add angle property for 2d (#7515)

* add angle property

* add angle api doc
This commit is contained in:
yinkaile
2020-10-30 15:20:11 +08:00
committed by GitHub
parent fb7f42af8c
commit a39badcfea
+19
View File
@@ -206,6 +206,25 @@ export class Node extends BaseNode {
return this._euler;
}
/**
* @en Rotation in local coordinate system, represented by euler angles, but limited on z axis
* @zh 本地坐标系下的旋转,用欧拉角表示,但是限定在 z 轴上。
*/
@editable
get angle () {
return this._euler.z;
}
set angle (val: number) {
Vec3.set(this._euler, 0, 0, val);
Quat.fromAngleZ(this._lrot, val);
this._eulerDirty = false;
this.invalidateChildren(TransformBit.ROTATION);
if (this._eventMask & TRANSFORM_ON) {
this.emit(SystemEventType.TRANSFORM_CHANGED, TransformBit.ROTATION);
}
}
/**
* @en Rotation in world coordinate system, represented by a quaternion
* @zh 世界坐标系下的旋转,用四元数表示