UNPKG

2.55 kBTypeScriptView Raw
1import { BufferGeometry } from "../core/BufferGeometry.js";
2
3/**
4 * {@link BoxGeometry} is a geometry class for a rectangular cuboid with a given 'width', 'height', and 'depth'
5 * @remarks On creation, the cuboid is centred on the origin, with each edge parallel to one of the axes.
6 * @example
7 * ```typescript
8 * const geometry = new THREE.BoxGeometry(1, 1, 1);
9 * const material = new THREE.MeshBasicMaterial({
10 * color: 0x00ff00
11 * });
12 * const cube = new THREE.Mesh(geometry, material);
13 * scene.add(cube);
14 * ```
15 * @see {@link https://threejs.org/docs/index.html#api/en/geometries/BoxGeometry | Official Documentation}
16 * @see {@link https://github.com/mrdoob/three.js/blob/master/src/geometries/BoxGeometry.js | Source}
17 */
18export class BoxGeometry extends BufferGeometry {
19 /**
20 * Create a new instance of {@link BoxGeometry}
21 * @param width Width; that is, the length of the edges parallel to the X axis. Optional; Expects a `Float`. Default `1`
22 * @param height Height; that is, the length of the edges parallel to the Y axis. Optional; Expects a `Float`. Default `1`
23 * @param depth Depth; that is, the length of the edges parallel to the Z axis. Optional; Expects a `Float`. Default `1`
24 * @param widthSegments Number of segmented rectangular faces along the width of the sides. Optional; Expects a `Integer`. Default `1`
25 * @param heightSegments Number of segmented rectangular faces along the height of the sides. Optional; Expects a `Integer`. Default `1`
26 * @param depthSegments Number of segmented rectangular faces along the depth of the sides. Optional; Expects a `Integer`. Default `1`
27 */
28 constructor(
29 width?: number,
30 height?: number,
31 depth?: number,
32 widthSegments?: number,
33 heightSegments?: number,
34 depthSegments?: number,
35 );
36
37 /**
38 * A Read-only _string_ to check if `this` object type.
39 * @remarks Sub-classes will update this value.
40 * @defaultValue `BoxGeometry`
41 */
42 override readonly type: string | "BoxGeometry";
43
44 /**
45 * An object with a property for each of the constructor parameters.
46 * @remarks Any modification after instantiation does not change the geometry.
47 */
48 readonly parameters: {
49 readonly width: number;
50 readonly height: number;
51 readonly depth: number;
52 readonly widthSegments: number;
53 readonly heightSegments: number;
54 readonly depthSegments: number;
55 };
56
57 /** @internal */
58 static fromJSON(data: {}): BoxGeometry;
59}