Threejs:将球体(地球仪)旋转到球体本身的另一个点(城市) [英] Threejs: Rotate sphere(globe) to another point(city) on the sphere itself

查看:101
本文介绍了Threejs:将球体(地球仪)旋转到球体本身的另一个点(城市)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个地球(球体几何),其中包含一组预定义的地理地图位置并绘制为点(球体几何).我想通过沿 y 轴旋转地球来聚焦(将一个位置移动到另一个位置)这些位置.我尝试了以下代码,似乎不适用于所有位置.

I'm building a globe(sphere geometry) with set of predefined locations on geo-mapped and drawn as point(sphere geometry). I would like to focus(moving one location to another) those locations by rotating globe along y-axis. I tried the following code, seems not working for all locations.

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;

我想,我对这个概念还不够了解.希望我能从社区中得到一些想法.

I think, I don't understand the concept enough. Hopefully, I will get some idea from the community.

小提琴

推荐答案

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(或球体)

where a= latitude, b= longitude,group=Object3D(or sphere)

这篇关于Threejs:将球体(地球仪)旋转到球体本身的另一个点(城市)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