AABB
AlignmentBehavior
ArriveBehavior
AStar
BFS
BoundingSphere
BVH
BVHNode
Cell
CellSpacePartitioning
CohesionBehavior
CompositeGoal
ConvexHull
Corridor
CostTable
DFS
Dijkstra
Edge
EntityManager
EvadeBehavior
EventDispatcher
Behavior
FollowPathBehavior
FuzzyAND
FuzzyCompositeTerm
FuzzyFAIRLY
FuzzyModule
FuzzyOR
FuzzyRule
FuzzySet
FuzzyTerm
FuzzyVariable
FuzzyVERY
GameEntity
Goal
GoalEvaluator
Graph
GraphUtils
HalfEdge
HeuristicPolicyDijkstra
HeuristicPolicyEuclid
HeuristicPolicyEuclidSquared
HeuristicPolicyManhattan
InterposeBehavior
LeftSCurveFuzzySet
LeftShoulderFuzzySet
LineSegment
Logger
MathUtils
Matrix3
Matrix4
MemoryRecord
MemorySystem
MeshGeometry
MessageDispatcher
MovingEntity
NavEdge
NavMesh
NavMeshLoader
NavNode
Node
NormalDistFuzzySet
OBB
ObstacleAvoidanceBehavior
OffsetPursuitBehavior
OnPathBehavior
Path
Plane
Polygon
Polyhedron
PriorityQueue
PursuitBehavior
Quaternion
Ray
RectangleTriggerRegion
Regular
RightSCurveFuzzySet
RightShoulderFuzzySet
SAT
SeekBehavior
SeparationBehavior
SingletonFuzzySet
Smoother
SphericalTriggerRegion
State
StateMachine
SteeringBehavior
SteeringManager
Task
TaskQueue
Telegram
Think
Time
TriangularFuzzySet
Trigger
TriggerRegion
Vector3
Vehicle
Version
WanderBehavior

getWorldDirection

该方法用于获取MovingEntity在世界坐标系中的朝向向量。

语法

MovingEntity.getWorldDirection()

返回值

  • Type: Vector3

返回MovingEntity在世界坐标系中朝向的向量。

示例

let entity = new MovingEntity(); // 创建MovingEntity实例
let direction = entity.getWorldDirection(); // 获取在世界坐标系中的朝向向量
console.log(direction); // Vector3 {x: 0, y: 0, z: -1} (示例结果可能有所不同)

备注

MovingEntity的朝向是通过rotation属性表示的欧拉角,getWorldDirection方法通过该欧拉角计算得到在世界坐标系中的朝向向量。

对于未设置欧拉角的MovingEntity实例,getWorldDirection将返回Z轴负方向的单位向量。

本方法只能用于MovingEntity实例,不能直接用于Three.js场景中的其他对象。