1 | import { BufferGeometry } from "../core/BufferGeometry.js";
|
2 | import { Shape } from "../extras/core/Shape.js";
|
3 |
|
4 | /**
|
5 | * Creates an one-sided polygonal geometry from one or more path shapes.
|
6 | * @example
|
7 | * ```typescript
|
8 | * const x = 0, y = 0;
|
9 | * const heartShape = new THREE.Shape();
|
10 | * heartShape.moveTo(x + 5, y + 5);
|
11 | * heartShape.bezierCurveTo(x + 5, y + 5, x + 4, y, x, y);
|
12 | * heartShape.bezierCurveTo(x - 6, y, x - 6, y + 7, x - 6, y + 7);
|
13 | * heartShape.bezierCurveTo(x - 6, y + 11, x - 3, y + 15.4, x + 5, y + 19);
|
14 | * heartShape.bezierCurveTo(x + 12, y + 15.4, x + 16, y + 11, x + 16, y + 7);
|
15 | * heartShape.bezierCurveTo(x + 16, y + 7, x + 16, y, x + 10, y);
|
16 | * heartShape.bezierCurveTo(x + 7, y, x + 5, y + 5, x + 5, y + 5);
|
17 | * const geometry = new THREE.ShapeGeometry(heartShape);
|
18 | * const material = new THREE.MeshBasicMaterial({
|
19 | * color: 0x00ff00
|
20 | * });
|
21 | * const mesh = new THREE.Mesh(geometry, material);
|
22 | * scene.add(mesh);
|
23 | * ```
|
24 | * @see {@link https://threejs.org/docs/index.html#api/en/geometries/ShapeGeometry | Official Documentation}
|
25 | * @see {@link https://github.com/mrdoob/three.js/blob/master/src/geometries/ShapeGeometry.js | Source}
|
26 | */
|
27 | export class ShapeGeometry extends BufferGeometry {
|
28 | /**
|
29 | * Create a new instance of {@link ShapeGeometry}
|
30 | * @param shapes Array of shapes or a single {@link THREE.Shape | Shape}. Default `new Shape([new Vector2(0, 0.5), new Vector2(-0.5, -0.5), new Vector2(0.5, -0.5)])`, _a single triangle shape_.
|
31 | * @param curveSegments Number of segments per shape. Expects a `Integer`. Default `12`
|
32 | */
|
33 | constructor(shapes?: Shape | Shape[], curveSegments?: number);
|
34 |
|
35 | /**
|
36 | * A Read-only _string_ to check if `this` object type.
|
37 | * @remarks Sub-classes will update this value.
|
38 | * @defaultValue `ShapeGeometry`
|
39 | */
|
40 | override readonly type: string | "ShapeGeometry";
|
41 |
|
42 | /**
|
43 | * An object with a property for each of the constructor parameters.
|
44 | * @remarks Any modification after instantiation does not change the geometry.
|
45 | */
|
46 | readonly parameters: {
|
47 | readonly shapes: Shape | Shape[];
|
48 | readonly curveSegments: number;
|
49 | };
|
50 |
|
51 | /** @internal */
|
52 | static fromJSON(data: {}): ShapeGeometry;
|
53 | }
|