@onerjs/addons 8.27.1 → 8.27.3

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 (83) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +1 -0
  3. package/index.js.map +1 -1
  4. package/msdfText/paragraphOptions.d.ts +15 -0
  5. package/msdfText/paragraphOptions.js.map +1 -1
  6. package/msdfText/sdf/paragraph.js +1 -1
  7. package/msdfText/sdf/paragraph.js.map +1 -1
  8. package/navigation/common/config.d.ts +35 -0
  9. package/navigation/common/config.js +61 -0
  10. package/navigation/common/config.js.map +1 -0
  11. package/navigation/common/convert.d.ts +8 -0
  12. package/navigation/common/convert.js +22 -0
  13. package/navigation/common/convert.js.map +1 -0
  14. package/navigation/common/getters.d.ts +15 -0
  15. package/navigation/common/getters.js +76 -0
  16. package/navigation/common/getters.js.map +1 -0
  17. package/navigation/common/index.d.ts +6 -0
  18. package/navigation/common/index.js +7 -0
  19. package/navigation/common/index.js.map +1 -0
  20. package/navigation/common/smooth-path.d.ts +32 -0
  21. package/navigation/common/smooth-path.js +340 -0
  22. package/navigation/common/smooth-path.js.map +1 -0
  23. package/navigation/common/tile-cache.d.ts +15 -0
  24. package/navigation/common/tile-cache.js +32 -0
  25. package/navigation/common/tile-cache.js.map +1 -0
  26. package/navigation/common/utils.d.ts +17 -0
  27. package/navigation/common/utils.js +66 -0
  28. package/navigation/common/utils.js.map +1 -0
  29. package/navigation/debug/NavigationDebugger.d.ts +248 -0
  30. package/navigation/debug/NavigationDebugger.js +587 -0
  31. package/navigation/debug/NavigationDebugger.js.map +1 -0
  32. package/navigation/debug/index.d.ts +2 -0
  33. package/navigation/debug/index.js +3 -0
  34. package/navigation/debug/index.js.map +1 -0
  35. package/navigation/debug/simple-debug.d.ts +13 -0
  36. package/navigation/debug/simple-debug.js +23 -0
  37. package/navigation/debug/simple-debug.js.map +1 -0
  38. package/navigation/factory/common.d.ts +20 -0
  39. package/navigation/factory/common.js +80 -0
  40. package/navigation/factory/common.js.map +1 -0
  41. package/navigation/factory/factory.single-thread.d.ts +7 -0
  42. package/navigation/factory/factory.single-thread.js +15 -0
  43. package/navigation/factory/factory.single-thread.js.map +1 -0
  44. package/navigation/factory/factory.worker.d.ts +9 -0
  45. package/navigation/factory/factory.worker.js +40 -0
  46. package/navigation/factory/factory.worker.js.map +1 -0
  47. package/navigation/factory/index.d.ts +1 -0
  48. package/navigation/factory/index.js +3 -0
  49. package/navigation/factory/index.js.map +1 -0
  50. package/navigation/generator/generator.common.d.ts +25 -0
  51. package/navigation/generator/generator.common.js +40 -0
  52. package/navigation/generator/generator.common.js.map +1 -0
  53. package/navigation/generator/generator.single-thread.d.ts +20 -0
  54. package/navigation/generator/generator.single-thread.js +57 -0
  55. package/navigation/generator/generator.single-thread.js.map +1 -0
  56. package/navigation/generator/generator.worker.d.ts +29 -0
  57. package/navigation/generator/generator.worker.js +47 -0
  58. package/navigation/generator/generator.worker.js.map +1 -0
  59. package/navigation/generator/index.d.ts +3 -0
  60. package/navigation/generator/index.js +5 -0
  61. package/navigation/generator/index.js.map +1 -0
  62. package/navigation/generator/injection.d.ts +6 -0
  63. package/navigation/generator/injection.js +16 -0
  64. package/navigation/generator/injection.js.map +1 -0
  65. package/navigation/index.d.ts +5 -0
  66. package/navigation/index.js +7 -0
  67. package/navigation/index.js.map +1 -0
  68. package/navigation/plugin/RecastJSCrowd.d.ts +198 -0
  69. package/navigation/plugin/RecastJSCrowd.js +359 -0
  70. package/navigation/plugin/RecastJSCrowd.js.map +1 -0
  71. package/navigation/plugin/RecastNavigationJSPlugin.d.ts +419 -0
  72. package/navigation/plugin/RecastNavigationJSPlugin.js +482 -0
  73. package/navigation/plugin/RecastNavigationJSPlugin.js.map +1 -0
  74. package/navigation/plugin/index.d.ts +1 -0
  75. package/navigation/plugin/index.js +2 -0
  76. package/navigation/plugin/index.js.map +1 -0
  77. package/navigation/types.d.ts +199 -0
  78. package/navigation/types.js +11 -0
  79. package/navigation/types.js.map +1 -0
  80. package/navigation/worker/navmesh-worker.d.ts +4 -0
  81. package/navigation/worker/navmesh-worker.js +63 -0
  82. package/navigation/worker/navmesh-worker.js.map +1 -0
  83. package/package.json +2 -2
