@loaders.gl/i3s 4.2.0-alpha.4 → 4.2.0-alpha.6

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 (89) hide show
  1. package/dist/arcgis-webscene-loader.d.ts +1 -1
  2. package/dist/arcgis-webscene-loader.d.ts.map +1 -1
  3. package/dist/arcgis-webscene-loader.js +20 -11
  4. package/dist/dist.dev.js +1244 -722
  5. package/dist/dist.min.js +9 -0
  6. package/dist/i3s-attribute-loader.d.ts +2 -2
  7. package/dist/i3s-attribute-loader.d.ts.map +1 -1
  8. package/dist/i3s-attribute-loader.js +146 -95
  9. package/dist/i3s-building-scene-layer-loader.d.ts +2 -2
  10. package/dist/i3s-building-scene-layer-loader.d.ts.map +1 -1
  11. package/dist/i3s-building-scene-layer-loader.js +18 -14
  12. package/dist/i3s-content-loader.d.ts +2 -2
  13. package/dist/i3s-content-loader.d.ts.map +1 -1
  14. package/dist/i3s-content-loader.js +24 -25
  15. package/dist/i3s-content-worker-node.js +46 -46
  16. package/dist/i3s-content-worker-node.js.map +4 -4
  17. package/dist/i3s-content-worker.js +15 -27
  18. package/dist/i3s-loader.d.ts +2 -2
  19. package/dist/i3s-loader.d.ts.map +1 -1
  20. package/dist/i3s-loader.js +78 -66
  21. package/dist/i3s-node-page-loader.d.ts +2 -2
  22. package/dist/i3s-node-page-loader.d.ts.map +1 -1
  23. package/dist/i3s-node-page-loader.js +17 -13
  24. package/dist/i3s-slpk-loader.js +19 -15
  25. package/dist/index.cjs +92 -163
  26. package/dist/index.cjs.map +7 -0
  27. package/dist/index.d.ts +14 -14
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +3 -1
  30. package/dist/lib/helpers/i3s-nodepages-tiles.d.ts +1 -1
  31. package/dist/lib/helpers/i3s-nodepages-tiles.d.ts.map +1 -1
  32. package/dist/lib/helpers/i3s-nodepages-tiles.js +230 -184
  33. package/dist/lib/parsers/constants.js +72 -45
  34. package/dist/lib/parsers/parse-arcgis-webscene.d.ts +1 -1
  35. package/dist/lib/parsers/parse-arcgis-webscene.d.ts.map +1 -1
  36. package/dist/lib/parsers/parse-arcgis-webscene.js +80 -59
  37. package/dist/lib/parsers/parse-i3s-attribute.js +83 -46
  38. package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts +1 -1
  39. package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts.map +1 -1
  40. package/dist/lib/parsers/parse-i3s-building-scene-layer.js +36 -33
  41. package/dist/lib/parsers/parse-i3s-tile-content.d.ts +1 -1
  42. package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -1
  43. package/dist/lib/parsers/parse-i3s-tile-content.js +433 -388
  44. package/dist/lib/parsers/parse-i3s.d.ts +1 -1
  45. package/dist/lib/parsers/parse-i3s.d.ts.map +1 -1
  46. package/dist/lib/parsers/parse-i3s.js +84 -81
  47. package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts +1 -1
  48. package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts.map +1 -1
  49. package/dist/lib/parsers/parse-slpk/parse-slpk.js +23 -16
  50. package/dist/lib/parsers/parse-slpk/slpk-archieve.js +134 -97
  51. package/dist/lib/utils/convert-i3s-obb-to-mbs.js +12 -5
  52. package/dist/lib/utils/customize-colors.d.ts +1 -1
  53. package/dist/lib/utils/customize-colors.d.ts.map +1 -1
  54. package/dist/lib/utils/customize-colors.js +95 -81
  55. package/dist/lib/utils/url-utils.d.ts +1 -1
  56. package/dist/lib/utils/url-utils.d.ts.map +1 -1
  57. package/dist/lib/utils/url-utils.js +48 -28
  58. package/dist/types.d.ts +1 -1
  59. package/dist/types.d.ts.map +1 -1
  60. package/dist/types.js +5 -6
  61. package/dist/workers/i3s-content-worker-node.js +1 -1
  62. package/dist/workers/i3s-content-worker.js +0 -1
  63. package/package.json +15 -12
  64. package/src/i3s-loader.ts +2 -1
  65. package/src/lib/helpers/i3s-nodepages-tiles.ts +1 -3
  66. package/src/lib/parsers/parse-i3s-tile-content.ts +4 -26
  67. package/dist/arcgis-webscene-loader.js.map +0 -1
  68. package/dist/i3s-attribute-loader.js.map +0 -1
  69. package/dist/i3s-building-scene-layer-loader.js.map +0 -1
  70. package/dist/i3s-content-loader.js.map +0 -1
  71. package/dist/i3s-loader.js.map +0 -1
  72. package/dist/i3s-node-page-loader.js.map +0 -1
  73. package/dist/i3s-slpk-loader.js.map +0 -1
  74. package/dist/index.js.map +0 -1
  75. package/dist/lib/helpers/i3s-nodepages-tiles.js.map +0 -1
  76. package/dist/lib/parsers/constants.js.map +0 -1
  77. package/dist/lib/parsers/parse-arcgis-webscene.js.map +0 -1
  78. package/dist/lib/parsers/parse-i3s-attribute.js.map +0 -1
  79. package/dist/lib/parsers/parse-i3s-building-scene-layer.js.map +0 -1
  80. package/dist/lib/parsers/parse-i3s-tile-content.js.map +0 -1
  81. package/dist/lib/parsers/parse-i3s.js.map +0 -1
  82. package/dist/lib/parsers/parse-slpk/parse-slpk.js.map +0 -1
  83. package/dist/lib/parsers/parse-slpk/slpk-archieve.js.map +0 -1
  84. package/dist/lib/utils/convert-i3s-obb-to-mbs.js.map +0 -1
  85. package/dist/lib/utils/customize-colors.js.map +0 -1
  86. package/dist/lib/utils/url-utils.js.map +0 -1
  87. package/dist/types.js.map +0 -1
  88. package/dist/workers/i3s-content-worker-node.js.map +0 -1
  89. package/dist/workers/i3s-content-worker.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { I3STilesetHeader, I3STileHeader, I3SMinimalNodeData, Node3DIndexDocument, SceneLayer3D } from '../../types';
