Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

303
Vistas
Why does camera Y position change sporadically with PointerLockControls in Three.js?

I'm currently working on a first person 3D game in javascript using Three.js. I'm using PointerLockControls to control camera movement, and for some reason, the camera seems to be jumping around randomly on the Y axis. It's not noticable in the game itself but if I print out camera.position in my render loop, it changes sporadically. I'm using WASD to call controls.moveForward() and controls.moveRight() which shouldn't affect Y position (I think, correct me if I'm wrong) but it changes nonetheless. This is the code of interest:

var controls = new THREE.PointerLockControls(camera, document.body);
document.onclick = function () {
    controls.lock();
}

function loop() {
            if (wDown) {
                controls.moveForward(0.1);
            }
            if (sDown) {
                controls.moveForward(-0.1);
            }
            if (dDown) {
                controls.moveRight(0.1);
            }
            if (aDown) {
                controls.moveRight(-0.1);
            }
            // printing out camera position
            console.log(camera.position);
            renderer.render(scene, camera);
            requestAnimationFrame(loop);
}

Edit: I should note, the Y position only changes when I move using WASD.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda