gpt4 book ai didi

javascript - 三人组 : Rotate sphere(globe) to another point(city) on the sphere itself

转载 作者:行者123 更新时间:2023-11-28 02:08:11 25 4
gpt4 key购买 nike

我正在构建一个地球仪(球体几何形状),其中包含一组在地理映射上预定义的位置并绘制为点(球体几何形状)。我想通过沿 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;

我想,我对这个概念还不够理解。希望我能从社区获得一些想法。

Fiddle

最佳答案

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com