@loaders.gl/tile-converter 4.0.0 → 4.0.2

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 (39) hide show
  1. package/dist/converter.min.cjs +109 -109
  2. package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts +74 -0
  3. package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts.map +1 -0
  4. package/dist/i3s-converter/helpers/attribute-metadata-info.js +157 -0
  5. package/dist/i3s-converter/helpers/attribute-metadata-info.js.map +1 -0
  6. package/dist/i3s-converter/helpers/feature-attributes.d.ts +3 -28
  7. package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
  8. package/dist/i3s-converter/helpers/feature-attributes.js +16 -125
  9. package/dist/i3s-converter/helpers/feature-attributes.js.map +1 -1
  10. package/dist/i3s-converter/i3s-converter.d.ts +11 -5
  11. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  12. package/dist/i3s-converter/i3s-converter.js +31 -44
  13. package/dist/i3s-converter/i3s-converter.js.map +1 -1
  14. package/dist/i3s-converter/types.d.ts +15 -0
  15. package/dist/i3s-converter/types.d.ts.map +1 -1
  16. package/dist/i3s-converter/types.js +6 -0
  17. package/dist/i3s-converter/types.js.map +1 -1
  18. package/dist/i3s-server/app.d.ts.map +1 -1
  19. package/dist/i3s-server/app.js +3 -6
  20. package/dist/i3s-server/app.js.map +1 -1
  21. package/dist/i3s-server/bin/i3s-server.min.cjs +86 -86
  22. package/dist/i3s-server/bin/www.js.map +1 -1
  23. package/dist/i3s-server/routes/index.d.ts +1 -1
  24. package/dist/i3s-server/routes/index.d.ts.map +1 -1
  25. package/dist/i3s-server/routes/index.js +2 -5
  26. package/dist/i3s-server/routes/index.js.map +1 -1
  27. package/dist/i3s-server/routes/slpk-router.d.ts.map +1 -1
  28. package/dist/i3s-server/routes/slpk-router.js +3 -3
  29. package/dist/i3s-server/routes/slpk-router.js.map +1 -1
  30. package/dist/index.cjs +269 -173
  31. package/package.json +15 -15
  32. package/src/i3s-converter/helpers/attribute-metadata-info.ts +246 -0
  33. package/src/i3s-converter/helpers/feature-attributes.ts +18 -180
  34. package/src/i3s-converter/i3s-converter.ts +46 -65
  35. package/src/i3s-converter/types.ts +16 -0
  36. package/src/i3s-server/app.ts +9 -4
  37. package/src/i3s-server/bin/www.ts +6 -0
  38. package/src/i3s-server/routes/index.ts +2 -4
  39. package/src/i3s-server/routes/slpk-router.ts +4 -3
package/dist/index.cjs CHANGED
@@ -35,6 +35,218 @@ __export(src_exports, {
35
35
  });
36
36
  module.exports = __toCommonJS(src_exports);
37
37
 
