簡體   English   中英

使用鼠標圍繞中心旋轉Three.js相機

[英]Rotate Three.js camera around center using mouse

我正在嘗試使用鼠標圍繞中心點(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));

一個最小的示例在這里: https : //jsfiddle.net/qsor9w27/2/

我認為最簡單的方法是使用OrbitControlsTrackballControls

請參見使用OrbitControls的此示例

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM