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,120 @@
|
|
|
1
|
+
// Real CSS geometry for the engine/kit control seam. Run with CHROME pointing
|
|
2
|
+
// to the QA browser (and BROWSER_WS when using a remote GPU browser).
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import { readFile } from 'node:fs/promises';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { chromium } from 'playwright-core';
|
|
7
|
+
import { launchChromium, logRenderer } from '../../../experiments/hub-town/qa/launch.mjs';
|
|
8
|
+
|
|
9
|
+
const root = new URL('../../../', import.meta.url);
|
|
10
|
+
const source = await readFile(new URL('../code/systems/hub.js', import.meta.url), 'utf8');
|
|
11
|
+
const setup = source.slice(source.indexOf(' this.chrome.setWorldLabelFocus'), source.indexOf(' Avatar.load(scene);'));
|
|
12
|
+
const browser = await launchChromium(chromium, { executablePath: process.env.CHROME });
|
|
13
|
+
try {
|
|
14
|
+
const page = await browser.newPage();
|
|
15
|
+
await page.route('http://layout.test/**', async route => {
|
|
16
|
+
const path = new URL(route.request().url()).pathname;
|
|
17
|
+
if (path === '/') return route.fulfill({ contentType: 'text/html', body: '<script type="importmap">{"imports":{"three":"/node_modules/three/build/three.module.js"}}</script><body style="margin:0"></body>' });
|
|
18
|
+
const url = new URL(`.${path}`, root);
|
|
19
|
+
assert(fileURLToPath(url).startsWith(fileURLToPath(root)));
|
|
20
|
+
await route.fulfill({ contentType: 'text/javascript', body: await readFile(url, 'utf8') });
|
|
21
|
+
});
|
|
22
|
+
for (const [width, height] of [[844, 390], [667, 375], [932, 430], [914, 411], [1440, 900]]) {
|
|
23
|
+
await page.setViewportSize({ width, height });
|
|
24
|
+
for (const mode of ['legacy', 'overflow', 'safe', 'act']) for (const input of ['touch', 'keyboard']) {
|
|
25
|
+
await page.goto('http://layout.test/');
|
|
26
|
+
await logRenderer(page, 'control layout');
|
|
27
|
+
const result = await page.evaluate(async ({ mode, input, setup }) => {
|
|
28
|
+
const { makeChrome } = await import('/kits/hub-game/code/client/chrome.js');
|
|
29
|
+
const { overlaps } = await import('/kits/hub-game/code/client/safeLayout.js');
|
|
30
|
+
const chrome = makeChrome({ avatarCount: 4, onBack() {}, onAvatar() {}, safeInsets: ['safe', 'act'].includes(mode) });
|
|
31
|
+
const soundChanges = [];
|
|
32
|
+
chrome.soundControl(true, { volume: 0.7, muted: false }, { onMuted: value => soundChanges.push(['muted', value]), onVolume: value => soundChanges.push(['volume', value]) });
|
|
33
|
+
chrome.showPicker(true, 0);
|
|
34
|
+
chrome.setEmotes([['wave', '👋']]); chrome.setSay({ reactions: [], phrases: [] });
|
|
35
|
+
chrome.setHud({ title: 'Town', text: 'Your next step is here.' }, null);
|
|
36
|
+
const { attachOrbitInput } = await import('/kits/physics-3d/engine3d/orbitinput.js');
|
|
37
|
+
const canvas = document.createElement('canvas'); document.body.append(canvas);
|
|
38
|
+
const runtime = { cameraControl: 'orbit', keys: new Set() };
|
|
39
|
+
const engine = attachOrbitInput(canvas, runtime, { set() {} }, () => {});
|
|
40
|
+
runtime.lookInput.listen();
|
|
41
|
+
if (input === 'keyboard') window.dispatchEvent(new KeyboardEvent('keydown', { code: 'KeyW' }));
|
|
42
|
+
else window.dispatchEvent(new PointerEvent('pointerdown', { pointerType: 'touch' }));
|
|
43
|
+
const scene = { persistent: {}, three: { renderer: { domElement: { parentElement: document.body } } } };
|
|
44
|
+
const Hub = { deck: { safeInsets: mode === 'safe', act: mode === 'act' }, hub: {} };
|
|
45
|
+
const context = { chrome };
|
|
46
|
+
const draw = () => {
|
|
47
|
+
new Function('Hub', 'scene', 'worldLabelFocus', setup).call(context, Hub, scene, () => false);
|
|
48
|
+
chrome.grabPrompt(null); chrome.sitPrompt(null); chrome.talkPrompt(null);
|
|
49
|
+
chrome.layoutInteractionRail();
|
|
50
|
+
chrome.setActions([{ id: 'invite-friend', label: 'Invite a friend' }], () => {}, true, 1, mode === 'overflow');
|
|
51
|
+
chrome.frameSafeInsets?.();
|
|
52
|
+
};
|
|
53
|
+
// The actual Act pair includes the talk pill and jump control.
|
|
54
|
+
if (mode === 'act') {
|
|
55
|
+
const { makeAct } = await import('/kits/hub-game/code/client/act.js');
|
|
56
|
+
const { hub } = await import('/kits/hub-game/code/client/state.js');
|
|
57
|
+
hub.place = { id: 'main', act: true };
|
|
58
|
+
hub.prompts = [{ id: 'rowan', verb: 'Talk to Rowan' }];
|
|
59
|
+
const actor = { id: 'rowan', components: { HubNpc: { name: 'Rowan' }, Transform: { x: 1, y: 1, z: 0 } } };
|
|
60
|
+
const act = makeAct(chrome, { perform() {} }, { prepare() {} });
|
|
61
|
+
Object.assign(scene, { getActors: () => [actor], getActor: () => actor, moveInput: { consumeJump() {} } });
|
|
62
|
+
scene.three.camera = { position: { clone: () => ({ set() { return this; }, project: () => ({ x: 0, y: 0, z: 0 }) }) } };
|
|
63
|
+
act.frame(scene, { net: { selfId: () => 'p', send() {} } }, { components: { Transform: { x: 0, y: 1, z: 0 } } }, true);
|
|
64
|
+
}
|
|
65
|
+
// Exercise the engine's cached cadence, including observer delivery
|
|
66
|
+
// before paint. A debug layout report would force a fresh measurement
|
|
67
|
+
// and conceal stale or drifting placement in the actual frame path.
|
|
68
|
+
const paint = () => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
69
|
+
draw(); await paint(); draw(); await paint();
|
|
70
|
+
await new Promise(resolve => setTimeout(resolve, 550));
|
|
71
|
+
for (let frame = 0; frame < 8; frame++) {draw(); await paint();}
|
|
72
|
+
chrome.setLabels([{ id: 'rowan', x: innerWidth - 32, y: 84, text: "Hi, I'm Rowan!", npc: true, speech: true, opacity: 1 }]);
|
|
73
|
+
chrome.flushWorldLabels();
|
|
74
|
+
const greeting = [...document.querySelectorAll('div')].find(node => node.textContent === "Hi, I'm Rowan!" && node.children.length === 0);
|
|
75
|
+
const soundBox = document.querySelector('[data-hub="sound"]').getBoundingClientRect();
|
|
76
|
+
const greetingHit = greeting && getComputedStyle(greeting).visibility !== 'hidden' && overlaps(greeting.getBoundingClientRect(), soundBox);
|
|
77
|
+
const nodes = [...document.querySelectorAll('button')].filter(node => ['Character', 'Invite a friend'].includes(node.textContent) || /^(Emote|Quick chat|Shift lock|Sound:)/.test(node.getAttribute('aria-label') ?? '') || ['act', 'jump', 'prompt'].includes(node.dataset.hubAct));
|
|
78
|
+
const controls = nodes.filter(node => node.getBoundingClientRect().width > 0 && getComputedStyle(node).visibility !== 'hidden').map(node => ({ name: node.getAttribute('aria-label') || node.textContent, ...Object.fromEntries(['left','right','top','bottom','width','height'].map(key => [key, node.getBoundingClientRect()[key]])) }));
|
|
79
|
+
const collisions = [];
|
|
80
|
+
for (let i = 0; i < controls.length; i++) for (let j = i + 1; j < controls.length; j++) if (overlaps(controls[i], controls[j])) collisions.push([controls[i].name, controls[j].name]);
|
|
81
|
+
const corners = [{ left: 0, right: 64, top: 0, bottom: 56 }, { left: innerWidth - 64, right: innerWidth, top: 0, bottom: 56 }];
|
|
82
|
+
const cornerHits = controls.filter(box => corners.some(corner => overlaps(box, corner)));
|
|
83
|
+
const outside = controls.filter(box => box.left < 0 || box.top < 0 || box.right > innerWidth || box.bottom > innerHeight);
|
|
84
|
+
const prompt = document.querySelector('[data-hub="hud-prompt"]');
|
|
85
|
+
const promptBox = prompt.getBoundingClientRect();
|
|
86
|
+
const hud = { text: prompt.textContent, visible: getComputedStyle(prompt).display !== 'none' && getComputedStyle(prompt).visibility !== 'hidden',
|
|
87
|
+
left: promptBox.left, right: promptBox.right, top: promptBox.top, bottom: promptBox.bottom, width: promptBox.width, height: promptBox.height };
|
|
88
|
+
const promptHits = controls.filter(box => overlaps(box, hud));
|
|
89
|
+
const sound = document.querySelector('[data-hub="sound"]');
|
|
90
|
+
sound.dispatchEvent(new PointerEvent('pointerdown'));
|
|
91
|
+
draw();
|
|
92
|
+
chrome.flushSafeInsets?.();
|
|
93
|
+
const card = document.querySelector('[data-hub="sound-card"]');
|
|
94
|
+
const popup = card.getBoundingClientRect();
|
|
95
|
+
const popupHits = nodes.filter(node => node !== sound && node.getBoundingClientRect().width > 0 && getComputedStyle(node).visibility !== 'hidden' && overlaps(node.getBoundingClientRect(), popup)).map(node => node.getAttribute('aria-label') || node.textContent);
|
|
96
|
+
const mute = [...card.querySelectorAll('button')][0], volume = card.querySelector('input');
|
|
97
|
+
const reachable = [mute, volume].every(node => { const r = node.getBoundingClientRect(); return node.contains(document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2)); });
|
|
98
|
+
mute.dispatchEvent(new PointerEvent('pointerdown'));
|
|
99
|
+
volume.value = '35'; volume.dispatchEvent(new Event('input'));
|
|
100
|
+
sound.dispatchEvent(new PointerEvent('pointerdown'));
|
|
101
|
+
engine.detach(); chrome.dispose(); canvas.remove();
|
|
102
|
+
return { greetingHit: Boolean(greetingHit), controls, collisions, cornerHits, outside, hud, promptHits, popupHits, reachable, soundChanges, height: innerHeight };
|
|
103
|
+
}, { mode, input, setup });
|
|
104
|
+
assert.equal(result.controls.length, (mode === 'act' ? 9 : 6) - (input === 'touch' ? 1 : 0), `${mode}: required controls and talk pill measured`);
|
|
105
|
+
assert.equal(result.controls.some(box => box.name.startsWith('Shift lock')), input === 'keyboard', 'Shift lock follows input modality');
|
|
106
|
+
assert.deepEqual(result.collisions, [], `${width}x${height} ${mode} ${input}`);
|
|
107
|
+
assert.deepEqual(result.cornerHits, [], 'reserved corners');
|
|
108
|
+
assert.deepEqual(result.outside, [], 'viewport bounds');
|
|
109
|
+
assert(result.hud.visible && result.hud.width > 0 && result.hud.height > 0, 'HUD prompt remains visible');
|
|
110
|
+
assert.equal(result.hud.text, 'Your next step is here.');
|
|
111
|
+
assert(result.hud.top > result.height / 2 && result.hud.bottom <= result.height - 54, 'HUD prompt retains its bottom band');
|
|
112
|
+
assert.deepEqual(result.promptHits, [], 'HUD prompt clears the controls');
|
|
113
|
+
assert.equal(result.greetingHit, false, 'Rowan greeting yields to Sound');
|
|
114
|
+
assert.deepEqual(result.popupHits, [], 'Sound popup clears the control column');
|
|
115
|
+
assert(result.reachable, 'Mute and Volume receive taps');
|
|
116
|
+
assert.deepEqual(result.soundChanges, [['muted', true], ['volume', 0.35]]);
|
|
117
|
+
console.log(`${width}x${height} ${mode} ${input}: ${result.controls.length} controls clear`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
} finally { await browser.close(); }
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import { crowdNamesFor, layoutCrowdNames, makeCrowdNames, MAX_CANDIDATES, MIN_FONT_PX, readableSpriteBox, spriteBox } from '../code/client/crowdNames.js';
|
|
4
|
+
import { placeLabels } from '../code/client/padOccupancy.js';
|
|
5
|
+
|
|
6
|
+
const box = (x, y = 80, w = 50, h = 20) => ({ left: x, right: x + w, top: y, bottom: y + h });
|
|
7
|
+
const player = (id, x, screen = x * 100 + 20, options = {}) => ({
|
|
8
|
+
id,
|
|
9
|
+
friend: options.friend === true,
|
|
10
|
+
distance: options.distance ?? Math.abs(x),
|
|
11
|
+
at: { x, z: options.z ?? 0 },
|
|
12
|
+
box: options.box ?? box(screen),
|
|
13
|
+
});
|
|
14
|
+
const view = { w: 844, h: 390 };
|
|
15
|
+
const run = (state, candidates, now = 0, options = {}) => layoutCrowdNames(state, candidates, { now, view: options.view ?? view, obstacles: options.obstacles ?? [] });
|
|
16
|
+
|
|
17
|
+
{
|
|
18
|
+
const state = makeCrowdNames();
|
|
19
|
+
// Display text is deliberately duplicated and absent from allocator input:
|
|
20
|
+
// stable session ids, never name or roster order, settle the tie.
|
|
21
|
+
const candidates = Array.from({ length: 12 }, (_, index) => player(`p${String(index).padStart(2, '0')}`, index * 0.2, 20 + index * 60, { distance: 3 }));
|
|
22
|
+
const result = run(state, [...candidates].reverse());
|
|
23
|
+
assert.deepEqual([...result.visible].sort(), ['p00', 'p01']);
|
|
24
|
+
assert.equal(result.summary.count, 10);
|
|
25
|
+
assert.equal(result.pairTests, 66, 'the twelve-player fixture makes at most 66 pair tests');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
{
|
|
29
|
+
const state = makeCrowdNames();
|
|
30
|
+
const incumbent = player('a', 0, 100, { distance: 1 });
|
|
31
|
+
assert.deepEqual([...run(state, [incumbent], 0).visible], ['a']);
|
|
32
|
+
const friend = player('b', 0.2, 110, { friend: true, distance: 2 });
|
|
33
|
+
assert.deepEqual([...run(state, [incumbent, friend], 100).visible], ['b'], 'friend priority wins even during the incumbent hold');
|
|
34
|
+
friend.friend = false;
|
|
35
|
+
assert.deepEqual([...run(state, [incumbent, friend], 150).visible], ['a'], 'friend revocation clears retained priority immediately');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
{
|
|
39
|
+
const state = makeCrowdNames();
|
|
40
|
+
const incumbent = player('a', 0, 100, { distance: 10 });
|
|
41
|
+
assert.deepEqual([...run(state, [incumbent], 0).visible], ['a']);
|
|
42
|
+
const newcomer = player('b', 0.2, 110, { distance: 1 });
|
|
43
|
+
assert.deepEqual([...run(state, [incumbent, newcomer], 600).visible], ['b'], 'distance ranking takes over when a newcomer arrives after the retained-slot hold expires');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
{
|
|
47
|
+
const unavailable = [player('b', 0, 100, { distance: 2 }), player('a', 0.2, 110, { distance: 2 })];
|
|
48
|
+
assert.deepEqual([...run(makeCrowdNames(), unavailable).visible], ['a'], 'without friend data stable id settles an equal collision');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
{
|
|
52
|
+
const state = makeCrowdNames();
|
|
53
|
+
const farApart = [player('a', 0, 100), player('b', 20, 110)];
|
|
54
|
+
const result = run(state, farApart);
|
|
55
|
+
assert.equal(result.visible.size, 1, 'far-apart players whose screen rectangles overlap still collide');
|
|
56
|
+
assert.equal(result.summary.count, 1);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
{
|
|
60
|
+
const state = makeCrowdNames();
|
|
61
|
+
const nearby = [player('a', 0, 50), player('b', 0.9, 180), player('c', 1.8, 310)];
|
|
62
|
+
let result = run(state, nearby, 0);
|
|
63
|
+
assert.equal(result.visible.size, 2, 'a connected metre-proximity group draws at most two names');
|
|
64
|
+
assert.equal(result.summary.count, 1);
|
|
65
|
+
nearby[1].at.x = 1.1;
|
|
66
|
+
run(state, nearby.slice(0, 2), 20);
|
|
67
|
+
assert.equal(state.nearPairs.size, 1, 'world grouping leaves at the wider hysteresis distance');
|
|
68
|
+
nearby[1].at.x = 1.3;
|
|
69
|
+
run(state, nearby.slice(0, 2), 40);
|
|
70
|
+
assert.equal(state.nearPairs.size, 0);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
{
|
|
74
|
+
const state = makeCrowdNames();
|
|
75
|
+
const a = player('a', 0, 100);
|
|
76
|
+
const b = player('b', 0.2, 110);
|
|
77
|
+
assert.deepEqual([...run(state, [a, b], 0).visible], ['a']);
|
|
78
|
+
b.at.x = 10;
|
|
79
|
+
b.box = box(300);
|
|
80
|
+
assert.deepEqual([...run(state, [a, b], 100).visible], ['a'], 'a suppressed candidate does not restore immediately');
|
|
81
|
+
assert.deepEqual([...run(state, [a, b], 349).visible], ['a']);
|
|
82
|
+
assert.deepEqual([...run(state, [a, b], 350).visible].sort(), ['a', 'b'], 'eight-pixel clearance held for 250ms restores the name');
|
|
83
|
+
run(state, [b], 351);
|
|
84
|
+
assert.equal(state.chosen.has('a'), false, 'departure drops retained history immediately');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
{
|
|
88
|
+
const state = makeCrowdNames();
|
|
89
|
+
const blocked = player('a', 0, 100);
|
|
90
|
+
assert.equal(run(state, [blocked], 0, { obstacles: [box(90, 70, 90, 60)] }).visible.size, 0);
|
|
91
|
+
const clipped = player('edge', 2, 0, { box: box(2) });
|
|
92
|
+
const result = run(makeCrowdNames(), [clipped]);
|
|
93
|
+
assert.equal(result.visible.size, 0, 'partially clipped tags are suppressed');
|
|
94
|
+
assert.equal(result.summary, null, 'offscreen/clipped names do not contribute to a count');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
{
|
|
98
|
+
const players = Array.from({ length: 6 }, (_, index) => player(`p${index}`, index * 0.1, 20 + index * 70));
|
|
99
|
+
const result = run(makeCrowdNames(), players, 0, { view: { w: 509, h: 218 } });
|
|
100
|
+
assert.equal(result.visible.size, 0, '509x218 suppresses every individual name');
|
|
101
|
+
assert.equal(result.summary.count, 6);
|
|
102
|
+
assert.equal(result.summary.tiny, true);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
{
|
|
106
|
+
const many = Array.from({ length: 40 }, (_, index) => player(`p${String(index).padStart(2, '0')}`, index * 0.05, 10 + (index % 10) * 70, { distance: index }));
|
|
107
|
+
const result = run(makeCrowdNames(), many);
|
|
108
|
+
assert.equal(result.considered, MAX_CANDIDATES);
|
|
109
|
+
assert.equal(result.pairTests, (MAX_CANDIDATES * (MAX_CANDIDATES - 1)) / 2, 'pair work stays bounded beyond the fixture');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
{
|
|
113
|
+
const holder = {};
|
|
114
|
+
const net = {};
|
|
115
|
+
const data = {}, place = {};
|
|
116
|
+
const first = crowdNamesFor(holder, { scene: 'town', data, net, place, visit: 'self:0' });
|
|
117
|
+
first.chosen.add('a');
|
|
118
|
+
assert.notEqual(crowdNamesFor(holder, { scene: 'town', data, net, place, visit: 'self:1' }), first, 'same-net WORLD reconnect resets visit history');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
{
|
|
122
|
+
const sprite = { position: { x: 100, y: 100, z: 0 }, scale: { x: 40, y: 20 } };
|
|
123
|
+
const cam = { matrixWorld: { elements: [1, 0, 0, 0, 0, 1, 0, 0] } };
|
|
124
|
+
const projected = spriteBox(sprite, cam, view, (_cam, x, y) => ({ x, y }));
|
|
125
|
+
assert.deepEqual(projected, { left: 80, right: 120, top: 90, bottom: 110 }, 'final sprite scale is projected in camera billboard axes');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
{
|
|
129
|
+
const sprite = { position: { x: 100, y: 100, z: 0 }, scale: { x: 40, y: 20 } };
|
|
130
|
+
const cam = { matrixWorld: { elements: [1, 0, 0, 0, 0, 1, 0, 0] } };
|
|
131
|
+
const project = (_cam, x, y) => ({ x, y });
|
|
132
|
+
const result = readableSpriteBox(sprite, cam, view, project);
|
|
133
|
+
assert.ok(result.resized, 'a plate below the E readability floor is enlarged');
|
|
134
|
+
assert.ok(Math.abs((result.box.bottom - result.box.top) * 44 / 68 - MIN_FONT_PX) < 1e-9, 'the projected canvas font reaches 15 CSS pixels');
|
|
135
|
+
assert.deepEqual(result.box, spriteBox(sprite, cam, view, project), 'the collision box is reprojected at the final scale and camera');
|
|
136
|
+
assert.equal((result.box.left + result.box.right) / 2, 100, 'enlarging preserves the avatar association centre');
|
|
137
|
+
const zoomed = { position: sprite.position, scale: { x: 40, y: 20 } };
|
|
138
|
+
assert.equal(readableSpriteBox(zoomed, cam, view, (_cam, x, y) => ({ x: x * 2, y: y * 2 })).resized, null, 'a current zoom that already reads above the floor is untouched');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
{
|
|
142
|
+
const project3d = (cam, x, y, z, viewport) => {
|
|
143
|
+
const point = new THREE.Vector3(x, y, z).project(cam);
|
|
144
|
+
if (point.z < -1 || point.z > 1) {return null;}
|
|
145
|
+
return { x: ((point.x + 1) / 2) * viewport.w, y: ((1 - point.y) / 2) * viewport.h };
|
|
146
|
+
};
|
|
147
|
+
const setCamera = (cam, angle, distance, update = false) => {
|
|
148
|
+
cam.position.set(-distance * Math.sin(angle), 7, distance * Math.cos(angle));
|
|
149
|
+
cam.lookAt(0, 1, 0);
|
|
150
|
+
if (update) {cam.updateMatrixWorld();}
|
|
151
|
+
};
|
|
152
|
+
const makeCamera = () => new THREE.PerspectiveCamera(50, view.w / view.h, 0.1, 100);
|
|
153
|
+
const makeSprites = () => ['a', 'b'].map((id) => ({ id, position: new THREE.Vector3(-2, 2, -2), scale: new THREE.Vector3(1.5, 0.35, 1) }));
|
|
154
|
+
const fontPx = (bounds) => (bounds.bottom - bounds.top) * 44 / 68;
|
|
155
|
+
const touches = (a, b, gap = 0) => a.left - gap < b.right && b.left - gap < a.right && a.top - gap < b.bottom && b.top - gap < a.bottom;
|
|
156
|
+
const allocate = (cam, sprites) => {
|
|
157
|
+
const candidates = sprites.map((sprite, index) => {
|
|
158
|
+
const geometry = readableSpriteBox(sprite, cam, view, project3d);
|
|
159
|
+
return { id: sprite.id, friend: false, distance: index + 1, at: { x: sprite.position.x, z: sprite.position.z }, ...geometry };
|
|
160
|
+
});
|
|
161
|
+
const result = run(makeCrowdNames(), candidates);
|
|
162
|
+
const selected = candidates.find((candidate) => result.visible.has(candidate.id));
|
|
163
|
+
const size = { w: 81, h: 26 };
|
|
164
|
+
const item = {
|
|
165
|
+
id: 'crowd:summary',
|
|
166
|
+
text: '+1 more',
|
|
167
|
+
x: result.summary.x,
|
|
168
|
+
y: result.summary.y,
|
|
169
|
+
box: {
|
|
170
|
+
left: result.summary.x - size.w / 2,
|
|
171
|
+
right: result.summary.x + size.w / 2,
|
|
172
|
+
top: result.summary.y - size.h,
|
|
173
|
+
bottom: result.summary.y,
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
const summary = placeLabels([item], null, [selected.box], view, () => size)[0];
|
|
177
|
+
return { selected, summary };
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const staleCamera = makeCamera();
|
|
181
|
+
const staleSprites = makeSprites();
|
|
182
|
+
setCamera(staleCamera, 0.5, 9, true);
|
|
183
|
+
setCamera(staleCamera, 0.3, 8);
|
|
184
|
+
const stale = allocate(staleCamera, staleSprites);
|
|
185
|
+
assert.ok(stale.selected.resized, 'the stale view matrix appears to reach the readability floor');
|
|
186
|
+
assert.ok(Math.abs(fontPx(stale.selected.box) - MIN_FONT_PX) < 1e-9);
|
|
187
|
+
staleCamera.updateMatrixWorld(); // What WebGLRenderer does after Hub.update.
|
|
188
|
+
const staleRendered = spriteBox(staleSprites[0], staleCamera, view, project3d);
|
|
189
|
+
assert.ok(fontPx(staleRendered) < MIN_FONT_PX, 'the renderer camera update exposes stale readability geometry');
|
|
190
|
+
assert.ok(touches(staleRendered, stale.summary.box, 6), 'the renderer camera update moves the chosen plate into the stale summary');
|
|
191
|
+
|
|
192
|
+
const currentCamera = makeCamera();
|
|
193
|
+
const currentSprites = makeSprites();
|
|
194
|
+
setCamera(currentCamera, 0.5, 9, true);
|
|
195
|
+
setCamera(currentCamera, 0.3, 8);
|
|
196
|
+
currentCamera.updateMatrixWorld(); // E mirrors the root camera update before its shared projection pass.
|
|
197
|
+
const current = allocate(currentCamera, currentSprites);
|
|
198
|
+
currentCamera.updateMatrixWorld(); // The later renderer update is now geometry-neutral.
|
|
199
|
+
const currentRendered = spriteBox(currentSprites[0], currentCamera, view, project3d);
|
|
200
|
+
assert.deepEqual(currentRendered, current.selected.box, 'E allocates against the same camera geometry the renderer draws');
|
|
201
|
+
assert.ok(Math.abs(fontPx(currentRendered) - MIN_FONT_PX) < 1e-9, 'the rendered plate keeps the 15 CSS pixel floor');
|
|
202
|
+
assert.equal(touches(currentRendered, current.summary.box, 6), false, 'the rendered plate keeps summary clearance');
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
console.log('crowd names: stable privacy-safe ranking, grouping, hysteresis, tiny view and bounded work passed');
|
|
@@ -11,6 +11,7 @@ register(`data:text/javascript,${encodeURIComponent(`
|
|
|
11
11
|
import { readFile } from 'node:fs/promises';
|
|
12
12
|
import { fileURLToPath } from 'node:url';
|
|
13
13
|
export async function resolve(specifier, context, next) {
|
|
14
|
+
if (specifier === '@imports/castle.physics-3d/engine3d/modelready.js') return { url: ${JSON.stringify(new URL('../../physics-3d/engine3d/modelready.js', import.meta.url).href)}, shortCircuit: true };
|
|
14
15
|
if (['pxmodel', 'optimize', 'look', 'lookbake'].some((m) => specifier === '@imports/castle.physics-3d/engine3d/' + m)) return { url: ${JSON.stringify(new URL('./fixtures/engine-models-stub.mjs', import.meta.url).href)}, shortCircuit: true };
|
|
15
16
|
if (specifier === '@imports/castle.physics-3d/engine3d/orbitlens.js') return { url: ${JSON.stringify(new URL('../../physics-3d/engine3d/orbitlens.js', import.meta.url).href)}, shortCircuit: true };
|
|
16
17
|
if (specifier === 'castle-web-sdk') return { url: 'data:text/javascript,export {};', shortCircuit: true };
|
|
@@ -104,7 +105,7 @@ function rig(w = 360, h = 780) {
|
|
|
104
105
|
let passed = 0;
|
|
105
106
|
function test(name, fn) { fn(); passed += 1; console.log(`ok: ${name}`); }
|
|
106
107
|
|
|
107
|
-
function keylessDrawing(travel = null) {
|
|
108
|
+
function keylessDrawing(travel = null, companionEnded = false) {
|
|
108
109
|
const previous = travel ? rig() : null;
|
|
109
110
|
if (previous) { previous.receive(); previous.frame(); previous.tile('Chair').click(); previous.frame(); }
|
|
110
111
|
State.clear();
|
|
@@ -113,7 +114,8 @@ function keylessDrawing(travel = null) {
|
|
|
113
114
|
const calls = [];
|
|
114
115
|
let system;
|
|
115
116
|
installSystem({ registerSystem(s) { system = s; } });
|
|
116
|
-
|
|
117
|
+
// This decor trace ignores the independent default world-label lifecycle.
|
|
118
|
+
const chrome = new Proxy({ peopleOpen: () => false, chatFocused: () => false, setWorldLabelFocus() {}, beginWorldLabels() {}, flushWorldLabels() {}, safeSurface() {}, setWorldViewport() {}, setWorldAvatar() {}, askShowable: () => true }, { get(target, name) { return target[name] ?? ((...args) => calls.push([name, ...args])); } });
|
|
117
119
|
system.chrome = chrome;
|
|
118
120
|
if (previous) { previous.chrome.setDecorating = (on) => calls.push(['decorating', on]); }
|
|
119
121
|
system.talk = { frame() {}, talking: () => false, typing: () => false, talkingWith: () => null };
|
|
@@ -127,6 +129,10 @@ function keylessDrawing(travel = null) {
|
|
|
127
129
|
system.sceneKey = 'keyless';
|
|
128
130
|
if (previous) { system.decor = previous.ui; }
|
|
129
131
|
const scene = { sceneKey: 'keyless', currentScenePath: 'scenes/main.scene', multiplayer: {}, actorWith: () => null, persistent: { hubTickets: [], hubAvatar: 0 }, getActors: () => [] };
|
|
132
|
+
if (companionEnded) {
|
|
133
|
+
system.companionTalkDrawn = true;
|
|
134
|
+
scene.three = { renderer: { domElement: { parentElement: { engine: true } } } };
|
|
135
|
+
}
|
|
130
136
|
State.hub.place = { id: 'main', title: 'Town', scene: 'scenes/main.scene', result: null };
|
|
131
137
|
State.hub.hud = { title: 'Town', text: 'Welcome' };
|
|
132
138
|
if (previous && travel === 'reset') { system.reset(null); }
|
|
@@ -136,7 +142,7 @@ function keylessDrawing(travel = null) {
|
|
|
136
142
|
assert.equal(previous.counts().disposed, 1);assert.equal(previous.counts().lost, 1);
|
|
137
143
|
assert.equal(previous.world.scene.children.length, 4);
|
|
138
144
|
assert(walk(previous.root).every((node) => Object.keys(node.handlers).length === 0), 'listeners removed');
|
|
139
|
-
assert.deepEqual(calls[
|
|
145
|
+
assert.deepEqual(calls.find(([name]) => name === 'decorating'), ['decorating', false], 'teardown restores the shared chrome');
|
|
140
146
|
calls.length = 0;system.afterBehaviors(scene, 0.05);
|
|
141
147
|
assert(!calls.some(([name]) => name === 'decorating'), 'later keyless frames never call decor chrome');
|
|
142
148
|
}
|
|
@@ -145,10 +151,45 @@ function keylessDrawing(travel = null) {
|
|
|
145
151
|
}
|
|
146
152
|
function domNodeCount() { return document.body.children.length; }
|
|
147
153
|
const fixture = new URL('./fixtures/decor-keyless-draw.json', import.meta.url);
|
|
148
|
-
test('
|
|
154
|
+
test('deferred decor sources are ready before thumbnail and placed-ghost clones', () => {
|
|
155
|
+
const r = rig();
|
|
156
|
+
const saved = new Map();
|
|
157
|
+
for (const id of ['chair-template', 'copy']) {
|
|
158
|
+
const entry = r.world.nodes.get(id);
|
|
159
|
+
saved.set(id, [...entry.node.children]);
|
|
160
|
+
entry.node.clear();
|
|
161
|
+
entry.modelWait = true;
|
|
162
|
+
}
|
|
163
|
+
const promoted = [];
|
|
164
|
+
r.world.modelLoad = { ensureActor(id) {
|
|
165
|
+
const entry = r.world.nodes.get(id);
|
|
166
|
+
if (!entry?.modelWait) return;
|
|
167
|
+
promoted.push(id);
|
|
168
|
+
entry.node.add(...saved.get(id));
|
|
169
|
+
delete entry.modelWait;
|
|
170
|
+
} };
|
|
171
|
+
r.receive(); r.frame();
|
|
172
|
+
assert.deepEqual(promoted, ['chair-template'], 'thumbnail promotes only the visual it clones');
|
|
173
|
+
assert.equal(r.counts().rendered, 1);
|
|
174
|
+
r.pointer('pointerdown', 1.5, 1.5); r.frame();
|
|
175
|
+
assert.deepEqual(promoted, ['chair-template', 'copy'], 'placed ghost promotes its independent source');
|
|
176
|
+
const ghost = r.world.scene.children.find(node => node.isGroup && node !== r.world.nodes.get('copy').node &&
|
|
177
|
+
node.children.some(child => child.material?.opacity === 0.8));
|
|
178
|
+
assert.ok(ghost, 'ghost contains the filled model');
|
|
179
|
+
assert.ok(ghost.position.toArray().every(Number.isFinite), 'ghost bounds produce a finite placement');
|
|
180
|
+
r.ui.dispose();
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
test('keyless frame: drawing trace includes engine clearance independently of decor', () => {
|
|
149
184
|
const expected = JSON.parse(fs.readFileSync(fixture, 'utf8')), actual = keylessDrawing();
|
|
150
185
|
assert.deepEqual(actual, expected); assert.equal(JSON.stringify(actual), JSON.stringify(expected));
|
|
151
186
|
});
|
|
187
|
+
test('companion removal keeps engine clearance through the complete frame', () => {
|
|
188
|
+
const calls = keylessDrawing(null, true);
|
|
189
|
+
assert.deepEqual(calls.filter(([name]) => name === 'layoutCompanion'), [['layoutCompanion', { engine: true }]], 'only the engine parent determines clearance; companion teardown cannot reset it');
|
|
190
|
+
assert(calls.some(([name, on]) => name === 'setCompanionBadge' && on === false), 'companion removal branch ran');
|
|
191
|
+
assert(calls.some(([name, screen]) => name === 'setCompanionTalk' && screen === null), 'old companion talk control removed');
|
|
192
|
+
});
|
|
152
193
|
test('decor travel and reset to keyless dispose every resource and restore the pre-change trace', () => {
|
|
153
194
|
const expected = JSON.parse(fs.readFileSync(fixture, 'utf8'));
|
|
154
195
|
for (const transition of ['travel', 'reset']) {
|
|
@@ -89,6 +89,13 @@ const item = { id: 'chair', tab: 'furniture', label: 'Chair', template: 'chair',
|
|
|
89
89
|
const spec = () => ({ title: 'Only you can change your house', tabs: [{ id: 'furniture', label: 'Furniture' }, { id: 'walls', label: 'Walls' }], items: [structuredClone(item)], swatches: [{ id: 'sage', tab: 'walls', label: 'Sage', color: '#779977' }], placed: [] });
|
|
90
90
|
const privateWire = (r) => r.sent.filter(([, msg]) => msg.k === 'hub-decor');
|
|
91
91
|
|
|
92
|
+
test('freshFriends flag belongs only to the opted-in server context', () => {
|
|
93
|
+
const off = boot(), on = boot({ freshFriends: true });
|
|
94
|
+
assert.equal(Object.hasOwn(off.hub, 'freshFriends'), false);
|
|
95
|
+
assert.equal(on.hub.freshFriends, true);
|
|
96
|
+
assert.equal(JSON.stringify(on.server.join()), JSON.stringify(off.server.join()));
|
|
97
|
+
});
|
|
98
|
+
|
|
92
99
|
test('keys absent: pre-change hub, manifest and every snapshot/delta/message deep- and JSON-equal', () => {
|
|
93
100
|
const expected = JSON.parse(fs.readFileSync(fixture, 'utf8')), actual = keylessTrace();
|
|
94
101
|
assert.deepEqual(actual, expected);
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Root `castle.json` owns the default environment choice for the lifetime of
|
|
2
|
+
// the page. Exercise the production hook and hub-system call so mounted scene
|
|
3
|
+
// data cannot turn a root opt-out back on.
|
|
4
|
+
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import { register } from 'node:module';
|
|
7
|
+
|
|
8
|
+
register(`data:text/javascript,${encodeURIComponent(`
|
|
9
|
+
import { readFile } from 'node:fs/promises';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
export async function resolve(specifier, context, next) {
|
|
12
|
+
if (['pxmodel', 'optimize', 'look', 'lookbake'].some((name) => specifier === '@imports/castle.physics-3d/engine3d/' + name)) return { url: ${JSON.stringify(new URL('./fixtures/engine-models-stub.mjs', import.meta.url).href)}, shortCircuit: true };
|
|
13
|
+
if (specifier === '@imports/castle.physics-3d/engine3d/orbitlens.js') return { url: ${JSON.stringify(new URL('../../physics-3d/engine3d/orbitlens.js', import.meta.url).href)}, shortCircuit: true };
|
|
14
|
+
if (specifier === 'castle-web-sdk') return { url: 'data:text/javascript,export {};', shortCircuit: true };
|
|
15
|
+
if (specifier === '@imports/castle.multiplayer-3d/code/client/avatars.js') return { url: 'data:text/javascript,export const dropMissing = () => {};', shortCircuit: true };
|
|
16
|
+
if (specifier.startsWith('@imports/castle.physics-2d/engine/')) return { url: 'data:text/javascript,export const initialMedia = {}; export const playMedia = () => {}; export const stopMedia = () => {};', shortCircuit: true };
|
|
17
|
+
if (specifier === '../client/pack.js') return { url: 'data:text/javascript,export const cachedPacks = () => []; export const loadPack = () => {}; export const matchesOwn = () => false; export const resolveDeckDoor = () => {};', shortCircuit: true };
|
|
18
|
+
return next(specifier, context);
|
|
19
|
+
}
|
|
20
|
+
export async function load(url, context, next) {
|
|
21
|
+
if (url.includes('/code/client/hookLayer.js?')) {
|
|
22
|
+
const clean = new URL(url);
|
|
23
|
+
clean.search = '';
|
|
24
|
+
const source = await readFile(fileURLToPath(clean), 'utf8');
|
|
25
|
+
return { format: 'module', source: source.replaceAll('import.meta.glob(', 'globalThis.__rootGlob('), shortCircuit: true };
|
|
26
|
+
}
|
|
27
|
+
return next(url, context);
|
|
28
|
+
}
|
|
29
|
+
`)}`);
|
|
30
|
+
|
|
31
|
+
globalThis.__rootCastleJson = {};
|
|
32
|
+
globalThis.__rootGlob = (pattern) => pattern === '/castle.json'
|
|
33
|
+
? { '/castle.json': globalThis.__rootCastleJson }
|
|
34
|
+
: {};
|
|
35
|
+
|
|
36
|
+
const State = await import('../code/client/state.js');
|
|
37
|
+
assert.equal(State.deck.defaultEnvironment, true, 'state defaults on before the root manifest is read');
|
|
38
|
+
for (const [name, hub, expected] of [
|
|
39
|
+
['missing', {}, true],
|
|
40
|
+
['true', { defaultEnvironment: true }, true],
|
|
41
|
+
['false', { defaultEnvironment: false }, false],
|
|
42
|
+
]) {
|
|
43
|
+
globalThis.__rootCastleJson = { hub };
|
|
44
|
+
await import(`../code/client/hookLayer.js?default-environment-${name}`);
|
|
45
|
+
assert.equal(State.deck.defaultEnvironment, expected, `${name} root value resolves to ${expected}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Cross the production system boundary once before and once after a session
|
|
49
|
+
// clear. The mounted scene's own data cannot replace the root choice.
|
|
50
|
+
const { installSystem } = await import('../code/systems/hub.js');
|
|
51
|
+
let system;
|
|
52
|
+
installSystem({ registerSystem(value) { system = value; } });
|
|
53
|
+
const noop = () => {};
|
|
54
|
+
system.chrome = new Proxy({ layoutCompanion: noop }, {
|
|
55
|
+
get(target, key) { return target[key] ?? noop; },
|
|
56
|
+
});
|
|
57
|
+
system.talk = {};
|
|
58
|
+
system.grab = {};
|
|
59
|
+
system.idle = {};
|
|
60
|
+
system.sound = {};
|
|
61
|
+
system.sayHooked = true;
|
|
62
|
+
for (const method of [
|
|
63
|
+
'keepResident', 'wearAvatar', 'applyTune', 'watchSession', 'sayHello',
|
|
64
|
+
'followPlace', 'holdFall',
|
|
65
|
+
]) {
|
|
66
|
+
system[method] = noop;
|
|
67
|
+
}
|
|
68
|
+
function frameUntilEnvironment(sceneKey, data = {}) {
|
|
69
|
+
const local = { id: 'self', components: { Transform: { y: -21 } } };
|
|
70
|
+
const scene = {
|
|
71
|
+
sceneKey,
|
|
72
|
+
data,
|
|
73
|
+
persistent: { hubDepth: 0, hubTickets: [], hubAvatar: 0 },
|
|
74
|
+
multiplayer: { net: { selfId: () => 'self' } },
|
|
75
|
+
actorWith: () => local,
|
|
76
|
+
};
|
|
77
|
+
State.hub.place = { id: 'main', fallY: -20 };
|
|
78
|
+
system.sceneKey = sceneKey;
|
|
79
|
+
const stop = new Error('environment reached');
|
|
80
|
+
let enabled;
|
|
81
|
+
system.environment.frame = (...args) => {
|
|
82
|
+
enabled = args[4];
|
|
83
|
+
throw stop;
|
|
84
|
+
};
|
|
85
|
+
assert.throws(() => system.afterBehaviors(scene, 1 / 60), (error) => error === stop);
|
|
86
|
+
assert.equal(enabled, false, 'HubSystem passes the root opt-out to the controller');
|
|
87
|
+
}
|
|
88
|
+
frameUntilEnvironment('town');
|
|
89
|
+
State.clear();
|
|
90
|
+
assert.equal(State.deck.defaultEnvironment, false, 'session clearing preserves root deck state');
|
|
91
|
+
frameUntilEnvironment('mounted:night', {
|
|
92
|
+
engine: { sky: { zones: [{ id: 'night', color: '#101827' }] } },
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
console.log('default environment root wiring tests passed');
|