@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.
Files changed (38) hide show
  1. package/LICENSE +201 -201
  2. package/NOTICE +4 -4
  3. package/README.md +620 -387
  4. package/dist/{dune-coast-info-e8eDZXBu.js → dune-coast-info-D9yQIv8G.js} +13 -3
  5. package/dist/dune-coast.d.ts +20 -1
  6. package/dist/dune-coast.js +374 -187
  7. package/dist/errors-fc4i1pSL.js +7 -0
  8. package/dist/fauld-blast.d.ts +119 -21
  9. package/dist/fauld-blast.js +957 -206
  10. package/dist/fauld-countryside.d.ts +1 -1
  11. package/dist/fauld-countryside.js +4 -4
  12. package/dist/fauld-crater.d.ts +1 -1
  13. package/dist/fauld-crater.js +4 -4
  14. package/dist/fauld-dig.d.ts +89 -0
  15. package/dist/fauld-dustfall-fines-grid-MA6XPrq6.js +14 -0
  16. package/dist/fauld-dustfall-fines-grid.d.ts +11 -0
  17. package/dist/fauld-dustfall-grid-Bb4X8b-u.js +14 -0
  18. package/dist/fauld-dustfall-grid.d.ts +11 -0
  19. package/dist/fauld-explosion.d.ts +135 -0
  20. package/dist/fauld-grains.d.ts +27 -0
  21. package/dist/fauld-mud.d.ts +104 -0
  22. package/dist/fauld-surge.d.ts +71 -0
  23. package/dist/fauld-tunnels.d.ts +76 -3
  24. package/dist/fauld-tunnels.js +518 -193
  25. package/dist/fauld-world-CNNSonJF.js +863 -0
  26. package/dist/fauld-world.d.ts +86 -3
  27. package/dist/index.js +2 -2
  28. package/dist/{library-mesh-BRk4Ycnn.js → library-mesh-CjTG-mVZ.js} +97 -74
  29. package/dist/library-parts.d.ts +11 -1
  30. package/dist/library.js +1 -1
  31. package/dist/look-family.d.ts +16 -1
  32. package/dist/look-family.js +35 -12
  33. package/dist/shared/settings.d.ts +89 -89
  34. package/dist/{timber-valley-info-BB6GvcsL.js → timber-valley-info-vVI2nwDs.js} +11 -0
  35. package/dist/timber-valley.d.ts +69 -3
  36. package/dist/timber-valley.js +198 -136
  37. package/package.json +106 -104
  38. package/dist/fauld-world-85dg03jo.js +0 -582
@@ -1,33 +1,91 @@
1
- // @margo/core-built 0.1.0
1
+ // @margo/core-built 1.0.0
2
2
  import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
3
 
4
- import { t as e } from "./dune-coast-info-e8eDZXBu.js";
4
+ import { t as e } from "./dune-coast-info-D9yQIv8G.js";
5
5
  import { PbrMaterial as t } from "@margoengine/core";
6
6
  import { applyMatrix4 as n, toGeometry as r } from "@margoengine/geometry";
7
7
  import { Noise as i } from "@margoengine/procedural/noise";
8
- import { generateLaunchRail as a, generatePlankShed as o } from "@margoengine/procedural/sheds";
9
- import { weatheredWood as s } from "@margoengine/materials/presets";
10
- import { TerrainColors as c, TerrainHeightmap as l, heightfieldGeometry as u } from "@margoengine/terrain";
11
- import { duneField as d, duneHill as f } from "@margoengine/terrain/dunes";
12
- import { DAY_PRESETS as p } from "@margoengine/sky/day-presets";
13
- import { PresetScene as m, SCENE_PRESETS as h } from "@margoengine/sky/scenes";
14
- import { degrees as g, sunPath as _ } from "@margoengine/sky/sun";
15
- import { Water as v } from "@margoengine/water";
16
- import { GrassScatter as y } from "@margoengine/scatter/grass";
17
- import { Shadows as b } from "@margoengine/shadows";
18
- import { GTAO as x } from "@margoengine/post/gtao";
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";
19
24
  //#region src/dune-coast.ts
