0
鼠标coortinates我想创建一个交互式全景像这样的:three.js所得到的质地
http://mrdoob.github.io/three.js/examples/webgl_panorama_equirectangular.html
,但我想,让用户与它进行交互。
是否可以从鼠标移动中的纹理获取坐标以创建类似三维图像映射的three.js?
谢谢!
鼠标coortinates我想创建一个交互式全景像这样的:three.js所得到的质地
http://mrdoob.github.io/three.js/examples/webgl_panorama_equirectangular.html
,但我想,让用户与它进行交互。
是否可以从鼠标移动中的纹理获取坐标以创建类似三维图像映射的three.js?
谢谢!
检查:Translating mouse location to Object coordinates
当发现三角形射线相交,你可以收集该三角形顶点的三维坐标和UV的。您有足够的数据来计算交点的UV位置。
伪代码:
x0 = mouse.x; y0 = mouse.y;
vec3 samplePoint = unproject(x0, y0); // returns (x, y, near-plane-z) coords
ray.origin = camera.position;
ray.direction = samplePoint - camera.position;
var triangleComplexObj = check_for_intersections(scene, ray); // returns triangle, it's vertices and their UV and 3d coord and intersection coord
calulateUV(triangleComplexObj , triangleComplexObj.intersectionPoint);
这也许有点复杂的理解,但应该做的伎俩。希望这可以帮助。
我已经做了这样的事情,但射线脚轮返回一个没有价值的数组。这是我的代码: var samplePoint = new THREE.Vector3(x0,y0,0); var raycast = new THREE.Raycaster(o.camera.position,samplePoint.sub(o.camera.position)); var raycast = new THREE.Raycaster(o.camera.position,samplePoint.sub(o.camera.position)); \t \t \t \t \t var c = raycast.intersectObject(o.mesh,false); console.log(c); – 2013-05-08 18:21:01
我认为raycaster.intersectObject返回一个空数组的原因是因为相机在球体内 – 2013-05-08 18:48:28