@loaders.gl/3d-tiles 4.0.0-alpha.5 → 4.0.0-alpha.7
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.js +2 -2
- package/dist/cesium-ion-loader.d.ts.map +1 -1
- package/dist/cesium-ion-loader.js +37 -32
- package/dist/dist.min.js +5345 -2938
- 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 +64 -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 +98 -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 +37 -0
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -0
- package/dist/es5/lib/parsers/parse-3d-tile-header.js +271 -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 +172 -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 +271 -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 +138 -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/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js +26 -0
- 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 +61 -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 +12 -0
- package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -0
- package/dist/esm/lib/parsers/parse-3d-tile-header.js +164 -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 +147 -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 +211 -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 +62 -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 +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -9
- package/dist/lib/classes/helpers/tile-3d-accessor-utils.d.ts +1 -1
- package/dist/lib/classes/helpers/tile-3d-accessor-utils.js +106 -89
- package/dist/lib/classes/tile-3d-batch-table-hierarchy.js +184 -202
- package/dist/lib/classes/tile-3d-batch-table.d.ts +1 -1
- package/dist/lib/classes/tile-3d-batch-table.js +223 -282
- package/dist/lib/classes/tile-3d-feature-table.js +64 -86
- package/dist/lib/constants.js +23 -19
- package/dist/lib/encoders/encode-3d-tile-batched-model.js +45 -45
- package/dist/lib/encoders/encode-3d-tile-composite.js +23 -24
- package/dist/lib/encoders/encode-3d-tile-instanced-model.js +37 -37
- package/dist/lib/encoders/encode-3d-tile-point-cloud.js +36 -38
- package/dist/lib/encoders/encode-3d-tile.js +30 -32
- package/dist/lib/encoders/helpers/encode-3d-tile-header.js +28 -29
- package/dist/lib/ion/ion.js +60 -69
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +60 -62
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +26 -26
- package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js +39 -28
- package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts +11 -0
- package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js +247 -203
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +84 -63
- package/dist/lib/parsers/helpers/parse-3d-tile-header.js +26 -15
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts +2 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +98 -58
- package/dist/lib/parsers/helpers/parse-3d-tile-tables.js +84 -80
- package/dist/lib/parsers/helpers/parse-utils.js +29 -16
- package/dist/lib/parsers/parse-3d-tile-batched-model.js +30 -26
- package/dist/lib/parsers/parse-3d-tile-composite.d.ts +6 -1
- package/dist/lib/parsers/parse-3d-tile-composite.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-composite.js +23 -16
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +3 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.js +19 -9
- package/dist/lib/parsers/parse-3d-tile-header.d.ts +6 -4
- package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-header.js +166 -138
- package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts +3 -1
- package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-instanced-model.js +179 -170
- package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts +4 -2
- package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-point-cloud.js +351 -184
- package/dist/lib/parsers/parse-3d-tile.js +36 -31
- 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.js +7 -2
- package/dist/tile-3d-subtree-loader.js +22 -13
- package/dist/tile-3d-writer.js +24 -17
- package/dist/tiles-3d-loader.d.ts +15 -1
- package/dist/tiles-3d-loader.d.ts.map +1 -1
- package/dist/tiles-3d-loader.js +67 -71
- package/dist/types.d.ts +28 -15
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -2
- package/package.json +12 -11
- package/src/cesium-ion-loader.ts +1 -0
- package/src/index.ts +1 -1
- package/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts +104 -27
- package/src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts +4 -2
- package/src/lib/parsers/helpers/parse-3d-tile-subtree.ts +50 -7
- package/src/lib/parsers/parse-3d-tile-composite.ts +17 -6
- package/src/lib/parsers/parse-3d-tile-gltf.ts +25 -0
- package/src/lib/parsers/parse-3d-tile-header.ts +93 -24
- package/src/lib/parsers/parse-3d-tile-instanced-model.ts +17 -3
- package/src/lib/parsers/parse-3d-tile-point-cloud.ts +37 -10
- 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/tiles-3d-loader.ts +64 -46
- package/src/types.ts +20 -5
- 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-implicit-tiles.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-subtree.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-gltf.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-subtree-loader.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-gltf.js +0 -16
|
@@ -10,14 +10,28 @@ import Tile3DBatchTable from '../classes/tile-3d-batch-table';
|
|
|
10
10
|
import {parse3DTileHeaderSync} from './helpers/parse-3d-tile-header';
|
|
11
11
|
import {parse3DTileTablesHeaderSync, parse3DTileTablesSync} from './helpers/parse-3d-tile-tables';
|
|
12
12
|
import {parse3DTileGLTFViewSync, extractGLTF} from './helpers/parse-3d-tile-gltf-view';
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
import {Tiles3DLoaderOptions} from '../../tiles-3d-loader';
|
|
14
|
+
import {LoaderContext} from '@loaders.gl/loader-utils';
|
|
15
|
+
|
|
16
|
+
export async function parseInstancedModel3DTile(
|
|
17
|
+
tile,
|
|
18
|
+
arrayBuffer: ArrayBuffer,
|
|
19
|
+
byteOffset: number,
|
|
20
|
+
options: Tiles3DLoaderOptions,
|
|
21
|
+
context: LoaderContext
|
|
22
|
+
): Promise<number> {
|
|
15
23
|
byteOffset = parseInstancedModel(tile, arrayBuffer, byteOffset, options, context);
|
|
16
24
|
await extractGLTF(tile, tile.gltfFormat, options, context);
|
|
17
25
|
return byteOffset;
|
|
18
26
|
}
|
|
19
27
|
|
|
20
|
-
function parseInstancedModel(
|
|
28
|
+
function parseInstancedModel(
|
|
29
|
+
tile,
|
|
30
|
+
arrayBuffer: ArrayBuffer,
|
|
31
|
+
byteOffset: number,
|
|
32
|
+
options: Tiles3DLoaderOptions,
|
|
33
|
+
context: LoaderContext
|
|
34
|
+
): number {
|
|
21
35
|
byteOffset = parse3DTileHeaderSync(tile, arrayBuffer, byteOffset);
|
|
22
36
|
if (tile.version !== 1) {
|
|
23
37
|
throw new Error(`Instanced 3D Model version ${tile.version} is not supported`);
|
|
@@ -12,8 +12,16 @@ 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
|
+
|
|
18
|
+
export async function parsePointCloud3DTile(
|
|
19
|
+
tile,
|
|
20
|
+
arrayBuffer: ArrayBuffer,
|
|
21
|
+
byteOffset: number,
|
|
22
|
+
options: Tiles3DLoaderOptions,
|
|
23
|
+
context: LoaderContext
|
|
24
|
+
): Promise<number> {
|
|
17
25
|
byteOffset = parse3DTileHeaderSync(tile, arrayBuffer, byteOffset);
|
|
18
26
|
byteOffset = parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset);
|
|
19
27
|
byteOffset = parse3DTileTablesSync(tile, arrayBuffer, byteOffset, options);
|
|
@@ -24,13 +32,14 @@ export async function parsePointCloud3DTile(tile, arrayBuffer, byteOffset, optio
|
|
|
24
32
|
await parseDraco(tile, featureTable, batchTable, options, context);
|
|
25
33
|
|
|
26
34
|
parsePositions(tile, featureTable, options);
|
|
35
|
+
// @ts-expect-error TODO - do we need to assert on the batch table?
|
|
27
36
|
parseColors(tile, featureTable, batchTable);
|
|
28
37
|
parseNormals(tile, featureTable);
|
|
29
38
|
|
|
30
39
|
return byteOffset;
|
|
31
40
|
}
|
|
32
41
|
|
|
33
|
-
function initializeTile(tile) {
|
|
42
|
+
function initializeTile(tile): void {
|
|
34
43
|
// Initialize point cloud tile defaults
|
|
35
44
|
tile.attributes = {
|
|
36
45
|
positions: null,
|
|
@@ -44,7 +53,10 @@ function initializeTile(tile) {
|
|
|
44
53
|
tile.isOctEncoded16P = false;
|
|
45
54
|
}
|
|
46
55
|
|
|
47
|
-
function parsePointCloudTables(tile) {
|
|
56
|
+
function parsePointCloudTables(tile): {
|
|
57
|
+
featureTable: Tile3DFeatureTable;
|
|
58
|
+
batchTable: Tile3DBatchTable | null;
|
|
59
|
+
} {
|
|
48
60
|
const featureTable = new Tile3DFeatureTable(tile.featureTableJson, tile.featureTableBinary);
|
|
49
61
|
|
|
50
62
|
const pointsLength = featureTable.getGlobalProperty('POINTS_LENGTH');
|
|
@@ -64,7 +76,11 @@ function parsePointCloudTables(tile) {
|
|
|
64
76
|
return {featureTable, batchTable};
|
|
65
77
|
}
|
|
66
78
|
|
|
67
|
-
function parsePositions(
|
|
79
|
+
function parsePositions(
|
|
80
|
+
tile,
|
|
81
|
+
featureTable: Tile3DFeatureTable,
|
|
82
|
+
options: Tiles3DLoaderOptions
|
|
83
|
+
): void {
|
|
68
84
|
if (!tile.attributes.positions) {
|
|
69
85
|
if (featureTable.hasProperty('POSITION')) {
|
|
70
86
|
tile.attributes.positions = featureTable.getPropertyArray('POSITION', GL.FLOAT, 3);
|
|
@@ -101,7 +117,7 @@ function parsePositions(tile, featureTable, options) {
|
|
|
101
117
|
}
|
|
102
118
|
}
|
|
103
119
|
|
|
104
|
-
function parseColors(tile, featureTable, batchTable) {
|
|
120
|
+
function parseColors(tile, featureTable: Tile3DFeatureTable, batchTable: Tile3DBatchTable): void {
|
|
105
121
|
if (!tile.attributes.colors) {
|
|
106
122
|
let colors = null;
|
|
107
123
|
if (featureTable.hasProperty('RGBA')) {
|
|
@@ -122,7 +138,7 @@ function parseColors(tile, featureTable, batchTable) {
|
|
|
122
138
|
}
|
|
123
139
|
}
|
|
124
140
|
|
|
125
|
-
function parseNormals(tile, featureTable) {
|
|
141
|
+
function parseNormals(tile, featureTable: Tile3DFeatureTable): void {
|
|
126
142
|
if (!tile.attributes.normals) {
|
|
127
143
|
let normals = null;
|
|
128
144
|
if (featureTable.hasProperty('NORMAL')) {
|
|
@@ -136,7 +152,7 @@ function parseNormals(tile, featureTable) {
|
|
|
136
152
|
}
|
|
137
153
|
}
|
|
138
154
|
|
|
139
|
-
function parseBatchIds(tile, featureTable) {
|
|
155
|
+
function parseBatchIds(tile, featureTable: Tile3DFeatureTable): Tile3DBatchTable | null {
|
|
140
156
|
let batchTable: Tile3DBatchTable | null = null;
|
|
141
157
|
if (!tile.batchIds && featureTable.hasProperty('BATCH_ID')) {
|
|
142
158
|
tile.batchIds = featureTable.getPropertyArray('BATCH_ID', GL.UNSIGNED_SHORT, 1);
|
|
@@ -154,7 +170,13 @@ function parseBatchIds(tile, featureTable) {
|
|
|
154
170
|
}
|
|
155
171
|
|
|
156
172
|
// eslint-disable-next-line complexity
|
|
157
|
-
async function parseDraco(
|
|
173
|
+
async function parseDraco(
|
|
174
|
+
tile,
|
|
175
|
+
featureTable: Tile3DFeatureTable,
|
|
176
|
+
batchTable,
|
|
177
|
+
options: Tiles3DLoaderOptions,
|
|
178
|
+
context: LoaderContext
|
|
179
|
+
) {
|
|
158
180
|
let dracoBuffer;
|
|
159
181
|
let dracoFeatureTableProperties;
|
|
160
182
|
let dracoBatchTableProperties;
|
|
@@ -202,7 +224,12 @@ async function parseDraco(tile, featureTable, batchTable, options, context) {
|
|
|
202
224
|
}
|
|
203
225
|
|
|
204
226
|
// eslint-disable-next-line complexity, max-statements
|
|
205
|
-
export async function loadDraco(
|
|
227
|
+
export async function loadDraco(
|
|
228
|
+
tile,
|
|
229
|
+
dracoData,
|
|
230
|
+
options: Tiles3DLoaderOptions,
|
|
231
|
+
context: LoaderContext
|
|
232
|
+
) {
|
|
206
233
|
const {parse} = context;
|
|
207
234
|
const dracoOptions = {
|
|
208
235
|
...options,
|
|
@@ -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
|
+
}
|