UNPKG

2.18 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:B%C3%A9zier_2_big.gif | quadratic bezier curve},
6 * defined by a start point, end point and a single control point.
7 * @example
8 * ```typescript
9 * const curve = new THREE.QuadraticBezierCurve(
10 * new THREE.Vector2(-10, 0),
11 * new THREE.Vector2(20, 15),
12 * new THREE.Vector2(10, 0));
13 * const points = curve.getPoints(50);
14 * const geometry = new THREE.BufferGeometry().setFromPoints(points);
15 * const material = new THREE.LineBasicMaterial({
16 * color: 0xff0000
17 * });
18 * // Create the final object to add to the scene
19 * const curveObject = new THREE.Line(geometry, material);
20 * ```
21 * @see {@link https://threejs.org/docs/index.html#api/en/extras/curves/QuadraticBezierCurve | Official Documentation}
22 * @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/curves/QuadraticBezierCurve.js | Source}
23 */
24export class QuadraticBezierCurve extends Curve<Vector2> {
25 /**
26 * This constructor creates a new {@link QuadraticBezierCurve}.
27 * @param v0 The start point. Default is `new THREE.Vector2()`.
28 * @param v1 The control point. Default is `new THREE.Vector2()`.
29 * @param v2 The end point. Default is `new THREE.Vector2()`.
30 */
31 constructor(v0?: Vector2, v1?: Vector2, v2?: Vector2);
32
33 /**
34 * Read-only flag to check if a given object is of type {@link LineCurve3}.
35 * @remarks This is a _constant_ value
36 * @defaultValue `true`
37 */
38 readonly isQuadraticBezierCurve = true;
39
40 /**
41 * A Read-only _string_ to check if `this` object type.
42 * @remarks Sub-classes will update this value.
43 * @defaultValue `QuadraticBezierCurve`
44 */
45 override readonly type: string | "QuadraticBezierCurve";
46
47 /**
48 * The start point.
49 * @defaultValue `new THREE.Vector2()`
50 */
51 v0: Vector2;
52
53 /**
54 * The control point.
55 * @defaultValue `new THREE.Vector2()`
56 */
57 v1: Vector2;
58
59 /**
60 * The end point.
61 * @defaultValue `new THREE.Vector2()`
62 */
63 v2: Vector2;
64}