import type { Node, StorageBufferNode } from 'three/webgpu'; import type { TSLFloatNode, TSLMat4Node, TSLUintNode, TSLVec2Node, TSLVec3Node, TSLVec4Node } from '../../../types/tsl.js'; /** Workgroup dimensions accepted by the legacy Boids compute leaves. */ export type BoidsComputeWorkgroupSize = number[]; /** Legacy grid coordinate mapper supplied by the simulation object. */ export interface BoidsPositionToCellCoords { (position: TSLVec2Node | TSLVec3Node, cellSize: TSLVec2Node | TSLVec3Node, gridResolution: TSLVec2Node | TSLVec3Node, domainDimensions: TSLVec2Node | TSLVec3Node): Node<'ivec2'> | Node<'ivec3'>; } /** Legacy grid hash mapper supplied by the simulation object. */ export interface BoidsCellKeyToHash { (cellCoordinates: Node<'ivec2'> | Node<'ivec3'>, gridResolution: TSLVec2Node | TSLVec3Node): TSLUintNode; } /** Shared CPU dispatch controls for the legacy Boids compute leaves. */ export interface BoidsComputeDispatch { particleMaxCount: number; workGroupsCount: BoidsComputeWorkgroupSize; } /** Simulation surface consumed by `computeIndices`. */ export interface BoidsIndicesComputeSimulation extends BoidsComputeDispatch { is3D: boolean; debug: boolean; positionToCellCoords: BoidsPositionToCellCoords; cellKeyToHash: BoidsCellKeyToHash; buffers: { positions: StorageBufferNode<'vec3'>; indices: StorageBufferNode<'uvec2'>; debug?: { cellId: StorageBufferNode<'uint'>; }; }; ubos: { max_particles: TSLUintNode; particleCount: TSLUintNode; count_cells: TSLUintNode; grid_cell_size: TSLVec3Node; grid_resolution: TSLVec3Node; domainDimensions: TSLVec3Node; domainMatrix?: TSLMat4Node; }; } /** Simulation surface consumed by `computeOffsets`. */ export interface BoidsOffsetsComputeSimulation extends BoidsComputeDispatch { gridCellCount: number; buffers: { indices: StorageBufferNode<'uvec2'>; cell_offsets: StorageBufferNode<'uint'>; }; ubos: { max_particles: TSLUintNode; count_cells: TSLUintNode; }; } /** Simulation surface consumed by `computeSort`. */ export interface BoidsSortComputeSimulation extends BoidsComputeDispatch { buffers: { indices: StorageBufferNode<'uvec2'>; }; ubos: { sorting_step: TSLVec4Node; }; } /** Simulation surface consumed by the legacy spatial-lookup Boids kernel. */ export interface BoidsComputeSimulation extends BoidsComputeDispatch { is3D: boolean; debug: boolean; positionToCellCoords: BoidsPositionToCellCoords; cellKeyToHash: BoidsCellKeyToHash; buffers: { positions: StorageBufferNode<'vec3'>; velocities: StorageBufferNode<'vec3'>; cell_offsets: StorageBufferNode<'uint'>; cellHashes: StorageBufferNode<'uint'>; particleIds: StorageBufferNode<'uint'>; candidateVisits?: StorageBufferNode<'uint'>; debug?: StorageBufferNode<'uint'>; }; ubos: { max_particles: TSLUintNode; particleCount: TSLUintNode; grid_cell_size: TSLVec3Node; grid_resolution: TSLVec3Node; domainDimensions: TSLVec3Node; domainMatrix?: TSLMat4Node; delta?: TSLFloatNode; }; }