castle-web-cli 0.4.238 → 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 +218 -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 +22 -3
- package/dist/init.js +24 -2
- package/dist/multiplayerDoc.d.ts +1 -1
- package/dist/multiplayerDoc.js +9 -0
- package/dist/platformDoc.js +4 -2
- package/dist/playPagePolicy.d.ts +1 -0
- package/dist/playPagePolicy.js +12 -3
- package/dist/resetLeaderboards.d.ts +8 -1
- package/dist/resetLeaderboards.js +43 -8
- package/dist/roomLogs.d.ts +39 -0
- package/dist/roomLogs.js +166 -0
- package/dist/save-deck.d.ts +32 -2
- package/dist/save-deck.js +240 -39
- package/kits/base/CLAUDE.md +2 -1
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +240 -8
- package/kits/base/sdk/analytics.d.ts +8 -0
- package/kits/base/sdk/analytics.js +92 -0
- package/kits/base/sdk/castle.d.ts +8 -2
- package/kits/base/sdk/castle.js +3 -0
- package/kits/base/sdk/commands.d.ts +79 -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 +198 -26
- package/kits/base/sdk/reconnectBudget.d.ts +6 -0
- package/kits/base/sdk/reconnectBudget.js +41 -1
- package/kits/base/sdk/rooms.d.ts +11 -0
- package/kits/base/sdk/rooms.js +22 -0
- 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/store.d.ts +8 -2
- package/kits/base/sdk/store.js +5 -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/castle.json +4 -4
- 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 +474 -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/menuRows.js +8 -2
- 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 +75 -52
- 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 +215 -26
- 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 +40 -15
- 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/doorAnalytics.js +2 -5
- 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 +854 -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/loadAbandon.js +2 -5
- 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/trackQueue.js +29 -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 +437 -57
- package/kits/hub-game/docs/analytics.md +20 -3
- 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 +80 -1
- 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-analytics.mjs +1 -1
- 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 +147 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +260 -5
- 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-load-abandon.mjs +2 -2
- 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 +55 -6
- 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-resync.mjs +13 -0
- package/kits/hub-game/scripts/test-role-client.mjs +10 -3
- 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-track-queue.mjs +64 -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 +77 -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 +380 -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 +48 -2
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +21 -3
- 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
|
@@ -7,6 +7,12 @@ behavior / scene / blueprint model, deck file map, live reload, and the
|
|
|
7
7
|
`imports/castle.physics-2d/` and work exactly as that kit's CLAUDE.md
|
|
8
8
|
describes. This file covers what is different in 3D.
|
|
9
9
|
|
|
10
|
+
## Welcome message
|
|
11
|
+
|
|
12
|
+
Welcome to an early test of Castle's new engine, in 3D with real physics! You're starting with Castle's 3D scene editor. Open `scenes/main.scene` to try it out, or I can start building something for you — a physics playground, a little obstacle course, a 3D puzzle, whatever you like.
|
|
13
|
+
|
|
14
|
+
Do you already know what you want to make, or do you want to figure it out together?
|
|
15
|
+
|
|
10
16
|
## Quick reference
|
|
11
17
|
|
|
12
18
|
<!-- Injected into Castle's create assistant every turn; keep this compact and factual. -->
|
|
@@ -59,12 +65,18 @@ bottom }`; any ref can pick a frame of a multi-frame sprite with
|
|
|
59
65
|
"tile": 2, "color": "#..." }` at the scene file's top level (`tile` = meters
|
|
60
66
|
per texture repeat). `"ground": { "none": true }` has no ground at all, drawn
|
|
61
67
|
or stood on: whatever is not on an actor falls (pits, lava, sky islands).
|
|
68
|
+
`"ground": { "half": 150 }` sizes it: the collider reaches that many meters
|
|
69
|
+
each way (default 100, clamped 1..200, multiplayer-3d's server slab too)
|
|
70
|
+
and the drawn plane is twice as wide (default 60 m square);
|
|
71
|
+
engine3d/groundsize.js has the rule.
|
|
62
72
|
`Shape.artRepeat: [u, v]` tiles a texture across a
|
|
63
73
|
face so long walls don't stretch.
|
|
64
74
|
- A scene file's top level may carry an `engine` object, beside `ground`.
|
|
65
75
|
Every key in it is opt-in: a scene without the key runs the engine exactly
|
|
66
76
|
as before. Each key's terms are in a file under `docs/`; read that file
|
|
67
77
|
before setting the key, or before changing code in a scene that sets it.
|
|
78
|
+
- `modelCache: { maxBytes }` -- reuse complete model templates across opens,
|
|
79
|
+
bounded on-device storage: docs/engine-model-cache.md.
|
|
68
80
|
- `load` -- builds the models near the player before the first frame and
|
|
69
81
|
the rest in slices after it: docs/engine-load.md.
|
|
70
82
|
- `skipUnchangedActors`, `dropEmptyParts`, `skipEmptyNodes`,
|
|
@@ -79,6 +91,8 @@ bottom }`; any ref can pick a frame of a multi-frame sprite with
|
|
|
79
91
|
- `camera` -- `follow: "rigid"`, the `control: "orbit"` third-person
|
|
80
92
|
camera, and its `pitch`, `minPitch`, `distance` and `fov`; also the rule
|
|
81
93
|
for steady forces: docs/engine-camera.md.
|
|
94
|
+
- `player.slideOnWalls: true` -- project the built-in grounded walk along
|
|
95
|
+
nearby fixed solid walls: docs/engine-player.md.
|
|
82
96
|
- `view` -- view distance and fog: docs/engine-view.md.
|
|
83
97
|
- `look` -- models drawn first and their look baked after:
|
|
84
98
|
docs/engine-look.md.
|
|
@@ -91,10 +91,46 @@ function pullSteadily(phys, actor) {
|
|
|
91
91
|
phys.addForce(actor, { x: 0, y: -14 * phys.mass(actor), z: 0 });
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
// Clip the requested walk against at most two nearby wall planes. A second
|
|
95
|
+
// plane that sends the tangent back into the first is a closed corner.
|
|
96
|
+
// Keep the tangent's length: projecting must not speed up a diagonal walk.
|
|
97
|
+
function slideMove(phys, actor, move) {
|
|
98
|
+
const wanted = move;
|
|
99
|
+
let first = null;
|
|
100
|
+
let excludeCollider;
|
|
101
|
+
for (let i = 0; i < 2; i += 1) {
|
|
102
|
+
const length = Math.hypot(move.x, move.z);
|
|
103
|
+
if (length < 1e-6) return { x: 0, z: 0 };
|
|
104
|
+
const hit = phys.castWalkWall(actor, { x: move.x / length, y: 0, z: move.z / length }, 0.12, excludeCollider);
|
|
105
|
+
const n = hit?.normal;
|
|
106
|
+
// castWalkWall resolves convex-edge support normals to surface faces:
|
|
107
|
+
// adjoining boxes in a straight wall do not supply a second wall plane.
|
|
108
|
+
// Floors and slopes keep their existing drive; only near-vertical faces.
|
|
109
|
+
if (!n || Math.abs(n.y) > 0.2) break;
|
|
110
|
+
const horizontal = Math.hypot(n.x, n.z);
|
|
111
|
+
if (horizontal < 1e-6) break;
|
|
112
|
+
const normal = { x: n.x / horizontal, z: n.z / horizontal };
|
|
113
|
+
const into = move.x * normal.x + move.z * normal.z;
|
|
114
|
+
if (into >= -1e-6) break;
|
|
115
|
+
// Reproject the original request on the second plane. Projecting the
|
|
116
|
+
// first tangent again can create an unwanted escape along the corner
|
|
117
|
+
// (and drift from tiny errors in Rapier's sweep normals).
|
|
118
|
+
const amount = wanted.x * normal.x + wanted.z * normal.z;
|
|
119
|
+
move = { x: wanted.x - amount * normal.x, z: wanted.z - amount * normal.z };
|
|
120
|
+
if (first && move.x * first.x + move.z * first.z < -1e-6) return { x: 0, z: 0 };
|
|
121
|
+
first = normal;
|
|
122
|
+
excludeCollider = hit.colliderHandle;
|
|
123
|
+
}
|
|
124
|
+
return move;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function applyMove(phys, actor, move, speed, grounded, dt, scene) {
|
|
95
128
|
const mass = phys.mass(actor);
|
|
96
129
|
const vel = phys.getVelocity(actor);
|
|
97
130
|
if (move) {
|
|
131
|
+
if (scene.data?.engine?.player?.slideOnWalls === true && grounded && vel.y <= 1) {
|
|
132
|
+
move = slideMove(phys, actor, move);
|
|
133
|
+
}
|
|
98
134
|
const factor = Math.min(1, dt * 14) * (grounded ? 1 : 0.3);
|
|
99
135
|
phys.applyImpulse(actor, {
|
|
100
136
|
x: (move.x * speed - vel.x) * mass * factor,
|
|
@@ -476,7 +512,7 @@ function updateOrbiting(actor, scene, props, dt) {
|
|
|
476
512
|
if (scene.playerDrive?.step) {
|
|
477
513
|
scene.playerDrive.step(actor, phys, { keys: scene.keys, stick: scene.moveInput, grounded }, dt);
|
|
478
514
|
} else {
|
|
479
|
-
applyMove(phys, actor, driveOrbiting(scene, per, rt, props, dt), props.speed, grounded, dt);
|
|
515
|
+
applyMove(phys, actor, driveOrbiting(scene, per, rt, props, dt), props.speed, grounded, dt, scene);
|
|
480
516
|
t.rotationY = rt.facing / DEG;
|
|
481
517
|
jumpOrbiting(phys, actor, scene, rt, grounded, props.jumpSpeed, dt);
|
|
482
518
|
}
|
|
@@ -1166,7 +1202,7 @@ export class Player {
|
|
|
1166
1202
|
z: -Math.cos(per.camAngle) * drive.forward,
|
|
1167
1203
|
}
|
|
1168
1204
|
: null;
|
|
1169
|
-
applyMove(phys, actor, move, this.props.speed, grounded, dt);
|
|
1205
|
+
applyMove(phys, actor, move, this.props.speed, grounded, dt, scene);
|
|
1170
1206
|
t.rotationY = rt.facing / DEG;
|
|
1171
1207
|
|
|
1172
1208
|
// Jump: Space on keyboard, or a short tap anywhere on the canvas (which
|
|
@@ -50,16 +50,16 @@
|
|
|
50
50
|
"imports": {
|
|
51
51
|
"castle.physics-2d": {
|
|
52
52
|
"deckId": "ckRZGFW4iPrx",
|
|
53
|
-
"version": "2026-
|
|
53
|
+
"version": "2026-11-15T00:41:50.817Z"
|
|
54
54
|
},
|
|
55
55
|
"castle.base": {
|
|
56
56
|
"deckId": "yRcmH4_aYllE",
|
|
57
|
-
"version": "2026-
|
|
57
|
+
"version": "2026-11-15T00:40:25.157Z"
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
"main": "main.jsx",
|
|
61
61
|
"autoUpdateWhenImported": true,
|
|
62
62
|
"deckId": "JH0SclbPVP0y",
|
|
63
63
|
"cardId": "eXfAaUdbSU5A",
|
|
64
|
-
"publishedVersion": "2026-
|
|
64
|
+
"publishedVersion": "2026-11-15T00:45:03.769Z"
|
|
65
65
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Model templates across opens
|
|
2
|
+
|
|
3
|
+
A scene may opt in with a top-level engine setting:
|
|
4
|
+
|
|
5
|
+
```json
|
|
6
|
+
"engine": { "modelCache": { "maxBytes": 8388608 } }
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
`"modelCache": {}` uses 8 MiB (8,388,608 bytes). `maxBytes` must be a
|
|
10
|
+
positive integer no larger than 16 MiB (16,777,216 bytes). A different shape,
|
|
11
|
+
unknown property or invalid value turns the key off. Without a valid key play
|
|
12
|
+
builds models as before, without capture or LocalCache calls. Editors and
|
|
13
|
+
thumbnails do not use it (`staticActorsOff`).
|
|
14
|
+
|
|
15
|
+
The cache keeps built model templates in SDK LocalCache on the player's device.
|
|
16
|
+
It is disposable: any read may miss, a write may store nothing, and storage may
|
|
17
|
+
be cleared. An unavailable, corrupt, old or unsuitable template builds normally.
|
|
18
|
+
A missing cache never changes scene data or prevents play.
|
|
19
|
+
|
|
20
|
+
Before the scene's first model sync, play reads one binary scene blob and one
|
|
21
|
+
small text index. There are no per-model bridge reads. Preload, including the
|
|
22
|
+
build digest, has a 1,500 ms timeout; after that this visit proceeds with all
|
|
23
|
+
misses, and its late read is ignored. A scene switch preloads the new scene
|
|
24
|
+
before its first model sync too. Gameplay updates do not run during the initial
|
|
25
|
+
preload. Scene loads and the first frame can therefore be later by up to that
|
|
26
|
+
allowance on a slow or unavailable bridge.
|
|
27
|
+
|
|
28
|
+
The blob key contains the scene path and a digest of the deck frame's code.
|
|
29
|
+
Once per page, native SHA-256 hashes the ordered `document.scripts` entries:
|
|
30
|
+
`"src:" + script.src` for content-addressed external scripts, or
|
|
31
|
+
`"inline:" + script.textContent` for inline scripts
|
|
32
|
+
(including the complete code in a single-file deck), plus the template codec
|
|
33
|
+
version and Three revision. The first 16 hexadecimal characters name the build.
|
|
34
|
+
Any deck save may invalidate the cache, including changes outside the kit. No
|
|
35
|
+
extra copy of kit source is bundled and no script contents are fetched.
|
|
36
|
+
|
|
37
|
+
An external script must have a complete 64-hex SHA-256 path segment, including
|
|
38
|
+
the CLI's `/cauldron-chunks/<sha256>.js` URLs. Any unhashed external script,
|
|
39
|
+
including dev-server entry/module URLs, disables caching for the visit:
|
|
40
|
+
`modelCacheReport.digest` is `"unavailable"` and `reason` is `"unhashed script"`.
|
|
41
|
+
Hashes in query strings, shortened hashes and arbitrary filenames do not qualify.
|
|
42
|
+
|
|
43
|
+
Hashing starts during preload, alongside optional module loading, within the
|
|
44
|
+
same 1,500 ms deadline. Storage reads wait for a successful hash. If `document`,
|
|
45
|
+
`document.scripts`, `TextEncoder` or `crypto.subtle` is unavailable, or hashing
|
|
46
|
+
fails, this visit builds normally without capture or any LocalCache calls;
|
|
47
|
+
`modelCacheReport.digest` is `"unavailable"`. The result, including failure, is
|
|
48
|
+
memoized for the page. A hash that finishes after the deadline is ignored for
|
|
49
|
+
that visit.
|
|
50
|
+
|
|
51
|
+
The index names the current blob, so a different digest removes the old blob
|
|
52
|
+
when the index is available. An index read can miss too; removal is best effort,
|
|
53
|
+
and SDK LocalCache still enforces its own per-deck limit.
|
|
54
|
+
|
|
55
|
+
Each template also has a key covering its model text, referenced model texts,
|
|
56
|
+
art state, look switch and build options. Only representable construction results
|
|
57
|
+
are written. Models requesting art, whether missing, loading or ready, currently
|
|
58
|
+
refuse caching; textures and unsupported metadata also fall back normally.
|
|
59
|
+
|
|
60
|
+
A hit supplies the same shared template that a normal build would supply to
|
|
61
|
+
`takeModel`. Actor copies, instancing and model release keep their usual
|
|
62
|
+
ownership. `engine.load` still decides which actors may wait. With
|
|
63
|
+
`dropEmptyParts`, the cache retains the original tree before pruning; play
|
|
64
|
+
prunes it normally. A miss serializes synchronously inside capture as soon as
|
|
65
|
+
the build returns, before any actor receives shared materials or geometry.
|
|
66
|
+
Later gameplay edits, including tinting, cannot change those bytes.
|
|
67
|
+
|
|
68
|
+
With deferred look baking, storage holds the unbaked construction result and a
|
|
69
|
+
recipe for its pending work. A hit restores that work through the normal look
|
|
70
|
+
queue, including merged-part outlines, placements and geometry copies. It bakes
|
|
71
|
+
as a fresh build does. On a same-page revisit, replay uses the current parsed
|
|
72
|
+
models' matching occlusion cache immediately, as a normal rebuild does, and
|
|
73
|
+
only queues the remaining work. Partially executed bake tasks are never serialized.
|
|
74
|
+
|
|
75
|
+
Writes happen after a frame has drawn and `load:rest-built` has settled. Without
|
|
76
|
+
`engine.load`, they start three seconds after the first drawn frame. Writing
|
|
77
|
+
uses only the bytes held since construction and may proceed while look baking
|
|
78
|
+
is pending. Blob copying yields in slices; bridge writes remain asynchronous.
|
|
79
|
+
Synchronous miss encoding adds work to a cache-enabled build. A scene left or
|
|
80
|
+
disposed while writing cancels the remaining work.
|
|
81
|
+
|
|
82
|
+
The budget covers the complete binary blob, including its template keys and
|
|
83
|
+
header. It evicts least recently used templates first, retaining their usage
|
|
84
|
+
order across opens. An entry too large for the budget is omitted. The small
|
|
85
|
+
index is separate. Other scenes and other SDK LocalCache users share the SDK's
|
|
86
|
+
20 MiB per-deck allowance, so multiple scene blobs can evict each other.
|
|
87
|
+
|
|
88
|
+
`scene.three.modelCacheReport` exists for a valid key:
|
|
89
|
+
|
|
90
|
+
- `hits`, `misses`: template lookups that loaded bytes or needed a normal build.
|
|
91
|
+
- `stored`, `bytes`: templates and total blob bytes retained by the most recent
|
|
92
|
+
read/write attempt. A successful SDK set does not prove durable storage.
|
|
93
|
+
- `readMs`, `decodeMs`: preload time and total template decoding time.
|
|
94
|
+
- `digest: "unavailable"`: build hashing failed or a required browser API was
|
|
95
|
+
unavailable, so caching is off for this visit.
|
|
96
|
+
- `reason: "unhashed script"`: an external script lacked content identity.
|
|
97
|
+
|
|
98
|
+
For QA, set `globalThis.__castleModelCacheVerify = true` before opening the
|
|
99
|
+
scene. Every hit also builds a fresh template and compares canonical serialized
|
|
100
|
+
bytes. For deferred look, isolated proof copies complete their bakes before
|
|
101
|
+
comparison; the playing template still goes through its own queue. `verified`
|
|
102
|
+
counts comparisons and `mismatches` lists differing keys. A
|
|
103
|
+
mismatch discards the cached template and uses a normal build. These fields and
|
|
104
|
+
the extra builds are absent when verification is off.
|
|
105
|
+
|
|
106
|
+
Run `node scripts/test-model-cache.mjs` for the fake-bridge checks, world
|
|
107
|
+
lifecycle, independent hit verification and load/look/pruning/instancing cases.
|
|
108
|
+
`node scripts/test-template-cache-minified.mjs` bundles and minifies the codec,
|
|
109
|
+
builder and Three together and compares their encoded bytes with unminified builds.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Scene key: engine.player
|
|
2
|
+
|
|
3
|
+
Opt a scene into wall sliding for the built-in `Player` walk:
|
|
4
|
+
|
|
5
|
+
```json
|
|
6
|
+
{
|
|
7
|
+
"engine": {
|
|
8
|
+
"player": {
|
|
9
|
+
"slideOnWalls": true
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Only literal `true` enables it. Absent, `false`, or any other value preserves
|
|
16
|
+
all existing movement impulses and physics API calls, with no wall probes.
|
|
17
|
+
This applies to both tank-style walking and the orbit camera's walking.
|
|
18
|
+
A scene-provided `playerDrive.step` keeps its own movement rules.
|
|
19
|
+
|
|
20
|
+
When grounded and not rising from a jump, the player probes horizontally in
|
|
21
|
+
the requested walk direction. The probe sweeps the player's actual collider
|
|
22
|
+
at its current position and rotation up to 0.12 m, with a 0.01 m contact
|
|
23
|
+
skin. For the standard Player this is the full upright capsule, including
|
|
24
|
+
its lower part: a 0.5 m barrier blocks it even though a waist-height ball
|
|
25
|
+
would miss the barrier or meet only its top edge. Its width also catches a
|
|
26
|
+
grazing wall that a centre ray would miss. Only fixed solid colliders
|
|
27
|
+
participate: sensors, dynamic bodies, kinematic bodies, and the player
|
|
28
|
+
itself are excluded.
|
|
29
|
+
|
|
30
|
+
For a mostly vertical surface (`abs(normal.y) <= 0.2`), `applyMove` removes
|
|
31
|
+
the into-wall component of the requested horizontal velocity before its
|
|
32
|
+
usual walk impulse. The remaining tangent retains its projected speed; it
|
|
33
|
+
is not normalized back to full speed. A second probe checks the tangent
|
|
34
|
+
against another wall. If both planes block the walk, the target is zero,
|
|
35
|
+
so a corner stops the player without repeatedly pushing into either wall.
|
|
36
|
+
Rapier still handles collision response and existing momentum.
|
|
37
|
+
|
|
38
|
+
A shape sweep can report an oblique support normal at a convex box edge.
|
|
39
|
+
That normal alone would turn adjoining boxes in one straight wall into a
|
|
40
|
+
false closed corner. For near-vertical hits, two short rays sample either
|
|
41
|
+
side of the contact on the met collider (1 mm sideways, from 2 cm out).
|
|
42
|
+
The face normal most aligned with the sweep's support normal is used.
|
|
43
|
+
Thus the next box supplies the same wall plane at a straight seam; a real
|
|
44
|
+
perpendicular wall still supplies a blocking second plane. This also keeps
|
|
45
|
+
sliding across small protrusions or recesses of a few millimetres.
|
|
46
|
+
|
|
47
|
+
Upward normals at the capsule's rounded bottom are kept as reported by the
|
|
48
|
+
sweep, so a passable curb is not turned into a vertical wall by sampling
|
|
49
|
+
its side. Geometry below the hovering capsule is not swept into at all.
|
|
50
|
+
|
|
51
|
+
Floors, gentler slopes, airborne steering, jumping, the hover spring, and
|
|
52
|
+
camera placement keep their existing rules. No friction coefficients or
|
|
53
|
+
combine rules change. Removing the sustained into-wall drive is enough to
|
|
54
|
+
avoid the wall friction stall with the standard zero-friction Player.
|
|
55
|
+
|
|
56
|
+
The narrow physics API helper is
|
|
57
|
+
`scene.physics3d.castWalkWall(actor, dir, maxToi, excludeCollider?)`.
|
|
58
|
+
`dir` is a horizontal unit vector; `maxToi` is the sweep distance in metres.
|
|
59
|
+
It returns `null` or `{ distance, actorId, colliderHandle, normal }`, with
|
|
60
|
+
the fixed surface's world-space face normal (or the original upward contact
|
|
61
|
+
normal for a floor or step). The optional collider handle lets
|
|
62
|
+
the second probe pass the first wall. It changes no bodies or colliders.
|
|
63
|
+
|
|
64
|
+
Run `npm run test:wall-slide` in the kit (also included in `npm run check`).
|
|
65
|
+
It runs the real Player and physics system on the kit's vendored Rapier:
|
|
66
|
+
a four-second walk headed 15 degrees off a long wall's normal reproduces
|
|
67
|
+
the unkeyed stall, and the keyed walk retains over 90% of its open-ground
|
|
68
|
+
tangent distance without penetrating the wall (5 mm solver tolerance).
|
|
69
|
+
It also checks both walk modes, corners, more grazing headings, unchanged
|
|
70
|
+
open-ground trajectories, slopes, jumps, filtering, and exact pre-key
|
|
71
|
+
`applyMove` calls and impulse arithmetic. Regression cases cross two- and
|
|
72
|
+
three-box straight walls at 5 degrees off the normal, including seams
|
|
73
|
+
with +/-3 mm offsets, and slide along a 0.5 m barrier at 15 degrees. Curb
|
|
74
|
+
crossings at 2, 8, and 15 cm keep exactly the same trajectories with the key
|
|
75
|
+
off and on. Projection alone passes these checks with Rapier's existing
|
|
76
|
+
average friction combine rule.
|
|
@@ -185,3 +185,19 @@ the `engine` object at a scene file's top level, beside `ground`.
|
|
|
185
185
|
the play scene excludes empty actors; traverse `scene.three.nodes` to find
|
|
186
186
|
all actors. If the scene itself has a transform or a parent, nodes stay
|
|
187
187
|
attached so world-space reads retain that transform.
|
|
188
|
+
|
|
189
|
+
2026-10-26: `releaseModel(cache, key, dispose, park = false)` can retain a
|
|
190
|
+
sleeping actor's shared template with zero users; `takeModel` reuses that exact
|
|
191
|
+
template on wake. Actor nodes and instance bookkeeping are still removed.
|
|
192
|
+
Ordinary removal and signature rebuilds retain their disposal behavior. Parked
|
|
193
|
+
templates are cleared when no actors sleep, on scene changes/reloads, and on
|
|
194
|
+
world disposal. `prewarmSleepingModels(world, runtime, { budgetMs = 4, now })`
|
|
195
|
+
builds sleeping actors' missing templates parked, nearest the camera first,
|
|
196
|
+
using the same keys, empty-part variants and look-bake rules as waking. It
|
|
197
|
+
returns the number built and stops after crossing its time budget; an unsettled
|
|
198
|
+
`engine.load` pass prevents prewarming. `needsSleepingModelPrewarm(world,
|
|
199
|
+
runtime)` lets a caller stop invoking the builder after completion and resume
|
|
200
|
+
when the sleep set, a model file/reference, art readiness or build variant
|
|
201
|
+
changes. The runtime's `sleepVersion` and `sleepingActorCount` make sleep-set
|
|
202
|
+
checks cheap; older runtimes still park safely but check sleep membership to
|
|
203
|
+
detect changes.
|
|
@@ -872,7 +872,11 @@ drawn apart from the rest (see Cost), so move the few parts that matter.
|
|
|
872
872
|
|
|
873
873
|
Set `"gait": "model"` at the top level of the deck's own `castle.json` to
|
|
874
874
|
match walk cadence to world-space leg length (including model/actor scale).
|
|
875
|
-
Without it, the fixed gait is unchanged.
|
|
875
|
+
Without it, the fixed gait is unchanged. Model gait steps at most 2.5
|
|
876
|
+
stride cycles a second (two footfalls each): faster motion widens the swing
|
|
877
|
+
up to 0.4 rad past its base, and beyond that the feet slip rather than the
|
|
878
|
+
legs speed up. The torso bob shrinks once cadence passes the fixed gait's
|
|
879
|
+
1.9 cycles a second. Missing legs fall back to 45% of
|
|
876
880
|
visible model height, then the fixed constants if no height is measurable.
|
|
877
881
|
Multiplayer-3d supplies remote cadence from network tracks; local motion,
|
|
878
882
|
air poses and turn lean still follow position. Long paused frames advance
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
|
|
4
4
|
const STOP_SPEED = 0.05;
|
|
5
|
+
// Stride cycles a second (two footfalls each). Above it the swing widens to
|
|
6
|
+
// lengthen the stride, and past the widest swing the feet slip rather than
|
|
7
|
+
// the legs blur: short chibi legs cannot cover a hub run at a calm cadence.
|
|
8
|
+
const MAX_CADENCE = 2.5;
|
|
9
|
+
const MAX_EXTRA_SWING = 0.4;
|
|
10
|
+
// The fixed gait's cadence at its 5 m/s walk; torso bob shrinks above it.
|
|
11
|
+
const FIXED_CADENCE = 5 * 2.4 / (2 * Math.PI);
|
|
5
12
|
const HINT_MAX_AGE_MS = 100;
|
|
6
13
|
|
|
7
14
|
let mode = 'fixed';
|
|
@@ -86,7 +93,7 @@ function measureLegs(node, state, ids) {
|
|
|
86
93
|
}
|
|
87
94
|
|
|
88
95
|
// Both walkers use the same world-length stride and adaptive swing. Cadence,
|
|
89
|
-
// rather than metres per second, is capped
|
|
96
|
+
// rather than metres per second, is capped at MAX_CADENCE.
|
|
90
97
|
// Air and lean still observe actual position and elapsed time.
|
|
91
98
|
export function modelWalk(node, state, ids, baseAmplitude, observedSpeed, dt, hint) {
|
|
92
99
|
const gait = measureLegs(node, state, ids);
|
|
@@ -102,19 +109,20 @@ export function modelWalk(node, state, ids, baseAmplitude, observedSpeed, dt, hi
|
|
|
102
109
|
}
|
|
103
110
|
const supplied = Number.isFinite(hint?.speed) ? hint.speed : observedSpeed;
|
|
104
111
|
const speed = Number.isFinite(supplied) ? Math.max(0, Math.min(30, supplied)) : 0;
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
: Math.min(baseAmplitude + 0.3, Math.asin(Math.min(1, speed / (4 * gait.length * softCadence))));
|
|
112
|
+
const amplitude = speed <= cycle * MAX_CADENCE ? baseAmplitude
|
|
113
|
+
: Math.min(baseAmplitude + MAX_EXTRA_SWING, Math.asin(Math.min(1, speed / (4 * gait.length * MAX_CADENCE))));
|
|
108
114
|
const targetAmount = Math.min(1, speed / (5 * scale));
|
|
109
115
|
// The rendered angle includes the swing amount. Use its target (not the
|
|
110
116
|
// eased startup pose), avoiding both low-speed slip and startup spikes.
|
|
111
117
|
const effectiveAmplitude = amplitude * targetAmount;
|
|
112
118
|
const stride = 4 * gait.length * Math.sin(effectiveAmplitude);
|
|
113
|
-
// This replaces the rad/metre clamp: even a tiny/broken model cannot
|
|
114
|
-
//
|
|
115
|
-
const cadence = speed < STOP_SPEED ? 0 : Math.min(
|
|
119
|
+
// This replaces the rad/metre clamp: even a tiny/broken model cannot step
|
|
120
|
+
// faster than MAX_CADENCE. Division overflow also lands on this bound.
|
|
121
|
+
const cadence = speed < STOP_SPEED ? 0 : Math.min(MAX_CADENCE, speed / stride);
|
|
122
|
+
const bobScale = cadence > FIXED_CADENCE ? FIXED_CADENCE / cadence : 1;
|
|
116
123
|
Object.assign(gait, { model: true, k: stride > 0 ? 2 * Math.PI / stride : 2.4, walkSpeed: 5 * scale,
|
|
117
|
-
cap: 30, cadence, amplitude, effectiveAmplitude, targetAmount, amplitudeScale: amplitude / baseAmplitude
|
|
124
|
+
cap: 30, cadence, amplitude, effectiveAmplitude, targetAmount, amplitudeScale: amplitude / baseAmplitude,
|
|
125
|
+
bobScale });
|
|
118
126
|
return {
|
|
119
127
|
...gait,
|
|
120
128
|
speed,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// A scene's optional ground size: `"ground": { "half": 150 }` is the ground's
|
|
2
|
+
// half-width in meters, the same on both axes, for the collider players stand
|
|
3
|
+
// on and for the drawn plane. Without it (or with anything but a finite
|
|
4
|
+
// number) a scene keeps the old ground: a 100 m half-width collider under a
|
|
5
|
+
// 60 m drawn plane. The value is clamped to 1..200, the edge of
|
|
6
|
+
// multiplayer-3d's world bounds; a native engine reads the key by this rule.
|
|
7
|
+
|
|
8
|
+
export const GROUND_HALF_MIN = 1;
|
|
9
|
+
export const GROUND_HALF_MAX = 200;
|
|
10
|
+
// The collider's half-width when a scene does not set one.
|
|
11
|
+
export const DEFAULT_COLLIDER_HALF = 100;
|
|
12
|
+
|
|
13
|
+
// The scene's ground half-width in meters, or null when it does not set one.
|
|
14
|
+
export function groundHalf(setting) {
|
|
15
|
+
const half = setting?.half;
|
|
16
|
+
if (typeof half !== 'number' || !Number.isFinite(half)) return null;
|
|
17
|
+
return Math.min(GROUND_HALF_MAX, Math.max(GROUND_HALF_MIN, half));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// The half-width of the ground collider a scene stands on.
|
|
21
|
+
export function colliderHalf(setting) {
|
|
22
|
+
return groundHalf(setting) ?? DEFAULT_COLLIDER_HALF;
|
|
23
|
+
}
|
|
@@ -17,6 +17,22 @@
|
|
|
17
17
|
import * as THREE from 'three';
|
|
18
18
|
|
|
19
19
|
const known = new WeakSet();
|
|
20
|
+
const templateHooks = new WeakMap();
|
|
21
|
+
const artTemplates = new WeakSet();
|
|
22
|
+
let captureDepth = 0;
|
|
23
|
+
export let templateCaptureActive = false;
|
|
24
|
+
|
|
25
|
+
// Synchronous, nestable capture. Call end in finally, including failed builds.
|
|
26
|
+
export function beginTemplateCapture() {
|
|
27
|
+
captureDepth += 1;
|
|
28
|
+
templateCaptureActive = true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function endTemplateCapture() {
|
|
32
|
+
if (captureDepth === 0) throw new Error('no template capture active');
|
|
33
|
+
captureDepth -= 1;
|
|
34
|
+
templateCaptureActive = captureDepth > 0;
|
|
35
|
+
}
|
|
20
36
|
|
|
21
37
|
const DEFAULT_HOOK = THREE.Material.prototype.onBeforeCompile;
|
|
22
38
|
const DEFAULT_KEY = THREE.Material.prototype.customProgramCacheKey;
|
|
@@ -45,3 +61,37 @@ export function markKitHooks(material, previousHook = null, previousKey = null)
|
|
|
45
61
|
known.add(material.onBeforeCompile);
|
|
46
62
|
known.add(material.customProgramCacheKey);
|
|
47
63
|
}
|
|
64
|
+
|
|
65
|
+
// Private recipes keep functions and closure state out of template bytes. A
|
|
66
|
+
// changed or unrecorded callback is refused, even on a material the kit patched.
|
|
67
|
+
export function recordTemplateHook(material, recipe, previousHook = null, previousKey = null) {
|
|
68
|
+
if (!templateCaptureActive) return;
|
|
69
|
+
const previous = templateHooks.get(material);
|
|
70
|
+
const starts = previousHook === null || (previousHook === DEFAULT_HOOK && previousKey === DEFAULT_KEY);
|
|
71
|
+
const wraps = previous && previous.hook === previousHook && previous.key === previousKey;
|
|
72
|
+
if (!starts && !wraps) return;
|
|
73
|
+
if (recipe.kind !== 'outline' && material.onBeforeRender !== DEFAULT_DRAW && !(wraps && previous.draw === material.onBeforeRender)) return;
|
|
74
|
+
templateHooks.set(material, {
|
|
75
|
+
hook: material.onBeforeCompile,
|
|
76
|
+
key: material.customProgramCacheKey,
|
|
77
|
+
draw: material.onBeforeRender,
|
|
78
|
+
recipes: [...(starts ? [] : previous.recipes), recipe],
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function templateHookRecipes(material) {
|
|
83
|
+
const found = templateHooks.get(material);
|
|
84
|
+
if (found && found.hook === material.onBeforeCompile && found.key === material.customProgramCacheKey && found.draw === material.onBeforeRender) return found.recipes;
|
|
85
|
+
if (material.onBeforeCompile === DEFAULT_HOOK && material.customProgramCacheKey === DEFAULT_KEY && material.onBeforeRender === DEFAULT_DRAW) return [];
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Art requests must survive missing/loading textures without adding anything
|
|
90
|
+
// to Object3D.userData or doing model scans in normal play.
|
|
91
|
+
export function recordTemplateArt(root) {
|
|
92
|
+
if (templateCaptureActive) artTemplates.add(root);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function templateRequestsArt(root) {
|
|
96
|
+
return artTemplates.has(root);
|
|
97
|
+
}
|