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

247
Views
How to move camera forward along horizontal with ThreeJS

I have a three.js program, where when I press the "w" key it moves the camera forward.

if (keys.indexOf(playerControls["forward"]) != -1) {
    camera.translateZ(-0.1);
}

However, I want the camera to not move vertically at all, but just horizontally (x and z axes move when "w" is pressed, but y axis is ignored). How would I be able to do this? (without a bunch of trig)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The translateZ is important to move the camera in the direction you're facing, but you can easily fix the Y position by correcting it after each movement:

const camHeight = 5;

if (keys.indexOf(playerControls["forward"]) != -1) {
    camera.translateZ(-0.1);
    camera.position.y = camHeight;
}
about 4 years ago · Juan Pablo Isaza Report
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!