@recast-navigation/core 0.26.0 → 0.28.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.
@@ -1,26 +1,45 @@
1
1
  import { FloatArray, UnsignedCharArray, UnsignedIntArray } from './arrays';
2
2
  import { NavMesh } from './nav-mesh';
3
- import type R from './raw-module';
3
+ import { type RawModule } from './raw';
4
4
  import { Vector3 } from './utils';
5
5
  export declare class QueryFilter {
6
- raw: R.dtQueryFilter;
6
+ raw: RawModule.dtQueryFilter;
7
7
  get includeFlags(): number;
8
8
  set includeFlags(flags: number);
9
9
  get excludeFlags(): number;
10
10
  set excludeFlags(flags: number);
11
- constructor(raw?: R.dtQueryFilter);
11
+ /**
12
+ * Constructs a new query filter object.
13
+ */
14
+ constructor();
15
+ /**
16
+ * Constructs a query filter wrapper for a raw dtQueryFilter object.
17
+ * @param raw
18
+ */
19
+ constructor(raw: RawModule.dtQueryFilter);
12
20
  getAreaCost(i: number): number;
13
21
  setAreaCost(i: number, cost: number): void;
14
22
  }
15
23
  export type NavMeshQueryParams = {
16
- navMesh: NavMesh;
17
24
  /**
18
25
  * @default 2048
19
26
  */
20
27
  maxNodes?: number;
28
+ /**
29
+ * Default query filter.
30
+ *
31
+ * If omitted, the default filter will include all flags and exclude none.
32
+ *
33
+ * ```ts
34
+ * this.defaultFilter = new QueryFilter();
35
+ * this.defaultFilter.includeFlags = 0xffff;
36
+ * this.defaultFilter.excludeFlags = 0;
37
+ * ```
38
+ */
39
+ defaultQueryFilter?: QueryFilter;
21
40
  };
