Three.js在相机移动时渲染循环冻结

时间:2014-02-02 07:15:21

标签: javascript three.js

这是我的代码:(我使用THREEx,keyboardstate.js输入btw)

camera.forward = new THREE.Vector3(0, 0, -1).applyMatrix4(camera.matrixWorld).sub(camera.position).normalize();
camera.right = new THREE.Vector3(-1, 0, 0).applyMatrix4(camera.matrixWorld).sub(camera.position).normalize();

if (keys.pressed('W')) {
    camera.position.add(camera.forward.multiplyScalar(2).multiplyScalar(clock.getDelta())); 
}
if (keys.pressed('S')) {
    camera.position.add(camera.forward.subVectors(new THREE.Vector3(0, 0, 1), camera.forward).normalize().multiplyScalar(2).multiplyScalar(clock.getDelta()));  
}
if (keys.pressed('Q')) {
    camera.rotation.y += 0.3 * clock.getDelta();
}
if (keys.pressed('E')) {
    camera.rotation.y -= 0.3 * clock.getDelta();
}

if (light.position.x >= 3) {
    negative = true;
} else if (light.position.x <= -3) {
    negative = false;
}

if (negative) {
    light.position.x -= 0.5 * clock.getDelta();
} else {
    light.position.x += 0.5 * clock.getDelta();
}

我的问题是,当我按下W,S,Q或E时,指示灯会停止移动吗?就好像场景因为相机以任何方式移动/旋转而冻结。

提前致谢!

0 个答案:

没有答案