Skip to content

Commit

Permalink
Docs: Add example to DataTexture
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 committed Nov 20, 2017
1 parent 1ac876f commit f1bac35
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/api/textures/DataTexture.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,33 @@ <h3>[name]( data, width, height, format, type, mapping, wrapS, wrapT, magFilter,
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.
</div>

<h2>Example</h2>

<code>
// create a buffer with color data

var size = width * height;
var data = new Uint8Array( 3 * size );

var r = Math.floor( color.r * 255 );
var g = Math.floor( color.g * 255 );
var b = Math.floor( color.b * 255 );

for ( var i = 0; i < size; i ++ ) {

var stride = i * 3;

data[ stride ] = r;
data[ stride + 1 ] = g;
data[ stride + 2 ] = b;

}

// used the buffer to create a [name]

var texture = new THREE.DataTexture( data, width, height, THREE.RGBFormat );
</code>

<h2>Properties</h2>

<h3>[property:Image image]</h3>
Expand Down

0 comments on commit f1bac35

Please sign in to comment.