castle-web-cli 0.4.232 → 0.4.233

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 (355) hide show
  1. package/dist/agent-failures.d.ts +8 -0
  2. package/dist/agent-failures.js +19 -2
  3. package/dist/agent-prompts.d.ts +1 -1
  4. package/dist/agent-prompts.js +10 -3
  5. package/dist/agent.d.ts +64 -3
  6. package/dist/agent.js +170 -81
  7. package/dist/castle-host/host.d.ts +1 -0
  8. package/dist/castle-host/host.js +51 -3
  9. package/dist/castleJson.d.ts +4 -2
  10. package/dist/castleJson.js +2 -0
  11. package/dist/check.d.ts +3 -1
  12. package/dist/check.js +11 -1
  13. package/dist/devSessionStorage.js +47 -1
  14. package/dist/importPinMismatch.d.ts +22 -0
  15. package/dist/importPinMismatch.js +77 -0
  16. package/dist/importRegression.js +3 -15
  17. package/dist/imports.d.ts +10 -3
  18. package/dist/imports.js +88 -20
  19. package/dist/index.js +5 -4
  20. package/dist/init.js +1 -1
  21. package/dist/platformDoc.js +22 -0
  22. package/dist/routerFences.d.ts +5 -0
  23. package/dist/routerFences.js +12 -2
  24. package/dist/save-deck.d.ts +5 -0
  25. package/dist/save-deck.js +37 -4
  26. package/dist/serve.js +3 -0
  27. package/dist/shell/assets/{index-D2tWM896.js → index-BjOxR-lW.js} +4 -4
  28. package/dist/shell/assets/index-MVLfNYd9.css +1 -0
  29. package/dist/shell/index.html +2 -2
  30. package/dist/taskSteer.d.ts +13 -0
  31. package/dist/taskSteer.js +22 -2
  32. package/kits/base/castle.json +1 -1
  33. package/kits/base/package-lock.json +1 -1
  34. package/kits/base/sdk/README.md +79 -2
  35. package/kits/base/sdk/avatar.d.ts +6 -2
  36. package/kits/base/sdk/avatar.js +12 -4
  37. package/kits/base/sdk/castle.d.ts +1 -1
  38. package/kits/base/sdk/commands.d.ts +14 -0
  39. package/kits/base/sdk/hub.d.ts +6 -2
  40. package/kits/base/sdk/hub.js +13 -0
  41. package/kits/base/sdk/multiplayer.js +17 -1
  42. package/kits/base/sdk/save.js +2 -1
  43. package/kits/base/sdk/server/hub.d.ts +87 -0
  44. package/kits/base/sdk/server/hub.js +70 -0
  45. package/kits/base/sdk/server/platformHandle.d.ts +31 -1
  46. package/kits/base/sdk/server/storage.d.ts +13 -0
  47. package/kits/base/sdk/server/storage.js +46 -0
  48. package/kits/base/sdk/server/wrapper.d.ts +36 -5
  49. package/kits/base/sdk/server/wrapper.js +83 -8
  50. package/kits/hub-game/CLAUDE.md +329 -11
  51. package/kits/hub-game/blueprints/avatar-10.scene +28 -0
  52. package/kits/hub-game/blueprints/avatar-11.scene +28 -0
  53. package/kits/hub-game/blueprints/avatar-12.scene +28 -0
  54. package/kits/hub-game/blueprints/avatar-13.scene +28 -0
  55. package/kits/hub-game/blueprints/avatar-14.scene +28 -0
  56. package/kits/hub-game/blueprints/avatar-15.scene +28 -0
  57. package/kits/hub-game/blueprints/avatar-4.scene +28 -0
  58. package/kits/hub-game/blueprints/avatar-5.scene +28 -0
  59. package/kits/hub-game/blueprints/avatar-6.scene +28 -0
  60. package/kits/hub-game/blueprints/avatar-7.scene +28 -0
  61. package/kits/hub-game/blueprints/avatar-8.scene +28 -0
  62. package/kits/hub-game/blueprints/avatar-9.scene +28 -0
  63. package/kits/hub-game/code/client/actorBudget.js +47 -0
  64. package/kits/hub-game/code/client/attention.js +11 -2
  65. package/kits/hub-game/code/client/avatar.js +309 -35
  66. package/kits/hub-game/code/client/avatarCap.js +228 -0
  67. package/kits/hub-game/code/client/avatarColors.js +70 -0
  68. package/kits/hub-game/code/client/avatarFaces.js +21 -0
  69. package/kits/hub-game/code/client/avatarShare.js +251 -0
  70. package/kits/hub-game/code/client/ballot.js +467 -0
  71. package/kits/hub-game/code/client/build.js +22 -0
  72. package/kits/hub-game/code/client/chrome.js +1144 -50
  73. package/kits/hub-game/code/client/companion.js +716 -0
  74. package/kits/hub-game/code/client/companionDress.js +99 -0
  75. package/kits/hub-game/code/client/decor.js +509 -0
  76. package/kits/hub-game/code/client/earned.js +131 -0
  77. package/kits/hub-game/code/client/emoteBubble.js +75 -0
  78. package/kits/hub-game/code/client/grab.js +339 -20
  79. package/kits/hub-game/code/client/hookLayer.js +299 -13
  80. package/kits/hub-game/code/client/idle.js +163 -22
  81. package/kits/hub-game/code/client/interestCap.js +81 -0
  82. package/kits/hub-game/code/client/keys.js +36 -0
  83. package/kits/hub-game/code/client/labelsNear.js +205 -0
  84. package/kits/hub-game/code/client/menuIcons.js +34 -0
  85. package/kits/hub-game/code/client/pack.js +6 -2
  86. package/kits/hub-game/code/client/packFormat.js +3 -3
  87. package/kits/hub-game/code/client/rehello.js +167 -0
  88. package/kits/hub-game/code/client/shot.js +92 -0
  89. package/kits/hub-game/code/client/sound.js +63 -8
  90. package/kits/hub-game/code/client/soundscape.js +1151 -0
  91. package/kits/hub-game/code/client/soundscapeActions.js +99 -0
  92. package/kits/hub-game/code/client/soundscapeAmbience.js +453 -0
  93. package/kits/hub-game/code/client/soundscapeBaked.js +143 -0
  94. package/kits/hub-game/code/client/soundscapeBusker.js +217 -0
  95. package/kits/hub-game/code/client/soundscapeCourt.js +200 -0
  96. package/kits/hub-game/code/client/soundscapeCrowd.js +331 -0
  97. package/kits/hub-game/code/client/soundscapeCues.js +362 -0
  98. package/kits/hub-game/code/client/soundscapeMap.js +181 -0
  99. package/kits/hub-game/code/client/soundscapeMarket.js +176 -0
  100. package/kits/hub-game/code/client/soundscapeMusic.js +126 -0
  101. package/kits/hub-game/code/client/soundscapeMusicEngine.js +460 -0
  102. package/kits/hub-game/code/client/soundscapeSimlish.js +737 -0
  103. package/kits/hub-game/code/client/soundscapeSongs.js +127 -0
  104. package/kits/hub-game/code/client/soundscapeSongsRound3.js +63 -0
  105. package/kits/hub-game/code/client/soundscapeSynthesis.js +168 -0
  106. package/kits/hub-game/code/client/soundscapeUi.js +211 -0
  107. package/kits/hub-game/code/client/soundscapeVoice.js +1209 -0
  108. package/kits/hub-game/code/client/soundscapeWaves.js +206 -0
  109. package/kits/hub-game/code/client/spin.js +101 -0
  110. package/kits/hub-game/code/client/state.js +109 -1
  111. package/kits/hub-game/code/client/stuck.js +259 -0
  112. package/kits/hub-game/code/client/talk.js +538 -47
  113. package/kits/hub-game/code/client/tiers.js +516 -27
  114. package/kits/hub-game/code/client/toastBand.js +37 -0
  115. package/kits/hub-game/code/client/together.js +32 -0
  116. package/kits/hub-game/code/client/visibility.js +43 -0
  117. package/kits/hub-game/code/client/wear.js +461 -170
  118. package/kits/hub-game/code/client/yours.js +199 -0
  119. package/kits/hub-game/code/companionSpec.js +45 -0
  120. package/kits/hub-game/code/privateText.js +7 -0
  121. package/kits/hub-game/code/server/actions.js +133 -0
  122. package/kits/hub-game/code/server/actors.js +9 -1
  123. package/kits/hub-game/code/server/ask.js +155 -0
  124. package/kits/hub-game/code/server/ballot.js +539 -0
  125. package/kits/hub-game/code/server/cells.js +100 -0
  126. package/kits/hub-game/code/server/companion.js +82 -0
  127. package/kits/hub-game/code/server/cues.js +70 -0
  128. package/kits/hub-game/code/server/decor.js +269 -0
  129. package/kits/hub-game/code/server/earned.js +461 -0
  130. package/kits/hub-game/code/server/friendBests.js +166 -0
  131. package/kits/hub-game/code/server/friendsAmong.js +232 -0
  132. package/kits/hub-game/code/server/history.js +5 -0
  133. package/kits/hub-game/code/server/hub.js +1254 -50
  134. package/kits/hub-game/code/server/idle.js +30 -11
  135. package/kits/hub-game/code/server/index.js +2 -2
  136. package/kits/hub-game/code/server/labels.js +28 -2
  137. package/kits/hub-game/code/server/manifest.js +378 -7
  138. package/kits/hub-game/code/server/menu.js +133 -0
  139. package/kits/hub-game/code/server/npcs.js +830 -80
  140. package/kits/hub-game/code/server/party.js +2 -2
  141. package/kits/hub-game/code/server/players.js +22 -0
  142. package/kits/hub-game/code/server/shot.js +110 -0
  143. package/kits/hub-game/code/server/standing.js +124 -0
  144. package/kits/hub-game/code/server/vis.js +113 -0
  145. package/kits/hub-game/code/server/wear.js +12 -0
  146. package/kits/hub-game/code/server/yours.js +59 -0
  147. package/kits/hub-game/code/shared/cues.js +9 -0
  148. package/kits/hub-game/code/shared/decor.js +41 -0
  149. package/kits/hub-game/code/shared/shot.js +19 -0
  150. package/kits/hub-game/code/shared/spin.js +57 -0
  151. package/kits/hub-game/code/systems/hub.js +845 -95
  152. package/kits/hub-game/docs/content-pack.md +1 -1
  153. package/kits/hub-game/docs/contract.md +2244 -61
  154. package/kits/hub-game/docs/home-pieces.md +64 -0
  155. package/kits/hub-game/models/avatar-10.pxmodel +28 -0
  156. package/kits/hub-game/models/avatar-11.pxmodel +28 -0
  157. package/kits/hub-game/models/avatar-12.pxmodel +27 -0
  158. package/kits/hub-game/models/avatar-13.pxmodel +24 -0
  159. package/kits/hub-game/models/avatar-14.pxmodel +29 -0
  160. package/kits/hub-game/models/avatar-15.pxmodel +24 -0
  161. package/kits/hub-game/models/avatar-4.pxmodel +29 -0
  162. package/kits/hub-game/models/avatar-5.pxmodel +27 -0
  163. package/kits/hub-game/models/avatar-6.pxmodel +26 -0
  164. package/kits/hub-game/models/avatar-7.pxmodel +25 -0
  165. package/kits/hub-game/models/avatar-8.pxmodel +24 -0
  166. package/kits/hub-game/models/avatar-9.pxmodel +30 -0
  167. package/kits/hub-game/models/earned/badge-round.pxmodel +100 -0
  168. package/kits/hub-game/models/earned/badge-shield.pxmodel +117 -0
  169. package/kits/hub-game/models/earned/badge-star.pxmodel +87 -0
  170. package/kits/hub-game/models/earned/belt-plain.pxmodel +72 -0
  171. package/kits/hub-game/models/earned/held-ball.pxmodel +43 -0
  172. package/kits/hub-game/models/earned/held-lantern.pxmodel +85 -0
  173. package/kits/hub-game/models/earned/held-net.pxmodel +57 -0
  174. package/kits/hub-game/models/earned/held-trophy.pxmodel +109 -0
  175. package/kits/hub-game/models/earned/pin-round.pxmodel +62 -0
  176. package/kits/hub-game/models/earned/sash-plain.pxmodel +66 -0
  177. package/kits/hub-game/models/earned/square/belt-plain.pxmodel +104 -0
  178. package/kits/hub-game/models/earned/square/sash-plain.pxmodel +98 -0
  179. package/kits/hub-game/models/hats/bat-clip.pxmodel +206 -0
  180. package/kits/hub-game/models/hats/beekeeper.pxmodel +149 -0
  181. package/kits/hub-game/models/hats/cap.pxmodel +162 -0
  182. package/kits/hub-game/models/hats/captain.pxmodel +178 -0
  183. package/kits/hub-game/models/hats/crooked-top.pxmodel +172 -0
  184. package/kits/hub-game/models/hats/flower-crown.pxmodel +451 -0
  185. package/kits/hub-game/models/hats/foam-crown.pxmodel +179 -0
  186. package/kits/hub-game/models/hats/lantern.pxmodel +230 -0
  187. package/kits/hub-game/models/hats/laurel.pxmodel +533 -0
  188. package/kits/hub-game/models/hats/lighthouse.pxmodel +96 -0
  189. package/kits/hub-game/models/hats/sailor.pxmodel +141 -0
  190. package/kits/hub-game/models/hats/souwester.pxmodel +131 -0
  191. package/kits/hub-game/models/hats/straw.pxmodel +139 -0
  192. package/kits/hub-game/models/hats/sunflower.pxmodel +406 -0
  193. package/kits/hub-game/models/hats/sweatband.pxmodel +112 -0
  194. package/kits/hub-game/models/hats/witch.pxmodel +147 -0
  195. package/kits/hub-game/package-lock.json +2 -0
  196. package/kits/hub-game/package.json +2 -1
  197. package/kits/hub-game/scripts/check.mjs +78 -11
  198. package/kits/hub-game/scripts/companion-follower-wire.json +1 -0
  199. package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +121 -0
  200. package/kits/hub-game/scripts/fixtures/decor-keyless.json +293 -0
  201. package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +23 -0
  202. package/kits/hub-game/scripts/fixtures/fake-dom.mjs +107 -0
  203. package/kits/hub-game/scripts/fixtures/interest-legacy.json +385 -0
  204. package/kits/hub-game/scripts/fixtures/npc-notes-v1.77.jsonl +4 -0
  205. package/kits/hub-game/scripts/fixtures/vis-shared-wire.json +1 -0
  206. package/kits/hub-game/scripts/gen-avatars.mjs +933 -16
  207. package/kits/hub-game/scripts/gen-earned.mjs +285 -0
  208. package/kits/hub-game/scripts/gen-hats.mjs +827 -0
  209. package/kits/hub-game/scripts/grab.before-orbit.mjs +400 -0
  210. package/kits/hub-game/scripts/soundscape-wave-analysis.mjs +125 -0
  211. package/kits/hub-game/scripts/test-actions-client.mjs +488 -0
  212. package/kits/hub-game/scripts/test-actions.mjs +298 -0
  213. package/kits/hub-game/scripts/test-actor-budget.mjs +44 -0
  214. package/kits/hub-game/scripts/test-actors.mjs +19 -17
  215. package/kits/hub-game/scripts/test-ask-client.mjs +358 -0
  216. package/kits/hub-game/scripts/test-ask.mjs +269 -0
  217. package/kits/hub-game/scripts/test-attention.mjs +10 -1
  218. package/kits/hub-game/scripts/test-avatar-cap.mjs +379 -0
  219. package/kits/hub-game/scripts/test-avatar-colors.mjs +72 -0
  220. package/kits/hub-game/scripts/test-avatar-models.mjs +181 -0
  221. package/kits/hub-game/scripts/test-avatar-share.mjs +318 -0
  222. package/kits/hub-game/scripts/test-avatar-wire.mjs +753 -0
  223. package/kits/hub-game/scripts/test-avatar.mjs +540 -7
  224. package/kits/hub-game/scripts/test-ballot.mjs +1001 -0
  225. package/kits/hub-game/scripts/test-build.mjs +31 -0
  226. package/kits/hub-game/scripts/test-cells.mjs +71 -0
  227. package/kits/hub-game/scripts/test-chat.mjs +662 -0
  228. package/kits/hub-game/scripts/test-classic.mjs +2 -0
  229. package/kits/hub-game/scripts/test-companion-chat.mjs +198 -0
  230. package/kits/hub-game/scripts/test-companion-client.mjs +1167 -0
  231. package/kits/hub-game/scripts/test-companion.mjs +259 -0
  232. package/kits/hub-game/scripts/test-decor-client.mjs +303 -0
  233. package/kits/hub-game/scripts/test-decor.mjs +457 -0
  234. package/kits/hub-game/scripts/test-earned-client.mjs +459 -0
  235. package/kits/hub-game/scripts/test-earned.mjs +1194 -0
  236. package/kits/hub-game/scripts/test-emote-bubble.mjs +110 -0
  237. package/kits/hub-game/scripts/test-friend-bests.mjs +435 -0
  238. package/kits/hub-game/scripts/test-grab-orbit.mjs +918 -0
  239. package/kits/hub-game/scripts/test-grab.mjs +7 -0
  240. package/kits/hub-game/scripts/test-hats.mjs +422 -168
  241. package/kits/hub-game/scripts/test-hub-leaving.mjs +203 -0
  242. package/kits/hub-game/scripts/test-hub-ops.mjs +439 -2
  243. package/kits/hub-game/scripts/test-hub-trip.mjs +716 -2
  244. package/kits/hub-game/scripts/test-hud-clear.mjs +328 -4
  245. package/kits/hub-game/scripts/test-idle.mjs +361 -1
  246. package/kits/hub-game/scripts/test-interest-cap.mjs +36 -0
  247. package/kits/hub-game/scripts/test-interest-cells.mjs +493 -0
  248. package/kits/hub-game/scripts/test-interest-client.mjs +118 -0
  249. package/kits/hub-game/scripts/test-keys.mjs +46 -1
  250. package/kits/hub-game/scripts/test-labels.mjs +596 -0
  251. package/kits/hub-game/scripts/test-manifest.mjs +207 -0
  252. package/kits/hub-game/scripts/test-menu-client.mjs +480 -0
  253. package/kits/hub-game/scripts/test-menu.mjs +296 -0
  254. package/kits/hub-game/scripts/test-npcs.mjs +1718 -12
  255. package/kits/hub-game/scripts/test-object-entry.mjs +76 -0
  256. package/kits/hub-game/scripts/test-pack.mjs +7 -0
  257. package/kits/hub-game/scripts/test-picker.mjs +314 -0
  258. package/kits/hub-game/scripts/test-rehello.mjs +1039 -0
  259. package/kits/hub-game/scripts/test-relations-among.mjs +222 -0
  260. package/kits/hub-game/scripts/test-relations-refresh.mjs +188 -0
  261. package/kits/hub-game/scripts/test-shot.mjs +756 -0
  262. package/kits/hub-game/scripts/test-soundscape.mjs +5432 -0
  263. package/kits/hub-game/scripts/test-spin.mjs +314 -0
  264. package/kits/hub-game/scripts/test-standing.mjs +416 -0
  265. package/kits/hub-game/scripts/test-stuck.mjs +1903 -0
  266. package/kits/hub-game/scripts/test-tier-cells.mjs +706 -0
  267. package/kits/hub-game/scripts/test-tiers-render.mjs +339 -0
  268. package/kits/hub-game/scripts/test-tiers.mjs +477 -2
  269. package/kits/hub-game/scripts/test-toast-band.mjs +61 -0
  270. package/kits/hub-game/scripts/test-try-on.mjs +22 -22
  271. package/kits/hub-game/scripts/test-vis.mjs +343 -0
  272. package/kits/hub-game/scripts/test-visibility.mjs +134 -0
  273. package/kits/hub-game/scripts/test-yours-chrome.mjs +166 -0
  274. package/kits/hub-game/scripts/test-yours.mjs +372 -0
  275. package/kits/multiplayer-3d/CLAUDE.md +50 -0
  276. package/kits/multiplayer-3d/castle.json +5 -5
  277. package/kits/multiplayer-3d/code/client/avatars.js +7 -0
  278. package/kits/multiplayer-3d/code/client/gait.js +65 -0
  279. package/kits/multiplayer-3d/code/client/nameTags.js +59 -4
  280. package/kits/multiplayer-3d/code/options.js +5 -0
  281. package/kits/multiplayer-3d/code/server/ownership.js +10 -2
  282. package/kits/multiplayer-3d/code/server/sceneBodies.js +12 -0
  283. package/kits/multiplayer-3d/code/server/world.js +7 -0
  284. package/kits/multiplayer-3d/code/systems/multiplayer.js +74 -4
  285. package/kits/multiplayer-3d/package.json +2 -1
  286. package/kits/multiplayer-3d/scripts/fixtures/README.md +11 -0
  287. package/kits/multiplayer-3d/scripts/fixtures/ownership-legacy.json +2 -0
  288. package/kits/multiplayer-3d/scripts/ownership-harness.mjs +102 -0
  289. package/kits/multiplayer-3d/scripts/ownership-loader.mjs +46 -0
  290. package/kits/multiplayer-3d/scripts/ownership-worker.mjs +15 -0
  291. package/kits/multiplayer-3d/scripts/record-ownership-session.mjs +98 -0
  292. package/kits/multiplayer-3d/scripts/test-eligible-claims.mjs +167 -0
  293. package/kits/multiplayer-3d/scripts/test-own-name-tag.mjs +247 -0
  294. package/kits/physics-2d/CLAUDE.md +9 -0
  295. package/kits/physics-2d/castle.json +2 -2
  296. package/kits/physics-2d/engine/scene.js +253 -1
  297. package/kits/physics-2d/engine/skyKey.js +129 -0
  298. package/kits/physics-2d/engine/stillClock.js +106 -0
  299. package/kits/physics-2d/engine/updateBudget.js +21 -0
  300. package/kits/physics-2d/scripts/test-skip-unchanged.mjs +326 -1
  301. package/kits/physics-3d/CLAUDE.md +1169 -30
  302. package/kits/physics-3d/behaviors/Player.jsx +629 -72
  303. package/kits/physics-3d/castle.json +3 -3
  304. package/kits/physics-3d/docs/pxmodel-format.md +8 -0
  305. package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +69 -13
  306. package/kits/physics-3d/engine3d/actornode.js +86 -0
  307. package/kits/physics-3d/engine3d/animationBudget.js +23 -0
  308. package/kits/physics-3d/engine3d/editorWorld.js +6 -0
  309. package/kits/physics-3d/engine3d/emptynodes.js +232 -0
  310. package/kits/physics-3d/engine3d/framecap.js +96 -0
  311. package/kits/physics-3d/engine3d/gait.js +118 -0
  312. package/kits/physics-3d/engine3d/kithooks.js +47 -0
  313. package/kits/physics-3d/engine3d/look.js +507 -48
  314. package/kits/physics-3d/engine3d/lookbake.js +208 -0
  315. package/kits/physics-3d/engine3d/materialpresets.js +2 -0
  316. package/kits/physics-3d/engine3d/motion.js +39 -10
  317. package/kits/physics-3d/engine3d/nearshadows.js +37 -19
  318. package/kits/physics-3d/engine3d/optimize.js +9 -5
  319. package/kits/physics-3d/engine3d/orbitinput.js +487 -9
  320. package/kits/physics-3d/engine3d/orbitlens.js +48 -0
  321. package/kits/physics-3d/engine3d/ownmodel.js +213 -0
  322. package/kits/physics-3d/engine3d/pxmodel.js +42 -11
  323. package/kits/physics-3d/engine3d/shadowfade.js +882 -0
  324. package/kits/physics-3d/engine3d/sky.js +547 -0
  325. package/kits/physics-3d/engine3d/skylife.js +306 -0
  326. package/kits/physics-3d/engine3d/unchanged.js +11 -0
  327. package/kits/physics-3d/engine3d/viewrange.js +52 -0
  328. package/kits/physics-3d/engine3d/world3d.js +796 -69
  329. package/kits/physics-3d/main.jsx +5 -0
  330. package/kits/physics-3d/package.json +1 -1
  331. package/kits/physics-3d/scripts/look-baseline.mjs +155 -0
  332. package/kits/physics-3d/scripts/test-camera-orbit.mjs +2563 -80
  333. package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +1 -1
  334. package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +435 -0
  335. package/kits/physics-3d/scripts/test-frame-cap.mjs +452 -0
  336. package/kits/physics-3d/scripts/test-gait.mjs +387 -0
  337. package/kits/physics-3d/scripts/test-look-bake.mjs +1056 -0
  338. package/kits/physics-3d/scripts/test-model-parse-cache.mjs +92 -0
  339. package/kits/physics-3d/scripts/test-near-shadows.mjs +3 -0
  340. package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1920 -0
  341. package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +545 -0
  342. package/kits/physics-3d/scripts/test-orbit-shot.mjs +583 -0
  343. package/kits/physics-3d/scripts/test-orbit-view.mjs +230 -0
  344. package/kits/physics-3d/scripts/test-skip-empty-nodes.mjs +845 -0
  345. package/kits/physics-3d/scripts/test-sky.mjs +2470 -0
  346. package/kits/physics-3d/scripts/test-static-actors.mjs +8 -1
  347. package/kits/physics-3d/scripts/test-static-scenery.mjs +2171 -0
  348. package/kits/physics-3d/scripts/test-steady-hover.mjs +2 -0
  349. package/kits/physics-3d/scripts/test-view-range.mjs +260 -0
  350. package/kits/physics-3d/systems/physics3d.js +383 -6
  351. package/kits/real-time/castle.json +2 -2
  352. package/kits/real-time/code/server/gameHooks.js +7 -0
  353. package/kits/real-time/code/server/session.js +97 -19
  354. package/package.json +2 -2
  355. package/dist/shell/assets/index-Cf61cNfT.css +0 -1
