mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
fix eulerAngle flip in animation editor (#4446)
This commit is contained in:
committed by
Weiliang Wang
parent
59b55d9260
commit
87f59ff193
@@ -1030,6 +1030,7 @@ class mat4 {
|
||||
/**
|
||||
* Decompose an affine matrix to a quaternion rotation, a translation offset and a scale vector.
|
||||
* Assumes the transformation is combined in the order of Scale -> Rotate -> Translate.
|
||||
* Not applicable when containing negative scaling.
|
||||
* @param m - Matrix to decompose.
|
||||
* @param q - Resulting rotation quaternion.
|
||||
* @param v - Resulting translation offset.
|
||||
@@ -1048,7 +1049,7 @@ class mat4 {
|
||||
m3_1.m06 = m.m08 / s.z;
|
||||
m3_1.m07 = m.m09 / s.z;
|
||||
m3_1.m08 = m.m10 / s.z;
|
||||
quat.normalize(q, quat.fromMat3(q, m3_1));
|
||||
quat.fromMat3(q, m3_1); // already normalized
|
||||
vec3.set(v, m.m12, m.m13, m.m14);
|
||||
}
|
||||
|
||||
|
||||
@@ -737,10 +737,10 @@ export default class quat {
|
||||
bank = Math.atan2(2 * x * w - 2 * y * z, 1 - 2 * sqx - 2 * sqz); // bank
|
||||
}
|
||||
|
||||
// Keep angles [0..360].
|
||||
out.y = toDegree(heading) + (heading < 0 ? 360 : 0);
|
||||
out.z = toDegree(attitude) + (attitude < 0 ? 360 : 0);
|
||||
out.x = toDegree(bank) + (bank < 0 ? 360 : 0);
|
||||
// ranged [-180, 180]
|
||||
out.y = toDegree(heading);
|
||||
out.z = toDegree(attitude);
|
||||
out.x = toDegree(bank);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -901,26 +901,6 @@ class Node extends BaseNode {
|
||||
}
|
||||
}
|
||||
|
||||
if (CC_EDITOR) {
|
||||
const repeat = (t: number, l: number) => t - Math.floor(t / l) * l;
|
||||
Object.defineProperty(Node.prototype, 'eulerAngles', {
|
||||
set (val: Vec3) {
|
||||
this.setRotationFromEuler(val.x, val.y, val.z);
|
||||
},
|
||||
get () {
|
||||
if (this._eulerDirty) {
|
||||
const eu = this._euler;
|
||||
quat.toEuler(v3_a, this._lrot);
|
||||
eu.x = repeat(v3_a.x - eu.x + 180, 360) + eu.x - 180;
|
||||
eu.y = repeat(v3_a.y - eu.y + 180, 360) + eu.y - 180;
|
||||
eu.z = repeat(v3_a.z - eu.z + 180, 360) + eu.z - 180;
|
||||
this._eulerDirty = false;
|
||||
}
|
||||
return this._euler;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Object.defineProperty(Node.prototype, 'position', {
|
||||
get: Node.prototype.getPosition,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user