@woosh/meep-engine 2.157.0 → 2.158.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 (60) hide show
  1. package/package.json +1 -1
  2. package/src/core/geom/3d/shape/PosedShape3D.d.ts +17 -0
  3. package/src/core/geom/3d/shape/PosedShape3D.d.ts.map +1 -1
  4. package/src/core/geom/3d/shape/PosedShape3D.js +50 -0
  5. package/src/engine/graphics/ecs/trail2d/Trail2D.d.ts.map +1 -1
  6. package/src/engine/graphics/ecs/trail2d/Trail2D.js +21 -0
  7. package/src/engine/graphics/ecs/trail2d/Trail2DFlags.d.ts +1 -0
  8. package/src/engine/graphics/ecs/trail2d/Trail2DFlags.js +9 -1
  9. package/src/engine/physics/fluid/FluidField.d.ts +53 -9
  10. package/src/engine/physics/fluid/FluidField.d.ts.map +1 -1
  11. package/src/engine/physics/fluid/FluidField.js +684 -600
  12. package/src/engine/physics/fluid/FluidSimulator.d.ts +53 -38
  13. package/src/engine/physics/fluid/FluidSimulator.d.ts.map +1 -1
  14. package/src/engine/physics/fluid/FluidSimulator.js +252 -178
  15. package/src/engine/physics/fluid/REVIEW_02_PLAN.md +155 -26
  16. package/src/engine/physics/fluid/ecs/FluidObstacle.d.ts +72 -0
  17. package/src/engine/physics/fluid/ecs/FluidObstacle.d.ts.map +1 -0
  18. package/src/engine/physics/fluid/ecs/FluidObstacle.js +97 -0
  19. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +117 -0
  20. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts.map +1 -0
  21. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.js +348 -0
  22. package/src/engine/physics/fluid/ecs/FluidSystem.d.ts +3 -3
  23. package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts +62 -12
  24. package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts.map +1 -1
  25. package/src/engine/physics/fluid/effector/GlobalFluidEffector.js +135 -38
  26. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.d.ts.map +1 -1
  27. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.js +85 -38
  28. package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts.map +1 -1
  29. package/src/engine/physics/fluid/effector/WakeFluidEffector.js +104 -50
  30. package/src/engine/physics/fluid/prototype.js +25 -1
  31. package/src/engine/physics/fluid/solver/v3_grid_sample_scalar_masked.d.ts +30 -0
  32. package/src/engine/physics/fluid/solver/v3_grid_sample_scalar_masked.d.ts.map +1 -0
  33. package/src/engine/physics/fluid/solver/v3_grid_sample_scalar_masked.js +92 -0
  34. package/src/engine/physics/fluid/solver/v3_mac_advect_maccormack_velocity.d.ts +42 -0
  35. package/src/engine/physics/fluid/solver/v3_mac_advect_maccormack_velocity.d.ts.map +1 -0
  36. package/src/engine/physics/fluid/solver/v3_mac_advect_maccormack_velocity.js +319 -0
  37. package/src/engine/physics/fluid/solver/v3_mac_advect_scalar.d.ts +53 -0
  38. package/src/engine/physics/fluid/solver/v3_mac_advect_scalar.d.ts.map +1 -0
  39. package/src/engine/physics/fluid/solver/v3_mac_advect_scalar.js +236 -0
  40. package/src/engine/physics/fluid/solver/v3_mac_advect_sl_velocity.d.ts +46 -0
  41. package/src/engine/physics/fluid/solver/v3_mac_advect_sl_velocity.d.ts.map +1 -0
  42. package/src/engine/physics/fluid/solver/v3_mac_advect_sl_velocity.js +217 -0
  43. package/src/engine/physics/fluid/solver/v3_mac_apply_vorticity_confinement.d.ts +40 -0
  44. package/src/engine/physics/fluid/solver/v3_mac_apply_vorticity_confinement.d.ts.map +1 -0
  45. package/src/engine/physics/fluid/solver/v3_mac_apply_vorticity_confinement.js +165 -0
  46. package/src/engine/physics/fluid/solver/v3_mac_clip_trace.d.ts +44 -0
  47. package/src/engine/physics/fluid/solver/v3_mac_clip_trace.d.ts.map +1 -0
  48. package/src/engine/physics/fluid/solver/v3_mac_clip_trace.js +95 -0
  49. package/src/engine/physics/fluid/solver/v3_mac_compute_divergence.d.ts +38 -0
  50. package/src/engine/physics/fluid/solver/v3_mac_compute_divergence.d.ts.map +1 -0
  51. package/src/engine/physics/fluid/solver/v3_mac_compute_divergence.js +77 -0
  52. package/src/engine/physics/fluid/solver/v3_mac_compute_face_solid.d.ts +52 -0
  53. package/src/engine/physics/fluid/solver/v3_mac_compute_face_solid.d.ts.map +1 -0
  54. package/src/engine/physics/fluid/solver/v3_mac_compute_face_solid.js +131 -0
  55. package/src/engine/physics/fluid/solver/v3_mac_subtract_pressure_gradient.d.ts +38 -0
  56. package/src/engine/physics/fluid/solver/v3_mac_subtract_pressure_gradient.d.ts.map +1 -0
  57. package/src/engine/physics/fluid/solver/v3_mac_subtract_pressure_gradient.js +104 -0
  58. package/src/engine/physics/fluid/effector/AmbientWindFluidEffector.d.ts +0 -41
  59. package/src/engine/physics/fluid/effector/AmbientWindFluidEffector.d.ts.map +0 -1
  60. package/src/engine/physics/fluid/effector/AmbientWindFluidEffector.js +0 -124
