@onerjs/addons 8.27.1 → 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.
Files changed (83) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +1 -0
  3. package/index.js.map +1 -1
  4. package/msdfText/paragraphOptions.d.ts +15 -0
  5. package/msdfText/paragraphOptions.js.map +1 -1
  6. package/msdfText/sdf/paragraph.js +1 -1
  7. package/msdfText/sdf/paragraph.js.map +1 -1
  8. package/navigation/common/config.d.ts +35 -0
  9. package/navigation/common/config.js +61 -0
  10. package/navigation/common/config.js.map +1 -0
  11. package/navigation/common/convert.d.ts +8 -0
  12. package/navigation/common/convert.js +22 -0
  13. package/navigation/common/convert.js.map +1 -0
  14. package/navigation/common/getters.d.ts +15 -0
  15. package/navigation/common/getters.js +76 -0
  16. package/navigation/common/getters.js.map +1 -0
  17. package/navigation/common/index.d.ts +6 -0
  18. package/navigation/common/index.js +7 -0
  19. package/navigation/common/index.js.map +1 -0
  20. package/navigation/common/smooth-path.d.ts +32 -0
  21. package/navigation/common/smooth-path.js +340 -0
  22. package/navigation/common/smooth-path.js.map +1 -0
  23. package/navigation/common/tile-cache.d.ts +15 -0
  24. package/navigation/common/tile-cache.js +32 -0
  25. package/navigation/common/tile-cache.js.map +1 -0
  26. package/navigation/common/utils.d.ts +17 -0
  27. package/navigation/common/utils.js +66 -0
  28. package/navigation/common/utils.js.map +1 -0
  29. package/navigation/debug/NavigationDebugger.d.ts +248 -0
  30. package/navigation/debug/NavigationDebugger.js +587 -0
  31. package/navigation/debug/NavigationDebugger.js.map +1 -0
  32. package/navigation/debug/index.d.ts +2 -0
  33. package/navigation/debug/index.js +3 -0
  34. package/navigation/debug/index.js.map +1 -0
  35. package/navigation/debug/simple-debug.d.ts +13 -0
  36. package/navigation/debug/simple-debug.js +23 -0
  37. package/navigation/debug/simple-debug.js.map +1 -0
  38. package/navigation/factory/common.d.ts +20 -0
  39. package/navigation/factory/common.js +80 -0
  40. package/navigation/factory/common.js.map +1 -0
  41. package/navigation/factory/factory.single-thread.d.ts +7 -0
  42. package/navigation/factory/factory.single-thread.js +15 -0
  43. package/navigation/factory/factory.single-thread.js.map +1 -0
  44. package/navigation/factory/factory.worker.d.ts +9 -0
  45. package/navigation/factory/factory.worker.js +40 -0
  46. package/navigation/factory/factory.worker.js.map +1 -0
  47. package/navigation/factory/index.d.ts +1 -0
  48. package/navigation/factory/index.js +3 -0
  49. package/navigation/factory/index.js.map +1 -0
  50. package/navigation/generator/generator.common.d.ts +25 -0
  51. package/navigation/generator/generator.common.js +40 -0
  52. package/navigation/generator/generator.common.js.map +1 -0
  53. package/navigation/generator/generator.single-thread.d.ts +20 -0
  54. package/navigation/generator/generator.single-thread.js +57 -0
  55. package/navigation/generator/generator.single-thread.js.map +1 -0
  56. package/navigation/generator/generator.worker.d.ts +29 -0
  57. package/navigation/generator/generator.worker.js +47 -0
  58. package/navigation/generator/generator.worker.js.map +1 -0
  59. package/navigation/generator/index.d.ts +3 -0
  60. package/navigation/generator/index.js +5 -0
  61. package/navigation/generator/index.js.map +1 -0
  62. package/navigation/generator/injection.d.ts +6 -0
  63. package/navigation/generator/injection.js +16 -0
  64. package/navigation/generator/injection.js.map +1 -0
  65. package/navigation/index.d.ts +5 -0
  66. package/navigation/index.js +7 -0
  67. package/navigation/index.js.map +1 -0
  68. package/navigation/plugin/RecastJSCrowd.d.ts +198 -0
  69. package/navigation/plugin/RecastJSCrowd.js +359 -0
  70. package/navigation/plugin/RecastJSCrowd.js.map +1 -0
  71. package/navigation/plugin/RecastNavigationJSPlugin.d.ts +419 -0
  72. package/navigation/plugin/RecastNavigationJSPlugin.js +482 -0
  73. package/navigation/plugin/RecastNavigationJSPlugin.js.map +1 -0
  74. package/navigation/plugin/index.d.ts +1 -0
  75. package/navigation/plugin/index.js +2 -0
  76. package/navigation/plugin/index.js.map +1 -0
  77. package/navigation/types.d.ts +199 -0
  78. package/navigation/types.js +11 -0
  79. package/navigation/types.js.map +1 -0
  80. package/navigation/worker/navmesh-worker.d.ts +4 -0
  81. package/navigation/worker/navmesh-worker.js +63 -0
  82. package/navigation/worker/navmesh-worker.js.map +1 -0
  83. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./atmosphere/index.js";
