@loaders.gl/tile-converter 4.0.0-alpha.4 → 4.0.0-alpha.6
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 +28 -0
- package/dist/3d-tiles-attributes-worker.d.ts.map +1 -0
- package/dist/3d-tiles-attributes-worker.js +3 -0
- package/dist/3d-tiles-attributes-worker.js.map +7 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +90 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.js +273 -231
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +79 -18
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +269 -236
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +4 -7
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +22 -9
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +9 -0
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/texture-atlas.js +47 -28
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts +15 -0
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +1 -0
- package/dist/3d-tiles-converter/json-templates/tileset.js +42 -36
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +2 -2
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +4 -0
- package/dist/converter-cli.d.ts +2 -0
- package/dist/converter-cli.d.ts.map +1 -0
- package/dist/converter-cli.js +280 -0
- package/dist/converter.min.js +186 -190
- package/dist/deps-installer/deps-installer.d.ts +11 -3
- package/dist/deps-installer/deps-installer.d.ts.map +1 -0
- package/dist/deps-installer/deps-installer.js +60 -23
- package/dist/dist.min.js +63496 -0
- package/dist/es5/3d-tiles-attributes-worker.js +25 -0
- package/dist/es5/3d-tiles-attributes-worker.js.map +1 -0
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +470 -0
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -0
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +301 -0
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -0
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +18 -0
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -0
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +33 -0
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -0
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js +61 -0
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -0
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/constants.js +9 -0
- package/dist/es5/constants.js.map +1 -0
- package/dist/es5/converter-cli.js +289 -0
- package/dist/es5/converter-cli.js.map +1 -0
- package/dist/es5/deps-installer/deps-installer.js +123 -0
- package/dist/es5/deps-installer/deps-installer.js.map +1 -0
- package/dist/es5/i3s-attributes-worker.js +25 -0
- package/dist/es5/i3s-attributes-worker.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +116 -0
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js +90 -0
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +41 -0
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/feature-attributes.js +174 -0
- package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +213 -0
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +1173 -0
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js +83 -0
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/node-debug.js +76 -0
- package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/node-index-document.js +492 -0
- package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/node-pages.js +519 -0
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -0
- package/dist/es5/i3s-converter/i3s-converter.js +1519 -0
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -0
- 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 +163 -0
- package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -0
- package/dist/es5/i3s-converter/json-templates/metadata.js +31 -0
- package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -0
- package/dist/es5/i3s-converter/json-templates/node.js +99 -0
- package/dist/es5/i3s-converter/json-templates/node.js.map +1 -0
- package/dist/es5/i3s-converter/json-templates/scene-server.js +39 -0
- package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -0
- package/dist/es5/i3s-converter/json-templates/shared-resources.js +173 -0
- package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -0
- package/dist/es5/i3s-converter/json-templates/store.js +107 -0
- package/dist/es5/i3s-converter/json-templates/store.js.map +1 -0
- package/dist/es5/i3s-converter/types.js +2 -0
- package/dist/es5/i3s-converter/types.js.map +1 -0
- package/dist/es5/i3s-server/app.js +18 -0
- package/dist/es5/i3s-server/app.js.map +1 -0
- package/dist/es5/i3s-server/controllers/index-controller.js +55 -0
- package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -0
- package/dist/es5/i3s-server/routes/index.js +37 -0
- package/dist/es5/i3s-server/routes/index.js.map +1 -0
- package/dist/es5/index.js +21 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/utils/compress-util.js +346 -0
- package/dist/es5/lib/utils/compress-util.js.map +1 -0
- package/dist/es5/lib/utils/file-utils.js +208 -0
- package/dist/es5/lib/utils/file-utils.js.map +1 -0
- package/dist/es5/lib/utils/lod-conversion-utils.js +44 -0
- package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -0
- package/dist/es5/lib/utils/queue.js +47 -0
- package/dist/es5/lib/utils/queue.js.map +1 -0
- package/dist/es5/lib/utils/statistic-utills.d.ts +25 -0
- package/dist/es5/lib/utils/statistic-utills.js +147 -0
- package/dist/es5/lib/utils/statistic-utills.js.map +1 -0
- package/dist/es5/lib/utils/write-queue.js +214 -0
- package/dist/es5/lib/utils/write-queue.js.map +1 -0
- package/dist/es5/pgm-loader.js +41 -0
- package/dist/es5/pgm-loader.js.map +1 -0
- package/dist/es5/workers/3d-tiles-attributes-worker.js +28 -0
- package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -0
- package/dist/es5/workers/i3s-attributes-worker.js +30 -0
- package/dist/es5/workers/i3s-attributes-worker.js.map +1 -0
- package/dist/esm/3d-tiles-attributes-worker.js +16 -0
- package/dist/esm/3d-tiles-attributes-worker.js.map +1 -0
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +248 -0
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -0
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +224 -0
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -0
- package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +10 -0
- package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -0
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js +27 -0
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -0
- package/dist/esm/3d-tiles-converter/json-templates/tileset.js +37 -0
- package/dist/esm/3d-tiles-converter/json-templates/tileset.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/constants.js +2 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/converter-cli.js +232 -0
- package/dist/esm/converter-cli.js.map +1 -0
- package/dist/esm/deps-installer/deps-installer.js +44 -0
- package/dist/esm/deps-installer/deps-installer.js.map +1 -0
- package/dist/esm/i3s-attributes-worker.js +16 -0
- package/dist/esm/i3s-attributes-worker.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +105 -0
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js +80 -0
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/create-scene-server-path.js +16 -0
- package/dist/esm/i3s-converter/helpers/create-scene-server-path.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/feature-attributes.js +147 -0
- package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -0
- package/{src → dist/esm}/i3s-converter/helpers/geometry-attributes.js +80 -106
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +887 -0
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js +76 -0
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -0
- package/{src → dist/esm}/i3s-converter/helpers/node-debug.js +20 -41
- package/dist/esm/i3s-converter/helpers/node-debug.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/node-index-document.js +188 -0
- package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/node-pages.js +206 -0
- package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -0
- package/dist/esm/i3s-converter/i3s-converter.js +771 -0
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -0
- 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 +133 -0
- package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -0
- package/dist/esm/i3s-converter/json-templates/metadata.js +22 -0
- package/dist/esm/i3s-converter/json-templates/metadata.js.map +1 -0
- package/dist/esm/i3s-converter/json-templates/node.js +80 -0
- package/dist/esm/i3s-converter/json-templates/node.js.map +1 -0
- package/dist/esm/i3s-converter/json-templates/scene-server.js +28 -0
- package/dist/esm/i3s-converter/json-templates/scene-server.js.map +1 -0
- package/dist/esm/i3s-converter/json-templates/shared-resources.js +123 -0
- package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -0
- package/dist/esm/i3s-converter/json-templates/store.js +98 -0
- package/dist/esm/i3s-converter/json-templates/store.js.map +1 -0
- package/dist/esm/i3s-converter/types.js +2 -0
- package/dist/esm/i3s-converter/types.js.map +1 -0
- package/dist/esm/i3s-server/app.js +16 -0
- package/dist/esm/i3s-server/app.js.map +1 -0
- package/dist/esm/i3s-server/bin/www +102 -0
- package/dist/esm/i3s-server/certs/cert.pem +19 -0
- package/dist/esm/i3s-server/certs/key.pem +27 -0
- package/dist/esm/i3s-server/controllers/index-controller.js +24 -0
- package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -0
- package/dist/esm/i3s-server/routes/index.js +16 -0
- package/dist/esm/i3s-server/routes/index.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/utils/compress-util.js +168 -0
- package/dist/esm/lib/utils/compress-util.js.map +1 -0
- package/dist/esm/lib/utils/file-utils.js +87 -0
- package/dist/esm/lib/utils/file-utils.js.map +1 -0
- package/dist/esm/lib/utils/lod-conversion-utils.js +37 -0
- package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -0
- package/dist/esm/lib/utils/queue.js +15 -0
- package/dist/esm/lib/utils/queue.js.map +1 -0
- package/dist/esm/lib/utils/statistic-utills.d.ts +25 -0
- package/dist/esm/lib/utils/statistic-utills.js +62 -0
- package/dist/esm/lib/utils/statistic-utills.js.map +1 -0
- package/dist/esm/lib/utils/write-queue.js +85 -0
- package/dist/esm/lib/utils/write-queue.js.map +1 -0
- package/dist/esm/pgm-loader.js +15 -0
- package/dist/esm/pgm-loader.js.map +1 -0
- package/dist/esm/workers/3d-tiles-attributes-worker.js +8 -0
- package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -0
- package/dist/esm/workers/i3s-attributes-worker.js +7 -0
- package/dist/esm/workers/i3s-attributes-worker.js.map +1 -0
- package/dist/i3s-attributes-worker.d.ts +37 -0
- package/dist/i3s-attributes-worker.d.ts.map +1 -0
- package/dist/i3s-attributes-worker.js +9 -0
- package/dist/i3s-attributes-worker.js.map +7 -0
- 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 +41 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/coordinate-converter.js +120 -42
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +9 -0
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/create-scene-server-path.js +27 -15
- 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 +8 -0
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/geometry-attributes.js +188 -185
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +36 -35
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/geometry-converter.js +1149 -650
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts +9 -0
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/gltf-attributes.js +88 -0
- package/dist/i3s-converter/helpers/node-debug.d.ts +8 -0
- package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/node-debug.js +106 -74
- package/dist/i3s-converter/helpers/node-index-document.d.ts +95 -0
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/node-index-document.js +250 -0
- package/dist/i3s-converter/helpers/node-pages.d.ts +125 -113
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/node-pages.js +313 -133
- package/dist/i3s-converter/i3s-converter.d.ts +267 -0
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -0
- package/dist/i3s-converter/i3s-converter.js +860 -861
- 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 +70 -0
- package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/layers.js +138 -190
- package/dist/i3s-converter/json-templates/metadata.d.ts +22 -0
- package/dist/i3s-converter/json-templates/metadata.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/metadata.js +25 -22
- package/dist/i3s-converter/json-templates/node.d.ts +61 -0
- package/dist/i3s-converter/json-templates/node.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/node.js +88 -79
- package/dist/i3s-converter/json-templates/scene-server.d.ts +28 -0
- package/dist/i3s-converter/json-templates/scene-server.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/scene-server.js +31 -28
- package/dist/i3s-converter/json-templates/shared-resources.d.ts +14 -0
- package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/shared-resources.js +124 -125
- package/dist/i3s-converter/json-templates/store.d.ts +95 -0
- package/dist/i3s-converter/json-templates/store.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/store.js +100 -95
- package/dist/i3s-converter/types.d.ts +145 -0
- package/dist/i3s-converter/types.d.ts.map +1 -0
- package/dist/i3s-converter/types.js +2 -0
- package/dist/i3s-server/app.d.ts +3 -0
- package/dist/i3s-server/app.d.ts.map +1 -0
- package/dist/i3s-server/app.js +2 -9
- package/dist/i3s-server/controllers/index-controller.d.ts +2 -0
- package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -0
- package/dist/i3s-server/controllers/index-controller.js +16 -24
- package/dist/i3s-server/routes/index.d.ts +3 -0
- package/dist/i3s-server/routes/index.d.ts.map +1 -0
- package/dist/i3s-server/routes/index.js +11 -15
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -5
- package/dist/lib/utils/compress-util.d.ts +45 -0
- package/dist/lib/utils/compress-util.d.ts.map +1 -0
- package/dist/lib/utils/compress-util.js +238 -160
- package/dist/lib/utils/file-utils.d.ts +22 -14
- package/dist/lib/utils/file-utils.d.ts.map +1 -0
- package/dist/lib/utils/file-utils.js +133 -36
- package/dist/lib/utils/lod-conversion-utils.d.ts +21 -12
- package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -0
- package/dist/lib/utils/lod-conversion-utils.js +72 -39
- package/dist/lib/utils/queue.d.ts +7 -0
- package/dist/lib/utils/queue.d.ts.map +1 -0
- package/dist/lib/utils/queue.js +18 -0
- package/dist/lib/utils/statistic-utills.d.ts +3 -25
- package/dist/lib/utils/statistic-utills.d.ts.map +1 -0
- package/dist/lib/utils/statistic-utills.js +58 -67
- package/dist/lib/utils/write-queue.d.ts +39 -0
- package/dist/lib/utils/write-queue.d.ts.map +1 -0
- package/dist/lib/utils/write-queue.js +80 -0
- package/dist/pgm-loader.d.ts +6 -0
- package/dist/pgm-loader.d.ts.map +1 -0
- package/dist/pgm-loader.js +23 -14
- package/dist/workers/3d-tiles-attributes-worker.d.ts +2 -0
- package/dist/workers/3d-tiles-attributes-worker.d.ts.map +1 -0
- package/dist/workers/3d-tiles-attributes-worker.js +9 -0
- package/dist/workers/i3s-attributes-worker.d.ts +2 -0
- package/dist/workers/i3s-attributes-worker.d.ts.map +1 -0
- package/dist/workers/i3s-attributes-worker.js +5 -0
- package/package.json +35 -24
- package/src/3d-tiles-attributes-worker.ts +43 -0
- package/src/3d-tiles-converter/3d-tiles-converter.ts +124 -59
- package/src/3d-tiles-converter/helpers/{b3dm-converter.js → b3dm-converter.ts} +71 -38
- package/src/3d-tiles-converter/helpers/{i3s-obb-to-3d-tiles-obb.js → i3s-obb-to-3d-tiles-obb.ts} +16 -1
- package/src/3d-tiles-converter/helpers/texture-atlas.ts +4 -4
- package/src/3d-tiles-converter/json-templates/{tileset.js → tileset.ts} +9 -9
- package/src/constants.ts +2 -0
- package/src/converter-cli.ts +370 -0
- package/src/deps-installer/deps-installer.ts +71 -0
- package/src/i3s-attributes-worker.ts +50 -0
- package/src/i3s-converter/helpers/batch-ids-extensions.ts +206 -0
- package/src/i3s-converter/helpers/coordinate-converter.ts +87 -27
- package/src/i3s-converter/helpers/create-scene-server-path.ts +29 -0
- package/src/i3s-converter/helpers/feature-attributes.ts +247 -0
- package/src/i3s-converter/helpers/geometry-attributes.ts +267 -0
- package/src/i3s-converter/helpers/geometry-converter.ts +1608 -0
- package/src/i3s-converter/helpers/gltf-attributes.ts +103 -0
- package/src/i3s-converter/helpers/node-debug.ts +146 -0
- package/src/i3s-converter/helpers/node-index-document.ts +315 -0
- package/src/i3s-converter/helpers/node-pages.ts +344 -0
- package/src/i3s-converter/i3s-converter.ts +557 -627
- package/src/i3s-converter/json-templates/geometry-definitions.ts +83 -0
- package/src/i3s-converter/json-templates/layers.ts +137 -0
- package/src/i3s-converter/json-templates/{metadata.js → metadata.ts} +2 -2
- package/src/i3s-converter/json-templates/{node.js → node.ts} +12 -12
- package/src/i3s-converter/json-templates/{scene-server.js → scene-server.ts} +2 -2
- package/src/i3s-converter/json-templates/{shared-resources.js → shared-resources.ts} +17 -17
- package/src/i3s-converter/types.ts +165 -0
- package/src/index.ts +0 -4
- package/src/lib/utils/{compress-util.js → compress-util.ts} +105 -18
- package/src/lib/utils/file-utils.ts +139 -0
- package/src/lib/utils/{lod-conversion-utils.js → lod-conversion-utils.ts} +27 -5
- package/src/lib/utils/queue.ts +17 -0
- package/src/lib/utils/write-queue.ts +110 -0
- package/src/pgm-loader.ts +3 -3
- package/src/workers/3d-tiles-attributes-worker.ts +6 -0
- package/src/workers/i3s-attributes-worker.ts +7 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
- package/dist/3d-tiles-converter/helpers/texture-atlas.js.map +0 -1
- package/dist/3d-tiles-converter/json-templates/tileset.js.map +0 -1
- package/dist/bundle.js.map +0 -1
- package/dist/deps-installer/deps-installer.js.map +0 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js.map +0 -1
- package/dist/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
- package/dist/i3s-converter/helpers/geometry-attributes.js.map +0 -1
- package/dist/i3s-converter/helpers/geometry-converter.js.map +0 -1
- package/dist/i3s-converter/helpers/node-debug.js.map +0 -1
- package/dist/i3s-converter/helpers/node-pages.js.map +0 -1
- package/dist/i3s-converter/i3s-converter.js.map +0 -1
- package/dist/i3s-converter/json-templates/layers.js.map +0 -1
- package/dist/i3s-converter/json-templates/metadata.js.map +0 -1
- package/dist/i3s-converter/json-templates/node.js.map +0 -1
- package/dist/i3s-converter/json-templates/scene-server.js.map +0 -1
- package/dist/i3s-converter/json-templates/shared-resources.js.map +0 -1
- package/dist/i3s-converter/json-templates/store.js.map +0 -1
- package/dist/i3s-server/app.js.map +0 -1
- package/dist/i3s-server/controllers/index-controller.js.map +0 -1
- package/dist/i3s-server/routes/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/geoid-height-model.d.ts +0 -41
- package/dist/lib/geoid-height-model.js +0 -140
- package/dist/lib/geoid-height-model.js.map +0 -1
- package/dist/lib/pgm-parser.d.ts +0 -14
- package/dist/lib/pgm-parser.js +0 -183
- package/dist/lib/pgm-parser.js.map +0 -1
- package/dist/lib/utils/compress-util.js.map +0 -1
- package/dist/lib/utils/compress-utils.d.ts +0 -53
- package/dist/lib/utils/file-utils.js.map +0 -1
- package/dist/lib/utils/lod-conversion-utils.js.map +0 -1
- package/dist/lib/utils/statistic-utills.js.map +0 -1
- package/dist/pgm-loader.js.map +0 -1
- package/src/3d-tiles-converter/helpers/b3dm-converter.d.ts +0 -23
- package/src/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +0 -16
- package/src/deps-installer/deps-installer.d.ts +0 -10
- package/src/deps-installer/deps-installer.js +0 -22
- package/src/i3s-converter/helpers/create-scene-server-path.js +0 -25
- package/src/i3s-converter/helpers/geometry-converter.d.ts +0 -40
- package/src/i3s-converter/helpers/geometry-converter.js +0 -915
- package/src/i3s-converter/helpers/node-pages.d.ts +0 -144
- package/src/i3s-converter/helpers/node-pages.js +0 -208
- package/src/i3s-converter/json-templates/layers.js +0 -199
- package/src/lib/geoid-height-model.d.ts +0 -41
- package/src/lib/geoid-height-model.js +0 -239
- package/src/lib/pgm-parser.d.ts +0 -14
- package/src/lib/pgm-parser.js +0 -179
- package/src/lib/utils/compress-utils.d.ts +0 -53
- package/src/lib/utils/file-utils.d.ts +0 -43
- package/src/lib/utils/file-utils.js +0 -38
- package/src/lib/utils/lod-conversion-utils.d.ts +0 -32
- /package/dist/{i3s-server → es5/i3s-server}/bin/www +0 -0
- /package/dist/{i3s-server → es5/i3s-server}/certs/cert.pem +0 -0
- /package/dist/{i3s-server → es5/i3s-server}/certs/key.pem +0 -0
- /package/src/i3s-converter/json-templates/{store.js → store.ts} +0 -0
- /package/src/lib/utils/{statistic-utills.js → statistic-utills.ts} +0 -0
|
@@ -0,0 +1,887 @@
|
|
|
1
|
+
import { Vector3, Matrix4, Vector4 } from '@math.gl/core';
|
|
2
|
+
import { Ellipsoid } from '@math.gl/geospatial';
|
|
3
|
+
import { DracoWriterWorker } from '@loaders.gl/draco';
|
|
4
|
+
import { assert, encode } from '@loaders.gl/core';
|
|
5
|
+
import { concatenateArrayBuffers, concatenateTypedArrays } from '@loaders.gl/loader-utils';
|
|
6
|
+
import md5 from 'md5';
|
|
7
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
8
|
+
import { generateAttributes } from './geometry-attributes';
|
|
9
|
+
import { createBoundingVolumesFromGeometry } from './coordinate-converter';
|
|
10
|
+
import { prepareDataForAttributesConversion } from './gltf-attributes';
|
|
11
|
+
import { handleBatchIdsExtensions } from './batch-ids-extensions';
|
|
12
|
+
import { checkPropertiesLength, flattenPropertyTableByFeatureIds } from './feature-attributes';
|
|
13
|
+
import { GL } from '@loaders.gl/math';
|
|
14
|
+
const DEFAULT_ROUGHNESS_FACTOR = 1;
|
|
15
|
+
const DEFAULT_METALLIC_FACTOR = 1;
|
|
16
|
+
const VALUES_PER_VERTEX = 3;
|
|
17
|
+
const VALUES_PER_TEX_COORD = 2;
|
|
18
|
+
const VALUES_PER_COLOR_ELEMENT = 4;
|
|
19
|
+
const STRING_TYPE = 'string';
|
|
20
|
+
const SHORT_INT_TYPE = 'Int32';
|
|
21
|
+
const DOUBLE_TYPE = 'Float64';
|
|
22
|
+
const OBJECT_ID_TYPE = 'Oid32';
|
|
23
|
+
const BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BATCHID'];
|
|
24
|
+
const EXT_FEATURE_METADATA = 'EXT_feature_metadata';
|
|
25
|
+
const EXT_MESH_FEATURES = 'EXT_mesh_features';
|
|
26
|
+
let scratchVector = new Vector3();
|
|
27
|
+
export default async function convertB3dmToI3sGeometry(tileContent, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, workerSource) {
|
|
28
|
+
var _tileContent$gltf;
|
|
29
|
+
const useCartesianPositions = generateBoundingVolumes;
|
|
30
|
+
const materialAndTextureList = await convertMaterials((_tileContent$gltf = tileContent.gltf) === null || _tileContent$gltf === void 0 ? void 0 : _tileContent$gltf.materials, shouldMergeMaterials);
|
|
31
|
+
const dataForAttributesConversion = prepareDataForAttributesConversion(tileContent);
|
|
32
|
+
const convertedAttributesMap = await convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions);
|
|
33
|
+
if (generateBoundingVolumes) {
|
|
34
|
+
_generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel);
|
|
35
|
+
}
|
|
36
|
+
const result = [];
|
|
37
|
+
for (const materialAndTexture of materialAndTextureList) {
|
|
38
|
+
const originarMaterialId = materialAndTexture.mergedMaterials[0].originalMaterialId;
|
|
39
|
+
if (!convertedAttributesMap.has(originarMaterialId)) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const convertedAttributes = convertedAttributesMap.get(originarMaterialId);
|
|
43
|
+
if (!convertedAttributes) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const {
|
|
47
|
+
material,
|
|
48
|
+
texture
|
|
49
|
+
} = materialAndTexture;
|
|
50
|
+
const nodeId = await addNodeToNodePage();
|
|
51
|
+
result.push(await _makeNodeResources({
|
|
52
|
+
convertedAttributes,
|
|
53
|
+
material,
|
|
54
|
+
texture,
|
|
55
|
+
tileContent,
|
|
56
|
+
nodeId,
|
|
57
|
+
featuresHashArray,
|
|
58
|
+
propertyTable,
|
|
59
|
+
attributeStorageInfo,
|
|
60
|
+
draco,
|
|
61
|
+
workerSource
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
if (!result.length) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
function _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel) {
|
|
70
|
+
for (const attributes of convertedAttributesMap.values()) {
|
|
71
|
+
const boundingVolumes = createBoundingVolumesFromGeometry(attributes.positions, geoidHeightModel);
|
|
72
|
+
attributes.boundingVolumes = boundingVolumes;
|
|
73
|
+
const cartographicOrigin = boundingVolumes.obb.center;
|
|
74
|
+
for (let index = 0; index < attributes.positions.length; index += VALUES_PER_VERTEX) {
|
|
75
|
+
const vertex = attributes.positions.subarray(index, index + VALUES_PER_VERTEX);
|
|
76
|
+
Ellipsoid.WGS84.cartesianToCartographic(Array.from(vertex), scratchVector);
|
|
77
|
+
scratchVector[2] = scratchVector[2] - geoidHeightModel.getHeight(scratchVector[1], scratchVector[0]);
|
|
78
|
+
scratchVector = scratchVector.subtract(cartographicOrigin);
|
|
79
|
+
attributes.positions.set(scratchVector, index);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async function _makeNodeResources(_ref) {
|
|
84
|
+
var _tileContent$gltf2;
|
|
85
|
+
let {
|
|
86
|
+
convertedAttributes,
|
|
87
|
+
material,
|
|
88
|
+
texture,
|
|
89
|
+
tileContent,
|
|
90
|
+
nodeId,
|
|
91
|
+
featuresHashArray,
|
|
92
|
+
propertyTable,
|
|
93
|
+
attributeStorageInfo,
|
|
94
|
+
draco,
|
|
95
|
+
workerSource
|
|
96
|
+
} = _ref;
|
|
97
|
+
const boundingVolumes = convertedAttributes.boundingVolumes;
|
|
98
|
+
const vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;
|
|
99
|
+
const {
|
|
100
|
+
faceRange,
|
|
101
|
+
featureIds,
|
|
102
|
+
positions,
|
|
103
|
+
normals,
|
|
104
|
+
colors,
|
|
105
|
+
uvRegions,
|
|
106
|
+
texCoords,
|
|
107
|
+
featureCount
|
|
108
|
+
} = generateAttributes(convertedAttributes);
|
|
109
|
+
if (tileContent.batchTableJson) {
|
|
110
|
+
makeFeatureIdsUnique(featureIds, convertedAttributes.featureIndices, featuresHashArray, tileContent.batchTableJson);
|
|
111
|
+
}
|
|
112
|
+
const header = new Uint32Array(2);
|
|
113
|
+
const typedFeatureIds = generateBigUint64Array(featureIds);
|
|
114
|
+
header.set([vertexCount, featureCount], 0);
|
|
115
|
+
const fileBuffer = new Uint8Array(concatenateArrayBuffers(header.buffer, positions.buffer, normals.buffer, texture ? texCoords.buffer : new ArrayBuffer(0), colors.buffer, uvRegions, typedFeatureIds.buffer, faceRange.buffer));
|
|
116
|
+
const compressedGeometry = draco ? generateCompressedGeometry(vertexCount, convertedAttributes, {
|
|
117
|
+
positions,
|
|
118
|
+
normals,
|
|
119
|
+
texCoords: texture ? texCoords : new Float32Array(0),
|
|
120
|
+
colors,
|
|
121
|
+
uvRegions,
|
|
122
|
+
featureIds,
|
|
123
|
+
faceRange
|
|
124
|
+
}, workerSource.draco) : null;
|
|
125
|
+
let attributes = [];
|
|
126
|
+
if (attributeStorageInfo && propertyTable) {
|
|
127
|
+
attributes = convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attributeStorageInfo);
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
nodeId,
|
|
131
|
+
geometry: fileBuffer,
|
|
132
|
+
compressedGeometry,
|
|
133
|
+
texture,
|
|
134
|
+
hasUvRegions: Boolean(uvRegions.length),
|
|
135
|
+
sharedResources: getSharedResources(((_tileContent$gltf2 = tileContent.gltf) === null || _tileContent$gltf2 === void 0 ? void 0 : _tileContent$gltf2.materials) || [], nodeId),
|
|
136
|
+
meshMaterial: material,
|
|
137
|
+
vertexCount,
|
|
138
|
+
attributes,
|
|
139
|
+
featureCount,
|
|
140
|
+
boundingVolumes
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export async function convertAttributes(attributesData, materialAndTextureList, useCartesianPositions) {
|
|
144
|
+
const {
|
|
145
|
+
nodes,
|
|
146
|
+
images,
|
|
147
|
+
cartographicOrigin,
|
|
148
|
+
cartesianModelMatrix
|
|
149
|
+
} = attributesData;
|
|
150
|
+
const attributesMap = new Map();
|
|
151
|
+
for (const materialAndTexture of materialAndTextureList) {
|
|
152
|
+
const attributes = {
|
|
153
|
+
positions: new Float32Array(0),
|
|
154
|
+
normals: new Float32Array(0),
|
|
155
|
+
texCoords: new Float32Array(0),
|
|
156
|
+
colors: new Uint8Array(0),
|
|
157
|
+
uvRegions: new Uint16Array(0),
|
|
158
|
+
featureIndicesGroups: [],
|
|
159
|
+
featureIndices: [],
|
|
160
|
+
boundingVolumes: null,
|
|
161
|
+
mergedMaterials: materialAndTexture.mergedMaterials
|
|
162
|
+
};
|
|
163
|
+
for (const mergedMaterial of materialAndTexture.mergedMaterials) {
|
|
164
|
+
attributesMap.set(mergedMaterial.originalMaterialId, attributes);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions);
|
|
168
|
+
for (const attrKey of attributesMap.keys()) {
|
|
169
|
+
const attributes = attributesMap.get(attrKey);
|
|
170
|
+
if (!attributes) {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (attributes.positions.length === 0) {
|
|
174
|
+
attributesMap.delete(attrKey);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (attributes.featureIndicesGroups) {
|
|
178
|
+
attributes.featureIndices = attributes.featureIndicesGroups.reduce((acc, value) => acc.concat(value));
|
|
179
|
+
delete attributes.featureIndicesGroups;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return attributesMap;
|
|
183
|
+
}
|
|
184
|
+
function convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions) {
|
|
185
|
+
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]);
|
|
186
|
+
if (nodes) {
|
|
187
|
+
for (const node of nodes) {
|
|
188
|
+
convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function getCompositeTransformationMatrix(node, matrix) {
|
|
193
|
+
let transformationMatrix = matrix;
|
|
194
|
+
const {
|
|
195
|
+
matrix: nodeMatrix,
|
|
196
|
+
rotation,
|
|
197
|
+
scale,
|
|
198
|
+
translation
|
|
199
|
+
} = node;
|
|
200
|
+
if (nodeMatrix) {
|
|
201
|
+
transformationMatrix = matrix.multiplyRight(nodeMatrix);
|
|
202
|
+
}
|
|
203
|
+
if (translation) {
|
|
204
|
+
transformationMatrix = transformationMatrix.translate(translation);
|
|
205
|
+
}
|
|
206
|
+
if (rotation) {
|
|
207
|
+
transformationMatrix = transformationMatrix.rotateXYZ(rotation);
|
|
208
|
+
}
|
|
209
|
+
if (scale) {
|
|
210
|
+
transformationMatrix = transformationMatrix.scale(scale);
|
|
211
|
+
}
|
|
212
|
+
return transformationMatrix;
|
|
213
|
+
}
|
|
214
|
+
function convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions) {
|
|
215
|
+
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]);
|
|
216
|
+
const transformationMatrix = getCompositeTransformationMatrix(node, matrix);
|
|
217
|
+
const mesh = node.mesh;
|
|
218
|
+
if (mesh) {
|
|
219
|
+
convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
|
|
220
|
+
}
|
|
221
|
+
convertNodes(node.children || [], images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
|
|
222
|
+
}
|
|
223
|
+
function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap) {
|
|
224
|
+
let useCartesianPositions = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
225
|
+
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]);
|
|
226
|
+
for (const primitive of mesh.primitives) {
|
|
227
|
+
let outputAttributes = null;
|
|
228
|
+
let materialUvRegion;
|
|
229
|
+
if (primitive.material) {
|
|
230
|
+
var _outputAttributes, _outputAttributes$mer;
|
|
231
|
+
outputAttributes = attributesMap.get(primitive.material.uniqueId);
|
|
232
|
+
materialUvRegion = (_outputAttributes = outputAttributes) === null || _outputAttributes === void 0 ? void 0 : (_outputAttributes$mer = _outputAttributes.mergedMaterials.find(_ref2 => {
|
|
233
|
+
var _primitive$material;
|
|
234
|
+
let {
|
|
235
|
+
originalMaterialId
|
|
236
|
+
} = _ref2;
|
|
237
|
+
return originalMaterialId === ((_primitive$material = primitive.material) === null || _primitive$material === void 0 ? void 0 : _primitive$material.uniqueId);
|
|
238
|
+
})) === null || _outputAttributes$mer === void 0 ? void 0 : _outputAttributes$mer.uvRegion;
|
|
239
|
+
} else if (attributesMap.has('default')) {
|
|
240
|
+
outputAttributes = attributesMap.get('default');
|
|
241
|
+
}
|
|
242
|
+
assert(outputAttributes !== null, 'Primitive - material mapping failed');
|
|
243
|
+
const attributes = primitive.attributes;
|
|
244
|
+
if (!outputAttributes) {
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
const indices = getIndices(primitive);
|
|
248
|
+
outputAttributes.positions = concatenateTypedArrays(outputAttributes.positions, transformVertexArray({
|
|
249
|
+
vertices: attributes.POSITION.value,
|
|
250
|
+
cartographicOrigin,
|
|
251
|
+
cartesianModelMatrix,
|
|
252
|
+
nodeMatrix: matrix,
|
|
253
|
+
indices,
|
|
254
|
+
attributeSpecificTransformation: transformVertexPositions,
|
|
255
|
+
useCartesianPositions
|
|
256
|
+
}));
|
|
257
|
+
outputAttributes.normals = concatenateTypedArrays(outputAttributes.normals, transformVertexArray({
|
|
258
|
+
vertices: attributes.NORMAL && attributes.NORMAL.value,
|
|
259
|
+
cartographicOrigin,
|
|
260
|
+
cartesianModelMatrix,
|
|
261
|
+
nodeMatrix: matrix,
|
|
262
|
+
indices,
|
|
263
|
+
attributeSpecificTransformation: transformVertexNormals,
|
|
264
|
+
useCartesianPositions: false
|
|
265
|
+
}));
|
|
266
|
+
outputAttributes.texCoords = concatenateTypedArrays(outputAttributes.texCoords, flattenTexCoords(attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value, indices));
|
|
267
|
+
outputAttributes.colors = concatenateTypedArrays(outputAttributes.colors, flattenColors(attributes.COLOR_0, indices));
|
|
268
|
+
if (materialUvRegion) {
|
|
269
|
+
outputAttributes.uvRegions = concatenateTypedArrays(outputAttributes.uvRegions, createUvRegion(materialUvRegion, indices));
|
|
270
|
+
}
|
|
271
|
+
outputAttributes.featureIndicesGroups = outputAttributes.featureIndicesGroups || [];
|
|
272
|
+
outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images), indices));
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function getIndices(primitive) {
|
|
276
|
+
var _primitive$indices;
|
|
277
|
+
let indices = (_primitive$indices = primitive.indices) === null || _primitive$indices === void 0 ? void 0 : _primitive$indices.value;
|
|
278
|
+
if (indices && primitive.mode === GL.TRIANGLE_STRIP) {
|
|
279
|
+
const TypedArrayConstructor = indices.constructor;
|
|
280
|
+
const newIndices = new TypedArrayConstructor((indices.length - 2) * 3);
|
|
281
|
+
let triangleIndex = 0;
|
|
282
|
+
let currentTriangle = indices.slice(0, 3);
|
|
283
|
+
newIndices.set(currentTriangle, 0);
|
|
284
|
+
for (let i = 1; i + 2 < indices.length; i++) {
|
|
285
|
+
triangleIndex += 3;
|
|
286
|
+
currentTriangle = indices.slice(i, i + 3);
|
|
287
|
+
if (i % 2 === 0) {
|
|
288
|
+
newIndices.set(currentTriangle, triangleIndex);
|
|
289
|
+
} else {
|
|
290
|
+
newIndices.set(currentTriangle.reverse(), triangleIndex);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
indices = newIndices;
|
|
294
|
+
}
|
|
295
|
+
return indices;
|
|
296
|
+
}
|
|
297
|
+
function transformVertexArray(args) {
|
|
298
|
+
const {
|
|
299
|
+
vertices,
|
|
300
|
+
indices,
|
|
301
|
+
attributeSpecificTransformation
|
|
302
|
+
} = args;
|
|
303
|
+
const newVertices = new Float32Array(indices.length * VALUES_PER_VERTEX);
|
|
304
|
+
if (!vertices) {
|
|
305
|
+
return newVertices;
|
|
306
|
+
}
|
|
307
|
+
for (let i = 0; i < indices.length; i++) {
|
|
308
|
+
const coordIndex = indices[i] * VALUES_PER_VERTEX;
|
|
309
|
+
const vertex = vertices.subarray(coordIndex, coordIndex + VALUES_PER_VERTEX);
|
|
310
|
+
let vertexVector = new Vector3(Array.from(vertex));
|
|
311
|
+
vertexVector = attributeSpecificTransformation(vertexVector, args);
|
|
312
|
+
newVertices[i * VALUES_PER_VERTEX] = vertexVector.x;
|
|
313
|
+
newVertices[i * VALUES_PER_VERTEX + 1] = vertexVector.y;
|
|
314
|
+
newVertices[i * VALUES_PER_VERTEX + 2] = vertexVector.z;
|
|
315
|
+
}
|
|
316
|
+
return newVertices;
|
|
317
|
+
}
|
|
318
|
+
function transformVertexPositions(vertexVector, calleeArgs) {
|
|
319
|
+
const {
|
|
320
|
+
cartesianModelMatrix,
|
|
321
|
+
cartographicOrigin,
|
|
322
|
+
nodeMatrix,
|
|
323
|
+
useCartesianPositions
|
|
324
|
+
} = calleeArgs;
|
|
325
|
+
if (nodeMatrix) {
|
|
326
|
+
vertexVector = vertexVector.transform(nodeMatrix);
|
|
327
|
+
}
|
|
328
|
+
vertexVector = vertexVector.transform(cartesianModelMatrix);
|
|
329
|
+
if (useCartesianPositions) {
|
|
330
|
+
return vertexVector;
|
|
331
|
+
}
|
|
332
|
+
Ellipsoid.WGS84.cartesianToCartographic([vertexVector[0], vertexVector[1], vertexVector[2]], vertexVector);
|
|
333
|
+
vertexVector = vertexVector.subtract(cartographicOrigin);
|
|
334
|
+
return vertexVector;
|
|
335
|
+
}
|
|
336
|
+
function transformVertexNormals(vertexVector, calleeArgs) {
|
|
337
|
+
const {
|
|
338
|
+
cartesianModelMatrix,
|
|
339
|
+
nodeMatrix
|
|
340
|
+
} = calleeArgs;
|
|
341
|
+
if (nodeMatrix) {
|
|
342
|
+
vertexVector = vertexVector.transformAsVector(nodeMatrix);
|
|
343
|
+
}
|
|
344
|
+
vertexVector = vertexVector.transformAsVector(cartesianModelMatrix);
|
|
345
|
+
return vertexVector;
|
|
346
|
+
}
|
|
347
|
+
function flattenTexCoords(texCoords, indices) {
|
|
348
|
+
const newTexCoords = new Float32Array(indices.length * VALUES_PER_TEX_COORD);
|
|
349
|
+
if (!texCoords) {
|
|
350
|
+
newTexCoords.fill(1);
|
|
351
|
+
return newTexCoords;
|
|
352
|
+
}
|
|
353
|
+
for (let i = 0; i < indices.length; i++) {
|
|
354
|
+
const coordIndex = indices[i] * VALUES_PER_TEX_COORD;
|
|
355
|
+
const texCoord = texCoords.subarray(coordIndex, coordIndex + VALUES_PER_TEX_COORD);
|
|
356
|
+
newTexCoords[i * VALUES_PER_TEX_COORD] = texCoord[0];
|
|
357
|
+
newTexCoords[i * VALUES_PER_TEX_COORD + 1] = texCoord[1];
|
|
358
|
+
}
|
|
359
|
+
return newTexCoords;
|
|
360
|
+
}
|
|
361
|
+
function flattenColors(colorsAttribute, indices) {
|
|
362
|
+
const components = (colorsAttribute === null || colorsAttribute === void 0 ? void 0 : colorsAttribute.components) || VALUES_PER_COLOR_ELEMENT;
|
|
363
|
+
const newColors = new Uint8Array(indices.length * components);
|
|
364
|
+
if (!colorsAttribute) {
|
|
365
|
+
newColors.fill(255);
|
|
366
|
+
return newColors;
|
|
367
|
+
}
|
|
368
|
+
const colors = colorsAttribute.value;
|
|
369
|
+
for (let i = 0; i < indices.length; i++) {
|
|
370
|
+
const colorIndex = indices[i] * components;
|
|
371
|
+
const color = colors.subarray(colorIndex, colorIndex + components);
|
|
372
|
+
const colorUint8 = new Uint8Array(components);
|
|
373
|
+
for (let j = 0; j < color.length; j++) {
|
|
374
|
+
colorUint8[j] = color[j] * 255;
|
|
375
|
+
}
|
|
376
|
+
newColors.set(colorUint8, i * components);
|
|
377
|
+
}
|
|
378
|
+
return newColors;
|
|
379
|
+
}
|
|
380
|
+
function createUvRegion(materialUvRegion, indices) {
|
|
381
|
+
const result = new Uint16Array(indices.length * 4);
|
|
382
|
+
for (let i = 0; i < result.length; i += 4) {
|
|
383
|
+
result.set(materialUvRegion, i);
|
|
384
|
+
}
|
|
385
|
+
return result;
|
|
386
|
+
}
|
|
387
|
+
function flattenBatchIds(batchedIds, indices) {
|
|
388
|
+
if (!batchedIds.length || !indices.length) {
|
|
389
|
+
return [];
|
|
390
|
+
}
|
|
391
|
+
const newBatchIds = [];
|
|
392
|
+
for (let i = 0; i < indices.length; i++) {
|
|
393
|
+
const coordIndex = indices[i];
|
|
394
|
+
newBatchIds.push(batchedIds[coordIndex]);
|
|
395
|
+
}
|
|
396
|
+
return newBatchIds;
|
|
397
|
+
}
|
|
398
|
+
function getBatchIds(attributes, primitive, images) {
|
|
399
|
+
const batchIds = handleBatchIdsExtensions(attributes, primitive, images);
|
|
400
|
+
if (batchIds.length) {
|
|
401
|
+
return batchIds;
|
|
402
|
+
}
|
|
403
|
+
for (let index = 0; index < BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES.length; index++) {
|
|
404
|
+
const possibleBatchIdAttributeName = BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES[index];
|
|
405
|
+
if (attributes[possibleBatchIdAttributeName] && attributes[possibleBatchIdAttributeName].value) {
|
|
406
|
+
return attributes[possibleBatchIdAttributeName].value;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return [];
|
|
410
|
+
}
|
|
411
|
+
async function convertMaterials() {
|
|
412
|
+
let sourceMaterials = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
413
|
+
let shouldMergeMaterials = arguments.length > 1 ? arguments[1] : undefined;
|
|
414
|
+
let materials = [];
|
|
415
|
+
for (const sourceMaterial of sourceMaterials) {
|
|
416
|
+
materials.push(convertMaterial(sourceMaterial));
|
|
417
|
+
}
|
|
418
|
+
if (shouldMergeMaterials) {
|
|
419
|
+
materials = await mergeAllMaterials(materials);
|
|
420
|
+
}
|
|
421
|
+
return materials;
|
|
422
|
+
}
|
|
423
|
+
async function mergeAllMaterials(materials) {
|
|
424
|
+
const result = [];
|
|
425
|
+
while (materials.length > 0) {
|
|
426
|
+
let newMaterial = materials.splice(0, 1)[0];
|
|
427
|
+
const mergedIndices = [];
|
|
428
|
+
for (let i = 0; i < materials.length; i++) {
|
|
429
|
+
const material = materials[i];
|
|
430
|
+
if (newMaterial.texture && material.texture || !newMaterial.texture && !material.texture) {
|
|
431
|
+
newMaterial = await mergeMaterials(newMaterial, material);
|
|
432
|
+
mergedIndices.push(i);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
if (newMaterial.texture && mergedIndices.length) {
|
|
436
|
+
var _newMaterial$mergedMa, _newMaterial$mergedMa2;
|
|
437
|
+
const newWidth = (_newMaterial$mergedMa = newMaterial.mergedMaterials) === null || _newMaterial$mergedMa === void 0 ? void 0 : _newMaterial$mergedMa.reduce((accum, _ref3) => {
|
|
438
|
+
let {
|
|
439
|
+
textureSize
|
|
440
|
+
} = _ref3;
|
|
441
|
+
return accum + ((textureSize === null || textureSize === void 0 ? void 0 : textureSize.width) || 0);
|
|
442
|
+
}, 0);
|
|
443
|
+
const newHeight = (_newMaterial$mergedMa2 = newMaterial.mergedMaterials) === null || _newMaterial$mergedMa2 === void 0 ? void 0 : _newMaterial$mergedMa2.reduce((accum, _ref4) => {
|
|
444
|
+
let {
|
|
445
|
+
textureSize
|
|
446
|
+
} = _ref4;
|
|
447
|
+
return Math.max(accum, (textureSize === null || textureSize === void 0 ? void 0 : textureSize.height) || 0);
|
|
448
|
+
}, 0);
|
|
449
|
+
let currentX = -1;
|
|
450
|
+
for (const aTextureMetadata of newMaterial.mergedMaterials) {
|
|
451
|
+
if (aTextureMetadata.textureSize) {
|
|
452
|
+
const newX = currentX + 1 + aTextureMetadata.textureSize.width / newWidth * 2 ** (Uint16Array.BYTES_PER_ELEMENT * 8) - 1;
|
|
453
|
+
aTextureMetadata.uvRegion = new Uint16Array([currentX + 1, 0, newX, aTextureMetadata.textureSize.height / newHeight * 2 ** (Uint16Array.BYTES_PER_ELEMENT * 8) - 1]);
|
|
454
|
+
currentX = newX;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
newMaterial.texture.image.width = newWidth;
|
|
458
|
+
newMaterial.texture.image.height = newHeight;
|
|
459
|
+
}
|
|
460
|
+
for (const index of mergedIndices.reverse()) {
|
|
461
|
+
materials.splice(index, 1);
|
|
462
|
+
}
|
|
463
|
+
result.push(newMaterial);
|
|
464
|
+
}
|
|
465
|
+
if (!result.length) {
|
|
466
|
+
result.push({
|
|
467
|
+
material: getDefaultMaterial(),
|
|
468
|
+
mergedMaterials: [{
|
|
469
|
+
originalMaterialId: 'default'
|
|
470
|
+
}]
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
return result;
|
|
474
|
+
}
|
|
475
|
+
async function mergeMaterials(material1, material2) {
|
|
476
|
+
var _material1$texture, _material2$texture;
|
|
477
|
+
if ((_material1$texture = material1.texture) !== null && _material1$texture !== void 0 && _material1$texture.bufferView && (_material2$texture = material2.texture) !== null && _material2$texture !== void 0 && _material2$texture.bufferView && material1.mergedMaterials && material2.mergedMaterials) {
|
|
478
|
+
const buffer1 = Buffer.from(material1.texture.bufferView.data);
|
|
479
|
+
const buffer2 = Buffer.from(material2.texture.bufferView.data);
|
|
480
|
+
try {
|
|
481
|
+
const {
|
|
482
|
+
joinImages
|
|
483
|
+
} = await import('join-images');
|
|
484
|
+
const sharpData = await joinImages([buffer1, buffer2], {
|
|
485
|
+
direction: 'horizontal'
|
|
486
|
+
});
|
|
487
|
+
material1.texture.bufferView.data = await sharpData.toFormat(material1.texture.mimeType === 'image/png' ? 'png' : 'jpeg').toBuffer();
|
|
488
|
+
} catch (error) {
|
|
489
|
+
console.log('Join images into a texture atlas has failed. Consider usage `--split-nodes` option. (See documentation https://loaders.gl/modules/tile-converter/docs/cli-reference/tile-converter)');
|
|
490
|
+
throw error;
|
|
491
|
+
}
|
|
492
|
+
material1.material.pbrMetallicRoughness.baseColorTexture.textureSetDefinitionId = 1;
|
|
493
|
+
}
|
|
494
|
+
material1.mergedMaterials = material1.mergedMaterials.concat(material2.mergedMaterials);
|
|
495
|
+
return material1;
|
|
496
|
+
}
|
|
497
|
+
function convertMaterial(sourceMaterial) {
|
|
498
|
+
var _sourceMaterial$emiss, _sourceMaterial$pbrMe, _sourceMaterial$pbrMe2, _sourceMaterial$pbrMe3;
|
|
499
|
+
const material = {
|
|
500
|
+
doubleSided: sourceMaterial.doubleSided,
|
|
501
|
+
emissiveFactor: (_sourceMaterial$emiss = sourceMaterial.emissiveFactor) === null || _sourceMaterial$emiss === void 0 ? void 0 : _sourceMaterial$emiss.map(c => Math.round(c * 255)),
|
|
502
|
+
alphaMode: convertAlphaMode(sourceMaterial.alphaMode),
|
|
503
|
+
pbrMetallicRoughness: {
|
|
504
|
+
roughnessFactor: (sourceMaterial === null || sourceMaterial === void 0 ? void 0 : (_sourceMaterial$pbrMe = sourceMaterial.pbrMetallicRoughness) === null || _sourceMaterial$pbrMe === void 0 ? void 0 : _sourceMaterial$pbrMe.roughnessFactor) || DEFAULT_ROUGHNESS_FACTOR,
|
|
505
|
+
metallicFactor: (sourceMaterial === null || sourceMaterial === void 0 ? void 0 : (_sourceMaterial$pbrMe2 = sourceMaterial.pbrMetallicRoughness) === null || _sourceMaterial$pbrMe2 === void 0 ? void 0 : _sourceMaterial$pbrMe2.metallicFactor) || DEFAULT_METALLIC_FACTOR
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
let texture;
|
|
509
|
+
if (sourceMaterial !== null && sourceMaterial !== void 0 && (_sourceMaterial$pbrMe3 = sourceMaterial.pbrMetallicRoughness) !== null && _sourceMaterial$pbrMe3 !== void 0 && _sourceMaterial$pbrMe3.baseColorTexture) {
|
|
510
|
+
texture = sourceMaterial.pbrMetallicRoughness.baseColorTexture.texture.source;
|
|
511
|
+
material.pbrMetallicRoughness.baseColorTexture = {
|
|
512
|
+
textureSetDefinitionId: 0
|
|
513
|
+
};
|
|
514
|
+
} else if (sourceMaterial.emissiveTexture) {
|
|
515
|
+
texture = sourceMaterial.emissiveTexture.texture.source;
|
|
516
|
+
material.pbrMetallicRoughness.baseColorTexture = {
|
|
517
|
+
textureSetDefinitionId: 0
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
const uniqueId = uuidv4();
|
|
521
|
+
sourceMaterial.uniqueId = uniqueId;
|
|
522
|
+
let mergedMaterials = [{
|
|
523
|
+
originalMaterialId: uniqueId
|
|
524
|
+
}];
|
|
525
|
+
if (!texture) {
|
|
526
|
+
var _sourceMaterial$pbrMe4;
|
|
527
|
+
const baseColorFactor = sourceMaterial === null || sourceMaterial === void 0 ? void 0 : (_sourceMaterial$pbrMe4 = sourceMaterial.pbrMetallicRoughness) === null || _sourceMaterial$pbrMe4 === void 0 ? void 0 : _sourceMaterial$pbrMe4.baseColorFactor;
|
|
528
|
+
material.pbrMetallicRoughness.baseColorFactor = baseColorFactor && baseColorFactor.map(c => Math.round(c * 255)) || undefined;
|
|
529
|
+
} else {
|
|
530
|
+
mergedMaterials[0].textureSize = {
|
|
531
|
+
width: texture.image.width,
|
|
532
|
+
height: texture.image.height
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
return {
|
|
536
|
+
material,
|
|
537
|
+
texture,
|
|
538
|
+
mergedMaterials
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
function convertAlphaMode(gltfAlphaMode) {
|
|
542
|
+
switch (gltfAlphaMode) {
|
|
543
|
+
case 'OPAQUE':
|
|
544
|
+
return 'opaque';
|
|
545
|
+
case 'MASK':
|
|
546
|
+
return 'mask';
|
|
547
|
+
case 'BLEND':
|
|
548
|
+
return 'blend';
|
|
549
|
+
default:
|
|
550
|
+
return 'opaque';
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
function getDefaultMaterial() {
|
|
554
|
+
return {
|
|
555
|
+
alphaMode: 'opaque',
|
|
556
|
+
pbrMetallicRoughness: {
|
|
557
|
+
metallicFactor: 1,
|
|
558
|
+
roughnessFactor: 1
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
function getSharedResources(gltfMaterials, nodeId) {
|
|
563
|
+
const i3sResources = {};
|
|
564
|
+
if (!gltfMaterials || !gltfMaterials.length) {
|
|
565
|
+
return i3sResources;
|
|
566
|
+
}
|
|
567
|
+
i3sResources.materialDefinitionInfos = [];
|
|
568
|
+
for (const gltfMaterial of gltfMaterials) {
|
|
569
|
+
const {
|
|
570
|
+
materialDefinitionInfo,
|
|
571
|
+
textureDefinitionInfo
|
|
572
|
+
} = convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId);
|
|
573
|
+
i3sResources.materialDefinitionInfos.push(materialDefinitionInfo);
|
|
574
|
+
if (textureDefinitionInfo) {
|
|
575
|
+
i3sResources.textureDefinitionInfos = i3sResources.textureDefinitionInfos || [];
|
|
576
|
+
i3sResources.textureDefinitionInfos.push(textureDefinitionInfo);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
return i3sResources;
|
|
580
|
+
}
|
|
581
|
+
function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
|
|
582
|
+
var _gltfMaterial$pbrMeta;
|
|
583
|
+
const texture = (gltfMaterial === null || gltfMaterial === void 0 ? void 0 : (_gltfMaterial$pbrMeta = gltfMaterial.pbrMetallicRoughness) === null || _gltfMaterial$pbrMeta === void 0 ? void 0 : _gltfMaterial$pbrMeta.baseColorTexture) || gltfMaterial.emissiveTexture;
|
|
584
|
+
let textureDefinitionInfo = null;
|
|
585
|
+
if (texture) {
|
|
586
|
+
textureDefinitionInfo = extractSharedResourcesTextureInfo(texture.texture, nodeId);
|
|
587
|
+
}
|
|
588
|
+
const {
|
|
589
|
+
baseColorFactor,
|
|
590
|
+
metallicFactor
|
|
591
|
+
} = (gltfMaterial === null || gltfMaterial === void 0 ? void 0 : gltfMaterial.pbrMetallicRoughness) || {};
|
|
592
|
+
let colorFactor = baseColorFactor;
|
|
593
|
+
if ((!baseColorFactor || baseColorFactor[3] === 0) && gltfMaterial.emissiveFactor) {
|
|
594
|
+
colorFactor = gltfMaterial.emissiveFactor;
|
|
595
|
+
colorFactor[3] = colorFactor[3] || 1;
|
|
596
|
+
}
|
|
597
|
+
return {
|
|
598
|
+
materialDefinitionInfo: extractSharedResourcesMaterialInfo(colorFactor || [1, 1, 1, 1], metallicFactor),
|
|
599
|
+
textureDefinitionInfo
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
function extractSharedResourcesMaterialInfo(baseColorFactor) {
|
|
603
|
+
let metallicFactor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
604
|
+
const matDielectricColorComponent = 0.04 / 255;
|
|
605
|
+
const black = new Vector4(0, 0, 0, 1);
|
|
606
|
+
const unitVector = new Vector4(1, 1, 1, 1);
|
|
607
|
+
const dielectricSpecular = new Vector4(matDielectricColorComponent, matDielectricColorComponent, matDielectricColorComponent, 0);
|
|
608
|
+
const baseColorVector = new Vector4(baseColorFactor);
|
|
609
|
+
const firstOperand = unitVector.subtract(dielectricSpecular).multiply(baseColorVector);
|
|
610
|
+
const diffuse = firstOperand.lerp(firstOperand, black, metallicFactor);
|
|
611
|
+
dielectricSpecular[3] = 1;
|
|
612
|
+
const specular = dielectricSpecular.lerp(dielectricSpecular, baseColorVector, metallicFactor);
|
|
613
|
+
return {
|
|
614
|
+
params: {
|
|
615
|
+
diffuse: diffuse.toArray(),
|
|
616
|
+
specular: specular.toArray(),
|
|
617
|
+
renderMode: 'solid'
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
function extractSharedResourcesTextureInfo(texture, nodeId) {
|
|
622
|
+
var _texture$source, _texture$source2, _texture$source3;
|
|
623
|
+
return {
|
|
624
|
+
encoding: texture !== null && texture !== void 0 && (_texture$source = texture.source) !== null && _texture$source !== void 0 && _texture$source.mimeType ? [texture.source.mimeType] : undefined,
|
|
625
|
+
images: [{
|
|
626
|
+
id: generateImageId(texture, nodeId),
|
|
627
|
+
size: (_texture$source2 = texture.source) === null || _texture$source2 === void 0 ? void 0 : _texture$source2.image.width,
|
|
628
|
+
length: [(_texture$source3 = texture.source) === null || _texture$source3 === void 0 ? void 0 : _texture$source3.image.data.length]
|
|
629
|
+
}]
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
function generateImageId(texture, nodeId) {
|
|
633
|
+
var _texture$source4;
|
|
634
|
+
const {
|
|
635
|
+
width,
|
|
636
|
+
height
|
|
637
|
+
} = (_texture$source4 = texture.source) === null || _texture$source4 === void 0 ? void 0 : _texture$source4.image;
|
|
638
|
+
const levelCountOfTexture = 1;
|
|
639
|
+
const indexOfLevel = 0;
|
|
640
|
+
const indexOfTextureInStore = nodeId + 1;
|
|
641
|
+
const zerosCount = 32 - indexOfTextureInStore.toString(2).length;
|
|
642
|
+
const rightHalf = '0'.repeat(zerosCount).concat(indexOfTextureInStore.toString(2));
|
|
643
|
+
const shiftedLevelCountOfTexture = levelCountOfTexture << 28;
|
|
644
|
+
const shiftedIndexOfLevel = indexOfLevel << 24;
|
|
645
|
+
const shiftedWidth = width - 1 << 12;
|
|
646
|
+
const shiftedHeight = height - 1 << 0;
|
|
647
|
+
const leftHalf = shiftedLevelCountOfTexture + shiftedIndexOfLevel + shiftedWidth + shiftedHeight;
|
|
648
|
+
const imageId = BigInt("0b".concat(leftHalf.toString(2)).concat(rightHalf));
|
|
649
|
+
return imageId.toString();
|
|
650
|
+
}
|
|
651
|
+
function makeFeatureIdsUnique(featureIds, featureIndices, featuresHashArray, batchTable) {
|
|
652
|
+
const replaceMap = getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray);
|
|
653
|
+
replaceIndicesByUnique(featureIndices, replaceMap);
|
|
654
|
+
replaceIndicesByUnique(featureIds, replaceMap);
|
|
655
|
+
}
|
|
656
|
+
function getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {
|
|
657
|
+
const featureMap = {};
|
|
658
|
+
for (let index = 0; index < featureIds.length; index++) {
|
|
659
|
+
const oldFeatureId = featureIds[index];
|
|
660
|
+
const uniqueFeatureId = getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray);
|
|
661
|
+
featureMap[oldFeatureId.toString()] = uniqueFeatureId;
|
|
662
|
+
}
|
|
663
|
+
return featureMap;
|
|
664
|
+
}
|
|
665
|
+
function generateStringFromBatchTableByIndex(batchTable, index) {
|
|
666
|
+
let str = '';
|
|
667
|
+
for (const key in batchTable) {
|
|
668
|
+
str += batchTable[key][index];
|
|
669
|
+
}
|
|
670
|
+
return str;
|
|
671
|
+
}
|
|
672
|
+
function getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray) {
|
|
673
|
+
const batchTableStr = generateStringFromBatchTableByIndex(batchTable, index);
|
|
674
|
+
const hash = md5(batchTableStr);
|
|
675
|
+
if (featuresHashArray.includes(hash)) {
|
|
676
|
+
return featuresHashArray.indexOf(hash);
|
|
677
|
+
}
|
|
678
|
+
return featuresHashArray.push(hash) - 1;
|
|
679
|
+
}
|
|
680
|
+
function replaceIndicesByUnique(indicesArray, featureMap) {
|
|
681
|
+
for (let index = 0; index < indicesArray.length; index++) {
|
|
682
|
+
indicesArray[index] = featureMap[indicesArray[index]];
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
function convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attributeStorageInfo) {
|
|
686
|
+
const attributeBuffers = [];
|
|
687
|
+
const needFlattenPropertyTable = checkPropertiesLength(featureIds, propertyTable);
|
|
688
|
+
const properties = needFlattenPropertyTable ? flattenPropertyTableByFeatureIds(featureIds, propertyTable) : propertyTable;
|
|
689
|
+
const propertyTableWithObjectIds = {
|
|
690
|
+
OBJECTID: featureIds,
|
|
691
|
+
...properties
|
|
692
|
+
};
|
|
693
|
+
for (const propertyName in propertyTableWithObjectIds) {
|
|
694
|
+
const type = getAttributeType(propertyName, attributeStorageInfo);
|
|
695
|
+
const value = propertyTableWithObjectIds[propertyName];
|
|
696
|
+
const attributeBuffer = generateAttributeBuffer(type, value);
|
|
697
|
+
attributeBuffers.push(attributeBuffer);
|
|
698
|
+
}
|
|
699
|
+
return attributeBuffers;
|
|
700
|
+
}
|
|
701
|
+
function generateAttributeBuffer(type, value) {
|
|
702
|
+
let attributeBuffer;
|
|
703
|
+
switch (type) {
|
|
704
|
+
case OBJECT_ID_TYPE:
|
|
705
|
+
case SHORT_INT_TYPE:
|
|
706
|
+
attributeBuffer = generateShortIntegerAttributeBuffer(value);
|
|
707
|
+
break;
|
|
708
|
+
case DOUBLE_TYPE:
|
|
709
|
+
attributeBuffer = generateDoubleAttributeBuffer(value);
|
|
710
|
+
break;
|
|
711
|
+
case STRING_TYPE:
|
|
712
|
+
attributeBuffer = generateStringAttributeBuffer(value);
|
|
713
|
+
break;
|
|
714
|
+
default:
|
|
715
|
+
attributeBuffer = generateStringAttributeBuffer(value);
|
|
716
|
+
}
|
|
717
|
+
return attributeBuffer;
|
|
718
|
+
}
|
|
719
|
+
function getAttributeType(key, attributeStorageInfo) {
|
|
720
|
+
const attribute = attributeStorageInfo.find(attr => attr.name === key);
|
|
721
|
+
return attribute.attributeValues.valueType;
|
|
722
|
+
}
|
|
723
|
+
function generateShortIntegerAttributeBuffer(featureIds) {
|
|
724
|
+
const count = new Uint32Array([featureIds.length]);
|
|
725
|
+
const valuesArray = new Uint32Array(featureIds);
|
|
726
|
+
return concatenateArrayBuffers(count.buffer, valuesArray.buffer);
|
|
727
|
+
}
|
|
728
|
+
function generateDoubleAttributeBuffer(featureIds) {
|
|
729
|
+
const count = new Uint32Array([featureIds.length]);
|
|
730
|
+
const padding = new Uint8Array(4);
|
|
731
|
+
const valuesArray = new Float64Array(featureIds);
|
|
732
|
+
return concatenateArrayBuffers(count.buffer, padding.buffer, valuesArray.buffer);
|
|
733
|
+
}
|
|
734
|
+
function generateStringAttributeBuffer(batchAttributes) {
|
|
735
|
+
const stringCountArray = new Uint32Array([batchAttributes.length]);
|
|
736
|
+
let totalNumberOfBytes = 0;
|
|
737
|
+
const stringSizesArray = new Uint32Array(batchAttributes.length);
|
|
738
|
+
const stringBufferArray = [];
|
|
739
|
+
for (let index = 0; index < batchAttributes.length; index++) {
|
|
740
|
+
const currentString = "".concat(String(batchAttributes[index]), "\0");
|
|
741
|
+
const currentStringBuffer = Buffer.from(currentString);
|
|
742
|
+
const currentStringSize = currentStringBuffer.length;
|
|
743
|
+
totalNumberOfBytes += currentStringSize;
|
|
744
|
+
stringSizesArray[index] = currentStringSize;
|
|
745
|
+
stringBufferArray.push(currentStringBuffer);
|
|
746
|
+
}
|
|
747
|
+
const totalBytes = new Uint32Array([totalNumberOfBytes]);
|
|
748
|
+
return concatenateArrayBuffers(stringCountArray.buffer, totalBytes.buffer, stringSizesArray.buffer, ...stringBufferArray);
|
|
749
|
+
}
|
|
750
|
+
function generateBigUint64Array(featureIds) {
|
|
751
|
+
const typedFeatureIds = new BigUint64Array(featureIds.length);
|
|
752
|
+
for (let index = 0; index < featureIds.length; index++) {
|
|
753
|
+
typedFeatureIds[index] = BigInt(featureIds[index]);
|
|
754
|
+
}
|
|
755
|
+
return typedFeatureIds;
|
|
756
|
+
}
|
|
757
|
+
async function generateCompressedGeometry(vertexCount, convertedAttributes, attributes, dracoWorkerSoure) {
|
|
758
|
+
const {
|
|
759
|
+
positions,
|
|
760
|
+
normals,
|
|
761
|
+
texCoords,
|
|
762
|
+
colors,
|
|
763
|
+
uvRegions,
|
|
764
|
+
featureIds,
|
|
765
|
+
faceRange
|
|
766
|
+
} = attributes;
|
|
767
|
+
const indices = new Uint32Array(vertexCount);
|
|
768
|
+
for (let index = 0; index < indices.length; index++) {
|
|
769
|
+
indices.set([index], index);
|
|
770
|
+
}
|
|
771
|
+
const featureIndices = new Uint32Array(convertedAttributes.featureIndices.length ? convertedAttributes.featureIndices : vertexCount);
|
|
772
|
+
const featureIndex = generateFeatureIndexAttribute(featureIndices, faceRange);
|
|
773
|
+
const compressedAttributes = {
|
|
774
|
+
positions,
|
|
775
|
+
normals,
|
|
776
|
+
colors,
|
|
777
|
+
'feature-index': featureIndex
|
|
778
|
+
};
|
|
779
|
+
if (texCoords.length) {
|
|
780
|
+
compressedAttributes.texCoords = texCoords;
|
|
781
|
+
}
|
|
782
|
+
const attributesMetadata = {
|
|
783
|
+
'feature-index': {
|
|
784
|
+
'i3s-attribute-type': 'feature-index',
|
|
785
|
+
'i3s-feature-ids': new Int32Array(featureIds)
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
if (uvRegions.length) {
|
|
789
|
+
compressedAttributes['uv-region'] = uvRegions;
|
|
790
|
+
attributesMetadata['uv-region'] = {
|
|
791
|
+
'i3s-attribute-type': 'uv-region'
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
return encode({
|
|
795
|
+
attributes: compressedAttributes,
|
|
796
|
+
indices
|
|
797
|
+
}, DracoWriterWorker, {
|
|
798
|
+
...DracoWriterWorker.options,
|
|
799
|
+
source: dracoWorkerSoure,
|
|
800
|
+
reuseWorkers: true,
|
|
801
|
+
_nodeWorkers: true,
|
|
802
|
+
draco: {
|
|
803
|
+
method: 'MESH_SEQUENTIAL_ENCODING',
|
|
804
|
+
attributesMetadata
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
function generateFeatureIndexAttribute(featureIndex, faceRange) {
|
|
809
|
+
const orderedFeatureIndices = new Uint32Array(featureIndex.length);
|
|
810
|
+
let fillIndex = 0;
|
|
811
|
+
let startIndex = 0;
|
|
812
|
+
for (let index = 1; index < faceRange.length; index += 2) {
|
|
813
|
+
const endIndex = (faceRange[index] + 1) * VALUES_PER_VERTEX;
|
|
814
|
+
orderedFeatureIndices.fill(fillIndex, startIndex, endIndex);
|
|
815
|
+
fillIndex++;
|
|
816
|
+
startIndex = endIndex + 1;
|
|
817
|
+
}
|
|
818
|
+
return orderedFeatureIndices;
|
|
819
|
+
}
|
|
820
|
+
export function getPropertyTable(tileContent) {
|
|
821
|
+
const batchTableJson = tileContent === null || tileContent === void 0 ? void 0 : tileContent.batchTableJson;
|
|
822
|
+
if (batchTableJson) {
|
|
823
|
+
return batchTableJson;
|
|
824
|
+
}
|
|
825
|
+
const {
|
|
826
|
+
extensionName,
|
|
827
|
+
extension
|
|
828
|
+
} = getPropertyTableExtension(tileContent);
|
|
829
|
+
switch (extensionName) {
|
|
830
|
+
case EXT_MESH_FEATURES:
|
|
831
|
+
{
|
|
832
|
+
console.warn('The I3S converter does not yet support the EXT_mesh_features extension');
|
|
833
|
+
return null;
|
|
834
|
+
}
|
|
835
|
+
case EXT_FEATURE_METADATA:
|
|
836
|
+
{
|
|
837
|
+
return getPropertyTableFromExtFeatureMetadata(extension);
|
|
838
|
+
}
|
|
839
|
+
default:
|
|
840
|
+
return null;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
function getPropertyTableExtension(tileContent) {
|
|
844
|
+
var _tileContent$gltf3, _tileContent$gltf5, _tileContent$gltf5$ex;
|
|
845
|
+
const extensionsWithPropertyTables = [EXT_FEATURE_METADATA, EXT_MESH_FEATURES];
|
|
846
|
+
const extensionsUsed = tileContent === null || tileContent === void 0 ? void 0 : (_tileContent$gltf3 = tileContent.gltf) === null || _tileContent$gltf3 === void 0 ? void 0 : _tileContent$gltf3.extensionsUsed;
|
|
847
|
+
if (!extensionsUsed) {
|
|
848
|
+
return {
|
|
849
|
+
extensionName: null,
|
|
850
|
+
extension: null
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
let extensionName = '';
|
|
854
|
+
for (const extensionItem of (tileContent === null || tileContent === void 0 ? void 0 : (_tileContent$gltf4 = tileContent.gltf) === null || _tileContent$gltf4 === void 0 ? void 0 : _tileContent$gltf4.extensionsUsed) || []) {
|
|
855
|
+
var _tileContent$gltf4;
|
|
856
|
+
if (extensionsWithPropertyTables.includes(extensionItem)) {
|
|
857
|
+
extensionName = extensionItem;
|
|
858
|
+
break;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
const extension = tileContent === null || tileContent === void 0 ? void 0 : (_tileContent$gltf5 = tileContent.gltf) === null || _tileContent$gltf5 === void 0 ? void 0 : (_tileContent$gltf5$ex = _tileContent$gltf5.extensions) === null || _tileContent$gltf5$ex === void 0 ? void 0 : _tileContent$gltf5$ex[extensionName];
|
|
862
|
+
return {
|
|
863
|
+
extensionName,
|
|
864
|
+
extension
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
function getPropertyTableFromExtFeatureMetadata(extension) {
|
|
868
|
+
if (extension !== null && extension !== void 0 && extension.featureTextures) {
|
|
869
|
+
console.warn('The I3S converter does not yet support the EXT_feature_metadata feature textures');
|
|
870
|
+
return null;
|
|
871
|
+
}
|
|
872
|
+
if (extension !== null && extension !== void 0 && extension.featureTables) {
|
|
873
|
+
var _Object$keys;
|
|
874
|
+
const firstFeatureTableName = (_Object$keys = Object.keys(extension.featureTables)) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0];
|
|
875
|
+
if (firstFeatureTableName) {
|
|
876
|
+
const featureTable = extension === null || extension === void 0 ? void 0 : extension.featureTables[firstFeatureTableName];
|
|
877
|
+
const propertyTable = {};
|
|
878
|
+
for (const propertyName in featureTable.properties) {
|
|
879
|
+
propertyTable[propertyName] = featureTable.properties[propertyName].data;
|
|
880
|
+
}
|
|
881
|
+
return propertyTable;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
console.warn("The I3S converter couldn't handle EXT_feature_metadata extension");
|
|
885
|
+
return null;
|
|
886
|
+
}
|
|
887
|
+
//# sourceMappingURL=geometry-converter.js.map
|