GridPristine
new GridPristine()Infinite grid mesh with anti-aliased lines and dual-layer composition.
Features
- Two independent grid layers (A and B) with configurable cell size, width, color, and opacity
- Analytic derivative-based rendering keeps line thickness stable across all zoom levels
- World-space positioning using positionWorld (grid doesn't move with camera)
- Smooth anti-aliasing at any distance or angle
- Full TSL/NodeMaterial implementation for WebGPU compatibility
Rendering
- Uses fragment shader derivatives (dFdx/dFdy) to compute pixel-space line width
- Lines automatically adapt thickness based on screen-space density
- Composite blend: background → layer B → layer A
- No texture lookups or geometry subdivision required
Use Cases
- Scene reference grids with major/minor divisions
- CAD/3D editor floor grids
- Architectural visualization ground planes
- Debug visualizations requiring stable grid lines
Example
import { GridPristine } from '@three-blocks/core';
import * as THREE from 'three/webgpu';
// Basic grid with default settings
const grid = new GridPristine();
scene.add(grid);Methods
attachGUI#
attachGUI(gui : *) : GridPristineAttach a GUI folder with common controls. Compatible with lil-gui, dat.gui, and Three.js Inspector.
Parameters
gui*GUI instance (e.g., lil-gui/dat.gui or renderer.inspector.createParameters()).
Returns
disposeGUI#
disposeGUI() : GridPristineDetach and destroy the GUI folder.
Returns
dispose#
dispose() : voidDispose GPU resources and detach GUI.
Returns
voidType Definitions
GridPristineOptions#
width:number, height:number, cellSizeA:number, lineWidthA:number, +7 more
Properties
widthoptionalnumberPlane width in world units.
Default is
Default is
9999.heightoptionalnumberPlane height in world units.
Default is
Default is
9999.cellSizeAoptionalnumberCell size for layer A (world units).
Default is
Default is
10.0.lineWidthAoptionalnumberLine width for layer A (world units).
Default is
Default is
0.03.colorAoptionalnumber | string | THREE.ColorLine color for layer A.
Default is
Default is
0xffffff.opacityAoptionalnumberOpacity for layer A in [0,1].
Default is
Default is
1.0.cellSizeBoptionalnumberCell size for layer B (world units).
Default is
Default is
1.0.lineWidthBoptionalnumberLine width for layer B (world units).
Default is
Default is
0.02.colorBoptionalnumber | string | THREE.ColorLine color for layer B.
Default is
Default is
0xcccccc.opacityBoptionalnumberOpacity for layer B in [0,1].
Default is
Default is
0.45.bgColoroptionalnumber | string | THREE.ColorBackground color.
Default is
Default is
0x000000.