@loaders.gl/3d-tiles 4.0.0-alpha.1 → 4.0.0-alpha.11
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/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +2 -2
- package/dist/cesium-ion-loader.d.ts +6 -0
- package/dist/cesium-ion-loader.d.ts.map +1 -0
- package/dist/cesium-ion-loader.js +37 -32
- package/dist/dist.min.js +14805 -0
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/cesium-ion-loader.js +77 -0
- package/dist/es5/cesium-ion-loader.js.map +1 -0
- package/dist/es5/index.js +63 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js +114 -0
- package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -0
- package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js +180 -0
- package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -0
- package/dist/es5/lib/classes/tile-3d-batch-table.js +285 -0
- package/dist/es5/lib/classes/tile-3d-batch-table.js.map +1 -0
- package/dist/es5/lib/classes/tile-3d-feature-table.js +97 -0
- package/dist/es5/lib/classes/tile-3d-feature-table.js.map +1 -0
- package/dist/es5/lib/constants.js +32 -0
- package/dist/es5/lib/constants.js.map +1 -0
- package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js +49 -0
- package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js.map +1 -0
- package/dist/es5/lib/encoders/encode-3d-tile-composite.js +30 -0
- package/dist/es5/lib/encoders/encode-3d-tile-composite.js.map +1 -0
- package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js +47 -0
- package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js.map +1 -0
- package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js +48 -0
- package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js.map +1 -0
- package/dist/es5/lib/encoders/encode-3d-tile.js +35 -0
- package/dist/es5/lib/encoders/encode-3d-tile.js.map +1 -0
- package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js +35 -0
- package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js.map +1 -0
- package/dist/es5/lib/ion/ion.js +170 -0
- package/dist/es5/lib/ion/ion.js.map +1 -0
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js +65 -0
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -0
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js +32 -0
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -0
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-positions.js +32 -0
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -0
- package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js +280 -0
- package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -0
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +110 -0
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -0
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js +22 -0
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -0
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js +145 -0
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -0
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js +85 -0
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -0
- package/dist/es5/lib/parsers/helpers/parse-utils.js +28 -0
- package/dist/es5/lib/parsers/helpers/parse-utils.js.map +1 -0
- package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js +51 -0
- package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js.map +1 -0
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js +48 -0
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -0
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +52 -0
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -0
- package/dist/es5/lib/parsers/parse-3d-tile-header.js +289 -0
- package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -0
- package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js +163 -0
- package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -0
- package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js +295 -0
- package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -0
- package/dist/es5/lib/parsers/parse-3d-tile.js +74 -0
- package/dist/es5/lib/parsers/parse-3d-tile.js.map +1 -0
- package/dist/es5/lib/utils/obb/s2-corners-to-obb.js +30 -0
- package/dist/es5/lib/utils/obb/s2-corners-to-obb.js.map +1 -0
- package/dist/es5/lib/utils/s2/converters/s2-to-boundary.js +44 -0
- package/dist/es5/lib/utils/s2/converters/s2-to-boundary.js.map +1 -0
- package/dist/es5/lib/utils/s2/converters/s2-to-obb-points.js +30 -0
- package/dist/es5/lib/utils/s2/converters/s2-to-obb-points.js.map +1 -0
- package/dist/es5/lib/utils/s2/converters/s2-to-region.js +52 -0
- package/dist/es5/lib/utils/s2/converters/s2-to-region.js.map +1 -0
- package/dist/es5/lib/utils/s2/index.js +90 -0
- package/dist/es5/lib/utils/s2/index.js.map +1 -0
- package/dist/es5/lib/utils/s2/s2-geometry-functions.js +19 -0
- package/dist/es5/lib/utils/s2/s2-geometry-functions.js.map +1 -0
- package/dist/es5/lib/utils/s2/s2-token-functions.js +41 -0
- package/dist/es5/lib/utils/s2/s2-token-functions.js.map +1 -0
- package/dist/es5/lib/utils/s2/s2geometry/s2-cell-utils.js +22 -0
- package/dist/es5/lib/utils/s2/s2geometry/s2-cell-utils.js.map +1 -0
- package/dist/es5/lib/utils/s2/s2geometry/s2-geometry.js +207 -0
- package/dist/es5/lib/utils/s2/s2geometry/s2-geometry.js.map +1 -0
- package/dist/es5/lib/utils/version.js +9 -0
- package/dist/es5/lib/utils/version.js.map +1 -0
- package/dist/es5/tile-3d-subtree-loader.js +22 -0
- package/dist/es5/tile-3d-subtree-loader.js.map +1 -0
- package/dist/es5/tile-3d-writer.js +26 -0
- package/dist/es5/tile-3d-writer.js.map +1 -0
- package/dist/es5/tiles-3d-loader.js +133 -0
- package/dist/es5/tiles-3d-loader.js.map +1 -0
- package/dist/es5/types.js +2 -0
- package/dist/es5/types.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/cesium-ion-loader.js +36 -0
- package/dist/esm/cesium-ion-loader.js.map +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/classes/helpers/tile-3d-accessor-utils.js +96 -0
- package/dist/esm/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -0
- package/dist/esm/lib/classes/tile-3d-batch-table-hierarchy.js +171 -0
- package/dist/esm/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -0
- package/dist/esm/lib/classes/tile-3d-batch-table.js +231 -0
- package/dist/esm/lib/classes/tile-3d-batch-table.js.map +1 -0
- package/dist/esm/lib/classes/tile-3d-feature-table.js +70 -0
- package/dist/esm/lib/classes/tile-3d-feature-table.js.map +1 -0
- package/dist/esm/lib/constants.js +22 -0
- package/dist/esm/lib/constants.js.map +1 -0
- package/dist/esm/lib/encoders/encode-3d-tile-batched-model.js +40 -0
- package/dist/esm/lib/encoders/encode-3d-tile-batched-model.js.map +1 -0
- package/dist/esm/lib/encoders/encode-3d-tile-composite.js +21 -0
- package/dist/esm/lib/encoders/encode-3d-tile-composite.js.map +1 -0
- package/dist/esm/lib/encoders/encode-3d-tile-instanced-model.js +36 -0
- package/dist/esm/lib/encoders/encode-3d-tile-instanced-model.js.map +1 -0
- package/dist/esm/lib/encoders/encode-3d-tile-point-cloud.js +39 -0
- package/dist/esm/lib/encoders/encode-3d-tile-point-cloud.js.map +1 -0
- package/dist/esm/lib/encoders/encode-3d-tile.js +29 -0
- package/dist/esm/lib/encoders/encode-3d-tile.js.map +1 -0
- package/dist/esm/lib/encoders/helpers/encode-3d-tile-header.js +28 -0
- package/dist/esm/lib/encoders/helpers/encode-3d-tile-header.js.map +1 -0
- package/dist/esm/lib/ion/ion.js +70 -0
- package/dist/esm/lib/ion/ion.js.map +1 -0
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js +58 -0
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -0
- package/{src → dist/esm}/lib/parsers/helpers/normalize-3d-tile-normals.js +5 -10
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -0
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-positions.js +26 -0
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -0
- package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js +241 -0
- package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -0
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +67 -0
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -0
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-header.js +16 -0
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -0
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js +67 -0
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -0
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js +80 -0
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -0
- package/dist/esm/lib/parsers/helpers/parse-utils.js +20 -0
- package/dist/esm/lib/parsers/helpers/parse-utils.js.map +1 -0
- package/dist/esm/lib/parsers/parse-3d-tile-batched-model.js +25 -0
- package/dist/esm/lib/parsers/parse-3d-tile-batched-model.js.map +1 -0
- package/dist/esm/lib/parsers/parse-3d-tile-composite.js +15 -0
- package/dist/esm/lib/parsers/parse-3d-tile-composite.js.map +1 -0
- package/dist/esm/lib/parsers/parse-3d-tile-gltf.js +20 -0
- package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -0
- package/dist/esm/lib/parsers/parse-3d-tile-header.js +181 -0
- package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -0
- package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js +138 -0
- package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -0
- package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js +232 -0
- package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -0
- package/dist/esm/lib/parsers/parse-3d-tile.js +30 -0
- package/dist/esm/lib/parsers/parse-3d-tile.js.map +1 -0
- package/dist/esm/lib/utils/obb/s2-corners-to-obb.js +23 -0
- package/dist/esm/lib/utils/obb/s2-corners-to-obb.js.map +1 -0
- package/dist/esm/lib/utils/s2/converters/s2-to-boundary.js +40 -0
- package/dist/esm/lib/utils/s2/converters/s2-to-boundary.js.map +1 -0
- package/dist/esm/lib/utils/s2/converters/s2-to-obb-points.js +24 -0
- package/dist/esm/lib/utils/s2/converters/s2-to-obb-points.js.map +1 -0
- package/dist/esm/lib/utils/s2/converters/s2-to-region.js +42 -0
- package/dist/esm/lib/utils/s2/converters/s2-to-region.js.map +1 -0
- package/dist/esm/lib/utils/s2/index.js +7 -0
- package/dist/esm/lib/utils/s2/index.js.map +1 -0
- package/dist/esm/lib/utils/s2/s2-geometry-functions.js +12 -0
- package/dist/esm/lib/utils/s2/s2-geometry-functions.js.map +1 -0
- package/dist/esm/lib/utils/s2/s2-token-functions.js +32 -0
- package/dist/esm/lib/utils/s2/s2-token-functions.js.map +1 -0
- package/dist/esm/lib/utils/s2/s2geometry/s2-cell-utils.js +15 -0
- package/dist/esm/lib/utils/s2/s2geometry/s2-cell-utils.js.map +1 -0
- package/dist/esm/lib/utils/s2/s2geometry/s2-geometry.js +186 -0
- package/dist/esm/lib/utils/s2/s2geometry/s2-geometry.js.map +1 -0
- package/dist/esm/lib/utils/version.js +2 -0
- package/dist/esm/lib/utils/version.js.map +1 -0
- package/dist/esm/tile-3d-subtree-loader.js +14 -0
- package/dist/esm/tile-3d-subtree-loader.js.map +1 -0
- package/dist/esm/tile-3d-writer.js +19 -0
- package/dist/esm/tile-3d-writer.js.map +1 -0
- package/dist/esm/tiles-3d-loader.js +68 -0
- package/dist/esm/tiles-3d-loader.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -8
- package/dist/lib/classes/helpers/tile-3d-accessor-utils.d.ts +8 -0
- package/dist/lib/classes/helpers/tile-3d-accessor-utils.d.ts.map +1 -0
- package/dist/lib/classes/helpers/tile-3d-accessor-utils.js +106 -89
- package/dist/lib/classes/tile-3d-batch-table-hierarchy.d.ts +10 -0
- package/dist/lib/classes/tile-3d-batch-table-hierarchy.d.ts.map +1 -0
- package/dist/lib/classes/tile-3d-batch-table-hierarchy.js +184 -202
- package/dist/lib/classes/tile-3d-batch-table.d.ts +34 -0
- package/dist/lib/classes/tile-3d-batch-table.d.ts.map +1 -0
- package/dist/lib/classes/tile-3d-batch-table.js +223 -267
- package/dist/lib/classes/tile-3d-feature-table.d.ts +15 -0
- package/dist/lib/classes/tile-3d-feature-table.d.ts.map +1 -0
- package/dist/lib/classes/tile-3d-feature-table.js +64 -79
- package/dist/lib/constants.d.ts +22 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +23 -18
- package/dist/lib/encoders/encode-3d-tile-batched-model.d.ts +2 -0
- package/dist/lib/encoders/encode-3d-tile-batched-model.d.ts.map +1 -0
- package/dist/lib/encoders/encode-3d-tile-batched-model.js +45 -45
- package/dist/lib/encoders/encode-3d-tile-composite.d.ts +2 -0
- package/dist/lib/encoders/encode-3d-tile-composite.d.ts.map +1 -0
- package/dist/lib/encoders/encode-3d-tile-composite.js +23 -24
- package/dist/lib/encoders/encode-3d-tile-instanced-model.d.ts +2 -0
- package/dist/lib/encoders/encode-3d-tile-instanced-model.d.ts.map +1 -0
- package/dist/lib/encoders/encode-3d-tile-instanced-model.js +37 -37
- package/dist/lib/encoders/encode-3d-tile-point-cloud.d.ts +2 -0
- package/dist/lib/encoders/encode-3d-tile-point-cloud.d.ts.map +1 -0
- package/dist/lib/encoders/encode-3d-tile-point-cloud.js +36 -38
- package/dist/lib/encoders/encode-3d-tile.d.ts +2 -0
- package/dist/lib/encoders/encode-3d-tile.d.ts.map +1 -0
- package/dist/lib/encoders/encode-3d-tile.js +30 -32
- package/dist/lib/encoders/helpers/encode-3d-tile-header.d.ts +3 -0
- package/dist/lib/encoders/helpers/encode-3d-tile-header.d.ts.map +1 -0
- package/dist/lib/encoders/helpers/encode-3d-tile-header.js +28 -29
- package/dist/lib/ion/ion.d.ts +4 -0
- package/dist/lib/ion/ion.d.ts.map +1 -0
- package/dist/lib/ion/ion.js +60 -69
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.d.ts +9 -0
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +60 -62
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.d.ts +7 -0
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +26 -26
- package/dist/lib/parsers/helpers/normalize-3d-tile-positions.d.ts +2 -0
- package/dist/lib/parsers/helpers/normalize-3d-tile-positions.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js +39 -28
- package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts +57 -0
- package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js +266 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts +10 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +90 -63
- package/dist/lib/parsers/helpers/parse-3d-tile-header.d.ts +3 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-header.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-header.js +26 -15
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts +10 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +104 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-tables.d.ts +5 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-tables.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-tables.js +85 -81
- package/dist/lib/parsers/helpers/parse-utils.d.ts +4 -0
- package/dist/lib/parsers/helpers/parse-utils.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/parse-utils.js +29 -16
- package/dist/lib/parsers/parse-3d-tile-batched-model.d.ts +5 -0
- package/dist/lib/parsers/parse-3d-tile-batched-model.d.ts.map +1 -0
- package/dist/lib/parsers/parse-3d-tile-batched-model.js +30 -26
- package/dist/lib/parsers/parse-3d-tile-composite.d.ts +8 -0
- package/dist/lib/parsers/parse-3d-tile-composite.d.ts.map +1 -0
- package/dist/lib/parsers/parse-3d-tile-composite.js +23 -16
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +5 -0
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts.map +1 -0
- package/dist/lib/parsers/parse-3d-tile-gltf.js +28 -0
- package/dist/lib/parsers/parse-3d-tile-header.d.ts +20 -0
- package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -0
- package/dist/lib/parsers/parse-3d-tile-header.js +186 -71
- package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts +5 -0
- package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts.map +1 -0
- package/dist/lib/parsers/parse-3d-tile-instanced-model.js +165 -170
- package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts +6 -0
- package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts.map +1 -0
- package/dist/lib/parsers/parse-3d-tile-point-cloud.js +372 -184
- package/dist/lib/parsers/parse-3d-tile.d.ts +5 -0
- package/dist/lib/parsers/parse-3d-tile.d.ts.map +1 -0
- package/dist/lib/parsers/parse-3d-tile.js +32 -27
- package/dist/lib/utils/obb/s2-corners-to-obb.d.ts +15 -0
- package/dist/lib/utils/obb/s2-corners-to-obb.d.ts.map +1 -0
- package/dist/lib/utils/obb/s2-corners-to-obb.js +37 -0
- package/dist/lib/utils/s2/converters/s2-to-boundary.d.ts +9 -0
- package/dist/lib/utils/s2/converters/s2-to-boundary.d.ts.map +1 -0
- package/dist/lib/utils/s2/converters/s2-to-boundary.js +61 -0
- package/dist/lib/utils/s2/converters/s2-to-obb-points.d.ts +15 -0
- package/dist/lib/utils/s2/converters/s2-to-obb-points.d.ts.map +1 -0
- package/dist/lib/utils/s2/converters/s2-to-obb-points.js +36 -0
- package/dist/lib/utils/s2/converters/s2-to-region.d.ts +13 -0
- package/dist/lib/utils/s2/converters/s2-to-region.d.ts.map +1 -0
- package/dist/lib/utils/s2/converters/s2-to-region.js +59 -0
- package/dist/lib/utils/s2/index.d.ts +8 -0
- package/dist/lib/utils/s2/index.d.ts.map +1 -0
- package/dist/lib/utils/s2/index.js +23 -0
- package/dist/lib/utils/s2/s2-geometry-functions.d.ts +14 -0
- package/dist/lib/utils/s2/s2-geometry-functions.d.ts.map +1 -0
- package/dist/lib/utils/s2/s2-geometry-functions.js +29 -0
- package/dist/lib/utils/s2/s2-token-functions.d.ts +23 -0
- package/dist/lib/utils/s2/s2-token-functions.d.ts.map +1 -0
- package/dist/lib/utils/s2/s2-token-functions.js +68 -0
- package/dist/lib/utils/s2/s2geometry/s2-cell-utils.d.ts +14 -0
- package/dist/lib/utils/s2/s2geometry/s2-cell-utils.d.ts.map +1 -0
- package/dist/lib/utils/s2/s2geometry/s2-cell-utils.js +32 -0
- package/dist/lib/utils/s2/s2geometry/s2-geometry.d.ts +52 -0
- package/dist/lib/utils/s2/s2geometry/s2-geometry.d.ts.map +1 -0
- package/dist/lib/utils/s2/s2geometry/s2-geometry.js +260 -0
- package/dist/lib/utils/version.d.ts +2 -0
- package/dist/lib/utils/version.d.ts.map +1 -0
- package/dist/lib/utils/version.js +7 -2
- package/dist/tile-3d-subtree-loader.d.ts +7 -0
- package/dist/tile-3d-subtree-loader.d.ts.map +1 -0
- package/dist/tile-3d-subtree-loader.js +23 -0
- package/dist/tile-3d-writer.d.ts +6 -0
- package/dist/tile-3d-writer.d.ts.map +1 -0
- package/dist/tile-3d-writer.js +24 -17
- package/dist/tiles-3d-loader.d.ts +20 -0
- package/dist/tiles-3d-loader.d.ts.map +1 -0
- package/dist/tiles-3d-loader.js +69 -65
- package/dist/types.d.ts +335 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -2
- package/package.json +14 -13
- package/src/cesium-ion-loader.ts +1 -0
- package/src/index.ts +13 -1
- package/src/lib/classes/{tile-3d-batch-table.js → tile-3d-batch-table.ts} +14 -4
- package/src/lib/classes/{tile-3d-feature-table.js → tile-3d-feature-table.ts} +5 -2
- package/src/lib/{constants.js → constants.ts} +2 -1
- package/src/lib/parsers/helpers/{normalize-3d-tile-colors.js → normalize-3d-tile-colors.ts} +10 -4
- package/src/lib/parsers/helpers/normalize-3d-tile-normals.ts +35 -0
- package/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts +396 -0
- package/src/lib/parsers/helpers/{parse-3d-tile-gltf-view.js → parse-3d-tile-gltf-view.ts} +40 -16
- package/src/lib/parsers/helpers/{parse-3d-tile-header.js → parse-3d-tile-header.ts} +7 -1
- package/src/lib/parsers/helpers/parse-3d-tile-subtree.ts +148 -0
- package/src/lib/parsers/helpers/{parse-3d-tile-tables.js → parse-3d-tile-tables.ts} +33 -12
- package/src/lib/parsers/{parse-3d-tile-batched-model.js → parse-3d-tile-batched-model.ts} +18 -3
- package/src/lib/parsers/{parse-3d-tile-composite.js → parse-3d-tile-composite.ts} +20 -8
- package/src/lib/parsers/parse-3d-tile-gltf.ts +33 -0
- package/src/lib/parsers/parse-3d-tile-header.ts +253 -0
- package/src/lib/parsers/{parse-3d-tile-instanced-model.js → parse-3d-tile-instanced-model.ts} +41 -30
- package/src/lib/parsers/{parse-3d-tile-point-cloud.js → parse-3d-tile-point-cloud.ts} +73 -14
- package/src/lib/parsers/{parse-3d-tile.js → parse-3d-tile.ts} +14 -1
- package/src/lib/utils/obb/s2-corners-to-obb.ts +51 -0
- package/src/lib/utils/s2/converters/s2-to-boundary.ts +67 -0
- package/src/lib/utils/s2/converters/s2-to-obb-points.ts +46 -0
- package/src/lib/utils/s2/converters/s2-to-region.ts +69 -0
- package/src/lib/utils/s2/index.ts +17 -0
- package/src/lib/utils/s2/s2-geometry-functions.ts +28 -0
- package/src/lib/utils/s2/s2-token-functions.ts +67 -0
- package/src/lib/utils/s2/s2geometry/s2-cell-utils.ts +33 -0
- package/src/lib/utils/s2/s2geometry/s2-geometry.ts +296 -0
- package/src/tile-3d-subtree-loader.ts +19 -0
- package/src/tiles-3d-loader.ts +68 -37
- package/src/types.ts +321 -13
- package/dist/bundle.js.map +0 -1
- package/dist/cesium-ion-loader.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/classes/helpers/tile-3d-accessor-utils.js.map +0 -1
- package/dist/lib/classes/tile-3d-batch-table-hierarchy.js.map +0 -1
- package/dist/lib/classes/tile-3d-batch-table.js.map +0 -1
- package/dist/lib/classes/tile-3d-feature-table.js.map +0 -1
- package/dist/lib/constants.js.map +0 -1
- package/dist/lib/encoders/encode-3d-tile-batched-model.js.map +0 -1
- package/dist/lib/encoders/encode-3d-tile-composite.js.map +0 -1
- package/dist/lib/encoders/encode-3d-tile-instanced-model.js.map +0 -1
- package/dist/lib/encoders/encode-3d-tile-point-cloud.js.map +0 -1
- package/dist/lib/encoders/encode-3d-tile.js.map +0 -1
- package/dist/lib/encoders/helpers/encode-3d-tile-header.js.map +0 -1
- package/dist/lib/ion/ion.js.map +0 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js.map +0 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js.map +0 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js.map +0 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +0 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-header.js.map +0 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-tables.js.map +0 -1
- package/dist/lib/parsers/helpers/parse-utils.js.map +0 -1
- package/dist/lib/parsers/parse-3d-tile-batched-model.js.map +0 -1
- package/dist/lib/parsers/parse-3d-tile-composite.js.map +0 -1
- package/dist/lib/parsers/parse-3d-tile-header.js.map +0 -1
- package/dist/lib/parsers/parse-3d-tile-instanced-model.js.map +0 -1
- package/dist/lib/parsers/parse-3d-tile-point-cloud.js.map +0 -1
- package/dist/lib/parsers/parse-3d-tile.js.map +0 -1
- package/dist/lib/utils/version.js.map +0 -1
- package/dist/tile-3d-writer.js.map +0 -1
- package/dist/tiles-3d-loader.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/src/lib/parsers/parse-3d-tile-header.js +0 -69
- /package/src/lib/classes/helpers/{tile-3d-accessor-utils.js → tile-3d-accessor-utils.ts} +0 -0
- /package/src/lib/classes/{tile-3d-batch-table-hierarchy.js → tile-3d-batch-table-hierarchy.ts} +0 -0
- /package/src/lib/encoders/{encode-3d-tile-batched-model.js → encode-3d-tile-batched-model.ts} +0 -0
- /package/src/lib/encoders/{encode-3d-tile-composite.js → encode-3d-tile-composite.ts} +0 -0
- /package/src/lib/encoders/{encode-3d-tile-instanced-model.js → encode-3d-tile-instanced-model.ts} +0 -0
- /package/src/lib/encoders/{encode-3d-tile-point-cloud.js → encode-3d-tile-point-cloud.ts} +0 -0
- /package/src/lib/encoders/{encode-3d-tile.js → encode-3d-tile.ts} +0 -0
- /package/src/lib/encoders/helpers/{encode-3d-tile-header.js → encode-3d-tile-header.ts} +0 -0
- /package/src/lib/ion/{ion.js → ion.ts} +0 -0
- /package/src/lib/parsers/helpers/{normalize-3d-tile-positions.js → normalize-3d-tile-positions.ts} +0 -0
- /package/src/lib/parsers/helpers/{parse-utils.js → parse-utils.ts} +0 -0
- /package/src/lib/utils/{version.js → version.ts} +0 -0
|
@@ -12,8 +12,17 @@ import {parse3DTileTablesHeaderSync, parse3DTileTablesSync} from './helpers/pars
|
|
|
12
12
|
import {normalize3DTileColorAttribute} from './helpers/normalize-3d-tile-colors';
|
|
13
13
|
import {normalize3DTileNormalAttribute} from './helpers/normalize-3d-tile-normals';
|
|
14
14
|
import {normalize3DTilePositionAttribute} from './helpers/normalize-3d-tile-positions';
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
import {Tiles3DLoaderOptions} from '../../tiles-3d-loader';
|
|
16
|
+
import {LoaderContext} from '@loaders.gl/loader-utils';
|
|
17
|
+
import {Tiles3DTileContent} from '../../types';
|
|
18
|
+
|
|
19
|
+
export async function parsePointCloud3DTile(
|
|
20
|
+
tile: Tiles3DTileContent,
|
|
21
|
+
arrayBuffer: ArrayBuffer,
|
|
22
|
+
byteOffset: number,
|
|
23
|
+
options?: Tiles3DLoaderOptions,
|
|
24
|
+
context?: LoaderContext
|
|
25
|
+
): Promise<number> {
|
|
17
26
|
byteOffset = parse3DTileHeaderSync(tile, arrayBuffer, byteOffset);
|
|
18
27
|
byteOffset = parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset);
|
|
19
28
|
byteOffset = parse3DTileTablesSync(tile, arrayBuffer, byteOffset, options);
|
|
@@ -24,13 +33,14 @@ export async function parsePointCloud3DTile(tile, arrayBuffer, byteOffset, optio
|
|
|
24
33
|
await parseDraco(tile, featureTable, batchTable, options, context);
|
|
25
34
|
|
|
26
35
|
parsePositions(tile, featureTable, options);
|
|
36
|
+
// @ts-expect-error TODO - do we need to assert on the batch table?
|
|
27
37
|
parseColors(tile, featureTable, batchTable);
|
|
28
38
|
parseNormals(tile, featureTable);
|
|
29
39
|
|
|
30
40
|
return byteOffset;
|
|
31
41
|
}
|
|
32
42
|
|
|
33
|
-
function initializeTile(tile) {
|
|
43
|
+
function initializeTile(tile: Tiles3DTileContent): void {
|
|
34
44
|
// Initialize point cloud tile defaults
|
|
35
45
|
tile.attributes = {
|
|
36
46
|
positions: null,
|
|
@@ -44,7 +54,10 @@ function initializeTile(tile) {
|
|
|
44
54
|
tile.isOctEncoded16P = false;
|
|
45
55
|
}
|
|
46
56
|
|
|
47
|
-
function parsePointCloudTables(tile) {
|
|
57
|
+
function parsePointCloudTables(tile: Tiles3DTileContent): {
|
|
58
|
+
featureTable: Tile3DFeatureTable;
|
|
59
|
+
batchTable: Tile3DBatchTable | null;
|
|
60
|
+
} {
|
|
48
61
|
const featureTable = new Tile3DFeatureTable(tile.featureTableJson, tile.featureTableBinary);
|
|
49
62
|
|
|
50
63
|
const pointsLength = featureTable.getGlobalProperty('POINTS_LENGTH');
|
|
@@ -64,7 +77,17 @@ function parsePointCloudTables(tile) {
|
|
|
64
77
|
return {featureTable, batchTable};
|
|
65
78
|
}
|
|
66
79
|
|
|
67
|
-
function parsePositions(
|
|
80
|
+
function parsePositions(
|
|
81
|
+
tile: Tiles3DTileContent,
|
|
82
|
+
featureTable: Tile3DFeatureTable,
|
|
83
|
+
options: Tiles3DLoaderOptions | undefined
|
|
84
|
+
): void {
|
|
85
|
+
tile.attributes = tile.attributes || {
|
|
86
|
+
positions: null,
|
|
87
|
+
colors: null,
|
|
88
|
+
normals: null,
|
|
89
|
+
batchIds: null
|
|
90
|
+
};
|
|
68
91
|
if (!tile.attributes.positions) {
|
|
69
92
|
if (featureTable.hasProperty('POSITION')) {
|
|
70
93
|
tile.attributes.positions = featureTable.getPropertyArray('POSITION', GL.FLOAT, 3);
|
|
@@ -101,7 +124,17 @@ function parsePositions(tile, featureTable, options) {
|
|
|
101
124
|
}
|
|
102
125
|
}
|
|
103
126
|
|
|
104
|
-
function parseColors(
|
|
127
|
+
function parseColors(
|
|
128
|
+
tile: Tiles3DTileContent,
|
|
129
|
+
featureTable: Tile3DFeatureTable,
|
|
130
|
+
batchTable: Tile3DBatchTable
|
|
131
|
+
): void {
|
|
132
|
+
tile.attributes = tile.attributes || {
|
|
133
|
+
positions: null,
|
|
134
|
+
colors: null,
|
|
135
|
+
normals: null,
|
|
136
|
+
batchIds: null
|
|
137
|
+
};
|
|
105
138
|
if (!tile.attributes.colors) {
|
|
106
139
|
let colors = null;
|
|
107
140
|
if (featureTable.hasProperty('RGBA')) {
|
|
@@ -122,7 +155,13 @@ function parseColors(tile, featureTable, batchTable) {
|
|
|
122
155
|
}
|
|
123
156
|
}
|
|
124
157
|
|
|
125
|
-
function parseNormals(tile, featureTable) {
|
|
158
|
+
function parseNormals(tile: Tiles3DTileContent, featureTable: Tile3DFeatureTable): void {
|
|
159
|
+
tile.attributes = tile.attributes || {
|
|
160
|
+
positions: null,
|
|
161
|
+
colors: null,
|
|
162
|
+
normals: null,
|
|
163
|
+
batchIds: null
|
|
164
|
+
};
|
|
126
165
|
if (!tile.attributes.normals) {
|
|
127
166
|
let normals = null;
|
|
128
167
|
if (featureTable.hasProperty('NORMAL')) {
|
|
@@ -136,8 +175,11 @@ function parseNormals(tile, featureTable) {
|
|
|
136
175
|
}
|
|
137
176
|
}
|
|
138
177
|
|
|
139
|
-
function parseBatchIds(
|
|
140
|
-
|
|
178
|
+
function parseBatchIds(
|
|
179
|
+
tile: Tiles3DTileContent,
|
|
180
|
+
featureTable: Tile3DFeatureTable
|
|
181
|
+
): Tile3DBatchTable | null {
|
|
182
|
+
let batchTable: Tile3DBatchTable | null = null;
|
|
141
183
|
if (!tile.batchIds && featureTable.hasProperty('BATCH_ID')) {
|
|
142
184
|
tile.batchIds = featureTable.getPropertyArray('BATCH_ID', GL.UNSIGNED_SHORT, 1);
|
|
143
185
|
|
|
@@ -154,7 +196,13 @@ function parseBatchIds(tile, featureTable) {
|
|
|
154
196
|
}
|
|
155
197
|
|
|
156
198
|
// eslint-disable-next-line complexity
|
|
157
|
-
async function parseDraco(
|
|
199
|
+
async function parseDraco(
|
|
200
|
+
tile: Tiles3DTileContent,
|
|
201
|
+
featureTable: Tile3DFeatureTable,
|
|
202
|
+
batchTable,
|
|
203
|
+
options?: Tiles3DLoaderOptions,
|
|
204
|
+
context?: LoaderContext
|
|
205
|
+
) {
|
|
158
206
|
let dracoBuffer;
|
|
159
207
|
let dracoFeatureTableProperties;
|
|
160
208
|
let dracoBatchTableProperties;
|
|
@@ -175,7 +223,10 @@ async function parseDraco(tile, featureTable, batchTable, options, context) {
|
|
|
175
223
|
throw new Error('Draco properties, byteOffset, and byteLength must be defined');
|
|
176
224
|
}
|
|
177
225
|
|
|
178
|
-
dracoBuffer = tile.featureTableBinary.slice(
|
|
226
|
+
dracoBuffer = (tile.featureTableBinary || []).slice(
|
|
227
|
+
dracoByteOffset,
|
|
228
|
+
dracoByteOffset + dracoByteLength
|
|
229
|
+
);
|
|
179
230
|
|
|
180
231
|
tile.hasPositions = Number.isFinite(dracoFeatureTableProperties.POSITION);
|
|
181
232
|
tile.hasColors =
|
|
@@ -202,12 +253,20 @@ async function parseDraco(tile, featureTable, batchTable, options, context) {
|
|
|
202
253
|
}
|
|
203
254
|
|
|
204
255
|
// eslint-disable-next-line complexity, max-statements
|
|
205
|
-
export async function loadDraco(
|
|
256
|
+
export async function loadDraco(
|
|
257
|
+
tile: Tiles3DTileContent,
|
|
258
|
+
dracoData,
|
|
259
|
+
options?: Tiles3DLoaderOptions,
|
|
260
|
+
context?: LoaderContext
|
|
261
|
+
): Promise<void> {
|
|
262
|
+
if (!context) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
206
265
|
const {parse} = context;
|
|
207
266
|
const dracoOptions = {
|
|
208
267
|
...options,
|
|
209
268
|
draco: {
|
|
210
|
-
...options
|
|
269
|
+
...options?.draco,
|
|
211
270
|
extraAttributes: dracoData.batchTableProperties || {}
|
|
212
271
|
}
|
|
213
272
|
};
|
|
@@ -250,7 +309,7 @@ export async function loadDraco(tile, dracoData, options, context) {
|
|
|
250
309
|
|
|
251
310
|
tile.attributes = {
|
|
252
311
|
positions: decodedPositions,
|
|
253
|
-
colors: normalize3DTileColorAttribute(tile, decodedColors),
|
|
312
|
+
colors: normalize3DTileColorAttribute(tile, decodedColors, undefined),
|
|
254
313
|
normals: decodedNormals,
|
|
255
314
|
batchIds: decodedBatchIds,
|
|
256
315
|
...batchTableAttributes
|
|
@@ -8,9 +8,19 @@ import {parsePointCloud3DTile} from './parse-3d-tile-point-cloud';
|
|
|
8
8
|
import {parseBatchedModel3DTile} from './parse-3d-tile-batched-model';
|
|
9
9
|
import {parseInstancedModel3DTile} from './parse-3d-tile-instanced-model';
|
|
10
10
|
import {parseComposite3DTile} from './parse-3d-tile-composite';
|
|
11
|
+
import {parseGltf3DTile} from './parse-3d-tile-gltf';
|
|
12
|
+
import {LoaderContext} from '@loaders.gl/loader-utils';
|
|
13
|
+
import {Tiles3DLoaderOptions} from '../../tiles-3d-loader';
|
|
14
|
+
import {Tiles3DTileContent} from '../../types';
|
|
11
15
|
|
|
12
16
|
// Extracts
|
|
13
|
-
export async function parse3DTile(
|
|
17
|
+
export async function parse3DTile(
|
|
18
|
+
arrayBuffer: ArrayBuffer,
|
|
19
|
+
byteOffset = 0,
|
|
20
|
+
options: Tiles3DLoaderOptions | undefined,
|
|
21
|
+
context: LoaderContext | undefined,
|
|
22
|
+
tile: Tiles3DTileContent = {}
|
|
23
|
+
) {
|
|
14
24
|
tile.byteOffset = byteOffset;
|
|
15
25
|
tile.type = getMagicString(arrayBuffer, byteOffset);
|
|
16
26
|
|
|
@@ -29,6 +39,9 @@ export async function parse3DTile(arrayBuffer, byteOffset = 0, options, context,
|
|
|
29
39
|
case TILE3D_TYPE.BATCHED_3D_MODEL:
|
|
30
40
|
return await parseBatchedModel3DTile(tile, arrayBuffer, byteOffset, options, context);
|
|
31
41
|
|
|
42
|
+
case TILE3D_TYPE.GLTF:
|
|
43
|
+
return await parseGltf3DTile(tile, arrayBuffer, options, context);
|
|
44
|
+
|
|
32
45
|
case TILE3D_TYPE.INSTANCED_3D_MODEL:
|
|
33
46
|
return await parseInstancedModel3DTile(tile, arrayBuffer, byteOffset, options, context);
|
|
34
47
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {Vector3} from '@math.gl/core';
|
|
2
|
+
import {OrientedBoundingBox, makeOrientedBoundingBoxFromPoints} from '@math.gl/culling';
|
|
3
|
+
|
|
4
|
+
import type {S2HeightInfo} from '../../utils/s2/index';
|
|
5
|
+
import {getS2OrientedBoundingBoxCornerPoints} from '../../utils/s2/index';
|
|
6
|
+
|
|
7
|
+
import {getS2LngLat} from '../../utils/s2/index';
|
|
8
|
+
import {Ellipsoid} from '@math.gl/geospatial';
|
|
9
|
+
|
|
10
|
+
export type S2VolumeInfo = {
|
|
11
|
+
/** S2 key or token */
|
|
12
|
+
token: string;
|
|
13
|
+
/** minimum height in meters */
|
|
14
|
+
minimumHeight: number;
|
|
15
|
+
/** maximum height in meters */
|
|
16
|
+
maximumHeight: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Converts S2VolumeInfo to OrientedBoundingBox
|
|
21
|
+
* @param {S2VolumeInfo} s2VolumeInfo - s2 volume to convert
|
|
22
|
+
* @returns Oriented Bounding Box of type Box
|
|
23
|
+
*/
|
|
24
|
+
export function convertS2BoundingVolumetoOBB(s2VolumeInfo: S2VolumeInfo): number[] {
|
|
25
|
+
const token: string = s2VolumeInfo.token;
|
|
26
|
+
const heightInfo: S2HeightInfo = {
|
|
27
|
+
minimumHeight: s2VolumeInfo.minimumHeight,
|
|
28
|
+
maximumHeight: s2VolumeInfo.maximumHeight
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const corners: Vector3[] = getS2OrientedBoundingBoxCornerPoints(token, heightInfo);
|
|
32
|
+
|
|
33
|
+
// Add a point that doesn't allow the box dive under the Earth
|
|
34
|
+
|
|
35
|
+
const center = getS2LngLat(token);
|
|
36
|
+
const centerLng: number = center[0];
|
|
37
|
+
const centerLat: number = center[1];
|
|
38
|
+
const point = Ellipsoid.WGS84.cartographicToCartesian([
|
|
39
|
+
centerLng,
|
|
40
|
+
centerLat,
|
|
41
|
+
heightInfo.maximumHeight
|
|
42
|
+
]);
|
|
43
|
+
const centerPointAdditional = new Vector3(point[0], point[1], point[2]);
|
|
44
|
+
corners.push(centerPointAdditional);
|
|
45
|
+
|
|
46
|
+
// corners should be an array of Vector3 (XYZ)
|
|
47
|
+
const obb: OrientedBoundingBox = makeOrientedBoundingBoxFromPoints(corners);
|
|
48
|
+
const box: number[] = [...obb.center, ...obb.halfAxes];
|
|
49
|
+
|
|
50
|
+
return box;
|
|
51
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type {S2Cell} from '../s2geometry/s2-geometry';
|
|
2
|
+
import {IJToST, STToUV, FaceUVToXYZ, XYZToLngLat} from '../s2geometry/s2-geometry';
|
|
3
|
+
|
|
4
|
+
const MAX_RESOLUTION = 100;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Get a polygon with corner coordinates for an S2 cell
|
|
8
|
+
* @param s2cell {S2Cell} S2 cell
|
|
9
|
+
* @return {Float64Array} - a simple polygon in flat array format: [lng0, lat0, lng1, lat1, ...]
|
|
10
|
+
* - the polygon is closed, i.e. last coordinate is a copy of the first coordinate
|
|
11
|
+
*/
|
|
12
|
+
// eslint-disable-next-line max-statements
|
|
13
|
+
export function getS2BoundaryFlatFromS2Cell(s2cell: S2Cell): Float64Array {
|
|
14
|
+
const {face, ij, level} = s2cell;
|
|
15
|
+
const offsets = [
|
|
16
|
+
[0, 0],
|
|
17
|
+
[0, 1],
|
|
18
|
+
[1, 1],
|
|
19
|
+
[1, 0],
|
|
20
|
+
[0, 0]
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
// The S2 cell edge is curved: http://s2geometry.io/
|
|
24
|
+
// This is more prominent at lower levels
|
|
25
|
+
// resolution is the number of segments to generate per edge.
|
|
26
|
+
// We exponentially reduce resolution as level increases so it doesn't affect perf
|
|
27
|
+
// when there are a large number of cells
|
|
28
|
+
const resolution = Math.max(1, Math.ceil(MAX_RESOLUTION * Math.pow(2, -level)));
|
|
29
|
+
const result = new Float64Array(4 * resolution * 2 + 2);
|
|
30
|
+
let ptIndex = 0;
|
|
31
|
+
let prevLng = 0;
|
|
32
|
+
|
|
33
|
+
for (let i = 0; i < 4; i++) {
|
|
34
|
+
const offset = offsets[i].slice(0) as [number, number];
|
|
35
|
+
const nextOffset = offsets[i + 1];
|
|
36
|
+
const stepI = (nextOffset[0] - offset[0]) / resolution;
|
|
37
|
+
const stepJ = (nextOffset[1] - offset[1]) / resolution;
|
|
38
|
+
|
|
39
|
+
for (let j = 0; j < resolution; j++) {
|
|
40
|
+
offset[0] += stepI;
|
|
41
|
+
offset[1] += stepJ;
|
|
42
|
+
// Cell can be represented by coordinates IJ, ST, UV, XYZ
|
|
43
|
+
// http://s2geometry.io/devguide/s2cell_hierarchy#coordinate-systems
|
|
44
|
+
const st = IJToST(ij, level, offset);
|
|
45
|
+
const uv = STToUV(st);
|
|
46
|
+
const xyz = FaceUVToXYZ(face, uv);
|
|
47
|
+
const lngLat = XYZToLngLat(xyz);
|
|
48
|
+
|
|
49
|
+
// Adjust longitude for Web Mercator projection
|
|
50
|
+
|
|
51
|
+
if (Math.abs(lngLat[1]) > 89.999) {
|
|
52
|
+
lngLat[0] = prevLng;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const deltaLng = lngLat[0] - prevLng;
|
|
56
|
+
lngLat[0] += deltaLng > 180 ? -360 : deltaLng < -180 ? 360 : 0;
|
|
57
|
+
|
|
58
|
+
result[ptIndex++] = lngLat[0];
|
|
59
|
+
result[ptIndex++] = lngLat[1];
|
|
60
|
+
prevLng = lngLat[0];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// close the loop
|
|
64
|
+
result[ptIndex++] = result[0];
|
|
65
|
+
result[ptIndex++] = result[1];
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {getS2Cell} from '../s2geometry/s2-cell-utils';
|
|
2
|
+
import {getS2Region} from './s2-to-region';
|
|
3
|
+
import {Vector3} from '@math.gl/core';
|
|
4
|
+
|
|
5
|
+
export type S2HeightInfo = {
|
|
6
|
+
minimumHeight: number;
|
|
7
|
+
maximumHeight: number;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Converts S2HeightInfo to corner points of an oriented bounding box
|
|
12
|
+
* Can be used to constuct an OrientedBoundingBox instance
|
|
13
|
+
* @param tokenOrKey {string} A string that is the cell's hex token or the Hilbert quad key (containing /)
|
|
14
|
+
* @param heightInfo {S2HeightInfo} min and max height of the box
|
|
15
|
+
* @returns corner points of the oriented bounding box
|
|
16
|
+
*/
|
|
17
|
+
export function getS2OrientedBoundingBoxCornerPoints(
|
|
18
|
+
tokenOrKey: string, // This can be an S2 key or token
|
|
19
|
+
heightInfo?: S2HeightInfo
|
|
20
|
+
): Vector3[] {
|
|
21
|
+
const min: number = heightInfo?.minimumHeight || 0;
|
|
22
|
+
const max: number = heightInfo?.maximumHeight || 0;
|
|
23
|
+
|
|
24
|
+
const s2cell = getS2Cell(tokenOrKey);
|
|
25
|
+
const region = getS2Region(s2cell);
|
|
26
|
+
|
|
27
|
+
// region lng/lat are in degrees
|
|
28
|
+
const W = region.west;
|
|
29
|
+
const S = region.south;
|
|
30
|
+
const E = region.east;
|
|
31
|
+
const N = region.north;
|
|
32
|
+
|
|
33
|
+
const points: Vector3[] = [];
|
|
34
|
+
|
|
35
|
+
points.push(new Vector3(W, N, min));
|
|
36
|
+
points.push(new Vector3(E, N, min));
|
|
37
|
+
points.push(new Vector3(E, S, min));
|
|
38
|
+
points.push(new Vector3(W, S, min));
|
|
39
|
+
|
|
40
|
+
points.push(new Vector3(W, N, max));
|
|
41
|
+
points.push(new Vector3(E, N, max));
|
|
42
|
+
points.push(new Vector3(E, S, max));
|
|
43
|
+
points.push(new Vector3(W, S, max));
|
|
44
|
+
|
|
45
|
+
return points;
|
|
46
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type {S2Cell} from '../s2geometry/s2-geometry';
|
|
2
|
+
import {getS2BoundaryFlatFromS2Cell} from './s2-to-boundary';
|
|
3
|
+
import {getS2Cell} from '../s2geometry/s2-cell-utils';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Converts S2 cell to the 2D region
|
|
7
|
+
* @param s2cell {S2Cell} S2 cell to convert to 2D region
|
|
8
|
+
* @returns 2D region as an object containing: west, north, east, south in degrees
|
|
9
|
+
*/
|
|
10
|
+
export function getS2Region(s2cell: S2Cell): {
|
|
11
|
+
west: number;
|
|
12
|
+
east: number;
|
|
13
|
+
north: number;
|
|
14
|
+
south: number;
|
|
15
|
+
} {
|
|
16
|
+
let region;
|
|
17
|
+
if (s2cell.face === 2 || s2cell.face === 5) {
|
|
18
|
+
// let corners: Float64Array;
|
|
19
|
+
let corners: any = null;
|
|
20
|
+
let len = 0;
|
|
21
|
+
for (let i = 0; i < 4; i++) {
|
|
22
|
+
const key = `${s2cell.face}/${i}`;
|
|
23
|
+
const cell = getS2Cell(key);
|
|
24
|
+
const corns: Float64Array = getS2BoundaryFlatFromS2Cell(cell);
|
|
25
|
+
if (typeof corners === 'undefined' || corners === null)
|
|
26
|
+
corners = new Float64Array(4 * corns.length);
|
|
27
|
+
corners.set(corns, len);
|
|
28
|
+
len += corns.length;
|
|
29
|
+
}
|
|
30
|
+
region = get2DRegionFromS2Corners(corners);
|
|
31
|
+
} else {
|
|
32
|
+
const corners: Float64Array = getS2BoundaryFlatFromS2Cell(s2cell);
|
|
33
|
+
region = get2DRegionFromS2Corners(corners);
|
|
34
|
+
}
|
|
35
|
+
return region;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Converts the S2 cell defined by its corners to the 2D region
|
|
40
|
+
* @param corners {Float64Array} - a simple polygon in flat array format: [lng0, lat0, lng1, lat1, ...]
|
|
41
|
+
* @returns 2D region as an object containing: west, north, east, south in degrees
|
|
42
|
+
*/
|
|
43
|
+
function get2DRegionFromS2Corners(corners: Float64Array): {
|
|
44
|
+
west: number;
|
|
45
|
+
east: number;
|
|
46
|
+
north: number;
|
|
47
|
+
south: number;
|
|
48
|
+
} {
|
|
49
|
+
if (corners.length % 2 !== 0) {
|
|
50
|
+
throw new Error('Invalid corners');
|
|
51
|
+
}
|
|
52
|
+
const longitudes: number[] = [];
|
|
53
|
+
const latitudes: number[] = [];
|
|
54
|
+
for (let i = 0; i < corners.length; i += 2) {
|
|
55
|
+
longitudes.push(corners[i]);
|
|
56
|
+
latitudes.push(corners[i + 1]);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
longitudes.sort((a, b) => a - b);
|
|
60
|
+
latitudes.sort((a, b) => a - b);
|
|
61
|
+
|
|
62
|
+
// Return the region in degrees
|
|
63
|
+
return {
|
|
64
|
+
west: longitudes[0],
|
|
65
|
+
east: longitudes[longitudes.length - 1],
|
|
66
|
+
north: latitudes[latitudes.length - 1],
|
|
67
|
+
south: latitudes[0]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// math.gl MIT license
|
|
2
|
+
|
|
3
|
+
export {getS2CellIdFromToken, getS2TokenFromCellId, getS2ChildCellId} from './s2-token-functions';
|
|
4
|
+
export {getS2BoundaryFlat, getS2LngLat} from './s2-geometry-functions';
|
|
5
|
+
|
|
6
|
+
export {getS2Cell, getS2QuadKey} from './s2geometry/s2-cell-utils';
|
|
7
|
+
export {
|
|
8
|
+
getS2QuadkeyFromCellId,
|
|
9
|
+
getS2CellFromQuadKey,
|
|
10
|
+
getS2CellIdFromQuadkey,
|
|
11
|
+
getS2LngLatFromS2Cell
|
|
12
|
+
} from './s2geometry/s2-geometry';
|
|
13
|
+
|
|
14
|
+
export {getS2Region} from './converters/s2-to-region';
|
|
15
|
+
|
|
16
|
+
export type {S2HeightInfo} from './converters/s2-to-obb-points';
|
|
17
|
+
export {getS2OrientedBoundingBoxCornerPoints} from './converters/s2-to-obb-points';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// math.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import {getS2BoundaryFlatFromS2Cell} from './converters/s2-to-boundary';
|
|
4
|
+
import {getS2LngLatFromS2Cell} from './s2geometry/s2-geometry';
|
|
5
|
+
import {getS2Cell} from './s2geometry/s2-cell-utils';
|
|
6
|
+
|
|
7
|
+
// GEOMETRY
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Retrieve S2 geometry center
|
|
11
|
+
* @param s2Token {string} A string that is the cell's hex token
|
|
12
|
+
* @returns {[number, number]} Longitude and Latitude coordinates of the S2 cell's center
|
|
13
|
+
*/
|
|
14
|
+
export function getS2LngLat(s2Token: string): [number, number] {
|
|
15
|
+
const s2cell = getS2Cell(s2Token);
|
|
16
|
+
return getS2LngLatFromS2Cell(s2cell);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get a polygon with corner coordinates for an s2 cell
|
|
21
|
+
* @param tokenOrKey {string} A string that is the cell's hex token or the Hilbert quad key (containing /)
|
|
22
|
+
* @return {Float64Array} - a simple polygon in flat array format: [lng0, lat0, lng1, lat1, ...]
|
|
23
|
+
* - the polygon is closed, i.e. last coordinate is a copy of the first coordinate
|
|
24
|
+
*/
|
|
25
|
+
export function getS2BoundaryFlat(tokenOrKey: string): Float64Array {
|
|
26
|
+
const s2cell = getS2Cell(tokenOrKey);
|
|
27
|
+
return getS2BoundaryFlatFromS2Cell(s2cell);
|
|
28
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import Long from 'long';
|
|
4
|
+
|
|
5
|
+
const MAXIMUM_TOKEN_LENGTH = 16;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Convert the S2 token to the S2 cell ID
|
|
9
|
+
* @param token {string} A string that is the cell's hex token. Zero cell ID is represented as 'X'.
|
|
10
|
+
* @returns {Long} Cell id that is a 64-bit encoding of a face and a Hilbert curve parameter on that face.
|
|
11
|
+
* See {@link https://github.com/google/s2-geometry-library-java/blob/c04b68bf3197a9c34082327eeb3aec7ab7c85da1/src/com/google/common/geometry/S2CellId.java#L439} for more information
|
|
12
|
+
*/
|
|
13
|
+
export function getS2CellIdFromToken(token: string): Long {
|
|
14
|
+
if (token === 'X') {
|
|
15
|
+
token = '';
|
|
16
|
+
}
|
|
17
|
+
// pad token with zeros to make the length 16 that is defined in MAXIMUM_TOKEN_LENGTH
|
|
18
|
+
const paddedToken = token.padEnd(MAXIMUM_TOKEN_LENGTH, '0');
|
|
19
|
+
return Long.fromString(paddedToken, true, 16); // Hex base
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Convert the S2 cell ID to the S2 token
|
|
24
|
+
* @param cellId {Long} A 64-bit encoding of a face and a Hilbert curve parameter on that face.
|
|
25
|
+
* @returns {string} A string that is the cell's hex token. Zero cell ID is represented as 'X'.
|
|
26
|
+
*/
|
|
27
|
+
export function getS2TokenFromCellId(cellId: Long): string {
|
|
28
|
+
if (cellId.isZero()) {
|
|
29
|
+
return 'X';
|
|
30
|
+
}
|
|
31
|
+
let numZeroDigits = cellId.countTrailingZeros();
|
|
32
|
+
|
|
33
|
+
const remainder = numZeroDigits % 4;
|
|
34
|
+
numZeroDigits = (numZeroDigits - remainder) / 4;
|
|
35
|
+
const trailingZeroHexChars = numZeroDigits;
|
|
36
|
+
numZeroDigits *= 4;
|
|
37
|
+
|
|
38
|
+
const x = cellId.shiftRightUnsigned(numZeroDigits);
|
|
39
|
+
const hexString = x.toString(16).replace(/0+$/, '');
|
|
40
|
+
const zeroString = Array(17 - trailingZeroHexChars - hexString.length).join('0');
|
|
41
|
+
return zeroString + hexString;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Get one of four S2 cell's children.
|
|
46
|
+
* @param cellId {Long} A 64-bit encoding of a face and a Hilbert curve parameter on that face.
|
|
47
|
+
* The cell must NOT be a leaf one. So, the cell's level is in the range [0-29].
|
|
48
|
+
* @param index {number} Child index defines one of four S2 cell's children. Must be in the range [0-3].
|
|
49
|
+
* @returns The ID of the cell's child.
|
|
50
|
+
*/
|
|
51
|
+
export function getS2ChildCellId(cellId: Long, index: number): Long {
|
|
52
|
+
// Shift sentinel bit 2 positions to the right.
|
|
53
|
+
const newLsb = lsb(cellId).shiftRightUnsigned(2);
|
|
54
|
+
// Insert child index before the sentinel bit.
|
|
55
|
+
const childCellId: Long = cellId.add(Long.fromNumber(2 * index + 1 - 4).multiply(newLsb));
|
|
56
|
+
return childCellId;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Return the lowest-numbered bit that is on for this cell id.
|
|
61
|
+
* @private
|
|
62
|
+
* @param cellId {Long} Cell id.
|
|
63
|
+
* @returns {Long} The lowest-numbered bit that is on for this cell id.
|
|
64
|
+
*/
|
|
65
|
+
function lsb(cellId: Long): Long {
|
|
66
|
+
return cellId.and(cellId.not().add(1)); // eslint-disable-line
|
|
67
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// math.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import type {S2Cell} from './s2-geometry';
|
|
4
|
+
import {getS2CellFromQuadKey, getS2QuadkeyFromCellId} from './s2-geometry';
|
|
5
|
+
import {getS2CellIdFromToken} from '../s2-token-functions';
|
|
6
|
+
|
|
7
|
+
import Long from 'long';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Return the S2Cell from the cell's hex token or the Hilbert quad key
|
|
11
|
+
* @param tokenOrKey {string} A string that is the cell's hex token or the Hilbert quad key (containing /)
|
|
12
|
+
* @returns {@link S2Cell}
|
|
13
|
+
*/
|
|
14
|
+
export function getS2Cell(tokenOrKey: string): S2Cell {
|
|
15
|
+
const key = getS2QuadKey(tokenOrKey);
|
|
16
|
+
const s2cell = getS2CellFromQuadKey(key);
|
|
17
|
+
return s2cell;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get the underlying Hilbert quad key
|
|
22
|
+
* @param tokenOrKey {string} A string that is the cell's hex token or the Hilbert quad key (containing /)
|
|
23
|
+
* @returns Hilbert quad key
|
|
24
|
+
*/
|
|
25
|
+
export function getS2QuadKey(tokenOrKey: string): string {
|
|
26
|
+
if (tokenOrKey.indexOf('/') > 0) {
|
|
27
|
+
// is Hilbert quad key
|
|
28
|
+
return tokenOrKey;
|
|
29
|
+
}
|
|
30
|
+
// is S2 cell's hex token
|
|
31
|
+
const id: Long = getS2CellIdFromToken(tokenOrKey);
|
|
32
|
+
return getS2QuadkeyFromCellId(id);
|
|
33
|
+
}
|