@woosh/meep-engine 3.74.0 → 3.75.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 (161) hide show
  1. package/CHANGELOG.md +20 -19
  2. package/package.json +1 -1
  3. package/src/core/geom/2d/hilbert/v2_hilbert_encode.d.ts +11 -0
  4. package/src/core/geom/2d/hilbert/v2_hilbert_encode.d.ts.map +1 -0
  5. package/src/core/geom/2d/hilbert/v2_hilbert_encode.js +46 -0
  6. package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts +6 -0
  7. package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts.map +1 -1
  8. package/src/engine/graphics/render/frame_graph/FrameGraph.js +9 -0
  9. package/src/engine/graphics3/GPUAcousticSystem.d.ts +29 -32
  10. package/src/engine/graphics3/GPUAcousticSystem.d.ts.map +1 -1
  11. package/src/engine/graphics3/GPUAcousticSystem.js +87 -162
  12. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  13. package/src/engine/sound/ecs/audio/AudioEmitterSystem.d.ts.map +1 -1
  14. package/src/engine/sound/ecs/audio/AudioEmitterSystem.js +35 -17
  15. package/src/engine/sound/ecs/audio/LiveEmitterSet.d.ts.map +1 -1
  16. package/src/engine/sound/ecs/audio/LiveEmitterSet.js +2 -3
  17. package/src/engine/sound/simulation/AcousticSimulator.d.ts +7 -0
  18. package/src/engine/sound/simulation/AcousticSimulator.d.ts.map +1 -1
  19. package/src/engine/sound/simulation/AcousticSimulator.js +27 -0
  20. package/src/engine/sound/simulation/README.md +121 -107
  21. package/src/engine/sound/sopra/README.md +8 -3
  22. package/src/engine/sound/sopra/definition/effect/AcousticReverbEffect.d.ts +2 -2
  23. package/src/engine/sound/sopra/definition/effect/AcousticReverbEffect.d.ts.map +1 -1
  24. package/src/engine/sound/sopra/definition/effect/AcousticReverbEffect.js +4 -3
  25. package/src/engine/sound/sopra/runtime/AcousticReverbConvolution.d.ts +118 -0
  26. package/src/engine/sound/sopra/runtime/AcousticReverbConvolution.d.ts.map +1 -0
  27. package/src/engine/sound/sopra/runtime/AcousticReverbConvolution.js +472 -0
  28. package/src/engine/sound/sopra/runtime/AcousticReverbLines.d.ts +166 -0
  29. package/src/engine/sound/sopra/runtime/AcousticReverbLines.d.ts.map +1 -0
  30. package/src/engine/sound/sopra/runtime/AcousticReverbLines.js +447 -0
  31. package/src/engine/sound/sopra/runtime/AcousticReverbNetwork.d.ts +69 -113
  32. package/src/engine/sound/sopra/runtime/AcousticReverbNetwork.d.ts.map +1 -1
  33. package/src/engine/sound/sopra/runtime/AcousticReverbNetwork.js +143 -491
  34. package/src/engine/sound/sopra/runtime/AcousticSpeakers.d.ts +102 -0
  35. package/src/engine/sound/sopra/runtime/AcousticSpeakers.d.ts.map +1 -0
  36. package/src/engine/sound/sopra/runtime/AcousticSpeakers.js +232 -0
  37. package/src/engine/sound/sopra/runtime/BusGraph.d.ts +17 -3
  38. package/src/engine/sound/sopra/runtime/BusGraph.d.ts.map +1 -1
  39. package/src/engine/sound/sopra/runtime/BusGraph.js +55 -5
  40. package/src/engine/sound/sopra/runtime/EventInstance.d.ts +8 -6
  41. package/src/engine/sound/sopra/runtime/EventInstance.d.ts.map +1 -1
  42. package/src/engine/sound/sopra/runtime/EventInstance.js +113 -105
  43. package/src/engine/sound/sopra/runtime/acoustic_reverb_decay.d.ts +13 -0
  44. package/src/engine/sound/sopra/runtime/acoustic_reverb_decay.d.ts.map +1 -0
  45. package/src/engine/sound/sopra/runtime/acoustic_reverb_decay.js +15 -0
  46. package/src/generation/grid/generation/discrete/GridTaskConnectRooms.d.ts.map +1 -1
  47. package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +4 -6
  48. package/src/shade/playground/skinned_blas_refit/diff_traced_against_rasterized.d.ts.map +1 -1
  49. package/src/shade/playground/skinned_blas_refit/diff_traced_against_rasterized.js +4 -5
  50. package/src/shade/playground/skinned_blas_refit/main.d.ts.map +1 -1
  51. package/src/shade/playground/skinned_blas_refit/main.js +6 -12
  52. package/src/shade/playground/skinned_mesh_soup/main.d.ts.map +1 -1
  53. package/src/shade/playground/skinned_mesh_soup/main.js +1 -2
  54. package/src/shade/playground/vgeo_scene/README.md +12 -2
  55. package/src/shade/playground/vgeo_scene/main.js +1 -1
  56. package/src/shade/playground/volumetrics_froxel/README.md +191 -191
  57. package/src/shade/playground/volumetrics_froxel/measure.d.ts +3 -3
  58. package/src/shade/playground/volumetrics_froxel/measure.d.ts.map +1 -1
  59. package/src/shade/playground/volumetrics_froxel/measure.js +11 -13
  60. package/src/shade/playground/vsm/main.d.ts.map +1 -1
  61. package/src/shade/playground/vsm/main.js +5 -6
  62. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  63. package/src/shade/renderer/Renderer.js +31 -8
  64. package/src/shade/renderer/acoustics/ACOUSTIC_LISTENER_RESOURCES.d.ts +28 -0
  65. package/src/shade/renderer/acoustics/ACOUSTIC_LISTENER_RESOURCES.d.ts.map +1 -0
  66. package/src/shade/renderer/acoustics/ACOUSTIC_LISTENER_RESOURCES.js +42 -0
  67. package/src/shade/renderer/acoustics/ACOUSTIC_PROBE_DATABASE_SPEC.d.ts +58 -0
  68. package/src/shade/renderer/acoustics/ACOUSTIC_PROBE_DATABASE_SPEC.d.ts.map +1 -0
  69. package/src/shade/renderer/acoustics/ACOUSTIC_PROBE_DATABASE_SPEC.js +108 -0
  70. package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
  71. package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts +161 -0
  72. package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts.map +1 -0
  73. package/src/shade/renderer/acoustics/GPUAcousticProbes.js +760 -0
  74. package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
  75. package/src/shade/renderer/acoustics/acoustic_listener_order.d.ts +12 -0
  76. package/src/shade/renderer/acoustics/acoustic_listener_order.d.ts.map +1 -0
  77. package/src/shade/renderer/acoustics/acoustic_listener_order.js +56 -0
  78. package/src/shade/renderer/acoustics/chunk_acoustic_direct.d.ts.map +1 -1
  79. package/src/shade/renderer/acoustics/chunk_acoustic_direct.js +5 -0
  80. package/src/shade/renderer/acoustics/chunk_acoustic_direct_cone.d.ts +57 -0
  81. package/src/shade/renderer/acoustics/chunk_acoustic_direct_cone.d.ts.map +1 -0
  82. package/src/shade/renderer/acoustics/chunk_acoustic_direct_cone.js +314 -0
  83. package/src/shade/renderer/acoustics/chunk_acoustic_finite.d.ts +15 -0
  84. package/src/shade/renderer/acoustics/chunk_acoustic_finite.d.ts.map +1 -0
  85. package/src/shade/renderer/acoustics/chunk_acoustic_finite.js +21 -0
  86. package/src/shade/renderer/acoustics/chunk_acoustic_gather.js +1 -1
  87. package/src/shade/renderer/acoustics/chunk_acoustic_lean.d.ts +27 -0
  88. package/src/shade/renderer/acoustics/chunk_acoustic_lean.d.ts.map +1 -0
  89. package/src/shade/renderer/acoustics/chunk_acoustic_lean.js +42 -0
  90. package/src/shade/renderer/acoustics/chunk_acoustic_listener.d.ts +80 -0
  91. package/src/shade/renderer/acoustics/chunk_acoustic_listener.d.ts.map +1 -0
  92. package/src/shade/renderer/acoustics/chunk_acoustic_listener.js +274 -0
  93. package/src/shade/renderer/acoustics/chunk_acoustic_partials.d.ts +2 -2
  94. package/src/shade/renderer/acoustics/chunk_acoustic_partials.js +2 -2
  95. package/src/shade/renderer/acoustics/chunk_acoustic_phonon.d.ts +7 -0
  96. package/src/shade/renderer/acoustics/chunk_acoustic_phonon.d.ts.map +1 -1
  97. package/src/shade/renderer/acoustics/chunk_acoustic_phonon.js +24 -1
  98. package/src/shade/renderer/acoustics/chunk_acoustic_resample.js +1 -1
  99. package/src/shade/renderer/acoustics/chunk_acoustic_reservoir.js +1 -1
  100. package/src/shade/renderer/acoustics/chunk_acoustic_through.d.ts +43 -0
  101. package/src/shade/renderer/acoustics/chunk_acoustic_through.d.ts.map +1 -0
  102. package/src/shade/renderer/acoustics/chunk_acoustic_through.js +153 -0
  103. package/src/shade/renderer/acoustics/chunk_acoustic_trace.d.ts +3 -1
  104. package/src/shade/renderer/acoustics/chunk_acoustic_trace.d.ts.map +1 -1
  105. package/src/shade/renderer/acoustics/chunk_acoustic_trace.js +10 -1
  106. package/src/shade/renderer/acoustics/shader_acoustic_combine.d.ts +7 -3
  107. package/src/shade/renderer/acoustics/shader_acoustic_combine.d.ts.map +1 -1
  108. package/src/shade/renderer/acoustics/shader_acoustic_combine.js +22 -6
  109. package/src/shade/renderer/acoustics/shader_acoustic_coupling.d.ts +14 -0
  110. package/src/shade/renderer/acoustics/shader_acoustic_coupling.d.ts.map +1 -0
  111. package/src/shade/renderer/acoustics/shader_acoustic_coupling.js +102 -0
  112. package/src/shade/renderer/acoustics/shader_acoustic_listener.d.ts +12 -0
  113. package/src/shade/renderer/acoustics/shader_acoustic_listener.d.ts.map +1 -0
  114. package/src/shade/renderer/acoustics/shader_acoustic_listener.js +80 -0
  115. package/src/shade/renderer/acoustics/shader_acoustic_receive.d.ts.map +1 -1
  116. package/src/shade/renderer/acoustics/shader_acoustic_receive.js +27 -6
  117. package/src/shade/renderer/acoustics/shader_acoustic_room.d.ts +11 -0
  118. package/src/shade/renderer/acoustics/shader_acoustic_room.d.ts.map +1 -0
  119. package/src/shade/renderer/acoustics/shader_acoustic_room.js +111 -0
  120. package/src/shade/renderer/acoustics/shader_acoustic_source.d.ts +18 -0
  121. package/src/shade/renderer/acoustics/shader_acoustic_source.d.ts.map +1 -0
  122. package/src/shade/renderer/acoustics/shader_acoustic_source.js +130 -0
  123. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  124. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  125. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +7 -7
  126. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  127. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  128. package/src/shade/renderer/geometry/virtual/build/level/VGeoFrontier.d.ts +2 -2
  129. package/src/shade/renderer/geometry/virtual/build/level/VGeoFrontier.js +2 -2
  130. package/src/shade/renderer/geometry/virtual/build/level/VGeoLevelOptions.d.ts +5 -2
  131. package/src/shade/renderer/geometry/virtual/build/level/VGeoLevelOptions.d.ts.map +1 -1
  132. package/src/shade/renderer/geometry/virtual/build/level/VGeoLevelOptions.js +5 -2
  133. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.d.ts +9 -2
  134. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.d.ts.map +1 -1
  135. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.js +48 -12
  136. package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.d.ts +0 -22
  137. package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.d.ts.map +1 -1
  138. package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.js +0 -42
  139. package/src/shade/renderer/geometry/virtual/format/read/VGeoReadOptions.d.ts +2 -18
  140. package/src/shade/renderer/geometry/virtual/format/read/VGeoReadOptions.d.ts.map +1 -1
  141. package/src/shade/renderer/geometry/virtual/format/read/VGeoReadOptions.js +2 -19
  142. package/src/shade/renderer/geometry/virtual/format/read/vgeo_page_worker_serve.d.ts.map +1 -1
  143. package/src/shade/renderer/geometry/virtual/format/read/vgeo_page_worker_serve.js +0 -1
  144. package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.d.ts +5 -4
  145. package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.d.ts.map +1 -1
  146. package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.js +3 -1
  147. package/src/shade/renderer/geometry/virtual/runtime/VGeoFeedbackLoop.d.ts.map +1 -1
  148. package/src/shade/renderer/geometry/virtual/runtime/VGeoFeedbackLoop.js +3 -1
  149. package/src/shade/renderer/geometry/virtual/runtime/VGeoPageFetcher.d.ts.map +1 -1
  150. package/src/shade/renderer/geometry/virtual/runtime/VGeoPageFetcher.js +0 -1
  151. package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.d.ts +60 -14
  152. package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.d.ts.map +1 -1
  153. package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.js +75 -39
  154. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.d.ts +0 -9
  155. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.d.ts.map +1 -1
  156. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.js +45 -17
  157. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +7 -3
  158. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts.map +1 -1
  159. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +43 -7
  160. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  161. package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
