castle-web-cli 0.4.232 → 0.4.234
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-failures.d.ts +8 -0
- package/dist/agent-failures.js +19 -2
- package/dist/agent-prompts.d.ts +1 -1
- package/dist/agent-prompts.js +10 -3
- package/dist/agent.d.ts +64 -3
- package/dist/agent.js +170 -81
- package/dist/api.d.ts +11 -0
- package/dist/api.js +43 -0
- package/dist/bundle.d.ts +64 -0
- package/dist/bundle.js +558 -2
- package/dist/castle-host/host.d.ts +18 -2
- package/dist/castle-host/host.js +844 -39
- package/dist/castleJson.d.ts +23 -2
- package/dist/castleJson.js +46 -2
- package/dist/check.d.ts +3 -1
- package/dist/check.js +20 -3
- package/dist/chunkLoader.d.ts +3 -0
- package/dist/chunkLoader.js +111 -0
- package/dist/devParty.d.ts +26 -0
- package/dist/devParty.js +231 -0
- package/dist/devSaveStorage.js +4 -0
- package/dist/devSessionStorage.js +50 -2
- package/dist/devSocial.d.ts +24 -0
- package/dist/devSocial.js +70 -0
- package/dist/ide.d.ts +2 -0
- package/dist/ide.js +119 -15
- package/dist/importPinMismatch.d.ts +22 -0
- package/dist/importPinMismatch.js +77 -0
- package/dist/importRegression.js +3 -15
- package/dist/imports.d.ts +10 -3
- package/dist/imports.js +88 -20
- package/dist/index.js +11 -4
- package/dist/init.js +1 -1
- package/dist/platformDoc.js +22 -0
- package/dist/routerFences.d.ts +5 -0
- package/dist/routerFences.js +12 -2
- package/dist/save-deck.d.ts +25 -1
- package/dist/save-deck.js +178 -9
- package/dist/serve.js +32 -11
- package/dist/shell/assets/{index-D2tWM896.js → index-DulbYIJm.js} +97 -97
- package/dist/shell/assets/index-MVLfNYd9.css +1 -0
- package/dist/shell/index.html +2 -2
- package/dist/taskSteer.d.ts +13 -0
- package/dist/taskSteer.js +22 -2
- package/dist/vitePlugins.d.ts +2 -1
- package/dist/vitePlugins.js +13 -0
- package/kits/base/castle.json +1 -1
- package/kits/base/package-lock.json +1 -1
- package/kits/base/sdk/README.md +339 -5
- package/kits/base/sdk/avatar.d.ts +6 -2
- package/kits/base/sdk/avatar.js +12 -4
- package/kits/base/sdk/castle.d.ts +7 -3
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +176 -1
- package/kits/base/sdk/commands.js +3 -0
- package/kits/base/sdk/display.d.ts +3 -0
- package/kits/base/sdk/display.js +9 -3
- package/kits/base/sdk/hub.d.ts +37 -6
- package/kits/base/sdk/hub.js +63 -4
- package/kits/base/sdk/multiplayer.d.ts +7 -1
- package/kits/base/sdk/multiplayer.js +148 -32
- package/kits/base/sdk/multiplayerProtocol.d.ts +2 -0
- package/kits/base/sdk/party.d.ts +23 -0
- package/kits/base/sdk/party.js +91 -0
- package/kits/base/sdk/reconnectBudget.d.ts +23 -0
- package/kits/base/sdk/reconnectBudget.js +96 -0
- package/kits/base/sdk/save.d.ts +38 -1
- package/kits/base/sdk/save.js +81 -7
- package/kits/base/sdk/server/hub.d.ts +117 -0
- package/kits/base/sdk/server/hub.js +119 -2
- package/kits/base/sdk/server/platformHandle.d.ts +43 -1
- package/kits/base/sdk/server/storage.d.ts +17 -0
- package/kits/base/sdk/server/storage.js +65 -3
- package/kits/base/sdk/server/wrapper.d.ts +43 -6
- package/kits/base/sdk/server/wrapper.js +93 -9
- package/kits/base/sdk/social.d.ts +9 -0
- package/kits/base/sdk/social.js +5 -0
- package/kits/hub-game/CLAUDE.md +451 -13
- package/kits/hub-game/README.md +63 -0
- package/kits/hub-game/blueprints/avatar-10.scene +28 -0
- package/kits/hub-game/blueprints/avatar-11.scene +28 -0
- package/kits/hub-game/blueprints/avatar-12.scene +28 -0
- package/kits/hub-game/blueprints/avatar-13.scene +28 -0
- package/kits/hub-game/blueprints/avatar-14.scene +28 -0
- package/kits/hub-game/blueprints/avatar-15.scene +28 -0
- package/kits/hub-game/blueprints/avatar-4.scene +28 -0
- package/kits/hub-game/blueprints/avatar-5.scene +28 -0
- package/kits/hub-game/blueprints/avatar-6.scene +28 -0
- package/kits/hub-game/blueprints/avatar-7.scene +28 -0
- package/kits/hub-game/blueprints/avatar-8.scene +28 -0
- package/kits/hub-game/blueprints/avatar-9.scene +28 -0
- package/kits/hub-game/castle.json +5 -5
- package/kits/hub-game/code/client/act.js +312 -0
- package/kits/hub-game/code/client/actionLayout.js +147 -0
- package/kits/hub-game/code/client/actionOverflow.js +556 -0
- package/kits/hub-game/code/client/actorBudget.js +47 -0
- package/kits/hub-game/code/client/arrivalCamera.js +50 -0
- package/kits/hub-game/code/client/askSlot.js +117 -0
- package/kits/hub-game/code/client/attention.js +11 -2
- package/kits/hub-game/code/client/avatar.js +311 -35
- package/kits/hub-game/code/client/avatarCap.js +228 -0
- package/kits/hub-game/code/client/avatarColors.js +70 -0
- package/kits/hub-game/code/client/avatarFaces.js +21 -0
- package/kits/hub-game/code/client/avatarShare.js +253 -0
- package/kits/hub-game/code/client/backVisibility.js +13 -0
- package/kits/hub-game/code/client/ballot.js +472 -0
- package/kits/hub-game/code/client/build.js +38 -0
- package/kits/hub-game/code/client/chat.js +41 -5
- package/kits/hub-game/code/client/chatModeration.js +5 -0
- package/kits/hub-game/code/client/chrome.js +2144 -160
- package/kits/hub-game/code/client/companion.js +716 -0
- package/kits/hub-game/code/client/companionDress.js +99 -0
- package/kits/hub-game/code/client/crowdNames.js +241 -0
- package/kits/hub-game/code/client/decor.js +515 -0
- package/kits/hub-game/code/client/defaultEnvironment.js +194 -0
- package/kits/hub-game/code/client/doorErrors.js +39 -0
- package/kits/hub-game/code/client/earned.js +131 -0
- package/kits/hub-game/code/client/emoteBubble.js +75 -0
- package/kits/hub-game/code/client/fall.js +18 -0
- package/kits/hub-game/code/client/farAvatars.js +233 -0
- package/kits/hub-game/code/client/firstJoin.js +9 -2
- package/kits/hub-game/code/client/fpsTelemetry.js +50 -0
- package/kits/hub-game/code/client/frameBatch.js +5 -0
- package/kits/hub-game/code/client/grab.js +368 -29
- package/kits/hub-game/code/client/hookLayer.js +385 -20
- package/kits/hub-game/code/client/hudCopy.js +51 -0
- package/kits/hub-game/code/client/hudRate.js +20 -0
- package/kits/hub-game/code/client/idle.js +177 -24
- package/kits/hub-game/code/client/interestCap.js +81 -0
- package/kits/hub-game/code/client/invites.js +231 -0
- package/kits/hub-game/code/client/joinError.js +9 -0
- package/kits/hub-game/code/client/keys.js +36 -0
- package/kits/hub-game/code/client/labelsNear.js +234 -0
- package/kits/hub-game/code/client/landscapeLayout.js +17 -0
- package/kits/hub-game/code/client/layoutCache.js +264 -0
- package/kits/hub-game/code/client/loadTelemetry.js +20 -0
- package/kits/hub-game/code/client/loadingCover.js +148 -0
- package/kits/hub-game/code/client/loadingEntry.js +8 -0
- package/kits/hub-game/code/client/menuIcons.js +34 -0
- package/kits/hub-game/code/client/menuRows.js +43 -0
- package/kits/hub-game/code/client/modelReady.js +7 -0
- package/kits/hub-game/code/client/pack.js +6 -2
- package/kits/hub-game/code/client/packFormat.js +3 -3
- package/kits/hub-game/code/client/padCueArrival.js +23 -0
- package/kits/hub-game/code/client/padCues.js +112 -0
- package/kits/hub-game/code/client/padOccupancy.js +88 -0
- package/kits/hub-game/code/client/padReadability.js +26 -0
- package/kits/hub-game/code/client/padRings.js +69 -0
- package/kits/hub-game/code/client/pushVisit.js +14 -0
- package/kits/hub-game/code/client/quality.js +205 -0
- package/kits/hub-game/code/client/qualityEntry.js +55 -0
- package/kits/hub-game/code/client/rehello.js +167 -0
- package/kits/hub-game/code/client/safeLayout.js +338 -0
- package/kits/hub-game/code/client/safeStyle.js +42 -0
- package/kits/hub-game/code/client/say.js +12 -3
- package/kits/hub-game/code/client/shot.js +146 -0
- package/kits/hub-game/code/client/shotFit.js +56 -0
- package/kits/hub-game/code/client/signIn.js +28 -0
- package/kits/hub-game/code/client/sound.js +63 -8
- package/kits/hub-game/code/client/soundscape.js +1151 -0
- package/kits/hub-game/code/client/soundscapeActions.js +99 -0
- package/kits/hub-game/code/client/soundscapeAmbience.js +453 -0
- package/kits/hub-game/code/client/soundscapeBaked.js +143 -0
- package/kits/hub-game/code/client/soundscapeBusker.js +217 -0
- package/kits/hub-game/code/client/soundscapeCourt.js +200 -0
- package/kits/hub-game/code/client/soundscapeCrowd.js +331 -0
- package/kits/hub-game/code/client/soundscapeCues.js +362 -0
- package/kits/hub-game/code/client/soundscapeMap.js +181 -0
- package/kits/hub-game/code/client/soundscapeMarket.js +176 -0
- package/kits/hub-game/code/client/soundscapeMusic.js +126 -0
- package/kits/hub-game/code/client/soundscapeMusicEngine.js +460 -0
- package/kits/hub-game/code/client/soundscapeSimlish.js +737 -0
- package/kits/hub-game/code/client/soundscapeSongs.js +127 -0
- package/kits/hub-game/code/client/soundscapeSongsRound3.js +63 -0
- package/kits/hub-game/code/client/soundscapeSynthesis.js +168 -0
- package/kits/hub-game/code/client/soundscapeUi.js +211 -0
- package/kits/hub-game/code/client/soundscapeVoice.js +1209 -0
- package/kits/hub-game/code/client/soundscapeWaves.js +206 -0
- package/kits/hub-game/code/client/spin.js +101 -0
- package/kits/hub-game/code/client/state.js +162 -1
- package/kits/hub-game/code/client/stuck.js +259 -0
- package/kits/hub-game/code/client/talk.js +714 -59
- package/kits/hub-game/code/client/tiers.js +543 -52
- package/kits/hub-game/code/client/toastBand.js +37 -0
- package/kits/hub-game/code/client/together.js +39 -2
- package/kits/hub-game/code/client/visibility.js +43 -0
- package/kits/hub-game/code/client/weakestLookBake.js +92 -0
- package/kits/hub-game/code/client/weakestTier.js +295 -0
- package/kits/hub-game/code/client/wear.js +461 -170
- package/kits/hub-game/code/client/worldLabels.js +241 -0
- package/kits/hub-game/code/client/yours.js +200 -0
- package/kits/hub-game/code/companionSpec.js +45 -0
- package/kits/hub-game/code/npcDisplayText.js +55 -0
- package/kits/hub-game/code/privateText.js +7 -0
- package/kits/hub-game/code/server/act.js +124 -0
- package/kits/hub-game/code/server/actions.js +138 -0
- package/kits/hub-game/code/server/actors.js +11 -2
- package/kits/hub-game/code/server/analytics.js +83 -0
- package/kits/hub-game/code/server/anonymousEntry.js +49 -0
- package/kits/hub-game/code/server/arrivalPose.js +36 -0
- package/kits/hub-game/code/server/ask.js +155 -0
- package/kits/hub-game/code/server/ballot.js +539 -0
- package/kits/hub-game/code/server/cells.js +100 -0
- package/kits/hub-game/code/server/companion.js +107 -0
- package/kits/hub-game/code/server/cues.js +70 -0
- package/kits/hub-game/code/server/decor.js +269 -0
- package/kits/hub-game/code/server/doorAnalytics.js +52 -0
- package/kits/hub-game/code/server/earned.js +478 -0
- package/kits/hub-game/code/server/frameBatch.js +183 -0
- package/kits/hub-game/code/server/friendBests.js +166 -0
- package/kits/hub-game/code/server/friendsAmong.js +272 -0
- package/kits/hub-game/code/server/history.js +7 -0
- package/kits/hub-game/code/server/hub.js +2510 -95
- package/kits/hub-game/code/server/idle.js +60 -12
- package/kits/hub-game/code/server/index.js +28 -6
- package/kits/hub-game/code/server/invites.js +19 -0
- package/kits/hub-game/code/server/labels.js +36 -2
- package/kits/hub-game/code/server/loadAbandon.js +106 -0
- package/kits/hub-game/code/server/manifest.js +586 -7
- package/kits/hub-game/code/server/menu.js +161 -0
- package/kits/hub-game/code/server/npcs.js +1025 -113
- package/kits/hub-game/code/server/observe.js +408 -0
- package/kits/hub-game/code/server/padOccupancy.js +85 -0
- package/kits/hub-game/code/server/party.js +2 -2
- package/kits/hub-game/code/server/players.js +30 -0
- package/kits/hub-game/code/server/resumePose.js +152 -0
- package/kits/hub-game/code/server/say.js +1 -1
- package/kits/hub-game/code/server/shot.js +110 -0
- package/kits/hub-game/code/server/standing.js +123 -0
- package/kits/hub-game/code/server/storageLimit.js +187 -0
- package/kits/hub-game/code/server/vis.js +175 -0
- package/kits/hub-game/code/server/wear.js +12 -0
- package/kits/hub-game/code/server/yours.js +59 -0
- package/kits/hub-game/code/shared/act.js +35 -0
- package/kits/hub-game/code/shared/cues.js +9 -0
- package/kits/hub-game/code/shared/danceIdle.js +28 -0
- package/kits/hub-game/code/shared/decor.js +41 -0
- package/kits/hub-game/code/shared/loadStages.js +12 -0
- package/kits/hub-game/code/shared/quality.js +74 -0
- package/kits/hub-game/code/shared/say.js +2 -0
- package/kits/hub-game/code/shared/shot.js +53 -0
- package/kits/hub-game/code/shared/spin.js +57 -0
- package/kits/hub-game/code/systems/hub.js +1753 -202
- package/kits/hub-game/docs/analytics.md +279 -0
- package/kits/hub-game/docs/content-pack.md +1 -1
- package/kits/hub-game/docs/contract.md +3475 -77
- package/kits/hub-game/docs/home-pieces.md +71 -0
- package/kits/hub-game/docs/observed-progress.md +252 -0
- package/kits/hub-game/main.jsx +2 -0
- package/kits/hub-game/models/avatar-10.pxmodel +28 -0
- package/kits/hub-game/models/avatar-11.pxmodel +28 -0
- package/kits/hub-game/models/avatar-12.pxmodel +27 -0
- package/kits/hub-game/models/avatar-13.pxmodel +24 -0
- package/kits/hub-game/models/avatar-14.pxmodel +29 -0
- package/kits/hub-game/models/avatar-15.pxmodel +24 -0
- package/kits/hub-game/models/avatar-4.pxmodel +29 -0
- package/kits/hub-game/models/avatar-5.pxmodel +27 -0
- package/kits/hub-game/models/avatar-6.pxmodel +26 -0
- package/kits/hub-game/models/avatar-7.pxmodel +25 -0
- package/kits/hub-game/models/avatar-8.pxmodel +24 -0
- package/kits/hub-game/models/avatar-9.pxmodel +30 -0
- package/kits/hub-game/models/earned/badge-round.pxmodel +100 -0
- package/kits/hub-game/models/earned/badge-shield.pxmodel +117 -0
- package/kits/hub-game/models/earned/badge-star.pxmodel +87 -0
- package/kits/hub-game/models/earned/belt-plain.pxmodel +72 -0
- package/kits/hub-game/models/earned/held-ball.pxmodel +43 -0
- package/kits/hub-game/models/earned/held-lantern.pxmodel +85 -0
- package/kits/hub-game/models/earned/held-net.pxmodel +57 -0
- package/kits/hub-game/models/earned/held-trophy.pxmodel +109 -0
- package/kits/hub-game/models/earned/pin-round.pxmodel +62 -0
- package/kits/hub-game/models/earned/sash-plain.pxmodel +66 -0
- package/kits/hub-game/models/earned/square/belt-plain.pxmodel +104 -0
- package/kits/hub-game/models/earned/square/sash-plain.pxmodel +98 -0
- package/kits/hub-game/models/hats/bat-clip.pxmodel +206 -0
- package/kits/hub-game/models/hats/beekeeper.pxmodel +149 -0
- package/kits/hub-game/models/hats/cap.pxmodel +162 -0
- package/kits/hub-game/models/hats/captain.pxmodel +178 -0
- package/kits/hub-game/models/hats/crooked-top.pxmodel +172 -0
- package/kits/hub-game/models/hats/flower-crown.pxmodel +451 -0
- package/kits/hub-game/models/hats/foam-crown.pxmodel +179 -0
- package/kits/hub-game/models/hats/lantern.pxmodel +230 -0
- package/kits/hub-game/models/hats/laurel.pxmodel +533 -0
- package/kits/hub-game/models/hats/lighthouse.pxmodel +96 -0
- package/kits/hub-game/models/hats/sailor.pxmodel +141 -0
- package/kits/hub-game/models/hats/souwester.pxmodel +131 -0
- package/kits/hub-game/models/hats/straw.pxmodel +139 -0
- package/kits/hub-game/models/hats/sunflower.pxmodel +406 -0
- package/kits/hub-game/models/hats/sweatband.pxmodel +112 -0
- package/kits/hub-game/models/hats/witch.pxmodel +147 -0
- package/kits/hub-game/package-lock.json +10 -1
- package/kits/hub-game/package.json +6 -2
- package/kits/hub-game/play/player.js +142 -0
- package/kits/hub-game/play/registry.js +47 -0
- package/kits/hub-game/play.jsx +37 -0
- package/kits/hub-game/scripts/check.mjs +117 -16
- package/kits/hub-game/scripts/companion-follower-wire.json +1 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +132 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless.json +293 -0
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +26 -0
- package/kits/hub-game/scripts/fixtures/fake-dom.mjs +123 -0
- package/kits/hub-game/scripts/fixtures/interest-legacy.json +385 -0
- package/kits/hub-game/scripts/fixtures/npc-notes-v1.77.jsonl +4 -0
- package/kits/hub-game/scripts/fixtures/vis-shared-wire.json +1 -0
- package/kits/hub-game/scripts/gen-avatars.mjs +933 -16
- package/kits/hub-game/scripts/gen-earned.mjs +285 -0
- package/kits/hub-game/scripts/gen-hats.mjs +827 -0
- package/kits/hub-game/scripts/grab.before-orbit.mjs +400 -0
- package/kits/hub-game/scripts/pose-storage-fixture.mjs +46 -0
- package/kits/hub-game/scripts/soundscape-wave-analysis.mjs +125 -0
- package/kits/hub-game/scripts/test-act-client.mjs +186 -0
- package/kits/hub-game/scripts/test-act.mjs +171 -0
- package/kits/hub-game/scripts/test-action-layout.mjs +80 -0
- package/kits/hub-game/scripts/test-action-observers.mjs +46 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +853 -0
- package/kits/hub-game/scripts/test-actions.mjs +298 -0
- package/kits/hub-game/scripts/test-actor-budget.mjs +44 -0
- package/kits/hub-game/scripts/test-actors.mjs +38 -23
- package/kits/hub-game/scripts/test-analytics.mjs +76 -0
- package/kits/hub-game/scripts/test-anonymous-entry.mjs +28 -0
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +196 -0
- package/kits/hub-game/scripts/test-arrival-pose.mjs +24 -0
- package/kits/hub-game/scripts/test-ask-client.mjs +358 -0
- package/kits/hub-game/scripts/test-ask-slot.mjs +85 -0
- package/kits/hub-game/scripts/test-ask.mjs +269 -0
- package/kits/hub-game/scripts/test-attention.mjs +10 -1
- package/kits/hub-game/scripts/test-avatar-cap.mjs +379 -0
- package/kits/hub-game/scripts/test-avatar-colors.mjs +72 -0
- package/kits/hub-game/scripts/test-avatar-models.mjs +181 -0
- package/kits/hub-game/scripts/test-avatar-share.mjs +318 -0
- package/kits/hub-game/scripts/test-avatar-wire.mjs +792 -0
- package/kits/hub-game/scripts/test-avatar.mjs +584 -7
- package/kits/hub-game/scripts/test-back-visibility.mjs +82 -0
- package/kits/hub-game/scripts/test-ballot.mjs +1008 -0
- package/kits/hub-game/scripts/test-ban-join.mjs +121 -13
- package/kits/hub-game/scripts/test-build.mjs +49 -0
- package/kits/hub-game/scripts/test-cells.mjs +71 -0
- package/kits/hub-game/scripts/test-chat.mjs +863 -0
- package/kits/hub-game/scripts/test-classic.mjs +2 -0
- package/kits/hub-game/scripts/test-companion-chat.mjs +216 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +1167 -0
- package/kits/hub-game/scripts/test-companion.mjs +259 -0
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +120 -0
- package/kits/hub-game/scripts/test-crowd-names.mjs +205 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +344 -0
- package/kits/hub-game/scripts/test-decor.mjs +464 -0
- package/kits/hub-game/scripts/test-default-environment-root.mjs +95 -0
- package/kits/hub-game/scripts/test-default-environment.mjs +267 -0
- package/kits/hub-game/scripts/test-door-analytics.mjs +58 -0
- package/kits/hub-game/scripts/test-door-jump.mjs +100 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +459 -0
- package/kits/hub-game/scripts/test-earned.mjs +1224 -0
- package/kits/hub-game/scripts/test-emote-bubble.mjs +110 -0
- package/kits/hub-game/scripts/test-far-avatars.mjs +340 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +112 -0
- package/kits/hub-game/scripts/test-frame-batch.mjs +252 -0
- package/kits/hub-game/scripts/test-fresh-friends.mjs +118 -0
- package/kits/hub-game/scripts/test-friend-bests.mjs +435 -0
- package/kits/hub-game/scripts/test-grab-orbit.mjs +961 -0
- package/kits/hub-game/scripts/test-grab.mjs +7 -0
- package/kits/hub-game/scripts/test-hats.mjs +422 -168
- package/kits/hub-game/scripts/test-high-only.mjs +170 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +203 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +758 -2
- package/kits/hub-game/scripts/test-hub-trip.mjs +1594 -12
- package/kits/hub-game/scripts/test-hud-clear.mjs +484 -57
- package/kits/hub-game/scripts/test-hud-defects-dom.mjs +100 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +224 -0
- package/kits/hub-game/scripts/test-hud-safe-visibility-dom.mjs +83 -0
- package/kits/hub-game/scripts/test-idle.mjs +427 -1
- package/kits/hub-game/scripts/test-interest-cap.mjs +36 -0
- package/kits/hub-game/scripts/test-interest-cells.mjs +513 -0
- package/kits/hub-game/scripts/test-interest-client.mjs +118 -0
- package/kits/hub-game/scripts/test-interest.mjs +15 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +430 -0
- package/kits/hub-game/scripts/test-invites.mjs +109 -0
- package/kits/hub-game/scripts/test-keys.mjs +46 -1
- package/kits/hub-game/scripts/test-labels.mjs +664 -0
- package/kits/hub-game/scripts/test-landscape-layout.mjs +194 -0
- package/kits/hub-game/scripts/test-list-scroll-dom.mjs +49 -0
- package/kits/hub-game/scripts/test-load-abandon.mjs +246 -0
- package/kits/hub-game/scripts/test-loading-cover.mjs +162 -0
- package/kits/hub-game/scripts/test-manifest.mjs +472 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +585 -0
- package/kits/hub-game/scripts/test-menu.mjs +319 -0
- package/kits/hub-game/scripts/test-npcs.mjs +2528 -13
- package/kits/hub-game/scripts/test-object-entry.mjs +76 -0
- package/kits/hub-game/scripts/test-observed.mjs +745 -0
- package/kits/hub-game/scripts/test-pack.mjs +7 -0
- package/kits/hub-game/scripts/test-pad-cues.mjs +304 -0
- package/kits/hub-game/scripts/test-pad-occupancy.mjs +177 -0
- package/kits/hub-game/scripts/test-picker.mjs +541 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +690 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +559 -0
- package/kits/hub-game/scripts/test-push-visit.mjs +26 -0
- package/kits/hub-game/scripts/test-quality.mjs +385 -0
- package/kits/hub-game/scripts/test-rehello.mjs +1733 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +222 -0
- package/kits/hub-game/scripts/test-relations-refresh.mjs +188 -0
- package/kits/hub-game/scripts/test-resume-action-order.mjs +598 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +239 -0
- package/kits/hub-game/scripts/test-resume-pose.mjs +142 -0
- package/kits/hub-game/scripts/test-safe-events-dom.mjs +116 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +330 -0
- package/kits/hub-game/scripts/test-say.mjs +1 -1
- package/kits/hub-game/scripts/test-shot.mjs +901 -0
- package/kits/hub-game/scripts/test-signin-client.mjs +45 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +5437 -0
- package/kits/hub-game/scripts/test-spin.mjs +314 -0
- package/kits/hub-game/scripts/test-standing.mjs +449 -0
- package/kits/hub-game/scripts/test-storage-limit.mjs +333 -0
- package/kits/hub-game/scripts/test-stuck.mjs +1904 -0
- package/kits/hub-game/scripts/test-talk-overlay-dom.mjs +130 -0
- package/kits/hub-game/scripts/test-tier-cells.mjs +706 -0
- package/kits/hub-game/scripts/test-tiers-render.mjs +412 -0
- package/kits/hub-game/scripts/test-tiers.mjs +476 -2
- package/kits/hub-game/scripts/test-toast-band.mjs +61 -0
- package/kits/hub-game/scripts/test-try-on.mjs +22 -22
- package/kits/hub-game/scripts/test-vis.mjs +770 -0
- package/kits/hub-game/scripts/test-visibility.mjs +134 -0
- package/kits/hub-game/scripts/test-weakest-tier.mjs +924 -0
- package/kits/hub-game/scripts/test-world-labels.mjs +367 -0
- package/kits/hub-game/scripts/test-yours-chrome.mjs +210 -0
- package/kits/hub-game/scripts/test-yours.mjs +403 -0
- package/kits/multiplayer-3d/CLAUDE.md +50 -0
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/avatars.js +7 -0
- package/kits/multiplayer-3d/code/client/gait.js +65 -0
- package/kits/multiplayer-3d/code/client/joinFailure.js +27 -0
- package/kits/multiplayer-3d/code/client/nameTags.js +59 -4
- package/kits/multiplayer-3d/code/client/resumeGate.js +139 -0
- package/kits/multiplayer-3d/code/options.js +5 -0
- package/kits/multiplayer-3d/code/server/ownership.js +10 -2
- package/kits/multiplayer-3d/code/server/sceneBodies.js +12 -0
- package/kits/multiplayer-3d/code/server/world.js +7 -0
- package/kits/multiplayer-3d/code/systems/multiplayer.js +443 -34
- package/kits/multiplayer-3d/package-lock.json +8 -1
- package/kits/multiplayer-3d/package.json +3 -1
- package/kits/multiplayer-3d/scripts/fixtures/README.md +11 -0
- package/kits/multiplayer-3d/scripts/fixtures/ownership-legacy.json +2 -0
- package/kits/multiplayer-3d/scripts/ownership-harness.mjs +102 -0
- package/kits/multiplayer-3d/scripts/ownership-loader.mjs +46 -0
- package/kits/multiplayer-3d/scripts/ownership-worker.mjs +15 -0
- package/kits/multiplayer-3d/scripts/record-ownership-session.mjs +98 -0
- package/kits/multiplayer-3d/scripts/test-eligible-claims.mjs +167 -0
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +436 -0
- package/kits/multiplayer-3d/scripts/test-own-name-tag.mjs +247 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +624 -0
- package/kits/physics-2d/CLAUDE.md +19 -1
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/frozenActors.js +233 -0
- package/kits/physics-2d/engine/scene.js +337 -3
- package/kits/physics-2d/engine/skyKey.js +129 -0
- package/kits/physics-2d/engine/stillClock.js +106 -0
- package/kits/physics-2d/engine/updateBudget.js +21 -0
- package/kits/physics-2d/eslint.config.js +1 -1
- package/kits/physics-2d/play/behaviors/AnalogStick.js +198 -0
- package/kits/physics-2d/play/behaviors/Camera.js +40 -0
- package/kits/physics-2d/play/behaviors/Collider.js +122 -0
- package/kits/physics-2d/play/behaviors/Draggable.js +115 -0
- package/kits/physics-2d/play/behaviors/Goal.js +46 -0
- package/kits/physics-2d/play/behaviors/Joints.js +126 -0
- package/kits/physics-2d/play/behaviors/Layout.js +71 -0
- package/kits/physics-2d/play/behaviors/RigidBody.js +57 -0
- package/kits/physics-2d/play/behaviors/Slingshot.js +142 -0
- package/kits/physics-2d/play/behaviors/SoundPlayer.js +263 -0
- package/kits/physics-2d/play/behaviors/Sprite.js +406 -0
- package/kits/physics-2d/play/behaviors/Style.js +209 -0
- package/kits/physics-2d/play/behaviors/Text.js +85 -0
- package/kits/physics-2d/play/behaviors/Video.js +93 -0
- package/kits/physics-2d/scripts/test-skip-unchanged.mjs +326 -1
- package/kits/physics-3d/CLAUDE.md +42 -529
- package/kits/physics-3d/behaviors/Body.jsx +3 -0
- package/kits/physics-3d/behaviors/Model.jsx +3 -0
- package/kits/physics-3d/behaviors/Player.jsx +661 -87
- package/kits/physics-3d/behaviors/Shape.jsx +3 -0
- package/kits/physics-3d/behaviors/Solid.jsx +3 -0
- package/kits/physics-3d/behaviors/Transform.jsx +3 -0
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-camera.md +542 -0
- package/kits/physics-3d/docs/engine-frame-cap.md +136 -0
- package/kits/physics-3d/docs/engine-load.md +149 -0
- package/kits/physics-3d/docs/engine-look.md +114 -0
- package/kits/physics-3d/docs/engine-shadows.md +372 -0
- package/kits/physics-3d/docs/engine-skip-work.md +187 -0
- package/kits/physics-3d/docs/engine-sky.md +198 -0
- package/kits/physics-3d/docs/engine-static-actors.md +226 -0
- package/kits/physics-3d/docs/engine-view.md +37 -0
- package/kits/physics-3d/docs/pxmodel-format.md +9 -1
- package/kits/physics-3d/engine3d/PlayOnly3D.jsx +5 -1
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +19 -277
- package/kits/physics-3d/engine3d/actornode.js +87 -0
- package/kits/physics-3d/engine3d/animationBudget.js +23 -0
- package/kits/physics-3d/engine3d/branches.js +3 -13
- package/kits/physics-3d/engine3d/cage.js +2 -7
- package/kits/physics-3d/engine3d/cageops.js +2 -17
- package/kits/physics-3d/engine3d/dataBehaviors.js +12 -0
- package/kits/physics-3d/engine3d/editorWorld.js +6 -0
- package/kits/physics-3d/engine3d/emptynodes.js +232 -0
- package/kits/physics-3d/engine3d/framecap.js +99 -0
- package/kits/physics-3d/engine3d/frozenphysics.js +140 -0
- package/kits/physics-3d/engine3d/frozenstatics.js +273 -0
- package/kits/physics-3d/engine3d/gait.js +126 -0
- package/kits/physics-3d/engine3d/initialModelFiles.js +18 -0
- package/kits/physics-3d/engine3d/kithooks.js +47 -0
- package/kits/physics-3d/engine3d/look.js +514 -48
- package/kits/physics-3d/engine3d/lookbake.js +208 -0
- package/kits/physics-3d/engine3d/materialpresets.js +2 -0
- package/kits/physics-3d/engine3d/modelFiles.js +3 -17
- package/kits/physics-3d/engine3d/modelMath.js +49 -0
- package/kits/physics-3d/engine3d/modelready.js +16 -0
- package/kits/physics-3d/engine3d/motion.js +39 -10
- package/kits/physics-3d/engine3d/nearshadows.js +106 -21
- package/kits/physics-3d/engine3d/optimize.js +9 -5
- package/kits/physics-3d/engine3d/orbitinput.js +522 -10
- package/kits/physics-3d/engine3d/orbitlens.js +48 -0
- package/kits/physics-3d/engine3d/ownmodel.js +213 -0
- package/kits/physics-3d/engine3d/partgeometry.js +1 -16
- package/kits/physics-3d/engine3d/paths.js +1 -9
- package/kits/physics-3d/engine3d/playTimings.js +50 -0
- package/kits/physics-3d/engine3d/playerRun.js +372 -0
- package/kits/physics-3d/engine3d/pxmodel.js +42 -11
- package/kits/physics-3d/engine3d/rapier.js +27 -0
- package/kits/physics-3d/engine3d/scatter.js +1 -11
- package/kits/physics-3d/engine3d/shadowfade.js +890 -0
- package/kits/physics-3d/engine3d/sky.js +547 -0
- package/kits/physics-3d/engine3d/skylife.js +306 -0
- package/kits/physics-3d/engine3d/squarefirst.js +177 -0
- package/kits/physics-3d/engine3d/stillshadows.js +399 -0
- package/kits/physics-3d/engine3d/sweep.js +1 -25
- package/kits/physics-3d/engine3d/unchanged.js +11 -0
- package/kits/physics-3d/engine3d/viewrange.js +52 -0
- package/kits/physics-3d/engine3d/world3d.js +1253 -76
- package/kits/physics-3d/eslint.config.js +2 -1
- package/kits/physics-3d/main.jsx +10 -2
- package/kits/physics-3d/package-lock.json +7 -0
- package/kits/physics-3d/package.json +5 -1
- package/kits/physics-3d/play/behaviors/Body.js +31 -0
- package/kits/physics-3d/play/behaviors/Door.js +37 -0
- package/kits/physics-3d/play/behaviors/Lookable.js +16 -0
- package/kits/physics-3d/play/behaviors/Model.js +23 -0
- package/kits/physics-3d/play/behaviors/Pickup.js +46 -0
- package/kits/physics-3d/play/behaviors/Player.js +1204 -0
- package/kits/physics-3d/play/behaviors/Shape.js +47 -0
- package/kits/physics-3d/play/behaviors/Solid.js +16 -0
- package/kits/physics-3d/play/behaviors/Transform.js +29 -0
- package/kits/physics-3d/pnpm-lock.yaml +8 -0
- package/kits/physics-3d/scripts/bench-shadow-fade.mjs +37 -0
- package/kits/physics-3d/scripts/build-rapier-gz.mjs +56 -0
- package/kits/physics-3d/scripts/frozen-statics-fixture.mjs +141 -0
- package/kits/physics-3d/scripts/look-baseline.mjs +155 -0
- package/kits/physics-3d/scripts/test-camera-follow.mjs +5 -1
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +2613 -82
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +2 -2
- package/kits/physics-3d/scripts/test-empty-gait-hints.mjs +89 -0
- package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +438 -0
- package/kits/physics-3d/scripts/test-frame-cap.mjs +452 -0
- package/kits/physics-3d/scripts/test-frozen-nested.mjs +49 -0
- package/kits/physics-3d/scripts/test-frozen-statics-legacy-physics2d.mjs +123 -0
- package/kits/physics-3d/scripts/test-frozen-statics.mjs +434 -0
- package/kits/physics-3d/scripts/test-gait.mjs +387 -0
- package/kits/physics-3d/scripts/test-look-bake.mjs +1056 -0
- package/kits/physics-3d/scripts/test-model-parse-cache.mjs +92 -0
- package/kits/physics-3d/scripts/test-near-shadows.mjs +5 -2
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +2001 -0
- package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +582 -0
- package/kits/physics-3d/scripts/test-orbit-shot.mjs +657 -0
- package/kits/physics-3d/scripts/test-orbit-view.mjs +230 -0
- package/kits/physics-3d/scripts/test-rapier-gz.mjs +106 -0
- package/kits/physics-3d/scripts/test-skip-empty-nodes.mjs +845 -0
- package/kits/physics-3d/scripts/test-sky.mjs +2470 -0
- package/kits/physics-3d/scripts/test-square-first.mjs +921 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +10 -1
- package/kits/physics-3d/scripts/test-static-physics.mjs +4 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +2174 -0
- package/kits/physics-3d/scripts/test-steady-hover.mjs +7 -2
- package/kits/physics-3d/scripts/test-still-shadows.mjs +477 -0
- package/kits/physics-3d/scripts/test-view-range.mjs +260 -0
- package/kits/physics-3d/systems/physics3d.js +419 -9
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +33 -10
- package/kits/real-time/code/client/gameHooks.js +2 -0
- package/kits/real-time/code/client/joinOverlay.js +9 -4
- package/kits/real-time/code/server/gameHooks.js +7 -0
- package/kits/real-time/code/server/session.js +102 -22
- package/kits/real-time/package-lock.json +1 -1
- package/package.json +2 -2
- package/dist/shell/assets/index-Cf61cNfT.css +0 -1
|
@@ -10,9 +10,15 @@
|
|
|
10
10
|
// rapier's wasm loads async; the system installs immediately and starts
|
|
11
11
|
// simulating on the first frame after init resolves.
|
|
12
12
|
import * as THREE from 'three';
|
|
13
|
-
import * as RAPIER from '
|
|
14
|
-
import { remember, sameAs } from '../engine3d/unchanged.js';
|
|
13
|
+
import * as RAPIER from '../engine3d/rapier.js';
|
|
14
|
+
import { remember, sameAs, noteChangedStill } from '../engine3d/unchanged.js';
|
|
15
15
|
import { isOrbitLook } from '../engine3d/orbitinput.js';
|
|
16
|
+
import { giveBackOrbitLens } from '../engine3d/orbitlens.js';
|
|
17
|
+
import { giveBackViewRange } from '../engine3d/viewrange.js';
|
|
18
|
+
import { leaveSky } from '../engine3d/skylife.js';
|
|
19
|
+
import { dropShadowFade } from '../engine3d/shadowfade.js';
|
|
20
|
+
import { FrozenPhysics } from '../engine3d/frozenphysics.js';
|
|
21
|
+
import { prepareModelConsumers } from '../engine3d/modelready.js';
|
|
16
22
|
|
|
17
23
|
const FIXED_STEP = 1 / 60;
|
|
18
24
|
const MAX_STEPS_PER_FRAME = 4;
|
|
@@ -38,13 +44,15 @@ function ensureRapierInit() {
|
|
|
38
44
|
// with (behaviors run before physics, and see last frame's). It is placed on a
|
|
39
45
|
// frame physics could not step too (rapier still loading). A request is used
|
|
40
46
|
// once, and only while the scene it was made for is loaded; a load and a
|
|
41
|
-
// dispose drop it (`reset`).
|
|
42
|
-
//
|
|
47
|
+
// dispose drop it (`reset`). A scene that capped its frame rate
|
|
48
|
+
// (`"engine": { "maxFps": n }`) asks for its keyless follow camera the same
|
|
49
|
+
// way (Player.jsx `placeCapped`). Without either key nothing is asked for, and
|
|
50
|
+
// this reads one property and returns.
|
|
43
51
|
export function placeFollowCamera(scene) {
|
|
44
52
|
const request = scene.followCamera;
|
|
45
53
|
if (!request) return;
|
|
46
54
|
scene.followCamera = null;
|
|
47
|
-
if (scene.cameraFollowsRigidly !== true || request.data !== scene.data) return;
|
|
55
|
+
if ((scene.cameraFollowsRigidly !== true && !(scene.maxFps > 0)) || request.data !== scene.data) return;
|
|
48
56
|
request.place(scene, request.id, request.dt);
|
|
49
57
|
}
|
|
50
58
|
|
|
@@ -79,6 +87,7 @@ export class Physics3DSystem {
|
|
|
79
87
|
}
|
|
80
88
|
|
|
81
89
|
reset(runtime) {
|
|
90
|
+
if (this.frozenPhysics) { this.frozenPhysics.dispose(); this.frozenPhysics = null; }
|
|
82
91
|
// Rapier objects live in wasm -- dropping the JS reference leaks them, so
|
|
83
92
|
// both the world and its event queue are freed explicitly. Runs on every
|
|
84
93
|
// scene load (the runtime resets registered systems) and on dispose.
|
|
@@ -95,6 +104,7 @@ export class Physics3DSystem {
|
|
|
95
104
|
// What a skipping pass wrote down goes with the world it was written for.
|
|
96
105
|
this.remembered = null;
|
|
97
106
|
this.rememberedIn = null;
|
|
107
|
+
if (this.stillKeeper) this.stillKeeper.interrupt();
|
|
98
108
|
// A force asked for and not yet used goes with it.
|
|
99
109
|
this.forces = null;
|
|
100
110
|
// A follow camera asked for before the load goes with the scene it was
|
|
@@ -107,6 +117,36 @@ export class Physics3DSystem {
|
|
|
107
117
|
// And a facing asked for under the key and not yet taken, whether or not
|
|
108
118
|
// the orbit input was ever made (only a keyed scene asks for one).
|
|
109
119
|
if (runtime?.faceRequest !== undefined) runtime.faceRequest = undefined;
|
|
120
|
+
// And the actor a keyed Player named for this frame's draw (engine3d/
|
|
121
|
+
// ownmodel.js): a load between its placement and the draw leaves the
|
|
122
|
+
// new scene's frame drawn whole. Only a keyed Player ever names one.
|
|
123
|
+
if (runtime?.orbitOwnModel !== undefined) runtime.orbitOwnModel = undefined;
|
|
124
|
+
// And the lens the orbit key put on the world camera (engine3d/
|
|
125
|
+
// orbitlens.js): given back here, at the start of the load, so the next
|
|
126
|
+
// scene's own code starts from the lens the camera had before the key
|
|
127
|
+
// and what it sets stands. A world that never played the key has none.
|
|
128
|
+
if (runtime?.three?.orbitLens) giveBackOrbitLens(runtime.three);
|
|
129
|
+
if (runtime?.three?.viewRange) giveBackViewRange(runtime.three);
|
|
130
|
+
// And the sky the scene being left had (engine3d/skylife.js): disposed
|
|
131
|
+
// here unless a frame of the world is being drawn, when that frame
|
|
132
|
+
// disposes it on its way out. A world that never played the key has
|
|
133
|
+
// none. Null is the only success sentinel; a falsy thrown value is still
|
|
134
|
+
// an error and stops the load after the record has been released.
|
|
135
|
+
if (runtime?.three?.sky) {
|
|
136
|
+
const failed = leaveSky(runtime.three, runtime.sky);
|
|
137
|
+
if (failed !== null) throw failed;
|
|
138
|
+
}
|
|
139
|
+
// And the materials the near shadows' far edge fades out on
|
|
140
|
+
// (engine3d/shadowfade.js): the world's variants of them are disposed.
|
|
141
|
+
// A world that never played both keys has none. Through the world's
|
|
142
|
+
// outside-call bracket (world3d.js), which every world that drew a fade
|
|
143
|
+
// made for its near shadows.
|
|
144
|
+
const world = runtime?.three;
|
|
145
|
+
if (world?.shadowFade) {
|
|
146
|
+
const call = world.nearShadowCall;
|
|
147
|
+
if (typeof call === 'function') call(() => dropShadowFade(world));
|
|
148
|
+
else dropShadowFade(world);
|
|
149
|
+
}
|
|
110
150
|
}
|
|
111
151
|
|
|
112
152
|
dispose(runtime) {
|
|
@@ -120,6 +160,44 @@ export class Physics3DSystem {
|
|
|
120
160
|
|
|
121
161
|
simulate(scene, dt) {
|
|
122
162
|
if (!rapierReady) return;
|
|
163
|
+
if (this.frozenPhysics && this.frozenPhysics.owner !== scene.frozenActors) {
|
|
164
|
+
this.frozenPhysics.dispose();
|
|
165
|
+
this.frozenPhysics = null;
|
|
166
|
+
}
|
|
167
|
+
if (scene.freezesStatics === true) {
|
|
168
|
+
this.ensureWorld(scene);
|
|
169
|
+
if (typeof this.world.forEachActiveRigidBody === 'function') {
|
|
170
|
+
this.remembered ??= new WeakMap();
|
|
171
|
+
this.rememberedIn = this.world;
|
|
172
|
+
if (this.forces && this.forcesAt !== scene.time) this.forces = null;
|
|
173
|
+
const frozen = this.frozenPhysics ??= new FrozenPhysics(this, scene);
|
|
174
|
+
frozen.simulate(dt);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
// Older/custom physics providers cannot enumerate awake bodies safely.
|
|
178
|
+
scene.releaseStill();
|
|
179
|
+
}
|
|
180
|
+
// A system that has held bodies still, or a scene that asks to
|
|
181
|
+
// (`"engine": { "staticActors": true }`): the same pass, whatever its
|
|
182
|
+
// kind, seen in and out by the system's keeper (`simulateKept`, below).
|
|
183
|
+
if (this.stillKeeper || scene.keepsStaticActors === true) {
|
|
184
|
+
this.simulateKept(scene, dt);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
// Every other pass is counted while it runs, and that is all: nothing in
|
|
188
|
+
// a system without a keeper reads the count. It is what tells a keeper
|
|
189
|
+
// made from inside this pass (a collision callback that updates a scene
|
|
190
|
+
// that asks) that a pass it never saw enter is running around it.
|
|
191
|
+
this.unkept = (this.unkept ?? 0) + 1;
|
|
192
|
+
try {
|
|
193
|
+
this.simulateAsEver(scene, dt);
|
|
194
|
+
} finally {
|
|
195
|
+
this.unkept -= 1;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// `simulate` as it always was.
|
|
200
|
+
simulateAsEver(scene, dt) {
|
|
123
201
|
this.ensureWorld(scene);
|
|
124
202
|
// A force is for the frame it was asked in: one left from a frame whose
|
|
125
203
|
// pass did not run, or asked after that frame's pass (from a collision
|
|
@@ -186,6 +264,7 @@ export class Physics3DSystem {
|
|
|
186
264
|
removeBody(actorId) {
|
|
187
265
|
const entry = this.bodies.get(actorId);
|
|
188
266
|
if (!entry) return;
|
|
267
|
+
this.frozenPhysics?.forgetBody(actorId);
|
|
189
268
|
if (entry.collider) this.byCollider.delete(entry.collider.handle);
|
|
190
269
|
this.world.removeRigidBody(entry.body);
|
|
191
270
|
this.bodies.delete(actorId);
|
|
@@ -257,7 +336,7 @@ export class Physics3DSystem {
|
|
|
257
336
|
// Snapshot dynamic bodies before each step so rendering can interpolate
|
|
258
337
|
// between the last two physics states -- without this, bodies advance
|
|
259
338
|
// only on step frames and stutter on displays faster than 60Hz.
|
|
260
|
-
for (const entry of this.bodies.values()) {
|
|
339
|
+
for (const entry of this.frozenPhysics ? this.frozenPhysics.stepEntries() : this.bodies.values()) {
|
|
261
340
|
if (entry.body.bodyType() !== RAPIER.RigidBodyType.Dynamic) continue;
|
|
262
341
|
const p = entry.body.translation();
|
|
263
342
|
const q = entry.body.rotation();
|
|
@@ -359,6 +438,160 @@ export class Physics3DSystem {
|
|
|
359
438
|
this.dispatchCallbacks(scene);
|
|
360
439
|
}
|
|
361
440
|
|
|
441
|
+
// `simulate` for a system with a keeper, or a scene that asks for one. The
|
|
442
|
+
// invariant is the world's (world3d.js `syncActorsKept`), about entry
|
|
443
|
+
// points and not kinds of pass:
|
|
444
|
+
//
|
|
445
|
+
// From the moment a physics system has a keeper, the keeper sees EVERY
|
|
446
|
+
// entry into and exit from `simulate`, of every kind (plain, skipping,
|
|
447
|
+
// settled, ordinary; any runtime). An adoption can be recorded only by a
|
|
448
|
+
// pass that was alone from its entry to its exit, and any pass of any
|
|
449
|
+
// kind that enters, or is running, drops it.
|
|
450
|
+
//
|
|
451
|
+
// `simulate` is the one function through which this system's bodies are
|
|
452
|
+
// made, removed, pushed, stepped and written back (`reconcileBodies`,
|
|
453
|
+
// `reconcileUnchanged`, `pushTransforms`, `pushUnchanged`, `step`,
|
|
454
|
+
// `writeBack`, `dispatchCallbacks` are reached only from it); `reset`, the
|
|
455
|
+
// other, reports to the keeper, and its world's adoption is not this
|
|
456
|
+
// world's. The `scene.physics3d` calls that move one body (`setVelocity`,
|
|
457
|
+
// `applyImpulse`, `addForce`) touch the actor they are handed.
|
|
458
|
+
// - A pass that holds nothing still (its scene did not ask) is counted in,
|
|
459
|
+
// drops whatever was adopted before it does anything, runs as it always
|
|
460
|
+
// did, and never adopts on its way out.
|
|
461
|
+
// - A pass of a scene that asks is `afterBehaviorsStill`.
|
|
462
|
+
// - A pass that entered BEFORE the system had a keeper was not seen
|
|
463
|
+
// entering: `this.unkept` counts those while they run, and while it is
|
|
464
|
+
// not zero no pass is settled and none adopts.
|
|
465
|
+
simulateKept(scene, dt) {
|
|
466
|
+
const keeper = (this.stillKeeper ??= scene.newStillKeeper());
|
|
467
|
+
if (scene.keepsStaticActors === true) {
|
|
468
|
+
this.ensureWorld(scene);
|
|
469
|
+
if (this.forces && this.forcesAt !== scene.time) this.forces = null;
|
|
470
|
+
if (!this.remembered || this.rememberedIn !== this.world) {
|
|
471
|
+
this.remembered = new WeakMap();
|
|
472
|
+
this.rememberedIn = this.world;
|
|
473
|
+
}
|
|
474
|
+
this.afterBehaviorsStill(scene, dt);
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
const pass = keeper.begin(-1);
|
|
478
|
+
try {
|
|
479
|
+
this.simulateAsEver(scene, dt);
|
|
480
|
+
} finally {
|
|
481
|
+
keeper.end(pass, false);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// `afterBehaviorsSkipping` for a scene that also set `"engine":
|
|
486
|
+
// { "staticActors": true }` (world3d.js has the rule; docs/engine-static-actors.md the terms).
|
|
487
|
+
// A pass is ordinary, every actor as above, unless this system has adopted
|
|
488
|
+
// the runtime's still set, in this same rapier world; then the still
|
|
489
|
+
// actors' bodies, which are fixed and where that pass put them, are left
|
|
490
|
+
// alone.
|
|
491
|
+
//
|
|
492
|
+
// The adoption is kept by the system's StillKeeper (physics-2d
|
|
493
|
+
// engine/stillClock.js has it and the rule it is) and nowhere else: it
|
|
494
|
+
// counts this entry before the pass does anything; it adopts only in the
|
|
495
|
+
// `finally` of a pass that ran the reconcile, the push, rapier's step, the
|
|
496
|
+
// write-back and the collision callbacks and returned, with nobody having
|
|
497
|
+
// entered, no pass the keeper never saw running (`this.unkept`), and the
|
|
498
|
+
// still set unmoved. Nothing is put back: a pass that was interrupted
|
|
499
|
+
// leaves no adoption. What this system adds to an adoption is the rapier
|
|
500
|
+
// world it was made in and how many still actors have a body. An actor is
|
|
501
|
+
// adopted only with a fixed body, so one whose body something made dynamic
|
|
502
|
+
// or kinematic is touched instead.
|
|
503
|
+
afterBehaviorsStill(scene, dt) {
|
|
504
|
+
const keeper = this.stillKeeper;
|
|
505
|
+
const set = scene.stillActors;
|
|
506
|
+
const pass = keeper.begin(scene.stillVersion);
|
|
507
|
+
if (pass.settled && !(set && keeper.adopted.world === this.world && !(this.unkept > 0))) keeper.demote(pass);
|
|
508
|
+
const bodies = pass.settled ? keeper.adopted.bodies : 0;
|
|
509
|
+
let completed = false;
|
|
510
|
+
try {
|
|
511
|
+
this.stillPass(scene, dt, pass.settled ? set : null, bodies);
|
|
512
|
+
completed = true;
|
|
513
|
+
} finally {
|
|
514
|
+
keeper.end(pass, completed && !(this.unkept > 0), scene.stillVersion, () => (set && set.size > 0 && scene.stillActors === set ? this.adoptStill(scene, set) : null));
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// The pass itself: every actor, or, when `still` is the set a pass before
|
|
519
|
+
// adopted, every actor but those.
|
|
520
|
+
stillPass(scene, dt, still, stillBodies) {
|
|
521
|
+
const all = scene.getActors();
|
|
522
|
+
let actors = all;
|
|
523
|
+
if (still) {
|
|
524
|
+
actors = all.filter((actor) => !still.has(actor));
|
|
525
|
+
this.reconcileLive(actors, still, scene, stillBodies);
|
|
526
|
+
if (scene.three?.auditStatic > 0) this.auditStill(scene, still);
|
|
527
|
+
} else {
|
|
528
|
+
this.reconcileUnchanged(all);
|
|
529
|
+
}
|
|
530
|
+
const dynamic = this.pushUnchanged(actors);
|
|
531
|
+
this.step(dt);
|
|
532
|
+
this.writeBack({ getActors: () => dynamic });
|
|
533
|
+
this.dispatchCallbacks(scene);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// `reconcileUnchanged` for the actors that are not still: a body with
|
|
537
|
+
// neither this pass's mark nor a still actor has lost its actor.
|
|
538
|
+
reconcileLive(actors, still, scene, stillBodies) {
|
|
539
|
+
this.pass = (this.pass ?? 0) + 1;
|
|
540
|
+
const pass = this.pass;
|
|
541
|
+
let marked = stillBodies;
|
|
542
|
+
for (const actor of actors) {
|
|
543
|
+
if (!actor.components.Transform) continue;
|
|
544
|
+
const entry = this.bodyFor(actor);
|
|
545
|
+
if (entry.pass === pass) continue;
|
|
546
|
+
entry.pass = pass;
|
|
547
|
+
marked += 1;
|
|
548
|
+
}
|
|
549
|
+
if (marked === this.bodies.size) return;
|
|
550
|
+
for (const [id, entry] of [...this.bodies]) {
|
|
551
|
+
if (entry.pass !== pass && !still.has(scene.getActor(id))) this.removeBody(id);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// On the way out of an ordinary pass that completed: the still actors'
|
|
556
|
+
// bodies are counted, and from the next pass on are left alone. Returns
|
|
557
|
+
// what to keep, or null when a still actor's body is not fixed (the actor
|
|
558
|
+
// is touched; the pass after that adopts the rest).
|
|
559
|
+
adoptStill(scene, set) {
|
|
560
|
+
if (!this.world) return null;
|
|
561
|
+
let bodies = 0;
|
|
562
|
+
const moved = [];
|
|
563
|
+
for (const actor of set) {
|
|
564
|
+
const entry = actor.components.Transform ? this.bodies.get(actor.id) : null;
|
|
565
|
+
if (!entry) continue;
|
|
566
|
+
if (entry.body.bodyType() === RAPIER.RigidBodyType.Fixed) bodies += 1;
|
|
567
|
+
else moved.push(actor);
|
|
568
|
+
}
|
|
569
|
+
if (moved.length > 0) {
|
|
570
|
+
for (const actor of moved) scene.touch(actor);
|
|
571
|
+
return null;
|
|
572
|
+
}
|
|
573
|
+
return { world: this.world, bodies };
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// `world.auditStatic` (QA only; world3d.js): every still actor's body
|
|
577
|
+
// against what an ordinary pass would have found.
|
|
578
|
+
auditStill(scene, set) {
|
|
579
|
+
for (const actor of [...set]) {
|
|
580
|
+
const entry = this.bodies.get(actor.id);
|
|
581
|
+
const t = actor.components.Transform;
|
|
582
|
+
const made = entry && this.remembered.get(entry);
|
|
583
|
+
let what = null;
|
|
584
|
+
if (!t || !entry || !made) what = t || entry ? 'its Transform or its body (gone)' : null;
|
|
585
|
+
else if (!madeTheSame(made.madeFrom, actor)) what = 'a component its body is made from';
|
|
586
|
+
else if (entry.body.bodyType() !== RAPIER.RigidBodyType.Fixed) what = "its body's type";
|
|
587
|
+
else if (!alreadyPushed(entry, made, t)) what = 'its Transform (where its body is)';
|
|
588
|
+
if (!what) continue;
|
|
589
|
+
// Touched first: the note warns on the console, which is not the engine's.
|
|
590
|
+
scene.touch(actor);
|
|
591
|
+
noteChangedStill(scene.three, actor.id, what);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
362
595
|
reconcileUnchanged(actors) {
|
|
363
596
|
// Each body whose actor is still here is marked with this pass's count; a
|
|
364
597
|
// body without the mark afterwards has lost its actor.
|
|
@@ -426,10 +659,13 @@ export class Physics3DSystem {
|
|
|
426
659
|
}
|
|
427
660
|
|
|
428
661
|
function emitPair(scene, aId, bId, method) {
|
|
662
|
+
prepareModelConsumers(scene.three, scene, aId);
|
|
429
663
|
const a = scene.getActor(aId);
|
|
430
664
|
const b = scene.getActor(bId);
|
|
431
665
|
if (!a || !b) return;
|
|
432
666
|
scene.forEachBehavior(a, (instance) => instance[method]?.(a, scene, b));
|
|
667
|
+
// The first actor's callback may add a consumer to the second actor.
|
|
668
|
+
prepareModelConsumers(scene.three, scene, bId);
|
|
433
669
|
scene.forEachBehavior(b, (instance) => instance[method]?.(b, scene, a));
|
|
434
670
|
}
|
|
435
671
|
|
|
@@ -562,14 +798,32 @@ function makeApi(system, runtime) {
|
|
|
562
798
|
return {
|
|
563
799
|
ready: () => rapierReady && Boolean(system.world),
|
|
564
800
|
debugRender: () => (system.world ? system.world.debugRender() : null),
|
|
565
|
-
bodyOf
|
|
801
|
+
bodyOf: (actor) => {
|
|
802
|
+
// A raw Rapier handle allows writes outside our component/API hooks.
|
|
803
|
+
// Keep that body in the checked pass from now on.
|
|
804
|
+
if (runtime.freezesStatics) {
|
|
805
|
+
runtime.frozenActors.release(runtime.getActor(idOf(actor)));
|
|
806
|
+
system.frozenPhysics?.exposed.add(idOf(actor));
|
|
807
|
+
runtime.touch(actor);
|
|
808
|
+
}
|
|
809
|
+
return bodyOf(actor);
|
|
810
|
+
},
|
|
566
811
|
mass: (actor) => bodyOf(actor)?.mass() ?? 0,
|
|
567
812
|
getVelocity: (actor) => {
|
|
568
813
|
const v = bodyOf(actor)?.linvel();
|
|
569
814
|
return v ? { x: v.x, y: v.y, z: v.z } : { x: 0, y: 0, z: 0 };
|
|
570
815
|
},
|
|
571
|
-
|
|
572
|
-
|
|
816
|
+
// Each of these that moves a body says so first (`touch`: a scene that
|
|
817
|
+
// set `"engine": { "staticActors": true }` holds some actors still). An
|
|
818
|
+
// actor that is not still, or a scene without the key, is not affected.
|
|
819
|
+
setVelocity: (actor, v) => {
|
|
820
|
+
runtime.touch?.(actor);
|
|
821
|
+
return bodyOf(actor)?.setLinvel(v, true);
|
|
822
|
+
},
|
|
823
|
+
applyImpulse: (actor, v) => {
|
|
824
|
+
runtime.touch?.(actor);
|
|
825
|
+
return bodyOf(actor)?.applyImpulse(v, true);
|
|
826
|
+
},
|
|
573
827
|
// A force on the actor's body through the fixed steps of this frame's
|
|
574
828
|
// physics pass and no longer, asked from a behavior's `update`: it acts
|
|
575
829
|
// once per step, as gravity does, where an impulse acts once per frame.
|
|
@@ -580,6 +834,7 @@ function makeApi(system, runtime) {
|
|
|
580
834
|
const id = idOf(actor);
|
|
581
835
|
const body = system.world && system.bodies.get(id)?.body;
|
|
582
836
|
if (!body) return;
|
|
837
|
+
runtime.touch?.(actor);
|
|
583
838
|
if (system.forces && system.forcesAt !== runtime.time) system.forces = null;
|
|
584
839
|
system.forcesAt = runtime.time;
|
|
585
840
|
const forces = (system.forces ??= new Map());
|
|
@@ -619,5 +874,160 @@ function makeApi(system, runtime) {
|
|
|
619
874
|
const hit = system.world?.castRay(new RAPIER.Ray(origin, dir), maxToi, true, fixedSolids());
|
|
620
875
|
return hit ? { distance: hit.timeOfImpact, actorId: system.byCollider.get(hit.collider.handle) ?? null } : null;
|
|
621
876
|
},
|
|
877
|
+
// The orbit camera's lens (behaviors/Player.jsx, under the orbit key
|
|
878
|
+
// only; nothing else calls these three), against what `castRayFixed`
|
|
879
|
+
// meets. `castRayFixedNormal`: what `castRayFixed` finds, with the unit
|
|
880
|
+
// `normal` of the surface there, facing the ray's origin.
|
|
881
|
+
castRayFixedNormal: (origin, dir, maxToi) => {
|
|
882
|
+
const met = system.world?.castRayAndGetNormal(new RAPIER.Ray(origin, dir), maxToi, true, fixedSolids());
|
|
883
|
+
if (!met) return null;
|
|
884
|
+
const n = met.normal;
|
|
885
|
+
return { distance: met.timeOfImpact, actorId: system.byCollider.get(met.collider.handle) ?? null, normal: { x: n.x, y: n.y, z: n.z } };
|
|
886
|
+
},
|
|
887
|
+
// `castBallFixed`: a ball of `radius` swept from `origin` along the unit
|
|
888
|
+
// `dir`, no farther than `maxToi`; the first fixed solid it touches, as
|
|
889
|
+
// `{ distance, actorId, normal }` (how far the ball's middle got, and the
|
|
890
|
+
// surface's unit normal there, facing the ball), or null. A ball that
|
|
891
|
+
// starts touching something is not answered reliably by rapier, so the
|
|
892
|
+
// caller starts it clear (`nearFixed`). Nor is the sweep itself: where
|
|
893
|
+
// rapier stops the ball is off by an amount that changes from one place
|
|
894
|
+
// to the next (short by centimetres against the ground or tens of
|
|
895
|
+
// centimetres along a wall met at a grazing angle, past the surface by up
|
|
896
|
+
// to 2 cm when the ball starts within a few centimetres of one), in a
|
|
897
|
+
// corner it can name the second solid the ball meets instead of the
|
|
898
|
+
// first, and now and then it misses a solid outright (review 8: a box
|
|
899
|
+
// the ball passes through, at one radius and not at a millimetre more).
|
|
900
|
+
// So rapier's answer is only where to look:
|
|
901
|
+
// - the ball is put where it touches the plane that touches the solid
|
|
902
|
+
// where it was met (exact on a face; on an edge or a corner of a
|
|
903
|
+
// convex solid the solid is all behind that plane: `touchingAt`), or
|
|
904
|
+
// at `maxToi` when rapier met nothing;
|
|
905
|
+
// - a ray along the line, that far, keeps the line of sight: a solid it
|
|
906
|
+
// meets nearer brings the ball in to it;
|
|
907
|
+
// - the place is checked with an overlap query, the ball BALL_TOLERANCE
|
|
908
|
+
// smaller. Another solid in the way there is swept against alone and
|
|
909
|
+
// the ball put where it touches that one, BALL_RECHECKS times at most;
|
|
910
|
+
// - a place still not clear (rapier missed that solid again) is found by
|
|
911
|
+
// halving between the start (clear) and it with overlap queries, to
|
|
912
|
+
// BALL_BISECT or BALL_HALVINGS halvings.
|
|
913
|
+
// Queries: three as a rule (the sweep, the ray, one overlap); at most
|
|
914
|
+
// 3 + 2 * BALL_RECHECKS + BALL_HALVINGS, 25.
|
|
915
|
+
castBallFixed: (origin, dir, maxToi, radius) => {
|
|
916
|
+
if (!system.world || !(radius > 0)) return null;
|
|
917
|
+
const swept = sweepBall(system.world, origin, dir, maxToi, radius);
|
|
918
|
+
if (!swept.met) return null;
|
|
919
|
+
const n = swept.normal;
|
|
920
|
+
return { distance: swept.distance, actorId: system.byCollider.get(swept.met.handle) ?? null, normal: { x: n.x, y: n.y, z: n.z } };
|
|
921
|
+
},
|
|
922
|
+
// `nearFixed`: every fixed solid within `within` of `point`, each as
|
|
923
|
+
// `{ distance, inside, normal, point, actorId }`: its nearest point to
|
|
924
|
+
// `point` and the unit normal from there to `point` (a plane that
|
|
925
|
+
// touches the solid there and, for a convex solid, has all of it
|
|
926
|
+
// behind); `inside` (and no normal) for a point inside one. An empty
|
|
927
|
+
// list when there is none that near.
|
|
928
|
+
nearFixed: (point, within) => {
|
|
929
|
+
const found = [];
|
|
930
|
+
if (!system.world || !(within > 0)) return found;
|
|
931
|
+
system.world.intersectionsWithShape(point, UNTURNED, new RAPIER.Ball(within), (collider) => {
|
|
932
|
+
const near = collider.projectPoint(point, false);
|
|
933
|
+
if (!near) return true;
|
|
934
|
+
const actorId = system.byCollider.get(collider.handle) ?? null;
|
|
935
|
+
const at = { x: near.point.x, y: near.point.y, z: near.point.z };
|
|
936
|
+
const distance = Math.hypot(point.x - at.x, point.y - at.y, point.z - at.z);
|
|
937
|
+
const normal = near.isInside || !(distance > 0) ? null : { x: (point.x - at.x) / distance, y: (point.y - at.y) / distance, z: (point.z - at.z) / distance };
|
|
938
|
+
found.push({ distance: near.isInside ? 0 : distance, inside: near.isInside, normal, point: at, actorId });
|
|
939
|
+
return true;
|
|
940
|
+
}, fixedSolids());
|
|
941
|
+
return found;
|
|
942
|
+
},
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
// No rotation, for the ball `castBallFixed` sweeps; how much smaller the
|
|
947
|
+
// ball is when it checks the place it was put; and how many solids found in
|
|
948
|
+
// the way there it sweeps against alone.
|
|
949
|
+
const UNTURNED = { x: 0, y: 0, z: 0, w: 1 };
|
|
950
|
+
const BALL_TOLERANCE = 5e-5;
|
|
951
|
+
const BALL_RECHECKS = 3;
|
|
952
|
+
// How finely `castBallFixed` halves toward a clear place when rapier missed
|
|
953
|
+
// a solid: to a millimetre, in at most 16 halvings (37.4 m, the farthest
|
|
954
|
+
// the orbit camera goes, is under 2^16 mm).
|
|
955
|
+
const BALL_BISECT = 0.001;
|
|
956
|
+
const BALL_HALVINGS = 16;
|
|
957
|
+
|
|
958
|
+
// `castBallFixed`'s sweep, in `world`: `{ met, normal, distance }`, the
|
|
959
|
+
// solid met (null for none) and its normal there, and how far the ball got.
|
|
960
|
+
function sweepBall(world, origin, dir, maxToi, radius) {
|
|
961
|
+
const ball = new RAPIER.Ball(radius);
|
|
962
|
+
const inner = new RAPIER.Ball(Math.max(radius - BALL_TOLERANCE, radius / 2));
|
|
963
|
+
const at = (t) => ({ x: origin.x + dir.x * t, y: origin.y + dir.y * t, z: origin.z + dir.z * t });
|
|
964
|
+
const inTheWayAt = (t) => world.intersectionWithShape(at(t), UNTURNED, inner, fixedSolids());
|
|
965
|
+
const sweepAgainst = (only) => world.castShape(origin, UNTURNED, dir, ball, 0, maxToi, true, fixedSolids(), undefined, undefined, undefined, only);
|
|
966
|
+
const swept = { met: null, normal: null, distance: maxToi };
|
|
967
|
+
const take = (hit) => {
|
|
968
|
+
swept.met = hit.collider;
|
|
969
|
+
swept.normal = hit.normal1;
|
|
970
|
+
swept.distance = touchingAt(hit, origin, dir, radius, maxToi);
|
|
622
971
|
};
|
|
972
|
+
const first = sweepAgainst(undefined);
|
|
973
|
+
if (first) take(first);
|
|
974
|
+
// The line of sight: a solid across the line nearer than that.
|
|
975
|
+
const line = world.castRay(new RAPIER.Ray(origin, dir), swept.distance, true, fixedSolids());
|
|
976
|
+
if (line) Object.assign(swept, { met: line.collider, normal: null, distance: line.timeOfImpact });
|
|
977
|
+
for (let i = 0; ; i += 1) {
|
|
978
|
+
const inTheWay = inTheWayAt(swept.distance);
|
|
979
|
+
// Clear, or touching only the solid it was put against (the plane's own
|
|
980
|
+
// small error there).
|
|
981
|
+
if (!inTheWay || (swept.normal && inTheWay.handle === swept.met.handle)) break;
|
|
982
|
+
const alone = i < BALL_RECHECKS ? sweepAgainst((c) => c.handle === inTheWay.handle) : null;
|
|
983
|
+
if (alone && touchingAt(alone, origin, dir, radius, maxToi) < swept.distance) {
|
|
984
|
+
take(alone);
|
|
985
|
+
continue;
|
|
986
|
+
}
|
|
987
|
+
// Missed again: the farthest clear place short of this one.
|
|
988
|
+
Object.assign(swept, { met: inTheWay, normal: null, distance: clearShortOf(inTheWayAt, swept.distance) });
|
|
989
|
+
break;
|
|
990
|
+
}
|
|
991
|
+
if (swept.met && !swept.normal) swept.normal = normalFrom(swept.met, at(swept.distance), dir);
|
|
992
|
+
return swept;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
// The farthest place short of `blocked` (a distance along the sweep whose
|
|
996
|
+
// ball is in the way) that `inTheWayAt` finds clear, halving between the
|
|
997
|
+
// start (clear) and it: to BALL_BISECT, BALL_HALVINGS halvings at most.
|
|
998
|
+
function clearShortOf(inTheWayAt, blocked) {
|
|
999
|
+
let clear = 0;
|
|
1000
|
+
let far = blocked;
|
|
1001
|
+
for (let k = 0; k < BALL_HALVINGS && far - clear > BALL_BISECT; k += 1) {
|
|
1002
|
+
const half = (clear + far) / 2;
|
|
1003
|
+
if (inTheWayAt(half)) far = half;
|
|
1004
|
+
else clear = half;
|
|
1005
|
+
}
|
|
1006
|
+
return clear;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
// The unit normal of `collider`'s surface nearest `point`, facing the
|
|
1010
|
+
// point; against the sweep when the point is on it.
|
|
1011
|
+
function normalFrom(collider, point, dir) {
|
|
1012
|
+
const near = collider.projectPoint(point, false);
|
|
1013
|
+
if (!near) return { x: -dir.x, y: -dir.y, z: -dir.z };
|
|
1014
|
+
const dx = point.x - near.point.x;
|
|
1015
|
+
const dy = point.y - near.point.y;
|
|
1016
|
+
const dz = point.z - near.point.z;
|
|
1017
|
+
const length = Math.hypot(dx, dy, dz);
|
|
1018
|
+
return length > 0 ? { x: dx / length, y: dy / length, z: dz / length } : { x: -dir.x, y: -dir.y, z: -dir.z };
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
// How far along `dir` from `origin` a ball of `radius` touches the plane
|
|
1022
|
+
// that touches the solid where rapier's sweep `met` it (its witness point
|
|
1023
|
+
// and normal), no farther than `maxToi`; rapier's own answer when the ball
|
|
1024
|
+
// does not move toward that plane.
|
|
1025
|
+
function touchingAt(met, origin, dir, radius, maxToi) {
|
|
1026
|
+
const n = met.normal1;
|
|
1027
|
+
const at = met.witness1;
|
|
1028
|
+
const toi = met.time_of_impact;
|
|
1029
|
+
const closing = -(n.x * dir.x + n.y * dir.y + n.z * dir.z);
|
|
1030
|
+
if (!(closing > 1e-9)) return toi;
|
|
1031
|
+
const off = n.x * (origin.x + dir.x * toi - at.x) + n.y * (origin.y + dir.y * toi - at.y) + n.z * (origin.z + dir.z * toi - at.z);
|
|
1032
|
+
return Math.min(Math.max(0, toi + (off - radius) / closing), maxToi);
|
|
623
1033
|
}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
"imports": {
|
|
4
4
|
"castle.base": {
|
|
5
5
|
"deckId": "yRcmH4_aYllE",
|
|
6
|
-
"version": "2026-10-
|
|
6
|
+
"version": "2026-10-18T06:37:02.597Z"
|
|
7
7
|
}
|
|
8
8
|
},
|
|
9
9
|
"autoUpdateWhenImported": true,
|
|
10
10
|
"deckId": "xFVr-afOLuUQ",
|
|
11
11
|
"cardId": "w6G45sy3_P_m",
|
|
12
|
-
"publishedVersion": "2026-10-
|
|
12
|
+
"publishedVersion": "2026-10-18T06:38:41.691Z"
|
|
13
13
|
}
|
|
@@ -50,6 +50,10 @@ function makeNet(connection) {
|
|
|
50
50
|
// frames do: a hidden tab stops `requestAnimationFrame`, so a reply left in the
|
|
51
51
|
// queue would wait until the tab is shown again.
|
|
52
52
|
//
|
|
53
|
+
// `unpack(data)` optionally expands a transport frame into ordered packets;
|
|
54
|
+
// every packet shares that frame's arrival clock. Without it, one frame is
|
|
55
|
+
// one packet, including message kinds only a higher-level kit understands.
|
|
56
|
+
//
|
|
53
57
|
// `onConnected()` runs on each later transition back to connected: a
|
|
54
58
|
// reconnect, which can land on a replaced server process that has to be told
|
|
55
59
|
// again whatever the first connection told it.
|
|
@@ -58,21 +62,29 @@ export async function connectSession({
|
|
|
58
62
|
onLog = () => {},
|
|
59
63
|
onArrival = () => false,
|
|
60
64
|
onConnected = () => {},
|
|
65
|
+
unpack,
|
|
66
|
+
// The caller may abandon a pending attempt before its acquisition resolves.
|
|
67
|
+
// An obsolete destination must not start a fallback that cancels a newer join.
|
|
68
|
+
isCurrent = () => true,
|
|
61
69
|
} = {}) {
|
|
62
|
-
const { connection, world } = await joinTarget(join, onLog);
|
|
70
|
+
const { connection, world } = await joinTarget(join, onLog, isCurrent);
|
|
63
71
|
const net = makeNet(connection);
|
|
72
|
+
const decode = unpack ?? ((data) => [data]);
|
|
64
73
|
|
|
65
74
|
// Messages are queued with this page's clock at arrival. The client system
|
|
66
75
|
// drains the queue on its own frame and pairs `localMs` with the message's `t`
|
|
67
76
|
// in `clock.js`.
|
|
68
|
-
connection.onMessage((
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
connection.onMessage((frame) => {
|
|
78
|
+
const localMs = performance.now();
|
|
79
|
+
for (const data of decode(frame)) {
|
|
80
|
+
if (data?.k === Messages.UNLOADED) {
|
|
81
|
+
showLoadFailed();
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const msg = { ...data, localMs };
|
|
85
|
+
if (!onArrival(msg)) {
|
|
86
|
+
net.inbox.push(msg);
|
|
87
|
+
}
|
|
76
88
|
}
|
|
77
89
|
});
|
|
78
90
|
connection.onRoster(({ players, you }) => {
|
|
@@ -102,6 +114,7 @@ export async function connectSession({
|
|
|
102
114
|
}
|
|
103
115
|
});
|
|
104
116
|
return {
|
|
117
|
+
...(unpack ? { unpacks: true } : {}),
|
|
105
118
|
// The player id this connection was assigned.
|
|
106
119
|
selfId: () => connection.playerId,
|
|
107
120
|
|
|
@@ -165,6 +178,13 @@ export async function connectSession({
|
|
|
165
178
|
you: net.you?.username ?? net.roster.get(connection.playerId) ?? '',
|
|
166
179
|
}),
|
|
167
180
|
|
|
181
|
+
// Optional host identity follows each hello and disappears while offline.
|
|
182
|
+
get serverBuild() {
|
|
183
|
+
const bundleId = connection.serverBundleId ?? null;
|
|
184
|
+
const bundleSha256 = connection.serverBundleSha256 ?? null;
|
|
185
|
+
return bundleId || bundleSha256 ? { sessionId: connection.sessionId, bundleId, bundleSha256 } : null;
|
|
186
|
+
},
|
|
187
|
+
|
|
168
188
|
// The shared-character calls (`requestCharacterTurn`,
|
|
169
189
|
// `getCharacterTurnStatus`, `readCharacters`) of a destination world, or
|
|
170
190
|
// of a session whose host said it brokers shared characters into it (a hub
|
|
@@ -187,7 +207,7 @@ export function charactersOf(connection, world) {
|
|
|
187
207
|
return world || connection?.sharedCharacters === true ? connection : null;
|
|
188
208
|
}
|
|
189
209
|
|
|
190
|
-
async function joinTarget(join, onLog) {
|
|
210
|
+
async function joinTarget(join, onLog, isCurrent) {
|
|
191
211
|
if (!join?.destination) {
|
|
192
212
|
return { connection: await Multiplayer.join(join), world: false };
|
|
193
213
|
}
|
|
@@ -201,6 +221,9 @@ async function joinTarget(join, onLog) {
|
|
|
201
221
|
if (result?.status === 'joined') {
|
|
202
222
|
return { connection: result.connection, world: true };
|
|
203
223
|
}
|
|
224
|
+
if (!isCurrent()) {
|
|
225
|
+
throw Object.assign(new Error('Join attempt was cancelled.'), { code: 'CANCELLED' });
|
|
226
|
+
}
|
|
204
227
|
if (result) {
|
|
205
228
|
onLog(`destination ${routeId} is ${result.status}; joining the fallback session`);
|
|
206
229
|
}
|
|
@@ -18,6 +18,8 @@ const modules = {
|
|
|
18
18
|
// The 2D and 3D multiplayer systems import this value and call the hooks at the
|
|
19
19
|
// stages listed below.
|
|
20
20
|
//
|
|
21
|
+
// unpack(data) optional transport decoder, returning ordered
|
|
22
|
+
// packets before state/arrival dispatch
|
|
21
23
|
// arrive(msg, system) a message that is neither STATE nor WORLD,
|
|
22
24
|
// the moment it arrives, with or without
|
|
23
25
|
// frames. Returning true handles it there, and
|