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

clampPoint

clampPoint 方法用于将给定的点限制在一个包围球内部。

语法

BoundingSphere.prototype.clampPoint ( point : Vector3, target : Vector3 ) : Vector3

参数

  • point - 待限制的点坐标对象,即 THREE.Vector3 类型。
  • target - 可选参数,如果指定,将把结果存储到目标对象中,即 THREE.Vector3 类型。

返回值

返回一个新的限制后的点坐标对象,如果指定了 target 参数,则返回目标对象。

示例

const sphere = new THREE.Sphere( new THREE.Vector3( 0, 0, 0 ), 5 );
const point = new THREE.Vector3( 10, 0, 0 );
const result = new THREE.Vector3();

sphere.clampPoint( point, result );

console.log( result ); // 输出为: { x: 5, y: 0, z: 0 }

说明

clampPoint 方法将给定的点坐标限制在一个包围球内部。如果给定的点坐标在包围球外部,则返回最近的包围球表面上的点。如果给定的点坐标在包围球内部,则返回原始坐标。

参考文献