@almadar/ui 2.13.2 → 2.14.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 (34) hide show
  1. package/dist/chunk-4N3BAPDB.js +1667 -0
  2. package/dist/{chunk-PERGHHON.js → chunk-IRIGCHP4.js} +2 -12
  3. package/dist/{chunk-ZW5N4AUU.js → chunk-M7MOIE46.js} +3 -3
  4. package/dist/{chunk-Y7IHEYYE.js → chunk-QU2X55WH.js} +11 -1
  5. package/dist/{chunk-77CBR3Z7.js → chunk-SKWPSQHQ.js} +13448 -2279
  6. package/dist/{chunk-4ZBSL37D.js → chunk-XL7WB2O5.js} +415 -58
  7. package/dist/components/index.css +508 -0
  8. package/dist/components/index.js +769 -11187
  9. package/dist/components/organisms/game/three/index.js +49 -1709
  10. package/dist/hooks/index.js +2 -2
  11. package/dist/lib/index.js +1 -3
  12. package/dist/providers/index.css +599 -0
  13. package/dist/providers/index.js +5 -4
  14. package/dist/runtime/index.css +599 -0
  15. package/dist/runtime/index.js +6 -6
  16. package/package.json +5 -4
  17. package/dist/ThemeContext-D9xUORq5.d.ts +0 -105
  18. package/dist/chunk-42YQ6JVR.js +0 -48
  19. package/dist/chunk-WCTZ7WZX.js +0 -311
  20. package/dist/cn-C_ATNPvi.d.ts +0 -332
  21. package/dist/components/index.d.ts +0 -9788
  22. package/dist/components/organisms/game/three/index.d.ts +0 -1233
  23. package/dist/context/index.d.ts +0 -208
  24. package/dist/event-bus-types-CjJduURa.d.ts +0 -73
  25. package/dist/hooks/index.d.ts +0 -1221
  26. package/dist/isometric-ynNHVPZx.d.ts +0 -111
  27. package/dist/lib/index.d.ts +0 -320
  28. package/dist/locales/index.d.ts +0 -22
  29. package/dist/offline-executor-CHr4uAhf.d.ts +0 -401
  30. package/dist/providers/index.d.ts +0 -465
  31. package/dist/renderer/index.d.ts +0 -525
  32. package/dist/runtime/index.d.ts +0 -280
  33. package/dist/stores/index.d.ts +0 -151
  34. package/dist/useUISlots-BBjNvQtb.d.ts +0 -85