@@ -0,0 +1,65 @@
1
+ // Cadence follows timestamped network motion, before render-pose smoothing.
2
+ // Player poses have no wire velocity. Object samples may supply `velocity`.
3
+ const HOLD_MS = 250;
4
+ const PAUSE_MS = 250;
5
+ const STOP_SPEED = 0.05;
6
+
7
+ // Called once per active system frame. A resumed frame starts a new clock,
8
+ // matching the wall-clock pause reset in easeWalkSpeed.
9
+ export function walkFrameTime(frame, wall = performance.now()) {
10
+ const elapsed = wall - frame.wall;
11
+ frame.wall = wall;
12
+ return Number.isFinite(elapsed) && elapsed >= 0 && elapsed <= PAUSE_MS
13
+ ? Math.max(0, Math.min(elapsed / 1000, 0.25)) : 0;
14
+ }
15
+
16
+ function segmentSpeed(before, after) {
17
+ if (!before || !after) {return 0;}
18
+ const span = (after.simMs - before.simMs) / 1000;
19
+ const distance = Math.hypot(...[0, 1, 2].map((i) => after.pose[i] - before.pose[i]));
20
+ if (!(span > 0) || !Number.isFinite(span) || !Number.isFinite(distance) || distance > 4) {return 0;}
21
+ const velocity = after.velocity;
22
+ const speed = velocity ? Math.hypot(velocity[0], velocity[2])
23
+ : Math.hypot(after.pose[0] - before.pose[0], after.pose[2] - before.pose[2]) / span;
24
+ return Number.isFinite(speed) ? speed : 0;
25
+ }
26
+
27
+ export function trackWalkSpeed(track, at) {
28
+ const samples = track.samples;
29
+ if (!Number.isFinite(at) || samples.length < 2 || at <= samples[0].simMs) {return 0;}
30
+ const newest = samples.at(-1);
31
+ if (at > newest.simMs) {
32
+ const over = at - newest.simMs;
33
+ return segmentSpeed(samples.at(-2), newest) * Math.max(0, 1 - over / HOLD_MS);
34
+ }
35
+ // Same newest-first bracketing search as real-time's sampleAt.
36
+ for (let i = samples.length - 1; i > 0; i -= 1) {
37
+ const before = samples[i - 1];
38
+ const after = samples[i];
39
+ if (before.simMs <= at && at <= after.simMs) {
40
+ const span = after.simMs - before.simMs;
41
+ if (!(span > 0)) {return 0;}
42
+ // sampleAt draws linearly within this segment. Smoothing belongs in
43
+ // easeWalkSpeed: previous motion must not animate a stationary segment.
44
+ return segmentSpeed(before, after);
45
+ }
46
+ }
47
+ return 0;
48
+ }
49
+
50
+ export function easeWalkSpeed(speeds, id, track, at, dt, wall = performance.now()) {
51
+ const target = trackWalkSpeed(track, at);
52
+ const previous = speeds.get(id);
53
+ // Frame dt may be capped after a suspension. Use actual wall/render time
54
+ // and track identity so old motion cannot leak into a fresh or held pose.
55
+ const reset = !previous || previous.track !== track
56
+ || !Number.isFinite(at) || !Number.isFinite(wall)
57
+ || !Number.isFinite(previous.at) || !Number.isFinite(previous.wall)
58
+ || at < previous.at || at - previous.at > 500
59
+ || wall < previous.wall || wall - previous.wall > PAUSE_MS;
60
+ const ease = Number.isFinite(dt) && dt > 0 ? 1 - Math.exp(-dt / 0.1) : 0;
61
+ const eased = reset ? target : previous.speed + (target - previous.speed) * ease;
62
+ const speed = target === 0 && eased < STOP_SPEED ? 0 : eased;
63
+ speeds.set(id, { speed, track, at, wall });
64
+ return speed;
65
+ }
@@ -63,11 +63,44 @@ export function moveNameTag(tag, transform, camera, heightAbove = HEIGHT_ABOVE)
63
63
  tag.sprite.scale.set(tag.width * scale, tag.height * scale, 1);
