castle-web-cli 0.4.239 → 0.4.241
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.js +5 -1
- package/dist/api.d.ts +20 -0
- package/dist/api.js +57 -0
- package/dist/bundle.d.ts +38 -1
- package/dist/bundle.js +309 -13
- package/dist/castle-host/host.js +163 -11
- package/dist/castleJson.d.ts +10 -0
- package/dist/castleJson.js +46 -2
- package/dist/check.js +5 -2
- package/dist/devSessionServer.js +4 -1
- package/dist/devSessionStorage.d.ts +1 -0
- package/dist/devSessionStorage.js +32 -7
- package/dist/importOrder.d.ts +2 -0
- package/dist/importOrder.js +29 -0
- package/dist/index.js +6 -3
- package/dist/init.js +24 -2
- package/dist/multiplayerDoc.d.ts +1 -1
- package/dist/multiplayerDoc.js +2 -0
- package/dist/platformDoc.js +3 -2
- package/dist/playPagePolicy.js +5 -1
- package/dist/resetLeaderboards.d.ts +8 -1
- package/dist/resetLeaderboards.js +43 -8
- package/dist/roomLogs.d.ts +1 -0
- package/dist/roomLogs.js +30 -6
- package/dist/save-deck.d.ts +32 -2
- package/dist/save-deck.js +240 -39
- package/kits/base/CLAUDE.md +1 -1
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +174 -6
- package/kits/base/sdk/analytics.d.ts +8 -0
- package/kits/base/sdk/analytics.js +92 -0
- package/kits/base/sdk/castle.d.ts +5 -1
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +48 -0
- package/kits/base/sdk/commands.js +1 -0
- package/kits/base/sdk/debugConsole.d.ts +17 -0
- package/kits/base/sdk/debugConsole.js +154 -0
- package/kits/base/sdk/experiments.js +24 -1
- package/kits/base/sdk/hostRetry.d.ts +7 -0
- package/kits/base/sdk/hostRetry.js +57 -0
- package/kits/base/sdk/hub.d.ts +20 -2
- package/kits/base/sdk/hub.js +99 -13
- package/kits/base/sdk/multiplayer.d.ts +2 -0
- package/kits/base/sdk/multiplayer.js +168 -26
- package/kits/base/sdk/reconnectBudget.d.ts +6 -0
- package/kits/base/sdk/reconnectBudget.js +41 -1
- package/kits/base/sdk/runtime.js +36 -19
- package/kits/base/sdk/server/hub.d.ts +19 -0
- package/kits/base/sdk/server/hub.js +12 -0
- package/kits/base/sdk/server/platformHandle.d.ts +1 -0
- package/kits/base/sdk/server/wrapper.d.ts +1 -1
- package/kits/base/sdk/server/wrapper.js +26 -1
- package/kits/base/sdk/transport.d.ts +2 -1
- package/kits/base/sdk/transport.js +35 -0
- package/kits/hub-game/CLAUDE.md +66 -19
- package/kits/hub-game/code/client/act.js +9 -6
- package/kits/hub-game/code/client/actCore.js +26 -6
- package/kits/hub-game/code/client/actGateLog.js +36 -0
- package/kits/hub-game/code/client/actionOverflow.js +29 -8
- package/kits/hub-game/code/client/actionRailSurface.js +186 -0
- package/kits/hub-game/code/client/actionRailTree.js +173 -0
- package/kits/hub-game/code/client/askSurface.js +85 -0
- package/kits/hub-game/code/client/askTree.js +51 -0
- package/kits/hub-game/code/client/attention.js +31 -6
- package/kits/hub-game/code/client/ballot.js +42 -5
- package/kits/hub-game/code/client/ballotSurface.js +115 -0
- package/kits/hub-game/code/client/ballotTree.js +180 -0
- package/kits/hub-game/code/client/catchingUp.js +19 -0
- package/kits/hub-game/code/client/celebrate.js +66 -0
- package/kits/hub-game/code/client/chrome.js +481 -57
- package/kits/hub-game/code/client/companion.js +93 -23
- package/kits/hub-game/code/client/companionDress.js +1 -1
- package/kits/hub-game/code/client/cornerSurface.js +106 -0
- package/kits/hub-game/code/client/cornerTree.js +83 -0
- package/kits/hub-game/code/client/decor.js +20 -11
- package/kits/hub-game/code/client/deviceStorage.js +121 -0
- package/kits/hub-game/code/client/disguise.js +23 -0
- package/kits/hub-game/code/client/disguiseDraw.js +87 -0
- package/kits/hub-game/code/client/dockSurface.js +206 -0
- package/kits/hub-game/code/client/dockTree.js +232 -0
- package/kits/hub-game/code/client/earned.js +29 -0
- package/kits/hub-game/code/client/emoteSurface.js +188 -0
- package/kits/hub-game/code/client/emoteTree.js +264 -0
- package/kits/hub-game/code/client/farAvatars.js +4 -3
- package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
- package/kits/hub-game/code/client/grab.js +121 -50
- package/kits/hub-game/code/client/holdShow.js +19 -0
- package/kits/hub-game/code/client/hookLayer.js +96 -12
- package/kits/hub-game/code/client/hubControls.js +7 -1
- package/kits/hub-game/code/client/hudSurface.js +11 -3
- package/kits/hub-game/code/client/hudTree.js +7 -4
- package/kits/hub-game/code/client/idle.js +21 -3
- package/kits/hub-game/code/client/invites.js +24 -3
- package/kits/hub-game/code/client/keys.js +15 -0
- package/kits/hub-game/code/client/labelsNear.js +8 -1
- package/kits/hub-game/code/client/layoutCache.js +57 -8
- package/kits/hub-game/code/client/loadingCover.js +53 -4
- package/kits/hub-game/code/client/menuIcons.js +15 -0
- package/kits/hub-game/code/client/menuSurface.js +102 -0
- package/kits/hub-game/code/client/menuTree.js +135 -0
- package/kits/hub-game/code/client/modelLook.js +41 -0
- package/kits/hub-game/code/client/padCues.js +11 -7
- package/kits/hub-game/code/client/padReadability.js +3 -3
- package/kits/hub-game/code/client/pickerSurface.js +152 -0
- package/kits/hub-game/code/client/pickerTree.js +163 -0
- package/kits/hub-game/code/client/pushVisit.js +4 -2
- package/kits/hub-game/code/client/quality.js +188 -29
- package/kits/hub-game/code/client/qualityEntry.js +10 -1
- package/kits/hub-game/code/client/quickChatSurface.js +222 -0
- package/kits/hub-game/code/client/quickChatTree.js +201 -0
- package/kits/hub-game/code/client/rehello.js +75 -0
- package/kits/hub-game/code/client/renderVisibility.js +17 -0
- package/kits/hub-game/code/client/replay.js +118 -0
- package/kits/hub-game/code/client/role.js +3 -0
- package/kits/hub-game/code/client/safeLayout.js +441 -56
- package/kits/hub-game/code/client/safeStyle.js +13 -10
- package/kits/hub-game/code/client/say.js +2 -0
- package/kits/hub-game/code/client/soundSurface.js +77 -0
- package/kits/hub-game/code/client/soundTree.js +74 -0
- package/kits/hub-game/code/client/soundscape.js +12 -9
- package/kits/hub-game/code/client/soundscapeCues.js +1 -1
- package/kits/hub-game/code/client/state.js +67 -1
- package/kits/hub-game/code/client/stuckSurface.js +76 -0
- package/kits/hub-game/code/client/stuckTree.js +67 -0
- package/kits/hub-game/code/client/talk.js +42 -12
- package/kits/hub-game/code/client/talkTree.js +4 -2
- package/kits/hub-game/code/client/textAskSurface.js +147 -0
- package/kits/hub-game/code/client/textAskTree.js +67 -0
- package/kits/hub-game/code/client/tiers.js +252 -27
- package/kits/hub-game/code/client/together.js +4 -1
- package/kits/hub-game/code/client/uiDom.js +86 -8
- package/kits/hub-game/code/client/uiTree.js +33 -4
- package/kits/hub-game/code/client/vehicle.js +72 -51
- package/kits/hub-game/code/client/weakestTier.js +75 -31
- package/kits/hub-game/code/client/wear.js +159 -5
- package/kits/hub-game/code/client/worldLabels.js +205 -25
- package/kits/hub-game/code/companionSpec.js +4 -2
- package/kits/hub-game/code/server/act.js +3 -0
- package/kits/hub-game/code/server/actGate.js +83 -0
- package/kits/hub-game/code/server/actions.js +71 -15
- package/kits/hub-game/code/server/actors.js +20 -5
- package/kits/hub-game/code/server/analytics.js +35 -3
- package/kits/hub-game/code/server/ask.js +39 -3
- package/kits/hub-game/code/server/ballot.js +167 -4
- package/kits/hub-game/code/server/celebrate.js +64 -0
- package/kits/hub-game/code/server/companion.js +17 -2
- package/kits/hub-game/code/server/decor.js +11 -2
- package/kits/hub-game/code/server/disguise.js +63 -0
- package/kits/hub-game/code/server/earned.js +6 -2
- package/kits/hub-game/code/server/friendBests.js +13 -4
- package/kits/hub-game/code/server/friendsAmong.js +67 -8
- package/kits/hub-game/code/server/grab.js +12 -2
- package/kits/hub-game/code/server/heldOffers.js +142 -0
- package/kits/hub-game/code/server/holdShow.js +98 -0
- package/kits/hub-game/code/server/hub.js +991 -72
- package/kits/hub-game/code/server/idle.js +110 -9
- package/kits/hub-game/code/server/index.js +9 -0
- package/kits/hub-game/code/server/labels.js +13 -3
- package/kits/hub-game/code/server/manifest.js +94 -6
- package/kits/hub-game/code/server/menu.js +26 -3
- package/kits/hub-game/code/server/npcs.js +55 -9
- package/kits/hub-game/code/server/observe.js +67 -6
- package/kits/hub-game/code/server/players.js +14 -2
- package/kits/hub-game/code/server/replay.js +135 -0
- package/kits/hub-game/code/server/standing.js +7 -3
- package/kits/hub-game/code/server/storageLimit.js +4 -1
- package/kits/hub-game/code/server/townDay.js +74 -0
- package/kits/hub-game/code/server/vehicle.js +3 -0
- package/kits/hub-game/code/server/vis.js +26 -4
- package/kits/hub-game/code/server/wallet.js +677 -0
- package/kits/hub-game/code/server/wear.js +13 -3
- package/kits/hub-game/code/server/writerLease.js +191 -0
- package/kits/hub-game/code/shared/act.js +1 -1
- package/kits/hub-game/code/shared/expression.js +6 -0
- package/kits/hub-game/code/shared/replay.js +37 -0
- package/kits/hub-game/code/systems/hub.js +429 -55
- package/kits/hub-game/docs/analytics.md +16 -2
- package/kits/hub-game/docs/contract.md +956 -101
- package/kits/hub-game/docs/home-pieces.md +5 -6
- package/kits/hub-game/docs/observed-progress.md +49 -1
- package/kits/hub-game/docs/vehicle-preset.md +23 -0
- package/kits/hub-game/index.html +1 -0
- package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
- package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
- package/kits/hub-game/models/hats/cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/captain.pxmodel +3 -3
- package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
- package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
- package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
- package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
- package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
- package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
- package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
- package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
- package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
- package/kits/hub-game/models/hats/straw.pxmodel +3 -3
- package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
- package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
- package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
- package/kits/hub-game/models/hats/witch.pxmodel +3 -3
- package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
- package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
- package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
- package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
- package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
- package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
- package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
- package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
- package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
- package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
- package/kits/hub-game/package-lock.json +3 -3
- package/kits/hub-game/package.json +4 -3
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
- package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
- package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
- package/kits/hub-game/scripts/gen-hats.mjs +1 -1
- package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
- package/kits/hub-game/scripts/pack.mjs +89 -23
- package/kits/hub-game/scripts/test-act-client.mjs +5 -0
- package/kits/hub-game/scripts/test-act-core.mjs +32 -0
- package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
- package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
- package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
- package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
- package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
- package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
- package/kits/hub-game/scripts/test-actions.mjs +24 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -0
- package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
- package/kits/hub-game/scripts/test-analytics.mjs +79 -0
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
- package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
- package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
- package/kits/hub-game/scripts/test-attention.mjs +43 -1
- package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
- package/kits/hub-game/scripts/test-ballot.mjs +421 -4
- package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
- package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
- package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
- package/kits/hub-game/scripts/test-chat.mjs +73 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
- package/kits/hub-game/scripts/test-companion.mjs +110 -3
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
- package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
- package/kits/hub-game/scripts/test-decor.mjs +27 -0
- package/kits/hub-game/scripts/test-device-class.mjs +4 -1
- package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
- package/kits/hub-game/scripts/test-disguise.mjs +176 -0
- package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
- package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
- package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
- package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
- package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
- package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
- package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
- package/kits/hub-game/scripts/test-grab.mjs +10 -1
- package/kits/hub-game/scripts/test-hats.mjs +28 -0
- package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
- package/kits/hub-game/scripts/test-high-only.mjs +3 -3
- package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
- package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
- package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
- package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +119 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +240 -4
- package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
- package/kits/hub-game/scripts/test-idle.mjs +160 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
- package/kits/hub-game/scripts/test-labels.mjs +11 -0
- package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
- package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
- package/kits/hub-game/scripts/test-manifest.mjs +27 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +54 -5
- package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
- package/kits/hub-game/scripts/test-npcs.mjs +128 -0
- package/kits/hub-game/scripts/test-observed.mjs +171 -3
- package/kits/hub-game/scripts/test-pack.mjs +166 -0
- package/kits/hub-game/scripts/test-pad-cues.mjs +39 -0
- package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
- package/kits/hub-game/scripts/test-placeat-server.mjs +648 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
- package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
- package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
- package/kits/hub-game/scripts/test-quality.mjs +312 -9
- package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
- package/kits/hub-game/scripts/test-rehello.mjs +242 -3
- package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
- package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
- package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
- package/kits/hub-game/scripts/test-replay.mjs +178 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
- package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
- package/kits/hub-game/scripts/test-role-client.mjs +2 -1
- package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
- package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
- package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
- package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
- package/kits/hub-game/scripts/test-standing.mjs +135 -2
- package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
- package/kits/hub-game/scripts/test-stuck.mjs +36 -1
- package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
- package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
- package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
- package/kits/hub-game/scripts/test-tiers.mjs +453 -3
- package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-together.mjs +11 -0
- package/kits/hub-game/scripts/test-town-day.mjs +90 -0
- package/kits/hub-game/scripts/test-try-on.mjs +39 -0
- package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
- package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
- package/kits/hub-game/scripts/test-vehicle-client.mjs +68 -1
- package/kits/hub-game/scripts/test-vis.mjs +145 -0
- package/kits/hub-game/scripts/test-wallet.mjs +650 -0
- package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
- package/kits/hub-game/scripts/test-world-labels.mjs +340 -0
- package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
- package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
- package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
- package/kits/hub-game/tools/hubScene/export.mjs +6 -5
- package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
- package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +36 -2
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +10 -2
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/resumeGate.js +66 -2
- package/kits/multiplayer-3d/code/server/ownership.js +25 -6
- package/kits/multiplayer-3d/code/server/world.js +19 -4
- package/kits/multiplayer-3d/code/systems/multiplayer.js +108 -18
- package/kits/multiplayer-3d/package-lock.json +1 -1
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
- package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +417 -5
- package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +10 -2
- package/kits/physics-3d/CLAUDE.md +14 -0
- package/kits/physics-3d/behaviors/Player.jsx +39 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-model-cache.md +109 -0
- package/kits/physics-3d/docs/engine-player.md +76 -0
- package/kits/physics-3d/docs/engine-skip-work.md +16 -0
- package/kits/physics-3d/docs/pxmodel-format.md +5 -1
- package/kits/physics-3d/engine3d/gait.js +16 -8
- package/kits/physics-3d/engine3d/groundsize.js +23 -0
- package/kits/physics-3d/engine3d/kithooks.js +50 -0
- package/kits/physics-3d/engine3d/look.js +110 -17
- package/kits/physics-3d/engine3d/lookbake.js +19 -1
- package/kits/physics-3d/engine3d/materialpresets.js +3 -2
- package/kits/physics-3d/engine3d/modelcache.js +280 -0
- package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
- package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
- package/kits/physics-3d/engine3d/modelrefs.js +13 -0
- package/kits/physics-3d/engine3d/optimize.js +20 -9
- package/kits/physics-3d/engine3d/playerRun.js +26 -1
- package/kits/physics-3d/engine3d/pxmodel.js +7 -3
- package/kits/physics-3d/engine3d/templatecache.js +722 -0
- package/kits/physics-3d/engine3d/world3d.js +211 -17
- package/kits/physics-3d/package-lock.json +1 -1
- package/kits/physics-3d/package.json +2 -1
- package/kits/physics-3d/play/behaviors/Player.js +43 -3
- package/kits/physics-3d/scripts/render.mjs +56 -8
- package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
- package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
- package/kits/physics-3d/scripts/test-coaxial-escape.mjs +176 -0
- package/kits/physics-3d/scripts/test-gait.mjs +53 -9
- package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
- package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
- package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
- package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
- package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
- package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
- package/kits/physics-3d/systems/physics3d.js +59 -2
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +3 -0
- package/package.json +2 -2
- package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
|
@@ -1,52 +1,57 @@
|
|
|
1
1
|
// Vehicle preset, contract v1.160. The driver's existing capsule is the car.
|
|
2
|
-
import {
|
|
3
|
-
import { buildModelNode, parseModelCached } from '@imports/castle.physics-3d/engine3d/pxmodel';
|
|
4
|
-
import { copyModel, takeModel, releaseModel } from '@imports/castle.physics-3d/engine3d/optimize';
|
|
2
|
+
import { modelLook } from './modelLook.js';
|
|
5
3
|
import { vehicleOf } from '../shared/car.js';
|
|
6
4
|
import { actorFor, pinRiders } from './riders.js';
|
|
7
5
|
import { bumperBlocked, carInput, stepCar } from './car.js';
|
|
8
6
|
import { hub } from './state.js';
|
|
9
7
|
|
|
10
8
|
const DEG = Math.PI / 180;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
// Under the orbit key (physics-3d engine-camera.md) the Player's camDistance
|
|
10
|
+
// and camHeight do not move the camera, so a car there is chased here, as the
|
|
11
|
+
// native host chases it (hub_render_bridge): behind the car's heading eased
|
|
12
|
+
// at CHASE_RATE, at the car's cam or CAM_SCALE times the orbit's own walking
|
|
13
|
+
// distance and height, looking ORBIT_LOOK over the car. The player's orbit
|
|
14
|
+
// choice (zoom, tilt) is left as it was and takes over again on the way out.
|
|
15
|
+
const CHASE_RATE = 4, CAM_SCALE = 1.4, ORBIT_LOOK = 0.438, ORBIT_START = 3.65, ORBIT_PITCH = 15 * DEG;
|
|
16
|
+
const arc = (a) => Math.atan2(Math.sin(a), Math.cos(a));
|
|
17
|
+
function chaseCam(scene, car, player) {
|
|
18
|
+
if (scene.cameraControl !== 'orbit') {return { distance: player.camDistance, height: player.camHeight, look: 0.5 };}
|
|
19
|
+
const range = Number.isFinite(scene.cameraOrbit?.range) ? scene.cameraOrbit.range : ORBIT_START;
|
|
20
|
+
const pitch = Number.isFinite(scene.cameraOrbit?.pitch) ? scene.cameraOrbit.pitch : ORBIT_PITCH;
|
|
21
|
+
return {
|
|
22
|
+
distance: car.cam?.distance ?? range * Math.cos(pitch) * CAM_SCALE,
|
|
23
|
+
height: car.cam?.height ?? (range * Math.sin(pitch) + ORBIT_LOOK) * CAM_SCALE,
|
|
24
|
+
look: ORBIT_LOOK,
|
|
21
25
|
};
|
|
22
|
-
for (const part of data.parts ?? []) {visit(part);}
|
|
23
|
-
return JSON.stringify(data);
|
|
24
26
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
export { actorFor, pinRiders };
|
|
28
|
+
|
|
29
|
+
// v1.165 fix: a server placement of the driver (`hub.placeAt` / `hub.hold`
|
|
30
|
+
// with a facing, a reset, the grid) reaches this client only as its own
|
|
31
|
+
// clamped pose row, `[id, x, y, z, facing, 1]`, whose position multiplayer
|
|
32
|
+
// applies and whose facing it leaves to the local controller. The car's
|
|
33
|
+
// heading is the local Transform's, so without this a placed kart kept the
|
|
34
|
+
// heading it was walked or driven in. `hub.selfClamp` (hookLayer `state`)
|
|
35
|
+
// keeps the newest such row; the next car step takes its facing, from rest,
|
|
36
|
+
// when the clamp is a placement: the driver is held, or the facing turns the
|
|
37
|
+
// car by more than PLACED_TURN, or the clamp moved it more than PLACED_M. An
|
|
38
|
+
// ordinary refused move (a facing within a few degrees of the car's, a small
|
|
39
|
+
// step) is left to multiplayer's easing as before. No wire field is added.
|
|
40
|
+
export const PLACED_TURN = 20 * DEG;
|
|
41
|
+
export const PLACED_M = 1;
|
|
42
|
+
const PLACED_FRESH_MS = 1000;
|
|
43
|
+
export function placedHeading(clamp, before, { held = false, at = null, now = 0 } = {}) {
|
|
44
|
+
if (!clamp || !Number.isFinite(clamp.facing) || now - clamp.at > PLACED_FRESH_MS) {return null;}
|
|
45
|
+
const turn = Math.abs(Math.atan2(Math.sin(clamp.facing - before.heading), Math.cos(clamp.facing - before.heading)));
|
|
46
|
+
const moved = at ? Math.hypot(clamp.x - at.x, clamp.z - at.z) : 0;
|
|
47
|
+
return held || turn > PLACED_TURN || moved > PLACED_M ? { speed: 0, heading: clamp.facing } : null;
|
|
32
48
|
}
|
|
49
|
+
|
|
50
|
+
export { tintPaint } from './modelLook.js';
|
|
33
51
|
export function carLook(scene, car) {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const tinted = tintPaint(text, car.color), parsed = parseModelCached(tinted);
|
|
38
|
-
if (!parsed) {return null;}
|
|
39
|
-
let builds = buildsOf.get(scene.three);
|
|
40
|
-
if (!builds) {builds = new Map(); buildsOf.set(scene.three, builds);}
|
|
41
|
-
const key = `${model.file}:${tinted}`;
|
|
42
|
-
const template = takeModel(builds, key, () => buildModelNode(parsed, scene.sprites, scene.files, model.file, [model.file], { optimize: true }));
|
|
43
|
-
const group = new Group(), copy = copyModel(template);
|
|
44
|
-
group.name = 'hub:car';
|
|
45
|
-
copy.scale.setScalar(model.scale ?? 1);
|
|
46
|
-
copy.position.y = model.yOffset ?? 0;
|
|
47
|
-
group.position.set(...car.seats[0].map(v => -v));
|
|
48
|
-
group.add(copy);
|
|
49
|
-
return { group, release: () => {group.removeFromParent(); releaseModel(builds, key, disposeTree);} };
|
|
52
|
+
const look = modelLook(scene, car.look, car.color);
|
|
53
|
+
if (look) {look.group.name = 'hub:car'; look.group.position.set(...car.seats[0].map(v => -v));}
|
|
54
|
+
return look;
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
// What a drawn look depends on: riders getting in or out do not rebuild it.
|
|
@@ -64,7 +69,7 @@ function lookKey(car) {
|
|
|
64
69
|
|
|
65
70
|
export function makeVehicle() {
|
|
66
71
|
const drawn = new Map();
|
|
67
|
-
let installed = null, saved = null, carState = null, lastCar = null;
|
|
72
|
+
let installed = null, saved = null, carState = null, lastCar = null, chase = null;
|
|
68
73
|
function clearDrive() {
|
|
69
74
|
if (installed) {
|
|
70
75
|
const { scene, seam, previous, player, camera } = installed;
|
|
@@ -73,7 +78,7 @@ export function makeVehicle() {
|
|
|
73
78
|
}
|
|
74
79
|
if (player) {player.camDistance = camera.distance; player.camHeight = camera.height;}
|
|
75
80
|
}
|
|
76
|
-
installed = null; saved = null; carState = null; lastCar = null;
|
|
81
|
+
installed = null; saved = null; carState = null; lastCar = null; chase = null;
|
|
77
82
|
}
|
|
78
83
|
const api = {
|
|
79
84
|
frame(scene, local, cars, on = true) {
|
|
@@ -94,7 +99,12 @@ export function makeVehicle() {
|
|
|
94
99
|
const controls = carInput(input.keys, input.stick);
|
|
95
100
|
const stopped = hub.held.has(id);
|
|
96
101
|
const jumped = carState && Math.hypot(t.x - carState.x, t.z - carState.z) > 3;
|
|
97
|
-
|
|
102
|
+
let before = { speed: stopped || jumped ? 0 : carState?.speed ?? 0, heading: (t.rotationY ?? 0) * DEG };
|
|
103
|
+
if (hub.selfClamp) {
|
|
104
|
+
const placed = placedHeading(hub.selfClamp, before, { held: stopped, at: carState, now: performance.now() });
|
|
105
|
+
hub.selfClamp = null;
|
|
106
|
+
if (placed) {before = placed;}
|
|
107
|
+
}
|
|
98
108
|
const direction = { x: Math.sin(before.heading), y: 0, z: Math.cos(before.heading) };
|
|
99
109
|
// Players do not stop a car, but what stands behind one does: the
|
|
100
110
|
// ray passes over every avatar's collider (physics-3d's `skip`).
|
|
@@ -122,8 +132,12 @@ export function makeVehicle() {
|
|
|
122
132
|
// any change to how it drives starts it from rest.
|
|
123
133
|
const signature = JSON.stringify({ ...car, riders: undefined, look: undefined, color: undefined });
|
|
124
134
|
if (lastCar !== signature) {carState = null; lastCar = signature;}
|
|
125
|
-
|
|
126
|
-
|
|
135
|
+
// Under the orbit key the chase below places the camera; writing these
|
|
136
|
+
// would only restart the player's orbit zoom and tilt.
|
|
137
|
+
if (scene.cameraControl !== 'orbit') {
|
|
138
|
+
player.camDistance = car.cam?.distance ?? saved.distance * CAM_SCALE;
|
|
139
|
+
player.camHeight = car.cam?.height ?? saved.height * CAM_SCALE;
|
|
140
|
+
}
|
|
127
141
|
return mine;
|
|
128
142
|
},
|
|
129
143
|
draw(scene, local, cars) {
|
|
@@ -140,15 +154,22 @@ export function makeVehicle() {
|
|
|
140
154
|
}
|
|
141
155
|
},
|
|
142
156
|
// A local rider follows the driver's drawn centre, at this car's camera
|
|
143
|
-
// distance/height
|
|
157
|
+
// distance/height; under the orbit key the driver is chased too (above).
|
|
158
|
+
// Run after multiplayer has placed the driver's avatar.
|
|
144
159
|
camera(scene, local, cars) {
|
|
145
|
-
const id = scene.multiplayer?.net?.selfId?.(), mine = vehicleOf(cars, id);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
160
|
+
const id = scene.multiplayer?.net?.selfId?.(), mine = vehicleOf(cars, id), orbit = scene.cameraControl === 'orbit';
|
|
161
|
+
// A moment shot (`hub.shot`, a deck's `scene.orbitShot`) owns the camera while it lasts.
|
|
162
|
+
if (!mine || (mine.driver && !orbit) || (orbit && scene.orbitShot)) {chase = null; return;}
|
|
163
|
+
const t = (mine.driver ? local : actorFor(scene, local, mine.of))?.components.Transform;
|
|
164
|
+
const car = cars[mine.driver ? id : mine.of], cam = scene.three?.camera, player = local?.components.Player;
|
|
165
|
+
if (!t || !car || !cam || !player) {return;}
|
|
166
|
+
const heading = (t.rotationY ?? 0) * DEG, now = performance.now();
|
|
167
|
+
let a = heading;
|
|
168
|
+
if (orbit && chase) {a = chase.yaw + arc(heading - chase.yaw) * (1 - Math.exp(-CHASE_RATE * Math.min(0.1, Math.max(0, (now - chase.at) / 1000))));}
|
|
169
|
+
chase = orbit ? { yaw: a, at: now } : null;
|
|
170
|
+
const { distance, height, look } = chaseCam(scene, car, player);
|
|
171
|
+
cam.position.set(t.x - Math.sin(a) * distance, t.y + height, t.z - Math.cos(a) * distance);
|
|
172
|
+
cam.lookAt(t.x, t.y + look, t.z);
|
|
152
173
|
},
|
|
153
174
|
clear() {clearDrive(); for (const entry of drawn.values()) {entry.release();} drawn.clear();},
|
|
154
175
|
};
|
|
@@ -63,6 +63,15 @@ function simplifiedFiles(files) {
|
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
// quality.js mindDue's default edge for far NPCs on Low.
|
|
67
|
+
export const RESIDENT_SIGHT_M = 20;
|
|
68
|
+
const PREWARM_OPTIONS = { budgetMs: 4 };
|
|
69
|
+
// TECNO (Middle), measured: building every frame from 3 s after join doubled the
|
|
70
|
+
// first 15 s's frame times. Wait out the join, then one slice per step.
|
|
71
|
+
const PREWARM_DELAY_MS = 15000;
|
|
72
|
+
const PREWARM_STEP_MS = 100;
|
|
73
|
+
const PREWARM_IDLE_CHECK_MS = 250;
|
|
74
|
+
|
|
66
75
|
// Middle shares only district sleep with Weakest, and halves Low's buffers.
|
|
67
76
|
export function makeWeakestTier({ profile = 'weakest' } = {}) {
|
|
68
77
|
const middle = profile === 'middle';
|
|
@@ -74,6 +83,7 @@ export function makeWeakestTier({ profile = 'weakest' } = {}) {
|
|
|
74
83
|
let cheapFiles = null;
|
|
75
84
|
let cheapSnapshot = null;
|
|
76
85
|
let nextAt = -Infinity;
|
|
86
|
+
let prewarmAt = Infinity;
|
|
77
87
|
const asleep = new Map();
|
|
78
88
|
let ownsBake = false;
|
|
79
89
|
let ownsEmptyParts = false;
|
|
@@ -96,6 +106,11 @@ export function makeWeakestTier({ profile = 'weakest' } = {}) {
|
|
|
96
106
|
}
|
|
97
107
|
resolution = null;
|
|
98
108
|
}
|
|
109
|
+
release();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Everything but the buffers: wakes the town and returns its model files.
|
|
113
|
+
function release() {
|
|
99
114
|
for (const actor of asleep.values()) {
|
|
100
115
|
// The runtime checks identity, so replaced actors/loads cannot inherit
|
|
101
116
|
// a wake, while a data edit cannot strand an actor this profile slept.
|
|
@@ -142,22 +157,54 @@ export function makeWeakestTier({ profile = 'weakest' } = {}) {
|
|
|
142
157
|
}
|
|
143
158
|
held = source = map = districts = originalFiles = cheapFiles = cheapSnapshot = null;
|
|
144
159
|
nextAt = -Infinity;
|
|
160
|
+
prewarmAt = Infinity;
|
|
145
161
|
ownsBake = false;
|
|
146
162
|
ownsEmptyParts = false;
|
|
147
163
|
active = false;
|
|
148
164
|
district = null;
|
|
149
165
|
}
|
|
150
166
|
|
|
151
|
-
|
|
167
|
+
// The profile's cheap buffers, set once and held until restore.
|
|
168
|
+
function cap(scene) {
|
|
169
|
+
const renderer = scene.three?.renderer;
|
|
170
|
+
const composer = scene.three?.composer;
|
|
152
171
|
if (
|
|
153
|
-
!
|
|
154
|
-
typeof
|
|
155
|
-
|
|
156
|
-
|
|
172
|
+
!resolution &&
|
|
173
|
+
typeof renderer?.getPixelRatio === 'function' &&
|
|
174
|
+
typeof renderer.setPixelRatio === 'function' &&
|
|
175
|
+
typeof composer?.setPixelRatio === 'function' &&
|
|
176
|
+
Number.isFinite(composer._pixelRatio)
|
|
157
177
|
) {
|
|
178
|
+
const pixelRatio = renderer.getPixelRatio();
|
|
179
|
+
if (Number.isFinite(pixelRatio) && pixelRatio > 0) {
|
|
180
|
+
const cheapRatio = middle ? pixelRatio * 0.5 : Math.min(pixelRatio, composer._pixelRatio, 0.5);
|
|
181
|
+
const cheapComposerRatio = middle ? composer._pixelRatio * 0.5 : cheapRatio;
|
|
182
|
+
resolution = {
|
|
183
|
+
renderer,
|
|
184
|
+
composer,
|
|
185
|
+
pixelRatio,
|
|
186
|
+
composerRatio: composer._pixelRatio,
|
|
187
|
+
cheapRatio,
|
|
188
|
+
cheapComposerRatio,
|
|
189
|
+
};
|
|
190
|
+
renderer.setPixelRatio(cheapRatio);
|
|
191
|
+
composer.setPixelRatio(cheapComposerRatio);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function frame(scene, enabled, now, bounded = false, pointerTargets = null) {
|
|
197
|
+
if (!enabled || typeof scene.setActorSleeping !== 'function' || scene.requestedScene) {
|
|
158
198
|
restore();
|
|
159
199
|
return;
|
|
160
200
|
}
|
|
201
|
+
// A game through a door wakes the town but keeps the profile's buffers:
|
|
202
|
+
// on the moto (weakest) door games drew at 1.75 against the Town's 0.5.
|
|
203
|
+
if (scene.content) {
|
|
204
|
+
release();
|
|
205
|
+
cap(scene);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
161
208
|
if (held !== scene || source !== scene.data || map !== scene.actors || wantsBoundedLook !== bounded) {
|
|
162
209
|
restore();
|
|
163
210
|
districts = readDistricts(scene.data?.weakestDistricts);
|
|
@@ -168,6 +215,7 @@ export function makeWeakestTier({ profile = 'weakest' } = {}) {
|
|
|
168
215
|
held = scene;
|
|
169
216
|
source = scene.data;
|
|
170
217
|
map = scene.actors;
|
|
218
|
+
prewarmAt = now + PREWARM_DELAY_MS;
|
|
171
219
|
if (!middle && scene.three) {
|
|
172
220
|
scene.three.lookBake ??= makeLookBake();
|
|
173
221
|
bakeQueue = scene.three.lookBake;
|
|
@@ -204,31 +252,7 @@ export function makeWeakestTier({ profile = 'weakest' } = {}) {
|
|
|
204
252
|
ownsEmptyParts = true;
|
|
205
253
|
Object.defineProperty(scene, 'dropsEmptyParts', { value: true, configurable: true });
|
|
206
254
|
}
|
|
207
|
-
|
|
208
|
-
const composer = scene.three?.composer;
|
|
209
|
-
if (
|
|
210
|
-
!resolution &&
|
|
211
|
-
typeof renderer?.getPixelRatio === 'function' &&
|
|
212
|
-
typeof renderer.setPixelRatio === 'function' &&
|
|
213
|
-
typeof composer?.setPixelRatio === 'function' &&
|
|
214
|
-
Number.isFinite(composer._pixelRatio)
|
|
215
|
-
) {
|
|
216
|
-
const pixelRatio = renderer.getPixelRatio();
|
|
217
|
-
if (Number.isFinite(pixelRatio) && pixelRatio > 0) {
|
|
218
|
-
const cheapRatio = middle ? pixelRatio * 0.5 : Math.min(pixelRatio, composer._pixelRatio, 0.5);
|
|
219
|
-
const cheapComposerRatio = middle ? composer._pixelRatio * 0.5 : cheapRatio;
|
|
220
|
-
resolution = {
|
|
221
|
-
renderer,
|
|
222
|
-
composer,
|
|
223
|
-
pixelRatio,
|
|
224
|
-
composerRatio: composer._pixelRatio,
|
|
225
|
-
cheapRatio,
|
|
226
|
-
cheapComposerRatio,
|
|
227
|
-
};
|
|
228
|
-
renderer.setPixelRatio(cheapRatio);
|
|
229
|
-
composer.setPixelRatio(cheapComposerRatio);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
255
|
+
cap(scene);
|
|
232
256
|
// Labels and goal pointers read retained components through getActor,
|
|
233
257
|
// but keep their targets' behaviors and NPCs live too. A newly received
|
|
234
258
|
// target wakes immediately, even inside the district check interval.
|
|
@@ -239,6 +263,16 @@ export function makeWeakestTier({ profile = 'weakest' } = {}) {
|
|
|
239
263
|
asleep.delete(id);
|
|
240
264
|
}
|
|
241
265
|
}
|
|
266
|
+
if (now >= prewarmAt) {
|
|
267
|
+
// The world's own methods: an engine older than parking has none.
|
|
268
|
+
const world = scene.three;
|
|
269
|
+
if (typeof world?.needsSleepingModelPrewarm === 'function' && world.needsSleepingModelPrewarm(scene)) {
|
|
270
|
+
world.prewarmSleepingModels(scene, PREWARM_OPTIONS);
|
|
271
|
+
}
|
|
272
|
+
// One slice per step until done. Afterwards, mutable actor Models and
|
|
273
|
+
// asset readiness need a scan at most four times a second.
|
|
274
|
+
prewarmAt = now + (scene.three?.sleepingModelPrewarm?.done ? PREWARM_IDLE_CHECK_MS : PREWARM_STEP_MS);
|
|
275
|
+
}
|
|
242
276
|
if (district === cell && now < nextAt) {
|
|
243
277
|
return;
|
|
244
278
|
}
|
|
@@ -266,7 +300,13 @@ export function makeWeakestTier({ profile = 'weakest' } = {}) {
|
|
|
266
300
|
dx === 0 && dz === 0
|
|
267
301
|
? row.districts.includes(cell)
|
|
268
302
|
: insideOutline(districts.table.byId.get(cell).outline, c.Transform?.x, c.Transform?.z);
|
|
269
|
-
|
|
303
|
+
// A resident walked off its authored spot stays drawn across a district
|
|
304
|
+
// line within Low's far-NPC edge, so a schedule walker does not pop out
|
|
305
|
+
// mid-street; it holds 2 m longer once awake.
|
|
306
|
+
const walker = Boolean(c.HubNpc) && (dx !== 0 || dz !== 0);
|
|
307
|
+
const sight = asleep.has(id) ? RESIDENT_SIGHT_M : RESIDENT_SIGHT_M + 2;
|
|
308
|
+
const seen = walker && (c.Transform.x - p.x) ** 2 + (c.Transform.z - p.z) ** 2 <= sight * sight;
|
|
309
|
+
const want = protectedActor || (!hiddenTemplate && (sameDistrict || near || seen));
|
|
270
310
|
if (want) {
|
|
271
311
|
if (asleep.has(id)) {
|
|
272
312
|
scene.setActorSleeping(actor, false);
|
|
@@ -285,6 +325,10 @@ export function makeWeakestTier({ profile = 'weakest' } = {}) {
|
|
|
285
325
|
get active() {
|
|
286
326
|
return active;
|
|
287
327
|
},
|
|
328
|
+
// Holding cheap buffers (in the town's districts or a door's game).
|
|
329
|
+
get capped() {
|
|
330
|
+
return resolution !== null;
|
|
331
|
+
},
|
|
288
332
|
get district() {
|
|
289
333
|
return district;
|
|
290
334
|
},
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
// has no node for yet (its model still coming) wears nothing until it has one,
|
|
23
23
|
// and a node rebuilt (another avatar chosen) is worn on again.
|
|
24
24
|
|
|
25
|
+
import { disguiseBody } from './disguise.js';
|
|
25
26
|
import * as THREE from 'three';
|
|
26
27
|
// A namespace, not a named import: `bakingLater` is in a physics-3d from
|
|
27
28
|
// 2026-10-04 on, and a deck pinned to one before it bundles and bakes now.
|
|
@@ -29,7 +30,8 @@ import * as Look from '@imports/castle.physics-3d/engine3d/look';
|
|
|
29
30
|
import { buildModelNode, parseModelCached } from '@imports/castle.physics-3d/engine3d/pxmodel';
|
|
30
31
|
import { copyModel, releaseModel, takeModel } from '@imports/castle.physics-3d/engine3d/optimize';
|
|
31
32
|
import { hatId } from './hats.js';
|
|
32
|
-
import { earnedLook, tinted } from './earned.js';
|
|
33
|
+
import { SPARKLE_MS, SPARKLE_NEAR_M, badgeGrow, earnedLook, phoneView, tinted } from './earned.js';
|
|
34
|
+
import { holdShowLook } from './holdShow.js';
|
|
33
35
|
import { ROLE_MAIN, roleLook, rolePieces } from './role.js';
|
|
34
36
|
|
|
35
37
|
// Heights from the avatar's origin, the capsule's centre: the model's feet,
|
|
@@ -198,6 +200,28 @@ function build(spec, hat) {
|
|
|
198
200
|
return null;
|
|
199
201
|
}
|
|
200
202
|
|
|
203
|
+
// A seat, a bed, a car or an emote moves an avatar's model rig, not its node
|
|
204
|
+
// (idle.js keeps the rig's standing pose in `userData.hubIdleBase`). What is
|
|
205
|
+
// worn hangs on the node, so it is moved by the same change: the rig's pose
|
|
206
|
+
// now over its standing one, before the piece's own placement. Standing, a
|
|
207
|
+
// piece keeps its plain transform.
|
|
208
|
+
const POSE = { now: new THREE.Matrix4(), base: new THREE.Matrix4(), q: new THREE.Quaternion(), e: new THREE.Euler(), v: new THREE.Vector3() };
|
|
209
|
+
function followPose(group, node) {
|
|
210
|
+
const rig = node.children.find((c) => c !== group && c.userData?.hubIdleBase);
|
|
211
|
+
const base = rig?.userData.hubIdleBase, r = rig?.rotation;
|
|
212
|
+
if (!base || (rig.position.y === base.y && (!Object.hasOwn(base, 'z') || rig.position.z === base.z) && r.x === base.rx && r.y === base.ry && r.z === base.rz)) {
|
|
213
|
+
group.matrixAutoUpdate = true;
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
POSE.now.compose(rig.position, rig.quaternion, rig.scale);
|
|
217
|
+
POSE.v.set(rig.position.x, base.y, Object.hasOwn(base, 'z') ? base.z : rig.position.z);
|
|
218
|
+
POSE.base.compose(POSE.v, POSE.q.setFromEuler(POSE.e.set(base.rx, base.ry, base.rz, r.order)), rig.scale).invert();
|
|
219
|
+
group.updateMatrix();
|
|
220
|
+
group.matrix.premultiply(POSE.now.multiply(POSE.base));
|
|
221
|
+
group.matrixAutoUpdate = false;
|
|
222
|
+
group.matrixWorldNeedsUpdate = true;
|
|
223
|
+
}
|
|
224
|
+
|
|
201
225
|
// Moves what moves (a halo's bob, an orbit's beads) to time `t` seconds. A
|
|
202
226
|
// halo turns to face `camera` (world position, or null) from its avatar,
|
|
203
227
|
// whose pose is read from `at` (its Transform: what the engine will put the
|
|
@@ -331,6 +355,8 @@ function buildEarned(spec, world, files, prefix = 'earned') {
|
|
|
331
355
|
glow.renderOrder = 1;
|
|
332
356
|
placed.add(glow);
|
|
333
357
|
group.userData.glow = glow;
|
|
358
|
+
// Grown with distance and sparkled about (`makeItems`): a badge only.
|
|
359
|
+
group.userData.badge = { placed, color: spec.color };
|
|
334
360
|
}
|
|
335
361
|
group.add(placed);
|
|
336
362
|
return group;
|
|
@@ -361,6 +387,77 @@ function glowTexture() {
|
|
|
361
387
|
return glowMap;
|
|
362
388
|
}
|
|
363
389
|
|
|
390
|
+
// A sparkle's star, made once: four thin rays fading out from a soft white
|
|
391
|
+
// core, white so its material tints it.
|
|
392
|
+
let sparkleMap = null;
|
|
393
|
+
function sparkleTexture() {
|
|
394
|
+
if (!sparkleMap) {
|
|
395
|
+
const n = 64;
|
|
396
|
+
const data = new Uint8Array(n * n * 4);
|
|
397
|
+
for (let j = 0; j < n; j += 1) {
|
|
398
|
+
for (let i = 0; i < n; i += 1) {
|
|
399
|
+
const x = Math.abs(i + 0.5 - n / 2) / (n / 2);
|
|
400
|
+
const y = Math.abs(j + 0.5 - n / 2) / (n / 2);
|
|
401
|
+
const core = Math.max(0, 1 - Math.hypot(x, y) / 0.35) ** 2;
|
|
402
|
+
const ray = Math.max(Math.max(0, 1 - x) ** 2 * Math.max(0, 1 - y / 0.08), Math.max(0, 1 - y) ** 2 * Math.max(0, 1 - x / 0.08));
|
|
403
|
+
const at = (j * n + i) * 4;
|
|
404
|
+
data.fill(255, at, at + 3);
|
|
405
|
+
data[at + 3] = Math.round(255 * Math.min(1, core + ray));
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
sparkleMap = new THREE.DataTexture(data, n, n);
|
|
409
|
+
sparkleMap.magFilter = THREE.LinearFilter;
|
|
410
|
+
sparkleMap.minFilter = THREE.LinearFilter;
|
|
411
|
+
sparkleMap.needsUpdate = true;
|
|
412
|
+
}
|
|
413
|
+
return sparkleMap;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// A badge's arrival sparkle: one camera-facing star over the badge, in its
|
|
417
|
+
// colour lifted toward white, added to what is behind it. `tickSparkle`
|
|
418
|
+
// moves it to `k` (0 to 1 through its life): it swells to SPARKLE_PEAK m
|
|
419
|
+
// across in the first quarter, turns, and fades out.
|
|
420
|
+
const SPARKLE_PEAK = 0.9;
|
|
421
|
+
function makeSparkle(color) {
|
|
422
|
+
const sprite = new THREE.Sprite(new THREE.SpriteMaterial({
|
|
423
|
+
color: new THREE.Color(color).lerp(new THREE.Color('#ffffff'), 0.45),
|
|
424
|
+
map: sparkleTexture(),
|
|
425
|
+
transparent: true,
|
|
426
|
+
blending: THREE.AdditiveBlending,
|
|
427
|
+
depthWrite: false,
|
|
428
|
+
toneMapped: false,
|
|
429
|
+
}));
|
|
430
|
+
sprite.name = 'earned:sparkle';
|
|
431
|
+
sprite.position.z = 0.06;
|
|
432
|
+
sprite.renderOrder = 2;
|
|
433
|
+
sprite.scale.setScalar(0);
|
|
434
|
+
return sprite;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
function tickSparkle(sprite, k) {
|
|
438
|
+
const size = SPARKLE_PEAK * (k < 0.25 ? k / 0.25 : 1 - ((k - 0.25) / 0.75) * 0.4);
|
|
439
|
+
sprite.scale.setScalar(size);
|
|
440
|
+
sprite.material.rotation = k * Math.PI * 0.75;
|
|
441
|
+
sprite.material.opacity = k < 0.25 ? 1 : Math.max(0, 1 - (k - 0.25) / 0.75);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function dropSparkle(group) {
|
|
445
|
+
const sprite = group?.userData.sparkle;
|
|
446
|
+
if (sprite) {
|
|
447
|
+
sprite.parent?.remove(sprite);
|
|
448
|
+
sprite.material.dispose();
|
|
449
|
+
group.userData.sparkle = null;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// Where an avatar is this frame, into `out`, from its Transform (what the
|
|
454
|
+
// engine will put the node at: a node just made may not have been placed,
|
|
455
|
+
// its matrices still the origin's), or null when it has none.
|
|
456
|
+
const AT = { a: new THREE.Vector3(), b: new THREE.Vector3(), c: new THREE.Vector3() };
|
|
457
|
+
function transformAt(transform, out) {
|
|
458
|
+
return transform ? out.set(transform.x ?? 0, transform.y ?? 0, transform.z ?? 0) : null;
|
|
459
|
+
}
|
|
460
|
+
|
|
364
461
|
export function makeWear() {
|
|
365
462
|
// playerId -> { json, spec, group, node, world }
|
|
366
463
|
const drawn = new Map();
|
|
@@ -390,11 +487,12 @@ export function makeWear() {
|
|
|
390
487
|
const self = mp?.net?.selfId?.() ?? null;
|
|
391
488
|
const t = now / 1000;
|
|
392
489
|
for (const playerId of [...drawn.keys()]) {
|
|
393
|
-
if (!wearing.has(playerId)) {
|
|
490
|
+
if (!wearing.has(playerId) || disguiseBody(self, playerId)) {
|
|
394
491
|
remove(playerId);
|
|
395
492
|
}
|
|
396
493
|
}
|
|
397
494
|
for (const [playerId, wearable] of wearing) {
|
|
495
|
+
if (disguiseBody(self, playerId)) {continue;}
|
|
398
496
|
const actorId = playerId === self ? local?.id : mp?.avatars?.actors?.get(playerId);
|
|
399
497
|
const node = actorId ? (nodes?.get(actorId)?.node ?? null) : null;
|
|
400
498
|
const top = topOf(playerId);
|
|
@@ -427,6 +525,7 @@ export function makeWear() {
|
|
|
427
525
|
}
|
|
428
526
|
const at = (playerId === self ? local : scene.getActor?.(actorId))?.components?.Transform ?? null;
|
|
429
527
|
animate(entry.group, entry.spec, t, camera, at);
|
|
528
|
+
followPose(entry.group, node);
|
|
430
529
|
}
|
|
431
530
|
},
|
|
432
531
|
|
|
@@ -446,6 +545,11 @@ export function makeWear() {
|
|
|
446
545
|
};
|
|
447
546
|
}
|
|
448
547
|
|
|
548
|
+
// Visit-only flowers share the held-item renderer and build lifecycle.
|
|
549
|
+
export function makeHoldShow() {
|
|
550
|
+
return makeItems(holdShowLook, 'hold-show');
|
|
551
|
+
}
|
|
552
|
+
|
|
449
553
|
// Earned items (v1.53, `earned.js`): drawn as a hat is, on the same node, by
|
|
450
554
|
// `frame(scene, local, earned, fitOf)` with `earned` playerId -> `{ class,
|
|
451
555
|
// shape, color }` and `fitOf(playerId)` that player's avatar's earned fit
|
|
@@ -471,12 +575,16 @@ export function makeRole() {
|
|
|
471
575
|
}
|
|
472
576
|
|
|
473
577
|
function makeItems(lookOf, prefix) {
|
|
474
|
-
// playerId -> { json, group, node, world }
|
|
578
|
+
// playerId -> { json, group, node, world, sparkleAt }
|
|
475
579
|
const drawn = new Map();
|
|
580
|
+
// Players whose badge has been seen near (and sparkled, off Low) in this
|
|
581
|
+
// place: never again until the scene is loaded again or cleared.
|
|
582
|
+
const seen = new Set();
|
|
476
583
|
function remove(playerId) {
|
|
477
584
|
const entry = drawn.get(playerId);
|
|
478
585
|
drawn.delete(playerId);
|
|
479
586
|
if (entry?.group) {
|
|
587
|
+
dropSparkle(entry.group);
|
|
480
588
|
entry.group.parent?.remove(entry.group);
|
|
481
589
|
releaseModel(entry.group.userData.hatBuilds, entry.group.userData.hatKey, disposeTree);
|
|
482
590
|
// The glow's own disc and material; its fall-off texture is shared.
|
|
@@ -491,19 +599,28 @@ function makeItems(lookOf, prefix) {
|
|
|
491
599
|
get size() {
|
|
492
600
|
return drawn.size;
|
|
493
601
|
},
|
|
494
|
-
|
|
602
|
+
// `view`: `phone` (a phone-size viewport: badges grow with distance;
|
|
603
|
+
// this page's window by default), `low` (the Low tier: no sparkle) and
|
|
604
|
+
// `now` (ms).
|
|
605
|
+
frame(scene, local, earned, fitOf = () => null, { phone = phoneView(globalThis.window?.innerWidth, globalThis.window?.innerHeight), low = false, now = performance.now() } = {}) {
|
|
495
606
|
if (earned.size === 0 && drawn.size === 0) {
|
|
496
607
|
return;
|
|
497
608
|
}
|
|
498
609
|
const mp = scene.multiplayer;
|
|
499
610
|
const nodes = scene.three?.nodes;
|
|
500
611
|
const self = mp?.net?.selfId?.() ?? null;
|
|
612
|
+
const camera = scene.three?.camera ?? null;
|
|
613
|
+
// Where "near" is measured from: this player's body.
|
|
614
|
+
const here = transformAt(local?.components?.Transform, AT.b);
|
|
615
|
+
// The camera's world position, as of the last render.
|
|
616
|
+
const eye = camera ? AT.c.setFromMatrixPosition(camera.matrixWorld) : null;
|
|
501
617
|
for (const playerId of [...drawn.keys()]) {
|
|
502
|
-
if (!earned.has(playerId)) {
|
|
618
|
+
if (!earned.has(playerId) || disguiseBody(self, playerId)) {
|
|
503
619
|
remove(playerId);
|
|
504
620
|
}
|
|
505
621
|
}
|
|
506
622
|
for (const [playerId, item] of earned) {
|
|
623
|
+
if (disguiseBody(self, playerId)) {continue;}
|
|
507
624
|
const actorId = playerId === self ? local?.id : mp?.avatars?.actors?.get(playerId);
|
|
508
625
|
const node = actorId ? (nodes?.get(actorId)?.node ?? null) : null;
|
|
509
626
|
if (!node) {
|
|
@@ -526,19 +643,56 @@ function makeItems(lookOf, prefix) {
|
|
|
526
643
|
node.add(entry.group);
|
|
527
644
|
entry.node = node;
|
|
528
645
|
}
|
|
646
|
+
if (entry.group) {followPose(entry.group, node);}
|
|
647
|
+
const badge = entry.group?.userData.badge;
|
|
648
|
+
if (badge) {
|
|
649
|
+
const transform = (playerId === self ? local : scene.getActor?.(actorId))?.components?.Transform;
|
|
650
|
+
frameBadge(entry, badge, playerId !== self ? playerId : null, transformAt(transform, AT.a), here, eye, phone, low, now);
|
|
651
|
+
}
|
|
529
652
|
}
|
|
530
653
|
},
|
|
531
654
|
|
|
532
655
|
forget() {
|
|
656
|
+
seen.clear();
|
|
533
657
|
for (const playerId of [...drawn.keys()]) {
|
|
534
658
|
remove(playerId);
|
|
535
659
|
}
|
|
536
660
|
},
|
|
537
661
|
|
|
538
662
|
clear() {
|
|
663
|
+
seen.clear();
|
|
539
664
|
for (const playerId of [...drawn.keys()]) {
|
|
540
665
|
remove(playerId);
|
|
541
666
|
}
|
|
542
667
|
},
|
|
543
668
|
};
|
|
669
|
+
|
|
670
|
+
// A badge's size for its distance from the camera, and its sparkle: begun
|
|
671
|
+
// the first time another player's badge (`other`, null for this player's
|
|
672
|
+
// own) is within SPARKLE_NEAR_M of `here`, moved on, and taken away once
|
|
673
|
+
// over. `at` is where the badged avatar is (null: unknown, so neither
|
|
674
|
+
// grown nor counted as seen), `here` this player and `eye` the camera.
|
|
675
|
+
function frameBadge(entry, badge, other, at, here, eye, phone, low, now) {
|
|
676
|
+
const grow = phone && eye && at ? badgeGrow(at.distanceTo(eye), true) : 1;
|
|
677
|
+
if (badge.placed.scale.x !== grow) {
|
|
678
|
+
badge.placed.scale.setScalar(grow);
|
|
679
|
+
}
|
|
680
|
+
if (other !== null && !seen.has(other) && here && at && at.distanceTo(here) <= SPARKLE_NEAR_M) {
|
|
681
|
+
seen.add(other);
|
|
682
|
+
if (!low) {
|
|
683
|
+
entry.group.userData.sparkle = makeSparkle(badge.color);
|
|
684
|
+
badge.placed.add(entry.group.userData.sparkle);
|
|
685
|
+
entry.sparkleAt = now;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
const sprite = entry.group.userData.sparkle;
|
|
689
|
+
if (sprite) {
|
|
690
|
+
const k = (now - entry.sparkleAt) / SPARKLE_MS;
|
|
691
|
+
if (k >= 1 || low) {
|
|
692
|
+
dropSparkle(entry.group);
|
|
693
|
+
} else {
|
|
694
|
+
tickSparkle(sprite, Math.max(0, k));
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
544
698
|
}
|