import { DIVEGridColors } from '../../constants/GridColors.ts'; import { Color, ColorRepresentation, Mesh } from 'three/webgpu'; import { DIVEComponent } from '../../engine/component/Component.ts'; /** * Everything about a grid a caller can decide. * * Colors come as a whole rather than one at a time, because what makes a grid * readable is the relationship between the two lines and the ground they sit * on -- see the presets in {@link DIVEGridColors}. The engine never picks one: * the ground is a white floor in one scene and the page behind a transparent * canvas in the next, and only the caller knows which. */ export type DIVEGridSettings = DIVEGridColors & { /** Distance between minor grid lines in meters. @default 1 */ gridSize: number; /** Draw a thicker major line every N cells. @default 10 */ majorLineEvery: number; }; export declare const DIVEGridDefaultSettings: Required; /** * An infinite shader-based grid that follows the camera. * * Draws anti-aliased minor and major grid lines with a radial distance fade. The * plane is finite and snaps to the camera in whole cells, which is what makes it * look endless: the fade hides the edge, and snapping keeps the lines from * crawling as the camera moves. * * The camera comes from `onBeforeRender` on the contributed mesh, which is the * sanctioned way for a component to get one -- `tick` has no view context, and * the grid has to react to whichever camera is rendering rather than to time. * * Visibility lives on the mesh rather than on a node, so hiding the grid never * touches whatever else its node carries. * * @module */ export declare class GridComponent extends DIVEComponent { readonly isGridComponent: true; private _mesh; private _material; private _uniforms; private _gridSize; constructor(); /** The plane the grid is drawn on. */ get mesh(): Mesh; /** Whether the grid is drawn. */ get visible(): boolean; /** Distance between minor grid lines in meters. */ get gridSize(): number; /** How many cells apart the thicker major lines are drawn. */ get majorLineEvery(): number; /** Color of the minor grid lines. */ get minorLineColor(): Color; /** Color of the major grid lines. */ get majorLineColor(): Color; /** How opaque the minor grid lines are drawn. */ get minorLineOpacity(): number; /** How opaque the major grid lines are drawn. */ get majorLineOpacity(): number; /** * Takes on whatever the settings carry, leaving the rest as it is. * * The way a preset is put on: `applySettings(DIVEGridOnDarkColors)` reads * as what it does, and says nothing about the cell size the caller chose. * * @param settings - Cell size, major line spacing, line colors. */ applySettings(settings: Partial): this; /** * @param visible - Whether the grid is drawn. */ setVisibility(visible: boolean): this; /** * @param size - Distance between minor grid lines in meters. Also the step * the plane snaps to, so the lines stay put as the camera moves. */ setGridSize(size: number): this; /** * @param n - Draw a thicker major line every N cells. */ setMajorLineEvery(n: number): this; /** * @param color - Color of the minor grid lines. */ setMinorLineColor(color: ColorRepresentation): this; /** * @param color - Color of the major grid lines. */ setMajorLineColor(color: ColorRepresentation): this; /** * @param opacity - How opaque the minor grid lines are drawn, 0 to 1. */ setMinorLineOpacity(opacity: number): this; /** * @param opacity - How opaque the major grid lines are drawn, 0 to 1. */ setMajorLineOpacity(opacity: number): this; copy(source: this): this; dispose(): void; }