• 3dTiles 最后一块拼图:几何误差与屏幕空间误差


    // Cesium3DTile.js Cesium3DTile.prototype.getScreenSpaceError()
    Cesium3DTile.prototype.getScreenSpaceError = function (
      frameState,
      useParentGeometricError,
      progressiveResolutionHeightFraction
    ) {
      var tileset = this._tileset;
      var heightFraction = defaultValue(progressiveResolutionHeightFraction, 1.0);
      var parentGeometricError = defined(this.parent)
        ? this.parent.geometricError
        : tileset._geometricError;
      var geometricError = useParentGeometricError
        ? parentGeometricError
        : this.geometricError;
      if (geometricError === 0.0) {
        // Leaf tiles do not have any error so save the computation
        return 0.0;
      }
      var camera = frameState.camera;
      var frustum = camera.frustum;
      var context = frameState.context;
      var width = context.drawingBufferWidth;
      var height = context.drawingBufferHeight * heightFraction;
      var error;
      if (
        frameState.mode === SceneMode.SCENE2D ||
        frustum instanceof OrthographicFrustum
      ) {
        if (defined(frustum._offCenterFrustum)) {
          frustum = frustum._offCenterFrustum;
        }
        var pixelSize =
          Math.max(frustum.top - frustum.bottom, frustum.right - frustum.left) /
          Math.max(width, height);
        error = geometricError / pixelSize;
      } else {
        // Avoid divide by zero when viewer is inside the tile
        var distance = Math.max(this._distanceToCamera, CesiumMath.EPSILON7);
        var sseDenominator = camera.frustum.sseDenominator;
        error = (geometricError * height) / (distance * sseDenominator);
        if (tileset.dynamicScreenSpaceError) {
          var density = tileset._dynamicScreenSpaceErrorComputedDensity;
          var factor = tileset.dynamicScreenSpaceErrorFactor;
          var dynamicError = CesiumMath.fog(distance, density) * factor;
          error -= dynamicError;
        }
      }
    
      error /= frameState.pixelRatio;
    
      return error;
    };
    

    上述源码是获取当前 Tile 的屏幕空间误差的,在这里,可以很直观看出 几何误差 与 屏幕空间误差 的关系。
    屏幕空间误差是指当前摄像机状态下(如果是2D,那么就是当前高度的视角下),实时计算出来的一个值
    而几何误差,则用于计算当前状态下的屏幕空间误差,见这两行:

    error = geometricError / pixelSize;
    
    error = (geometricError * height) / (distance * sseDenominator);
    

    而具体的这个屏幕空间误差的含义,待后续研究。

  • 相关阅读:
    运维自动化-Ansible
    YARN 的深入简出
    HDFS 总结
    IDEA 创建HDFS项目 JAVA api
    解决 HDFS 开发 java.lang.IllegalArgumentException: java.net.UnknownHostException: hadoop000
    hadoop深入简出(二)
    大数据hadoop的伪分布式搭建
    anaconda的安装tensorflow
    switch只跟在这些之后
    jsp页面之初体验
  • 原文地址:https://www.cnblogs.com/onsummer/p/13357226.html
Copyright © 2020-2023  润新知