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

intersectsBoundingSphere

Yuka.js库中AABB的方法之一,用于检测AABB(轴对齐包围盒)是否与给定的球体相交。

语法

intersectsBoundingSphere( sphere: Sphere ): boolean

参数

  • sphereSphere类型,用于检测是否相交的球体。

返回值

  • boolean类型,如果相交为true,否则为false

示例

import { AABB, Sphere } from 'yuka';

const aabb = new AABB();
aabb.min.set( -1, -1, -1 );
aabb.max.set( 1, 1, 1 );
const sphere = new Sphere(1, 1, 1, 2);

const intersects = aabb.intersectsBoundingSphere( sphere );

console.log( intersects ); // true

实现原理

该方法在AABB和球体之间进行了一些数学计算以确定它们是否相交。通过计算此方法可以快速确定相交,特别是在高性能的3D引擎中。