2
0

DataArrayTexture.html 3.2 KB

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