1
+ import { I3STilesetHeader, I3STileHeader, I3SMinimalNodeData, Node3DIndexDocument, SceneLayer3D } from "../../types.js";
2
2
  import type { LoaderOptions, LoaderContext } from '@loaders.gl/loader-utils';
3
3
  export declare function normalizeTileData(tile: Node3DIndexDocument, context: LoaderContext): I3STileHeader;
4
4
  export declare function normalizeTileNonUrlData(tile: I3SMinimalNodeData): I3STileHeader;
@@ -1 +1 @@
1
- {"version":3,"file":"parse-i3s.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-i3s.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,gBAAgB,EAChB,aAAa,EAEb,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EAEb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAG3E,wBAAgB,iBAAiB,CAAC,IAAI,EAAG,mBAAmB,EAAE,OAAO,EAAE,aAAa,GAAG,aAAa,CA6BnG;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAG,kBAAkB,GAAG,aAAa,CAkChF;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAG,YAAY,EAAE,OAAO,EAAG,aAAa,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,GAAG,gBAAgB,CAAC,CAgC7J"}
1
+ {"version":3,"file":"parse-i3s.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-i3s.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,gBAAgB,EAChB,aAAa,EAEb,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EAEb,uBAAoB;AACrB,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAG3E,wBAAgB,iBAAiB,CAAC,IAAI,EAAG,mBAAmB,EAAE,OAAO,EAAE,aAAa,GAAG,aAAa,CA6BnG;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAG,kBAAkB,GAAG,aAAa,CAkChF;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAG,YAAY,EAAE,OAAO,EAAG,aAAa,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,GAAG,gBAAgB,CAAC,CAgC7J"}
@@ -6,89 +6,92 @@ import I3SNodePagesTiles from "../helpers/i3s-nodepages-tiles.js";
6
6
  import { generateTileAttributeUrls, getUrlWithToken, getUrlWithoutParams } from "../utils/url-utils.js";
