@series-inc/rundot-syncplay 6.0.0-rc.3 → 6.0.0-rc.31

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 (200) hide show
  1. package/MIGRATING-RC20-TO-RC22.md +133 -0
  2. package/MIGRATING-RC28-TO-RC29.md +51 -0
  3. package/README.md +133 -0
  4. package/core/deterministic-math.d.ts +75 -1
  5. package/core/native/instance_ledger.hpp +1095 -0
  6. package/core/native/legacy_checkpoint_ids.hpp +107 -0
  7. package/core/native/physics/abi.cpp +5 -0
  8. package/core/native/physics/abi.hpp +2 -0
  9. package/core/native/physics/buoyancy.cpp +432 -54
  10. package/core/native/physics/buoyancy.hpp +48 -0
  11. package/core/native/physics/capsule_triangle_native.inc +57 -17
  12. package/core/native/physics/certified_sum.hpp +218 -0
  13. package/core/native/physics/checkpoint_schema.hpp +379 -0
  14. package/core/native/physics/constraint_rows.cpp +2 -2
  15. package/core/native/physics/constraint_rows.hpp +4 -1
  16. package/core/native/physics/exact/exact-applied.hpp +57 -1
  17. package/core/native/physics/exact/word-core.hpp +1 -0
  18. package/core/native/physics/geometry_memory.hpp +435 -11
  19. package/core/native/physics/geometry_store.cpp +379 -25
  20. package/core/native/physics/geometry_store.hpp +40 -2
  21. package/core/native/physics/material_pose.hpp +628 -320
  22. package/core/native/physics/physics.cpp +1305 -188
  23. package/core/native/physics/physics.hpp +89 -2
  24. package/core/native/physics/topology.cpp +236 -8
  25. package/core/native/physics/topology.hpp +60 -2
  26. package/core/native/physics/world.cpp +4207 -511
  27. package/core/native/physics/world.hpp +722 -23
  28. package/core/native/physics/world_abi.cpp +3589 -440
  29. package/core/native/physics/world_abi.hpp +462 -10
  30. package/core/native/physics/world_digest_visitor.hpp +277 -0
  31. package/core/native/physics/world_strong_digest.hpp +557 -0
  32. package/core/native/physics2d/ccd.cpp +137 -8
  33. package/core/native/physics2d/checkpoint_memory.hpp +349 -0
  34. package/core/native/physics2d/commands.cpp +163 -25
  35. package/core/native/physics2d/commands.hpp +2 -0
  36. package/core/native/physics2d/contour.cpp +325 -0
  37. package/core/native/physics2d/contour.hpp +143 -0
  38. package/core/native/physics2d/joints.cpp +14 -23
  39. package/core/native/physics2d/memory_private.hpp +125 -0
  40. package/core/native/physics2d/owned_abi.cpp +1351 -898
  41. package/core/native/physics2d/owned_abi.hpp +177 -44
  42. package/core/native/physics2d/physics2d.cpp +1133 -59
  43. package/core/native/physics2d/physics2d.hpp +86 -1
  44. package/core/native/physics2d/queries.cpp +1046 -77
  45. package/core/native/physics2d/queries.hpp +62 -4
  46. package/core/native/physics2d/world.cpp +982 -357
  47. package/core/native/physics2d/world.hpp +109 -11
  48. package/core/native/sha256/sha256_compress_unsigned.hpp +68 -0
  49. package/core/native/sha256/sha256_fips_constants.hpp +24 -0
  50. package/core/native/sha256/sha256_length.hpp +56 -0
  51. package/core/native/sha256/sha256_memo.hpp +48 -0
  52. package/core/native/sha256/sha256_sink.hpp +234 -0
  53. package/core/physics2d-owned.d.ts +327 -154
  54. package/core/runtime.d.ts +192 -19
  55. package/core/scripts/build-native.mjs +12 -0
  56. package/core/scripts/build-wasm-physics.mjs +170 -22
  57. package/core/scripts/generate-physics2d-vectors.mjs +59 -0
  58. package/core/src/kinetix-deterministic-math.d.ts +2 -0
  59. package/core/src/kinetix-deterministic-math.mjs +513 -27
  60. package/core/src/kinetix-owned-runtime-adapter.mjs +788 -0
  61. package/core/src/kinetix-runtime-adapter-utils.mjs +44 -2
  62. package/core/src/kinetix-runtime-contract.mjs +55 -9
  63. package/core/src/kinetix-runtime-identity.mjs +12 -1
  64. package/core/src/kinetix-state-report.mjs +36 -0
  65. package/core/src/physics/abi-constants.mjs +5 -4
  66. package/core/src/physics/buoyancy.d.mts +132 -55
  67. package/core/src/physics/buoyancy.mjs +160 -4
  68. package/core/src/physics/distance.d.mts +160 -7
  69. package/core/src/physics/feature-api.d.mts +13 -585
  70. package/core/src/physics/gear.d.mts +544 -301
  71. package/core/src/physics/mass-properties.d.mts +114 -3
  72. package/core/src/physics/physics-profile-wasm-module.generated.mjs +48 -0
  73. package/core/src/physics/physics-wasm-module.generated.mjs +34 -6
  74. package/core/src/physics/powertrain.d.mts +256 -226
  75. package/core/src/physics/pulley.d.mts +92 -349
  76. package/core/src/physics/rope.d.mts +230 -29
  77. package/core/src/physics/surface-velocity.d.mts +152 -196
  78. package/core/src/physics/voxel-cooking.d.mts +36 -20
  79. package/core/src/physics/voxel-cooking.mjs +71 -2
  80. package/core/src/physics/voxel-swept-quad.mjs +110 -0
  81. package/core/src/physics/wasm-instance.mjs +142 -26
  82. package/core/src/physics/world.d.mts +62 -0
  83. package/core/src/physics/world.mjs +1743 -175
  84. package/core/src/physics2d/body-state.mjs +45 -5
  85. package/core/src/physics2d/collision.d.mts +13 -11
  86. package/core/src/physics2d/collision.mjs +39 -3
  87. package/core/src/physics2d/contour-state.mjs +771 -0
  88. package/core/src/physics2d/feature-api.d.mts +207 -1
  89. package/core/src/physics2d/owned-queries.mjs +3 -1
  90. package/core/src/physics2d/owned-transport.mjs +245 -113
  91. package/core/src/physics2d/owned-world.mjs +202 -62
  92. package/core/src/physics2d/particle-fluid.d.mts +139 -30
  93. package/core/src/physics2d/particle-fluid.mjs +67 -31
  94. package/core/src/physics2d/physics2d-wasm-module.generated.mjs +25 -8
  95. package/core/src/physics2d/query-codec.mjs +40 -6
  96. package/core/src/physics2d/submerged-geometry.d.mts +35 -16
  97. package/core/src/runtime.mjs +23 -0
  98. package/core/src/shared/bytes.d.mts +2 -0
  99. package/core/src/shared/bytes.mjs +33 -0
  100. package/core/src/shared/sha256.d.mts +3 -0
  101. package/core/src/shared/sha256.mjs +72 -22
  102. package/core/units.d.ts +50 -0
  103. package/core/world.d.ts +203 -2
  104. package/dist/authority-room.d.ts +9 -0
  105. package/dist/authority-room.js +40 -15
  106. package/dist/browser.d.ts +6 -5
  107. package/dist/browser.js +4 -3
  108. package/dist/cadence.d.ts +7 -0
  109. package/dist/cadence.js +19 -0
  110. package/dist/canonical.d.ts +1 -0
  111. package/dist/canonical.js +3 -0
  112. package/dist/checksum-policy.d.ts +10 -0
  113. package/dist/checksum-policy.js +14 -0
  114. package/dist/compat/v5.d.ts +5 -1
  115. package/dist/compat/v5.js +52 -9
  116. package/dist/creator.d.ts +7 -6
  117. package/dist/creator.js +4 -3
  118. package/dist/game-byte-section.d.ts +36 -0
  119. package/dist/game-byte-section.js +350 -0
  120. package/dist/index.d.ts +16 -7
  121. package/dist/index.js +12 -5
  122. package/dist/instant-replay.d.ts +27 -2
  123. package/dist/instant-replay.js +91 -16
  124. package/dist/lag-compensation3d.js +11 -10
  125. package/dist/match-log.d.ts +21 -4
  126. package/dist/match-log.js +92 -9
  127. package/dist/math.d.ts +2 -0
  128. package/dist/math.js +1 -0
  129. package/dist/modules/character-3d.d.ts +16 -1
  130. package/dist/modules/character-3d.js +42 -5
  131. package/dist/modules/combat.js +6 -5
  132. package/dist/movement3d-revision1.d.ts +2 -0
  133. package/dist/movement3d-revision1.js +973 -0
  134. package/dist/movement3d.d.ts +106 -3
  135. package/dist/movement3d.js +1270 -250
  136. package/dist/networked-client.d.ts +15 -0
  137. package/dist/networked-client.js +378 -105
  138. package/dist/node.d.ts +3 -2
  139. package/dist/node.js +2 -1
  140. package/dist/physics/2d.d.ts +19 -4
  141. package/dist/physics/2d.js +31 -6
  142. package/dist/physics/3d.d.ts +672 -238
  143. package/dist/physics/3d.js +3361 -397
  144. package/dist/physics/edit-result-graph.d.ts +36 -0
  145. package/dist/physics/edit-result-graph.js +141 -0
  146. package/dist/physics/game-codec3d.d.ts +41 -0
  147. package/dist/physics/game-codec3d.js +544 -0
  148. package/dist/physics/installed-checkpoint3d.d.ts +13 -0
  149. package/dist/physics/installed-checkpoint3d.js +120 -0
  150. package/dist/physics/installed-runtime3d.d.ts +51 -0
  151. package/dist/physics/installed-runtime3d.js +372 -0
  152. package/dist/physics/installed-state-commitment3d.d.ts +2 -0
  153. package/dist/physics/installed-state-commitment3d.js +24 -0
  154. package/dist/physics/units.d.ts +94 -0
  155. package/dist/physics/units.js +92 -0
  156. package/dist/physics/vehicle-state3d.d.ts +97 -0
  157. package/dist/physics/vehicle-state3d.js +1316 -0
  158. package/dist/physics/voxel-body-state.d.ts +61 -0
  159. package/dist/physics/voxel-body-state.js +410 -0
  160. package/dist/r3f-render-adapter.d.ts +59 -1
  161. package/dist/r3f-render-adapter.js +137 -2
  162. package/dist/replay.d.ts +13 -0
  163. package/dist/replay.js +95 -70
  164. package/dist/runner.d.ts +17 -2
  165. package/dist/runner.js +472 -84
  166. package/dist/runtime-cleanup.d.ts +54 -0
  167. package/dist/runtime-cleanup.js +266 -0
  168. package/dist/runtime-lease.d.ts +11 -1
  169. package/dist/runtime-lease.js +23 -10
  170. package/dist/runtime-room-metadata.d.ts +2 -8
  171. package/dist/runtime-room-metadata.js +6 -13
  172. package/dist/runtime-session.d.ts +8 -0
  173. package/dist/runtime-session.js +217 -57
  174. package/dist/schema-codegen.js +3 -0
  175. package/dist/schema-dsl-binary.d.ts +10 -4
  176. package/dist/schema-dsl-binary.js +375 -76
  177. package/dist/scratch-pool.d.ts +32 -0
  178. package/dist/scratch-pool.js +60 -0
  179. package/dist/sdk-session.d.ts +1 -0
  180. package/dist/sdk-session.js +4 -0
  181. package/dist/secret-config.js +2 -60
  182. package/dist/secret-crypto.js +70 -36
  183. package/dist/session-snapshot.d.ts +15 -4
  184. package/dist/session-snapshot.js +35 -33
  185. package/dist/session-wire.js +8 -20
  186. package/dist/sparse-set.d.ts +1 -0
  187. package/dist/sparse-set.js +22 -0
  188. package/dist/spatial/spatial-grid-3d.d.ts +41 -0
  189. package/dist/spatial/spatial-grid-3d.js +115 -0
  190. package/dist/synctest.d.ts +9 -0
  191. package/dist/synctest.js +106 -17
  192. package/dist/testing-network.d.ts +2 -0
  193. package/dist/testing-network.js +122 -18
  194. package/dist/testing.d.ts +27 -6
  195. package/dist/testing.js +297 -56
  196. package/dist/tools/index.d.ts +3 -2
  197. package/dist/tools/index.js +3 -2
  198. package/dist/tools/module-certification.d.ts +6 -0
  199. package/dist/tools/module-certification.js +26 -2
  200. package/package.json +15 -6