@@ -19,7 +19,12 @@ export namespace PressureSolver {
19
19
  let MICPCG: string;
20
20
  }
21
21
  /**
22
- * Velocity / scalar transport scheme selection.
22
+ * VELOCITY transport scheme selection. Passive scalars always use
23
+ * semi-Lagrangian transport regardless of this setting — gather-form
24
+ * MacCormack is non-conservative (the corrector re-adds roughly double the
25
+ * gather bias; measured 1.7x total dye mass in one second of a sealed
26
+ * vortex, independent of wall handling), and scalar conservation is a hard
27
+ * requirement, not a preference.
23
28
  *
24
29
  * - `"semi-lagrangian"` — first-order back-trace + trilinear gather (Stam
25
30
  * 1999). Cheapest; strongly dissipative — a vortex loses half its kinetic
@@ -27,10 +32,8 @@ export namespace PressureSolver {
27
32
  *
28
33
  * - `"maccormack"` — unconditionally stable MacCormack (Selle et al. 2008):
29
34
  * a forward and a backward semi-Lagrangian pass with error correction and
30
- * a monotone min-max limiter. Second-order accurate in space and time at
31
- * ~2× the advection cost and advection is the minority of step() cost
32
- * next to pressure, so the end-to-end price is small. Allocates 3
33
- * additional N-sized scratch buffers, shared with the reflection scheme.
35
+ * a monotone min-max limiter. Second-order accurate in space and time.
36
+ * Allocates 3 additional face-lattice scratch buffers.
34
37
  */
35
38
  export type AdvectionScheme = string;
