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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/arcgis-webscene-loader.d.ts +1 -1
  2. package/dist/arcgis-webscene-loader.d.ts.map +1 -1
  3. package/dist/arcgis-webscene-loader.js +20 -11
  4. package/dist/dist.dev.js +1244 -722
  5. package/dist/dist.min.js +9 -0
  6. package/dist/i3s-attribute-loader.d.ts +2 -2
  7. package/dist/i3s-attribute-loader.d.ts.map +1 -1
  8. package/dist/i3s-attribute-loader.js +146 -95
  9. package/dist/i3s-building-scene-layer-loader.d.ts +2 -2
  10. package/dist/i3s-building-scene-layer-loader.d.ts.map +1 -1
  11. package/dist/i3s-building-scene-layer-loader.js +18 -14
  12. package/dist/i3s-content-loader.d.ts +2 -2
  13. package/dist/i3s-content-loader.d.ts.map +1 -1
  14. package/dist/i3s-content-loader.js +24 -25
  15. package/dist/i3s-content-worker-node.js +46 -46
  16. package/dist/i3s-content-worker-node.js.map +4 -4
  17. package/dist/i3s-content-worker.js +15 -27
  18. package/dist/i3s-loader.d.ts +2 -2
  19. package/dist/i3s-loader.d.ts.map +1 -1
  20. package/dist/i3s-loader.js +78 -66
  21. package/dist/i3s-node-page-loader.d.ts +2 -2
  22. package/dist/i3s-node-page-loader.d.ts.map +1 -1
  23. package/dist/i3s-node-page-loader.js +17 -13
  24. package/dist/i3s-slpk-loader.js +19 -15
  25. package/dist/index.cjs +92 -163
  26. package/dist/index.cjs.map +7 -0
  27. package/dist/index.d.ts +14 -14
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +3 -1
  30. package/dist/lib/helpers/i3s-nodepages-tiles.d.ts +1 -1
  31. package/dist/lib/helpers/i3s-nodepages-tiles.d.ts.map +1 -1
  32. package/dist/lib/helpers/i3s-nodepages-tiles.js +230 -184
  33. package/dist/lib/parsers/constants.js +72 -45
  34. package/dist/lib/parsers/parse-arcgis-webscene.d.ts +1 -1
  35. package/dist/lib/parsers/parse-arcgis-webscene.d.ts.map +1 -1
  36. package/dist/lib/parsers/parse-arcgis-webscene.js +80 -59
  37. package/dist/lib/parsers/parse-i3s-attribute.js +83 -46
  38. package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts +1 -1
  39. package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts.map +1 -1
  40. package/dist/lib/parsers/parse-i3s-building-scene-layer.js +36 -33
  41. package/dist/lib/parsers/parse-i3s-tile-content.d.ts +1 -1
  42. package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -1
  43. package/dist/lib/parsers/parse-i3s-tile-content.js +433 -388
  44. package/dist/lib/parsers/parse-i3s.d.ts +1 -1
  45. package/dist/lib/parsers/parse-i3s.d.ts.map +1 -1
  46. package/dist/lib/parsers/parse-i3s.js +84 -81
  47. package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts +1 -1
  48. package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts.map +1 -1
  49. package/dist/lib/parsers/parse-slpk/parse-slpk.js +23 -16
  50. package/dist/lib/parsers/parse-slpk/slpk-archieve.js +134 -97
  51. package/dist/lib/utils/convert-i3s-obb-to-mbs.js +12 -5
  52. package/dist/lib/utils/customize-colors.d.ts +1 -1
  53. package/dist/lib/utils/customize-colors.d.ts.map +1 -1
  54. package/dist/lib/utils/customize-colors.js +95 -81
  55. package/dist/lib/utils/url-utils.d.ts +1 -1
  56. package/dist/lib/utils/url-utils.d.ts.map +1 -1
  57. package/dist/lib/utils/url-utils.js +48 -28
  58. package/dist/types.d.ts +1 -1
  59. package/dist/types.d.ts.map +1 -1
  60. package/dist/types.js +5 -6
  61. package/dist/workers/i3s-content-worker-node.js +1 -1
  62. package/dist/workers/i3s-content-worker.js +0 -1
  63. package/package.json +15 -12
  64. package/src/i3s-loader.ts +2 -1
  65. package/src/lib/helpers/i3s-nodepages-tiles.ts +1 -3
  66. package/src/lib/parsers/parse-i3s-tile-content.ts +4 -26
  67. package/dist/arcgis-webscene-loader.js.map +0 -1
  68. package/dist/i3s-attribute-loader.js.map +0 -1
  69. package/dist/i3s-building-scene-layer-loader.js.map +0 -1
  70. package/dist/i3s-content-loader.js.map +0 -1
  71. package/dist/i3s-loader.js.map +0 -1
  72. package/dist/i3s-node-page-loader.js.map +0 -1
  73. package/dist/i3s-slpk-loader.js.map +0 -1
  74. package/dist/index.js.map +0 -1
  75. package/dist/lib/helpers/i3s-nodepages-tiles.js.map +0 -1
  76. package/dist/lib/parsers/constants.js.map +0 -1
  77. package/dist/lib/parsers/parse-arcgis-webscene.js.map +0 -1
  78. package/dist/lib/parsers/parse-i3s-attribute.js.map +0 -1
  79. package/dist/lib/parsers/parse-i3s-building-scene-layer.js.map +0 -1
  80. package/dist/lib/parsers/parse-i3s-tile-content.js.map +0 -1
  81. package/dist/lib/parsers/parse-i3s.js.map +0 -1
  82. package/dist/lib/parsers/parse-slpk/parse-slpk.js.map +0 -1
  83. package/dist/lib/parsers/parse-slpk/slpk-archieve.js.map +0 -1
  84. package/dist/lib/utils/convert-i3s-obb-to-mbs.js.map +0 -1
  85. package/dist/lib/utils/customize-colors.js.map +0 -1
  86. package/dist/lib/utils/url-utils.js.map +0 -1
  87. package/dist/types.js.map +0 -1
  88. package/dist/workers/i3s-content-worker-node.js.map +0 -1
  89. package/dist/workers/i3s-content-worker.js.map +0 -1