@@ -0,0 +1,133 @@
1
+ # Migrating from Syncplay 6.0.0-rc.20 to rc.22
2
+
3
+ Syncplay `6.0.0-rc.22` introduces ergonomics improvements for branded units, public state codecs for game-owned state containing `bigint` physics identifiers, generalized multi-wheel vehicle verification, and explicit guidance for Kinematic Character Controller (KCC) Revision 2.
4
+
5
+ ---
6
+
7
+ ## 1. Branded Vector Helpers & Migration Codemod (Item 10)
8
+
9
+ ### What Changed
10
+ In rc.20, unit branding (`Meters`, `Radians`, `Newtons`, etc.) was tightened across all physics APIs to prevent unit mismatch bugs. However, writing `{ x: meters(a), y: meters(b), z: meters(c) }` across hundreds of lines introduces substantial boilerplate.
11
+
12
+ rc.22 exports convenient vector constructors that accept both positional coordinates and existing `{ x, y, z }` record objects:
13
+
14
+ ```ts
15
+ import {
16
+ meters3,
17
+ radians3,
18
+ metersPerSecond3,
19
+ metersPerSecondSquared3,
20
+ newtons3,
21
+ vec3,
22
+ meters2,
23
+ radians2,
24
+ metersPerSecond2,
25
+ vec2,
26
+ } from '@series-inc/rundot-syncplay/physics/3d';
27
+ ```
28
+
29
+ ### Usage
30
+
31
+ ```ts
32
+ // Positional coordinates
33
+ const pos = meters3(0, 1.5, -2);
34
+ const vel = metersPerSecond3(0, 0, 15);
35
+ const force = newtons3(0, 500, 0);
36
+
37
+ // Object coordinates (drop-in wrapper for legacy vector objects)
38
+ const legacyVec = { x: 10, y: 0, z: -5 };
39
+ const brandedPos = meters3(legacyVec);
40
+
41
+ // Custom brands
42
+ const custom = vec3(turns, 0.1, 0.2, 0.3);
43
+ ```
44
+
45
+ ### Regex / Search & Replace Codemod
46
+
47
+ If your codebase has repetitive manual `{ x: meters(...), y: meters(...), z: meters(...) }` calls, you can migrate them with the following regular expressions:
48
+
49
+ - **Find:**
50
+ ```regexp
51
+ \{\s*x:\s*meters\(([^)]+)\),\s*y:\s*meters\(([^)]+)\),\s*z:\s*meters\(([^)]+)\)\s*\}
52
+ ```
53
+ - **Replace:**
54
+ ```ts
55
+ meters3($1, $2, $3)
56
+ ```
57
+
58
+ - **2D Vectors Find:**
59
+ ```regexp
60
+ \{\s*x:\s*meters\(([^)]+)\),\s*y:\s*meters\(([^)]+)\)\s*\}
61
+ ```
62
+ - **Replace:**
63
+ ```ts
64
+ meters2($1, $2)
65
+ ```
66
+
67
+ ---
68
+
69
+ ## 2. KCC Revision 2: Native Step-Up & Platform Support Persistence (Item 11)
70
+
71
+ ### Native Step-Up (No Custom Raycast Hacks)
72
+ In Revision 1, stepping up over vertical edges (curbs, stairs, debris) often required game-side raycasts to manually nudge the character upward before stepping.
73
+
74
+ In **Revision 2 (`behaviorRevision: 2`)**, the solver natively sweeps the bottom spherical cap against vertical steps up to `stepHeight`.
75
+ - Author `stepHeight: 0.3` (or your desired maximum step height in meters).
76
+ - A 0.2 m vertical edge will be climbed smoothly and deterministically without clipping or snagging.
77
+ - **Action Required:** Remove any custom game-side pre-step raycasts or edge-nudging hacks; they are redundant and can interfere with the native solver's ground alignment.
78
+
79
+ ### Crucial: Persist the `support` Field Across Ticks
80
+ Revision 2 introduces physical moving-platform carry and continuous contact resolution via the `support` property on `DeterministicKccState3D` / step result.
81
+
82
+ ```ts
83
+ // Ticking KCC Revision 2:
84
+ const result = stepDeterministicKcc3D(input, {
85
+ ...currentState,
86
+ // CRITICAL: Pass back the support returned from the previous tick!
87
+ support: lastStepResult.support,
88
+ }, world, options);
89
+ ```
90
+
91
+ > [!IMPORTANT]
92
+ > If your game drops `support` or creates a fresh state object each frame without copying `lastStepResult.support`, the character controller will not inherit platform velocity or maintain stable ground contact.
93
+
94
+ ---
95
+
96
+ ## 3. Game-Owned State Codecs for BigInt Body IDs (Item 8)
97
+
98
+ ### What Changed
99
+ `DeterministicVehicleState3D` and `DeterministicKccSupport3D` (when `kind: 'physics'`) carry native 64-bit `PhysicsBodyId3D` values represented as JavaScript `bigint` primitives.
100
+
101
+ Standard `JSON.stringify(state)` throws:
102
+ ```
103
+ TypeError: Do not know how to serialize a BigInt
104
+ ```
105
+
106
+ ### Solution
107
+ Syncplay rc.22 exports canonical serialization and deserialization helpers that encode `bigint` without loss:
108
+
109
+ ```ts
110
+ import {
111
+ encodeDeterministicVehicleState3D,
112
+ decodeDeterministicVehicleState3D,
113
+ encodeDeterministicVehicleState3DBytes,
114
+ decodeDeterministicVehicleState3DBytes,
115
+ encodeDeterministicKccSupport3D,
116
+ decodeDeterministicKccSupport3D,
117
+ encodeDeterministicKccSupport3DBytes,
118
+ decodeDeterministicKccSupport3DBytes,
119
+ } from '@series-inc/rundot-syncplay/physics/3d';
120
+
121
+ // Save vehicle state to JSON string or binary Uint8Array
122
+ const savedJson = encodeDeterministicVehicleState3D(vehicleState);
123
+ const savedBytes = encodeDeterministicVehicleState3DBytes(vehicleState);
124
+
125
+ // Restore vehicle state
126
+ const restoredState = decodeDeterministicVehicleState3D(savedJson);
127
+
128
+ // Save KCC support state
129
+ const savedSupportJson = encodeDeterministicKccSupport3D(kccResult.support);
130
+ const restoredSupport = decodeDeterministicKccSupport3D(savedSupportJson);
131
+ ```
132
+
133
+ These functions use canonical JSON formatting with BigInt sentinels (`{"$rdm":"bigint","value":"..."}`) ensuring bit-identical hashing and portable network snapshots across clients.
@@ -0,0 +1,51 @@
1
+ # Migrating from Syncplay 6.0.0-rc.28 to rc.29
2
+
3
+ Syncplay `6.0.0-rc.29` resolves partner feedback on portal physics, doorway aperture sliding, character controller pending body references, and output parity across checkpoint restores.
4
+
5
+ ---
6
+
7
+ ## 1. Reserved Collision Layers 24–30 (Portal Host Slots)
8
+
9
+ ### What Changed
10
+ To provide zero-overhead wall aperture cutouts without altering the native C++ physics solver, Syncplay dynamically isolates portal host colliders by temporarily shifting host bodies to dedicated internal filtering layers.
11
+
12
+ - **Bits 24 through 30 (`0x7f000000`)** in the 32-bit collision layer bitmask are now reserved for internal portal host filtering.
13
+ - Up to **7 distinct host bodies** can be registered concurrently across active portal pairs in a physics world.
14
+ - Host slots are dynamically allocated upon portal pair creation and automatically reclaimed when the portal pair is removed via `removePortalPair(handle)`.
15
+
16
+ ### Action Required
17
+ If your game uses layers 24 through 30 for custom gameplay categories (such as projectiles, debris, or triggers), those categories will conflict with portal host suppression.
18
+ - Move custom gameplay categories to unreserved layers (bits 0 through 23).
19
+ - Update any layer bitmasks (`mask` and `layerMask` queries) that reference layers 24–30.
20
+
21
+ ---
22
+
23
+ ## 2. Aperture Containment Tolerance (0.05 m per Boundary)
24
+
25
+ ### What Changed
26
+ In rc.28, resting contact solvers permitted normal micro-penetration (~2 mm under gravity). For bodies sliding into doorways where the portal aperture started at floor height ($y=0$), the body's lower bounds slightly breached the zero margin, causing the wall host collider to remain active and stopping the body at the frame.
27
+
28
+ In rc.29, aperture containment calculations incorporate an explicit margin tolerance of **0.05 m (5 cm)** per projected boundary:
29
+
30
+ $$|x| + e_x \le \frac{W}{2} + 0.05, \qquad |y| + e_y \le \frac{H}{2} + 0.05$$
31
+
32
+ ### Behavior
33
+ - A centered body can be up to **0.10 m wider** than the opening ($0.05\text{ m}$ on each side) and still pass through without being blocked by the host wall.
34
+ - Bodies that protrude more than 0.05 m past any single boundary remain blocked by the wall collider.
35
+ - Floor-level doorways admit resting boxes and angled approaches smoothly without catching.
36
+
37
+ ---
38
+
39
+ ## 3. KCC Explicit Portals: Pending Body References
40
+
41
+ ### What Changed
42
+ When creating a character controller and a portal pair inside the same `world.edit()` transaction, passing `hostBodyId` as the pending body reference object returned by `edit.createBody()` previously threw `SyntaxError: Cannot convert [object Object] to a BigInt`.
43
+
44
+ In rc.29, character controller portal ingestion automatically resolves pending body references through `physics.resolveBody(ref).id`, accepting raw `BigInt`, number, string, live handle, or pending reference objects.
45
+
46
+ ---
47
+
48
+ ## 4. Checkpoint Output Parity
49
+
50
+ ### What Changed
51
+ `world.checkpointLatest(checkpoint)` now satisfies the full `PhysicsLatestOutputs3D` contract, returning frozen empty arrays for `portalCrossings: []` and `motionBatch: { count: 0, bodies: [] }` on checkpoint reads, guaranteeing strict deep-equality against `world.latest()` on non-crossing frames.
package/README.md CHANGED
@@ -459,6 +459,44 @@ Call `initPhysics2D()` or `initPhysics3D()` before world creation. Create an
459
459
  owned world with `createPhysicsWorld2D()` or `createPhysicsWorld3D()`. Each
