@recast-navigation/three 0.0.5 → 0.0.7

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/README.md CHANGED
@@ -37,7 +37,7 @@ import { threeToNavMesh } from 'recast-navigation/three';
37
37
 
38
38
  const scene = new THREE.Scene();
39
39
 
40
- /* add some objects to the scene */
40
+ /* add meshes to the scene */
41
41
  // ...
42
42
 
43
43
  const meshes: Mesh[] = [];
@@ -48,75 +48,55 @@ scene.traverse((child) => {
48
48
  }
49
49
  });
50
50
 
51
- const navMesh: NavMesh = threeToNavMesh(meshes, { /* NavMesh config */ }});
52
- ```
53
-
54
- You can also use `threeToNavMeshArgs` to get the arguments for `NavMesh.build`:
51
+ /* solo navmesh */
52
+ const { navMesh }: NavMesh = threeToNavMesh(meshes, { /* NavMesh config */ }});
55
53
 
56
- ```ts
57
- const [positions, indices] = threeToNavMeshArgs(meshes);
54
+ /* tiled navmesh */
55
+ const { navMesh, tileCache } = threeToNavMesh(meshes, { tileSize: 16 }});
58
56
  ```
59
57
 
60
- ### `NavMeshHelper`
58
+ ### `NavMeshHelper`, `TileCacheHelper`, `CrowdHelper`
61
59
 
62
60
  ```ts
63
- import * as THREE from 'three';
64
- import { NavMeshHelper } from 'recast-navigation/three';
65
-
66
- const navMesh = new NavMesh();
67
-
68
- /* initialize the NavMesh */
69
- // ...
61
+ import {
62
+ CrowdHelper,
63
+ NavMeshHelper,
64
+ TileCacheHelper,
65
+ } from 'recast-navigation/three';
70
66
 
71
67
  const navMeshHelper = new NavMeshHelper({ navMesh });
68
+ const tileCacheHelper = new TileCacheHelper({ tileCache });
69
+ const crowdHelper = new CrowdHelper({ crowd });
72
70
 
73
71
  const scene = new THREE.Scene();
74
72
 
75
73
  scene.add(navMeshHelper.navMesh);
76
- scene.add(navMeshHelper.obstacles);
74
+ scene.add(tileCacheHelper.obstacles);
75
+ scene.add(crowdHelper.agents);
77
76
 
78
77
  navMeshHelper.updateNavMesh();
79
- navMeshHelper.updateObstacles();
78
+ tileCacheHelper.updateObstacles();
79
+ crowdHelper.update();
80
80
  ```
81
81
 
82
- You can optionally pass custom materials to the NavMeshHelper constructor.
82
+ You can optionally provide custom materials to the helpers.
83
83
 
84
84
  ```ts
85
85
  const navMeshMaterial = new THREE.MeshBasicMaterial({ color: 'red' });
86
86
  const obstacleMaterial = new THREE.MeshBasicMaterial({ color: 'blue' });
87
+ const agentMaterial = new THREE.MeshBasicMaterial({ color: 'red' });
87
88
 
88
89
  const navMeshHelper = new NavMeshHelper({
89
90
  navMesh,
90
91
  navMeshMaterial,
91
- obstacleMaterial,
92
92
  });
93
- ```
94
-
95
- ### `CrowdHelper`
96
-
97
- ```ts
98
- import * as THREE from 'three';
99
- import { Crowd, NavMesh } from 'recast-navigation';
100
- import { CrowdHelper } from 'recast-navigation/three';
101
93
 
102
- const navMesh = new NavMesh();
103
- /* ... */
104
-
105
- const crowd = new Crowd({ navMesh, maxAgents: 1, maxAgentRadius: 1 });
106
-
107
- const crowdHelper = new CrowdHelper({ crowd });
108
-
109
- const scene = new THREE.Scene();
110
-
111
- scene.add(crowdHelper.agents);
112
-
113
- crowdHelper.update();
114
- ```
115
-
116
- You can optionally provide a custom material for displaying agents.
117
-
118
- ```ts
119
- const agentMaterial = new THREE.MeshBasicMaterial({ color: 'red' });
94
+ const tileCacheHelper = new TileCacheHelper({
95
+ tileCache,
96
+ obstacleMaterial,
97
+ });
120
98
 
