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
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
// Real Player + Physics3DSystem + the kit's real, vendored Rapier WASM.
|
|
2
|
+
// Run from any directory: node kits/physics-3d/scripts/test-wall-slide.mjs.
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import { register } from 'node:module';
|
|
5
|
+
|
|
6
|
+
register('data:text/javascript,' + encodeURIComponent(`
|
|
7
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
export async function resolve(specifier, context, next) {
|
|
10
|
+
const parent = context.parentURL ?? '';
|
|
11
|
+
if (specifier.startsWith('@imports/castle.physics-2d/')) {
|
|
12
|
+
specifier = parent.replace(/\\/kits\\/.*/, '/kits/physics-2d/') + specifier.slice(27);
|
|
13
|
+
}
|
|
14
|
+
if ((specifier.startsWith('.') || specifier.startsWith('file:')) && parent.includes('/kits/') && !/\\.(m?js|jsx|json)$/.test(specifier)) {
|
|
15
|
+
const base = new URL(specifier, parent).href;
|
|
16
|
+
for (const ext of ['.js', '.jsx']) if (existsSync(fileURLToPath(base + ext))) return next(base + ext, context);
|
|
17
|
+
}
|
|
18
|
+
return next(specifier, context);
|
|
19
|
+
}
|
|
20
|
+
export async function load(url, context, next) {
|
|
21
|
+
if (url.endsWith('/behaviors/Player.jsx')) {
|
|
22
|
+
return { format: 'module', source: readFileSync(fileURLToPath(url), 'utf8') + '\\nexport { applyMove };', shortCircuit: true };
|
|
23
|
+
}
|
|
24
|
+
return next(url, context);
|
|
25
|
+
}
|
|
26
|
+
`));
|
|
27
|
+
const { Player, applyMove } = await import('../behaviors/Player.jsx');
|
|
28
|
+
const { Physics3DSystem } = await import('../systems/physics3d.js');
|
|
29
|
+
const { Player: PlayPlayer } = await import('../play/behaviors/Player.js');
|
|
30
|
+
const DT = 1 / 60;
|
|
31
|
+
const RADIUS = 0.35;
|
|
32
|
+
const props = { ...Player.defaultProps };
|
|
33
|
+
const transform = (x, y, z) => ({ x, y, z, rotationX: 0, rotationY: 0, rotationZ: 0, scaleX: 1, scaleY: 1, scaleZ: 1 });
|
|
34
|
+
const wall = (id, x, z, width, depth, type = 'fixed', solid = true) => ({
|
|
35
|
+
id, runtime: {}, components: {
|
|
36
|
+
Transform: transform(x, 2, z), Shape: { kind: 'box', width, height: 4, depth },
|
|
37
|
+
Body: { type, gravityScale: 0, friction: 0.6, restitution: 0 }, ...(solid ? { Solid: {} } : {}),
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
async function makeWorld({ enabled, walls = [], angle = 15, orbit = false, x = -RADIUS - 0.002, z = 0, PlayerClass = Player } = {}) {
|
|
42
|
+
const actor = { id: 'player', runtime: {}, components: {
|
|
43
|
+
Transform: transform(x, 1, z), Shape: { kind: 'capsule', radius: RADIUS, height: 1.4 },
|
|
44
|
+
Body: { type: 'dynamic', lockRotations: true, friction: 0, restitution: 0, gravityScale: 2 }, Solid: {}, Player: { ...props },
|
|
45
|
+
} };
|
|
46
|
+
const system = new Physics3DSystem();
|
|
47
|
+
const scene = {
|
|
48
|
+
time: 0, keys: new Set(), persistent: { camAngle: (90 + angle) * Math.PI / 180 },
|
|
49
|
+
data: { engine: { player: { ...(enabled === undefined ? {} : { slideOnWalls: enabled }) } } },
|
|
50
|
+
actors: [actor, ...walls], maxFps: 0, three: null,
|
|
51
|
+
cameraControl: orbit ? 'orbit' : undefined,
|
|
52
|
+
getActors: () => scene.actors, getActor: (id) => scene.actors.find((a) => a.id === id),
|
|
53
|
+
actorsWith: () => [], forEachBehavior: () => {},
|
|
54
|
+
};
|
|
55
|
+
system.attach(scene);
|
|
56
|
+
const calls = [];
|
|
57
|
+
const api = scene.physics3d;
|
|
58
|
+
scene.physics3d = Object.fromEntries(Object.entries(api).map(([name, fn]) => [name, (...args) => {
|
|
59
|
+
const result = fn(...args);
|
|
60
|
+
calls.push(JSON.stringify([name, args.map((a) => a?.components ? a.id : a), result]));
|
|
61
|
+
return result;
|
|
62
|
+
}]));
|
|
63
|
+
const frame = (walking = false, jump = false) => {
|
|
64
|
+
scene.time += DT;
|
|
65
|
+
scene.keys = new Set([...(walking ? ['KeyW'] : []), ...(jump ? ['Space'] : [])]);
|
|
66
|
+
new PlayerClass(props).update(actor, scene, DT);
|
|
67
|
+
system.afterBehaviors(scene, DT);
|
|
68
|
+
return { ...system.bodies.get(actor.id).body.translation() };
|
|
69
|
+
};
|
|
70
|
+
for (let i = 0; i < 200 && !api.ready(); i += 1) {
|
|
71
|
+
await new Promise((resolve) => setTimeout(resolve, 5));
|
|
72
|
+
system.afterBehaviors(scene, DT);
|
|
73
|
+
}
|
|
74
|
+
assert.ok(api.ready(), 'real Rapier initialized');
|
|
75
|
+
for (let i = 0; i < 180; i += 1) frame();
|
|
76
|
+
calls.length = 0;
|
|
77
|
+
return { actor, scene, system, calls, frame, close: () => system.dispose(scene) };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function walk(options, jump = false) {
|
|
81
|
+
const w = await makeWorld(options);
|
|
82
|
+
try {
|
|
83
|
+
const start = { ...w.actor.components.Transform };
|
|
84
|
+
const samples = [];
|
|
85
|
+
for (let i = 0; i < 240; i += 1) samples.push(w.frame(true, jump && i === 0));
|
|
86
|
+
const end = samples.at(-1);
|
|
87
|
+
const tail = samples.slice(-60);
|
|
88
|
+
return {
|
|
89
|
+
dx: end.x - start.x, dz: end.z - start.z,
|
|
90
|
+
maxX: Math.max(...samples.map((p) => p.x)), maxZ: Math.max(...samples.map((p) => p.z)),
|
|
91
|
+
jitter: Math.max(...tail.map((p) => p.x)) - Math.min(...tail.map((p) => p.x)) +
|
|
92
|
+
Math.max(...tail.map((p) => p.z)) - Math.min(...tail.map((p) => p.z)),
|
|
93
|
+
samples, calls: [...w.calls],
|
|
94
|
+
};
|
|
95
|
+
} finally { w.close(); }
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// The pre-key primitive, retained to check exact calls and arithmetic without
|
|
99
|
+
// relying on the new implementation as its own reference.
|
|
100
|
+
function originalMove(phys, actor, move, speed, grounded, dt) {
|
|
101
|
+
const mass = phys.mass(actor);
|
|
102
|
+
const vel = phys.getVelocity(actor);
|
|
103
|
+
if (move) {
|
|
104
|
+
const factor = Math.min(1, dt * 14) * (grounded ? 1 : 0.3);
|
|
105
|
+
phys.applyImpulse(actor, {
|
|
106
|
+
x: (move.x * speed - vel.x) * mass * factor, y: 0,
|
|
107
|
+
z: (move.z * speed - vel.z) * mass * factor,
|
|
108
|
+
});
|
|
109
|
+
} else if (grounded) {
|
|
110
|
+
const factor = Math.min(1, dt * 12);
|
|
111
|
+
phys.applyImpulse(actor, { x: -vel.x * mass * factor, y: 0, z: -vel.z * mass * factor });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
for (const enabled of [undefined, false, 1, 'true']) {
|
|
115
|
+
for (const grounded of [true, false]) for (const move of [null, { x: 0, z: 0 }, { x: 0.3, z: -0.8 }]) {
|
|
116
|
+
for (const dt of [0, 1 / 144, DT, 1 / 30, 0.1]) {
|
|
117
|
+
const record = (fn) => {
|
|
118
|
+
const calls = [];
|
|
119
|
+
const phys = {
|
|
120
|
+
mass: (a) => { calls.push(['mass', a]); return 2.75; },
|
|
121
|
+
getVelocity: (a) => { calls.push(['getVelocity', a]); return { x: 1.234, y: -0.12, z: -0.567 }; },
|
|
122
|
+
applyImpulse: (a, v) => calls.push(['applyImpulse', a, v]),
|
|
123
|
+
castWalkWall: () => assert.fail('no casts without literal true'),
|
|
124
|
+
};
|
|
125
|
+
fn(phys, 'player', move, 6, grounded, dt, { data: { engine: { player: { slideOnWalls: enabled } } } });
|
|
126
|
+
return calls;
|
|
127
|
+
};
|
|
128
|
+
assert.deepEqual(record(applyMove), record(originalMove), 'disabled key: original calls, order and impulse bits');
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
console.log('disabled key: original applyMove calls and impulses match exactly (120 cases)');
|
|
133
|
+
|
|
134
|
+
// Airborne steering bypasses the wall probe even with the key enabled.
|
|
135
|
+
for (const [grounded, y] of [[false, -2], [false, 8], [true, 8]]) {
|
|
136
|
+
const a = [];
|
|
137
|
+
const b = [];
|
|
138
|
+
const fake = (calls) => ({
|
|
139
|
+
mass: () => 2, getVelocity: () => ({ x: 1, y, z: -1 }),
|
|
140
|
+
applyImpulse: (_, impulse) => calls.push(impulse),
|
|
141
|
+
castWalkWall: () => assert.fail('jumping/airborne players do not probe walls'),
|
|
142
|
+
});
|
|
143
|
+
const move = { x: 0.4, z: 0.8 };
|
|
144
|
+
applyMove(fake(a), 'player', move, 6, grounded, DT, { data: { engine: { player: { slideOnWalls: true } } } });
|
|
145
|
+
originalMove(fake(b), 'player', move, 6, grounded, DT);
|
|
146
|
+
assert.deepEqual(a, b, 'airborne steering unchanged');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const longWall = () => [wall('wall', 0.5, 0, 1, 100)];
|
|
150
|
+
const free = await walk({ enabled: true });
|
|
151
|
+
const baseline = await walk({ walls: longWall() });
|
|
152
|
+
console.log(`baseline: ${baseline.dz.toFixed(4)} m along wall in 4 s; free tangent ${free.dz.toFixed(4)} m`);
|
|
153
|
+
assert.ok(baseline.dz >= -0.01 && baseline.dz < 0.4, 'without the key, the real wall reproduces the stall');
|
|
154
|
+
const off = await walk({ enabled: false, walls: longWall() });
|
|
155
|
+
assert.deepEqual(off.samples, baseline.samples, 'false preserves every physics position');
|
|
156
|
+
assert.deepEqual(off.calls, baseline.calls, 'false preserves every API call and argument');
|
|
157
|
+
assert.ok(!baseline.calls.some((call) => call.includes('castWalkWall')), 'absent key makes no extra casts');
|
|
158
|
+
|
|
159
|
+
for (const orbit of [false, true]) {
|
|
160
|
+
const slide = await walk({ enabled: true, walls: longWall(), orbit });
|
|
161
|
+
assert.ok(slide.dz > free.dz * 0.9, 'slide covers most of the free tangent distance');
|
|
162
|
+
assert.ok(slide.maxX <= -RADIUS + 0.005, 'capsule never penetrates the wall (5 mm solver tolerance)');
|
|
163
|
+
console.log(`${orbit ? 'orbit' : 'tank'} slide: ${slide.dz.toFixed(4)} m; closest capsule edge ${(slide.maxX + RADIUS).toFixed(5)} m`);
|
|
164
|
+
}
|
|
165
|
+
const corner = await walk({ enabled: true, angle: 45, z: -RADIUS - 0.002, walls: [
|
|
166
|
+
wall('x-wall', 0.5, 0, 1, 100), wall('z-wall', 0, 0.5, 100, 1),
|
|
167
|
+
] });
|
|
168
|
+
assert.ok(corner.maxX <= -RADIUS + 0.005 && corner.maxZ <= -RADIUS + 0.005, 'corner does not penetrate either wall');
|
|
169
|
+
assert.ok(corner.jitter < 0.001, 'corner stops with less than 1 mm movement in its final second');
|
|
170
|
+
console.log(`corner: final-second movement ${corner.jitter.toFixed(6)} m`);
|
|
171
|
+
const mirrorSlide = await walk({ enabled: true, walls: longWall(), PlayerClass: PlayPlayer });
|
|
172
|
+
const sourceSlide = await walk({ enabled: true, walls: longWall() });
|
|
173
|
+
assert.deepEqual(mirrorSlide.samples, sourceSlide.samples, 'generated play mirror has identical wall slide');
|
|
174
|
+
assert.deepEqual(mirrorSlide.calls, sourceSlide.calls, 'generated play mirror makes identical physics calls');
|
|
175
|
+
const openOff = await walk({ enabled: false });
|
|
176
|
+
assert.deepEqual(free.samples, openOff.samples, 'open-ground walking is exactly unchanged');
|
|
177
|
+
console.log(`open ground: ${Math.hypot(free.dx, free.dz).toFixed(4)} m, identical with key off/on`);
|
|
178
|
+
const approach = await walk({ enabled: true, angle: 45, x: -2, z: -2, walls: [
|
|
179
|
+
wall('x-wall', 0.5, 0, 1, 100), wall('z-wall', 0, 0.5, 100, 1),
|
|
180
|
+
] });
|
|
181
|
+
assert.ok(approach.jitter < 0.001, 'entering a corner at speed also comes to rest without jitter');
|
|
182
|
+
assert.ok(approach.samples.at(-1).x <= -RADIUS + 0.005 && approach.samples.at(-1).z <= -RADIUS + 0.005,
|
|
183
|
+
'corner approach finishes outside both walls');
|
|
184
|
+
|
|
185
|
+
// More grazing headings must also be seen by the radius sweep, even where
|
|
186
|
+
// a short centre ray would miss the wall entirely.
|
|
187
|
+
for (const angle of [10, 20, 75, 80]) {
|
|
188
|
+
const open = await walk({ enabled: true, angle });
|
|
189
|
+
const slide = await walk({ enabled: true, angle, walls: longWall() });
|
|
190
|
+
assert.ok(slide.dz > open.dz * 0.9, `heading ${angle}: retains tangent speed`);
|
|
191
|
+
assert.ok(slide.maxX <= -RADIUS + 0.005, `heading ${angle}: does not penetrate`);
|
|
192
|
+
}
|
|
193
|
+
// The helper passes through non-fixed bodies and sensors, even with a fixed
|
|
194
|
+
// player (its own collider must still be excluded explicitly).
|
|
195
|
+
for (const [type, solid] of [['dynamic', true], ['kinematic', true], ['fixed', false]]) {
|
|
196
|
+
const w = await makeWorld({ enabled: true, walls: [wall('ignored', 0.5, 0, 1, 100, type, solid)] });
|
|
197
|
+
try {
|
|
198
|
+
assert.equal(w.scene.physics3d.castWalkWall(w.actor, { x: 1, y: 0, z: 0 }, 0.12), null, `${type}/${solid}: ignored`);
|
|
199
|
+
w.actor.components.Body.type = 'fixed';
|
|
200
|
+
w.system.afterBehaviors(w.scene, DT);
|
|
201
|
+
assert.equal(w.scene.physics3d.castWalkWall(w.actor, { x: 1, y: 0, z: 0 }, 0.12), null, 'player is excluded even when fixed');
|
|
202
|
+
} finally { w.close(); }
|
|
203
|
+
}
|
|
204
|
+
// Hover, slopes and jump trajectories stay exactly as before. A broad ramp
|
|
205
|
+
// tilts up 12 degrees; the player starts on it and walks uphill.
|
|
206
|
+
const ramp = () => {
|
|
207
|
+
const a = wall('ramp', 0, 0, 100, 100);
|
|
208
|
+
Object.assign(a.components.Transform, { y: -2, rotationZ: 12 });
|
|
209
|
+
return [a];
|
|
210
|
+
};
|
|
211
|
+
for (const jump of [false, true]) {
|
|
212
|
+
const a = await walk({ enabled: false, walls: ramp() }, jump);
|
|
213
|
+
const b = await walk({ enabled: true, walls: ramp() }, jump);
|
|
214
|
+
assert.deepEqual(b.samples, a.samples, `ramp, jump=${jump}: unchanged positions`);
|
|
215
|
+
}
|
|
216
|
+
const jumpingOff = await walk({ enabled: false }, true);
|
|
217
|
+
const jumpingOn = await walk({ enabled: true }, true);
|
|
218
|
+
assert.deepEqual(jumpingOn.samples, jumpingOff.samples, 'jump and landing unchanged on open ground');
|
|
219
|
+
assert.ok(Math.max(...jumpingOn.samples.map((p) => p.y)) > 1.5, 'jump case really leaves the ground');
|
|
220
|
+
console.log('grazing headings, fixed-solid filtering, self exclusion, ramp, hover and jump checks passed');
|
|
221
|
+
// A straight wall split into boxes must not become a closed corner at a
|
|
222
|
+
// convex box edge. Cross both seams of the three-box wall within four seconds.
|
|
223
|
+
const joinedWalls = (count, offset = 0) => {
|
|
224
|
+
const ends = count === 2 ? [-50, 0.25, 50] : [-50, 0.25, 1, 50];
|
|
225
|
+
return Array.from({ length: count }, (_, i) => wall(`part-${i}`, 0.5 + (i % 2 ? offset : 0),
|
|
226
|
+
(ends[i] + ends[i + 1]) / 2, 1, ends[i + 1] - ends[i]));
|
|
227
|
+
};
|
|
228
|
+
const seamFree = await walk({ enabled: true, angle: 5 });
|
|
229
|
+
const seamOne = await walk({ enabled: true, angle: 5, walls: longWall() });
|
|
230
|
+
const seams = [];
|
|
231
|
+
for (const count of [2, 3]) for (const offset of [0, 0.003, -0.003]) {
|
|
232
|
+
const result = await walk({ enabled: true, angle: 5, walls: joinedWalls(count, offset) });
|
|
233
|
+
console.log(`${count}-box seam, offset ${offset}: ${result.dz.toFixed(4)} m; one box ${seamOne.dz.toFixed(4)} m`);
|
|
234
|
+
seams.push({ count, offset, result });
|
|
235
|
+
}
|
|
236
|
+
// Verify the primitive's choice directly: the second box's convex edge is
|
|
237
|
+
// a continuation of the x-facing wall, not an opposing z-facing end wall.
|
|
238
|
+
const seamProbe = await makeWorld({ enabled: true, walls: joinedWalls(2), z: 0.15 });
|
|
239
|
+
try {
|
|
240
|
+
const first = seamProbe.system.bodies.get('part-0').collider.handle;
|
|
241
|
+
const hit = seamProbe.scene.physics3d.castWalkWall(seamProbe.actor, { x: 0, y: 0, z: 1 }, 0.12, first);
|
|
242
|
+
assert.ok(hit && hit.actorId === 'part-1', 'probe really reaches the adjoining box edge');
|
|
243
|
+
assert.ok(hit.normal.x < -0.999 && Math.abs(hit.normal.z) < 1e-6, 'edge resolves to the continuing wall face');
|
|
244
|
+
} finally { seamProbe.close(); }
|
|
245
|
+
const barrier = (height) => {
|
|
246
|
+
const a = wall('barrier', 0.5, 0, 1, 100);
|
|
247
|
+
a.components.Shape.height = height;
|
|
248
|
+
a.components.Transform.y = height / 2;
|
|
249
|
+
return [a];
|
|
250
|
+
};
|
|
251
|
+
const lowOff = await walk({ enabled: false, walls: barrier(0.5) });
|
|
252
|
+
const lowOn = await walk({ enabled: true, walls: barrier(0.5) });
|
|
253
|
+
console.log(`0.5 m barrier: off ${lowOff.dz.toFixed(4)} m, on ${lowOn.dz.toFixed(4)} m; free ${free.dz.toFixed(4)} m`);
|
|
254
|
+
for (const height of [0.02, 0.08, 0.15]) {
|
|
255
|
+
const curbOff = await walk({ enabled: false, walls: barrier(height) });
|
|
256
|
+
const curbOn = await walk({ enabled: true, walls: barrier(height) });
|
|
257
|
+
assert.ok(curbOn.dx > 20, `${height} m curb is crossed`);
|
|
258
|
+
assert.deepEqual(curbOn.samples, curbOff.samples, `${height} m curb: hover/step trajectory unchanged`);
|
|
259
|
+
console.log(`${height} m curb: ${curbOn.dx.toFixed(4)} m across it, identical with key off/on`);
|
|
260
|
+
}
|
|
261
|
+
for (const { count, offset, result } of seams) {
|
|
262
|
+
assert.ok(result.dz > seamFree.dz * 0.9, `${count}-box seam ${offset}: retains free tangent speed`);
|
|
263
|
+
assert.ok(result.maxX <= -RADIUS + Math.max(0, offset) + 0.005, 'no wall penetration across seams');
|
|
264
|
+
}
|
|
265
|
+
assert.ok(lowOff.dz < 0.4, 'low barrier reproduces the original stall');
|
|
266
|
+
assert.ok(lowOn.dz > free.dz * 0.9, 'low barrier retains free tangent speed');
|
|
267
|
+
assert.ok(lowOn.maxX <= -RADIUS + 0.005, 'capsule never penetrates low barrier');
|
|
268
|
+
const mirrorSeam = await walk({ enabled: true, angle: 5, walls: joinedWalls(3, -0.003), PlayerClass: PlayPlayer });
|
|
269
|
+
assert.deepEqual(mirrorSeam.samples, seams.at(-1).result.samples, 'play mirror crosses offset seams identically');
|
|
270
|
+
const mirrorBarrier = await walk({ enabled: true, walls: barrier(0.5), PlayerClass: PlayPlayer });
|
|
271
|
+
assert.deepEqual(mirrorBarrier.samples, lowOn.samples, 'play mirror slides along low barriers identically');
|
|
272
|
+
console.log('wall-slide: all checks passed (real Rapier; friction combine rule unchanged)');
|
|
@@ -18,6 +18,7 @@ import { giveBackViewRange } from '../engine3d/viewrange.js';
|
|
|
18
18
|
import { leaveSky } from '../engine3d/skylife.js';
|
|
19
19
|
import { dropShadowFade } from '../engine3d/shadowfade.js';
|
|
20
20
|
import { FrozenPhysics } from '../engine3d/frozenphysics.js';
|
|
21
|
+
import { colliderHalf } from '../engine3d/groundsize.js';
|
|
21
22
|
import { prepareModelConsumers } from '../engine3d/modelready.js';
|
|
22
23
|
|
|
23
24
|
const FIXED_STEP = 1 / 60;
|
|
@@ -225,11 +226,13 @@ export class Physics3DSystem {
|
|
|
225
226
|
// A scene whose top level says `"ground": { "none": true }` has no ground:
|
|
226
227
|
// what is not stood on something falls (a pit, lava, the sky).
|
|
227
228
|
if (scene?.data?.ground?.none === true) return;
|
|
228
|
-
// The ground everything stands on
|
|
229
|
+
// The ground everything stands on: 100 m each way from the origin, or
|
|
230
|
+
// the scene's `ground.half` (engine3d/groundsize.js).
|
|
231
|
+
const half = colliderHalf(scene?.data?.ground);
|
|
229
232
|
const groundBody = this.world.createRigidBody(
|
|
230
233
|
RAPIER.RigidBodyDesc.fixed().setTranslation(0, -0.5, 0)
|
|
231
234
|
);
|
|
232
|
-
this.world.createCollider(RAPIER.ColliderDesc.cuboid(
|
|
235
|
+
this.world.createCollider(RAPIER.ColliderDesc.cuboid(half, 0.5, half), groundBody);
|
|
233
236
|
}
|
|
234
237
|
|
|
235
238
|
reconcileBodies(scene) {
|
|
@@ -789,6 +792,33 @@ function fixedSolids() {
|
|
|
789
792
|
return flags.EXCLUDE_DYNAMIC | flags.EXCLUDE_KINEMATIC | flags.EXCLUDE_SENSORS;
|
|
790
793
|
}
|
|
791
794
|
|
|
795
|
+
// A sweep can return a convex edge's support normal instead of either
|
|
796
|
+
// face. Sample both sides of the contact and use the face closest to that
|
|
797
|
+
// support normal: the next box's end is not a second wall at a straight seam.
|
|
798
|
+
function walkFaceNormal(hit) {
|
|
799
|
+
const n = hit.normal1;
|
|
800
|
+
// A lower-cap/top-edge contact with an upward normal can be stepped over;
|
|
801
|
+
// keep it instead of substituting a vertical side face below that edge.
|
|
802
|
+
if (Math.abs(n.y) > 0.2) return n;
|
|
803
|
+
const p = hit.witness1;
|
|
804
|
+
let best = n;
|
|
805
|
+
let alignment = -1;
|
|
806
|
+
for (const side of [-0.001, 0.001]) {
|
|
807
|
+
const from = {
|
|
808
|
+
x: p.x + n.x * 0.02 - n.z * side,
|
|
809
|
+
y: p.y + n.y * 0.02,
|
|
810
|
+
z: p.z + n.z * 0.02 + n.x * side,
|
|
811
|
+
};
|
|
812
|
+
const face = hit.collider.castRayAndGetNormal(new RAPIER.Ray(from, { x: -n.x, y: -n.y, z: -n.z }), 0.04, true);
|
|
813
|
+
const score = face ? face.normal.x * n.x + face.normal.y * n.y + face.normal.z * n.z : -1;
|
|
814
|
+
if (face && face.timeOfImpact > 0 && score > alignment) {
|
|
815
|
+
best = face.normal;
|
|
816
|
+
alignment = score;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
return best;
|
|
820
|
+
}
|
|
821
|
+
|
|
792
822
|
// The author-facing API behaviors reach through `scene.physics3d`. Motion goes
|
|
793
823
|
// through the body (never by writing a dynamic actor's Transform); rays
|
|
794
824
|
// exclude sensors so ground checks don't land on pickups.
|
|
@@ -808,6 +838,14 @@ function makeApi(system, runtime) {
|
|
|
808
838
|
}
|
|
809
839
|
return bodyOf(actor);
|
|
810
840
|
},
|
|
841
|
+
// After directly correcting a body's position, discard its pre-correction
|
|
842
|
+
// interpolation pose. Frames without a fixed step then draw the body
|
|
843
|
+
// where it was put; the next fixed step starts fresh history there.
|
|
844
|
+
resetInterpolation: (actor) => {
|
|
845
|
+
runtime.touch?.(actor);
|
|
846
|
+
const entry = system.bodies.get(idOf(actor));
|
|
847
|
+
if (entry) entry.prev = null;
|
|
848
|
+
},
|
|
811
849
|
mass: (actor) => bodyOf(actor)?.mass() ?? 0,
|
|
812
850
|
getVelocity: (actor) => {
|
|
813
851
|
const v = bodyOf(actor)?.linvel();
|
|
@@ -887,6 +925,25 @@ function makeApi(system, runtime) {
|
|
|
887
925
|
const n = met.normal;
|
|
888
926
|
return { distance: met.timeOfImpact, actorId: system.byCollider.get(met.collider.handle) ?? null, normal: { x: n.x, y: n.y, z: n.z } };
|
|
889
927
|
},
|
|
928
|
+
// Player walk probe: sweep its actual collider horizontally a short
|
|
929
|
+
// distance, including the capsule's lower part against low barriers.
|
|
930
|
+
// Only fixed solids; exclude the player and optionally the first wall
|
|
931
|
+
// so a second probe can find the other face of a corner. The 1 cm skin
|
|
932
|
+
// removes the into-wall target before contact creates sustained friction.
|
|
933
|
+
castWalkWall: (actor, dir, maxToi, excludeCollider) => {
|
|
934
|
+
const body = bodyOf(actor);
|
|
935
|
+
const collider = system.bodies.get(idOf(actor))?.collider;
|
|
936
|
+
if (!system.world || !body || !collider) return null;
|
|
937
|
+
const hit = system.world.castShape(
|
|
938
|
+
collider.translation(), collider.rotation(), dir, collider.shape, 0.01, maxToi, false,
|
|
939
|
+
fixedSolids(), undefined, undefined, body,
|
|
940
|
+
excludeCollider === undefined ? undefined : (collider) => collider.handle !== excludeCollider
|
|
941
|
+
);
|
|
942
|
+
if (!hit) return null;
|
|
943
|
+
const n = walkFaceNormal(hit);
|
|
944
|
+
return { distance: hit.time_of_impact, actorId: system.byCollider.get(hit.collider.handle) ?? null,
|
|
945
|
+
colliderHandle: hit.collider.handle, normal: { x: n.x, y: n.y, z: n.z } };
|
|
946
|
+
},
|
|
890
947
|
// `castBallFixed`: a ball of `radius` swept from `origin` along the unit
|
|
891
948
|
// `dir`, no farther than `maxToi`; the first fixed solid it touches, as
|
|
892
949
|
// `{ distance, actorId, normal }` (how far the ball's middle got, and the
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
"imports": {
|
|
4
4
|
"castle.base": {
|
|
5
5
|
"deckId": "yRcmH4_aYllE",
|
|
6
|
-
"version": "2026-
|
|
6
|
+
"version": "2026-11-15T00:40:25.157Z"
|
|
7
7
|
}
|
|
8
8
|
},
|
|
9
9
|
"autoUpdateWhenImported": true,
|
|
10
10
|
"deckId": "xFVr-afOLuUQ",
|
|
11
11
|
"cardId": "w6G45sy3_P_m",
|
|
12
|
-
"publishedVersion": "2026-
|
|
12
|
+
"publishedVersion": "2026-11-15T00:41:55.124Z"
|
|
13
13
|
}
|
|
@@ -163,6 +163,9 @@ export async function connectSession({
|
|
|
163
163
|
// or still open).
|
|
164
164
|
closeError: () => net.closeCode ?? null,
|
|
165
165
|
|
|
166
|
+
// Ask the SDK to recover a silent socket; older SDKs cannot do this.
|
|
167
|
+
reconnect: () => typeof connection.reconnect === 'function' ? connection.reconnect() : false,
|
|
168
|
+
|
|
166
169
|
// Connection and presence data for a deck status line.
|
|
167
170
|
status: () => ({
|
|
168
171
|
state: connection.state,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "castle-web-cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.241",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/castle-xyz/castle-experimental-web.git"
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "rm -rf dist && tsc && chmod +x dist/index.js && vite build && vite build -c vite.cover-bridge.config.ts && cp -R src/castle-host dist/castle-host && chmod -R u+w kits 2>/dev/null; rm -rf kits && cp -R ../kits kits && chmod -R u+w kits && rm -rf kits/*/imports && node ../scripts/vendor-three.mjs",
|
|
14
14
|
"dev": "tsc --watch",
|
|
15
|
-
"check": "node ../scripts/sync-shared.mjs --check && node ../scripts/tests/icon-registry.mjs && node ../scripts/tests/sandbox-graphql-fields.mjs && node ../scripts/tests/kit-package-json.mjs && node ../scripts/tests/kit-catalog.mjs && node ../scripts/tests/import-deck-ref.mjs && node ../scripts/tests/hub-server-config.mjs && node ../scripts/tests/save-failure-reason.mjs && node ../scripts/tests/flow-draft-status.mjs && node ../scripts/tests/router-fences.mjs && node ../scripts/tests/held-tasks.mjs && node ../scripts/tests/held-task-prompts.mjs && node ../scripts/tests/router-stops.mjs && node ../scripts/tests/task-steer.mjs && node ../scripts/tests/task-steer-store.mjs && node ../scripts/tests/task-steer-line.mjs && node ../scripts/tests/router-task-endings.mjs && node ../scripts/tests/router-task-report.mjs && node ../scripts/tests/task-resume.mjs && node ../scripts/tests/task-model-request.mjs && node ../scripts/tests/plan-answered-questions.mjs && node ../scripts/tests/plan-no-standing-nudge.mjs && node ../scripts/tests/sdk-readme-limits.mjs && node ../scripts/tests/task-account.mjs && node ../scripts/tests/effort-support.mjs && node ../scripts/tests/cli-login-pkce.mjs && node ../scripts/tests/publish-timeout.mjs && node ../scripts/tests/bundle-latin1.mjs && eslint . && jscpd && tsc --noEmit && tsc --noEmit -p src/shell/tsconfig.json"
|
|
15
|
+
"check": "node ../scripts/sync-shared.mjs --check && node ../scripts/tests/icon-registry.mjs && node ../scripts/tests/sandbox-graphql-fields.mjs && node ../scripts/tests/kit-package-json.mjs && node ../scripts/tests/kit-catalog.mjs && node ../scripts/tests/import-order.mjs && node ../scripts/tests/import-deck-ref.mjs && node ../scripts/tests/hub-server-config.mjs && node ../scripts/tests/save-failure-reason.mjs && node ../scripts/tests/flow-draft-status.mjs && node ../scripts/tests/router-fences.mjs && node ../scripts/tests/held-tasks.mjs && node ../scripts/tests/held-task-prompts.mjs && node ../scripts/tests/router-stops.mjs && node ../scripts/tests/task-steer.mjs && node ../scripts/tests/task-steer-store.mjs && node ../scripts/tests/task-steer-line.mjs && node ../scripts/tests/router-task-endings.mjs && node ../scripts/tests/router-task-report.mjs && node ../scripts/tests/task-resume.mjs && node ../scripts/tests/task-model-request.mjs && node ../scripts/tests/plan-answered-questions.mjs && node ../scripts/tests/plan-no-standing-nudge.mjs && node ../scripts/tests/sdk-readme-limits.mjs && node ../scripts/tests/task-account.mjs && node ../scripts/tests/effort-support.mjs && node ../scripts/tests/cli-login-pkce.mjs && node ../scripts/tests/publish-timeout.mjs && node ../scripts/tests/bundle-latin1.mjs && eslint . && jscpd && tsc --noEmit && tsc --noEmit -p src/shell/tsconfig.json"
|
|
16
16
|
},
|
|
17
17
|
"jscpd": {
|
|
18
18
|
"path": [
|