@@ -3,199 +3,245 @@ import { getSupportedGPUTextureFormats, selectSupportedBasisFormat } from '@load
3
3
  import { I3SNodePageLoader } from "../../i3s-node-page-loader.js";
4
4
  import { normalizeTileNonUrlData } from "../parsers/parse-i3s.js";
5
5
  import { getUrlWithToken, generateTilesetAttributeUrls } from "../utils/url-utils.js";
6
+ /**
7
+ * class I3SNodePagesTiles - loads nodePages and form i3s tiles from them
8
+ */
6
9
  export default class I3SNodePagesTiles {
7
- constructor(tileset) {
8
- var _tileset$nodePages, _tileset$nodePages2;
9
- let url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
10
- let options = arguments.length > 2 ? arguments[2] : undefined;
11
- this.tileset = void 0;
12
- this.nodePages = [];
13
- this.pendingNodePages = [];
14
- this.nodesPerPage = void 0;
15
- this.options = void 0;
16
- this.lodSelectionMetricType = void 0;
17
- this.textureDefinitionsSelectedFormats = [];
18
- this.nodesInNodePages = void 0;
19
- this.url = void 0;
20
- this.textureLoaderOptions = {};
21
- this.tileset = {
22
- ...tileset
23
- };
24
- this.url = url;
25
- this.nodesPerPage = ((_tileset$nodePages = tileset.nodePages) === null || _tileset$nodePages === void 0 ? void 0 : _tileset$nodePages.nodesPerPage) || 64;
26
- this.lodSelectionMetricType = (_tileset$nodePages2 = tileset.nodePages) === null || _tileset$nodePages2 === void 0 ? void 0 : _tileset$nodePages2.lodSelectionMetricType;
27
- this.options = options;
28
- this.nodesInNodePages = 0;
29
- this.initSelectedFormatsForTextureDefinitions(tileset);
30
- }
31
- async getNodeById(id) {
32
- const pageIndex = Math.floor(id / this.nodesPerPage);
33
- if (!this.nodePages[pageIndex] && !this.pendingNodePages[pageIndex]) {
34
- var _this$options$i3s;
35
- const nodePageUrl = getUrlWithToken(this.url.indexOf('.slpk') !== -1 ? `nodepages/${pageIndex}` : `${this.url}/nodepages/${pageIndex}`, (_this$options$i3s = this.options.i3s) === null || _this$options$i3s === void 0 ? void 0 : _this$options$i3s.token);
36
- this.pendingNodePages[pageIndex] = {
37
- status: 'Pending',
38
- promise: load(nodePageUrl, I3SNodePageLoader, this.options)
39
- };
40
- this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;
41
- this.nodesInNodePages += this.nodePages[pageIndex].nodes.length;
42
- this.pendingNodePages[pageIndex].status = 'Done';
10
+ tileset;
11
+ nodePages = [];
12
+ pendingNodePages = [];
13
+ nodesPerPage;
14
+ options;
15
+ lodSelectionMetricType;
16
+ textureDefinitionsSelectedFormats = [];
17
+ nodesInNodePages;
18
+ url;
19
+ textureLoaderOptions = {};
20
+ /**
21
+ * @constructs
22
+ * Create a I3SNodePagesTiles instance.
23
+ * @param tileset - i3s tileset header ('layers/0')
24
+ * @param url - tileset url
25
+ * @param options - i3s loader options
26
+ */
27
+ constructor(tileset, url = '', options) {
28
+ this.tileset = { ...tileset }; // spread the tileset to avoid circular reference
29
+ this.url = url;
30
+ this.nodesPerPage = tileset.nodePages?.nodesPerPage || 64;
31
+ this.lodSelectionMetricType = tileset.nodePages?.lodSelectionMetricType;
32
+ this.options = options;
33
+ this.nodesInNodePages = 0;
34
+ this.initSelectedFormatsForTextureDefinitions(tileset);
43
35
  }
44
- if (this.pendingNodePages[pageIndex].status === 'Pending') {
45
- this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;
46
- }
47
- const nodeIndex = id % this.nodesPerPage;
48
- return this.nodePages[pageIndex].nodes[nodeIndex];
49
- }
50
- async formTileFromNodePages(id) {
51
- const node = await this.getNodeById(id);
52
- const children = [];
53
- const childNodesPromises = [];
54
- for (const child of node.children || []) {
55
- childNodesPromises.push(this.getNodeById(child));
56
- }
57
- const childNodes = await Promise.all(childNodesPromises);
58
- for (const childNode of childNodes) {
59
- children.push({
60
- id: childNode.index.toString(),
61
- obb: childNode.obb
62
- });
63
- }
64
- let contentUrl;
65
- let textureUrl;
66
- let materialDefinition;
67
- let textureFormat = 'jpg';
68
- let attributeUrls = [];
69
- let isDracoGeometry = false;
70
- if (node && node.mesh) {
71
- const {
72
- url,
73
- isDracoGeometry: isDracoGeometryResult
74
- } = node.mesh.geometry && this.getContentUrl(node.mesh.geometry) || {
75
- isDracoGeometry: false
76
- };
77
- contentUrl = url;
78
- isDracoGeometry = isDracoGeometryResult;
79
- const {
80
- textureData,
81
- materialDefinition: nodeMaterialDefinition
82
- } = this.getInformationFromMaterial(node.mesh.material);
83
- materialDefinition = nodeMaterialDefinition;
84
- textureFormat = textureData.format || textureFormat;
85
- if (textureData.name) {
86
- textureUrl = `${this.url}/nodes/${node.mesh.material.resource}/textures/${textureData.name}`;
87
- }
88
- if (this.tileset.attributeStorageInfo) {
89
- attributeUrls = generateTilesetAttributeUrls(this.tileset, this.url, node.mesh.attribute.resource);
90
- }
91
- }
92
- const lodSelection = this.getLodSelection(node);
93
- return normalizeTileNonUrlData({
94
- id: id.toString(),
95
- lodSelection,
96
- obb: node.obb,
97
- contentUrl,
98
- textureUrl,
99
- attributeUrls,
100
- materialDefinition,
101
- textureFormat,
102
- textureLoaderOptions: this.textureLoaderOptions,
103
- children,
104
- isDracoGeometry
105
- });
106
- }
107
- getContentUrl(meshGeometryData) {
108
- let result = null;
109
- const geometryDefinition = this.tileset.geometryDefinitions[meshGeometryData.definition];
110
- let geometryIndex = -1;
111
- if (this.options.i3s && this.options.i3s.useDracoGeometry) {
112
- geometryIndex = geometryDefinition.geometryBuffers.findIndex(buffer => buffer.compressedAttributes && buffer.compressedAttributes.encoding === 'draco');
36
+ /**
37
+ * Loads some nodePage and return a particular node from it
38
+ * @param id - id of node through all node pages
39
+ */
40
+ async getNodeById(id) {
41
+ const pageIndex = Math.floor(id / this.nodesPerPage);
42
+ if (!this.nodePages[pageIndex] && !this.pendingNodePages[pageIndex]) {
43
+ const nodePageUrl = getUrlWithToken(`${this.url}/nodepages/${pageIndex}`,
44
+ // @ts-expect-error this.options is not properly typed
45
+ this.options.i3s?.token);
46
+ this.pendingNodePages[pageIndex] = {
47
+ status: 'Pending',
48
+ promise: load(nodePageUrl, I3SNodePageLoader, this.options)
49
+ };
50
+ this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;
51
+ this.nodesInNodePages += this.nodePages[pageIndex].nodes.length;
52
+ this.pendingNodePages[pageIndex].status = 'Done';
53
+ }
54
+ if (this.pendingNodePages[pageIndex].status === 'Pending') {
55
+ this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;
56
+ }
57
+ const nodeIndex = id % this.nodesPerPage;
58
+ return this.nodePages[pageIndex].nodes[nodeIndex];
113
59
  }
114
- if (geometryIndex === -1) {
115
- geometryIndex = geometryDefinition.geometryBuffers.findIndex(buffer => !buffer.compressedAttributes);
60
+ /**
61
+ * Forms tile header using node and tileset data
62
+ * @param id - id of node through all node pages
63
+ */
64
+ // eslint-disable-next-line complexity, max-statements
65
+ async formTileFromNodePages(id) {
66
+ const node = await this.getNodeById(id);
67
+ const children = [];
68
+ const childNodesPromises = [];
69
+ for (const child of node.children || []) {
70
+ childNodesPromises.push(this.getNodeById(child));
71
+ }
72
+ const childNodes = await Promise.all(childNodesPromises);
73
+ for (const childNode of childNodes) {
74
+ children.push({
75
+ id: childNode.index.toString(),
76
+ obb: childNode.obb
77
+ });
78
+ }
79
+ let contentUrl;
80
+ let textureUrl;
81
+ let materialDefinition;
82
+ let textureFormat = 'jpg';
83
+ let attributeUrls = [];
84
+ let isDracoGeometry = false;
85
+ if (node && node.mesh) {
86
+ // Get geometry resource URL and type (compressed / non-compressed)
87
+ const { url, isDracoGeometry: isDracoGeometryResult } = (node.mesh.geometry &&
88
+ this.getContentUrl(node.mesh.geometry)) || { isDracoGeometry: false };
89
+ contentUrl = url;
90
+ isDracoGeometry = isDracoGeometryResult;
91
+ const { textureData, materialDefinition: nodeMaterialDefinition } = this.getInformationFromMaterial(node.mesh.material);
92
+ materialDefinition = nodeMaterialDefinition;
93
+ textureFormat = textureData.format || textureFormat;
94
+ if (textureData.name) {
95
+ textureUrl = `${this.url}/nodes/${node.mesh.material.resource}/textures/${textureData.name}`;
96
+ }
97
+ if (this.tileset.attributeStorageInfo) {
98
+ attributeUrls = generateTilesetAttributeUrls(this.tileset, this.url, node.mesh.attribute.resource);
99
+ }
100
+ }
101
+ const lodSelection = this.getLodSelection(node);
102
+ return normalizeTileNonUrlData({
103
+ id: id.toString(),
104
+ lodSelection,
105
+ obb: node.obb,
106
+ contentUrl,
107
+ textureUrl,
108
+ attributeUrls,
109
+ materialDefinition,
110
+ textureFormat,
111
+ textureLoaderOptions: this.textureLoaderOptions,
112
+ children,
113
+ isDracoGeometry
114
+ });
116
115
  }
117
- if (geometryIndex !== -1) {
118
- const isDracoGeometry = Boolean(geometryDefinition.geometryBuffers[geometryIndex].compressedAttributes);
119
- result = {
120
- url: `${this.url}/nodes/${meshGeometryData.resource}/geometries/${geometryIndex}`,
121
- isDracoGeometry
122
- };
116
+ /**
117
+ * Forms url and type of geometry resource by nodepage's data and `geometryDefinitions` in the tileset
118
+ * @param - data about the node's mesh from the nodepage
119
+ * @returns -
120
+ * {string} url - url to the geometry resource
121
+ * {boolean} isDracoGeometry - whether the geometry resource contain DRACO compressed geometry
122
+ */
123
+ getContentUrl(meshGeometryData) {
124
+ let result = null;
125
+ // @ts-ignore
126
+ const geometryDefinition = this.tileset.geometryDefinitions[meshGeometryData.definition];
127
+ let geometryIndex = -1;
128
+ // Try to find DRACO geometryDefinition of `useDracoGeometry` option is set
129
+ // @ts-expect-error this.options is not properly typed
130
+ if (this.options.i3s && this.options.i3s.useDracoGeometry) {
131
+ geometryIndex = geometryDefinition.geometryBuffers.findIndex((buffer) => buffer.compressedAttributes && buffer.compressedAttributes.encoding === 'draco');
132
+ }
133
+ // If DRACO geometry is not applicable try to select non-compressed geometry
134
+ if (geometryIndex === -1) {
135
+ geometryIndex = geometryDefinition.geometryBuffers.findIndex((buffer) => !buffer.compressedAttributes);
136
+ }
137
+ if (geometryIndex !== -1) {
138
+ const isDracoGeometry = Boolean(geometryDefinition.geometryBuffers[geometryIndex].compressedAttributes);
139
+ result = {
140
+ url: `${this.url}/nodes/${meshGeometryData.resource}/geometries/${geometryIndex}`,
141
+ isDracoGeometry
142
+ };
143
+ }
144
+ return result;
123
145
  }
124
- return result;
125
- }
126
- getLodSelection(node) {
127
- const lodSelection = [];
128
- if (this.lodSelectionMetricType === 'maxScreenThresholdSQ') {
129
- lodSelection.push({
130
- metricType: 'maxScreenThreshold',
131
- maxError: Math.sqrt(node.lodThreshold / (Math.PI * 0.25))
132
- });
146
+ /**
147
+ * Forms 1.6 compatible LOD selection object from a nodepage's node data
148
+ * @param node - a node from nodepage
149
+ * @returns- Array of LodSelection
150
+ */
151
+ getLodSelection(node) {
152
+ const lodSelection = [];
153
+ if (this.lodSelectionMetricType === 'maxScreenThresholdSQ') {
154
+ lodSelection.push({
155
+ metricType: 'maxScreenThreshold',
156
+ // @ts-ignore
157
+ maxError: Math.sqrt(node.lodThreshold / (Math.PI * 0.25))
158
+ });
159
+ }
160
+ lodSelection.push({
161
+ metricType: this.lodSelectionMetricType,
162
+ // @ts-ignore
163
+ maxError: node.lodThreshold
164
+ });
165
+ return lodSelection;
133
166
  }
134
- lodSelection.push({
135
- metricType: this.lodSelectionMetricType,
136
- maxError: node.lodThreshold
137
- });
138
- return lodSelection;
139
- }
140
- getInformationFromMaterial(material) {
141
- const informationFromMaterial = {
142
- textureData: {
143
- name: null
144
- }
145
- };
146
- if (material) {
147
- var _this$tileset$materia;
148
- const materialDefinition = (_this$tileset$materia = this.tileset.materialDefinitions) === null || _this$tileset$materia === void 0 ? void 0 : _this$tileset$materia[material.definition];
149
- if (materialDefinition) {
150
- var _materialDefinition$p, _materialDefinition$p2;
151
- informationFromMaterial.materialDefinition = materialDefinition;
152
- 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;
153
- if (typeof textureSetDefinitionIndex === 'number') {
154
- informationFromMaterial.textureData = this.textureDefinitionsSelectedFormats[textureSetDefinitionIndex] || informationFromMaterial.textureData;
167
+ /**
168
+ * Returns information about texture and material from `materialDefinitions`
169
+ * @param material - material data from nodepage
170
+ * @returns - Couple {textureData, materialDefinition}
171
+ * {string} textureData.name - path name of the texture
172
+ * {string} textureData.format - format of the texture
173
+ * materialDefinition - PBR-like material definition from `materialDefinitions`
174
+ */
175
+ getInformationFromMaterial(material) {
176
+ const informationFromMaterial = { textureData: { name: null } };
177
+ if (material) {
178
+ const materialDefinition = this.tileset.materialDefinitions?.[material.definition];
179
+ if (materialDefinition) {
180
+ informationFromMaterial.materialDefinition = materialDefinition;
181
+ const textureSetDefinitionIndex = materialDefinition?.pbrMetallicRoughness?.baseColorTexture?.textureSetDefinitionId;
182
+ if (typeof textureSetDefinitionIndex === 'number') {
183
+ informationFromMaterial.textureData =
184
+ this.textureDefinitionsSelectedFormats[textureSetDefinitionIndex] ||
185
+ informationFromMaterial.textureData;
186
+ }
187
+ }
155
188
  }
156
- }
189
+ return informationFromMaterial;
157
190
  }
158
- return informationFromMaterial;
159
- }
160
- initSelectedFormatsForTextureDefinitions(tileset) {
161
- this.textureDefinitionsSelectedFormats = [];
162
- const possibleI3sFormats = this.getSupportedTextureFormats();
163
- const textureSetDefinitions = tileset.textureSetDefinitions || [];
164
- for (const textureSetDefinition of textureSetDefinitions) {
165
- const formats = textureSetDefinition && textureSetDefinition.formats || [];
166
- let selectedFormat = null;
167
- for (const i3sFormat of possibleI3sFormats) {
168
- const format = formats.find(value => value.format === i3sFormat);
169
- if (format) {
170
- selectedFormat = format;
171
- break;
191
+ /**
192
+ * Sets preferable and supported format for each textureDefinition of the tileset
193
+ * @param tileset - I3S layer data
194
+ * @returns
195
+ */
196
+ initSelectedFormatsForTextureDefinitions(tileset) {
197
+ this.textureDefinitionsSelectedFormats = [];
198
+ const possibleI3sFormats = this.getSupportedTextureFormats();
199
+ const textureSetDefinitions = tileset.textureSetDefinitions || [];
200
+ for (const textureSetDefinition of textureSetDefinitions) {
201
+ const formats = (textureSetDefinition && textureSetDefinition.formats) || [];
202
+ let selectedFormat = null;
203
+ for (const i3sFormat of possibleI3sFormats) {
204
+ const format = formats.find((value) => value.format === i3sFormat);
205
+ if (format) {
206
+ selectedFormat = format;
207
+ break;
208
+ }
209
+ }
210
+ // For I3S 1.8 need to define basis target format to decode
211
+ if (selectedFormat && selectedFormat.format === 'ktx2') {
212
+ this.textureLoaderOptions.basis = {
213
+ format: selectSupportedBasisFormat(),
214
+ containerFormat: 'ktx2',
215
+ module: 'encoder'
216
+ };
217
+ }
218
+ this.textureDefinitionsSelectedFormats.push(selectedFormat);
172
219
  }
173
- }
174
- if (selectedFormat && selectedFormat.format === 'ktx2') {
175
- this.textureLoaderOptions.basis = {
176
- format: selectSupportedBasisFormat(),
177
- containerFormat: 'ktx2',
178
- module: 'encoder'
179
- };
180
- }
181
- this.textureDefinitionsSelectedFormats.push(selectedFormat);
182
220
  }
183
- }
184
- getSupportedTextureFormats() {
185
- const formats = [];
186
- if (!this.options.i3s || this.options.i3s.useCompressedTextures) {
187
- const supportedCompressedFormats = getSupportedGPUTextureFormats();
188
- if (supportedCompressedFormats.has('etc2')) {
189
- formats.push('ktx-etc2');
190
- }
191
- if (supportedCompressedFormats.has('dxt')) {
192
- formats.push('dds');
193
- }
194
- formats.push('ktx2');
221
+ /**
222
+ * Returns the array of supported texture format
223
+ * @returns list of format strings
224
+ */
225
+ getSupportedTextureFormats() {
226
+ const formats = [];
227
+ // @ts-expect-error this.options is not properly typed
228
+ if (!this.options.i3s || this.options.i3s.useCompressedTextures) {
229
+ // I3S 1.7 selection
230
+ const supportedCompressedFormats = getSupportedGPUTextureFormats();
231
+ // List of possible in i3s formats:
232
+ // https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md
233
+ if (supportedCompressedFormats.has('etc2')) {
234
+ formats.push('ktx-etc2');
235
+ }
236
+ if (supportedCompressedFormats.has('dxt')) {
237
+ formats.push('dds');
238
+ }
239
+ // I3S 1.8 selection
240
+ // ktx2 wraps basis texture which at the edge case can be decoded as uncompressed image
241
+ formats.push('ktx2');
242
+ }
243
+ formats.push('jpg');
244
+ formats.push('png');
245
+ return formats;
195
246
  }
196
- formats.push('jpg');
197
- formats.push('png');
198
- return formats;
199
- }
200
247
  }
201
- //# sourceMappingURL=i3s-nodepages-tiles.js.map
@@ -1,56 +1,83 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { GL } from '@loaders.gl/math';
2
5
  export function getConstructorForDataFormat(dataType) {
3
- switch (dataType) {
4
- case 'UInt8':
5
- return Uint8Array;
6
- case 'UInt16':
7
- return Uint16Array;
8
- case 'UInt32':
9
- return Uint32Array;
10
- case 'Float32':
11
- return Float32Array;
12
- case 'UInt64':
13
- return Float64Array;
14
- default:
15
- throw new Error(`parse i3s tile content: unknown type of data: ${dataType}`);
16
- }
6
+ switch (dataType) {
7
+ case 'UInt8':
8
+ return Uint8Array;
9
+ case 'UInt16':
10
+ return Uint16Array;
11
+ case 'UInt32':
12
+ return Uint32Array;
13
+ case 'Float32':
14
+ return Float32Array;
15
+ case 'UInt64':
16
+ return Float64Array;
17
+ default:
18
+ throw new Error(`parse i3s tile content: unknown type of data: ${dataType}`);
19
+ }
17
20
  }
18
21
  export const GL_TYPE_MAP = {
19
- UInt8: GL.UNSIGNED_BYTE,
20
- UInt16: GL.UNSIGNED_SHORT,
21
- Float32: GL.FLOAT,
22
- UInt32: GL.UNSIGNED_INT,
23
- UInt64: GL.DOUBLE
22
+ UInt8: GL.UNSIGNED_BYTE,
23
+ UInt16: GL.UNSIGNED_SHORT,
24
+ Float32: GL.FLOAT,
25
+ UInt32: GL.UNSIGNED_INT,
26
+ UInt64: GL.DOUBLE
24
27
  };
28
+ /**
29
+ * Returns how many bytes a type occupies
30
+ * @param dataType
31
+ * @returns
32
+ */
25
33
  export function sizeOf(dataType) {
26
- switch (dataType) {
27
- case 'UInt8':
28
- return 1;
29
- case 'UInt16':
30
- case 'Int16':
31
- return 2;
32
- case 'UInt32':
33
- case 'Int32':
34
- case 'Float32':
35
- return 4;
36
- case 'UInt64':
37
- case 'Int64':
38
- case 'Float64':
39
- return 8;
40
- default:
41
- throw new Error(`parse i3s tile content: unknown size of data: ${dataType}`);
42
- }
34
+ switch (dataType) {
35
+ case 'UInt8':
36
+ return 1;
37
+ case 'UInt16':
38
+ case 'Int16':
39
+ return 2;
40
+ case 'UInt32':
41
+ case 'Int32':
42
+ case 'Float32':
43
+ return 4;
44
+ case 'UInt64':
45
+ case 'Int64':
46
+ case 'Float64':
47
+ return 8;
48
+ default:
49
+ throw new Error(`parse i3s tile content: unknown size of data: ${dataType}`);
50
+ }
43
51
  }
44
52
  export const STRING_ATTRIBUTE_TYPE = 'String';
45
53
  export const OBJECT_ID_ATTRIBUTE_TYPE = 'Oid32';
46
54
  export const FLOAT_64_TYPE = 'Float64';
47
55
  export const INT_16_ATTRIBUTE_TYPE = 'Int16';
48
- export let COORDINATE_SYSTEM = function (COORDINATE_SYSTEM) {
49
- COORDINATE_SYSTEM[COORDINATE_SYSTEM["DEFAULT"] = -1] = "DEFAULT";
50
- COORDINATE_SYSTEM[COORDINATE_SYSTEM["LNGLAT"] = 1] = "LNGLAT";
51
- COORDINATE_SYSTEM[COORDINATE_SYSTEM["METER_OFFSETS"] = 2] = "METER_OFFSETS";
52
- COORDINATE_SYSTEM[COORDINATE_SYSTEM["LNGLAT_OFFSETS"] = 3] = "LNGLAT_OFFSETS";
53
- COORDINATE_SYSTEM[COORDINATE_SYSTEM["CARTESIAN"] = 0] = "CARTESIAN";
54
- return COORDINATE_SYSTEM;
55
- }({});
56
- //# sourceMappingURL=constants.js.map
56
+ // https://github.com/visgl/deck.gl/blob/9548f43cba2234a1f4877b6b17f6c88eb35b2e08/modules/core/src/lib/constants.js#L27
57
+ // Describes the format of positions
58
+ export var COORDINATE_SYSTEM;
59
+ (function (COORDINATE_SYSTEM) {
60
+ /**
61
+ * `LNGLAT` if rendering into a geospatial viewport, `CARTESIAN` otherwise
62
+ */
63
+ COORDINATE_SYSTEM[COORDINATE_SYSTEM["DEFAULT"] = -1] = "DEFAULT";
64
+ /**
65
+ * Positions are interpreted as [lng, lat, elevation]
66
+ * lng lat are degrees, elevation is meters. distances as meters.
67
+ */
68
+ COORDINATE_SYSTEM[COORDINATE_SYSTEM["LNGLAT"] = 1] = "LNGLAT";
69
+ /**
70
+ * Positions are interpreted as meter offsets, distances as meters
71
+ */
72
+ COORDINATE_SYSTEM[COORDINATE_SYSTEM["METER_OFFSETS"] = 2] = "METER_OFFSETS";
73
+ /**
74
+ * Positions are interpreted as lng lat offsets: [deltaLng, deltaLat, elevation]
75
+ * deltaLng, deltaLat are delta degrees, elevation is meters.
76
+ * distances as meters.
77
+ */
78
+ COORDINATE_SYSTEM[COORDINATE_SYSTEM["LNGLAT_OFFSETS"] = 3] = "LNGLAT_OFFSETS";
79
+ /**
80
+ * Non-geospatial
81
+ */
82
+ COORDINATE_SYSTEM[COORDINATE_SYSTEM["CARTESIAN"] = 0] = "CARTESIAN";
83
+ })(COORDINATE_SYSTEM || (COORDINATE_SYSTEM = {}));
@@ -1,4 +1,4 @@
1
- import type { ArcGISWebSceneData } from '../../types';
1
+ import type { ArcGISWebSceneData } from "../../types.js";
2
2
  /**
3
3
  * Provides additional information in the exception Error object, e.g. unsupported layer types.
4
4
  * @param message - message used in the Error object
@@ -1 +1 @@
1
- {"version":3,"file":"parse-arcgis-webscene.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-arcgis-webscene.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAmB,MAAM,aAAa,CAAC;AA2BtE;;;;;GAKG;AACH,qBAAa,UAAW,SAAQ,KAAK;IAG1B,OAAO,EAAE,OAAO;gBADvB,OAAO,EAAE,MAAM,EACR,OAAO,EAAE,OAAO;CAK1B;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAclF"}
1
+ {"version":3,"file":"parse-arcgis-webscene.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-arcgis-webscene.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAmB,uBAAoB;AA2BtE;;;;;GAKG;AACH,qBAAa,UAAW,SAAQ,KAAK;IAG1B,OAAO,EAAE,OAAO;gBADvB,OAAO,EAAE,MAAM,EACR,OAAO,EAAE,OAAO;CAK1B;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAclF"}