20
- var S = e, C = 0, w = 900, T = {
25
+ var w = e, ce = 0, T = 900, E = {
21
26
  origin: [-900, -800],
22
27
  size: [2200, 2e3]
23
- };
24
- function E(e) {
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) {
25
83
  if (typeof e != "object" || !e) throw TypeError("dune-coast: pass settings as an object.");
26
84
  let t = {
27
- ...Object.fromEntries(Object.entries(S.settings).map(([e, t]) => [e, t.default])),
85
+ ...Object.fromEntries(Object.entries(w.settings).map(([e, t]) => [e, t.default])),
28
86
  ...e
29
87
  };
30
- for (let [e, n] of Object.entries(S.settings)) {
88
+ for (let [e, n] of Object.entries(w.settings)) {
31
89
  let r = t[e];
32
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]}.`);
33
91
  if (n.options && !n.options.includes(r)) throw RangeError(`dune-coast: unknown ${e}; pass ${n.options.join(" or ")}.`);
@@ -45,7 +103,7 @@ function E(e) {
45
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.");
46
104
  return t;
47
105
  }
48
- function D(e) {
106
+ function ue(e) {
49
107
  let t = Date.parse(e + "T12:00:00Z"), n = Date.UTC(Number(e.slice(0, 4)), 0, 1, 12);
50
108
  return Math.round((t - n) / 864e5) + 1;
51
109
  }
@@ -66,11 +124,11 @@ function k(e) {
66
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;
67
125
  };
68
126
  }
69
- let t = T.size[0] / 2 + 1, n = T.size[1] / 2 + 1, r = ((e.windFrom + 180) % 360 - 90 + 360) % 360, i = d({
127
+ let t = E.size[0] / 2 + 1, n = E.size[1] / 2 + 1, r = ((e.windFrom + 180) % 360 - 90 + 360) % 360, i = g({
70
128
  width: t,
71
129
  depth: n,
72
130
  cellSize: 2,
73
- origin: T.origin,
131
+ origin: E.origin,
74
132
  type: "transverse",
75
133
  height: .8,
76
134
  spacing: 16,
@@ -108,37 +166,72 @@ function k(e) {
108
166
  }
109
167
  ].filter((e) => e.height > 0);
110
168
  return (e, r) => {
111
- let o = (e - T.origin[0]) / 2, s = (r - T.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)), p = (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, m = 0;
112
- for (let t of a) m += f(e, r, t);
113
- let h = 2.5 + p * (1 - O(.5, 4, m)) + m, g = e < w ? (w - e) / 28 : (w - e) / 50, _ = O(730, 830, e), v = 3.2 * Math.exp(-(((e - 785) / 28) ** 2)) * (.8 + .2 * Math.sin(r / 37 + Math.sin(r / 91)));
114
- return (1 - _) * h + _ * g + v;
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;
115
173
  };
116
174
  }
117
- function A(e = {}) {
118
- return k(E(e));
119
- }
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
+ }];
120
184
  function j(e, t) {
121
- let n = t + 1, r = T.size[0] / t, i = T.size[1] / t, a = new Float32Array(n * n);
122
- for (let t = 0; t < n; t++) for (let o = 0; o < n; o++) a[t * n + o] = e(T.origin[0] + o * r, T.origin[1] + t * i);
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);
123
216
  return (e, o) => {
124
- let s = Math.min(t, Math.max(0, (e - T.origin[0]) / r)), c = Math.min(t, Math.max(0, (o - T.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];
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];
125
218
  return (p + (m - p) * d) * (1 - f) + (h + (g - h) * d) * f;
126
219
  };
127
220
  }
128
- function M(e, t) {
221
+ function P(e, t) {
129
222
  let n = new i(e.seed + 7), r = .9 - 1.2 * e.grass;
130
223
  return (i, a) => {
131
224
  let o = t(i, a), s = O(1.2, 2, o) * (1 - O(7, 11, o));
132
225
  if (!(s > 0) || e.grass <= 0) return 0;
133
- 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);
134
- return s * Math.max(.03, .95 * O(l, l + .15, u));
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);
135
228
  };
136
229
  }
137
- function N(e = {}) {
138
- let t = E(e);
139
- return M(t, k(t));
230
+ function F(e = {}) {
231
+ let t = D(e);
232
+ return P(t, k(t));
140
233
  }
141
- function P(e, t, r, i, a = 0) {
234
+ function I(e, t, r, i, a = 0) {
142
235
  let o = Math.cos(a), s = Math.sin(a);
143
236
  return n(e, [
144
237
  o,
@@ -159,42 +252,47 @@ function P(e, t, r, i, a = 0) {
159
252
  1
160
253
  ]);
161
254
  }
162
- function F(e, n = {}) {
163
- let i = E(n), d = i.quality === "film", f = k(i), w = [], A = [], N = _({
164
- latitude: g(i.latitude),
165
- dayOfYear: D(i.date),
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),
166
259
  hour: i.hour
167
- }), F = i.weather === "overcast" ? h.overcast : h.noon, I = m.attach(e, {
260
+ }), F = i.weather === "overcast" ? x.overcast : x.noon, L = ee.attach(e, {
168
261
  ...F,
169
262
  day: {
170
- ...i.weather === "overcast" ? p.overcast : p.noon,
263
+ ...i.weather === "overcast" ? b.overcast : b.noon,
171
264
  azimuth: N.azimuth.degrees,
172
265
  elevation: Math.max(1, N.elevation.degrees),
173
266
  clouds: i.weather === "overcast" ? 1 : .35
174
267
  },
175
268
  fog: 3.912 / i.visibility
176
- });
177
- A.push(() => I.dispose());
178
- let L = i.occlusion > 0 ? new x({
269
+ }, { meter: !0 });
270
+ j.push(() => L.dispose());
271
+ let R = i.occlusion > 0 ? new se({
179
272
  radius: i.occlusion,
180
- slices: d ? 3 : 2,
181
- steps: d ? 8 : 6
273
+ slices: g ? 3 : 2,
274
+ steps: g ? 8 : 6
182
275
  }) : void 0;
183
- L && I.post.addEffect(L, 0);
184
- let R = b.attach(e, {
185
- resolution: d ? 4096 : 2048,
276
+ R && L.post.addEffect(R, 0);
277
+ let z = oe.attach(e, {
278
+ resolution: g ? 4096 : 2048,
186
279
  distance: 220,
187
280
  lambda: .75,
188
281
  lightSize: i.weather === "overcast" ? .08 : .02,
189
282
  normalBias: .06,
190
283
  casterMargin: 80
191
284
  });
192
- A.push(() => R.dispose());
193
- let z = d ? 1023 : 511, B = j(f, z), V = e.createMesh().setGeometry(r(u(B, {
194
- size: T.size,
195
- origin: T.origin,
196
- resolution: z
197
- }))).setMaterial(new t({
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({
198
296
  color: [
199
297
  i.sand[0],
200
298
  i.sand[1],
@@ -202,15 +300,15 @@ function F(e, n = {}) {
202
300
  ],
203
301
  roughness: .92
204
302
  }));
205
- V.name = "dune-coast ground", w.push(V), R.add(V, { static: !0 });
206
- let H = l.attach(e, f, {
207
- origin: [660, T.origin[1]],
208
- size: [400, T.size[1]],
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]],
209
307
  resolution: 512
210
308
  });
211
- A.push(() => H.dispose());
212
- let U;
213
- if (c.attach(e, V, {
309
+ j.push(() => W.dispose());
310
+ let G;
311
+ if (f.attach(e, U, {
214
312
  sand: i.sand,
215
313
  shore: [80, 90],
216
314
  stoneNormal: [.2, .25],
@@ -223,9 +321,9 @@ function F(e, n = {}) {
223
321
  broad: i.sandBands
224
322
  },
225
323
  wetness: {
226
- texture: () => U?.coastalDepthTexture,
227
- origin: [660, T.origin[1]],
228
- size: [400, T.size[1]]
324
+ texture: () => G?.coastalDepthTexture,
325
+ origin: [660, E.origin[1]],
326
+ size: [400, E.size[1]]
229
327
  }
230
328
  }), i.surf > 0) {
231
329
  let t = i.surf / 2, n = (i.windFrom + 180) * Math.PI / 180, r = [Math.sin(n), -Math.cos(n)], a = [
@@ -257,10 +355,25 @@ function F(e, n = {}) {
257
355
  steepness: .35,
258
356
  phase: 1.3
259
357
  }
260
- ];
261
- U = v.attach(e, {
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, {
262
375
  size: [1200, 1200],
263
- segments: d ? 512 : 256,
376
+ segments: g ? 512 : 256,
264
377
  horizon: !0,
265
378
  height: 0,
266
379
  color: [
@@ -272,28 +385,37 @@ function F(e, n = {}) {
272
385
  spray: !0,
273
386
  whitecaps: Math.min(1, i.wind / 18),
274
387
  chop: Math.min(1, i.wind / 16),
275
- depth: () => I.post.depthTexture,
276
- sceneColor: () => I.post.sceneTexture,
277
- reflection: () => I.sky.reflectionTexture,
278
- lights: I.sky.lights,
279
- shadows: R,
388
+ depth: () => L.post.depthTexture,
389
+ sceneColor: () => L.post.sceneTexture,
390
+ reflection: () => L.sky.reflectionTexture,
391
+ lights: L.sky.lights,
392
+ shadows: z,
280
393
  terrain: {
281
- heightmap: () => H.texture,
282
- origin: [660, T.origin[1]],
283
- size: [400, T.size[1]]
394
+ heightmap: () => W.texture,
395
+ origin: [660, E.origin[1]],
396
+ size: [400, E.size[1]]
284
397
  },
285
- waves: a
286
- }), A.push(() => U?.dispose());
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
+ });
287
409
  }
288
- let W;
410
+ let K;
289
411
  if (i.grass > 0) {
290
- let n = z + 1, r = T.size[0] / z, a = T.size[1] / z, o = [T.origin[0] - r / 2, T.origin[1] - a / 2], s = [T.size[0] + r, T.size[1] + a], c = {
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 = {
291
413
  origin: o,
292
414
  size: s,
293
415
  resolution: n
294
- }, u = l.attach(e, B, c), f = l.attach(e, M(i, B), c), p = (i.windFrom + 180) * Math.PI / 180;
295
- A.push(() => u.dispose(), () => f.dispose()), W = y.attach(e, {
296
- count: d ? 24e4 : 8e4,
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,
297
419
  area: [480, 480],
298
420
  follow: !0,
299
421
  bounds: [
@@ -302,8 +424,8 @@ function F(e, n = {}) {
302
424
  o[0] + s[0],
303
425
  o[1] + s[1]
304
426
  ],
305
- heightmap: () => u.texture,
306
- densityMap: () => f.texture,
427
+ heightmap: () => l.texture,
428
+ densityMap: () => u.texture,
307
429
  maxSlope: 32,
308
430
  scale: [.7, 1.25],
309
431
  lod: [
@@ -340,75 +462,99 @@ function F(e, n = {}) {
340
462
  doubleSided: !0
341
463
  }),
342
464
  wind: [
343
- Math.sin(p),
344
- -Math.cos(p),
465
+ Math.sin(d),
466
+ -Math.cos(d),
345
467
  Math.min(1, i.wind / 15)
346
468
  ],
347
469
  sink: .04,
348
470
  seed: i.seed
349
- }), A.push(() => W?.dispose());
471
+ }), j.push(() => K?.dispose());
350
472
  }
351
- let G, K = !1, q = Promise.resolve(), J = [], Y = `dune-coast-clock:${C++}`;
473
+ let q, J = !1, fe = Promise.resolve(), Y = [], X = `dune-coast-clock:${ce++}`;
352
474
  if (i.blownSand > 0) {
353
- let t = i.grass > 0 ? M(i, B) : () => 0, n = (i.windFrom + 180) * Math.PI / 180, r = {
354
- ground: B,
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,
355
477
  wind: {
356
478
  speed: i.wind,
357
479
  direction: Math.atan2(Math.sin(n), -Math.cos(n)),
358
480
  gust: .35
359
481
  },
360
- mask: (e, n) => O(1.2, 2.2, B(e, n)) * (1 - t(e, n)),
482
+ mask: (e, n) => O(1.2, 2.2, V(e, n)) * (1 - t(e, n)),
361
483
  amount: i.blownSand,
362
484
  color: i.sand,
363
485
  fog: 3.912 / i.visibility,
364
- depth: () => I.post.depthTexture,
486
+ depth: () => L.post.depthTexture,
365
487
  softness: .2,
366
- sky: I.sky,
488
+ sky: L.sky,
367
489
  seed: i.seed
368
- }, a = {coreRequirement:/*@__PURE__*/__margoCoreRequirement("0.1.0",import.meta.url),
369
- name: Y,
490
+ }, a = {coreRequirement:/*@__PURE__*/__margoCoreRequirement("1.0.0",import.meta.url),
491
+ name: X,
370
492
  setup() {},
371
- onPreUpdate: (e) => J.push(e)
372
- }, o = () => e.sceneOf(a)?.removePlugin(Y);
373
- e.use(a), q = import("@margoengine/vfx/blown-sand").then(({ BlownSand: t }) => {
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 }) => {
374
496
  let n = e.sceneOf(a);
375
- if (K || !n) return;
376
- n.removePlugin(Y);
497
+ if (J || !n) return;
498
+ n.removePlugin(X);
377
499
  let i = new t(r);
378
500
  n.use(i);
379
- for (let e of J) i.advanceTime(e);
380
- J.length = 0, G = i;
501
+ for (let e of Y) i.advanceTime(e);
502
+ Y.length = 0, q = i;
381
503
  }, (e) => {
382
- throw K || o(), e;
383
- }), A.push(() => {
384
- K = !0, G ? G.dispose() : o();
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
+ }
385
522
  });
523
+ let t = Z;
524
+ j.push(() => t.dispose()), le.forEach((e, n) => t.walk(e, { seed: i.seed + n }));
386
525
  }
387
526
  if (i.camp) {
388
- let n = new t({
389
- color: [
390
- i.boards[0],
391
- i.boards[1],
392
- i.boards[2]
393
- ],
394
- roughness: s.roughness,
395
- metalness: s.metalness
396
- }), c = new t({
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({
397
531
  color: [
398
- i.roof[0],
399
- i.roof[1],
400
- i.roof[2]
532
+ e[0],
533
+ e[1],
534
+ e[2]
401
535
  ],
402
- roughness: s.roughness,
403
- metalness: s.metalness
404
- }), l = (e) => e === "trim" ? u : e === "roof" ? c : n, u = new t({
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({
405
544
  color: [
406
- .2,
407
- .17,
408
- .13
545
+ 1,
546
+ 1,
547
+ 1
409
548
  ],
410
- roughness: .9
411
- }), d = new t({
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({
412
558
  color: [
413
559
  .35,
414
560
  .34,
@@ -416,17 +562,43 @@ function F(e, n = {}) {
416
562
  ],
417
563
  roughness: .6,
418
564
  metalness: .8
419
- }), p = (t, n, i) => {
420
- let a = e.createMesh().setGeometry(r(t)).setMaterial(n);
421
- a.name = i, w.push(a), R.add(a, { static: !0 });
422
- }, m = (e, t) => i.shedWindows ? t.map((t) => ({
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) => ({
423
595
  wall: e,
424
596
  at: t,
425
597
  width: .8,
426
598
  height: .7,
427
599
  bottom: 1,
428
600
  leaf: "none"
429
- })) : [], h = o({
601
+ })) : [], b = o({
430
602
  overhang: i.shedOverhang,
431
603
  weathering: i.shedWeathering,
432
604
  openings: [
@@ -436,11 +608,11 @@ function F(e, n = {}) {
436
608
  height: 2.1,
437
609
  leaf: "awning"
438
610
  },
439
- ...m("back", [-3.5, 3.5]),
440
- ...m("left", [0])
611
+ ...y("back", [-3.5, 3.5]),
612
+ ...y("left", [0])
441
613
  ],
442
614
  seed: 3
443
- }), g = o({
615
+ }), ee = o({
444
616
  overhang: i.shedOverhang,
445
617
  weathering: i.shedWeathering,
446
618
  length: 7.6,
@@ -465,42 +637,56 @@ function F(e, n = {}) {
465
637
  bottom: 1,
466
638
  leaf: "none"
467
639
  },
468
- ...m("left", [0])
640
+ ...y("left", [0])
469
641
  ],
470
642
  seed: 4
471
- }), _ = -88.5, v = (e, t) => f(e, t) - .05;
472
- for (let [e, t] of Object.entries(h.parts)) p(P(t, -70, v(-70, 30), 30, Math.PI), l(e), `hangar ${e}`);
473
- for (let [e, t] of Object.entries(g.parts)) p(P(t, _, v(_, 30), 30, Math.PI), l(e), `shed ${e}`);
474
- let y = a({ ground: (e) => f(0, -e) });
475
- p(P(y.parts.wood, 0, 0, 0, Math.PI / 2), n, "rail"), y.parts.metal && p(P(y.parts.metal, 0, 0, 0, Math.PI / 2), d, "rail strip");
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");
476
662
  }
477
- let X = (e, t, n) => [
663
+ let Q = (e, t, n) => [
478
664
  e,
479
- f(e, t) + n,
665
+ k(e, t) + n,
480
666
  t
481
- ], Z = {
667
+ ], $ = {
482
668
  rail: {
483
- position: X(6, 4, 1.6),
484
- target: X(0, -18, .3),
669
+ position: Q(6, 4, 1.6),
670
+ target: Q(0, -18, .3),
485
671
  about: "the launch rail, its south end at the origin"
486
672
  },
487
673
  camp: {
488
- position: X(-60, -25, 1.7),
489
- target: X(-78, 30, 2),
674
+ position: Q(-60, -25, 1.7),
675
+ target: Q(-78, 30, 2),
490
676
  about: "the hangar and the shed, seen from the north"
491
677
  },
492
678
  flightLine: {
493
- position: X(0, -18.3, 1.5),
494
- target: X(0, -60, 1.5),
679
+ position: Q(0, -18.3, 1.5),
680
+ target: Q(0, -60, 1.5),
495
681
  about: "north along the first flight, 120 ft"
496
682
  },
497
683
  bigHill: {
498
- position: X(-40, 430, 1.7),
499
- target: X(-40, -50, 2),
684
+ position: Q(-40, 430, 1.7),
685
+ target: Q(-40, -50, 2),
500
686
  about: "the big dune crest, looking back at the camp"
501
687
  },
502
688
  beach: {
503
- position: X(780, 0, 1.7),
689
+ position: Q(780, 0, 1.7),
504
690
  target: [
505
691
  1100,
506
692
  1,
@@ -509,37 +695,37 @@ function F(e, n = {}) {
509
695
  about: "the foredune crest over the surf"
510
696
  },
511
697
  "first-flight": {
512
- position: X(14, -14, 1.3),
513
- target: X(-60, -40, .4),
698
+ position: Q(14, -14, 1.3),
699
+ target: Q(-60, -40, .4),
514
700
  about: "LC-W861-35, the first flight launch, looking west"
515
701
  },
516
702
  "camp-buildings": {
517
- position: X(-40, -12, 1.6),
518
- target: X(-80, 30, 1.6),
703
+ position: Q(-40, -12, 1.6),
704
+ target: Q(-80, 30, 1.6),
519
705
  about: "LC-W86-15, the camp from the north-east"
520
706
  },
521
707
  "killdevil-from-flat": {
522
- position: X(10, -60, 1.6),
523
- target: X(-40, 430, 14),
708
+ position: Q(10, -60, 1.6),
709
+ target: Q(-40, 430, 14),
524
710
  about: "LC-W86-120, the big dune across the flat"
525
711
  },
526
712
  "flyer-on-rail": {
527
- position: X(-75, 300, 1.6),
528
- target: X(-25, 330, 1),
713
+ position: Q(-75, 300, 1.6),
714
+ target: Q(-25, 330, 1),
529
715
  about: "LC-W86-21, on the windward slope, the slope rising right"
530
716
  },
531
717
  "killdevil-back": {
532
- position: X(-40, 640, 1.6),
533
- target: X(-40, 430, 10),
718
+ position: Q(-40, 640, 1.6),
719
+ target: Q(-40, 430, 10),
534
720
  about: "LC-W85-110, the lee side of the big dune"
535
721
  },
536
722
  "landing-rail-view": {
537
- position: X(-4, -48, 1.2),
538
- target: X(0, 0, .2),
723
+ position: Q(-4, -48, 1.2),
724
+ target: Q(0, 0, .2),
539
725
  about: "LC-W86-38, back south along the flight line"
540
726
  },
541
727
  surf: {
542
- position: X(860, -30, 1.7),
728
+ position: Q(860, -30, 1.7),
543
729
  target: [
544
730
  960,
545
731
  .5,
@@ -548,39 +734,40 @@ function F(e, n = {}) {
548
734
  about: "the beach and the surf, looking east"
549
735
  },
550
736
  crest: {
551
- position: X(-75, 424, 1.6),
552
- target: X(-30, 432, .5),
737
+ position: Q(-75, 424, 1.6),
738
+ target: Q(-30, 432, .5),
553
739
  about: "the big dune crest seen side on, the wind blowing across the view from left to right"
554
740
  }
555
741
  };
556
742
  return {
557
743
  settings: i,
558
- height: f,
559
- anchors: Z,
560
- views: S.views,
744
+ height: k,
745
+ anchors: $,
746
+ views: w.views,
561
747
  view(t, n = 50) {
562
- let r = Z[t];
563
- if (!r) throw RangeError(`dune-coast: no anchor ${t}; pass one of ${Object.keys(Z).join(", ")}.`);
748
+ let r = $[t];
749
+ if (!r) throw RangeError(`dune-coast: no anchor ${t}; pass one of ${Object.keys($).join(", ")}.`);
564
750
  e.camera.position = [...r.position], e.camera.target = [...r.target], e.camera.fov = n;
565
751
  },
566
752
  advanceTime(e) {
567
- I.sky.advanceTime?.(e), U?.advanceTime(e), W?.advanceTime(e), G ? G.advanceTime(e) : i.blownSand > 0 && J.push(e);
753
+ L.sky.advanceTime?.(e), G?.advanceTime(e), K?.advanceTime(e), q ? q.advanceTime(e) : i.blownSand > 0 && Y.push(e);
568
754
  },
569
- ready: q,
755
+ ready: fe,
570
756
  parts: {
571
- preset: I,
572
- water: U,
573
- shadows: R,
574
- grass: W,
575
- occlusion: L,
757
+ preset: L,
758
+ water: G,
759
+ shadows: z,
760
+ grass: K,
761
+ occlusion: R,
762
+ footprints: Z,
576
763
  get blownSand() {
577
- return G;
764
+ return q;
578
765
  }
579
766
  },
580
767
  dispose() {
581
- for (let e of w) e.dispose?.();
582
- for (let e of A.reverse()) e();
583
- w.length = 0, A.length = 0;
768
+ for (let e of A) e.dispose?.();
769
+ for (let e of j.reverse()) e();
770
+ A.length = 0, j.length = 0;
584
771
  },
585
772
  [Symbol.dispose]() {
586
773
  this.dispose();
@@ -588,4 +775,4 @@ function F(e, n = {}) {
588
775
  };
589
776
  }
590
777
  //#endregion
591
- export { F as attach, N as grassCover, A as ground, S as info };
778
+ export { L as attach, F as grassCover, N as ground, w as info };