为什么不能使用FirstpersonVrControls?

时间:2017-05-21 15:00:39

标签: three.js

代码在VR oculus中工作得很好,只是第一人移动不起作用。我怎么能卖掉这个问题?

controls = new THREE.VRControls( camera );
var fpVrControls = new THREE.FirstPersonVRControls(camera, scene);

fpVrControls.verticalMovement = true;
...



function animate(timestamp) {

    vrControls.update(); //when I paste this line scene doesn't work
    fpVrControls.update(timestamp); //when I paste this line scene doesn't work

    effect.requestAnimationFrame( animate );
    render();

}

1 个答案:

答案 0 :(得分:0)

vrControls.update();

vrControls至少在此范围内为undefined。您在此行中使用controlscontrols = new THREE.VRControls( camera );,而不是vrControls

因此,除非您在代码中的其他地方定义vrControls,否则会引发错误,说update() is not a function of undefined

另外,我无法看到你的HTML,因为你没有包含它,但是THREE.VRcontrols不在核心的three.js或three.min.js中,所以你需要手动包含它。它位于\examples\js\controls

下的threejs-master包中

修改

始终检查控制台。它没有定义,因为它没有加载。 enter image description here