2
2
  export * from "./htmlMesh/index.js";
3
3
  export * from "./msdfText/index.js";
4
+ export * from "./navigation/index.js";
package/index.js CHANGED
@@ -2,4 +2,5 @@
2
2
  export * from "./atmosphere/index.js";
3
3
  export * from "./htmlMesh/index.js";
4
4
  export * from "./msdfText/index.js";
5
+ export * from "./navigation/index.js";
5
6
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../dev/addons/src/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\nexport * from \"./atmosphere/index\";\nexport * from \"./htmlMesh/index\";\nexport * from \"./msdfText/index\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../dev/addons/src/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\nexport * from \"./atmosphere/index\";\nexport * from \"./htmlMesh/index\";\nexport * from \"./msdfText/index\";\nexport * from \"./navigation/index\";\n"]}
@@ -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;AAexC,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\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};\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"]}
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,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAE/E,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAC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AM,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 { 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,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAEO,eAAe,CAAC,IAAY;QAChC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACvC,MAAM,OAAO,GAAG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,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"]}
@@ -0,0 +1,35 @@
1
+ import type { SoloNavMeshGeneratorConfig, TileCacheGeneratorConfig, TiledNavMeshGeneratorConfig } from "@recast-navigation/generators";
2
+ import type { CrowdAgentParams } from "@recast-navigation/core";
3
+ import type { IAgentParametersV2, INavMeshParametersV2 } from "../types.js";
4
+ export declare const DefaultMaxObstacles = 128;
5
+ /**
6
+ * Creates a SoloNavMesh configuration based on the provided parameters.
7
+ * @param parameters The parameters used to configure the SoloNavMesh generation.
8
+ * @returns A configuration object for generating a SoloNavMesh.
9
+ * @see https://docs.recast-navigation-js.isaacmason.com/types/index.RecastConfig.html
10
+ */
11
+ export declare function CreateSoloNavMeshConfig(parameters: INavMeshParametersV2): Partial<SoloNavMeshGeneratorConfig>;
12
+ /**
13
+ * Creates a TiledNavMesh configuration based on the provided parameters.
14
+ * @param parameters The parameters used to configure the TiledNavMesh generation.
15
+ * @returns A configuration object for generating a TiledNavMesh.
16
+ */
17
+ export declare function CreateTiledNavMeshConfig(parameters: INavMeshParametersV2): Partial<TiledNavMeshGeneratorConfig>;
18
+ /**
19
+ * Creates a TileCacheNavMesh configuration based on the provided parameters.
20
+ * @param parameters The parameters used to configure the TileCacheNavMesh generation.
21
+ * @returns A configuration object for generating a TileCacheNavMesh.
22
+ */
23
+ export declare function CreateTileCacheNavMeshConfig(parameters: INavMeshParametersV2): Partial<TileCacheGeneratorConfig>;
24
+ /**
25
+ * Convert IAgentParameters to Recast CrowdAgentParams
26
+ * @param config Agent parameters
27
+ * @returns Recast crowd agent paramaters
28
+ */
29
+ export declare function ToSoloNavMeshGeneratorConfig(config: INavMeshParametersV2): Partial<SoloNavMeshGeneratorConfig>;
30
+ /**
31
+ * Convert IAgentParameters to Recast CrowdAgentParams
32
+ * @param agentParams Agent parameters
33
+ * @returns Recast crowd agent paramaters
34
+ */
35
+ export declare function ToCrowdAgentParams(agentParams: IAgentParametersV2): Partial<CrowdAgentParams>;
@@ -0,0 +1,61 @@
1
+ import { Logger } from "@onerjs/core/Misc/logger.js";
2
+ import { CreateDefaultTileCacheMeshProcess } from "./tile-cache.js";
3
+ export const DefaultMaxObstacles = 128;
4
+ /**
5
+ * Creates a SoloNavMesh configuration based on the provided parameters.
6
+ * @param parameters The parameters used to configure the SoloNavMesh generation.
7
+ * @returns A configuration object for generating a SoloNavMesh.
8
+ * @see https://docs.recast-navigation-js.isaacmason.com/types/index.RecastConfig.html
9
+ */
10
+ export function CreateSoloNavMeshConfig(parameters) {
11
+ return ToSoloNavMeshGeneratorConfig(parameters);
12
+ }
13
+ /**
14
+ * Creates a TiledNavMesh configuration based on the provided parameters.
15
+ * @param parameters The parameters used to configure the TiledNavMesh generation.
16
+ * @returns A configuration object for generating a TiledNavMesh.
17
+ */
18
+ export function CreateTiledNavMeshConfig(parameters) {
19
+ const cfg = {
20
+ ...CreateSoloNavMeshConfig(parameters),
21
+ tileSize: parameters.tileSize ?? 32,
22
+ };
23
+ return cfg;
24
+ }
25
+ /**
26
+ * Creates a TileCacheNavMesh configuration based on the provided parameters.
27
+ * @param parameters The parameters used to configure the TileCacheNavMesh generation.
28
+ * @returns A configuration object for generating a TileCacheNavMesh.
29
+ */
30
+ export function CreateTileCacheNavMeshConfig(parameters) {
31
+ const cfg = {
32
+ ...CreateTiledNavMeshConfig(parameters),
33
+ expectedLayersPerTile: parameters.expectedLayersPerTile ?? 1,
34
+ maxObstacles: parameters.maxObstacles ?? DefaultMaxObstacles,
35
+ };
36
+ if (parameters.tileCacheMeshProcess) {
37
+ cfg.tileCacheMeshProcess = parameters.tileCacheMeshProcess;
38
+ }
39
+ else if (parameters.offMeshConnections) {
40
+ Logger.Warn("offMeshConnections are required but no tileCacheMeshProcess is set. Using fallback DefaultTileCacheMeshProcess.");
41
+ cfg.tileCacheMeshProcess = CreateDefaultTileCacheMeshProcess(parameters.offMeshConnections);
42
+ }
43
+ return cfg;
44
+ }
45
+ /**
46
+ * Convert IAgentParameters to Recast CrowdAgentParams
47
+ * @param config Agent parameters
48
+ * @returns Recast crowd agent paramaters
49
+ */
50
+ export function ToSoloNavMeshGeneratorConfig(config) {
51
+ return Object.fromEntries(Object.entries(config).filter(([_, v]) => v !== undefined));
52
+ }
53
+ /**
54
+ * Convert IAgentParameters to Recast CrowdAgentParams
55
+ * @param agentParams Agent parameters
56
+ * @returns Recast crowd agent paramaters
57
+ */
58
+ export function ToCrowdAgentParams(agentParams) {
59
+ return Object.fromEntries(Object.entries(agentParams).filter(([_, v]) => v !== undefined));
60
+ }
61
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/common/config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,oCAAyB;AAG1C,OAAO,EAAE,iCAAiC,EAAE,MAAM,cAAc,CAAC;AAEjE,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,UAAgC;IACpE,OAAO,4BAA4B,CAAC,UAAU,CAAC,CAAC;AACpD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,UAAgC;IACrE,MAAM,GAAG,GAAyC;QAC9C,GAAG,uBAAuB,CAAC,UAAU,CAAC;QACtC,QAAQ,EAAE,UAAU,CAAC,QAAQ,IAAI,EAAE;KACtC,CAAC;IACF,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAAC,UAAgC;IACzE,MAAM,GAAG,GAAsC;QAC3C,GAAG,wBAAwB,CAAC,UAAU,CAAC;QACvC,qBAAqB,EAAE,UAAU,CAAC,qBAAqB,IAAI,CAAC;QAC5D,YAAY,EAAE,UAAU,CAAC,YAAY,IAAI,mBAAmB;KAC/D,CAAC;IAEF,IAAI,UAAU,CAAC,oBAAoB,EAAE,CAAC;QAClC,GAAG,CAAC,oBAAoB,GAAG,UAAU,CAAC,oBAAoB,CAAC;IAC/D,CAAC;SAAM,IAAI,UAAU,CAAC,kBAAkB,EAAE,CAAC;QACvC,MAAM,CAAC,IAAI,CAAC,iHAAiH,CAAC,CAAC;QAC/H,GAAG,CAAC,oBAAoB,GAAG,iCAAiC,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAChG,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAAC,MAA4B;IACrE,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC;AAC1F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAA+B;IAC9D,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC;AAC/F,CAAC","sourcesContent":["import type { SoloNavMeshGeneratorConfig, TileCacheGeneratorConfig, TiledNavMeshGeneratorConfig } from \"@recast-navigation/generators\";\nimport type { CrowdAgentParams } from \"@recast-navigation/core\";\n\nimport { Logger } from \"core/Misc/logger\";\n\nimport type { IAgentParametersV2, INavMeshParametersV2 } from \"../types\";\nimport { CreateDefaultTileCacheMeshProcess } from \"./tile-cache\";\n\nexport const DefaultMaxObstacles = 128;\n\n/**\n * Creates a SoloNavMesh configuration based on the provided parameters.\n * @param parameters The parameters used to configure the SoloNavMesh generation.\n * @returns A configuration object for generating a SoloNavMesh.\n * @see https://docs.recast-navigation-js.isaacmason.com/types/index.RecastConfig.html\n */\nexport function CreateSoloNavMeshConfig(parameters: INavMeshParametersV2): Partial<SoloNavMeshGeneratorConfig> {\n return ToSoloNavMeshGeneratorConfig(parameters);\n}\n\n/**\n * Creates a TiledNavMesh configuration based on the provided parameters.\n * @param parameters The parameters used to configure the TiledNavMesh generation.\n * @returns A configuration object for generating a TiledNavMesh.\n */\nexport function CreateTiledNavMeshConfig(parameters: INavMeshParametersV2): Partial<TiledNavMeshGeneratorConfig> {\n const cfg: Partial<TiledNavMeshGeneratorConfig> = {\n ...CreateSoloNavMeshConfig(parameters),\n tileSize: parameters.tileSize ?? 32,\n };\n return cfg;\n}\n\n/**\n * Creates a TileCacheNavMesh configuration based on the provided parameters.\n * @param parameters The parameters used to configure the TileCacheNavMesh generation.\n * @returns A configuration object for generating a TileCacheNavMesh.\n */\nexport function CreateTileCacheNavMeshConfig(parameters: INavMeshParametersV2): Partial<TileCacheGeneratorConfig> {\n const cfg: Partial<TileCacheGeneratorConfig> = {\n ...CreateTiledNavMeshConfig(parameters),\n expectedLayersPerTile: parameters.expectedLayersPerTile ?? 1,\n maxObstacles: parameters.maxObstacles ?? DefaultMaxObstacles,\n };\n\n if (parameters.tileCacheMeshProcess) {\n cfg.tileCacheMeshProcess = parameters.tileCacheMeshProcess;\n } else if (parameters.offMeshConnections) {\n Logger.Warn(\"offMeshConnections are required but no tileCacheMeshProcess is set. Using fallback DefaultTileCacheMeshProcess.\");\n cfg.tileCacheMeshProcess = CreateDefaultTileCacheMeshProcess(parameters.offMeshConnections);\n }\n\n return cfg;\n}\n\n/**\n * Convert IAgentParameters to Recast CrowdAgentParams\n * @param config Agent parameters\n * @returns Recast crowd agent paramaters\n */\nexport function ToSoloNavMeshGeneratorConfig(config: INavMeshParametersV2): Partial<SoloNavMeshGeneratorConfig> {\n return Object.fromEntries(Object.entries(config).filter(([_, v]) => v !== undefined));\n}\n\n/**\n * Convert IAgentParameters to Recast CrowdAgentParams\n * @param agentParams Agent parameters\n * @returns Recast crowd agent paramaters\n */\nexport function ToCrowdAgentParams(agentParams: IAgentParametersV2): Partial<CrowdAgentParams> {\n return Object.fromEntries(Object.entries(agentParams).filter(([_, v]) => v !== undefined));\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import { Vector3 } from "@onerjs/core/Maths/math.vector.js";
2
+ import type { ComputePathResult } from "../types.js";
3
+ /**
4
+ * Converts navigation path points to a Vector3 array.
5
+ * @param navPath The navigation path containing points and success status.
6
+ * @returns An array of Vector3 points representing the navigation path.
7
+ */
8
+ export declare function ConvertNavPathPoints(navPath: ComputePathResult): Vector3[];
@@ -0,0 +1,22 @@
1
+ import { Vector3 } from "@onerjs/core/Maths/math.vector.js";
2
+ import { Logger } from "@onerjs/core/Misc/logger.js";
3
+ /**
4
+ * Converts navigation path points to a Vector3 array.
5
+ * @param navPath The navigation path containing points and success status.
6
+ * @returns An array of Vector3 points representing the navigation path.
7
+ */
8
+ export function ConvertNavPathPoints(navPath) {
9
+ const positions = [];
10
+ if (navPath.success) {
11
+ const pointCount = navPath.path.length;
12
+ for (let pt = 0; pt < pointCount; pt++) {
13
+ const p = navPath.path[pt];
14
+ positions.push(new Vector3(p.x, p.y, p.z));
15
+ }
16
+ }
17
+ else {
18
+ Logger.Warn("Unable to convert navigation path point, because navPath generation has failed.");
19
+ }
20
+ return positions;
21
+ }
22
+ //# sourceMappingURL=convert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/common/convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,0CAA+B;AACjD,OAAO,EAAE,MAAM,EAAE,oCAAyB;AAI1C;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA0B;IAC3D,MAAM,SAAS,GAAG,EAAE,CAAC;IAErB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QAClB,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;QACvC,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,UAAU,EAAE,EAAE,EAAE,EAAE,CAAC;YACrC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC3B,SAAS,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,MAAM,CAAC,IAAI,CAAC,iFAAiF,CAAC,CAAC;IACnG,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC","sourcesContent":["import { Vector3 } from \"core/Maths/math.vector\";\nimport { Logger } from \"core/Misc/logger\";\n\nimport type { ComputePathResult } from \"../types\";\n\n/**\n * Converts navigation path points to a Vector3 array.\n * @param navPath The navigation path containing points and success status.\n * @returns An array of Vector3 points representing the navigation path.\n */\nexport function ConvertNavPathPoints(navPath: ComputePathResult): Vector3[] {\n const positions = [];\n\n if (navPath.success) {\n const pointCount = navPath.path.length;\n for (let pt = 0; pt < pointCount; pt++) {\n const p = navPath.path[pt];\n positions.push(new Vector3(p.x, p.y, p.z));\n }\n } else {\n Logger.Warn(\"Unable to convert navigation path point, because navPath generation has failed.\");\n }\n\n return positions;\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { Mesh } from "@onerjs/core/Meshes/mesh.js";
2
+ /**
3
+ * Extracts positions and indices from an array of meshes.
4
+ * @param meshes The array of meshes from which to extract positions and indices.
5
+ * @returns A tuple containing a Float32Array of positions and a Uint32Array of
6
+ */
7
+ export declare function GetPositionsAndIndices(meshes: Mesh[]): [positions: Float32Array, indices: Uint32Array];
8
+ /**
9
+ * Reverses the order of vertices in each triangle (3 indices per face) to ensure
10
+ * that the winding order is consistent with the Recast Navigation requirements.
11
+ * This is necessary because Recast Navigation expects the indices to be in a specific winding order.
12
+ * @param meshOrIndices The mesh from which to extract indices or the indices themselves.
13
+ * @returns Array of indices with reversed winding order.
14
+ */
15
+ export declare function GetReversedIndices(meshOrIndices: Mesh | Uint32Array | number[]): Uint32Array<ArrayBufferLike> | number[] | Int32Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | null;
@@ -0,0 +1,76 @@
1
+ import { VertexBuffer } from "@onerjs/core/Buffers/buffer.js";
2
+ import { Matrix, Vector3 } from "@onerjs/core/Maths/math.vector.js";
3
+ import { Mesh } from "@onerjs/core/Meshes/mesh.js";
4
+ /**
5
+ * Extracts positions and indices from an array of meshes.
6
+ * @param meshes The array of meshes from which to extract positions and indices.
7
+ * @returns A tuple containing a Float32Array of positions and a Uint32Array of
8
+ */
9
+ export function GetPositionsAndIndices(meshes) {
10
+ let offset = 0;
11
+ let index;
12
+ let tri;
13
+ let pt;
14
+ const positions = [];
15
+ const indices = [];
16
+ for (index = 0; index < meshes.length; index++) {
17
+ if (meshes[index]) {
18
+ const mesh = meshes[index];
19
+ const meshIndices = GetReversedIndices(mesh);
20
+ if (!meshIndices) {
21
+ continue;
22
+ }
23
+ const meshPositions = mesh.getVerticesData(VertexBuffer.PositionKind, false, false);
24
+ if (!meshPositions) {
25
+ continue;
26
+ }
27
+ const worldMatrices = [];
28
+ const worldMatrix = mesh.computeWorldMatrix(true);
29
+ if (mesh.hasThinInstances) {
30
+ const thinMatrices = mesh.thinInstanceGetWorldMatrices();
31
+ for (let instanceIndex = 0; instanceIndex < thinMatrices.length; instanceIndex++) {
32
+ const tmpMatrix = new Matrix();
33
+ const thinMatrix = thinMatrices[instanceIndex];
34
+ thinMatrix.multiplyToRef(worldMatrix, tmpMatrix);
35
+ worldMatrices.push(tmpMatrix);
36
+ }
37
+ }
38
+ else {
39
+ worldMatrices.push(worldMatrix);
40
+ }
41
+ const transformed = Vector3.Zero();
42
+ const position = Vector3.Zero();
43
+ for (let matrixIndex = 0; matrixIndex < worldMatrices.length; matrixIndex++) {
44
+ const wm = worldMatrices[matrixIndex];
45
+ for (tri = 0; tri < meshIndices.length; tri++) {
46
+ indices.push(meshIndices[tri] + offset);
47
+ }
48
+ for (pt = 0; pt < meshPositions.length; pt += 3) {
49
+ Vector3.FromArrayToRef(meshPositions, pt, position);
50
+ Vector3.TransformCoordinatesToRef(position, wm, transformed);
51
+ positions.push(transformed.x, transformed.y, transformed.z);
52
+ }
53
+ offset += meshPositions.length / 3;
54
+ }
55
+ }
56
+ }
57
+ return [Float32Array.from(positions), Uint32Array.from(indices)];
58
+ }
59
+ /**
60
+ * Reverses the order of vertices in each triangle (3 indices per face) to ensure
61
+ * that the winding order is consistent with the Recast Navigation requirements.
62
+ * This is necessary because Recast Navigation expects the indices to be in a specific winding order.
63
+ * @param meshOrIndices The mesh from which to extract indices or the indices themselves.
64
+ * @returns Array of indices with reversed winding order.
65
+ */
66
+ export function GetReversedIndices(meshOrIndices) {
67
+ const indices = meshOrIndices instanceof Mesh ? meshOrIndices.getIndices() : meshOrIndices;
68
+ if (indices) {
69
+ for (let i = 0; i < indices.length; i += 3) {
70
+ // Swap the second and third index to reverse the winding order
71
+ [indices[i + 1], indices[i + 2]] = [indices[i + 2], indices[i + 1]];
72
+ }
73
+ }
74
+ return indices;
75
+ }
76
+ //# sourceMappingURL=getters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getters.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/common/getters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,uCAA4B;AACnD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,0CAA+B;AACzD,OAAO,EAAE,IAAI,EAAE,oCAAyB;AAExC;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACjD,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,KAAa,CAAC;IAClB,IAAI,GAAW,CAAC;IAChB,IAAI,EAAU,CAAC;IACf,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,KAAK,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QAC7C,IAAI,MAAM,CAAC,KAAK,CAA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AC,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACxE,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC","sourcesContent":["import { VertexBuffer } from \"core/Buffers/buffer\";\nimport { Matrix, Vector3 } from \"core/Maths/math.vector\";\nimport { Mesh } from \"core/Meshes/mesh\";\n\n/**\n * Extracts positions and indices from an array of meshes.\n * @param meshes The array of meshes from which to extract positions and indices.\n * @returns A tuple containing a Float32Array of positions and a Uint32Array of\n */\nexport function GetPositionsAndIndices(meshes: Mesh[]): [positions: Float32Array, indices: Uint32Array] {\n let offset = 0;\n let index: number;\n let tri: number;\n let pt: number;\n const positions: number[] = [];\n const indices: number[] = [];\n\n for (index = 0; index < meshes.length; index++) {\n if (meshes[index]) {\n const mesh = meshes[index];\n\n const meshIndices = GetReversedIndices(mesh);\n if (!meshIndices) {\n continue;\n }\n\n const meshPositions = mesh.getVerticesData(VertexBuffer.PositionKind, false, false);\n if (!meshPositions) {\n continue;\n }\n\n const worldMatrices: Matrix[] = [];\n const worldMatrix = mesh.computeWorldMatrix(true);\n\n if (mesh.hasThinInstances) {\n const thinMatrices = (mesh as Mesh).thinInstanceGetWorldMatrices();\n for (let instanceIndex = 0; instanceIndex < thinMatrices.length; instanceIndex++) {\n const tmpMatrix = new Matrix();\n const thinMatrix = thinMatrices[instanceIndex];\n thinMatrix.multiplyToRef(worldMatrix, tmpMatrix);\n worldMatrices.push(tmpMatrix);\n }\n } else {\n worldMatrices.push(worldMatrix);\n }\n\n const transformed = Vector3.Zero();\n const position = Vector3.Zero();\n\n for (let matrixIndex = 0; matrixIndex < worldMatrices.length; matrixIndex++) {\n const wm = worldMatrices[matrixIndex];\n for (tri = 0; tri < meshIndices.length; tri++) {\n indices.push(meshIndices[tri] + offset);\n }\n\n for (pt = 0; pt < meshPositions.length; pt += 3) {\n Vector3.FromArrayToRef(meshPositions, pt, position);\n Vector3.TransformCoordinatesToRef(position, wm, transformed);\n positions.push(transformed.x, transformed.y, transformed.z);\n }\n\n offset += meshPositions.length / 3;\n }\n }\n }\n return [Float32Array.from(positions), Uint32Array.from(indices)];\n}\n\n/**\n * Reverses the order of vertices in each triangle (3 indices per face) to ensure\n * that the winding order is consistent with the Recast Navigation requirements.\n * This is necessary because Recast Navigation expects the indices to be in a specific winding order.\n * @param meshOrIndices The mesh from which to extract indices or the indices themselves.\n * @returns Array of indices with reversed winding order.\n */\nexport function GetReversedIndices(\n meshOrIndices: Mesh | Uint32Array | number[]\n): Uint32Array<ArrayBufferLike> | number[] | Int32Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | null {\n const indices = meshOrIndices instanceof Mesh ? meshOrIndices.getIndices() : meshOrIndices;\n\n if (indices) {\n for (let i = 0; i < indices.length; i += 3) {\n // Swap the second and third index to reverse the winding order\n [indices[i + 1], indices[i + 2]] = [indices[i + 2], indices[i + 1]];\n }\n }\n\n return indices;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ export * from "./config.js";
2
+ export * from "./convert.js";
3
+ export * from "./getters.js";
4
+ export * from "./smooth-path.js";
5
+ export * from "./utils.js";
6
+ export * from "./tile-cache.js";
@@ -0,0 +1,7 @@
1
+ export * from "./config.js";
2
+ export * from "./convert.js";
3
+ export * from "./getters.js";
4
+ export * from "./smooth-path.js";
5
+ export * from "./utils.js";
6
+ export * from "./tile-cache.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC","sourcesContent":["export * from \"./config\";\nexport * from \"./convert\";\nexport * from \"./getters\";\nexport * from \"./smooth-path\";\nexport * from \"./utils\";\nexport * from \"./tile-cache\";\n"]}
@@ -0,0 +1,32 @@
1
+ import type { NavMeshQuery, NavMesh, QueryFilter } from "@recast-navigation/core";
2
+ import type { IVector3Like } from "@onerjs/core/Maths/math.like.js";
3
+ import { Vector3 } from "@onerjs/core/Maths/math.vector.js";
4
+ /**
5
+ * Compute a smooth navigation path from start to end. Returns an empty array if no path can be computed
6
+ * @param navMesh the navigation mesh to use
7
+ * @param navmeshQuery the navigation mesh query to use
8
+ * @param start world position
9
+ * @param end world position
10
+ * @param options options object
11
+ * @returns array containing world position composing the path
12
+ */
13
+ export declare function ComputeSmoothPath(navMesh: NavMesh, navmeshQuery: NavMeshQuery, start: IVector3Like, end: IVector3Like, options?: {
14
+ filter?: QueryFilter;
15
+ halfExtents?: IVector3Like;
16
+ /**
17
+ * @default 256
18
+ */
19
+ maxPathPolys?: number;
20
+ /**
21
+ * @default 2048
22
+ */
23
+ maxSmoothPathPoints?: number;
24
+ /**
25
+ * @default 0.5
26
+ */
27
+ stepSize?: number;
28
+ /**
29
+ * @default 0.01
30
+ */
31
+ slop?: number;
32
+ }): Vector3[];