460
460
  world provides fixed stepping, atomic edits, retained queries, opaque native
461
461
  checkpoints, portable checkpoint bytes, a state digest, and explicit disposal.
462
+ The 2D engine supports circle, box, capsule, polygon, segment, chain, piecewise
463
+ contour loops, and circular quadrant arcs with the free-side collision rule and
464
+ strict deterministic query tie-ordering.
465
+
466
+ Store logical body IDs in checkpointed game state. A hit has `bodyId`. A
467
+ contact has `bodyA` and `bodyB`. Keep an application `Map` from these `bigint`
468
+ IDs to entities. Each contact then uses `entities.get(contact.bodyA)` and
469
+ `entities.get(contact.bodyB)`. It requires no body-name scan.
470
+
471
+ Resolve a fresh handle with `world.resolveBody(id)` after a restore. Old
472
+ handles are stale. Transfer IDs as decimal strings if the game codec does not
473
+ support `bigint`. Convert them with `BigInt(text)`, never `Number(text)`.
474
+ Rebuild the lookup from the restored game state before processing contacts.
475
+ Physics checkpoints do not contain the application's entity table. Transfer
476
+ and restore both parts of the same frame.
477
+
478
+ ### Grab servo revision 2
479
+
480
+ Set `behaviorRevision: 2` to use gravity compensation, target velocity,
481
+ angular damping, and the corrected local anchor. Revision 2 rotates the local
482
+ anchor with the body orientation. Existing calls use revision 1.
483
+
484
+ Use `createGrabServoState3D()` and `stepGrabServo3D()` for explicit game state.
485
+ Store the returned state with the physics checkpoint. The object wrapper
486
+ provides `capture()` and `restore()` for the same state. Restore both parts of
487
+ the same frame. The servo resolves the body ID after a physics restore.
488
+
489
+ Force and acceleration limits apply to the total force in revision 2.
490
+ This includes gravity compensation. Torque limits apply to total torque.
491
+ One scale applies to all three components. A limit can reduce compensation,
492
+ so the body can fall. The default force limit is 1000 N. A 150 kg body under
493
+ 9.81 m/s² gravity requires more than this limit to hold its position.
494
+ Choose limits for the body's mass and gravity. A binding limit cannot promise
495
+ position holding. Revision 1 keeps its earlier acceleration-limit rule.
496
+
497
+ Include the helper revision in canonical session configuration and the game
498
+ deterministic version. Store targets, tuning, force limits, release state,
499
+ and body IDs in checkpointed game state.
462
500
 
