castle-web-cli 0.4.84 → 0.4.86
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/ide.js +35 -13
- package/dist/shell/assets/{index-BOgm5T3W.js → index-BJLaUTJE.js} +21 -21
- package/dist/shell/index.html +1 -1
- package/kits/basic-2d/CLAUDE.md +3 -3
- package/kits/basic-2d/behaviors/Collider.jsx +172 -26
- package/kits/basic-2d/behaviors/Layout.jsx +24 -0
- package/kits/basic-2d/editors/PlayOnly.jsx +11 -9
- package/kits/basic-2d/editors/SceneEditor.jsx +49 -16
- package/kits/basic-2d/editors/SelectionOverlay.jsx +21 -11
- package/kits/basic-2d/editors/behaviorRegistry.js +9 -3
- package/kits/basic-2d/engine/behaviorExtensions.js +28 -0
- package/kits/basic-2d/engine/collider.js +60 -6
- package/kits/basic-2d/engine/scene.js +28 -2
- package/kits/basic-2d/engine/systemRegistry.js +12 -0
- package/kits/basic-2d/engine/ui.jsx +2 -0
- package/kits/basic-2d/main.jsx +3 -2
- package/kits/physics-2d/.prettierrc +8 -0
- package/kits/physics-2d/CLAUDE.md +329 -0
- package/kits/physics-2d/behaviors/Camera.jsx +43 -0
- package/kits/physics-2d/behaviors/Collider.jsx +213 -0
- package/kits/physics-2d/behaviors/Goal.jsx +29 -0
- package/kits/physics-2d/behaviors/Layout.jsx +53 -0
- package/kits/physics-2d/behaviors/Sprite.jsx +352 -0
- package/kits/physics-2d/behaviors/tint.js +47 -0
- package/kits/physics-2d/blueprints/ball.scene +14 -0
- package/kits/physics-2d/blueprints/block.scene +12 -0
- package/kits/physics-2d/blueprints/cauldron.scene +18 -0
- package/kits/physics-2d/blueprints/crate.scene +14 -0
- package/kits/physics-2d/blueprints/goal.scene +12 -0
- package/kits/physics-2d/castle.json +13 -0
- package/kits/physics-2d/docs/pxart-format.md +377 -0
- package/kits/physics-2d/drawings/block.pxart +25 -0
- package/kits/physics-2d/drawings/cauldron.pxart +113 -0
- package/kits/physics-2d/editors/BlueprintLibrary.jsx +247 -0
- package/kits/physics-2d/editors/ErrorBoundary.jsx +59 -0
- package/kits/physics-2d/editors/PlayOnly.jsx +31 -0
- package/kits/physics-2d/editors/PxArtEditor.jsx +954 -0
- package/kits/physics-2d/editors/SceneEditor.jsx +1696 -0
- package/kits/physics-2d/editors/SelectionOverlay.jsx +909 -0
- package/kits/physics-2d/editors/SingleEditor.jsx +122 -0
- package/kits/physics-2d/editors/behaviorRegistry.js +30 -0
- package/kits/physics-2d/editors/editorHistory.js +157 -0
- package/kits/physics-2d/editors/inspectorSheet.js +13 -0
- package/kits/physics-2d/editors/pixelCanvas.js +11 -0
- package/kits/physics-2d/editors/pixelEditorChrome.jsx +74 -0
- package/kits/physics-2d/editors/pixelGeometry.js +140 -0
- package/kits/physics-2d/editors/pixelInspector.jsx +633 -0
- package/kits/physics-2d/editors/pxArtEditorModel.js +732 -0
- package/kits/physics-2d/editors/pxArtPlayback.js +92 -0
- package/kits/physics-2d/editors/pxArtTimeline.jsx +752 -0
- package/kits/physics-2d/editors/pxArtTimeline.module.css +506 -0
- package/kits/physics-2d/editors/pxArtTools.js +232 -0
- package/kits/physics-2d/editors/useArtboardFit.js +102 -0
- package/kits/physics-2d/engine/ScenePlayer.jsx +196 -0
- package/kits/physics-2d/engine/SceneUI.jsx +59 -0
- package/kits/physics-2d/engine/assets.js +15 -0
- package/kits/physics-2d/engine/autoInspector.jsx +70 -0
- package/kits/physics-2d/engine/behaviorExtensions.js +28 -0
- package/kits/physics-2d/engine/blueprint.js +521 -0
- package/kits/physics-2d/engine/collider.js +200 -0
- package/kits/physics-2d/engine/files.js +117 -0
- package/kits/physics-2d/engine/liveReload.js +88 -0
- package/kits/physics-2d/engine/pxart.js +1032 -0
- package/kits/physics-2d/engine/pxartSmooth.js +222 -0
- package/kits/physics-2d/engine/scene.js +685 -0
- package/kits/physics-2d/engine/spriteGeometry.js +32 -0
- package/kits/physics-2d/engine/systemRegistry.js +12 -0
- package/kits/physics-2d/engine/ui.jsx +688 -0
- package/kits/physics-2d/engine/ui.module.css +2287 -0
- package/kits/physics-2d/eslint.config.js +71 -0
- package/kits/physics-2d/index.html +24 -0
- package/kits/physics-2d/main.jsx +24 -0
- package/kits/physics-2d/package-lock.json +2706 -0
- package/kits/physics-2d/package.json +42 -0
- package/kits/physics-2d/physics/PhysicsSystem.js +290 -0
- package/kits/physics-2d/physics/behaviors/AnalogStick.jsx +101 -0
- package/kits/physics-2d/physics/behaviors/Draggable.jsx +79 -0
- package/kits/physics-2d/physics/behaviors/RigidBody.jsx +55 -0
- package/kits/physics-2d/physics/behaviors/Slingshot.jsx +118 -0
- package/kits/physics-2d/physics/controls.js +79 -0
- package/kits/physics-2d/physics/extensions/collider.js +15 -0
- package/kits/physics-2d/physics/index.js +26 -0
- package/kits/physics-2d/physics/matterBridge.js +126 -0
- package/kits/physics-2d/pnpm-lock.yaml +1761 -0
- package/kits/physics-2d/scenes/main.scene +12 -0
- package/kits/physics-2d/scenes/sandbox.scene +13 -0
- package/kits/physics-2d/scripts/draw.mjs +121 -0
- package/kits/physics-2d/systems/physics.js +8 -0
- package/kits/physics-2d/vite.config.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Shared sprite-to-Layout geometry. Lives in engine/ (not behaviors/) so both
|
|
2
|
+
// Sprite.jsx (rendering) and the Collider rect logic (engine/collider.js) can
|
|
3
|
+
// use the same math without behaviors/ <-> engine/ import cycles.
|
|
4
|
+
|
|
5
|
+
// Destination rect for a draw mode: the Layout box for `stretch`/`tile`, or an
|
|
6
|
+
// aspect-ratio-preserving centered rect for `fit` and `cover`:
|
|
7
|
+
// - `fit` (CSS object-fit: contain): the largest rect with the art's aspect
|
|
8
|
+
// ratio that fits INSIDE the box -- letterboxed sides just aren't drawn.
|
|
9
|
+
// - `cover` (CSS object-fit: cover): the smallest rect with the art's aspect
|
|
10
|
+
// ratio that fully COVERS the box -- the overflow is cropped by the caller
|
|
11
|
+
// clipping to the Layout box (see Sprite.draw).
|
|
12
|
+
// `artSize` only needs `.width`/`.height` -- a rendered canvas or a sprite's
|
|
13
|
+
// `.resolution` both work.
|
|
14
|
+
export function spriteDestRect(mode, layout, artSize) {
|
|
15
|
+
if (mode !== 'fit' && mode !== 'cover') return layout;
|
|
16
|
+
const aspect = artSize.width / artSize.height;
|
|
17
|
+
let width = layout.width;
|
|
18
|
+
let height = width / aspect;
|
|
19
|
+
// `fit` shrinks until the art fits inside the box; `cover` grows until it
|
|
20
|
+
// fills the box. The comparison flips between the two.
|
|
21
|
+
const overflows = mode === 'fit' ? height > layout.height : height < layout.height;
|
|
22
|
+
if (overflows) {
|
|
23
|
+
height = layout.height;
|
|
24
|
+
width = height * aspect;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
x: layout.x + (layout.width - width) / 2,
|
|
28
|
+
y: layout.y + (layout.height - height) / 2,
|
|
29
|
+
width,
|
|
30
|
+
height,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Discover per-frame runtime systems from `systems/*.js`. Each such module
|
|
2
|
+
// exports `installSystem(runtime)`, which is called once for every created
|
|
3
|
+
// SceneRuntime (see engine/scene.js `makeScene`) to register itself via
|
|
4
|
+
// `runtime.registerSystem(...)`. A system is a plain object with an optional
|
|
5
|
+
// `afterBehaviors(scene, dt)` hook, run once per frame after all behavior
|
|
6
|
+
// updates. Empty in a kit with no `systems/` dir (e.g. basic-2d); a kit adds a
|
|
7
|
+
// system by dropping a file here -- no edits to the engine required. Symmetric
|
|
8
|
+
// with editors/behaviorRegistry.js.
|
|
9
|
+
const modules = import.meta.glob('../systems/*.js', { eager: true });
|
|
10
|
+
export const systemInstallers = Object.values(modules)
|
|
11
|
+
.map((mod) => mod.installSystem)
|
|
12
|
+
.filter((fn) => typeof fn === 'function');
|