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

applyRotation

说明

applyRotation方法用于将当前的向量沿着指定的轴旋转指定的角度。该方法将修改当前的向量,而不是返回一个新的向量。

语法

applyRotation(axis: Vector3, angle: number): this

参数

  • axis:一个 Vector3 对象,表示旋转的轴向。
  • angle:一个 number 值,表示旋转的角度,单位为弧度。

返回值

applyRotation 方法返回修改后的当前向量对象。

示例

const vec = new Vector3(1, 0, 0);
vec.applyRotation(new Vector3(0, 0, 1), Math.PI / 2);  // 将 vec 绕 z 轴逆时针旋转 90 度
console.log(vec);  // 输出结果为 Vector3(-0,9999999999999999, 0, 1.2246467991473532e-16)

异常

如果 axis 不是一个有效的 Vector3 对象,则抛出 TypeError 异常;如果 angle 不是一个有效的数值,则抛出 TypeError 异常。

参考