Source/Core/TerrainEncoding.js
/**
 * Data used to quantize and pack the terrain mesh. The position can be unpacked for picking and all attributes
 * are unpacked in the vertex shader.
 *
 * @alias TerrainEncoding
 * @constructor
 *
 * @param {AxisAlignedBoundingBox} axisAlignedBoundingBox The bounds of the tile in the east-north-up coordinates at the tiles center.
 * @param {Number} minimumHeight The minimum height.
 * @param {Number} maximumHeight The maximum height.
 * @param {Matrix4} fromENU The east-north-up to fixed frame matrix at the center of the terrain mesh.
 * @param {Boolean} hasVertexNormals If the mesh has vertex normals.
 * @param {Boolean} [hasWebMercatorT=false] true if the terrain data includes a Web Mercator texture coordinate; otherwise, false.
 *
 * @private
 */
Data used to quantize and pack the terrain mesh. The position can be unpacked for picking and all attributes
are unpacked in the vertex shader.



@param {AxisAlignedBoundingBox} axisAlignedBoundingBox The bounds of the tile in the east-north-up coordinates at the tiles center.
@param {Number} minimumHeight The minimum height.
@param {Number} maximumHeight The maximum height.
@param {Matrix4} fromENU The east-north-up to fixed frame matrix at the center of the terrain mesh.
@param {Boolean} hasVertexNormals If the mesh has vertex normals.
@param {Boolean} [hasWebMercatorT=false] true if the terrain data includes a Web Mercator texture coordinate; otherwise, false.

