@recast-navigation/core 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,7 +20,13 @@ export type NavMeshQueryParams = {
20
20
  };
21
21
  export declare class NavMeshQuery {
22
22
  raw: R.NavMeshQuery;
23
+ /**
24
+ * Default query filter.
25
+ */
23
26
  defaultFilter: QueryFilter;
27
+ /**
28
+ * Default search distance along each axis.
29
+ */
24
30
  defaultQueryHalfExtents: {
25
31
  x: number;
26
32
  y: number;
@@ -33,10 +39,12 @@ export declare class NavMeshQuery {
33
39
  findNearestPoly(position: Vector3, options?: {
34
40
  /**
35
41
  * The polygon filter to apply to the query.
42
+ * @default this.defaultFilter
36
43
  */
37
44
  filter?: QueryFilter;
38
45
  /**
39
46
  * The search distance along each axis. [(x, y, z)]
47
+ * @default this.defaultQueryHalfExtents
40
48
  */
41
49
  halfExtents?: Vector3;
42
50
  }): {
@@ -55,10 +63,20 @@ export declare class NavMeshQuery {
55
63
  * @param startRef Reference of polygon to start search from
56
64
  * @param centerPos Center of circle
57
65
  * @param radius Radius of circle
58
- * @param filter The polygon filter to apply to the query
59
- * @param maxResult The maximum number of polygons the result arrays can hold
66
+ * @param options
60
67
  */
61
- findPolysAroundCircle(startRef: number, centerPos: Vector3, radius: number, filter?: QueryFilter, maxResult?: number): {
68
+ findPolysAroundCircle(startRef: number, centerPos: Vector3, radius: number, options?: {
69
+ /**
70
+ * The polygon filter to apply to the query.
71
+ * @default this.defaultFilter
72
+ */
73
+ filter?: QueryFilter;
74
+ /**
75
+ * The maximum number of polygons the result arrays can hold.
76
+ * @default 256
77
+ */
78
+ maxPolys?: number;
79
+ }): {
62
80
  success: boolean;
63
81
  status: number;
64
82
  resultRefs: number[];
@@ -70,10 +88,20 @@ export declare class NavMeshQuery {
70
88
  * Finds polygons that overlap the search box.
71
89
  * @param center The center of the search box
72
90
  * @param halfExtents The search distance along each axis
73
- * @param filter The polygon filter to apply to the query
74
- * @param maxPolys The maximum number of polygons the search result can hold
91
+ * @param options
75
92
  */
76
- queryPolygons(center: Vector3, halfExtents: Vector3, filter?: QueryFilter, maxPolys?: number): {
93
+ queryPolygons(center: Vector3, halfExtents: Vector3, options?: {
94
+ /**
95
+ * The polygon filter to apply to the query.
96
+ * @default this.defaultFilter
97
+ */
98
+ filter?: QueryFilter;
99
+ /**
100
+ * The maximum number of polygons the search result can hold.
101
+ * @default 256
102
+ */
103
+ maxPolys?: number;
104
+ }): {
77
105
  success: boolean;
78
106
  status: number;
79
107
  polyRefs: number[];
@@ -81,6 +109,9 @@ export declare class NavMeshQuery {
81
109
  };
82
110
  /**
83
111
  * Returns the closest point on the given polygon to the given position.
112
+ *
113
+ * @param polyRef The reference of the polygon
114
+ * @param position The position to find the closest point to
84
115
  */
85
116
  closestPointOnPoly(polyRef: number, position: Vector3): {
86
117
  success: boolean;
@@ -98,10 +129,12 @@ export declare class NavMeshQuery {
98
129
  getClosestPoint(position: Vector3, options?: {
99
130
  /**
100
131
  * The polygon filter to apply to the query.
132
+ * @default this.defaultFilter
101
133
  */
102
134
  filter?: QueryFilter;
103
135
  /**
104
136
  * The search distance along each axis. [(x, y, z)]
137
+ * @default this.defaultQueryHalfExtents
105
138
  */
106
139
  halfExtents?: Vector3;
107
140
  }): Vector3;
@@ -111,23 +144,33 @@ export declare class NavMeshQuery {
111
144
  getRandomPointAround(position: Vector3, radius: number, options?: {
112
145
  /**
113
146
  * The polygon filter to apply to the query.
147
+ * @default this.defaultFilter
114
148
  */
115
149
  filter?: QueryFilter;
116
150
  /**
117
151
  * The search distance along each axis. [(x, y, z)]
152
+ * @default this.defaultQueryHalfExtents
118
153
  */
119
154
  halfExtents?: Vector3;
120
155
  }): Vector3;
121
156
  /**
122
157
  * Moves from the start to the end position constrained to the navigation mesh.
158
+ *
159
+ * @param startRef The reference id of the start polygon.
160
+ * @param startPosition A position of the mover within the start polygon.
161
+ * @param endPosition The desired end position of the mover.
162
+ *
163
+ * @returns The result of the move along surface operation.
123
164
  */
124
165
  moveAlongSurface(startRef: number, startPosition: Vector3, endPosition: Vector3, options?: {
125
166
  /**
126
167
  * The polygon filter to apply to the query.
168
+ * @default this.defaultFilter
127
169
  */
128
170
  filter?: QueryFilter;
129
171
  /**
130
172
  * The maximum number of polygons the output visited array can hold.
173
+ * @default 256
131
174
  */
132
175
  maxVisitedSize?: number;
133
176
  }): {
@@ -141,7 +184,31 @@ export declare class NavMeshQuery {
141
184
  visited: number[];
142
185
  };
143
186
  /**
144
- * Gets the height of the polygon at the provided position using the height detail
187
+ * Returns a random point on the navmesh.
188
+ * @param options additional options
189
+ * @returns a random point on the navmesh
190
+ */
191
+ findRandomPoint(options?: {
192
+ /**
193
+ * The polygon filter to apply to the query.
194
+ * @default this.defaultFilter
195
+ */
196
+ filter?: QueryFilter;
197
+ }): {
198
+ success: boolean;
199
+ status: number;
200
+ randomPolyRef: number;
201
+ randomPoint: {
202
+ x: number;
203
+ y: number;
204
+ z: number;
205
+ };
206
+ };
207
+ /**
208
+ * Gets the height of the polygon at the provided position using the height detail.
209
+ *
210
+ * @param polyRef The reference id of the polygon.
211
+ * @param position A position within the xz-bounds of the polygon.
145
212
  */
146
213
  getPolyHeight(polyRef: number, position: Vector3): {
147
214
  success: boolean;
@@ -151,22 +218,235 @@ export declare class NavMeshQuery {
151
218
  /**
152
219
  * Finds a straight path from the start position to the end position.
153
220
  *
221
+ * @param start The start position.
222
+ * @param end The end position.
223
+ *
154
224
  * @returns an array of Vector3 positions that make up the path, or an empty array if no path was found.
155
225
  */
156
226
  computePath(start: Vector3, end: Vector3, options?: {
157
227
  /**
158
228
  * The polygon filter to apply to the query.
229
+ * @default this.defaultFilter
159
230
  */
160
231
  filter?: QueryFilter;
161
232
  /**
162
- * The maximum number of polygons the @p path array can hold. [Limit: >= 1]
233
+ * The maximum number of polygons the path array can hold. [Limit: >= 1]
234
+ * @default 256
163
235
  */
164
236
  maxPathPolys?: number;
165
237
  /**
166
- * The maximum number of points the straight path arrays can hold. [Limit: > 0]
238
+ * The maximum number of points the straight path arrays can hold. [Limit: > 0]
239
+ * @default 256
240
+ */
241
+ maxStraightPathPoints?: number;
242
+ }): {
243
+ /**
244
+ * Whether a path was successfully computed.
245
+ */
246
+ success: boolean;
247
+ /**
248
+ * Error information if the path computation failed.
249
+ */
250
+ error?: {
251
+ /**
252
+ * Description of the error.
253
+ */
254
+ name: string;
255
+ /**
256
+ * A dtStatus status code if relevant.
257
+ */
258
+ status?: number;
259
+ };
260
+ /**
261
+ * The result path.
262
+ */
263
+ path: Vector3[];
264
+ };
265
+ /**
266
+ * Finds a path from the start polygon to the end polygon.
267
+ * @param startRef the reference id of the start polygon.
268
+ * @param endRef the reference id of the end polygon.
269
+ * @param startPosition position within the start polygon.
270
+ * @param endPosition position within the end polygon.
271
+ * @param options additional options
272
+ * @returns
273
+ */
274
+ findPath(startRef: number, endRef: number, startPosition: Vector3, endPosition: Vector3, options?: {
275
+ /**
276
+ * The polygon filter to apply to the query.
277
+ * @default this.defaultFilter
278
+ */
279
+ filter?: QueryFilter;
280
+ /**
281
+ * The maximum number of polygons the path array can hold. [Limit: >= 1]
282
+ * @default 256
283
+ */
284
+ maxPathPolys?: number;
285
+ }): {
286
+ success: boolean;
287
+ status: number;
288
+ polys: R.UnsignedIntArray;
289
+ };
290
+ /**
291
+ * Finds the straight path from the start to the end position within the polygon corridor.
292
+ *
293
+ * This method peforms what is often called 'string pulling'.
294
+ *
295
+ * The start position is clamped to the first polygon in the path, and the
296
+ * end position is clamped to the last. So the start and end positions should
297
+ * normally be within or very near the first and last polygons respectively.
298
+ *
299
+ * The returned polygon references represent the reference id of the polygon
300
+ * that is entered at the associated path position. The reference id associated
301
+ * with the end point will always be zero. This allows, for example, matching
302
+ * off-mesh link points to their representative polygons.
303
+ *
304
+ * If the provided result arrays are too small for the entire result set,
305
+ * they will be filled as far as possible from the start toward the end
306
+ * position.
307
+ *
308
+ * @param start path start position
309
+ * @param end path end position
310
+ * @param path an array of polygon references that represent the path corridor
311
+ * @param options additional options
312
+ * @returns the straight path result
313
+ */
314
+ findStraightPath(start: Vector3, end: Vector3, path: R.UnsignedIntArray, options?: {
315
+ /**
316
+ * The maximum number of points the straight path arrays can hold. [Limit: > 0]
317
+ * @default 256
167
318
  */
168
319
  maxStraightPathPoints?: number;
169
- }): Vector3[];
320
+ /**
321
+ * Options for dtNavMeshQuery::findStraightPath
322
+ *
323
+ * Add a vertex at every polygon edge crossing where area changes.
324
+ * DT_STRAIGHTPATH_AREA_CROSSINGS = 1
325
+ *
326
+ * Add a vertex at every polygon edge crossing.
327
+ * DT_STRAIGHTPATH_ALL_CROSSINGS = 2
328
+ *
329
+ * @default 0
330
+ */
331
+ straightPathOptions?: number;
332
+ }): {
333
+ success: boolean;
334
+ status: number;
335
+ /**
336
+ * The straight path points.
337
+ */
338
+ straightPath: R.FloatArray;
339
+ /**
340
+ * The straight path flags.
341
+ */
342
+ straightPathFlags: R.UnsignedCharArray;
343
+ /**
344
+ * The reference ids of the visited polygons.
345
+ *
346
+ * Raw.Module.DT_STRAIGHTPATH_START
347
+ * Raw.Module.DT_STRAIGHTPATH_END
348
+ * Raw.Module.DT_STRAIGHTPATH_OFFMESH_CONNECTION
349
+ */
350
+ straightPathRefs: R.UnsignedIntArray;
351
+ /**
352
+ * The number of points in the straight path.
353
+ */
354
+ straightPathCount: number;
355
+ };
356
+ /**
357
+ * Casts a 'walkability' ray along the surface of the navigation mesh from the start position toward the end position.
358
+ *
359
+ * This method is meant to be used for quick, short distance checks.
360
+ *
361
+ * If the path array is too small to hold the result, it will be filled as far as possible from the start postion toward the end position.
362
+ *
363
+ * The raycast ignores the y-value of the end position. (2D check.) This places significant limits on how it can be used.
364
+ *
365
+ * <b>Using the Hit Parameter (t)</b>
366
+ *
367
+ * If the hit parameter is a very high value, then the ray has hit
368
+ * the end position. In this case the path represents a valid corridor to the
369
+ * end position and the value of hitNormal is undefined.
370
+ *
371
+ * If the hit parameter is zero, then the start position is on the wall that
372
+ * was hit and the value of hitNormal is undefined.
373
+ *
374
+ * If 0 < t < 1.0 then the following applies:
375
+ *
376
+ * ```
377
+ * distanceToHitBorder = distanceToEndPosition * t
378
+ * hitPoint = startPos + (endPos - startPos) * t
379
+ * ```
380
+ *
381
+ * <b>Use Case Restriction</b>
382
+ *
383
+ * Consider a scene where there is a main floor with a second floor balcony that hangs over the main floor.
384
+ * So the first floor mesh extends below the balcony mesh.
385
+ * The start position is somewhere on the first floor.
386
+ * The end position is on the balcony.
387
+ *
388
+ * The raycast will search toward the end position along the first floor mesh.
389
+ * If it reaches the end position's xz-coordinates it will indicate FLT_MAX,(no wall hit), meaning it reached the end position.
390
+ * This is one example of why this method is meant for short distance checks.
391
+ *
392
+ * @param startRef the reference id of the start polygon.
393
+ * @param startPosition a position within the start polygon representing the start of the ray
394
+ * @param endPosition the position to cast the ray toward.
395
+ * @param options additional options
396
+ */
397
+ raycast(startRef: number, startPosition: Vector3, endPosition: Vector3, options?: {
398
+ /**
399
+ * The polygon filter to apply to the query.
400
+ * @default this.defaultFilter
401
+ */
402
+ filter?: QueryFilter;
403
+ /**
404
+ * Determines how the raycast behaves.
405
+ *
406
+ * // Raycast should calculate movement cost along the ray and fill RaycastHit::cost
407
+ * DT_RAYCAST_USE_COSTS = 1
408
+ *
409
+ * @default 0
410
+ */
411
+ raycastOptions?: number;
412
+ /**
413
+ * Optional parent of start ref. Used during for cost calculation.
414
+ */
415
+ prevRef?: number;
416
+ }): {
417
+ /**
418
+ * Whether the raycast was successful.
419
+ */
420
+ success: boolean;
421
+ /**
422
+ * The status of the raycast.
423
+ */
424
+ status: number;
425
+ /**
426
+ * The hit parameter.
427
+ */
428
+ t: number;
429
+ /**
430
+ * The normal of the nearest wall hit.
431
+ */
432
+ hitNormal: Vector3;
433
+ /**
434
+ * The index of the edge on the final polygon where the wall was hit.
435
+ */
436
+ hitEdgeIndex: number;
437
+ /**
438
+ * The reference ids of the visited polygons.
439
+ */
440
+ path: number[];
441
+ /**
442
+ * The maximum number of polygons the path can contain.
443
+ */
444
+ maxPath: number;
445
+ /**
446
+ * The cost of the path until hit.
447
+ */
448
+ pathCost: number;
449
+ };
170
450
  /**
171
451
  * Destroys the NavMeshQuery instance
172
452
  */
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "email": "isaac@isaacmason.com",
7
7
  "url": "https://isaacmason.com/"
8
8
  },
9
- "version": "0.22.0",
9
+ "version": "0.23.0",
10
10
  "license": "MIT",
11
11
  "homepage": "https://github.com/isaac-mason/recast-navigation-js",
12
12
  "bugs": {
@@ -26,7 +26,7 @@
26
26
  "lint": "eslint --ext .ts src"
27
27
  },
28
28
  "dependencies": {
29
- "@recast-navigation/wasm": "0.22.0"
29
+ "@recast-navigation/wasm": "0.23.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@babel/core": "^7.24.4",