@almadar/ui 5.105.0 → 5.108.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.
Files changed (146) hide show
  1. package/dist/avl/index.cjs +2127 -5818
  2. package/dist/avl/index.js +1234 -4925
  3. package/dist/components/{game/2d → core}/atoms/GameIcon.d.ts +1 -1
  4. package/dist/components/core/atoms/index.d.ts +2 -1
  5. package/dist/components/core/molecules/index.d.ts +1 -1
  6. package/dist/components/core/organisms/index.d.ts +1 -1
  7. package/dist/components/core/templates/index.d.ts +1 -2
  8. package/dist/components/game/{2d/atoms → atoms}/ChoiceButton.d.ts +1 -1
  9. package/dist/components/game/{2d/atoms → atoms}/ControlButton.d.ts +1 -1
  10. package/dist/components/game/atoms/DrawShape.d.ts +50 -0
  11. package/dist/components/game/atoms/DrawSprite.d.ts +47 -0
  12. package/dist/components/game/atoms/DrawText.d.ts +31 -0
  13. package/dist/components/game/{2d/atoms → atoms}/GameAudioToggle.d.ts +1 -1
  14. package/dist/components/game/{2d/atoms → atoms}/MiniMap.d.ts +1 -1
  15. package/dist/components/game/{2d/atoms → atoms}/ScoreDisplay.d.ts +1 -1
  16. package/dist/components/game/{2d/atoms → atoms}/StateIndicator.d.ts +1 -1
  17. package/dist/components/game/{2d/molecules → molecules}/ActionTile.d.ts +1 -1
  18. package/dist/components/game/molecules/Canvas.d.ts +96 -0
  19. package/dist/components/game/molecules/Canvas2D.d.ts +120 -0
  20. package/dist/components/game/{2d/molecules → molecules}/ControlGrid.d.ts +1 -1
  21. package/dist/components/game/molecules/DrawShapeLayer.d.ts +19 -0
  22. package/dist/components/game/molecules/DrawSpriteLayer.d.ts +21 -0
  23. package/dist/components/game/molecules/DrawTextLayer.d.ts +22 -0
  24. package/dist/components/game/{2d/molecules → molecules}/GameHud.d.ts +1 -1
  25. package/dist/components/game/{2d/molecules → molecules}/StatBadge.d.ts +1 -1
  26. package/dist/components/game/{2d/molecules → molecules}/StateNode.d.ts +1 -1
  27. package/dist/components/game/{2d/molecules → molecules}/TraitSlot.d.ts +1 -1
  28. package/dist/components/game/{2d/molecules → molecules}/TraitStateViewer.d.ts +1 -1
  29. package/dist/components/game/{2d/molecules → molecules}/TransitionArrow.d.ts +1 -1
  30. package/dist/components/game/molecules/index.d.ts +39 -0
  31. package/dist/components/game/patterns.d.ts +20 -0
  32. package/dist/components/index.cjs +2417 -5988
  33. package/dist/components/index.js +1520 -5074
  34. package/dist/{components/game/shared/hooks → hooks}/useCamera.d.ts +1 -1
  35. package/dist/{components/game/shared/hooks → hooks}/useUnitSpriteAtlas.d.ts +2 -2
  36. package/dist/lib/drawable/contract.d.ts +68 -0
  37. package/dist/lib/drawable/hitTest.d.ts +23 -0
  38. package/dist/lib/drawable/paintDispatch.d.ts +22 -0
  39. package/dist/lib/drawable/projector.d.ts +14 -0
  40. package/dist/lib/drawable/projector3d.d.ts +20 -0
  41. package/dist/lib/drawable/three/Canvas3DHost.d.ts +178 -0
  42. package/dist/lib/drawable/three/Drawable3D.d.ts +20 -0
  43. package/dist/lib/drawable/three/GameCamera3D.d.ts +16 -0
  44. package/dist/lib/drawable/three/game3dTheme.d.ts +14 -0
  45. package/dist/{components/game/shared → lib/drawable/three}/hooks/useGameCanvas3DEvents.d.ts +4 -3
  46. package/dist/{components/game/3d → lib/drawable/three}/index.cjs +2223 -4466
  47. package/dist/{components/game/3d → lib/drawable/three}/index.css +3 -3
  48. package/dist/lib/drawable/three/index.d.ts +39 -0
  49. package/dist/{components/game/3d → lib/drawable/three}/index.js +2132 -4375
  50. package/dist/lib/drawable/three/mesh3d.d.ts +28 -0
  51. package/dist/{components/game/shared/index.d.ts → lib/gameShared.d.ts} +1 -2
  52. package/dist/lib/imageCache.d.ts +9 -0
  53. package/dist/lib/painter2d.d.ts +81 -0
  54. package/dist/{components/game/shared/lib → lib}/puzzleObject.d.ts +11 -2
  55. package/dist/lib/webPainter2d.d.ts +7 -0
  56. package/dist/marketing/index.cjs +10 -0
  57. package/dist/marketing/index.js +10 -0
  58. package/dist/{components/game/shared/providers → providers}/GameAudioProvider.d.ts +1 -1
  59. package/dist/providers/index.cjs +2524 -5889
  60. package/dist/providers/index.d.ts +2 -0
  61. package/dist/providers/index.js +1743 -5112
  62. package/dist/runtime/index.cjs +1982 -5673
  63. package/dist/runtime/index.js +1208 -4899
  64. package/package.json +13 -13
  65. package/dist/components/game/2d/atoms/ActionButton.d.ts +0 -31
  66. package/dist/components/game/2d/atoms/ComboCounter.d.ts +0 -20
  67. package/dist/components/game/2d/atoms/DamageNumber.d.ts +0 -18
  68. package/dist/components/game/2d/atoms/GameCard.d.ts +0 -34
  69. package/dist/components/game/2d/atoms/ItemSlot.d.ts +0 -31
  70. package/dist/components/game/2d/atoms/ResourceCounter.d.ts +0 -26
  71. package/dist/components/game/2d/atoms/Sprite.d.ts +0 -52
  72. package/dist/components/game/2d/atoms/StatusEffect.d.ts +0 -25
  73. package/dist/components/game/2d/atoms/TurnIndicator.d.ts +0 -22
  74. package/dist/components/game/2d/atoms/WaypointMarker.d.ts +0 -23
  75. package/dist/components/game/2d/molecules/Canvas2D.d.ts +0 -175
  76. package/dist/components/game/2d/molecules/EventLog.d.ts +0 -31
  77. package/dist/components/game/2d/molecules/InventoryGrid.d.ts +0 -35
  78. package/dist/components/game/2d/molecules/ObjectRulePanel.d.ts +0 -32
  79. package/dist/components/game/2d/molecules/ResourceBar.d.ts +0 -26
  80. package/dist/components/game/2d/molecules/RuleEditor.d.ts +0 -39
  81. package/dist/components/game/2d/molecules/SideCanvas2D.d.ts +0 -36
  82. package/dist/components/game/2d/molecules/VariablePanel.d.ts +0 -28
  83. package/dist/components/game/2d/molecules/index.d.ts +0 -66
  84. package/dist/components/game/2d/organisms/BuilderBoard.d.ts +0 -60
  85. package/dist/components/game/2d/organisms/ClassifierBoard.d.ts +0 -66
  86. package/dist/components/game/2d/organisms/DebuggerBoard.d.ts +0 -61
  87. package/dist/components/game/2d/organisms/EventHandlerBoard.d.ts +0 -42
  88. package/dist/components/game/2d/organisms/NegotiatorBoard.d.ts +0 -56
  89. package/dist/components/game/2d/organisms/SequencerBoard.d.ts +0 -69
  90. package/dist/components/game/2d/organisms/SimulatorBoard.d.ts +0 -58
  91. package/dist/components/game/2d/organisms/StateArchitectBoard.d.ts +0 -61
  92. package/dist/components/game/2d/templates/GameTemplate.d.ts +0 -35
  93. package/dist/components/game/3d/atoms/EventMarker3D.d.ts +0 -17
  94. package/dist/components/game/3d/atoms/SpriteBillboard3D.d.ts +0 -18
  95. package/dist/components/game/3d/index.d.ts +0 -13
  96. package/dist/components/game/3d/molecules/FeatureMesh3D.d.ts +0 -21
  97. package/dist/components/game/3d/molecules/GameCamera3D.d.ts +0 -35
  98. package/dist/components/game/3d/molecules/GameCanvas3D.d.ts +0 -259
  99. package/dist/components/game/3d/molecules/SideScene3D.d.ts +0 -31
  100. package/dist/components/game/3d/molecules/TileMesh3D.d.ts +0 -28
  101. package/dist/components/game/3d/molecules/UnitMesh3D.d.ts +0 -29
  102. package/dist/components/game/3d/molecules/index.d.ts +0 -35
  103. package/dist/components/game/3d/organisms/GameBoard3D.d.ts +0 -66
  104. package/dist/components/game/3d/patterns.d.ts +0 -20
  105. package/dist/components/game/3d/templates/GameCanvas3DBattleTemplate.d.ts +0 -82
  106. package/dist/components/game/3d/templates/GameCanvas3DCastleTemplate.d.ts +0 -87
  107. package/dist/components/game/3d/templates/GameCanvas3DWorldMapTemplate.d.ts +0 -95
  108. package/dist/components/game/shared/effects.d.ts +0 -253
  109. package/dist/components/game/shared/game3dTheme.d.ts +0 -55
  110. package/dist/components/game/shared/lib/game3dAssetManifest.d.ts +0 -48
  111. /package/dist/components/game/{2d/atoms → atoms}/DialogueBubble.d.ts +0 -0
  112. /package/dist/components/game/{2d/atoms → atoms}/HealthBar.d.ts +0 -0
  113. /package/dist/components/game/{2d/atoms → atoms}/TimerDisplay.d.ts +0 -0
  114. /package/dist/components/game/{2d/molecules → molecules}/ActionPalette.d.ts +0 -0
  115. /package/dist/components/game/{2d/molecules → molecules}/GameMenu.d.ts +0 -0
  116. /package/dist/components/game/{2d/molecules → molecules}/SequenceBar.d.ts +0 -0
  117. /package/dist/components/game/{2d/molecules → molecules}/StateGraph.d.ts +0 -0
  118. /package/dist/components/game/{2d/molecules → molecules}/StateJsonView.d.ts +0 -0
  119. /package/dist/components/game/{2d/templates → templates}/GameShell.d.ts +0 -0
  120. /package/dist/{components/game/shared/hooks → hooks}/useGameAudio.d.ts +0 -0
  121. /package/dist/{components/game/shared → hooks}/useImageCache.d.ts +0 -0
  122. /package/dist/{components/game/shared → lib}/boardEntity.d.ts +0 -0
  123. /package/dist/{components/game/3d/molecules → lib/drawable/three}/Camera3D.d.ts +0 -0
  124. /package/dist/{components/game/3d/molecules → lib/drawable/three}/Canvas3DErrorBoundary.d.ts +0 -0
  125. /package/dist/{components/game/3d/molecules → lib/drawable/three}/Canvas3DLoadingState.d.ts +0 -0
  126. /package/dist/{components/game/3d/molecules → lib/drawable/three}/Lighting3D.d.ts +0 -0
  127. /package/dist/{components/game/3d/molecules → lib/drawable/three}/ModelLoader.d.ts +0 -0
  128. /package/dist/{components/game/3d/molecules → lib/drawable/three}/Scene3D.d.ts +0 -0
  129. /package/dist/{components/game/shared → lib/drawable/three}/hooks/useAssetLoader.d.ts +0 -0
  130. /package/dist/{components/game/shared → lib/drawable/three}/hooks/useRaycaster.d.ts +0 -0
  131. /package/dist/{components/game/shared → lib/drawable/three}/hooks/useSceneGraph.d.ts +0 -0
  132. /package/dist/{components/game/shared → lib/drawable/three}/hooks/useThree.d.ts +0 -0
  133. /package/dist/{components/game/shared → lib/drawable/three}/lib/AssetLoader.d.ts +0 -0
  134. /package/dist/{components/game/shared → lib/drawable/three}/lib/culling.d.ts +0 -0
  135. /package/dist/{components/game/shared → lib/drawable/three}/lib/grid3D.d.ts +0 -0
  136. /package/dist/{components/game/shared/lib → lib}/editorUtils.d.ts +0 -0
  137. /package/dist/{components/game/shared → lib}/game.d.ts +0 -0
  138. /package/dist/{components/game/shared → lib}/isometric.d.ts +0 -0
  139. /package/dist/{components/game/shared → lib}/isometricTypes.d.ts +0 -0
  140. /package/dist/{components/game/shared → lib}/makeAsset.d.ts +0 -0
  141. /package/dist/{components/game/shared/lib → lib}/mechanics.d.ts +0 -0
  142. /package/dist/{components/game/shared/lib → lib}/physicsPresets.d.ts +0 -0
  143. /package/dist/{components/game/shared/lib → lib}/physicsTypes.d.ts +0 -0
  144. /package/dist/{components/game/shared → lib}/spriteAnimation.d.ts +0 -0
  145. /package/dist/{components/game/shared → lib}/spriteAnimationTypes.d.ts +0 -0
  146. /package/dist/{components/game/shared → lib}/spriteSheetConstants.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- import type { CameraState } from '../isometricTypes';
