How to get model rotation angle from 0 to 360 while using transform Controls

Hello, People I am trying to get model angle degree from 0 to 360 is there any way to do that,
I am using Transform Controls and when I rotate model I want to get angle from 0 to 360
I am struggling because of Euler gives me only range from 0 to 180 and -179 to 0 and I can’t detect model is on 0 degree or 360 degrees.
Advanced Thank You

1 Like

I think this should help? TransformControls rotation is done using quaternions, so it’s not that straightforward to read them.

I coped the code and this is what I have but still it is not woriking any Idea what am I doing wrong ?

if (mode === “rotate”) {
const euler = new THREE.Euler();
const rotation = euler.setFromQuaternion(this.picked_asset.quaternion);
console.log(rotation);
const radians = rotation.x > 0 ? rotation.x : 2 * Math.PI + rotation.x;
const degrees = THREE.Math.radToDeg(radians);

(1) But wait - you are trying to read the model rotation in transform controls, or write it to the model properties as an angle between 0 and 2π ? It looks like you are modifying control’s code - so just in case, second option is not possible (or not practical, at least.)

(2) Euler gives me only range from 0 to 180 and -179 to 0 - without copying the code, just apply it to what you’ve got there. If angle is between 0° and 180°, use that value as the rotation. If value is between -179° and 0°, add 360° (2π) to it - it will result in a properly adjusted angle (-90° will equal 270° etc.)

(3) Also:

0° is always equal 360° :thinking:

1 Like

thank you very much I found my bug

Would you tell us?

So the rotation is represented as @mjurczyk described you need to covert that. To recive it from 0-360