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,924 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { fpsTelemetryFor } from '../code/client/fpsTelemetry.js';
|
|
4
|
+
import { register } from 'node:module';
|
|
5
|
+
import { makeTiers, middleGpu, weakestGpu } from '../code/client/tiers.js';
|
|
6
|
+
import { goalAt } from '../code/client/labelsNear.js';
|
|
7
|
+
import { goalPointers, goalText, pointerAt } from '../code/client/together.js';
|
|
8
|
+
import { PerspectiveCamera } from 'three';
|
|
9
|
+
import { doorPoint } from '../code/client/doorFrame.js';
|
|
10
|
+
import { makeIdle, SIT_OFFER_M } from '../code/client/idle.js';
|
|
11
|
+
import { deck, hub, clear as clearHub } from '../code/client/state.js';
|
|
12
|
+
import { allActors, filterQualityScene, makeQualityVisit, qualityPlayers, samePad, talkActors } from '../code/client/quality.js';
|
|
13
|
+
|
|
14
|
+
const stubs = {
|
|
15
|
+
'castle-web-sdk': `export const resolveDeckFile = (name) => String(name).replace(/^\\.\\//, '');
|
|
16
|
+
export const deckPrefixOf = () => ''; export const IMPORTS_DIR = 'imports'; export const IMPORTS_PREFIX = 'imports/';`,
|
|
17
|
+
'./files': `export const initialFiles = {}; export const parseJsonFile = (path, text) => ({ value: JSON.parse(text) });
|
|
18
|
+
export const formatJson = (value) => JSON.stringify(value);`,
|
|
19
|
+
'./systemRegistry': `export const systemInstallers = [];`,
|
|
20
|
+
'./fonts': `export const deckFontFamily = 'sans-serif';`,
|
|
21
|
+
};
|
|
22
|
+
register(
|
|
23
|
+
'data:text/javascript,' +
|
|
24
|
+
encodeURIComponent(`
|
|
25
|
+
import { existsSync } from 'node:fs';
|
|
26
|
+
import { fileURLToPath } from 'node:url';
|
|
27
|
+
const stubs = ${JSON.stringify(stubs)};
|
|
28
|
+
export async function resolve(specifier, context, next) {
|
|
29
|
+
const parent = context.parentURL ?? '';
|
|
30
|
+
if (parent.includes('/physics-2d/engine/') && stubs[specifier]) {
|
|
31
|
+
return { url: 'data:text/javascript,' + encodeURIComponent(stubs[specifier]), shortCircuit: true };
|
|
32
|
+
}
|
|
33
|
+
if (specifier.startsWith('@imports/castle.physics-3d/')) { specifier = parent.replace(/\\/kits\\/.*/, '/kits/physics-3d/') + specifier.slice(27); }
|
|
34
|
+
if (specifier.startsWith('@imports/castle.physics-2d/')) {
|
|
35
|
+
specifier = parent.replace(/\\/kits\\/.*/, '/kits/physics-2d/') + specifier.slice(27);
|
|
36
|
+
}
|
|
37
|
+
if ((specifier.startsWith('.') || specifier.startsWith('file:')) && parent.includes('/kits/') && !/\\.(m?js|jsx|json)$/.test(specifier)) {
|
|
38
|
+
const base = new URL(specifier, parent).href;
|
|
39
|
+
if (existsSync(fileURLToPath(base + '.js'))) return next(base + '.js', context);
|
|
40
|
+
}
|
|
41
|
+
return next(specifier, context);
|
|
42
|
+
}
|
|
43
|
+
`),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const { SceneRuntime } = await import('../../physics-2d/engine/scene.js');
|
|
47
|
+
const { makeWeakestTier, readDistricts } = await import('../code/client/weakestTier.js');
|
|
48
|
+
|
|
49
|
+
const spec = {
|
|
50
|
+
version: 1,
|
|
51
|
+
districts: [
|
|
52
|
+
{
|
|
53
|
+
id: 'left',
|
|
54
|
+
outline: [
|
|
55
|
+
[-20, -20],
|
|
56
|
+
[0, -20],
|
|
57
|
+
[0, 20],
|
|
58
|
+
[-20, 20],
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: 'right',
|
|
63
|
+
outline: [
|
|
64
|
+
[0, -20],
|
|
65
|
+
[20, -20],
|
|
66
|
+
[20, 20],
|
|
67
|
+
[0, 20],
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
actors: [
|
|
72
|
+
{ id: 'left-wall', districts: ['left'], origin: [-14, 0], bounds: [-15, -1, -14, 1] },
|
|
73
|
+
{ id: 'right-wall', districts: ['right'], origin: [14, 0], bounds: [14, -1, 15, 1] },
|
|
74
|
+
{ id: 'door', districts: ['right'], origin: [14, 0], bounds: [14, -1, 15, 1] },
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
const inert = (id, x) => ({
|
|
78
|
+
id,
|
|
79
|
+
static: true,
|
|
80
|
+
components: { Transform: { x, y: 0, z: 0 }, Shape: { solid: true } },
|
|
81
|
+
runtime: { sentinel: {} },
|
|
82
|
+
});
|
|
83
|
+
function fixture() {
|
|
84
|
+
const player = { id: 'self', components: { Player: {}, Transform: { x: -10, z: 0 } } };
|
|
85
|
+
const left = inert('left-wall', -14),
|
|
86
|
+
right = inert('right-wall', 14);
|
|
87
|
+
const door = {
|
|
88
|
+
...inert('door', 14),
|
|
89
|
+
components: { ...inert('door', 14).components, HubDoor: {} },
|
|
90
|
+
};
|
|
91
|
+
const data = { weakestDistricts: spec, actors: [player, left, right, door] };
|
|
92
|
+
const files = {
|
|
93
|
+
'models/m.pxmodel': JSON.stringify({
|
|
94
|
+
parts: [{ id: 'a', look: { ao: 1, outline: 1 } }],
|
|
95
|
+
look: { rim: 0.2 },
|
|
96
|
+
}),
|
|
97
|
+
};
|
|
98
|
+
const scene = new SceneRuntime(data, [], {}, files);
|
|
99
|
+
return {
|
|
100
|
+
scene,
|
|
101
|
+
player: scene.getActor('self'),
|
|
102
|
+
left: scene.getActor('left-wall'),
|
|
103
|
+
right: scene.getActor('right-wall'),
|
|
104
|
+
files,
|
|
105
|
+
data: scene.data,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
for (const value of [
|
|
109
|
+
null,
|
|
110
|
+
{},
|
|
111
|
+
{ ...spec, districts: [null] },
|
|
112
|
+
{ ...spec, actors: [{ ...spec.actors[0], districts: ['missing'] }] },
|
|
113
|
+
{ ...spec, actors: [spec.actors[0], spec.actors[0]] },
|
|
114
|
+
]) {
|
|
115
|
+
assert.equal(readDistricts(value), null);
|
|
116
|
+
}
|
|
117
|
+
assert.ok(readDistricts(spec));
|
|
118
|
+
for (const gpu of ['Mali-G52 MC1', 'ANGLE (ARM, Mali-G52 MC2, OpenGL ES 3.2)', 'mali-g52 mc2']) {
|
|
119
|
+
assert.ok(middleGpu(gpu), gpu);
|
|
120
|
+
}
|
|
121
|
+
for (const gpu of ['Mali-G52 MC3', 'Mali-G52 MC12', 'Mali-G51', 'PowerVR GE8320', 'Adreno 506', null, undefined, 42]) {
|
|
122
|
+
assert.ok(!middleGpu(gpu), String(gpu));
|
|
123
|
+
}
|
|
124
|
+
// The runtime-only model variant restores the inherited scene setting, while
|
|
125
|
+
// an existing or replacement own setting remains its owner's.
|
|
126
|
+
for (const initial of [undefined, false, true]) {
|
|
127
|
+
const h = fixture(),
|
|
128
|
+
controller = makeWeakestTier();
|
|
129
|
+
if (initial !== undefined) {
|
|
130
|
+
Object.defineProperty(h.scene, 'dropsEmptyParts', { value: initial, configurable: true });
|
|
131
|
+
}
|
|
132
|
+
controller.frame(h.scene, true, 0);
|
|
133
|
+
assert.equal(h.scene.dropsEmptyParts, initial ?? true);
|
|
134
|
+
controller.restore();
|
|
135
|
+
assert.equal(h.scene.dropsEmptyParts, initial ?? false);
|
|
136
|
+
assert.equal(Object.hasOwn(h.scene, 'dropsEmptyParts'), initial !== undefined);
|
|
137
|
+
controller.frame(h.scene, true, 1);
|
|
138
|
+
Object.defineProperty(h.scene, 'dropsEmptyParts', { value: false, configurable: true });
|
|
139
|
+
controller.restore();
|
|
140
|
+
assert.equal(h.scene.dropsEmptyParts, false);
|
|
141
|
+
assert.equal(Object.hasOwn(h.scene, 'dropsEmptyParts'), true);
|
|
142
|
+
}
|
|
143
|
+
assert.ok(weakestGpu('ANGLE (PowerVR, PowerVR Rogue GE8320, OpenGL ES 3.2)'));
|
|
144
|
+
for (const gpu of [
|
|
145
|
+
'PowerVR SGX Doma',
|
|
146
|
+
'PowerVR SGX (Doma)',
|
|
147
|
+
'ANGLE (PowerVR, PowerVR SGX Doma, OpenGL ES 3.1)',
|
|
148
|
+
]) {
|
|
149
|
+
assert.ok(weakestGpu(gpu), gpu);
|
|
150
|
+
}
|
|
151
|
+
for (const gpu of [
|
|
152
|
+
'PowerVR SGX', 'PowerVR SGX 544MP', 'PowerVR SGX 545',
|
|
153
|
+
'PowerVR SGX DomaXT', 'PowerVR SGX Doma Plus',
|
|
154
|
+
'PowerVR Rogue GM9446', 'Mali-G52 MC2', null, undefined, 42,
|
|
155
|
+
]) {
|
|
156
|
+
assert.ok(!weakestGpu(gpu), String(gpu));
|
|
157
|
+
}
|
|
158
|
+
for (const [enabled, gpu, profile] of [
|
|
159
|
+
[false, 'PowerVR Rogue GE8320', 'low'],
|
|
160
|
+
[true, 'PowerVR Rogue GE8320', 'weakest'],
|
|
161
|
+
[true, 'PowerVR SGX Doma', 'weakest'],
|
|
162
|
+
[true, 'PowerVR SGX (Doma)', 'weakest'],
|
|
163
|
+
[false, 'PowerVR SGX Doma', 'high'],
|
|
164
|
+
[true, 'PowerVR SGX 544MP', 'high'],
|
|
165
|
+
[true, 'Mali-G52 MC2', 'middle'],
|
|
166
|
+
[false, 'Mali-G52 MC2', 'low'],
|
|
167
|
+
]) {
|
|
168
|
+
const tiers = makeTiers({
|
|
169
|
+
weakest: enabled,
|
|
170
|
+
storage: null,
|
|
171
|
+
deviceMemory: 4,
|
|
172
|
+
levers: { apply() {}, high() {} },
|
|
173
|
+
});
|
|
174
|
+
const renderer = { getContext: () => ({ getExtension: () => null, getParameter: () => gpu }) };
|
|
175
|
+
tiers.frame({ three: { renderer } }, true, 0);
|
|
176
|
+
assert.equal(tiers.handle.profile ?? tiers.current(), profile);
|
|
177
|
+
tiers.set('high');
|
|
178
|
+
assert.equal(tiers.handle.profile ?? tiers.current(), 'high');
|
|
179
|
+
tiers.set('low');
|
|
180
|
+
assert.equal(tiers.handle.profile ?? tiers.current(), ['weakest', 'middle'].includes(profile) ? profile : 'low');
|
|
181
|
+
assert.equal(tiers.middle(), profile === 'middle');
|
|
182
|
+
if (enabled) {
|
|
183
|
+
tiers.set('weakest');
|
|
184
|
+
assert.equal(tiers.weakest(), true);
|
|
185
|
+
assert.equal(tiers.middle(), false);
|
|
186
|
+
assert.equal(tiers.handle.profile, 'weakest');
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
const f = fixture(),
|
|
190
|
+
tier = makeWeakestTier();
|
|
191
|
+
tier.frame(f.scene, false, 0);
|
|
192
|
+
assert.equal(f.scene.files, f.files);
|
|
193
|
+
assert.equal(Object.hasOwn(f.scene, 'dropsEmptyParts'), false);
|
|
194
|
+
|
|
195
|
+
// Resolution belongs to this runtime and both render targets, then returns
|
|
196
|
+
// exactly to its previous settings on High or when entering a door scene.
|
|
197
|
+
{
|
|
198
|
+
const h = fixture(),
|
|
199
|
+
controller = makeWeakestTier();
|
|
200
|
+
let ratio = 2;
|
|
201
|
+
h.scene.three = {};
|
|
202
|
+
h.scene.three.renderer = {
|
|
203
|
+
getPixelRatio: () => ratio,
|
|
204
|
+
setPixelRatio: (v) => {
|
|
205
|
+
ratio = v;
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
h.scene.three.composer = {
|
|
209
|
+
_pixelRatio: 1.5,
|
|
210
|
+
setPixelRatio(v) {
|
|
211
|
+
this._pixelRatio = v;
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
controller.frame(h.scene, false, 0);
|
|
215
|
+
assert.equal(ratio, 2);
|
|
216
|
+
controller.frame(h.scene, true, 0);
|
|
217
|
+
assert.equal(ratio, 0.5);
|
|
218
|
+
assert.equal(h.scene.three.composer._pixelRatio, 0.5);
|
|
219
|
+
controller.frame(h.scene, false, 100);
|
|
220
|
+
assert.equal(ratio, 2);
|
|
221
|
+
assert.equal(h.scene.three.composer._pixelRatio, 1.5);
|
|
222
|
+
controller.frame(h.scene, true, 200);
|
|
223
|
+
// A later owner changed the buffers: restoring this tier must not undo it.
|
|
224
|
+
ratio = 1;
|
|
225
|
+
h.scene.three.composer._pixelRatio = 1;
|
|
226
|
+
controller.restore();
|
|
227
|
+
assert.equal(ratio, 1);
|
|
228
|
+
assert.equal(h.scene.three.composer._pixelRatio, 1);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Execute the hub's actual entry method: an opted-in ordinary Low GPU never
|
|
232
|
+
// creates or frames the district/bake/resolution controller.
|
|
233
|
+
{
|
|
234
|
+
const source = fs.readFileSync(new URL('../code/systems/hub.js', import.meta.url), 'utf8');
|
|
235
|
+
const start = source.indexOf(' deviceTier(scene, mp, now) {');
|
|
236
|
+
const method = source.slice(start, source.indexOf('\n }\n', start) + 4).trim();
|
|
237
|
+
const Hub = { deck: { tiers: true, weakestTier: true }, hub: {} };
|
|
238
|
+
let enabled = false,
|
|
239
|
+
made = 0,
|
|
240
|
+
framed = 0,
|
|
241
|
+
restored = 0;
|
|
242
|
+
const tiers = { frame() {}, weakest: () => enabled, current: () => 'low', handle: {} };
|
|
243
|
+
const controller = {
|
|
244
|
+
active: false,
|
|
245
|
+
frame() {
|
|
246
|
+
framed++;
|
|
247
|
+
this.active = true;
|
|
248
|
+
},
|
|
249
|
+
restore() {
|
|
250
|
+
restored++;
|
|
251
|
+
this.active = false;
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
const entry = new Function(
|
|
255
|
+
'Hub',
|
|
256
|
+
'makeTiers',
|
|
257
|
+
'makeWeakestTier',
|
|
258
|
+
'readDistricts',
|
|
259
|
+
'makeFarAvatars',
|
|
260
|
+
'globalThis',
|
|
261
|
+
'fpsTelemetryFor',
|
|
262
|
+
'qualityFor',
|
|
263
|
+
`return function ${method};`,
|
|
264
|
+
)(
|
|
265
|
+
Hub,
|
|
266
|
+
() => tiers,
|
|
267
|
+
({ profile }) => {
|
|
268
|
+
made++;
|
|
269
|
+
controller.profile = profile;
|
|
270
|
+
return controller;
|
|
271
|
+
},
|
|
272
|
+
readDistricts,
|
|
273
|
+
() => ({ update() {}, clear() {} }),
|
|
274
|
+
{ __hub: {} },
|
|
275
|
+
fpsTelemetryFor,
|
|
276
|
+
() => null,
|
|
277
|
+
);
|
|
278
|
+
const system = { pendingEnd: null };
|
|
279
|
+
const scene = { actorWith: () => null };
|
|
280
|
+
for (let i = 0; i < 1000; i++) entry.call(system, scene, null, i);
|
|
281
|
+
assert.equal(made, 0);
|
|
282
|
+
assert.equal(framed, 0);
|
|
283
|
+
enabled = true;
|
|
284
|
+
for (let i = 0; i < 1000; i++) entry.call(system, scene, null, i);
|
|
285
|
+
assert.equal(made, 0);
|
|
286
|
+
assert.equal(framed, 0);
|
|
287
|
+
scene.data = { weakestDistricts: { version: 99 } };
|
|
288
|
+
entry.call(system, scene, null, 1000);
|
|
289
|
+
assert.equal(made, 0);
|
|
290
|
+
scene.data.weakestDistricts = spec;
|
|
291
|
+
entry.call(system, scene, null, 1001);
|
|
292
|
+
assert.equal(made, 1);
|
|
293
|
+
assert.equal(framed, 1);
|
|
294
|
+
enabled = false;
|
|
295
|
+
entry.call(system, {}, null, 1002);
|
|
296
|
+
entry.call(system, {}, null, 1003);
|
|
297
|
+
assert.equal(restored, 1);
|
|
298
|
+
Hub.deck.tiers = false;
|
|
299
|
+
system.tiers = undefined;
|
|
300
|
+
entry.call(system, {}, null, 1004);
|
|
301
|
+
assert.equal(system.tiers, undefined);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Execute the hub entry with real tier selection and district controllers.
|
|
305
|
+
// No engine build or browser is needed: these are Low's existing buffers.
|
|
306
|
+
const hubSource = fs.readFileSync(new URL('../code/systems/hub.js', import.meta.url), 'utf8');
|
|
307
|
+
const deviceStart = hubSource.indexOf(' deviceTier(scene, mp, now) {');
|
|
308
|
+
const deviceMethod = hubSource.slice(deviceStart, hubSource.indexOf('\n }\n', deviceStart) + 4).trim();
|
|
309
|
+
function middleFixture({ enabled = true, gpu = 'Mali-G52 MC2', composerRatio = 2 } = {}) {
|
|
310
|
+
const h = fixture();
|
|
311
|
+
let ratio = 2;
|
|
312
|
+
const Hub = { deck: { tiers: true, weakestTier: enabled }, hub: { labels: {}, labelsMe: {} } };
|
|
313
|
+
const merges = [];
|
|
314
|
+
h.scene.three = {
|
|
315
|
+
renderer: {
|
|
316
|
+
getContext: () => ({ getExtension: () => null, getParameter: () => gpu }),
|
|
317
|
+
getPixelRatio: () => ratio,
|
|
318
|
+
setPixelRatio: (v) => { ratio = v; },
|
|
319
|
+
},
|
|
320
|
+
composer: { _pixelRatio: composerRatio, setPixelRatio(v) { this._pixelRatio = v; } },
|
|
321
|
+
nodes: new Map(),
|
|
322
|
+
camera: new PerspectiveCamera(60, 800 / 600, 0.1, 1000),
|
|
323
|
+
};
|
|
324
|
+
h.scene.three.camera.updateMatrixWorld();
|
|
325
|
+
const entry = new Function('Hub', 'makeTiers', 'makeWeakestTier', 'readDistricts', 'makeFarAvatars',
|
|
326
|
+
'globalThis', 'fpsTelemetryFor', 'qualityFor', `return function ${deviceMethod};`)(
|
|
327
|
+
Hub,
|
|
328
|
+
(options) => makeTiers({ ...options, storage: null, deviceMemory: 4, levers: { apply() {}, high() {} } }),
|
|
329
|
+
makeWeakestTier, readDistricts, () => ({ update(...args) { merges.push(args.at(-1)); }, clear() {} }),
|
|
330
|
+
{ __hub: {} }, fpsTelemetryFor, () => null,
|
|
331
|
+
);
|
|
332
|
+
const system = { pendingEnd: null };
|
|
333
|
+
return { ...h, Hub, system, merges, ratio: () => ratio,
|
|
334
|
+
setRatio: (v) => { ratio = v; }, frame: (now = 0) => entry.call(system, h.scene, null, now) };
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
{
|
|
338
|
+
const h = middleFixture({ composerRatio: 1.5 });
|
|
339
|
+
const queue = { skipSurfaceBakes: false, sentinel: {} };
|
|
340
|
+
h.scene.three.lookBake = queue;
|
|
341
|
+
h.Hub.deck.weakestLookBake = true; // Middle must ignore even this opt-in.
|
|
342
|
+
h.frame();
|
|
343
|
+
assert.equal(h.system.tiers.current(), 'low');
|
|
344
|
+
assert.equal(h.system.tiers.middle(), true);
|
|
345
|
+
assert.equal(h.system.tiers.handle.profile, 'middle');
|
|
346
|
+
assert.equal(h.system.weakestTier.profile, 'middle');
|
|
347
|
+
assert.equal(h.ratio(), 1, 'DPR 2 becomes DPR 1, rather than the absolute 0.5 Weakest cap');
|
|
348
|
+
assert.equal(h.scene.three.composer._pixelRatio, 0.75, 'each buffer halves its own Low ratio');
|
|
349
|
+
assert.equal(h.scene.isActorSleeping(h.right), true);
|
|
350
|
+
assert.equal(h.scene.files, h.files);
|
|
351
|
+
assert.equal(Object.hasOwn(h.scene, 'bakesLookLater'), false);
|
|
352
|
+
assert.equal(Object.hasOwn(h.scene, 'dropsEmptyParts'), false);
|
|
353
|
+
assert.equal(h.scene.three.lookBake, queue);
|
|
354
|
+
assert.deepEqual(Object.keys(queue), ['skipSurfaceBakes', 'sentinel']);
|
|
355
|
+
assert.equal(queue.skipSurfaceBakes, false);
|
|
356
|
+
assert.deepEqual(h.merges, [], 'Middle does not enable far-avatar merging');
|
|
357
|
+
h.frame(100);
|
|
358
|
+
assert.equal(h.ratio(), 1, 'repeated frames never halve again');
|
|
359
|
+
h.system.tiers.set('high');
|
|
360
|
+
h.frame(101);
|
|
361
|
+
assert.equal(h.system.tiers.middle(), false);
|
|
362
|
+
assert.equal(h.ratio(), 2);
|
|
363
|
+
assert.equal(h.scene.three.composer._pixelRatio, 1.5);
|
|
364
|
+
assert.equal(h.scene.getActors().length, h.scene.actors.size);
|
|
365
|
+
assert.equal(h.scene.files, h.files);
|
|
366
|
+
assert.equal(Object.hasOwn(h.scene, 'bakesLookLater'), false);
|
|
367
|
+
assert.equal(Object.hasOwn(h.scene, 'dropsEmptyParts'), false);
|
|
368
|
+
}
|
|
369
|
+
{
|
|
370
|
+
const h = middleFixture();
|
|
371
|
+
for (const mode of ['auto', 'weakest', 'low', 'weakest', 'high', 'low']) {
|
|
372
|
+
h.system.tiers?.set(mode);
|
|
373
|
+
h.frame();
|
|
374
|
+
const weakest = mode === 'weakest', high = mode === 'high';
|
|
375
|
+
assert.equal(h.system.tiers.handle.profile, weakest ? 'weakest' : high ? 'high' : 'middle');
|
|
376
|
+
assert.equal(h.ratio(), weakest ? 0.5 : high ? 2 : 1);
|
|
377
|
+
assert.equal(h.scene.three.composer._pixelRatio, h.ratio());
|
|
378
|
+
assert.equal(h.scene.isActorSleeping(h.right), !high);
|
|
379
|
+
assert.equal(h.scene.files === h.files, !weakest);
|
|
380
|
+
assert.equal(Object.hasOwn(h.scene, 'bakesLookLater'), weakest);
|
|
381
|
+
assert.equal(Object.hasOwn(h.scene, 'dropsEmptyParts'), weakest);
|
|
382
|
+
assert.equal(Object.hasOwn(h.scene.three.lookBake ?? {}, 'skipSurfaceBakes'), weakest);
|
|
383
|
+
if (mode === 'auto') assert.equal(h.scene.three.lookBake, undefined, 'Middle never creates a bake queue');
|
|
384
|
+
}
|
|
385
|
+
assert.deepEqual(h.merges, [12, 12], 'only Weakest enabled merging');
|
|
386
|
+
h.Hub.deck.mergeFarAvatars = true;
|
|
387
|
+
h.frame();
|
|
388
|
+
assert.equal(h.merges.at(-1), Infinity, 'explicit merge opt-in keeps its normal policy on Middle');
|
|
389
|
+
h.system.weakestTier.restore();
|
|
390
|
+
assert.equal(h.ratio(), 2);
|
|
391
|
+
assert.equal(h.scene.getActors().length, h.scene.actors.size);
|
|
392
|
+
}
|
|
393
|
+
for (const invalid of [undefined, { version: 99 }]) {
|
|
394
|
+
const h = middleFixture();
|
|
395
|
+
h.scene.data.weakestDistricts = invalid;
|
|
396
|
+
h.frame();
|
|
397
|
+
assert.equal(h.system.weakestTier, undefined);
|
|
398
|
+
assert.equal(h.ratio(), 2);
|
|
399
|
+
assert.equal(h.scene.getActors().length, h.scene.actors.size);
|
|
400
|
+
}
|
|
401
|
+
for (const options of [{ enabled: false }, { gpu: 'Mali-G52 MC3' }]) {
|
|
402
|
+
const h = middleFixture(options);
|
|
403
|
+
h.frame();
|
|
404
|
+
assert.equal(h.system.tiers.middle(), false);
|
|
405
|
+
assert.equal(h.system.weakestTier, undefined);
|
|
406
|
+
assert.equal(h.ratio(), 2);
|
|
407
|
+
}
|
|
408
|
+
{
|
|
409
|
+
const h = middleFixture({ gpu: 'PowerVR Rogue GE8320' });
|
|
410
|
+
h.frame();
|
|
411
|
+
assert.equal(h.system.tiers.weakest(), true);
|
|
412
|
+
assert.equal(h.system.tiers.middle(), false);
|
|
413
|
+
assert.equal(h.ratio(), 0.5);
|
|
414
|
+
h.system.weakestTier.restore();
|
|
415
|
+
}
|
|
416
|
+
// Restoration only touches owned ratios, and wakes actors even after data edits.
|
|
417
|
+
{
|
|
418
|
+
const h = middleFixture();
|
|
419
|
+
h.frame();
|
|
420
|
+
h.setRatio(1.25);
|
|
421
|
+
h.scene.data = { ...h.scene.data };
|
|
422
|
+
h.system.weakestTier.restore();
|
|
423
|
+
assert.equal(h.ratio(), 1.25);
|
|
424
|
+
assert.equal(h.scene.three.composer._pixelRatio, 2);
|
|
425
|
+
assert.equal(h.scene.getActors().length, h.scene.actors.size);
|
|
426
|
+
h.frame();
|
|
427
|
+
h.scene.three.composer._pixelRatio = 1.75;
|
|
428
|
+
h.system.weakestTier.restore();
|
|
429
|
+
assert.equal(h.ratio(), 1.25);
|
|
430
|
+
assert.equal(h.scene.three.composer._pixelRatio, 1.75);
|
|
431
|
+
}
|
|
432
|
+
for (const leave of [
|
|
433
|
+
(h) => { h.scene.content = {}; },
|
|
434
|
+
(h) => { h.scene.requestedScene = 'scenes/door.scene'; },
|
|
435
|
+
(h) => { h.player.components.Transform.x = 40; },
|
|
436
|
+
(h) => { h.scene.data = { ...h.scene.data, weakestDistricts: { version: 99 } }; },
|
|
437
|
+
]) {
|
|
438
|
+
const h = middleFixture();
|
|
439
|
+
h.frame();
|
|
440
|
+
assert.equal(h.scene.isActorSleeping(h.right), true);
|
|
441
|
+
leave(h);
|
|
442
|
+
h.frame(1);
|
|
443
|
+
assert.equal(h.system.weakestTier.active, false);
|
|
444
|
+
assert.equal(h.ratio(), 2);
|
|
445
|
+
assert.equal(h.scene.three.composer._pixelRatio, 2);
|
|
446
|
+
assert.equal(h.scene.getActors().length, h.scene.actors.size);
|
|
447
|
+
assert.equal(h.scene.files, h.files);
|
|
448
|
+
}
|
|
449
|
+
// Same apron/protected/hidden-template rules for both profiles.
|
|
450
|
+
for (const profile of ['middle', 'weakest']) {
|
|
451
|
+
const h = fixture(), controller = makeWeakestTier({ profile });
|
|
452
|
+
const extras = [
|
|
453
|
+
['anchor', 14, { RouteAnchor: {} }, 0, false],
|
|
454
|
+
['body', 14, { Body: { type: 'dynamic' } }, 0, false],
|
|
455
|
+
['player', 14, { Player: {} }, 0, false],
|
|
456
|
+
['apron', -6, {}, 0, false],
|
|
457
|
+
['beyond', -5.9, {}, 0, true],
|
|
458
|
+
['hidden', -10, {}, -100, true],
|
|
459
|
+
];
|
|
460
|
+
h.scene.data.weakestDistricts = { ...spec, actors: [...spec.actors] };
|
|
461
|
+
for (const [id, x, components, y] of extras) {
|
|
462
|
+
h.scene.spawnActor({ id, components: { Transform: { x, y, z: 0 }, ...components } });
|
|
463
|
+
h.scene.data.weakestDistricts.actors.push({ id, districts: [id === 'hidden' ? 'left' : 'right'], origin: [x, 0], bounds: [x, 0, x, 0] });
|
|
464
|
+
}
|
|
465
|
+
controller.frame(h.scene, true, 0);
|
|
466
|
+
for (const [id, , , , sleeps] of extras) assert.equal(h.scene.isActorSleeping(h.scene.getActor(id)), sleeps, `${profile}: ${id}`);
|
|
467
|
+
controller.restore();
|
|
468
|
+
assert.equal(h.scene.getActors().length, h.scene.actors.size);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// Run the actual goal/label collection and chrome.setPointers pass. Current
|
|
472
|
+
// target NPCs wake even when a new label arrives inside the 100 ms sleep tick.
|
|
473
|
+
const labelStart = hubSource.indexOf(' for (const [id, label] of Object.entries');
|
|
474
|
+
const labelLoop = hubSource.slice(labelStart, hubSource.indexOf(' // In a town only', labelStart));
|
|
475
|
+
const pointerStart = hubSource.indexOf(' const pointerView =');
|
|
476
|
+
const pointerPass = hubSource.slice(pointerStart, hubSource.indexOf('\n if (cam && idle)', pointerStart));
|
|
477
|
+
const drawPointers = new Function('Hub', 'scene', 'goalAt', 'goalPointers', 'goalText', 'pointerAt', `
|
|
478
|
+
const goals = [], placed = [], talkingWith = null;
|
|
479
|
+
${labelLoop}
|
|
480
|
+
const view = { w: 800, h: 600 }, cam = scene.three.camera, idle = true, place = {}, inGame = false;
|
|
481
|
+
const local = scene.actorWith('Player'), GOALS_MAX = 2, GOAL_NEAR_M = 6;
|
|
482
|
+
const offsetWorldPoint = (point) => point;
|
|
483
|
+
let points;
|
|
484
|
+
const chrome = { setPointers: (value) => { points = value; } };
|
|
485
|
+
${pointerPass}
|
|
486
|
+
return { points, placed };
|
|
487
|
+
`);
|
|
488
|
+
for (const mode of ['low', 'weakest']) {
|
|
489
|
+
const h = middleFixture();
|
|
490
|
+
h.right.components.HubNpc = {};
|
|
491
|
+
h.frame();
|
|
492
|
+
h.system.tiers.set(mode);
|
|
493
|
+
h.frame(1);
|
|
494
|
+
assert.equal(h.scene.isActorSleeping(h.right), true);
|
|
495
|
+
assert.equal(h.scene.isActorSleeping(h.scene.getActor('door')), true, `${mode}: unlabelled far door sleeps`);
|
|
496
|
+
h.Hub.hub.labelsMe = { 'right-wall': { style: 'goal', text: 'Market stamp', distanceM: 55 } };
|
|
497
|
+
h.Hub.hub.labels = { door: { style: 'sign', text: 'Market' } };
|
|
498
|
+
h.frame(2);
|
|
499
|
+
assert.equal(h.scene.isActorSleeping(h.right), false, `${mode}: target NPC wakes`);
|
|
500
|
+
assert.equal(h.scene.isActorSleeping(h.scene.getActor('door')), mode === 'weakest',
|
|
501
|
+
`${mode}: only Middle wakes a far shared-label target immediately`);
|
|
502
|
+
h.frame(150);
|
|
503
|
+
assert.equal(h.scene.isActorSleeping(h.right), false, `${mode}: goal target stays awake across district checks`);
|
|
504
|
+
assert.equal(h.scene.isActorSleeping(h.scene.getActor('door')), mode === 'weakest',
|
|
505
|
+
`${mode}: far shared-label target follows the profile's protection rule`);
|
|
506
|
+
const { points, placed } = drawPointers.call({ pendingEnd: null, together: { pointers: () => [] } },
|
|
507
|
+
h.Hub, h.scene, goalAt, goalPointers, goalText, pointerAt);
|
|
508
|
+
assert.equal(points.length, 1);
|
|
509
|
+
assert.equal(points[0].id, 'goal:right-wall');
|
|
510
|
+
assert.equal(points[0].text, 'Market stamp · 55 m');
|
|
511
|
+
assert.ok(Number.isFinite(points[0].x) && Number.isFinite(points[0].y));
|
|
512
|
+
assert.equal(placed[0].id, 'door');
|
|
513
|
+
assert.equal(placed[0].at, h.scene.getActor('door').components.Transform);
|
|
514
|
+
h.Hub.hub.labelsMe = {};
|
|
515
|
+
h.Hub.hub.labels = {};
|
|
516
|
+
h.frame(300);
|
|
517
|
+
assert.equal(h.scene.isActorSleeping(h.right), true, 'removed targets can sleep again');
|
|
518
|
+
h.system.weakestTier.restore();
|
|
519
|
+
}
|
|
520
|
+
// Other players are never put to sleep: party members, players on this
|
|
521
|
+
// player's pad and recent chatters are remote avatars, which carry no district
|
|
522
|
+
// row, so a far one stays live, and Middle never merges them.
|
|
523
|
+
for (const mode of ['low', 'weakest']) {
|
|
524
|
+
const h = middleFixture();
|
|
525
|
+
for (const [id, x] of [['party-peer', 14], ['pad-peer', 16], ['chat-peer', 18]]) {
|
|
526
|
+
h.scene.spawnActor({ id, components: { Transform: { x, y: 0, z: 0 }, HubAvatar: {} } });
|
|
527
|
+
}
|
|
528
|
+
h.frame();
|
|
529
|
+
h.system.tiers.set(mode);
|
|
530
|
+
h.frame(1);
|
|
531
|
+
h.frame(300);
|
|
532
|
+
assert.equal(h.scene.isActorSleeping(h.right), true, `${mode}: far district asleep`);
|
|
533
|
+
for (const id of ['party-peer', 'pad-peer', 'chat-peer']) {
|
|
534
|
+
assert.equal(h.scene.isActorSleeping(h.scene.getActor(id)), false, `${mode}: ${id} stays awake`);
|
|
535
|
+
}
|
|
536
|
+
if (mode === 'low') assert.deepEqual(h.merges, [], 'Middle leaves remote players unmerged');
|
|
537
|
+
h.system.weakestTier.restore();
|
|
538
|
+
}
|
|
539
|
+
// A pad on the active guide route stays awake in a far district while it is
|
|
540
|
+
// labelled for this player, and may sleep again once the guide moves on.
|
|
541
|
+
for (const mode of ['low', 'weakest']) {
|
|
542
|
+
const h = middleFixture();
|
|
543
|
+
h.scene.data.weakestDistricts = { ...spec, actors: [...spec.actors,
|
|
544
|
+
{ id: 'route-pad', districts: ['right'], origin: [16, 0], bounds: [15, -1, 17, 1] }] };
|
|
545
|
+
h.scene.spawnActor({ id: 'route-pad', components: { Transform: { x: 16, y: 0, z: 0 }, HubPad: {} } });
|
|
546
|
+
h.frame();
|
|
547
|
+
h.system.tiers.set(mode);
|
|
548
|
+
h.frame(1);
|
|
549
|
+
const pad = h.scene.getActor('route-pad');
|
|
550
|
+
assert.equal(h.scene.isActorSleeping(pad), true, `${mode}: unlabelled far pad sleeps`);
|
|
551
|
+
h.Hub.hub.labelsMe = { 'route-pad': { style: 'sign', text: 'Step on the pad' } };
|
|
552
|
+
h.frame(2);
|
|
553
|
+
assert.equal(h.scene.isActorSleeping(pad), false, `${mode}: guide-route pad wakes`);
|
|
554
|
+
h.frame(300);
|
|
555
|
+
assert.equal(h.scene.isActorSleeping(pad), false, `${mode}: guide-route pad stays awake across district checks`);
|
|
556
|
+
h.Hub.hub.labelsMe = {};
|
|
557
|
+
h.frame(500);
|
|
558
|
+
assert.equal(h.scene.isActorSleeping(pad), true, `${mode}: pad sleeps after the guide moves on`);
|
|
559
|
+
h.system.weakestTier.restore();
|
|
560
|
+
}
|
|
561
|
+
console.log('middle tier: GPU selection, half Low buffers, sleep-only policy, transitions, ownership and far quest pointers passed');
|
|
562
|
+
|
|
563
|
+
assert.equal(f.scene.actors.size, 4);
|
|
564
|
+
tier.frame(f.scene, true, 0);
|
|
565
|
+
assert.equal(tier.active, true);
|
|
566
|
+
assert.equal(tier.district, 'left');
|
|
567
|
+
assert.equal(
|
|
568
|
+
f.scene.getActors().some((a) => a.id === 'right-wall'),
|
|
569
|
+
false,
|
|
570
|
+
);
|
|
571
|
+
assert.equal(
|
|
572
|
+
f.scene.getActors().some((a) => a.id === 'door'),
|
|
573
|
+
false,
|
|
574
|
+
);
|
|
575
|
+
assert.equal(f.scene.data, f.data);
|
|
576
|
+
assert.equal(f.data.actors.length, 4);
|
|
577
|
+
assert.equal(f.scene.bakesLookLater, true);
|
|
578
|
+
assert.equal(f.scene.dropsEmptyParts, true);
|
|
579
|
+
const cheap = JSON.parse(f.scene.files['models/m.pxmodel']);
|
|
580
|
+
assert.deepEqual(cheap, JSON.parse(f.files['models/m.pxmodel']));
|
|
581
|
+
assert.notEqual(f.scene.files['models/m.pxmodel'], f.files['models/m.pxmodel']);
|
|
582
|
+
assert.equal(JSON.parse(f.files['models/m.pxmodel']).look.ao, undefined);
|
|
583
|
+
f.player.components.Transform.x = 12;
|
|
584
|
+
tier.frame(f.scene, true, 50);
|
|
585
|
+
assert.equal(tier.district, 'right');
|
|
586
|
+
assert.equal(f.scene.actors.get('right-wall'), f.right);
|
|
587
|
+
assert.equal(
|
|
588
|
+
f.scene.getActors().some((a) => a.id === 'left-wall'),
|
|
589
|
+
false,
|
|
590
|
+
);
|
|
591
|
+
f.player.components.Transform.x = 40;
|
|
592
|
+
tier.frame(f.scene, true, 60);
|
|
593
|
+
assert.equal(tier.active, false);
|
|
594
|
+
assert.equal(f.scene.actors.get('left-wall'), f.left);
|
|
595
|
+
assert.equal(f.scene.files, f.files);
|
|
596
|
+
assert.equal(Object.hasOwn(f.scene, 'bakesLookLater'), false);
|
|
597
|
+
assert.equal(Object.hasOwn(f.scene, 'dropsEmptyParts'), false);
|
|
598
|
+
assert.equal(f.scene.dropsEmptyParts, false);
|
|
599
|
+
// Replaced ids, scene loads, mounted content, and externally changed files.
|
|
600
|
+
f.player.components.Transform.x = -10;
|
|
601
|
+
tier.frame(f.scene, true, 100);
|
|
602
|
+
const replacement = inert('right-wall', 16);
|
|
603
|
+
const spawned = f.scene.spawnActor(replacement);
|
|
604
|
+
tier.restore();
|
|
605
|
+
assert.equal(f.scene.actors.get('right-wall'), spawned);
|
|
606
|
+
tier.frame(f.scene, true, 200);
|
|
607
|
+
f.scene.load({ actors: [] });
|
|
608
|
+
tier.restore();
|
|
609
|
+
assert.equal(f.scene.actors.size, 0);
|
|
610
|
+
const g = fixture();
|
|
611
|
+
tier.frame(g.scene, true, 300);
|
|
612
|
+
g.scene.content = {};
|
|
613
|
+
tier.frame(g.scene, true, 301);
|
|
614
|
+
assert.equal(g.scene.actors.size, 4);
|
|
615
|
+
assert.equal(g.scene.files, g.files);
|
|
616
|
+
console.log(
|
|
617
|
+
'weakest tier: deterministic selection, exact parked state, source/editor isolation, switches, and malformed data passed',
|
|
618
|
+
);
|
|
619
|
+
|
|
620
|
+
// Generic sleeping keeps ID lookup and serialization complete but pauses
|
|
621
|
+
// behavior passes, and spawns/despawns/loads cannot inherit stale sleep state.
|
|
622
|
+
{
|
|
623
|
+
class Counter {
|
|
624
|
+
static behaviorName = 'Counter';
|
|
625
|
+
update(actor) {
|
|
626
|
+
actor.runtime.calls = (actor.runtime.calls ?? 0) + 1;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
const r = new SceneRuntime(
|
|
630
|
+
{
|
|
631
|
+
actors: [
|
|
632
|
+
{ id: 'a', components: { Counter: {} } },
|
|
633
|
+
{ id: 'b', components: { Counter: {} } },
|
|
634
|
+
],
|
|
635
|
+
},
|
|
636
|
+
[Counter],
|
|
637
|
+
{},
|
|
638
|
+
{},
|
|
639
|
+
);
|
|
640
|
+
const b = r.getActor('b');
|
|
641
|
+
r.update(0.1);
|
|
642
|
+
const before = r.serialize();
|
|
643
|
+
assert.equal(r.setActorSleeping('b', true), true);
|
|
644
|
+
assert.equal(r.getActor('b'), b);
|
|
645
|
+
assert.deepEqual(r.serialize(), before);
|
|
646
|
+
r.update(0.1);
|
|
647
|
+
assert.equal(b.runtime.calls, 1);
|
|
648
|
+
assert.equal(r.getActor('a').runtime.calls, 2);
|
|
649
|
+
r.setActorSleeping(b, false);
|
|
650
|
+
r.update(0.1);
|
|
651
|
+
assert.equal(b.runtime.calls, 2);
|
|
652
|
+
r.setActorSleeping(b, true);
|
|
653
|
+
r.despawnActor('b');
|
|
654
|
+
const replacement = r.spawnActor({ id: 'b', components: { Counter: {} } });
|
|
655
|
+
assert.equal(r.setActorSleeping(b, false), false);
|
|
656
|
+
assert.ok(r.getActors().includes(replacement));
|
|
657
|
+
r.setActorSleeping(replacement, true);
|
|
658
|
+
r.load({ actors: [{ id: 'c', components: { Counter: {} } }] });
|
|
659
|
+
assert.deepEqual(
|
|
660
|
+
r.getActors().map((a) => a.id),
|
|
661
|
+
['c'],
|
|
662
|
+
);
|
|
663
|
+
}
|
|
664
|
+
console.log('real runtime sleeping: ID lookup, behavior pause, serialization and ID reuse passed');
|
|
665
|
+
|
|
666
|
+
// Build gameplay caches while a far district sleeps, then return to it without
|
|
667
|
+
// changing the scene key, data, actor Map or its size. Use the production trip
|
|
668
|
+
// reveal and swing methods so the sleeping return door must actually close.
|
|
669
|
+
{
|
|
670
|
+
const method = (name) => {
|
|
671
|
+
const start = hubSource.indexOf(` ${name}(`);
|
|
672
|
+
return hubSource.slice(start, hubSource.indexOf('\n }\n', start) + 4).trim();
|
|
673
|
+
};
|
|
674
|
+
const helper = (name) => {
|
|
675
|
+
const start = hubSource.indexOf(`function ${name}(`);
|
|
676
|
+
return hubSource.slice(start, hubSource.indexOf('\n}\n', start) + 2);
|
|
677
|
+
};
|
|
678
|
+
const constants = ['REVEAL_MS', 'DOOR_SWING_DEG', 'clamp01', 'ease']
|
|
679
|
+
.map((name) => hubSource.match(new RegExp(`^const ${name} = .*;$`, 'm'))[0]).join('\n');
|
|
680
|
+
const doors = new Function('allActors', 'doorPoint', `${constants}
|
|
681
|
+
${helper('doorActor')}
|
|
682
|
+
${helper('isCabinet')}
|
|
683
|
+
return { doorActor, stepTrip: function ${method('stepTrip')}, swingDoor: function ${method('swingDoor')} };`)(allActors, doorPoint);
|
|
684
|
+
assert.deepEqual(allActors({ getActors: () => ['fallback'] }), ['fallback']);
|
|
685
|
+
assert.deepEqual(allActors({ actors: new Map(), getActors: () => ['awake'] }), []);
|
|
686
|
+
const previousQuality = deck.quality;
|
|
687
|
+
try {
|
|
688
|
+
for (const profile of ['weakest', 'middle']) {
|
|
689
|
+
clearHub();
|
|
690
|
+
delete deck.quality;
|
|
691
|
+
const h = fixture(), controller = makeWeakestTier({ profile });
|
|
692
|
+
const { scene, player } = h;
|
|
693
|
+
const door = scene.getActor('door');
|
|
694
|
+
door.components.HubDoor.id = 'gems';
|
|
695
|
+
const closed = structuredClone(door.components.Transform);
|
|
696
|
+
const trip = { phase: 'revealing', target: { arriveDoor: 'gems' }, startedAt: 0, revealAt: 0, marks: {} };
|
|
697
|
+
let finished = false;
|
|
698
|
+
const owner = { trip, doorBase: new Map(), swingDoor: doors.swingDoor,
|
|
699
|
+
setTripCover() {}, showLeaving() {}, finishTrip() { finished = true; } };
|
|
700
|
+
owner.swingDoor(door, 1, scene);
|
|
701
|
+
assert.equal(door.components.Transform.rotationY, 100);
|
|
702
|
+
for (const [id, component] of [['bench', 'HubSeat'], ['pad', 'HubPad'], ['npc', 'HubNpc']]) {
|
|
703
|
+
scene.spawnActor({ ...inert(id, 14), components: {
|
|
704
|
+
Transform: { x: 14, y: 0, z: 0 }, [component]: {},
|
|
705
|
+
Shape: { kind: 'box', width: 2.4, depth: 0.6 },
|
|
706
|
+
} });
|
|
707
|
+
}
|
|
708
|
+
scene.spawnActor({ id: 'guest', components: { Transform: { x: 15, z: 0 } } });
|
|
709
|
+
scene.data.weakestDistricts = { ...spec, actors: [...spec.actors,
|
|
710
|
+
...['bench', 'pad', 'npc'].map((id) => ({ ...spec.actors[1], id }))] };
|
|
711
|
+
const q = makeQualityVisit({ current: () => 'low' });
|
|
712
|
+
filterQualityScene(scene, scene.data, q);
|
|
713
|
+
deck.quality = { low: { players: 0 } };
|
|
714
|
+
const sent = [], prompts = [];
|
|
715
|
+
let pressSit;
|
|
716
|
+
const mp = { net: { selfId: () => 'me', send: (msg) => sent.push(msg) },
|
|
717
|
+
avatars: { actors: new Map([['guest-player', 'guest']]) } };
|
|
718
|
+
scene.multiplayer = mp;
|
|
719
|
+
hub.place = { idle: { seats: true } };
|
|
720
|
+
const idle = makeIdle({ onSit: (fn) => { pressSit = fn; }, sitPrompt: (label) => prompts.push(label) });
|
|
721
|
+
controller.frame(scene, true, 0);
|
|
722
|
+
for (const id of ['door', 'bench', 'pad', 'npc']) {
|
|
723
|
+
assert.equal(scene.isActorSleeping(scene.getActor(id)), true, `${profile}: ${id} sleeps`);
|
|
724
|
+
assert.ok(!scene.getActors().includes(scene.getActor(id)));
|
|
725
|
+
assert.ok(allActors(scene).includes(scene.getActor(id)));
|
|
726
|
+
}
|
|
727
|
+
assert.equal(doors.doorActor(scene, 'gems'), 'door', `${profile}: sleeping door lookup`);
|
|
728
|
+
assert.equal(doors.doorActor(scene, 'missing'), null);
|
|
729
|
+
doors.stepTrip.call(owner, scene, mp, player, 700);
|
|
730
|
+
assert.equal(finished, true);
|
|
731
|
+
assert.equal(scene.isActorSleeping(door), true, 'closing does not wake the door');
|
|
732
|
+
assert.deepEqual(door.components.Transform, { ...closed, rotationY: 0 }, `${profile}: return closes sleeping door`);
|
|
733
|
+
idle.frame(scene, mp, player, true, 'town');
|
|
734
|
+
assert.equal(prompts.at(-1), null);
|
|
735
|
+
qualityPlayers(scene, q, 0);
|
|
736
|
+
assert.ok(q.culled.has('guest'), 'far guest uses no player slot');
|
|
737
|
+
const pads = q.pads;
|
|
738
|
+
const npcs = talkActors(scene);
|
|
739
|
+
assert.ok(pads.includes(scene.getActor('pad')), `${profile}: pad cached while asleep`);
|
|
740
|
+
assert.ok(npcs.includes(scene.getActor('npc')), `${profile}: NPC cached while asleep`);
|
|
741
|
+
const npcCache = q.npcs;
|
|
742
|
+
const count = scene.actors.size;
|
|
743
|
+
player.components.Transform.x = 14 + 1.2 + SIT_OFFER_M - 0.01;
|
|
744
|
+
controller.frame(scene, true, 500);
|
|
745
|
+
assert.equal(scene.actors.size, count);
|
|
746
|
+
for (const id of ['door', 'bench', 'pad', 'npc']) {
|
|
747
|
+
assert.equal(scene.isActorSleeping(scene.getActor(id)), false, `${profile}: ${id} wakes`);
|
|
748
|
+
}
|
|
749
|
+
assert.deepEqual(scene.getActor('door').components.Transform, { ...closed, rotationY: 0 }, 'wake keeps the closed pose');
|
|
750
|
+
idle.frame(scene, mp, player, true, 'town');
|
|
751
|
+
assert.equal(prompts.at(-1), 'Sit', `${profile}: cached sleeping bench offered on wake`);
|
|
752
|
+
pressSit();
|
|
753
|
+
idle.frame(scene, mp, player, true, 'town');
|
|
754
|
+
assert.deepEqual(sent.at(-1), { k: 'hub-sit', seat: 'bench' });
|
|
755
|
+
player.components.Transform.x = 14;
|
|
756
|
+
qualityPlayers(scene, q, 500);
|
|
757
|
+
assert.equal(q.pads, pads);
|
|
758
|
+
assert.equal(samePad(scene, player.components.Transform, scene.getActor('guest').components.Transform, pads), true);
|
|
759
|
+
assert.ok(q.drawn.has('guest-player'), `${profile}: cached pad exempts nearby guest`);
|
|
760
|
+
assert.deepEqual(talkActors(scene), [scene.getActor('npc')]);
|
|
761
|
+
assert.equal(q.npcs, npcCache);
|
|
762
|
+
// Preserve talkActors' live ID resolution even if its cache is retained.
|
|
763
|
+
scene.despawnActor('npc');
|
|
764
|
+
scene.spawnActor(inert('replacement', 14));
|
|
765
|
+
assert.deepEqual(talkActors(scene), []);
|
|
766
|
+
assert.equal(q.npcs, npcCache);
|
|
767
|
+
idle.dispose();
|
|
768
|
+
controller.restore();
|
|
769
|
+
}
|
|
770
|
+
} finally {
|
|
771
|
+
if (previousQuality === undefined) { delete deck.quality; } else { deck.quality = previousQuality; }
|
|
772
|
+
clearHub();
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
console.log('sleeping gameplay: Weakest/Middle return doors close, benches offer Sit, pad/NPC caches survive wake passed');
|
|
776
|
+
|
|
777
|
+
for (const weakest of [false, true]) {
|
|
778
|
+
const t = makeTiers({ weakest, storage: null });
|
|
779
|
+
assert.equal(t.set('weakest'), weakest);
|
|
780
|
+
if (weakest) {
|
|
781
|
+
assert.equal(t.current(), 'low');
|
|
782
|
+
assert.equal(t.weakest(), true);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
// Mode toggles use authored bounds even after gameplay moves a wall.
|
|
787
|
+
{
|
|
788
|
+
const h = fixture(),
|
|
789
|
+
controller = makeWeakestTier();
|
|
790
|
+
h.right.components.Transform.x = -10;
|
|
791
|
+
controller.frame(h.scene, true, 0);
|
|
792
|
+
assert.ok(h.scene.getActors().includes(h.right));
|
|
793
|
+
h.scene.files['models/generated.pxmodel'] = JSON.stringify({ parts: [], look: { outline: 2 } });
|
|
794
|
+
const generatedDuringWeakest = h.scene.files['models/generated.pxmodel'];
|
|
795
|
+
controller.restore();
|
|
796
|
+
assert.notEqual(h.scene.files['models/generated.pxmodel'], generatedDuringWeakest);
|
|
797
|
+
assert.equal(JSON.parse(h.scene.files['models/generated.pxmodel']).look.outline, 2);
|
|
798
|
+
controller.frame(h.scene, true, 1000);
|
|
799
|
+
assert.ok(h.scene.getActors().includes(h.right));
|
|
800
|
+
const packed = JSON.parse(h.scene.files['models/m.pxmodel']);
|
|
801
|
+
controller.restore();
|
|
802
|
+
assert.deepEqual(packed, JSON.parse(h.scene.files['models/m.pxmodel']));
|
|
803
|
+
}
|
|
804
|
+
// v1.121: real engine queue ordering/drain, with body/accessory geometries.
|
|
805
|
+
{
|
|
806
|
+
const { makeLookBake, queueLookBake, stepLookBake } = await import('../../physics-3d/engine3d/lookbake.js');
|
|
807
|
+
const { makeWeakestLookBake } = await import('../code/client/weakestLookBake.js');
|
|
808
|
+
const THREE = await import('three');
|
|
809
|
+
const queue = makeLookBake();
|
|
810
|
+
let clock = 0;
|
|
811
|
+
queue.now = () => clock;
|
|
812
|
+
const add = (owner) => {
|
|
813
|
+
const geometry = new THREE.BufferGeometry();
|
|
814
|
+
queueLookBake(queue, owner, [geometry], function* () { clock += 2; yield; clock += 2; });
|
|
815
|
+
return geometry;
|
|
816
|
+
};
|
|
817
|
+
const far = add('far'), near = add('near'), own = add('self'), hat = add('shared-hat');
|
|
818
|
+
add('unknown');
|
|
819
|
+
const actor = (id, x) => ({ id, components: { Transform: { x, z: 0 } } });
|
|
820
|
+
const actors = new Map([['self', actor('self', 100)], ['near', actor('near', 101)], ['far', actor('far', 200)]]);
|
|
821
|
+
const node = (...geometries) => { const root = new THREE.Group(); for (const geometry of geometries) root.add(new THREE.Mesh(geometry)); return root; };
|
|
822
|
+
const scene = {
|
|
823
|
+
actorWith: () => actors.get('self'), getActor: (id) => actors.get(id),
|
|
824
|
+
multiplayer: { placed: () => true },
|
|
825
|
+
three: { scene: new THREE.Scene(), nodes: new Map([
|
|
826
|
+
['far', { modelKey: 'far', node: node(far, hat) }],
|
|
827
|
+
['near', { modelKey: 'near', node: node(near) }],
|
|
828
|
+
['self', { modelKey: 'self', node: node(own, hat) }],
|
|
829
|
+
]) },
|
|
830
|
+
};
|
|
831
|
+
const policy = makeWeakestLookBake(queue);
|
|
832
|
+
policy.frame(scene, 0);
|
|
833
|
+
assert.deepEqual(queue.tasks.map((t) => t.owner), ['self', 'shared-hat', 'near', 'far', 'unknown']);
|
|
834
|
+
assert.equal(queue.budgetMs, 24);
|
|
835
|
+
assert.equal(queue.hubWeakest.placedAt, 0);
|
|
836
|
+
const renderTarget = scene.three.scene;
|
|
837
|
+
const installedAfter = renderTarget.onAfterRender;
|
|
838
|
+
// Real render-loop order: hub policy ran, then sync adds a model. The
|
|
839
|
+
// Three scene callback runs after drawing and before engine queue stepping.
|
|
840
|
+
const justSynced = add('new-self-accessory');
|
|
841
|
+
scene.three.nodes.get('self').node.add(new THREE.Mesh(justSynced));
|
|
842
|
+
assert.equal(queue.unsorted, true);
|
|
843
|
+
renderTarget.onAfterRender();
|
|
844
|
+
assert.equal(queue.unsorted, false);
|
|
845
|
+
assert.deepEqual(queue.tasks.slice(0, 3).map((t) => t.owner), ['self', 'shared-hat', 'new-self-accessory']);
|
|
846
|
+
const lateHat = add('late-hat');
|
|
847
|
+
scene.three.nodes.get('self').node.add(new THREE.Mesh(lateHat));
|
|
848
|
+
policy.frame(scene, 100);
|
|
849
|
+
assert.deepEqual(queue.tasks.slice(0, 3).map((t) => t.owner), ['self', 'shared-hat', 'new-self-accessory']);
|
|
850
|
+
const copy = own.clone();
|
|
851
|
+
scene.three.nodes.get('self').node.add(new THREE.Mesh(copy));
|
|
852
|
+
assert.ok(queue.tasks.find((t) => t.owner === 'self').geometries.includes(copy));
|
|
853
|
+
queue.tasks.find((t) => t.owner === 'far').started = true;
|
|
854
|
+
actors.get('near').components.Transform.x = 300;
|
|
855
|
+
policy.frame(scene, 350);
|
|
856
|
+
assert.equal(queue.tasks[0].owner, 'far');
|
|
857
|
+
policy.frame(scene, 15000);
|
|
858
|
+
assert.equal(queue.budgetMs, 32);
|
|
859
|
+
assert.equal(queue.hubWeakest.budgetMs, 32);
|
|
860
|
+
stepLookBake(queue);
|
|
861
|
+
assert.equal(queue.pending, 7);
|
|
862
|
+
while (queue.pending) stepLookBake(queue);
|
|
863
|
+
assert.equal(queue.baked, 7);
|
|
864
|
+
assert.equal(queue.shown, false);
|
|
865
|
+
stepLookBake(queue);
|
|
866
|
+
assert.equal(queue.shown, true);
|
|
867
|
+
policy.frame(scene, 16000);
|
|
868
|
+
assert.equal(queue.hubWeakest.shown, true);
|
|
869
|
+
policy.restore();
|
|
870
|
+
assert.notEqual(renderTarget.onAfterRender, installedAfter);
|
|
871
|
+
assert.equal(Object.hasOwn(renderTarget, 'onAfterRender'), false);
|
|
872
|
+
assert.equal(queue.budgetMs, 6);
|
|
873
|
+
assert.equal(Object.hasOwn(queue, 'hubWeakest'), false);
|
|
874
|
+
}
|
|
875
|
+
for (const bounded of [false, true]) {
|
|
876
|
+
const h = fixture(), controller = makeWeakestTier();
|
|
877
|
+
const { makeLookBake } = await import('../../physics-3d/engine3d/lookbake.js');
|
|
878
|
+
const queue = makeLookBake();
|
|
879
|
+
h.scene.three = { lookBake: queue, nodes: new Map() };
|
|
880
|
+
h.scene.multiplayer = { placed: () => false };
|
|
881
|
+
controller.frame(h.scene, true, 0, bounded);
|
|
882
|
+
assert.equal(queue.skipSurfaceBakes, !bounded);
|
|
883
|
+
assert.equal(queue.budgetMs, bounded ? 24 : 6);
|
|
884
|
+
assert.equal(Object.hasOwn(queue, 'hubWeakest'), bounded);
|
|
885
|
+
assert.equal(h.scene.bakesLookLater, true);
|
|
886
|
+
if (bounded) {
|
|
887
|
+
controller.frame(h.scene, true, 1, false);
|
|
888
|
+
assert.equal(queue.skipSurfaceBakes, true);
|
|
889
|
+
assert.equal(queue.budgetMs, 6);
|
|
890
|
+
assert.equal(Object.hasOwn(queue, 'hubWeakest'), false);
|
|
891
|
+
}
|
|
892
|
+
controller.restore();
|
|
893
|
+
assert.equal(queue.budgetMs, 6);
|
|
894
|
+
assert.equal(Object.hasOwn(queue, 'skipSurfaceBakes'), false);
|
|
895
|
+
assert.equal(Object.hasOwn(queue, 'hubWeakest'), false);
|
|
896
|
+
assert.equal(h.scene.files, h.files);
|
|
897
|
+
assert.equal(Object.hasOwn(h.scene, 'bakesLookLater'), false);
|
|
898
|
+
}
|
|
899
|
+
console.log('bounded Weakest look: self/accessory/distance ordering, real drain and exact restoration passed');
|
|
900
|
+
|
|
901
|
+
{
|
|
902
|
+
const { makeLookBake } = await import('../../physics-3d/engine3d/lookbake.js');
|
|
903
|
+
const { makeWeakestLookBake } = await import('../code/client/weakestLookBake.js');
|
|
904
|
+
const THREE = await import('three');
|
|
905
|
+
for (const replaced of [false, true]) {
|
|
906
|
+
const target = new THREE.Scene(), queue = makeLookBake();
|
|
907
|
+
let calls = 0;
|
|
908
|
+
const prior = function (arg) { assert.equal(this, target); assert.equal(arg, 'draw'); calls += 1; };
|
|
909
|
+
target.onAfterRender = prior;
|
|
910
|
+
const policy = makeWeakestLookBake(queue);
|
|
911
|
+
policy.frame({ three: { scene: target }, multiplayer: { placed: () => false } }, 0);
|
|
912
|
+
const installed = target.onAfterRender;
|
|
913
|
+
target.onAfterRender('draw');
|
|
914
|
+
assert.equal(calls, 1);
|
|
915
|
+
const replacement = function (...args) { installed.apply(this, args); };
|
|
916
|
+
if (replaced) target.onAfterRender = replacement;
|
|
917
|
+
queue.budgetMs = 17; // another owner changed it; restore must not clobber.
|
|
918
|
+
policy.restore();
|
|
919
|
+
assert.equal(target.onAfterRender, replaced ? replacement : prior);
|
|
920
|
+
assert.equal(queue.budgetMs, 17);
|
|
921
|
+
target.onAfterRender('draw');
|
|
922
|
+
assert.equal(calls, 2);
|
|
923
|
+
}
|
|
924
|
+
}
|