Reputation: 3052
I have a set of points stored in a giant string, with newline characters \n separating one point from the next. Each point is stored as x y z r g b, where r g b are values ranging from 0-255.
According to the ThreeJS docs, it is possible to do this:
var color = new THREE.Color("rgb(255,0,0)");
However, my points still show up as all white in my ThreeJS viewer. What am I doing wrong? Code is as follows:
var cloud = data.split('\n');
for (var i=0; i<cloud.length; i++) {
var colour = 'rgb(' + pt[3] + ',' + pt[4] + ',' + pt[5] + ')';
model.vertices.push( new THREE.Vector3(x, y, z) );
colours.push( new THREE.Color(colour) );
}
Upvotes: 0
Views: 2964
Reputation: 3052
I realised what my mistake was: I forgot to parse points 3 to 5 as floats.
This fixed it:
var colour = 'rgb(' + parseFloat(pt[3]) + ',' + parseFloat(pt[4]) + ',' + parseFloat(pt[5]) + ')';
Upvotes: 2