@babylonjs/addons 9.0.0 → 9.2.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/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration.js.map +1 -1
- package/atmosphere/Shaders/ShadersInclude/atmosphereFunctions.js.map +1 -1
- package/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration.js.map +1 -1
- package/atmosphere/Shaders/ShadersInclude/atmosphereVertexDeclaration.js.map +1 -1
- package/atmosphere/Shaders/ShadersInclude/depthFunctions.js.map +1 -1
- package/atmosphere/Shaders/aerialPerspective.fragment.js.map +1 -1
- package/atmosphere/Shaders/compositeAerialPerspective.fragment.js.map +1 -1
- package/atmosphere/Shaders/compositeGlobeAtmosphere.fragment.js.map +1 -1
- package/atmosphere/Shaders/compositeSky.fragment.js.map +1 -1
- package/atmosphere/Shaders/diffuseSkyIrradiance.fragment.js.map +1 -1
- package/atmosphere/Shaders/fullscreenTriangle.vertex.js.map +1 -1
- package/atmosphere/Shaders/multiScattering.fragment.js.map +1 -1
- package/atmosphere/Shaders/skyView.fragment.js.map +1 -1
- package/atmosphere/Shaders/transmittance.fragment.js.map +1 -1
- package/atmosphere/ShadersWGSL/ShadersInclude/atmosphereFunctions.js.map +1 -1
- package/atmosphere/ShadersWGSL/ShadersInclude/atmosphereUboDeclaration.js.map +1 -1
- package/atmosphere/ShadersWGSL/ShadersInclude/depthFunctions.js.map +1 -1
- package/atmosphere/ShadersWGSL/aerialPerspective.fragment.js.map +1 -1
- package/atmosphere/ShadersWGSL/compositeAerialPerspective.fragment.js.map +1 -1
- package/atmosphere/ShadersWGSL/compositeGlobeAtmosphere.fragment.js.map +1 -1
- package/atmosphere/ShadersWGSL/compositeSky.fragment.js.map +1 -1
- package/atmosphere/ShadersWGSL/diffuseSkyIrradiance.fragment.js.map +1 -1
- package/atmosphere/ShadersWGSL/fullscreenTriangle.vertex.js.map +1 -1
- package/atmosphere/ShadersWGSL/multiScattering.fragment.js.map +1 -1
- package/atmosphere/ShadersWGSL/skyView.fragment.js.map +1 -1
- package/atmosphere/ShadersWGSL/transmittance.fragment.js.map +1 -1
- package/atmosphere/atmosphere.d.ts +9 -9
- package/atmosphere/atmosphere.js.map +1 -1
- package/atmosphere/atmosphereOptions.d.ts +3 -3
- package/atmosphere/atmosphereOptions.js.map +1 -1
- package/atmosphere/atmospherePBRMaterialPlugin.d.ts +5 -5
- package/atmosphere/atmospherePBRMaterialPlugin.js.map +1 -1
- package/atmosphere/atmospherePerCameraVariables.d.ts +2 -2
- package/atmosphere/atmospherePerCameraVariables.js.map +1 -1
- package/atmosphere/atmospherePhysicalProperties.d.ts +1 -1
- package/atmosphere/atmospherePhysicalProperties.js.map +1 -1
- package/atmosphere/atmospherePhysicalPropertiesOptions.d.ts +1 -1
- package/atmosphere/atmospherePhysicalPropertiesOptions.js.map +1 -1
- package/atmosphere/diffuseSkyIrradianceLut.d.ts +2 -2
- package/atmosphere/diffuseSkyIrradianceLut.js.map +1 -1
- package/atmosphere/sampling.d.ts +1 -1
- package/atmosphere/sampling.js.map +1 -1
- package/atmosphere/transmittanceLut.d.ts +3 -3
- package/atmosphere/transmittanceLut.js.map +1 -1
- package/htmlMesh/htmlMesh.d.ts +2 -2
- package/htmlMesh/htmlMesh.js.map +1 -1
- package/htmlMesh/htmlMeshRenderer.d.ts +3 -3
- package/htmlMesh/htmlMeshRenderer.js.map +1 -1
- package/htmlMesh/pointerEventsCapture.js.map +1 -1
- package/htmlMesh/pointerEventsCaptureBehavior.d.ts +2 -2
- package/htmlMesh/pointerEventsCaptureBehavior.js.map +1 -1
- package/msdfText/fontAsset.d.ts +3 -3
- package/msdfText/fontAsset.js.map +1 -1
- package/msdfText/paragraphOptions.d.ts +3 -3
- package/msdfText/paragraphOptions.js.map +1 -1
- package/msdfText/sdf/font.d.ts +1 -1
- package/msdfText/sdf/font.js.map +1 -1
- package/msdfText/sdf/glyph.d.ts +1 -1
- package/msdfText/sdf/glyph.js.map +1 -1
- package/msdfText/sdf/line.d.ts +1 -1
- package/msdfText/sdf/line.js.map +1 -1
- package/msdfText/sdf/paragraph.d.ts +3 -3
- package/msdfText/sdf/paragraph.js.map +1 -1
- package/msdfText/shaders/msdf.fragment.js.map +1 -1
- package/msdfText/shaders/msdf.vertex.js.map +1 -1
- package/msdfText/shadersWGSL/msdf.fragment.js.map +1 -1
- package/msdfText/shadersWGSL/msdf.vertex.js.map +1 -1
- package/msdfText/textRenderer.d.ts +10 -6
- package/msdfText/textRenderer.js +9 -0
- package/msdfText/textRenderer.js.map +1 -1
- package/navigation/common/config.d.ts +3 -3
- package/navigation/common/config.js.map +1 -1
- package/navigation/common/convert.d.ts +1 -1
- package/navigation/common/convert.js.map +1 -1
- package/navigation/common/getters.js.map +1 -1
- package/navigation/common/smooth-path.d.ts +2 -2
- package/navigation/common/smooth-path.js.map +1 -1
- package/navigation/common/tile-cache.d.ts +1 -1
- package/navigation/common/tile-cache.js.map +1 -1
- package/navigation/common/utils.d.ts +1 -1
- package/navigation/common/utils.js.map +1 -1
- package/navigation/debug/NavigationDebugger.d.ts +5 -5
- package/navigation/debug/NavigationDebugger.js.map +1 -1
- package/navigation/debug/simple-debug.d.ts +3 -3
- package/navigation/debug/simple-debug.js.map +1 -1
- package/navigation/factory/common.d.ts +1 -1
- package/navigation/factory/common.js.map +1 -1
- package/navigation/factory/factory.single-thread.d.ts +1 -1
- package/navigation/factory/factory.single-thread.js.map +1 -1
- package/navigation/factory/factory.worker.js +6 -0
- package/navigation/factory/factory.worker.js.map +1 -1
- package/navigation/generator/generator.common.d.ts +1 -1
- package/navigation/generator/generator.common.js.map +1 -1
- package/navigation/generator/generator.single-thread.d.ts +2 -2
- package/navigation/generator/generator.single-thread.js.map +1 -1
- package/navigation/generator/generator.worker.d.ts +3 -3
- package/navigation/generator/generator.worker.js.map +1 -1
- package/navigation/generator/injection.d.ts +1 -1
- package/navigation/generator/injection.js.map +1 -1
- package/navigation/plugin/RecastJSCrowd.d.ts +7 -7
- package/navigation/plugin/RecastJSCrowd.js.map +1 -1
- package/navigation/plugin/RecastNavigationJSPlugin.d.ts +7 -7
- package/navigation/plugin/RecastNavigationJSPlugin.js.map +1 -1
- package/navigation/types.d.ts +6 -6
- package/navigation/types.js.map +1 -1
- package/navigation/worker/navmesh-worker.js +1 -1
- package/navigation/worker/navmesh-worker.js.map +1 -1
- package/package.json +3 -3
- package/readme.md +12 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.single-thread.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/generator/generator.single-thread.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"generator.single-thread.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/generator/generator.single-thread.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACnH,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAAC,MAAmB,EAAE,UAAgC;IACjF,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAE3B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IAC3E,CAAC;IAED,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,sBAAsB,CAAC,MAAM,EAAE,EAAE,mBAAmB,EAAE,UAAU,CAAC,mBAAmB,EAAE,CAAC,CAAC;IACrH,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CA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ACH,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,YAAY,EAAE,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC;QACrD,SAAS,EAAE,WAAW,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;KAClE,CAAC;AACN,CAAC","sourcesContent":["import { type SoloNavMeshGeneratorConfig, type TileCacheGeneratorConfig, type TiledNavMeshGeneratorConfig } from \"@recast-navigation/generators\";\n\nimport { Logger } from \"core/Misc/logger\";\nimport { type Mesh } from \"core/Meshes/mesh\";\n\nimport { type INavMeshParametersV2 } from \"../types\";\nimport { GetPositionsAndIndices } from \"../common/getters\";\nimport { CreateSoloNavMeshConfig, CreateTileCacheNavMeshConfig, CreateTiledNavMeshConfig } from \"../common/config\";\nimport { GetRecast } from \"../factory/common\";\n\n/**\n * Builds a NavMesh and NavMeshQuery from meshes using provided parameters.\n * @param meshes The array of meshes used to create the NavMesh.\n * @param parameters The parameters used to configure the NavMesh generation.\n * @returns An object containing the NavMesh and NavMeshQuery.\n * @remarks This function generates a NavMesh based on the provided meshes and parameters.\n * It supports different configurations such as solo, tiled, and tile cache nav meshes.\n * If you need obstacles, ensure that `maxObstacles` is set to a value greater than 0.\n * Recommended values for `tileSize` are between 32 and 64 when using obstacles/tile cache.\n * If you need a tiled nav mesh, ensure that `tileSize` is set to a value greater than 0.\n * @throws Error if the NavMesh data is invalid or cannot be deserialized.\n */\nexport function GenerateNavMesh(meshes: Array<Mesh>, parameters: INavMeshParametersV2) {\n const recast = GetRecast();\n\n if (meshes.length === 0) {\n throw new Error(\"At least one mesh is needed to create the nav mesh.\");\n }\n\n const [positions, indices] = GetPositionsAndIndices(meshes, { doNotReverseIndices: parameters.doNotReverseIndices });\n if (!positions || !indices) {\n throw new Error(\"Unable to get nav mesh. No vertices or indices.\");\n }\n\n // Decide on the type of nav mesh to generate based on parameters\n // If tileSize is set, we will generate a tiled nav mesh\n // If maxObstacles is set, we will generate a tile cache nav mesh\n // Otherwise, we will generate a solo nav mesh\n // Note: tileSize is only used for tiled nav meshes, not tile cache nav meshes\n // If both tileSize and maxObstacles are set, we will generate a tile cache\n const tileSize = parameters.tileSize ?? 0;\n const needsTileCache = (parameters.maxObstacles ?? 0) > 0;\n const needsTiledNavMesh = tileSize > 0;\n if (needsTileCache) {\n if (tileSize < 32 || tileSize > 64) {\n Logger.Warn(\"NavigationPlugin: Tile cache is enabled. Recommended tileSize is 32 to 64. Other values may lead to unexpected behavior.\");\n }\n }\n\n // Create the appropriate configuration based on the parameters\n const config = needsTileCache ? CreateTileCacheNavMeshConfig(parameters) : needsTiledNavMesh ? CreateTiledNavMeshConfig(parameters) : CreateSoloNavMeshConfig(parameters);\n const result = needsTileCache\n ? recast.generateTileCache(positions, indices, config as TileCacheGeneratorConfig, parameters.keepIntermediates)\n : needsTiledNavMesh\n ? recast.generateTiledNavMesh(positions, indices, config as TiledNavMeshGeneratorConfig, parameters.keepIntermediates)\n : recast.generateSoloNavMesh(positions, indices, config as SoloNavMeshGeneratorConfig, parameters.keepIntermediates);\n\n if (!result.success) {\n throw new Error(`Unable to generateSoloNavMesh: ${result.error}`);\n }\n\n return {\n navMesh: result.navMesh,\n intermediates: result.intermediates,\n navMeshQuery: new recast.NavMeshQuery(result.navMesh),\n tileCache: \"tileCache\" in result ? result.tileCache : undefined,\n };\n}\n"]}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* Workers are not yet supported.
|
|
5
5
|
* For more info visit: https://forum.babylonjs.com/t/replacing-recastjs-with-recast-navigation-js/56003/46
|
|
6
6
|
*/
|
|
7
|
-
import type
|
|
8
|
-
import type
|
|
9
|
-
import type
|
|
7
|
+
import { type NavMeshQuery, type NavMesh, type TileCache } from "@recast-navigation/core";
|
|
8
|
+
import { type Mesh } from "@babylonjs/core/Meshes/mesh.js";
|
|
9
|
+
import { type INavMeshParametersV2 } from "../types.js";
|
|
10
10
|
/**
|
|
11
11
|
* Builds a NavMesh and NavMeshQuery from meshes using provided parameters.
|
|
12
12
|
* @param meshes The array of meshes used to create the NavMesh.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.worker.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/generator/generator.worker.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,iCAAiC,EAAE,MAAM,sBAAsB,CAAC;AAEzE;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CACrC,MAAmB,EACnB,UAAgC,EAChC,aAYC;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IAC3E,CAAC;IAED,2DAA2D;IAC3D,aAAa,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,EAAE;QACnC,IAAK,CAAS,CAAC,IAAI,EAAE,OAAO,KAAK,KAAK,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,EAAE,CAAC,CAAC;QACxD,CAAC;aAAM,CAAC;YACJ,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC;YACtC,IAAI,SAAS,EAAE,CAAC;gBACZ,0FAA0F;gBAC1F,MAAM,cAAc,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC;gBACjD,MAAM,WAAW,GAAG,sBAAsB,CAAC,cAAc,EAAE,iCAAiC,EAAE,CAAC,CAAC;gBAChG,aAAa,CAAC,UAAU,CAAC,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;gBAC/F,OAAO;YACX,CAAC;iBAAM,CAAC;gBACJ,IAAI,OAAO,EAAE,CAAC;oBACV,sDAAsD;oBACtD,MAAM,YAAY,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;oBAC7C,MAAM,WAAW,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAC;oBACvD,aAAa,CAAC,UAAU,CAAC,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;oBACnF,OAAO;gBACX,CAAC;YACL,CAAC;YAED,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,EAAE,CAAC,CAAC;QAClE,CAAC;IACL,CAAC,CAAC;IAEF,yBAAyB;IACzB,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,sBAAsB,CAAC,MAAM,EAAE,EAAE,mBAAmB,EAAE,UAAU,CAAC,mBAAmB,EAAE,CAAC,CAAC;IACrH,MAAM,aAAa,GAAG,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC;IAClD,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;IAC7C,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;AACjJ,CAAC","sourcesContent":["/**\n * IMPORTANT!\n * This file is still under construction and will change in the future.\n * Workers are not yet supported.\n * For more info visit: https://forum.babylonjs.com/t/replacing-recastjs-with-recast-navigation-js/56003/46\n */\nimport type
|
|
1
|
+
{"version":3,"file":"generator.worker.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/generator/generator.worker.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,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AC;QAClE,CAAC;IACL,CAAC,CAAC;IAEF,yBAAyB;IACzB,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,sBAAsB,CAAC,MAAM,EAAE,EAAE,mBAAmB,EAAE,UAAU,CAAC,mBAAmB,EAAE,CAAC,CAAC;IACrH,MAAM,aAAa,GAAG,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC;IAClD,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;IAC7C,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;AACjJ,CAAC","sourcesContent":["/**\n * IMPORTANT!\n * This file is still under construction and will change in the future.\n * Workers are not yet supported.\n * For more info visit: https://forum.babylonjs.com/t/replacing-recastjs-with-recast-navigation-js/56003/46\n */\nimport { type NavMeshQuery, type NavMesh, type TileCache } from \"@recast-navigation/core\";\n\nimport { type Mesh } from \"core/Meshes/mesh\";\n\nimport { type INavMeshParametersV2 } from \"../types\";\nimport { GetPositionsAndIndices } from \"../common/getters\";\nimport { BuildFromNavmeshData, BuildFromTileCacheData } from \"./generator.common\";\nimport { CreateDefaultTileCacheMeshProcess } from \"../common/tile-cache\";\n\n/**\n * Builds a NavMesh and NavMeshQuery from meshes using provided parameters.\n * @param meshes The array of meshes used to create the NavMesh.\n * @param parameters The parameters used to configure the NavMesh generation.\n * @param workerOptions Options for the worker, including a completion callback and the worker instance.\n * @throws Error if the NavMesh data is invalid or cannot be deserialized.\n */\nexport function GenerateNavMeshWithWorker(\n meshes: Array<Mesh>,\n parameters: INavMeshParametersV2,\n workerOptions: {\n /**\n * Completion callback that is called when the NavMesh generation is complete.\n * @param navMesh The generated NavMesh.\n * @param navMeshQuery The NavMeshQuery associated with the generated NavMesh.\n * @param tileCache Optional TileCache if tile cache generation was used.\n */\n completion: (navMesh: NavMesh, navMeshQuery: NavMeshQuery, tileCache?: TileCache) => void;\n /**\n * Worker instance used for asynchronous NavMesh generation.\n */\n worker: Worker;\n }\n) {\n if (meshes.length === 0) {\n throw new Error(\"At least one mesh is needed to create the nav mesh.\");\n }\n\n // callback function to process the message from the worker\n workerOptions.worker.onmessage = (e) => {\n if ((e as any).data?.success === false) {\n throw new Error(`Unable to generate navMesh: ${e}`);\n } else {\n const { navMesh, tileCache } = e.data;\n if (tileCache) {\n // if tileCache is present, the binary data contains the navmesh and the tilecache as well\n const tileCacheArray = new Uint8Array(tileCache);\n const navMeshData = BuildFromTileCacheData(tileCacheArray, CreateDefaultTileCacheMeshProcess());\n workerOptions.completion(navMeshData.navMesh, navMeshData.navMeshQuery, navMeshData.tileCache);\n return;\n } else {\n if (navMesh) {\n // deserialize the navmesh only (no tilecache present)\n const navMeshArray = new Uint8Array(navMesh);\n const navMeshData = BuildFromNavmeshData(navMeshArray);\n workerOptions.completion(navMeshData.navMesh, navMeshData.navMeshQuery, undefined);\n return;\n }\n }\n\n throw new Error(`Unable to generate navMesh/tileCache: ${e}`);\n }\n };\n\n // send message to worker\n const [positions, indices] = GetPositionsAndIndices(meshes, { doNotReverseIndices: parameters.doNotReverseIndices });\n const positionsCopy = new Float32Array(positions);\n const indicesCopy = new Uint32Array(indices);\n workerOptions.worker.postMessage({ positions: positionsCopy, indices: indicesCopy, parameters }, [positionsCopy.buffer, indicesCopy.buffer]);\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type RecastNavigationJSPluginV2 } from "../plugin/RecastNavigationJSPlugin.js";
|
|
2
2
|
/**
|
|
3
3
|
* Injects the navigation mesh generation methods into the navigation plugin.
|
|
4
4
|
* @param navigationPlugin The navigation plugin to inject the methods into.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injection.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/generator/injection.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,gBAA4C;IACzE,gBAAgB,CAAC,iBAAiB,GAAG,CAAC,MAAc,EAAE,UAAgC,EAAE,EAAE;QACtF,OAAO,eAAe,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC/C,CAAC,CAAC;IAEF,gBAAgB,CAAC,sBAAsB,GAAG,KAAK,EAAE,MAAc,EAAE,UAAgC,EAAE,EAAE;QACjG,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACjC,OAAO,CAAC,eAAe,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC","sourcesContent":["import type
|
|
1
|
+
{"version":3,"file":"injection.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/generator/injection.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,gBAA4C;IACzE,gBAAgB,CAAC,iBAAiB,GAAG,CAAC,MAAc,EAAE,UAAgC,EAAE,EAAE;QACtF,OAAO,eAAe,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC/C,CAAC,CAAC;IAEF,gBAAgB,CAAC,sBAAsB,GAAG,KAAK,EAAE,MAAc,EAAE,UAAgC,EAAE,EAAE;QACjG,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACjC,OAAO,CAAC,eAAe,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC","sourcesContent":["import { type Mesh } from \"core/Meshes/mesh\";\n\nimport { type RecastNavigationJSPluginV2 } from \"../plugin/RecastNavigationJSPlugin\";\nimport { type INavMeshParametersV2 } from \"../types\";\nimport { GenerateNavMesh } from \"./generator.single-thread\";\n\n/**\n * Injects the navigation mesh generation methods into the navigation plugin.\n * @param navigationPlugin The navigation plugin to inject the methods into.\n */\nexport function InjectGenerators(navigationPlugin: RecastNavigationJSPluginV2) {\n navigationPlugin.createNavMeshImpl = (meshes: Mesh[], parameters: INavMeshParametersV2) => {\n return GenerateNavMesh(meshes, parameters);\n };\n\n navigationPlugin.createNavMeshAsyncImpl = async (meshes: Mesh[], parameters: INavMeshParametersV2) => {\n return await new Promise((resolve) => {\n resolve(GenerateNavMesh(meshes, parameters));\n });\n };\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
4
|
-
import type
|
|
1
|
+
import { type Crowd } from "@recast-navigation/core";
|
|
2
|
+
import { type IVector3Like } from "@babylonjs/core/Maths/math.like.js";
|
|
3
|
+
import { type TransformNode } from "@babylonjs/core/Meshes/transformNode.js";
|
|
4
|
+
import { type ICrowd } from "@babylonjs/core/Navigation/INavigationEngine.js";
|
|
5
5
|
import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
|
6
6
|
import { Observable } from "@babylonjs/core/Misc/observable.js";
|
|
7
|
-
import type
|
|
8
|
-
import type
|
|
9
|
-
import type
|
|
7
|
+
import { type Scene } from "@babylonjs/core/scene.js";
|
|
8
|
+
import { type RecastNavigationJSPluginV2 } from "./RecastNavigationJSPlugin.js";
|
|
9
|
+
import { type IAgentParametersV2 } from "../types.js";
|
|
10
10
|
/**
|
|
11
11
|
* Recast Detour crowd implementation
|
|
12
12
|
* This class provides methods to manage a crowd of agents, allowing them to navigate a navigation mesh.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecastJSCrowd.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/plugin/RecastJSCrowd.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,6CAA+B;AAC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e;QACtC,MAAM,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC;QACzD,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACI,UAAU,CAAC,KAAa;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;QAC7D,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,EAAE,CAAC;QACd,CAAC;QAED,MAAM,SAAS,GAAG,EAAE,CAAC;QACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,SAAS,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAE5B,IAAI,IAAI,CAAC,2BAA2B,EAAE,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,4BAA4B,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;YAClF,IAAI,CAAC,2BAA2B,GAAG,IAAI,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,CAAC;IACzC,CAAC;CACJ","sourcesContent":["import type { Crowd } from \"@recast-navigation/core\";\n\nimport type { Nullable } from \"core/types\";\nimport type { IVector3Like } from \"core/Maths/math.like\";\nimport type { TransformNode } from \"core/Meshes/transformNode\";\nimport type { ICrowd } from \"core/Navigation/INavigationEngine\";\nimport { Vector3 } from \"core/Maths/math.vector\";\nimport { Epsilon } from \"core/Maths/math.constants\";\nimport type { Observer } from \"core/Misc/observable\";\nimport { Observable } from \"core/Misc/observable\";\nimport type { Scene } from \"core/scene\";\n\nimport type { RecastNavigationJSPluginV2 } from \"./RecastNavigationJSPlugin\";\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\nimport { ToCrowdAgentParams } from \"../common/config\";\nimport type { IAgentParametersV2 } from \"../types\";\nimport { GetRecast } from \"../factory/common\";\n\n/**\n * Recast Detour crowd implementation\n * This class provides methods to manage a crowd of agents, allowing them to navigate a navigation mesh.\n * It supports adding agents, updating their parameters, moving them to destinations, and checking their states.\n * The crowd is updated in the scene's animation loop, and it notifies observers when agents reach their destinations.\n */\nexport class RecastJSCrowd implements ICrowd {\n /**\n * Recast plugin\n */\n public get navigationPlugin(): RecastNavigationJSPluginV2 {\n return this._navigationPlugin;\n }\n\n /**\n * Link to the detour crowd\n */\n public get recastCrowd(): Crowd {\n return this._recastCrowd;\n }\n\n /**\n * One transform per agent\n */\n public get transforms(): TransformNode[] {\n return this._transforms;\n }\n\n /**\n * All agents created\n */\n public get agents(): readonly number[] {\n return Object.freeze(this._agents);\n }\n\n /**\n * Agents reach radius\n */\n public get reachRadii(): readonly number[] {\n return Object.freeze(this._reachRadii);\n }\n\n private _navigationPlugin: RecastNavigationJSPluginV2;\n private _recastCrowd: Crowd;\n private _transforms: TransformNode[] = [];\n private _agents: number[] = [];\n private _reachRadii: number[] = [];\n\n /**\n * true when a destination is active for an agent and notifier hasn't been notified of reach\n */\n private _agentDestinationArmed: boolean[] = new Array<boolean>();\n /**\n * agent current target\n */\n private _agentDestination: Vector3[] = new Array<Vector3>();\n /**\n * Link to the scene is kept to unregister the crowd from the scene\n */\n private _scene: Scene;\n\n private _engine: AbstractEngine;\n\n /**\n * Observer for crowd updates\n */\n private _onBeforeAnimationsObserver: Nullable<Observer<Scene>> = null;\n\n /**\n * Fires each time an agent is in reach radius of its destination\n */\n public onReachTargetObservable = new Observable<{\n /**\n * The index of the agent that reached its target\n */\n agentIndex: number;\n /**\n * The destination that the agent reached\n */\n destination: Vector3;\n }>();\n\n /**\n * Constructor\n * @param plugin recastJS plugin\n * @param maxAgents the maximum agent count in the crowd\n * @param maxAgentRadius the maximum radius an agent can have\n * @param scene to attach the crowd to\n * @returns the crowd you can add agents to\n */\n public constructor(plugin: RecastNavigationJSPluginV2, maxAgents: number, maxAgentRadius: number, scene: Scene) {\n this._navigationPlugin = plugin;\n\n if (!plugin.navMesh) {\n throw new Error(\"There is no NavMesh generated.\");\n }\n\n this._recastCrowd = new (GetRecast().Crowd)(plugin.navMesh, {\n maxAgents,\n maxAgentRadius,\n });\n\n this._scene = scene;\n this._engine = scene.getEngine();\n\n this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\n this.update(this._engine.getDeltaTime() * 0.001 * plugin.timeFactor);\n });\n }\n\n /**\n * Add a new agent to the crowd with the specified parameter a corresponding transformNode.\n * You can attach anything to that node. The node position is updated in the scene update tick.\n * @param pos world position that will be constrained by the navigation mesh\n * @param parameters agent parameters\n * @param transform hooked to the agent that will be update by the scene\n * @returns agent index\n */\n public addAgent(pos: IVector3Like, parameters: IAgentParametersV2, transform: TransformNode): number {\n const agentParams = ToCrowdAgentParams(parameters);\n\n const agent = this._recastCrowd.addAgent({ x: pos.x, y: pos.y, z: pos.z }, agentParams);\n\n this._transforms.push(transform);\n this._agents.push(agent.agentIndex);\n this._reachRadii.push(parameters.reachRadius ? parameters.reachRadius : parameters.radius);\n this._agentDestinationArmed.push(false);\n this._agentDestination.push(new Vector3(0, 0, 0));\n\n return agent.agentIndex;\n }\n\n /**\n * Returns the agent position in world space\n * @param index agent index returned by addAgent\n * @returns world space position\n */\n public getAgentPosition(index: number): Vector3 {\n const agentPos = this._recastCrowd.getAgent(index)?.position() ?? Vector3.ZeroReadOnly;\n return new Vector3(agentPos.x, agentPos.y, agentPos.z);\n }\n\n /**\n * Returns the agent position result in world space\n * @param index agent index returned by addAgent\n * @param result output world space position\n */\n public getAgentPositionToRef(index: number, result: Vector3): void {\n const agentPos = this._recastCrowd.getAgent(index)?.position() ?? Vector3.ZeroReadOnly;\n result.set(agentPos.x, agentPos.y, agentPos.z);\n }\n\n /**\n * Returns the agent velocity in world space\n * @param index agent index returned by addAgent\n * @returns world space velocity\n */\n public getAgentVelocity(index: number): Vector3 {\n const agentVel = this._recastCrowd.getAgent(index)?.velocity() ?? Vector3.ZeroReadOnly;\n return new Vector3(agentVel.x, agentVel.y, agentVel.z);\n }\n\n /**\n * Returns the agent velocity result in world space\n * @param index agent index returned by addAgent\n * @param result output world space velocity\n */\n public getAgentVelocityToRef(index: number, result: Vector3): void {\n const agentVel = this._recastCrowd.getAgent(index)?.velocity() ?? Vector3.ZeroReadOnly;\n result.set(agentVel.x, agentVel.y, agentVel.z);\n }\n\n /**\n * Returns the agent next target point on the path\n * @param index agent index returned by addAgent\n * @returns world space position\n */\n public getAgentNextTargetPath(index: number): Vector3 {\n const pathTargetPos = this._recastCrowd.getAgent(index)?.nextTargetInPath() ?? Vector3.ZeroReadOnly;\n return new Vector3(pathTargetPos.x, pathTargetPos.y, pathTargetPos.z);\n }\n\n /**\n * Returns the agent next target point on the path\n * @param index agent index returned by addAgent\n * @param result output world space position\n */\n public getAgentNextTargetPathToRef(index: number, result: Vector3): void {\n const pathTargetPos = this._recastCrowd.getAgent(index)?.nextTargetInPath() ?? Vector3.ZeroReadOnly;\n result.set(pathTargetPos.x, pathTargetPos.y, pathTargetPos.z);\n }\n\n /**\n * Gets the agent state\n * @param index agent index returned by addAgent\n * @returns agent state, 0 = DT_CROWDAGENT_STATE_INVALID, 1 = DT_CROWDAGENT_STATE_WALKING, 2 = DT_CROWDAGENT_STATE_OFFMESH\n */\n public getAgentState(index: number): number {\n return this._recastCrowd.getAgent(index)?.state() ?? 0; // invalid\n }\n\n /**\n * returns true if the agent in over an off mesh link connection\n * @param index agent index returned by addAgent\n * @returns true if over an off mesh link connection\n */\n public overOffmeshConnection(index: number): boolean {\n return this._recastCrowd.getAgent(index)?.overOffMeshConnection() ?? false;\n }\n\n /**\n * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh\n * @param index agent index returned by addAgent\n * @param destination targeted world position\n */\n public agentGoto(index: number, destination: IVector3Like): void {\n this._recastCrowd.getAgent(index)?.requestMoveTarget(destination);\n\n // arm observer\n const item = this._agents.indexOf(index);\n if (item > -1) {\n this._agentDestinationArmed[item] = true;\n this._agentDestination[item].set(destination.x, destination.y, destination.z);\n }\n }\n\n /**\n * Teleport the agent to a new position\n * @param index agent index returned by addAgent\n * @param destination targeted world position\n */\n public agentTeleport(index: number, destination: IVector3Like): void {\n this._recastCrowd.getAgent(index)?.teleport(destination);\n }\n\n /**\n * Update agent parameters\n * @param index agent index returned by addAgent\n * @param parameters agent parameters\n */\n public updateAgentParameters(index: number, parameters: IAgentParametersV2): void {\n const agent = this._recastCrowd.getAgent(index);\n if (!agent) {\n return;\n }\n\n const agentParams = agent.parameters();\n\n if (!agentParams) {\n return;\n }\n\n if (parameters.radius !== undefined) {\n agentParams.radius = parameters.radius;\n }\n if (parameters.height !== undefined) {\n agentParams.height = parameters.height;\n }\n if (parameters.maxAcceleration !== undefined) {\n agentParams.maxAcceleration = parameters.maxAcceleration;\n }\n if (parameters.maxSpeed !== undefined) {\n agentParams.maxSpeed = parameters.maxSpeed;\n }\n if (parameters.collisionQueryRange !== undefined) {\n agentParams.collisionQueryRange = parameters.collisionQueryRange;\n }\n if (parameters.pathOptimizationRange !== undefined) {\n agentParams.pathOptimizationRange = parameters.pathOptimizationRange;\n }\n if (parameters.separationWeight !== undefined) {\n agentParams.separationWeight = parameters.separationWeight;\n }\n\n agent.updateParameters(agentParams);\n }\n\n /**\n * remove a particular agent previously created\n * @param index agent index returned by addAgent\n */\n public removeAgent(index: number): void {\n this._recastCrowd.removeAgent(index);\n\n const item = this._agents.indexOf(index);\n if (item > -1) {\n this._agents.splice(item, 1);\n this._transforms.splice(item, 1);\n this._reachRadii.splice(item, 1);\n this._agentDestinationArmed.splice(item, 1);\n this._agentDestination.splice(item, 1);\n }\n }\n\n /**\n * get the list of all agents attached to this crowd\n * @returns list of agent indices\n */\n public getAgents(): number[] {\n return this._agents;\n }\n\n /**\n * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function\n * @param deltaTime in seconds\n */\n public update(deltaTime: number): void {\n if (deltaTime <= Epsilon) {\n return;\n }\n\n // update crowd\n const timeStep = this._navigationPlugin.getTimeStep();\n const maxStepCount = this._navigationPlugin.getMaximumSubStepCount();\n if (timeStep <= Epsilon) {\n this._recastCrowd.update(deltaTime);\n } else {\n let iterationCount = Math.floor(deltaTime / timeStep);\n if (maxStepCount && iterationCount > maxStepCount) {\n iterationCount = maxStepCount;\n }\n if (iterationCount < 1) {\n iterationCount = 1;\n }\n\n const step = deltaTime / iterationCount;\n for (let i = 0; i < iterationCount; i++) {\n this._recastCrowd.update(step);\n }\n }\n\n // update transforms\n for (let index = 0; index < this._agents.length; index++) {\n // update transform position\n const agentIndex = this._agents[index];\n const agentPosition = this.getAgentPosition(agentIndex);\n this._transforms[index].position = agentPosition;\n // check agent reach destination\n if (this._agentDestinationArmed[index]) {\n const dx = agentPosition.x - this._agentDestination[index].x;\n const dz = agentPosition.z - this._agentDestination[index].z;\n const radius = this._reachRadii[index];\n const groundY = this._agentDestination[index].y - this._reachRadii[index];\n const ceilingY = this._agentDestination[index].y + this._reachRadii[index];\n const distanceXZSquared = dx * dx + dz * dz;\n if (agentPosition.y > groundY && agentPosition.y < ceilingY && distanceXZSquared < radius * radius) {\n this._agentDestinationArmed[index] = false;\n this.onReachTargetObservable.notifyObservers({\n agentIndex: agentIndex,\n destination: this._agentDestination[index],\n });\n }\n }\n }\n }\n\n /**\n * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)\n * The queries will try to find a solution within those bounds\n * default is (1,1,1)\n * @param extent x,y,z value that define the extent around the queries point of reference\n */\n setDefaultQueryExtent(extent: IVector3Like): void {\n this._navigationPlugin.setDefaultQueryExtent(extent);\n }\n\n /**\n * Get the Bounding box extent specified by setDefaultQueryExtent\n * @returns the box extent values\n */\n getDefaultQueryExtent(): Vector3 {\n const p = this._navigationPlugin.getDefaultQueryExtent();\n return new Vector3(p.x, p.y, p.z);\n }\n\n /**\n * Get the Bounding box extent result specified by setDefaultQueryExtent\n * @param result output the box extent values\n */\n getDefaultQueryExtentToRef(result: Vector3): void {\n const p = this._navigationPlugin.getDefaultQueryExtent();\n result.set(p.x, p.y, p.z);\n }\n\n /**\n * Get the next corner points composing the path (max 4 points)\n * @param index agent index returned by addAgent\n * @returns array containing world position composing the path\n */\n public getCorners(index: number): Vector3[] {\n const corners = this._recastCrowd.getAgent(index)?.corners();\n if (!corners) {\n return [];\n }\n\n const positions = [];\n for (let i = 0; i < corners.length; i++) {\n positions.push(new Vector3(corners[i].x, corners[i].y, corners[i].z));\n }\n return positions;\n }\n\n /**\n * Release all resources\n */\n public dispose(): void {\n this._recastCrowd.destroy();\n\n if (this._onBeforeAnimationsObserver) {\n this._scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);\n this._onBeforeAnimationsObserver = null;\n }\n\n this.onReachTargetObservable.clear();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RecastJSCrowd.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/plugin/RecastJSCrowd.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAiB,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAKjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IACtB;;OAE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AC3B,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;QAC7D,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,EAAE,CAAC;QACd,CAAC;QAED,MAAM,SAAS,GAAG,EAAE,CAAC;QACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,SAAS,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAE5B,IAAI,IAAI,CAAC,2BAA2B,EAAE,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,4BAA4B,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;YAClF,IAAI,CAAC,2BAA2B,GAAG,IAAI,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,CAAC;IACzC,CAAC;CACJ","sourcesContent":["import { type Crowd } from \"@recast-navigation/core\";\n\nimport { type Nullable } from \"core/types\";\nimport { type IVector3Like } from \"core/Maths/math.like\";\nimport { type TransformNode } from \"core/Meshes/transformNode\";\nimport { type ICrowd } from \"core/Navigation/INavigationEngine\";\nimport { Vector3 } from \"core/Maths/math.vector\";\nimport { Epsilon } from \"core/Maths/math.constants\";\nimport { type Observer, Observable } from \"core/Misc/observable\";\nimport { type Scene } from \"core/scene\";\n\nimport { type RecastNavigationJSPluginV2 } from \"./RecastNavigationJSPlugin\";\nimport { type AbstractEngine } from \"core/Engines/abstractEngine\";\nimport { ToCrowdAgentParams } from \"../common/config\";\nimport { type IAgentParametersV2 } from \"../types\";\nimport { GetRecast } from \"../factory/common\";\n\n/**\n * Recast Detour crowd implementation\n * This class provides methods to manage a crowd of agents, allowing them to navigate a navigation mesh.\n * It supports adding agents, updating their parameters, moving them to destinations, and checking their states.\n * The crowd is updated in the scene's animation loop, and it notifies observers when agents reach their destinations.\n */\nexport class RecastJSCrowd implements ICrowd {\n /**\n * Recast plugin\n */\n public get navigationPlugin(): RecastNavigationJSPluginV2 {\n return this._navigationPlugin;\n }\n\n /**\n * Link to the detour crowd\n */\n public get recastCrowd(): Crowd {\n return this._recastCrowd;\n }\n\n /**\n * One transform per agent\n */\n public get transforms(): TransformNode[] {\n return this._transforms;\n }\n\n /**\n * All agents created\n */\n public get agents(): readonly number[] {\n return Object.freeze(this._agents);\n }\n\n /**\n * Agents reach radius\n */\n public get reachRadii(): readonly number[] {\n return Object.freeze(this._reachRadii);\n }\n\n private _navigationPlugin: RecastNavigationJSPluginV2;\n private _recastCrowd: Crowd;\n private _transforms: TransformNode[] = [];\n private _agents: number[] = [];\n private _reachRadii: number[] = [];\n\n /**\n * true when a destination is active for an agent and notifier hasn't been notified of reach\n */\n private _agentDestinationArmed: boolean[] = new Array<boolean>();\n /**\n * agent current target\n */\n private _agentDestination: Vector3[] = new Array<Vector3>();\n /**\n * Link to the scene is kept to unregister the crowd from the scene\n */\n private _scene: Scene;\n\n private _engine: AbstractEngine;\n\n /**\n * Observer for crowd updates\n */\n private _onBeforeAnimationsObserver: Nullable<Observer<Scene>> = null;\n\n /**\n * Fires each time an agent is in reach radius of its destination\n */\n public onReachTargetObservable = new Observable<{\n /**\n * The index of the agent that reached its target\n */\n agentIndex: number;\n /**\n * The destination that the agent reached\n */\n destination: Vector3;\n }>();\n\n /**\n * Constructor\n * @param plugin recastJS plugin\n * @param maxAgents the maximum agent count in the crowd\n * @param maxAgentRadius the maximum radius an agent can have\n * @param scene to attach the crowd to\n * @returns the crowd you can add agents to\n */\n public constructor(plugin: RecastNavigationJSPluginV2, maxAgents: number, maxAgentRadius: number, scene: Scene) {\n this._navigationPlugin = plugin;\n\n if (!plugin.navMesh) {\n throw new Error(\"There is no NavMesh generated.\");\n }\n\n this._recastCrowd = new (GetRecast().Crowd)(plugin.navMesh, {\n maxAgents,\n maxAgentRadius,\n });\n\n this._scene = scene;\n this._engine = scene.getEngine();\n\n this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\n this.update(this._engine.getDeltaTime() * 0.001 * plugin.timeFactor);\n });\n }\n\n /**\n * Add a new agent to the crowd with the specified parameter a corresponding transformNode.\n * You can attach anything to that node. The node position is updated in the scene update tick.\n * @param pos world position that will be constrained by the navigation mesh\n * @param parameters agent parameters\n * @param transform hooked to the agent that will be update by the scene\n * @returns agent index\n */\n public addAgent(pos: IVector3Like, parameters: IAgentParametersV2, transform: TransformNode): number {\n const agentParams = ToCrowdAgentParams(parameters);\n\n const agent = this._recastCrowd.addAgent({ x: pos.x, y: pos.y, z: pos.z }, agentParams);\n\n this._transforms.push(transform);\n this._agents.push(agent.agentIndex);\n this._reachRadii.push(parameters.reachRadius ? parameters.reachRadius : parameters.radius);\n this._agentDestinationArmed.push(false);\n this._agentDestination.push(new Vector3(0, 0, 0));\n\n return agent.agentIndex;\n }\n\n /**\n * Returns the agent position in world space\n * @param index agent index returned by addAgent\n * @returns world space position\n */\n public getAgentPosition(index: number): Vector3 {\n const agentPos = this._recastCrowd.getAgent(index)?.position() ?? Vector3.ZeroReadOnly;\n return new Vector3(agentPos.x, agentPos.y, agentPos.z);\n }\n\n /**\n * Returns the agent position result in world space\n * @param index agent index returned by addAgent\n * @param result output world space position\n */\n public getAgentPositionToRef(index: number, result: Vector3): void {\n const agentPos = this._recastCrowd.getAgent(index)?.position() ?? Vector3.ZeroReadOnly;\n result.set(agentPos.x, agentPos.y, agentPos.z);\n }\n\n /**\n * Returns the agent velocity in world space\n * @param index agent index returned by addAgent\n * @returns world space velocity\n */\n public getAgentVelocity(index: number): Vector3 {\n const agentVel = this._recastCrowd.getAgent(index)?.velocity() ?? Vector3.ZeroReadOnly;\n return new Vector3(agentVel.x, agentVel.y, agentVel.z);\n }\n\n /**\n * Returns the agent velocity result in world space\n * @param index agent index returned by addAgent\n * @param result output world space velocity\n */\n public getAgentVelocityToRef(index: number, result: Vector3): void {\n const agentVel = this._recastCrowd.getAgent(index)?.velocity() ?? Vector3.ZeroReadOnly;\n result.set(agentVel.x, agentVel.y, agentVel.z);\n }\n\n /**\n * Returns the agent next target point on the path\n * @param index agent index returned by addAgent\n * @returns world space position\n */\n public getAgentNextTargetPath(index: number): Vector3 {\n const pathTargetPos = this._recastCrowd.getAgent(index)?.nextTargetInPath() ?? Vector3.ZeroReadOnly;\n return new Vector3(pathTargetPos.x, pathTargetPos.y, pathTargetPos.z);\n }\n\n /**\n * Returns the agent next target point on the path\n * @param index agent index returned by addAgent\n * @param result output world space position\n */\n public getAgentNextTargetPathToRef(index: number, result: Vector3): void {\n const pathTargetPos = this._recastCrowd.getAgent(index)?.nextTargetInPath() ?? Vector3.ZeroReadOnly;\n result.set(pathTargetPos.x, pathTargetPos.y, pathTargetPos.z);\n }\n\n /**\n * Gets the agent state\n * @param index agent index returned by addAgent\n * @returns agent state, 0 = DT_CROWDAGENT_STATE_INVALID, 1 = DT_CROWDAGENT_STATE_WALKING, 2 = DT_CROWDAGENT_STATE_OFFMESH\n */\n public getAgentState(index: number): number {\n return this._recastCrowd.getAgent(index)?.state() ?? 0; // invalid\n }\n\n /**\n * returns true if the agent in over an off mesh link connection\n * @param index agent index returned by addAgent\n * @returns true if over an off mesh link connection\n */\n public overOffmeshConnection(index: number): boolean {\n return this._recastCrowd.getAgent(index)?.overOffMeshConnection() ?? false;\n }\n\n /**\n * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh\n * @param index agent index returned by addAgent\n * @param destination targeted world position\n */\n public agentGoto(index: number, destination: IVector3Like): void {\n this._recastCrowd.getAgent(index)?.requestMoveTarget(destination);\n\n // arm observer\n const item = this._agents.indexOf(index);\n if (item > -1) {\n this._agentDestinationArmed[item] = true;\n this._agentDestination[item].set(destination.x, destination.y, destination.z);\n }\n }\n\n /**\n * Teleport the agent to a new position\n * @param index agent index returned by addAgent\n * @param destination targeted world position\n */\n public agentTeleport(index: number, destination: IVector3Like): void {\n this._recastCrowd.getAgent(index)?.teleport(destination);\n }\n\n /**\n * Update agent parameters\n * @param index agent index returned by addAgent\n * @param parameters agent parameters\n */\n public updateAgentParameters(index: number, parameters: IAgentParametersV2): void {\n const agent = this._recastCrowd.getAgent(index);\n if (!agent) {\n return;\n }\n\n const agentParams = agent.parameters();\n\n if (!agentParams) {\n return;\n }\n\n if (parameters.radius !== undefined) {\n agentParams.radius = parameters.radius;\n }\n if (parameters.height !== undefined) {\n agentParams.height = parameters.height;\n }\n if (parameters.maxAcceleration !== undefined) {\n agentParams.maxAcceleration = parameters.maxAcceleration;\n }\n if (parameters.maxSpeed !== undefined) {\n agentParams.maxSpeed = parameters.maxSpeed;\n }\n if (parameters.collisionQueryRange !== undefined) {\n agentParams.collisionQueryRange = parameters.collisionQueryRange;\n }\n if (parameters.pathOptimizationRange !== undefined) {\n agentParams.pathOptimizationRange = parameters.pathOptimizationRange;\n }\n if (parameters.separationWeight !== undefined) {\n agentParams.separationWeight = parameters.separationWeight;\n }\n\n agent.updateParameters(agentParams);\n }\n\n /**\n * remove a particular agent previously created\n * @param index agent index returned by addAgent\n */\n public removeAgent(index: number): void {\n this._recastCrowd.removeAgent(index);\n\n const item = this._agents.indexOf(index);\n if (item > -1) {\n this._agents.splice(item, 1);\n this._transforms.splice(item, 1);\n this._reachRadii.splice(item, 1);\n this._agentDestinationArmed.splice(item, 1);\n this._agentDestination.splice(item, 1);\n }\n }\n\n /**\n * get the list of all agents attached to this crowd\n * @returns list of agent indices\n */\n public getAgents(): number[] {\n return this._agents;\n }\n\n /**\n * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function\n * @param deltaTime in seconds\n */\n public update(deltaTime: number): void {\n if (deltaTime <= Epsilon) {\n return;\n }\n\n // update crowd\n const timeStep = this._navigationPlugin.getTimeStep();\n const maxStepCount = this._navigationPlugin.getMaximumSubStepCount();\n if (timeStep <= Epsilon) {\n this._recastCrowd.update(deltaTime);\n } else {\n let iterationCount = Math.floor(deltaTime / timeStep);\n if (maxStepCount && iterationCount > maxStepCount) {\n iterationCount = maxStepCount;\n }\n if (iterationCount < 1) {\n iterationCount = 1;\n }\n\n const step = deltaTime / iterationCount;\n for (let i = 0; i < iterationCount; i++) {\n this._recastCrowd.update(step);\n }\n }\n\n // update transforms\n for (let index = 0; index < this._agents.length; index++) {\n // update transform position\n const agentIndex = this._agents[index];\n const agentPosition = this.getAgentPosition(agentIndex);\n this._transforms[index].position = agentPosition;\n // check agent reach destination\n if (this._agentDestinationArmed[index]) {\n const dx = agentPosition.x - this._agentDestination[index].x;\n const dz = agentPosition.z - this._agentDestination[index].z;\n const radius = this._reachRadii[index];\n const groundY = this._agentDestination[index].y - this._reachRadii[index];\n const ceilingY = this._agentDestination[index].y + this._reachRadii[index];\n const distanceXZSquared = dx * dx + dz * dz;\n if (agentPosition.y > groundY && agentPosition.y < ceilingY && distanceXZSquared < radius * radius) {\n this._agentDestinationArmed[index] = false;\n this.onReachTargetObservable.notifyObservers({\n agentIndex: agentIndex,\n destination: this._agentDestination[index],\n });\n }\n }\n }\n }\n\n /**\n * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)\n * The queries will try to find a solution within those bounds\n * default is (1,1,1)\n * @param extent x,y,z value that define the extent around the queries point of reference\n */\n setDefaultQueryExtent(extent: IVector3Like): void {\n this._navigationPlugin.setDefaultQueryExtent(extent);\n }\n\n /**\n * Get the Bounding box extent specified by setDefaultQueryExtent\n * @returns the box extent values\n */\n getDefaultQueryExtent(): Vector3 {\n const p = this._navigationPlugin.getDefaultQueryExtent();\n return new Vector3(p.x, p.y, p.z);\n }\n\n /**\n * Get the Bounding box extent result specified by setDefaultQueryExtent\n * @param result output the box extent values\n */\n getDefaultQueryExtentToRef(result: Vector3): void {\n const p = this._navigationPlugin.getDefaultQueryExtent();\n result.set(p.x, p.y, p.z);\n }\n\n /**\n * Get the next corner points composing the path (max 4 points)\n * @param index agent index returned by addAgent\n * @returns array containing world position composing the path\n */\n public getCorners(index: number): Vector3[] {\n const corners = this._recastCrowd.getAgent(index)?.corners();\n if (!corners) {\n return [];\n }\n\n const positions = [];\n for (let i = 0; i < corners.length; i++) {\n positions.push(new Vector3(corners[i].x, corners[i].y, corners[i].z));\n }\n return positions;\n }\n\n /**\n * Release all resources\n */\n public dispose(): void {\n this._recastCrowd.destroy();\n\n if (this._onBeforeAnimationsObserver) {\n this._scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);\n this._onBeforeAnimationsObserver = null;\n }\n\n this.onReachTargetObservable.clear();\n }\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
4
|
-
import type
|
|
1
|
+
import { type TileCacheMeshProcess, type NavMesh, type QueryFilter, type TileCache, type NavMeshQuery } from "@recast-navigation/core";
|
|
2
|
+
import { type ICrowd, type INavigationEnginePlugin, type IObstacle } from "@babylonjs/core/Navigation/INavigationEngine.js";
|
|
3
|
+
import { type Mesh } from "@babylonjs/core/Meshes/mesh.js";
|
|
4
|
+
import { type Scene } from "@babylonjs/core/scene.js";
|
|
5
5
|
import { Vector3 } from "@babylonjs/core/Maths/math.js";
|
|
6
|
-
import type
|
|
7
|
-
import type
|
|
8
|
-
import type
|
|
6
|
+
import { type IVector3Like } from "@babylonjs/core/Maths/math.like.js";
|
|
7
|
+
import { type Nullable } from "@babylonjs/core/types.js";
|
|
8
|
+
import { type CreateNavMeshResult, type GeneratorIntermediates, type INavMeshParametersV2, type RecastInjection } from "../types.js";
|
|
9
9
|
/**
|
|
10
10
|
* Navigation plugin for Babylon.js. It is a simple wrapper around the recast-navigation-js library. Not all features are implemented.
|
|
11
11
|
* @remarks This plugin provides navigation mesh generation and pathfinding capabilities using the recast-navigation-js library
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecastNavigationJSPlugin.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/plugin/RecastNavigationJSPlugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAG1C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,sCAAwB;AAKtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,iCAAiC,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAErG;;;;;;;GAOG;AACH,MAAM,OAAO,0BAA0B;IAiCnC;;;OAGG;IACH,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAaD;;;OAGG;IACH,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAQD;;;OAGG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IASD;;;OAGG;IACH,YAAmB,eAAiC;QA9DpD;;WAEG;QACI,SAAI,GAAW,0BAA0B,CAAC;QAgDjD,4BAA4B;QACpB,yBAAoB,GAAW,EAAE,CAAC;QAClC,cAAS,GAAW,CAAC,GAAG,EAAE,CAAC;QAC3B,gBAAW,GAAW,CAAC,CA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CAAC,gEAAgE,CAAC,CAAC;QACtF,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,YAAY,CAAC;QACzC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,aAAa,CAAC;QAC3C,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC;QAEnC,OAAO;YACH,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,wBAAwB;SACxD,CAAC;IACN,CAAC;IAEO,qBAAqB,CAAC,UAAgC;QAC1D,uGAAuG;QACvG,IAAI,UAAU,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACxC,UAAU,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,wEAAwE;YACzH,UAAU,CAAC,YAAY,GAAG,mBAAmB,CAAC;QAClD,CAAC;QAED,UAAU,CAAC,kBAAkB,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC;IACvF,CAAC;CACJ","sourcesContent":["import type { TileCacheMeshProcess, NavMesh, QueryFilter, TileCache, NavMeshQuery } from \"@recast-navigation/core\";\n\nimport type { ICrowd, INavigationEnginePlugin, IObstacle } from \"core/Navigation/INavigationEngine\";\nimport { Logger } from \"core/Misc/logger\";\nimport type { Mesh } from \"core/Meshes/mesh\";\nimport type { Scene } from \"core/scene\";\nimport { TmpVectors, Vector3 } from \"core/Maths/math\";\nimport type { IVector3Like } from \"core/Maths/math.like\";\nimport type { Nullable } from \"core/types\";\n\nimport type { CreateNavMeshResult, GeneratorIntermediates, INavMeshParametersV2, RecastInjection } from \"../types\";\nimport { RecastJSCrowd } from \"./RecastJSCrowd\";\nimport { ConvertNavPathPoints } from \"../common/convert\";\nimport { ComputeSmoothPath } from \"../common/smooth-path\";\nimport { CreateDebugNavMesh } from \"../debug/simple-debug\";\nimport { GetRecast } from \"../factory/common\";\nimport { InjectGenerators } from \"../generator/injection\";\nimport { DefaultMaxObstacles } from \"../common/config\";\nimport { CreateDefaultTileCacheMeshProcess, WaitForFullTileCacheUpdate } from \"../common/tile-cache\";\n\n/**\n * Navigation plugin for Babylon.js. It is a simple wrapper around the recast-navigation-js library. Not all features are implemented.\n * @remarks This plugin provides navigation mesh generation and pathfinding capabilities using the recast-navigation-js library\n * @remarks It supports both single-threaded and multi-threaded generation of navigation meshes.\n * @remarks The plugin can be used to create navigation meshes from meshes in a scene, compute paths, and manage crowd agents, etc.\n * @remarks It also provides methods for creating obstacles and querying the navigation mesh.\n * @see https://github.com/isaac-mason/recast-navigation-js\n */\nexport class RecastNavigationJSPluginV2 implements INavigationEnginePlugin {\n /**\n * Creates a navigation mesh - will be injected by the factory\n * @param meshes array of all the geometry used to compute the navigation mesh\n * @param parameters bunch of parameters used to filter geometry\n * @returns the created navmesh and navmesh query\n */\n createNavMeshImpl: (meshes: Array<Mesh>, parameters: INavMeshParametersV2) => CreateNavMeshResult;\n\n /**\n * Creates a navigation mesh - will be injected by the factory\n * @param meshes array of all the geometry used to compute the navigation mesh\n * @param parameters bunch of parameters used to filter geometry\n * @returns the created navmesh and navmesh query\n */\n createNavMeshAsyncImpl: (meshes: Array<Mesh>, parameters: INavMeshParametersV2) => Promise<CreateNavMeshResult>;\n\n /**\n * recast-navigation-js injection\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n public bjsRECAST: RecastInjection;\n\n /**\n * plugin name\n */\n public name: string = \"RecastNavigationJSPlugin\";\n\n /**\n * the navmesh created\n */\n public navMesh?: NavMesh;\n\n /**\n * The navmesh query created from the navmesh\n * @remarks This is used to query the navmesh for pathfinding and other navigation tasks\n */\n public get navMeshQuery(): NavMeshQuery {\n return this._navMeshQuery;\n }\n\n private _navMeshQuery!: NavMeshQuery;\n\n /**\n * Intermediates generated during the navmesh creation\n * @remarks This is used for debugging and visualization purposes.\n * @remarks You have access to vertices, indices and vertex colors to visualize the navmesh creation process.\n * @remarks This is only available if the `keepIntermediates` parameter is set\n * @remarks to true during navmesh generation.\n */\n private _intermediates?: GeneratorIntermediates;\n\n /**\n * Gets the intermediates generated during the navmesh creation\n * @returns The generator intermediates, or undefined if not available\n */\n public get intermediates(): GeneratorIntermediates | undefined {\n return this._intermediates;\n }\n\n /**\n * Tile cache used for tiled navigation meshes\n * @remarks This is used to store and manage tiles of the navigation mesh for efficient path and when obstacles are used.\n */\n private _tileCache?: TileCache;\n\n /**\n * Gets the tile cache used for tiled navigation meshes\n * @returns The tile cache instance, or undefined if not available\n */\n public get tileCache(): TileCache | undefined {\n return this._tileCache;\n }\n\n // Crowd specific properties\n private _maximumSubStepCount: number = 10;\n private _timeStep: number = 1 / 60;\n private _timeFactor: number = 1;\n\n private _crowd?: ICrowd;\n\n /**\n * Creates a RecastNavigationJSPluginV2 instance\n * @param recastInjection The recast-navigation-js injection containing core and generators\n */\n public constructor(recastInjection?: RecastInjection) {\n if (!recastInjection) {\n recastInjection = GetRecast();\n InjectGenerators(this);\n }\n\n this.bjsRECAST = recastInjection;\n\n if (!this.isSupported()) {\n Logger.Error(\"RecastJS is not available. Please make sure you included the js file.\");\n return;\n }\n this.setTimeStep();\n }\n\n /**\n * Set the time step of the navigation tick update.\n * Default is 1/60.\n * A value of 0 will disable fixed time update\n * @param newTimeStep the new timestep to apply to this world.\n */\n public setTimeStep(newTimeStep: number = 1 / 60): void {\n this._timeStep = newTimeStep;\n }\n\n /**\n * Get the time step of the navigation tick update.\n * @returns the current time step\n */\n public getTimeStep(): number {\n return this._timeStep;\n }\n\n /**\n * If delta time in navigation tick update is greater than the time step\n * a number of sub iterations are done. If more iterations are need to reach deltatime\n * they will be discarded.\n * A value of 0 will set to no maximum and update will use as many substeps as needed\n * @param newStepCount the maximum number of iterations\n */\n public setMaximumSubStepCount(newStepCount: number = 10): void {\n this._maximumSubStepCount = newStepCount;\n }\n\n /**\n * Get the maximum number of iterations per navigation tick update\n * @returns the maximum number of iterations\n */\n public getMaximumSubStepCount(): number {\n return this._maximumSubStepCount;\n }\n\n /**\n * Time factor applied when updating crowd agents (default 1). A value of 0 will pause crowd updates.\n * @param value the time factor applied at update\n */\n public set timeFactor(value: number) {\n this._timeFactor = Math.max(value, 0);\n }\n\n /**\n * Get the time factor used for crowd agent update\n * @returns the time factor\n */\n public get timeFactor(): number {\n return this._timeFactor;\n }\n\n /**\n * Creates a navigation mesh - will be injected by the factory\n * @param meshes array of all the geometry used to compute the navigation mesh\n * @param parameters bunch of parameters used to filter geometry\n * @returns the created navmesh and navmesh query\n * @throws Error if the function is not injected yet or if the navmesh is not created\n */\n public createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParametersV2): CreateNavMeshResult {\n if (!this.createNavMeshImpl) {\n throw new Error(\"Function not injected yet. Use the factory to create the plugin.\");\n }\n\n this._preprocessParameters(parameters);\n\n const result = this.createNavMeshImpl(meshes, parameters);\n return this._processNavMeshResult(result);\n }\n\n /**\n * Creates a navigation mesh asynchronously - will be injected by the factory\n * @param meshes array of all the geometry used to compute the navigation mesh\n * @param parameters bunch of parameters used to filter geometry\n * @returns the created navmesh and navmesh query\n * @throws Error if the function is not injected yet or if the navmesh is not created\n */\n public async createNavMeshAsync(meshes: Array<Mesh>, parameters: INavMeshParametersV2): Promise<CreateNavMeshResult> {\n if (!this.createNavMeshAsyncImpl) {\n throw new Error(\"Function not injected yet. Use the factory to create the plugin.\");\n }\n\n this._preprocessParameters(parameters);\n\n const result = await this.createNavMeshAsyncImpl(meshes, parameters);\n return this._processNavMeshResult(result);\n }\n\n /**\n * Create a navigation mesh debug mesh\n * @param scene is where the mesh will be added\n * @returns debug display mesh\n */\n public createDebugNavMesh(scene: Scene): Mesh {\n if (!this.navMesh) {\n throw new Error(\"There is no navMesh generated.\");\n }\n\n if (this.navMesh && this._tileCache) {\n WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);\n }\n\n return CreateDebugNavMesh(this.navMesh, scene);\n }\n\n /**\n * Get a navigation mesh constrained position, closest to the parameter position\n * @param position world position\n * @returns the closest point to position constrained by the navigation mesh\n */\n public getClosestPoint(\n position: IVector3Like,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n }\n ): Vector3 {\n const ret = this._navMeshQuery.findClosestPoint(position, options);\n const pr = new Vector3(ret.point.x, ret.point.y, ret.point.z);\n return pr;\n }\n\n /**\n * Get a navigation mesh constrained position, closest to the parameter position\n * @param position world position\n * @param result output the closest point to position constrained by the navigation mesh\n */\n public getClosestPointToRef(\n position: IVector3Like,\n result: Vector3,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n }\n ): void {\n const ret = this._navMeshQuery.findClosestPoint(position, options);\n result.set(ret.point.x, ret.point.y, ret.point.z);\n }\n\n /**\n * Get a navigation mesh constrained position, within a particular radius\n * @param position world position\n * @param maxRadius the maximum distance to the constrained world position\n * @returns the closest point to position constrained by the navigation mesh\n */\n public getRandomPointAround(\n position: IVector3Like,\n maxRadius: number,\n options?: {\n startRef?: number;\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n }\n ): Vector3 {\n const ret = this._navMeshQuery.findRandomPointAroundCircle(position, maxRadius, options);\n const pr = new Vector3(ret.randomPoint.x, ret.randomPoint.y, ret.randomPoint.z);\n return pr;\n }\n\n /**\n * Get a navigation mesh constrained position, within a particular radius\n * @param position world position\n * @param maxRadius the maximum distance to the constrained world position\n * @param result output the closest point to position constrained by the navigation mesh\n */\n public getRandomPointAroundToRef(\n position: IVector3Like,\n maxRadius: number,\n result: Vector3,\n options?: {\n startRef?: number;\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n }\n ): void {\n const ret = this._navMeshQuery.findRandomPointAroundCircle(position, maxRadius, options);\n result.set(ret.randomPoint.x, ret.randomPoint.y, ret.randomPoint.z);\n }\n\n /**\n * Compute the final position from a segment made of destination-position\n * @param position position to start from\n * @param destination position to go to\n * @param startRef the reference id of the start polygon\n * @param options options for the function\n * @returns the resulting point along the navmesh\n */\n public moveAlong(\n position: IVector3Like,\n destination: IVector3Like,\n startRef = 0,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * The maximum number of polygons the output visited array can hold.\n */\n maxVisitedSize?: number;\n }\n ): Vector3 {\n const ret = this._navMeshQuery.moveAlongSurface(startRef, position, destination, options);\n const pr = new Vector3(ret.resultPosition.x, ret.resultPosition.y, ret.resultPosition.z);\n return pr;\n }\n\n /**\n * Compute the final position from a segment made of destination-position\n * @param position world position\n * @param destination world position\n * @param result output the resulting point along the navmesh\n * @param startRef the reference id of the start polygon.\n * @param options options for the function\n */\n public moveAlongToRef(\n position: IVector3Like,\n destination: IVector3Like,\n result: Vector3,\n startRef = 0,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n maxVisitedSize?: number;\n }\n ): void {\n const ret = this._navMeshQuery.moveAlongSurface(startRef, position, destination, options);\n result.set(ret.resultPosition.x, ret.resultPosition.y, ret.resultPosition.z);\n }\n\n /**\n * Compute a navigation path from start to end. Returns an empty array if no path can be computed\n * Path is straight.\n * @param start world position\n * @param end world position\n * @param options options for the function\n * @returns array containing world position composing the path\n */\n public computePath(\n start: IVector3Like,\n end: IVector3Like,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n maxPathPolys?: number;\n maxStraightPathPoints?: number;\n }\n ): Vector3[] {\n return ConvertNavPathPoints(this._navMeshQuery.computePath(start, end, options));\n }\n\n /**\n * Compute a navigation path from start to end. Returns an empty array if no path can be computed.\n * Path follows navigation mesh geometry.\n * @param start world position\n * @param end world position\n * @param options options to configure the path computation\n * @returns array containing world position composing the path\n */\n public computePathSmooth(\n start: Vector3,\n end: Vector3,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n maxPathPolys?: number;\n maxSmoothPathPoints?: number;\n stepSize?: number;\n slop?: number;\n }\n ): Vector3[] {\n if (!this.navMesh) {\n Logger.Error(\"No navmesh available. Cannot compute smooth path.\");\n return [];\n }\n return ComputeSmoothPath(this.navMesh, this._navMeshQuery, start, end, options);\n }\n\n /**\n * Create a new Crowd so you can add agents\n * @param maxAgents the maximum agent count in the crowd\n * @param maxAgentRadius the maximum radius an agent can have\n * @param scene to attach the crowd to\n * @returns the crowd you can add agents to\n */\n public createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd {\n const crowd = new RecastJSCrowd(this, maxAgents, maxAgentRadius, scene);\n this._crowd = crowd;\n return crowd;\n }\n\n /**\n * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)\n * The queries will try to find a solution within those bounds\n * default is (1,1,1)\n * @param extent x,y,z value that define the extent around the queries point of reference\n */\n public setDefaultQueryExtent(extent: IVector3Like): void {\n this._navMeshQuery.defaultQueryHalfExtents = extent;\n }\n\n /**\n * Get the Bounding box extent specified by setDefaultQueryExtent\n * @returns the box extent values\n */\n public getDefaultQueryExtent(): Vector3 {\n return new Vector3(this._navMeshQuery.defaultQueryHalfExtents.x, this._navMeshQuery.defaultQueryHalfExtents.y, this._navMeshQuery.defaultQueryHalfExtents.z);\n }\n\n /**\n * Get the Bounding box extent result specified by setDefaultQueryExtent\n * @param result output the box extent values\n */\n public getDefaultQueryExtentToRef(result: Vector3): void {\n result.set(this._navMeshQuery.defaultQueryHalfExtents.x, this._navMeshQuery.defaultQueryHalfExtents.y, this._navMeshQuery.defaultQueryHalfExtents.z);\n }\n\n /**\n * build the navmesh from a previously saved state using getNavmeshData\n * @param data the Uint8Array returned by getNavmeshData\n */\n public buildFromNavmeshData(data: Uint8Array): void {\n const result = this.bjsRECAST.importNavMesh(data);\n this.navMesh = result.navMesh;\n this._navMeshQuery = new this.bjsRECAST.NavMeshQuery(this.navMesh);\n }\n\n /**\n * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data\n * @returns data the Uint8Array that can be saved and reused\n */\n public getNavmeshData(): Uint8Array {\n if (!this.navMesh) {\n throw new Error(\"There is no NavMesh generated.\");\n }\n return this.bjsRECAST.exportNavMesh(this.navMesh);\n }\n\n /**\n * build the tile cache from a previously saved state using getTileCacheData\n * @param tileCacheData the data returned by getTileCacheData\n * @param tileCacheMeshProcess optional process to apply to each tile created\n */\n public buildFromTileCacheData(tileCacheData: Uint8Array, tileCacheMeshProcess?: TileCacheMeshProcess): void {\n const result = this.bjsRECAST.importTileCache(tileCacheData, tileCacheMeshProcess ?? CreateDefaultTileCacheMeshProcess([]));\n this.navMesh = result.navMesh;\n this._tileCache = result.tileCache;\n this._navMeshQuery = new this.bjsRECAST.NavMeshQuery(this.navMesh);\n }\n\n /**\n * returns the tile cache data that can be used later. The tile cache must be built before retrieving the data\n * @returns the tile cache data that can be used later. The tile cache must be built before retrieving the data\n * @throws Error if there is no TileCache generated\n * @remarks The returned data can be used to rebuild the tile cache later using buildFromTileCacheData\n */\n public getTileCacheData(): Uint8Array {\n if (!this.navMesh || !this._tileCache) {\n throw new Error(\"There is no TileCache generated.\");\n }\n return this.bjsRECAST.exportTileCache(this.navMesh, this._tileCache);\n }\n\n /**\n * Disposes\n */\n public dispose() {\n this._crowd?.dispose();\n this.navMesh?.destroy();\n this._navMeshQuery?.destroy();\n this._tileCache?.destroy();\n }\n\n /**\n * Creates a cylinder obstacle and add it to the navigation\n * @param position world position\n * @param radius cylinder radius\n * @param height cylinder height\n * @param doNotWaitForCacheUpdate if true the function will not wait for the tile cache to be fully updated before returning\n * @returns the obstacle freshly created\n */\n public addCylinderObstacle(position: IVector3Like, radius: number, height: number, doNotWaitForCacheUpdate = false): Nullable<IObstacle> {\n const obstacleResult = this._tileCache?.addCylinderObstacle(position, radius, height);\n if (!obstacleResult?.success) {\n return null;\n }\n\n if (!doNotWaitForCacheUpdate && this.navMesh && this._tileCache) {\n WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);\n }\n\n return (obstacleResult.obstacle as IObstacle) ?? null;\n }\n\n /**\n * Creates an oriented box obstacle and add it to the navigation\n * @param position world position\n * @param extent box size\n * @param angle angle in radians of the box orientation on Y axis\n * @param doNotWaitForCacheUpdate if true the function will not wait for the tile cache to be fully updated before returning\n * @returns the obstacle freshly created\n */\n public addBoxObstacle(position: IVector3Like, extent: IVector3Like, angle: number, doNotWaitForCacheUpdate = false): Nullable<IObstacle> {\n const obstacleResult = this._tileCache?.addBoxObstacle(position, extent, angle);\n if (!obstacleResult?.success) {\n return null;\n }\n\n if (!doNotWaitForCacheUpdate && this.navMesh && this._tileCache) {\n WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);\n }\n\n return (obstacleResult.obstacle as IObstacle) ?? null;\n }\n\n /**\n * Removes an obstacle created by addCylinderObstacle or addBoxObstacle\n * @param obstacle obstacle to remove from the navigation\n * @param doNotWaitForCacheUpdate if true the function will not wait for the tile cache to be fully updated before returning\n *\n */\n public removeObstacle(obstacle: IObstacle, doNotWaitForCacheUpdate = false): void {\n this._tileCache?.removeObstacle(obstacle);\n\n if (!doNotWaitForCacheUpdate && this.navMesh && this._tileCache) {\n WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);\n }\n }\n\n /**\n * If this plugin is supported\n * @returns true if plugin is supported\n */\n public isSupported(): boolean {\n return !!this.bjsRECAST;\n }\n\n /**\n * Returns the seed used for randomized functions like `getRandomPointAround`\n * @returns seed number\n */\n public getRandomSeed(): number {\n return this.bjsRECAST.getRandomSeed();\n }\n\n /**\n * Set the seed used for randomized functions like `getRandomPointAround`\n * @param seed number used as seed for random functions\n */\n public setRandomSeed(seed: number): void {\n this.bjsRECAST.setRandomSeed(seed);\n }\n\n // New functions beyond the INavigationEnginePlugin interface\n\n /**\n * Perform a raycast on the navmesh\n * @param start start position\n * @param end end position\n * @returns if a direct path exists between start and end, and the hit point if any\n */\n public raycast(start: IVector3Like, end: IVector3Like) {\n const nearestStartPoly = this._navMeshQuery.findNearestPoly(start);\n const raycastResult = this._navMeshQuery.raycast(nearestStartPoly.nearestRef, start, end);\n\n const hit = 0 < raycastResult.t && raycastResult.t < 1.0;\n if (!hit) {\n return {\n hit: false,\n };\n } else {\n TmpVectors.Vector3[0].set(start.x, start.y, start.z);\n TmpVectors.Vector3[1].set(end.x, end.y, end.z);\n\n const distanceToHitBorder = Vector3.Distance(TmpVectors.Vector3[0], TmpVectors.Vector3[1]) * (raycastResult?.t ?? 0);\n const direction = TmpVectors.Vector3[1].subtract(TmpVectors.Vector3[0]).normalize();\n const hitPoint = TmpVectors.Vector3[0].add(direction.multiplyByFloats(distanceToHitBorder, distanceToHitBorder, distanceToHitBorder));\n\n return {\n hit: true,\n hitPoint,\n };\n }\n }\n\n /**\n * Compute the final position from a segment made of destination-position, and return the height of the polygon\n * This is a more sophisticated version of moveAlong that will use the height of the polygon at the end position\n * @param position world position to start from\n * @param velocity velocity of the movement\n * @param options options for the function\n * @returns the resulting point along the navmesh, the polygon reference id and the height of the polygon\n */\n public moveAlongWithVelocity(\n position: IVector3Like,\n velocity: IVector3Like,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n /**\n * The maximum number of polygons the output visited array can hold.\n */\n maxVisitedSize?: number;\n }\n ) {\n const { point, polyRef } = this._navMeshQuery.findClosestPoint(\n {\n x: position.x,\n y: position.y,\n z: position.z,\n },\n options\n );\n\n const { resultPosition } = this._navMeshQuery.moveAlongSurface(\n polyRef,\n point,\n {\n x: point.x + velocity.x,\n y: point.y + velocity.y,\n z: point.z + velocity.z,\n },\n options\n );\n const polyHeightResult = this._navMeshQuery.getPolyHeight(polyRef, resultPosition);\n\n return {\n position: { x: resultPosition.x, y: polyHeightResult.success ? polyHeightResult.height : resultPosition.y, z: resultPosition.z },\n polyRef: polyRef,\n height: polyHeightResult.height,\n };\n }\n\n /**\n * Handles common post-processing and validation of navmesh creation results\n * @param result The partial result from navmesh creation\n * @returns The validated and complete CreateNavMeshresult\n */\n private _processNavMeshResult(result: Nullable<Partial<CreateNavMeshResult>>): CreateNavMeshResult {\n if (!result?.navMesh || !result?.navMeshQuery) {\n throw new Error(\"Unable to create navmesh. No navMesh or navMeshQuery returned.\");\n }\n\n this.navMesh = result.navMesh;\n this._navMeshQuery = result.navMeshQuery;\n this._intermediates = result.intermediates;\n this._tileCache = result.tileCache;\n\n return {\n navMesh: result.navMesh,\n navMeshQuery: result.navMeshQuery,\n intermediates: result.intermediates,\n tileCache: result.tileCache, // tileCache is optional\n };\n }\n\n private _preprocessParameters(parameters: INavMeshParametersV2) {\n // if maxObstacles is not defined, set it to a default value and set a default tile size if not defined\n if (parameters.maxObstacles === undefined) {\n parameters.tileSize = parameters.tileSize ?? 32; // maxObstacles will trigger tile cache creation, so we need a tile size\n parameters.maxObstacles = DefaultMaxObstacles;\n }\n\n parameters.walkableSlopeAngle = Math.max(0.1, parameters.walkableSlopeAngle ?? 60);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RecastNavigationJSPlugin.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/plugin/RecastNavigationJSPlugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAKtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC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,EAAE,wBAAwB;SACxD,CAAC;IACN,CAAC;IAEO,qBAAqB,CAAC,UAAgC;QAC1D,uGAAuG;QACvG,IAAI,UAAU,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACxC,UAAU,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,wEAAwE;YACzH,UAAU,CAAC,YAAY,GAAG,mBAAmB,CAAC;QAClD,CAAC;QAED,UAAU,CAAC,kBAAkB,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC;IACvF,CAAC;CACJ","sourcesContent":["import { type TileCacheMeshProcess, type NavMesh, type QueryFilter, type TileCache, type NavMeshQuery } from \"@recast-navigation/core\";\n\nimport { type ICrowd, type INavigationEnginePlugin, type IObstacle } from \"core/Navigation/INavigationEngine\";\nimport { Logger } from \"core/Misc/logger\";\nimport { type Mesh } from \"core/Meshes/mesh\";\nimport { type Scene } from \"core/scene\";\nimport { TmpVectors, Vector3 } from \"core/Maths/math\";\nimport { type IVector3Like } from \"core/Maths/math.like\";\nimport { type Nullable } from \"core/types\";\n\nimport { type CreateNavMeshResult, type GeneratorIntermediates, type INavMeshParametersV2, type RecastInjection } from \"../types\";\nimport { RecastJSCrowd } from \"./RecastJSCrowd\";\nimport { ConvertNavPathPoints } from \"../common/convert\";\nimport { ComputeSmoothPath } from \"../common/smooth-path\";\nimport { CreateDebugNavMesh } from \"../debug/simple-debug\";\nimport { GetRecast } from \"../factory/common\";\nimport { InjectGenerators } from \"../generator/injection\";\nimport { DefaultMaxObstacles } from \"../common/config\";\nimport { CreateDefaultTileCacheMeshProcess, WaitForFullTileCacheUpdate } from \"../common/tile-cache\";\n\n/**\n * Navigation plugin for Babylon.js. It is a simple wrapper around the recast-navigation-js library. Not all features are implemented.\n * @remarks This plugin provides navigation mesh generation and pathfinding capabilities using the recast-navigation-js library\n * @remarks It supports both single-threaded and multi-threaded generation of navigation meshes.\n * @remarks The plugin can be used to create navigation meshes from meshes in a scene, compute paths, and manage crowd agents, etc.\n * @remarks It also provides methods for creating obstacles and querying the navigation mesh.\n * @see https://github.com/isaac-mason/recast-navigation-js\n */\nexport class RecastNavigationJSPluginV2 implements INavigationEnginePlugin {\n /**\n * Creates a navigation mesh - will be injected by the factory\n * @param meshes array of all the geometry used to compute the navigation mesh\n * @param parameters bunch of parameters used to filter geometry\n * @returns the created navmesh and navmesh query\n */\n createNavMeshImpl: (meshes: Array<Mesh>, parameters: INavMeshParametersV2) => CreateNavMeshResult;\n\n /**\n * Creates a navigation mesh - will be injected by the factory\n * @param meshes array of all the geometry used to compute the navigation mesh\n * @param parameters bunch of parameters used to filter geometry\n * @returns the created navmesh and navmesh query\n */\n createNavMeshAsyncImpl: (meshes: Array<Mesh>, parameters: INavMeshParametersV2) => Promise<CreateNavMeshResult>;\n\n /**\n * recast-navigation-js injection\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n public bjsRECAST: RecastInjection;\n\n /**\n * plugin name\n */\n public name: string = \"RecastNavigationJSPlugin\";\n\n /**\n * the navmesh created\n */\n public navMesh?: NavMesh;\n\n /**\n * The navmesh query created from the navmesh\n * @remarks This is used to query the navmesh for pathfinding and other navigation tasks\n */\n public get navMeshQuery(): NavMeshQuery {\n return this._navMeshQuery;\n }\n\n private _navMeshQuery!: NavMeshQuery;\n\n /**\n * Intermediates generated during the navmesh creation\n * @remarks This is used for debugging and visualization purposes.\n * @remarks You have access to vertices, indices and vertex colors to visualize the navmesh creation process.\n * @remarks This is only available if the `keepIntermediates` parameter is set\n * @remarks to true during navmesh generation.\n */\n private _intermediates?: GeneratorIntermediates;\n\n /**\n * Gets the intermediates generated during the navmesh creation\n * @returns The generator intermediates, or undefined if not available\n */\n public get intermediates(): GeneratorIntermediates | undefined {\n return this._intermediates;\n }\n\n /**\n * Tile cache used for tiled navigation meshes\n * @remarks This is used to store and manage tiles of the navigation mesh for efficient path and when obstacles are used.\n */\n private _tileCache?: TileCache;\n\n /**\n * Gets the tile cache used for tiled navigation meshes\n * @returns The tile cache instance, or undefined if not available\n */\n public get tileCache(): TileCache | undefined {\n return this._tileCache;\n }\n\n // Crowd specific properties\n private _maximumSubStepCount: number = 10;\n private _timeStep: number = 1 / 60;\n private _timeFactor: number = 1;\n\n private _crowd?: ICrowd;\n\n /**\n * Creates a RecastNavigationJSPluginV2 instance\n * @param recastInjection The recast-navigation-js injection containing core and generators\n */\n public constructor(recastInjection?: RecastInjection) {\n if (!recastInjection) {\n recastInjection = GetRecast();\n InjectGenerators(this);\n }\n\n this.bjsRECAST = recastInjection;\n\n if (!this.isSupported()) {\n Logger.Error(\"RecastJS is not available. Please make sure you included the js file.\");\n return;\n }\n this.setTimeStep();\n }\n\n /**\n * Set the time step of the navigation tick update.\n * Default is 1/60.\n * A value of 0 will disable fixed time update\n * @param newTimeStep the new timestep to apply to this world.\n */\n public setTimeStep(newTimeStep: number = 1 / 60): void {\n this._timeStep = newTimeStep;\n }\n\n /**\n * Get the time step of the navigation tick update.\n * @returns the current time step\n */\n public getTimeStep(): number {\n return this._timeStep;\n }\n\n /**\n * If delta time in navigation tick update is greater than the time step\n * a number of sub iterations are done. If more iterations are need to reach deltatime\n * they will be discarded.\n * A value of 0 will set to no maximum and update will use as many substeps as needed\n * @param newStepCount the maximum number of iterations\n */\n public setMaximumSubStepCount(newStepCount: number = 10): void {\n this._maximumSubStepCount = newStepCount;\n }\n\n /**\n * Get the maximum number of iterations per navigation tick update\n * @returns the maximum number of iterations\n */\n public getMaximumSubStepCount(): number {\n return this._maximumSubStepCount;\n }\n\n /**\n * Time factor applied when updating crowd agents (default 1). A value of 0 will pause crowd updates.\n * @param value the time factor applied at update\n */\n public set timeFactor(value: number) {\n this._timeFactor = Math.max(value, 0);\n }\n\n /**\n * Get the time factor used for crowd agent update\n * @returns the time factor\n */\n public get timeFactor(): number {\n return this._timeFactor;\n }\n\n /**\n * Creates a navigation mesh - will be injected by the factory\n * @param meshes array of all the geometry used to compute the navigation mesh\n * @param parameters bunch of parameters used to filter geometry\n * @returns the created navmesh and navmesh query\n * @throws Error if the function is not injected yet or if the navmesh is not created\n */\n public createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParametersV2): CreateNavMeshResult {\n if (!this.createNavMeshImpl) {\n throw new Error(\"Function not injected yet. Use the factory to create the plugin.\");\n }\n\n this._preprocessParameters(parameters);\n\n const result = this.createNavMeshImpl(meshes, parameters);\n return this._processNavMeshResult(result);\n }\n\n /**\n * Creates a navigation mesh asynchronously - will be injected by the factory\n * @param meshes array of all the geometry used to compute the navigation mesh\n * @param parameters bunch of parameters used to filter geometry\n * @returns the created navmesh and navmesh query\n * @throws Error if the function is not injected yet or if the navmesh is not created\n */\n public async createNavMeshAsync(meshes: Array<Mesh>, parameters: INavMeshParametersV2): Promise<CreateNavMeshResult> {\n if (!this.createNavMeshAsyncImpl) {\n throw new Error(\"Function not injected yet. Use the factory to create the plugin.\");\n }\n\n this._preprocessParameters(parameters);\n\n const result = await this.createNavMeshAsyncImpl(meshes, parameters);\n return this._processNavMeshResult(result);\n }\n\n /**\n * Create a navigation mesh debug mesh\n * @param scene is where the mesh will be added\n * @returns debug display mesh\n */\n public createDebugNavMesh(scene: Scene): Mesh {\n if (!this.navMesh) {\n throw new Error(\"There is no navMesh generated.\");\n }\n\n if (this.navMesh && this._tileCache) {\n WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);\n }\n\n return CreateDebugNavMesh(this.navMesh, scene);\n }\n\n /**\n * Get a navigation mesh constrained position, closest to the parameter position\n * @param position world position\n * @returns the closest point to position constrained by the navigation mesh\n */\n public getClosestPoint(\n position: IVector3Like,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n }\n ): Vector3 {\n const ret = this._navMeshQuery.findClosestPoint(position, options);\n const pr = new Vector3(ret.point.x, ret.point.y, ret.point.z);\n return pr;\n }\n\n /**\n * Get a navigation mesh constrained position, closest to the parameter position\n * @param position world position\n * @param result output the closest point to position constrained by the navigation mesh\n */\n public getClosestPointToRef(\n position: IVector3Like,\n result: Vector3,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n }\n ): void {\n const ret = this._navMeshQuery.findClosestPoint(position, options);\n result.set(ret.point.x, ret.point.y, ret.point.z);\n }\n\n /**\n * Get a navigation mesh constrained position, within a particular radius\n * @param position world position\n * @param maxRadius the maximum distance to the constrained world position\n * @returns the closest point to position constrained by the navigation mesh\n */\n public getRandomPointAround(\n position: IVector3Like,\n maxRadius: number,\n options?: {\n startRef?: number;\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n }\n ): Vector3 {\n const ret = this._navMeshQuery.findRandomPointAroundCircle(position, maxRadius, options);\n const pr = new Vector3(ret.randomPoint.x, ret.randomPoint.y, ret.randomPoint.z);\n return pr;\n }\n\n /**\n * Get a navigation mesh constrained position, within a particular radius\n * @param position world position\n * @param maxRadius the maximum distance to the constrained world position\n * @param result output the closest point to position constrained by the navigation mesh\n */\n public getRandomPointAroundToRef(\n position: IVector3Like,\n maxRadius: number,\n result: Vector3,\n options?: {\n startRef?: number;\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n }\n ): void {\n const ret = this._navMeshQuery.findRandomPointAroundCircle(position, maxRadius, options);\n result.set(ret.randomPoint.x, ret.randomPoint.y, ret.randomPoint.z);\n }\n\n /**\n * Compute the final position from a segment made of destination-position\n * @param position position to start from\n * @param destination position to go to\n * @param startRef the reference id of the start polygon\n * @param options options for the function\n * @returns the resulting point along the navmesh\n */\n public moveAlong(\n position: IVector3Like,\n destination: IVector3Like,\n startRef = 0,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * The maximum number of polygons the output visited array can hold.\n */\n maxVisitedSize?: number;\n }\n ): Vector3 {\n const ret = this._navMeshQuery.moveAlongSurface(startRef, position, destination, options);\n const pr = new Vector3(ret.resultPosition.x, ret.resultPosition.y, ret.resultPosition.z);\n return pr;\n }\n\n /**\n * Compute the final position from a segment made of destination-position\n * @param position world position\n * @param destination world position\n * @param result output the resulting point along the navmesh\n * @param startRef the reference id of the start polygon.\n * @param options options for the function\n */\n public moveAlongToRef(\n position: IVector3Like,\n destination: IVector3Like,\n result: Vector3,\n startRef = 0,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n maxVisitedSize?: number;\n }\n ): void {\n const ret = this._navMeshQuery.moveAlongSurface(startRef, position, destination, options);\n result.set(ret.resultPosition.x, ret.resultPosition.y, ret.resultPosition.z);\n }\n\n /**\n * Compute a navigation path from start to end. Returns an empty array if no path can be computed\n * Path is straight.\n * @param start world position\n * @param end world position\n * @param options options for the function\n * @returns array containing world position composing the path\n */\n public computePath(\n start: IVector3Like,\n end: IVector3Like,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n maxPathPolys?: number;\n maxStraightPathPoints?: number;\n }\n ): Vector3[] {\n return ConvertNavPathPoints(this._navMeshQuery.computePath(start, end, options));\n }\n\n /**\n * Compute a navigation path from start to end. Returns an empty array if no path can be computed.\n * Path follows navigation mesh geometry.\n * @param start world position\n * @param end world position\n * @param options options to configure the path computation\n * @returns array containing world position composing the path\n */\n public computePathSmooth(\n start: Vector3,\n end: Vector3,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n maxPathPolys?: number;\n maxSmoothPathPoints?: number;\n stepSize?: number;\n slop?: number;\n }\n ): Vector3[] {\n if (!this.navMesh) {\n Logger.Error(\"No navmesh available. Cannot compute smooth path.\");\n return [];\n }\n return ComputeSmoothPath(this.navMesh, this._navMeshQuery, start, end, options);\n }\n\n /**\n * Create a new Crowd so you can add agents\n * @param maxAgents the maximum agent count in the crowd\n * @param maxAgentRadius the maximum radius an agent can have\n * @param scene to attach the crowd to\n * @returns the crowd you can add agents to\n */\n public createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd {\n const crowd = new RecastJSCrowd(this, maxAgents, maxAgentRadius, scene);\n this._crowd = crowd;\n return crowd;\n }\n\n /**\n * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)\n * The queries will try to find a solution within those bounds\n * default is (1,1,1)\n * @param extent x,y,z value that define the extent around the queries point of reference\n */\n public setDefaultQueryExtent(extent: IVector3Like): void {\n this._navMeshQuery.defaultQueryHalfExtents = extent;\n }\n\n /**\n * Get the Bounding box extent specified by setDefaultQueryExtent\n * @returns the box extent values\n */\n public getDefaultQueryExtent(): Vector3 {\n return new Vector3(this._navMeshQuery.defaultQueryHalfExtents.x, this._navMeshQuery.defaultQueryHalfExtents.y, this._navMeshQuery.defaultQueryHalfExtents.z);\n }\n\n /**\n * Get the Bounding box extent result specified by setDefaultQueryExtent\n * @param result output the box extent values\n */\n public getDefaultQueryExtentToRef(result: Vector3): void {\n result.set(this._navMeshQuery.defaultQueryHalfExtents.x, this._navMeshQuery.defaultQueryHalfExtents.y, this._navMeshQuery.defaultQueryHalfExtents.z);\n }\n\n /**\n * build the navmesh from a previously saved state using getNavmeshData\n * @param data the Uint8Array returned by getNavmeshData\n */\n public buildFromNavmeshData(data: Uint8Array): void {\n const result = this.bjsRECAST.importNavMesh(data);\n this.navMesh = result.navMesh;\n this._navMeshQuery = new this.bjsRECAST.NavMeshQuery(this.navMesh);\n }\n\n /**\n * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data\n * @returns data the Uint8Array that can be saved and reused\n */\n public getNavmeshData(): Uint8Array {\n if (!this.navMesh) {\n throw new Error(\"There is no NavMesh generated.\");\n }\n return this.bjsRECAST.exportNavMesh(this.navMesh);\n }\n\n /**\n * build the tile cache from a previously saved state using getTileCacheData\n * @param tileCacheData the data returned by getTileCacheData\n * @param tileCacheMeshProcess optional process to apply to each tile created\n */\n public buildFromTileCacheData(tileCacheData: Uint8Array, tileCacheMeshProcess?: TileCacheMeshProcess): void {\n const result = this.bjsRECAST.importTileCache(tileCacheData, tileCacheMeshProcess ?? CreateDefaultTileCacheMeshProcess([]));\n this.navMesh = result.navMesh;\n this._tileCache = result.tileCache;\n this._navMeshQuery = new this.bjsRECAST.NavMeshQuery(this.navMesh);\n }\n\n /**\n * returns the tile cache data that can be used later. The tile cache must be built before retrieving the data\n * @returns the tile cache data that can be used later. The tile cache must be built before retrieving the data\n * @throws Error if there is no TileCache generated\n * @remarks The returned data can be used to rebuild the tile cache later using buildFromTileCacheData\n */\n public getTileCacheData(): Uint8Array {\n if (!this.navMesh || !this._tileCache) {\n throw new Error(\"There is no TileCache generated.\");\n }\n return this.bjsRECAST.exportTileCache(this.navMesh, this._tileCache);\n }\n\n /**\n * Disposes\n */\n public dispose() {\n this._crowd?.dispose();\n this.navMesh?.destroy();\n this._navMeshQuery?.destroy();\n this._tileCache?.destroy();\n }\n\n /**\n * Creates a cylinder obstacle and add it to the navigation\n * @param position world position\n * @param radius cylinder radius\n * @param height cylinder height\n * @param doNotWaitForCacheUpdate if true the function will not wait for the tile cache to be fully updated before returning\n * @returns the obstacle freshly created\n */\n public addCylinderObstacle(position: IVector3Like, radius: number, height: number, doNotWaitForCacheUpdate = false): Nullable<IObstacle> {\n const obstacleResult = this._tileCache?.addCylinderObstacle(position, radius, height);\n if (!obstacleResult?.success) {\n return null;\n }\n\n if (!doNotWaitForCacheUpdate && this.navMesh && this._tileCache) {\n WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);\n }\n\n return (obstacleResult.obstacle as IObstacle) ?? null;\n }\n\n /**\n * Creates an oriented box obstacle and add it to the navigation\n * @param position world position\n * @param extent box size\n * @param angle angle in radians of the box orientation on Y axis\n * @param doNotWaitForCacheUpdate if true the function will not wait for the tile cache to be fully updated before returning\n * @returns the obstacle freshly created\n */\n public addBoxObstacle(position: IVector3Like, extent: IVector3Like, angle: number, doNotWaitForCacheUpdate = false): Nullable<IObstacle> {\n const obstacleResult = this._tileCache?.addBoxObstacle(position, extent, angle);\n if (!obstacleResult?.success) {\n return null;\n }\n\n if (!doNotWaitForCacheUpdate && this.navMesh && this._tileCache) {\n WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);\n }\n\n return (obstacleResult.obstacle as IObstacle) ?? null;\n }\n\n /**\n * Removes an obstacle created by addCylinderObstacle or addBoxObstacle\n * @param obstacle obstacle to remove from the navigation\n * @param doNotWaitForCacheUpdate if true the function will not wait for the tile cache to be fully updated before returning\n *\n */\n public removeObstacle(obstacle: IObstacle, doNotWaitForCacheUpdate = false): void {\n this._tileCache?.removeObstacle(obstacle);\n\n if (!doNotWaitForCacheUpdate && this.navMesh && this._tileCache) {\n WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);\n }\n }\n\n /**\n * If this plugin is supported\n * @returns true if plugin is supported\n */\n public isSupported(): boolean {\n return !!this.bjsRECAST;\n }\n\n /**\n * Returns the seed used for randomized functions like `getRandomPointAround`\n * @returns seed number\n */\n public getRandomSeed(): number {\n return this.bjsRECAST.getRandomSeed();\n }\n\n /**\n * Set the seed used for randomized functions like `getRandomPointAround`\n * @param seed number used as seed for random functions\n */\n public setRandomSeed(seed: number): void {\n this.bjsRECAST.setRandomSeed(seed);\n }\n\n // New functions beyond the INavigationEnginePlugin interface\n\n /**\n * Perform a raycast on the navmesh\n * @param start start position\n * @param end end position\n * @returns if a direct path exists between start and end, and the hit point if any\n */\n public raycast(start: IVector3Like, end: IVector3Like) {\n const nearestStartPoly = this._navMeshQuery.findNearestPoly(start);\n const raycastResult = this._navMeshQuery.raycast(nearestStartPoly.nearestRef, start, end);\n\n const hit = 0 < raycastResult.t && raycastResult.t < 1.0;\n if (!hit) {\n return {\n hit: false,\n };\n } else {\n TmpVectors.Vector3[0].set(start.x, start.y, start.z);\n TmpVectors.Vector3[1].set(end.x, end.y, end.z);\n\n const distanceToHitBorder = Vector3.Distance(TmpVectors.Vector3[0], TmpVectors.Vector3[1]) * (raycastResult?.t ?? 0);\n const direction = TmpVectors.Vector3[1].subtract(TmpVectors.Vector3[0]).normalize();\n const hitPoint = TmpVectors.Vector3[0].add(direction.multiplyByFloats(distanceToHitBorder, distanceToHitBorder, distanceToHitBorder));\n\n return {\n hit: true,\n hitPoint,\n };\n }\n }\n\n /**\n * Compute the final position from a segment made of destination-position, and return the height of the polygon\n * This is a more sophisticated version of moveAlong that will use the height of the polygon at the end position\n * @param position world position to start from\n * @param velocity velocity of the movement\n * @param options options for the function\n * @returns the resulting point along the navmesh, the polygon reference id and the height of the polygon\n */\n public moveAlongWithVelocity(\n position: IVector3Like,\n velocity: IVector3Like,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n /**\n * The maximum number of polygons the output visited array can hold.\n */\n maxVisitedSize?: number;\n }\n ) {\n const { point, polyRef } = this._navMeshQuery.findClosestPoint(\n {\n x: position.x,\n y: position.y,\n z: position.z,\n },\n options\n );\n\n const { resultPosition } = this._navMeshQuery.moveAlongSurface(\n polyRef,\n point,\n {\n x: point.x + velocity.x,\n y: point.y + velocity.y,\n z: point.z + velocity.z,\n },\n options\n );\n const polyHeightResult = this._navMeshQuery.getPolyHeight(polyRef, resultPosition);\n\n return {\n position: { x: resultPosition.x, y: polyHeightResult.success ? polyHeightResult.height : resultPosition.y, z: resultPosition.z },\n polyRef: polyRef,\n height: polyHeightResult.height,\n };\n }\n\n /**\n * Handles common post-processing and validation of navmesh creation results\n * @param result The partial result from navmesh creation\n * @returns The validated and complete CreateNavMeshresult\n */\n private _processNavMeshResult(result: Nullable<Partial<CreateNavMeshResult>>): CreateNavMeshResult {\n if (!result?.navMesh || !result?.navMeshQuery) {\n throw new Error(\"Unable to create navmesh. No navMesh or navMeshQuery returned.\");\n }\n\n this.navMesh = result.navMesh;\n this._navMeshQuery = result.navMeshQuery;\n this._intermediates = result.intermediates;\n this._tileCache = result.tileCache;\n\n return {\n navMesh: result.navMesh,\n navMeshQuery: result.navMeshQuery,\n intermediates: result.intermediates,\n tileCache: result.tileCache, // tileCache is optional\n };\n }\n\n private _preprocessParameters(parameters: INavMeshParametersV2) {\n // if maxObstacles is not defined, set it to a default value and set a default tile size if not defined\n if (parameters.maxObstacles === undefined) {\n parameters.tileSize = parameters.tileSize ?? 32; // maxObstacles will trigger tile cache creation, so we need a tile size\n parameters.maxObstacles = DefaultMaxObstacles;\n }\n\n parameters.walkableSlopeAngle = Math.max(0.1, parameters.walkableSlopeAngle ?? 60);\n }\n}\n"]}
|
package/navigation/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
4
|
-
import type
|
|
5
|
-
import type
|
|
6
|
-
import type
|
|
1
|
+
import { type NavMesh, type NavMeshQuery, type TileCache, type TileCacheMeshProcess } from "@recast-navigation/core";
|
|
2
|
+
import { type SoloNavMeshGeneratorIntermediates, type TileCacheGeneratorIntermediates, type TiledNavMeshGeneratorIntermediates } from "@recast-navigation/generators";
|
|
3
|
+
import { type IVector3Like } from "@babylonjs/core/Maths/math.like.js";
|
|
4
|
+
import { type Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
|
5
|
+
import { type IAgentParameters, type INavMeshParameters } from "@babylonjs/core/Navigation/INavigationEngine.js";
|
|
6
|
+
import { type Nullable } from "@babylonjs/core/types.js";
|
|
7
7
|
/**
|
|
8
8
|
* Recast injection type
|
|
9
9
|
*/
|
package/navigation/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../dev/addons/src/navigation/types.ts"],"names":[],"mappings":"AAqKA;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,yBAAyB,EAAE,2BAA2B;IACtD,uBAAuB,EAAE,yBAAyB;IAClD,gBAAgB,EAAE,kBAAkB;IACpC,qBAAqB,EAAE,uBAAuB;IAC9C,sCAAsC,EAAE,wCAAwC;CACnF,CAAC","sourcesContent":["import type
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../dev/addons/src/navigation/types.ts"],"names":[],"mappings":"AAqKA;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,yBAAyB,EAAE,2BAA2B;IACtD,uBAAuB,EAAE,yBAAyB;IAClD,gBAAgB,EAAE,kBAAkB;IACpC,qBAAqB,EAAE,uBAAuB;IAC9C,sCAAsC,EAAE,wCAAwC;CACnF,CAAC","sourcesContent":["import { type NavMesh, type NavMeshQuery, type TileCache, type TileCacheMeshProcess } from \"@recast-navigation/core\";\nimport { type SoloNavMeshGeneratorIntermediates, type TileCacheGeneratorIntermediates, type TiledNavMeshGeneratorIntermediates } from \"@recast-navigation/generators\";\n\nimport { type IVector3Like } from \"core/Maths/math.like\";\nimport { type Vector3 } from \"core/Maths/math.vector\";\nimport { type IAgentParameters, type INavMeshParameters } from \"core/Navigation/INavigationEngine\";\nimport { type Nullable } from \"core/types\";\n\n/**\n * Recast injection type\n */\nexport type RecastInjection = any; // typeof import(\"@recast-navigation/core\") & typeof import(\"@recast-navigation/generators\");\n\n/**\n * Off-mesh connection data\n */\nexport interface IOffMeshConnection {\n /**\n * The start position of the off-mesh connection.\n */\n startPosition: IVector3Like;\n /**\n * The end position of the off-mesh connection.\n */\n endPosition: IVector3Like;\n /**\n * The radius of the off-mesh connection.\n */\n radius: number;\n /**\n * The type of the off-mesh connection.\n */\n bidirectional: boolean;\n /**\n * The area type of the off-mesh connection.\n */\n area: number;\n /**\n * The flags of the off-mesh connection.\n */\n flags: number;\n /**\n * The user ID of the off-mesh connection.\n * @remarks This can be used to associate the off-mesh connection with a specific user\n */\n userId?: number;\n}\n\n/**\n * Result of a navigation mesh creation.\n */\nexport type CreateNavMeshResult = Nullable<{\n /**\n * Navigation mesh\n */\n navMesh: NavMesh;\n /**\n * Navigation mesh query\n */\n navMeshQuery: NavMeshQuery;\n /**\n * Intermediates generated during the NavMesh creation process.\n * @remarks This is only available if the `keepIntermediates` parameter is set to true in the `INavMeshParametersV2`.\n * It can be used for debugging or visualization purposes.\n */\n intermediates?: GeneratorIntermediates;\n /**\n * Tile cache generated during the NavMesh creation process.\n * @remarks This is only available if the `maxObstacles` parameter is set to a value greater than 0 in the `INavMeshParametersV2`. Defaults `maxObstacles` to 128.\n * It can be used for obstacle avoidance and dynamic navigation mesh updates.\n * @see {@link INavMeshParametersV2}\n */\n tileCache?: TileCache;\n}>;\n\n/**\n * Agent parameters\n * For actual limits and default values check the recast-navigation-js docs.\n * @see https://docs.recast-navigation-js.isaacmason.com/types/index.CrowdAgentParams.html\n */\nexport interface IAgentParametersV2 extends IAgentParameters {\n /**\n * Flags that impact steering behavior.\n */\n updateFlags: number;\n /**\n * The index of the avoidance configuration to use for the agent. [Limits: 0 to #DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS inclusive]\n */\n obstacleAvoidanceType: number;\n /**\n * The index of the query filter used by this agent.\n */\n queryFilterType: number;\n /**\n * User defined data attached to the agent.\n */\n userData: unknown;\n}\n\n/**\n * NavMesh parameters\n * For actual limits and default values check the recast-navigation-js docs.\n * @see https://docs.recast-navigation-js.isaacmason.com/types/index.RecastConfig.html\n */\nexport interface INavMeshParametersV2 extends INavMeshParameters {\n /**\n * OffMeshConnections - Teleports\n */\n offMeshConnections?: IOffMeshConnection[];\n /**\n * Whether to keep intermediate navigation mesh data for debug visualization. Default is false.\n */\n keepIntermediates?: boolean;\n /**\n * The maximum number of obstacles that can be added to the navigation mesh. Default is 32.\n * If this value is greater then 0, the navigation mesh will be generated with a tile cache.\n */\n maxObstacles?: number;\n /**\n * The size of each tile in the tiled navigation mesh. Default is 32.\n */\n expectedLayersPerTile?: number;\n /**\n * Function which is sets the polyAreas and polyFlags for the tile cache mesh. Defaults to a function that sets all areas to 0 and flags to 1.\n */\n tileCacheMeshProcess?: TileCacheMeshProcess;\n /**\n * Don't reverse indices of the source mesh\n */\n doNotReverseIndices?: boolean;\n}\n\n/**\n * Result of a steer target computation.\n */\nexport type SteerTargetResult =\n | {\n /**\n * Indicates whether the steering target computation was successful.\n */\n success: false;\n }\n | {\n /**\n * Indicates whether the steering target computation was successful.\n */\n success: true;\n /**\n * The position to steer towards.\n */\n steerPos: Vector3;\n /**\n * The flag indicating the type of steering position.\n */\n steerPosFlag: number;\n /**\n * The reference to the polygon that the steering position is associated with.\n */\n steerPosRef: number;\n /**\n * The points that make up the path to the steering position.\n */\n points: Vector3[];\n };\n\n/**\n * Error types for path computation.\n */\nexport const ComputePathError = {\n START_NEAREST_POLY_FAILED: \"START_NEAREST_POLY_FAILED\",\n END_NEAREST_POLY_FAILED: \"END_NEAREST_POLY_FAILED\",\n FIND_PATH_FAILED: \"FIND_PATH_FAILED\",\n NO_POLYGON_PATH_FOUND: \"NO_POLYGON_PATH_FOUND\",\n NO_CLOSEST_POINT_ON_LAST_POLYGON_FOUND: \"NO_CLOSEST_POINT_ON_LAST_POLYGON_FOUND\",\n};\n\nexport type ComputePathErrorType = (typeof ComputePathError)[keyof typeof ComputePathError];\n\n/**\n * Result of a path computation.\n */\nexport type ComputePathResult = {\n /**\n * Indicates whether the path computation was successful.\n */\n success: boolean;\n /**\n * The error message if the path computation failed.\n */\n error?: {\n /**\n * A descriptive error message.\n */\n name?: string;\n /**\n * The type of error that occurred during path computation.\n * @remarks This will be one of the values from `ComputePathError`\n */\n type?: ComputePathErrorType;\n /**\n * Status describing the error.\n */\n status?: number;\n };\n /**\n * The computed path as an array of Vector3 points.\n */\n path: IVector3Like[];\n};\n\n/**\n * Intermediates generated during the NavMesh creation process.\n * @remarks This is only available if the `keepIntermediates` parameter is set to true in the `INavMeshParametersV2`.\n * It can be used for debugging or visualization purposes.\n */\nexport type GeneratorIntermediates = SoloNavMeshGeneratorIntermediates | TiledNavMeshGeneratorIntermediates | TileCacheGeneratorIntermediates | null;\n"]}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* For more info visit: https://forum.babylonjs.com/t/replacing-recastjs-with-recast-navigation-js/56003/46
|
|
6
6
|
*/
|
|
7
7
|
import { exportNavMesh, exportTileCache, init as initRecast } from "@recast-navigation/core";
|
|
8
|
-
import { generateSoloNavMesh, generateTileCache, generateTiledNavMesh } from "@recast-navigation/generators";
|
|
8
|
+
import { generateSoloNavMesh, generateTileCache, generateTiledNavMesh, } from "@recast-navigation/generators";
|
|
9
9
|
import { CreateSoloNavMeshConfig, CreateTileCacheNavMeshConfig } from "../common/config.js";
|
|
10
10
|
/**
|
|
11
11
|
* Generates a navigation mesh in a web worker.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navmesh-worker.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/worker/navmesh-worker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"navmesh-worker.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/worker/navmesh-worker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EAIH,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,GACvB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAGzF;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACjC,IAAI,CAAC,SAAS,GAAG,KAAK,EAAE,KAkBvB,EAAE,EAAE;QACD,IAAI,CAAC,KAAK,CAAC,IAAI,I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zB,OAAO;QACX,CAAC;QAED,4BAA4B;QAC5B,MAAM,aAAa,GAAmB,EAAE,CAAC;QACzC,MAAM,OAAO,GAGT,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;QAEjD,gEAAgE;QAChE,IAAI,WAAW,IAAI,MAAM,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YAC5C,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;gBACnB,MAAM,eAAe,GAAG,eAAe,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;gBAC1E,OAAO,CAAC,SAAS,GAAG,eAAe,CAAC;gBACpC,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;YAC/C,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,6BAA6B;YAC7B,MAAM,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACpD,OAAO,CAAC,OAAO,GAAG,aAAa,CAAC;YAChC,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC7C,CAAC;QAED,4BAA4B;QAC5B,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,CAAC;QAEvD,WAAW;QACX,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QAE1B,IAAI,WAAW,IAAI,MAAM,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YAC5C,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAC/B,CAAC;IACL,CAAC,CAAC;AACN,CAAC","sourcesContent":["/**\n * IMPORTANT!\n * This file is still under construction and will change in the future.\n * Workers are not yet supported.\n * For more info visit: https://forum.babylonjs.com/t/replacing-recastjs-with-recast-navigation-js/56003/46\n */\nimport { exportNavMesh, exportTileCache, init as initRecast } from \"@recast-navigation/core\";\nimport {\n type SoloNavMeshGeneratorConfig,\n type TileCacheGeneratorConfig,\n type TiledNavMeshGeneratorConfig,\n generateSoloNavMesh,\n generateTileCache,\n generateTiledNavMesh,\n} from \"@recast-navigation/generators\";\n\nimport { CreateSoloNavMeshConfig, CreateTileCacheNavMeshConfig } from \"../common/config\";\nimport { type INavMeshParametersV2 } from \"../types\";\n\n/**\n * Generates a navigation mesh in a web worker.\n */\nexport function GenerateNavMeshWorker() {\n self.onmessage = async (event: {\n /**\n * The data sent to the worker.\n */\n data: {\n /**\n * The positions of the vertices in the nav mesh.\n */\n positions: Float32Array;\n /**\n * The indices of the vertices in the nav mesh.\n */\n indices: Uint32Array;\n /**\n * The parameters used to configure the nav mesh generation.\n */\n parameters: INavMeshParametersV2;\n };\n }) => {\n if (!event.data || !event.data.positions || !event.data.indices || !event.data.parameters) {\n self.postMessage({ success: false, error: \"Invalid input data.\" });\n return;\n }\n\n await initRecast();\n\n const { positions, indices, parameters } = event.data;\n\n // Decide on the type of nav mesh to generate based on parameters\n // If tileSize is set, we will generate a tiled nav mesh\n // If maxObstacles is set, we will generate a tile cache nav mesh\n // Otherwise, we will generate a solo nav mesh\n const needsTileCache = (parameters.maxObstacles ?? 0) > 0;\n const needsTiledNavMesh = \"tileSize\" in parameters && (parameters.tileSize ?? 0) > 0;\n const config = needsTileCache ? CreateTileCacheNavMeshConfig(parameters) : needsTileCache ? CreateTileCacheNavMeshConfig(parameters) : CreateSoloNavMeshConfig(parameters);\n\n const result = needsTiledNavMesh\n ? needsTileCache\n ? generateTileCache(positions, indices, config as TileCacheGeneratorConfig)\n : generateTiledNavMesh(positions, indices, config as TiledNavMeshGeneratorConfig)\n : generateSoloNavMesh(positions, indices, config as SoloNavMeshGeneratorConfig);\n\n if (!result.success || !result.navMesh) {\n self.postMessage(result);\n return;\n }\n\n // prepare the transferables\n const transferables: Transferable[] = [];\n const message: {\n navMesh?: Uint8Array<ArrayBufferLike>;\n tileCache?: Uint8Array<ArrayBufferLike>;\n } = { navMesh: undefined, tileCache: undefined };\n\n // If tile cache is present, serialize it and add to the message\n if (\"tileCache\" in result && result.tileCache) {\n if (result.tileCache) {\n const tileCacheExport = exportTileCache(result.navMesh, result.tileCache);\n message.tileCache = tileCacheExport;\n transferables.push(tileCacheExport.buffer);\n }\n } else {\n // otherwise send the NavMesh\n const navMeshExport = exportNavMesh(result.navMesh);\n message.navMesh = navMeshExport;\n transferables.push(navMeshExport.buffer);\n }\n\n // send transferable message\n self.postMessage(message, { transfer: transferables });\n\n // clean up\n result.navMesh?.destroy();\n\n if (\"tileCache\" in result && result.tileCache) {\n result.tileCache.destroy();\n }\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babylonjs/addons",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"module": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "npm run clean && npm run compile",
|
|
17
17
|
"clean": "rimraf dist && rimraf *.tsbuildinfo -g && rimraf \"./**/*.!(md|json|build.json|lts.json)\" -g",
|
|
18
|
-
"compile": "tsc -b tsconfig.build.json",
|
|
18
|
+
"compile": "tsc -b tsconfig.build.json && build-tools -c tp --outDir . --buildType es6 --basePackage @babylonjs/addons --appendJS",
|
|
19
19
|
"postcompile": "build-tools -c add-js-to-es6"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@babylonjs/core": "9.
|
|
22
|
+
"@babylonjs/core": "9.2.0",
|
|
23
23
|
"@dev/addons": "^1.0.0",
|
|
24
24
|
"@dev/build-tools": "^1.0.0"
|
|
25
25
|
},
|