36
39
  export namespace AdvectionScheme {
@@ -38,7 +41,10 @@ export namespace AdvectionScheme {
38
41
  let MACCORMACK: string;
39
42
  }
40
43
  /**
41
- * Cell-centered 3D Stable Fluids solver (Stam, 1999/2003).
44
+ * 3D incompressible-flow solver on a MAC (staggered) grid — Stam's stable-
45
+ * fluids step structure (1999/2003) with face-centered velocity (Harlow &
46
+ * Welch 1965), an exact discrete Helmholtz projection, and optional
47
+ * advection-reflection / MacCormack transport.
42
48
  *
43
49
  * Holds tuning knobs plus transient working memory (per-step velocity snapshots,
44
50
  * divergence, ping-pong scratch). None of that working memory carries information
@@ -56,8 +62,8 @@ export namespace AdvectionScheme {
56
62
  * form of the same two projections (see {@link advection_reflection}).
57
63
  * Advection itself is semi-Lagrangian or MacCormack per
58
64
  * {@link advection_scheme}.
59
- * 6. For each scalar attribute on the field: optionally diffuse, then advect
60
- * with the same scheme.
65
+ * 6. For each scalar attribute on the field: optionally diffuse, then
66
+ * advect (always semi-Lagrangian — see {@link AdvectionScheme}).
61
67
  *
62
68
  * Pressure is warm-started from the previous step's solution (`field.pressure`),
63
69
  * which converges much faster than starting from zero once the flow reaches a
@@ -127,13 +133,19 @@ export class FluidSimulator {
127
133
  *
128
134
  * Why it exists: the solver has no other dissipation mechanism that bounds
129
135
  * energy under sustained forcing. Incompressible projection cannot oppose
130
- * a uniform body force (a uniform field is divergence-free), so a constant
131
- * {@link GlobalFluidEffector} accelerates the fluid without limit — there
132
- * is no terminal state. A small damping rate gives constant forcing a
133
- * terminal velocity of approximately `acceleration / velocity_damping`
134
- * and makes transient gusts decay back to calm, which is what wind-field
135
- * use cases want (drive with {@link AmbientWindFluidEffector} for a
136
- * specific ambient target instead of a force).
136
+ * a uniform body force (a uniform field is divergence-free), so a bare
137
+ * `force` on a {@link GlobalFluidEffector} accelerates the fluid without
138
+ * limit — there is no terminal state. A small damping rate gives constant
139
+ * forcing a terminal velocity of approximately
140
+ * `acceleration / velocity_damping` and makes transient gusts decay back
141
+ * to calm.
142
+ *
143
+ * Relationship to {@link GlobalFluidEffector#drag}: the effector's drag
144
+ * is the same operation expressed as SCENE CONTENT — it relaxes toward a
145
+ * configurable ambient wind and travels with the effector entity. This
146
+ * knob is the SOLVER-level stability primitive: it exists even when no
147
+ * effectors are wired, and always relaxes toward zero. Use the effector
148
+ * for atmosphere design; use this to guarantee boundedness.
137
149
  *
138
150
  * The exponential form is frame-rate independent: two half-steps damp
139
151
  * exactly as much as one full step.
@@ -175,21 +187,19 @@ export class FluidSimulator {
175
187
  */
176
188
  vorticity_confinement: number;
177
189
  /**
178
- * Which transport scheme advects velocity and scalars see
179
- * {@link AdvectionScheme}.
180
- *
181
- * **Default semi-Lagrangian MacCormack is gated on a MAC-staggered
182
- * grid.** On the current collocated discretization the projection has an
183
- * operator-mismatch floor (high-frequency divergence it cannot see, let
184
- * alone remove quality.spec.js scenario 7), and MacCormack's
185
- * anti-diffusive corrector amplifies exactly that residue instead of
186
- * letting first-order smearing absorb it. Measured on the sealed-vortex
187
- * scenario: kinetic energy transiently grows to **1.9×** within 10 s
188
- * (vs SL's monotone decay), and a passive scalar's total mass inflates
189
- * **1.8×** in one second of orbiting. The kernels are correct in
190
- * isolation (their specs transport clean fields sharply and monotonely) —
191
- * it is the interaction with the collocated pressure floor that is
192
- * unstable. Flip this on once the grid is staggered.
190
+ * Which transport scheme advects VELOCITY see {@link AdvectionScheme}
191
+ * (scalars are always semi-Lagrangian; see the enum docstring for why).
192
+ *
193
+ * **Default MacCormack.** On the MAC grid with solid-clipped traces it is
194
+ * measured long-horizon stable (sealed-vortex energy peaks at 0.96x its
195
+ * initial over 10 s, monotone decay thereafter) and retains dramatically
196
+ * more energy than first-order transport: 0.80 vs 0.53 KE after one
197
+ * second (quality.spec.js scenario 2b).
198
+ *
199
+ * Do NOT combine with {@link advection_reflection}: the energy-preserving
200
+ * reflection re-injects the corrector overshoots and the pair pumps
201
+ * energy without bound (10 s peak 3.7x measured both with and without
202
+ * trace clipping). Reflection is the companion for SEMI_LAGRANGIAN.
193
203
  *
194
204
  * @type {string}
195
205
  */
@@ -207,22 +217,27 @@ export class FluidSimulator {
207
217
  *
208
218
  * Same two pressure solves as the default double-projection Stam step,
209
219
  * and two half-dt advections instead of one full-dt one — measured cost
210
- * +20% of step() at 32×8×32. The reflection replaces the
220
+ * ~+70% of step() at 32×8×32 on the MAC lattices (each half-step pays the
221
+ * cross-component carrier sampling). The reflection replaces the
211
222
  * energy-DISSIPATING first projection with an energy-PRESERVING
212
223
  * reflection about the divergence-free subspace.
213
224
  *
214
- * Default ON: with semi-Lagrangian advection this is measured stable
215
- * (sealed-vortex kinetic energy never exceeds 0.99× its initial over
216
- * 10 s) while retaining visibly more swirl — peak vorticity 0.73 vs 0.62
217
- * after one second (quality.spec.js scenario 2b). With MacCormack it
218
- * compounds the collocated-floor amplification (3.4× energy growth) —
219
- * see {@link advection_scheme}; that combination should wait for MAC
220
- * staggering.
225
+ * With semi-Lagrangian advection this is measured stable (sealed-vortex
226
+ * kinetic energy never exceeds its initial over 10 s) while retaining
227
+ * visibly more swirl — peak vorticity 0.74 vs 0.68 after one second
228
+ * (quality.spec.js scenario 2b). Do NOT combine with MacCormack — the
229
+ * reflection re-injects the corrector overshoots (10 s energy peak
230
+ * 3.7x); see {@link advection_scheme}.
221
231
  *
222
232
  * Only consulted when {@link project_before_advection} is true — the
223
233
  * scheme is defined around the mid-step projection. With
224
234
  * `project_before_advection = false` this flag is ignored.
225
235
  *
236
+ * Default OFF: the default velocity scheme is MacCormack, with which the
237
+ * reflection is unstable (see {@link advection_scheme}). Enable it when
238
+ * running SEMI_LAGRANGIAN velocity transport — that pairing is measured
239
+ * stable and retains visibly more swirl than plain SL.
240
+ *
226
241
  * @type {boolean}
227
242
  */
228
243
  advection_reflection: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"FluidSimulator.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/fluid/FluidSimulator.js"],"names":[],"mappings":";;;;;;;;;;;;;;;6BA4BU,MAAM;;;;;;;;;;;;;;;;;;;8BAqBN,MAAM;;;;;AAOhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH;;;;;;;;;GASG;AACH,wCAFU,MAAM,CAE2B;AAE3C;;;;;;;;;;;;;;;;GAgBG;AACH,qCAFU,MAAM,CAE2B;AAE3C;IAEI;;;OAGG;IACH,yBAFU,MAAM,CAEY;IAE5B;;;;OAIG;IACH,+BAFU,MAAM,CAEkB;IAElC;;;;;OAKG;IACH,uBAFU,MAAM,CAEU;IAE1B;;OAEG;IACH,6BAFU,MAAM,CAEgB;IAEhC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,kBAFU,MAAM,CAEK;IAErB;;;;;;;;;;;;;;;OAeG;IACH,iBAFU,MAAM,CAEqB;IAErC;;;;;;;;;;;;;;OAcG;IACH,uBAFU,MAAM,CAEU;IAE1B;;;;;;;;;;;;;;;;;;OAkBG;IACH,kBAFU,MAAM,CAEmC;IAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,sBAFU,OAAO,CAEW;IAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,0BAFU,OAAO,CAEe;IAEhC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,0BAFU,MAAM,CAEgB;IA4IhC;;;;;;;;;;;;OAYG;IACH,iCALW,MAAM,SACN,MAAM,SACN,MAAM,GACL,MAAM,CAUjB;IAED;;;;;;;;;;;;OAYG;IACH,iCAGC;IAuED;;;;;;;;;;;;;OAaG;IACH,oCAVW,MAAM,aAEN,uBAAuB,iBACvB,YAAY,GAAC,MAAM,EAAE,QA4K/B;;CACJ"}
