PhysicsSpatialGridHelper
new PhysicsSpatialGridHelper(physics : Physics, options : Object)Create a spatial grid visualization helper.
Constructor Parameters
optionsoptionalObjectConfiguration options.
cellSizeoptionalnumberSize of each grid cell in world units.
Default is4.gridExtentoptionalnumberNumber of cells to show in each direction from center.
Default is6.showQueryRadiusoptionalbooleanHighlight the query radius area.
Default istrue.queryRadiusoptionalnumberRadius used for spatial queries (capsule size).
Default is3.gridColoroptionalnumberColor of grid lines (grey).
Default is0x888888.queryColoroptionalnumberColor of query radius box (yellow).
Default is0x00ff88.activeColoroptionalnumberColor of active cells (green).
Default is0xffff00.targetoptionalTHREE.Object3DTarget object to follow (uses interpolated position).enabledoptionalbooleanWhether to start enabled.
Default istrue.
Methods
setCellSize#
setCellSize(size : number)Set the cell size (should match PhysicsSpatialGrid.cellSize).
Parameters
sizenumberCell size in world units.
setGridExtent#
setGridExtent(extent : number)Set the grid extent (number of cells from center).
Parameters
extentnumberNumber of cells in each direction.
setQueryRadius#
setQueryRadius(radius : number)Set the query radius for visualization.
Parameters
radiusnumberQuery radius in world units.
setTarget#
setTarget(target : THREE.Object3D)Set the target object to follow (uses interpolated position).
Parameters
targetTHREE.Object3DTarget object (e.g., player mesh).
setEnabled#
setEnabled(enabled : boolean)Enable or disable the helper.
Parameters
enabledbooleanWhether to show the visualization.
toggle#
toggle()Toggle enabled state.
update#
update()Update the visualization. Call every frame. Positions the grid around the player and updates the query radius box.
dispose#
dispose()Dispose of the helper and free resources.