@onerjs/addons 8.27.1 → 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.
Files changed (82) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +1 -0
  3. package/index.js.map +1 -1
  4. package/navigation/common/config.d.ts +35 -0
  5. package/navigation/common/config.js +61 -0
  6. package/navigation/common/config.js.map +1 -0
  7. package/navigation/common/convert.d.ts +8 -0
  8. package/navigation/common/convert.js +22 -0
  9. package/navigation/common/convert.js.map +1 -0
  10. package/navigation/common/getters.d.ts +15 -0
  11. package/navigation/common/getters.js +76 -0
  12. package/navigation/common/getters.js.map +1 -0
  13. package/navigation/common/index.d.ts +6 -0
  14. package/navigation/common/index.js +7 -0
  15. package/navigation/common/index.js.map +1 -0
  16. package/navigation/common/smooth-path.d.ts +32 -0
  17. package/navigation/common/smooth-path.js +340 -0
  18. package/navigation/common/smooth-path.js.map +1 -0
  19. package/navigation/common/tile-cache.d.ts +15 -0
  20. package/navigation/common/tile-cache.js +32 -0
  21. package/navigation/common/tile-cache.js.map +1 -0
  22. package/navigation/common/utils.d.ts +17 -0
  23. package/navigation/common/utils.js +66 -0
  24. package/navigation/common/utils.js.map +1 -0
  25. package/navigation/debug/NavigationDebugger.d.ts +248 -0
  26. package/navigation/debug/NavigationDebugger.js +587 -0
  27. package/navigation/debug/NavigationDebugger.js.map +1 -0
  28. package/navigation/debug/index.d.ts +2 -0
  29. package/navigation/debug/index.js +3 -0
  30. package/navigation/debug/index.js.map +1 -0
  31. package/navigation/debug/simple-debug.d.ts +13 -0
  32. package/navigation/debug/simple-debug.js +23 -0
  33. package/navigation/debug/simple-debug.js.map +1 -0
  34. package/navigation/factory/common.d.ts +20 -0
  35. package/navigation/factory/common.js +80 -0
  36. package/navigation/factory/common.js.map +1 -0
  37. package/navigation/factory/factory.single-thread.d.ts +7 -0
  38. package/navigation/factory/factory.single-thread.js +15 -0
  39. package/navigation/factory/factory.single-thread.js.map +1 -0
  40. package/navigation/factory/factory.wasm.d.ts +7 -0
  41. package/navigation/factory/factory.wasm.js +15 -0
  42. package/navigation/factory/factory.wasm.js.map +1 -0
  43. package/navigation/factory/factory.worker.d.ts +9 -0
  44. package/navigation/factory/factory.worker.js +40 -0
  45. package/navigation/factory/factory.worker.js.map +1 -0
  46. package/navigation/factory/index.d.ts +2 -0
  47. package/navigation/factory/index.js +4 -0
  48. package/navigation/factory/index.js.map +1 -0
  49. package/navigation/generator/generator.common.d.ts +25 -0
  50. package/navigation/generator/generator.common.js +40 -0
  51. package/navigation/generator/generator.common.js.map +1 -0
  52. package/navigation/generator/generator.single-thread.d.ts +20 -0
  53. package/navigation/generator/generator.single-thread.js +57 -0
  54. package/navigation/generator/generator.single-thread.js.map +1 -0
  55. package/navigation/generator/generator.worker.d.ts +29 -0
  56. package/navigation/generator/generator.worker.js +47 -0
  57. package/navigation/generator/generator.worker.js.map +1 -0
  58. package/navigation/generator/index.d.ts +3 -0
  59. package/navigation/generator/index.js +5 -0
  60. package/navigation/generator/index.js.map +1 -0
  61. package/navigation/generator/injection.d.ts +6 -0
  62. package/navigation/generator/injection.js +16 -0
  63. package/navigation/generator/injection.js.map +1 -0
  64. package/navigation/index.d.ts +5 -0
  65. package/navigation/index.js +7 -0
  66. package/navigation/index.js.map +1 -0
  67. package/navigation/plugin/RecastJSCrowd.d.ts +198 -0
  68. package/navigation/plugin/RecastJSCrowd.js +359 -0
  69. package/navigation/plugin/RecastJSCrowd.js.map +1 -0
  70. package/navigation/plugin/RecastNavigationJSPlugin.d.ts +396 -0
  71. package/navigation/plugin/RecastNavigationJSPlugin.js +445 -0
  72. package/navigation/plugin/RecastNavigationJSPlugin.js.map +1 -0
  73. package/navigation/plugin/index.d.ts +1 -0
  74. package/navigation/plugin/index.js +2 -0
  75. package/navigation/plugin/index.js.map +1 -0
  76. package/navigation/types.d.ts +199 -0
  77. package/navigation/types.js +11 -0
  78. package/navigation/types.js.map +1 -0
  79. package/navigation/worker/navmesh-worker.d.ts +4 -0
  80. package/navigation/worker/navmesh-worker.js +63 -0
  81. package/navigation/worker/navmesh-worker.js.map +1 -0
  82. package/package.json +2 -2