463
501
  The TypeScript facade does not contain a second solver. Both dimensions run in
464
502
  the canonical C++ core compiled to WASM. The internal solver algorithm, state
@@ -475,3 +513,98 @@ the [3D guide](https://github.com/series-ai/venus/blob/develop/packages/sdk-docs
475
513
  the [RC1 migration helper](https://github.com/series-ai/venus/blob/develop/packages/sdk-docs/rundot-developer-platform/api/SYNCPLAY-RC1-MIGRATION.md).
476
514
  Physical-phone performance remains a release gate. Do not infer phone results
477
515
  from desktop measurements.
516
+
517
+ Restore the physics world before you restore a grab servo state. Revision 2 accepts
518
+ an active state whose body was removed in the same tick. Its next step changes
519
+ the state to `released` with reason `body-removed`. That step applies no force.
520
+ `isBroken()` reads the current condition. It does not change the captured state.
521
+
522
+ Revision 1 keeps its body handle until you restore the servo state. A physics
523
+ restore makes the old handle stale. Restore both states before the next step.
524
+
525
+ ### SI types in the next RC
526
+
527
+ The next RC requires SI constructors at typed physics call sites. Replace plain
528
+ numbers with the constructor for each quantity. Use meters for positions,
529
+ kilograms for mass, metersPerSecond for linear velocity, and newtons for force.
530
+ Use frameVelocity and frameGravity for frame quantities. Each constructor keeps
531
+ the bits of a finite input. It rejects NaN and infinity.
532
+
533
+ This change can produce TypeScript errors in existing games. Update those call
534
+ sites when you upgrade the SDK. Revision 1 helper behavior remains selected by
535
+ default. The revision 1 tests compare complete results with the previous RC.
536
+ New helper behavior requires an explicit revision selection.
537
+
538
+ ### Shape-preserving body changes
539
+
540
+ Use `world.setBodyTransform(idOrHandle, { position, orientation })` to change a pose.
541
+ Use `meters()` for each position component.
542
+ The world normalizes the quaternion.
543
+ The operation keeps the shape, mass, inertia, logical ID, and velocities.
544
+ An identical normalized pose preserves sleep and the mutation revision.
545
+ A changed pose wakes the affected dynamic joint group.
546
+
547
+ Use `world.setBodyLinearDamping(idOrHandle, factor)` to change linear damping.
548
+ The factor is the fraction of velocity kept per tick.
549
+ Its range is 0 through 1.
550
+ The operation preserves sleep.
551
+ Use `world.wakeBody(idOrHandle)` to wake a dynamic body without a velocity change.
552
+ Resolve a new handle after a checkpoint restore, or use the logical ID.
553
+
554
+ ### Batch motion output
555
+
556
+ `world.writeBodyMotionInto(poses, velocities, ids, status)` returns the body count,
557
+ mutation `revision`, and `restoreEpoch`.
558
+ Use `Float64Array` for poses and velocities.
559
+ Use `BigUint64Array` for logical IDs.
560
+ Use `Uint8Array` for status.
561
+ The output orders bodies by ascending logical ID.
562
+
563
+ Each pose has seven values: x, y, z, qx, qy, qz, qw.
564
+ Each velocity has six values: vx, vy, vz, wx, wy, wz.
565
+ Positions use meters.
566
+ Linear velocities use meters per second.
567
+ Angular velocities use radians per second.
568
+ Quaternion components have no unit.
569
+
570
+ Status bits 0 and 1 contain the body kind: static 0, dynamic 1, or kinematic 2.
571
+ Bit 2 means trigger.
572
+ Bit 3 means sensor.
573
+ Bit 4 means sleeping.
574
+ Bit 5 means angular motion is enabled.
575
+ The operation checks all buffers before it writes a value.
576
+ It preserves the unused output suffix.
577
+
578
+
579
+ Engine RPM values use `turnsPerMinute(value)`.
580
+ The powertrain reverse-gear check takes `metersPerSecond(value)`.
581
+ These constructors preserve finite values and reject NaN and infinity.
582
+
583
+ The 2D particle emitter preserves a supplied particle ID.
584
+ An omitted ID or zero requests the next automatic ID.
585
+ A supplied ID must be unique and from 1 through 4294967294.
586
+ Particle records stay in increasing ID order.
587
+
588
+ `createVoxelBody3D` creates a native body and immutable voxel state.
589
+ Store the returned state in the captured game state.
590
+ `carveVoxelBody3D` stages a cut and publishes one body edit after cooking succeeds.
591
+ Use its returned state for the next cut.
592
+ `paintVoxelBody3D` changes material IDs and keeps the same collision children.
593
+ `hydrateVoxelBodyState3D` checks the stored partition against the restored native body.
594
+ It does not replace that partition with a full cook.
595
+
596
+ Body-level sphere, capsule, and swept-quad regions use body-local meters.
597
+ Box regions use integer cell indices.
598
+ The body API accounts for `originOffset` in SI regions.
599
+ Occupancy must contain only zero and one.
600
+ Each occupied cell keeps its initial mass when a cut removes other cells.
601
+ A cut preserves the velocity of retained material when the center of mass changes.
602
+ Locked velocity components stay zero.
603
+
604
+ A removed voxel state keeps only its body ID, format, revision, and removed status.
605
+ Hydration checks that its revision is positive and its body ID is absent.
606
+ This absence check does not prove which world first allocated the removed ID.
607
+
608
+ `voxelBodyDigest3D(state)` returns the cached SHA-256 content digest. Creation, edits, and hydration compute this digest once per immutable root. Repeated reads do not scan cells or cooked children. The digest includes the body ID, revision, dimensions, occupancy, materials, child IDs and descriptors, next ID, cell mass, origin offset, and child limit. Hydrate a copied or decoded root before you read its digest or use it in carve, paint, or remove. These operations accept only roots registered by this module instance. If two package copies load, hydrate the root in the receiving copy.
609
+
610
+ Pass the current voxel root to each edit. Native validation detects differences in geometry and mass. It cannot detect a stale root that differs only in paint. Keep the returned root in canonical game state. Use that root for each later cut, paint, or removal.
@@ -1,2 +1,76 @@
1
+ export declare const DETERMINISTIC_MATH_PROFILE: string;
2
+ export declare const DETERMINISTIC_MATH_VERSION: string;
1
3
  export declare const DETERMINISTIC_MATH_SOURCE: string;
2
- export declare function installDeterministicMath(): void;
4
+ export declare const DETERMINISTIC_MATH_FUNCTIONS: readonly string[];
5
+
6
+ export interface DeterministicMathKnownAnswer {
7
+ readonly name: string;
8
+ readonly args: readonly number[];
9
+ readonly hex: string;
10
+ }
11
+
12
+ export declare const DETERMINISTIC_MATH_KNOWN_ANSWERS: readonly DeterministicMathKnownAnswer[];
13
+
14
+ export type DeterministicMathConflictReason =
15
+ | 'profile_mismatch'
16
+ | 'version_mismatch'
17
+ | 'function_replaced'
18
+ | 'function_provenance_mismatch'
19
+ | 'legacy_marker_mismatch'
20
+ | 'installation_failed';
21
+
22
+ export interface DeterministicMathConflictErrorOptions {
23
+ code?: string;
24
+ expectedProfile?: string;
25
+ installedProfile?: string;
26
+ expectedVersion?: string;
27
+ installedVersion?: string;
28
+ reason?: DeterministicMathConflictReason | string;
29
+ }
30
+
31
+ export declare class DeterministicMathConflictError extends Error {
32
+ readonly code: string;
33
+ readonly expectedProfile?: string;
34
+ readonly installedProfile?: string;
35
+ readonly expectedVersion?: string;
36
+ readonly installedVersion?: string;
37
+ readonly reason?: DeterministicMathConflictReason | string;
38
+ constructor(message: string, options?: DeterministicMathConflictErrorOptions);
39
+ }
40
+
41
+ export interface DeterministicMathCheckOptions {
42
+ readonly profile?: string;
43
+ readonly version?: string;
44
+ readonly target?: typeof globalThis | Record<string, unknown>;
45
+ }
46
+
47
+ export interface DeterministicMathInstallOptions {
48
+ readonly profile?: string;
49
+ readonly version?: string;
50
+ readonly target?: typeof globalThis | Record<string, unknown>;
51
+ }
52
+
53
+ export interface DeterministicMathAttestation {
54
+ readonly version: string;
55
+ readonly profile: string;
56
+ readonly functions: Readonly<Record<string, unknown>>;
57
+ }
58
+
59
+ export declare function verifyDeterministicMathKnownAnswers(targetMath: unknown): boolean;
60
+
61
+ export declare function isDeterministicMathInstalled(
62
+ targetOrOptions?: typeof globalThis | DeterministicMathCheckOptions | string,
63
+ ): boolean;
64
+
65
+ export declare function installDeterministicMath(
66
+ targetOrOptions?: typeof globalThis | DeterministicMathInstallOptions | string,
67
+ ): void;
68
+
69
+ export declare function ensureDeterministicMathInstalled(
70
+ options?: DeterministicMathInstallOptions | string,
71
+ ): void;
72
+
73
+ export declare function createInitialStateWithDeterministicMath<T>(
74
+ factory: () => T,
75
+ options?: DeterministicMathInstallOptions | string,
76
+ ): T;