@almadar/ui 2.0.4 → 2.1.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/ThemeContext-D9xUORq5.d.ts +105 -0
- package/dist/{chunk-QU4JHKVC.js → chunk-BTXQJGFB.js} +24 -24
- package/dist/{chunk-JZ55M7DV.js → chunk-FZJ73RDM.js} +2 -2
- package/dist/cn-BoBXsxuX.d.ts +194 -0
- package/dist/components/index.d.ts +7080 -0
- package/dist/components/index.js +8 -8
- package/dist/components/organisms/game/three/index.d.ts +1227 -0
- package/dist/context/index.d.ts +208 -0
- package/dist/context/index.js +2 -2
- package/dist/event-bus-types-CjJduURa.d.ts +73 -0
- package/dist/hooks/index.d.ts +1091 -0
- package/dist/hooks/index.js +2 -2
- package/dist/isometric-ynNHVPZx.d.ts +111 -0
- package/dist/lib/index.d.ts +427 -0
- package/dist/locales/index.d.ts +22 -0
- package/dist/offline-executor-CHr4uAhf.d.ts +401 -0
- package/dist/providers/index.d.ts +465 -0
- package/dist/providers/index.js +4 -4
- package/dist/renderer/index.d.ts +525 -0
- package/dist/stores/index.d.ts +151 -0
- package/dist/useUISlots-D0mttBSP.d.ts +85 -0
- package/package.json +1 -1
- package/dist/{chunk-BKC4XU44.js → chunk-6WHMUKED.js} +1 -1
|
@@ -0,0 +1,1227 @@
|
|
|
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
|
+
interface UseGameCanvas3DEventsOptions extends GameCanvas3DEventConfig {
|
|
720
|
+
/** Callback for tile clicks (direct) */
|
|
721
|
+
onTileClick?: (tile: IsometricTile, event: React.MouseEvent) => void;
|
|
722
|
+
/** Callback for unit clicks (direct) */
|
|
723
|
+
onUnitClick?: (unit: IsometricUnit, event: React.MouseEvent) => void;
|
|
724
|
+
/** Callback for feature clicks (direct) */
|
|
725
|
+
onFeatureClick?: (feature: IsometricFeature, event: React.MouseEvent) => void;
|
|
726
|
+
/** Callback for canvas clicks (direct) */
|
|
727
|
+
onCanvasClick?: (event: React.MouseEvent) => void;
|
|
728
|
+
/** Callback for tile hover (direct) */
|
|
729
|
+
onTileHover?: (tile: IsometricTile | null, event: React.MouseEvent) => void;
|
|
730
|
+
/** Callback for unit animation changes (direct) */
|
|
731
|
+
onUnitAnimation?: (unitId: string, state: string) => void;
|
|
732
|
+
}
|
|
733
|
+
interface UseGameCanvas3DEventsReturn {
|
|
734
|
+
/** Handle tile click - emits event and calls callback */
|
|
735
|
+
handleTileClick: (tile: IsometricTile, event: React.MouseEvent) => void;
|
|
736
|
+
/** Handle unit click - emits event and calls callback */
|
|
737
|
+
handleUnitClick: (unit: IsometricUnit, event: React.MouseEvent) => void;
|
|
738
|
+
/** Handle feature click - emits event and calls callback */
|
|
739
|
+
handleFeatureClick: (feature: IsometricFeature, event: React.MouseEvent) => void;
|
|
740
|
+
/** Handle canvas click - emits event and calls callback */
|
|
741
|
+
handleCanvasClick: (event: React.MouseEvent) => void;
|
|
742
|
+
/** Handle tile hover - emits event and calls callback */
|
|
743
|
+
handleTileHover: (tile: IsometricTile | null, event: React.MouseEvent) => void;
|
|
744
|
+
/** Handle unit animation - emits event and calls callback */
|
|
745
|
+
handleUnitAnimation: (unitId: string, state: string) => void;
|
|
746
|
+
/** Handle camera change - emits event */
|
|
747
|
+
handleCameraChange: (position: {
|
|
748
|
+
x: number;
|
|
749
|
+
y: number;
|
|
750
|
+
z: number;
|
|
751
|
+
}) => void;
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Hook for integrating GameCanvas3D with the event bus
|
|
755
|
+
*
|
|
756
|
+
* Supports both declarative event props (tileClickEvent) and
|
|
757
|
+
* direct callback props (onTileClick).
|
|
758
|
+
*
|
|
759
|
+
* @example
|
|
760
|
+
* ```tsx
|
|
761
|
+
* const events = useGameCanvas3DEvents({
|
|
762
|
+
* tileClickEvent: 'TILE_SELECTED',
|
|
763
|
+
* unitClickEvent: 'UNIT_SELECTED',
|
|
764
|
+
* onTileClick: (tile) => console.log('Tile:', tile)
|
|
765
|
+
* });
|
|
766
|
+
*
|
|
767
|
+
* // In component:
|
|
768
|
+
* <TileRenderer onTileClick={events.handleTileClick} />
|
|
769
|
+
* ```
|
|
770
|
+
*/
|
|
771
|
+
declare function useGameCanvas3DEvents(options: UseGameCanvas3DEventsOptions): UseGameCanvas3DEventsReturn;
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* TileRenderer
|
|
775
|
+
*
|
|
776
|
+
* Renders isometric tiles using Three.js InstancedMesh for performance.
|
|
777
|
+
* Supports texture mapping and custom tile geometries.
|
|
778
|
+
*
|
|
779
|
+
* @packageDocumentation
|
|
780
|
+
*/
|
|
781
|
+
|
|
782
|
+
interface TileRendererProps {
|
|
783
|
+
/** Array of tiles to render */
|
|
784
|
+
tiles: IsometricTile[];
|
|
785
|
+
/** Grid cell size */
|
|
786
|
+
cellSize?: number;
|
|
787
|
+
/** Grid offset X */
|
|
788
|
+
offsetX?: number;
|
|
789
|
+
/** Grid offset Z */
|
|
790
|
+
offsetZ?: number;
|
|
791
|
+
/** Use instancing for performance */
|
|
792
|
+
useInstancing?: boolean;
|
|
793
|
+
/** Terrain color mapping */
|
|
794
|
+
terrainColors?: Record<string, string>;
|
|
795
|
+
/** Called when tile is clicked */
|
|
796
|
+
onTileClick?: (tile: IsometricTile) => void;
|
|
797
|
+
/** Called when tile is hovered */
|
|
798
|
+
onTileHover?: (tile: IsometricTile | null) => void;
|
|
799
|
+
/** Selected tile IDs */
|
|
800
|
+
selectedTileIds?: string[];
|
|
801
|
+
/** Valid move tile coordinates */
|
|
802
|
+
validMoves?: Array<{
|
|
803
|
+
x: number;
|
|
804
|
+
z: number;
|
|
805
|
+
}>;
|
|
806
|
+
/** Attack target coordinates */
|
|
807
|
+
attackTargets?: Array<{
|
|
808
|
+
x: number;
|
|
809
|
+
z: number;
|
|
810
|
+
}>;
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* TileRenderer Component
|
|
814
|
+
*
|
|
815
|
+
* Renders grid tiles with instancing for optimal performance.
|
|
816
|
+
*
|
|
817
|
+
* @example
|
|
818
|
+
* ```tsx
|
|
819
|
+
* <TileRenderer
|
|
820
|
+
* tiles={tiles}
|
|
821
|
+
* cellSize={1}
|
|
822
|
+
* onTileClick={handleTileClick}
|
|
823
|
+
* validMoves={[{ x: 1, z: 1 }]}
|
|
824
|
+
* />
|
|
825
|
+
* ```
|
|
826
|
+
*/
|
|
827
|
+
declare function TileRenderer({ tiles, cellSize, offsetX, offsetZ, useInstancing, terrainColors, onTileClick, onTileHover, selectedTileIds, validMoves, attackTargets, }: TileRendererProps): React__default.JSX.Element;
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* UnitRenderer
|
|
831
|
+
*
|
|
832
|
+
* Renders animated units in the 3D scene.
|
|
833
|
+
* Supports skeletal animations, health bars, and selection indicators.
|
|
834
|
+
*
|
|
835
|
+
* @packageDocumentation
|
|
836
|
+
*/
|
|
837
|
+
|
|
838
|
+
type UnitAnimationState = 'idle' | 'walk' | 'attack' | 'hurt' | 'die';
|
|
839
|
+
interface UnitRendererProps {
|
|
840
|
+
/** Array of units to render */
|
|
841
|
+
units: IsometricUnit[];
|
|
842
|
+
/** Grid cell size */
|
|
843
|
+
cellSize?: number;
|
|
844
|
+
/** Grid offset X */
|
|
845
|
+
offsetX?: number;
|
|
846
|
+
/** Grid offset Z */
|
|
847
|
+
offsetZ?: number;
|
|
848
|
+
/** Currently selected unit ID */
|
|
849
|
+
selectedUnitId?: string | null;
|
|
850
|
+
/** Called when unit is clicked */
|
|
851
|
+
onUnitClick?: (unit: IsometricUnit) => void;
|
|
852
|
+
/** Called when unit animation state changes */
|
|
853
|
+
onAnimationStateChange?: (unitId: string, state: UnitAnimationState) => void;
|
|
854
|
+
/** Animation speed multiplier */
|
|
855
|
+
animationSpeed?: number;
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* UnitRenderer Component
|
|
859
|
+
*
|
|
860
|
+
* Renders all units in the scene.
|
|
861
|
+
*
|
|
862
|
+
* @example
|
|
863
|
+
* ```tsx
|
|
864
|
+
* <UnitRenderer
|
|
865
|
+
* units={units}
|
|
866
|
+
* cellSize={1}
|
|
867
|
+
* selectedUnitId="unit-1"
|
|
868
|
+
* onUnitClick={handleUnitClick}
|
|
869
|
+
* />
|
|
870
|
+
* ```
|
|
871
|
+
*/
|
|
872
|
+
declare function UnitRenderer({ units, cellSize, offsetX, offsetZ, selectedUnitId, onUnitClick, onAnimationStateChange, animationSpeed, }: UnitRendererProps): React__default.JSX.Element;
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* FeatureRenderer
|
|
876
|
+
*
|
|
877
|
+
* Renders static features (trees, rocks, buildings) in the 3D scene.
|
|
878
|
+
* Supports different feature types and selection states.
|
|
879
|
+
*
|
|
880
|
+
* @packageDocumentation
|
|
881
|
+
*/
|
|
882
|
+
|
|
883
|
+
interface FeatureRendererProps {
|
|
884
|
+
/** Array of features to render */
|
|
885
|
+
features: IsometricFeature[];
|
|
886
|
+
/** Grid cell size */
|
|
887
|
+
cellSize?: number;
|
|
888
|
+
/** Grid offset X */
|
|
889
|
+
offsetX?: number;
|
|
890
|
+
/** Grid offset Z */
|
|
891
|
+
offsetZ?: number;
|
|
892
|
+
/** Called when feature is clicked */
|
|
893
|
+
onFeatureClick?: (feature: IsometricFeature) => void;
|
|
894
|
+
/** Called when feature is hovered */
|
|
895
|
+
onFeatureHover?: (feature: IsometricFeature | null) => void;
|
|
896
|
+
/** Selected feature IDs */
|
|
897
|
+
selectedFeatureIds?: string[];
|
|
898
|
+
/** Feature color overrides */
|
|
899
|
+
featureColors?: Record<string, string>;
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* FeatureRenderer Component
|
|
903
|
+
*
|
|
904
|
+
* Renders all features in the scene.
|
|
905
|
+
*
|
|
906
|
+
* @example
|
|
907
|
+
* ```tsx
|
|
908
|
+
* <FeatureRenderer
|
|
909
|
+
* features={features}
|
|
910
|
+
* cellSize={1}
|
|
911
|
+
* onFeatureClick={handleFeatureClick}
|
|
912
|
+
* />
|
|
913
|
+
* ```
|
|
914
|
+
*/
|
|
915
|
+
declare function FeatureRenderer({ features, cellSize, offsetX, offsetZ, onFeatureClick, onFeatureHover, selectedFeatureIds, featureColors, }: FeatureRendererProps): React__default.JSX.Element;
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* FeatureRenderer3D
|
|
919
|
+
*
|
|
920
|
+
* Renders 3D features with GLB model loading from CDN.
|
|
921
|
+
* Supports assetUrl property on features for external model loading.
|
|
922
|
+
*
|
|
923
|
+
* @packageDocumentation
|
|
924
|
+
*/
|
|
925
|
+
|
|
926
|
+
interface FeatureRenderer3DProps {
|
|
927
|
+
/** Array of features to render */
|
|
928
|
+
features: IsometricFeature[];
|
|
929
|
+
/** Grid cell size */
|
|
930
|
+
cellSize?: number;
|
|
931
|
+
/** Grid offset X */
|
|
932
|
+
offsetX?: number;
|
|
933
|
+
/** Grid offset Z */
|
|
934
|
+
offsetZ?: number;
|
|
935
|
+
/** Called when feature is clicked */
|
|
936
|
+
onFeatureClick?: (feature: IsometricFeature) => void;
|
|
937
|
+
/** Called when feature is hovered */
|
|
938
|
+
onFeatureHover?: (feature: IsometricFeature | null) => void;
|
|
939
|
+
/** Selected feature IDs */
|
|
940
|
+
selectedFeatureIds?: string[];
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
943
|
+
* FeatureRenderer3D Component
|
|
944
|
+
*
|
|
945
|
+
* Renders 3D features with GLB model loading support.
|
|
946
|
+
*
|
|
947
|
+
* @example
|
|
948
|
+
* ```tsx
|
|
949
|
+
* <FeatureRenderer3D
|
|
950
|
+
* features={[
|
|
951
|
+
* { id: 'gate', x: 0, y: 0, type: 'gate', assetUrl: 'https://.../gate.glb' }
|
|
952
|
+
* ]}
|
|
953
|
+
* cellSize={1}
|
|
954
|
+
* />
|
|
955
|
+
* ```
|
|
956
|
+
*/
|
|
957
|
+
declare function FeatureRenderer3D({ features, cellSize, offsetX, offsetZ, onFeatureClick, onFeatureHover, selectedFeatureIds, }: FeatureRenderer3DProps): React__default.JSX.Element;
|
|
958
|
+
|
|
959
|
+
declare function preloadFeatures(urls: string[]): void;
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Grid 3D Utilities
|
|
963
|
+
*
|
|
964
|
+
* Utility functions for 3D grid coordinate transformations,
|
|
965
|
+
* raycasting, and spatial calculations for GameCanvas3D.
|
|
966
|
+
*
|
|
967
|
+
* @packageDocumentation
|
|
968
|
+
*/
|
|
969
|
+
|
|
970
|
+
interface Grid3DConfig {
|
|
971
|
+
/** Size of each grid cell */
|
|
972
|
+
cellSize: number;
|
|
973
|
+
/** Grid offset X */
|
|
974
|
+
offsetX?: number;
|
|
975
|
+
/** Grid offset Z */
|
|
976
|
+
offsetZ?: number;
|
|
977
|
+
/** Grid Y height (elevation) */
|
|
978
|
+
elevation?: number;
|
|
979
|
+
}
|
|
980
|
+
interface GridCoordinate {
|
|
981
|
+
x: number;
|
|
982
|
+
y: number;
|
|
983
|
+
z: number;
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Convert grid coordinates to world position
|
|
987
|
+
* @param gridX - Grid X coordinate
|
|
988
|
+
* @param gridZ - Grid Z coordinate
|
|
989
|
+
* @param config - Grid configuration
|
|
990
|
+
* @returns World position vector
|
|
991
|
+
*/
|
|
992
|
+
declare function gridToWorld(gridX: number, gridZ: number, config?: Grid3DConfig): THREE.Vector3;
|
|
993
|
+
/**
|
|
994
|
+
* Convert world position to grid coordinates
|
|
995
|
+
* @param worldX - World X position
|
|
996
|
+
* @param worldZ - World Z position
|
|
997
|
+
* @param config - Grid configuration
|
|
998
|
+
* @returns Grid coordinates
|
|
999
|
+
*/
|
|
1000
|
+
declare function worldToGrid(worldX: number, worldZ: number, config?: Grid3DConfig): {
|
|
1001
|
+
x: number;
|
|
1002
|
+
z: number;
|
|
1003
|
+
};
|
|
1004
|
+
/**
|
|
1005
|
+
* Raycast from camera through mouse position to find grid intersection
|
|
1006
|
+
* @param camera - Three.js camera
|
|
1007
|
+
* @param mouseX - Mouse X position (normalized -1 to 1)
|
|
1008
|
+
* @param mouseY - Mouse Y position (normalized -1 to 1)
|
|
1009
|
+
* @param planeY - Y height of the intersection plane (default: 0)
|
|
1010
|
+
* @returns Intersection point or null
|
|
1011
|
+
*/
|
|
1012
|
+
declare function raycastToPlane(camera: THREE.Camera, mouseX: number, mouseY: number, planeY?: number): THREE.Vector3 | null;
|
|
1013
|
+
/**
|
|
1014
|
+
* Raycast from camera through mouse position against a set of objects
|
|
1015
|
+
* @param camera - Three.js camera
|
|
1016
|
+
* @param mouseX - Mouse X position (normalized -1 to 1)
|
|
1017
|
+
* @param mouseY - Mouse Y position (normalized -1 to 1)
|
|
1018
|
+
* @param objects - Array of objects to test
|
|
1019
|
+
* @returns First intersection or null
|
|
1020
|
+
*/
|
|
1021
|
+
declare function raycastToObjects(camera: THREE.Camera, mouseX: number, mouseY: number, objects: THREE.Object3D[]): THREE.Intersection | null;
|
|
1022
|
+
/**
|
|
1023
|
+
* Calculate distance between two grid coordinates
|
|
1024
|
+
* @param a - First grid coordinate
|
|
1025
|
+
* @param b - Second grid coordinate
|
|
1026
|
+
* @returns Distance in grid units
|
|
1027
|
+
*/
|
|
1028
|
+
declare function gridDistance(a: {
|
|
1029
|
+
x: number;
|
|
1030
|
+
z: number;
|
|
1031
|
+
}, b: {
|
|
1032
|
+
x: number;
|
|
1033
|
+
z: number;
|
|
1034
|
+
}): number;
|
|
1035
|
+
/**
|
|
1036
|
+
* Calculate Manhattan distance between two grid coordinates
|
|
1037
|
+
* @param a - First grid coordinate
|
|
1038
|
+
* @param b - Second grid coordinate
|
|
1039
|
+
* @returns Manhattan distance
|
|
1040
|
+
*/
|
|
1041
|
+
declare function gridManhattanDistance(a: {
|
|
1042
|
+
x: number;
|
|
1043
|
+
z: number;
|
|
1044
|
+
}, b: {
|
|
1045
|
+
x: number;
|
|
1046
|
+
z: number;
|
|
1047
|
+
}): number;
|
|
1048
|
+
/**
|
|
1049
|
+
* Get neighboring grid cells
|
|
1050
|
+
* @param x - Center X coordinate
|
|
1051
|
+
* @param z - Center Z coordinate
|
|
1052
|
+
* @param includeDiagonal - Whether to include diagonal neighbors
|
|
1053
|
+
* @returns Array of neighbor coordinates
|
|
1054
|
+
*/
|
|
1055
|
+
declare function getNeighbors(x: number, z: number, includeDiagonal?: boolean): {
|
|
1056
|
+
x: number;
|
|
1057
|
+
z: number;
|
|
1058
|
+
}[];
|
|
1059
|
+
/**
|
|
1060
|
+
* Check if a grid coordinate is within bounds
|
|
1061
|
+
* @param x - X coordinate
|
|
1062
|
+
* @param z - Z coordinate
|
|
1063
|
+
* @param bounds - Bounds object
|
|
1064
|
+
* @returns Whether the coordinate is within bounds
|
|
1065
|
+
*/
|
|
1066
|
+
declare function isInBounds(x: number, z: number, bounds: {
|
|
1067
|
+
minX: number;
|
|
1068
|
+
maxX: number;
|
|
1069
|
+
minZ: number;
|
|
1070
|
+
maxZ: number;
|
|
1071
|
+
}): boolean;
|
|
1072
|
+
/**
|
|
1073
|
+
* Get all grid cells within a circular radius
|
|
1074
|
+
* @param centerX - Center X coordinate
|
|
1075
|
+
* @param centerZ - Center Z coordinate
|
|
1076
|
+
* @param radius - Radius in grid units
|
|
1077
|
+
* @returns Array of coordinates within radius
|
|
1078
|
+
*/
|
|
1079
|
+
declare function getCellsInRadius(centerX: number, centerZ: number, radius: number): {
|
|
1080
|
+
x: number;
|
|
1081
|
+
z: number;
|
|
1082
|
+
}[];
|
|
1083
|
+
/**
|
|
1084
|
+
* Create a highlight mesh for grid cells
|
|
1085
|
+
* @param color - Highlight color
|
|
1086
|
+
* @param opacity - Opacity (0-1)
|
|
1087
|
+
* @returns Mesh that can be positioned at grid cells
|
|
1088
|
+
*/
|
|
1089
|
+
declare function createGridHighlight(color?: number, opacity?: number): THREE.Mesh;
|
|
1090
|
+
/**
|
|
1091
|
+
* Normalize mouse coordinates to NDC (-1 to 1)
|
|
1092
|
+
* @param clientX - Mouse client X
|
|
1093
|
+
* @param clientY - Mouse client Y
|
|
1094
|
+
* @param element - Canvas element
|
|
1095
|
+
* @returns Normalized coordinates
|
|
1096
|
+
*/
|
|
1097
|
+
declare function normalizeMouseCoordinates(clientX: number, clientY: number, element: HTMLElement): {
|
|
1098
|
+
x: number;
|
|
1099
|
+
y: number;
|
|
1100
|
+
};
|
|
1101
|
+
|
|
1102
|
+
/**
|
|
1103
|
+
* Culling Utilities
|
|
1104
|
+
*
|
|
1105
|
+
* Frustum culling and LOD (Level of Detail) management for 3D scene optimization.
|
|
1106
|
+
*
|
|
1107
|
+
* @packageDocumentation
|
|
1108
|
+
*/
|
|
1109
|
+
|
|
1110
|
+
interface CullingOptions {
|
|
1111
|
+
/** Camera frustum for culling */
|
|
1112
|
+
camera: THREE.Camera;
|
|
1113
|
+
/** Optional padding around frustum */
|
|
1114
|
+
padding?: number;
|
|
1115
|
+
}
|
|
1116
|
+
interface LODLevel {
|
|
1117
|
+
/** Distance threshold for this LOD level */
|
|
1118
|
+
distance: number;
|
|
1119
|
+
/** Geometry or mesh for this level */
|
|
1120
|
+
geometry?: THREE.BufferGeometry;
|
|
1121
|
+
/** Scale multiplier for this level */
|
|
1122
|
+
scale?: number;
|
|
1123
|
+
/** Whether to use simplified material */
|
|
1124
|
+
simpleMaterial?: boolean;
|
|
1125
|
+
}
|
|
1126
|
+
interface LODConfig {
|
|
1127
|
+
/** LOD levels from closest to farthest */
|
|
1128
|
+
levels: LODLevel[];
|
|
1129
|
+
/** Transition smoothness (0-1) */
|
|
1130
|
+
transitionSmoothness?: number;
|
|
1131
|
+
}
|
|
1132
|
+
/**
|
|
1133
|
+
* Frustum culling check for a position
|
|
1134
|
+
* @param position - World position to check
|
|
1135
|
+
* @param camera - Camera to check against
|
|
1136
|
+
* @param padding - Optional padding in world units
|
|
1137
|
+
* @returns Whether the position is within the frustum
|
|
1138
|
+
*/
|
|
1139
|
+
declare function isInFrustum(position: THREE.Vector3, camera: THREE.Camera, padding?: number): boolean;
|
|
1140
|
+
/**
|
|
1141
|
+
* Filter an array of positions to only those within the frustum
|
|
1142
|
+
* @param positions - Array of world positions
|
|
1143
|
+
* @param camera - Camera to check against
|
|
1144
|
+
* @param padding - Optional padding in world units
|
|
1145
|
+
* @returns Array of positions within frustum
|
|
1146
|
+
*/
|
|
1147
|
+
declare function filterByFrustum(positions: THREE.Vector3[], camera: THREE.Camera, padding?: number): THREE.Vector3[];
|
|
1148
|
+
/**
|
|
1149
|
+
* Get indices of visible items from an array
|
|
1150
|
+
* @param positions - Array of world positions
|
|
1151
|
+
* @param camera - Camera to check against
|
|
1152
|
+
* @param padding - Optional padding in world units
|
|
1153
|
+
* @returns Set of visible indices
|
|
1154
|
+
*/
|
|
1155
|
+
declare function getVisibleIndices(positions: THREE.Vector3[], camera: THREE.Camera, padding?: number): Set<number>;
|
|
1156
|
+
/**
|
|
1157
|
+
* Calculate LOD level based on distance from camera
|
|
1158
|
+
* @param position - Object position
|
|
1159
|
+
* @param camera - Camera position
|
|
1160
|
+
* @param lodLevels - Array of distance thresholds (sorted closest to farthest)
|
|
1161
|
+
* @returns Index of the LOD level to use
|
|
1162
|
+
*/
|
|
1163
|
+
declare function calculateLODLevel(position: THREE.Vector3, camera: THREE.Camera, lodLevels: number[]): number;
|
|
1164
|
+
/**
|
|
1165
|
+
* Create a distance-based LOD system for an instanced mesh
|
|
1166
|
+
* @param instancedMesh - The instanced mesh to manage
|
|
1167
|
+
* @param positions - Array of instance positions
|
|
1168
|
+
* @param camera - Camera to calculate distances from
|
|
1169
|
+
* @param lodDistances - Distance thresholds for LOD levels
|
|
1170
|
+
* @returns Array of LOD indices for each instance
|
|
1171
|
+
*/
|
|
1172
|
+
declare function updateInstanceLOD(instancedMesh: THREE.InstancedMesh, positions: THREE.Vector3[], camera: THREE.Camera, lodDistances: number[]): Uint8Array;
|
|
1173
|
+
/**
|
|
1174
|
+
* Create visibility data for instanced mesh culling
|
|
1175
|
+
* Updates the instance matrix to hide/show instances
|
|
1176
|
+
* @param instancedMesh - The instanced mesh
|
|
1177
|
+
* @param positions - Array of instance positions
|
|
1178
|
+
* @param visibleIndices - Set of visible indices
|
|
1179
|
+
* @returns Updated count of visible instances
|
|
1180
|
+
*/
|
|
1181
|
+
declare function cullInstancedMesh(instancedMesh: THREE.InstancedMesh, positions: THREE.Vector3[], visibleIndices: Set<number>): number;
|
|
1182
|
+
/**
|
|
1183
|
+
* Spatial hash grid for efficient object queries
|
|
1184
|
+
*/
|
|
1185
|
+
declare class SpatialHashGrid {
|
|
1186
|
+
private cellSize;
|
|
1187
|
+
private cells;
|
|
1188
|
+
private objectPositions;
|
|
1189
|
+
constructor(cellSize?: number);
|
|
1190
|
+
/**
|
|
1191
|
+
* Get cell key for a position
|
|
1192
|
+
*/
|
|
1193
|
+
private getCellKey;
|
|
1194
|
+
/**
|
|
1195
|
+
* Insert an object into the grid
|
|
1196
|
+
*/
|
|
1197
|
+
insert(id: string, position: THREE.Vector3): void;
|
|
1198
|
+
/**
|
|
1199
|
+
* Remove an object from the grid
|
|
1200
|
+
*/
|
|
1201
|
+
remove(id: string): void;
|
|
1202
|
+
/**
|
|
1203
|
+
* Update an object's position
|
|
1204
|
+
*/
|
|
1205
|
+
update(id: string, newPosition: THREE.Vector3): void;
|
|
1206
|
+
/**
|
|
1207
|
+
* Query objects within a radius of a position
|
|
1208
|
+
*/
|
|
1209
|
+
queryRadius(center: THREE.Vector3, radius: number): string[];
|
|
1210
|
+
/**
|
|
1211
|
+
* Query objects within a bounding box
|
|
1212
|
+
*/
|
|
1213
|
+
queryBox(minX: number, maxX: number, minZ: number, maxZ: number): string[];
|
|
1214
|
+
/**
|
|
1215
|
+
* Clear all objects from the grid
|
|
1216
|
+
*/
|
|
1217
|
+
clear(): void;
|
|
1218
|
+
/**
|
|
1219
|
+
* Get statistics about the grid
|
|
1220
|
+
*/
|
|
1221
|
+
getStats(): {
|
|
1222
|
+
objects: number;
|
|
1223
|
+
cells: number;
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
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 };
|