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

该方法用于判断一个BoundingSphere对象是否与另一个BoundingSphere对象相交。

语法

boundingSphere.intersectsBoundingSphere(sphere);

参数

  • boundingSphere:一个表示BoundingSphere对象的实例。
  • sphere: 一个表示BoundingSphere对象的实例。

返回值

返回一个布尔值,表示两个BoundingSphere对象是否相交。

示例

var sphere1 = new THREE.Sphere(new THREE.Vector3(0, 0, 0), 10);
var sphere2 = new THREE.Sphere(new THREE.Vector3(20, 0, 0), 5);
var result = sphere1.intersectsBoundingSphere(sphere2);
console.log(result); // false

sphere2.radius = 15;
result = sphere1.intersectsBoundingSphere(sphere2);
console.log(result); // true

描述

BoundingSphere是Yuka.js库中的一个类,用于表示一个包围场景对象的球形区域。它通常用于碰撞检测和视锥体剔除等场景优化技术中。

intersectsBoundingSphere方法会判断两个BoundingSphere对象是否相交。当两个BoundingSphere对象的中心点距离大于它们半径之和时,它们不相交,并且返回值为false。当它们相交时,返回值为true。

注意事项

  • BoundingSphere对象的半径应该是正数。
  • BoundingSphere对象的中心点应该用THREE.Vector3表示。
  • 版本要求:Yuka.js v1.4.0 及以上版本。

参考链接