UNPKG

3.79 kBTypeScriptView Raw
1import { Vector2 } from "../../math/Vector2.js";
2import { Curve } from "../core/Curve.js";
3
4/**
5 * Creates a 2d curve in the shape of an ellipse
6 * @remarks
7 * Setting the {@link xRadius} equal to the {@link yRadius} will result in a circle.
8 * @example
9 * ```typescript
10 * const curve = new THREE.EllipseCurve(
11 * 0, 0, // ax, aY
12 * 10, 10, // xRadius, yRadius
13 * 0, 2 * Math.PI, // aStartAngle, aEndAngle
14 * false, // aClockwise
15 * 0 // aRotation
16 * );
17 * const points = curve.getPoints(50);
18 * const geometry = new THREE.BufferGeometry().setFromPoints(points);
19 * const material = new THREE.LineBasicMaterial({ color: 0xff0000 });
20 * // Create the final object to add to the scene
21 * const ellipse = new THREE.Line(geometry, material);
22 * ```
23 * @see {@link https://threejs.org/docs/index.html#api/en/extras/curves/EllipseCurve | Official Documentation}
24 * @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/curves/EllipseCurve.js | Source}
25 */
26export class EllipseCurve extends Curve<Vector2> {
27 /**
28 * This constructor creates a new {@link EllipseCurve}.
29 * @param aX The X center of the ellipse. Expects a `Float`. Default is `0`.
30 * @param aY The Y center of the ellipse. Expects a `Float`. Default is `0`.
31 * @param xRadius The radius of the ellipse in the x direction. Expects a `Float`. Default is `1`.
32 * @param yRadius The radius of the ellipse in the y direction. Expects a `Float`. Default is `1`.
33 * @param aStartAngle The start angle of the curve in radians starting from the positive X axis. Default is `0`.
34 * @param aEndAngle The end angle of the curve in radians starting from the positive X axis. Default is `2 x Math.PI`.
35 * @param aClockwise Whether the ellipse is drawn clockwise. Default is `false`.
36 * @param aRotation The rotation angle of the ellipse in radians, counterclockwise from the positive X axis. Default is `0`.
37 */
38 constructor(
39 aX?: number,
40 aY?: number,
41 xRadius?: number,
42 yRadius?: number,
43 aStartAngle?: number,
44 aEndAngle?: number,
45 aClockwise?: boolean,
46 aRotation?: number,
47 );
48
49 /**
50 * Read-only flag to check if a given object is of type {@link EllipseCurve}.
51 * @remarks This is a _constant_ value
52 * @defaultValue `true`
53 */
54 readonly isEllipseCurve = true;
55
56 /**
57 * A Read-only _string_ to check if `this` object type.
58 * @remarks Sub-classes will update this value.
59 * @defaultValue `EllipseCurve`
60 */
61 override readonly type: string | "EllipseCurve";
62
63 /**
64 * The X center of the ellipse.
65 * @remarks Expects a `Float`
66 * @defaultValue `0`
67 */
68 aX: number;
69
70 /**
71 * The Y center of the ellipse.
72 * @remarks Expects a `Float`
73 * @defaultValue `0`
74 */
75 aY: number;
76
77 /**
78 * The radius of the ellipse in the x direction.
79 * @defaultValue `1`
80 */
81 xRadius: number;
82
83 /**
84 * The radius of the ellipse in the y direction.
85 * @defaultValue `1`
86 */
87 yRadius: number;
88
89 /**
90 * The start angle of the curve in radians starting from the middle right side.
91 * @remarks Expects a `Float`
92 * @defaultValue `0`
93 */
94 aStartAngle: number;
95
96 /**
97 * The end angle of the curve in radians starting from the middle right side.
98 * @remarks Expects a `Float`
99 * @defaultValue `2 * Math.PI`
100 */
101 aEndAngle: number;
102
103 /**
104 * Whether the ellipse is drawn clockwise.
105 * @defaultValue `false``
106 */
107 aClockwise: boolean;
108
109 /**
110 * The rotation angle of the ellipse in radians, counterclockwise from the positive X axis (optional).
111 * @remarks Expects a `Float`
112 * @defaultValue `0`
113 */
114 aRotation: number;
115}