@onerjs/addons 8.27.2 → 8.27.3
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/msdfText/paragraphOptions.d.ts +15 -0
- package/msdfText/paragraphOptions.js.map +1 -1
- package/msdfText/sdf/paragraph.js +1 -1
- package/msdfText/sdf/paragraph.js.map +1 -1
- package/navigation/factory/index.d.ts +0 -1
- package/navigation/factory/index.js +0 -1
- package/navigation/factory/index.js.map +1 -1
- package/navigation/plugin/RecastNavigationJSPlugin.d.ts +26 -3
- package/navigation/plugin/RecastNavigationJSPlugin.js +52 -15
- package/navigation/plugin/RecastNavigationJSPlugin.js.map +1 -1
- package/navigation/types.d.ts +1 -1
- package/navigation/types.js.map +1 -1
- package/package.json +2 -2
- package/navigation/factory/factory.wasm.d.ts +0 -7
- package/navigation/factory/factory.wasm.js +0 -15
- package/navigation/factory/factory.wasm.js.map +0 -1
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import type { IVector2Like } from "@onerjs/core/Maths/math.like.js";
|
|
2
|
+
import type { SdfTextLine } from "./sdf/line.js";
|
|
3
|
+
import type { SdfGlyph } from "./sdf/glyph.js";
|
|
4
|
+
export interface ISdfTextParagraphMetrics {
|
|
5
|
+
/** @internal */
|
|
6
|
+
readonly paragraph: string;
|
|
7
|
+
/** @internal */
|
|
8
|
+
readonly lines: SdfTextLine[];
|
|
9
|
+
/** @internal */
|
|
10
|
+
readonly width: number;
|
|
11
|
+
/** @internal */
|
|
12
|
+
readonly height: number;
|
|
13
|
+
/** @internal */
|
|
14
|
+
readonly glyphs: SdfGlyph[];
|
|
15
|
+
}
|
|
2
16
|
/** @internal */
|
|
3
17
|
export type ParagraphOptions = {
|
|
4
18
|
maxWidth: number;
|
|
@@ -8,6 +22,7 @@ export type ParagraphOptions = {
|
|
|
8
22
|
whiteSpace: "pre-line";
|
|
9
23
|
textAlign: "left" | "right" | "center";
|
|
10
24
|
translate: IVector2Like | undefined;
|
|
25
|
+
customLayoutEngine?: (text: string, options: ParagraphOptions) => ISdfTextParagraphMetrics;
|
|
11
26
|
};
|
|
12
27
|
/** @internal */
|
|
13
28
|
export declare const DefaultParagraphOptions: ParagraphOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paragraphOptions.js","sourceRoot":"","sources":["../../../../dev/addons/src/msdfText/paragraphOptions.ts"],"names":[],"mappings":"AAAA,wCAAwC;
|
|
1
|
+
{"version":3,"file":"paragraphOptions.js","sourceRoot":"","sources":["../../../../dev/addons/src/msdfText/paragraphOptions.ts"],"names":[],"mappings":"AAAA,wCAAwC;AA+BxC,gBAAgB;AAChB,MAAM,CAAC,MAAM,uBAAuB,GAAqB;IACrD,QAAQ,EAAE,QAAQ;IAClB,UAAU,EAAE,CAAC;IACb,aAAa,EAAE,CAAC;IAChB,OAAO,EAAE,CAAC;IACV,UAAU,EAAE,UAAU;IACtB,SAAS,EAAE,QAAQ;IACnB,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE;CAClC,CAAC","sourcesContent":["/* eslint-disable jsdoc/require-jsdoc */\r\n\r\nimport type { IVector2Like } from \"core/Maths/math.like\";\r\nimport type { SdfTextLine } from \"./sdf/line\";\r\nimport type { SdfGlyph } from \"./sdf/glyph\";\r\n\r\nexport interface ISdfTextParagraphMetrics {\r\n /** @internal */\r\n readonly paragraph: string;\r\n /** @internal */\r\n readonly lines: SdfTextLine[];\r\n /** @internal */\r\n readonly width: number;\r\n /** @internal */\r\n readonly height: number;\r\n /** @internal */\r\n readonly glyphs: SdfGlyph[];\r\n}\r\n\r\n/** @internal */\r\nexport type ParagraphOptions = {\r\n maxWidth: number;\r\n lineHeight: number;\r\n letterSpacing: number;\r\n tabSize: number;\r\n whiteSpace: /* 'normal' | 'nowrap' | 'pre' | 'pre-wrap' | */ \"pre-line\" /* | 'break-spaces'*/;\r\n textAlign: \"left\" | \"right\" | \"center\" /* | 'justify'*/;\r\n translate: IVector2Like | undefined;\r\n customLayoutEngine?: (text: string, options: ParagraphOptions) => ISdfTextParagraphMetrics;\r\n};\r\n\r\n/** @internal */\r\nexport const DefaultParagraphOptions: ParagraphOptions = {\r\n maxWidth: Infinity,\r\n lineHeight: 1,\r\n letterSpacing: 1,\r\n tabSize: 4,\r\n whiteSpace: \"pre-line\",\r\n textAlign: \"center\",\r\n translate: { x: -0.5, y: -0.5 },\r\n};\r\n"]}
|
|
@@ -8,7 +8,7 @@ export class SdfTextParagraph {
|
|
|
8
8
|
this.text = text;
|
|
9
9
|
this.fontAsset = fontAsset;
|
|
10
10
|
this.options = { ...DefaultParagraphOptions, ...options };
|
|
11
|
-
const { paragraph, lines, glyphs, width, height } = this._computeMetrics(text);
|
|
11
|
+
const { paragraph, lines, glyphs, width, height } = this.options.customLayoutEngine ? this.options.customLayoutEngine(text, this.options) : this._computeMetrics(text);
|
|
12
12
|
this.paragraph = paragraph;
|
|
13
13
|
this.lines = lines;
|
|
14
14
|
this.glyphs = glyphs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paragraph.js","sourceRoot":"","sources":["../../../../../dev/addons/src/msdfText/sdf/paragraph.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAyB,MAAM,qBAAqB,CAAC;AAKrF,gBAAgB;AAChB,MAAM,OAAO,gBAAgB;IAGzB,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;IAC5E,CAAC;IAQD,YACoB,IAAY,EACZ,SAAoB,EACpC,OAAmC;QAFnB,SAAI,GAAJ,IAAI,CAAQ;QACZ,cAAS,GAAT,SAAS,CAAW;QAGpC,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,uBAAuB,EAAE,GAAG,OAAO,EAAE,CAAC;QAE1D,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,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C,CAAC;YACD,eAAe,EAAE,CAAC;QACtB,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["/* eslint-disable babylonjs/available */\r\n/* eslint-disable jsdoc/require-jsdoc */\r\nimport type { FontAsset } from \"../fontAsset\";\r\nimport { DefaultParagraphOptions, type ParagraphOptions } from \"../paragraphOptions\";\r\nimport type { BMFontChar } from \"./bmFont\";\r\nimport type { SdfGlyph } from \"./glyph\";\r\nimport type { SdfTextLine } from \"./line\";\r\n\r\n/** @internal */\r\nexport class SdfTextParagraph {\r\n public readonly options: ParagraphOptions;\r\n\r\n get lineHeight() {\r\n return this.fontAsset._font.common.lineHeight * this.options.lineHeight;\r\n }\r\n\r\n readonly paragraph;\r\n readonly lines;\r\n readonly width;\r\n readonly height;\r\n readonly glyphs;\r\n\r\n constructor(\r\n public readonly text: string,\r\n public readonly fontAsset: FontAsset,\r\n options?: Partial<ParagraphOptions>\r\n ) {\r\n this.options = { ...DefaultParagraphOptions, ...options };\r\n\r\n const { paragraph, lines, glyphs, width, height } = this._computeMetrics(text);\r\n\r\n this.paragraph = paragraph;\r\n this.lines = lines;\r\n this.glyphs = glyphs;\r\n this.width = width;\r\n this.height = height;\r\n }\r\n\r\n private _computeMetrics(text: string) {\r\n const collapsed = this._collapse(text);\r\n const breaked = this._breakLines(collapsed);\r\n const trimmed = breaked.map((line) => line.trim());\r\n\r\n const lines: SdfTextLine[] = [];\r\n for (const line of trimmed) {\r\n lines.push(...this._wrap(line, lines.length));\r\n }\r\n\r\n const width = Math.max(...lines.map((line) => line.width));\r\n const height = this.lineHeight * lines.length;\r\n\r\n if (this.options.textAlign !== \"left\" || this.options.translate) {\r\n lines.forEach((line) => {\r\n const anchor = (() => {\r\n switch (this.options.textAlign) {\r\n case \"right\":\r\n return width - line.width;\r\n case \"center\":\r\n return (width - line.width) / 2;\r\n case \"left\":\r\n default:\r\n return 0;\r\n }\r\n })();\r\n\r\n const x = this.options.translate ? this.options.translate.x * width : 0;\r\n const y = this.options.translate ? this.options.translate.y * height : 0;\r\n for (const glyph of line.glyphs) {\r\n glyph.x += anchor;\r\n glyph.x += x;\r\n glyph.y += y;\r\n }\r\n });\r\n }\r\n\r\n const glyphs = lines.flatMap((line) => line.glyphs);\r\n\r\n return {\r\n paragraph: trimmed.join(\"\\n\"),\r\n lines,\r\n glyphs,\r\n width,\r\n height,\r\n };\r\n }\r\n\r\n private _breakLines(text: string) {\r\n return text.split(\"\\n\");\r\n }\r\n\r\n private _collapse(text: string) {\r\n return text.replace(/\\t/g, \" \".repeat(this.options.tabSize)).replace(/ +/g, \" \");\r\n }\r\n\r\n private _wrap(text: string, lineOffset = 0) {\r\n const lines = new Array<SdfTextLine>();\r\n\r\n let currentLine = lineOffset;\r\n let currentGlyphs = new Array<SdfGlyph>();\r\n let currentCursor = 0;\r\n let currentWidth = 0;\r\n let lastChar: BMFontChar | undefined;\r\n let start = 0;\r\n let end = start;\r\n\r\n const pushCurrentLine = () => {\r\n lines.push({\r\n text: text.slice(start, end),\r\n glyphs: currentGlyphs,\r\n start: start,\r\n end: end,\r\n width: currentWidth,\r\n });\r\n };\r\n\r\n while (end < text.length) {\r\n const i = end;\r\n const charCode = text.charCodeAt(i);\r\n const char = this.fontAsset._getChar(charCode);\r\n const charWidth = char.width;\r\n const kerning = lastChar ? this.fontAsset._getKerning(lastChar.id, char.id) : 0;\r\n\r\n currentCursor += kerning;\r\n const newWidth = currentCursor + charWidth;\r\n const cursorProgress = char.xadvance + this.options.letterSpacing;\r\n const nextPosition = currentCursor + cursorProgress;\r\n\r\n const shouldBreak = nextPosition > this.options.maxWidth || newWidth > this.options.maxWidth;\r\n\r\n if (shouldBreak) {\r\n pushCurrentLine();\r\n\r\n currentLine++;\r\n lastChar = undefined;\r\n currentCursor = 0;\r\n currentWidth = 0;\r\n start = end;\r\n end = start + 1;\r\n currentGlyphs = [];\r\n }\r\n\r\n const x = currentCursor;\r\n const y = currentLine * this.lineHeight;\r\n\r\n currentGlyphs.push({\r\n char,\r\n line: currentLine,\r\n position: currentGlyphs.length,\r\n x: x,\r\n y: y,\r\n });\r\n\r\n if (!shouldBreak) {\r\n lastChar = char;\r\n currentCursor = nextPosition;\r\n currentWidth = newWidth;\r\n end++;\r\n } else {\r\n currentCursor = cursorProgress;\r\n }\r\n }\r\n\r\n if (currentGlyphs.length > 0) {\r\n if (lastChar) {\r\n // currentWidth += lastChar.xadvance;\r\n }\r\n pushCurrentLine();\r\n }\r\n\r\n return lines;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"paragraph.js","sourceRoot":"","sources":["../../../../../dev/addons/src/msdfText/sdf/paragraph.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAyB,MAAM,qBAAqB,CAAC;AAKrF,gBAAgB;AAChB,MAAM,OAAO,gBAAgB;IAGzB,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;IAC5E,CAAC;IAQD,YACoB,IAAY,EACZ,SAAoB,EACpC,OAAmC;QAFnB,SAAI,GAAJ,IAAI,CAAQ;QACZ,cAAS,GAAT,SAAS,CAAW;QAGpC,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,uBAAuB,EAAE,GAAG,OAAO,EAAE,CAAC;QAE1D,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAEvK,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG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CAAC;YAEpD,MAAM,WAAW,GAAG,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;YAE7F,IAAI,WAAW,EAAE,CAAC;gBACd,eAAe,EAAE,CAAC;gBAElB,WAAW,EAAE,CAAC;gBACd,QAAQ,GAAG,SAAS,CAAC;gBACrB,aAAa,GAAG,CAAC,CAAC;gBAClB,YAAY,GAAG,CAAC,CAAC;gBACjB,KAAK,GAAG,GAAG,CAAC;gBACZ,GAAG,GAAG,KAAK,GAAG,CAAC,CAAC;gBAChB,aAAa,GAAG,EAAE,CAAC;YACvB,CAAC;YAED,MAAM,CAAC,GAAG,aAAa,CAAC;YACxB,MAAM,CAAC,GAAG,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC;YAExC,aAAa,CAAC,IAAI,CAAC;gBACf,IAAI;gBACJ,IAAI,EAAE,WAAW;gBACjB,QAAQ,EAAE,aAAa,CAAC,MAAM;gBAC9B,CAAC,EAAE,CAAC;gBACJ,CAAC,EAAE,CAAC;aACP,CAAC,CAAC;YAEH,IAAI,CAAC,WAAW,EAAE,CAAC;gBACf,QAAQ,GAAG,IAAI,CAAC;gBAChB,aAAa,GAAG,YAAY,CAAC;gBAC7B,YAAY,GAAG,QAAQ,CAAC;gBACxB,GAAG,EAAE,CAAC;YACV,CAAC;iBAAM,CAAC;gBACJ,aAAa,GAAG,cAAc,CAAC;YACnC,CAAC;QACL,CAAC;QAED,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,IAAI,QAAQ,EAAE,CAAC;gBACX,qCAAqC;YACzC,CAAC;YACD,eAAe,EAAE,CAAC;QACtB,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["/* eslint-disable babylonjs/available */\r\n/* eslint-disable jsdoc/require-jsdoc */\r\nimport type { FontAsset } from \"../fontAsset\";\r\nimport type { ISdfTextParagraphMetrics } from \"../paragraphOptions\";\r\nimport { DefaultParagraphOptions, type ParagraphOptions } from \"../paragraphOptions\";\r\nimport type { BMFontChar } from \"./bmFont\";\r\nimport type { SdfGlyph } from \"./glyph\";\r\nimport type { SdfTextLine } from \"./line\";\r\n\r\n/** @internal */\r\nexport class SdfTextParagraph {\r\n public readonly options: ParagraphOptions;\r\n\r\n get lineHeight() {\r\n return this.fontAsset._font.common.lineHeight * this.options.lineHeight;\r\n }\r\n\r\n readonly paragraph;\r\n readonly lines;\r\n readonly width;\r\n readonly height;\r\n readonly glyphs;\r\n\r\n constructor(\r\n public readonly text: string,\r\n public readonly fontAsset: FontAsset,\r\n options?: Partial<ParagraphOptions>\r\n ) {\r\n this.options = { ...DefaultParagraphOptions, ...options };\r\n\r\n const { paragraph, lines, glyphs, width, height } = this.options.customLayoutEngine ? this.options.customLayoutEngine(text, this.options) : this._computeMetrics(text);\r\n\r\n this.paragraph = paragraph;\r\n this.lines = lines;\r\n this.glyphs = glyphs;\r\n this.width = width;\r\n this.height = height;\r\n }\r\n\r\n private _computeMetrics(text: string): ISdfTextParagraphMetrics {\r\n const collapsed = this._collapse(text);\r\n const breaked = this._breakLines(collapsed);\r\n const trimmed = breaked.map((line) => line.trim());\r\n\r\n const lines: SdfTextLine[] = [];\r\n for (const line of trimmed) {\r\n lines.push(...this._wrap(line, lines.length));\r\n }\r\n\r\n const width = Math.max(...lines.map((line) => line.width));\r\n const height = this.lineHeight * lines.length;\r\n\r\n if (this.options.textAlign !== \"left\" || this.options.translate) {\r\n lines.forEach((line) => {\r\n const anchor = (() => {\r\n switch (this.options.textAlign) {\r\n case \"right\":\r\n return width - line.width;\r\n case \"center\":\r\n return (width - line.width) / 2;\r\n case \"left\":\r\n default:\r\n return 0;\r\n }\r\n })();\r\n\r\n const x = this.options.translate ? this.options.translate.x * width : 0;\r\n const y = this.options.translate ? this.options.translate.y * height : 0;\r\n for (const glyph of line.glyphs) {\r\n glyph.x += anchor;\r\n glyph.x += x;\r\n glyph.y += y;\r\n }\r\n });\r\n }\r\n\r\n const glyphs = lines.flatMap((line) => line.glyphs);\r\n\r\n return {\r\n paragraph: trimmed.join(\"\\n\"),\r\n lines,\r\n glyphs,\r\n width,\r\n height,\r\n };\r\n }\r\n\r\n private _breakLines(text: string) {\r\n return text.split(\"\\n\");\r\n }\r\n\r\n private _collapse(text: string) {\r\n return text.replace(/\\t/g, \" \".repeat(this.options.tabSize)).replace(/ +/g, \" \");\r\n }\r\n\r\n private _wrap(text: string, lineOffset = 0) {\r\n const lines = new Array<SdfTextLine>();\r\n\r\n let currentLine = lineOffset;\r\n let currentGlyphs = new Array<SdfGlyph>();\r\n let currentCursor = 0;\r\n let currentWidth = 0;\r\n let lastChar: BMFontChar | undefined;\r\n let start = 0;\r\n let end = start;\r\n\r\n const pushCurrentLine = () => {\r\n lines.push({\r\n text: text.slice(start, end),\r\n glyphs: currentGlyphs,\r\n start: start,\r\n end: end,\r\n width: currentWidth,\r\n });\r\n };\r\n\r\n while (end < text.length) {\r\n const i = end;\r\n const charCode = text.charCodeAt(i);\r\n const char = this.fontAsset._getChar(charCode);\r\n const charWidth = char.width;\r\n const kerning = lastChar ? this.fontAsset._getKerning(lastChar.id, char.id) : 0;\r\n\r\n currentCursor += kerning;\r\n const newWidth = currentCursor + charWidth;\r\n const cursorProgress = char.xadvance + this.options.letterSpacing;\r\n const nextPosition = currentCursor + cursorProgress;\r\n\r\n const shouldBreak = nextPosition > this.options.maxWidth || newWidth > this.options.maxWidth;\r\n\r\n if (shouldBreak) {\r\n pushCurrentLine();\r\n\r\n currentLine++;\r\n lastChar = undefined;\r\n currentCursor = 0;\r\n currentWidth = 0;\r\n start = end;\r\n end = start + 1;\r\n currentGlyphs = [];\r\n }\r\n\r\n const x = currentCursor;\r\n const y = currentLine * this.lineHeight;\r\n\r\n currentGlyphs.push({\r\n char,\r\n line: currentLine,\r\n position: currentGlyphs.length,\r\n x: x,\r\n y: y,\r\n });\r\n\r\n if (!shouldBreak) {\r\n lastChar = char;\r\n currentCursor = nextPosition;\r\n currentWidth = newWidth;\r\n end++;\r\n } else {\r\n currentCursor = cursorProgress;\r\n }\r\n }\r\n\r\n if (currentGlyphs.length > 0) {\r\n if (lastChar) {\r\n // currentWidth += lastChar.xadvance;\r\n }\r\n pushCurrentLine();\r\n }\r\n\r\n return lines;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/factory/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/factory/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,cAAc,yBAAyB,CAAC","sourcesContent":["// export * from \"./factory.worker\";\nexport * from \"./factory.single-thread\";\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NavMesh, QueryFilter, TileCache, NavMeshQuery } from "@recast-navigation/core";
|
|
1
|
+
import type { TileCacheMeshProcess, NavMesh, QueryFilter, TileCache, NavMeshQuery } from "@recast-navigation/core";
|
|
2
2
|
import type { ICrowd, INavigationEnginePlugin, IObstacle } from "@onerjs/core/Navigation/INavigationEngine.js";
|
|
3
3
|
import type { Mesh } from "@onerjs/core/Meshes/mesh.js";
|
|
4
4
|
import type { Scene } from "@onerjs/core/scene.js";
|
|
@@ -54,12 +54,22 @@ export declare class RecastNavigationJSPluginV2 implements INavigationEnginePlug
|
|
|
54
54
|
* @remarks This is only available if the `keepIntermediates` parameter is set
|
|
55
55
|
* @remarks to true during navmesh generation.
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
private _intermediates?;
|
|
58
|
+
/**
|
|
59
|
+
* Gets the intermediates generated during the navmesh creation
|
|
60
|
+
* @returns The generator intermediates, or undefined if not available
|
|
61
|
+
*/
|
|
62
|
+
get intermediates(): GeneratorIntermediates | undefined;
|
|
58
63
|
/**
|
|
59
64
|
* Tile cache used for tiled navigation meshes
|
|
60
65
|
* @remarks This is used to store and manage tiles of the navigation mesh for efficient path and when obstacles are used.
|
|
61
66
|
*/
|
|
62
|
-
|
|
67
|
+
private _tileCache?;
|
|
68
|
+
/**
|
|
69
|
+
* Gets the tile cache used for tiled navigation meshes
|
|
70
|
+
* @returns The tile cache instance, or undefined if not available
|
|
71
|
+
*/
|
|
72
|
+
get tileCache(): TileCache | undefined;
|
|
63
73
|
private _maximumSubStepCount;
|
|
64
74
|
private _timeStep;
|
|
65
75
|
private _timeFactor;
|
|
@@ -299,6 +309,19 @@ export declare class RecastNavigationJSPluginV2 implements INavigationEnginePlug
|
|
|
299
309
|
* @returns data the Uint8Array that can be saved and reused
|
|
300
310
|
*/
|
|
301
311
|
getNavmeshData(): Uint8Array;
|
|
312
|
+
/**
|
|
313
|
+
* build the tile cache from a previously saved state using getTileCacheData
|
|
314
|
+
* @param tileCacheData the data returned by getTileCacheData
|
|
315
|
+
* @param tileCacheMeshProcess optional process to apply to each tile created
|
|
316
|
+
*/
|
|
317
|
+
buildFromTileCacheData(tileCacheData: Uint8Array, tileCacheMeshProcess?: TileCacheMeshProcess): void;
|
|
318
|
+
/**
|
|
319
|
+
* returns the tile cache data that can be used later. The tile cache must be built before retrieving the data
|
|
320
|
+
* @returns the tile cache data that can be used later. The tile cache must be built before retrieving the data
|
|
321
|
+
* @throws Error if there is no TileCache generated
|
|
322
|
+
* @remarks The returned data can be used to rebuild the tile cache later using buildFromTileCacheData
|
|
323
|
+
*/
|
|
324
|
+
getTileCacheData(): Uint8Array;
|
|
302
325
|
/**
|
|
303
326
|
* Disposes
|
|
304
327
|
*/
|
|
@@ -7,7 +7,7 @@ import { CreateDebugNavMesh } from "../debug/simple-debug.js";
|
|
|
7
7
|
import { GetRecast } from "../factory/common.js";
|
|
8
8
|
import { InjectGenerators } from "../generator/injection.js";
|
|
9
9
|
import { DefaultMaxObstacles } from "../common/config.js";
|
|
10
|
-
import { WaitForFullTileCacheUpdate } from "../common/tile-cache.js";
|
|
10
|
+
import { CreateDefaultTileCacheMeshProcess, WaitForFullTileCacheUpdate } from "../common/tile-cache.js";
|
|
11
11
|
/**
|
|
12
12
|
* Navigation plugin for Babylon.js. It is a simple wrapper around the recast-navigation-js library. Not all features are implemented.
|
|
13
13
|
* @remarks This plugin provides navigation mesh generation and pathfinding capabilities using the recast-navigation-js library
|
|
@@ -24,6 +24,20 @@ export class RecastNavigationJSPluginV2 {
|
|
|
24
24
|
get navMeshQuery() {
|
|
25
25
|
return this._navMeshQuery;
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Gets the intermediates generated during the navmesh creation
|
|
29
|
+
* @returns The generator intermediates, or undefined if not available
|
|
30
|
+
*/
|
|
31
|
+
get intermediates() {
|
|
32
|
+
return this._intermediates;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Gets the tile cache used for tiled navigation meshes
|
|
36
|
+
* @returns The tile cache instance, or undefined if not available
|
|
37
|
+
*/
|
|
38
|
+
get tileCache() {
|
|
39
|
+
return this._tileCache;
|
|
40
|
+
}
|
|
27
41
|
/**
|
|
28
42
|
* Creates a RecastNavigationJSPluginV2 instance
|
|
29
43
|
* @param recastInjection The recast-navigation-js injection containing core and generators
|
|
@@ -134,8 +148,8 @@ export class RecastNavigationJSPluginV2 {
|
|
|
134
148
|
if (!this.navMesh) {
|
|
135
149
|
throw new Error("There is no navMesh generated.");
|
|
136
150
|
}
|
|
137
|
-
if (this.navMesh && this.
|
|
138
|
-
WaitForFullTileCacheUpdate(this.navMesh, this.
|
|
151
|
+
if (this.navMesh && this._tileCache) {
|
|
152
|
+
WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);
|
|
139
153
|
}
|
|
140
154
|
return CreateDebugNavMesh(this.navMesh, scene);
|
|
141
155
|
}
|
|
@@ -283,6 +297,29 @@ export class RecastNavigationJSPluginV2 {
|
|
|
283
297
|
}
|
|
284
298
|
return this.bjsRECAST.exportNavMesh(this.navMesh);
|
|
285
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* build the tile cache from a previously saved state using getTileCacheData
|
|
302
|
+
* @param tileCacheData the data returned by getTileCacheData
|
|
303
|
+
* @param tileCacheMeshProcess optional process to apply to each tile created
|
|
304
|
+
*/
|
|
305
|
+
buildFromTileCacheData(tileCacheData, tileCacheMeshProcess) {
|
|
306
|
+
const result = this.bjsRECAST.importTileCache(tileCacheData, tileCacheMeshProcess ?? CreateDefaultTileCacheMeshProcess([]));
|
|
307
|
+
this.navMesh = result.navMesh;
|
|
308
|
+
this._tileCache = result.tileCache;
|
|
309
|
+
this._navMeshQuery = new this.bjsRECAST.NavMeshQuery(this.navMesh);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* returns the tile cache data that can be used later. The tile cache must be built before retrieving the data
|
|
313
|
+
* @returns the tile cache data that can be used later. The tile cache must be built before retrieving the data
|
|
314
|
+
* @throws Error if there is no TileCache generated
|
|
315
|
+
* @remarks The returned data can be used to rebuild the tile cache later using buildFromTileCacheData
|
|
316
|
+
*/
|
|
317
|
+
getTileCacheData() {
|
|
318
|
+
if (!this.navMesh || !this._tileCache) {
|
|
319
|
+
throw new Error("There is no TileCache generated.");
|
|
320
|
+
}
|
|
321
|
+
return this.bjsRECAST.exportTileCache(this.navMesh, this._tileCache);
|
|
322
|
+
}
|
|
286
323
|
/**
|
|
287
324
|
* Disposes
|
|
288
325
|
*/
|
|
@@ -290,7 +327,7 @@ export class RecastNavigationJSPluginV2 {
|
|
|
290
327
|
this._crowd?.dispose();
|
|
291
328
|
this.navMesh?.destroy();
|
|
292
329
|
this._navMeshQuery?.destroy();
|
|
293
|
-
this.
|
|
330
|
+
this._tileCache?.destroy();
|
|
294
331
|
}
|
|
295
332
|
/**
|
|
296
333
|
* Creates a cylinder obstacle and add it to the navigation
|
|
@@ -301,12 +338,12 @@ export class RecastNavigationJSPluginV2 {
|
|
|
301
338
|
* @returns the obstacle freshly created
|
|
302
339
|
*/
|
|
303
340
|
addCylinderObstacle(position, radius, height, doNotWaitForCacheUpdate = false) {
|
|
304
|
-
const obstacleResult = this.
|
|
341
|
+
const obstacleResult = this._tileCache?.addCylinderObstacle(position, radius, height);
|
|
305
342
|
if (!obstacleResult?.success) {
|
|
306
343
|
return null;
|
|
307
344
|
}
|
|
308
|
-
if (!doNotWaitForCacheUpdate && this.navMesh && this.
|
|
309
|
-
WaitForFullTileCacheUpdate(this.navMesh, this.
|
|
345
|
+
if (!doNotWaitForCacheUpdate && this.navMesh && this._tileCache) {
|
|
346
|
+
WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);
|
|
310
347
|
}
|
|
311
348
|
return obstacleResult.obstacle ?? null;
|
|
312
349
|
}
|
|
@@ -319,12 +356,12 @@ export class RecastNavigationJSPluginV2 {
|
|
|
319
356
|
* @returns the obstacle freshly created
|
|
320
357
|
*/
|
|
321
358
|
addBoxObstacle(position, extent, angle, doNotWaitForCacheUpdate = false) {
|
|
322
|
-
const obstacleResult = this.
|
|
359
|
+
const obstacleResult = this._tileCache?.addBoxObstacle(position, extent, angle);
|
|
323
360
|
if (!obstacleResult?.success) {
|
|
324
361
|
return null;
|
|
325
362
|
}
|
|
326
|
-
if (!doNotWaitForCacheUpdate && this.navMesh && this.
|
|
327
|
-
WaitForFullTileCacheUpdate(this.navMesh, this.
|
|
363
|
+
if (!doNotWaitForCacheUpdate && this.navMesh && this._tileCache) {
|
|
364
|
+
WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);
|
|
328
365
|
}
|
|
329
366
|
return obstacleResult.obstacle ?? null;
|
|
330
367
|
}
|
|
@@ -335,9 +372,9 @@ export class RecastNavigationJSPluginV2 {
|
|
|
335
372
|
*
|
|
336
373
|
*/
|
|
337
374
|
removeObstacle(obstacle, doNotWaitForCacheUpdate = false) {
|
|
338
|
-
this.
|
|
339
|
-
if (!doNotWaitForCacheUpdate && this.navMesh && this.
|
|
340
|
-
WaitForFullTileCacheUpdate(this.navMesh, this.
|
|
375
|
+
this._tileCache?.removeObstacle(obstacle);
|
|
376
|
+
if (!doNotWaitForCacheUpdate && this.navMesh && this._tileCache) {
|
|
377
|
+
WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);
|
|
341
378
|
}
|
|
342
379
|
}
|
|
343
380
|
/**
|
|
@@ -426,8 +463,8 @@ export class RecastNavigationJSPluginV2 {
|
|
|
426
463
|
}
|
|
427
464
|
this.navMesh = result.navMesh;
|
|
428
465
|
this._navMeshQuery = result.navMeshQuery;
|
|
429
|
-
this.
|
|
430
|
-
this.
|
|
466
|
+
this._intermediates = result.intermediates;
|
|
467
|
+
this._tileCache = result.tileCache;
|
|
431
468
|
return {
|
|
432
469
|
navMesh: result.navMesh,
|
|
433
470
|
navMeshQuery: result.navMeshQuery,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecastNavigationJSPlugin.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/plugin/RecastNavigationJSPlugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,oCAAyB;AAG1C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,mCAAwB;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,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAElE;;;;;;;GAOG;AACH,MAAM,OAAO,0BAA0B;IAiCnC;;;OAGG;IACH,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,aAAa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AC,UAAgC;QAC1D,IAAI,CAAC,UAAU,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;YAC9D,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 { 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 { 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 visusalize 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 public intermediates?: GeneratorIntermediates;\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 public tileCache?: TileCache;\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 * Creates a navigation mesh - will be injected by the factory\n * @param start the start position of the navmesh\n * @param end the end position of the navmesh\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 * 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 funccntions 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 sophisiticated 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 wvelocity 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 ((parameters.tileSize ?? 0 > 0) && !!parameters.maxObstacles) {\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,oCAAyB;AAG1C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,mCAAwB;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,mBA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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 visusalize 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 * Creates a navigation mesh - will be injected by the factory\n * @param start the start position of the navmesh\n * @param end the end position of the navmesh\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 funccntions 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 sophisiticated 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 wvelocity 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 ((parameters.tileSize ?? 0 > 0) && !!parameters.maxObstacles) {\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
|
@@ -62,7 +62,7 @@ export type CreateNavMeshResult = Nullable<{
|
|
|
62
62
|
intermediates?: GeneratorIntermediates;
|
|
63
63
|
/**
|
|
64
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`.
|
|
65
|
+
* @remarks This is only available if the `maxObstacles` parameter is set to a value greater than 0 in the `INavMeshParametersV2`. Defaults `maxObstacles` to 128.
|
|
66
66
|
* It can be used for obstacle avoidance and dynamic navigation mesh updates.
|
|
67
67
|
* @see {@link INavMeshParametersV2}
|
|
68
68
|
*/
|
package/navigation/types.js.map
CHANGED
|
@@ -1 +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
|
|
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`. 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\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.3",
|
|
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.3",
|
|
22
22
|
"@dev/addons": "^1.0.0",
|
|
23
23
|
"@dev/build-tools": "^1.0.0"
|
|
24
24
|
},
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { RecastNavigationJSPluginV2 } from "../plugin/RecastNavigationJSPlugin.js";
|
|
2
|
-
/**
|
|
3
|
-
* Creates a navigation plugin for the given scene using Recast WASM.
|
|
4
|
-
* @returns A promise that resolves to the created navigation plugin.
|
|
5
|
-
* @remarks This function initializes the Recast WASM module and then calls the NavigationPlugin
|
|
6
|
-
*/
|
|
7
|
-
export declare function CreateNavigationPluginWasmAsync(): Promise<RecastNavigationJSPluginV2>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { InjectGenerators } from "../generator/injection.js";
|
|
2
|
-
import { RecastNavigationJSPluginV2 } from "../plugin/RecastNavigationJSPlugin.js";
|
|
3
|
-
import { GetRecast, InitRecast } from "./common.js";
|
|
4
|
-
/**
|
|
5
|
-
* Creates a navigation plugin for the given scene using Recast WASM.
|
|
6
|
-
* @returns A promise that resolves to the created navigation plugin.
|
|
7
|
-
* @remarks This function initializes the Recast WASM module and then calls the NavigationPlugin
|
|
8
|
-
*/
|
|
9
|
-
export async function CreateNavigationPluginWasmAsync() {
|
|
10
|
-
await InitRecast();
|
|
11
|
-
const navigationPlugin = new RecastNavigationJSPluginV2(GetRecast());
|
|
12
|
-
InjectGenerators(navigationPlugin);
|
|
13
|
-
return navigationPlugin;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=factory.wasm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factory.wasm.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/factory/factory.wasm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEjD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,+BAA+B;IACjD,MAAM,UAAU,EAAE,CAAC;IAEnB,MAAM,gBAAgB,GAAG,IAAI,0BAA0B,CAAC,SAAS,EAAE,CAAC,CAAC;IACrE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IAEnC,OAAO,gBAAgB,CAAC;AAC5B,CAAC","sourcesContent":["import { InjectGenerators } from \"../generator/injection\";\nimport { RecastNavigationJSPluginV2 } from \"../plugin/RecastNavigationJSPlugin\";\nimport { GetRecast, InitRecast } from \"./common\";\n\n/**\n * Creates a navigation plugin for the given scene using Recast WASM.\n * @returns A promise that resolves to the created navigation plugin.\n * @remarks This function initializes the Recast WASM module and then calls the NavigationPlugin\n */\nexport async function CreateNavigationPluginWasmAsync() {\n await InitRecast();\n\n const navigationPlugin = new RecastNavigationJSPluginV2(GetRecast());\n InjectGenerators(navigationPlugin);\n\n return navigationPlugin;\n}\n"]}
|