mrdoob/three.js — Issue #1277: rendering datatexture
Author: gibo
Created: 2012-02-08 17:15:38+00:00
State: open

Currently trying to create a datatexture, made up of blue pixels and then applied to a sphere...However, the scene does not render.

Is this a problem with my code? or a bug?

When trying to render with a loaded image texture, it works fine (line 4)

var textureWidth = 1250;
var textureHeight = 625;

sphere = new THREE.SphereGeometry( 500, 60, 40 );
//map = THREE.ImageUtils.loadTexture( 'img.jpg' );

var size = textureWidth * textureHeight;
var dataColor = new Uint8Array( size * 3 );
for (var i = 0; i < size; i ++) {
dataColor[ i * 3 ] = 0;
dataColor[ i * 3 + 1 ] = 0;
dataColor[ i * 3 + 2 ] = 255;
}
map = new THREE.DataTexture(dataColor, textureWidth, textureHeight, THREE.RGBFormat );
map.needsUpdate = true;

material = new THREE.MeshBasicMaterial( { wireframe: false, map: map } )
mesh = new THREE.Mesh( sphere, material );
mesh.scale.x = -1;
sceneRT.add( mesh );