@@ -1,9 +1,11 @@
1
1
  import { assert } from "../../core/assert.js";
2
- import { random_orthonormal_basis } from "../../core/geom/random/random_orthonormal_basis.js";
3
- import { seededRandom } from "../../core/math/random/seededRandom.js";
4
- import { ACOUSTIC_RESULT_STRUCT } from "../../shade/renderer/acoustics/ACOUSTIC_DATABASE_SPEC.js";
5
- import { ACOUSTIC_LATTICE_POINTS_A_FRAME, GPUAcousticLattice } from "../../shade/renderer/acoustics/GPUAcousticLattice.js";
6
- import { ACOUSTIC_RESULT_FLOATS, GPUAcoustics } from "../../shade/renderer/acoustics/GPUAcoustics.js";
2
+ import {
3
+ ACOUSTIC_DIRECT_ENERGY,
4
+ ACOUSTIC_DIRECT_FLOATS,
5
+ ACOUSTIC_DIRECT_REVERB,
6
+ ACOUSTIC_REVERB_FLOATS,
7
+ GPUAcousticProbes
8
+ } from "../../shade/renderer/acoustics/GPUAcousticProbes.js";
7
9
  import { GPUBrickAcoustics } from "../../shade/renderer/acoustics/GPUBrickAcoustics.js";
