如何让相机围绕一个点旋转?我开始这样做,但是当 phi = 90 和 -90 时我遇到了一些问题,并且以这种旋转方式我不会滚动相机
theta = - ( ( event.clientX - lastLeft ) * 360 /window.innerWidth ) + onMouseDownTheta;
phi = ( ( event.clientY - lastTop ) * 360 /window.innerHeight ) + onMouseDownPhi;
var cosPhi = Math.cos( phi * Math.PI / 180 );
var sinPhi = Math.sin( phi * Math.PI / 180 );
var sinTheta = Math.sin( theta * Math.PI / 180 );
var cosTheta = Math.cos( theta * Math.PI / 180 );
camera.position.x = - radious * sinTheta * cosPhi;
camera.position.y = radious * sinPhi;
camera.position.z = radious * cosTheta * cosPhi;
camera.lookAt(new THREE.Vector3(0,0,0))
if(phi > 90){
u = u*(-1);
camera.up = new THREE.Vector3(0, u, 0);
}
camera.updateMatrix();