CubeTexture.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { Texture } from './Texture.js';
  2. import { CubeReflectionMapping, RGBFormat } from '../constants.js';
  3. class CubeTexture extends Texture {
  4. constructor( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {
  5. images = images !== undefined ? images : [];
  6. mapping = mapping !== undefined ? mapping : CubeReflectionMapping;
  7. format = format !== undefined ? format : RGBFormat;
  8. super( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
  9. // Why CubeTexture._needsFlipEnvMap is necessary:
  10. //
  11. // By convention -- likely based on the RenderMan spec from the 1990's -- cube maps are specified by WebGL (and three.js)
  12. // in a coordinate system in which positive-x is to the right when looking up the positive-z axis -- in other words,
  13. // in a left-handed coordinate system. By continuing this convention, preexisting cube maps continued to render correctly.
  14. // three.js uses a right-handed coordinate system. So environment maps used in three.js appear to have px and nx swapped
  15. // and the flag _needsFlipEnvMap controls this conversion. The flip is not required (and thus _needsFlipEnvMap is set to false)
  16. // when using WebGLCubeRenderTarget.texture as a cube texture.
  17. this._needsFlipEnvMap = true;
  18. this.flipY = false;
  19. }
  20. get images() {
  21. return this.image;
  22. }
  23. set images( value ) {
  24. this.image = value;
  25. }
  26. }
  27. CubeTexture.prototype.isCubeTexture = true;
  28. export { CubeTexture };
粤ICP备19079148号