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

intersectsOBB

intersectsOBB是Yuka js库中的面向对象碰撞检测函数,用于检测一个光线是否与一个方向轴对齐的包围盒(OBB)相交。

语法

intersectsOBB( ray, obb )

参数

  • ray:表示光线的Ray对象;
  • obb:表示包围盒的OBB对象。

返回值

如果光线与包围盒相交,则返回距离光线原点最近的交点(Vector3对象),否则返回null

示例

const ray = new YUKA.Ray();
const obb = new YUKA.OBB();
const intersectionPoint = new YUKA.Vector3();

// 对ray和obb进行设置, 然后使用intersectsOBB检测相交关系
const result = YUKA.intersectsOBB( ray, obb, intersectionPoint );
if ( result ) {
  console.log( '相交点的坐标是:', intersectionPoint );
}
else {
  console.log( '光线与包围盒不相交.' );
}

说明

包围盒OBB是在3D场景中最常用的一种几何形状。它是一种有向的盒子,具有3个相互垂直的尺寸(长度、宽度和高度),并定义了一个旋转轴的变换。

光线与OBB相交检测是计算机图形学中的基本操作之一,被广泛应用于游戏、虚拟现实等领域。intersectsOBB函数实现了光线与OBB的相交检测,可以帮助开发者高效地构建3D应用程序。