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