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

at

描述

at 方法将根据给定的比例(一个介于0和1之间的数字),在当前线段的端点之间插值并返回相应的点。0对应第一个端点,1对应第二个端点。

语法

lineSegment.at(ratio);
  • ratio: 描述线段上某位置的比例(0-1之间的数值)。

返回值

返回描述该线段上特定比例位置的点坐标。

示例

const lineSegment = new Yuka.LineSegment( new Yuka.Vector3( 1, 0, 0 ), new Yuka.Vector3( 4, 0, 0 ) );

console.log(lineSegment.at(0.5)); // 输出 (2.5, 0, 0)

异常

  • 如果提供的比例不在(0-1)之间,则会抛出范围错误(RangeError)。

注意事项

  • 由于线段必须是有限的,因此在(0-1)之外的比例上插值将生成线段上的位置,但超出线段的末端点。
  • 插值始终在X,Y和Z维度上执行。