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
|
@@ -75,19 +75,93 @@ export function panelPlacement(box, view, margin = {}, bands = [], minWidth = 16
|
|
|
75
75
|
return placed;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
// A card that opens from a button (Quick chat, Emote) and has no clear place
|
|
79
|
+
// off it, such as on a 179x250 view: it opens on the side of its button with
|
|
80
|
+
// more room, fitted to that room and level with the button's bottom, never
|
|
81
|
+
// over the button itself; the caller lets it scroll there.
|
|
82
|
+
export function besideButton(box, view, margin = {}, button) {
|
|
83
|
+
const left = Math.max(margin.left ?? 6, view.insets.left);
|
|
84
|
+
const right = view.w - Math.max(margin.right ?? 6, view.insets.right);
|
|
85
|
+
const top = Math.max(margin.top ?? 6, view.insets.top);
|
|
86
|
+
const bottom = view.h - Math.max(margin.bottom ?? 6, view.insets.bottom);
|
|
87
|
+
const leftRoom = button.left - 6 - left, rightRoom = right - button.right - 6;
|
|
88
|
+
const onRight = rightRoom > leftRoom;
|
|
89
|
+
const w = Math.min(box.right - box.left, Math.max(0, onRight ? rightRoom : leftRoom));
|
|
90
|
+
const h = Math.min(box.bottom - box.top, Math.max(0, bottom - top));
|
|
91
|
+
const x = onRight ? button.right + 6 : button.left - 6 - w;
|
|
92
|
+
const y = Math.max(top, Math.min(button.bottom - h, bottom - h));
|
|
93
|
+
return { x, y, w, h };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Transient text (the engine's look caption, the feed, stats) whose words lie
|
|
97
|
+
// under a band after `safePlacement`, which only moves down: a centred line
|
|
98
|
+
// such as "2 here · a boat shed" at the bottom of a landscape phone stays
|
|
99
|
+
// under the bottom controls. Its words, `need` wide and centred in the box,
|
|
100
|
+
// go to the nearest row and lane that is clear of every band; `null` when no
|
|
101
|
+
// lane anywhere fits them, and the line is not drawn. Words already clear
|
|
102
|
+
// keep the `safePlacement` box exactly. `whole` (the HUD prompt, whose pill
|
|
103
|
+
// is its box) keeps the line's full height: a place `safePlacement` squashed
|
|
104
|
+
// under a band is not clear, and the rows are chosen for the whole line.
|
|
105
|
+
export function clearPlacement(box, view, margin = {}, bands = [], need = box.right - box.left, whole = false) {
|
|
106
|
+
const placed = safePlacement(box, view, margin, bands);
|
|
107
|
+
const left = Math.max(margin.left ?? 6, view.insets.left);
|
|
108
|
+
const right = view.w - Math.max(margin.right ?? 6, view.insets.right);
|
|
109
|
+
const top = Math.max(margin.top ?? 6, view.insets.top);
|
|
110
|
+
const bottom = view.h - Math.max(margin.bottom ?? 6, view.insets.bottom);
|
|
111
|
+
const full = Math.min(box.bottom - box.top, bottom - top);
|
|
112
|
+
const w = Math.min(need, placed.w), h = whole ? full : placed.h;
|
|
113
|
+
const cx = placed.x + placed.w / 2;
|
|
114
|
+
const words = rect(cx - w / 2, placed.y, w, h);
|
|
115
|
+
if ((!whole || placed.h >= full) && !bands.some((band) => overlaps(words, band))) {return placed;}
|
|
116
|
+
const rows = new Set([placed.y]);
|
|
117
|
+
for (const band of bands) {rows.add(band.top - 6 - h); rows.add(band.bottom + 6);}
|
|
118
|
+
let best = null;
|
|
119
|
+
for (const y of rows) {
|
|
120
|
+
if (y < top || y + h > bottom) {continue;}
|
|
121
|
+
// The free horizontal lanes in this row, between the bands it crosses.
|
|
122
|
+
const crossing = bands.filter((band) => band.top < y + h && band.bottom > y).sort((a, b) => a.left - b.left);
|
|
123
|
+
let from = left;
|
|
124
|
+
for (const band of [...crossing, { left: right + 6, right: Infinity }]) {
|
|
125
|
+
const to = Math.min(right, band.left - 6);
|
|
126
|
+
if (to - from >= w) {
|
|
127
|
+
const x = Math.max(from, Math.min(cx - w / 2, to - w));
|
|
128
|
+
const distance = Math.abs(y - placed.y) + Math.abs(x + w / 2 - cx);
|
|
129
|
+
if (!best || distance < best.distance) {best = { x, y, w, h, distance };}
|
|
130
|
+
}
|
|
131
|
+
from = Math.max(from, band.right + 6);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (!best) {return null;}
|
|
135
|
+
const { distance, ...clear } = best;
|
|
136
|
+
return clear;
|
|
137
|
+
}
|
|
138
|
+
|
|
78
139
|
// One bottom-up column for controls that formerly had independent offsets.
|
|
79
140
|
// A short view starts another column to the left rather than covering a peer.
|
|
80
|
-
|
|
141
|
+
// A control never stands on an obstacle (the Doors dock): it takes the lowest
|
|
142
|
+
// place in its column clear of the obstacles and the controls placed so far.
|
|
143
|
+
// `fits` is false where one rises over the ceiling or leaves the view.
|
|
144
|
+
export function stackPlacement(sizes, view, ceiling, gap = 6, obstacles = []) {
|
|
81
145
|
const bottom = view.h - Math.max(10, view.insets.bottom);
|
|
82
146
|
const right = view.w - Math.max(12, view.insets.right);
|
|
83
|
-
let edge = right,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
147
|
+
let edge = right, width = 0, column = 0;
|
|
148
|
+
const taken = obstacles.map((box) => ({ left: box.left - gap, right: box.right + gap, top: box.top - gap, bottom: box.bottom + gap }));
|
|
149
|
+
// The lowest bottom edge in this column clear of everything taken.
|
|
150
|
+
const lowest = (w, h, under = ceiling) => [bottom, ...taken.map((box) => box.top)].filter((y) => y <= bottom).sort((a, b) => b - a)
|
|
151
|
+
.find((y) => y - h >= under && !taken.some((box) => overlaps(rect(edge - w, y - h, w, h), box)));
|
|
152
|
+
let fits = true;
|
|
153
|
+
const placements = sizes.map(({ w, h }) => {
|
|
154
|
+
let y = lowest(w, h);
|
|
155
|
+
if (y === undefined && column) {edge -= width + gap; width = 0; column = 0; y = lowest(w, h);}
|
|
156
|
+
if (y === undefined || edge - w < Math.max(6, view.insets.left)) {fits = false;}
|
|
157
|
+
y ??= lowest(w, h, -Infinity) ?? bottom;
|
|
158
|
+
const placed = { x: edge - w, y: y - h, w, h };
|
|
159
|
+
taken.push({ left: placed.x - gap, right: edge + gap, top: placed.y - gap, bottom: y + gap });
|
|
160
|
+
width = Math.max(width, w); column++;
|
|
89
161
|
return placed;
|
|
90
162
|
});
|
|
163
|
+
placements.fits = fits;
|
|
164
|
+
return placements;
|
|
91
165
|
}
|
|
92
166
|
|
|
93
167
|
// A standing text line (the HUD prompt) beside the bottom-right control
|
|
@@ -109,6 +183,21 @@ export function besideColumn(placed, view, margin = {}, column = [], minLane = 1
|
|
|
109
183
|
return { x, y, w, h };
|
|
110
184
|
}
|
|
111
185
|
|
|
186
|
+
// The narrowest lane the HUD is moved into beside the right-edge controls.
|
|
187
|
+
const HUD_LANE_MIN = 72;
|
|
188
|
+
|
|
189
|
+
// The box a node stands in while it is out of sight (visibility), but not
|
|
190
|
+
// while it is not laid out at all (display).
|
|
191
|
+
const laidOutRect = (node) => {
|
|
192
|
+
if (!node?.getBoundingClientRect || node.isConnected === false) {return null;}
|
|
193
|
+
for (let parent = node; parent; parent = parent.parentElement ?? parent.parent) {
|
|
194
|
+
const style = globalThis.getComputedStyle?.(parent) ?? parent.style;
|
|
195
|
+
if (style?.display === 'none') {return null;}
|
|
196
|
+
}
|
|
197
|
+
const box = node.getBoundingClientRect();
|
|
198
|
+
return box.width > 0 && box.height > 0 ? box : null;
|
|
199
|
+
};
|
|
200
|
+
|
|
112
201
|
const visibleRect = (node) => {
|
|
113
202
|
if (!node?.getBoundingClientRect || node.isConnected === false) {return null;}
|
|
114
203
|
for (let parent = node; parent; parent = parent.parentElement ?? parent.parent) {
|
|
@@ -119,6 +208,31 @@ const visibleRect = (node) => {
|
|
|
119
208
|
return box.width > 0 && box.height > 0 ? box : null;
|
|
120
209
|
};
|
|
121
210
|
|
|
211
|
+
// The box its ancestors clip a node to: a deck's stage is a card inset in a
|
|
212
|
+
// standalone page, and the engine's text lives inside it while the chrome
|
|
213
|
+
// does not. Null when nothing between it and the page clips it.
|
|
214
|
+
const clipRect = (node) => {
|
|
215
|
+
for (let parent = node.parentElement ?? node.parent; parent && parent !== node.ownerDocument?.body; parent = parent.parentElement ?? parent.parent) {
|
|
216
|
+
const style = globalThis.getComputedStyle?.(parent) ?? parent.style;
|
|
217
|
+
const clips = (value) => Boolean(value) && value !== 'visible';
|
|
218
|
+
if (style && parent.getBoundingClientRect && [style.overflowX, style.overflowY, style.overflow].some(clips)) {
|
|
219
|
+
return parent.getBoundingClientRect();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return null;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const centred = (node) => (globalThis.getComputedStyle?.(node) ?? node.style)?.textAlign === 'center';
|
|
226
|
+
|
|
227
|
+
// The width of a text node's words (a centred line spans its whole box).
|
|
228
|
+
const wordsWidth = (node, box) => {
|
|
229
|
+
const range = node.ownerDocument?.createRange?.();
|
|
230
|
+
if (!range) {return box.width;}
|
|
231
|
+
range.selectNodeContents(node);
|
|
232
|
+
const words = range.getBoundingClientRect();
|
|
233
|
+
return words.width > 0 ? Math.min(box.width, Math.ceil(words.width) + 2) : box.width;
|
|
234
|
+
};
|
|
235
|
+
|
|
122
236
|
export function makeSafeLayout({ root, entries, view = globalThis.window, hud = () => null, onLayout = () => {} }) {
|
|
123
237
|
const probe = document.createElement('div');
|
|
124
238
|
probe.style.cssText = 'position:fixed;inset:0;visibility:hidden;pointer-events:none;padding-top:env(safe-area-inset-top);padding-right:env(safe-area-inset-right);padding-bottom:env(safe-area-inset-bottom);padding-left:env(safe-area-inset-left)';
|
|
@@ -128,6 +242,10 @@ export function makeSafeLayout({ root, entries, view = globalThis.window, hud =
|
|
|
128
242
|
let cachedView = null, insetsDirty = true;
|
|
129
243
|
let checkedAt = -Infinity, timer = null;
|
|
130
244
|
let disposed = false, last = null, forced = false;
|
|
245
|
+
// A moved prompt's old box, which the rail (outside `flush`) yields to.
|
|
246
|
+
let promptHeld = null;
|
|
247
|
+
// The same for each act prompt that moved or was hidden this pass.
|
|
248
|
+
let actHeld = new Map();
|
|
131
249
|
const observers = new Map(), pending = new Map();
|
|
132
250
|
let projected = new WeakSet();
|
|
133
251
|
const readView = () => {
|
|
@@ -198,21 +316,116 @@ export function makeSafeLayout({ root, entries, view = globalThis.window, hud =
|
|
|
198
316
|
...current.filter((entry) => entry.id === 'sound').map((entry) => {
|
|
199
317
|
const box = visibleRect(entry.node); return box ? Math.max(box.bottom, viewport.insets.top + 56 + box.height) + 6 : 0;
|
|
200
318
|
}));
|
|
201
|
-
|
|
319
|
+
// The column keeps clear of an entry with `clearOfStack` (the Doors dock)
|
|
320
|
+
// where it stands at the bottom; one the column has no room beside is
|
|
321
|
+
// raised (`clearOfStack.raise`), when the column fits without it. Its
|
|
322
|
+
// boxes count while it is hidden (a raised dock under the Sound card), so
|
|
323
|
+
// hiding it never lowers it.
|
|
324
|
+
const homes = current.filter((entry) => entry.clearOfStack?.atBottom());
|
|
325
|
+
const obstacles = homes.flatMap((entry) => {
|
|
326
|
+
const boxes = [entry.node, ...(entry.reportNodes?.() ?? []).map((item) => item.node)].map(laidOutRect).filter(Boolean);
|
|
327
|
+
if (!boxes.length || !entry.clearOfStack.raised()) {return boxes;}
|
|
328
|
+
const drop = viewport.h - Math.max(entry.margin?.bottom ?? 6, viewport.insets.bottom) - Math.max(...boxes.map((box) => box.bottom));
|
|
329
|
+
return boxes.map((box) => ({ left: box.left, right: box.right, top: box.top + drop, bottom: box.bottom + drop }));
|
|
330
|
+
});
|
|
331
|
+
const stackSizes = stack.map(({ box }) => ({ w: box.width, h: box.height }));
|
|
332
|
+
let placements = stackPlacement(stackSizes, viewport, ceiling, 6, obstacles);
|
|
333
|
+
if (homes.length) {
|
|
334
|
+
const clear = stackPlacement(stackSizes, viewport, ceiling);
|
|
335
|
+
const raise = obstacles.length > 0 && !placements.fits && clear.fits;
|
|
336
|
+
for (const entry of homes) {entry.clearOfStack.raise(raise);}
|
|
337
|
+
if (raise) {placements = clear;}
|
|
338
|
+
}
|
|
202
339
|
stack.forEach(({ entry, box }, index) => {
|
|
203
340
|
const at = placements[index];
|
|
204
341
|
write(entry.stackNode ?? entry.node, 'translate', `${at.x - box.left}px ${at.y - box.top}px`);
|
|
205
342
|
});
|
|
206
343
|
const column = stack.flatMap(({ entry }) => [entry.node, ...(entry.reportNodes?.() ?? []).map((item) => item.node)])
|
|
207
344
|
.map(visibleRect).filter(Boolean);
|
|
345
|
+
// The HUD over the right-edge controls (the stacked column, Sound) of a
|
|
346
|
+
// small view, such as a game in a short desktop window (179x250): it is
|
|
347
|
+
// laid out in the lane left of them instead, under the host's corner
|
|
348
|
+
// when that corner leaves no room beside it, and not moved while no lane
|
|
349
|
+
// at least HUD_LANE_MIN wide is free. Null where the HUD is clear.
|
|
350
|
+
const beside = column.concat(current.filter((entry) => entry.id === 'sound').map((entry) => visibleRect(entry.node)).filter(Boolean));
|
|
351
|
+
const hudLane = (node, box, placed, margin) => {
|
|
352
|
+
const at = (b, p) => rect(p.x, p.y, b.width, b.height);
|
|
353
|
+
let hits = beside.filter((band) => overlaps(at(box, placed), band));
|
|
354
|
+
if (!hits.length) {return null;}
|
|
355
|
+
const edge = Math.max(margin?.left ?? 6, viewport.insets.left);
|
|
356
|
+
const below = viewport.insets.top + 56 + 6;
|
|
357
|
+
for (let pass = 0; pass < 2 && hits.length; pass++) {
|
|
358
|
+
const right = Math.min(...hits.map((band) => band.left)) - 6;
|
|
359
|
+
// Beside the host's corner, or under it when that lane is too narrow.
|
|
360
|
+
const left = right - Math.max(edge, corners[0].right + 6) >= HUD_LANE_MIN ? Math.max(edge, corners[0].right + 6) : edge;
|
|
361
|
+
const top = left === edge ? Math.max(placed.y, below) : placed.y;
|
|
362
|
+
if (right - left < HUD_LANE_MIN) {return pass ? { box, placed } : null;}
|
|
363
|
+
write(node, 'boxSizing', 'border-box');
|
|
364
|
+
write(node, 'maxWidth', `${right - left}px`);
|
|
365
|
+
write(node, 'whiteSpace', 'normal');
|
|
366
|
+
write(node, 'overflowWrap', 'anywhere');
|
|
367
|
+
for (const child of node.children) {write(child, 'maxWidth', `${right - left}px`);}
|
|
368
|
+
const fresh = visibleRect(node);
|
|
369
|
+
if (!fresh) {return null;}
|
|
370
|
+
box = fresh;
|
|
371
|
+
placed = { x: left + (right - left - box.width) / 2, y: top, w: box.width, h: Math.min(box.height, viewport.h - Math.max(margin?.bottom ?? 6, viewport.insets.bottom) - top) };
|
|
372
|
+
hits = beside.filter((band) => overlaps(at(box, placed), band));
|
|
373
|
+
}
|
|
374
|
+
return { box, placed };
|
|
375
|
+
};
|
|
208
376
|
const controls = [];
|
|
209
377
|
const transient = [];
|
|
378
|
+
// World labels and pointers: the caption family yields to them, the
|
|
379
|
+
// toast and the ribbon do not (a world label collapses on its own).
|
|
380
|
+
const floating = [];
|
|
381
|
+
// The new place of a prompt that left its old one (see `lay` below), and
|
|
382
|
+
// how to put it back there.
|
|
383
|
+
let promptMoved = null, promptBack = null;
|
|
384
|
+
promptHeld = null;
|
|
385
|
+
// Act prompts on a new lane; one a later surface lands on is hidden.
|
|
386
|
+
let actMoved = [];
|
|
387
|
+
actHeld = new Map();
|
|
388
|
+
const actOff = (box) => {
|
|
389
|
+
actMoved = actMoved.filter((item) => {
|
|
390
|
+
if (!box || !overlaps(box, item.box)) {return true;}
|
|
391
|
+
write(item.node, 'display', 'none');
|
|
392
|
+
return false;
|
|
393
|
+
});
|
|
394
|
+
};
|
|
395
|
+
const keepOff = (box) => {
|
|
396
|
+
if (!promptMoved || !box || !overlaps(box, promptMoved)) {return;}
|
|
397
|
+
// An act prompt on a lane chose it off the moved prompt's old place.
|
|
398
|
+
const held = promptHeld;
|
|
399
|
+
promptBack(); promptMoved = promptBack = promptHeld = null;
|
|
400
|
+
actOff(held);
|
|
401
|
+
};
|
|
402
|
+
const captions = [];
|
|
210
403
|
// Controls are placed before transient text, which yields to their boxes.
|
|
211
|
-
|
|
404
|
+
// The standing prompt follows every control, so it can see them all.
|
|
405
|
+
const standing = (entry) => entry.kind === 'text' && !entry.transient && entry.stack === undefined;
|
|
406
|
+
const act = (entry) => entry.transient && entry.kind === 'control' && entry.id?.startsWith('act-prompt:');
|
|
407
|
+
const priority = (entry) => entry.transient ? 2 : entry.kind === 'card' ? 1 : standing(entry) ? 0.5 : 0;
|
|
212
408
|
current.sort((a, b) => priority(a) - priority(b));
|
|
409
|
+
// Cards and transient text are placed after the prompt and yield to its
|
|
410
|
+
// old place, exactly as before; a prompt that moves keeps off their
|
|
411
|
+
// unplaced boxes.
|
|
412
|
+
const later = current.filter((entry) => !entry.projected && (entry.transient || entry.kind === 'card'))
|
|
413
|
+
.map((entry) => visibleRect(entry.node)).filter(Boolean);
|
|
213
414
|
for (const entry of current) {
|
|
214
415
|
if (entry.projected) {continue;}
|
|
215
|
-
const { node, kind
|
|
416
|
+
const { node, kind } = entry;
|
|
417
|
+
let { margin } = entry;
|
|
418
|
+
// The caption family is drawn only where its card shows it: a row
|
|
419
|
+
// below the card's clipped edge is not clear, it is cut off.
|
|
420
|
+
const clip = kind === 'text' && entry.transient ? clipRect(node) : null;
|
|
421
|
+
if (clip) {
|
|
422
|
+
margin = { ...margin,
|
|
423
|
+
left: Math.max(margin?.left ?? 6, clip.left + 6), top: Math.max(margin?.top ?? 6, clip.top + 6),
|
|
424
|
+
right: Math.max(margin?.right ?? 6, viewport.w - clip.right + 6), bottom: Math.max(margin?.bottom ?? 6, viewport.h - clip.bottom + 6) };
|
|
425
|
+
}
|
|
426
|
+
// The toast and the result ribbon are painted pills: they keep their
|
|
427
|
+
// whole box clear, as the caption keeps its words.
|
|
428
|
+
const pill = kind === 'toast' || kind === 'ribbon';
|
|
216
429
|
// A pinned card fits itself to the view; it is an obstacle, never moved.
|
|
217
430
|
if (entry.pinned) {
|
|
218
431
|
const own = visibleRect(node);
|
|
@@ -227,63 +440,196 @@ export function makeSafeLayout({ root, entries, view = globalThis.window, hud =
|
|
|
227
440
|
if (hudBox && node !== hud()) {bands.push(hudBox);}
|
|
228
441
|
bands.push(...controls);
|
|
229
442
|
bands.push(...transient);
|
|
443
|
+
if (!pill) {bands.push(...floating);}
|
|
444
|
+
// The caption family also keeps its words off the prompt's new place.
|
|
445
|
+
if (promptMoved && kind === 'text') {bands.push(promptMoved);}
|
|
446
|
+
if (kind === 'text') {bands.push(...actMoved.map((item) => item.box));}
|
|
230
447
|
}
|
|
231
|
-
if (kind === 'card') {
|
|
448
|
+
if (kind === 'card' || standing(entry)) {
|
|
232
449
|
bands.push(...controls);
|
|
233
450
|
const hudBox = visibleRect(hud());
|
|
234
451
|
if (hudBox) {bands.push(hudBox);}
|
|
235
452
|
}
|
|
453
|
+
if (standing(entry)) {bands.push(...later);}
|
|
454
|
+
// Transient text chooses its lane from its full box: the places below
|
|
455
|
+
// see the box it was narrowed to and keep that lane, unless its words
|
|
456
|
+
// wrapped taller there, when the lane is chosen again for that height.
|
|
457
|
+
let clear, full;
|
|
458
|
+
const clearText = (value) => {
|
|
459
|
+
if (clear === undefined) {
|
|
460
|
+
full = value;
|
|
461
|
+
const need = standing(entry) || pill ? value.width : wordsWidth(node, value);
|
|
462
|
+
clear = clearPlacement(value, viewport, margin, bands, need, standing(entry) || pill);
|
|
463
|
+
// A centred line whose words are clear but whose box spans a
|
|
464
|
+
// control (the full-width look caption under quick chat) is
|
|
465
|
+
// narrowed to its words where they are, so nothing reads it as
|
|
466
|
+
// lying under the control.
|
|
467
|
+
if (clear && !standing(entry) && !pill && clear.w > need + 0.5 && centred(node)
|
|
468
|
+
&& bands.some((band) => overlaps(rect(clear.x, clear.y, clear.w, clear.h), band))) {
|
|
469
|
+
clear = { x: clear.x + (clear.w - need) / 2, y: clear.y, w: need, h: clear.h };
|
|
470
|
+
}
|
|
471
|
+
return clear;
|
|
472
|
+
}
|
|
473
|
+
if (clear && value.height > clear.h) {
|
|
474
|
+
clear = clearPlacement(rect(full.left, full.top, full.width, value.height), viewport, margin, bands, clear.w, standing(entry) || pill);
|
|
475
|
+
}
|
|
476
|
+
return clear;
|
|
477
|
+
};
|
|
478
|
+
// The standing prompt is laid out beside the column against the corners
|
|
479
|
+
// only, as before. When that place covers a control, such as People in
|
|
480
|
+
// the dock on a landscape phone, it is laid out again by the caption's
|
|
481
|
+
// lane rule, and keeps its old place while no lane fits, since an
|
|
482
|
+
// instruction is never hidden. What follows yields to the old place.
|
|
483
|
+
const beside = (value) => besideColumn(safePlacement(value, viewport, margin, corners), viewport, margin, column);
|
|
484
|
+
// A goal or friend chip (`setPointers`) is moved only down out from
|
|
485
|
+
// under a band, capped at the bottom edge: one under the Act/Jump pair
|
|
486
|
+
// landed on the chat button below it. A move that ends on a control
|
|
487
|
+
// takes the nearest place clear of every band, else of every control,
|
|
488
|
+
// else stays where its own avoidance put it. A move clear of the
|
|
489
|
+
// controls is kept exactly.
|
|
490
|
+
const chip = (value) => {
|
|
491
|
+
const placed = safePlacement(value, viewport, margin, bands);
|
|
492
|
+
const hit = [...corners, ...controls];
|
|
493
|
+
if (!hit.some((band) => overlaps(rect(placed.x, placed.y, placed.w, placed.h), band))) {return placed;}
|
|
494
|
+
return clearPlacement(value, viewport, margin, bands, value.width, true)
|
|
495
|
+
?? clearPlacement(value, viewport, margin, hit, value.width, true)
|
|
496
|
+
?? safePlacement(value, viewport, margin);
|
|
497
|
+
};
|
|
236
498
|
const place = (value) => kind === 'card' ? panelPlacement(value, viewport, margin, bands)
|
|
237
|
-
: kind === 'text' &&
|
|
238
|
-
:
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
write(
|
|
256
|
-
write(
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
499
|
+
: (kind === 'text' && entry.transient) || pill ? clearText(value)
|
|
500
|
+
: standing(entry) ? beside(value)
|
|
501
|
+
: kind === 'pointer' && entry.transient && entry.id?.startsWith('pointer:') ? chip(value)
|
|
502
|
+
: safePlacement(value, viewport, margin, bands);
|
|
503
|
+
const lay = (place, box) => {
|
|
504
|
+
let placed = place(box);
|
|
505
|
+
if (!placed) {
|
|
506
|
+
write(node, 'display', 'none');
|
|
507
|
+
return null;
|
|
508
|
+
}
|
|
509
|
+
// The centered HUD title row has a lane between both native corners.
|
|
510
|
+
if (kind === 'hud' && box.top < viewport.insets.top + 56) {
|
|
511
|
+
const lane = Math.max(0, viewport.w - viewport.insets.left - viewport.insets.right - 128);
|
|
512
|
+
placed.w = Math.min(placed.w, lane);
|
|
513
|
+
}
|
|
514
|
+
if (box.width > placed.w || node.scrollWidth > node.clientWidth + 1) {
|
|
515
|
+
write(node, 'boxSizing', 'border-box');
|
|
516
|
+
write(node, 'maxWidth', `${placed.w}px`);
|
|
517
|
+
write(node, 'whiteSpace', 'normal');
|
|
518
|
+
write(node, 'overflowWrap', 'anywhere');
|
|
519
|
+
}
|
|
520
|
+
if (kind === 'hud') {
|
|
521
|
+
for (const child of node.children) {
|
|
522
|
+
// The clear-HUD path may have clamped or ellipsized an inner line.
|
|
523
|
+
// The opted-in rule keeps those words reachable instead.
|
|
524
|
+
write(child, 'maxWidth', `${placed.w}px`);
|
|
525
|
+
write(child, 'whiteSpace', 'normal');
|
|
526
|
+
write(child, 'overflowWrap', 'anywhere');
|
|
527
|
+
// Copy rows own their two-line clipping and empty-row visibility.
|
|
528
|
+
if (child.dataset?.hubCopy) {continue;}
|
|
529
|
+
write(child, 'overflow', 'visible');
|
|
530
|
+
write(child, 'textOverflow', '');
|
|
531
|
+
write(child, 'webkitLineClamp', '');
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
if (box.height > placed.h) {
|
|
535
|
+
write(node, 'boxSizing', 'border-box');
|
|
536
|
+
write(node, 'maxHeight', `${placed.h}px`);
|
|
537
|
+
write(node, 'overflowY', 'auto');
|
|
538
|
+
}
|
|
539
|
+
box = visibleRect(node);
|
|
540
|
+
if (!box) {return null;}
|
|
541
|
+
placed = place(box);
|
|
542
|
+
if (placed && box.height > placed.h) {
|
|
543
|
+
write(node, 'boxSizing', 'border-box');
|
|
544
|
+
write(node, 'maxHeight', `${placed.h}px`);
|
|
545
|
+
write(node, 'overflowY', 'auto');
|
|
546
|
+
box = visibleRect(node);
|
|
547
|
+
if (!box) {return null;}
|
|
548
|
+
placed = place(box);
|
|
549
|
+
}
|
|
550
|
+
if (!placed) {
|
|
551
|
+
write(node, 'display', 'none');
|
|
552
|
+
return null;
|
|
263
553
|
}
|
|
554
|
+
if (kind === 'hud') {
|
|
555
|
+
const lane = hudLane(node, box, placed, margin);
|
|
556
|
+
if (lane) {({ box, placed } = lane);}
|
|
557
|
+
}
|
|
558
|
+
// CSS translate is independent of the renderer's anchoring transform.
|
|
559
|
+
const dx = placed.x - box.left, dy = placed.y - box.top;
|
|
560
|
+
if (dx || dy) {write(node, 'translate', `${dx}px ${dy}px`);}
|
|
561
|
+
return visibleRect(node) ?? null;
|
|
562
|
+
};
|
|
563
|
+
const natural = box;
|
|
564
|
+
let final = lay(place, box);
|
|
565
|
+
if (!final) {continue;}
|
|
566
|
+
// The Sound card (`offControls`) also goes beside its button when its
|
|
567
|
+
// panel place lands on another control, as at 179x250.
|
|
568
|
+
const own = kind === 'card' && visibleRect(entry.beside);
|
|
569
|
+
if (own && (overlaps(final, own) || entry.offControls && controls.some((band) => overlaps(final, band)))) {
|
|
570
|
+
corrections.clearNode(node);
|
|
571
|
+
box = visibleRect(node);
|
|
572
|
+
if (box) {
|
|
573
|
+
write(node, 'overflowX', 'auto');
|
|
574
|
+
final = lay((value) => besideButton(value, viewport, margin, own), box);
|
|
575
|
+
}
|
|
576
|
+
if (!final) {continue;}
|
|
264
577
|
}
|
|
265
|
-
if (
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
578
|
+
if (standing(entry) && controls.some((band) => overlaps(final, band))) {
|
|
579
|
+
const old = final;
|
|
580
|
+
if (clearText(natural)) {
|
|
581
|
+
corrections.clearNode(node);
|
|
582
|
+
box = visibleRect(node);
|
|
583
|
+
final = box && lay((value) => clearText(value) ?? beside(value), box);
|
|
584
|
+
// The lane is kept only while nothing placed after the prompt
|
|
585
|
+
// lands on it; otherwise the prompt goes back to its old place,
|
|
586
|
+
// which everything after it was placed around.
|
|
587
|
+
const back = () => {
|
|
588
|
+
corrections.clearNode(node);
|
|
589
|
+
const again = visibleRect(node);
|
|
590
|
+
if (again) {lay(place, again);}
|
|
591
|
+
};
|
|
592
|
+
if (final) {promptMoved = final; promptBack = back; promptHeld = old;} else {back();}
|
|
593
|
+
}
|
|
594
|
+
controls.push(old);
|
|
595
|
+
continue;
|
|
269
596
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
597
|
+
// An act pill, such as Talk to Rowan, the greeter, keeps the place it
|
|
598
|
+
// was given while that is clear of every control, the HUD and the
|
|
599
|
+
// transient text before it; otherwise its whole pill takes the
|
|
600
|
+
// caption's lane rule, also off the prompt's new place, other moved
|
|
601
|
+
// act prompts and the unplaced boxes of what follows, and it is not
|
|
602
|
+
// drawn while no lane fits. What follows, and the rail (`heldAct`),
|
|
603
|
+
// is placed around its old place exactly as before.
|
|
604
|
+
// A moved prompt is seen where it is drawn, not at its old place.
|
|
605
|
+
const seen = act(entry) && [...bands.filter((band) => !promptMoved || band !== promptHeld),
|
|
606
|
+
...actMoved.map((item) => item.box), ...(promptMoved ? [promptMoved] : [])];
|
|
607
|
+
// A pill pushed partly out of the view (below a low control), or
|
|
608
|
+
// shortened or narrowed to fit there, is not clear either: its whole
|
|
609
|
+
// natural box must fit inside the margins.
|
|
610
|
+
const outside = () => final.height < natural.height - 0.5 || final.width < natural.width - 0.5
|
|
611
|
+
|| final.left < Math.max(margin?.left ?? 6, viewport.insets.left) - 0.5
|
|
612
|
+
|| final.top < Math.max(margin?.top ?? 6, viewport.insets.top) - 0.5
|
|
613
|
+
|| final.right > viewport.w - Math.max(margin?.right ?? 6, viewport.insets.right) + 0.5
|
|
614
|
+
|| final.bottom > viewport.h - Math.max(margin?.bottom ?? 6, viewport.insets.bottom) + 0.5;
|
|
615
|
+
if (seen && (seen.some((band) => overlaps(final, band)) || outside())) {
|
|
616
|
+
const old = final;
|
|
617
|
+
const after = current.slice(current.indexOf(entry) + 1)
|
|
618
|
+
.filter((other) => !other.projected && (other.transient || other.kind === 'card'))
|
|
619
|
+
.map((other) => visibleRect(other.node)).filter(Boolean);
|
|
620
|
+
const lane = [...seen, ...after];
|
|
621
|
+
corrections.clearNode(node);
|
|
277
622
|
box = visibleRect(node);
|
|
278
|
-
|
|
279
|
-
|
|
623
|
+
final = box && lay((value) => clearPlacement(value, viewport, margin, lane, value.width, true), box);
|
|
624
|
+
actHeld.set(node, old);
|
|
625
|
+
if (final) {actMoved.push({ node, box: final }); keepOff(final);}
|
|
626
|
+
transient.push(old);
|
|
627
|
+
continue;
|
|
280
628
|
}
|
|
281
|
-
|
|
282
|
-
const dx = placed.x - box.left, dy = placed.y - box.top;
|
|
283
|
-
if (dx || dy) {write(node, 'translate', `${dx}px ${dy}px`);}
|
|
284
|
-
const final = visibleRect(node);
|
|
629
|
+
if (kind === 'card' || entry.transient) {keepOff(final); actOff(final);}
|
|
285
630
|
if (final && !entry.transient && kind !== 'hud' && kind !== 'label' && kind !== 'pointer') {controls.push(final);}
|
|
286
|
-
if (final && entry.transient) {transient.push(final);}
|
|
631
|
+
if (final && entry.transient) {(kind === 'label' || kind === 'pointer' ? floating : transient).push(final);}
|
|
632
|
+
if (final && clear && entry.transient) {captions.push({ node, pill });}
|
|
287
633
|
}
|
|
288
634
|
sizes?.disconnect();
|
|
289
635
|
sizes?.observe(root);
|
|
@@ -301,6 +647,33 @@ export function makeSafeLayout({ root, entries, view = globalThis.window, hud =
|
|
|
301
647
|
// v1.152: the action rail settles against the final controls here, so
|
|
302
648
|
// the report is read after it.
|
|
303
649
|
onLayout();
|
|
650
|
+
// The rail and the cards it lays out settle around the prompt's old box;
|
|
651
|
+
// one that settles onto its lane sends the prompt back there.
|
|
652
|
+
// An act prompt's lane they settle onto is not clear: it is not drawn.
|
|
653
|
+
if (promptMoved || actMoved.length) {
|
|
654
|
+
for (const entry of current) {
|
|
655
|
+
if (entry.projected || entry.transient || (entry.kind !== 'control' && entry.kind !== 'card')) {continue;}
|
|
656
|
+
for (const node of [entry.node, ...(entry.reportNodes?.() ?? []).map((item) => item.node)]) {
|
|
657
|
+
const box = visibleRect(node);
|
|
658
|
+
keepOff(box); actOff(box);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
// The rail settled after transient text chose its lane, and does not
|
|
663
|
+
// make way for the engine's text: a caption whose words it now covers is
|
|
664
|
+
// not drawn this pass. The rail's move schedules the next pass, which
|
|
665
|
+
// places the caption around the settled rail.
|
|
666
|
+
if (captions.length) {
|
|
667
|
+
const settled = current.filter((entry) => !entry.transient && !entry.projected && !['hud', 'label', 'pointer'].includes(entry.kind))
|
|
668
|
+
.flatMap((entry) => [entry.node, ...(entry.reportNodes?.() ?? []).map((item) => item.node)]).map(visibleRect).filter(Boolean);
|
|
669
|
+
for (const { node, pill } of captions) {
|
|
670
|
+
const box = visibleRect(node);
|
|
671
|
+
if (!box) {continue;}
|
|
672
|
+
const w = pill ? box.width : Math.min(box.width, wordsWidth(node, box));
|
|
673
|
+
const words = rect(box.left + (box.width - w) / 2, box.top, w, box.height);
|
|
674
|
+
if (settled.some((band) => overlaps(words, band))) {write(node, 'display', 'none');}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
304
677
|
const boxes = [];
|
|
305
678
|
for (const entry of current) {
|
|
306
679
|
const reported = entry.reportNodes?.() ?? [{ node: entry.node, id: entry.id, kind: entry.kind }];
|
|
@@ -327,7 +700,15 @@ export function makeSafeLayout({ root, entries, view = globalThis.window, hud =
|
|
|
327
700
|
let different = false;
|
|
328
701
|
for (const { target, contentRect } of records) {
|
|
329
702
|
const key = `${contentRect.width}:${contentRect.height}`;
|
|
330
|
-
|
|
703
|
+
const was = dimensions.get(target);
|
|
704
|
+
if (was !== key) {
|
|
705
|
+
different = true; dimensions.set(target, key);
|
|
706
|
+
// The probe's content box is the view less its safe-area padding: it
|
|
707
|
+
// changes size when an inset does, also at an unchanged view size
|
|
708
|
+
// (an Android keyboard or nav bar), which raises no window resize.
|
|
709
|
+
// Its first observation is no change.
|
|
710
|
+
if (target === probe && was !== undefined) {insetsDirty = true;}
|
|
711
|
+
}
|
|
331
712
|
}
|
|
332
713
|
if (different) {schedule();}
|
|
333
714
|
}) : null;
|
|
@@ -342,6 +723,10 @@ export function makeSafeLayout({ root, entries, view = globalThis.window, hud =
|
|
|
342
723
|
readView();
|
|
343
724
|
return {
|
|
344
725
|
view: () => cachedView,
|
|
726
|
+
// The box the HUD prompt held before it moved this pass, or null.
|
|
727
|
+
heldPrompt: () => promptHeld,
|
|
728
|
+
// The box an act prompt held before it moved or was hidden, or null.
|
|
729
|
+
heldAct: (node) => actHeld.get(node) ?? null,
|
|
345
730
|
watch,
|
|
346
731
|
schedule,
|
|
347
732
|
begin: () => {},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Persistent CSS wins over the renderer's normal inline declarations. The
|
|
2
2
|
// renderer can keep writing its baseline without a per-frame restore/reapply.
|
|
3
|
-
const properties = ['translate', 'boxSizing', 'maxWidth', 'whiteSpace', 'overflowWrap', 'overflow', 'textOverflow', 'webkitLineClamp', 'display', 'maxHeight', 'overflowY'];
|
|
3
|
+
const properties = ['translate', 'boxSizing', 'maxWidth', 'whiteSpace', 'overflowWrap', 'overflow', 'textOverflow', 'webkitLineClamp', 'display', 'maxHeight', 'overflowY', 'overflowX'];
|
|
4
4
|
const cssName = key => key.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`).replace(/^webkit-/, '-webkit-');
|
|
5
5
|
export function makeSafeStyle(root) {
|
|
6
6
|
const sheet = document.createElement('style');
|
|
@@ -10,6 +10,15 @@ export function makeSafeStyle(root) {
|
|
|
10
10
|
}).join('\n');
|
|
11
11
|
root.appendChild(sheet);
|
|
12
12
|
const changed = new Map();
|
|
13
|
+
const restore = (node) => {
|
|
14
|
+
for (const [key, before] of changed.get(node) ?? []) {
|
|
15
|
+
if (typeof node.style.removeProperty === 'function') {
|
|
16
|
+
const name = cssName(key);
|
|
17
|
+
node.style.removeProperty(`--hub-safe-${name}`);
|
|
18
|
+
node.removeAttribute(`data-hub-safe-${name}`);
|
|
19
|
+
} else {node.style[key] = before;}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
13
22
|
return {
|
|
14
23
|
write(node, key, value) {
|
|
15
24
|
let keys = changed.get(node);
|
|
@@ -26,17 +35,11 @@ export function makeSafeStyle(root) {
|
|
|
26
35
|
}
|
|
27
36
|
},
|
|
28
37
|
clear() {
|
|
29
|
-
for (const
|
|
30
|
-
for (const [key, before] of keys) {
|
|
31
|
-
if (typeof node.style.removeProperty === 'function') {
|
|
32
|
-
const name = cssName(key);
|
|
33
|
-
node.style.removeProperty(`--hub-safe-${name}`);
|
|
34
|
-
node.removeAttribute(`data-hub-safe-${name}`);
|
|
35
|
-
} else {node.style[key] = before;}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
+
for (const node of changed.keys()) {restore(node);}
|
|
38
39
|
changed.clear();
|
|
39
40
|
},
|
|
41
|
+
// One node's corrections only (its children's stay).
|
|
42
|
+
clearNode(node) {restore(node); changed.delete(node);},
|
|
40
43
|
dispose() {this.clear(); sheet.remove();},
|
|
41
44
|
};
|
|
42
45
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// and the short feed of what was just said. Every word here is the kit's: a
|
|
4
4
|
// `hub-said` carries an id, never text.
|
|
5
5
|
|
|
6
|
+
import { disguiseBody } from './disguise.js';
|
|
6
7
|
import { hub } from './state.js';
|
|
7
8
|
|
|
8
9
|
export const REACTIONS = ['👍', '😂', '❤️', '😮', '👋', '🎉'];
|
|
@@ -93,6 +94,7 @@ export function makeSay() {
|
|
|
93
94
|
const out = [];
|
|
94
95
|
const mp = scene.multiplayer;
|
|
95
96
|
for (const [playerId, b] of bubbles) {
|
|
97
|
+
if (disguiseBody(selfId, playerId)) {continue;}
|
|
96
98
|
const actorId = playerId === selfId ? local?.id : mp?.avatars?.actors?.get(playerId);
|
|
97
99
|
const at = actorId ? scene.getActor(actorId)?.components.Transform : null;
|
|
98
100
|
const screen = at ? project(cam, at.x, at.y + BUBBLE_Y, at.z, view) : null;
|