@@ -1,1233 +0,0 @@
1
- import React__default, { Component, ReactNode, ErrorInfo } from 'react';
2
- import * as THREE from 'three';
3
- import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
4
- import { I as IsometricTile, a as IsometricUnit, b as IsometricFeature } from '../../../../isometric-ynNHVPZx.js';
5
-
6
- /**
7
- * Scene3D
8
- *
9
- * Three.js scene wrapper component for React Three Fiber.
10
- * Manages the scene environment, fog, and background.
11
- *
12
- * @packageDocumentation
13
- */
14
-
15
- interface Scene3DProps {
16
- /** Background color or URL */
17
- background?: string;
18
- /** Fog configuration */
19
- fog?: {
20
- color: string;
21
- near: number;
22
- far: number;
23
- };
24
- /** Children to render in scene */
25
- children?: React__default.ReactNode;
26
- }
27
- /**
28
- * Scene3D Component
29
- *
30
- * Manages Three.js scene settings like background and fog.
31
- *
32
- * @example
33
- * ```tsx
34
- * <Canvas>
35
- * <Scene3D background="#1a1a2e" fog={{ color: '#1a1a2e', near: 10, far: 50 }}>
36
- * <GameObjects />
37
- * </Scene3D>
38
- * </Canvas>
39
- * ```
40
- */
41
- declare function Scene3D({ background, fog, children }: Scene3DProps): React__default.JSX.Element;
42
-
43
- /**
44
- * Camera3D
45
- *
46
- * Three.js camera component with orbit controls.
47
- * Supports isometric, perspective, and top-down camera modes.
48
- *
49
- * @packageDocumentation
50
- */
51
-
52
- type CameraMode$1 = 'isometric' | 'perspective' | 'top-down';
53
- interface Camera3DProps {
54
- /** Camera mode */
55
- mode?: CameraMode$1;
56
- /** Initial camera position */
57
- position?: [number, number, number];
58
- /** Target to look at */
59
- target?: [number, number, number];
60
- /** Zoom level */
61
- zoom?: number;
62
- /** Field of view (perspective mode only) */
63
- fov?: number;
64
- /** Enable orbit controls */
65
- enableOrbit?: boolean;
66
- /** Minimum zoom distance */
67
- minDistance?: number;
68
- /** Maximum zoom distance */
69
- maxDistance?: number;
70
- /** Called when camera changes */
71
- onChange?: (camera: THREE.Camera) => void;
72
- }
73
- interface Camera3DHandle {
74
- /** Get current camera */
75
- getCamera: () => THREE.Camera;
76
- /** Set camera position */
77
- setPosition: (x: number, y: number, z: number) => void;
78
- /** Look at target */
79
- lookAt: (x: number, y: number, z: number) => void;
80
- /** Reset to initial position */
81
- reset: () => void;
82
- /** Get current view bounds */
83
- getViewBounds: () => {
84
- min: THREE.Vector3;
85
- max: THREE.Vector3;
86
- };
87
- }
88
- /**
89
- * Camera3D Component
90
- *
91
- * Configurable camera with orbit controls and multiple modes.
92
- *
93
- * @example
94
- * ```tsx
95
- * <Canvas>
96
- * <Camera3D mode="isometric" position={[10, 10, 10]} target={[0, 0, 0]} />
97
- * </Canvas>
98
- * ```
99
- */
100
- declare const Camera3D: React__default.ForwardRefExoticComponent<Camera3DProps & React__default.RefAttributes<Camera3DHandle>>;
101
-
102
- /**
103
- * Lighting3D
104
- *
105
- * Default lighting setup for 3D game scenes.
106
- * Includes ambient, directional, and optional point lights.
107
- *
108
- * @packageDocumentation
109
- */
110
-
111
- interface Lighting3DProps {
112
- /** Ambient light intensity */
113
- ambientIntensity?: number;
114
- /** Ambient light color */
115
- ambientColor?: string;
116
- /** Directional light intensity */
117
- directionalIntensity?: number;
118
- /** Directional light color */
119
- directionalColor?: string;
120
- /** Directional light position */
121
- directionalPosition?: [number, number, number];
122
- /** Enable shadows */
123
- shadows?: boolean;
124
- /** Shadow map size */
125
- shadowMapSize?: number;
126
- /** Shadow camera size */
127
- shadowCameraSize?: number;
128
- /** Show helper for directional light */
129
- showHelpers?: boolean;
130
- }
131
- /**
132
- * Lighting3D Component
133
- *
134
- * Pre-configured lighting setup for game scenes.
135
- *
136
- * @example
137
- * ```tsx
138
- * <Canvas>
139
- * <Lighting3D
140
- * ambientIntensity={0.6}
141
- * directionalIntensity={1.0}
142
- * shadows={true}
143
- * />
144
- * </Canvas>
145
- * ```
146
- */
147
- declare function Lighting3D({ ambientIntensity, ambientColor, directionalIntensity, directionalColor, directionalPosition, shadows, shadowMapSize, shadowCameraSize, showHelpers, }: Lighting3DProps): React__default.JSX.Element;
148
-
149
- /**
150
- * Canvas3DLoadingState
151
- *
152
- * Loading state component for 3D canvas with progress indicator.
153
- * Displays asset loading progress and estimated time remaining.
154
- *
155
- * @packageDocumentation
156
- */
157
-
158
- interface Canvas3DLoadingStateProps {
159
- /** Current loading progress (0-100) */
160
- progress?: number;
161
- /** Number of assets loaded */
162
- loaded?: number;
163
- /** Total assets to load */
164
- total?: number;
165
- /** Loading message */
166
- message?: string;
167
- /** Secondary details message */
168
- details?: string;
169
- /** Whether to show spinner */
170
- showSpinner?: boolean;
171
- /** Custom className */
172
- className?: string;
173
- }
174
- /**
175
- * Canvas3DLoadingState Component
176
- *
177
- * Displays loading progress for 3D assets.
178
- *
179
- * @example
180
- * ```tsx
181
- * <Canvas3DLoadingState
182
- * progress={65}
183
- * loaded={13}
184
- * total={20}
185
- * message="Loading 3D models..."
186
- * details="character-knight.glb"
187
- * />
188
- * ```
189
- */
190
- declare function Canvas3DLoadingState({ progress, loaded, total, message, details, showSpinner, className, }: Canvas3DLoadingStateProps): React__default.JSX.Element;
191
-
192
- /**
193
- * Canvas3DErrorBoundary
194
- *
195
- * Error boundary for 3D canvas components.
196
- * Catches Three.js and React Three Fiber errors gracefully.
197
- *
198
- * @packageDocumentation
199
- */
200
-
201
- interface Canvas3DErrorBoundaryProps {
202
- /** Child components */
203
- children: ReactNode;
204
- /** Custom fallback component */
205
- fallback?: ReactNode;
206
- /** Error callback */
207
- onError?: (error: Error, errorInfo: ErrorInfo) => void;
208
- /** Reset callback */
209
- onReset?: () => void;
210
- }
211
- interface Canvas3DErrorBoundaryState {
212
- /** Whether an error has occurred */
213
- hasError: boolean;
214
- /** The error that occurred */
215
- error: Error | null;
216
- /** Error info from React */
217
- errorInfo: ErrorInfo | null;
218
- }
219
- /**
220
- * Canvas3DErrorBoundary Component
221
- *
222
- * Catches errors in 3D canvas and displays a user-friendly fallback.
223
- *
224
- * @example
225
- * ```tsx
226
- * <Canvas3DErrorBoundary
227
- * onError={(error) => console.error('3D Error:', error)}
228
- * onReset={() => console.log('Resetting...')}
229
- * >
230
- * <GameCanvas3D {...props} />
231
- * </Canvas3DErrorBoundary>
232
- * ```
233
- */
234
- declare class Canvas3DErrorBoundary extends Component<Canvas3DErrorBoundaryProps, Canvas3DErrorBoundaryState> {
235
- constructor(props: Canvas3DErrorBoundaryProps);
236
- static getDerivedStateFromError(error: Error): Canvas3DErrorBoundaryState;
237
- componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
238
- handleReset: () => void;
239
- render(): ReactNode;
240
- }
241
-
242
- /**
243
- * ModelLoader Component
244
- *
245
- * React Three Fiber component for loading and displaying GLB/GLTF models from URLs.
246
- * Handles loading states and errors without requiring React Suspense.
247
- *
248
- * @packageDocumentation
249
- */
250
-
251
- interface ModelLoaderProps {
252
- /** URL to the GLB/GLTF model */
253
- url: string;
254
- /** Position [x, y, z] */
255
- position?: [number, number, number];
256
- /** Scale - either a single number or [x, y, z] */
257
- scale?: number | [number, number, number];
258
- /** Rotation in degrees [x, y, z] */
259
- rotation?: [number, number, number];
260
- /** Whether the model is selected */
261
- isSelected?: boolean;
262
- /** Whether the model is hovered */
263
- isHovered?: boolean;
264
- /** Click handler */
265
- onClick?: () => void;
266
- /** Hover handler */
267
- onHover?: (hovered: boolean) => void;
268
- /** Fallback geometry type */
269
- fallbackGeometry?: 'box' | 'sphere' | 'cylinder' | 'none';
270
- /** Enable shadows */
271
- castShadow?: boolean;
272
- /** Receive shadows */
273
- receiveShadow?: boolean;
274
- /**
275
- * Base path for shared resources (textures, materials).
276
- * If not provided, auto-detected from the URL by looking for a `/3d/` segment.
277
- * E.g. "https://host/3d/" so that "Textures/colormap.png" resolves correctly.
278
- */
279
- resourceBasePath?: string;
280
- }
281
- /**
282
- * ModelLoader component for rendering GLB models in React Three Fiber
283
- */
284
- declare function ModelLoader({ url, position, scale, rotation, isSelected, isHovered, onClick, onHover, fallbackGeometry, castShadow, receiveShadow, resourceBasePath, }: ModelLoaderProps): React__default.JSX.Element;
285
-
286
- /**
287
- * PhysicsObject3D Component
288
- *
289
- * Three.js component that syncs a 3D object's position with physics state.
290
- * Use this to render physics-enabled entities in GameCanvas3D.
291
- *
292
- * @example
293
- * ```tsx
294
- * <PhysicsObject3D
295
- * entityId="player-1"
296
- * modelUrl="https://trait-wars-assets.web.app/3d/medieval/props/barrels.glb"
297
- * initialPosition={[0, 10, 0]}
298
- * mass={1}
299
- * />
300
- * ```
301
- *
302
- * @packageDocumentation
303
- */
304
-
305
- interface Physics3DState {
306
- id: string;
307
- x: number;
308
- y: number;
309
- z: number;
310
- vx: number;
311
- vy: number;
312
- vz: number;
313
- rx: number;
314
- ry: number;
315
- rz: number;
316
- isGrounded: boolean;
317
- gravity: number;
318
- friction: number;
319
- mass: number;
320
- state: 'Active' | 'Frozen';
321
- }
322
- interface PhysicsObject3DProps {
323
- /** Unique entity ID */
324
- entityId: string;
325
- /** GLB model URL */
326
- modelUrl: string;
327
- /** Initial position [x, y, z] */
328
- initialPosition?: [number, number, number];
329
- /** Initial velocity [vx, vy, vz] */
330
- initialVelocity?: [number, number, number];
331
- /** Mass for collision response */
332
- mass?: number;
333
- /** Gravity force (default: 9.8) */
334
- gravity?: number;
335
- /** Ground plane Y position (default: 0) */
336
- groundY?: number;
337
- /** Model scale */
338
- scale?: number | [number, number, number];
339
- /** Called when physics state updates */
340
- onPhysicsUpdate?: (state: Physics3DState) => void;
341
- /** Called when object hits ground */
342
- onGroundHit?: () => void;
343
- /** Called when collision occurs */
344
- onCollision?: (otherEntityId: string) => void;
345
- }
346
- /**
347
- * 3D Physics-enabled object for GameCanvas3D
348
- */
349
- declare function PhysicsObject3D({ entityId, modelUrl, initialPosition, initialVelocity, mass, gravity, groundY, scale, onPhysicsUpdate, onGroundHit, onCollision, }: PhysicsObject3DProps): React__default.JSX.Element;
350
- /**
351
- * Hook for controlling a PhysicsObject3D from parent component
352
- */
353
- declare function usePhysics3DController(entityId: string): {
354
- applyForce: (fx: number, fy: number, fz: number) => void;
355
- setVelocity: (vx: number, vy: number, vz: number) => void;
356
- setPosition: (x: number, y: number, z: number) => void;
357
- jump: (force?: number) => void;
358
- };
359
-
360
- /**
361
- * AssetLoader
362
- *
363
- * Three.js asset loading manager for 3D models and textures.
364
- * Supports GLB/GLTF (primary), OBJ (fallback), and texture loading.
365
- * Implements caching for performance.
366
- *
367
- * @packageDocumentation
368
- */
369
-
370
- interface LoadedModel {
371
- scene: THREE.Group;
372
- animations: THREE.AnimationClip[];
373
- }
374
- declare class AssetLoader {
375
- private objLoader;
376
- private textureLoader;
377
- private modelCache;
378
- private textureCache;
379
- private loadingPromises;
380
- constructor();
381
- /**
382
- * Load a GLB/GLTF model
383
- * @param url - URL to the .glb or .gltf file
384
- * @returns Promise with loaded model scene and animations
385
- */
386
- loadModel(url: string): Promise<LoadedModel>;
387
- /**
388
- * Load an OBJ model (fallback for non-GLB assets)
389
- * @param url - URL to the .obj file
390
- * @returns Promise with loaded object group
391
- */
392
- loadOBJ(url: string): Promise<THREE.Group>;
393
- /**
394
- * Load a texture
395
- * @param url - URL to the texture image
396
- * @returns Promise with loaded texture
397
- */
398
- loadTexture(url: string): Promise<THREE.Texture>;
399
- /**
400
- * Preload multiple assets
401
- * @param urls - Array of asset URLs to preload
402
- * @returns Promise that resolves when all assets are loaded
403
- */
404
- preload(urls: string[]): Promise<void>;
405
- /**
406
- * Check if a model is cached
407
- * @param url - Model URL
408
- */
409
- hasModel(url: string): boolean;
410
- /**
411
- * Check if a texture is cached
412
- * @param url - Texture URL
413
- */
414
- hasTexture(url: string): boolean;
415
- /**
416
- * Get cached model (throws if not cached)
417
- * @param url - Model URL
418
- */
419
- getModel(url: string): LoadedModel;
420
- /**
421
- * Get cached texture (throws if not cached)
422
- * @param url - Texture URL
423
- */
424
- getTexture(url: string): THREE.Texture;
425
- /**
426
- * Clear all caches
427
- */
428
- clearCache(): void;
429
- /**
430
- * Get cache statistics
431
- */
432
- getStats(): {
433
- models: number;
434
- textures: number;
435
- loading: number;
436
- };
437
- }
438
- declare const assetLoader: AssetLoader;
439
-
440
- type CameraMode = 'isometric' | 'perspective' | 'top-down';
441
- interface UseThreeOptions {
442
- /** Camera mode for viewing the scene */
443
- cameraMode?: CameraMode;
444
- /** Initial camera position [x, y, z] */
445
- cameraPosition?: [number, number, number];
446
- /** Background color */
447
- backgroundColor?: string;
448
- /** Enable shadows */
449
- shadows?: boolean;
450
- /** Enable grid helper */
451
- showGrid?: boolean;
452
- /** Grid size */
453
- gridSize?: number;
454
- /** Asset loader instance */
455
- assetLoader?: AssetLoader;
456
- }
457
- interface UseThreeReturn {
458
- /** Canvas element reference (for React Three Fiber) */
459
- canvasRef: React.RefObject<HTMLCanvasElement | null>;
460
- /** Three.js renderer */
461
- renderer: THREE.WebGLRenderer | null;
462
- /** Three.js scene */
463
- scene: THREE.Scene | null;
464
- /** Three.js camera */
465
- camera: THREE.Camera | null;
466
- /** Orbit controls */
467
- controls: OrbitControls | null;
468
- /** Is scene ready */
469
- isReady: boolean;
470
- /** Canvas dimensions */
471
- dimensions: {
472
- width: number;
473
- height: number;
474
- };
475
- /** Set camera position */
476
- setCameraPosition: (x: number, y: number, z: number) => void;
477
- /** Look at a specific point */
478
- lookAt: (x: number, y: number, z: number) => void;
479
- /** Reset camera to initial position */
480
- resetCamera: () => void;
481
- /** Fit view to bounds */
482
- fitView: (bounds: {
483
- minX: number;
484
- maxX: number;
485
- minZ: number;
486
- maxZ: number;
487
- }) => void;
488
- }
489
- /**
490
- * Hook for managing a Three.js scene
491
- * This is a lower-level hook used by GameCanvas3D
492
- */
493
- declare function useThree(options?: UseThreeOptions): UseThreeReturn;
494
-
495
- interface UseAssetLoaderOptions {
496
- /** URLs to preload on mount */
497
- preloadUrls?: string[];
498
- /** Asset loader instance (uses singleton if not provided) */
499
- loader?: AssetLoader;
500
- }
501
- interface AssetLoadingState {
502
- /** Whether assets are currently loading */
503
- isLoading: boolean;
504
- /** Loading progress (0-100) */
505
- progress: number;
506
- /** Number of loaded assets */
507
- loaded: number;
508
- /** Total assets to load */
509
- total: number;
510
- /** Any loading errors */
511
- errors: string[];
512
- }
513
- interface UseAssetLoaderReturn extends AssetLoadingState {
514
- /** Load a single model */
515
- loadModel: (url: string) => Promise<LoadedModel>;
516
- /** Load a single OBJ model */
517
- loadOBJ: (url: string) => Promise<THREE.Group>;
518
- /** Load a single texture */
519
- loadTexture: (url: string) => Promise<THREE.Texture>;
520
- /** Preload multiple assets */
521
- preload: (urls: string[]) => Promise<void>;
522
- /** Check if model is cached */
523
- hasModel: (url: string) => boolean;
524
- /** Check if texture is cached */
525
- hasTexture: (url: string) => boolean;
526
- /** Get cached model */
527
- getModel: (url: string) => LoadedModel | undefined;
528
- /** Get cached texture */
529
- getTexture: (url: string) => THREE.Texture | undefined;
530
- /** Clear all caches */
531
- clearCache: () => void;
532
- }
533
- /**
534
- * Hook for managing 3D asset loading in React components
535
- *
536
- * @example
537
- * ```tsx
538
- * const { loadModel, isLoading, progress } = useAssetLoader({
539
- * preloadUrls: ['/assets/model.glb']
540
- * });
541
- *
542
- * useEffect(() => {
543
- * loadModel('/assets/character.glb').then((model) => {
544
- * scene.add(model.scene);
545
- * });
546
- * }, []);
547
- * ```
548
- */
549
- declare function useAssetLoader(options?: UseAssetLoaderOptions): UseAssetLoaderReturn;
550
-
551
- type NodeType = 'tile' | 'unit' | 'feature' | 'highlight' | 'effect';
552
- interface SceneGraphNode {
553
- /** Unique node identifier */
554
- id: string;
555
- /** Node type classification */
556
- type: NodeType;
557
- /** Three.js object */
558
- mesh: THREE.Object3D;
559
- /** World position */
560
- position: {
561
- x: number;
562
- y: number;
563
- z: number;
564
- };
565
- /** Grid position */
566
- gridPosition: {
567
- x: number;
568
- z: number;
569
- };
570
- /** Optional metadata */
571
- metadata?: Record<string, unknown>;
572
- }
573
- interface UseSceneGraphReturn {
574
- /** Reference to the nodes map */
575
- nodesRef: React.MutableRefObject<Map<string, SceneGraphNode>>;
576
- /** Add a node to the scene */
577
- addNode: (node: SceneGraphNode) => void;
578
- /** Remove a node from the scene */
579
- removeNode: (id: string) => void;
580
- /** Get a node by ID */
581
- getNode: (id: string) => SceneGraphNode | undefined;
582
- /** Update node position */
583
- updateNodePosition: (id: string, x: number, y: number, z: number) => void;
584
- /** Update node grid position */
585
- updateNodeGridPosition: (id: string, gridX: number, gridZ: number) => void;
586
- /** Get node at grid position */
587
- getNodeAtGrid: (x: number, z: number, type?: NodeType) => SceneGraphNode | undefined;
588
- /** Get all nodes of a specific type */
589
- getNodesByType: (type: NodeType) => SceneGraphNode[];
590
- /** Get all nodes within a bounding box */
591
- getNodesInBounds: (minX: number, maxX: number, minZ: number, maxZ: number) => SceneGraphNode[];
592
- /** Clear all nodes */
593
- clearNodes: () => void;
594
- /** Count nodes by type */
595
- countNodes: (type?: NodeType) => number;
596
- }
597
- /**
598
- * Hook for managing the 3D scene graph
599
- *
600
- * @example
601
- * ```tsx
602
- * const { addNode, removeNode, getNodeAtGrid } = useSceneGraph();
603
- *
604
- * // Add a tile
605
- * addNode({
606
- * id: 'tile-0-0',
607
- * type: 'tile',
608
- * mesh: tileMesh,
609
- * position: { x: 0, y: 0, z: 0 },
610
- * gridPosition: { x: 0, z: 0 }
611
- * });
612
- * ```
613
- */
614
- declare function useSceneGraph(): UseSceneGraphReturn;
615
-
616
- interface RaycastHit {
617
- /** Intersected object */
618
- object: THREE.Object3D;
619
- /** Intersection point */
620
- point: THREE.Vector3;
621
- /** Distance from camera */
622
- distance: number;
623
- /** UV coordinates (if available) */
624
- uv?: THREE.Vector2;
625
- /** Face normal */
626
- face?: THREE.Face;
627
- /** Face index */
628
- faceIndex?: number;
629
- /** Instance ID (for instanced meshes) */
630
- instanceId?: number;
631
- }
632
- interface GridHit {
633
- /** Grid X coordinate */
634
- gridX: number;
635
- /** Grid Z coordinate */
636
- gridZ: number;
637
- /** World position */
638
- worldPosition: THREE.Vector3;
639
- /** Intersected object type */
640
- objectType?: 'tile' | 'unit' | 'feature';
641
- /** Object ID if available */
642
- objectId?: string;
643
- }
644
- interface UseRaycasterOptions {
645
- /** Camera reference */
646
- camera: THREE.Camera | null;
647
- /** Canvas element for coordinate conversion */
648
- canvas: HTMLCanvasElement | null;
649
- /** Grid cell size */
650
- cellSize?: number;
651
- /** Grid offset X */
652
- offsetX?: number;
653
- /** Grid offset Z */
654
- offsetZ?: number;
655
- }
656
- interface UseRaycasterReturn {
657
- /** Raycaster instance */
658
- raycaster: React.MutableRefObject<THREE.Raycaster>;
659
- /** Mouse vector instance */
660
- mouse: React.MutableRefObject<THREE.Vector2>;
661
- /** Get intersection at client coordinates */
662
- getIntersection: (clientX: number, clientY: number, objects: THREE.Object3D[]) => RaycastHit | null;
663
- /** Get all intersections at client coordinates */
664
- getAllIntersections: (clientX: number, clientY: number, objects: THREE.Object3D[]) => RaycastHit[];
665
- /** Get grid coordinates at client position */
666
- getGridCoordinates: (clientX: number, clientY: number) => {
667
- x: number;
668
- z: number;
669
- } | null;
670
- /** Get tile at client position from scene */
671
- getTileAtPosition: (clientX: number, clientY: number, scene: THREE.Scene) => GridHit | null;
672
- /** Convert client coordinates to normalized device coordinates */
673
- clientToNDC: (clientX: number, clientY: number) => {
674
- x: number;
675
- y: number;
676
- };
677
- /** Check if point is within canvas bounds */
678
- isWithinCanvas: (clientX: number, clientY: number) => boolean;
679
- }
680
- /**
681
- * Hook for 3D raycasting operations
682
- *
683
- * @example
684
- * ```tsx
685
- * const { getIntersection, getGridCoordinates } = useRaycaster({
686
- * camera,
687
- * canvas: canvasRef.current
688
- * });
689
- *
690
- * const handleClick = (e: MouseEvent) => {
691
- * const hit = getIntersection(e.clientX, e.clientY, tileMeshes);
692
- * if (hit) {
693
- * const grid = getGridCoordinates(e.clientX, e.clientY);
694
- * console.log('Clicked grid:', grid);
695
- * }
696
- * };
697
- * ```
698
- */
699
- declare function useRaycaster(options: UseRaycasterOptions): UseRaycasterReturn;
700
-
701
- interface GameCanvas3DEventConfig {
702
- /** Event name for tile clicks */
703
- tileClickEvent?: string;
704
- /** Event name for unit clicks */
705
- unitClickEvent?: string;
706
- /** Event name for feature clicks */
707
- featureClickEvent?: string;
708
- /** Event name for canvas clicks */
709
- canvasClickEvent?: string;
710
- /** Event name for tile hover */
711
- tileHoverEvent?: string;
712
- /** Event name for tile leave */
713
- tileLeaveEvent?: string;
714
- /** Event name for unit animation changes */
715
- unitAnimationEvent?: string;
716
- /** Event name for camera changes */
717
- cameraChangeEvent?: string;
718
- }
719
- /** Minimal mouse event interface — satisfied by both React.MouseEvent and ThreeEvent<MouseEvent> */
720
- interface MinimalMouseEvent {
721
- clientX: number;
722
- clientY: number;
723
- button: number;
724
- }
725
- interface UseGameCanvas3DEventsOptions extends GameCanvas3DEventConfig {
726
- /** Callback for tile clicks (direct) */
727
- onTileClick?: (tile: IsometricTile, event: React.MouseEvent) => void;
728
- /** Callback for unit clicks (direct) */
729
- onUnitClick?: (unit: IsometricUnit, event: React.MouseEvent) => void;
730
- /** Callback for feature clicks (direct) */
731
- onFeatureClick?: (feature: IsometricFeature, event: React.MouseEvent) => void;
732
- /** Callback for canvas clicks (direct) */
733
- onCanvasClick?: (event: React.MouseEvent) => void;
734
- /** Callback for tile hover (direct) */
735
- onTileHover?: (tile: IsometricTile | null, event: React.MouseEvent) => void;
736
- /** Callback for unit animation changes (direct) */
737
- onUnitAnimation?: (unitId: string, state: string) => void;
738
- }
739
- interface UseGameCanvas3DEventsReturn {
740
- /** Handle tile click - emits event and calls callback */
741
- handleTileClick: (tile: IsometricTile, event: React.MouseEvent) => void;
742
- /** Handle unit click - emits event and calls callback */
743
- handleUnitClick: (unit: IsometricUnit, event: React.MouseEvent) => void;
744
- /** Handle feature click - emits event and calls callback */
745
- handleFeatureClick: (feature: IsometricFeature, event: React.MouseEvent) => void;
746
- /** Handle canvas click - emits event and calls callback */
747
- handleCanvasClick: (event: MinimalMouseEvent) => void;
748
- /** Handle tile hover - emits event and calls callback */
749
- handleTileHover: (tile: IsometricTile | null, event: React.MouseEvent) => void;
750
- /** Handle unit animation - emits event and calls callback */
751
- handleUnitAnimation: (unitId: string, state: string) => void;
752
- /** Handle camera change - emits event */
753
- handleCameraChange: (position: {
754
- x: number;
755
- y: number;
756
- z: number;
757
- }) => void;
758
- }
759
- /**
760
- * Hook for integrating GameCanvas3D with the event bus
761
- *
762
- * Supports both declarative event props (tileClickEvent) and
763
- * direct callback props (onTileClick).
764
- *
765
- * @example
766
- * ```tsx
767
- * const events = useGameCanvas3DEvents({
768
- * tileClickEvent: 'TILE_SELECTED',
769
- * unitClickEvent: 'UNIT_SELECTED',
770
- * onTileClick: (tile) => console.log('Tile:', tile)
771
- * });
772
- *
773
- * // In component:
774
- * <TileRenderer onTileClick={events.handleTileClick} />
775
- * ```
776
- */
777
- declare function useGameCanvas3DEvents(options: UseGameCanvas3DEventsOptions): UseGameCanvas3DEventsReturn;
778
-
779
- /**
780
- * TileRenderer
781
- *
782
- * Renders isometric tiles using Three.js InstancedMesh for performance.
783
- * Supports texture mapping and custom tile geometries.
784
- *
785
- * @packageDocumentation
786
- */
787
-
788
- interface TileRendererProps {
789
- /** Array of tiles to render */
790
- tiles: IsometricTile[];
791
- /** Grid cell size */
792
- cellSize?: number;
793
- /** Grid offset X */
794
- offsetX?: number;
795
- /** Grid offset Z */
796
- offsetZ?: number;
797
- /** Use instancing for performance */
798
- useInstancing?: boolean;
799
- /** Terrain color mapping */
800
- terrainColors?: Record<string, string>;
801
- /** Called when tile is clicked */
802
- onTileClick?: (tile: IsometricTile) => void;
803
- /** Called when tile is hovered */
804
- onTileHover?: (tile: IsometricTile | null) => void;
805
- /** Selected tile IDs */
806
- selectedTileIds?: string[];
807
- /** Valid move tile coordinates */
808
- validMoves?: Array<{
809
- x: number;
810
- z: number;
811
- }>;
812
- /** Attack target coordinates */
813
- attackTargets?: Array<{
814
- x: number;
815
- z: number;
816
- }>;
817
- }
818
- /**
819
- * TileRenderer Component
820
- *
821
- * Renders grid tiles with instancing for optimal performance.
822
- *
823
- * @example
824
- * ```tsx
825
- * <TileRenderer
826
- * tiles={tiles}
827
- * cellSize={1}
828
- * onTileClick={handleTileClick}
829
- * validMoves={[{ x: 1, z: 1 }]}
830
- * />
831
- * ```
832
- */
833
- declare function TileRenderer({ tiles, cellSize, offsetX, offsetZ, useInstancing, terrainColors, onTileClick, onTileHover, selectedTileIds, validMoves, attackTargets, }: TileRendererProps): React__default.JSX.Element;
834
-
835
- /**
836
- * UnitRenderer
837
- *
838
- * Renders animated units in the 3D scene.
839
- * Supports skeletal animations, health bars, and selection indicators.
840
- *
841
- * @packageDocumentation
842
- */
843
-
844
- type UnitAnimationState = 'idle' | 'walk' | 'attack' | 'hurt' | 'die';
845
- interface UnitRendererProps {
846
- /** Array of units to render */
847
- units: IsometricUnit[];
848
- /** Grid cell size */
849
- cellSize?: number;
850
- /** Grid offset X */
851
- offsetX?: number;
852
- /** Grid offset Z */
853
- offsetZ?: number;
854
- /** Currently selected unit ID */
855
- selectedUnitId?: string | null;
856
- /** Called when unit is clicked */
857
- onUnitClick?: (unit: IsometricUnit) => void;
858
- /** Called when unit animation state changes */
859
- onAnimationStateChange?: (unitId: string, state: UnitAnimationState) => void;
860
- /** Animation speed multiplier */
861
- animationSpeed?: number;
862
- }
863
- /**
864
- * UnitRenderer Component
865
- *
866
- * Renders all units in the scene.
867
- *
868
- * @example
869
- * ```tsx
870
- * <UnitRenderer
871
- * units={units}
872
- * cellSize={1}
873
- * selectedUnitId="unit-1"
874
- * onUnitClick={handleUnitClick}
875
- * />
876
- * ```
877
- */
878
- declare function UnitRenderer({ units, cellSize, offsetX, offsetZ, selectedUnitId, onUnitClick, onAnimationStateChange, animationSpeed, }: UnitRendererProps): React__default.JSX.Element;
879
-
880
- /**
881
- * FeatureRenderer
882
- *
883
- * Renders static features (trees, rocks, buildings) in the 3D scene.
884
- * Supports different feature types and selection states.
885
- *
886
- * @packageDocumentation
887
- */
888
-
889
- interface FeatureRendererProps {
890
- /** Array of features to render */
891
- features: IsometricFeature[];
892
- /** Grid cell size */
893
- cellSize?: number;
894
- /** Grid offset X */
895
- offsetX?: number;
896
- /** Grid offset Z */
897
- offsetZ?: number;
898
- /** Called when feature is clicked */
899
- onFeatureClick?: (feature: IsometricFeature) => void;
900
- /** Called when feature is hovered */
901
- onFeatureHover?: (feature: IsometricFeature | null) => void;
902
- /** Selected feature IDs */
903
- selectedFeatureIds?: string[];
904
- /** Feature color overrides */
905
- featureColors?: Record<string, string>;
906
- }
907
- /**
908
- * FeatureRenderer Component
909
- *
910
- * Renders all features in the scene.
911
- *
912
- * @example
913
- * ```tsx
914
- * <FeatureRenderer
915
- * features={features}
916
- * cellSize={1}
917
- * onFeatureClick={handleFeatureClick}
918
- * />
919
- * ```
920
- */
921
- declare function FeatureRenderer({ features, cellSize, offsetX, offsetZ, onFeatureClick, onFeatureHover, selectedFeatureIds, featureColors, }: FeatureRendererProps): React__default.JSX.Element;
922
-
923
- /**
924
- * FeatureRenderer3D
925
- *
926
- * Renders 3D features with GLB model loading from CDN.
927
- * Supports assetUrl property on features for external model loading.
928
- *
929
- * @packageDocumentation
930
- */
931
-
932
- interface FeatureRenderer3DProps {
933
- /** Array of features to render */
934
- features: IsometricFeature[];
935
- /** Grid cell size */
936
- cellSize?: number;
937
- /** Grid offset X */
938
- offsetX?: number;
939
- /** Grid offset Z */
940
- offsetZ?: number;
941
- /** Called when feature is clicked */
942
- onFeatureClick?: (feature: IsometricFeature) => void;
943
- /** Called when feature is hovered */
944
- onFeatureHover?: (feature: IsometricFeature | null) => void;
945
- /** Selected feature IDs */
946
- selectedFeatureIds?: string[];
947
- }
948
- /**
949
- * FeatureRenderer3D Component
950
- *
951
- * Renders 3D features with GLB model loading support.
952
- *
953
- * @example
954
- * ```tsx
955
- * <FeatureRenderer3D
956
- * features={[
957
- * { id: 'gate', x: 0, y: 0, type: 'gate', assetUrl: 'https://.../gate.glb' }
958
- * ]}
959
- * cellSize={1}
960
- * />
961
- * ```
962
- */
963
- declare function FeatureRenderer3D({ features, cellSize, offsetX, offsetZ, onFeatureClick, onFeatureHover, selectedFeatureIds, }: FeatureRenderer3DProps): React__default.JSX.Element;
964
-
965
- declare function preloadFeatures(urls: string[]): void;
966
-
967
- /**
968
- * Grid 3D Utilities
969
- *
970
- * Utility functions for 3D grid coordinate transformations,
971
- * raycasting, and spatial calculations for GameCanvas3D.
972
- *
973
- * @packageDocumentation
974
- */
975
-
976
- interface Grid3DConfig {
977
- /** Size of each grid cell */
978
- cellSize: number;
979
- /** Grid offset X */
980
- offsetX?: number;
981
- /** Grid offset Z */
982
- offsetZ?: number;
983
- /** Grid Y height (elevation) */
984
- elevation?: number;
985
- }
986
- interface GridCoordinate {
987
- x: number;
988
- y: number;
989
- z: number;
990
- }
991
- /**
992
- * Convert grid coordinates to world position
993
- * @param gridX - Grid X coordinate
994
- * @param gridZ - Grid Z coordinate
995
- * @param config - Grid configuration
996
- * @returns World position vector
997
- */
998
- declare function gridToWorld(gridX: number, gridZ: number, config?: Grid3DConfig): THREE.Vector3;
999
- /**
1000
- * Convert world position to grid coordinates
1001
- * @param worldX - World X position
1002
- * @param worldZ - World Z position
1003
- * @param config - Grid configuration
1004
- * @returns Grid coordinates
1005
- */
1006
- declare function worldToGrid(worldX: number, worldZ: number, config?: Grid3DConfig): {
1007
- x: number;
1008
- z: number;
1009
- };
1010
- /**
1011
- * Raycast from camera through mouse position to find grid intersection
1012
- * @param camera - Three.js camera
1013
- * @param mouseX - Mouse X position (normalized -1 to 1)
1014
- * @param mouseY - Mouse Y position (normalized -1 to 1)
1015
- * @param planeY - Y height of the intersection plane (default: 0)
1016
- * @returns Intersection point or null
1017
- */
1018
- declare function raycastToPlane(camera: THREE.Camera, mouseX: number, mouseY: number, planeY?: number): THREE.Vector3 | null;
1019
- /**
1020
- * Raycast from camera through mouse position against a set of objects
1021
- * @param camera - Three.js camera
1022
- * @param mouseX - Mouse X position (normalized -1 to 1)
1023
- * @param mouseY - Mouse Y position (normalized -1 to 1)
1024
- * @param objects - Array of objects to test
1025
- * @returns First intersection or null
1026
- */
1027
- declare function raycastToObjects(camera: THREE.Camera, mouseX: number, mouseY: number, objects: THREE.Object3D[]): THREE.Intersection | null;
1028
- /**
1029
- * Calculate distance between two grid coordinates
1030
- * @param a - First grid coordinate
1031
- * @param b - Second grid coordinate
1032
- * @returns Distance in grid units
1033
- */
1034
- declare function gridDistance(a: {
1035
- x: number;
1036
- z: number;
1037
- }, b: {
1038
- x: number;
1039
- z: number;
1040
- }): number;
1041
- /**
1042
- * Calculate Manhattan distance between two grid coordinates
1043
- * @param a - First grid coordinate
1044
- * @param b - Second grid coordinate
1045
- * @returns Manhattan distance
1046
- */
1047
- declare function gridManhattanDistance(a: {
1048
- x: number;
1049
- z: number;
1050
- }, b: {
1051
- x: number;
1052
- z: number;
1053
- }): number;
1054
- /**
1055
- * Get neighboring grid cells
1056
- * @param x - Center X coordinate
1057
- * @param z - Center Z coordinate
1058
- * @param includeDiagonal - Whether to include diagonal neighbors
1059
- * @returns Array of neighbor coordinates
1060
- */
1061
- declare function getNeighbors(x: number, z: number, includeDiagonal?: boolean): {
1062
- x: number;
1063
- z: number;
1064
- }[];
1065
- /**
1066
- * Check if a grid coordinate is within bounds
1067
- * @param x - X coordinate
1068
- * @param z - Z coordinate
1069
- * @param bounds - Bounds object
1070
- * @returns Whether the coordinate is within bounds
1071
- */
1072
- declare function isInBounds(x: number, z: number, bounds: {
1073
- minX: number;
1074
- maxX: number;
1075
- minZ: number;
1076
- maxZ: number;
1077
- }): boolean;
1078
- /**
1079
- * Get all grid cells within a circular radius
1080
- * @param centerX - Center X coordinate
1081
- * @param centerZ - Center Z coordinate
1082
- * @param radius - Radius in grid units
1083
- * @returns Array of coordinates within radius
1084
- */
1085
- declare function getCellsInRadius(centerX: number, centerZ: number, radius: number): {
1086
- x: number;
1087
- z: number;
1088
- }[];
1089
- /**
1090
- * Create a highlight mesh for grid cells
1091
- * @param color - Highlight color
1092
- * @param opacity - Opacity (0-1)
1093
- * @returns Mesh that can be positioned at grid cells
1094
- */
1095
- declare function createGridHighlight(color?: number, opacity?: number): THREE.Mesh;
1096
- /**
1097
- * Normalize mouse coordinates to NDC (-1 to 1)
1098
- * @param clientX - Mouse client X
1099
- * @param clientY - Mouse client Y
1100
- * @param element - Canvas element
1101
- * @returns Normalized coordinates
1102
- */
1103
- declare function normalizeMouseCoordinates(clientX: number, clientY: number, element: HTMLElement): {
1104
- x: number;
1105
- y: number;
1106
- };
1107
-
1108
- /**
1109
- * Culling Utilities
1110
- *
1111
- * Frustum culling and LOD (Level of Detail) management for 3D scene optimization.
1112
- *
1113
- * @packageDocumentation
1114
- */
1115
-
1116
- interface CullingOptions {
1117
- /** Camera frustum for culling */
1118
- camera: THREE.Camera;
1119
- /** Optional padding around frustum */
1120
- padding?: number;
1121
- }
1122
- interface LODLevel {
1123
- /** Distance threshold for this LOD level */
1124
- distance: number;
1125
- /** Geometry or mesh for this level */
1126
- geometry?: THREE.BufferGeometry;
1127
- /** Scale multiplier for this level */
1128
- scale?: number;
1129
- /** Whether to use simplified material */
1130
- simpleMaterial?: boolean;
1131
- }
1132
- interface LODConfig {
1133
- /** LOD levels from closest to farthest */
1134
- levels: LODLevel[];
1135
- /** Transition smoothness (0-1) */
1136
- transitionSmoothness?: number;
1137
- }
1138
- /**
1139
- * Frustum culling check for a position
1140
- * @param position - World position to check
1141
- * @param camera - Camera to check against
1142
- * @param padding - Optional padding in world units
1143
- * @returns Whether the position is within the frustum
1144
- */
1145
- declare function isInFrustum(position: THREE.Vector3, camera: THREE.Camera, padding?: number): boolean;
1146
- /**
1147
- * Filter an array of positions to only those within the frustum
1148
- * @param positions - Array of world positions
1149
- * @param camera - Camera to check against
1150
- * @param padding - Optional padding in world units
1151
- * @returns Array of positions within frustum
1152
- */
1153
- declare function filterByFrustum(positions: THREE.Vector3[], camera: THREE.Camera, padding?: number): THREE.Vector3[];
1154
- /**
1155
- * Get indices of visible items from an array
1156
- * @param positions - Array of world positions
1157
- * @param camera - Camera to check against
1158
- * @param padding - Optional padding in world units
1159
- * @returns Set of visible indices
1160
- */
1161
- declare function getVisibleIndices(positions: THREE.Vector3[], camera: THREE.Camera, padding?: number): Set<number>;
1162
- /**
1163
- * Calculate LOD level based on distance from camera
1164
- * @param position - Object position
1165
- * @param camera - Camera position
1166
- * @param lodLevels - Array of distance thresholds (sorted closest to farthest)
1167
- * @returns Index of the LOD level to use
1168
- */
1169
- declare function calculateLODLevel(position: THREE.Vector3, camera: THREE.Camera, lodLevels: number[]): number;
1170
- /**
1171
- * Create a distance-based LOD system for an instanced mesh
1172
- * @param instancedMesh - The instanced mesh to manage
1173
- * @param positions - Array of instance positions
1174
- * @param camera - Camera to calculate distances from
1175
- * @param lodDistances - Distance thresholds for LOD levels
1176
- * @returns Array of LOD indices for each instance
1177
- */
1178
- declare function updateInstanceLOD(instancedMesh: THREE.InstancedMesh, positions: THREE.Vector3[], camera: THREE.Camera, lodDistances: number[]): Uint8Array;
1179
- /**
1180
- * Create visibility data for instanced mesh culling
1181
- * Updates the instance matrix to hide/show instances
1182
- * @param instancedMesh - The instanced mesh
1183
- * @param positions - Array of instance positions
1184
- * @param visibleIndices - Set of visible indices
1185
- * @returns Updated count of visible instances
1186
- */
1187
- declare function cullInstancedMesh(instancedMesh: THREE.InstancedMesh, positions: THREE.Vector3[], visibleIndices: Set<number>): number;
1188
- /**
1189
- * Spatial hash grid for efficient object queries
1190
- */
1191
- declare class SpatialHashGrid {
1192
- private cellSize;
1193
- private cells;
1194
- private objectPositions;
1195
- constructor(cellSize?: number);
1196
- /**
1197
- * Get cell key for a position
1198
- */
1199
- private getCellKey;
1200
- /**
1201
- * Insert an object into the grid
1202
- */
1203
- insert(id: string, position: THREE.Vector3): void;
1204
- /**
1205
- * Remove an object from the grid
1206
- */
1207
- remove(id: string): void;
1208
- /**
1209
- * Update an object's position
1210
- */
1211
- update(id: string, newPosition: THREE.Vector3): void;
1212
- /**
1213
- * Query objects within a radius of a position
1214
- */
1215
- queryRadius(center: THREE.Vector3, radius: number): string[];
1216
- /**
1217
- * Query objects within a bounding box
1218
- */
1219
- queryBox(minX: number, maxX: number, minZ: number, maxZ: number): string[];
1220
- /**
1221
- * Clear all objects from the grid
1222
- */
1223
- clear(): void;
1224
- /**
1225
- * Get statistics about the grid
1226
- */
1227
- getStats(): {
1228
- objects: number;
1229
- cells: number;
1230
- };
1231
- }
1232
-
1233
- export { AssetLoader, type AssetLoadingState, Camera3D, type Camera3DHandle, type Camera3DProps, type CameraMode$1 as CameraMode, Canvas3DErrorBoundary, type Canvas3DErrorBoundaryProps, type Canvas3DErrorBoundaryState, Canvas3DLoadingState, type Canvas3DLoadingStateProps, type CullingOptions, FeatureRenderer, FeatureRenderer3D, type FeatureRenderer3DProps, type FeatureRendererProps, type GameCanvas3DEventConfig, type Grid3DConfig, type GridCoordinate, type GridHit, type LODConfig, type LODLevel, Lighting3D, type Lighting3DProps, type LoadedModel, ModelLoader, type ModelLoaderProps, type NodeType, type Physics3DState, PhysicsObject3D, type PhysicsObject3DProps, type RaycastHit, Scene3D, type Scene3DProps, type SceneGraphNode, SpatialHashGrid, TileRenderer, type TileRendererProps, type UnitAnimationState, UnitRenderer, type UnitRendererProps, type UseAssetLoaderOptions, type UseAssetLoaderReturn, type UseGameCanvas3DEventsOptions, type UseGameCanvas3DEventsReturn, type UseRaycasterOptions, type UseRaycasterReturn, type UseSceneGraphReturn, type UseThreeOptions, type UseThreeReturn, assetLoader, calculateLODLevel, createGridHighlight, cullInstancedMesh, filterByFrustum, getCellsInRadius, getNeighbors, getVisibleIndices, gridDistance, gridManhattanDistance, gridToWorld, isInBounds, isInFrustum, normalizeMouseCoordinates, preloadFeatures, raycastToObjects, raycastToPlane, updateInstanceLOD, useAssetLoader, useGameCanvas3DEvents, usePhysics3DController, useRaycaster, useSceneGraph, useThree, worldToGrid };