@loaders.gl/i3s 4.0.0-alpha.4 → 4.0.0-alpha.5

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 (65) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/dist.min.js +10374 -0
  4. package/dist/i3s-attribute-loader.d.ts +14 -0
  5. package/dist/i3s-attribute-loader.d.ts.map +1 -0
  6. package/dist/i3s-attribute-loader.js +1 -1
  7. package/dist/i3s-building-scene-layer-loader.d.ts +6 -0
  8. package/dist/i3s-building-scene-layer-loader.d.ts.map +1 -0
  9. package/dist/i3s-building-scene-layer-loader.js +1 -1
  10. package/dist/i3s-content-loader.d.ts +6 -0
  11. package/dist/i3s-content-loader.d.ts.map +1 -0
  12. package/dist/i3s-content-loader.js +1 -1
  13. package/dist/i3s-content-worker.js +391 -270
  14. package/dist/i3s-loader.d.ts +6 -0
  15. package/dist/i3s-loader.d.ts.map +1 -0
  16. package/dist/i3s-loader.js +1 -1
  17. package/dist/i3s-node-page-loader.d.ts +6 -0
  18. package/dist/i3s-node-page-loader.d.ts.map +1 -0
  19. package/dist/i3s-node-page-loader.js +1 -1
  20. package/dist/index.d.ts +7 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js.map +1 -1
  23. package/dist/lib/helpers/i3s-nodepages-tiles.d.ts +73 -0
  24. package/dist/lib/helpers/i3s-nodepages-tiles.d.ts.map +1 -0
  25. package/dist/lib/helpers/i3s-nodepages-tiles.js +33 -23
  26. package/dist/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
  27. package/dist/lib/parsers/constants.d.ts +40 -0
  28. package/dist/lib/parsers/constants.d.ts.map +1 -0
  29. package/dist/lib/parsers/constants.js +54 -38
  30. package/dist/lib/parsers/constants.js.map +1 -1
  31. package/dist/lib/parsers/parse-i3s-attribute.d.ts +10 -0
  32. package/dist/lib/parsers/parse-i3s-attribute.d.ts.map +1 -0
  33. package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts +9 -0
  34. package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts.map +1 -0
  35. package/dist/lib/parsers/parse-i3s-building-scene-layer.js +2 -0
  36. package/dist/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -1
  37. package/dist/lib/parsers/parse-i3s-tile-content.d.ts +4 -0
  38. package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -0
  39. package/dist/lib/parsers/parse-i3s-tile-content.js +76 -79
  40. package/dist/lib/parsers/parse-i3s-tile-content.js.map +1 -1
  41. package/dist/lib/parsers/parse-i3s.d.ts +6 -0
  42. package/dist/lib/parsers/parse-i3s.d.ts.map +1 -0
  43. package/dist/lib/parsers/parse-i3s.js +40 -25
  44. package/dist/lib/parsers/parse-i3s.js.map +1 -1
  45. package/dist/lib/utils/convert-i3s-obb-to-mbs.d.ts +2 -0
  46. package/dist/lib/utils/convert-i3s-obb-to-mbs.d.ts.map +1 -0
  47. package/dist/lib/utils/url-utils.d.ts +22 -0
  48. package/dist/lib/utils/url-utils.d.ts.map +1 -0
  49. package/dist/lib/utils/url-utils.js +2 -3
  50. package/dist/lib/utils/url-utils.js.map +1 -1
  51. package/dist/types.d.ts +643 -0
  52. package/dist/types.d.ts.map +1 -0
  53. package/dist/types.js +20 -1
  54. package/dist/types.js.map +1 -1
  55. package/dist/workers/i3s-content-worker.d.ts +2 -0
  56. package/dist/workers/i3s-content-worker.d.ts.map +1 -0
  57. package/package.json +12 -12
  58. package/src/index.ts +3 -3
  59. package/src/lib/helpers/i3s-nodepages-tiles.ts +71 -55
  60. package/src/lib/parsers/constants.ts +67 -54
  61. package/src/lib/parsers/parse-i3s-building-scene-layer.ts +2 -1
  62. package/src/lib/parsers/parse-i3s-tile-content.ts +150 -146
  63. package/src/lib/parsers/parse-i3s.ts +48 -37
  64. package/src/lib/utils/url-utils.ts +7 -7
  65. package/src/types.ts +412 -73
@@ -0,0 +1,6 @@
1
+ import type { LoaderWithParser } from '@loaders.gl/loader-utils';
2
+ /**
3
+ * Loader for I3S - Indexed 3D Scene Layer
4
+ */
5
+ export declare const I3SLoader: LoaderWithParser;
6
+ //# sourceMappingURL=i3s-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i3s-loader.d.ts","sourceRoot":"","sources":["../src/i3s-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAc/D;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,gBAsBvB,CAAC"}
@@ -2,7 +2,7 @@ import { load, parse } from '@loaders.gl/core';
2
2
  import { I3SContentLoader } from './i3s-content-loader';
3
3
  import { normalizeTileData, normalizeTilesetData } from './lib/parsers/parse-i3s';
4
4
  import { COORDINATE_SYSTEM } from './lib/parsers/constants';
5
- const VERSION = typeof "4.0.0-alpha.4" !== 'undefined' ? "4.0.0-alpha.4" : 'latest';
5
+ const VERSION = typeof "4.0.0-alpha.5" !== 'undefined' ? "4.0.0-alpha.5" : 'latest';
6
6
  const TILESET_REGEX = /layers\/[0-9]+$/;
7
7
  const TILE_HEADER_REGEX = /nodes\/([0-9-]+|root)$/;
8
8
  const SLPK_HEX = '504b0304';
@@ -0,0 +1,6 @@
1
+ import type { LoaderWithParser } from '@loaders.gl/loader-utils';
2
+ /**
3
+ * Loader for I3S node pages
4
+ */
5
+ export declare const I3SNodePageLoader: LoaderWithParser;
6
+ //# sourceMappingURL=i3s-node-page-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i3s-node-page-loader.d.ts","sourceRoot":"","sources":["../src/i3s-node-page-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAU/D;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAS/B,CAAC"}
@@ -1,4 +1,4 @@
1
- const VERSION = typeof "4.0.0-alpha.4" !== 'undefined' ? "4.0.0-alpha.4" : 'latest';
1
+ const VERSION = typeof "4.0.0-alpha.5" !== 'undefined' ? "4.0.0-alpha.5" : 'latest';
2
2
 
