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

描述

fromPoints 是 Yuka js 库的 AABB 类的一个静态方法。该方法用于根据给定的一组点(向量)生成一个 AABB(轴对齐包围盒)对象。

语法

AABB.fromPoints( points )

参数

  • points:必选参数,类型为 Array,表示一组点,每个点用一个向量表示。

返回值

返回一个 AABB(轴对齐包围盒)对象。

示例

import { Vector3, AABB } from 'yuka';

const points = [
  new Vector3( -1, -1, -1 ),
  new Vector3( 0, 0, 0 ),
  new Vector3( 1, 1, 1 )
];

const aabb = AABB.fromPoints( points );

console.log( aabb.min ); // 输出:Vector3 { x: -1, y: -1, z: -1 }
console.log( aabb.max ); // 输出:Vector3 { x: 1, y: 1, z: 1 }

异常

  • 如果 points 参数不是 Array 类型,则会抛出一个类型错误异常 TypeError。

说明

  • AABB 是三维空间中以坐标轴为方向的平行六面体,是最基本的三维物体包围盒之一;
  • 该方法采用迭代法求 AABB,即找出一组最小的x、y、z值(最小点),以及一组最大的x、y、z值(最大点),从而确定 AABB 包含的物体大小和位置;
  • 该方法可用于诸如碰撞检测、空间分区、光线追踪等场景。

参考链接