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

direction

该方法用于计算从Ray的原点沿着给定方向射出的一条新Ray。

语法

ray.direction(direction)

参数

  • direction:Vector3类型。表示新Ray的方向向量。

示例

// 创建一个以原点为起点,向右为方向的Ray
var ray = new YUKA.Ray(new YUKA.Vector3(0, 0, 0), new YUKA.Vector3(1, 0, 0));
// 计算从该Ray的起点,沿着向上的方向射出的一条新Ray
var directionVector = new YUKA.Vector3(0, 1, 0);
var newRay = ray.direction(directionVector);

返回值

该方法返回一条新的Ray对象。

注意事项

  • direction参数必须是一个单位向量(即长度为1.0的向量),否则将导致计算错误。如果传入的向量不是单位向量,则需要进行归一化处理,例如:direction.normalize()

参考资料