我正在构建一个地球仪(球体几何形状),其中包含一组在地理映射上预定义的位置并绘制为点(球体几何形状)。我想通过沿 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;
我想,我对这个概念还不够理解。希望我能从社区获得一些想法。
最佳答案
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(或球体)
关于javascript - 三人组 : Rotate sphere(globe) to another point(city) on the sphere itself,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17474185/