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
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
// still the player's. The
|
|
23
23
|
// fake multiplayer kit of the tests before that has no acknowledgements,
|
|
24
24
|
// so its swings are the unbounded ones at the carry speed.
|
|
25
|
+
// - Against the same bound, with or without the key, a fresh grab's ease-in
|
|
26
|
+
// to its hold point keeps inside it too, so bunched reports no longer drop
|
|
27
|
+
// the hold; it gives up the bound AIM_GIVE_UP_MS after the grab, and
|
|
28
|
+
// without acknowledgements it is the carry at the carry speed it was.
|
|
25
29
|
// `npm run check` runs it; it needs nothing installed.
|
|
26
30
|
|
|
27
31
|
import assert from 'node:assert/strict';
|
|
@@ -30,7 +34,9 @@ import { register } from 'node:module';
|
|
|
30
34
|
import { AIM_GIVE_UP_MS, AIM_SLACK_M, AIM_WAIT_MS, KEEP_TELL_MS, makeGrab } from '../code/client/grab.js';
|
|
31
35
|
import { deck, hub } from '../code/client/state.js';
|
|
32
36
|
import { GRAB_DEFAULTS } from '../code/server/manifest.js';
|
|
33
|
-
import
|
|
37
|
+
import * as Grab from '../code/server/grab.js';
|
|
38
|
+
|
|
39
|
+
const { THROW_REACH } = Grab;
|
|
34
40
|
|
|
35
41
|
let clock = 1000;
|
|
36
42
|
Object.defineProperty(globalThis, 'performance', {
|
|
@@ -598,10 +604,20 @@ const TICK_MS = 1000 / 30;
|
|
|
598
604
|
// (otherwise it waits for a later one), from when `seen.bunching` is set
|
|
599
605
|
// (every tick until then); `upMs` and `downMs` are the one-way delays.
|
|
600
606
|
// `acks: false` leaves the acknowledgements off the multiplayer kit, as one
|
|
601
|
-
// from before them: the swing
|
|
607
|
+
// from before them: the swing and the pickup's ease-in are the unbounded ones
|
|
608
|
+
// they were. `cameraControl: null` is a place without the orbit key.
|
|
602
609
|
function networked(
|
|
603
610
|
grab,
|
|
604
|
-
{
|
|
611
|
+
{
|
|
612
|
+
deliver = () => true,
|
|
613
|
+
upMs = 30,
|
|
614
|
+
downMs = 30,
|
|
615
|
+
camAngle = 0,
|
|
616
|
+
acks = true,
|
|
617
|
+
steps = () => 2,
|
|
618
|
+
cameraControl = 'orbit',
|
|
619
|
+
grabServer = false,
|
|
620
|
+
} = {},
|
|
605
621
|
) {
|
|
606
622
|
const uplink = [];
|
|
607
623
|
const downlink = [];
|
|
@@ -644,10 +660,11 @@ function networked(
|
|
|
644
660
|
const ack = r.mp.acks?.get('a');
|
|
645
661
|
uplink.push({
|
|
646
662
|
at: clock + upMs,
|
|
663
|
+
player: { ...r.me },
|
|
647
664
|
pose: ['a', t.x, t.y, t.z, 0, 0, 0, 1, v.x, v.y, v.z, 0, 0, 0, 1, seq, ack ? ack[1] : 0],
|
|
648
665
|
});
|
|
649
666
|
};
|
|
650
|
-
const r = rig(grab, { a: at(1.2, 0) }, { cameraControl
|
|
667
|
+
const r = rig(grab, { a: at(1.2, 0) }, { cameraControl, persistent: { camAngle }, physics, onReport });
|
|
651
668
|
if (acks) {
|
|
652
669
|
r.mp.acks = new Map();
|
|
653
670
|
}
|
|
@@ -671,6 +688,20 @@ function networked(
|
|
|
671
688
|
['a', { owner: 'me', epoch: 1, claimable: true, body: kinematic(start), reportedAt: 0, claimedAt: 0 }],
|
|
672
689
|
]),
|
|
673
690
|
};
|
|
691
|
+
const h = grabServer ? {
|
|
692
|
+
...Grab.newGrabState(),
|
|
693
|
+
place: { grab }, sim,
|
|
694
|
+
actors: [...r.actors].map(([id, actor]) => ({ id, ...actor })),
|
|
695
|
+
players: new Map([['me', { arrived: true }]]),
|
|
696
|
+
held: new Map(), hidden: new Set(), hooks: {}, ctx: {},
|
|
697
|
+
session: { send: (_id, message) => {
|
|
698
|
+
seen.messages.push(message);
|
|
699
|
+
downlink.push({ at: nextTick + downMs, acks: [], handovers: [], messages: [message], t: sim.timeMs });
|
|
700
|
+
} },
|
|
701
|
+
} : null;
|
|
702
|
+
seen.messages = [];
|
|
703
|
+
seen.holds = 0;
|
|
704
|
+
if (h) {sim.players.get('me').at = { ...r.me };}
|
|
674
705
|
let tick = 0;
|
|
675
706
|
let nextTick = clock + TICK_MS;
|
|
676
707
|
const server = () => {
|
|
@@ -689,6 +720,7 @@ function networked(
|
|
|
689
720
|
// Handed back to the server: the hold is over, and the reports
|
|
690
721
|
// still on the way are from a grant that has ended.
|
|
691
722
|
} else if (m.pose) {
|
|
723
|
+
if (h) {sim.players.get('me').at = m.player;}
|
|
692
724
|
const at = entry.body.translation();
|
|
693
725
|
const elapsed = Math.max(0, sim.timeMs - entry.reportedAt) / 1000;
|
|
694
726
|
const d = Math.hypot(m.pose[1] - at.x, m.pose[2] - at.y, m.pose[3] - at.z);
|
|
@@ -701,6 +733,10 @@ function networked(
|
|
|
701
733
|
// (code/server/grab.js): the object is still this player's.
|
|
702
734
|
seen.throws.push({ owned: entry.owner === 'me', at: entry.body.translation() });
|
|
703
735
|
}
|
|
736
|
+
if (h && m.message) {
|
|
737
|
+
Grab.message(h, 'me', m.message);
|
|
738
|
+
if (m.message.op === 'hold') {seen.holds += 1;}
|
|
739
|
+
}
|
|
704
740
|
}
|
|
705
741
|
if (seen.bunching) {
|
|
706
742
|
seen.bunches.push(bunch);
|
|
@@ -712,6 +748,10 @@ function networked(
|
|
|
712
748
|
sim.objects.get('a').body.step();
|
|
713
749
|
sim.timeMs += 1000 / 60;
|
|
714
750
|
}
|
|
751
|
+
if (h) {
|
|
752
|
+
Ownership.sweepOwners(sim, handovers);
|
|
753
|
+
Grab.tick(h);
|
|
754
|
+
}
|
|
715
755
|
seen.handovers.push(...handovers);
|
|
716
756
|
const acks = Ownership.acks(sim);
|
|
717
757
|
if (acks.length || handovers.length) {
|
|
@@ -725,6 +765,7 @@ function networked(
|
|
|
725
765
|
const m = downlink.shift();
|
|
726
766
|
// The broadcast's simulation time, as the hub's state hook keeps it.
|
|
727
767
|
hub.lastT = m.t;
|
|
768
|
+
hub.grabEvents.push(...(m.messages ?? []));
|
|
728
769
|
for (const [id, ...ack] of m.acks) {
|
|
729
770
|
r.mp.acks?.set(id, ack);
|
|
730
771
|
}
|
|
@@ -746,7 +787,7 @@ function networked(
|
|
|
746
787
|
clock = was;
|
|
747
788
|
return step(ms, pressed, idle);
|
|
748
789
|
};
|
|
749
|
-
return { r, seen, sim, tick: () => tick };
|
|
790
|
+
return { r, seen, sim, h, tick: () => tick };
|
|
750
791
|
}
|
|
751
792
|
|
|
752
793
|
// Grab, carry to the hold point, and press Throw with the camera looking
|
|
@@ -760,8 +801,8 @@ function throwBehind(grab, network, frames) {
|
|
|
760
801
|
r.step();
|
|
761
802
|
}
|
|
762
803
|
assert.equal(seen.handovers.length, 0, 'the carry itself is inside the bound');
|
|
763
|
-
// The bunches start with the press. (
|
|
764
|
-
// the
|
|
804
|
+
// The bunches start with the press. (The pickup's ease-in is bounded as
|
|
805
|
+
// the swing is, with or without the key: see the tests after these.)
|
|
765
806
|
seen.bunching = true;
|
|
766
807
|
const pressAt = clock;
|
|
767
808
|
r.step(16, true);
|
|
@@ -819,13 +860,16 @@ for (const [name, network] of Object.entries({
|
|
|
819
860
|
}
|
|
820
861
|
}
|
|
821
862
|
|
|
822
|
-
test('with the key, three reports to a tick,
|
|
863
|
+
test('with the key, three reports to a tick, no client acknowledgements: the fixed server accepts the unbounded swing and throw', () => {
|
|
823
864
|
const { r, seen } = throwBehind({ ...GRAB_DEFAULTS }, { deliver: (tick) => tick % 5 === 0, acks: false }, lumpy);
|
|
824
|
-
assert.
|
|
865
|
+
assert.deepEqual(seen.handovers, []);
|
|
866
|
+
// This exceeds the former stepped-body allowance, while the corrected
|
|
867
|
+
// server measures accepted targets against the burst's earned budget.
|
|
825
868
|
assert.ok(seen.worst > Limits.MOVE_SLACK, String(seen.worst));
|
|
826
869
|
assert.equal(r.g.holding(), null);
|
|
827
|
-
assert.equal(seen.throws.length,
|
|
828
|
-
assert.equal(
|
|
870
|
+
assert.equal(seen.throws.length, 1);
|
|
871
|
+
assert.equal(seen.throws[0].owned, true);
|
|
872
|
+
assert.equal(r.throws().length, 1);
|
|
829
873
|
});
|
|
830
874
|
|
|
831
875
|
test('with the key, an ordinary connection: half a turn at the default hold takes about a second, at most AIM_SLACK_M from where the server\'s body may be', () => {
|
|
@@ -958,4 +1002,209 @@ test('with the key, three reports to a tick: the swing is bounded by where each
|
|
|
958
1002
|
}
|
|
959
1003
|
});
|
|
960
1004
|
|
|
1005
|
+
// ---- The pickup's ease-in against the same move bound -------------------------
|
|
1006
|
+
//
|
|
1007
|
+
// Without the orbit key, a fresh grab at the longest hold (3 m, the object
|
|
1008
|
+
// ~1.8 m from it): the ease-in at the carry speed puts 0.32 m between reports
|
|
1009
|
+
// at 60 fps, so two reports bunched to one server tick are 0.64 m apart with
|
|
1010
|
+
// no time allowed, past the 0.6 m slack, and the server takes the object
|
|
1011
|
+
// back under the former server check. A client without acknowledgements still
|
|
1012
|
+
// carries unbounded; the fixed server now accepts those bunched reports too.
|
|
1013
|
+
|
|
1014
|
+
// Grab with bunching from the first report; frames from `frames(i)` ms.
|
|
1015
|
+
// Returns when the object is at its hold point, or the hold is gone.
|
|
1016
|
+
function pickUp(grab, network, frames = () => 16, max = 400) {
|
|
1017
|
+
const net = networked(grab, { cameraControl: null, ...network });
|
|
1018
|
+
const { r, seen } = net;
|
|
1019
|
+
assert.notEqual(r.scene.cameraControl, 'orbit');
|
|
1020
|
+
seen.bunching = true;
|
|
1021
|
+
r.step();
|
|
1022
|
+
const grabAt = clock;
|
|
1023
|
+
assert.equal(r.step(16, true), 'Throw');
|
|
1024
|
+
const holdD = Math.max(grab.holdDistance, 0.35 + 0.3 + 0.15);
|
|
1025
|
+
const there = () => flat(r.actors.get('a').components.Transform, { x: r.me.x, z: r.me.z + holdD }) < 1e-6;
|
|
1026
|
+
let i = 0;
|
|
1027
|
+
while (!there() && r.g.holding() === 'a' && i < max) {
|
|
1028
|
+
r.step(frames(i));
|
|
1029
|
+
i += 1;
|
|
1030
|
+
}
|
|
1031
|
+
return { ...net, there: there(), ms: clock - grabAt };
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
for (const [name, network] of Object.entries({
|
|
1035
|
+
'two reports to a tick': { deliver: (tick) => tick % 3 === 0 },
|
|
1036
|
+
'three reports to a tick': { deliver: (tick) => tick % 5 === 0 },
|
|
1037
|
+
'a stall, then a bunch': { deliver: (tick) => tick % 12 === 0 || tick % 12 > 8, upMs: 60, downMs: 60 },
|
|
1038
|
+
})) {
|
|
1039
|
+
for (const frames of [() => 16, lumpy]) {
|
|
1040
|
+
test(`without the key, ${name}: a fresh grab at a 3 m hold eases in inside multiplayer-3d's move bound and keeps the hold`, () => {
|
|
1041
|
+
const { r, seen, there, ms } = pickUp({ ...GRAB_DEFAULTS, holdDistance: 3 }, network, frames);
|
|
1042
|
+
// A second more, for the server to hear every report of the ease-in.
|
|
1043
|
+
for (let i = 0; i < 60; i += 1) {
|
|
1044
|
+
r.step(frames(i));
|
|
1045
|
+
}
|
|
1046
|
+
assert.ok(Math.max(...seen.bunches) >= 2, JSON.stringify(seen.bunches));
|
|
1047
|
+
assert.ok(seen.worst <= Limits.MOVE_SLACK, String(seen.worst));
|
|
1048
|
+
assert.deepEqual(seen.handovers, []);
|
|
1049
|
+
assert.equal(r.g.holding(), 'a');
|
|
1050
|
+
assert.ok(there);
|
|
1051
|
+
// Before the give-up: the acknowledgements, not the fallback, got it there.
|
|
1052
|
+
assert.ok(ms < AIM_GIVE_UP_MS, String(ms));
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
for (const [name, deliver] of Object.entries({
|
|
1058
|
+
'two reports to a tick': (tick) => tick % 3 === 0,
|
|
1059
|
+
'three reports to a tick': (tick) => tick % 5 === 0,
|
|
1060
|
+
'a stall, then a bunch': (tick) => tick % 12 === 0 || tick % 12 > 8,
|
|
1061
|
+
})) {
|
|
1062
|
+
test(`without the key, ${name}, no client acknowledgements: the fixed server keeps a fresh unbounded 3 m hold`, () => {
|
|
1063
|
+
const { r, seen } = pickUp({ ...GRAB_DEFAULTS, holdDistance: 3 }, { deliver, acks: false });
|
|
1064
|
+
// The client is at the hold point long before the server hears of it.
|
|
1065
|
+
for (let i = 0; i < 60; i += 1) {
|
|
1066
|
+
r.step();
|
|
1067
|
+
}
|
|
1068
|
+
assert.deepEqual(seen.handovers, []);
|
|
1069
|
+
assert.ok(seen.worst > Limits.MOVE_SLACK, String(seen.worst));
|
|
1070
|
+
assert.equal(r.g.holding(), 'a');
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
test('without the key, an ordinary connection: the ease-in waits for its first acknowledgement, then gets to a 3 m hold well inside a second', () => {
|
|
1075
|
+
const { r, seen, there, ms } = pickUp({ ...GRAB_DEFAULTS, holdDistance: 3 }, {});
|
|
1076
|
+
assert.deepEqual(seen.handovers, []);
|
|
1077
|
+
assert.ok(seen.worst <= AIM_SLACK_M + 0.05, String(seen.worst));
|
|
1078
|
+
assert.equal(r.g.holding(), 'a');
|
|
1079
|
+
assert.ok(there);
|
|
1080
|
+
assert.ok(ms > 100 && ms < 1000, String(ms));
|
|
1081
|
+
});
|
|
1082
|
+
|
|
1083
|
+
test('without the key, a server that never answers: the ease-in holds the object where it lay, then gives up at AIM_GIVE_UP_MS and carries it at the carry speed', () => {
|
|
1084
|
+
const { r, seen } = networked({ ...GRAB_DEFAULTS, holdDistance: 3 }, { cameraControl: null, deliver: () => false });
|
|
1085
|
+
assert.notEqual(r.scene.cameraControl, 'orbit');
|
|
1086
|
+
seen.bunching = true;
|
|
1087
|
+
r.step();
|
|
1088
|
+
const grabAt = clock;
|
|
1089
|
+
assert.equal(r.step(16, true), 'Throw');
|
|
1090
|
+
// Where it lay when grabbed (the grab frame does not move it: no report yet).
|
|
1091
|
+
const t = r.actors.get('a').components.Transform;
|
|
1092
|
+
const lay = { ...t };
|
|
1093
|
+
while (clock + 16 < grabAt + AIM_GIVE_UP_MS) {
|
|
1094
|
+
r.step();
|
|
1095
|
+
assert.deepEqual({ x: t.x, y: t.y, z: t.z }, lay);
|
|
1096
|
+
assert.deepEqual(r.bodies.get('a').v, { x: 0, y: 0, z: 0 });
|
|
1097
|
+
}
|
|
1098
|
+
while (clock < grabAt + AIM_GIVE_UP_MS) {
|
|
1099
|
+
r.step();
|
|
1100
|
+
}
|
|
1101
|
+
// Past the give-up: the plain carry, at the carry speed, with its velocity.
|
|
1102
|
+
const before = { ...t };
|
|
1103
|
+
r.step(16);
|
|
1104
|
+
assert.ok(Math.abs(Math.hypot(t.x - before.x, t.y - before.y, t.z - before.z) - 20 * 0.016) < 1e-9);
|
|
1105
|
+
const v = r.bodies.get('a').v;
|
|
1106
|
+
assert.ok(Math.abs(Math.hypot(v.x, v.y, v.z) - 20) < 1e-9, JSON.stringify(v));
|
|
1107
|
+
for (let i = 0; i < 10; i += 1) {
|
|
1108
|
+
r.step(16);
|
|
1109
|
+
}
|
|
1110
|
+
assert.ok(flat(t, { x: r.me.x, z: r.me.z + 3 }) < 1e-6, JSON.stringify(t));
|
|
1111
|
+
assert.equal(r.g.holding(), 'a');
|
|
1112
|
+
});
|
|
1113
|
+
|
|
1114
|
+
test('without the key, a multiplayer kit without acknowledgements: the ease-in is the carry it was, at the carry speed from the grab frame', () => {
|
|
1115
|
+
const { r } = networked({ ...GRAB_DEFAULTS, holdDistance: 3 }, { cameraControl: null, acks: false });
|
|
1116
|
+
assert.notEqual(r.scene.cameraControl, 'orbit');
|
|
1117
|
+
r.step();
|
|
1118
|
+
const t = r.actors.get('a').components.Transform;
|
|
1119
|
+
let before = { ...t };
|
|
1120
|
+
r.step(16, true);
|
|
1121
|
+
// Carried at the carry speed's velocity, not at rest.
|
|
1122
|
+
const v = r.bodies.get('a').v;
|
|
1123
|
+
assert.ok(Math.abs(Math.hypot(v.x, v.y, v.z) - 20) < 1e-9, JSON.stringify(v));
|
|
1124
|
+
const steps = [];
|
|
1125
|
+
for (let i = 0; i < 5; i += 1) {
|
|
1126
|
+
steps.push(Math.hypot(t.x - before.x, t.y - before.y, t.z - before.z));
|
|
1127
|
+
before = { ...t };
|
|
1128
|
+
r.step(16);
|
|
1129
|
+
}
|
|
1130
|
+
// (The first is measured from before the grab frame's physics, which let
|
|
1131
|
+
// the loose object fall a fraction of a millimetre.)
|
|
1132
|
+
for (const d of steps) {
|
|
1133
|
+
assert.ok(Math.abs(d - 20 * 0.016) < 1e-3, JSON.stringify(steps));
|
|
1134
|
+
}
|
|
1135
|
+
});
|
|
1136
|
+
|
|
1137
|
+
// Codex review: the trail of reports is pruned as acknowledgements come in,
|
|
1138
|
+
// not only when the ease-in or a swing reads it, so a long ordinary hold
|
|
1139
|
+
// keeps a few reports, not one for every report of the hold.
|
|
1140
|
+
for (const cameraControl of [null, 'orbit']) {
|
|
1141
|
+
test(`${cameraControl ? 'with' : 'without'} the key, a minute's hold on an ordinary connection keeps only the reports in flight`, () => {
|
|
1142
|
+
const { r, seen } = networked({ ...GRAB_DEFAULTS, holdDistance: 3 }, { cameraControl });
|
|
1143
|
+
assert.equal(r.scene.cameraControl === 'orbit', cameraControl === 'orbit');
|
|
1144
|
+
r.step();
|
|
1145
|
+
assert.equal(r.step(16, true), 'Throw');
|
|
1146
|
+
let most = 0;
|
|
1147
|
+
for (let i = 0; i < 60 * 60; i += 1) {
|
|
1148
|
+
// Walking about, so the carry keeps reporting new places.
|
|
1149
|
+
r.me.x = Math.sin(i / 50) * 2;
|
|
1150
|
+
r.step();
|
|
1151
|
+
most = Math.max(most, r.g.trailLength());
|
|
1152
|
+
}
|
|
1153
|
+
assert.equal(r.g.holding(), 'a');
|
|
1154
|
+
assert.deepEqual(seen.handovers, []);
|
|
1155
|
+
// A report every 50 ms and about 100 ms there and back: a handful.
|
|
1156
|
+
assert.ok(most > 0 && most <= 6, String(most));
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
function walkCarry({ distance = 7.5, turn = 90, bunch = true } = {}) {
|
|
1161
|
+
const grab = { ...GRAB_DEFAULTS, throwSpeed: 6, steady: true, reach: 2.2, keepHeld: true };
|
|
1162
|
+
const { r, seen, h } = networked(grab, { grabServer: true, deliver: (tick) => tick % 3 === 0 });
|
|
1163
|
+
r.step();
|
|
1164
|
+
assert.equal(r.step(16, true), 'Throw');
|
|
1165
|
+
for (let i = 0; i < 63; i += 1) {r.step();}
|
|
1166
|
+
assert.equal(Grab.holding(h, 'me'), 'a');
|
|
1167
|
+
assert.ok(h.pins.has('a'));
|
|
1168
|
+
// Evidence: facing 204.955 -> 115.274 degrees, walking towards (5, -1).
|
|
1169
|
+
// Rotate those coordinates to +z -> +x; preserve the 7.5 m path at 6 m/s.
|
|
1170
|
+
// The Player eases its facing towards the walk rather than snapping it.
|
|
1171
|
+
seen.bunching = bunch;
|
|
1172
|
+
for (let walked = 0; walked < distance;) {
|
|
1173
|
+
const stride = Math.min(6 * 0.016, distance - walked);
|
|
1174
|
+
r.me.x += Math.sin(turn * DEG) * stride;
|
|
1175
|
+
r.me.z += Math.cos(turn * DEG) * stride;
|
|
1176
|
+
r.me.rotationY += (turn - r.me.rotationY) * (1 - Math.exp(-12 * 0.016));
|
|
1177
|
+
r.step();
|
|
1178
|
+
walked += stride;
|
|
1179
|
+
}
|
|
1180
|
+
for (let i = 0; i < 63; i += 1) {r.step();}
|
|
1181
|
+
assert.deepEqual(seen.messages, [], 'no deck drop or grab refusal');
|
|
1182
|
+
assert.equal(seen.throws.length, 0, 'no Throw input');
|
|
1183
|
+
return { r, seen, h };
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
// The shared ownership bound uses accepted targets and banks elapsed movement,
|
|
1187
|
+
// so ordinary carry reports can bunch without ending the hold or its pin.
|
|
1188
|
+
test('Number Pals regression: a 7.5 m turning walk with bunched reports keeps the hold and pin', () => {
|
|
1189
|
+
const { r, seen, h } = walkCarry();
|
|
1190
|
+
assert.ok(Math.max(...seen.bunches) >= 2);
|
|
1191
|
+
assert.deepEqual(seen.handovers, []);
|
|
1192
|
+
assert.equal(r.g.holding(), 'a');
|
|
1193
|
+
assert.equal(Grab.holding(h, 'me'), 'a');
|
|
1194
|
+
assert.ok(h.pins.has('a'), 'the keepHeld pin is renewed');
|
|
1195
|
+
assert.ok(seen.holds >= 3);
|
|
1196
|
+
});
|
|
1197
|
+
|
|
1198
|
+
for (const [name, options] of [
|
|
1199
|
+
['the turning walk without packet bunching', { bunch: false }],
|
|
1200
|
+
['a short straight walk with packet bunching', { distance: 0.3, turn: 0 }],
|
|
1201
|
+
]) test(`Number Pals control: ${name} keeps the carry`, () => {
|
|
1202
|
+
const { r, seen, h } = walkCarry(options);
|
|
1203
|
+
assert.deepEqual(seen.handovers, []);
|
|
1204
|
+
assert.equal(r.g.holding(), 'a');
|
|
1205
|
+
assert.equal(Grab.holding(h, 'me'), 'a');
|
|
1206
|
+
assert.ok(h.pins.has('a'), 'the keepHeld pin is renewed');
|
|
1207
|
+
assert.ok(seen.holds >= 2);
|
|
1208
|
+
});
|
|
1209
|
+
|
|
961
1210
|
console.log(`test-grab-orbit: ${n} passed`);
|
|
@@ -327,16 +327,25 @@ test('hub.drop tells a holder to let go, and only holders', () => {
|
|
|
327
327
|
const { hub, say, sent } = boot();
|
|
328
328
|
say('p1', { actor: 'crate', op: 'grab' });
|
|
329
329
|
const drops = () => sent.filter(([, d]) => d.k === 'hub-drop');
|
|
330
|
-
assert.equal(hub.drop('p2'), 0);
|
|
331
330
|
assert.equal(hub.drop('p1'), 1);
|
|
332
331
|
assert.deepEqual(drops(), [['p1', { k: 'hub-drop', actor: 'crate' }]]);
|
|
333
332
|
assert.equal(hub.holding('p1'), null);
|
|
334
333
|
assert.equal(hub.drop(), 0);
|
|
334
|
+
assert.equal(drops().length, 1, 'hub.drop() with no id tells only registered holders');
|
|
335
335
|
say('p1', { actor: 'barrel', op: 'grab' });
|
|
336
336
|
assert.equal(hub.drop(), 1);
|
|
337
337
|
assert.equal(drops().length, 2);
|
|
338
338
|
});
|
|
339
339
|
|
|
340
|
+
test('v1.191: hub.drop(playerId) tells a named player here even with no registered hold', () => {
|
|
341
|
+
const { hub, sent } = boot();
|
|
342
|
+
const drops = () => sent.filter(([, d]) => d.k === 'hub-drop');
|
|
343
|
+
assert.equal(hub.drop('p2'), 0, 'the count is still of registered holds');
|
|
344
|
+
assert.deepEqual(drops(), [['p2', { k: 'hub-drop' }]]);
|
|
345
|
+
assert.equal(hub.drop('nobody'), 0);
|
|
346
|
+
assert.equal(drops().length, 1, 'a player not in the place is not sent anything');
|
|
347
|
+
});
|
|
348
|
+
|
|
340
349
|
test('a hold the multiplayer kit or the place ended is forgotten', () => {
|
|
341
350
|
const { h, hub, say, world, objects } = boot();
|
|
342
351
|
say('p1', { actor: 'crate', op: 'grab' });
|
|
@@ -481,4 +481,32 @@ test('hub.wearing reads what a player here owns, a copy, never a try-on', () =>
|
|
|
481
481
|
assert.equal(Wear.wearing(h, 'gone'), null);
|
|
482
482
|
});
|
|
483
483
|
|
|
484
|
+
test('a worn hat follows its avatar when a seat or emote moves the model rig, and stands again after', () => {
|
|
485
|
+
const scene = fakeScene();
|
|
486
|
+
const theirs = scene.place('body-p2', 0, 0, 0);
|
|
487
|
+
const rig = new THREE.Group(); rig.position.y = -0.7; theirs.add(rig);
|
|
488
|
+
const wear = makeWear(), wearing = new Map([['p2', { kind: 'hat-cap', color: '#2f6fd0', rarity: 0 }]]);
|
|
489
|
+
wear.frame(scene, { id: 'me-body' }, wearing, () => 1.5, 0, () => Avatar.hatFit(1, 'toon'));
|
|
490
|
+
const cap = theirs.children.find((child) => child.name === 'wear:hat');
|
|
491
|
+
scene.world.updateMatrixWorld(true);
|
|
492
|
+
const standing = worldAt(cap);
|
|
493
|
+
// idle.js's seat: the rig drops 0.45 m and tips back, its standing pose kept.
|
|
494
|
+
rig.userData.hubIdleBase = { y: -0.7, rx: 0, ry: 0, rz: 0 };
|
|
495
|
+
rig.position.y = -0.7 - 0.45; rig.rotation.x = -0.2;
|
|
496
|
+
wear.frame(scene, { id: 'me-body' }, wearing, () => 1.5, 0, () => Avatar.hatFit(1, 'toon'));
|
|
497
|
+
scene.world.updateMatrixWorld(true);
|
|
498
|
+
const seated = worldAt(cap);
|
|
499
|
+
assert.ok(seated.y < standing.y - 0.3, `the hat came down with the body: ${standing.y} -> ${seated.y}`);
|
|
500
|
+
// Exactly as a point on the rig: the rig's pose now over its standing one.
|
|
501
|
+
rig.updateMatrix();
|
|
502
|
+
const delta = rig.matrix.clone().multiply(new THREE.Matrix4().makeTranslation(0, 0.7, 0));
|
|
503
|
+
const expected = theirs.localToWorld(cap.position.clone().applyMatrix4(delta));
|
|
504
|
+
assert.ok(seated.distanceTo(expected) < 1e-9, 'moved as the rig moved');
|
|
505
|
+
rig.position.y = -0.7; rig.rotation.x = 0;
|
|
506
|
+
wear.frame(scene, { id: 'me-body' }, wearing, () => 1.5, 0, () => Avatar.hatFit(1, 'toon'));
|
|
507
|
+
scene.world.updateMatrixWorld(true);
|
|
508
|
+
assert.ok(worldAt(cap).distanceTo(standing) < 1e-9, 'standing again, back where it was');
|
|
509
|
+
assert.equal(cap.matrixAutoUpdate, true);
|
|
510
|
+
});
|
|
511
|
+
|
|
484
512
|
console.log(`test-hats: ${n} passed`);
|