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

clone

描述

BoundingSphere.clone() 方法用于克隆一个 BoundingSphere 对象。

语法

clone(): BoundingSphere

返回值

  • BoundingSphere 克隆出来的 BoundingSphere 对象。

示例

const sphere = new THREE.Sphere(new THREE.Vector3(1, 2, 3), 4);
const clonedSphere = sphere.clone();
console.log(clonedSphere);

输出结果:

Sphere {
  center: Vector3 { x: 1, y: 2, z: 3 },
  radius: 4
}

实现原理

BoundingSphere.clone() 方法通过使用一个已有的 BoundingSphere 对象的参数值来创建一个新的 BoundingSphere 对象来实现克隆操作。由于 BoundingSphere 对象是基于 Sphere 对象实现的,因此在克隆时也需要同时克隆 Sphere 对象的属性。

注意事项

BoundingSphere 对象在暴露 clone() 方法之前必须已经初始化,否则会抛出 TypeError 异常。