@recast-navigation/core 0.5.0 → 0.7.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,4 +1,4 @@
1
- import { DetourMeshTile, DetourOffMeshConnection, dtPoly } from './detour';
1
+ import { DetourMeshTile, DetourOffMeshConnection, DetourPoly } from './detour';
2
2
  import type R from './raw-module';
3
3
  import { Vector3 } from './utils';
4
4
  export declare class NavMeshGetTilesAtResult {
@@ -26,7 +26,7 @@ export declare class NavMeshGetTileAndPolyByRefResult {
26
26
  raw: R.NavMeshGetTileAndPolyByRefResult;
27
27
  constructor(raw: R.NavMeshGetTileAndPolyByRefResult);
28
28
  tile(): DetourMeshTile;
29
- poly(): dtPoly;
29
+ poly(): DetourPoly;
30
30
  status(): number;
31
31
  destroy(): void;
32
32
  }
@@ -37,18 +37,19 @@ export declare class NavMeshStoreTileStateResult {
37
37
  dataSize(): number;
38
38
  destroy(): void;
39
39
  }
40
- export declare class DebugNavMesh {
41
- positions: number[];
42
- indices: number[];
43
- constructor(navMesh: NavMesh);
44
- }
45
- export type NavMeshParams = {
40
+ export type NavMeshParamsType = {
46
41
  orig: Vector3;
47
42
  tileWidth: number;
48
43
  tileHeight: number;
49
44
  maxTiles: number;
50
45
  maxPolys: number;
51
46
  };
47
+ export declare class NavMeshParams {
48
+ raw: R.dtNavMeshParams;
49
+ constructor(raw: R.dtNavMeshParams);
50
+ static create(params: NavMeshParamsType): NavMeshParams;
51
+ clone(): NavMeshParams;
52
+ }
52
53
  export declare class NavMesh {
53
54
  raw: R.NavMesh;
54
55
  constructor(raw?: R.NavMesh);
@@ -57,13 +58,13 @@ export declare class NavMesh {
57
58
  * @param navMeshData the nav mesh data
58
59
  * @returns the status of the operation
59
60
  */
60
- initSolo(navMeshData: R.NavMeshData): boolean;
61
+ initSolo(navMeshData: R.UnsignedCharArray): boolean;
61
62
  /**
62
63
  * Initializes the NavMesh for use with multiple tiles.
63
64
  * @param params parameters for the NavMesh
64
65
  * @returns the status of the operation
65
66
  */
66
- initTiled(params: R.dtNavMeshParams): boolean;
67
+ initTiled(params: NavMeshParams): boolean;
67
68
  /**
68
69
  * Adds a tile to the NavMesh.
69
70
  * @param navMeshData the nav mesh data
@@ -71,7 +72,7 @@ export declare class NavMesh {
71
72
  * @param lastRef
72
73
  * @returns the status of the operation and the reference of the added tile
73
74
  */
74
- addTile(navMeshData: R.NavMeshData, flags: number, lastRef: number): {
75
+ addTile(navMeshData: R.UnsignedCharArray, flags: number, lastRef: number): {
75
76
  status: number;
76
77
  tileRef: number;
77
78
  };
@@ -233,9 +234,9 @@ export declare class NavMesh {
233
234
  */
234
235
  restoreTileState(tile: DetourMeshTile, data: number[], maxDataSize: number): number;
235
236
  /**
236
- * Returns a DebugNavMesh that can be used to visualize the NavMesh.
237
+ * Returns a triangle mesh that can be used to visualize the NavMesh.
237
238
  */
238
- getDebugNavMesh(): DebugNavMesh;
239
+ getDebugNavMesh(): [positions: number[], indices: number[]];
239
240
  /**
240
241
  * Destroys the NavMesh.
241
242
  */
package/dist/raw.d.ts CHANGED
@@ -1,5 +1,11 @@
1
1
  import RawModule from './raw-module';
2
- declare const arrays: readonly ["IntArray", "UnsignedIntArray", "UnsignedCharArray", "UnsignedShortArray", "FloatArray"];
2
+ export declare const Arrays: {
3
+ IntArray: typeof RawModule.IntArray;
4
+ UnsignedIntArray: typeof RawModule.UnsignedIntArray;
5
+ UnsignedCharArray: typeof RawModule.UnsignedCharArray;
6
+ UnsignedShortArray: typeof RawModule.UnsignedShortArray;
7
+ FloatArray: typeof RawModule.FloatArray;
8
+ };
3
9
  /**
4
10
  * Lower level bindings for the Recast and Detour libraries.
5
11
  *
@@ -7,22 +13,16 @@ declare const arrays: readonly ["IntArray", "UnsignedIntArray", "UnsignedCharArr
7
13
  */
8
14
  export declare const Raw: {
9
15
  Module: typeof RawModule;
10
- Arrays: {
11
- IntArray: typeof RawModule.IntArray;
12
- UnsignedIntArray: typeof RawModule.UnsignedIntArray;
13
- UnsignedCharArray: typeof RawModule.UnsignedCharArray;
14
- UnsignedShortArray: typeof RawModule.UnsignedShortArray;
15
- FloatArray: typeof RawModule.FloatArray;
16
- };
17
16
  isNull: (obj: unknown) => boolean;
18
17
  CrowdUtils: RawModule.CrowdUtils;
19
18
  Detour: RawModule.Detour;
20
19
  Recast: RawModule.Recast;
21
20
  DetourNavMeshBuilder: RawModule.DetourNavMeshBuilder;
22
21
  DetourTileCacheBuilder: RawModule.DetourTileCacheBuilder;
23
- ChunkyTriMesh: RawModule.ChunkyTriMesh;
22
+ ChunkyTriMeshUtils: RawModule.ChunkyTriMeshUtils;
24
23
  NavMeshImporter: RawModule.NavMeshImporter;
25
24
  NavMeshExporter: RawModule.NavMeshExporter;
25
+ rcConfig: typeof RawModule.rcConfig;
26
26
  dtNavMeshCreateParams: typeof RawModule.dtNavMeshCreateParams;
27
27
  dtNavMeshParams: typeof RawModule.dtNavMeshParams;
28
28
  Vec3: typeof RawModule.Vec3;
@@ -32,7 +32,6 @@ export declare const Raw: {
32
32
  RecastLinearAllocator: typeof RawModule.RecastLinearAllocator;
33
33
  rcContext: typeof RawModule.rcContext;
34
34
  dtTileCacheLayerHeader: typeof RawModule.dtTileCacheLayerHeader;
35
- TileCacheData: typeof RawModule.TileCacheData;
36
35
  rcChunkyTriMesh: typeof RawModule.rcChunkyTriMesh;
37
36
  BoolRef: typeof RawModule.BoolRef;
38
37
  IntRef: typeof RawModule.IntRef;
@@ -42,4 +41,3 @@ export declare const Raw: {
42
41
  FloatRef: typeof RawModule.FloatRef;
43
42
  };
44
43
  export declare const init: () => Promise<void>;
45
- export {};
package/dist/recast.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ import { Vector3Tuple } from 'three';
1
2
  import type R from './raw-module';
2
- import { Vector3 } from './utils';
3
+ import { Vector2Tuple, Vector3 } from './utils';
3
4
  export type RecastConfigType = {
4
5
  /**
5
6
  * The size of the non-navigable border around the heightfield.
@@ -104,6 +105,35 @@ export declare class RecastConfig {
104
105
  static create(partialConfig: Partial<RecastConfigType>): RecastConfig;
105
106
  clone(): RecastConfig;
106
107
  }
108
+ export declare class RecastBuildContext {
109
+ raw: R.RecastBuildContext;
110
+ logs: Array<{
111
+ category: number;
112
+ msg: string;
113
+ }>;
114
+ startTimes: {
115
+ [label: string]: number;
116
+ };
117
+ accumulatedTimes: {
118
+ [label: string]: number;
119
+ };
120
+ constructor(timersAndLogsEnabled?: boolean);
121
+ log(category: number, msg: string): void;
122
+ resetLog(): void;
123
+ startTimer(label: number): void;
124
+ stopTimer(label: number): void;
125
+ getAccumulatedTime(label: number): number;
126
+ resetTimers(): void;
127
+ }
128
+ export declare class RecastChunkyTriMesh {
129
+ raw: R.rcChunkyTriMesh;
130
+ constructor(raw?: R.rcChunkyTriMesh);
131
+ init(verts: R.FloatArray, tris: R.IntArray, ntris: number, trisPerChunk: number): boolean;
132
+ getChunksOverlappingRect(boundsMin: Vector2Tuple, boundsMax: Vector2Tuple, chunks: R.IntArray, maxChunks: number): number;
133
+ getNodeTris(nodeId: number): R.IntArray;
134
+ nodes(index: number): R.rcChunkyTriMeshNode;
135
+ maxTrisPerChunk(): number;
136
+ }
107
137
  export declare class RecastSpan {
108
138
  raw: R.rcSpan;
109
139
  constructor(raw: R.rcSpan);
@@ -221,7 +251,9 @@ export declare class RecastPolyMesh {
221
251
  polys(index: number): number;
222
252
  regs(index: number): number;
223
253
  flags(index: number): number;
254
+ setFlags(index: number, value: number): void;
224
255
  areas(index: number): number;
256
+ setAreas(index: number, value: number): void;
225
257
  nverts(): number;
226
258
  npolys(): number;
227
259
  maxpolys(): number;
@@ -243,3 +275,50 @@ export declare class RecastPolyMeshDetail {
243
275
  nverts(): number;
244
276
  ntris(): number;
245
277
  }
278
+ export declare const calcBounds: (verts: R.FloatArray, nv: number) => R.RecastCalcBoundsResult;
279
+ export declare const calcGridSize: (bmin: Vector3Tuple, bmax: Vector3Tuple, cs: number) => R.RecastCalcGridSizeResult;
280
+ export declare const createHeightfield: (buildContext: RecastBuildContext, heightfield: RecastHeightfield, width: number, height: number, bmin: Vector3Tuple, bmax: Vector3Tuple, cs: number, ch: number) => boolean;
281
+ export declare const markWalkableTriangles: (buildContext: RecastBuildContext, walkableSlopeAngle: number, verts: R.FloatArray, nv: number, tris: R.IntArray, nt: number, areas: R.UnsignedCharArray) => void;
282
+ export declare const clearUnwalkableTriangles: (buildContext: RecastBuildContext, walkableSlopeAngle: number, verts: R.FloatArray, nv: number, tris: R.IntArray, nt: number, areas: R.UnsignedCharArray) => void;
283
+ export declare const rasterizeTriangles: (buildContext: RecastBuildContext, verts: R.FloatArray, nv: number, tris: R.IntArray, areas: R.UnsignedCharArray, nt: number, heightfield: RecastHeightfield, flagMergeThreshold?: number) => boolean;
284
+ export declare const filterLowHangingWalkableObstacles: (buildContext: RecastBuildContext, walkableClimb: number, heightfield: RecastHeightfield) => void;
285
+ export declare const filterLedgeSpans: (buildContext: RecastBuildContext, walkableHeight: number, walkableClimb: number, heightfield: RecastHeightfield) => void;
286
+ export declare const filterWalkableLowHeightSpans: (buildContext: RecastBuildContext, walkableHeight: number, heightfield: RecastHeightfield) => void;
287
+ export declare const getHeightFieldSpanCount: (buildContext: RecastBuildContext, heightfield: RecastHeightfield) => number;
288
+ export declare const buildCompactHeightfield: (buildContext: RecastBuildContext, walkableHeight: number, walkableClimb: number, heightfield: RecastHeightfield, compactHeightfield: RecastCompactHeightfield) => boolean;
289
+ export declare const erodeWalkableArea: (buildContext: RecastBuildContext, radius: number, compactHeightfield: RecastCompactHeightfield) => boolean;
290
+ export declare const medianFilterWalkableArea: (buildContext: RecastBuildContext, compactHeightfield: RecastCompactHeightfield) => boolean;
291
+ export declare const markBoxArea: (buildContext: RecastBuildContext, bmin: Vector3Tuple, bmax: Vector3Tuple, areaId: number, compactHeightfield: RecastCompactHeightfield) => void;
292
+ export declare const markConvexPolyArea: (buildContext: RecastBuildContext, verts: R.FloatArray, nverts: number, hmin: number, hmax: number, areaId: number, compactHeightfield: RecastCompactHeightfield) => void;
293
+ export declare const markCylinderArea: (buildContext: RecastBuildContext, pos: Vector3Tuple, radius: number, height: number, areaId: number, compactHeightfield: RecastCompactHeightfield) => void;
294
+ export declare const buildDistanceField: (buildContext: RecastBuildContext, compactHeightfield: RecastCompactHeightfield) => boolean;
295
+ export declare const buildRegions: (buildContext: RecastBuildContext, compactHeightfield: RecastCompactHeightfield, borderSize: number, minRegionArea: number, mergeRegionArea: number) => boolean;
296
+ export declare const buildLayerRegions: (buildContext: RecastBuildContext, compactHeightfield: RecastCompactHeightfield, borderSize: number, minRegionArea: number) => boolean;
297
+ export declare const buildRegionsMonotone: (buildContext: RecastBuildContext, compactHeightfield: RecastCompactHeightfield, borderSize: number, minRegionArea: number, mergeRegionArea: number) => boolean;
298
+ export declare const setCon: (compactSpan: RecastCompactSpan, dir: number, i: number) => void;
299
+ export declare const getCon: (compactSpan: RecastCompactSpan, dir: number) => number;
300
+ export declare const getDirOffsetX: (dir: number) => number;
301
+ export declare const getDirOffsetY: (dir: number) => number;
302
+ export declare const getDirForOffset: (x: number, y: number) => number;
303
+ export declare const buildHeightfieldLayers: (buildContext: RecastBuildContext, compactHeightfield: RecastCompactHeightfield, borderSize: number, walkableHeight: number, heightfieldLayerSet: RecastHeightfieldLayerSet) => boolean;
304
+ export declare const buildContours: (buildContext: RecastBuildContext, compactHeightfield: RecastCompactHeightfield, maxError: number, maxEdgeLen: number, contourSet: RecastContourSet, buildFlags?: number) => boolean;
305
+ export declare const buildPolyMesh: (buildContext: RecastBuildContext, contourSet: RecastContourSet, nvp: number, polyMesh: RecastPolyMesh) => boolean;
306
+ export declare const mergePolyMeshes: (buildContext: RecastBuildContext, meshes: RecastPolyMesh[], outPolyMesh: RecastPolyMesh) => boolean;
307
+ export declare const buildPolyMeshDetail: (buildContext: RecastBuildContext, mesh: RecastPolyMesh, compactHeightfield: RecastCompactHeightfield, sampleDist: number, sampleMaxError: number, polyMeshDetail: RecastPolyMeshDetail) => boolean;
308
+ export declare const copyPolyMesh: (buildContext: RecastBuildContext, src: RecastPolyMesh, dest: RecastPolyMesh) => boolean;
309
+ export declare const mergePolyMeshDetails: (buildContext: RecastBuildContext, meshes: RecastPolyMeshDetail[], out: RecastPolyMeshDetail) => boolean;
310
+ export declare const getHeightfieldLayerHeights: (heightfieldLayer: RecastHeightfieldLayer) => R.UnsignedCharArray;
311
+ export declare const getHeightfieldLayerAreas: (heightfieldLayer: RecastHeightfieldLayer) => R.UnsignedCharArray;
312
+ export declare const getHeightfieldLayerCons: (heightfieldLayer: RecastHeightfieldLayer) => R.UnsignedCharArray;
313
+ export declare const allocHeightfield: () => RecastHeightfield;
314
+ export declare const freeHeightfield: (heightfield: RecastHeightfield) => void;
315
+ export declare const allocCompactHeightfield: () => RecastCompactHeightfield;
316
+ export declare const freeCompactHeightfield: (compactHeightfield: RecastCompactHeightfield) => void;
317
+ export declare const allocHeightfieldLayerSet: () => RecastHeightfieldLayerSet;
318
+ export declare const freeHeightfieldLayerSet: (heightfieldLayerSet: RecastHeightfieldLayerSet) => void;
319
+ export declare const allocContourSet: () => RecastContourSet;
320
+ export declare const freeContourSet: (contourSet: RecastContourSet) => void;
321
+ export declare const allocPolyMesh: () => RecastPolyMesh;
322
+ export declare const freePolyMesh: (polyMesh: RecastPolyMesh) => void;
323
+ export declare const allocPolyMeshDetail: () => RecastPolyMeshDetail;
324
+ export declare const freePolyMeshDetail: (polyMeshDetail: RecastPolyMeshDetail) => void;
@@ -1,3 +1,4 @@
1
+ import { NavMeshCreateParams } from './detour';
1
2
  import { NavMesh } from './nav-mesh';
2
3
  import type R from './raw-module';
3
4
  import { Vector3 } from './utils';
@@ -17,7 +18,7 @@ export type CylinderObstacle = {
17
18
  height: number;
18
19
  };
19
20
  export type Obstacle = BoxObstacle | CylinderObstacle;
20
- export type TileCacheParams = {
21
+ export type TileCacheParamsType = {
21
22
  orig: ReadonlyArray<number>;
22
23
  cs: number;
23
24
  ch: number;
@@ -30,10 +31,10 @@ export type TileCacheParams = {
30
31
  maxTiles: number;
31
32
  maxObstacles: number;
32
33
  };
33
- export declare class dtTileCacheParams {
34
+ export declare class DetourTileCacheParams {
34
35
  raw: R.dtTileCacheParams;
35
36
  constructor(raw: R.dtTileCacheParams);
36
- static create(config: TileCacheParams): dtTileCacheParams;
37
+ static create(config: TileCacheParamsType): DetourTileCacheParams;
37
38
  }
38
39
  export type TileCacheUpdateResult = {
39
40
  status: number;
@@ -47,7 +48,7 @@ export declare class TileCache {
47
48
  * Initialises the TileCache
48
49
  * @param params
49
50
  */
50
- init(params: R.dtTileCacheParams, alloc: R.RecastLinearAllocator, compressor: R.RecastFastLZCompressor, meshProcess: TileCacheMeshProcess): boolean;
51
+ init(params: DetourTileCacheParams, alloc: R.RecastLinearAllocator, compressor: R.RecastFastLZCompressor, meshProcess: TileCacheMeshProcess): boolean;
51
52
  /**
52
53
  * Updates the tile cache by rebuilding tiles touched by unfinished obstacle requests.
53
54
  * This should be called after adding or removing obstacles.
@@ -65,12 +66,13 @@ export declare class TileCache {
65
66
  * Removes an obstacle from the navigation mesh.
66
67
  */
67
68
  removeObstacle(obstacle: Obstacle | ObstacleRef): void;
68
- addTile(data: R.TileCacheData, flags?: number): R.TileCacheAddTileResult;
69
+ addTile(data: R.UnsignedCharArray, flags?: number): R.TileCacheAddTileResult;
69
70
  buildNavMeshTile(ref: R.dtCompressedTileRef, navMesh: NavMesh): number;
70
71
  buildNavMeshTilesAt(tx: number, ty: number, navMesh: NavMesh): number;
71
72
  destroy(): void;
72
73
  }
73
74
  export declare class TileCacheMeshProcess {
74
75
  raw: R.TileCacheMeshProcess;
75
- constructor(process: (navMeshCreateParams: R.dtNavMeshCreateParams, polyAreasArray: R.UnsignedCharArray, polyFlagsArray: R.UnsignedShortArray) => void);
76
+ constructor(process: (navMeshCreateParams: NavMeshCreateParams, polyAreasArray: R.UnsignedCharArray, polyFlagsArray: R.UnsignedShortArray) => void);
76
77
  }
78
+ export declare const buildTileCacheLayer: (comp: R.RecastFastLZCompressor, header: R.dtTileCacheLayerHeader, heights: R.UnsignedCharArray, areas: R.UnsignedCharArray, cons: R.UnsignedCharArray, tileCacheData: R.UnsignedCharArray) => number;
package/dist/utils.d.ts CHANGED
@@ -5,6 +5,11 @@ export type Vector3 = {
5
5
  z: number;
6
6
  };
7
7
  export type Vector3Tuple = [number, number, number];
8
+ export type Vector2 = {
9
+ x: number;
10
+ y: number;
11
+ };
12
+ export type Vector2Tuple = [x: number, y: number];
8
13
  export declare const vec3: {
9
14
  toRaw: ({ x, y, z }: Vector3, existing?: R.Vec3) => R.Vec3;
10
15
  fromRaw: (vec3: R.Vec3, freeRaw?: boolean) => {
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.5.0",
9
+ "version": "0.7.0",
10
10
  "license": "MIT",
11
11
  "homepage": "https://github.com/isaac-mason/recast-navigation-js",
12
12
  "bugs": {
@@ -25,11 +25,11 @@
25
25
  "test": "vitest run"
26
26
  },
27
27
  "dependencies": {
28
- "@recast-navigation/wasm": "0.5.0"
28
+ "@recast-navigation/wasm": "0.7.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@babel/core": "^7.22.11",
32
- "@rollup/plugin-commonjs": "^24.0.1",
32
+ "@rollup/plugin-commonjs": "^25.0.4",
33
33
  "@rollup/plugin-node-resolve": "^15.0.1",
34
34
  "@rollup/plugin-terser": "^0.4.3",
35
35
  "@rollup/plugin-typescript": "^11.1.2",
@@ -40,7 +40,7 @@
40
40
  "eslint": "^8.5.0",
41
41
  "eslint-config-airbnb": "^18.2.1",
42
42
  "eslint-config-airbnb-base": "^15.0.0",
43
- "eslint-config-prettier": "^8.3.0",
43
+ "eslint-config-prettier": "^9.0.0",
44
44
  "eslint-import-resolver-typescript": "^3.5.5",
45
45
  "eslint-plugin-es": "^4.1.0",
46
46
  "eslint-plugin-import": "^2.28.0",