SpatialGridHelper
new SpatialGridHelper(simulation : Object, showTexts : boolean)Helper for visualizing the spatial grid used by particle simulations.
Constructor Parameters
simulationObjectThe simulation object (SPH, Boids) to which the helper is attached.
showTextsoptionalbooleanWhether to show cell IDs as text.
Default is
Default is
true.Example
import { SPH, SpatialGridHelper } from '@three-blocks/core';
import * as THREE from 'three/webgpu';
// Create SPH simulation with spatial grid enabled
const sph = new SPH({
count: 4096,
is3D: true,
domainDimensions: new THREE.Vector3(20, 20, 20),
h: 1.0,
useSpatialGrid: true,
debug: true
});
// Create and attach grid helper for visualization
const gridHelper = new SpatialGridHelper(sph, true);
scene.add(gridHelper);
// Optional: Update helper when domain changes
sph.setDomainFromObject(mesh);
gridHelper.init(); // Rebuild grid visualization
// Clean up
gridHelper.dispose();
sph.dispose();