Javascript 使用鼠标围绕中心旋转Three.js摄影机

Javascript 使用鼠标围绕中心旋转Three.js摄影机,javascript,3d,three.js,Javascript,3d,Three.js,我尝试使用鼠标围绕中心点0、0、0旋转相机,但如果我向右或向左旋转180度,则尝试向上或向下旋转,它根本不会垂直旋转 我尝试使用纬度/经度坐标,然后将其转换为笛卡尔坐标,如: this.camera.position.x = Math.sin(this.lat) * this.alt; this.camera.position.z = Math.cos(this.lat) * Math.cos(this.lng) * this.alt; this.camera.position.y = Math

我尝试使用鼠标围绕中心点0、0、0旋转相机,但如果我向右或向左旋转180度,则尝试向上或向下旋转,它根本不会垂直旋转

我尝试使用纬度/经度坐标,然后将其转换为笛卡尔坐标,如:

this.camera.position.x = Math.sin(this.lat) * this.alt;
this.camera.position.z = Math.cos(this.lat) * Math.cos(this.lng) * this.alt;
this.camera.position.y = Math.cos(this.lat) * Math.sin(this.lng) * this.alt;
this.camera.lookAt(new THREE.Vector3(0, 0, 0));

这里有一个最简单的例子:

我认为最简单的方法是使用或


看看哪个在使用轨道控制。

是的,但我更愿意自己做,这样我才能理解它是如何工作的。我明白了:使用怎么样,它已经在Three.js中了,并且它用来有球坐标,可能对你的相机和你的极角φ问题更好?