@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
|
@@ -1,915 +0,0 @@
|
|
|
1
|
-
import {Vector3, Matrix4, Vector4} from '@math.gl/core';
|
|
2
|
-
import {Ellipsoid} from '@math.gl/geospatial';
|
|
3
|
-
|
|
4
|
-
import {DracoWriter} from '@loaders.gl/draco';
|
|
5
|
-
import {encode, assert} from '@loaders.gl/core';
|
|
6
|
-
import {concatenateArrayBuffers, concatenateTypedArrays} from '@loaders.gl/loader-utils';
|
|
7
|
-
import md5 from 'md5';
|
|
8
|
-
import {generateAttributes} from './geometry-attributes';
|
|
9
|
-
|
|
10
|
-
const VALUES_PER_VERTEX = 3;
|
|
11
|
-
const VALUES_PER_TEX_COORD = 2;
|
|
12
|
-
const VALUES_PER_COLOR_ELEMENT = 4;
|
|
13
|
-
|
|
14
|
-
const STRING_TYPE = 'string';
|
|
15
|
-
const SHORT_INT_TYPE = 'Int32';
|
|
16
|
-
const DOUBLE_TYPE = 'Float64';
|
|
17
|
-
const OBJECT_ID_TYPE = 'Oid32';
|
|
18
|
-
/*
|
|
19
|
-
* 'CUSTOM_ATTRIBUTE_2' - Attribute name which includes batch info and used by New York map.
|
|
20
|
-
* _BATCHID - Default attribute name which includes batch info.
|
|
21
|
-
* BATCHID - Legacy attribute name which includes batch info.
|
|
22
|
-
*/
|
|
23
|
-
const BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BATCHID'];
|
|
24
|
-
|
|
25
|
-
export default async function convertB3dmToI3sGeometry(
|
|
26
|
-
tileContent,
|
|
27
|
-
nodeId,
|
|
28
|
-
featuresHashArray,
|
|
29
|
-
attributeStorageInfo,
|
|
30
|
-
draco
|
|
31
|
-
) {
|
|
32
|
-
const materialAndTextureList = convertMaterials(tileContent);
|
|
33
|
-
const convertedAttributesMap = convertAttributes(tileContent);
|
|
34
|
-
|
|
35
|
-
if (convertedAttributesMap.has('default')) {
|
|
36
|
-
materialAndTextureList.push({
|
|
37
|
-
material: getDefaultMaterial()
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const result = [];
|
|
42
|
-
let nodesCounter = nodeId;
|
|
43
|
-
let {materials = []} = tileContent.gltf;
|
|
44
|
-
if (!materials.length === 0) {
|
|
45
|
-
materials.push({id: 'default'});
|
|
46
|
-
}
|
|
47
|
-
for (let i = 0; i < materials.length; i++) {
|
|
48
|
-
const sourceMaterial = materials[i];
|
|
49
|
-
if (!convertedAttributesMap.has(sourceMaterial.id)) {
|
|
50
|
-
continue; // eslint-disable-line no-continue
|
|
51
|
-
}
|
|
52
|
-
const convertedAttributes = convertedAttributesMap.get(sourceMaterial.id);
|
|
53
|
-
const {material, texture} = materialAndTextureList[i];
|
|
54
|
-
result.push(
|
|
55
|
-
await _makeNodeResources({
|
|
56
|
-
convertedAttributes,
|
|
57
|
-
material,
|
|
58
|
-
texture,
|
|
59
|
-
tileContent,
|
|
60
|
-
nodeId: nodesCounter,
|
|
61
|
-
featuresHashArray,
|
|
62
|
-
attributeStorageInfo,
|
|
63
|
-
draco
|
|
64
|
-
})
|
|
65
|
-
);
|
|
66
|
-
nodesCounter++;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (!result.length) {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
return result;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async function _makeNodeResources({
|
|
76
|
-
convertedAttributes,
|
|
77
|
-
material,
|
|
78
|
-
texture,
|
|
79
|
-
tileContent,
|
|
80
|
-
nodeId,
|
|
81
|
-
featuresHashArray,
|
|
82
|
-
attributeStorageInfo,
|
|
83
|
-
draco
|
|
84
|
-
}) {
|
|
85
|
-
const vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;
|
|
86
|
-
const triangleCount = vertexCount / 3;
|
|
87
|
-
const {faceRange, featureIds, positions, normals, colors, texCoords, featureCount} =
|
|
88
|
-
generateAttributes({triangleCount, ...convertedAttributes});
|
|
89
|
-
|
|
90
|
-
if (tileContent.batchTableJson) {
|
|
91
|
-
makeFeatureIdsUnique(
|
|
92
|
-
featureIds,
|
|
93
|
-
convertedAttributes.featureIndices,
|
|
94
|
-
featuresHashArray,
|
|
95
|
-
tileContent.batchTableJson
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const header = new Uint32Array(2);
|
|
100
|
-
const typedFeatureIds = generateBigUint64Array(featureIds);
|
|
101
|
-
|
|
102
|
-
header.set([vertexCount, featureCount], 0);
|
|
103
|
-
const fileBuffer = new Uint8Array(
|
|
104
|
-
concatenateArrayBuffers(
|
|
105
|
-
header.buffer,
|
|
106
|
-
positions.buffer,
|
|
107
|
-
normals.buffer,
|
|
108
|
-
texture ? texCoords.buffer : new ArrayBuffer(0),
|
|
109
|
-
colors.buffer,
|
|
110
|
-
typedFeatureIds.buffer,
|
|
111
|
-
faceRange.buffer
|
|
112
|
-
)
|
|
113
|
-
);
|
|
114
|
-
const compressedGeometry = draco
|
|
115
|
-
? await generateCompressedGeometry(vertexCount, convertedAttributes, {
|
|
116
|
-
positions,
|
|
117
|
-
normals,
|
|
118
|
-
texCoords: texture ? texCoords : new Float32Array(0),
|
|
119
|
-
colors,
|
|
120
|
-
featureIds,
|
|
121
|
-
faceRange
|
|
122
|
-
})
|
|
123
|
-
: null;
|
|
124
|
-
|
|
125
|
-
const attributes = convertBatchTableToAttributeBuffers(
|
|
126
|
-
tileContent.batchTableJson,
|
|
127
|
-
featureIds,
|
|
128
|
-
attributeStorageInfo
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
return {
|
|
132
|
-
geometry: fileBuffer,
|
|
133
|
-
compressedGeometry,
|
|
134
|
-
texture,
|
|
135
|
-
sharedResources: getSharedResources(tileContent, nodeId),
|
|
136
|
-
meshMaterial: material,
|
|
137
|
-
vertexCount,
|
|
138
|
-
attributes,
|
|
139
|
-
featureCount
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Convert attributes from the gltf nodes tree to i3s plain geometry
|
|
145
|
-
* @param {Object} tileContent - 3d tile content
|
|
146
|
-
* @returns {Map}
|
|
147
|
-
* Map<{
|
|
148
|
-
* positions: Float32Array,
|
|
149
|
-
* normals: Float32Array,
|
|
150
|
-
* colors: Uint8Array,
|
|
151
|
-
* texCoords: Float32Array
|
|
152
|
-
* }>
|
|
153
|
-
* @todo implement colors support (if applicable for gltf format)
|
|
154
|
-
*/
|
|
155
|
-
function convertAttributes(tileContent) {
|
|
156
|
-
const attributesMap = new Map();
|
|
157
|
-
|
|
158
|
-
for (const material of tileContent.gltf.materials || [{id: 'default'}]) {
|
|
159
|
-
attributesMap.set(material.id, {
|
|
160
|
-
positions: new Float32Array(0),
|
|
161
|
-
normals: new Float32Array(0),
|
|
162
|
-
texCoords: new Float32Array(0),
|
|
163
|
-
colors: new Uint8Array(0),
|
|
164
|
-
featureIndices: []
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const nodes = (tileContent.gltf.scene || tileContent.gltf.scenes?.[0] || tileContent.gltf).nodes;
|
|
169
|
-
convertNodes(nodes, tileContent, attributesMap);
|
|
170
|
-
|
|
171
|
-
for (const attrKey of attributesMap.keys()) {
|
|
172
|
-
const attributes = attributesMap.get(attrKey);
|
|
173
|
-
if (attributes.positions.length === 0) {
|
|
174
|
-
attributesMap.delete(attrKey);
|
|
175
|
-
continue; // eslint-disable-line no-continue
|
|
176
|
-
}
|
|
177
|
-
const vertexCount = attributes.positions.length / VALUES_PER_VERTEX;
|
|
178
|
-
if (!attributes.colors.length) {
|
|
179
|
-
attributes.colors = new Uint8Array(vertexCount * VALUES_PER_COLOR_ELEMENT);
|
|
180
|
-
for (let index = 0; index < attributes.colors.length; index += 4) {
|
|
181
|
-
attributes.colors.set([255, 255, 255, 255], index);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
if (!attributes.texCoords.length) {
|
|
185
|
-
attributes.texCoords = new Float32Array(vertexCount * VALUES_PER_TEX_COORD);
|
|
186
|
-
for (let index = 0; index < attributes.texCoords.length; index += 2) {
|
|
187
|
-
attributes.texCoords.set([1, 1], index);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
attributes.featureIndices = attributes.featureIndices.reduce((acc, value) => acc.concat(value));
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return attributesMap;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Gltf has hierarchical structure of nodes. This function converts nodes starting from those which are in gltf scene object.
|
|
198
|
-
* The goal is applying tranformation matrix for all children. Functions "convertNodes" and "convertNode" work together recursively.
|
|
199
|
-
* @param {Object[]} nodes - gltf nodes array
|
|
200
|
-
* @param {Object} tileContent - 3d tile content
|
|
201
|
-
* @param {Map} attributesMap Map<{positions: Float32Array, normals: Float32Array, texCoords: Float32Array, colors: UInt8Array, featureIndices: Array}> - for recursive concatenation of
|
|
202
|
-
* attributes
|
|
203
|
-
* @param {Matrix4} matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices
|
|
204
|
-
* @returns {void}
|
|
205
|
-
*/
|
|
206
|
-
function convertNodes(
|
|
207
|
-
nodes,
|
|
208
|
-
tileContent,
|
|
209
|
-
attributesMap,
|
|
210
|
-
matrix = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])
|
|
211
|
-
) {
|
|
212
|
-
if (nodes) {
|
|
213
|
-
for (const node of nodes) {
|
|
214
|
-
convertNode(node, tileContent, attributesMap, matrix);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Convert all primitives of node and all children nodes
|
|
221
|
-
* @param {Object} node - gltf node
|
|
222
|
-
* @param {Object} tileContent - 3d tile content
|
|
223
|
-
* @param {Map} attributesMap Map<{positions: Float32Array, normals: Float32Array, texCoords: Float32Array, colors: Uint8Array, featureIndices: Array}> - for recursive concatenation of
|
|
224
|
-
* attributes
|
|
225
|
-
* @param {Matrix4} matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices
|
|
226
|
-
* @todo: optimize arrays concatenation
|
|
227
|
-
*/
|
|
228
|
-
function convertNode(
|
|
229
|
-
node,
|
|
230
|
-
tileContent,
|
|
231
|
-
attributesMap,
|
|
232
|
-
matrix = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])
|
|
233
|
-
) {
|
|
234
|
-
const nodeMatrix = node.matrix;
|
|
235
|
-
const compositeMatrix = nodeMatrix ? matrix.multiplyRight(nodeMatrix) : matrix;
|
|
236
|
-
|
|
237
|
-
const mesh = node.mesh;
|
|
238
|
-
if (mesh) {
|
|
239
|
-
convertMesh(mesh, tileContent, attributesMap, compositeMatrix);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
convertNodes(node.children, tileContent, attributesMap, compositeMatrix);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Convert all primitives of node and all children nodes
|
|
247
|
-
* @param {Object} mesh - gltf node
|
|
248
|
-
* @param {Object} content - 3d tile content
|
|
249
|
-
* @param {Map} attributesMap Map<{positions: Float32Array, normals: Float32Array, texCoords: Float32Array, colors: Uint8Array, featureIndices: Array}> - for recursive concatenation of
|
|
250
|
-
* attributes
|
|
251
|
-
* @param {Matrix4} matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices
|
|
252
|
-
* @todo: optimize arrays concatenation
|
|
253
|
-
*/
|
|
254
|
-
function convertMesh(
|
|
255
|
-
mesh,
|
|
256
|
-
content,
|
|
257
|
-
attributesMap,
|
|
258
|
-
matrix = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])
|
|
259
|
-
) {
|
|
260
|
-
for (const primitive of mesh.primitives) {
|
|
261
|
-
let outputAttributes = null;
|
|
262
|
-
if (primitive.material) {
|
|
263
|
-
outputAttributes = attributesMap.get(primitive.material.id);
|
|
264
|
-
} else if (attributesMap.has('default')) {
|
|
265
|
-
outputAttributes = attributesMap.get('default');
|
|
266
|
-
}
|
|
267
|
-
assert(outputAttributes !== null, 'Primitive - material mapping failed');
|
|
268
|
-
const attributes = primitive.attributes;
|
|
269
|
-
|
|
270
|
-
outputAttributes.positions = concatenateTypedArrays(
|
|
271
|
-
outputAttributes.positions,
|
|
272
|
-
transformVertexArray({
|
|
273
|
-
vertices: attributes.POSITION.value,
|
|
274
|
-
cartographicOrigin: content.cartographicOrigin,
|
|
275
|
-
cartesianModelMatrix: content.cartesianModelMatrix,
|
|
276
|
-
nodeMatrix: matrix,
|
|
277
|
-
indices: primitive.indices.value,
|
|
278
|
-
attributeSpecificTransformation: transformVertexPositions
|
|
279
|
-
})
|
|
280
|
-
);
|
|
281
|
-
outputAttributes.normals = concatenateTypedArrays(
|
|
282
|
-
outputAttributes.normals,
|
|
283
|
-
transformVertexArray({
|
|
284
|
-
vertices: attributes.NORMAL && attributes.NORMAL.value,
|
|
285
|
-
cartographicOrigin: content.cartographicOrigin,
|
|
286
|
-
cartesianModelMatrix: content.cartesianModelMatrix,
|
|
287
|
-
nodeMatrix: matrix,
|
|
288
|
-
indices: primitive.indices.value,
|
|
289
|
-
attributeSpecificTransformation: transformVertexNormals
|
|
290
|
-
})
|
|
291
|
-
);
|
|
292
|
-
outputAttributes.texCoords = concatenateTypedArrays(
|
|
293
|
-
outputAttributes.texCoords,
|
|
294
|
-
flattenTexCoords(
|
|
295
|
-
attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value,
|
|
296
|
-
primitive.indices.value
|
|
297
|
-
)
|
|
298
|
-
);
|
|
299
|
-
|
|
300
|
-
outputAttributes.colors = concatenateTypedArrays(
|
|
301
|
-
outputAttributes.colors,
|
|
302
|
-
flattenColors(attributes.COLOR_0, primitive.indices.value)
|
|
303
|
-
);
|
|
304
|
-
|
|
305
|
-
outputAttributes.featureIndices.push(
|
|
306
|
-
flattenBatchIds(getBatchIdsByAttributeName(attributes), primitive.indices.value)
|
|
307
|
-
);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Convert vertices attributes (POSITIONS or NORMALS) to i3s compatible format
|
|
313
|
-
* @param {object} args - source tile (3DTile)
|
|
314
|
-
* @param {Float32Array} args.vertices - gltf primitive POSITION or NORMAL attribute
|
|
315
|
-
* @param {Object} args.cartographicOrigin - cartographic origin coordinates
|
|
316
|
-
* @param {Object} args.cartesianModelMatrix - a cartesian model matrix to transform coordnates from cartesian to cartographic format
|
|
317
|
-
* @param {Matrix4} args.nodeMatrix - a gltf node transformation matrix - cumulative transformation matrix formed from all parent node matrices
|
|
318
|
-
* @param {Uint8Array} args.indices - gltf primitive indices
|
|
319
|
-
* @param {Function} args.attributeSpecificTransformation - function to do attribute - specific transformations
|
|
320
|
-
* @returns {Float32Array}
|
|
321
|
-
*/
|
|
322
|
-
function transformVertexArray(args) {
|
|
323
|
-
const {vertices, indices, attributeSpecificTransformation} = args;
|
|
324
|
-
const newVertices = new Float32Array(indices.length * VALUES_PER_VERTEX);
|
|
325
|
-
if (!vertices) {
|
|
326
|
-
return newVertices;
|
|
327
|
-
}
|
|
328
|
-
for (let i = 0; i < indices.length; i++) {
|
|
329
|
-
const coordIndex = indices[i] * VALUES_PER_VERTEX;
|
|
330
|
-
const vertex = vertices.subarray(coordIndex, coordIndex + VALUES_PER_VERTEX);
|
|
331
|
-
let vertexVector = new Vector3(Array.from(vertex));
|
|
332
|
-
|
|
333
|
-
vertexVector = attributeSpecificTransformation(vertexVector, args);
|
|
334
|
-
|
|
335
|
-
newVertices[i * VALUES_PER_VERTEX] = vertexVector.x;
|
|
336
|
-
newVertices[i * VALUES_PER_VERTEX + 1] = vertexVector.y;
|
|
337
|
-
newVertices[i * VALUES_PER_VERTEX + 2] = vertexVector.z;
|
|
338
|
-
}
|
|
339
|
-
return newVertices;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
function transformVertexPositions(vertexVector, calleeArgs) {
|
|
343
|
-
const {cartesianModelMatrix, cartographicOrigin, nodeMatrix} = calleeArgs;
|
|
344
|
-
|
|
345
|
-
if (nodeMatrix) {
|
|
346
|
-
vertexVector = vertexVector.transform(nodeMatrix);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
vertexVector = vertexVector.transform(cartesianModelMatrix);
|
|
350
|
-
Ellipsoid.WGS84.cartesianToCartographic(
|
|
351
|
-
[vertexVector[0], vertexVector[1], vertexVector[2]],
|
|
352
|
-
vertexVector
|
|
353
|
-
);
|
|
354
|
-
vertexVector = vertexVector.subtract(cartographicOrigin);
|
|
355
|
-
return vertexVector;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
function transformVertexNormals(vertexVector, calleeArgs) {
|
|
359
|
-
const {cartesianModelMatrix, nodeMatrix} = calleeArgs;
|
|
360
|
-
|
|
361
|
-
if (nodeMatrix) {
|
|
362
|
-
vertexVector = vertexVector.transformAsVector(nodeMatrix);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
vertexVector = vertexVector.transformAsVector(cartesianModelMatrix);
|
|
366
|
-
return vertexVector;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Convert uv0 (texture coordinates) from coords based on indices to plain arrays, compatible with i3s
|
|
371
|
-
* @param {Float32Array} texCoords - gltf primitive TEXCOORD_0 attribute
|
|
372
|
-
* @param {Uint8Array} indices - gltf primitive indices
|
|
373
|
-
* @returns {Float32Array}
|
|
374
|
-
*/
|
|
375
|
-
function flattenTexCoords(texCoords, indices) {
|
|
376
|
-
if (!texCoords) {
|
|
377
|
-
return new Float32Array(0);
|
|
378
|
-
}
|
|
379
|
-
const newTexCoords = new Float32Array(indices.length * VALUES_PER_TEX_COORD);
|
|
380
|
-
for (let i = 0; i < indices.length; i++) {
|
|
381
|
-
const coordIndex = indices[i] * VALUES_PER_TEX_COORD;
|
|
382
|
-
const texCoord = texCoords.subarray(coordIndex, coordIndex + VALUES_PER_TEX_COORD);
|
|
383
|
-
newTexCoords[i * VALUES_PER_TEX_COORD] = texCoord[0];
|
|
384
|
-
newTexCoords[i * VALUES_PER_TEX_COORD + 1] = texCoord[1];
|
|
385
|
-
}
|
|
386
|
-
return newTexCoords;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* Convert color from COLOR_0 based on indices to plain arrays, compatible with i3s
|
|
391
|
-
* @param {object} colorsAttribute - gltf primitive COLOR_0 attribute
|
|
392
|
-
* @param {Uint8Array} indices - gltf primitive indices
|
|
393
|
-
* @returns {Uint8Array}
|
|
394
|
-
*/
|
|
395
|
-
function flattenColors(colorsAttribute, indices) {
|
|
396
|
-
if (!colorsAttribute) {
|
|
397
|
-
return new Uint8Array(0);
|
|
398
|
-
}
|
|
399
|
-
const components = colorsAttribute.components;
|
|
400
|
-
const colors = colorsAttribute.value;
|
|
401
|
-
const newColors = new Uint8Array(indices.length * components);
|
|
402
|
-
for (let i = 0; i < indices.length; i++) {
|
|
403
|
-
const colorIndex = indices[i] * components;
|
|
404
|
-
const color = colors.subarray(colorIndex, colorIndex + components);
|
|
405
|
-
const colorUint8 = new Uint8Array(components);
|
|
406
|
-
for (let j = 0; j < color.length; j++) {
|
|
407
|
-
colorUint8[j] = color[j] * 255;
|
|
408
|
-
}
|
|
409
|
-
newColors.set(colorUint8, i * components);
|
|
410
|
-
}
|
|
411
|
-
return newColors;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Flatten batchedIds list based on indices to right ordered array, compatible with i3s
|
|
416
|
-
* @param {Array} batchedIds - gltf primitive
|
|
417
|
-
* @param {Uint8Array} indices - gltf primitive indices
|
|
418
|
-
* @returns {Array}
|
|
419
|
-
*/
|
|
420
|
-
function flattenBatchIds(batchedIds, indices) {
|
|
421
|
-
if (!batchedIds.length || !indices.length) {
|
|
422
|
-
return [];
|
|
423
|
-
}
|
|
424
|
-
const newBatchIds = [];
|
|
425
|
-
for (let i = 0; i < indices.length; i++) {
|
|
426
|
-
const coordIndex = indices[i];
|
|
427
|
-
newBatchIds.push(batchedIds[coordIndex]);
|
|
428
|
-
}
|
|
429
|
-
return newBatchIds;
|
|
430
|
-
}
|
|
431
|
-
/**
|
|
432
|
-
* Return batchIds based on possible attribute names for different kind of maps.
|
|
433
|
-
* @param {Object} attributes {attributeName: Float32Array}
|
|
434
|
-
* @returns {Array}
|
|
435
|
-
*/
|
|
436
|
-
function getBatchIdsByAttributeName(attributes) {
|
|
437
|
-
let batchIds = [];
|
|
438
|
-
|
|
439
|
-
for (let index = 0; index < BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES.length; index++) {
|
|
440
|
-
const possibleBatchIdAttributeName = BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES[index];
|
|
441
|
-
if (
|
|
442
|
-
attributes[possibleBatchIdAttributeName] &&
|
|
443
|
-
attributes[possibleBatchIdAttributeName].value
|
|
444
|
-
) {
|
|
445
|
-
batchIds = attributes[possibleBatchIdAttributeName].value;
|
|
446
|
-
break;
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
return batchIds;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
function convertMaterials(tileContent) {
|
|
454
|
-
const result = [];
|
|
455
|
-
const sourceMaterials = tileContent.gltf.materials || [];
|
|
456
|
-
for (const sourceMaterial of sourceMaterials) {
|
|
457
|
-
result.push(convertMaterial(sourceMaterial));
|
|
458
|
-
}
|
|
459
|
-
return result;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
* Convert texture and material from gltf 2.0 material object
|
|
464
|
-
* @param {Object} sourceMaterial - material object
|
|
465
|
-
* @returns {Object}
|
|
466
|
-
*/
|
|
467
|
-
function convertMaterial(sourceMaterial) {
|
|
468
|
-
const material = {
|
|
469
|
-
doubleSided: sourceMaterial.doubleSided,
|
|
470
|
-
emissiveFactor: sourceMaterial.emissiveFactor.map((c) => Math.round(c * 255)),
|
|
471
|
-
// It is in upper case in GLTF: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#alpha-coverage
|
|
472
|
-
// But it is in lower case in I3S: https://github.com/Esri/i3s-spec/blob/master/docs/1.7/materialDefinitions.cmn.md
|
|
473
|
-
alphaMode: (sourceMaterial.alphaMode || 'OPAQUE').toLowerCase(),
|
|
474
|
-
pbrMetallicRoughness: {
|
|
475
|
-
roughnessFactor: sourceMaterial.pbrMetallicRoughness.roughnessFactor,
|
|
476
|
-
metallicFactor: sourceMaterial.pbrMetallicRoughness.metallicFactor
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
let texture;
|
|
481
|
-
if (sourceMaterial.pbrMetallicRoughness.baseColorTexture) {
|
|
482
|
-
texture = sourceMaterial.pbrMetallicRoughness.baseColorTexture.texture.source;
|
|
483
|
-
material.pbrMetallicRoughness.baseColorTexture = {
|
|
484
|
-
textureSetDefinitionId: 0
|
|
485
|
-
};
|
|
486
|
-
} else if (sourceMaterial.emissiveTexture) {
|
|
487
|
-
texture = sourceMaterial.emissiveTexture.texture.source;
|
|
488
|
-
// ArcGIS webscene doesn't show emissiveTexture but shows baseColorTexture
|
|
489
|
-
material.pbrMetallicRoughness.baseColorTexture = {
|
|
490
|
-
textureSetDefinitionId: 0
|
|
491
|
-
};
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
if (!texture) {
|
|
495
|
-
// Should use default baseColorFactor if it is not present in source material
|
|
496
|
-
// https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-pbrmetallicroughness
|
|
497
|
-
const baseColorFactor = sourceMaterial.pbrMetallicRoughness.baseColorFactor;
|
|
498
|
-
material.pbrMetallicRoughness.baseColorFactor =
|
|
499
|
-
(baseColorFactor && baseColorFactor.map((c) => Math.round(c * 255))) || undefined;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
return {material, texture};
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
function getDefaultMaterial() {
|
|
506
|
-
return {
|
|
507
|
-
alphaMode: 'opaque',
|
|
508
|
-
pbrMetallicRoughness: {}
|
|
509
|
-
};
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* Form "sharedResources" from gltf materials array
|
|
514
|
-
* @param {Object} tileContent - 3d tile content
|
|
515
|
-
* @returns {Object} {materialDefinitionInfos: Object[], textureDefinitionInfos: Object[]} -
|
|
516
|
-
* 2 arrays in format of i3s sharedResources data https://github.com/Esri/i3s-spec/blob/master/docs/1.7/sharedResource.cmn.md
|
|
517
|
-
*/
|
|
518
|
-
function getSharedResources(tileContent, nodeId) {
|
|
519
|
-
const gltfMaterials = tileContent.gltf.materials;
|
|
520
|
-
const i3sResources = {};
|
|
521
|
-
|
|
522
|
-
if (!gltfMaterials || !gltfMaterials.length) {
|
|
523
|
-
return i3sResources;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
i3sResources.materialDefinitionInfos = [];
|
|
527
|
-
for (const gltfMaterial of gltfMaterials) {
|
|
528
|
-
const {materialDefinitionInfo, textureDefinitionInfo} = convertGLTFMaterialToI3sSharedResources(
|
|
529
|
-
gltfMaterial,
|
|
530
|
-
nodeId
|
|
531
|
-
);
|
|
532
|
-
i3sResources.materialDefinitionInfos.push(materialDefinitionInfo);
|
|
533
|
-
if (textureDefinitionInfo) {
|
|
534
|
-
i3sResources.textureDefinitionInfos = i3sResources.textureDefinitionInfos || [];
|
|
535
|
-
i3sResources.textureDefinitionInfos.push(textureDefinitionInfo);
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
return i3sResources;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
/**
|
|
542
|
-
* Convert gltf material into I3S sharedResources data
|
|
543
|
-
* @param {Object} gltfMaterial - gltf material data
|
|
544
|
-
* @returns {Object} - Couple {materialDefinitionInfo, textureDefinitionInfo} extracted from gltf material data
|
|
545
|
-
*/
|
|
546
|
-
function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
|
|
547
|
-
const texture =
|
|
548
|
-
gltfMaterial.pbrMetallicRoughness.baseColorTexture || gltfMaterial.emissiveTexture;
|
|
549
|
-
let textureDefinitionInfo = null;
|
|
550
|
-
if (texture) {
|
|
551
|
-
textureDefinitionInfo = extractSharedResourcesTextureInfo(texture.texture, nodeId);
|
|
552
|
-
}
|
|
553
|
-
const {baseColorFactor, metallicFactor} = gltfMaterial.pbrMetallicRoughness;
|
|
554
|
-
let colorFactor = baseColorFactor;
|
|
555
|
-
// If alpha channel is 0 try to get emissive factor from gltf material.
|
|
556
|
-
if ((!baseColorFactor || baseColorFactor[3] === 0) && gltfMaterial.emissiveFactor) {
|
|
557
|
-
colorFactor = gltfMaterial.emissiveFactor;
|
|
558
|
-
colorFactor[3] = colorFactor[3] || 1;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
return {
|
|
562
|
-
materialDefinitionInfo: extractSharedResourcesMaterialInfo(colorFactor, metallicFactor),
|
|
563
|
-
textureDefinitionInfo
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* Form "materialDefinition" which is part of "sharedResouces"
|
|
569
|
-
* https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#materials
|
|
570
|
-
* See formulas in appendix "Appendix B: BRDF Implementation":
|
|
571
|
-
* const dielectricSpecular = rgb(0.04, 0.04, 0.04)
|
|
572
|
-
* const black = rgb(0, 0, 0)
|
|
573
|
-
* cdiff = lerp(baseColor.rgb * (1 - dielectricSpecular.r), black, metallic)
|
|
574
|
-
* F0 = lerp(dieletricSpecular, baseColor.rgb, metallic)
|
|
575
|
-
*
|
|
576
|
-
* Assumption: F0 - specular in i3s ("specular reflection" <-> "reflectance value at normal incidence")
|
|
577
|
-
* cdiff - diffuse in i3s ("Diffuse color" <-> "'c' diffuse" (c means color?))
|
|
578
|
-
* @param {number[]} baseColorFactor - RGBA color in 0..1 format
|
|
579
|
-
* @param {number} metallicFactor - "metallicFactor" attribute of gltf material object
|
|
580
|
-
* @returns {Object}
|
|
581
|
-
*/
|
|
582
|
-
function extractSharedResourcesMaterialInfo(baseColorFactor, metallicFactor = 0) {
|
|
583
|
-
const matDielectricColorComponent = 0.04 / 255; // Color from rgb (255) to 0..1 resolution
|
|
584
|
-
// All color resolutions are 0..1
|
|
585
|
-
const black = new Vector4(0, 0, 0, 1);
|
|
586
|
-
const unitVector = new Vector4(1, 1, 1, 1);
|
|
587
|
-
const dielectricSpecular = new Vector4(
|
|
588
|
-
matDielectricColorComponent,
|
|
589
|
-
matDielectricColorComponent,
|
|
590
|
-
matDielectricColorComponent,
|
|
591
|
-
0
|
|
592
|
-
);
|
|
593
|
-
const baseColorVector = new Vector4(baseColorFactor);
|
|
594
|
-
// https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#metallic-roughness-material
|
|
595
|
-
// Formulas for Cdiff & F0
|
|
596
|
-
const firstOperand = unitVector.subtract(dielectricSpecular).multiply(baseColorVector);
|
|
597
|
-
const diffuse = firstOperand.lerp(firstOperand, black, metallicFactor);
|
|
598
|
-
dielectricSpecular[3] = 1;
|
|
599
|
-
const specular = dielectricSpecular.lerp(dielectricSpecular, baseColorVector, metallicFactor);
|
|
600
|
-
return {
|
|
601
|
-
diffuse: diffuse.toArray(),
|
|
602
|
-
specular: specular.toArray()
|
|
603
|
-
};
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
/**
|
|
607
|
-
* Form "textureDefinition" which is part of "sharedResouces"
|
|
608
|
-
* @param {Object} texture - texture image info
|
|
609
|
-
* @returns {Object}
|
|
610
|
-
*/
|
|
611
|
-
function extractSharedResourcesTextureInfo(texture, nodeId) {
|
|
612
|
-
return {
|
|
613
|
-
encoding: [texture.source.mimeType],
|
|
614
|
-
images: [
|
|
615
|
-
{
|
|
616
|
-
// 'i3s' has just size which is width of the image. Images are supposed to be square.
|
|
617
|
-
// https://github.com/Esri/i3s-spec/blob/master/docs/1.7/image.cmn.md
|
|
618
|
-
id: generateImageId(texture, nodeId),
|
|
619
|
-
size: texture.source.image.width,
|
|
620
|
-
length: [texture.source.image.data.length]
|
|
621
|
-
}
|
|
622
|
-
]
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
/*
|
|
626
|
-
* Formula for counting imageId:
|
|
627
|
-
* https://github.com/Esri/i3s-spec/blob/0a6366a9249b831db8436c322f8d27521e86cf07/format/Indexed%203d%20Scene%20Layer%20Format%20Specification.md#generating-image-ids
|
|
628
|
-
* @param {Object} texture - texture image info
|
|
629
|
-
* @returns {string}
|
|
630
|
-
*/
|
|
631
|
-
function generateImageId(texture, nodeId) {
|
|
632
|
-
const {width, height} = texture.source.image;
|
|
633
|
-
const levelCountOfTexture = 1;
|
|
634
|
-
const indexOfLevel = 0;
|
|
635
|
-
const indexOfTextureInStore = nodeId + 1;
|
|
636
|
-
|
|
637
|
-
const zerosCount = 32 - indexOfTextureInStore.toString(2).length;
|
|
638
|
-
const rightHalf = '0'.repeat(zerosCount).concat(indexOfTextureInStore.toString(2));
|
|
639
|
-
|
|
640
|
-
const shiftedLevelCountOfTexture = levelCountOfTexture << 28;
|
|
641
|
-
const shiftedIndexOfLevel = indexOfLevel << 24;
|
|
642
|
-
const shiftedWidth = (width - 1) << 12;
|
|
643
|
-
const shiftedHeight = (height - 1) << 0;
|
|
644
|
-
|
|
645
|
-
const leftHalf = shiftedLevelCountOfTexture + shiftedIndexOfLevel + shiftedWidth + shiftedHeight;
|
|
646
|
-
const imageId = BigInt(`0b${leftHalf.toString(2)}${rightHalf}`);
|
|
647
|
-
return imageId.toString();
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
/**
|
|
651
|
-
* Make all feature ids unique through all nodes in layout.
|
|
652
|
-
* @param {Array} featureIds
|
|
653
|
-
* @param {Array} featureIndices
|
|
654
|
-
* @param {Array} featuresHashArray
|
|
655
|
-
* @param {Object} batchTable
|
|
656
|
-
* @returns {void}
|
|
657
|
-
*/
|
|
658
|
-
function makeFeatureIdsUnique(featureIds, featureIndices, featuresHashArray, batchTable) {
|
|
659
|
-
const replaceMap = getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray);
|
|
660
|
-
replaceIndicesByUnique(featureIndices, replaceMap);
|
|
661
|
-
replaceIndicesByUnique(featureIds, replaceMap);
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
/**
|
|
665
|
-
* Generate replace map to make featureIds unique.
|
|
666
|
-
* @param {Array} featureIds
|
|
667
|
-
* @param {Object} batchTable
|
|
668
|
-
* @param {Array} featuresHashArray
|
|
669
|
-
* @returns {Object}
|
|
670
|
-
*/
|
|
671
|
-
function getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {
|
|
672
|
-
const featureMap = {};
|
|
673
|
-
|
|
674
|
-
for (let index = 0; index < featureIds.length; index++) {
|
|
675
|
-
const oldFeatureId = featureIds[index];
|
|
676
|
-
const uniqueFeatureId = getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray);
|
|
677
|
-
featureMap[oldFeatureId.toString()] = uniqueFeatureId;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
return featureMap;
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
/**
|
|
684
|
-
* Generates string for unique batch id creation.
|
|
685
|
-
* @param {Object} batchTable
|
|
686
|
-
* @param {Number} index
|
|
687
|
-
* @returns {String}
|
|
688
|
-
*/
|
|
689
|
-
function generateStringFromBatchTableByIndex(batchTable, index) {
|
|
690
|
-
let str = '';
|
|
691
|
-
for (const key in batchTable) {
|
|
692
|
-
str += batchTable[key][index];
|
|
693
|
-
}
|
|
694
|
-
return str;
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
/**
|
|
698
|
-
* Return already exited featureId or creates and returns new to support unique feature ids throw nodes.
|
|
699
|
-
* @param {Number} index
|
|
700
|
-
* @param {Object} batchTable
|
|
701
|
-
* @param {Array} featuresHashArray
|
|
702
|
-
* @returns {Number}
|
|
703
|
-
*/
|
|
704
|
-
function getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray) {
|
|
705
|
-
const batchTableStr = generateStringFromBatchTableByIndex(batchTable, index);
|
|
706
|
-
const hash = md5(batchTableStr);
|
|
707
|
-
|
|
708
|
-
if (featuresHashArray.includes(hash)) {
|
|
709
|
-
return featuresHashArray.indexOf(hash);
|
|
710
|
-
}
|
|
711
|
-
return featuresHashArray.push(hash) - 1;
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
/**
|
|
715
|
-
* Do replacement of indices for making them unique through all nodes.
|
|
716
|
-
* @param {Array} indicesArray
|
|
717
|
-
* @param {Object} featureMap
|
|
718
|
-
* @returns {void}
|
|
719
|
-
*/
|
|
720
|
-
function replaceIndicesByUnique(indicesArray, featureMap) {
|
|
721
|
-
for (let index = 0; index < indicesArray.length; index++) {
|
|
722
|
-
indicesArray[index] = featureMap[indicesArray[index]];
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
/**
|
|
727
|
-
* Convert batch table data to attribute buffers.
|
|
728
|
-
* @param {Object} batchTable - table with metadata for particular feature.
|
|
729
|
-
* @param {Array} featureIds
|
|
730
|
-
* @param {Array} attributeStorageInfo
|
|
731
|
-
* @returns {Array} - Array of file buffers.
|
|
732
|
-
*/
|
|
733
|
-
function convertBatchTableToAttributeBuffers(batchTable, featureIds, attributeStorageInfo) {
|
|
734
|
-
const attributeBuffers = [];
|
|
735
|
-
|
|
736
|
-
if (batchTable) {
|
|
737
|
-
const batchTableWithFeatureIds = {
|
|
738
|
-
OBJECTID: featureIds,
|
|
739
|
-
...batchTable
|
|
740
|
-
};
|
|
741
|
-
|
|
742
|
-
for (const key in batchTableWithFeatureIds) {
|
|
743
|
-
const type = getAttributeType(key, attributeStorageInfo);
|
|
744
|
-
|
|
745
|
-
let attributeBuffer = null;
|
|
746
|
-
|
|
747
|
-
switch (type) {
|
|
748
|
-
case OBJECT_ID_TYPE:
|
|
749
|
-
case SHORT_INT_TYPE:
|
|
750
|
-
attributeBuffer = generateShortIntegerAttributeBuffer(batchTableWithFeatureIds[key]);
|
|
751
|
-
break;
|
|
752
|
-
case DOUBLE_TYPE:
|
|
753
|
-
attributeBuffer = generateDoubleAttributeBuffer(batchTableWithFeatureIds[key]);
|
|
754
|
-
break;
|
|
755
|
-
case STRING_TYPE:
|
|
756
|
-
attributeBuffer = generateStringAttributeBuffer(batchTableWithFeatureIds[key]);
|
|
757
|
-
break;
|
|
758
|
-
default:
|
|
759
|
-
attributeBuffer = generateStringAttributeBuffer(batchTableWithFeatureIds[key]);
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
attributeBuffers.push(attributeBuffer);
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
return attributeBuffers;
|
|
767
|
-
}
|
|
768
|
-
/**
|
|
769
|
-
* Return attribute type.
|
|
770
|
-
* @param {String} key
|
|
771
|
-
* @param {Array} attributeStorageInfo
|
|
772
|
-
* @returns {String} attribute type.
|
|
773
|
-
*/
|
|
774
|
-
function getAttributeType(key, attributeStorageInfo) {
|
|
775
|
-
const attribute = attributeStorageInfo.find((attr) => attr.name === key);
|
|
776
|
-
return attribute.attributeValues.valueType;
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
/**
|
|
780
|
-
* Convert short integer to attribute arrayBuffer.
|
|
781
|
-
* @param {Array} featureIds
|
|
782
|
-
* @returns {ArrayBuffer} - Buffer with objectId data.
|
|
783
|
-
*/
|
|
784
|
-
function generateShortIntegerAttributeBuffer(featureIds) {
|
|
785
|
-
const count = new Uint32Array([featureIds.length]);
|
|
786
|
-
const valuesArray = new Uint32Array(featureIds);
|
|
787
|
-
return concatenateArrayBuffers(count.buffer, valuesArray.buffer);
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
/**
|
|
791
|
-
* Convert double to attribute arrayBuffer.
|
|
792
|
-
* @param {Array} featureIds
|
|
793
|
-
* @returns {ArrayBuffer} - Buffer with objectId data.
|
|
794
|
-
*/
|
|
795
|
-
function generateDoubleAttributeBuffer(featureIds) {
|
|
796
|
-
const count = new Uint32Array([featureIds.length]);
|
|
797
|
-
const padding = new Uint8Array(4);
|
|
798
|
-
const valuesArray = new Float64Array(featureIds);
|
|
799
|
-
|
|
800
|
-
return concatenateArrayBuffers(count.buffer, padding.buffer, valuesArray.buffer);
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
/**
|
|
804
|
-
* Convert batch table attributes to array buffer with batch table data.
|
|
805
|
-
* @param {Array} batchAttributes
|
|
806
|
-
* @returns {ArrayBuffer} - Buffer with batch table data.
|
|
807
|
-
*/
|
|
808
|
-
function generateStringAttributeBuffer(batchAttributes) {
|
|
809
|
-
const stringCountArray = new Uint32Array([batchAttributes.length]);
|
|
810
|
-
let totalNumberOfBytes = 0;
|
|
811
|
-
const stringSizesArray = new Uint32Array(batchAttributes.length);
|
|
812
|
-
const stringBufferArray = [];
|
|
813
|
-
|
|
814
|
-
for (let index = 0; index < batchAttributes.length; index++) {
|
|
815
|
-
const currentString = `${String(batchAttributes[index])}\0`;
|
|
816
|
-
const currentStringBuffer = Buffer.from(currentString);
|
|
817
|
-
const currentStringSize = currentStringBuffer.length;
|
|
818
|
-
totalNumberOfBytes += currentStringSize;
|
|
819
|
-
stringSizesArray[index] = currentStringSize;
|
|
820
|
-
stringBufferArray.push(currentStringBuffer);
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
const totalBytes = new Uint32Array([totalNumberOfBytes]);
|
|
824
|
-
|
|
825
|
-
return concatenateArrayBuffers(
|
|
826
|
-
stringCountArray.buffer,
|
|
827
|
-
totalBytes.buffer,
|
|
828
|
-
stringSizesArray.buffer,
|
|
829
|
-
...stringBufferArray
|
|
830
|
-
);
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
/**
|
|
834
|
-
* Convert featureIds to BigUint64Array.
|
|
835
|
-
* @param {Array} featureIds
|
|
836
|
-
* @returns {BigUint64Array} - Array of feature ids in BigUint64 format.
|
|
837
|
-
*/
|
|
838
|
-
function generateBigUint64Array(featureIds) {
|
|
839
|
-
const typedFeatureIds = new BigUint64Array(featureIds.length);
|
|
840
|
-
for (let index = 0; index < featureIds.length; index++) {
|
|
841
|
-
typedFeatureIds[index] = BigInt(featureIds[index]);
|
|
842
|
-
}
|
|
843
|
-
return typedFeatureIds;
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
/**
|
|
847
|
-
* Generates draco compressed geometry
|
|
848
|
-
* @param {Number} vertexCount
|
|
849
|
-
* @param {Object} convertedAttributes
|
|
850
|
-
* @returns {Promise<object>} - COmpressed geometry.
|
|
851
|
-
*/
|
|
852
|
-
async function generateCompressedGeometry(vertexCount, convertedAttributes, attributes) {
|
|
853
|
-
const {positions, normals, texCoords, colors, featureIds, faceRange} = attributes;
|
|
854
|
-
const indices = new Uint32Array(vertexCount);
|
|
855
|
-
|
|
856
|
-
for (let index = 0; index < indices.length; index++) {
|
|
857
|
-
indices.set([index], index);
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
const featureIndices = new Uint32Array(
|
|
861
|
-
convertedAttributes.featureIndices.length ? convertedAttributes.featureIndices : vertexCount
|
|
862
|
-
);
|
|
863
|
-
|
|
864
|
-
const featureIndex = generateFeatureIndexAttribute(featureIndices, faceRange);
|
|
865
|
-
|
|
866
|
-
const compressedAttributes = {
|
|
867
|
-
positions,
|
|
868
|
-
normals,
|
|
869
|
-
colors,
|
|
870
|
-
'feature-index': featureIndex
|
|
871
|
-
};
|
|
872
|
-
|
|
873
|
-
if (texCoords.length) {
|
|
874
|
-
compressedAttributes.texCoords = texCoords;
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
const attributesMetadata = {
|
|
878
|
-
'feature-index': {
|
|
879
|
-
'i3s-attribute-type': 'feature-index',
|
|
880
|
-
'i3s-feature-ids': new Int32Array(featureIds)
|
|
881
|
-
}
|
|
882
|
-
};
|
|
883
|
-
|
|
884
|
-
return new Uint8Array(
|
|
885
|
-
await encode({attributes: compressedAttributes, indices}, DracoWriter, {
|
|
886
|
-
draco: {
|
|
887
|
-
method: 'MESH_SEQUENTIAL_ENCODING',
|
|
888
|
-
attributesMetadata
|
|
889
|
-
}
|
|
890
|
-
})
|
|
891
|
-
);
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
/**
|
|
895
|
-
* Generates ordered feature indices based on face range
|
|
896
|
-
* @param {Uint32Array} featureIndex
|
|
897
|
-
* @param {Uint32Array} faceRange
|
|
898
|
-
* @returns {Uint32Array}
|
|
899
|
-
*/
|
|
900
|
-
function generateFeatureIndexAttribute(featureIndex, faceRange) {
|
|
901
|
-
const orderedFeatureIndices = new Uint32Array(featureIndex.length);
|
|
902
|
-
let fillIndex = 0;
|
|
903
|
-
let startIndex = 0;
|
|
904
|
-
|
|
905
|
-
for (let index = 1; index < faceRange.length; index += 2) {
|
|
906
|
-
const endIndex = (faceRange[index] + 1) * VALUES_PER_VERTEX;
|
|
907
|
-
|
|
908
|
-
orderedFeatureIndices.fill(fillIndex, startIndex, endIndex);
|
|
909
|
-
|
|
910
|
-
fillIndex++;
|
|
911
|
-
startIndex = endIndex + 1;
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
return orderedFeatureIndices;
|
|
915
|
-
}
|