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

CurvePath.add()

CurvePath.add()是three.js中CurvePath类的一个方法。它用于将一条曲线添加到路径中。

语法

add (curve: Curve)

参数

  • curve - 要添加到路径中的曲线。可以是LineCurveQuadraticBezierCurveCubicBezierCurveEllipseCurveArcCurveSplineCurveCatmullRomCurve和其他曲线。

返回值

CurvePath对象。

异常

  • 如果curve参数不是曲线,则抛出一个类型错误。

示例

下面是一个简单的例子,展示如何向CurvePath添加曲线。

// 创建一条闭合的曲线
var curve = new THREE.CatmullRomCurve3( [
  new THREE.Vector3( -10, 0, 10 ),
  new THREE.Vector3( -5, 5, 5 ),
  new THREE.Vector3( 0, 0, 0 ),
  new THREE.Vector3( 5, -5, 5 ),
  new THREE.Vector3( 10, 0, 10 )
] );

// 创建一个路径对象
var path = new THREE.CurvePath();

// 将曲线添加到路径中
path.add(curve);

// 创建线条几何体
var geometry = new THREE.BufferGeometry().setFromPoints( path.getPoints( 50 ) );

// 创建线条材质
var material = new THREE.LineBasicMaterial( { color: 0xff0000 } );

// 创建线条
var line = new THREE.Line( geometry, material );

// 添加线条到场景中
scene.add( line );

备注

CurvePath.add()方法可以多次调用,将多个曲线添加到路径中。

参考