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,40 @@
|
|
|
1
|
+
// Generated from ../../behaviors/Camera.jsx; run npm run sync:play-behaviors.
|
|
2
|
+
import { layoutCenter } from '../../engine/layout';
|
|
3
|
+
import { cardSize } from '../../engine/scene';
|
|
4
|
+
|
|
5
|
+
// Follow camera: keeps the target actor centered in the viewport, clamped to
|
|
6
|
+
// the room bounds so the empty area past the room edges never scrolls in.
|
|
7
|
+
class Camera {
|
|
8
|
+
static behaviorName = 'Camera';
|
|
9
|
+
static defaultProps = {
|
|
10
|
+
target: '',
|
|
11
|
+
followX: true,
|
|
12
|
+
followY: true,
|
|
13
|
+
roomWidth: 900,
|
|
14
|
+
roomHeight: 1100,
|
|
15
|
+
};
|
|
16
|
+
constructor(props) {
|
|
17
|
+
this.props = props;
|
|
18
|
+
}
|
|
19
|
+
update(_actor, scene) {
|
|
20
|
+
const target = this.props.target ? scene.getActor(this.props.target) : undefined;
|
|
21
|
+
const center = layoutCenter(target?.components.Layout);
|
|
22
|
+
if (!center)
|
|
23
|
+
return;
|
|
24
|
+
const desiredX = center.x - cardSize.width / 2;
|
|
25
|
+
const desiredY = center.y - cardSize.height / 2;
|
|
26
|
+
scene.camera = {
|
|
27
|
+
x: this.props.followX
|
|
28
|
+
? clamp(desiredX, 0, this.props.roomWidth - cardSize.width)
|
|
29
|
+
: 0,
|
|
30
|
+
y: this.props.followY
|
|
31
|
+
? clamp(desiredY, 0, this.props.roomHeight - cardSize.height)
|
|
32
|
+
: 0,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function clamp(value, min, max) {
|
|
37
|
+
return Math.max(min, Math.min(Math.max(min, max), value));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { Camera };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// Generated from ../../behaviors/Collider.jsx; run npm run sync:play-behaviors.
|
|
2
|
+
import { POSITIVE } from '../../engine/propertyRanges';
|
|
3
|
+
import { computeAutoFit, getColliderShapes } from '../../engine/collider';
|
|
4
|
+
export { getColliderRect, getColliderShapes, intersects } from '../../engine/collider';
|
|
5
|
+
|
|
6
|
+
// The pre-list spelling of the shape, still on decks authored before shapes
|
|
7
|
+
// became a list. Only consulted when there is no `shapes[0]` to ask.
|
|
8
|
+
function legacyShape(props) {
|
|
9
|
+
return typeof props.shape === 'string' && props.shape ? props.shape : 'box';
|
|
10
|
+
}
|
|
11
|
+
// Draw one resolved (world-space) collider shape as an outline.
|
|
12
|
+
function drawShape(ctx, s) {
|
|
13
|
+
if (s.type === 'circle') {
|
|
14
|
+
ctx.beginPath();
|
|
15
|
+
ctx.arc(s.cx, s.cy, s.radius, 0, Math.PI * 2);
|
|
16
|
+
ctx.stroke();
|
|
17
|
+
}
|
|
18
|
+
else if (s.type === 'triangle' || s.type === 'polygon') {
|
|
19
|
+
if (!s.points || s.points.length < 2)
|
|
20
|
+
return;
|
|
21
|
+
ctx.beginPath();
|
|
22
|
+
ctx.moveTo(s.points[0].x, s.points[0].y);
|
|
23
|
+
for (let k = 1; k < s.points.length; k++)
|
|
24
|
+
ctx.lineTo(s.points[k].x, s.points[k].y);
|
|
25
|
+
ctx.closePath();
|
|
26
|
+
ctx.stroke();
|
|
27
|
+
}
|
|
28
|
+
else if (s.angle) {
|
|
29
|
+
// Rotate the outline about the box center to match the (angled) matter part.
|
|
30
|
+
ctx.save();
|
|
31
|
+
ctx.translate(s.cx, s.cy);
|
|
32
|
+
ctx.rotate((s.angle * Math.PI) / 180);
|
|
33
|
+
ctx.strokeRect(-s.width / 2 + 1, -s.height / 2 + 1, s.width - 2, s.height - 2);
|
|
34
|
+
ctx.restore();
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
ctx.strokeRect(s.x + 1, s.y + 1, s.width - 2, s.height - 2);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
class Collider {
|
|
41
|
+
static behaviorName = 'Collider';
|
|
42
|
+
// A Collider is a LIST of shapes (`shapes`), each a fraction of the Layout box
|
|
43
|
+
// -- so it keeps its relative size when the box is resized. Unset `shapes` = one
|
|
44
|
+
// full-box shape. Only material fields live here; geometry is authored into
|
|
45
|
+
// `shapes` through the inspector.
|
|
46
|
+
static defaultProps = {
|
|
47
|
+
// `isTrigger` marks a sensor: reports overlaps (draws yellow, pass-through
|
|
48
|
+
// zone for pickup/goal logic) but doesn't block -- collisions are data.
|
|
49
|
+
isTrigger: false,
|
|
50
|
+
debug: false,
|
|
51
|
+
// Physics material, read by engine/physics/matterBridge.js. `bounciness` =
|
|
52
|
+
// restitution (0 dead .. ~1 very bouncy); `friction` = surface friction;
|
|
53
|
+
// `density` sets mass (= density x total shape area); matter's default 0.001.
|
|
54
|
+
bounciness: 0,
|
|
55
|
+
friction: 0.1,
|
|
56
|
+
// `frictionStatic` is stiction -- resistance to *starting* to slide (matter
|
|
57
|
+
// default 0.5). `density` sets mass (= density x total shape area).
|
|
58
|
+
frictionStatic: 0.5,
|
|
59
|
+
density: 0.001,
|
|
60
|
+
};
|
|
61
|
+
// Shape, and how many of them -- a compound collider's shape count is the
|
|
62
|
+
// thing you cannot see from the canvas without turning debug on.
|
|
63
|
+
static summary(props) {
|
|
64
|
+
const list = Array.isArray(props.shapes) ? props.shapes : [];
|
|
65
|
+
// A compound collider's shape COUNT is the thing you cannot see from the
|
|
66
|
+
// canvas without turning debug on, so it wins over naming one of them.
|
|
67
|
+
const shape = list.length > 1
|
|
68
|
+
? `${list.length} shapes`
|
|
69
|
+
// `shapes[0].type` is where the shape lives now; `props.shape` is the
|
|
70
|
+
// pre-list spelling, still on decks authored before the change.
|
|
71
|
+
: list[0]?.type ?? legacyShape(props);
|
|
72
|
+
return props.isTrigger ? `${shape} · trigger` : shape;
|
|
73
|
+
}
|
|
74
|
+
// Inspector ranges. No `max` on any of these: matter treats them as open-ended
|
|
75
|
+
// (bounciness "can exceed 1" per the docs, and stiction above 1 is meaningful),
|
|
76
|
+
// and a max is a hard authoring ceiling here -- typed entry is clamped to it,
|
|
77
|
+
// not just the slider. `min: 0` and a fine step are the parts that are safe.
|
|
78
|
+
static propertyMeta = {
|
|
79
|
+
bounciness: POSITIVE,
|
|
80
|
+
friction: POSITIVE,
|
|
81
|
+
frictionStatic: POSITIVE,
|
|
82
|
+
};
|
|
83
|
+
constructor(props) {
|
|
84
|
+
this.props = props;
|
|
85
|
+
}
|
|
86
|
+
// Seed props when first added: fit a single box to the sprite's opaque bounds
|
|
87
|
+
// (or the full box when there's nothing to fit to).
|
|
88
|
+
static initialProps(actor, ctx) {
|
|
89
|
+
const fit = computeAutoFit(actor, ctx?.sprites);
|
|
90
|
+
return fit ? { ...Collider.defaultProps, shapes: [fit] } : { ...Collider.defaultProps };
|
|
91
|
+
}
|
|
92
|
+
draw(actor, scene, ctx, options) {
|
|
93
|
+
// A selected instance always shows its collider -- but the editor's selection
|
|
94
|
+
// overlay draws it, so skip here to avoid a double outline.
|
|
95
|
+
if (options.colliderOverlayIds?.includes(actor.id))
|
|
96
|
+
return;
|
|
97
|
+
// Otherwise draw when this actor's blueprint is selected in the hotbar (so
|
|
98
|
+
// all its instances light up), or when the per-collider debug flag is on
|
|
99
|
+
// (unselected actors in the editor, and during play).
|
|
100
|
+
const blueprintSelected = scene.usesBlueprint(actor, options.dimBlueprintPath);
|
|
101
|
+
if (!blueprintSelected && !options.showDebugColliders && !this.props.debug)
|
|
102
|
+
return;
|
|
103
|
+
const shapes = getColliderShapes(actor);
|
|
104
|
+
if (!shapes)
|
|
105
|
+
return;
|
|
106
|
+
const isSensor = Boolean(this.props.isTrigger) || this.props.kind === 'pickup';
|
|
107
|
+
// When editing this blueprint (hotbar), highlight the shape the inspector has
|
|
108
|
+
// selected so you can tell which chip is which on its lit instances -- the
|
|
109
|
+
// selected-instance path does this via the SelectionOverlay instead.
|
|
110
|
+
const highlight = blueprintSelected ? options.colliderShapeSel ?? -1 : -1;
|
|
111
|
+
ctx.save();
|
|
112
|
+
shapes.forEach((s, k) => {
|
|
113
|
+
const on = k === highlight;
|
|
114
|
+
ctx.strokeStyle = on ? '#ffd24a' : isSensor ? '#ffe17a' : '#8db7ff';
|
|
115
|
+
ctx.lineWidth = on ? 3.5 : 2;
|
|
116
|
+
drawShape(ctx, s);
|
|
117
|
+
});
|
|
118
|
+
ctx.restore();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export { Collider };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Generated from ../../behaviors/Draggable.jsx; run npm run sync:play-behaviors.
|
|
2
|
+
import { UNIT } from '../../engine/propertyRanges';
|
|
3
|
+
import { TARGETED_CLAIM, dragHold, inActorWorldSpace } from '../../engine/physics/controls';
|
|
4
|
+
|
|
5
|
+
// Draggable: grab the actor with the pointer and fling it around. The grab is a
|
|
6
|
+
// real physics constraint from the exact spot that was touched to the pointer,
|
|
7
|
+
// so the object still collides with the world AND turns when held off-center --
|
|
8
|
+
// grab a plank by its end and it swings.
|
|
9
|
+
//
|
|
10
|
+
// The touch zone is the actor's COLLIDER at its current orientation (via
|
|
11
|
+
// scene.physics.actorAtPoint), not its Layout box, so a circle is round and a
|
|
12
|
+
// rotated actor's grabbable area rotates with it.
|
|
13
|
+
//
|
|
14
|
+
// A drag belongs to the finger that started it: it follows that pointer alone
|
|
15
|
+
// until that pointer lifts, so later fingers can't steal or drop it, and a
|
|
16
|
+
// second finger can drag a second actor at the same time.
|
|
17
|
+
//
|
|
18
|
+
// stiffness -> how tightly the object is held, 0 (loose and swingy) to 1
|
|
19
|
+
// (rigid, snaps to the pointer). Mapped through `dragHold`, which spreads the
|
|
20
|
+
// authored range over matter's very compressed useful band and eases damping
|
|
21
|
+
// along with it, so the low end is genuinely floppy rather than just slow.
|
|
22
|
+
class Draggable {
|
|
23
|
+
static behaviorName = 'Draggable';
|
|
24
|
+
// Inert without a body to hold: needs a Collider (to have one at all) and a
|
|
25
|
+
// dynamic RigidBody (so the grab can actually move it).
|
|
26
|
+
static expectedSiblings = ['Collider', 'RigidBody'];
|
|
27
|
+
static defaultProps = {
|
|
28
|
+
stiffness: 0.3,
|
|
29
|
+
};
|
|
30
|
+
// 0..1 with a fine step, so the inspector renders a real slider over the
|
|
31
|
+
// whole range rather than an unbounded whole-number scrubber.
|
|
32
|
+
static propertyMeta = {
|
|
33
|
+
stiffness: UNIT,
|
|
34
|
+
};
|
|
35
|
+
static initialState = { pointerId: null };
|
|
36
|
+
constructor(props) {
|
|
37
|
+
this.props = props;
|
|
38
|
+
}
|
|
39
|
+
// Switched off mid-drag, this is the only thing that can let go: `update` is
|
|
40
|
+
// the sole caller of `release`, and it stops running the moment the behavior
|
|
41
|
+
// is disabled. Without this the actor stays welded to the pointer.
|
|
42
|
+
onDisable(actor, scene) {
|
|
43
|
+
if (this.state.pointerId == null)
|
|
44
|
+
return;
|
|
45
|
+
scene.physics.release(actor);
|
|
46
|
+
this.state.pointerId = null;
|
|
47
|
+
}
|
|
48
|
+
update(actor, scene) {
|
|
49
|
+
const state = this.state;
|
|
50
|
+
const held = state.pointerId == null ? null : scene.pointers.get(state.pointerId);
|
|
51
|
+
// The finger that started this drag lifted (or its contact was cancelled).
|
|
52
|
+
if (state.pointerId != null && !held?.down) {
|
|
53
|
+
scene.physics.release(actor);
|
|
54
|
+
state.pointerId = null;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (held)
|
|
58
|
+
return scene.physics.moveGrab(actor, held.x, held.y);
|
|
59
|
+
// Idle: look for a new press on this actor. Each pointer carries its own
|
|
60
|
+
// press edge, so a finger landing while another is already down still
|
|
61
|
+
// registers -- and an actor already being dragged never gets here, so the
|
|
62
|
+
// first finger keeps it.
|
|
63
|
+
for (const p of scene.pointers.values()) {
|
|
64
|
+
if (!p.justPressed)
|
|
65
|
+
continue;
|
|
66
|
+
if (scene.physics.actorAtPoint(p.x, p.y)?.id !== actor.id)
|
|
67
|
+
continue;
|
|
68
|
+
// A press on this collider is unambiguous, so it outranks any control that
|
|
69
|
+
// merely takes presses anywhere -- whatever order the actors update in.
|
|
70
|
+
if (!scene.claimPointer(p.id, actor.id, TARGETED_CLAIM))
|
|
71
|
+
continue;
|
|
72
|
+
if (scene.physics.grab(actor, p.x, p.y, dragHold(this.props.stiffness))) {
|
|
73
|
+
state.pointerId = p.id;
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Feedback while held (castle-client's Drag overlay): a circle where the
|
|
79
|
+
// object is actually being held + a circle at the touch, connected by a line
|
|
80
|
+
// -- both translucent white with a solid white border. The handle comes from
|
|
81
|
+
// the constraint the simulation is solving, so it sits exactly where the
|
|
82
|
+
// physics holds the object and tracks it through rotation. Drawn in world
|
|
83
|
+
// space so the overlay itself doesn't spin with the actor.
|
|
84
|
+
draw(actor, scene, ctx) {
|
|
85
|
+
const id = this.state.pointerId;
|
|
86
|
+
if (id == null)
|
|
87
|
+
return;
|
|
88
|
+
const handle = scene.physics.grabPoint(actor);
|
|
89
|
+
const touch = scene.pointers.get(id);
|
|
90
|
+
if (!handle || !touch)
|
|
91
|
+
return;
|
|
92
|
+
inActorWorldSpace(ctx, actor.components.Layout, (g) => drawDrag(g, handle, { x: touch.x, y: touch.y }));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Matches sling/drag.cpp: line first, then a circle at each end -- translucent
|
|
96
|
+
// white fill (0.3) + solid white border (0.8), radius 18.
|
|
97
|
+
function drawDrag(ctx, a, b) {
|
|
98
|
+
const radius = 18;
|
|
99
|
+
ctx.lineWidth = 1.5;
|
|
100
|
+
ctx.strokeStyle = 'rgba(255, 255, 255, 0.8)';
|
|
101
|
+
ctx.beginPath();
|
|
102
|
+
ctx.moveTo(a.x, a.y);
|
|
103
|
+
ctx.lineTo(b.x, b.y);
|
|
104
|
+
ctx.stroke();
|
|
105
|
+
for (const p of [a, b]) {
|
|
106
|
+
ctx.beginPath();
|
|
107
|
+
ctx.arc(p.x, p.y, radius, 0, Math.PI * 2);
|
|
108
|
+
ctx.fillStyle = 'rgba(255, 255, 255, 0.3)';
|
|
109
|
+
ctx.fill();
|
|
110
|
+
ctx.strokeStyle = 'rgba(255, 255, 255, 0.8)';
|
|
111
|
+
ctx.stroke();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { Draggable };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Generated from ../../behaviors/Goal.jsx; run npm run sync:play-behaviors.
|
|
2
|
+
import { layoutRect } from '../../engine/layout';
|
|
3
|
+
|
|
4
|
+
// Goal: a sensor zone that counts when a physics body enters it, and flashes
|
|
5
|
+
// green briefly. Demonstrates the physics collision callbacks + a Collider with
|
|
6
|
+
// `isTrigger: true`. Put it on an actor with a Layout and a trigger Collider.
|
|
7
|
+
class Goal {
|
|
8
|
+
static behaviorName = 'Goal';
|
|
9
|
+
// Scores on collision callbacks, which only fire for an actor with a body.
|
|
10
|
+
static expectedSiblings = ['Collider'];
|
|
11
|
+
static defaultProps = {};
|
|
12
|
+
static initialState = { scored: 0, flashUntil: 0 };
|
|
13
|
+
constructor(props) {
|
|
14
|
+
this.props = props;
|
|
15
|
+
}
|
|
16
|
+
onCollisionEnter(actor, scene, other) {
|
|
17
|
+
if (!other.components.RigidBody)
|
|
18
|
+
return; // only score moving bodies
|
|
19
|
+
this.score();
|
|
20
|
+
}
|
|
21
|
+
// Public method other behaviors can call directly:
|
|
22
|
+
// `other.behaviors.Goal?.score()`. A pure refactor of the old
|
|
23
|
+
// onCollisionEnter body -- same increment, same flash window.
|
|
24
|
+
score() {
|
|
25
|
+
this.state.scored += 1;
|
|
26
|
+
this.state.flashUntil = this.scene.time + 0.6;
|
|
27
|
+
// Kept as the older spelling -- a deck reading `goal.runtime.scored` or
|
|
28
|
+
// `.flashUntil` (where this lived before `this.state`) still sees them.
|
|
29
|
+
this.actor.runtime.scored = this.state.scored;
|
|
30
|
+
this.actor.runtime.flashUntil = this.state.flashUntil;
|
|
31
|
+
}
|
|
32
|
+
draw(actor, scene, ctx) {
|
|
33
|
+
const box = layoutRect(actor.components.Layout);
|
|
34
|
+
if (!box)
|
|
35
|
+
return;
|
|
36
|
+
const lit = this.state.flashUntil > scene.time;
|
|
37
|
+
ctx.save();
|
|
38
|
+
ctx.strokeStyle = lit ? '#5ac54f' : 'rgba(255, 235, 87, 0.9)';
|
|
39
|
+
ctx.lineWidth = 4;
|
|
40
|
+
ctx.setLineDash([6, 4]);
|
|
41
|
+
ctx.strokeRect(box.x + 2, box.y + 2, box.width - 4, box.height - 4);
|
|
42
|
+
ctx.restore();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { Goal };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// Generated from ../../behaviors/Joints.jsx; run npm run sync:play-behaviors.
|
|
2
|
+
import { layoutCenter } from '../../engine/layout';
|
|
3
|
+
import { inActorWorldSpace } from '../../engine/physics/controls';
|
|
4
|
+
import '../../engine/physics/joints';
|
|
5
|
+
import { drawJointArt } from '../../engine/physics/jointArt';
|
|
6
|
+
|
|
7
|
+
// Joints: connect this actor to one or more `target` actors with physics links.
|
|
8
|
+
// The component holds a LIST so an actor can carry several links at once (a
|
|
9
|
+
// a body both sprung and roped, a truss node). Each entry picks a TYPE -- spring
|
|
10
|
+
// (elastic), rod (rigid stick, ends rotate; also the hinge -- to a static anchor),
|
|
11
|
+
// weld (fused, no relative rotation), rope (slack, taut at max length). The
|
|
12
|
+
// simulation builds the matter constraints
|
|
13
|
+
// (see physics/joints.js); this behavior owns the authoring UI + editor overlay.
|
|
14
|
+
//
|
|
15
|
+
// Both actors of a link need a Collider (to have a body); the owner is usually a
|
|
16
|
+
// dynamic RigidBody and each target either dynamic or a static anchor. `target`
|
|
17
|
+
// is instance-local -- pick it per instance, since a blueprint-level target would
|
|
18
|
+
// point every instance at the same actor.
|
|
19
|
+
class Joints {
|
|
20
|
+
static behaviorName = 'Joints';
|
|
21
|
+
// A link binds two bodies, so the OWNER needs a Collider to have one. Only the
|
|
22
|
+
// owner: the `target` actor needs one too, but it isn't a sibling -- it's a
|
|
23
|
+
// separate actor the author picks later, and inventing a Collider on it isn't
|
|
24
|
+
// this hook's business.
|
|
25
|
+
static expectedSiblings = ['Collider'];
|
|
26
|
+
static defaultProps = { list: [] };
|
|
27
|
+
// A freshly-added Joints behavior starts with one blank link to fill in.
|
|
28
|
+
static initialProps() {
|
|
29
|
+
return { list: [defaultJoint()] };
|
|
30
|
+
}
|
|
31
|
+
constructor(props) {
|
|
32
|
+
this.props = props;
|
|
33
|
+
}
|
|
34
|
+
// Draw every link. In the EDITOR (options.editPlaceholders) it's an authoring
|
|
35
|
+
// overlay -- always shown so connections are visible, sprite-art previewed
|
|
36
|
+
// WYSIWYG, and even `hidden` joints drawn as a faint line so you don't lose
|
|
37
|
+
// them. In PLAY each joint's `render` decides: `hidden` (nothing), `line` (the
|
|
38
|
+
// schematic) or `sprite` (art along the joint). Drawn in world space so the
|
|
39
|
+
// link doesn't spin with the actor's rotation (see inActorWorldSpace).
|
|
40
|
+
draw(actor, scene, ctx, options) {
|
|
41
|
+
const list = Array.isArray(this.props.list) ? this.props.list : [];
|
|
42
|
+
if (!list.length)
|
|
43
|
+
return;
|
|
44
|
+
const editing = Boolean(options.editPlaceholders);
|
|
45
|
+
const emphasized = options.colliderOverlayIds?.includes(actor.id) ||
|
|
46
|
+
scene.usesBlueprint(actor, options.dimBlueprintPath);
|
|
47
|
+
const a = layoutCenter(actor.components.Layout);
|
|
48
|
+
inActorWorldSpace(ctx, actor.components.Layout, (g) => {
|
|
49
|
+
for (const joint of list) {
|
|
50
|
+
const target = joint?.target && scene.getActor(joint.target);
|
|
51
|
+
if (!target || target.id === actor.id)
|
|
52
|
+
continue;
|
|
53
|
+
const b = layoutCenter(target.components.Layout);
|
|
54
|
+
// hidden shows as a faint line in the editor, nothing in play.
|
|
55
|
+
let render = joint.render ?? 'line';
|
|
56
|
+
if (editing && render === 'hidden')
|
|
57
|
+
render = 'line';
|
|
58
|
+
if (render === 'hidden')
|
|
59
|
+
continue;
|
|
60
|
+
if (render === 'sprite' && drawJointArt(g, scene, joint, a, b))
|
|
61
|
+
continue;
|
|
62
|
+
g.globalAlpha = editing ? (emphasized ? 1 : 0.45) : 0.7;
|
|
63
|
+
g.strokeStyle = '#c9a9ff';
|
|
64
|
+
g.fillStyle = '#c9a9ff';
|
|
65
|
+
g.lineWidth = 2;
|
|
66
|
+
drawLink(g, a, b, joint.type ?? 'spring');
|
|
67
|
+
g.globalAlpha = 1;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function defaultJoint() {
|
|
73
|
+
return { type: 'spring', target: '', length: -1, springiness: 0.4, damping: 0.1, render: 'line' };
|
|
74
|
+
}
|
|
75
|
+
// Draw the link between two world points, styled by joint type: spring coils,
|
|
76
|
+
// rope dashes, weld doubles the line, rod is a plain line.
|
|
77
|
+
function drawLink(ctx, a, b, type) {
|
|
78
|
+
if (type === 'spring')
|
|
79
|
+
return drawCoil(ctx, a, b);
|
|
80
|
+
if (type === 'rope') {
|
|
81
|
+
ctx.setLineDash([6, 5]);
|
|
82
|
+
line(ctx, a, b);
|
|
83
|
+
ctx.setLineDash([]);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (type === 'weld')
|
|
87
|
+
return drawDouble(ctx, a, b);
|
|
88
|
+
line(ctx, a, b); // rod (and any fallthrough)
|
|
89
|
+
}
|
|
90
|
+
function line(ctx, a, b) {
|
|
91
|
+
ctx.beginPath();
|
|
92
|
+
ctx.moveTo(a.x, a.y);
|
|
93
|
+
ctx.lineTo(b.x, b.y);
|
|
94
|
+
ctx.stroke();
|
|
95
|
+
}
|
|
96
|
+
// Two parallel lines offset along the perpendicular -- the "fused" read.
|
|
97
|
+
function drawDouble(ctx, a, b) {
|
|
98
|
+
const dx = b.x - a.x;
|
|
99
|
+
const dy = b.y - a.y;
|
|
100
|
+
const len = Math.hypot(dx, dy) || 1;
|
|
101
|
+
const nx = (-dy / len) * 3;
|
|
102
|
+
const ny = (dx / len) * 3;
|
|
103
|
+
line(ctx, { x: a.x + nx, y: a.y + ny }, { x: b.x + nx, y: b.y + ny });
|
|
104
|
+
line(ctx, { x: a.x - nx, y: a.y - ny }, { x: b.x - nx, y: b.y - ny });
|
|
105
|
+
}
|
|
106
|
+
// A zig-zag coil between the endpoints, straight stubs at each end.
|
|
107
|
+
function drawCoil(ctx, a, b) {
|
|
108
|
+
const dx = b.x - a.x;
|
|
109
|
+
const dy = b.y - a.y;
|
|
110
|
+
const len = Math.hypot(dx, dy) || 1;
|
|
111
|
+
const px = -dy / len;
|
|
112
|
+
const py = dx / len;
|
|
113
|
+
const coils = Math.max(3, Math.min(10, Math.round(len / 22)));
|
|
114
|
+
const amp = 6;
|
|
115
|
+
ctx.beginPath();
|
|
116
|
+
ctx.moveTo(a.x, a.y);
|
|
117
|
+
for (let i = 1; i < coils; i++) {
|
|
118
|
+
const t = i / coils;
|
|
119
|
+
const side = i % 2 === 0 ? 1 : -1;
|
|
120
|
+
ctx.lineTo(a.x + dx * t + px * amp * side, a.y + dy * t + py * amp * side);
|
|
121
|
+
}
|
|
122
|
+
ctx.lineTo(b.x, b.y);
|
|
123
|
+
ctx.stroke();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { Joints };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Generated from ../../behaviors/Layout.jsx; run npm run sync:play-behaviors.
|
|
2
|
+
import { DEFAULT_ORIGIN_Y, DEFAULT_ORIGIN_X, layoutRect } from '../../engine/layout';
|
|
3
|
+
|
|
4
|
+
class Layout {
|
|
5
|
+
static behaviorName = 'Layout';
|
|
6
|
+
static defaultProps = {
|
|
7
|
+
x: 0,
|
|
8
|
+
y: 0,
|
|
9
|
+
z: 0,
|
|
10
|
+
rotation: 0,
|
|
11
|
+
width: 50,
|
|
12
|
+
height: 50,
|
|
13
|
+
// Which point of the box `x`/`y` names, as a fraction of the box from its
|
|
14
|
+
// own top-left: `0, 0` top-left, `0.5, 0.5` center (the default, and what
|
|
15
|
+
// an absent origin means -- see DEFAULT_ORIGIN_* in engine/layout.js),
|
|
16
|
+
// `1, 1` bottom-right. Not clamped. Rotation still pivots on the box
|
|
17
|
+
// CENTER -- the origin anchors position only.
|
|
18
|
+
originX: DEFAULT_ORIGIN_X,
|
|
19
|
+
originY: DEFAULT_ORIGIN_Y,
|
|
20
|
+
// Show the Layout box (the invisible frame the sprite fills and the collider
|
|
21
|
+
// derives from) as a dashed outline, in editor and play. Per-actor toggle.
|
|
22
|
+
debug: false,
|
|
23
|
+
};
|
|
24
|
+
// Position first: it is what tells two instances of the same blueprint apart,
|
|
25
|
+
// and the first thing you look for when the panel is shut.
|
|
26
|
+
static summary(props) {
|
|
27
|
+
const round = (n) => Math.round(Number(n) || 0);
|
|
28
|
+
return `${round(props.x)}, ${round(props.y)} · ${round(props.width)}×${round(props.height)}`;
|
|
29
|
+
}
|
|
30
|
+
// Position/rotation/z never inherit from a blueprint: they're always written
|
|
31
|
+
// as instance values at placement time (z gets an explicit top-of-stack value
|
|
32
|
+
// on spawn), and a blueprint edit to its own template x/y/z/rotation only
|
|
33
|
+
// affects newly placed instances, never moves ones already placed. Because
|
|
34
|
+
// they're always instance-local, they're also never surfaced as blueprint
|
|
35
|
+
// "overrides" in the inspector. width/height default to inherited (absent),
|
|
36
|
+
// and so does the origin: it describes the KIND of thing (a ball is placed by
|
|
37
|
+
// its center), so it belongs on the blueprint -- with a per-instance override
|
|
38
|
+
// available like any other inherited prop.
|
|
39
|
+
//
|
|
40
|
+
// Size is width/height in card units -- the same space you compose in. A
|
|
41
|
+
// user-facing scaleX/scaleY (relative to the sprite's native pixels) was
|
|
42
|
+
// tried and reverted: it only pays off under pixel-perfect (integer scales),
|
|
43
|
+
// and in today's card-units model it just adds a conversion + couples Layout
|
|
44
|
+
// to the Sprite. Revisit scale fields when pixel-perfect mode lands. See
|
|
45
|
+
// ~/castle/cauldron-rendering-scale-model.md.
|
|
46
|
+
static propertyMeta = {
|
|
47
|
+
x: { inherit: false },
|
|
48
|
+
y: { inherit: false },
|
|
49
|
+
z: { inherit: false },
|
|
50
|
+
rotation: { inherit: false },
|
|
51
|
+
};
|
|
52
|
+
constructor(props) {
|
|
53
|
+
this.props = props;
|
|
54
|
+
}
|
|
55
|
+
// Outline the Layout box when `debug` is on. Drawn in the actor's own rotated
|
|
56
|
+
// frame (so it rotates with the actor), with a distinct dashed lavender style
|
|
57
|
+
// so it reads separately from the solid collider debug and the selection box.
|
|
58
|
+
draw(actor, scene, ctx) {
|
|
59
|
+
if (!this.props.debug)
|
|
60
|
+
return;
|
|
61
|
+
const rect = layoutRect(this.props);
|
|
62
|
+
ctx.save();
|
|
63
|
+
ctx.strokeStyle = 'rgba(190, 178, 255, 0.75)';
|
|
64
|
+
ctx.setLineDash([4, 3]);
|
|
65
|
+
ctx.lineWidth = 1.5;
|
|
66
|
+
ctx.strokeRect(rect.x + 0.5, rect.y + 0.5, rect.width - 1, rect.height - 1);
|
|
67
|
+
ctx.restore();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { Layout };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Generated from ../../behaviors/RigidBody.jsx; run npm run sync:play-behaviors.
|
|
2
|
+
import { DAMPING } from '../../engine/propertyRanges';
|
|
3
|
+
|
|
4
|
+
// RigidBody makes an actor a physics object. Pair it with a Collider (which
|
|
5
|
+
// gives the shape + material). The simulation reads these props each frame; the
|
|
6
|
+
// behavior itself does no per-frame work -- author code drives motion through
|
|
7
|
+
// `scene.physics` (setVelocity / applyImpulse / applyForce).
|
|
8
|
+
//
|
|
9
|
+
// bodyType 'dynamic' -> simulated: gravity, collisions, forces move it.
|
|
10
|
+
// 'static' -> never moves (a wall); a Collider alone is also this.
|
|
11
|
+
// 'kinematic' -> unpushable, but you move it by writing its Layout.
|
|
12
|
+
// gravityScale -> multiplies world gravity for this body (0 = float).
|
|
13
|
+
// drag -> linear damping (matter frictionAir).
|
|
14
|
+
// angularDrag -> extra spin damping.
|
|
15
|
+
// freezeRotation -> lock rotation (stays upright).
|
|
16
|
+
// velocityX/velocityY -> initial velocity, applied once when play starts.
|
|
17
|
+
class RigidBody {
|
|
18
|
+
static behaviorName = 'RigidBody';
|
|
19
|
+
// No Collider means no body at all (matterBridge's `isPhysicsActor`), so a
|
|
20
|
+
// RigidBody on its own simulates nothing.
|
|
21
|
+
static expectedSiblings = ['Collider'];
|
|
22
|
+
static defaultProps = {
|
|
23
|
+
bodyType: 'dynamic',
|
|
24
|
+
// New bodies float until the author opts into gravity — falling immediately
|
|
25
|
+
// on add is the common surprise when placing a dynamic body to push around.
|
|
26
|
+
gravityScale: 0,
|
|
27
|
+
drag: 0.01,
|
|
28
|
+
angularDrag: 0,
|
|
29
|
+
freezeRotation: false,
|
|
30
|
+
velocityX: 0,
|
|
31
|
+
velocityY: 0,
|
|
32
|
+
// Initial spin, degrees per fixed step (like velocityX/Y are px per step),
|
|
33
|
+
// applied once when play starts.
|
|
34
|
+
angularVelocity: 0,
|
|
35
|
+
};
|
|
36
|
+
// Body type is the whole question about a rigid body: does this thing fall,
|
|
37
|
+
// sit still, or get pushed around by hand.
|
|
38
|
+
static summary(props) {
|
|
39
|
+
return typeof props.bodyType === 'string' ? props.bodyType : '';
|
|
40
|
+
}
|
|
41
|
+
// `drag`/`angularDrag` are matter's air friction, where values above 1 flip
|
|
42
|
+
// the velocity sign and destabilize the body -- so 1 is a real ceiling, not a
|
|
43
|
+
// convenience. `gravityScale` deliberately has none: negative is legitimate
|
|
44
|
+
// (it inverts gravity), as is scaling well past 1. Drag steps at 0.005 so the
|
|
45
|
+
// scrubber lands on the default (0.01) and the finer authored values kits use.
|
|
46
|
+
static propertyMeta = {
|
|
47
|
+
gravityScale: { step: 0.1 },
|
|
48
|
+
drag: { ...DAMPING, step: 0.005 },
|
|
49
|
+
angularDrag: DAMPING,
|
|
50
|
+
angularVelocity: { step: 0.1 },
|
|
51
|
+
};
|
|
52
|
+
constructor(props) {
|
|
53
|
+
this.props = props;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { RigidBody };
|