BufferGeometry
Object3D
Raycaster
Camera
CubeCamera
PerspectiveCamera
OrthographicCamera
StereoCamera
Clock
Curve
CurvePath
Path
Shape
ShapePath
ArrowHelper
AxesHelper
BoxHelper
Box3Helper
CameraHelper
DirectionalLightHelper
GridHelper
PolarGridHelper
HemisphereLightHelper
PlaneHelper
PointLightHelper
SkeletonHelper
SpotLightHelper
Light
PointLight
RectAreaLight
SpotLight
DirectionalLight
HemisphereLight
LightShadow
PointLightShadow
AnimationLoader
AudioLoader
BufferGeometryLoader
CompressedTextureLoader
CubeTextureLoader
DataTextureLoader
FileLoader
ImageBitmapLoader
ImageLoader
Loader
LoaderUtils
MaterialLoader
ObjectLoader
TextureLoader
LoadingManager
Material
Box2
Box3
Color
Cylindrical
Euler
Frustum
Interpolant
Line3
MathUtils
Matrix3
Matrix4
Plane
Quaternion
AnimationAction
AnimationClip
AnimationMixer
AnimationObjectGroup
AnimationUtils
keyframeTrack
PropertyBinding
PropertyMixer
BooleanKeyframeTrack
QuaternionKeyframeTrack
StringKeyframeTrack
Audio
AudioAnalyser
AudioContext
AudioListener
PositionalAudio

Line3.closestPointToPoint()

描述

Line3.closestPointToPoint( point, clampToLineSegment = false, target = new Vector3() )是在一个三维空间中给出一个线,并在此线上最接近给定点的点。

参数

  • point(类型: Vector3):要计算的点。
  • clampToLineSegment(类型:Boolean,默认值:false):如果为true,则返回的点将被限制在线段之间(两个端点之间)。
  • target(类型:Vector3,默认值:new Vector3()):用于存储结果的可选向量。

返回值

Vector3:点在线上的最佳匹配点。

示例

const point = new Vector3( 1, 1, 1 );
const lineStart = new Vector3( 0, 0, 0 );
const lineEnd = new Vector3( 0, 0, 2 );
const line = new Line3( lineStart, lineEnd );
const closestPoint = line.closestPointToPoint( point, true );
// closestPoint is (0, 0, 1)

注意事项

如果给定点在线段上,则返回给定点。否则返回在线段的端点之一(如果不将clampToLineSegment设置为false的话)。

参考文献