1
+ {"version":3,"file":"FluidSimulator.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/fluid/FluidSimulator.js"],"names":[],"mappings":";;;;;;;;;;;;;;;6BA2BU,MAAM;;;;;;;;;;;;;;;;;;;;;;8BAwBN,MAAM;;;;;AAOhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH;;;;;;;;;GASG;AACH,wCAFU,MAAM,CAE2B;AAE3C;;;;;;;;;;;;;;;;GAgBG;AACH,qCAFU,MAAM,CAE2B;AAE3C;IAEI;;;OAGG;IACH,yBAFU,MAAM,CAEY;IAE5B;;;;OAIG;IACH,+BAFU,MAAM,CAEkB;IAElC;;;;;OAKG;IACH,uBAFU,MAAM,CAEU;IAE1B;;OAEG;IACH,6BAFU,MAAM,CAEgB;IAEhC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,kBAFU,MAAM,CAEK;IAErB;;;;;;;;;;;;;;;OAeG;IACH,iBAFU,MAAM,CAEqB;IAErC;;;;;;;;;;;;;;OAcG;IACH,uBAFU,MAAM,CAEU;IAE1B;;;;;;;;;;;;;;;;OAgBG;IACH,kBAFU,MAAM,CAE8B;IAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,sBAFU,OAAO,CAEY;IAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,0BAFU,OAAO,CAEe;IAEhC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,0BAFU,MAAM,CAEgB;IAuKhC;;;;;;;;;;;;OAYG;IACH,iCALW,MAAM,SACN,MAAM,SACN,MAAM,GACL,MAAM,CAUjB;IAED;;;;;;;;;;;;OAYG;IACH,iCAGC;IAwFD;;;;;;;;;;;;;OAaG;IACH,oCAVW,MAAM,aAEN,uBAAuB,iBACvB,YAAY,GAAC,MAAM,EAAE,QA4L/B;;CACJ"}