@margoengine/scenes 0.0.0-stage → 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.
Files changed (48) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +4 -0
  3. package/README.md +619 -2
  4. package/dist/dune-coast-info-D9yQIv8G.js +218 -0
  5. package/dist/dune-coast-info.d.ts +3 -0
  6. package/dist/dune-coast.d.ts +179 -0
  7. package/dist/dune-coast.js +778 -0
  8. package/dist/errors-fc4i1pSL.js +7 -0
  9. package/dist/fauld-blast.d.ts +165 -0
  10. package/dist/fauld-blast.js +1034 -0
  11. package/dist/fauld-countryside.d.ts +13 -0
  12. package/dist/fauld-countryside.js +10 -0
  13. package/dist/fauld-crater.d.ts +13 -0
  14. package/dist/fauld-crater.js +10 -0
  15. package/dist/fauld-dig.d.ts +89 -0
  16. package/dist/fauld-dustfall-fines-grid-MA6XPrq6.js +14 -0
  17. package/dist/fauld-dustfall-fines-grid.d.ts +11 -0
  18. package/dist/fauld-dustfall-grid-Bb4X8b-u.js +14 -0
  19. package/dist/fauld-dustfall-grid.d.ts +11 -0
  20. package/dist/fauld-explosion.d.ts +135 -0
  21. package/dist/fauld-grains.d.ts +27 -0
  22. package/dist/fauld-mud.d.ts +104 -0
  23. package/dist/fauld-surge.d.ts +71 -0
  24. package/dist/fauld-tunnels-info-8qv9X4OJ.js +70 -0
  25. package/dist/fauld-tunnels-info.d.ts +5 -0
  26. package/dist/fauld-tunnels-plan.d.ts +1069 -0
  27. package/dist/fauld-tunnels.d.ts +281 -0
  28. package/dist/fauld-tunnels.js +6801 -0
  29. package/dist/fauld-world-CNNSonJF.js +863 -0
  30. package/dist/fauld-world-info.d.ts +7 -0
  31. package/dist/fauld-world.d.ts +243 -0
  32. package/dist/index.d.ts +53 -0
  33. package/dist/index.js +160 -0
  34. package/dist/library-mesh-CjTG-mVZ.js +329 -0
  35. package/dist/library-mesh.d.ts +108 -0
  36. package/dist/library-parts.d.ts +55 -0
  37. package/dist/library.d.ts +52 -0
  38. package/dist/library.js +48 -0
  39. package/dist/look-family.d.ts +63 -0
  40. package/dist/look-family.js +57 -0
  41. package/dist/shared/settings.d.ts +89 -0
  42. package/dist/shot-settings.d.ts +40 -0
  43. package/dist/shot-settings.js +94 -0
  44. package/dist/timber-valley-info-vVI2nwDs.js +253 -0
  45. package/dist/timber-valley-info.d.ts +3 -0
  46. package/dist/timber-valley.d.ts +229 -0
  47. package/dist/timber-valley.js +424 -0
  48. package/package.json +104 -4
