Three.js Vector.project()给出了Infinity的值?

时间:2016-05-08 09:10:47

标签: javascript 3d three.js

有人能说清楚为什么我从{x:0.50516157,y:-0.62950189,z:0}这样的位置值得到{x:Infinity,y:-Infinity,z:-Infinity}的原因我正在尝试将我的位置矢量投影到相机上。我在此找到了类似的查询Converting World coordinates to Screen coordinates in Three.js using Projection,但解决方案并没有解决我的问题。如果有人可以帮助我,那将真正有助于充分和节省时间。

var screenvector = new THREE.Vector3();
var position = new THREE.Vector3();
position = convertLatLontoVec3(lat, lng).multiplyScalar(radius);
//convertLatLontoVec3(returns new THREE.Vector3(x, y, z);)
screenvector.copy(position);
//till here during debugging i can find the values of position.x, .y, .z 
screenvector.project(camera); //But once this step is executed all the values are becoming infintiy. I don't understand why is it happening. 

1 个答案:

答案 0 :(得分:3)

如果要投影“屏幕空间”矢量,则很可能是在 view / worldSpace 中的相机原点(图中的z == 0)。无限在这里有意义。您可能想取消投影

projecting from camera position

从z == 0开始,相机后面的任何东西都是无限的(我认为)。