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
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { register } from 'node:module';
|
|
5
|
+
import * as THREE from 'three';
|
|
6
|
+
import { readManifest } from '../code/server/manifest.js';
|
|
7
|
+
import { actorReferences, QUALITY_RANGES, readQuality } from '../code/shared/quality.js';
|
|
8
|
+
import { deck, hub, clear as clearState } from '../code/client/state.js';
|
|
9
|
+
import { makeTiers, MODE_KEY, TIER_KEY } from '../code/client/tiers.js';
|
|
10
|
+
import { applyPlayerVisibility, capLabels, capWorldLabels, choosePlayers, filterQualityScene, lowQuality, makeQualityVisit,
|
|
11
|
+
mindDue, noteQualityInteraction, qualityFor, qualityPlayers, qualitySpawnIds, restoreDecor } from '../code/client/quality.js';
|
|
12
|
+
import { fps } from '../code/server/analytics.js';
|
|
13
|
+
import * as labelsNear from '../code/client/labelsNear.js';
|
|
14
|
+
const { chromeItem, labelBox, near, nearFor } = labelsNear;
|
|
15
|
+
// Present only once the HUD layout snapshot lands; render() passes it through.
|
|
16
|
+
const nearCandidates = labelsNear.nearCandidates;
|
|
17
|
+
import { relevantLabels } from '../code/client/worldLabels.js';
|
|
18
|
+
import { makeFpsTelemetry, fpsTelemetryFor, setFpsTelemetry } from '../code/client/fpsTelemetry.js';
|
|
19
|
+
import { templatesOf } from '../code/server/actors.js';
|
|
20
|
+
import check from './check.mjs';
|
|
21
|
+
|
|
22
|
+
// Real engine load/sync. Only Vite discovery is replaced, as in test-tiers-render.
|
|
23
|
+
const stubs = {
|
|
24
|
+
'castle-web-sdk': `export const isEdit = () => true; export const resolveDeckFile = (name) => String(name).replace(/^\\.\\//, '');
|
|
25
|
+
export const deckPrefixOf = () => ''; export const IMPORTS_DIR = 'imports'; export const IMPORTS_PREFIX = 'imports/';`,
|
|
26
|
+
'./files': 'export const initialFiles = {}; export const parseJsonFile = (p, t) => ({ value: JSON.parse(t) }); export const formatJson = JSON.stringify;',
|
|
27
|
+
'./systemRegistry': 'export const systemInstallers = [];', './fonts': "export const deckFontFamily = 'sans-serif';",
|
|
28
|
+
};
|
|
29
|
+
register('data:text/javascript,' + encodeURIComponent(`
|
|
30
|
+
import { existsSync, readFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url';
|
|
31
|
+
const stubs = ${JSON.stringify(stubs)};
|
|
32
|
+
export async function resolve(specifier, context, next) {
|
|
33
|
+
const parent = context.parentURL ?? '';
|
|
34
|
+
if ((parent.includes('/physics-2d/engine/') || specifier === 'castle-web-sdk') && stubs[specifier])
|
|
35
|
+
return { url: 'data:text/javascript,' + encodeURIComponent(stubs[specifier]), shortCircuit: true };
|
|
36
|
+
const alias = /^@imports\\/castle\\.([^/]+)\\/(.*)$/.exec(specifier);
|
|
37
|
+
if (alias) specifier = parent.replace(/\\/kits\\/.*/, '/kits/' + alias[1] + '/') + alias[2];
|
|
38
|
+
if ((specifier.startsWith('.') || specifier.startsWith('file:')) && parent.includes('/kits/') && !/\\.(m?js|jsx|json)$/.test(specifier)) {
|
|
39
|
+
const base = new URL(specifier, parent).href;
|
|
40
|
+
if (existsSync(fileURLToPath(base + '.js'))) return next(base + '.js', context);
|
|
41
|
+
}
|
|
42
|
+
return next(specifier, context);
|
|
43
|
+
}
|
|
44
|
+
export async function load(url, context, next) {
|
|
45
|
+
if (url.endsWith('/qualityEntry.js')) return { format: 'module', shortCircuit: true,
|
|
46
|
+
source: readFileSync(fileURLToPath(url), 'utf8').replace(/^const config = .*$/m, 'const config = {};').replace(/^const sources = .*$/m, 'const sources = {};') };
|
|
47
|
+
return next(url, context);
|
|
48
|
+
}
|
|
49
|
+
`));
|
|
50
|
+
const { initialFiles } = await import('data:text/javascript,' + encodeURIComponent(stubs['./files']));
|
|
51
|
+
const { SceneRuntime } = await import('../../physics-2d/engine/scene.js');
|
|
52
|
+
const { syncActors } = await import('../../physics-3d/engine3d/world3d.js');
|
|
53
|
+
const { installQualityLoad } = await import('../code/client/qualityEntry.js');
|
|
54
|
+
let count = 0;
|
|
55
|
+
async function test(name, fn) { await fn(); count++; console.log(`ok: ${name}`); }
|
|
56
|
+
const base = { hub: { contract: 1, title: 'Quality', tiers: true }, server: { maxPlayers: 8 } };
|
|
57
|
+
const config = (low = {}) => ({ ...base, hub: { ...base.hub, quality: { low } } });
|
|
58
|
+
const enable = (low = {}) => { deck.tiers = true; deck.quality = readQuality({ low }, true, []); };
|
|
59
|
+
const actor = (id, components = {}, extra = {}) => ({ id, ...extra, components: { Transform: { x: 0, y: 0, z: -5 }, Shape: { kind: 'box', width: 1, height: 1, depth: 1, color: '#888888' }, ...components } });
|
|
60
|
+
const authored = { actors: [actor('decor'), actor('ground', { Solid: {} }), actor('player', { Player: {} }),
|
|
61
|
+
actor('keep', {}, { tier: 'keep' }), actor('low', {}, { tier: 'low' }), actor('near', {}, { tier: 'near' }),
|
|
62
|
+
actor('pad', { HubPad: {} }), actor('door', { HubDoor: {} }), actor('npc', { HubNpc: {} }),
|
|
63
|
+
actor('template', {}, { decor: true }), actor('spawn-target', {}, { tier: 'keep' }), actor('script-target', {}, { tier: 'keep' })] };
|
|
64
|
+
function makeWorld() {
|
|
65
|
+
const world = { scene: new THREE.Scene(), camera: new THREE.PerspectiveCamera(), renderer: {}, nodes: new Map(),
|
|
66
|
+
scenePath: undefined, parked: new Map(), models: new Map(), skipping: { on: false }, modelSigs: new Map(),
|
|
67
|
+
sigEpoch: 0, syncCount: 0, syncDepth: 0, generation: 0, snapshots: new WeakMap(), instances: new Map(),
|
|
68
|
+
ground: new THREE.Mesh(new THREE.PlaneGeometry(1, 1), new THREE.MeshStandardMaterial()), grid: new THREE.Object3D(), sky: null };
|
|
69
|
+
world.scene.add(world.ground, world.grid); return world;
|
|
70
|
+
}
|
|
71
|
+
const makeTier = (mode) => () => { const t = makeTiers({ storage: null, deviceMemory: 8 }); t.set(mode); return t; };
|
|
72
|
+
const adapt = (mode, options = {}) => installQualityLoad(SceneRuntime, { make: makeTier(mode), pick: (t) => t.pick(null),
|
|
73
|
+
componentsOf: (_s, a) => a.components, protectedIds: new Set(['spawn-target', 'script-target']), ...options });
|
|
74
|
+
|
|
75
|
+
await test('manifest: objects, unknown keys, tiers, all bounds and reserved physicsHz', () => {
|
|
76
|
+
assert.deepEqual(readManifest(config({ physicsHz: 15 })).errors, []);
|
|
77
|
+
assert.equal(readManifest(config({ physicsHz: 15 })).manifest.quality.low.physicsHz, 15);
|
|
78
|
+
for (const [key, [min, max]] of Object.entries(QUALITY_RANGES)) {
|
|
79
|
+
for (const value of [min, max]) assert.deepEqual(readManifest(config({ [key]: value })).errors, []);
|
|
80
|
+
for (const value of [min - 1, max + 1, 1.5, '4', null, false]) {
|
|
81
|
+
const errors = readManifest(config({ [key]: value })).errors.join();
|
|
82
|
+
assert.ok(errors.includes(`hub.quality.low.${key}`) && errors.includes(String(min)) && errors.includes(String(max)), errors);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
for (const decor of ['skip', 'hide']) assert.deepEqual(readManifest(config({ decor })).errors, []);
|
|
86
|
+
assert.match(readManifest(config({ decor: 'remove' })).errors.join(), /decor.*skip.*hide/);
|
|
87
|
+
for (const quality of [null, false, [], 'skip', 1]) assert.match(readManifest({ ...base, hub: { ...base.hub, quality } }).errors.join(), /hub.quality.*object/);
|
|
88
|
+
for (const low of [null, [], false, 'low']) assert.match(readManifest({ ...base, hub: { ...base.hub, quality: { low } } }).errors.join(), /hub.quality.low.*object/);
|
|
89
|
+
assert.match(readManifest(config({ typo: 1 })).errors.join(), /hub.quality.low.typo/);
|
|
90
|
+
assert.match(readManifest({ ...base, hub: { ...base.hub, quality: { high: {} } } }).errors.join(), /hub.quality.high/);
|
|
91
|
+
for (const tiers of [false, undefined]) assert.match(readManifest({ ...config(), hub: { ...config().hub, tiers } }).errors.join(), /quality requires hub.tiers: true/);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
await test('absent quality: identical manifest, actor/node trace and template bytes; no hint/storage calls', () => {
|
|
95
|
+
delete deck.quality;
|
|
96
|
+
const before = new SceneRuntime(authored, [], {}, {}, 'scenes/main.scene'); before.three = makeWorld(); syncActors(before.three, before, {});
|
|
97
|
+
let calls = 0; const undo = adapt('low', { make: () => { calls++; throw new Error('off'); }, pick: () => calls++ });
|
|
98
|
+
try {
|
|
99
|
+
const after = new SceneRuntime(authored, [], {}, {}, 'scenes/main.scene'); after.three = makeWorld(); syncActors(after.three, after, {});
|
|
100
|
+
assert.equal(JSON.stringify(after.data), JSON.stringify(before.data));
|
|
101
|
+
assert.deepEqual([...after.actors.keys()], [...before.actors.keys()]); assert.deepEqual([...after.three.nodes.keys()], [...before.three.nodes.keys()]);
|
|
102
|
+
assert.equal(calls, 0); assert.equal(qualityFor(after), undefined);
|
|
103
|
+
} finally { undo(); }
|
|
104
|
+
const result = readManifest(base); assert.equal(Object.hasOwn(result.manifest, 'quality'), false);
|
|
105
|
+
assert.equal(JSON.stringify(result), JSON.stringify(readManifest({ ...base, hub: { ...base.hub, quality: undefined } })));
|
|
106
|
+
const h = { spawned: new Map([['copy', { from: 'template' }]]), actors: [actor('template')] };
|
|
107
|
+
assert.equal(JSON.stringify(templatesOf(h)), JSON.stringify({ template: h.actors[0].components }));
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
await test('tier before load: manual beats history, history beats GPU/memory; judge starts on first frame', () => {
|
|
111
|
+
enable();
|
|
112
|
+
for (const [mode, history, gpu, mem, expected] of [
|
|
113
|
+
['low', null, 'Metal', 8, 'low'], ['high', { tier: 'low', at: 100 }, 'Mali-G52 MC2', 2, 'high'],
|
|
114
|
+
['auto', { tier: 'low', at: 100 }, 'Metal', 8, 'low'], ['auto', null, 'Mali-G52 MC2', 8, 'low'],
|
|
115
|
+
['auto', null, 'Metal', 2, 'low'], ['auto', null, 'Metal', 8, 'high'],
|
|
116
|
+
]) {
|
|
117
|
+
const storage = { getItem: (key) => JSON.stringify(key === MODE_KEY ? mode : key === TIER_KEY ? history : null) };
|
|
118
|
+
const undo = adapt('low', { make: () => makeTiers({ storage, clock: () => 101, deviceMemory: mem }),
|
|
119
|
+
pick: (t) => t.pick({ getContext: () => ({ getExtension: () => null, getParameter: () => gpu }) }) });
|
|
120
|
+
try {
|
|
121
|
+
const scene = new SceneRuntime(authored, [], {}, {}, 'scenes/main.scene');
|
|
122
|
+
assert.equal(qualityFor(scene).tiers.current(), expected); assert.equal(scene.actors.has('decor'), expected === 'high');
|
|
123
|
+
assert.equal(qualityFor(scene).tiers.last, null);
|
|
124
|
+
} finally { undo(); }
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
await test('skip builds no decor actors/nodes on Low; High/hide build all; protects gameplay and authored files', () => {
|
|
129
|
+
for (const [mode, decor] of [['low', 'skip'], ['high', 'skip'], ['low', 'hide']]) {
|
|
130
|
+
enable({ decor }); const serialized = JSON.stringify(authored); const undo = adapt(mode);
|
|
131
|
+
try {
|
|
132
|
+
const scene = new SceneRuntime(authored, [], {}, {}, 'scenes/main.scene'); scene.three = makeWorld(); syncActors(scene.three, scene, {});
|
|
133
|
+
assert.equal(scene.actors.has('decor'), mode !== 'low' || decor !== 'skip'); assert.equal(scene.three.nodes.has('decor'), scene.actors.has('decor'));
|
|
134
|
+
for (const a of authored.actors.filter((a) => a.id !== 'decor')) assert.ok(scene.getActor(a.id), a.id);
|
|
135
|
+
assert.equal(JSON.stringify(authored), serialized);
|
|
136
|
+
} finally { undo(); }
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
await test('blueprint-resolved colliders survive the early filter; visual-only blueprints can be skipped', () => {
|
|
141
|
+
enable(); const undo = adapt('low', { componentsOf: undefined });
|
|
142
|
+
try {
|
|
143
|
+
const files = { 'solid.scene': JSON.stringify({ actors: [{ components: { Solid: {}, Shape: { solid: true } } }] }),
|
|
144
|
+
'visual.scene': JSON.stringify({ actors: [{ components: { Shape: { kind: 'box' } } }] }) };
|
|
145
|
+
const scene = new SceneRuntime({ actors: [actor('solid', {}, { blueprint: 'solid.scene' }), actor('visual', {}, { blueprint: 'visual.scene' })] }, [], {}, files, 'main.scene');
|
|
146
|
+
assert.ok(scene.getActor('solid')); assert.equal(scene.getActor('visual'), undefined);
|
|
147
|
+
} finally { undo(); }
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
await test('Low→High measured 8 ms admission slices include sync; downgrade retains actors; reload resets queue', () => {
|
|
151
|
+
enable(); const undo = adapt('low');
|
|
152
|
+
try {
|
|
153
|
+
const data = { actors: Array.from({ length: 12 }, (_, n) => actor(`d${n}`)) };
|
|
154
|
+
initialFiles['scenes/main.scene'] = JSON.stringify(data);
|
|
155
|
+
const scene = new SceneRuntime(data, [], {}, {}, 'scenes/main.scene');
|
|
156
|
+
scene.three = makeWorld(); syncActors(scene.three, scene, {}); const q = qualityFor(scene); assert.equal(q.skipped.length, 12);
|
|
157
|
+
q.tiers.set('high'); let time = 0, slices = 0;
|
|
158
|
+
while (q.skipped.length) {
|
|
159
|
+
const start = time, before = scene.actors.size;
|
|
160
|
+
restoreDecor(scene, q, (s) => { syncActors(s.three, s, {}); time += 2; }, () => time);
|
|
161
|
+
assert.ok(time - start <= 8); assert.ok(scene.actors.size > before); slices++;
|
|
162
|
+
}
|
|
163
|
+
assert.ok(slices > 1); assert.equal(scene.three.nodes.size, 12);
|
|
164
|
+
q.tiers.set('low'); q.tiers.frame(scene, false, 16); assert.equal(scene.actors.size, 12);
|
|
165
|
+
assert.equal([...scene.three.nodes.values()].filter((e) => e.node.parent).length, 0);
|
|
166
|
+
scene.load({ actors: [actor('new-decor')] }); assert.deepEqual(q.skipped.map((a) => a.id), ['new-decor']);
|
|
167
|
+
scene.content = { id: 'other' }; scene.load(authored); assert.equal(scene.actors.size, authored.actors.length);
|
|
168
|
+
} finally { undo(); }
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
await test('players: 2 m hysteresis; party, pad, 10 s chat/emote exemptions; retained state and first-frame/new-node cap', () => {
|
|
172
|
+
const players = [{ id: 'a', distance: 10 }, { id: 'b', distance: 9 }, { id: 'party', distance: 100, exempt: true }];
|
|
173
|
+
assert.deepEqual([...choosePlayers(players, 1)], ['party', 'b']); assert.deepEqual([...choosePlayers(players, 1, new Set(['a']))], ['party', 'a']);
|
|
174
|
+
players[1].distance = 7; assert.ok(choosePlayers(players, 1, new Set(['a'])).has('b'));
|
|
175
|
+
enable({ players: 1 }); clearState();
|
|
176
|
+
const actors = [actor('self', { Transform: { x: 0, z: 0 }, Player: {} }), actor('a', { Transform: { x: 8, z: 0 } }),
|
|
177
|
+
actor('b', { Transform: { x: 9, z: 0 } }), actor('party', { Transform: { x: 80, z: 0 } }),
|
|
178
|
+
actor('on-pad', { Transform: { x: 1, z: 0 } }), actor('pad', { Transform: { x: 0, z: 0 }, HubPad: { radius: 2 } })];
|
|
179
|
+
const scene = new SceneRuntime({ actors }, [], {}, {}, 'scene'); scene.three = makeWorld();
|
|
180
|
+
scene.multiplayer = { net: { selfId: () => 'me' }, avatars: { actors: new Map([['me', 'self'], ['a', 'a'], ['b', 'b'], ['party', 'party'], ['on-pad', 'on-pad']]) } };
|
|
181
|
+
const q = makeQualityVisit(makeTier('low')()); filterQualityScene(scene, scene.data, q); hub.party.members = ['party'];
|
|
182
|
+
qualityPlayers(scene, q, 0); assert.ok(q.culled.has('b')); assert.equal(q.drawn.size, 3);
|
|
183
|
+
syncActors(scene.three, scene, {}); scene.three.scene.onBeforeRender(); assert.equal(scene.three.nodes.get('b').node.visible, false);
|
|
184
|
+
const b = scene.getActor('b'); noteQualityInteraction(scene, 'b', 1); qualityPlayers(scene, q, 2); assert.equal(scene.three.nodes.get('b').node.visible, true);
|
|
185
|
+
qualityPlayers(scene, q, 10002); assert.equal(scene.three.nodes.get('b').node.visible, false);
|
|
186
|
+
hub.lastT = 12000; hub.emotes.b = { at: 12000, id: 'wave' }; qualityPlayers(scene, q, 12000); assert.equal(scene.three.nodes.get('b').node.visible, true);
|
|
187
|
+
hub.emotes.b = { at: 12000, id: 'wave' }; qualityPlayers(scene, q, 22001); assert.equal(scene.three.nodes.get('b').node.visible, false, 'snapshot cannot extend exemption');
|
|
188
|
+
const replacement = new THREE.Object3D(); scene.three.nodes.get('b').node = replacement; applyPlayerVisibility(scene, q);
|
|
189
|
+
assert.equal(replacement.visible, false); assert.equal(scene.getActor('b'), b);
|
|
190
|
+
q.tiers.set('high'); qualityPlayers(scene, q, 22002); assert.equal(replacement.visible, true);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
await test('first-frame cap also removes shared model instances and restores them on High', () => {
|
|
194
|
+
enable({ players: 1 }); clearState(); const undo = adapt('low');
|
|
195
|
+
try {
|
|
196
|
+
const files = { 'body.pxmodel': JSON.stringify({ format: 'pxmodel', look: false, parts: [{ id: 'box', kind: 'box', size: [1, 1, 1], color: '#888888' }] }) };
|
|
197
|
+
const remote = (id, x) => actor(id, { Body: {}, Transform: { x, y: 0, z: -5 }, Model: { file: 'body.pxmodel' } });
|
|
198
|
+
const scene = new SceneRuntime({ actors: [actor('self', { Player: {}, Transform: { x: 0, z: -5 } }), remote('a', 0), remote('b', 1)] }, [], {}, files, 'scene');
|
|
199
|
+
scene.three = makeWorld(); scene.three.instanceModels = true;
|
|
200
|
+
scene.multiplayer = { net: { selfId: () => 'me' }, avatars: { actors: new Map([['a', 'a'], ['b', 'b']]) } };
|
|
201
|
+
const q = qualityFor(scene); qualityPlayers(scene, q, 0);
|
|
202
|
+
syncActors(scene.three, scene, {});
|
|
203
|
+
const counts = () => [...scene.three.instances.values()].flatMap((group) => group.parts.map((part) => part.mesh?.count ?? 0));
|
|
204
|
+
assert.ok(counts().some((count) => count === 2));
|
|
205
|
+
scene.three.scene.onBeforeRender(); assert.ok(counts().every((count) => count <= 1));
|
|
206
|
+
q.tiers.set('high'); qualityPlayers(scene, q, 16); assert.ok(counts().some((count) => count === 2));
|
|
207
|
+
} finally { undo(); }
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
await test('labels: nearest N, zero and party exemption; pointers never enter the cap', () => {
|
|
211
|
+
const labels = [{ id: 'far', d: 12 }, { id: 'near', d: 2 }, { id: 'party', d: 100 }];
|
|
212
|
+
const pointers = [{ id: 'quest', kind: 'pointer' }, { id: 'door', kind: 'pointer' }, { id: 'home', kind: 'pointer' }];
|
|
213
|
+
assert.deepEqual(capLabels(labels, 1, (a) => a.d, (a) => a.id === 'party').map((a) => a.id), ['near', 'party']);
|
|
214
|
+
assert.deepEqual(capLabels(labels, 0, (a) => a.d, (a) => a.id === 'party').map((a) => a.id), ['party']); assert.deepEqual(capLabels([...labels, ...pointers], 0, (a) => a.d, (a) => a.id === 'party').map((a) => a.id), ['party', 'quest', 'door', 'home']);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// Run the production nearLabels method so exemptions and anchor metadata are
|
|
218
|
+
// checked at the seam where render ids are generated, after real admission.
|
|
219
|
+
function nearLabelFixture(placed, actors, { defaults = true, attention = {}, padOccupancy = false } = {}) {
|
|
220
|
+
const source = fs.readFileSync(new URL('../code/systems/hub.js', import.meta.url), 'utf8');
|
|
221
|
+
const start = source.indexOf(' nearLabels(scene, placed,');
|
|
222
|
+
const method = source.slice(start, source.indexOf('\n // The People list', start));
|
|
223
|
+
const render = new Function('Hub', 'nearFor', 'sceneKeyOf', 'nearCandidates', 'project', 'labelBox', 'chromeItem', 'relevantLabels', 'near',
|
|
224
|
+
`return function ${method.trim()}`)({ deck, hub }, nearFor, () => 'scene', nearCandidates,
|
|
225
|
+
(_cam, x) => ({ x: 200 + x * 40, y: 300 }), labelBox, chromeItem, relevantLabels, near);
|
|
226
|
+
const owner = { chrome: { measureLabel: () => ({ w: 60, h: 20 }) }, attention };
|
|
227
|
+
const scene = { data: {}, getActor: (id) => actors.get(id) };
|
|
228
|
+
return (now = 1000) => render.call(owner, scene, placed, { x: 0, z: 0 }, {}, { w: 1200, h: 600 }, now, padOccupancy, defaults);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
await test('door labels admitted by the three-slot 12/14 m rule are free at labels 0 and 1', () => {
|
|
232
|
+
enable();
|
|
233
|
+
const entry = (id, x) => ({ id, at: { x, y: 0, z: 0 }, label: { text: id, style: 'sign' }, always: true });
|
|
234
|
+
const placed = [entry('door-a', 5), entry('door-b', 7), entry('door-c', 9), entry('door-d', 11)];
|
|
235
|
+
const actors = new Map(placed.map(({ id, at }) => [id, { components: { Transform: at, HubDoor: {} } }]));
|
|
236
|
+
const admitted = nearLabelFixture(placed, actors)();
|
|
237
|
+
assert.deepEqual(admitted.map((item) => item.actorId), ['door-a', 'door-b', 'door-c']);
|
|
238
|
+
for (const limit of [0, 1]) {
|
|
239
|
+
assert.deepEqual(capWorldLabels(admitted, placed, { x: 0, z: 0 }, limit, new Set()), admitted);
|
|
240
|
+
}
|
|
241
|
+
const mixed = [placed[0], placed[1], entry('ordinary', 1)];
|
|
242
|
+
const mixedLabels = nearLabelFixture(mixed, actors)();
|
|
243
|
+
assert.equal(capWorldLabels(mixedLabels, mixed, { x: 0, z: 0 }, 1, new Set()).length, 3, 'doors consume no quality slots');
|
|
244
|
+
assert.equal(capWorldLabels(mixedLabels, mixed, { x: 0, z: 0 }, 0, new Set()).length, 3, 'every admitted caption is exempt');
|
|
245
|
+
const edge = [entry('door-a', 11.5)];
|
|
246
|
+
const atEdge = nearLabelFixture(edge, actors);
|
|
247
|
+
assert.equal(atEdge().length, 1);
|
|
248
|
+
edge[0].at.x = 13.5;
|
|
249
|
+
assert.equal(capWorldLabels(atEdge(1200), edge, { x: 0, z: 0 }, 0, new Set()).length, 1, 'retained through the hysteresis band');
|
|
250
|
+
edge[0].at.x = 14.1;
|
|
251
|
+
assert.equal(capWorldLabels(atEdge(1400), edge, { x: 0, z: 0 }, 0, new Set()).length, 0, 'quality never resurrects a door rejected by the near rule');
|
|
252
|
+
delete deck.quality;
|
|
253
|
+
assert.ok(nearLabelFixture(placed, actors)().every((item) => !Object.hasOwn(item, 'actorId') && !Object.hasOwn(item, 'qualityNear')), 'legacy render shape unchanged');
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
await test('HubPad and linked captions admitted in either near-label mode survive labels 0 and 1', () => {
|
|
257
|
+
enable();
|
|
258
|
+
for (const defaults of [true, false]) {
|
|
259
|
+
for (const components of [{ HubPad: { door: 'race' } }, { HubDoor: { id: 'race' } }, {}]) {
|
|
260
|
+
const placed = [{ id: 'pad-race', at: { x: 5, y: 0, z: 0 }, label: { text: 'Race · step on to play', style: 'tag' }, always: false }];
|
|
261
|
+
const actors = new Map([['pad-race', { components }]]);
|
|
262
|
+
const render = nearLabelFixture(placed, actors, { defaults, attention: { plate: 'pad-race' }, padOccupancy: true });
|
|
263
|
+
const admitted = render();
|
|
264
|
+
assert.equal(admitted.length, 1, 'caption is admitted at 5 m by the existing rule');
|
|
265
|
+
assert.equal(admitted[0].actorId, 'pad-race');
|
|
266
|
+
for (const limit of [0, 1]) {
|
|
267
|
+
assert.deepEqual(capWorldLabels(admitted, placed, { x: 0, z: 0 }, limit, new Set()), admitted);
|
|
268
|
+
const extra = { id: 'uncapped-rule-bystander', actorId: 'other', text: 'Other' };
|
|
269
|
+
const withExtra = [...placed, { id: 'other', at: { x: 2, y: 0, z: 0 } }];
|
|
270
|
+
assert.deepEqual(capWorldLabels([...admitted, extra], withExtra, { x: 0, z: 0 }, limit, new Set()),
|
|
271
|
+
limit === 0 ? admitted : [...admitted, extra], 'admitted caption consumes no quality slots');
|
|
272
|
+
}
|
|
273
|
+
placed.length = 0;
|
|
274
|
+
assert.deepEqual(render(1200), [], 'rule-rejected captions are never reintroduced');
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
await test('speech rendering ids rank by actor anchor: a 2 m line beats a 10 m sign', () => {
|
|
280
|
+
enable({ labels: 1 });
|
|
281
|
+
for (const npc of [false, true]) {
|
|
282
|
+
const placed = [
|
|
283
|
+
{ id: 'speaker', at: { x: 2, y: 0, z: 0 }, label: { text: 'Hello', style: 'speech', npc }, always: false },
|
|
284
|
+
{ id: 'sign', at: { x: 10, y: 0, z: 0 }, label: { text: 'Sign', style: 'sign' }, always: true },
|
|
285
|
+
];
|
|
286
|
+
// Labels from the unconstrained drawing path still use chromeItem's
|
|
287
|
+
// suffixed render ids, but have no near-rule admission exemption.
|
|
288
|
+
const rendered = placed.map(({ id, label }, index) => ({
|
|
289
|
+
...chromeItem(id, label.text, label.style === 'speech', npc && index === 0,
|
|
290
|
+
{ left: 200 + index * 200, right: 260 + index * 200, top: 280, bottom: 300 }, 1), actorId: id,
|
|
291
|
+
}));
|
|
292
|
+
const speech = rendered.find((item) => item.speech);
|
|
293
|
+
assert.notEqual(speech.id, 'speaker', 'exercise chromeItem suffix');
|
|
294
|
+
assert.equal(speech.actorId, 'speaker');
|
|
295
|
+
assert.deepEqual(capWorldLabels(rendered, placed, { x: 0, z: 0 }, 1, new Set()), [speech]);
|
|
296
|
+
assert.deepEqual(capWorldLabels(rendered, placed, { x: 0, z: 0 }, 0, new Set(['speaker'])), [speech], 'party exemption also uses the actor id');
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
await test('spawns: nearest decor only, cap zero, moving into range, gameplay intact, opt-in metadata', () => {
|
|
301
|
+
const templates = { scenery: { ...actor('t').components, decor: true }, gem: actor('gem', { Pickup: {} }).components };
|
|
302
|
+
const copies = { far: { from: 'scenery', x: 20, z: 0 }, near: { from: 'scenery', x: 1, z: 0 }, gem: { from: 'gem', x: 100, z: 0 } };
|
|
303
|
+
assert.deepEqual([...qualitySpawnIds(copies, templates, { x: 0, z: 0 }, 1)], ['gem', 'near']);
|
|
304
|
+
assert.deepEqual([...qualitySpawnIds(copies, templates, { x: 20, z: 0 }, 1)], ['gem', 'far']);
|
|
305
|
+
assert.deepEqual([...qualitySpawnIds(copies, templates, { x: 0, z: 0 }, 0)], ['gem']);
|
|
306
|
+
const h = { spawned: new Map([['copy', { from: 't' }]]), actors: [actor('t')] };
|
|
307
|
+
assert.equal(templatesOf(h).t.decor, undefined); h.qualityDecor = new Set(['t']); assert.equal(templatesOf(h).t.decor, true);
|
|
308
|
+
const source = fs.readFileSync(new URL('../code/systems/hub.js', import.meta.url), 'utf8');
|
|
309
|
+
const method = source.slice(source.indexOf(' applySpawns(scene) {'), source.indexOf('\n // Turning displays', source.indexOf(' applySpawns(scene) {')));
|
|
310
|
+
const apply = new Function('Hub', 'lowQuality', 'qualitySpawnIds', 'addSpinner', `return function ${method.trim()}`)({ deck, hub }, lowQuality, qualitySpawnIds, () => null);
|
|
311
|
+
enable({ spawned: 1 }); const scene = new SceneRuntime({ actors: [actor('self', { Player: {}, Transform: { x: 0, z: 0 } })] }, [], {}, {}, 'scene');
|
|
312
|
+
filterQualityScene(scene, scene.data, makeQualityVisit(makeTier('low')())); hub.spawnTemplates = templates; hub.spawned = copies;
|
|
313
|
+
const owner = { spawnedHere: new Set(), stash: new Map(), tinted: new Map() };
|
|
314
|
+
apply.call(owner, scene); assert.ok(scene.getActor('gem')); assert.ok(scene.getActor('near')); assert.equal(scene.getActor('far'), undefined);
|
|
315
|
+
assert.equal(Object.hasOwn(scene.getActor('near').components, 'decor'), false);
|
|
316
|
+
scene.actorWith('Player').components.Transform.x = 20; apply.call(owner, scene); assert.ok(scene.getActor('far')); assert.equal(scene.getActor('near'), undefined); assert.ok(scene.getActor('gem'));
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
await test('publish check: literal decor refs refused, spawn templates exempt, no-decor warning only with quality', async () => {
|
|
320
|
+
const root = fs.mkdtempSync(path.join(process.cwd(), '.quality-test-'));
|
|
321
|
+
try {
|
|
322
|
+
fs.mkdirSync(path.join(root, 'scenes')); fs.mkdirSync(path.join(root, 'code/server'), { recursive: true });
|
|
323
|
+
const json = { ...config(), server: { main: 'code/server/index.js', maxPlayers: 8 } };
|
|
324
|
+
fs.writeFileSync(path.join(root, 'castle.json'), JSON.stringify(json)); fs.writeFileSync(path.join(root, 'scenes/main.scene'), JSON.stringify(authored));
|
|
325
|
+
fs.writeFileSync(path.join(root, 'code/server/game.js'), "hub.hide('decor'); hub.spawn('spawn-target', {});");
|
|
326
|
+
let result = await check({ deckDir: root, self: true }); assert.ok(result.errors.some((e) => /script names decor actor "decor"/.test(e)));
|
|
327
|
+
assert.ok(!result.errors.some((e) => /script names decor actor "spawn-target"/.test(e)));
|
|
328
|
+
fs.writeFileSync(path.join(root, 'scenes/main.scene'), JSON.stringify({ actors: [actor('keep', {}, { tier: 'keep' })] }));
|
|
329
|
+
result = await check({ deckDir: root, self: true }); assert.deepEqual(result.errors, []); assert.ok(result.warnings.some((e) => /spawned.*no decor: true/.test(e)));
|
|
330
|
+
fs.writeFileSync(path.join(root, 'scenes/main.scene'), JSON.stringify({ actors: [actor('unsafe-template', { Solid: {} }, { decor: true })] }));
|
|
331
|
+
result = await check({ deckDir: root, self: true }); assert.ok(result.errors.some((e) => /decor: true.*no collider/.test(e)));
|
|
332
|
+
fs.writeFileSync(path.join(root, 'scenes/main.scene'), JSON.stringify({ actors: [actor('pure-template')] }));
|
|
333
|
+
fs.writeFileSync(path.join(root, 'code/server/game.js'), "hub.spawn('pure-template');");
|
|
334
|
+
result = await check({ deckDir: root, self: true }); assert.ok(result.errors.some((e) => /script names decor actor "pure-template"/.test(e)));
|
|
335
|
+
delete json.hub.quality; fs.writeFileSync(path.join(root, 'castle.json'), JSON.stringify(json)); result = await check({ deckDir: root, self: true });
|
|
336
|
+
assert.ok(!result.warnings.some((e) => /spawned/.test(e)));
|
|
337
|
+
const refs = actorReferences(["hub.move('x', {}); scene.getActor('y'); hub.spawn('t'); hub.hide(computed); const example = \"hub.hide('string-example')\"; // hub.hide('comment');"]);
|
|
338
|
+
assert.deepEqual([...refs.ids], ['x', 'y']); assert.deepEqual([...refs.templates], ['t']);
|
|
339
|
+
} finally { fs.rmSync(root, { recursive: true, force: true }); }
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
await test('far minds: cadence with near/talk-range/conversation/High/absent exemptions', () => {
|
|
343
|
+
enable({ farMindsHz: 4 }); const scene = new SceneRuntime({ actors: [] }, [], {}, {}, 'scene');
|
|
344
|
+
const q = makeQualityVisit(makeTier('low')()); filterQualityScene(scene, scene.data, q);
|
|
345
|
+
const npc = actor('npc', { Transform: { x: 30, z: 0 }, HubNpc: {} }); const me = { x: 0, z: 0 };
|
|
346
|
+
assert.equal(mindDue(scene, npc, me, null, 0), true);
|
|
347
|
+
for (const now of [1, 16, 100, 249]) assert.equal(mindDue(scene, npc, me, null, now), false);
|
|
348
|
+
assert.equal(mindDue(scene, npc, me, null, 250), true); assert.equal(mindDue(scene, npc, me, 'npc', 251), true);
|
|
349
|
+
npc.components.HubNpc.talkRange = 40; assert.equal(mindDue(scene, npc, me, null, 251), true);
|
|
350
|
+
delete npc.components.HubNpc.talkRange; npc.components.Transform.x = 2; assert.equal(mindDue(scene, npc, me, null, 251), true);
|
|
351
|
+
npc.components.Transform.x = 30; deck.lowActorDistance = true; npc.lowDrawDistance = 35; assert.equal(mindDue(scene, npc, me, null, 251), true); delete deck.lowActorDistance;
|
|
352
|
+
q.tiers.set('high'); assert.equal(mindDue(scene, npc, me, null, 251), true);
|
|
353
|
+
q.tiers.set('low'); delete deck.quality; assert.equal(mindDue(scene, npc, me, null, 251), true);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
await test('quality telemetry is deferred: local diagnostics retain it, wire and recorded measurements stay legacy', () => {
|
|
357
|
+
const source = fs.readFileSync(new URL('../code/systems/hub.js', import.meta.url), 'utf8');
|
|
358
|
+
const start = source.indexOf(' measure(scene, mp, now) {');
|
|
359
|
+
const method = source.slice(start, source.indexOf('\n dispose() {', start));
|
|
360
|
+
const measure = new Function('Hub', 'makeFpsTelemetry', 'fpsTelemetryFor', `return function ${method.trim()}`)(
|
|
361
|
+
{ deck, hub }, (options) => makeFpsTelemetry({ ...options, document: null, target: {} }), fpsTelemetryFor);
|
|
362
|
+
const record = (quality) => {
|
|
363
|
+
if (quality) {enable({ decor: quality });} else {delete deck.quality;}
|
|
364
|
+
const sent = [], net = { send: (message) => sent.push(message) };
|
|
365
|
+
setFpsTelemetry(net, { scene: 'scene' });
|
|
366
|
+
const scene = {}, mp = { net, avatars: { actors: new Map([['a', 'body']]) } };
|
|
367
|
+
const system = { scenePath: 'scene', fpsTier: 1, stats: false };
|
|
368
|
+
measure.call(system, scene, mp, 0); measure.call(system, scene, mp, 1000); system.fpsTelemetry.leave(); system.fpsTelemetry.dispose();
|
|
369
|
+
return sent[0];
|
|
370
|
+
};
|
|
371
|
+
const legacy = record(null);
|
|
372
|
+
assert.equal(Object.hasOwn(makeTier('low')().handle, 'quality'), false);
|
|
373
|
+
for (const quality of ['skip', 'hide']) {
|
|
374
|
+
const message = record(quality);
|
|
375
|
+
assert.equal(makeTier('low')().handle.quality, quality, 'quality remains available at __hub.tier.quality');
|
|
376
|
+
assert.equal(JSON.stringify(message), JSON.stringify(legacy), 'no unsupported field or measurement repacking');
|
|
377
|
+
const calls = [], h = { manifest: { quality: {} }, sim: { timeMs: 60000 }, place: { analytics: true, fpsTelemetry: { scene: 'scene' } },
|
|
378
|
+
players: new Map([['p', { arrived: true }]]), session: { hub: { track: (_id, data) => { calls.push(data); return true; } } } };
|
|
379
|
+
const session = { players: [{ playerId: 'p' }] };
|
|
380
|
+
assert.equal(fps(h, session, session.players[0], { ...message, quality }), false, 'server rejects unsupported quality field');
|
|
381
|
+
assert.equal(fps(h, session, session.players[0], message), true);
|
|
382
|
+
assert.deepEqual(calls[0], { kind: 26, subject: 1, value: message.median * 4096 + message.p10, result: 2, flags: 0 }, 'leave flags for Ghost attribution');
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
delete deck.quality; clearState(); console.log(`test-quality: ${count} passed`);
|