8
10
  import { shader_brick_acoustics_gather } from "../../shade/renderer/acoustics/shader_brick_acoustics_gather.js";
9
11
  import { generate_record_writer } from "../../shade/renderer/buffer/table/serde/generate_record_writer.js";
@@ -11,12 +13,10 @@ import { FramePhase } from "../../shade/renderer/extension/FramePhase.js";
11
13
  import { RenderExtension } from "../../shade/renderer/extension/RenderExtension.js";
12
14
  import { ACOUSTIC_MATERIAL_FLAG_SET, ACOUSTIC_MATERIAL_STRUCT } from "../../shade/renderer/scene/ACOUSTIC_MATERIAL_STRUCT.js";
13
15
  import { row_of_entity } from "../../shade/renderer/scene/rows/GPUSceneRows.js";
14
- import { Vector3 } from "../../core/geom/Vector3.js";
15
16
  import { System } from "../ecs/System.js";
16
17
  import { AcousticPropagation } from "../sound/simulation/core/AcousticPropagation.js";
17
18
  import { AcousticMaterial } from "../sound/simulation/definition/AcousticMaterial.js";
18
19
  import { AcousticBody } from "../sound/simulation/ecs/AcousticBody.js";
19
- import { DEFAULT_ACOUSTIC_SOURCE_RADIUS } from "../sound/simulation/core/DEFAULT_ACOUSTIC_SOURCE_RADIUS.js";
20
20
 
21
21
  /**
22
22
  * @typedef {import("../../shade/renderer/scene/GPUSceneContext.js").GPUSceneContext} GPUSceneContext
@@ -31,47 +31,20 @@ const MATERIAL_WRITER = generate_record_writer(ACOUSTIC_MATERIAL_STRUCT);
31
31
  /** Floats of an `AcousticMaterial` as a body's record is compared: absorption ×3, scattering, transmission ×3. */
32
32
  const MATERIAL_FLOATS = 7;
33
33
 
34
- /**
35
- * Where a field of a result row sits, in floats.
36
- * @param {string} name
37
- * @returns {number}
38
- */
39
- function result_float(name) {
40
- return ACOUSTIC_RESULT_STRUCT.fields.find(field => field.name === name).offset / 4;
41
- }
42
-
43
- const RESULT_DIRECT = result_float('direct');
44
- const RESULT_EARLY = result_float('early');
45
- const RESULT_REFLECTED_AGE = result_float('reflected_age');
46
- const RESULT_EARLY_DIRECTION = result_float('early_direction');
47
- const RESULT_LATE = result_float('late');
48
- const RESULT_LATE_DIRECTION = result_float('late_direction');
49
- const RESULT_MOMENT = result_float('moment');
50
-
51
34
  /** Rows a source's last written state is kept for, to start with; it doubles. */
52
35
  const INITIAL_ROWS = 64;
53
36
 
54
37
  /**
55
- * Floats a source's last written state takes: place, radius, forward, dipole weight and power.
38
+ * Floats a source's last written state takes: place and radius.
56
39
  * @type {number}
57
40
  */
58
- const SOURCE_FLOATS = 9;
59
-
60
- /** Scratch for a source's forward. */
61
- const FORWARD = new Vector3();
41
+ const SOURCE_FLOATS = 4;
62
42
 
63
43
  /** Decibels a metre to the energy's absorption a metre, `m` of `exp(−m ℓ)`. */
64
44
  const DB_TO_ENERGY_NEPERS = Math.LN10 / 10;
65
45
 
66
- /** Scratch for a prior. */
67
- const PRIOR = new Float32Array(ACOUSTIC_RESULT_FLOATS);
68
-
69
- /**
70
- * Seed of the frames' sample rotations: they decorrelate the Fibonacci points from the geometry, and seeded they
71
- * are the same run to run.
72
- * @type {number}
73
- */
74
- const ROTATION_SEED = 1;
46
+ /** Scratch for the reverb at the listener. */
47
+ const REVERB = new Float32Array(ACOUSTIC_REVERB_FLOATS);
75
48
 
76
49
  /**
77
50
  * An `AcousticBody` the system writes into `acoustic_materials`, and what its row was last written as.
@@ -85,23 +58,18 @@ class BodyEntry {
85
58
  }
86
59
 
87
60
  /**
88
- * The GPU acoustics as the simulator reads them ({@link AcousticPropagation}): a receiver a live source, and its
89
- * terms as they last landed. Neutral where there is no device, and for a source whose first result has not landed.
61
+ * The GPU acoustics as the simulator reads them ({@link AcousticPropagation}): a row a live source, its direct path as
62
+ * it last landed, and the reverb the probe at the listener measures. Neutral where there is no device, and for a
63
+ * source whose first result has not landed.
90
64
  */
