import type { FuelSettings } from './fuel.ts'; import type { FlameSettings } from './flame.ts'; export type Vec3 = [number, number, number]; /** Samples a shadow ray takes toward the sun, a fixed rendering budget. */ export declare const SHADOW_STEPS = 32; export declare const LIGHTING_DIVISORS: readonly [1, 2, 4]; export type LightingDivisor = (typeof LIGHTING_DIVISORS)[number]; export interface RenderSettings { fireIntensity: number; flameOpacity: number; smokeDensity: number; scattering: number; shadowDensity: number; temperature: number; smokeColor: Vec3; fireColor: Vec3; sootGlow: number; } /** The simulation's lattice: cubic flame, heat, smoke and fuel cells of `voxelSize` * meters, anchored at the world origin. Smoke can use larger cells. */ export interface SimulationGrid { voxelSize: number; /** Velocity and pressure cells are `velocityDivisor` field cells wide. Defaults to 1. */ velocityDivisor?: VelocityDivisor; /** Fine cells per brick side, independent of velocity resolution. Defaults to 16. */ brickSize?: BrickSize; /** Smoke cells per fine-field cell along each axis. Defaults to 1. */ smokeDivisor?: SmokeDivisor; /** Compile scalar transport with MacCormack correction. Defaults to true. */ scalarMacCormack?: boolean; } export declare const VELOCITY_DIVISORS: readonly [1, 2, 4]; export type VelocityDivisor = (typeof VELOCITY_DIVISORS)[number]; export declare const SMOKE_DIVISORS: readonly [1, 2, 4]; export type SmokeDivisor = (typeof SMOKE_DIVISORS)[number]; export declare const FIXED_DT: number; /** Fine cells per side of a sparse allocation brick. */ export declare const BRICK_SIZES: readonly [8, 16, 32]; export type BrickSize = (typeof BRICK_SIZES)[number]; /** The device limits that size the brick pools. */ export type PoolLimits = Pick; /** WebGPU's default limits, which Three.js requests unless told otherwise. */ export declare const DEFAULT_POOL_LIMITS: PoolLimits; /** Most field voxels the pools may hold: every slot's storage buffers and texture * atlas fit the device's limits. The largest buffers are pressure (velocity cells * in half precision) and solid cells (one bit per field cell, solids.wgsl). */ export declare function maxPoolVoxels(velocityDivisor: VelocityDivisor, limits?: PoolLimits, brickSize?: BrickSize): number; /** Slots of brick pools along one axis of the largest 3D texture: a field slot is a brick * plus a one-texel apron. */ export declare function poolSlotsPerAxis(brickSize: BrickSize, limits?: PoolLimits): number; /** * Pools place slot `s` at (s % side, (s / side) % side, s / side²) slots, and grow by * rows of `side` slots within the first layer, then by whole layers. `side` is fixed for * the device, so slots keep their texels as the pools grow: it is the smallest that fits * the most voxels the device allows within the 3D texture limit. */ export declare function poolSide(velocityDivisor: VelocityDivisor, limits?: PoolLimits, brickSize?: BrickSize): number; /** Rows of `side` slots that hold `slots`: whole rows in the first layer, then whole layers. */ export declare function poolRows(slots: number, side: number): number; /** Texels per axis of a pool of `rows` rows of slots `edge` texels on a side. */ export declare function poolSize(rows: number, side: number, edge: number): Vec3; /** Slots the pools start with: whole rows holding at least 128, within `limit`. */ export declare function initialPoolSlots(side: number, limit: number): number; /** Simulation memory with pools of `slots` slots and `tiles` tile slots, plus the * curl-noise texture. */ export declare function memoryEstimate(slots: number, velocityDivisor?: VelocityDivisor, tiles?: number, smokeDivisor?: SmokeDivisor, scalarMacCormack?: boolean, brickSize?: BrickSize): number; /** Renderer memory with pools of `slots` slots: each slot's incident light, at the chosen * resolution with an apron (RGBA16F), and the flags of its 8³-cell blocks (RG16F); the * page tables of `bricks` bricks in boxes, in rows of 4096; the box table, the blackbody * table and the parameters. Smoothed fields borrow the simulation's scalar predictor. * Excludes screen and Three.js buffers. */ export declare function renderMemoryEstimate(slots: number, brickSize?: BrickSize, bricks?: number, lightingDivisor?: LightingDivisor): number; export interface SimulationSettings { buoyancy: number; smokeWeight: number; velocityDamping: number; cooling: number; dissipation: number; vorticity: number; seed: number; } /** Positions are in world space. */ export interface SimulationSource { id: string; shape: 'sphere' | 'box' | 'mesh'; position: Vec3; /** Sphere radii or box half-extents. */ size: Vec3; /** Normalized remaining-lifetime target. */ flame: number; /** Direct heat and smoke rates per second. */ heatRate: number; smokeRate: number; fuelRate?: number; velocity: Vec3; velocityResponse: number; /** Radial target speed, evaluated by the original emitter coupling. */ outwardSpeed: number; /** Burst-only initial scalar variation. Continuous sources omit this. */ variation?: { period: number; strength: number; }; /** Immutable transformed surface samples in world space. Replace the array when the * mesh moves. */ samples?: readonly { position: Vec3; weight: number; }[]; surfaceArea?: number; } /** A collider in world space: a sphere or a box, or a mesh's occupancy. */ export type SimulationCollider = { shape: 'sphere' | 'box'; position: Vec3; /** Sphere radii or box half-extents along its axes. */ size: Vec3; /** The box's axes in world space, unit vectors: the world axes by default. Spheres * ignore them. */ axes?: readonly [Vec3, Vec3, Vec3]; } | { shape: 'mesh'; occupancy: MeshColliderMask; }; /** Acceleration field, optionally masked by the union of emitter spatial footprints. */ export interface SimulationForce { type: 'wind' | 'turbulence' | 'vortex' | 'radial'; vector: Vec3; center: Vec3; strength: number; scale: number; lift: number; inward: number; sources?: readonly SimulationSource[]; } export interface SimulationFrame { simulation: SimulationSettings; combustion: FlameSettings; fuel?: FuelSettings; sources: readonly SimulationSource[]; forces?: readonly SimulationForce[]; colliders: readonly SimulationCollider[]; } /** Cell-center occupancy of a box of lattice cells: cell `lo + (x, y, z)` holds * `mask[(z * size.y + y) * size.x + x]`. The lattice's cell 0 starts at the world origin. * Immutable: replace it when the geometry moves. */ export interface MeshColliderMask { mask: Uint32Array; lo: Vec3; size: Vec3; }