项目链接(源内联): http://neveronti.me/WalkingSimulator/
我的相机旋转功能:
//Rotates camera horizontally
y-=mouseMove.x*.02;
//rotates camera vertically
//checks to see if it's moving camera up or down
if(mouseMove.y<0){
//checks that it's not at the bottom or top
if(Math.abs(camera.rotation.y*(180/Math.PI))>2 || camera.rotation.x<=0){
x-=mouseMove.y*.02;
}
} else if(mouseMove.y>0) {
if(Math.abs(camera.rotation.y*(180/Math.PI))>2 || camera.rotation.x>=0){
x-=mouseMove.y*.02;
}
}
我的更新相机功能:
function updateCamera(){
camera.lastRotation=camera.quaternion.clone();
var euler = new THREE.Euler( 0, 0, 0, 'YXZ' );
euler.x = x;
euler.y = y;
euler.z = z;
mouseMove.x=0;
mouseMove.y=0;
camera.quaternion.setFromEuler( euler );
}
问题的图片: