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

fromPoints

该方法用于创建一个OBB(包围盒),通过传入多个点的数组,返回一个基于这些点的OBB。

语法

Yuka.OBB.fromPoints(points)

参数

  • points:Array,一个包含多个点的数组,每个点都是一个Vector3对象,表示一个三维坐标的点。

返回值

返回一个OBB对象,该对象包含两个属性:

  • center:Vector3,OBB的中心点坐标。
  • halfExtents:Vector3,OBB的长、宽、高三个方向的半径。

示例

const points = [
  new Yuka.Vector3(1, 2, 3),
  new Yuka.Vector3(4, 5, 6),
  new Yuka.Vector3(7, 8, 9)
];

const obb = Yuka.OBB.fromPoints(points);

console.log(obb.center); // 输出:(4, 5, 6)
console.log(obb.halfExtents); // 输出:(3, 3, 3)

备注

如果传入的点数组为空,该方法将返回一个所有属性均为零的OBB对象。否则,将根据传入的点计算出OBB的中心点和半径。