7
7
  import { I3SLoader } from "../../i3s-loader.js";
8
8
  export function normalizeTileData(tile, context) {
9
- const url = context.url || '';
10
- let contentUrl;
11
- if (tile.geometryData) {
12
- contentUrl = `${url}/${tile.geometryData[0].href}`;
13
- }
14
- let textureUrl;
15
- if (tile.textureData) {
16
- textureUrl = `${url}/${tile.textureData[0].href}`;
17
- }
18
- let attributeUrls;
19
- if (tile.attributeData) {
20
- attributeUrls = generateTileAttributeUrls(url, tile);
21
- }
22
- const children = tile.children || [];
23
- return normalizeTileNonUrlData({
24
- ...tile,
25
- children,
26
- url,
27
- contentUrl,
28
- textureUrl,
29
- textureFormat: 'jpg',
30
- attributeUrls,
31
- isDracoGeometry: false
32
- });
9
+ const url = context.url || '';
10
+ let contentUrl;
11
+ if (tile.geometryData) {
12
+ contentUrl = `${url}/${tile.geometryData[0].href}`;
13
+ }
14
+ let textureUrl;
15
+ if (tile.textureData) {
16
+ textureUrl = `${url}/${tile.textureData[0].href}`;
17
+ }
18
+ let attributeUrls;
19
+ if (tile.attributeData) {
20
+ attributeUrls = generateTileAttributeUrls(url, tile);
21
+ }
22
+ const children = tile.children || [];
23
+ return normalizeTileNonUrlData({
24
+ ...tile,
25
+ children,
26
+ url,
27
+ contentUrl,
28
+ textureUrl,
29
+ textureFormat: 'jpg', // `jpg` format will cause `ImageLoader` usage that will be able to handle `png` as well
30
+ attributeUrls,
31
+ isDracoGeometry: false
32
+ });
33
33
  }
34
34
  export function normalizeTileNonUrlData(tile) {
35
- var _tile$lodSelection, _tile$lodSelection2;
36
- const boundingVolume = {};
37
- let mbs = [0, 0, 0, 1];
38
- if (tile.mbs) {
39
- mbs = tile.mbs;
40
- boundingVolume.sphere = [...Ellipsoid.WGS84.cartographicToCartesian(tile.mbs.slice(0, 3)), tile.mbs[3]];
41
- } else if (tile.obb) {
42
- boundingVolume.box = [...Ellipsoid.WGS84.cartographicToCartesian(tile.obb.center), ...tile.obb.halfSize, ...tile.obb.quaternion];
43
- const obb = new OrientedBoundingBox().fromCenterHalfSizeQuaternion(boundingVolume.box.slice(0, 3), tile.obb.halfSize, tile.obb.quaternion);
44
- const boundingSphere = obb.getBoundingSphere();
45
- boundingVolume.sphere = [...boundingSphere.center, boundingSphere.radius];
46
- mbs = [...tile.obb.center, boundingSphere.radius];
47
- }
48
- const lodMetricType = (_tile$lodSelection = tile.lodSelection) === null || _tile$lodSelection === void 0 ? void 0 : _tile$lodSelection[0].metricType;
49
- const lodMetricValue = (_tile$lodSelection2 = tile.lodSelection) === null || _tile$lodSelection2 === void 0 ? void 0 : _tile$lodSelection2[0].maxError;
50
- const type = TILE_TYPE.MESH;
51
- const refine = TILE_REFINEMENT.REPLACE;
52
- return {
53
- ...tile,
54
- mbs,
55
- boundingVolume,
56
- lodMetricType,
57
- lodMetricValue,
58
- type,
59
- refine
60
- };
35
+ const boundingVolume = {};
36
+ let mbs = [0, 0, 0, 1];
37
+ if (tile.mbs) {
38
+ mbs = tile.mbs;
39
+ boundingVolume.sphere = [
40
+ ...Ellipsoid.WGS84.cartographicToCartesian(tile.mbs.slice(0, 3)), // cartesian center of sphere
41
+ tile.mbs[3] // radius of sphere
42
+ ];
43
+ }
44
+ else if (tile.obb) {
45
+ boundingVolume.box = [
46
+ ...Ellipsoid.WGS84.cartographicToCartesian(tile.obb.center), // cartesian center of box
47
+ ...tile.obb.halfSize, // halfSize
48
+ ...tile.obb.quaternion // quaternion
49
+ ];
50
+ const obb = new OrientedBoundingBox().fromCenterHalfSizeQuaternion(boundingVolume.box.slice(0, 3), tile.obb.halfSize, tile.obb.quaternion);
51
+ const boundingSphere = obb.getBoundingSphere();
52
+ boundingVolume.sphere = [...boundingSphere.center, boundingSphere.radius];
53
+ mbs = [...tile.obb.center, boundingSphere.radius];
54
+ }
55
+ const lodMetricType = tile.lodSelection?.[0].metricType;
56
+ const lodMetricValue = tile.lodSelection?.[0].maxError;
57
+ const type = TILE_TYPE.MESH;
58
+ /**
59
+ * I3S specification supports only REPLACE
60
+ */
61
+ const refine = TILE_REFINEMENT.REPLACE;
62
+ return { ...tile, mbs, boundingVolume, lodMetricType, lodMetricValue, type, refine };
61
63
  }
