@series-inc/rundot-3d-engine 0.3.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 (38) hide show
  1. package/LICENSE.txt +6 -0
  2. package/README.md +80 -0
  3. package/dist/ComponentRegistry-V_7WauAE.d.ts +448 -0
  4. package/dist/chunk-ZNDJR3RD.js +5623 -0
  5. package/dist/chunk-ZNDJR3RD.js.map +1 -0
  6. package/dist/index.d.ts +1484 -0
  7. package/dist/index.js +1390 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/systems/index.d.ts +3356 -0
  10. package/dist/systems/index.js +9652 -0
  11. package/dist/systems/index.js.map +1 -0
  12. package/docs/core/Component.md +321 -0
  13. package/docs/core/GameObject.md +204 -0
  14. package/docs/core/VenusGame.md +316 -0
  15. package/docs/patterns/ComponentCommunication.md +337 -0
  16. package/docs/patterns/CreatingGameObjects.md +290 -0
  17. package/docs/patterns/MeshColliders.md +338 -0
  18. package/docs/patterns/MeshLoading.md +316 -0
  19. package/docs/physics/Colliders.md +249 -0
  20. package/docs/physics/PhysicsSystem.md +151 -0
  21. package/docs/physics/RigidBodyComponent.md +201 -0
  22. package/docs/rendering/AssetManager.md +308 -0
  23. package/docs/rendering/InstancedRenderer.md +286 -0
  24. package/docs/rendering/MeshRenderer.md +286 -0
  25. package/docs/rendering/SkeletalRenderer.md +308 -0
  26. package/docs/systems/AnimationSystem.md +75 -0
  27. package/docs/systems/AudioSystem.md +79 -0
  28. package/docs/systems/InputManager.md +101 -0
  29. package/docs/systems/LightingSystem.md +101 -0
  30. package/docs/systems/NavigationSystem.md +246 -0
  31. package/docs/systems/ParticleSystem.md +44 -0
  32. package/docs/systems/PrefabSystem.md +60 -0
  33. package/docs/systems/SplineSystem.md +194 -0
  34. package/docs/systems/StowKitSystem.md +77 -0
  35. package/docs/systems/TweenSystem.md +132 -0
  36. package/docs/systems/UISystem.md +73 -0
  37. package/package.json +62 -0
  38. package/scripts/postinstall.mjs +51 -0
