webGL 旋转算法

lon = 0,//y旋转角度
lat = 0, onMouseDownLat = 0,
phi = 0, theta = 0;

 

if ( isUserInteracting === false ) {

lon += 0.1;

}

lat = Math.max( - 85, Math.min( 85, lat ) );
phi = THREE.Math.degToRad( 90 - lat );
theta = THREE.Math.degToRad( lon );

camera.target.x = 500 * Math.sin( phi ) * Math.cos( theta );
camera.target.y = 500 * Math.cos( phi );
camera.target.z = 500 * Math.sin( phi ) * Math.sin( theta );

camera.lookAt( camera.target );

posted @ 2017-01-19 15:28  ~噜啦啦~  阅读(403)  评论(0编辑  收藏  举报