@loaders.gl/tile-converter 3.4.11 → 3.4.12

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 (53) hide show
  1. package/dist/3d-tiles-attributes-worker.js +1 -1
  2. package/dist/converter.min.js +58 -58
  3. package/dist/dist.min.js +11 -26
  4. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  5. package/dist/es5/deps-installer/deps-installer.js +1 -1
  6. package/dist/es5/i3s-attributes-worker.js +1 -1
  7. package/dist/es5/pgm-loader.js +1 -1
  8. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  9. package/dist/esm/deps-installer/deps-installer.js +1 -1
  10. package/dist/esm/i3s-attributes-worker.js +1 -1
  11. package/dist/esm/pgm-loader.js +1 -1
  12. package/package.json +15 -15
  13. package/dist/3d-tiles-converter/3d-tiles-converter.js +0 -287
  14. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +0 -282
  15. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -23
  16. package/dist/3d-tiles-converter/helpers/texture-atlas.js +0 -52
  17. package/dist/3d-tiles-converter/json-templates/tileset.js +0 -43
  18. package/dist/bundle.js +0 -5
  19. package/dist/constants.js +0 -4
  20. package/dist/converter-cli.js +0 -280
  21. package/dist/deps-installer/deps-installer.js +0 -63
  22. package/dist/i3s-converter/helpers/batch-ids-extensions.js +0 -141
  23. package/dist/i3s-converter/helpers/coordinate-converter.js +0 -124
  24. package/dist/i3s-converter/helpers/create-scene-server-path.js +0 -28
  25. package/dist/i3s-converter/helpers/feature-attributes.js +0 -216
  26. package/dist/i3s-converter/helpers/geometry-attributes.js +0 -202
  27. package/dist/i3s-converter/helpers/geometry-converter.js +0 -1195
  28. package/dist/i3s-converter/helpers/gltf-attributes.js +0 -88
  29. package/dist/i3s-converter/helpers/node-debug.js +0 -120
  30. package/dist/i3s-converter/helpers/node-index-document.js +0 -250
  31. package/dist/i3s-converter/helpers/node-pages.js +0 -316
  32. package/dist/i3s-converter/i3s-converter.js +0 -890
  33. package/dist/i3s-converter/json-templates/geometry-definitions.js +0 -87
  34. package/dist/i3s-converter/json-templates/layers.js +0 -139
  35. package/dist/i3s-converter/json-templates/metadata.js +0 -25
  36. package/dist/i3s-converter/json-templates/node.js +0 -89
  37. package/dist/i3s-converter/json-templates/scene-server.js +0 -31
  38. package/dist/i3s-converter/json-templates/shared-resources.js +0 -129
  39. package/dist/i3s-converter/json-templates/store.js +0 -103
  40. package/dist/i3s-converter/types.js +0 -2
  41. package/dist/i3s-server/app.js +0 -14
  42. package/dist/i3s-server/controllers/index-controller.js +0 -23
  43. package/dist/i3s-server/routes/index.js +0 -16
  44. package/dist/index.js +0 -10
  45. package/dist/lib/utils/compress-util.js +0 -257
  46. package/dist/lib/utils/file-utils.js +0 -138
  47. package/dist/lib/utils/lod-conversion-utils.js +0 -76
  48. package/dist/lib/utils/queue.js +0 -18
  49. package/dist/lib/utils/statistic-utills.js +0 -64
  50. package/dist/lib/utils/write-queue.js +0 -80
  51. package/dist/pgm-loader.js +0 -24
  52. package/dist/workers/3d-tiles-attributes-worker.js +0 -9
  53. package/dist/workers/i3s-attributes-worker.js +0 -5
