[page:Texture] →

[name]

Crea un array di texture direttamente da dati grezzi, dalla larghezza, dall'altezza e dalla profondità. Questo tipo di texture può solo essere utilizzata in un contesto di rendering WebGL 2.

Costruttore

[name]( data, width, height, depth )

L'argomento data deve essere un [link:https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView ArrayBufferView]. Le proprietà ereditate da [page:Texture] sono predefinite, eccetto magFilter e minFilter per impostazione predefinita THREE.NearestFilter. Le proprietà flipY e generateMipmaps sono inizialmente impostate a false.

L'interpretazione dei dati dipende dal tipo e dal formato: Se il tipo è THREE.UnsignedByteType, un Uint8Array sarà utile per indirizzare i dati texel. Se il formato è THREE.RGBAFormat, i dati necessitano di quattro valori per un texel; Rosso, Verde, Blu e Alfa (tipicamente l'opacità).
Per i tipi compressi, THREE.UnsignedShort4444Type e THREE.UnsignedShort5551Type tutti i componenti di colore di un texel possono essere indirizzati come campi di bit all'interno di un elemento intero di un Uint16Array.
Per utilizzare i tipi THREE.FloatType e THREE.HalfFloatType, l'implementazione WebGL deve supportare le rispettive estensioni OES_texture_float e OES_texture_half_float. Per utilizzare THREE.LinearFilter per l'interpolazione bilineare component-wise dei texel basati su questi tipi, devono essere presenti anche le estensioni WebGL OES_texture_float_linear o OES_texture_half_float_linear.

Codice di Esempio

Crea un [name] dove ogni texture ha un colore diverso.

// crea un buffer con i dati del colore const width = 512; const height = 512; const depth = 100; const size = width * height; const data = new Uint8Array( 4 * size * depth ); for ( let i = 0; i < depth; i ++ ) { const color = new THREE.Color( Math.random(), Math.random(), Math.random() ); const r = Math.floor( color.r * 255 ); const g = Math.floor( color.g * 255 ); const b = Math.floor( color.b * 255 ); for ( let j = 0; j < size; j ++ ) { const stride = ( i * size + j ) * 4; data[ stride ] = r; data[ stride + 1 ] = g; data[ stride + 2 ] = b; data[ stride + 3 ] = 255; } } // utilizza il buffer per creare un [name] const texture = new THREE.DataArrayTexture( data, width, height, depth ); texture.needsUpdate = true;

Esempi

[example:webgl2_materials_texture2darray WebGL2 / materials / texture2darray]

Proprietà

Vedi la classe base [page:Texture Texture] per le proprietà comuni.

[property:Image image]

Sostituito con un tipo di record contenente dati, larghezza, altezza e profondità.

Metodi

Vedi la classe base [page:Texture Texture] per i metodi comuni.

Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]