64
64
  }
65
65
 
66
+ // The own tag's registration with physics-3d's `world.ownModelWith` (orbit
67
+ // camera key only): tag -> { set, sprite }. Kept here, off the tag, so a tag
68
+ // never registered is disposed without reading anything of it.
69
+ const ownRegistered = new WeakMap();
70
+
71
+ // Puts the tag's current sprite in `set` (the world's now), taking out
72
+ // what was registered before if either has changed. Called only under the
73
+ // orbit camera key.
74
+ export function registerOwnNameTag(tag, set) {
75
+ const had = ownRegistered.get(tag);
76
+ if (had && had.sprite === tag.sprite && had.set === set) {
77
+ return;
78
+ }
79
+ if (had) {
80
+ had.set.delete(had.sprite);
81
+ ownRegistered.delete(tag);
82
+ }
83
+ if (set instanceof Set) {
84
+ set.add(tag.sprite);
85
+ ownRegistered.set(tag, { set, sprite: tag.sprite });
86
+ }
87
+ }
88
+
66
89
  // Remove a tag from the three.js scene and release its texture and material.
67
90
  export function disposeNameTag(world, tag) {
68
- world.scene.remove(tag.sprite);
69
- tag.sprite.material.map.dispose();
70
- tag.sprite.material.dispose();
91
+ try {
92
+ world.scene.remove(tag.sprite);
93
+ tag.sprite.material.map.dispose();
94
+ tag.sprite.material.dispose();
95
+ } finally {
96
+ // After the listeners those ran, so one that registered it again is
97
+ // undone too.
98
+ const own = ownRegistered.get(tag);
99
+ if (own) {
100
+ ownRegistered.delete(tag);
101
+ own.set.delete(own.sprite);
102
+ }
103
+ }
71
104
  }
