@loaders.gl/i3s 3.4.6 → 4.0.0-alpha.10

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 (122) hide show
  1. package/dist/arcgis-webscene-loader.js +1 -1
  2. package/dist/dist.min.js +8452 -8866
  3. package/dist/es5/arcgis-webscene-loader.js +1 -1
  4. package/dist/es5/arcgis-webscene-loader.js.map +1 -1
  5. package/dist/es5/i3s-attribute-loader.js +18 -20
  6. package/dist/es5/i3s-attribute-loader.js.map +1 -1
  7. package/dist/es5/i3s-building-scene-layer-loader.js +1 -1
  8. package/dist/es5/i3s-building-scene-layer-loader.js.map +1 -1
  9. package/dist/es5/i3s-content-loader.js +2 -3
  10. package/dist/es5/i3s-content-loader.js.map +1 -1
  11. package/dist/es5/i3s-loader.js +1 -1
  12. package/dist/es5/i3s-loader.js.map +1 -1
  13. package/dist/es5/i3s-node-page-loader.js +4 -22
  14. package/dist/es5/i3s-node-page-loader.js.map +1 -1
  15. package/dist/es5/i3s-slpk-loader.js +1 -1
  16. package/dist/es5/i3s-slpk-loader.js.map +1 -1
  17. package/dist/es5/index.js +8 -1
  18. package/dist/es5/index.js.map +1 -1
  19. package/dist/es5/lib/parsers/parse-arcgis-webscene.js.map +1 -1
  20. package/dist/es5/lib/parsers/parse-i3s-attribute.js +7 -26
  21. package/dist/es5/lib/parsers/parse-i3s-attribute.js.map +1 -1
  22. package/dist/es5/lib/parsers/parse-i3s-tile-content.js +2 -2
  23. package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -1
  24. package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js +2 -2
  25. package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js.map +1 -1
  26. package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js +140 -23
  27. package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js.map +1 -1
  28. package/dist/es5/lib/utils/{customizeColors.js → customize-/321/201olors.js} +65 -40
  29. package/dist/es5/lib/utils/customize-/321/201olors.js.map +1 -0
  30. package/dist/es5/types.js.map +1 -1
  31. package/dist/es5/workers/{i3s-content-nodejs-worker.js → i3s-content-worker-node.js} +2 -2
  32. package/dist/es5/workers/i3s-content-worker-node.js.map +1 -0
  33. package/dist/esm/arcgis-webscene-loader.js +1 -1
  34. package/dist/esm/arcgis-webscene-loader.js.map +1 -1
  35. package/dist/esm/i3s-attribute-loader.js +2 -6
  36. package/dist/esm/i3s-attribute-loader.js.map +1 -1
  37. package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
  38. package/dist/esm/i3s-building-scene-layer-loader.js.map +1 -1
  39. package/dist/esm/i3s-content-loader.js +2 -3
  40. package/dist/esm/i3s-content-loader.js.map +1 -1
  41. package/dist/esm/i3s-loader.js +1 -1
  42. package/dist/esm/i3s-loader.js.map +1 -1
  43. package/dist/esm/i3s-node-page-loader.js +3 -7
  44. package/dist/esm/i3s-node-page-loader.js.map +1 -1
  45. package/dist/esm/i3s-slpk-loader.js +1 -1
  46. package/dist/esm/i3s-slpk-loader.js.map +1 -1
  47. package/dist/esm/index.js +2 -1
  48. package/dist/esm/index.js.map +1 -1
  49. package/dist/esm/lib/parsers/parse-arcgis-webscene.js.map +1 -1
  50. package/dist/esm/lib/parsers/parse-i3s-attribute.js +1 -1
  51. package/dist/esm/lib/parsers/parse-i3s-attribute.js.map +1 -1
  52. package/dist/esm/lib/parsers/parse-i3s-tile-content.js +1 -1
  53. package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -1
  54. package/dist/esm/lib/parsers/parse-slpk/parse-slpk.js +2 -2
  55. package/dist/esm/lib/parsers/parse-slpk/parse-slpk.js.map +1 -1
  56. package/dist/esm/lib/parsers/parse-slpk/slpk-archieve.js +59 -9
  57. package/dist/esm/lib/parsers/parse-slpk/slpk-archieve.js.map +1 -1
  58. package/dist/esm/lib/utils/{customizeColors.js → customize-/321/201olors.js} +9 -3
  59. package/dist/esm/lib/utils/customize-/321/201olors.js.map +1 -0
  60. package/dist/esm/types.js.map +1 -1
  61. package/dist/esm/workers/{i3s-content-nodejs-worker.js → i3s-content-worker-node.js} +2 -2
  62. package/dist/esm/workers/i3s-content-worker-node.js.map +1 -0
  63. package/dist/i3s-attribute-loader.d.ts +3 -2
  64. package/dist/i3s-attribute-loader.d.ts.map +1 -1
  65. package/dist/i3s-attribute-loader.js +2 -5
  66. package/dist/i3s-building-scene-layer-loader.js +1 -1
  67. package/dist/i3s-content-loader.d.ts.map +1 -1
  68. package/dist/i3s-content-loader.js +2 -3
  69. package/dist/i3s-content-worker-node.js +197 -0
  70. package/dist/{i3s-content-nodejs-worker.js.map → i3s-content-worker-node.js.map} +3 -3
  71. package/dist/i3s-content-worker.js +93 -527
  72. package/dist/i3s-node-page-loader.d.ts +3 -2
  73. package/dist/i3s-node-page-loader.d.ts.map +1 -1
  74. package/dist/i3s-node-page-loader.js +2 -6
  75. package/dist/i3s-slpk-loader.d.ts +6 -3
  76. package/dist/i3s-slpk-loader.d.ts.map +1 -1
  77. package/dist/index.d.ts +3 -2
  78. package/dist/index.d.ts.map +1 -1
  79. package/dist/index.js +6 -3
  80. package/dist/lib/parsers/parse-arcgis-webscene.js +1 -0
  81. package/dist/lib/parsers/parse-i3s-attribute.d.ts +6 -4
  82. package/dist/lib/parsers/parse-i3s-attribute.d.ts.map +1 -1
  83. package/dist/lib/parsers/parse-i3s-attribute.js +11 -10
  84. package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -1
  85. package/dist/lib/parsers/parse-i3s-tile-content.js +7 -2
  86. package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts.map +1 -1
  87. package/dist/lib/parsers/parse-slpk/parse-slpk.js +1 -1
  88. package/dist/lib/parsers/parse-slpk/slpk-archieve.d.ts +6 -0
  89. package/dist/lib/parsers/parse-slpk/slpk-archieve.d.ts.map +1 -1
  90. package/dist/lib/parsers/parse-slpk/slpk-archieve.js +72 -9
  91. package/dist/lib/utils/{customizeColors.d.ts → customize-/321/201olors.d.ts} +1 -1
  92. package/dist/lib/utils/customize-/321/201olors.d.ts.map +1 -0
  93. package/dist/lib/utils/{customizeColors.js → customize-/321/201olors.js} +18 -3
  94. package/dist/types.d.ts +1 -0
  95. package/dist/types.d.ts.map +1 -1
  96. package/dist/workers/i3s-content-worker-node.d.ts +2 -0
  97. package/dist/workers/i3s-content-worker-node.d.ts.map +1 -0
  98. package/dist/workers/{i3s-content-nodejs-worker.js → i3s-content-worker-node.js} +2 -1
  99. package/package.json +13 -13
  100. package/src/arcgis-webscene-loader.ts +1 -1
  101. package/src/i3s-attribute-loader.ts +7 -7
  102. package/src/i3s-building-scene-layer-loader.ts +1 -1
  103. package/src/i3s-content-loader.ts +2 -3
  104. package/src/i3s-node-page-loader.ts +6 -10
  105. package/src/i3s-slpk-loader.ts +5 -3
  106. package/src/index.ts +13 -7
  107. package/src/lib/parsers/parse-arcgis-webscene.ts +1 -0
  108. package/src/lib/parsers/parse-i3s-attribute.ts +21 -14
  109. package/src/lib/parsers/parse-i3s-tile-content.ts +6 -1
  110. package/src/lib/parsers/parse-slpk/parse-slpk.ts +4 -1
  111. package/src/lib/parsers/parse-slpk/slpk-archieve.ts +73 -9
  112. package/src/lib/utils/{customizeColors.ts → customize-/321/201olors.ts} +18 -3
  113. package/src/types.ts +1 -0
  114. package/src/workers/{i3s-content-nodejs-worker.ts → i3s-content-worker-node.ts} +2 -1
  115. package/dist/es5/lib/utils/customizeColors.js.map +0 -1
  116. package/dist/es5/workers/i3s-content-nodejs-worker.js.map +0 -1
  117. package/dist/esm/lib/utils/customizeColors.js.map +0 -1
  118. package/dist/esm/workers/i3s-content-nodejs-worker.js.map +0 -1
  119. package/dist/i3s-content-nodejs-worker.js +0 -198
  120. package/dist/lib/utils/customizeColors.d.ts.map +0 -1
  121. package/dist/workers/i3s-content-nodejs-worker.d.ts +0 -2
  122. package/dist/workers/i3s-content-nodejs-worker.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/i3s",
