updateState()

in modules/layers/src/imagery-layer/imagery-layer.js [99:138]


  updateState({props, oldProps, changeFlags}) {
    const {gl} = this.context;
    const {model} = this.state;

    const {heightMap, imagery, uCount, vCount} = props;
    if (heightMap && heightMap !== oldProps.heightMap) {
      getTexture(gl, heightMap).then(texture => {
        model.setUniforms({heightMapTexture: texture, hasHeightMap: true});
      });
    }
    if (imagery !== oldProps.imagery) {
      this.setState({imageLoaded: false});
      getTexture(gl, imagery).then(texture => {
        this.setState({imageLoaded: true});
        model.setUniforms({imageryTexture: texture});
      });
    }
    if (uCount !== oldProps.uCount || vCount !== oldProps.vCount) {
      const geometry = new GridGeometry({uCount, vCount});
      model.setGeometry(geometry);
    }
    if (changeFlags.propsChanged) {
      const {
        heightMapBounds,
        heightRange,
        imageryBounds,
        desaturate,
        transparentColor,
        tintColor
      } = props;
      model.setUniforms({
        heightMapBounds,
        heightRange,
        imageryBounds,
        desaturate,
        transparentColor,
        tintColor
      });
    }
  }