@loaders.gl/tile-converter 3.2.12 → 3.3.0-alpha.10
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/3d-tiles-attributes-worker.d.ts +3 -3
- package/dist/3d-tiles-attributes-worker.d.ts.map +1 -1
- package/dist/3d-tiles-attributes-worker.js +2 -3
- package/dist/3d-tiles-attributes-worker.js.map +3 -3
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +8 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +57 -43
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +5 -5
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +21 -17
- package/dist/converter-cli.js +43 -8
- package/dist/converter.min.js +24 -21
- package/dist/deps-installer/deps-installer.d.ts +5 -1
- package/dist/deps-installer/deps-installer.d.ts.map +1 -1
- package/dist/deps-installer/deps-installer.js +29 -1
- package/dist/dist.min.js +58405 -61237
- package/dist/es5/3d-tiles-attributes-worker.js +4 -7
- package/dist/es5/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +125 -210
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +53 -85
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -8
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +0 -5
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js +0 -6
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -1
- package/dist/es5/bundle.js +0 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/constants.js.map +1 -1
- package/dist/es5/converter-cli.js +50 -60
- package/dist/es5/converter-cli.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +73 -28
- package/dist/es5/deps-installer/deps-installer.js.map +1 -1
- package/dist/es5/i3s-attributes-worker.js +3 -6
- package/dist/es5/i3s-attributes-worker.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +124 -0
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js +2 -19
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +0 -11
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/feature-attributes.js +184 -0
- package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +60 -51
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +516 -356
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js +57 -43
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-debug.js +4 -23
- package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-index-document.js +507 -0
- package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/node-pages.js +462 -208
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +722 -1153
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/geometry-definitions.js +107 -0
- package/dist/es5/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
- package/dist/es5/i3s-converter/json-templates/layers.js +2 -107
- package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/metadata.js +0 -2
- package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/node.js +2 -12
- package/dist/es5/i3s-converter/json-templates/node.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/scene-server.js +0 -2
- package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/shared-resources.js +9 -32
- package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/store.js.map +1 -1
- package/dist/es5/i3s-converter/types.js.map +1 -1
- package/dist/es5/i3s-server/app.js +0 -5
- package/dist/es5/i3s-server/app.js.map +1 -1
- package/dist/es5/i3s-server/controllers/index-controller.js +0 -16
- package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -1
- package/dist/es5/i3s-server/routes/index.js +1 -10
- package/dist/es5/i3s-server/routes/index.js.map +1 -1
- package/dist/es5/index.js +0 -3
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/utils/compress-util.js +19 -74
- package/dist/es5/lib/utils/compress-util.js.map +1 -1
- package/dist/es5/lib/utils/file-utils.js +103 -47
- package/dist/es5/lib/utils/file-utils.js.map +1 -1
- package/dist/es5/lib/utils/lod-conversion-utils.js +0 -7
- package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/es5/lib/utils/queue.js +0 -14
- package/dist/es5/lib/utils/queue.js.map +1 -1
- package/dist/es5/lib/utils/statistic-utills.js +1 -46
- package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
- package/dist/es5/lib/utils/write-queue.js +41 -82
- package/dist/es5/lib/utils/write-queue.js.map +1 -1
- package/dist/es5/pgm-loader.js +1 -8
- package/dist/es5/pgm-loader.js.map +1 -1
- package/dist/es5/workers/3d-tiles-attributes-worker.js +2 -9
- package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/es5/workers/i3s-attributes-worker.js +2 -10
- package/dist/es5/workers/i3s-attributes-worker.js.map +1 -1
- package/dist/esm/3d-tiles-attributes-worker.js +4 -2
- package/dist/esm/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +60 -77
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +29 -50
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +1 -0
- package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js +1 -4
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
- package/dist/esm/3d-tiles-converter/json-templates/tileset.js +0 -3
- package/dist/esm/3d-tiles-converter/json-templates/tileset.js.map +1 -1
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/converter-cli.js +46 -40
- package/dist/esm/converter-cli.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +30 -4
- package/dist/esm/deps-installer/deps-installer.js.map +1 -1
- package/dist/esm/i3s-attributes-worker.js +3 -1
- package/dist/esm/i3s-attributes-worker.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +113 -0
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js +5 -6
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/create-scene-server-path.js +1 -0
- package/dist/esm/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/feature-attributes.js +158 -0
- package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js +39 -33
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +295 -196
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js +59 -34
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-debug.js +3 -13
- package/dist/esm/i3s-converter/helpers/node-debug.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-index-document.js +197 -0
- package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/node-pages.js +161 -87
- package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +216 -491
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/geometry-definitions.js +89 -0
- package/dist/esm/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
- package/dist/esm/i3s-converter/json-templates/layers.js +2 -95
- package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/metadata.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/node.js +0 -4
- package/dist/esm/i3s-converter/json-templates/node.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/scene-server.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/shared-resources.js +3 -15
- package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/store.js.map +1 -1
- package/dist/esm/i3s-converter/types.js.map +1 -1
- package/dist/esm/i3s-server/app.js +0 -5
- package/dist/esm/i3s-server/app.js.map +1 -1
- package/dist/esm/i3s-server/controllers/index-controller.js +0 -5
- package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -1
- package/dist/esm/i3s-server/routes/index.js +0 -3
- package/dist/esm/i3s-server/routes/index.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/utils/compress-util.js +19 -12
- package/dist/esm/lib/utils/compress-util.js.map +1 -1
- package/dist/esm/lib/utils/file-utils.js +54 -11
- package/dist/esm/lib/utils/file-utils.js.map +1 -1
- package/dist/esm/lib/utils/lod-conversion-utils.js +2 -6
- package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/esm/lib/utils/queue.js +0 -4
- package/dist/esm/lib/utils/queue.js.map +1 -1
- package/dist/esm/lib/utils/statistic-utills.js +0 -11
- package/dist/esm/lib/utils/statistic-utills.js.map +1 -1
- package/dist/esm/lib/utils/write-queue.js +27 -38
- package/dist/esm/lib/utils/write-queue.js.map +1 -1
- package/dist/esm/pgm-loader.js +3 -1
- package/dist/esm/pgm-loader.js.map +1 -1
- package/dist/esm/workers/3d-tiles-attributes-worker.js +4 -1
- package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/esm/workers/i3s-attributes-worker.js +4 -1
- package/dist/esm/workers/i3s-attributes-worker.js.map +1 -1
- package/dist/i3s-attributes-worker.d.ts +7 -3
- package/dist/i3s-attributes-worker.d.ts.map +1 -1
- package/dist/i3s-attributes-worker.js +2 -3
- package/dist/i3s-attributes-worker.js.map +3 -3
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +11 -0
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +141 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +2 -2
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/feature-attributes.d.ts +56 -0
- package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/feature-attributes.js +216 -0
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-attributes.js +42 -17
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +18 -6
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +349 -99
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +53 -21
- package/dist/i3s-converter/helpers/node-index-document.d.ts +91 -0
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/node-index-document.js +242 -0
- package/dist/i3s-converter/helpers/node-pages.d.ts +81 -42
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-pages.js +200 -92
- package/dist/i3s-converter/i3s-converter.d.ts +52 -108
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +218 -403
- package/dist/i3s-converter/json-templates/geometry-definitions.d.ts +7 -0
- package/dist/i3s-converter/json-templates/geometry-definitions.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/geometry-definitions.js +87 -0
- package/dist/i3s-converter/json-templates/layers.d.ts +1 -30
- package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -1
- package/dist/i3s-converter/json-templates/layers.js +2 -86
- package/dist/i3s-converter/json-templates/shared-resources.js +3 -3
- package/dist/i3s-converter/types.d.ts +38 -8
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/dist/lib/utils/file-utils.d.ts +17 -1
- package/dist/lib/utils/file-utils.d.ts.map +1 -1
- package/dist/lib/utils/file-utils.js +64 -7
- package/dist/lib/utils/write-queue.d.ts +19 -3
- package/dist/lib/utils/write-queue.d.ts.map +1 -1
- package/dist/lib/utils/write-queue.js +21 -16
- package/dist/pgm-loader.d.ts.map +1 -1
- package/dist/pgm-loader.js +2 -1
- package/dist/workers/3d-tiles-attributes-worker.js +1 -1
- package/dist/workers/i3s-attributes-worker.js +1 -1
- package/package.json +18 -16
- package/src/3d-tiles-attributes-worker.ts +1 -1
- package/src/3d-tiles-converter/3d-tiles-converter.ts +71 -55
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +25 -18
- package/src/converter-cli.ts +54 -8
- package/src/deps-installer/deps-installer.ts +38 -2
- package/src/i3s-attributes-worker.ts +5 -1
- package/src/i3s-converter/helpers/batch-ids-extensions.ts +206 -0
- package/src/i3s-converter/helpers/coordinate-converter.ts +2 -2
- package/src/i3s-converter/helpers/feature-attributes.ts +247 -0
- package/src/i3s-converter/helpers/geometry-attributes.ts +46 -18
- package/src/i3s-converter/helpers/geometry-converter.ts +423 -111
- package/src/i3s-converter/helpers/gltf-attributes.ts +59 -24
- package/src/i3s-converter/helpers/node-index-document.ts +306 -0
- package/src/i3s-converter/helpers/node-pages.ts +222 -109
- package/src/i3s-converter/i3s-converter.ts +264 -487
- package/src/i3s-converter/json-templates/geometry-definitions.ts +83 -0
- package/src/i3s-converter/json-templates/layers.ts +2 -91
- package/src/i3s-converter/json-templates/shared-resources.ts +3 -3
- package/src/i3s-converter/types.ts +33 -2
- package/src/lib/utils/file-utils.ts +62 -7
- package/src/lib/utils/write-queue.ts +42 -19
- package/src/pgm-loader.ts +2 -2
- package/src/workers/3d-tiles-attributes-worker.ts +1 -1
- package/src/workers/i3s-attributes-worker.ts +2 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GLTFAccessorPostprocessed, GLTFImagePostprocessed, GLTFMeshPrimitivePostprocessed } from '@loaders.gl/gltf';
|
|
2
|
+
/**
|
|
3
|
+
* Getting batchIds from 3DTilesNext extensions.
|
|
4
|
+
* @param attributes - gltf accessors
|
|
5
|
+
* @param primitive - gltf primitive data
|
|
6
|
+
* @param images - gltf texture images
|
|
7
|
+
*/
|
|
8
|
+
export declare function handleBatchIdsExtensions(attributes: {
|
|
9
|
+
[key: string]: GLTFAccessorPostprocessed;
|
|
10
|
+
}, primitive: GLTFMeshPrimitivePostprocessed, images: GLTFImagePostprocessed[]): number[];
|
|
11
|
+
//# sourceMappingURL=batch-ids-extensions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-ids-extensions.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/batch-ids-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,8BAA8B,EAC/B,MAAM,kBAAkB,CAAC;AAS1B;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE;IACV,CAAC,GAAG,EAAE,MAAM,GAAG,yBAAyB,CAAC;CAC1C,EACD,SAAS,EAAE,8BAA8B,EACzC,MAAM,EAAE,sBAAsB,EAAE,GAC/B,MAAM,EAAE,CAwBV"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleBatchIdsExtensions = void 0;
|
|
4
|
+
const EXT_MESH_FEATURES = 'EXT_mesh_features';
|
|
5
|
+
const EXT_FEATURE_METADATA = 'EXT_feature_metadata';
|
|
6
|
+
/**
|
|
7
|
+
* Getting batchIds from 3DTilesNext extensions.
|
|
8
|
+
* @param attributes - gltf accessors
|
|
9
|
+
* @param primitive - gltf primitive data
|
|
10
|
+
* @param images - gltf texture images
|
|
11
|
+
*/
|
|
12
|
+
function handleBatchIdsExtensions(attributes, primitive, images) {
|
|
13
|
+
const extensions = primitive?.extensions;
|
|
14
|
+
if (!extensions) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
for (const [extensionName, extensionData] of Object.entries(extensions || {})) {
|
|
18
|
+
switch (extensionName) {
|
|
19
|
+
case EXT_FEATURE_METADATA:
|
|
20
|
+
return handleExtFeatureMetadataExtension(attributes, extensionData, images);
|
|
21
|
+
case EXT_MESH_FEATURES:
|
|
22
|
+
console.warn('EXT_mesh_features extension is not supported yet');
|
|
23
|
+
return [];
|
|
24
|
+
default:
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
exports.handleBatchIdsExtensions = handleBatchIdsExtensions;
|
|
31
|
+
/**
|
|
32
|
+
* Get batchIds from EXT_feature_metadata extension.
|
|
33
|
+
* Docs - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata
|
|
34
|
+
* @param attributes
|
|
35
|
+
* @param extFeatureMetadata
|
|
36
|
+
* @param textures
|
|
37
|
+
*/
|
|
38
|
+
function handleExtFeatureMetadataExtension(attributes, extFeatureMetadata, images) {
|
|
39
|
+
// Take only first extension object to get batchIds attribute name.
|
|
40
|
+
const featureIdAttribute = extFeatureMetadata?.featureIdAttributes?.[0];
|
|
41
|
+
if (featureIdAttribute?.featureIds?.attribute) {
|
|
42
|
+
const batchIdsAttribute = attributes[featureIdAttribute.featureIds.attribute];
|
|
43
|
+
return batchIdsAttribute.value;
|
|
44
|
+
}
|
|
45
|
+
if (featureIdAttribute?.featureIds?.hasOwnProperty('constant') &&
|
|
46
|
+
featureIdAttribute?.featureIds?.hasOwnProperty('divisor')) {
|
|
47
|
+
const featuresCount = attributes?.POSITIONS?.value.length / 3 || 0;
|
|
48
|
+
return generateImplicitFeatureIds(featuresCount, featureIdAttribute.featureIds.constant, featureIdAttribute.featureIds.divisor);
|
|
49
|
+
}
|
|
50
|
+
// Take only first extension object to get batchIds attribute name.
|
|
51
|
+
const featureIdTexture = extFeatureMetadata?.featureIdTextures && extFeatureMetadata?.featureIdTextures[0];
|
|
52
|
+
if (featureIdTexture) {
|
|
53
|
+
const textureAttributeIndex = featureIdTexture?.featureIds?.texture?.texCoord || 0;
|
|
54
|
+
const textCoordAttribute = `TEXCOORD_${textureAttributeIndex}`;
|
|
55
|
+
const textureCoordinates = attributes[textCoordAttribute].value;
|
|
56
|
+
return generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, images);
|
|
57
|
+
}
|
|
58
|
+
// Take only first extension texture to get batchIds from the root EXT_feature_metadata object.
|
|
59
|
+
const featureTexture = extFeatureMetadata?.featureTextures && extFeatureMetadata?.featureTextures[0];
|
|
60
|
+
/**
|
|
61
|
+
* TODO need to get batchIds from root extension
|
|
62
|
+
*/
|
|
63
|
+
if (featureTexture) {
|
|
64
|
+
console.warn("EXT_feature_metadata doesn't yet support featureTextures in primitive");
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Generates implicit feature ids
|
|
71
|
+
* Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#implicit-feature-ids
|
|
72
|
+
* @param featuresCount
|
|
73
|
+
* @param constant
|
|
74
|
+
* @param devisor
|
|
75
|
+
*/
|
|
76
|
+
function generateImplicitFeatureIds(featuresCount, constant = 0, divisor = 0) {
|
|
77
|
+
let featureIds = [];
|
|
78
|
+
if (divisor > 0) {
|
|
79
|
+
let currentValue = constant;
|
|
80
|
+
let devisorCounter = divisor;
|
|
81
|
+
for (let index = 0; index < featuresCount; index++) {
|
|
82
|
+
featureIds.push(currentValue);
|
|
83
|
+
devisorCounter -= 1;
|
|
84
|
+
if (devisorCounter === 0) {
|
|
85
|
+
currentValue++;
|
|
86
|
+
devisorCounter = divisor;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
featureIds = Array(featuresCount).fill(constant, 0, featuresCount);
|
|
92
|
+
}
|
|
93
|
+
return featureIds;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get batchIds from texture.
|
|
97
|
+
* @param primitive
|
|
98
|
+
* @param featureIdTextures
|
|
99
|
+
*/
|
|
100
|
+
function generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, images) {
|
|
101
|
+
if (!images?.length) {
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
const CHANNELS_MAP = {
|
|
105
|
+
r: 0,
|
|
106
|
+
g: 1,
|
|
107
|
+
b: 2,
|
|
108
|
+
a: 3
|
|
109
|
+
};
|
|
110
|
+
const textureIndex = featureIdTexture?.featureIds?.texture?.index;
|
|
111
|
+
const featureChannel = featureIdTexture?.featureIds?.channels;
|
|
112
|
+
if (!featureChannel || textureIndex === undefined) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
const image = images[textureIndex];
|
|
116
|
+
const batchIds = [];
|
|
117
|
+
const channels = CHANNELS_MAP[featureChannel];
|
|
118
|
+
if (!image.compressed) {
|
|
119
|
+
for (let index = 0; index < textureCoordinates.length; index += 2) {
|
|
120
|
+
const u = textureCoordinates[index];
|
|
121
|
+
const v = textureCoordinates[index + 1];
|
|
122
|
+
const tx = Math.min((emod(u) * image.width) | 0, image.width - 1);
|
|
123
|
+
const ty = Math.min((emod(v) * image.height) | 0, image.height - 1);
|
|
124
|
+
const offset = (ty * image.width + tx) * image.components + channels;
|
|
125
|
+
const batchId = new Uint8Array(image.data)[offset];
|
|
126
|
+
batchIds.push(batchId);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
console.warn(`Can't get batch Ids from ${image.mimeType} compressed texture`);
|
|
131
|
+
}
|
|
132
|
+
return batchIds;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Handle UVs if they are out of range [0,1].
|
|
136
|
+
* @param n
|
|
137
|
+
* @param m
|
|
138
|
+
*/
|
|
139
|
+
function emod(n) {
|
|
140
|
+
return ((n % 1) + 1) % 1;
|
|
141
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BoundingVolumes, FullExtent, Mbs, Obb } from '@loaders.gl/i3s';
|
|
2
2
|
import { Vector3 } from '@math.gl/core';
|
|
3
3
|
import { OrientedBoundingBox, BoundingSphere } from '@math.gl/culling';
|
|
4
|
-
import
|
|
4
|
+
import { Tile3D } from '@loaders.gl/tiles';
|
|
5
5
|
import { Geoid } from '@math.gl/geoid';
|
|
6
6
|
/**
|
|
7
7
|
* Create bounding volumes object from tile and geoid height model.
|
|
@@ -9,7 +9,7 @@ import { Geoid } from '@math.gl/geoid';
|
|
|
9
9
|
* @param geoidHeightModel
|
|
10
10
|
* @returns - Bounding volumes object
|
|
11
11
|
*/
|
|
12
|
-
export declare function createBoundingVolumes(tile:
|
|
12
|
+
export declare function createBoundingVolumes(tile: Tile3D, geoidHeightModel: Geoid): BoundingVolumes;
|
|
13
13
|
/**
|
|
14
14
|
* Generates bounding volumes from geometry positions
|
|
15
15
|
* @param cartesianPositions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinate-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/coordinate-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAE3E,OAAO,EAAsB,OAAO,EAAC,MAAM,eAAe,CAAC;AAE3D,OAAO,EACL,mBAAmB,EAGnB,cAAc,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"coordinate-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/coordinate-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAE3E,OAAO,EAAsB,OAAO,EAAC,MAAM,eAAe,CAAC;AAE3D,OAAO,EACL,mBAAmB,EAGnB,cAAc,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAErC;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,KAAK,GAAG,eAAe,CAiC5F;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC/C,kBAAkB,EAAE,YAAY,EAChC,gBAAgB,EAAE,KAAK,GACtB;IAAC,GAAG,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAC,CAoBtB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO,EAAE,CAW5E;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,cAAc,EAAE,mBAAmB,GAAG,cAAc,GACnD,UAAU,CA4BZ;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAK9C"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { FeatureTableJson } from '@loaders.gl/3d-tiles';
|
|
2
|
+
import { Attribute, AttributeStorageInfo, ESRIField, Field, PopupInfo } from '@loaders.gl/i3s';
|
|
3
|
+
/**
|
|
4
|
+
* Takes attributes from property table based on featureIds.
|
|
5
|
+
* If there is no property value for particular featureId (index) the property will be null.
|
|
6
|
+
* Example:
|
|
7
|
+
* Initial data:
|
|
8
|
+
* OBJECTID: [0, 1, 5]
|
|
9
|
+
* component: ['Windows', 'Frames', 'Wall', 'Roof', 'Skylight']
|
|
10
|
+
* Result:
|
|
11
|
+
* OBJECTID: [0, 1, 5]
|
|
12
|
+
* component: ['Windows', 'Frames', 'null']
|
|
13
|
+
* @param featureIds
|
|
14
|
+
* @param propertyTable
|
|
15
|
+
*/
|
|
16
|
+
export declare function flattenPropertyTableByFeatureIds(featureIds: number[], propertyTable: FeatureTableJson): FeatureTableJson;
|
|
17
|
+
/**
|
|
18
|
+
* Check that all attributes in propertyTable have the same length as FeatureIds.
|
|
19
|
+
* If there are differencies between lengths we should flatten property table based on exiesting featureIds.
|
|
20
|
+
* @param featureIds
|
|
21
|
+
* @param propertyTable
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
export declare function checkPropertiesLength(featureIds: number[], propertyTable: FeatureTableJson): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
|
|
27
|
+
* @param key - attribute's key
|
|
28
|
+
* @param attribute - attribute's type in propertyTable
|
|
29
|
+
*/
|
|
30
|
+
export declare function getAttributeType(key: string, attribute: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Generate storage attribute for map segmentation.
|
|
33
|
+
* @param attributeIndex - order index of attribute (f_0, f_1 ...).
|
|
34
|
+
* @param key - attribute key from propertyTable.
|
|
35
|
+
* @param attributeType - attribute type.
|
|
36
|
+
* @return Updated storageAttribute.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createdStorageAttribute(attributeIndex: number, key: string, attributeType: Attribute): AttributeStorageInfo;
|
|
39
|
+
/**
|
|
40
|
+
* Find and return attribute type based on key form propertyTable.
|
|
41
|
+
* @param attributeType
|
|
42
|
+
*/
|
|
43
|
+
export declare function getFieldAttributeType(attributeType: Attribute): ESRIField;
|
|
44
|
+
/**
|
|
45
|
+
* Setup field attribute for map segmentation.
|
|
46
|
+
* @param key - attribute for map segmentation.
|
|
47
|
+
* @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').
|
|
48
|
+
*/
|
|
49
|
+
export declare function createFieldAttribute(key: string, fieldAttributeType: ESRIField): Field;
|
|
50
|
+
/**
|
|
51
|
+
* Generate popup info to show metadata on the map.
|
|
52
|
+
* @param propertyTable - table data with OBJECTID.
|
|
53
|
+
* @return data for correct rendering of popup.
|
|
54
|
+
*/
|
|
55
|
+
export declare function createPopupInfo(propertyTable: FeatureTableJson): PopupInfo;
|
|
56
|
+
//# sourceMappingURL=feature-attributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature-attributes.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/feature-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,SAAS,EACT,KAAK,EAEL,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;;;GAYG;AACH,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,MAAM,EAAE,EACpB,aAAa,EAAE,gBAAgB,GAC9B,gBAAgB,CAQlB;AAkBD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,EAAE,EACpB,aAAa,EAAE,gBAAgB,GAC9B,OAAO,CAUT;AAUD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAUvE;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,MAAM,EACtB,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,SAAS,GACvB,oBAAoB,CA0BtB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,SAAS,GAAG,SAAS,CAazE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,kBAAkB,EAAE,SAAS,GAAG,KAAK,CAMtF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,aAAa,EAAE,gBAAgB,GAAG,SAAS,CA8B1E"}
|
|
@@ -0,0 +1,216 @@
|
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry-attributes.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAE,mBAAmB,EAA+B,MAAM,UAAU,CAAC;AAMpG;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,mBAAmB,GAAG,kBAAkB,
|
|
1
|
+
{"version":3,"file":"geometry-attributes.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAE,mBAAmB,EAA+B,MAAM,UAAU,CAAC;AAMpG;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,mBAAmB,GAAG,kBAAkB,CAyBtF"}
|
|
@@ -10,7 +10,7 @@ const POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;
|
|
|
10
10
|
* @returns attirbutes with featureCount, featureIds and changed faceRange.
|
|
11
11
|
*/
|
|
12
12
|
function generateAttributes(attributes) {
|
|
13
|
-
const { positions, normals, texCoords, colors, featureIndices } = attributes;
|
|
13
|
+
const { positions, normals, texCoords, colors, uvRegions, featureIndices } = attributes;
|
|
14
14
|
const triangleCount = positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
|
|
15
15
|
if (!featureIndices.length) {
|
|
16
16
|
return {
|
|
@@ -20,7 +20,8 @@ function generateAttributes(attributes) {
|
|
|
20
20
|
positions,
|
|
21
21
|
normals,
|
|
22
22
|
texCoords,
|
|
23
|
-
colors
|
|
23
|
+
colors,
|
|
24
|
+
uvRegions
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
27
|
const data = calculateFaceRangesAndFeaturesCount(featureIndices);
|
|
@@ -38,62 +39,83 @@ exports.generateAttributes = generateAttributes;
|
|
|
38
39
|
function calculateFaceRangesAndFeaturesCount(featureIndices) {
|
|
39
40
|
let rangeIndex = 1;
|
|
40
41
|
let featureIndex = 1;
|
|
41
|
-
let currentFeatureId = featureIndices
|
|
42
|
+
let currentFeatureId = getFrequentValue(featureIndices.slice(0, VALUES_PER_VERTEX));
|
|
42
43
|
const faceRangeList = [];
|
|
43
44
|
const featureIds = [];
|
|
44
45
|
const uniqueFeatureIds = [currentFeatureId];
|
|
45
46
|
faceRangeList[0] = 0;
|
|
46
47
|
featureIds[0] = currentFeatureId;
|
|
47
|
-
for (let index =
|
|
48
|
-
|
|
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) {
|
|
49
51
|
faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;
|
|
50
52
|
faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;
|
|
51
|
-
featureIds[featureIndex] =
|
|
52
|
-
if (!uniqueFeatureIds.includes(
|
|
53
|
-
uniqueFeatureIds.push(
|
|
53
|
+
featureIds[featureIndex] = newFeatureId;
|
|
54
|
+
if (!uniqueFeatureIds.includes(newFeatureId)) {
|
|
55
|
+
uniqueFeatureIds.push(newFeatureId);
|
|
54
56
|
}
|
|
55
57
|
rangeIndex += 2;
|
|
56
58
|
featureIndex += 1;
|
|
57
59
|
}
|
|
58
|
-
currentFeatureId =
|
|
60
|
+
currentFeatureId = newFeatureId;
|
|
59
61
|
}
|
|
60
62
|
faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;
|
|
61
63
|
const faceRange = new Uint32Array(faceRangeList);
|
|
62
64
|
const featureCount = uniqueFeatureIds.length;
|
|
63
65
|
return { faceRange, featureCount, featureIds };
|
|
64
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
|
+
}
|
|
65
85
|
/**
|
|
66
86
|
* Generate list of attribute object grouped by feature ids.
|
|
67
87
|
* @param attributes
|
|
68
88
|
* @returns sorted list of attribute objects.
|
|
69
89
|
*/
|
|
70
90
|
function makeAttributeObjects(attributes) {
|
|
71
|
-
const { featureIds, positions, normals, colors, texCoords, faceRange = new Uint32Array(0) } = attributes;
|
|
91
|
+
const { featureIds, positions, normals, colors, uvRegions, texCoords, faceRange = new Uint32Array(0) } = attributes;
|
|
72
92
|
const groupedData = [];
|
|
73
93
|
let positionsList = new Float32Array(positions);
|
|
74
94
|
let normalsList = new Float32Array(normals);
|
|
75
95
|
let colorsList = new Uint8Array(colors);
|
|
76
96
|
let texCoordsList = new Float32Array(texCoords);
|
|
77
|
-
let
|
|
97
|
+
let uvRegionsList = new Uint16Array(uvRegions);
|
|
78
98
|
for (let index = 0; index < featureIds.length; index++) {
|
|
79
|
-
const startIndex = faceRange[index
|
|
80
|
-
const endIndex = faceRange[index
|
|
99
|
+
const startIndex = faceRange[index * 2];
|
|
100
|
+
const endIndex = faceRange[index * 2 + 1];
|
|
81
101
|
const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);
|
|
82
102
|
const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);
|
|
83
103
|
const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);
|
|
104
|
+
const uvRegionsCount = getSliceAttributeCount('uvRegions', startIndex, endIndex);
|
|
84
105
|
const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);
|
|
85
106
|
groupedData.push({
|
|
86
107
|
featureId: featureIds[index],
|
|
87
108
|
positions: positionsList.slice(0, positionsCount),
|
|
88
109
|
normals: normalsList.slice(0, normalsCount),
|
|
89
110
|
colors: colorsList.slice(0, colorsCount),
|
|
111
|
+
uvRegions: uvRegionsList.slice(0, uvRegionsCount),
|
|
90
112
|
texCoords: texCoordsList.slice(0, texCoordsCount)
|
|
91
113
|
});
|
|
92
114
|
positionsList = positionsList.slice(positionsCount);
|
|
93
115
|
normalsList = normalsList.slice(normalsCount);
|
|
94
116
|
colorsList = colorsList.slice(colorsCount);
|
|
117
|
+
uvRegionsList = uvRegionsList.slice(uvRegionsCount);
|
|
95
118
|
texCoordsList = texCoordsList.slice(texCoordsCount);
|
|
96
|
-
faceRangeIndex += 1;
|
|
97
119
|
}
|
|
98
120
|
return groupedData.sort((first, second) => first.featureId - second.featureId);
|
|
99
121
|
}
|
|
@@ -105,7 +127,7 @@ function makeAttributeObjects(attributes) {
|
|
|
105
127
|
* @returns sliced count
|
|
106
128
|
*/
|
|
107
129
|
function getSliceAttributeCount(attributeName, startIndex, endIndex) {
|
|
108
|
-
const
|
|
130
|
+
const itemsPerVertex4 = 4;
|
|
109
131
|
const texCoordsPerVertex = 2;
|
|
110
132
|
const trianglesCount = endIndex - startIndex + 1;
|
|
111
133
|
const vertexCount = trianglesCount * 3;
|
|
@@ -114,7 +136,8 @@ function getSliceAttributeCount(attributeName, startIndex, endIndex) {
|
|
|
114
136
|
case 'normals':
|
|
115
137
|
return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;
|
|
116
138
|
case 'colors':
|
|
117
|
-
|
|
139
|
+
case 'uvRegions':
|
|
140
|
+
return vertexCount * itemsPerVertex4;
|
|
118
141
|
case 'texCoords':
|
|
119
142
|
return vertexCount * texCoordsPerVertex;
|
|
120
143
|
default:
|
|
@@ -154,6 +177,7 @@ function groupAttributesAndRangesByFeatureId(unifiedObjects, featureCount) {
|
|
|
154
177
|
let positions = new Float32Array(firstAttributeObject.positions);
|
|
155
178
|
let normals = new Float32Array(firstAttributeObject.normals);
|
|
156
179
|
let colors = new Uint8Array(firstAttributeObject.colors);
|
|
180
|
+
let uvRegions = new Uint16Array(firstAttributeObject.uvRegions);
|
|
157
181
|
let texCoords = new Float32Array(firstAttributeObject.texCoords);
|
|
158
182
|
const range = [0];
|
|
159
183
|
let objIndex = 0;
|
|
@@ -164,6 +188,7 @@ function groupAttributesAndRangesByFeatureId(unifiedObjects, featureCount) {
|
|
|
164
188
|
positions = (0, loader_utils_1.concatenateTypedArrays)(positions, currentAttributesObject.positions);
|
|
165
189
|
normals = (0, loader_utils_1.concatenateTypedArrays)(normals, currentAttributesObject.normals);
|
|
166
190
|
colors = (0, loader_utils_1.concatenateTypedArrays)(colors, currentAttributesObject.colors);
|
|
191
|
+
uvRegions = (0, loader_utils_1.concatenateTypedArrays)(uvRegions, currentAttributesObject.uvRegions);
|
|
167
192
|
texCoords = (0, loader_utils_1.concatenateTypedArrays)(texCoords, currentAttributesObject.texCoords);
|
|
168
193
|
const groupedObject = unifiedObjects[objIndex];
|
|
169
194
|
range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);
|
|
@@ -173,5 +198,5 @@ function groupAttributesAndRangesByFeatureId(unifiedObjects, featureCount) {
|
|
|
173
198
|
}
|
|
174
199
|
range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);
|
|
175
200
|
const faceRange = new Uint32Array(range);
|
|
176
|
-
return { faceRange, featureIds, positions, normals, colors, texCoords, featureCount };
|
|
201
|
+
return { faceRange, featureIds, positions, normals, colors, uvRegions, texCoords, featureCount };
|
|
177
202
|
}
|
|
@@ -1,29 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { B3DMContent, FeatureTableJson } from '@loaders.gl/3d-tiles';
|
|
2
|
+
import { ConvertedAttributes, I3SConvertedResources, I3SMaterialWithTexture } from '../types';
|
|
3
3
|
import { AttributeStorageInfo } from '@loaders.gl/i3s';
|
|
4
4
|
import { Geoid } from '@math.gl/geoid';
|
|
5
|
+
/** Usage of worker here brings more overhead than advantage */
|
|
5
6
|
import { B3DMAttributesData } from '../../i3s-attributes-worker';
|
|
6
7
|
/**
|
|
7
8
|
* Convert binary data from b3dm file to i3s resources
|
|
8
9
|
*
|
|
9
10
|
* @param tileContent - 3d tile content
|
|
10
|
-
* @param
|
|
11
|
+
* @param addNodeToNodePage - function to add new node to node pages
|
|
12
|
+
* @param propertyTable - batch table (corresponding to feature attributes data)
|
|
11
13
|
* @param featuresHashArray - hash array of features that is needed to not to mix up same features in parent and child nodes
|
|
12
14
|
* @param attributeStorageInfo - attributes metadata from 3DSceneLayer json
|
|
13
15
|
* @param draco - is converter should create draco compressed geometry
|
|
14
16
|
* @param generateBoundingVolumes - is converter should create accurate bounding voulmes from geometry attributes
|
|
17
|
+
* @param shouldMergeMaterials - Try to merge similar materials to be able to merge meshes into one node
|
|
15
18
|
* @param geoidHeightModel - model to convert elevation from elipsoidal to geoid
|
|
19
|
+
* @param workerSource - source code of used workers
|
|
16
20
|
* @returns Array of node resources to create one or more i3s nodes
|
|
17
21
|
*/
|
|
18
|
-
export default function convertB3dmToI3sGeometry(tileContent: B3DMContent,
|
|
22
|
+
export default function convertB3dmToI3sGeometry(tileContent: B3DMContent, addNodeToNodePage: () => Promise<number>, propertyTable: FeatureTableJson | null, featuresHashArray: string[], attributeStorageInfo: AttributeStorageInfo[] | undefined, draco: boolean, generateBoundingVolumes: boolean, shouldMergeMaterials: boolean, geoidHeightModel: Geoid, workerSource: {
|
|
19
23
|
[key: string]: string;
|
|
20
24
|
}): Promise<I3SConvertedResources[] | null>;
|
|
21
25
|
/**
|
|
22
26
|
* Convert attributes from the gltf nodes tree to i3s plain geometry
|
|
23
|
-
* @param
|
|
27
|
+
* @param attributesData - geometry attributes from gltf
|
|
28
|
+
* @param materialAndTextureList - array of data about materials and textures of the content
|
|
24
29
|
* @param useCartesianPositions - convert positions to absolute cartesian coordinates instead of cartographic offsets.
|
|
25
30
|
* Cartesian coordinates will be required for creating bounding voulmest from geometry positions
|
|
26
31
|
* @returns map of converted geometry attributes
|
|
27
32
|
*/
|
|
28
|
-
export declare function convertAttributes(attributesData: B3DMAttributesData, useCartesianPositions: boolean): Promise<Map<string, ConvertedAttributes>>;
|
|
33
|
+
export declare function convertAttributes(attributesData: B3DMAttributesData, materialAndTextureList: I3SMaterialWithTexture[], useCartesianPositions: boolean): Promise<Map<string, ConvertedAttributes>>;
|
|
34
|
+
/**
|
|
35
|
+
* Find property table in tile
|
|
36
|
+
* For example it can be batchTable for b3dm files or property table in gLTF extension.
|
|
37
|
+
* @param sourceTile
|
|
38
|
+
* @return batch table from b3dm / feature properties from EXT_FEATURE_METADATA
|
|
39
|
+
*/
|
|
40
|
+
export declare function getPropertyTable(tileContent: B3DMContent): FeatureTableJson | null;
|
|
29
41
|
//# sourceMappingURL=geometry-converter.d.ts.map
|