@woosh/meep-engine 3.63.3 → 3.64.1

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 (190) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/package.json +1 -1
  3. package/src/core/color/xyz/m3_chromatic_adaptation_bradford.d.ts +14 -0
  4. package/src/core/color/xyz/m3_chromatic_adaptation_bradford.d.ts.map +1 -0
  5. package/src/core/color/xyz/m3_chromatic_adaptation_bradford.js +51 -0
  6. package/src/core/math/linalg/eigen/matrix_symmetric_3x3_eigen.d.ts +2 -1
  7. package/src/core/math/linalg/eigen/matrix_symmetric_3x3_eigen.d.ts.map +1 -1
  8. package/src/core/math/linalg/eigen/matrix_symmetric_3x3_eigen.js +51 -70
  9. package/src/core/math/linalg/eigen/matrix_symmetric_4x4_eigen.d.ts.map +1 -1
  10. package/src/core/math/linalg/eigen/matrix_symmetric_4x4_eigen.js +8 -64
  11. package/src/core/math/linalg/eigen/matrix_symmetric_jacobi_rotate_in_place.d.ts +17 -0
  12. package/src/core/math/linalg/eigen/matrix_symmetric_jacobi_rotate_in_place.d.ts.map +1 -0
  13. package/src/core/math/linalg/eigen/matrix_symmetric_jacobi_rotate_in_place.js +64 -0
  14. package/src/core/math/linalg/solve_box_constrained_qp.d.ts +30 -0
  15. package/src/core/math/linalg/solve_box_constrained_qp.d.ts.map +1 -0
  16. package/src/core/math/linalg/solve_box_constrained_qp.js +205 -0
  17. package/src/engine/graphics/texture/sampler/exr_to_sampler2d.d.ts +27 -0
  18. package/src/engine/graphics/texture/sampler/exr_to_sampler2d.d.ts.map +1 -0
  19. package/src/engine/graphics/texture/sampler/exr_to_sampler2d.js +91 -0
  20. package/src/engine/graphics/texture/sampler/sampler2d_to_exr.d.ts +23 -0
  21. package/src/engine/graphics/texture/sampler/sampler2d_to_exr.d.ts.map +1 -0
  22. package/src/engine/graphics/texture/sampler/sampler2d_to_exr.js +64 -0
  23. package/src/engine/physics/constraint/soft_spring_coefficients.d.ts +24 -0
  24. package/src/engine/physics/constraint/soft_spring_coefficients.d.ts.map +1 -0
  25. package/src/engine/physics/constraint/soft_spring_coefficients.js +38 -0
  26. package/src/engine/physics/constraint/solve_constraints.d.ts.map +1 -1
  27. package/src/engine/physics/constraint/solve_constraints.js +16 -8
  28. package/src/engine/physics/ecs/PhysicsSystem.d.ts +54 -0
  29. package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
  30. package/src/engine/physics/ecs/PhysicsSystem.js +192 -7
  31. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  32. package/src/engine/physics/inertia/world_inverse_inertia.d.ts +3 -5
  33. package/src/engine/physics/inertia/world_inverse_inertia.d.ts.map +1 -1
  34. package/src/engine/physics/inertia/world_inverse_inertia.js +3 -5
  35. package/src/engine/physics/vehicle/RaycastVehicle.d.ts +183 -12
  36. package/src/engine/physics/vehicle/RaycastVehicle.d.ts.map +1 -1
  37. package/src/engine/physics/vehicle/RaycastVehicle.js +1046 -121
  38. package/src/format/image/exr/ExrCompression.d.ts +22 -0
  39. package/src/format/image/exr/ExrCompression.d.ts.map +1 -0
  40. package/src/format/image/exr/ExrCompression.js +27 -0
  41. package/src/format/image/exr/ExrImage.d.ts +32 -0
  42. package/src/format/image/exr/ExrImage.d.ts.map +1 -0
  43. package/src/format/image/exr/ExrImage.js +32 -0
  44. package/src/format/image/exr/ExrPixelType.d.ts +13 -0
  45. package/src/format/image/exr/ExrPixelType.d.ts.map +1 -0
  46. package/src/format/image/exr/ExrPixelType.js +18 -0
  47. package/src/format/image/exr/exr_compare_names.d.ts +16 -0
  48. package/src/format/image/exr/exr_compare_names.d.ts.map +1 -0
  49. package/src/format/image/exr/exr_compare_names.js +25 -0
  50. package/src/format/image/exr/exr_constants.d.ts +49 -0
  51. package/src/format/image/exr/exr_constants.d.ts.map +1 -0
  52. package/src/format/image/exr/exr_constants.js +56 -0
  53. package/src/format/image/exr/exr_read.d.ts +32 -0
  54. package/src/format/image/exr/exr_read.d.ts.map +1 -0
  55. package/src/format/image/exr/exr_read.js +531 -0
  56. package/src/format/image/exr/exr_sample_bits.d.ts +16 -0
  57. package/src/format/image/exr/exr_sample_bits.d.ts.map +1 -0
  58. package/src/format/image/exr/exr_sample_bits.js +21 -0
  59. package/src/format/image/exr/exr_scanlines_per_chunk.d.ts +17 -0
  60. package/src/format/image/exr/exr_scanlines_per_chunk.d.ts.map +1 -0
  61. package/src/format/image/exr/exr_scanlines_per_chunk.js +31 -0
  62. package/src/format/image/exr/exr_write.d.ts +27 -0
  63. package/src/format/image/exr/exr_write.d.ts.map +1 -0
  64. package/src/format/image/exr/exr_write.js +378 -0
  65. package/src/shade/playground/probe_clipmap/index.html +5 -0
  66. package/src/shade/playground/probe_clipmap/main.d.ts.map +1 -1
  67. package/src/shade/playground/probe_clipmap/main.js +34 -1
  68. package/src/shade/playground/tonemap_sdr/README.md +11 -8
  69. package/src/shade/playground/tonemap_sdr/ToneMapCompare.js +2 -2
  70. package/src/shade/renderer/Renderer.d.ts +5 -6
  71. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  72. package/src/shade/renderer/Renderer.js +15 -88
  73. package/src/shade/renderer/animation/chunk_animation_curve_evaluate_keys.d.ts +14 -0
  74. package/src/shade/renderer/animation/chunk_animation_curve_evaluate_keys.d.ts.map +1 -0
  75. package/src/shade/renderer/animation/chunk_animation_curve_evaluate_keys.js +62 -0
  76. package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts +158 -0
  77. package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts.map +1 -0
  78. package/src/shade/renderer/deferred/tonemap/ColorGrade.js +337 -0
  79. package/src/shade/renderer/deferred/tonemap/SAMPLER_TONEMAP_LUT.d.ts +9 -0
  80. package/src/shade/renderer/deferred/tonemap/SAMPLER_TONEMAP_LUT.d.ts.map +1 -0
  81. package/src/shade/renderer/deferred/tonemap/SAMPLER_TONEMAP_LUT.js +15 -0
  82. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_ACES.d.ts +6 -0
  83. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_ACES.d.ts.map +1 -0
  84. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_ACES.js +84 -0
  85. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_GT7.d.ts +10 -0
  86. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_GT7.d.ts.map +1 -0
  87. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_GT7.js +25 -0
  88. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_NONE.d.ts +9 -0
  89. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_NONE.d.ts.map +1 -0
  90. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_NONE.js +20 -0
  91. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_PBR_NEUTRAL.d.ts +14 -0
  92. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_PBR_NEUTRAL.d.ts.map +1 -0
  93. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_PBR_NEUTRAL.js +30 -0
  94. package/src/shade/renderer/deferred/tonemap/ToneMapOperator.d.ts +54 -0
  95. package/src/shade/renderer/deferred/tonemap/ToneMapOperator.d.ts.map +1 -0
  96. package/src/shade/renderer/deferred/tonemap/ToneMapOperator.js +63 -0
  97. package/src/shade/renderer/deferred/tonemap/ToneMapper.d.ts +106 -0
  98. package/src/shade/renderer/deferred/tonemap/ToneMapper.d.ts.map +1 -0
  99. package/src/shade/renderer/deferred/tonemap/ToneMapper.js +474 -0
  100. package/src/shade/renderer/deferred/tonemap/TonemapAces2Tables.d.ts +5 -13
  101. package/src/shade/renderer/deferred/tonemap/TonemapAces2Tables.d.ts.map +1 -1
  102. package/src/shade/renderer/deferred/tonemap/TonemapAces2Tables.js +5 -44
  103. package/src/shade/renderer/deferred/tonemap/TonemapDisplaySettings.d.ts +7 -25
  104. package/src/shade/renderer/deferred/tonemap/TonemapDisplaySettings.d.ts.map +1 -1
  105. package/src/shade/renderer/deferred/tonemap/TonemapDisplaySettings.js +11 -51
  106. package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.d.ts +20 -0
  107. package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.d.ts.map +1 -0
  108. package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.js +103 -0
  109. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_lut.d.ts +9 -0
  110. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_lut.d.ts.map +1 -0
  111. package/src/shade/renderer/deferred/tonemap/{shader_tonemap_HDR_none.js → shader_tonemap_HDR_lut.js} +22 -18
  112. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_lut.d.ts +9 -0
  113. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_lut.d.ts.map +1 -0
  114. package/src/shade/renderer/deferred/tonemap/{shader_tonemap_LDR_aces.js → shader_tonemap_LDR_lut.js} +24 -24
  115. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_bake.d.ts +23 -0
  116. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_bake.d.ts.map +1 -0
  117. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_bake.js +92 -0
  118. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_sdr_from_hdr.d.ts +15 -0
  119. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_sdr_from_hdr.d.ts.map +1 -0
  120. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_sdr_from_hdr.js +73 -0
  121. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  122. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  123. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +6 -6
  124. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  125. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  126. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +1 -1
  127. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts +3 -15
  128. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts.map +1 -1
  129. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.js +4 -17
  130. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts +3 -3
  131. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts.map +1 -1
  132. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.js +15 -13
  133. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.d.ts +7 -3
  134. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.d.ts.map +1 -1
  135. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.js +28 -17
  136. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.d.ts +18 -18
  137. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.d.ts.map +1 -1
  138. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.js +44 -48
  139. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  140. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  141. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts +22 -0
  142. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts.map +1 -0
  143. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.js +62 -0
  144. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.d.ts +13 -0
  145. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.d.ts.map +1 -0
  146. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.js +140 -0
  147. package/src/shade/renderer/shader/chunk/color/oklab/chunk_oklab_compute_max_saturation.d.ts +11 -0
  148. package/src/shade/renderer/shader/chunk/color/oklab/chunk_oklab_compute_max_saturation.d.ts.map +1 -0
  149. package/src/shade/renderer/shader/chunk/color/oklab/chunk_oklab_compute_max_saturation.js +65 -0
  150. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_bt2390_eetf.d.ts +14 -0
  151. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_bt2390_eetf.d.ts.map +1 -0
  152. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_bt2390_eetf.js +38 -0
  153. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_lut.d.ts +16 -0
  154. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_lut.d.ts.map +1 -0
  155. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_lut.js +41 -0
  156. package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.d.ts +8 -0
  157. package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.d.ts.map +1 -1
  158. package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.js +21 -3
  159. package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
  160. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +8 -8
  161. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
  162. package/src/shade/wgsl/emulator/WGSLLanguageCore.js +2 -0
  163. package/src/shade/renderer/ShadeToneMappingMode.d.ts +0 -15
  164. package/src/shade/renderer/ShadeToneMappingMode.d.ts.map +0 -1
  165. package/src/shade/renderer/ShadeToneMappingMode.js +0 -41
  166. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR.d.ts +0 -9
  167. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR.d.ts.map +0 -1
  168. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR.js +0 -79
  169. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_aces.d.ts +0 -17
  170. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_aces.d.ts.map +0 -1
  171. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_aces.js +0 -101
  172. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_none.d.ts +0 -9
  173. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_none.d.ts.map +0 -1
  174. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_pbr_neutral.d.ts +0 -10
  175. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_pbr_neutral.d.ts.map +0 -1
  176. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_pbr_neutral.js +0 -80
  177. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR.d.ts +0 -9
  178. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR.d.ts.map +0 -1
  179. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR.js +0 -80
  180. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_aces.d.ts +0 -10
  181. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_aces.d.ts.map +0 -1
  182. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_none.d.ts +0 -9
  183. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_none.d.ts.map +0 -1
  184. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_none.js +0 -71
  185. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_pbr_neutral.d.ts +0 -10
  186. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_pbr_neutral.d.ts.map +0 -1
  187. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_pbr_neutral.js +0 -76
  188. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_hdr_bt2390.d.ts +0 -3
  189. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_hdr_bt2390.d.ts.map +0 -1
  190. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_hdr_bt2390.js +0 -44
