castle-web-cli 0.4.239 → 0.4.241
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.
- package/dist/agent.js +5 -1
- package/dist/api.d.ts +20 -0
- package/dist/api.js +57 -0
- package/dist/bundle.d.ts +38 -1
- package/dist/bundle.js +309 -13
- package/dist/castle-host/host.js +163 -11
- package/dist/castleJson.d.ts +10 -0
- package/dist/castleJson.js +46 -2
- package/dist/check.js +5 -2
- package/dist/devSessionServer.js +4 -1
- package/dist/devSessionStorage.d.ts +1 -0
- package/dist/devSessionStorage.js +32 -7
- package/dist/importOrder.d.ts +2 -0
- package/dist/importOrder.js +29 -0
- package/dist/index.js +6 -3
- package/dist/init.js +24 -2
- package/dist/multiplayerDoc.d.ts +1 -1
- package/dist/multiplayerDoc.js +2 -0
- package/dist/platformDoc.js +3 -2
- package/dist/playPagePolicy.js +5 -1
- package/dist/resetLeaderboards.d.ts +8 -1
- package/dist/resetLeaderboards.js +43 -8
- package/dist/roomLogs.d.ts +1 -0
- package/dist/roomLogs.js +30 -6
- package/dist/save-deck.d.ts +32 -2
- package/dist/save-deck.js +240 -39
- package/kits/base/CLAUDE.md +1 -1
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +174 -6
- package/kits/base/sdk/analytics.d.ts +8 -0
- package/kits/base/sdk/analytics.js +92 -0
- package/kits/base/sdk/castle.d.ts +5 -1
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +48 -0
- package/kits/base/sdk/commands.js +1 -0
- package/kits/base/sdk/debugConsole.d.ts +17 -0
- package/kits/base/sdk/debugConsole.js +154 -0
- package/kits/base/sdk/experiments.js +24 -1
- package/kits/base/sdk/hostRetry.d.ts +7 -0
- package/kits/base/sdk/hostRetry.js +57 -0
- package/kits/base/sdk/hub.d.ts +20 -2
- package/kits/base/sdk/hub.js +99 -13
- package/kits/base/sdk/multiplayer.d.ts +2 -0
- package/kits/base/sdk/multiplayer.js +168 -26
- package/kits/base/sdk/reconnectBudget.d.ts +6 -0
- package/kits/base/sdk/reconnectBudget.js +41 -1
- package/kits/base/sdk/runtime.js +36 -19
- package/kits/base/sdk/server/hub.d.ts +19 -0
- package/kits/base/sdk/server/hub.js +12 -0
- package/kits/base/sdk/server/platformHandle.d.ts +1 -0
- package/kits/base/sdk/server/wrapper.d.ts +1 -1
- package/kits/base/sdk/server/wrapper.js +26 -1
- package/kits/base/sdk/transport.d.ts +2 -1
- package/kits/base/sdk/transport.js +35 -0
- package/kits/hub-game/CLAUDE.md +66 -19
- package/kits/hub-game/code/client/act.js +9 -6
- package/kits/hub-game/code/client/actCore.js +26 -6
- package/kits/hub-game/code/client/actGateLog.js +36 -0
- package/kits/hub-game/code/client/actionOverflow.js +29 -8
- package/kits/hub-game/code/client/actionRailSurface.js +186 -0
- package/kits/hub-game/code/client/actionRailTree.js +173 -0
- package/kits/hub-game/code/client/askSurface.js +85 -0
- package/kits/hub-game/code/client/askTree.js +51 -0
- package/kits/hub-game/code/client/attention.js +31 -6
- package/kits/hub-game/code/client/ballot.js +42 -5
- package/kits/hub-game/code/client/ballotSurface.js +115 -0
- package/kits/hub-game/code/client/ballotTree.js +180 -0
- package/kits/hub-game/code/client/catchingUp.js +19 -0
- package/kits/hub-game/code/client/celebrate.js +66 -0
- package/kits/hub-game/code/client/chrome.js +481 -57
- package/kits/hub-game/code/client/companion.js +93 -23
- package/kits/hub-game/code/client/companionDress.js +1 -1
- package/kits/hub-game/code/client/cornerSurface.js +106 -0
- package/kits/hub-game/code/client/cornerTree.js +83 -0
- package/kits/hub-game/code/client/decor.js +20 -11
- package/kits/hub-game/code/client/deviceStorage.js +121 -0
- package/kits/hub-game/code/client/disguise.js +23 -0
- package/kits/hub-game/code/client/disguiseDraw.js +87 -0
- package/kits/hub-game/code/client/dockSurface.js +206 -0
- package/kits/hub-game/code/client/dockTree.js +232 -0
- package/kits/hub-game/code/client/earned.js +29 -0
- package/kits/hub-game/code/client/emoteSurface.js +188 -0
- package/kits/hub-game/code/client/emoteTree.js +264 -0
- package/kits/hub-game/code/client/farAvatars.js +4 -3
- package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
- package/kits/hub-game/code/client/grab.js +121 -50
- package/kits/hub-game/code/client/holdShow.js +19 -0
- package/kits/hub-game/code/client/hookLayer.js +96 -12
- package/kits/hub-game/code/client/hubControls.js +7 -1
- package/kits/hub-game/code/client/hudSurface.js +11 -3
- package/kits/hub-game/code/client/hudTree.js +7 -4
- package/kits/hub-game/code/client/idle.js +21 -3
- package/kits/hub-game/code/client/invites.js +24 -3
- package/kits/hub-game/code/client/keys.js +15 -0
- package/kits/hub-game/code/client/labelsNear.js +8 -1
- package/kits/hub-game/code/client/layoutCache.js +57 -8
- package/kits/hub-game/code/client/loadingCover.js +53 -4
- package/kits/hub-game/code/client/menuIcons.js +15 -0
- package/kits/hub-game/code/client/menuSurface.js +102 -0
- package/kits/hub-game/code/client/menuTree.js +135 -0
- package/kits/hub-game/code/client/modelLook.js +41 -0
- package/kits/hub-game/code/client/padCues.js +11 -7
- package/kits/hub-game/code/client/padReadability.js +3 -3
- package/kits/hub-game/code/client/pickerSurface.js +152 -0
- package/kits/hub-game/code/client/pickerTree.js +163 -0
- package/kits/hub-game/code/client/pushVisit.js +4 -2
- package/kits/hub-game/code/client/quality.js +188 -29
- package/kits/hub-game/code/client/qualityEntry.js +10 -1
- package/kits/hub-game/code/client/quickChatSurface.js +222 -0
- package/kits/hub-game/code/client/quickChatTree.js +201 -0
- package/kits/hub-game/code/client/rehello.js +75 -0
- package/kits/hub-game/code/client/renderVisibility.js +17 -0
- package/kits/hub-game/code/client/replay.js +118 -0
- package/kits/hub-game/code/client/role.js +3 -0
- package/kits/hub-game/code/client/safeLayout.js +441 -56
- package/kits/hub-game/code/client/safeStyle.js +13 -10
- package/kits/hub-game/code/client/say.js +2 -0
- package/kits/hub-game/code/client/soundSurface.js +77 -0
- package/kits/hub-game/code/client/soundTree.js +74 -0
- package/kits/hub-game/code/client/soundscape.js +12 -9
- package/kits/hub-game/code/client/soundscapeCues.js +1 -1
- package/kits/hub-game/code/client/state.js +67 -1
- package/kits/hub-game/code/client/stuckSurface.js +76 -0
- package/kits/hub-game/code/client/stuckTree.js +67 -0
- package/kits/hub-game/code/client/talk.js +42 -12
- package/kits/hub-game/code/client/talkTree.js +4 -2
- package/kits/hub-game/code/client/textAskSurface.js +147 -0
- package/kits/hub-game/code/client/textAskTree.js +67 -0
- package/kits/hub-game/code/client/tiers.js +252 -27
- package/kits/hub-game/code/client/together.js +4 -1
- package/kits/hub-game/code/client/uiDom.js +86 -8
- package/kits/hub-game/code/client/uiTree.js +33 -4
- package/kits/hub-game/code/client/vehicle.js +72 -51
- package/kits/hub-game/code/client/weakestTier.js +75 -31
- package/kits/hub-game/code/client/wear.js +159 -5
- package/kits/hub-game/code/client/worldLabels.js +205 -25
- package/kits/hub-game/code/companionSpec.js +4 -2
- package/kits/hub-game/code/server/act.js +3 -0
- package/kits/hub-game/code/server/actGate.js +83 -0
- package/kits/hub-game/code/server/actions.js +71 -15
- package/kits/hub-game/code/server/actors.js +20 -5
- package/kits/hub-game/code/server/analytics.js +35 -3
- package/kits/hub-game/code/server/ask.js +39 -3
- package/kits/hub-game/code/server/ballot.js +167 -4
- package/kits/hub-game/code/server/celebrate.js +64 -0
- package/kits/hub-game/code/server/companion.js +17 -2
- package/kits/hub-game/code/server/decor.js +11 -2
- package/kits/hub-game/code/server/disguise.js +63 -0
- package/kits/hub-game/code/server/earned.js +6 -2
- package/kits/hub-game/code/server/friendBests.js +13 -4
- package/kits/hub-game/code/server/friendsAmong.js +67 -8
- package/kits/hub-game/code/server/grab.js +12 -2
- package/kits/hub-game/code/server/heldOffers.js +142 -0
- package/kits/hub-game/code/server/holdShow.js +98 -0
- package/kits/hub-game/code/server/hub.js +991 -72
- package/kits/hub-game/code/server/idle.js +110 -9
- package/kits/hub-game/code/server/index.js +9 -0
- package/kits/hub-game/code/server/labels.js +13 -3
- package/kits/hub-game/code/server/manifest.js +94 -6
- package/kits/hub-game/code/server/menu.js +26 -3
- package/kits/hub-game/code/server/npcs.js +55 -9
- package/kits/hub-game/code/server/observe.js +67 -6
- package/kits/hub-game/code/server/players.js +14 -2
- package/kits/hub-game/code/server/replay.js +135 -0
- package/kits/hub-game/code/server/standing.js +7 -3
- package/kits/hub-game/code/server/storageLimit.js +4 -1
- package/kits/hub-game/code/server/townDay.js +74 -0
- package/kits/hub-game/code/server/vehicle.js +3 -0
- package/kits/hub-game/code/server/vis.js +26 -4
- package/kits/hub-game/code/server/wallet.js +677 -0
- package/kits/hub-game/code/server/wear.js +13 -3
- package/kits/hub-game/code/server/writerLease.js +191 -0
- package/kits/hub-game/code/shared/act.js +1 -1
- package/kits/hub-game/code/shared/expression.js +6 -0
- package/kits/hub-game/code/shared/replay.js +37 -0
- package/kits/hub-game/code/systems/hub.js +429 -55
- package/kits/hub-game/docs/analytics.md +16 -2
- package/kits/hub-game/docs/contract.md +956 -101
- package/kits/hub-game/docs/home-pieces.md +5 -6
- package/kits/hub-game/docs/observed-progress.md +49 -1
- package/kits/hub-game/docs/vehicle-preset.md +23 -0
- package/kits/hub-game/index.html +1 -0
- package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
- package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
- package/kits/hub-game/models/hats/cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/captain.pxmodel +3 -3
- package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
- package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
- package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
- package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
- package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
- package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
- package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
- package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
- package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
- package/kits/hub-game/models/hats/straw.pxmodel +3 -3
- package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
- package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
- package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
- package/kits/hub-game/models/hats/witch.pxmodel +3 -3
- package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
- package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
- package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
- package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
- package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
- package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
- package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
- package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
- package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
- package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
- package/kits/hub-game/package-lock.json +3 -3
- package/kits/hub-game/package.json +4 -3
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
- package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
- package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
- package/kits/hub-game/scripts/gen-hats.mjs +1 -1
- package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
- package/kits/hub-game/scripts/pack.mjs +89 -23
- package/kits/hub-game/scripts/test-act-client.mjs +5 -0
- package/kits/hub-game/scripts/test-act-core.mjs +32 -0
- package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
- package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
- package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
- package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
- package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
- package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
- package/kits/hub-game/scripts/test-actions.mjs +24 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -0
- package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
- package/kits/hub-game/scripts/test-analytics.mjs +79 -0
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
- package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
- package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
- package/kits/hub-game/scripts/test-attention.mjs +43 -1
- package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
- package/kits/hub-game/scripts/test-ballot.mjs +421 -4
- package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
- package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
- package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
- package/kits/hub-game/scripts/test-chat.mjs +73 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
- package/kits/hub-game/scripts/test-companion.mjs +110 -3
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
- package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
- package/kits/hub-game/scripts/test-decor.mjs +27 -0
- package/kits/hub-game/scripts/test-device-class.mjs +4 -1
- package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
- package/kits/hub-game/scripts/test-disguise.mjs +176 -0
- package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
- package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
- package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
- package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
- package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
- package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
- package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
- package/kits/hub-game/scripts/test-grab.mjs +10 -1
- package/kits/hub-game/scripts/test-hats.mjs +28 -0
- package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
- package/kits/hub-game/scripts/test-high-only.mjs +3 -3
- package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
- package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
- package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
- package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +119 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +240 -4
- package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
- package/kits/hub-game/scripts/test-idle.mjs +160 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
- package/kits/hub-game/scripts/test-labels.mjs +11 -0
- package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
- package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
- package/kits/hub-game/scripts/test-manifest.mjs +27 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +54 -5
- package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
- package/kits/hub-game/scripts/test-npcs.mjs +128 -0
- package/kits/hub-game/scripts/test-observed.mjs +171 -3
- package/kits/hub-game/scripts/test-pack.mjs +166 -0
- package/kits/hub-game/scripts/test-pad-cues.mjs +39 -0
- package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
- package/kits/hub-game/scripts/test-placeat-server.mjs +648 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
- package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
- package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
- package/kits/hub-game/scripts/test-quality.mjs +312 -9
- package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
- package/kits/hub-game/scripts/test-rehello.mjs +242 -3
- package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
- package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
- package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
- package/kits/hub-game/scripts/test-replay.mjs +178 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
- package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
- package/kits/hub-game/scripts/test-role-client.mjs +2 -1
- package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
- package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
- package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
- package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
- package/kits/hub-game/scripts/test-standing.mjs +135 -2
- package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
- package/kits/hub-game/scripts/test-stuck.mjs +36 -1
- package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
- package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
- package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
- package/kits/hub-game/scripts/test-tiers.mjs +453 -3
- package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-together.mjs +11 -0
- package/kits/hub-game/scripts/test-town-day.mjs +90 -0
- package/kits/hub-game/scripts/test-try-on.mjs +39 -0
- package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
- package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
- package/kits/hub-game/scripts/test-vehicle-client.mjs +68 -1
- package/kits/hub-game/scripts/test-vis.mjs +145 -0
- package/kits/hub-game/scripts/test-wallet.mjs +650 -0
- package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
- package/kits/hub-game/scripts/test-world-labels.mjs +340 -0
- package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
- package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
- package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
- package/kits/hub-game/tools/hubScene/export.mjs +6 -5
- package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
- package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +36 -2
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +10 -2
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/resumeGate.js +66 -2
- package/kits/multiplayer-3d/code/server/ownership.js +25 -6
- package/kits/multiplayer-3d/code/server/world.js +19 -4
- package/kits/multiplayer-3d/code/systems/multiplayer.js +108 -18
- package/kits/multiplayer-3d/package-lock.json +1 -1
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
- package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +417 -5
- package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +10 -2
- package/kits/physics-3d/CLAUDE.md +14 -0
- package/kits/physics-3d/behaviors/Player.jsx +39 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-model-cache.md +109 -0
- package/kits/physics-3d/docs/engine-player.md +76 -0
- package/kits/physics-3d/docs/engine-skip-work.md +16 -0
- package/kits/physics-3d/docs/pxmodel-format.md +5 -1
- package/kits/physics-3d/engine3d/gait.js +16 -8
- package/kits/physics-3d/engine3d/groundsize.js +23 -0
- package/kits/physics-3d/engine3d/kithooks.js +50 -0
- package/kits/physics-3d/engine3d/look.js +110 -17
- package/kits/physics-3d/engine3d/lookbake.js +19 -1
- package/kits/physics-3d/engine3d/materialpresets.js +3 -2
- package/kits/physics-3d/engine3d/modelcache.js +280 -0
- package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
- package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
- package/kits/physics-3d/engine3d/modelrefs.js +13 -0
- package/kits/physics-3d/engine3d/optimize.js +20 -9
- package/kits/physics-3d/engine3d/playerRun.js +26 -1
- package/kits/physics-3d/engine3d/pxmodel.js +7 -3
- package/kits/physics-3d/engine3d/templatecache.js +722 -0
- package/kits/physics-3d/engine3d/world3d.js +211 -17
- package/kits/physics-3d/package-lock.json +1 -1
- package/kits/physics-3d/package.json +2 -1
- package/kits/physics-3d/play/behaviors/Player.js +43 -3
- package/kits/physics-3d/scripts/render.mjs +56 -8
- package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
- package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
- package/kits/physics-3d/scripts/test-coaxial-escape.mjs +176 -0
- package/kits/physics-3d/scripts/test-gait.mjs +53 -9
- package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
- package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
- package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
- package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
- package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
- package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
- package/kits/physics-3d/systems/physics3d.js +59 -2
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +3 -0
- package/package.json +2 -2
- package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
|
@@ -31,7 +31,19 @@ const RESYNC = 'r';
|
|
|
31
31
|
// How long the joining overlay may hold the card before giving up.
|
|
32
32
|
const JOIN_WAIT_MS = 10000;
|
|
33
33
|
const JOIN_WATCHDOG_MS = 20000;
|
|
34
|
+
// A frame gap this long, with no visibilitychange, is a suspended page (a
|
|
35
|
+
// backgrounded WebView that never said so), and a join pending across it is
|
|
36
|
+
// redone. Shorter gaps are load hitches: a cold Town load's first frames come
|
|
37
|
+
// seconds apart while the world builds, and treating those as a return threw
|
|
38
|
+
// every first join away. They are visible wall time, so they still spend the
|
|
39
|
+
// watchdog budget. After placement the resume gate keeps its own, much
|
|
40
|
+
// shorter, ResumeGate.STALL_MS.
|
|
41
|
+
const JOIN_STALL_MS = 10000;
|
|
34
42
|
const JOIN_FAILURE_LIMIT = 3;
|
|
43
|
+
// A return's cover says nothing for this long after the page shows again:
|
|
44
|
+
// most returns are back sooner, and a plain cover over them reads as a blink
|
|
45
|
+
// rather than a fault. Past it, the cover says it is reconnecting.
|
|
46
|
+
export const QUIET_RETURN_MS = 2500;
|
|
35
47
|
import { game } from '@imports/castle.real-time/code/client/gameHooks.js';
|
|
36
48
|
|
|
37
49
|
// Apply this fraction of a server player correction per frame. Corrections over
|
|
@@ -213,10 +225,20 @@ class MultiplayerSystem {
|
|
|
213
225
|
// `outAt` is the page time the player last came out from behind it, by a
|
|
214
226
|
// snapshot, by giving up, or by the session closing under it (`returning`).
|
|
215
227
|
this.resume = ResumeGate.makeGate();
|
|
228
|
+
// How long to wait for a resync reply before forcing recovery; 0 turns it off.
|
|
229
|
+
this.resyncReplyMs = ResumeGate.RESYNC_REPLY_MS;
|
|
230
|
+
// A reconnect can retain joined and the old local pose. It must not
|
|
231
|
+
// report that pose as acknowledgement of this connection's placement.
|
|
232
|
+
this.reportPlacement = ResumeGate.makeGate();
|
|
216
233
|
this.frameAt = 0;
|
|
217
234
|
this.wasAway = false;
|
|
218
235
|
this.gaveUp = false;
|
|
219
236
|
this.outAt = null;
|
|
237
|
+
// Page time the return's quiet cover began: the away, or the page
|
|
238
|
+
// showing again after it (`QUIET_RETURN_MS`).
|
|
239
|
+
this.quietFrom = null;
|
|
240
|
+
// Whether the cover was last put up (`drawCover`).
|
|
241
|
+
this.coverUp = false;
|
|
220
242
|
this.onVisibility = null;
|
|
221
243
|
// Whether the session's last WORLD offered a resync (`rs`).
|
|
222
244
|
this.resyncs = false;
|
|
@@ -230,7 +252,7 @@ class MultiplayerSystem {
|
|
|
230
252
|
if (!this.net) {
|
|
231
253
|
this.stepJoin(scene);
|
|
232
254
|
this.watchJoin(scene);
|
|
233
|
-
|
|
255
|
+
this.drawCover();
|
|
234
256
|
return void this.start(scene);
|
|
235
257
|
}
|
|
236
258
|
|
|
@@ -263,6 +285,9 @@ class MultiplayerSystem {
|
|
|
263
285
|
// mean the room drawn is no longer current. The page being hidden arms the
|
|
264
286
|
// same gate from its event (`start`), before the page goes.
|
|
265
287
|
if (last && now - last > ResumeGate.STALL_MS) {
|
|
288
|
+
// Every stall return is quiet at first, even one that finds the gate
|
|
289
|
+
// still armed from an earlier away.
|
|
290
|
+
if (this.wasAway) { this.quietFrom = now; }
|
|
266
291
|
this.away(last);
|
|
267
292
|
}
|
|
268
293
|
const connected = this.net.status().state === 'connected';
|
|
@@ -271,6 +296,7 @@ class MultiplayerSystem {
|
|
|
271
296
|
this.gaveUp = false;
|
|
272
297
|
} else {
|
|
273
298
|
this.away(last || now);
|
|
299
|
+
this.waitForPlacement(now);
|
|
274
300
|
}
|
|
275
301
|
ResumeGate.noteConnection(this.resume, connected, now);
|
|
276
302
|
if (gaitModel()) {
|
|
@@ -293,11 +319,20 @@ class MultiplayerSystem {
|
|
|
293
319
|
if (this.watchJoin(scene)) {
|
|
294
320
|
return;
|
|
295
321
|
}
|
|
322
|
+
if (!pageHidden() && ResumeGate.unanswered(this.resume, now, this.resyncReplyMs)) {
|
|
323
|
+
console.warn('[multiplayer] resync unanswered; reconnecting');
|
|
324
|
+
this.net.reconnect?.();
|
|
325
|
+
}
|
|
296
326
|
if (ResumeGate.waited(this.resume, now, !pageHidden())) {
|
|
297
327
|
console.warn('[multiplayer] no current snapshot since coming back; showing the room as it is');
|
|
298
328
|
this.resumed();
|
|
299
329
|
this.gaveUp = true;
|
|
300
330
|
}
|
|
331
|
+
// A WORLD without a self row (including a resync) can release the cover
|
|
332
|
+
// without placing us. Bound the separate report wait by the same timeout.
|
|
333
|
+
if (ResumeGate.waited(this.reportPlacement, now, !pageHidden())) {
|
|
334
|
+
ResumeGate.clear(this.reportPlacement);
|
|
335
|
+
}
|
|
301
336
|
this.applyGone(scene);
|
|
302
337
|
this.reportGone(scene);
|
|
303
338
|
|
|
@@ -317,7 +352,7 @@ class MultiplayerSystem {
|
|
|
317
352
|
// Deck code can make a final local adjustment after engine Player behavior
|
|
318
353
|
// and physics, then optionally replace the kit's standard report.
|
|
319
354
|
game.beforeReport?.(scene, local, this);
|
|
320
|
-
if (!this.joined) {
|
|
355
|
+
if (!this.joined || this.reportPlacement.armed) {
|
|
321
356
|
// Nothing reported until the session has placed this player.
|
|
322
357
|
} else if (game.report) {
|
|
323
358
|
game.report(scene, local, this);
|
|
@@ -338,7 +373,7 @@ class MultiplayerSystem {
|
|
|
338
373
|
}
|
|
339
374
|
this.publish(scene, local);
|
|
340
375
|
updateSoloBadge(this.net.status(), game);
|
|
341
|
-
|
|
376
|
+
this.drawCover();
|
|
342
377
|
}
|
|
343
378
|
|
|
344
379
|
// Join the session `target` names (the public one unless `switchSession`
|
|
@@ -362,8 +397,12 @@ class MultiplayerSystem {
|
|
|
362
397
|
if (pageHidden()) {
|
|
363
398
|
if (this.joinAttempt) { this.joinAttempt.hidden = true; }
|
|
364
399
|
this.away(this.frameAt || performance.now());
|
|
400
|
+
ResumeGate.suspendReply(this.resume, performance.now());
|
|
401
|
+
this.relabelCover();
|
|
365
402
|
} else {
|
|
403
|
+
if (this.wasAway) { this.quietFrom = performance.now(); }
|
|
366
404
|
this.visibleJoin(this.joinScene ?? scene, this.joinAttempt?.hidden === true);
|
|
405
|
+
this.relabelCover();
|
|
367
406
|
}
|
|
368
407
|
};
|
|
369
408
|
document.addEventListener('visibilitychange', this.onVisibility);
|
|
@@ -395,6 +434,7 @@ class MultiplayerSystem {
|
|
|
395
434
|
return;
|
|
396
435
|
}
|
|
397
436
|
this.net = net;
|
|
437
|
+
if (this.joined) {this.waitForPlacement(performance.now());}
|
|
398
438
|
this.joinCommitted = true;
|
|
399
439
|
if (net.status().state === 'connected') { this.joinStage('connected'); }
|
|
400
440
|
this.joinRetryAt = 0;
|
|
@@ -421,7 +461,8 @@ class MultiplayerSystem {
|
|
|
421
461
|
}
|
|
422
462
|
|
|
423
463
|
// Only adjacent visible steps spend the budget. A suspended WebView can
|
|
424
|
-
// miss visibilitychange entirely, including while getSession is pending
|
|
464
|
+
// miss visibilitychange entirely, including while getSession is pending, so
|
|
465
|
+
// a gap past JOIN_STALL_MS counts as a return; a shorter one is a hitch.
|
|
425
466
|
stepJoin(scene) {
|
|
426
467
|
this.joinScene = scene;
|
|
427
468
|
const now = performance.now();
|
|
@@ -430,7 +471,7 @@ class MultiplayerSystem {
|
|
|
430
471
|
if (this.joined || this.target?.mode === 'hub' || this.joinFailed || this.net?.status().solo) { return; }
|
|
431
472
|
const attempt = this.joinAttempt;
|
|
432
473
|
const gap = attempt ? now - attempt.stepAt : 0;
|
|
433
|
-
const stalled = this.starting ? gap >
|
|
474
|
+
const stalled = this.starting ? gap > JOIN_STALL_MS : last !== null && now - last > JOIN_STALL_MS;
|
|
434
475
|
if (!pageHidden() && (attempt?.hidden || stalled)) {
|
|
435
476
|
this.visibleJoin(scene, true, true);
|
|
436
477
|
return;
|
|
@@ -511,7 +552,7 @@ class MultiplayerSystem {
|
|
|
511
552
|
this.joinFailed ||= this.joinFailures >= JOIN_FAILURE_LIMIT;
|
|
512
553
|
if (this.joinFailed) {
|
|
513
554
|
this.joinStage('gave up');
|
|
514
|
-
|
|
555
|
+
this.drawCover(false);
|
|
515
556
|
this.removeJoinFailure ??= showJoinFailure(this.joinName(), () => {
|
|
516
557
|
if (!this.joinFailed) { return; }
|
|
517
558
|
this.joinStage('retry tapped');
|
|
@@ -524,7 +565,7 @@ class MultiplayerSystem {
|
|
|
524
565
|
this.joinRetryAt = 0;
|
|
525
566
|
this.joinStartedAt = 0;
|
|
526
567
|
void this.start(this.joinScene ?? scene);
|
|
527
|
-
|
|
568
|
+
this.drawCover();
|
|
528
569
|
});
|
|
529
570
|
} else {
|
|
530
571
|
this.joinRetryAt = performance.now() + Math.min(30_000, 1_000 * 2 ** Math.min(this.joinFailures - 1, 5));
|
|
@@ -584,7 +625,7 @@ class MultiplayerSystem {
|
|
|
584
625
|
this.clock = Clock.makeClock();
|
|
585
626
|
this.target = join;
|
|
586
627
|
this.quiet = quiet;
|
|
587
|
-
|
|
628
|
+
this.drawCover();
|
|
588
629
|
}
|
|
589
630
|
|
|
590
631
|
// Where the join `switchSession` asked for stands: 'joining', 'joined' (it
|
|
@@ -614,6 +655,8 @@ class MultiplayerSystem {
|
|
|
614
655
|
// kept behind the cover from now until a current snapshot (`receive`). The
|
|
615
656
|
// cover goes up at once, because this runs from the page's hidden event.
|
|
616
657
|
away(since) {
|
|
658
|
+
// The report wait counts visible time only, like the cover's give-up.
|
|
659
|
+
ResumeGate.pauseWait(this.reportPlacement, since);
|
|
617
660
|
if (!this.net || !this.joined || this.gaveUp || this.net.status().solo || this.joinError) {
|
|
618
661
|
return;
|
|
619
662
|
}
|
|
@@ -621,7 +664,8 @@ class MultiplayerSystem {
|
|
|
621
664
|
if (ResumeGate.arm(this.resume, since, serverAt)) {
|
|
622
665
|
console.log('[multiplayer] away; holding the room until a current snapshot');
|
|
623
666
|
this.wasAway = true;
|
|
624
|
-
|
|
667
|
+
this.quietFrom = performance.now();
|
|
668
|
+
this.drawCover();
|
|
625
669
|
}
|
|
626
670
|
}
|
|
627
671
|
|
|
@@ -630,11 +674,21 @@ class MultiplayerSystem {
|
|
|
630
674
|
reconnected() {
|
|
631
675
|
const now = performance.now();
|
|
632
676
|
this.gaveUp = false;
|
|
677
|
+
ResumeGate.clear(this.reportPlacement);
|
|
678
|
+
this.waitForPlacement(now);
|
|
633
679
|
this.away(this.frameAt || now);
|
|
634
680
|
ResumeGate.noteConnection(this.resume, false, now);
|
|
635
681
|
ResumeGate.noteConnection(this.resume, true, now);
|
|
636
682
|
}
|
|
637
683
|
|
|
684
|
+
waitForPlacement(now) {
|
|
685
|
+
if (!this.joined || this.gaveUp || this.net?.status().solo) {return;}
|
|
686
|
+
if (ResumeGate.arm(this.reportPlacement, now, null)) {
|
|
687
|
+
this.placedTo = null;
|
|
688
|
+
this.clampedTo = null;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
|
|
638
692
|
// A current snapshot arrived after an away. Every displayed pose is
|
|
639
693
|
// forgotten, so this frame draws each object and player at its current pose
|
|
640
694
|
// rather than smoothing from the one shown before the away, and each live
|
|
@@ -687,14 +741,39 @@ class MultiplayerSystem {
|
|
|
687
741
|
// gone, and the join overlay covers the next one.
|
|
688
742
|
endAway() {
|
|
689
743
|
ResumeGate.clear(this.resume);
|
|
744
|
+
ResumeGate.clear(this.reportPlacement);
|
|
690
745
|
this.wasAway = false;
|
|
691
746
|
this.gaveUp = false;
|
|
692
747
|
}
|
|
693
748
|
|
|
694
|
-
// What the cover says.
|
|
749
|
+
// What the cover says. A return's says nothing while hidden and for
|
|
750
|
+
// QUIET_RETURN_MS after the page shows again.
|
|
695
751
|
coverText() {
|
|
752
|
+
if (this.wasAway) {
|
|
753
|
+
return this.quietReturn() ? '' : 'Reconnecting…';
|
|
754
|
+
}
|
|
696
755
|
const name = this.joinName();
|
|
697
|
-
return
|
|
756
|
+
return name ? `Joining ${name}…` : 'Joining…';
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
// Put the cover up or take it down (`joiningOverlayWanted` unless told),
|
|
760
|
+
// with what it says now.
|
|
761
|
+
drawCover(wanted = this.joiningOverlayWanted()) {
|
|
762
|
+
this.coverUp = wanted;
|
|
763
|
+
showJoinOverlay(wanted, this.coverText());
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// Only what an up cover says, now: a visibility change restarts a return's
|
|
767
|
+
// quiet before the next frame runs, and must not move the cover itself.
|
|
768
|
+
relabelCover() {
|
|
769
|
+
if (this.coverUp) {
|
|
770
|
+
showJoinOverlay(true, this.coverText());
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
// Whether a return's cover is still in its quiet first QUIET_RETURN_MS.
|
|
775
|
+
quietReturn() {
|
|
776
|
+
return this.wasAway && (pageHidden() || (this.quietFrom !== null && performance.now() - this.quietFrom < QUIET_RETURN_MS));
|
|
698
777
|
}
|
|
699
778
|
|
|
700
779
|
// Drain queued transport messages. State messages update clock, ownership, pose
|
|
@@ -796,7 +875,8 @@ class MultiplayerSystem {
|
|
|
796
875
|
for (const [id, x, y, z, facing, clamped] of msg.ps ?? []) {
|
|
797
876
|
if (id !== selfId) {
|
|
798
877
|
sample(this.players, msg, id, [x, y, z, facing]);
|
|
799
|
-
} else if (msg.k === WORLD
|
|
878
|
+
} else if (!again && (msg.k === WORLD || this.reportPlacement.armed) &&
|
|
879
|
+
(!this.reportPlacement.armed || msg.localMs >= this.reportPlacement.since)) {
|
|
800
880
|
// The WORLD snapshot that starts a session carries where this player
|
|
801
881
|
// left off. The body is moved there in one step, behind the overlay.
|
|
802
882
|
this.placedTo = { x, y, z };
|
|
@@ -1143,6 +1223,11 @@ class MultiplayerSystem {
|
|
|
1143
1223
|
// Without a body yet, the placement waits for one.
|
|
1144
1224
|
if (this.placedTo && body) {
|
|
1145
1225
|
body.setTranslation(this.placedTo, true);
|
|
1226
|
+
scene.physics3d.resetInterpolation?.(local);
|
|
1227
|
+
// Physics already synced this frame: reports and hooks must see the
|
|
1228
|
+
// correction too, rather than the Transform from before it.
|
|
1229
|
+
Object.assign(local.components.Transform, this.placedTo);
|
|
1230
|
+
ResumeGate.clear(this.reportPlacement);
|
|
1146
1231
|
body.setLinvel({ x: 0, y: 0, z: 0 }, true);
|
|
1147
1232
|
this.placedTo = null;
|
|
1148
1233
|
this.settleFrames = 1;
|
|
@@ -1162,23 +1247,25 @@ class MultiplayerSystem {
|
|
|
1162
1247
|
// intermediate positions as valid movement.
|
|
1163
1248
|
if (Math.hypot(off.x, off.y, off.z) > CLAMP_SNAP) {
|
|
1164
1249
|
body.setTranslation(to, true);
|
|
1250
|
+
scene.physics3d.resetInterpolation?.(local);
|
|
1251
|
+
Object.assign(local.components.Transform, to);
|
|
1165
1252
|
body.setLinvel({ x: 0, y: 0, z: 0 }, true);
|
|
1166
1253
|
return;
|
|
1167
1254
|
}
|
|
1168
1255
|
|
|
1169
1256
|
// Ease smaller corrections to avoid an abrupt backward change after an
|
|
1170
1257
|
// ordinary dropped frame or client stall.
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
);
|
|
1258
|
+
const eased = { x: at.x + off.x * CLAMP_EASE, y: at.y + off.y * CLAMP_EASE, z: at.z + off.z * CLAMP_EASE };
|
|
1259
|
+
body.setTranslation(eased, true);
|
|
1260
|
+
scene.physics3d.resetInterpolation?.(local);
|
|
1261
|
+
Object.assign(local.components.Transform, eased);
|
|
1175
1262
|
}
|
|
1176
1263
|
|
|
1177
1264
|
// Report the post-physics local Player pose, poses of locally owned objects,
|
|
1178
1265
|
// and proximity-based ownership requests. Engine Player behavior and local
|
|
1179
1266
|
// Rapier simulation have already completed for this frame.
|
|
1180
1267
|
report(scene, local) {
|
|
1181
|
-
if (!local) {
|
|
1268
|
+
if (!local || this.reportPlacement.armed) {
|
|
1182
1269
|
return;
|
|
1183
1270
|
}
|
|
1184
1271
|
const now = performance.now();
|
|
@@ -1388,6 +1475,9 @@ class MultiplayerSystem {
|
|
|
1388
1475
|
// Other players' avatars are the kit's own and are not reported. Nothing is
|
|
1389
1476
|
// reported before the session has placed this player.
|
|
1390
1477
|
reportGone(scene) {
|
|
1478
|
+
// Keep the previous set until reporting resumes, so removals during the
|
|
1479
|
+
// wait are reported afterwards rather than lost or sent to an old world.
|
|
1480
|
+
if (this.reportPlacement.armed) {return;}
|
|
1391
1481
|
const ids = new Set(scene.actors.keys());
|
|
1392
1482
|
if (this.seen && this.joined) {
|
|
1393
1483
|
const avatars = new Set(this.avatars.actors.values());
|
|
@@ -1455,7 +1545,7 @@ class MultiplayerSystem {
|
|
|
1455
1545
|
document.removeEventListener('visibilitychange', this.onVisibility);
|
|
1456
1546
|
this.onVisibility = null;
|
|
1457
1547
|
}
|
|
1458
|
-
|
|
1548
|
+
this.drawCover(false);
|
|
1459
1549
|
// The badge is a fixed element outside the scene, so a disposed runtime
|
|
1460
1550
|
// (an editor preview closing, say) has to take it down explicitly.
|
|
1461
1551
|
showSoloBadge(null);
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
"private": true,
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"test": "node scripts/test-own-name-tag.mjs && node scripts/test-eligible-claims.mjs && node scripts/test-resume-gate.mjs && node scripts/test-join-watchdog.mjs",
|
|
6
|
+
"test": "node scripts/test-own-name-tag.mjs && node scripts/test-ground-half.mjs && node scripts/test-eligible-claims.mjs && node scripts/test-resync-reconnect.mjs && node scripts/test-resume-gate.mjs && node scripts/test-join-watchdog.mjs && npm run test:owned-moves",
|
|
7
|
+
"test:owned-moves": "node scripts/test-owned-moves.mjs",
|
|
7
8
|
"check": "eslint . && npm test && node --input-type=module -e \"const { bundleProject } = await import('../../cli/dist/bundle.js'); await bundleProject('.');\"",
|
|
8
9
|
"format": "prettier --write \"code/**/*.js\" castle.json package.json"
|
|
9
10
|
},
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// The server's ground slab: 100 m each way without `ground.half`, the scene's
|
|
2
|
+
// half-width with it, and no slab for `ground.none`. A body dropped past the
|
|
3
|
+
// old edge stands only on the larger ground.
|
|
4
|
+
import assert from 'node:assert/strict';
|
|
5
|
+
import RAPIER from '@dimforge/rapier3d-compat';
|
|
6
|
+
import { runWorker } from './ownership-worker.mjs';
|
|
7
|
+
import { loadKit } from './ownership-harness.mjs';
|
|
8
|
+
|
|
9
|
+
const configs = {
|
|
10
|
+
absent: { actors: [] },
|
|
11
|
+
styled: { actors: [], ground: { color: '#336633' } },
|
|
12
|
+
wide: { actors: [], ground: { half: 150 } },
|
|
13
|
+
huge: { actors: [], ground: { half: 1e6 } },
|
|
14
|
+
text: { actors: [], ground: { half: '150' } },
|
|
15
|
+
none: { actors: [], ground: { none: true, half: 150 } },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// Where a straight-down ray from 10 m up at (x, 0) meets the ground, or null.
|
|
19
|
+
function groundAt(world, x) {
|
|
20
|
+
const hit = world.castRay(new RAPIER.Ray({ x, y: 10, z: 0 }, { x: 0, y: -1, z: 0 }), 50, true);
|
|
21
|
+
return hit ? Math.round((10 - hit.timeOfImpact) * 1000) / 1000 : null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const which = process.argv[2];
|
|
25
|
+
if (which) {
|
|
26
|
+
const kit = await loadKit(configs[which]);
|
|
27
|
+
const sim = await kit.World.createSimulation();
|
|
28
|
+
// Scene queries see colliders only after a step.
|
|
29
|
+
sim.world.step();
|
|
30
|
+
const shapes = [];
|
|
31
|
+
sim.world.forEachCollider((c) => {
|
|
32
|
+
const h = c.halfExtents();
|
|
33
|
+
shapes.push([h.x, h.y, h.z, c.translation().y]);
|
|
34
|
+
});
|
|
35
|
+
const report = { shapes, at: Object.fromEntries([0, 90, 99, 101, 149, 151, 199, 201].map((x) => [x, groundAt(sim.world, x)])) };
|
|
36
|
+
sim.world.free();
|
|
37
|
+
process.stdout.write(JSON.stringify(report));
|
|
38
|
+
} else {
|
|
39
|
+
const out = {};
|
|
40
|
+
for (const name of Object.keys(configs)) {
|
|
41
|
+
out[name] = JSON.parse(await runWorker(new URL(import.meta.url), [name]));
|
|
42
|
+
}
|
|
43
|
+
const legacy = { shapes: [[100, 0.5, 100, -0.5]], at: { 0: 0, 90: 0, 99: 0, 101: null, 149: null, 151: null, 199: null, 201: null } };
|
|
44
|
+
assert.deepEqual(out.absent, legacy, 'no ground.half keeps the 100 m slab');
|
|
45
|
+
assert.deepEqual(out.styled, legacy, 'a dressed ground without half keeps the 100 m slab');
|
|
46
|
+
assert.deepEqual(out.text, legacy, 'a half that is not a number is ignored');
|
|
47
|
+
assert.deepEqual(out.wide.shapes, [[150, 0.5, 150, -0.5]], 'ground.half sizes the slab');
|
|
48
|
+
assert.equal(out.wide.at[101], 0, 'past the old edge stands on ground');
|
|
49
|
+
assert.equal(out.wide.at[149], 0);
|
|
50
|
+
assert.equal(out.wide.at[151], null, 'past the new edge falls');
|
|
51
|
+
assert.deepEqual(out.huge.shapes, [[200, 0.5, 200, -0.5]], 'half clamps to the world bounds');
|
|
52
|
+
assert.equal(out.huge.at[199], 0);
|
|
53
|
+
assert.equal(out.huge.at[201], null);
|
|
54
|
+
assert.deepEqual(out.none.shapes, [], 'ground.none still has no slab');
|
|
55
|
+
console.log('ground half: absent/dressed/non-number keep the 100 m slab; 150 and clamped 200 extend it; none has none');
|
|
56
|
+
}
|
|
@@ -55,6 +55,8 @@ register(`data:text/javascript,${encodeURIComponent(`
|
|
|
55
55
|
return next(u, c);
|
|
56
56
|
}
|
|
57
57
|
`)}`);
|
|
58
|
+
// multiplayer.js's JOIN_STALL_MS: a frame gap that reads as a suspended page.
|
|
59
|
+
const JOIN_STALL_MS = 10000;
|
|
58
60
|
let now = 1000;
|
|
59
61
|
Object.defineProperty(globalThis, 'performance', { value: { now: () => now }, configurable: true });
|
|
60
62
|
const warnings = [];
|
|
@@ -212,7 +214,8 @@ await check('queued WORLD placement at 15.1s survives stalls and visible returns
|
|
|
212
214
|
});
|
|
213
215
|
await check('connected unplaced nets survive returns without WORLD and retain their visible watchdog budget', async () => {
|
|
214
216
|
const { system } = setup(); const n = await connect();
|
|
215
|
-
step(19000); frame(
|
|
217
|
+
step(19000); frame(JOIN_STALL_MS + 100);
|
|
218
|
+
assert.equal(system.net, n, 'a long freeze never discards a connected net');
|
|
216
219
|
visibility(true); now += 120000; visibility(false); frame();
|
|
217
220
|
assert.equal(system.net, n); assert.equal(attempts.length, 1);
|
|
218
221
|
assert.equal(system.joinAttempt.visibleMs, 19000, 'parked time is excluded');
|
|
@@ -254,11 +257,59 @@ await check('hidden time spends no watchdog budget; attempts started hidden refr
|
|
|
254
257
|
});
|
|
255
258
|
await check('frame gaps without visibilitychange refresh pending and disconnected joins', async () => {
|
|
256
259
|
for (const assigned of [false, true]) {
|
|
257
|
-
const { system } = setup();
|
|
260
|
+
const { system } = setup(); const old = assigned ? await connect() : null;
|
|
261
|
+
if (old) { old.state = 'reconnecting'; }
|
|
262
|
+
frame(JOIN_STALL_MS - 100);
|
|
263
|
+
assert.equal(attempts.length, 1, 'just under the threshold is a hitch');
|
|
264
|
+
frame(JOIN_STALL_MS + 100);
|
|
258
265
|
assert.equal(attempts.length, 2); assert.equal(stages('visible rejoin').length, 1);
|
|
266
|
+
assert.equal(old?.closes ?? 0, assigned ? 1 : 0);
|
|
259
267
|
assert.equal(stages('watchdog abort').length, 0); assert.equal(system.joinFailures, 1);
|
|
260
268
|
}
|
|
261
269
|
});
|
|
270
|
+
await check('load hitches under JOIN_STALL_MS keep the first join and count no failure', async () => {
|
|
271
|
+
// A cold Town load: the first tick after the attempt starts lands 1.6 s
|
|
272
|
+
// later, and more hitches follow while the world builds.
|
|
273
|
+
for (const kind of ['pending', 'connecting', 'connected', 'reconnecting']) {
|
|
274
|
+
const { system } = setup();
|
|
275
|
+
frame(1600);
|
|
276
|
+
let n = null;
|
|
277
|
+
if (kind !== 'pending') { n = await connect(); n.state = kind === 'connected' ? 'connected' : kind; }
|
|
278
|
+
frame(1100); step(300); frame(4000); step(200); frame(9000);
|
|
279
|
+
assert.equal(attempts.length, 1, `${kind}: no new attempt`);
|
|
280
|
+
assert.equal(stages('visible rejoin').length, 0, kind);
|
|
281
|
+
assert.equal(stages('failure').length, 0, kind);
|
|
282
|
+
assert.equal(stages('watchdog abort').length, 0, kind);
|
|
283
|
+
assert.equal(system.joinFailures, 0, kind);
|
|
284
|
+
assert.equal(n?.closes ?? 0, 0, `${kind}: the assigned net stays open`);
|
|
285
|
+
if (!n) { n = await connect(); }
|
|
286
|
+
assert.equal(system.net, n);
|
|
287
|
+
n.state = 'connected'; placed(n);
|
|
288
|
+
assert.equal(stages('placed')[0].attempt, 1, `${kind}: placed on attempt 1`);
|
|
289
|
+
assert.equal(n.closes, 0); assert.equal(system.joinFailures, 0);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
await check('hitches spend the visible watchdog budget; a placement queued on that frame still wins', async () => {
|
|
293
|
+
const { system } = setup(); const n = await connect(); n.state = 'connecting';
|
|
294
|
+
step(12000); frame(9000);
|
|
295
|
+
assert.equal(system.joinAttempt.visibleMs, 21000, 'a hitch is visible wall time');
|
|
296
|
+
assert.equal(stages('watchdog abort').length, 1, 'over 20 s of visible time is a timeout');
|
|
297
|
+
assert.equal(n.closes, 1); assert.equal(system.joinFailures, 1);
|
|
298
|
+
const { system: again } = setup(); const m = await connect(); m.state = 'connecting';
|
|
299
|
+
step(12000); now += 9000;
|
|
300
|
+
m.inbox.push({ k: 'w', t: now, localMs: now, ps: [['self', 0, 0, 0, 0]], os: [], own: [] });
|
|
301
|
+
frame(); assert.equal(again.joined, true); assert.equal(m.closes, 0); assert.equal(again.joinFailures, 0);
|
|
302
|
+
});
|
|
303
|
+
await check('three load hitches in a row never show the join failure panel', async () => {
|
|
304
|
+
for (const assigned of [false, true]) {
|
|
305
|
+
const { system } = setup(); const n = assigned ? await connect() : null;
|
|
306
|
+
if (n) { n.state = 'connecting'; }
|
|
307
|
+
for (const hitch of [1600, 3000, 5000]) { frame(hitch); step(200); }
|
|
308
|
+
assert.equal(panel(), undefined); assert.equal(system.joinFailed, false);
|
|
309
|
+
assert.equal(system.joinFailures, 0); assert.equal(attempts.length, 1);
|
|
310
|
+
assert.equal(stages('gave up').length, 0);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
262
313
|
await check('three mixed failures stop retries; body panel and Retry recover exactly once', async () => {
|
|
263
314
|
const { system, scene } = setup();
|
|
264
315
|
const hubCover = makeLoadingCover({ enabled: true, title: 'Town', document });
|
|
@@ -380,7 +431,7 @@ await check('destination cancellation cannot fall back publicly and cancel its r
|
|
|
380
431
|
const join = (options) => { attempts.push({ options }); return connectSession(options); };
|
|
381
432
|
const { system } = setup(target, join);
|
|
382
433
|
assert.equal(destinations.length, 1);
|
|
383
|
-
frame(
|
|
434
|
+
frame(JOIN_STALL_MS + 100); // the parked acquisition is abandoned and a fresh one starts
|
|
384
435
|
await settle();
|
|
385
436
|
assert.equal(destinations.length, 2);
|
|
386
437
|
assert.equal(envelopes.filter((e) => e.cancel).length, 1, 'SDK cancels only the old acquisition');
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
// Real Rapier bodies and the kit's actual ownership/world handlers: accepted
|
|
2
|
+
// targets do not become body positions until physics steps. Reports may arrive
|
|
3
|
+
// together, so both their positional baseline and earned allowance must survive
|
|
4
|
+
// more than one report between steps.
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import RAPIER from '@dimforge/rapier3d-compat';
|
|
7
|
+
import { loadKit } from './ownership-harness.mjs';
|
|
8
|
+
|
|
9
|
+
const { Ownership, World } = await loadKit({
|
|
10
|
+
ground: { none: true },
|
|
11
|
+
actors: [{
|
|
12
|
+
id: 'pal',
|
|
13
|
+
components: {
|
|
14
|
+
Transform: { x: 0, y: 3, z: 0 },
|
|
15
|
+
Shape: { kind: 'sphere', radius: 0.2 },
|
|
16
|
+
Body: { type: 'dynamic', gravityScale: 0 },
|
|
17
|
+
},
|
|
18
|
+
}],
|
|
19
|
+
});
|
|
20
|
+
const Players = await import('../code/server/players.js');
|
|
21
|
+
const Limits = await import('../code/server/limits.js');
|
|
22
|
+
|
|
23
|
+
let passed = 0;
|
|
24
|
+
async function test(name, run) {
|
|
25
|
+
const sim = await World.createSimulation();
|
|
26
|
+
try {
|
|
27
|
+
Players.addPlayer(sim, 'cook', [0, 0, 0, 0]);
|
|
28
|
+
Players.addPlayer(sim, 'guest', [0, 0, 0, 0]);
|
|
29
|
+
Ownership.claim(sim, 'cook', ['pal'], []);
|
|
30
|
+
const entry = sim.objects.get('pal');
|
|
31
|
+
assert.equal(entry.owner, 'cook');
|
|
32
|
+
let seq = 0;
|
|
33
|
+
const handovers = [];
|
|
34
|
+
const report = (x, player = 'cook', epoch = entry.epoch) => {
|
|
35
|
+
Ownership.setObjectPoses(sim, player, [
|
|
36
|
+
['pal', x, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, epoch, ++seq, 0],
|
|
37
|
+
], handovers);
|
|
38
|
+
};
|
|
39
|
+
await run({ sim, entry, report, handovers });
|
|
40
|
+
passed += 1;
|
|
41
|
+
} catch (err) {
|
|
42
|
+
console.error(`test-owned-moves: ${name}`);
|
|
43
|
+
throw err;
|
|
44
|
+
} finally {
|
|
45
|
+
sim.world.free();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
for (const speed of [4, 8]) {
|
|
50
|
+
for (const count of [2, 3]) {
|
|
51
|
+
await test(`${count} reports bunched at ${speed} m/s keep ownership`, ({ sim, entry, report, handovers }) => {
|
|
52
|
+
let x = 0;
|
|
53
|
+
for (let burst = 0; burst < 12; burst++) {
|
|
54
|
+
World.step(sim, count * 0.1);
|
|
55
|
+
const stepped = entry.body.translation().x;
|
|
56
|
+
for (let i = 0; i < count; i++) {
|
|
57
|
+
x += speed * 0.1;
|
|
58
|
+
report(x);
|
|
59
|
+
assert.equal(entry.owner, 'cook', `burst ${burst}, report ${i}`);
|
|
60
|
+
assert.equal(entry.body.translation().x, stepped, 'the pending target has not stepped');
|
|
61
|
+
}
|
|
62
|
+
assert.equal(entry.pose.at.x, x);
|
|
63
|
+
assert.equal(Ownership.acks(sim).length, 1, 'the newest accepted report is acknowledged');
|
|
64
|
+
World.step(sim, 1 / 60);
|
|
65
|
+
assert.ok(Math.abs(entry.body.translation().x - x) < 1e-4);
|
|
66
|
+
}
|
|
67
|
+
assert.deepEqual(handovers, []);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
for (const cadence of [100, 150, 200, 250]) {
|
|
73
|
+
for (const speed of [4, 8]) {
|
|
74
|
+
await test(`${cadence} ms cadence with jitter at ${speed} m/s keeps ownership`, ({ sim, entry, report, handovers }) => {
|
|
75
|
+
const jitter = [0, 40, -20, 60, 0, -30];
|
|
76
|
+
let receivedAt = 0;
|
|
77
|
+
for (let i = 0; i < 30; i++) {
|
|
78
|
+
const next = (i + 1) * cadence + jitter[i % jitter.length];
|
|
79
|
+
World.step(sim, (next - receivedAt) / 1000);
|
|
80
|
+
receivedAt = next;
|
|
81
|
+
report(speed * (i + 1) * cadence / 1000);
|
|
82
|
+
Ownership.sweepOwners(sim, handovers);
|
|
83
|
+
assert.equal(entry.owner, 'cook', `report ${i}`);
|
|
84
|
+
}
|
|
85
|
+
assert.deepEqual(handovers, []);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
await test('a 5 m jump with no elapsed time returns the object to the server', ({ entry, report, handovers }) => {
|
|
91
|
+
const epoch = entry.epoch;
|
|
92
|
+
report(5);
|
|
93
|
+
assert.equal(entry.owner, null);
|
|
94
|
+
assert.equal(entry.epoch, epoch + 1);
|
|
95
|
+
assert.equal(entry.body.bodyType(), RAPIER.RigidBodyType.Dynamic);
|
|
96
|
+
assert.equal(entry.body.translation().x, 0, 'the rejected target is never applied');
|
|
97
|
+
assert.equal(entry.ack, null);
|
|
98
|
+
assert.equal(handovers.length, 1);
|
|
99
|
+
assert.equal(handovers[0][1], 0);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
await test('a burst spends elapsed allowance once, not once per report', ({ sim, entry, report }) => {
|
|
103
|
+
World.step(sim, 0.15);
|
|
104
|
+
for (const x of [2, 4, 6]) {
|
|
105
|
+
report(x);
|
|
106
|
+
assert.equal(entry.owner, 'cook');
|
|
107
|
+
assert.equal(entry.body.translation().x, 0);
|
|
108
|
+
}
|
|
109
|
+
report(7);
|
|
110
|
+
assert.equal(entry.owner, null, '7 m exceeds 40 m/s * 0.15 s + 0.6 m');
|
|
111
|
+
assert.equal(entry.body.translation().x, 6, 'handover applies the last accepted target');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
await test('zero-time reports cannot each mint another delivery slack', ({ entry, report }) => {
|
|
115
|
+
report(0.4);
|
|
116
|
+
assert.equal(entry.owner, 'cook');
|
|
117
|
+
report(0.8);
|
|
118
|
+
assert.equal(entry.owner, null, 'the burst exceeds the single 0.6 m slack');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
for (const idle of ['long gap', 'many stationary reports']) {
|
|
122
|
+
await test(`${idle} cannot bank more than the elapsed cap`, ({ sim, entry, report }) => {
|
|
123
|
+
if (idle === 'long gap') {
|
|
124
|
+
// Exercise the receipt handler before its next timeout sweep, as after a
|
|
125
|
+
// stalled event loop: even this cannot spend ten seconds of allowance.
|
|
126
|
+
World.step(sim, 10);
|
|
127
|
+
} else {
|
|
128
|
+
for (let i = 0; i < 50; i++) {
|
|
129
|
+
World.step(sim, 0.1);
|
|
130
|
+
report(0);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const cap = Limits.MAX_OBJECT_SPEED * Limits.OWNER_TIMEOUT_MS / 1000 + Limits.MOVE_SLACK;
|
|
134
|
+
report(cap / 2);
|
|
135
|
+
assert.equal(entry.owner, 'cook');
|
|
136
|
+
report(cap - 0.01);
|
|
137
|
+
assert.equal(entry.owner, 'cook');
|
|
138
|
+
report(cap + 0.01);
|
|
139
|
+
assert.equal(entry.owner, null, 'the whole burst, not each report, shares the capped bank');
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Any single report the old per-report rule (speed times the gap, plus
|
|
144
|
+
// slack) accepted inside the ownership timeout is still accepted.
|
|
145
|
+
for (const [speed, gapMs] of [[30, 1000], [16, 1400], [38, 1450], [8, 600]]) {
|
|
146
|
+
await test(`a ${speed} m/s move after a ${gapMs} ms gap keeps ownership`, ({ sim, entry, report }) => {
|
|
147
|
+
World.step(sim, gapMs / 1000);
|
|
148
|
+
report(speed * gapMs / 1000);
|
|
149
|
+
assert.equal(entry.owner, 'cook');
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
await test('a new grant clears the old pending pose, target and unused movement budget', ({ sim, entry, report, handovers }) => {
|
|
154
|
+
World.step(sim, 0.5);
|
|
155
|
+
const oldEpoch = entry.epoch;
|
|
156
|
+
report(8);
|
|
157
|
+
assert.equal(entry.owner, 'cook');
|
|
158
|
+
assert.equal(entry.pose.at.x, 8);
|
|
159
|
+
assert.equal(entry.body.translation().x, 0, 'the old owner has an unstepped target');
|
|
160
|
+
sim.players.get('cook').at.x = 4;
|
|
161
|
+
Ownership.claim(sim, 'guest', ['pal'], handovers);
|
|
162
|
+
assert.equal(entry.owner, 'guest');
|
|
163
|
+
assert.equal(entry.epoch, oldEpoch + 1);
|
|
164
|
+
assert.equal(entry.pose, null);
|
|
165
|
+
// Step Rapier without advancing simulation time, isolating the old target
|
|
166
|
+
// from any new movement allowance.
|
|
167
|
+
sim.world.step();
|
|
168
|
+
assert.equal(entry.body.translation().x, 0, 'the previous grant cannot move the body');
|
|
169
|
+
report(0, 'guest');
|
|
170
|
+
assert.equal(entry.owner, 'guest', 'the grant starts from its body, not the old target at 8 m');
|
|
171
|
+
report(5, 'guest');
|
|
172
|
+
assert.equal(entry.owner, null, 'the guest cannot spend the old owner\'s unused bank');
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
await test('a grant after server movement starts from the current server body', ({ sim, entry, report }) => {
|
|
176
|
+
World.step(sim, 0.5);
|
|
177
|
+
report(8);
|
|
178
|
+
Ownership.release(sim, 'cook', ['pal'], []);
|
|
179
|
+
entry.body.setTranslation({ x: 20, y: 3, z: 0 }, true);
|
|
180
|
+
sim.players.get('guest').at.x = 20;
|
|
181
|
+
Ownership.claim(sim, 'guest', ['pal'], []);
|
|
182
|
+
assert.equal(entry.owner, 'guest');
|
|
183
|
+
assert.equal(entry.pose, null);
|
|
184
|
+
report(20, 'guest');
|
|
185
|
+
assert.equal(entry.owner, 'guest');
|
|
186
|
+
report(8, 'guest');
|
|
187
|
+
assert.equal(entry.owner, null, 'the old accepted pose is no longer a baseline');
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
console.log(`test-owned-moves: ${passed} passed (real Rapier; bursts, jitter, teleport rejection, capped bank, fresh grants)`);
|