@margoengine/vfx 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/NOTICE +4 -4
- package/README.md +2241 -1642
- package/dist/{base-C9upJytz.js → base-LGs65K7K.js} +174 -123
- package/dist/base.d.ts +104 -2
- package/dist/base.js +1 -1
- package/dist/blown-sand.js +3 -3
- package/dist/clouds.d.ts +12 -4
- package/dist/clouds.js +35 -18
- package/dist/compat-BFjXAQuu.js +14 -0
- package/dist/debris.d.ts +43 -0
- package/dist/debris.js +33 -1
- package/dist/dust-current.d.ts +66 -0
- package/dist/dust-current.js +92 -0
- package/dist/fire-front.d.ts +72 -1
- package/dist/fire-front.js +309 -69
- package/dist/fire.d.ts +24 -3
- package/dist/fire.js +114 -93
- package/dist/flame.d.ts +171 -3
- package/dist/flame.js +343 -131
- package/dist/flocking-shaders.d.ts +48 -0
- package/dist/flocking-sim.d.ts +623 -0
- package/dist/flocking.d.ts +145 -0
- package/dist/flocking.js +1846 -0
- package/dist/gunfire.d.ts +52 -6
- package/dist/gunfire.js +108 -98
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/json.js +2 -0
- package/dist/lit-Dx2tNwP-.js +152 -0
- package/dist/lit.d.ts +8 -1
- package/dist/lit.js +1 -105
- package/dist/mesh.d.ts +2 -0
- package/dist/mesh.js +92 -69
- package/dist/over-life.js +16 -15
- package/dist/reactive-mask-B8xbyzlk.js +69 -0
- package/dist/ribbons.d.ts +4 -2
- package/dist/ribbons.js +87 -73
- package/dist/settings.js +1 -1
- package/dist/shader.d.ts +5 -0
- package/dist/shared/fog.d.ts +33 -33
- package/dist/shared/pass.d.ts +53 -53
- package/dist/shared/settings.d.ts +89 -89
- package/dist/smoke.d.ts +72 -4
- package/dist/smoke.js +280 -56
- package/package.json +200 -192
package/dist/fire-front.d.ts
CHANGED
|
@@ -366,6 +366,12 @@ export declare class FireFront implements EnginePlugin {
|
|
|
366
366
|
embers: number;
|
|
367
367
|
spots: number;
|
|
368
368
|
private engine?;
|
|
369
|
+
/** advanceTime stepped the fire since the engine's last frame with time in it, not from that frame. */
|
|
370
|
+
private stepped;
|
|
371
|
+
/** How many engine frames in a row found such a step: two or more is a doubled clock. */
|
|
372
|
+
private doubled;
|
|
373
|
+
/** Inside onPreUpdate: the engine's own step. */
|
|
374
|
+
private fromEngine;
|
|
369
375
|
private disposed;
|
|
370
376
|
private readonly step;
|
|
371
377
|
private readonly seg;
|
|
@@ -390,6 +396,24 @@ export declare class FireFront implements EnginePlugin {
|
|
|
390
396
|
private burning;
|
|
391
397
|
private pending;
|
|
392
398
|
private readonly travel;
|
|
399
|
+
private readonly carry;
|
|
400
|
+
private carryKey;
|
|
401
|
+
/** Light order of each cell (1, 2, ...): the order `burning` holds them in, so the lazy cells interleave exactly. */
|
|
402
|
+
private readonly seqOf;
|
|
403
|
+
/** The cell lit `seq`-th. */
|
|
404
|
+
private readonly cellOfSeq;
|
|
405
|
+
private seqN;
|
|
406
|
+
/** Steps taken since the front was made or reset; the step in progress inside `advance`. */
|
|
407
|
+
private stepN;
|
|
408
|
+
/** Light order of the cell the step is visiting (-1 before the first: ignitions). */
|
|
409
|
+
private visitSeq;
|
|
410
|
+
private lazyOn;
|
|
411
|
+
private readonly lazy;
|
|
412
|
+
/** Step -> neighbours reached in it, each `seq * 16 + k`; `dueSteps` is a min-heap of the steps. */
|
|
413
|
+
private readonly due;
|
|
414
|
+
private readonly dueSteps;
|
|
415
|
+
/** Step -> lazy cells whose last open neighbour closes in it (they leave at the end of that step). */
|
|
416
|
+
private readonly dying;
|
|
393
417
|
private beds;
|
|
394
418
|
private bedKey;
|
|
395
419
|
private dirty;
|
|
@@ -446,6 +470,33 @@ export declare class FireFront implements EnginePlugin {
|
|
|
446
470
|
* releases. `WeatherDrive` lights the smoke haze from below with it (KB-WEATHER-FIREHAZE1). 0 while nothing burns.
|
|
447
471
|
*/
|
|
448
472
|
get radiantPower(): number;
|
|
473
|
+
/**
|
|
474
|
+
* The engine sun intensity of the scene's noon sun its smoke columns' glow and its flames' radiance are referred to (`SmokeOptions.noon`, `FlameOptions.noon`,
|
|
475
|
+
* KB-VFX-GLOWUNITS1), written on every column now and on those made later. `WeatherDrive` sets it from its sky's
|
|
476
|
+
* `lighting.intensity` each frame. Undefined: the columns' own (`smoke.noon`, default pi).
|
|
477
|
+
*/
|
|
478
|
+
get noon(): number | undefined;
|
|
479
|
+
set noon(value: number | undefined);
|
|
480
|
+
private noonValue?;
|
|
481
|
+
private noonOn;
|
|
482
|
+
/**
|
|
483
|
+
* Light of the air round its smoke columns (`SmokeOptions.air`, shares of the noon sun's light, red, green and blue),
|
|
484
|
+
* written on every column now and on those made later. `WeatherDrive` sets it each frame to its fires' light on the
|
|
485
|
+
* smoke pall over this front, so the columns inside the firelit pall take its light, not only their bases' glow
|
|
486
|
+
* (KB-VFX-COLUMNAMBIENT1). Undefined: the columns' own (`smoke.air`, default none).
|
|
487
|
+
*/
|
|
488
|
+
get air(): readonly [number, number, number] | undefined;
|
|
489
|
+
set air(value: readonly [number, number, number] | undefined);
|
|
490
|
+
private airValue?;
|
|
491
|
+
/**
|
|
492
|
+
* The reflectance of the smoke pall over this front (`SmokeOptions.airReflectance`, red, green and blue, each 0 to
|
|
493
|
+
* 1), written on every column now and on those made later: the share of the `air`'s light the pall sends back down,
|
|
494
|
+
* so the columns are lit from below by the fire and less from above (KB-VFX-SMOKEFLAT1). `WeatherDrive` sets it each
|
|
495
|
+
* frame to its haze's reflectance. Undefined: the columns' own (`smoke.airReflectance`, default `PALL_REFLECTANCE`).
|
|
496
|
+
*/
|
|
497
|
+
get airReflectance(): readonly [number, number, number] | undefined;
|
|
498
|
+
set airReflectance(value: readonly [number, number, number] | undefined);
|
|
499
|
+
private airBackValue?;
|
|
449
500
|
/** True while a cell burns or an ignition waits. */
|
|
450
501
|
get active(): boolean;
|
|
451
502
|
private queue;
|
|
@@ -453,6 +504,16 @@ export declare class FireFront implements EnginePlugin {
|
|
|
453
504
|
ignite(x: number, z: number, radius?: number, time?: number): this;
|
|
454
505
|
private bedsFor;
|
|
455
506
|
private light;
|
|
507
|
+
private closeToward;
|
|
508
|
+
private closed;
|
|
509
|
+
/** Takes a cell past its flames, after its visit in step `s`, out of `burning` into a lazy record. */
|
|
510
|
+
private lazify;
|
|
511
|
+
/** A lazy cell's kept travel reaches neighbour `k` in step `s`: what its visit would have done. */
|
|
512
|
+
private reach;
|
|
513
|
+
/** Puts every lazy cell back into `burning`, in light order, with the travel the steps since would have added. */
|
|
514
|
+
private flush;
|
|
515
|
+
/** The next step a lazy cell does anything in (reaches a neighbour or leaves), or Infinity. */
|
|
516
|
+
private nextLazyStep;
|
|
456
517
|
private lightArea;
|
|
457
518
|
/** The 10 m wind `[x, z]` at world `(x, z)` this step. */
|
|
458
519
|
private windAt;
|
|
@@ -469,11 +530,14 @@ export declare class FireFront implements EnginePlugin {
|
|
|
469
530
|
update(delta: number): void;
|
|
470
531
|
/**
|
|
471
532
|
* Steps the fire until nothing burns and no ignition waits, then resolves with the fire time. Yields to the event
|
|
472
|
-
* loop every 4,096 steps; `signal` aborts it.
|
|
533
|
+
* loop every 4,096 steps; `signal` aborts it. The burn is the one `advanceTime` steps, cell for cell, but a cell past
|
|
534
|
+
* its flames is not visited each step: it waits for the step its kept travel reaches a neighbour, worked out ahead
|
|
535
|
+
* (KB-SCENES-BURNTSLOW1), and steps in which nothing but such cells wait are only counted.
|
|
473
536
|
* @param maxSeconds The most fire time to simulate. Default 86,400.
|
|
474
537
|
*/
|
|
475
538
|
settle(maxSeconds?: number, signal?: AbortSignal): Promise<number>;
|
|
476
539
|
private advance;
|
|
540
|
+
private carryOn;
|
|
477
541
|
/** Flame exposure of structure cells near a burning cell: within 1.5 flame lengths they heat up and ignite. */
|
|
478
542
|
private exposeStructures;
|
|
479
543
|
private throwEmbers;
|
|
@@ -523,6 +587,13 @@ export declare class FireFront implements EnginePlugin {
|
|
|
523
587
|
/** Puts each flame volume on its stretch of the front or its building, keeping a volume with the stretch it had. */
|
|
524
588
|
private syncFlames;
|
|
525
589
|
private place;
|
|
590
|
+
/**
|
|
591
|
+
* The ground under a stretch of front over its plane (`slope` through its centre) at `Flame` `relief`'s grid of
|
|
592
|
+
* points over its footprint, into `out`: a stretch is up to a few flame lengths long and the ground under it rises
|
|
593
|
+
* and falls by up to 0.7 flame lengths off any one plane (the timber-valley town fire), so on the plane alone the
|
|
594
|
+
* flames were buried in the rises and floated over the hollows, a hard cut along their foot (KB-VFX-FLAMELOOK1).
|
|
595
|
+
*/
|
|
596
|
+
private reliefOf;
|
|
526
597
|
/**
|
|
527
598
|
* Puts each ember effect over its flame volume: born over the footprint (its box turned to the world axes) a third of
|
|
528
599
|
* the flame length up, at the kit's rate times sqrt(L / EMBER_LENGTH) times the stretch's length in flame lengths (1
|
package/dist/fire-front.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// @margo/core-built
|
|
1
|
+
// @margo/core-built 1.0.0
|
|
2
2
|
import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
|
|
3
|
-
const e=(engine,version="
|
|
3
|
+
const e=(engine,version="1.0.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
|
|
4
4
|
import { engineRuntime as __margoRuntime } from "@margoengine/core/extension";
|
|
5
5
|
import { MargoError as t } from "@margoengine/math/errors";
|
|
6
6
|
//#region src/fire-front.ts
|
|
@@ -176,20 +176,20 @@ function p(e, t, n = 1, r = t + .01, i = t + .02) {
|
|
|
176
176
|
}, b = g / v, x = _ / v, S = b * y(p) + x * y(m), C = a.reduce((e, t) => e + t.w, 0), w = C / e.depth, T = w / o, E = 3.348 * S ** -.8189, D = (e, t) => e.reduce((e, n) => e + n.w * Math.exp(-t / n.c.sav), 0), O = p.length ? ((e, t) => e.reduce((e, n) => e + n.w * n.m * Math.exp(-t / n.c.sav), 0))(p, 138) / D(p, 138) : 0, k = (e) => {
|
|
177
177
|
let t = h(e);
|
|
178
178
|
return t > 0 ? e.reduce((e, n) => e + n.area / t * n.m, 0) : 0;
|
|
179
|
-
}, A = k(p),
|
|
179
|
+
}, A = k(p), ee = k(m), j = m.length && p.length ? D(p, 138) / D(m, 500) : 0, M = e.extinction, N = m.length ? Math.max(M, 2.9 * j * (1 - O / M) - .226) : M, P = (e, t) => {
|
|
180
180
|
let n = Math.min(e / t, 1);
|
|
181
181
|
return 1 - 2.59 * n + 5.11 * n * n - 3.52 * n * n * n;
|
|
182
|
-
},
|
|
182
|
+
}, F = Math.min(.174 * c ** -.19, 1), I = S ** 1.5 / (495 + .0594 * S ** 1.5), L = 133 * S ** -.7913, R = I * (T / E) ** L * Math.exp(L * (1 - T / E)), z = (e) => {
|
|
183
183
|
let t = h(e);
|
|
184
184
|
return t > 0 ? e.reduce((e, n) => e + n.area / t * n.w * .9445, 0) : 0;
|
|
185
|
-
},
|
|
185
|
+
}, B = R * s * F * (z(p) * P(A, M) + (m.length ? z(m) * P(ee, N) : 0)), V = Math.exp((.792 + .681 * Math.sqrt(S)) * (T + .1)) / (192 + .2595 * S), H = (e, t) => t > 0 ? e.reduce((e, n) => e + n.area / t * Math.exp(-138 / n.c.sav) * (250 + 1116 * n.m), 0) : 0, U = w * (b * H(p, g) + x * H(m, _));
|
|
186
186
|
return {
|
|
187
187
|
model: e,
|
|
188
188
|
sigma: S,
|
|
189
189
|
beta: T,
|
|
190
190
|
betaOp: E,
|
|
191
|
-
ir:
|
|
192
|
-
rate0:
|
|
191
|
+
ir: B,
|
|
192
|
+
rate0: B * V / U * u,
|
|
193
193
|
windC: 7.47 * Math.exp(-.133 * S ** .55),
|
|
194
194
|
windB: .02526 * S ** .54,
|
|
195
195
|
windE: .715 * Math.exp(-359e-6 * S),
|
|
@@ -275,15 +275,65 @@ var T = (e, t) => m(e, .4 * t * x);
|
|
|
275
275
|
function E(e, t, n) {
|
|
276
276
|
return 3.34 * e.rate0 * (1 + T(e, t) + n);
|
|
277
277
|
}
|
|
278
|
-
var D = 0, O = 1, k = 2, A = 3,
|
|
278
|
+
var D = 0, O = 1, k = 2, A = 3, ee = 18622e3, j = .3, M = (() => {
|
|
279
279
|
let e = [];
|
|
280
280
|
for (let t = -2; t <= 2; t++) for (let n = -2; n <= 2; n++) {
|
|
281
281
|
let r = Math.abs(n), i = Math.abs(t);
|
|
282
282
|
(r || i) && (Math.max(r, i) === 1 || r + i === 3 && r && i) && e.push([n, t]);
|
|
283
283
|
}
|
|
284
284
|
return e;
|
|
285
|
-
})(), P = 6, F = 20, I = .003, L = -1e9, R = 0;
|
|
286
|
-
function
|
|
285
|
+
})(), N = -1, P = 6, F = 20, I = .003, L = -1e9, R = 8, z = 0;
|
|
286
|
+
function B(e, t, n) {
|
|
287
|
+
let r = 0;
|
|
288
|
+
for (; r < n && e < 1;) {
|
|
289
|
+
if (e >= 11754943508222875e-54) {
|
|
290
|
+
let i = 2 ** Math.floor(Math.log2(e));
|
|
291
|
+
i > e ? i /= 2 : i * 2 <= e && (i *= 2);
|
|
292
|
+
let a = i * 2, o = i / 8388608, s = Math.fround(e + t) - e;
|
|
293
|
+
if (s === 0) return z = e, n;
|
|
294
|
+
let c = e + o;
|
|
295
|
+
if (c + t < a && Math.fround(c + t) - c === s) {
|
|
296
|
+
let i = Math.max(0, Math.floor((a - t - e) / s) + 1);
|
|
297
|
+
for (; i > 0 && !(e + (i - 1) * s + t < a);) i--;
|
|
298
|
+
for (; e + i * s + t < a;) i++;
|
|
299
|
+
if (i = Math.min(i, n - r), i >= 1) {
|
|
300
|
+
e += i * s, r += i;
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
let i = Math.fround(e + t);
|
|
306
|
+
if (i === e) return z = e, n;
|
|
307
|
+
e = i, r++;
|
|
308
|
+
}
|
|
309
|
+
return z = e, r;
|
|
310
|
+
}
|
|
311
|
+
var V = B;
|
|
312
|
+
function H(e, t, n) {
|
|
313
|
+
return B(e, t, n), z;
|
|
314
|
+
}
|
|
315
|
+
function U(e, t) {
|
|
316
|
+
let n = e.length;
|
|
317
|
+
for (e.push(t); n > 0;) {
|
|
318
|
+
let r = n - 1 >> 1;
|
|
319
|
+
if (e[r] <= t) break;
|
|
320
|
+
e[n] = e[r], n = r;
|
|
321
|
+
}
|
|
322
|
+
e[n] = t;
|
|
323
|
+
}
|
|
324
|
+
function W(e) {
|
|
325
|
+
let t = e.pop();
|
|
326
|
+
if (!e.length) return;
|
|
327
|
+
let n = 0;
|
|
328
|
+
for (;;) {
|
|
329
|
+
let r = 2 * n + 1;
|
|
330
|
+
if (r >= e.length || (r + 1 < e.length && e[r + 1] < e[r] && r++, e[r] >= t)) break;
|
|
331
|
+
e[n] = e[r], n = r;
|
|
332
|
+
}
|
|
333
|
+
e[n] = t;
|
|
334
|
+
}
|
|
335
|
+
var G = 0;
|
|
336
|
+
function K(e) {
|
|
287
337
|
let t = e >>> 0;
|
|
288
338
|
return () => {
|
|
289
339
|
t = t + 1831565813 >>> 0;
|
|
@@ -291,22 +341,22 @@ function z(e) {
|
|
|
291
341
|
return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
|
|
292
342
|
};
|
|
293
343
|
}
|
|
294
|
-
var
|
|
344
|
+
var te = class n {coreRequirement=__margoCoreRequirement("1.0.0",import.meta.url);
|
|
295
345
|
constructor(e) {
|
|
296
|
-
if (this.name = "fire-front:" +
|
|
346
|
+
if (this.name = "fire-front:" + G++, this.time = 0, this.embers = 0, this.spots = 0, this.stepped = !1, this.doubled = 0, this.fromEngine = !1, this.disposed = !1, this.acc = 0, this.fuels = [], this.burning = [], this.pending = [], this.travel = /* @__PURE__ */ new Map(), this.carry = /* @__PURE__ */ new Map(), this.carryKey = "", this.seqN = 0, this.stepN = 0, this.visitSeq = -1, this.lazyOn = !1, this.lazy = /* @__PURE__ */ new Map(), this.due = /* @__PURE__ */ new Map(), this.dueSteps = [], this.dying = /* @__PURE__ */ new Map(), this.beds = [], this.bedKey = "", this.dirty = !0, this.columns = [], this.segs = /* @__PURE__ */ new Map(), this.flameAcc = /* @__PURE__ */ new Map(), this.frontFlames = [], this.houseFlames = [], this.emberPool = [], this.emberBase = [], this.frontKeys = [], this.houseKeys = [], this.midflame = [0, 0], this.born = [], this.smokeReady = Promise.resolve(), this.smokeRadius = !1, typeof e != "object" || !e) throw TypeError("FireFront options must be an object");
|
|
297
347
|
this.options = e;
|
|
298
348
|
let t = e.size ?? [1024, 1024], n = f(e.cell ?? 8, "cell", 1, 100);
|
|
299
349
|
for (let e of t) f(e, "size", n, 1e5);
|
|
300
350
|
if (this.width = Math.max(1, Math.ceil(t[0] / n)), this.height = Math.max(1, Math.ceil(t[1] / n)), this.width * this.height > 4194304) throw RangeError("FireFront grid is over 4,194,304 cells; raise cell or lower size.");
|
|
301
|
-
this.cell = n, this.origin = e.origin ?? [-t[0] / 2, -t[1] / 2], this.step = f(e.step ?? .5, "step", .05, 5), this.seg = Math.max(n, f(e.segment ?? 120, "segment", 1, 1e5)), this.random =
|
|
351
|
+
this.cell = n, this.origin = e.origin ?? [-t[0] / 2, -t[1] / 2], this.step = f(e.step ?? .5, "step", .05, 5), this.seg = Math.max(n, f(e.segment ?? 120, "segment", 1, 1e5)), this.random = K(f(e.seed ?? 1, "seed", 0, 4294967295)), this.checkLive();
|
|
302
352
|
let r = this.width * this.height;
|
|
303
|
-
this.cellFuel = new Uint8Array(r), this.structureOf = new Uint16Array(r), this.stateOf = new Uint8Array(r), this.arrival = new Float32Array(r).fill(-1), this.burnout = new Float32Array(r).fill(-1), this.intensity = new Float32Array(r), this.exposure = new Float32Array(r), this.slopeX = new Float32Array(r), this.slopeZ = new Float32Array(r), this.crownOf = new Float32Array(r), this.fed = new Uint8Array(r), e.canopy && (this.stands = new Float32Array(r * 3)), this.rows = new Float32Array(this.width * 4), this.fill();
|
|
353
|
+
this.cellFuel = new Uint8Array(r), this.structureOf = new Uint16Array(r), this.stateOf = new Uint8Array(r), this.arrival = new Float32Array(r).fill(-1), this.burnout = new Float32Array(r).fill(-1), this.intensity = new Float32Array(r), this.exposure = new Float32Array(r), this.slopeX = new Float32Array(r), this.slopeZ = new Float32Array(r), this.crownOf = new Float32Array(r), this.fed = new Uint8Array(r), this.seqOf = new Float64Array(r), this.cellOfSeq = new Int32Array(r + 1), e.canopy && (this.stands = new Float32Array(r * 3)), this.rows = new Float32Array(this.width * 4), this.fill();
|
|
304
354
|
for (let t of e.ignitions ?? []) this.queue(t);
|
|
305
355
|
}
|
|
306
356
|
static create(e = {}) {
|
|
307
357
|
return new n(e);
|
|
308
358
|
}
|
|
309
|
-
static attach(t, r = {}) {__margoAssertCore(t,__margoCoreRequirement("
|
|
359
|
+
static attach(t, r = {}) {__margoAssertCore(t,__margoCoreRequirement("1.0.0",import.meta.url));
|
|
310
360
|
let i = new n(r);
|
|
311
361
|
return e(t).use(i), i;
|
|
312
362
|
}
|
|
@@ -401,15 +451,56 @@ var B = class n {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url)
|
|
|
401
451
|
get smokeEmission() {
|
|
402
452
|
let e = 0;
|
|
403
453
|
for (let t of this.segs.values()) e += t.heat / .7;
|
|
404
|
-
return (this.options.smokeYield ?? 15) * e /
|
|
454
|
+
return (this.options.smokeYield ?? 15) * e / ee;
|
|
405
455
|
}
|
|
406
456
|
get radiantPower() {
|
|
407
457
|
let e = 0;
|
|
408
458
|
for (let t of this.segs.values()) e += t.heat;
|
|
409
|
-
return
|
|
459
|
+
return j / .7 * e;
|
|
460
|
+
}
|
|
461
|
+
get noon() {
|
|
462
|
+
return this.noonValue;
|
|
463
|
+
}
|
|
464
|
+
set noon(e) {
|
|
465
|
+
e !== void 0 && f(e, "noon", 1e-9, 1e7), this.noonValue = e;
|
|
466
|
+
for (let e of this.columns) this.noonOn(e);
|
|
467
|
+
}
|
|
468
|
+
noonOn(e) {
|
|
469
|
+
let t = e.options;
|
|
470
|
+
this.noonValue === void 0 ? this.options.smoke?.noon === void 0 ? delete t.noon : t.noon = this.options.smoke.noon : t.noon = this.noonValue, this.airValue ? t.air = this.airValue : this.options.smoke?.air === void 0 ? delete t.air : t.air = this.options.smoke.air, this.airBackValue ? t.airReflectance = this.airBackValue : this.options.smoke?.airReflectance === void 0 ? delete t.airReflectance : t.airReflectance = this.options.smoke.airReflectance;
|
|
471
|
+
}
|
|
472
|
+
get air() {
|
|
473
|
+
return this.airValue;
|
|
474
|
+
}
|
|
475
|
+
set air(e) {
|
|
476
|
+
if (e !== void 0) {
|
|
477
|
+
if (!Array.isArray(e) || e.length !== 3) throw TypeError("FireFront air must be [r, g, b] or undefined");
|
|
478
|
+
for (let t of e) f(t, "air", 0, 1e3);
|
|
479
|
+
}
|
|
480
|
+
this.airValue = e && [
|
|
481
|
+
e[0],
|
|
482
|
+
e[1],
|
|
483
|
+
e[2]
|
|
484
|
+
];
|
|
485
|
+
for (let e of this.columns) this.noonOn(e);
|
|
486
|
+
}
|
|
487
|
+
get airReflectance() {
|
|
488
|
+
return this.airBackValue;
|
|
489
|
+
}
|
|
490
|
+
set airReflectance(e) {
|
|
491
|
+
if (e !== void 0) {
|
|
492
|
+
if (!Array.isArray(e) || e.length !== 3) throw TypeError("FireFront airReflectance must be [r, g, b] or undefined");
|
|
493
|
+
for (let t of e) f(t, "airReflectance", 0, 1);
|
|
494
|
+
}
|
|
495
|
+
this.airBackValue = e && [
|
|
496
|
+
e[0],
|
|
497
|
+
e[1],
|
|
498
|
+
e[2]
|
|
499
|
+
];
|
|
500
|
+
for (let e of this.columns) this.noonOn(e);
|
|
410
501
|
}
|
|
411
502
|
get active() {
|
|
412
|
-
return this.burning.length > 0 || this.pending.length > 0;
|
|
503
|
+
return this.burning.length > 0 || this.pending.length > 0 || this.lazy.size > 0;
|
|
413
504
|
}
|
|
414
505
|
queue(e) {
|
|
415
506
|
if (!Array.isArray(e.at) || e.at.length !== 2) throw TypeError("FireFront ignition needs at: [x, z]");
|
|
@@ -429,7 +520,72 @@ var B = class n {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url)
|
|
|
429
520
|
light(e, t) {
|
|
430
521
|
if (this.stateOf[e] !== 0 || !this.cellFuel[e]) return !1;
|
|
431
522
|
let n = this.bedsFor()[this.cellFuel[e] - 1], r = n.model;
|
|
432
|
-
return this.stateOf[e] = 1, this.arrival[e] = t, this.burnout[e] = t + (r.structure ? this.options.structureBurnTime ?? 1800 : n.residence), this.born.push(e), this.dirty = !0, !0;
|
|
523
|
+
return this.stateOf[e] = 1, this.arrival[e] = t, this.burnout[e] = t + (r.structure ? this.options.structureBurnTime ?? 1800 : n.residence), this.born.push(e), this.dirty = !0, this.seqOf[e] = ++this.seqN, this.cellOfSeq[this.seqN] = e, this.lazy.size && this.closeToward(e), !0;
|
|
524
|
+
}
|
|
525
|
+
closeToward(e) {
|
|
526
|
+
let { width: t, height: n } = this, r = e % t, i = (e - r) / t, a = this.stepN;
|
|
527
|
+
for (let e = 0; e < M.length; e++) {
|
|
528
|
+
let [o, s] = M[e], c = r - o, l = i - s;
|
|
529
|
+
if (c < 0 || l < 0 || c >= t || l >= n) continue;
|
|
530
|
+
let u = l * t + c, d = this.lazy.get(u);
|
|
531
|
+
d && d.open & 1 << e && (d.open &= ~(1 << e), this.closed(u, d, this.seqOf[u] > this.visitSeq ? a : a + 1));
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
closed(e, t, n) {
|
|
535
|
+
if (n > t.death && (t.death = n), t.open === 0) {
|
|
536
|
+
let n = this.dying.get(t.death);
|
|
537
|
+
n ? n.push(e) : this.dying.set(t.death, [e]);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
lazify(e, t, n) {
|
|
541
|
+
let r = this.travel.get(e), { width: i } = this, a = e % i, o = (e - a) / i, s = this.seqOf[e], c = 0, l = [];
|
|
542
|
+
for (let e = 0; e < M.length; e++) {
|
|
543
|
+
let t = n[e];
|
|
544
|
+
if (r[e] >= 1 || t === N) continue;
|
|
545
|
+
let s = (o + M[e][1]) * i + a + M[e][0];
|
|
546
|
+
if (this.stateOf[s] === 0) {
|
|
547
|
+
if (!(t > 0)) return !1;
|
|
548
|
+
c |= 1 << e, l.push(e, V(r[e], t, Infinity));
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
let u = {
|
|
552
|
+
entry: t,
|
|
553
|
+
open: c,
|
|
554
|
+
death: t + 1
|
|
555
|
+
};
|
|
556
|
+
this.lazy.set(e, u);
|
|
557
|
+
for (let e = 0; e < l.length; e += 2) {
|
|
558
|
+
let n = l[e + 1];
|
|
559
|
+
if (n === Infinity) continue;
|
|
560
|
+
let r = t + n, i = this.due.get(r), a = s * 16 + l[e];
|
|
561
|
+
i ? i.push(a) : (this.due.set(r, [a]), U(this.dueSteps, r));
|
|
562
|
+
}
|
|
563
|
+
return c === 0 && this.closed(e, u, t + 1), !0;
|
|
564
|
+
}
|
|
565
|
+
reach(e, t, n) {
|
|
566
|
+
let r = Math.floor(e / 16), i = e - r * 16, a = this.cellOfSeq[r], o = this.lazy.get(a);
|
|
567
|
+
if (!o || !(o.open & 1 << i)) return;
|
|
568
|
+
o.open &= ~(1 << i), this.visitSeq = r;
|
|
569
|
+
let s = a + M[i][1] * this.width + M[i][0];
|
|
570
|
+
this.light(s, t) && this.carry.get(a)[M.length + i] === 1 ? (this.fed[s] = 1, this.closed(a, o, n)) : this.closed(a, o, n + 1);
|
|
571
|
+
}
|
|
572
|
+
flush() {
|
|
573
|
+
if (!this.lazy.size) return;
|
|
574
|
+
let e = this.stepN, t = [];
|
|
575
|
+
for (let [n, r] of this.lazy) {
|
|
576
|
+
let i = this.travel.get(n), a = this.carry.get(n);
|
|
577
|
+
for (let t = 0; t < M.length; t++) r.open & 1 << t ? i[t] = H(i[t], a[t], e - r.entry) : i[t] < 1 && a[t] !== N && (i[t] = 2);
|
|
578
|
+
t.push(n);
|
|
579
|
+
}
|
|
580
|
+
t.sort((e, t) => this.seqOf[e] - this.seqOf[t]);
|
|
581
|
+
let n = this.burning, r = [], i = 0, a = 0;
|
|
582
|
+
for (; i < n.length || a < t.length;) a >= t.length || i < n.length && this.seqOf[n[i]] < this.seqOf[t[a]] ? r.push(n[i++]) : r.push(t[a++]);
|
|
583
|
+
this.burning = r, this.lazy.clear(), this.due.clear(), this.dueSteps.length = 0, this.dying.clear();
|
|
584
|
+
}
|
|
585
|
+
nextLazyStep() {
|
|
586
|
+
let e = this.dueSteps.length ? this.dueSteps[0] : Infinity;
|
|
587
|
+
for (let t of this.dying.keys()) t < e && (e = t);
|
|
588
|
+
return e;
|
|
433
589
|
}
|
|
434
590
|
lightArea(e, t) {
|
|
435
591
|
let { width: n, height: r, cell: i, origin: a } = this, o = e.radius ?? 0, s = Math.floor((e.at[0] - o - a[0]) / i), c = Math.floor((e.at[0] + o - a[0]) / i), l = Math.floor((e.at[1] - o - a[1]) / i), u = Math.floor((e.at[1] + o - a[1]) / i);
|
|
@@ -448,12 +604,12 @@ var B = class n {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url)
|
|
|
448
604
|
}
|
|
449
605
|
advanceTime(e) {
|
|
450
606
|
if (this.disposed) throw new t("disposed", "FireFront is disposed; attach a new FireFront");
|
|
451
|
-
for (f(e, "delta", 0, 86400), this.checkLive(), this.acc += e; this.acc >= this.step - 1e-9;) this.acc -= this.step, this.advance(this.step);
|
|
607
|
+
for (f(e, "delta", 0, 86400), e > 0 && this.engine && !this.fromEngine && (this.stepped = !0), this.checkLive(), this.acc += e; this.acc >= this.step - 1e-9;) this.acc -= this.step, this.advance(this.step);
|
|
452
608
|
this.dirty && this.publish(), this.syncFlames();
|
|
453
609
|
}
|
|
454
610
|
resetTime() {
|
|
455
611
|
if (this.disposed) return;
|
|
456
|
-
this.time = this.acc = this.embers = this.spots = 0, this.random =
|
|
612
|
+
this.time = this.acc = this.embers = this.spots = 0, this.stepped = !1, this.doubled = 0, this.random = K(f(this.options.seed ?? 1, "seed", 0, 4294967295));
|
|
457
613
|
let e = this.stateOf;
|
|
458
614
|
for (let t = 0; t < e.length; t++) e[t] !== 3 && (e[t] = 0);
|
|
459
615
|
this.arrival.fill(-1), this.burnout.fill(-1);
|
|
@@ -465,7 +621,7 @@ var B = class n {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url)
|
|
|
465
621
|
]) e.fill(0);
|
|
466
622
|
this.burning = [], this.born = [], this.pending = [];
|
|
467
623
|
for (let e of this.options.ignitions ?? []) this.queue(e);
|
|
468
|
-
this.travel.clear(), this.segs.clear(), this.flameAcc.clear(), this.bedKey = "", this.beds = [], this.fm10 = void 0, this.frontKeys.fill(void 0), this.houseKeys.fill(void 0);
|
|
624
|
+
this.travel.clear(), this.carry.clear(), this.carryKey = "", this.lazy.clear(), this.due.clear(), this.dueSteps.length = 0, this.dying.clear(), this.seqN = this.stepN = 0, this.visitSeq = -1, this.seqOf.fill(0), this.cellOfSeq.fill(0), this.segs.clear(), this.flameAcc.clear(), this.bedKey = "", this.beds = [], this.fm10 = void 0, this.frontKeys.fill(void 0), this.houseKeys.fill(void 0);
|
|
469
625
|
for (let e of [
|
|
470
626
|
...this.columns,
|
|
471
627
|
...this.frontFlames,
|
|
@@ -480,73 +636,140 @@ var B = class n {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url)
|
|
|
480
636
|
async settle(e = 86400, t) {
|
|
481
637
|
f(e, "maxSeconds", 0, 1e9);
|
|
482
638
|
let n = this.time + e, r = 0;
|
|
483
|
-
|
|
639
|
+
this.lazyOn = !0;
|
|
640
|
+
try {
|
|
641
|
+
for (; this.active && this.time < n;) {
|
|
642
|
+
if (t?.throwIfAborted(), this.burning.length === 0 && this.pending.length === 0) {
|
|
643
|
+
let e = this.nextLazyStep(), t = !1;
|
|
644
|
+
for (; this.stepN + 1 < e && this.time < n;) this.time += this.step, this.stepN++, t = !0;
|
|
645
|
+
if (t && (this.segs.clear(), this.flameAcc.clear()), this.time >= n) break;
|
|
646
|
+
}
|
|
647
|
+
this.advance(this.step), ++r % 4096 == 0 && (this.flush(), await Promise.resolve());
|
|
648
|
+
}
|
|
649
|
+
} finally {
|
|
650
|
+
this.flush(), this.lazyOn = !1;
|
|
651
|
+
}
|
|
484
652
|
return this.dirty && this.publish(), this.time;
|
|
485
653
|
}
|
|
486
654
|
advance(e) {
|
|
487
|
-
let t = this.time + e, n = this.options, { width: r, height: i, cell: a } = this, o = this.bedsFor()
|
|
488
|
-
|
|
655
|
+
let t = this.time + e, n = this.options, { width: r, height: i, cell: a } = this, o = this.bedsFor(), s = n.wind ?? [0, 0], c = Array.isArray(s) ? [
|
|
656
|
+
s[0],
|
|
657
|
+
s[1],
|
|
658
|
+
n.windReduction ?? .4,
|
|
659
|
+
n.foliarMoisture ?? 1,
|
|
660
|
+
n.crown,
|
|
661
|
+
this.bedKey,
|
|
662
|
+
e
|
|
663
|
+
].join() : "";
|
|
664
|
+
this.lazy.size && (c === "" || c !== this.carryKey) && this.flush();
|
|
665
|
+
let l = ++this.stepN;
|
|
666
|
+
for (this.visitSeq = -1; this.pending.length && (this.pending[0].time ?? 0) <= t;) this.lightArea(this.pending.shift(), t);
|
|
489
667
|
for (let e of this.born) this.burning.push(e);
|
|
490
668
|
this.born.length = 0;
|
|
491
|
-
let
|
|
669
|
+
let u = n.windReduction ?? .4, d = n.spotting ?? .02, f = [0, 0], p = this.fm10, g = n.foliarMoisture ?? 1, _ = {
|
|
492
670
|
baseHeight: 0,
|
|
493
671
|
bulkDensity: 0,
|
|
494
672
|
height: 0
|
|
495
|
-
},
|
|
673
|
+
}, y = c;
|
|
674
|
+
(y === "" || y !== this.carryKey) && (this.carry.clear(), this.carryKey = y);
|
|
675
|
+
let b = [];
|
|
496
676
|
this.segs.clear(), this.flameAcc.clear();
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
677
|
+
let x;
|
|
678
|
+
this.dueSteps.length && this.dueSteps[0] === l && (W(this.dueSteps), x = this.due.get(l).sort((e, t) => e - t), this.due.delete(l));
|
|
679
|
+
let S = 0, w = this.burning;
|
|
680
|
+
for (let s = 0; s < w.length; s++) {
|
|
681
|
+
let c = w[s], E = this.seqOf[c];
|
|
682
|
+
if (x) for (; S < x.length && x[S] < E * 16;) this.reach(x[S++], t, l);
|
|
683
|
+
this.visitSeq = E;
|
|
684
|
+
let D = c % r, O = (c - D) / r, k = this.origin[0] + (D + .5) * a, A = this.origin[1] + (O + .5) * a, j = o[this.cellFuel[c] - 1];
|
|
685
|
+
this.stateOf[c] === 1 && t >= this.burnout[c] && (this.stateOf[c] = 2, this.dirty = !0);
|
|
686
|
+
let P = this.stateOf[c] === 1 ? void 0 : this.carry.get(c);
|
|
687
|
+
if (P) {
|
|
688
|
+
this.carryOn(c, D, O, t, P) ? (!this.lazyOn || !this.lazify(c, l, P)) && b.push(c) : (this.travel.delete(c), this.carry.delete(c));
|
|
689
|
+
continue;
|
|
690
|
+
}
|
|
691
|
+
this.windAt(k, A, f);
|
|
692
|
+
let F = Math.hypot(f[0], f[1]) * u, I = m(j, F), R = this.slopeX[c], z = this.slopeZ[c], B = Math.hypot(R, z), V = h(j, B), H = F > 1e-9 ? f[0] / Math.hypot(f[0], f[1]) : 0, U = F > 1e-9 ? f[1] / Math.hypot(f[0], f[1]) : 0, W = B > 1e-9 ? R / B : 0, G = B > 1e-9 ? z / B : 0, K = I * H + V * W, te = I * U + V * G, q = Math.hypot(K, te), J = v(j, I, V, q), ne = q > 1e-9 ? K / q : 1, re = q > 1e-9 ? te / q : 0, ie = Math.sqrt(Math.max(J.lengthToBreadth ** 2 - 1, 0)) / J.lengthToBreadth, ae = this.canopyAt(c, j.model, _), Y, oe = ne, se = re, ce = ie;
|
|
693
|
+
if (ae) {
|
|
694
|
+
let e = Math.hypot(f[0], f[1]), t = T(p, e), n = h(p, B), r = t * H + n * W, i = t * U + n * G, a = Math.hypot(r, i), o = C(J, ae, g, 3.34 * p.rate0 * (1 + a), e, this.fed[c] === 1);
|
|
695
|
+
o.fraction > 0 && (Y = o, a > 1e-9 && (oe = r / a, se = i / a), ce = Math.sqrt(Math.max(o.lengthToBreadth ** 2 - 1, 0)) / o.lengthToBreadth);
|
|
504
696
|
}
|
|
505
|
-
let
|
|
506
|
-
if (
|
|
507
|
-
this.intensity[
|
|
508
|
-
let r = a * a, i = X ? .7 *
|
|
509
|
-
s ? (s.x +=
|
|
510
|
-
x:
|
|
511
|
-
z:
|
|
697
|
+
let le = this.stateOf[c] === 1, X = j.model.structure === !0, Z = Y ?? J;
|
|
698
|
+
if (le) {
|
|
699
|
+
this.intensity[c] = Z.firelineIntensity / 1e3, Y && Y.fraction > this.crownOf[c] && (this.crownOf[c] = Y.fraction);
|
|
700
|
+
let r = a * a, i = X ? .7 * j.consumed * ee / (n.structureBurnTime ?? 1800) * r : .7 * J.reactionIntensity * 1e3 * r * (Y ? Y.firelineIntensity / Y.rate / (J.firelineIntensity / J.rate) : 1), o = Math.floor((A - this.origin[1]) / this.seg) * 65536 + Math.floor((k - this.origin[0]) / this.seg), s = this.segs.get(o);
|
|
701
|
+
s ? (s.x += k * i, s.z += A * i, s.heat += i, s.cells++) : this.segs.set(o, {
|
|
702
|
+
x: k * i,
|
|
703
|
+
z: A * i,
|
|
512
704
|
heat: i,
|
|
513
705
|
cells: 1
|
|
514
706
|
});
|
|
515
|
-
let
|
|
516
|
-
|
|
517
|
-
x:
|
|
518
|
-
z:
|
|
707
|
+
let l = X ? this.structureOf[c] ? -this.structureOf[c] : L - o : o, u = this.flameAcc.get(l);
|
|
708
|
+
u ? (u.x += k * i, u.z += A * i, u.heat += i, u.cells++, u.intensity += Z.firelineIntensity * i, u.crown += (Y?.fraction ?? 0) * i, u.xx += k * k * i, u.zz += A * A * i, u.xz += k * A * i, u.minX = Math.min(u.minX, k - a / 2), u.maxX = Math.max(u.maxX, k + a / 2), u.minZ = Math.min(u.minZ, A - a / 2), u.maxZ = Math.max(u.maxZ, A + a / 2)) : this.flameAcc.set(l, {
|
|
709
|
+
x: k * i,
|
|
710
|
+
z: A * i,
|
|
519
711
|
heat: i,
|
|
520
712
|
cells: 1,
|
|
521
713
|
intensity: Z.firelineIntensity * i,
|
|
522
|
-
crown: (
|
|
523
|
-
xx:
|
|
524
|
-
zz:
|
|
525
|
-
xz:
|
|
526
|
-
minX:
|
|
527
|
-
maxX:
|
|
528
|
-
minZ:
|
|
529
|
-
maxZ:
|
|
530
|
-
structure: X ? this.structureOf[
|
|
531
|
-
}), Z.firelineIntensity > 1e3 &&
|
|
714
|
+
crown: (Y?.fraction ?? 0) * i,
|
|
715
|
+
xx: k * k * i,
|
|
716
|
+
zz: A * A * i,
|
|
717
|
+
xz: k * A * i,
|
|
718
|
+
minX: k - a / 2,
|
|
719
|
+
maxX: k + a / 2,
|
|
720
|
+
minZ: A - a / 2,
|
|
721
|
+
maxZ: A + a / 2,
|
|
722
|
+
structure: X ? this.structureOf[c] : 0
|
|
723
|
+
}), Z.firelineIntensity > 1e3 && d > 0 && this.throwEmbers(c, Z, f, t, e, d), X || this.exposeStructures(c, Z.flameLength, e, t);
|
|
532
724
|
}
|
|
533
|
-
let Q = this.travel.get(
|
|
534
|
-
Q || this.travel.set(
|
|
535
|
-
let $ =
|
|
536
|
-
|
|
725
|
+
let Q = this.travel.get(c);
|
|
726
|
+
Q || this.travel.set(c, Q = new Float32Array(M.length));
|
|
727
|
+
let $ = y ? this.carry.get(c) : void 0;
|
|
728
|
+
y && !$ && this.carry.set(c, $ = new Float64Array(2 * M.length).fill(NaN));
|
|
729
|
+
let ue = !1;
|
|
730
|
+
for (let n = 0; n < M.length; n++) {
|
|
537
731
|
if (Q[n] >= 1) continue;
|
|
538
|
-
let [o, s] =
|
|
539
|
-
if (c < 0 || l < 0 || c >= r || l >= i || !this.cellFuel[u] || this.fuels[this.cellFuel[u] - 1].structure
|
|
732
|
+
let [o, s] = M[n], c = D + o, l = O + s, u = l * r + c;
|
|
733
|
+
if (c < 0 || l < 0 || c >= r || l >= i || !this.cellFuel[u] || this.fuels[this.cellFuel[u] - 1].structure) {
|
|
734
|
+
Q[n] = 2, $ && ($[n] = N);
|
|
735
|
+
continue;
|
|
736
|
+
}
|
|
737
|
+
if (this.stateOf[u] !== 0) {
|
|
540
738
|
Q[n] = 2;
|
|
541
739
|
continue;
|
|
542
740
|
}
|
|
543
|
-
let d =
|
|
544
|
-
|
|
741
|
+
let d = Y !== void 0 && this.canopyAt(u, this.fuels[this.cellFuel[u] - 1], _) !== void 0, f = d ? Y.rate : J.rate, p = d ? ce : ie, m = Math.hypot(o, s) * a, h = (o * (d ? oe : ne) + s * (d ? se : re)) / Math.hypot(o, s), g = f * (1 - p) / (1 - p * h);
|
|
742
|
+
if (!(g > 1e-9)) {
|
|
743
|
+
Q[n] = 2, $ && ($[n] = N);
|
|
744
|
+
continue;
|
|
745
|
+
}
|
|
746
|
+
let v = g * e / m, y = d && Y.type === "active";
|
|
747
|
+
$ && ($[n] = v, $[M.length + n] = +!!y), Q[n] = Q[n] + v, Q[n] >= 1 && this.light(u, t) && y ? this.fed[u] = 1 : ue = !0;
|
|
545
748
|
}
|
|
546
|
-
this.stateOf[
|
|
749
|
+
this.stateOf[c] === 1 || ue ? b.push(c) : (this.travel.delete(c), this.carry.delete(c));
|
|
547
750
|
}
|
|
548
|
-
for (
|
|
549
|
-
|
|
751
|
+
if (x) for (; S < x.length;) this.reach(x[S++], t, l);
|
|
752
|
+
let E = this.dying.get(l);
|
|
753
|
+
if (E) {
|
|
754
|
+
for (let e of E) this.lazy.delete(e), this.travel.delete(e), this.carry.delete(e);
|
|
755
|
+
this.dying.delete(l);
|
|
756
|
+
}
|
|
757
|
+
for (let e of this.born) b.push(e);
|
|
758
|
+
this.born.length = 0, this.burning = b, this.time = t;
|
|
759
|
+
}
|
|
760
|
+
carryOn(e, t, n, r, i) {
|
|
761
|
+
let a = this.travel.get(e), o = M.length, s = !1;
|
|
762
|
+
for (let e = 0; e < o; e++) {
|
|
763
|
+
if (a[e] >= 1) continue;
|
|
764
|
+
let c = i[e];
|
|
765
|
+
if (c === N) {
|
|
766
|
+
a[e] = 2;
|
|
767
|
+
continue;
|
|
768
|
+
}
|
|
769
|
+
let [l, u] = M[e], d = (n + u) * this.width + t + l;
|
|
770
|
+
this.stateOf[d] === 0 ? (a[e] = a[e] + c, a[e] >= 1 && this.light(d, r) && i[o + e] === 1 ? this.fed[d] = 1 : s = !0) : a[e] = 2;
|
|
771
|
+
}
|
|
772
|
+
return s;
|
|
550
773
|
}
|
|
551
774
|
exposeStructures(e, t, n, r) {
|
|
552
775
|
let { width: i, height: a, cell: o } = this, s = Math.min(8, Math.ceil(1.5 * t / o) + 1), c = e % i, l = (e - c) / i, u = this.options.structureExposure ?? 90;
|
|
@@ -696,6 +919,7 @@ var B = class n {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url)
|
|
|
696
919
|
],
|
|
697
920
|
heat: 0
|
|
698
921
|
}));
|
|
922
|
+
for (let e of this.columns) this.noonOn(e);
|
|
699
923
|
if (this.smokeLook) for (let e of this.columns) this.smokeLook(e);
|
|
700
924
|
this.dirty = !0, this.publish();
|
|
701
925
|
}
|
|
@@ -800,8 +1024,18 @@ var B = class n {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url)
|
|
|
800
1024
|
continue;
|
|
801
1025
|
}
|
|
802
1026
|
let c = s.position, l = s.footprint, u = s.wind, d = o.kind === "structure" ? .7 : 1;
|
|
803
|
-
c[0] = o.x, c[1] = o.y, c[2] = o.z, l[0] = o.footprint[0] * d, l[1] = o.footprint[1] * d, s.yaw = o.yaw, s.length = o.flameLength, s.
|
|
1027
|
+
c[0] = o.x, c[1] = o.y, c[2] = o.z, l[0] = o.footprint[0] * d, l[1] = o.footprint[1] * d, s.yaw = o.yaw, s.length = o.flameLength, s.heat = o.heat / .7;
|
|
1028
|
+
let f = this.noonValue ?? this.options.smoke?.noon;
|
|
1029
|
+
f === void 0 ? delete s.noon : s.noon = f, s.slope = o.slope, s.relief = o.kind === "front" ? this.reliefOf(o, s.relief ?? new Float32Array(R ** 2)) : void 0, o.kind === "front" && (s.crowns = this.options.flame?.crowns ?? (o.crown >= .25 ? P : 0)), this.windAt(o.x, o.z, this.midflame), u[0] = this.midflame[0] * i, u[1] = this.midflame[1] * i;
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
reliefOf(e, t) {
|
|
1033
|
+
let n = this.options.ground ?? (() => 0), r = Math.cos(e.yaw), i = Math.sin(e.yaw), a = e.footprint[0] / 2, o = e.footprint[1] / 2;
|
|
1034
|
+
for (let s = 0; s < R; s++) for (let c = 0; c < R; c++) {
|
|
1035
|
+
let l = (2 * c / 7 - 1) * a, u = (2 * s / 7 - 1) * o, d = r * l + i * u, f = -i * l + r * u;
|
|
1036
|
+
t[s * R + c] = n(e.x + d, e.z + f) - (e.y + e.slope[0] * d + e.slope[1] * f);
|
|
804
1037
|
}
|
|
1038
|
+
return t;
|
|
805
1039
|
}
|
|
806
1040
|
placeEmbers() {
|
|
807
1041
|
let e = this.flameLook, t = (t) => e && typeof e[t] == "number" ? e[t] : 1;
|
|
@@ -820,7 +1054,13 @@ var B = class n {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url)
|
|
|
820
1054
|
}
|
|
821
1055
|
}
|
|
822
1056
|
onPreUpdate(e) {
|
|
823
|
-
this.advanceTime
|
|
1057
|
+
if (e > 0 && (this.doubled = this.stepped ? this.doubled + 1 : 0, this.stepped = !1, this.doubled >= 2)) throw new t("state", "FireFront was stepped with advanceTime between engine frames that also step it, so it burns faster than the engine clock; step it one way: leave it to the engine, or step a fire made without an engine yourself");
|
|
1058
|
+
this.fromEngine = !0;
|
|
1059
|
+
try {
|
|
1060
|
+
this.advanceTime(e);
|
|
1061
|
+
} finally {
|
|
1062
|
+
this.fromEngine = !1;
|
|
1063
|
+
}
|
|
824
1064
|
}
|
|
825
1065
|
dispose() {
|
|
826
1066
|
if (!this.disposed) {
|
|
@@ -837,4 +1077,4 @@ var B = class n {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url)
|
|
|
837
1077
|
}
|
|
838
1078
|
};
|
|
839
1079
|
//#endregion
|
|
840
|
-
export { O as BURNING, k as BURNT, a as FUEL_MODELS,
|
|
1080
|
+
export { O as BURNING, k as BURNT, a as FUEL_MODELS, te as FireFront, A as NO_FUEL, j as RADIANT_SHARE, D as UNBURNT, C as crownBehaviour, w as crownRate10, y as ellipseRate, g as fireBehaviour, p as fuelBed, h as slopeFactor, m as windFactor };
|