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

102
Views
Three JS rotate model towards xyz position

I'm trying to rotate an object in Three JS towards a fixed xyz location within a space. Currently I'm able to achieve it like this:

var position_x  = -0.85;
var position_z  = -4.44;

model.lookAt(position_x, 0, position_z);

However the lookAt() function rotates the model instantly and I would like to rotate the model more slowly. Is there a way to accomplish this using built in Three JS functions?

Thanks!

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

0

Is there a way to accomplish this using built in Three JS functions?

Yes, you can use Quaternion.rotateTowards() which works similar to Unity's Quaternion.rotateTowards() method.

The idea is to compute a target orientation which is represented by a quaternion. You can do this by using Matrix4.lookAt() and then create a quaternion based on this matrix via Quaternion.setFromRotationMatrix().

Next, you compute an angular step per frame the will define how much your object is turned towards the target. The computation of step looks like so:

const step = speed * delta;

delta is the time delta value in seconds and speed represents the turn rate of our model in radians per second.

A complete code example is available is here:

https://threejs.org/examples/webgl_math_orientation_transform

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!