UNPKG

2.5 kBTypeScriptView Raw
1import { BufferGeometry } from "../core/BufferGeometry.js";
2
3/**
4 * A polyhedron is a solid in three dimensions with flat faces
5 * @remarks
6 * This class will take an array of vertices, project them onto a sphere, and then divide them up to the desired level of detail
7 * This class is used by {@link THREE.DodecahedronGeometry | DodecahedronGeometry}, {@link THREE.IcosahedronGeometry | IcosahedronGeometry},
8 * {@link THREE.OctahedronGeometry | OctahedronGeometry}, and {@link THREE.TetrahedronGeometry | TetrahedronGeometry} to generate their respective geometries.
9 * @example
10 * ```typescript
11 * const verticesOfCube = [-1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, ];
12 * const indicesOfFaces = [
13 * 2, 1, 0, 0, 3, 2,
14 * 0, 4, 7, 7, 3, 0,
15 * 0, 1, 5, 5, 4, 0,
16 * 1, 2, 6, 6, 5, 1,
17 * 2, 3, 7, 7, 6, 2,
18 * 4, 5, 6, 6, 7, 4];
19 * const geometry = new THREE.PolyhedronGeometry(verticesOfCube, indicesOfFaces, 6, 2);
20 * ```
21 * @see {@link https://threejs.org/docs/index.html#api/en/geometries/PolyhedronGeometry | Official Documentation}
22 * @see {@link https://github.com/mrdoob/three.js/blob/master/src/geometries/PolyhedronGeometry.js | Source}
23 */
24export class PolyhedronGeometry extends BufferGeometry {
25 /**
26 * Create a new instance of {@link PolyhedronGeometry}
27 * @param vertices Array of points of the form [1,1,1, -1,-1,-1, ... ]. Default `[]`.
28 * @param indices Array of indices that make up the faces of the form [0,1,2, 2,3,0, ... ]. Default `[]`.
29 * @param radius [page:The radius of the final shape Expects a `Float`. Default `1`
30 * @param detail [page:How many levels to subdivide the geometry. The more detail, the smoother the shape. Expects a `Integer`. Default `0`
31 */
32 constructor(vertices?: number[], indices?: number[], radius?: number, detail?: number);
33
34 /**
35 * A Read-only _string_ to check if `this` object type.
36 * @remarks Sub-classes will update this value.
37 * @defaultValue `PolyhedronGeometry`
38 */
39 override readonly type: string | "PolyhedronGeometry";
40
41 /**
42 * An object with a property for each of the constructor parameters.
43 * @remarks Any modification after instantiation does not change the geometry.
44 */
45 readonly parameters: {
46 readonly vertices: number[];
47 readonly indices: number[];
48 readonly radius: number;
49 readonly detail: number;
50 };
51
52 /** @internal */
53 static fromJSON(data: {}): PolyhedronGeometry;
54}