@@ -1,216 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPopupInfo = exports.createFieldAttribute = exports.getFieldAttributeType = exports.createdStorageAttribute = exports.getAttributeType = exports.checkPropertiesLength = exports.flattenPropertyTableByFeatureIds = void 0;
4
- /**
5
- * Takes attributes from property table based on featureIds.
6
- * If there is no property value for particular featureId (index) the property will be null.
7
- * Example:
8
- * Initial data:
9
- * OBJECTID: [0, 1, 5]
10
- * component: ['Windows', 'Frames', 'Wall', 'Roof', 'Skylight']
11
- * Result:
12
- * OBJECTID: [0, 1, 5]
13
- * component: ['Windows', 'Frames', 'null']
14
- * @param featureIds
15
- * @param propertyTable
16
- */
17
- function flattenPropertyTableByFeatureIds(featureIds, propertyTable) {
18
- const resultPropertyTable = {};
19
- for (const propertyName in propertyTable) {
20
- const properties = propertyTable[propertyName];
21
- resultPropertyTable[propertyName] = getPropertiesByFeatureIds(properties, featureIds);
22
- }
23
- return resultPropertyTable;
24
- }
25
- exports.flattenPropertyTableByFeatureIds = flattenPropertyTableByFeatureIds;
26
- /**
27
- * Getting properties by featureId index
28
- * @param properties
29
- * @param featureIds
30
- */
31
- function getPropertiesByFeatureIds(properties, featureIds) {
32
- const resultProperties = [];
33
- for (const featureId of featureIds) {
34
- const property = properties[featureId] || null;
35
- resultProperties.push(property);
36
- }
37
- return resultProperties;
38
- }
39
- /**
40
- * Check that all attributes in propertyTable have the same length as FeatureIds.
41
- * If there are differencies between lengths we should flatten property table based on exiesting featureIds.
42
- * @param featureIds
43
- * @param propertyTable
44
- * @returns
45
- */
46
- function checkPropertiesLength(featureIds, propertyTable) {
47
- let needFlatten = false;
48
- for (const attribute of Object.values(propertyTable)) {
49
- if (featureIds.length !== attribute.length) {
50
- needFlatten = true;
51
- }
52
- }
53
- return needFlatten;
54
- }
55
- exports.checkPropertiesLength = checkPropertiesLength;
56
- /** String data type name for feature attributes */
57
- const STRING_TYPE = 'string';
58
- /** Integer data type name for feature attributes */
59
- const SHORT_INT_TYPE = 'Int32';
60
- /** Double data type name for feature attributes */
61
- const DOUBLE_TYPE = 'double';
62
- /** Type of attribute that is linked with feature ids */
63
- const OBJECT_ID_TYPE = 'OBJECTID';
64
- /**
65
- * Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
66
- * @param key - attribute's key
67
- * @param attribute - attribute's type in propertyTable
68
- */
69
- function getAttributeType(key, attribute) {
70
- if (key === OBJECT_ID_TYPE) {
71
- return OBJECT_ID_TYPE;
72
- }
73
- if (typeof attribute === STRING_TYPE) {
74
- return STRING_TYPE;
75
- }
76
- else if (typeof attribute === 'number') {
77
- return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;
78
- }
79
- return STRING_TYPE;
80
- }
81
- exports.getAttributeType = getAttributeType;
82
- /**
83
- * Generate storage attribute for map segmentation.
84
- * @param attributeIndex - order index of attribute (f_0, f_1 ...).
85
- * @param key - attribute key from propertyTable.
86
- * @param attributeType - attribute type.
87
- * @return Updated storageAttribute.
88
- */
89
- function createdStorageAttribute(attributeIndex, key, attributeType) {
90
- const storageAttribute = {
91
- key: `f_${attributeIndex}`,
92
- name: key,
93
- ordering: ['attributeValues'],
94
- header: [{ property: 'count', valueType: 'UInt32' }],
95
- attributeValues: { valueType: 'Int32', valuesPerElement: 1 }
96
- };
97
- switch (attributeType) {
98
- case OBJECT_ID_TYPE:
99
- setupIdAttribute(storageAttribute);
100
- break;
101
- case STRING_TYPE:
102
- setupStringAttribute(storageAttribute);
103
- break;
104
- case DOUBLE_TYPE:
105
- setupDoubleAttribute(storageAttribute);
106
- break;
107
- case SHORT_INT_TYPE:
108
- break;
109
- default:
110
- setupStringAttribute(storageAttribute);
111
- }
112
- return storageAttribute;
113
- }
114
- exports.createdStorageAttribute = createdStorageAttribute;
115
- /**
116
- * Find and return attribute type based on key form propertyTable.
117
- * @param attributeType
118
- */
119
- function getFieldAttributeType(attributeType) {
120
- switch (attributeType) {
121
- case OBJECT_ID_TYPE:
122
- return 'esriFieldTypeOID';
123
- case STRING_TYPE:
124
- return 'esriFieldTypeString';
125
- case SHORT_INT_TYPE:
126
- return 'esriFieldTypeInteger';
127
- case DOUBLE_TYPE:
128
- return 'esriFieldTypeDouble';
129
- default:
130
- return 'esriFieldTypeString';
131
- }
132
- }
133
- exports.getFieldAttributeType = getFieldAttributeType;
134
- /**
135
- * Setup field attribute for map segmentation.
136
- * @param key - attribute for map segmentation.
137
- * @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').
138
- */
139
- function createFieldAttribute(key, fieldAttributeType) {
140
- return {
141
- name: key,
142
- type: fieldAttributeType,
143
- alias: key
144
- };
145
- }
146
- exports.createFieldAttribute = createFieldAttribute;
147
- /**
148
- * Generate popup info to show metadata on the map.
149
- * @param propertyTable - table data with OBJECTID.
150
- * @return data for correct rendering of popup.
151
- */
152
- function createPopupInfo(propertyTable) {
153
- const title = '{OBJECTID}';
154
- const mediaInfos = [];
155
- const fieldInfos = [];
156
- const popupElements = [];
157
- const expressionInfos = [];
158
- for (const key in propertyTable) {
159
- fieldInfos.push({
160
- fieldName: key,
161
- visible: true,
162
- isEditable: false,
163
- label: key
164
- });
165
- }
166
- popupElements.push({
167
- fieldInfos,
168
- type: 'fields'
169
- });
170
- return {
171
- title,
172
- mediaInfos,
173
- popupElements,
174
- fieldInfos,
175
- expressionInfos
176
- };
177
- }
178
- exports.createPopupInfo = createPopupInfo;
179
- /**
180
- * Setup storage attribute as string.
181
- * @param storageAttribute - attribute for map segmentation.
182
- */
183
- function setupStringAttribute(storageAttribute) {
184
- // @ts-expect-error
185
- storageAttribute.ordering.unshift('attributeByteCounts');
186
- storageAttribute.header.push({ property: 'attributeValuesByteCount', valueType: 'UInt32' });
187
- storageAttribute.attributeValues = {
188
- valueType: 'String',
189
- encoding: 'UTF-8',
190
- valuesPerElement: 1
191
- };
192
- storageAttribute.attributeByteCounts = {
193
- valueType: 'UInt32',
194
- valuesPerElement: 1
195
- };
196
- }
197
- /**
198
- * Setup Id attribute for map segmentation.
199
- * @param storageAttribute - attribute for map segmentation .
200
- */
201
- function setupIdAttribute(storageAttribute) {
202
- storageAttribute.attributeValues = {
203
- valueType: 'Oid32',
204
- valuesPerElement: 1
205
- };
206
- }
207
- /**
208
- * Setup double attribute for map segmentation.
209
- * @param storageAttribute - attribute for map segmentation .
210
- */
211
- function setupDoubleAttribute(storageAttribute) {
212
- storageAttribute.attributeValues = {
213
- valueType: 'Float64',
214
- valuesPerElement: 1
215
- };
216
- }
@@ -1,202 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateAttributes = void 0;
4
- const loader_utils_1 = require("@loaders.gl/loader-utils");
5
- const VALUES_PER_VERTEX = 3;
6
- const POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;
7
- /**
8
- * Generate geometry attributes with faceRange and featureCount
9
- * @param attributes
10
- * @returns attirbutes with featureCount, featureIds and changed faceRange.
11
- */
12
- function generateAttributes(attributes) {
13
- const { positions, normals, texCoords, colors, uvRegions, featureIndices } = attributes;
14
- const triangleCount = positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
15
- if (!featureIndices.length) {
16
- return {
17
- faceRange: new Uint32Array([0, triangleCount - 1]),
18
- featureIds: [0],
19
- featureCount: 1,
20
- positions,
21
- normals,
22
- texCoords,
23
- colors,
24
- uvRegions
25
- };
26
- }
27
- const data = calculateFaceRangesAndFeaturesCount(featureIndices);
28
- const attributeObjects = makeAttributeObjects({ ...data, ...attributes });
29
- const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);
30
- const groupedAttributes = groupAttributesAndRangesByFeatureId(unifiedAttributeObjectsByFeatureIds, data.featureCount);
31
- return groupedAttributes;
32
- }
33
- exports.generateAttributes = generateAttributes;
34
- /**
35
- * Calculates face Ranges and feature count based on featureIndices.
36
- * @param featureIndices
37
- * @returns Object with featureCount, reordered attributes and changed faceRange.
38
- */
39
- function calculateFaceRangesAndFeaturesCount(featureIndices) {
40
- let rangeIndex = 1;
41
- let featureIndex = 1;
42
- let currentFeatureId = getFrequentValue(featureIndices.slice(0, VALUES_PER_VERTEX));
43
- const faceRangeList = [];
44
- const featureIds = [];
45
- const uniqueFeatureIds = [currentFeatureId];
46
- faceRangeList[0] = 0;
47
- featureIds[0] = currentFeatureId;
48
- for (let index = VALUES_PER_VERTEX; index < featureIndices.length; index += VALUES_PER_VERTEX) {
49
- const newFeatureId = getFrequentValue(featureIndices.slice(index, index + VALUES_PER_VERTEX));
50
- if (currentFeatureId !== newFeatureId) {
51
- faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;
52
- faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;
53
- featureIds[featureIndex] = newFeatureId;
54
- if (!uniqueFeatureIds.includes(newFeatureId)) {
55
- uniqueFeatureIds.push(newFeatureId);
56
- }
57
- rangeIndex += 2;
58
- featureIndex += 1;
59
- }
60
- currentFeatureId = newFeatureId;
61
- }
62
- faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;
63
- const faceRange = new Uint32Array(faceRangeList);
64
- const featureCount = uniqueFeatureIds.length;
65
- return { faceRange, featureCount, featureIds };
66
- }
67
- /**
68
- * Find most frequent value to avoid situation where one vertex can be part of multiple features (objects).
69
- * @param values
70
- */
71
- function getFrequentValue(values) {
72
- const map = {};
73
- let mostFrequentValue = values[0];
74
- let maxCount = 1;
75
- for (const value of values) {
76
- // Save item and it's frequency count to the map.
77
- map[value] = (map[value] || 0) + 1;
78
- // Find max count of frequency.
79
- maxCount = maxCount > map[value] ? maxCount : map[value];
80
- // Find the most frequent value.
81
- mostFrequentValue = maxCount > map[value] ? mostFrequentValue : value;
82
- }
83
- return mostFrequentValue;
84
- }
85
- /**
86
- * Generate list of attribute object grouped by feature ids.
87
- * @param attributes
88
- * @returns sorted list of attribute objects.
89
- */
90
- function makeAttributeObjects(attributes) {
91
- const { featureIds, positions, normals, colors, uvRegions, texCoords, faceRange = new Uint32Array(0) } = attributes;
92
- const groupedData = [];
93
- let positionsList = new Float32Array(positions);
94
- let normalsList = new Float32Array(normals);
95
- let colorsList = new Uint8Array(colors);
96
- let texCoordsList = new Float32Array(texCoords);
97
- let uvRegionsList = new Uint16Array(uvRegions);
98
- for (let index = 0; index < featureIds.length; index++) {
99
- const startIndex = faceRange[index * 2];
100
- const endIndex = faceRange[index * 2 + 1];
101
- const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);
102
- const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);
103
- const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);
104
- const uvRegionsCount = getSliceAttributeCount('uvRegions', startIndex, endIndex);
105
- const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);
106
- groupedData.push({
107
- featureId: featureIds[index],
108
- positions: positionsList.slice(0, positionsCount),
109
- normals: normalsList.slice(0, normalsCount),
110
- colors: colorsList.slice(0, colorsCount),
111
- uvRegions: uvRegionsList.slice(0, uvRegionsCount),
112
- texCoords: texCoordsList.slice(0, texCoordsCount)
113
- });
114
- positionsList = positionsList.slice(positionsCount);
115
- normalsList = normalsList.slice(normalsCount);
116
- colorsList = colorsList.slice(colorsCount);
117
- uvRegionsList = uvRegionsList.slice(uvRegionsCount);
118
- texCoordsList = texCoordsList.slice(texCoordsCount);
119
- }
120
- return groupedData.sort((first, second) => first.featureId - second.featureId);
121
- }
122
- /**
123
- * Generate sliced count for generating attribute objects depends on attribute name and range.
124
- * @param attributeName
125
- * @param startIndex
126
- * @param endIndex
127
- * @returns sliced count
128
- */
129
- function getSliceAttributeCount(attributeName, startIndex, endIndex) {
130
- const itemsPerVertex4 = 4;
131
- const texCoordsPerVertex = 2;
132
- const trianglesCount = endIndex - startIndex + 1;
133
- const vertexCount = trianglesCount * 3;
134
- switch (attributeName) {
135
- case 'positions':
136
- case 'normals':
137
- return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;
138
- case 'colors':
139
- case 'uvRegions':
140
- return vertexCount * itemsPerVertex4;
141
- case 'texCoords':
142
- return vertexCount * texCoordsPerVertex;
143
- default:
144
- return 0;
145
- }
146
- }
147
- /**
148
- * Generates unique object list depends on feature ids and concantenate their attributes.
149
- * @param sortedData
150
- * @returns unique list of objects
151
- */
152
- function unifyObjectsByFeatureId(sortedData) {
153
- const uniqueObjects = [];
154
- for (let index = 0; index < sortedData.length; index++) {
155
- const currentObject = sortedData[index];
156
- const existedObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);
157
- if (existedObject) {
158
- existedObject.positions = (0, loader_utils_1.concatenateTypedArrays)(existedObject.positions, currentObject.positions);
159
- existedObject.normals = (0, loader_utils_1.concatenateTypedArrays)(existedObject.normals, currentObject.normals);
160
- existedObject.colors = (0, loader_utils_1.concatenateTypedArrays)(existedObject.colors, currentObject.colors);
161
- existedObject.texCoords = (0, loader_utils_1.concatenateTypedArrays)(existedObject.texCoords, currentObject.texCoords);
162
- }
163
- else {
164
- uniqueObjects.push(currentObject);
165
- }
166
- }
167
- return uniqueObjects;
168
- }
169
- /**
170
- * Generates attribute objects with new faceRange and reordered attributes.
171
- * @param unifiedObjects
172
- * @returns generated attributes with new faceRange.
173
- */
174
- function groupAttributesAndRangesByFeatureId(unifiedObjects, featureCount) {
175
- const firstAttributeObject = unifiedObjects[0];
176
- const featureIds = [firstAttributeObject.featureId || 0];
177
- let positions = new Float32Array(firstAttributeObject.positions);
178
- let normals = new Float32Array(firstAttributeObject.normals);
179
- let colors = new Uint8Array(firstAttributeObject.colors);
180
- let uvRegions = new Uint16Array(firstAttributeObject.uvRegions);
181
- let texCoords = new Float32Array(firstAttributeObject.texCoords);
182
- const range = [0];
183
- let objIndex = 0;
184
- let sum = 0;
185
- for (let index = 1; index < unifiedObjects.length; index++) {
186
- const currentAttributesObject = unifiedObjects[index];
187
- featureIds.push(currentAttributesObject.featureId || 0);
188
- positions = (0, loader_utils_1.concatenateTypedArrays)(positions, currentAttributesObject.positions);
189
- normals = (0, loader_utils_1.concatenateTypedArrays)(normals, currentAttributesObject.normals);
190
- colors = (0, loader_utils_1.concatenateTypedArrays)(colors, currentAttributesObject.colors);
191
- uvRegions = (0, loader_utils_1.concatenateTypedArrays)(uvRegions, currentAttributesObject.uvRegions);
192
- texCoords = (0, loader_utils_1.concatenateTypedArrays)(texCoords, currentAttributesObject.texCoords);
193
- const groupedObject = unifiedObjects[objIndex];
194
- range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);
195
- range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);
196
- sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
197
- objIndex += 1;
198
- }
199
- range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);
200
- const faceRange = new Uint32Array(range);
201
- return { faceRange, featureIds, positions, normals, colors, uvRegions, texCoords, featureCount };
202
- }