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