@private
Data used to quantize and pack the terrain mesh . The position can be unpacked for picking and all attributes are unpacked in the vertex shader . @param { AxisAlignedBoundingBox } axisAlignedBoundingBox The bounds of the tile in the east - north - up coordinates at the tiles center . @param { Number } minimumHeight The minimum height . @param { Number } maximumHeight The maximum height . @param { Matrix4 } fromENU The east - north - up to fixed frame matrix at the center of the terrain mesh . @param { Boolean } hasVertexNormals If the mesh has vertex normals . @param { Boolean } [ hasWebMercatorT = false ] true if the terrain data includes a Web Mercator texture coordinate ; otherwise false . @private
function TerrainEncoding(
  axisAlignedBoundingBox,
  minimumHeight,
  maximumHeight,
  fromENU,
  hasVertexNormals,
  hasWebMercatorT
) {
  var quantization = TerrainQuantization.NONE;
  var center;
  var toENU;
  var matrix;
  if (
    defined(axisAlignedBoundingBox) &&
    defined(minimumHeight) &&
    defined(maximumHeight) &&
    defined(fromENU)
  ) {
    var minimum = axisAlignedBoundingBox.minimum;
    var maximum = axisAlignedBoundingBox.maximum;
    var dimensions = Cartesian3.subtract(
      maximum,
      minimum,
      cartesian3DimScratch
    );
    var hDim = maximumHeight - minimumHeight;
    var maxDim = Math.max(Cartesian3.maximumComponent(dimensions), hDim);
    if (maxDim < SHIFT_LEFT_12 - 1.0) {
      quantization = TerrainQuantization.BITS12;
    } else {
      quantization = TerrainQuantization.NONE;
    }
    center = axisAlignedBoundingBox.center;
    toENU = Matrix4.inverseTransformation(fromENU, new Matrix4());
    var translation = Cartesian3.negate(minimum, cartesian3Scratch);
    Matrix4.multiply(
      Matrix4.fromTranslation(translation, matrix4Scratch),
      toENU,
      toENU
    );
    var scale = cartesian3Scratch;
    scale.x = 1.0 / dimensions.x;
    scale.y = 1.0 / dimensions.y;
    scale.z = 1.0 / dimensions.z;
    Matrix4.multiply(Matrix4.fromScale(scale, matrix4Scratch), toENU, toENU);
    matrix = Matrix4.clone(fromENU);
    Matrix4.setTranslation(matrix, Cartesian3.ZERO, matrix);
    fromENU = Matrix4.clone(fromENU, new Matrix4());
    var translationMatrix = Matrix4.fromTranslation(minimum, matrix4Scratch);
    var scaleMatrix = Matrix4.fromScale(dimensions, matrix4Scratch2);
    var st = Matrix4.multiply(translationMatrix, scaleMatrix, matrix4Scratch);
    Matrix4.multiply(fromENU, st, fromENU);
    Matrix4.multiply(matrix, st, matrix);
  }
  this.quantization = quantization;
  this.minimumHeight = minimumHeight;
  this.maximumHeight = maximumHeight;
  this.center = center;
  this.toScaledENU = toENU;
  this.fromScaledENU = fromENU;
  this.matrix = matrix;
  this.hasVertexNormals = hasVertexNormals;
  this.hasWebMercatorT = defaultValue(hasWebMercatorT, false);
}
function TerrainEncoding ( axisAlignedBoundingBox , minimumHeight , maximumHeight , fromENU , hasVertexNormals , hasWebMercatorT ) { var quantization = TerrainQuantization . NONE ; var center ; var toENU ; var matrix ; if ( defined ( axisAlignedBoundingBox ) && defined ( minimumHeight ) && defined ( maximumHeight ) && defined ( fromENU ) ) { var minimum = axisAlignedBoundingBox . minimum ; var maximum = axisAlignedBoundingBox . maximum ; var dimensions = Cartesian3 . subtract ( maximum , minimum , cartesian3DimScratch ) ; var hDim = maximumHeight - minimumHeight ; var maxDim = Math . max ( Cartesian3 . maximumComponent ( dimensions ) , hDim ) ; if ( maxDim < SHIFT_LEFT_12 - 1.0 ) { quantization = TerrainQuantization . BITS12 ; } else { quantization = TerrainQuantization . NONE ; } center = axisAlignedBoundingBox . center ; toENU = Matrix4 . inverseTransformation ( fromENU , new Matrix4 ( ) ) ; var translation = Cartesian3 . negate ( minimum , cartesian3Scratch ) ; Matrix4 . multiply ( Matrix4 . fromTranslation ( translation , matrix4Scratch ) , toENU , toENU ) ; var scale = cartesian3Scratch ; scale . x = 1.0 / dimensions . x ; scale . y = 1.0 / dimensions . y ; scale . z = 1.0 / dimensions . z ; Matrix4 . multiply ( Matrix4 . fromScale ( scale , matrix4Scratch ) , toENU , toENU ) ; matrix = Matrix4 . clone ( fromENU ) ; Matrix4 . setTranslation ( matrix , Cartesian3 . ZERO , matrix ) ; fromENU = Matrix4 . clone ( fromENU , new Matrix4 ( ) ) ; var translationMatrix = Matrix4 . fromTranslation ( minimum , matrix4Scratch ) ; var scaleMatrix = Matrix4 . fromScale ( dimensions , matrix4Scratch2 ) ; var st = Matrix4 . multiply ( translationMatrix , scaleMatrix , matrix4Scratch ) ; Matrix4 . multiply ( fromENU , st , fromENU ) ; Matrix4 . multiply ( matrix , st , matrix ) ; } this . quantization = quantization ; this . minimumHeight = minimumHeight ; this . maximumHeight = maximumHeight ; this . center = center ; this . toScaledENU = toENU ; this . fromScaledENU = fromENU ; this . matrix = matrix ; this . hasVertexNormals = hasVertexNormals ; this . hasWebMercatorT = defaultValue ( hasWebMercatorT , false ) ; }
Data used to quantize and pack the terrain mesh.
Data used to quantize and pack the terrain mesh .
/**
   * How the vertices of the mesh were compressed.
   * @type {TerrainQuantization}
   */ /**
   * The minimum height of the tile including the skirts.
   * @type {Number}
   */ /**
   * The maximum height of the tile.
   * @type {Number}
   */ /**
   * The center of the tile.
   * @type {Cartesian3}
   */ /**
   * A matrix that takes a vertex from the tile, transforms it to east-north-up at the center and scales
   * it so each component is in the [0, 1] range.
   * @type {Matrix4}
   */ /**
   * A matrix that restores a vertex transformed with toScaledENU back to the earth fixed reference frame
   * @type {Matrix4}
   */ /**
   * The matrix used to decompress the terrain vertices in the shader for RTE rendering.
   * @type {Matrix4}
   */ /**
   * The terrain mesh contains normals.
   * @type {Boolean}
   */ /**
   * The terrain mesh contains a vertical texture coordinate following the Web Mercator projection.
   * @type {Boolean}
   */