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
|
@@ -0,0 +1,961 @@
|
|
|
1
|
+
// Throwing under the engine's orbit camera key (code/client/grab.js,
|
|
2
|
+
// `scene.cameraControl === 'orbit'`), on a fake scene, Player, multiplayer kit
|
|
3
|
+
// and chrome:
|
|
4
|
+
// - Without the key every frame is what it was: a seeded run of frames
|
|
5
|
+
// (presses, turns, uneven frames, objects moving, handed on, hidden, the
|
|
6
|
+
// player unable to act, keepHeld and steady places) gives the same body
|
|
7
|
+
// calls, sends, prompts and transforms as `grab.before-orbit.mjs`, which is
|
|
8
|
+
// code/client/grab.js as it was on the commit before the key, copied whole,
|
|
9
|
+
// and never sets `scene.faceRequest`.
|
|
10
|
+
// - With it a throw goes along PI - camAngle: the press asks the Player to
|
|
11
|
+
// face that way, the held object swings round the player to the hold point
|
|
12
|
+
// along it, and the throw is let go only once a movement report carrying
|
|
13
|
+
// the new facing has gone out (or AIM_WAIT_MS after the press without
|
|
14
|
+
// one) and the object is there, or AIM_GIVE_UP_MS after the press whatever
|
|
15
|
+
// happened; anything that ends a hold meanwhile ends it with no throw.
|
|
16
|
+
// - Against multiplayer-3d's own setObjectPoses (the owned-object move
|
|
17
|
+
// bound) with reports bunched between server steps, a stall, ticks that
|
|
18
|
+
// run no physics step, carry movement not yet acknowledged at the press and
|
|
19
|
+
// uneven frames, the swing never puts the object more than AIM_SLACK_M
|
|
20
|
+
// from anywhere the server's body may be, so the object is never taken
|
|
21
|
+
// away mid-throw and the throw reaches the server while the object is
|
|
22
|
+
// still the player's. The
|
|
23
|
+
// fake multiplayer kit of the tests before that has no acknowledgements,
|
|
24
|
+
// so its swings are the unbounded ones at the carry speed.
|
|
25
|
+
// `npm run check` runs it; it needs nothing installed.
|
|
26
|
+
|
|
27
|
+
import assert from 'node:assert/strict';
|
|
28
|
+
import { readFileSync } from 'node:fs';
|
|
29
|
+
import { register } from 'node:module';
|
|
30
|
+
import { AIM_GIVE_UP_MS, AIM_SLACK_M, AIM_WAIT_MS, KEEP_TELL_MS, makeGrab } from '../code/client/grab.js';
|
|
31
|
+
import { deck, hub } from '../code/client/state.js';
|
|
32
|
+
import { GRAB_DEFAULTS } from '../code/server/manifest.js';
|
|
33
|
+
import { THROW_REACH } from '../code/server/grab.js';
|
|
34
|
+
|
|
35
|
+
let clock = 1000;
|
|
36
|
+
Object.defineProperty(globalThis, 'performance', {
|
|
37
|
+
value: { now: () => clock },
|
|
38
|
+
configurable: true,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// The copy imports './state.js' as the live module does; it is pointed at the
|
|
42
|
+
// same file, so both read one `hub`.
|
|
43
|
+
const beforeSource = readFileSync(new URL('./grab.before-orbit.mjs', import.meta.url), 'utf8');
|
|
44
|
+
assert.ok(!beforeSource.includes('orbit') && beforeSource.includes("from './state.js'"));
|
|
45
|
+
const { makeGrab: makeGrabBefore } = await import(
|
|
46
|
+
`data:text/javascript,${encodeURIComponent(
|
|
47
|
+
beforeSource.replace("from './state.js'", `from '${new URL('../code/client/state.js', import.meta.url)}'`),
|
|
48
|
+
)}`
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const DEG = Math.PI / 180;
|
|
52
|
+
const PILLOW = { kind: 'sphere', radius: 0.3 };
|
|
53
|
+
const SEND_MS = 50; // the multiplayer kit's MOVE_HZ, 20
|
|
54
|
+
|
|
55
|
+
// One client in a place, in the engine's order each frame: the Player
|
|
56
|
+
// behavior, which takes a facing request once (physics-3d updateOrbiting);
|
|
57
|
+
// the client's physics (`physics(rig, ms)`); the hub, whose grab runs after
|
|
58
|
+
// that physics step; and the multiplayer kit, which runs after the hub and
|
|
59
|
+
// sends a movement report at most every 50 ms, packing the bodies as the hub
|
|
60
|
+
// left them (`onReport(rig)` sees each report as it goes out, before
|
|
61
|
+
// `moveSeq` counts it). A rig without `physics` or `onReport` has neither.
|
|
62
|
+
function rig(
|
|
63
|
+
grab,
|
|
64
|
+
objects,
|
|
65
|
+
{ make = makeGrab, cameraControl, persistent, moveSeq = true, player = 'orbit', physics, onReport } = {},
|
|
66
|
+
) {
|
|
67
|
+
hub.place = grab === null ? {} : { grab };
|
|
68
|
+
hub.hidden.clear();
|
|
69
|
+
hub.held.clear();
|
|
70
|
+
hub.grabEvents.length = 0;
|
|
71
|
+
const log = [];
|
|
72
|
+
const prompts = [];
|
|
73
|
+
const wire = [];
|
|
74
|
+
let press = null;
|
|
75
|
+
const chrome = {
|
|
76
|
+
onGrab: (fn) => (press = fn),
|
|
77
|
+
grabPrompt: (text) => {
|
|
78
|
+
prompts.push(text);
|
|
79
|
+
log.push(['prompt', text]);
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
const g = make(chrome);
|
|
83
|
+
const actors = new Map();
|
|
84
|
+
const bodies = new Map();
|
|
85
|
+
for (const [id, o] of Object.entries(objects)) {
|
|
86
|
+
const transform = { x: o.x, y: o.y ?? 0.85, z: o.z };
|
|
87
|
+
actors.set(id, {
|
|
88
|
+
components: { Transform: transform, Shape: o.shape ?? PILLOW, Body: { type: 'dynamic' } },
|
|
89
|
+
});
|
|
90
|
+
const body = {
|
|
91
|
+
v: { x: 0, y: 0, z: 0 },
|
|
92
|
+
translation: () => ({ x: transform.x, y: transform.y, z: transform.z }),
|
|
93
|
+
isDynamic: () => true,
|
|
94
|
+
linvel: () => ({ ...body.v }),
|
|
95
|
+
setTranslation(p, wake) {
|
|
96
|
+
log.push(['setTranslation', id, { ...p }, wake]);
|
|
97
|
+
Object.assign(transform, p);
|
|
98
|
+
},
|
|
99
|
+
setLinvel(v, wake) {
|
|
100
|
+
log.push(['setLinvel', id, { ...v }, wake]);
|
|
101
|
+
body.v = { ...v };
|
|
102
|
+
},
|
|
103
|
+
setAngvel(v, wake) {
|
|
104
|
+
log.push(['setAngvel', id, { ...v }, wake]);
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
bodies.set(id, body);
|
|
108
|
+
}
|
|
109
|
+
const scene = {
|
|
110
|
+
getActor: (id) => actors.get(id) ?? null,
|
|
111
|
+
physics3d: { ready: () => true, bodyOf: (id) => bodies.get(id) ?? null },
|
|
112
|
+
persistent,
|
|
113
|
+
};
|
|
114
|
+
if (cameraControl !== undefined) {
|
|
115
|
+
scene.cameraControl = cameraControl;
|
|
116
|
+
}
|
|
117
|
+
const mine = new Set(actors.keys());
|
|
118
|
+
const mp = {
|
|
119
|
+
net: {
|
|
120
|
+
selfId: () => 'me',
|
|
121
|
+
send: (d) => {
|
|
122
|
+
log.push(['send', d]);
|
|
123
|
+
wire.push({ send: d });
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
own: { mine },
|
|
127
|
+
claimable: () => [...actors].map(([id, a]) => [id, a.components.Transform]),
|
|
128
|
+
};
|
|
129
|
+
if (moveSeq) {
|
|
130
|
+
mp.moveSeq = 0;
|
|
131
|
+
}
|
|
132
|
+
let sentAt = -Infinity;
|
|
133
|
+
const me = { x: 0, y: 0.85, z: 0, rotationY: 0 };
|
|
134
|
+
const rig = { local: { components: { Transform: me } } };
|
|
135
|
+
const step = (ms = 16, pressed = false, idle = true, pauseCarry = false) => {
|
|
136
|
+
clock += ms;
|
|
137
|
+
if (player === 'orbit' && scene.faceRequest !== undefined) {
|
|
138
|
+
if (Number.isFinite(scene.faceRequest)) {
|
|
139
|
+
rig.local.components.Transform.rotationY = scene.faceRequest / DEG;
|
|
140
|
+
}
|
|
141
|
+
scene.faceRequest = undefined;
|
|
142
|
+
}
|
|
143
|
+
physics?.(rig, ms);
|
|
144
|
+
if (pressed) {
|
|
145
|
+
press();
|
|
146
|
+
}
|
|
147
|
+
g.frame(scene, mp, rig.local, idle, pauseCarry);
|
|
148
|
+
if (clock - sentAt >= SEND_MS) {
|
|
149
|
+
sentAt = clock;
|
|
150
|
+
onReport?.(rig);
|
|
151
|
+
if (moveSeq) {
|
|
152
|
+
mp.moveSeq += 1;
|
|
153
|
+
}
|
|
154
|
+
wire.push({ facing: rig.local.components.Transform.rotationY });
|
|
155
|
+
}
|
|
156
|
+
log.push(['transform', { ...me }, scene.faceRequest]);
|
|
157
|
+
return prompts.at(-1);
|
|
158
|
+
};
|
|
159
|
+
const throws = () => wire.filter((w) => w.send?.op === 'throw');
|
|
160
|
+
Object.assign(rig, { g, step, me, mine, scene, mp, actors, bodies, log, wire, throws, rig });
|
|
161
|
+
return rig;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function at(distance, deg) {
|
|
165
|
+
return { x: Math.sin(deg * DEG) * distance, z: Math.cos(deg * DEG) * distance };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
{
|
|
169
|
+
const r = rig({ ...GRAB_DEFAULTS }, { a: at(1.2, 0) }, { cameraControl: 'orbit', persistent: { camAngle: 0 }, player: 'orbit', moveSeq: true });
|
|
170
|
+
r.step();
|
|
171
|
+
r.g.perform('a', r.scene, r.mp, r.local, 'grab');
|
|
172
|
+
let released = 0;
|
|
173
|
+
r.g.perform('a', r.scene, r.mp, r.local, 'throw', () => {released++;});
|
|
174
|
+
assert.equal(released, 0, 'Act throw waits for orbit preparation');
|
|
175
|
+
for (let n = 0; n < 200 && !released; n++) {r.step();}
|
|
176
|
+
assert.equal(released, 1, 'Act sends exactly one final after aim');
|
|
177
|
+
assert.equal(r.throws().length, 0, 'Act does not also send legacy throw');
|
|
178
|
+
assert(r.bodies.get('a').translation().z < 0, 'Act throw starts in front of the new facing');
|
|
179
|
+
}
|
|
180
|
+
{
|
|
181
|
+
deck.act = true;
|
|
182
|
+
const r = rig({ ...GRAB_DEFAULTS }, { a: at(1.2, 0) }, { cameraControl: 'orbit', persistent: { camAngle: 0 } });
|
|
183
|
+
r.step(); r.g.perform('a', r.scene, r.mp, r.local, 'grab');
|
|
184
|
+
let cancelled = 0, retried = 0;
|
|
185
|
+
r.g.perform('a', r.scene, r.mp, r.local, 'throw', () => {cancelled++;});
|
|
186
|
+
r.step(16, false, false, true);
|
|
187
|
+
assert.equal(r.g.holding(), 'a', 'sheet retains server-consistent carry');
|
|
188
|
+
r.step();
|
|
189
|
+
r.g.perform('a', r.scene, r.mp, r.local, 'throw', () => {retried++;});
|
|
190
|
+
for (let n = 0; n < 200 && !retried; n++) {r.step();}
|
|
191
|
+
assert.equal(cancelled, 0, 'sheet voids pending throw');
|
|
192
|
+
assert.equal(retried, 1, 'throw retry works after closing sheet');
|
|
193
|
+
deck.act = false;
|
|
194
|
+
}
|
|
195
|
+
{
|
|
196
|
+
deck.act = true;
|
|
197
|
+
const r = rig({ ...GRAB_DEFAULTS }, { a: at(1.2, 0) }, { cameraControl: 'orbit', persistent: { camAngle: 0 } });
|
|
198
|
+
r.step(); r.g.perform('a', r.scene, r.mp, r.local, 'grab');
|
|
199
|
+
let released = 0;
|
|
200
|
+
r.g.perform('a', r.scene, r.mp, r.local, 'throw', () => {released++;});
|
|
201
|
+
r.step(16, false, false);
|
|
202
|
+
assert.equal(r.g.holding(), null, 'travel/end invalidation still drops carry');
|
|
203
|
+
for (let n = 0; n < 200; n++) {r.step();}
|
|
204
|
+
assert.equal(released, 0, 'travel/end invalidation cancels final');
|
|
205
|
+
deck.act = false;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// A small seeded generator, so the run is the same every time.
|
|
209
|
+
function seeded(seed) {
|
|
210
|
+
let s = seed >>> 0;
|
|
211
|
+
return () => {
|
|
212
|
+
s = (s * 1664525 + 1013904223) >>> 0;
|
|
213
|
+
return s / 2 ** 32;
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
let n = 0;
|
|
218
|
+
function test(name, fn) {
|
|
219
|
+
try {
|
|
220
|
+
fn();
|
|
221
|
+
} catch (err) {
|
|
222
|
+
console.error(`test-grab-orbit: ${name}`);
|
|
223
|
+
throw err;
|
|
224
|
+
}
|
|
225
|
+
n += 1;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// A scripted run: the same random choices each time for the same seed.
|
|
229
|
+
function script(r, seed, frames = 900) {
|
|
230
|
+
const rand = seeded(seed);
|
|
231
|
+
for (let i = 0; i < frames; i += 1) {
|
|
232
|
+
const roll = rand();
|
|
233
|
+
if (roll < 0.04) {
|
|
234
|
+
r.me.rotationY = (rand() - 0.5) * 400;
|
|
235
|
+
} else if (roll < 0.06) {
|
|
236
|
+
r.me.x = (rand() - 0.5) * 2;
|
|
237
|
+
r.me.z = (rand() - 0.5) * 2;
|
|
238
|
+
} else if (roll < 0.07) {
|
|
239
|
+
r.mine.has('a') ? r.mine.delete('a') : r.mine.add('a');
|
|
240
|
+
} else if (roll < 0.075) {
|
|
241
|
+
hub.hidden.has('b') ? hub.hidden.delete('b') : hub.hidden.add('b');
|
|
242
|
+
} else if (roll < 0.08) {
|
|
243
|
+
hub.grabEvents.push({ k: 'hub-drop', actor: 'a' });
|
|
244
|
+
} else if (roll < 0.09) {
|
|
245
|
+
const t = r.actors.get('b').components.Transform;
|
|
246
|
+
const p = at(0.8 + rand() * 1.5, (rand() - 0.5) * 120);
|
|
247
|
+
t.x = r.me.x + p.x;
|
|
248
|
+
t.z = r.me.z + p.z;
|
|
249
|
+
}
|
|
250
|
+
const ms = rand() < 0.1 ? rand() * 120 : 8 + rand() * 25;
|
|
251
|
+
r.step(ms, rand() < 0.12, rand() > 0.03);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
test('without the key: a seeded run is the code before the key, call for call, and never asks for a facing', () => {
|
|
256
|
+
const places = [
|
|
257
|
+
{ ...GRAB_DEFAULTS },
|
|
258
|
+
{ ...GRAB_DEFAULTS, steady: true, reach: 2.2 },
|
|
259
|
+
{ ...GRAB_DEFAULTS, keepHeld: true, steady: true, holdDistance: 0.9, throwSpeed: 14 },
|
|
260
|
+
{ ...GRAB_DEFAULTS, reach: 2, holdDistance: 3, holdHeight: 2.5 },
|
|
261
|
+
];
|
|
262
|
+
// No key, a null one (what the engine latches without it), and anything
|
|
263
|
+
// that is not exactly 'orbit'; with and without a camera angle.
|
|
264
|
+
const keys = [undefined, null, 'Orbit', 'free'];
|
|
265
|
+
let throws = 0;
|
|
266
|
+
for (const [pi, grab] of places.entries()) {
|
|
267
|
+
for (const [ki, cameraControl] of keys.entries()) {
|
|
268
|
+
const seed = 1 + pi * 10 + ki;
|
|
269
|
+
const objects = { a: at(1.2, 0), b: at(1.5, 20) };
|
|
270
|
+
const persistent = ki % 2 === 0 ? { camAngle: 2.1 } : undefined;
|
|
271
|
+
const start = clock;
|
|
272
|
+
const now = rig(grab, objects, { cameraControl, persistent });
|
|
273
|
+
script(now, seed);
|
|
274
|
+
clock = start;
|
|
275
|
+
const before = rig(grab, objects, { cameraControl, persistent, make: makeGrabBefore });
|
|
276
|
+
script(before, seed);
|
|
277
|
+
assert.ok(now.log.length > 1500, String(now.log.length));
|
|
278
|
+
assert.deepEqual(now.log, before.log, `place ${pi}, key ${String(cameraControl)}`);
|
|
279
|
+
assert.deepEqual(now.wire, before.wire);
|
|
280
|
+
assert.ok(now.log.every((e) => e[0] !== 'transform' || e[2] === undefined));
|
|
281
|
+
assert.equal(now.scene.faceRequest, undefined);
|
|
282
|
+
throws += now.throws().length;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
// The run threw, many times over.
|
|
286
|
+
assert.ok(throws > 50, String(throws));
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// Grab the object in front with a press; returns the rig.
|
|
290
|
+
function holding(grab = { ...GRAB_DEFAULTS }, options = {}, objects = { a: at(1.2, 0) }) {
|
|
291
|
+
const r = rig(grab, objects, { cameraControl: 'orbit', persistent: { camAngle: 0 }, ...options });
|
|
292
|
+
r.step();
|
|
293
|
+
assert.equal(r.step(16, true), 'Throw');
|
|
294
|
+
assert.equal(r.g.holding(), 'a');
|
|
295
|
+
// Carried to its hold point in front.
|
|
296
|
+
for (let i = 0; i < 20; i += 1) {
|
|
297
|
+
r.step();
|
|
298
|
+
}
|
|
299
|
+
return r;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const flat = (p, q) => Math.hypot(p.x - q.x, p.z - q.z);
|
|
303
|
+
|
|
304
|
+
for (const grab of [{ ...GRAB_DEFAULTS }, { ...GRAB_DEFAULTS, holdDistance: 0.9, throwSpeed: 14, keepHeld: true, steady: true }]) test(`with the key (hold ${grab.holdDistance} m): the throw goes along PI - camAngle, the character is asked to face it, and the throw waits for the swing and a report of that facing`, () => {
|
|
305
|
+
const r = holding(grab);
|
|
306
|
+
const body = r.bodies.get('a');
|
|
307
|
+
const obj = r.actors.get('a').components.Transform;
|
|
308
|
+
assert.ok(obj.z > 0.8, 'held in front of the facing (+z)');
|
|
309
|
+
// The camera behind at camAngle 0 looks along -z: f = PI, behind the
|
|
310
|
+
// character, which faces +z.
|
|
311
|
+
const cam = 0;
|
|
312
|
+
const f = Math.PI - cam;
|
|
313
|
+
const pressAt = clock;
|
|
314
|
+
r.step(16, true);
|
|
315
|
+
assert.equal(r.scene.faceRequest, f);
|
|
316
|
+
assert.equal(r.throws().length, 0);
|
|
317
|
+
assert.equal(r.g.holding(), 'a');
|
|
318
|
+
// Frame by frame until it goes: still held, prompt Throw, never inside the
|
|
319
|
+
// player's capsule (radius 0.35 + the pillow's 0.3).
|
|
320
|
+
let frames = 0;
|
|
321
|
+
while (r.throws().length === 0) {
|
|
322
|
+
assert.equal(r.step(16), r.throws().length ? null : 'Throw');
|
|
323
|
+
assert.ok(flat(obj, r.me) >= 0.35 + 0.3, `${flat(obj, r.me)}`);
|
|
324
|
+
frames += 1;
|
|
325
|
+
assert.ok(frames < 60);
|
|
326
|
+
}
|
|
327
|
+
// Let go as soon as the swing (half a turn at 20 m/s) reached the hold
|
|
328
|
+
// point along f: a report of the facing went out long before.
|
|
329
|
+
const holdD = Math.max(grab.holdDistance, 0.35 + 0.3 + 0.15);
|
|
330
|
+
const swingMs = ((Math.PI * holdD) / 20) * 1000;
|
|
331
|
+
assert.ok(clock - pressAt >= swingMs && clock - pressAt <= swingMs + 40, `${clock - pressAt} ${swingMs}`);
|
|
332
|
+
assert.ok(Math.abs(obj.x - Math.sin(f) * holdD) < 1e-9 && Math.abs(obj.z - Math.cos(f) * holdD) < 1e-9);
|
|
333
|
+
assert.ok(flat(obj, r.me) < THROW_REACH);
|
|
334
|
+
// Along f at throwSpeed, a quarter up.
|
|
335
|
+
const v = body.v;
|
|
336
|
+
assert.ok(Math.abs(v.x - Math.sin(f) * grab.throwSpeed) < 1e-9);
|
|
337
|
+
assert.ok(Math.abs(v.z - Math.cos(f) * grab.throwSpeed) < 1e-9);
|
|
338
|
+
assert.equal(v.y, grab.throwSpeed * 0.25);
|
|
339
|
+
// On the wire: a movement report with the new facing went out before the throw.
|
|
340
|
+
const ti = r.wire.findIndex((w) => w.send?.op === 'throw');
|
|
341
|
+
const faced = r.wire.findIndex((w) => w.facing !== undefined && Math.abs(w.facing - 180) < 1e-9);
|
|
342
|
+
assert.ok(faced >= 0 && faced < ti, JSON.stringify(r.wire.slice(-8)));
|
|
343
|
+
// Exactly one throw, nothing more asked of the Player, the hold over.
|
|
344
|
+
assert.equal(r.g.holding(), null);
|
|
345
|
+
assert.equal(r.scene.faceRequest, undefined);
|
|
346
|
+
for (let i = 0; i < 30; i += 1) {
|
|
347
|
+
r.step();
|
|
348
|
+
}
|
|
349
|
+
assert.equal(r.throws().length, 1);
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
test('with the key: a camera already looking the way the character faces lets go at the next report, no swing', () => {
|
|
353
|
+
const r = holding({ ...GRAB_DEFAULTS }, { persistent: { camAngle: Math.PI } });
|
|
354
|
+
const obj = r.actors.get('a').components.Transform;
|
|
355
|
+
const held = { ...obj };
|
|
356
|
+
r.step(16, true);
|
|
357
|
+
assert.equal(r.throws().length, 0);
|
|
358
|
+
let frames = 0;
|
|
359
|
+
while (r.throws().length === 0) {
|
|
360
|
+
r.step(16);
|
|
361
|
+
frames += 1;
|
|
362
|
+
}
|
|
363
|
+
// One frame for the Player to take the request, up to a report's 50 ms,
|
|
364
|
+
// and the frame after it.
|
|
365
|
+
assert.ok(frames <= 6, String(frames));
|
|
366
|
+
assert.ok(Math.abs(obj.x - held.x) < 1e-9 && Math.abs(obj.z - held.z) < 1e-9);
|
|
367
|
+
assert.ok(Math.abs(r.bodies.get('a').v.z - 10) < 1e-9);
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
test('with the key: the release follows the report, not just the facing: a report that has not gone out yet holds the throw', () => {
|
|
371
|
+
const r = holding({ ...GRAB_DEFAULTS }, { persistent: { camAngle: Math.PI } });
|
|
372
|
+
// Frames of 5 ms: reports are 10 frames apart.
|
|
373
|
+
r.step(5, true);
|
|
374
|
+
const seq = r.mp.moveSeq;
|
|
375
|
+
let frames = 0;
|
|
376
|
+
while (r.throws().length === 0) {
|
|
377
|
+
r.step(5);
|
|
378
|
+
frames += 1;
|
|
379
|
+
}
|
|
380
|
+
assert.ok(r.mp.moveSeq > seq);
|
|
381
|
+
// The facing was taken the frame after the press; the throw waited for a report after it.
|
|
382
|
+
assert.ok(frames >= 2);
|
|
383
|
+
const ti = r.wire.findIndex((w) => w.send?.op === 'throw');
|
|
384
|
+
const lastReport = r.wire.slice(0, ti).findLastIndex((w) => w.facing !== undefined);
|
|
385
|
+
assert.ok(lastReport >= 0 && r.wire[lastReport].facing === 0);
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
test('with the key: no camera angle falls back to the facing', () => {
|
|
389
|
+
const r = holding({ ...GRAB_DEFAULTS }, { persistent: {} });
|
|
390
|
+
r.me.rotationY = 30;
|
|
391
|
+
for (let i = 0; i < 10; i += 1) {
|
|
392
|
+
r.step();
|
|
393
|
+
}
|
|
394
|
+
r.step(16, true);
|
|
395
|
+
assert.ok(Math.abs(r.scene.faceRequest - 30 * DEG) < 1e-12);
|
|
396
|
+
while (r.throws().length === 0) {
|
|
397
|
+
r.step();
|
|
398
|
+
}
|
|
399
|
+
const v = r.bodies.get('a').v;
|
|
400
|
+
assert.ok(Math.abs(v.x - Math.sin(30 * DEG) * 10) < 1e-9 && Math.abs(v.z - Math.cos(30 * DEG) * 10) < 1e-9);
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
test('with the key: the wait runs out -- no report counter, or a Player that never takes the facing -- and the throw still goes along f', () => {
|
|
404
|
+
for (const options of [{ moveSeq: false }, { player: 'none' }]) {
|
|
405
|
+
let pressAt;
|
|
406
|
+
// Half a turn: when the swing gets there, past the wait.
|
|
407
|
+
const r = holding({ ...GRAB_DEFAULTS }, options);
|
|
408
|
+
pressAt = clock;
|
|
409
|
+
r.step(16, true);
|
|
410
|
+
while (r.throws().length === 0) {
|
|
411
|
+
r.step(16);
|
|
412
|
+
}
|
|
413
|
+
const swingMs = ((Math.PI * 1.4) / 20) * 1000;
|
|
414
|
+
assert.ok(clock - pressAt >= swingMs && clock - pressAt <= swingMs + 40, String(clock - pressAt));
|
|
415
|
+
const v = r.bodies.get('a').v;
|
|
416
|
+
assert.ok(Math.abs(v.z + 10) < 1e-9 && Math.abs(v.x) < 1e-9);
|
|
417
|
+
assert.ok(Math.abs(r.actors.get('a').components.Transform.z + 1.4) < 1e-9);
|
|
418
|
+
// Camera aligned with the facing (no swing), no report counter: the
|
|
419
|
+
// throw goes at AIM_WAIT_MS. (A Player that never takes a request faces
|
|
420
|
+
// f already here, and lets go at the next report.)
|
|
421
|
+
if (options.moveSeq !== false) {
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
const aligned = holding({ ...GRAB_DEFAULTS }, { ...options, persistent: { camAngle: Math.PI } });
|
|
425
|
+
pressAt = clock;
|
|
426
|
+
aligned.step(16, true);
|
|
427
|
+
while (aligned.throws().length === 0) {
|
|
428
|
+
aligned.step(16);
|
|
429
|
+
}
|
|
430
|
+
// (Measured from before the press frame, 16 ms before the press.)
|
|
431
|
+
assert.ok(clock - pressAt >= AIM_WAIT_MS + 16 && clock - pressAt <= AIM_WAIT_MS + 32, String(clock - pressAt));
|
|
432
|
+
assert.ok(Math.abs(aligned.bodies.get('a').v.z - 10) < 1e-9);
|
|
433
|
+
}
|
|
434
|
+
// The longest hold (3 m), half a turn: under the give-up.
|
|
435
|
+
const far = holding({ ...GRAB_DEFAULTS, holdDistance: 3 });
|
|
436
|
+
const pressAt = clock;
|
|
437
|
+
far.step(16, true);
|
|
438
|
+
while (far.throws().length === 0) {
|
|
439
|
+
far.step(16);
|
|
440
|
+
}
|
|
441
|
+
assert.ok(clock - pressAt < AIM_GIVE_UP_MS, String(clock - pressAt));
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
test('with the key: a player who outruns the carry still throws, at AIM_GIVE_UP_MS', () => {
|
|
445
|
+
const r = holding();
|
|
446
|
+
const pressAt = clock;
|
|
447
|
+
r.step(16, true);
|
|
448
|
+
while (r.throws().length === 0) {
|
|
449
|
+
r.me.x += 0.8; // 50 m/s: the carry (20 m/s) never catches up
|
|
450
|
+
r.step(16);
|
|
451
|
+
assert.ok(clock - pressAt <= AIM_GIVE_UP_MS + 32);
|
|
452
|
+
}
|
|
453
|
+
assert.ok(clock - pressAt >= AIM_GIVE_UP_MS + 16);
|
|
454
|
+
const v = r.bodies.get('a').v;
|
|
455
|
+
assert.ok(Math.abs(v.z + 10) < 1e-9 && Math.abs(v.x) < 1e-9);
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
test('with the key: a second press while it waits throws nothing more', () => {
|
|
459
|
+
const r = holding();
|
|
460
|
+
r.step(16, true);
|
|
461
|
+
r.step(16, true);
|
|
462
|
+
r.step(16, true);
|
|
463
|
+
while (r.throws().length === 0) {
|
|
464
|
+
r.step(16, true);
|
|
465
|
+
}
|
|
466
|
+
// One throw, from the first press, along it; the presses that came while
|
|
467
|
+
// it waited grabbed nothing and threw nothing, and nothing is offered for
|
|
468
|
+
// REGRAB_MS after it (the object, which this fake does not fly, is still
|
|
469
|
+
// in reach).
|
|
470
|
+
assert.equal(r.throws().length, 1);
|
|
471
|
+
assert.ok(Math.abs(r.bodies.get('a').v.z + 10) < 1e-9);
|
|
472
|
+
for (let i = 0; i < 20; i += 1) {
|
|
473
|
+
assert.equal(r.step(16, i % 2 === 0), null);
|
|
474
|
+
}
|
|
475
|
+
assert.equal(r.throws().length, 1);
|
|
476
|
+
assert.equal(r.wire.filter((w) => w.send?.op === 'grab').length, 1);
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
test('with the key: a hold ended while the throw waits sends no throw', () => {
|
|
480
|
+
const cases = {
|
|
481
|
+
drop: (r) => hub.grabEvents.push({ k: 'hub-drop', actor: 'a' }),
|
|
482
|
+
deny: (r) => hub.grabEvents.push({ k: 'hub-grab-deny', actor: 'a' }),
|
|
483
|
+
handedOn: (r) => r.mine.delete('a'),
|
|
484
|
+
hidden: () => hub.hidden.add('a'),
|
|
485
|
+
removed: (r) => r.actors.delete('a'),
|
|
486
|
+
newSession: (r) => (r.mp.net = { ...r.mp.net }),
|
|
487
|
+
load: (r) => (r.rig.local = { components: { Transform: { ...r.me } } }),
|
|
488
|
+
};
|
|
489
|
+
for (const [name, end] of Object.entries(cases)) {
|
|
490
|
+
const r = holding();
|
|
491
|
+
r.step(16, true);
|
|
492
|
+
r.step(16);
|
|
493
|
+
end(r);
|
|
494
|
+
r.step(16);
|
|
495
|
+
assert.equal(r.g.holding(), null, name);
|
|
496
|
+
for (let i = 0; i < 40; i += 1) {
|
|
497
|
+
r.step(16);
|
|
498
|
+
}
|
|
499
|
+
assert.equal(r.throws().length, 0, name);
|
|
500
|
+
}
|
|
501
|
+
// A player who cannot act (a trip, the talk panel) for a frame.
|
|
502
|
+
const r = holding();
|
|
503
|
+
r.step(16, true);
|
|
504
|
+
r.step(16, false, false);
|
|
505
|
+
assert.equal(r.g.holding(), null);
|
|
506
|
+
for (let i = 0; i < 40; i += 1) {
|
|
507
|
+
r.step(16);
|
|
508
|
+
}
|
|
509
|
+
assert.equal(r.throws().length, 0);
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
test('with the key, keepHeld (v1.25): the hold is still told while the throw waits', () => {
|
|
513
|
+
const r = holding({ ...GRAB_DEFAULTS, keepHeld: true }, { moveSeq: false });
|
|
514
|
+
const holds = () => r.wire.filter((w) => w.send?.op === 'hold').length;
|
|
515
|
+
// Hold until a word is just due, then press.
|
|
516
|
+
while (holds() === 0) {
|
|
517
|
+
r.step(16);
|
|
518
|
+
}
|
|
519
|
+
for (let t = 0; t < KEEP_TELL_MS - 40; t += 16) {
|
|
520
|
+
r.step(16);
|
|
521
|
+
}
|
|
522
|
+
const before = holds();
|
|
523
|
+
r.step(16, true);
|
|
524
|
+
while (r.throws().length === 0) {
|
|
525
|
+
r.step(16);
|
|
526
|
+
}
|
|
527
|
+
assert.equal(holds(), before + 1);
|
|
528
|
+
const ti = r.wire.findIndex((w) => w.send?.op === 'throw');
|
|
529
|
+
assert.ok(r.wire.findLastIndex((w) => w.send?.op === 'hold') < ti);
|
|
530
|
+
for (let i = 0; i < 100; i += 1) {
|
|
531
|
+
r.step(33);
|
|
532
|
+
}
|
|
533
|
+
assert.equal(holds(), before + 1);
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
// ---- The swing against multiplayer-3d's real move bound ---------------------
|
|
537
|
+
//
|
|
538
|
+
// multiplayer-3d's own `setObjectPoses` and `acks` (code/server/ownership.js),
|
|
539
|
+
// on a stand-in for its kinematic body (a target set now is where the body is
|
|
540
|
+
// after the next physics step) and its session (30 Hz ticks of two 60 Hz
|
|
541
|
+
// steps; the reports a tick has received are applied before its steps, and
|
|
542
|
+
// its broadcast after them carries the acknowledgements and handovers). The
|
|
543
|
+
// network between holds reports back and hands them over in bunches -- two,
|
|
544
|
+
// three, a stall's worth, to one tick -- and the client's frames are uneven.
|
|
545
|
+
// Every report, the throw included, goes on the one ordered uplink.
|
|
546
|
+
|
|
547
|
+
const kits = new URL('../../', import.meta.url);
|
|
548
|
+
register(
|
|
549
|
+
`data:text/javascript,${encodeURIComponent(`
|
|
550
|
+
const kits = ${JSON.stringify(kits.href)};
|
|
551
|
+
const rapier = 'export default { RigidBodyType: { Dynamic: 0, Fixed: 1, KinematicPositionBased: 2 } };';
|
|
552
|
+
export async function resolve(specifier, context, next) {
|
|
553
|
+
const isRapier = specifier === '@dimforge/rapier3d-compat' ||
|
|
554
|
+
((specifier.startsWith('.') || specifier.startsWith('file:')) &&
|
|
555
|
+
new URL(specifier, context.parentURL).href.endsWith('/kits/physics-3d/engine3d/rapier.js'));
|
|
556
|
+
if (isRapier) {
|
|
557
|
+
return { url: 'data:text/javascript,' + encodeURIComponent(rapier), shortCircuit: true };
|
|
558
|
+
}
|
|
559
|
+
if (specifier.startsWith('@imports/castle.')) {
|
|
560
|
+
return { url: kits + specifier.slice('@imports/castle.'.length), shortCircuit: true };
|
|
561
|
+
}
|
|
562
|
+
return next(specifier, context);
|
|
563
|
+
}
|
|
564
|
+
`)}`,
|
|
565
|
+
);
|
|
566
|
+
const Ownership = await import('../../multiplayer-3d/code/server/ownership.js');
|
|
567
|
+
const Limits = await import('../../multiplayer-3d/code/server/limits.js');
|
|
568
|
+
|
|
569
|
+
function kinematic(at) {
|
|
570
|
+
const body = {
|
|
571
|
+
at: { ...at },
|
|
572
|
+
next: null,
|
|
573
|
+
type: 2,
|
|
574
|
+
translation: () => ({ ...body.at }),
|
|
575
|
+
setNextKinematicTranslation: (p) => (body.next = { ...p }),
|
|
576
|
+
setNextKinematicRotation() {},
|
|
577
|
+
setBodyType: (type) => (body.type = type),
|
|
578
|
+
setTranslation: (p) => (body.at = { ...p }),
|
|
579
|
+
setRotation() {},
|
|
580
|
+
setLinvel() {},
|
|
581
|
+
setAngvel() {},
|
|
582
|
+
linvel: () => ({ x: 0, y: 0, z: 0 }),
|
|
583
|
+
angvel: () => ({ x: 0, y: 0, z: 0 }),
|
|
584
|
+
step() {
|
|
585
|
+
if (body.next) {
|
|
586
|
+
body.at = body.next;
|
|
587
|
+
body.next = null;
|
|
588
|
+
}
|
|
589
|
+
},
|
|
590
|
+
};
|
|
591
|
+
return body;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
const TICK_MS = 1000 / 30;
|
|
595
|
+
|
|
596
|
+
// A held object, a server that granted it, and the network between them.
|
|
597
|
+
// `deliver(tick)` says whether a tick hands the server what has reached it
|
|
598
|
+
// (otherwise it waits for a later one), from when `seen.bunching` is set
|
|
599
|
+
// (every tick until then); `upMs` and `downMs` are the one-way delays.
|
|
600
|
+
// `acks: false` leaves the acknowledgements off the multiplayer kit, as one
|
|
601
|
+
// from before them: the swing is the unbounded one it was.
|
|
602
|
+
function networked(
|
|
603
|
+
grab,
|
|
604
|
+
{ deliver = () => true, upMs = 30, downMs = 30, camAngle = 0, acks = true, steps = () => 2 } = {},
|
|
605
|
+
) {
|
|
606
|
+
const uplink = [];
|
|
607
|
+
const downlink = [];
|
|
608
|
+
const seen = { reports: 0, worst: 0, handovers: [], throws: [], bunches: [], bunching: false };
|
|
609
|
+
let sim = null;
|
|
610
|
+
// The client's physics (physics-3d's physics3d system), before the hub:
|
|
611
|
+
// fixed 60 Hz steps from an accumulator, at most four a frame (a frame that
|
|
612
|
+
// takes four drops the rest of its time). The held object moves on at the
|
|
613
|
+
// velocity the hub left it with, and falls.
|
|
614
|
+
let acc = 0;
|
|
615
|
+
const physics = (r, ms) => {
|
|
616
|
+
acc += ms / 1000;
|
|
617
|
+
let steps = 0;
|
|
618
|
+
while (acc >= 1 / 60 && steps < 4) {
|
|
619
|
+
const h = 1 / 60;
|
|
620
|
+
for (const [id, body] of r.bodies) {
|
|
621
|
+
const t = r.actors.get(id)?.components.Transform;
|
|
622
|
+
if (!t || !r.mine.has(id)) {
|
|
623
|
+
continue;
|
|
624
|
+
}
|
|
625
|
+
t.x += body.v.x * h;
|
|
626
|
+
t.y += body.v.y * h - 0.5 * 9.81 * h * h;
|
|
627
|
+
t.z += body.v.z * h;
|
|
628
|
+
body.v = { ...body.v, y: body.v.y - 9.81 * h };
|
|
629
|
+
}
|
|
630
|
+
acc -= h;
|
|
631
|
+
steps += 1;
|
|
632
|
+
}
|
|
633
|
+
if (steps === 4) {
|
|
634
|
+
acc = 0;
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
const onReport = (r) => {
|
|
638
|
+
const t = r.actors.get('a').components.Transform;
|
|
639
|
+
const v = r.bodies.get('a').v;
|
|
640
|
+
if (!r.mine.has('a')) {
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
const seq = r.mp.moveSeq + 1;
|
|
644
|
+
const ack = r.mp.acks?.get('a');
|
|
645
|
+
uplink.push({
|
|
646
|
+
at: clock + upMs,
|
|
647
|
+
pose: ['a', t.x, t.y, t.z, 0, 0, 0, 1, v.x, v.y, v.z, 0, 0, 0, 1, seq, ack ? ack[1] : 0],
|
|
648
|
+
});
|
|
649
|
+
};
|
|
650
|
+
const r = rig(grab, { a: at(1.2, 0) }, { cameraControl: 'orbit', persistent: { camAngle }, physics, onReport });
|
|
651
|
+
if (acks) {
|
|
652
|
+
r.mp.acks = new Map();
|
|
653
|
+
}
|
|
654
|
+
hub.lastT = 0;
|
|
655
|
+
r.mp.handed = new Map([['a', { epoch: 1 }]]);
|
|
656
|
+
// Every message the hub sends goes on the uplink after the reports before it.
|
|
657
|
+
const send = r.mp.net.send;
|
|
658
|
+
r.mp.net.send = (d) => {
|
|
659
|
+
send(d);
|
|
660
|
+
if (d.op === 'throw') {
|
|
661
|
+
seen.thrownFrom = { ...r.actors.get('a').components.Transform };
|
|
662
|
+
seen.thrownAt = clock;
|
|
663
|
+
}
|
|
664
|
+
uplink.push({ at: clock + upMs, message: d });
|
|
665
|
+
};
|
|
666
|
+
const start = r.actors.get('a').components.Transform;
|
|
667
|
+
sim = {
|
|
668
|
+
timeMs: 0,
|
|
669
|
+
players: new Map([['me', {}]]),
|
|
670
|
+
objects: new Map([
|
|
671
|
+
['a', { owner: 'me', epoch: 1, claimable: true, body: kinematic(start), reportedAt: 0, claimedAt: 0 }],
|
|
672
|
+
]),
|
|
673
|
+
};
|
|
674
|
+
let tick = 0;
|
|
675
|
+
let nextTick = clock + TICK_MS;
|
|
676
|
+
const server = () => {
|
|
677
|
+
while (nextTick <= clock) {
|
|
678
|
+
tick += 1;
|
|
679
|
+
const handovers = [];
|
|
680
|
+
if (!seen.bunching || deliver(tick)) {
|
|
681
|
+
let bunch = 0;
|
|
682
|
+
while (uplink.length && uplink[0].at <= nextTick) {
|
|
683
|
+
const m = uplink.shift();
|
|
684
|
+
const entry = sim.objects.get('a');
|
|
685
|
+
if (m.pose && seen.throws.length > 0) {
|
|
686
|
+
// After the throw: the object's flight, which the server may take
|
|
687
|
+
// over (with its velocity) as it likes. Not followed here.
|
|
688
|
+
} else if (m.pose && entry.owner !== 'me') {
|
|
689
|
+
// Handed back to the server: the hold is over, and the reports
|
|
690
|
+
// still on the way are from a grant that has ended.
|
|
691
|
+
} else if (m.pose) {
|
|
692
|
+
const at = entry.body.translation();
|
|
693
|
+
const elapsed = Math.max(0, sim.timeMs - entry.reportedAt) / 1000;
|
|
694
|
+
const d = Math.hypot(m.pose[1] - at.x, m.pose[2] - at.y, m.pose[3] - at.z);
|
|
695
|
+
seen.worst = Math.max(seen.worst, d - Limits.MAX_OBJECT_SPEED * elapsed);
|
|
696
|
+
seen.reports += 1;
|
|
697
|
+
bunch += 1;
|
|
698
|
+
Ownership.setObjectPoses(sim, 'me', [m.pose], handovers);
|
|
699
|
+
} else if (m.message.op === 'throw') {
|
|
700
|
+
// What the hub server checks of a throw before it lets it fly
|
|
701
|
+
// (code/server/grab.js): the object is still this player's.
|
|
702
|
+
seen.throws.push({ owned: entry.owner === 'me', at: entry.body.translation() });
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
if (seen.bunching) {
|
|
706
|
+
seen.bunches.push(bunch);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
// Physics steps: two a tick, unless `steps(tick)` says otherwise (a
|
|
710
|
+
// tick that ran no step still acknowledges what it applied).
|
|
711
|
+
for (let i = 0, k = seen.bunching ? steps(tick) : 2; i < k; i += 1) {
|
|
712
|
+
sim.objects.get('a').body.step();
|
|
713
|
+
sim.timeMs += 1000 / 60;
|
|
714
|
+
}
|
|
715
|
+
seen.handovers.push(...handovers);
|
|
716
|
+
const acks = Ownership.acks(sim);
|
|
717
|
+
if (acks.length || handovers.length) {
|
|
718
|
+
downlink.push({ at: nextTick + downMs, acks, handovers, t: sim.timeMs });
|
|
719
|
+
}
|
|
720
|
+
nextTick += TICK_MS;
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
const client = () => {
|
|
724
|
+
while (downlink.length && downlink[0].at <= clock) {
|
|
725
|
+
const m = downlink.shift();
|
|
726
|
+
// The broadcast's simulation time, as the hub's state hook keeps it.
|
|
727
|
+
hub.lastT = m.t;
|
|
728
|
+
for (const [id, ...ack] of m.acks) {
|
|
729
|
+
r.mp.acks?.set(id, ack);
|
|
730
|
+
}
|
|
731
|
+
for (const [id, owner] of m.handovers) {
|
|
732
|
+
if (owner !== 'me') {
|
|
733
|
+
r.mine.delete(id);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
const step = r.step;
|
|
739
|
+
r.step = (ms = 16, pressed = false, idle = true) => {
|
|
740
|
+
// Up to the moment this frame starts: the server's ticks, then what has
|
|
741
|
+
// reached the client.
|
|
742
|
+
const was = clock;
|
|
743
|
+
clock += ms;
|
|
744
|
+
server();
|
|
745
|
+
client();
|
|
746
|
+
clock = was;
|
|
747
|
+
return step(ms, pressed, idle);
|
|
748
|
+
};
|
|
749
|
+
return { r, seen, sim, tick: () => tick };
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
// Grab, carry to the hold point, and press Throw with the camera looking
|
|
753
|
+
// behind the character; frames from `frames(i)` ms. Returns when the throw
|
|
754
|
+
// has reached the server, or the hold is gone.
|
|
755
|
+
function throwBehind(grab, network, frames) {
|
|
756
|
+
const { r, seen, sim } = networked(grab, network);
|
|
757
|
+
r.step();
|
|
758
|
+
assert.equal(r.step(16, true), 'Throw');
|
|
759
|
+
for (let i = 0; i < 40; i += 1) {
|
|
760
|
+
r.step();
|
|
761
|
+
}
|
|
762
|
+
assert.equal(seen.handovers.length, 0, 'the carry itself is inside the bound');
|
|
763
|
+
// The bunches start with the press. (A pickup's ease-in at the carry speed,
|
|
764
|
+
// the same with or without the key, is no more bunch-proof than it was.)
|
|
765
|
+
seen.bunching = true;
|
|
766
|
+
const pressAt = clock;
|
|
767
|
+
r.step(16, true);
|
|
768
|
+
let i = 0;
|
|
769
|
+
while (seen.throws.length === 0 && r.mine.has('a') && i < 1000) {
|
|
770
|
+
r.step(frames(i));
|
|
771
|
+
i += 1;
|
|
772
|
+
}
|
|
773
|
+
// How long after the press the client let go.
|
|
774
|
+
return { r, seen, sim, ms: seen.thrownAt - pressAt };
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
const lumpy = (i) => (i % 17 === 5 ? 120 : i % 5 === 2 ? 33 : 16);
|
|
778
|
+
|
|
779
|
+
for (const [name, network] of Object.entries({
|
|
780
|
+
'two reports to a tick': { deliver: (tick) => tick % 3 === 0 },
|
|
781
|
+
'three reports to a tick': { deliver: (tick) => tick % 5 === 0 },
|
|
782
|
+
'a stall, then a bunch': { deliver: (tick) => tick % 12 === 0 || tick % 12 > 8, upMs: 60, downMs: 60 },
|
|
783
|
+
'a long stall': { deliver: (tick) => tick % 40 === 0 },
|
|
784
|
+
})) {
|
|
785
|
+
for (const grab of [
|
|
786
|
+
{ ...GRAB_DEFAULTS },
|
|
787
|
+
{ ...GRAB_DEFAULTS, holdDistance: 3 },
|
|
788
|
+
{ ...GRAB_DEFAULTS, holdDistance: 0.9, throwSpeed: 14, keepHeld: true, steady: true },
|
|
789
|
+
]) {
|
|
790
|
+
test(`with the key, ${name} (hold ${grab.holdDistance} m): the swing keeps inside multiplayer-3d's move bound and the throw reaches the server`, () => {
|
|
791
|
+
const { r, seen, ms } = throwBehind(grab, network, lumpy);
|
|
792
|
+
// Bunches came: some tick was handed two reports or more at once.
|
|
793
|
+
assert.ok(Math.max(...seen.bunches) >= 2, JSON.stringify(seen.bunches));
|
|
794
|
+
// Never past the 0.6 m a zero-time report gets, from the server's body.
|
|
795
|
+
assert.ok(seen.worst <= Limits.MOVE_SLACK, String(seen.worst));
|
|
796
|
+
// No handover before the throw (after it, the server may take the
|
|
797
|
+
// flight over as it likes).
|
|
798
|
+
assert.deepEqual(seen.handovers, []);
|
|
799
|
+
// Thrown once, while the server still had it the player's.
|
|
800
|
+
assert.equal(r.throws().length, 1);
|
|
801
|
+
assert.equal(seen.throws.length, 1);
|
|
802
|
+
assert.equal(seen.throws[0].owned, true);
|
|
803
|
+
assert.ok(ms <= AIM_GIVE_UP_MS + 200, String(ms));
|
|
804
|
+
// Along f = PI (behind), at the place's throw speed.
|
|
805
|
+
const v = r.bodies.get('a').v;
|
|
806
|
+
assert.ok(Math.abs(v.x) < 1e-9 && Math.abs(v.z + grab.throwSpeed) < 1e-9, JSON.stringify(v));
|
|
807
|
+
const holdD = Math.max(grab.holdDistance, 0.35 + 0.3 + 0.15);
|
|
808
|
+
if (ms < AIM_GIVE_UP_MS) {
|
|
809
|
+
// From the hold point behind: the swing got there before the give-up.
|
|
810
|
+
assert.ok(flat(seen.thrownFrom, { x: 0, z: -holdD }) < 1e-6, JSON.stringify(seen.thrownFrom));
|
|
811
|
+
// The server's body, a report or two behind, within its throw reach.
|
|
812
|
+
assert.ok(flat(seen.throws[0].at, r.me) < THROW_REACH);
|
|
813
|
+
} else {
|
|
814
|
+
// The server heard too little of the swing in time: let go at the
|
|
815
|
+
// give-up, from where it had got to, still the player's.
|
|
816
|
+
assert.ok(name !== 'two reports to a tick' || grab.holdDistance > 1.4, String(ms));
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
test('with the key, three reports to a tick, a multiplayer kit without acknowledgements: the unbounded swing loses the object and the throw (what the bound is for)', () => {
|
|
823
|
+
const { r, seen } = throwBehind({ ...GRAB_DEFAULTS }, { deliver: (tick) => tick % 5 === 0, acks: false }, lumpy);
|
|
824
|
+
assert.ok(seen.handovers.length > 0);
|
|
825
|
+
assert.ok(seen.worst > Limits.MOVE_SLACK, String(seen.worst));
|
|
826
|
+
assert.equal(r.g.holding(), null);
|
|
827
|
+
assert.equal(seen.throws.length, 0);
|
|
828
|
+
assert.equal(r.throws().length, 0);
|
|
829
|
+
});
|
|
830
|
+
|
|
831
|
+
test('with the key, an ordinary connection: half a turn at the default hold takes about a second, at most AIM_SLACK_M from where the server\'s body may be', () => {
|
|
832
|
+
const { r, seen, ms } = throwBehind({ ...GRAB_DEFAULTS }, {}, () => 16);
|
|
833
|
+
assert.deepEqual(seen.handovers, []);
|
|
834
|
+
assert.equal(seen.throws.length, 1);
|
|
835
|
+
assert.equal(seen.throws[0].owned, true);
|
|
836
|
+
assert.ok(seen.worst <= AIM_SLACK_M + 0.05, String(seen.worst));
|
|
837
|
+
// Slower than the carry speed's 220 ms (the server's acknowledgements set
|
|
838
|
+
// the pace), well inside the give-up.
|
|
839
|
+
assert.ok(ms > 400 && ms < 1500, String(ms));
|
|
840
|
+
assert.ok(flat(seen.thrownFrom, { x: 0, z: -1.4 }) < 1e-6, JSON.stringify(seen.thrownFrom));
|
|
841
|
+
});
|
|
842
|
+
|
|
843
|
+
// Codex review 2, finding 1: carry movement the server has not acknowledged
|
|
844
|
+
// yet, from before the press, counts against the swing. The player steps
|
|
845
|
+
// 0.3 m aside just before pressing; the carry follows in reports the server
|
|
846
|
+
// has not acknowledged, and the swing may not then add a fresh 0.5 m to them.
|
|
847
|
+
test('with the key, three reports to a tick: carry movement not yet acknowledged when Throw is pressed counts against the swing', () => {
|
|
848
|
+
const { r, seen } = networked({ ...GRAB_DEFAULTS }, { deliver: (tick) => tick % 5 === 0 });
|
|
849
|
+
r.step();
|
|
850
|
+
assert.equal(r.step(16, true), 'Throw');
|
|
851
|
+
for (let i = 0; i < 40; i += 1) {
|
|
852
|
+
r.step();
|
|
853
|
+
}
|
|
854
|
+
assert.equal(seen.handovers.length, 0);
|
|
855
|
+
seen.bunching = true;
|
|
856
|
+
for (let i = 0; i < 6; i += 1) {
|
|
857
|
+
r.me.x -= 0.05;
|
|
858
|
+
r.step();
|
|
859
|
+
}
|
|
860
|
+
r.step(16, true);
|
|
861
|
+
let i = 0;
|
|
862
|
+
while (seen.throws.length === 0 && r.mine.has('a') && i < 1000) {
|
|
863
|
+
r.step();
|
|
864
|
+
i += 1;
|
|
865
|
+
}
|
|
866
|
+
assert.ok(seen.worst <= Limits.MOVE_SLACK, String(seen.worst));
|
|
867
|
+
assert.deepEqual(seen.handovers, []);
|
|
868
|
+
assert.equal(seen.throws.length, 1);
|
|
869
|
+
assert.equal(seen.throws[0].owned, true);
|
|
870
|
+
});
|
|
871
|
+
|
|
872
|
+
// Codex review 2, finding 2: an acknowledgement is not a body moved. A tick
|
|
873
|
+
// that applies and acknowledges reports but runs no physics step leaves the
|
|
874
|
+
// server's body where it was; the next report is measured from there with no
|
|
875
|
+
// time allowed. One such tick anywhere in the swing -- or two or three back to
|
|
876
|
+
// back -- on a link with no delay and 5 ms frames (reports ten frames apart),
|
|
877
|
+
// loses nothing.
|
|
878
|
+
for (const run of [1, 2, 3]) {
|
|
879
|
+
test(`with the key, ${run} tick(s) in a row that run no physics step: the swing does not take an acknowledgement as the body moved`, () => {
|
|
880
|
+
let swung = 0;
|
|
881
|
+
for (let skip = 1; skip <= 20; skip += 1) {
|
|
882
|
+
let first = null;
|
|
883
|
+
const { r, seen, tick } = networked(
|
|
884
|
+
{ ...GRAB_DEFAULTS },
|
|
885
|
+
{
|
|
886
|
+
upMs: 0,
|
|
887
|
+
downMs: 0,
|
|
888
|
+
steps: (k) => {
|
|
889
|
+
first ??= k;
|
|
890
|
+
return k >= first + skip && k < first + skip + run ? 0 : 2;
|
|
891
|
+
},
|
|
892
|
+
},
|
|
893
|
+
);
|
|
894
|
+
r.step(5);
|
|
895
|
+
assert.equal(r.step(5, true), 'Throw');
|
|
896
|
+
for (let i = 0; i < 150; i += 1) {
|
|
897
|
+
r.step(5);
|
|
898
|
+
}
|
|
899
|
+
assert.equal(seen.handovers.length, 0);
|
|
900
|
+
seen.bunching = true;
|
|
901
|
+
r.step(5, true);
|
|
902
|
+
let i = 0;
|
|
903
|
+
while (seen.throws.length === 0 && r.mine.has('a') && i < 2000) {
|
|
904
|
+
r.step(5);
|
|
905
|
+
i += 1;
|
|
906
|
+
}
|
|
907
|
+
assert.ok(seen.worst <= Limits.MOVE_SLACK, `stepless from tick ${skip}: ${seen.worst}`);
|
|
908
|
+
assert.deepEqual(seen.handovers, [], `stepless from tick ${skip}`);
|
|
909
|
+
assert.equal(seen.throws.length, 1, `stepless from tick ${skip}`);
|
|
910
|
+
assert.equal(seen.throws[0].owned, true);
|
|
911
|
+
assert.ok(flat(seen.thrownFrom, { x: 0, z: -1.4 }) < 1e-6, JSON.stringify(seen.thrownFrom));
|
|
912
|
+
if (tick() > first + skip) {
|
|
913
|
+
swung += 1;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
// The swing on this link takes about a dozen ticks: most runs put the
|
|
917
|
+
// stepless ticks inside it.
|
|
918
|
+
assert.ok(swung >= 10, String(swung));
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
// Codex review 3: the trail holds each report's position as it went out --
|
|
923
|
+
// the body where the hub left it, read by the multiplayer kit straight after
|
|
924
|
+
// -- not the body a frame later, which the client's physics (before the hub)
|
|
925
|
+
// has moved on at the carry's velocity. The player steps 0.15 m aside over
|
|
926
|
+
// one 80 ms frame (four physics steps, the cap) and presses Throw on the next
|
|
927
|
+
// 80 ms frame: the carry report says one place, the body read back a frame
|
|
928
|
+
// later says another 0.125 m on, and a swing bounded by the second (turning
|
|
929
|
+
// the way the player stepped, -x) puts a report 0.620646 m from the server's
|
|
930
|
+
// body with no time allowed -- the object taken away, no throw.
|
|
931
|
+
test('with the key, three reports to a tick: the swing is bounded by where each report put the object, not where the client\'s physics moved it after', () => {
|
|
932
|
+
for (const [grab, dx] of [
|
|
933
|
+
[{ ...GRAB_DEFAULTS }, -0.15],
|
|
934
|
+
[{ ...GRAB_DEFAULTS }, -0.2],
|
|
935
|
+
[{ ...GRAB_DEFAULTS }, 0.15],
|
|
936
|
+
[{ ...GRAB_DEFAULTS, holdDistance: 0.9 }, -0.15],
|
|
937
|
+
]) {
|
|
938
|
+
const { r, seen } = networked(grab, { deliver: (tick) => tick % 5 === 0 });
|
|
939
|
+
r.step();
|
|
940
|
+
assert.equal(r.step(16, true), 'Throw');
|
|
941
|
+
for (let i = 0; i < 40; i += 1) {
|
|
942
|
+
r.step();
|
|
943
|
+
}
|
|
944
|
+
assert.equal(seen.handovers.length, 0);
|
|
945
|
+
seen.bunching = true;
|
|
946
|
+
r.me.x += dx;
|
|
947
|
+
r.step(80);
|
|
948
|
+
r.step(80, true);
|
|
949
|
+
let i = 0;
|
|
950
|
+
while (seen.throws.length === 0 && r.mine.has('a') && i < 1000) {
|
|
951
|
+
r.step();
|
|
952
|
+
i += 1;
|
|
953
|
+
}
|
|
954
|
+
assert.ok(seen.worst <= Limits.MOVE_SLACK, `hold ${grab.holdDistance}, step ${dx}: ${seen.worst}`);
|
|
955
|
+
assert.deepEqual(seen.handovers, []);
|
|
956
|
+
assert.equal(seen.throws.length, 1);
|
|
957
|
+
assert.equal(seen.throws[0].owned, true);
|
|
958
|
+
}
|
|
959
|
+
});
|
|
960
|
+
|
|
961
|
+
console.log(`test-grab-orbit: ${n} passed`);
|