I am rotating an entity with this code, where angMult is just a script attribute to vary the size. Because it is using Euler angles, I’m not sure how to stop when the entity rotates to a particular 90 degree point. The y value simple starts reversing, while x and z go to 180. Is there a ‘right way’ to do this? I just want to rotate an item 180 degrees, but stop at that point. The pause is just so I can see each set of rotate values.
Though for performance you should use .lengthSq() to avoid a recursive square root. Also my scratchQ is a global variable to stop there being lots of garbage collection caused by allocating a new Quat each time the function is called - but this means it’s value is overwritten each time the function is called. If for some reason you needed to store it you would do someQuaternionToStoreAnswer.copy(rotationDifference(this.entity.getLocalRotation(), someStopPoint))
someStopPoint might be declared like this: var someStopPoint = new pc.Quat(); someStopPoint.setFromEulerAngles(0,90,0);