castle-web-cli 0.4.233 → 0.4.235
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/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 +17 -2
- package/dist/castle-host/host.js +793 -36
- package/dist/castleJson.d.ts +20 -1
- package/dist/castleJson.js +44 -2
- package/dist/check.js +9 -2
- 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 +3 -1
- 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/index.js +8 -2
- package/dist/init.js +1 -1
- package/dist/save-deck.d.ts +20 -1
- package/dist/save-deck.js +141 -5
- package/dist/serve.js +29 -11
- package/dist/shell/assets/{index-BjOxR-lW.js → index-DulbYIJm.js} +97 -97
- package/dist/shell/index.html +1 -1
- package/dist/vitePlugins.d.ts +2 -1
- package/dist/vitePlugins.js +13 -0
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +266 -3
- package/kits/base/sdk/castle.d.ts +7 -3
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +162 -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 +33 -6
- package/kits/base/sdk/hub.js +68 -5
- package/kits/base/sdk/hubRejoin.d.ts +4 -0
- package/kits/base/sdk/hubRejoin.js +15 -0
- package/kits/base/sdk/multiplayer.d.ts +7 -1
- package/kits/base/sdk/multiplayer.js +147 -40
- 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 +79 -6
- package/kits/base/sdk/server/hub.d.ts +31 -1
- package/kits/base/sdk/server/hub.js +50 -3
- package/kits/base/sdk/server/platformHandle.d.ts +13 -1
- package/kits/base/sdk/server/storage.d.ts +4 -0
- package/kits/base/sdk/server/storage.js +19 -3
- package/kits/base/sdk/server/wrapper.d.ts +7 -1
- package/kits/base/sdk/server/wrapper.js +10 -1
- package/kits/base/sdk/social.d.ts +9 -0
- package/kits/base/sdk/social.js +5 -0
- package/kits/hub-game/CLAUDE.md +123 -3
- package/kits/hub-game/README.md +63 -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/arrivalCamera.js +50 -0
- package/kits/hub-game/code/client/askSlot.js +117 -0
- package/kits/hub-game/code/client/avatar.js +4 -2
- package/kits/hub-game/code/client/avatarShare.js +2 -0
- package/kits/hub-game/code/client/backVisibility.js +13 -0
- package/kits/hub-game/code/client/ballot.js +15 -10
- package/kits/hub-game/code/client/build.js +16 -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 +1148 -258
- package/kits/hub-game/code/client/crowdNames.js +241 -0
- package/kits/hub-game/code/client/decor.js +10 -4
- 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/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 +31 -11
- package/kits/hub-game/code/client/hookLayer.js +87 -8
- 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 +14 -2
- 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/labelsNear.js +31 -2
- 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/menuRows.js +43 -0
- package/kits/hub-game/code/client/modelReady.js +7 -0
- 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/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 +64 -10
- 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/state.js +53 -0
- package/kits/hub-game/code/client/talk.js +209 -45
- package/kits/hub-game/code/client/tiers.js +68 -66
- package/kits/hub-game/code/client/together.js +7 -2
- 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/worldLabels.js +241 -0
- package/kits/hub-game/code/client/yours.js +10 -9
- package/kits/hub-game/code/npcDisplayText.js +55 -0
- package/kits/hub-game/code/server/act.js +124 -0
- package/kits/hub-game/code/server/actions.js +6 -1
- package/kits/hub-game/code/server/actors.js +2 -1
- 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/companion.js +28 -3
- package/kits/hub-game/code/server/doorAnalytics.js +52 -0
- package/kits/hub-game/code/server/earned.js +22 -5
- package/kits/hub-game/code/server/frameBatch.js +183 -0
- package/kits/hub-game/code/server/friendsAmong.js +49 -9
- package/kits/hub-game/code/server/history.js +2 -0
- package/kits/hub-game/code/server/hub.js +1306 -95
- package/kits/hub-game/code/server/idle.js +30 -1
- package/kits/hub-game/code/server/index.js +26 -4
- package/kits/hub-game/code/server/invites.js +19 -0
- package/kits/hub-game/code/server/labels.js +9 -1
- package/kits/hub-game/code/server/loadAbandon.js +106 -0
- package/kits/hub-game/code/server/manifest.js +211 -3
- package/kits/hub-game/code/server/menu.js +31 -3
- package/kits/hub-game/code/server/npcs.js +226 -64
- 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/players.js +9 -1
- 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/standing.js +4 -5
- package/kits/hub-game/code/server/storageLimit.js +187 -0
- package/kits/hub-game/code/server/vis.js +67 -5
- package/kits/hub-game/code/shared/act.js +35 -0
- package/kits/hub-game/code/shared/danceIdle.js +28 -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 +35 -1
- package/kits/hub-game/code/systems/hub.js +970 -169
- package/kits/hub-game/docs/analytics.md +279 -0
- package/kits/hub-game/docs/contract.md +1259 -42
- package/kits/hub-game/docs/home-pieces.md +9 -2
- package/kits/hub-game/docs/observed-progress.md +252 -0
- package/kits/hub-game/main.jsx +2 -0
- package/kits/hub-game/package-lock.json +10 -3
- package/kits/hub-game/package.json +6 -3
- 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 +39 -5
- package/kits/hub-game/scripts/companion-follower-wire.json +1 -1
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +11 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless.json +5 -5
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +3 -0
- package/kits/hub-game/scripts/fixtures/fake-dom.mjs +19 -3
- package/kits/hub-game/scripts/fixtures/interest-legacy.json +3 -3
- package/kits/hub-game/scripts/fixtures/vis-shared-wire.json +1 -1
- package/kits/hub-game/scripts/pose-storage-fixture.mjs +46 -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 +367 -2
- package/kits/hub-game/scripts/test-actors.mjs +20 -7
- 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-slot.mjs +85 -0
- package/kits/hub-game/scripts/test-avatar-wire.mjs +49 -10
- package/kits/hub-game/scripts/test-avatar.mjs +44 -0
- package/kits/hub-game/scripts/test-back-visibility.mjs +82 -0
- package/kits/hub-game/scripts/test-ballot.mjs +11 -4
- package/kits/hub-game/scripts/test-ban-join.mjs +121 -13
- package/kits/hub-game/scripts/test-build.mjs +20 -2
- package/kits/hub-game/scripts/test-chat.mjs +206 -5
- package/kits/hub-game/scripts/test-companion-chat.mjs +20 -2
- 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 +45 -4
- package/kits/hub-game/scripts/test-decor.mjs +7 -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.mjs +33 -3
- 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-grab-orbit.mjs +47 -4
- package/kits/hub-game/scripts/test-high-only.mjs +170 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +321 -2
- package/kits/hub-game/scripts/test-hub-trip.mjs +879 -11
- package/kits/hub-game/scripts/test-hud-clear.mjs +162 -59
- 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 +66 -0
- package/kits/hub-game/scripts/test-interest-cells.mjs +20 -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-labels.mjs +71 -3
- 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 +265 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +105 -0
- package/kits/hub-game/scripts/test-menu.mjs +23 -0
- package/kits/hub-game/scripts/test-npcs.mjs +917 -10
- package/kits/hub-game/scripts/test-observed.mjs +745 -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 +234 -7
- 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 +699 -5
- 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 +145 -0
- package/kits/hub-game/scripts/test-signin-client.mjs +45 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +22 -17
- package/kits/hub-game/scripts/test-standing.mjs +35 -2
- package/kits/hub-game/scripts/test-storage-limit.mjs +333 -0
- package/kits/hub-game/scripts/test-stuck.mjs +5 -4
- package/kits/hub-game/scripts/test-talk-overlay-dom.mjs +130 -0
- package/kits/hub-game/scripts/test-tiers-render.mjs +86 -13
- package/kits/hub-game/scripts/test-tiers.mjs +7 -8
- package/kits/hub-game/scripts/test-vis.mjs +433 -6
- 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 +50 -6
- package/kits/hub-game/scripts/test-yours.mjs +39 -8
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/joinFailure.js +27 -0
- package/kits/multiplayer-3d/code/client/resumeGate.js +139 -0
- package/kits/multiplayer-3d/code/systems/multiplayer.js +369 -30
- package/kits/multiplayer-3d/package-lock.json +8 -1
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +436 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +624 -0
- package/kits/physics-2d/CLAUDE.md +10 -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 +87 -5
- 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-3d/CLAUDE.md +25 -1651
- 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 +35 -18
- 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 +1 -1
- package/kits/physics-3d/engine3d/PlayOnly3D.jsx +5 -1
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +19 -333
- package/kits/physics-3d/engine3d/actornode.js +1 -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/framecap.js +4 -1
- 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 +8 -0
- package/kits/physics-3d/engine3d/initialModelFiles.js +18 -0
- package/kits/physics-3d/engine3d/look.js +7 -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 +3 -3
- package/kits/physics-3d/engine3d/nearshadows.js +77 -10
- package/kits/physics-3d/engine3d/orbitinput.js +59 -25
- 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 +3 -3
- 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 +23 -15
- package/kits/physics-3d/engine3d/sky.js +1 -1
- 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/world3d.js +468 -18
- package/kits/physics-3d/eslint.config.js +2 -1
- package/kits/physics-3d/main.jsx +6 -3
- 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/test-camera-follow.mjs +5 -1
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +52 -4
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +1 -1
- package/kits/physics-3d/scripts/test-empty-gait-hints.mjs +89 -0
- package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +6 -3
- package/kits/physics-3d/scripts/test-frame-cap.mjs +1 -1
- 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-look-bake.mjs +1 -1
- package/kits/physics-3d/scripts/test-near-shadows.mjs +2 -2
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +88 -7
- package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +40 -3
- package/kits/physics-3d/scripts/test-orbit-shot.mjs +75 -1
- package/kits/physics-3d/scripts/test-rapier-gz.mjs +106 -0
- package/kits/physics-3d/scripts/test-sky.mjs +1 -1
- package/kits/physics-3d/scripts/test-square-first.mjs +921 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +3 -1
- package/kits/physics-3d/scripts/test-static-physics.mjs +4 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +5 -2
- package/kits/physics-3d/scripts/test-steady-hover.mjs +5 -2
- package/kits/physics-3d/scripts/test-still-shadows.mjs +477 -0
- package/kits/physics-3d/systems/physics3d.js +37 -4
- 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/session.js +6 -4
- package/kits/real-time/package-lock.json +1 -1
- package/package.json +2 -2
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
// bounds, taken out beyond that. High draws it as authored; NPCs keep their
|
|
24
24
|
// own distance rule, and keep always wins over distance. `"tier": "low"`
|
|
25
25
|
// draws only on Low, at any distance; High takes its node out instead.
|
|
26
|
-
//
|
|
27
|
-
// reads null (`skyOff` below), so the engine makes no dome and uploads no art.
|
|
26
|
+
// Both tiers draw the kit sky when the scene declares `engine.sky`.
|
|
28
27
|
// A scene file may also carry visibility cells (`readCells` below): on Low an
|
|
29
28
|
// actor tagged with cells the camera's cell cannot see is not drawn, `keep`
|
|
30
29
|
// or not -- keep is about distance, a cell about what is in the way.
|
|
@@ -39,6 +38,7 @@
|
|
|
39
38
|
// over all of it.
|
|
40
39
|
|
|
41
40
|
import { Box3, Sphere } from 'three';
|
|
41
|
+
import { classify } from '../shared/quality.js';
|
|
42
42
|
import { hub, deck } from './state.js';
|
|
43
43
|
|
|
44
44
|
export const TIERS = ['low', 'high'];
|
|
@@ -76,6 +76,19 @@ const WEAK_GPUS = [
|
|
|
76
76
|
/Adreno\D*(?:[34]\d\d|50\d)\b/i,
|
|
77
77
|
];
|
|
78
78
|
|
|
79
|
+
export function weakestGpu(renderer) {
|
|
80
|
+
// Moto's native WebView names the GE8320 driver Doma. Match that exact
|
|
81
|
+
// alias, not the unrelated numbered SGX family or other Doma variants.
|
|
82
|
+
return typeof renderer === 'string' && (
|
|
83
|
+
/PowerVR(?: Rogue)? GE8\d{2,3}\b/i.test(renderer) ||
|
|
84
|
+
/\bPowerVR SGX (?:Doma|\(Doma\))(?=\s*(?:[,)]|$))/i.test(renderer)
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function middleGpu(renderer) {
|
|
89
|
+
return typeof renderer === 'string' && /Mali-G52 MC[12]\b/i.test(renderer);
|
|
90
|
+
}
|
|
91
|
+
|
|
79
92
|
export function weakGpu(renderer) {
|
|
80
93
|
return typeof renderer === 'string' && WEAK_GPUS.some((re) => re.test(renderer));
|
|
81
94
|
}
|
|
@@ -112,9 +125,9 @@ export function writeJson(storage, key, value) {
|
|
|
112
125
|
}
|
|
113
126
|
}
|
|
114
127
|
|
|
115
|
-
export function readMode(storage) {
|
|
128
|
+
export function readMode(storage, weakest = false) {
|
|
116
129
|
const mode = readJson(storage, MODE_KEY);
|
|
117
|
-
return MODES.includes(mode) ? mode : 'auto';
|
|
130
|
+
return MODES.includes(mode) || (weakest && mode === 'weakest') ? mode : 'auto';
|
|
118
131
|
}
|
|
119
132
|
|
|
120
133
|
// Where a device starts: found slow here within the week, then its hints.
|
|
@@ -182,9 +195,7 @@ export function makeJudge() {
|
|
|
182
195
|
// (scenery: those plus Solid or Lookable, or a Shape with `solid`) or 'game'
|
|
183
196
|
// (anything else, never
|
|
184
197
|
// touched: doors, pads, players, balls, the town's own pieces).
|
|
185
|
-
|
|
186
|
-
const DECOR = new Set(['Transform', 'Shape', 'Model']);
|
|
187
|
-
const SCENERY = new Set(['Transform', 'Shape', 'Model', 'Solid', 'Lookable']);
|
|
198
|
+
export { classify } from '../shared/quality.js';
|
|
188
199
|
|
|
189
200
|
// The mark a scene file puts on an actor (`"tier": "keep"`, a field of the
|
|
190
201
|
// actor beside `id`) to have it drawn on every tier whatever `classify` says
|
|
@@ -194,24 +205,9 @@ const SCENERY = new Set(['Transform', 'Shape', 'Model', 'Solid', 'Lookable']);
|
|
|
194
205
|
export const KEEP = 'keep';
|
|
195
206
|
export const NEAR = 'near';
|
|
196
207
|
export const LOW = 'low';
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
// physics-3d makes an actor's collider block when it has `Solid` or its
|
|
201
|
-
// Shape says `solid` (physics3d.js `isSolid`); either way it is scenery that
|
|
202
|
-
// stops a player, never decor.
|
|
203
|
-
const solid = names.includes('Solid') || Boolean(components?.Shape?.solid);
|
|
204
|
-
if (names.includes('HubNpc')) {
|
|
205
|
-
return 'npc';
|
|
206
|
-
}
|
|
207
|
-
if (names.some((name) => GAMEPLAY.test(name))) {
|
|
208
|
-
return 'game';
|
|
209
|
-
}
|
|
210
|
-
if (!solid && names.every((name) => DECOR.has(name))) {
|
|
211
|
-
return 'decor';
|
|
212
|
-
}
|
|
213
|
-
return names.every((name) => SCENERY.has(name)) ? 'static' : 'game';
|
|
214
|
-
}
|
|
208
|
+
// High-only decor remains ordinary decor in the Low pass below, never kept
|
|
209
|
+
// or near scenery and never a protected actor for visibility cells.
|
|
210
|
+
export const HIGH = 'high';
|
|
215
211
|
|
|
216
212
|
// Visibility cells: a scene file may cut its ground into cells and say, for
|
|
217
213
|
// each, which cells can be seen from somewhere in it (a top-level `cells`
|
|
@@ -379,7 +375,7 @@ function nodeBounds(node) {
|
|
|
379
375
|
// replaces nodes (a scene load, a door trip and the way back, the town's nodes
|
|
380
376
|
// parked and put back: world3d.js `swapSceneNodes` adds a parked node back to
|
|
381
377
|
// the scene); `restore` puts back exactly what it changed.
|
|
382
|
-
export function makeLevers({ boundsOf = nodeBounds } = {}) {
|
|
378
|
+
export function makeLevers({ boundsOf = nodeBounds, onLayout } = {}) {
|
|
383
379
|
const lv = {
|
|
384
380
|
world: null,
|
|
385
381
|
active: false,
|
|
@@ -387,8 +383,6 @@ export function makeLevers({ boundsOf = nodeBounds } = {}) {
|
|
|
387
383
|
lights: new Set(),
|
|
388
384
|
// node -> the parent it was taken out of.
|
|
389
385
|
removed: new WeakMap(),
|
|
390
|
-
// The runtime whose `sky` reads null for Low (`skyOff`), or null.
|
|
391
|
-
skyOff: null,
|
|
392
386
|
// Shared model instances draw outside the actor graph: hide their
|
|
393
387
|
// detached Low-only root too, preserving its authored visibility.
|
|
394
388
|
visibility: new WeakMap(),
|
|
@@ -554,6 +548,22 @@ export function makeLevers({ boundsOf = nodeBounds } = {}) {
|
|
|
554
548
|
lv.removed.delete(node);
|
|
555
549
|
};
|
|
556
550
|
|
|
551
|
+
// Deferred model fills preserve node identity, so bounds cached for an
|
|
552
|
+
// empty rig must be forgotten. Classification itself is read every pass.
|
|
553
|
+
// Only subscribe in an engine.load world; keyless worlds stay untouched.
|
|
554
|
+
let modelFillScene = null;
|
|
555
|
+
const modelFilled = ({ node }) => {
|
|
556
|
+
lv.bounds.delete(node);
|
|
557
|
+
lv.nextAt = 0;
|
|
558
|
+
};
|
|
559
|
+
const watchModelFills = (world) => {
|
|
560
|
+
const scene = world?.modelLoad ? world.scene : null;
|
|
561
|
+
if (scene === modelFillScene) {return;}
|
|
562
|
+
modelFillScene?.removeEventListener('modelfilled', modelFilled);
|
|
563
|
+
modelFillScene = scene;
|
|
564
|
+
modelFillScene?.addEventListener('modelfilled', modelFilled);
|
|
565
|
+
};
|
|
566
|
+
|
|
557
567
|
const far = (node, near, cam, sized, at) => {
|
|
558
568
|
const p = at && [at.x, at.y, at.z].every(Number.isFinite) ? at : node.position;
|
|
559
569
|
let b = { dx: 0, dy: 0, dz: 0, r: 0 };
|
|
@@ -606,6 +616,7 @@ export function makeLevers({ boundsOf = nodeBounds } = {}) {
|
|
|
606
616
|
// A node already gone is as good as removed.
|
|
607
617
|
}
|
|
608
618
|
lv.overlay = null;
|
|
619
|
+
onLayout?.(null);
|
|
609
620
|
};
|
|
610
621
|
|
|
611
622
|
// The tuning overlay (`?hubcells=1`): which cell the eye is in, what is out
|
|
@@ -621,6 +632,7 @@ export function makeLevers({ boundsOf = nodeBounds } = {}) {
|
|
|
621
632
|
el.style.cssText = 'position:fixed;top:4px;left:4px;z-index:2147483647;pointer-events:none;font:11px/1.35 monospace;color:#fff;background:rgba(0,0,0,.65);padding:4px 6px;white-space:pre;border-radius:3px';
|
|
622
633
|
globalThis.document.body.appendChild(el);
|
|
623
634
|
lv.overlay = el;
|
|
635
|
+
onLayout?.(el);
|
|
624
636
|
}
|
|
625
637
|
const y = world.camera?.position?.y;
|
|
626
638
|
const pop = lv.pop;
|
|
@@ -741,29 +753,6 @@ export function makeLevers({ boundsOf = nodeBounds } = {}) {
|
|
|
741
753
|
return false;
|
|
742
754
|
};
|
|
743
755
|
|
|
744
|
-
// The kit sky off while Low. physics-3d draws what the runtime's `sky`
|
|
745
|
-
// getter answers (the scene's parsed `engine.sky`, or null) and reads it
|
|
746
|
-
// afresh every frame, releasing a dome whose key is gone; it has no switch
|
|
747
|
-
// of its own. So Low puts an own `sky` of null on the runtime, over the
|
|
748
|
-
// getter, and leaving Low deletes it: the getter answers again and the
|
|
749
|
-
// next frame makes the sky. `skyZone` is not touched (nothing steps it).
|
|
750
|
-
// Never on High, so a deck that is never Low has no such property.
|
|
751
|
-
const skyOff = (scene) => {
|
|
752
|
-
const held = lv.skyOff;
|
|
753
|
-
if (held && held !== scene) {
|
|
754
|
-
if (Object.getOwnPropertyDescriptor(held, 'sky')?.value === null) {
|
|
755
|
-
delete held.sky;
|
|
756
|
-
}
|
|
757
|
-
lv.skyOff = null;
|
|
758
|
-
}
|
|
759
|
-
if (scene && !lv.skyOff) {
|
|
760
|
-
if (!Object.hasOwn(scene, 'sky')) {
|
|
761
|
-
Object.defineProperty(scene, 'sky', { value: null, configurable: true, enumerable: false });
|
|
762
|
-
}
|
|
763
|
-
lv.skyOff = scene;
|
|
764
|
-
}
|
|
765
|
-
};
|
|
766
|
-
|
|
767
756
|
// Each frame: Low applies its rules; High hides only low-marked actors.
|
|
768
757
|
// tiers run in the runtime's update, before the player loads a requested
|
|
769
758
|
// scene and builds its nodes: a low-marked node built in a frame is drawn
|
|
@@ -773,19 +762,13 @@ export function makeLevers({ boundsOf = nodeBounds } = {}) {
|
|
|
773
762
|
// or put back, actors come or gone, the scene loaded again: new scene data
|
|
774
763
|
// may carry other `tier` marks over the same nodes). `actors` false (a game reached through
|
|
775
764
|
// a door: another deck's content) puts scenery back and keeps only the
|
|
776
|
-
// shadow lever
|
|
765
|
+
// shadow lever and the place's own hidden actors.
|
|
777
766
|
const update = (world, scene, now, { actors = true, tier = LOW } = {}) => {
|
|
778
767
|
adopt(world);
|
|
768
|
+
watchModelFills(world);
|
|
779
769
|
const isLow = tier === LOW;
|
|
780
770
|
lv.active = isLow;
|
|
781
|
-
// Whatever scene plays, a game reached through a door included. It
|
|
782
|
-
// stays over a scene load, so a keyed scene loaded on Low never draws
|
|
783
|
-
// or uploads its sky, not even for the frame of the load.
|
|
784
|
-
// A scene load asked for this frame runs right after this update, before
|
|
785
|
-
// the draw. Its reset releases a sky made on High by the key it reads, so
|
|
786
|
-
// Low does not start hiding the key in that frame, only from the next.
|
|
787
771
|
const loading = Boolean(scene.requestedScene);
|
|
788
|
-
skyOff(isLow && (lv.skyOff === scene || !loading) ? scene : null);
|
|
789
772
|
if (!isLow) {
|
|
790
773
|
if (loading) {
|
|
791
774
|
// And the load may reuse a node for the next scene's actor of the
|
|
@@ -857,8 +840,8 @@ export function makeLevers({ boundsOf = nodeBounds } = {}) {
|
|
|
857
840
|
// left to the engine), every shadow on again.
|
|
858
841
|
lv.restore = (world) => {
|
|
859
842
|
adopt(world);
|
|
843
|
+
watchModelFills(null);
|
|
860
844
|
wakeSleeping();
|
|
861
|
-
skyOff(null);
|
|
862
845
|
for (const entry of world.nodes.values()) {
|
|
863
846
|
if (entry?.node && lv.removed.has(entry.node)) {
|
|
864
847
|
unhide(entry.node);
|
|
@@ -909,20 +892,24 @@ function pageStorage() {
|
|
|
909
892
|
|
|
910
893
|
// The hub system's tiers: `frame(scene, counts, now)` each frame. `counts` is
|
|
911
894
|
// whether this frame says how the device draws the place (see `makeJudge`).
|
|
912
|
-
export function makeTiers({ storage = pageStorage(), clock = () => Date.now(), deviceMemory = globalThis.navigator?.deviceMemory ?? null, levers = makeLevers() } = {}) {
|
|
895
|
+
export function makeTiers({ storage = pageStorage(), clock = () => Date.now(), deviceMemory = globalThis.navigator?.deviceMemory ?? null, onLayout, levers = makeLevers({ onLayout }), weakest = false } = {}) {
|
|
913
896
|
const t = {
|
|
914
|
-
mode: readMode(storage),
|
|
897
|
+
mode: readMode(storage, weakest),
|
|
915
898
|
auto: null,
|
|
916
899
|
judge: makeJudge(),
|
|
917
900
|
levers,
|
|
918
901
|
last: null,
|
|
902
|
+
weakestDevice: false,
|
|
903
|
+
middleDevice: false,
|
|
919
904
|
};
|
|
920
905
|
|
|
921
|
-
t.current = () => (t.mode === 'auto' ? (t.auto?.tier ?? 'high') : t.mode);
|
|
906
|
+
t.current = () => (t.mode === 'weakest' ? 'low' : t.mode === 'auto' ? (t.auto?.tier ?? 'high') : t.mode);
|
|
907
|
+
t.weakest = () => weakest && t.current() === 'low' && (t.mode === 'weakest' || t.weakestDevice);
|
|
908
|
+
t.middle = () => weakest && t.current() === 'low' && t.middleDevice && !t.weakest();
|
|
922
909
|
t.reason = () => (t.mode === 'auto' ? (t.auto?.reason ?? 'auto') : 'manual');
|
|
923
910
|
|
|
924
911
|
t.set = (mode) => {
|
|
925
|
-
if (!MODES.includes(mode)) {
|
|
912
|
+
if (!MODES.includes(mode) && !(weakest && mode === 'weakest')) {
|
|
926
913
|
return false;
|
|
927
914
|
}
|
|
928
915
|
t.mode = mode;
|
|
@@ -932,13 +919,25 @@ export function makeTiers({ storage = pageStorage(), clock = () => Date.now(), d
|
|
|
932
919
|
return true;
|
|
933
920
|
};
|
|
934
921
|
|
|
922
|
+
// Also used before load by the quality entry; frame timing still starts on frame one.
|
|
923
|
+
t.pick = (renderer) => {
|
|
924
|
+
// Hints are read once, from the renderer the place is drawn with.
|
|
925
|
+
if (t.auto === null) {
|
|
926
|
+
const gpu = gpuOf(renderer);
|
|
927
|
+
t.weakestDevice = weakest && weakestGpu(gpu);
|
|
928
|
+
t.middleDevice = weakest && middleGpu(gpu);
|
|
929
|
+
t.auto = initialTier({ storage, now: clock(), gpu, deviceMemory });
|
|
930
|
+
if (t.weakestDevice) { t.auto = { tier: 'low', reason: 'gpu' }; }
|
|
931
|
+
}
|
|
932
|
+
return t.current();
|
|
933
|
+
};
|
|
934
|
+
|
|
935
935
|
t.frame = (scene, counts, now) => {
|
|
936
936
|
const world = scene.three;
|
|
937
937
|
if (!world) {
|
|
938
938
|
return;
|
|
939
939
|
}
|
|
940
|
-
|
|
941
|
-
t.auto ??= initialTier({ storage, now: clock(), gpu: gpuOf(world.renderer), deviceMemory });
|
|
940
|
+
t.pick(world.renderer);
|
|
942
941
|
const dt = t.last === null ? 0 : now - t.last;
|
|
943
942
|
t.last = now;
|
|
944
943
|
if (t.mode === 'auto' && t.auto.tier === 'high') {
|
|
@@ -990,5 +989,8 @@ export function makeTiers({ storage = pageStorage(), clock = () => Date.now(), d
|
|
|
990
989
|
cells: (on) => levers.setCells?.(on),
|
|
991
990
|
set: (mode) => t.set(mode),
|
|
992
991
|
};
|
|
992
|
+
// Local diagnostics only until the analytics transport preserves quality.
|
|
993
|
+
if (deck.quality) {Object.defineProperty(t.handle, 'quality', { enumerable: true, get: () => deck.quality?.low.decor });}
|
|
994
|
+
if (weakest) { Object.defineProperty(t.handle, 'profile', { enumerable: true, get: () => t.weakest() ? 'weakest' : t.middle() ? 'middle' : t.current() }); }
|
|
993
995
|
return t;
|
|
994
996
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// too far away to see. A game draws none of it.
|
|
6
6
|
|
|
7
7
|
import { deck, hub } from './state.js';
|
|
8
|
+
import { guestName } from './signIn.js';
|
|
8
9
|
import { NAME_NEAR_M } from './attention.js';
|
|
9
10
|
|
|
10
11
|
// How often the place is asked where the tracked players are.
|
|
@@ -327,7 +328,7 @@ export function makeTogether() {
|
|
|
327
328
|
key: `p:${playerId}`,
|
|
328
329
|
playerId,
|
|
329
330
|
userId,
|
|
330
|
-
username: username || null,
|
|
331
|
+
username: hub.guests?.has(playerId) ? guestName(username) : username || null,
|
|
331
332
|
rank: t?.party ? 0 : t?.friend ? 1 : 3,
|
|
332
333
|
mark: t?.party ? '● ' : t?.friend ? '★ ' : '',
|
|
333
334
|
where: town ? (hub.whereAt[playerId]?.where ?? 'in town') : null,
|
|
@@ -345,6 +346,9 @@ export function makeTogether() {
|
|
|
345
346
|
if (typeof f.door === 'string' && !door) {
|
|
346
347
|
continue;
|
|
347
348
|
}
|
|
349
|
+
// At home in their own House behind that door (a host that says so):
|
|
350
|
+
// Join visits that owner's House, not this player's own.
|
|
351
|
+
const owner = door && f.home === true && typeof f.ownerUserId === 'string' && /^[1-9]\d{0,9}$/.test(f.ownerUserId) ? f.ownerUserId : null;
|
|
348
352
|
here.push({
|
|
349
353
|
key: `u:${f.userId}`,
|
|
350
354
|
playerId: null,
|
|
@@ -352,9 +356,10 @@ export function makeTogether() {
|
|
|
352
356
|
username: f.username ?? null,
|
|
353
357
|
rank: 2,
|
|
354
358
|
mark: '★ ',
|
|
355
|
-
where: door ? `inside ${door.title ?? 'a game'}` : 'in another part of town',
|
|
359
|
+
where: owner ? `inside ${f.username ? `${f.username}'s` : 'their'} House` : door ? `inside ${door.title ?? 'a game'}` : 'in another part of town',
|
|
356
360
|
actions: [{ id: door ? 'door' : 'jump', text: 'Join' }],
|
|
357
361
|
door: door?.id ?? null,
|
|
362
|
+
...(owner ? { owner } : {}),
|
|
358
363
|
});
|
|
359
364
|
}
|
|
360
365
|
// A stable sort: each group keeps the roster's order.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Client-only policy for the opted-in Weakest picture. The engine still owns
|
|
2
|
+
// task stepping, geometry disposal/clones and the first-drawn-frame fence.
|
|
3
|
+
import { orderLookBake } from '@imports/castle.physics-3d/engine3d/lookbake';
|
|
4
|
+
|
|
5
|
+
export function makeWeakestLookBake(queue) {
|
|
6
|
+
const previousBudget = queue.budgetMs;
|
|
7
|
+
const stats = { budgetMs: 24, placedAt: null, pending: queue.pending, shown: false };
|
|
8
|
+
let nextOrder = -Infinity;
|
|
9
|
+
let renderTarget = null;
|
|
10
|
+
let previousAfter = null;
|
|
11
|
+
let afterRender = null;
|
|
12
|
+
let ownedAfter = false;
|
|
13
|
+
let lastNow = 0;
|
|
14
|
+
let active = true;
|
|
15
|
+
queue.hubWeakest = stats;
|
|
16
|
+
|
|
17
|
+
function frame(scene, now) {
|
|
18
|
+
if (scene.multiplayer?.placed?.() === true && stats.placedAt === null) {stats.placedAt = now;}
|
|
19
|
+
// A bounded catch-up budget, never a deadline that discards work. Phone QA
|
|
20
|
+
// decides whether all visible looks meet 30 s and the whole queue 60 s.
|
|
21
|
+
stats.budgetMs = stats.placedAt !== null && now - stats.placedAt >= 15000 ? 32 : 24;
|
|
22
|
+
queue.budgetMs = stats.budgetMs;
|
|
23
|
+
stats.pending = queue.pending;
|
|
24
|
+
stats.shown = queue.shown;
|
|
25
|
+
lastNow = now;
|
|
26
|
+
attachRender(scene);
|
|
27
|
+
order(scene, now);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function order(scene, now) {
|
|
31
|
+
if (!queue.pending || (!queue.unsorted && now < nextOrder)) {return;}
|
|
32
|
+
nextOrder = now + 250;
|
|
33
|
+
const player = scene.actorWith('Player');
|
|
34
|
+
const p = player?.components?.Transform;
|
|
35
|
+
if (!p || !Number.isFinite(p.x) || !Number.isFinite(p.z)) {return;}
|
|
36
|
+
const geometries = new Map();
|
|
37
|
+
const owners = new Map();
|
|
38
|
+
const nearest = (map, key, distance) => {
|
|
39
|
+
if (key != null && !(distance >= map.get(key))) {map.set(key, distance);}
|
|
40
|
+
};
|
|
41
|
+
for (const [id, entry] of scene.three.nodes) {
|
|
42
|
+
// Unbuilt models own no look task yet. Do not promote every waiting
|
|
43
|
+
// model just to sort; a fill adds tasks and marks the queue unsorted.
|
|
44
|
+
if (entry.modelWait) {continue;}
|
|
45
|
+
const actor = scene.getActor(id);
|
|
46
|
+
const at = actor?.components?.Transform;
|
|
47
|
+
if (!at || !Number.isFinite(at.x) || !Number.isFinite(at.z)) {continue;}
|
|
48
|
+
const distance = id === player.id ? 0 : 1 + (at.x - p.x) ** 2 + (at.z - p.z) ** 2;
|
|
49
|
+
nearest(owners, entry.modelKey, distance);
|
|
50
|
+
// Accessories have their own shared model keys. Geometry membership
|
|
51
|
+
// gives them the closest wearer's priority, including the local player.
|
|
52
|
+
entry.node.traverse((node) => nearest(geometries, node.geometry, distance));
|
|
53
|
+
}
|
|
54
|
+
for (const task of queue.tasks) {
|
|
55
|
+
for (const geometry of task.geometries) {nearest(owners, task.owner, geometries.get(geometry) ?? Number.MAX_VALUE);}
|
|
56
|
+
}
|
|
57
|
+
orderLookBake(queue, (owner) => owners.get(owner) ?? Number.MAX_VALUE);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function releaseRender() {
|
|
61
|
+
if (renderTarget?.onAfterRender === afterRender) {
|
|
62
|
+
if (ownedAfter) {renderTarget.onAfterRender = previousAfter;}
|
|
63
|
+
else {delete renderTarget.onAfterRender;}
|
|
64
|
+
}
|
|
65
|
+
renderTarget = previousAfter = afterRender = null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function attachRender(scene) {
|
|
69
|
+
const target = scene.three.scene;
|
|
70
|
+
if (!target || target === renderTarget) {return;}
|
|
71
|
+
releaseRender();
|
|
72
|
+
renderTarget = target;
|
|
73
|
+
ownedAfter = Object.hasOwn(target, 'onAfterRender');
|
|
74
|
+
previousAfter = target.onAfterRender;
|
|
75
|
+
const prior = previousAfter;
|
|
76
|
+
afterRender = function (...args) {
|
|
77
|
+
prior?.apply(this, args);
|
|
78
|
+
// Models are synchronized after the hub update. This fence sees newly
|
|
79
|
+
// queued models before world3d.bakeLooks can sort or start any task.
|
|
80
|
+
if (active && renderTarget === target) {order(scene, lastNow);}
|
|
81
|
+
};
|
|
82
|
+
target.onAfterRender = afterRender;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function restore() {
|
|
86
|
+
active = false;
|
|
87
|
+
releaseRender();
|
|
88
|
+
if (queue.budgetMs === stats.budgetMs) {queue.budgetMs = previousBudget;}
|
|
89
|
+
if (queue.hubWeakest === stats) {delete queue.hubWeakest;}
|
|
90
|
+
}
|
|
91
|
+
return { frame, restore };
|
|
92
|
+
}
|