UNPKG

2.39 kBTypeScriptView Raw
1import { Vector2 } from "../../math/Vector2.js";
2import { Curve } from "../core/Curve.js";
3
4/**
5 * Create a smooth **2D** {@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 CubicBezierCurve extends Curve<Vector2> {
26 /**
27 * This constructor creates a new {@link CubicBezierCurve}.
28 * @param v0 The starting point. Default is `new THREE.Vector2()`.
29 * @param v1 The first control point. Default is `new THREE.Vector2()`.
30 * @param v2 The second control point. Default is `new THREE.Vector2()`.
31 * @param v3 The ending point. Default is `new THREE.Vector2()`.
32 */
33 constructor(v0?: Vector2, v1?: Vector2, v2?: Vector2, v3?: Vector2);
34
35 /**
36 * Read-only flag to check if a given object is of type {@link CubicBezierCurve}.
37 * @remarks This is a _constant_ value
38 * @defaultValue `true`
39 */
40 readonly isCubicBezierCurve = true;
41
42 /**
43 * A Read-only _string_ to check if `this` object type.
44 * @remarks Sub-classes will update this value.
45 * @defaultValue `CubicBezierCurve`
46 */
47 override readonly type: string | "CubicBezierCurve";
48
49 /**
50 * The starting point.
51 * @defaultValue `new THREE.Vector2()`
52 */
53 v0: Vector2;
54
55 /**
56 * The first control point.
57 * @defaultValue `new THREE.Vector2()`
58 */
59 v1: Vector2;
60
61 /**
62 * The second control point.
63 * @defaultValue `new THREE.Vector2()`
64 */
65 v2: Vector2;
66
67 /**
68 * The ending point.
69 * @defaultValue `new THREE.Vector2()`
70 */
71 v3: Vector2;
72}