UNPKG

2.4 kBTypeScriptView Raw
1import { Vector3 } from "../../math/Vector3.js";
2import { Curve } from "../core/Curve.js";
3
4/**
5 * Create a smooth **3D** {@link http://en.wikipedia.org/wiki/B%C3%A9zier_curve#mediaviewer/File:Bezier_curve.svg | cubic bezier curve},
6 * defined by a start point, endpoint and two control points.
7 * @example
8 * ```typescript
9 * const curve = new THREE.CubicBezierCurve(
10 * new THREE.Vector2(-10, 0),
11 * new THREE.Vector2(-5, 15),
12 * new THREE.Vector2(20, 15),
13 * new THREE.Vector2(10, 0));
14 * const points = curve.getPoints(50);
15 * const geometry = new THREE.BufferGeometry().setFromPoints(points);
16 * const material = new THREE.LineBasicMaterial({
17 * color: 0xff0000
18 * });
19 * // Create the final object to add to the scene
20 * const curveObject = new THREE.Line(geometry, material);
21 * ```
22 * @see {@link https://threejs.org/docs/index.html#api/en/extras/curves/CubicBezierCurve | Official Documentation}
23 * @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/curves/CubicBezierCurve.js | Source}
24 */
25export class CubicBezierCurve3 extends Curve<Vector3> {
26 /**
27 * This constructor creates a new {@link CubicBezierCurve3}.
28 * @param v0 The starting point. Default is `new THREE.Vector3()`.
29 * @param v1 The first control point. Default is `new THREE.Vector3()`.
30 * @param v2 The second control point. Default is `new THREE.Vector3()`.
31 * @param v3 The ending point. Default is `new THREE.Vector3()`.
32 */
33 constructor(v0?: Vector3, v1?: Vector3, v2?: Vector3, v3?: Vector3);
34
35 /**
36 * Read-only flag to check if a given object is of type {@link CubicBezierCurve3}.
37 * @remarks This is a _constant_ value
38 * @defaultValue `true`
39 */
40 readonly isCubicBezierCurve3 = true;
41
42 /**
43 * A Read-only _string_ to check if `this` object type.
44 * @remarks Sub-classes will update this value.
45 * @defaultValue `CubicBezierCurve3`
46 */
47 override readonly type: string | "CubicBezierCurve3";
48
49 /**
50 * The starting point.
51 * @defaultValue `new THREE.Vector3()`.
52 */
53 v0: Vector3;
54
55 /**
56 * The first control point.
57 * @defaultValue `new THREE.Vector3()`.
58 */
59 v1: Vector3;
60
61 /**
62 * The second control point.
63 * @defaultValue `new THREE.Vector3()`.
64 */
65 v2: Vector3;
66
67 /**
68 * The ending point.
69 * @defaultValue `new THREE.Vector3()`.
70 */
71 v3: Vector3;
72}