@margoengine/vfx 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/LICENSE +201 -201
  2. package/NOTICE +4 -4
  3. package/README.md +2241 -1642
  4. package/dist/{base-C9upJytz.js → base-LGs65K7K.js} +174 -123
  5. package/dist/base.d.ts +104 -2
  6. package/dist/base.js +1 -1
  7. package/dist/blown-sand.js +3 -3
  8. package/dist/clouds.d.ts +12 -4
  9. package/dist/clouds.js +35 -18
  10. package/dist/compat-BFjXAQuu.js +14 -0
  11. package/dist/debris.d.ts +43 -0
  12. package/dist/debris.js +33 -1
  13. package/dist/dust-current.d.ts +66 -0
  14. package/dist/dust-current.js +92 -0
  15. package/dist/fire-front.d.ts +72 -1
  16. package/dist/fire-front.js +309 -69
  17. package/dist/fire.d.ts +24 -3
  18. package/dist/fire.js +114 -93
  19. package/dist/flame.d.ts +171 -3
  20. package/dist/flame.js +343 -131
  21. package/dist/flocking-shaders.d.ts +48 -0
  22. package/dist/flocking-sim.d.ts +623 -0
  23. package/dist/flocking.d.ts +145 -0
  24. package/dist/flocking.js +1846 -0
  25. package/dist/gunfire.d.ts +52 -6
  26. package/dist/gunfire.js +108 -98
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +5 -5
  29. package/dist/json.js +2 -0
  30. package/dist/lit-Dx2tNwP-.js +152 -0
  31. package/dist/lit.d.ts +8 -1
  32. package/dist/lit.js +1 -105
  33. package/dist/mesh.d.ts +2 -0
  34. package/dist/mesh.js +92 -69
  35. package/dist/over-life.js +16 -15
  36. package/dist/reactive-mask-B8xbyzlk.js +69 -0
  37. package/dist/ribbons.d.ts +4 -2
  38. package/dist/ribbons.js +87 -73
  39. package/dist/settings.js +1 -1
  40. package/dist/shader.d.ts +5 -0
  41. package/dist/shared/fog.d.ts +33 -33
  42. package/dist/shared/pass.d.ts +53 -53
  43. package/dist/shared/settings.d.ts +89 -89
  44. package/dist/smoke.d.ts +72 -4
  45. package/dist/smoke.js +280 -56
  46. package/package.json +200 -192
