1
0

CubeTexture.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { Texture } from './Texture.js';
  2. import { CubeReflectionMapping, RGBFormat } from '../constants.js';
  3. function CubeTexture( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {
  4. images = images !== undefined ? images : [];
  5. mapping = mapping !== undefined ? mapping : CubeReflectionMapping;
  6. format = format !== undefined ? format : RGBFormat;
  7. Texture.call( this, images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
  8. this.flipY = false;
  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. }
  19. CubeTexture.prototype = Object.create( Texture.prototype );
  20. CubeTexture.prototype.constructor = CubeTexture;
  21. CubeTexture.prototype.isCubeTexture = true;
  22. Object.defineProperty( CubeTexture.prototype, 'images', {
  23. get: function () {
  24. return this.image;
  25. },
  26. set: function ( value ) {
  27. this.image = value;
  28. }
  29. } );
  30. export { CubeTexture };
粤ICP备19079148号