22
41
  export declare class NavMeshQuery {
23
- raw: R.NavMeshQuery;
42
+ raw: RawModule.NavMeshQuery;
24
43
  /**
25
44
  * Default query filter.
26
45
  */
@@ -33,7 +52,27 @@ export declare class NavMeshQuery {
33
52
  y: number;
34
53
  z: number;
35
54
  };
36
- constructor(value: R.NavMeshQuery | NavMeshQueryParams);
55
+ /**
56
+ * Constructs a new navigation mesh query object.
57
+ * @param navMesh the navigation mesh to use for the query
58
+ * @param params optional additional parameters
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * const query = new NavMeshQuery(navMesh);
63
+ * ```
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * const query = new NavMeshQuery(navMesh, { maxNodes: 2048 });
68
+ * ```
69
+ */
70
+ constructor(navMesh: NavMesh, params?: NavMeshQueryParams);
71
+ /**
72
+ * Constructs a navigation mesh query object from a raw object.
73
+ * @param raw
74
+ */
75
+ constructor(raw: RawModule.NavMeshQuery);
37
76
  /**
38
77
  * Finds the polygon nearest to the given position.
39
78
  */
@@ -82,7 +121,7 @@ export declare class NavMeshQuery {
82
121
  status: number;
83
122
  resultRefs: number[];
84
123
  resultParents: number[];
85
- resultCost: number;
124
+ resultCost: number[];
86
125
  resultCount: number;
87
126
  };
88
127
  /**
@@ -122,7 +161,7 @@ export declare class NavMeshQuery {
122
161
  y: number;
123
162
  z: number;
124
163
  };
125
- posOverPoly: boolean;
164
+ isPointOverPoly: boolean;
126
165
  };
127
166
  /**
128
167
  * Finds the closest point on the NavMesh to the given position.
@@ -299,6 +338,12 @@ export declare class NavMeshQuery {
299
338
  * @param endPosition position within the end polygon.
300
339
  * @param options additional options
301
340
  * @returns
341
+ *
342
+ * The `polys` array returned must be freed after use.
343
+ *
344
+ * ```ts
345
+ * findPathResult.polys.destroy();
346
+ * ```
302
347
  */
303
348
  findPath(startRef: number, endRef: number, startPosition: Vector3, endPosition: Vector3, options?: {
304
349
  /**
@@ -339,6 +384,14 @@ export declare class NavMeshQuery {
339
384
  * @param path an array of polygon references that represent the path corridor
340
385
  * @param options additional options
341
386
  * @returns the straight path result
387
+ *
388
+ * The straightPath, straightPathFlags, and straightPathRefs arrays returned must be freed after use.
389
+ *
390
+ * ```ts
391
+ * findStraightPathResult.straightPath.destroy();
392
+ * findStraightPathResult.straightPathFlags.destroy();
393
+ * findStraightPathResult.straightPathRefs.destroy();
394
+ * ```
342
395
  */
343
396
  findStraightPath(start: Vector3, end: Vector3, path: UnsignedIntArray, options?: {
344
397
  /**
@@ -1,35 +1,28 @@
1
1
  import { UnsignedCharArray } from './arrays';
2
2
  import { DetourMeshTile, DetourOffMeshConnection, DetourPoly } from './detour';
3
- import type R from './raw-module';
3
+ import { type RawModule } from './raw';
4
4
  import { Vector3 } from './utils';
5
5
  export declare class NavMeshGetTilesAtResult {
6
- raw: R.NavMeshGetTilesAtResult;
7
- constructor(raw: R.NavMeshGetTilesAtResult);
6
+ raw: RawModule.NavMeshGetTilesAtResult;
7
+ constructor(raw: RawModule.NavMeshGetTilesAtResult);
8
8
  tiles(index: number): DetourMeshTile;
9
9
  tileCount(): number;
10
10
  }
11
11
  export declare class NavMeshRemoveTileResult {
12
- raw: R.NavMeshRemoveTileResult;
13
- constructor(raw: R.NavMeshRemoveTileResult);
12
+ raw: RawModule.NavMeshRemoveTileResult;
13
+ constructor(raw: RawModule.NavMeshRemoveTileResult);
14
14
  data(): number[];
15
15
  dataSize(): number;
16
16
  }
17
17
  export declare class NavMeshCalcTileLocResult {
18
- raw: R.NavMeshCalcTileLocResult;
19
- constructor(raw: R.NavMeshCalcTileLocResult);
18
+ raw: RawModule.NavMeshCalcTileLocResult;
19
+ constructor(raw: RawModule.NavMeshCalcTileLocResult);
20
20
  tileX(): number;
21
21
  tileY(): number;
22
22
  }
23
- export declare class NavMeshGetTileAndPolyByRefResult {
24
- raw: R.NavMeshGetTileAndPolyByRefResult;
25
- constructor(raw: R.NavMeshGetTileAndPolyByRefResult);
26
- tile(): DetourMeshTile;
27
- poly(): DetourPoly;
28
- status(): number;
29
- }
30
23
  export declare class NavMeshStoreTileStateResult {
31
- raw: R.NavMeshStoreTileStateResult;
32
- constructor(raw: R.NavMeshStoreTileStateResult);
24
+ raw: RawModule.NavMeshStoreTileStateResult;
25
+ constructor(raw: RawModule.NavMeshStoreTileStateResult);
33
26
  data(): number[];
34
27
  dataSize(): number;
35
28
  }
@@ -55,14 +48,22 @@ export type NavMeshParamsType = {
55
48
  maxPolys: number;
56
49
  };
57
50
  export declare class NavMeshParams {
58
- raw: R.dtNavMeshParams;
59
- constructor(raw: R.dtNavMeshParams);
51
+ raw: RawModule.dtNavMeshParams;
52
+ constructor(raw: RawModule.dtNavMeshParams);
60
53
  static create(params: NavMeshParamsType): NavMeshParams;
61
54
  clone(): NavMeshParams;
62
55
  }
63
56
  export declare class NavMesh {
64
- raw: R.NavMesh;
65
- constructor(raw?: R.NavMesh);
57
+ raw: RawModule.NavMesh;
58
+ /**
59
+ * Constructs a new NavMesh
60
+ */
61
+ constructor();
62
+ /**
63
+ * Creates a wrapper around a raw NavMesh object
64
+ * @param raw raw object
65
+ */
66
+ constructor(raw: RawModule.NavMesh);
66
67
  /**
67
68
  * Initializes the NavMesh for use with a single tile.
68
69
  * @param navMeshData the nav mesh data
@@ -162,13 +163,21 @@ export declare class NavMesh {
162
163
  * @param ref The reference for the a polygon.
163
164
  * @returns
164
165
  */
165
- getTileAndPolyByRef(ref: number): NavMeshGetTileAndPolyByRefResult;
166
+ getTileAndPolyByRef(ref: number): {
167
+ success: boolean;
168
+ status: number;
169
+ tile: DetourMeshTile;
170
+ poly: DetourPoly;
171
+ };
166
172
  /**
167
173
  * Gets the tile and polygon for the specified polygon reference.
168
174
  * @param ref A known valid reference for a polygon.
169
175
  * @returns
170
176
  */
171
- getTileAndPolyByRefUnsafe(ref: number): NavMeshGetTileAndPolyByRefResult;
177
+ getTileAndPolyByRefUnsafe(ref: number): {
178
+ tile: DetourMeshTile;
179
+ poly: DetourPoly;
180
+ };
172
181
  /**
173
182
  * Checks the validity of a polygon reference.
174
183
  * @param ref
package/dist/raw.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import RawModule from './raw-module';
1
+ import type { default as Module, default as RawModule } from '@recast-navigation/wasm';
2
+ export type { RawModule };
2
3
  /**
3
4
  * Lower level bindings for the Recast and Detour libraries.
4
5
  *
@@ -7,37 +8,37 @@ import RawModule from './raw-module';
7
8
  export declare const Raw: {
8
9
  Module: typeof RawModule;
9
10
  isNull: (obj: unknown) => boolean;
10
- CrowdUtils: RawModule.CrowdUtils;
11
- Detour: RawModule.Detour;
12
- Recast: RawModule.Recast;
13
- DetourNavMeshBuilder: RawModule.DetourNavMeshBuilder;
14
- DetourTileCacheBuilder: RawModule.DetourTileCacheBuilder;
15
- ChunkyTriMeshUtils: RawModule.ChunkyTriMeshUtils;
16
- NavMeshImporter: RawModule.NavMeshImporter;
17
- NavMeshExporter: RawModule.NavMeshExporter;
18
- RecastDebugDraw: RawModule.RecastDebugDraw;
19
- DetourDebugDraw: RawModule.DetourDebugDraw;
20
- rcConfig: typeof RawModule.rcConfig;
21
- dtNavMeshCreateParams: typeof RawModule.dtNavMeshCreateParams;
22
- dtNavMeshParams: typeof RawModule.dtNavMeshParams;
23
- Vec3: typeof RawModule.Vec3;
24
- Vec2: typeof RawModule.Vec2;
25
- dtTileCacheParams: typeof RawModule.dtTileCacheParams;
26
- RecastFastLZCompressor: typeof RawModule.RecastFastLZCompressor;
27
- RecastLinearAllocator: typeof RawModule.RecastLinearAllocator;
28
- rcContext: typeof RawModule.rcContext;
29
- dtTileCacheLayerHeader: typeof RawModule.dtTileCacheLayerHeader;
30
- rcChunkyTriMesh: typeof RawModule.rcChunkyTriMesh;
31
- BoolRef: typeof RawModule.BoolRef;
32
- IntRef: typeof RawModule.IntRef;
33
- UnsignedIntRef: typeof RawModule.UnsignedIntRef;
34
- UnsignedCharRef: typeof RawModule.UnsignedCharRef;
35
- UnsignedShortRef: typeof RawModule.UnsignedShortRef;
36
- FloatRef: typeof RawModule.FloatRef;
37
- IntArray: typeof RawModule.IntArray;
38
- UnsignedIntArray: typeof RawModule.UnsignedIntArray;
39
- UnsignedCharArray: typeof RawModule.UnsignedCharArray;
40
- UnsignedShortArray: typeof RawModule.UnsignedShortArray;
41
- FloatArray: typeof RawModule.FloatArray;
11
+ destroy: (obj: unknown) => void;
12
+ CrowdUtils: Module.CrowdUtils;
13
+ Detour: Module.Detour;
14
+ Recast: Module.Recast;
15
+ DetourNavMeshBuilder: Module.DetourNavMeshBuilder;
16
+ DetourTileCacheBuilder: Module.DetourTileCacheBuilder;
17
+ ChunkyTriMeshUtils: Module.ChunkyTriMeshUtils;
18
+ NavMeshImporter: Module.NavMeshImporter;
19
+ NavMeshExporter: Module.NavMeshExporter;
20
+ RecastDebugDraw: Module.RecastDebugDraw;
21
+ DetourDebugDraw: Module.DetourDebugDraw;
22
+ rcConfig: typeof Module.rcConfig;
23
+ dtNavMeshCreateParams: typeof Module.dtNavMeshCreateParams;
24
+ dtNavMeshParams: typeof Module.dtNavMeshParams;
25
+ Vec3: typeof Module.Vec3;
26
+ dtTileCacheParams: typeof Module.dtTileCacheParams;
27
+ RecastFastLZCompressor: typeof Module.RecastFastLZCompressor;
28
+ RecastLinearAllocator: typeof Module.RecastLinearAllocator;
29
+ rcContext: typeof Module.rcContext;
30
+ dtTileCacheLayerHeader: typeof Module.dtTileCacheLayerHeader;
31
+ rcChunkyTriMesh: typeof Module.rcChunkyTriMesh;
32
+ BoolRef: typeof Module.BoolRef;
33
+ IntRef: typeof Module.IntRef;
34
+ UnsignedIntRef: typeof Module.UnsignedIntRef;
35
+ UnsignedCharRef: typeof Module.UnsignedCharRef;
36
+ UnsignedShortRef: typeof Module.UnsignedShortRef;
37
+ FloatRef: typeof Module.FloatRef;
38
+ IntArray: typeof Module.IntArray;
39
+ UnsignedIntArray: typeof Module.UnsignedIntArray;
40
+ UnsignedCharArray: typeof Module.UnsignedCharArray;
41
+ UnsignedShortArray: typeof Module.UnsignedShortArray;
42
+ FloatArray: typeof Module.FloatArray;
42
43
  };
43
- export declare const init: () => Promise<void>;
44
+ export declare const init: (impl?: typeof Module) => Promise<void>;
package/dist/recast.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Vector3Tuple } from 'three';
2
2
  import { FloatArray, IntArray, UnsignedCharArray } from './arrays';
3
- import type R from './raw-module';
3
+ import { type RawModule } from './raw';
4
4
  import { Vector2Tuple, Vector3 } from './utils';
5
5
  export type RecastConfig = {
6
6
  /**
@@ -95,10 +95,10 @@ export type RecastConfig = {
95
95
  detailSampleMaxError: number;
96
96
  };
97
97
  export declare const recastConfigDefaults: RecastConfig;
98
- export declare const createRcConfig: (partialConfig: Partial<RecastConfig>) => R.rcConfig;
99
- export declare const cloneRcConfig: (rcConfig: R.rcConfig) => R.rcConfig;
98
+ export declare const createRcConfig: (partialConfig: Partial<RecastConfig>) => RawModule.rcConfig;
99
+ export declare const cloneRcConfig: (rcConfig: RawModule.rcConfig) => RawModule.rcConfig;
100
100
  export declare class RecastBuildContext {
101
- raw: R.RecastBuildContext;
101
+ raw: RawModule.RecastBuildContext;
102
102
  logs: Array<{
103
103
  category: number;
104
104
  msg: string;
@@ -118,31 +118,38 @@ export declare class RecastBuildContext {
118
118
  resetTimers(): void;
119
119
  }
120
120
  export declare class RecastChunkyTriMesh {
121
- raw: R.rcChunkyTriMesh;
122
- constructor(raw?: R.rcChunkyTriMesh);
121
+ raw: RawModule.rcChunkyTriMesh;
122
+ /**
123
+ * Creates a new RecastChunkyTriMesh.
124
+ */
125
+ constructor();
126
+ /**
127
+ * Creates a wrapper around an existing raw RecastChunkyTriMesh object.
128
+ */
129
+ constructor(raw: RawModule.rcChunkyTriMesh);
123
130
  init(verts: FloatArray, tris: IntArray, ntris: number, trisPerChunk: number): boolean;
124
131
  getChunksOverlappingRect(boundsMin: Vector2Tuple, boundsMax: Vector2Tuple, chunks: IntArray, maxChunks: number): number;
125
132
  getNodeTris(nodeId: number): IntArray;
126
- nodes(index: number): R.rcChunkyTriMeshNode;
133
+ nodes(index: number): RawModule.rcChunkyTriMeshNode;
127
134
  maxTrisPerChunk(): number;
128
135
  }
129
136
  export declare class RecastSpan {
130
- raw: R.rcSpan;
131
- constructor(raw: R.rcSpan);
137
+ raw: RawModule.rcSpan;
138
+ constructor(raw: RawModule.rcSpan);
132
139
  smin(): number;
133
140
  smax(): number;
134
141
  area(): number;
135
142
  next(): RecastSpan | null;
136
143
  }
137
144
  export declare class RecastSpanPool {
138
- raw: R.rcSpanPool;
139
- constructor(raw: R.rcSpanPool);
145
+ raw: RawModule.rcSpanPool;
146
+ constructor(raw: RawModule.rcSpanPool);
140
147
  next(): RecastSpanPool | null;
141
148
  items(index: number): RecastSpan;
142
149
  }
143
150
  export declare class RecastHeightfield {
144
- raw: R.rcHeightfield;
145
- constructor(raw: R.rcHeightfield);
151
+ raw: RawModule.rcHeightfield;
152
+ constructor(raw: RawModule.rcHeightfield);
146
153
  width(): number;
147
154
  height(): number;
148
155
  bmin(): Vector3;
@@ -154,22 +161,22 @@ export declare class RecastHeightfield {
154
161
  freelist(index: number): RecastSpan;
155
162
  }
156
163
  export declare class RecastCompactCell {
157
- raw: R.rcCompactCell;
158
- constructor(raw: R.rcCompactCell);
164
+ raw: RawModule.rcCompactCell;
165
+ constructor(raw: RawModule.rcCompactCell);
159
166
  index(): number;
160
167
  count(): number;
161
168
  }
162
169
  export declare class RecastCompactSpan {
163
- raw: R.rcCompactSpan;
164
- constructor(raw: R.rcCompactSpan);
170
+ raw: RawModule.rcCompactSpan;
171
+ constructor(raw: RawModule.rcCompactSpan);
165
172
  y(): number;
166
173
  reg(): number;
167
174
  con(): number;
168
175
  h(): number;
169
176
  }
170
177
  export declare class RecastCompactHeightfield {
171
- raw: R.rcCompactHeightfield;
172
- constructor(raw: R.rcCompactHeightfield);
178
+ raw: RawModule.rcCompactHeightfield;
179
+ constructor(raw: RawModule.rcCompactHeightfield);
173
180
  width(): number;
174
181
  height(): number;
175
182
  spanCount(): number;
@@ -188,8 +195,8 @@ export declare class RecastCompactHeightfield {
188
195
  areas(index: number): number;
189
196
  }
190
197
  export declare class RecastContour {
191
- raw: R.rcContour;
192
- constructor(raw: R.rcContour);
198
+ raw: RawModule.rcContour;
199
+ constructor(raw: RawModule.rcContour);
193
200
  verts(index: number): number;
194
201
  nverts(): number;
195
202
  rverts(index: number): number;
@@ -198,8 +205,8 @@ export declare class RecastContour {
198
205
  area(): number;
199
206
  }
200
207
  export declare class RecastContourSet {
201
- raw: R.rcContourSet;
202
- constructor(raw: R.rcContourSet);
208
+ raw: RawModule.rcContourSet;
209
+ constructor(raw: RawModule.rcContourSet);
203
210
  conts(index: number): RecastContour;
204
211
  nconts(): number;
205
212
  bmin(): Vector3;
@@ -212,8 +219,8 @@ export declare class RecastContourSet {
212
219
  maxError(): number;
213
220
  }
214
221
  export declare class RecastHeightfieldLayer {
215
- raw: R.rcHeightfieldLayer;
216
- constructor(raw: R.rcHeightfieldLayer);
222
+ raw: RawModule.rcHeightfieldLayer;
223
+ constructor(raw: RawModule.rcHeightfieldLayer);
217
224
  bmin(): Vector3;
218
225
  bmax(): Vector3;
219
226
  cs(): number;
@@ -231,14 +238,14 @@ export declare class RecastHeightfieldLayer {
231
238
  cons(index: number): number;
232
239
  }
233
240
  export declare class RecastHeightfieldLayerSet {
234
- raw: R.rcHeightfieldLayerSet;
235
- constructor(raw: R.rcHeightfieldLayerSet);
241
+ raw: RawModule.rcHeightfieldLayerSet;
242
+ constructor(raw: RawModule.rcHeightfieldLayerSet);
236
243
  layers(index: number): RecastHeightfieldLayer;
237
244
  nlayers(): number;
238
245
  }
239
246
  export declare class RecastPolyMesh {
240
- raw: R.rcPolyMesh;
241
- constructor(raw: R.rcPolyMesh);
247
+ raw: RawModule.rcPolyMesh;
248
+ constructor(raw: RawModule.rcPolyMesh);
242
249
  verts(index: number): number;
243
250
  polys(index: number): number;
244
251
  regs(index: number): number;
@@ -258,8 +265,8 @@ export declare class RecastPolyMesh {
258
265
  maxEdgeError(): number;
259
266
  }
260
267
  export declare class RecastPolyMeshDetail {
261
- raw: R.rcPolyMeshDetail;
262
- constructor(raw: R.rcPolyMeshDetail);
268
+ raw: RawModule.rcPolyMeshDetail;
269
+ constructor(raw: RawModule.rcPolyMeshDetail);
263
270
  meshes(index: number): number;
264
271
  verts(index: number): number;
265
272
  tris(index: number): number;
@@ -267,8 +274,8 @@ export declare class RecastPolyMeshDetail {
267
274
  nverts(): number;
268
275
  ntris(): number;
269
276
  }
270
- export declare const calcBounds: (verts: FloatArray, nv: number) => R.RecastCalcBoundsResult;
271
- export declare const calcGridSize: (bmin: Vector3Tuple, bmax: Vector3Tuple, cs: number) => R.RecastCalcGridSizeResult;
277
+ export declare const calcBounds: (verts: FloatArray, nv: number) => RawModule.RecastCalcBoundsResult;
278
+ export declare const calcGridSize: (bmin: Vector3Tuple, bmax: Vector3Tuple, cs: number) => RawModule.RecastCalcGridSizeResult;
272
279
  export declare const createHeightfield: (buildContext: RecastBuildContext, heightfield: RecastHeightfield, width: number, height: number, bmin: Vector3Tuple, bmax: Vector3Tuple, cs: number, ch: number) => boolean;
273
280
  export declare const markWalkableTriangles: (buildContext: RecastBuildContext, walkableSlopeAngle: number, verts: FloatArray, nv: number, tris: IntArray, nt: number, areas: UnsignedCharArray) => void;
274
281
  export declare const clearUnwalkableTriangles: (buildContext: RecastBuildContext, walkableSlopeAngle: number, verts: FloatArray, nv: number, tris: IntArray, nt: number, areas: UnsignedCharArray) => void;
@@ -1,12 +1,12 @@
1
1
  import { NavMesh } from '../nav-mesh';
2
- import type R from '../raw-module';
2
+ import { type RawModule } from '../raw';
3
3
  import { TileCache, TileCacheMeshProcess } from '../tile-cache';
4
4
  export type NavMeshImporterResult = {
5
5
  navMesh: NavMesh;
6
6
  } | {
7
7
  navMesh: NavMesh;
8
8
  tileCache: TileCache;
9
- allocator: R.RecastLinearAllocator;
10
- compressor: R.RecastFastLZCompressor;
9
+ allocator: RawModule.RecastLinearAllocator;
10
+ compressor: RawModule.RecastFastLZCompressor;
11
11
  };
12
12
  export declare const importNavMesh: (data: Uint8Array, tileCacheMeshProcess?: TileCacheMeshProcess) => NavMeshImporterResult;
@@ -1,9 +1,9 @@
1
1
  import { UnsignedCharArray, UnsignedShortArray } from './arrays';
2
2
  import { NavMeshCreateParams } from './detour';
3
3
  import { NavMesh } from './nav-mesh';
4
- import type R from './raw-module';
4
+ import { type RawModule } from './raw';
5
5
  import { Vector3 } from './utils';
6
- export type ObstacleRef = R.dtObstacleRef;
6
+ export type ObstacleRef = RawModule.dtObstacleRef;
7
7
  export type BoxObstacle = {
8
8
  type: 'box';
9
9
  ref: ObstacleRef;
@@ -46,8 +46,8 @@ export type TileCacheParamsType = {
46
46
  maxObstacles: number;
47
47
  };
48
48
  export declare class DetourTileCacheParams {
49
- raw: R.dtTileCacheParams;
50
- constructor(raw: R.dtTileCacheParams);
49
+ raw: RawModule.dtTileCacheParams;
50
+ constructor(raw: RawModule.dtTileCacheParams);
51
51
  static create(config: TileCacheParamsType): DetourTileCacheParams;
52
52
  }
53
53
  export type TileCacheUpdateResult = {
@@ -56,14 +56,22 @@ export type TileCacheUpdateResult = {
56
56
  upToDate: boolean;
57
57
  };
58
58
  export declare class TileCache {
59
- raw: R.TileCache;
59
+ raw: RawModule.TileCache;
60
60
  obstacles: Map<ObstacleRef, Obstacle>;
61
- constructor(raw?: R.TileCache);
61
+ /**
62
+ * Constructs a new TileCache
63
+ */
64
+ constructor();
65
+ /**
66
+ * Creates a wrapper around a raw TileCache object
67
+ * @param raw raw object
68
+ */
69
+ constructor(raw: RawModule.TileCache);
62
70
  /**
63
71
  * Initialises the TileCache
64
72
  * @param params
65
73
  */
66
- init(params: DetourTileCacheParams, alloc: R.RecastLinearAllocator, compressor: R.RecastFastLZCompressor, meshProcess: TileCacheMeshProcess): boolean;
74
+ init(params: DetourTileCacheParams, alloc: RawModule.RecastLinearAllocator, compressor: RawModule.RecastFastLZCompressor, meshProcess: TileCacheMeshProcess): boolean;
67
75
  /**
68
76
  * Updates the tile cache by rebuilding tiles touched by unfinished obstacle requests.
69
77
  *
@@ -97,13 +105,13 @@ export declare class TileCache {
97
105
  * Removes an obstacle from the navigation mesh.
98
106
  */
99
107
  removeObstacle(obstacle: Obstacle | ObstacleRef): RemoveObstacleResult;
100
- addTile(data: UnsignedCharArray, flags?: number): R.TileCacheAddTileResult;
101
- buildNavMeshTile(ref: R.dtCompressedTileRef, navMesh: NavMesh): number;
108
+ addTile(data: UnsignedCharArray, flags?: number): RawModule.TileCacheAddTileResult;
109
+ buildNavMeshTile(ref: RawModule.dtCompressedTileRef, navMesh: NavMesh): number;
102
110
  buildNavMeshTilesAt(tx: number, ty: number, navMesh: NavMesh): number;
103
111
  destroy(): void;
104
112
  }
105
113
  export declare class TileCacheMeshProcess {
106
- raw: R.TileCacheMeshProcess;
114
+ raw: RawModule.TileCacheMeshProcess;
107
115
  constructor(process: (navMeshCreateParams: NavMeshCreateParams, polyAreasArray: UnsignedCharArray, polyFlagsArray: UnsignedShortArray) => void);
108
116
  }
109
- export declare const buildTileCacheLayer: (comp: R.RecastFastLZCompressor, header: R.dtTileCacheLayerHeader, heights: UnsignedCharArray, areas: UnsignedCharArray, cons: UnsignedCharArray, tileCacheData: UnsignedCharArray) => number;
117
+ export declare const buildTileCacheLayer: (comp: RawModule.RecastFastLZCompressor, header: RawModule.dtTileCacheLayerHeader, heights: UnsignedCharArray, areas: UnsignedCharArray, cons: UnsignedCharArray, tileCacheData: UnsignedCharArray) => number;
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type R from './raw-module';
1
+ import { type RawModule } from './raw';
2
2
  export type Vector3 = {
3
3
  x: number;
4
4
  y: number;
@@ -11,8 +11,8 @@ export type Vector2 = {
11
11
  };
12
12
  export type Vector2Tuple = [x: number, y: number];
13
13
  export declare const vec3: {
14
- toRaw: ({ x, y, z }: Vector3, existing?: R.Vec3) => R.Vec3;
15
- fromRaw: (vec3: R.Vec3, freeRaw?: boolean) => {
14
+ toRaw: ({ x, y, z }: Vector3, existing?: RawModule.Vec3) => RawModule.Vec3;
15
+ fromRaw: (vec3: RawModule.Vec3) => {
16
16
  x: number;
17
17
  y: number;
18
18
  z: number;
package/package.json CHANGED
@@ -6,13 +6,14 @@
6
6
  "email": "isaac@isaacmason.com",
7
7
  "url": "https://isaacmason.com/"
8
8
  },
9
- "version": "0.26.0",
9
+ "version": "0.28.0",
10
10
  "license": "MIT",
11
11
  "homepage": "https://github.com/isaac-mason/recast-navigation-js",
12
12
  "bugs": {
13
13
  "url": "https://github.com/isaac-mason/recast-navigation-js/issues"
14
14
  },
15
- "main": "./dist/index.cjs",
15
+ "type": "module",
16
+ "main": "./dist/index.mjs",
16
17
  "module": "./dist/index.mjs",
17
18
  "types": "./dist/index.d.ts",
18
19
  "files": [
@@ -26,11 +27,14 @@
26
27
  "lint": "eslint --ext .ts src"
27
28
  },
28
29
  "dependencies": {
29
- "@recast-navigation/wasm": "0.26.0"
30
+ "@recast-navigation/wasm": "0.28.0"
30
31
  },
31
32
  "devDependencies": {
32
- "@babel/core": "^7.24.4",
33
+ "@babel/core": "^7.24.5",
34
+ "@babel/preset-env": "^7.24.5",
35
+ "@babel/preset-typescript": "^7.24.1",
33
36
  "@isaac-mason/eslint-config-typescript": "^0.0.5",
37
+ "@rollup/plugin-babel": "^6.0.4",
34
38
  "@rollup/plugin-commonjs": "^25.0.7",
35
39
  "@rollup/plugin-node-resolve": "^15.0.1",
36
40
  "@rollup/plugin-terser": "^0.4.3",