I have integrated THREE.PointerLockControls
into my project following the implementation demonstrated in this example (view code). The code seems to be accurately translated from the example, but I am facing issues with deceleration of the controller once it starts moving. Additionally, the acceleration of my controller is much slower compared to the example. Below is a snippet of the code containing the logic for my controller, which has been simplified from my original code.
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 35);
var controls = new THREE.PointerLockControls(camera);
scene.add( controls.getObject() );
var ray = new THREE.Raycaster();
var renderer = new THREE.WebGLRenderer();
var clock = new THREE.Clock();
var objects = [];
var block3Dsize = 5;
var blocker = document.getElementById( 'blocker' );
var instructions = document.getElementById( 'instructions' );
// Pointer Lock API implementation
var havePointerLock = 'pointerLockElement' in document || 'mozPointerLockElement' in document || 'webkitPointerLockElement' in document;
if ( havePointerLock ) {
// Event handlers for pointer lock state change and error
}
init();
animate();
function init(){
// Initialize scene elements
}
function animate() {
requestAnimationFrame( animate );
// Intersection detection and movement update
}
In addition, is there a way to specify the position of the controller/camera combination? Setting
controller.getObject().position.x = 10
does not seem to work.
Thank you!