Data3DTexture.html 4.0 KB

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