three.js 3D坐标转化为2D屏幕坐标

来源:互联网 发布:visio网络图库下载 编辑:程序博客网 时间:2024/05/17 01:26
//创建一个3D坐标var vector = new THREE.Vector3();  //获取模型var obj = scene.getObjectByName(modelName);vector = vector.setFromMatrixPosition(obj.matrixWorld).project(camera);               var halfWidth = window.innerWidth / 2;  var halfHeight = window.innerHeight / 2;  console.log(vector.x * halfWidth + halfWidth)var result = {      x: Math.round(vector.x * halfWidth + halfWidth),      y: Math.round(-vector.y * halfHeight + halfHeight)};  //2D坐标console.log(result)
阅读全文
0 0
原创粉丝点击