draw()

in showcases/wind/src/layers/wind-layer/wind-layer.js [78:146]


  draw({uniforms}) {
    // Return early if elevationTexture is not loaded.
    if (!this.state.elevationTexture) {
      return;
    }

    const {gl} = this.context;

    const {
      model,
      elevationTexture,
      textureFrom,
      textureTo,
      width,
      height,
      delta,
      timeInterval
    } = this.state;

    const {bbox, dataBounds, dataTextureArray} = this.props;
    const pixelStoreParameters = {
      [GL.UNPACK_FLIP_Y_WEBGL]: true
    };

    textureFrom.setImageData({
      pixels: dataTextureArray[timeInterval | 0],
      width,
      height,
      format: gl.RGBA32F,
      type: gl.FLOAT,
      dataFormat: gl.RGBA,
      parameters: pixelStoreParameters
    });

    textureTo.setImageData({
      pixels: dataTextureArray[timeInterval | (0 + 1)],
      width,
      height,
      format: gl.RGBA32F,
      type: gl.FLOAT,
      dataFormat: gl.RGBA,
      parameters: pixelStoreParameters
    });

    const parameters = {
      clearDepth: 1.0,
      depthTest: true,
      depthFunc: gl.LEQUAL
    };

    uniforms = Object.assign({}, uniforms, LIGHT_UNIFORMS, {
      bbox: [bbox.minLng, bbox.maxLng, bbox.minLat, bbox.maxLat],
      size: [width, height],
      delta,
      bounds0: [dataBounds[0].min, dataBounds[0].max],
      bounds1: [dataBounds[1].min, dataBounds[1].max],
      bounds2: [dataBounds[2].min, dataBounds[2].max],
      dataFrom: textureFrom,
      dataTo: textureTo,
      elevationTexture,
      elevationBounds: ELEVATION_DATA_BOUNDS,
      elevationRange: ELEVATION_RANGE
    });

    model.draw({uniforms, parameters});

    // onAfterRender
    gl.bindTexture(gl.TEXTURE_2D, null);
  }