2
0

Data3DTexture.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. [page:Texture] &rarr;
  11. <h1>[name]</h1>
  12. <p class="desc">
  13. Creates a three-dimensional texture from raw data, with parameters to
  14. divide it into width, height, and depth. This type of texture can only be
  15. used with a WebGL 2 rendering context.
  16. </p>
  17. <h2>Constructor</h2>
  18. <h3>
  19. [name]( [param:TypedArray data], [param:Number width], [param:Number height], [param:Number depth] )
  20. </h3>
  21. <p>
  22. [page:Object data] --
  23. [link:https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView ArrayBufferView] of the texture.<br />
  24. [page:Number width] -- width of the texture.<br />
  25. [page:Number height] -- height of the texture.<br />
  26. [page:Number depth] -- depth of the texture.
  27. </p>
  28. <h2>Code Example</h2>
  29. <p>This creates a [name] with repeating data, 0 to 255</p>
  30. <code>
  31. // create a buffer with some data
  32. const sizeX = 64;
  33. const sizeY = 64;
  34. const sizeZ = 64;
  35. const data = new Uint8Array( sizeX * sizeY * sizeZ );
  36. let i = 0;
  37. for ( let z = 0; z < sizeZ; z ++ ) {
  38. for ( let y = 0; y < sizeY; y ++ ) {
  39. for ( let x = 0; x < sizeX; x ++ ) {
  40. data[ i ] = i % 256;
  41. i ++;
  42. }
  43. }
  44. }
  45. // use the buffer to create the texture
  46. const texture = new THREE.Data3DTexture( data, sizeX, sizeY, sizeZ );
  47. texture.needsUpdate = true;
  48. </code>
  49. <h2>Examples</h2>
  50. <p>
  51. [example:webgl2_materials_texture3d WebGL2 / materials / texture3d]<br />
  52. [example:webgl2_materials_texture3d_partialupdate WebGL2 / materials / texture3d / partialupdate]<br />
  53. [example:webgl2_volume_cloud WebGL2 / volume / cloud]<br />
  54. [example:webgl2_volume_perlin WebGL2 / volume / perlin]
  55. </p>
  56. <h2>Properties</h2>
  57. <p>See the base [page:Texture Texture] class for common properties.</p>
  58. <h3>[property:Boolean flipY]</h3>
  59. <p>
  60. Whether the texture is flipped along the Y axis when uploaded to the GPU.
  61. Default is `false`.
  62. </p>
  63. <h3>[property:Boolean generateMipmaps]</h3>
  64. <p>
  65. Whether to generate mipmaps (if possible) for the texture. Default is
  66. `false`.
  67. </p>
  68. <h3>[property:Image image]</h3>
  69. <p>
  70. Overridden with a record type holding data, width and height and depth.
  71. </p>
  72. <h3>[property:Boolean isData3DTexture]</h3>
  73. <p>Read-only flag to check if a given object is of type [name].</p>
  74. <h3>[property:number magFilter]</h3>
  75. <p>
  76. How the texture is sampled when a texel covers more than one pixel. The
  77. default is [page:Textures THREE.NearestFilter], which uses the value of
  78. the closest texel.<br /><br />
  79. See the [page:Textures texture constants] page for details.
  80. </p>
  81. <h3>[property:number minFilter]</h3>
  82. <p>
  83. How the texture is sampled when a texel covers less than one pixel. The
  84. default is [page:Textures THREE.NearestFilter], which uses the value of
  85. the closest texel.<br /><br />
  86. See the [page:Textures texture constants] page for details.
  87. </p>
  88. <h3>[property:number unpackAlignment]</h3>
  89. <p>
  90. `1` by default. Specifies the alignment requirements for the start of each
  91. pixel row in memory. The allowable values are 1 (byte-alignment), 2 (rows
  92. aligned to even-numbered bytes), 4 (word-alignment), and 8 (rows start on
  93. double-word boundaries). See
  94. [link:https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glPixelStorei.xhtml glPixelStorei] for more information.
  95. </p>
  96. <h3>[property:number wrapR]</h3>
  97. <p>
  98. This defines how the texture is wrapped in the depth direction.<br />
  99. The default is [page:Textures THREE.ClampToEdgeWrapping], where the edge
  100. is clamped to the outer edge texels. The other two choices are
  101. [page:Textures THREE.RepeatWrapping] and [page:Textures THREE.MirroredRepeatWrapping].
  102. See the [page:Textures texture constants] page for details.
  103. </p>
  104. <h2>Methods</h2>
  105. <p>See the base [page:Texture Texture] class for common methods.</p>
  106. <h2>Source</h2>
  107. <p>
  108. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  109. </p>
  110. </body>
  111. </html>