不适用控制器实现(WASD)控制移动方向,核心代码如下:
if (front) {
camera.position.z += vect.dot(new THREE.Vector3(0, 0, 15)) * 0.01;
camera.position.x += vect.dot(new THREE.Vector3(15, 0, 0)) * 0.01;
}
if (back) {
camera.position.z -= vect.dot(new THREE.Vector3(0, 0, 15)) * 0.01;
camera.position.x -= vect.dot(new THREE.Vector3(15, 0, 0)) * 0.01;
}
if (right) {
camera.position.z -= vect.dot(new THREE.Vector3(15, 15, 0)) * 0.01;
camera.position.x -= vect.dot(new THREE.Vector3(0,15, 15)) * 0.01;
}
if (left) {
camera.position.z += vect.dot(new THREE.Vector3(15, 15, 0)) * 0.01;
camera.position.x += vect.dot(new THREE.Vector3(0,15, 15)) * 0.01;
}
效果如下:
仅仅记录一下!!需要源码和引用文件的留邮箱发送!!