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

Curve.getTangent()

方法描述

Curve.getTangent() 方法用于获取二维或三维空间中曲线上某一点的切线向量。对于计算切线的点,可以通过参数 t 来指定。t 的取值范围通常是 [0, 1],表示曲线上的相对位置。

语法

getTangent(t)

参数

  • t:表示曲线上的相对位置,取值范围是 [0, 1]

返回值

返回一个表示曲线上某一点切线方向的向量,该向量为 THREE.Vector2THREE.Vector3 类型。

示例

const curve = new THREE.SplineCurve([
  new THREE.Vector2(-10, 0),
  new THREE.Vector2(-5, 5),
  new THREE.Vector2(0, 0),
  new THREE.Vector2(5, -5),
  new THREE.Vector2(10, 0)
]);

const tangent = curve.getTangent(0.5);
console.log(tangent); // 输出:THREE.Vector2 { x: 0, y: -2.743945670087258 }

注意事项

  • Curve.getPoint 方法可用于获取曲线上某一点的坐标。
  • 该方法只适用于继承了 THREE.Curve 类的曲线类,例如 THREE.SplineCurveTHREE.LineCurve
  • 对于一些特殊的曲线,切线向量可能不存在或无法计算,例如射线 THREE.Ray 和线段 THREE.Line3。在使用该方法时,需要注意特定曲线的限制和约束。