@@ -0,0 +1,3356 @@
1
+ import { b as PrefabComponentConstructor, c as PrefabJSON, P as PrefabNode, d as PrefabCollectionJSON, G as GameObject, C as Component, a as ComponentJSON, R as RigidBodyComponentThree, A as AnimationCullingManager } from '../ComponentRegistry-V_7WauAE.js';
2
+ export { f as ColliderShape, i as ComponentRegistry, j as PrefabComponentFactory, l as PrefabComponentJSON, k as PrefabMountJSON, m as PrefabNodeJSON, h as RigidBodyOptions, e as RigidBodyType, T as TransformComponentJSON, g as createCollisionGroup, n as isTransformComponent } from '../ComponentRegistry-V_7WauAE.js';
3
+ import * as THREE from 'three';
4
+ import { Vector3 } from 'three';
5
+ import { World, RigidBodyDesc, ColliderDesc, RigidBody, Collider } from '@dimforge/rapier3d';
6
+ import { StowKitPack } from '@stowkit/three-loader';
7
+
8
+ declare function PrefabComponent(typeName: string): <T extends PrefabComponentConstructor>(target: T) => T;
9
+
10
+ declare class Prefab {
11
+ static createFromJSON(json: PrefabJSON): Prefab;
12
+ private readonly _name;
13
+ private readonly _root;
14
+ private readonly _mounts;
15
+ constructor(name: string, root: PrefabNode, mounts: {
16
+ alias: string;
17
+ path: string;
18
+ }[]);
19
+ get name(): string;
20
+ get root(): PrefabNode;
21
+ get mounts(): ReadonlyArray<{
22
+ alias: string;
23
+ path: string;
24
+ }>;
25
+ getNodeByPath(path: string): PrefabNode | undefined;
26
+ }
27
+
28
+ declare class PrefabCollection {
29
+ static createFromJSON(json: PrefabCollectionJSON): PrefabCollection;
30
+ private readonly _prefabsByName;
31
+ constructor(prefabs: Iterable<Prefab>);
32
+ get prefabs(): IterableIterator<Prefab>;
33
+ getPrefabByName(name: string): Prefab | undefined;
34
+ getAllComponentTypes(): Set<string>;
35
+ /**
36
+ * Get all unique mounts from all prefabs in the collection.
37
+ * Mounts define StowKit pack aliases and CDN paths.
38
+ * @returns Array of mount points with alias and path
39
+ */
40
+ getMounts(): Array<{
41
+ alias: string;
42
+ path: string;
43
+ }>;
44
+ private traverseNodes;
45
+ }
46
+
47
+ /**
48
+ * Options for prefab instantiation
49
+ */
50
+ interface PrefabInstantiateOptions {
51
+ /** Whether meshes should cast shadows (default: true) */
52
+ castShadow?: boolean;
53
+ /** Whether meshes should receive shadows (default: true) */
54
+ receiveShadow?: boolean;
55
+ }
56
+ declare class PrefabInstance {
57
+ /**
58
+ * Current instantiation options - used by components during creation
59
+ * Components like MeshRenderer can read this to apply shadow settings
60
+ */
61
+ static currentOptions: PrefabInstantiateOptions | null;
62
+ static instantiate(prefabNode: PrefabNode, parent?: GameObject | null, options?: PrefabInstantiateOptions): PrefabInstance;
63
+ /**
64
+ * Apply shadow options to all meshes in the prefab tree.
65
+ * Call this after meshes have loaded if shadows aren't being applied correctly.
66
+ */
67
+ setShadows(castShadow: boolean, receiveShadow?: boolean): void;
68
+ private applyShadowOptions;
69
+ private static createComponent;
70
+ private readonly _prefabNode;
71
+ private readonly _gameObject;
72
+ private readonly _components;
73
+ private readonly _childrenByName;
74
+ private readonly _descendantsByPath;
75
+ constructor(prefabNode: PrefabNode, gameObject: GameObject, components: Component[], children: PrefabInstance[]);
76
+ get name(): string;
77
+ get gameObject(): GameObject;
78
+ get prefabNode(): PrefabNode;
79
+ get components(): ReadonlyArray<Component>;
80
+ get children(): ReadonlyArray<PrefabInstance>;
81
+ get descendants(): MapIterator<[string, PrefabInstance]>;
82
+ getComponent<T extends Component>(componentType: new (...args: unknown[]) => T): T | undefined;
83
+ getChildByName(name: string): PrefabInstance | undefined;
84
+ getDescendantByPath(path: string): PrefabInstance | undefined;
85
+ getDescendantByPathOrThrow(path: string): PrefabInstance;
86
+ dispose(): void;
87
+ }
88
+
89
+ declare class PrefabLoader {
90
+ static loadCollection(json: PrefabCollectionJSON): PrefabCollection;
91
+ static instantiate(prefabNode: PrefabNode, parent?: GameObject | null, options?: PrefabInstantiateOptions): PrefabInstance;
92
+ static instantiatePrefab(prefab: Prefab, parent?: GameObject | null, options?: PrefabInstantiateOptions): PrefabInstance;
93
+ static validateCollection(collection: PrefabCollection): string[];
94
+ static getRegisteredComponentTypes(): string[];
95
+ }
96
+
97
+ /**
98
+ * Three.js physics system using Rapier
99
+ * Much simpler than Babylon.js Havok integration
100
+ */
101
+ declare class PhysicsSystem {
102
+ private static world;
103
+ private static isInitialized;
104
+ private static rigidBodies;
105
+ private static colliders;
106
+ private static fixedTimeStep;
107
+ private static maxSubSteps;
108
+ private static accumulator;
109
+ private static alpha;
110
+ /**
111
+ * Configure physics stepping parameters at runtime
112
+ */
113
+ static configure(params?: {
114
+ fixedTimeStep?: number;
115
+ maxSubSteps?: number;
116
+ }): void;
117
+ /**
118
+ * Get interpolation alpha for rendering (accumulator / fixedTimeStep)
119
+ */
120
+ static getInterpolationAlpha(): number;
121
+ private static eventQueue;
122
+ private static colliderHandleToComponent;
123
+ private static colliderHandleToId;
124
+ private static colliderIdToGameObject;
125
+ private static debugEnabled;
126
+ private static debugScene;
127
+ private static debugMeshes;
128
+ private static debugMaterial;
129
+ /**
130
+ * Initialize Rapier physics world
131
+ */
132
+ static initialize(): Promise<void>;
133
+ /**
134
+ * Get the physics world
135
+ */
136
+ static getWorld(): World | null;
137
+ /**
138
+ * Check if physics is initialized
139
+ */
140
+ static isReady(): boolean;
141
+ /**
142
+ * Step the physics simulation
143
+ */
144
+ static step(deltaTime: number): void;
145
+ /**
146
+ * Create a rigid body
147
+ */
148
+ static createRigidBody(id: string, rigidBodyDesc: RigidBodyDesc, colliderDesc?: ColliderDesc): {
149
+ rigidBody: RigidBody;
150
+ collider?: Collider;
151
+ } | null;
152
+ /**
153
+ * Register a GameObject with its collider ID (called by RigidBodyComponentThree for all colliders)
154
+ */
155
+ static registerGameObject(colliderId: string, gameObject: any): void;
156
+ /**
157
+ * Unregister a GameObject from collider mapping
158
+ */
159
+ static unregisterGameObject(colliderId: string): void;
160
+ /**
161
+ * Register a component for trigger events
162
+ */
163
+ static registerTriggerComponent(colliderId: string, component: any): void;
164
+ /**
165
+ * Unregister a component from trigger events
166
+ */
167
+ static unregisterTriggerComponent(colliderId: string): void;
168
+ /**
169
+ * Process collision events from the event queue
170
+ */
171
+ private static processCollisionEvents;
172
+ /**
173
+ * Remove a rigid body
174
+ */
175
+ static removeRigidBody(id: string): void;
176
+ /**
177
+ * Get rigid body by ID
178
+ */
179
+ static getRigidBody(id: string): RigidBody | null;
180
+ /**
181
+ * Get collider by ID
182
+ */
183
+ static getCollider(id: string): Collider | null;
184
+ /**
185
+ * Sync Three.js object position with physics body
186
+ */
187
+ static syncObjectToPhysics(object: THREE.Object3D, rigidBody: RigidBody): void;
188
+ /**
189
+ * Sync physics body position to Three.js object
190
+ */
191
+ static syncPhysicsToObject(rigidBody: RigidBody, object: THREE.Object3D): void;
192
+ /**
193
+ * Create a ground plane
194
+ */
195
+ static createGround(size?: number): {
196
+ rigidBody: RigidBody;
197
+ collider: Collider;
198
+ } | null;
199
+ /**
200
+ * Create a box collider
201
+ */
202
+ static createBox(id: string, position: THREE.Vector3, size: THREE.Vector3, isDynamic?: boolean): {
203
+ rigidBody: RigidBody;
204
+ collider: Collider;
205
+ } | null;
206
+ /**
207
+ * Create a sphere collider
208
+ */
209
+ static createSphere(id: string, position: THREE.Vector3, radius: number, isDynamic?: boolean): {
210
+ rigidBody: RigidBody;
211
+ collider: Collider;
212
+ } | null;
213
+ /**
214
+ * Initialize debug visualization
215
+ */
216
+ static initializeDebug(scene: THREE.Scene): void;
217
+ /**
218
+ * Toggle physics debug visualization
219
+ */
220
+ static setDebugEnabled(enabled: boolean): void;
221
+ /**
222
+ * Get debug enabled state
223
+ */
224
+ static isDebugEnabled(): boolean;
225
+ /**
226
+ * Create debug mesh for a collider
227
+ */
228
+ private static createDebugMesh;
229
+ /**
230
+ * Add debug mesh for a physics body
231
+ */
232
+ private static addDebugMesh;
233
+ /**
234
+ * Remove debug mesh for a physics body
235
+ */
236
+ private static removeDebugMesh;
237
+ /**
238
+ * Show all debug meshes
239
+ */
240
+ private static showAllDebugMeshes;
241
+ /**
242
+ * Hide all debug meshes
243
+ */
244
+ private static hideAllDebugMeshes;
245
+ /**
246
+ * Update debug mesh positions to match physics bodies
247
+ */
248
+ static updateDebugMeshes(): void;
249
+ /**
250
+ * Dispose of physics system
251
+ */
252
+ static dispose(): void;
253
+ }
254
+
255
+ interface BoxComponentJSON extends ComponentJSON {
256
+ type: "box";
257
+ isCollider?: boolean;
258
+ size: number[];
259
+ offset: number[];
260
+ }
261
+ declare class BoxColliderComponent extends Component {
262
+ static fromPrefabJSON(json: BoxComponentJSON, _node: PrefabNode): BoxColliderComponent | null;
263
+ private rigidBody;
264
+ private readonly size;
265
+ private readonly offset;
266
+ constructor(size: THREE.Vector3, offset: THREE.Vector3);
267
+ protected onCreate(): void;
268
+ getRigidBody(): RigidBodyComponentThree | null;
269
+ }
270
+
271
+ interface MeshColliderJSON extends ComponentJSON {
272
+ type: "mesh_collider";
273
+ colliderType: "bounding_box";
274
+ }
275
+ declare class MeshColliderComponent extends Component {
276
+ static fromPrefabJSON(json: MeshColliderJSON, node: PrefabNode): MeshColliderComponent | null;
277
+ private rigidBody;
278
+ private readonly meshName;
279
+ constructor(meshName: string);
280
+ protected onCreate(): void;
281
+ getRigidBody(): RigidBodyComponentThree | null;
282
+ }
283
+
284
+ /**
285
+ * Debug utility for analyzing rendering performance and GPU instancing
286
+ * Contains all debugging functionality separate from core rendering classes
287
+ */
288
+ declare class RenderingDebugger {
289
+ /**
290
+ * Get comprehensive rendering statistics from AssetManager
291
+ */
292
+ static getRenderingStats(): any;
293
+ /**
294
+ * Print comprehensive rendering report
295
+ */
296
+ static printRenderingReport(): void;
297
+ /**
298
+ * Analyze what's causing high draw calls
299
+ */
300
+ static analyzeDrawCalls(): void;
301
+ /**
302
+ * Test frustum culling with current camera
303
+ */
304
+ static testFrustumCulling(): void;
305
+ /**
306
+ * Debug frustum culling for a specific asset type
307
+ * @param assetPath Asset to debug (e.g., 'tree.obj')
308
+ */
309
+ static debugFrustumCullingForAsset(assetPath: string): void;
310
+ /**
311
+ * Inspect scene objects to detect duplicate rendering
312
+ */
313
+ static inspectScene(): void;
314
+ /**
315
+ * Make all debug functions globally available
316
+ */
317
+ static makeGloballyAvailable(): void;
318
+ }
319
+
320
+ /**
321
+ * Debug option interface for tracking state
322
+ */
323
+ interface DebugOption {
324
+ label: string;
325
+ checked: boolean;
326
+ onChange: (checked: boolean) => void;
327
+ element?: HTMLElement;
328
+ }
329
+ /**
330
+ * Base Debug panel for Three.js applications
331
+ * Can be extended by specific game implementations to add custom debug options
332
+ */
333
+ declare class DebugPanelThree {
334
+ static alwaysHide: boolean;
335
+ protected container: HTMLElement;
336
+ protected contentContainer: HTMLElement;
337
+ protected options: DebugOption[];
338
+ protected isVisible: boolean;
339
+ protected contentsExpanded: boolean;
340
+ protected performanceStats: {
341
+ fps: number;
342
+ frameTime: number;
343
+ };
344
+ protected performanceElement?: HTMLElement;
345
+ protected playerPositionElement?: HTMLElement;
346
+ protected renderer?: any;
347
+ protected playerGameObject?: any;
348
+ constructor();
349
+ /**
350
+ * Set the Three.js renderer for draw call tracking
351
+ * Should be called by the game implementation
352
+ */
353
+ setRenderer(renderer: any): void;
354
+ /**
355
+ * Set the player GameObject for position tracking
356
+ * Should be called by the game implementation
357
+ */
358
+ setPlayerGameObject(playerGameObject: any): void;
359
+ /**
360
+ * Create the main debug panel HTML structure
361
+ */
362
+ protected createPanel(): void;
363
+ /**
364
+ * Add core debug options that all implementations should have
365
+ * Can be overridden by implementations to add custom options
366
+ */
367
+ protected addCoreOptions(): void;
368
+ /**
369
+ * Add common debug options that most Three.js games will need
370
+ * These have working implementations using dynamic imports
371
+ */
372
+ protected addCommonDebugOptions(): void;
373
+ /**
374
+ * Run scene analysis to find instancing opportunities
375
+ */
376
+ protected runSceneAnalysis(): void;
377
+ /**
378
+ * Run render cost analysis to identify bottlenecks
379
+ */
380
+ protected runRenderCostAnalysis(): void;
381
+ /**
382
+ * Get the scene from VenusGame
383
+ */
384
+ protected findScene(): THREE.Scene | null;
385
+ /**
386
+ * Bake duplicate meshes into InstancedMeshes for better performance.
387
+ * Finds meshes with the same geometry and replaces them with a single InstancedMesh.
388
+ */
389
+ protected bakeInstancing(): void;
390
+ /**
391
+ * Add a debug option to the panel
392
+ */
393
+ addOption(label: string, defaultValue: boolean, onChange: (checked: boolean) => void): void;
394
+ /**
395
+ * Add a numeric slider to the panel
396
+ */
397
+ addSlider(label: string, defaultValue: number, min: number, max: number, onChange: (value: number) => void): void;
398
+ /**
399
+ * Create performance stats display
400
+ */
401
+ protected createPerformanceDisplay(): void;
402
+ /**
403
+ * Create player position display
404
+ */
405
+ protected createPlayerPositionDisplay(): void;
406
+ /**
407
+ * Set up performance monitoring
408
+ */
409
+ protected setupPerformanceMonitoring(): void;
410
+ /**
411
+ * Update all performance metrics in the display
412
+ */
413
+ protected updatePerformanceDisplay(): void;
414
+ /**
415
+ * Update player position display
416
+ */
417
+ protected updatePlayerPositionDisplay(): void;
418
+ /**
419
+ * Set up keyboard toggle for debug panel
420
+ */
421
+ protected setupKeyboardToggle(): void;
422
+ /**
423
+ * Show the debug panel
424
+ */
425
+ show(): void;
426
+ /**
427
+ * Hide the debug panel
428
+ */
429
+ hide(): void;
430
+ /**
431
+ * Toggle the debug panel visibility
432
+ */
433
+ toggle(): void;
434
+ /**
435
+ * Get current visibility state
436
+ */
437
+ getVisibility(): boolean;
438
+ /**
439
+ * Dispose of the debug panel
440
+ */
441
+ dispose(): void;
442
+ }
443
+
444
+ /**
445
+ * Simple centralized input management system
446
+ * Just tracks key state - gameplay logic stays in components
447
+ */
448
+ declare enum InputAction {
449
+ MOVE_FORWARD = "move_forward",
450
+ MOVE_BACKWARD = "move_backward",
451
+ MOVE_LEFT = "move_left",
452
+ MOVE_RIGHT = "move_right",
453
+ RUN = "run"
454
+ }
455
+ /**
456
+ * Default key bindings - can be customized later
457
+ */
458
+ declare const DEFAULT_KEY_BINDINGS: Record<InputAction, string>;
459
+ /**
460
+ * Centralized Input Manager - Singleton
461
+ * Simple API for checking if keys/actions are currently pressed
462
+ */
463
+ declare class InputManager {
464
+ private static instance;
465
+ private activeKeys;
466
+ private keyBindings;
467
+ private isEnabled;
468
+ private boundKeyDown;
469
+ private boundKeyUp;
470
+ private boundWindowBlur;
471
+ private constructor();
472
+ /**
473
+ * Get singleton instance
474
+ */
475
+ static getInstance(): InputManager;
476
+ /**
477
+ * Initialize the input system (call this in VenusGame)
478
+ */
479
+ static initialize(): void;
480
+ /**
481
+ * Setup DOM event listeners
482
+ */
483
+ private setupEventListeners;
484
+ /**
485
+ * Handle key down events
486
+ */
487
+ private onKeyDown;
488
+ /**
489
+ * Handle key up events
490
+ */
491
+ private onKeyUp;
492
+ /**
493
+ * Handle window blur to prevent stuck keys
494
+ */
495
+ private onWindowBlur;
496
+ /**
497
+ * Check if a specific action is currently pressed
498
+ */
499
+ isActionPressed(action: InputAction): boolean;
500
+ /**
501
+ * Check if a specific key code is currently pressed
502
+ */
503
+ isKeyPressed(keyCode: string): boolean;
504
+ /**
505
+ * Enable/disable input processing
506
+ */
507
+ setEnabled(enabled: boolean): void;
508
+ /**
509
+ * Update key binding for an action
510
+ */
511
+ setKeyBinding(action: InputAction, keyCode: string): void;
512
+ /**
513
+ * Check if a key code is used by the game (for preventDefault)
514
+ */
515
+ private isGameKey;
516
+ /**
517
+ * Get all currently active keys (for debugging)
518
+ */
519
+ getActiveKeys(): string[];
520
+ /**
521
+ * Cleanup - remove event listeners
522
+ */
523
+ dispose(): void;
524
+ }
525
+ declare const Input: {
526
+ isPressed: (action: InputAction) => boolean;
527
+ isKeyPressed: (keyCode: string) => boolean;
528
+ setEnabled: (enabled: boolean) => void;
529
+ };
530
+
531
+ /**
532
+ * Simple Three.js directional light component
533
+ * No complex shadow management - just Three.js native properties
534
+ */
535
+ declare class DirectionalLightComponent extends Component {
536
+ private light;
537
+ constructor(options?: {
538
+ color?: THREE.ColorRepresentation;
539
+ intensity?: number;
540
+ castShadow?: boolean;
541
+ shadowMapSize?: number;
542
+ shadowCamera?: {
543
+ left?: number;
544
+ right?: number;
545
+ top?: number;
546
+ bottom?: number;
547
+ near?: number;
548
+ far?: number;
549
+ };
550
+ });
551
+ protected onCreate(): void;
552
+ protected onCleanup(): void;
553
+ /**
554
+ * Get the Three.js light for direct access
555
+ */
556
+ getLight(): THREE.DirectionalLight;
557
+ /**
558
+ * Set light position
559
+ */
560
+ setPosition(x: number, y: number, z: number): void;
561
+ /**
562
+ * Set light target position
563
+ */
564
+ setTarget(x: number, y: number, z: number): void;
565
+ /**
566
+ * Set light intensity
567
+ */
568
+ setIntensity(intensity: number): void;
569
+ /**
570
+ * Set light color
571
+ */
572
+ setColor(color: THREE.ColorRepresentation): void;
573
+ /**
574
+ * Enable/disable shadow casting
575
+ */
576
+ setCastShadow(enabled: boolean): void;
577
+ }
578
+
579
+ /**
580
+ * Enhanced Three.js ambient light component that mimics Babylon.js HemisphericLight
581
+ * Provides directional ambient lighting with ground color support
582
+ */
583
+ declare class AmbientLightComponent extends Component {
584
+ private ambientLight;
585
+ private hemisphereLight;
586
+ private useHemispheric;
587
+ constructor(options?: {
588
+ color?: THREE.ColorRepresentation;
589
+ intensity?: number;
590
+ groundColor?: THREE.ColorRepresentation;
591
+ direction?: THREE.Vector3;
592
+ });
593
+ protected onCreate(): void;
594
+ protected onCleanup(): void;
595
+ /**
596
+ * Get the Three.js light for direct access
597
+ */
598
+ getLight(): THREE.Light;
599
+ /**
600
+ * Set light intensity
601
+ */
602
+ setIntensity(intensity: number): void;
603
+ /**
604
+ * Set sky color (main color)
605
+ */
606
+ setColor(color: THREE.ColorRepresentation): void;
607
+ /**
608
+ * Set ground color (only works with hemispheric lighting)
609
+ */
610
+ setGroundColor(color: THREE.ColorRepresentation): void;
611
+ }
612
+
613
+ /**
614
+ * Simple Three.js material utilities
615
+ * Provides common material patterns without complex abstractions
616
+ */
617
+ declare class MaterialUtils {
618
+ static readonly DEFAULT_TOON_GRADIENT_PATH = "assets/cozy_game_general/threeTone.jpg";
619
+ private static textureLoader;
620
+ private static cachedGradientMap;
621
+ /**
622
+ * Create a standard PBR material with common settings
623
+ */
624
+ static createStandardMaterial(options?: {
625
+ color?: THREE.ColorRepresentation;
626
+ map?: THREE.Texture;
627
+ mapPath?: string;
628
+ roughness?: number;
629
+ metalness?: number;
630
+ normalMap?: THREE.Texture;
631
+ normalMapPath?: string;
632
+ transparent?: boolean;
633
+ opacity?: number;
634
+ }): THREE.MeshStandardMaterial;
635
+ /**
636
+ * Create a basic material with a color
637
+ */
638
+ static createBasicMaterial(color: THREE.ColorRepresentation): THREE.MeshBasicMaterial;
639
+ /**
640
+ * Create a Lambert material (good for low-poly/stylized looks)
641
+ */
642
+ static createLambertMaterial(options?: {
643
+ color?: THREE.ColorRepresentation;
644
+ map?: THREE.Texture;
645
+ }): THREE.MeshLambertMaterial;
646
+ /**
647
+ * Create a material with texture
648
+ */
649
+ static createTexturedMaterial(textureUrl: string, options?: {
650
+ color?: THREE.ColorRepresentation;
651
+ roughness?: number;
652
+ metalness?: number;
653
+ }): THREE.MeshStandardMaterial;
654
+ /**
655
+ * Create a simple shared material for prototyping
656
+ */
657
+ static createSharedMaterial(color?: THREE.ColorRepresentation): THREE.MeshStandardMaterial;
658
+ /**
659
+ * Get or load the toon gradient map (ramp) texture.
660
+ * The texture is cached after first load. Uses nearest filtering and disables mipmaps
661
+ * to preserve crisp banding of the ramp.
662
+ */
663
+ static getToonGradientMap(gradientPath?: string): THREE.Texture;
664
+ /**
665
+ * Create a MeshToonMaterial with optional albedo map and the shared gradient ramp.
666
+ */
667
+ static createToonMaterial(options?: {
668
+ color?: THREE.ColorRepresentation;
669
+ map?: THREE.Texture;
670
+ mapPath?: string;
671
+ transparent?: boolean;
672
+ opacity?: number;
673
+ gradientPath?: string;
674
+ emissive?: THREE.ColorRepresentation;
675
+ }): THREE.MeshToonMaterial;
676
+ /**
677
+ * Convert an arbitrary THREE.Material into a MeshToonMaterial while
678
+ * preserving common properties like color, map and transparency.
679
+ */
680
+ static convertToToon(material: THREE.Material, gradientPath?: string): THREE.MeshToonMaterial;
681
+ }
682
+
683
+ /**
684
+ * Math utilities for game development
685
+ */
686
+ declare class MathUtil {
687
+ /**
688
+ * Linear interpolation - exponential approach, never quite reaches target
689
+ * @param current Current value
690
+ * @param target Target value
691
+ * @param factor Interpolation factor (0-1)
692
+ * @returns Interpolated value
693
+ */
694
+ static lerp(current: number, target: number, factor: number): number;
695
+ /**
696
+ * Move towards - linear approach with max speed, reaches target exactly
697
+ * @param current Current value
698
+ * @param target Target value
699
+ * @param maxDelta Maximum change per call
700
+ * @returns New value moved towards target
701
+ */
702
+ static moveTowards(current: number, target: number, maxDelta: number): number;
703
+ /**
704
+ * Clamp a value between min and max
705
+ * @param value Value to clamp
706
+ * @param min Minimum value
707
+ * @param max Maximum value
708
+ * @returns Clamped value
709
+ */
710
+ static clamp(value: number, min: number, max: number): number;
711
+ /**
712
+ * Check if two values are approximately equal
713
+ * @param a First value
714
+ * @param b Second value
715
+ * @param epsilon Tolerance (default: 0.001)
716
+ * @returns True if values are approximately equal
717
+ */
718
+ static approximately(a: number, b: number, epsilon?: number): boolean;
719
+ }
720
+
721
+ /**
722
+ * Easing functions for smooth animations
723
+ */
724
+ declare class Easing {
725
+ static linear(t: number): number;
726
+ static easeInQuad(t: number): number;
727
+ static easeOutQuad(t: number): number;
728
+ static easeInOutQuad(t: number): number;
729
+ static easeInCubic(t: number): number;
730
+ static easeOutCubic(t: number): number;
731
+ static easeInOutCubic(t: number): number;
732
+ static spring(t: number, damping?: number, stiffness?: number): number;
733
+ static easeOutElastic(t: number): number;
734
+ static easeInBack(t: number, s?: number): number;
735
+ static easeOutBack(t: number, s?: number): number;
736
+ static anticipateOvershoot(t: number, s?: number): number;
737
+ }
738
+ /**
739
+ * Individual tween instance
740
+ */
741
+ declare class Tween {
742
+ private target;
743
+ private property;
744
+ private startValue;
745
+ private endValue;
746
+ private duration;
747
+ private elapsed;
748
+ private easingFunction;
749
+ private onComplete?;
750
+ private onUpdate?;
751
+ private active;
752
+ constructor(target: any, property: string, endValue: number, duration: number, easingFunction?: (t: number) => number);
753
+ /**
754
+ * Set completion callback
755
+ */
756
+ onCompleted(callback: () => void): Tween;
757
+ /**
758
+ * Set update callback
759
+ */
760
+ onUpdated(callback: (value: number) => void): Tween;
761
+ /**
762
+ * Update the tween (optimized for performance)
763
+ */
764
+ update(deltaTime: number): boolean;
765
+ /**
766
+ * Stop the tween
767
+ */
768
+ stop(): void;
769
+ /**
770
+ * Check if tween is active
771
+ */
772
+ isActive(): boolean;
773
+ }
774
+ /**
775
+ * Global tween manager with performance optimizations
776
+ */
777
+ declare class TweenSystem {
778
+ private static tweens;
779
+ private static pendingTweens;
780
+ static debugLogging: boolean;
781
+ private static lastActiveFrame;
782
+ private static frameCount;
783
+ /**
784
+ * Create and register a new tween
785
+ */
786
+ static tween(target: any, property: string, endValue: number, duration: number, easingFunction?: (t: number) => number): Tween;
787
+ /**
788
+ * Update all active tweens (optimized to skip when empty)
789
+ */
790
+ static update(deltaTime: number): void;
791
+ /**
792
+ * Stop all tweens
793
+ */
794
+ static stopAll(): void;
795
+ /**
796
+ * Get number of active tweens
797
+ */
798
+ static getActiveCount(): number;
799
+ /**
800
+ * Check if the tween system is currently active
801
+ */
802
+ static isActive(): boolean;
803
+ /**
804
+ * Get performance stats for debugging
805
+ */
806
+ static getStats(): {
807
+ active: number;
808
+ pending: number;
809
+ lastActiveFrame: number;
810
+ currentFrame: number;
811
+ };
812
+ }
813
+
814
+ /**
815
+ * Second-order dynamics system for smooth, physics-based animation
816
+ * Based on the critically damped harmonic oscillator
817
+ * Perfect for springy, responsive animations that react to input changes
818
+ */
819
+ declare class SecondOrderDynamics {
820
+ private k1;
821
+ private k2;
822
+ private k3;
823
+ private xp;
824
+ private y;
825
+ private yd;
826
+ /**
827
+ * Create a second-order dynamics system
828
+ * @param f - Frequency (speed of response) - higher = faster response
829
+ * @param z - Damping coefficient - 0 = no damping (oscillates forever), 1 = critically damped, >1 = overdamped
830
+ * @param r - Initial response factor - affects initial "kick" of the animation
831
+ * @param initialValue - Starting position
832
+ */
833
+ constructor(f: number, z: number, r: number, initialValue?: THREE.Vector3);
834
+ /**
835
+ * Update the system with a new target position
836
+ * @param x - Target position
837
+ * @param deltaTime - Time step
838
+ * @returns Current smoothed position
839
+ */
840
+ update(x: THREE.Vector3, deltaTime: number): THREE.Vector3;
841
+ /**
842
+ * Get current position without updating
843
+ */
844
+ getCurrentPosition(): THREE.Vector3;
845
+ /**
846
+ * Get current velocity
847
+ */
848
+ getCurrentVelocity(): THREE.Vector3;
849
+ /**
850
+ * Reset the system to a new position
851
+ */
852
+ reset(position: THREE.Vector3): void;
853
+ }
854
+ /**
855
+ * Simplified 1D version for scalar values
856
+ */
857
+ declare class SecondOrderDynamics1D {
858
+ private k1;
859
+ private k2;
860
+ private k3;
861
+ private xp;
862
+ private y;
863
+ private yd;
864
+ constructor(f: number, z: number, r: number, initialValue?: number);
865
+ update(x: number, deltaTime: number): number;
866
+ getCurrentValue(): number;
867
+ getCurrentVelocity(): number;
868
+ reset(value: number): void;
869
+ }
870
+
871
+ interface Footprint {
872
+ type: "polygon" | "circle";
873
+ vertices?: Vector3[];
874
+ x?: number;
875
+ z?: number;
876
+ radius?: number;
877
+ }
878
+ interface AABB {
879
+ minX: number;
880
+ minZ: number;
881
+ maxX: number;
882
+ maxZ: number;
883
+ }
884
+ /**
885
+ * A fast 2D navigation grid using reference counting for obstacle management
886
+ * OPTIMIZED for high-performance incremental add/remove operations
887
+ */
888
+ declare class NavigationGrid {
889
+ private grid;
890
+ private worldWidth;
891
+ private worldDepth;
892
+ private gridSize;
893
+ private cols;
894
+ private rows;
895
+ private halfWorldWidth;
896
+ private halfWorldDepth;
897
+ private halfGridSize;
898
+ private gridSizeInv;
899
+ private static DEBUG_MODE;
900
+ constructor(worldWidth: number, worldDepth: number, gridSize: number);
901
+ /**
902
+ * OPTIMIZED: Converts world X, Z coordinates to grid column, row
903
+ * Uses pre-calculated values for maximum performance
904
+ */
905
+ worldToGrid(x: number, z: number): {
906
+ col: number;
907
+ row: number;
908
+ };
909
+ /**
910
+ * Converts grid column, row to world X, Z center coordinates
911
+ * Uses centered coordinate system where (0,0) world = center of grid
912
+ */
913
+ gridToWorld(col: number, row: number): {
914
+ x: number;
915
+ z: number;
916
+ };
917
+ /**
918
+ * Point-in-Polygon test using ray casting algorithm for 2D XZ plane
919
+ */
920
+ private isPointInPolygon;
921
+ /**
922
+ * Point-in-Circle test for 2D XZ plane
923
+ */
924
+ private isPointInCircle;
925
+ /**
926
+ * Check if a polygon intersects with a grid cell (not just contains the center)
927
+ * This is crucial for thin obstacles like walls that might span multiple cells
928
+ * but not contain the cell centers
929
+ */
930
+ private doesPolygonIntersectCell;
931
+ /**
932
+ * Check if two line segments intersect
933
+ */
934
+ private doLineSegmentsIntersect;
935
+ /**
936
+ * Calculate the direction/orientation of three points
937
+ */
938
+ private direction;
939
+ /**
940
+ * Check if point p lies on line segment ab
941
+ */
942
+ private onSegment;
943
+ /**
944
+ * OPTIMIZED: Fast polygon-cell intersection using simplified approach
945
+ * Much faster than full line-segment intersection for reference counting
946
+ */
947
+ private fastPolygonIntersectCell;
948
+ /**
949
+ * OPTIMIZED: Calculate AABB with minimal overhead
950
+ */
951
+ private calculateAABB;
952
+ /**
953
+ * OPTIMIZED: Add obstacle with maximum performance - INCREMENTAL reference counting only
954
+ * Only touches cells affected by THIS obstacle - no global rebaking
955
+ */
956
+ addObstacle(footprint: Footprint): void;
957
+ /**
958
+ * OPTIMIZED: Remove obstacle with maximum performance - INCREMENTAL reference counting only
959
+ * Only touches cells affected by THIS obstacle - no global rebaking
960
+ */
961
+ removeObstacle(footprint: Footprint): void;
962
+ /**
963
+ * Check if a grid cell is walkable (reference count is zero)
964
+ */
965
+ isWalkable(col: number, row: number): boolean;
966
+ /**
967
+ * Get grid dimensions
968
+ */
969
+ getDimensions(): {
970
+ cols: number;
971
+ rows: number;
972
+ worldWidth: number;
973
+ worldDepth: number;
974
+ gridSize: number;
975
+ };
976
+ /**
977
+ * Debug helper to print the grid state
978
+ */
979
+ printGrid(): void;
980
+ /**
981
+ * Get the raw grid data (for debugging or visualization)
982
+ */
983
+ getGridData(): number[][];
984
+ /**
985
+ * Enable/disable debug logging for performance tuning
986
+ * Set to false for production performance
987
+ */
988
+ static setDebugMode(enabled: boolean): void;
989
+ /**
990
+ * Get current debug mode status
991
+ */
992
+ static isDebugMode(): boolean;
993
+ }
994
+
995
+ interface Waypoint {
996
+ x: number;
997
+ z: number;
998
+ }
999
+ interface PathfindingResult {
1000
+ success: boolean;
1001
+ waypoints: Waypoint[];
1002
+ distance: number;
1003
+ }
1004
+ /**
1005
+ * Three.js version of DynamicNavSystem
1006
+ * Uses Three.js Vector2/Vector3 instead of Babylon.js types
1007
+ * Clean static API with no scene dependency needed
1008
+ */
1009
+ declare class DynamicNavSystem {
1010
+ private static navigationGrid;
1011
+ private static scene;
1012
+ private static isInitialized;
1013
+ private static obstacleRegistry;
1014
+ /**
1015
+ * Initialize the navigation system (must be called before use)
1016
+ * Scene parameter is optional - only needed for debug visualization
1017
+ */
1018
+ static initialize(scene?: THREE.Scene, worldWidth?: number, worldDepth?: number, gridSize?: number): void;
1019
+ /**
1020
+ * Check if the system is initialized
1021
+ */
1022
+ static getIsInitialized(): boolean;
1023
+ /**
1024
+ * Dispose of the navigation system
1025
+ */
1026
+ static dispose(): void;
1027
+ /**
1028
+ * Add an obstacle to the navigation grid
1029
+ */
1030
+ static addObstacle(footprint: Footprint): void;
1031
+ /**
1032
+ * Remove an obstacle from the navigation grid
1033
+ */
1034
+ static removeObstacle(footprint: Footprint): void;
1035
+ /**
1036
+ * Check if a position is walkable
1037
+ */
1038
+ static isWalkable(x: number, z: number): boolean;
1039
+ /**
1040
+ * Convert world coordinates to grid coordinates
1041
+ */
1042
+ static worldToGrid(x: number, z: number): {
1043
+ col: number;
1044
+ row: number;
1045
+ } | null;
1046
+ /**
1047
+ * Convert grid coordinates to world coordinates
1048
+ */
1049
+ static gridToWorld(col: number, row: number): {
1050
+ x: number;
1051
+ z: number;
1052
+ } | null;
1053
+ /**
1054
+ * Debug method to print current navigation state
1055
+ */
1056
+ static debugNavigation(): void;
1057
+ /**
1058
+ * Add a box obstacle to the navigation grid
1059
+ * @param x World X position (center)
1060
+ * @param z World Z position (center)
1061
+ * @param width Width of the obstacle
1062
+ * @param depth Depth of the obstacle
1063
+ */
1064
+ static addBoxObstacle(x: number, z: number, width: number, depth: number): void;
1065
+ /**
1066
+ * Remove a box obstacle from the navigation grid
1067
+ * @param x World X position (center)
1068
+ * @param z World Z position (center)
1069
+ * @param width Width of the obstacle
1070
+ * @param depth Depth of the obstacle
1071
+ */
1072
+ static removeBoxObstacle(x: number, z: number, width: number, depth: number): void;
1073
+ static addBoxObstacleFromRigidBody(gameObject: GameObject): void;
1074
+ /**
1075
+ * Add a box obstacle from a GameObject and its bounds size
1076
+ * @param gameObject The GameObject to get world position from
1077
+ * @param boundsSize The size from renderer bounds (uses X and Z for navigation)
1078
+ */
1079
+ static addBoxObstacleFromBounds(gameObject: GameObject, boundsSize: THREE.Vector3): void;
1080
+ /**
1081
+ * Add a rotated box obstacle from bounds and track it by GameObject ID
1082
+ * @param gameObject The GameObject to get world transform from
1083
+ * @param boundsSize The size from bounds (uses X and Z for navigation)
1084
+ * @returns The ID used to track this obstacle (GameObject UUID)
1085
+ */
1086
+ static addRotatedBoxObstacle(gameObject: GameObject, boundsSize: THREE.Vector3): string;
1087
+ /**
1088
+ * Remove an obstacle by GameObject ID
1089
+ * @param id The ID returned from addRotatedBoxObstacle (GameObject UUID)
1090
+ * @returns true if obstacle was found and removed
1091
+ */
1092
+ static removeObstacleById(id: string): boolean;
1093
+ /**
1094
+ * Remove an obstacle by GameObject
1095
+ * @param gameObject The GameObject whose obstacle should be removed
1096
+ * @returns true if obstacle was found and removed
1097
+ */
1098
+ static removeObstacleByGameObject(gameObject: GameObject): boolean;
1099
+ /**
1100
+ * Find a path from start position to end position using A* pathfinding
1101
+ * @param startPos Start position as THREE.Vector2 (x, z)
1102
+ * @param endPos End position as THREE.Vector2 (x, z)
1103
+ */
1104
+ static findPath(startPos: THREE.Vector2, endPos: THREE.Vector2): PathfindingResult;
1105
+ /**
1106
+ * Find a path from start position to end position using A* pathfinding
1107
+ * @param startPos Start position as THREE.Vector3 (uses x, z components)
1108
+ * @param endPos End position as THREE.Vector3 (uses x, z components)
1109
+ */
1110
+ static findPath(startPos: THREE.Vector3, endPos: THREE.Vector3): PathfindingResult;
1111
+ /**
1112
+ * Find the closest walkable cell to a given position
1113
+ */
1114
+ private static findClosestWalkableCell;
1115
+ /**
1116
+ * A* pathfinding algorithm implementation
1117
+ * Returns array of grid nodes representing the path
1118
+ */
1119
+ private static findPathAStar;
1120
+ /**
1121
+ * Reconstruct path from the end node back to start
1122
+ */
1123
+ private static reconstructPath;
1124
+ /**
1125
+ * Calculate distance between two grid positions (Manhattan distance with diagonal support)
1126
+ */
1127
+ private static getDistance;
1128
+ /**
1129
+ * Simplify path by removing unnecessary waypoints using line-of-sight optimization
1130
+ */
1131
+ private static simplifyPath;
1132
+ /**
1133
+ * Check if there's a clear line of sight between two waypoints
1134
+ */
1135
+ private static hasLineOfSight;
1136
+ /**
1137
+ * Calculate total distance of a path (like Babylon.js version)
1138
+ */
1139
+ private static calculatePathDistance;
1140
+ /**
1141
+ * Check if a path exists between two positions (faster than full pathfinding)
1142
+ */
1143
+ static canReach(startX: number, startZ: number, endX: number, endZ: number): boolean;
1144
+ }
1145
+
1146
+ /**
1147
+ * Three.js version of NavAgent
1148
+ * Transform-based navigation agent for AI entities
1149
+ * Moves the gameObject position directly without physics for smooth movement
1150
+ * Uses waypoint-based pathfinding for all movement
1151
+ * Perfect for entities that don't need collision detection (like customers)
1152
+ *
1153
+ * Handles pathfinding and visualization automatically!
1154
+ */
1155
+ declare class NavAgent extends Component {
1156
+ moveSpeed: number;
1157
+ acceleration: number;
1158
+ deceleration: number;
1159
+ arrivalDistance: number;
1160
+ angularAcceleration: number;
1161
+ private waypoints;
1162
+ private currentWaypointIndex;
1163
+ private currentVelocity;
1164
+ private maxSpeed;
1165
+ private currentTarget;
1166
+ private isMoving;
1167
+ private pathVisualizationId;
1168
+ private isVisualizationEnabled;
1169
+ constructor();
1170
+ /**
1171
+ * Move to a target position using pathfinding
1172
+ * Handles pathfinding and visualization automatically
1173
+ * Returns true if pathfinding succeeded, false otherwise
1174
+ */
1175
+ moveTo(targetPosition: THREE.Vector3 | THREE.Vector2): boolean;
1176
+ /**
1177
+ * Check if the agent has reached its target (matches Babylon.js NavAgent exactly)
1178
+ */
1179
+ hasReachedTarget(): boolean;
1180
+ /**
1181
+ * Check if the agent is currently in motion
1182
+ * Returns true if the agent has a target or is still moving (velocity > threshold)
1183
+ */
1184
+ isInMotion(): boolean;
1185
+ /**
1186
+ * Get the current movement speed as a normalized value (0-1)
1187
+ * 0 = stopped, 1 = moving at max speed
1188
+ * Useful for animation blending
1189
+ */
1190
+ getMovementSpeedNormalized(): number;
1191
+ /**
1192
+ * Get the current movement speed (units per second)
1193
+ */
1194
+ getMovementSpeed(): number;
1195
+ /**
1196
+ * Enable or disable path visualization
1197
+ */
1198
+ setVisualizationEnabled(enabled: boolean): void;
1199
+ /**
1200
+ * Get current movement speed
1201
+ */
1202
+ getCurrentSpeed(): number;
1203
+ /**
1204
+ * Get current waypoints
1205
+ */
1206
+ getWaypoints(): THREE.Vector3[];
1207
+ /**
1208
+ * Stop current movement (matches Babylon.js NavAgent)
1209
+ */
1210
+ stop(): void;
1211
+ /**
1212
+ * Set path from pathfinding result (used internally by moveTo)
1213
+ */
1214
+ private setPath;
1215
+ /**
1216
+ * Set waypoints to follow (used internally)
1217
+ */
1218
+ private setWaypoints;
1219
+ /**
1220
+ * Clear the current target (stops movement) - matches Babylon.js NavAgent exactly
1221
+ */
1222
+ private clearTarget;
1223
+ /**
1224
+ * Clear path visualization
1225
+ */
1226
+ private clearVisualization;
1227
+ /**
1228
+ * Update movement along waypoints (called automatically by component system)
1229
+ */
1230
+ update(deltaTime: number): void;
1231
+ /**
1232
+ * Handle stopping when path is complete
1233
+ * Returns true if path is complete
1234
+ */
1235
+ private handlePathComplete;
1236
+ /**
1237
+ * Check if current waypoint is reached and advance if so
1238
+ */
1239
+ private checkWaypointReached;
1240
+ /**
1241
+ * Move toward a specific position with smooth acceleration/deceleration
1242
+ */
1243
+ private moveTowardPosition;
1244
+ /**
1245
+ * Apply the current velocity to the gameObject position
1246
+ */
1247
+ private applyMovement;
1248
+ /**
1249
+ * Rotate towards movement direction
1250
+ */
1251
+ private rotateTowardsDirection;
1252
+ }
1253
+
1254
+ /**
1255
+ * Three.js visualization system for pathfinding results
1256
+ * Shows waypoints as spheres and paths as lines for debugging
1257
+ */
1258
+ declare class PathVisualizationThree {
1259
+ private static scene;
1260
+ private static isInitialized;
1261
+ private static visualizationEnabled;
1262
+ private static pathMaterial;
1263
+ private static waypointMaterial;
1264
+ private static startMaterial;
1265
+ private static endMaterial;
1266
+ private static pathVisualizations;
1267
+ private static currentPath;
1268
+ /**
1269
+ * Initialize the path visualization system
1270
+ */
1271
+ static initialize(scene: THREE.Scene): void;
1272
+ /**
1273
+ * Create materials for different visual elements
1274
+ */
1275
+ private static createMaterials;
1276
+ /**
1277
+ * Enable or disable path visualization globally
1278
+ */
1279
+ static setVisualizationEnabled(enabled: boolean): void;
1280
+ /**
1281
+ * Check if path visualization is globally enabled
1282
+ */
1283
+ static isVisualizationEnabled(): boolean;
1284
+ /**
1285
+ * Add a path visualization with optional ID for later removal
1286
+ */
1287
+ static addPath(pathId: string, result: PathfindingResult, startX?: number, startZ?: number, endX?: number, endZ?: number): boolean;
1288
+ /**
1289
+ * Add a path visualization (simplified API - infers start/end from waypoints)
1290
+ */
1291
+ static addPathSimple(pathId: string, result: PathfindingResult): boolean;
1292
+ /**
1293
+ * Remove a specific path visualization by ID
1294
+ */
1295
+ static removePath(pathId: string): boolean;
1296
+ /**
1297
+ * Visualize a pathfinding result (legacy method - uses default ID)
1298
+ */
1299
+ static visualizePath(result: PathfindingResult, startX?: number, startZ?: number, endX?: number, endZ?: number): void;
1300
+ /**
1301
+ * Create visual marker for start position
1302
+ */
1303
+ private static createStartMarker;
1304
+ /**
1305
+ * Create visual marker for end position
1306
+ */
1307
+ private static createEndMarker;
1308
+ /**
1309
+ * Create spheres to mark waypoints along the path
1310
+ */
1311
+ private static createWaypointSpheres;
1312
+ /**
1313
+ * Create lines connecting waypoints to show the path
1314
+ */
1315
+ private static createPathLines;
1316
+ /**
1317
+ * Clear all path visualizations
1318
+ */
1319
+ static clearVisualization(): void;
1320
+ /**
1321
+ * Get list of active path IDs
1322
+ */
1323
+ static getActivePathIds(): string[];
1324
+ /**
1325
+ * Check if any path is currently being visualized
1326
+ */
1327
+ static hasActiveVisualization(): boolean;
1328
+ /**
1329
+ * Get current path result (legacy support)
1330
+ */
1331
+ static getCurrentPath(): PathfindingResult | null;
1332
+ /**
1333
+ * Console helper function for manual testing
1334
+ */
1335
+ static testPath(startX: number, startZ: number, endX: number, endZ: number): void;
1336
+ /**
1337
+ * Dispose of the path visualization system
1338
+ */
1339
+ static dispose(): void;
1340
+ }
1341
+ declare global {
1342
+ interface Window {
1343
+ testPathThree: (startX: number, startZ: number, endX: number, endZ: number) => void;
1344
+ clearPathThree: () => void;
1345
+ addPathThree: (pathId: string, startX: number, startZ: number, endX: number, endZ: number) => void;
1346
+ removePathThree: (pathId: string) => void;
1347
+ listPathsThree: () => void;
1348
+ }
1349
+ }
1350
+
1351
+ /**
1352
+ * HTML/CSS-based UI system for Three.js
1353
+ * Provides overlay elements for HUD, interaction prompts, menus, and dialogs
1354
+ * Uses modern CSS and HTML instead of canvas-based UI
1355
+ *
1356
+ * The system uses two separate containers:
1357
+ * - Main container: For HUD, menus, etc. Respects safe area insets
1358
+ * - World container: For world-space UI (indicators above 3D objects). Not affected by safe areas
1359
+ */
1360
+ declare class UISystem {
1361
+ private static container;
1362
+ private static worldContainer;
1363
+ private static isInitialized;
1364
+ private static activeElements;
1365
+ private static lastMoneyAmount;
1366
+ private static referenceWidth;
1367
+ private static referenceHeight;
1368
+ private static matchWidthOrHeight;
1369
+ private static minScale;
1370
+ private static maxScale;
1371
+ private static currentScale;
1372
+ /**
1373
+ * Reset the UISystem state - useful for page refreshes or reinitialization
1374
+ */
1375
+ static reset(): void;
1376
+ static setInsets(insets: {
1377
+ left: number;
1378
+ top: number;
1379
+ right: number;
1380
+ bottom: number;
1381
+ }): void;
1382
+ /**
1383
+ * Initialize the UI system
1384
+ */
1385
+ static initialize(): void;
1386
+ /**
1387
+ * Add global CSS styles for UI elements
1388
+ */
1389
+ private static addGlobalStyles;
1390
+ /**
1391
+ * Create a HUD element (money display, health bar, etc.)
1392
+ */
1393
+ static createHUD(id: string, content: string, position: {
1394
+ x: number;
1395
+ y: number;
1396
+ }, options?: {
1397
+ className?: string;
1398
+ style?: string;
1399
+ }): UIElement;
1400
+ /**
1401
+ * Create an interaction prompt (Press E to interact, etc.)
1402
+ */
1403
+ static createInteractionPrompt(id: string, text: string, position: {
1404
+ x: number;
1405
+ y: number;
1406
+ }): UIElement;
1407
+ /**
1408
+ * Create a progress bar (cooking progress, etc.)
1409
+ */
1410
+ static createProgressBar(id: string, position: {
1411
+ x: number;
1412
+ y: number;
1413
+ }, size: {
1414
+ width: number;
1415
+ height: number;
1416
+ }, progress?: number): UIProgressBar;
1417
+ /**
1418
+ * Create a button
1419
+ */
1420
+ static createButton(id: string, text: string, position: {
1421
+ x: number;
1422
+ y: number;
1423
+ }, onClick: () => void): UIElement;
1424
+ /**
1425
+ * Create a modal dialog
1426
+ */
1427
+ static createModal(id: string, content: string, options?: {
1428
+ title?: string;
1429
+ buttons?: Array<{
1430
+ text: string;
1431
+ onClick: () => void;
1432
+ }>;
1433
+ width?: number;
1434
+ height?: number;
1435
+ fullScreenOverlay?: boolean;
1436
+ }): UIElement;
1437
+ /**
1438
+ * Update money display (special HUD element)
1439
+ */
1440
+ static updateMoneyDisplay(amount: number): void;
1441
+ /**
1442
+ * Create a world-space UI element that follows a 3D position
1443
+ */
1444
+ static createWorldSpaceUI(id: string, content: string, worldPosition: THREE.Vector3, camera: THREE.Camera, options?: {
1445
+ offset?: {
1446
+ x: number;
1447
+ y: number;
1448
+ };
1449
+ className?: string;
1450
+ }): UIWorldElement;
1451
+ /**
1452
+ * Update all world-space UI elements
1453
+ */
1454
+ static updateWorldSpaceElements(camera: THREE.Camera): void;
1455
+ /**
1456
+ * Unity-style Canvas Scaler with "Match Width Or Height" support
1457
+ *
1458
+ * How it works:
1459
+ * - Reference resolution (e.g., 800x600) - screen size where UI is 100% scale
1460
+ * - matchWidthOrHeight: 0 = match width, 1 = match height, 0.5 = blend both
1461
+ * - UI components use CSS: transform: scale(var(--ui-scale, 1))
1462
+ *
1463
+ * The blend formula (same as Unity):
1464
+ * scale = widthScale^(1-match) * heightScale^match
1465
+ *
1466
+ * This means on portrait mobile (narrow width, tall height):
1467
+ * - Width-only (match=0): very small UI
1468
+ * - Height-only (match=1): large UI
1469
+ * - Blend (match=0.5): balanced UI that looks good
1470
+ */
1471
+ static updateResponsiveScale(): void;
1472
+ /**
1473
+ * Create a HUD element with responsive anchor-based positioning
1474
+ */
1475
+ static createResponsiveHUD(id: string, content: string, anchor: {
1476
+ x: number;
1477
+ y: number;
1478
+ }, // 0-1 values (0 = left/top, 1 = right/bottom)
1479
+ offset?: {
1480
+ x: number;
1481
+ y: number;
1482
+ }, // Pixel offset from anchor
1483
+ options?: {
1484
+ className?: string;
1485
+ style?: string;
1486
+ }): UIElement;
1487
+ /**
1488
+ * Get an element by ID
1489
+ */
1490
+ static getElement(id: string): UIElement | undefined;
1491
+ /**
1492
+ * Remove an element
1493
+ */
1494
+ static removeElement(id: string): void;
1495
+ /**
1496
+ * Clear all UI elements
1497
+ */
1498
+ static clear(): void;
1499
+ /**
1500
+ * Show/hide the entire UI system
1501
+ */
1502
+ static setVisible(visible: boolean): void;
1503
+ /**
1504
+ * Generic element creation helper
1505
+ */
1506
+ private static createElement;
1507
+ /**
1508
+ * Configure the reference resolution for UI scaling (like Unity's Canvas Scaler)
1509
+ * @param referenceWidth - The width at which UI is designed (default: 1920 Full HD)
1510
+ * @param referenceHeight - The height at which UI is designed (default: 1080 Full HD)
1511
+ * @param matchWidthOrHeight - 0 = match width, 1 = match height, 0.5 = blend both (recommended)
1512
+ * @param minScale - Minimum scale factor (prevents UI from getting too small)
1513
+ * @param maxScale - Maximum scale factor (prevents UI from getting too large)
1514
+ */
1515
+ static configureScaling(referenceWidth?: number, referenceHeight?: number, matchWidthOrHeight?: number, minScale?: number, maxScale?: number): void;
1516
+ /**
1517
+ * Get the current calculated UI scale factor
1518
+ */
1519
+ static getUIScale(): number;
1520
+ /**
1521
+ * Get the reference width used for scaling calculations
1522
+ */
1523
+ static getReferenceWidth(): number;
1524
+ /**
1525
+ * Dispose of the UI system
1526
+ */
1527
+ static dispose(): void;
1528
+ }
1529
+ interface UIElement {
1530
+ id: string;
1531
+ type: string;
1532
+ element: HTMLElement;
1533
+ show: () => void;
1534
+ hide: () => void;
1535
+ remove: () => void;
1536
+ }
1537
+ interface UIProgressBar extends UIElement {
1538
+ fillElement: HTMLElement;
1539
+ setProgress: (value: number) => void;
1540
+ }
1541
+ interface UIWorldElement extends UIElement {
1542
+ worldPosition: THREE.Vector3;
1543
+ update: (camera: THREE.Camera) => void;
1544
+ }
1545
+
1546
+ /**
1547
+ * Three.js UI utilities for creating consistent world-space UI components
1548
+ * Simplified to provide consistent text sizing based on world units
1549
+ */
1550
+ declare class UIUtils {
1551
+ /**
1552
+ * Create world-space UI plane with consistent text sizing
1553
+ * Text sizes in pixels directly translate to world units via pixelsPerUnit
1554
+ *
1555
+ * @param worldWidth Width of the plane in world units
1556
+ * @param worldHeight Height of the plane in world units
1557
+ * @param options Configuration options
1558
+ * @returns Object containing the plane mesh, canvas, context, and texture
1559
+ */
1560
+ static createWorldUI(worldWidth: number, worldHeight: number, options?: {
1561
+ /** Resolution (pixels per world unit) - use same value across all UI for consistent text size */
1562
+ pixelsPerUnit?: number;
1563
+ /** Height above ground (default: 0.05) */
1564
+ heightOffset?: number;
1565
+ /** Rotate 180 degrees for correct text orientation (default: true) */
1566
+ flipOrientation?: boolean;
1567
+ }): {
1568
+ plane: THREE.Mesh;
1569
+ canvas: HTMLCanvasElement;
1570
+ ctx: CanvasRenderingContext2D;
1571
+ texture: THREE.CanvasTexture;
1572
+ worldSize: {
1573
+ width: number;
1574
+ height: number;
1575
+ };
1576
+ pixelsPerUnit: number;
1577
+ };
1578
+ /**
1579
+ * Helper function to draw rounded rectangles on canvas
1580
+ */
1581
+ static drawRoundedRect(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius: number): void;
1582
+ static readonly COLORS: {
1583
+ SUCCESS: string;
1584
+ PRIMARY: string;
1585
+ WARNING: string;
1586
+ DANGER: string;
1587
+ WHITE: string;
1588
+ BLACK: string;
1589
+ GRAY: string;
1590
+ BACKGROUND: string;
1591
+ BORDER: string;
1592
+ };
1593
+ static readonly FONT_FAMILY = "'Palanquin Dark', sans-serif";
1594
+ /**
1595
+ * Initialize CSS variables for UI styling
1596
+ * Call this once at app startup (UISystem.initialize() calls this automatically)
1597
+ */
1598
+ static initializeCSSVariables(): void;
1599
+ }
1600
+
1601
+ declare class UILoadingScreen {
1602
+ private static loadingScreenElement;
1603
+ /**
1604
+ * Show the loading screen with a spinner
1605
+ * @param message Optional loading message to display
1606
+ * @param backgroundColor Optional background color (default: #1a1a1a)
1607
+ */
1608
+ static showLoadingScreen(message?: string, backgroundColor?: string): void;
1609
+ /**
1610
+ * Hide and remove the loading screen
1611
+ * @param fadeOut Optional fade out animation (default: true)
1612
+ */
1613
+ static hideLoadingScreen(fadeOut?: boolean): void;
1614
+ /**
1615
+ * Remove the loading screen from DOM
1616
+ */
1617
+ private static removeLoadingScreen;
1618
+ /**
1619
+ * Add spinner animation to the document
1620
+ */
1621
+ private static addSpinnerAnimation;
1622
+ }
1623
+
1624
+ /**
1625
+ * A reusable particle emitter component that can be attached to any GameObject.
1626
+ * The particle system becomes a child of the GameObject and follows it automatically.
1627
+ */
1628
+ declare class Particle extends Component {
1629
+ private emitter;
1630
+ private config;
1631
+ private assets;
1632
+ private static readonly _tempOrigin;
1633
+ /**
1634
+ * Creates a new particle emitter component
1635
+ * @param config - The emitter configuration
1636
+ * @param assets - The assets (textures) for the particles
1637
+ */
1638
+ constructor(config: EmitterConfig, assets: EmitterAssets);
1639
+ protected onCreate(): void;
1640
+ /**
1641
+ * Trigger a burst of particles at the current GameObject position
1642
+ * @param count - Number of particles to emit
1643
+ */
1644
+ trigger(count?: number): void;
1645
+ /**
1646
+ * Update the particle system
1647
+ * @param deltaTime - Time since last frame in seconds
1648
+ */
1649
+ update(deltaTime: number): void;
1650
+ /**
1651
+ * Get the underlying particle system
1652
+ */
1653
+ getEmitter(): ParticleSystem | null;
1654
+ /**
1655
+ * Clean up the particle system
1656
+ */
1657
+ protected onCleanup(): void;
1658
+ }
1659
+
1660
+ /**
1661
+ * Animation Curve System for Particle Effects
1662
+ *
1663
+ * Provides cubic Hermite interpolation similar to Unity's AnimationCurve.
1664
+ * Used for "X over Lifetime" properties like size, speed, opacity, rotation.
1665
+ */
1666
+ /**
1667
+ * A single keyframe on an animation curve.
1668
+ */
1669
+ interface CurveKeyframe {
1670
+ /** Time position on the curve (0-1 normalized) */
1671
+ time: number;
1672
+ /** Output value at this keyframe */
1673
+ value: number;
1674
+ /** Left tangent slope (controls curve shape approaching this point) */
1675
+ inTangent: number;
1676
+ /** Right tangent slope (controls curve shape leaving this point) */
1677
+ outTangent: number;
1678
+ }
1679
+ /**
1680
+ * An animation curve defined by keyframes with tangent handles.
1681
+ */
1682
+ interface AnimationCurve {
1683
+ /** Sorted array of keyframes (by time) */
1684
+ keys: CurveKeyframe[];
1685
+ }
1686
+ /**
1687
+ * CurveableValue - a property that can be either a constant or a curve.
1688
+ * Used in EmitterConfig for properties that support "over lifetime" curves.
1689
+ */
1690
+ type CurveableValue = number | {
1691
+ curve: AnimationCurve;
1692
+ };
1693
+ /**
1694
+ * Evaluates an animation curve at a given time using cubic Hermite interpolation.
1695
+ *
1696
+ * @param curve - The animation curve to evaluate
1697
+ * @param t - Time value (typically 0-1 for particle lifetime)
1698
+ * @returns The interpolated value at time t
1699
+ */
1700
+ declare function evaluateCurve(curve: AnimationCurve, t: number): number;
1701
+ /**
1702
+ * Evaluates a CurveableValue (constant or curve) at a given time.
1703
+ *
1704
+ * @param value - Either a constant number or an object with a curve
1705
+ * @param t - Time value (0-1 for particle lifetime)
1706
+ * @param defaultValue - Value to return if value is undefined
1707
+ * @returns The evaluated value
1708
+ */
1709
+ declare function evaluateCurveableValue(value: CurveableValue | undefined, t: number, defaultValue?: number): number;
1710
+ /**
1711
+ * Creates a keyframe with auto-calculated tangents for smooth interpolation.
1712
+ */
1713
+ declare function createKeyframe(time: number, value: number, inTangent?: number, outTangent?: number): CurveKeyframe;
1714
+ /**
1715
+ * Creates a simple curve from an array of [time, value] pairs.
1716
+ * Tangents are automatically calculated for smooth interpolation.
1717
+ */
1718
+ declare function createCurveFromPoints(points: Array<[number, number]>): AnimationCurve;
1719
+ /**
1720
+ * Preset curve factories for common curve shapes.
1721
+ */
1722
+ declare const CurvePresets: {
1723
+ /**
1724
+ * Linear curve from 0 to 1
1725
+ */
1726
+ linear(): AnimationCurve;
1727
+ /**
1728
+ * Linear curve from 1 to 0 (inverse)
1729
+ */
1730
+ linearInverse(): AnimationCurve;
1731
+ /**
1732
+ * Constant value curve
1733
+ */
1734
+ constant(value?: number): AnimationCurve;
1735
+ /**
1736
+ * Ease-in curve (slow start, fast end)
1737
+ */
1738
+ easeIn(): AnimationCurve;
1739
+ /**
1740
+ * Ease-out curve (fast start, slow end)
1741
+ */
1742
+ easeOut(): AnimationCurve;
1743
+ /**
1744
+ * Ease-in-out curve (smooth S-curve)
1745
+ */
1746
+ easeInOut(): AnimationCurve;
1747
+ /**
1748
+ * Bell curve (starts at 0, peaks at 1 in middle, returns to 0)
1749
+ */
1750
+ bell(): AnimationCurve;
1751
+ /**
1752
+ * Fade-in curve (0 to 1 with smooth ramp)
1753
+ */
1754
+ fadeIn(): AnimationCurve;
1755
+ /**
1756
+ * Fade-out curve (1 to 0 with smooth ramp)
1757
+ */
1758
+ fadeOut(): AnimationCurve;
1759
+ /**
1760
+ * Bounce curve (oscillating decay)
1761
+ */
1762
+ bounce(): AnimationCurve;
1763
+ };
1764
+ /**
1765
+ * Clones an animation curve (deep copy).
1766
+ */
1767
+ declare function cloneCurve(curve: AnimationCurve): AnimationCurve;
1768
+ /**
1769
+ * Adds a keyframe to a curve at the specified time.
1770
+ * The curve is re-sorted after insertion.
1771
+ */
1772
+ declare function addKeyframe(curve: AnimationCurve, keyframe: CurveKeyframe): AnimationCurve;
1773
+ /**
1774
+ * Removes a keyframe at the specified index.
1775
+ */
1776
+ declare function removeKeyframe(curve: AnimationCurve, index: number): AnimationCurve;
1777
+ /**
1778
+ * Updates a keyframe at the specified index.
1779
+ */
1780
+ declare function updateKeyframe(curve: AnimationCurve, index: number, updates: Partial<CurveKeyframe>): AnimationCurve;
1781
+
1782
+ interface CurvePropertyValue {
1783
+ mode: "constant" | "curve";
1784
+ constant?: number;
1785
+ curve?: {
1786
+ keys: {
1787
+ time: number;
1788
+ value: number;
1789
+ inTangent: number;
1790
+ outTangent: number;
1791
+ }[];
1792
+ };
1793
+ }
1794
+ interface ParticleSystemJSON extends ComponentJSON {
1795
+ type: "particle_system";
1796
+ main: {
1797
+ duration: number;
1798
+ looping: boolean;
1799
+ startLifetimeMin: number;
1800
+ startLifetimeMax: number;
1801
+ startSpeedMin: number;
1802
+ startSpeedMax: number;
1803
+ startSizeMin: number;
1804
+ startSizeMax: number;
1805
+ gravityModifier: number;
1806
+ maxParticles: number;
1807
+ startColor: number[];
1808
+ useRandomStartColors?: boolean;
1809
+ randomStartColors?: number[][];
1810
+ colorOverLifetime: boolean;
1811
+ endColor: number[];
1812
+ useMidColor?: boolean;
1813
+ midColor?: number[];
1814
+ opacityOverLifetime?: CurvePropertyValue;
1815
+ };
1816
+ emission: {
1817
+ enabled: boolean;
1818
+ mode: "constant" | "burst";
1819
+ rateOverTime: number;
1820
+ burstCount?: number;
1821
+ burstCycles?: number;
1822
+ burstInterval?: number;
1823
+ };
1824
+ shape: {
1825
+ enabled: boolean;
1826
+ shape: "cone" | "sphere" | "box" | "point";
1827
+ radius: number;
1828
+ coneAngleMin?: number;
1829
+ coneAngleMax?: number;
1830
+ coneDirection?: number[];
1831
+ boxSize?: number[];
1832
+ sphereRadius?: number;
1833
+ };
1834
+ velocity: {
1835
+ enabled: boolean;
1836
+ gravity: number[];
1837
+ damping?: number;
1838
+ speedOverLifetime?: CurvePropertyValue;
1839
+ orbitalX?: number;
1840
+ orbitalY?: number;
1841
+ orbitalZ?: number;
1842
+ };
1843
+ size: {
1844
+ value?: {
1845
+ enabled?: boolean;
1846
+ endSizeMin?: number;
1847
+ endSizeMax?: number;
1848
+ };
1849
+ enabled?: boolean;
1850
+ endSizeMin: number;
1851
+ endSizeMax: number;
1852
+ sizeOverLifetime?: CurvePropertyValue;
1853
+ };
1854
+ rotation: {
1855
+ enabled: boolean;
1856
+ startAngleMin: number;
1857
+ startAngleMax: number;
1858
+ angularVelocityMin: number;
1859
+ angularVelocityMax: number;
1860
+ rotationOverLifetime?: CurvePropertyValue;
1861
+ };
1862
+ noise?: {
1863
+ enabled: boolean;
1864
+ positionAmount?: number;
1865
+ rotationAmount?: number;
1866
+ sizeAmount?: number;
1867
+ frequency?: number;
1868
+ scrollSpeed?: number;
1869
+ octaves?: number;
1870
+ };
1871
+ textureSheet: {
1872
+ enabled: boolean;
1873
+ timeMode?: "fps" | "startLifetime";
1874
+ rows: number;
1875
+ columns: number;
1876
+ fps: number;
1877
+ loop: boolean;
1878
+ randomStartFrame?: boolean;
1879
+ };
1880
+ collision: {
1881
+ enabled: boolean;
1882
+ planeY?: number;
1883
+ restitution?: number;
1884
+ friction?: number;
1885
+ killAfterBounces?: number;
1886
+ };
1887
+ renderer: {
1888
+ texture: {
1889
+ pack: string;
1890
+ assetId: string;
1891
+ };
1892
+ renderMode?: "billboard" | "quad";
1893
+ blending: "additive" | "normal";
1894
+ premultipliedAlpha: boolean;
1895
+ maskFromLuminance: boolean;
1896
+ velocityScale: number;
1897
+ stretchWithVelocity: boolean;
1898
+ alignToVelocity: boolean;
1899
+ flipX?: number;
1900
+ flipY?: number;
1901
+ };
1902
+ }
1903
+ /**
1904
+ * Prefab component for particle systems.
1905
+ * Directly creates particle emitter like the editor does.
1906
+ */
1907
+ declare class ParticleSystemPrefabComponent extends Component {
1908
+ private emitter;
1909
+ private json;
1910
+ private static readonly _tempOrigin;
1911
+ /**
1912
+ * Create a ParticleSystemPrefabComponent from prefab JSON
1913
+ */
1914
+ static fromPrefabJSON(json: ParticleSystemJSON, _node: PrefabNode): ParticleSystemPrefabComponent | null;
1915
+ constructor(json: ParticleSystemJSON);
1916
+ protected onCreate(): void;
1917
+ /**
1918
+ * Load texture on-demand and update the emitter's material
1919
+ * This matches how the editor loads textures asynchronously
1920
+ */
1921
+ private loadTextureAsync;
1922
+ /**
1923
+ * Build EmitterConfig from prefab JSON - matches editor's buildEmitterConfigFromComponentData
1924
+ */
1925
+ private buildEmitterConfig;
1926
+ /**
1927
+ * Build EmitterAssets from prefab JSON
1928
+ * Starts with procedural texture - actual texture is loaded asynchronously in loadTextureAsync()
1929
+ */
1930
+ private buildEmitterAssets;
1931
+ /**
1932
+ * Trigger a burst of particles
1933
+ */
1934
+ trigger(count?: number): void;
1935
+ /**
1936
+ * Play the particle system
1937
+ */
1938
+ play(): void;
1939
+ /**
1940
+ * Stop the particle system
1941
+ */
1942
+ stop(): void;
1943
+ /**
1944
+ * Update the particle system
1945
+ */
1946
+ update(deltaTime: number): void;
1947
+ /**
1948
+ * Get the underlying particle system
1949
+ */
1950
+ getEmitter(): ParticleSystem | null;
1951
+ protected onCleanup(): void;
1952
+ }
1953
+
1954
+ type ParticleSystem = {
1955
+ object: THREE.InstancedMesh;
1956
+ update: (dt: number, camera: THREE.Camera, emitterWorldMatrix?: THREE.Matrix4) => void;
1957
+ burst: (origin: THREE.Vector3, count?: number) => void;
1958
+ setSpawnRate: (rate: number) => void;
1959
+ setOrigin: (origin: THREE.Vector3) => void;
1960
+ config: EmitterConfig;
1961
+ setTexture?: (texture: THREE.Texture) => void;
1962
+ play: () => void;
1963
+ stop: () => void;
1964
+ restart: () => void;
1965
+ isPlaying: () => boolean;
1966
+ getElapsed: () => number;
1967
+ playInternal?: () => void;
1968
+ stopInternal?: () => void;
1969
+ restartInternal?: () => void;
1970
+ };
1971
+ type NumRange = number | readonly [number, number];
1972
+ type Vec4Range = THREE.Vector4 | {
1973
+ min: THREE.Vector4;
1974
+ max: THREE.Vector4;
1975
+ };
1976
+ declare function range(min: number, max: number): readonly [number, number];
1977
+ declare const EmitterShape: {
1978
+ readonly CONE: "cone";
1979
+ readonly SPHERE: "sphere";
1980
+ readonly BOX: "box";
1981
+ readonly POINT: "point";
1982
+ };
1983
+ type EmitterShapeKey = (typeof EmitterShape)[keyof typeof EmitterShape];
1984
+ type BurstConfig = {
1985
+ time: number;
1986
+ count: number;
1987
+ cycles?: number;
1988
+ interval?: number;
1989
+ };
1990
+ type EmissionConfig = {
1991
+ mode: "constant" | "burst";
1992
+ rateOverTime?: number;
1993
+ bursts?: BurstConfig[];
1994
+ };
1995
+ type NoiseConfig = {
1996
+ enabled?: boolean;
1997
+ positionAmount?: number;
1998
+ rotationAmount?: number;
1999
+ sizeAmount?: number;
2000
+ frequency?: number;
2001
+ scrollSpeed?: number;
2002
+ octaves?: number;
2003
+ strengthX?: number;
2004
+ strengthY?: number;
2005
+ };
2006
+ type FlipConfig = {
2007
+ x?: number;
2008
+ y?: number;
2009
+ };
2010
+ type RenderMode = "billboard" | "quad";
2011
+ type EmitterConfig = {
2012
+ maxParticles?: number;
2013
+ duration?: number;
2014
+ looping?: boolean;
2015
+ playOnAwake?: boolean;
2016
+ emission?: EmissionConfig;
2017
+ shape?: EmitterShapeKey;
2018
+ coneAngle?: NumRange;
2019
+ coneDirection?: THREE.Vector3;
2020
+ radius?: number;
2021
+ boxSize?: THREE.Vector3;
2022
+ sphereRadius?: number;
2023
+ lifetime?: NumRange;
2024
+ size?: {
2025
+ start: NumRange;
2026
+ end: NumRange;
2027
+ };
2028
+ speed?: NumRange;
2029
+ gravity?: THREE.Vector3;
2030
+ damping?: number;
2031
+ orbital?: {
2032
+ x?: number;
2033
+ y?: number;
2034
+ z?: number;
2035
+ };
2036
+ alignment?: {
2037
+ velocityScale?: number;
2038
+ enableVelocityStretch?: boolean;
2039
+ enableVelocityAlignment?: boolean;
2040
+ };
2041
+ rotation?: {
2042
+ angle?: NumRange;
2043
+ velocity?: NumRange;
2044
+ };
2045
+ sizeOverLifetime?: CurveableValue;
2046
+ speedOverLifetime?: CurveableValue;
2047
+ opacityOverLifetime?: CurveableValue;
2048
+ rotationOverLifetime?: CurveableValue;
2049
+ noise?: NoiseConfig;
2050
+ color?: {
2051
+ start: Vec4Range;
2052
+ startList?: THREE.Vector4[];
2053
+ useStartAsEnd?: boolean;
2054
+ mid?: Vec4Range;
2055
+ end: Vec4Range;
2056
+ };
2057
+ blending?: THREE.Blending;
2058
+ premultipliedAlpha?: boolean;
2059
+ maskFromLuminance?: boolean;
2060
+ flip?: FlipConfig;
2061
+ renderMode?: RenderMode;
2062
+ collision?: {
2063
+ enabled?: boolean;
2064
+ planeY?: number;
2065
+ restitution?: number;
2066
+ friction?: number;
2067
+ killAfterBounces?: number;
2068
+ };
2069
+ spriteSheet?: {
2070
+ rows: number;
2071
+ columns: number;
2072
+ frameCount?: number;
2073
+ timeMode?: "fps" | "startLifetime";
2074
+ fps?: number;
2075
+ loop?: boolean;
2076
+ randomStartFrame?: boolean;
2077
+ };
2078
+ debug?: boolean;
2079
+ debugVelocities?: boolean;
2080
+ };
2081
+ type EmitterAssets = {
2082
+ texture?: THREE.Texture;
2083
+ textureUrl?: string;
2084
+ material?: THREE.MeshBasicMaterial;
2085
+ };
2086
+ declare function createParticleEmitter(cfg?: EmitterConfig, assets?: EmitterAssets): ParticleSystem;
2087
+
2088
+ declare enum ParameterType {
2089
+ BOOL = "bool",
2090
+ FLOAT = "float",
2091
+ INT = "int",
2092
+ TRIGGER = "trigger"
2093
+ }
2094
+ declare enum ComparisonOperator {
2095
+ EQUALS = "==",
2096
+ NOT_EQUALS = "!=",
2097
+ GREATER = ">",
2098
+ LESS = "<",
2099
+ GREATER_EQUALS = ">=",
2100
+ LESS_EQUALS = "<="
2101
+ }
2102
+ declare enum BlendType {
2103
+ LINEAR = "linear",
2104
+ EASE_IN_OUT = "ease_in_out"
2105
+ }
2106
+ declare enum AnimationEvent {
2107
+ STATE_CHANGED = "state_changed",
2108
+ TRANSITION_START = "transition_start",
2109
+ TRANSITION_END = "transition_end"
2110
+ }
2111
+ interface Parameter {
2112
+ type: ParameterType;
2113
+ value: any;
2114
+ }
2115
+ interface TransitionCondition {
2116
+ parameter: string;
2117
+ operator: ComparisonOperator;
2118
+ value: any;
2119
+ }
2120
+ interface TransitionConfig$1 {
2121
+ from: string;
2122
+ to: string;
2123
+ conditions: TransitionCondition[];
2124
+ duration?: number;
2125
+ priority?: number;
2126
+ blend_type?: BlendType;
2127
+ }
2128
+ interface ClipInfo {
2129
+ id: string;
2130
+ is_playing: boolean;
2131
+ weight: number;
2132
+ loop: boolean;
2133
+ }
2134
+ interface BlendTreeConfig {
2135
+ parameter: string;
2136
+ children: {
2137
+ state_id: string;
2138
+ threshold: number;
2139
+ }[];
2140
+ }
2141
+ interface ActiveTransition {
2142
+ from_state: string;
2143
+ to_state: string;
2144
+ progress: number;
2145
+ }
2146
+ type EventCallback = () => void;
2147
+ /**
2148
+ * Lightweight animation state machine for visualization
2149
+ * No actual animation playback - SharedAnimationManager handles that
2150
+ */
2151
+ declare class Animatrix {
2152
+ private states;
2153
+ private transitions;
2154
+ private parameters;
2155
+ private treeStates;
2156
+ private blendTreeConfigs;
2157
+ private currentState;
2158
+ private activeTransition;
2159
+ private listeners;
2160
+ constructor();
2161
+ add_parameter(name: string, type: ParameterType, defaultValue: any): void;
2162
+ add_clip(name: string, clipInfo: {
2163
+ duration: number;
2164
+ }): void;
2165
+ add_blend_tree_1d(id: string, parameter: string, children: {
2166
+ state_id: string;
2167
+ threshold: number;
2168
+ }[]): void;
2169
+ add_transition(config: TransitionConfig$1): void;
2170
+ set_state(name: string): void;
2171
+ set_bool(name: string, value: boolean): void;
2172
+ set_float(name: string, value: number): void;
2173
+ set_int(name: string, value: number): void;
2174
+ get_float(name: string): number;
2175
+ get_bool(name: string): boolean;
2176
+ get_int(name: string): number;
2177
+ update(_deltaTime: number): void;
2178
+ stop_all(): void;
2179
+ get_current_state(): string | null;
2180
+ get_clips(): Map<string, ClipInfo>;
2181
+ get_transitions(): TransitionConfig$1[];
2182
+ get_active_transition(): ActiveTransition | null;
2183
+ get_blend_tree_ids(): Set<string>;
2184
+ is_blend_tree_state(id: string): boolean;
2185
+ get_blend_tree_config(id: string): BlendTreeConfig | null;
2186
+ get_clip_progress(_stateId: string): number;
2187
+ get_parameters_map(): Map<string, Parameter>;
2188
+ add_listener(event: AnimationEvent, callback: EventCallback): void;
2189
+ remove_listener(event: AnimationEvent, callback: EventCallback): void;
2190
+ private emit_event;
2191
+ }
2192
+
2193
+ declare class AnimatrixVisualizer {
2194
+ private animator;
2195
+ private animators;
2196
+ private current_animator_name;
2197
+ private canvas;
2198
+ private ctx;
2199
+ private node_positions;
2200
+ private is_visible;
2201
+ private container;
2202
+ private auto_layout_complete;
2203
+ private animation_frame_id;
2204
+ private event_listeners;
2205
+ private readonly NODE_RADIUS;
2206
+ private readonly NODE_COLOR_IDLE;
2207
+ private readonly NODE_COLOR_ACTIVE;
2208
+ private readonly NODE_COLOR_TRANSITIONING;
2209
+ private readonly NODE_COLOR_BLENDTREE;
2210
+ private readonly CONNECTION_COLOR;
2211
+ private readonly CONNECTION_COLOR_ACTIVE;
2212
+ private readonly TEXT_COLOR;
2213
+ private readonly BG_COLOR;
2214
+ private viewScale;
2215
+ private panX;
2216
+ private panY;
2217
+ private isPanningView;
2218
+ private panStart;
2219
+ private isDraggingWindow;
2220
+ private dragWindowOffset;
2221
+ private isResizingWindow;
2222
+ private resizeStart;
2223
+ private isMinimized;
2224
+ private nodeDrawerOpen;
2225
+ private hoveredChevron;
2226
+ private pendingLabels;
2227
+ private drillDownState;
2228
+ private drillDownTreeConfig;
2229
+ private lastClickTime;
2230
+ private lastClickNode;
2231
+ private getLOD;
2232
+ constructor(animator?: Animatrix, name?: string);
2233
+ add_animator(name: string, animator: Animatrix): void;
2234
+ remove_animator(name: string): void;
2235
+ set_animator(name: string | null): void;
2236
+ private setup_animator_listeners;
2237
+ private cleanup_animator_listeners;
2238
+ private update_animator_select;
2239
+ private update_title;
2240
+ private start_animation_loop;
2241
+ private auto_layout_nodes;
2242
+ private detectCycles;
2243
+ private radialLayout;
2244
+ private sortNodesByConnectivity;
2245
+ private forceDirectedRefinement;
2246
+ private buildGraph;
2247
+ private assignLayers;
2248
+ private minimizeCrossings;
2249
+ private orderLayerByBarycenter;
2250
+ private assignCoordinates;
2251
+ private priorityLayoutAdjustment;
2252
+ private dragging_node;
2253
+ private drag_offset;
2254
+ private handle_mouse_down;
2255
+ private handle_mouse_move;
2256
+ private handle_mouse_up;
2257
+ private handle_wheel;
2258
+ private start_window_drag;
2259
+ private on_window_drag;
2260
+ private stop_window_drag;
2261
+ private start_window_resize;
2262
+ private on_window_resize;
2263
+ private stop_window_resize;
2264
+ private toggle_minimize;
2265
+ private update_canvas_size;
2266
+ private render;
2267
+ private enterDrillDown;
2268
+ private exitDrillDown;
2269
+ private render_drill_down_view;
2270
+ private draw_connections;
2271
+ private getRectEdgePoint;
2272
+ private draw_nodes;
2273
+ private get_node_dimensions;
2274
+ private queue_label;
2275
+ private draw_labels_screen_space;
2276
+ private draw_chevron;
2277
+ private draw_rounded_rect;
2278
+ private draw_playback_indicator;
2279
+ private update_parameters_panel;
2280
+ toggle_visibility(): void;
2281
+ show(): void;
2282
+ hide(): void;
2283
+ destroy(): void;
2284
+ }
2285
+
2286
+ declare class AnimationLibrary {
2287
+ private static clips;
2288
+ private static loader;
2289
+ private static debug;
2290
+ private static readonly ACCESSORY_PREFIXES;
2291
+ static setDebug(enabled: boolean): void;
2292
+ static loadAnimation(id: string, path: string): Promise<THREE.AnimationClip>;
2293
+ static loadAnimations(paths: {
2294
+ [id: string]: string;
2295
+ }): Promise<void>;
2296
+ static registerClip(id: string, clip: THREE.AnimationClip): void;
2297
+ static getClip(id: string): THREE.AnimationClip | undefined;
2298
+ static cloneClip(id: string): THREE.AnimationClip | undefined;
2299
+ static getAllClips(): Map<string, THREE.AnimationClip>;
2300
+ static hasClip(id: string): boolean;
2301
+ }
2302
+
2303
+ /**
2304
+ * Simplified component wrapper for Animatrix animation visualization
2305
+ * Note: For actual animation playback, use AnimationGraphComponent which uses SharedAnimationManager
2306
+ */
2307
+ declare class AnimationControllerComponent extends Component {
2308
+ private static instances;
2309
+ private static sharedVisualizer;
2310
+ private static debugViewEnabled;
2311
+ private animator;
2312
+ private debug;
2313
+ constructor(debug?: boolean);
2314
+ static setDebugViewEnabled(enabled: boolean): void;
2315
+ static isDebugViewEnabled(): boolean;
2316
+ getAnimator(): Animatrix | null;
2317
+ addParameter(name: string, type: ParameterType, initialValue?: any): void;
2318
+ setBool(name: string, value: boolean): void;
2319
+ setFloat(name: string, value: number): void;
2320
+ setInt(name: string, value: number): void;
2321
+ setState(stateId: string): boolean;
2322
+ getCurrentState(): string | null;
2323
+ stopAll(): void;
2324
+ protected onCreate(): void;
2325
+ protected onCleanup(): void;
2326
+ update(deltaTime: number): void;
2327
+ }
2328
+
2329
+ /**
2330
+ * Component for managing animation library functionality
2331
+ * Provides centralized animation loading and caching as a component
2332
+ */
2333
+ declare class AnimationLibraryComponent extends Component {
2334
+ private loadedAnimations;
2335
+ private debug;
2336
+ constructor(debug?: boolean);
2337
+ /**
2338
+ * Load a single animation and add it to the library
2339
+ */
2340
+ loadAnimation(id: string, path: string): Promise<THREE.AnimationClip>;
2341
+ /**
2342
+ * Load multiple animations in parallel
2343
+ */
2344
+ loadAnimations(paths: {
2345
+ [id: string]: string;
2346
+ }): Promise<void>;
2347
+ /**
2348
+ * Get an animation clip from the library
2349
+ */
2350
+ getClip(id: string): THREE.AnimationClip | undefined;
2351
+ /**
2352
+ * Get a cloned copy of an animation clip
2353
+ */
2354
+ cloneClip(id: string): THREE.AnimationClip | undefined;
2355
+ /**
2356
+ * Check if an animation is loaded in the library
2357
+ */
2358
+ hasClip(id: string): boolean;
2359
+ /**
2360
+ * Get all loaded animations
2361
+ */
2362
+ getAllClips(): Map<string, THREE.AnimationClip>;
2363
+ /**
2364
+ * Get list of animations loaded by this component instance
2365
+ */
2366
+ getLoadedAnimationIds(): string[];
2367
+ /**
2368
+ * Set debug mode for the animation library
2369
+ */
2370
+ setDebug(enabled: boolean): void;
2371
+ protected onCreate(): void;
2372
+ protected onCleanup(): void;
2373
+ onEnabled(): void;
2374
+ onDisabled(): void;
2375
+ /**
2376
+ * Preload a standard set of character animations
2377
+ * Useful for common character animation setups
2378
+ */
2379
+ preloadCharacterAnimations(basePath?: string): Promise<void>;
2380
+ /**
2381
+ * Check if all required animations are loaded
2382
+ */
2383
+ hasAllAnimations(requiredIds: string[]): boolean;
2384
+ /**
2385
+ * Get missing animations from a required list
2386
+ */
2387
+ getMissingAnimations(requiredIds: string[]): string[];
2388
+ }
2389
+
2390
+ /**
2391
+ * Component for visualizing animation state machines
2392
+ * Provides debug visualization functionality as a component
2393
+ */
2394
+ declare class AnimationVisualizerComponent extends Component {
2395
+ private visualizer;
2396
+ private animationController;
2397
+ private name;
2398
+ constructor(name?: string);
2399
+ /**
2400
+ * Set the animation controller to visualize
2401
+ */
2402
+ setAnimationController(controller: AnimationControllerComponent): void;
2403
+ /**
2404
+ * Get the underlying visualizer instance
2405
+ */
2406
+ getVisualizer(): AnimatrixVisualizer | null;
2407
+ /**
2408
+ * Show the visualizer UI
2409
+ */
2410
+ show(): void;
2411
+ /**
2412
+ * Hide the visualizer UI
2413
+ */
2414
+ hide(): void;
2415
+ /**
2416
+ * Toggle visualizer visibility
2417
+ */
2418
+ toggleVisibility(): void;
2419
+ /**
2420
+ * Check if visualizer is currently visible
2421
+ */
2422
+ isVisible(): boolean;
2423
+ /**
2424
+ * Destroy the visualizer UI
2425
+ */
2426
+ destroyVisualizer(): void;
2427
+ protected onCreate(): void;
2428
+ protected onCleanup(): void;
2429
+ onEnabled(): void;
2430
+ onDisabled(): void;
2431
+ /**
2432
+ * Auto-setup: find an AnimationControllerComponent on the same GameObject and connect to it
2433
+ */
2434
+ autoConnectToController(): boolean;
2435
+ /**
2436
+ * Connect to a specific animation controller component from another GameObject
2437
+ */
2438
+ connectToController(controller: AnimationControllerComponent): void;
2439
+ }
2440
+
2441
+ interface ParameterConfig {
2442
+ type: "bool" | "float" | "int";
2443
+ default: any;
2444
+ }
2445
+ interface AnimationTreeChild {
2446
+ animation: string;
2447
+ threshold: number;
2448
+ }
2449
+ interface AnimationTree {
2450
+ parameter: string;
2451
+ children: AnimationTreeChild[];
2452
+ }
2453
+ interface StateConfig {
2454
+ animation?: string;
2455
+ tree?: AnimationTree;
2456
+ randomizeStartTime?: boolean;
2457
+ }
2458
+ interface TransitionConfig {
2459
+ from: string;
2460
+ to: string;
2461
+ when?: Record<string, any>;
2462
+ /** Exit time as a normalized value (0-1). If true, defaults to 1.0 (end of animation) */
2463
+ exitTime?: number | boolean;
2464
+ }
2465
+ interface AnimationGraphConfig {
2466
+ parameters?: Record<string, ParameterConfig>;
2467
+ states: Record<string, StateConfig>;
2468
+ transitions?: TransitionConfig[];
2469
+ initialState: string;
2470
+ debug?: boolean;
2471
+ }
2472
+ interface StoredTreeConfig {
2473
+ stateName: string;
2474
+ tree: AnimationTree | null;
2475
+ simpleAnimation: string | null;
2476
+ }
2477
+ declare class AnimationGraphComponent extends Component {
2478
+ private static instances;
2479
+ private static instancesByName;
2480
+ private static sharedVisualizer;
2481
+ private static debugViewEnabled;
2482
+ private static treeConfigs;
2483
+ private config;
2484
+ private readonly model;
2485
+ private controller;
2486
+ private sharedManager;
2487
+ private animator;
2488
+ private animatorName;
2489
+ private parameters;
2490
+ private currentState;
2491
+ private currentAnimation;
2492
+ private stateElapsedTime;
2493
+ private currentStateDuration;
2494
+ private transitionsByState;
2495
+ private stateDurations;
2496
+ private useFrustumCulling;
2497
+ private boundingRadius;
2498
+ private cullingManager;
2499
+ constructor(model: THREE.Object3D, config: AnimationGraphConfig);
2500
+ static setDebugViewEnabled(enabled: boolean): void;
2501
+ static isDebugViewEnabled(): boolean;
2502
+ static getTreeConfig(animatorName: string, stateName: string): StoredTreeConfig | null;
2503
+ static getStateConfigs(animatorName: string): Map<string, StoredTreeConfig> | null;
2504
+ static getParameterValue(animatorName: string, paramName: string): any;
2505
+ static getCurrentAnimation(animatorName: string): string | null;
2506
+ getAnimator(): Animatrix | null;
2507
+ protected onCreate(): void;
2508
+ private setupAnimationGraph;
2509
+ /**
2510
+ * Pre-index transitions by source state for O(1) lookup during update
2511
+ */
2512
+ private preIndexTransitions;
2513
+ /**
2514
+ * Cache state durations to avoid repeated AnimationLibrary lookups
2515
+ */
2516
+ private cacheStateDurations;
2517
+ private storeTreeConfigs;
2518
+ private registerAnimationClips;
2519
+ private setupAnimatrix;
2520
+ update(deltaTime: number): void;
2521
+ private updateAnimation;
2522
+ setParameter(name: string, value: any): void;
2523
+ getParameter(name: string): any;
2524
+ setState(stateName: string): void;
2525
+ getCurrentState(): string | null;
2526
+ /**
2527
+ * Pause/unpause animation updates.
2528
+ * Use for off-screen or distant characters to save CPU.
2529
+ * @param paused If true, animation mixer won't update (bones freeze)
2530
+ */
2531
+ setPaused(paused: boolean): void;
2532
+ /**
2533
+ * Check if animation is paused
2534
+ */
2535
+ isPaused(): boolean;
2536
+ /**
2537
+ * Enable/disable frustum culling for this animator.
2538
+ * When enabled, animation updates are skipped if the model is outside the camera frustum.
2539
+ * @param enabled Whether to use frustum culling (default: true)
2540
+ */
2541
+ setFrustumCulling(enabled: boolean): void;
2542
+ /**
2543
+ * Set the bounding radius used for frustum culling.
2544
+ * @param radius The sphere radius around the character (default: 2)
2545
+ */
2546
+ setBoundingRadius(radius: number): void;
2547
+ /**
2548
+ * Get the AnimationCullingManager instance for global culling settings.
2549
+ * Use this to add cameras, configure distance culling, etc.
2550
+ */
2551
+ static getCullingManager(): AnimationCullingManager;
2552
+ private getStateDuration;
2553
+ private getStateRandomizeTime;
2554
+ addEventListener(_event: string, _callback: (data?: any) => void): void;
2555
+ protected onCleanup(): void;
2556
+ }
2557
+
2558
+ /**
2559
+ * Shared animation clip registry
2560
+ * Stores clips once, characters create their own mixers
2561
+ *
2562
+ * Note: We tried using AnimationObjectGroup for true sharing, but it had
2563
+ * issues with certain animations not applying to some character models.
2564
+ * Per-character mixers are slightly less efficient but much more reliable.
2565
+ */
2566
+ declare class SharedAnimationManager {
2567
+ private static instance;
2568
+ private clips;
2569
+ private constructor();
2570
+ static getInstance(): SharedAnimationManager;
2571
+ /**
2572
+ * Register an animation clip once
2573
+ */
2574
+ registerClip(name: string, clip: THREE.AnimationClip): void;
2575
+ getClip(name: string): THREE.AnimationClip | undefined;
2576
+ getRegisteredClipNames(): string[];
2577
+ /**
2578
+ * No-op for backward compatibility
2579
+ * Per-character mixers update themselves
2580
+ */
2581
+ update(_deltaTime: number): void;
2582
+ }
2583
+ /**
2584
+ * Per-character animation controller with its own mixer
2585
+ * Uses shared clips from SharedAnimationManager for memory efficiency
2586
+ */
2587
+ declare class CharacterAnimationController {
2588
+ private manager;
2589
+ private mixer;
2590
+ private actions;
2591
+ private currentAnimation;
2592
+ private crossfadeDuration;
2593
+ private isPaused;
2594
+ constructor(model: THREE.Object3D, manager: SharedAnimationManager);
2595
+ /**
2596
+ * Pause animation updates (for off-screen or distant characters)
2597
+ */
2598
+ setPaused(paused: boolean): void;
2599
+ /**
2600
+ * Check if animation is paused
2601
+ */
2602
+ getIsPaused(): boolean;
2603
+ /**
2604
+ * Set the crossfade duration for animation transitions
2605
+ */
2606
+ setCrossfadeDuration(duration: number): void;
2607
+ /**
2608
+ * Play a single animation with crossfade transition
2609
+ */
2610
+ playAnimation(name: string, startTime?: number): void;
2611
+ /**
2612
+ * Update the mixer - MUST be called every frame
2613
+ * Returns early if paused (for performance optimization of off-screen characters)
2614
+ */
2615
+ update(deltaTime: number): void;
2616
+ /**
2617
+ * Stop all animations
2618
+ */
2619
+ stopAll(): void;
2620
+ /**
2621
+ * Cleanup
2622
+ */
2623
+ dispose(): void;
2624
+ }
2625
+
2626
+ /**
2627
+ * Console filter stub - kept for backwards compatibility
2628
+ * Filtering is no longer needed as animations are pre-cleaned
2629
+ */
2630
+ declare class AnimationConsoleFilter {
2631
+ private static isFilterActive;
2632
+ /**
2633
+ * Enable filtering of PropertyBinding warnings for missing animation targets
2634
+ * NOTE: This is no longer needed as we're pre-cleaning animations
2635
+ */
2636
+ static enable(): void;
2637
+ /**
2638
+ * Disable the console filter
2639
+ */
2640
+ static disable(): void;
2641
+ /**
2642
+ * Check if the filter is currently active
2643
+ */
2644
+ static isActive(): boolean;
2645
+ }
2646
+
2647
+ /**
2648
+ * Simple performance utilities for the animation system
2649
+ * Focuses on reducing skin influences and cleaning up animation tracks
2650
+ */
2651
+ declare class AnimationPerformance {
2652
+ /**
2653
+ * Reduce the number of bone influences per vertex for better mobile performance
2654
+ * @param skinnedMesh The skinned mesh to optimize
2655
+ * @param maxInfluences Maximum number of bone influences per vertex (default 2)
2656
+ */
2657
+ static reduceSkinInfluences(skinnedMesh: THREE.SkinnedMesh, maxInfluences?: number): void;
2658
+ /**
2659
+ * Clean up animation clip by removing tracks for non-bone objects
2660
+ * This prevents PropertyBinding warnings and improves performance
2661
+ * Removes tracks for accessories, hair, hats, etc that are mesh names not bones
2662
+ *
2663
+ * IMPORTANT: Returns a NEW clip, does not modify the original
2664
+ */
2665
+ static cleanAnimationClip(clip: THREE.AnimationClip, model: THREE.Object3D, silent?: boolean): THREE.AnimationClip;
2666
+ /**
2667
+ * Process all skinned meshes in a model to reduce influences
2668
+ */
2669
+ static optimizeModelForMobile(model: THREE.Object3D, maxInfluences?: number): void;
2670
+ /**
2671
+ * Clean all animation clips in a mixer to remove missing bone tracks
2672
+ */
2673
+ static cleanMixerAnimations(mixer: THREE.AnimationMixer, model: THREE.Object3D): void;
2674
+ /**
2675
+ * Check if running on a mobile device
2676
+ */
2677
+ static isMobile(): boolean;
2678
+ /**
2679
+ * Get recommended settings based on platform
2680
+ */
2681
+ static getRecommendedSettings(): {
2682
+ maxSkinInfluences: number;
2683
+ enableDebugLogs: boolean;
2684
+ };
2685
+ }
2686
+
2687
+ /**
2688
+ * Configuration for spline debug visualization
2689
+ */
2690
+ interface SplineDebugConfig {
2691
+ showWaypoints?: boolean;
2692
+ showCurve?: boolean;
2693
+ showDirection?: boolean;
2694
+ waypointSize?: number;
2695
+ waypointColor?: THREE.Color;
2696
+ curveColor?: THREE.Color;
2697
+ }
2698
+ /**
2699
+ * Global manager for spline debug visualization
2700
+ * Allows centralized control of debug rendering for all splines
2701
+ */
2702
+ declare class SplineDebugManager {
2703
+ private static instance;
2704
+ private registrations;
2705
+ private debugEnabled;
2706
+ private defaultConfig;
2707
+ private constructor();
2708
+ /**
2709
+ * Get the singleton instance
2710
+ */
2711
+ static getInstance(): SplineDebugManager;
2712
+ /**
2713
+ * Register a spline for debug visualization
2714
+ */
2715
+ registerSpline(spline: SplineThree, config?: SplineDebugConfig): void;
2716
+ /**
2717
+ * Unregister a spline from debug visualization
2718
+ */
2719
+ unregisterSpline(spline: SplineThree): void;
2720
+ /**
2721
+ * Enable debug visualization for all registered splines
2722
+ */
2723
+ setDebugEnabled(enabled: boolean): void;
2724
+ /**
2725
+ * Check if debug is currently enabled
2726
+ */
2727
+ isDebugEnabled(): boolean;
2728
+ /**
2729
+ * Get the number of registered splines
2730
+ */
2731
+ getRegisteredCount(): number;
2732
+ /**
2733
+ * Create debug visualization for a specific spline
2734
+ */
2735
+ private createDebugVisualization;
2736
+ /**
2737
+ * Destroy debug visualization for a specific spline
2738
+ */
2739
+ private destroyDebugVisualization;
2740
+ /**
2741
+ * Update configuration for the default debug visualization
2742
+ */
2743
+ setDefaultConfig(config: SplineDebugConfig): void;
2744
+ /**
2745
+ * Clear all registrations (useful for cleanup/testing)
2746
+ */
2747
+ clear(): void;
2748
+ }
2749
+
2750
+ interface SplinePointThree {
2751
+ position: THREE.Vector3;
2752
+ index: number;
2753
+ }
2754
+ interface SplineSegmentThree {
2755
+ startPoint: SplinePointThree;
2756
+ endPoint: SplinePointThree;
2757
+ length: number;
2758
+ }
2759
+ declare enum SplineTypeThree {
2760
+ LINEAR = "linear",
2761
+ CATMULL_ROM = "catmull_rom",
2762
+ BEZIER = "bezier"
2763
+ }
2764
+ interface SplineConfigThree {
2765
+ type: SplineTypeThree;
2766
+ resolution: number;
2767
+ tension?: number;
2768
+ closed?: boolean;
2769
+ }
2770
+ /**
2771
+ * A flexible spline system for Three.js that can create smooth curves through waypoints
2772
+ */
2773
+ declare class SplineThree {
2774
+ private waypoints;
2775
+ private config;
2776
+ private interpolatedPoints;
2777
+ private segments;
2778
+ private totalLength;
2779
+ private cumulativeDistances;
2780
+ private debugEnabled;
2781
+ private debugConfig;
2782
+ constructor(config?: SplineConfigThree);
2783
+ /**
2784
+ * Set the waypoints for the spline
2785
+ */
2786
+ setWaypoints(waypoints: THREE.Vector3[]): void;
2787
+ /**
2788
+ * Get a point along the spline at parameter t (0-1)
2789
+ */
2790
+ getPointAt(t: number): THREE.Vector3;
2791
+ /**
2792
+ * Get the direction (tangent) at parameter t (0-1)
2793
+ */
2794
+ getDirectionAt(t: number): THREE.Vector3;
2795
+ /**
2796
+ * Convert a distance along the spline to a t parameter (0-1)
2797
+ * Uses the cumulative distance lookup table for accurate distance-based parameterization
2798
+ */
2799
+ private getTFromDistance;
2800
+ /**
2801
+ * Get a point at a specific distance from the start
2802
+ * This now uses proper distance-based parameterization
2803
+ */
2804
+ getPointAtDistance(distance: number): THREE.Vector3;
2805
+ /**
2806
+ * Get the direction (tangent) at a specific distance from the start
2807
+ * This now uses proper distance-based parameterization
2808
+ */
2809
+ getDirectionAtDistance(distance: number): THREE.Vector3;
2810
+ /**
2811
+ * Find the closest point on the spline to a given position
2812
+ */
2813
+ getClosestPoint(position: THREE.Vector3): {
2814
+ point: THREE.Vector3;
2815
+ t: number;
2816
+ distance: number;
2817
+ };
2818
+ /**
2819
+ * Get the total length of the spline
2820
+ */
2821
+ getTotalLength(): number;
2822
+ /**
2823
+ * Get all interpolated points
2824
+ */
2825
+ getInterpolatedPoints(): THREE.Vector3[];
2826
+ /**
2827
+ * Get the original waypoints (not interpolated points)
2828
+ */
2829
+ getWaypoints(): THREE.Vector3[];
2830
+ /**
2831
+ * Get the segments of the spline
2832
+ */
2833
+ getSegments(): SplineSegmentThree[];
2834
+ /**
2835
+ * Position a GameObject at parameter t along the spline with proper rotation
2836
+ */
2837
+ setGameObjectAt(gameObject: any, t: number): void;
2838
+ /**
2839
+ * Generate the spline interpolation
2840
+ */
2841
+ private generateSpline;
2842
+ /**
2843
+ * Generate linear interpolation between waypoints
2844
+ */
2845
+ private generateLinearSpline;
2846
+ /**
2847
+ * Generate Catmull-Rom spline interpolation
2848
+ */
2849
+ private generateCatmullRomSpline;
2850
+ /**
2851
+ * Catmull-Rom interpolation function
2852
+ */
2853
+ private catmullRomInterpolate;
2854
+ /**
2855
+ * Generate Bezier spline (simplified - using quadratic Bezier)
2856
+ */
2857
+ private generateBezierSpline;
2858
+ /**
2859
+ * Quadratic Bezier interpolation
2860
+ */
2861
+ private quadraticBezier;
2862
+ /**
2863
+ * Calculate segments between interpolated points
2864
+ */
2865
+ private calculateSegments;
2866
+ /**
2867
+ * Calculate total length of the spline and build cumulative distance lookup table
2868
+ */
2869
+ private calculateTotalLength;
2870
+ /**
2871
+ * Enable debug visualization for this spline
2872
+ */
2873
+ enableDebug(config?: SplineDebugConfig): void;
2874
+ /**
2875
+ * Disable debug visualization for this spline
2876
+ */
2877
+ disableDebug(): void;
2878
+ /**
2879
+ * Check if debug is enabled for this spline
2880
+ */
2881
+ isDebugEnabled(): boolean;
2882
+ /**
2883
+ * Get the debug configuration for this spline
2884
+ */
2885
+ getDebugConfig(): SplineDebugConfig | undefined;
2886
+ /**
2887
+ * Dispose of the spline and unregister from debug manager
2888
+ */
2889
+ dispose(): void;
2890
+ }
2891
+
2892
+ interface SplineDebugOptionsThree {
2893
+ showWaypoints?: boolean;
2894
+ showCurve?: boolean;
2895
+ showDirection?: boolean;
2896
+ waypointSize?: number;
2897
+ waypointColor?: THREE.Color;
2898
+ curveColor?: THREE.Color;
2899
+ directionColor?: THREE.Color;
2900
+ directionLength?: number;
2901
+ directionSpacing?: number;
2902
+ }
2903
+ /**
2904
+ * Three.js component for debugging and visualizing splines
2905
+ */
2906
+ declare class SplineDebugRendererThree extends Component {
2907
+ private spline;
2908
+ private options;
2909
+ private waypointMeshes;
2910
+ private curveLine;
2911
+ private directionArrows;
2912
+ private parentGroup;
2913
+ constructor(spline: SplineThree, options?: SplineDebugOptionsThree);
2914
+ protected onCreate(): void;
2915
+ protected onCleanup(): void;
2916
+ update(deltaTime: number): void;
2917
+ /**
2918
+ * Update the visualization (call this if the spline changes)
2919
+ */
2920
+ refresh(): void;
2921
+ /**
2922
+ * Show or hide waypoints
2923
+ */
2924
+ setShowWaypoints(show: boolean): void;
2925
+ /**
2926
+ * Show or hide the curve
2927
+ */
2928
+ setShowCurve(show: boolean): void;
2929
+ /**
2930
+ * Show or hide direction arrows
2931
+ */
2932
+ setShowDirection(show: boolean): void;
2933
+ /**
2934
+ * Create all debug visualization elements
2935
+ */
2936
+ private createDebugVisualization;
2937
+ /**
2938
+ * Create waypoint spheres
2939
+ */
2940
+ private createWaypoints;
2941
+ /**
2942
+ * Create the curve line
2943
+ */
2944
+ private createCurve;
2945
+ /**
2946
+ * Create direction arrows along the spline
2947
+ */
2948
+ private createDirectionArrows;
2949
+ /**
2950
+ * Create a single direction arrow
2951
+ */
2952
+ private createArrow;
2953
+ /**
2954
+ * Clear all visualization elements
2955
+ */
2956
+ private clearVisualization;
2957
+ }
2958
+
2959
+ declare const AudioSystem: AudioSystemInstance;
2960
+ declare const Main2DAudioBank: AudioBank2D;
2961
+ declare const Main3DAudioBank: AudioBank3D;
2962
+ type AudioSystemInstance = {
2963
+ mainListener: THREE.AudioListener | null;
2964
+ initialize(): void;
2965
+ };
2966
+ type AudioBank2D = {
2967
+ [key: string]: THREE.Audio;
2968
+ };
2969
+ type AudioBank3D = {
2970
+ [key: string]: THREE.PositionalAudio;
2971
+ };
2972
+ type AudioClip2DConfig = {
2973
+ path: string;
2974
+ volume?: number;
2975
+ };
2976
+ type AudioClip3DConfig = {
2977
+ path: string;
2978
+ volume?: number;
2979
+ };
2980
+ declare function PopulateAudioBank2D(systemInstance: AudioSystemInstance, audioBank: AudioBank2D, clips: AudioClip2DConfig[]): Promise<void>;
2981
+ declare function PopulateAudioBank3D(systemInstance: AudioSystemInstance, audioBank: AudioBank3D, clips: AudioClip3DConfig[]): Promise<void>;
2982
+ declare function PlayAudioOneShot2D(audioBank: AudioBank2D, audioClip: string): void;
2983
+ /**
2984
+ * Play a random 2D audio clip from the provided list.
2985
+ * Only clips that exist and are loaded in the provided bank will be considered.
2986
+ * Returns the clip name that was played.
2987
+ */
2988
+ declare function PlayAudioRandom2D(audioBank: AudioBank2D, clipNames: string[]): string;
2989
+ declare function PlayAudioOneShot3D(audioBank: AudioBank3D, audioClip: string, parentObject: THREE.Object3D): void;
2990
+ /** Set global master volume using Three.js AudioListener */
2991
+ declare function SetMasterVolume(volume: number): void;
2992
+ /** Get the last set (intended) master volume [0..1]. */
2993
+ declare function GetMasterVolume(): number;
2994
+ /** Toggle global mute using Three.js AudioListener */
2995
+ declare function SetAudioMuted(muted: boolean): void;
2996
+ /** Check if audio is currently muted globally. */
2997
+ declare function IsAudioMuted(): boolean;
2998
+
2999
+ /**
3000
+ * A simple 2D audio component that can be attached to any GameObject.
3001
+ * Provides easy access to play 2D audio clips from a configured bank.
3002
+ */
3003
+ declare class Audio2D extends Component {
3004
+ private audioBank;
3005
+ private availableClips;
3006
+ /**
3007
+ * Creates a new Audio2D component
3008
+ * @param availableClips - Array of clip names this component can play (optional - if not provided, can play any clip in the bank)
3009
+ */
3010
+ constructor(availableClips?: string[]);
3011
+ /**
3012
+ * Play a 2D audio clip
3013
+ * @param clipName - Name/path of the audio clip to play
3014
+ */
3015
+ play(clipName: string): void;
3016
+ /**
3017
+ * Check if a clip is available and loaded
3018
+ * @param clipName - Name/path of the audio clip to check
3019
+ */
3020
+ isClipReady(clipName: string): boolean;
3021
+ /**
3022
+ * Get list of available clips (if configured)
3023
+ */
3024
+ getAvailableClips(): string[];
3025
+ /**
3026
+ * Add a clip to the available clips list
3027
+ * @param clipName - Name/path of the audio clip to add
3028
+ */
3029
+ addAvailableClip(clipName: string): void;
3030
+ /**
3031
+ * Remove a clip from the available clips list
3032
+ * @param clipName - Name/path of the audio clip to remove
3033
+ */
3034
+ removeAvailableClip(clipName: string): void;
3035
+ protected onCreate(): void;
3036
+ protected onCleanup(): void;
3037
+ }
3038
+ /**
3039
+ * A 2D audio component that plays a random clip from a provided list.
3040
+ * Uses the main 2D audio bank.
3041
+ */
3042
+ declare class RandomAudio2D extends Component {
3043
+ private audioBank;
3044
+ private clipNames;
3045
+ private avoidImmediateRepeat;
3046
+ private lastPlayed;
3047
+ /**
3048
+ * @param clipNames - List of clip paths to randomly play (must be in Main2DAudioBank)
3049
+ * @param avoidImmediateRepeat - If true, avoids choosing the same clip twice in a row when possible
3050
+ */
3051
+ constructor(clipNames: string[], avoidImmediateRepeat?: boolean);
3052
+ /**
3053
+ * Play a random clip from the list. Returns the chosen clip name.
3054
+ */
3055
+ play(): string;
3056
+ /** Replace the internal clip list. */
3057
+ setClips(clipNames: string[]): void;
3058
+ /** Get the internal clip list. */
3059
+ getClips(): string[];
3060
+ /** Add a single clip to the list. */
3061
+ addClip(clipName: string): void;
3062
+ /** Remove a single clip from the list. */
3063
+ removeClip(clipName: string): void;
3064
+ /** Check if all clips are present (and at least one is loaded) in the bank. */
3065
+ isReady(): boolean;
3066
+ protected onCreate(): void;
3067
+ protected onCleanup(): void;
3068
+ }
3069
+
3070
+ declare const MusicBank: MusicBankType;
3071
+ type MusicBankType = {
3072
+ [key: string]: THREE.Audio;
3073
+ };
3074
+ interface MusicSystemState {
3075
+ currentTrack: string | null;
3076
+ isPlaying: boolean;
3077
+ isPaused: boolean;
3078
+ volume: number;
3079
+ loop: boolean;
3080
+ playlist: string[];
3081
+ playlistIndex: number;
3082
+ playlistActive: boolean;
3083
+ }
3084
+ declare const MusicSystem: MusicSystemState;
3085
+ /**
3086
+ * Populate the music bank with audio files
3087
+ * @param systemInstance - The audio system instance
3088
+ * @param musicBank - The music bank to populate
3089
+ * @param musicList - Array of music file paths
3090
+ */
3091
+ declare function PopulateMusicBank(systemInstance: AudioSystemInstance, musicBank: MusicBankType, musicList: string[]): Promise<void>;
3092
+ /**
3093
+ * Play a music track
3094
+ * @param musicBank - The music bank
3095
+ * @param trackName - Name/path of the music track
3096
+ * @param loop - Whether to loop the track (default: true)
3097
+ */
3098
+ declare function PlayMusic(musicBank: MusicBankType, trackName: string, loop?: boolean): void;
3099
+ /**
3100
+ * Pause the currently playing music
3101
+ * @param musicBank - The music bank
3102
+ */
3103
+ declare function PauseMusic(musicBank: MusicBankType): void;
3104
+ /**
3105
+ * Resume the currently paused music
3106
+ * @param musicBank - The music bank
3107
+ */
3108
+ declare function ResumeMusic(musicBank: MusicBankType): void;
3109
+ /**
3110
+ * Stop the currently playing music
3111
+ * @param musicBank - The music bank
3112
+ */
3113
+ declare function StopMusic(musicBank: MusicBankType): void;
3114
+ /**
3115
+ * Set the volume for music playback
3116
+ * @param volume - Volume level (0.0 to 1.0)
3117
+ * @param musicBank - The music bank
3118
+ */
3119
+ declare function SetMusicVolume(volume: number, musicBank: MusicBankType): void;
3120
+ /**
3121
+ * Toggle music playback (play/pause)
3122
+ * @param musicBank - The music bank
3123
+ */
3124
+ declare function ToggleMusic(musicBank: MusicBankType): void;
3125
+ /**
3126
+ * Check if a music track is ready to play
3127
+ * @param musicBank - The music bank
3128
+ * @param trackName - Name/path of the music track
3129
+ */
3130
+ declare function IsMusicReady(musicBank: MusicBankType, trackName: string): boolean;
3131
+ /**
3132
+ * Get the current music system state
3133
+ */
3134
+ declare function GetMusicSystemState(): MusicSystemState;
3135
+ /**
3136
+ * Crossfade to a new music track
3137
+ * @param musicBank - The music bank
3138
+ * @param newTrackName - Name/path of the new music track
3139
+ * @param fadeDuration - Duration of the crossfade in milliseconds (default: 2000ms)
3140
+ * @param loop - Whether to loop the new track (default: true)
3141
+ */
3142
+ declare function CrossfadeToMusic(musicBank: MusicBankType, newTrackName: string, fadeDuration?: number, loop?: boolean): void;
3143
+ /**
3144
+ * Start music with automatic handling of browser autoplay policies
3145
+ * This utility function tries to play music immediately, and if blocked by autoplay policy,
3146
+ * it sets up event listeners to start music on first user interaction.
3147
+ *
3148
+ * @param musicBank - The music bank
3149
+ * @param trackName - Name/path of the music track to play
3150
+ * @param loop - Whether to loop the track (default: true)
3151
+ */
3152
+ declare function StartMusicWithAutoplayHandling(musicBank: MusicBankType, trackName: string, loop?: boolean): void;
3153
+ /**
3154
+ * Start playing a playlist of tracks in rotation
3155
+ * @param musicBank - The music bank
3156
+ * @param trackNames - Array of track names to play in rotation
3157
+ * @param startIndex - Index to start from (default: 0)
3158
+ */
3159
+ declare function StartPlaylist(musicBank: MusicBankType, trackNames: string[], startIndex?: number): void;
3160
+ /**
3161
+ * Stop the playlist and reset state
3162
+ * @param musicBank - The music bank
3163
+ */
3164
+ declare function StopPlaylist(musicBank: MusicBankType): void;
3165
+ /**
3166
+ * Start playlist with automatic handling of browser autoplay policies
3167
+ * @param musicBank - The music bank
3168
+ * @param trackNames - Array of track names to play in rotation
3169
+ */
3170
+ declare function StartPlaylistWithAutoplayHandling(musicBank: MusicBankType, trackNames: string[]): void;
3171
+
3172
+ /**
3173
+ * Configuration for loading from build.json.
3174
+ */
3175
+ interface StowKitLoadConfig {
3176
+ /**
3177
+ * Material converter function - called when cloning meshes.
3178
+ * Game provides this to apply custom materials (e.g., toon shaders).
3179
+ * If not provided, materials are used as-is.
3180
+ */
3181
+ materialConverter?: (material: THREE.Material) => THREE.Material;
3182
+ /**
3183
+ * Function to fetch blob data from CDN.
3184
+ * Required for loading packs from mount paths.
3185
+ */
3186
+ fetchBlob: (path: string) => Promise<Blob>;
3187
+ /**
3188
+ * Decoder paths for StowKit loaders.
3189
+ */
3190
+ decoderPaths?: {
3191
+ basis?: string;
3192
+ draco?: string;
3193
+ wasm?: string;
3194
+ };
3195
+ }
3196
+ /**
3197
+ * StowKitSystem - Simple asset loading from build.json.
3198
+ *
3199
+ * Usage:
3200
+ * ```typescript
3201
+ * // Load everything from build.json - that's it!
3202
+ * const prefabs = await StowKitSystem.getInstance().loadFromBuildJson(buildJson, {
3203
+ * materialConverter: (mat) => MaterialUtils.convertToToon(mat),
3204
+ * fetchBlob: (path) => RundotGameAPI.cdn.fetchBlob(path)
3205
+ * })
3206
+ *
3207
+ * // Register instancing batches (optional, for frequently spawned items)
3208
+ * await StowKitSystem.getInstance().registerMeshForInstancing("burger", "restaurant_display_Burger", 100)
3209
+ *
3210
+ * // Use prefabs - meshes load automatically
3211
+ * const burgerStation = PrefabLoader.instantiate(prefabs.getPrefabByName("burger_station"))
3212
+ * ```
3213
+ */
3214
+ declare class StowKitSystem {
3215
+ private static _instance;
3216
+ private materialConverter?;
3217
+ private decoderPaths;
3218
+ private fetchBlob?;
3219
+ private packs;
3220
+ private meshes;
3221
+ private textures;
3222
+ private animations;
3223
+ private audioFiles;
3224
+ private _prefabCollection;
3225
+ private loadMeshPromises;
3226
+ private loadTexturePromises;
3227
+ private loadAudioPromises;
3228
+ private loadAnimationPromises;
3229
+ private constructor();
3230
+ static getInstance(): StowKitSystem;
3231
+ /**
3232
+ * Get the material converter function (if configured).
3233
+ */
3234
+ getMaterialConverter(): ((material: THREE.Material) => THREE.Material) | undefined;
3235
+ /**
3236
+ * Load everything from build.json.
3237
+ * This is the main entry point - loads prefab collection and all packs from mounts.
3238
+ *
3239
+ * @param buildJson The build.json content (import directly or fetch)
3240
+ * @param config Configuration including material converter and CDN fetch function
3241
+ * @returns The loaded PrefabCollection
3242
+ */
3243
+ loadFromBuildJson(buildJson: unknown, config: StowKitLoadConfig): Promise<PrefabCollection>;
3244
+ /**
3245
+ * Load an additional pack by path.
3246
+ * Use this for packs not referenced in prefab mounts (e.g., character packs).
3247
+ *
3248
+ * @param alias Unique alias for this pack
3249
+ * @param path CDN path to the .stow file
3250
+ */
3251
+ loadPack(alias: string, path: string): Promise<void>;
3252
+ /**
3253
+ * Get the prefab collection.
3254
+ */
3255
+ getPrefabCollection(): PrefabCollection;
3256
+ /**
3257
+ * Get a prefab node by path from the "restaurant" prefab.
3258
+ * Convenience method for game code.
3259
+ */
3260
+ getPrefab(path: string): PrefabNode;
3261
+ /**
3262
+ * Get a loaded pack by alias.
3263
+ */
3264
+ getPack(alias: string): StowKitPack | null;
3265
+ /**
3266
+ * Check if a pack is loaded.
3267
+ */
3268
+ isPackLoaded(alias: string): boolean;
3269
+ /**
3270
+ * Get a mesh by name. Loads on-demand if not cached.
3271
+ * For synchronous access, use getMeshSync() after ensuring it's loaded.
3272
+ */
3273
+ getMesh(name: string): Promise<THREE.Group>;
3274
+ /**
3275
+ * Get a mesh synchronously. Returns null if not loaded yet.
3276
+ */
3277
+ getMeshSync(name: string): THREE.Group | null;
3278
+ /**
3279
+ * Check if a mesh is loaded.
3280
+ */
3281
+ isMeshLoaded(name: string): boolean;
3282
+ private loadMeshFromPacks;
3283
+ /**
3284
+ * Load a skinned mesh (for characters).
3285
+ */
3286
+ getSkinnedMesh(name: string, scale?: number): Promise<THREE.Group>;
3287
+ private loadSkinnedMeshFromPacks;
3288
+ /**
3289
+ * Clone a mesh with material conversion and shadow settings.
3290
+ */
3291
+ cloneMesh(meshName: string, castShadow?: boolean, receiveShadow?: boolean): Promise<THREE.Group>;
3292
+ /**
3293
+ * Clone an already-loaded mesh synchronously.
3294
+ */
3295
+ cloneMeshSync(original: THREE.Group, castShadow?: boolean, receiveShadow?: boolean): THREE.Group;
3296
+ /**
3297
+ * Get a texture by name. Loads on-demand if not cached.
3298
+ */
3299
+ getTexture(name: string): Promise<THREE.Texture>;
3300
+ /**
3301
+ * Get a texture synchronously. Returns null if not loaded yet.
3302
+ */
3303
+ getTextureSync(name: string): THREE.Texture | null;
3304
+ private loadTextureFromPacks;
3305
+ /**
3306
+ * Get an animation by name. Loads on-demand if not cached.
3307
+ * @param name Animation name
3308
+ * @param meshName Mesh to load animation with (required for first load)
3309
+ */
3310
+ getAnimation(name: string, meshName?: string): Promise<THREE.AnimationClip>;
3311
+ /**
3312
+ * Get an animation synchronously. Returns null if not loaded yet.
3313
+ */
3314
+ getAnimationSync(name: string): THREE.AnimationClip | null;
3315
+ /**
3316
+ * Get all loaded animations.
3317
+ */
3318
+ getAllAnimations(): Map<string, THREE.AnimationClip>;
3319
+ private loadAnimationFromPacks;
3320
+ /**
3321
+ * Get audio by name. Loads on-demand if not cached.
3322
+ */
3323
+ getAudio(name: string): Promise<THREE.Audio>;
3324
+ /**
3325
+ * Get audio synchronously. Returns null if not loaded yet.
3326
+ */
3327
+ getAudioSync(name: string): THREE.Audio | null;
3328
+ /**
3329
+ * Get all loaded audio.
3330
+ */
3331
+ getAllAudio(): Map<string, THREE.Audio>;
3332
+ private loadAudioFromPacks;
3333
+ /**
3334
+ * Register a mesh for GPU instancing.
3335
+ * Batch auto-grows as needed, so initialCapacity is optional.
3336
+ */
3337
+ registerMeshForInstancing(batchKey: string, meshName: string, castShadow?: boolean, receiveShadow?: boolean, initialCapacity?: number): Promise<boolean>;
3338
+ /**
3339
+ * Register a batch for GPU instancing from a prefab.
3340
+ * Extracts the mesh name from the prefab's stow_mesh component.
3341
+ * Batch auto-grows as needed, so initialCapacity is optional.
3342
+ */
3343
+ registerBatchFromPrefab(prefabName: string, castShadow?: boolean, receiveShadow?: boolean, initialCapacity?: number): Promise<boolean>;
3344
+ private extractGeometry;
3345
+ private createMaterial;
3346
+ /**
3347
+ * Get bounds of a mesh group.
3348
+ */
3349
+ getBounds(meshGroup: THREE.Group): THREE.Vector3;
3350
+ /**
3351
+ * Dispose of all loaded assets and reset the system.
3352
+ */
3353
+ dispose(): void;
3354
+ }
3355
+
3356
+ export { type AABB, type ActiveTransition, AmbientLightComponent, AnimationConsoleFilter, AnimationControllerComponent, AnimationCullingManager, type AnimationCurve, AnimationEvent, AnimationGraphComponent, AnimationLibrary, AnimationLibraryComponent, AnimationPerformance, AnimationVisualizerComponent, Animatrix, AnimatrixVisualizer, Audio2D, type AudioBank2D, type AudioBank3D, type AudioClip2DConfig, type AudioClip3DConfig, AudioSystem, type AudioSystemInstance, type BlendTreeConfig, BlendType, BoxColliderComponent, type BurstConfig, CharacterAnimationController, type ClipInfo, ComparisonOperator, ComponentJSON, CrossfadeToMusic, type CurveKeyframe, CurvePresets, type CurveableValue, DEFAULT_KEY_BINDINGS, DebugPanelThree, DirectionalLightComponent, DynamicNavSystem, Easing, type EmissionConfig, type EmitterAssets, type EmitterConfig, EmitterShape, type EmitterShapeKey, type FlipConfig, type Footprint, GetMasterVolume, GetMusicSystemState, Input, InputAction, InputManager, IsAudioMuted, IsMusicReady, Main2DAudioBank, Main3DAudioBank, MaterialUtils, MathUtil, MeshColliderComponent, MusicBank, type MusicBankType, MusicSystem, type MusicSystemState, NavAgent, NavigationGrid, type NoiseConfig, type NumRange, type Parameter, ParameterType, Particle, type ParticleSystem, ParticleSystemPrefabComponent, PathVisualizationThree, type PathfindingResult, PauseMusic, PhysicsSystem, PlayAudioOneShot2D, PlayAudioOneShot3D, PlayAudioRandom2D, PlayMusic, PopulateAudioBank2D, PopulateAudioBank3D, PopulateMusicBank, Prefab, PrefabCollection, PrefabCollectionJSON, PrefabComponent, PrefabComponentConstructor, PrefabInstance, type PrefabInstantiateOptions, PrefabJSON, PrefabLoader, PrefabNode, RandomAudio2D, type RenderMode, RenderingDebugger, ResumeMusic, RigidBodyComponentThree, SecondOrderDynamics, SecondOrderDynamics1D, SetAudioMuted, SetMasterVolume, SetMusicVolume, SharedAnimationManager, type SplineConfigThree, type SplineDebugConfig, SplineDebugManager, type SplineDebugOptionsThree, SplineDebugRendererThree, type SplinePointThree, type SplineSegmentThree, SplineThree, SplineTypeThree, StartMusicWithAutoplayHandling, StartPlaylist, StartPlaylistWithAutoplayHandling, StopMusic, StopPlaylist, type StowKitLoadConfig, StowKitSystem, ToggleMusic, type TransitionCondition, type TransitionConfig$1 as TransitionConfig, Tween, TweenSystem, type UIElement, UILoadingScreen, type UIProgressBar, UISystem, UIUtils, type UIWorldElement, type Waypoint, addKeyframe, cloneCurve, createCurveFromPoints, createKeyframe, createParticleEmitter, evaluateCurve, evaluateCurveableValue, range, removeKeyframe, updateKeyframe };