package/dist/smoke.js CHANGED
@@ -1,6 +1,6 @@
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
- const e=(engine,version="0.1.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
3
+ const e=(engine,version="1.0.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
4
4
  import { engineRuntime as __margoRuntime } from "@margoengine/core/extension";
5
5
  import { finiteVector as t } from "@margoengine/math/validate";
6
6
  import { VFX as n } from "@margoengine/vfx/base";
@@ -10,10 +10,11 @@ import { overLife as a } from "@margoengine/vfx/over-life";
10
10
  import { schedule as o } from "@margoengine/vfx/schedule";
11
11
  import { lit as s } from "@margoengine/vfx/lit";
12
12
  import { nodes as c } from "@margoengine/vfx/nodes";
13
- import { textureFeature as l } from "@margoengine/vfx/texture";
13
+ import { obstacles as l } from "@margoengine/vfx/obstacles";
14
+ import { textureFeature as u } from "@margoengine/vfx/texture";
14
15
  //#region src/smoke.ts
15
- var u = .093, d = .5, f = 1.6, p = 5, m = 2.9, h = 9.81, g = 1.225, _ = 1005, v = 32, y = 1, b = .3;
16
- function x(e) {
16
+ var d = 4, f = .093, p = .5, m = 1.6, h = 5, g = 2.9, _ = 9.81, v = 1.225, y = 1005, b = 1e5, x = .35, S = .5, C = 32, w = 1, T = .3;
17
+ function E(e) {
17
18
  let t = [], n = [
18
19
  1,
19
20
  1,
@@ -22,40 +23,172 @@ function x(e) {
22
23
  .5,
23
24
  0
24
25
  ];
25
- for (let r = 0; r < v; r++) {
26
+ for (let r = 0; r < C; r++) {
26
27
  let i = r / 31, a = i * 5, o = Math.min(4, Math.floor(a)), s = n[o] + (n[o + 1] - n[o]) * (a - o);
27
28
  t.push(Math.max(0, Math.min(1, Math.min(1, i * e / 1) * s)));
28
29
  }
29
30
  return t[0] = Math.max(0, 1 - 1 / (e / 31)), t;
30
31
  }
31
- function S(e, t = 288.15) {
32
+ function D(e, t = 288.15) {
32
33
  if (!(e >= 0 && Number.isFinite(e))) throw RangeError("Smoke heat must be a finite number of watts, 0 or more");
33
34
  if (!(t > 0 && Number.isFinite(t))) throw RangeError("Smoke airTemperature must be a finite temperature above 0 K");
34
- return h * e / (Math.PI * g * _ * t);
35
+ return _ * e / (Math.PI * v * y * t);
35
36
  }
36
- function C(e, t = 288.15) {
37
+ function O(e, t = 288.15) {
37
38
  if (!Number.isFinite(e) || e < 0) throw RangeError("Smoke lapse must be a finite rise of 0 or more kelvin a metre");
38
- return h / t * e;
39
+ return _ / t * e;
39
40
  }
40
- function w(e, t, n, r, i = 0, a) {
41
- let o = u, s = Math.cbrt(25 * t / (48 * o * o)), c = r / (1.2 * o), l = Math.max(0, e), p = l > 0 ? (4 / 3 * s * l + c ** (4 / 3)) ** .75 : c, h = p - c, g = s / Math.cbrt(p), _ = a ?? {
41
+ function k(e, t, n, r, i = 0, a) {
42
+ let o = f, s = Math.cbrt(25 * t / (48 * o * o)), c = r / (1.2 * o), l = Math.max(0, e), u = l > 0 ? (4 / 3 * s * l + c ** (4 / 3)) ** .75 : c, d = u - c, h = s / Math.cbrt(u), _ = a ?? {
42
43
  rise: 0,
43
44
  speed: 0,
44
45
  radius: 0,
45
46
  bent: !1,
46
47
  level: !1
47
48
  };
48
- if (_.rise = h, _.speed = g, _.radius = 1.2 * o * p, _.bent = !1, _.level = !1, n > 1e-6) {
49
- let e = f * Math.cbrt(t / n), i = r / d, a = (i / e) ** 1.5, o = e * (l + a) ** (2 / 3) - i, s = 2 / 3 * e / Math.cbrt(l + a);
50
- (l > 0 ? o < h : s < g) && (_.rise = o, _.speed = s, _.radius = d * (o + i), _.bent = !0);
49
+ if (_.rise = d, _.speed = h, _.radius = 1.2 * o * u, _.bent = !1, _.level = !1, n > 1e-6) {
50
+ let e = m * Math.cbrt(t / n), i = r / p, a = (i / e) ** 1.5, o = e * (l + a) ** (2 / 3) - i, s = 2 / 3 * e / Math.cbrt(l + a);
51
+ (l > 0 ? o < d : s < h) && (_.rise = o, _.speed = s, _.radius = p * (o + i), _.bent = !0);
51
52
  }
52
53
  if (i > 0) {
53
- let e = n > 1e-6 ? Math.min(m * Math.cbrt(t / (n * i)), 5 * t ** .25 * i ** -.375) : 5 * t ** .25 * i ** -.375;
54
+ let e = n > 1e-6 ? Math.min(g * Math.cbrt(t / (n * i)), 5 * t ** .25 * i ** -.375) : 5 * t ** .25 * i ** -.375;
54
55
  _.rise >= e && (_.rise = e, _.speed = 0, _.level = !0);
55
56
  }
56
57
  return _;
57
58
  }
58
- var T = (e) => e?.particles.flames?.options ?? e?.flame?.options, E = (e, t, n) => {
59
+ function A(e, t, n = t) {
60
+ if (!(e >= 0 && Number.isFinite(e))) throw RangeError("Smoke heat must be a finite number of watts, 0 or more");
61
+ if (!(t > 0 && Number.isFinite(t))) throw RangeError("Smoke ceiling height must be a finite number of metres above 0");
62
+ if (!(n >= 0 && Number.isFinite(n))) throw RangeError("Smoke ceiling distance must be a finite number of metres, 0 or more");
63
+ let r = e / 1e3;
64
+ return n <= .15 * t ? .96 * Math.cbrt(r / t) : .195 * Math.cbrt(r) * Math.sqrt(t) / n ** (5 / 6);
65
+ }
66
+ function j(e, t, n) {
67
+ let r = 1.2 * f, i = Math.max(0, (e - t) / 1.1116);
68
+ return {
69
+ rise: i,
70
+ radius: Math.min(n, t + r * i)
71
+ };
72
+ }
73
+ var M = () => ({
74
+ kind: "box",
75
+ center: [
76
+ 0,
77
+ 0,
78
+ 0
79
+ ],
80
+ halfSize: [
81
+ b,
82
+ b,
83
+ b
84
+ ]
85
+ }), N = (e) => [
86
+ {
87
+ op: "attribute",
88
+ value: "position"
89
+ },
90
+ {
91
+ op: "const",
92
+ value: e.from
93
+ },
94
+ {
95
+ op: "add",
96
+ inputs: [4, 5]
97
+ },
98
+ {
99
+ op: "attribute",
100
+ value: "age"
101
+ },
102
+ e.arrive,
103
+ {
104
+ op: "add",
105
+ inputs: [7, 8]
106
+ },
107
+ {
108
+ op: "const",
109
+ value: 1 / S
110
+ },
111
+ {
112
+ op: "mul",
113
+ inputs: [9, 10]
114
+ },
115
+ {
116
+ op: "const",
117
+ value: 0
118
+ },
119
+ {
120
+ op: "max",
121
+ inputs: [11, 12]
122
+ },
123
+ {
124
+ op: "const",
125
+ value: 1
126
+ },
127
+ {
128
+ op: "min",
129
+ inputs: [13, 14]
130
+ },
131
+ {
132
+ op: "const",
133
+ value: e.spread
134
+ },
135
+ {
136
+ op: "mul",
137
+ inputs: [6, 16]
138
+ },
139
+ {
140
+ op: "normalize",
141
+ inputs: [17]
142
+ },
143
+ {
144
+ op: "const",
145
+ value: e.push
146
+ },
147
+ {
148
+ op: "mul",
149
+ inputs: [18, 19]
150
+ },
151
+ {
152
+ op: "const",
153
+ value: [
154
+ 0,
155
+ -4,
156
+ 0
157
+ ]
158
+ },
159
+ {
160
+ op: "mul",
161
+ inputs: [0, 21]
162
+ },
163
+ {
164
+ op: "add",
165
+ inputs: [20, 22]
166
+ },
167
+ {
168
+ op: "const",
169
+ value: [
170
+ 0,
171
+ -4,
172
+ 0
173
+ ]
174
+ },
175
+ {
176
+ op: "mul",
177
+ inputs: [6, 24]
178
+ },
179
+ {
180
+ op: "add",
181
+ inputs: [23, 25]
182
+ },
183
+ {
184
+ op: "mul",
185
+ inputs: [26, 15]
186
+ },
187
+ {
188
+ op: "force",
189
+ inputs: [27]
190
+ }
191
+ ], P = (e) => e?.particles.flames?.options ?? e?.flame?.options, F = (e, t, n) => {
59
192
  if (!e) return 0;
60
193
  if (typeof e == "object" && "sample" in e) {
61
194
  let r = e.sample(t[0], t[1], t[2], n);
@@ -63,12 +196,12 @@ var T = (e) => e?.particles.flames?.options ?? e?.flame?.options, E = (e, t, n)
63
196
  }
64
197
  let r = e;
65
198
  return Math.hypot(r[0], r[1]);
66
- }, D = (e, t, n, r, i = !1) => {
199
+ }, I = (e, t, n, r, i = !1) => {
67
200
  if (!(Number.isFinite(e) && (i ? e > n : e >= n) && e <= r)) throw RangeError(`Smoke ${t} is ${e}; pass a finite number ${i ? "above" : "from"} ${n} ${i ? "and at most" : "to"} ${r}`);
68
201
  return e;
69
- }, O = 0, k = class u {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url);
202
+ }, L = 0, R = class p {coreRequirement=__margoCoreRequirement("1.0.0",import.meta.url);
70
203
  constructor(e, t) {
71
- this.name = "vfx-smoke:" + O++, this.disposed = !1, this.clock = 0, this.speed = Array(v).fill(1), this.size = Array(v).fill(1), this.point = {
204
+ this.name = "vfx-smoke:" + L++, this.disposed = !1, this.clock = 0, this.speed = Array(C).fill(1), this.size = Array(C).fill(1), this.point = {
72
205
  rise: 0,
73
206
  speed: 0,
74
207
  radius: 0,
@@ -79,6 +212,8 @@ var T = (e) => e?.particles.flames?.options ?? e?.flame?.options, E = (e, t, n)
79
212
  NaN,
80
213
  NaN,
81
214
  NaN,
215
+ NaN,
216
+ NaN,
82
217
  NaN
83
218
  ], this.velocity = [
84
219
  0,
@@ -106,18 +241,41 @@ var T = (e) => e?.particles.flames?.options ?? e?.flame?.options, E = (e, t, n)
106
241
  0,
107
242
  0
108
243
  ];
109
- let u = t.fire;
110
- if (u && !u.particles?.flames && !u.flame?.options) throw TypeError("Invalid Smoke fire; pass a Fire from @margoengine/vfx/fire");
111
- if (this.options = t, this.lifetime = D(t.lifetime ?? 60, "lifetime", 0, 3600, !0), t.prewarm !== void 0 && typeof t.prewarm != "boolean") throw TypeError("Smoke prewarm must be true or false");
112
- let d = D(t.rate ?? 20, "rate", 0, 1e5, !0);
113
- this.capacity = Math.max(64, Math.ceil(d * this.lifetime * 1.05) + 16), this.lit = {
244
+ let d = t.fire;
245
+ if (d && !d.particles?.flames && !d.flame?.options) throw TypeError("Invalid Smoke fire; pass a Fire from @margoengine/vfx/fire");
246
+ if (this.options = t, t.gallery !== void 0 && t.ceiling === void 0) throw TypeError("Smoke gallery needs a ceiling; pass the roof as ceiling with the walls");
247
+ if (this.roof = t.ceiling === void 0 ? void 0 : {
248
+ box: M(),
249
+ walls: t.gallery === void 0 ? void 0 : [M(), M()],
250
+ spread: [
251
+ 1,
252
+ 0,
253
+ 1
254
+ ],
255
+ from: [
256
+ 0,
257
+ 0,
258
+ 0
259
+ ],
260
+ arrive: {
261
+ op: "const",
262
+ value: 0
263
+ },
264
+ push: [
265
+ 0,
266
+ 0,
267
+ 0
268
+ ]
269
+ }, this.lifetime = I(t.lifetime ?? 60, "lifetime", 0, 3600, !0), t.prewarm !== void 0 && typeof t.prewarm != "boolean" && !(typeof t.prewarm == "number" && t.prewarm >= 0 && Number.isFinite(t.prewarm))) throw TypeError("Smoke prewarm must be true, false or the seconds the source has burned (0 or more)");
270
+ let f = I(t.rate ?? 20, "rate", 0, 1e5, !0);
271
+ this.capacity = Math.max(64, Math.ceil(f * this.lifetime * 1.05) + 16), this.lit = {
114
272
  wrap: .6,
115
273
  ...t.lights ? { lights: t.lights } : {},
116
274
  ...t.shadows ? { shadows: t.shadows } : {}
117
275
  }, this.check(), this.write();
118
- let f = {
276
+ let p = {
119
277
  capacity: this.capacity,
120
- rate: d,
278
+ rate: f,
121
279
  position: [...this.at],
122
280
  velocity: [...this.velocity],
123
281
  spread: 0,
@@ -136,7 +294,7 @@ var T = (e) => e?.particles.flames?.options ?? e?.flame?.options, E = (e, t, n)
136
294
  angularVelocity: .05,
137
295
  ...t.wind ? { wind: t.wind } : {},
138
296
  ...t.texture ? { texture: t.texture } : {},
139
- curves: { alpha: x(this.lifetime) },
297
+ curves: { alpha: E(this.lifetime) },
140
298
  overLife: {
141
299
  speed: this.speed,
142
300
  size: this.size
@@ -147,9 +305,13 @@ var T = (e) => e?.particles.flames?.options ?? e?.flame?.options, E = (e, t, n)
147
305
  depth: t.depth
148
306
  } : {},
149
307
  ...t.prewarm ?? !0 ? { schedule: {
150
- prewarm: this.lifetime,
308
+ prewarm: typeof t.prewarm == "number" ? Math.min(t.prewarm, this.lifetime) : this.lifetime,
151
309
  step: Math.max(.1, this.lifetime / 600)
152
310
  } } : {},
311
+ ...this.roof ? {
312
+ obstacles: [this.roof.box, ...this.roof.walls ?? []],
313
+ bounce: 0
314
+ } : {},
153
315
  nodes: { graph: [
154
316
  {
155
317
  op: "attribute",
@@ -166,17 +328,19 @@ var T = (e) => e?.particles.flames?.options ?? e?.flame?.options, E = (e, t, n)
166
328
  {
167
329
  op: "force",
168
330
  inputs: [2]
169
- }
331
+ },
332
+ ...this.roof ? N(this.roof) : []
170
333
  ] }
171
334
  };
172
- this.ownWind = t.wind, this.calm(f.wind ?? T(u)?.wind), this.effect = n.attach(e, f, {
335
+ this.ownWind = t.wind, this.calm(p.wind ?? P(d)?.wind), this.effect = n.attach(e, p, {
173
336
  curves: r,
174
337
  soft: i,
175
338
  lit: s,
176
339
  overLife: a,
177
340
  schedule: o,
178
- texture: l,
179
- nodes: c
341
+ texture: u,
342
+ nodes: c,
343
+ ...this.roof ? { obstacles: l } : {}
180
344
  });
181
345
  }
182
346
  calm(e) {
@@ -194,43 +358,103 @@ var T = (e) => e?.particles.flames?.options ?? e?.flame?.options, E = (e, t, n)
194
358
  return this.options.radius ?? (this.options.fire ? .3 : 2);
195
359
  }
196
360
  check() {
197
- let e = this.options, n = e.position ?? T(e.fire)?.position;
361
+ let e = this.options, n = e.position ?? P(e.fire)?.position;
198
362
  if (!n) throw TypeError("Smoke needs a position [x, y, z] or a fire");
199
- t(n, 3, "Smoke position"), this.at[0] = n[0], this.at[1] = n[1], this.at[2] = n[2], S(this.heat(), e.airTemperature);
200
- let r = D(this.radius(), "radius", 0, 1e4, !0);
201
- D(e.stability ?? 0, "stability", 0, 1), D(e.rate ?? 20, "rate", 0, 1e5, !0), D(e.turbulence ?? .4, "turbulence", 0, 1e3);
202
- let i = D(e.opacity ?? .5, "opacity", 0, 1), a = e.color ?? [
363
+ t(n, 3, "Smoke position"), this.at[0] = n[0], this.at[1] = n[1], this.at[2] = n[2], D(this.heat(), e.airTemperature);
364
+ let r = I(this.radius(), "radius", 0, 1e4, !0);
365
+ if (I(e.stability ?? 0, "stability", 0, 1), this.roof) this.placeRoof(this.roof, r);
366
+ else if (e.ceiling !== void 0) throw TypeError("Smoke ceiling is chosen at attach; attach the smoke with a ceiling to move it later");
367
+ if (e.gallery !== void 0 && !this.roof?.walls) throw TypeError("Smoke gallery is chosen at attach; attach the smoke with a gallery to move it later");
368
+ I(e.rate ?? 20, "rate", 0, 1e5, !0), I(e.turbulence ?? .4, "turbulence", 0, 1e3);
369
+ let i = I(e.opacity ?? .5, "opacity", 0, 1), a = e.color ?? [
203
370
  .3,
204
371
  .29,
205
372
  .28
206
373
  ];
207
374
  t(a, 3, "Smoke color");
208
- for (let e = 0; e < 3; e++) this.rgba[e] = D(a[e], "color channel", 0, 1);
209
- this.rgba[3] = i, this.extent[0] = this.extent[2] = r * .7;
210
- let o = D(e.glow ?? 1, "glow", 0, 10);
375
+ for (let e = 0; e < 3; e++) this.rgba[e] = I(a[e], "color channel", 0, 1);
376
+ if (this.rgba[3] = i, this.extent[0] = this.extent[2] = r * .7, this.roof?.walls) {
377
+ let t = e.gallery?.axis === "x" ? 0 : 2, n = j(this.roof.box.center[1] - b - this.at[1], r, this.halfWidth());
378
+ this.extent[t] = Math.max(this.extent[t], n.radius);
379
+ }
380
+ let o = I(e.glow ?? 1, "glow", 0, 10);
211
381
  if (o > 0) {
212
382
  this.glowAt[0] = this.at[0], this.glowAt[1] = this.at[1], this.glowAt[2] = this.at[2];
213
383
  let e = this.lit.glow ??= {
214
384
  position: this.glowAt,
215
385
  power: 0
216
386
  };
217
- e.position = this.glowAt, e.power = o * b / .7 * this.heat(), e.radius = Math.max(r, .01);
387
+ e.position = this.glowAt, e.power = o * T / .7 * this.heat(), e.radius = Math.max(r, .01);
218
388
  } else delete this.lit.glow;
389
+ if (e.noon === void 0 ? delete this.lit.noon : this.lit.noon = I(e.noon, "noon", 0, 1e7, !0), e.air === void 0) delete this.lit.air;
390
+ else {
391
+ t(e.air, 3, "Smoke air");
392
+ for (let t = 0; t < 3; t++) I(e.air[t], "air channel", 0, 1e3);
393
+ this.lit.air = [
394
+ e.air[0],
395
+ e.air[1],
396
+ e.air[2]
397
+ ];
398
+ }
399
+ if (e.airReflectance === void 0) delete this.lit.airReflectance;
400
+ else {
401
+ t(e.airReflectance, 3, "Smoke airReflectance");
402
+ for (let t = 0; t < 3; t++) I(e.airReflectance[t], "airReflectance channel", 0, 1);
403
+ this.lit.airReflectance = [
404
+ e.airReflectance[0],
405
+ e.airReflectance[1],
406
+ e.airReflectance[2]
407
+ ];
408
+ }
409
+ e.ground === void 0 ? delete this.lit.ground : this.lit.ground = I(e.ground, "ground", 0, 1);
410
+ }
411
+ placeRoof(e, t) {
412
+ let n = this.options.ceiling;
413
+ if (typeof n != "number" || !Number.isFinite(n)) throw RangeError(`Smoke ceiling is ${n}; pass the roof's world height, a finite number of metres`);
414
+ let r = n - this.at[1], i = this.placeWalls(e), a = j(r, t, i), o = f, s = Math.cbrt(25 * D(this.heat(), this.options.airTemperature) / (48 * o * o)), c = t / (1.2 * o);
415
+ e.box.center[0] = this.at[0], e.box.center[1] = n + b, e.box.center[2] = this.at[2], e.from[0] = -this.at[0], e.from[1] = -(n - a.radius), e.from[2] = -this.at[2], e.arrive.value = s > 0 ? -(((c + a.rise) ** (4 / 3) - c ** (4 / 3)) * 3) / (4 * s) : -3600;
416
+ let l = Math.max(r, t), u = i === Infinity ? l : Math.max(i, t);
417
+ e.push[0] = e.push[2] = d * A(this.heat() / .7, l, u);
418
+ }
419
+ placeWalls(e) {
420
+ if (!e.walls) return Infinity;
421
+ let t = this.options.gallery?.axis, n = this.options.gallery?.walls;
422
+ if (t !== "x" && t !== "z") throw TypeError("Smoke gallery axis must be 'x' or 'z'");
423
+ if (!(n?.length === 2 && Number.isFinite(n[0]) && Number.isFinite(n[1]) && n[0] < n[1])) throw RangeError("Smoke gallery walls must be two finite numbers of metres, the lower first");
424
+ let r = t === "x" ? 2 : 0;
425
+ for (let t = 0; t < 2; t++) {
426
+ let i = e.walls[t].center;
427
+ i[0] = this.at[0], i[1] = this.at[1], i[2] = this.at[2], i[r] = n[t] + (t ? b : -1e5);
428
+ }
429
+ return e.spread[0] = e.spread[2] = 1, e.spread[r] = x, (n[1] - n[0]) / 2;
430
+ }
431
+ halfWidth() {
432
+ let e = this.options.gallery?.walls;
433
+ return e ? (e[1] - e[0]) / 2 : Infinity;
219
434
  }
220
435
  wind() {
221
- return E(this.options.wind ?? this.effect?.options.wind ?? T(this.options.fire)?.wind, this.at, this.clock);
436
+ return F(this.options.wind ?? this.effect?.options.wind ?? P(this.options.fire)?.wind, this.at, this.clock);
222
437
  }
223
438
  write() {
224
- let e = this.options, t = S(this.heat(), e.airTemperature), n = this.radius(), r = this.wind(), i = e.stability ?? 0, a = this.key;
225
- if (a[0] === t && a[1] === r && a[2] === n && a[3] === i && a[4] === this.lifetime) return;
226
- a[0] = t, a[1] = r, a[2] = n, a[3] = i, a[4] = this.lifetime;
227
- let o = this.point, s = w(0, t, 0, n, 0, o).speed;
228
- this.velocity[1] = s;
229
- for (let e = 0; e < v; e++) w(e / 31 * this.lifetime, t, r, n, i, o), this.speed[e] = s > 0 ? Math.min(1e3, o.speed / s) : 0, this.size[e] = Math.min(1e3, o.radius / n);
439
+ let e = this.options, t = D(this.heat(), e.airTemperature), n = this.radius(), r = this.wind(), i = e.stability ?? 0, a = e.ceiling === void 0 ? Infinity : e.ceiling - this.at[1], o = this.halfWidth(), s = this.key;
440
+ if (s[0] === t && s[1] === r && s[2] === n && s[3] === i && s[4] === this.lifetime && s[5] === a && s[6] === o) return;
441
+ s[5] = a, s[6] = o, s[0] = t, s[1] = r, s[2] = n, s[3] = i, s[4] = this.lifetime;
442
+ let c = this.point, l = k(0, t, 0, n, 0, c).speed;
443
+ this.velocity[1] = l;
444
+ let u = a === Infinity ? void 0 : j(a, n, o);
445
+ for (let e = 0; e < C; e++) {
446
+ k(e / 31 * this.lifetime, t, r, n, i, c);
447
+ let a = u !== void 0 && e > 0 && c.rise >= u.rise;
448
+ this.speed[e] = a ? this.speed[e - 1] : l > 0 ? Math.min(1e3, c.speed / l) : 0, this.size[e] = Math.min(1e3, (u ? Math.min(c.radius, u.radius) : c.radius) / n);
449
+ }
230
450
  }
231
451
  column(e) {
232
- let t = this.options;
233
- return w(e, S(this.heat(), t.airTemperature), this.wind(), this.radius(), t.stability ?? 0);
452
+ let t = this.options, n = k(e, D(this.heat(), t.airTemperature), this.wind(), this.radius(), t.stability ?? 0);
453
+ if (t.ceiling !== void 0) {
454
+ let e = j(t.ceiling - this.at[1], this.radius(), this.halfWidth());
455
+ n.rise >= e.rise && (n.rise = e.rise, n.speed = 0, n.level = !0), n.radius = Math.min(n.radius, e.radius);
456
+ }
457
+ return n;
234
458
  }
235
459
  setup(e) {
236
460
  this.engine = e;
@@ -244,7 +468,7 @@ var T = (e) => e?.particles.flames?.options ?? e?.flame?.options, E = (e, t, n)
244
468
  advanceTime(e) {
245
469
  if (this.disposed) return;
246
470
  this.clock += e > 0 ? e : 0;
247
- let t = this.options, n = this.effect, r = n.options, i = T(t.fire);
471
+ let t = this.options, n = this.effect, r = n.options, i = P(t.fire);
248
472
  this.check(), t.wind !== this.ownWind && (n.setWind(t.wind), this.ownWind = t.wind), !t.wind && i && r.wind !== i.wind && n.setWind(i.wind), this.calm(r.wind), this.write();
249
473
  let a = this.radius();
250
474
  r.position = this.at, r.velocity = this.velocity, r.emissionExtent = this.extent, r.color = this.rgba, r.size = 2 * a, r.frequency = 1 / (8 * a), r.rate = t.rate ?? 20, r.turbulence = t.turbulence ?? .4;
@@ -256,7 +480,7 @@ var T = (e) => e?.particles.flames?.options ?? e?.flame?.options, E = (e, t, n)
256
480
  return this.effect.reset(), this;
257
481
  }
258
482
  setHeat(e) {
259
- return S(e, this.options.airTemperature), this.options.heat = e, this;
483
+ return D(e, this.options.airTemperature), this.options.heat = e, this;
260
484
  }
261
485
  setWind(e) {
262
486
  return this.effect.setWind(e), this.options.wind = this.ownWind = e, this;
@@ -264,9 +488,9 @@ var T = (e) => e?.particles.flames?.options ?? e?.flame?.options, E = (e, t, n)
264
488
  setFog(e) {
265
489
  return this.effect.setFog(e), this;
266
490
  }
267
- static attach(t, n) {__margoAssertCore(t,__margoCoreRequirement("0.1.0",import.meta.url));
491
+ static attach(t, n) {__margoAssertCore(t,__margoCoreRequirement("1.0.0",import.meta.url));
268
492
  if (!n || typeof n != "object") throw TypeError("Invalid Smoke options; pass {position: [x, y, z]} or {fire}");
269
- let r = new u(t, n);
493
+ let r = new p(t, n);
270
494
  return e(t).use(r), r;
271
495
  }
272
496
  dispose() {
@@ -277,4 +501,4 @@ var T = (e) => e?.particles.flames?.options ?? e?.flame?.options, E = (e, t, n)
277
501
  }
278
502
  };
279
503
  //#endregion
280
- export { d as BENT_PLUME_RADIUS, u as PLUME_ENTRAINMENT, b as RADIANT_FRACTION, y as SMOKE_FADE_IN, p as STABLE_CALM_RISE, m as STABLE_WIND_RISE, k as Smoke, f as TWO_THIRDS_LAW, C as airStability, S as buoyancyFlux, w as plumeRise, x as smokeAlphaCurve };
504
+ export { p as BENT_PLUME_RADIUS, f as PLUME_ENTRAINMENT, T as RADIANT_FRACTION, w as SMOKE_FADE_IN, h as STABLE_CALM_RISE, g as STABLE_WIND_RISE, R as Smoke, m as TWO_THIRDS_LAW, O as airStability, D as buoyancyFlux, A as ceilingJetSpeed, k as plumeRise, E as smokeAlphaCurve };