CubeTexture.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { Texture } from './Texture.js';
  2. import { CubeReflectionMapping } from '../constants.js';
  3. /**
  4. * Creates a cube texture made up of six images.
  5. *
  6. * ```js
  7. * const loader = new THREE.CubeTextureLoader();
  8. * loader.setPath( 'textures/cube/pisa/' );
  9. *
  10. * const textureCube = loader.load( [
  11. * 'px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png'
  12. * ] );
  13. *
  14. * const material = new THREE.MeshBasicMaterial( { color: 0xffffff, envMap: textureCube } );
  15. * ```
  16. *
  17. * @augments Texture
  18. */
  19. class CubeTexture extends Texture {
  20. /**
  21. * Constructs a new cube texture.
  22. *
  23. * @param {Array<Image>} [images=[]] - An array holding a image for each side of a cube.
  24. * @param {number} [mapping=CubeReflectionMapping] - The texture mapping.
  25. * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value.
  26. * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value.
  27. * @param {number} [magFilter=LinearFilter] - The mag filter value.
  28. * @param {number} [minFilter=LinearMipmapLinearFilter] - The min filter value.
  29. * @param {number} [format=RGBAFormat] - The texture format.
  30. * @param {number} [type=UnsignedByteType] - The texture type.
  31. * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value.
  32. * @param {string} [colorSpace=NoColorSpace] - The color space value.
  33. */
  34. constructor( images = [], mapping = CubeReflectionMapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, colorSpace ) {
  35. super( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, colorSpace );
  36. /**
  37. * This flag can be used for type testing.
  38. *
  39. * @type {boolean}
  40. * @readonly
  41. * @default true
  42. */
  43. this.isCubeTexture = true;
  44. /**
  45. * If set to `true`, the texture is flipped along the vertical axis when
  46. * uploaded to the GPU.
  47. *
  48. * Overwritten and set to `false` by default.
  49. *
  50. * @type {boolean}
  51. * @default false
  52. */
  53. this.flipY = false;
  54. }
  55. /**
  56. * Alias for {@link CubeTexture#image}.
  57. *
  58. * @type {Array<Image>}
  59. */
  60. get images() {
  61. return this.image;
  62. }
  63. set images( value ) {
  64. this.image = value;
  65. }
  66. }
  67. export { CubeTexture };
粤ICP备19079148号