@onerjs/addons 8.27.0 → 8.27.2
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/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/navigation/common/config.d.ts +35 -0
- package/navigation/common/config.js +61 -0
- package/navigation/common/config.js.map +1 -0
- package/navigation/common/convert.d.ts +8 -0
- package/navigation/common/convert.js +22 -0
- package/navigation/common/convert.js.map +1 -0
- package/navigation/common/getters.d.ts +15 -0
- package/navigation/common/getters.js +76 -0
- package/navigation/common/getters.js.map +1 -0
- package/navigation/common/index.d.ts +6 -0
- package/navigation/common/index.js +7 -0
- package/navigation/common/index.js.map +1 -0
- package/navigation/common/smooth-path.d.ts +32 -0
- package/navigation/common/smooth-path.js +340 -0
- package/navigation/common/smooth-path.js.map +1 -0
- package/navigation/common/tile-cache.d.ts +15 -0
- package/navigation/common/tile-cache.js +32 -0
- package/navigation/common/tile-cache.js.map +1 -0
- package/navigation/common/utils.d.ts +17 -0
- package/navigation/common/utils.js +66 -0
- package/navigation/common/utils.js.map +1 -0
- package/navigation/debug/NavigationDebugger.d.ts +248 -0
- package/navigation/debug/NavigationDebugger.js +587 -0
- package/navigation/debug/NavigationDebugger.js.map +1 -0
- package/navigation/debug/index.d.ts +2 -0
- package/navigation/debug/index.js +3 -0
- package/navigation/debug/index.js.map +1 -0
- package/navigation/debug/simple-debug.d.ts +13 -0
- package/navigation/debug/simple-debug.js +23 -0
- package/navigation/debug/simple-debug.js.map +1 -0
- package/navigation/factory/common.d.ts +20 -0
- package/navigation/factory/common.js +80 -0
- package/navigation/factory/common.js.map +1 -0
- package/navigation/factory/factory.single-thread.d.ts +7 -0
- package/navigation/factory/factory.single-thread.js +15 -0
- package/navigation/factory/factory.single-thread.js.map +1 -0
- package/navigation/factory/factory.wasm.d.ts +7 -0
- package/navigation/factory/factory.wasm.js +15 -0
- package/navigation/factory/factory.wasm.js.map +1 -0
- package/navigation/factory/factory.worker.d.ts +9 -0
- package/navigation/factory/factory.worker.js +40 -0
- package/navigation/factory/factory.worker.js.map +1 -0
- package/navigation/factory/index.d.ts +2 -0
- package/navigation/factory/index.js +4 -0
- package/navigation/factory/index.js.map +1 -0
- package/navigation/generator/generator.common.d.ts +25 -0
- package/navigation/generator/generator.common.js +40 -0
- package/navigation/generator/generator.common.js.map +1 -0
- package/navigation/generator/generator.single-thread.d.ts +20 -0
- package/navigation/generator/generator.single-thread.js +57 -0
- package/navigation/generator/generator.single-thread.js.map +1 -0
- package/navigation/generator/generator.worker.d.ts +29 -0
- package/navigation/generator/generator.worker.js +47 -0
- package/navigation/generator/generator.worker.js.map +1 -0
- package/navigation/generator/index.d.ts +3 -0
- package/navigation/generator/index.js +5 -0
- package/navigation/generator/index.js.map +1 -0
- package/navigation/generator/injection.d.ts +6 -0
- package/navigation/generator/injection.js +16 -0
- package/navigation/generator/injection.js.map +1 -0
- package/navigation/index.d.ts +5 -0
- package/navigation/index.js +7 -0
- package/navigation/index.js.map +1 -0
- package/navigation/plugin/RecastJSCrowd.d.ts +198 -0
- package/navigation/plugin/RecastJSCrowd.js +359 -0
- package/navigation/plugin/RecastJSCrowd.js.map +1 -0
- package/navigation/plugin/RecastNavigationJSPlugin.d.ts +396 -0
- package/navigation/plugin/RecastNavigationJSPlugin.js +445 -0
- package/navigation/plugin/RecastNavigationJSPlugin.js.map +1 -0
- package/navigation/plugin/index.d.ts +1 -0
- package/navigation/plugin/index.js +2 -0
- package/navigation/plugin/index.js.map +1 -0
- package/navigation/types.d.ts +199 -0
- package/navigation/types.js +11 -0
- package/navigation/types.js.map +1 -0
- package/navigation/worker/navmesh-worker.d.ts +4 -0
- package/navigation/worker/navmesh-worker.js +63 -0
- package/navigation/worker/navmesh-worker.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IMPORTANT!
|
|
3
|
+
* This file is still under construction and will change in the future.
|
|
4
|
+
* Workers are not yet supported.
|
|
5
|
+
* For more info visit: https://forum.babylonjs.com/t/replacing-recastjs-with-recast-navigation-js/56003/46
|
|
6
|
+
*/
|
|
7
|
+
import type { NavMeshQuery, NavMesh, TileCache } from "@recast-navigation/core";
|
|
8
|
+
import type { Mesh } from "@onerjs/core/Meshes/mesh.js";
|
|
9
|
+
import type { INavMeshParametersV2 } from "../types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Builds a NavMesh and NavMeshQuery from meshes using provided parameters.
|
|
12
|
+
* @param meshes The array of meshes used to create the NavMesh.
|
|
13
|
+
* @param parameters The parameters used to configure the NavMesh generation.
|
|
14
|
+
* @param workerOptions Options for the worker, including a completion callback and the worker instance.
|
|
15
|
+
* @throws Error if the NavMesh data is invalid or cannot be deserialized.
|
|
16
|
+
*/
|
|
17
|
+
export declare function GenerateNavMeshWithWorker(meshes: Array<Mesh>, parameters: INavMeshParametersV2, workerOptions: {
|
|
18
|
+
/**
|
|
19
|
+
* Completion callback that is called when the NavMesh generation is complete.
|
|
20
|
+
* @param navMesh The generated NavMesh.
|
|
21
|
+
* @param navMeshQuery The NavMeshQuery associated with the generated NavMesh.
|
|
22
|
+
* @param tileCache Optional TileCache if tile cache generation was used.
|
|
23
|
+
*/
|
|
24
|
+
completion: (navMesh: NavMesh, navMeshQuery: NavMeshQuery, tileCache?: TileCache) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Worker instance used for asynchronous NavMesh generation.
|
|
27
|
+
*/
|
|
28
|
+
worker: Worker;
|
|
29
|
+
}): void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { GetPositionsAndIndices } from "../common/getters.js";
|
|
2
|
+
import { BuildFromNavmeshData, BuildFromTileCacheData } from "./generator.common.js";
|
|
3
|
+
import { CreateDefaultTileCacheMeshProcess } from "../common/tile-cache.js";
|
|
4
|
+
/**
|
|
5
|
+
* Builds a NavMesh and NavMeshQuery from meshes using provided parameters.
|
|
6
|
+
* @param meshes The array of meshes used to create the NavMesh.
|
|
7
|
+
* @param parameters The parameters used to configure the NavMesh generation.
|
|
8
|
+
* @param workerOptions Options for the worker, including a completion callback and the worker instance.
|
|
9
|
+
* @throws Error if the NavMesh data is invalid or cannot be deserialized.
|
|
10
|
+
*/
|
|
11
|
+
export function GenerateNavMeshWithWorker(meshes, parameters, workerOptions) {
|
|
12
|
+
if (meshes.length === 0) {
|
|
13
|
+
throw new Error("At least one mesh is needed to create the nav mesh.");
|
|
14
|
+
}
|
|
15
|
+
// callback function to process the message from the worker
|
|
16
|
+
workerOptions.worker.onmessage = (e) => {
|
|
17
|
+
if (e.data?.success === false) {
|
|
18
|
+
throw new Error(`Unable to generate navMesh: ${e}`);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const { navMesh, tileCache } = e.data;
|
|
22
|
+
if (tileCache) {
|
|
23
|
+
// if tileCache is present, the binary data contains the navmesh and the tilecache as well
|
|
24
|
+
const tileCacheArray = new Uint8Array(tileCache);
|
|
25
|
+
const navMeshData = BuildFromTileCacheData(tileCacheArray, CreateDefaultTileCacheMeshProcess());
|
|
26
|
+
workerOptions.completion(navMeshData.navMesh, navMeshData.navMeshQuery, navMeshData.tileCache);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
if (navMesh) {
|
|
31
|
+
// deserialize the navmesh only (no tilecache present)
|
|
32
|
+
const navMeshArray = new Uint8Array(navMesh);
|
|
33
|
+
const navMeshData = BuildFromNavmeshData(navMeshArray);
|
|
34
|
+
workerOptions.completion(navMeshData.navMesh, navMeshData.navMeshQuery, undefined);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
throw new Error(`Unable to generate navMesh/tileCache: ${e}`);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
// send message to worker
|
|
42
|
+
const [positions, indices] = GetPositionsAndIndices(meshes);
|
|
43
|
+
const positionsCopy = new Float32Array(positions);
|
|
44
|
+
const indicesCopy = new Uint32Array(indices);
|
|
45
|
+
workerOptions.worker.postMessage({ positions: positionsCopy, indices: indicesCopy, parameters }, [positionsCopy.buffer, indicesCopy.buffer]);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=generator.worker.js.map
|
|
@@ -0,0 +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;IAC5D,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);\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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/generator/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,sCAAsC","sourcesContent":["export * from \"./generator.common\";\nexport * from \"./generator.single-thread\";\nexport * from \"./injection\";\n// export * from \"./generator.worker\";\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RecastNavigationJSPluginV2 } from "../plugin/RecastNavigationJSPlugin.js";
|
|
2
|
+
/**
|
|
3
|
+
* Injects the navigation mesh generation methods into the navigation plugin.
|
|
4
|
+
* @param navigationPlugin The navigation plugin to inject the methods into.
|
|
5
|
+
*/
|
|
6
|
+
export declare function InjectGenerators(navigationPlugin: RecastNavigationJSPluginV2): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { GenerateNavMesh } from "./generator.single-thread.js";
|
|
2
|
+
/**
|
|
3
|
+
* Injects the navigation mesh generation methods into the navigation plugin.
|
|
4
|
+
* @param navigationPlugin The navigation plugin to inject the methods into.
|
|
5
|
+
*/
|
|
6
|
+
export function InjectGenerators(navigationPlugin) {
|
|
7
|
+
navigationPlugin.createNavMeshImpl = (meshes, parameters) => {
|
|
8
|
+
return GenerateNavMesh(meshes, parameters);
|
|
9
|
+
};
|
|
10
|
+
navigationPlugin.createNavMeshAsyncImpl = async (meshes, parameters) => {
|
|
11
|
+
return await new Promise((resolve) => {
|
|
12
|
+
resolve(GenerateNavMesh(meshes, parameters));
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=injection.js.map
|
|
@@ -0,0 +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 { 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"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-restricted-imports */
|
|
2
|
+
export * from "./plugin/index.js";
|
|
3
|
+
export * from "./factory/index.js";
|
|
4
|
+
export * from "./common/index.js";
|
|
5
|
+
export * from "./generator/index.js";
|
|
6
|
+
export * from "./debug/index.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/addons/src/navigation/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./plugin/index\";\r\nexport * from \"./factory/index\";\r\nexport * from \"./common/index\";\r\nexport * from \"./generator/index\";\r\nexport * from \"./debug/index\";\r\n"]}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import type { Crowd } from "@recast-navigation/core";
|
|
2
|
+
import type { IVector3Like } from "@onerjs/core/Maths/math.like.js";
|
|
3
|
+
import type { TransformNode } from "@onerjs/core/Meshes/transformNode.js";
|
|
4
|
+
import type { ICrowd } from "@onerjs/core/Navigation/INavigationEngine.js";
|
|
5
|
+
import { Vector3 } from "@onerjs/core/Maths/math.vector.js";
|
|
6
|
+
import { Observable } from "@onerjs/core/Misc/observable.js";
|
|
7
|
+
import type { Scene } from "@onerjs/core/scene.js";
|
|
8
|
+
import type { RecastNavigationJSPluginV2 } from "./RecastNavigationJSPlugin.js";
|
|
9
|
+
import type { IAgentParametersV2 } from "../types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Recast Detour crowd implementation
|
|
12
|
+
* This class provides methods to manage a crowd of agents, allowing them to navigate a navigation mesh.
|
|
13
|
+
* It supports adding agents, updating their parameters, moving them to destinations, and checking their states.
|
|
14
|
+
* The crowd is updated in the scene's animation loop, and it notifies observers when agents reach their destinations.
|
|
15
|
+
*/
|
|
16
|
+
export declare class RecastJSCrowd implements ICrowd {
|
|
17
|
+
/**
|
|
18
|
+
* Recast plugin
|
|
19
|
+
*/
|
|
20
|
+
get navigationPlugin(): RecastNavigationJSPluginV2;
|
|
21
|
+
/**
|
|
22
|
+
* Link to the detour crowd
|
|
23
|
+
*/
|
|
24
|
+
get recastCrowd(): Crowd;
|
|
25
|
+
/**
|
|
26
|
+
* One transform per agent
|
|
27
|
+
*/
|
|
28
|
+
get transforms(): TransformNode[];
|
|
29
|
+
/**
|
|
30
|
+
* All agents created
|
|
31
|
+
*/
|
|
32
|
+
get agents(): readonly number[];
|
|
33
|
+
/**
|
|
34
|
+
* Agents reach radius
|
|
35
|
+
*/
|
|
36
|
+
get reachRadii(): readonly number[];
|
|
37
|
+
private _navigationPlugin;
|
|
38
|
+
private _recastCrowd;
|
|
39
|
+
private _transforms;
|
|
40
|
+
private _agents;
|
|
41
|
+
private _reachRadii;
|
|
42
|
+
/**
|
|
43
|
+
* true when a destination is active for an agent and notifier hasn't been notified of reach
|
|
44
|
+
*/
|
|
45
|
+
private _agentDestinationArmed;
|
|
46
|
+
/**
|
|
47
|
+
* agent current target
|
|
48
|
+
*/
|
|
49
|
+
private _agentDestination;
|
|
50
|
+
/**
|
|
51
|
+
* Link to the scene is kept to unregister the crowd from the scene
|
|
52
|
+
*/
|
|
53
|
+
private _scene;
|
|
54
|
+
private _engine;
|
|
55
|
+
/**
|
|
56
|
+
* Observer for crowd updates
|
|
57
|
+
*/
|
|
58
|
+
private _onBeforeAnimationsObserver;
|
|
59
|
+
/**
|
|
60
|
+
* Fires each time an agent is in reach radius of its destination
|
|
61
|
+
*/
|
|
62
|
+
onReachTargetObservable: Observable<{
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
*/
|
|
66
|
+
agentIndex: number;
|
|
67
|
+
/**
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
destination: Vector3;
|
|
71
|
+
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Constructor
|
|
74
|
+
* @param plugin recastJS plugin
|
|
75
|
+
* @param maxAgents the maximum agent count in the crowd
|
|
76
|
+
* @param maxAgentRadius the maximum radius an agent can have
|
|
77
|
+
* @param scene to attach the crowd to
|
|
78
|
+
* @returns the crowd you can add agents to
|
|
79
|
+
*/
|
|
80
|
+
constructor(plugin: RecastNavigationJSPluginV2, maxAgents: number, maxAgentRadius: number, scene: Scene);
|
|
81
|
+
/**
|
|
82
|
+
* Add a new agent to the crowd with the specified parameter a corresponding transformNode.
|
|
83
|
+
* You can attach anything to that node. The node position is updated in the scene update tick.
|
|
84
|
+
* @param pos world position that will be constrained by the navigation mesh
|
|
85
|
+
* @param parameters agent parameters
|
|
86
|
+
* @param transform hooked to the agent that will be update by the scene
|
|
87
|
+
* @returns agent index
|
|
88
|
+
*/
|
|
89
|
+
addAgent(pos: IVector3Like, parameters: IAgentParametersV2, transform: TransformNode): number;
|
|
90
|
+
/**
|
|
91
|
+
* Returns the agent position in world space
|
|
92
|
+
* @param index agent index returned by addAgent
|
|
93
|
+
* @returns world space position
|
|
94
|
+
*/
|
|
95
|
+
getAgentPosition(index: number): Vector3;
|
|
96
|
+
/**
|
|
97
|
+
* Returns the agent position result in world space
|
|
98
|
+
* @param index agent index returned by addAgent
|
|
99
|
+
* @param result output world space position
|
|
100
|
+
*/
|
|
101
|
+
getAgentPositionToRef(index: number, result: Vector3): void;
|
|
102
|
+
/**
|
|
103
|
+
* Returns the agent velocity in world space
|
|
104
|
+
* @param index agent index returned by addAgent
|
|
105
|
+
* @returns world space velocity
|
|
106
|
+
*/
|
|
107
|
+
getAgentVelocity(index: number): Vector3;
|
|
108
|
+
/**
|
|
109
|
+
* Returns the agent velocity result in world space
|
|
110
|
+
* @param index agent index returned by addAgent
|
|
111
|
+
* @param result output world space velocity
|
|
112
|
+
*/
|
|
113
|
+
getAgentVelocityToRef(index: number, result: Vector3): void;
|
|
114
|
+
/**
|
|
115
|
+
* Returns the agent next target point on the path
|
|
116
|
+
* @param index agent index returned by addAgent
|
|
117
|
+
* @returns world space position
|
|
118
|
+
*/
|
|
119
|
+
getAgentNextTargetPath(index: number): Vector3;
|
|
120
|
+
/**
|
|
121
|
+
* Returns the agent next target point on the path
|
|
122
|
+
* @param index agent index returned by addAgent
|
|
123
|
+
* @param result output world space position
|
|
124
|
+
*/
|
|
125
|
+
getAgentNextTargetPathToRef(index: number, result: Vector3): void;
|
|
126
|
+
/**
|
|
127
|
+
* Gets the agent state
|
|
128
|
+
* @param index agent index returned by addAgent
|
|
129
|
+
* @returns agent state, 0 = DT_CROWDAGENT_STATE_INVALID, 1 = DT_CROWDAGENT_STATE_WALKING, 2 = DT_CROWDAGENT_STATE_OFFMESH
|
|
130
|
+
*/
|
|
131
|
+
getAgentState(index: number): number;
|
|
132
|
+
/**
|
|
133
|
+
* returns true if the agent in over an off mesh link connection
|
|
134
|
+
* @param index agent index returned by addAgent
|
|
135
|
+
* @returns true if over an off mesh link connection
|
|
136
|
+
*/
|
|
137
|
+
overOffmeshConnection(index: number): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
|
|
140
|
+
* @param index agent index returned by addAgent
|
|
141
|
+
* @param destination targeted world position
|
|
142
|
+
*/
|
|
143
|
+
agentGoto(index: number, destination: IVector3Like): void;
|
|
144
|
+
/**
|
|
145
|
+
* Teleport the agent to a new position
|
|
146
|
+
* @param index agent index returned by addAgent
|
|
147
|
+
* @param destination targeted world position
|
|
148
|
+
*/
|
|
149
|
+
agentTeleport(index: number, destination: IVector3Like): void;
|
|
150
|
+
/**
|
|
151
|
+
* Update agent parameters
|
|
152
|
+
* @param index agent index returned by addAgent
|
|
153
|
+
* @param parameters agent parameters
|
|
154
|
+
*/
|
|
155
|
+
updateAgentParameters(index: number, parameters: IAgentParametersV2): void;
|
|
156
|
+
/**
|
|
157
|
+
* remove a particular agent previously created
|
|
158
|
+
* @param index agent index returned by addAgent
|
|
159
|
+
*/
|
|
160
|
+
removeAgent(index: number): void;
|
|
161
|
+
/**
|
|
162
|
+
* get the list of all agents attached to this crowd
|
|
163
|
+
* @returns list of agent indices
|
|
164
|
+
*/
|
|
165
|
+
getAgents(): number[];
|
|
166
|
+
/**
|
|
167
|
+
* Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
|
|
168
|
+
* @param deltaTime in seconds
|
|
169
|
+
*/
|
|
170
|
+
update(deltaTime: number): void;
|
|
171
|
+
/**
|
|
172
|
+
* Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
|
|
173
|
+
* The queries will try to find a solution within those bounds
|
|
174
|
+
* default is (1,1,1)
|
|
175
|
+
* @param extent x,y,z value that define the extent around the queries point of reference
|
|
176
|
+
*/
|
|
177
|
+
setDefaultQueryExtent(extent: IVector3Like): void;
|
|
178
|
+
/**
|
|
179
|
+
* Get the Bounding box extent specified by setDefaultQueryExtent
|
|
180
|
+
* @returns the box extent values
|
|
181
|
+
*/
|
|
182
|
+
getDefaultQueryExtent(): Vector3;
|
|
183
|
+
/**
|
|
184
|
+
* Get the Bounding box extent result specified by setDefaultQueryExtent
|
|
185
|
+
* @param result output the box extent values
|
|
186
|
+
*/
|
|
187
|
+
getDefaultQueryExtentToRef(result: Vector3): void;
|
|
188
|
+
/**
|
|
189
|
+
* Get the next corner points composing the path (max 4 points)
|
|
190
|
+
* @param index agent index returned by addAgent
|
|
191
|
+
* @returns array containing world position composing the path
|
|
192
|
+
*/
|
|
193
|
+
getCorners(index: number): Vector3[];
|
|
194
|
+
/**
|
|
195
|
+
* Release all resources
|
|
196
|
+
*/
|
|
197
|
+
dispose(): void;
|
|
198
|
+
}
|