Currently I am working on a project in THREE.JS and I am encountering an issue with projecting a Vector3. When attempting to project the Vector3 (0,0,0), which should ideally appear at the center of my camera screen, I receive NaN as the result. Surprisingly, other Vector3s that are all visible (though visibility shouldn't impact this, right?) are returning values like NaN, 0, Infinity, and various random numbers between -1 and 0 most of the time. Below is a snippet of the code I am using:
camera.position.x=32;
camera.position.y=32;
camera.position.z=32;
camera.lookAt(new THREE.Vector3(0,0,0));
for(var x=0;x<=16;x++)
{
for(var z=0;z<=16;z++)
{
var p=new THREE.Vector3(x,0,z).project(camera);
alert(p.x+" "+p.y+" "+p.z);
//I'm stuck here!!!
}
}
Any help or guidance would be greatly appreciated :)