@recast-navigation/three 0.4.1 → 0.6.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,5 +1,5 @@
|
|
|
1
1
|
import { NavMesh } from '@recast-navigation/core';
|
|
2
|
-
import { Material, Mesh, Object3D } from 'three';
|
|
2
|
+
import { BufferGeometry, Material, Mesh, Object3D } from 'three';
|
|
3
3
|
export type NavMeshHelperParams = {
|
|
4
4
|
navMesh: NavMesh;
|
|
5
5
|
navMeshMaterial?: Material;
|
|
@@ -8,6 +8,7 @@ export declare class NavMeshHelper extends Object3D {
|
|
|
8
8
|
navMesh: NavMesh;
|
|
9
9
|
navMeshMaterial: Material;
|
|
10
10
|
mesh: Mesh;
|
|
11
|
+
geometry: BufferGeometry;
|
|
11
12
|
constructor({ navMesh, navMeshMaterial }: NavMeshHelperParams);
|
|
12
13
|
/**
|
|
13
14
|
* Update the three debug nav mesh.
|
package/dist/index.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Object3D as e,MeshBasicMaterial as t,Vector3 as s,CapsuleGeometry as o,Mesh as a,Matrix4 as i,Color as
|
|
1
|
+
import{Object3D as e,MeshBasicMaterial as t,Vector3 as s,CapsuleGeometry as o,Mesh as a,Matrix4 as i,Color as r,BoxGeometry as n,InstancedMesh as h,DynamicDrawUsage as l,BufferGeometry as c,BufferAttribute as g,CylinderGeometry as d}from"three";import{generateSoloNavMesh as p,generateTiledNavMesh as w}from"@recast-navigation/core";class f extends e{agentMeshes=new Map;recastCrowd;agentMaterial;constructor({crowd:e,agentMaterial:s}){super(),this.recastCrowd=e,this.agentMaterial=s??new t({color:"red"}),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),i=this.recastCrowd.getAgentParameters(o);let r=this.agentMeshes.get(o);void 0===r&&(r=this.createAgentMesh(i),this.add(r),this.agentMeshes.set(o,r)),r.position.set(e.x,e.y+i.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.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)}}const m=new i;class u extends e{heightfields;highlightWalkable;defaultColor;walkableColor;material;constructor({heightfields:e,highlightWalkable:s=!1,material:o=new t,defaultColor:a="blue",walkableColor:i="green"}){super(),this.heightfields=e,this.highlightWalkable=s,this.material=o,this.defaultColor=new r(a),this.walkableColor=new r(i),this.update()}update(){this.clear();for(const e of this.heightfields){const t=e.bmin(),s=e.cs(),o=e.ch(),a=e.width(),i=e.height(),r=[];for(let n=0;n<i;++n)for(let i=0;i<a;++i){const h=t.x+i*s,l=t.z+n*s;let c=e.spans(i+n*a);for(;c;){const e=h,a=t.y+c.smin()*o,i=l,n=h+s,g=t.y+c.smax()*o,d=l+s;r.push({position:[(n+e)/2,(g+a)/2,(d+i)/2],walkable:this.highlightWalkable&&0!==c.area()}),c=c.next()}}const c=new n(s,o,s),g=new h(c,this.material,r.length);g.instanceMatrix.setUsage(l);for(let e=0;e<r.length;e++){const{position:t,walkable:s}=r[e];g.setMatrixAt(e,m.setPosition(...t)),g.setColorAt(e,s?this.walkableColor:this.defaultColor)}g.instanceMatrix.needsUpdate=!0,g.instanceColor&&(g.instanceColor.needsUpdate=!0),this.add(g)}}}class M extends e{navMesh;navMeshMaterial;mesh;geometry;constructor({navMesh:e,navMeshMaterial:s}){super(),this.navMesh=e,this.navMeshMaterial=s||new t({color:"orange",transparent:!0,opacity:.7}),this.geometry=new c,this.update(),this.mesh=new a(this.geometry,this.navMeshMaterial),this.add(this.mesh)}update(){const[e,t]=this.navMesh.getDebugNavMesh();this.geometry.setAttribute("position",new g(Float32Array.from(e),3)),this.geometry.setIndex(new g(Uint32Array.from(t),1)),this.geometry.computeVertexNormals()}}class y extends e{tileCache;obstacleMeshes=new Map;obstacleMaterial;constructor({tileCache:e,obstacleMaterial:s}){super(),this.tileCache=e,this.obstacleMaterial=s||new t({color:"red",wireframe:!0,wireframeLinewidth:2}),this.update()}update(){const e=new Set(this.obstacleMeshes.keys());for(const[,t]of this.tileCache.obstacles){let s=this.obstacleMeshes.get(t);if(e.delete(t),!s){const{position:e}=t,s=new a(void 0,this.obstacleMaterial);if(s.position.copy(e),"box"===t.type){const{extent:e,angle:o}=t;s.geometry=new n(2*e.x,2*e.y,2*e.z),s.rotation.y=o}else{if("cylinder"!==t.type)throw new Error(`Unknown obstacle type: ${t}`);{const{radius:e,height:o}=t;s.geometry=new d(e,e,o,16),s.position.y+=o/2}}this.add(s),this.obstacleMeshes.set(t,s)}}for(const t of e){const e=this.obstacleMeshes.get(t);e&&(this.remove(e),this.obstacleMeshes.delete(t))}}}const b=new s,x=e=>{const t=[];for(const s of e){const e=s.geometry.attributes.position;if(!e||3!==e.itemSize)continue;let o=s,a=s.geometry.getIndex()?.array;if(!a){o=o.clone(),o.geometry=s.geometry.clone();const t=[];for(let s=0;s<e.count;s++)t.push(s);o.geometry.setIndex(t)}t.push(o)}const s=[],o=[],a={};let i=0;for(const e of t){e.updateMatrixWorld();const t=e.geometry.attributes.position.array,r=e.geometry.getIndex().array;for(let n=0;n<r.length;n++){const h=3*r[n],l=b.set(t[h],t[h+1],t[h+2]);e.localToWorld(l);const c=`${l.x}_${l.y}_${l.z}`;let g=a[c];g||(a[c]=g=i,s.push(l.x,l.y,l.z),i++),o.push(g)}}return[Float32Array.from(s),Uint32Array.from(o)]},C=(e,t={},s=!1)=>{const[o,a]=x(e);return p(o,a,t,s)},k=(e,t={},s=!1)=>{const[o,a]=x(e);return w(o,a,t,s)};export{f as CrowdHelper,u as HeightfieldHelper,M as NavMeshHelper,y as TileCacheHelper,x as getPositionsAndIndices,C as threeToSoloNavMesh,k as threeToTiledNavMesh};
|
|
2
2
|
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/helpers/crowd-helper.ts","../src/helpers/heightfield-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 Material,\n Mesh,\n MeshBasicMaterial,\n Object3D,\n Vector3\n} from 'three';\n\nexport type CrowdHelperParams = {\n crowd: Crowd;\n agentMaterial?: Material;\n};\n\nexport class CrowdHelper extends Object3D {\n agentMeshes: Map<number, Mesh> = new Map();\n\n recastCrowd: Crowd;\n\n agentMaterial: Material;\n\n constructor({ crowd, agentMaterial }: CrowdHelperParams) {\n super()\n\n this.recastCrowd = crowd;\n \n this.agentMaterial = agentMaterial ?? new MeshBasicMaterial({ color: 'red' });\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.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.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 { RecastHeightfield, RecastSpan } from '@recast-navigation/core';\nimport {\n BoxGeometry,\n Color,\n ColorRepresentation,\n DynamicDrawUsage,\n InstancedMesh,\n Material,\n Matrix4,\n MeshBasicMaterial,\n Object3D,\n Vector3Tuple,\n} from 'three';\n\nconst tmpMatrix4 = new Matrix4();\n\nexport type HeightfieldHelperParams = {\n heightfields: RecastHeightfield[];\n\n /**\n * @default false\n */\n highlightWalkable?: boolean;\n\n /**\n * @default 'blue'\n */\n defaultColor?: ColorRepresentation;\n\n /**\n * @default 'green'\n */\n walkableColor?: ColorRepresentation;\n\n /**\n * @default MeshBasicMaterial\n */\n material?: Material;\n};\n\nexport class HeightfieldHelper extends Object3D {\n heightfields: RecastHeightfield[];\n\n highlightWalkable: boolean;\n\n defaultColor: Color;\n\n walkableColor: Color;\n\n material: Material;\n\n constructor({\n heightfields,\n highlightWalkable = false,\n material = new MeshBasicMaterial(),\n defaultColor = 'blue',\n walkableColor = 'green',\n }: HeightfieldHelperParams) {\n super();\n\n this.heightfields = heightfields;\n this.highlightWalkable = highlightWalkable;\n this.material = material;\n this.defaultColor = new Color(defaultColor);\n this.walkableColor = new Color(walkableColor);\n }\n\n update(): void {\n this.clear();\n\n for (const hf of this.heightfields) {\n const orig = hf.bmin();\n const cs = hf.cs();\n const ch = hf.ch();\n\n const width = hf.width();\n const height = hf.height();\n\n const boxes: {\n position: Vector3Tuple;\n walkable: boolean;\n }[] = [];\n\n for (let y = 0; y < height; ++y) {\n for (let x = 0; x < width; ++x) {\n const fx = orig.x + x * cs;\n const fz = orig.z + y * cs;\n\n let span: RecastSpan | null = hf.spans(x + y * width);\n\n while (span) {\n const minX = fx;\n const minY = orig.y + span.smin() * ch;\n const minZ = fz;\n\n const maxX = fx + cs;\n const maxY = orig.y + span.smax() * ch;\n const maxZ = fz + cs;\n\n boxes.push({\n position: [\n (maxX + minX) / 2,\n (maxY + minY) / 2,\n (maxZ + minZ) / 2,\n ],\n walkable: this.highlightWalkable && span.area() !== 0,\n });\n\n span = span.next();\n }\n }\n }\n\n const geometry = new BoxGeometry(cs, ch, cs);\n\n const instancedMesh = new InstancedMesh(\n geometry,\n this.material,\n boxes.length\n );\n instancedMesh.instanceMatrix.setUsage(DynamicDrawUsage);\n\n for (let i = 0; i < boxes.length; i++) {\n const { position, walkable } = boxes[i];\n\n instancedMesh.setMatrixAt(i, tmpMatrix4.setPosition(...position));\n instancedMesh.setColorAt(\n i,\n walkable ? this.walkableColor : this.defaultColor\n );\n }\n\n instancedMesh.instanceMatrix.needsUpdate = true;\n\n if (instancedMesh.instanceColor) {\n instancedMesh.instanceColor.needsUpdate = true;\n }\n\n this.add(instancedMesh);\n }\n }\n}\n","import { NavMesh } from '@recast-navigation/core';\nimport {\n BufferAttribute,\n BufferGeometry,\n Material,\n Mesh,\n MeshBasicMaterial,\n Object3D,\n} from 'three';\n\nexport type NavMeshHelperParams = {\n navMesh: NavMesh;\n navMeshMaterial?: Material;\n};\n\nexport class NavMeshHelper extends Object3D {\n navMesh: NavMesh;\n \n navMeshMaterial: Material;\n\n mesh: Mesh;\n\n constructor({ navMesh, navMeshMaterial }: NavMeshHelperParams) {\n super();\n\n this.navMesh = 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.mesh = new Mesh(new BufferGeometry(), this.navMeshMaterial);\n this.add(this.mesh)\n\n this.update();\n }\n\n /**\n * Update the three debug nav mesh.\n *\n * This should be called after updating the nav mesh.\n */\n update() {\n const { positions, indices } = this.navMesh.getDebugNavMesh();\n\n const geometry = this.mesh.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 { Obstacle, TileCache } from '@recast-navigation/core';\nimport {\n BoxGeometry,\n CylinderGeometry,\n Material,\n Mesh,\n MeshBasicMaterial,\n Object3D,\n Vector3,\n} from 'three';\n\nexport type TileCacheHelperParams = {\n tileCache: TileCache;\n obstacleMaterial?: Material;\n};\n\nexport class TileCacheHelper extends Object3D {\n tileCache: TileCache;\n\n obstacleMeshes: Map<Obstacle, Mesh> = new Map();\n\n obstacleMaterial: Material;\n\n constructor({ tileCache, obstacleMaterial }: TileCacheHelperParams) {\n super();\n\n this.tileCache = tileCache;\n\n this.obstacleMaterial = obstacleMaterial\n ? obstacleMaterial\n : new MeshBasicMaterial({\n color: 'red',\n wireframe: true,\n wireframeLinewidth: 2,\n });\n\n this.update();\n }\n\n /**\n * Update the obstacle meshes.\n *\n * This should be called after adding or removing obstacles.\n */\n update() {\n const unseen = new Set(this.obstacleMeshes.keys());\n\n for (const [, obstacle] of this.tileCache.obstacles) {\n let obstacleMesh = this.obstacleMeshes.get(obstacle);\n\n unseen.delete(obstacle);\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.add(mesh);\n this.obstacleMeshes.set(obstacle, mesh);\n }\n }\n\n for (const obstacle of unseen) {\n const obstacleMesh = this.obstacleMeshes.get(obstacle);\n\n if (obstacleMesh) {\n this.remove(obstacleMesh);\n this.obstacleMeshes.delete(obstacle);\n }\n }\n }\n}\n","import {\n generateSoloNavMesh,\n generateTiledNavMesh,\n SoloNavMeshGeneratorConfig,\n TiledNavMeshGeneratorConfig\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 threeToSoloNavMesh = (\n meshes: Mesh[],\n navMeshGeneratorConfig: Partial<SoloNavMeshGeneratorConfig> = {},\n keepIntermediates = false\n) => {\n const [positions, indices] = getPositionsAndIndices(meshes);\n\n return generateSoloNavMesh(\n positions,\n indices,\n navMeshGeneratorConfig,\n keepIntermediates\n );\n};\n\nexport const threeToTiledNavMesh = (\n meshes: Mesh[],\n navMeshGeneratorConfig: Partial<TiledNavMeshGeneratorConfig> = {},\n keepIntermediates = false\n) => {\n const [positions, indices] = getPositionsAndIndices(meshes);\n\n return generateTiledNavMesh(\n positions,\n indices,\n navMeshGeneratorConfig,\n keepIntermediates\n );\n};\n"],"names":["CrowdHelper","Object3D","agentMeshes","Map","recastCrowd","agentMaterial","constructor","crowd","super","this","MeshBasicMaterial","color","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","tmpMatrix4","Matrix4","HeightfieldHelper","heightfields","highlightWalkable","defaultColor","walkableColor","material","Color","clear","hf","orig","bmin","cs","ch","width","boxes","fx","fz","span","spans","minX","minY","smin","minZ","maxX","maxY","smax","maxZ","push","walkable","area","next","BoxGeometry","instancedMesh","InstancedMesh","length","instanceMatrix","setUsage","DynamicDrawUsage","setMatrixAt","setPosition","setColorAt","needsUpdate","instanceColor","NavMeshHelper","navMesh","navMeshMaterial","mesh","transparent","opacity","BufferGeometry","positions","indices","getDebugNavMesh","setAttribute","BufferAttribute","Float32Array","setIndex","Uint16Array","computeVertexNormals","TileCacheHelper","tileCache","obstacleMeshes","obstacleMaterial","wireframe","wireframeLinewidth","obstacle","obstacles","obstacleMesh","type","extent","angle","rotation","Error","CylinderGeometry","tmpVec3","getPositionsAndIndices","meshes","meshesToMerge","mergedPositionsLength","mergedIndicesLength","positionAttribute","attributes","itemSize","array","getIndex","mergedPositions","mergedIndices","Uint32Array","indicesOffset","positionsOffset","positionArray","pt","localToWorld","index","tri","tmp","threeToSoloNavMesh","navMeshGeneratorConfig","keepIntermediates","generateSoloNavMesh","threeToTiledNavMesh","generateTiledNavMesh"],"mappings":"6UAeM,MAAOA,UAAoBC,EAC/BC,YAAiC,IAAIC,IAErCC,YAEAC,cAEA,WAAAC,EAAYC,MAAEA,EAAKF,cAAEA,IACnBG,QAEAC,KAAKL,YAAcG,EAEnBE,KAAKJ,cAAgBA,GAAiB,IAAIK,EAAkB,CAAEC,MAAO,QAErEF,KAAKG,QACN,CAOD,MAAAA,GACE,MAAMC,EAAgBJ,KAAKL,YAAYU,YAEjCC,EAAS,IAAIC,IAAIP,KAAKP,YAAYe,QAExC,IAAK,MAAMC,KAAKL,EAAe,CAC7BE,EAAOI,OAAOD,GAEd,MAAME,EAAWX,KAAKL,YAAYiB,iBAAiBH,GAC7CI,EAAWb,KAAKL,YAAYmB,iBAAiBL,GAC7CM,EAAcf,KAAKL,YAAYqB,mBAAmBP,GAExD,IAAIQ,EAAYjB,KAAKP,YAAYyB,IAAIT,QAEnBU,IAAdF,IACFA,EAAYjB,KAAKoB,gBAAgBL,GAEjCf,KAAKqB,IAAIJ,GACTjB,KAAKP,YAAY6B,IAAIb,EAAGQ,IAG1BA,EAAUN,SAASW,IACjBX,EAASY,EACTZ,EAASa,EAAIT,EAAYU,OAAS,EAClCd,EAASe,GAEXT,EAAUU,QACR,IAAIC,GAAUC,KAAKZ,EAAUN,UAAUU,IAAIR,GAE9C,CAED,IAAK,MAAMiB,KAAWxB,EAAQ,CAC5B,MAAMW,EAAYjB,KAAKP,YAAYyB,IAAIY,GAEnCb,IACFjB,KAAK+B,OAAOd,GACZjB,KAAKP,YAAYiB,OAAOoB,GAE3B,CACF,CAEO,eAAAV,CAAgBL,GACtB,MAAMiB,EAAW,IAAIC,EACnBlB,EAAYmB,OACZnB,EAAYU,OAA8B,EAArBV,EAAYmB,QAGnC,OAAO,I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ED,MAAO,CAACV,EAAiBC,EAAc,EAG5BU,EAAqB,CAChCpB,EACAqB,EAA8D,CAAA,EAC9DC,GAAoB,KAEpB,MAAOhD,EAAWC,GAAWwB,EAAuBC,GAEpD,OAAOuB,EACLjD,EACAC,EACA8C,EACAC,EACD,EAGUE,EAAsB,CACjCxB,EACAqB,EAA+D,CAAA,EAC/DC,GAAoB,KAEpB,MAAOhD,EAAWC,GAAWwB,EAAuBC,GAEpD,OAAOyB,EACLnD,EACAC,EACA8C,EACAC,EACD"}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/helpers/crowd-helper.ts","../src/helpers/heightfield-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 Material,\n Mesh,\n MeshBasicMaterial,\n Object3D,\n Vector3\n} from 'three';\n\nexport type CrowdHelperParams = {\n crowd: Crowd;\n agentMaterial?: Material;\n};\n\nexport class CrowdHelper extends Object3D {\n agentMeshes: Map<number, Mesh> = new Map();\n\n recastCrowd: Crowd;\n\n agentMaterial: Material;\n\n constructor({ crowd, agentMaterial }: CrowdHelperParams) {\n super()\n\n this.recastCrowd = crowd;\n \n this.agentMaterial = agentMaterial ?? new MeshBasicMaterial({ color: 'red' });\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.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.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 { RecastHeightfield, RecastSpan } from '@recast-navigation/core';\nimport {\n BoxGeometry,\n Color,\n ColorRepresentation,\n DynamicDrawUsage,\n InstancedMesh,\n Material,\n Matrix4,\n MeshBasicMaterial,\n Object3D,\n Vector3Tuple,\n} from 'three';\n\nconst tmpMatrix4 = new Matrix4();\n\nexport type HeightfieldHelperParams = {\n heightfields: RecastHeightfield[];\n\n /**\n * @default false\n */\n highlightWalkable?: boolean;\n\n /**\n * @default 'blue'\n */\n defaultColor?: ColorRepresentation;\n\n /**\n * @default 'green'\n */\n walkableColor?: ColorRepresentation;\n\n /**\n * @default MeshBasicMaterial\n */\n material?: Material;\n};\n\nexport class HeightfieldHelper extends Object3D {\n heightfields: RecastHeightfield[];\n\n highlightWalkable: boolean;\n\n defaultColor: Color;\n\n walkableColor: Color;\n\n material: Material;\n\n constructor({\n heightfields,\n highlightWalkable = false,\n material = new MeshBasicMaterial(),\n defaultColor = 'blue',\n walkableColor = 'green',\n }: HeightfieldHelperParams) {\n super();\n\n this.heightfields = heightfields;\n this.highlightWalkable = highlightWalkable;\n this.material = material;\n this.defaultColor = new Color(defaultColor);\n this.walkableColor = new Color(walkableColor);\n\n this.update();\n }\n\n update(): void {\n this.clear();\n\n for (const hf of this.heightfields) {\n const orig = hf.bmin();\n const cs = hf.cs();\n const ch = hf.ch();\n\n const width = hf.width();\n const height = hf.height();\n\n const boxes: {\n position: Vector3Tuple;\n walkable: boolean;\n }[] = [];\n\n for (let y = 0; y < height; ++y) {\n for (let x = 0; x < width; ++x) {\n const fx = orig.x + x * cs;\n const fz = orig.z + y * cs;\n\n let span: RecastSpan | null = hf.spans(x + y * width);\n\n while (span) {\n const minX = fx;\n const minY = orig.y + span.smin() * ch;\n const minZ = fz;\n\n const maxX = fx + cs;\n const maxY = orig.y + span.smax() * ch;\n const maxZ = fz + cs;\n\n boxes.push({\n position: [\n (maxX + minX) / 2,\n (maxY + minY) / 2,\n (maxZ + minZ) / 2,\n ],\n walkable: this.highlightWalkable && span.area() !== 0,\n });\n\n span = span.next();\n }\n }\n }\n\n const geometry = new BoxGeometry(cs, ch, cs);\n\n const instancedMesh = new InstancedMesh(\n geometry,\n this.material,\n boxes.length\n );\n instancedMesh.instanceMatrix.setUsage(DynamicDrawUsage);\n\n for (let i = 0; i < boxes.length; i++) {\n const { position, walkable } = boxes[i];\n\n instancedMesh.setMatrixAt(i, tmpMatrix4.setPosition(...position));\n instancedMesh.setColorAt(\n i,\n walkable ? this.walkableColor : this.defaultColor\n );\n }\n\n instancedMesh.instanceMatrix.needsUpdate = true;\n\n if (instancedMesh.instanceColor) {\n instancedMesh.instanceColor.needsUpdate = true;\n }\n\n this.add(instancedMesh);\n }\n }\n}\n","import { NavMesh } from '@recast-navigation/core';\nimport {\n BufferAttribute,\n BufferGeometry,\n Material,\n Mesh,\n MeshBasicMaterial,\n Object3D,\n} from 'three';\n\nexport type NavMeshHelperParams = {\n navMesh: NavMesh;\n navMeshMaterial?: Material;\n};\n\nexport class NavMeshHelper extends Object3D {\n navMesh: NavMesh;\n\n navMeshMaterial: Material;\n\n mesh: Mesh;\n\n geometry: BufferGeometry;\n\n constructor({ navMesh, navMeshMaterial }: NavMeshHelperParams) {\n super();\n\n this.navMesh = 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.geometry = new BufferGeometry();\n\n this.update();\n\n this.mesh = new Mesh(this.geometry, this.navMeshMaterial);\n\n this.add(this.mesh);\n }\n\n /**\n * Update the three debug nav mesh.\n *\n * This should be called after updating the nav mesh.\n */\n update() {\n const [positions, indices] = this.navMesh.getDebugNavMesh();\n\n this.geometry.setAttribute(\n 'position',\n new BufferAttribute(Float32Array.from(positions), 3)\n );\n\n this.geometry.setIndex(new BufferAttribute(Uint32Array.from(indices), 1));\n\n this.geometry.computeVertexNormals();\n }\n}\n","import { Obstacle, TileCache } from '@recast-navigation/core';\nimport {\n BoxGeometry,\n CylinderGeometry,\n Material,\n Mesh,\n MeshBasicMaterial,\n Object3D,\n Vector3,\n} from 'three';\n\nexport type TileCacheHelperParams = {\n tileCache: TileCache;\n obstacleMaterial?: Material;\n};\n\nexport class TileCacheHelper extends Object3D {\n tileCache: TileCache;\n\n obstacleMeshes: Map<Obstacle, Mesh> = new Map();\n\n obstacleMaterial: Material;\n\n constructor({ tileCache, obstacleMaterial }: TileCacheHelperParams) {\n super();\n\n this.tileCache = tileCache;\n\n this.obstacleMaterial = obstacleMaterial\n ? obstacleMaterial\n : new MeshBasicMaterial({\n color: 'red',\n wireframe: true,\n wireframeLinewidth: 2,\n });\n\n this.update();\n }\n\n /**\n * Update the obstacle meshes.\n *\n * This should be called after adding or removing obstacles.\n */\n update() {\n const unseen = new Set(this.obstacleMeshes.keys());\n\n for (const [, obstacle] of this.tileCache.obstacles) {\n let obstacleMesh = this.obstacleMeshes.get(obstacle);\n\n unseen.delete(obstacle);\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.add(mesh);\n this.obstacleMeshes.set(obstacle, mesh);\n }\n }\n\n for (const obstacle of unseen) {\n const obstacleMesh = this.obstacleMeshes.get(obstacle);\n\n if (obstacleMesh) {\n this.remove(obstacleMesh);\n this.obstacleMeshes.delete(obstacle);\n }\n }\n }\n}\n","import {\n generateSoloNavMesh,\n generateTiledNavMesh,\n SoloNavMeshGeneratorConfig,\n TiledNavMeshGeneratorConfig,\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 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 let meshToMerge = mesh;\n let index: ArrayLike<number> | undefined = mesh.geometry.getIndex()?.array;\n\n if (!index) {\n meshToMerge = meshToMerge.clone();\n meshToMerge.geometry = mesh.geometry.clone();\n\n // this will become indexed when merging with other meshes\n const ascendingIndex: number[] = [];\n for (let i = 0; i < positionAttribute.count; i++) {\n ascendingIndex.push(i);\n }\n\n meshToMerge.geometry.setIndex(ascendingIndex);\n }\n\n meshesToMerge.push(meshToMerge);\n }\n\n const mergedPositions: number[] = [];\n const mergedIndices: number[] = [];\n\n const positionToIndex: { [hash: string]: number } = {};\n let indexCounter = 0;\n\n for (const mesh of meshesToMerge) {\n mesh.updateMatrixWorld();\n\n const positions = mesh.geometry.attributes.position.array;\n const index = mesh.geometry.getIndex()!.array;\n\n for (let i = 0; i < index.length; i++) {\n const pt = index[i] * 3;\n\n const pos = tmpVec3.set(\n positions[pt],\n positions[pt + 1],\n positions[pt + 2]\n );\n mesh.localToWorld(pos);\n\n const key = `${pos.x}_${pos.y}_${pos.z}`;\n let idx = positionToIndex[key];\n\n if (!idx) {\n positionToIndex[key] = idx = indexCounter;\n mergedPositions.push(pos.x, pos.y, pos.z);\n indexCounter++;\n }\n\n mergedIndices.push(idx);\n }\n }\n\n return [Float32Array.from(mergedPositions), Uint32Array.from(mergedIndices)];\n};\n\nexport const threeToSoloNavMesh = (\n meshes: Mesh[],\n navMeshGeneratorConfig: Partial<SoloNavMeshGeneratorConfig> = {},\n keepIntermediates = false\n) => {\n const [positions, indices] = getPositionsAndIndices(meshes);\n\n return generateSoloNavMesh(\n positions,\n indices,\n navMeshGeneratorConfig,\n keepIntermediates\n );\n};\n\nexport const threeToTiledNavMesh = (\n meshes: Mesh[],\n navMeshGeneratorConfig: Partial<TiledNavMeshGeneratorConfig> = {},\n keepIntermediates = false\n) => {\n const [positions, indices] = getPositionsAndIndices(meshes);\n\n return generateTiledNavMesh(\n positions,\n indices,\n navMeshGeneratorConfig,\n keepIntermediates\n );\n};\n"],"names":["CrowdHelper","Object3D","agentMeshes","Map","recastCrowd","agentMaterial","constructor","crowd","super","this","MeshBasicMaterial","color","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","tmpMatrix4","Matrix4","HeightfieldHelper","heightfields","highlightWalkable","defaultColor","walkableColor","material","Color","clear","hf","orig","bmin","cs","ch","width","boxes","fx","fz","span","spans","minX","minY","smin","minZ","maxX","maxY","smax","maxZ","push","walkable","area","next","BoxGeometry","instancedMesh","InstancedMesh","length","instanceMatrix","setUsage","DynamicDrawUsage","setMatrixAt","setPosition","setColorAt","needsUpdate","instanceColor","NavMeshHelper","navMesh","navMeshMaterial","mesh","transparent","opacity","BufferGeometry","positions","indices","getDebugNavMesh","setAttribute","BufferAttribute","Float32Array","from","setIndex","Uint32Array","computeVertexNormals","TileCacheHelper","tileCache","obstacleMeshes","obstacleMaterial","wireframe","wireframeLinewidth","obstacle","obstacles","obstacleMesh","type","extent","angle","rotation","Error","CylinderGeometry","tmpVec3","getPositionsAndIndices","meshes","meshesToMerge","positionAttribute","attributes","itemSize","meshToMerge","index","getIndex","array","clone","ascendingIndex","count","mergedPositions","mergedIndices","positionToIndex","indexCounter","updateMatrixWorld","pt","pos","localToWorld","key","idx","threeToSoloNavMesh","navMeshGeneratorConfig","keepIntermediates","generateSoloNavMesh","threeToTiledNavMesh","generateTiledNavMesh"],"mappings":"6UAeM,MAAOA,UAAoBC,EAC/BC,YAAiC,IAAIC,IAErCC,YAEAC,cAEA,WAAAC,EAAYC,MAAEA,EAAKF,cAAEA,IACnBG,QAEAC,KAAKL,YAAcG,EAEnBE,KAAKJ,cAAgBA,GAAiB,IAAIK,EAAkB,CAAEC,MAAO,QAErEF,KAAKG,QACN,CAOD,MAAAA,GACE,MAAMC,EAAgBJ,KAAKL,YAAYU,YAEjCC,EAAS,IAAIC,IAAIP,KAAKP,YAAYe,QAExC,IAAK,MAAMC,KAAKL,EAAe,CAC7BE,EAAOI,OAAOD,GAEd,MAAME,EAAWX,KAAKL,YAAYiB,iBAAiBH,GAC7CI,EAAWb,KAAKL,YAAYmB,iBAAiBL,GAC7CM,EAAcf,KAAKL,YAAYqB,mBAAmBP,GAExD,IAAIQ,EAAYjB,KAAKP,YAAYyB,IAAIT,QAEnBU,IAAdF,IACFA,EAAYjB,KAAKoB,gBAAgBL,GAEjCf,KAAKqB,IAAIJ,GACTjB,KAAKP,YAAY6B,IAAIb,EAAGQ,IAG1BA,EAAUN,SAASW,IACjBX,EAASY,EACTZ,EAASa,EAAIT,EAAYU,OAAS,EAClCd,EAASe,GAEXT,EAAUU,QACR,IAAIC,GAAUC,KAAKZ,EAAUN,UAAUU,IAAIR,GAE9C,CAED,IAAK,MAAMiB,KAAWxB,EAAQ,CAC5B,MAAMW,EAAYjB,KAAKP,YAAYyB,IAAI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EAAG6G,EAAI3G,GACvCwG,KAGFF,EAAc/D,KAAKuE,EACpB,CACF,CAED,MAAO,CAAC3C,aAAaC,KAAKiC,GAAkB/B,YAAYF,KAAKkC,GAAe,EAGjES,EAAqB,CAChCtB,EACAuB,EAA8D,CAAA,EAC9DC,GAAoB,KAEpB,MAAOnD,EAAWC,GAAWyB,EAAuBC,GAEpD,OAAOyB,EACLpD,EACAC,EACAiD,EACAC,EACD,EAGUE,EAAsB,CACjC1B,EACAuB,EAA+D,CAAA,EAC/DC,GAAoB,KAEpB,MAAOnD,EAAWC,GAAWyB,EAAuBC,GAEpD,OAAO2B,EACLtD,EACAC,EACAiD,EACAC,EACD"}
|
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.6.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"homepage": "https://github.com/isaac-mason/recast-navigation-js",
|
|
12
12
|
"bugs": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"build": "rollup --config rollup.config.js --bundleConfigAsCjs"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@recast-navigation/core": "0.
|
|
27
|
+
"@recast-navigation/core": "0.6.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"three": "0.x.x"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@rollup/plugin-typescript": "^11.1.2",
|
|
37
37
|
"@types/three": "^0.155.0",
|
|
38
38
|
"@typescript-eslint/eslint-plugin": "^5.7.0",
|
|
39
|
-
"@typescript-eslint/parser": "^
|
|
39
|
+
"@typescript-eslint/parser": "^6.4.1",
|
|
40
40
|
"eslint": "^8.5.0",
|
|
41
41
|
"eslint-config-airbnb": "^18.2.1",
|
|
42
42
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
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",
|
|
47
|
-
"eslint-plugin-prettier": "^
|
|
47
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
48
48
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
49
49
|
"eslint-plugin-typescript-enum": "^2.1.0",
|
|
50
50
|
"prettier": "^3.0.2",
|