@recast-navigation/three 0.37.0 → 0.39.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.
- package/LICENSE +1 -1
- package/README.md +0 -28
- package/dist/helpers/index.d.ts +0 -1
- package/dist/index.mjs +4 -51
- package/dist/utils/generators.d.ts +2 -2
- package/package.json +5 -5
- package/dist/helpers/off-mesh-connections-helper.d.ts +0 -18
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -126,18 +126,6 @@ scene.add(navMeshHelper);
|
|
|
126
126
|
navMeshHelper.update();
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
-
#### `OffMeshConnectionsHelper`
|
|
130
|
-
|
|
131
|
-
```ts
|
|
132
|
-
import { OffMeshConnectionsHelper } from '@recast-navigation/three';
|
|
133
|
-
|
|
134
|
-
const offMeshConnectionsHelper = new OffMeshConnectionsHelper(
|
|
135
|
-
offMeshConnections
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
scene.add(offMeshConnectionsHelper);
|
|
139
|
-
```
|
|
140
|
-
|
|
141
129
|
#### `TileCacheHelper`
|
|
142
130
|
|
|
143
131
|
Visualises obstacles in a `TileCache`.
|
|
@@ -179,22 +167,6 @@ const navMeshHelper = new NavMeshHelper(navMesh, {
|
|
|
179
167
|
navMeshMaterial,
|
|
180
168
|
});
|
|
181
169
|
|
|
182
|
-
// OffMeshConnectionsHelper
|
|
183
|
-
const offMeshConnectionEntryCircleMaterial = new THREE.MeshBasicMaterial({
|
|
184
|
-
color: 'green',
|
|
185
|
-
});
|
|
186
|
-
const offMeshConnectionExitCircleMaterial = new THREE.MeshBasicMaterial({
|
|
187
|
-
color: 'yellow',
|
|
188
|
-
});
|
|
189
|
-
const offMeshConnectionLineMaterial = new THREE.LineBasicMaterial({
|
|
190
|
-
color: 'white',
|
|
191
|
-
});
|
|
192
|
-
const offMeshConnectionsHelper = new OffMeshConnectionsHelper(offMeshConnections, {
|
|
193
|
-
entryCircleMaterial: offMeshConnectionEntryCircleMaterial,
|
|
194
|
-
exitCircleMaterial: offMeshConnectionExitCircleMaterial,
|
|
195
|
-
lineMaterial: offMeshConnectionLineMaterial,
|
|
196
|
-
});
|
|
197
|
-
|
|
198
170
|
// TileCacheHelper
|
|
199
171
|
const obstacleMaterial = new THREE.MeshBasicMaterial({ color: 'blue' });
|
|
200
172
|
const tileCacheHelper = new TileCacheHelper(tileCache, {
|
package/dist/helpers/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DebugDrawerUtils } from '@recast-navigation/core';
|
|
1
|
+
import { DebugDrawerUtils, getNavMeshPositionsAndIndices } from '@recast-navigation/core';
|
|
2
2
|
import * as THREE from 'three';
|
|
3
|
-
import { Object3D, MeshBasicMaterial, Vector3, Mesh, CylinderGeometry, BufferGeometry, BufferAttribute,
|
|
3
|
+
import { Object3D, MeshBasicMaterial, Vector3, Mesh, CylinderGeometry, BufferGeometry, BufferAttribute, BoxGeometry } from 'three';
|
|
4
4
|
import { LineMaterial } from 'three/addons/lines/LineMaterial.js';
|
|
5
5
|
import { LineSegments2 } from 'three/addons/lines/LineSegments2.js';
|
|
6
6
|
import { LineSegmentsGeometry } from 'three/addons/lines/LineSegmentsGeometry.js';
|
|
@@ -296,60 +296,13 @@ class NavMeshHelper extends Object3D {
|
|
|
296
296
|
* This should be called after updating the nav mesh.
|
|
297
297
|
*/
|
|
298
298
|
update() {
|
|
299
|
-
const [positions, indices] = this.navMesh
|
|
299
|
+
const [positions, indices] = getNavMeshPositionsAndIndices(this.navMesh);
|
|
300
300
|
this.navMeshGeometry.setAttribute('position', new BufferAttribute(Float32Array.from(positions), 3));
|
|
301
301
|
this.navMeshGeometry.setIndex(new BufferAttribute(Uint32Array.from(indices), 1));
|
|
302
302
|
this.navMeshGeometry.computeVertexNormals();
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
-
class OffMeshConnectionsHelper extends Object3D {
|
|
307
|
-
constructor(offMeshConnections, params) {
|
|
308
|
-
super();
|
|
309
|
-
this.offMeshConnections = offMeshConnections ?? [];
|
|
310
|
-
this.entryCircleMaterial = params?.entryCircleMaterial ?? new MeshBasicMaterial({
|
|
311
|
-
color: 'green'
|
|
312
|
-
});
|
|
313
|
-
this.exitCircleMaterial = params?.exitCircleMaterial ?? new MeshBasicMaterial({
|
|
314
|
-
color: 'blue'
|
|
315
|
-
});
|
|
316
|
-
this.lineMaterial = params?.lineMaterial ?? new LineBasicMaterial({
|
|
317
|
-
color: 'red'
|
|
318
|
-
});
|
|
319
|
-
this.update();
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Update the three debug view of the off mesh connections.
|
|
323
|
-
*/
|
|
324
|
-
update() {
|
|
325
|
-
this.clear();
|
|
326
|
-
for (const offMeshConnection of this.offMeshConnections) {
|
|
327
|
-
// start and end circles
|
|
328
|
-
const circleGeometry = new CircleGeometry(offMeshConnection.radius, 16);
|
|
329
|
-
const startMesh = new Mesh(circleGeometry, this.entryCircleMaterial);
|
|
330
|
-
startMesh.position.copy(offMeshConnection.startPosition);
|
|
331
|
-
startMesh.position.y += 0.001;
|
|
332
|
-
startMesh.rotation.x = -Math.PI / 2;
|
|
333
|
-
this.add(startMesh);
|
|
334
|
-
const endMesh = new Mesh(circleGeometry, offMeshConnection.bidirectional ? this.entryCircleMaterial : this.exitCircleMaterial);
|
|
335
|
-
endMesh.position.copy(offMeshConnection.endPosition);
|
|
336
|
-
endMesh.position.y += 0.001;
|
|
337
|
-
endMesh.rotation.x = -Math.PI / 2;
|
|
338
|
-
this.add(endMesh);
|
|
339
|
-
// line between points
|
|
340
|
-
const start = new Vector3().copy(offMeshConnection.startPosition);
|
|
341
|
-
const end = new Vector3().copy(offMeshConnection.endPosition);
|
|
342
|
-
const middle = new Vector3().addVectors(start, end).multiplyScalar(0.5);
|
|
343
|
-
middle.y *= 1.2;
|
|
344
|
-
const curve = new CatmullRomCurve3([start, middle, end]);
|
|
345
|
-
const curvePoints = curve.getPoints(50);
|
|
346
|
-
const lineGeometry = new BufferGeometry().setFromPoints(curvePoints);
|
|
347
|
-
const line = new Line(lineGeometry, this.lineMaterial);
|
|
348
|
-
this.add(line);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
306
|
class TileCacheHelper extends Object3D {
|
|
354
307
|
obstacleMeshes = new Map();
|
|
355
308
|
constructor(tileCache, params) {
|
|
@@ -456,4 +409,4 @@ const threeToTileCache = (meshes, navMeshGeneratorConfig = {}, keepIntermediates
|
|
|
456
409
|
return generateTileCache(positions, indices, navMeshGeneratorConfig, keepIntermediates);
|
|
457
410
|
};
|
|
458
411
|
|
|
459
|
-
export { CrowdHelper, DebugDrawer, NavMeshHelper,
|
|
412
|
+
export { CrowdHelper, DebugDrawer, NavMeshHelper, TileCacheHelper, getPositionsAndIndices, threeToSoloNavMesh, threeToTileCache, threeToTiledNavMesh };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SoloNavMeshGeneratorConfig, TileCacheGeneratorConfig, TiledNavMeshGeneratorConfig } from '@recast-navigation/generators';
|
|
2
2
|
import { Mesh } from 'three';
|
|
3
|
-
export declare const threeToSoloNavMesh: (meshes: Mesh[], navMeshGeneratorConfig?: Partial<SoloNavMeshGeneratorConfig>, keepIntermediates?: boolean) => import("@recast-navigation/generators").
|
|
4
|
-
export declare const threeToTiledNavMesh: (meshes: Mesh[], navMeshGeneratorConfig?: Partial<TiledNavMeshGeneratorConfig>, keepIntermediates?: boolean) => import("@recast-navigation/generators").
|
|
3
|
+
export declare const threeToSoloNavMesh: (meshes: Mesh[], navMeshGeneratorConfig?: Partial<SoloNavMeshGeneratorConfig>, keepIntermediates?: boolean) => import("@recast-navigation/generators").GenerateSoloNavMeshResult;
|
|
4
|
+
export declare const threeToTiledNavMesh: (meshes: Mesh[], navMeshGeneratorConfig?: Partial<TiledNavMeshGeneratorConfig>, keepIntermediates?: boolean) => import("@recast-navigation/generators").GenerateTiledNavMeshResult;
|
|
5
5
|
export declare const threeToTileCache: (meshes: Mesh[], navMeshGeneratorConfig?: Partial<TileCacheGeneratorConfig>, keepIntermediates?: boolean) => import("@recast-navigation/generators").TileCacheGeneratorResult;
|
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.
|
|
9
|
+
"version": "0.39.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"homepage": "https://github.com/isaac-mason/recast-navigation-js",
|
|
12
12
|
"bugs": {
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"lint": "eslint src"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@recast-navigation/core": "0.
|
|
31
|
-
"@recast-navigation/generators": "0.
|
|
30
|
+
"@recast-navigation/core": "0.39.0",
|
|
31
|
+
"@recast-navigation/generators": "0.39.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@types/three": "0.x.x",
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
44
44
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
45
45
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
46
|
-
"@types/three": "^0.
|
|
46
|
+
"@types/three": "^0.172.0",
|
|
47
47
|
"eslint": "^9.6.0",
|
|
48
48
|
"prettier": "^3.1.0",
|
|
49
49
|
"rollup": "^4.14.0",
|
|
50
50
|
"rollup-plugin-copy": "^3.4.0",
|
|
51
51
|
"rollup-plugin-filesize": "^10.0.0",
|
|
52
|
-
"three": "^0.
|
|
52
|
+
"three": "^0.172.0",
|
|
53
53
|
"typescript": "^5.4.3"
|
|
54
54
|
},
|
|
55
55
|
"packageManager": "yarn@3.2.1"
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { OffMeshConnectionParams } from '@recast-navigation/core';
|
|
2
|
-
import { LineBasicMaterial, Material, Object3D } from 'three';
|
|
3
|
-
export type OffMeshConnectionsHelperParams = {
|
|
4
|
-
entryCircleMaterial?: Material;
|
|
5
|
-
exitCircleMaterial?: Material;
|
|
6
|
-
lineMaterial?: LineBasicMaterial;
|
|
7
|
-
};
|
|
8
|
-
export declare class OffMeshConnectionsHelper extends Object3D {
|
|
9
|
-
offMeshConnections: OffMeshConnectionParams[];
|
|
10
|
-
entryCircleMaterial: Material;
|
|
11
|
-
exitCircleMaterial: Material;
|
|
12
|
-
lineMaterial: LineBasicMaterial;
|
|
13
|
-
constructor(offMeshConnections: OffMeshConnectionParams[], params?: OffMeshConnectionsHelperParams);
|
|
14
|
-
/**
|
|
15
|
-
* Update the three debug view of the off mesh connections.
|
|
16
|
-
*/
|
|
17
|
-
update(): void;
|
|
18
|
-
}
|