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

该函数用于判断凸包是否与一个轴对齐的边界框(AABB)相交。

方法

intersectsAABB(aabb: Object): boolean

参数

  • aabb: Object - 轴对齐的边界框(AABB)。它应该具有以下属性:
    • minX: number - AABB 的最小 X 坐标。
    • maxX: number - AABB 的最大 X 坐标。
    • minY: number - AABB 的最小 Y 坐标。
    • maxY: number - AABB 的最大 Y 坐标。

返回值

boolean - 如果凸包与 AABB 相交,则返回 true,否则返回 false

示例

import Yuka from 'yuka'; 

const convexHull = new Yuka.ConvexHull();
convexHull.fromPoints( [ /* ... */ ] );

const aabb = {
  minX: -1,
  maxX: 1,
  minY: -1,
  maxY: 1
};

if ( convexHull.intersectsAABB( aabb ) ) {
  console.log( 'Convex hull intersects AABB.' );
}

异常

无。

备注

该方法的实现基于 SAT 碰撞检测算法。要使碰撞检测更有效率,请始终尽可能使用最小的边界框来包围对象,以便减少不必要的计算。