I want to project the world position to screen. And i found Vector3.project(camera). But I got Infinity.
var geom = new THREE.SphereGeometry(0.1,30,30);
var mat = new THREE.MeshBasicMaterial({color: 0xffffff});
var mesh = new THREE.Mesh(geom, mat);
mesh.position.set(1,2,0);
scene.add(mesh);
var position = mesh.position.clone();
position.project(camera);
console.log(position)
So how to project world position to screen coordinate system correctly?
There is not a lot of documentation on the reason. If could tell briefly why one does need to do that before projecting a Vector please, that’d be helpful. Thanks.
related question: how about when you change the viewport as well? cause it doesn’t seem to work as expected if you set the viewport!
here the screenshots: