当前位置: 代码迷 >> JavaScript >> Three.JS 从世界坐标系变换到屏幕坐标系
  详细解决方案

Three.JS 从世界坐标系变换到屏幕坐标系

热度:208   发布时间:2013-04-21 15:31:38.0
Three.JS 从世界坐标系转换到屏幕坐标系
var projector = new THREE.Projector();

var world_vector = new THREE.Vector3(0,0,1);

var vector = projector.projectVector(world_vector, camera);

var halfWidth = window.innerWidth / 2;
var halfHeight = window.innerHeight / 2;

var result = {

	x: Math.round(vector.x * halfWidth + halfWidth),
	y: Math.round(-vector.y * halfHeight + halfHeight)

};

?

  相关解决方案