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

intersectAABB

简介

该方法是Yuka.js库中的一种用于检测光线与轴对齐包围盒(AABB)相交的算法。

语法

intersectAABB( ray, box, intersectionPoint )

参数

  • ray: 光线对象。表示从起点出发的一条有方向的无限长线段。
  • box:轴对齐包围盒对象。表示一个以坐标轴对齐并且可以围住一组物体的盒子。
  • intersectionPoint:可选参数。用于返回包围盒和光线相交部分的位置坐标。如果光线和包围盒未相交,则返回null。

返回值

返回一个布尔值,表示光线是否与轴对齐包围盒相交。

示例

const ray = new THREE.Ray(
  new THREE.Vector3( -1, 0, 0 ), // 起点坐标
  new THREE.Vector3( 1, 0, 0 ) // 方向向量
);

const box = new THREE.Box3(
  new THREE.Vector3( -2, -2, -2 ), // 包围盒最小坐标
  new THREE.Vector3( 2, 2, 2 ) // 包围盒最大坐标
);

const intersectionPoint = new THREE.Vector3();
const isIntersected = intersectAABB( ray, box, intersectionPoint );

console.log( isIntersected ); // true
console.log( intersectionPoint ); // THREE.Vector3 { x: -1, y: 0, z: 0 }

参考