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.getPoints()

Curve.getPoints()方法返回一组沿路径等间距的点,这些点用于从起点到终点绘制曲线。可以用于渲染、建模等应用。

语法

Curve.getPoints(divisions);

参数

  • divisions: 表示细分数,即生成的等间距点数。可选参数,默认值为50。

返回值

返回一个包含等间距点的数组。

示例

var curve = new THREE.EllipseCurve(
  0, 0, // x, y
  2, 1, // xRadius, yRadius
  0, 2 * Math.PI, // aStartAngle, aEndAngle
  false, // aClockwise
  0 // aRotation
);

var points = curve.getPoints(50);
var geometry = new THREE.BufferGeometry().setFromPoints(points);

var material = new THREE.LineBasicMaterial({ color: 0xff0000 });

var ellipse = new THREE.Line(geometry, material);
scene.add(ellipse);

在上述示例中,我们先创建了一个EllipseCurve对象,接着调用getPoints(50)方法,生成了包含50个等间距点的数组。然后,使用这个点数组创建了一个Line对象,并添加到场景中。

注意事项

  • 细分数越大,生成的点数组越多,曲线的细节和精度也会提高,但同时也会增加渲染时间和内存占用。
  • Curve.getPoints()方法只能用于这些继承THREE.Curve类的对象:
    • THREE.ArcCurve
    • THREE.CatmullRomCurve3
    • THREE.CubicBezierCurve
    • THREE.EllipseCurve
    • THREE.LineCurve
    • THREE.QuadraticBezierCurve
    • THREE.SplineCurve
  • 每个曲线对象都有一个默认的细分数,可以通过THREE.Curve.DEFAULT_POINTS属性访问。
    • THREE.ArcCurve.DEFAULT_POINTS: 12;
    • THREE.CatmullRomCurve3.DEFAULT_POINTS: 5;
    • THREE.CubicBezierCurve.DEFAULT_POINTS: 20;
    • THREE.EllipseCurve.DEFAULT_POINTS: 36;
    • THREE.LineCurve.DEFAULT_POINTS: 2;
    • THREE.QuadraticBezierCurve.DEFAULT_POINTS: 12;
    • THREE.SplineCurve.DEFAULT_POINTS: 5;

参考链接

https://threejs.org/docs/#api/en/extras/core/Curve.getPoints