castle-web-cli 0.4.233 → 0.4.234
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +260 -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 +50 -4
- package/kits/base/sdk/multiplayer.d.ts +7 -1
- package/kits/base/sdk/multiplayer.js +140 -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 +1257 -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 +819 -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,921 @@
|
|
|
1
|
+
// Real sync/render/runtime/physics with the existing Node/browser/Rapier stubs.
|
|
2
|
+
// Optional SQUARE_FIRST_BASELINE=<pre-change world3d.js> checks the old module
|
|
3
|
+
// too; the ordinary test always compares invalid keys and drained rigs to the
|
|
4
|
+
// synchronous path, including build calls and geometry/material sharing.
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import { register } from 'node:module';
|
|
8
|
+
import * as THREE from 'three';
|
|
9
|
+
import { makeWorld } from './test-static-passes.mjs';
|
|
10
|
+
await import('./test-static-scenery.mjs');
|
|
11
|
+
const { SceneRuntime } = await import('../../physics-2d/engine/scene.js');
|
|
12
|
+
const { Physics3DSystem } = await import('../systems/physics3d.js');
|
|
13
|
+
const { syncActors, renderWorld, disposeWorld, ensureActorModel } = await import('../engine3d/world3d.js');
|
|
14
|
+
const { prepareEmptyNodes } = await import('../engine3d/emptynodes.js');
|
|
15
|
+
const { readLoadKey, nearModelKeys } = await import('../engine3d/squarefirst.js');
|
|
16
|
+
const { makeLevers } = await import('../../hub-game/code/client/tiers.js');
|
|
17
|
+
const { setLookEnabled } = await import('../engine3d/look.js');
|
|
18
|
+
const dataNames = ['Transform', 'Shape', 'Model', 'Solid', 'Body'];
|
|
19
|
+
const playClasses = await Promise.all(dataNames.map(async name => (await import(`../play/behaviors/${name}.js`))[name]));
|
|
20
|
+
const [Transform, Shape, Model, Solid, Body] = playClasses;
|
|
21
|
+
|
|
22
|
+
// Load the actual canonical JSX classes too. Only inspector UI dependencies
|
|
23
|
+
// are stood in for; JSX is transpiled in memory and static Inspectors remain.
|
|
24
|
+
// This ensures registration accepts BOTH distinct class identities, without
|
|
25
|
+
// requiring squarefirst or any play module to import React/editor code.
|
|
26
|
+
register(`data:text/javascript,${encodeURIComponent(`
|
|
27
|
+
import fs from 'node:fs/promises';
|
|
28
|
+
import ts from ${JSON.stringify(import.meta.resolve('typescript'))};
|
|
29
|
+
const sources = new Set(${JSON.stringify(dataNames.map(name => new URL(`../behaviors/${name}.jsx`, import.meta.url).href))});
|
|
30
|
+
export async function resolve(specifier, context, next) {
|
|
31
|
+
if (sources.has(context.parentURL) && /\\/(ui|autoInspector)$/.test(specifier)) {
|
|
32
|
+
return { url: 'data:text/javascript,export const SelectField = () => null, TextField = () => null, AutoFields = () => null, overrideProps = () => ({});', shortCircuit: true };
|
|
33
|
+
}
|
|
34
|
+
return next(specifier, context);
|
|
35
|
+
}
|
|
36
|
+
export async function load(url, context, next) {
|
|
37
|
+
if (!sources.has(url)) return next(url, context);
|
|
38
|
+
const source = await fs.readFile(new URL(url), 'utf8');
|
|
39
|
+
return { format: 'module', shortCircuit: true, source: ts.transpileModule(source, {
|
|
40
|
+
compilerOptions: { target: ts.ScriptTarget.ESNext, module: ts.ModuleKind.ESNext, jsx: ts.JsxEmit.React }
|
|
41
|
+
}).outputText };
|
|
42
|
+
}
|
|
43
|
+
`)}`);
|
|
44
|
+
const editorClasses = await Promise.all(dataNames.map(async name => (await import(`../behaviors/${name}.jsx`))[name]));
|
|
45
|
+
const { prepareModelConsumers } = await import('../engine3d/modelready.js');
|
|
46
|
+
const { makeFrameClock, makeInputLatch, nextFrame, updateLending } = await import('../engine3d/framecap.js');
|
|
47
|
+
|
|
48
|
+
// Remove the fence implementation as well as its marker: masking only the
|
|
49
|
+
// marker would let a mistakenly installed hook hide a missing legacy check.
|
|
50
|
+
const sceneURL = new URL('../../physics-2d/engine/scene.js', import.meta.url);
|
|
51
|
+
let legacySource = fs.readFileSync(sceneURL, 'utf8');
|
|
52
|
+
assert.match(legacySource, /this\.beforeBehavior\?\.\(actor, name\);/);
|
|
53
|
+
legacySource = legacySource.replace('this.beforeBehavior?.(actor, name);', '')
|
|
54
|
+
.replace('get callsBeforeBehavior() { return true; }', '');
|
|
55
|
+
legacySource = legacySource.replace(/from (['"])(\.\/[^'"]+)\1/g,
|
|
56
|
+
(_all, quote, spec) => `from ${quote}${new URL(spec + '.js', sceneURL).href}${quote}`);
|
|
57
|
+
const { SceneRuntime: NoFenceRuntime } = await import(`data:text/javascript,${encodeURIComponent(legacySource)}`);
|
|
58
|
+
class LegacyRuntime extends NoFenceRuntime {
|
|
59
|
+
load(data) {
|
|
60
|
+
const engine = { ...data.engine }, legacyEngine = { ...engine };
|
|
61
|
+
delete legacyEngine.frozenStatics;
|
|
62
|
+
const result = super.load({ ...data, engine: legacyEngine });
|
|
63
|
+
this.data.engine = engine;
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
get freezesStatics() { return undefined; }
|
|
67
|
+
get frozenActors() { return undefined; }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Run the production player's imperative frame loop with a local RAF clock.
|
|
71
|
+
// No DOM or browser; runtime, physics, sync and render are the real modules.
|
|
72
|
+
const playerSource = fs.readFileSync(new URL('../engine3d/playerRun.js', import.meta.url), 'utf8');
|
|
73
|
+
const loopSource = playerSource.slice(playerSource.indexOf('function startLoop('),
|
|
74
|
+
playerSource.indexOf('// Load the scene a behavior asked for'));
|
|
75
|
+
function playerFrames(s, prior = false) {
|
|
76
|
+
let tick;
|
|
77
|
+
const dependencies = { makeFrameClock, nextFrame, updateLending, prepareModelConsumers,
|
|
78
|
+
syncActors, renderWorld, updateHud() {}, performance: { now: () => 0 },
|
|
79
|
+
requestAnimationFrame(fn) { if (fn.name === 'tick') tick = fn; return 1; }, cancelAnimationFrame() {} };
|
|
80
|
+
const source = prior ? loopSource.replace('prepareModelConsumers(world, runtime);', '') : loopSource;
|
|
81
|
+
const loop = new Function(...Object.keys(dependencies), source + '\nreturn startLoop;')(...Object.values(dependencies));
|
|
82
|
+
s.world.debugLines = { visible: false };
|
|
83
|
+
const stop = loop(s.runtime, s.world, s.runtime.sprites, {}, undefined, error => { throw error; }, makeInputLatch());
|
|
84
|
+
let now = 0;
|
|
85
|
+
return { frame() { tick(now += 1000 / 30); }, stop };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let checks = 0;
|
|
89
|
+
function equal(a, b, why) { checks++; assert.deepEqual(a, b, why); }
|
|
90
|
+
// Earlier lifecycle/budget cases explicitly request the old unbounded drain.
|
|
91
|
+
const LOAD = { first: { radius: 30 }, sliceMs: 8, horizon: 0 };
|
|
92
|
+
const full = { skipUnchangedActors: true };
|
|
93
|
+
const still = { ...full, staticActors: true };
|
|
94
|
+
const frozen = { ...still, frozenStatics: true };
|
|
95
|
+
const modes = [{}, full, still, frozen].flatMap(mode => [mode, { ...mode, skipEmptyNodes: true }]);
|
|
96
|
+
const file = name => `models/${name}.pxmodel`;
|
|
97
|
+
const box = (id = 'box', more = {}) => ({ id, kind: 'box', size: [1, 2, 3], color: '#8899aa', ...more });
|
|
98
|
+
function model(parts = [box()], more = {}) { return JSON.stringify({ format: 'pxmodel', look: false, parts, ...more }); }
|
|
99
|
+
const files = Object.fromEntries(['player', 'near', 'edge', 'far', 'other', 'custom', 'body'].map(name => [file(name), model()]));
|
|
100
|
+
files[file('empty')] = model([]);
|
|
101
|
+
files[file('motion')] = model([box('bob', { motion: { move: [0, 1, 0] } })]);
|
|
102
|
+
files[file('gait')] = model([box('torso')]);
|
|
103
|
+
files[file('slot')] = model([box('slot-hat')]);
|
|
104
|
+
files[file('keep')] = model([box('socket', { keep: true })]);
|
|
105
|
+
files[file('tint')] = model([box('paint', { tint: '#aabbcc' })]);
|
|
106
|
+
files[file('ref')] = model([{ id: 'reference', kind: 'model', src: file('gait') }]);
|
|
107
|
+
files[file('static-ref')] = model([{ id: 'reference', kind: 'model', src: file('far') }]);
|
|
108
|
+
function actor(id, x, name = id, components = {}) {
|
|
109
|
+
return { id, static: true, components: {
|
|
110
|
+
Transform: { x, y: 2, z: 50, rotationX: 12, rotationY: 35, rotationZ: -7 },
|
|
111
|
+
Shape: { kind: 'box', width: 1, height: 2, depth: 3, color: '#8899aa' },
|
|
112
|
+
Model: { file: file(name), scale: 1.7, yOffset: -0.5 }, ...components,
|
|
113
|
+
} };
|
|
114
|
+
}
|
|
115
|
+
function cast() {
|
|
116
|
+
return [actor('player', 1000, 'player', { Player: {} }), actor('near', 1005),
|
|
117
|
+
actor('edge', 1030), actor('shared-first', 2000, 'near'), actor('far', 1070),
|
|
118
|
+
actor('shared-wait', 1090, 'far'), actor('other', 1100), actor('empty', 1110),
|
|
119
|
+
actor('static-ref', 1120), actor('origin', 0, 'other'),
|
|
120
|
+
actor('custom', 2000, 'custom', { ReadsParts: { enabled: false } }),
|
|
121
|
+
actor('body', 2000, 'body', { Body: { type: 'fixed' } }),
|
|
122
|
+
...['motion', 'gait', 'slot', 'keep', 'tint', 'ref'].map(name => actor(name, 2000))];
|
|
123
|
+
}
|
|
124
|
+
class ReadsParts { static behaviorName = 'ReadsParts'; update() {} }
|
|
125
|
+
function side(engine = {}, actors = cast(), sync = syncActors, table = files, Runtime = SceneRuntime) {
|
|
126
|
+
const data = { name: 'Square', engine, ground: { none: true }, actors };
|
|
127
|
+
const runtime = new Runtime(data, [ReadsParts, Body], {}, { ...table }, 'scenes/main.scene');
|
|
128
|
+
const system = new Physics3DSystem();
|
|
129
|
+
runtime.registerSystem(system); system.attach(runtime);
|
|
130
|
+
const world = makeWorld();
|
|
131
|
+
runtime.three = world;
|
|
132
|
+
let renders = 0;
|
|
133
|
+
world.composer = { render() { renders++; world.scene.updateMatrixWorld(); } };
|
|
134
|
+
const builds = [];
|
|
135
|
+
const set = world.models.set;
|
|
136
|
+
world.models.set = function (key, entry) { builds.push(key); return set.call(this, key, entry); };
|
|
137
|
+
const stages = [];
|
|
138
|
+
world.onStage = (name, summary) => stages.push([name, summary, renders]);
|
|
139
|
+
if (runtime.skipsEmptyNodes) prepareEmptyNodes(world, runtime);
|
|
140
|
+
return { world, runtime, sync, builds, stages, system };
|
|
141
|
+
}
|
|
142
|
+
// Start Rapier once before comparing frames.
|
|
143
|
+
close(side());
|
|
144
|
+
await new Promise(resolve => setTimeout(resolve, 0));
|
|
145
|
+
function sync(s) { s.runtime.update(1 / 60); s.sync(s.world, s.runtime, {}, 1 / 60); }
|
|
146
|
+
function frame(s) { sync(s); renderWorld(s.world, s.runtime); }
|
|
147
|
+
function close(s) { s.runtime.dispose(); disposeWorld(s.world); equal(s.world.models.size, 0, 'no shared users survive disposal'); }
|
|
148
|
+
function drain(s, other) {
|
|
149
|
+
if (s.world.modelLoad) s.world.modelLoad.now = () => 0;
|
|
150
|
+
for (let i = 0; i < 20; i++) {
|
|
151
|
+
frame(s); if (other) frame(other);
|
|
152
|
+
if (!s.world.loadQueue?.pending && !s.world.lookBake?.pending && !other?.world.lookBake?.pending) return;
|
|
153
|
+
}
|
|
154
|
+
assert.fail('queue did not drain');
|
|
155
|
+
}
|
|
156
|
+
function treeState(world) {
|
|
157
|
+
const geometryIds = new Map(), materialIds = new Map();
|
|
158
|
+
const identity = (map, object) => { if (!map.has(object)) map.set(object, map.size); return map.get(object); };
|
|
159
|
+
const visit = node => ({
|
|
160
|
+
type: node.type, name: node.name, visible: node.visible,
|
|
161
|
+
actor: node.userData.actorId ?? null, part: node.userData.partId ?? null,
|
|
162
|
+
parts: [...(node.userData.modelParts?.keys() ?? [])],
|
|
163
|
+
local: [...node.matrix.elements], world: [...node.matrixWorld.elements],
|
|
164
|
+
geometry: node.geometry ? { identity: identity(geometryIds, node.geometry), type: node.geometry.constructor.name,
|
|
165
|
+
index: node.geometry.index ? [...node.geometry.index.array] : null,
|
|
166
|
+
attributes: Object.fromEntries(Object.entries(node.geometry.attributes).map(([name, a]) => [name, [a.itemSize, [...a.array]]])) } : null,
|
|
167
|
+
materials: [node.material].flat().filter(Boolean).map(m => ({ identity: identity(materialIds, m),
|
|
168
|
+
type: m.constructor.name, color: m.color?.getHex(), visible: m.visible, side: m.side,
|
|
169
|
+
defines: m.defines, program: m.customProgramCacheKey() })),
|
|
170
|
+
children: node.children.map(visit),
|
|
171
|
+
});
|
|
172
|
+
return [...world.nodes].map(([id, entry]) => [id, visit(entry.node)]);
|
|
173
|
+
}
|
|
174
|
+
function bodies(s) {
|
|
175
|
+
return [...s.system.bodies].map(([id, e]) => [id, e.sig, e.body.translation(), e.body.rotation(), e.body.bodyType()]);
|
|
176
|
+
}
|
|
177
|
+
function cache(s) { return [...s.world.models].map(([key, e]) => [key, e.users]).sort(); }
|
|
178
|
+
const builtFiles = s => s.builds.map(key => key.split('|')[0]);
|
|
179
|
+
|
|
180
|
+
let baseline;
|
|
181
|
+
if (process.env.SQUARE_FIRST_BASELINE) {
|
|
182
|
+
let source = fs.readFileSync(process.env.SQUARE_FIRST_BASELINE, 'utf8');
|
|
183
|
+
source = source.replace(/from (['"])(\.\/[^'"]+|@imports\/castle.physics-2d\/[^'"]+)\1/g, (_all, quote, spec) => {
|
|
184
|
+
let url = spec.startsWith('./') ? new URL(spec, new URL('../engine3d/world3d.js', import.meta.url)) :
|
|
185
|
+
new URL('../../physics-2d/' + spec.slice('@imports/castle.physics-2d/'.length), import.meta.url);
|
|
186
|
+
if (!url.pathname.endsWith('.js')) url = new URL(url.href + '.js');
|
|
187
|
+
return `from ${quote}${url.href}${quote}`;
|
|
188
|
+
});
|
|
189
|
+
source = source.replace(/from (['"])(three[^'"]*)\1/g, (_all, quote, spec) => `from ${quote}${import.meta.resolve(spec)}${quote}`);
|
|
190
|
+
baseline = (await import(`data:text/javascript,${encodeURIComponent(source)}`)).syncActors;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Invalid means the complete old path, not defaults for a partly valid key.
|
|
194
|
+
const invalid = [undefined, null, false, [], {}, { first: {} }, { first: { radius: 0 } },
|
|
195
|
+
{ first: { radius: -1 } }, { first: { radius: Infinity } }, { first: { radius: '30' } },
|
|
196
|
+
{ first: { radius: 30, typo: 1 } }, { first: [1] }, { first: [''] },
|
|
197
|
+
{ ...LOAD, sliceMs: 0 }, { ...LOAD, sliceMs: 51 }, { ...LOAD, sliceMs: '8' }, { ...LOAD, typo: true },
|
|
198
|
+
...[null, false, {}, 'Lookable', [1], [''], ['Lookable', null]].map(inert => ({ ...LOAD, inert })),
|
|
199
|
+
...[-1, Infinity, NaN, '45', null, false, {}, []].map(horizon => ({ ...LOAD, horizon }))];
|
|
200
|
+
for (const load of invalid) equal(readLoadKey({ engine: { load } }), null, 'invalid key');
|
|
201
|
+
equal(readLoadKey({ engine: { load: { first: [] } } }), { first: [], sliceMs: 8, horizon: 45 });
|
|
202
|
+
equal(readLoadKey({ engine: { load: { ...LOAD, inert: ['Lookable'] } } }), { ...LOAD, inert: ['Lookable'] });
|
|
203
|
+
equal(readLoadKey({ engine: { load: { ...LOAD, inert: [] } } }), { ...LOAD, inert: [] });
|
|
204
|
+
|
|
205
|
+
// Unregistered server data runs no client code; every registered custom class
|
|
206
|
+
// blocks by default, even a constructor-only class or a disabled component.
|
|
207
|
+
for (const name of ['TownBoatHull', 'TownBoatTrim', 'TownStamp', 'TownSign', 'TownTrade',
|
|
208
|
+
'TownGardenCrop', 'Lookable', 'RouteAnchor', 'WalkSurface', 'HubNpc', 'HubSpin', 'TownHatShow']) {
|
|
209
|
+
for (const registered of [false, true]) {
|
|
210
|
+
for (const inert of [[], [name]]) {
|
|
211
|
+
class Component { static behaviorName = name; constructor(props) { this.props = props; } }
|
|
212
|
+
const s = side({ load: { horizon: 0, first: [], inert } }, [actor('far', 70, 'far', { [name]: { $enabled: false } })]);
|
|
213
|
+
if (registered) s.runtime.setBehaviors([Component]);
|
|
214
|
+
sync(s);
|
|
215
|
+
equal(Boolean(s.world.nodes.get('far').modelWait), !registered || inert.includes(name), `${name}: registry and inert declaration`);
|
|
216
|
+
if (!registered) equal(s.runtime.behavior('far', name), undefined, 'unregistered data has no behaviour instance');
|
|
217
|
+
drain(s); close(s);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
{
|
|
222
|
+
const s = side({ load: { horizon: 0, first: [], inert: ['Player'] } }, [actor('far', 70, 'far', { Player: {} })]);
|
|
223
|
+
sync(s); equal(s.world.loadQueue.pending, 0, 'Player always blocks, even unregistered and declared inert'); close(s);
|
|
224
|
+
}
|
|
225
|
+
for (const type of ['fixed', 'kinematic', 'dynamic']) {
|
|
226
|
+
for (const mode of [full, still, frozen]) {
|
|
227
|
+
const actors = () => [{ ...actor('body', 70, 'body', { Body: { type, gravityScale: 0, friction: 0.6 } }), static: false }];
|
|
228
|
+
const old = side(mode, actors()), s = side({ ...mode, load: { horizon: 0, first: [] } }, actors());
|
|
229
|
+
sync(old); sync(s);
|
|
230
|
+
equal(Boolean(s.world.nodes.get('body').modelWait), true, `${type} Body can wait`);
|
|
231
|
+
equal(bodies(s), bodies(old), 'Body initialization ignores visual readiness');
|
|
232
|
+
if (type === 'dynamic') {
|
|
233
|
+
old.runtime.physics3d.setVelocity('body', { x: 3, y: 0, z: 0 });
|
|
234
|
+
s.runtime.physics3d.setVelocity('body', { x: 3, y: 0, z: 0 });
|
|
235
|
+
} else {
|
|
236
|
+
old.runtime.getActor('body').components.Transform.x += 3;
|
|
237
|
+
s.runtime.getActor('body').components.Transform.x += 3;
|
|
238
|
+
}
|
|
239
|
+
frame(old); frame(s);
|
|
240
|
+
equal(bodies(s), bodies(old), 'moving Body physics matches while waiting');
|
|
241
|
+
equal(s.world.nodes.get('body').node.position.toArray(), old.world.nodes.get('body').node.position.toArray(), 'waiting node follows Body transform');
|
|
242
|
+
drain(s, old); equal(treeState(s.world), treeState(old.world)); close(s); close(old);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
// An empty-node lifecycle callback that rejects sync cannot consume the first
|
|
246
|
+
// pass or arm a queue before actors are really placed.
|
|
247
|
+
for (const field of ['emptyNodesBlocked', 'dispatchDepth', 'draining']) {
|
|
248
|
+
const s = side({ skipEmptyNodes: true, load: LOAD });
|
|
249
|
+
const target = field === 'emptyNodesBlocked' ? s.world : s.world.emptyNodes;
|
|
250
|
+
target[field] = true;
|
|
251
|
+
syncActors(s.world, s.runtime, {});
|
|
252
|
+
equal(s.world.modelLoad, undefined, 'rejected sync leaves load unarmed');
|
|
253
|
+
delete target[field]; sync(s);
|
|
254
|
+
equal(s.world.loadQueue.pending, 5, 'first real sync selects first keys'); close(s);
|
|
255
|
+
}
|
|
256
|
+
{
|
|
257
|
+
const old = side({}), editor = side({ load: LOAD });
|
|
258
|
+
editor.world.staticActorsOff = true;
|
|
259
|
+
sync(old); sync(editor);
|
|
260
|
+
renderWorld(old.world); renderWorld(editor.world);
|
|
261
|
+
equal(editor.world.loadQueue, undefined, 'editor visuals stay synchronous');
|
|
262
|
+
equal(treeState(editor.world), treeState(old.world)); close(editor); close(old);
|
|
263
|
+
}
|
|
264
|
+
{
|
|
265
|
+
const s = side({ load: { horizon: 0, first: [] } }, [actor('far', 70), actor('late', 90, 'far', { ReadsParts: {} })]);
|
|
266
|
+
sync(s); equal(builtFiles(s), [file('far')]);
|
|
267
|
+
equal(s.world.loadQueue.pending, 0, 'unsafe later actor promotes the earlier copy before construction'); close(s);
|
|
268
|
+
}
|
|
269
|
+
{
|
|
270
|
+
const s = side({ load: { horizon: 0, first: [] } }, [actor('far', 70), actor('copy', 80, 'far')]);
|
|
271
|
+
s.world.instanceModels = true; sync(s);
|
|
272
|
+
equal(s.world.loadQueue.deferredKeys, 0); equal(s.world.instances.size, 1); close(s);
|
|
273
|
+
}
|
|
274
|
+
for (const mode of modes) {
|
|
275
|
+
for (const load of invalid) {
|
|
276
|
+
const old = side(mode, cast(), baseline ?? syncActors), s = side({ ...mode, load });
|
|
277
|
+
for (let i = 0; i < 4; i++) { frame(old); frame(s); }
|
|
278
|
+
equal(treeState(s.world), treeState(old.world), 'absent/invalid key: identical node trees, geometry, sharing and matrices');
|
|
279
|
+
equal(s.builds, old.builds, 'absent/invalid key: identical shared-build calls');
|
|
280
|
+
equal(cache(s), cache(old)); equal(bodies(s), bodies(old));
|
|
281
|
+
equal(s.world.loadQueue, undefined); equal(s.world.modelLoad, undefined);
|
|
282
|
+
close(old); close(s);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
for (const mode of modes.flatMap(mode => [mode, { ...mode, dropEmptyParts: true }])) {
|
|
287
|
+
const old = side(mode), s = side({ ...mode, load: LOAD });
|
|
288
|
+
sync(old); sync(s);
|
|
289
|
+
equal(bodies(s), bodies(old), 'colliders and bodies built at once');
|
|
290
|
+
equal(s.runtime.serialize().actors, old.runtime.serialize().actors, 'actor data unchanged');
|
|
291
|
+
const first = ['player', 'near', 'edge', 'custom', 'motion', 'gait', 'slot', 'keep', 'tint', 'ref'].map(file);
|
|
292
|
+
equal(builtFiles(s), first, 'only selected/unsafe shared keys built on first sync');
|
|
293
|
+
equal(s.world.loadQueue, { pending: 5, near: 5, built: 10, firstKeys: 10, deferredKeys: 5 });
|
|
294
|
+
assert.throws(() => { s.world.loadQueue.pending = 0; }, TypeError);
|
|
295
|
+
assert.throws(() => { s.world.loadQueue = {}; }, TypeError);
|
|
296
|
+
const waits = [...s.world.nodes.values()].filter(e => e.modelWait).map(e => [e, e.node.children[0], e.node.userData.modelParts]);
|
|
297
|
+
for (const [e, rig, parts] of waits) {
|
|
298
|
+
equal(rig.children.length, 0); equal(parts.size, 0); equal(rig.position.y, -0.5);
|
|
299
|
+
equal(rig.scale.toArray(), [1.7, 1.7, 1.7]); equal(rig.userData.modelParts, parts);
|
|
300
|
+
equal(e.node.position.toArray(), old.world.nodes.get(e.node.userData.actorId).node.position.toArray());
|
|
301
|
+
}
|
|
302
|
+
renderWorld(s.world, s.runtime); renderWorld(old.world, old.runtime);
|
|
303
|
+
equal(s.builds.length, first.length, 'first rendered frame builds no deferred models');
|
|
304
|
+
drain(s, old);
|
|
305
|
+
equal(s.world.loadQueue, { pending: 0, near: 0, built: 15, firstKeys: 10, deferredKeys: 5 });
|
|
306
|
+
for (const [entry, rig, parts] of waits) {
|
|
307
|
+
assert.strictEqual(entry.node.userData.modelParts, parts, 'the Map is filled in place');
|
|
308
|
+
if (!(mode.dropEmptyParts && entry.node.userData.actorId === 'empty')) assert.strictEqual(entry.node.children[0], rig, 'rig identity retained');
|
|
309
|
+
equal(entry.modelWait, undefined);
|
|
310
|
+
}
|
|
311
|
+
// Check the matrices IMMEDIATELY after filling, including frozen subtrees.
|
|
312
|
+
equal(treeState(s.world), treeState(old.world), 'drained rigs equal synchronous rigs before another render');
|
|
313
|
+
equal(cache(s), cache(old), 'each placed actor acquired exactly one shared user');
|
|
314
|
+
equal(s.stages.map(([name]) => name), ['load:first-built', 'load:rest-built']);
|
|
315
|
+
equal(s.stages[0][1].pending, 5); assert.ok(s.stages[1][2] >= 2);
|
|
316
|
+
for (let i = 0; i < 6; i++) { frame(s); frame(old); }
|
|
317
|
+
equal(treeState(s.world), treeState(old.world), 'static adoption/empty detachment after fill');
|
|
318
|
+
close(old); close(s);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// Array selection, origin fallback, x/z only, and centre fixed at first sync.
|
|
322
|
+
for (const first of [['far'], { radius: 30 }]) {
|
|
323
|
+
const actors = [actor('near', 5), actor('far', 80), actor('shared-wait', 100, 'far')];
|
|
324
|
+
actors.forEach(a => { a.components.Transform.z = 0; a.components.Transform.y = 10000; });
|
|
325
|
+
const s = side({ load: { horizon: 0, first } }, actors);
|
|
326
|
+
sync(s);
|
|
327
|
+
equal(builtFiles(s), [file(Array.isArray(first) ? 'far' : 'near')]);
|
|
328
|
+
drain(s); close(s);
|
|
329
|
+
}
|
|
330
|
+
{
|
|
331
|
+
const s = side({ load: LOAD }); sync(s);
|
|
332
|
+
s.runtime.getActor('player').components.Transform.x = 1070;
|
|
333
|
+
frame(s);
|
|
334
|
+
assert.ok(s.world.nodes.get('far').modelWait, 'moving player does not move first-sync centre');
|
|
335
|
+
drain(s); close(s);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// Deterministic clock: nearest pending key (including its nearest COPY), one
|
|
339
|
+
// noninterruptible key minimum, and no new key after the budget is exhausted.
|
|
340
|
+
for (const cost of [3, 20]) {
|
|
341
|
+
const s = side({ load: { horizon: 0, first: [], sliceMs: 8 } }, [actor('far', 100), actor('other', 10), actor('copy', 1, 'far'), actor('near', 20)]);
|
|
342
|
+
sync(s); let time = 0;
|
|
343
|
+
s.world.modelLoad.now = () => time;
|
|
344
|
+
const set = s.world.models.set;
|
|
345
|
+
s.world.models.set = function (...args) { time += cost; return set.apply(this, args); };
|
|
346
|
+
s.world.camera.position.set(0, 2, 50);
|
|
347
|
+
renderWorld(s.world, s.runtime); equal(s.builds.length, 0);
|
|
348
|
+
renderWorld(s.world, s.runtime);
|
|
349
|
+
equal(builtFiles(s), (cost === 3 ? ['far', 'other', 'near'] : ['far']).map(file));
|
|
350
|
+
equal(s.world.models.get(s.world.nodes.get('far').modelKey).users, 2, 'whole shared key filled within one step');
|
|
351
|
+
if (cost === 20) {
|
|
352
|
+
s.world.camera.position.x = 20;
|
|
353
|
+
renderWorld(s.world, s.runtime);
|
|
354
|
+
equal(builtFiles(s), ['far', 'near'].map(file), 'camera motion reprioritizes remaining keys');
|
|
355
|
+
}
|
|
356
|
+
drain(s); close(s);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// The default horizon is 45 m, exactly like an explicit 45. Zero retains the
|
|
360
|
+
// old full drain. X/z eligibility follows the player, not camera or height,
|
|
361
|
+
// and any nearby copy admits its entire shared key.
|
|
362
|
+
equal(readLoadKey({ engine: { load: { first: [], horizon: 0 } } }), { first: [], sliceMs: 8, horizon: 0 });
|
|
363
|
+
for (const mode of modes) {
|
|
364
|
+
for (const horizon of [undefined, 45, 0]) {
|
|
365
|
+
const setting = { first: [], ...(horizon === undefined ? {} : { horizon }) };
|
|
366
|
+
const actors = [actor('player', 0, 'player', { Player: {} }), actor('near', 10), actor('edge', 45, 'other'),
|
|
367
|
+
actor('far', 100), actor('distant-copy', 200, 'far'), actor('shared', 150, 'body'), actor('shared-near', 30, 'body')];
|
|
368
|
+
actors.forEach(actor => { actor.components.Transform.z = 0; actor.components.Transform.y = 10000; });
|
|
369
|
+
const s = side({ ...mode, load: setting }, actors);
|
|
370
|
+
sync(s); s.world.modelLoad.now = () => 0;
|
|
371
|
+
s.world.camera.position.set(1000, 0, 0);
|
|
372
|
+
equal(s.world.loadQueue.pending, 4);
|
|
373
|
+
equal(s.world.loadQueue.near, horizon === 0 ? 4 : 3, 'near counts distinct pending keys in the live horizon');
|
|
374
|
+
renderWorld(s.world, s.runtime); equal(s.builds.length, 1, 'first drawn frame still arms without building');
|
|
375
|
+
renderWorld(s.world, s.runtime);
|
|
376
|
+
equal(s.world.nodes.get('shared').modelWait, undefined, 'nearby copy fills its distant shared copy too');
|
|
377
|
+
if (horizon === 0) {
|
|
378
|
+
equal(s.world.loadQueue.pending, 0, 'zero horizon builds every remaining key');
|
|
379
|
+
} else {
|
|
380
|
+
equal(s.world.loadQueue.pending, 1); equal(s.world.loadQueue.near, 0);
|
|
381
|
+
equal(s.stages.map(([name]) => name), ['load:first-built'], 'no rest-built while distant keys remain');
|
|
382
|
+
for (let i = 0; i < 4; i++) frame(s);
|
|
383
|
+
equal(s.world.loadQueue.pending, 1, 'far key remains pending across drawn frames');
|
|
384
|
+
s.runtime.touch('player'); s.runtime.getActor('player').components.Transform.x = 53.5;
|
|
385
|
+
frame(s); equal(s.world.loadQueue.pending, 1, '46.5 m is outside the default horizon');
|
|
386
|
+
s.runtime.touch('player'); s.runtime.getActor('player').components.Transform.x = 55;
|
|
387
|
+
equal(s.world.loadQueue.near, 1, 'near updates at the inclusive horizon boundary before draining');
|
|
388
|
+
frame(s);
|
|
389
|
+
equal(s.world.nodes.get('far').modelWait, undefined);
|
|
390
|
+
equal(s.world.nodes.get('distant-copy').modelWait, undefined);
|
|
391
|
+
}
|
|
392
|
+
equal(s.world.loadQueue.pending, 0); equal(s.world.loadQueue.near, 0);
|
|
393
|
+
equal(s.stages.map(([name]) => name), ['load:first-built', 'load:rest-built']); close(s);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
{
|
|
397
|
+
const actors = [actor('a', 100, 'far'), actor('b', 145, 'other'), actor('c', 160, 'near')];
|
|
398
|
+
actors.forEach(actor => { actor.components.Transform.z = 0; });
|
|
399
|
+
const s = side({ load: { first: [] } }, actors);
|
|
400
|
+
const parent = new THREE.Group(); parent.position.x = 100;
|
|
401
|
+
parent.add(s.world.camera); s.world.scene.add(parent); s.world.camera.position.set(0, 5000, 0);
|
|
402
|
+
sync(s); s.world.modelLoad.now = () => 0;
|
|
403
|
+
equal(s.world.loadQueue.near, 2, 'without Player use camera world position, ignoring height');
|
|
404
|
+
renderWorld(s.world, s.runtime); renderWorld(s.world, s.runtime);
|
|
405
|
+
equal(s.world.loadQueue.pending, 1);
|
|
406
|
+
s.world.camera.position.x = 15;
|
|
407
|
+
equal(s.world.loadQueue.near, 1, 'camera movement brings the remaining key into range');
|
|
408
|
+
renderWorld(s.world, s.runtime); equal(s.world.loadQueue.pending, 0); close(s);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// A Player added to an existing actor replaces a cached camera fallback even
|
|
412
|
+
// when actor membership, pending membership and camera position stay unchanged.
|
|
413
|
+
for (const mode of modes) {
|
|
414
|
+
const focus = actor('focus', 100, 'player'), far = actor('far', 100);
|
|
415
|
+
delete focus.components.Model;
|
|
416
|
+
focus.components.Transform.z = far.components.Transform.z = 0;
|
|
417
|
+
const s = side({ ...mode, load: { first: [] } }, [focus, far]); sync(s);
|
|
418
|
+
const load = s.world.modelLoad, actors = s.runtime.actors, revision = load.pendingRevision;
|
|
419
|
+
load.now = () => 0;
|
|
420
|
+
renderWorld(s.world, s.runtime);
|
|
421
|
+
equal(s.world.loadQueue.near, 0, 'camera fallback leaves the distant key outside the horizon');
|
|
422
|
+
s.runtime.getActor('focus').components.Player = {};
|
|
423
|
+
assert.strictEqual(s.runtime.actors, actors);
|
|
424
|
+
equal(load.pendingRevision, revision, 'adding Player does not change pending membership');
|
|
425
|
+
equal(s.world.loadQueue.near, 1, 'new Player is found despite the cached missing focus');
|
|
426
|
+
renderWorld(s.world, s.runtime);
|
|
427
|
+
equal(s.world.nodes.get('far').modelWait, undefined, 'drain follows the newly added Player');
|
|
428
|
+
close(s);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// Reuse eligibility while the focus moves at most 1 m from the last sample.
|
|
432
|
+
// Adding/removing a copy invalidates even when the number of keys stays equal.
|
|
433
|
+
{
|
|
434
|
+
const actors = [actor('player', 0, 'player', { Player: {} }), actor('far', 100), actor('other', 200)];
|
|
435
|
+
actors.forEach(actor => { actor.components.Transform.z = 0; });
|
|
436
|
+
const s = side({ load: { first: [] } }, actors); sync(s);
|
|
437
|
+
const load = s.world.modelLoad, focus = s.runtime.getActor('player').components.Transform;
|
|
438
|
+
const initial = nearModelKeys(s.world, load), getActors = s.runtime.getActors;
|
|
439
|
+
const t = s.runtime.getActor('far').components.Transform, descriptor = Object.getOwnPropertyDescriptor(t, 'x');
|
|
440
|
+
let lookups = 0, positions = 0;
|
|
441
|
+
try {
|
|
442
|
+
s.runtime.getActors = function () { lookups++; return getActors.call(this); };
|
|
443
|
+
Object.defineProperty(t, 'x', { configurable: true, enumerable: true, get() { positions++; return descriptor.value; } });
|
|
444
|
+
for (const x of [0, 0.5, 1, 0.25, 0]) {
|
|
445
|
+
focus.x = x;
|
|
446
|
+
assert.strictEqual(nearModelKeys(s.world, load), initial, 'sub-metre movement reuses the cached Set');
|
|
447
|
+
}
|
|
448
|
+
equal({ lookups, positions }, { lookups: 0, positions: 0 }, 'cached horizon reads no waiter positions or actor list');
|
|
449
|
+
focus.x = 1.01;
|
|
450
|
+
assert.notStrictEqual(nearModelKeys(s.world, load), initial, 'movement over 1 m recomputes eligibility');
|
|
451
|
+
equal(positions > 0, true);
|
|
452
|
+
} finally { delete s.runtime.getActors; Object.defineProperty(t, 'x', descriptor); }
|
|
453
|
+
const count = load.pending.size;
|
|
454
|
+
const copy = actor('near-copy', 10, 'far'); copy.components.Transform.z = 0;
|
|
455
|
+
s.runtime.spawnActor(copy); sync(s);
|
|
456
|
+
equal(load.pending.size, count);
|
|
457
|
+
equal(nearModelKeys(s.world, load).size, 1, 'near copy admits the existing far key without player movement');
|
|
458
|
+
s.runtime.despawnActor('near-copy'); sync(s);
|
|
459
|
+
equal(load.pending.size, count);
|
|
460
|
+
equal(nearModelKeys(s.world, load).size, 0, 'removing the near copy invalidates the cached membership');
|
|
461
|
+
const far = s.runtime.getActor('far'); far.runtime.renderSleep = true;
|
|
462
|
+
s.world.nodes.get('far').node.removeFromParent();
|
|
463
|
+
far.components.Transform.x = 10; sync(s);
|
|
464
|
+
equal(nearModelKeys(s.world, load).size, 1, 'moving a detached pending actor refreshes eligibility while the player stands still');
|
|
465
|
+
close(s);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// Deterministic drawn intervals and per-key build cost. One key overruns the
|
|
469
|
+
// 1 ms slice; another never starts on that frame. A 500 ms outlier must not
|
|
470
|
+
// turn the median into an average and permit the following 60 ms frames.
|
|
471
|
+
function pacedSide() {
|
|
472
|
+
const ids = Array.from({ length: 10 }, (_, i) => `pace${i}`);
|
|
473
|
+
const table = { ...files, ...Object.fromEntries(ids.map(id => [file(id), model()])) };
|
|
474
|
+
const actors = [...ids.map((id, i) => actor(id, i + 1)), actor('far', 200), actor('consumer', 300, 'other')];
|
|
475
|
+
actors.forEach(actor => { actor.components.Transform.z = 0; });
|
|
476
|
+
const s = side({ load: { first: [], sliceMs: 1 } }, actors, syncActors, table);
|
|
477
|
+
s.world.camera.position.set(0, 0, 0);
|
|
478
|
+
sync(s);
|
|
479
|
+
let drawn = 0, now = 0;
|
|
480
|
+
s.world.modelLoad.now = () => now;
|
|
481
|
+
const set = s.world.models.set;
|
|
482
|
+
s.world.models.set = function (...args) { now += 2; return set.apply(this, args); };
|
|
483
|
+
const draw = interval => { drawn += interval; now = drawn; renderWorld(s.world, s.runtime); };
|
|
484
|
+
draw(0);
|
|
485
|
+
return { s, draw };
|
|
486
|
+
}
|
|
487
|
+
{
|
|
488
|
+
const { s, draw } = pacedSide();
|
|
489
|
+
for (let i = 0; i < 5; i++) { draw(16); equal(s.builds.length, i + 1, 'one over-budget key per building frame'); }
|
|
490
|
+
draw(500); equal(s.builds.length, 5, 'long frame skips the next background build');
|
|
491
|
+
ensureActorModel(s.world, 'far');
|
|
492
|
+
equal(s.builds.length, 6, 'explicit ensure ignores horizon and the current pacing skip');
|
|
493
|
+
s.runtime.touch('consumer'); s.runtime.getActor('consumer').components.ReadsParts = {};
|
|
494
|
+
s.runtime.behavior('consumer', 'ReadsParts');
|
|
495
|
+
equal(s.builds.length, 7, 'consumer promotion ignores horizon and pacing too');
|
|
496
|
+
draw(60); equal(s.builds.length, 7, 'second slow interval skips');
|
|
497
|
+
draw(60); equal(s.builds.length, 7, 'third slow interval skips');
|
|
498
|
+
draw(60); equal(s.builds.length, 8, 'fourth slow interval must build for progress');
|
|
499
|
+
draw(16); equal(s.builds.length, 9, 'normal intervals resume building immediately');
|
|
500
|
+
close(s);
|
|
501
|
+
}
|
|
502
|
+
for (const baseline of [16, 40]) {
|
|
503
|
+
const { s, draw } = pacedSide();
|
|
504
|
+
for (let i = 0; i < 5; i++) draw(baseline);
|
|
505
|
+
const threshold = Math.max(2 * baseline, 50);
|
|
506
|
+
draw(threshold); equal(s.builds.length, 6, 'threshold equality does not skip');
|
|
507
|
+
draw(threshold + 1); equal(s.builds.length, 6, 'strictly above twice median or the 50 ms floor skips');
|
|
508
|
+
close(s);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// Removal, signature edits (even while sleeping), and changes in consumers.
|
|
512
|
+
for (const mode of modes) {
|
|
513
|
+
for (const action of ['remove', 'signature', 'asset', 'behaviour', 'instances']) {
|
|
514
|
+
const s = side({ ...mode, load: { horizon: 0, first: [] } }, [actor('far', 70), actor('copy', 80, 'far')]);
|
|
515
|
+
sync(s); const previous = s.world.nodes.get('far'), wait = previous.modelWait;
|
|
516
|
+
if (action === 'remove') s.runtime.despawnActor('far');
|
|
517
|
+
else if (action === 'signature') {
|
|
518
|
+
s.world.scene.remove(previous.node); s.runtime.getActor('far').runtime.renderSleep = true;
|
|
519
|
+
s.runtime.touch('far'); s.runtime.getActor('far').components.Model.scale = 2;
|
|
520
|
+
} else if (action === 'asset') {
|
|
521
|
+
s.world.scene.remove(previous.node); s.runtime.getActor('far').runtime.renderSleep = true;
|
|
522
|
+
s.runtime.files[file('far')] = model([box('edited', { size: [3, 4, 5] })]);
|
|
523
|
+
} else if (action === 'behaviour') {
|
|
524
|
+
s.runtime.touch('far'); s.runtime.getActor('far').components.ReadsParts = {};
|
|
525
|
+
} else s.world.instanceModels = true;
|
|
526
|
+
frame(s);
|
|
527
|
+
assert.ok(![...wait.load.pending.values()].some(waits => waits.has(wait)), 'old wait dropped');
|
|
528
|
+
if (action === 'remove') equal(s.world.nodes.has('far'), false);
|
|
529
|
+
if (action === 'signature' || action === 'asset') assert.notStrictEqual(s.world.nodes.get('far'), previous);
|
|
530
|
+
if (action === 'behaviour') equal(s.world.loadQueue.pending, 0, 'unsafe actor promotes every user of its key');
|
|
531
|
+
if (action === 'instances') equal(s.world.instances.size, 1, 'instanceModels stays synchronous');
|
|
532
|
+
drain(s); close(s);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// A resident town parks complete nodes only. An incomplete rig cannot be
|
|
537
|
+
// reused as a complete rig by a keyless game or on the return door trip.
|
|
538
|
+
for (const mode of [full, still, frozen]) {
|
|
539
|
+
const s = side({ ...mode, load: LOAD }); sync(s);
|
|
540
|
+
const townKey = s.runtime.sceneKey ?? s.runtime.scenePath;
|
|
541
|
+
const wait = s.world.nodes.get('far').modelWait;
|
|
542
|
+
s.runtime.residentScenes = new Set([townKey]);
|
|
543
|
+
s.runtime.scenePath = 'scenes/away.scene';
|
|
544
|
+
s.runtime.load({ engine: mode, actors: [actor('far', 70)] });
|
|
545
|
+
frame(s);
|
|
546
|
+
equal(wait.load.pending.size, 0); equal(s.world.loadQueue, undefined);
|
|
547
|
+
equal(s.world.nodes.get('far').modelWait, undefined);
|
|
548
|
+
assert.ok(s.world.nodes.get('far').node.children[0].children.length);
|
|
549
|
+
for (const entry of s.world.parked.get(townKey)?.values() ?? []) equal(entry.modelWait, undefined);
|
|
550
|
+
s.runtime.scenePath = 'scenes/main.scene';
|
|
551
|
+
s.runtime.load({ engine: { ...mode, load: LOAD }, actors: cast() });
|
|
552
|
+
frame(s); drain(s); close(s);
|
|
553
|
+
}
|
|
554
|
+
for (const action of ['dispose-world', 'dispose-runtime', 'same-path-load', 'key-removed']) {
|
|
555
|
+
const s = side({ ...frozen, load: LOAD }); sync(s);
|
|
556
|
+
const wait = s.world.nodes.get('far').modelWait, modelCount = s.world.models.size;
|
|
557
|
+
if (action === 'dispose-world') disposeWorld(s.world);
|
|
558
|
+
else if (action === 'dispose-runtime') s.runtime.dispose();
|
|
559
|
+
else if (action === 'same-path-load') s.runtime.load({ ...s.runtime.data });
|
|
560
|
+
else { delete s.runtime.data.engine.load; sync(s); }
|
|
561
|
+
equal(wait.load.pending.size, 0); equal(wait.entry.modelWait, undefined);
|
|
562
|
+
if (action.startsWith('dispose')) equal(s.world.loadQueue, undefined);
|
|
563
|
+
if (action === 'key-removed') {
|
|
564
|
+
equal(s.world.nodes.size, cast().length, 'removing the key rebuilds cancelled frozen actors');
|
|
565
|
+
assert.ok(s.world.nodes.get('far').node.children[0].children.length, 'cancelled actor has its synchronous visual');
|
|
566
|
+
}
|
|
567
|
+
assert.ok(s.world.models.size <= modelCount + 5, 'no cancelled wait takes a shared user');
|
|
568
|
+
close(s);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// A data component name does not bless a replacement behaviour class that
|
|
572
|
+
// reads parts, including a callback inherited from another prototype.
|
|
573
|
+
{
|
|
574
|
+
class CustomModel { update() {} }
|
|
575
|
+
class Model extends CustomModel { static behaviorName = 'Model'; }
|
|
576
|
+
const s = side({ load: { horizon: 0, first: [] } }, [actor('far', 70)]);
|
|
577
|
+
s.runtime.setBehaviors([Model]); sync(s);
|
|
578
|
+
equal(s.world.loadQueue.pending, 0); equal(builtFiles(s), [file('far')]); close(s);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// The real low-tier/decor lever may detach a waiting root. Filling never
|
|
582
|
+
// steals its parent or wakes renderSleep, and High can restore the same root.
|
|
583
|
+
for (const mode of [full, still, frozen]) {
|
|
584
|
+
const s = side({ ...mode, skipEmptyNodes: true, load: { horizon: 0, first: [] } }, [actor('far', 100), actor('near', 5, 'near', { Solid: {} })]);
|
|
585
|
+
sync(s); s.runtime.readFromFile = () => s.runtime.data;
|
|
586
|
+
const levers = makeLevers(); levers.apply(s.world, s.runtime, 0);
|
|
587
|
+
const entry = s.world.nodes.get('far');
|
|
588
|
+
equal(entry.node.parent, null, 'Low detaches decor while it waits');
|
|
589
|
+
s.runtime.getActor('far').runtime.renderSleep = true;
|
|
590
|
+
drain(s);
|
|
591
|
+
equal(entry.node.parent, null, 'fill respects Low detachment');
|
|
592
|
+
equal(s.runtime.getActor('far').runtime.renderSleep, true);
|
|
593
|
+
delete s.runtime.getActor('far').runtime.renderSleep;
|
|
594
|
+
levers.restore(s.world); frame(s);
|
|
595
|
+
equal(entry.node.parent, s.world.scene, 'High restores filled decor'); close(s);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// Retaining readers can synchronously request one complete shared model key,
|
|
599
|
+
// without drawing a frame or draining unrelated waiting keys.
|
|
600
|
+
for (const mode of modes) {
|
|
601
|
+
const s = side({ ...mode, load: { horizon: 0, first: [] } }, [actor('far', 70), actor('copy', 80, 'far'), actor('other', 90)]);
|
|
602
|
+
sync(s);
|
|
603
|
+
const events = [];
|
|
604
|
+
s.world.scene.addEventListener('modelfilled', event => events.push(event.actorId));
|
|
605
|
+
ensureActorModel(s.world, 'far');
|
|
606
|
+
equal(events, ['far', 'copy']);
|
|
607
|
+
equal(s.world.nodes.get('other').modelWait !== undefined, true, 'promotion leaves unrelated key deferred');
|
|
608
|
+
const bounds = new THREE.Box3().setFromObject(s.world.nodes.get('far').node.clone(true));
|
|
609
|
+
equal(bounds.isEmpty(), false, 'reader clones a filled rig');
|
|
610
|
+
equal([...bounds.min.toArray(), ...bounds.max.toArray()].every(Number.isFinite), true);
|
|
611
|
+
const count = s.builds.length;
|
|
612
|
+
ensureActorModel(s.world, 'far'); ensureActorModel(s.world, 'missing');
|
|
613
|
+
equal(s.builds.length, count, 'complete/missing promotions are no-ops');
|
|
614
|
+
drain(s); close(s);
|
|
615
|
+
}
|
|
616
|
+
{
|
|
617
|
+
const s = side({}, [actor('far', 70)]); sync(s);
|
|
618
|
+
const before = Object.keys(s.world), count = s.builds.length;
|
|
619
|
+
ensureActorModel(s.world, 'far');
|
|
620
|
+
equal(Object.keys(s.world), before, 'keyless promotion adds no world state');
|
|
621
|
+
equal(s.builds.length, count); close(s);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// A fill listener can invalidate the next copy under the same shared key.
|
|
625
|
+
// File, asset and scale edits must never consume its captured model. Detached
|
|
626
|
+
// renderSleep actors get ordinary replacement placement, not a lost visual.
|
|
627
|
+
for (const mode of modes) {
|
|
628
|
+
for (const edit of ['file', 'asset', 'scale']) {
|
|
629
|
+
const s = side({ ...mode, load: { horizon: 0, first: [] } }, [actor('far', 70), actor('copy', 80, 'far')]);
|
|
630
|
+
sync(s);
|
|
631
|
+
const copy = s.runtime.getActor('copy'), previous = s.world.nodes.get('copy');
|
|
632
|
+
previous.node.removeFromParent(); copy.runtime.renderSleep = true;
|
|
633
|
+
s.world.scene.addEventListener('modelfilled', event => {
|
|
634
|
+
if (event.actorId !== 'far') return;
|
|
635
|
+
s.runtime.touch(copy);
|
|
636
|
+
if (edit === 'file') copy.components.Model.file = file('other');
|
|
637
|
+
if (edit === 'asset') s.runtime.files[file('far')] = model([box('replacement', { size: [5, 6, 7] })]);
|
|
638
|
+
if (edit === 'scale') copy.components.Model.scale = 3;
|
|
639
|
+
});
|
|
640
|
+
ensureActorModel(s.world, 'far');
|
|
641
|
+
const entry = s.world.nodes.get('copy');
|
|
642
|
+
assert.notStrictEqual(entry, previous, 'signature mismatch replaces the waiting node');
|
|
643
|
+
equal(entry.modelWait, undefined, 'replacement is ready synchronously');
|
|
644
|
+
equal(entry.node.parent === s.world.scene, true, 'sleeping replacement is attached for tier adoption');
|
|
645
|
+
equal(copy.runtime.renderSleep, true, 'engine does not change the sleep owner flag');
|
|
646
|
+
equal(entry.node.children[0].scale.x, edit === 'scale' ? 3 : 1.7);
|
|
647
|
+
equal(entry.modelKey.startsWith(edit === 'file' ? file('other') : file('far')), true);
|
|
648
|
+
if (edit === 'asset') equal(entry.node.userData.modelParts.has('replacement'), true);
|
|
649
|
+
sync(s);
|
|
650
|
+
equal(s.world.nodes.get('copy'), entry, 'ordinary placement retains the correct rebuilt visual');
|
|
651
|
+
close(s);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
// Promotion precedes the FIRST callback, including registration, component
|
|
656
|
+
// additions during this update, direct dispatch and collision-style dispatch.
|
|
657
|
+
for (const mode of modes) {
|
|
658
|
+
for (const change of ['register', 'component', 'during-update', 'collision', 'access']) {
|
|
659
|
+
let reads = 0;
|
|
660
|
+
const inspect = (actor, scene) => {
|
|
661
|
+
equal(scene.three.nodes.get(actor.id).modelWait, undefined, `${change}: first consumer sees no wait`);
|
|
662
|
+
equal(scene.three.nodes.get(actor.id).node.userData.modelParts.size > 0, true);
|
|
663
|
+
reads++;
|
|
664
|
+
};
|
|
665
|
+
class Consumer { static behaviorName = 'Consumer'; update = inspect; onCollisionEnter = inspect; }
|
|
666
|
+
const target = actor('far', 70, 'far', change === 'register' ? { Consumer: {} } : {});
|
|
667
|
+
const actors = change === 'during-update' ? [actor('near', 5), target] : [target];
|
|
668
|
+
const s = side({ ...mode, load: { horizon: 0, first: [] } }, actors);
|
|
669
|
+
if (change !== 'register') s.runtime.setBehaviors([Consumer]);
|
|
670
|
+
sync(s);
|
|
671
|
+
equal(Boolean(s.world.nodes.get('far').modelWait), true);
|
|
672
|
+
s.runtime.setBehaviors([Consumer]);
|
|
673
|
+
s.runtime.touch('far'); s.runtime.getActor('far').components.Consumer = {};
|
|
674
|
+
if (change === 'during-update') {
|
|
675
|
+
delete s.runtime.getActor('far').components.Consumer;
|
|
676
|
+
class Writer { static behaviorName = 'Writer'; update(_actor, scene) {
|
|
677
|
+
scene.touch('far'); scene.getActor('far').components.Consumer = {};
|
|
678
|
+
} }
|
|
679
|
+
s.runtime.getActor('near').components.Writer = {};
|
|
680
|
+
s.runtime.touch('near'); s.runtime.setBehaviors([Consumer, Writer]);
|
|
681
|
+
}
|
|
682
|
+
if (change === 'collision') s.runtime.forEachBehavior(s.runtime.getActor('far'), instance => instance.onCollisionEnter?.(s.runtime.getActor('far'), s.runtime));
|
|
683
|
+
else if (change === 'access') s.runtime.behavior('far', 'Consumer').update(s.runtime.getActor('far'), s.runtime);
|
|
684
|
+
else s.runtime.update(1 / 60);
|
|
685
|
+
equal(reads, 1, `${change}: one first consumer call`);
|
|
686
|
+
close(s);
|
|
687
|
+
equal(Object.hasOwn(s.runtime, 'beforeBehavior'), false, 'dispose removes the dormant dispatch fence');
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
// A published runtime without the dispatch fence still promotes changes made
|
|
692
|
+
// between frames, through BOTH production player update paths. No phantom
|
|
693
|
+
// beforeBehavior property is installed, and the first constructor sees a rig.
|
|
694
|
+
equal(SceneRuntime.prototype.callsBeforeBehavior, true, 'modern runtime explicitly advertises the fence');
|
|
695
|
+
for (const mode of modes) {
|
|
696
|
+
for (const cap of [0, 30]) {
|
|
697
|
+
for (const change of ['register', 'component']) {
|
|
698
|
+
let s, constructed = 0, updated = 0;
|
|
699
|
+
class Consumer {
|
|
700
|
+
static behaviorName = 'Consumer';
|
|
701
|
+
constructor(props) {
|
|
702
|
+
this.props = props; constructed++;
|
|
703
|
+
equal(s.world.nodes.get('far').modelWait, undefined, 'legacy first constructor sees a filled rig');
|
|
704
|
+
}
|
|
705
|
+
update(actor, scene) {
|
|
706
|
+
updated++;
|
|
707
|
+
equal(scene.three.nodes.get(actor.id).node.userData.modelParts.size > 0, true, 'legacy first update sees real parts');
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
s = side({ ...mode, maxFps: cap, load: { horizon: 0, first: [] } },
|
|
711
|
+
[actor('far', 70, 'far', change === 'register' ? { Consumer: {} } : {})], syncActors, files, LegacyRuntime);
|
|
712
|
+
if (change === 'component') s.runtime.setBehaviors([Consumer]);
|
|
713
|
+
const player = playerFrames(s);
|
|
714
|
+
try {
|
|
715
|
+
equal(s.runtime.callsBeforeBehavior, undefined);
|
|
716
|
+
player.frame();
|
|
717
|
+
equal(Boolean(s.world.nodes.get('far').modelWait), true, 'legacy retains deferred loading');
|
|
718
|
+
equal(Object.hasOwn(s.runtime, 'beforeBehavior'), false, 'capability absence does not install an ineffective fence');
|
|
719
|
+
if (change === 'register') s.runtime.setBehaviors([Consumer]);
|
|
720
|
+
else { s.runtime.touch('far'); s.runtime.getActor('far').components.Consumer = {}; }
|
|
721
|
+
player.frame();
|
|
722
|
+
equal(constructed, 1); equal(updated, 1, `${change}, cap ${cap}: consumer ran once after promotion`);
|
|
723
|
+
} finally { player.stop(); close(s); }
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
// Unchanged legacy dispatch checks allocate no component-key lists, compare
|
|
729
|
+
// only captured class identities and build no per-wait model/node signatures. Real
|
|
730
|
+
// component additions still promote before the consumer's first update.
|
|
731
|
+
{
|
|
732
|
+
const s = side({ load: { first: [] } }, [actor('far', 70), actor('other', 90)], syncActors, files, LegacyRuntime);
|
|
733
|
+
sync(s);
|
|
734
|
+
const actors = s.runtime.getActors(), components = new Set(actors.map(actor => actor.components));
|
|
735
|
+
const signatureInputs = new Set(actors.flatMap(actor => [actor.components.Model, actor.components.Shape]));
|
|
736
|
+
const keys = Object.keys, stringify = JSON.stringify, get = s.runtime.behaviors.get, table = s.runtime.files;
|
|
737
|
+
let keyLists = 0, signatures = 0, classes = 0, assets = 0;
|
|
738
|
+
try {
|
|
739
|
+
Object.keys = object => { if (components.has(object)) keyLists++; return keys(object); };
|
|
740
|
+
JSON.stringify = function (value, ...args) { if (signatureInputs.has(value)) signatures++; return stringify.call(this, value, ...args); };
|
|
741
|
+
s.runtime.behaviors.get = function (name) { classes++; return get.call(this, name); };
|
|
742
|
+
s.runtime.files = new Proxy(table, { get(target, name) { assets++; return target[name]; } });
|
|
743
|
+
for (let i = 0; i < 20; i++) prepareModelConsumers(s.world, s.runtime);
|
|
744
|
+
} finally {
|
|
745
|
+
Object.keys = keys; JSON.stringify = stringify;
|
|
746
|
+
delete s.runtime.behaviors.get; s.runtime.files = table;
|
|
747
|
+
}
|
|
748
|
+
equal({ keyLists, signatures, classes, assets },
|
|
749
|
+
{ keyLists: 0, signatures: 0, classes: actors.reduce((n, actor) => n + keys(actor.components).length, 0) * 20, assets: 0 },
|
|
750
|
+
'unchanged legacy checks use only membership and one class lookup per component');
|
|
751
|
+
let reads = 0;
|
|
752
|
+
class Consumer { static behaviorName = 'Consumer'; update(actor, scene) {
|
|
753
|
+
equal(scene.three.nodes.get(actor.id).modelWait, undefined); reads++;
|
|
754
|
+
} }
|
|
755
|
+
s.runtime.setBehaviors([Consumer]);
|
|
756
|
+
s.runtime.getActor('far').components.Consumer = {};
|
|
757
|
+
prepareModelConsumers(s.world, s.runtime); s.runtime.update(1 / 60);
|
|
758
|
+
equal(reads, 1, 'new component is filled before its first legacy update'); close(s);
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
// Registry additions in place (including remove+add preserving Map size),
|
|
762
|
+
// replacement Maps and component edits preserving count all retain the fence.
|
|
763
|
+
for (const change of ['map-add', 'map-same-size', 'map-replace', 'same-count']) {
|
|
764
|
+
const s = side({ load: { first: [] } }, [actor('far', 70, 'far', change === 'same-count' ? { ServerData: {} } : { Consumer: {} })], syncActors, files, LegacyRuntime);
|
|
765
|
+
let reads = 0;
|
|
766
|
+
class Consumer { static behaviorName = 'Consumer'; update(actor, scene) {
|
|
767
|
+
equal(scene.three.nodes.get(actor.id).modelWait, undefined); reads++;
|
|
768
|
+
} }
|
|
769
|
+
if (change === 'same-count') s.runtime.setBehaviors([Consumer]);
|
|
770
|
+
sync(s);
|
|
771
|
+
if (change === 'map-add') s.runtime.behaviors.set('Consumer', Consumer);
|
|
772
|
+
else if (change === 'map-same-size') {
|
|
773
|
+
const registry = s.runtime.behaviors, size = registry.size;
|
|
774
|
+
registry.delete('ReadsParts'); registry.set('Consumer', Consumer);
|
|
775
|
+
assert.strictEqual(s.runtime.behaviors, registry);
|
|
776
|
+
equal(registry.size, size, 'registration swap preserves registry identity and size');
|
|
777
|
+
equal(Boolean(s.world.nodes.get('far').modelWait), true, 'actor waits before same-size registry swap is checked');
|
|
778
|
+
}
|
|
779
|
+
else if (change === 'map-replace') s.runtime.setBehaviors([Body, Consumer]);
|
|
780
|
+
else {
|
|
781
|
+
delete s.runtime.getActor('far').components.ServerData;
|
|
782
|
+
s.runtime.getActor('far').components.Consumer = {};
|
|
783
|
+
}
|
|
784
|
+
prepareModelConsumers(s.world, s.runtime); s.runtime.update(1 / 60);
|
|
785
|
+
equal(reads, 1, `${change} promotes before first update`); close(s);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// Pair dispatch must not inspect/promote an unrelated unsafe waiter. Updating
|
|
789
|
+
// the registry fingerprint for the pair cannot mark that waiter checked.
|
|
790
|
+
{
|
|
791
|
+
const s = side({ load: { first: [] } }, [actor('a', 70, 'far'), actor('b', 80, 'other'),
|
|
792
|
+
actor('bystander', 90, 'body', { Consumer: {} })], syncActors, files, LegacyRuntime);
|
|
793
|
+
sync(s);
|
|
794
|
+
let reads = 0;
|
|
795
|
+
class Consumer { static behaviorName = 'Consumer'; update(actor, scene) {
|
|
796
|
+
equal(scene.three.nodes.get(actor.id).modelWait, undefined); reads++;
|
|
797
|
+
} }
|
|
798
|
+
s.runtime.setBehaviors([Consumer]);
|
|
799
|
+
const getActor = s.runtime.getActor, getNode = s.world.nodes.get;
|
|
800
|
+
const actorsRead = [], nodesRead = [];
|
|
801
|
+
try {
|
|
802
|
+
s.runtime.getActor = function (id) { actorsRead.push(id); return getActor.call(this, id); };
|
|
803
|
+
s.world.nodes.get = function (id) { nodesRead.push(id); return getNode.call(this, id); };
|
|
804
|
+
s.system.enter = [['a', 'b']]; s.system.dispatchCallbacks(s.runtime);
|
|
805
|
+
} finally { delete s.runtime.getActor; delete s.world.nodes.get; }
|
|
806
|
+
equal([...new Set(actorsRead)].sort(), ['a', 'b'], 'collision checks only look up the pair actors');
|
|
807
|
+
equal([...new Set(nodesRead)].sort(), ['a', 'b'], 'collision checks only look up the pair waits');
|
|
808
|
+
equal(Boolean(s.world.nodes.get('bystander').modelWait), true, 'unrelated waiter is untouched by the collision');
|
|
809
|
+
prepareModelConsumers(s.world, s.runtime); s.runtime.update(1 / 60);
|
|
810
|
+
equal(reads, 1, 'next full update still checks the bystander against the new registry'); close(s);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
// The callback on one side of a collision may add a consumer to the other
|
|
814
|
+
// side during the same physics dispatch. Check again before that side runs.
|
|
815
|
+
for (const method of ['onCollisionEnter', 'onCollisionExit']) {
|
|
816
|
+
const s = side({ ...full, load: { horizon: 0, first: [] } },
|
|
817
|
+
[actor('near', 5, 'near', { Writer: {} }), actor('far', 70)], syncActors, files, LegacyRuntime);
|
|
818
|
+
let reads = 0;
|
|
819
|
+
class Writer { static behaviorName = 'Writer'; [method](_actor, scene, other) {
|
|
820
|
+
scene.touch(other); other.components.Consumer = {};
|
|
821
|
+
} }
|
|
822
|
+
class Consumer { static behaviorName = 'Consumer'; [method](actor, scene) {
|
|
823
|
+
equal(scene.three.nodes.get(actor.id).modelWait, undefined, 'legacy collision consumer is promoted before dispatch');
|
|
824
|
+
reads++;
|
|
825
|
+
} }
|
|
826
|
+
s.runtime.setBehaviors([Writer, Consumer]);
|
|
827
|
+
s.sync(s.world, s.runtime, {});
|
|
828
|
+
equal(Boolean(s.world.nodes.get('far').modelWait), true);
|
|
829
|
+
s.system[method === 'onCollisionEnter' ? 'enter' : 'exit'] = [['near', 'far']];
|
|
830
|
+
s.system.dispatchCallbacks(s.runtime);
|
|
831
|
+
equal(reads, 1); close(s);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// The legacy keyless player trace is identical to the pre-check loop: tree,
|
|
835
|
+
// physics, builds and own fields. Merely calling the fallback adds no state.
|
|
836
|
+
for (const mode of modes) {
|
|
837
|
+
for (const cap of [0, 30]) {
|
|
838
|
+
const old = side({ ...mode, maxFps: cap }, cast(), syncActors, files, LegacyRuntime);
|
|
839
|
+
const s = side({ ...mode, maxFps: cap }, cast(), syncActors, files, LegacyRuntime);
|
|
840
|
+
const before = Object.getOwnPropertyNames(s.runtime), fields = Object.keys(s.world);
|
|
841
|
+
prepareModelConsumers(s.world, s.runtime);
|
|
842
|
+
equal(Object.getOwnPropertyNames(s.runtime), before); equal(Object.keys(s.world), fields);
|
|
843
|
+
const prior = playerFrames(old, true), player = playerFrames(s);
|
|
844
|
+
try {
|
|
845
|
+
for (let i = 0; i < 4; i++) { prior.frame(); player.frame(); }
|
|
846
|
+
equal(treeState(s.world), treeState(old.world), 'legacy keyless tree/matrices/sharing identical');
|
|
847
|
+
equal(s.builds, old.builds); equal(bodies(s), bodies(old));
|
|
848
|
+
equal(Object.getOwnPropertyNames(s.runtime).sort(), Object.getOwnPropertyNames(old.runtime).sort());
|
|
849
|
+
equal(Object.keys(s.world).sort(), Object.keys(old.world).sort());
|
|
850
|
+
equal(Object.hasOwn(s.runtime, 'beforeBehavior'), false);
|
|
851
|
+
equal(s.world.modelLoad, undefined); equal(s.world.loadQueue, undefined);
|
|
852
|
+
} finally { player.stop(); prior.stop(); close(s); close(old); }
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
// Constructor-owned callbacks and subclasses cannot impersonate a kit data
|
|
857
|
+
// class. Only the exact class exported by each behaviour module is safe.
|
|
858
|
+
for (const classes of [playClasses, editorClasses]) {
|
|
859
|
+
for (const KitClass of classes) {
|
|
860
|
+
const name = KitClass.behaviorName;
|
|
861
|
+
for (const inert of [[], [name]]) {
|
|
862
|
+
class Replacement { static behaviorName = name; constructor(props) {
|
|
863
|
+
this.props = props; this.update = () => {}; this.onCollisionEnter = () => {};
|
|
864
|
+
} }
|
|
865
|
+
const s = side({ load: { horizon: 0, first: [], inert } }, [actor('far', 70, 'far', { [name]: {} })]);
|
|
866
|
+
// Model/Transform need their fixture values, not an empty override.
|
|
867
|
+
s.runtime.getActor('far').components[name] = { ...actor('far', 70).components[name] };
|
|
868
|
+
s.runtime.setBehaviors([Replacement]); sync(s);
|
|
869
|
+
equal(Boolean(s.world.nodes.get('far').modelWait), inert.includes(name), `${name}: own callbacks require inert declaration`);
|
|
870
|
+
close(s);
|
|
871
|
+
}
|
|
872
|
+
const s = side({ load: { horizon: 0, first: [] } }, [actor('far', 70, 'far', { Solid: {}, Body: {} })]);
|
|
873
|
+
s.runtime.setBehaviors(classes); sync(s);
|
|
874
|
+
equal(Boolean(s.world.nodes.get('far').modelWait), true, 'actual kit data classes may wait'); close(s);
|
|
875
|
+
class Subclass extends KitClass {}
|
|
876
|
+
const subclass = side({ load: { horizon: 0, first: [] } }, [actor('far', 70, 'far', { Solid: {}, Body: {} })]);
|
|
877
|
+
subclass.runtime.setBehaviors([Subclass]); sync(subclass);
|
|
878
|
+
equal(subclass.world.nodes.get('far').modelWait, undefined, `${name}: subclass is a different identity`); close(subclass);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
// Hub play registers generated mirrors, whose identities differ from the
|
|
883
|
+
// canonical editor exports. Every kit data component must still permit a far
|
|
884
|
+
// static actor to wait, while replacing any one of those classes must block.
|
|
885
|
+
for (const mode of modes) {
|
|
886
|
+
const make = () => side({ ...mode, load: { horizon: 0, first: { radius: 30 } } },
|
|
887
|
+
[actor('far', 70, 'far', { Solid: {}, Body: { type: 'fixed' } })]);
|
|
888
|
+
const s = make();
|
|
889
|
+
s.runtime.setBehaviors(playClasses); sync(s);
|
|
890
|
+
equal(Boolean(s.world.nodes.get('far').modelWait), true, 'generated play data classes permit far static actors to wait');
|
|
891
|
+
equal(s.builds.length, 0, 'hub play does not synchronously build this far model');
|
|
892
|
+
drain(s); close(s);
|
|
893
|
+
for (const KitClass of playClasses) {
|
|
894
|
+
equal(KitClass === editorClasses.find(Behavior => Behavior.behaviorName === KitClass.behaviorName), false, 'test covers distinct mirror/editor identities');
|
|
895
|
+
class Replacement {
|
|
896
|
+
static behaviorName = KitClass.behaviorName;
|
|
897
|
+
static defaultProps = KitClass.defaultProps;
|
|
898
|
+
constructor(props) { this.props = props; this.update = () => {}; }
|
|
899
|
+
}
|
|
900
|
+
const unsafe = make();
|
|
901
|
+
unsafe.runtime.setBehaviors(playClasses.map(Behavior => Behavior === KitClass ? Replacement : Behavior));
|
|
902
|
+
sync(unsafe);
|
|
903
|
+
equal(unsafe.world.nodes.get('far').modelWait, undefined, `${KitClass.behaviorName}: replacement of a play class blocks`);
|
|
904
|
+
equal(unsafe.builds.length, 1); close(unsafe);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
// Deferred look baking shares the same takeModel build and disposal path.
|
|
909
|
+
setLookEnabled(true);
|
|
910
|
+
{
|
|
911
|
+
const table = { [file('far')]: model([box()], { look: { outline: true, occlusion: true } }) };
|
|
912
|
+
const mode = { ...frozen, skipEmptyNodes: true, dropEmptyParts: true, look: { bake: 'deferred' } };
|
|
913
|
+
const s = side({ ...mode, load: { horizon: 0, first: [] } }, [actor('far', 70), actor('copy', 90, 'far')], syncActors, table);
|
|
914
|
+
const old = side(mode, [actor('far', 70), actor('copy', 90, 'far')], syncActors, table);
|
|
915
|
+
frame(s); frame(old);
|
|
916
|
+
equal(s.world.lookBake, undefined, 'no look task before deferred build');
|
|
917
|
+
drain(s, old);
|
|
918
|
+
equal(treeState(s.world), treeState(old.world), 'look/drop/frozen result equals synchronous construction');
|
|
919
|
+
close(s); close(old);
|
|
920
|
+
}
|
|
921
|
+
console.log(`square-first: ${checks} checks; absent/invalid sync equivalence${baseline ? ' against pre-change module' : ''}, first keys, in-place fill, budgets, lifecycle and low-end interplays`);
|