@loaders.gl/tile-converter 4.0.0-alpha.17 → 4.0.0-alpha.18

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 (48) hide show
  1. package/bin/converter.js +1 -1
  2. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +5 -4
  3. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  4. package/dist/3d-tiles-converter/3d-tiles-converter.js +39 -37
  5. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +3 -1
  6. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
  7. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +4 -2
  8. package/dist/3d-tiles-converter/helpers/load-i3s.d.ts +10 -0
  9. package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +1 -0
  10. package/dist/3d-tiles-converter/helpers/load-i3s.js +42 -0
  11. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +2 -1
  12. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +1 -1
  13. package/dist/3d-tiles-converter/helpers/texture-atlas.js +2 -0
  14. package/dist/converter.min.js +79 -79
  15. package/dist/dist.min.js +747 -3012
  16. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +94 -81
  17. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  18. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +6 -4
  19. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  20. package/dist/es5/3d-tiles-converter/helpers/load-i3s.js +63 -0
  21. package/dist/es5/3d-tiles-converter/helpers/load-i3s.js.map +1 -0
  22. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
  23. package/dist/es5/deps-installer/deps-installer.js +1 -1
  24. package/dist/es5/lib/utils/lod-conversion-utils.js +10 -4
  25. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
  26. package/dist/es5/pgm-loader.js +1 -1
  27. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +46 -43
  28. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  29. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +4 -3
  30. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  31. package/dist/esm/3d-tiles-converter/helpers/load-i3s.js +32 -0
  32. package/dist/esm/3d-tiles-converter/helpers/load-i3s.js.map +1 -0
  33. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
  34. package/dist/esm/deps-installer/deps-installer.js +1 -1
  35. package/dist/esm/i3s-server/bin/i3s-server.min.js +72 -72
  36. package/dist/esm/lib/utils/lod-conversion-utils.js +6 -4
  37. package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
  38. package/dist/esm/pgm-loader.js +1 -1
  39. package/dist/lib/utils/lod-conversion-utils.d.ts +2 -2
  40. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -1
  41. package/dist/lib/utils/lod-conversion-utils.js +4 -4
  42. package/dist/slpk-extractor.min.js +38 -38
  43. package/package.json +14 -14
  44. package/src/3d-tiles-converter/3d-tiles-converter.ts +60 -46
  45. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +11 -10
  46. package/src/3d-tiles-converter/helpers/load-i3s.ts +51 -0
  47. package/src/3d-tiles-converter/helpers/texture-atlas.ts +6 -2
  48. package/src/lib/utils/lod-conversion-utils.ts +10 -6
@@ -21,10 +21,12 @@ export function convertGeometricErrorToScreenThreshold(tile, coordinates) {
21
21
  return lodSelection;
22
22
  }