62
64
  export async function normalizeTilesetData(tileset, options, context) {
63
- const url = getUrlWithoutParams(context.url || '');
64
- let nodePagesTile;
65
- let root;
66
- if (tileset.nodePages) {
67
- nodePagesTile = new I3SNodePagesTiles(tileset, url, options);
68
- root = await nodePagesTile.formTileFromNodePages(0);
69
- } else {
70
- const parseOptions = options.i3s;
71
- const rootNodeUrl = getUrlWithToken(`${url}/nodes/root`, parseOptions.token);
72
- root = await load(rootNodeUrl, I3SLoader, {
73
- ...options,
74
- i3s: {
75
- ...options.i3s,
76
- loadContent: false,
77
- isTileHeader: true,
78
- isTileset: false
79
- }
80
- });
81
- }
82
- return {
83
- ...tileset,
84
- loader: I3SLoader,
85
- url,
86
- basePath: url,
87
- type: TILESET_TYPE.I3S,
88
- nodePagesTile,
89
- root,
90
- lodMetricType: root.lodMetricType,
91
- lodMetricValue: root.lodMetricValue
92
- };
65
+ const url = getUrlWithoutParams(context.url || '');
66
+ let nodePagesTile;
67
+ let root;
68
+ if (tileset.nodePages) {
69
+ nodePagesTile = new I3SNodePagesTiles(tileset, url, options);
70
+ root = await nodePagesTile.formTileFromNodePages(0);
71
+ }
72
+ else {
73
+ const parseOptions = options.i3s;
74
+ const rootNodeUrl = getUrlWithToken(`${url}/nodes/root`, parseOptions.token);
75
+ // eslint-disable-next-line no-use-before-define
76
+ root = await load(rootNodeUrl, I3SLoader, {
77
+ ...options,
78
+ i3s: {
79
+ // @ts-expect-error options is not properly typed
80
+ ...options.i3s,
81
+ loadContent: false, isTileHeader: true, isTileset: false
82
+ }
83
+ });
84
+ }
85
+ return {
86
+ ...tileset,
87
+ loader: I3SLoader,
88
+ url,
89
+ basePath: url,
90
+ type: TILESET_TYPE.I3S,
91
+ nodePagesTile,
92
+ // @ts-expect-error
93
+ root,
94
+ lodMetricType: root.lodMetricType,
95
+ lodMetricValue: root.lodMetricValue
96
+ };
93
97
  }
94
- //# sourceMappingURL=parse-i3s.js.map
@@ -1,5 +1,5 @@
1
1
  import { FileProvider } from '@loaders.gl/loader-utils';
