WebGLCubeRenderTarget constructor

WebGLCubeRenderTarget([
  1. int size = 1,
  2. WebGLRenderTargetOptions? options
])

Implementation

WebGLCubeRenderTarget([int size = 1, WebGLRenderTargetOptions? options]) : super(size, size, options) {
  // By convention -- likely based on the RenderMan spec from the 1990's -- cube maps are specified by WebGL (and three.js)
  // in a coordinate system in which positive-x is to the right when looking up the positive-z axis -- in other words,
  // in a left-handed coordinate system. By continuing this convention, preexisting cube maps continued to render correctly.

  // three.js uses a right-handed coordinate system. So environment maps used in three.js appear to have px and nx swapped
  // and the flag isRenderTargetTexture controls this conversion. The flip is not required when using WebGLCubeRenderTarget.texture
  // as a cube texture (this is detected when isRenderTargetTexture is set to true for cube textures).
  final image = ImageElement(width: size, height: size, depth: 1);
  final images = [image, image, image, image, image, image];

  texture = CubeTexture(
    images,
    this.options.mapping,
    this.options.wrapS,
    this.options.wrapT,
    this.options.magFilter,
    this.options.minFilter,
    this.options.format,
    this.options.type,
    this.options.anisotropy,
    this.options.colorSpace
  );
  texture.isRenderTargetTexture = true;

  texture.generateMipmaps = this.options.generateMipmaps;
  texture.minFilter = this.options.minFilter ?? LinearFilter;
}