38
+ // src/i3s-converter/types.ts
39
+ var AttributeType = {
40
+ /** Type of attribute that is linked with feature ids */
41
+ OBJECT_ID_TYPE: "OBJECTID",
42
+ /** String data type name for feature attributes */
43
+ STRING_TYPE: "string",
44
+ /** Double data type name for feature attributes */
45
+ DOUBLE_TYPE: "double",
46
+ /** Integer data type name for feature attributes */
47
+ SHORT_INT_TYPE: "Int32"
48
+ };
49
+
50
+ // src/i3s-converter/helpers/attribute-metadata-info.ts
51
+ var AttributeMetadataInfo = class {
52
+ constructor() {
53
+ this._attributeStorageInfo = [];
54
+ this._fields = [];
55
+ }
56
+ get attributeStorageInfo() {
57
+ return this._attributeStorageInfo;
58
+ }
59
+ get fields() {
60
+ return this._fields;
61
+ }
62
+ get popupInfo() {
63
+ return this._popupInfo;
64
+ }
65
+ /**
66
+ * Creates and stores Attribute Storage Info, Fields and PopupInfo objects based on attribute's types.
67
+ * Appends objects that have not been stored yet.
68
+ * @param attributeTypesMap - set of attribute's types
69
+ * @example AttributeStorageInfo, Fields and PopupInfo already contain objects for the following attributes:
70
+ * {
71
+ * color: 'string',
72
+ * name: 'string',
73
+ * opt_uint8: 'Int32'
74
+ * }
75
+ * Then, we call the addMetadataInfo method with the following attributeTypesMap:
76
+ * {
77
+ * // The same attributes
78
+ * color: 'string',
79
+ * name: 'string',
80
+ * opt_uint8: 'Int32',
81
+ * // New attributes
82
+ * opt_uint64: 'string',
83
+ * opt_float32: 'double',
84
+ * }
85
+ * The method creates and stores objects for opt_uint64, opt_float32 attributes.
86
+ */
87
+ addMetadataInfo(attributeTypesMap) {
88
+ if (!Object.keys(attributeTypesMap).length) {
89
+ return;
90
+ }
91
+ const attributeTypes = {
92
+ OBJECTID: AttributeType.OBJECT_ID_TYPE,
93
+ ...attributeTypesMap
94
+ };
95
+ let isUpdated = false;
96
+ let attributeIndex = this._attributeStorageInfo.length;
97
+ for (const key in attributeTypes) {
98
+ const elementFound = this._attributeStorageInfo.find((element) => element.name === key);
99
+ if (!elementFound) {
100
+ const attributeType = attributeTypes[key];
101
+ const storageAttribute = this.createStorageAttribute(attributeIndex, key, attributeType);
102
+ const fieldAttributeType = this.getFieldAttributeType(attributeType);
103
+ const fieldAttribute = this.createFieldAttribute(key, fieldAttributeType);
104
+ this._attributeStorageInfo.push(storageAttribute);
105
+ this._fields.push(fieldAttribute);
106
+ attributeIndex += 1;
107
+ isUpdated = true;
108
+ }
109
+ }
110
+ if (isUpdated) {
111
+ const attributeNames = [];
112
+ for (let info of this._attributeStorageInfo) {
113
+ attributeNames.push(info.name);
114
+ }
115
+ this._popupInfo = this.createPopupInfo(attributeNames);
116
+ }
117
+ }
118
+ /**
119
+ * Generates storage attribute for map segmentation.
120
+ * @param attributeIndex - order index of attribute (f_0, f_1 ...).
121
+ * @param key - attribute key from propertyTable.
122
+ * @param attributeType - attribute type.
123
+ * @return Updated storageAttribute.
124
+ */
125
+ createStorageAttribute(attributeIndex, key, attributeType) {
126
+ const storageAttribute = {
127
+ key: `f_${attributeIndex}`,
128
+ name: key,
129
+ ordering: ["attributeValues"],
130
+ header: [{ property: "count", valueType: "UInt32" }],
131
+ attributeValues: { valueType: "Int32", valuesPerElement: 1 }
132
+ };
133
+ switch (attributeType) {
134
+ case AttributeType.OBJECT_ID_TYPE:
135
+ this.setupIdAttribute(storageAttribute);
136
+ break;
137
+ case AttributeType.STRING_TYPE:
138
+ this.setupStringAttribute(storageAttribute);
139
+ break;
140
+ case AttributeType.DOUBLE_TYPE:
141
+ this.setupDoubleAttribute(storageAttribute);
142
+ break;
143
+ case AttributeType.SHORT_INT_TYPE:
144
+ break;
145
+ default:
146
+ this.setupStringAttribute(storageAttribute);
147
+ }
148
+ return storageAttribute;
149
+ }
150
+ /**
151
+ * Finds and returns attribute type based on key form propertyTable.
152
+ * @param attributeType
153
+ */
154
+ getFieldAttributeType(attributeType) {
155
+ switch (attributeType) {
156
+ case AttributeType.OBJECT_ID_TYPE:
157
+ return "esriFieldTypeOID";
158
+ case AttributeType.STRING_TYPE:
159
+ return "esriFieldTypeString";
160
+ case AttributeType.SHORT_INT_TYPE:
161
+ return "esriFieldTypeInteger";
162
+ case AttributeType.DOUBLE_TYPE:
163
+ return "esriFieldTypeDouble";
164
+ default:
165
+ return "esriFieldTypeString";
166
+ }
167
+ }
168
+ /**
169
+ * Sets up Id attribute for map segmentation.
170
+ * @param storageAttribute - attribute for map segmentation .
171
+ */
172
+ setupIdAttribute(storageAttribute) {
173
+ storageAttribute.attributeValues = {
174
+ valueType: "Oid32",
175
+ valuesPerElement: 1
176
+ };
177
+ }
178
+ /**
179
+ * Sets up storage attribute as string.
180
+ * @param storageAttribute - attribute for map segmentation.
181
+ */
182
+ setupStringAttribute(storageAttribute) {
183
+ storageAttribute.ordering.unshift("attributeByteCounts");
184
+ storageAttribute.header.push({ property: "attributeValuesByteCount", valueType: "UInt32" });
185
+ storageAttribute.attributeValues = {
186
+ valueType: "String",
187
+ encoding: "UTF-8",
188
+ valuesPerElement: 1
189
+ };
190
+ storageAttribute.attributeByteCounts = {
191
+ valueType: "UInt32",
192
+ valuesPerElement: 1
193
+ };
194
+ }
195
+ /**
196
+ * Sets up double attribute for map segmentation.
197
+ * @param storageAttribute - attribute for map segmentation .
198
+ */
199
+ setupDoubleAttribute(storageAttribute) {
200
+ storageAttribute.attributeValues = {
201
+ valueType: "Float64",
202
+ valuesPerElement: 1
203
+ };
204
+ }
205
+ /**
206
+ * Sets up field attribute for map segmentation.
207
+ * @param key - attribute for map segmentation.
208
+ * @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').
209
+ */
210
+ createFieldAttribute(key, fieldAttributeType) {
211
+ return {
212
+ name: key,
213
+ type: fieldAttributeType,
214
+ alias: key
215
+ };
216
+ }
217
+ /**
218
+ * Generates popup info to show metadata on the map.
219
+ * @param propertyNames - array of property names including OBJECTID.
220
+ * @return data for correct rendering of popup.
221
+ */
222
+ createPopupInfo(propertyNames) {
223
+ const title = "{OBJECTID}";
224
+ const mediaInfos = [];
225
+ const fieldInfos = [];
226
+ const popupElements = [];
227
+ const expressionInfos = [];
228
+ for (const propertyName of propertyNames) {
229
+ fieldInfos.push({
230
+ fieldName: propertyName,
231
+ visible: true,
232
+ isEditable: false,
233
+ label: propertyName
234
+ });
235
+ }
236
+ popupElements.push({
237
+ fieldInfos,
238
+ type: "fields"
239
+ });
240
+ return {
241
+ title,
242
+ mediaInfos,
243
+ popupElements,
244
+ fieldInfos,
245
+ expressionInfos
246
+ };
247
+ }
248
+ };
249
+
38
250
  // src/i3s-converter/i3s-converter.ts
