All files / engine/Source/Scene/Model ImageryInput.js

0% Statements 0/5
100% Branches 0/0
0% Functions 0/1
0% Lines 0/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61                                                                                                                         
/**
 * A structure summarizing the input for the shader that is draping imagery
 * over 3D Tiles, as part of the <code>ImageryPipelineStage</code>.
 *
 * The <code>ImageryPipelineStage</code> receives the primitive, and their
 * <code>ModelPrimitiveImagery</code> objects. These objects provide the
 * <code>ImageryCoverage</code> information, indicating the set of imagery
 * tiles that are covered by the primitive.
 *
 * The <code>ImageryPipelineStage</code> uses the <code>ImageryCoverage</code>
 * to fetch the <code>Imagery</code> object and its texture for the (x, y, level)
 * of each coverage, computes the texture translation and scale, and the covered
 * texture coordinate rectangle of that imagery texture.
 *
 * This information is summarized in an instance of this class, to later
 * be passed to the shader via uniforms.
 *
 * @private
 */
class ImageryInput {
  /**
   * Creates a new instance
   *
   * @param {ImageryLayer} imageryLayer The imagery layer
   * @param {Texture} texture The texture from the imagery
   * @param {Cartesian4} textureTranslationAndScale The translation
   * and scale that have to be applied to the texture, to properly
   * be draped on the primitive. This is stored as a Cartesian4
   * with (x,y) being the translation and (z,w) being the scale.
   * It could be cleaner and clearer to store this as separate
   * Cartesian2 objects, but using a single Cartesian4 probably
   * was a design choice that was originally made in GlobeFS.glsl,
   * with the goal to have fewer uniforms
   * @param {Cartesian4} textureCoordinateRectangle The bounding
   * rectangle (in texture coordinates). This directly corresponds
   * to the <code>ImageryCoverage.textureCoordinateRectangle</code>,
   * but converted into a Cartesian4 for the consumption in the
   * shader
   * @param {number} imageryTexCoordAttributeSetIndex The "set index"
   * of the texture coordinate attribute that should be used. This
   * will be used to access the texture coordinate attribute
   * <code>a_imagery_texCoord_${imageryTexCoordAttributeSetIndex}</code>
   * in the shader.
   */
  constructor(
    imageryLayer,
    texture,
    textureTranslationAndScale,
    textureCoordinateRectangle,
    imageryTexCoordAttributeSetIndex,
  ) {
    this.imageryLayer = imageryLayer;
    this.texture = texture;
    this.textureTranslationAndScale = textureTranslationAndScale;
    this.textureCoordinateRectangle = textureCoordinateRectangle;
    this.imageryTexCoordAttributeSetIndex = imageryTexCoordAttributeSetIndex;
  }
}
 
export default ImageryInput;