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

284
Views
THREE.js rotation to marked face

I have stuck with rotating objects in THREE.js. My situation looks like that. I click on the surface and I detect what triangle is it. Next, I get the normal vector of my selected triangles and the normal vector for my floor and I want to rotate the object so that the selected triangle lies on the floor. But always when I calculate Quaternion from my floor normal vector and triangle normal vector and I try to apply to my object, that rotation is completely wrong.

let triangleNormal: Vector3 = new Vector3();
triangle.getNormal(triangleNormal);
console.log('Triangle normal', triangleNormal);

const normals = floor.geometry.getAttribute('normal');
const floorNormal = new Vector3();
floorNormal.fromBufferAttribute(normals, i);

const quaternion = new THREE.Quaternion();
quaternion.setFromUnitVectors(floorNormal, triangleNormal);
targetObject.applyQuaternion(quaternion);

Does someone have an idea what I'm doing wrong?

about 4 years ago · Santiago Trujillo
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!