@series-inc/rundot-syncplay 6.0.0-rc.2 → 6.0.0-rc.21

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 (329) hide show
  1. package/README.md +133 -0
  2. package/core/deterministic-math.d.ts +75 -1
  3. package/core/native/instance_ledger.hpp +1095 -0
  4. package/core/native/legacy_checkpoint_ids.hpp +107 -0
  5. package/core/native/physics/abi.cpp +39 -211
  6. package/core/native/physics/abi.hpp +2 -6
  7. package/core/native/physics/articulation.cpp +1434 -0
  8. package/core/native/physics/articulation.hpp +279 -0
  9. package/core/native/physics/buoyancy.cpp +1588 -0
  10. package/core/native/physics/buoyancy.hpp +254 -0
  11. package/core/native/physics/capsule_triangle.cpp +168 -0
  12. package/core/native/physics/capsule_triangle.hpp +40 -0
  13. package/core/native/physics/capsule_triangle_native.inc +291 -0
  14. package/core/native/physics/certified_sum.hpp +218 -0
  15. package/core/native/physics/character.cpp +638 -0
  16. package/core/native/physics/character.hpp +169 -0
  17. package/core/native/physics/checkpoint_schema.hpp +379 -0
  18. package/core/native/physics/cloth.cpp +1401 -0
  19. package/core/native/physics/cloth.hpp +357 -0
  20. package/core/native/physics/constraint_rows.cpp +363 -2
  21. package/core/native/physics/constraint_rows.hpp +72 -1
  22. package/core/native/physics/deformable_query.cpp +1630 -0
  23. package/core/native/physics/deformable_query.hpp +578 -0
  24. package/core/native/physics/distance.cpp +1166 -0
  25. package/core/native/physics/distance.hpp +151 -0
  26. package/core/native/physics/exact/exact-applied.cpp +101 -0
  27. package/core/native/physics/exact/exact-applied.hpp +112 -0
  28. package/core/native/physics/exact/exact-dyadic.cpp +691 -0
  29. package/core/native/physics/exact/exact-dyadic.hpp +58 -0
  30. package/core/native/physics/exact/exact-operation.hpp +51 -0
  31. package/core/native/physics/exact/word-core.hpp +262 -0
  32. package/core/native/physics/extended_abi.cpp +1242 -0
  33. package/core/native/physics/extended_abi.hpp +355 -0
  34. package/core/native/physics/extended_abi_characters.cpp +261 -0
  35. package/core/native/physics/extended_abi_characters.hpp +434 -0
  36. package/core/native/physics/extended_abi_core_features.cpp +713 -0
  37. package/core/native/physics/extended_abi_core_features.hpp +226 -0
  38. package/core/native/physics/extended_abi_deformables.cpp +448 -0
  39. package/core/native/physics/extended_abi_deformables.hpp +867 -0
  40. package/core/native/physics/extended_abi_vehicles.cpp +411 -0
  41. package/core/native/physics/extended_abi_vehicles.hpp +222 -0
  42. package/core/native/physics/fracture.cpp +1981 -0
  43. package/core/native/physics/fracture.hpp +460 -0
  44. package/core/native/physics/gear.cpp +563 -0
  45. package/core/native/physics/gear.hpp +158 -0
  46. package/core/native/physics/geometry_memory.hpp +476 -0
  47. package/core/native/physics/geometry_store.cpp +547 -0
  48. package/core/native/physics/geometry_store.hpp +134 -0
  49. package/core/native/physics/lag_compensation.cpp +1626 -0
  50. package/core/native/physics/lag_compensation.hpp +405 -0
  51. package/core/native/physics/mass_properties.cpp +449 -0
  52. package/core/native/physics/mass_properties.hpp +23 -0
  53. package/core/native/physics/material_pose.hpp +988 -0
  54. package/core/native/physics/particles.cpp +1065 -0
  55. package/core/native/physics/particles.hpp +261 -0
  56. package/core/native/physics/path_joint.cpp +781 -0
  57. package/core/native/physics/path_joint.hpp +154 -0
  58. package/core/native/physics/physics.cpp +13043 -1065
  59. package/core/native/physics/physics.hpp +184 -8
  60. package/core/native/physics/planar_deformable.cpp +2433 -0
  61. package/core/native/physics/planar_deformable.hpp +889 -0
  62. package/core/native/physics/platformer_2d.cpp +1353 -0
  63. package/core/native/physics/platformer_2d.hpp +340 -0
  64. package/core/native/physics/powered_ragdoll.cpp +1100 -0
  65. package/core/native/physics/powered_ragdoll.hpp +279 -0
  66. package/core/native/physics/powertrain.cpp +586 -0
  67. package/core/native/physics/powertrain.hpp +180 -0
  68. package/core/native/physics/pulley.cpp +311 -0
  69. package/core/native/physics/pulley.hpp +121 -0
  70. package/core/native/physics/ragdoll.cpp +586 -0
  71. package/core/native/physics/ragdoll.hpp +221 -0
  72. package/core/native/physics/rope.cpp +692 -0
  73. package/core/native/physics/rope.hpp +215 -0
  74. package/core/native/physics/rounded_convex.cpp +1229 -0
  75. package/core/native/physics/rounded_convex.hpp +287 -0
  76. package/core/native/physics/sdf_geometry.cpp +1821 -0
  77. package/core/native/physics/sdf_geometry.hpp +474 -0
  78. package/core/native/physics/soft_body.cpp +1449 -0
  79. package/core/native/physics/soft_body.hpp +328 -0
  80. package/core/native/physics/soft_collision.cpp +1862 -0
  81. package/core/native/physics/soft_collision.hpp +561 -0
  82. package/core/native/physics/surface_velocity.cpp +366 -0
  83. package/core/native/physics/surface_velocity.hpp +243 -0
  84. package/core/native/physics/topology.cpp +357 -39
  85. package/core/native/physics/topology.hpp +97 -6
  86. package/core/native/physics/tracks.cpp +1179 -0
  87. package/core/native/physics/tracks.hpp +404 -0
  88. package/core/native/physics/vehicle.cpp +629 -0
  89. package/core/native/physics/vehicle.hpp +191 -0
  90. package/core/native/physics/voxel_cooking.cpp +1929 -0
  91. package/core/native/physics/voxel_cooking.hpp +395 -0
  92. package/core/native/physics/world.cpp +5290 -854
  93. package/core/native/physics/world.hpp +796 -24
  94. package/core/native/physics/world_abi.cpp +3840 -306
  95. package/core/native/physics/world_abi.hpp +530 -10
  96. package/core/native/physics/world_digest_visitor.hpp +277 -0
  97. package/core/native/physics/world_strong_digest.hpp +557 -0
  98. package/core/native/physics2d/ccd.cpp +1302 -0
  99. package/core/native/physics2d/ccd.hpp +141 -0
  100. package/core/native/physics2d/checkpoint_memory.hpp +349 -0
  101. package/core/native/physics2d/clock_primitives.hpp +138 -0
  102. package/core/native/physics2d/commands.cpp +174 -28
  103. package/core/native/physics2d/commands.hpp +3 -1
  104. package/core/native/physics2d/compound.cpp +581 -0
  105. package/core/native/physics2d/compound.hpp +248 -0
  106. package/core/native/physics2d/contour.cpp +325 -0
  107. package/core/native/physics2d/contour.hpp +143 -0
  108. package/core/native/physics2d/frame_scope.hpp +124 -0
  109. package/core/native/physics2d/joint_phases.hpp +93 -0
  110. package/core/native/physics2d/joints.cpp +587 -150
  111. package/core/native/physics2d/joints.hpp +5 -0
  112. package/core/native/physics2d/memory_private.hpp +125 -0
  113. package/core/native/physics2d/owned_abi.cpp +1354 -879
  114. package/core/native/physics2d/owned_abi.hpp +190 -52
  115. package/core/native/physics2d/phase_test_hooks.hpp +17 -0
  116. package/core/native/physics2d/physics2d.cpp +2073 -120
  117. package/core/native/physics2d/physics2d.hpp +154 -2
  118. package/core/native/physics2d/queries.cpp +1055 -79
  119. package/core/native/physics2d/queries.hpp +71 -5
  120. package/core/native/physics2d/world.cpp +1313 -353
  121. package/core/native/physics2d/world.hpp +124 -13
  122. package/core/native/sha256/sha256_compress_unsigned.hpp +68 -0
  123. package/core/native/sha256/sha256_fips_constants.hpp +24 -0
  124. package/core/native/sha256/sha256_length.hpp +56 -0
  125. package/core/native/sha256/sha256_memo.hpp +48 -0
  126. package/core/native/sha256/sha256_sink.hpp +234 -0
  127. package/core/physics2d-owned.d.ts +466 -126
  128. package/core/runtime.d.ts +192 -19
  129. package/core/scripts/build-native.mjs +34 -0
  130. package/core/scripts/build-wasm-physics.mjs +272 -23
  131. package/core/scripts/extended-physics-profile.mjs +634 -0
  132. package/core/scripts/generate-physics2d-vectors.mjs +59 -0
  133. package/core/src/kinetix-deterministic-math.d.ts +2 -0
  134. package/core/src/kinetix-deterministic-math.mjs +513 -27
  135. package/core/src/kinetix-owned-runtime-adapter.mjs +788 -0
  136. package/core/src/kinetix-runtime-adapter-utils.mjs +54 -6
  137. package/core/src/kinetix-runtime-contract.mjs +55 -9
  138. package/core/src/kinetix-runtime-identity.mjs +12 -1
  139. package/core/src/kinetix-session-config.mjs +7 -2
  140. package/core/src/kinetix-state-report.mjs +36 -0
  141. package/core/src/physics/abi-constants.mjs +5 -4
  142. package/core/src/physics/articulation.d.mts +194 -0
  143. package/core/src/physics/articulation.mjs +1141 -0
  144. package/core/src/physics/buoyancy.d.mts +143 -0
  145. package/core/src/physics/buoyancy.mjs +268 -0
  146. package/core/src/physics/cloth.d.mts +314 -0
  147. package/core/src/physics/cloth.mjs +1156 -0
  148. package/core/src/physics/deformable-query.d.mts +217 -0
  149. package/core/src/physics/deformable-query.mjs +1412 -0
  150. package/core/src/physics/distance.d.mts +160 -0
  151. package/core/src/physics/distance.mjs +175 -0
  152. package/core/src/physics/extended-wasm-instance.d.mts +5 -0
  153. package/core/src/physics/extended-wasm-instance.mjs +48 -0
  154. package/core/src/physics/feature-api.d.mts +74 -0
  155. package/core/src/physics/feature-api.mjs +98 -0
  156. package/core/src/physics/fracture.d.mts +133 -0
  157. package/core/src/physics/fracture.mjs +1324 -0
  158. package/core/src/physics/gear.d.mts +585 -0
  159. package/core/src/physics/gear.mjs +955 -0
  160. package/core/src/physics/lag-compensation.d.mts +101 -0
  161. package/core/src/physics/lag-compensation.mjs +1100 -0
  162. package/core/src/physics/mass-properties.d.mts +114 -0
  163. package/core/src/physics/mass-properties.mjs +137 -468
  164. package/core/src/physics/particles.d.mts +177 -0
  165. package/core/src/physics/particles.mjs +758 -0
  166. package/core/src/physics/path-joint.d.mts +171 -0
  167. package/core/src/physics/path-joint.mjs +1231 -0
  168. package/core/src/physics/physics-extended-wasm-module.generated.mjs +13 -0
  169. package/core/src/physics/physics-profile-wasm-module.generated.mjs +48 -0
  170. package/core/src/physics/physics-wasm-module.generated.mjs +34 -5
  171. package/core/src/physics/powered-ragdoll.d.mts +188 -0
  172. package/core/src/physics/powered-ragdoll.mjs +1043 -0
  173. package/core/src/physics/powertrain.d.mts +260 -0
  174. package/core/src/physics/powertrain.mjs +621 -0
  175. package/core/src/physics/pulley.d.mts +98 -0
  176. package/core/src/physics/pulley.mjs +686 -0
  177. package/core/src/physics/ragdoll.d.mts +289 -0
  178. package/core/src/physics/ragdoll.mjs +1323 -0
  179. package/core/src/physics/rope.d.mts +241 -0
  180. package/core/src/physics/rope.mjs +319 -0
  181. package/core/src/physics/rounded-convex.d.mts +328 -0
  182. package/core/src/physics/rounded-convex.mjs +1404 -0
  183. package/core/src/physics/sdf-geometry.d.mts +117 -0
  184. package/core/src/physics/sdf-geometry.mjs +1204 -0
  185. package/core/src/physics/soft-body.d.mts +144 -0
  186. package/core/src/physics/soft-body.mjs +1285 -0
  187. package/core/src/physics/soft-collision.d.mts +651 -0
  188. package/core/src/physics/soft-collision.mjs +1883 -0
  189. package/core/src/physics/surface-velocity.d.mts +156 -0
  190. package/core/src/physics/surface-velocity.mjs +722 -0
  191. package/core/src/physics/tracks.d.mts +411 -0
  192. package/core/src/physics/tracks.mjs +1074 -0
  193. package/core/src/physics/vehicle.d.mts +3 -0
  194. package/core/src/physics/vehicle.mjs +172 -0
  195. package/core/src/physics/voxel-cooking.d.mts +219 -0
  196. package/core/src/physics/voxel-cooking.mjs +1499 -0
  197. package/core/src/physics/voxel-swept-quad.mjs +110 -0
  198. package/core/src/physics/wasm-instance.mjs +160 -23
  199. package/core/src/physics/world.d.mts +62 -0
  200. package/core/src/physics/world.mjs +1947 -152
  201. package/core/src/physics2d/body-state.mjs +218 -15
  202. package/core/src/physics2d/collision.d.mts +52 -0
  203. package/core/src/physics2d/collision.mjs +234 -0
  204. package/core/src/physics2d/compound.mjs +454 -0
  205. package/core/src/physics2d/contour-state.mjs +771 -0
  206. package/core/src/physics2d/feature-api.d.mts +211 -0
  207. package/core/src/physics2d/feature-api.mjs +3 -0
  208. package/core/src/physics2d/fluid-state.mjs +145 -0
  209. package/core/src/physics2d/joint-state.mjs +1 -1
  210. package/core/src/physics2d/owned-queries.mjs +3 -1
  211. package/core/src/physics2d/owned-transport.mjs +268 -122
  212. package/core/src/physics2d/owned-world.mjs +353 -230
  213. package/core/src/physics2d/particle-fluid.d.mts +152 -0
  214. package/core/src/physics2d/particle-fluid.mjs +233 -0
  215. package/core/src/physics2d/physics2d-wasm-module.generated.mjs +27 -10
  216. package/core/src/physics2d/query-codec.mjs +61 -13
  217. package/core/src/physics2d/submerged-geometry.d.mts +51 -0
  218. package/core/src/physics2d/submerged-geometry.mjs +186 -0
  219. package/core/src/runtime.mjs +23 -0
  220. package/core/src/shared/bytes.d.mts +2 -0
  221. package/core/src/shared/bytes.mjs +33 -0
  222. package/core/src/shared/sha256.d.mts +3 -0
  223. package/core/src/shared/sha256.mjs +72 -22
  224. package/core/units.d.ts +50 -0
  225. package/core/world.d.ts +253 -5
  226. package/dist/authority-room.d.ts +9 -0
  227. package/dist/authority-room.js +45 -16
  228. package/dist/browser.d.ts +6 -5
  229. package/dist/browser.js +4 -3
  230. package/dist/cadence.d.ts +7 -0
  231. package/dist/cadence.js +19 -0
  232. package/dist/canonical.d.ts +1 -0
  233. package/dist/canonical.js +3 -0
  234. package/dist/checksum-policy.d.ts +10 -0
  235. package/dist/checksum-policy.js +14 -0
  236. package/dist/collider-cooking-hull.d.ts +18 -0
  237. package/dist/collider-cooking-hull.js +248 -0
  238. package/dist/collider-cooking.d.ts +140 -0
  239. package/dist/collider-cooking.js +794 -0
  240. package/dist/compat/v5.d.ts +121 -0
  241. package/dist/compat/v5.js +479 -0
  242. package/dist/creator.d.ts +7 -6
  243. package/dist/creator.js +4 -3
  244. package/dist/game-byte-section.d.ts +36 -0
  245. package/dist/game-byte-section.js +350 -0
  246. package/dist/index.d.ts +13 -6
  247. package/dist/index.js +9 -4
  248. package/dist/instant-replay.d.ts +27 -2
  249. package/dist/instant-replay.js +91 -16
  250. package/dist/lag-compensation3d.js +11 -10
  251. package/dist/match-log.d.ts +21 -4
  252. package/dist/match-log.js +92 -9
  253. package/dist/math.d.ts +2 -0
  254. package/dist/math.js +1 -0
  255. package/dist/modules/character-3d.d.ts +16 -1
  256. package/dist/modules/character-3d.js +42 -5
  257. package/dist/modules/combat.js +6 -5
  258. package/dist/movement3d-revision1.d.ts +2 -0
  259. package/dist/movement3d-revision1.js +973 -0
  260. package/dist/movement3d.d.ts +53 -3
  261. package/dist/movement3d.js +917 -247
  262. package/dist/networked-client.d.ts +15 -0
  263. package/dist/networked-client.js +378 -105
  264. package/dist/node.d.ts +3 -2
  265. package/dist/node.js +2 -1
  266. package/dist/physics/2d.d.ts +38 -4
  267. package/dist/physics/2d.js +57 -36
  268. package/dist/physics/3d.d.ts +755 -111
  269. package/dist/physics/3d.js +2355 -158
  270. package/dist/physics/edit-result-graph.d.ts +36 -0
  271. package/dist/physics/edit-result-graph.js +141 -0
  272. package/dist/physics/game-codec3d.d.ts +41 -0
  273. package/dist/physics/game-codec3d.js +544 -0
  274. package/dist/physics/installed-checkpoint3d.d.ts +13 -0
  275. package/dist/physics/installed-checkpoint3d.js +120 -0
  276. package/dist/physics/installed-runtime3d.d.ts +51 -0
  277. package/dist/physics/installed-runtime3d.js +372 -0
  278. package/dist/physics/installed-state-commitment3d.d.ts +2 -0
  279. package/dist/physics/installed-state-commitment3d.js +24 -0
  280. package/dist/physics/units.d.ts +38 -0
  281. package/dist/physics/units.js +56 -0
  282. package/dist/physics/vehicle-state3d.d.ts +93 -0
  283. package/dist/physics/vehicle-state3d.js +1191 -0
  284. package/dist/physics/voxel-body-state.d.ts +61 -0
  285. package/dist/physics/voxel-body-state.js +410 -0
  286. package/dist/r3f-render-adapter.d.ts +59 -1
  287. package/dist/r3f-render-adapter.js +137 -2
  288. package/dist/replay.d.ts +13 -0
  289. package/dist/replay.js +95 -70
  290. package/dist/run-room-transport.js +5 -1
  291. package/dist/runner.d.ts +17 -2
  292. package/dist/runner.js +472 -84
  293. package/dist/runtime-cleanup.d.ts +54 -0
  294. package/dist/runtime-cleanup.js +266 -0
  295. package/dist/runtime-lease.d.ts +11 -1
  296. package/dist/runtime-lease.js +23 -10
  297. package/dist/runtime-room-metadata.d.ts +2 -8
  298. package/dist/runtime-room-metadata.js +11 -14
  299. package/dist/runtime-session.d.ts +8 -0
  300. package/dist/runtime-session.js +222 -58
  301. package/dist/schema-codegen.js +3 -0
  302. package/dist/schema-dsl-binary.d.ts +10 -4
  303. package/dist/schema-dsl-binary.js +375 -76
  304. package/dist/scratch-pool.d.ts +32 -0
  305. package/dist/scratch-pool.js +60 -0
  306. package/dist/sdk-session.d.ts +1 -0
  307. package/dist/sdk-session.js +4 -0
  308. package/dist/secret-config.js +2 -60
  309. package/dist/secret-crypto.js +70 -36
  310. package/dist/session-snapshot.d.ts +15 -4
  311. package/dist/session-snapshot.js +35 -33
  312. package/dist/session-wire.js +14 -22
  313. package/dist/sparse-set.d.ts +1 -0
  314. package/dist/sparse-set.js +22 -0
  315. package/dist/spatial/spatial-grid-3d.d.ts +41 -0
  316. package/dist/spatial/spatial-grid-3d.js +115 -0
  317. package/dist/synctest.d.ts +9 -0
  318. package/dist/synctest.js +106 -17
  319. package/dist/testing-network.d.ts +2 -0
  320. package/dist/testing-network.js +122 -18
  321. package/dist/testing.d.ts +27 -6
  322. package/dist/testing.js +297 -56
  323. package/dist/tools/index.d.ts +3 -2
  324. package/dist/tools/index.js +3 -2
  325. package/dist/tools/module-certification.d.ts +6 -0
  326. package/dist/tools/module-certification.js +26 -2
  327. package/package.json +18 -5
  328. package/core/scripts/run-box3d-benchmark.mjs +0 -350
  329. package/core/src/physics/index.mjs +0 -3169
