mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
add angle property for 2d (#7515)
* add angle property * add angle api doc
This commit is contained in:
@@ -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 世界坐标系下的旋转,用四元数表示
|
||||
|
||||
Reference in New Issue
Block a user