我有一個球,我需要轉換成鼠標點擊的經度和緯度轉換鼠標點擊的經度和緯度上旋轉球
一切只要工作細如無旋轉的球,但如果有任何旋轉 - 我得到錯誤的結果
這裏是我的代碼:
var mouse = new THREE.Vector2();
mouse.x = (event.pageX/window.innerWidth) * 2 - 1;
mouse.y = -(event.pageY/window.innerHeight) * 2 + 1;
var raycaster = new THREE.Raycaster();
raycaster.setFromCamera(mouse, camera);
var intersects = raycaster.intersectObject(EarthSphere);
if (intersects.length!=1) return;
var pointOnSphere = new THREE.Vector3();
pointOnSphere.x = intersects[0].point.x;
pointOnSphere.y = intersects[0].point.y;
pointOnSphere.z = intersects[0].point.z;
var EarthRadius = 20;
var lat = 90 - (Math.acos(pointOnSphere.y/EarthRadius)) * 180/Math.PI;
var lon = ((90 + (Math.atan2(pointOnSphere.x , pointOnSphere.z)) * 180/Math.PI) % 360) - 180;
我居興,我需要根據EarthSphere以某種方式操縱pointOnSphere,任何想法?
EDITED
earth.updateMatrixWorld(真); pointOnSphere = earth.localToWorld(pointOnSphere.clone());
我覺得像下面將工作:
EarthSphere.updateMatrixWorld(true);
pointOnSphere = EarthSphere.localToWorld(pointOnSphere.clone());
但它不工作..
你有旋轉矩陣嗎? – Rabbid76
的EarthSphere是網狀,所以EarthSphere.matrix? – user1732451