72
105
 
73
106
  // A logged-out player's name is `anonymous-user-<uuid>`. Drawn in full it is
@@ -78,6 +111,28 @@ export function shortName(username) {
78
111
  return anon ? `anon-${anon[1].replace(/-/g, '').slice(-6)}` : (username ?? 'player');
79
112
  }
80
113
 
114
+ // The tag's rounded plate as a path. CanvasRenderingContext2D.roundRect arrived
115
+ // in Safari 16; iOS 15 has none, and calling it there threw after join. The
116
+ // fallback traces the same outline, clockwise from the top left, with one
117
+ // quarter arc a corner.
118
+ export function platePath(ctx, width, height, radius) {
119
+ if (typeof ctx.roundRect === 'function') {
120
+ ctx.roundRect(0, 0, width, height, radius);
121
+ return;
122
+ }
123
+ const r = Math.min(radius, width / 2, height / 2);
124
+ ctx.moveTo(r, 0);
125
+ ctx.lineTo(width - r, 0);
126
+ ctx.arc(width - r, r, r, -Math.PI / 2, 0);
127
+ ctx.lineTo(width, height - r);
128
+ ctx.arc(width - r, height - r, r, 0, Math.PI / 2);
129
+ ctx.lineTo(r, height);
130
+ ctx.arc(r, height - r, r, Math.PI / 2, Math.PI);
131
+ ctx.lineTo(0, r);
132
+ ctx.arc(r, r, r, Math.PI, Math.PI * 1.5);
133
+ ctx.closePath();
134
+ }
135
+
81
136
  // Rasterize one display name into the canvas used as the sprite texture.
