我正在构建一个地球仪(球体几何体),在地理地图上绘制一组预定义的位置并绘制为点(球体几何体)。我想通过沿y轴旋转地球来聚焦(将一个位置移动到另一个位置)这些位置。我尝试了以下代码,似乎并不适用于所有位置。
location.geometry.computeBoundingBox();
var position = new THREE.Vector3();
position.subVectors( location.geometry.boundingBox.max, location.geometry.boundingBox.min );
position.multiplyScalar( 0.20 );
position.sub( location.geometry.boundingBox.min );
location.matrixWorld.multiplyVector3( position );
var point1 = scene.clone().position;
var point2 = position;
var distance = point1.distanceTo( point2 );
locationCollection.rotation.y = distance;
我想,我对这个概念不够了解。希望我能从社区中得到一些想法。
答案 0 :(得分:1)
var c = group.rotation.y;
var d = -b * (Math.PI / 180)%(2 * Math.PI);
var e = Math.PI / 2 * -1;
group.rotation.y = c % (2 * Math.PI);
group.rotation.x = a * (Math.PI / 180) % Math.PI;
group.rotation.y= d+e;
其中a =纬度,b =经度,group = Object3D(或球体)