3
- "version": "3.4.6",
3
+ "version": "4.0.0-alpha.10",
4
4
  "description": "i3s .",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -27,19 +27,19 @@
27
27
  "README.md"
28
28
  ],
29
29
  "scripts": {
30
- "pre-build": "npm run build-bundle && npm run build-worker && npm run build-loader-worker-nodejs",
30
+ "pre-build": "npm run build-bundle && npm run build-worker && npm run build-worker-node",
31
31
  "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/dist.min.js",
32
- "build-worker": "esbuild src/workers/i3s-content-worker.ts --bundle --outfile=dist/i3s-content-worker.js --define:__VERSION__=\\\"$npm_package_version\\\"",
33
- "build-loader-worker-nodejs": "esbuild src/workers/i3s-content-nodejs-worker.ts --outfile=dist/i3s-content-nodejs-worker.js --platform=node --target=esnext,node12 --minify --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\""
32
+ "build-worker": "esbuild src/workers/i3s-content-worker.ts --outfile=dist/i3s-content-worker.js --target=esnext --bundle --define:__VERSION__=\\\"$npm_package_version\\\"",
33
+ "build-worker-node": "esbuild src/workers/i3s-content-worker-node.ts --outfile=dist/i3s-content-worker-node.js --platform=node --target=node16 --minify --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\""
34
34
  },
35
35
  "dependencies": {
36
- "@loaders.gl/compression": "3.4.6",
37
- "@loaders.gl/draco": "3.4.6",
38
- "@loaders.gl/images": "3.4.6",
39
- "@loaders.gl/loader-utils": "3.4.6",
40
- "@loaders.gl/schema": "3.4.6",
41
- "@loaders.gl/textures": "3.4.6",
42
- "@loaders.gl/tiles": "3.4.6",
36
+ "@loaders.gl/compression": "4.0.0-alpha.10",
37
+ "@loaders.gl/draco": "4.0.0-alpha.10",
38
+ "@loaders.gl/images": "4.0.0-alpha.10",
39
+ "@loaders.gl/loader-utils": "4.0.0-alpha.10",
40
+ "@loaders.gl/schema": "4.0.0-alpha.10",
41
+ "@loaders.gl/textures": "4.0.0-alpha.10",
42
+ "@loaders.gl/tiles": "4.0.0-alpha.10",
43
43
  "@luma.gl/constants": "^8.5.4",
44
44
  "@math.gl/core": "^3.5.1",
45
45
  "@math.gl/culling": "^3.5.1",
@@ -47,7 +47,7 @@
47
47
  "md5": "^2.3.0"
48
48
  },
49
49
  "peerDependencies": {
50
- "@loaders.gl/core": "^3.4.0"
50
+ "@loaders.gl/core": "^4.0.0-alpha.8"
51
51
  },
52
- "gitHead": "f878cbf97013ab99866390ef58e6ca26717af6cb"
52
+ "gitHead": "7efdbe09e02098aad6d985e4d6465d08806e19a9"
53
53
  }
@@ -5,7 +5,7 @@ import {parseWebscene} from './lib/parsers/parse-arcgis-webscene';
5
5
 
6
6
  // __VERSION__ is injected by babel-plugin-version-inline
7
7
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
8
- const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
8
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';
9
9
 
