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

Set

在Yuka js库中,BoundingSphere的set方法用于设置BoundingSphere的中心点和半径值。

语法

set( center: Vector3, radius: number ): BoundingSphere

参数

  • center:一个Vector3,表示BoundingSphere的中心点。
  • radius:一个数字,表示BoundingSphere的半径值。

返回值

一个新的BoundingSphere对象。

示例

const boundingSphere = new BoundingSphere();
boundingSphere.set( new Vector3( 0, 0, 0 ), 1 );

以上代码将创建一个新的BoundingSphere对象,并将其中心点设置为 (0, 0, 0),半径值为 1

异常

如果center参数不是一个Vector3对象,将抛出一个类型错误。

如果radius参数不是一个数字,将抛出一个类型错误。

注意事项

执行该方法后,将会创建一个新的BoundingSphere对象并返回,原有的BoundingSphere对象将会被销毁。如果需要保留原有对象,请在调用该方法之前创建一个新变量进行存储。