Data3DTexture.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import { Texture } from './Texture.js';
  2. import { ClampToEdgeWrapping, NearestFilter } from '../constants.js';
  3. /**
  4. * Creates a three-dimensional texture from raw data, with parameters to
  5. * divide it into width, height, and depth.
  6. *
  7. * @augments Texture
  8. */
  9. class Data3DTexture extends Texture {
  10. /**
  11. * Constructs a new data array texture.
  12. *
  13. * @param {?TypedArray} [data=null] - The buffer data.
  14. * @param {number} [width=1] - The width of the texture.
  15. * @param {number} [height=1] - The height of the texture.
  16. * @param {number} [depth=1] - The depth of the texture.
  17. */
  18. constructor( data = null, width = 1, height = 1, depth = 1 ) {
  19. // We're going to add .setXXX() methods for setting properties later.
  20. // Users can still set in Data3DTexture directly.
  21. //
  22. // const texture = new THREE.Data3DTexture( data, width, height, depth );
  23. // texture.anisotropy = 16;
  24. //
  25. // See #14839
  26. super( null );
  27. /**
  28. * This flag can be used for type testing.
  29. *
  30. * @type {boolean}
  31. * @readonly
  32. * @default true
  33. */
  34. this.isData3DTexture = true;
  35. /**
  36. * The image definition of a data texture.
  37. *
  38. * @type {{data:TypedArray,width:number,height:number,depth:number}}
  39. */
  40. this.image = { data, width, height, depth };
  41. /**
  42. * How the texture is sampled when a texel covers more than one pixel.
  43. *
  44. * Overwritten and set to `NearestFilter` by default.
  45. *
  46. * @type {(NearestFilter|NearestMipmapNearestFilter|NearestMipmapLinearFilter|LinearFilter|LinearMipmapNearestFilter|LinearMipmapLinearFilter)}
  47. * @default NearestFilter
  48. */
  49. this.magFilter = NearestFilter;
  50. /**
  51. * How the texture is sampled when a texel covers less than one pixel.
  52. *
  53. * Overwritten and set to `NearestFilter` by default.
  54. *
  55. * @type {(NearestFilter|NearestMipmapNearestFilter|NearestMipmapLinearFilter|LinearFilter|LinearMipmapNearestFilter|LinearMipmapLinearFilter)}
  56. * @default NearestFilter
  57. */
  58. this.minFilter = NearestFilter;
  59. /**
  60. * This defines how the texture is wrapped in the depth and corresponds to
  61. * *W* in UVW mapping.
  62. *
  63. * @type {(RepeatWrapping|ClampToEdgeWrapping|MirroredRepeatWrapping)}
  64. * @default ClampToEdgeWrapping
  65. */
  66. this.wrapR = ClampToEdgeWrapping;
  67. /**
  68. * Whether to generate mipmaps (if possible) for a texture.
  69. *
  70. * Overwritten and set to `false` by default.
  71. *
  72. * @type {boolean}
  73. * @default false
  74. */
  75. this.generateMipmaps = false;
  76. /**
  77. * If set to `true`, the texture is flipped along the vertical axis when
  78. * uploaded to the GPU.
  79. *
  80. * Overwritten and set to `false` by default.
  81. *
  82. * @type {boolean}
  83. * @default false
  84. */
  85. this.flipY = false;
  86. /**
  87. * Specifies the alignment requirements for the start of each pixel row in memory.
  88. *
  89. * Overwritten and set to `1` by default.
  90. *
  91. * @type {boolean}
  92. * @default 1
  93. */
  94. this.unpackAlignment = 1;
  95. }
  96. }
  97. export { Data3DTexture };
粤ICP备19079148号