Skip to content

Commit

Permalink
fixed setWorldPosition & setWorldScale (#5109)
Browse files Browse the repository at this point in the history
* fixed setWorldPosition & setWorldScale

* add worldEulerAngles
  • Loading branch information
2youyou2 committed Aug 8, 2019
1 parent a8a28b9 commit 2cec6a3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
21 changes: 21 additions & 0 deletions cocos2d/core/3d/polyfill-3d.js
Expand Up @@ -231,6 +231,27 @@ cc.js.getset(proto, 'z', function () {
}
});

if (CC_EDITOR) {
let vec3_tmp = cc.v3();
cc.js.getset(proto, 'worldEulerAngles', function () {
let angles = cc.v3(this._eulerAngles);
let parent = this.parent;
while (parent) {
angles.addSelf(parent._eulerAngles);
parent = parent.parent;
}
return angles;
}, function (v) {
vec3_tmp.set(v);
let parent = this.parent;
while (parent) {
vec3_tmp.subSelf(parent._eulerAngles);
parent = parent.parent;
}
this.eulerAngles = vec3_tmp;
});
}

cc.js.getset(proto, 'eulerAngles', function () {
if (CC_EDITOR) {
return this._eulerAngles;
Expand Down
4 changes: 2 additions & 2 deletions cocos2d/core/CCNode.js
Expand Up @@ -2650,7 +2650,7 @@ let NodeDefines = {
else {
vec3.copy(_swpVec3, pos);
}
trs.toPosition(_swpVec3, ltrs);
trs.fromPosition(ltrs, _swpVec3);
this.setLocalDirty(LocalDirtyFlag.POSITION);

// fast check event
Expand Down Expand Up @@ -2736,7 +2736,7 @@ let NodeDefines = {
else {
vec3.copy(_swsVec3, scale);
}
trs.fromScale(_swsVec3, this._trs);
trs.fromScale(this._trs, _swsVec3);
this.setLocalDirty(LocalDirtyFlag.SCALE);
},

Expand Down

0 comments on commit 2cec6a3

Please sign in to comment.