@@ -0,0 +1,199 @@
1
+ import type { NavMesh, NavMeshQuery, TileCache, TileCacheMeshProcess } from "@recast-navigation/core";
2
+ import type { SoloNavMeshGeneratorIntermediates, TileCacheGeneratorIntermediates, TiledNavMeshGeneratorIntermediates } from "@recast-navigation/generators";
3
+ import type { IVector3Like } from "@onerjs/core/Maths/math.like.js";
4
+ import type { Vector3 } from "@onerjs/core/Maths/math.vector.js";
5
+ import type { IAgentParameters, INavMeshParameters } from "@onerjs/core/Navigation/INavigationEngine.js";
6
+ import type { Nullable } from "@onerjs/core/types.js";
7
+ /**
8
+ * Recast injection type
9
+ */
10
+ export type RecastInjection = any;
11
+ /**
12
+ * Off-mesh connection data
13
+ */
14
+ export interface IOffMeshConnection {
15
+ /**
16
+ * The start position of the off-mesh connection.
17
+ */
18
+ startPosition: IVector3Like;
19
+ /**
20
+ * The end position of the off-mesh connection.
21
+ */
22
+ endPosition: IVector3Like;
23
+ /**
24
+ * The radius of the off-mesh connection.
25
+ */
26
+ radius: number;
27
+ /**
28
+ * The type of the off-mesh connection.
29
+ */
30
+ bidirectional: boolean;
31
+ /**
32
+ * The area type of the off-mesh connection.
33
+ */
34
+ area: number;
35
+ /**
36
+ * The flags of the off-mesh connection.
37
+ */
38
+ flags: number;
39
+ /**
40
+ * The user ID of the off-mesh connection.
41
+ * @remarks This can be used to associate the off-mesh connection with a specific user
42
+ */
43
+ userId?: number;
44
+ }
45
+ /**
46
+ * Result of a navigation mesh creation.
47
+ */
48
+ export type CreateNavMeshResult = Nullable<{
49
+ /**
50
+ * Navigation mesh
51
+ */
52
+ navMesh: NavMesh;
53
+ /**
54
+ * Navigation mesh query
55
+ */
56
+ navMeshQuery: NavMeshQuery;
57
+ /**
58
+ * Intermediates generated during the NavMesh creation process.
59
+ * @remarks This is only available if the `keepIntermediates` parameter is set to true in the `INavMeshParametersV2`.
60
+ * It can be used for debugging or visualization purposes.
61
+ */
62
+ intermediates?: GeneratorIntermediates;
63
+ /**
64
+ * Tile cache generated during the NavMesh creation process.
65
+ * @remarks This is only available if the `maxObstacles` parameter is set to a value greater than 0 in the `INavMeshParametersV2`.
66
+ * It can be used for obstacle avoidance and dynamic navigation mesh updates.
67
+ * @see {@link INavMeshParametersV2}
68
+ */
69
+ tileCache?: TileCache;
70
+ }>;
71
+ /**
72
+ * Agent parameters
73
+ * For actual limits and default values check the recast-navigation-js docs.
74
+ * @see https://docs.recast-navigation-js.isaacmason.com/types/index.CrowdAgentParams.html
75
+ */
76
+ export interface IAgentParametersV2 extends IAgentParameters {
77
+ /**
78
+ * Flags that impact steering behavior.
79
+ */
80
+ updateFlags: number;
81
+ /**
82
+ * The index of the avoidance configuration to use for the agent. [Limits: 0 to #DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS inclusive]
83
+ */
84
+ obstacleAvoidanceType: number;
85
+ /**
86
+ * The index of the query filter used by this agent.
87
+ */
88
+ queryFilterType: number;
89
+ /**
90
+ * User defined data attached to the agent.
91
+ */
92
+ userData: unknown;
93
+ }
94
+ /**
95
+ * NavMesh parameters
96
+ * For actual limits and default values check the recast-navigation-js docs.
97
+ * @see https://docs.recast-navigation-js.isaacmason.com/types/index.RecastConfig.html
98
+ */
99
+ export interface INavMeshParametersV2 extends INavMeshParameters {
100
+ /**
101
+ * OffMeshConnections - Teleports
102
+ */
103
+ offMeshConnections?: IOffMeshConnection[];
104
+ /**
105
+ * Whether to keep intermediate navigation mesh data for debug visualization. Default is false.
106
+ */
107
+ keepIntermediates?: boolean;
108
+ /**
109
+ * The maximum number of obstacles that can be added to the navigation mesh. Default is 32.
110
+ * If this value is greater then 0, the navigation mesh will be generated with a tile cache.
111
+ */
112
+ maxObstacles?: number;
113
+ /**
114
+ * The size of each tile in the tiled navigation mesh. Default is 32.
115
+ */
116
+ expectedLayersPerTile?: number;
117
+ /**
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
+ */
120
+ tileCacheMeshProcess?: TileCacheMeshProcess;
121
+ }
122
+ /**
123
+ * Result of a steer target computation.
124
+ */
125
+ export type SteerTargetResult = {
126
+ /**
127
+ * Indicates whether the steering target computation was successful.
128
+ */
129
+ success: false;
130
+ } | {
131
+ /**
132
+ * Indicates whether the steering target computation was successful.
133
+ */
134
+ success: true;
135
+ /**
136
+ * The position to steer towards.
137
+ */
138
+ steerPos: Vector3;
139
+ /**
140
+ * The flag indicating the type of steering position.
141
+ */
142
+ steerPosFlag: number;
143
+ /**
144
+ * The reference to the polygon that the steering position is associated with.
145
+ */
146
+ steerPosRef: number;
147
+ /**
148
+ * The points that make up the path to the steering position.
149
+ */
150
+ points: Vector3[];
151
+ };
152
+ /**
153
+ * Error types for path computation.
154
+ */
155
+ export declare const ComputePathError: {
156
+ START_NEAREST_POLY_FAILED: string;
157
+ END_NEAREST_POLY_FAILED: string;
158
+ FIND_PATH_FAILED: string;
159
+ NO_POLYGON_PATH_FOUND: string;
160
+ NO_CLOSEST_POINT_ON_LAST_POLYGON_FOUND: string;
161
+ };
162
+ export type ComputePathErrorType = (typeof ComputePathError)[keyof typeof ComputePathError];
163
+ /**
164
+ * Result of a path computation.
165
+ */
166
+ export type ComputePathResult = {
167
+ /**
168
+ * Indicates whether the path computation was successful.
169
+ */
170
+ success: boolean;
171
+ /**
172
+ * The error message if the path computation failed.
173
+ */
174
+ error?: {
175
+ /**
176
+ * A descriptive error message.
177
+ */
178
+ name?: string;
179
+ /**
180
+ * The type of error that occurred during path computation.
181
+ * @remarks This will be one of the values from `ComputePathError`
182
+ */
183
+ type?: ComputePathErrorType;
184
+ /**
185
+ * Statusring describing the error.
186
+ */
187
+ status?: number;
188
+ };
189
+ /**
190
+ * The computed path as an array of Vector3 points.
191
+ */
192
+ path: IVector3Like[];
193
+ };
194
+ /**
195
+ * Intermediates generated during the NavMesh creation process.
196
+ * @remarks This is only available if the `keepIntermediates` parameter is set to true in the `INavMeshParametersV2`.
197
+ * It can be used for debugging or visualization purposes.
198
+ */
199
+ export type GeneratorIntermediates = SoloNavMeshGeneratorIntermediates | TiledNavMeshGeneratorIntermediates | TileCacheGeneratorIntermediates | null;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Error types for path computation.
3
+ */
4
+ export const ComputePathError = {
5
+ START_NEAREST_POLY_FAILED: "START_NEAREST_POLY_FAILED",
6
+ END_NEAREST_POLY_FAILED: "END_NEAREST_POLY_FAILED",
7
+ FIND_PATH_FAILED: "FIND_PATH_FAILED",
8
+ NO_POLYGON_PATH_FOUND: "NO_POLYGON_PATH_FOUND",
9
+ NO_CLOSEST_POINT_ON_LAST_POLYGON_FOUND: "NO_CLOSEST_POINT_ON_LAST_POLYGON_FOUND",
10
+ };
11
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../dev/addons/src/navigation/types.ts"],"names":[],"mappings":"AAiKA;;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`.\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\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"]}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Generates a navigation mesh in a web worker.
3
+ */
4
+ export declare function GenerateNavMeshWorker(): void;
@@ -0,0 +1,63 @@
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 { exportNavMesh, exportTileCache, init as initRecast } from "@recast-navigation/core";
8
+ import { generateSoloNavMesh, generateTileCache, generateTiledNavMesh } from "@recast-navigation/generators";
9
+ import { CreateSoloNavMeshConfig, CreateTileCacheNavMeshConfig } from "../common/config.js";
10
+ /**
11
+ * Generates a navigation mesh in a web worker.
12
+ */
13
+ export function GenerateNavMeshWorker() {
14
+ self.onmessage = async (event) => {
15
+ if (!event.data || !event.data.positions || !event.data.indices || !event.data.parameters) {
16
+ self.postMessage({ success: false, error: "Invalid input data." });
17
+ return;
18
+ }
19
+ await initRecast();
20
+ const { positions, indices, parameters } = event.data;
21
+ // Decide on the type of nav mesh to generate based on parameters
22
+ // If tileSize is set, we will generate a tiled nav mesh
23
+ // If maxObstacles is set, we will generate a tile cache nav mesh
24
+ // Otherwise, we will generate a solo nav mesh
25
+ const needsTileCache = (parameters.maxObstacles ?? 0) > 0;
26
+ const needsTiledNavMesh = "tileSize" in parameters && (parameters.tileSize ?? 0) > 0;
27
+ const config = needsTileCache ? CreateTileCacheNavMeshConfig(parameters) : needsTileCache ? CreateTileCacheNavMeshConfig(parameters) : CreateSoloNavMeshConfig(parameters);
28
+ const result = needsTiledNavMesh
29
+ ? needsTileCache
30
+ ? generateTileCache(positions, indices, config)
31
+ : generateTiledNavMesh(positions, indices, config)
32
+ : generateSoloNavMesh(positions, indices, config);
33
+ if (!result.success || !result.navMesh) {
34
+ self.postMessage(result);
35
+ return;
36
+ }
37
+ // prepare the transferables
38
+ const transferables = [];
39
+ const message = { navMesh: undefined, tileCache: undefined };
40
+ // If tile cache is present, serialize it and add to the message
41
+ if ("tileCache" in result && result.tileCache) {
42
+ if (result.tileCache) {
43
+ const tileCacheExport = exportTileCache(result.navMesh, result.tileCache);
44
+ message.tileCache = tileCacheExport;
45
+ transferables.push(tileCacheExport.buffer);
46
+ }
47
+ }
48
+ else {
49
+ // otherwise send the NavMesh
50
+ const navMeshExport = exportNavMesh(result.navMesh);
51
+ message.navMesh = navMeshExport;
52
+ transferables.push(navMeshExport.buffer);
53
+ }
54
+ // send tansferable message
55
+ self.postMessage(message, { transfer: transferables });
56
+ // clean up
57
+ result.navMesh?.destroy();
58
+ if ("tileCache" in result && result.tileCache) {
59
+ result.tileCache.destroy();
60
+ }
61
+ };
62
+ }
63
+ //# sourceMappingURL=navmesh-worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navmesh-worker.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/worker/navmesh-worker.ts"],"names":[],"mappings":"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","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 type { SoloNavMeshGeneratorConfig, TileCacheGeneratorConfig, TiledNavMeshGeneratorConfig } from \"@recast-navigation/generators\";\nimport { generateSoloNavMesh, generateTileCache, generateTiledNavMesh } 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 tansferable 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": "@onerjs/addons",
3
- "version": "8.27.1",
3
+ "version": "8.27.2",
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.1",
21
+ "@onerjs/core": "^8.27.2",
22
22
  "@dev/addons": "^1.0.0",
23
23
  "@dev/build-tools": "^1.0.0"
24
24
  },