@@ -0,0 +1,778 @@
1
+ // @margo/core-built 1.0.0
2
+ import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
+
4
+ import { t as e } from "./dune-coast-info-D9yQIv8G.js";
5
+ import { PbrMaterial as t } from "@margoengine/core";
6
+ import { applyMatrix4 as n, toGeometry as r } from "@margoengine/geometry";
7
+ import { Noise as i } from "@margoengine/procedural/noise";
8
+ import { generateLaunchRail as a, generatePlankShed as o, shedBoardMap as s } from "@margoengine/procedural/sheds";
9
+ import { Material as c, Texture as l, createMesh as u } from "@margoengine/materials";
10
+ import { weatheredWood as d } from "@margoengine/materials/presets";
11
+ import { TerrainColors as f, TerrainHeightmap as p, heightfieldGeometry as m } from "@margoengine/terrain";
12
+ import { TerrainDeformation as h } from "@margoengine/terrain/deform";
13
+ import { duneField as g, duneHill as _ } from "@margoengine/terrain/dunes";
14
+ import { refinedHeightfieldGeometry as v, windScour as y } from "@margoengine/terrain/scour";
15
+ import { DAY_PRESETS as b } from "@margoengine/sky/day-presets";
16
+ import { PresetScene as ee, SCENE_PRESETS as x } from "@margoengine/sky/scenes";
17
+ import { degrees as S, sunPath as te } from "@margoengine/sky/sun";
18
+ import { Water as ne } from "@margoengine/water";
19
+ import { SpectralSea as re } from "@margoengine/physics/sea";
20
+ import { jonswap as C, sumSpectra as ie } from "@margoengine/physics/waves";
21
+ import { GrassScatter as ae } from "@margoengine/scatter/grass";
22
+ import { Shadows as oe } from "@margoengine/shadows";
23
+ import { GTAO as se } from "@margoengine/post/gtao";
24
+ //#region src/dune-coast.ts
25
+ var w = e, ce = 0, T = 900, E = {
26
+ origin: [-900, -800],
27
+ size: [2200, 2e3]
28
+ }, le = [
29
+ [
30
+ [-86.9, 27],
31
+ [-79, 24.5],
32
+ [-71, 27.2]
33
+ ],
34
+ [
35
+ [-69.5, 27],
36
+ [-52, 17],
37
+ [-31, 8.5],
38
+ [-11, 2.5],
39
+ [-1.6, .8]
40
+ ],
41
+ [
42
+ [-1.4, -2.4],
43
+ [-13, 3.6],
44
+ [-33, 12],
45
+ [-56, 20.5],
46
+ [-71, 26.4]
47
+ ],
48
+ [
49
+ [-68, 25.5],
50
+ [-45, 6],
51
+ [-22, -6],
52
+ [-2.2, -9]
53
+ ],
54
+ [
55
+ [1.2, 2.5],
56
+ [1.5, -7],
57
+ [1.1, -19.5],
58
+ [-1.1, -20.5],
59
+ [-1.3, -9],
60
+ [-1.6, 1.5]
61
+ ],
62
+ [
63
+ [-2.5, -46],
64
+ [-1.4, -31],
65
+ [-1.2, -21]
66
+ ],
67
+ [
68
+ [-.4, -20],
69
+ [-3.5, -12],
70
+ [-2.8, -4],
71
+ [3.5, 3],
72
+ [6.5, 5.5]
73
+ ],
74
+ [
75
+ [-70, 26],
76
+ [-55, 9],
77
+ [-43.5, -7],
78
+ [-30, -14],
79
+ [-6, -15.5]
80
+ ]
81
+ ];
82
+ function D(e) {
83
+ if (typeof e != "object" || !e) throw TypeError("dune-coast: pass settings as an object.");
84
+ let t = {
85
+ ...Object.fromEntries(Object.entries(w.settings).map(([e, t]) => [e, t.default])),
86
+ ...e
87
+ };
88
+ for (let [e, n] of Object.entries(w.settings)) {
89
+ let r = t[e];
90
+ if (n.range && !(typeof r == "number" && r >= n.range[0] && r <= n.range[1])) throw RangeError(`dune-coast: ${e} is out of range; pass ${n.range[0]} to ${n.range[1]}.`);
91
+ if (n.options && !n.options.includes(r)) throw RangeError(`dune-coast: unknown ${e}; pass ${n.options.join(" or ")}.`);
92
+ }
93
+ for (let e of [
94
+ "sand",
95
+ "boards",
96
+ "roof",
97
+ "grassColor"
98
+ ]) {
99
+ let n = t[e];
100
+ if (!n || n.length !== 3 || !Array.from(n).every((e) => typeof e == "number" && e >= 0 && e <= 1)) throw RangeError(`dune-coast: ${e} is not a colour; pass three linear RGB values from 0 to 1.`);
101
+ }
102
+ if (!Number.isInteger(t.grassBlades)) throw RangeError("dune-coast: grassBlades is not a whole number; pass 4 to 64.");
103
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(t.date) || Number.isNaN(Date.parse(t.date))) throw RangeError("dune-coast: date is not a date; pass YYYY-MM-DD.");
104
+ return t;
105
+ }
106
+ function ue(e) {
107
+ let t = Date.parse(e + "T12:00:00Z"), n = Date.UTC(Number(e.slice(0, 4)), 0, 1, 12);
108
+ return Math.round((t - n) / 864e5) + 1;
109
+ }
110
+ var O = (e, t, n) => {
111
+ let r = Math.min(1, Math.max(0, (n - e) / (t - e)));
112
+ return r * r * (3 - 2 * r);
113
+ };
114
+ function k(e) {
115
+ if (e.heights) {
116
+ let { samples: t, width: n, depth: r } = e.heights, i = e.heights.cellSize ?? 1, [a, o] = e.heights.origin ?? [-n * i / 2, -r * i / 2], s = e.heights.sea ?? .05;
117
+ if (t.length !== n * r) throw RangeError("dune-coast: heights.samples must hold width * depth values.");
118
+ let c = (e, i) => {
119
+ let a = t[Math.min(r - 1, Math.max(0, i)) * n + Math.min(n - 1, Math.max(0, e))];
120
+ return a <= s ? -1.5 : a;
121
+ };
122
+ return (e, t) => {
123
+ let n = (e - a) / i, r = (t - o) / i, s = Math.floor(n), l = Math.floor(r), u = n - s, d = r - l;
124
+ return (c(s, l) * (1 - u) + c(s + 1, l) * u) * (1 - d) + (c(s, l + 1) * (1 - u) + c(s + 1, l + 1) * u) * d;
125
+ };
126
+ }
127
+ let t = E.size[0] / 2 + 1, n = E.size[1] / 2 + 1, r = ((e.windFrom + 180) % 360 - 90 + 360) % 360, i = g({
128
+ width: t,
129
+ depth: n,
130
+ cellSize: 2,
131
+ origin: E.origin,
132
+ type: "transverse",
133
+ height: .8,
134
+ spacing: 16,
135
+ stoss: 10,
136
+ lee: 28,
137
+ irregularity: .9,
138
+ round: 4,
139
+ wind: r,
140
+ seed: e.seed,
141
+ amount: (e, t) => O(90, 220, Math.hypot(e + 10, t - 10)) * (1 - O(640, 720, e))
142
+ }), a = [
143
+ {
144
+ crest: [-40, 430],
145
+ height: e.hill,
146
+ wind: r,
147
+ stoss: 12,
148
+ lee: 30,
149
+ round: e.hill / 3 * (1 - .85 * e.crest)
150
+ },
151
+ {
152
+ crest: [-560, 260],
153
+ height: 11,
154
+ wind: r,
155
+ stoss: 11,
156
+ lee: 30,
157
+ halfWidth: 70
158
+ },
159
+ {
160
+ crest: [260, 520],
161
+ height: 7,
162
+ wind: r,
163
+ stoss: 10,
164
+ lee: 28,
165
+ halfWidth: 45
166
+ }
167
+ ].filter((e) => e.height > 0);
168
+ return (e, r) => {
169
+ let o = (e - E.origin[0]) / 2, s = (r - E.origin[1]) / 2, c = Math.min(t - 2, Math.max(0, Math.floor(o))), l = Math.min(n - 2, Math.max(0, Math.floor(s))), u = Math.min(1, Math.max(0, o - c)), d = Math.min(1, Math.max(0, s - l)), f = (i[l * t + c] * (1 - u) + i[l * t + c + 1] * u) * (1 - d) + (i[(l + 1) * t + c] * (1 - u) + i[(l + 1) * t + c + 1] * u) * d, p = 0;
170
+ for (let t of a) p += _(e, r, t);
171
+ let m = 2.5 + f * (1 - O(.5, 4, p)) + p, h = e < T ? (T - e) / 28 : (T - e) / 50, g = O(730, 830, e), v = 3.2 * Math.exp(-(((e - 785) / 28) ** 2)) * (.8 + .2 * Math.sin(r / 37 + Math.sin(r / 91)));
172
+ return (1 - g) * m + g * h + v;
173
+ };
174
+ }
175
+ var A = [{
176
+ center: [-70, 30],
177
+ size: [13.4, 4.9],
178
+ height: 3.2
179
+ }, {
180
+ center: [-88.5, 30],
181
+ size: [7.6, 4.9],
182
+ height: 3.71
183
+ }];
184
+ function j(e, t) {
185
+ if (!(e.scour > 0)) return;
186
+ let n = ((e.windFrom + 180) % 360 - 90 + 360) % 360, r = Math.cos(n * Math.PI / 180), a = Math.sin(n * Math.PI / 180), o = P(e, t), s = new i(e.seed + 11), c = [];
187
+ for (let e = 0; e < 56; e++) for (let t = 0; t < 54; t++) {
188
+ let n = -110 + 2.5 * t + 1.1 * s.simplex2(t * 7.3, e * 5.1), i = -65 + 2.5 * e + 1.1 * s.simplex2(t * 3.7 + 40, e * 8.9);
189
+ Math.abs(n) < 4 && i > -23 && i < 4 || o(n, i) > .45 && o(n + 1.6 * r, i + 1.6 * a) < .2 && c.push({
190
+ center: [n, i],
191
+ width: 1 + .5 * s.simplex2(t * 11.9 - 3, e * 13.3)
192
+ });
193
+ }
194
+ return y({
195
+ buildings: e.camp ? A : [],
196
+ plants: c,
197
+ wind: n,
198
+ speed: e.wind
199
+ });
200
+ }
201
+ function M(e) {
202
+ let t = k(e), n = j(e, t), r = n ? (t, r) => e.scour * n.change(t, r) : void 0;
203
+ return {
204
+ base: t,
205
+ wind: n,
206
+ change: r,
207
+ height: r ? (e, n) => t(e, n) + r(e, n) : t
208
+ };
209
+ }
210
+ function N(e = {}) {
211
+ return M(D(e)).height;
212
+ }
213
+ function de(e, t) {
214
+ let n = t + 1, r = E.size[0] / t, i = E.size[1] / t, a = new Float32Array(n * n);
215
+ for (let t = 0; t < n; t++) for (let o = 0; o < n; o++) a[t * n + o] = e(E.origin[0] + o * r, E.origin[1] + t * i);
216
+ return (e, o) => {
217
+ let s = Math.min(t, Math.max(0, (e - E.origin[0]) / r)), c = Math.min(t, Math.max(0, (o - E.origin[1]) / i)), l = Math.min(t - 1, Math.floor(s)), u = Math.min(t - 1, Math.floor(c)), d = s - l, f = c - u, p = a[u * n + l], m = a[u * n + l + 1], h = a[(u + 1) * n + l], g = a[(u + 1) * n + l + 1];
218
+ return (p + (m - p) * d) * (1 - f) + (h + (g - h) * d) * f;
219
+ };
220
+ }
221
+ function P(e, t) {
222
+ let n = new i(e.seed + 7), r = .9 - 1.2 * e.grass;
223
+ return (i, a) => {
224
+ let o = t(i, a), s = O(1.2, 2, o) * (1 - O(7, 11, o));
225
+ if (!(s > 0) || e.grass <= 0) return 0;
226
+ let c = (t(i + 6, a) + t(i - 6, a) + t(i, a + 6) + t(i, a - 6)) / 4, l = r - .5 * O(-.05, .35, o - c), u = .65 * n.simplex2(i / 8, a / 8) + .3 * n.simplex2(i / 2.5 - 9, a / 2.5 + 4) + .5 * n.simplex2(i / 30 + 31, a / 30 - 17), d = O(-98, -96.5, i) * (1 - O(-62, -60.5, i)) * O(26, 27.5, a) * (1 - O(32.5, 34, a));
227
+ return s * Math.max(.03, .95 * O(l, l + .15, u)) * (1 - d);
228
+ };
229
+ }
230
+ function F(e = {}) {
231
+ let t = D(e);
232
+ return P(t, k(t));
233
+ }
234
+ function I(e, t, r, i, a = 0) {
235
+ let o = Math.cos(a), s = Math.sin(a);
236
+ return n(e, [
237
+ o,
238
+ 0,
239
+ -s,
240
+ 0,
241
+ 0,
242
+ 1,
243
+ 0,
244
+ 0,
245
+ s,
246
+ 0,
247
+ o,
248
+ 0,
249
+ t,
250
+ r,
251
+ i,
252
+ 1
253
+ ]);
254
+ }
255
+ function L(e, n = {}) {
256
+ let i = D(n), g = i.quality === "film", { base: _, wind: y, change: T, height: k } = M(i), A = [], j = [], N = te({
257
+ latitude: S(i.latitude),
258
+ dayOfYear: ue(i.date),
259
+ hour: i.hour
260
+ }), F = i.weather === "overcast" ? x.overcast : x.noon, L = ee.attach(e, {
261
+ ...F,
262
+ day: {
263
+ ...i.weather === "overcast" ? b.overcast : b.noon,
264
+ azimuth: N.azimuth.degrees,
265
+ elevation: Math.max(1, N.elevation.degrees),
266
+ clouds: i.weather === "overcast" ? 1 : .35
267
+ },
268
+ fog: 3.912 / i.visibility
269
+ }, { meter: !0 });
270
+ j.push(() => L.dispose());
271
+ let R = i.occlusion > 0 ? new se({
272
+ radius: i.occlusion,
273
+ slices: g ? 3 : 2,
274
+ steps: g ? 8 : 6
275
+ }) : void 0;
276
+ R && L.post.addEffect(R, 0);
277
+ let z = oe.attach(e, {
278
+ resolution: g ? 4096 : 2048,
279
+ distance: 220,
280
+ lambda: .75,
281
+ lightSize: i.weather === "overcast" ? .08 : .02,
282
+ normalBias: .06,
283
+ casterMargin: 80
284
+ });
285
+ j.push(() => z.dispose());
286
+ let B = g ? 1023 : 511, V = de(_, B), H = {
287
+ size: E.size,
288
+ origin: E.origin,
289
+ resolution: B
290
+ }, U = e.createMesh().setGeometry(r(y ? v(V, {
291
+ ...H,
292
+ regions: y.bounds,
293
+ subdivide: g ? 5 : 3,
294
+ add: T
295
+ }) : m(V, H))).setMaterial(new t({
296
+ color: [
297
+ i.sand[0],
298
+ i.sand[1],
299
+ i.sand[2]
300
+ ],
301
+ roughness: .92
302
+ }));
303
+ U.name = "dune-coast ground", A.push(U), z.add(U, { static: !0 });
304
+ let W = p.attach(e, k, {
305
+ origin: [660, E.origin[1]],
306
+ size: [400, E.size[1]],
307
+ resolution: 512
308
+ });
309
+ j.push(() => W.dispose());
310
+ let G;
311
+ if (f.attach(e, U, {
312
+ sand: i.sand,
313
+ shore: [80, 90],
314
+ stoneNormal: [.2, .25],
315
+ wetHeight: [-.1, .9],
316
+ wetDarkening: .58,
317
+ variation: .08,
318
+ detail: 1,
319
+ sandSurface: {
320
+ wind: [Math.sin((i.windFrom + 180) * Math.PI / 180), -Math.cos((i.windFrom + 180) * Math.PI / 180)],
321
+ broad: i.sandBands
322
+ },
323
+ wetness: {
324
+ texture: () => G?.coastalDepthTexture,
325
+ origin: [660, E.origin[1]],
326
+ size: [400, E.size[1]]
327
+ }
328
+ }), i.surf > 0) {
329
+ let t = i.surf / 2, n = (i.windFrom + 180) * Math.PI / 180, r = [Math.sin(n), -Math.cos(n)], a = [
330
+ {
331
+ direction: [-.97, .24],
332
+ amplitude: t * .75,
333
+ wavelength: 72,
334
+ steepness: .45,
335
+ phase: .4
336
+ },
337
+ {
338
+ direction: [-.88, -.47],
339
+ amplitude: t * .4,
340
+ wavelength: 41,
341
+ steepness: .45,
342
+ phase: 2.2
343
+ },
344
+ {
345
+ direction: r,
346
+ amplitude: Math.min(.35, .025 * i.wind),
347
+ wavelength: 11,
348
+ steepness: .3,
349
+ phase: 4.1
350
+ },
351
+ {
352
+ direction: [r[0] * .8 - .2, r[1]],
353
+ amplitude: Math.min(.12, .01 * i.wind),
354
+ wavelength: 5,
355
+ steepness: .35,
356
+ phase: 1.3
357
+ }
358
+ ], o = () => ({
359
+ frequencies: Float64Array.from({ length: 34 }, (e, t) => .04 * 25 ** (t / 33)),
360
+ directions: Float64Array.from({ length: 24 }, (e, t) => 2 * Math.PI * t / 24),
361
+ energy: /* @__PURE__ */ new Float64Array(816),
362
+ depth: 20,
363
+ density: 1025
364
+ }), s = (e) => 4 * Math.sqrt(e.reduce((e, t) => e + t.amplitude * t.amplitude / 2, 0)), c = (e) => Math.sqrt(2 * Math.PI * e / 9.81), l = ie(o(), C({
365
+ height: s(a.slice(0, 2)),
366
+ period: c(72),
367
+ direction: Math.atan2(.24, -.97),
368
+ spread: { s: 25 }
369
+ }, o()), C({
370
+ height: s(a.slice(2)),
371
+ period: c(11),
372
+ direction: Math.atan2(r[1], r[0])
373
+ }, o()));
374
+ G = ne.attach(e, {
375
+ size: [1200, 1200],
376
+ segments: g ? 512 : 256,
377
+ horizon: !0,
378
+ height: 0,
379
+ color: [
380
+ .018,
381
+ .04,
382
+ .036
383
+ ],
384
+ foamDistance: 3,
385
+ spray: !0,
386
+ whitecaps: Math.min(1, i.wind / 18),
387
+ chop: Math.min(1, i.wind / 16),
388
+ depth: () => L.post.depthTexture,
389
+ sceneColor: () => L.post.sceneTexture,
390
+ reflection: () => L.sky.reflectionTexture,
391
+ lights: L.sky.lights,
392
+ shadows: z,
393
+ terrain: {
394
+ heightmap: () => W.texture,
395
+ origin: [660, E.origin[1]],
396
+ size: [400, E.size[1]]
397
+ },
398
+ waves: a,
399
+ sea: new re({
400
+ waves: l,
401
+ seed: 1
402
+ })
403
+ }), j.push(() => G?.dispose());
404
+ let u = L.sky.options.fog;
405
+ u && (L.sky.options.fog = {
406
+ ...u,
407
+ depth: () => G?.depthTexture ?? L.post.depthTexture
408
+ });
409
+ }
410
+ let K;
411
+ if (i.grass > 0) {
412
+ let n = B + 1, r = E.size[0] / B, a = E.size[1] / B, o = [E.origin[0] - r / 2, E.origin[1] - a / 2], s = [E.size[0] + r, E.size[1] + a], c = {
413
+ origin: o,
414
+ size: s,
415
+ resolution: n
416
+ }, l = p.attach(e, V, c), u = p.attach(e, P(i, V), c), d = (i.windFrom + 180) * Math.PI / 180;
417
+ j.push(() => l.dispose(), () => u.dispose()), K = ae.attach(e, {
418
+ count: g ? 24e4 : 8e4,
419
+ area: [480, 480],
420
+ follow: !0,
421
+ bounds: [
422
+ o[0],
423
+ o[1],
424
+ o[0] + s[0],
425
+ o[1] + s[1]
426
+ ],
427
+ heightmap: () => l.texture,
428
+ densityMap: () => u.texture,
429
+ maxSlope: 32,
430
+ scale: [.7, 1.25],
431
+ lod: [
432
+ 30,
433
+ 90,
434
+ 230
435
+ ],
436
+ edgeShrink: 40,
437
+ grass: {
438
+ height: i.grassHeight,
439
+ heightVariance: .5,
440
+ width: i.grassWidth,
441
+ blades: i.grassBlades,
442
+ radius: .25,
443
+ lean: .65,
444
+ round: .4
445
+ },
446
+ blades: {
447
+ rootShade: .5,
448
+ widen: 1,
449
+ translucency: i.grassTranslucency
450
+ },
451
+ variation: {
452
+ hue: i.grassVariety,
453
+ value: .25
454
+ },
455
+ material: new t({
456
+ color: [
457
+ i.grassColor[0],
458
+ i.grassColor[1],
459
+ i.grassColor[2]
460
+ ],
461
+ roughness: .85,
462
+ doubleSided: !0
463
+ }),
464
+ wind: [
465
+ Math.sin(d),
466
+ -Math.cos(d),
467
+ Math.min(1, i.wind / 15)
468
+ ],
469
+ sink: .04,
470
+ seed: i.seed
471
+ }), j.push(() => K?.dispose());
472
+ }
473
+ let q, J = !1, fe = Promise.resolve(), Y = [], X = `dune-coast-clock:${ce++}`;
474
+ if (i.blownSand > 0) {
475
+ let t = i.grass > 0 ? P(i, V) : () => 0, n = (i.windFrom + 180) * Math.PI / 180, r = {
476
+ ground: T ? (e, t) => V(e, t) + T(e, t) : V,
477
+ wind: {
478
+ speed: i.wind,
479
+ direction: Math.atan2(Math.sin(n), -Math.cos(n)),
480
+ gust: .35
481
+ },
482
+ mask: (e, n) => O(1.2, 2.2, V(e, n)) * (1 - t(e, n)),
483
+ amount: i.blownSand,
484
+ color: i.sand,
485
+ fog: 3.912 / i.visibility,
486
+ depth: () => L.post.depthTexture,
487
+ softness: .2,
488
+ sky: L.sky,
489
+ seed: i.seed
490
+ }, a = {coreRequirement:/*@__PURE__*/__margoCoreRequirement("1.0.0",import.meta.url),
491
+ name: X,
492
+ setup() {},
493
+ onPreUpdate: (e) => Y.push(e)
494
+ }, o = () => e.sceneOf(a)?.removePlugin(X);
495
+ e.use(a), fe = import("@margoengine/vfx/blown-sand").then(({ BlownSand: t }) => {
496
+ let n = e.sceneOf(a);
497
+ if (J || !n) return;
498
+ n.removePlugin(X);
499
+ let i = new t(r);
500
+ n.use(i);
501
+ for (let e of Y) i.advanceTime(e);
502
+ Y.length = 0, q = i;
503
+ }, (e) => {
504
+ throw J || o(), e;
505
+ }), j.push(() => {
506
+ J = !0, q ? q.dispose() : o();
507
+ });
508
+ }
509
+ let Z;
510
+ if (i.camp && i.footprints > 0) {
511
+ Z = h.attach(e, U, {
512
+ size: g ? 2048 : 1024,
513
+ depth: .045 * i.footprints,
514
+ rim: .3,
515
+ darken: .22,
516
+ distance: 45,
517
+ persist: !0,
518
+ follow: () => {
519
+ let [t, , n] = e.camera.position, [r, , i] = e.camera.target, a = Math.hypot(r - t, i - n), o = a > 0 ? Math.min(1, (g ? 20 : 10) / a) : 0;
520
+ return [t + (r - t) * o, n + (i - n) * o];
521
+ }
522
+ });
523
+ let t = Z;
524
+ j.push(() => t.dispose()), le.forEach((e, n) => t.walk(e, { seed: i.seed + n }));
525
+ }
526
+ if (i.camp) {
527
+ let t = (e, t) => {
528
+ let n = new l(e, t);
529
+ return j.push(() => n.dispose()), n;
530
+ }, n = (e, n) => t(s({
531
+ color: [
532
+ e[0],
533
+ e[1],
534
+ e[2]
535
+ ],
536
+ variation: i.shedWeathering,
537
+ seed: n
538
+ }), {
539
+ colorSpace: "srgb",
540
+ wrapS: "repeat",
541
+ wrapT: "repeat",
542
+ anisotropy: 8
543
+ }), r = (e, t) => new c({
544
+ color: [
545
+ 1,
546
+ 1,
547
+ 1
548
+ ],
549
+ map: e,
550
+ roughness: d.roughness,
551
+ metalness: d.metalness,
552
+ ...t ? { aoMap: t } : {}
553
+ }), f = n(i.boards, 1), p = r(f), m = r(n(i.roof, 2)), h = r(n([
554
+ .2,
555
+ .17,
556
+ .13
557
+ ], 3)), g = new c({
558
+ color: [
559
+ .35,
560
+ .34,
561
+ .33
562
+ ],
563
+ roughness: .6,
564
+ metalness: .8
565
+ }), _ = (e) => {
566
+ let n = Math.max(1, Math.round(255 * e)), a = t({
567
+ data: new Uint8Array([
568
+ n,
569
+ n,
570
+ n,
571
+ 255
572
+ ]),
573
+ width: 1,
574
+ height: 1
575
+ }, {});
576
+ return {
577
+ siding: p,
578
+ roof: m,
579
+ trim: h,
580
+ faces: r(f, a),
581
+ floor: new c({
582
+ color: [
583
+ i.sand[0],
584
+ i.sand[1],
585
+ i.sand[2]
586
+ ],
587
+ roughness: .92,
588
+ aoMap: a
589
+ })
590
+ };
591
+ }, v = (t, n, r) => {
592
+ let i = u(e, t, n);
593
+ i.root.name = r, j.push(() => i.dispose()), z.add(i, { static: !0 });
594
+ }, y = (e, t) => i.shedWindows ? t.map((t) => ({
595
+ wall: e,
596
+ at: t,
597
+ width: .8,
598
+ height: .7,
599
+ bottom: 1,
600
+ leaf: "none"
601
+ })) : [], b = o({
602
+ overhang: i.shedOverhang,
603
+ weathering: i.shedWeathering,
604
+ openings: [
605
+ {
606
+ wall: "front",
607
+ width: 3.6,
608
+ height: 2.1,
609
+ leaf: "awning"
610
+ },
611
+ ...y("back", [-3.5, 3.5]),
612
+ ...y("left", [0])
613
+ ],
614
+ seed: 3
615
+ }), ee = o({
616
+ overhang: i.shedOverhang,
617
+ weathering: i.shedWeathering,
618
+ length: 7.6,
619
+ width: 4.9,
620
+ eaves: 2.3,
621
+ pitch: 30,
622
+ siding: "vertical",
623
+ board: .2,
624
+ openings: [
625
+ {
626
+ wall: "front",
627
+ at: -1.6,
628
+ width: .9,
629
+ height: 1.95,
630
+ leaf: "closed"
631
+ },
632
+ {
633
+ wall: "front",
634
+ at: 1.5,
635
+ width: .8,
636
+ height: .7,
637
+ bottom: 1,
638
+ leaf: "none"
639
+ },
640
+ ...y("left", [0])
641
+ ],
642
+ seed: 4
643
+ }), x = (e, t) => k(e, t) - .05;
644
+ for (let [e, t, n] of [[
645
+ "hangar",
646
+ b,
647
+ -70
648
+ ], [
649
+ "shed",
650
+ ee,
651
+ -88.5
652
+ ]]) {
653
+ let r = _(t.inside.daylight), { faces: i, floor: a } = t.inside;
654
+ for (let [o, s] of Object.entries({
655
+ ...t.parts,
656
+ faces: i,
657
+ floor: a
658
+ })) v(I(s, n, x(n, 30), 30, Math.PI), r[o], `${e} ${o}`);
659
+ }
660
+ let S = a({ ground: (e) => k(0, -e) });
661
+ v(I(S.parts.wood, 0, 0, 0, Math.PI / 2), p, "rail"), S.parts.metal && v(I(S.parts.metal, 0, 0, 0, Math.PI / 2), g, "rail strip");
662
+ }
663
+ let Q = (e, t, n) => [
664
+ e,
665
+ k(e, t) + n,
666
+ t
667
+ ], $ = {
668
+ rail: {
669
+ position: Q(6, 4, 1.6),
670
+ target: Q(0, -18, .3),
671
+ about: "the launch rail, its south end at the origin"
672
+ },
673
+ camp: {
674
+ position: Q(-60, -25, 1.7),
675
+ target: Q(-78, 30, 2),
676
+ about: "the hangar and the shed, seen from the north"
677
+ },
678
+ flightLine: {
679
+ position: Q(0, -18.3, 1.5),
680
+ target: Q(0, -60, 1.5),
681
+ about: "north along the first flight, 120 ft"
682
+ },
683
+ bigHill: {
684
+ position: Q(-40, 430, 1.7),
685
+ target: Q(-40, -50, 2),
686
+ about: "the big dune crest, looking back at the camp"
687
+ },
688
+ beach: {
689
+ position: Q(780, 0, 1.7),
690
+ target: [
691
+ 1100,
692
+ 1,
693
+ 40
694
+ ],
695
+ about: "the foredune crest over the surf"
696
+ },
697
+ "first-flight": {
698
+ position: Q(14, -14, 1.3),
699
+ target: Q(-60, -40, .4),
700
+ about: "LC-W861-35, the first flight launch, looking west"
701
+ },
702
+ "camp-buildings": {
703
+ position: Q(-40, -12, 1.6),
704
+ target: Q(-80, 30, 1.6),
705
+ about: "LC-W86-15, the camp from the north-east"
706
+ },
707
+ "killdevil-from-flat": {
708
+ position: Q(10, -60, 1.6),
709
+ target: Q(-40, 430, 14),
710
+ about: "LC-W86-120, the big dune across the flat"
711
+ },
712
+ "flyer-on-rail": {
713
+ position: Q(-75, 300, 1.6),
714
+ target: Q(-25, 330, 1),
715
+ about: "LC-W86-21, on the windward slope, the slope rising right"
716
+ },
717
+ "killdevil-back": {
718
+ position: Q(-40, 640, 1.6),
719
+ target: Q(-40, 430, 10),
720
+ about: "LC-W85-110, the lee side of the big dune"
721
+ },
722
+ "landing-rail-view": {
723
+ position: Q(-4, -48, 1.2),
724
+ target: Q(0, 0, .2),
725
+ about: "LC-W86-38, back south along the flight line"
726
+ },
727
+ surf: {
728
+ position: Q(860, -30, 1.7),
729
+ target: [
730
+ 960,
731
+ .5,
732
+ 10
733
+ ],
734
+ about: "the beach and the surf, looking east"
735
+ },
736
+ crest: {
737
+ position: Q(-75, 424, 1.6),
738
+ target: Q(-30, 432, .5),
739
+ about: "the big dune crest seen side on, the wind blowing across the view from left to right"
740
+ }
741
+ };
742
+ return {
743
+ settings: i,
744
+ height: k,
745
+ anchors: $,
746
+ views: w.views,
747
+ view(t, n = 50) {
748
+ let r = $[t];
749
+ if (!r) throw RangeError(`dune-coast: no anchor ${t}; pass one of ${Object.keys($).join(", ")}.`);
750
+ e.camera.position = [...r.position], e.camera.target = [...r.target], e.camera.fov = n;
751
+ },
752
+ advanceTime(e) {
753
+ L.sky.advanceTime?.(e), G?.advanceTime(e), K?.advanceTime(e), q ? q.advanceTime(e) : i.blownSand > 0 && Y.push(e);
754
+ },
755
+ ready: fe,
756
+ parts: {
757
+ preset: L,
758
+ water: G,
759
+ shadows: z,
760
+ grass: K,
761
+ occlusion: R,
762
+ footprints: Z,
763
+ get blownSand() {
764
+ return q;
765
+ }
766
+ },
767
+ dispose() {
768
+ for (let e of A) e.dispose?.();
769
+ for (let e of j.reverse()) e();
770
+ A.length = 0, j.length = 0;
771
+ },
772
+ [Symbol.dispose]() {
773
+ this.dispose();
774
+ }
775
+ };
776
+ }
777
+ //#endregion
778
+ export { L as attach, F as grassCover, N as ground, w as info };