UNPKG

2.08 kBTypeScriptView Raw
1import { BufferGeometry } from "../core/BufferGeometry.js";
2import { LineBasicMaterial } from "../materials/LineBasicMaterial.js";
3import { ColorRepresentation } from "../math/Color.js";
4import { LineSegments } from "../objects/LineSegments.js";
5
6/**
7 * The {@link GridHelper} is an object to define grids
8 * @remarks
9 * Grids are two-dimensional arrays of lines.
10 * @example
11 * ```typescript
12 * const size = 10;
13 * const divisions = 10;
14 * const {@link GridHelper} = new THREE.GridHelper(size, divisions);
15 * scene.add(gridHelper);
16 * ```
17 * @see Example: {@link https://threejs.org/examples/#webgl_helpers | WebGL / helpers}
18 * @see {@link https://threejs.org/docs/index.html#api/en/helpers/GridHelper | Official Documentation}
19 * @see {@link https://github.com/mrdoob/three.js/blob/master/src/helpers/GridHelper.js | Source}
20 */
21export class GridHelper extends LineSegments<BufferGeometry, LineBasicMaterial> {
22 /**
23 * Creates a new {@link GridHelper} of size 'size' and divided into 'divisions' segments per side
24 * @remarks
25 * Colors are optional.
26 * @param size The size of the grid. Default `10`
27 * @param divisions The number of divisions across the grid. Default `10`
28 * @param colorCenterLine The color of the centerline. This can be a {@link THREE.Color | Color}, a hexadecimal value and an CSS-Color name. Default `0x444444`
29 * @param colorGrid The color of the lines of the grid. This can be a {@link THREE.Color | Color}, a hexadecimal value and an CSS-Color name. Default `0x888888`
30 */
31 constructor(size?: number, divisions?: number, color1?: ColorRepresentation, color2?: ColorRepresentation);
32
33 /**
34 * A Read-only _string_ to check if `this` object type.
35 * @remarks Sub-classes will update this value.
36 * @override
37 * @defaultValue `GridHelper`
38 */
39 override readonly type: string | "GridHelper";
40
41 /**
42 * Frees the GPU-related resources allocated by this instance
43 * @remarks
44 * Call this method whenever this instance is no longer used in your app.
45 */
46 dispose(): void;
47}