From 74e10b193be9b76dc163b1f88c3c6b9f8f78f7b1 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 2 Mar 2018 15:33:11 +0800 Subject: [PATCH] Fix quat not initialized issue --- cocos2d/core/CCNode.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index 915da020e9..031ae16fee 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -1055,10 +1055,14 @@ var Node = cc.Class({ this._scale.y = this._scaleY; this._scaleY = undefined; } - // Upgrade rotationX, rotationY from v1.x - // TODO: remove in future version, 3.0 ? - - + // TODO: remove _rotationX & _rotationY in future version, 3.0 ? + // Update quaternion from rotation + if (this._rotationX === this._rotationY) { + math.quat.fromEuler(this._quat, 0, 0, -this._rotationX); + } + else { + math.quat.fromEuler(this._quat, this._rotationX, this._rotationY, 0); + } var prefabInfo = this._prefab; if (prefabInfo && prefabInfo.sync && prefabInfo.root === this) {