12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <!DOCTYPE html>
- <html lang="zh">
- <head>
- <meta charset="utf-8" />
- <base href="../../../" />
- <script src="page.js"></script>
- <link type="text/css" rel="stylesheet" href="page.css" />
- </head>
- <body>
- [page:Texture] →
- <h1>[name]</h1>
- <p class="desc">从原始数据(raw data)、宽(width)、高(height)来直接创建一个纹理贴图。</p>
- <h2>构造函数</h2>
- <h3>[name]( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy )</h3>
- <p>
- data 参数必须是一个 [link:https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView ArrayBufferView] 。
- 其他参数对应于继承自 [page:Texture] 的属性,其中 magFilter 与 minFilter 默认为 THREE.NearestFilter。属性 flipY 和 generateMipmaps 初始设为 false。
- </p>
- <p>
- 数据的解释取决于type与format:
- If the type is THREE.UnsignedByteType, a Uint8Array will be useful for addressing the texel data.
- If the format is THREE.RGBAFormat, data needs four values for one texel; Red, Green, Blue and Alpha (typically the opacity). Similarly, THREE.RGBFormat specifies a format where only three values are used for each texel.<br />
- For the packed types, THREE.UnsignedShort4444Type, THREE.UnsignedShort5551Type or THREE.UnsignedShort565Type, all color components of one texel can be addressed as bitfields within an integer element of a Uint16Array.<br />
- In order to use the types THREE.FloatType and THREE.HalfFloatType, the WebGL implementation must support the respective extensions OES_texture_float and OES_texture_half_float. In order to use THREE.LinearFilter for component-wise, bilinear interpolation of the texels based on these types, the WebGL extensions OES_texture_float_linear or OES_texture_half_float_linear must also be present.
- </p>
- <h2>代码示例</h2>
- <code>
- // create a buffer with color data
- const width = 512;
- const height = 512;
- const size = width * height;
- const data = new Uint8Array( 3 * size );
- const color = new THREE.Color( 0xffffff );
- const r = Math.floor( color.r * 255 );
- const g = Math.floor( color.g * 255 );
- const b = Math.floor( color.b * 255 );
- for ( let i = 0; i < size; i ++ ) {
- const stride = i * 3;
- data[ stride ] = r;
- data[ stride + 1 ] = g;
- data[ stride + 2 ] = b;
- }
- // used the buffer to create a [name]
- const texture = new THREE.DataTexture( data, width, height, THREE.RGBFormat );
- </code>
- <h2>属性</h2>
- <p>
- See the base [page:Texture Texture] class for common properties.
- </p>
- <h3>[property:Image image]</h3>
- <p>
- Overridden with a record type holding data, width and height.
- </p>
- <h2>方法</h2>
- <p>
- See the base [page:Texture Texture] class for common methods.
- </p>
- <h2>源码</h2>
- <p>
- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
- </p>
- </body>
- </html>
|