diff --git a/cocos/core/vmath/mat4.ts b/cocos/core/vmath/mat4.ts index 224d437e77..fddb92a923 100644 --- a/cocos/core/vmath/mat4.ts +++ b/cocos/core/vmath/mat4.ts @@ -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); } diff --git a/cocos/core/vmath/quat.ts b/cocos/core/vmath/quat.ts index 2c5ab16a81..220d897da9 100644 --- a/cocos/core/vmath/quat.ts +++ b/cocos/core/vmath/quat.ts @@ -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; } diff --git a/cocos/scene-graph/node.ts b/cocos/scene-graph/node.ts index 5e05095c26..376c63355d 100644 --- a/cocos/scene-graph/node.ts +++ b/cocos/scene-graph/node.ts @@ -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, });