@onerjs/addons 8.27.5 → 8.27.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/navigation/common/getters.d.ts +3 -1
- package/navigation/common/getters.js +2 -2
- package/navigation/common/getters.js.map +1 -1
- package/navigation/generator/generator.single-thread.js +1 -1
- package/navigation/generator/generator.single-thread.js.map +1 -1
- package/navigation/generator/generator.worker.js +1 -1
- package/navigation/generator/generator.worker.js.map +1 -1
- package/navigation/types.d.ts +4 -0
- package/navigation/types.js.map +1 -1
- package/package.json +2 -2
|
@@ -4,7 +4,9 @@ import { Mesh } from "@onerjs/core/Meshes/mesh.js";
|
|
|
4
4
|
* @param meshes The array of meshes from which to extract positions and indices.
|
|
5
5
|
* @returns A tuple containing a Float32Array of positions and a Uint32Array of
|
|
6
6
|
*/
|
|
7
|
-
export declare function GetPositionsAndIndices(meshes: Mesh[]
|
|
7
|
+
export declare function GetPositionsAndIndices(meshes: Mesh[], options?: {
|
|
8
|
+
doNotReverseIndices?: boolean;
|
|
9
|
+
}): [positions: Float32Array, indices: Uint32Array];
|
|
8
10
|
/**
|
|
9
11
|
* Reverses the order of vertices in each triangle (3 indices per face) to ensure
|
|
10
12
|
* that the winding order is consistent with the Recast Navigation requirements.
|
|
@@ -6,7 +6,7 @@ import { Mesh } from "@onerjs/core/Meshes/mesh.js";
|
|
|
6
6
|
* @param meshes The array of meshes from which to extract positions and indices.
|
|
7
7
|
* @returns A tuple containing a Float32Array of positions and a Uint32Array of
|
|
8
8
|
*/
|
|
9
|
-
export function GetPositionsAndIndices(meshes) {
|
|
9
|
+
export function GetPositionsAndIndices(meshes, options) {
|
|
10
10
|
let offset = 0;
|
|
11
11
|
let index;
|
|
12
12
|
let tri;
|
|
@@ -16,7 +16,7 @@ export function GetPositionsAndIndices(meshes) {
|
|
|
16
16
|
for (index = 0; index < meshes.length; index++) {
|
|
17
17
|
if (meshes[index]) {
|
|
18
18
|
const mesh = meshes[index];
|
|
19
|
-
const meshIndices = GetReversedIndices(mesh);
|
|
19
|
+
const meshIndices = options?.doNotReverseIndices ? mesh.getIndices(false, true) : GetReversedIndices(mesh);
|
|
20
20
|
if (!meshIndices) {
|
|
21
21
|
continue;
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getters.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/common/getters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,uCAA4B;AACnD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,0CAA+B;AACzD,OAAO,EAAE,IAAI,EAAE,oCAAyB;AAExC;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,
|
|
1
|
+
{"version":3,"file":"getters.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/common/getters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,uCAA4B;AACnD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,0CAA+B;AACzD,OAAO,EAAE,IAAI,EAAE,oCAAyB;AAExC;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAClC,MAAc,EACd,OAEC;IAED,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,KAAa,CAAC;IAClB,IAAI,GAAW,CAAC;IAChB,IAAI,EAAU,CAAC;IACf,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,KAAK,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QAC7C,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAChB,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;YAE3B,MAAM,WAAW,GAAG,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAA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C,CAAC,CAAC;QACxE,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC","sourcesContent":["import { VertexBuffer } from \"core/Buffers/buffer\";\nimport { Matrix, Vector3 } from \"core/Maths/math.vector\";\nimport { Mesh } from \"core/Meshes/mesh\";\n\n/**\n * Extracts positions and indices from an array of meshes.\n * @param meshes The array of meshes from which to extract positions and indices.\n * @returns A tuple containing a Float32Array of positions and a Uint32Array of\n */\nexport function GetPositionsAndIndices(\n meshes: Mesh[],\n options?: {\n doNotReverseIndices?: boolean;\n }\n): [positions: Float32Array, indices: Uint32Array] {\n let offset = 0;\n let index: number;\n let tri: number;\n let pt: number;\n const positions: number[] = [];\n const indices: number[] = [];\n\n for (index = 0; index < meshes.length; index++) {\n if (meshes[index]) {\n const mesh = meshes[index];\n\n const meshIndices = options?.doNotReverseIndices ? mesh.getIndices(false, true) : GetReversedIndices(mesh);\n if (!meshIndices) {\n continue;\n }\n\n const meshPositions = mesh.getVerticesData(VertexBuffer.PositionKind, false, false);\n if (!meshPositions) {\n continue;\n }\n\n const worldMatrices: Matrix[] = [];\n const worldMatrix = mesh.computeWorldMatrix(true);\n\n if (mesh.hasThinInstances) {\n const thinMatrices = (mesh as Mesh).thinInstanceGetWorldMatrices();\n for (let instanceIndex = 0; instanceIndex < thinMatrices.length; instanceIndex++) {\n const tmpMatrix = new Matrix();\n const thinMatrix = thinMatrices[instanceIndex];\n thinMatrix.multiplyToRef(worldMatrix, tmpMatrix);\n worldMatrices.push(tmpMatrix);\n }\n } else {\n worldMatrices.push(worldMatrix);\n }\n\n const transformed = Vector3.Zero();\n const position = Vector3.Zero();\n\n for (let matrixIndex = 0; matrixIndex < worldMatrices.length; matrixIndex++) {\n const wm = worldMatrices[matrixIndex];\n for (tri = 0; tri < meshIndices.length; tri++) {\n indices.push(meshIndices[tri] + offset);\n }\n\n for (pt = 0; pt < meshPositions.length; pt += 3) {\n Vector3.FromArrayToRef(meshPositions, pt, position);\n Vector3.TransformCoordinatesToRef(position, wm, transformed);\n positions.push(transformed.x, transformed.y, transformed.z);\n }\n\n offset += meshPositions.length / 3;\n }\n }\n }\n return [Float32Array.from(positions), Uint32Array.from(indices)];\n}\n\n/**\n * Reverses the order of vertices in each triangle (3 indices per face) to ensure\n * that the winding order is consistent with the Recast Navigation requirements.\n * This is necessary because Recast Navigation expects the indices to be in a specific winding order.\n * @param meshOrIndices The mesh from which to extract indices or the indices themselves.\n * @returns Array of indices with reversed winding order.\n */\nexport function GetReversedIndices(\n meshOrIndices: Mesh | Uint32Array | number[]\n): Uint32Array<ArrayBufferLike> | number[] | Int32Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | null {\n const indices = meshOrIndices instanceof Mesh ? meshOrIndices.getIndices(false, true) : meshOrIndices;\n\n if (indices) {\n for (let i = 0; i < indices.length; i += 3) {\n // Swap the second and third index to reverse the winding order\n [indices[i + 1], indices[i + 2]] = [indices[i + 2], indices[i + 1]];\n }\n }\n\n return indices;\n}\n"]}
|
|
@@ -19,7 +19,7 @@ export function GenerateNavMesh(meshes, parameters) {
|
|
|
19
19
|
if (meshes.length === 0) {
|
|
20
20
|
throw new Error("At least one mesh is needed to create the nav mesh.");
|
|
21
21
|
}
|
|
22
|
-
const [positions, indices] = GetPositionsAndIndices(meshes);
|
|
22
|
+
const [positions, indices] = GetPositionsAndIndices(meshes, { doNotReverseIndices: parameters.doNotReverseIndices });
|
|
23
23
|
if (!positions || !indices) {
|
|
24
24
|
throw new Error("Unable to get nav mesh. No vertices or indices.");
|
|
25
25
|
}
|
|
@@ -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,oCAAyB;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,CAAC,CAAC;
|
|
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,oCAAyB;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,CAAC,CAAC;IACvE,CAAC;IAED,iEAAiE;IACjE,wDAAwD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AE,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, TileCacheGeneratorConfig, 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"]}
|
|
@@ -39,7 +39,7 @@ export function GenerateNavMeshWithWorker(meshes, parameters, workerOptions) {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
// send message to worker
|
|
42
|
-
const [positions, indices] = GetPositionsAndIndices(meshes);
|
|
42
|
+
const [positions, indices] = GetPositionsAndIndices(meshes, { doNotReverseIndices: parameters.doNotReverseIndices });
|
|
43
43
|
const positionsCopy = new Float32Array(positions);
|
|
44
44
|
const indicesCopy = new Uint32Array(indices);
|
|
45
45
|
workerOptions.worker.postMessage({ positions: positionsCopy, indices: indicesCopy, parameters }, [positionsCopy.buffer, indicesCopy.buffer]);
|
|
@@ -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,CAAC,CAAC;
|
|
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 { NavMeshQuery, NavMesh, 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"]}
|
package/navigation/types.d.ts
CHANGED
|
@@ -118,6 +118,10 @@ export interface INavMeshParametersV2 extends INavMeshParameters {
|
|
|
118
118
|
* 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.
|
|
119
119
|
*/
|
|
120
120
|
tileCacheMeshProcess?: TileCacheMeshProcess;
|
|
121
|
+
/**
|
|
122
|
+
* Don't reverse indices of the source mesh
|
|
123
|
+
*/
|
|
124
|
+
doNotReverseIndices?: boolean;
|
|
121
125
|
}
|
|
122
126
|
/**
|
|
123
127
|
* Result of a steer target computation.
|
package/navigation/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../dev/addons/src/navigation/types.ts"],"names":[],"mappings":"
|
|
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, NavMeshQuery, TileCache, TileCacheMeshProcess } from \"@recast-navigation/core\";\nimport type { SoloNavMeshGeneratorIntermediates, TileCacheGeneratorIntermediates, 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, 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 * Statusring 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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onerjs/addons",
|
|
3
|
-
"version": "8.27.
|
|
3
|
+
"version": "8.27.7",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"module": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"postcompile": "build-tools -c add-js-to-es6"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@onerjs/core": "^8.27.
|
|
21
|
+
"@onerjs/core": "^8.27.7",
|
|
22
22
|
"@dev/addons": "^1.0.0",
|
|
23
23
|
"@dev/build-tools": "^1.0.0"
|
|
24
24
|
},
|