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

146
Views
Check if rotation of model has changed?

How would you check if the rotation of a model has changed? tried:

 var oldRotate = this._target.quaternion;
  console.log('works returns vector3 quaternion: ', oldRotate);
   var newRotate = oldRotate;

      if (oldRotate != newRotate) {
             console.log('this isnt triggering');
     }

this doesn't work and yes it's in a 'loop'

also tried:

 var oldRotation = new THREE.Vector3();
      oldRotation.copy(controlObject.quaternion);
      
      controlObject.position.copy(pos);
      this._position.copy(pos);
  
      this._parent.SetPosition(this._position);
      this._parent.SetQuaternion(this._target.quaternion);
   
  
  
       var newRotation = new THREE.Vector3();
          newRotation.copy(controlObject.quaternion);
  
   console.log(oldRotation.equals(newRotation));

any ideas?

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

0

You can't compare objects for equality using the ==/!= operator. This will merely compare the references to the objects, not their values. You will need to compare using the .equals method.

Also, in your example, you're assigning oldR to newRotate directly. I'm not sure if you've not included some intervening code. Either way, you should also be using .clone otherwise the != will never happen.

See: https://threejs.org/docs/#api/en/math/Quaternion for information about the clone and equals methods.

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!