Search code examples
three.jspointerlock

How to initiate Three.js PointerLockControls when camera is not at origin?


I am trying to use PointerLockControls in my three.js game and I want my player to start from another point but not from origin.

Let's say I want to start playing from 1000,0,0. If I place: camera.position.set(1000, 0, 0) in line 193 in http://threejs.org/examples/#misc_controls_pointerlock

then the example shows a weird behavior: When I move the mouse the camera is orbiting around origin with a radius of 1000. I would expect to start first person view from 1000,0,0. How to achieve that?


Solution

  • I found it my self. Controls should be moved, not the camera.

    Just add

    controls.getObject().position.set(1000, 0, 0);
    

    in line 204 and it works fine.