babylonjs-addons 8.29.0 → 8.29.2

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.
@@ -2,6 +2,1319 @@
2
2
  declare module ADDONS {
3
3
 
4
4
 
5
+ /**
6
+ * Recast injection type
7
+ */
8
+ export type RecastInjection = any;
9
+ /**
10
+ * Off-mesh connection data
11
+ */
12
+ export interface IOffMeshConnection {
13
+ /**
14
+ * The start position of the off-mesh connection.
15
+ */
16
+ startPosition: BABYLON.IVector3Like;
17
+ /**
18
+ * The end position of the off-mesh connection.
19
+ */
20
+ endPosition: BABYLON.IVector3Like;
21
+ /**
22
+ * The radius of the off-mesh connection.
23
+ */
24
+ radius: number;
25
+ /**
26
+ * The type of the off-mesh connection.
27
+ */
28
+ bidirectional: boolean;
29
+ /**
30
+ * The area type of the off-mesh connection.
31
+ */
32
+ area: number;
33
+ /**
34
+ * The flags of the off-mesh connection.
35
+ */
36
+ flags: number;
37
+ /**
38
+ * The user ID of the off-mesh connection.
39
+ * @remarks This can be used to associate the off-mesh connection with a specific user
40
+ */
41
+ userId?: number;
42
+ }
43
+ /**
44
+ * Result of a navigation mesh creation.
45
+ */
46
+ export type CreateNavMeshResult = BABYLON.Nullable<{
47
+ /**
48
+ * Navigation mesh
49
+ */
50
+ navMesh: any;
51
+ /**
52
+ * Navigation mesh query
53
+ */
54
+ navMeshQuery: any;
55
+ /**
56
+ * Intermediates generated during the any creation process.
57
+ * @remarks This is only available if the `keepIntermediates` parameter is set to true in the `INavMeshParametersV2`.
58
+ * It can be used for debugging or visualization purposes.
59
+ */
60
+ intermediates?: GeneratorIntermediates;
61
+ /**
62
+ * Tile cache generated during the any creation process.
63
+ * @remarks This is only available if the `maxObstacles` parameter is set to a value greater than 0 in the `INavMeshParametersV2`. Defaults `maxObstacles` to 128.
64
+ * It can be used for obstacle avoidance and dynamic navigation mesh updates.
65
+ * @see {@link INavMeshParametersV2}
66
+ */
67
+ tileCache?: any;
68
+ }>;
69
+ /**
70
+ * Agent parameters
71
+ * For actual limits and default values check the recast-navigation-js docs.
72
+ * @see https://docs.recast-navigation-js.isaacmason.com/types/index.CrowdAgentParams.html
73
+ */
74
+ export interface IAgentParametersV2 extends BABYLON.IAgentParameters {
75
+ /**
76
+ * Flags that impact steering behavior.
77
+ */
78
+ updateFlags: number;
79
+ /**
80
+ * The index of the avoidance configuration to use for the agent. [Limits: 0 to #DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS inclusive]
81
+ */
82
+ obstacleAvoidanceType: number;
83
+ /**
84
+ * The index of the query filter used by this agent.
85
+ */
86
+ queryFilterType: number;
87
+ /**
88
+ * User defined data attached to the agent.
89
+ */
90
+ userData: unknown;
91
+ }
92
+ /**
93
+ * any parameters
94
+ * For actual limits and default values check the recast-navigation-js docs.
95
+ * @see https://docs.recast-navigation-js.isaacmason.com/types/index.RecastConfig.html
96
+ */
97
+ export interface INavMeshParametersV2 extends BABYLON.INavMeshParameters {
98
+ /**
99
+ * OffMeshConnections - Teleports
100
+ */
101
+ offMeshConnections?: IOffMeshConnection[];
102
+ /**
103
+ * Whether to keep intermediate navigation mesh data for debug visualization. Default is false.
104
+ */
105
+ keepIntermediates?: boolean;
106
+ /**
107
+ * The maximum number of obstacles that can be added to the navigation mesh. Default is 32.
108
+ * If this value is greater then 0, the navigation mesh will be generated with a tile cache.
109
+ */
110
+ maxObstacles?: number;
111
+ /**
112
+ * The size of each tile in the tiled navigation mesh. Default is 32.
113
+ */
114
+ expectedLayersPerTile?: number;
115
+ /**
116
+ * Function which is sets the polyAreas and polyFlags for the tile cache mesh. Defaults to a function that sets all areas to 0 and flags to 1.
117
+ */
118
+ tileCacheMeshProcess?: any;
119
+ }
120
+ /**
121
+ * Result of a steer target computation.
122
+ */
123
+ export type SteerTargetResult = {
124
+ /**
125
+ * Indicates whether the steering target computation was successful.
126
+ */
127
+ success: false;
128
+ } | {
129
+ /**
130
+ * Indicates whether the steering target computation was successful.
131
+ */
132
+ success: true;
133
+ /**
134
+ * The position to steer towards.
135
+ */
136
+ steerPos: BABYLON.Vector3;
137
+ /**
138
+ * The flag indicating the type of steering position.
139
+ */
140
+ steerPosFlag: number;
141
+ /**
142
+ * The reference to the polygon that the steering position is associated with.
143
+ */
144
+ steerPosRef: number;
145
+ /**
146
+ * The points that make up the path to the steering position.
147
+ */
148
+ points: BABYLON.Vector3[];
149
+ };
150
+ /**
151
+ * Error types for path computation.
152
+ */
153
+ export var ComputePathError: {
154
+ START_NEAREST_POLY_FAILED: string;
155
+ END_NEAREST_POLY_FAILED: string;
156
+ FIND_PATH_FAILED: string;
157
+ NO_POLYGON_PATH_FOUND: string;
158
+ NO_CLOSEST_POINT_ON_LAST_POLYGON_FOUND: string;
159
+ };
160
+ export type ComputePathErrorType = (typeof ComputePathError)[keyof typeof ComputePathError];
161
+ /**
162
+ * Result of a path computation.
163
+ */
164
+ export type ComputePathResult = {
165
+ /**
166
+ * Indicates whether the path computation was successful.
167
+ */
168
+ success: boolean;
169
+ /**
170
+ * The error message if the path computation failed.
171
+ */
172
+ error?: {
173
+ /**
174
+ * A descriptive error message.
175
+ */
176
+ name?: string;
177
+ /**
178
+ * The type of error that occurred during path computation.
179
+ * @remarks This will be one of the values from `ComputePathError`
180
+ */
181
+ type?: ComputePathErrorType;
182
+ /**
183
+ * Statusring describing the error.
184
+ */
185
+ status?: number;
186
+ };
187
+ /**
188
+ * The computed path as an array of BABYLON.Vector3 points.
189
+ */
190
+ path: BABYLON.IVector3Like[];
191
+ };
192
+ /**
193
+ * Intermediates generated during the any creation process.
194
+ * @remarks This is only available if the `keepIntermediates` parameter is set to true in the `INavMeshParametersV2`.
195
+ * It can be used for debugging or visualization purposes.
196
+ */
197
+ export type GeneratorIntermediates = any | any | any | null;
198
+
199
+
200
+
201
+
202
+ /**
203
+ * Generates a navigation mesh in a web worker.
204
+ */
205
+ export function GenerateNavMeshWorker(): void;
206
+
207
+
208
+
209
+
210
+ /**
211
+ * Navigation plugin for Babylon.js. It is a simple wrapper around the recast-navigation-js library. Not all features are implemented.
212
+ * @remarks This plugin provides navigation mesh generation and pathfinding capabilities using the recast-navigation-js library
213
+ * @remarks It supports both single-threaded and multi-threaded generation of navigation meshes.
214
+ * @remarks The plugin can be used to create navigation meshes from meshes in a scene, compute paths, and manage crowd agents, etc.
215
+ * @remarks It also provides methods for creating obstacles and querying the navigation mesh.
216
+ * @see https://github.com/isaac-mason/recast-navigation-js
217
+ */
218
+ export class RecastNavigationJSPluginV2 implements BABYLON.INavigationEnginePlugin {
219
+ /**
220
+ * Creates a navigation mesh - will be injected by the factory
221
+ * @param meshes array of all the geometry used to compute the navigation mesh
222
+ * @param parameters bunch of parameters used to filter geometry
223
+ * @returns the created navmesh and navmesh query
224
+ */
225
+ createNavMeshImpl: (meshes: Array<BABYLON.Mesh>, parameters: INavMeshParametersV2) => CreateNavMeshResult;
226
+ /**
227
+ * Creates a navigation mesh - will be injected by the factory
228
+ * @param meshes array of all the geometry used to compute the navigation mesh
229
+ * @param parameters bunch of parameters used to filter geometry
230
+ * @returns the created navmesh and navmesh query
231
+ */
232
+ createNavMeshAsyncImpl: (meshes: Array<BABYLON.Mesh>, parameters: INavMeshParametersV2) => Promise<CreateNavMeshResult>;
233
+ /**
234
+ * recast-navigation-js injection
235
+ */
236
+ bjsRECAST: RecastInjection;
237
+ /**
238
+ * plugin name
239
+ */
240
+ name: string;
241
+ /**
242
+ * the navmesh created
243
+ */
244
+ navMesh?: any;
245
+ /**
246
+ * The navmesh query created from the navmesh
247
+ * @remarks This is used to query the navmesh for pathfinding and other navigation tasks
248
+ */
249
+ get navMeshQuery(): any;
250
+ private _navMeshQuery;
251
+ /**
252
+ * Intermediates generated during the navmesh creation
253
+ * @remarks This is used for debugging and visualization purposes.
254
+ * @remarks You have access to vertices, indices and vertex colors to visusalize the navmesh creation process.
255
+ * @remarks This is only available if the `keepIntermediates` parameter is set
256
+ * @remarks to true during navmesh generation.
257
+ */
258
+ private _intermediates?;
259
+ /**
260
+ * Gets the intermediates generated during the navmesh creation
261
+ * @returns The generator intermediates, or undefined if not available
262
+ */
263
+ get intermediates(): GeneratorIntermediates | undefined;
264
+ /**
265
+ * Tile cache used for tiled navigation meshes
266
+ * @remarks This is used to store and manage tiles of the navigation mesh for efficient path and when obstacles are used.
267
+ */
268
+ private _tileCache?;
269
+ /**
270
+ * Gets the tile cache used for tiled navigation meshes
271
+ * @returns The tile cache instance, or undefined if not available
272
+ */
273
+ get tileCache(): any | undefined;
274
+ private _maximumSubStepCount;
275
+ private _timeStep;
276
+ private _timeFactor;
277
+ private _crowd?;
278
+ /**
279
+ * Creates a RecastNavigationJSPluginV2 instance
280
+ * @param recastInjection The recast-navigation-js injection containing core and generators
281
+ */
282
+ constructor(recastInjection?: RecastInjection);
283
+ /**
284
+ * Set the time step of the navigation tick update.
285
+ * Default is 1/60.
286
+ * A value of 0 will disable fixed time update
287
+ * @param newTimeStep the new timestep to apply to this world.
288
+ */
289
+ setTimeStep(newTimeStep?: number): void;
290
+ /**
291
+ * Get the time step of the navigation tick update.
292
+ * @returns the current time step
293
+ */
294
+ getTimeStep(): number;
295
+ /**
296
+ * If delta time in navigation tick update is greater than the time step
297
+ * a number of sub iterations are done. If more iterations are need to reach deltatime
298
+ * they will be discarded.
299
+ * A value of 0 will set to no maximum and update will use as many substeps as needed
300
+ * @param newStepCount the maximum number of iterations
301
+ */
302
+ setMaximumSubStepCount(newStepCount?: number): void;
303
+ /**
304
+ * Get the maximum number of iterations per navigation tick update
305
+ * @returns the maximum number of iterations
306
+ */
307
+ getMaximumSubStepCount(): number;
308
+ /**
309
+ * Time factor applied when updating crowd agents (default 1). A value of 0 will pause crowd updates.
310
+ * @param value the time factor applied at update
311
+ */
312
+ set timeFactor(value: number);
313
+ /**
314
+ * Get the time factor used for crowd agent update
315
+ * @returns the time factor
316
+ */
317
+ get timeFactor(): number;
318
+ /**
319
+ * Creates a navigation mesh - will be injected by the factory
320
+ * @param meshes array of all the geometry used to compute the navigation mesh
321
+ * @param parameters bunch of parameters used to filter geometry
322
+ * @returns the created navmesh and navmesh query
323
+ * @throws Error if the function is not injected yet or if the navmesh is not created
324
+ */
325
+ createNavMesh(meshes: Array<BABYLON.Mesh>, parameters: INavMeshParametersV2): CreateNavMeshResult;
326
+ /**
327
+ * Creates a navigation mesh asynchronously - will be injected by the factory
328
+ * @param meshes array of all the geometry used to compute the navigation mesh
329
+ * @param parameters bunch of parameters used to filter geometry
330
+ * @returns the created navmesh and navmesh query
331
+ * @throws Error if the function is not injected yet or if the navmesh is not created
332
+ */
333
+ createNavMeshAsync(meshes: Array<BABYLON.Mesh>, parameters: INavMeshParametersV2): Promise<CreateNavMeshResult>;
334
+ /**
335
+ * Create a navigation mesh debug mesh
336
+ * @param scene is where the mesh will be added
337
+ * @returns debug display mesh
338
+ */
339
+ createDebugNavMesh(scene: BABYLON.Scene): BABYLON.Mesh;
340
+ /**
341
+ * Get a navigation mesh constrained position, closest to the parameter position
342
+ * @param position world position
343
+ * @returns the closest point to position constrained by the navigation mesh
344
+ */
345
+ getClosestPoint(position: BABYLON.IVector3Like, options?: {
346
+ /**
347
+ * The polygon filter to apply to the query.
348
+ */
349
+ filter?: any;
350
+ /**
351
+ * Half extents for the search box
352
+ */
353
+ halfExtents?: BABYLON.IVector3Like;
354
+ }): BABYLON.Vector3;
355
+ /**
356
+ * Get a navigation mesh constrained position, closest to the parameter position
357
+ * @param position world position
358
+ * @param result output the closest point to position constrained by the navigation mesh
359
+ */
360
+ getClosestPointToRef(position: BABYLON.IVector3Like, result: BABYLON.Vector3, options?: {
361
+ /**
362
+ * The polygon filter to apply to the query.
363
+ */
364
+ filter?: any;
365
+ /**
366
+ * Half extents for the search box
367
+ */
368
+ halfExtents?: BABYLON.IVector3Like;
369
+ }): void;
370
+ /**
371
+ * Get a navigation mesh constrained position, within a particular radius
372
+ * @param position world position
373
+ * @param maxRadius the maximum distance to the constrained world position
374
+ * @returns the closest point to position constrained by the navigation mesh
375
+ */
376
+ getRandomPointAround(position: BABYLON.IVector3Like, maxRadius: number, options?: {
377
+ startRef?: number;
378
+ /**
379
+ * The polygon filter to apply to the query.
380
+ */
381
+ filter?: any;
382
+ /**
383
+ * Half extents for the search box
384
+ */
385
+ halfExtents?: BABYLON.IVector3Like;
386
+ }): BABYLON.Vector3;
387
+ /**
388
+ * Get a navigation mesh constrained position, within a particular radius
389
+ * @param position world position
390
+ * @param maxRadius the maximum distance to the constrained world position
391
+ * @param result output the closest point to position constrained by the navigation mesh
392
+ */
393
+ getRandomPointAroundToRef(position: BABYLON.IVector3Like, maxRadius: number, result: BABYLON.Vector3, options?: {
394
+ startRef?: number;
395
+ /**
396
+ * The polygon filter to apply to the query.
397
+ */
398
+ filter?: any;
399
+ /**
400
+ * Half extents for the search box
401
+ */
402
+ halfExtents?: BABYLON.IVector3Like;
403
+ }): void;
404
+ /**
405
+ * Compute the final position from a segment made of destination-position
406
+ * @param position position to start from
407
+ * @param destination position to go to
408
+ * @param startRef the reference id of the start polygon
409
+ * @param options options for the function
410
+ * @returns the resulting point along the navmesh
411
+ */
412
+ moveAlong(position: BABYLON.IVector3Like, destination: BABYLON.IVector3Like, startRef?: number, options?: {
413
+ /**
414
+ * The polygon filter to apply to the query.
415
+ */
416
+ filter?: any;
417
+ /**
418
+ * The maximum number of polygons the output visited array can hold.
419
+ */
420
+ maxVisitedSize?: number;
421
+ }): BABYLON.Vector3;
422
+ /**
423
+ * Compute the final position from a segment made of destination-position
424
+ * @param position world position
425
+ * @param destination world position
426
+ * @param result output the resulting point along the navmesh
427
+ * @param startRef the reference id of the start polygon.
428
+ * @param options options for the function
429
+ */
430
+ moveAlongToRef(position: BABYLON.IVector3Like, destination: BABYLON.IVector3Like, result: BABYLON.Vector3, startRef?: number, options?: {
431
+ /**
432
+ * The polygon filter to apply to the query.
433
+ */
434
+ filter?: any;
435
+ maxVisitedSize?: number;
436
+ }): void;
437
+ /**
438
+ * Compute a navigation path from start to end. Returns an empty array if no path can be computed
439
+ * Path is straight.
440
+ * @param start world position
441
+ * @param end world position
442
+ * @param options options for the function
443
+ * @returns array containing world position composing the path
444
+ */
445
+ computePath(start: BABYLON.IVector3Like, end: BABYLON.IVector3Like, options?: {
446
+ /**
447
+ * The polygon filter to apply to the query.
448
+ */
449
+ filter?: any;
450
+ /**
451
+ * Half extents for the search box
452
+ */
453
+ halfExtents?: BABYLON.IVector3Like;
454
+ maxPathPolys?: number;
455
+ maxStraightPathPoints?: number;
456
+ }): BABYLON.Vector3[];
457
+ /**
458
+ * Creates a navigation mesh - will be injected by the factory
459
+ * @param start the start position of the navmesh
460
+ * @param end the end position of the navmesh
461
+ * @param options options to configure the path computation
462
+ * @returns array containing world position composing the path
463
+ */
464
+ computePathSmooth(start: BABYLON.Vector3, end: BABYLON.Vector3, options?: {
465
+ /**
466
+ * The polygon filter to apply to the query.
467
+ */
468
+ filter?: any;
469
+ /**
470
+ * Half extents for the search box
471
+ */
472
+ halfExtents?: BABYLON.IVector3Like;
473
+ maxPathPolys?: number;
474
+ maxSmoothPathPoints?: number;
475
+ stepSize?: number;
476
+ slop?: number;
477
+ }): BABYLON.Vector3[];
478
+ /**
479
+ * Create a new Crowd so you can add agents
480
+ * @param maxAgents the maximum agent count in the crowd
481
+ * @param maxAgentRadius the maximum radius an agent can have
482
+ * @param scene to attach the crowd to
483
+ * @returns the crowd you can add agents to
484
+ */
485
+ createCrowd(maxAgents: number, maxAgentRadius: number, scene: BABYLON.Scene): BABYLON.ICrowd;
486
+ /**
487
+ * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
488
+ * The queries will try to find a solution within those bounds
489
+ * default is (1,1,1)
490
+ * @param extent x,y,z value that define the extent around the queries point of reference
491
+ */
492
+ setDefaultQueryExtent(extent: BABYLON.IVector3Like): void;
493
+ /**
494
+ * Get the Bounding box extent specified by setDefaultQueryExtent
495
+ * @returns the box extent values
496
+ */
497
+ getDefaultQueryExtent(): BABYLON.Vector3;
498
+ /**
499
+ * Get the Bounding box extent result specified by setDefaultQueryExtent
500
+ * @param result output the box extent values
501
+ */
502
+ getDefaultQueryExtentToRef(result: BABYLON.Vector3): void;
503
+ /**
504
+ * build the navmesh from a previously saved state using getNavmeshData
505
+ * @param data the Uint8Array returned by getNavmeshData
506
+ */
507
+ buildFromNavmeshData(data: Uint8Array): void;
508
+ /**
509
+ * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
510
+ * @returns data the Uint8Array that can be saved and reused
511
+ */
512
+ getNavmeshData(): Uint8Array;
513
+ /**
514
+ * build the tile cache from a previously saved state using getTileCacheData
515
+ * @param tileCacheData the data returned by getTileCacheData
516
+ * @param tileCacheMeshProcess optional process to apply to each tile created
517
+ */
518
+ buildFromTileCacheData(tileCacheData: Uint8Array, tileCacheMeshProcess?: any): void;
519
+ /**
520
+ * returns the tile cache data that can be used later. The tile cache must be built before retrieving the data
521
+ * @returns the tile cache data that can be used later. The tile cache must be built before retrieving the data
522
+ * @throws Error if there is no any generated
523
+ * @remarks The returned data can be used to rebuild the tile cache later using buildFromTileCacheData
524
+ */
525
+ getTileCacheData(): Uint8Array;
526
+ /**
527
+ * Disposes
528
+ */
529
+ dispose(): void;
530
+ /**
531
+ * Creates a cylinder obstacle and add it to the navigation
532
+ * @param position world position
533
+ * @param radius cylinder radius
534
+ * @param height cylinder height
535
+ * @param doNotWaitForCacheUpdate if true the function will not wait for the tile cache to be fully updated before returning
536
+ * @returns the obstacle freshly created
537
+ */
538
+ addCylinderObstacle(position: BABYLON.IVector3Like, radius: number, height: number, doNotWaitForCacheUpdate?: boolean): BABYLON.Nullable<BABYLON.IObstacle>;
539
+ /**
540
+ * Creates an oriented box obstacle and add it to the navigation
541
+ * @param position world position
542
+ * @param extent box size
543
+ * @param angle angle in radians of the box orientation on Y axis
544
+ * @param doNotWaitForCacheUpdate if true the function will not wait for the tile cache to be fully updated before returning
545
+ * @returns the obstacle freshly created
546
+ */
547
+ addBoxObstacle(position: BABYLON.IVector3Like, extent: BABYLON.IVector3Like, angle: number, doNotWaitForCacheUpdate?: boolean): BABYLON.Nullable<BABYLON.IObstacle>;
548
+ /**
549
+ * Removes an obstacle created by addCylinderObstacle or addBoxObstacle
550
+ * @param obstacle obstacle to remove from the navigation
551
+ * @param doNotWaitForCacheUpdate if true the function will not wait for the tile cache to be fully updated before returning
552
+ *
553
+ */
554
+ removeObstacle(obstacle: BABYLON.IObstacle, doNotWaitForCacheUpdate?: boolean): void;
555
+ /**
556
+ * If this plugin is supported
557
+ * @returns true if plugin is supported
558
+ */
559
+ isSupported(): boolean;
560
+ /**
561
+ * Returns the seed used for randomized functions like `getRandomPointAround`
562
+ * @returns seed number
563
+ */
564
+ getRandomSeed(): number;
565
+ /**
566
+ * Set the seed used for randomized functions like `getRandomPointAround`
567
+ * @param seed number used as seed for random functions
568
+ */
569
+ setRandomSeed(seed: number): void;
570
+ /**
571
+ * Perform a raycast on the navmesh
572
+ * @param start start position
573
+ * @param end end position
574
+ * @returns if a direct path exists between start and end, and the hit point if any
575
+ */
576
+ raycast(start: BABYLON.IVector3Like, end: BABYLON.IVector3Like): {
577
+ hit: boolean;
578
+ hitPoint?: undefined;
579
+ } | {
580
+ hit: boolean;
581
+ hitPoint: BABYLON.Vector3;
582
+ };
583
+ /**
584
+ * Compute the final position from a segment made of destination-position, and return the height of the polygon
585
+ * This is a more sophisiticated version of moveAlong that will use the height of the polygon at the end position
586
+ * @param position world position to start from
587
+ * @param velocity wvelocity of the movement
588
+ * @param options options for the function
589
+ * @returns the resulting point along the navmesh, the polygon reference id and the height of the polygon
590
+ */
591
+ moveAlongWithVelocity(position: BABYLON.IVector3Like, velocity: BABYLON.IVector3Like, options?: {
592
+ /**
593
+ * The polygon filter to apply to the query.
594
+ */
595
+ filter?: any;
596
+ /**
597
+ * Half extents for the search box
598
+ */
599
+ halfExtents?: BABYLON.IVector3Like;
600
+ /**
601
+ * The maximum number of polygons the output visited array can hold.
602
+ */
603
+ maxVisitedSize?: number;
604
+ }): {
605
+ position: {
606
+ x: number;
607
+ y: number;
608
+ z: number;
609
+ };
610
+ polyRef: number;
611
+ height: number;
612
+ };
613
+ /**
614
+ * Handles common post-processing and validation of navmesh creation results
615
+ * @param result The partial result from navmesh creation
616
+ * @returns The validated and complete CreateNavMeshresult
617
+ */
618
+ private _processNavMeshResult;
619
+ private _preprocessParameters;
620
+ }
621
+
622
+
623
+ /**
624
+ * Recast Detour crowd implementation
625
+ * This class provides methods to manage a crowd of agents, allowing them to navigate a navigation mesh.
626
+ * It supports adding agents, updating their parameters, moving them to destinations, and checking their states.
627
+ * The crowd is updated in the scene's animation loop, and it notifies observers when agents reach their destinations.
628
+ */
629
+ export class RecastJSCrowd implements BABYLON.ICrowd {
630
+ /**
631
+ * Recast plugin
632
+ */
633
+ get navigationPlugin(): RecastNavigationJSPluginV2;
634
+ /**
635
+ * Link to the detour crowd
636
+ */
637
+ get recastCrowd(): any;
638
+ /**
639
+ * One transform per agent
640
+ */
641
+ get transforms(): BABYLON.TransformNode[];
642
+ /**
643
+ * All agents created
644
+ */
645
+ get agents(): readonly number[];
646
+ /**
647
+ * Agents reach radius
648
+ */
649
+ get reachRadii(): readonly number[];
650
+ private _navigationPlugin;
651
+ private _recastCrowd;
652
+ private _transforms;
653
+ private _agents;
654
+ private _reachRadii;
655
+ /**
656
+ * true when a destination is active for an agent and notifier hasn't been notified of reach
657
+ */
658
+ private _agentDestinationArmed;
659
+ /**
660
+ * agent current target
661
+ */
662
+ private _agentDestination;
663
+ /**
664
+ * Link to the scene is kept to unregister the crowd from the scene
665
+ */
666
+ private _scene;
667
+ private _engine;
668
+ /**
669
+ * Observer for crowd updates
670
+ */
671
+ private _onBeforeAnimationsObserver;
672
+ /**
673
+ * Fires each time an agent is in reach radius of its destination
674
+ */
675
+ onReachTargetObservable: BABYLON.Observable<{
676
+ /**
677
+ *
678
+ */
679
+ agentIndex: number;
680
+ /**
681
+ *
682
+ */
683
+ destination: BABYLON.Vector3;
684
+ }>;
685
+ /**
686
+ * Constructor
687
+ * @param plugin recastJS plugin
688
+ * @param maxAgents the maximum agent count in the crowd
689
+ * @param maxAgentRadius the maximum radius an agent can have
690
+ * @param scene to attach the crowd to
691
+ * @returns the crowd you can add agents to
692
+ */
693
+ constructor(plugin: RecastNavigationJSPluginV2, maxAgents: number, maxAgentRadius: number, scene: BABYLON.Scene);
694
+ /**
695
+ * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
696
+ * You can attach anything to that node. The node position is updated in the scene update tick.
697
+ * @param pos world position that will be constrained by the navigation mesh
698
+ * @param parameters agent parameters
699
+ * @param transform hooked to the agent that will be update by the scene
700
+ * @returns agent index
701
+ */
702
+ addAgent(pos: BABYLON.IVector3Like, parameters: IAgentParametersV2, transform: BABYLON.TransformNode): number;
703
+ /**
704
+ * Returns the agent position in world space
705
+ * @param index agent index returned by addAgent
706
+ * @returns world space position
707
+ */
708
+ getAgentPosition(index: number): BABYLON.Vector3;
709
+ /**
710
+ * Returns the agent position result in world space
711
+ * @param index agent index returned by addAgent
712
+ * @param result output world space position
713
+ */
714
+ getAgentPositionToRef(index: number, result: BABYLON.Vector3): void;
715
+ /**
716
+ * Returns the agent velocity in world space
717
+ * @param index agent index returned by addAgent
718
+ * @returns world space velocity
719
+ */
720
+ getAgentVelocity(index: number): BABYLON.Vector3;
721
+ /**
722
+ * Returns the agent velocity result in world space
723
+ * @param index agent index returned by addAgent
724
+ * @param result output world space velocity
725
+ */
726
+ getAgentVelocityToRef(index: number, result: BABYLON.Vector3): void;
727
+ /**
728
+ * Returns the agent next target point on the path
729
+ * @param index agent index returned by addAgent
730
+ * @returns world space position
731
+ */
732
+ getAgentNextTargetPath(index: number): BABYLON.Vector3;
733
+ /**
734
+ * Returns the agent next target point on the path
735
+ * @param index agent index returned by addAgent
736
+ * @param result output world space position
737
+ */
738
+ getAgentNextTargetPathToRef(index: number, result: BABYLON.Vector3): void;
739
+ /**
740
+ * Gets the agent state
741
+ * @param index agent index returned by addAgent
742
+ * @returns agent state, 0 = DT_CROWDAGENT_STATE_INVALID, 1 = DT_CROWDAGENT_STATE_WALKING, 2 = DT_CROWDAGENT_STATE_OFFMESH
743
+ */
744
+ getAgentState(index: number): number;
745
+ /**
746
+ * returns true if the agent in over an off mesh link connection
747
+ * @param index agent index returned by addAgent
748
+ * @returns true if over an off mesh link connection
749
+ */
750
+ overOffmeshConnection(index: number): boolean;
751
+ /**
752
+ * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
753
+ * @param index agent index returned by addAgent
754
+ * @param destination targeted world position
755
+ */
756
+ agentGoto(index: number, destination: BABYLON.IVector3Like): void;
757
+ /**
758
+ * Teleport the agent to a new position
759
+ * @param index agent index returned by addAgent
760
+ * @param destination targeted world position
761
+ */
762
+ agentTeleport(index: number, destination: BABYLON.IVector3Like): void;
763
+ /**
764
+ * Update agent parameters
765
+ * @param index agent index returned by addAgent
766
+ * @param parameters agent parameters
767
+ */
768
+ updateAgentParameters(index: number, parameters: IAgentParametersV2): void;
769
+ /**
770
+ * remove a particular agent previously created
771
+ * @param index agent index returned by addAgent
772
+ */
773
+ removeAgent(index: number): void;
774
+ /**
775
+ * get the list of all agents attached to this crowd
776
+ * @returns list of agent indices
777
+ */
778
+ getAgents(): number[];
779
+ /**
780
+ * Tick update done by the BABYLON.Scene. Agent position/velocity/acceleration is updated by this function
781
+ * @param deltaTime in seconds
782
+ */
783
+ update(deltaTime: number): void;
784
+ /**
785
+ * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
786
+ * The queries will try to find a solution within those bounds
787
+ * default is (1,1,1)
788
+ * @param extent x,y,z value that define the extent around the queries point of reference
789
+ */
790
+ setDefaultQueryExtent(extent: BABYLON.IVector3Like): void;
791
+ /**
792
+ * Get the Bounding box extent specified by setDefaultQueryExtent
793
+ * @returns the box extent values
794
+ */
795
+ getDefaultQueryExtent(): BABYLON.Vector3;
796
+ /**
797
+ * Get the Bounding box extent result specified by setDefaultQueryExtent
798
+ * @param result output the box extent values
799
+ */
800
+ getDefaultQueryExtentToRef(result: BABYLON.Vector3): void;
801
+ /**
802
+ * Get the next corner points composing the path (max 4 points)
803
+ * @param index agent index returned by addAgent
804
+ * @returns array containing world position composing the path
805
+ */
806
+ getCorners(index: number): BABYLON.Vector3[];
807
+ /**
808
+ * Release all resources
809
+ */
810
+ dispose(): void;
811
+ }
812
+
813
+
814
+ /**
815
+ * Injects the navigation mesh generation methods into the navigation plugin.
816
+ * @param navigationPlugin The navigation plugin to inject the methods into.
817
+ */
818
+ export function InjectGenerators(navigationPlugin: RecastNavigationJSPluginV2): void;
819
+
820
+
821
+
822
+
823
+ /**
824
+ * IMPORTANT!
825
+ * This file is still under construction and will change in the future.
826
+ * Workers are not yet supported.
827
+ * For more info visit: https://forum.babylonjs.com/t/replacing-recastjs-with-recast-navigation-js/56003/46
828
+ */
829
+ /**
830
+ * Builds a any and any from meshes using provided parameters.
831
+ * @param meshes The array of meshes used to create the any
832
+ * @param parameters The parameters used to configure the any generation.
833
+ * @param workerOptions Options for the worker, including a completion callback and the worker instance.
834
+ * @throws Error if the any data is invalid or cannot be deserialized.
835
+ */
836
+ export function GenerateNavMeshWithWorker(meshes: Array<BABYLON.Mesh>, parameters: INavMeshParametersV2, workerOptions: {
837
+ /**
838
+ * Completion callback that is called when the any generation is complete.
839
+ * @param navMesh The generated any
840
+ * @param navMeshQuery The any associated with the generated any
841
+ * @param tileCache Optional any if tile cache generation was used.
842
+ */
843
+ completion: (navMesh: any, navMeshQuery: any, tileCache?: any) => void;
844
+ /**
845
+ * Worker instance used for asynchronous any generation.
846
+ */
847
+ worker: Worker;
848
+ }): void;
849
+
850
+
851
+ /**
852
+ * Builds a NavMesh and NavMeshQuery from meshes using provided parameters.
853
+ * @param meshes The array of meshes used to create the NavMesh.
854
+ * @param parameters The parameters used to configure the NavMesh generation.
855
+ * @returns An object containing the NavMesh and NavMeshQuery.
856
+ * @remarks This function generates a NavMesh based on the provided meshes and parameters.
857
+ * It supports different configurations such as solo, tiled, and tile cache nav meshes.
858
+ * If you need obstacles, ensure that `maxObstacles` is set to a value greater than 0.
859
+ * Recommended values for `tileSize` are between 32 and 64 when using obstacles/tile cache.
860
+ * If you need a tiled nav mesh, ensure that `tileSize` is set to a value greater than 0.
861
+ * @throws Error if the NavMesh data is invalid or cannot be deserialized.
862
+ */
863
+ export function GenerateNavMesh(meshes: Array<BABYLON.Mesh>, parameters: INavMeshParametersV2): {
864
+ navMesh: any;
865
+ intermediates: any;
866
+ navMeshQuery: any;
867
+ tileCache: any;
868
+ };
869
+
870
+
871
+ /**
872
+ * Builds a NavMesh and NavMeshQuery from serialized data.
873
+ * @param data The serialized NavMesh data.
874
+ * @returns An object containing the NavMesh and NavMeshQuery.
875
+ * @remarks This function deserializes the NavMesh data and creates a NavMeshQuery
876
+ * instance for querying the NavMesh.
877
+ * @throws Error if the NavMesh data is invalid or cannot be deserialized.
878
+ */
879
+ export function BuildFromNavmeshData(data: Uint8Array): {
880
+ navMesh: any;
881
+ navMeshQuery: any;
882
+ tileCache: undefined;
883
+ };
884
+ /**
885
+ * Builds a TileCache and NavMeshQuery from serialized data.
886
+ * @param data The serialized TileCache data.
887
+ * @param tileCacheMeshProcess Optional function to process the TileCache mesh.
888
+ * @returns An object containing the TileCache, NavMesh, and NavMeshQuery.
889
+ */
890
+ export function BuildFromTileCacheData(data: Uint8Array, tileCacheMeshProcess: any): {
891
+ navMesh: any;
892
+ navMeshQuery: any;
893
+ tileCache: any;
894
+ };
895
+
896
+
897
+
898
+
899
+ /**
900
+ * Creates a navigation plugin for the given scene using a worker.
901
+ * @returns A promise that resolves to the created navigation plugin.
902
+ * @remarks This function initializes the Recast module and sets up the navigation plugin to use a worker.
903
+ * The worker is used to handle the creation of the navigation mesh asynchronously.
904
+ * The `createNavMesh` method is not supported in worker mode, use `createNavMeshAsync` instead.
905
+ */
906
+ export function CreateNavigationPluginWorkerAsync(): Promise<RecastNavigationJSPluginV2>;
907
+
908
+
909
+ /**
910
+ * Creates a navigation plugin for the given scene.
911
+ * @returns A promise that resolves to the created navigation plugin.
912
+ * @remarks This function initializes the Recast module and sets up the navigation plugin.
913
+ */
914
+ export function CreateNavigationPluginAsync(): Promise<RecastNavigationJSPluginV2>;
915
+
916
+
917
+ /**
918
+ * Gets the RecastInjection instance (reference to the recast-navigation-js library).
919
+ * @returns The RecastInjection instance
920
+ * @throws Error if Recast is not initialized
921
+ */
922
+ export function GetRecast(): RecastInjection;
923
+ /**
924
+ * Sets the RecastInjection instance (reference to the recast-navigation-js library).
925
+ * @param recast The RecastInjection instance to set
926
+ */
927
+ export function SetRecast(recast: RecastInjection): void;
928
+ /**
929
+ * Initialize the Manifold library
930
+ * @param version defines the version of the library to use, default is "0.43.0"
931
+ * @param options defines the options to use to initialize the library
932
+ */
933
+ export function InitRecast(version?: string, options?: {
934
+ instance: RecastInjection;
935
+ }): Promise<void>;
936
+
937
+
938
+ /**
939
+ * Creates a debug mesh for visualizing a any in the scene.
940
+ * @param navMesh The any to visualize.
941
+ * @param scene The scene in which to create the debug mesh.
942
+ * @param parent Optional parent node for the debug mesh.
943
+ * @param flags Poly flags to filter by, defaults to undefined to include all polys
944
+ * @returns The created debug mesh.
945
+ */
946
+ export function CreateDebugNavMesh(navMesh: any, scene: BABYLON.Scene, parent?: BABYLON.Node, flags?: number): BABYLON.Mesh;
947
+
948
+
949
+
950
+
951
+ export var DebugLayerOption: {
952
+ HEIGHTFIELD_SOLID: string;
953
+ HEIGHTFIELD_WALKABLE: string;
954
+ COMPACT_HEIGHTFIELD_SOLID: string;
955
+ COMPACT_HEIGHTFIELD_REGIONS: string;
956
+ COMPACT_HEIGHTFIELD_DISTANCE: string;
957
+ RAW_CONTOURS: string;
958
+ CONTOURS: string;
959
+ POLY_MESH: string;
960
+ POLY_MESH_DETAIL: string;
961
+ NAVMESH: string;
962
+ NAVMESH_BV_TREE: string;
963
+ };
964
+ export type DebugLayerOptions = (typeof DebugLayerOption)[keyof typeof DebugLayerOption];
965
+ /**
966
+ * NavigationDebugger is a utility class for visualizing navigation meshes and related data in a Babylon.js scene.
967
+ * It provides methods to draw various navigation-related primitives such as points, lines, triangles, and quads.
968
+ * It also supports drawing heightfields, compact heightfields, contours, poly meshes, and nav meshes.
969
+ */
970
+ export class NavigationDebugger {
971
+ private _scene;
972
+ /**
973
+ * The name of the debug mesh used for navigation debugging.
974
+ * This is used to group all navigation debug meshes under a single name for easier management
975
+ */
976
+ static NAV_MESH_DEBUG_NAME: string;
977
+ /**
978
+ * The name of the debug mesh used for visualization of the navigation mesh using points.
979
+ */
980
+ static NAV_MESH_DEBUG_NAME_POINTS: string;
981
+ /**
982
+ * The name of the debug mesh used for visualization of the navigation mesh using triangles.
983
+ */
984
+ static NAV_MESH_DEBUG_NAME_TRIS: string;
985
+ /**
986
+ * The name of the debug mesh used for visualization of the navigation mesh using quads.
987
+ */
988
+ static NAV_MESH_DEBUG_NAME_QUADS: string;
989
+ /**
990
+ * The name of the debug mesh used for visualization of the navigation mesh using lines.
991
+ */
992
+ static NAV_MESH_DEBUG_NAME_LINES: string;
993
+ /**
994
+ * The material used for rendering triangles in the navigation debug visualization.
995
+ */
996
+ triMaterial: BABYLON.StandardMaterial;
997
+ /**
998
+ * The material used for rendering points in the navigation debug visualization.
999
+ */
1000
+ pointMaterial: BABYLON.StandardMaterial;
1001
+ /**
1002
+ * The list of line materials used in the navigation debug visualization.
1003
+ */
1004
+ lineMaterials: BABYLON.StandardMaterial[];
1005
+ /**
1006
+ * The parent node for the debug drawer.
1007
+ */
1008
+ debugDrawerParentNode: BABYLON.TransformNode;
1009
+ /**
1010
+ * * Gets or sets the primitive types to be drawn by the debug drawer.
1011
+ * * This allows you to control which types of primitives (points, lines, tris, quads) are rendered in the navigation debug visualization.
1012
+ * * The default value is `["points", "lines", "tris", "quads"]`.
1013
+ * * You can modify this property to include or exclude specific primitive types based on your debugging needs.
1014
+ * @returns An array of primitive types that the debug drawer will render.
1015
+ */
1016
+ get primitiveTypes(): any;
1017
+ set primitiveTypes(value: any);
1018
+ private _lineMaterialOptions;
1019
+ private _pointMesh;
1020
+ private _debugDrawerUtils;
1021
+ private _primitiveTypes;
1022
+ constructor(_scene: BABYLON.Scene, options?: {
1023
+ parent?: {
1024
+ node?: BABYLON.TransformNode | string;
1025
+ };
1026
+ primitiveTypes?: any;
1027
+ materials?: {
1028
+ triMaterial?: BABYLON.StandardMaterial;
1029
+ pointMaterial?: BABYLON.StandardMaterial;
1030
+ lineMaterialOptions: {
1031
+ greasedLineMaterialOptions: Partial<BABYLON.GreasedLineMaterialOptions>;
1032
+ greasedLineMeshOptions: Partial<BABYLON.GreasedLineMeshOptions>;
1033
+ };
1034
+ };
1035
+ });
1036
+ /**
1037
+ * Resets the debug drawer by disposing of all child meshes in the debug drawer parent node.
1038
+ * This is useful for clearing the debug visualization before drawing new primitives.
1039
+ */
1040
+ clear(): void;
1041
+ /**
1042
+ * Disposes of the debug drawer, including all meshes and materials used for rendering.
1043
+ * This method should be called when the debug drawer is no longer needed to free up resources.
1044
+ */
1045
+ dispose(): void;
1046
+ /**
1047
+ * This method iterates through the provided primitives and draws them based on their type.
1048
+ * It supports drawing points, lines, triangles, and quads, depending on the primitive type.
1049
+ * @param primitives An array of debug drawer primitives to be drawn.
1050
+ * @param options Optional parameters to control the drawing behavior, such as whether to join meshes.
1051
+ */
1052
+ drawPrimitives(primitives: any, options?: {
1053
+ joinMeshes?: boolean;
1054
+ }): void;
1055
+ /**
1056
+ * Draws a heightfield as solid using the debug drawer utilities.
1057
+ * @param hf The heightfield to draw as solid.
1058
+ */
1059
+ drawHeightfieldSolid(hf: any): void;
1060
+ /**
1061
+ * Draws a heightfield as walkable using the debug drawer utilities.
1062
+ * @param hf The heightfield to draw as walkable.
1063
+ */
1064
+ drawHeightfieldWalkable(hf: any): void;
1065
+ /**
1066
+ * Draws a compact heightfield as solid using the debug drawer utilities.
1067
+ * @param chf The compact heightfield to draw as solid.
1068
+ */
1069
+ drawCompactHeightfieldSolid(chf: any): void;
1070
+ /**
1071
+ * Draws the regions of a compact heightfield using the debug drawer utilities.
1072
+ * @param chf The compact heightfield to draw regions for.
1073
+ */
1074
+ drawCompactHeightfieldRegions(chf: any): void;
1075
+ /**
1076
+ * Draws the distance field of a compact heightfield using the debug drawer utilities.
1077
+ * @param chf The compact heightfield to draw the distance for.
1078
+ */
1079
+ drawCompactHeightfieldDistance(chf: any): void;
1080
+ /**
1081
+ * Draws a heightfield layer using the debug drawer utilities.
1082
+ * @param layer The heightfield layer to draw.
1083
+ * @param idx The index of the layer to draw.
1084
+ */
1085
+ drawHeightfieldLayer(layer: any, idx: number): void;
1086
+ /**
1087
+ * Draws the layers of a heightfield using the debug drawer utilities.
1088
+ * @param lset The heightfield layer set containing the layers to draw.
1089
+ */
1090
+ drawHeightfieldLayers(lset: any): void;
1091
+ /**
1092
+ * Draws the region connections of a any using the debug drawer utilities.
1093
+ * @param cset any to draw
1094
+ * @param alpha The alpha value for the drawn contours, default is 1.
1095
+ */
1096
+ drawRegionConnections(cset: any, alpha?: number): void;
1097
+ /**
1098
+ * Draws raw contours from a any using the debug drawer utilities.
1099
+ * @param cset any to draw
1100
+ * @param alpha The alpha value for the drawn contours, default is 1.
1101
+ */
1102
+ drawRawContours(cset: any, alpha?: number): void;
1103
+ /**
1104
+ * Draws contours from a any using the debug drawer utilities.
1105
+ * @param cset any to draw
1106
+ * @param alpha The alpha value for the drawn contours, default is 1.
1107
+ */
1108
+ drawContours(cset: any, alpha?: number): void;
1109
+ /**
1110
+ * Draws a poly mesh using the debug drawer utilities.
1111
+ * @param mesh any to draw
1112
+ */
1113
+ drawPolyMesh(mesh: any): void;
1114
+ /**
1115
+ * Draws a poly mesh detail using the debug drawer utilities.
1116
+ * @param dmesh any to draw
1117
+ */
1118
+ drawPolyMeshDetail(dmesh: any): void;
1119
+ /**
1120
+ * Draws a any using the debug drawer utilities.
1121
+ * @param mesh any to draw
1122
+ * @param flags Flags to control the drawing behavior, default is 0.
1123
+ */
1124
+ drawNavMesh(mesh: any, flags?: number): void;
1125
+ /**
1126
+ * Draws a any with closed list using the debug drawer utilities.
1127
+ * @param mesh any to draw
1128
+ * @param query any to use for drawing the closed list.
1129
+ * @param flags Flags to control the drawing behavior, default is 0.
1130
+ */
1131
+ drawNavMeshWithClosedList(mesh: any, query: any, flags?: number): void;
1132
+ /**
1133
+ * Draws the nodes of a any using the debug drawer utilities.
1134
+ * @param query any to use for drawing the nodes.
1135
+ */
1136
+ drawNavMeshNodes(query: any): void;
1137
+ /**
1138
+ * Draws the bounding volume tree of a any using the debug drawer utilities.
1139
+ * @param mesh any to draw the bounding volume tree for.
1140
+ */
1141
+ drawNavMeshBVTree(mesh: any): void;
1142
+ /**
1143
+ * Draws the portals of a any using the debug drawer utilities.
1144
+ * @param mesh any to draw the portals for.
1145
+ */
1146
+ drawNavMeshPortals(mesh: any): void;
1147
+ /**
1148
+ * Draws polygons of a any with specific flags using the debug drawer utilities.
1149
+ * @param mesh any to draw the polygons with specific flags.
1150
+ * @param flags The flags to filter the polygons to be drawn.
1151
+ * @param col The color to use for the drawn polygons, represented as a number.
1152
+ */
1153
+ drawNavMeshPolysWithFlags(mesh: any, flags: number, col: number): void;
1154
+ /**
1155
+ * Draws polygons of a any with specific reference and color using the debug drawer utilities.
1156
+ * @param mesh any to draw the polygons with specific reference and color.
1157
+ * @param ref The reference number of the polygons to be drawn.
1158
+ * @param col The color to use for the drawn polygons, represented as a number.
1159
+ */
1160
+ drawNavMeshPoly(mesh: any, ref: number, col: number): void;
1161
+ /**
1162
+ * Get the intermediates from the generator
1163
+ * @param intermediates - The generator intermediates
1164
+ * @returns An object containing lists of heightfields, compact heightfields, contour sets
1165
+ */
1166
+ getIntermediates: (intermediates: GeneratorIntermediates) => {
1167
+ heightfieldList: any;
1168
+ compactHeightfieldList: any;
1169
+ contourSetList: any;
1170
+ polyMeshList: any;
1171
+ polyMeshDetailList: any;
1172
+ };
1173
+ /**
1174
+ * Draw debug information based on the selected option
1175
+ * @param navMesh - The navigation mesh to draw
1176
+ * @param intermediates - The generator intermediates containing the data to draw
1177
+ * @param scene - The scene to draw in
1178
+ * @param option - The debug drawer option to use
1179
+ * @remarks This method will reset the debug drawer before drawing.
1180
+ */
1181
+ draw(navMesh: any, intermediates: GeneratorIntermediates, scene: BABYLON.Scene, option: DebugLayerOptions): void;
1182
+ private _drawPoints;
1183
+ private _drawLines;
1184
+ private _drawTris;
1185
+ private _drawQuads;
1186
+ /**
1187
+ * Merge the debug meshes for better performance
1188
+ */
1189
+ private _joinDebugMeshes;
1190
+ private _convertUnindexedToIndexed;
1191
+ }
1192
+
1193
+
1194
+ /**
1195
+ * Utility function based on Chaikin's alogrithm for navigation path smoothing and segment generation.
1196
+ * @param points Array of points to be smoothed, where each point is an object with x, y, and z properties.
1197
+ * @param iterations Number of smoothing iterations to apply. Default 1.
1198
+ * @returns A new array of smoothed points after applying the Chaikin's algorithm.
1199
+ */
1200
+ export function GetChaikinSmoothPath(points: BABYLON.IVector3Like[], iterations?: number): BABYLON.IVector3Like[];
1201
+ /**
1202
+ * Generates a series of points that create an L-shaped path between each pair of points in the input navigation segment.
1203
+ * The path consists of a horizontal segment followed by a vertical segment, or vice versa,
1204
+ * depending on the relative distances between the x and z coordinates of the points.
1205
+ * @param navSegment An array of BABYLON.Vector3 points representing the navigation segment.
1206
+ * @returns An array of BABYLON.Vector3 points representing the L-shaped path.
1207
+ */
1208
+ export function GetLShapedPath(navSegment: BABYLON.Vector3[]): BABYLON.Vector3[];
1209
+
1210
+
1211
+ /**
1212
+ * Creates a default tile cache mesh process function
1213
+ * @param offMeshConnections offMeshConnections
1214
+ * @param area the area to be set for each poly
1215
+ * @param flags the flags to be set for each poly
1216
+ * @returns the tile cache mesh process function
1217
+ */
1218
+ export function CreateDefaultTileCacheMeshProcess(offMeshConnections?: any, area?: number, flags?: number): any;
1219
+ /**
1220
+ * Waits until the tile cache is fully updated
1221
+ * @param navMesh The any
1222
+ * @param tileCache THe any
1223
+ */
1224
+ export function WaitForFullTileCacheUpdate(navMesh: any, tileCache: any): void;
1225
+
1226
+
1227
+ /**
1228
+ * Compute a smooth navigation path from start to end. Returns an empty array if no path can be computed
1229
+ * @param navMesh the navigation mesh to use
1230
+ * @param navmeshQuery the navigation mesh query to use
1231
+ * @param start world position
1232
+ * @param end world position
1233
+ * @param options options object
1234
+ * @returns array containing world position composing the path
1235
+ */
1236
+ export function ComputeSmoothPath(navMesh: any, navmeshQuery: any, start: BABYLON.IVector3Like, end: BABYLON.IVector3Like, options?: {
1237
+ filter?: any;
1238
+ halfExtents?: BABYLON.IVector3Like;
1239
+ /**
1240
+ * @default 256
1241
+ */
1242
+ maxPathPolys?: number;
1243
+ /**
1244
+ * @default 2048
1245
+ */
1246
+ maxSmoothPathPoints?: number;
1247
+ /**
1248
+ * @default 0.5
1249
+ */
1250
+ stepSize?: number;
1251
+ /**
1252
+ * @default 0.01
1253
+ */
1254
+ slop?: number;
1255
+ }): BABYLON.Vector3[];
1256
+
1257
+
1258
+
1259
+
1260
+ /**
1261
+ * Extracts positions and indices from an array of meshes.
1262
+ * @param meshes The array of meshes from which to extract positions and indices.
1263
+ * @returns A tuple containing a Float32Array of positions and a Uint32Array of
1264
+ */
1265
+ export function GetPositionsAndIndices(meshes: BABYLON.Mesh[]): [positions: Float32Array, indices: Uint32Array];
1266
+ /**
1267
+ * Reverses the order of vertices in each triangle (3 indices per face) to ensure
1268
+ * that the winding order is consistent with the Recast Navigation requirements.
1269
+ * This is necessary because Recast Navigation expects the indices to be in a specific winding order.
1270
+ * @param meshOrIndices The mesh from which to extract indices or the indices themselves.
1271
+ * @returns Array of indices with reversed winding order.
1272
+ */
1273
+ export function GetReversedIndices(meshOrIndices: BABYLON.Mesh | Uint32Array | number[]): Uint32Array<ArrayBufferLike> | number[] | Int32Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | null;
1274
+
1275
+
1276
+ /**
1277
+ * Converts navigation path points to a BABYLON.Vector3 array.
1278
+ * @param navPath The navigation path containing points and success status.
1279
+ * @returns An array of BABYLON.Vector3 points representing the navigation path.
1280
+ */
1281
+ export function ConvertNavPathPoints(navPath: ComputePathResult): BABYLON.Vector3[];
1282
+
1283
+
1284
+ export const DefaultMaxObstacles = 128;
1285
+ /**
1286
+ * Creates a SoloNavMesh configuration based on the provided parameters.
1287
+ * @param parameters The parameters used to configure the SoloNavMesh generation.
1288
+ * @returns A configuration object for generating a SoloNavMesh.
1289
+ * @see https://docs.recast-navigation-js.isaacmason.com/types/index.RecastConfig.html
1290
+ */
1291
+ export function CreateSoloNavMeshConfig(parameters: INavMeshParametersV2): Partial<any>;
1292
+ /**
1293
+ * Creates a TiledNavMesh configuration based on the provided parameters.
1294
+ * @param parameters The parameters used to configure the TiledNavMesh generation.
1295
+ * @returns A configuration object for generating a TiledNavMesh.
1296
+ */
1297
+ export function CreateTiledNavMeshConfig(parameters: INavMeshParametersV2): Partial<any>;
1298
+ /**
1299
+ * Creates a TileCacheNavMesh configuration based on the provided parameters.
1300
+ * @param parameters The parameters used to configure the TileCacheNavMesh generation.
1301
+ * @returns A configuration object for generating a TileCacheNavMesh.
1302
+ */
1303
+ export function CreateTileCacheNavMeshConfig(parameters: INavMeshParametersV2): Partial<any>;
1304
+ /**
1305
+ * Convert IAgentParameters to Recast any
1306
+ * @param config Agent parameters
1307
+ * @returns Recast crowd agent paramaters
1308
+ */
1309
+ export function ToSoloNavMeshGeneratorConfig(config: INavMeshParametersV2): Partial<any>;
1310
+ /**
1311
+ * Convert IAgentParameters to Recast any
1312
+ * @param agentParams Agent parameters
1313
+ * @returns Recast crowd agent paramaters
1314
+ */
1315
+ export function ToCrowdAgentParams(agentParams: IAgentParametersV2): Partial<any>;
1316
+
1317
+
5
1318
  /**
6
1319
  * Abstract Node class from Babylon.js
7
1320
  */
@@ -126,6 +1439,18 @@ declare module ADDONS {
126
1439
  }
127
1440
 
128
1441
 
1442
+ export interface ISdfTextParagraphMetrics {
1443
+ /** @internal */
1444
+ readonly paragraph: string;
1445
+ /** @internal */
1446
+ readonly lines: SdfTextLine[];
1447
+ /** @internal */
1448
+ readonly width: number;
1449
+ /** @internal */
1450
+ readonly height: number;
1451
+ /** @internal */
1452
+ readonly glyphs: SdfGlyph[];
1453
+ }
129
1454
  /** @internal */
130
1455
  export type ParagraphOptions = {
131
1456
  maxWidth: number;
@@ -135,6 +1460,7 @@ declare module ADDONS {
135
1460
  whiteSpace: "pre-line";
136
1461
  textAlign: "left" | "right" | "center";
137
1462
  translate: BABYLON.IVector2Like | undefined;
1463
+ customLayoutEngine?: (text: string, options: ParagraphOptions) => ISdfTextParagraphMetrics;
138
1464
  };
139
1465
  /** @internal */
140
1466
  export var DefaultParagraphOptions: ParagraphOptions;