121
- const crowdHelper = new CrowdHelper({ crowd, agentMaterial });
99
+ const crowdHelper = new CrowdHelper({
100
+ crowd,
101
+ agentMaterial,
122
102
  ```
@@ -15,6 +15,6 @@ export declare class CrowdHelper {
15
15
  *
16
16
  * This should be called after updating the crowd.
17
17
  */
18
- update(): void;
18
+ updateAgents(): void;
19
19
  private createAgentMesh;
20
20
  }
@@ -1,2 +1,3 @@
1
1
  export * from './crowd-helper';
2
2
  export * from './nav-mesh-helper';
3
+ export * from './tile-cache-helper';
@@ -1,28 +1,18 @@
1
- import { NavMesh, ObstacleRef } from '@recast-navigation/core';
2
- import { Group, Material, Mesh } from 'three';
1
+ import { NavMesh } from '@recast-navigation/core';
2
+ import { Material, Mesh } from 'three';
3
3
  export declare type NavMeshHelperParams = {
4
4
  navMesh: NavMesh;
5
5
  navMeshMaterial?: Material;
6
- obstacleMaterial?: Material;
7
6
  };
8
7
  export declare class NavMeshHelper {
9
8
  navMesh: Mesh;
10
- obstacles: Group;
11
- obstacleMeshes: Map<ObstacleRef, Mesh>;
12
9
  navMeshMaterial: Material;
13
- obstacleMaterial: Material;
14
10
  recastNavMesh: NavMesh;
15
- constructor({ navMesh, navMeshMaterial, obstacleMaterial, }: NavMeshHelperParams);
11
+ constructor({ navMesh, navMeshMaterial }: NavMeshHelperParams);
16
12
  /**
17
13
  * Update the three debug nav mesh.
18
14
  *
19
15
  * This should be called after updating the nav mesh.
20
16
  */
21
17
  updateNavMesh(): void;
22
- /**
23
- * Update the obstacle meshes.
24
- *
25
- * This should be called after adding or removing obstacles.
26
- */
27
- updateObstacles(): void;
28
18
  }
@@ -0,0 +1,19 @@
1
+ import { ObstacleRef, TileCache } from '@recast-navigation/core';
2
+ import { Group, Material, Mesh } from 'three';
3
+ export declare type TileCacheHelperParams = {
4
+ tileCache: TileCache;
5
+ obstacleMaterial?: Material;
6
+ };
7
+ export declare class TileCacheHelper {
8
+ tileCache: TileCache;
9
+ obstacles: Group;
10
+ obstacleMeshes: Map<ObstacleRef, Mesh>;
11
+ obstacleMaterial: Material;
12
+ constructor({ tileCache, obstacleMaterial }: TileCacheHelperParams);
13
+ /**
14
+ * Update the obstacle meshes.
15
+ *
16
+ * This should be called after adding or removing obstacles.
17
+ */
18
+ updateObstacles(): void;
19
+ }
package/dist/index.es.js CHANGED
@@ -1,2 +1,2 @@
1
- import{MeshBasicMaterial as e,Group as t,Vector3 as s,CapsuleGeometry as o,Mesh as a,BufferGeometry as n,BufferAttribute as r,BoxGeometry as i,CylinderGeometry as h}from"three";import{NavMesh as c}from"@recast-navigation/core";class l{agents;agentMeshes=new Map;recastCrowd;agentMaterial;constructor({crowd:s,agentMaterial:o}){this.recastCrowd=s,this.agentMaterial=o??new e({color:"blue",wireframe:!0}),this.agents=new t,this.update()}update(){const e=this.recastCrowd.getAgents(),t=new Set(this.agentMeshes.keys());for(const o of e){t.delete(o);const e=this.recastCrowd.getAgentPosition(o),a=this.recastCrowd.getAgentVelocity(o),n=this.recastCrowd.getAgentParameters(o);let r=this.agentMeshes.get(o);void 0===r&&(r=this.createAgentMesh(n),this.agents.add(r),this.agentMeshes.set(o,r)),r.position.set(e.x,e.y+n.height/2,e.z),r.lookAt((new s).copy(r.position).add(a))}for(const e of t){const t=this.agentMeshes.get(e);t&&(this.agents.remove(t),this.agentMeshes.delete(e))}}createAgentMesh(e){const t=new o(e.radius,e.height-2*e.radius);return new a(t,this.agentMaterial)}}class g{navMesh;obstacles;obstacleMeshes=new Map;navMeshMaterial;obstacleMaterial;recastNavMesh;constructor({navMesh:s,navMeshMaterial:o,obstacleMaterial:r}){this.recastNavMesh=s,this.navMeshMaterial=o||new e({color:"blue",wireframe:!0}),this.obstacleMaterial=r||new e({color:"red",wireframe:!0}),this.navMesh=new a(new n,this.navMeshMaterial),this.obstacles=new t,this.updateNavMesh(),this.updateObstacles()}updateNavMesh(){const{positions:e,indices:t}=this.recastNavMesh.getDebugNavMesh();for(let e=0;e<t.length;e+=3){const s=t[e];t[e]=t[e+2],t[e+2]=s}const s=this.navMesh.geometry;s.setAttribute("position",new r(new Float32Array(e),3)),s.setIndex(new r(new Uint16Array(t),1)),s.computeVertexNormals()}updateObstacles(){const e=new Set(this.obstacleMeshes.keys());for(const[t,s]of this.recastNavMesh.obstacles){let o=this.obstacleMeshes.get(t);if(e.delete(t),!o){const{position:e}=s,o=new a(void 0,this.obstacleMaterial);if(o.position.copy(e),"box"===s.type){const{extent:e,angle:t}=s;o.geometry=new i(2*e.x,2*e.y,2*e.z),o.rotation.y=t}else{if("cylinder"!==s.type)throw new Error(`Unknown obstacle type: ${s}`);{const{radius:e,height:t}=s;o.geometry=new h(e,e,t,16),o.position.y+=t/2}}this.obstacles.add(o),this.obstacleMeshes.set(t,o)}}for(const t of e){const e=this.obstacleMeshes.get(t);e&&(this.obstacles.remove(e),this.obstacleMeshes.delete(t))}}}const M=e=>{let t,o,a;const n=[],r=[];let i=0;for(t=0;t<e.length;t++)if(e[t]){const h=e[t],c=h.geometry.getAttribute("position").array;if(!c)continue;let l=h.geometry.getIndex()?.array;if(!l){const e=[];for(let t=0;t<c.length/3;t++)e.push(t);l=e}for(o=0;o<l.length;o++)n.push(l[o]+i);const g=new s;for(a=0;a<c.length;a+=3)g.set(c[a],c[a+1],c[a+2]),h.localToWorld(g),r.push(g.x,g.y,g.z);i+=c.length/3}return[r,n]},w=(e,t={})=>{const[s,o]=M(e),a=new c;return a.build(s,o,t),a};export{l as CrowdHelper,g as NavMeshHelper,w as threeToNavMesh,M as threeToNavMeshArgs};
1
+ import{MeshBasicMaterial as e,Group as t,Vector3 as s,CapsuleGeometry as a,Mesh as o,BufferGeometry as n,BufferAttribute as r,BoxGeometry as i,CylinderGeometry as h}from"three";import{NavMeshGenerator as c}from"@recast-navigation/core";class l{agents;agentMeshes=new Map;recastCrowd;agentMaterial;constructor({crowd:s,agentMaterial:a}){this.recastCrowd=s,this.agentMaterial=a??new e({color:"red"}),this.agents=new t,this.updateAgents()}updateAgents(){const e=this.recastCrowd.getAgents(),t=new Set(this.agentMeshes.keys());for(const a of e){t.delete(a);const e=this.recastCrowd.getAgentPosition(a),o=this.recastCrowd.getAgentVelocity(a),n=this.recastCrowd.getAgentParameters(a);let r=this.agentMeshes.get(a);void 0===r&&(r=this.createAgentMesh(n),this.agents.add(r),this.agentMeshes.set(a,r)),r.position.set(e.x,e.y+n.height/2,e.z),r.lookAt((new s).copy(r.position).add(o))}for(const e of t){const t=this.agentMeshes.get(e);t&&(this.agents.remove(t),this.agentMeshes.delete(e))}}createAgentMesh(e){const t=new a(e.radius,e.height-2*e.radius);return new o(t,this.agentMaterial)}}class g{navMesh;navMeshMaterial;recastNavMesh;constructor({navMesh:t,navMeshMaterial:s}){this.recastNavMesh=t,this.navMeshMaterial=s||new e({color:"orange",transparent:!0,opacity:.7}),this.navMesh=new o(new n,this.navMeshMaterial),this.updateNavMesh()}updateNavMesh(){const{positions:e,indices:t}=this.recastNavMesh.getDebugNavMesh();for(let e=0;e<t.length;e+=3){const s=t[e];t[e]=t[e+2],t[e+2]=s}const s=this.navMesh.geometry;s.setAttribute("position",new r(new Float32Array(e),3)),s.setIndex(new r(new Uint16Array(t),1)),s.computeVertexNormals()}}class M{tileCache;obstacles;obstacleMeshes=new Map;obstacleMaterial;constructor({tileCache:s,obstacleMaterial:a}){this.tileCache=s,this.obstacleMaterial=a||new e({color:"red",wireframe:!0,wireframeLinewidth:2}),this.obstacles=new t,this.updateObstacles()}updateObstacles(){const e=new Set(this.obstacleMeshes.keys());for(const[t,s]of this.tileCache.obstacles){let a=this.obstacleMeshes.get(t);if(e.delete(t),!a){const{position:e}=s,a=new o(void 0,this.obstacleMaterial);if(a.position.copy(e),"box"===s.type){const{extent:e,angle:t}=s;a.geometry=new i(2*e.x,2*e.y,2*e.z),a.rotation.y=t}else{if("cylinder"!==s.type)throw new Error(`Unknown obstacle type: ${s}`);{const{radius:e,height:t}=s;a.geometry=new h(e,e,t,16),a.position.y+=t/2}}this.obstacles.add(a),this.obstacleMeshes.set(t,a)}}for(const t of e){const e=this.obstacleMeshes.get(t);e&&(this.obstacles.remove(e),this.obstacleMeshes.delete(t))}}}const w=new s,d=e=>{const t=[];let s=0,a=0;for(const o of e){const e=o.geometry.attributes.position;e&&3===e.itemSize&&(s+=e.array.length,a+=o.geometry.getIndex()?.array.length??e.array.length/3,t.push(o))}const o=new Float32Array(s),n=new Uint32Array(a);let r=0,i=0;for(const e of t){const t=e.geometry.attributes.position.array,s=w;for(let a=0;a<t.length;a+=3)s.set(t[a],t[a+1],t[a+2]),e.localToWorld(s),o[a+i]=s.x,o[a+i+1]=s.y,o[a+i+2]=s.z;const a=e.geometry.getIndex()?.array;if(a)for(let e=0;e<a.length;e++)n[e+r]=a[e]+r;else for(let e=0;e<t.length/3;e++)n[e+r]=e+r;i+=t.length,r+=t.length/3}for(let e=0;e<n.length;e+=3){const t=n[e];n[e]=n[e+2],n[e+2]=t}return[o,n]},y=(e,t={})=>{const[s,a]=d(e);return(new c).generate(s,a,t)};export{l as CrowdHelper,g as NavMeshHelper,M as TileCacheHelper,d as getPositionsAndIndices,y as threeToNavMesh};
2
2
  //# sourceMappingURL=index.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../src/helpers/crowd-helper.ts","../src/helpers/nav-mesh-helper.ts","../src/utils/three-to-nav-mesh.ts"],"sourcesContent":["import { Crowd, CrowdAgentParams } from '@recast-navigation/core';\nimport {\n CapsuleGeometry,\n Group,\n Material,\n Mesh,\n MeshBasicMaterial,\n Vector3,\n} from 'three';\n\nexport type CrowdHelperParams = {\n crowd: Crowd;\n agentMaterial?: Material;\n};\n\nexport class CrowdHelper {\n agents: Group;\n\n agentMeshes: Map<number, Mesh> = new Map();\n\n recastCrowd: Crowd;\n\n agentMaterial: Material;\n\n constructor({ crowd, agentMaterial }: CrowdHelperParams) {\n this.recastCrowd = crowd;\n \n this.agentMaterial = agentMaterial ?? new MeshBasicMaterial({ color: 'blue', wireframe: true });\n\n this.agents = new Group();\n\n this.update();\n }\n\n /**\n * Update the three debug view of the crowd agents.\n * \n * This should be called after updating the crowd.\n */\n update() {\n const agentsIndices = this.recastCrowd.getAgents();\n\n const unseen = new Set(this.agentMeshes.keys());\n\n for (const i of agentsIndices) {\n unseen.delete(i);\n\n const position = this.recastCrowd.getAgentPosition(i);\n const velocity = this.recastCrowd.getAgentVelocity(i);\n const agentParams = this.recastCrowd.getAgentParameters(i);\n\n let agentMesh = this.agentMeshes.get(i);\n\n if (agentMesh === undefined) {\n agentMesh = this.createAgentMesh(agentParams);\n \n this.agents.add(agentMesh);\n this.agentMeshes.set(i, agentMesh);\n }\n\n agentMesh.position.set(\n position.x,\n position.y + agentParams.height / 2,\n position.z\n );\n agentMesh.lookAt(\n new Vector3().copy(agentMesh.position).add(velocity as Vector3)\n ); \n }\n\n for (const agentId of unseen) {\n const agentMesh = this.agentMeshes.get(agentId);\n\n if (agentMesh) {\n this.agents.remove(agentMesh);\n this.agentMeshes.delete(agentId);\n }\n }\n }\n\n private createAgentMesh(agentParams: CrowdAgentParams): Mesh {\n const geometry = new CapsuleGeometry(\n agentParams.radius,\n agentParams.height - agentParams.radius * 2\n );\n\n return new Mesh(geometry, this.agentMaterial);\n }\n}\n","import { NavMesh, ObstacleRef } from '@recast-navigation/core';\nimport {\n BoxGeometry,\n BufferAttribute,\n BufferGeometry,\n CylinderGeometry,\n Group,\n Material,\n Mesh,\n MeshBasicMaterial,\n Vector3,\n} from 'three';\n\nexport type NavMeshHelperParams = {\n navMesh: NavMesh;\n navMeshMaterial?: Material;\n obstacleMaterial?: Material;\n};\n\nexport class NavMeshHelper {\n navMesh: Mesh;\n\n obstacles: Group;\n\n obstacleMeshes: Map<ObstacleRef, Mesh> = new Map();\n\n navMeshMaterial: Material;\n\n obstacleMaterial: Material;\n\n recastNavMesh: NavMesh;\n\n constructor({\n navMesh,\n navMeshMaterial,\n obstacleMaterial,\n }: NavMeshHelperParams) {\n this.recastNavMesh = navMesh;\n\n this.navMeshMaterial = navMeshMaterial\n ? navMeshMaterial\n : new MeshBasicMaterial({ color: 'blue', wireframe: true });\n this.obstacleMaterial = obstacleMaterial\n ? obstacleMaterial\n : new MeshBasicMaterial({ color: 'red', wireframe: true });\n\n this.navMesh = new Mesh(new BufferGeometry(), this.navMeshMaterial);\n\n this.obstacles = new Group();\n\n this.updateNavMesh();\n this.updateObstacles();\n }\n\n /**\n * Update the three debug nav mesh.\n * \n * This should be called after updating the nav mesh.\n */\n updateNavMesh() {\n const { positions, indices } = this.recastNavMesh.getDebugNavMesh();\n\n // Set the winding order of the affected faces to clockwise\n for (let i = 0; i < indices.length; i += 3) {\n const tmp = indices[i];\n indices[i] = indices[i + 2];\n indices[i + 2] = tmp;\n }\n\n const geometry = this.navMesh.geometry;\n\n geometry.setAttribute(\n 'position',\n new BufferAttribute(new Float32Array(positions), 3)\n );\n\n geometry.setIndex(new BufferAttribute(new Uint16Array(indices), 1));\n\n geometry.computeVertexNormals();\n }\n\n /**\n * Update the obstacle meshes.\n *\n * This should be called after adding or removing obstacles.\n */\n updateObstacles() { \n const unseen = new Set(this.obstacleMeshes.keys());\n\n for (const [ref, obstacle] of this.recastNavMesh.obstacles) {\n let obstacleMesh = this.obstacleMeshes.get(ref);\n\n unseen.delete(ref);\n\n if (!obstacleMesh) {\n const { position } = obstacle;\n\n const mesh = new Mesh(undefined, this.obstacleMaterial);\n\n mesh.position.copy(position as Vector3);\n\n if (obstacle.type === 'box') {\n const { extent, angle } = obstacle;\n\n mesh.geometry = new BoxGeometry(\n extent.x * 2,\n extent.y * 2,\n extent.z * 2\n );\n\n mesh.rotation.y = angle;\n } else if (obstacle.type === 'cylinder') {\n const { radius, height } = obstacle;\n\n mesh.geometry = new CylinderGeometry(radius, radius, height, 16);\n\n mesh.position.y += height / 2;\n } else {\n throw new Error(`Unknown obstacle type: ${obstacle}`);\n }\n\n this.obstacles.add(mesh);\n this.obstacleMeshes.set(ref, mesh);\n }\n }\n\n for (const ref of unseen) {\n const obstacleMesh = this.obstacleMeshes.get(ref);\n\n if (obstacleMesh) {\n this.obstacles.remove(obstacleMesh);\n this.obstacleMeshes.delete(ref);\n }\n }\n }\n}\n","import { NavMesh, NavMeshConfig } from '@recast-navigation/core';\nimport { BufferAttribute, Mesh, Vector3 } from 'three';\n\nexport const threeToNavMeshArgs = (\n meshes: Mesh[]\n): [positions: number[], indices: number[]] => {\n let index: number;\n let tri: number;\n let pt: number;\n\n const indices: number[] = [];\n const positions: number[] = [];\n\n let offset = 0;\n for (index = 0; index < meshes.length; index++) {\n if (meshes[index]) {\n const mesh = meshes[index];\n\n const meshPositions = (mesh.geometry.getAttribute(\n 'position'\n ) as BufferAttribute)!.array;\n\n if (!meshPositions) {\n continue;\n }\n\n let meshIndices = mesh.geometry.getIndex()?.array;\n\n if (!meshIndices) {\n const indices = [];\n for (let i = 0; i < meshPositions.length / 3; i++) {\n indices.push(i);\n }\n meshIndices = indices;\n }\n\n for (tri = 0; tri < meshIndices.length; tri++) {\n indices.push(meshIndices[tri] + offset);\n }\n\n const position = new Vector3();\n for (pt = 0; pt < meshPositions.length; pt += 3) {\n position.set(\n meshPositions[pt],\n meshPositions[pt + 1],\n meshPositions[pt + 2]\n );\n mesh.localToWorld(position);\n\n positions.push(position.x, position.y, position.z);\n }\n\n offset += meshPositions.length / 3;\n }\n }\n\n return [positions, indices];\n};\n\nexport const threeToNavMesh = (\n meshes: Mesh[],\n navMeshConfig: Partial<NavMeshConfig> = {}\n): NavMesh => {\n const [positions, indices] = threeToNavMeshArgs(meshes);\n\n const navMesh = new NavMesh();\n navMesh.build(positions, indices, navMeshConfig);\n\n return navMesh;\n};\n"],"names":["CrowdHelper","agents","agentMeshes","Map","recastCrowd","agentMaterial","constructor","crowd","this","MeshBasicMaterial","color","wireframe","Group","update","agentsIndices","getAgents","unseen","Set","keys","i","delete","position","getAgentPosition","velocity","getAgentVelocity","agentParams","getAgentParameters","agentMesh","get","undefined","createAgentMesh","add","set","x","y","height","z","lookAt","Vector3","copy","agentId","remove","geometry","CapsuleGeometry","radius","Mesh","NavMeshHelper","navMesh","obstacles","obstacleMeshes","navMeshMaterial","obstacleMaterial","recastNavMesh","BufferGeometry","updateNavMesh","updateObstacles","positions","indices","getDebugNavMesh","length","tmp","setAttribute","BufferAttribute","Float32Array","setIndex","Uint16Array","computeVertexNormals","ref","obstacle","obstacleMesh","mesh","type","extent","angle","BoxGeometry","rotation","Error","CylinderGeometry","threeToNavMeshArgs","meshes","index","tri","pt","offset","meshPositions","getAttribute","array","meshIndices","getIndex","push","localToWorld","threeToNavMesh","navMeshConfig","NavMesh","build"],"mappings":"yOA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cF,EAAK,IAErBZ,EAAKoB,aAAarE,GAElBmC,EAAUiC,KAAKpE,EAASY,EAAGZ,EAASa,EAAGb,EAASe,GAGlD+C,GAAUC,EAAczB,OAAS,CAClC,CAGH,MAAO,CAACH,EAAWC,EAAQ,EAGhBkC,EAAiB,CAC5BZ,EACAa,EAAwC,MAExC,MAAOpC,EAAWC,GAAWqB,EAAmBC,GAE1ChC,EAAU,IAAI8C,EAGpB,OAFA9C,EAAQ+C,MAAMtC,EAAWC,EAASmC,GAE3B7C,CAAO"}
1
+ {"version":3,"file":"index.es.js","sources":["../src/helpers/crowd-helper.ts","../src/helpers/nav-mesh-helper.ts","../src/helpers/tile-cache-helper.ts","../src/utils/three-to-nav-mesh.ts"],"sourcesContent":["import { Crowd, CrowdAgentParams } from '@recast-navigation/core';\nimport {\n CapsuleGeometry,\n Group,\n Material,\n Mesh,\n MeshBasicMaterial,\n Vector3,\n} from 'three';\n\nexport type CrowdHelperParams = {\n crowd: Crowd;\n agentMaterial?: Material;\n};\n\nexport class CrowdHelper {\n agents: Group;\n\n agentMeshes: Map<number, Mesh> = new Map();\n\n recastCrowd: Crowd;\n\n agentMaterial: Material;\n\n constructor({ crowd, agentMaterial }: CrowdHelperParams) {\n this.recastCrowd = crowd;\n \n this.agentMaterial = agentMaterial ?? new MeshBasicMaterial({ color: 'red' });\n\n this.agents = new Group();\n\n this.updateAgents();\n }\n\n /**\n * Update the three debug view of the crowd agents.\n * \n * This should be called after updating the crowd.\n */\n updateAgents() {\n const agentsIndices = this.recastCrowd.getAgents();\n\n const unseen = new Set(this.agentMeshes.keys());\n\n for (const i of agentsIndices) {\n unseen.delete(i);\n\n const position = this.recastCrowd.getAgentPosition(i);\n const velocity = this.recastCrowd.getAgentVelocity(i);\n const agentParams = this.recastCrowd.getAgentParameters(i);\n\n let agentMesh = this.agentMeshes.get(i);\n\n if (agentMesh === undefined) {\n agentMesh = this.createAgentMesh(agentParams);\n \n this.agents.add(agentMesh);\n this.agentMeshes.set(i, agentMesh);\n }\n\n agentMesh.position.set(\n position.x,\n position.y + agentParams.height / 2,\n position.z\n );\n agentMesh.lookAt(\n new Vector3().copy(agentMesh.position).add(velocity as Vector3)\n ); \n }\n\n for (const agentId of unseen) {\n const agentMesh = this.agentMeshes.get(agentId);\n\n if (agentMesh) {\n this.agents.remove(agentMesh);\n this.agentMeshes.delete(agentId);\n }\n }\n }\n\n private createAgentMesh(agentParams: CrowdAgentParams): Mesh {\n const geometry = new CapsuleGeometry(\n agentParams.radius,\n agentParams.height - agentParams.radius * 2\n );\n\n return new Mesh(geometry, this.agentMaterial);\n }\n}\n","import { NavMesh } from '@recast-navigation/core';\nimport {\n BufferAttribute,\n BufferGeometry,\n Material,\n Mesh,\n MeshBasicMaterial,\n} from 'three';\n\nexport type NavMeshHelperParams = {\n navMesh: NavMesh;\n navMeshMaterial?: Material;\n};\n\nexport class NavMeshHelper {\n navMesh: Mesh;\n\n navMeshMaterial: Material;\n\n recastNavMesh: NavMesh;\n\n constructor({ navMesh, navMeshMaterial }: NavMeshHelperParams) {\n this.recastNavMesh = navMesh;\n\n this.navMeshMaterial = navMeshMaterial\n ? navMeshMaterial\n : new MeshBasicMaterial({\n color: 'orange',\n transparent: true,\n opacity: 0.7,\n });\n\n this.navMesh = new Mesh(new BufferGeometry(), this.navMeshMaterial);\n\n this.updateNavMesh();\n }\n\n /**\n * Update the three debug nav mesh.\n *\n * This should be called after updating the nav mesh.\n */\n updateNavMesh() {\n const { positions, indices } = this.recastNavMesh.getDebugNavMesh();\n\n for (let i = 0; i < indices.length; i += 3) {\n const tmp = indices[i];\n indices[i] = indices[i + 2];\n indices[i + 2] = tmp;\n }\n\n const geometry = this.navMesh.geometry;\n\n geometry.setAttribute(\n 'position',\n new BufferAttribute(new Float32Array(positions), 3)\n );\n\n geometry.setIndex(new BufferAttribute(new Uint16Array(indices), 1));\n\n geometry.computeVertexNormals();\n }\n}\n","import { ObstacleRef, TileCache } from '@recast-navigation/core';\nimport {\n BoxGeometry,\n CylinderGeometry,\n Group,\n Material,\n Mesh,\n MeshBasicMaterial,\n Vector3,\n} from 'three';\n\nexport type TileCacheHelperParams = {\n tileCache: TileCache;\n obstacleMaterial?: Material;\n};\n\nexport class TileCacheHelper {\n tileCache: TileCache;\n\n obstacles: Group;\n\n obstacleMeshes: Map<ObstacleRef, Mesh> = new Map();\n\n obstacleMaterial: Material;\n\n constructor({ tileCache, obstacleMaterial }: TileCacheHelperParams) {\n this.tileCache = tileCache;\n\n this.obstacleMaterial = obstacleMaterial\n ? obstacleMaterial\n : new MeshBasicMaterial({ color: 'red', wireframe: true, wireframeLinewidth: 2 });\n\n this.obstacles = new Group();\n\n this.updateObstacles();\n }\n\n /**\n * Update the obstacle meshes.\n *\n * This should be called after adding or removing obstacles.\n */\n updateObstacles() {\n const unseen = new Set(this.obstacleMeshes.keys());\n\n for (const [ref, obstacle] of this.tileCache.obstacles) {\n let obstacleMesh = this.obstacleMeshes.get(ref);\n\n unseen.delete(ref);\n\n if (!obstacleMesh) {\n const { position } = obstacle;\n\n const mesh = new Mesh(undefined, this.obstacleMaterial);\n\n mesh.position.copy(position as Vector3);\n\n if (obstacle.type === 'box') {\n const { extent, angle } = obstacle;\n\n mesh.geometry = new BoxGeometry(\n extent.x * 2,\n extent.y * 2,\n extent.z * 2\n );\n\n mesh.rotation.y = angle;\n } else if (obstacle.type === 'cylinder') {\n const { radius, height } = obstacle;\n\n mesh.geometry = new CylinderGeometry(radius, radius, height, 16);\n\n mesh.position.y += height / 2;\n } else {\n throw new Error(`Unknown obstacle type: ${obstacle}`);\n }\n\n this.obstacles.add(mesh);\n this.obstacleMeshes.set(ref, mesh);\n }\n }\n\n for (const ref of unseen) {\n const obstacleMesh = this.obstacleMeshes.get(ref);\n\n if (obstacleMesh) {\n this.obstacles.remove(obstacleMesh);\n this.obstacleMeshes.delete(ref);\n }\n }\n }\n}\n","import {\n NavMeshConfig,\n NavMeshGenerator,\n NavMeshGeneratorResult,\n} from '@recast-navigation/core';\nimport { BufferAttribute, Mesh, Vector3 } from 'three';\n\nconst tmpVec3 = new Vector3();\n\nexport const getPositionsAndIndices = (\n meshes: Mesh[]\n): [positions: Float32Array, indices: Uint32Array] => {\n const meshesToMerge: Mesh[] = [];\n\n let mergedPositionsLength = 0;\n let mergedIndicesLength = 0;\n\n for (const mesh of meshes) {\n const positionAttribute = mesh.geometry.attributes\n .position as BufferAttribute;\n\n if (!positionAttribute || positionAttribute.itemSize !== 3) {\n continue;\n }\n\n mergedPositionsLength += positionAttribute.array.length;\n\n mergedIndicesLength +=\n mesh.geometry.getIndex()?.array.length ??\n positionAttribute.array.length / 3;\n\n meshesToMerge.push(mesh);\n }\n\n const mergedPositions = new Float32Array(mergedPositionsLength);\n const mergedIndices = new Uint32Array(mergedIndicesLength);\n\n let indicesOffset = 0;\n let positionsOffset = 0;\n\n for (const mesh of meshesToMerge) {\n const positionAttribute = mesh.geometry.attributes\n .position as BufferAttribute;\n const positionArray = positionAttribute.array;\n\n const position = tmpVec3;\n for (let pt = 0; pt < positionArray.length; pt += 3) {\n position.set(\n positionArray[pt],\n positionArray[pt + 1],\n positionArray[pt + 2]\n );\n mesh.localToWorld(position);\n\n mergedPositions[pt + positionsOffset] = position.x;\n mergedPositions[pt + positionsOffset + 1] = position.y;\n mergedPositions[pt + positionsOffset + 2] = position.z;\n }\n\n const index = mesh.geometry.getIndex()?.array;\n\n if (index) {\n for (let tri = 0; tri < index.length; tri++) {\n mergedIndices[tri + indicesOffset] = index[tri] + indicesOffset;\n }\n } else {\n for (let i = 0; i < positionArray.length / 3; i++) {\n mergedIndices[i + indicesOffset] = i + indicesOffset;\n }\n }\n\n positionsOffset += positionArray.length;\n indicesOffset += positionArray.length / 3;\n }\n\n for (let i = 0; i < mergedIndices.length; i += 3) {\n const tmp = mergedIndices[i];\n mergedIndices[i] = mergedIndices[i + 2];\n mergedIndices[i + 2] = tmp;\n }\n\n return [mergedPositions, mergedIndices];\n};\n\nexport const threeToNavMesh = (\n meshes: Mesh[],\n navMeshConfig: Partial<NavMeshConfig> = {}\n): NavMeshGeneratorResult => {\n const [positions, indices] = getPositionsAndIndices(meshes);\n\n const navMeshGenerator = new NavMeshGenerator();\n\n return navMeshGenerator.generate(positions, indices, navMeshConfig);\n};\n"],"names":["CrowdHelper","agents","agentMeshes","Map","recastCrowd","agentMaterial","constructor","crowd","this","MeshBasicMaterial","color","Group","updateAgents","agentsIndices","getAgents","unseen","Set","keys","i","delete","position","getAgentPosition","velocity","getAgentVelocity","agentParams","getAgentParameters","agentMesh","get","undefined","createAgentMesh","add","set","x","y","height","z","lookAt","Vector3","copy","agentId","remove","geometry","CapsuleGeometry","radius","Mesh","NavMeshHelper","navMesh","navMeshMaterial","recastNavMesh","transparent","opacity","BufferGeometry","updateNavMesh","positions","indices","getDebugNavMesh","length","tmp","setAttribute","BufferAttribute","Float32Array","setIndex","Uint16Array","computeVertexNormals","TileCacheHelper","tileCache","obstacles","obstacleMeshes","obstacleMaterial","wireframe","wireframeLinewidth","updateObstacles","ref","obstacle","obstacleMesh","mesh","type","extent","angle","BoxGeometry","rotation","Error","CylinderGeometry","tmpVec3","getPositionsAndIndices","meshes","meshesToMerge","mergedPositionsLength","mergedIndicesLength","positionAttribute","attributes","itemSize","array","getIndex","push","mergedPositions","mergedIndices","Uint32Array","indicesOffset","positionsOffset","positionArray","pt","localToWorld","index","tri","threeToNavMesh","navMeshConfig","NavMeshGenerator","generate"],"mappings":"kPAeaA,EACXC,OAEAC,YAAiC,IAAIC,IAErCC,YAEAC,cAEAC,aAAYC,MAAEA,EAAKF,cAAEA,IACnBG,KAAKJ,YAAcG,EAEnBC,KAAKH,cAAgBA,GAAiB,IAAII,EAAkB,CAAEC,MAAO,QAErEF,KAAKP,OAAS,IAAIU,EAElBH,KAAKI,cACN,CAODA,eACE,MAAMC,EAAgBL,KAAKJ,YAAYU,YAEjCC,EAAS,IAAIC,IAAIR,KAAKN,YAAYe,QAExC,IAAK,MAAMC,KAAKL,EAAe,CAC7BE,EAAOI,OAAOD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,EAAcQ,EAAMN,GAAiBK,EAAMC,GAAON,OAGpD,IAAK,IAAIhF,EAAI,EAAGA,EAAIkF,EAAc5C,OAAS,EAAGtC,IAC5C8E,EAAc9E,EAAIgF,GAAiBhF,EAAIgF,EAI3CC,GAAmBC,EAAc5C,OACjC0C,GAAiBE,EAAc5C,OAAS,CACzC,CAED,IAAK,IAAItC,EAAI,EAAGA,EAAI8E,EAAcxC,OAAQtC,GAAK,EAAG,CAChD,MAAMuC,EAAMuC,EAAc9E,GAC1B8E,EAAc9E,GAAK8E,EAAc9E,EAAI,GACrC8E,EAAc9E,EAAI,GAAKuC,CACxB,CAED,MAAO,CAACsC,EAAiBC,EAAc,EAG5BS,EAAiB,CAC5BpB,EACAqB,EAAwC,MAExC,MAAOrD,EAAWC,GAAW8B,EAAuBC,GAIpD,OAFyB,IAAIsB,GAELC,SAASvD,EAAWC,EAASoD,EAAc"}
@@ -1,4 +1,4 @@
1
- import { NavMesh, NavMeshConfig } from '@recast-navigation/core';
1
+ import { NavMeshConfig, NavMeshGeneratorResult } from '@recast-navigation/core';
2
2
  import { Mesh } from 'three';
3
- export declare const threeToNavMeshArgs: (meshes: Mesh[]) => [positions: number[], indices: number[]];
4
- export declare const threeToNavMesh: (meshes: Mesh[], navMeshConfig?: Partial<NavMeshConfig>) => NavMesh;
3
+ export declare const getPositionsAndIndices: (meshes: Mesh[]) => [positions: Float32Array, indices: Uint32Array];
4
+ export declare const threeToNavMesh: (meshes: Mesh[], navMeshConfig?: Partial<NavMeshConfig>) => NavMeshGeneratorResult;
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.0.5",
9
+ "version": "0.0.7",
10
10
  "license": "MIT",
11
11
  "homepage": "https://github.com/isaac-mason/recast-navigation-js",
12
12
  "bugs": {
@@ -24,11 +24,10 @@
24
24
  "build": "rollup --config rollup.config.js --bundleConfigAsCjs"
25
25
  },
26
26
  "dependencies": {
27
- "@recast-navigation/core": "0.0.5",
28
- "three": "^0.150.1"
27
+ "@recast-navigation/core": "0.0.7"
29
28
  },
30
29
  "peerDependencies": {
31
- "three": "^0.150.1"
30
+ "three": "0.x.x"
32
31
  },
33
32
  "devDependencies": {
34
33
  "@rollup/plugin-commonjs": "^24.0.1",
@@ -52,6 +51,7 @@
52
51
  "rollup": "^3.20.0",
53
52
  "rollup-plugin-copy": "^3.4.0",
54
53
  "rollup-plugin-filesize": "^10.0.0",
54
+ "three": "^0.150.1",
55
55
  "typescript": "^4.5.4"
56
56
  },
57
57
  "packageManager": "yarn@3.2.1"