@@ -4,62 +4,204 @@ import { mkdirSync, readFileSync, realpathSync, renameSync, writeFileSync } from
4
4
  import { dirname, join } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
 
7
+ import {
8
+ extendedPhysicsCompileSources,
9
+ extendedPhysicsExportedFunctions,
10
+ extendedPhysicsSources,
11
+ } from './extended-physics-profile.mjs';
12
+
7
13
  const root = join(import.meta.dirname, '..');
8
14
  const buildDirectory = join(root, 'build');
9
15
  const profilingFunctions = process.env.SYNCPLAY_WASM_PROFILING_FUNCTIONS === '1';
10
- const commonSources = ['native/deterministic_math.hpp', 'native/deterministic_math.cpp', 'native/wasm_runtime.cpp'];
16
+ const commonSources = ['native/instance_ledger.hpp', 'native/legacy_checkpoint_ids.hpp', 'native/deterministic_math.hpp', 'native/deterministic_math.cpp', 'native/wasm_runtime.cpp'];
11
17
  const profiles = {
12
18
  physics3d: {
13
19
  exceptionFlag: '-fwasm-exceptions',
20
+ extraFlags: [
21
+ '-D_LIBCPP_VERBOSE_ABORT(...)=__builtin_trap()',
22
+ '-Icore/native',
23
+ '-Inative',
24
+ '-Wl,--allow-multiple-definition',
25
+ '-sSTACK_SIZE=1048576',
26
+ ],
14
27
  wasmName: 'physics.wasm',
15
28
  generatedPath: ['src', 'physics', 'physics-wasm-module.generated.mjs'],
16
29
  metadataExport: 'physicsWasmMetadata',
17
30
  base64Export: 'physicsWasmModuleBase64',
18
31
  sources: [
19
32
  'native/physics/physics.hpp', 'native/physics/physics.cpp',
33
+ 'native/physics/capsule_triangle.hpp', 'native/physics/capsule_triangle.cpp',
34
+ 'native/physics/geometry_store.hpp', 'native/physics/geometry_store.cpp',
35
+ 'native/physics/voxel_cooking.hpp', 'native/physics/voxel_cooking.cpp',
36
+ 'native/physics/buoyancy.hpp', 'native/physics/buoyancy.cpp',
37
+ 'native/physics/geometry_memory.hpp',
38
+ 'native/physics/material_pose.hpp',
39
+ 'native/physics/capsule_triangle_native.inc', 'native/physics/certified_sum.hpp',
40
+ 'native/physics/exact/exact-applied.hpp', 'native/physics/exact/exact-applied.cpp',
41
+ 'native/physics/exact/exact-dyadic.hpp', 'native/physics/exact/exact-dyadic.cpp',
42
+ 'native/physics/exact/exact-operation.hpp', 'native/physics/exact/word-core.hpp',
20
43
  'native/physics/constraint_rows.hpp', 'native/physics/constraint_rows.cpp',
21
44
  'native/physics/topology.hpp', 'native/physics/topology.cpp',
22
- 'native/physics/world.hpp', 'native/physics/world.cpp',
45
+ 'native/physics/world.hpp', 'native/physics/world_digest_visitor.hpp', 'native/physics/world.cpp',
23
46
  'native/physics/world_abi.hpp', 'native/physics/world_abi.cpp',
24
- 'native/physics/abi.hpp', 'native/physics/abi.cpp', ...commonSources,
47
+ 'native/physics/checkpoint_schema.hpp',
48
+ 'native/physics/world_strong_digest.hpp',
49
+ 'native/sha256/sha256_sink.hpp',
50
+ 'native/sha256/sha256_memo.hpp',
51
+ 'native/sha256/sha256_compress_unsigned.hpp',
52
+ 'native/sha256/sha256_fips_constants.hpp',
53
+ 'native/sha256/sha256_length.hpp',
54
+
55
+ 'native/physics/abi.hpp', 'native/physics/abi.cpp',
56
+ 'scripts/extended-physics-profile.mjs', ...extendedPhysicsSources, ...commonSources,
25
57
  ],
26
58
  compileSources: [
27
59
  'native/physics/physics.cpp',
60
+ 'native/physics/capsule_triangle.cpp',
61
+ 'native/physics/geometry_store.cpp',
62
+ 'native/physics/voxel_cooking.cpp',
63
+ 'native/physics/buoyancy.cpp',
64
+ 'native/physics/exact/exact-applied.cpp',
65
+ 'native/physics/exact/exact-dyadic.cpp',
28
66
  'native/physics/constraint_rows.cpp',
29
67
  'native/physics/topology.cpp',
30
68
  'native/physics/world.cpp', 'native/physics/world_abi.cpp',
31
- 'native/physics/abi.cpp', 'native/deterministic_math.cpp', 'native/wasm_runtime.cpp',
69
+ 'native/physics/abi.cpp', ...extendedPhysicsCompileSources,
70
+ 'native/deterministic_math.cpp', 'native/wasm_runtime.cpp',
32
71
  ],
33
72
  exportedFunctions: [
34
73
  '_malloc', '_free',
35
- '_rundot_kinetix_world_abi_version',
74
+ '_rundot_kinetix_ext_voxel_abi_version',
75
+ '_rundot_kinetix_ext_voxel_child_stride',
76
+ '_rundot_kinetix_ext_voxel_stats_stride',
77
+ '_rundot_kinetix_ext_voxel_subchunk_stride',
78
+ '_rundot_kinetix_ext_voxel_ray_hit_stride',
79
+ '_rundot_kinetix_ext_voxel_seam_result_stride',
80
+ '_rundot_kinetix_ext_voxel_mass_properties_stride',
81
+ '_rundot_kinetix_ext_voxel_mass_properties',
82
+ '_rundot_kinetix_ext_voxel_scratch_size',
83
+ '_rundot_kinetix_ext_voxel_cook_chunk',
84
+ '_rundot_kinetix_ext_voxel_carve',
85
+ '_rundot_kinetix_ext_voxel_incremental_cook',
86
+ '_rundot_kinetix_ext_voxel_split_components',
87
+ '_rundot_kinetix_ext_voxel_incremental_slice',
88
+ '_rundot_kinetix_ext_voxel_raycast_dda',
89
+ '_rundot_kinetix_ext_voxel_seam_query',
90
+ '_rundot_kinetix_world_abi_version', '_rundot_kinetix_numeric_environment_valid',
36
91
  '_rundot_kinetix_world_joint_warm_state_stride',
37
92
  '_rundot_kinetix_world_topology_abi_version',
93
+ '_rundot_kinetix_world_topology_geometry_abi_version',
94
+ '_rundot_kinetix_world_topology_geometry_command_stride',
38
95
  '_rundot_kinetix_world_topology_command_stride',
39
96
  '_rundot_kinetix_world_topology_result_stride',
40
97
  '_rundot_kinetix_world_topology_info_stride',
41
98
  '_rundot_kinetix_world_topology_max_commands',
42
99
  '_rundot_kinetix_world_topology_body_id_stride',
43
100
  '_rundot_kinetix_world_topology_joint_identity_stride',
101
+ '_rundot_kinetix_world_topology_fluid_id_stride',
44
102
  '_rundot_kinetix_world_apply_topology_batch',
103
+ '_rundot_kinetix_world_apply_topology_geometry_batch',
104
+ '_rundot_kinetix_world_prepare_topology_edit',
105
+ '_rundot_kinetix_world_copy_topology_edit_removed',
106
+ '_rundot_kinetix_world_commit_topology_edit',
107
+ '_rundot_kinetix_world_abandon_topology_edit',
108
+ '_rundot_kinetix_world_body_geometry_info',
109
+ '_rundot_kinetix_world_copy_body_geometry',
45
110
  '_rundot_kinetix_world_topology_info',
46
111
  '_rundot_kinetix_world_copy_topology',
47
112
  '_rundot_kinetix_world_body_exists',
48
113
  '_rundot_kinetix_world_joint_exists',
114
+ '_rundot_kinetix_world_fluid_exists',
49
115
  '_rundot_kinetix_world_read_body',
50
116
  '_rundot_kinetix_world_read_joint',
117
+ '_rundot_kinetix_world_read_fluid',
51
118
  '_rundot_kinetix_world_contact_output_info',
52
119
  '_rundot_kinetix_world_copy_contact_output',
120
+ '_rundot_kinetix_world_joint_output_info',
121
+ '_rundot_kinetix_world_copy_joint_output',
122
+ '_rundot_kinetix_world_fluid_interaction_info',
123
+ '_rundot_kinetix_world_copy_fluid_interactions',
53
124
  '_rundot_kinetix_world_max_handles',
54
125
  '_rundot_kinetix_world_buffer_allocate',
55
126
  '_rundot_kinetix_world_buffer_free',
56
127
  '_rundot_kinetix_world_create',
128
+ '_rundot_kinetix_instance_ledger_info',
129
+ '_rundot_kinetix_instance_ledger_metadata',
130
+ '_rundot_kinetix_instance_ledger_classes',
131
+ '_rundot_kinetix_instance_ledger_reset_high_water',
132
+ '_rundot_kinetix_world_attach',
133
+ '_rundot_kinetix_world_capture_cache_bytes',
134
+ '_rundot_kinetix_world_checkpoint_capacity',
135
+ '_rundot_kinetix_world_checkpoint_capture_snapshot_token',
136
+ '_rundot_kinetix_world_checkpoint_capture_token',
137
+ '_rundot_kinetix_world_checkpoint_legacy_preflight',
138
+ '_rundot_kinetix_world_checkpoint_live_count',
139
+ '_rundot_kinetix_world_checkpoint_preflight',
140
+ '_rundot_kinetix_world_checkpoint_release_token',
141
+ '_rundot_kinetix_world_checkpoint_restore_token',
142
+ '_rundot_kinetix_world_create_with_checkpoint_capacity',
143
+ '_rundot_kinetix_world_detach',
144
+ '_rundot_kinetix_world_import_snapshot_attached',
145
+ '_rundot_kinetix_world_ownership_counts',
146
+ '_rundot_kinetix_world_revision',
57
147
  '_rundot_kinetix_world_destroy',
58
148
  '_rundot_kinetix_world_digest',
149
+ '_rundot_kinetix_world_digest_algorithm_revision',
150
+ '_rundot_kinetix_world_checkpoint_digest',
151
+ '_rundot_kinetix_world_checkpoint_strong_digest',
152
+ '_rundot_kinetix_world_checkpoint_strong_digest_token',
153
+ '_rundot_kinetix_world_strong_digest_algorithm_revision',
154
+ '_rundot_kinetix_world_checkpoint_digest_token',
155
+ '_rundot_kinetix_world_checkpoint_view_info',
156
+ '_rundot_kinetix_world_checkpoint_view_info_token',
157
+ '_rundot_kinetix_world_checkpoint_write_body_motion_into',
158
+ '_rundot_kinetix_world_checkpoint_write_body_motion_into_token',
159
+ '_rundot_kinetix_world_checkpoint_copy_latest_output',
160
+ '_rundot_kinetix_world_checkpoint_copy_latest_output_token',
161
+ '_rundot_kinetix_world_checkpoint_import',
162
+ '_rundot_kinetix_world_checkpoint_import_token',
163
+ '_rundot_kinetix_world_frame',
59
164
  '_rundot_kinetix_world_replace_state',
60
165
  '_rundot_kinetix_world_step',
61
166
  '_rundot_kinetix_world_apply_impulse',
167
+ '_rundot_kinetix_world_set_body_force',
168
+ '_rundot_kinetix_world_apply_force',
169
+ '_rundot_kinetix_world_apply_force_at_point',
170
+ '_rundot_kinetix_world_clear_body_force',
171
+ '_rundot_kinetix_world_set_body_surface_velocity',
172
+ '_rundot_kinetix_world_max_support_records',
173
+ '_rundot_kinetix_world_apply_support',
174
+ '_rundot_kinetix_world_read_surface_velocity',
175
+ '_rundot_kinetix_world_read_body_mobility',
176
+ '_rundot_kinetix_world_read_pending_support_impulse',
177
+ '_rundot_kinetix_world_set_body_linear_velocity',
178
+ '_rundot_kinetix_world_set_body_angular_velocity',
179
+ '_rundot_kinetix_world_set_body_transform',
180
+ '_rundot_kinetix_world_set_body_linear_damping',
181
+ '_rundot_kinetix_world_wake_body',
182
+ '_rundot_kinetix_world_write_body_motion',
183
+ '_rundot_kinetix_world_motion_pose_stride',
184
+ '_rundot_kinetix_world_motion_velocity_stride',
185
+ '_rundot_kinetix_world_motion_status_version',
186
+ '_rundot_kinetix_world_motion_pose_value_limit',
187
+ '_rundot_kinetix_world_motion_velocity_value_limit',
188
+ '_rundot_kinetix_world_motion_id_word_limit',
189
+ '_rundot_kinetix_world_motion_status_byte_limit',
190
+ '_rundot_kinetix_physics_buoyancy',
191
+ '_rundot_kinetix_physics_voxel_buoyancy',
192
+ '_rundot_kinetix_physics_buoyancy_abi_version',
193
+ '_rundot_kinetix_physics_buoyancy_input_stride',
194
+ '_rundot_kinetix_physics_buoyancy_output_stride',
195
+ '_rundot_kinetix_physics_fluid_abi_version',
196
+ '_rundot_kinetix_physics_fluid_forces_input_stride',
197
+ '_rundot_kinetix_physics_fluid_forces_output_stride',
198
+ '_rundot_kinetix_physics_fluid_volume_input_stride',
199
+ '_rundot_kinetix_physics_fluid_state_forces_input_stride',
200
+ '_rundot_kinetix_physics_fluid_forces',
201
+ '_rundot_kinetix_physics_fluid_state_forces',
202
+ '_rundot_kinetix_physics_voxel_fluid_forces',
62
203
  '_rundot_kinetix_world_query',
204
+ '_rundot_kinetix_world_query_body_ray',
63
205
  '_rundot_kinetix_world_state_info',
64
206
  '_rundot_kinetix_world_copy_state',
65
207
  '_rundot_kinetix_world_capture_snapshot',
@@ -94,23 +236,31 @@ const profiles = {
94
236
  '_rundot_kinetix_physics_raycast',
95
237
  '_rundot_kinetix_physics_overlap',
96
238
  '_rundot_kinetix_physics_shape_cast',
239
+ ...extendedPhysicsExportedFunctions,
97
240
  ],
98
241
  metadata: {
99
- abiVersion: 18, bodyStride: 44, jointStride: 50, worldAbiVersion: 3, jointWarmStateStride: 160,
242
+ abiVersion: 21, bodyStride: 44, jointStride: 50, worldAbiVersion: 13, strongDigestAlgorithmRevision: 1, worldSnapshotVersion: 16, worldSnapshotVersions: [14, 15, 16], digestAlgorithmRevision: 2, jointWarmStateStride: 160,
100
243
  contactTelemetryStride: 9, jointTelemetryStride: 11,
101
244
  queryInputStride: 21, queryResultStride: 9,
102
245
  },
103
246
  },
104
247
  physics2d: {
105
248
  exceptionFlag: '-fno-exceptions',
249
+ extraFlags: ['-D_LIBCPP_VERBOSE_ABORT(...)=__builtin_trap()'],
106
250
  wasmName: 'physics2d.wasm',
107
251
  generatedPath: ['src', 'physics2d', 'physics2d-wasm-module.generated.mjs'],
108
252
  metadataExport: 'physics2dWasmMetadata',
109
253
  base64Export: 'physics2dWasmModuleBase64',
110
254
  sources: [
111
255
  'native/physics2d/physics2d.hpp', 'native/physics2d/physics2d.cpp',
256
+ 'native/physics2d/contour.hpp', 'native/physics2d/contour.cpp',
257
+ 'native/physics2d/ccd.hpp', 'native/physics2d/ccd.cpp',
258
+ 'native/physics2d/compound.hpp', 'native/physics2d/compound.cpp',
112
259
  'native/physics2d/fluid.hpp', 'native/physics2d/fluid.cpp',
113
260
  'native/physics2d/joints.hpp', 'native/physics2d/joints.cpp',
261
+ 'native/physics2d/joint_phases.hpp', 'native/physics2d/phase_test_hooks.hpp',
262
+ 'native/physics2d/clock_primitives.hpp',
263
+ 'native/physics2d/frame_scope.hpp', 'native/physics2d/memory_private.hpp', 'native/physics2d/checkpoint_memory.hpp',
114
264
  'native/physics2d/queries.hpp', 'native/physics2d/queries.cpp',
115
265
  'native/physics2d/world.hpp', 'native/physics2d/world.cpp',
116
266
  'native/physics2d/commands.hpp', 'native/physics2d/commands.cpp',
@@ -119,7 +269,9 @@ const profiles = {
119
269
  ...commonSources,
120
270
  ],
121
271
  compileSources: [
122
- 'native/physics2d/physics2d.cpp', 'native/physics2d/buoyancy.cpp',
272
+ 'native/physics2d/physics2d.cpp', 'native/physics2d/contour.cpp', 'native/physics2d/ccd.cpp',
273
+ 'native/physics2d/compound.cpp',
274
+ 'native/physics2d/buoyancy.cpp',
123
275
  'native/physics2d/fluid.cpp', 'native/physics2d/joints.cpp',
124
276
  'native/physics2d/queries.cpp',
125
277
  'native/physics2d/world.cpp',
@@ -130,13 +282,32 @@ const profiles = {
130
282
  exportedFunctions: [
131
283
  '_malloc', '_free',
132
284
  '_rundot_physics2d_owned_c_abi_version',
285
+ '_rundot_physics2d_owned_checkpoint_token_size',
286
+ '_rundot_physics2d_owned_instance_ledger_info',
287
+ '_rundot_physics2d_owned_instance_ledger_reset',
288
+ '_rundot_physics2d_owned_world_attach',
289
+ '_rundot_physics2d_owned_world_checkpoint_capacity',
290
+ '_rundot_physics2d_owned_world_checkpoint_capture_size_token',
291
+ '_rundot_physics2d_owned_world_checkpoint_capture_snapshot_token',
292
+ '_rundot_physics2d_owned_world_checkpoint_capture_token',
293
+ '_rundot_physics2d_owned_world_checkpoint_live_count',
294
+ '_rundot_physics2d_owned_world_checkpoint_preflight',
295
+ '_rundot_physics2d_owned_world_checkpoint_release_token',
296
+ '_rundot_physics2d_owned_world_checkpoint_restore_token',
297
+ '_rundot_physics2d_owned_world_detach',
298
+ '_rundot_physics2d_owned_world_restore_authorized',
299
+ '_rundot_physics2d_owned_world_revision',
300
+ '_rundot_physics2d_owned_world_sample_fluid_medium',
133
301
  '_rundot_physics2d_owned_world_storage_abi_version',
134
302
  '_rundot_physics2d_owned_snapshot_version',
135
303
  '_rundot_physics2d_owned_required_settings_abi_version',
136
304
  '_rundot_physics2d_owned_physics_profile',
137
- '_rundot_physics2d_owned_registry_size',
138
- '_rundot_physics2d_owned_registry_alignment',
139
305
  '_rundot_physics2d_owned_max_worlds_per_registry',
306
+ '_rundot_physics2d_owned_max_registries',
307
+ '_rundot_physics2d_owned_registry_create',
308
+ '_rundot_physics2d_owned_registry_destroy',
309
+ '_rundot_physics2d_owned_buffer_allocate',
310
+ '_rundot_physics2d_owned_buffer_free',
140
311
  '_rundot_physics2d_owned_world_key_size',
141
312
  '_rundot_physics2d_owned_world_capacity_size',
142
313
  '_rundot_physics2d_owned_world_settings_size',
@@ -147,8 +318,7 @@ const profiles = {
147
318
  '_rundot_physics2d_owned_entity_handle_size',
148
319
  '_rundot_physics2d_owned_removed_identity_size',
149
320
  '_rundot_physics2d_owned_body_payload_size',
150
- '_rundot_physics2d_owned_registry_init',
151
- '_rundot_physics2d_owned_registry_deinit',
321
+ '_rundot_physics2d_owned_contact_event_size',
152
322
  '_rundot_physics2d_owned_world_create',
153
323
  '_rundot_physics2d_owned_world_destroy',
154
324
  '_rundot_physics2d_owned_world_info',
@@ -161,6 +331,7 @@ const profiles = {
161
331
  '_rundot_physics2d_owned_world_read_body',
162
332
  '_rundot_physics2d_owned_world_read_joint',
163
333
  '_rundot_physics2d_owned_world_read_fluid',
334
+ '_rundot_physics2d_owned_world_read_contour_edges',
164
335
  '_rundot_physics2d_owned_world_copy_latest_outputs',
165
336
  '_rundot_physics2d_owned_world_capture',
166
337
  '_rundot_physics2d_owned_world_restore',
@@ -172,6 +343,7 @@ const profiles = {
172
343
  '_rundot_physics2d_owned_world_checkpoint_capture_snapshot',
173
344
  '_rundot_physics2d_owned_world_raycast',
174
345
  '_rundot_physics2d_owned_world_overlap',
346
+ '_rundot_physics2d_owned_world_overlap_contacts',
175
347
  '_rundot_physics2d_owned_world_shape_cast',
176
348
  '_rundot_physics2d_owned_world_closest_points',
177
349
  '_rundot_physics2d_abi_version',
@@ -184,7 +356,13 @@ const profiles = {
184
356
  '_rundot_physics2d_max_velocity_iterations',
185
357
  '_rundot_physics2d_polygon_geometry_size',
186
358
  '_rundot_physics2d_polygon_mass_properties_size',
359
+ '_rundot_physics2d_set_polygon_geometry',
360
+ '_rundot_physics2d_set_contour_geometry',
187
361
  '_rundot_physics2d_polygon_mass_properties',
362
+ '_rundot_physics2d_collide',
363
+ '_rundot_physics2d_ccd_abi_version',
364
+ '_rundot_physics2d_ccd_time_of_impact',
365
+ '_rundot_physics2d_ccd_time_of_impact_ex',
188
366
  '_rundot_physics2d_max_polygon_vertices',
189
367
  '_rundot_physics2d_fluid_abi_version',
190
368
  '_rundot_physics2d_fluid_region_size',
@@ -212,15 +390,35 @@ const profiles = {
212
390
  '_rundot_physics2d_cast_hit_size',
213
391
  '_rundot_physics2d_closest_point_hit_size',
214
392
  '_rundot_physics2d_overlap_hit_size',
393
+ '_rundot_physics2d_overlap_contact_hit_size',
394
+ '_rundot_physics2d_overlap_contacts',
215
395
  '_rundot_physics2d_submerged_geometry_abi_version',
216
396
  '_rundot_physics2d_submerged_geometry_input_size',
217
397
  '_rundot_physics2d_submerged_geometry_output_size',
218
398
  '_rundot_physics2d_submerged_geometry_max_vertices',
219
399
  '_rundot_physics2d_submerged_geometry_max_queries',
400
+ '_rundot_physics2d_submerged_geometry',
401
+ '_rundot_physics2d_compound_abi_version',
402
+ '_rundot_physics2d_compound_child_size',
403
+ '_rundot_physics2d_compound_body_size',
404
+ '_rundot_physics2d_compound_compute_mass',
405
+ '_rundot_physics2d_compound_collide',
406
+ '_rundot_physics2d_owned_particle_fluid_abi_version',
407
+ '_rundot_physics2d_owned_particle_fluid_state_size',
408
+ '_rundot_physics2d_owned_particle_fluid_config_size',
409
+ '_rundot_physics2d_owned_particle_fluid_particle_size',
410
+ '_rundot_physics2d_owned_particle_fluid_max_particles',
411
+ '_rundot_physics2d_owned_particle_fluid_init_grid',
412
+ '_rundot_physics2d_owned_particle_fluid_emit',
413
+ '_rundot_physics2d_owned_particle_fluid_step',
414
+ '_rundot_physics2d_owned_particle_fluid_sample',
415
+ '_rundot_physics2d_owned_particle_fluid_total_mass',
416
+ '_rundot_physics2d_owned_particle_fluid_volume',
417
+ '_rundot_physics2d_owned_particle_fluid_validate',
220
418
  ],
221
419
  metadata: {
222
- abiVersion: 2, bodyBytes: 144, manifoldBytes: 104, stepOptionsBytes: 32,
223
- ownedCAbiVersion: 1, worldAbiVersion: 2, worldSnapshotVersion: 2,
420
+ abiVersion: 5, bodyBytes: 160, manifoldBytes: 104, stepOptionsBytes: 32,
421
+ ownedCAbiVersion: 6, worldAbiVersion: 7, worldSnapshotVersion: 6,
224
422
  worldSettingsAbiVersion: 1, worldPhysicsProfile: 1,
225
423
  polygonGeometryBytes: 136, polygonMassPropertiesBytes: 32, maxPolygonVertices: 8,
226
424
  maxBodies: 4096, maxCandidatePairs: 1 << 18,
@@ -230,14 +428,25 @@ const profiles = {
230
428
  fluidAbiVersion: 1, fluidRegionBytes: 112, fluidStateBytes: 7176, maxFluidRegions: 64,
231
429
  jointAbiVersion: 2, jointRecordBytes: 160, jointStateBytes: 128, jointTelemetryBytes: 80,
232
430
  jointBreakEventBytes: 16, gearReactionBytes: 64, maxGearReactionEntries: 16384, maxJoints: 4096, maxJointWarmRows: 8, maxJointEvents: 4096,
233
- queryAbiVersion: 1, queryShapeBytes: 160, raycastQueryBytes: 48,
431
+ queryAbiVersion: 3, queryShapeBytes: 160, raycastQueryBytes: 48,
234
432
  overlapQueryBytes: 192, shapeCastQueryBytes: 216, closestPointsQueryBytes: 24,
235
- queryFilterBytes: 8, castHitBytes: 64, closestPointHitBytes: 40, overlapHitBytes: 8,
433
+ queryFilterBytes: 16, castHitBytes: 64, closestPointHitBytes: 40, overlapHitBytes: 8,
236
434
  },
237
435
  },
238
436
 
239
437
  };
240
438
 
439
+ const physicsProfile = {
440
+ ...profiles.physics3d,
441
+ profilingFunctions: true,
442
+ wasmName: 'physics-profile.wasm',
443
+ generatedPath: ['src', 'physics', 'physics-profile-wasm-module.generated.mjs'],
444
+ metadataExport: 'physicsProfileWasmMetadata',
445
+ base64Export: 'physicsProfileWasmModuleBase64',
446
+ assetPath: ['assets', 'physics-profile.wasm'],
447
+ assetMetadataPath: ['assets', 'physics-profile.metadata.json'],
448
+ };
449
+
241
450
  function probeCompiler() {
242
451
  for (const candidate of ['em++', 'emcc']) {
243
452
  const probe = spawnSync(candidate, ['--version'], { encoding: 'utf8' });
@@ -264,7 +473,7 @@ function compilerFlags(profile) {
264
473
  '--no-entry', '-sSTANDALONE_WASM=1', '-sALLOW_MEMORY_GROWTH=1',
265
474
  '-sABORTING_MALLOC=0',
266
475
  '-sERROR_ON_UNDEFINED_SYMBOLS=1',
267
- ...(profilingFunctions ? ['--profiling-funcs'] : []),
476
+ ...(profile.profilingFunctions ? ['--profiling-funcs'] : []),
268
477
  ...(profile.extraFlags ?? []),
269
478
  `-sEXPORTED_FUNCTIONS=[${profile.exportedFunctions.map((name) => JSON.stringify(name)).join(',')}]`,
270
479
  ];
@@ -277,6 +486,7 @@ function compileWasm(profile, compiler, wasmPath) {
277
486
  ...profile.compileSources.map((source) => join(root, source)),
278
487
  '-o', wasmPath,
279
488
  ], {
489
+ cwd: root,
280
490
  encoding: 'utf8',
281
491
  env: { ...process.env, EM_CACHE: join(buildDirectory, 'em-cache') },
282
492
  });
@@ -334,6 +544,11 @@ function buildProfile(profile, { check = false } = {}) {
334
544
  compilerVersion: compiler.version,
335
545
  sourceHash: expectedSourceHash,
336
546
  wasmSha256: createHash('sha256').update(wasmBytes).digest('hex'),
547
+ artifact: profile.profilingFunctions ? 'profile' : 'production',
548
+ packageVersion: JSON.parse(readFileSync(join(root, '..', 'package.json'), 'utf8')).version,
549
+ compilerFlags: compilerFlags(profile),
550
+ simulationSourceHash: profile.profilingFunctions
551
+ ? sourceHash(profiles.physics3d) : expectedSourceHash,
337
552
  };
338
553
  const generated = renderGenerated(profile, metadata, wasmBytes);
339
554
  if (check) {
@@ -342,11 +557,28 @@ function buildProfile(profile, { check = false } = {}) {
342
557
  if (JSON.stringify(current.metadata) !== JSON.stringify(rebuilt.metadata) || current.base64 !== rebuilt.base64) {
343
558
  throw new Error(`KINETIX_WASM_GENERATED_DRIFT ${generatedModulePath}`);
344
559
  }
560
+ if (profile.assetPath) {
561
+ const assetPath = join(root, ...profile.assetPath);
562
+ const assetMetadataPath = join(root, ...profile.assetMetadataPath);
563
+ if (!readFileSync(assetPath).equals(wasmBytes)
564
+ || readFileSync(assetMetadataPath, 'utf8') !== `${JSON.stringify(metadata, null, 2)}\n`) {
565
+ throw new Error(`KINETIX_WASM_PROFILE_ASSET_DRIFT ${assetPath}`);
566
+ }
567
+ }
345
568
  } else {
346
569
  mkdirSync(dirname(generatedModulePath), { recursive: true });
347
570
  const stagingPath = `${generatedModulePath}.${process.pid}.tmp`;
348
571
  writeFileSync(stagingPath, generated, 'utf8');
349
572
  renameSync(stagingPath, generatedModulePath);
573
+ if (profile.assetPath) {
574
+ const assetPath = join(root, ...profile.assetPath);
575
+ const assetMetadataPath = join(root, ...profile.assetMetadataPath);
576
+ mkdirSync(dirname(assetPath), { recursive: true });
577
+ writeFileSync(`${assetPath}.${process.pid}.tmp`, wasmBytes);
578
+ renameSync(`${assetPath}.${process.pid}.tmp`, assetPath);
579
+ writeFileSync(`${assetMetadataPath}.${process.pid}.tmp`, `${JSON.stringify(metadata, null, 2)}\n`);
580
+ renameSync(`${assetMetadataPath}.${process.pid}.tmp`, assetMetadataPath);
581
+ }
350
582
  }
351
583
  return { metadata, wasmPath, generatedModulePath };
352
584
  }
@@ -362,7 +594,11 @@ function invokedDirectly() {
362
594
  }
363
595
 
364
596
  export function buildWasmPhysics(options = {}) {
365
- return buildProfile(profiles.physics3d, options);
597
+ const artifact = options.artifact ?? (profilingFunctions ? 'profile' : 'production');
598
+ if (artifact !== 'production' && artifact !== 'profile') {
599
+ throw new Error('KINETIX_WASM_ARTIFACT_INVALID artifact must be production or profile');
600
+ }
601
+ return buildProfile(artifact === 'profile' ? physicsProfile : profiles.physics3d, options);
366
602
  }
367
603
 
368
604
  export function buildWasmPhysics2D(options = {}) {
@@ -370,7 +606,8 @@ export function buildWasmPhysics2D(options = {}) {
370
606
  }
371
607
 
372
608
  export function getWasmPhysicsSourceHashes() {
373
- return Object.fromEntries(Object.entries(profiles).map(([name, profile]) => [name, sourceHash(profile)]));
609
+ return Object.fromEntries([...Object.entries(profiles), ['physics3dProfile', physicsProfile]]
610
+ .map(([name, profile]) => [name, sourceHash(profile)]));
374
611
  }
375
612
 
376
613
  /**
@@ -380,7 +617,7 @@ export function getWasmPhysicsSourceHashes() {
380
617
  */
381
618
  export function getWasmNumericProfile({ all = false } = {}) {
382
619
  const targetProfiles = all
383
- ? Object.entries(profiles)
620
+ ? [...Object.entries(profiles), ['physics3dProfile', physicsProfile]]
384
621
  : Object.entries(profiles).filter(([name]) => name === 'physics3d' || name === 'physics2d');
385
622
  return Object.freeze(targetProfiles.map(([name, profile]) => Object.freeze({
386
623
  artifact: name,
@@ -391,9 +628,21 @@ export function getWasmNumericProfile({ all = false } = {}) {
391
628
 
392
629
  if (invokedDirectly()) {
393
630
  const check = process.argv.includes('--check');
394
- const results = [
395
- buildWasmPhysics({ check }),
396
- buildWasmPhysics2D({ check }),
397
- ];
631
+ const profileArg = process.argv.find((arg) => arg.startsWith('--profile='));
632
+ const profileName = profileArg ? profileArg.split('=')[1]
633
+ : profilingFunctions ? 'physics3d-profile' : null;
634
+ if (profileName !== null && !['physics3d', 'physics3d-profile', 'physics2d'].includes(profileName)) {
635
+ throw new Error(`KINETIX_WASM_PROFILE_INVALID ${profileName}`);
636
+ }
637
+ const results = [];
638
+ if (!profileName || profileName === 'physics3d') {
639
+ results.push(buildWasmPhysics({ check, artifact: 'production' }));
640
+ }
641
+ if (profileName === 'physics3d-profile') {
642
+ results.push(buildWasmPhysics({ check, artifact: 'profile' }));
643
+ }
644
+ if (!profileName || profileName === 'physics2d') {
645
+ results.push(buildWasmPhysics2D({ check }));
646
+ }
398
647
  for (const result of results) console.log(`KINETIX_WASM_BUILD_OK ${result.wasmPath}`);
399
648
  }