82
137
  function drawLabel(text) {
83
138
  const canvas = document.createElement('canvas');
@@ -92,7 +147,7 @@ function drawLabel(text) {
92
147
  canvas.height = 68;
93
148
  ctx.font = font;
94
149
  ctx.fillStyle = 'rgba(12,12,16,0.72)';
95
- ctx.roundRect(0, 0, width, 68, 16);
150
+ platePath(ctx, width, 68, 16);
96
151
  ctx.fill();
97
152
  ctx.fillStyle = '#f2f2f5';
98
153
  ctx.textBaseline = 'middle';
@@ -0,0 +1,5 @@
1
+ // Scene options travel with the active scene, including hub content packs.
2
+ // Strict opt-in: absent, false, and non-boolean values retain legacy behaviour.
3
+ export function eligibleClaims(data) {
4
+ return data?.multiplayer?.eligibleClaims === true;
5
+ }
@@ -27,8 +27,15 @@ export function claim(sim, playerId, ids, handovers) {
27
27
  return;
28
28
  }
29
29
 
30
- // Limit one message to eight claim checks to bound per-message server work.
31
- for (const id of ids.slice(0, 8)) {
30
+ // Legacy decks spend eight checks on the first eight ids, unchanged. Opt-in
31
+ // decks skip ineligible ids before spending those checks. Scanning at most
32
+ // 256 ids bounds lookups/reach tests even for an arbitrarily long bad packet;
33
+ // only eight eligible candidates can reach the takeover/handover work.
34
+ let checks = 0;
35
+ for (const id of ids.slice(0, sim.eligibleClaims === true ? 256 : 8)) {
36
+ if (sim.eligibleClaims === true && checks >= 8) {
37
+ break;
38
+ }
32
39
  const entry = sim.objects.get(id);
33
40
  if (!entry?.claimable || entry.owner === playerId) {
34
41
  continue;
@@ -37,6 +44,7 @@ export function claim(sim, playerId, ids, handovers) {
37
44
  if (!Limits.withinReach(player.at, at)) {
38
45
  continue;
39
46
  }
47
+ checks += 1;
40
48
  if (entry.owner && !mayTakeOver(sim, entry, player, at)) {
41
49
  continue;
42
50
  }
@@ -80,6 +80,18 @@ export function sceneGround(scenePath = MAIN_SCENE) {
80
80
  return text ? (JSON.parse(text).ground ?? null) : null;
81
81
  }
82
82
 
83
+ // Scene-level multiplayer options, read from the scene this session simulates.
84
+ export function sceneOptions(scenePath = MAIN_SCENE) {
85
+ const text = sceneTexts[`/${resolveScenePath(scenePath)}`];
86
+ return text ? JSON.parse(text) : null;
87
+ }
88
+
89
+ // The scene's optional ground-cell table; the hub validates its contract.
90
+ export function sceneCells(scenePath = MAIN_SCENE) {
91
+ const text = sceneTexts[`/${resolveScenePath(scenePath)}`];
92
+ return text ? (JSON.parse(text).cells ?? null) : null;
93
+ }
94
+
83
95
  // Shallow-merge each component in engine precedence order: defaults, blueprint,
84
96
  // then scene instance values.
85
97
  function resolveComponents(actor) {
@@ -11,7 +11,11 @@ import {
11
11
  number,
12
12
  } from '@imports/castle.real-time/code/server/limits.js';
13
13
  import { readScene, resolveScenePath, sceneGround } from './sceneBodies.js';
14
+ // A namespace read, so a test's stand-in for the scene loader that predates
15
+ // `sceneOptions` still loads: it has no options and the key stays off.
16
+ import * as SceneBodies from './sceneBodies.js';
14
17
  import * as Limits from './limits.js';
18
+ import { eligibleClaims } from '../options.js';
15
19
 
16
20
  const DEG = Math.PI / 180;
17
21
 
@@ -57,6 +61,9 @@ export async function createSimulation(scenePath) {
57
61
  await RAPIER.init();
58
62
  const sim = emptySim();
59
63
  sim.scenePath = resolveScenePath(scenePath);
64
+ if (eligibleClaims(SceneBodies.sceneOptions?.(sim.scenePath))) {
65
+ sim.eligibleClaims = true;
66
+ }
60
67
  buildGround(sim);
61
68
  buildScene(sim);
62
69
  return sim;
@@ -8,12 +8,14 @@
8
8
  // object is drawn from interpolated network poses a render delay behind.
9
9
 
10
10
  import * as Avatars from '../client/avatars.js';
11
+ import { easeWalkSpeed, walkFrameTime } from '../client/gait.js';
11
12
  import * as Clock from '@imports/castle.real-time/code/client/clock.js';
12
13
  import * as Interpolate from '@imports/castle.real-time/code/client/interpolate.js';
13
14
  import * as Ownership from '@imports/castle.real-time/code/client/ownership.js';
14
15
  import * as Smoothing from '@imports/castle.real-time/code/client/smooth.js';
15
16
  import * as Poses from '../client/poses.js';
16
17
  import * as Steer from '../client/steer.js';
18
+ import { eligibleClaims } from '../options.js';
17
19
  import { connectSession } from '@imports/castle.real-time/code/client/connection.js';
18
20
  import { showSoloBadge, updateSoloBadge } from '@imports/castle.real-time/code/client/soloBadge.js';
19
21
  import { showJoinOverlay } from '@imports/castle.real-time/code/client/joinOverlay.js';
@@ -53,6 +55,13 @@ const deckSystem = {
53
55
  ...import.meta.glob('/code/systems/multiplayer.js'),
54
56
  };
55
57
 
58
+ // Read only in this browser system; the track helpers are also imported by
59
+ // Node probes. No gait-module dependency on the deck's physics-3d version.
60
+ const castleJson = Object.values(import.meta.glob('/castle.json', { eager: true, import: 'default' }))[0] ?? {};
61
+ export function gaitModel() {
62
+ return castleJson.gait === 'model';
63
+ }
64
+
56
65
  // The engine system owns connection-wide state and runtime actor lifecycles. The
57
66
  // system registry calls `installSystem` once for each created engine runtime.
58
67
  // Install one multiplayer system into an engine runtime. Return null when a
@@ -213,6 +222,9 @@ class MultiplayerSystem {
213
222
  if (this.holding) {
214
223
  return;
215
224
  }
225
+ if (gaitModel()) {
226
+ this.walkTimeHint = walkFrameTime((this.walkFrame ??= {}));
227
+ }
216
228
  const local = scene.actorWith('Player');
217
229
  if (this.settleFrames > 0) {
218
230
  this.settleFrames -= 1;
@@ -454,6 +466,25 @@ class MultiplayerSystem {
454
466
  this.clampedTo = { x, y, z };
455
467
  }
456
468
  }
469
+ // A re-entering object starts at its current pose, without sliding from
470
+ // the last pose this client saw before it left the interest set.
471
+ // An entry row under an older epoch than the last handover seen is a
472
+ // new object reusing the id: nothing this client kept about the old one
473
+ // (its handover, or holding it) applies.
474
+ const entryRows = msg.oin?.length ? new Map((msg.os ?? []).map(([id, ...row]) => [id, row])) : null;
475
+ for (const id of msg.oin ?? []) {
476
+ if (entryRows.get(id)?.[7] < this.handed.get(id)?.epoch) {
477
+ this.forgetObject(id);
478
+ this.own.mine.delete(id);
479
+ this.own.asked.delete(id);
480
+ this.own.released.delete(id);
481
+ }
482
+ this.objects.delete(id);
483
+ if (gaitModel()) {this.objectWalkSpeeds?.delete(id);}
484
+ Smoothing.forget(this.shown, id);
485
+ this.written.delete(id);
486
+ this.live.delete(id);
487
+ }
457
488
  for (const [id, ...row] of msg.os ?? []) {
458
489
  this.sampleObject(msg, id, row);
459
490
  }
@@ -558,6 +589,11 @@ class MultiplayerSystem {
558
589
 
559
590
  // The Transform follows the body at the next physics step. It is moved
560
591
  // now so this frame's reach checks and report read the seed as well.
592
+ // The engine is told first (`touch`): a scene may hold an actor still
593
+ // (physics-3d `"engine": { "staticActors": true }`). Only actors with
594
+ // a dynamic or kinematic Body are objects here (server world.js), and
595
+ // those are never still; the touch costs nothing then.
596
+ scene.touch?.(id);
561
597
  Poses.applyPose(transform, seed);
562
598
  }
563
599
  const [vx, vy, vz, wx, wy, wz] = velocity;
@@ -594,6 +630,7 @@ class MultiplayerSystem {
594
630
  // An owned object is simulated here, and is live once it is let go.
595
631
  // Writing the older network pose over it would undo a local push.
596
632
  if (this.own.mine.has(id)) {
633
+ if (gaitModel()) {this.objectWalkSpeeds?.delete(id);}
597
634
  if (dynamic) {
598
635
  this.live.set(id, Steer.makeState());
599
636
  }
@@ -610,9 +647,13 @@ class MultiplayerSystem {
610
647
  )
611
648
  : null;
612
649
  if (network && this.isLive(id, network, body, transform, me)) {
650
+ if (gaitModel()) {this.objectWalkSpeeds?.delete(id);}
613
651
  Steer.steer(body, network, this.live.get(id), dt, now, world, player);
614
652
  } else if (!this.live.has(id)) {
615
- this.drawInterpolated(id, track, actor, body, at, dt);
653
+ scene.touch?.(id);
654
+ this.drawInterpolated(id, track, actor, body, at, dt, scene, now);
655
+ } else if (gaitModel()) {
656
+ this.objectWalkSpeeds?.delete(id);
616
657
  }
617
658
  }
618
659
  }
@@ -649,7 +690,7 @@ class MultiplayerSystem {
649
690
  // Draw an object from its track at the render time `at`, on both its Transform
650
691
  // and its rapier body. A pose already written, with the body still there, is
651
692
  // not written again, so a body at rest can sleep.
652
- drawInterpolated(id, track, actor, body, at, dt) {
693
+ drawInterpolated(id, track, actor, body, at, dt, scene, wall) {
653
694
  const sampled = Interpolate.sampleAt(track, at, Poses.blend);
654
695
  if (!sampled) {
655
696
  return;
@@ -657,6 +698,15 @@ class MultiplayerSystem {
657
698
 
658
699
  // Smooth the sampled target to absorb small steps from uneven delivery.
659
700
  const pose = Smoothing.smooth(this.shown, id, sampled, dt, Poses);
701
+ if (gaitModel()) {
702
+ const speed = easeWalkSpeed((this.objectWalkSpeeds ??= new Map()), id, track, at, dt, wall);
703
+ const node = scene.three?.nodes?.get(actor.id)?.node;
704
+ if (node) {
705
+ node.userData.walkSpeedHint = speed;
706
+ node.userData.walkTimeHint = this.walkTimeHint;
707
+ node.userData.walkHintAt = wall;
708
+ }
709
+ }
660
710
  const written = this.written.get(id);
661
711
  if (written && Poses.same(written, pose) && bodyAt(body, pose)) {
662
712
  return;
@@ -673,6 +723,7 @@ class MultiplayerSystem {
673
723
  // Apply each other player's pose, spawning its avatar and name tag when needed.
674
724
  applyPlayerPoses(scene, at, dt) {
675
725
  const others = this.net.others();
726
+ const wall = gaitModel() ? performance.now() : undefined;
676
727
  for (const [playerId, username] of others) {
677
728
  const track = this.players.get(playerId);
678
729
  const sampled = track && Interpolate.sampleAt(track, at, Poses.blend);
@@ -687,10 +738,19 @@ class MultiplayerSystem {
687
738
  if (!look) {
688
739
  continue;
689
740
  }
690
- Avatars.showPlayer(this.avatars, scene, playerId, look.username ?? null, pose, {
741
+ const actor = Avatars.showPlayer(this.avatars, scene, playerId, look.username ?? null, pose, {
691
742
  blueprint: look.blueprint,
692
743
  userId: this.net.userId(playerId),
693
744
  });
745
+ if (gaitModel()) {
746
+ const speed = easeWalkSpeed((this.playerWalkSpeeds ??= new Map()), playerId, track, at, dt, wall);
747
+ const node = scene.three?.nodes?.get(actor.id)?.node;
748
+ if (node) {
749
+ node.userData.walkSpeedHint = speed;
750
+ node.userData.walkTimeHint = this.walkTimeHint;
751
+ node.userData.walkHintAt = wall;
752
+ }
753
+ }
694
754
  }
695
755
  Avatars.dropMissing(this.avatars, scene, others);
696
756
  Avatars.animate(this.avatars, scene, dt);
@@ -720,6 +780,7 @@ class MultiplayerSystem {
720
780
  // Remove history and smoothing state after a player leaves the SDK roster.
721
781
  dropPlayer(playerId) {
722
782
  this.players.delete(playerId);
783
+ if (gaitModel()) {this.playerWalkSpeeds?.delete(playerId);}
723
784
  Smoothing.forget(this.shown, playerId);
724
785
  }
725
786
 
@@ -782,7 +843,9 @@ class MultiplayerSystem {
782
843
  const objects = game.claimable?.(scene, this) ?? this.claimable(scene);
783
844
  const claims = Ownership.toClaim(
784
845
  this.own,
785
- objects,
846
+ eligibleClaims(scene.data)
847
+ ? objects.filter(([id]) => scene.getActor(id)?.components.Body?.type === 'dynamic')
848
+ : objects,
786
849
  me,
787
850
  this.otherPlaces(now),
788
851
  now,
@@ -929,6 +992,12 @@ class MultiplayerSystem {
929
992
  game.reset?.(scene, this);
930
993
  Avatars.clearAvatars(this.avatars, scene);
931
994
  this.players.clear();
995
+ if (gaitModel()) {
996
+ this.playerWalkSpeeds?.clear();
997
+ this.objectWalkSpeeds?.clear();
998
+ delete this.walkFrame;
999
+ delete this.walkTimeHint;
1000
+ }
932
1001
  this.objects.clear();
933
1002
  this.own = Ownership.makeOwnership();
934
1003
  this.granted.clear();
@@ -954,6 +1023,7 @@ class MultiplayerSystem {
954
1023
  // starts afresh.
955
1024
  forgetObject(id) {
956
1025
  this.objects.delete(id);
1026
+ if (gaitModel()) {this.objectWalkSpeeds?.delete(id);}
957
1027
  this.live.delete(id);
958
1028
  this.written.delete(id);
959
1029
  this.handed.delete(id);
@@ -3,7 +3,8 @@
3
3
  "private": true,
4
4
  "type": "module",
5
5
  "scripts": {
6
- "check": "eslint . && node --input-type=module -e \"const { bundleProject } = await import('../../cli/dist/bundle.js'); await bundleProject('.');\"",
6
+ "test": "node scripts/test-own-name-tag.mjs && node scripts/test-eligible-claims.mjs",
7
+ "check": "eslint . && npm test && node --input-type=module -e \"const { bundleProject } = await import('../../cli/dist/bundle.js'); await bundleProject('.');\"",
7
8
  "format": "prettier --write \"code/**/*.js\" castle.json package.json"
8
9
  },
9
10
  "dependencies": {
@@ -0,0 +1,11 @@
1
+ `ownership-legacy.json` was recorded from the unmodified multiplayer system,
2
+ server ownership, poses and world modules at HEAD 4290fc44005a5b53cdde1f0506504e40d9fa84e1, before the eligibleClaims
3
+ change. The four changed runtime modules were read with `git show HEAD:<path>`
4
+ into `/tmp/house-ownership-baseline/code/`, and the recorder was run with
5
+ `OWNERSHIP_BASELINE_DIR=file:///tmp/house-ownership-baseline/`. `record-ownership-session.mjs` drives those real modules and the real
6
+ rate-limited real-time transport with deterministic body APIs and clock; only
7
+ browser UI, SDK connection and bundler globs are replaced. The transcript covers
8
+ WORLD/STATE rows, initial grant, owner reports, rate-limited asks, releases,
9
+ handover-induced map reorder and starvation, persistent state, and contested
10
+ claims (hold, tie, nearer claimant and timeout). Tests compare literal stdout
11
+ bytes to this fixture; they never regenerate it.
@@ -0,0 +1,2 @@
1
+ [multiplayer] placed by the session
2
+ [["server",{"k":"w","t":0,"localMs":0,"ps":[],"os":[["dish",1,0,0,0,0,0,1,0],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[["dish",0,0,0,0,0,0,0,0,0],["door-0",0,0,0,0,0,0,0,0,0],["door-1",0,0,0,0,0,0,0,0,0],["door-2",0,0,0,0,0,0,0,0,0],["door-3",0,0,0,0,0,0,0,0,0],["door-4",0,0,0,0,0,0,0,0,0],["door-5",0,0,0,0,0,0,0,0,0],["door-6",0,0,0,0,0,0,0,0,0],["door-7",0,0,0,0,0,0,0,0,0],["door-8",0,0,0,0,0,0,0,0,0],["door-9",0,0,0,0,0,0,0,0,0],["door-10",0,0,0,0,0,0,0,0,0],["door-11",0,0,0,0,0,0,0,0,0],["ball",0,0,0,0,0,0,0,0,0]]}],["client",{"k":"i","p":[0,0,0,0],"c":["dish","door-0","door-1","door-2","door-3","door-4","door-5","door-6","door-7","door-8","door-9","door-10","door-11","ball"],"r":[],"o":[],"s":{}}],["server",{"k":"s","t":120,"localMs":120,"ps":[],"os":[["dish",1,0,0,0,0,0,1,1],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[["dish","cook",0,0,0,0,0,0,1]]}],["held",150],["client",{"k":"i","p":[0,0,0,0],"c":["door-0","door-1","door-2","door-3","door-4","door-5","door-6","door-7","door-8","door-9","door-10","door-11","ball"],"r":[],"o":[["dish",1,0,0,0,0,0,1,0,0,0,0,0,0,1,2,0]]}],["server",{"k":"s","t":240,"localMs":240,"ps":[],"os":[["dish",1,0,0,0,0,0,1,1],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[]}],["client",{"k":"i","p":[20,0,0,0],"c":[],"r":["dish"],"o":[["dish",1,0,0,0,0,0,1,0,0,0,0,0,0,1,3,0]]}],["server",{"k":"s","t":360,"localMs":360,"ps":[],"os":[["dish",1,0,0,0,0,0,1,2],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[["dish",0,0,0,0,0,0,0,2]]}],["server",{"k":"s","t":480,"localMs":480,"ps":[],"os":[["dish",1,0,0,0,0,0,1,3],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[["dish",0,0,0,0,0,0,0,3]]}],["client",{"k":"i","p":[20,0,0,0],"c":[],"r":[],"o":[]}],["server",{"k":"s","t":480,"localMs":480,"ps":[],"os":[["dish",1,0,0,0,0,0,1,3],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[]}],["client",{"k":"i","p":[20,0,0,0],"c":[],"r":[],"o":[]}],["server",{"k":"s","t":720,"localMs":720,"ps":[],"os":[["dish",1,0,0,0,0,0,1,3],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[]}],["client",{"k":"i","p":[20,0,0,0],"c":[],"r":[],"o":[]}],["server",{"k":"s","t":840,"localMs":840,"ps":[],"os":[["dish",1,0,0,0,0,0,1,3],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[]}],["client",{"k":"i","p":[0,0,0,0],"c":["door-0","door-1","door-2","door-3","door-4","door-5","door-6","door-7","door-8","door-9","door-10","door-11","ball","dish"],"r":[],"o":[]}],["server",{"k":"s","t":960,"localMs":960,"ps":[],"os":[["dish",1,0,0,0,0,0,1,3],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[]}],["client",{"k":"i","p":[0,0,0,0],"c":["door-0","door-1","door-2","door-3","door-4","door-5","door-6","door-7","door-8","door-9","door-10","door-11","ball","dish"],"r":[],"o":[],"s":{"score":1}}],["server",{"k":"s","t":1080,"localMs":1080,"ps":[],"os":[["dish",1,0,0,0,0,0,1,3],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[]}],["client",{"k":"i","p":[0,0,0,0],"c":["door-0","door-1","door-2","door-3","door-4","door-5","door-6","door-7","door-8","door-9","door-10","door-11","ball","dish"],"r":[],"o":[]}],["server",{"k":"s","t":1320,"localMs":1320,"ps":[],"os":[["dish",1,0,0,0,0,0,1,3],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[]}],["client",{"k":"i","p":[0,0,0,0],"c":["door-0","door-1","door-2","door-3","door-4","door-5","door-6","door-7","door-8","door-9","door-10","door-11","ball","dish"],"r":[],"o":[]}],["server",{"k":"s","t":1560,"localMs":1560,"ps":[],"os":[["dish",1,0,0,0,0,0,1,3],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[]}],["client",{"k":"i","p":[0,0,0,0],"c":["door-0","door-1","door-2","door-3","door-4","door-5","door-6","door-7","door-8","door-9","door-10","door-11","ball","dish"],"r":[],"o":[]}],["server",{"k":"s","t":1800,"localMs":1800,"ps":[],"os":[["dish",1,0,0,0,0,0,1,3],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[]}],["contest",[]],["contest",[]],["contest",[["ball","cook",0,0,0,0,0,0,1]]],["contest",[["ball","cook",0,0,0,0,0,0,2]]]]
@@ -0,0 +1,102 @@
1
+ // Run the real kit modules in Node: replace bundler globs and browser-only UI,
2
+ // keeping ownership, poses, tracks, and the rate-limited wire transport intact.
3
+ import { register } from 'node:module';
4
+
5
+ export async function loadKit(scene = { actors: [] }) {
6
+ register(new URL('./ownership-loader.mjs', import.meta.url), {
7
+ data: {
8
+ baselineDir: process.env.OWNERSHIP_BASELINE_DIR,
9
+ scene,
10
+ kits: new URL('../../', import.meta.url).href,
11
+ },
12
+ });
13
+ const { installSystem } = await import('../code/systems/multiplayer.js');
14
+ const Ownership = await import('../code/server/ownership.js');
15
+ const World = await import('../code/server/world.js');
16
+ const { connectSession } = await import('../../real-time/code/client/connection.js');
17
+ return { installSystem, Ownership, World, connectSession, sceneData: scene };
18
+ }
19
+
20
+ export function fakeBody(point) {
21
+ let at = { ...point },
22
+ rotation = { x: 0, y: 0, z: 0, w: 1 };
23
+ let linear = { x: 0, y: 0, z: 0 },
24
+ angular = { x: 0, y: 0, z: 0 };
25
+ return {
26
+ translation: () => at,
27
+ rotation: () => rotation,
28
+ linvel: () => linear,
29
+ angvel: () => angular,
30
+ isSleeping: () => false,
31
+ setTranslation(v) {
32
+ at = { ...v };
33
+ },
34
+ setRotation(v) {
35
+ rotation = { ...v };
36
+ },
37
+ setNextKinematicTranslation(v) {
38
+ at = { ...v };
39
+ },
40
+ setNextKinematicRotation(v) {
41
+ rotation = { ...v };
42
+ },
43
+ setLinvel(v) {
44
+ linear = { ...v };
45
+ },
46
+ setAngvel(v) {
47
+ angular = { ...v };
48
+ },
49
+ setBodyType() {},
50
+ };
51
+ }
52
+
53
+ export function setClock() {
54
+ let now = 0;
55
+ Object.defineProperty(globalThis, 'performance', {
56
+ configurable: true,
57
+ value: { now: () => now },
58
+ });
59
+ return (value) => {
60
+ now = value;
61
+ };
62
+ }
63
+
64
+ export async function makeClient(kit, id, actors, at, others = () => []) {
65
+ const packets = [],
66
+ inbox = [];
67
+ const connection = {
68
+ playerId: id,
69
+ state: 'connected',
70
+ isSolo: false,
71
+ send(data) {
72
+ packets.push(structuredClone(data));
73
+ },
74
+ onMessage() {},
75
+ onRoster() {},
76
+ onStateChange() {},
77
+ leave() {},
78
+ };
79
+ globalThis.__ownershipConnection = connection;
80
+ const system = kit.installSystem({ registerSystem() {} });
81
+ system.net = await kit.connectSession();
82
+ system.net.drain = () => inbox.splice(0);
83
+ system.otherPlaces = others;
84
+ const actorMap = new Map(actors.map((a) => [a.id, structuredClone(a)]));
85
+ const bodies = new Map([...actorMap].map(([key, a]) => [key, fakeBody(a.components.Transform)]));
86
+ const scene = {
87
+ data: kit.sceneData,
88
+ persistent: {},
89
+ getActor: (key) => actorMap.get(key),
90
+ physics3d: { bodyOf: (key) => bodies.get(key) },
91
+ };
92
+ const local = { components: { Transform: { ...at } } };
93
+ function receive(msg) {
94
+ inbox.push(msg);
95
+ system.receive(scene);
96
+ }
97
+ function report() {
98
+ system.report(scene, local);
99
+ return packets.at(-1);
100
+ }
101
+ return { id, system, scene, local, bodies, actorMap, packets, receive, report };
102
+ }
@@ -0,0 +1,46 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ let settings;
3
+ export function initialize(data) {
4
+ settings = data;
5
+ }
6
+ const stubs = {
7
+ '../client/avatars.js':
8
+ 'export const makeAvatars=()=>({actors:new Map(),tags:new Map(),leaving:new Map()}); export const showSelf=()=>{};',
9
+ '../client/steer.js': 'export const makeState=()=>({});',
10
+ '@imports/castle.real-time/code/client/gameHooks.js': 'export const game={};',
11
+ '@imports/castle.real-time/code/server/gameHooks.js':
12
+ 'export const componentDefaults={}; export const game={};',
13
+ 'castle-web-sdk': 'export const Multiplayer={join:async()=>globalThis.__ownershipConnection};',
14
+ };
15
+ export async function resolve(s, c, next) {
16
+ if (stubs[s])
17
+ return { url: 'data:text/javascript,' + encodeURIComponent(stubs[s]), shortCircuit: true };
18
+ if (s.startsWith('@imports/castle.real-time/'))
19
+ s = settings.kits + 'real-time/' + s.slice('@imports/castle.real-time/'.length);
20
+ return next(s, c);
21
+ }
22
+ export async function load(url, c, next) {
23
+ const relative = url.split('/multiplayer-3d/')[1];
24
+ const baseline =
25
+ settings.baselineDir &&
26
+ [
27
+ 'code/systems/multiplayer.js',
28
+ 'code/server/ownership.js',
29
+ 'code/server/world.js',
30
+ 'code/server/sceneBodies.js',
31
+ ].includes(relative);
32
+ const globs = url.endsWith('/systems/multiplayer.js') || url.endsWith('/server/sceneBodies.js');
33
+ if (baseline || globs) {
34
+ let source = await readFile(
35
+ baseline ? new URL(relative, settings.baselineDir) : new URL(url),
36
+ 'utf8',
37
+ );
38
+ source = source.replace(/import.meta.glob\([^)]*\)/g, (glob) => {
39
+ if (glob.includes('/scenes/'))
40
+ return JSON.stringify({ '/scenes/main.scene': JSON.stringify(settings.scene) });
41
+ return '({})';
42
+ });
43
+ return { format: 'module', source, shortCircuit: true };
44
+ }
45
+ return next(url, c);
46
+ }
@@ -0,0 +1,15 @@
1
+ // Separate module graphs let each config run as a fresh deck in one test process.
2
+ import { Worker } from 'node:worker_threads';
3
+ export function runWorker(url, argv = []) {
4
+ return new Promise((resolve, reject) => {
5
+ const worker = new Worker(url, { argv, stdout: true });
6
+ let out = '';
7
+ worker.stdout.on('data', (chunk) => {
8
+ out += chunk;
9
+ });
10
+ worker.on('error', reject);
11
+ worker.on('exit', (code) =>
12
+ code === 0 ? resolve(out) : reject(new Error(`worker exited ${code}: ${out}`)),
13
+ );
14
+ });
15
+ }