THREE.PointerLockControls()返回“undefined不是函数”

时间:2014-02-17 20:49:21

标签: javascript three.js

我正试图在三个中实现移动相机:

function initThree(){
    scene = new THREE.Scene();
    camera = new THREE.PerspectiveCamera(75,window.innerWidth/window.innerHeight,0.1,1000);
    renderer = new THREE.CanvasRenderer();
    renderer.setSize(window.innerWidth,window.innerHeight);
    document.body.appendChild(renderer.domElement);
    geometry = new THREE.CubeGeometry(1,1,1);
    material = new THREE.MeshBasicMaterial({color:0x00ff00});
    cube = new THREE.Mesh(geometry,material);
    scene.add(cube);
    camera.position.z=5;
    controls = new THREE.PointerLockControls(camera); //fails at this line

}

在标记的行上,我收到以下错误:

Uncaught TypeError: undefined is not a function 

但是,在this页面上有一个例子吗?我目前正在使用this三个版本的本地副本。

任何帮助都会很棒!

1 个答案:

答案 0 :(得分:1)

您收到该错误是因为controls不属于main source。如果要使用控件,可能需要单独包含它们。请参阅此related post