@almadar/ui 5.105.0 → 5.107.0
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/avl/index.cjs +1903 -4193
- package/dist/avl/index.js +998 -3288
- package/dist/components/core/atoms/index.d.ts +1 -1
- package/dist/components/core/molecules/index.d.ts +1 -1
- package/dist/components/core/organisms/index.d.ts +1 -1
- package/dist/components/core/templates/index.d.ts +2 -2
- package/dist/components/game/{2d/atoms → atoms}/ActionButton.d.ts +1 -1
- package/dist/components/game/{2d/atoms → atoms}/ChoiceButton.d.ts +1 -1
- package/dist/components/game/{2d/atoms → atoms}/ControlButton.d.ts +1 -1
- package/dist/components/game/atoms/DrawShape.d.ts +50 -0
- package/dist/components/game/atoms/DrawSprite.d.ts +47 -0
- package/dist/components/game/atoms/DrawText.d.ts +31 -0
- package/dist/components/game/{2d/atoms → atoms}/GameAudioToggle.d.ts +1 -1
- package/dist/components/game/{2d/atoms → atoms}/GameIcon.d.ts +1 -1
- package/dist/components/game/{2d/atoms → atoms}/ItemSlot.d.ts +1 -1
- package/dist/components/game/{2d/atoms → atoms}/MiniMap.d.ts +1 -1
- package/dist/components/game/{2d/atoms → atoms}/ResourceCounter.d.ts +2 -2
- package/dist/components/game/{2d/atoms → atoms}/ScoreDisplay.d.ts +1 -1
- package/dist/components/game/{2d/atoms → atoms}/Sprite.d.ts +1 -1
- package/dist/components/game/{2d/atoms → atoms}/StateIndicator.d.ts +1 -1
- package/dist/components/game/{2d/atoms → atoms}/StatusEffect.d.ts +1 -1
- package/dist/components/game/{2d/atoms → atoms}/WaypointMarker.d.ts +1 -1
- package/dist/components/game/{shared/hooks → hooks}/useCamera.d.ts +1 -1
- package/dist/components/game/{shared/hooks → hooks}/useUnitSpriteAtlas.d.ts +2 -2
- package/dist/components/game/{shared → lib}/index.d.ts +1 -2
- package/dist/components/game/{shared/lib → lib}/puzzleObject.d.ts +1 -1
- package/dist/components/game/{2d/molecules → molecules}/ActionTile.d.ts +1 -1
- package/dist/components/game/molecules/Canvas.d.ts +96 -0
- package/dist/components/game/molecules/Canvas2D.d.ts +120 -0
- package/dist/components/game/{2d/molecules → molecules}/ControlGrid.d.ts +1 -1
- package/dist/components/game/molecules/DrawShapeLayer.d.ts +19 -0
- package/dist/components/game/molecules/DrawSpriteLayer.d.ts +21 -0
- package/dist/components/game/molecules/DrawTextLayer.d.ts +22 -0
- package/dist/components/game/{2d/molecules → molecules}/GameHud.d.ts +1 -1
- package/dist/components/game/{2d/molecules → molecules}/InventoryGrid.d.ts +1 -1
- package/dist/components/game/{2d/molecules → molecules}/ResourceBar.d.ts +1 -1
- package/dist/components/game/{2d/molecules → molecules}/StatBadge.d.ts +1 -1
- package/dist/components/game/{2d/molecules → molecules}/StateNode.d.ts +1 -1
- package/dist/components/game/{2d/molecules → molecules}/TraitSlot.d.ts +1 -1
- package/dist/components/game/{2d/molecules → molecules}/TraitStateViewer.d.ts +1 -1
- package/dist/components/game/{2d/molecules → molecules}/TransitionArrow.d.ts +1 -1
- package/dist/components/game/{2d/molecules → molecules}/index.d.ts +9 -16
- package/dist/components/game/patterns.d.ts +20 -0
- package/dist/components/game/{shared/providers → providers}/GameAudioProvider.d.ts +1 -1
- package/dist/components/game/{2d/templates → templates}/GameTemplate.d.ts +1 -1
- package/dist/components/game/{3d → three}/atoms/SpriteBillboard3D.d.ts +1 -1
- package/dist/components/game/{shared → three}/hooks/useGameCanvas3DEvents.d.ts +4 -3
- package/dist/components/game/{3d → three}/index.cjs +766 -3008
- package/dist/components/game/{3d → three}/index.css +3 -3
- package/dist/components/game/{3d → three}/index.d.ts +0 -1
- package/dist/components/game/{3d → three}/index.js +622 -2863
- package/dist/components/game/{shared → three}/lib/game3dAssetManifest.d.ts +1 -1
- package/dist/components/game/three/molecules/GameCanvas3D.d.ts +175 -0
- package/dist/components/game/{3d → three}/molecules/index.d.ts +9 -12
- package/dist/components/game/{3d → three}/patterns.d.ts +0 -4
- package/dist/components/index.cjs +2315 -4418
- package/dist/components/index.js +1412 -3508
- package/dist/lib/drawable/Drawable3D.d.ts +20 -0
- package/dist/lib/drawable/contract.d.ts +68 -0
- package/dist/lib/drawable/hitTest.d.ts +23 -0
- package/dist/lib/drawable/mesh3d.d.ts +28 -0
- package/dist/lib/drawable/paintDispatch.d.ts +22 -0
- package/dist/lib/drawable/projector.d.ts +14 -0
- package/dist/lib/drawable/projector3d.d.ts +20 -0
- package/dist/lib/imageCache.d.ts +9 -0
- package/dist/lib/painter2d.d.ts +81 -0
- package/dist/lib/webPainter2d.d.ts +7 -0
- package/dist/marketing/index.cjs +10 -0
- package/dist/marketing/index.js +10 -0
- package/dist/providers/index.cjs +1748 -4042
- package/dist/providers/index.js +956 -3250
- package/dist/runtime/index.cjs +1758 -4048
- package/dist/runtime/index.js +972 -3262
- package/package.json +13 -13
- package/dist/components/game/2d/molecules/Canvas2D.d.ts +0 -175
- package/dist/components/game/2d/molecules/SideCanvas2D.d.ts +0 -36
- package/dist/components/game/2d/organisms/BuilderBoard.d.ts +0 -60
- package/dist/components/game/2d/organisms/ClassifierBoard.d.ts +0 -66
- package/dist/components/game/2d/organisms/DebuggerBoard.d.ts +0 -61
- package/dist/components/game/2d/organisms/EventHandlerBoard.d.ts +0 -42
- package/dist/components/game/2d/organisms/NegotiatorBoard.d.ts +0 -56
- package/dist/components/game/2d/organisms/SequencerBoard.d.ts +0 -69
- package/dist/components/game/2d/organisms/SimulatorBoard.d.ts +0 -58
- package/dist/components/game/2d/organisms/StateArchitectBoard.d.ts +0 -61
- package/dist/components/game/3d/atoms/EventMarker3D.d.ts +0 -17
- package/dist/components/game/3d/molecules/FeatureMesh3D.d.ts +0 -21
- package/dist/components/game/3d/molecules/GameCanvas3D.d.ts +0 -259
- package/dist/components/game/3d/molecules/SideScene3D.d.ts +0 -31
- package/dist/components/game/3d/molecules/TileMesh3D.d.ts +0 -28
- package/dist/components/game/3d/molecules/UnitMesh3D.d.ts +0 -29
- package/dist/components/game/3d/organisms/GameBoard3D.d.ts +0 -66
- package/dist/components/game/3d/templates/GameCanvas3DBattleTemplate.d.ts +0 -82
- package/dist/components/game/3d/templates/GameCanvas3DCastleTemplate.d.ts +0 -87
- package/dist/components/game/3d/templates/GameCanvas3DWorldMapTemplate.d.ts +0 -95
- package/dist/components/game/shared/effects.d.ts +0 -253
- /package/dist/components/game/{2d/atoms → atoms}/ComboCounter.d.ts +0 -0
- /package/dist/components/game/{2d/atoms → atoms}/DamageNumber.d.ts +0 -0
- /package/dist/components/game/{2d/atoms → atoms}/DialogueBubble.d.ts +0 -0
- /package/dist/components/game/{2d/atoms → atoms}/GameCard.d.ts +0 -0
- /package/dist/components/game/{2d/atoms → atoms}/HealthBar.d.ts +0 -0
- /package/dist/components/game/{2d/atoms → atoms}/TimerDisplay.d.ts +0 -0
- /package/dist/components/game/{2d/atoms → atoms}/TurnIndicator.d.ts +0 -0
- /package/dist/components/game/{shared/hooks → hooks}/useGameAudio.d.ts +0 -0
- /package/dist/components/game/{shared → hooks}/useImageCache.d.ts +0 -0
- /package/dist/components/game/{shared → lib}/boardEntity.d.ts +0 -0
- /package/dist/components/game/{shared/lib → lib}/editorUtils.d.ts +0 -0
- /package/dist/components/game/{shared → lib}/game.d.ts +0 -0
- /package/dist/components/game/{shared → lib}/isometric.d.ts +0 -0
- /package/dist/components/game/{shared → lib}/isometricTypes.d.ts +0 -0
- /package/dist/components/game/{shared → lib}/makeAsset.d.ts +0 -0
- /package/dist/components/game/{shared/lib → lib}/mechanics.d.ts +0 -0
- /package/dist/components/game/{shared/lib → lib}/physicsPresets.d.ts +0 -0
- /package/dist/components/game/{shared/lib → lib}/physicsTypes.d.ts +0 -0
- /package/dist/components/game/{shared → lib}/spriteAnimation.d.ts +0 -0
- /package/dist/components/game/{shared → lib}/spriteAnimationTypes.d.ts +0 -0
- /package/dist/components/game/{shared → lib}/spriteSheetConstants.d.ts +0 -0
- /package/dist/components/game/{2d/molecules → molecules}/ActionPalette.d.ts +0 -0
- /package/dist/components/game/{2d/molecules → molecules}/EventLog.d.ts +0 -0
- /package/dist/components/game/{2d/molecules → molecules}/GameMenu.d.ts +0 -0
- /package/dist/components/game/{2d/molecules → molecules}/ObjectRulePanel.d.ts +0 -0
- /package/dist/components/game/{2d/molecules → molecules}/RuleEditor.d.ts +0 -0
- /package/dist/components/game/{2d/molecules → molecules}/SequenceBar.d.ts +0 -0
- /package/dist/components/game/{2d/molecules → molecules}/StateGraph.d.ts +0 -0
- /package/dist/components/game/{2d/molecules → molecules}/StateJsonView.d.ts +0 -0
- /package/dist/components/game/{2d/molecules → molecules}/VariablePanel.d.ts +0 -0
- /package/dist/components/game/{2d/templates → templates}/GameShell.d.ts +0 -0
- /package/dist/components/game/{shared → three}/game3dTheme.d.ts +0 -0
- /package/dist/components/game/{shared → three}/hooks/useAssetLoader.d.ts +0 -0
- /package/dist/components/game/{shared → three}/hooks/useRaycaster.d.ts +0 -0
- /package/dist/components/game/{shared → three}/hooks/useSceneGraph.d.ts +0 -0
- /package/dist/components/game/{shared → three}/hooks/useThree.d.ts +0 -0
- /package/dist/components/game/{shared → three}/lib/AssetLoader.d.ts +0 -0
- /package/dist/components/game/{shared → three}/lib/culling.d.ts +0 -0
- /package/dist/components/game/{shared → three}/lib/grid3D.d.ts +0 -0
- /package/dist/components/game/{3d → three}/molecules/Camera3D.d.ts +0 -0
- /package/dist/components/game/{3d → three}/molecules/Canvas3DErrorBoundary.d.ts +0 -0
- /package/dist/components/game/{3d → three}/molecules/Canvas3DLoadingState.d.ts +0 -0
- /package/dist/components/game/{3d → three}/molecules/GameCamera3D.d.ts +0 -0
- /package/dist/components/game/{3d → three}/molecules/Lighting3D.d.ts +0 -0
- /package/dist/components/game/{3d → three}/molecules/ModelLoader.d.ts +0 -0
- /package/dist/components/game/{3d → three}/molecules/Scene3D.d.ts +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drawable3D — the R3F dispatcher for neutral drawable descriptors.
|
|
3
|
+
*
|
|
4
|
+
* The 3D twin of `paintDrawable`: given ONE descriptor, it renders the matching
|
|
5
|
+
* R3F element (mesh/billboard). ⚠ R3F throws if a plain descriptor object reaches
|
|
6
|
+
* `<group>{children}` — the host must ALWAYS map descriptors through THIS
|
|
7
|
+
* component first, never pass raw `DrawableNode`s as children. Consumes the same
|
|
8
|
+
* `DrawSpriteProps`/`DrawShapeProps`/`DrawTextProps` descriptors as the 2D paint
|
|
9
|
+
* dispatch — that is what makes canvas-2d and canvas-3d the same `children`
|
|
10
|
+
* interface.
|
|
11
|
+
*/
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import type { Projector3D } from './projector3d';
|
|
14
|
+
import type { DrawableNode } from './paintDispatch';
|
|
15
|
+
export interface Drawable3DProps {
|
|
16
|
+
node: DrawableNode;
|
|
17
|
+
projector: Projector3D;
|
|
18
|
+
}
|
|
19
|
+
export declare function Drawable3D({ node, projector }: Drawable3DProps): React.JSX.Element | null;
|
|
20
|
+
export default Drawable3D;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drawable contract — the shared vocabulary every neutral drawable primitive
|
|
3
|
+
* (the `draw-sprite`/`draw-shape`/`draw-text` atoms, `draw-sprite-layer`/
|
|
4
|
+
* `draw-shape-layer` molecules) is authored against. A drawable is a pure
|
|
5
|
+
* descriptor the canvas HOST walks and paints via the portable {@link Painter2D}
|
|
6
|
+
* seam — no `CanvasRenderingContext2D`, no DOM. Genre (a "unit"/"tile"/
|
|
7
|
+
* "highlight") is a `.lolo` COMPOSITION of these, never its own primitive.
|
|
8
|
+
*
|
|
9
|
+
* A position is a core `ScenePos` (logical scene space). The host's {@link Projector}
|
|
10
|
+
* maps it to pixels; primitives never do projection math themselves. Because the
|
|
11
|
+
* `ScenePos` type identity is what pattern-sync stamps as the `drawable`
|
|
12
|
+
* capability, every drawable descriptor's `position` MUST be a core `ScenePos`.
|
|
13
|
+
*/
|
|
14
|
+
import type { ScenePos } from '@almadar/core';
|
|
15
|
+
import type { Painter2D, PainterPoint } from '../painter2d';
|
|
16
|
+
/**
|
|
17
|
+
* How a drawable aligns to its projected position.
|
|
18
|
+
* - `top-left` — the cell's top-left corner (tiles).
|
|
19
|
+
* - `ground` — the cell's ground point, bottom-center of the drawable (units/features).
|
|
20
|
+
* - `center` — the cell's visual center (effects).
|
|
21
|
+
*/
|
|
22
|
+
export type DrawableAnchor = 'top-left' | 'ground' | 'center';
|
|
23
|
+
/**
|
|
24
|
+
* Maps logical scene coordinates to pixel space for one projection (iso/hex/flat/free).
|
|
25
|
+
* Owns ALL projection geometry so the primitives stay projection-agnostic. The host
|
|
26
|
+
* applies the camera transform on the painter around the walk; the projector is
|
|
27
|
+
* pre-camera (logical→cell-pixel).
|
|
28
|
+
*/
|
|
29
|
+
export interface Projector {
|
|
30
|
+
/** Cell top-left in pixels. */
|
|
31
|
+
project(pos: ScenePos): PainterPoint;
|
|
32
|
+
/** The pixel reference point for an anchor (see {@link DrawableAnchor}). */
|
|
33
|
+
anchorPoint(pos: ScenePos, anchor: DrawableAnchor): PainterPoint;
|
|
34
|
+
/** The cell footprint polygon — a rect (square grids) or a diamond (iso/hex). */
|
|
35
|
+
cellPath(pos: ScenePos): PainterPoint[];
|
|
36
|
+
/** Scaled cell width in px (`TILE_WIDTH * scale`). */
|
|
37
|
+
readonly tileWidth: number;
|
|
38
|
+
/** Scaled floor/diamond height in px (`FLOOR_HEIGHT * scale`). */
|
|
39
|
+
readonly floorHeight: number;
|
|
40
|
+
/** Scaled diamond-top offset in px (`DIAMOND_TOP_Y * scale`). */
|
|
41
|
+
readonly diamondTopY: number;
|
|
42
|
+
/** Render scale factor. */
|
|
43
|
+
readonly scale: number;
|
|
44
|
+
/** True for square-pitch grids (`flat`/`free`); false for diamond (iso/hex). */
|
|
45
|
+
readonly squareGrid: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** Per-frame context handed to every paint fn. */
|
|
48
|
+
export interface DrawContext {
|
|
49
|
+
projector: Projector;
|
|
50
|
+
/** Animation clock in ms (0 when static). Reserved for a LOLO-driven pulse/breathe input. */
|
|
51
|
+
time: number;
|
|
52
|
+
/** Force a host re-draw once an async resource (image / atlas JSON) has loaded. */
|
|
53
|
+
invalidate: () => void;
|
|
54
|
+
}
|
|
55
|
+
/** Common shape of every drawable descriptor. `type` keys the host's paint dispatch. */
|
|
56
|
+
export interface DrawableBase {
|
|
57
|
+
type: string;
|
|
58
|
+
/**
|
|
59
|
+
* Optional hit-test handle. When a board authors a per-entity id here (e.g.
|
|
60
|
+
* `id: (object/get @u id)` on a unit sprite), the canvas host indexes the
|
|
61
|
+
* descriptor's `ScenePos → id` and resolves a pointer/raycast at that cell to
|
|
62
|
+
* this id — the source of `unitClickEvent {unitId}`. A source-tagged handle,
|
|
63
|
+
* NOT a heuristic: no id → the host emits only the coordinate (tile click).
|
|
64
|
+
*/
|
|
65
|
+
id?: string;
|
|
66
|
+
}
|
|
67
|
+
/** A paint function: draws one descriptor of type `T` to the painter. */
|
|
68
|
+
export type PaintFn<T extends DrawableBase> = (painter: Painter2D, node: T, dctx: DrawContext) => void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drawable click hit-test — the shared walk both canvas hosts (2D + 3D) use to
|
|
3
|
+
* resolve a pointer/raycast at a scene cell to a per-entity id.
|
|
4
|
+
*
|
|
5
|
+
* A drawable descriptor carries an optional source-tagged `id` (see
|
|
6
|
+
* {@link DrawableBase.id}); a board tags its unit sprites (`id: (@u id)`). The
|
|
7
|
+
* host collects every drawn descriptor's `ScenePos` + `id`, builds a
|
|
8
|
+
* `"x,y" → id` index (later descriptors win, so a unit drawn over its tile takes
|
|
9
|
+
* the cell), and a click that lands on a tagged cell becomes `unitClick {unitId}`.
|
|
10
|
+
* No id → the host emits only the coordinate (tile click). One owner, both hosts —
|
|
11
|
+
* no per-host duplicate walker.
|
|
12
|
+
*/
|
|
13
|
+
import type { ScenePos } from '@almadar/core';
|
|
14
|
+
import type { DrawableNode } from './paintDispatch';
|
|
15
|
+
/** One drawn descriptor's scene position + optional hit-test id. */
|
|
16
|
+
export interface DrawnItem {
|
|
17
|
+
pos: ScenePos;
|
|
18
|
+
id?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Collect every drawable's scene position + hit id (atoms directly; layers via `items`). */
|
|
21
|
+
export declare function collectDrawnItems(nodes: DrawableNode[]): DrawnItem[];
|
|
22
|
+
/** Build the `"x,y" → id` cell index from the tagged descriptors (later wins). */
|
|
23
|
+
export declare function buildHitIndex(items: DrawnItem[]): Map<string, string>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* R3F mesh backends for the neutral drawable atoms — the 3D twin of the atoms'
|
|
3
|
+
* 2D `paint*` fns. Kept HERE (not in the atom files) so the `three`/`drei`/`fiber`
|
|
4
|
+
* dependency stays out of the 2D paint path; only the 3D dispatcher `Drawable3D`
|
|
5
|
+
* (→ used by `GameCanvas3D`, itself in the code-split 3D surface) imports this.
|
|
6
|
+
* Each mesh consumes the SAME descriptor as its 2D painter, so canvas-2d and
|
|
7
|
+
* canvas-3d render the same `children`.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import type { DrawSpriteProps } from '../../components/game/atoms/DrawSprite';
|
|
11
|
+
import type { DrawShapeProps } from '../../components/game/atoms/DrawShape';
|
|
12
|
+
import type { DrawTextProps } from '../../components/game/atoms/DrawText';
|
|
13
|
+
import type { Projector3D } from './projector3d';
|
|
14
|
+
/** R3F mesh backend for `draw-sprite`: a GLB via `ModelLoader` when `asset.dimension === '3d'`; else a billboard. */
|
|
15
|
+
export declare function Sprite3D({ node, projector }: {
|
|
16
|
+
node: DrawSpriteProps;
|
|
17
|
+
projector: Projector3D;
|
|
18
|
+
}): React.JSX.Element | null;
|
|
19
|
+
/** R3F mesh backend for `draw-shape`: a flat mesh on the ground plane. */
|
|
20
|
+
export declare function Shape3D({ node, projector }: {
|
|
21
|
+
node: DrawShapeProps;
|
|
22
|
+
projector: Projector3D;
|
|
23
|
+
}): React.JSX.Element | null;
|
|
24
|
+
/** R3F mesh backend for `draw-text`: a billboarded drei `<Text>` above the scene position. */
|
|
25
|
+
export declare function Text3D({ node, projector }: {
|
|
26
|
+
node: DrawTextProps;
|
|
27
|
+
projector: Projector3D;
|
|
28
|
+
}): React.JSX.Element | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drawable paint dispatch (2D) + the `DrawableNode` union.
|
|
3
|
+
*
|
|
4
|
+
* `paintDrawable` routes ONE descriptor to its 2D painter; the host walks its
|
|
5
|
+
* `children` through it. The "drawable" designation itself is NOT recorded here —
|
|
6
|
+
* it is DERIVED from the core `ScenePos` type each descriptor's `position` uses
|
|
7
|
+
* and stamped into `patterns-registry.json` by pattern-sync (mirroring how `Asset`
|
|
8
|
+
* is tagged), then read by the orbital-rust validator. So this module is pure
|
|
9
|
+
* paint routing; the capability is the registry's, not a hand-list.
|
|
10
|
+
*/
|
|
11
|
+
import type { Painter2D } from '../painter2d';
|
|
12
|
+
import type { DrawContext } from './contract';
|
|
13
|
+
import { type DrawSpriteProps } from '../../components/game/atoms/DrawSprite';
|
|
14
|
+
import { type DrawShapeProps } from '../../components/game/atoms/DrawShape';
|
|
15
|
+
import { type DrawTextProps } from '../../components/game/atoms/DrawText';
|
|
16
|
+
import { type DrawSpriteLayerProps } from '../../components/game/molecules/DrawSpriteLayer';
|
|
17
|
+
import { type DrawShapeLayerProps } from '../../components/game/molecules/DrawShapeLayer';
|
|
18
|
+
import { type DrawTextLayerProps } from '../../components/game/molecules/DrawTextLayer';
|
|
19
|
+
/** Every drawable descriptor. The host's `children` are a `DrawableNode[]`. */
|
|
20
|
+
export type DrawableNode = DrawSpriteProps | DrawShapeProps | DrawTextProps | DrawSpriteLayerProps | DrawShapeLayerProps | DrawTextLayerProps;
|
|
21
|
+
/** Dispatch a drawable descriptor to its 2D painter. Unknown types are skipped — never throws. */
|
|
22
|
+
export declare function paintDrawable(painter: Painter2D, node: DrawableNode, dctx: DrawContext): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Projector } from './contract';
|
|
2
|
+
import { type TileLayout } from '../../components/game/lib/isometric';
|
|
3
|
+
/** Projection modes the 2D host supports. `side` is handled by the side host, not here. */
|
|
4
|
+
export type Projection2D = TileLayout | 'free';
|
|
5
|
+
export interface Projector2DOptions {
|
|
6
|
+
scale: number;
|
|
7
|
+
/** Horizontal offset that centers the grid (0 for `flat`/`free`). */
|
|
8
|
+
baseOffsetX: number;
|
|
9
|
+
layout: Projection2D;
|
|
10
|
+
/** Override the measured diamond-top offset (default `DIAMOND_TOP_Y`). */
|
|
11
|
+
diamondTopY?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Build a {@link Projector} for a 2D projection. */
|
|
14
|
+
export declare function create2DProjector(opts: Projector2DOptions): Projector;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 3D projector — maps a core `ScenePos` to an R3F world position, mirroring the
|
|
3
|
+
* `gridToWorld` convention in `grid3D.ts` (grid X → world X, grid Y → world Z on
|
|
4
|
+
* the ground plane, scene Z → world Y as height). The 3D twin of `create2DProjector`;
|
|
5
|
+
* the SAME drawable descriptors flow to both, only the renderer differs (mesh vs paint).
|
|
6
|
+
*/
|
|
7
|
+
import type { ScenePos } from '@almadar/core';
|
|
8
|
+
export interface Projector3D {
|
|
9
|
+
/** Scene position → `[x, y, z]` world position (y is up). */
|
|
10
|
+
toWorld(pos: ScenePos): [number, number, number];
|
|
11
|
+
/** World units per grid cell. */
|
|
12
|
+
readonly cellSize: number;
|
|
13
|
+
}
|
|
14
|
+
export interface Projector3DOptions {
|
|
15
|
+
cellSize?: number;
|
|
16
|
+
offsetX?: number;
|
|
17
|
+
offsetZ?: number;
|
|
18
|
+
}
|
|
19
|
+
/** Build a {@link Projector3D}. */
|
|
20
|
+
export declare function create3DProjector(opts?: Projector3DOptions): Projector3D;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return the decoded image for `url`, or `null` if it is not ready yet (a load
|
|
3
|
+
* is kicked off on the first miss). Safe to call every frame — cached after the
|
|
4
|
+
* first request. SSR-safe: returns `null` without a DOM. `onReady` (optional)
|
|
5
|
+
* fires once when a pending load resolves so a caller can trigger a re-draw.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getOrLoadImage(url: string, onReady?: () => void): HTMLImageElement | null;
|
|
8
|
+
/** Test/reset hook — clears the module cache. */
|
|
9
|
+
export declare function clearImageCache(): void;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Painter2D — the portable 2D draw seam.
|
|
3
|
+
*
|
|
4
|
+
* A small verb set that every drawable atom paints through, so a scene stays a
|
|
5
|
+
* pure descriptor tree with no `CanvasRenderingContext2D` reference of its own.
|
|
6
|
+
* The web implementation (`createWebPainter`) wraps a `ctx`; a native platform
|
|
7
|
+
* ships its own implementation of the SAME interface — that is the cross-platform
|
|
8
|
+
* driver (draw-list over DOM overlays). This file is DOM-free: it is the shared
|
|
9
|
+
* contract, importable by any target.
|
|
10
|
+
*
|
|
11
|
+
* Coordinates are PIXELS in the painter's current transform. Scene→pixel mapping
|
|
12
|
+
* is the host projector's job (it maps a core `ScenePos` before calling here), so
|
|
13
|
+
* the painter carries no scene/projection semantics.
|
|
14
|
+
*/
|
|
15
|
+
/** An opaque, painter-owned handle to a resolved texture (web: a decoded image). */
|
|
16
|
+
export interface TextureHandle {
|
|
17
|
+
readonly width: number;
|
|
18
|
+
readonly height: number;
|
|
19
|
+
}
|
|
20
|
+
/** Destination rectangle for a blit; `w`/`h` omitted → the source's natural size. */
|
|
21
|
+
export interface BlitDest {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
w?: number;
|
|
25
|
+
h?: number;
|
|
26
|
+
}
|
|
27
|
+
/** Source sub-rectangle within a texture (an atlas frame). Omitted → whole texture. */
|
|
28
|
+
export interface BlitSrc {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
w: number;
|
|
32
|
+
h: number;
|
|
33
|
+
}
|
|
34
|
+
/** A polyline/polygon vertex in pixel space. */
|
|
35
|
+
export interface PainterPoint {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
}
|
|
39
|
+
export interface TextStyle {
|
|
40
|
+
color: string;
|
|
41
|
+
/** CSS font shorthand (e.g. `"12px sans-serif"`). */
|
|
42
|
+
font?: string;
|
|
43
|
+
align?: CanvasTextAlign;
|
|
44
|
+
baseline?: CanvasTextBaseline;
|
|
45
|
+
}
|
|
46
|
+
/** A drop shadow applied to subsequent draws until cleared. */
|
|
47
|
+
export interface PainterShadow {
|
|
48
|
+
color: string;
|
|
49
|
+
blur: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The verb set. Roughly the union of what `Canvas2D`'s draw passes call on a 2D
|
|
53
|
+
* context, reframed as painter-neutral operations so the same drawable atoms
|
|
54
|
+
* paint identically on web `ctx` and on a native surface.
|
|
55
|
+
*/
|
|
56
|
+
export interface Painter2D {
|
|
57
|
+
/** Reset the surface to `width`×`height` logical px at device-pixel-ratio `dpr`. */
|
|
58
|
+
setViewport(width: number, height: number, dpr: number): void;
|
|
59
|
+
/** Clear the whole surface. */
|
|
60
|
+
clear(): void;
|
|
61
|
+
save(): void;
|
|
62
|
+
restore(): void;
|
|
63
|
+
translate(x: number, y: number): void;
|
|
64
|
+
scale(sx: number, sy: number): void;
|
|
65
|
+
rotate(radians: number): void;
|
|
66
|
+
/** Global alpha (0..1) for subsequent draws. */
|
|
67
|
+
setAlpha(alpha: number): void;
|
|
68
|
+
/** Drop shadow for subsequent draws; `null` clears it. */
|
|
69
|
+
setShadow(shadow: PainterShadow | null): void;
|
|
70
|
+
/** Resolve a texture URL to a handle, or `null` if not loaded yet (load is kicked off). */
|
|
71
|
+
resolveTexture(url: string): TextureHandle | null;
|
|
72
|
+
/** Blit a (sub-rect of a) texture to a destination rectangle. */
|
|
73
|
+
blit(tex: TextureHandle, dest: BlitDest, src?: BlitSrc): void;
|
|
74
|
+
fillRect(x: number, y: number, w: number, h: number, color: string): void;
|
|
75
|
+
strokeRect(x: number, y: number, w: number, h: number, color: string, lineWidth?: number): void;
|
|
76
|
+
fillPoly(points: readonly PainterPoint[], color: string): void;
|
|
77
|
+
strokePoly(points: readonly PainterPoint[], color: string, lineWidth?: number, closed?: boolean): void;
|
|
78
|
+
fillEllipse(cx: number, cy: number, rx: number, ry: number, color: string): void;
|
|
79
|
+
strokeEllipse(cx: number, cy: number, rx: number, ry: number, color: string, lineWidth?: number): void;
|
|
80
|
+
text(str: string, x: number, y: number, style: TextStyle): void;
|
|
81
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Painter2D } from './painter2d';
|
|
2
|
+
/**
|
|
3
|
+
* Create a {@link Painter2D} backed by a web 2D context. `onAssetLoad` (optional)
|
|
4
|
+
* fires when a texture requested via `resolveTexture` finishes loading, so a
|
|
5
|
+
* draw-host can schedule a re-draw.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createWebPainter(ctx: CanvasRenderingContext2D, onAssetLoad?: () => void): Painter2D;
|
package/dist/marketing/index.cjs
CHANGED
|
@@ -4633,6 +4633,15 @@ var tagVariantMap = {
|
|
|
4633
4633
|
secondary: "secondary",
|
|
4634
4634
|
accent: "info"
|
|
4635
4635
|
};
|
|
4636
|
+
var backgroundStyles = {
|
|
4637
|
+
dark: "bg-foreground text-background",
|
|
4638
|
+
gradient: [
|
|
4639
|
+
"bg-[radial-gradient(ellipse_at_top,var(--color-primary)/0.08,transparent_60%),",
|
|
4640
|
+
"radial-gradient(ellipse_at_bottom_right,var(--color-accent)/0.06,transparent_50%)]",
|
|
4641
|
+
"bg-background"
|
|
4642
|
+
].join(" "),
|
|
4643
|
+
subtle: "bg-muted/30"
|
|
4644
|
+
};
|
|
4636
4645
|
var MarketingImage = ({ src, alt, className }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4637
4646
|
Box,
|
|
4638
4647
|
{
|
|
@@ -4774,6 +4783,7 @@ var HeroSection = ({
|
|
|
4774
4783
|
"w-full min-h-[60vh] flex items-center justify-center",
|
|
4775
4784
|
"py-20",
|
|
4776
4785
|
"relative overflow-hidden",
|
|
4786
|
+
backgroundStyles[background],
|
|
4777
4787
|
className
|
|
4778
4788
|
),
|
|
4779
4789
|
children: [
|
package/dist/marketing/index.js
CHANGED
|
@@ -4612,6 +4612,15 @@ var tagVariantMap = {
|
|
|
4612
4612
|
secondary: "secondary",
|
|
4613
4613
|
accent: "info"
|
|
4614
4614
|
};
|
|
4615
|
+
var backgroundStyles = {
|
|
4616
|
+
dark: "bg-foreground text-background",
|
|
4617
|
+
gradient: [
|
|
4618
|
+
"bg-[radial-gradient(ellipse_at_top,var(--color-primary)/0.08,transparent_60%),",
|
|
4619
|
+
"radial-gradient(ellipse_at_bottom_right,var(--color-accent)/0.06,transparent_50%)]",
|
|
4620
|
+
"bg-background"
|
|
4621
|
+
].join(" "),
|
|
4622
|
+
subtle: "bg-muted/30"
|
|
4623
|
+
};
|
|
4615
4624
|
var MarketingImage = ({ src, alt, className }) => /* @__PURE__ */ jsx(
|
|
4616
4625
|
Box,
|
|
4617
4626
|
{
|
|
@@ -4753,6 +4762,7 @@ var HeroSection = ({
|
|
|
4753
4762
|
"w-full min-h-[60vh] flex items-center justify-center",
|
|
4754
4763
|
"py-20",
|
|
4755
4764
|
"relative overflow-hidden",
|
|
4765
|
+
backgroundStyles[background],
|
|
4756
4766
|
className
|
|
4757
4767
|
),
|
|
4758
4768
|
children: [
|