Data3DTexture.html 4.1 KB

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