39
251
  var import_core9 = require("@loaders.gl/core");
40
252
  var import_d_tiles2 = require("@loaders.gl/3d-tiles");
@@ -1106,116 +1318,15 @@ function checkPropertiesLength(featureIds, propertyTable) {
1106
1318
  }
1107
1319
  return needFlatten;
1108
1320
  }
1109
- var STRING_TYPE = "string";
1110
- var SHORT_INT_TYPE = "Int32";
1111
- var DOUBLE_TYPE = "double";
1112
- var OBJECT_ID_TYPE = "OBJECTID";
1113
1321
  function getAttributeType(attribute) {
1114
- if (typeof attribute === STRING_TYPE || typeof attribute === "bigint") {
1115
- return STRING_TYPE;
1322
+ if (typeof attribute === "string" || typeof attribute === "bigint") {
1323
+ return AttributeType.STRING_TYPE;
1116
1324
  } else if (typeof attribute === "number") {
1117
- return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;
1325
+ return Number.isInteger(attribute) ? AttributeType.SHORT_INT_TYPE : AttributeType.DOUBLE_TYPE;
1118
1326
  }
1119
- return STRING_TYPE;
1327
+ return AttributeType.STRING_TYPE;
1120
1328
  }
1121
- function createdStorageAttribute(attributeIndex, key, attributeType) {
1122
- const storageAttribute = {
1123
- key: `f_${attributeIndex}`,
1124
- name: key,
1125
- ordering: ["attributeValues"],
1126
- header: [{ property: "count", valueType: "UInt32" }],
1127
- attributeValues: { valueType: "Int32", valuesPerElement: 1 }
1128
- };
1129
- switch (attributeType) {
1130
- case OBJECT_ID_TYPE:
1131
- setupIdAttribute(storageAttribute);
1132
- break;
1133
- case STRING_TYPE:
1134
- setupStringAttribute(storageAttribute);
1135
- break;
1136
- case DOUBLE_TYPE:
1137
- setupDoubleAttribute(storageAttribute);
1138
- break;
1139
- case SHORT_INT_TYPE:
1140
- break;
1141
- default:
1142
- setupStringAttribute(storageAttribute);
1143
- }
1144
- return storageAttribute;
1145
- }
1146
- function getFieldAttributeType(attributeType) {
1147
- switch (attributeType) {
1148
- case OBJECT_ID_TYPE:
1149
- return "esriFieldTypeOID";
1150
- case STRING_TYPE:
1151
- return "esriFieldTypeString";
1152
- case SHORT_INT_TYPE:
1153
- return "esriFieldTypeInteger";
1154
- case DOUBLE_TYPE:
1155
- return "esriFieldTypeDouble";
1156
- default:
1157
- return "esriFieldTypeString";
1158
- }
1159
- }
1160
- function createFieldAttribute(key, fieldAttributeType) {
1161
- return {
1162
- name: key,
1163
- type: fieldAttributeType,
1164
- alias: key
1165
- };
1166
- }
1167
- function createPopupInfo(propertyNames) {
1168
- const title = "{OBJECTID}";
1169
- const mediaInfos = [];
1170
- const fieldInfos = [];
1171
- const popupElements = [];
1172
- const expressionInfos = [];
1173
- for (const propertyName of propertyNames) {
1174
- fieldInfos.push({
1175
- fieldName: propertyName,
1176
- visible: true,
1177
- isEditable: false,
1178
- label: propertyName
1179
- });
1180
- }
1181
- popupElements.push({
1182
- fieldInfos,
1183
- type: "fields"
1184
- });
1185
- return {
1186
- title,
1187
- mediaInfos,
1188
- popupElements,
1189
- fieldInfos,
1190
- expressionInfos
1191
- };
1192
- }
1193
- function setupStringAttribute(storageAttribute) {
1194
- storageAttribute.ordering.unshift("attributeByteCounts");
1195
- storageAttribute.header.push({ property: "attributeValuesByteCount", valueType: "UInt32" });
1196
- storageAttribute.attributeValues = {
1197
- valueType: "String",
1198
- encoding: "UTF-8",
1199
- valuesPerElement: 1
1200
- };
1201
- storageAttribute.attributeByteCounts = {
1202
- valueType: "UInt32",
1203
- valuesPerElement: 1
1204
- };
1205
- }
1206
- function setupIdAttribute(storageAttribute) {
1207
- storageAttribute.attributeValues = {
1208
- valueType: "Oid32",
1209
- valuesPerElement: 1
1210
- };
1211
- }
1212
- function setupDoubleAttribute(storageAttribute) {
1213
- storageAttribute.attributeValues = {
1214
- valueType: "Float64",
1215
- valuesPerElement: 1
1216
- };
1217
- }
1218
- function getAttributeTypesFromPropertyTable(propertyTable) {
1329
+ function getAttributeTypesMapFromPropertyTable(propertyTable) {
1219
1330
  const attributeTypesMap = {};
1220
1331
  for (const key in propertyTable) {
1221
1332
  const firstAttribute = propertyTable[key][0];
@@ -1224,7 +1335,7 @@ function getAttributeTypesFromPropertyTable(propertyTable) {
1224
1335
  }
1225
1336
  return attributeTypesMap;
1226
1337
  }
1227
- var getAttributeTypesFromSchema = (gltfJson, metadataClass) => {
1338
+ var getAttributeTypesMapFromSchema = (gltfJson, metadataClass) => {
1228
1339
  var _a2, _b, _c, _d, _e, _f, _g, _h;
1229
1340
  const attributeTypesMap = {};
1230
1341
  const extFeatureMetadataSchemaClass = (_d = (_c = (_b = (_a2 = gltfJson.extensions) == null ? void 0 : _a2[import_gltf2.EXT_FEATURE_METADATA]) == null ? void 0 : _b.schema) == null ? void 0 : _c.classes) == null ? void 0 : _d[metadataClass];
@@ -1256,11 +1367,11 @@ var getAttributeTypeFromExtFeatureMetadata = (property) => {
1256
1367
  case "UINT16":
1257
1368
  case "INT32":
1258
1369
  case "UINT32":
1259
- attributeType = SHORT_INT_TYPE;
1370
+ attributeType = AttributeType.SHORT_INT_TYPE;
1260
1371
  break;
1261
1372
  case "FLOAT32":
1262
1373
  case "FLOAT64":
1263
- attributeType = DOUBLE_TYPE;
1374
+ attributeType = AttributeType.DOUBLE_TYPE;
1264
1375
  break;
1265
1376
  case "INT64":
1266
1377
  case "UINT64":
@@ -1268,10 +1379,10 @@ var getAttributeTypeFromExtFeatureMetadata = (property) => {
1268
1379
  case "ENUM":
1269
1380
  case "STRING":
1270
1381
  case "ARRAY":
1271
- attributeType = STRING_TYPE;
1382
+ attributeType = AttributeType.STRING_TYPE;
1272
1383
  break;
1273
1384
  default:
1274
- attributeType = STRING_TYPE;
1385
+ attributeType = AttributeType.STRING_TYPE;
1275
1386
  break;
1276
1387
  }
1277
1388
  return attributeType;
@@ -1279,7 +1390,7 @@ var getAttributeTypeFromExtFeatureMetadata = (property) => {
1279
1390
  var getAttributeTypeFromExtStructuralMetadata = (property) => {
1280
1391
  let attributeType;
1281
1392
  if (property.array) {
1282
- attributeType = STRING_TYPE;
1393
+ attributeType = AttributeType.STRING_TYPE;
1283
1394
  } else {
1284
1395
  switch (property.componentType) {
1285
1396
  case "INT8":
@@ -1288,18 +1399,18 @@ var getAttributeTypeFromExtStructuralMetadata = (property) => {
1288
1399
  case "UINT16":
1289
1400
  case "INT32":
1290
1401
  case "UINT32":
1291
- attributeType = SHORT_INT_TYPE;
1402
+ attributeType = AttributeType.SHORT_INT_TYPE;
1292
1403
  break;
1293
1404
  case "FLOAT32":
1294
1405
  case "FLOAT64":
1295
- attributeType = DOUBLE_TYPE;
1406
+ attributeType = AttributeType.DOUBLE_TYPE;
1296
1407
  break;
1297
1408
  case "INT64":
1298
1409
  case "UINT64":
1299
- attributeType = STRING_TYPE;
1410
+ attributeType = AttributeType.STRING_TYPE;
1300
1411
  break;
1301
1412
  default:
1302
- attributeType = STRING_TYPE;
1413
+ attributeType = AttributeType.STRING_TYPE;
1303
1414
  break;
1304
1415
  }
1305
1416
  }
@@ -1325,10 +1436,10 @@ var DEFAULT_METALLIC_FACTOR = 1;
1325
1436
  var VALUES_PER_VERTEX2 = 3;
1326
1437
  var VALUES_PER_TEX_COORD = 2;
1327
1438
  var VALUES_PER_COLOR_ELEMENT = 4;
1328
- var STRING_TYPE2 = "string";
1329
- var SHORT_INT_TYPE2 = "Int32";
1330
- var DOUBLE_TYPE2 = "Float64";
1331
- var OBJECT_ID_TYPE2 = "Oid32";
1439
+ var STRING_TYPE = "string";
1440
+ var SHORT_INT_TYPE = "Int32";
1441
+ var DOUBLE_TYPE = "Float64";
1442
+ var OBJECT_ID_TYPE = "Oid32";
1332
1443
  var BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ["CUSTOM_ATTRIBUTE_2", "_BATCHID", "BATCHID"];
1333
1444
  var scratchVector = new import_core4.Vector3();
1334
1445
  async function convertB3dmToI3sGeometry(tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, libraries, metadataClass) {
@@ -2083,14 +2194,14 @@ function convertPropertyTableToAttributeBuffers(featureIds, featureIdsMap, prope
2083
2194
  function generateAttributeBuffer(type, value) {
2084
2195
  let attributeBuffer;
2085
2196
  switch (type) {
2086
- case OBJECT_ID_TYPE2:
2087
- case SHORT_INT_TYPE2:
2197
+ case OBJECT_ID_TYPE:
2198
+ case SHORT_INT_TYPE:
2088
2199
  attributeBuffer = generateShortIntegerAttributeBuffer(value);
2089
2200
  break;
2090
- case DOUBLE_TYPE2:
2201
+ case DOUBLE_TYPE:
2091
2202
  attributeBuffer = generateDoubleAttributeBuffer(value);
2092
2203
  break;
2093
- case STRING_TYPE2:
2204
+ case STRING_TYPE:
2094
2205
  attributeBuffer = generateStringAttributeBuffer(value);
2095
2206
  break;
2096
2207
  default:
@@ -3675,6 +3786,16 @@ var I3SConverter = class {
3675
3786
  meshTopologyTypes: /* @__PURE__ */ new Set(),
3676
3787
  metadataClasses: /* @__PURE__ */ new Set()
3677
3788
  };
3789
+ /** Total count of tiles in tileset */
3790
+ this.tileCountTotal = 0;
3791
+ /** Count of tiles already converted plus one (refers to the tile currently being converted) */
3792
+ this.tileCountCurrentlyConverting = 0;
3793
+ /**
3794
+ * The number of digits to appear after decimal point in the string representation of the tile count.
3795
+ * It's calculated based on the total count of tiles.
3796
+ */
3797
+ this.numberOfDigitsInPercentage = 0;
3798
+ this.attributeMetadataInfo = new AttributeMetadataInfo();
3678
3799
  this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE, this);
3679
3800
  this.options = {};
3680
3801
  this.layers0Path = "";
@@ -3806,8 +3927,10 @@ var I3SConverter = class {
3806
3927
  this.options.maxDepth
3807
3928
  );
3808
3929
  const { meshTopologyTypes, metadataClasses } = this.preprocessData;
3930
+ this.numberOfDigitsInPercentage = this.tileCountTotal > 100 ? Math.ceil(Math.log10(this.tileCountTotal)) - 2 : 0;
3809
3931
  console.log(`------------------------------------------------`);
3810
3932
  console.log(`Preprocess results:`);
3933
+ console.log(`Tile count: ${this.tileCountTotal}`);
3811
3934
  console.log(`glTF mesh topology types: ${Array.from(meshTopologyTypes).join(", ")}`);
3812
3935
  if (metadataClasses.size) {
3813
3936
  console.log(
@@ -3839,6 +3962,7 @@ var I3SConverter = class {
3839
3962
  return null;
3840
3963
  }
3841
3964
  if (sourceTile.id) {
3965
+ this.tileCountTotal++;
3842
3966
  console.log(`[analyze]: ${sourceTile.id}`);
3843
3967
  }
3844
3968
  let tileContent = null;
@@ -3931,6 +4055,12 @@ var I3SConverter = class {
3931
4055
  this.finalizeTile.bind(this),
3932
4056
  this.options.maxDepth
3933
4057
  );
4058
+ this.layers0.attributeStorageInfo = this.attributeMetadataInfo.attributeStorageInfo;
4059
+ this.layers0.fields = this.attributeMetadataInfo.fields;
4060
+ this.layers0.popupInfo = this.attributeMetadataInfo.popupInfo;
4061
+ if (this.attributeMetadataInfo.attributeStorageInfo.length) {
4062
+ this.layers0.layerType = _3D_OBJECT_LAYER_TYPE;
4063
+ }
3934
4064
  this.layers0.materialDefinitions = this.materialDefinitions;
3935
4065
  this.layers0.geometryDefinitions = (0, import_json_map_transform8.default)(
3936
4066
  this.geometryConfigs.map((config) => ({
@@ -4042,7 +4172,13 @@ var I3SConverter = class {
4042
4172
  return traversalProps;
4043
4173
  }
4044
4174
  if (sourceTile.id) {
4045
- console.log(`[convert]: ${sourceTile.id}`);
4175
+ this.tileCountCurrentlyConverting++;
4176
+ let percentString = "";
4177
+ if (this.tileCountTotal) {
4178
+ const percent = this.tileCountCurrentlyConverting / this.tileCountTotal * 100;
4179
+ percentString = " " + percent.toFixed(this.numberOfDigitsInPercentage);
4180
+ }
4181
+ console.log(`[convert${percentString}%]: ${sourceTile.id}`);
4046
4182
  }
4047
4183
  const { parentNodes, transform: transform11 } = traversalProps;
4048
4184
  let transformationMatrix = transform11.clone();
@@ -4172,7 +4308,6 @@ var I3SConverter = class {
4172
4308
  * @returns - converted node resources
4173
4309
  */
4174
4310
  async _convertResources(sourceTile, transformationMatrix, boundingVolume, tileContent, parentId, propertyTable) {
4175
- var _a2;
4176
4311
  if (!this.isContentSupported(sourceTile) || !tileContent) {
4177
4312
  return null;
4178
4313
  }
@@ -4188,7 +4323,7 @@ var I3SConverter = class {
4188
4323
  async () => (await this.nodePages.push({ index: 0, obb: draftObb }, parentId)).index,
4189
4324
  propertyTable,
4190
4325
  this.featuresHashArray,
4191
- (_a2 = this.layers0) == null ? void 0 : _a2.attributeStorageInfo,
4326
+ this.attributeMetadataInfo.attributeStorageInfo,
4192
4327
  this.options.draco,
4193
4328
  this.generateBoundingVolumes,
4194
4329
  this.options.mergeMaterials,
@@ -4439,11 +4574,10 @@ var I3SConverter = class {
4439
4574
  * @param slpkChildPath - the resource path inside *slpk file
4440
4575
  */
4441
4576
  async _writeAttributes(attributes = [], childPath, slpkChildPath) {
4442
- var _a2, _b;
4443
- if ((attributes == null ? void 0 : attributes.length) && ((_b = (_a2 = this.layers0) == null ? void 0 : _a2.attributeStorageInfo) == null ? void 0 : _b.length)) {
4444
- const minimumLength = attributes.length < this.layers0.attributeStorageInfo.length ? attributes.length : this.layers0.attributeStorageInfo.length;
4577
+ if ((attributes == null ? void 0 : attributes.length) && this.attributeMetadataInfo.attributeStorageInfo.length) {
4578
+ const minimumLength = attributes.length < this.attributeMetadataInfo.attributeStorageInfo.length ? attributes.length : this.attributeMetadataInfo.attributeStorageInfo.length;
4445
4579
  for (let index = 0; index < minimumLength; index++) {
4446
- const folderName = this.layers0.attributeStorageInfo[index].key;
4580
+ const folderName = this.attributeMetadataInfo.attributeStorageInfo[index].key;
4447
4581
  const fileBuffer = new Uint8Array(attributes[index]);
4448
4582
  if (this.options.slpk) {
4449
4583
  const slpkAttributesPath = (0, import_path7.join)(childPath, "attributes", folderName);
@@ -4515,55 +4649,17 @@ var I3SConverter = class {
4515
4649
  createAttributeStorageInfo(tileContent, propertyTable) {
4516
4650
  let attributeTypesMap = null;
4517
4651
  if (this.options.metadataClass) {
4518
- if (!this.layers0.attributeStorageInfo.length && (tileContent == null ? void 0 : tileContent.gltf)) {
4519
- attributeTypesMap = getAttributeTypesFromSchema(
4652
+ if (!this.attributeMetadataInfo.attributeStorageInfo.length && (tileContent == null ? void 0 : tileContent.gltf)) {
4653
+ attributeTypesMap = getAttributeTypesMapFromSchema(
4520
4654
  tileContent.gltf,
4521
4655
  this.options.metadataClass
4522
4656
  );
4523
4657
  }
4524
4658
  } else if (propertyTable) {
4525
- attributeTypesMap = getAttributeTypesFromPropertyTable(propertyTable);
4659
+ attributeTypesMap = getAttributeTypesMapFromPropertyTable(propertyTable);
4526
4660
  }
4527
4661
  if (attributeTypesMap) {
4528
- this.createStorageAttributes(attributeTypesMap);
4529
- }
4530
- }
4531
- /**
4532
- * Creates Attribute Storage Info objects based on attribute's types
4533
- * @param attributeTypesMap - set of attribute's types
4534
- */
4535
- createStorageAttributes(attributeTypesMap) {
4536
- if (!Object.keys(attributeTypesMap).length) {
4537
- return;
4538
- }
4539
- const attributeTypes = {
4540
- OBJECTID: "OBJECTID",
4541
- ...attributeTypesMap
4542
- };
4543
- let isUpdated = false;
4544
- let attributeIndex = this.layers0.attributeStorageInfo.length;
4545
- for (const key in attributeTypes) {
4546
- const elementFound = this.layers0.attributeStorageInfo.find(
4547
- (element) => element.name === key
4548
- );
4549
- if (!elementFound) {
4550
- const attributeType = attributeTypes[key];
4551
- const storageAttribute = createdStorageAttribute(attributeIndex, key, attributeType);
4552
- const fieldAttributeType = getFieldAttributeType(attributeType);
4553
- const fieldAttribute = createFieldAttribute(key, fieldAttributeType);
4554
- this.layers0.attributeStorageInfo.push(storageAttribute);
4555
- this.layers0.fields.push(fieldAttribute);
4556
- attributeIndex += 1;
4557
- isUpdated = true;
4558
- }
4559
- }
4560
- if (isUpdated) {
4561
- const attributeNames = [];
4562
- for (let info of this.layers0.attributeStorageInfo) {
4563
- attributeNames.push(info.name);
4564
- }
4565
- this.layers0.popupInfo = createPopupInfo(attributeNames);
4566
- this.layers0.layerType = _3D_OBJECT_LAYER_TYPE;
4662
+ this.attributeMetadataInfo.addMetadataInfo(attributeTypesMap);
4567
4663
  }
4568
4664
  }
4569
4665
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/tile-converter",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "Converter",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -52,18 +52,18 @@
52
52
  "build-i3s-server-bundle": "esbuild src/i3s-server/bin/www.ts --outfile=dist/i3s-server/bin/i3s-server.min.cjs --platform=node --target=esnext,node14 --minify --bundle --define:__VERSION__=\\\"$npm_package_version\\\""
53
53
  },
54
54
  "dependencies": {
55
- "@loaders.gl/3d-tiles": "4.0.0",
56
- "@loaders.gl/crypto": "4.0.0",
57
- "@loaders.gl/draco": "4.0.0",
58
- "@loaders.gl/gltf": "4.0.0",
59
- "@loaders.gl/i3s": "4.0.0",
60
- "@loaders.gl/images": "4.0.0",
61
- "@loaders.gl/loader-utils": "4.0.0",
62
- "@loaders.gl/polyfills": "4.0.0",
63
- "@loaders.gl/textures": "4.0.0",
64
- "@loaders.gl/tiles": "4.0.0",
65
- "@loaders.gl/worker-utils": "4.0.0",
66
- "@loaders.gl/zip": "4.0.0",
55
+ "@loaders.gl/3d-tiles": "4.0.2",
56
+ "@loaders.gl/crypto": "4.0.2",
57
+ "@loaders.gl/draco": "4.0.2",
58
+ "@loaders.gl/gltf": "4.0.2",
59
+ "@loaders.gl/i3s": "4.0.2",
60
+ "@loaders.gl/images": "4.0.2",
61
+ "@loaders.gl/loader-utils": "4.0.2",
62
+ "@loaders.gl/polyfills": "4.0.2",
63
+ "@loaders.gl/textures": "4.0.2",
64
+ "@loaders.gl/tiles": "4.0.2",
65
+ "@loaders.gl/worker-utils": "4.0.2",
66
+ "@loaders.gl/zip": "4.0.2",
67
67
  "@math.gl/core": "^4.0.0",
68
68
  "@math.gl/culling": "^4.0.0",
69
69
  "@math.gl/geoid": "^4.0.0",
@@ -81,13 +81,13 @@
81
81
  "uuid": "^9.0.0"
82
82
  },
83
83
  "peerDependencies": {
84
- "@loaders.gl/core": "4.0.0-beta.6"
84
+ "@loaders.gl/core": "^4.0.0"
85
85
  },
86
86
  "quarantinedDependencies": {
87
87
  "join-images": "^1.1.3",
88
88
  "sharp": "^0.31.3"
89
89
  },
90
- "gitHead": "9b4211dc0ecd4134a1638ac0a29c5ea9008fd971",
90
+ "gitHead": "471058d109d5652f28c32c1f296fd632f9a5c806",
91
91
  "devDependencies": {
92
92
  "@types/express": "^4.17.17",
93
93
  "@types/node": "^20.4.2"