@loaders.gl/tile-converter 4.0.0-alpha.19 → 4.0.0-alpha.21
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/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -1
- package/dist/converter-cli.js +10 -2
- package/dist/converter.min.js +172 -103
- package/dist/dist.min.js +33357 -33374
- package/dist/es5/constants.js +5 -1
- package/dist/es5/constants.js.map +1 -1
- package/dist/es5/converter-cli.js +7 -2
- package/dist/es5/converter-cli.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +1 -1
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +21 -8
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +7 -6
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +67 -59
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +38 -9
- package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +55 -13
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-converter/types.js +11 -11
- package/dist/es5/i3s-converter/types.js.map +1 -1
- package/dist/es5/i3s-server/controllers/slpk-controller.js +2 -2
- package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -1
- package/dist/es5/index.js +0 -7
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/es5/slpk-extractor/slpk-extractor.js +10 -11
- package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -1
- package/dist/esm/constants.js +2 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/converter-cli.js +7 -2
- package/dist/esm/converter-cli.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +1 -1
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +18 -6
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js +7 -6
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +28 -20
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +28 -9
- package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +39 -9
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/i3s-converter/types.js +9 -9
- package/dist/esm/i3s-converter/types.js.map +1 -1
- package/dist/esm/i3s-server/bin/i3s-server.min.js +69 -69
- package/dist/esm/i3s-server/controllers/slpk-controller.js +2 -2
- package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/esm/slpk-extractor/slpk-extractor.js +3 -4
- package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +11 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +33 -13
- package/dist/i3s-converter/helpers/geometry-attributes.js +7 -6
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +6 -3
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +42 -35
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +2 -2
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +39 -14
- package/dist/i3s-converter/i3s-converter.d.ts +2 -0
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +40 -10
- package/dist/i3s-converter/types.d.ts +4 -2
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/dist/i3s-converter/types.js +11 -11
- package/dist/i3s-server/controllers/slpk-controller.js +2 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/slpk-extractor/slpk-extractor.d.ts +1 -1
- package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -1
- package/dist/slpk-extractor/slpk-extractor.js +6 -7
- package/dist/slpk-extractor.min.js +42 -42
- package/package.json +15 -14
- package/src/constants.ts +3 -0
- package/src/converter-cli.ts +9 -2
- package/src/i3s-converter/helpers/batch-ids-extensions.ts +39 -12
- package/src/i3s-converter/helpers/geometry-attributes.ts +15 -8
- package/src/i3s-converter/helpers/geometry-converter.ts +66 -35
- package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +48 -18
- package/src/i3s-converter/i3s-converter.ts +54 -12
- package/src/i3s-converter/types.ts +4 -2
- package/src/i3s-server/controllers/slpk-controller.ts +2 -2
- package/src/index.ts +0 -1
- package/src/slpk-extractor/slpk-extractor.ts +3 -4
- package/dist/es5/slpk-extractor/helpers/file-handle-provider.js +0 -214
- package/dist/es5/slpk-extractor/helpers/file-handle-provider.js.map +0 -1
- package/dist/es5/slpk-extractor/helpers/fs-promises.js +0 -77
- package/dist/es5/slpk-extractor/helpers/fs-promises.js.map +0 -1
- package/dist/esm/slpk-extractor/helpers/file-handle-provider.js +0 -54
- package/dist/esm/slpk-extractor/helpers/file-handle-provider.js.map +0 -1
- package/dist/esm/slpk-extractor/helpers/fs-promises.js +0 -32
- package/dist/esm/slpk-extractor/helpers/fs-promises.js.map +0 -1
- package/dist/slpk-extractor/helpers/file-handle-provider.d.ts +0 -51
- package/dist/slpk-extractor/helpers/file-handle-provider.d.ts.map +0 -1
- package/dist/slpk-extractor/helpers/file-handle-provider.js +0 -86
- package/dist/slpk-extractor/helpers/fs-promises.d.ts +0 -38
- package/dist/slpk-extractor/helpers/fs-promises.d.ts.map +0 -1
- package/dist/slpk-extractor/helpers/fs-promises.js +0 -51
- package/src/slpk-extractor/helpers/file-handle-provider.ts +0 -109
- package/src/slpk-extractor/helpers/fs-promises.ts +0 -66
|
@@ -8,10 +8,11 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
8
8
|
import { generateAttributes } from './geometry-attributes';
|
|
9
9
|
import { createBoundingVolumesFromGeometry } from './coordinate-converter';
|
|
10
10
|
import { prepareDataForAttributesConversion } from './gltf-attributes';
|
|
11
|
-
import { handleBatchIdsExtensions } from './batch-ids-extensions';
|
|
11
|
+
import { getTextureByMetadataClass, handleBatchIdsExtensions } from './batch-ids-extensions';
|
|
12
12
|
import { checkPropertiesLength, flattenPropertyTableByFeatureIds } from './feature-attributes';
|
|
13
13
|
import { GL } from '@loaders.gl/math';
|
|
14
14
|
import { generateSyntheticIndices } from '../../lib/utils/geometry-utils';
|
|
15
|
+
import { EXT_FEATURE_METADATA, EXT_MESH_FEATURES } from '../../constants';
|
|
15
16
|
const DEFAULT_ROUGHNESS_FACTOR = 1;
|
|
16
17
|
const DEFAULT_METALLIC_FACTOR = 1;
|
|
17
18
|
const VALUES_PER_VERTEX = 3;
|
|
@@ -22,15 +23,14 @@ const SHORT_INT_TYPE = 'Int32';
|
|
|
22
23
|
const DOUBLE_TYPE = 'Float64';
|
|
23
24
|
const OBJECT_ID_TYPE = 'Oid32';
|
|
24
25
|
const BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BATCHID'];
|
|
25
|
-
const EXT_FEATURE_METADATA = 'EXT_feature_metadata';
|
|
26
|
-
const EXT_MESH_FEATURES = 'EXT_mesh_features';
|
|
27
26
|
let scratchVector = new Vector3();
|
|
28
|
-
export default async function convertB3dmToI3sGeometry(tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, libraries) {
|
|
27
|
+
export default async function convertB3dmToI3sGeometry(tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, libraries, metadataClass) {
|
|
29
28
|
var _tileContent$gltf;
|
|
30
29
|
const useCartesianPositions = generateBoundingVolumes;
|
|
31
30
|
const materialAndTextureList = await convertMaterials((_tileContent$gltf = tileContent.gltf) === null || _tileContent$gltf === void 0 ? void 0 : _tileContent$gltf.materials, shouldMergeMaterials);
|
|
32
31
|
const dataForAttributesConversion = prepareDataForAttributesConversion(tileContent, tileTransform, tileBoundingVolume);
|
|
33
|
-
const
|
|
32
|
+
const featureTexture = getTextureByMetadataClass(tileContent, metadataClass);
|
|
33
|
+
const convertedAttributesMap = await convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions, featureTexture);
|
|
34
34
|
if (generateBoundingVolumes) {
|
|
35
35
|
_generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel);
|
|
36
36
|
}
|
|
@@ -141,7 +141,7 @@ async function _makeNodeResources(_ref) {
|
|
|
141
141
|
boundingVolumes
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
|
-
export async function convertAttributes(attributesData, materialAndTextureList, useCartesianPositions) {
|
|
144
|
+
export async function convertAttributes(attributesData, materialAndTextureList, useCartesianPositions, featureTexture) {
|
|
145
145
|
const {
|
|
146
146
|
nodes,
|
|
147
147
|
images,
|
|
@@ -165,7 +165,7 @@ export async function convertAttributes(attributesData, materialAndTextureList,
|
|
|
165
165
|
attributesMap.set(mergedMaterial.originalMaterialId, attributes);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions);
|
|
168
|
+
convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, undefined, featureTexture);
|
|
169
169
|
for (const attrKey of attributesMap.keys()) {
|
|
170
170
|
const attributes = attributesMap.get(attrKey);
|
|
171
171
|
if (!attributes) {
|
|
@@ -184,9 +184,10 @@ export async function convertAttributes(attributesData, materialAndTextureList,
|
|
|
184
184
|
}
|
|
185
185
|
function convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions) {
|
|
186
186
|
let matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
187
|
+
let featureTexture = arguments.length > 7 ? arguments[7] : undefined;
|
|
187
188
|
if (nodes) {
|
|
188
189
|
for (const node of nodes) {
|
|
189
|
-
convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix);
|
|
190
|
+
convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix, featureTexture);
|
|
190
191
|
}
|
|
191
192
|
}
|
|
192
193
|
}
|
|
@@ -214,16 +215,18 @@ function getCompositeTransformationMatrix(node, matrix) {
|
|
|
214
215
|
}
|
|
215
216
|
function convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions) {
|
|
216
217
|
let matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
218
|
+
let featureTexture = arguments.length > 7 ? arguments[7] : undefined;
|
|
217
219
|
const transformationMatrix = getCompositeTransformationMatrix(node, matrix);
|
|
218
220
|
const mesh = node.mesh;
|
|
219
221
|
if (mesh) {
|
|
220
|
-
convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
|
|
222
|
+
convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix, featureTexture);
|
|
221
223
|
}
|
|
222
|
-
convertNodes(node.children || [], images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
|
|
224
|
+
convertNodes(node.children || [], images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix, featureTexture);
|
|
223
225
|
}
|
|
224
226
|
function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap) {
|
|
225
227
|
let useCartesianPositions = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
226
228
|
let matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
229
|
+
let featureTexture = arguments.length > 7 ? arguments[7] : undefined;
|
|
227
230
|
for (const primitive of mesh.primitives) {
|
|
228
231
|
let outputAttributes = null;
|
|
229
232
|
let materialUvRegion;
|
|
@@ -271,7 +274,7 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
|
|
|
271
274
|
outputAttributes.uvRegions = concatenateTypedArrays(outputAttributes.uvRegions, createUvRegion(materialUvRegion, indices));
|
|
272
275
|
}
|
|
273
276
|
outputAttributes.featureIndicesGroups = outputAttributes.featureIndicesGroups || [];
|
|
274
|
-
outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images), indices));
|
|
277
|
+
outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images, featureTexture), indices));
|
|
275
278
|
}
|
|
276
279
|
}
|
|
277
280
|
function normalizeIndices(primitive) {
|
|
@@ -401,8 +404,8 @@ function flattenBatchIds(batchedIds, indices) {
|
|
|
401
404
|
}
|
|
402
405
|
return newBatchIds;
|
|
403
406
|
}
|
|
404
|
-
function getBatchIds(attributes, primitive, images) {
|
|
405
|
-
const batchIds = handleBatchIdsExtensions(attributes, primitive, images);
|
|
407
|
+
function getBatchIds(attributes, primitive, images, featureTexture) {
|
|
408
|
+
const batchIds = handleBatchIdsExtensions(attributes, primitive, images, featureTexture);
|
|
406
409
|
if (batchIds.length) {
|
|
407
410
|
return batchIds;
|
|
408
411
|
}
|
|
@@ -829,7 +832,7 @@ function generateFeatureIndexAttribute(featureIndex, faceRange) {
|
|
|
829
832
|
}
|
|
830
833
|
return orderedFeatureIndices;
|
|
831
834
|
}
|
|
832
|
-
export function getPropertyTable(tileContent) {
|
|
835
|
+
export function getPropertyTable(tileContent, metadataClass) {
|
|
833
836
|
if (!tileContent) {
|
|
834
837
|
return null;
|
|
835
838
|
}
|
|
@@ -849,7 +852,7 @@ export function getPropertyTable(tileContent) {
|
|
|
849
852
|
}
|
|
850
853
|
case EXT_FEATURE_METADATA:
|
|
851
854
|
{
|
|
852
|
-
return getPropertyTableFromExtFeatureMetadata(extension);
|
|
855
|
+
return getPropertyTableFromExtFeatureMetadata(extension, metadataClass);
|
|
853
856
|
}
|
|
854
857
|
default:
|
|
855
858
|
return null;
|
|
@@ -885,7 +888,7 @@ function getPropertyTableExtension(tileContent) {
|
|
|
885
888
|
extension
|
|
886
889
|
};
|
|
887
890
|
}
|
|
888
|
-
function getPropertyTableFromExtFeatureMetadata(extension) {
|
|
891
|
+
function getPropertyTableFromExtFeatureMetadata(extension, metadataClass) {
|
|
889
892
|
if (extension !== null && extension !== void 0 && extension.featureTables) {
|
|
890
893
|
var _Object$keys;
|
|
891
894
|
const firstFeatureTableName = (_Object$keys = Object.keys(extension.featureTables)) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0];
|
|
@@ -899,10 +902,15 @@ function getPropertyTableFromExtFeatureMetadata(extension) {
|
|
|
899
902
|
}
|
|
900
903
|
}
|
|
901
904
|
if (extension !== null && extension !== void 0 && extension.featureTextures) {
|
|
902
|
-
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
|
|
905
|
+
let featureTexture;
|
|
906
|
+
for (const textureKey in extension.featureTextures) {
|
|
907
|
+
const texture = extension.featureTextures[textureKey];
|
|
908
|
+
if (texture.class === metadataClass) {
|
|
909
|
+
featureTexture = textureKey;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
if (typeof featureTexture === 'string') {
|
|
913
|
+
const featureTable = extension === null || extension === void 0 ? void 0 : extension.featureTextures[featureTexture];
|
|
906
914
|
const propertyTable = {};
|
|
907
915
|
for (const propertyName in featureTable.properties) {
|
|
908
916
|
propertyTable[propertyName] = featureTable.properties[propertyName].data;
|