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

intersectsAABB

intersectsAABB是Yuka js库的一个函数,用于判断两个AABB(轴对齐包围盒)之间是否存在相交。

语法

intersectsAABB(aabb1, aabb2)

参数

  • aabb1:Object,代表第一个AABB,包含minmax属性,分别表示AABB的最小和最大点的坐标值。例如:{min: {x: 0, y: 0, z: 0}, max: {x: 1, y: 1, z: 1}}
  • aabb2:Object,代表第二个AABB,包含minmax属性,分别表示AABB的最小和最大点的坐标值。例如:{min: {x: 0, y: 0, z: 0}, max: {x: 1, y: 1, z: 1}}

返回值

  • 如果两个AABB存在相交,则返回true
  • 如果两个AABB不存在相交,则返回false

示例

const aabb1 = {min: {x: 0, y: 0, z: 0}, max: {x: 1, y: 1, z: 1}};
const aabb2 = {min: {x: -1, y: -1, z: -1}, max: {x: 0.5, y: 0.5, z: 0.5}};

const result = intersectsAABB(aabb1, aabb2); // 返回true

备注

如果两个AABB相交,那么它们共享的面肯定是一个矩形。在代码实现中,intersectsAABB会比较两个AABB的6个面是否存在重叠,如果存在重叠,则两个AABB相交。