23
23
  export function convertScreenThresholdToGeometricError(node) {
24
- const metricData = node.header.lodSelection.maxScreenThreshold || {};
25
- let maxError = metricData.maxError;
24
+ var _node$lodSelection;
25
+ const metricData = (_node$lodSelection = node.lodSelection) === null || _node$lodSelection === void 0 ? void 0 : _node$lodSelection.find(metric => metric.metricType === 'maxScreenThreshold');
26
+ let maxError = metricData === null || metricData === void 0 ? void 0 : metricData.maxError;
26
27
  if (!maxError) {
27
- const sqMetricData = node.header.lodSelection.maxScreenThresholdSQ;
28
+ var _node$lodSelection2;
29
+ const sqMetricData = (_node$lodSelection2 = node.lodSelection) === null || _node$lodSelection2 === void 0 ? void 0 : _node$lodSelection2.find(metric => metric.metricType === 'maxScreenThresholdSQ');
28
30
  if (sqMetricData) {
29
31
  maxError = Math.sqrt(sqMetricData.maxError / (Math.PI * 0.25));
30
32
  }
@@ -32,6 +34,6 @@ export function convertScreenThresholdToGeometricError(node) {
32
34
  if (!maxError) {
33
35
  maxError = DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR;
34
36
  }
35
- return node.header.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR / maxError;
37
+ return node.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR / maxError;
36
38
  }
37
39
  //# sourceMappingURL=lod-conversion-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lod-conversion-utils.js","names":["DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR","convertGeometricErrorToScreenThreshold","tile","coordinates","lodSelection","boundingVolume","lodMetricValue","maxScreenThreshold","metricType","maxError","mbs","maxScreenThresholdSQ","Math","PI","constructor","name","push","convertScreenThresholdToGeometricError","node","metricData","header","sqMetricData","sqrt"],"sources":["../../../../src/lib/utils/lod-conversion-utils.ts"],"sourcesContent":["import {Tiles3DTileJSONPostprocessed} from '@loaders.gl/3d-tiles';\nimport {BoundingVolumes} from '@loaders.gl/i3s';\nimport {Tile3D} from '@loaders.gl/tiles';\n\n// https://cesium.com/docs/cesiumjs-ref-doc/Cesium3DTileset.html\nconst DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR = 16;\n/**\n * Do conversion from geometric error to screen threshold\n * \n * In 3DTiles we have HLOD logic and parent tile also has bigger lodMetric value then its children.\n * In I3s we have reverse logic related to maxError. Parent has lower maxError than its child.\n * In nodes where are no children tile.lodMetricValue is 0. This is because of logic of HLOD in 3DTiles\n * 3DTiles spec:\n * https://github.com/CesiumGS/3d-tiles/tree/master/specification#geometric-error\n * I3S spec:\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/lodSelection.cmn.md\n * To avoid infinity values when we do calculations of maxError we shold replace 0 with value which allows us\n * to make child maxError bigger than his parent maxError.\n * \n * @param tile - 3d-tiles tile JSON\n * @param coordinates - node converted coordinates\n * @returns An array of LOD metrics in format compatible with i3s 3DNodeIndexDocument.lodSelection\n * @example \n * [\n {\n \"metricType\": \"maxScreenThresholdSQ\",\n \"maxError\": 870638.071285568\n },\n {\n \"metricType\": \"maxScreenThreshold\",\n \"maxError\": 1052.8679031638949\n }\n ]\n */\nexport function convertGeometricErrorToScreenThreshold(\n tile: Tiles3DTileJSONPostprocessed,\n coordinates: BoundingVolumes\n) {\n const lodSelection: {metricType: string; maxError: number}[] = [];\n const boundingVolume = tile.boundingVolume;\n const lodMetricValue = tile.lodMetricValue || 0.1;\n const maxScreenThreshold = {\n metricType: 'maxScreenThreshold',\n maxError: (coordinates.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / lodMetricValue\n };\n const maxScreenThresholdSQ = {\n metricType: 'maxScreenThresholdSQ',\n maxError: Math.PI * 0.25 * maxScreenThreshold.maxError * maxScreenThreshold.maxError\n };\n\n if (boundingVolume.constructor.name === 'OrientedBoundingBox') {\n lodSelection.push(maxScreenThresholdSQ);\n lodSelection.push(maxScreenThreshold);\n } else {\n lodSelection.push(maxScreenThreshold);\n lodSelection.push(maxScreenThresholdSQ);\n }\n\n return lodSelection;\n}\n\n/**\n * Convert LOD metric from \"Screen Threshold\" to \"Screen Space Error\"\n * @param node - i3s node data\n * @returns lod metric in 3d-tiles format\n */\nexport function convertScreenThresholdToGeometricError(node: Tile3D): number {\n const metricData = node.header.lodSelection.maxScreenThreshold || {};\n let maxError = metricData.maxError;\n if (!maxError) {\n const sqMetricData = node.header.lodSelection.maxScreenThresholdSQ;\n if (sqMetricData) {\n maxError = Math.sqrt(sqMetricData.maxError / (Math.PI * 0.25));\n }\n }\n\n if (!maxError) {\n maxError = DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR;\n }\n\n return (node.header.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / maxError;\n}\n"],"mappings":"AAKA,MAAMA,kCAAkC,GAAG,EAAE;AA6B7C,OAAO,SAASC,sCAAsCA,CACpDC,IAAkC,EAClCC,WAA4B,EAC5B;EACA,MAAMC,YAAsD,GAAG,EAAE;EACjE,MAAMC,cAAc,GAAGH,IAAI,CAACG,cAAc;EAC1C,MAAMC,cAAc,GAAGJ,IAAI,CAACI,cAAc,IAAI,GAAG;EACjD,MAAMC,kBAAkB,GAAG;IACzBC,UAAU,EAAE,oBAAoB;IAChCC,QAAQ,EAAGN,WAAW,CAACO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAGV,kCAAkC,GAAIM;EAC5E,CAAC;EACD,MAAMK,oBAAoB,GAAG;IAC3BH,UAAU,EAAE,sBAAsB;IAClCC,QAAQ,EAAEG,IAAI,CAACC,EAAE,GAAG,IAAI,GAAGN,kBAAkB,CAACE,QAAQ,GAAGF,kBAAkB,CAACE;EAC9E,CAAC;EAED,IAAIJ,cAAc,CAACS,WAAW,CAACC,IAAI,KAAK,qBAAqB,EAAE;IAC7DX,YAAY,CAACY,IAAI,CAACL,oBAAoB,CAAC;IACvCP,YAAY,CAACY,IAAI,CAACT,kBAAkB,CAAC;EACvC,CAAC,MAAM;IACLH,YAAY,CAACY,IAAI,CAACT,kBAAkB,CAAC;IACrCH,YAAY,CAACY,IAAI,CAACL,oBAAoB,CAAC;EACzC;EAEA,OAAOP,YAAY;AACrB;AAOA,OAAO,SAASa,sCAAsCA,CAACC,IAAY,EAAU;EAC3E,MAAMC,UAAU,GAAGD,IAAI,CAACE,MAAM,CAAChB,YAAY,CAACG,kBAAkB,IAAI,CAAC,CAAC;EACpE,IAAIE,QAAQ,GAAGU,UAAU,CAACV,QAAQ;EAClC,IAAI,CAACA,QAAQ,EAAE;IACb,MAAMY,YAAY,GAAGH,IAAI,CAACE,MAAM,CAAChB,YAAY,CAACO,oBAAoB;IAClE,IAAIU,YAAY,EAAE;MAChBZ,QAAQ,GAAGG,IAAI,CAACU,IAAI,CAACD,YAAY,CAACZ,QAAQ,IAAIG,IAAI,CAACC,EAAE,GAAG,IAAI,CAAC,CAAC;IAChE;EACF;EAEA,IAAI,CAACJ,QAAQ,EAAE;IACbA,QAAQ,GAAGT,kCAAkC;EAC/C;EAEA,OAAQkB,IAAI,CAACE,MAAM,CAACV,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAGV,kCAAkC,GAAIS,QAAQ;AACjF"}
1
+ {"version":3,"file":"lod-conversion-utils.js","names":["DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR","convertGeometricErrorToScreenThreshold","tile","coordinates","lodSelection","boundingVolume","lodMetricValue","maxScreenThreshold","metricType","maxError","mbs","maxScreenThresholdSQ","Math","PI","constructor","name","push","convertScreenThresholdToGeometricError","node","_node$lodSelection","metricData","find","metric","_node$lodSelection2","sqMetricData","sqrt"],"sources":["../../../../src/lib/utils/lod-conversion-utils.ts"],"sourcesContent":["import {Tiles3DTileJSONPostprocessed} from '@loaders.gl/3d-tiles';\nimport {BoundingVolumes} from '@loaders.gl/i3s';\nimport {I3STileHeader} from '@loaders.gl/i3s/src/types';\n\n// https://cesium.com/docs/cesiumjs-ref-doc/Cesium3DTileset.html\nconst DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR = 16;\n/**\n * Do conversion from geometric error to screen threshold\n * \n * In 3DTiles we have HLOD logic and parent tile also has bigger lodMetric value then its children.\n * In I3s we have reverse logic related to maxError. Parent has lower maxError than its child.\n * In nodes where are no children tile.lodMetricValue is 0. This is because of logic of HLOD in 3DTiles\n * 3DTiles spec:\n * https://github.com/CesiumGS/3d-tiles/tree/master/specification#geometric-error\n * I3S spec:\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/lodSelection.cmn.md\n * To avoid infinity values when we do calculations of maxError we shold replace 0 with value which allows us\n * to make child maxError bigger than his parent maxError.\n * \n * @param tile - 3d-tiles tile JSON\n * @param coordinates - node converted coordinates\n * @returns An array of LOD metrics in format compatible with i3s 3DNodeIndexDocument.lodSelection\n * @example \n * [\n {\n \"metricType\": \"maxScreenThresholdSQ\",\n \"maxError\": 870638.071285568\n },\n {\n \"metricType\": \"maxScreenThreshold\",\n \"maxError\": 1052.8679031638949\n }\n ]\n */\nexport function convertGeometricErrorToScreenThreshold(\n tile: Tiles3DTileJSONPostprocessed,\n coordinates: BoundingVolumes\n) {\n const lodSelection: {metricType: string; maxError: number}[] = [];\n const boundingVolume = tile.boundingVolume;\n const lodMetricValue = tile.lodMetricValue || 0.1;\n const maxScreenThreshold = {\n metricType: 'maxScreenThreshold',\n maxError: (coordinates.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / lodMetricValue\n };\n const maxScreenThresholdSQ = {\n metricType: 'maxScreenThresholdSQ',\n maxError: Math.PI * 0.25 * maxScreenThreshold.maxError * maxScreenThreshold.maxError\n };\n\n if (boundingVolume.constructor.name === 'OrientedBoundingBox') {\n lodSelection.push(maxScreenThresholdSQ);\n lodSelection.push(maxScreenThreshold);\n } else {\n lodSelection.push(maxScreenThreshold);\n lodSelection.push(maxScreenThresholdSQ);\n }\n\n return lodSelection;\n}\n\n/**\n * Convert LOD metric from \"Screen Threshold\" to \"Screen Space Error\"\n * @param node - i3s node data\n * @returns lod metric in 3d-tiles format\n */\nexport function convertScreenThresholdToGeometricError(node: I3STileHeader): number {\n const metricData = node.lodSelection?.find(\n (metric) => metric.metricType === 'maxScreenThreshold'\n );\n let maxError = metricData?.maxError;\n if (!maxError) {\n const sqMetricData = node.lodSelection?.find(\n (metric) => metric.metricType === 'maxScreenThresholdSQ'\n );\n if (sqMetricData) {\n maxError = Math.sqrt(sqMetricData.maxError / (Math.PI * 0.25));\n }\n }\n\n if (!maxError) {\n maxError = DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR;\n }\n\n return (node.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / maxError;\n}\n"],"mappings":"AAKA,MAAMA,kCAAkC,GAAG,EAAE;AA6B7C,OAAO,SAASC,sCAAsCA,CACpDC,IAAkC,EAClCC,WAA4B,EAC5B;EACA,MAAMC,YAAsD,GAAG,EAAE;EACjE,MAAMC,cAAc,GAAGH,IAAI,CAACG,cAAc;EAC1C,MAAMC,cAAc,GAAGJ,IAAI,CAACI,cAAc,IAAI,GAAG;EACjD,MAAMC,kBAAkB,GAAG;IACzBC,UAAU,EAAE,oBAAoB;IAChCC,QAAQ,EAAGN,WAAW,CAACO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAGV,kCAAkC,GAAIM;EAC5E,CAAC;EACD,MAAMK,oBAAoB,GAAG;IAC3BH,UAAU,EAAE,sBAAsB;IAClCC,QAAQ,EAAEG,IAAI,CAACC,EAAE,GAAG,IAAI,GAAGN,kBAAkB,CAACE,QAAQ,GAAGF,kBAAkB,CAACE;EAC9E,CAAC;EAED,IAAIJ,cAAc,CAACS,WAAW,CAACC,IAAI,KAAK,qBAAqB,EAAE;IAC7DX,YAAY,CAACY,IAAI,CAACL,oBAAoB,CAAC;IACvCP,YAAY,CAACY,IAAI,CAACT,kBAAkB,CAAC;EACvC,CAAC,MAAM;IACLH,YAAY,CAACY,IAAI,CAACT,kBAAkB,CAAC;IACrCH,YAAY,CAACY,IAAI,CAACL,oBAAoB,CAAC;EACzC;EAEA,OAAOP,YAAY;AACrB;AAOA,OAAO,SAASa,sCAAsCA,CAACC,IAAmB,EAAU;EAAA,IAAAC,kBAAA;EAClF,MAAMC,UAAU,IAAAD,kBAAA,GAAGD,IAAI,CAACd,YAAY,cAAAe,kBAAA,uBAAjBA,kBAAA,CAAmBE,IAAI,CACvCC,MAAM,IAAKA,MAAM,CAACd,UAAU,KAAK,oBACpC,CAAC;EACD,IAAIC,QAAQ,GAAGW,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEX,QAAQ;EACnC,IAAI,CAACA,QAAQ,EAAE;IAAA,IAAAc,mBAAA;IACb,MAAMC,YAAY,IAAAD,mBAAA,GAAGL,IAAI,CAACd,YAAY,cAAAmB,mBAAA,uBAAjBA,mBAAA,CAAmBF,IAAI,CACzCC,MAAM,IAAKA,MAAM,CAACd,UAAU,KAAK,sBACpC,CAAC;IACD,IAAIgB,YAAY,EAAE;MAChBf,QAAQ,GAAGG,IAAI,CAACa,IAAI,CAACD,YAAY,CAACf,QAAQ,IAAIG,IAAI,CAACC,EAAE,GAAG,IAAI,CAAC,CAAC;IAChE;EACF;EAEA,IAAI,CAACJ,QAAQ,EAAE;IACbA,QAAQ,GAAGT,kCAAkC;EAC/C;EAEA,OAAQkB,IAAI,CAACR,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAGV,kCAAkC,GAAIS,QAAQ;AAC1E"}
@@ -1,5 +1,5 @@
1
1
  import { parsePGM } from '@math.gl/geoid';
2
- const VERSION = typeof "4.0.0-alpha.17" !== 'undefined' ? "4.0.0-alpha.17" : 'latest';
2
+ const VERSION = typeof "4.0.0-alpha.18" !== 'undefined' ? "4.0.0-alpha.18" : 'latest';
3
3
  export const PGMLoader = {
4
4
  name: 'PGM - Netpbm grayscale image format',
5
5
  id: 'pgm',
@@ -1,6 +1,6 @@
1
1
  import { Tiles3DTileJSONPostprocessed } from '@loaders.gl/3d-tiles';
2
2
  import { BoundingVolumes } from '@loaders.gl/i3s';
3
- import { Tile3D } from '@loaders.gl/tiles';
3
+ import { I3STileHeader } from '@loaders.gl/i3s/src/types';
4
4
  /**
5
5
  * Do conversion from geometric error to screen threshold
6
6
  *
@@ -38,5 +38,5 @@ export declare function convertGeometricErrorToScreenThreshold(tile: Tiles3DTile
38
38
  * @param node - i3s node data
39
39
  * @returns lod metric in 3d-tiles format
40
40
  */
41
- export declare function convertScreenThresholdToGeometricError(node: Tile3D): number;
41
+ export declare function convertScreenThresholdToGeometricError(node: I3STileHeader): number;
42
42
  //# sourceMappingURL=lod-conversion-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lod-conversion-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/lod-conversion-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,4BAA4B,EAAC,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AAIzC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,sCAAsC,CACpD,IAAI,EAAE,4BAA4B,EAClC,WAAW,EAAE,eAAe;gBAEK,MAAM;cAAY,MAAM;IAqB1D;AAED;;;;GAIG;AACH,wBAAgB,sCAAsC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAe3E"}
1
+ {"version":3,"file":"lod-conversion-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/lod-conversion-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,4BAA4B,EAAC,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAIxD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,sCAAsC,CACpD,IAAI,EAAE,4BAA4B,EAClC,WAAW,EAAE,eAAe;gBAEK,MAAM;cAAY,MAAM;IAqB1D;AAED;;;;GAIG;AACH,wBAAgB,sCAAsC,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAmBlF"}
@@ -60,10 +60,10 @@ exports.convertGeometricErrorToScreenThreshold = convertGeometricErrorToScreenTh
60
60
  * @returns lod metric in 3d-tiles format
61
61
  */
62
62
  function convertScreenThresholdToGeometricError(node) {
63
- const metricData = node.header.lodSelection.maxScreenThreshold || {};
64
- let maxError = metricData.maxError;
63
+ const metricData = node.lodSelection?.find((metric) => metric.metricType === 'maxScreenThreshold');
64
+ let maxError = metricData?.maxError;
65
65
  if (!maxError) {
66
- const sqMetricData = node.header.lodSelection.maxScreenThresholdSQ;
66
+ const sqMetricData = node.lodSelection?.find((metric) => metric.metricType === 'maxScreenThresholdSQ');
67
67
  if (sqMetricData) {
68
68
  maxError = Math.sqrt(sqMetricData.maxError / (Math.PI * 0.25));
69
69
  }
@@ -71,6 +71,6 @@ function convertScreenThresholdToGeometricError(node) {
71
71
  if (!maxError) {
72
72
  maxError = DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR;
73
73
  }
74
- return (node.header.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / maxError;
74
+ return (node.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / maxError;
75
75
  }
76
76
  exports.convertScreenThresholdToGeometricError = convertScreenThresholdToGeometricError;