10
10
  /**
11
11
  * Loader for ArcGis WebScene
@@ -1,5 +1,6 @@
1
- import type {LoaderWithParser} from '@loaders.gl/loader-utils';
1
+ import type {LoaderOptions, LoaderWithParser} from '@loaders.gl/loader-utils';
2
2
  import {load} from '@loaders.gl/core';
3
+ import type {I3STileAttributes} from './lib/parsers/parse-i3s-attribute';
3
4
  import {parseI3STileAttribute} from './lib/parsers/parse-i3s-attribute';
4
5
  import {getUrlWithToken} from './lib/utils/url-utils';
5
6
 
@@ -8,25 +9,24 @@ import {getUrlWithToken} from './lib/utils/url-utils';
8
9
  const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
9
10
  const EMPTY_VALUE = '';
10
11
  const REJECTED_STATUS = 'rejected';
12
+
11
13
  /**
12
14
  * Loader for I3S attributes
13
15
  */
14
- export const I3SAttributeLoader: LoaderWithParser = {
16
+ export const I3SAttributeLoader: LoaderWithParser<I3STileAttributes, never, LoaderOptions> = {
15
17
  name: 'I3S Attribute',
16
18
  id: 'i3s-attribute',
17
19
  module: 'i3s',
18
20
  version: VERSION,
19
21
  mimeTypes: ['application/binary'],
20
- parse,
22
+ parse: async (arrayBuffer: ArrayBuffer, options?: LoaderOptions) => parseI3STileAttribute(arrayBuffer, options),
21
23
  extensions: ['bin'],
22
24
  options: {},
23
25
  binary: true
24
26
  };
25
27
 
26
- async function parse(data, options) {
27
- data = parseI3STileAttribute(data, options);
28
- return data;
29
- }
28
+
29
+ // TODO - these seem to use the loader rather than being part of the loader. Move to different file...
30
30
 
31
31
  /**
32
32
  * Load attributes based on feature id
@@ -6,7 +6,7 @@ import {parseBuildingSceneLayer} from './lib/parsers/parse-i3s-building-scene-la
6
6
  // __VERSION__ is injected by babel-plugin-version-inline
7
7
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
8
8
 
9
- const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
9
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';
10
10
  /**
11
11
  * Loader for I3S - Building Scene Layer
12
12
  */
@@ -1,4 +1,3 @@
1
- import {isBrowser} from '@loaders.gl/worker-utils';
2
1
  import type {LoaderWithParser, LoaderContext} from '@loaders.gl/loader-utils';
3
2
  import type {I3SLoaderOptions} from './i3s-loader';
4
3
  import {parseI3STileContent} from './lib/parsers/parse-i3s-tile-content';
@@ -7,13 +6,13 @@ import {I3STileOptions, I3STilesetOptions} from './types';
7
6
  // __VERSION__ is injected by babel-plugin-version-inline
8
7
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
9
8
 
10
- const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
9
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';
11
10
  /**
12
11
  * Loader for I3S - Indexed 3D Scene Layer
13
12
  */
14
13
  export const I3SContentLoader: LoaderWithParser = {
15
14
  name: 'I3S Content (Indexed Scene Layers)',
16
- id: isBrowser ? 'i3s-content' : 'i3s-content-nodejs',
15
+ id: 'i3s-content',
17
16
  module: 'i3s',
18
17
  worker: true,
19
18
  version: VERSION,
@@ -1,28 +1,24 @@
1
- import type {LoaderWithParser} from '@loaders.gl/loader-utils';
1
+ import type {LoaderOptions, LoaderWithParser} from '@loaders.gl/loader-utils';
2
+ import type {NodePage} from './types';
2
3
 
3
4
  // __VERSION__ is injected by babel-plugin-version-inline
4
5
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
5
6
  const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
6
7
 
7
- async function parseNodePage(data) {
8
- return JSON.parse(new TextDecoder().decode(data));
8
+ async function parseNodePage(data: ArrayBuffer, options?: LoaderOptions): Promise<NodePage> {
9
+ return JSON.parse(new TextDecoder().decode(data)) as NodePage;
9
10
  }
10
11
 
11
12
  /**
12
13
  * Loader for I3S node pages
13
14
  */
14
- export const I3SNodePageLoader: LoaderWithParser = {
15
+ export const I3SNodePageLoader: LoaderWithParser<NodePage, never, LoaderOptions> = {
15
16
  name: 'I3S Node Page',
16
17
  id: 'i3s-node-page',
17
18
  module: 'i3s',
18
19
  version: VERSION,
19
20
  mimeTypes: ['application/json'],
20
- parse,
21
+ parse: parseNodePage,
21
22
  extensions: ['json'],
22
23
  options: {}
23
24
  };
24
-
25
- async function parse(data) {
26
- data = parseNodePage(data);
27
- return data;
28
- }
@@ -6,14 +6,16 @@ import {parseSLPK} from './lib/parsers/parse-slpk/parse-slpk';
6
6
  const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
7
7
 
8
8
  export type SLPKLoaderOptions = LoaderOptions & {
9
- path?: string;
10
- mode?: 'http' | 'raw';
9
+ slpk?: {
10
+ path?: string;
11
+ pathMode?: 'http' | 'raw';
12
+ };
11
13
  };
12
14
 
13
15
  /**
14
16
  * Loader for SLPK - Scene Layer Package
15
17
  */
16
- export const SLPKLoader: LoaderWithParser = {
18
+ export const SLPKLoader: LoaderWithParser<Buffer, never, SLPKLoaderOptions> = {
17
19
  name: 'I3S SLPK (Scene Layer Package)',
18
20
  id: 'slpk',
19
21
  module: 'i3s',
package/src/index.ts CHANGED
@@ -1,9 +1,5 @@
1
- export {I3SLoader} from './i3s-loader';
2
- export {SLPKLoader} from './i3s-slpk-loader';
3
- export {I3SContentLoader} from './i3s-content-loader';
4
- export {I3SAttributeLoader, loadFeatureAttributes} from './i3s-attribute-loader';
5
- export {I3SBuildingSceneLayerLoader} from './i3s-building-scene-layer-loader';
6
- export {ArcGisWebSceneLoader} from './arcgis-webscene-loader';
1
+ // loaders.gl, MIT license
2
+
7
3
  export type {
8
4
  BoundingVolumes,
9
5
  Mbs,
@@ -34,6 +30,16 @@ export type {
34
30
  ValueCount,
35
31
  BuildingSceneSublayer,
36
32
  DATA_TYPE,
37
- OperationalLayer
33
+ OperationalLayer,
34
+ TextureSetDefinitionFormats
38
35
  } from './types';
36
+
39
37
  export {COORDINATE_SYSTEM} from './lib/parsers/constants';
38
+
39
+ export {I3SLoader} from './i3s-loader';
40
+ export {SLPKLoader} from './i3s-slpk-loader';
41
+ export {I3SContentLoader} from './i3s-content-loader';
42
+ export {I3SAttributeLoader, loadFeatureAttributes} from './i3s-attribute-loader';
43
+ export {I3SBuildingSceneLayerLoader} from './i3s-building-scene-layer-loader';
44
+ export {I3SNodePageLoader} from './i3s-node-page-loader';
45
+ export {ArcGisWebSceneLoader} from './arcgis-webscene-loader';
@@ -90,6 +90,7 @@ async function parseOperationalLayers(
90
90
  async function checkSupportedIndexCRS(layer: OperationalLayer) {
91
91
  try {
92
92
  const layerJson = await load(layer.url, JSONLoader);
93
+ // @ts-expect-error
93
94
  const wkid = layerJson?.spatialReference?.wkid;
94
95
 
95
96
  if (wkid !== SUPPORTED_WKID) {
@@ -1,3 +1,7 @@
1
+ // loaders.gl, MIT license
2
+
3
+ import {TypedArray} from '@loaders.gl/schema';
4
+
1
5
  import {
2
6
  STRING_ATTRIBUTE_TYPE,
3
7
  OBJECT_ID_ATTRIBUTE_TYPE,
@@ -5,13 +9,16 @@ import {
5
9
  INT_16_ATTRIBUTE_TYPE
6
10
  } from './constants';
7
11
 
12
+ type Attribute = string[] | TypedArray | null;
13
+ export type I3STileAttributes = Record<string, Attribute>;
14
+
8
15
  /**
9
16
  * Get particular tile and creates attribute object inside.
10
- * @param {ArrayBuffer} arrayBuffer
17
+ * @param arrayBuffer
11
18
  * @param {Object} options
12
19
  * @returns {Promise<object>}
13
20
  */
14
- export async function parseI3STileAttribute(arrayBuffer, options) {
21
+ export function parseI3STileAttribute(arrayBuffer: ArrayBuffer, options): I3STileAttributes {
15
22
  const {attributeName, attributeType} = options;
16
23
 
17
24
  if (!attributeName) {
@@ -25,10 +32,10 @@ export async function parseI3STileAttribute(arrayBuffer, options) {
25
32
  /**
26
33
  * Parse attributes based on attribute type.
27
34
  * @param {String} attributeType
28
- * @param {ArrayBuffer} arrayBuffer
29
- * @returns {any}
35
+ * @param arrayBuffer
36
+ * @returns
30
37
  */
31
- function parseAttribute(attributeType, arrayBuffer) {
38
+ function parseAttribute(attributeType, arrayBuffer: ArrayBuffer): Attribute {
32
39
  switch (attributeType) {
33
40
  case STRING_ATTRIBUTE_TYPE:
34
41
  return parseStringsAttribute(arrayBuffer);
@@ -46,10 +53,10 @@ function parseAttribute(attributeType, arrayBuffer) {
46
53
  /**
47
54
  * Parse short number attribute.
48
55
  * Short Integer spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
49
- * @param {ArrayBuffer} arrayBuffer
50
- * @returns {Uint32Array}
56
+ * @param arrayBuffer
57
+ * @returns
51
58
  */
52
- function parseShortNumberAttribute(arrayBuffer) {
59
+ function parseShortNumberAttribute(arrayBuffer: ArrayBuffer): Uint32Array {
53
60
  const countOffset = 4;
54
61
  return new Uint32Array(arrayBuffer, countOffset);
55
62
  }
@@ -57,10 +64,10 @@ function parseShortNumberAttribute(arrayBuffer) {
57
64
  /**
58
65
  * Parse Int16 short number attribute.
59
66
  * Parsing of such data is not documented. Added to handle Building Scene Layer Tileset attributes data.
60
- * @param {ArrayBuffer} arrayBuffer
61
- * @returns {Int16Array}
67
+ * @param arrayBuffer
68
+ * @returns
62
69
  */
63
- function parseInt16ShortNumberAttribute(arrayBuffer) {
70
+ function parseInt16ShortNumberAttribute(arrayBuffer: ArrayBuffer): Int16Array {
64
71
  const countOffset = 4;
65
72
  return new Int16Array(arrayBuffer, countOffset);
66
73
  }
@@ -68,10 +75,10 @@ function parseInt16ShortNumberAttribute(arrayBuffer) {
68
75
  /**
69
76
  * Parse float attribute.
70
77
  * Double Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
71
- * @param {ArrayBuffer} arrayBuffer
72
- * @returns {Float64Array}
78
+ * @param arrayBuffer
79
+ * @returns
73
80
  */
74
- function parseFloatAttribute(arrayBuffer) {
81
+ function parseFloatAttribute(arrayBuffer: ArrayBuffer): Float64Array {
75
82
  const countOffset = 8;
76
83
  return new Float64Array(arrayBuffer, countOffset);
77
84
  }
@@ -23,7 +23,7 @@ import {getUrlWithToken} from '../utils/url-utils';
23
23
 
24
24
  import {GL_TYPE_MAP, getConstructorForDataFormat, sizeOf, COORDINATE_SYSTEM} from './constants';
25
25
  import {I3SLoaderOptions} from '../../i3s-loader';
26
- import {customizeColors} from '../utils/customizeColors';
26
+ import {customizeColors} from '../utils/customize-сolors';
27
27
 
28
28
  const scratchVector = new Vector3([0, 0, 0]);
29
29
 
@@ -80,18 +80,23 @@ export async function parseI3STileContent(
80
80
  } catch (e) {
81
81
  // context object is different between worker and node.js conversion script.
82
82
  // To prevent error we parse data in ordinary way if it is not parsed by using context.
83
+ // @ts-expect-error
83
84
  content.texture = await parse(arrayBuffer, loader, options);
84
85
  }
85
86
  } else if (loader === CompressedTextureLoader || loader === BasisLoader) {
86
87
  let texture = await load(arrayBuffer, loader, tileOptions.textureLoaderOptions);
87
88
  if (loader === BasisLoader) {
89
+ // @ts-expect-error
88
90
  texture = texture[0];
89
91
  }
90
92
  content.texture = {
91
93
  compressed: true,
92
94
  mipmaps: false,
95
+ // @ts-expect-error
93
96
  width: texture[0].width,
97
+ // @ts-expect-error
94
98
  height: texture[0].height,
99
+ // @ts-expect-error
95
100
  data: texture
96
101
  };
97
102
  }
@@ -57,5 +57,8 @@ export async function parseSLPK(data: ArrayBuffer, options: SLPKLoaderOptions =
57
57
  throw new Error('No hash file in slpk');
58
58
  }
59
59
 
60
- return await new SLPKArchive(data, hashFile).getFile(options.path ?? '');
60
+ return await new SLPKArchive(data, hashFile).getFile(
61
+ options.slpk?.path ?? '',
62
+ options.slpk?.pathMode
63
+ );
61
64
  }
@@ -15,6 +15,41 @@ type HashElement = {
15
15
  offset: number;
16
16
  };
17
17
 
18
+ const PATH_DESCRIPTIONS: {test: RegExp; extensions: string[]}[] = [
19
+ {
20
+ test: /^$/,
21
+ extensions: ['3dSceneLayer.json.gz']
22
+ },
23
+ {
24
+ test: /^nodepages\/\d+$/,
25
+ extensions: ['.json.gz']
26
+ },
27
+ {
28
+ test: /^nodes\/\d+$/,
29
+ extensions: ['/3dNodeIndexDocument.json.gz']
30
+ },
31
+ {
32
+ test: /^nodes\/\d+\/textures\/.+$/,
33
+ extensions: ['.jpg', '.png', '.bin.dds.gz', '.ktx']
34
+ },
35
+ {
36
+ test: /^nodes\/\d+\/geometries\/\d+$/,
37
+ extensions: ['.bin.gz', '.draco.gz']
38
+ },
39
+ {
40
+ test: /^nodes\/\d+\/attributes\/f_\d+\/\d+$/,
41
+ extensions: ['.bin.gz']
42
+ },
43
+ {
44
+ test: /^statistics\/f_\d+\/\d+$/,
45
+ extensions: ['.json.gz']
46
+ },
47
+ {
48
+ test: /^nodes\/\d+\/shared$/,
49
+ extensions: ['/sharedResource.json.gz']
50
+ }
51
+ ];
52
+
18
53
  /**
19
54
  * Class for handling information about slpk file
20
55
  */
@@ -60,13 +95,46 @@ export class SLPKArchive {
60
95
  */
61
96
  async getFile(path: string, mode: 'http' | 'raw' = 'raw'): Promise<Buffer> {
62
97
  if (mode === 'http') {
63
- throw new Error('http mode is not supported');
98
+ const extensions = PATH_DESCRIPTIONS.find((val) => val.test.test(path))?.extensions;
99
+ if (extensions) {
100
+ let data: ArrayBuffer | undefined;
101
+ for (const ext of extensions) {
102
+ data = await this.getDataByPath(`${path}${ext}`);
103
+ if (data) {
104
+ break;
105
+ }
106
+ }
107
+ if (data) {
108
+ return Buffer.from(data);
109
+ }
110
+ }
111
+ }
112
+ if (mode === 'raw') {
113
+ const decompressedFile = await this.getDataByPath(`${path}.gz`);
114
+ if (decompressedFile) {
115
+ return Buffer.from(decompressedFile);
116
+ }
117
+ const fileWithoutCompression = this.getFileBytes(path);
118
+ if (fileWithoutCompression) {
119
+ return Buffer.from(fileWithoutCompression);
120
+ }
64
121
  }
65
122
 
66
- const fileToDecompress = this.getFileBytes(`${path}.gz`);
123
+ throw new Error('No such file in the archieve');
124
+ }
67
125
 
68
- if (fileToDecompress) {
69
- const decompressedData = await processOnWorker(CompressionWorker, fileToDecompress, {
126
+ /**
127
+ * returning uncompressed data for paths that ends with .gz and raw data for all other paths
128
+ * @param path - path inside the archive
129
+ * @returns buffer with the file data
130
+ */
131
+ private async getDataByPath(path: string): Promise<ArrayBuffer | undefined> {
132
+ const data = this.getFileBytes(path);
133
+ if (!data) {
134
+ return undefined;
135
+ }
136
+ if (/\.gz$/.test(path)) {
137
+ const decompressedData = await processOnWorker(CompressionWorker, data, {
70
138
  compression: 'gzip',
71
139
  operation: 'decompress',
72
140
  _workerType: 'test',
@@ -74,11 +142,7 @@ export class SLPKArchive {
74
142
  });
75
143
  return decompressedData;
76
144
  }
77
- const fileWithoutCompression = this.getFileBytes(path);
78
- if (fileWithoutCompression) {
79
- return Promise.resolve(Buffer.from(fileWithoutCompression));
80
- }
81
- throw new Error('No such file in the archieve');
145
+ return Buffer.from(data);
82
146
  }
83
147
 
84
148
  /**
@@ -4,7 +4,7 @@ import type {COLOR, I3STileOptions, I3STilesetOptions} from '../../types';
4
4
  import {load} from '@loaders.gl/core';
5
5
  import {getAttributeValueType, I3SAttributeLoader} from '../../i3s-attribute-loader';
6
6
  import {I3SLoaderOptions} from '../../i3s-loader';
7
- import {getUrlWithToken} from '../utils/url-utils';
7
+ import {getUrlWithToken} from './url-utils';
8
8
 
9
9
  /**
10
10
  * Modify vertex colors array to visualize 3D objects in a attribute driven way
@@ -64,8 +64,11 @@ export async function customizeColors(
64
64
  }
65
65
 
66
66
  const attributeValuesMap: {[key: number]: COLOR} = {};
67
+ // @ts-expect-error
67
68
  for (let i = 0; i < objectIdAttributeData[objectIdField.name].length; i++) {
69
+ // @ts-expect-error
68
70
  attributeValuesMap[objectIdAttributeData[objectIdField.name][i]] = calculateColorForAttribute(
71
+ // @ts-expect-error
69
72
  colorizeAttributeData[colorizeAttributeField.name][i] as number,
70
73
  options
71
74
  );
@@ -76,7 +79,17 @@ export async function customizeColors(
76
79
  if (!color) {
77
80
  continue; // eslint-disable-line no-continue
78
81
  }
79
- colors.value.set(color, i * 4);
82
+
83
+ /* eslint max-statements: ["error", 30] */
84
+ /* eslint complexity: ["error", 12] */
85
+ if (options.i3s.colorsByAttribute.mode === 'multiply') {
86
+ // multiplying original mesh and calculated for attribute rgba colors in range 0-255
87
+ color.forEach((colorItem, index) => {
88
+ colors.value[i * 4 + index] = (colors.value[i * 4 + index] * colorItem) / 255;
89
+ });
90
+ } else {
91
+ colors.value.set(color, i * 4);
92
+ }
80
93
  }
81
94
 
82
95
  return colors;
@@ -114,7 +127,7 @@ async function loadFeatureAttributeData(
114
127
  {attributeUrls}: I3STileOptions,
115
128
  {attributeStorageInfo}: I3STilesetOptions,
116
129
  options?: I3SLoaderOptions
117
- ): Promise<{[key: string]: string[] | Uint32Array | Uint16Array | Float64Array} | null> {
130
+ ): Promise<{[key: string]: string[] | Uint32Array | Uint16Array | Float64Array | null} | null> {
118
131
  const attributeIndex = attributeStorageInfo.findIndex(({name}) => attributeName === name);
119
132
  if (attributeIndex === -1) {
120
133
  return null;
@@ -125,5 +138,7 @@ async function loadFeatureAttributeData(
125
138
  attributeName,
126
139
  attributeType
127
140
  });
141
+
142
+ // @ts-expect-error TODO action engine
128
143
  return objectIdAttributeData;
129
144
  }
package/src/types.ts CHANGED
@@ -114,6 +114,7 @@ export type I3SParseOptions = {
114
114
  maxValue: number;
115
115
  minColor: COLOR;
116
116
  maxColor: COLOR;
117
+ mode: string;
117
118
  };
118
119
 
119
120
  /** @deprecated */
@@ -1,5 +1,6 @@
1
- import {createLoaderWorker} from '@loaders.gl/loader-utils';
1
+ // Polyfills increases the bundle size significantly. Use it for NodeJS worker only
2
2
  import '@loaders.gl/polyfills';
3
+ import {createLoaderWorker} from '@loaders.gl/loader-utils';
3
4
  import {I3SContentLoader} from '../i3s-content-loader';
4
5
 
5
6
  createLoaderWorker(I3SContentLoader);
@@ -1 +0,0 @@
1
- {"version":3,"file":"customizeColors.js","names":["_core","require","_i3sAttributeLoader","_urlUtils","customizeColors","_x","_x2","_x3","_x4","_x5","_customizeColors","apply","arguments","_asyncToGenerator2","default","_regenerator","mark","_callee","colors","featureIds","tileOptions","tilesetOptions","options","_options$i3s2","colorizeAttributeField","colorizeAttributeData","objectIdField","objectIdAttributeData","attributeValuesMap","i","_i","color","wrap","_callee$","_context","prev","next","i3s","colorsByAttribute","abrupt","fields","find","_ref3","_options$i3s3","_options$i3s3$colorsB","name","attributeName","includes","type","loadFeatureAttributeData","sent","_ref4","length","calculateColorForAttribute","value","set","stop","attributeValue","_options$i3s","_options$i3s$colorsBy","minValue","maxValue","minColor","maxColor","rate","Math","round","_x6","_x7","_x8","_x9","_loadFeatureAttributeData","_callee2","_ref","_ref2","_options$i3s4","attributeUrls","attributeStorageInfo","attributeIndex","objectIdAttributeUrl","attributeType","_callee2$","_context2","findIndex","_ref5","getUrlWithToken","token","getAttributeValueType","load","I3SAttributeLoader"],"sources":["../../../../src/lib/utils/customizeColors.ts"],"sourcesContent":["import type {MeshAttribute} from '@loaders.gl/schema';\nimport type {COLOR, I3STileOptions, I3STilesetOptions} from '../../types';\n\nimport {load} from '@loaders.gl/core';\nimport {getAttributeValueType, I3SAttributeLoader} from '../../i3s-attribute-loader';\nimport {I3SLoaderOptions} from '../../i3s-loader';\nimport {getUrlWithToken} from '../utils/url-utils';\n\n/**\n * Modify vertex colors array to visualize 3D objects in a attribute driven way\n * @param colors - vertex colors attribute\n * @param featureIds - feature Ids attribute\n * @param tileOptions - tile - related options\n * @param tilesetOptions - tileset-related options\n * @param options - loader options\n * @returns midified colors attribute\n */\nexport async function customizeColors(\n colors: MeshAttribute,\n featureIds: MeshAttribute,\n tileOptions: I3STileOptions,\n tilesetOptions: I3STilesetOptions,\n options?: I3SLoaderOptions\n): Promise<MeshAttribute> {\n if (!options?.i3s?.colorsByAttribute) {\n return colors;\n }\n\n const colorizeAttributeField = tilesetOptions.fields.find(\n ({name}) => name === options?.i3s?.colorsByAttribute?.attributeName\n );\n if (\n !colorizeAttributeField ||\n !['esriFieldTypeDouble', 'esriFieldTypeInteger', 'esriFieldTypeSmallInteger'].includes(\n colorizeAttributeField.type\n )\n ) {\n return colors;\n }\n\n const colorizeAttributeData = await loadFeatureAttributeData(\n colorizeAttributeField.name,\n tileOptions,\n tilesetOptions,\n options\n );\n if (!colorizeAttributeData) {\n return colors;\n }\n\n const objectIdField = tilesetOptions.fields.find(({type}) => type === 'esriFieldTypeOID');\n if (!objectIdField) {\n return colors;\n }\n\n const objectIdAttributeData = await loadFeatureAttributeData(\n objectIdField.name,\n tileOptions,\n tilesetOptions,\n options\n );\n if (!objectIdAttributeData) {\n return colors;\n }\n\n const attributeValuesMap: {[key: number]: COLOR} = {};\n for (let i = 0; i < objectIdAttributeData[objectIdField.name].length; i++) {\n attributeValuesMap[objectIdAttributeData[objectIdField.name][i]] = calculateColorForAttribute(\n colorizeAttributeData[colorizeAttributeField.name][i] as number,\n options\n );\n }\n\n for (let i = 0; i < featureIds.value.length; i++) {\n const color = attributeValuesMap[featureIds.value[i]];\n if (!color) {\n continue; // eslint-disable-line no-continue\n }\n colors.value.set(color, i * 4);\n }\n\n return colors;\n}\n\n/**\n * Calculate rgba color from the attribute value\n * @param attributeValue - value of the attribute\n * @param options - loader options\n * @returns - color array for a specific attribute value\n */\nfunction calculateColorForAttribute(attributeValue: number, options?: I3SLoaderOptions): COLOR {\n if (!options?.i3s?.colorsByAttribute) {\n return [255, 255, 255, 255];\n }\n const {minValue, maxValue, minColor, maxColor} = options.i3s.colorsByAttribute;\n const rate = (attributeValue - minValue) / (maxValue - minValue);\n const color: COLOR = [255, 255, 255, 255];\n for (let i = 0; i < minColor.length; i++) {\n color[i] = Math.round((maxColor[i] - minColor[i]) * rate + minColor[i]);\n }\n return color;\n}\n\n/**\n * Load feature attribute data from the ArcGIS rest service\n * @param attributeName - attribute name\n * @param tileOptions - tile-related options\n * @param tilesetOptions - tileset-related options\n * @param options - loader options\n * @returns - Array-like list of the attribute values\n */\nasync function loadFeatureAttributeData(\n attributeName: string,\n {attributeUrls}: I3STileOptions,\n {attributeStorageInfo}: I3STilesetOptions,\n options?: I3SLoaderOptions\n): Promise<{[key: string]: string[] | Uint32Array | Uint16Array | Float64Array} | null> {\n const attributeIndex = attributeStorageInfo.findIndex(({name}) => attributeName === name);\n if (attributeIndex === -1) {\n return null;\n }\n const objectIdAttributeUrl = getUrlWithToken(attributeUrls[attributeIndex], options?.i3s?.token);\n const attributeType = getAttributeValueType(attributeStorageInfo[attributeIndex]);\n const objectIdAttributeData = await load(objectIdAttributeUrl, I3SAttributeLoader, {\n attributeName,\n attributeType\n });\n return objectIdAttributeData;\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAAmD,SAW7BG,eAAeA,CAAAC,EAAA,EAAAC,GAAA,EAAAC,GAAA,EAAAC,GAAA,EAAAC,GAAA;EAAA,OAAAC,gBAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;AAAA,SAAAF,iBAAA;EAAAA,g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I,SAAA,CAAA9C,IAAA;YAAA;UAAA;UAAA,OAAA8C,SAAA,CAAA3C,MAAA,WAChB,IAAI;QAAA;UAEPwC,oBAAoB,GAAG,IAAAM,yBAAe,EAACT,aAAa,CAACE,cAAc,CAAC,EAAExD,OAAO,aAAPA,OAAO,wBAAAqD,aAAA,GAAPrD,OAAO,CAAEe,GAAG,cAAAsC,aAAA,uBAAZA,aAAA,CAAcW,KAAK,CAAC;UAC1FN,aAAa,GAAG,IAAAO,yCAAqB,EAACV,oBAAoB,CAACC,cAAc,CAAC,CAAC;UAAAI,SAAA,CAAA9C,IAAA;UAAA,OAC7C,IAAAoD,UAAI,EAACT,oBAAoB,EAAEU,sCAAkB,EAAE;YACjF3C,aAAa,EAAbA,aAAa;YACbkC,aAAa,EAAbA;UACF,CAAC,CAAC;QAAA;UAHIrD,qBAAqB,GAAAuD,SAAA,CAAAhC,IAAA;UAAA,OAAAgC,SAAA,CAAA3C,MAAA,WAIpBZ,qBAAqB;QAAA;QAAA;UAAA,OAAAuD,SAAA,CAAA1B,IAAA;MAAA;IAAA,GAAAgB,QAAA;EAAA,CAC7B;EAAA,OAAAD,yBAAA,CAAA5D,KAAA,OAAAC,SAAA;AAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"i3s-content-nodejs-worker.js","names":["_loaderUtils","require","_i3sContentLoader","createLoaderWorker","I3SContentLoader"],"sources":["../../../src/workers/i3s-content-nodejs-worker.ts"],"sourcesContent":["import {createLoaderWorker} from '@loaders.gl/loader-utils';\nimport '@loaders.gl/polyfills';\nimport {I3SContentLoader} from '../i3s-content-loader';\n\ncreateLoaderWorker(I3SContentLoader);\n"],"mappings":";;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACAA,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,+BAAkB,EAACC,kCAAgB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"customizeColors.js","names":["load","getAttributeValueType","I3SAttributeLoader","getUrlWithToken","customizeColors","colors","featureIds","tileOptions","tilesetOptions","options","_options$i3s","i3s","colorsByAttribute","colorizeAttributeField","fields","find","_ref","_options$i3s2","_options$i3s2$colorsB","name","attributeName","includes","type","colorizeAttributeData","loadFeatureAttributeData","objectIdField","_ref2","objectIdAttributeData","attributeValuesMap","i","length","calculateColorForAttribute","value","color","set","attributeValue","_options$i3s3","minValue","maxValue","minColor","maxColor","rate","Math","round","_ref3","_ref4","_options$i3s4","attributeUrls","attributeStorageInfo","attributeIndex","findIndex","_ref5","objectIdAttributeUrl","token","attributeType"],"sources":["../../../../src/lib/utils/customizeColors.ts"],"sourcesContent":["import type {MeshAttribute} from '@loaders.gl/schema';\nimport type {COLOR, I3STileOptions, I3STilesetOptions} from '../../types';\n\nimport {load} from '@loaders.gl/core';\nimport {getAttributeValueType, I3SAttributeLoader} from '../../i3s-attribute-loader';\nimport {I3SLoaderOptions} from '../../i3s-loader';\nimport {getUrlWithToken} from '../utils/url-utils';\n\n/**\n * Modify vertex colors array to visualize 3D objects in a attribute driven way\n * @param colors - vertex colors attribute\n * @param featureIds - feature Ids attribute\n * @param tileOptions - tile - related options\n * @param tilesetOptions - tileset-related options\n * @param options - loader options\n * @returns midified colors attribute\n */\nexport async function customizeColors(\n colors: MeshAttribute,\n featureIds: MeshAttribute,\n tileOptions: I3STileOptions,\n tilesetOptions: I3STilesetOptions,\n options?: I3SLoaderOptions\n): Promise<MeshAttribute> {\n if (!options?.i3s?.colorsByAttribute) {\n return colors;\n }\n\n const colorizeAttributeField = tilesetOptions.fields.find(\n ({name}) => name === options?.i3s?.colorsByAttribute?.attributeName\n );\n if (\n !colorizeAttributeField ||\n !['esriFieldTypeDouble', 'esriFieldTypeInteger', 'esriFieldTypeSmallInteger'].includes(\n colorizeAttributeField.type\n )\n ) {\n return colors;\n }\n\n const colorizeAttributeData = await loadFeatureAttributeData(\n colorizeAttributeField.name,\n tileOptions,\n tilesetOptions,\n options\n );\n if (!colorizeAttributeData) {\n return colors;\n }\n\n const objectIdField = tilesetOptions.fields.find(({type}) => type === 'esriFieldTypeOID');\n if (!objectIdField) {\n return colors;\n }\n\n const objectIdAttributeData = await loadFeatureAttributeData(\n objectIdField.name,\n tileOptions,\n tilesetOptions,\n options\n );\n if (!objectIdAttributeData) {\n return colors;\n }\n\n const attributeValuesMap: {[key: number]: COLOR} = {};\n for (let i = 0; i < objectIdAttributeData[objectIdField.name].length; i++) {\n attributeValuesMap[objectIdAttributeData[objectIdField.name][i]] = calculateColorForAttribute(\n colorizeAttributeData[colorizeAttributeField.name][i] as number,\n options\n );\n }\n\n for (let i = 0; i < featureIds.value.length; i++) {\n const color = attributeValuesMap[featureIds.value[i]];\n if (!color) {\n continue; // eslint-disable-line no-continue\n }\n colors.value.set(color, i * 4);\n }\n\n return colors;\n}\n\n/**\n * Calculate rgba color from the attribute value\n * @param attributeValue - value of the attribute\n * @param options - loader options\n * @returns - color array for a specific attribute value\n */\nfunction calculateColorForAttribute(attributeValue: number, options?: I3SLoaderOptions): COLOR {\n if (!options?.i3s?.colorsByAttribute) {\n return [255, 255, 255, 255];\n }\n const {minValue, maxValue, minColor, maxColor} = options.i3s.colorsByAttribute;\n const rate = (attributeValue - minValue) / (maxValue - minValue);\n const color: COLOR = [255, 255, 255, 255];\n for (let i = 0; i < minColor.length; i++) {\n color[i] = Math.round((maxColor[i] - minColor[i]) * rate + minColor[i]);\n }\n return color;\n}\n\n/**\n * Load feature attribute data from the ArcGIS rest service\n * @param attributeName - attribute name\n * @param tileOptions - tile-related options\n * @param tilesetOptions - tileset-related options\n * @param options - loader options\n * @returns - Array-like list of the attribute values\n */\nasync function loadFeatureAttributeData(\n attributeName: string,\n {attributeUrls}: I3STileOptions,\n {attributeStorageInfo}: I3STilesetOptions,\n options?: I3SLoaderOptions\n): Promise<{[key: string]: string[] | Uint32Array | Uint16Array | Float64Array} | null> {\n const attributeIndex = attributeStorageInfo.findIndex(({name}) => attributeName === name);\n if (attributeIndex === -1) {\n return null;\n }\n const objectIdAttributeUrl = getUrlWithToken(attributeUrls[attributeIndex], options?.i3s?.token);\n const attributeType = getAttributeValueType(attributeStorageInfo[attributeIndex]);\n const objectIdAttributeData = await load(objectIdAttributeUrl, I3SAttributeLoader, {\n attributeName,\n attributeType\n });\n return objectIdAttributeData;\n}\n"],"mappings":"AAGA,SAAQA,IAAI,QAAO,kBAAkB;AACrC,SAAQC,qBAAqB,EAAEC,kBAAkB,QAAO,4BAA4B;AAEpF,SAAQC,eAAe,QAAO,oBAAoB;AAWlD,OAAO,eAAeC,eAAeA,CACnCC,MAAqB,EACrBC,UAAyB,EACzBC,WAA2B,EAC3BC,cAAiC,EACjCC,OAA0B,EACF;EAAA,IAAAC,YAAA;EACxB,IAAI,EAACD,OAAO,aAAPA,OAAO,gBAAAC,YAAA,GAAPD,OAAO,CAAEE,GAAG,cAAAD,YAAA,eAAZA,YAAA,CAAcE,iBAAiB,GAAE;IACpC,OAAOP,MAAM;EACf;EAEA,MAAMQ,sBAAsB,GAAGL,cAAc,CAACM,MAAM,CAACC,IAAI,CACvDC,IAAA;IAAA,IAAAC,aAAA,EAAAC,qBAAA;IAAA,IAAC;MAACC;IAAI,CAAC,GAAAH,IAAA;IAAA,OAAKG,IAAI,MAAKV,OAAO,aAAPA,OAAO,wBAAAQ,aAAA,GAAPR,OAAO,CAAEE,GAAG,cAAAM,aAAA,wBAAAC,qBAAA,GAAZD,aAAA,CAAcL,iBAAiB,cAAAM,qBAAA,uBAA/BA,qBAAA,CAAiCE,aAAa;EAAA,CACrE,CAAC;EACD,IACE,CAACP,sBAAsB,IACvB,CAAC,CAAC,qBAAqB,EAAE,sBAAsB,EAAE,2BAA2B,CAAC,CAACQ,QAAQ,CACpFR,sBAAsB,CAACS,IACzB,CAAC,EACD;IACA,OAAOjB,MAAM;EACf;EAEA,MAAMkB,qBAAqB,GAAG,MAAMC,wBAAwB,CAC1DX,sBAAsB,CAACM,IAAI,EAC3BZ,WAAW,EACXC,cAAc,EACdC,OACF,CAAC;EACD,IAAI,CA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A,MAAMG,oBAAoB,GAAGjD,eAAe,CAAC4C,aAAa,CAACE,cAAc,CAAC,EAAExC,OAAO,aAAPA,OAAO,wBAAAqC,aAAA,GAAPrC,OAAO,CAAEE,GAAG,cAAAmC,aAAA,uBAAZA,aAAA,CAAcO,KAAK,CAAC;EAChG,MAAMC,aAAa,GAAGrD,qBAAqB,CAAC+C,oBAAoB,CAACC,cAAc,CAAC,CAAC;EACjF,MAAMtB,qBAAqB,GAAG,MAAM3B,IAAI,CAACoD,oBAAoB,EAAElD,kBAAkB,EAAE;IACjFkB,aAAa;IACbkC;EACF,CAAC,CAAC;EACF,OAAO3B,qBAAqB;AAC9B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"i3s-content-nodejs-worker.js","names":["createLoaderWorker","I3SContentLoader"],"sources":["../../../src/workers/i3s-content-nodejs-worker.ts"],"sourcesContent":["import {createLoaderWorker} from '@loaders.gl/loader-utils';\nimport '@loaders.gl/polyfills';\nimport {I3SContentLoader} from '../i3s-content-loader';\n\ncreateLoaderWorker(I3SContentLoader);\n"],"mappings":"AAAA,SAAQA,kBAAkB,QAAO,0BAA0B;AAC3D,OAAO,uBAAuB;AAC9B,SAAQC,gBAAgB,QAAO,uBAAuB;AAEtDD,kBAAkB,CAACC,gBAAgB,CAAC"}