3
3
  async function parseNodePage(data) {
4
4
  return JSON.parse(new TextDecoder().decode(data));
@@ -0,0 +1,7 @@
1
+ export { I3SLoader } from './i3s-loader';
2
+ export { I3SContentLoader } from './i3s-content-loader';
3
+ export { I3SAttributeLoader, loadFeatureAttributes } from './i3s-attribute-loader';
4
+ export { I3SBuildingSceneLayerLoader } from './i3s-building-scene-layer-loader';
5
+ export type { BoundingVolumes, Mbs, Obb, SceneLayer3D, AttributeStorageInfo, Field, ESRIField, PopupInfo, Node3DIndexDocument, LodSelection, NodeReference, Resource, MaxScreenThresholdSQ, NodeInPage, SharedResources, Attribute, Extent, FeatureAttribute, FieldInfo, I3SMaterialDefinition } from './types';
6
+ export { COORDINATE_SYSTEM } from './lib/parsers/constants';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAE,qBAAqB,EAAC,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAAC,2BAA2B,EAAC,MAAM,mCAAmC,CAAC;AAC9E,YAAY,EACV,eAAe,EACf,GAAG,EACH,GAAG,EACH,YAAY,EACZ,oBAAoB,EACpB,KAAK,EACL,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,SAAS,EACT,qBAAqB,EACtB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["I3SLoader","I3SContentLoader","I3SAttributeLoader","loadFeatureAttributes","I3SBuildingSceneLayerLoader","COORDINATE_SYSTEM"],"mappings":"AAAA,SAAQA,SAAR,QAAwB,cAAxB;AACA,SAAQC,gBAAR,QAA+B,sBAA/B;AACA,SAAQC,kBAAR,EAA4BC,qBAA5B,QAAwD,wBAAxD;AACA,SAAQC,2BAAR,QAA0C,mCAA1C;AAuBA,SAAQC,iBAAR,QAAgC,yBAAhC","sourcesContent":["export {I3SLoader} from './i3s-loader';\nexport {I3SContentLoader} from './i3s-content-loader';\nexport {I3SAttributeLoader, loadFeatureAttributes} from './i3s-attribute-loader';\nexport {I3SBuildingSceneLayerLoader} from './i3s-building-scene-layer-loader';\nexport type {\n BoundingVolumes,\n Mbs,\n Obb,\n SceneLayer3D,\n AttributeStorageInfo,\n Field,\n ESRIField,\n PopupInfo,\n Node3DIndexDocument,\n LodSelection,\n NodeReference,\n Resource,\n I3SGeometry,\n MaxScreenThresholdSQ,\n NodeInPage,\n SharedResources,\n TextureImage,\n Attribute,\n Extent,\n FeatureAttribute\n} from './types';\nexport {COORDINATE_SYSTEM} from './lib/parsers/constants';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["I3SLoader","I3SContentLoader","I3SAttributeLoader","loadFeatureAttributes","I3SBuildingSceneLayerLoader","COORDINATE_SYSTEM"],"mappings":"AAAA,SAAQA,SAAR,QAAwB,cAAxB;AACA,SAAQC,gBAAR,QAA+B,sBAA/B;AACA,SAAQC,kBAAR,EAA4BC,qBAA5B,QAAwD,wBAAxD;AACA,SAAQC,2BAAR,QAA0C,mCAA1C;AAuBA,SAAQC,iBAAR,QAAgC,yBAAhC","sourcesContent":["export {I3SLoader} from './i3s-loader';\nexport {I3SContentLoader} from './i3s-content-loader';\nexport {I3SAttributeLoader, loadFeatureAttributes} from './i3s-attribute-loader';\nexport {I3SBuildingSceneLayerLoader} from './i3s-building-scene-layer-loader';\nexport type {\n BoundingVolumes,\n Mbs,\n Obb,\n SceneLayer3D,\n AttributeStorageInfo,\n Field,\n ESRIField,\n PopupInfo,\n Node3DIndexDocument,\n LodSelection,\n NodeReference,\n Resource,\n MaxScreenThresholdSQ,\n NodeInPage,\n SharedResources,\n Attribute,\n Extent,\n FeatureAttribute,\n FieldInfo,\n I3SMaterialDefinition\n} from './types';\nexport {COORDINATE_SYSTEM} from './lib/parsers/constants';\n"],"file":"index.js"}
@@ -0,0 +1,73 @@
1
+ import type { LoaderOptions } from '@loaders.gl/loader-utils';
2
+ import { I3STilesetHeader, NodePage, NodeInPage, I3STextureFormat, I3STileHeader } from '../../types';
3
+ /**
4
+ * class I3SNodePagesTiles - loads nodePages and form i3s tiles from them
5
+ */
6
+ export default class I3SNodePagesTiles {
7
+ tileset: I3STilesetHeader;
8
+ nodePages: NodePage[];
9
+ pendingNodePages: {
10
+ promise: Promise<NodePage>;
11
+ status: 'Pending' | 'Done';
12
+ }[];
13
+ nodesPerPage: number;
14
+ options: LoaderOptions;
15
+ lodSelectionMetricType?: string;
16
+ textureDefinitionsSelectedFormats: ({
17
+ format: I3STextureFormat;
18
+ name: string;
19
+ } | null)[];
20
+ private textureLoaderOptions;
21
+ /**
22
+ * @constructs
23
+ * Create a I3SNodePagesTiles instance.
24
+ * @param tileset - i3s tileset header ('layers/0')
25
+ * @param options - i3s loader options
26
+ */
27
+ constructor(tileset: I3STilesetHeader, options: LoaderOptions);
28
+ /**
29
+ * Loads some nodePage and return a particular node from it
30
+ * @param id - id of node through all node pages
31
+ */
32
+ getNodeById(id: number): Promise<NodeInPage>;
33
+ /**
34
+ * Forms tile header using node and tileset data
35
+ * @param id - id of node through all node pages
36
+ */
37
+ formTileFromNodePages(id: number): Promise<I3STileHeader>;
38
+ /**
39
+ * Forms url and type of geometry resource by nodepage's data and `geometryDefinitions` in the tileset
40
+ * @param - data about the node's mesh from the nodepage
41
+ * @returns -
42
+ * {string} url - url to the geometry resource
43
+ * {boolean} isDracoGeometry - whether the geometry resource contain DRACO compressed geometry
44
+ */
45
+ private getContentUrl;
46
+ /**
47
+ * Forms 1.6 compatible LOD selection object from a nodepage's node data
48
+ * @param node - a node from nodepage
49
+ * @returns- Array of LodSelection
50
+ */
51
+ private getLodSelection;
52
+ /**
53
+ * Returns information about texture and material from `materialDefinitions`
54
+ * @param material - material data from nodepage
55
+ * @returns - Couple {textureData, materialDefinition}
56
+ * {string} textureData.name - path name of the texture
57
+ * {string} textureData.format - format of the texture
58
+ * materialDefinition - PBR-like material definition from `materialDefinitions`
59
+ */
60
+ private getInformationFromMaterial;
61
+ /**
62
+ * Sets preferable and supported format for each textureDefinition of the tileset
63
+ * @param tileset - I3S layer data
64
+ * @returns
65
+ */
66
+ private initSelectedFormatsForTextureDefinitions;
67
+ /**
68
+ * Returns the array of supported texture format
69
+ * @returns list of format strings
70
+ */
71
+ private getSupportedTextureFormats;
72
+ }
73
+ //# sourceMappingURL=i3s-nodepages-tiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i3s-nodepages-tiles.d.ts","sourceRoot":"","sources":["../../../src/lib/helpers/i3s-nodepages-tiles.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EACL,gBAAgB,EAEhB,QAAQ,EACR,UAAU,EAIV,gBAAgB,EAEhB,aAAa,EACd,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,OAAO,EAAE,gBAAgB,CAAC;IAC1B,SAAS,EAAE,QAAQ,EAAE,CAAM;IAC3B,gBAAgB,EAAE;QAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAA;KAAC,EAAE,CAAM;IAClF,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,aAAa,CAAC;IACvB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,iCAAiC,EAAE,CAAC;QAAC,MAAM,EAAE,gBAAgB,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,GAAG,IAAI,CAAC,EAAE,CAAM;IAC5F,OAAO,CAAC,oBAAoB,CAA4B;IAExD;;;;;OAKG;gBACS,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,aAAa;IAS7D;;;OAGG;IACG,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAqBlD;;;OAGG;IAEG,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAuD/D;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IA6BrB;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAiBvB;;;;;;;OAOG;IACH,OAAO,CAAC,0BAA0B;IAuBlC;;;;OAIG;IACH,OAAO,CAAC,wCAAwC;IA2BhD;;;OAGG;IACH,OAAO,CAAC,0BAA0B;CAuBnC"}
@@ -6,6 +6,8 @@ import { normalizeTileNonUrlData } from '../parsers/parse-i3s';
6
6
  import { getUrlWithToken, generateTilesetAttributeUrls } from '../utils/url-utils';
7
7
  export default class I3SNodePagesTiles {
8
8
  constructor(tileset, options) {
9
+ var _tileset$nodePages, _tileset$nodePages2;
10
+
9
11
  _defineProperty(this, "tileset", void 0);
10
12
 
11
13
  _defineProperty(this, "nodePages", []);
@@ -24,8 +26,8 @@ export default class I3SNodePagesTiles {
24
26
 
25
27
  this.tileset = { ...tileset
26
28
  };
27
- this.nodesPerPage = tileset.nodePages.nodesPerPage;
28
- this.lodSelectionMetricType = tileset.nodePages.lodSelectionMetricType;
29
+ this.nodesPerPage = ((_tileset$nodePages = tileset.nodePages) === null || _tileset$nodePages === void 0 ? void 0 : _tileset$nodePages.nodesPerPage) || 64;
30
+ this.lodSelectionMetricType = (_tileset$nodePages2 = tileset.nodePages) === null || _tileset$nodePages2 === void 0 ? void 0 : _tileset$nodePages2.lodSelectionMetricType;
29
31
  this.options = options;
30
32
  this.initSelectedFormatsForTextureDefinitions(tileset);
31
33
  }
@@ -60,15 +62,15 @@ export default class I3SNodePagesTiles {
60
62
  for (const child of node.children || []) {
61
63
  const childNode = await this.getNodeById(child);
62
64
  children.push({
63
- id: child,
65
+ id: child.toString(),
64
66
  obb: childNode.obb
65
67
  });
66
68
  }
67
69
 
68
- let contentUrl = null;
69
- let textureUrl = null;
70
- let materialDefinition = null;
71
- let textureFormat = 'jpeg';
70
+ let contentUrl;
71
+ let textureUrl;
72
+ let materialDefinition;
73
+ let textureFormat = 'jpg';
72
74
  let attributeUrls = [];
73
75
  let isDracoGeometry = false;
74
76
 
@@ -77,12 +79,14 @@ export default class I3SNodePagesTiles {
77
79
  url,
78
80
  isDracoGeometry: isDracoGeometryResult
79
81
  } = node.mesh.geometry && this.getContentUrl(node.mesh.geometry) || {
80
- url: null,
81
- isDracoGeometry: null
82
+ isDracoGeometry: false
82
83
  };
83
84
  contentUrl = url;
84
85
  isDracoGeometry = isDracoGeometryResult;
85
- const [textureData, nodeMaterialDefinition] = this.getInformationFromMaterial(node.mesh.material);
86
+ const {
87
+ textureData,
88
+ materialDefinition: nodeMaterialDefinition
89
+ } = this.getInformationFromMaterial(node.mesh.material);
86
90
  materialDefinition = nodeMaterialDefinition;
87
91
  textureFormat = textureData.format || textureFormat;
88
92
 
@@ -97,7 +101,7 @@ export default class I3SNodePagesTiles {
97
101
 
98
102
  const lodSelection = this.getLodSelection(node);
99
103
  return normalizeTileNonUrlData({
100
- id,
104
+ id: id.toString(),
101
105
  lodSelection,
102
106
  obb: node.obb,
103
107
  contentUrl,
@@ -112,7 +116,7 @@ export default class I3SNodePagesTiles {
112
116
  }
113
117
 
114
118
  getContentUrl(meshGeometryData) {
115
- let result = {};
119
+ let result = null;
116
120
  const geometryDefinition = this.tileset.geometryDefinitions[meshGeometryData.definition];
117
121
  let geometryIndex = -1;
118
122
 
@@ -153,24 +157,30 @@ export default class I3SNodePagesTiles {
153
157
  }
154
158
 
155
159
  getInformationFromMaterial(material) {
156
- const textureDataDefault = {
157
- name: null,
158
- format: null
160
+ const informationFromMaterial = {
161
+ textureData: {
162
+ name: null
163
+ }
159
164
  };
160
165
 
161
166
  if (material) {
162
- const materialDefinition = this.tileset.materialDefinitions[material.definition];
163
- const textureSetDefinitionIndex = materialDefinition && materialDefinition.pbrMetallicRoughness && materialDefinition.pbrMetallicRoughness.baseColorTexture && materialDefinition.pbrMetallicRoughness.baseColorTexture.textureSetDefinitionId;
167
+ var _this$tileset$materia;
164
168
 
165
- if (textureSetDefinitionIndex || textureSetDefinitionIndex === 0) {
166
- const textureData = this.textureDefinitionsSelectedFormats[textureSetDefinitionIndex] || textureDataDefault;
167
- return [textureData, materialDefinition];
168
- }
169
+ const materialDefinition = (_this$tileset$materia = this.tileset.materialDefinitions) === null || _this$tileset$materia === void 0 ? void 0 : _this$tileset$materia[material.definition];
169
170
 
170
- return [textureDataDefault, materialDefinition];
171
+ if (materialDefinition) {
172
+ var _materialDefinition$p, _materialDefinition$p2;
173
+
174
+ informationFromMaterial.materialDefinition = materialDefinition;
175
+ const textureSetDefinitionIndex = materialDefinition === null || materialDefinition === void 0 ? void 0 : (_materialDefinition$p = materialDefinition.pbrMetallicRoughness) === null || _materialDefinition$p === void 0 ? void 0 : (_materialDefinition$p2 = _materialDefinition$p.baseColorTexture) === null || _materialDefinition$p2 === void 0 ? void 0 : _materialDefinition$p2.textureSetDefinitionId;
176
+
177
+ if (typeof textureSetDefinitionIndex === 'number') {
178
+ informationFromMaterial.textureData = this.textureDefinitionsSelectedFormats[textureSetDefinitionIndex] || informationFromMaterial.textureData;
179
+ }
180
+ }
171
181
  }
172
182
 
173
- return [textureDataDefault, null];
183
+ return informationFromMaterial;
174
184
  }
175
185
 
176
186
  initSelectedFormatsForTextureDefinitions(tileset) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/helpers/i3s-nodepages-tiles.ts"],"names":["load","getSupportedGPUTextureFormats","selectSupportedBasisFormat","I3SNodePageLoader","normalizeTileNonUrlData","getUrlWithToken","generateTilesetAttributeUrls","I3SNodePagesTiles","constructor","tileset","options","nodesPerPage","nodePages","lodSelectionMetricType","initSelectedFormatsForTextureDefinitions","getNodeById","id","pageIndex","Math","floor","pendingNodePages","nodePageUrl","url","i3s","token","status","promise","nodeIndex","nodes","formTileFromNodePages","node","children","child","childNode","push","obb","contentUrl","textureUrl","materialDefinition","textureFormat","attributeUrls","isDracoGeometry","mesh","isDracoGeometryResult","geometry","getContentUrl","textureData","nodeMaterialDefinition","getInformationFromMaterial","material","format","name","resource","attributeStorageInfo","attribute","lodSelection","getLodSelection","textureLoaderOptions","meshGeometryData","result","geometryDefinition","geometryDefinitions","definition","geometryIndex","useDracoGeometry","geometryBuffers","findIndex","buffer","compressedAttributes","encoding","Boolean","metricType","maxError","sqrt","lodThreshold","PI","textureDataDefault","materialDefinitions","textureSetDefinitionIndex","pbrMetallicRoughness","baseColorTexture","textureSetDefinitionId","textureDefinitionsSelectedFormats","possibleI3sFormats","getSupportedTextureFormats","textureSetDefinitions","textureSetDefinition","formats","selectedFormat","i3sFormat","find","value","basis","containerFormat","module","useCompressedTextures","supportedCompressedFormats","has"],"mappings":";AAAA,SAAQA,IAAR,QAAmB,kBAAnB;AACA,SAAQC,6BAAR,EAAuCC,0BAAvC,QAAwE,sBAAxE;AAEA,SAAQC,iBAAR,QAAgC,4BAAhC;AACA,SAAQC,uBAAR,QAAsC,sBAAtC;AACA,SAAQC,eAAR,EAAyBC,4BAAzB,QAA4D,oBAA5D;AAKA,eAAe,MAAMC,iBAAN,CAAwB;AAgBrCC,EAAAA,WAAW,CAACC,OAAD,EAAmBC,OAAnB,EAAoC;AAAA;;AAAA,uCAdvB,EAcuB;;AAAA,8CAbgC,EAahC;;AAAA;;AAAA;;AAAA;;AAAA,+DATJ,EASI;;AAAA,kDARM,EAQN;;AAC7C,SAAKD,OAAL,GAAe,EAAC,GAAGA;AA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;AAChC1C,UAAAA,MAAM,EAAEhD,0BAA0B,EADF;AAEhC2F,UAAAA,eAAe,EAAE,MAFe;AAGhCC,UAAAA,MAAM,EAAE;AAHwB,SAAlC;AAKD;;AAED,WAAKZ,iCAAL,CAAuChD,IAAvC,CAA4CsD,cAA5C;AACD;AACF;;AAMOJ,EAAAA,0BAA0B,GAAa;AAC7C,UAAMG,OAAiB,GAAG,EAA1B;;AACA,QAAI,CAAC,KAAK7E,OAAL,CAAaa,GAAd,IAAqB,KAAKb,OAAL,CAAaa,GAAb,CAAiBwE,qBAA1C,EAAiE;AAE/D,YAAMC,0BAA0B,GAAG/F,6BAA6B,EAAhE;;AAGA,UAAI+F,0BAA0B,CAACC,GAA3B,CAA+B,MAA/B,CAAJ,EAA4C;AAC1CV,QAAAA,OAAO,CAACrD,IAAR,CAAa,UAAb;AACD;;AACD,UAAI8D,0BAA0B,CAACC,GAA3B,CAA+B,KAA/B,CAAJ,EAA2C;AACzCV,QAAAA,OAAO,CAACrD,IAAR,CAAa,KAAb;AACD;;AAIDqD,MAAAA,OAAO,CAACrD,IAAR,CAAa,MAAb;AACD;;AAEDqD,IAAAA,OAAO,CAACrD,IAAR,CAAa,KAAb;AACAqD,IAAAA,OAAO,CAACrD,IAAR,CAAa,KAAb;AACA,WAAOqD,OAAP;AACD;;AA7PoC","sourcesContent":["import {load} from '@loaders.gl/core';\nimport {getSupportedGPUTextureFormats, selectSupportedBasisFormat} from '@loaders.gl/textures';\nimport {Tileset, NodePage} from '../../types';\nimport {I3SNodePageLoader} from '../../i3s-node-page-loader';\nimport {normalizeTileNonUrlData} from '../parsers/parse-i3s';\nimport {getUrlWithToken, generateTilesetAttributeUrls} from '../utils/url-utils';\n\n/**\n * class I3SNodePagesTiles - loads nodePages and form i3s tiles from them\n */\nexport default class I3SNodePagesTiles {\n tileset: Tileset;\n nodePages: NodePage[] = [];\n pendingNodePages: {promise: Promise<NodePage>; status: 'Pending' | 'Done'}[] = [];\n nodesPerPage: number;\n options: {[key: string]: any};\n lodSelectionMetricType: any;\n textureDefinitionsSelectedFormats: any[] = [];\n private textureLoaderOptions: {[key: string]: any} = {};\n\n /**\n * @constructs\n * Create a I3SNodePagesTiles instance.\n * @param tileset - i3s tileset header ('layers/0')\n * @param options - i3s loader options\n */\n constructor(tileset: Tileset, options: object) {\n this.tileset = {...tileset}; // spread the tileset to avoid circular reference\n this.nodesPerPage = tileset.nodePages.nodesPerPage;\n this.lodSelectionMetricType = tileset.nodePages.lodSelectionMetricType;\n this.options = options;\n\n this.initSelectedFormatsForTextureDefinitions(tileset);\n }\n\n /**\n * Loads some nodePage and return a particular node from it\n * @param id - id of node through all node pages\n */\n async getNodeById(id: number) {\n const pageIndex = Math.floor(id / this.nodesPerPage);\n if (!this.nodePages[pageIndex] && !this.pendingNodePages[pageIndex]) {\n const nodePageUrl = getUrlWithToken(\n `${this.tileset.url}/nodepages/${pageIndex}`,\n this.options.i3s?.token\n );\n this.pendingNodePages[pageIndex] = {\n status: 'Pending',\n promise: load(nodePageUrl, I3SNodePageLoader, this.options)\n };\n this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;\n this.pendingNodePages[pageIndex].status = 'Done';\n }\n if (this.pendingNodePages[pageIndex].status === 'Pending') {\n this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;\n }\n const nodeIndex = id % this.nodesPerPage;\n return this.nodePages[pageIndex].nodes[nodeIndex];\n }\n\n /**\n * Forms tile header using node and tileset data\n * @param id - id of node through all node pages\n */\n // eslint-disable-next-line complexity\n async formTileFromNodePages(id: number) {\n const node = await this.getNodeById(id);\n const children: any[] = [];\n for (const child of node.children || []) {\n const childNode = await this.getNodeById(child);\n children.push({\n id: child,\n obb: childNode.obb\n });\n }\n\n let contentUrl = null;\n let textureUrl: string | null = null;\n let materialDefinition = null;\n let textureFormat = 'jpeg';\n let attributeUrls: string[] = [];\n let isDracoGeometry = false;\n\n if (node && node.mesh) {\n // Get geometry resource URL and type (compressed / non-compressed)\n const {url, isDracoGeometry: isDracoGeometryResult} = (node.mesh.geometry &&\n this.getContentUrl(node.mesh.geometry)) || {url: null, isDracoGeometry: null};\n contentUrl = url;\n isDracoGeometry = isDracoGeometryResult;\n\n const [textureData, nodeMaterialDefinition] = this.getInformationFromMaterial(\n node.mesh.material\n );\n materialDefinition = nodeMaterialDefinition;\n textureFormat = textureData.format || textureFormat;\n if (textureData.name) {\n textureUrl = `${this.tileset.url}/nodes/${node.mesh.material.resource}/textures/${textureData.name}`;\n }\n\n if (this.tileset.attributeStorageInfo) {\n attributeUrls = generateTilesetAttributeUrls(this.tileset, node.mesh.attribute.resource);\n }\n }\n\n const lodSelection = this.getLodSelection(node);\n\n return normalizeTileNonUrlData({\n id,\n lodSelection,\n obb: node.obb,\n contentUrl,\n textureUrl,\n attributeUrls,\n materialDefinition,\n textureFormat,\n textureLoaderOptions: this.textureLoaderOptions,\n children,\n isDracoGeometry\n });\n }\n\n /**\n * Forms url and type of geometry resource by nodepage's data and `geometryDefinitions` in the tileset\n * @param {Object} meshGeometryData - data about the node's mesh from the nodepage\n * @returns {Object} -\n * {string} url - url to the geometry resource\n * {boolean} isDracoGeometry - whether the geometry resource contain DRACO compressed geometry\n */\n private getContentUrl(meshGeometryData) {\n let result = {};\n const geometryDefinition = this.tileset.geometryDefinitions[meshGeometryData.definition];\n let geometryIndex = -1;\n // Try to find DRACO geometryDefinition of `useDracoGeometry` option is set\n if (this.options.i3s && this.options.i3s.useDracoGeometry) {\n geometryIndex = geometryDefinition.geometryBuffers.findIndex(\n (buffer) => buffer.compressedAttributes && buffer.compressedAttributes.encoding === 'draco'\n );\n }\n // If DRACO geometry is not applicable try to select non-compressed geometry\n if (geometryIndex === -1) {\n geometryIndex = geometryDefinition.geometryBuffers.findIndex(\n (buffer) => !buffer.compressedAttributes\n );\n }\n if (geometryIndex !== -1) {\n const isDracoGeometry = Boolean(\n geometryDefinition.geometryBuffers[geometryIndex].compressedAttributes\n );\n result = {\n url: `${this.tileset.url}/nodes/${meshGeometryData.resource}/geometries/${geometryIndex}`,\n isDracoGeometry\n };\n }\n return result;\n }\n\n /**\n * Forms 1.6 compatible LOD selection object from a nodepage's node data\n * @param {Object} node - a node from nodepage\n * @returns {Object[]} - Array of object of following properties:\n * {string} metricType - the label of the LOD metric\n * {number} maxError - the value of the metric\n */\n private getLodSelection(node): object[] {\n const lodSelection: object[] = [];\n if (this.lodSelectionMetricType === 'maxScreenThresholdSQ') {\n lodSelection.push({\n metricType: 'maxScreenThreshold',\n maxError: Math.sqrt(node.lodThreshold / (Math.PI * 0.25))\n });\n }\n lodSelection.push({\n metricType: this.lodSelectionMetricType,\n maxError: node.lodThreshold\n });\n return lodSelection;\n }\n\n /**\n * Returns information about texture and material from `materialDefinitions`\n * @param {Object} material - material data from nodepage\n * @returns {Object[]} - Couple [textureData, materialDefinition]\n * {string} textureData.name - path name of the texture\n * {string} textureData.format - format of the texture\n * materialDefinition - PBR-like material definition from `materialDefinitions`\n */\n private getInformationFromMaterial(material) {\n const textureDataDefault = {name: null, format: null};\n if (material) {\n const materialDefinition = this.tileset.materialDefinitions[material.definition];\n const textureSetDefinitionIndex =\n materialDefinition &&\n materialDefinition.pbrMetallicRoughness &&\n materialDefinition.pbrMetallicRoughness.baseColorTexture &&\n materialDefinition.pbrMetallicRoughness.baseColorTexture.textureSetDefinitionId;\n if (textureSetDefinitionIndex || textureSetDefinitionIndex === 0) {\n const textureData =\n this.textureDefinitionsSelectedFormats[textureSetDefinitionIndex] || textureDataDefault;\n return [textureData, materialDefinition];\n }\n return [textureDataDefault, materialDefinition];\n }\n return [textureDataDefault, null];\n }\n\n /**\n * Sets preferable and supported format for each textureDefinition of the tileset\n * @param {Object} tileset - I3S layer data\n * @returns {void}\n */\n private initSelectedFormatsForTextureDefinitions(tileset) {\n this.textureDefinitionsSelectedFormats = [];\n const possibleI3sFormats = this.getSupportedTextureFormats();\n const textureSetDefinitions = tileset.textureSetDefinitions || [];\n for (const textureSetDefinition of textureSetDefinitions) {\n const formats = (textureSetDefinition && textureSetDefinition.formats) || [];\n let selectedFormat: {format: string; name: string} | null = null;\n for (const i3sFormat of possibleI3sFormats) {\n const format = formats.find((value) => value.format === i3sFormat);\n if (format) {\n selectedFormat = format;\n break;\n }\n }\n // For I3S 1.8 need to define basis target format to decode\n if (selectedFormat && selectedFormat.format === 'ktx2') {\n this.textureLoaderOptions.basis = {\n format: selectSupportedBasisFormat(),\n containerFormat: 'ktx2',\n module: 'encoder'\n };\n }\n\n this.textureDefinitionsSelectedFormats.push(selectedFormat);\n }\n }\n\n /**\n * Returns the array of supported texture format\n * @returns list of format strings\n */\n private getSupportedTextureFormats(): string[] {\n const formats: string[] = [];\n if (!this.options.i3s || this.options.i3s.useCompressedTextures) {\n // I3S 1.7 selection\n const supportedCompressedFormats = getSupportedGPUTextureFormats();\n // List of possible in i3s formats:\n // https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md\n if (supportedCompressedFormats.has('etc2')) {\n formats.push('ktx-etc2');\n }\n if (supportedCompressedFormats.has('dxt')) {\n formats.push('dds');\n }\n\n // I3S 1.8 selection\n // ktx2 wraps basis texture which at the edge case can be decoded as uncompressed image\n formats.push('ktx2');\n }\n\n formats.push('jpg');\n formats.push('png');\n return formats;\n }\n}\n"],"file":"i3s-nodepages-tiles.js"}
1
+ {"version":3,"sources":["../../../src/lib/helpers/i3s-nodepages-tiles.ts"],"names":["load","getSupportedGPUTextureFormats","selectSupportedBasisFormat","I3SNodePageLoader","normalizeTileNonUrlData","getUrlWithToken","generateTilesetAttributeUrls","I3SNodePagesTiles","constructor","tileset","options","nodesPerPage","nodePages","lodSelectionMetricType","initSelectedFormatsForTextureDefinitions","getNodeById","id","pageIndex","Math","floor","pendingNodePages","nodePageUrl","url","i3s","token","status","promise","nodeIndex","nodes","formTileFromNodePages","node","children","child","childNode","push","toString","obb","contentUrl","textureUrl","materialDefinition","textureFormat","attributeUrls","isDracoGeometry","mesh","isDracoGeometryResult","geometry","getContentUrl","textureData","nodeMaterialDefinition","getInformationFromMaterial","material","format","name","resource","attributeStorageInfo","attribute","lodSelection","getLodSelection","textureLoaderOptions","meshGeometryData","result","geometryDefinition","geometryDefinitions","definition","geometryIndex","useDracoGeometry","geometryBuffers","findIndex","buffer","compressedAttributes","encoding","Boolean","metricType","maxError","sqrt","lodThreshold","PI","informationFromMaterial","materialDefinitions","textureSetDefinitionIndex","pbrMetallicRoughness","baseColorTexture","textureSetDefinitionId","textureDefinitionsSelectedFormats","possibleI3sFormats","getSupportedTextureFormats","textureSetDefinitions","textureSetDefinition","formats","selectedFormat","i3sFormat","find","value","basis","containerFormat","module","useCompressedTextures","supportedCompressedFormats","has"],"mappings":";AAAA,SAAQA,IAAR,QAAmB,kBAAnB;AACA,SAAQC,6BAAR,EAAuCC,0BAAvC,QAAwE,sBAAxE;AACA,SAAQC,iBAAR,QAAgC,4BAAhC;AACA,SAAQC,uBAAR,QAAsC,sBAAtC;AACA,SAAQC,eAAR,EAAyBC,4BAAzB,QAA4D,oBAA5D;AAkBA,eAAe,MAAMC,iBAAN,CAAwB;AAgBrCC,EAAAA,WAAW,CAACC,OAAD,EAA4BC,OAA5B,EAAoD;AAAA;;AAAA;;AAAA,uCAdvC,EAcuC;;AAAA,8CAbgB,EAahB;;AAAA;;AAAA;;AAAA;;AAAA,+DAT0B,EAS1B;;AAAA,kDARV,EAQU;;AAC7D,SAAKD,OAAL,GAAe,EAAC,GAAGA;AAAJ,KAAf;AACA,SAAKE,YAAL,GAAoB,uBAAAF,OAAO,CAACG,SAAR,0EAAmBD,YAAnB,KAAmC,EAAvD;AACA,SAAKE,sBAAL,0BAA8BJ,OAAO,CAACG,SAAtC,wDAA8B,oBAAmBC,sBAAjD;AACA,SAAKH,OAAL,GAAeA,OAAf;AAEA,SAAKI,wCAAL,CAA8CL,OAA9C;AACD;;AAMgB,QAAXM,WAAW,CAACC,EAAD,EAAkC;AACjD,UAAMC,SAAS,GAAGC,IAAI,CAACC,KAAL,CAAWH,EAAE,GA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AAKb,OAAL,CAAaa,GAAb,CAAiByE,qBAA1C,EAAiE;AAE/D,YAAMC,0BAA0B,GAAGhG,6BAA6B,EAAhE;;AAGA,UAAIgG,0BAA0B,CAACC,GAA3B,CAA+B,MAA/B,CAAJ,EAA4C;AAC1CV,QAAAA,OAAO,CAACtD,IAAR,CAAa,UAAb;AACD;;AACD,UAAI+D,0BAA0B,CAACC,GAA3B,CAA+B,KAA/B,CAAJ,EAA2C;AACzCV,QAAAA,OAAO,CAACtD,IAAR,CAAa,KAAb;AACD;;AAIDsD,MAAAA,OAAO,CAACtD,IAAR,CAAa,MAAb;AACD;;AAEDsD,IAAAA,OAAO,CAACtD,IAAR,CAAa,KAAb;AACAsD,IAAAA,OAAO,CAACtD,IAAR,CAAa,KAAb;AACA,WAAOsD,OAAP;AACD;;AAjQoC","sourcesContent":["import {load} from '@loaders.gl/core';\nimport {getSupportedGPUTextureFormats, selectSupportedBasisFormat} from '@loaders.gl/textures';\nimport {I3SNodePageLoader} from '../../i3s-node-page-loader';\nimport {normalizeTileNonUrlData} from '../parsers/parse-i3s';\nimport {getUrlWithToken, generateTilesetAttributeUrls} from '../utils/url-utils';\nimport type {LoaderOptions} from '@loaders.gl/loader-utils';\nimport {\n I3STilesetHeader,\n LodSelection,\n NodePage,\n NodeInPage,\n Obb,\n MeshMaterial,\n I3SMaterialDefinition,\n I3STextureFormat,\n MeshGeometry,\n I3STileHeader\n} from '../../types';\n\n/**\n * class I3SNodePagesTiles - loads nodePages and form i3s tiles from them\n */\nexport default class I3SNodePagesTiles {\n tileset: I3STilesetHeader;\n nodePages: NodePage[] = [];\n pendingNodePages: {promise: Promise<NodePage>; status: 'Pending' | 'Done'}[] = [];\n nodesPerPage: number;\n options: LoaderOptions;\n lodSelectionMetricType?: string;\n textureDefinitionsSelectedFormats: ({format: I3STextureFormat; name: string} | null)[] = [];\n private textureLoaderOptions: {[key: string]: any} = {};\n\n /**\n * @constructs\n * Create a I3SNodePagesTiles instance.\n * @param tileset - i3s tileset header ('layers/0')\n * @param options - i3s loader options\n */\n constructor(tileset: I3STilesetHeader, options: LoaderOptions) {\n this.tileset = {...tileset}; // spread the tileset to avoid circular reference\n this.nodesPerPage = tileset.nodePages?.nodesPerPage || 64;\n this.lodSelectionMetricType = tileset.nodePages?.lodSelectionMetricType;\n this.options = options;\n\n this.initSelectedFormatsForTextureDefinitions(tileset);\n }\n\n /**\n * Loads some nodePage and return a particular node from it\n * @param id - id of node through all node pages\n */\n async getNodeById(id: number): Promise<NodeInPage> {\n const pageIndex = Math.floor(id / this.nodesPerPage);\n if (!this.nodePages[pageIndex] && !this.pendingNodePages[pageIndex]) {\n const nodePageUrl = getUrlWithToken(\n `${this.tileset.url}/nodepages/${pageIndex}`,\n this.options.i3s?.token\n );\n this.pendingNodePages[pageIndex] = {\n status: 'Pending',\n promise: load(nodePageUrl, I3SNodePageLoader, this.options)\n };\n this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;\n this.pendingNodePages[pageIndex].status = 'Done';\n }\n if (this.pendingNodePages[pageIndex].status === 'Pending') {\n this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;\n }\n const nodeIndex = id % this.nodesPerPage;\n return this.nodePages[pageIndex].nodes[nodeIndex];\n }\n\n /**\n * Forms tile header using node and tileset data\n * @param id - id of node through all node pages\n */\n // eslint-disable-next-line complexity\n async formTileFromNodePages(id: number): Promise<I3STileHeader> {\n const node: NodeInPage = await this.getNodeById(id);\n const children: {id: string; obb: Obb}[] = [];\n for (const child of node.children || []) {\n const childNode = await this.getNodeById(child);\n children.push({\n id: child.toString(),\n obb: childNode.obb\n });\n }\n\n let contentUrl: string | undefined;\n let textureUrl: string | undefined;\n let materialDefinition: I3SMaterialDefinition | undefined;\n let textureFormat: I3STextureFormat = 'jpg';\n let attributeUrls: string[] = [];\n let isDracoGeometry: boolean = false;\n\n if (node && node.mesh) {\n // Get geometry resource URL and type (compressed / non-compressed)\n const {url, isDracoGeometry: isDracoGeometryResult} = (node.mesh.geometry &&\n this.getContentUrl(node.mesh.geometry)) || {isDracoGeometry: false};\n contentUrl = url;\n isDracoGeometry = isDracoGeometryResult;\n\n const {textureData, materialDefinition: nodeMaterialDefinition} =\n this.getInformationFromMaterial(node.mesh.material);\n materialDefinition = nodeMaterialDefinition;\n textureFormat = textureData.format || textureFormat;\n if (textureData.name) {\n textureUrl = `${this.tileset.url}/nodes/${node.mesh.material.resource}/textures/${textureData.name}`;\n }\n\n if (this.tileset.attributeStorageInfo) {\n attributeUrls = generateTilesetAttributeUrls(this.tileset, node.mesh.attribute.resource);\n }\n }\n\n const lodSelection = this.getLodSelection(node);\n\n return normalizeTileNonUrlData({\n id: id.toString(),\n lodSelection,\n obb: node.obb,\n contentUrl,\n textureUrl,\n attributeUrls,\n materialDefinition,\n textureFormat,\n textureLoaderOptions: this.textureLoaderOptions,\n children,\n isDracoGeometry\n });\n }\n\n /**\n * Forms url and type of geometry resource by nodepage's data and `geometryDefinitions` in the tileset\n * @param - data about the node's mesh from the nodepage\n * @returns -\n * {string} url - url to the geometry resource\n * {boolean} isDracoGeometry - whether the geometry resource contain DRACO compressed geometry\n */\n private getContentUrl(meshGeometryData: MeshGeometry) {\n let result: {url: string; isDracoGeometry: boolean} | null = null;\n // @ts-ignore\n const geometryDefinition = this.tileset.geometryDefinitions[meshGeometryData.definition];\n let geometryIndex = -1;\n // Try to find DRACO geometryDefinition of `useDracoGeometry` option is set\n if (this.options.i3s && this.options.i3s.useDracoGeometry) {\n geometryIndex = geometryDefinition.geometryBuffers.findIndex(\n (buffer) => buffer.compressedAttributes && buffer.compressedAttributes.encoding === 'draco'\n );\n }\n // If DRACO geometry is not applicable try to select non-compressed geometry\n if (geometryIndex === -1) {\n geometryIndex = geometryDefinition.geometryBuffers.findIndex(\n (buffer) => !buffer.compressedAttributes\n );\n }\n if (geometryIndex !== -1) {\n const isDracoGeometry = Boolean(\n geometryDefinition.geometryBuffers[geometryIndex].compressedAttributes\n );\n result = {\n url: `${this.tileset.url}/nodes/${meshGeometryData.resource}/geometries/${geometryIndex}`,\n isDracoGeometry\n };\n }\n return result;\n }\n\n /**\n * Forms 1.6 compatible LOD selection object from a nodepage's node data\n * @param node - a node from nodepage\n * @returns- Array of LodSelection\n */\n private getLodSelection(node: NodeInPage): LodSelection[] {\n const lodSelection: LodSelection[] = [];\n if (this.lodSelectionMetricType === 'maxScreenThresholdSQ') {\n lodSelection.push({\n metricType: 'maxScreenThreshold',\n // @ts-ignore\n maxError: Math.sqrt(node.lodThreshold / (Math.PI * 0.25))\n });\n }\n lodSelection.push({\n metricType: this.lodSelectionMetricType,\n // @ts-ignore\n maxError: node.lodThreshold\n });\n return lodSelection;\n }\n\n /**\n * Returns information about texture and material from `materialDefinitions`\n * @param material - material data from nodepage\n * @returns - Couple {textureData, materialDefinition}\n * {string} textureData.name - path name of the texture\n * {string} textureData.format - format of the texture\n * materialDefinition - PBR-like material definition from `materialDefinitions`\n */\n private getInformationFromMaterial(material: MeshMaterial) {\n const informationFromMaterial: {\n textureData: {name: string | null; format?: I3STextureFormat};\n materialDefinition?: I3SMaterialDefinition;\n } = {textureData: {name: null}};\n\n if (material) {\n const materialDefinition = this.tileset.materialDefinitions?.[material.definition];\n if (materialDefinition) {\n informationFromMaterial.materialDefinition = materialDefinition;\n const textureSetDefinitionIndex =\n materialDefinition?.pbrMetallicRoughness?.baseColorTexture?.textureSetDefinitionId;\n\n if (typeof textureSetDefinitionIndex === 'number') {\n informationFromMaterial.textureData =\n this.textureDefinitionsSelectedFormats[textureSetDefinitionIndex] ||\n informationFromMaterial.textureData;\n }\n }\n }\n return informationFromMaterial;\n }\n\n /**\n * Sets preferable and supported format for each textureDefinition of the tileset\n * @param tileset - I3S layer data\n * @returns\n */\n private initSelectedFormatsForTextureDefinitions(tileset: I3STilesetHeader): void {\n this.textureDefinitionsSelectedFormats = [];\n const possibleI3sFormats = this.getSupportedTextureFormats();\n const textureSetDefinitions = tileset.textureSetDefinitions || [];\n for (const textureSetDefinition of textureSetDefinitions) {\n const formats = (textureSetDefinition && textureSetDefinition.formats) || [];\n let selectedFormat: {name: string; format: I3STextureFormat} | null = null;\n for (const i3sFormat of possibleI3sFormats) {\n const format = formats.find((value) => value.format === i3sFormat);\n if (format) {\n selectedFormat = format;\n break;\n }\n }\n // For I3S 1.8 need to define basis target format to decode\n if (selectedFormat && selectedFormat.format === 'ktx2') {\n this.textureLoaderOptions.basis = {\n format: selectSupportedBasisFormat(),\n containerFormat: 'ktx2',\n module: 'encoder'\n };\n }\n\n this.textureDefinitionsSelectedFormats.push(selectedFormat);\n }\n }\n\n /**\n * Returns the array of supported texture format\n * @returns list of format strings\n */\n private getSupportedTextureFormats(): I3STextureFormat[] {\n const formats: I3STextureFormat[] = [];\n if (!this.options.i3s || this.options.i3s.useCompressedTextures) {\n // I3S 1.7 selection\n const supportedCompressedFormats = getSupportedGPUTextureFormats();\n // List of possible in i3s formats:\n // https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md\n if (supportedCompressedFormats.has('etc2')) {\n formats.push('ktx-etc2');\n }\n if (supportedCompressedFormats.has('dxt')) {\n formats.push('dds');\n }\n\n // I3S 1.8 selection\n // ktx2 wraps basis texture which at the edge case can be decoded as uncompressed image\n formats.push('ktx2');\n }\n\n formats.push('jpg');\n formats.push('png');\n return formats;\n }\n}\n"],"file":"i3s-nodepages-tiles.js"}
@@ -0,0 +1,40 @@
1
+ export declare function getConstructorForDataFormat(dataType: string): Uint8ArrayConstructor | Uint16ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor;
2
+ export declare const GL_TYPE_MAP: {
3
+ [key: string]: number;
4
+ };
5
+ /**
6
+ * Returns how many bytes a type occupies
7
+ * @param dataType
8
+ * @returns
9
+ */
10
+ export declare function sizeOf(dataType: string): number;
11
+ export declare const STRING_ATTRIBUTE_TYPE = "String";
12
+ export declare const OBJECT_ID_ATTRIBUTE_TYPE = "Oid32";
13
+ export declare const FLOAT_64_TYPE = "Float64";
14
+ export declare const INT_16_ATTRIBUTE_TYPE = "Int16";
15
+ export declare enum COORDINATE_SYSTEM {
16
+ /**
17
+ * `LNGLAT` if rendering into a geospatial viewport, `CARTESIAN` otherwise
18
+ */
19
+ DEFAULT = -1,
20
+ /**
21
+ * Positions are interpreted as [lng, lat, elevation]
22
+ * lng lat are degrees, elevation is meters. distances as meters.
23
+ */
24
+ LNGLAT = 1,
25
+ /**
26
+ * Positions are interpreted as meter offsets, distances as meters
27
+ */
28
+ METER_OFFSETS = 2,
29
+ /**
30
+ * Positions are interpreted as lng lat offsets: [deltaLng, deltaLat, elevation]
31
+ * deltaLng, deltaLat are delta degrees, elevation is meters.
32
+ * distances as meters.
33
+ */
34
+ LNGLAT_OFFSETS = 3,
35
+ /**
36
+ * Non-geospatial
37
+ */
38
+ CARTESIAN = 0
39
+ }
40
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/constants.ts"],"names":[],"mappings":"AAGA,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,+HAe3D;AAED,eAAO,MAAM,WAAW,EAAE;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAM/C,CAAC;AACF;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAkB/C;AAED,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,wBAAwB,UAAU,CAAC;AAChD,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,qBAAqB,UAAU,CAAC;AAI7C,oBAAY,iBAAiB;IAC3B;;OAEG;IACH,OAAO,KAAK;IACZ;;;OAGG;IACH,MAAM,IAAI;IACV;;OAEG;IACH,aAAa,IAAI;IACjB;;;;OAIG;IACH,cAAc,IAAI;IAClB;;OAEG;IACH,SAAS,IAAI;CACd"}
@@ -1,11 +1,26 @@
1
1
  import GL from '@luma.gl/constants';
2
- export const TYPE_ARRAY_MAP = {
3
- UInt8: Uint8Array,
4
- UInt16: Uint16Array,
5
- UInt32: Uint32Array,
6
- Float32: Float32Array,
7
- UInt64: Float64Array
8
- };
2
+ import { DATA_TYPE } from '../../types';
3
+ export function getConstructorForDataFormat(dataType) {
4
+ switch (dataType) {
5
+ case DATA_TYPE.UInt8:
6
+ return Uint8Array;
7
+
8
+ case DATA_TYPE.UInt16:
9
+ return Uint16Array;
10
+
11
+ case DATA_TYPE.UInt32:
12
+ return Uint32Array;
13
+
14
+ case DATA_TYPE.Float32:
15
+ return Float32Array;
16
+
17
+ case DATA_TYPE.UInt64:
18
+ return Float64Array;
19
+
20
+ default:
21
+ throw new Error("parse i3s tile content: unknown type of data: ".concat(dataType));
22
+ }
23
+ }
9
24
  export const GL_TYPE_MAP = {
10
25
  UInt8: GL.UNSIGNED_BYTE,
11
26
  UInt16: GL.UNSIGNED_INT,
@@ -13,39 +28,40 @@ export const GL_TYPE_MAP = {
13
28
  UInt32: GL.UNSIGNED_INT,
14
29
  UInt64: GL.DOUBLE
15
30
  };
16
- export const I3S_NAMED_VERTEX_ATTRIBUTES = {
17
- position: 'position',
18
- normal: 'normal',
19
- uv0: 'uv0',
20
- color: 'color',
21
- region: 'region'
22
- };
23
- export const I3S_NAMED_GEOMETRY_ATTRIBUTES = {
24
- vertexAttributes: 'vertexAttributes',
25
- featureAttributeOrder: 'featureAttributeOrder',
26
- featureAttributes: 'featureAttributes'
27
- };
28
- export const I3S_NAMED_HEADER_ATTRIBUTES = {
29
- header: 'header',
30
- vertexCount: 'vertexCount',
31
- featureCount: 'featureCount'
32
- };
33
- export const SIZEOF = {
34
- UInt8: 1,
35
- UInt16: 2,
36
- UInt32: 4,
37
- Float32: 4,
38
- UInt64: 8
39
- };
31
+ export function sizeOf(dataType) {
32
+ switch (dataType) {
33
+ case DATA_TYPE.UInt8:
34
+ return 1;
35
+
36
+ case DATA_TYPE.UInt16:
37
+ case DATA_TYPE.Int16:
38
+ return 2;
39
+
40
+ case DATA_TYPE.UInt32:
41
+ case DATA_TYPE.Int32:
42
+ case DATA_TYPE.Float32:
43
+ return 4;
44
+
45
+ case DATA_TYPE.UInt64:
46
+ case DATA_TYPE.Int64:
47
+ case DATA_TYPE.Float64:
48
+ return 8;
49
+
50
+ default:
51
+ throw new Error("parse i3s tile content: unknown size of data: ".concat(dataType));
52
+ }
53
+ }
40
54
  export const STRING_ATTRIBUTE_TYPE = 'String';
41
55
  export const OBJECT_ID_ATTRIBUTE_TYPE = 'Oid32';
42
56
  export const FLOAT_64_TYPE = 'Float64';
43
57
  export const INT_16_ATTRIBUTE_TYPE = 'Int16';
44
- export const COORDINATE_SYSTEM = {
45
- DEFAULT: -1,
46
- LNGLAT: 1,
47
- METER_OFFSETS: 2,
48
- LNGLAT_OFFSETS: 3,
49
- CARTESIAN: 0
50
- };
58
+ export let COORDINATE_SYSTEM;
59
+
60
+ (function (COORDINATE_SYSTEM) {
61
+ COORDINATE_SYSTEM[COORDINATE_SYSTEM["DEFAULT"] = -1] = "DEFAULT";
62
+ COORDINATE_SYSTEM[COORDINATE_SYSTEM["LNGLAT"] = 1] = "LNGLAT";
63
+ COORDINATE_SYSTEM[COORDINATE_SYSTEM["METER_OFFSETS"] = 2] = "METER_OFFSETS";
64
+ COORDINATE_SYSTEM[COORDINATE_SYSTEM["LNGLAT_OFFSETS"] = 3] = "LNGLAT_OFFSETS";
65
+ COORDINATE_SYSTEM[COORDINATE_SYSTEM["CARTESIAN"] = 0] = "CARTESIAN";
66
+ })(COORDINATE_SYSTEM || (COORDINATE_SYSTEM = {}));
51
67
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/parsers/constants.ts"],"names":["GL","TYPE_ARRAY_MAP","UInt8","Uint8Array","UInt16","Uint16Array","UInt32","Uint32Array","Float32","Float32Array","UInt64","Float64Array","GL_TYPE_MAP","UNSIGNED_BYTE","UNSIGNED_INT","FLOAT","DOUBLE","I3S_NAMED_VERTEX_ATTRIBUTES","position","normal","uv0","color","region","I3S_NAMED_GEOMETRY_ATTRIBUTES","vertexAttributes","featureAttributeOrder","featureAttributes","I3S_NAMED_HEADER_ATTRIBUTES","header","vertexCount","featureCount","SIZEOF","STRING_ATTRIBUTE_TYPE","OBJECT_ID_ATTRIBUTE_TYPE","FLOAT_64_TYPE","INT_16_ATTRIBUTE_TYPE","COORDINATE_SYSTEM","DEFAULT","LNGLAT","METER_OFFSETS","LNGLAT_OFFSETS","CARTESIAN"],"mappings":"AAAA,OAAOA,EAAP,MAAe,oBAAf;AAEA,OAAO,MAAMC,cAAc,GAAG;AAC5BC,EAAAA,KAAK,EAAEC,UADqB;AAE5BC,EAAAA,MAAM,EAAEC,WAFoB;AAG5BC,EAAAA,MAAM,EAAEC,WAHoB;AAI5BC,EAAAA,OAAO,EAAEC,YAJmB;AAK5BC,EAAAA,MAAM,EAAEC;AALoB,CAAvB;AAQP,OAAO,MAAMC,WAAW,GAAG;AACzBV,EAAAA,KAAK,EAAEF,EAAE,CAACa,aADe;AAEzBT,EAAAA,MAAM,EAAEJ,EAAE,CAACc,YAFc;AAGzBN,EAAAA,OAAO,EAAER,EAAE,CAACe,KAHa;AAIzBT,EAAAA,MAAM,EAAEN,EAAE,CAACc,YAJc;AAKzBJ,EAAAA,MAAM,EAAEV,EAAE,CAACgB;AALc,CAApB;AAQP,OAAO,MAAMC,2BAA2B,GAAG;AACzCC,EAAAA,QAAQ,EAAE,UAD+B;AAEzCC,EAAAA,MAAM,EAAE,QAFiC;AAGzCC,EAAAA,GAAG,EAAE,KAHoC;AAIzCC,EAAAA,KAAK,EAAE,OAJkC;AAKzCC,EAAAA,MAAM,EAAE;AALiC,CAApC;AAQP,OAAO,MAAMC,6BAA6B,GAAG;AAC3CC,EAAAA,gBAAgB,EAAE,kBADyB;AAE3CC,EAAAA,qBAAqB,EAAE,uBAFoB;AAG3CC,EAAAA,iBAAiB,EAAE;AAHwB,CAAtC;AAMP,OAAO,MAAMC,2BAA2B,GAAG;AACzCC,EAAAA,MAAM,EAAE,QADiC;AAEzCC,EAAAA,WAAW,EAAE,aAF4B;AAGzCC,EAAAA,YAAY,EAAE;AAH2B,CAApC;AAMP,OAAO,MAAMC,MAAM,GAAG;AACpB7B,EAAAA,KAAK,EAAE,CADa;AAEpBE,EAAAA,MAAM,EAAE,CAFY;AAGpBE,EAAAA,MAAM,EAAE,CAHY;AAIpBE,EAAAA,OAAO,EAAE,CAJW;AAKpBE,EAAAA,MAAM,EAAE;AALY,CAAf;AAQP,OAAO,MAAMsB,qBAAqB,GAAG,QAA9B;AACP,OAAO,MAAMC,wBAAwB,GAAG,OAAjC;AACP,OAAO,MAAMC,aAAa,GAAG,SAAtB;AACP,OAAO,MAAMC,qBAAqB,GAAG,OAA9B;AAIP,OAAO,MAAMC,iBAAiB,GAAG;AAE/BC,EAAAA,OAAO,EAAE,CAAC,CAFqB;AAK/BC,EAAAA,MAAM,EAAE,CALuB;AAQ/BC,EAAAA,aAAa,EAAE,CARgB;AAa/BC,EAAAA,cAAc,EAAE,CAbe;AAgB/BC,EAAAA,SAAS,EAAE;AAhBoB,CAA1B","sourcesContent":["import GL from '@luma.gl/constants';\n\nexport const TYPE_ARRAY_MAP = {\n UInt8: Uint8Array,\n UInt16: Uint16Array,\n UInt32: Uint32Array,\n Float32: Float32Array,\n UInt64: Float64Array\n};\n\nexport const GL_TYPE_MAP = {\n UInt8: GL.UNSIGNED_BYTE,\n UInt16: GL.UNSIGNED_INT,\n Float32: GL.FLOAT,\n UInt32: GL.UNSIGNED_INT,\n UInt64: GL.DOUBLE\n};\n\nexport const I3S_NAMED_VERTEX_ATTRIBUTES = {\n position: 'position',\n normal: 'normal',\n uv0: 'uv0',\n color: 'color',\n region: 'region'\n};\n\nexport const I3S_NAMED_GEOMETRY_ATTRIBUTES = {\n vertexAttributes: 'vertexAttributes',\n featureAttributeOrder: 'featureAttributeOrder',\n featureAttributes: 'featureAttributes'\n};\n\nexport const I3S_NAMED_HEADER_ATTRIBUTES = {\n header: 'header',\n vertexCount: 'vertexCount',\n featureCount: 'featureCount'\n};\n\nexport const SIZEOF = {\n UInt8: 1,\n UInt16: 2,\n UInt32: 4,\n Float32: 4,\n UInt64: 8\n};\n\nexport const STRING_ATTRIBUTE_TYPE = 'String';\nexport const OBJECT_ID_ATTRIBUTE_TYPE = 'Oid32';\nexport const FLOAT_64_TYPE = 'Float64';\nexport const INT_16_ATTRIBUTE_TYPE = 'Int16';\n\n// https://github.com/visgl/deck.gl/blob/9548f43cba2234a1f4877b6b17f6c88eb35b2e08/modules/core/src/lib/constants.js#L27\n// Describes the format of positions\nexport const COORDINATE_SYSTEM = {\n // `LNGLAT` if rendering into a geospatial viewport, `CARTESIAN` otherwise\n DEFAULT: -1,\n // Positions are interpreted as [lng, lat, elevation]\n // lng lat are degrees, elevation is meters. distances as meters.\n LNGLAT: 1,\n\n // Positions are interpreted as meter offsets, distances as meters\n METER_OFFSETS: 2,\n\n // Positions are interpreted as lng lat offsets: [deltaLng, deltaLat, elevation]\n // deltaLng, deltaLat are delta degrees, elevation is meters.\n // distances as meters.\n LNGLAT_OFFSETS: 3,\n\n // Non-geospatial\n CARTESIAN: 0\n};\n"],"file":"constants.js"}
1
+ {"version":3,"sources":["../../../src/lib/parsers/constants.ts"],"names":["GL","DATA_TYPE","getConstructorForDataFormat","dataType","UInt8","Uint8Array","UInt16","Uint16Array","UInt32","Uint32Array","Float32","Float32Array","UInt64","Float64Array","Error","GL_TYPE_MAP","UNSIGNED_BYTE","UNSIGNED_INT","FLOAT","DOUBLE","sizeOf","Int16","Int32","Int64","Float64","STRING_ATTRIBUTE_TYPE","OBJECT_ID_ATTRIBUTE_TYPE","FLOAT_64_TYPE","INT_16_ATTRIBUTE_TYPE","COORDINATE_SYSTEM"],"mappings":"AAAA,OAAOA,EAAP,MAAe,oBAAf;AACA,SAAQC,SAAR,QAAwB,aAAxB;AAEA,OAAO,SAASC,2BAAT,CAAqCC,QAArC,EAA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AO,MAAMC,qBAAqB,GAAG,OAA9B;AAIP,WAAYC,iBAAZ;;WAAYA,iB;AAAAA,EAAAA,iB,CAAAA,iB;AAAAA,EAAAA,iB,CAAAA,iB;AAAAA,EAAAA,iB,CAAAA,iB;AAAAA,EAAAA,iB,CAAAA,iB;AAAAA,EAAAA,iB,CAAAA,iB;GAAAA,iB,KAAAA,iB","sourcesContent":["import GL from '@luma.gl/constants';\nimport {DATA_TYPE} from '../../types';\n\nexport function getConstructorForDataFormat(dataType: string) {\n switch (dataType) {\n case DATA_TYPE.UInt8:\n return Uint8Array;\n case DATA_TYPE.UInt16:\n return Uint16Array;\n case DATA_TYPE.UInt32:\n return Uint32Array;\n case DATA_TYPE.Float32:\n return Float32Array;\n case DATA_TYPE.UInt64:\n return Float64Array;\n default:\n throw new Error(`parse i3s tile content: unknown type of data: ${dataType}`);\n }\n}\n\nexport const GL_TYPE_MAP: {[key: string]: number} = {\n UInt8: GL.UNSIGNED_BYTE,\n UInt16: GL.UNSIGNED_INT,\n Float32: GL.FLOAT,\n UInt32: GL.UNSIGNED_INT,\n UInt64: GL.DOUBLE\n};\n/**\n * Returns how many bytes a type occupies\n * @param dataType\n * @returns\n */\nexport function sizeOf(dataType: string): number {\n switch (dataType) {\n case DATA_TYPE.UInt8:\n return 1;\n case DATA_TYPE.UInt16:\n case DATA_TYPE.Int16:\n return 2;\n case DATA_TYPE.UInt32:\n case DATA_TYPE.Int32:\n case DATA_TYPE.Float32:\n return 4;\n case DATA_TYPE.UInt64:\n case DATA_TYPE.Int64:\n case DATA_TYPE.Float64:\n return 8;\n default:\n throw new Error(`parse i3s tile content: unknown size of data: ${dataType}`);\n }\n}\n\nexport const STRING_ATTRIBUTE_TYPE = 'String';\nexport const OBJECT_ID_ATTRIBUTE_TYPE = 'Oid32';\nexport const FLOAT_64_TYPE = 'Float64';\nexport const INT_16_ATTRIBUTE_TYPE = 'Int16';\n\n// https://github.com/visgl/deck.gl/blob/9548f43cba2234a1f4877b6b17f6c88eb35b2e08/modules/core/src/lib/constants.js#L27\n// Describes the format of positions\nexport enum COORDINATE_SYSTEM {\n /**\n * `LNGLAT` if rendering into a geospatial viewport, `CARTESIAN` otherwise\n */\n DEFAULT = -1,\n /**\n * Positions are interpreted as [lng, lat, elevation]\n * lng lat are degrees, elevation is meters. distances as meters.\n */\n LNGLAT = 1,\n /**\n * Positions are interpreted as meter offsets, distances as meters\n */\n METER_OFFSETS = 2,\n /**\n * Positions are interpreted as lng lat offsets: [deltaLng, deltaLat, elevation]\n * deltaLng, deltaLat are delta degrees, elevation is meters.\n * distances as meters.\n */\n LNGLAT_OFFSETS = 3,\n /**\n * Non-geospatial\n */\n CARTESIAN = 0\n}\n"],"file":"constants.js"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Get particular tile and creates attribute object inside.
3
+ * @param {ArrayBuffer} arrayBuffer
4
+ * @param {Object} options
5
+ * @returns {Promise<object>}
6
+ */
7
+ export declare function parseI3STileAttribute(arrayBuffer: any, options: any): Promise<{
8
+ [x: number]: string[] | Int16Array | Uint32Array | Float64Array | null;
9
+ }>;
10
+ //# sourceMappingURL=parse-i3s-attribute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-i3s-attribute.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-i3s-attribute.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,WAAW,KAAA,EAAE,OAAO,KAAA;;GAS/D"}
@@ -0,0 +1,9 @@
1
+ import type { BuildingSceneLayerTileset } from '../../types';
2
+ /**
3
+ * Parses Builiding Scene Layer and creates tileset
4
+ * @param data
5
+ * @param options
6
+ * @param context
7
+ */
8
+ export declare function parseBuildingSceneLayer(data: ArrayBuffer, url: string): Promise<BuildingSceneLayerTileset>;
9
+ //# sourceMappingURL=parse-i3s-building-scene-layer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-i3s-building-scene-layer.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-i3s-building-scene-layer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,yBAAyB,EAAwB,MAAM,aAAa,CAAC;AAIlF;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,yBAAyB,CAAC,CAQpC"}
@@ -20,6 +20,7 @@ function parseSublayersTree(sublayers, url) {
20
20
  const {
21
21
  id,
22
22
  layerType,
23
+ visibility = true,
23
24
  ...rest
24
25
  } = subLayer;
25
26
 
@@ -29,6 +30,7 @@ function parseSublayersTree(sublayers, url) {
29
30
  url: sublayerUrl,
30
31
  id,
31
32
  layerType,
33
+ visibility,
32
34
  ...rest
33
35
  });
34
36
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/parsers/parse-i3s-building-scene-layer.ts"],"names":["OBJECT_3D_LAYER_TYPE","parseBuildingSceneLayer","data","url","layer0","JSON","parse","TextDecoder","decode","sublayers","header","parseSublayersTree","layers","index","length","subLayer","id","layerType","rest","sublayerUrl","push"],"mappings":"AAEA,MAAMA,oBAAoB,GAAG,UAA7B;AAQA,OAAO,eAAeC,uBAAf,CACLC,IADK,EAELC,GAFK,EAG+B;AACpC,QAAMC,MAAM,GAAGC,IAAI,CAACC,KAAL,CAAW,IAAIC,WAAJ,GAAkBC,MAAlB,CAAyBN,IAAzB,CAAX,CAAf;AACA,QAAM;AAACO,IAAAA;AAAD,MAAcL,MAApB;AAEA,SAAO;AACLM,IAAAA,MAAM,EAAEN,MADH;AAELK,IAAAA,SAAS,EAAEE,kBAAkB,CAACF,SAAD,EAAYN,GAAZ;AAFxB,GAAP;AAID;;AAOD,SAASQ,kBAAT,CACEF,SADF,EAEEN,GAFF,EAG2B;AACzB,MAAIS,MAA+B,GAAG,EAAtC;;AAEA,OAAK,IAAIC,KAAK,GAAG,CAAjB,EAAoBA,KAAK,GAAGJ,SAAS,CAACK,MAAtC,EAA8CD,KAAK,EAAnD,EAAuD;AAAA;;AACrD,UAAME,QAAQ,GAAGN,SAAS,CAACI,KAAD,CAA1B;AACA,UAAM;AAACG,MAAAA,EAAD;AAAKC,MAAAA,SAAL;AAAgB,SAAGC;AAAnB,QAA2BH,QAAjC;;AAGA,QAAIE,SAAS,KAAKjB,oBAAlB,EAAwC;AACtC,YAAMmB,WAAW,aAAMhB,GAAN,wBAAuBa,EAAvB,CAAjB;AAEAJ,MAAAA,MAAM,CAACQ,IAAP,CAAY;AACVjB,QAAAA,GAAG,EAAEgB,WADK;AAEVH,QAAAA,EAFU;AAGVC,QAAAA,SAHU;AAIV,WAAGC;AAJO,OAAZ;AAMD;;AAED,QAAIH,QAAJ,aAAIA,QAAJ,sCAAIA,QAAQ,CAAEN,SAAd,gDAAI,oBAAqBK,MAAzB,EAAiC;AAC/BF,MAAAA,MAAM,GAAG,CAAC,GAAGA,MAAJ,EAAY,GAAGD,kBAAkB,CAACI,QAAQ,CAACN,SAAV,EAAqBN,GAArB,CAAjC,CAAT;AACD;AACF;;AAED,SAAOS,MAAP;AACD","sourcesContent":["import type {BuildingSceneLayerTileset, BuildingSceneSublayer} from '../../types';\n\nconst OBJECT_3D_LAYER_TYPE = '3DObject';\n\n/**\n * Parses Builiding Scene Layer and creates tileset\n * @param data\n * @param options\n * @param context\n */\nexport async function parseBuildingSceneLayer(\n data: ArrayBuffer,\n url: string\n): Promise<BuildingSceneLayerTileset> {\n const layer0 = JSON.parse(new TextDecoder().decode(data));\n const {sublayers} = layer0;\n\n return {\n header: layer0,\n sublayers: parseSublayersTree(sublayers, url)\n };\n}\n\n/**\n * Recursively parses Building Scene Layer sublayers.\n * @param sublayers\n * @param url\n */\nfunction parseSublayersTree(\n sublayers: BuildingSceneSublayer[],\n url: string\n): BuildingSceneSublayer[] {\n let layers: BuildingSceneSublayer[] = [];\n\n for (let index = 0; index < sublayers.length; index++) {\n const subLayer = sublayers[index];\n const {id, layerType, ...rest} = subLayer;\n\n // Add support only for 3DObject layer type for I3S purposes.\n if (layerType === OBJECT_3D_LAYER_TYPE) {\n const sublayerUrl = `${url}/sublayers/${id}`;\n\n layers.push({\n url: sublayerUrl,\n id,\n layerType,\n ...rest\n });\n }\n\n if (subLayer?.sublayers?.length) {\n layers = [...layers, ...parseSublayersTree(subLayer.sublayers, url)];\n }\n }\n\n return layers;\n}\n"],"file":"parse-i3s-building-scene-layer.js"}
1
+ {"version":3,"sources":["../../../src/lib/parsers/parse-i3s-building-scene-layer.ts"],"names":["OBJECT_3D_LAYER_TYPE","parseBuildingSceneLayer","data","url","layer0","JSON","parse","TextDecoder","decode","sublayers","header","parseSublayersTree","layers","index","length","subLayer","id","layerType","visibility","rest","sublayerUrl","push"],"mappings":"AAEA,MAAMA,oBAAoB,GAAG,UAA7B;AAQA,OAAO,eAAeC,uBAAf,CACLC,IADK,EAELC,GAFK,EAG+B;AACpC,QAAMC,MAAM,GAAGC,IAAI,CAACC,KAAL,CAAW,IAAIC,WAAJ,GAAkBC,MAAlB,CAAyBN,IAAzB,CAAX,CAAf;AACA,QAAM;AAACO,IAAAA;AAAD,MAAcL,MAApB;AAEA,SAAO;AACLM,IAAAA,MAAM,EAAEN,MADH;AAELK,IAAAA,SAAS,EAAEE,kBAAkB,CAACF,SAAD,EAAYN,GAAZ;AAFxB,GAAP;AAID;;AAOD,SAASQ,kBAAT,CACEF,SADF,EAEEN,GAFF,EAG2B;AACzB,MAAIS,MAA+B,GAAG,EAAtC;;AAEA,OAAK,IAAIC,KAAK,GAAG,CAAjB,EAAoBA,KAAK,GAAGJ,SAAS,CAACK,MAAtC,EAA8CD,KAAK,EAAnD,EAAuD;AAAA;;AACrD,UAAME,QAAQ,GAAGN,SAAS,CAACI,KAAD,CAA1B;AACA,UAAM;AAACG,MAAAA,EAAD;AAAKC,MAAAA,SAAL;AAAgBC,MAAAA,UAAU,GAAG,IAA7B;AAAmC,SAAGC;AAAtC,QAA8CJ,QAApD;;AAGA,QAAIE,SAAS,KAAKjB,oBAAlB,EAAwC;AACtC,YAAMoB,WAAW,aAAMjB,GAAN,wBAAuBa,EAAvB,CAAjB;AAEAJ,MAAAA,MAAM,CAACS,IAAP,CAAY;AACVlB,QAAAA,GAAG,EAAEiB,WADK;AAEVJ,QAAAA,EAFU;AAGVC,QAAAA,SAHU;AAIVC,QAAAA,UAJU;AAKV,WAAGC;AALO,OAAZ;AAOD;;AAED,QAAIJ,QAAJ,aAAIA,QAAJ,sCAAIA,QAAQ,CAAEN,SAAd,gDAAI,oBAAqBK,MAAzB,EAAiC;AAC/BF,MAAAA,MAAM,GAAG,CAAC,GAAGA,MAAJ,EAAY,GAAGD,kBAAkB,CAACI,QAAQ,CAACN,SAAV,EAAqBN,GAArB,CAAjC,CAAT;AACD;AACF;;AAED,SAAOS,MAAP;AACD","sourcesContent":["import type {BuildingSceneLayerTileset, BuildingSceneSublayer} from '../../types';\n\nconst OBJECT_3D_LAYER_TYPE = '3DObject';\n\n/**\n * Parses Builiding Scene Layer and creates tileset\n * @param data\n * @param options\n * @param context\n */\nexport async function parseBuildingSceneLayer(\n data: ArrayBuffer,\n url: string\n): Promise<BuildingSceneLayerTileset> {\n const layer0 = JSON.parse(new TextDecoder().decode(data));\n const {sublayers} = layer0;\n\n return {\n header: layer0,\n sublayers: parseSublayersTree(sublayers, url)\n };\n}\n\n/**\n * Recursively parses Building Scene Layer sublayers.\n * @param sublayers\n * @param url\n */\nfunction parseSublayersTree(\n sublayers: BuildingSceneSublayer[],\n url: string\n): BuildingSceneSublayer[] {\n let layers: BuildingSceneSublayer[] = [];\n\n for (let index = 0; index < sublayers.length; index++) {\n const subLayer = sublayers[index];\n const {id, layerType, visibility = true, ...rest} = subLayer;\n\n // Add support only for 3DObject layer type for I3S purposes.\n if (layerType === OBJECT_3D_LAYER_TYPE) {\n const sublayerUrl = `${url}/sublayers/${id}`;\n\n layers.push({\n url: sublayerUrl,\n id,\n layerType,\n visibility,\n ...rest\n });\n }\n\n if (subLayer?.sublayers?.length) {\n layers = [...layers, ...parseSublayersTree(subLayer.sublayers, url)];\n }\n }\n\n return layers;\n}\n"],"file":"parse-i3s-building-scene-layer.js"}
@@ -0,0 +1,4 @@
1
+ import type { LoaderOptions, LoaderContext } from '@loaders.gl/loader-utils';
2
+ import { I3STilesetHeader, I3STileHeader } from '../../types';
3
+ export declare function parseI3STileContent(arrayBuffer: ArrayBuffer, tile: I3STileHeader, tileset: I3STilesetHeader, options?: LoaderOptions, context?: LoaderContext): Promise<I3STileHeader>;
4
+ //# sourceMappingURL=parse-i3s-tile-content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-i3s-tile-content.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-i3s-tile-content.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAK3E,OAAO,EACL,gBAAgB,EAChB,aAAa,EAQd,MAAM,aAAa,CAAC;AAuBrB,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,gBAAgB,EACzB,OAAO,CAAC,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,aAAa,0BAkDxB"}