From 8ceb4beae778eeaf3fd3a4b440dedc8a0d970579 Mon Sep 17 00:00:00 2001 From: troublemaker52025 Date: Thu, 10 Jun 2021 11:58:06 +0800 Subject: [PATCH] add node.up && node.right (#8643) * add node.up && node.right * modify comments * modify comments * update * Update cocos/core/scene-graph/node.ts Co-authored-by: Santy-Wang * Update cocos/core/scene-graph/node.ts Co-authored-by: Santy-Wang * Update cocos/core/scene-graph/node.ts Co-authored-by: Santy-Wang * Update cocos/core/scene-graph/node.ts Co-authored-by: Santy-Wang Co-authored-by: Santy-Wang --- cocos/core/scene-graph/node.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cocos/core/scene-graph/node.ts b/cocos/core/scene-graph/node.ts index 0cbb23ef03..3f9beb7a79 100644 --- a/cocos/core/scene-graph/node.ts +++ b/cocos/core/scene-graph/node.ts @@ -423,6 +423,22 @@ export class Node extends BaseNode { this.setWorldRotation(q_a); } + /** + * @en Return the up direction vertor of this node in world space. + * @zh 返回当前节点在世界空间中朝上的方向向量 + */ + get up (): Vec3 { + return Vec3.transformQuat(new Vec3(), Vec3.UP, this.worldRotation); + } + + /** + * @en Return the right direction vector of this node in world space. + * @zh 返回当前节点在世界空间中朝右的方向向量 + */ + get right (): Vec3 { + return Vec3.transformQuat(new Vec3(), Vec3.RIGHT, this.worldRotation); + } + /** * @en Layer of the current Node, it affects raycast, physics etc, refer to [[Layers]] * @zh 节点所属层,主要影响射线检测、物理碰撞等,参考 [[Layers]]