@@ -0,0 +1,419 @@
1
+ import type { TileCacheMeshProcess, NavMesh, QueryFilter, TileCache, NavMeshQuery } from "@recast-navigation/core";
2
+ import type { ICrowd, INavigationEnginePlugin, IObstacle } from "@onerjs/core/Navigation/INavigationEngine.js";
3
+ import type { Mesh } from "@onerjs/core/Meshes/mesh.js";
4
+ import type { Scene } from "@onerjs/core/scene.js";
5
+ import { Vector3 } from "@onerjs/core/Maths/math.js";
6
+ import type { IVector3Like } from "@onerjs/core/Maths/math.like.js";
7
+ import type { Nullable } from "@onerjs/core/types.js";
8
+ import type { CreateNavMeshResult, GeneratorIntermediates, INavMeshParametersV2, RecastInjection } from "../types.js";
9
+ /**
10
+ * Navigation plugin for Babylon.js. It is a simple wrapper around the recast-navigation-js library. Not all features are implemented.
11
+ * @remarks This plugin provides navigation mesh generation and pathfinding capabilities using the recast-navigation-js library
12
+ * @remarks It supports both single-threaded and multi-threaded generation of navigation meshes.
13
+ * @remarks The plugin can be used to create navigation meshes from meshes in a scene, compute paths, and manage crowd agents, etc.
14
+ * @remarks It also provides methods for creating obstacles and querying the navigation mesh.
15
+ * @see https://github.com/isaac-mason/recast-navigation-js
16
+ */
17
+ export declare class RecastNavigationJSPluginV2 implements INavigationEnginePlugin {
18
+ /**
19
+ * Creates a navigation mesh - will be injected by the factory
20
+ * @param meshes array of all the geometry used to compute the navigation mesh
21
+ * @param parameters bunch of parameters used to filter geometry
22
+ * @returns the created navmesh and navmesh query
23
+ */
24
+ createNavMeshImpl: (meshes: Array<Mesh>, parameters: INavMeshParametersV2) => CreateNavMeshResult;
25
+ /**
26
+ * Creates a navigation mesh - will be injected by the factory
27
+ * @param meshes array of all the geometry used to compute the navigation mesh
28
+ * @param parameters bunch of parameters used to filter geometry
29
+ * @returns the created navmesh and navmesh query
30
+ */
31
+ createNavMeshAsyncImpl: (meshes: Array<Mesh>, parameters: INavMeshParametersV2) => Promise<CreateNavMeshResult>;
32
+ /**
33
+ * recast-navigation-js injection
34
+ */
35
+ bjsRECAST: RecastInjection;
36
+ /**
37
+ * plugin name
38
+ */
39
+ name: string;
40
+ /**
41
+ * the navmesh created
42
+ */
43
+ navMesh?: NavMesh;
44
+ /**
45
+ * The navmesh query created from the navmesh
46
+ * @remarks This is used to query the navmesh for pathfinding and other navigation tasks
47
+ */
48
+ get navMeshQuery(): NavMeshQuery;
49
+ private _navMeshQuery;
50
+ /**
51
+ * Intermediates generated during the navmesh creation
52
+ * @remarks This is used for debugging and visualization purposes.
53
+ * @remarks You have access to vertices, indices and vertex colors to visusalize the navmesh creation process.
54
+ * @remarks This is only available if the `keepIntermediates` parameter is set
55
+ * @remarks to true during navmesh generation.
56
+ */
57
+ private _intermediates?;
58
+ /**
59
+ * Gets the intermediates generated during the navmesh creation
60
+ * @returns The generator intermediates, or undefined if not available
61
+ */
62
+ get intermediates(): GeneratorIntermediates | undefined;
63
+ /**
64
+ * Tile cache used for tiled navigation meshes
65
+ * @remarks This is used to store and manage tiles of the navigation mesh for efficient path and when obstacles are used.
66
+ */
67
+ private _tileCache?;
68
+ /**
69
+ * Gets the tile cache used for tiled navigation meshes
70
+ * @returns The tile cache instance, or undefined if not available
71
+ */
72
+ get tileCache(): TileCache | undefined;
73
+ private _maximumSubStepCount;
74
+ private _timeStep;
75
+ private _timeFactor;
76
+ private _crowd?;
77
+ /**
78
+ * Creates a RecastNavigationJSPluginV2 instance
79
+ * @param recastInjection The recast-navigation-js injection containing core and generators
80
+ */
81
+ constructor(recastInjection?: RecastInjection);
82
+ /**
83
+ * Set the time step of the navigation tick update.
84
+ * Default is 1/60.
85
+ * A value of 0 will disable fixed time update
86
+ * @param newTimeStep the new timestep to apply to this world.
87
+ */
88
+ setTimeStep(newTimeStep?: number): void;
89
+ /**
90
+ * Get the time step of the navigation tick update.
91
+ * @returns the current time step
92
+ */
93
+ getTimeStep(): number;
94
+ /**
95
+ * If delta time in navigation tick update is greater than the time step
96
+ * a number of sub iterations are done. If more iterations are need to reach deltatime
97
+ * they will be discarded.
98
+ * A value of 0 will set to no maximum and update will use as many substeps as needed
99
+ * @param newStepCount the maximum number of iterations
100
+ */
101
+ setMaximumSubStepCount(newStepCount?: number): void;
102
+ /**
103
+ * Get the maximum number of iterations per navigation tick update
104
+ * @returns the maximum number of iterations
105
+ */
106
+ getMaximumSubStepCount(): number;
107
+ /**
108
+ * Time factor applied when updating crowd agents (default 1). A value of 0 will pause crowd updates.
109
+ * @param value the time factor applied at update
110
+ */
111
+ set timeFactor(value: number);
112
+ /**
113
+ * Get the time factor used for crowd agent update
114
+ * @returns the time factor
115
+ */
116
+ get timeFactor(): number;
117
+ /**
118
+ * Creates a navigation mesh - will be injected by the factory
119
+ * @param meshes array of all the geometry used to compute the navigation mesh
120
+ * @param parameters bunch of parameters used to filter geometry
121
+ * @returns the created navmesh and navmesh query
122
+ * @throws Error if the function is not injected yet or if the navmesh is not created
123
+ */
124
+ createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParametersV2): CreateNavMeshResult;
125
+ /**
126
+ * Creates a navigation mesh asynchronously - will be injected by the factory
127
+ * @param meshes array of all the geometry used to compute the navigation mesh
128
+ * @param parameters bunch of parameters used to filter geometry
129
+ * @returns the created navmesh and navmesh query
130
+ * @throws Error if the function is not injected yet or if the navmesh is not created
131
+ */
132
+ createNavMeshAsync(meshes: Array<Mesh>, parameters: INavMeshParametersV2): Promise<CreateNavMeshResult>;
133
+ /**
134
+ * Create a navigation mesh debug mesh
135
+ * @param scene is where the mesh will be added
136
+ * @returns debug display mesh
137
+ */
138
+ createDebugNavMesh(scene: Scene): Mesh;
139
+ /**
140
+ * Get a navigation mesh constrained position, closest to the parameter position
141
+ * @param position world position
142
+ * @returns the closest point to position constrained by the navigation mesh
143
+ */
144
+ getClosestPoint(position: IVector3Like, options?: {
145
+ /**
146
+ * The polygon filter to apply to the query.
147
+ */
148
+ filter?: QueryFilter;
149
+ /**
150
+ * Half extents for the search box
151
+ */
152
+ halfExtents?: IVector3Like;
153
+ }): Vector3;
154
+ /**
155
+ * Get a navigation mesh constrained position, closest to the parameter position
156
+ * @param position world position
157
+ * @param result output the closest point to position constrained by the navigation mesh
158
+ */
159
+ getClosestPointToRef(position: IVector3Like, result: Vector3, options?: {
160
+ /**
161
+ * The polygon filter to apply to the query.
162
+ */
163
+ filter?: QueryFilter;
164
+ /**
165
+ * Half extents for the search box
166
+ */
167
+ halfExtents?: IVector3Like;
168
+ }): void;
169
+ /**
170
+ * Get a navigation mesh constrained position, within a particular radius
171
+ * @param position world position
172
+ * @param maxRadius the maximum distance to the constrained world position
173
+ * @returns the closest point to position constrained by the navigation mesh
174
+ */
175
+ getRandomPointAround(position: IVector3Like, maxRadius: number, options?: {
176
+ startRef?: number;
177
+ /**
178
+ * The polygon filter to apply to the query.
179
+ */
180
+ filter?: QueryFilter;
181
+ /**
182
+ * Half extents for the search box
183
+ */
184
+ halfExtents?: IVector3Like;
185
+ }): Vector3;
186
+ /**
187
+ * Get a navigation mesh constrained position, within a particular radius
188
+ * @param position world position
189
+ * @param maxRadius the maximum distance to the constrained world position
190
+ * @param result output the closest point to position constrained by the navigation mesh
191
+ */
192
+ getRandomPointAroundToRef(position: IVector3Like, maxRadius: number, result: Vector3, options?: {
193
+ startRef?: number;
194
+ /**
195
+ * The polygon filter to apply to the query.
196
+ */
197
+ filter?: QueryFilter;
198
+ /**
199
+ * Half extents for the search box
200
+ */
201
+ halfExtents?: IVector3Like;
202
+ }): void;
203
+ /**
204
+ * Compute the final position from a segment made of destination-position
205
+ * @param position position to start from
206
+ * @param destination position to go to
207
+ * @param startRef the reference id of the start polygon
208
+ * @param options options for the function
209
+ * @returns the resulting point along the navmesh
210
+ */
211
+ moveAlong(position: IVector3Like, destination: IVector3Like, startRef?: number, options?: {
212
+ /**
213
+ * The polygon filter to apply to the query.
214
+ */
215
+ filter?: QueryFilter;
216
+ /**
217
+ * The maximum number of polygons the output visited array can hold.
218
+ */
219
+ maxVisitedSize?: number;
220
+ }): Vector3;
221
+ /**
222
+ * Compute the final position from a segment made of destination-position
223
+ * @param position world position
224
+ * @param destination world position
225
+ * @param result output the resulting point along the navmesh
226
+ * @param startRef the reference id of the start polygon.
227
+ * @param options options for the function
228
+ */
229
+ moveAlongToRef(position: IVector3Like, destination: IVector3Like, result: Vector3, startRef?: number, options?: {
230
+ /**
231
+ * The polygon filter to apply to the query.
232
+ */
233
+ filter?: QueryFilter;
234
+ maxVisitedSize?: number;
235
+ }): void;
236
+ /**
237
+ * Compute a navigation path from start to end. Returns an empty array if no path can be computed
238
+ * Path is straight.
239
+ * @param start world position
240
+ * @param end world position
241
+ * @param options options for the function
242
+ * @returns array containing world position composing the path
243
+ */
244
+ computePath(start: IVector3Like, end: IVector3Like, options?: {
245
+ /**
246
+ * The polygon filter to apply to the query.
247
+ */
248
+ filter?: QueryFilter;
249
+ /**
250
+ * Half extents for the search box
251
+ */
252
+ halfExtents?: IVector3Like;
253
+ maxPathPolys?: number;
254
+ maxStraightPathPoints?: number;
255
+ }): Vector3[];
256
+ /**
257
+ * Creates a navigation mesh - will be injected by the factory
258
+ * @param start the start position of the navmesh
259
+ * @param end the end position of the navmesh
260
+ * @param options options to configure the path computation
261
+ * @returns array containing world position composing the path
262
+ */
263
+ computePathSmooth(start: Vector3, end: Vector3, options?: {
264
+ /**
265
+ * The polygon filter to apply to the query.
266
+ */
267
+ filter?: QueryFilter;
268
+ /**
269
+ * Half extents for the search box
270
+ */
271
+ halfExtents?: IVector3Like;
272
+ maxPathPolys?: number;
273
+ maxSmoothPathPoints?: number;
274
+ stepSize?: number;
275
+ slop?: number;
276
+ }): Vector3[];
277
+ /**
278
+ * Create a new Crowd so you can add agents
279
+ * @param maxAgents the maximum agent count in the crowd
280
+ * @param maxAgentRadius the maximum radius an agent can have
281
+ * @param scene to attach the crowd to
282
+ * @returns the crowd you can add agents to
283
+ */
284
+ createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
285
+ /**
286
+ * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
287
+ * The queries will try to find a solution within those bounds
288
+ * default is (1,1,1)
289
+ * @param extent x,y,z value that define the extent around the queries point of reference
290
+ */
291
+ setDefaultQueryExtent(extent: IVector3Like): void;
292
+ /**
293
+ * Get the Bounding box extent specified by setDefaultQueryExtent
294
+ * @returns the box extent values
295
+ */
296
+ getDefaultQueryExtent(): Vector3;
297
+ /**
298
+ * Get the Bounding box extent result specified by setDefaultQueryExtent
299
+ * @param result output the box extent values
300
+ */
301
+ getDefaultQueryExtentToRef(result: Vector3): void;
302
+ /**
303
+ * build the navmesh from a previously saved state using getNavmeshData
304
+ * @param data the Uint8Array returned by getNavmeshData
305
+ */
306
+ buildFromNavmeshData(data: Uint8Array): void;
307
+ /**
308
+ * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
309
+ * @returns data the Uint8Array that can be saved and reused
310
+ */
311
+ getNavmeshData(): Uint8Array;
312
+ /**
313
+ * build the tile cache from a previously saved state using getTileCacheData
314
+ * @param tileCacheData the data returned by getTileCacheData
315
+ * @param tileCacheMeshProcess optional process to apply to each tile created
316
+ */
317
+ buildFromTileCacheData(tileCacheData: Uint8Array, tileCacheMeshProcess?: TileCacheMeshProcess): void;
318
+ /**
319
+ * returns the tile cache data that can be used later. The tile cache must be built before retrieving the data
320
+ * @returns the tile cache data that can be used later. The tile cache must be built before retrieving the data
321
+ * @throws Error if there is no TileCache generated
322
+ * @remarks The returned data can be used to rebuild the tile cache later using buildFromTileCacheData
323
+ */
324
+ getTileCacheData(): Uint8Array;
325
+ /**
326
+ * Disposes
327
+ */
328
+ dispose(): void;
329
+ /**
330
+ * Creates a cylinder obstacle and add it to the navigation
331
+ * @param position world position
332
+ * @param radius cylinder radius
333
+ * @param height cylinder height
334
+ * @param doNotWaitForCacheUpdate if true the function will not wait for the tile cache to be fully updated before returning
335
+ * @returns the obstacle freshly created
336
+ */
337
+ addCylinderObstacle(position: IVector3Like, radius: number, height: number, doNotWaitForCacheUpdate?: boolean): Nullable<IObstacle>;
338
+ /**
339
+ * Creates an oriented box obstacle and add it to the navigation
340
+ * @param position world position
341
+ * @param extent box size
342
+ * @param angle angle in radians of the box orientation on Y axis
343
+ * @param doNotWaitForCacheUpdate if true the function will not wait for the tile cache to be fully updated before returning
344
+ * @returns the obstacle freshly created
345
+ */
346
+ addBoxObstacle(position: IVector3Like, extent: IVector3Like, angle: number, doNotWaitForCacheUpdate?: boolean): Nullable<IObstacle>;
347
+ /**
348
+ * Removes an obstacle created by addCylinderObstacle or addBoxObstacle
349
+ * @param obstacle obstacle to remove from the navigation
350
+ * @param doNotWaitForCacheUpdate if true the function will not wait for the tile cache to be fully updated before returning
351
+ *
352
+ */
353
+ removeObstacle(obstacle: IObstacle, doNotWaitForCacheUpdate?: boolean): void;
354
+ /**
355
+ * If this plugin is supported
356
+ * @returns true if plugin is supported
357
+ */
358
+ isSupported(): boolean;
359
+ /**
360
+ * Returns the seed used for randomized functions like `getRandomPointAround`
361
+ * @returns seed number
362
+ */
363
+ getRandomSeed(): number;
364
+ /**
365
+ * Set the seed used for randomized functions like `getRandomPointAround`
366
+ * @param seed number used as seed for random functions
367
+ */
368
+ setRandomSeed(seed: number): void;
369
+ /**
370
+ * Perform a raycast on the navmesh
371
+ * @param start start position
372
+ * @param end end position
373
+ * @returns if a direct path exists between start and end, and the hit point if any
374
+ */
375
+ raycast(start: IVector3Like, end: IVector3Like): {
376
+ hit: boolean;
377
+ hitPoint?: undefined;
378
+ } | {
379
+ hit: boolean;
380
+ hitPoint: Vector3;
381
+ };
382
+ /**
383
+ * Compute the final position from a segment made of destination-position, and return the height of the polygon
384
+ * This is a more sophisiticated version of moveAlong that will use the height of the polygon at the end position
385
+ * @param position world position to start from
386
+ * @param velocity wvelocity of the movement
387
+ * @param options options for the function
388
+ * @returns the resulting point along the navmesh, the polygon reference id and the height of the polygon
389
+ */
390
+ moveAlongWithVelocity(position: IVector3Like, velocity: IVector3Like, options?: {
391
+ /**
392
+ * The polygon filter to apply to the query.
393
+ */
394
+ filter?: QueryFilter;
395
+ /**
396
+ * Half extents for the search box
397
+ */
398
+ halfExtents?: IVector3Like;
399
+ /**
400
+ * The maximum number of polygons the output visited array can hold.
401
+ */
402
+ maxVisitedSize?: number;
403
+ }): {
404
+ position: {
405
+ x: number;
406
+ y: number;
407
+ z: number;
408
+ };
409
+ polyRef: number;
410
+ height: number;
411
+ };
412
+ /**
413
+ * Handles common post-processing and validation of navmesh creation results
414
+ * @param result The partial result from navmesh creation
415
+ * @returns The validated and complete CreateNavMeshresult
416
+ */
417
+ private _processNavMeshResult;
418
+ private _preprocessParameters;
419
+ }