castle-web-cli 0.4.239 → 0.4.240
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/platformDoc.js +2 -1
- package/dist/playPagePolicy.js +5 -1
- package/dist/resetLeaderboards.d.ts +8 -1
- package/dist/resetLeaderboards.js +43 -8
- 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 +473 -53
- 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/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 +851 -45
- 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 +8 -1
- package/kits/hub-game/code/server/replay.js +135 -0
- 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 +427 -54
- package/kits/hub-game/docs/analytics.md +16 -2
- package/kits/hub-game/docs/contract.md +942 -99
- 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 +420 -3
- 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-picker-surface.mjs +321 -0
- package/kits/hub-game/scripts/test-placeat-server.mjs +395 -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 +237 -0
- 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-stuck-surface.mjs +174 -0
- package/kits/hub-game/scripts/test-stuck.mjs +31 -0
- 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 +49 -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 +67 -11
- 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 +191 -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-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 +51 -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
|
@@ -243,6 +243,46 @@ let n = 0;
|
|
|
243
243
|
await settle();
|
|
244
244
|
assert.equal(canType, false);
|
|
245
245
|
handlers.end();
|
|
246
|
+
// v1.175: a refused inspect still shows an authored opening's asks, as
|
|
247
|
+
// taps the place answers (never a mind turn); typing stays off.
|
|
248
|
+
hub.npcEvents.push({ k: 'hub-npc', npc: 'greeter', name: 'Rowan', open: true, mind: true, character: 'greeter', opening: { text: 'What do you like?', asks: ['Fishing', 'Gardens'] }, fallbackChoices: ['Fishing', 'Gardens'] });
|
|
249
|
+
frame();
|
|
250
|
+
assert.equal(canType, false, 'typing still waits for a successful inspect');
|
|
251
|
+
assert.deepEqual(asks, ['Fishing', 'Gardens'], 'the authored asks show while the inspect is refused');
|
|
252
|
+
handlers.send('Something else');
|
|
253
|
+
assert.equal(sent.at(-1).k, 'hub-npc-end', 'words outside the taps are not sent');
|
|
254
|
+
handlers.send('Fishing');
|
|
255
|
+
const tap = sent.at(-1);
|
|
256
|
+
assert.deepEqual([tap.k, tap.npc, tap.text, typeof tap.rid], ['hub-npc-say', 'greeter', 'Fishing', 'string']);
|
|
257
|
+
assert.equal(turns, 0, 'a fallback tap is never a mind turn');
|
|
258
|
+
hub.npcEvents.push({ k: 'hub-npc-line', npc: 'greeter', text: 'Me too.', why: 'authored', rid: tap.rid });
|
|
259
|
+
frame();
|
|
260
|
+
assert.equal(waiting, false, 'the place answered');
|
|
261
|
+
assert.deepEqual(asks, ['Gardens'], 'an answered ask is gone; the rest stay');
|
|
262
|
+
assert.equal(canType, false);
|
|
263
|
+
handlers.end();
|
|
264
|
+
// v1.153: a child's bundle chips also wait for the inspect; meanwhile the
|
|
265
|
+
// three canned lines show, answered by the place, never an empty row.
|
|
266
|
+
const canned = ['What can I do here?', 'Tell me about yourself.', 'Where should I go next?'];
|
|
267
|
+
hub.npcEvents.push({ k: 'hub-npc', npc: 'greeter', name: 'Rowan', open: true, mind: true, character: 'greeter', ageOff: true, choices: [{ id: 'hi', label: 'Hi!' }, { id: 'pets', label: 'Pets?' }, { id: 'bye', label: 'Bye!' }], fallbackChoices: canned, opening: { text: 'Hello.' } });
|
|
268
|
+
frame();
|
|
269
|
+
assert.equal(canType, false);
|
|
270
|
+
assert.deepEqual(asks, canned, 'canned lines, not an empty row');
|
|
271
|
+
clock += 1000;
|
|
272
|
+
handlers.send({ id: 'hi', label: 'Hi!' });
|
|
273
|
+
assert.equal(sent.at(-1).k, 'hub-npc-end', 'a bundle chip still waits for the inspect');
|
|
274
|
+
handlers.send(canned[0]);
|
|
275
|
+
const childTap = sent.at(-1);
|
|
276
|
+
assert.deepEqual([childTap.k, childTap.text], ['hub-npc-say', canned[0]]);
|
|
277
|
+
assert.equal(turns, 0);
|
|
278
|
+
hub.npcEvents.push({ k: 'hub-npc-line', npc: 'greeter', text: 'Look around!', why: 'authored', rid: childTap.rid });
|
|
279
|
+
frame();
|
|
280
|
+
assert.equal(waiting, false, 'the place answered the child');
|
|
281
|
+
assert.equal(lines.at(-1), 'Look around!');
|
|
282
|
+
assert.deepEqual(asks, canned, 'canned lines may be asked again');
|
|
283
|
+
assert.ok(polls.every((timer) => timer.cancelled), 'the answer cleared its wait');
|
|
284
|
+
polls.length = 0;
|
|
285
|
+
handlers.end();
|
|
246
286
|
open();
|
|
247
287
|
assert.equal(inspections, 1, 'a refusal holds the next read back');
|
|
248
288
|
handlers.end();
|
|
@@ -563,6 +603,39 @@ let n = 0;
|
|
|
563
603
|
n += 1;
|
|
564
604
|
}
|
|
565
605
|
|
|
606
|
+
// v1.204: while catching up, opening an NPC and saying a line the place
|
|
607
|
+
// answers are refused with a line, once per press, and nothing is sent.
|
|
608
|
+
{
|
|
609
|
+
const { makeTalk } = await import('../code/client/talk.js');
|
|
610
|
+
const { hub } = await import('../code/client/state.js');
|
|
611
|
+
let handlers, catching = true;
|
|
612
|
+
const refusals = [], sent = [], drafts = [];
|
|
613
|
+
const chrome = {
|
|
614
|
+
onTalk: (h) => { handlers = h; },
|
|
615
|
+
openTalk() {}, closeTalk() {}, talkAsks() {}, talkWaiting() {}, talkTyping() {}, talkLine() {},
|
|
616
|
+
talkFocused: () => false, talkPrompt() {}, talkDraft: (text) => drafts.push(text),
|
|
617
|
+
};
|
|
618
|
+
const npc = { id: 'keeper', components: { HubNpc: { name: 'Mo' }, Transform: { x: 0, z: 1 } } };
|
|
619
|
+
const scene = { actorWith: () => ({ components: { Transform: { x: 0, z: 0 } } }), getActors: () => [npc] };
|
|
620
|
+
const net = { send: (msg) => sent.push(msg) };
|
|
621
|
+
const talk = makeTalk(chrome, () => { if (!catching) {return false;} refusals.push(1); return true; });
|
|
622
|
+
talk.frame(scene, { net }, true);
|
|
623
|
+
handlers.open();
|
|
624
|
+
assert.deepEqual(sent, []); assert.equal(refusals.length, 1);
|
|
625
|
+
catching = false; handlers.open();
|
|
626
|
+
assert.deepEqual(sent, [{ k: 'hub-npc-open', npc: 'keeper' }]);
|
|
627
|
+
hub.npcEvents.push({ k: 'hub-npc', npc: 'keeper', name: 'Mo', open: true, mind: false });
|
|
628
|
+
talk.frame(scene, { net }, true);
|
|
629
|
+
catching = true; handlers.send('Hello');
|
|
630
|
+
assert.equal(sent.length, 1, 'a refused line is not sent'); assert.equal(refusals.length, 2);
|
|
631
|
+
assert.deepEqual(drafts, ['Hello'], 'typed words go back into the field');
|
|
632
|
+
catching = false; handlers.send('Hello');
|
|
633
|
+
assert.equal(sent.at(-1).k, 'hub-npc-say'); assert.equal(sent.at(-1).text, 'Hello');
|
|
634
|
+
handlers.end();
|
|
635
|
+
hub.npcEvents.length = 0;
|
|
636
|
+
n += 1;
|
|
637
|
+
}
|
|
638
|
+
|
|
566
639
|
// A new session on the same connection has no conversation with this player:
|
|
567
640
|
// the old panel closes. A stale panel instead re-attaches once, explaining
|
|
568
641
|
// a refused open before closing.
|
|
@@ -158,7 +158,7 @@ function rig(options = process.env.COMPANION_IDLE_TEST === '1' ? { idle: true }
|
|
|
158
158
|
const hub = { place: { companion: true }, companion: { c: spec, n: 1 }, glow: new Set(['p1', 'p2']) };
|
|
159
159
|
const scene = { three: { scene: root, nodes }, multiplayer: { net: { selfId: () => 'p1' }, avatars: { actors: new Map([['p2', 'other']]) } }, getActor: () => null };
|
|
160
160
|
const drawer = Companion.makeCompanion(options);
|
|
161
|
-
const frame = (now = 0, visible = true, busy = false) => drawer.frame(scene, local, hub, 0.05, now, visible, null, busy);
|
|
161
|
+
const frame = (now = 0, visible = true, busy = false, low = false) => drawer.frame(scene, local, hub, 0.05, now, visible, null, busy, null, low);
|
|
162
162
|
const labels = (now = 0) => drawer.labels({}, {}, (cam, x, y, z) => ({ x, y, z }), now);
|
|
163
163
|
return { scene, local, own, other, root, hub, drawer, frame, labels };
|
|
164
164
|
}
|
|
@@ -182,25 +182,60 @@ test('followTarget: facing-relative rest, feet height, point direction and half-
|
|
|
182
182
|
near(Companion.followTarget(player, null, 2).y, 1.75);
|
|
183
183
|
assert.deepEqual(Companion.followTarget(player, { x: 2, z: 3 }, 0), Companion.followTarget(player, null, 0));
|
|
184
184
|
});
|
|
185
|
-
test('chat target
|
|
185
|
+
test('chat target holds Chirp between camera and player sized to the screen, faces the lens, lifts above a panel and exits to follow', () => {
|
|
186
186
|
const player = { x: 2, y: 1, z: 3, yaw: 0 };
|
|
187
|
+
const size = Companion.build('bird').userData.size;
|
|
187
188
|
const camera = { forward: { x: 0, z: -1 }, position: { x: 2, y: 2, z: 8 } };
|
|
188
|
-
const target = Companion.chatTarget(player, camera, 0);
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
near(
|
|
192
|
-
|
|
193
|
-
|
|
189
|
+
const target = Companion.chatTarget(player, camera, 0, undefined, undefined, undefined, size);
|
|
190
|
+
// On the sightline from the lens to the face (y 1.85), short of the player.
|
|
191
|
+
near(target.x, 2); assert(target.z > 3.9 && target.z < 8 - 0.9, `${target.z}`);
|
|
192
|
+
near((target.y - 2) / (target.z - 8), (1.85 - 2) / (3 - 8)); near(target.yaw, 0);
|
|
193
|
+
// The old spot 1.3 m past the player is gone at every orbit distance: the
|
|
194
|
+
// bird's paper fills CHAT_SHARE of view height at a phone and a tablet orbit.
|
|
195
|
+
const face = new THREE.Vector3(0, 1.85, 0);
|
|
196
|
+
const at = {};
|
|
197
|
+
for (const [name, orbit] of [['phone', 6], ['tablet', 11]]) {
|
|
198
|
+
const lens = new THREE.PerspectiveCamera(70, 412 / 870, 0.1, 100);
|
|
199
|
+
lens.position.copy(face).add(new THREE.Vector3(0, Math.sin(Math.PI / 7), Math.cos(Math.PI / 7)).multiplyScalar(orbit));
|
|
200
|
+
lens.lookAt(face); lens.updateMatrixWorld(true);
|
|
201
|
+
const input = { position: lens.position, forward: lens.getWorldDirection(new THREE.Vector3()), fov: lens.fov, near: lens.near };
|
|
202
|
+
const spot = Companion.chatTarget({ x: 0, y: 1, z: 0 }, input, 0, undefined, undefined, undefined, size);
|
|
203
|
+
const offset = new THREE.Vector3(spot.x, spot.y, spot.z).sub(lens.position);
|
|
204
|
+
const along = offset.dot(face.clone().sub(lens.position)) / face.distanceToSquared(lens.position);
|
|
205
|
+
assert(along > 0 && along < 1, `${name} between camera and player`);
|
|
206
|
+
assert(offset.length() >= 0.9, `${name} clear of the camera`);
|
|
207
|
+
assert(Math.hypot(spot.x, spot.z) >= 0.9, `${name} clear of the player`);
|
|
208
|
+
const depth = offset.dot(input.forward);
|
|
209
|
+
assert(Math.abs(size / (2 * depth * Math.tan(lens.fov * Math.PI / 360)) - Companion.CHAT_SHARE) < 1e-9, `${name} screen share`);
|
|
210
|
+
const ndc = (y) => new THREE.Vector3(spot.x, spot.y + y, spot.z).project(lens).y;
|
|
211
|
+
assert(Math.abs((ndc(size / 2) - ndc(-size / 2)) / 2 - Companion.CHAT_SHARE) < 0.02, `${name} projected share`);
|
|
212
|
+
near(spot.yaw, Math.atan2(lens.position.x - spot.x, lens.position.z - spot.z));
|
|
213
|
+
at[name] = offset.length();
|
|
214
|
+
}
|
|
215
|
+
near(at.phone, at.tablet);
|
|
216
|
+
// Far from the lens the depth stops 0.9 m short of the player; a camera too
|
|
217
|
+
// tight behind them for both clearances keeps the old spot past them.
|
|
218
|
+
const owl = Companion.chatTarget(player, camera, 0, undefined, undefined, undefined, 40);
|
|
219
|
+
near(owl.z, 3.9);
|
|
220
|
+
const tightCamera = { ...camera, position: { x: 2, y: 2, z: 4.6 } };
|
|
221
|
+
assert.deepEqual(Companion.chatTarget(player, tightCamera, 0, undefined, undefined, undefined, size), Companion.frontTarget(player, tightCamera, 0));
|
|
222
|
+
const panel = { left: 0, right: 360, top: 400, bottom: 668 }, view = { w: 360, h: 668 };
|
|
223
|
+
const lifted = Companion.chatTarget(player, camera, 0, panel, view, (p) => ({ x: 180, y: 450 - (p.y - target.y) * 200 }), size);
|
|
224
|
+
near(lifted.y, target.y + 0.4); near(lifted.z, target.z);
|
|
225
|
+
const offscreen = Companion.chatTarget(player, camera, 0, null, view, (p) => ({ x: 180, y: 700 - (p.y - target.y) * 200 }), size);
|
|
226
|
+
near(offscreen.y, target.y + 0.4);
|
|
194
227
|
// Every lift covered (a far orbit): the highest on-screen candidate, never the last one tried.
|
|
195
|
-
const covered = Companion.chatTarget(player, camera, 0,
|
|
196
|
-
near(covered.y,
|
|
228
|
+
const covered = Companion.chatTarget(player, camera, 0, panel, view, (p) => ({ x: 180, y: 600 - (p.y - target.y) * 20 }), size);
|
|
229
|
+
near(covered.y, target.y + 2);
|
|
230
|
+
// A camera in front of the player looking away keeps the bird ahead of the lens.
|
|
197
231
|
const over = { ...camera, position: { x: 2, y: 2.8, z: 1.7 } };
|
|
198
|
-
const raisedSafe = Companion.chatTarget(player, over, 0,
|
|
232
|
+
const raisedSafe = Companion.chatTarget(player, over, 0, panel, view, (p) => ({ x: 180, y: 450 - (p.y - 1.85) * 200 }), size);
|
|
199
233
|
assert(Math.hypot(raisedSafe.x - over.position.x, raisedSafe.y - over.position.y, raisedSafe.z - over.position.z) >= 0.9);
|
|
200
|
-
|
|
201
|
-
|
|
234
|
+
// Without a camera position: the nominal 6 m orbit behind the camera forward.
|
|
235
|
+
const rotated = Companion.chatTarget(player, { forward: { x: 1, z: 0 } }, 0, undefined, undefined, undefined, size);
|
|
236
|
+
assert(rotated.x > -4 + 0.9 && rotated.x < 2 - 0.9, `${rotated.x}`); near(rotated.z, 3); near(rotated.yaw, -Math.PI / 2);
|
|
202
237
|
const closeCamera = { ...camera, position: { x: 2, y: 1.85, z: 1.7 } };
|
|
203
|
-
const safe = Companion.chatTarget(player, closeCamera, 0);
|
|
238
|
+
const safe = Companion.chatTarget(player, closeCamera, 0, undefined, undefined, undefined, size);
|
|
204
239
|
assert(Math.hypot(safe.x - closeCamera.position.x, safe.y - closeCamera.position.y, safe.z - closeCamera.position.z) >= 0.9);
|
|
205
240
|
assert(Math.hypot(safe.x - player.x, safe.z - player.z) >= 0.9);
|
|
206
241
|
assert.deepEqual(Companion.motionTarget(player, null, 0, false, null), Companion.followTarget(player, null, 0));
|
|
@@ -212,9 +247,10 @@ test('chat holds through 30 s and 3 min away, then smoothly follows when closed'
|
|
|
212
247
|
const frame = (now, talking) => r.drawer.frame(r.scene, r.local, r.hub, 0.05, now, true, talking ? chat : null);
|
|
213
248
|
frame(0, true); frame(away, true);
|
|
214
249
|
const bird = r.root.children.find((n) => n.name === 'companion:bird');
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
frame(away
|
|
250
|
+
const spot = Companion.chatTarget({ x: 2, y: 1, z: 3, yaw: 0 }, chat.camera, 0, undefined, undefined, undefined, bird.userData.size).z;
|
|
251
|
+
near(bird.position.z, spot); near(bird.rotation.y, 0);
|
|
252
|
+
frame(away + 50, false); assert(bird.position.z < spot && bird.position.z > 2.65);
|
|
253
|
+
frame(away * 2, false); assert(bird.position.z < spot);
|
|
218
254
|
r.drawer.dispose();
|
|
219
255
|
}
|
|
220
256
|
});
|
|
@@ -318,6 +354,13 @@ function modelView(bird, cam) {
|
|
|
318
354
|
});
|
|
319
355
|
return { share: (top - bottom) / 2, depth, left: (left + 1) / 2, right: (right + 1) / 2, top: (1 - top) / 2, bottom: (1 - bottom) / 2, x: (left + right + 2) / 4, y: (2 - top - bottom) / 4 };
|
|
320
356
|
}
|
|
357
|
+
// The player's left side on screen (0..1): its centre less a 0.4 m half-width
|
|
358
|
+
// along the camera's right axis, as the show fit measures it.
|
|
359
|
+
function playerLeftScreen(player, cam) {
|
|
360
|
+
const right = new THREE.Vector3(1, 0, 0).applyQuaternion(cam.quaternion);
|
|
361
|
+
const side = new THREE.Vector3(player.x, player.y, player.z).addScaledVector(right, -0.4).project(cam);
|
|
362
|
+
return (side.x + 1) / 2;
|
|
363
|
+
}
|
|
321
364
|
function assertShowAngle(bird, cam, seconds) {
|
|
322
365
|
const localCamera = new THREE.Vector3(0, 0, 1).applyQuaternion(cam.quaternion).applyQuaternion(bird.quaternion.clone().invert());
|
|
323
366
|
const yaw = Math.atan2(localCamera.x, localCamera.z) * 180 / Math.PI;
|
|
@@ -418,6 +461,8 @@ test('town camera shows actual geometry at one third height and completes show f
|
|
|
418
461
|
if (!landscape) {
|
|
419
462
|
const playerScreen = new THREE.Vector3(player.x, player.y, player.z).project(cam);
|
|
420
463
|
assert(box.right <= (playerScreen.x + 1) / 2 - 0.02, `${species}: fitted box clears the player centre`);
|
|
464
|
+
} else {
|
|
465
|
+
assert(box.right <= playerLeftScreen(player, cam) - 0.02, `${species}: landscape box clears the player's left side`);
|
|
421
466
|
}
|
|
422
467
|
assertShowAngle(bird, cam, 1.6);
|
|
423
468
|
assertScreenUp(bird, cam);
|
|
@@ -453,6 +498,8 @@ test('town camera shows actual geometry at one third height and completes show f
|
|
|
453
498
|
if (!landscape) {
|
|
454
499
|
const playerScreen = new THREE.Vector3(player.x, player.y, player.z).project(cam);
|
|
455
500
|
assert(turnBox.right <= (playerScreen.x + 1) / 2 - 0.02, `${species}: player margin throughout the turn`);
|
|
501
|
+
} else {
|
|
502
|
+
assert(turnBox.right <= playerLeftScreen(player, cam) - 0.02, `${species}: landscape player margin throughout the turn`);
|
|
456
503
|
}
|
|
457
504
|
assertShowAngle(bird, cam, now / 1000);
|
|
458
505
|
assertScreenUp(bird, cam);
|
|
@@ -461,6 +508,49 @@ test('town camera shows actual geometry at one third height and completes show f
|
|
|
461
508
|
}
|
|
462
509
|
}
|
|
463
510
|
});
|
|
511
|
+
// From the House wardrobe (#1105): a close landscape menu shot of the player
|
|
512
|
+
// put Chirp's show spot over the player's head. In landscape the fitted box
|
|
513
|
+
// now stays left of the player's left side, with the portrait margin.
|
|
514
|
+
test('a close landscape menu camera keeps the show box off the player', () => {
|
|
515
|
+
for (const species of ['songbird', 'owl', 'parrot', 'hummingbird']) {
|
|
516
|
+
for (const [w, h] of [[844, 390], [740, 360]]) {
|
|
517
|
+
const r = rig(), player = r.local.components.Transform;
|
|
518
|
+
const cam = new THREE.PerspectiveCamera(50, w / h, 0.1, 100);
|
|
519
|
+
cam.position.set(player.x + 0.2, player.y + 1.3, player.z + 1.8); cam.lookAt(player.x, player.y + 1, player.z); cam.updateMatrixWorld(true);
|
|
520
|
+
r.scene.three.camera = cam; r.scene.cameraControl = 'fixed';
|
|
521
|
+
const dress = { species };
|
|
522
|
+
r.hub.companion = { c: { look: 'bird', dress }, n: 2 }; r.frame(0);
|
|
523
|
+
r.hub.companion = { c: { look: 'bird', dress, pose: 'show' }, n: 3 };
|
|
524
|
+
for (let now = 50; now <= 1600; now += 50) { r.frame(now); }
|
|
525
|
+
const bird = r.root.children.find((n) => n.name === 'companion:bird');
|
|
526
|
+
const box = modelView(bird, cam);
|
|
527
|
+
assert(box.right <= playerLeftScreen(player, cam) - 0.02, `${species} ${w}x${h}: box right ${box.right} clears the player's left side ${playerLeftScreen(player, cam)}`);
|
|
528
|
+
assert(box.left >= 0.04 && box.top >= 0.04 && box.bottom <= 0.96, `${species}: inside the inset ${JSON.stringify(box)}`);
|
|
529
|
+
assert(box.depth >= cam.near + 0.15);
|
|
530
|
+
r.drawer.dispose();
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
// Review: with the player's left side at or past the left inset there is no
|
|
535
|
+
// strip left of the player; the box keeps the usual spot inside the inset
|
|
536
|
+
// rather than centring on (or past) the screen's edge.
|
|
537
|
+
test('a close landscape shot with the player at the left edge keeps the show box on screen', () => {
|
|
538
|
+
for (const species of ['songbird', 'owl']) {
|
|
539
|
+
const r = rig(), player = r.local.components.Transform;
|
|
540
|
+
const cam = new THREE.PerspectiveCamera(50, 844 / 390, 0.1, 100);
|
|
541
|
+
cam.position.set(player.x + 1.6, player.y + 1.3, player.z + 1.8); cam.lookAt(player.x + 2.2, player.y + 1, player.z); cam.updateMatrixWorld(true);
|
|
542
|
+
const left = playerLeftScreen(player, cam);
|
|
543
|
+
assert(left <= 0.04, `the player's left side is at or past the inset (${left})`);
|
|
544
|
+
r.scene.three.camera = cam; r.scene.cameraControl = 'fixed';
|
|
545
|
+
r.hub.companion = { c: { look: 'bird', dress: { species } }, n: 2 }; r.frame(0);
|
|
546
|
+
r.hub.companion = { c: { look: 'bird', dress: { species }, pose: 'show' }, n: 3 };
|
|
547
|
+
for (let now = 50; now <= 2400; now += 50) { r.frame(now); }
|
|
548
|
+
const box = modelView(r.root.children.find((n) => n.name === 'companion:bird'), cam);
|
|
549
|
+
assert(box.left >= 0.04 && box.right <= 0.96 && box.top >= 0.04 && box.bottom <= 0.96, `${species}: inside the inset ${JSON.stringify(box)}`);
|
|
550
|
+
assert(Math.abs(box.x - 0.35) < 0.015, `${species}: the usual landscape spot, ${box.x}`);
|
|
551
|
+
r.drawer.dispose();
|
|
552
|
+
}
|
|
553
|
+
});
|
|
464
554
|
test('show restores quiet tophat to full scale and opaque paper on its first approach frame, including the orbit lens first frame', () => {
|
|
465
555
|
for (const fov of [undefined, 90]) {
|
|
466
556
|
const r = rig(), player = r.local.components.Transform;
|
|
@@ -794,8 +884,9 @@ test('walk-away within the target leash aborts once, and any chat returns home b
|
|
|
794
884
|
const chat = { camera: { forward: { x: 0, z: -1 } } };
|
|
795
885
|
r.drawer.frame(r.scene, r.local, r.hub, 0.05, 2050, true, chat);
|
|
796
886
|
for (let now = 2100; now <= 4000; now += 50) r.drawer.frame(r.scene, r.local, r.hub, 0.05, now, true, chat);
|
|
797
|
-
|
|
798
|
-
|
|
887
|
+
const spot = Companion.chatTarget({ x: 2, y: 1, z: 3, yaw: 0 }, chat.camera, 0, undefined, undefined, undefined, bird.userData.size).z;
|
|
888
|
+
assert(Math.abs(bird.position.z - spot) < 0.05); assert(Math.abs(bird.rotation.y) < 0.01);
|
|
889
|
+
r.frame(4050); const chatSpot = bird.position.clone(); assert(Math.abs(chatSpot.z - spot) < 0.5, 'new lead starts from the chat spot');
|
|
799
890
|
for (let now = 4100; now <= 7600; now += 50) { r.local.components.Transform.x += 0.1; r.frame(now); }
|
|
800
891
|
const player = r.local.components.Transform;
|
|
801
892
|
for (let now = 7650; now <= 10_000; now += 50) r.frame(now);
|
|
@@ -968,6 +1059,93 @@ test('glows skip self, follow/rebuild avatar nodes, hide on trips; absent local
|
|
|
968
1059
|
r.hub.glow.clear(); r.frame(250); assert.equal(replacement.children.length, 0);
|
|
969
1060
|
r.drawer.clear();
|
|
970
1061
|
});
|
|
1062
|
+
|
|
1063
|
+
test('v1.181 hubChirp parses dress tuples, latches deltas and clears with place/session', () => {
|
|
1064
|
+
State.clear();
|
|
1065
|
+
assert(!Object.hasOwn(State.hub, 'chirp'));
|
|
1066
|
+
hook.state({}, { hubPlace: { id: 'main', companion: true }, hubChirp: [
|
|
1067
|
+
['p1', null, null, null], ['p2', 'owl', 'tophat', 'mint'],
|
|
1068
|
+
['bad', 'unknown', null, null], ['bad2', null, 'typed', null],
|
|
1069
|
+
['bad3', null, null, 'unknown'], ['bad4', null, null, null, 'words'],
|
|
1070
|
+
['bad5', undefined, null, null], null,
|
|
1071
|
+
] });
|
|
1072
|
+
assert.deepEqual(State.hub.chirp, new Map([['p1', {}], ['p2', { species: 'owl', wear: 'tophat', tint: 'mint' }]]));
|
|
1073
|
+
hook.state({}, { hubGlow: ['p1', 'p2'] });
|
|
1074
|
+
assert.equal(State.hub.chirp.size, 2, 'absent delta key retains the whole block');
|
|
1075
|
+
hook.state({}, { hubChirp: [] }); assert.equal(State.hub.chirp.size, 0);
|
|
1076
|
+
hook.state({}, { hubChirp: [['p2', null, null, null]] });
|
|
1077
|
+
hook.state({}, { hubPlace: { id: 'main', companion: true } }); assert(!Object.hasOwn(State.hub, 'chirp'));
|
|
1078
|
+
hook.state({}, { hubChirp: [['p2', null, null, null]] });
|
|
1079
|
+
hook.state({}, { hubPlace: { id: 'plain' }, hubChirp: [['p2', null, null, null]] });
|
|
1080
|
+
assert(!Object.hasOwn(State.hub, 'chirp'));
|
|
1081
|
+
hook.state({}, { hubPlace: { id: 'main', companion: true }, hubChirp: [['p2', null, null, null]] });
|
|
1082
|
+
State.clear(); assert(!Object.hasOwn(State.hub, 'chirp'));
|
|
1083
|
+
});
|
|
1084
|
+
test('v1.181 others draw dressed birds at the shoulder; owner keeps full private follower', () => {
|
|
1085
|
+
for (const species of ['songbird', 'owl', 'parrot', 'hummingbird']) {
|
|
1086
|
+
const r = rig();
|
|
1087
|
+
r.hub.companion = { c: { look: 'bird', shown: true, dress: { species, tint: 'rose', wear: 'bow' }, say: 'Only me' }, n: 2 };
|
|
1088
|
+
r.frame();
|
|
1089
|
+
const own = r.root.children.find(n => n.name === 'companion:bird');
|
|
1090
|
+
const position = own.position.clone(), scale = own.scale.clone();
|
|
1091
|
+
r.hub.chirp = Companion.chirpMap([['p1', species, 'bow', 'rose'], ['p2', species, 'tophat', 'mint']]);
|
|
1092
|
+
r.frame();
|
|
1093
|
+
assert.equal(r.root.children.find(n => n.name === 'companion:bird'), own);
|
|
1094
|
+
assert(own.position.equals(position)); assert(own.scale.equals(scale));
|
|
1095
|
+
assert.equal(r.own.children.length, 0, 'no duplicate on self shoulder');
|
|
1096
|
+
const bird = r.other.children[0];
|
|
1097
|
+
assert.equal(bird.name, 'companion:bird'); assert.equal(r.other.children.length, 1, 'replaces the bare glow');
|
|
1098
|
+
near(bird.position.x, 0.4); near(bird.position.y, 0.75); near(bird.position.z, 0);
|
|
1099
|
+
assert(bird.scale.x < own.scale.x); assert(bird.getObjectByName('companion:wear:tophat'));
|
|
1100
|
+
const paper = [];
|
|
1101
|
+
bird.traverse(n => { if (n.material?.color.getHexString() === '87d8b0') paper.push(n); });
|
|
1102
|
+
assert(paper.length > 0, 'remote paper takes the public tint');
|
|
1103
|
+
assert.deepEqual(r.labels()[0].text, 'Only me'); assert.equal(r.labels().length, 1);
|
|
1104
|
+
let geometries = 0, materials = 0, disposedGeometry = 0, disposedMaterial = 0;
|
|
1105
|
+
bird.traverse(n => {
|
|
1106
|
+
if (n.geometry) { geometries++; n.geometry.addEventListener('dispose', () => disposedGeometry++); }
|
|
1107
|
+
if (n.material) { materials++; n.material.addEventListener('dispose', () => disposedMaterial++); }
|
|
1108
|
+
});
|
|
1109
|
+
r.hub.chirp = Companion.chirpMap([['p2', 'parrot', 'scarf', 'gold']]); r.frame(50);
|
|
1110
|
+
assert.equal(disposedGeometry, geometries); assert.equal(disposedMaterial, materials);
|
|
1111
|
+
assert(!bird.parent); assert(r.other.children[0].getObjectByName('companion:wear:scarf'));
|
|
1112
|
+
r.hub.chirp.clear(); r.frame(100); assert(r.other.children[0].isMesh, 'unshown follower returns to bare glow');
|
|
1113
|
+
r.hub.glow.clear(); r.frame(150); assert.equal(r.other.children.length, 0);
|
|
1114
|
+
r.drawer.dispose();
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
test('v1.181 Low uses a tint-coloured glow, restores paper on High and disposes each replacement', () => {
|
|
1118
|
+
const r = rig(); r.hub.chirp = Companion.chirpMap([['p2', 'owl', 'tophat', 'midnight']]); r.frame();
|
|
1119
|
+
const bird = r.other.children[0]; let disposed = 0;
|
|
1120
|
+
bird.traverse(n => n.geometry?.addEventListener('dispose', () => disposed++));
|
|
1121
|
+
r.frame(50, true, false, true);
|
|
1122
|
+
assert(disposed > 0); assert(!bird.parent);
|
|
1123
|
+
const glow = r.other.children[0]; assert(glow.isMesh); assert.equal(glow.geometry.type, 'OctahedronGeometry');
|
|
1124
|
+
assert.equal(glow.material.color.getHexString(), '39436b');
|
|
1125
|
+
let glowDisposed = 0; glow.material.addEventListener('dispose', () => glowDisposed++);
|
|
1126
|
+
r.frame(100); assert.equal(glowDisposed, 1); assert.equal(r.other.children[0].name, 'companion:bird');
|
|
1127
|
+
r.hub.chirp = Companion.chirpMap([['p2', null, null, null]]); r.frame(150, true, false, true);
|
|
1128
|
+
assert.equal(r.other.children[0].material.color.getHexString(), 'ffd27a');
|
|
1129
|
+
r.drawer.dispose(); assert.equal(r.other.children.length, 0);
|
|
1130
|
+
});
|
|
1131
|
+
test('v1.181 birds hide with the drawn avatar and disappear for a blocked pair, including stale nodes', () => {
|
|
1132
|
+
State.clear();
|
|
1133
|
+
const r = rig(); r.hub.chirp = Companion.chirpMap([['p2', 'owl', 'bow', 'rose']]); r.frame();
|
|
1134
|
+
const bird = r.other.children[0];
|
|
1135
|
+
r.other.visible = false; r.frame(50);
|
|
1136
|
+
assert.equal(bird.parent.visible, false, 'avatar visibility hides its child bird');
|
|
1137
|
+
r.other.visible = true; r.frame(100, false); assert.equal(bird.visible, false, 'trip hides the bird');
|
|
1138
|
+
r.frame(150); assert.equal(bird.visible, true);
|
|
1139
|
+
// A blocked pair is omitted from this viewer's avatar map. Even a fading
|
|
1140
|
+
// old body must not retain its bird; unaffected viewers retain theirs.
|
|
1141
|
+
hook.state({}, { hubPlace: { id: 'main', companion: true }, hubAv: { p1: 0 }, hubChirp: [['p2', 'owl', 'bow', 'rose']] });
|
|
1142
|
+
r.hub.avatars = State.hub.avatars; r.hub.chirp = State.hub.chirp; r.frame(200);
|
|
1143
|
+
assert.equal(hook.avatar('p2', 'Blocked'), null); assert.equal(r.other.children.length, 0);
|
|
1144
|
+
hook.state({}, { hubAv: { p1: 0, p2: 0 } }); r.hub.avatars = State.hub.avatars; r.frame(250);
|
|
1145
|
+
assert.equal(r.other.children[0].name, 'companion:bird');
|
|
1146
|
+
r.scene.multiplayer.avatars.actors.delete('p2'); r.frame(300); assert.equal(r.other.children.length, 0);
|
|
1147
|
+
r.drawer.dispose(); State.clear();
|
|
1148
|
+
});
|
|
971
1149
|
test('unknown point is ignored, known point faces the bird; clearing disposes both looks', () => {
|
|
972
1150
|
const r = rig(); r.hub.companion.c = { ...spec, look: 'bird' }; r.frame();
|
|
973
1151
|
const bird = r.root.children.find((n) => n.name === 'companion:bird');
|
|
@@ -980,13 +1158,13 @@ test('unknown point is ignored, known point faces the bird; clearing disposes bo
|
|
|
980
1158
|
});
|
|
981
1159
|
test('rehello drops stale private follower; avatar hello keeps it; new identity clears all', () => {
|
|
982
1160
|
let system; installSystem({ registerSystem(value) { system = value; } });
|
|
983
|
-
State.clear(); State.hub.place = { companion: true }; State.hub.companion = { c: spec, n: 1 }; State.hub.glow = new Set(['p1']);
|
|
1161
|
+
State.clear(); State.hub.place = { companion: true }; State.hub.companion = { c: spec, n: 1 }; State.hub.glow = new Set(['p1']); State.hub.chirp = new Map([['p1', {}]]);
|
|
984
1162
|
const scene = { persistent: {} }, sent = []; let playerId = 'p1';
|
|
985
1163
|
const net = { selfId: () => playerId, send: (msg) => sent.push(msg), drain: () => [] }, mp = { net };
|
|
986
1164
|
system.sendHello(scene, mp, net, 0, { again: true }); assert.deepEqual(State.hub.companion, { c: spec, n: 1 });
|
|
987
1165
|
system.sendHello(scene, mp, net, 0, { resume: true }); assert(!Object.hasOwn(State.hub, 'companion')); assert.equal(sent.at(-1).resume, true);
|
|
988
1166
|
hook.message({}, { k: 'hub-companion', c: spec, n: 1 });
|
|
989
|
-
playerId = 'p2'; net.drain(); assert(!Object.hasOwn(State.hub, 'companion')); assert(!Object.hasOwn(State.hub, 'glow'));
|
|
1167
|
+
playerId = 'p2'; net.drain(); assert(!Object.hasOwn(State.hub, 'chirp')); assert(!Object.hasOwn(State.hub, 'companion')); assert(!Object.hasOwn(State.hub, 'glow'));
|
|
990
1168
|
});
|
|
991
1169
|
test('same-id rehello asks the open talk panel to reattach after sending hello', () => {
|
|
992
1170
|
let system; installSystem({ registerSystem(value) { system = value; } });
|
|
@@ -1024,6 +1202,10 @@ test('system keyless frame creates nothing; opt-in creates drawer and removal di
|
|
|
1024
1202
|
system.talk.talkingWith = () => 'rowan'; system.afterBehaviors(scene, 0.05); assert.equal(busy.at(-1), false);
|
|
1025
1203
|
system.companionTappedUntil = performance.now() + 3000; system.afterBehaviors(scene, 0.05); assert.equal(busy.at(-1), true);
|
|
1026
1204
|
system.companionTappedUntil = -Infinity; system.afterBehaviors(scene, 0.05); assert.equal(busy.at(-1), false);
|
|
1205
|
+
const low = []; system.companion.frame = (...args) => low.push(args[9]);
|
|
1206
|
+
system.lowTier = true; system.afterBehaviors(scene, 0.05); assert.equal(low.at(-1), true);
|
|
1207
|
+
system.lowTier = false; system.afterBehaviors(scene, 0.05); assert.equal(low.at(-1), false);
|
|
1208
|
+
delete system.lowTier;
|
|
1027
1209
|
hook.state({}, { hubPlace: { id: 'main' } }); system.afterBehaviors(scene, 0.05); assert(!Object.hasOwn(system, 'companion'));
|
|
1028
1210
|
assert(!Object.hasOwn(system, 'companionTappedUntil'));
|
|
1029
1211
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// v1.71 companion: real place hooks, private delivery and public presence.
|
|
2
2
|
import assert from 'node:assert/strict';
|
|
3
3
|
import { register } from 'node:module';
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
4
5
|
|
|
5
6
|
register(`data:text/javascript,${encodeURIComponent(`
|
|
6
7
|
import { readFile } from 'node:fs/promises';
|
|
@@ -9,7 +10,7 @@ register(`data:text/javascript,${encodeURIComponent(`
|
|
|
9
10
|
if (url.endsWith('/code/server/hub.js?without-companion')) {
|
|
10
11
|
let source = await readFile(fileURLToPath(url), 'utf8');
|
|
11
12
|
source = source.split('\\n').filter((line) => !line.includes('import * as Companion') && !line.includes('...(' + 'h.place.companion')).join('\\n');
|
|
12
|
-
source = source.replace(/\\s*if \\(h.place.companion === true(?: && h.
|
|
13
|
+
source = source.replace(/\\s*if \\(h.place.companion === true(?: && h.companion(?:Shown)?Used)?\\) \\{[^{}]*\\}(?: else \\{[^{}]*\\})?/g, '');
|
|
13
14
|
if (source.includes('Companion.')) throw new Error('baseline still has a companion code path');
|
|
14
15
|
return { format: 'module', source, shortCircuit: true };
|
|
15
16
|
}
|
|
@@ -48,7 +49,7 @@ function boot(keys = {}, options = {}) {
|
|
|
48
49
|
removeActor(sim, id) { sim.bodies.delete(id); sim.objects.delete(id); },
|
|
49
50
|
};
|
|
50
51
|
globalThis.__hubTestActors = structuredClone(actors);
|
|
51
|
-
const server = (options.layer ?? layer)(json(keys), hooks, {}, () => true, () => null, null, engine);
|
|
52
|
+
const server = (options.layer ?? layer)(json({ ...(options.title ? { title: options.title } : {}), ...keys }), hooks, {}, () => true, () => null, null, engine);
|
|
52
53
|
const session = { sessionId: options.sessionId ?? 'dev', players: [...players], hub: options.platform ?? null, send(id, msg) { sent.push([id, structuredClone(msg)]); }, broadcast(msg) { sent.push(['all', structuredClone(msg)]); } };
|
|
53
54
|
const world = { timeMs: 0, scenePath: 'scenes/main.scene', objects: new Map(), bodies: new Map(), players: new Map(players.map((p) => [p.playerId, { at: { x: 0, y: 1, z: 0 }, facing: 0, body: { setTranslation() {} } }])) };
|
|
54
55
|
server.sceneFor(session);
|
|
@@ -116,6 +117,112 @@ await test('v1.78 show pose validates privately and absent pose preserves litera
|
|
|
116
117
|
assert.throws(() => r.hub.companion('p1', { look: 'bird', pose: 'bad' }), TypeError);
|
|
117
118
|
assert.deepEqual(offer(r).c, { look: 'bird', pose: 'show' });
|
|
118
119
|
});
|
|
120
|
+
|
|
121
|
+
await test('v1.181 shown is bird-only, true-only, copied and read once', async () => {
|
|
122
|
+
const { check } = await import('../code/companionSpec.js');
|
|
123
|
+
assert.deepEqual(check({ look: 'bird', shown: true }), { look: 'bird', shown: true });
|
|
124
|
+
for (const shown of [undefined, null, false, 0, 1, '', 'true', [], {}]) {
|
|
125
|
+
assert.throws(() => check({ look: 'bird', shown }), TypeError);
|
|
126
|
+
}
|
|
127
|
+
assert.throws(() => check({ look: 'lantern', shown: true }), TypeError);
|
|
128
|
+
let reads = 0;
|
|
129
|
+
check({ look: 'bird', get shown() { reads++; return true; } });
|
|
130
|
+
assert.equal(reads, 1);
|
|
131
|
+
assert.deepEqual(check(Object.assign(Object.create(null), { look: 'bird', shown: true })), { look: 'bird', shown: true });
|
|
132
|
+
const r = boot({ companion: true });
|
|
133
|
+
assert.equal(r.hub.companionShown, true);
|
|
134
|
+
assert(!Object.hasOwn(boot().hub, 'companionShown'));
|
|
135
|
+
const c = { look: 'bird', shown: true, dress: { species: 'owl', wear: 'bow', tint: 'mint' } };
|
|
136
|
+
r.hub.companion('p1', c); c.dress.tint = 'rose'; r.tick(250);
|
|
137
|
+
for (const bad of [false, undefined, null]) {
|
|
138
|
+
assert.throws(() => r.hub.companion('p1', { look: 'bird', shown: bad }), TypeError);
|
|
139
|
+
}
|
|
140
|
+
assert.deepEqual(r.server.join().hubChirp, [['p1', 'owl', 'bow', 'mint']]);
|
|
141
|
+
assert.deepEqual(offer(r).c, { look: 'bird', dress: { species: 'owl', wear: 'bow', tint: 'mint' } });
|
|
142
|
+
assert(!Object.hasOwn(offer(r).c, 'shown'), 'old clients receive the same private spec shape');
|
|
143
|
+
const flags = r.server.join().hubPlace;
|
|
144
|
+
assert(!Object.hasOwn(flags, 'companionShown'));
|
|
145
|
+
});
|
|
146
|
+
await test('v1.181 public dress sorts, latches, coalesces at four/s and never carries private fields', () => {
|
|
147
|
+
const r = boot({ companion: true });
|
|
148
|
+
assert(!Object.hasOwn(r.server.join(), 'hubChirp'));
|
|
149
|
+
assert(!Object.hasOwn(r.server.delta(), 'hubChirp'));
|
|
150
|
+
r.hub.companion('p2', { look: 'bird', shown: true });
|
|
151
|
+
r.hub.companion('p1', { look: 'bird', shown: true, dress: { species: 'owl', wear: 'bow', tint: 'mint' }, say: 'private words', at: 'private-target', pose: 'show' });
|
|
152
|
+
r.tick(250);
|
|
153
|
+
const rows = [['p1', 'owl', 'bow', 'mint'], ['p2', null, null, null]];
|
|
154
|
+
assert.deepEqual(r.server.join().hubChirp, rows);
|
|
155
|
+
assert.deepEqual(r.server.delta().hubChirp, rows);
|
|
156
|
+
assert.equal(r.server.delta(), null);
|
|
157
|
+
// Words, pose and target may change privately without a public delta.
|
|
158
|
+
r.hub.companion('p1', { look: 'bird', shown: true, dress: { species: 'owl', wear: 'bow', tint: 'mint' } }); r.tick(250);
|
|
159
|
+
assert.equal(r.server.delta(), null);
|
|
160
|
+
for (let i = 0; i < 24; i++) {
|
|
161
|
+
r.hub.companion('p1', { look: 'bird', shown: true, dress: { tint: i % 2 ? 'gold' : 'rose' } });
|
|
162
|
+
r.tick(10);
|
|
163
|
+
assert.equal(r.server.delta(), null);
|
|
164
|
+
assert.deepEqual(r.server.join().hubChirp, rows);
|
|
165
|
+
}
|
|
166
|
+
r.tick(10);
|
|
167
|
+
assert.deepEqual(r.server.delta().hubChirp, [['p1', null, null, 'gold'], rows[1]]);
|
|
168
|
+
assert.equal(r.server.delta(), null);
|
|
169
|
+
// An unsent intermediate dress never becomes public.
|
|
170
|
+
r.hub.companion('p1', { look: 'bird', shown: true, dress: { tint: 'rose' } });
|
|
171
|
+
r.hub.companion('p1', { look: 'bird', shown: true, dress: { tint: 'gold' } }); r.tick(250);
|
|
172
|
+
assert.equal(r.server.delta(), null);
|
|
173
|
+
r.hub.companion('p1', { look: 'bird' }); r.tick(250);
|
|
174
|
+
assert.deepEqual(r.server.delta().hubChirp, [rows[1]]);
|
|
175
|
+
r.hub.companion('p2', null); r.tick(250);
|
|
176
|
+
assert.deepEqual(r.server.join().hubChirp, []);
|
|
177
|
+
assert.deepEqual(r.server.delta().hubChirp, []);
|
|
178
|
+
assert.equal(r.server.delta(), null);
|
|
179
|
+
});
|
|
180
|
+
await test('v1.181 shown is cleared on leave, end and shutdown; empty snapshots stay latched', async () => {
|
|
181
|
+
for (const end of ['leave', 'end', 'shutdown']) {
|
|
182
|
+
const r = boot({ companion: true });
|
|
183
|
+
r.hub.companion('p1', { look: 'bird', shown: true }); r.tick(250); r.server.delta();
|
|
184
|
+
if (end === 'leave') { r.session.players = [players[1]]; r.world.players.delete('p1'); r.tick(); }
|
|
185
|
+
if (end === 'end') { r.hub.end(['p1']); r.tick(); }
|
|
186
|
+
if (end === 'shutdown') { await r.server.shutdown(); }
|
|
187
|
+
assert.deepEqual(r.server.join().hubChirp, []);
|
|
188
|
+
assert.deepEqual(r.server.delta().hubChirp, []);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
await test('v1.181 resumePose replays shown to the same account and clears it for another', () => {
|
|
192
|
+
for (const changed of [false, true]) {
|
|
193
|
+
const r = boot({ companion: true, resumePose: true });
|
|
194
|
+
r.hub.companion('p1', { look: 'bird', shown: true, dress: { species: 'owl' } }); r.tick(250); r.server.delta();
|
|
195
|
+
const body = r.world.players.get('p1');
|
|
196
|
+
r.session.players = [players[1]]; r.world.players.delete('p1'); r.tick(30000);
|
|
197
|
+
assert.deepEqual(r.server.delta().hubChirp, []);
|
|
198
|
+
assert.equal(r.hub.companion('p1', { look: 'bird', shown: true, dress: { tint: 'mint' } }), true);
|
|
199
|
+
r.tick(30000);
|
|
200
|
+
assert.deepEqual(r.server.join().hubChirp, []);
|
|
201
|
+
const returning = { ...players[0], ...(changed ? { userId: '999', username: 'Other' } : {}) };
|
|
202
|
+
r.session.players.push(returning); r.world.players.set('p1', body); r.sent.length = 0;
|
|
203
|
+
r.say('p1', { k: 'hub-hello', resume: true }); r.tick();
|
|
204
|
+
assert.deepEqual(offer(r).c, changed ? null : { look: 'bird', dress: { tint: 'mint' } });
|
|
205
|
+
assert.deepEqual(r.server.join().hubChirp, changed ? [] : [['p1', null, null, 'mint']]);
|
|
206
|
+
if (!changed) {
|
|
207
|
+
r.session.players[r.session.players.findIndex(p => p.playerId === 'p1')] = { ...returning, userId: '999' };
|
|
208
|
+
r.tick(); assert.deepEqual(r.server.join().hubChirp, []);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
await test('v1.181 absent shown preserves the literal pre-existing follower wire fixture', () => {
|
|
213
|
+
const captured = readFileSync(new URL('./companion-follower-wire.json', import.meta.url), 'utf8').trim();
|
|
214
|
+
for (const dress of [undefined, {}, { species: 'songbird' }]) {
|
|
215
|
+
const r = boot({ companion: true }, { title: 'Town' });
|
|
216
|
+
const states = [r.server.join(), r.server.delta()];
|
|
217
|
+
r.hub.companion('p1', { look: 'bird', say: 'Follow me', ...(dress ? { dress } : {}) }); r.tick(250);
|
|
218
|
+
states.push(r.server.join(), r.server.delta());
|
|
219
|
+
r.say('p1', { k: 'hub-npc-open', npc: 'companion:p1' });
|
|
220
|
+
r.say('p1', { k: 'hub-npc-say', npc: 'companion:p1', text: 'question' }); r.tick(250);
|
|
221
|
+
states.push(r.server.join(), r.server.delta());
|
|
222
|
+
assert.equal(JSON.stringify({ sent: r.sent, states }), captured);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
|
|
119
226
|
await test('manifest: place-only true or absent, including explicit undefined', () => {
|
|
120
227
|
for (const named of [false, true]) {
|
|
121
228
|
for (const value of [true, false, null, 0, 1, '', 'true', [], {}, undefined]) {
|
|
@@ -246,7 +353,6 @@ await test('keyless trace is byte-identical to a session with all companion bran
|
|
|
246
353
|
const now = Date.now; Date.now = () => 100000;
|
|
247
354
|
try { assert.equal(trace(layer), trace(baseline)); } finally { Date.now = now; }
|
|
248
355
|
});
|
|
249
|
-
console.log(`${passed} companion tests passed`);
|
|
250
356
|
|
|
251
357
|
await test('an ended visit drops the follower: nothing of it is replayed on a later hello', () => {
|
|
252
358
|
const r = boot({ companion: true });
|
|
@@ -257,3 +363,4 @@ await test('an ended visit drops the follower: nothing of it is replayed on a la
|
|
|
257
363
|
assert.deepEqual(wire(r).filter(([, m]) => m.k === 'hub-companion'), []);
|
|
258
364
|
assert.deepEqual(r.server.delta().hubGlow ?? [], []);
|
|
259
365
|
});
|
|
366
|
+
console.log(`${passed} companion tests passed`);
|