1
+ import type { CameraState } from '../lib/isometricTypes';
2
2
  interface CameraResult {
3
3
  /** Mutable camera state ref (x, y, zoom) */
4
4
  cameraRef: React.MutableRefObject<CameraState>;
@@ -1,5 +1,5 @@
1
- import type { IsometricUnit } from '../isometricTypes';
2
- import type { ResolvedFrame } from '../spriteAnimationTypes';
1
+ import type { IsometricUnit } from '../lib/isometricTypes';
2
+ import type { ResolvedFrame } from '../lib/spriteAnimationTypes';
3
3
  /**
4
4
  * Resolve the sprite-sheet atlas-JSON URL for a unit.
5
5
  *
@@ -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,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 '../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,178 @@
1
+ /**
2
+ * Canvas3DHost — the thin 3D draw-host: the `canvas` host's 3D painter backend
3
+ * (the R3F "vessel" behind the neutral drawables), the exact 3D analogue of the
4
+ * 2D `Painter2D` seam. Reached only via the lazy `@almadar/ui/.../game/three`
5
+ * subpath so three.js never enters a 2D bundle.
6
+ *
7
+ * The 3D twin of Canvas2D: the board authors a `drawables` list (the neutral
8
+ * `draw-*` children) and this host maps each descriptor through `Drawable3D` to a
9
+ * three.js mesh (a raw descriptor NEVER reaches `<group>{children}` — R3F throws).
10
+ * It owns NO game data — tiles, units, features, selection, health bars and labels
11
+ * are all `draw-*` children composed in `.lolo`, not props here. Only view state
12
+ * (camera, error boundary) is local.
13
+ *
14
+ * Camera: `isometric`/`perspective`/`top-down` frame the scene bounds (derived from
15
+ * the drawn descriptors); `follow`/`chase` track the neutral core `Camera.target`
16
+ * (forwarded as `followTarget`), falling back to the scene centre.
17
+ *
18
+ * Interaction: keyboard maps to semantic events (device-agnostic input). Pointer
19
+ * click/hover on neutral drawables needs a per-entity id + a scene-space raycast
20
+ * the descriptors don't yet carry — that hit-test is a tracked fork
21
+ * (docs/Almadar_Std_Game_V2_PLAN.md); the click/hover event props are accepted but
22
+ * not yet emitted from a raycast.
23
+ *
24
+ * @packageDocumentation
25
+ */
26
+ import React from 'react';
27
+ import type { EventEmit, Asset, ScenePos } from '@almadar/core';
28
+ import * as THREE from 'three';
29
+ import type { DrawableNode } from '../paintDispatch';
30
+ import type { IsometricTile, IsometricUnit, IsometricFeature } from '../../isometricTypes';
31
+ import './Canvas3DHost.css';
32
+ export type { IsometricTile, IsometricUnit, IsometricFeature };
33
+ /** Camera mode for 3D view.
34
+ * - `follow` tracks `followTarget` (the neutral `Camera.target`) from a fixed offset.
35
+ * - `chase` sits behind + above the target. */
36
+ export type CameraMode = 'isometric' | 'perspective' | 'top-down' | 'follow' | 'chase';
37
+ /** Per-role model manifest (retained type export; the thin host no longer resolves
38
+ * models from a manifest — a `draw-sprite` carries its own `Asset`). */
39
+ export interface GameCanvas3DAssetManifest {
40
+ terrains?: Record<string, Asset>;
41
+ units?: Record<string, Asset>;
42
+ features?: Record<string, Asset>;
43
+ effects?: Record<string, Asset>;
44
+ }
45
+ /** Map orientation */
46
+ export type MapOrientation = 'standard' | 'rotated';
47
+ /** Overlay control */
48
+ export type OverlayControl = 'default' | 'hidden' | 'minimap';
49
+ /** Props for GameCanvas3D component */
50
+ export interface Canvas3DHostProps {
51
+ /** Additional CSS classes */
52
+ className?: string;
53
+ /** Children to render inside the 3D canvas (e.g., physics objects, custom meshes) */
54
+ children?: React.ReactNode;
55
+ /** Neutral drawable descriptors — the same `children` vocabulary as Canvas2D. The
56
+ * host maps each through `Drawable3D` to a mesh. */
57
+ drawables?: DrawableNode[];
58
+ /** Loading state indicator */
59
+ isLoading?: boolean;
60
+ /** Error state */
61
+ error?: string | null;
62
+ /** Fog of war data (accepted for API parity; presentation-only). */
63
+ fogOfWar?: boolean[][];
64
+ /** Map orientation (data attribute). */
65
+ orientation?: MapOrientation;
66
+ /** Camera mode */
67
+ cameraMode?: CameraMode;
68
+ /** Follow-camera target in scene space (the neutral core `Camera.target`). */
69
+ followTarget?: ScenePos;
70
+ /** Show grid */
71
+ showGrid?: boolean;
72
+ /** Show coordinates overlay (accepted for API parity). */
73
+ showCoordinates?: boolean;
74
+ /** Show tile information (accepted for API parity). */
75
+ showTileInfo?: boolean;
76
+ /** Overlay control mode (data attribute). */
77
+ overlay?: OverlayControl;
78
+ /** Enable shadows */
79
+ shadows?: boolean;
80
+ /** Background color */
81
+ backgroundColor?: string;
82
+ /** Declarative event: tile click. Emitted from a ground-plane raycast → scene cell
83
+ * `{ x, z }` (the FSM validates the cell). `tileId` is optional — the neutral host
84
+ * has no per-tile id, and the board FSMs key off the coordinate. */
85
+ tileClickEvent?: EventEmit<{
86
+ x: number;
87
+ z: number;
88
+ tileId?: string;
89
+ type?: string;
90
+ terrain?: string;
91
+ elevation?: number;
92
+ }>;
93
+ /** Declarative event: unit click. Emitted `{ unitId, x, z }` when the raycast lands on a
94
+ * cell whose descriptor carries an `id` (a tagged unit sprite). */
95
+ unitClickEvent?: EventEmit<{
96
+ unitId: string;
97
+ x: number;
98
+ z: number;
99
+ unitType?: string;
100
+ name?: string;
101
+ team?: string;
102
+ faction?: string;
103
+ health?: number;
104
+ maxHealth?: number;
105
+ }>;
106
+ /** Declarative event: feature click. Accepted; not yet emitted (see `tileClickEvent`). */
107
+ featureClickEvent?: EventEmit<{
108
+ featureId: string;
109
+ x: number;
110
+ z: number;
111
+ type?: string;
112
+ elevation?: number;
113
+ }>;
114
+ /** Declarative event: canvas (background) click. */
115
+ canvasClickEvent?: EventEmit<{
116
+ clientX: number;
117
+ clientY: number;
118
+ button: number;
119
+ }>;
120
+ /** Declarative event: tile hover. Accepted; not yet emitted (see `tileClickEvent`). */
121
+ tileHoverEvent?: EventEmit<{
122
+ tileId: string;
123
+ x: number;
124
+ z: number;
125
+ type?: string;
126
+ }>;
127
+ /** Declarative event: tile leave. */
128
+ tileLeaveEvent?: EventEmit<Record<string, never>>;
129
+ /** Declarative event: unit animation. */
130
+ unitAnimationEvent?: EventEmit<{
131
+ unitId: string;
132
+ state: string;
133
+ timestamp: number;
134
+ }>;
135
+ /** Declarative event: camera change. */
136
+ cameraChangeEvent?: EventEmit<{
137
+ position: {
138
+ x: number;
139
+ y: number;
140
+ z: number;
141
+ };
142
+ timestamp: number;
143
+ }>;
144
+ /** Loading message */
145
+ loadingMessage?: string;
146
+ /** Unit draw-size multiplier (accepted for API parity; sizing is drawable-authored). */
147
+ unitScale?: number;
148
+ /** Board zoom (accepted for API parity; 3D zoom is camera-driven, not group-scaled). */
149
+ scale?: number;
150
+ /** Maps a keydown `e.code` → the board's SEMANTIC event (device-agnostic input). */
151
+ keyMap?: Record<string, string>;
152
+ /** Maps a keyup `e.code` → the board's SEMANTIC event. */
153
+ keyUpMap?: Record<string, string>;
154
+ /** Side-view world size in pixels (accepted for API parity). */
155
+ worldWidth?: number;
156
+ /** Side-view world size in pixels (accepted for API parity). */
157
+ worldHeight?: number;
158
+ /** Pixel→world-unit divisor for side view (accepted for API parity). */
159
+ pixelsPerUnit?: number;
160
+ }
161
+ /** Imperative handle for GameCanvas3D */
162
+ export interface Canvas3DHostHandle {
163
+ /** Get current camera position */
164
+ getCameraPosition: () => THREE.Vector3 | null;
165
+ /** Set camera position */
166
+ setCameraPosition: (x: number, y: number, z: number) => void;
167
+ /** Look at a specific point */
168
+ lookAt: (x: number, y: number, z: number) => void;
169
+ /** Reset camera to default position */
170
+ resetCamera: () => void;
171
+ /** Take a screenshot */
172
+ screenshot: () => string | null;
173
+ }
174
+ /**
175
+ * Canvas3DHost — thin 3D draw-host. Walks `drawables` through `Drawable3D`.
176
+ */
177
+ export declare const Canvas3DHost: React.ForwardRefExoticComponent<Canvas3DHostProps & React.RefAttributes<Canvas3DHostHandle>>;
178
+ export default Canvas3DHost;
@@ -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,16 @@
1
+ /** Reports the live camera position on every change (imperative handle integration). */
2
+ export declare function CameraController3D({ onCameraChange, }: {
3
+ onCameraChange?: (pos: {
4
+ x: number;
5
+ y: number;
6
+ z: number;
7
+ }) => void;
8
+ }): null;
9
+ /**
10
+ * Camera that smooth-tracks a world-space target (side-view player or selected unit).
11
+ * OrbitControls is disabled while following — the camera is authoritative.
12
+ */
13
+ export declare function FollowCamera3D({ target, offset, }: {
14
+ target: [number, number, number];
15
+ offset: [number, number, number];
16
+ }): null;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * game3dTheme — DEFAULT palette constants for the 3D draw-host (`Canvas3DHost`).
3
+ * No React deps — pure constants. Only the grid + background defaults remain live;
4
+ * every per-item color/size comes from the drawable descriptors that `.lolo` computes.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ /** Grid line colors for the drei `<Grid>`. */
9
+ export declare const GRID_COLORS_3D: {
10
+ cell: string;
11
+ section: string;
12
+ };
13
+ /** Default scene background (Canvas3DHostProps.backgroundColor default). */
14
+ export declare const DEFAULT_BACKGROUND_3D = "#1a1a2e";
@@ -1,11 +1,12 @@
1
1
  import type { EventEmit } from '@almadar/core';
2
- import type { IsometricTile, IsometricUnit, IsometricFeature } from '../isometricTypes';
2
+ import type { IsometricTile, IsometricUnit, IsometricFeature } from '../../../isometricTypes';
3
3
  export interface GameCanvas3DEventConfig {
4
- /** Event name for tile clicks */
4
+ /** Event name for tile clicks. `tileId` is optional — the neutral draw-host emits
5
+ * only the scene coordinate `{ x, z }` (the FSM keys off the cell, not an id). */
5
6
  tileClickEvent?: EventEmit<{
6
- tileId: string;
7
7
  x: number;
8
8
  z: number;
9
+ tileId?: string;
9
10
  type?: string;
10
11
  terrain?: string;
11
12
  elevation?: number;