@margoengine/scenes 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 +620 -387
- package/dist/{dune-coast-info-e8eDZXBu.js → dune-coast-info-D9yQIv8G.js} +13 -3
- package/dist/dune-coast.d.ts +20 -1
- package/dist/dune-coast.js +374 -187
- package/dist/errors-fc4i1pSL.js +7 -0
- package/dist/fauld-blast.d.ts +119 -21
- package/dist/fauld-blast.js +957 -206
- package/dist/fauld-countryside.d.ts +1 -1
- package/dist/fauld-countryside.js +4 -4
- package/dist/fauld-crater.d.ts +1 -1
- package/dist/fauld-crater.js +4 -4
- package/dist/fauld-dig.d.ts +89 -0
- package/dist/fauld-dustfall-fines-grid-MA6XPrq6.js +14 -0
- package/dist/fauld-dustfall-fines-grid.d.ts +11 -0
- package/dist/fauld-dustfall-grid-Bb4X8b-u.js +14 -0
- package/dist/fauld-dustfall-grid.d.ts +11 -0
- package/dist/fauld-explosion.d.ts +135 -0
- package/dist/fauld-grains.d.ts +27 -0
- package/dist/fauld-mud.d.ts +104 -0
- package/dist/fauld-surge.d.ts +71 -0
- package/dist/fauld-tunnels.d.ts +76 -3
- package/dist/fauld-tunnels.js +518 -193
- package/dist/fauld-world-CNNSonJF.js +863 -0
- package/dist/fauld-world.d.ts +86 -3
- package/dist/index.js +2 -2
- package/dist/{library-mesh-BRk4Ycnn.js → library-mesh-CjTG-mVZ.js} +97 -74
- package/dist/library-parts.d.ts +11 -1
- package/dist/library.js +1 -1
- package/dist/look-family.d.ts +16 -1
- package/dist/look-family.js +35 -12
- package/dist/shared/settings.d.ts +89 -89
- package/dist/{timber-valley-info-BB6GvcsL.js → timber-valley-info-vVI2nwDs.js} +11 -0
- package/dist/timber-valley.d.ts +69 -3
- package/dist/timber-valley.js +198 -136
- package/package.json +106 -104
- package/dist/fauld-world-85dg03jo.js +0 -582
package/dist/fauld-blast.js
CHANGED
|
@@ -1,164 +1,924 @@
|
|
|
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
|
|
4
|
-
import {
|
|
5
|
-
import { Water as
|
|
3
|
+
const p=(engine,version="1.0.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
|
|
4
|
+
import { _ as e, a as t, c as n, d as r, g as i, h as a, l as o, m as s, n as c, s as l, t as u, v as d } from "./fauld-world-CNNSonJF.js";
|
|
5
|
+
import { Water as f } from "@margoengine/water";
|
|
6
6
|
import { engineRuntime as __margoRuntime } from "@margoengine/core/extension";
|
|
7
|
-
import { BlastCloud as
|
|
8
|
-
import { Clouds as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { loadGLTF as
|
|
12
|
-
import { PBRInstances as
|
|
13
|
-
import {
|
|
7
|
+
import { BlastCloud as m } from "@margoengine/weather/eruption";
|
|
8
|
+
import { Clouds as h } from "@margoengine/vfx/clouds";
|
|
9
|
+
import { Fire as g } from "@margoengine/vfx/fire";
|
|
10
|
+
import { INCENDIARY_4LB as _, burningBed as v } from "@margoengine/vfx/flame";
|
|
11
|
+
import { loadGLTF as y } from "@margoengine/gltf/pbr";
|
|
12
|
+
import { PBRInstances as b } from "@margoengine/gltf/pbr-instancing";
|
|
13
|
+
import { ShallowWaterSurface as x } from "@margoengine/water/shallow-surface";
|
|
14
|
+
import { DustCurrent as S } from "@margoengine/vfx/dust-current";
|
|
15
|
+
//#region src/fauld-grains.ts
|
|
16
|
+
var C = Object.freeze({
|
|
17
|
+
diameters: Object.freeze([
|
|
18
|
+
801e-7,
|
|
19
|
+
1764e-7,
|
|
20
|
+
3996e-7,
|
|
21
|
+
.001485
|
|
22
|
+
]),
|
|
23
|
+
fines: 4e-4,
|
|
24
|
+
share: .315 / .64 / 4,
|
|
25
|
+
ring: 8
|
|
26
|
+
}), w = Object.freeze({
|
|
27
|
+
diameters: Object.freeze([107e-7, 338e-7]),
|
|
28
|
+
fines: C.fines,
|
|
29
|
+
share: .17 / .64,
|
|
30
|
+
ring: C.ring
|
|
31
|
+
}), T = Object.freeze({
|
|
32
|
+
mass: "blocky",
|
|
33
|
+
jointSpacing: "intermediate",
|
|
34
|
+
jointOrientation: "horizontal",
|
|
35
|
+
density: 2480,
|
|
36
|
+
modulus: 25e7
|
|
37
|
+
}), E = Object.freeze({
|
|
38
|
+
mass: 10,
|
|
39
|
+
area: .05,
|
|
40
|
+
frequency: 8,
|
|
41
|
+
damping: .05
|
|
42
|
+
}), D = Object.freeze({ fullScale: 632 }), O = 30, k = 300, A = {
|
|
43
|
+
cells: 128,
|
|
44
|
+
size: 3200
|
|
45
|
+
}, j = {
|
|
46
|
+
cells: 128,
|
|
47
|
+
size: 6400
|
|
48
|
+
};
|
|
49
|
+
async function M({ height: e, blasts: t, pieces: n = 600, wind: r = [
|
|
50
|
+
0,
|
|
51
|
+
0,
|
|
52
|
+
0
|
|
53
|
+
], dust: i = !1 }) {
|
|
54
|
+
let o = i === "fines" ? w : C;
|
|
55
|
+
if (!(t.length > 0 && t.every((e) => e.tnt > 0 && e.at >= 0))) throw RangeError("fauld explosion: pass the blasts, each with TNT above 0 kg and a film second of 0 or more.");
|
|
56
|
+
if (!(Number.isInteger(n) && n >= t.length && n <= 1e5)) throw RangeError(`fauld explosion: pieces is a whole number from one a blast to 100,000; got ${n}.`);
|
|
57
|
+
let [s, { CRATER_GROUNDS: c, craterSize: l }, { TerrainBed: u, bedSurface: d }, f, p, m, h] = await Promise.all([
|
|
58
|
+
import("@margoengine/physics/explosive"),
|
|
59
|
+
import("@margoengine/physics/crater"),
|
|
60
|
+
import("@margoengine/physics/earth"),
|
|
61
|
+
import("@margoengine/physics/plume"),
|
|
62
|
+
import("@margoengine/physics/world"),
|
|
63
|
+
import("@margoengine/physics"),
|
|
64
|
+
i ? import("@margoengine/physics/airborne") : void 0
|
|
65
|
+
]), g = f.PlumeSolver;
|
|
66
|
+
await m.Physics.load();
|
|
67
|
+
let _ = t.reduce((e, t) => e + t.tnt, 0), v = t.reduce((e, t) => e + t.at_[0] * t.tnt, 0) / _, y = t.reduce((e, t) => e + t.at_[1] * t.tnt, 0) / _, b = A.cells, x = {
|
|
68
|
+
columns: b,
|
|
69
|
+
rows: b,
|
|
70
|
+
width: A.size,
|
|
71
|
+
depth: A.size,
|
|
72
|
+
centre: [v, y]
|
|
73
|
+
}, S = [
|
|
74
|
+
0,
|
|
75
|
+
-9.81,
|
|
76
|
+
0
|
|
77
|
+
], M = new p.PhysicsWorld({
|
|
78
|
+
rate: {
|
|
79
|
+
num: O,
|
|
80
|
+
den: 1
|
|
81
|
+
},
|
|
82
|
+
gravity: S
|
|
83
|
+
}), N = new m.Physics(null, { gravity: S }), P = new u(), F = h ? await h.AirborneParticles.load({
|
|
84
|
+
id: "fauldSand",
|
|
85
|
+
emissions: !0,
|
|
86
|
+
deposit: !0
|
|
87
|
+
}) : void 0, I = await s.ExplosionSolver.load({
|
|
88
|
+
id: "fauldStore",
|
|
89
|
+
terrain: x,
|
|
90
|
+
...F ? { dust: F.emissionField } : {}
|
|
91
|
+
}), L = new s.BlastSolver(I.explosionsField, "fauldBlast"), R = new g(I.hotGasField, "fauldColumn");
|
|
92
|
+
M.add(P, {
|
|
93
|
+
...x,
|
|
94
|
+
elevations: (t, n) => e(t, n)
|
|
95
|
+
}), M.add(new p.RigidSolver(), { physics: N });
|
|
96
|
+
let z = 0;
|
|
97
|
+
if (M.add(I, {
|
|
98
|
+
charges: t.map((r, i) => {
|
|
99
|
+
let o = i === t.length - 1 ? n - z : Math.max(1, Math.round(n * r.tnt / _));
|
|
100
|
+
return z += o, {
|
|
101
|
+
position: [
|
|
102
|
+
r.at_[0],
|
|
103
|
+
e(r.at_[0], r.at_[1]) - a.depth,
|
|
104
|
+
r.at_[1]
|
|
105
|
+
],
|
|
106
|
+
time: r.at,
|
|
107
|
+
mass: r.tnt,
|
|
108
|
+
depth: a.depth,
|
|
109
|
+
ejecta: {
|
|
110
|
+
rock: "limestone",
|
|
111
|
+
pieces: o,
|
|
112
|
+
rockMass: T,
|
|
113
|
+
density: T.density
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}),
|
|
117
|
+
crater: c[a.ground],
|
|
118
|
+
landing: "soil",
|
|
119
|
+
...F ? { dust: {
|
|
120
|
+
sources: o.diameters.length * o.ring,
|
|
121
|
+
links: t.flatMap((e, t) => Array.from({ length: o.diameters.length * o.ring }, (e, n) => ({
|
|
122
|
+
charge: t,
|
|
123
|
+
source: n
|
|
124
|
+
}))),
|
|
125
|
+
fraction: o.fines * o.share / o.ring
|
|
126
|
+
} } : {}
|
|
127
|
+
}), M.add(L, {
|
|
128
|
+
physics: N,
|
|
129
|
+
groundHeight: null
|
|
130
|
+
}), M.add(R, { air: { wind: r } }), F) {
|
|
131
|
+
let t = f.hotGasReleases(I.hotGas()), [n] = t, i = j.size / 2, a = j.cells, s = {
|
|
132
|
+
columns: a,
|
|
133
|
+
rows: a,
|
|
134
|
+
width: j.size,
|
|
135
|
+
depth: j.size,
|
|
136
|
+
centre: [v, y]
|
|
137
|
+
}, c = new Float64Array((a + 1) * (a + 1));
|
|
138
|
+
for (let t = 0; t <= a; t++) for (let n = 0; n <= a; n++) c[n + (a + 1) * t] = e(v - i + j.size * t / a, y - i + j.size * n / a);
|
|
139
|
+
M.add(F, {
|
|
140
|
+
capacity: 8192,
|
|
141
|
+
wind: f.plumeWind(t, { wind: r }),
|
|
142
|
+
terrain: d(s, c),
|
|
143
|
+
bounds: [[
|
|
144
|
+
v - i,
|
|
145
|
+
-1e3,
|
|
146
|
+
y - i
|
|
147
|
+
], [
|
|
148
|
+
v + i,
|
|
149
|
+
2e4,
|
|
150
|
+
y + i
|
|
151
|
+
]],
|
|
152
|
+
sources: o.diameters.flatMap((e) => Array.from({ length: o.ring }, (t, r) => {
|
|
153
|
+
let i = 2 * Math.PI * r / o.ring, a = .7 * n.radius;
|
|
154
|
+
return {
|
|
155
|
+
kind: "mineral-dust",
|
|
156
|
+
diameter: e,
|
|
157
|
+
position: [
|
|
158
|
+
n.at[0] + a * Math.cos(i),
|
|
159
|
+
n.at[1] + n.radius,
|
|
160
|
+
n.at[2] + a * Math.sin(i)
|
|
161
|
+
],
|
|
162
|
+
rate: 0,
|
|
163
|
+
every: .05
|
|
164
|
+
};
|
|
165
|
+
})),
|
|
166
|
+
turbulence: (() => {
|
|
167
|
+
let e = .4 * Math.hypot(r[0], r[2]) / Math.log(200);
|
|
168
|
+
return {
|
|
169
|
+
rms: [
|
|
170
|
+
2.4 * e,
|
|
171
|
+
1.25 * e,
|
|
172
|
+
1.9 * e
|
|
173
|
+
],
|
|
174
|
+
time: 200
|
|
175
|
+
};
|
|
176
|
+
})()
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
let B = /* @__PURE__ */ new Map([[0, M.takeSnapshot().bytes]]), V = 0, ee = (e) => {
|
|
180
|
+
if (e < V) {
|
|
181
|
+
let t = 0;
|
|
182
|
+
for (let n of B.keys()) n <= e && n > t && (t = n);
|
|
183
|
+
M.restoreSnapshot(B.get(t)), V = t;
|
|
184
|
+
}
|
|
185
|
+
for (; V < e;) {
|
|
186
|
+
let t = Math.min(e, (Math.floor(V / k) + 1) * k);
|
|
187
|
+
M.advance(t), V = t, V % k === 0 && !B.has(V) && B.set(V, M.takeSnapshot().bytes);
|
|
188
|
+
}
|
|
189
|
+
}, te = t.length, H = /* @__PURE__ */ new Map();
|
|
190
|
+
return {
|
|
191
|
+
world: M,
|
|
192
|
+
charges: I,
|
|
193
|
+
bed: P,
|
|
194
|
+
blast: L,
|
|
195
|
+
plume: R,
|
|
196
|
+
sand: F ?? null,
|
|
197
|
+
get time() {
|
|
198
|
+
return V / O;
|
|
199
|
+
},
|
|
200
|
+
seek(e) {
|
|
201
|
+
if (!(e >= 0) || !Number.isFinite(e)) throw RangeError(`fauld explosion seek ${e}: pass a film time of 0 s or more.`);
|
|
202
|
+
ee(Math.round(e * O));
|
|
203
|
+
},
|
|
204
|
+
rocks() {
|
|
205
|
+
let e = I.fragments(), t = [];
|
|
206
|
+
for (let n = 0; n + 8 <= e.length; n += 8) {
|
|
207
|
+
let r = e[n + 7];
|
|
208
|
+
if (r === 0) continue;
|
|
209
|
+
let i = e[n + 6];
|
|
210
|
+
t.push({
|
|
211
|
+
position: [
|
|
212
|
+
e[n],
|
|
213
|
+
e[n + 1],
|
|
214
|
+
e[n + 2]
|
|
215
|
+
],
|
|
216
|
+
velocity: [
|
|
217
|
+
e[n + 3],
|
|
218
|
+
e[n + 4],
|
|
219
|
+
e[n + 5]
|
|
220
|
+
],
|
|
221
|
+
mass: i,
|
|
222
|
+
size: Math.cbrt(6 * i / (Math.PI * T.density)),
|
|
223
|
+
landed: r === 2
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
return t;
|
|
227
|
+
},
|
|
228
|
+
landings() {
|
|
229
|
+
let e = I.landings(), t = V / O, n = [];
|
|
230
|
+
for (let r = 0; r + 5 <= e.length; r += 5) {
|
|
231
|
+
let i = e[r], a = e[r + 4];
|
|
232
|
+
if (!(i >= 0 && i <= t)) continue;
|
|
233
|
+
let o = H.get(r);
|
|
234
|
+
o === void 0 && (o = a > 0 ? 4 * l(a, 0, c.wetSoil).radius : 0, H.set(r, o)), n.push({
|
|
235
|
+
time: i,
|
|
236
|
+
position: [
|
|
237
|
+
e[r + 1],
|
|
238
|
+
e[r + 2],
|
|
239
|
+
e[r + 3]
|
|
240
|
+
],
|
|
241
|
+
energy: a,
|
|
242
|
+
puff: o
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
return n;
|
|
246
|
+
},
|
|
247
|
+
column() {
|
|
248
|
+
let e = [];
|
|
249
|
+
for (let t = 0; t < te; t++) {
|
|
250
|
+
let n = R.thermal(t);
|
|
251
|
+
e.push({
|
|
252
|
+
centre: n.centre,
|
|
253
|
+
radius: n.radius,
|
|
254
|
+
top: n.top,
|
|
255
|
+
rising: n.rising
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
return e;
|
|
259
|
+
},
|
|
260
|
+
pressure(e) {
|
|
261
|
+
return L.pressureAt(e, V / O);
|
|
262
|
+
},
|
|
263
|
+
sound(e, t, n, r = 48e3) {
|
|
264
|
+
return L.pressureSeries(e, t, n, r);
|
|
265
|
+
},
|
|
266
|
+
recording(e, t, n, r = {}) {
|
|
267
|
+
let i = r.sampleRate ?? 48e3, a = r.fullScale ?? D.fullScale;
|
|
268
|
+
if (!(a > 0)) throw RangeError(`fauld recording: the full scale must be above 0 Pa; got ${a}.`);
|
|
269
|
+
let o = L.pressureSeries(e, t, n, i);
|
|
270
|
+
for (let e = 0; e < o.length; e++) o[e] = Math.max(-1, Math.min(1, o[e] / a));
|
|
271
|
+
return {
|
|
272
|
+
sampleRate: i,
|
|
273
|
+
numberOfChannels: 1,
|
|
274
|
+
length: o.length,
|
|
275
|
+
getChannelData: (e) => {
|
|
276
|
+
if (e !== 0) throw RangeError(`fauld recording: it is mono; ask for channel 0, not ${e}.`);
|
|
277
|
+
return o;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
},
|
|
281
|
+
shake: (n, r, i = E) => {
|
|
282
|
+
let o = Infinity, c = [
|
|
283
|
+
1,
|
|
284
|
+
0,
|
|
285
|
+
0
|
|
286
|
+
];
|
|
287
|
+
for (let r of t) {
|
|
288
|
+
let t = [
|
|
289
|
+
r.at_[0],
|
|
290
|
+
e(r.at_[0], r.at_[1]),
|
|
291
|
+
r.at_[1]
|
|
292
|
+
], i = [
|
|
293
|
+
n[0] - t[0],
|
|
294
|
+
0,
|
|
295
|
+
n[2] - t[2]
|
|
296
|
+
], l = Math.hypot(i[0], n[1] - t[1], i[2]), u = s.freeAirEquivalent(s.energyBudget(s.chargeEnergy(r.tnt), a.depth)), d = r.at + s.blastAt(u, Math.max(l, 1), {}, !0).arrival;
|
|
297
|
+
if (d < o) {
|
|
298
|
+
o = d;
|
|
299
|
+
let e = Math.hypot(i[0], i[2]) || 1;
|
|
300
|
+
c = [
|
|
301
|
+
i[0] / e,
|
|
302
|
+
0,
|
|
303
|
+
i[2] / e
|
|
304
|
+
];
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (!(r > o)) return [
|
|
308
|
+
0,
|
|
309
|
+
0,
|
|
310
|
+
0
|
|
311
|
+
];
|
|
312
|
+
let l = 2 * Math.PI * i.frequency, u = i.damping, d = Math.min(r, o + 4), f = 0, p = 0, m = o;
|
|
313
|
+
for (; m < d;) {
|
|
314
|
+
let e = Math.min(5e-4, d - m), t = L.pressureAt(n, m + e / 2) * i.area / i.mass;
|
|
315
|
+
p += e * (t - 2 * u * l * p - l * l * f), f += e * p, m += e;
|
|
316
|
+
}
|
|
317
|
+
if (r > d) {
|
|
318
|
+
let e = r - d, t = l * Math.sqrt(1 - u * u);
|
|
319
|
+
f = Math.exp(-u * l * e) * (f * Math.cos(t * e) + (p + u * l * f) / t * Math.sin(t * e));
|
|
320
|
+
}
|
|
321
|
+
return [
|
|
322
|
+
c[0] * f,
|
|
323
|
+
0,
|
|
324
|
+
c[2] * f
|
|
325
|
+
];
|
|
326
|
+
},
|
|
327
|
+
dustfall() {
|
|
328
|
+
if (!F) return null;
|
|
329
|
+
let e = F.budget, t = j.size / 2;
|
|
330
|
+
return {
|
|
331
|
+
deposited: F.deposited(),
|
|
332
|
+
shape: {
|
|
333
|
+
columns: j.cells,
|
|
334
|
+
rows: j.cells,
|
|
335
|
+
width: 2 * t,
|
|
336
|
+
depth: 2 * t,
|
|
337
|
+
centre: [v, y]
|
|
338
|
+
},
|
|
339
|
+
ground: e.deposited,
|
|
340
|
+
airborne: e.airborne + e.waiting,
|
|
341
|
+
outflow: e.outflow
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/fauld-mud.ts
|
|
348
|
+
var N = Object.freeze({
|
|
349
|
+
volume: 27300,
|
|
350
|
+
exponent: 1,
|
|
351
|
+
length: 58,
|
|
352
|
+
bank: 8,
|
|
353
|
+
cut: {
|
|
354
|
+
bottom: 2,
|
|
355
|
+
width: 25
|
|
356
|
+
},
|
|
357
|
+
breach: {
|
|
358
|
+
width: 40,
|
|
359
|
+
sideSlope: 1,
|
|
360
|
+
time: 40
|
|
361
|
+
}
|
|
362
|
+
}), P = Object.freeze({
|
|
363
|
+
density: 1800,
|
|
364
|
+
friction: .1,
|
|
365
|
+
poreSupport: .7,
|
|
366
|
+
turbulence: 500,
|
|
367
|
+
entrainment: {
|
|
368
|
+
growth: .002,
|
|
369
|
+
depth: .5
|
|
370
|
+
},
|
|
371
|
+
concentration: 1113
|
|
372
|
+
}), F = 60, I = 600;
|
|
373
|
+
async function L({ height: e, grid: t, outlet: n, toward: r, at: i, blasts: o, pond: s }) {
|
|
374
|
+
if (o ? !(o.length > 0 && o.every((e) => e.tnt > 0) && s) : !(i !== void 0 && i >= 0)) throw RangeError("fauld mud: pass the blasts (each with TNT above 0 kg) and the pond centre, or the film second `at` (0 or more) the bank is cut.");
|
|
375
|
+
let [{ DamBreach: c }, { GranularFlowSolver: l }, { PhysicsWorld: u }] = await Promise.all([
|
|
376
|
+
import("@margoengine/physics/breach"),
|
|
377
|
+
import("@margoengine/physics/granular-flow"),
|
|
378
|
+
import("@margoengine/physics/world")
|
|
379
|
+
]), d = t.cells, f = t.size[0] / d, p = t.size[1] / d, m = {
|
|
380
|
+
columns: d,
|
|
381
|
+
rows: d,
|
|
382
|
+
width: t.size[0],
|
|
383
|
+
depth: t.size[1],
|
|
384
|
+
centre: [t.origin[0] + t.size[0] / 2, t.origin[1] + t.size[1] / 2]
|
|
385
|
+
}, h = new Float64Array(d * d);
|
|
386
|
+
for (let n = 0; n < d; n++) for (let r = 0; r < d; r++) h[r + n * d] = e(t.origin[0] + (r + .5) * f, t.origin[1] + (n + .5) * p);
|
|
387
|
+
let g = e(n[0], n[1]), { volume: _, exponent: v, length: y, bank: b, cut: x, breach: S } = N, C = new u({
|
|
388
|
+
rate: {
|
|
389
|
+
num: F,
|
|
390
|
+
den: 1
|
|
391
|
+
},
|
|
392
|
+
gravity: [
|
|
393
|
+
0,
|
|
394
|
+
-9.81,
|
|
395
|
+
0
|
|
396
|
+
]
|
|
397
|
+
}), w, T;
|
|
398
|
+
if (o && s) {
|
|
399
|
+
let [{ ExplosionSolver: t }, { CraterSolver: n, CRATER_GROUNDS: r }, { TerrainBed: i }] = await Promise.all([
|
|
400
|
+
import("@margoengine/physics/explosive"),
|
|
401
|
+
import("@margoengine/physics/crater"),
|
|
402
|
+
import("@margoengine/physics/earth")
|
|
403
|
+
]), c = o.reduce((e, t) => e + t.tnt, 0), l = o.reduce((e, t) => e + t.at_[0] * t.tnt, 0) / c, u = o.reduce((e, t) => e + t.at_[1] * t.tnt, 0) / c, d = new t("fauldStore"), f = {
|
|
404
|
+
columns: 64,
|
|
405
|
+
rows: 64,
|
|
406
|
+
width: 640,
|
|
407
|
+
depth: 640,
|
|
408
|
+
centre: [l, u]
|
|
409
|
+
};
|
|
410
|
+
w = new n("fauldCrater", "fauldStore"), C.add(d, {
|
|
411
|
+
charges: [{
|
|
412
|
+
position: [
|
|
413
|
+
l,
|
|
414
|
+
e(l, u) - a.depth,
|
|
415
|
+
u
|
|
416
|
+
],
|
|
417
|
+
time: Math.min(...o.map((e) => e.at)),
|
|
418
|
+
mass: c,
|
|
419
|
+
depth: a.depth
|
|
420
|
+
}],
|
|
421
|
+
crater: r[a.ground]
|
|
422
|
+
}), C.add(new i(), {
|
|
423
|
+
...f,
|
|
424
|
+
elevations: (t, n) => e(t, n)
|
|
425
|
+
}), C.add(w, {
|
|
426
|
+
bed: f,
|
|
427
|
+
ground: r[a.ground],
|
|
428
|
+
shells: 8
|
|
429
|
+
});
|
|
430
|
+
let p = y / 2, m = [
|
|
431
|
+
[[s[0], s[1] - p], [1, 0]],
|
|
432
|
+
[[s[0], s[1] + p], [1, 0]],
|
|
433
|
+
[[s[0] - p, s[1]], [0, 1]],
|
|
434
|
+
[[s[0] + p, s[1]], [0, 1]]
|
|
435
|
+
], h = ([[e, t], [n, r]]) => {
|
|
436
|
+
let i = Math.max(-p, Math.min(p, (l - e) * n + (u - t) * r));
|
|
437
|
+
return Math.hypot(l - e - i * n, u - t - i * r);
|
|
438
|
+
}, g = m[0];
|
|
439
|
+
for (let e of m) h(e) < h(g) && (g = e);
|
|
440
|
+
T = {
|
|
441
|
+
position: g[0],
|
|
442
|
+
along: g[1]
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
let E = new c("hanbury", w ? { craters: w.cratersField } : {}), D = [r[0] - n[0], r[1] - n[1]], O = Math.hypot(D[0], D[1]) || 1, k = await l.load({
|
|
446
|
+
id: "fauldMud",
|
|
447
|
+
inflows: [{
|
|
448
|
+
field: E.mudField,
|
|
449
|
+
position: n,
|
|
450
|
+
velocity: [3 * D[0] / O, 3 * D[1] / O]
|
|
451
|
+
}]
|
|
452
|
+
});
|
|
453
|
+
C.add(E, {
|
|
454
|
+
dam: {
|
|
455
|
+
crest: g + b,
|
|
456
|
+
base: g,
|
|
457
|
+
crestLength: y,
|
|
458
|
+
crestWidth: 4,
|
|
459
|
+
...T ?? {}
|
|
460
|
+
},
|
|
461
|
+
reservoir: {
|
|
462
|
+
level: g + b - .3,
|
|
463
|
+
storage: {
|
|
464
|
+
volume: _,
|
|
465
|
+
exponent: v
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
...T ? {} : {
|
|
469
|
+
failure: {
|
|
470
|
+
mode: "instant",
|
|
471
|
+
start: i,
|
|
472
|
+
bottom: g + x.bottom,
|
|
473
|
+
width: x.width
|
|
474
|
+
},
|
|
475
|
+
growth: {
|
|
476
|
+
model: "prescribed",
|
|
477
|
+
width: S.width,
|
|
478
|
+
sideSlope: S.sideSlope,
|
|
479
|
+
time: S.time,
|
|
480
|
+
bottom: g
|
|
481
|
+
}
|
|
482
|
+
},
|
|
483
|
+
mud: { share: 1 }
|
|
484
|
+
}), C.add(k, {
|
|
485
|
+
grid: m,
|
|
486
|
+
bed: h,
|
|
487
|
+
density: P.density,
|
|
488
|
+
friction: P.friction,
|
|
489
|
+
poreSupport: P.poreSupport,
|
|
490
|
+
turbulence: P.turbulence,
|
|
491
|
+
entrainment: P.entrainment
|
|
492
|
+
});
|
|
493
|
+
let A = /* @__PURE__ */ new Map([[0, C.takeSnapshot().bytes]]), j = 0, M = (e) => {
|
|
494
|
+
if (e < j) {
|
|
495
|
+
let t = 0;
|
|
496
|
+
for (let n of A.keys()) n <= e && n > t && (t = n);
|
|
497
|
+
C.restoreSnapshot(A.get(t)), j = t;
|
|
498
|
+
}
|
|
499
|
+
for (; j < e;) {
|
|
500
|
+
let t = Math.min(e, (Math.floor(j / I) + 1) * I);
|
|
501
|
+
C.advance(t), j = t, j % I === 0 && !A.has(j) && A.set(j, C.takeSnapshot().bytes);
|
|
502
|
+
}
|
|
503
|
+
}, L = t.origin[0], R = t.origin[1];
|
|
504
|
+
return {
|
|
505
|
+
world: C,
|
|
506
|
+
breach: E,
|
|
507
|
+
flow: k,
|
|
508
|
+
crater: w,
|
|
509
|
+
get time() {
|
|
510
|
+
return j / F;
|
|
511
|
+
},
|
|
512
|
+
seek(e) {
|
|
513
|
+
if (!(e >= 0) || !Number.isFinite(e)) throw RangeError(`fauld mud seek ${e}: pass a film time of 0 s or more.`);
|
|
514
|
+
M(Math.round(e * F));
|
|
515
|
+
},
|
|
516
|
+
surface: {
|
|
517
|
+
shape: m,
|
|
518
|
+
sample(e, t, n) {
|
|
519
|
+
let r = Math.min(d - 1, Math.max(0, Math.floor((e - L) / f))), i = Math.min(d - 1, Math.max(0, Math.floor((t - R) / p))), a = k.sample(r, i);
|
|
520
|
+
return n.depth = a.depth, n.surface = a.surfaceElevation, n.velocity = a.depth > 1e-6 ? [a.discharge[0] / a.depth, a.discharge[1] / a.depth] : [0, 0], n;
|
|
521
|
+
}
|
|
522
|
+
},
|
|
523
|
+
sediment: {
|
|
524
|
+
concentrationSize: [d, d],
|
|
525
|
+
copyConcentrations(e) {
|
|
526
|
+
for (let t = 0; t < d; t++) for (let n = 0; n < d; n++) e[n + t * d] = k.sample(n, t).depth > 1e-4 ? P.concentration : 0;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
//#endregion
|
|
532
|
+
//#region src/fauld-surge.ts
|
|
533
|
+
var R = Object.freeze({
|
|
534
|
+
grain: Object.freeze({
|
|
535
|
+
diameter: 5e-5,
|
|
536
|
+
density: 2650
|
|
537
|
+
}),
|
|
538
|
+
cells: 96,
|
|
539
|
+
size: 3200
|
|
540
|
+
}), z = 10, B = 100;
|
|
541
|
+
async function V({ height: e, blasts: t }) {
|
|
542
|
+
if (!(t.length > 0 && t.every((e) => e.tnt > 0 && e.at >= 0))) throw RangeError("fauld surge: pass the blasts, each with TNT above 0 kg and a film second of 0 or more.");
|
|
543
|
+
let [{ ExplosionSolver: n }, { CRATER_GROUNDS: r }, { TerrainBed: i }, { GravityCurrentSolver: o }, { PhysicsWorld: s }] = await Promise.all([
|
|
544
|
+
import("@margoengine/physics/explosive"),
|
|
545
|
+
import("@margoengine/physics/crater"),
|
|
546
|
+
import("@margoengine/physics/earth"),
|
|
547
|
+
import("@margoengine/physics/gravity-current"),
|
|
548
|
+
import("@margoengine/physics/world")
|
|
549
|
+
]), c = t.reduce((e, t) => e + t.tnt, 0), l = t.reduce((e, t) => e + t.at_[0] * t.tnt, 0) / c, u = t.reduce((e, t) => e + t.at_[1] * t.tnt, 0) / c, d = R.cells, f = R.size, p = {
|
|
550
|
+
columns: d,
|
|
551
|
+
rows: d,
|
|
552
|
+
width: f,
|
|
553
|
+
depth: f,
|
|
554
|
+
centre: [l, u]
|
|
555
|
+
}, m = r[a.ground], h = new s({
|
|
556
|
+
rate: {
|
|
557
|
+
num: z,
|
|
558
|
+
den: 1
|
|
559
|
+
},
|
|
560
|
+
gravity: [
|
|
561
|
+
0,
|
|
562
|
+
-9.81,
|
|
563
|
+
0
|
|
564
|
+
]
|
|
565
|
+
}), g = new n("fauldStore"), _ = new i(), v = new o("fauldSurge", "fauldStore");
|
|
566
|
+
h.add(g, {
|
|
567
|
+
charges: [{
|
|
568
|
+
position: [
|
|
569
|
+
l,
|
|
570
|
+
e(l, u) - a.depth,
|
|
571
|
+
u
|
|
572
|
+
],
|
|
573
|
+
time: Math.min(...t.map((e) => e.at)),
|
|
574
|
+
mass: c,
|
|
575
|
+
depth: a.depth
|
|
576
|
+
}],
|
|
577
|
+
crater: m
|
|
578
|
+
}), h.add(_, {
|
|
579
|
+
...p,
|
|
580
|
+
elevations: (t, n) => e(t, n)
|
|
581
|
+
}), h.add(v, {
|
|
582
|
+
bed: p,
|
|
583
|
+
grains: [R.grain],
|
|
584
|
+
surge: { ground: m }
|
|
585
|
+
});
|
|
586
|
+
let y = Float64Array.from(_.elevations()), b = /* @__PURE__ */ new Map([[0, h.takeSnapshot().bytes]]), x = 0, S = (e) => {
|
|
587
|
+
if (e < x) {
|
|
588
|
+
let t = 0;
|
|
589
|
+
for (let n of b.keys()) n <= e && n > t && (t = n);
|
|
590
|
+
h.restoreSnapshot(b.get(t)), x = t;
|
|
591
|
+
}
|
|
592
|
+
for (; x < e;) {
|
|
593
|
+
let t = Math.min(e, (Math.floor(x / B) + 1) * B);
|
|
594
|
+
h.advance(t), x = t, x % B === 0 && !b.has(x) && b.set(x, h.takeSnapshot().bytes);
|
|
595
|
+
}
|
|
596
|
+
}, C = l - f / 2, w = u - f / 2, T = f / d, E = R.grain.diameter / 2, D = (e, t) => Math.min(d - 1, Math.max(0, Math.floor((e - t) / T)));
|
|
597
|
+
return {
|
|
598
|
+
world: h,
|
|
599
|
+
charge: g,
|
|
600
|
+
bed: _,
|
|
601
|
+
current: v,
|
|
602
|
+
shape: p,
|
|
603
|
+
get time() {
|
|
604
|
+
return x / z;
|
|
605
|
+
},
|
|
606
|
+
seek(e) {
|
|
607
|
+
if (!(e >= 0) || !Number.isFinite(e)) throw RangeError(`fauld surge seek ${e}: pass a film time of 0 s or more.`);
|
|
608
|
+
S(Math.round(e * z));
|
|
609
|
+
},
|
|
610
|
+
sample(e, t, n) {
|
|
611
|
+
let r = v.sample(D(e, C), D(t, w)), i = r.fractions[0] ?? 0;
|
|
612
|
+
return n.depth = r.depth, n.dust = i, n.velocity = [r.velocity[0], r.velocity[1]], n.opacity = 1.5 * r.depth * i / E, n;
|
|
613
|
+
},
|
|
614
|
+
deposit(e, t) {
|
|
615
|
+
let n = Math.min(d, Math.max(0, Math.round((e - C) / T))), r = Math.min(d, Math.max(0, Math.round((t - w) / T))) + (d + 1) * n;
|
|
616
|
+
return _.elevations()[r] - y[r];
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
function ee(e, t) {
|
|
621
|
+
let n = {
|
|
622
|
+
depth: 0,
|
|
623
|
+
dust: 0,
|
|
624
|
+
velocity: [0, 0],
|
|
625
|
+
opacity: 0
|
|
626
|
+
};
|
|
627
|
+
return new S({
|
|
628
|
+
shape: e.shape,
|
|
629
|
+
sample(t, r, i) {
|
|
630
|
+
return e.sample(t, r, n), i.depth = n.depth, i.opacity = n.opacity, i;
|
|
631
|
+
},
|
|
632
|
+
ground: t
|
|
633
|
+
}, {
|
|
634
|
+
stride: 2,
|
|
635
|
+
color: [
|
|
636
|
+
.33,
|
|
637
|
+
.3,
|
|
638
|
+
.26
|
|
639
|
+
]
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
//#endregion
|
|
14
643
|
//#region src/fauld-blast.ts
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
644
|
+
var te = Object.freeze({
|
|
645
|
+
dust: 4e-4,
|
|
646
|
+
ironOxide: 3
|
|
647
|
+
}), H = Object.freeze({
|
|
648
|
+
sky: .15,
|
|
649
|
+
sun: .11
|
|
650
|
+
}), ne = 12, U = i, re = 20, W = 3, G = 6, K = Object.freeze([-150, 95]);
|
|
651
|
+
function ie(e, t, n) {
|
|
652
|
+
let [r, i] = K, a = U.toward * Math.PI / 180;
|
|
653
|
+
return {
|
|
654
|
+
position: [
|
|
655
|
+
r,
|
|
656
|
+
t(r, i),
|
|
657
|
+
i
|
|
658
|
+
],
|
|
659
|
+
flameLength: 14,
|
|
660
|
+
width: 60,
|
|
661
|
+
wind: [U.speed * Math.sin(a), U.speed * Math.cos(a)],
|
|
662
|
+
smoke: {
|
|
663
|
+
prewarm: Math.max(0, e - 3),
|
|
664
|
+
color: [
|
|
665
|
+
n[0],
|
|
666
|
+
n[1],
|
|
667
|
+
n[2]
|
|
668
|
+
],
|
|
669
|
+
turbulence: 2.5
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
var q = Object.freeze({
|
|
674
|
+
bombs: 2e4,
|
|
675
|
+
area: 700,
|
|
676
|
+
spread: 6
|
|
677
|
+
});
|
|
678
|
+
function ae(e) {
|
|
679
|
+
return (e.event.start ?? 0) + Math.sqrt(.8 * e.depth / 9.80665) + (e.event.duration ?? 0);
|
|
680
|
+
}
|
|
681
|
+
function oe() {
|
|
682
|
+
return v({
|
|
683
|
+
..._,
|
|
684
|
+
fuel: q.bombs * _.itemMass,
|
|
685
|
+
area: q.area,
|
|
686
|
+
spread: q.spread
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
function se(e, t, n = oe()) {
|
|
690
|
+
let r = n.flameLength(t);
|
|
691
|
+
if (!(r >= .05)) return;
|
|
692
|
+
let i = U.toward * Math.PI / 180;
|
|
693
|
+
return {
|
|
694
|
+
position: [...e],
|
|
695
|
+
flameLength: r,
|
|
696
|
+
width: n.diameter,
|
|
697
|
+
breadth: n.diameter,
|
|
698
|
+
wind: [U.speed * Math.sin(i), U.speed * Math.cos(i)],
|
|
699
|
+
smoke: {
|
|
700
|
+
prewarm: t,
|
|
701
|
+
color: [..._.smoke],
|
|
702
|
+
turbulence: 2.5
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
function ce(e, t, n) {
|
|
707
|
+
if (!t) e?.dispose();
|
|
708
|
+
else return e ? (e.setLength(t.flameLength), e) : n(t);
|
|
709
|
+
}
|
|
710
|
+
var J = {
|
|
26
711
|
origin: [-200, -1e3],
|
|
27
712
|
size: [800, 800],
|
|
28
|
-
cells:
|
|
713
|
+
cells: 160
|
|
29
714
|
};
|
|
30
|
-
async function
|
|
31
|
-
let
|
|
32
|
-
if (!(
|
|
33
|
-
|
|
34
|
-
|
|
715
|
+
async function le(n, i = {}) {
|
|
716
|
+
let c = i.time ?? 0;
|
|
717
|
+
if (!(c >= 0 && c <= 3600)) throw RangeError(`fauld-blast time ${c} is outside 0 to 3,600 seconds; pass a film time in that range.`);
|
|
718
|
+
if (i.era !== void 0 && i.era !== "before") throw RangeError(`fauld-blast era '${i.era}': the blast digs its own crater into the ground before it; leave era out or pass 'before'.`);
|
|
719
|
+
let l = await r(n, {
|
|
35
720
|
sky: "overcast",
|
|
36
|
-
...
|
|
37
|
-
|
|
721
|
+
...i,
|
|
722
|
+
era: "before"
|
|
723
|
+
}), u = [];
|
|
38
724
|
try {
|
|
39
|
-
let r = (e, t) =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
],
|
|
725
|
+
let r = (e, t) => l.height(e, t), _ = r(0, 0), v = n.scene.lighting, S = [
|
|
726
|
+
v.direction[0],
|
|
727
|
+
v.direction[1],
|
|
728
|
+
v.direction[2]
|
|
729
|
+
], C = h.attach(n, {
|
|
44
730
|
limit: 400,
|
|
45
731
|
shading: "unlit"
|
|
46
732
|
});
|
|
47
|
-
|
|
48
|
-
let
|
|
733
|
+
u.push(() => C.dispose());
|
|
734
|
+
let w = h.attach(n, {
|
|
49
735
|
limit: 16e3,
|
|
50
736
|
relief: 1,
|
|
51
|
-
lightDirection:
|
|
737
|
+
lightDirection: S,
|
|
52
738
|
lightColor: [
|
|
53
|
-
.
|
|
54
|
-
.
|
|
55
|
-
.
|
|
739
|
+
H.sun,
|
|
740
|
+
H.sun,
|
|
741
|
+
H.sun * 1.02
|
|
56
742
|
],
|
|
57
|
-
ambient: .
|
|
743
|
+
ambient: H.sky,
|
|
58
744
|
density: .35
|
|
59
745
|
});
|
|
60
|
-
|
|
61
|
-
let
|
|
746
|
+
u.push(() => w.dispose());
|
|
747
|
+
let T = U.toward * Math.PI / 180, E = await M({
|
|
748
|
+
height: r,
|
|
749
|
+
blasts: s,
|
|
750
|
+
pieces: i.rocks ?? 600,
|
|
751
|
+
wind: [
|
|
752
|
+
U.speed * Math.sin(T),
|
|
753
|
+
0,
|
|
754
|
+
U.speed * Math.cos(T)
|
|
755
|
+
]
|
|
756
|
+
}), [{ chargeEnergy: D, energyBudget: O, fireball: k, tntEquivalent: A, FIREBALL_TEMPERATURE: j }, { burstDust: N, plumeAlbedo: P, TNT_SOOT_YIELD: F }] = await Promise.all([import("@margoengine/physics/explosive"), import("@margoengine/physics/plume")]), I = s.reduce((e, t) => e + t.tnt, 0), R = P({
|
|
757
|
+
soot: 1,
|
|
758
|
+
dust: 0
|
|
759
|
+
}), z = P({
|
|
760
|
+
soot: F * I,
|
|
761
|
+
dust: N(I),
|
|
762
|
+
ironOxide: te.ironOxide
|
|
763
|
+
}), B = s.map((e) => {
|
|
764
|
+
let t = D(e.tnt), n = O(t, a.depth);
|
|
765
|
+
return {
|
|
766
|
+
air: n.air / t,
|
|
767
|
+
radius: k(A(n.air)).radius
|
|
768
|
+
};
|
|
769
|
+
}), re = s.map((e, t) => ({
|
|
62
770
|
at: e.at,
|
|
63
771
|
tnt: e.tnt,
|
|
64
|
-
|
|
772
|
+
radius: B[t].radius,
|
|
65
773
|
position: [
|
|
66
774
|
e.at_[0],
|
|
67
775
|
r(e.at_[0], e.at_[1]),
|
|
68
776
|
e.at_[1]
|
|
69
|
-
]
|
|
70
|
-
|
|
71
|
-
|
|
777
|
+
],
|
|
778
|
+
depth: a.depth,
|
|
779
|
+
dust: N(e.tnt)
|
|
780
|
+
})), W = new m({
|
|
781
|
+
sources: re,
|
|
72
782
|
altitude: _,
|
|
73
|
-
|
|
74
|
-
|
|
783
|
+
heatShare: B[0].air,
|
|
784
|
+
fireTemperature: j,
|
|
785
|
+
entrainment: .25,
|
|
786
|
+
addedMass: .5,
|
|
787
|
+
wind: U.speed,
|
|
788
|
+
windDirection: U.toward,
|
|
75
789
|
fireDuration: 6,
|
|
790
|
+
color: z,
|
|
791
|
+
stemColor: z,
|
|
76
792
|
seed: 1944
|
|
77
793
|
});
|
|
78
|
-
|
|
79
|
-
let
|
|
80
|
-
|
|
794
|
+
u.push(() => W.clear());
|
|
795
|
+
let G = -1, [K, { GroundChange: q }] = await Promise.all([e(s, 9.80665, { height: r }), import("@margoengine/terrain/ground-change")]), le = q.attach(n, l.view.terrain, {
|
|
796
|
+
events: K.secondaries ? [K.event, K.secondaries] : [K.event],
|
|
797
|
+
clock: () => Math.max(G, 0),
|
|
798
|
+
shadows: l.shadows,
|
|
799
|
+
soil: o
|
|
800
|
+
});
|
|
801
|
+
u.push(() => le.dispose());
|
|
802
|
+
let ue = await y(n, `${i.library ?? "/asset-library/"}big-burn-1910/rocks/rock_07/rock_07_2k.gltf`, i.signal ? { signal: i.signal } : {}), de = i.rocks ?? 600, fe = new b(de);
|
|
803
|
+
for (let e of ue.primitives) e.instances = fe;
|
|
804
|
+
u.push(() => ue.dispose());
|
|
805
|
+
let Y = /* @__PURE__ */ new Float32Array(16), pe = () => {
|
|
806
|
+
let e = E.rocks();
|
|
807
|
+
fe.count = e.length;
|
|
808
|
+
for (let [t, n] of e.entries()) {
|
|
809
|
+
let e = n.landed ? t : t + 4 * G, r = Math.cos(e), i = Math.sin(e), a = 4 * n.size;
|
|
810
|
+
Y.fill(0), Y[0] = a * r, Y[2] = -a * i, Y[5] = a, Y[8] = a * i, Y[10] = a * r, Y[12] = n.position[0], Y[13] = n.position[1], Y[14] = n.position[2], Y[15] = 1, fe.setMatrixAt(t, Y);
|
|
811
|
+
let o = d(t);
|
|
812
|
+
fe.setColorAt(t, o ? [
|
|
813
|
+
.78,
|
|
814
|
+
.76,
|
|
815
|
+
.7,
|
|
816
|
+
1
|
|
817
|
+
] : [
|
|
818
|
+
.36,
|
|
819
|
+
.2,
|
|
820
|
+
.14,
|
|
821
|
+
1
|
|
822
|
+
]);
|
|
823
|
+
}
|
|
824
|
+
}, X = null, me = (e) => {
|
|
825
|
+
let t = E.landings().filter((t) => t.puff > 0 && e - t.time <= ne).slice(-400);
|
|
826
|
+
if (!t.length) {
|
|
827
|
+
X && w.remove(X), X = null;
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
let n = [
|
|
831
|
+
Infinity,
|
|
832
|
+
Infinity,
|
|
833
|
+
Infinity
|
|
834
|
+
], r = [
|
|
835
|
+
-Infinity,
|
|
836
|
+
-Infinity,
|
|
837
|
+
-Infinity
|
|
838
|
+
], i = 0, a = t.map((t) => {
|
|
839
|
+
let a = Math.max(0, e - t.time), o = t.puff * (.5 + .5 * Math.min(1, a / 2)), s = [
|
|
840
|
+
t.position[0],
|
|
841
|
+
t.position[1] + o / 2,
|
|
842
|
+
t.position[2]
|
|
843
|
+
];
|
|
844
|
+
for (let e = 0; e < 3; e++) n[e] = Math.min(n[e], s[e]), r[e] = Math.max(r[e], s[e]);
|
|
845
|
+
return i = Math.max(i, o), {
|
|
846
|
+
centre: s,
|
|
847
|
+
size: o,
|
|
848
|
+
fade: 1 - a / ne
|
|
849
|
+
};
|
|
850
|
+
}), o = [
|
|
81
851
|
0,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
],
|
|
85
|
-
radius: 80,
|
|
86
|
-
count: 1400,
|
|
87
|
-
speed: 40,
|
|
88
|
-
size: [.3, 2.4],
|
|
89
|
-
density: 1800,
|
|
90
|
-
ground: r,
|
|
91
|
-
color: [
|
|
92
|
-
.2,
|
|
93
|
-
.15,
|
|
94
|
-
.1
|
|
95
|
-
],
|
|
96
|
-
puffColor: [
|
|
97
|
-
.34,
|
|
98
|
-
.3,
|
|
99
|
-
.26
|
|
100
|
-
],
|
|
101
|
-
seed: 27
|
|
102
|
-
}), new u({
|
|
103
|
-
origin: [
|
|
852
|
+
1,
|
|
853
|
+
2
|
|
854
|
+
].map((e) => (n[e] + r[e]) / 2), s = [
|
|
104
855
|
0,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
],
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
for (let e of r.primitives) e.instances = i;
|
|
129
|
-
g.push(() => r.dispose());
|
|
130
|
-
let a = /* @__PURE__ */ new Float32Array(16);
|
|
131
|
-
return {
|
|
132
|
-
capacity: i.capacity,
|
|
133
|
-
get count() {
|
|
134
|
-
return i.count;
|
|
135
|
-
},
|
|
136
|
-
set count(e) {
|
|
137
|
-
i.count = e;
|
|
138
|
-
},
|
|
139
|
-
setMatrixAt(e, t) {
|
|
140
|
-
for (let e = 0; e < 16; e++) a[e] = e < 12 && e % 4 != 3 ? t[e] * 4 : t[e];
|
|
141
|
-
i.setMatrixAt(e, a);
|
|
142
|
-
},
|
|
143
|
-
setColorAt(e, t) {
|
|
144
|
-
i.setColorAt(e, [
|
|
145
|
-
t[0],
|
|
146
|
-
t[1],
|
|
147
|
-
t[2],
|
|
148
|
-
1
|
|
149
|
-
]);
|
|
856
|
+
1,
|
|
857
|
+
2
|
|
858
|
+
].map((e) => Math.max(r[e] - n[e], .001)), c = {
|
|
859
|
+
seed: 27,
|
|
860
|
+
segments: a.length,
|
|
861
|
+
bounds: s,
|
|
862
|
+
volume: i,
|
|
863
|
+
color: [
|
|
864
|
+
.34,
|
|
865
|
+
.3,
|
|
866
|
+
.26
|
|
867
|
+
],
|
|
868
|
+
opacity: a.reduce((e, t) => e + t.fade, 0) / a.length,
|
|
869
|
+
distribute: (e) => {
|
|
870
|
+
let t = a[e];
|
|
871
|
+
return {
|
|
872
|
+
point: [
|
|
873
|
+
0,
|
|
874
|
+
1,
|
|
875
|
+
2
|
|
876
|
+
].map((e) => (t.centre[e] - o[e]) * 2 / s[e]),
|
|
877
|
+
volume: t.size / i * (.4 + .6 * t.fade)
|
|
878
|
+
};
|
|
150
879
|
}
|
|
151
880
|
};
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
881
|
+
X ? Object.assign(X.options, c) : X = w.add(c);
|
|
882
|
+
let l = X.matrix;
|
|
883
|
+
l.fill(0), l[0] = l[5] = l[10] = l[15] = 1, l[12] = o[0], l[13] = o[1], l[14] = o[2];
|
|
884
|
+
}, Z = null, he;
|
|
885
|
+
u.push(() => he?.dispose());
|
|
886
|
+
let ge = ae(K), _e = oe(), ve = s.map((e) => {
|
|
887
|
+
let [t, n] = e.at_;
|
|
888
|
+
return {
|
|
889
|
+
position: [
|
|
890
|
+
t,
|
|
891
|
+
le.sample(t, n, ge).height,
|
|
892
|
+
n
|
|
893
|
+
],
|
|
894
|
+
fire: void 0
|
|
895
|
+
};
|
|
896
|
+
});
|
|
897
|
+
u.push(() => ve.forEach((e) => e.fire?.dispose()));
|
|
898
|
+
let Q = i.surge ? await V({
|
|
899
|
+
height: r,
|
|
900
|
+
blasts: s
|
|
901
|
+
}) : void 0, ye = Q ? ee(Q, r) : void 0;
|
|
902
|
+
ye && u.push(() => ye.clear());
|
|
903
|
+
let $, be;
|
|
904
|
+
if (i.mud) {
|
|
905
|
+
let [e, i] = t.reservoir;
|
|
906
|
+
$ = await L({
|
|
907
|
+
height: r,
|
|
908
|
+
grid: J,
|
|
909
|
+
outlet: [e, i - 40],
|
|
910
|
+
toward: t.works,
|
|
911
|
+
blasts: s,
|
|
912
|
+
pond: [e, i]
|
|
913
|
+
});
|
|
914
|
+
let a = J.cells, o = new Float32Array(a * a), c = Infinity;
|
|
915
|
+
for (let e = 0; e < a; e++) for (let t = 0; t < a; t++) {
|
|
916
|
+
let n = r(J.origin[0] + (t + .5) * J.size[0] / a, J.origin[1] + (e + .5) * J.size[1] / a);
|
|
917
|
+
o[e * a + t] = n, c = Math.min(c, n);
|
|
158
918
|
}
|
|
159
|
-
let
|
|
160
|
-
|
|
161
|
-
height:
|
|
919
|
+
let l = /* @__PURE__ */ new Map();
|
|
920
|
+
be = f.attach(n, {
|
|
921
|
+
height: c - 5,
|
|
162
922
|
size: [2400, 2400],
|
|
163
923
|
segments: 512,
|
|
164
924
|
waves: [{
|
|
@@ -173,111 +933,102 @@ async function S(e, t = {}) {
|
|
|
173
933
|
],
|
|
174
934
|
terrain: {
|
|
175
935
|
heightmap: () => {
|
|
176
|
-
let
|
|
177
|
-
if (!
|
|
178
|
-
let
|
|
179
|
-
size: [
|
|
936
|
+
let e = n.gpu;
|
|
937
|
+
if (!l.has(e)) {
|
|
938
|
+
let t = e.createTexture({
|
|
939
|
+
size: [a, a],
|
|
180
940
|
format: "r32float",
|
|
181
941
|
usage: 6
|
|
182
942
|
});
|
|
183
|
-
|
|
943
|
+
e.queue.writeTexture({ texture: t }, o, { bytesPerRow: a * 4 }, [a, a]), l.set(e, t);
|
|
184
944
|
}
|
|
185
|
-
return
|
|
945
|
+
return l.get(e);
|
|
186
946
|
},
|
|
187
|
-
origin:
|
|
188
|
-
size:
|
|
947
|
+
origin: J.origin,
|
|
948
|
+
size: J.size,
|
|
189
949
|
heights: {
|
|
190
|
-
data:
|
|
191
|
-
width:
|
|
192
|
-
height:
|
|
950
|
+
data: o,
|
|
951
|
+
width: a,
|
|
952
|
+
height: a
|
|
193
953
|
}
|
|
194
954
|
}
|
|
195
|
-
}),
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
maxDepth: 12,
|
|
203
|
-
maxSpeed: 20
|
|
204
|
-
}), g.push(() => j?.dispose()), g.push(() => a.forEach((e) => e.destroy()));
|
|
205
|
-
}
|
|
206
|
-
let N = -1, P = !1, F = !0, I = Math.min(n, 20);
|
|
207
|
-
if (j && n > 20) {
|
|
208
|
-
let [e, t] = i.reservoir, r = Math.min(n - 20, y);
|
|
209
|
-
j.setSources([{
|
|
210
|
-
position: [e, t - 40],
|
|
211
|
-
discharge: b,
|
|
212
|
-
radius: 25
|
|
213
|
-
}]), j.advanceTime(r), P = !0;
|
|
955
|
+
}), u.push(() => be?.dispose());
|
|
956
|
+
let d = x.attach(n, {
|
|
957
|
+
surface: be,
|
|
958
|
+
source: $.surface,
|
|
959
|
+
sediment: $.sediment
|
|
960
|
+
});
|
|
961
|
+
u.push(() => d.dispose()), u.push(() => l.forEach((e) => e.destroy()));
|
|
214
962
|
}
|
|
215
|
-
let
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
position
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
]
|
|
226
|
-
|
|
227
|
-
width: 60
|
|
228
|
-
}), g.push(() => A?.dispose());
|
|
229
|
-
}
|
|
230
|
-
if (j) {
|
|
231
|
-
let e = n >= 20 && n < 200;
|
|
232
|
-
if (e !== P) {
|
|
233
|
-
let [t, n] = i.reservoir;
|
|
234
|
-
j.setSources(e ? [{
|
|
235
|
-
position: [t, n - 40],
|
|
236
|
-
discharge: b,
|
|
237
|
-
radius: 25
|
|
238
|
-
}] : []), P = e;
|
|
239
|
-
}
|
|
240
|
-
F && n > I + j.time && j.advanceTime(n - I - j.time);
|
|
963
|
+
let xe = (e) => {
|
|
964
|
+
if (W.seek(e), W.draw(w, C, i.puffs ?? {}), E.seek(e), G = e, pe(), me(e), Z && (i.shake ?? !0)) {
|
|
965
|
+
let [t, r, i] = E.shake(Z.position, e);
|
|
966
|
+
n.camera.position = [
|
|
967
|
+
Z.position[0] + t,
|
|
968
|
+
Z.position[1] + r,
|
|
969
|
+
Z.position[2] + i
|
|
970
|
+
], n.camera.target = [
|
|
971
|
+
Z.target[0] + t,
|
|
972
|
+
Z.target[1] + r,
|
|
973
|
+
Z.target[2] + i
|
|
974
|
+
];
|
|
241
975
|
}
|
|
242
|
-
|
|
976
|
+
let t = (e) => g.attach(n, e);
|
|
977
|
+
he = ce(he, e >= 3 ? ie(e, r, R) : void 0, t);
|
|
978
|
+
for (let n of ve) n.fire = ce(n.fire, se(n.position, e - ge, _e), t);
|
|
979
|
+
$ && $.seek(e), Q && (Q.seek(e), ye.draw(w)), G = e;
|
|
243
980
|
};
|
|
244
|
-
|
|
245
|
-
let
|
|
981
|
+
xe(c);
|
|
982
|
+
let Se = p(n), Ce = {
|
|
246
983
|
name: "fauld-blast-clock",
|
|
247
984
|
onPreUpdate(e) {
|
|
248
|
-
e > 0 &&
|
|
985
|
+
e > 0 && xe(G + e);
|
|
249
986
|
}
|
|
250
987
|
};
|
|
251
|
-
return (
|
|
252
|
-
...
|
|
253
|
-
blast:
|
|
254
|
-
smoke:
|
|
255
|
-
fire:
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
988
|
+
return (i.clock ?? !0) && Se.use(Ce), {
|
|
989
|
+
...l,
|
|
990
|
+
blast: W,
|
|
991
|
+
smoke: w,
|
|
992
|
+
fire: C,
|
|
993
|
+
explosion: E,
|
|
994
|
+
dig: K,
|
|
995
|
+
crater: le,
|
|
996
|
+
get mud() {
|
|
997
|
+
return $;
|
|
259
998
|
},
|
|
999
|
+
surge: Q,
|
|
260
1000
|
get time() {
|
|
261
|
-
return
|
|
1001
|
+
return G;
|
|
1002
|
+
},
|
|
1003
|
+
look(e, t, n = 45) {
|
|
1004
|
+
Z = {
|
|
1005
|
+
position: [...e],
|
|
1006
|
+
target: [...t],
|
|
1007
|
+
fov: n
|
|
1008
|
+
}, l.look(e, t, n);
|
|
262
1009
|
},
|
|
263
1010
|
seek(e) {
|
|
264
1011
|
if (!(e >= 0)) throw RangeError(`fauld-blast seek ${e}: pass film seconds of 0 or more.`);
|
|
265
|
-
|
|
266
|
-
|
|
1012
|
+
xe(e);
|
|
1013
|
+
},
|
|
1014
|
+
soundtrack(e, t, n) {
|
|
1015
|
+
let r = n ?? Z?.position;
|
|
1016
|
+
if (!r) throw RangeError("fauld-blast soundtrack: put the camera with look first, or pass where to listen.");
|
|
1017
|
+
return E.recording(r, e, t);
|
|
267
1018
|
},
|
|
268
1019
|
dispose() {
|
|
269
|
-
|
|
270
|
-
for (let e of
|
|
271
|
-
|
|
1020
|
+
Se.sceneOf(Ce)?.removePlugin(Ce.name);
|
|
1021
|
+
for (let e of u.reverse()) e();
|
|
1022
|
+
u.length = 0, l.dispose();
|
|
272
1023
|
},
|
|
273
1024
|
[Symbol.dispose]() {
|
|
274
1025
|
this.dispose();
|
|
275
1026
|
}
|
|
276
1027
|
};
|
|
277
1028
|
} catch (e) {
|
|
278
|
-
for (let e of
|
|
279
|
-
throw
|
|
1029
|
+
for (let e of u.reverse()) e();
|
|
1030
|
+
throw l.dispose(), e;
|
|
280
1031
|
}
|
|
281
1032
|
}
|
|
282
1033
|
//#endregion
|
|
283
|
-
export {
|
|
1034
|
+
export { s as FAULD_BLASTS, E as FAULD_CAMERA, u as FAULD_CENTRE, c as FAULD_CLOUD_DECK, q as FAULD_CRATER_FIRE, K as FAULD_DUMP, G as FAULD_FIREBALL_SECONDS, W as FAULD_FIRE_AT, te as FAULD_LOAD, D as FAULD_MICROPHONE, P as FAULD_MUD, re as FAULD_MUD_AT, t as FAULD_PLACES, N as FAULD_RESERVOIR, T as FAULD_ROCK, l as FAULD_SIZE, n as FAULD_SLOTS, a as FAULD_STORE, R as FAULD_SURGE, i as FAULD_WIND, le as attach, oe as fauldCraterBed, se as fauldCraterFire, ae as fauldCraterFormed, e as fauldDig, ie as fauldDumpFire, M as fauldExplosion, ce as fauldFireStep, d as fauldGypsum, L as fauldMud, V as fauldSurge, ee as fauldSurgeDust };
|