91
65
  export class GPUAcousticPropagation extends AcousticPropagation {
92
66
  /**
93
67
  * The acoustics on the device, while the system has one; null leaves every source neutral.
94
- * @type {GPUAcoustics|null}
68
+ * @type {GPUAcousticProbes|null}
95
69
  */
96
70
  #acoustics = null;
97
71
 
98
- /**
99
- * The lattice that primes a newborn source, while the system has a device.
100
- * @type {GPUAcousticLattice|null}
101
- */
102
- #lattice = null;
103
-
104
- /** Each live source's receiver row. @type {Map<EventInstance, number>} */
72
+ /** Each live source's row. @type {Map<EventInstance, number>} */
105
73
  #rows = new Map();
106
74
 
107
75
  /** Each row's source as last written, {@link SOURCE_FLOATS} a row. */
@@ -115,34 +83,25 @@ export class GPUAcousticPropagation extends AcousticPropagation {
115
83
  has_listener = false;
116
84
 
117
85
  /**
118
- * @returns {GPUAcoustics|null}
86
+ * @returns {GPUAcousticProbes|null}
119
87
  */
120
88
  get acoustics() {
121
89
  return this.#acoustics;
122
90
  }
123
91
 
124
- /**
125
- * @returns {GPUAcousticLattice|null} the lattice that primes a newborn source, while there is a device
126
- */
127
- get lattice() {
128
- return this.#lattice;
129
- }
130
-
131
92
  /**
132
93
  * Take the acoustics of a device, or none. Rows of the acoustics before are the old device's: every source takes
133
94
  * a row anew at its next solve.
134
95
  *
135
- * @param {GPUAcoustics|null} acoustics
136
- * @param {GPUAcousticLattice|null} lattice its lattice, which primes a source as it starts
96
+ * @param {GPUAcousticProbes|null} acoustics
137
97
  */
138
- set_acoustics(acoustics, lattice) {
98
+ set_acoustics(acoustics) {
139
99
  this.#acoustics = acoustics;
140
- this.#lattice = lattice;
141
100
  this.#rows.clear();
142
101
  }
143
102
 
144
103
  /**
145
- * Sources with a receiver.
104
+ * Sources with a row.
146
105
  * @returns {number}
147
106
  */
148
107
  get source_count() {
@@ -150,8 +109,7 @@ export class GPUAcousticPropagation extends AcousticPropagation {
150
109
  }
151
110
 
152
111
  /**
153
- * The frame's listener, which the ring emits from and the lattice is placed about: they run whenever there is
154
- * one, sources or none.
112
+ * The frame's listener, which the probes stand about: they run whenever there is one, sources or none.
155
113
  *
156
114
  * @param {ArrayLike<number>} listener
157
115
  */
@@ -163,6 +121,14 @@ export class GPUAcousticPropagation extends AcousticPropagation {
163
121
  }
164
122
 
165
123
  /**
124
+ * A source's terms, as its row and the room last landed: its direct path; and its reverberant energy at the listener
125
+ * (its first-order reflections off the listener's hits and the orders after, as a ratio to its direct energy at
126
+ * 1 m), which against its own direct energy `d` away is that times `d²` (the source's sphere for the nearest): its
127
+ * `wet` term, with the room's decay and lean. Nothing early: a reflection is the reverb's. Before the room's first reading lands, or with
128
+ * the listener inside a solid, no reverb: energy is lost, never invented.
129
+ *
130
+ * A source out of hearing (`currentGain` 0) keeps its row and its last direct path, and costs no rays.
131
+ *
166
132
  * @param {EventInstance} instance
167
133
  * @param {ArrayLike<number>} listener
168
134
  * @param {AcousticSolution} out
@@ -184,67 +150,50 @@ export class GPUAcousticPropagation extends AcousticPropagation {
184
150
  let row = this.#rows.get(instance);
185
151
 
186
152
  if (row === undefined) {
187
- row = acoustics.add(source[0], source[1], source[2], source[3], FORWARD, source[7], source[8]);
153
+ row = acoustics.add(source[0], source[1], source[2], source[3]);
188
154
 
189
155
  this.#rows.set(instance, row);
190
156
  this.#remember(row);
191
-
192
- // what it hears until its own first result lands
193
- if (this.#lattice !== null && this.#lattice.prior(source[0], source[1], source[2], PRIOR, 0)) {
194
- acoustics.prime(row, PRIOR, 0);
195
- }
196
157
  } else if (!this.#unchanged(row)) {
197
- acoustics.move(row, source[0], source[1], source[2], source[3], FORWARD, source[7], source[8]);
158
+ acoustics.move(row, source[0], source[1], source[2], source[3]);
198
159
  this.#remember(row);
199
160
  }
200
161
 
201
- // how loud it is heard with nothing in the way: what its share of the frame's spare rays is weighed by
202
162
  const gain = instance.currentGain;
203
163
 
204
- acoustics.set_importance(row, Number.isFinite(gain) ? gain * gain : 1);
164
+ // a gain not known is heard
165
+ acoustics.set_heard(row, !(gain === 0));
205
166
 
206
167
  if (!acoustics.answered(row)) {
207
168
  return;
208
169
  }
209
170
 
210
- const results = acoustics.results;
211
- const at = row * ACOUSTIC_RESULT_FLOATS;
171
+ const results = acoustics.direct;
172
+ const at = row * ACOUSTIC_DIRECT_FLOATS;
212
173
 
213
- out.direct[0] = results[at + RESULT_DIRECT];
214
- out.direct[1] = results[at + RESULT_DIRECT + 1];
215
- out.direct[2] = results[at + RESULT_DIRECT + 2];
174
+ out.direct[0] = results[at + ACOUSTIC_DIRECT_ENERGY];
175
+ out.direct[1] = results[at + ACOUSTIC_DIRECT_ENERGY + 1];
176
+ out.direct[2] = results[at + ACOUSTIC_DIRECT_ENERGY + 2];
216
177
 
217
- if (!(results[at + RESULT_REFLECTED_AGE] > 0)) {
218
- // no reflected estimate has landed yet
178
+ if (!acoustics.room(REVERB)) {
219
179
  return;
220
180
  }
221
181
 
222
- let early_mean = 0;
223
- let late_mean = 0;
182
+ const dx = source[0] - listener[0];
183
+ const dy = source[1] - listener[1];
184
+ const dz = source[2] - listener[2];
185
+ const distance = Math.max(source[3], Math.sqrt(dx * dx + dy * dy + dz * dz));
186
+ const square = distance * distance;
224
187
 
225
188
  for (let b = 0; b < 3; b++) {
226
- const early = results[at + RESULT_EARLY + b];
227
- const late = results[at + RESULT_LATE + b];
228
-
229
- out.early[b] = early;
230
- out.wet[b] = late;
231
- // the late energy's first moment about the early/late boundary: the tail's time constant
232
- out.wetCentreTime[b] = late > 0 ? results[at + RESULT_MOMENT + b] / late : 0;
233
-
234
- early_mean += early / 3;
235
- late_mean += late / 3;
236
- }
237
-
238
- // each arrival's direction was weighted by its band-mean energy, so over the mean the vector's length is the
239
- // share that arrives from one direction
240
- for (let axis = 0; axis < 3; axis++) {
241
- out.earlyDirection[axis] = early_mean > 0 ? results[at + RESULT_EARLY_DIRECTION + axis] / early_mean : 0;
242
- out.wetDirection[axis] = late_mean > 0 ? results[at + RESULT_LATE_DIRECTION + axis] / late_mean : 0;
189
+ out.wet[b] = results[at + ACOUSTIC_DIRECT_REVERB + b] * square;
190
+ out.wetCentreTime[b] = REVERB[3 + b];
191
+ out.wetDirection[b] = REVERB[6 + b];
243
192
  }
244
193
  }
245
194
 
246
195
  /**
247
- * The source as its receiver is written: place, radius, forward (into {@link FORWARD} as well), and directivity.
196
+ * The source as its row is written: place and radius.
248
197
  *
249
198
  * @param {EventInstance} instance
250
199
  * @returns {Float64Array}
@@ -252,29 +201,12 @@ export class GPUAcousticPropagation extends AcousticPropagation {
252
201
  #read_source(instance) {
253
202
  const source = this.#source;
254
203
  const position = instance.position;
255
- const directivity = instance.directivity;
256
204
 
257
205
  source[0] = position[0];
258
206
  source[1] = position[1];
259
207
  source[2] = position[2];
260
208
  source[3] = instance.sourceRadius;
261
209
 
262
- FORWARD.copy(Vector3.forward);
263
-
264
- if (directivity !== null && directivity !== undefined && !directivity.isOmni && instance.orientation !== null) {
265
- FORWARD.applyQuaternion(instance.orientation);
266
-
267
- source[7] = directivity.dipoleWeight;
268
- source[8] = directivity.dipolePower;
269
- } else {
270
- source[7] = 0;
271
- source[8] = 1;
272
- }
273
-
274
- source[4] = FORWARD.x;
275
- source[5] = FORWARD.y;
276
- source[6] = FORWARD.z;
277
-
278
210
  return source;
279
211
  }
280
212
 
@@ -331,9 +263,10 @@ export class GPUAcousticPropagation extends AcousticPropagation {
331
263
  /**
332
264
  * # The GPU acoustics of a scene
333
265
  *
334
- * GPU acoustics design, "A frame on the GPU": sound traced through the scene's brick clipmap, the world the probe
335
- * clipmap GI traces, for the {@link AcousticSimulator} it is handed. The system is the simulator's
336
- * {@link AcousticPropagation}: the simulator asks it for each live source's terms and knows nothing of the device.
266
+ * Sound traced through the scene's brick clipmap, the world the probe clipmap GI traces, for the
267
+ * {@link AcousticSimulator} it is handed: one probe at the listener, its rays' first hits the room it stands in, and
268
+ * each heard source's direct path and the share of that room it lights (`GPUAcousticProbes`). Nothing is baked. The system is the simulator's {@link AcousticPropagation}: the simulator asks
269
+ * it for each live source's terms and knows nothing of the device.
337
270
  *
338
271
  * ```js
339
272
  * const simulator = configureAcousticSimulation(configuration, audio_emitter_system);
@@ -347,18 +280,16 @@ export class GPUAcousticPropagation extends AcousticPropagation {
347
280
  * `acoustic_materials` at its row, which the brick clipmap's acoustic payload reads as each brick is built; a
348
281
  * material that changed is written again, and the cells of its row built again. A mesh with no `AcousticBody`
349
282
  * is the engine's default material, `AcousticMaterial`'s own.
350
- * - **Sources.** A live source the simulator solves is a receiver, written when it starts, moves or turns, freed
351
- * when the simulator forgets it ({@link GPUAcousticPropagation}); its terms are its receiver's results as they
352
- * last landed: the direct path's energy, the early energy and where it comes from, the late energy, its lean and
353
- * its time constant, the late energy's centre time measured from the early/late boundary. Until its first result
354
- * lands it hears its prior, the lattice's terms about it (`GPUAcousticLattice`); where the lattice has none about
355
- * it, the neutral solution.
283
+ * - **Sources.** A live source the simulator solves is a row, written when it starts or moves, freed when the simulator
284
+ * forgets it ({@link GPUAcousticPropagation}); it is traced in the frames it is heard. Its terms are its direct path
285
+ * and its share of the room as they last landed, and the room's reverb; until its first result lands, the neutral
286
+ * solution.
356
287
  * - **The apply point**: the results that landed since the last update.
357
288
  *
358
289
  * ## The GPU half, at `FramePhase.FrameStart`
359
290
  *
360
- * The phonon ring's step from the listener, then every live receiver, a workgroup each, traced through the bricks the
361
- * scene's clipmap holds from the frames before, and the results read back (`GPUAcoustics`). Nothing while the scene's
291
+ * The listener's rays and the room they make, then the heard sources' coupling and direct paths, traced through the
292
+ * bricks the scene's clipmap holds from the frames before, and what they wrote read back. Nothing while the scene's
362
293
  * clipmap is not built yet, or before the simulator has solved with a listener.
363
294
  *
364
295
  * ## Delivery
@@ -369,10 +300,13 @@ export class GPUAcousticPropagation extends AcousticPropagation {
369
300
  *
370
301
  * ## Lifetime
371
302
  *
372
- * Its device state is made when the scene first has a context: the ring and the receivers, the bricks' acoustic
373
- * records, and a hold on the scene's brick clipmap with the records as its payload, which has the clipmap built
374
- * under any lighting mode. A new context (a device restart) drops them with the old device and makes them again;
375
- * shutdown gives them back and the simulator its own propagation back.
303
+ * Its device state is made when the scene first has a context: the rows and the room, the bricks' acoustic records,
304
+ * and a hold on the scene's brick clipmap with the records as its payload, which has the clipmap built under any
305
+ * lighting mode. A new context (a device restart) drops them with the old device and makes them again; shutdown gives
306
+ * them back and the simulator its own propagation back.
307
+ *
308
+ * The path-traced acoustics (`GPUAcoustics`: the phonon ring, its receivers and the lattice) are in the tree, unwired:
309
+ * `simulation/PATH_TRACED_RESEARCH.md`.
376
310
  */
377
311
  export class GPUAcousticSystem extends System {
378
312
 
@@ -382,7 +316,7 @@ export class GPUAcousticSystem extends System {
382
316
  * @param {import("../../shade/device/pipeline/PipelineEnquiry.js").PipelineEnquiry} enquiry
383
317
  */
384
318
  static enquirePipelines(enquiry) {
385
- GPUAcoustics.enquirePipelines(enquiry);
319
+ GPUAcousticProbes.enquirePipelines(enquiry);
386
320
  enquiry.compute.push(shader_brick_acoustics_gather.pipeline);
387
321
  }
388
322
 
@@ -417,14 +351,14 @@ export class GPUAcousticSystem extends System {
417
351
  */
418
352
  #context = null;
419
353
 
420
- /** @type {GPUAcoustics|null} */
354
+ /** @type {GPUAcousticProbes|null} */
421
355
  #acoustics = null;
422
356
 
423
357
  /** The bricks' acoustic records, the scene clipmap's payload. @type {GPUBrickAcoustics|null} */
424
358
  #payload = null;
425
359
 
426
- /** @type {GPUAcousticLattice|null} */
427
- #lattice = null;
360
+ /** What a frame is recorded with, kept rather than made. */
361
+ #record_options = { graph: null, clipmap: null, payload: null, listener: null, air: null };
428
362
 
429
363
  /** The ambient medium's absorption of energy a metre, per band. */
430
364
  #air = new Float64Array(3);
@@ -432,9 +366,6 @@ export class GPUAcousticSystem extends System {
432
366
  /** @type {Map<number, BodyEntry>} */
433
367
  #bodies = new Map();
434
368
 
435
- #rotation = new Float64Array(9);
436
- #random = seededRandom(ROTATION_SEED);
437
-
438
369
  /** Scratch for a material's floats, and for one row to invalidate. */
439
370
  #material = new Float32Array(MATERIAL_FLOATS);
440
371
  #invalidated = new Uint32Array(1);
@@ -541,8 +472,8 @@ export class GPUAcousticSystem extends System {
541
472
  }
542
473
 
543
474
  /**
544
- * The frame's GPU work, at `FramePhase.FrameStart`: every live receiver, through the bricks as the frames before
545
- * left them. Recorded into the graph the renderer submits ahead of the frame (`FrameContext#early_graph`), so the
475
+ * The frame's GPU work, at `FramePhase.FrameStart`: the listener's rays and the room, then the heard sources, through
476
+ * the bricks as the frames before left them. Recorded into the graph the renderer submits ahead of the frame (`FrameContext#early_graph`), so the
546
477
  * readback lands as soon as this work is done rather than behind the frame's rendering.
547
478
  *
548
479
  * @param {FrameContext} frame
@@ -561,12 +492,7 @@ export class GPUAcousticSystem extends System {
561
492
  return;
562
493
  }
563
494
 
564
- random_orthonormal_basis(this.#rotation, 0, this.#random);
565
-
566
495
  const listener = this.#propagation.listener;
567
- const lattice = this.#lattice;
568
-
569
- lattice.place(listener[0], listener[1], listener[2]);
570
496
 
571
497
  const medium = this.#simulator.medium.airAbsorption;
572
498
  const air = this.#air;
@@ -575,17 +501,19 @@ export class GPUAcousticSystem extends System {
575
501
  air[1] = medium[1] * DB_TO_ENERGY_NEPERS;
576
502
  air[2] = medium[2] * DB_TO_ENERGY_NEPERS;
577
503
 
578
- this.#acoustics.record({
579
- graph: frame.early_graph,
580
- clipmap,
581
- payload: this.#payload,
582
- listener,
583
- rotation: this.#rotation,
584
- air,
585
- points: lattice.frame_points(),
586
- point_count: ACOUSTIC_LATTICE_POINTS_A_FRAME,
587
- });
504
+ const options = this.#record_options;
505
+
506
+ options.graph = frame.early_graph;
507
+ options.clipmap = clipmap;
508
+ options.payload = this.#payload;
509
+ options.listener = listener;
510
+ options.air = air;
511
+
512
+ this.#acoustics.record(options);
588
513
 
514
+ options.graph = null;
515
+ options.clipmap = null;
516
+ options.payload = null;
589
517
  }
590
518
 
591
519
  /**
@@ -596,8 +524,7 @@ export class GPUAcousticSystem extends System {
596
524
  const world = context.brick_clipmap;
597
525
 
598
526
  // results that land between frames reach the sources there and then: the simulator answers them again
599
- this.#acoustics = new GPUAcoustics({ device, on_landed: this.#on_landed });
600
- this.#lattice = new GPUAcousticLattice(this.#acoustics, DEFAULT_ACOUSTIC_SOURCE_RADIUS);
527
+ this.#acoustics = new GPUAcousticProbes({ device, on_landed: this.#on_landed });
601
528
 
602
529
  // the clipmap's settings are the renderer's, read when it builds: the records take its capacity at its first
603
530
  // build, and grow with it after
@@ -611,7 +538,7 @@ export class GPUAcousticSystem extends System {
611
538
  world.add_material_writer(this.#payload);
612
539
 
613
540
  this.#context = context;
614
- this.#propagation.set_acoustics(this.#acoustics, this.#lattice);
541
+ this.#propagation.set_acoustics(this.#acoustics);
615
542
 
616
543
  // every body is written into the new context's database
617
544
  for (const entry of this.#bodies.values()) {
@@ -622,7 +549,7 @@ export class GPUAcousticSystem extends System {
622
549
  #drop_device() {
623
550
  const context = this.#context;
624
551
 
625
- this.#propagation.set_acoustics(null, null);
552
+ this.#propagation.set_acoustics(null);
626
553
 
627
554
  if (context === null) {
628
555
  return;
@@ -642,11 +569,9 @@ export class GPUAcousticSystem extends System {
642
569
  }
643
570
  }
644
571
 
645
- this.#lattice.destroy();
646
572
  this.#acoustics.destroy();
647
573
  this.#payload.destroy();
648
574
 
649
- this.#lattice = null;
650
575
  this.#acoustics = null;
651
576
  this.#payload = null;
652
577
  this.#context = null;
@@ -735,7 +660,7 @@ export class GPUAcousticSystem extends System {
735
660
  GPUAcousticSystem.prototype.isGPUAcousticSystem = true;
736
661
 
737
662
  /**
738
- * Records {@link GPUAcousticSystem}'s ring and receivers at the start of a frame.
663
+ * Records {@link GPUAcousticSystem}'s listener, room and sources at the start of a frame.
739
664
  */
740
665
  export class GPUAcousticExtension extends RenderExtension {
741
666
  name = 'gpu acoustics';
@@ -67,11 +67,11 @@ export class FluidObstacleSystem extends System<any> {
67
67
  /**
68
68
  * @param {FluidComponent} fluid
69
69
  */
70
- static "__#516@#refresh_masks"(fluid: FluidComponent): void;
70
+ static "__#519@#refresh_masks"(fluid: FluidComponent): void;
71
71
  /**
72
72
  * @param {FluidComponent} fluid
73
73
  */
74
- static "__#516@#clear_field"(fluid: FluidComponent): void;
74
+ static "__#519@#clear_field"(fluid: FluidComponent): void;
75
75
  /**
76
76
  * Mark every cell of `fluid` whose centre lies within `inflation` of the
77
77
  * posed shape as solid. Iteration is clipped to the shape's world AABB
@@ -83,7 +83,7 @@ export class FluidObstacleSystem extends System<any> {
83
83
  * @param {number} inflation world-units SDF threshold
84
84
  * @param {Float64Array} point length-3 scratch
85
85
  */
86
- static "__#516@#voxelize"(fluid: FluidComponent, posed: PosedShape3D, aabb: Float64Array, inflation: number, point: Float64Array): void;
86
+ static "__#519@#voxelize"(fluid: FluidComponent, posed: PosedShape3D, aabb: Float64Array, inflation: number, point: Float64Array): void;
87
87
  /**
88
88
  * Write the obstacle's translation velocity onto every face of every cell
89
89
  * it voxelized — the moving-wall boundary condition. Runs AFTER the mask
@@ -103,7 +103,7 @@ export class FluidObstacleSystem extends System<any> {
103
103
  * @param {number} wvy
104
104
  * @param {number} wvz
105
105
  */
106
- static "__#516@#stamp_wall_velocity"(fluid: FluidComponent, posed: PosedShape3D, aabb: Float64Array, inflation: number, point: Float64Array, wvx: number, wvy: number, wvz: number): void;
106
+ static "__#519@#stamp_wall_velocity"(fluid: FluidComponent, posed: PosedShape3D, aabb: Float64Array, inflation: number, point: Float64Array, wvx: number, wvy: number, wvz: number): void;
107
107
  constructor();
108
108
  dependencies: (typeof FluidObstacle)[];
109
109
  components_used: (ResourceAccessSpecification<typeof Transform64> | ResourceAccessSpecification<typeof FluidObstacle> | ResourceAccessSpecification<typeof Collider> | ResourceAccessSpecification<typeof RigidBody> | ResourceAccessSpecification<typeof FluidComponent>)[];
@@ -1 +1 @@
1
- {"version":3,"file":"AudioEmitterSystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/sound/ecs/audio/AudioEmitterSystem.js"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH;IAyBI;;;;;OAKG;IACH,0FAHW;QAAC,MAAM,CAAC,EAAC,MAAM,CAAC;QAAC,cAAc,CAAC,EAAC,MAAM,CAAC;QAAC,cAAc,CAAC,EAAC,MAAM,CAAA;KAAC,qBA+C1E;IA1ED,2DAA2C;IAE3C;;;;;OAKG;IACH,iBAFU,kBAAkB,CAEA;IAE5B;;;OAGG;IACH,cAFU,eAAe,CAEP;IAElB;;;;;OAKG;IACH,MAFU,MAAM,EAAE,CAER;IAWN;;;;;OAKG;IACH,aAFU,oBAAkB,IAAI,CAEF;IAE9B;;OAEG;IACH,yBAA8B;IAE9B;;OAEG;IACH,iBAFU,YAAY,CAEoB;IAE1C;;OAEG;IACH,2BAAgC;IAQhC;;;OAGG;IACH,mBAAkF;IAElF;;;;OAIG;IACH,SAFU,cAAc,CAE4C;IAGxE;;;;OAIG;IACH,cAJW,YAAY,aACZ,WAAW,UACX,MAAM,QAwEhB;IAED;;;;OAIG;IACH,gBAJW,YAAY,aACZ,WAAW,UACX,MAAM,QAkChB;IAED;;;;;;OAMG;IACH,oBAHW,MAAM,GACJ,gBAAc,IAAI,CAe9B;IA0JD;;OAEG;IACH,6DAKC;IAED;;;OAGG;IACH,wCAFa,QAAQ,IAAI,CAAC,CAKzB;IAmBD,6BAmEC;;CACJ;uBA7fsB,wBAAwB;4BACnB,uCAAuC;6BAKtC,mBAAmB;+BACjB,qBAAqB"}
1
+ {"version":3,"file":"AudioEmitterSystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/sound/ecs/audio/AudioEmitterSystem.js"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH;IAyBI;;;;;OAKG;IACH,0FAHW;QAAC,MAAM,CAAC,EAAC,MAAM,CAAC;QAAC,cAAc,CAAC,EAAC,MAAM,CAAC;QAAC,cAAc,CAAC,EAAC,MAAM,CAAA;KAAC,qBA+C1E;IA1ED,2DAA2C;IAE3C;;;;;OAKG;IACH,iBAFU,kBAAkB,CAEA;IAE5B;;;OAGG;IACH,cAFU,eAAe,CAEP;IAElB;;;;;OAKG;IACH,MAFU,MAAM,EAAE,CAER;IAWN;;;;;OAKG;IACH,aAFU,oBAAkB,IAAI,CAEF;IAE9B;;OAEG;IACH,yBAA8B;IAE9B;;OAEG;IACH,iBAFU,YAAY,CAEoB;IAE1C;;OAEG;IACH,2BAAgC;IAQhC;;;OAGG;IACH,mBAAkF;IAElF;;;;OAIG;IACH,SAFU,cAAc,CAE4C;IAGxE;;;;OAIG;IACH,cAJW,YAAY,aACZ,WAAW,UACX,MAAM,QAwEhB;IAED;;;;OAIG;IACH,gBAJW,YAAY,aACZ,WAAW,UACX,MAAM,QAkChB;IAED;;;;;;OAMG;IACH,oBAHW,MAAM,GACJ,gBAAc,IAAI,CAe9B;IA0JD;;OAEG;IACH,6DAKC;IAED;;;OAGG;IACH,wCAFa,QAAQ,IAAI,CAAC,CAKzB;IA6CD,6BA2DC;;CACJ;uBA/gBsB,wBAAwB;4BACnB,uCAAuC;6BAKtC,mBAAmB;+BACjB,qBAAqB"}
@@ -424,6 +424,32 @@ export class AudioEmitterSystem extends System {
424
424
  this.#unfollow_listener();
425
425
  }
426
426
 
427
+ /**
428
+ * A direct instance into the frame's acoustic list if it is acoustic, or out of the direct set if it has ended.
429
+ * Deleting the entry being visited is allowed during `Set#forEach`. Made once.
430
+ * @type {function(EventInstance): void}
431
+ */
432
+ #collect_direct = (instance) => {
433
+ if (instance.state !== EventInstanceState.Playing) {
434
+ this.directInstances.delete(instance); // self-ended one-shot — drop
435
+ return;
436
+ }
437
+
438
+ if (instance.acoustic) {
439
+ this.acousticLive.push(instance);
440
+ }
441
+ };
442
+
443
+ /**
444
+ * A live managed instance into the frame's acoustic list if it is acoustic. Made once.
445
+ * @type {function(EventInstance): void}
446
+ */
447
+ #collect_live = (instance) => {
448
+ if (instance.acoustic) {
449
+ this.acousticLive.push(instance);
450
+ }
451
+ };
452
+
427
453
  /**
428
454
  * Stop following the listener followed now, if any.
429
455
  */
@@ -483,28 +509,20 @@ export class AudioEmitterSystem extends System {
483
509
  // Drive the acoustic simulation over the bounded live set (direct one-shots + managed live
484
510
  // instances), BEFORE the tick so a fresh solution spatializes the same frame. Enumerates only the
485
511
  // few direct instances + ≤ budget managed ones — never all registered emitters.
486
- if (this.acousticSim !== null && listenerPosition !== null) {
512
+ if (this.acousticSim !== null) {
487
513
  const live = this.acousticLive;
488
514
  live.length = 0;
489
515
 
490
- for (const instance of this.directInstances) {
491
- if (instance.state !== EventInstanceState.Playing) {
492
- this.directInstances.delete(instance); // self-ended one-shot — drop
493
- continue;
494
- }
516
+ // callbacks made once: a frame builds the list with no iterator and no closure
517
+ this.directInstances.forEach(this.#collect_direct);
518
+ this.liveSet.forEachLive(this.#collect_live);
495
519
 
496
- if (instance.acoustic) {
497
- live.push(instance);
498
- }
520
+ if (listenerPosition !== null) {
521
+ this.acousticSim.apply(live, listenerPosition);
522
+ } else {
523
+ // no listener: nothing is solved, and a source that ended is let go rather than kept for it
524
+ this.acousticSim.retain(live);
499
525
  }
500
-
501
- this.liveSet.forEachLive((instance) => {
502
- if (instance.acoustic) {
503
- live.push(instance);
504
- }
505
- });
506
-
507
- this.acousticSim.apply(live, listenerPosition);
508
526
  }
509
527
 
510
528
  sopra.update(this.webAudioContext.currentTime);
@@ -1 +1 @@
1
- {"version":3,"file":"LiveEmitterSet.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/sound/ecs/audio/LiveEmitterSet.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;IA4EI;;;OAGG;IACH,6EAFW;QAAC,MAAM,CAAC,EAAC,MAAM,CAAC;QAAC,cAAc,CAAC,EAAC,MAAM,CAAC;QAAC,cAAc,CAAC,EAAC,MAAM,CAAA;KAAC,EAO1E;IAED;;OAEG;IACH,wBAEC;IAED;;OAEG;IACH,mBAEC;IAED;;;OAGG;IACH,eAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;OAGG;IACH,mBAHW,MAAM,GACJ,gBAAc,SAAS,CAInC;IAED;;;;;;;;;;;;;OAaG;IACH,YAZW,MAAM,qCAEN,YAAY,WACZ,MAAM,aACN,OAAO,iBACP,MAAM,gBACN,aAAW,IAAI,gBACf,sBAAoB,IAAI,oBACxB,oBAAoB,GAAC,IAAI,QASnC;IAED;;;;;;;;;OASG;IACH,cAFW,MAAM,QAOhB;IAED;;;;OAIG;IACH,+CAFmC,IAAI,QAMtC;IAED;;;;;;;OAOG;IACH,kBAHW,MAAM,UACN,MAAM,QAehB;IAED;;;OAGG;IACH,eAFW,MAAM,QAwBhB;IAED;;;;;;;OAOG;IACH,0BAFW,MAAM,EAAE,GAAC,YAAY,QA+D/B;;CAsFJ;mCA7ZY,OAAO,6CAA6C,EAAE,oBAAoB"}
1
+ {"version":3,"file":"LiveEmitterSet.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/sound/ecs/audio/LiveEmitterSet.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;IA4EI;;;OAGG;IACH,6EAFW;QAAC,MAAM,CAAC,EAAC,MAAM,CAAC;QAAC,cAAc,CAAC,EAAC,MAAM,CAAC;QAAC,cAAc,CAAC,EAAC,MAAM,CAAA;KAAC,EAO1E;IAED;;OAEG;IACH,wBAEC;IAED;;OAEG;IACH,mBAEC;IAED;;;OAGG;IACH,eAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;OAGG;IACH,mBAHW,MAAM,GACJ,gBAAc,SAAS,CAInC;IAED;;;;;;;;;;;;;OAaG;IACH,YAZW,MAAM,qCAEN,YAAY,WACZ,MAAM,aACN,OAAO,iBACP,MAAM,gBACN,aAAW,IAAI,gBACf,sBAAoB,IAAI,oBACxB,oBAAoB,GAAC,IAAI,QASnC;IAED;;;;;;;;;OASG;IACH,cAFW,MAAM,QAOhB;IAED;;;;OAIG;IACH,+CAFmC,IAAI,QAKtC;IAED;;;;;;;OAOG;IACH,kBAHW,MAAM,UACN,MAAM,QAehB;IAED;;;OAGG;IACH,eAFW,MAAM,QAwBhB;IAED;;;;;;;OAOG;IACH,0BAFW,MAAM,EAAE,GAAC,YAAY,QA+D/B;;CAsFJ;mCA5ZY,OAAO,6CAA6C,EAAE,oBAAoB"}
@@ -206,9 +206,8 @@ export class LiveEmitterSet {
206
206
  * @param {function(EventInstance):void} callback
207
207
  */
208
208
  forEachLive(callback) {
209
- for (const instance of this.#live.values()) {
210
- callback(instance);
211
- }
209
+ // `Map#forEach` takes no iterator; a callback made once makes the walk allocate nothing
210
+ this.#live.forEach(callback);
212
211
  }
213
212
 
214
213
  /**
@@ -56,6 +56,13 @@ export class AcousticSimulator {
56
56
  * Nothing before an apply has asked anything, or once the propagation asked has been replaced.
57
57
  */
58
58
  refresh(): void;
59
+ /**
60
+ * A frame with no listener: nothing is solved, and every source asked about that is not in `live_instances` is let
61
+ * go, as {@link apply} lets go of the ones that left. The ones still live keep what was solved for them, for the
62
+ * listener's return.
63
+ * @param {EventInstance[]} live_instances
64
+ */
65
+ retain(live_instances: EventInstance[]): void;
59
66
  /**
60
67
  * Have the propagation forget a live instance (call when the instance ends).
61
68
  * @param {EventInstance} instance
@@ -1 +1 @@
1
- {"version":3,"file":"AcousticSimulator.d.ts","sourceRoot":"","sources":["../../../../../src/engine/sound/simulation/AcousticSimulator.js"],"names":[],"mappings":"AA2BA;;;;;;;;;GASG;AACH;IACI;;;;;OAKG;IACH,aAFU,mBAAmB,GAAC,IAAI,CAEf;IAsEnB,mCAEC;IAZD;;;;;OAKG;IACH,6BAEC;IAMD;;;OAGG;IACH,8DAEC;IAED;;OAEG;IACH,iDAEC;IAsBD;;;;;;OAMG;IACH,sBAHW,eAAe,YACf,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,QA6B5C;IAED;;;;;;OAMG;IACH,yCAFW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,QAM5C;IAED;;;;;OAKG;IACH,gBAMC;IAiGD;;;OAGG;IACH,sCAIC;;CACJ;kCAvTY,OAAO,+BAA+B,EAAE,mBAAmB;+BANzC,0BAA0B"}
1
+ {"version":3,"file":"AcousticSimulator.d.ts","sourceRoot":"","sources":["../../../../../src/engine/sound/simulation/AcousticSimulator.js"],"names":[],"mappings":"AA2BA;;;;;;;;;GASG;AACH;IACI;;;;;OAKG;IACH,aAFU,mBAAmB,GAAC,IAAI,CAEf;IAsEnB,mCAEC;IAZD;;;;;OAKG;IACH,6BAEC;IAMD;;;OAGG;IACH,8DAEC;IAED;;OAEG;IACH,iDAEC;IAsBD;;;;;;OAMG;IACH,sBAHW,eAAe,YACf,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,QA6B5C;IAED;;;;;;OAMG;IACH,yCAFW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,QAM5C;IAED;;;;;OAKG;IACH,gBAMC;IAiGD;;;;;OAKG;IACH,uBAFW,eAAe,QAqBzB;IAED;;;OAGG;IACH,sCAIC;;CACJ;kCAlVY,OAAO,+BAA+B,EAAE,mBAAmB;+BANzC,0BAA0B"}