Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

302
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!