@@ -68,18 +68,71 @@ import { RigidBodyFlags } from "./RigidBodyFlags.js";
68
68
  import { SleepState } from "./SleepState.js";
69
69
 
70
70
  /**
71
- * Scratch for {@link applyImpulseAt}'s angular delta calculation.
71
+ * Scratch for the angular velocity change {@link applyImpulseAt} and
72
+ * {@link predictStepMeanVelocity} work out.
72
73
  * @type {Float64Array}
73
74
  */
74
75
  const scratch_angular_delta = new Float64Array(3);
75
76
 
76
77
  /**
77
- * Scratch for {@link applyImpulseAt}'s LockRot*-masked inverse-inertia
78
- * diagonal (the same mask {@link SolverBodyState#gather} applies).
78
+ * Scratch for the LockRot*-masked inverse-inertia diagonal (the same mask
79
+ * {@link SolverBodyState#gather} applies) of {@link applyImpulseAt} and
80
+ * {@link predictStepMeanVelocity}.
79
81
  * @type {Float64Array}
80
82
  */
81
83
  const scratch_locked_inertia = new Float64Array(3);
82
84
 
85
+ /**
86
+ * The damping and the substep {@link substep_mean_shares} reads.
87
+ * @type {Float64Array}
88
+ */
89
+ const scratch_mean_params = new Float64Array(2);
90
+
91
+ /**
92
+ * The shares {@link substep_mean_shares} writes.
93
+ * @type {Float64Array}
94
+ */
95
+ const scratch_mean_shares = new Float64Array(2);
96
+
97
+ /**
98
+ * The mean of the velocities that `count` substeps of {@link integrate_velocity_gravity} at `h` leave, one
99
+ * after each, as shares: `out[0]` of the velocity they start from, and `out[1]` of the gravity they add
100
+ * together, `gravity·gravityScale·h·count`.
101
+ *
102
+ * A substep adds `gravity·gravityScale·h` and then decays the velocity by `k = 1/(1 + damping·h)`, or not
103
+ * at all unless the damping is above 0. After substep `i` that leaves `kⁱ` of the velocity the substeps
104
+ * started from, and `Σⱼ₌₁…ᵢ kʲ` substeps' worth of gravity; so over `n = count` substeps
105
+ *
106
+ * out[0] = (1/n)·Σᵢ₌₁…ₙ kⁱ, out[1] = (1/n²)·Σᵢ₌₁…ₙ Σⱼ₌₁…ᵢ kʲ,
107
+ *
108
+ * 1 and `(n + 1)/(2n)` undamped. Summed term by term, as exact for a damping near 0 as for any other.
109
+ *
110
+ * Reads the damping (per second) at `params[0]` and `h` (seconds) at `params[1]`. They travel in an array
111
+ * because a number handed to a call V8 does not inline is boxed into a new heap object.
112
+ *
113
+ * @param {Float64Array} out
114
+ * @param {Float64Array} params
115
+ * @param {number} count substeps, at least 1
116
+ */
117
+ function substep_mean_shares(out, params, count) {
118
+ const damping = params[0];
119
+ const h = params[1];
120
+ const k = damping > 0 ? 1 / (1 + damping * h) : 1;
121
+
122
+ let power = 1; // kⁱ
123
+ let sum = 0; // Σⱼ₌₁…ᵢ kʲ
124
+ let sum_of_sums = 0;
125
+
126
+ for (let i = 0; i < count; i++) {
127
+ power *= k;
128
+ sum += power;
129
+ sum_of_sums += sum;
130
+ }
131
+
132
+ out[0] = sum / count;
133
+ out[1] = sum_of_sums / (count * count);
134
+ }
135
+
83
136
  /**
84
137
  * Reusable scratch buffer for world-AABB construction so the link path is
85
138
  * allocation-free in steady state.
@@ -1377,6 +1430,141 @@ export class PhysicsSystem extends System {
1377
1430
  this.__wake_body(rigidBody);
1378
1431
  }
1379
1432
 
1433
+ /**
1434
+ * The mean velocity a body will have across the next {@link fixedUpdate}`(dt)` under what already
1435
+ * acts on it: gravity, its damping, and the force and torque accumulated so far, with no contact or
1436
+ * joint. Its displacement over that step is this times `dt`.
1437
+ *
1438
+ * The accumulated force and torque are spent before the substeps, as is an impulse applied before
1439
+ * the step ({@link applyImpulseAt}): the mean keeps {@link predictStepMeanVelocityShare} of the
1440
+ * velocity change each makes, all of it on a body nothing damps. Gravity enters at each of the `N`
1441
+ * {@link substeps}: it adds `gravity·gravityScale·dt` to an undamped body's end velocity, but only
1442
+ * `(N + 1)/(2N)` of that to its mean. A damping above 0 decays the velocity at each substep by
1443
+ * `k = 1/(1 + damping·dt/N)`, so the mean keeps `(1/N)·Σᵢ kⁱ` of the velocity the substeps start
1444
+ * from and `(1/N²)·Σᵢ Σⱼ₌₁…ᵢ kʲ` of the step's gravity, `i = 1…N`; the angular velocity decays the
1445
+ * same way at the angular damping. A controller that works out its impulses from where the coming
1446
+ * step will carry the body predicts that motion with this.
1447
+ *
1448
+ * A body that is not Dynamic is predicted to keep its velocity, as a kinematic body moving at the
1449
+ * velocity it carries does. A KinematicPosition body given a target for the step
1450
+ * ({@link setTargetPose}) takes the velocity that reaches the target instead, and a Static body does
1451
+ * not move.
1452
+ *
1453
+ * @param {Float64Array|number[]} linear receives the mean linear velocity, indexed as [x, y, z]
1454
+ * @param {Float64Array|number[]} angular receives the mean angular velocity, indexed as [x, y, z]
1455
+ * @param {RigidBody} rigidBody
1456
+ * @param {Transform64} transform the body's world transform
1457
+ * @param {number} dt seconds, the step the next fixedUpdate takes
1458
+ */
1459
+ predictStepMeanVelocity(linear, angular, rigidBody, transform, dt) {
1460
+ const lv = rigidBody.linearVelocity;
1461
+ const av = rigidBody.angularVelocity;
1462
+
1463
+ if (rigidBody.kind !== BodyKind.Dynamic) {
1464
+ linear[0] = lv[0];
1465
+ linear[1] = lv[1];
1466
+ linear[2] = lv[2];
1467
+
1468
+ angular[0] = av[0];
1469
+ angular[1] = av[1];
1470
+ angular[2] = av[2];
1471
+
1472
+ return;
1473
+ }
1474
+
1475
+ const substeps = this.__substep_count();
1476
+ const inv_m = rigidBody.mass > 0 ? 1 / rigidBody.mass : 0;
1477
+ const af = rigidBody.accumulatedForce;
1478
+ const g = this.gravity;
1479
+
1480
+ scratch_mean_params[0] = rigidBody.linearDamping;
1481
+ scratch_mean_params[1] = dt / substeps;
1482
+ substep_mean_shares(scratch_mean_shares, scratch_mean_params, substeps);
1483
+
1484
+ const share = scratch_mean_shares[0];
1485
+ const gravity_share = rigidBody.gravityScale * dt * scratch_mean_shares[1];
1486
+
1487
+ linear[0] = share * (lv[0] + af[0] * inv_m * dt) + g[0] * gravity_share;
1488
+ linear[1] = share * (lv[1] + af[1] * inv_m * dt) + g[1] * gravity_share;
1489
+ linear[2] = share * (lv[2] + af[2] * inv_m * dt) + g[2] * gravity_share;
1490
+
1491
+ scratch_mean_params[0] = rigidBody.angularDamping;
1492
+ substep_mean_shares(scratch_mean_shares, scratch_mean_params, substeps);
1493
+
1494
+ const angular_share = scratch_mean_shares[0];
1495
+
1496
+ const at = rigidBody.accumulatedTorque;
1497
+
1498
+ if (at[0] !== 0 || at[1] !== 0 || at[2] !== 0) {
1499
+ locked_inverse_inertia(scratch_locked_inertia, 0, rigidBody);
1500
+ world_inverse_inertia_apply_raw(
1501
+ scratch_angular_delta, 0,
1502
+ scratch_locked_inertia[0], scratch_locked_inertia[1], scratch_locked_inertia[2],
1503
+ transform.rotation_x, transform.rotation_y, transform.rotation_z, transform.rotation_w,
1504
+ at[0], at[1], at[2]
1505
+ );
1506
+
1507
+ angular[0] = angular_share * (av[0] + scratch_angular_delta[0] * dt);
1508
+ angular[1] = angular_share * (av[1] + scratch_angular_delta[1] * dt);
1509
+ angular[2] = angular_share * (av[2] + scratch_angular_delta[2] * dt);
1510
+ } else {
1511
+ angular[0] = angular_share * av[0];
1512
+ angular[1] = angular_share * av[1];
1513
+ angular[2] = angular_share * av[2];
1514
+ }
1515
+ }
1516
+
1517
+ /**
1518
+ * How much of a change to a body's velocity, made before the next {@link fixedUpdate}`(dt)`, its mean
1519
+ * velocity across that step keeps, with no contact or joint: `out[0]` of a change to its linear
1520
+ * velocity, `out[1]` of one to its angular velocity. An impulse applied before the step
1521
+ * ({@link applyImpulseAt}) moves the {@link predictStepMeanVelocity} by these times the velocity
1522
+ * change it makes. A controller that solves for impulses against that motion takes their effect on
1523
+ * it from these.
1524
+ *
1525
+ * A damping above 0 decays the velocity at each of the `N` {@link substeps} by
1526
+ * `k = 1/(1 + damping·dt/N)`, so the mean keeps `(1/N)·Σᵢ₌₁…ₙ kⁱ` of a change: 1 for a body nothing
1527
+ * damps, less the more it is damped and the longer the step. A body that is not Dynamic: 1 and 1,
1528
+ * nothing damps it — as {@link predictStepMeanVelocity} predicts it to keep its velocity, with the
1529
+ * same exceptions.
1530
+ *
1531
+ * @param {Float64Array|number[]} out receives the linear share at [0] and the angular share at [1]
1532
+ * @param {RigidBody} rigidBody
1533
+ * @param {number} dt seconds, the step the next fixedUpdate takes
1534
+ */
1535
+ predictStepMeanVelocityShare(out, rigidBody, dt) {
1536
+ if (rigidBody.kind !== BodyKind.Dynamic) {
1537
+ out[0] = 1;
1538
+ out[1] = 1;
1539
+
1540
+ return;
1541
+ }
1542
+
1543
+ const substeps = this.__substep_count();
1544
+
1545
+ scratch_mean_params[0] = rigidBody.linearDamping;
1546
+ scratch_mean_params[1] = dt / substeps;
1547
+ substep_mean_shares(scratch_mean_shares, scratch_mean_params, substeps);
1548
+
1549
+ out[0] = scratch_mean_shares[0];
1550
+
1551
+ scratch_mean_params[0] = rigidBody.angularDamping;
1552
+ substep_mean_shares(scratch_mean_shares, scratch_mean_params, substeps);
1553
+
1554
+ out[1] = scratch_mean_shares[0];
1555
+ }
1556
+
1557
+ /**
1558
+ * The number of substeps {@link fixedUpdate} divides a step into: {@link substeps}, truncated, and 1
1559
+ * for anything below 2 — a count of 0, negative or fractional would make the substep `dt / N`
1560
+ * infinite and the loop bound meaningless.
1561
+ * @private
1562
+ * @returns {number}
1563
+ */
1564
+ __substep_count() {
1565
+ return this.substeps > 1 ? this.substeps | 0 : 1;
1566
+ }
1567
+
1380
1568
  /**
1381
1569
  * Replace the linear velocity. Wakes the body if asleep.
1382
1570
  *
@@ -2599,10 +2787,7 @@ export class PhysicsSystem extends System {
2599
2787
  // separate between substeps — the TGS stack-stability mechanism —
2600
2788
  // without re-running narrowphase. Restitution is applied after the
2601
2789
  // loop.
2602
- // Clamp the substep count: 0 (or a negative / fractional value) would
2603
- // feed h = dt / N = Infinity into prepare_contacts and a broken loop
2604
- // bound into the solver.
2605
- const N = this.substeps > 1 ? this.substeps | 0 : 1;
2790
+ const N = this.__substep_count();
2606
2791
  const h = dt / N;
2607
2792
  const count_after_wake = storage.awake_count;
2608
2793
 
@@ -66,11 +66,11 @@ export class FluidObstacleSystem extends System<any> {
66
66
  /**
67
67
  * @param {FluidComponent} fluid
68
68
  */
