@loaders.gl/tile-converter 4.4.0-alpha.1 → 4.4.0-alpha.9
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.
- package/dist/converter.min.cjs +89 -98
- package/dist/i3s-server/bin/i3s-server.min.cjs +78 -78
- package/package.json +17 -17
- package/src/3d-tiles-converter/3d-tiles-converter.ts +11 -7
- package/src/3d-tiles-converter/helpers/load-i3s.ts +5 -5
- package/src/converter-cli.ts +2 -2
- package/src/i3s-converter/helpers/geometry-converter.ts +17 -1
- package/src/i3s-converter/helpers/load-3d-tiles.ts +24 -9
- package/src/i3s-converter/i3s-converter.ts +25 -9
- package/src/i3s-server/controllers/slpk-controller.ts +2 -2
- package/src/lib/utils/compress-util.ts +1 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +0 -115
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +0 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +0 -388
- package/dist/3d-tiles-converter/helpers/3d-tiles-content-converter.d.ts +0 -88
- package/dist/3d-tiles-converter/helpers/3d-tiles-content-converter.d.ts.map +0 -1
- package/dist/3d-tiles-converter/helpers/3d-tiles-content-converter.js +0 -380
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +0 -13
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +0 -1
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -19
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts +0 -37
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +0 -1
- package/dist/3d-tiles-converter/helpers/load-i3s.js +0 -98
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +0 -10
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +0 -1
- package/dist/3d-tiles-converter/helpers/texture-atlas.js +0 -50
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts +0 -15
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +0 -1
- package/dist/3d-tiles-converter/json-templates/tileset.js +0 -39
- package/dist/constants.d.ts +0 -3
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -2
- package/dist/converter-cli.d.ts +0 -2
- package/dist/converter-cli.d.ts.map +0 -1
- package/dist/converter-cli.js +0 -290
- package/dist/deps-installer/deps-installer.d.ts +0 -19
- package/dist/deps-installer/deps-installer.d.ts.map +0 -1
- package/dist/deps-installer/deps-installer.js +0 -95
- package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts +0 -84
- package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/attribute-metadata-info.js +0 -219
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +0 -26
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +0 -165
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +0 -39
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js +0 -118
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +0 -9
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/create-scene-server-path.js +0 -21
- package/dist/i3s-converter/helpers/feature-attributes.d.ts +0 -54
- package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/feature-attributes.js +0 -193
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts +0 -8
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/geometry-attributes.js +0 -226
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +0 -60
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +0 -1309
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts +0 -28
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +0 -122
- package/dist/i3s-converter/helpers/load-3d-tiles.d.ts +0 -33
- package/dist/i3s-converter/helpers/load-3d-tiles.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/load-3d-tiles.js +0 -121
- package/dist/i3s-converter/helpers/node-debug.d.ts +0 -8
- package/dist/i3s-converter/helpers/node-debug.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/node-debug.js +0 -116
- package/dist/i3s-converter/helpers/node-index-document.d.ts +0 -111
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/node-index-document.js +0 -269
- package/dist/i3s-converter/helpers/node-pages.d.ts +0 -156
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/node-pages.js +0 -285
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +0 -22
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +0 -104
- package/dist/i3s-converter/helpers/progress.d.ts +0 -90
- package/dist/i3s-converter/helpers/progress.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/progress.js +0 -148
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts +0 -32
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/tileset-traversal.js +0 -34
- package/dist/i3s-converter/i3s-converter.d.ts +0 -312
- package/dist/i3s-converter/i3s-converter.d.ts.map +0 -1
- package/dist/i3s-converter/i3s-converter.js +0 -1191
- package/dist/i3s-converter/json-templates/geometry-definitions.d.ts +0 -7
- package/dist/i3s-converter/json-templates/geometry-definitions.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/geometry-definitions.js +0 -80
- package/dist/i3s-converter/json-templates/layers.d.ts +0 -70
- package/dist/i3s-converter/json-templates/layers.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/layers.js +0 -132
- package/dist/i3s-converter/json-templates/metadata.d.ts +0 -22
- package/dist/i3s-converter/json-templates/metadata.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/metadata.js +0 -21
- package/dist/i3s-converter/json-templates/node.d.ts +0 -61
- package/dist/i3s-converter/json-templates/node.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/node.js +0 -82
- package/dist/i3s-converter/json-templates/scene-server.d.ts +0 -28
- package/dist/i3s-converter/json-templates/scene-server.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/scene-server.js +0 -27
- package/dist/i3s-converter/json-templates/shared-resources.d.ts +0 -14
- package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/shared-resources.js +0 -122
- package/dist/i3s-converter/json-templates/store.d.ts +0 -95
- package/dist/i3s-converter/json-templates/store.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/store.js +0 -100
- package/dist/i3s-converter/types.d.ts +0 -226
- package/dist/i3s-converter/types.d.ts.map +0 -1
- package/dist/i3s-converter/types.js +0 -37
- package/dist/i3s-server/app.d.ts +0 -3
- package/dist/i3s-server/app.d.ts.map +0 -1
- package/dist/i3s-server/app.js +0 -31
- package/dist/i3s-server/bin/www.d.ts +0 -3
- package/dist/i3s-server/bin/www.d.ts.map +0 -1
- package/dist/i3s-server/bin/www.js +0 -46
- package/dist/i3s-server/controllers/slpk-controller.d.ts +0 -13
- package/dist/i3s-server/controllers/slpk-controller.d.ts.map +0 -1
- package/dist/i3s-server/controllers/slpk-controller.js +0 -32
- package/dist/i3s-server/routes/slpk-router.d.ts +0 -3
- package/dist/i3s-server/routes/slpk-router.d.ts.map +0 -1
- package/dist/i3s-server/routes/slpk-router.js +0 -40
- package/dist/i3s-server/utils/create-scene-server.d.ts +0 -17
- package/dist/i3s-server/utils/create-scene-server.d.ts.map +0 -1
- package/dist/i3s-server/utils/create-scene-server.js +0 -18
- package/dist/i3s-server/utils/server-utils.d.ts +0 -21
- package/dist/i3s-server/utils/server-utils.d.ts.map +0 -1
- package/dist/i3s-server/utils/server-utils.js +0 -60
- package/dist/index.cjs +0 -6228
- package/dist/index.cjs.map +0 -7
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/lib/json-schemas/conversion-dump-json-schema.d.ts +0 -463
- package/dist/lib/json-schemas/conversion-dump-json-schema.d.ts.map +0 -1
- package/dist/lib/json-schemas/conversion-dump-json-schema.js +0 -285
- package/dist/lib/utils/cli-utils.d.ts +0 -34
- package/dist/lib/utils/cli-utils.d.ts.map +0 -1
- package/dist/lib/utils/cli-utils.js +0 -76
- package/dist/lib/utils/compress-util.d.ts +0 -8
- package/dist/lib/utils/compress-util.d.ts.map +0 -1
- package/dist/lib/utils/compress-util.js +0 -25
- package/dist/lib/utils/conversion-dump.d.ts +0 -147
- package/dist/lib/utils/conversion-dump.d.ts.map +0 -1
- package/dist/lib/utils/conversion-dump.js +0 -257
- package/dist/lib/utils/file-utils.d.ts +0 -57
- package/dist/lib/utils/file-utils.d.ts.map +0 -1
- package/dist/lib/utils/file-utils.js +0 -140
- package/dist/lib/utils/geometry-utils.d.ts +0 -9
- package/dist/lib/utils/geometry-utils.d.ts.map +0 -1
- package/dist/lib/utils/geometry-utils.js +0 -14
- package/dist/lib/utils/lod-conversion-utils.d.ts +0 -42
- package/dist/lib/utils/lod-conversion-utils.d.ts.map +0 -1
- package/dist/lib/utils/lod-conversion-utils.js +0 -71
- package/dist/lib/utils/queue.d.ts +0 -7
- package/dist/lib/utils/queue.d.ts.map +0 -1
- package/dist/lib/utils/queue.js +0 -14
- package/dist/lib/utils/statistic-utils.d.ts +0 -20
- package/dist/lib/utils/statistic-utils.d.ts.map +0 -1
- package/dist/lib/utils/statistic-utils.js +0 -88
- package/dist/lib/utils/write-queue.d.ts +0 -44
- package/dist/lib/utils/write-queue.d.ts.map +0 -1
- package/dist/lib/utils/write-queue.js +0 -82
- package/dist/pgm-loader.d.ts +0 -28
- package/dist/pgm-loader.d.ts.map +0 -1
- package/dist/pgm-loader.js +0 -24
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { AttributeType } from "../types.js";
|
|
2
|
-
import { EXT_FEATURE_METADATA, EXT_STRUCTURAL_METADATA } from '@loaders.gl/gltf';
|
|
3
|
-
/**
|
|
4
|
-
* Takes attributes from property table based on featureIdsMap.
|
|
5
|
-
* If there is no property value for particular featureId (index) the property will be null.
|
|
6
|
-
* Example:
|
|
7
|
-
* Initial data:
|
|
8
|
-
* OBJECTID: {0: 0, 3: 33, 4: 333}
|
|
9
|
-
* component: ['Windows', 'Frames', 'Wall', 'Roof', 'Skylight']
|
|
10
|
-
* Result:
|
|
11
|
-
* OBJECTID: [0, 33, 333]
|
|
12
|
-
* component: ['Windows', 'Roof', 'Skylight']
|
|
13
|
-
* @param featureIdsMap
|
|
14
|
-
* @param propertyTable
|
|
15
|
-
*/
|
|
16
|
-
export function flattenPropertyTableByFeatureIds(featureIdsMap, propertyTable) {
|
|
17
|
-
const resultPropertyTable = {};
|
|
18
|
-
for (const propertyName in propertyTable) {
|
|
19
|
-
const properties = propertyTable[propertyName];
|
|
20
|
-
resultPropertyTable[propertyName] = getPropertiesByFeatureIds(properties, featureIdsMap);
|
|
21
|
-
}
|
|
22
|
-
return resultPropertyTable;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Getting properties by featureId index
|
|
26
|
-
* @param properties
|
|
27
|
-
* @param featureIdsMap
|
|
28
|
-
*/
|
|
29
|
-
function getPropertiesByFeatureIds(properties, featureIdsMap) {
|
|
30
|
-
const resultProperties = [];
|
|
31
|
-
if (properties) {
|
|
32
|
-
for (const featureIdKey in featureIdsMap) {
|
|
33
|
-
const property = properties[featureIdKey] || null;
|
|
34
|
-
resultProperties.push(property);
|
|
35
|
-
}
|
|
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
|
-
export function checkPropertiesLength(featureIds, propertyTable) {
|
|
47
|
-
let needFlatten = false;
|
|
48
|
-
for (const attribute of Object.values(propertyTable)) {
|
|
49
|
-
if (!featureIds || !attribute || featureIds.length !== attribute.length) {
|
|
50
|
-
needFlatten = true;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return needFlatten;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
|
|
57
|
-
* @param attribute - attribute taken from propertyTable
|
|
58
|
-
*/
|
|
59
|
-
export function getAttributeType(attribute) {
|
|
60
|
-
if (typeof attribute === 'string' || typeof attribute === 'bigint') {
|
|
61
|
-
return AttributeType.STRING_TYPE;
|
|
62
|
-
}
|
|
63
|
-
else if (typeof attribute === 'number') {
|
|
64
|
-
return Number.isInteger(attribute) ? AttributeType.SHORT_INT_TYPE : AttributeType.DOUBLE_TYPE;
|
|
65
|
-
}
|
|
66
|
-
return AttributeType.STRING_TYPE;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Gets attribute's types based on the property table records.
|
|
70
|
-
* @param propertyTable - Table with layer meta data.
|
|
71
|
-
* @returns set of attribute types
|
|
72
|
-
* @example of returned object:
|
|
73
|
-
* {
|
|
74
|
-
* "opt_uint8": "Int32",
|
|
75
|
-
* "opt_uint64": "string"
|
|
76
|
-
* }
|
|
77
|
-
*/
|
|
78
|
-
export function getAttributeTypesMapFromPropertyTable(propertyTable) {
|
|
79
|
-
const attributeTypesMap = {};
|
|
80
|
-
for (const key in propertyTable) {
|
|
81
|
-
// Get attribute type based on the first element of each property.
|
|
82
|
-
const firstAttribute = propertyTable[key][0];
|
|
83
|
-
const attributeType = getAttributeType(firstAttribute);
|
|
84
|
-
attributeTypesMap[key] = attributeType;
|
|
85
|
-
}
|
|
86
|
-
return attributeTypesMap;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Gets attribute's types from the extension schema selected by the class name 'metadataClass'.
|
|
90
|
-
* @param gltfJson - JSON part of GLB content
|
|
91
|
-
* @param metadataClass - name of the schema class
|
|
92
|
-
* @returns set of attribute's types
|
|
93
|
-
* @example of returned object:
|
|
94
|
-
* {
|
|
95
|
-
* "opt_uint8": "Int32",
|
|
96
|
-
* "opt_uint64": "string"
|
|
97
|
-
* }
|
|
98
|
-
*/
|
|
99
|
-
export const getAttributeTypesMapFromSchema = (gltfJson, metadataClass) => {
|
|
100
|
-
const attributeTypesMap = {};
|
|
101
|
-
const extFeatureMetadataSchemaClass = gltfJson.extensions?.[EXT_FEATURE_METADATA]?.schema?.classes?.[metadataClass];
|
|
102
|
-
if (extFeatureMetadataSchemaClass) {
|
|
103
|
-
for (const propertyName in extFeatureMetadataSchemaClass.properties) {
|
|
104
|
-
const property = extFeatureMetadataSchemaClass.properties[propertyName];
|
|
105
|
-
const attributeProperty = getAttributeTypeFromExtFeatureMetadata(property);
|
|
106
|
-
attributeTypesMap[propertyName] = attributeProperty;
|
|
107
|
-
}
|
|
108
|
-
return attributeTypesMap;
|
|
109
|
-
}
|
|
110
|
-
const extStructuralMetadataSchemaClass = gltfJson.extensions?.[EXT_STRUCTURAL_METADATA]?.schema?.classes?.[metadataClass];
|
|
111
|
-
if (extStructuralMetadataSchemaClass) {
|
|
112
|
-
for (const propertyName in extStructuralMetadataSchemaClass.properties) {
|
|
113
|
-
const property = extStructuralMetadataSchemaClass.properties[propertyName];
|
|
114
|
-
const attributeProperty = getAttributeTypeFromExtStructuralMetadata(property);
|
|
115
|
-
attributeTypesMap[propertyName] = attributeProperty;
|
|
116
|
-
}
|
|
117
|
-
return attributeTypesMap;
|
|
118
|
-
}
|
|
119
|
-
return null;
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* Gets the attribute type according to the Ext_feature_metadata extension class schema
|
|
123
|
-
* @see https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
|
|
124
|
-
* @param property - schema of the class property for Ext_feature_metadata
|
|
125
|
-
* @returns attribute's type
|
|
126
|
-
*/
|
|
127
|
-
// eslint-disable-next-line complexity
|
|
128
|
-
const getAttributeTypeFromExtFeatureMetadata = (property) => {
|
|
129
|
-
let attributeType;
|
|
130
|
-
switch (property.type) {
|
|
131
|
-
case 'INT8':
|
|
132
|
-
case 'UINT8':
|
|
133
|
-
case 'INT16':
|
|
134
|
-
case 'UINT16':
|
|
135
|
-
case 'INT32':
|
|
136
|
-
case 'UINT32':
|
|
137
|
-
attributeType = AttributeType.SHORT_INT_TYPE;
|
|
138
|
-
break;
|
|
139
|
-
case 'FLOAT32':
|
|
140
|
-
case 'FLOAT64':
|
|
141
|
-
attributeType = AttributeType.DOUBLE_TYPE;
|
|
142
|
-
break;
|
|
143
|
-
case 'INT64':
|
|
144
|
-
case 'UINT64':
|
|
145
|
-
case 'BOOLEAN':
|
|
146
|
-
case 'ENUM':
|
|
147
|
-
case 'STRING':
|
|
148
|
-
case 'ARRAY':
|
|
149
|
-
attributeType = AttributeType.STRING_TYPE;
|
|
150
|
-
break;
|
|
151
|
-
default:
|
|
152
|
-
attributeType = AttributeType.STRING_TYPE;
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
return attributeType;
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* Gets the attribute type according to the Ext_structural_metadata extension class schema
|
|
159
|
-
* @see https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
|
|
160
|
-
* @param property - schema of the class property for Ext_structural_metadata
|
|
161
|
-
* @returns attribute's type
|
|
162
|
-
*/
|
|
163
|
-
// eslint-disable-next-line complexity
|
|
164
|
-
const getAttributeTypeFromExtStructuralMetadata = (property) => {
|
|
165
|
-
let attributeType;
|
|
166
|
-
if (property.array) {
|
|
167
|
-
attributeType = AttributeType.STRING_TYPE;
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
switch (property.componentType) {
|
|
171
|
-
case 'INT8':
|
|
172
|
-
case 'UINT8':
|
|
173
|
-
case 'INT16':
|
|
174
|
-
case 'UINT16':
|
|
175
|
-
case 'INT32':
|
|
176
|
-
case 'UINT32':
|
|
177
|
-
attributeType = AttributeType.SHORT_INT_TYPE;
|
|
178
|
-
break;
|
|
179
|
-
case 'FLOAT32':
|
|
180
|
-
case 'FLOAT64':
|
|
181
|
-
attributeType = AttributeType.DOUBLE_TYPE;
|
|
182
|
-
break;
|
|
183
|
-
case 'INT64':
|
|
184
|
-
case 'UINT64':
|
|
185
|
-
attributeType = AttributeType.STRING_TYPE;
|
|
186
|
-
break;
|
|
187
|
-
default:
|
|
188
|
-
attributeType = AttributeType.STRING_TYPE;
|
|
189
|
-
break;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return attributeType;
|
|
193
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { GeometryAttributes, ConvertedAttributes } from "../types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Generate geometry attributes with faceRange and featureCount
|
|
4
|
-
* @param attributes
|
|
5
|
-
* @returns attirbutes with featureCount, featureIds and changed faceRange.
|
|
6
|
-
*/
|
|
7
|
-
export declare function generateAttributes(attributes: ConvertedAttributes): GeometryAttributes;
|
|
8
|
-
//# sourceMappingURL=geometry-attributes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"geometry-attributes.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EAGpB,oBAAiB;AAMlB;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,mBAAmB,GAAG,kBAAkB,CAyBtF"}
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import { concatenateTypedArrays } from '@loaders.gl/loader-utils';
|
|
2
|
-
const VALUES_PER_VERTEX = 3;
|
|
3
|
-
const POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;
|
|
4
|
-
/**
|
|
5
|
-
* Generate geometry attributes with faceRange and featureCount
|
|
6
|
-
* @param attributes
|
|
7
|
-
* @returns attirbutes with featureCount, featureIds and changed faceRange.
|
|
8
|
-
*/
|
|
9
|
-
export function generateAttributes(attributes) {
|
|
10
|
-
const { positions, normals, texCoords, colors, uvRegions, featureIndices } = attributes;
|
|
11
|
-
const triangleCount = positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
|
|
12
|
-
if (!featureIndices.length) {
|
|
13
|
-
return {
|
|
14
|
-
faceRange: new Uint32Array([0, triangleCount - 1]),
|
|
15
|
-
featureIds: [0],
|
|
16
|
-
featureCount: 1,
|
|
17
|
-
positions,
|
|
18
|
-
normals,
|
|
19
|
-
texCoords,
|
|
20
|
-
colors,
|
|
21
|
-
uvRegions
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
const data = calculateFaceRangesAndFeaturesCount(featureIndices);
|
|
25
|
-
const attributeObjects = makeAttributeObjects({ ...data, ...attributes });
|
|
26
|
-
const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);
|
|
27
|
-
const groupedAttributes = groupAttributesAndRangesByFeatureId(unifiedAttributeObjectsByFeatureIds, data.featureCount);
|
|
28
|
-
return groupedAttributes;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Calculates face Ranges and feature count based on featureIndices.
|
|
32
|
-
* @param featureIndices
|
|
33
|
-
* @returns Object with featureCount, reordered attributes and changed faceRange.
|
|
34
|
-
*/
|
|
35
|
-
function calculateFaceRangesAndFeaturesCount(featureIndices) {
|
|
36
|
-
let rangeIndex = 1;
|
|
37
|
-
let featureIndex = 1;
|
|
38
|
-
let currentFeatureId = getFrequentValue(featureIndices.slice(0, VALUES_PER_VERTEX));
|
|
39
|
-
const faceRangeList = [];
|
|
40
|
-
const featureIds = [];
|
|
41
|
-
const uniqueFeatureIds = [currentFeatureId];
|
|
42
|
-
faceRangeList[0] = 0;
|
|
43
|
-
featureIds[0] = currentFeatureId;
|
|
44
|
-
for (let index = VALUES_PER_VERTEX; index < featureIndices.length; index += VALUES_PER_VERTEX) {
|
|
45
|
-
const newFeatureId = getFrequentValue(featureIndices.slice(index, index + VALUES_PER_VERTEX));
|
|
46
|
-
if (currentFeatureId !== newFeatureId) {
|
|
47
|
-
faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;
|
|
48
|
-
faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;
|
|
49
|
-
featureIds[featureIndex] = newFeatureId;
|
|
50
|
-
if (!uniqueFeatureIds.includes(newFeatureId)) {
|
|
51
|
-
uniqueFeatureIds.push(newFeatureId);
|
|
52
|
-
}
|
|
53
|
-
rangeIndex += 2;
|
|
54
|
-
featureIndex += 1;
|
|
55
|
-
}
|
|
56
|
-
currentFeatureId = newFeatureId;
|
|
57
|
-
}
|
|
58
|
-
faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;
|
|
59
|
-
const faceRange = new Uint32Array(faceRangeList);
|
|
60
|
-
const featureCount = uniqueFeatureIds.length;
|
|
61
|
-
return { faceRange, featureCount, featureIds };
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Find most frequent value to avoid situation where one vertex can be part of multiple features (objects).
|
|
65
|
-
* @param values
|
|
66
|
-
*/
|
|
67
|
-
function getFrequentValue(values) {
|
|
68
|
-
const map = {};
|
|
69
|
-
let mostFrequentValue = values[0];
|
|
70
|
-
let maxCount = 1;
|
|
71
|
-
for (const value of values) {
|
|
72
|
-
// Save item and it's frequency count to the map.
|
|
73
|
-
map[value] = (map[value] || 0) + 1;
|
|
74
|
-
// Find max count of frequency.
|
|
75
|
-
maxCount = maxCount > map[value] ? maxCount : map[value];
|
|
76
|
-
// Find the most frequent value.
|
|
77
|
-
mostFrequentValue = maxCount > map[value] ? mostFrequentValue : value;
|
|
78
|
-
}
|
|
79
|
-
return mostFrequentValue;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Generate list of attribute object grouped by feature ids.
|
|
83
|
-
* @param attributes
|
|
84
|
-
* @returns sorted list of attribute objects.
|
|
85
|
-
*/
|
|
86
|
-
// eslint-disable-next-line max-statements
|
|
87
|
-
function makeAttributeObjects(attributes) {
|
|
88
|
-
const { featureIds, positions, normals, colors, uvRegions, texCoords, faceRange = new Uint32Array(0) } = attributes;
|
|
89
|
-
const groupedData = [];
|
|
90
|
-
const positionsList = new Float32Array(positions);
|
|
91
|
-
const normalsList = new Float32Array(normals);
|
|
92
|
-
const colorsList = new Uint8Array(colors);
|
|
93
|
-
const texCoordsList = new Float32Array(texCoords);
|
|
94
|
-
const uvRegionsList = new Uint16Array(uvRegions);
|
|
95
|
-
let positionsOffset = 0;
|
|
96
|
-
let normalsOffset = 0;
|
|
97
|
-
let colorsOffset = 0;
|
|
98
|
-
let uvRegionsOffset = 0;
|
|
99
|
-
let texCoordsOffset = 0;
|
|
100
|
-
for (let index = 0; index < featureIds.length; index++) {
|
|
101
|
-
const startIndex = faceRange[index * 2];
|
|
102
|
-
const endIndex = faceRange[index * 2 + 1];
|
|
103
|
-
const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);
|
|
104
|
-
const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);
|
|
105
|
-
const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);
|
|
106
|
-
const uvRegionsCount = getSliceAttributeCount('uvRegions', startIndex, endIndex);
|
|
107
|
-
const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);
|
|
108
|
-
groupedData.push({
|
|
109
|
-
featureId: featureIds[index],
|
|
110
|
-
positions: positionsList.subarray(positionsOffset, positionsOffset + positionsCount),
|
|
111
|
-
normals: normalsList.subarray(normalsOffset, normalsOffset + normalsCount),
|
|
112
|
-
colors: colorsList.subarray(colorsOffset, colorsOffset + colorsCount),
|
|
113
|
-
uvRegions: uvRegionsList.subarray(uvRegionsOffset, uvRegionsOffset + uvRegionsCount),
|
|
114
|
-
texCoords: texCoordsList.subarray(texCoordsOffset, texCoordsOffset + texCoordsCount)
|
|
115
|
-
});
|
|
116
|
-
positionsOffset += positionsCount;
|
|
117
|
-
normalsOffset += normalsCount;
|
|
118
|
-
colorsOffset += colorsCount;
|
|
119
|
-
uvRegionsOffset += uvRegionsCount;
|
|
120
|
-
texCoordsOffset += texCoordsCount;
|
|
121
|
-
}
|
|
122
|
-
return groupedData;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Generate sliced count for generating attribute objects depends on attribute name and range.
|
|
126
|
-
* @param attributeName
|
|
127
|
-
* @param startIndex
|
|
128
|
-
* @param endIndex
|
|
129
|
-
* @returns sliced count
|
|
130
|
-
*/
|
|
131
|
-
function getSliceAttributeCount(attributeName, startIndex, endIndex) {
|
|
132
|
-
const itemsPerVertex4 = 4;
|
|
133
|
-
const texCoordsPerVertex = 2;
|
|
134
|
-
const trianglesCount = endIndex - startIndex + 1;
|
|
135
|
-
const vertexCount = trianglesCount * 3;
|
|
136
|
-
switch (attributeName) {
|
|
137
|
-
case 'positions':
|
|
138
|
-
case 'normals':
|
|
139
|
-
return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;
|
|
140
|
-
case 'colors':
|
|
141
|
-
case 'uvRegions':
|
|
142
|
-
return vertexCount * itemsPerVertex4;
|
|
143
|
-
case 'texCoords':
|
|
144
|
-
return vertexCount * texCoordsPerVertex;
|
|
145
|
-
default:
|
|
146
|
-
return 0;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Generates unique object list depends on feature ids and concantenate their attributes.
|
|
151
|
-
* @param sortedData
|
|
152
|
-
* @returns unique list of objects
|
|
153
|
-
*/
|
|
154
|
-
function unifyObjectsByFeatureId(sortedData) {
|
|
155
|
-
const groupedMetadata = [];
|
|
156
|
-
for (const data of sortedData) {
|
|
157
|
-
const existingObject = groupedMetadata.find((obj) => obj.featureId === data.featureId);
|
|
158
|
-
if (existingObject) {
|
|
159
|
-
existingObject.attributes.push(data);
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
groupedMetadata.push({
|
|
163
|
-
featureId: data.featureId,
|
|
164
|
-
attributes: [data]
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
const uniqueObjects = [];
|
|
169
|
-
for (const metatada of groupedMetadata) {
|
|
170
|
-
const attributes = concatenateAttributes(metatada.attributes);
|
|
171
|
-
uniqueObjects.push({
|
|
172
|
-
featureId: metatada.featureId,
|
|
173
|
-
...attributes
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
return uniqueObjects;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Generates attribute objects with new faceRange and reordered attributes.
|
|
180
|
-
* @param unifiedObjects
|
|
181
|
-
* @returns generated attributes with new faceRange.
|
|
182
|
-
*/
|
|
183
|
-
function groupAttributesAndRangesByFeatureId(unifiedObjects, featureCount) {
|
|
184
|
-
const firstAttributeObject = unifiedObjects[0];
|
|
185
|
-
const featureIds = [firstAttributeObject.featureId || 0];
|
|
186
|
-
const range = [0];
|
|
187
|
-
let objIndex = 0;
|
|
188
|
-
let sum = 0;
|
|
189
|
-
for (let index = 1; index < unifiedObjects.length; index++) {
|
|
190
|
-
const currentAttributesObject = unifiedObjects[index];
|
|
191
|
-
featureIds.push(currentAttributesObject.featureId || 0);
|
|
192
|
-
const groupedObject = unifiedObjects[objIndex];
|
|
193
|
-
range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);
|
|
194
|
-
range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);
|
|
195
|
-
sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
|
|
196
|
-
objIndex += 1;
|
|
197
|
-
}
|
|
198
|
-
const attributes = concatenateAttributes(unifiedObjects);
|
|
199
|
-
range.push(attributes.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);
|
|
200
|
-
const faceRange = new Uint32Array(range);
|
|
201
|
-
return { faceRange, featureIds, featureCount, ...attributes };
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Concatenate attributes typed arrays
|
|
205
|
-
* @param attributes - grouped by featureId typed arrays
|
|
206
|
-
* @returns - concatenated typed array list
|
|
207
|
-
*/
|
|
208
|
-
function concatenateAttributes(attributes) {
|
|
209
|
-
const positionGroups = attributes.map(({ positions }) => positions);
|
|
210
|
-
const positions = positionGroups.length > 1 ? concatenateTypedArrays(...positionGroups) : positionGroups[0];
|
|
211
|
-
const normalGroups = attributes.map(({ normals }) => normals);
|
|
212
|
-
const normals = normalGroups.length > 1 ? concatenateTypedArrays(...normalGroups) : normalGroups[0];
|
|
213
|
-
const colorGroups = attributes.map(({ colors }) => colors);
|
|
214
|
-
const colors = colorGroups.length > 1 ? concatenateTypedArrays(...colorGroups) : colorGroups[0];
|
|
215
|
-
const texCoordGroups = attributes.map(({ texCoords }) => texCoords);
|
|
216
|
-
const texCoords = texCoordGroups.length > 1 ? concatenateTypedArrays(...texCoordGroups) : texCoordGroups[0];
|
|
217
|
-
const uvRegionGroups = attributes.map(({ uvRegions }) => uvRegions);
|
|
218
|
-
const uvRegions = uvRegionGroups.length > 1 ? concatenateTypedArrays(...uvRegionGroups) : uvRegionGroups[0];
|
|
219
|
-
return {
|
|
220
|
-
positions,
|
|
221
|
-
normals,
|
|
222
|
-
colors,
|
|
223
|
-
texCoords,
|
|
224
|
-
uvRegions
|
|
225
|
-
};
|
|
226
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { FeatureTableJson, Tiles3DTileContent } from '@loaders.gl/3d-tiles';
|
|
2
|
-
import { Matrix4 } from '@math.gl/core';
|
|
3
|
-
import { ConvertedAttributes, I3SConvertedResources, I3SMaterialWithTexture } from "../types.js";
|
|
4
|
-
import { AttributeStorageInfo } from '@loaders.gl/i3s';
|
|
5
|
-
import { Geoid } from '@math.gl/geoid';
|
|
6
|
-
import type { GLTFAttributesData } from "../types.js";
|
|
7
|
-
import { BoundingSphere, OrientedBoundingBox } from '@math.gl/culling';
|
|
8
|
-
/**
|
|
9
|
-
* Convert binary data from b3dm file to i3s resources
|
|
10
|
-
*
|
|
11
|
-
* @param tileContent - 3d tile content
|
|
12
|
-
* @param tileTransform - transformation matrix of the tile, calculated recursively multiplying
|
|
13
|
-
* transform of all parent tiles and transform of the current tile
|
|
14
|
-
* @param tileBoundingVolume - initialized bounding volume of the source tile
|
|
15
|
-
* @param addNodeToNodePage - function to add new node to node pages
|
|
16
|
-
* @param propertyTable - batch table (corresponding to feature attributes data)
|
|
17
|
-
* @param featuresHashArray - hash array of features that is needed to not to mix up same features in parent and child nodes
|
|
18
|
-
* @param attributeStorageInfo - attributes metadata from 3DSceneLayer json
|
|
19
|
-
* @param draco - is converter should create draco compressed geometry
|
|
20
|
-
* @param generateBoundingVolumes - is converter should create accurate bounding voulmes from geometry attributes
|
|
21
|
-
* @param shouldMergeMaterials - Try to merge similar materials to be able to merge meshes into one node
|
|
22
|
-
* @param geoidHeightModel - model to convert elevation from elipsoidal to geoid
|
|
23
|
-
* @param libraries - dynamicaly loaded 3rd-party libraries
|
|
24
|
-
* @param metadataClass `- user selected feature metadata class name`
|
|
25
|
-
* @returns Array of node resources to create one or more i3s nodes
|
|
26
|
-
*/
|
|
27
|
-
export default function convertB3dmToI3sGeometry({ tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, libraries, metadataClass }: {
|
|
28
|
-
tileContent: Tiles3DTileContent;
|
|
29
|
-
tileTransform: Matrix4;
|
|
30
|
-
tileBoundingVolume: OrientedBoundingBox | BoundingSphere;
|
|
31
|
-
addNodeToNodePage: () => Promise<number>;
|
|
32
|
-
propertyTable: FeatureTableJson | null;
|
|
33
|
-
featuresHashArray: string[];
|
|
34
|
-
attributeStorageInfo: AttributeStorageInfo[] | undefined;
|
|
35
|
-
draco: boolean;
|
|
36
|
-
generateBoundingVolumes: boolean;
|
|
37
|
-
shouldMergeMaterials: boolean;
|
|
38
|
-
geoidHeightModel: Geoid | null;
|
|
39
|
-
libraries: Record<string, string>;
|
|
40
|
-
metadataClass?: string;
|
|
41
|
-
}): Promise<I3SConvertedResources[] | null>;
|
|
42
|
-
/**
|
|
43
|
-
* Convert attributes from the gltf nodes tree to i3s plain geometry
|
|
44
|
-
* @param attributesData - geometry attributes from gltf
|
|
45
|
-
* @param materialAndTextureList - array of data about materials and textures of the content
|
|
46
|
-
* @param useCartesianPositions - convert positions to absolute cartesian coordinates instead of cartographic offsets.
|
|
47
|
-
* Cartesian coordinates will be required for creating bounding voulmest from geometry positions
|
|
48
|
-
* @param featureTexture - feature texture key
|
|
49
|
-
* @returns map of converted geometry attributes
|
|
50
|
-
*/
|
|
51
|
-
export declare function convertAttributes(attributesData: GLTFAttributesData, materialAndTextureList: I3SMaterialWithTexture[], useCartesianPositions: boolean, featureTexture: string | null): Promise<Map<string, ConvertedAttributes>>;
|
|
52
|
-
/**
|
|
53
|
-
* Find property table in tile
|
|
54
|
-
* For example it can be batchTable for b3dm files or property table in gLTF extension.
|
|
55
|
-
* @param tileContent - 3DTiles tile content
|
|
56
|
-
* @param metadataClass - user selected feature metadata class name
|
|
57
|
-
* @return batch table from b3dm / feature properties from EXT_FEATURE_METADATA or EXT_STRUCTURAL_METADATA.
|
|
58
|
-
*/
|
|
59
|
-
export declare function getPropertyTable(tileContent: Tiles3DTileContent | null, metadataClass?: string): FeatureTableJson | null;
|
|
60
|
-
//# sourceMappingURL=geometry-converter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"geometry-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-converter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,gBAAgB,EAAE,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAgB/E,OAAO,EAAU,OAAO,EAAU,MAAM,eAAe,CAAC;AAexD,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EAGvB,oBAAiB;AAClB,OAAO,EACL,oBAAoB,EAIrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAWrC,OAAO,KAAK,EAAC,kBAAkB,EAAgD,oBAAiB;AAEhG,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAyBrE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAA8B,wBAAwB,CAAC,EACrD,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,EACL,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,SAAS,EACT,aAAa,EACd,EAAE;IACD,WAAW,EAAE,kBAAkB,CAAC;IAChC,aAAa,EAAE,OAAO,CAAC;IACvB,kBAAkB,EAAE,mBAAmB,GAAG,cAAc,CAAC;IACzD,iBAAiB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACzC,aAAa,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACvC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,oBAAoB,EAAE,oBAAoB,EAAE,GAAG,SAAS,CAAC;IACzD,KAAK,EAAE,OAAO,CAAC;IACf,uBAAuB,EAAE,OAAO,CAAC;IACjC,oBAAoB,EAAE,OAAO,CAAC;IAC9B,gBAAgB,EAAE,KAAK,GAAG,IAAI,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,OAAO,CAAC,qBAAqB,EAAE,GAAG,IAAI,CAAC,CAgE1C;AAuJD;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,cAAc,EAAE,kBAAkB,EAClC,sBAAsB,EAAE,sBAAsB,EAAE,EAChD,qBAAqB,EAAE,OAAO,EAC9B,cAAc,EAAE,MAAM,GAAG,IAAI,GAC5B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAiD3C;AAuuCD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,kBAAkB,GAAG,IAAI,EACtC,aAAa,CAAC,EAAE,MAAM,GACrB,gBAAgB,GAAG,IAAI,CA+BzB"}
|