threejs-worldgen
    Preparing search index...

    A deterministic cellular-automaton wildfire over a square region of a frame, after Rothermel: each cell's rate of spread comes from its fuel (grass, shrubs, trees from the biome scatter tables and grass presets), fuel moisture (from the weather's humidity, rain and snow, damped by Rothermel's moisture coefficient), wind along the spread direction and slope (uphill runs). Water, bare rock, snow, roads and firebreak lines stop it. Cells go unburnt → burning → burnt → regrowing (grass in weeks, shrubs in years, trees in decades) → unburnt, and lightning from the weather starts new fires.

    Everything advances in whole ticks and is seeded, so the same options, world, weather and time give the same fire; FireSim.runTo replays from the start when time goes backwards, and quiet periods (nothing burning) are skipped in one jump.

    const fire = new FireSim({ center: [0, 0], size: 2048 }, { world, weather })
    fire.ignite(40, -12)
    fire.runTo(time) // any time, forwards or backwards
    fire.stats.burning
    Index
    capacity: Float32Array<ArrayBuffer> = ...

    Full fuel per cell and class, kg/m², 3 per cell.

    cols: number = 0

    Cells per side.

    elevation: Float64Array<ArrayBuffer> = ...

    Ground height per cell, metres.

    firebreak: Uint8Array<ArrayBuffer> = ...

    1 where fire cannot go.

    fuel: Float32Array<ArrayBuffer> = ...

    Current fuel per cell and class (grass, shrub, tree), kg/m², 3 per cell.

    moisture: Float32Array<ArrayBuffer> = ...

    Fuel moisture per cell (fraction of dry weight) at the last weather refresh.

    options: FireOptions

    Resolved settings.

    rows: number = 0

    Cells per side (same as cols).

    state: Uint8Array<ArrayBuffer> = ...

    Cell states (see FIRE_STATE), row-major from (minX, minZ).

    stats: FireStats = ...

    Running totals.

    tickIndex: number = 0

    Ticks since tick 0.

    version: number = 0

    Bumped on every tick or change (renderers compare it).

    • Seconds since cell index caught fire, or Infinity if it is not burning.

      Parameters

      • index: number

      Returns number

    • Seconds since cell index burnt out, or Infinity if it is not burnt or regrowing.

      Parameters

      • index: number

      Returns number

    • Centre of cell index, [x, z].

      Parameters

      • index: number

      Returns [number, number]

    • Ground height at (x, z), bilinear between cell centres.

      Parameters

      • x: number
      • z: number

      Returns number

    • Total current fuel of a cell, kg/m².

      Parameters

      • index: number

      Returns number

    • Fire intensity 0…1 of a cell (0 unless burning): rises and falls over its burn.

      Parameters

      • index: number

      Returns number

    • Starts a fire at (x, z) within radius metres at time (default: the next tick). Ignitions are stored in options.ignitions, so they replay when time is scrubbed back.

      Parameters

      • x: number
      • z: number
      • radius: number = ...
      • time: number = ...

      Returns this

    • Cell index at (x, z), or −1 outside the grid.

      Parameters

      • x: number
      • z: number

      Returns number

    • Back to tick 0: full fuel everywhere, nothing burning (scheduled ignitions are kept).

      Returns this

    • Runs (or replays) to time, seconds. Quiet stretches with nothing burning are skipped in one jump. With a budget (milliseconds) it stops early, after at least one tick, once that much time is spent and catches up on later calls; the result is the same either way, since the state depends only on the tick.

      Parameters

      • time: number
      • budget: number = Infinity

      Returns this

    • Burn scar 0…1 of a cell: rises while burning, 1 when burnt, fading as it regrows. Feeds the burn state.

      Parameters

      • index: number

      Returns number

    • Fuel on the grid now, kg, summed cell by cell (stats.fuel is the running total).

      Returns number

    • Wind velocity [x, z] (m/s) the cell saw at the last weather refresh.

      Parameters

      • index: number

      Returns [number, number]