2
0

DataArrayTexture.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <!DOCTYPE html>
  2. <html lang="it">
  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. Crea un array di texture direttamente da dati grezzi, dalla larghezza, dall'altezza e dalla profondità.
  14. Questo tipo di texture può solo essere utilizzata in un contesto di rendering WebGL 2.
  15. </p>
  16. <h2>Costruttore</h2>
  17. <h3>[name]( data, width, height, depth )</h3>
  18. <p>
  19. L'argomento data deve essere un [link:https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView ArrayBufferView].
  20. Le proprietà ereditate da [page:Texture] sono predefinite, eccetto magFilter e minFilter per impostazione predefinita THREE.NearestFilter.
  21. Le proprietà flipY e generateMipmaps sono inizialmente impostate a false.
  22. </p>
  23. <p>
  24. L'interpretazione dei dati dipende dal tipo e dal formato:
  25. Se il tipo è THREE.UnsignedByteType, un Uint8Array sarà utile per indirizzare i dati texel.
  26. Se il formato è THREE.RGBAFormat, i dati necessitano di quattro valori per un texel; Rosso, Verde, Blu e Alfa (tipicamente l'opacità).<br />
  27. Per i tipi compressi, THREE.UnsignedShort4444Type e THREE.UnsignedShort5551Type tutti i componenti di colore di un texel possono essere
  28. indirizzati come campi di bit all'interno di un elemento intero di un Uint16Array.<br />
  29. Per utilizzare i tipi THREE.FloatType e THREE.HalfFloatType, l'implementazione WebGL deve supportare le
  30. rispettive estensioni OES_texture_float e OES_texture_half_float.
  31. Per utilizzare THREE.LinearFilter per l'interpolazione bilineare component-wise dei texel basati
  32. su questi tipi, devono essere presenti anche le estensioni WebGL OES_texture_float_linear o OES_texture_half_float_linear.
  33. </p>
  34. <h2>Codice di Esempio</h2>
  35. <p>Crea un [name] dove ogni texture ha un colore diverso.</p>
  36. <code>
  37. // crea un buffer con i dati del colore
  38. const width = 512;
  39. const height = 512;
  40. const depth = 100;
  41. const size = width * height;
  42. const data = new Uint8Array( 4 * size * depth );
  43. for ( let i = 0; i < depth; i ++ ) {
  44. const color = new THREE.Color( Math.random(), Math.random(), Math.random() );
  45. const r = Math.floor( color.r * 255 );
  46. const g = Math.floor( color.g * 255 );
  47. const b = Math.floor( color.b * 255 );
  48. for ( let j = 0; j < size; j ++ ) {
  49. const stride = ( i * size + j ) * 4;
  50. data[ stride ] = r;
  51. data[ stride + 1 ] = g;
  52. data[ stride + 2 ] = b;
  53. data[ stride + 3 ] = 255;
  54. }
  55. }
  56. // utilizza il buffer per creare un [name]
  57. const texture = new THREE.DataArrayTexture( data, width, height, depth );
  58. texture.needsUpdate = true;
  59. </code>
  60. <h2>Esempi</h2>
  61. <p>
  62. [example:webgl2_materials_texture2darray WebGL2 / materials / texture2darray]
  63. </p>
  64. <h2>Proprietà</h2>
  65. <p>
  66. Vedi la classe base [page:Texture Texture] per le proprietà comuni.
  67. </p>
  68. <h3>[property:Object image]</h3>
  69. <p>
  70. Sostituito con un tipo di record contenente dati, larghezza, altezza e profondità.
  71. </p>
  72. <h2>Metodi</h2>
  73. <p>
  74. Vedi la classe base [page:Texture Texture] per i metodi comuni.
  75. </p>
  76. <h2>Source</h2>
  77. <p>
  78. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  79. </p>
  80. </body>
  81. </html>