get method

Texture? get(
  1. Texture? texture
)

Implementation

Texture? get(Texture? texture) {
  if (texture != null && texture.isRenderTargetTexture == false) {
    final mapping = texture.mapping;

    if (mapping == EquirectangularReflectionMapping || mapping == EquirectangularRefractionMapping) {
      if (cubemaps.has(texture)) {
        final cubemap = cubemaps.get(texture).texture;
        return mapTextureMapping(cubemap, texture.mapping);
      }
      else {
        final image = texture.image;

        if (image != null && image.height > 0) {
          final renderTarget = WebGLCubeRenderTarget(image.height ~/ 2);
          renderTarget.fromEquirectangularTexture(renderer, texture);
          cubemaps.add(key: texture, value: renderTarget);

          texture.addEventListener('dispose', onTextureDispose);

          return mapTextureMapping(renderTarget.texture, texture.mapping);
        }
        else {
          // image not yet ready. try the conversion next frame
          return null;
        }
      }
    }
  }

  return texture;
}