69
- static "__#487@#refresh_masks"(fluid: FluidComponent): void;
69
+ static "__#490@#refresh_masks"(fluid: FluidComponent): void;
70
70
  /**
71
71
  * @param {FluidComponent} fluid
72
72
  */
73
- static "__#487@#clear_field"(fluid: FluidComponent): void;
73
+ static "__#490@#clear_field"(fluid: FluidComponent): void;
74
74
  /**
75
75
  * Mark every cell of `fluid` whose centre lies within `inflation` of the
76
76
  * posed shape as solid. Iteration is clipped to the shape's world AABB
@@ -82,7 +82,7 @@ export class FluidObstacleSystem extends System<any> {
82
82
  * @param {number} inflation world-units SDF threshold
83
83
  * @param {Float64Array} point length-3 scratch
84
84
  */
85
- static "__#487@#voxelize"(fluid: FluidComponent, posed: PosedShape3D, aabb: Float64Array, inflation: number, point: Float64Array): void;
85
+ static "__#490@#voxelize"(fluid: FluidComponent, posed: PosedShape3D, aabb: Float64Array, inflation: number, point: Float64Array): void;
86
86
  /**
87
87
  * Write the obstacle's translation velocity onto every face of every cell
88
88
  * it voxelized — the moving-wall boundary condition. Runs AFTER the mask
@@ -102,7 +102,7 @@ export class FluidObstacleSystem extends System<any> {
102
102
  * @param {number} wvy
103
103
  * @param {number} wvz
104
104
  */