2
- import { SLPKArchive } from './slpk-archieve';
2
+ import { SLPKArchive } from "./slpk-archieve.js";
3
3
  /**
4
4
  * Creates slpk file handler from raw file
5
5
  * @param fileProvider raw file data
@@ -1 +1 @@
1
- {"version":3,"file":"parse-slpk.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-slpk/parse-slpk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAStD,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAE5C;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,YAAY,EAAE,YAAY,EAC1B,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,EAC1B,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,WAAW,CAAC,CA+BtB"}
1
+ {"version":3,"file":"parse-slpk.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-slpk/parse-slpk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAStD,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAE5C;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,YAAY,EAAE,YAAY,EAC1B,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,EAC1B,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,WAAW,CAAC,CA+BtB"}
@@ -1,21 +1,28 @@
1
1
  import { parseZipCDFileHeader, CD_HEADER_SIGNATURE, parseZipLocalFileHeader, searchFromTheEnd, parseHashTable, makeHashTableFromZipHeaders } from '@loaders.gl/zip';
2
2
  import { SLPKArchive } from "./slpk-archieve.js";
3
+ /**
4
+ * Creates slpk file handler from raw file
5
+ * @param fileProvider raw file data
6
+ * @param cb is called with information message during parsing
7
+ * @returns slpk file handler
8
+ */
3
9
  export async function parseSLPKArchive(fileProvider, cb, fileName) {
4
- const hashCDOffset = await searchFromTheEnd(fileProvider, CD_HEADER_SIGNATURE);
5
- const cdFileHeader = await parseZipCDFileHeader(hashCDOffset, fileProvider);
6
- let hashTable;
7
- if ((cdFileHeader === null || cdFileHeader === void 0 ? void 0 : cdFileHeader.fileName) !== '@specialIndexFileHASH128@') {
8
- hashTable = await makeHashTableFromZipHeaders(fileProvider);
9
- cb === null || cb === void 0 ? void 0 : cb('SLPK doesnt contain hash file, hash info has been composed according to zip archive headers');
10
- } else {
11
- const localFileHeader = await parseZipLocalFileHeader(cdFileHeader.localHeaderOffset, fileProvider);
12
- if (!localFileHeader) {
13
- throw new Error('corrupted SLPK');
10
+ const hashCDOffset = await searchFromTheEnd(fileProvider, CD_HEADER_SIGNATURE);
11
+ const cdFileHeader = await parseZipCDFileHeader(hashCDOffset, fileProvider);
12
+ let hashTable;
13
+ if (cdFileHeader?.fileName !== '@specialIndexFileHASH128@') {
14
+ hashTable = await makeHashTableFromZipHeaders(fileProvider);
15
+ cb?.('SLPK doesnt contain hash file, hash info has been composed according to zip archive headers');
14
16
  }
15
- const fileDataOffset = localFileHeader.fileDataOffset;
16
- const hashFile = await fileProvider.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
17
- hashTable = parseHashTable(hashFile);
18
- }
19
- return new SLPKArchive(fileProvider, hashTable, fileName);
17
+ else {
18
+ // cb?.('SLPK contains hash file');
19
+ const localFileHeader = await parseZipLocalFileHeader(cdFileHeader.localHeaderOffset, fileProvider);
20
+ if (!localFileHeader) {
21
+ throw new Error('corrupted SLPK');
22
+ }
23
+ const fileDataOffset = localFileHeader.fileDataOffset;
24
+ const hashFile = await fileProvider.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
25
+ hashTable = parseHashTable(hashFile);
26
+ }
27
+ return new SLPKArchive(fileProvider, hashTable, fileName);
20
28
  }
21
- //# sourceMappingURL=parse-slpk.js.map
@@ -1,107 +1,144 @@
1
1
  import { MD5Hash } from '@loaders.gl/crypto';
2
2
  import { IndexedArchive, parseZipLocalFileHeader } from '@loaders.gl/zip';
3
3
  import { GZipCompression } from '@loaders.gl/compression';
4
- const PATH_DESCRIPTIONS = [{
5
- test: /^$/,
6
- extensions: ['3dSceneLayer.json.gz']
7
- }, {
8
- test: /^nodepages\/\d+$/,
9
- extensions: ['.json.gz']
10
- }, {
11
- test: /^nodes\/(\d+|root)$/,
12
- extensions: ['/3dNodeIndexDocument.json.gz']
13
- }, {
14
- test: /^nodes\/\d+\/textures\/.+$/,
15
- extensions: ['.jpg', '.png', '.bin.dds.gz', '.ktx']
16
- }, {
17
- test: /^nodes\/\d+\/geometries\/\d+$/,
18
- extensions: ['.bin.gz', '.draco.gz']
19
- }, {
20
- test: /^nodes\/\d+\/attributes\/f_\d+\/\d+$/,
21
- extensions: ['.bin.gz']
22
- }, {
23
- test: /^statistics\/f_\d+\/\d+$/,
24
- extensions: ['.json.gz']
25
- }, {
26
- test: /^nodes\/\d+\/shared$/,
27
- extensions: ['/sharedResource.json.gz']
28
- }];
4
+ /** Description of real paths for different file types */
5
+ const PATH_DESCRIPTIONS = [
6
+ {
7
+ test: /^$/,
8
+ extensions: ['3dSceneLayer.json.gz']
9
+ },
10
+ {
11
+ test: /^nodepages\/\d+$/,
12
+ extensions: ['.json.gz']
13
+ },
14
+ {
15
+ test: /^nodes\/(\d+|root)$/,
16
+ extensions: ['/3dNodeIndexDocument.json.gz']
17
+ },
18
+ {
19
+ test: /^nodes\/\d+\/textures\/.+$/,
20
+ extensions: ['.jpg', '.png', '.bin.dds.gz', '.ktx']
21
+ },
22
+ {
23
+ test: /^nodes\/\d+\/geometries\/\d+$/,
24
+ extensions: ['.bin.gz', '.draco.gz']
25
+ },
26
+ {
27
+ test: /^nodes\/\d+\/attributes\/f_\d+\/\d+$/,
28
+ extensions: ['.bin.gz']
29
+ },
30
+ {
31
+ test: /^statistics\/f_\d+\/\d+$/,
32
+ extensions: ['.json.gz']
33
+ },
34
+ {
35
+ test: /^nodes\/\d+\/shared$/,
36
+ extensions: ['/sharedResource.json.gz']
37
+ }
38
+ ];
39
+ /**
40
+ * Class for handling information about slpk file
41
+ */
29
42
  export class SLPKArchive extends IndexedArchive {
30
- constructor(fileProvider, hashTable, fileName) {
31
- super(fileProvider, hashTable, fileName);
32
- this.hashTable = void 0;
33
- this._textEncoder = new TextEncoder();
34
- this._textDecoder = new TextDecoder();
35
- this._md5Hash = new MD5Hash();
36
- this.hashTable = hashTable;
37
- }
38
- async getFile(path) {
39
- let mode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'raw';
40
- if (mode === 'http') {
41
- var _PATH_DESCRIPTIONS$fi;
42
- const extensions = (_PATH_DESCRIPTIONS$fi = PATH_DESCRIPTIONS.find(val => val.test.test(path))) === null || _PATH_DESCRIPTIONS$fi === void 0 ? void 0 : _PATH_DESCRIPTIONS$fi.extensions;
43
- if (extensions) {
44
- let data;
45
- for (const ext of extensions) {
46
- data = await this.getDataByPath(`${path}${ext}`);
47
- if (data) {
48
- break;
49
- }
43
+ // Maps hex-encoded md5 filename hashes to bigint offsets into the archive
44
+ hashTable;
45
+ _textEncoder = new TextEncoder();
46
+ _textDecoder = new TextDecoder();
47
+ _md5Hash = new MD5Hash();
48
+ /**
49
+ * Constructor
50
+ * @param fileProvider - instance of a binary data reader
51
+ * @param hashTable - pre-loaded hashTable. If presented, getFile will skip reading the hash file
52
+ * @param fileName - name of the archive. It is used to add to an URL of a loader context
53
+ */
54
+ constructor(fileProvider, hashTable, fileName) {
55
+ super(fileProvider, hashTable, fileName);
56
+ this.hashTable = hashTable;
57
+ }
58
+ /**
59
+ * Returns file with the given path from slpk archive
60
+ * @param path - path inside the slpk
61
+ * @param mode - currently only raw mode supported
62
+ * @returns buffer with ready to use file
63
+ */
64
+ async getFile(path, mode = 'raw') {
65
+ if (mode === 'http') {
66
+ const extensions = PATH_DESCRIPTIONS.find((val) => val.test.test(path))?.extensions;
67
+ if (extensions) {
68
+ let data;
69
+ for (const ext of extensions) {
70
+ data = await this.getDataByPath(`${path}${ext}`);
71
+ if (data) {
72
+ break;
73
+ }
74
+ }
75
+ if (data) {
76
+ return data;
77
+ }
78
+ }
50
79
  }
51
- if (data) {
52
- return data;
80
+ if (mode === 'raw') {
81
+ const decompressedFile = await this.getDataByPath(`${path}.gz`);
82
+ if (decompressedFile) {
83
+ return decompressedFile;
84
+ }
85
+ const fileWithoutCompression = await this.getFileBytes(path);
86
+ if (fileWithoutCompression) {
87
+ return fileWithoutCompression;
88
+ }
53
89
  }
54
- }
55
- }
56
- if (mode === 'raw') {
57
- const decompressedFile = await this.getDataByPath(`${path}.gz`);
58
- if (decompressedFile) {
59
- return decompressedFile;
60
- }
61
- const fileWithoutCompression = await this.getFileBytes(path);
62
- if (fileWithoutCompression) {
63
- return fileWithoutCompression;
64
- }
65
- }
66
- throw new Error(`No such file in the archive: ${path}`);
67
- }
68
- async getDataByPath(path) {
69
- let data = await this.getFileBytes(path.toLocaleLowerCase());
70
- if (!data) {
71
- data = await this.getFileBytes(path);
72
- }
73
- if (!data) {
74
- return undefined;
90
+ throw new Error(`No such file in the archive: ${path}`);
75
91
  }
76
- if (/\.gz$/.test(path)) {
77
- const compression = new GZipCompression();
78
- const decompressedData = await compression.decompress(data);
79
- return decompressedData;
92
+ /**
93
+ * returning uncompressed data for paths that ends with .gz and raw data for all other paths
94
+ * @param path - path inside the archive
95
+ * @returns buffer with the file data
96
+ */
97
+ async getDataByPath(path) {
98
+ // sometimes paths are not in lower case when hash file is created,
99
+ // so first we're looking for lower case file name and then for original one
100
+ let data = await this.getFileBytes(path.toLocaleLowerCase());
101
+ if (!data) {
102
+ data = await this.getFileBytes(path);
103
+ }
104
+ if (!data) {
105
+ return undefined;
106
+ }
107
+ if (/\.gz$/.test(path)) {
108
+ const compression = new GZipCompression();
109
+ const decompressedData = await compression.decompress(data);
110
+ return decompressedData;
111
+ }
112
+ return data;
80
113
  }
81
- return data;
82
- }
83
- async getFileBytes(path) {
84
- let compressedFile;
85
- if (this.hashTable) {
86
- const binaryPath = this._textEncoder.encode(path);
87
- const nameHash = await this._md5Hash.hash(binaryPath.buffer, 'hex');
88
- const offset = this.hashTable[nameHash];
89
- if (offset === undefined) {
90
- return undefined;
91
- }
92
- const localFileHeader = await parseZipLocalFileHeader(offset, this.fileProvider);
93
- if (!localFileHeader) {
94
- return undefined;
95
- }
96
- compressedFile = await this.fileProvider.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
97
- } else {
98
- try {
99
- compressedFile = await this.getFileWithoutHash(path);
100
- } catch {
101
- compressedFile = undefined;
102
- }
114
+ /**
115
+ * Trying to get raw file data by address
116
+ * @param path - path inside the archive
117
+ * @returns buffer with the raw file data
118
+ */
119
+ async getFileBytes(path) {
120
+ let compressedFile;
121
+ if (this.hashTable) {
122
+ const binaryPath = this._textEncoder.encode(path);
123
+ const nameHash = await this._md5Hash.hash(binaryPath.buffer, 'hex');
124
+ const offset = this.hashTable[nameHash];
125
+ if (offset === undefined) {
126
+ return undefined;
127
+ }
128
+ const localFileHeader = await parseZipLocalFileHeader(offset, this.fileProvider);
129
+ if (!localFileHeader) {
130
+ return undefined;
131
+ }
132
+ compressedFile = await this.fileProvider.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
133
+ }
134
+ else {
135
+ try {
136
+ compressedFile = await this.getFileWithoutHash(path);
137
+ }
138
+ catch {
139
+ compressedFile = undefined;
140
+ }
141
+ }
142
+ return compressedFile;
103
143
  }
104
- return compressedFile;
105
- }
106
144
  }
107
- //# sourceMappingURL=slpk-archieve.js.map
@@ -1,9 +1,16 @@
1
1
  import { BoundingSphere } from '@math.gl/culling';
2
2
  import { Ellipsoid } from '@math.gl/geospatial';
3
3
  export function convertI3SObbToMbs(obb) {
4
- const halfSize = obb.halfSize;
5
- const centerCartesian = Ellipsoid.WGS84.cartographicToCartesian(obb.center);
6
- const sphere = new BoundingSphere().fromCornerPoints([centerCartesian[0] - halfSize[0], centerCartesian[1] - halfSize[1], centerCartesian[2] - halfSize[2]], [centerCartesian[0] + halfSize[0], centerCartesian[1] + halfSize[1], centerCartesian[2] + halfSize[2]]);
7
- return [...obb.center, sphere.radius];
4
+ const halfSize = obb.halfSize;
5
+ const centerCartesian = Ellipsoid.WGS84.cartographicToCartesian(obb.center);
6
+ const sphere = new BoundingSphere().fromCornerPoints([
7
+ centerCartesian[0] - halfSize[0],
8
+ centerCartesian[1] - halfSize[1],
9
+ centerCartesian[2] - halfSize[2]
10
+ ], [
11
+ centerCartesian[0] + halfSize[0],
12
+ centerCartesian[1] + halfSize[1],
13
+ centerCartesian[2] + halfSize[2]
14
+ ]);
15
+ return [...obb.center, sphere.radius];
8
16
  }
9
- //# sourceMappingURL=convert-i3s-obb-to-mbs.js.map
@@ -1,5 +1,5 @@
1
1
  import type { MeshAttribute, TypedArray } from '@loaders.gl/schema';
2
- import type { AttributeStorageInfo, Field } from '../../types';
2
+ import type { AttributeStorageInfo, Field } from "../../types.js";
3
3
  type ColorsByAttribute = {
4
4
  /** Feature attribute name */
5
5
  attributeName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"customize-colors.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/customize-colors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAC,oBAAoB,EAAS,KAAK,EAAC,MAAM,aAAa,CAAC;AAOpE,KAAK,iBAAiB,GAAG;IACvB,6BAA6B;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,2FAA2F;IAC3F,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,2FAA2F;IAC3F,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,kIAAkI;IAClI,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;;;;;GAUG;AAEH,wBAAsB,eAAe,CACnC,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,MAAM,EAAE,GAAG,UAAU,EACjC,aAAa,EAAE,MAAM,EAAE,EACvB,MAAM,EAAE,KAAK,EAAE,EACf,oBAAoB,EAAE,oBAAoB,EAAE,EAC5C,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,EAC3C,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,aAAa,CAAC,CA2ExB"}
1
+ {"version":3,"file":"customize-colors.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/customize-colors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAC,oBAAoB,EAAS,KAAK,EAAC,uBAAoB;AAOpE,KAAK,iBAAiB,GAAG;IACvB,6BAA6B;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,2FAA2F;IAC3F,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,2FAA2F;IAC3F,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,kIAAkI;IAClI,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;;;;;GAUG;AAEH,wBAAsB,eAAe,CACnC,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,MAAM,EAAE,GAAG,UAAU,EACjC,aAAa,EAAE,MAAM,EAAE,EACvB,MAAM,EAAE,KAAK,EAAE,EACf,oBAAoB,EAAE,oBAAoB,EAAE,EAC5C,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,EAC3C,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,aAAa,CAAC,CA2ExB"}