Reputation: 9169
I'm trying to implement a moving camera in THREE like so:
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
}
At the line marked, I get the following error:
Uncaught TypeError: undefined is not a function
However, there is an example of it on this page? I'm currently using a local copy of this THREE build.
Any help would be great!
Upvotes: 1
Views: 2853
Reputation: 4400
You're getting that error because the controls are not part of the main source. If you want to use the controls, you probably need to include them separately. See this related post.
Upvotes: 1