105
- static "__#487@#stamp_wall_velocity"(fluid: FluidComponent, posed: PosedShape3D, aabb: Float64Array, inflation: number, point: Float64Array, wvx: number, wvy: number, wvz: number): void;
105
+ static "__#490@#stamp_wall_velocity"(fluid: FluidComponent, posed: PosedShape3D, aabb: Float64Array, inflation: number, point: Float64Array, wvx: number, wvy: number, wvz: number): void;
106
106
  constructor();
107
107
  dependencies: (typeof FluidObstacle)[];
108
108
  components_used: (ResourceAccessSpecification<typeof Transform64> | ResourceAccessSpecification<typeof FluidObstacle> | ResourceAccessSpecification<typeof Collider> | ResourceAccessSpecification<typeof RigidBody> | ResourceAccessSpecification<typeof FluidComponent>)[];
@@ -39,11 +39,9 @@ export function world_inverse_inertia_apply(result: number[] | Float64Array, res
39
39
  * is the body-relative application point. The full constraint denominator is
40
40
  * `invM_A + invM_B + contribution_A + contribution_B`.
41
41
  *
42
- * The shared kernel behind the contact/joint solver's SoA path and the
43
- * raycast-vehicle's component path — each previously inlined the cross
44
- * product + {@link world_inverse_inertia_apply_raw} + dot themselves.
45
- * Identical operation order in every caller keeps the paths bit-identical
46
- * (the determinism contract): the arithmetic is
42
+ * The kernel the contact/joint solver's SoA path and the CCD sweep's component
43
+ * path share. Identical operation order in every caller keeps the paths
44
+ * bit-identical (the determinism contract): the arithmetic is
47
45
  * {@link angular_effective_mass_array}'s, which this packs its scalars for.
48
46
  *
49
47
  * @param {number} ix
@@ -1 +1 @@
1
- {"version":3,"file":"world_inverse_inertia.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/inertia/world_inverse_inertia.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,oDAXW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,qBACN,MAAM,EAAE,GAAC,YAAY,YAErB,MAAM,EAAE,GAAC,YAAY,MAGrB,MAAM,MACN,MAAM,MACN,MAAM,QAkBhB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,+CAhBW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,WACN,MAAM,EAAE,GAAC,YAAY,GACnB,MAAM,CA4BlB;AAOD;;;;;;;;;;;;;;;;GAgBG;AACH,qDAZW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,eACN,MAAM,EAAE,GAAC,YAAY,sBACrB,MAAM,YACN,MAAM,EAAE,GAAC,YAAY,mBACrB,MAAM,SACN,MAAM,EAAE,GAAC,YAAY,gBACrB,MAAM,QACN,MAAM,EAAE,GAAC,YAAY,eACrB,MAAM,WACN,MAAM,EAAE,GAAC,YAAY,QA6B/B;AAKD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wDAbW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAsBhB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,0DATW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,eACN,MAAM,EAAE,GAAC,YAAY,sBACrB,MAAM,YACN,MAAM,EAAE,GAAC,YAAY,mBACrB,MAAM,KACN,MAAM,EAAE,GAAC,YAAY,YACrB,MAAM,QAwDhB"}
1
+ {"version":3,"file":"world_inverse_inertia.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/inertia/world_inverse_inertia.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,oDAXW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,qBACN,MAAM,EAAE,GAAC,YAAY,YAErB,MAAM,EAAE,GAAC,YAAY,MAGrB,MAAM,MACN,MAAM,MACN,MAAM,QAkBhB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,+CAhBW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,WACN,MAAM,EAAE,GAAC,YAAY,GACnB,MAAM,CA4BlB;AAOD;;;;;;;;;;;;;;;;GAgBG;AACH,qDAZW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,eACN,MAAM,EAAE,GAAC,YAAY,sBACrB,MAAM,YACN,MAAM,EAAE,GAAC,YAAY,mBACrB,MAAM,SACN,MAAM,EAAE,GAAC,YAAY,gBACrB,MAAM,QACN,MAAM,EAAE,GAAC,YAAY,eACrB,MAAM,WACN,MAAM,EAAE,GAAC,YAAY,QA6B/B;AAKD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wDAbW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAsBhB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,0DATW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,eACN,MAAM,EAAE,GAAC,YAAY,sBACrB,MAAM,YACN,MAAM,EAAE,GAAC,YAAY,mBACrB,MAAM,KACN,MAAM,EAAE,GAAC,YAAY,YACrB,MAAM,QAwDhB"}
@@ -56,11 +56,9 @@ export function world_inverse_inertia_apply(
56
56
  * is the body-relative application point. The full constraint denominator is
57
57
  * `invM_A + invM_B + contribution_A + contribution_B`.
58
58
  *
59
- * The shared kernel behind the contact/joint solver's SoA path and the
60
- * raycast-vehicle's component path — each previously inlined the cross
61
- * product + {@link world_inverse_inertia_apply_raw} + dot themselves.
62
- * Identical operation order in every caller keeps the paths bit-identical
63
- * (the determinism contract): the arithmetic is
59
+ * The kernel the contact/joint solver's SoA path and the CCD sweep's component
60
+ * path share. Identical operation order in every caller keeps the paths
61
+ * bit-identical (the determinism contract): the arithmetic is
64
62
  * {@link angular_effective_mass_array}'s, which this packs its scalars for.
65
63
  *
66
64
  * @param {number} ix
@@ -25,13 +25,22 @@ export class Wheel {
25
25
  contactNormal: Float64Array;
26
26
  /** Body id of the surface under the wheel, or −1. */
27
27
  contactBodyId: number;
28
- /** Current steering angle (rad), set via {@link RaycastVehicle#setSteering}. */
28
+ /**
29
+ * This wheel's steering angle (rad): its forward direction turned about its suspension axis, toward
30
+ * `up × forward` when positive. {@link RaycastVehicle#setSteering} sets every steered wheel's.
31
+ */
29
32
  steering: number;
30
33
  /** Accumulated spin angle (rad) for rendering. */
31
34
  rotation: number;
32
- /** Forward ground speed at the contact (m/s). */
35
+ /**
36
+ * Forward ground speed at the contact across the coming step (m/s): the chassis' mean velocity there
37
+ * over the step, along the wheel's forward direction, with every impulse of the update in it.
38
+ */
33
39
  forwardSpeed: number;
34
- /** Suspension force magnitude applied this frame (N). */
40
+ /**
41
+ * The suspension's push in the last {@link RaycastVehicle#update}, as a force: the impulse it
42
+ * applied along the contact normal, divided by the step (N).
43
+ */
35
44
  suspensionForce: number;
36
45
  suspensionRestLength: number;
37
46
  suspensionLength: number;
@@ -50,13 +59,101 @@ export class RaycastVehicle {
50
59
  __drivenCount: number;
51
60
  __ray: Ray3;
52
61
  __hit: PhysicsSurfacePoint;
53
- __force: Float64Array;
62
+ /** Reused impulse payload for applyImpulseAt. @type {Float64Array} */
63
+ __impulse: Float64Array;
64
+ /**
65
+ * The chassis' mean linear and angular velocity across the coming step: before the springs push, for
66
+ * the spring solves; with them pushing, while the tyres solve and for each wheel's ground speed.
67
+ * @type {Float64Array}
68
+ */
69
+ __mean_linear: Float64Array;
70
+ /** @type {Float64Array} */
71
+ __mean_angular: Float64Array;
72
+ /** The chassis' mean velocity across the step per unit impulse applied before it, `M⁻¹`'s linear part. */
73
+ __mean_inverse_mass: number;
74
+ /**
75
+ * `M⁻¹`'s angular part, as the chassis' body-local inverse inertia diagonal (LockRot*-masked) times the
76
+ * angular share: turned to the world by the pose, its mean spin across the step per unit angular impulse.
77
+ * @type {Float64Array}
78
+ */
79
+ __mean_inverse_inertia: Float64Array;
80
+ /** Contact normal, forward and side directions (at FRAME_*), 9 per wheel. @type {Float64Array} */
81
+ __wheel_frame: Float64Array;
82
+ /** The contact's offset from the chassis' centre, 3 per wheel. @type {Float64Array} */
83
+ __wheel_lever: Float64Array;
84
+ /** 1 where the forward direction lies in the contact plane, so the tyre can grip and roll. @type {Uint8Array} */
85
+ __wheel_rolls: Uint8Array;
86
+ /**
87
+ * The tyre impulse the wheel applied in the last update, along its forward and side directions, 2 per
88
+ * wheel; zero for a wheel that applied none.
89
+ * @type {Float64Array}
90
+ */
91
+ __wheel_tyre: Float64Array;
92
+ /** The most impulse the tyre may apply this step, `μ·N·dt`. @type {Float64Array} */
93
+ __wheel_budget: Float64Array;
94
+ /**
95
+ * The brake's part of the forward impulse in {@link __wheel_tyre}: what the tyre applied along its
96
+ * forward direction, less the drive. The tyre starts the next update from it.
97
+ * @type {Float64Array}
98
+ */
99
+ __wheel_brake: Float64Array;
100
+ /**
101
+ * The chassis' mean velocity across the step per unit tyre impulse, the free springs answering it:
102
+ * `W·Jᵀ` for the forward, then the side direction, each linear then angular, 12 per wheel.
103
+ * @type {Float64Array}
104
+ */
105
+ __wheel_response: Float64Array;
106
+ /**
107
+ * The wheel's block of `J·W·Jᵀ`, how a unit tyre impulse changes its patch's slip: forward on forward,
108
+ * side on side, and either on the other, 3 per wheel.
109
+ * @type {Float64Array}
110
+ */
111
+ __wheel_block: Float64Array;
112
+ /** How many there are. */
113
+ __free_count: number;
114
+ /** Their rows. @type {Uint32Array} */
115
+ __free_row: Uint32Array;
54
116
  /**
55
- * World contact point handed to applyForceAt / applyImpulseAt, which read a pose by index so a
56
- * transform's own translation view can go straight in.
117
+ * Their block of {@link __row_matrix}, `J_s·M⁻¹·J_sᵀ + Γ`, times {@link __free_scale}, LU-factored.
57
118
  * @type {Float64Array}
58
119
  */
59
- __point: Float64Array;
120
+ __free_matrix: Float64Array;
121
+ /** The LU factorisation's pivots. @type {Uint32Array} */
122
+ __free_pivot: Uint32Array;
123
+ /** One over the block's largest diagonal. */
124
+ __free_scale: number;
125
+ /** Each free spring's speed per unit of one tyre impulse, `J_s·M⁻¹·Jᵀ`. @type {Float64Array} */
126
+ __free_speed: Float64Array;
127
+ /**
128
+ * How much less each free spring pushes per unit of one tyre impulse,
129
+ * `(J_s·M⁻¹·J_sᵀ + Γ)⁻¹·J_s·M⁻¹·Jᵀ`.
130
+ * @type {Float64Array}
131
+ */
132
+ __free_answer: Float64Array;
133
+ /** The wheel. @type {Uint32Array} */
134
+ __row_wheel: Uint32Array;
135
+ /** The contact normal `n`, then `r × n`, 6 per row. @type {Float64Array} */
136
+ __row_jacobian: Float64Array;
137
+ /**
138
+ * `M⁻¹`'s angular part on `r × n`: the chassis' mean spin across the step per unit impulse along the row,
139
+ * 3 per row.
140
+ * @type {Float64Array}
141
+ */
142
+ __row_response: Float64Array;
143
+ /** The spring's compliance `γ`. @type {Float64Array} */
144
+ __row_compliance: Float64Array;
145
+ /** `β·x`, the velocity the spring restores at. @type {Float64Array} */
146
+ __row_restore: Float64Array;
147
+ /** `β·x − J·v̄`: what the spring asks for against where the step carries the chassis. @type {Float64Array} */
148
+ __row_rhs: Float64Array;
149
+ /** The least impulse: a spring does not pull. @type {Float64Array} */
150
+ __row_lower: Float64Array;
151
+ /** The most impulse, `suspensionMaxForce·dt`. @type {Float64Array} */
152
+ __row_upper: Float64Array;
153
+ /** The impulses solved for. @type {Float64Array} */
154
+ __row_impulse: Float64Array;
155
+ /** Rows × rows, column-major: `J·M⁻¹·Jᵀ` plus each row's compliance on the diagonal. @type {Float64Array} */
156
+ __row_matrix: Float64Array;
60
157
  system: PhysicsSystem;
61
158
  chassisBody: RigidBody;
62
159
  chassisTransform: Transform64;
@@ -92,19 +189,93 @@ export class RaycastVehicle {
92
189
  steered?: boolean;
93
190
  driven?: boolean;
94
191
  }): Wheel;
95
- /** Set the steering angle (rad) on every steered wheel. */
96
- setSteering(angle: any): void;
192
+ /**
193
+ * Steer: turn every steered wheel so that its axle passes through one turn centre on a line across the
194
+ * chassis, and the tyres' grips agree on the point the chassis turns about. Each wheel's own angle goes
195
+ * into its {@link Wheel#steering}, from the wheels as they are configured when this is called. The
196
+ * wheels are taken to share their suspension axis and their straight-ahead direction, as a car's do;
197
+ * where they differ, their axles need not meet.
198
+ *
199
+ * The line passes through the unsteered wheels' mean mount position: the line their axles share.
200
+ * Where they sit on more than one line, no centre suits them all, and this one leaves them the least
201
+ * side slip, summed in squares. With every wheel steered, it passes through all the wheels' mean
202
+ * position: the line that needs the least steering, summed in squares, in a gentle turn.
203
+ *
204
+ * `angle` is the single-track ("bicycle") model's steering angle of the steered wheels farthest from
205
+ * the line, which turn the most: that of one wheel standing at the steered wheels' mean place across
206
+ * the chassis and as far ahead of the line as they are from it, with its axle through the centre.
207
+ * Steered wheels nearer the line turn less, and one on it changes nothing. Positive turns the chassis
208
+ * toward `up × forward` (+x for the default axes), where a positive {@link Wheel#steering} turns a
209
+ * wheel's forward direction; a steered wheel behind the line turns the other way. At 0 every wheel
210
+ * points straight. At ±π/2 the chassis pivots about the point of the line beside that one wheel, and
211
+ * the steered wheels on the inside of it turn past π/2. With every steered wheel on the line, to the
212
+ * rounding of the mean positions, none can move the centre along it, and each points straight.
213
+ *
214
+ * @param {number} angle radians
215
+ */
216
+ setSteering(angle: number): void;
97
217
  /** Total engine drive force (N), split evenly across the driven wheels. */
98
218
  setDriveForce(force: any): void;
99
219
  /** Brake force (N) per wheel, opposing each wheel's forward motion. */
100
220
  setBrake(force: any): void;
101
221
  /**
102
- * Step the vehicle: cast suspension rays, apply suspension + tyre forces.
103
- * Call once per frame **before** `PhysicsSystem.fixedUpdate(dt)` with the
104
- * same `dt`.
222
+ * Size the per-wheel and per-row storage for `wheel_count` wheels, keeping each wheel's last tyre
223
+ * impulse and its brake's part.
224
+ * @param {number} wheel_count
225
+ * @private
226
+ */
227
+ private __reserve;
228
+ /**
229
+ * Step the vehicle: cast the suspension rays, apply the tyre impulses, then push the chassis up on its
230
+ * grounded springs. Every impulse acts on the chassis velocity at once, for the next
231
+ * `PhysicsSystem.fixedUpdate` to integrate. Call once per fixed step, with that step's `dt`.
105
232
  * @param {number} dt
106
233
  */
107
234
  update(dt: number): void;
235
+ /**
236
+ * Fill the `rows` springs' Jacobians, the chassis' angular response to each, and the matrix
237
+ * `J·M⁻¹·Jᵀ` with each spring's compliance on its diagonal — all fixed by the pose, so shared by
238
+ * every solve of the step.
239
+ * @param {number} rows
240
+ * @private
241
+ */
242
+ private __prepare_springs;
243
+ /**
244
+ * Solve the `rows` prepared springs as one backward-Euler step against the chassis' mean motion in
245
+ * {@link __mean_linear} / {@link __mean_angular}, into {@link __row_impulse}: each pushes, and no
246
+ * harder than its most force.
247
+ * @param {number} rows
248
+ * @private
249
+ */
250
+ private __solve_springs;
251
+ /**
252
+ * Ready the tyres' solve, after the springs are solved against the tyres pushing as they did the step
253
+ * before. Factors the springs that push freely in that solve, which answer the tyres; turns the motion
254
+ * in {@link __mean_linear} / {@link __mean_angular} into the step's with those springs pushing and no
255
+ * tyre; and works out each tyre's response, `W·Jᵀ` and `J·W·Jᵀ`.
256
+ * @param {number} rows
257
+ * @private
258
+ */
259
+ private __prepare_tyres;
260
+ /**
261
+ * The chassis' mean velocity across the step per unit impulse along wheel `wi`'s forward or side
262
+ * direction at its contact, the free springs answering: `W·Jᵀ`, linear then angular, into
263
+ * {@link __wheel_response}, and `J·W·Jᵀ`, the change of the contact's speed along that direction per
264
+ * unit impulse, into its diagonal of {@link __wheel_block}.
265
+ * @param {number} wi
266
+ * @param {number} direction {@link FRAME_FORWARD} or {@link FRAME_SIDE}
267
+ * @private
268
+ */
269
+ private __tyre_response;
270
+ /**
271
+ * Set wheel `wi`'s tyre impulse for the step from {@link scratch_grip}'s drive, brake and side:
272
+ * `drive + brake` along its forward direction and `side` along its side, clamped together to its
273
+ * friction circle. The change applies to the chassis, and to its motion in {@link __mean_linear} /
274
+ * {@link __mean_angular} with the free springs answering.
275
+ * @param {number} wi
276
+ * @private
277
+ */
278
+ private __grip;
108
279
  }
109
280
  import { Ray3 } from "../../../core/geom/3d/ray/Ray3.js";
110
281
  import { PhysicsSurfacePoint } from "../queries/PhysicsSurfacePoint.js";
@@ -1 +1 @@
1
- {"version":3,"file":"RaycastVehicle.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/vehicle/RaycastVehicle.js"],"names":[],"mappings":"AAmFA;;;;GAIG;AACH;IAEI,8DAA8D;IAC9D,eAD8C,YAAY,CACtB;IAEpC,8EAA8E;IAC9E,oBAD8D,YAAY,CACvB;IAEnD,sEAAsE;IACtE,cADsD,YAAY,CACtB;IAE5C,4BAA0B;IAC1B,0BAAuB;IACvB,2BAA8B;IAC9B,eAAa;IACb,iBAAe;IACf,iBAAgB;IAChB,gBAAe;IAGf,mBAAkB;IAElB,oBAAgB;IAEhB,gDAAgD;IAChD,cADgC,YAAY,CACT;IAEnC,iDAAiD;IACjD,eADiC,YAAY,CACA;IAE7C,qDAAqD;IACrD,sBAAmB;IAEnB,gFAAgF;IAChF,iBAAa;IAEb,kDAAkD;IAClD,iBAAa;IAEb,iDAAiD;IACjD,qBAAiB;IAEjB,yDAAyD;IACzD,wBAAoB;IAGhB,6BAA+B;IAC/B,yBAAiD;CAExD;AAED;IAoBI;;;;OAIG;IACH,0FAOC;IA/BD,sBAAsB;IACtB,QADW,KAAK,EAAE,CACN;IAEZ,qBAAiB;IACjB,qBAAiB;IACjB,sBAAkB;IAClB,YAAmB;IACnB,2BAAkC;IAGlC,sBAA8B;IAE9B;;;;OAIG;IACH,SAFU,YAAY,CAEQ;IAQ1B,sBAAoB;IACpB,uBAA8B;IAC9B,8BAAwC;IAGxC,kDAAmF;IAGvF;;;;;;;;;;;;;;;;;OAiBG;IACH;QAb0B,aAAa,EAA5B,MAAM,EAAE;QACQ,kBAAkB,GAAlC,MAAM,EAAE;QACQ,YAAY,GAA5B,MAAM,EAAE;QACM,oBAAoB,GAAlC,MAAM;QACQ,mBAAmB,GAAjC,MAAM;QACQ,iBAAiB,GAA/B,MAAM;QACQ,kBAAkB,GAAhC,MAAM;QACQ,MAAM,GAApB,MAAM;QACQ,QAAQ,GAAtB,MAAM;QACS,OAAO,GAAtB,OAAO;QACQ,MAAM,GAArB,OAAO;QACL,KAAK,CA0BjB;IAED,2DAA2D;IAC3D,8BAIC;IAED,2EAA2E;IAC3E,gCAAmD;IAEnD,uEAAuE;IACvE,2BAA8C;IAE9C;;;;;OAKG;IACH,WAFW,MAAM,QA2IhB;CACJ;qBAtXoB,mCAAmC;oCACpB,mCAAmC"}
1
+ {"version":3,"file":"RaycastVehicle.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/vehicle/RaycastVehicle.js"],"names":[],"mappings":"AA0KA;;;;GAIG;AACH;IAEI,8DAA8D;IAC9D,eAD8C,YAAY,CACtB;IAEpC,8EAA8E;IAC9E,oBAD8D,YAAY,CACvB;IAEnD,sEAAsE;IACtE,cADsD,YAAY,CACtB;IAE5C,4BAA0B;IAC1B,0BAAuB;IACvB,2BAA8B;IAC9B,eAAa;IACb,iBAAe;IACf,iBAAgB;IAChB,gBAAe;IAGf,mBAAkB;IAElB,oBAAgB;IAEhB,gDAAgD;IAChD,cADgC,YAAY,CACT;IAEnC,iDAAiD;IACjD,eADiC,YAAY,CACA;IAE7C,qDAAqD;IACrD,sBAAmB;IAEnB;;;OAGG;IACH,iBAAa;IAEb,kDAAkD;IAClD,iBAAa;IAEb;;;OAGG;IACH,qBAAiB;IAEjB;;;OAGG;IACH,wBAAoB;IAGhB,6BAA+B;IAC/B,yBAAiD;CAExD;AAED;IA4II;;;;OAIG;IACH,0FAOC;IAvJD,sBAAsB;IACtB,QADW,KAAK,EAAE,CACN;IAEZ,qBAAiB;IACjB,qBAAiB;IACjB,sBAAkB;IAClB,YAAmB;IACnB,2BAAkC;IAElC,sEAAsE;IACtE,WADsD,YAAY,CAClC;IAEhC;;;;OAIG;IACH,eAFU,YAAY,CAEc;IACpC,2BAA2B;IAC3B,gBADW,YAAY,CACc;IAErC,0GAA0G;IAC1G,4BAAwB;IAExB;;;;OAIG;IACH,wBAFU,YAAY,CAEuB;IAI7C,kGAAkG;IAClG,eADkF,YAAY,CAC1D;IAEpC,uFAAuF;IACvF,eADuE,YAAY,CAC/C;IAEpC,iHAAiH;IACjH,eADmG,UAAU,CAC3E;IAElC;;;;OAIG;IACH,cAFU,YAAY,CAEa;IAEnC,oFAAoF;IACpF,gBADoE,YAAY,CAC3C;IAErC;;;;OAIG;IACH,eAFU,YAAY,CAEc;IAEpC;;;;OAIG;IACH,kBAFU,YAAY,CAEiB;IAEvC;;;;OAIG;IACH,eAFU,YAAY,CAEc;IAIpC,0BAA0B;IAC1B,qBAAiB;IAEjB,sCAAsC;IACtC,YADuB,WAAW,CACF;IAEhC;;;OAGG;IACH,eAFU,YAAY,CAEc;IAEpC,yDAAyD;IACzD,cAD0C,WAAW,CACnB;IAElC,6CAA6C;IAC7C,qBAAiB;IAEjB,gGAAgG;IAChG,cADgF,YAAY,CACzD;IAEnC;;;;OAIG;IACH,eAFU,YAAY,CAEc;IAIpC,qCAAqC;IACrC,aADsB,WAAW,CACA;IAEjC,4EAA4E;IAC5E,gBAD4D,YAAY,CACnC;IAErC;;;;OAIG;IACH,gBAFU,YAAY,CAEe;IAErC,wDAAwD;IACxD,kBADwC,YAAY,CACb;IAEvC,uEAAuE;IACvE,eADuD,YAAY,CAC/B;IAEpC,8GAA8G;IAC9G,WAD8F,YAAY,CAC1E;IAEhC,sEAAsE;IACtE,aADsD,YAAY,CAChC;IAElC,sEAAsE;IACtE,aADsD,YAAY,CAChC;IAElC,oDAAoD;IACpD,eADoC,YAAY,CACZ;IAEpC,6GAA6G;IAC7G,cAD6F,YAAY,CACtE;IAQ/B,sBAAoB;IACpB,uBAA8B;IAC9B,8BAAwC;IAGxC,kDAAmF;IAGvF;;;;;;;;;;;;;;;;;OAiBG;IACH;QAb0B,aAAa,EAA5B,MAAM,EAAE;QACQ,kBAAkB,GAAlC,MAAM,EAAE;QACQ,YAAY,GAA5B,MAAM,EAAE;QACM,oBAAoB,GAAlC,MAAM;QACQ,mBAAmB,GAAjC,MAAM;QACQ,iBAAiB,GAA/B,MAAM;QACQ,kBAAkB,GAAhC,MAAM;QACQ,MAAM,GAApB,MAAM;QACQ,QAAQ,GAAtB,MAAM;QACS,OAAO,GAAtB,OAAO;QACQ,MAAM,GAArB,OAAO;QACL,KAAK,CA0BjB;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,mBAFW,MAAM,QAwFhB;IAED,2EAA2E;IAC3E,gCAAmD;IAEnD,uEAAuE;IACvE,2BAA8C;IAE9C;;;;;OAKG;IACH,kBAoCC;IAED;;;;;OAKG;IACH,WAFW,MAAM,QA8UhB;IAED;;;;;;OAMG;IACH,0BA+DC;IAED;;;;;;OAMG;IACH,wBAkBC;IAED;;;;;;;OAOG;IACH,wBA0GC;IAED;;;;;;;;OAQG;IACH,wBAiFC;IAED;;;;;;;OAOG;IACH,eAgDC;CACJ;qBAnxCoB,mCAAmC;oCAWpB,mCAAmC"}