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
|
@@ -8,7 +8,14 @@
|
|
|
8
8
|
export function firstJoinFor(castleJson, multiplayer) {
|
|
9
9
|
const npcs = castleJson?.hub?.npcs;
|
|
10
10
|
if (typeof npcs?.route !== 'string' || multiplayer?.placeCharacters === true) {
|
|
11
|
-
return undefined;
|
|
11
|
+
return pongJoin(undefined, castleJson?.hub?.pongTimeoutMs);
|
|
12
12
|
}
|
|
13
|
-
return { destination: { routeId: npcs.route, slot: typeof npcs.slot === 'string' ? npcs.slot : 'main' }, fallback: { mode: 'public' } };
|
|
13
|
+
return pongJoin({ destination: { routeId: npcs.route, slot: typeof npcs.slot === 'string' ? npcs.slot : 'main' }, fallback: { mode: 'public' } }, castleJson?.hub?.pongTimeoutMs);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Client-only transport policy; absent/zero returns the exact original join.
|
|
17
|
+
export function pongJoin(join, ms) {
|
|
18
|
+
if (!Number.isInteger(ms) || ms <= 0 || ms > 2_147_483_647) { return join; }
|
|
19
|
+
if (join?.destination) { return { ...join, fallback: pongJoin(join.fallback, ms) }; }
|
|
20
|
+
return { ...(join ?? { mode: 'public' }), pongTimeoutMs: ms };
|
|
14
21
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Snapshot configuration belongs to a transport, never the page's root deck.
|
|
2
|
+
// Allocate nothing until an opted-in server snapshot arrives.
|
|
3
|
+
let sessions;
|
|
4
|
+
export function setFpsTelemetry(net, config) {
|
|
5
|
+
if (!net) {return;}
|
|
6
|
+
if (config) {
|
|
7
|
+
sessions ??= new WeakMap();
|
|
8
|
+
sessions.set(net, config);
|
|
9
|
+
} else {sessions?.delete(net);}
|
|
10
|
+
}
|
|
11
|
+
export function fpsTelemetryFor(net) {return net ? sessions?.get(net) : undefined;}
|
|
12
|
+
|
|
13
|
+
// Bounded one-second foreground samples; delivery is best effort.
|
|
14
|
+
export function makeFpsTelemetry({ send, document: doc = globalThis.document, target = globalThis }) {
|
|
15
|
+
let last = null, frames = 0, elapsed = 0, samples = [], context = null;
|
|
16
|
+
const flush = (final = false) => {
|
|
17
|
+
if (!samples.length || !context) {return;}
|
|
18
|
+
const sorted = [...samples].sort((a, b) => a - b);
|
|
19
|
+
const quantile = (q) => Math.min(4095, Math.max(0, Math.round(sorted[Math.max(0, Math.ceil(q * sorted.length) - 1)] * 10)));
|
|
20
|
+
const message = { k: 'hub-fps', median: quantile(0.5), p10: quantile(0.1), ...context, final };
|
|
21
|
+
samples = []; elapsed = 0;
|
|
22
|
+
try { send(message); } catch { /* Never interrupt a departure. */ }
|
|
23
|
+
};
|
|
24
|
+
const hide = () => { if (doc?.hidden) {last = null; frames = 0;} };
|
|
25
|
+
const pause = () => { last = null; frames = 0; elapsed = 0; samples = []; context = null; };
|
|
26
|
+
const leave = () => { flush(true); pause(); };
|
|
27
|
+
doc?.addEventListener?.('visibilitychange', hide);
|
|
28
|
+
target.addEventListener?.('pagehide', leave);
|
|
29
|
+
return {
|
|
30
|
+
leave,
|
|
31
|
+
pause,
|
|
32
|
+
frame(now, next) {
|
|
33
|
+
if (doc?.hidden) {last = null; frames = 0; return;}
|
|
34
|
+
if (context && context.scene !== next.scene) {flush(true); last = null; frames = 0;}
|
|
35
|
+
context = next;
|
|
36
|
+
if (last === null) {last = now; return;}
|
|
37
|
+
frames += 1;
|
|
38
|
+
if (now - last < 1000) {return;}
|
|
39
|
+
elapsed += now - last;
|
|
40
|
+
samples.push(frames * 1000 / (now - last));
|
|
41
|
+
last = now; frames = 0;
|
|
42
|
+
if (samples.length >= 60 || elapsed >= 60000) {flush();}
|
|
43
|
+
},
|
|
44
|
+
dispose() {
|
|
45
|
+
flush(true);
|
|
46
|
+
doc?.removeEventListener?.('visibilitychange', hide);
|
|
47
|
+
target.removeEventListener?.('pagehide', leave);
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Expand before WORLD/STATE dispatch and arrival hooks. Every packet in a
|
|
2
|
+
// transport frame shares its arrival time and retains its original order.
|
|
3
|
+
export function unpackFrame(data) {
|
|
4
|
+
return data?.k === 'hub-frame' && Array.isArray(data.packets) ? data.packets : [data];
|
|
5
|
+
}
|
|
@@ -18,8 +18,14 @@
|
|
|
18
18
|
// A place may keep an object for one player (v1.27, `hub.keepFor`): it is
|
|
19
19
|
// never offered to anyone else, so the nearest object a player may take is
|
|
20
20
|
// the one offered. Where nothing is kept the offer is exactly what it was.
|
|
21
|
+
//
|
|
22
|
+
// Under the engine's orbit camera key (a scene whose `engine.camera` is
|
|
23
|
+
// `{ "follow": "rigid", "control": "orbit" }`, `scene.cameraControl ===
|
|
24
|
+
// 'orbit'`) the camera and the character turn apart, so a throw goes where
|
|
25
|
+
// the camera looks rather than where the character happens to face: see
|
|
26
|
+
// `aimThrow`. Without the key every throw runs the code it always did.
|
|
21
27
|
|
|
22
|
-
import { hub } from './state.js';
|
|
28
|
+
import { deck, hub } from './state.js';
|
|
23
29
|
|
|
24
30
|
const DEG = Math.PI / 180;
|
|
25
31
|
// An object is offered when its near side is this close to the player
|
|
@@ -78,6 +84,35 @@ export const PRESS_WAIT_MS = 500;
|
|
|
78
84
|
// v1.25 `grab.keepHeld`: how often the server is told a hold goes on (its
|
|
79
85
|
// pin on the held object lasts 2.5 s past the last word).
|
|
80
86
|
export const KEEP_TELL_MS = 1000;
|
|
87
|
+
// Under the orbit camera key: a throw waits for the character to face the
|
|
88
|
+
// camera's way and for a movement report saying so to have gone out, at most
|
|
89
|
+
// AIM_WAIT_MS; and for the held object to swing round to the hold point along
|
|
90
|
+
// the throw, which takes no time at all when the camera already looks the way
|
|
91
|
+
// the character faces, and otherwise as long as the server takes to hear the
|
|
92
|
+
// swing (AIM_SLACK_M, below). Nothing waits past AIM_GIVE_UP_MS: a throw is
|
|
93
|
+
// never lost. The server judges a throw from the pose it last heard.
|
|
94
|
+
export const AIM_WAIT_MS = 150;
|
|
95
|
+
export const AIM_GIVE_UP_MS = 2000;
|
|
96
|
+
// How far (metres, in a straight line) the swing may put the held object
|
|
97
|
+
// from anywhere the server's body for it may be. multiplayer-3d checks each
|
|
98
|
+
// owned-object report against where its kinematic body is when the report
|
|
99
|
+
// arrives: no farther than MAX_OBJECT_SPEED (40 m/s) times the server time
|
|
100
|
+
// since the last report, plus MOVE_SLACK (0.6 m); a report past that takes
|
|
101
|
+
// the object away and ends the hold. Reports bunched by the network between
|
|
102
|
+
// two physics steps get no time at all, only the 0.6 m, and the body moves
|
|
103
|
+
// only at a step, to the newest report applied before it. So the swing never
|
|
104
|
+
// counts on time, and puts the object within this of every position this
|
|
105
|
+
// client has reported since the one the body is sure to have reached (see
|
|
106
|
+
// `reach`): wherever among them the body is, the next report is inside the
|
|
107
|
+
// bound. The report carries exactly where the swing put the object (the
|
|
108
|
+
// client's physics runs before this system, the report after it); the rest
|
|
109
|
+
// of the 0.6 m is margin.
|
|
110
|
+
export const AIM_SLACK_M = 0.5;
|
|
111
|
+
// How near the character's facing must be to the throw's to count as facing
|
|
112
|
+
// it (radians). The Player takes a facing request exactly, so standing still
|
|
113
|
+
// it is met the frame after the request; walking, the Player eases the
|
|
114
|
+
// facing toward the walk at once and the wait runs out instead.
|
|
115
|
+
const AIM_FACE_RAD = 1 * DEG;
|
|
81
116
|
// Where the walk preset's capsule stands (physics-3d `Player`): its radius and
|
|
82
117
|
// height, and how far it hovers.
|
|
83
118
|
const PLAYER = { radius: 0.35, height: 1.4, hover: 0.15 };
|
|
@@ -101,7 +136,7 @@ export function makeGrab(chrome) {
|
|
|
101
136
|
// E or F on a keyboard. Typing in the talk panel never reaches here (its
|
|
102
137
|
// input stops its keys), nor does any other text field.
|
|
103
138
|
const onKey = (event) => {
|
|
104
|
-
if (event.repeat || (event.code !== 'KeyE' && event.code !== 'KeyF')) {
|
|
139
|
+
if (deck.act === true || event.repeat || (event.code !== 'KeyE' && event.code !== 'KeyF')) {
|
|
105
140
|
return;
|
|
106
141
|
}
|
|
107
142
|
const target = event.target;
|
|
@@ -116,13 +151,29 @@ export function makeGrab(chrome) {
|
|
|
116
151
|
};
|
|
117
152
|
globalThis.addEventListener?.('keydown', onKey);
|
|
118
153
|
return {
|
|
119
|
-
frame: (scene, mp, local, idle) => frame(t, scene, mp, local, idle),
|
|
154
|
+
frame: (scene, mp, local, idle, pauseCarry = false) => frame(t, scene, mp, local, idle, pauseCarry),
|
|
120
155
|
holding: () => t.held?.id ?? null,
|
|
156
|
+
perform(id, scene, mp, local, op, onThrow) {
|
|
157
|
+
const body = scene.physics3d?.bodyOf(id), actor = scene.getActor(id);
|
|
158
|
+
if (!body || !actor || !mp.own?.mine?.has(id)) {return false;}
|
|
159
|
+
const config = hub.place?.grab;
|
|
160
|
+
if (op === 'throw' && t.held?.id === id) {
|
|
161
|
+
if (t.held.aim) {return false;}
|
|
162
|
+
t.held.actThrow = onThrow;
|
|
163
|
+
if (scene.cameraControl === 'orbit') {aimThrow(t, scene, mp, body, local, config, 0, performance.now());}
|
|
164
|
+
else {throwHeld(t, scene, body, local, config, { send() {} }, performance.now());}
|
|
165
|
+
} else if (op === 'grab' && !t.held) {
|
|
166
|
+
const at = body.translation(), size = sizeOf(actor.components.Shape);
|
|
167
|
+
t.held = { id, ...size, at: { ...at } };
|
|
168
|
+
carry(t, scene, body, local, config, 0);
|
|
169
|
+
}
|
|
170
|
+
return true;
|
|
171
|
+
},
|
|
121
172
|
dispose: () => globalThis.removeEventListener?.('keydown', onKey),
|
|
122
173
|
};
|
|
123
174
|
}
|
|
124
175
|
|
|
125
|
-
function frame(t, scene, mp, local, idle) {
|
|
176
|
+
function frame(t, scene, mp, local, idle, pauseCarry) {
|
|
126
177
|
const now = performance.now();
|
|
127
178
|
const dt = Math.min(0.1, Math.max(0, (now - (t.lastAt || now)) / 1000));
|
|
128
179
|
t.lastAt = now;
|
|
@@ -141,9 +192,11 @@ function frame(t, scene, mp, local, idle) {
|
|
|
141
192
|
const config = hub.place?.grab ?? null;
|
|
142
193
|
const phys = scene.physics3d;
|
|
143
194
|
const self = net?.selfId?.();
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
195
|
+
const ready = Boolean(config && net && local?.components.Transform && phys?.ready?.() && !hub.held.has(self));
|
|
196
|
+
const can = ready && idle;
|
|
197
|
+
// A temporary sheet cancels an Act throw, but preserves the carry shared
|
|
198
|
+
// with the server. Closing it can then start a new throw normally.
|
|
199
|
+
const paused = deck.act === true && ready && pauseCarry;
|
|
147
200
|
|
|
148
201
|
if (t.held) {
|
|
149
202
|
const id = t.held.id;
|
|
@@ -153,7 +206,7 @@ function frame(t, scene, mp, local, idle) {
|
|
|
153
206
|
// object to someone else or back to the server, when the place hides it,
|
|
154
207
|
// or when the player cannot act (a trip, held still, a game's end).
|
|
155
208
|
if (
|
|
156
|
-
!can ||
|
|
209
|
+
(!can && !paused) ||
|
|
157
210
|
told ||
|
|
158
211
|
!mp.own?.mine?.has(id) ||
|
|
159
212
|
hub.hidden.has(id) ||
|
|
@@ -161,19 +214,36 @@ function frame(t, scene, mp, local, idle) {
|
|
|
161
214
|
!scene.getActor(id)
|
|
162
215
|
) {
|
|
163
216
|
t.held = null;
|
|
164
|
-
} else if (pressed) {
|
|
165
|
-
throwHeld(t, scene, body, local, config, net, now);
|
|
166
217
|
} else {
|
|
167
|
-
|
|
168
|
-
if (
|
|
169
|
-
//
|
|
170
|
-
//
|
|
171
|
-
t.held
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
218
|
+
if (paused) {delete t.held.aim; delete t.held.actThrow;}
|
|
219
|
+
if (scene.cameraControl === 'orbit') {
|
|
220
|
+
// What this client has told the server of the hold, for a throw's
|
|
221
|
+
// swing to keep inside (`reach`); it changes nothing here.
|
|
222
|
+
listen(t.held, mp);
|
|
223
|
+
}
|
|
224
|
+
if (t.held.aim) {
|
|
225
|
+
aimFrame(t, scene, mp, body, local, config, net, now, dt);
|
|
226
|
+
} else if (can && pressed && scene.cameraControl === 'orbit') {
|
|
227
|
+
aimThrow(t, scene, mp, body, local, config, dt, now);
|
|
228
|
+
} else if (can && pressed) {
|
|
229
|
+
throwHeld(t, scene, body, local, config, net, now);
|
|
230
|
+
} else {
|
|
231
|
+
carry(t, scene, body, local, config, dt);
|
|
232
|
+
if (config.keepHeld === true) {
|
|
233
|
+
// v1.25: the server keeps a held object this client's only while it
|
|
234
|
+
// hears the hold goes on.
|
|
235
|
+
t.held.toldAt ??= now;
|
|
236
|
+
if (now - t.held.toldAt >= KEEP_TELL_MS) {
|
|
237
|
+
t.held.toldAt = now;
|
|
238
|
+
net.send({ k: 'hub-grab', actor: id, op: 'hold' });
|
|
239
|
+
}
|
|
175
240
|
}
|
|
176
241
|
}
|
|
242
|
+
if (t.held && scene.cameraControl === 'orbit') {
|
|
243
|
+
// Where the body is now is what the multiplayer kit's report, after
|
|
244
|
+
// this system, packs if one goes out this frame (`listen`).
|
|
245
|
+
put(t.held, body);
|
|
246
|
+
}
|
|
177
247
|
}
|
|
178
248
|
}
|
|
179
249
|
if (t.held) {
|
|
@@ -341,14 +411,14 @@ function sizeOf(shape) {
|
|
|
341
411
|
|
|
342
412
|
// Where a held object goes: `holdDistance` in front of the player (never so
|
|
343
413
|
// close that it touches them) and `holdHeight` above their feet (never so low
|
|
344
|
-
// that it is in the ground).
|
|
345
|
-
|
|
414
|
+
// that it is in the ground). `f`, radians, is the way it is in front along:
|
|
415
|
+
// the player's facing unless an aimed throw (below) says otherwise.
|
|
416
|
+
function holdPoint(local, config, held, f = (local.components.Transform.rotationY ?? 0) * DEG) {
|
|
346
417
|
const t = local.components.Transform;
|
|
347
418
|
const shape = local.components.Shape;
|
|
348
419
|
const radius = typeof shape?.radius === 'number' ? shape.radius : PLAYER.radius;
|
|
349
420
|
const height = typeof shape?.height === 'number' ? shape.height : PLAYER.height;
|
|
350
421
|
const feet = t.y - (height / 2 + PLAYER.hover);
|
|
351
|
-
const f = (t.rotationY ?? 0) * DEG;
|
|
352
422
|
const distance = Math.max(config.holdDistance, radius + held.extent + 0.15);
|
|
353
423
|
return {
|
|
354
424
|
x: t.x + Math.sin(f) * distance,
|
|
@@ -359,16 +429,25 @@ function holdPoint(local, config, held) {
|
|
|
359
429
|
|
|
360
430
|
// Move the held object toward its hold point, at most CARRY_SPEED. It keeps
|
|
361
431
|
// the velocity it is carried at, which the multiplayer kit reports with its
|
|
362
|
-
// pose, so other players draw it moving smoothly.
|
|
363
|
-
|
|
432
|
+
// pose, so other players draw it moving smoothly. `to` is where it goes: the
|
|
433
|
+
// hold point unless an aimed throw says otherwise, and `most` how far it may
|
|
434
|
+
// go this frame. Returns whether it got there this frame.
|
|
435
|
+
function carry(
|
|
436
|
+
t,
|
|
437
|
+
scene,
|
|
438
|
+
body,
|
|
439
|
+
local,
|
|
440
|
+
config,
|
|
441
|
+
dt,
|
|
442
|
+
to = holdPoint(local, config, t.held),
|
|
443
|
+
most = CARRY_SPEED * dt,
|
|
444
|
+
) {
|
|
364
445
|
const held = t.held;
|
|
365
|
-
const to = holdPoint(local, config, held);
|
|
366
446
|
const from = held.at;
|
|
367
447
|
const dx = to.x - from.x;
|
|
368
448
|
const dy = to.y - from.y;
|
|
369
449
|
const dz = to.z - from.z;
|
|
370
450
|
const d = Math.hypot(dx, dy, dz);
|
|
371
|
-
const most = CARRY_SPEED * dt;
|
|
372
451
|
const k = d > most && d > 0 ? most / d : 1;
|
|
373
452
|
const next = { x: from.x + dx * k, y: from.y + dy * k, z: from.z + dz * k };
|
|
374
453
|
body.setTranslation(next, true);
|
|
@@ -387,14 +466,274 @@ function carry(t, scene, body, local, config, dt) {
|
|
|
387
466
|
transform.y = next.y;
|
|
388
467
|
transform.z = next.z;
|
|
389
468
|
}
|
|
469
|
+
return k === 1;
|
|
390
470
|
}
|
|
391
471
|
|
|
392
|
-
// Let go along the player's facing at `throwSpeed`, a little upward
|
|
393
|
-
|
|
394
|
-
|
|
472
|
+
// Let go along the player's facing at `throwSpeed`, a little upward (or
|
|
473
|
+
// along `f`, radians, for an aimed throw).
|
|
474
|
+
function throwHeld(
|
|
475
|
+
t,
|
|
476
|
+
scene,
|
|
477
|
+
body,
|
|
478
|
+
local,
|
|
479
|
+
config,
|
|
480
|
+
net,
|
|
481
|
+
now,
|
|
482
|
+
f = (local.components.Transform.rotationY ?? 0) * DEG,
|
|
483
|
+
) {
|
|
395
484
|
const speed = config.throwSpeed;
|
|
396
485
|
body.setLinvel({ x: Math.sin(f) * speed, y: speed * THROW_UP, z: Math.cos(f) * speed }, true);
|
|
397
|
-
|
|
486
|
+
if (t.held.actThrow) {t.held.actThrow();}
|
|
487
|
+
else {net.send({ k: 'hub-grab', actor: t.held.id, op: 'throw' });}
|
|
398
488
|
t.held = null;
|
|
399
489
|
t.quietUntil = now + REGRAB_MS;
|
|
400
490
|
}
|
|
491
|
+
|
|
492
|
+
// ---- Under the orbit camera key only ------------------------------------------
|
|
493
|
+
//
|
|
494
|
+
// Throw where the camera looks: along f = PI - camAngle, the camera's forward
|
|
495
|
+
// on the ground (the facing the character always has without the key; Player
|
|
496
|
+
// keyless: `rt.facing = Math.PI - per.camAngle`). The press does not let go at
|
|
497
|
+
// once. It asks the Player to turn the character to f (`scene.faceRequest`,
|
|
498
|
+
// taken by the Player's next update), and from then on the held object swings
|
|
499
|
+
// round the player, at the hold distance and no faster than it is carried, to
|
|
500
|
+
// the hold point along f, so a throw toward the camera does not start inside
|
|
501
|
+
// the player. The swing goes only as fast as the server hears it: never more
|
|
502
|
+
// than AIM_SLACK_M, in a straight line, from any position this client has
|
|
503
|
+
// reported since the one the server's body is sure to have reached (`reach`,
|
|
504
|
+
// from multiplayer-3d's `acks` and the broadcasts' simulation time), carry
|
|
505
|
+
// reports from before the press included, so no bunch of its reports and no
|
|
506
|
+
// tick without a physics step can break the owned-object move bound and take
|
|
507
|
+
// the object away mid-throw. The throw is let go -- the velocity and the
|
|
508
|
+
// `hub-grab` throw -- on the first frame where:
|
|
509
|
+
// - the object is at that hold point, and
|
|
510
|
+
// - the character has faced f on every frame since some frame F (its
|
|
511
|
+
// Transform.rotationY, which the multiplayer kit packs into each movement
|
|
512
|
+
// report), and a movement report went out after F's: the multiplayer
|
|
513
|
+
// kit's `moveSeq` counts reports sent, and it reports after this system
|
|
514
|
+
// every frame, so a count that moved on since F means a report carrying
|
|
515
|
+
// f is on the wire before the throw, on the same connection.
|
|
516
|
+
// Past AIM_WAIT_MS after the press the object's place is enough, whatever the
|
|
517
|
+
// facing: a throw is not held up by a facing the Player did not take (a walk
|
|
518
|
+
// eases the facing toward it at once) or a report that never went out. The
|
|
519
|
+
// swing always gets there (it turns at the carry speed round a player who
|
|
520
|
+
// is placed every frame), unless the player outruns the carry (a tune far
|
|
521
|
+
// past the walk) or the server stops acknowledging (a stalled connection):
|
|
522
|
+
// AIM_GIVE_UP_MS after the press the throw goes from wherever the object is.
|
|
523
|
+
// A multiplayer kit without acknowledgements or report numbers swings at the
|
|
524
|
+
// carry speed, unbounded, as before.
|
|
525
|
+
// Meanwhile the object stays held: carried (at rest where it is put, under
|
|
526
|
+
// the acknowledgement bound; at the carry's velocity without it), the
|
|
527
|
+
// v1.25 `keepHeld` word still said; another press does nothing; anything that
|
|
528
|
+
// ends a hold (a drop, a refusal, the object handed on or hidden, the player
|
|
529
|
+
// unable to act, a new session or scene) ends it with no throw sent, as it
|
|
530
|
+
// ends any hold.
|
|
531
|
+
|
|
532
|
+
function aimThrow(t, scene, mp, body, local, config, dt, now) {
|
|
533
|
+
const me = local.components.Transform;
|
|
534
|
+
const cam = scene.persistent?.camAngle;
|
|
535
|
+
const f = Number.isFinite(cam) ? Math.PI - cam : (me.rotationY ?? 0) * DEG;
|
|
536
|
+
const at = t.held.at;
|
|
537
|
+
t.held.aim = {
|
|
538
|
+
f,
|
|
539
|
+
until: now + AIM_WAIT_MS,
|
|
540
|
+
last: now + AIM_GIVE_UP_MS,
|
|
541
|
+
// The object's bearing round the player, swung toward f.
|
|
542
|
+
a: Math.atan2(at.x - me.x, at.z - me.z),
|
|
543
|
+
facedSeq: null,
|
|
544
|
+
local,
|
|
545
|
+
};
|
|
546
|
+
scene.faceRequest = f;
|
|
547
|
+
swing(t, scene, mp, body, local, config, dt);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
function aimFrame(t, scene, mp, body, local, config, net, now, dt) {
|
|
551
|
+
const aim = t.held.aim;
|
|
552
|
+
if (aim.local !== local) {
|
|
553
|
+
// A scene load: the request was dropped with the scene, and the hold
|
|
554
|
+
// ends as one across a load does.
|
|
555
|
+
t.held = null;
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
if (config.keepHeld === true) {
|
|
559
|
+
t.held.toldAt ??= now;
|
|
560
|
+
if (now - t.held.toldAt >= KEEP_TELL_MS) {
|
|
561
|
+
t.held.toldAt = now;
|
|
562
|
+
net.send({ k: 'hub-grab', actor: t.held.id, op: 'hold' });
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
const there = swing(t, scene, mp, body, local, config, dt);
|
|
566
|
+
const seq = Number.isFinite(mp.moveSeq) ? mp.moveSeq : null;
|
|
567
|
+
const reported = aim.facedSeq !== null && seq !== aim.facedSeq;
|
|
568
|
+
if ((there && (reported || now >= aim.until)) || now >= aim.last) {
|
|
569
|
+
throwHeld(t, scene, body, local, config, net, now, aim.f);
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
const faced =
|
|
573
|
+
Math.abs(turn((local.components.Transform.rotationY ?? 0) * DEG - aim.f)) <= AIM_FACE_RAD;
|
|
574
|
+
aim.facedSeq = faced && seq !== null ? (aim.facedSeq ?? seq) : null;
|
|
575
|
+
// Asked again each frame it waits: a request is taken once.
|
|
576
|
+
scene.faceRequest = aim.f;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// One frame of the swing: the bearing turns toward f by what `most` metres
|
|
580
|
+
// covers at the hold distance, and the object goes at most `most` toward the
|
|
581
|
+
// hold point on that bearing. `most` is what the carry speed covers, or, where
|
|
582
|
+
// the server's acknowledgements bound the swing, the most of that which keeps
|
|
583
|
+
// the object within AIM_SLACK_M of every place `reach` says the server's body
|
|
584
|
+
// may be (none at all while it cannot say). Returns whether the object is at
|
|
585
|
+
// the hold point along f.
|
|
586
|
+
function swing(t, scene, mp, body, local, config, dt) {
|
|
587
|
+
const held = t.held;
|
|
588
|
+
const aim = held.aim;
|
|
589
|
+
const shape = local.components.Shape;
|
|
590
|
+
const radius = typeof shape?.radius === 'number' ? shape.radius : PLAYER.radius;
|
|
591
|
+
const distance = Math.max(config.holdDistance, radius + held.extent + 0.15);
|
|
592
|
+
const step = (most) => {
|
|
593
|
+
const by = most / distance;
|
|
594
|
+
const left = turn(aim.f - aim.a);
|
|
595
|
+
const a = Math.abs(left) <= by ? aim.f : aim.a + Math.sign(left) * by;
|
|
596
|
+
const to = holdPoint(local, config, held, a);
|
|
597
|
+
const from = held.at;
|
|
598
|
+
const d = Math.hypot(to.x - from.x, to.y - from.y, to.z - from.z);
|
|
599
|
+
const k = d > most && d > 0 ? most / d : 1;
|
|
600
|
+
const next = {
|
|
601
|
+
x: from.x + (to.x - from.x) * k,
|
|
602
|
+
y: from.y + (to.y - from.y) * k,
|
|
603
|
+
z: from.z + (to.z - from.z) * k,
|
|
604
|
+
};
|
|
605
|
+
return { a, to, next };
|
|
606
|
+
};
|
|
607
|
+
const full = CARRY_SPEED * dt;
|
|
608
|
+
const places = reach(held, mp);
|
|
609
|
+
let most = full;
|
|
610
|
+
if (places === false) {
|
|
611
|
+
most = 0;
|
|
612
|
+
} else if (places !== null) {
|
|
613
|
+
const fits = (p) =>
|
|
614
|
+
places.every((q) => Math.hypot(p.x - q.x, p.y - q.y, p.z - q.z) <= AIM_SLACK_M);
|
|
615
|
+
if (!fits(step(full).next)) {
|
|
616
|
+
// The farthest that fits, to well under a millimetre; none, when even a
|
|
617
|
+
// little way does not (the object stays where it was last reported).
|
|
618
|
+
let lo = 0;
|
|
619
|
+
let hi = full;
|
|
620
|
+
for (let i = 0; i < 24; i += 1) {
|
|
621
|
+
const mid = (lo + hi) / 2;
|
|
622
|
+
if (fits(step(mid).next)) {
|
|
623
|
+
lo = mid;
|
|
624
|
+
} else {
|
|
625
|
+
hi = mid;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
most = lo;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
const { a, to } = step(most);
|
|
632
|
+
aim.a = a;
|
|
633
|
+
const reached = carry(t, scene, body, local, config, dt, to, most);
|
|
634
|
+
if (places !== null) {
|
|
635
|
+
// Reported at rest where it is put: the swing's own pace is the
|
|
636
|
+
// acknowledgements', not a velocity the next physics step carries on.
|
|
637
|
+
body.setLinvel({ x: 0, y: 0, z: 0 }, true);
|
|
638
|
+
}
|
|
639
|
+
return reached && aim.a === aim.f;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
// What this client has told the server about a held object, kept frame by
|
|
643
|
+
// frame under the orbit key while it is held: `trail`, `[report number,
|
|
644
|
+
// position]` for each movement report since the hold began (carry and swing
|
|
645
|
+
// alike), known from report number `from` on; and `sure`, the newest report
|
|
646
|
+
// the server's body is sure to have reached (`reach`). The position is the one
|
|
647
|
+
// the report carried: the body where this system left it the frame the report
|
|
648
|
+
// went out (`put`), which the multiplayer kit reads straight after, before the
|
|
649
|
+
// next frame's physics moves it on at its velocity. Never the body read back a
|
|
650
|
+
// frame later, which is not where it was reported. Without acknowledgements or
|
|
651
|
+
// report numbers there is nothing to keep.
|
|
652
|
+
function listen(held, mp) {
|
|
653
|
+
if (!(mp.acks instanceof Map) || !Number.isFinite(mp.moveSeq)) {
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
const epoch = mp.handed?.get?.(held.id)?.epoch;
|
|
657
|
+
let sent = held.sent;
|
|
658
|
+
if (!sent || sent.epoch !== epoch) {
|
|
659
|
+
// Reports up to now are of an object not yet held here (or under another
|
|
660
|
+
// grant): where they put it is not known.
|
|
661
|
+
sent = held.sent = {
|
|
662
|
+
epoch,
|
|
663
|
+
seq: mp.moveSeq,
|
|
664
|
+
from: mp.moveSeq + 1,
|
|
665
|
+
trail: [],
|
|
666
|
+
sure: -Infinity,
|
|
667
|
+
put: null,
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
if (mp.moveSeq !== sent.seq) {
|
|
671
|
+
if (mp.moveSeq === sent.seq + 1 && sent.put) {
|
|
672
|
+
sent.trail.push([mp.moveSeq, sent.put]);
|
|
673
|
+
} else {
|
|
674
|
+
// Reports went out unseen, or after a frame that left nothing put:
|
|
675
|
+
// what they carried is not known.
|
|
676
|
+
sent.from = mp.moveSeq + 1;
|
|
677
|
+
}
|
|
678
|
+
sent.seq = mp.moveSeq;
|
|
679
|
+
}
|
|
680
|
+
sent.put = null;
|
|
681
|
+
// multiplayer-3d's acknowledgement is `[epoch, lastSeq, tAck, ...]`: the
|
|
682
|
+
// newest report applied, and the simulation time it was applied at.
|
|
683
|
+
const ack = mp.acks.get(held.id);
|
|
684
|
+
if (
|
|
685
|
+
Array.isArray(ack) &&
|
|
686
|
+
Number.isFinite(ack[1]) &&
|
|
687
|
+
Number.isFinite(ack[2]) &&
|
|
688
|
+
(!Number.isFinite(epoch) || ack[0] === epoch) &&
|
|
689
|
+
hub.lastT > ack[2]
|
|
690
|
+
) {
|
|
691
|
+
sent.sure = Math.max(sent.sure, ack[1]);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
// The body of a held object where this system leaves it this frame: the
|
|
696
|
+
// position a movement report going out this frame carries (`listen`).
|
|
697
|
+
function put(held, body) {
|
|
698
|
+
if (held.sent) {
|
|
699
|
+
const p = body.translation();
|
|
700
|
+
held.sent.put = { x: p.x, y: p.y, z: p.z };
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
// Every place the server's body for a held object may be when the next
|
|
705
|
+
// report reaches it: the reported positions from the newest one it is sure to
|
|
706
|
+
// have reached on. null when the multiplayer kit gives no acknowledgements
|
|
707
|
+
// or report numbers (the swing is unbounded, as before them); false when no
|
|
708
|
+
// such report is known yet.
|
|
709
|
+
//
|
|
710
|
+
// An acknowledgement alone is not a body moved. multiplayer-3d applies a
|
|
711
|
+
// report as it arrives (its kinematic target, stamped with the simulation
|
|
712
|
+
// time, `tAck`), moves the body to the newest applied target at each physics
|
|
713
|
+
// step, and acknowledges in the broadcast after a tick's steps; but a tick may
|
|
714
|
+
// run no step (its elapsed time short of one) and acknowledge all the same,
|
|
715
|
+
// leaving the body where the last step put it. The simulation time advances
|
|
716
|
+
// only by physics steps (a tick that falls behind skips time only after its
|
|
717
|
+
// full four), so a broadcast whose time (`msg.t`, which the hub's state hook
|
|
718
|
+
// keeps as `hub.lastT`) is past a report's `tAck` comes after a step that
|
|
719
|
+
// moved the body to that report or a later one. Later reports are ordered
|
|
720
|
+
// after it on the one connection, so the body may be at any of them, and
|
|
721
|
+
// never back before it.
|
|
722
|
+
function reach(held, mp) {
|
|
723
|
+
if (!(mp.acks instanceof Map) || !Number.isFinite(mp.moveSeq)) {
|
|
724
|
+
return null;
|
|
725
|
+
}
|
|
726
|
+
const sent = held.sent;
|
|
727
|
+
if (!sent || sent.sure < sent.from) {
|
|
728
|
+
return false;
|
|
729
|
+
}
|
|
730
|
+
while (sent.trail.length > 0 && sent.trail[0][0] < sent.sure) {
|
|
731
|
+
sent.trail.shift();
|
|
732
|
+
}
|
|
733
|
+
return sent.trail.length > 0 ? sent.trail.map(([, p]) => p) : false;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
// An angle as the shortest way round: -PI..PI.
|
|
737
|
+
function turn(angle) {
|
|
738
|
+
return angle - 2 * Math.PI * Math.floor((angle + Math.PI) / (2 * Math.PI));
|
|
739
|
+
}
|