@loaders.gl/3d-tiles 3.4.0-alpha.1 → 3.4.0-alpha.3
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/cesium-ion-loader.d.ts.map +1 -1
- package/dist/cesium-ion-loader.js +1 -0
- package/dist/dist.min.js +2517 -299
- package/dist/es5/cesium-ion-loader.js +23 -27
- package/dist/es5/cesium-ion-loader.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js +0 -2
- package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -1
- package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js +0 -6
- package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -1
- package/dist/es5/lib/classes/tile-3d-batch-table.js +2 -19
- package/dist/es5/lib/classes/tile-3d-batch-table.js.map +1 -1
- package/dist/es5/lib/classes/tile-3d-feature-table.js +1 -4
- package/dist/es5/lib/classes/tile-3d-feature-table.js.map +1 -1
- package/dist/es5/lib/constants.js +0 -2
- package/dist/es5/lib/constants.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js +0 -5
- package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile-composite.js +0 -2
- package/dist/es5/lib/encoders/encode-3d-tile-composite.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js +0 -3
- package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js +0 -3
- package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile.js +0 -1
- package/dist/es5/lib/encoders/encode-3d-tile.js.map +1 -1
- package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js +0 -3
- package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js.map +1 -1
- package/dist/es5/lib/ion/ion.js +109 -117
- package/dist/es5/lib/ion/ion.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js +0 -3
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-positions.js +0 -3
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js +161 -131
- package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +34 -42
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js +0 -3
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js +93 -100
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js +0 -5
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-utils.js +0 -2
- package/dist/es5/lib/parsers/helpers/parse-utils.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js +14 -16
- package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js +24 -27
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +12 -14
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-header.js +152 -148
- package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js +10 -22
- package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js +111 -119
- package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile.js +41 -44
- package/dist/es5/lib/parsers/parse-3d-tile.js.map +1 -1
- 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 +1 -1
- package/dist/es5/lib/utils/version.js.map +1 -1
- package/dist/es5/tile-3d-subtree-loader.js.map +1 -1
- package/dist/es5/tile-3d-writer.js.map +1 -1
- package/dist/es5/tiles-3d-loader.js +59 -65
- package/dist/es5/tiles-3d-loader.js.map +1 -1
- package/dist/esm/bundle.js +0 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/cesium-ion-loader.js +0 -2
- package/dist/esm/cesium-ion-loader.js.map +1 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/classes/helpers/tile-3d-accessor-utils.js +0 -1
- package/dist/esm/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -1
- package/dist/esm/lib/classes/tile-3d-batch-table-hierarchy.js +0 -7
- package/dist/esm/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -1
- package/dist/esm/lib/classes/tile-3d-batch-table.js +0 -13
- package/dist/esm/lib/classes/tile-3d-batch-table.js.map +1 -1
- package/dist/esm/lib/classes/tile-3d-feature-table.js +0 -3
- package/dist/esm/lib/classes/tile-3d-feature-table.js.map +1 -1
- package/dist/esm/lib/constants.js +0 -3
- package/dist/esm/lib/constants.js.map +1 -1
- package/dist/esm/lib/encoders/encode-3d-tile-batched-model.js +0 -8
- package/dist/esm/lib/encoders/encode-3d-tile-batched-model.js.map +1 -1
- package/dist/esm/lib/encoders/encode-3d-tile-composite.js +0 -4
- package/dist/esm/lib/encoders/encode-3d-tile-composite.js.map +1 -1
- package/dist/esm/lib/encoders/encode-3d-tile-instanced-model.js +0 -6
- package/dist/esm/lib/encoders/encode-3d-tile-instanced-model.js.map +1 -1
- package/dist/esm/lib/encoders/encode-3d-tile-point-cloud.js +0 -5
- package/dist/esm/lib/encoders/encode-3d-tile-point-cloud.js.map +1 -1
- package/dist/esm/lib/encoders/encode-3d-tile.js +0 -2
- package/dist/esm/lib/encoders/encode-3d-tile.js.map +1 -1
- package/dist/esm/lib/encoders/helpers/encode-3d-tile-header.js +0 -3
- package/dist/esm/lib/encoders/helpers/encode-3d-tile-header.js.map +1 -1
- package/dist/esm/lib/ion/ion.js +0 -9
- package/dist/esm/lib/ion/ion.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js +0 -4
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-positions.js +0 -4
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js +50 -19
- package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +1 -8
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-header.js +0 -4
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js +0 -6
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js +0 -6
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-utils.js +0 -4
- package/dist/esm/lib/parsers/helpers/parse-utils.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-batched-model.js +0 -3
- package/dist/esm/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-composite.js +0 -6
- package/dist/esm/lib/parsers/parse-3d-tile-composite.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-header.js +13 -6
- package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js +0 -12
- package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js +0 -6
- package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile.js +0 -4
- package/dist/esm/lib/parsers/parse-3d-tile.js.map +1 -1
- 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 +1 -2
- package/dist/esm/lib/utils/version.js.map +1 -1
- package/dist/esm/tile-3d-subtree-loader.js +0 -1
- package/dist/esm/tile-3d-subtree-loader.js.map +1 -1
- package/dist/esm/tile-3d-writer.js +0 -1
- package/dist/esm/tile-3d-writer.js.map +1 -1
- package/dist/esm/tiles-3d-loader.js +0 -1
- package/dist/esm/tiles-3d-loader.js.map +1 -1
- 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 +60 -11
- package/dist/lib/parsers/parse-3d-tile-batched-model.js +1 -1
- package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-header.js +13 -1
- 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/package.json +9 -8
- package/src/cesium-ion-loader.ts +1 -0
- package/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts +102 -13
- package/src/lib/parsers/parse-3d-tile-header.ts +17 -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
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { decodeRGB565, GL } from '@loaders.gl/math';
|
|
2
|
-
|
|
3
2
|
export function normalize3DTileColorAttribute(tile, colors, batchTable) {
|
|
4
3
|
if (!colors && (!tile || !tile.batchIds || !batchTable)) {
|
|
5
4
|
return null;
|
|
@@ -26,7 +25,6 @@ export function normalize3DTileColorAttribute(tile, colors, batchTable) {
|
|
|
26
25
|
normalized: true
|
|
27
26
|
};
|
|
28
27
|
}
|
|
29
|
-
|
|
30
28
|
if (isRGB565) {
|
|
31
29
|
const colorArray = new Uint8ClampedArray(pointCount * 3);
|
|
32
30
|
for (let i = 0; i < pointCount; i++) {
|
|
@@ -42,7 +40,6 @@ export function normalize3DTileColorAttribute(tile, colors, batchTable) {
|
|
|
42
40
|
normalized: true
|
|
43
41
|
};
|
|
44
42
|
}
|
|
45
|
-
|
|
46
43
|
if (colors && colors.length === pointCount * 3) {
|
|
47
44
|
return {
|
|
48
45
|
type: GL.UNSIGNED_BYTE,
|
|
@@ -51,7 +48,6 @@ export function normalize3DTileColorAttribute(tile, colors, batchTable) {
|
|
|
51
48
|
normalized: true
|
|
52
49
|
};
|
|
53
50
|
}
|
|
54
|
-
|
|
55
51
|
return {
|
|
56
52
|
type: GL.UNSIGNED_BYTE,
|
|
57
53
|
value: colors,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-3d-tile-colors.js","names":["decodeRGB565","GL","normalize3DTileColorAttribute","tile","colors","batchTable","batchIds","isRGB565","pointCount","colorArray","Uint8ClampedArray","i","batchId","dimensions","getProperty","color","map","d","type","UNSIGNED_BYTE","value","size","normalized","length"],"sources":["../../../../../src/lib/parsers/helpers/normalize-3d-tile-colors.ts"],"sourcesContent":["import {decodeRGB565, GL} from '@loaders.gl/math';\n\n/* eslint-disable complexity*/\nexport function normalize3DTileColorAttribute(tile, colors, batchTable?) {\n // no colors defined\n if (!colors && (!tile || !tile.batchIds || !batchTable)) {\n return null;\n }\n\n const {batchIds, isRGB565, pointCount} = tile;\n // Batch table, look up colors in table\n if (batchIds && batchTable) {\n const colorArray = new Uint8ClampedArray(pointCount * 3);\n for (let i = 0; i < pointCount; i++) {\n const batchId = batchIds[i];\n // TODO figure out what is `dimensions` used for\n const dimensions = batchTable.getProperty(batchId, 'dimensions');\n const color = dimensions.map((d) => d * 255);\n colorArray[i * 3] = color[0];\n colorArray[i * 3 + 1] = color[1];\n colorArray[i * 3 + 2] = color[2];\n }\n return {\n type: GL.UNSIGNED_BYTE,\n value: colorArray,\n size: 3,\n normalized: true\n };\n }\n\n // RGB565 case, convert to RGB\n if (isRGB565) {\n const colorArray = new Uint8ClampedArray(pointCount * 3);\n for (let i = 0; i < pointCount; i++) {\n const color = decodeRGB565(colors[i]);\n colorArray[i * 3] = color[0];\n colorArray[i * 3 + 1] = color[1];\n colorArray[i * 3 + 2] = color[2];\n }\n return {\n type: GL.UNSIGNED_BYTE,\n value: colorArray,\n size: 3,\n normalized: true\n };\n }\n\n // RGB case (tile.isTranslucent)\n if (colors && colors.length === pointCount * 3) {\n return {\n type: GL.UNSIGNED_BYTE,\n value: colors,\n size: 3,\n normalized: true\n };\n }\n\n // DEFAULT: RGBA case\n return {\n type: GL.UNSIGNED_BYTE,\n value: colors,\n size: 4,\n normalized: true\n };\n}\n/* eslint-enable complexity*/\n"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,EAAE,QAAO,kBAAkB
|
|
1
|
+
{"version":3,"file":"normalize-3d-tile-colors.js","names":["decodeRGB565","GL","normalize3DTileColorAttribute","tile","colors","batchTable","batchIds","isRGB565","pointCount","colorArray","Uint8ClampedArray","i","batchId","dimensions","getProperty","color","map","d","type","UNSIGNED_BYTE","value","size","normalized","length"],"sources":["../../../../../src/lib/parsers/helpers/normalize-3d-tile-colors.ts"],"sourcesContent":["import {decodeRGB565, GL} from '@loaders.gl/math';\n\n/* eslint-disable complexity*/\nexport function normalize3DTileColorAttribute(tile, colors, batchTable?) {\n // no colors defined\n if (!colors && (!tile || !tile.batchIds || !batchTable)) {\n return null;\n }\n\n const {batchIds, isRGB565, pointCount} = tile;\n // Batch table, look up colors in table\n if (batchIds && batchTable) {\n const colorArray = new Uint8ClampedArray(pointCount * 3);\n for (let i = 0; i < pointCount; i++) {\n const batchId = batchIds[i];\n // TODO figure out what is `dimensions` used for\n const dimensions = batchTable.getProperty(batchId, 'dimensions');\n const color = dimensions.map((d) => d * 255);\n colorArray[i * 3] = color[0];\n colorArray[i * 3 + 1] = color[1];\n colorArray[i * 3 + 2] = color[2];\n }\n return {\n type: GL.UNSIGNED_BYTE,\n value: colorArray,\n size: 3,\n normalized: true\n };\n }\n\n // RGB565 case, convert to RGB\n if (isRGB565) {\n const colorArray = new Uint8ClampedArray(pointCount * 3);\n for (let i = 0; i < pointCount; i++) {\n const color = decodeRGB565(colors[i]);\n colorArray[i * 3] = color[0];\n colorArray[i * 3 + 1] = color[1];\n colorArray[i * 3 + 2] = color[2];\n }\n return {\n type: GL.UNSIGNED_BYTE,\n value: colorArray,\n size: 3,\n normalized: true\n };\n }\n\n // RGB case (tile.isTranslucent)\n if (colors && colors.length === pointCount * 3) {\n return {\n type: GL.UNSIGNED_BYTE,\n value: colors,\n size: 3,\n normalized: true\n };\n }\n\n // DEFAULT: RGBA case\n return {\n type: GL.UNSIGNED_BYTE,\n value: colors,\n size: 4,\n normalized: true\n };\n}\n/* eslint-enable complexity*/\n"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,EAAE,QAAO,kBAAkB;AAGjD,OAAO,SAASC,6BAA6BA,CAACC,IAAI,EAAEC,MAAM,EAAEC,UAAW,EAAE;EAEvE,IAAI,CAACD,MAAM,KAAK,CAACD,IAAI,IAAI,CAACA,IAAI,CAACG,QAAQ,IAAI,CAACD,UAAU,CAAC,EAAE;IACvD,OAAO,IAAI;EACb;EAEA,MAAM;IAACC,QAAQ;IAAEC,QAAQ;IAAEC;EAAU,CAAC,GAAGL,IAAI;EAE7C,IAAIG,QAAQ,IAAID,UAAU,EAAE;IAC1B,MAAMI,UAAU,GAAG,IAAIC,iBAAiB,CAACF,UAAU,GAAG,CAAC,CAAC;IACxD,KAAK,IAAIG,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,UAAU,EAAEG,CAAC,EAAE,EAAE;MACnC,MAAMC,OAAO,GAAGN,QAAQ,CAACK,CAAC,CAAC;MAE3B,MAAME,UAAU,GAAGR,UAAU,CAACS,WAAW,CAACF,OAAO,EAAE,YAAY,CAAC;MAChE,MAAMG,KAAK,GAAGF,UAAU,CAACG,GAAG,CAAEC,CAAC,IAAKA,CAAC,GAAG,GAAG,CAAC;MAC5CR,UAAU,CAACE,CAAC,GAAG,CAAC,CAAC,GAAGI,KAAK,CAAC,CAAC,CAAC;MAC5BN,UAAU,CAACE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAGI,KAAK,CAAC,CAAC,CAAC;MAChCN,UAAU,CAACE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG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als.js","names":["Vector3","GL","octDecode","scratchNormal","normalize3DTileNormalAttribute","tile","normals","isOctEncoded16P","decodedArray","Float32Array","pointsLength","i","toArray","type","FLOAT","size","value"],"sources":["../../../../../src/lib/parsers/helpers/normalize-3d-tile-normals.ts"],"sourcesContent":["import {Vector3} from '@math.gl/core';\nimport {GL, octDecode} from '@loaders.gl/math';\n\nconst scratchNormal = new Vector3();\n\nexport function normalize3DTileNormalAttribute(tile, normals) {\n if (!normals) {\n return null;\n }\n\n if (tile.isOctEncoded16P) {\n const decodedArray = new Float32Array(tile.pointsLength * 3);\n for (let i = 0; i < tile.pointsLength; i++) {\n octDecode(normals[i * 2], normals[i * 2 + 1], scratchNormal);\n // @ts-ignore\n scratchNormal.toArray(decodedArray, i * 3);\n }\n\n return {\n type: GL.FLOAT,\n size: 2,\n value: decodedArray\n };\n }\n\n return {\n type: GL.FLOAT,\n size: 2,\n value: normals\n };\n}\n"],"mappings":"AAAA,SAAQA,OAAO,QAAO,eAAe;AACrC,SAAQC,EAAE,EAAEC,SAAS,QAAO,kBAAkB;AAE9C,MAAMC,aAAa,GAAG,IAAIH,OAAO,EAAE;AAEnC,OAAO,SAASI,
|
|
1
|
+
{"version":3,"file":"normalize-3d-tile-normals.js","names":["Vector3","GL","octDecode","scratchNormal","normalize3DTileNormalAttribute","tile","normals","isOctEncoded16P","decodedArray","Float32Array","pointsLength","i","toArray","type","FLOAT","size","value"],"sources":["../../../../../src/lib/parsers/helpers/normalize-3d-tile-normals.ts"],"sourcesContent":["import {Vector3} from '@math.gl/core';\nimport {GL, octDecode} from '@loaders.gl/math';\n\nconst scratchNormal = new Vector3();\n\nexport function normalize3DTileNormalAttribute(tile, normals) {\n if (!normals) {\n return null;\n }\n\n if (tile.isOctEncoded16P) {\n const decodedArray = new Float32Array(tile.pointsLength * 3);\n for (let i = 0; i < tile.pointsLength; i++) {\n octDecode(normals[i * 2], normals[i * 2 + 1], scratchNormal);\n // @ts-ignore\n scratchNormal.toArray(decodedArray, i * 3);\n }\n\n return {\n type: GL.FLOAT,\n size: 2,\n value: decodedArray\n };\n }\n\n return {\n type: GL.FLOAT,\n size: 2,\n value: normals\n };\n}\n"],"mappings":"AAAA,SAAQA,OAAO,QAAO,eAAe;AACrC,SAAQC,EAAE,EAAEC,SAAS,QAAO,kBAAkB;AAE9C,MAAMC,aAAa,GAAG,IAAIH,OAAO,EAAE;AAEnC,OAAO,SAASI,8BAA8BA,CAACC,IAAI,EAAEC,OAAO,EAAE;EAC5D,IAAI,CAACA,OAAO,EAAE;IACZ,OAAO,IAAI;EACb;EAEA,IAAID,IAAI,CAACE,eAAe,EAAE;IACxB,MAAMC,YAAY,GAAG,IAAIC,YAAY,CAACJ,IAAI,CAACK,YAAY,GAAG,CAAC,CAAC;IAC5D,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,IAAI,CAACK,YAAY,EAAEC,CAAC,EAAE,EAAE;MAC1CT,SAAS,CAACI,OAAO,CAACK,CAAC,GAAG,CAAC,CAAC,EAAEL,OAAO,CAACK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAER,aAAa,CAAC;MAE5DA,aAAa,CAACS,OAAO,CAACJ,YAAY,EAAEG,CAAC,GAAG,CAAC,CAAC;IAC5C;IAEA,OAAO;MACLE,IAAI,EAAEZ,EAAE,CAACa,KAAK;MACdC,IAAI,EAAE,CAAC;MACPC,KAAK,EAAER;IACT,CAAC;EACH;EAEA,OAAO;IACLK,IAAI,EAAEZ,EAAE,CAACa,KAAK;IACdC,IAAI,EAAE,CAAC;IACPC,KAAK,EAAEV;EACT,CAAC;AACH"}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { Vector3 } from '@math.gl/core';
|
|
2
2
|
import { GL } from '@loaders.gl/math';
|
|
3
|
-
|
|
4
3
|
export function normalize3DTilePositionAttribute(tile, positions, options) {
|
|
5
4
|
if (!tile.isQuantized) {
|
|
6
5
|
return positions;
|
|
7
6
|
}
|
|
8
|
-
|
|
9
7
|
if (options['3d-tiles'] && options['3d-tiles'].decodeQuantizedPositions) {
|
|
10
8
|
tile.isQuantized = false;
|
|
11
9
|
return decodeQuantizedPositions(tile, positions);
|
|
12
10
|
}
|
|
13
|
-
|
|
14
11
|
return {
|
|
15
12
|
type: GL.UNSIGNED_SHORT,
|
|
16
13
|
value: positions,
|
|
@@ -18,7 +15,6 @@ export function normalize3DTilePositionAttribute(tile, positions, options) {
|
|
|
18
15
|
normalized: true
|
|
19
16
|
};
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
function decodeQuantizedPositions(tile, positions) {
|
|
23
19
|
const scratchPosition = new Vector3();
|
|
24
20
|
const decodedArray = new Float32Array(tile.pointCount * 3);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-3d-tile-positions.js","names":["Vector3","GL","normalize3DTilePositionAttribute","tile","positions","options","isQuantized","decodeQuantizedPositions","type","UNSIGNED_SHORT","value","size","normalized","scratchPosition","decodedArray","Float32Array","pointCount","i","set","scale","quantizedRange","multiply","quantizedVolumeScale","add","quantizedVolumeOffset","toArray"],"sources":["../../../../../src/lib/parsers/helpers/normalize-3d-tile-positions.ts"],"sourcesContent":["import {Vector3} from '@math.gl/core';\nimport {GL} from '@loaders.gl/math';\n\n// Prepare attribute for positions\nexport function normalize3DTilePositionAttribute(tile, positions, options) {\n if (!tile.isQuantized) {\n return positions;\n }\n\n // For quantized posititions, either expand to Float32Array or return custom accessor\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/TileFormats/Instanced3DModel/README.md#quantized-positions\n\n // Optionally decodes quantized positions on GPU, for simpler renderers that don't accept normalized attributes\n if (options['3d-tiles'] && options['3d-tiles'].decodeQuantizedPositions) {\n tile.isQuantized = false;\n return decodeQuantizedPositions(tile, positions);\n }\n\n // Default: Use normalized shorts directly, no copying/processing.\n // NOTE: The \"missing\" offset/scaling operations are automatically added to modelMatrix if `tile.isQuantized === true`\n return {\n type: GL.UNSIGNED_SHORT,\n value: positions,\n size: 3,\n normalized: true\n };\n}\n\n// Pre-scale quantized positions on CPU\nfunction decodeQuantizedPositions(tile, positions) {\n const scratchPosition = new Vector3();\n const decodedArray = new Float32Array(tile.pointCount * 3);\n\n for (let i = 0; i < tile.pointCount; i++) {\n // POSITION = POSITION_QUANTIZED / 65535.0 * QUANTIZED_VOLUME_SCALE + QUANTIZED_VOLUME_OFFSET\n scratchPosition\n .set(positions[i * 3], positions[i * 3 + 1], positions[i * 3 + 2])\n .scale(1 / tile.quantizedRange)\n .multiply(tile.quantizedVolumeScale)\n .add(tile.quantizedVolumeOffset)\n .toArray(decodedArray, i * 3);\n }\n\n return decodedArray;\n}\n"],"mappings":"AAAA,SAAQA,OAAO,QAAO,eAAe;AACrC,SAAQC,EAAE,QAAO,kBAAkB
|
|
1
|
+
{"version":3,"file":"normalize-3d-tile-positions.js","names":["Vector3","GL","normalize3DTilePositionAttribute","tile","positions","options","isQuantized","decodeQuantizedPositions","type","UNSIGNED_SHORT","value","size","normalized","scratchPosition","decodedArray","Float32Array","pointCount","i","set","scale","quantizedRange","multiply","quantizedVolumeScale","add","quantizedVolumeOffset","toArray"],"sources":["../../../../../src/lib/parsers/helpers/normalize-3d-tile-positions.ts"],"sourcesContent":["import {Vector3} from '@math.gl/core';\nimport {GL} from '@loaders.gl/math';\n\n// Prepare attribute for positions\nexport function normalize3DTilePositionAttribute(tile, positions, options) {\n if (!tile.isQuantized) {\n return positions;\n }\n\n // For quantized posititions, either expand to Float32Array or return custom accessor\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/TileFormats/Instanced3DModel/README.md#quantized-positions\n\n // Optionally decodes quantized positions on GPU, for simpler renderers that don't accept normalized attributes\n if (options['3d-tiles'] && options['3d-tiles'].decodeQuantizedPositions) {\n tile.isQuantized = false;\n return decodeQuantizedPositions(tile, positions);\n }\n\n // Default: Use normalized shorts directly, no copying/processing.\n // NOTE: The \"missing\" offset/scaling operations are automatically added to modelMatrix if `tile.isQuantized === true`\n return {\n type: GL.UNSIGNED_SHORT,\n value: positions,\n size: 3,\n normalized: true\n };\n}\n\n// Pre-scale quantized positions on CPU\nfunction decodeQuantizedPositions(tile, positions) {\n const scratchPosition = new Vector3();\n const decodedArray = new Float32Array(tile.pointCount * 3);\n\n for (let i = 0; i < tile.pointCount; i++) {\n // POSITION = POSITION_QUANTIZED / 65535.0 * QUANTIZED_VOLUME_SCALE + QUANTIZED_VOLUME_OFFSET\n scratchPosition\n .set(positions[i * 3], positions[i * 3 + 1], positions[i * 3 + 2])\n .scale(1 / tile.quantizedRange)\n .multiply(tile.quantizedVolumeScale)\n .add(tile.quantizedVolumeOffset)\n .toArray(decodedArray, i * 3);\n }\n\n return decodedArray;\n}\n"],"mappings":"AAAA,SAAQA,OAAO,QAAO,eAAe;AACrC,SAAQC,EAAE,QAAO,kBAAkB;AAGnC,OAAO,SAASC,gCAAgCA,CAACC,IAAI,EAAEC,SAAS,EAAEC,OAAO,EAAE;EACzE,IAAI,CAACF,IAAI,CAACG,WAAW,EAAE;IACrB,OAAOF,SAAS;EAClB;EAMA,IAAIC,OAAO,CAAC,UAAU,CAAC,IAAIA,OAAO,CAAC,UAAU,CAAC,CAACE,wBAAwB,EAAE;IACvEJ,IAAI,CAACG,WAAW,GAAG,KAAK;IACxB,OAAOC,wBAAwB,CAACJ,IAAI,EAAEC,SAAS,CAAC;EAClD;EAIA,OAAO;IACLI,IAAI,EAAEP,EAAE,CAACQ,cAAc;IACvBC,KAAK,EAAEN,SAAS;IAChBO,IAAI,EAAE,CAAC;IACPC,UAAU,EAAE;EACd,CAAC;AACH;AAGA,SAASL,wBAAwBA,CAACJ,IAAI,EAAEC,SAAS,EAAE;EACjD,MAAMS,eAAe,GAAG,IAAIb,OAAO,EAAE;EACrC,MAAMc,YAAY,GAAG,IAAIC,YAAY,CAACZ,IAAI,CAACa,UAAU,GAAG,CAAC,CAAC;EAE1D,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGd,IAAI,CAACa,UAAU,EAAEC,CAAC,EAAE,EAAE;IAExCJ,eAAe,CACZK,GAAG,CAACd,SAAS,CAACa,CAAC,GAAG,CAAC,CAAC,EAAEb,SAAS,CAACa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAEb,SAAS,CAACa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CACjEE,KAAK,CAAC,CAAC,GAAGhB,IAAI,CAACiB,cAAc,CAAC,CAC9BC,QAAQ,CAAClB,IAAI,CAACmB,oBAAoB,CAAC,CACnCC,GAAG,CAACpB,IAAI,CAACqB,qBAAqB,CAAC,CAC/BC,OAAO,CAACX,YAAY,EAAEG,CAAC,GAAG,CAAC,CAAC;EACjC;EAEA,OAAOH,YAAY;AACrB"}
|
|
@@ -1,12 +1,43 @@
|
|
|
1
1
|
import { Tile3DSubtreeLoader } from '../../../tile-3d-subtree-loader';
|
|
2
2
|
import { load } from '@loaders.gl/core';
|
|
3
|
+
import { getS2CellIdFromToken, getS2ChildCellId, getS2TokenFromCellId } from '../../utils/s2/index';
|
|
4
|
+
import { convertS2BoundingVolumetoOBB } from '../../utils/obb/s2-corners-to-obb';
|
|
3
5
|
const QUADTREE_DEVISION_COUNT = 4;
|
|
4
6
|
const OCTREE_DEVISION_COUNT = 8;
|
|
5
7
|
const SUBDIVISION_COUNT_MAP = {
|
|
6
8
|
QUADTREE: QUADTREE_DEVISION_COUNT,
|
|
7
9
|
OCTREE: OCTREE_DEVISION_COUNT
|
|
8
10
|
};
|
|
9
|
-
|
|
11
|
+
function getChildS2VolumeBox(s2VolumeBox, index, subdivisionScheme) {
|
|
12
|
+
if (s2VolumeBox !== null && s2VolumeBox !== void 0 && s2VolumeBox.box) {
|
|
13
|
+
const cellId = getS2CellIdFromToken(s2VolumeBox.s2VolumeInfo.token);
|
|
14
|
+
const childCellId = getS2ChildCellId(cellId, index);
|
|
15
|
+
const childToken = getS2TokenFromCellId(childCellId);
|
|
16
|
+
const s2ChildVolumeInfo = {
|
|
17
|
+
...s2VolumeBox.s2VolumeInfo
|
|
18
|
+
};
|
|
19
|
+
s2ChildVolumeInfo.token = childToken;
|
|
20
|
+
switch (subdivisionScheme) {
|
|
21
|
+
case 'OCTREE':
|
|
22
|
+
const s2VolumeInfo = s2VolumeBox.s2VolumeInfo;
|
|
23
|
+
const delta = s2VolumeInfo.maximumHeight - s2VolumeInfo.minimumHeight;
|
|
24
|
+
const sizeZ = delta / 2.0;
|
|
25
|
+
const midZ = s2VolumeInfo.minimumHeight + delta / 2.0;
|
|
26
|
+
s2VolumeInfo.minimumHeight = midZ - sizeZ;
|
|
27
|
+
s2VolumeInfo.maximumHeight = midZ + sizeZ;
|
|
28
|
+
break;
|
|
29
|
+
default:
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
const box = convertS2BoundingVolumetoOBB(s2ChildVolumeInfo);
|
|
33
|
+
const childS2VolumeBox = {
|
|
34
|
+
box,
|
|
35
|
+
s2VolumeInfo: s2ChildVolumeInfo
|
|
36
|
+
};
|
|
37
|
+
return childS2VolumeBox;
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
10
41
|
export async function parseImplicitTiles(params) {
|
|
11
42
|
const {
|
|
12
43
|
options,
|
|
@@ -23,7 +54,8 @@ export async function parseImplicitTiles(params) {
|
|
|
23
54
|
x: 0,
|
|
24
55
|
y: 0,
|
|
25
56
|
z: 0
|
|
26
|
-
}
|
|
57
|
+
},
|
|
58
|
+
s2VolumeBox
|
|
27
59
|
} = params;
|
|
28
60
|
let {
|
|
29
61
|
subtree,
|
|
@@ -49,7 +81,6 @@ export async function parseImplicitTiles(params) {
|
|
|
49
81
|
const levelOffset = (childrenPerTile ** level - 1) / (childrenPerTile - 1);
|
|
50
82
|
let childTileMortonIndex = concatBits(parentData.mortonIndex, childIndex);
|
|
51
83
|
let tileAvailabilityIndex = levelOffset + childTileMortonIndex;
|
|
52
|
-
|
|
53
84
|
let childTileX = concatBits(parentData.x, childX);
|
|
54
85
|
let childTileY = concatBits(parentData.y, childY);
|
|
55
86
|
let childTileZ = concatBits(parentData.z, childZ);
|
|
@@ -94,22 +125,24 @@ export async function parseImplicitTiles(params) {
|
|
|
94
125
|
z: childTileZ
|
|
95
126
|
};
|
|
96
127
|
for (let index = 0; index < childrenPerTile; index++) {
|
|
97
|
-
const
|
|
128
|
+
const childS2VolumeBox = getChildS2VolumeBox(s2VolumeBox, index, subdivisionScheme);
|
|
129
|
+
const childTileParsed = await parseImplicitTiles({
|
|
98
130
|
subtree,
|
|
99
131
|
options,
|
|
100
132
|
parentData: pData,
|
|
101
133
|
childIndex: index,
|
|
102
134
|
level: childTileLevel,
|
|
103
|
-
globalData
|
|
135
|
+
globalData,
|
|
136
|
+
s2VolumeBox: childS2VolumeBox
|
|
104
137
|
});
|
|
105
|
-
if (
|
|
138
|
+
if (childTileParsed.contentUrl || childTileParsed.children.length) {
|
|
106
139
|
const globalLevel = lev + 1;
|
|
107
140
|
const childCoordinates = {
|
|
108
141
|
childTileX,
|
|
109
142
|
childTileY,
|
|
110
143
|
childTileZ
|
|
111
144
|
};
|
|
112
|
-
const formattedTile = formatTileData(
|
|
145
|
+
const formattedTile = formatTileData(childTileParsed, globalLevel, childCoordinates, options, s2VolumeBox);
|
|
113
146
|
tile.children.push(formattedTile);
|
|
114
147
|
}
|
|
115
148
|
}
|
|
@@ -124,8 +157,7 @@ function getAvailabilityResult(availabilityData, index) {
|
|
|
124
157
|
}
|
|
125
158
|
return false;
|
|
126
159
|
}
|
|
127
|
-
|
|
128
|
-
function formatTileData(tile, level, childCoordinates, options) {
|
|
160
|
+
function formatTileData(tile, level, childCoordinates, options, s2VolumeBox) {
|
|
129
161
|
const {
|
|
130
162
|
basePath,
|
|
131
163
|
refine,
|
|
@@ -137,7 +169,10 @@ function formatTileData(tile, level, childCoordinates, options) {
|
|
|
137
169
|
} = options;
|
|
138
170
|
const uri = tile.contentUrl && tile.contentUrl.replace("".concat(basePath, "/"), '');
|
|
139
171
|
const lodMetricValue = rootLodMetricValue / 2 ** level;
|
|
140
|
-
const boundingVolume =
|
|
172
|
+
const boundingVolume = s2VolumeBox !== null && s2VolumeBox !== void 0 && s2VolumeBox.box ? {
|
|
173
|
+
box: s2VolumeBox.box
|
|
174
|
+
} : rootBoundingVolume;
|
|
175
|
+
const boundingVolumeForChildTile = calculateBoundingVolumeForChildTile(level, boundingVolume, childCoordinates);
|
|
141
176
|
return {
|
|
142
177
|
children: tile.children,
|
|
143
178
|
contentUrl: tile.contentUrl,
|
|
@@ -151,10 +186,9 @@ function formatTileData(tile, level, childCoordinates, options) {
|
|
|
151
186
|
lodMetricValue,
|
|
152
187
|
geometricError: lodMetricValue,
|
|
153
188
|
transform: tile.transform,
|
|
154
|
-
boundingVolume
|
|
189
|
+
boundingVolume: boundingVolumeForChildTile
|
|
155
190
|
};
|
|
156
191
|
}
|
|
157
|
-
|
|
158
192
|
function calculateBoundingVolumeForChildTile(level, rootBoundingVolume, childCoordinates) {
|
|
159
193
|
if (rootBoundingVolume.region) {
|
|
160
194
|
const {
|
|
@@ -174,15 +208,14 @@ function calculateBoundingVolumeForChildTile(level, rootBoundingVolume, childCoo
|
|
|
174
208
|
region: [childWest, childSouth, childEast, childNorth, childMinimumHeight, childMaximumHeight]
|
|
175
209
|
};
|
|
176
210
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
211
|
+
if (rootBoundingVolume.box) {
|
|
212
|
+
return rootBoundingVolume;
|
|
213
|
+
}
|
|
214
|
+
throw new Error("Unsupported bounding volume type ".concat(rootBoundingVolume));
|
|
180
215
|
}
|
|
181
|
-
|
|
182
216
|
function concatBits(first, second) {
|
|
183
217
|
return parseInt(first.toString(2) + second.toString(2), 2);
|
|
184
218
|
}
|
|
185
|
-
|
|
186
219
|
export function replaceContentUrlTemplate(templateUrl, level, x, y, z) {
|
|
187
220
|
const mapUrl = generateMapUrl({
|
|
188
221
|
level,
|
|
@@ -192,7 +225,6 @@ export function replaceContentUrlTemplate(templateUrl, level, x, y, z) {
|
|
|
192
225
|
});
|
|
193
226
|
return templateUrl.replace(/{level}|{x}|{y}|{z}/gi, matched => mapUrl[matched]);
|
|
194
227
|
}
|
|
195
|
-
|
|
196
228
|
function generateMapUrl(items) {
|
|
197
229
|
const mapUrl = {};
|
|
198
230
|
for (const key in items) {
|
|
@@ -200,7 +232,6 @@ function generateMapUrl(items) {
|
|
|
200
232
|
}
|
|
201
233
|
return mapUrl;
|
|
202
234
|
}
|
|
203
|
-
|
|
204
235
|
function getBooleanValueFromBitstream(availabilityIndex, availabilityBuffer) {
|
|
205
236
|
const byteIndex = Math.floor(availabilityIndex / 8);
|
|
206
237
|
const bitIndex = availabilityIndex % 8;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-3d-implicit-tiles.js","names":["Tile3DSubtreeLoader","load","QUADTREE_DEVISION_COUNT","OCTREE_DEVISION_COUNT","SUBDIVISION_COUNT_MAP","QUADTREE","OCTREE","parseImplicitTiles","params","options","parentData","mortonIndex","x","y","z","childIndex","globalData","level","subtree","subdivisionScheme","subtreeLevels","maximumLevel","contentUrlTemplate","subtreesUriTemplate","basePath","tile","children","lodMetricValue","contentUrl","childrenPerTile","childX","childY","childZ","levelOffset","childTileMortonIndex","concatBits","tileAvailabilityIndex","childTileX","childTileY","childTileZ","isChildSubtreeAvailable","getAvailabilityResult","childSubtreeAvailability","lev","subtreePath","childSubtreeUrl","replaceContentUrlTemplate","childSubtree","isTileAvailable","tileAvailability","isContentAvailable","contentAvailability","childTileLevel","pData","index","currentTile","length","globalLevel","childCoordinates","formattedTile","formatTileData","push","availabilityData","Boolean","constant","explicitBitstream","getBooleanValueFromBitstream","refine","getRefine","lodMetricType","getTileType","rootLodMetricValue","rootBoundingVolume","uri","replace","boundingVolume","calculateBoundingVolumeForChildTile","content","id","type","geometricError","transform","region","west","south","east","north","minimumHeight","maximumHeight","boundingVolumesCount","sizeX","sizeY","sizeZ","childWest","childEast","childSouth","childNorth","childMinimumHeight","childMaximumHeight","console","warn","first","second","parseInt","toString","templateUrl","mapUrl","generateMapUrl","matched","items","key","availabilityIndex","availabilityBuffer","byteIndex","Math","floor","bitIndex","bitValue"],"sources":["../../../../../src/lib/parsers/helpers/parse-3d-implicit-tiles.ts"],"sourcesContent":["import type {Availability, BoundingVolume, Subtree} from '../../../types';\nimport {Tile3DSubtreeLoader} from '../../../tile-3d-subtree-loader';\nimport {load} from '@loaders.gl/core';\n\nconst QUADTREE_DEVISION_COUNT = 4;\nconst OCTREE_DEVISION_COUNT = 8;\n\nconst SUBDIVISION_COUNT_MAP = {\n QUADTREE: QUADTREE_DEVISION_COUNT,\n OCTREE: OCTREE_DEVISION_COUNT\n};\n\n/**\n * Recursively parse implicit tiles tree\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling\n * TODO Check out do we able to use Tile3D class as return type here.\n * @param subtree\n * @param lodMetricValue\n * @param options\n * @param parentData\n * @param childIndex\n * @param level\n * @param globalData\n */\n// eslint-disable-next-line max-statements\nexport async function parseImplicitTiles(params: {\n subtree: Subtree;\n options: any;\n parentData?: {mortonIndex: number; x: number; y: number; z: number};\n childIndex?: number;\n level?: number;\n globalData?: {level: number; mortonIndex: number; x: number; y: number; z: number};\n}) {\n const {\n options,\n parentData = {\n mortonIndex: 0,\n x: 0,\n y: 0,\n z: 0\n },\n childIndex = 0,\n globalData = {\n level: 0,\n mortonIndex: 0,\n x: 0,\n y: 0,\n z: 0\n }\n } = params;\n let {subtree, level = 0} = params;\n const {\n subdivisionScheme,\n subtreeLevels,\n maximumLevel,\n contentUrlTemplate,\n subtreesUriTemplate,\n basePath\n } = options;\n\n const tile = {children: [], lodMetricValue: 0, contentUrl: ''};\n\n const childrenPerTile = SUBDIVISION_COUNT_MAP[subdivisionScheme];\n\n const childX = childIndex & 0b01;\n const childY = (childIndex >> 1) & 0b01;\n const childZ = (childIndex >> 2) & 0b01;\n\n const levelOffset = (childrenPerTile ** level - 1) / (childrenPerTile - 1);\n let childTileMortonIndex = concatBits(parentData.mortonIndex, childIndex);\n let tileAvailabilityIndex = levelOffset + childTileMortonIndex;\n\n // Local tile coordinates\n let childTileX = concatBits(parentData.x, childX);\n let childTileY = concatBits(parentData.y, childY);\n let childTileZ = concatBits(parentData.z, childZ);\n\n let isChildSubtreeAvailable = false;\n\n if (level + 1 > subtreeLevels) {\n isChildSubtreeAvailable = getAvailabilityResult(\n subtree.childSubtreeAvailability,\n childTileMortonIndex\n );\n }\n\n const x = concatBits(globalData.x, childTileX);\n const y = concatBits(globalData.y, childTileY);\n const z = concatBits(globalData.z, childTileZ);\n const lev = level + globalData.level;\n\n if (isChildSubtreeAvailable) {\n const subtreePath = `${basePath}/${subtreesUriTemplate}`;\n const childSubtreeUrl = replaceContentUrlTemplate(subtreePath, lev, x, y, z);\n const childSubtree = await load(childSubtreeUrl, Tile3DSubtreeLoader);\n\n subtree = childSubtree;\n\n globalData.mortonIndex = childTileMortonIndex;\n globalData.x = childTileX;\n globalData.y = childTileY;\n globalData.z = childTileZ;\n globalData.level = level;\n\n childTileMortonIndex = 0;\n tileAvailabilityIndex = 0;\n childTileX = 0;\n childTileY = 0;\n childTileZ = 0;\n level = 0;\n }\n\n const isTileAvailable = getAvailabilityResult(subtree.tileAvailability, tileAvailabilityIndex);\n\n if (!isTileAvailable || level > maximumLevel) {\n return tile;\n }\n\n const isContentAvailable = getAvailabilityResult(\n subtree.contentAvailability,\n tileAvailabilityIndex\n );\n\n if (isContentAvailable) {\n tile.contentUrl = replaceContentUrlTemplate(contentUrlTemplate, lev, x, y, z);\n }\n\n const childTileLevel = level + 1;\n const pData = {mortonIndex: childTileMortonIndex, x: childTileX, y: childTileY, z: childTileZ};\n\n for (let index = 0; index < childrenPerTile; index++) {\n const currentTile = await parseImplicitTiles({\n subtree,\n options,\n parentData: pData,\n childIndex: index,\n level: childTileLevel,\n globalData\n });\n\n if (currentTile.contentUrl || currentTile.children.length) {\n const globalLevel = lev + 1;\n const childCoordinates = {childTileX, childTileY, childTileZ};\n const formattedTile = formatTileData(currentTile, globalLevel, childCoordinates, options);\n // @ts-ignore\n tile.children.push(formattedTile);\n }\n }\n\n return tile;\n}\n\nfunction getAvailabilityResult(availabilityData: Availability, index: number): boolean {\n if ('constant' in availabilityData) {\n return Boolean(availabilityData.constant);\n }\n\n if (availabilityData.explicitBitstream) {\n return getBooleanValueFromBitstream(index, availabilityData.explicitBitstream);\n }\n\n return false;\n}\n\n/**\n * Do formatting of implicit tile data.\n * TODO Check out do we able to use Tile3D class as type here.\n * @param tile\n * @param lodMetricValue\n * @param options\n * @returns\n */\nfunction formatTileData(\n tile,\n level: number,\n childCoordinates: {childTileX: number; childTileY: number; childTileZ: number},\n options: any\n) {\n const {\n basePath,\n refine,\n getRefine,\n lodMetricType,\n getTileType,\n rootLodMetricValue,\n rootBoundingVolume\n } = options;\n const uri = tile.contentUrl && tile.contentUrl.replace(`${basePath}/`, '');\n const lodMetricValue = rootLodMetricValue / 2 ** level;\n const boundingVolume = calculateBoundingVolumeForChildTile(\n level,\n rootBoundingVolume,\n childCoordinates\n );\n\n return {\n children: tile.children,\n contentUrl: tile.contentUrl,\n content: {uri},\n id: tile.contentUrl,\n refine: getRefine(refine),\n type: getTileType(tile),\n lodMetricType,\n lodMetricValue,\n geometricError: lodMetricValue,\n transform: tile.transform,\n boundingVolume\n };\n}\n\n/**\n * Calculate child bounding volume.\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subdivision-rules\n * @param level\n * @param rootBoundingVolume\n * @param childCoordinates\n */\nfunction calculateBoundingVolumeForChildTile(\n level: number,\n rootBoundingVolume: BoundingVolume,\n childCoordinates: {childTileX: number; childTileY: number; childTileZ: number}\n): BoundingVolume | null {\n if (rootBoundingVolume.region) {\n const {childTileX, childTileY, childTileZ} = childCoordinates;\n const [west, south, east, north, minimumHeight, maximumHeight] = rootBoundingVolume.region;\n const boundingVolumesCount = 2 ** level;\n\n const sizeX = (east - west) / boundingVolumesCount;\n const sizeY = (north - south) / boundingVolumesCount;\n const sizeZ = (maximumHeight - minimumHeight) / boundingVolumesCount;\n\n const [childWest, childEast] = [west + sizeX * childTileX, west + sizeX * (childTileX + 1)];\n const [childSouth, childNorth] = [south + sizeY * childTileY, south + sizeY * (childTileY + 1)];\n const [childMinimumHeight, childMaximumHeight] = [\n minimumHeight + sizeZ * childTileZ,\n minimumHeight + sizeZ * (childTileZ + 1)\n ];\n\n return {\n region: [childWest, childSouth, childEast, childNorth, childMinimumHeight, childMaximumHeight]\n };\n }\n\n // eslint-disable-next-line no-console\n console.warn('Unsupported bounding volume type: ', rootBoundingVolume);\n return null;\n}\n\n/**\n * Do binary concatenation\n * @param first\n * @param second\n */\nfunction concatBits(first: number, second: number): number {\n return parseInt(first.toString(2) + second.toString(2), 2);\n}\n\n/**\n * Replace implicit tile content url with real coordinates.\n * @param templateUrl\n * @param level\n * @param x\n * @param y\n * @param z\n */\nexport function replaceContentUrlTemplate(\n templateUrl: string,\n level: number,\n x: number,\n y: number,\n z: number\n): string {\n const mapUrl = generateMapUrl({level, x, y, z});\n return templateUrl.replace(/{level}|{x}|{y}|{z}/gi, (matched) => mapUrl[matched]);\n}\n\n/**\n * Get Map object for content url generation\n * @param items\n */\nfunction generateMapUrl(items: {[key: string]: number}): {[key: string]: string} {\n const mapUrl = {};\n\n for (const key in items) {\n mapUrl[`{${key}}`] = items[key];\n }\n return mapUrl;\n}\n\n/**\n * Get boolean value from bistream by index\n * A boolean value is encoded as a single bit, either 0 (false) or 1 (true).\n * Multiple boolean values are packed tightly in the same buffer.\n * These buffers of tightly-packed bits are sometimes referred to as bitstreams.\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/implicit-revisions/specification/Metadata#booleans\n * @param availabilitiIndex\n */\nfunction getBooleanValueFromBitstream(\n availabilityIndex: number,\n availabilityBuffer: Uint8Array\n): boolean {\n const byteIndex = Math.floor(availabilityIndex / 8);\n const bitIndex = availabilityIndex % 8;\n const bitValue = (availability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AiB,GAAG,CAAC;EACtC,MAAMM,QAAQ,GAAIL,kBAAkB,CAACC,SAAS,CAAC,IAAIG,QAAQ,GAAI,CAAC;EAEhE,OAAOC,QAAQ,KAAK,CAAC;AACvB"}
|
|
1
|
+
{"version":3,"file":"parse-3d-implicit-tiles.js","names":["Tile3DSubtreeLoader","load","getS2CellIdFromToken","getS2ChildCellId","getS2TokenFromCellId","convertS2BoundingVolumetoOBB","QUADTREE_DEVISION_COUNT","OCTREE_DEVISION_COUNT","SUBDIVISION_COUNT_MAP","QUADTREE","OCTREE","getChildS2VolumeBox","s2VolumeBox","index","subdivisionScheme","box","cellId","s2VolumeInfo","token","childCellId","childToken","s2ChildVolumeInfo","delta","maximumHeight","minimumHeight","sizeZ","midZ","childS2VolumeBox","undefined","parseImplicitTiles","params","options","parentData","mortonIndex","x","y","z","childIndex","globalData","level","subtree","subtreeLevels","maximumLevel","contentUrlTemplate","subtreesUriTemplate","basePath","tile","children","lodMetricValue","contentUrl","childrenPerTile","childX","childY","childZ","levelOffset","childTileMortonIndex","concatBits","tileAvailabilityIndex","childTileX","childTileY","childTileZ","isChildSubtreeAvailable","getAvailabilityResult","childSubtreeAvailability","lev","subtreePath","concat","childSubtreeUrl","replaceContentUrlTemplate","childSubtree","isTileAvailable","tileAvailability","isContentAvailable","contentAvailability","childTileLevel","pData","childTileParsed","length","globalLevel","childCoordinates","formattedTile","formatTileData","push","availabilityData","Boolean","constant","explicitBitstream","getBooleanValueFromBitstream","refine","getRefine","lodMetricType","getTileType","rootLodMetricValue","rootBoundingVolume","uri","replace","boundingVolume","boundingVolumeForChildTile","calculateBoundingVolumeForChildTile","content","id","type","geometricError","transform","region","west","south","east","north","boundingVolumesCount","sizeX","sizeY","childWest","childEast","childSouth","childNorth","childMinimumHeight","childMaximumHeight","Error","first","second","parseInt","toString","templateUrl","mapUrl","generateMapUrl","matched","items","key","availabilityIndex","availabilityBuffer","byteIndex","Math","floor","bitIndex","bitValue"],"sources":["../../../../../src/lib/parsers/helpers/parse-3d-implicit-tiles.ts"],"sourcesContent":["import type {Availability, BoundingVolume, Subtree} from '../../../types';\nimport {Tile3DSubtreeLoader} from '../../../tile-3d-subtree-loader';\nimport {load} from '@loaders.gl/core';\n\nimport {getS2CellIdFromToken, getS2ChildCellId, getS2TokenFromCellId} from '../../utils/s2/index';\nimport type {S2VolumeInfo} from '../../utils/obb/s2-corners-to-obb';\nimport {convertS2BoundingVolumetoOBB} from '../../utils/obb/s2-corners-to-obb';\nimport Long from 'long';\n\nconst QUADTREE_DEVISION_COUNT = 4;\nconst OCTREE_DEVISION_COUNT = 8;\n\nconst SUBDIVISION_COUNT_MAP = {\n QUADTREE: QUADTREE_DEVISION_COUNT,\n OCTREE: OCTREE_DEVISION_COUNT\n};\n\n/**\n * S2VolumeBox is an extention of BoundingVolume of type \"box\"\n */\nexport type S2VolumeBox = {\n /** BoundingVolume of type \"box\" has the \"box\" field. S2VolumeBox contains it as well. */\n box: number[];\n /** s2VolumeInfo provides additional info about the box - specifically the token, min and max height */\n s2VolumeInfo: S2VolumeInfo;\n};\n\nfunction getChildS2VolumeBox(\n s2VolumeBox: S2VolumeBox | undefined,\n index: number,\n subdivisionScheme: string\n): S2VolumeBox | undefined {\n if (s2VolumeBox?.box) {\n // Check if the BoundingVolume is of type \"box\"\n const cellId: Long = getS2CellIdFromToken(s2VolumeBox.s2VolumeInfo.token);\n const childCellId = getS2ChildCellId(cellId, index);\n const childToken = getS2TokenFromCellId(childCellId);\n\n // Clone object. Note, s2VolumeInfo is a plain object that doesn't contain any nested object.\n // So, we can use the Spread Operator to make a shallow copy of the object.\n const s2ChildVolumeInfo: S2VolumeInfo = {...s2VolumeBox.s2VolumeInfo};\n s2ChildVolumeInfo.token = childToken; // replace the token with the child's one\n\n // In case of QUADTREE the sizeZ should NOT be changed!\n // https://portal.ogc.org/files/102132\n // A quadtree divides space only on the x and y dimensions.\n // It divides each tile into 4 smaller tiles where the x and y dimensions are halved.\n // The quadtree z minimum and maximum remain unchanged.\n switch (subdivisionScheme) {\n case 'OCTREE':\n const s2VolumeInfo: S2VolumeInfo = s2VolumeBox.s2VolumeInfo;\n const delta = s2VolumeInfo.maximumHeight - s2VolumeInfo.minimumHeight;\n const sizeZ: number = delta / 2.0; // It's a next level (a child)\n const midZ: number = s2VolumeInfo.minimumHeight + delta / 2.0;\n s2VolumeInfo.minimumHeight = midZ - sizeZ;\n s2VolumeInfo.maximumHeight = midZ + sizeZ;\n break;\n default:\n break;\n }\n const box = convertS2BoundingVolumetoOBB(s2ChildVolumeInfo);\n const childS2VolumeBox: S2VolumeBox = {\n box,\n s2VolumeInfo: s2ChildVolumeInfo\n };\n return childS2VolumeBox;\n }\n return undefined;\n}\n\n/**\n * Recursively parse implicit tiles tree\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling\n * TODO Check out do we able to use Tile3D class as return type here.\n * @param subtree\n * @param lodMetricValue\n * @param options\n * @param parentData\n * @param childIndex\n * @param level\n * @param globalData\n */\n// eslint-disable-next-line max-statements\nexport async function parseImplicitTiles(params: {\n subtree: Subtree;\n options: any;\n parentData?: {mortonIndex: number; x: number; y: number; z: number};\n childIndex?: number;\n level?: number;\n globalData?: {level: number; mortonIndex: number; x: number; y: number; z: number};\n s2VolumeBox?: S2VolumeBox;\n}) {\n const {\n options,\n parentData = {\n mortonIndex: 0,\n x: 0,\n y: 0,\n z: 0\n },\n childIndex = 0,\n globalData = {\n level: 0,\n mortonIndex: 0,\n x: 0,\n y: 0,\n z: 0\n },\n s2VolumeBox\n } = params;\n let {subtree, level = 0} = params;\n const {\n subdivisionScheme,\n subtreeLevels,\n maximumLevel,\n contentUrlTemplate,\n subtreesUriTemplate,\n basePath\n } = options;\n\n const tile = {children: [], lodMetricValue: 0, contentUrl: ''};\n\n const childrenPerTile = SUBDIVISION_COUNT_MAP[subdivisionScheme];\n\n const childX = childIndex & 0b01;\n const childY = (childIndex >> 1) & 0b01;\n const childZ = (childIndex >> 2) & 0b01;\n\n const levelOffset = (childrenPerTile ** level - 1) / (childrenPerTile - 1);\n let childTileMortonIndex = concatBits(parentData.mortonIndex, childIndex);\n let tileAvailabilityIndex = levelOffset + childTileMortonIndex;\n\n // Local tile coordinates\n let childTileX = concatBits(parentData.x, childX);\n let childTileY = concatBits(parentData.y, childY);\n let childTileZ = concatBits(parentData.z, childZ);\n\n let isChildSubtreeAvailable = false;\n\n if (level + 1 > subtreeLevels) {\n isChildSubtreeAvailable = getAvailabilityResult(\n subtree.childSubtreeAvailability,\n childTileMortonIndex\n );\n }\n\n const x = concatBits(globalData.x, childTileX);\n const y = concatBits(globalData.y, childTileY);\n const z = concatBits(globalData.z, childTileZ);\n const lev = level + globalData.level;\n\n if (isChildSubtreeAvailable) {\n const subtreePath = `${basePath}/${subtreesUriTemplate}`;\n const childSubtreeUrl = replaceContentUrlTemplate(subtreePath, lev, x, y, z);\n const childSubtree = await load(childSubtreeUrl, Tile3DSubtreeLoader);\n\n subtree = childSubtree;\n\n globalData.mortonIndex = childTileMortonIndex;\n globalData.x = childTileX;\n globalData.y = childTileY;\n globalData.z = childTileZ;\n globalData.level = level;\n\n childTileMortonIndex = 0;\n tileAvailabilityIndex = 0;\n childTileX = 0;\n childTileY = 0;\n childTileZ = 0;\n level = 0;\n }\n\n const isTileAvailable = getAvailabilityResult(subtree.tileAvailability, tileAvailabilityIndex);\n\n if (!isTileAvailable || level > maximumLevel) {\n return tile;\n }\n\n const isContentAvailable = getAvailabilityResult(\n subtree.contentAvailability,\n tileAvailabilityIndex\n );\n\n if (isContentAvailable) {\n tile.contentUrl = replaceContentUrlTemplate(contentUrlTemplate, lev, x, y, z);\n }\n\n const childTileLevel = level + 1;\n const pData = {mortonIndex: childTileMortonIndex, x: childTileX, y: childTileY, z: childTileZ};\n\n for (let index = 0; index < childrenPerTile; index++) {\n const childS2VolumeBox: S2VolumeBox | undefined = getChildS2VolumeBox(\n s2VolumeBox,\n index,\n subdivisionScheme\n );\n\n // Recursive calling...\n const childTileParsed = await parseImplicitTiles({\n subtree,\n options,\n parentData: pData,\n childIndex: index,\n level: childTileLevel,\n globalData,\n s2VolumeBox: childS2VolumeBox\n });\n\n if (childTileParsed.contentUrl || childTileParsed.children.length) {\n const globalLevel = lev + 1;\n const childCoordinates = {childTileX, childTileY, childTileZ};\n const formattedTile = formatTileData(\n childTileParsed,\n globalLevel,\n childCoordinates,\n options,\n s2VolumeBox\n );\n // @ts-ignore\n tile.children.push(formattedTile);\n }\n }\n\n return tile;\n}\n\nfunction getAvailabilityResult(availabilityData: Availability, index: number): boolean {\n if ('constant' in availabilityData) {\n return Boolean(availabilityData.constant);\n }\n\n if (availabilityData.explicitBitstream) {\n return getBooleanValueFromBitstream(index, availabilityData.explicitBitstream);\n }\n\n return false;\n}\n\n/**\n * Do formatting of implicit tile data.\n * TODO Check out do we able to use Tile3D class as type here.\n * @param tile\n * @param lodMetricValue\n * @param options\n * @returns\n */\nfunction formatTileData(\n tile,\n level: number,\n childCoordinates: {childTileX: number; childTileY: number; childTileZ: number},\n options: any,\n s2VolumeBox?: S2VolumeBox\n) {\n const {\n basePath,\n refine,\n getRefine,\n lodMetricType,\n getTileType,\n rootLodMetricValue,\n rootBoundingVolume\n } = options;\n const uri = tile.contentUrl && tile.contentUrl.replace(`${basePath}/`, '');\n const lodMetricValue = rootLodMetricValue / 2 ** level;\n\n const boundingVolume: BoundingVolume = s2VolumeBox?.box\n ? {box: s2VolumeBox.box}\n : rootBoundingVolume;\n\n const boundingVolumeForChildTile = calculateBoundingVolumeForChildTile(\n level,\n boundingVolume,\n childCoordinates\n );\n\n return {\n children: tile.children,\n contentUrl: tile.contentUrl,\n content: {uri},\n id: tile.contentUrl,\n refine: getRefine(refine),\n type: getTileType(tile),\n lodMetricType,\n lodMetricValue,\n geometricError: lodMetricValue,\n transform: tile.transform,\n boundingVolume: boundingVolumeForChildTile\n };\n}\n\n/**\n * Calculate child bounding volume.\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subdivision-rules\n * @param level\n * @param rootBoundingVolume\n * @param childCoordinates\n */\nfunction calculateBoundingVolumeForChildTile(\n level: number,\n rootBoundingVolume: BoundingVolume,\n childCoordinates: {childTileX: number; childTileY: number; childTileZ: number}\n): BoundingVolume {\n if (rootBoundingVolume.region) {\n const {childTileX, childTileY, childTileZ} = childCoordinates;\n const [west, south, east, north, minimumHeight, maximumHeight] = rootBoundingVolume.region;\n const boundingVolumesCount = 2 ** level;\n\n const sizeX = (east - west) / boundingVolumesCount;\n const sizeY = (north - south) / boundingVolumesCount;\n\n // TODO : Why is the subdivisionScheme not being checked here?\n\n // In case of QUADTREE the sizeZ should NOT be changed!\n // https://portal.ogc.org/files/102132\n // A quadtree divides space only on the x and y dimensions. It divides each tile into 4 smaller tiles where the x and y dimensions are halved. The quadtree z minimum and maximum remain unchanged.\n\n const sizeZ = (maximumHeight - minimumHeight) / boundingVolumesCount;\n\n const [childWest, childEast] = [west + sizeX * childTileX, west + sizeX * (childTileX + 1)];\n const [childSouth, childNorth] = [south + sizeY * childTileY, south + sizeY * (childTileY + 1)];\n const [childMinimumHeight, childMaximumHeight] = [\n minimumHeight + sizeZ * childTileZ,\n minimumHeight + sizeZ * (childTileZ + 1)\n ];\n\n return {\n region: [childWest, childSouth, childEast, childNorth, childMinimumHeight, childMaximumHeight]\n };\n }\n\n if (rootBoundingVolume.box) {\n return rootBoundingVolume;\n }\n\n throw new Error(`Unsupported bounding volume type ${rootBoundingVolume}`);\n}\n\n/**\n * Do binary concatenation\n * @param first\n * @param second\n */\nfunction concatBits(first: number, second: number): number {\n return parseInt(first.toString(2) + second.toString(2), 2);\n}\n\n/**\n * Replace implicit tile content url with real coordinates.\n * @param templateUrl\n * @param level\n * @param x\n * @param y\n * @param z\n */\nexport function replaceContentUrlTemplate(\n templateUrl: string,\n level: number,\n x: number,\n y: number,\n z: number\n): string {\n const mapUrl = generateMapUrl({level, x, y, z});\n return templateUrl.replace(/{level}|{x}|{y}|{z}/gi, (matched) => mapUrl[matched]);\n}\n\n/**\n * Get Map object for content url generation\n * @param items\n */\nfunction generateMapUrl(items: {[key: string]: number}): {[key: string]: string} {\n const mapUrl = {};\n\n for (const key in items) {\n mapUrl[`{${key}}`] = items[key];\n }\n return mapUrl;\n}\n\n/**\n * Get boolean value from bistream by index\n * A boolean value is encoded as a single bit, either 0 (false) or 1 (true).\n * Multiple boolean values are packed tightly in the same buffer.\n * These buffers of tightly-packed bits are sometimes referred to as bitstreams.\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/implicit-revisions/specification/Metadata#booleans\n * @param availabilitiIndex\n */\nfunction getBooleanValueFromBitstream(\n availabilityIndex: number,\n availabilityBuffer: Uint8Array\n): boolean {\n const byteIndex = Math.floor(availabilityIndex / 8);\n const bitIndex = availabilityIndex % 8;\n const bitValue = (availabilityBuffer[byteIndex] >> bitIndex) & 1;\n\n return bitValue === 1;\n}\n"],"mappings":"AACA,SAAQA,mBAAmB,QAAO,iCAAiC;AACnE,SAAQC,IAAI,QAAO,kBAAkB;AAErC,SAAQC,oBAAoB,EAAEC,gBAAgB,EAAEC,oBAAoB,QAAO,sBAAsB;AAEjG,SAAQC,4BAA4B,QAAO,mCAAmC;AAG9E,MAAMC,uBAAuB,GAAG,CAAC;AACjC,MAAMC,qBAAqB,GAAG,CAAC;AAE/B,MAAMC,qBAAqB,GAAG;EAC5BC,QAAQ,EAAEH,uBAAuB;EACjCI,MAAM,EAAEH;AACV,CAAC;AAYD,SAASI,mBAAmBA,CAC1BC,WAAoC,EACpCC,KAAa,EACbC,iBAAyB,EACA;EACzB,IAAIF,WAAW,aAAXA,WAAW,eAAXA,WAAW,CAAEG,GAAG,EAAE;IAEpB,MAAMC,MAAY,GAAGd,oBAAoB,CAACU,WAAW,CAACK,YAAY,CAACC,KAAK,CAAC;IACzE,MAAMC,WAAW,GAAGhB,gBAAgB,CAACa,MAAM,EAAEH,KAAK,CAAC;IACnD,MAAMO,UAAU,GAAGhB,oBAAoB,CAACe,WAAW,CAAC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QAAQ,CAACF,KAAK,CAACG,QAAQ,CAAC,CAAC,CAAC,GAAGF,MAAM,CAACE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAC5D;AAUA,OAAO,SAAStD,yBAAyBA,CACvCuD,WAAmB,EACnBpF,KAAa,EACbL,CAAS,EACTC,CAAS,EACTC,CAAS,EACD;EACR,MAAMwF,MAAM,GAAGC,cAAc,CAAC;IAACtF,KAAK;IAAEL,CAAC;IAAEC,CAAC;IAAEC;EAAC,CAAC,CAAC;EAC/C,OAAOuF,WAAW,CAAC5B,OAAO,CAAC,uBAAuB,EAAG+B,OAAO,IAAKF,MAAM,CAACE,OAAO,CAAC,CAAC;AACnF;AAMA,SAASD,cAAcA,CAACE,KAA8B,EAA2B;EAC/E,MAAMH,MAAM,GAAG,CAAC,CAAC;EAEjB,KAAK,MAAMI,GAAG,IAAID,KAAK,EAAE;IACvBH,MAAM,KAAA1D,MAAA,CAAK8D,GAAG,OAAI,GAAGD,KAAK,CAACC,GAAG,CAAC;EACjC;EACA,OAAOJ,MAAM;AACf;AAUA,SAASrC,4BAA4BA,CACnC0C,iBAAyB,EACzBC,kBAA8B,EACrB;EACT,MAAMC,SAAS,GAAGC,IAAI,CAACC,KAAK,CAACJ,iBAAiB,GAAG,CAAC,CAAC;EACnD,MAAMK,QAAQ,GAAGL,iBAAiB,GAAG,CAAC;EACtC,MAAMM,QAAQ,GAAIL,kBAAkB,CAACC,SAAS,CAAC,IAAIG,QAAQ,GAAI,CAAC;EAEhE,OAAOC,QAAQ,KAAK,CAAC;AACvB"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
import { GLTFLoader } from '@loaders.gl/gltf';
|
|
4
2
|
import { sliceArrayBuffer } from '@loaders.gl/loader-utils';
|
|
5
3
|
export const GLTF_FORMAT = {
|
|
@@ -8,22 +6,17 @@ export const GLTF_FORMAT = {
|
|
|
8
6
|
};
|
|
9
7
|
export function parse3DTileGLTFViewSync(tile, arrayBuffer, byteOffset, options) {
|
|
10
8
|
tile.rotateYtoZ = true;
|
|
11
|
-
|
|
12
9
|
const gltfByteLength = tile.byteOffset + tile.byteLength - byteOffset;
|
|
13
10
|
if (gltfByteLength === 0) {
|
|
14
11
|
throw new Error('glTF byte length must be greater than 0.');
|
|
15
12
|
}
|
|
16
|
-
|
|
17
13
|
tile.gltfUpAxis = options['3d-tiles'] && options['3d-tiles'].assetGltfUpAxis ? options['3d-tiles'].assetGltfUpAxis : 'Y';
|
|
18
|
-
|
|
19
14
|
tile.gltfArrayBuffer = sliceArrayBuffer(arrayBuffer, byteOffset, gltfByteLength);
|
|
20
15
|
tile.gltfByteOffset = 0;
|
|
21
16
|
tile.gltfByteLength = gltfByteLength;
|
|
22
|
-
if (byteOffset % 4 === 0) {
|
|
23
|
-
} else {
|
|
17
|
+
if (byteOffset % 4 === 0) {} else {
|
|
24
18
|
console.warn("".concat(tile.type, ": embedded glb is not aligned to a 4-byte boundary."));
|
|
25
19
|
}
|
|
26
|
-
|
|
27
20
|
return tile.byteOffset + tile.byteLength;
|
|
28
21
|
}
|
|
29
22
|
export async function extractGLTF(tile, gltfFormat, options, context) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-3d-tile-gltf-view.js","names":["GLTFLoader","sliceArrayBuffer","GLTF_FORMAT","URI","EMBEDDED","parse3DTileGLTFViewSync","tile","arrayBuffer","byteOffset","options","rotateYtoZ","gltfByteLength","byteLength","Error","gltfUpAxis","assetGltfUpAxis","gltfArrayBuffer","gltfByteOffset","console","warn","type","extractGLTF","gltfFormat","context","tile3DOptions","extractGLTFBufferOrURL","loadGLTF","parse","fetch","gltfUrl","gltf","gltfUrlBytes","Uint8Array","textDecoder","TextDecoder","decode","replace"],"sources":["../../../../../src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts"],"sourcesContent":["// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n// TODO - should we automatically parse the embedded glTF or leave it to the app?\n// - I.e. some apps might work directly on a GLB, in that case no need for us to decode...\n// - And if we decode, do we still keep the GLB in case it is needed?\n// - Do we add an option to control this?\n// - Also, should we have hard dependency on gltf module or use injection or auto-discovery for gltf parser?\n\nimport {GLTFLoader} from '@loaders.gl/gltf';\nimport {sliceArrayBuffer} from '@loaders.gl/loader-utils';\n\nexport const GLTF_FORMAT = {\n URI: 0,\n EMBEDDED: 1\n};\n\nexport function parse3DTileGLTFViewSync(tile, arrayBuffer, byteOffset, options) {\n // Set flags\n // glTF models need to be rotated from Y to Z up\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up\n tile.rotateYtoZ = true;\n\n // Assume glTF consumes rest of tile\n const gltfByteLength = tile.byteOffset + tile.byteLength - byteOffset;\n if (gltfByteLength === 0) {\n throw new Error('glTF byte length must be greater than 0.');\n }\n\n // Save gltf up axis\n tile.gltfUpAxis =\n options['3d-tiles'] && options['3d-tiles'].assetGltfUpAxis\n ? options['3d-tiles'].assetGltfUpAxis\n : 'Y';\n\n // TODO - We can avoid copy if already 4-byte aligned...\n // However the rest of the code may not be able to accept byteOffsets, so copy anyway\n tile.gltfArrayBuffer = sliceArrayBuffer(arrayBuffer, byteOffset, gltfByteLength);\n tile.gltfByteOffset = 0;\n tile.gltfByteLength = gltfByteLength;\n\n if (byteOffset % 4 === 0) {\n // tile.gltfArrayBuffer = arrayBuffer;\n // tile.gltfByteOffset = byteOffset;\n // tile.gltfByteLength = gltfByteLength;\n } else {\n // Create a copy of the glb so that it is 4-byte aligned\n // eslint-disable-next-line\n console.warn(`${tile.type}: embedded glb is not aligned to a 4-byte boundary.`);\n }\n\n // Entire tile is consumed\n return tile.byteOffset + tile.byteLength;\n}\n\nexport async function extractGLTF(tile, gltfFormat, options, context) {\n const tile3DOptions = options['3d-tiles'] || {};\n\n extractGLTFBufferOrURL(tile, gltfFormat, options);\n\n if (tile3DOptions.loadGLTF) {\n const {parse, fetch} = context;\n if (tile.gltfUrl) {\n tile.gltfArrayBuffer = await fetch(tile.gltfUrl, options);\n tile.gltfByteOffset = 0;\n }\n if (tile.gltfArrayBuffer) {\n // TODO - Should handle byteOffset... However, not used now...\n tile.gltf = await parse(tile.gltfArrayBuffer, GLTFLoader, options, context);\n delete tile.gltfArrayBuffer;\n delete tile.gltfByteOffset;\n delete tile.gltfByteLength;\n }\n }\n}\n\nfunction extractGLTFBufferOrURL(tile, gltfFormat, options) {\n switch (gltfFormat) {\n case GLTF_FORMAT.URI:\n // We need to remove padding from the end of the model URL in case this tile was part of a composite tile.\n // This removes all white space and null characters from the end of the string.\n const gltfUrlBytes = new Uint8Array(tile.gltfArrayBuffer, tile.gltfByteOffset);\n const textDecoder = new TextDecoder();\n const gltfUrl = textDecoder.decode(gltfUrlBytes);\n tile.gltfUrl = gltfUrl.replace(/[\\s\\0]+$/, '');\n delete tile.gltfArrayBuffer;\n delete tile.gltfByteOffset;\n delete tile.gltfByteLength;\n break;\n case GLTF_FORMAT.EMBEDDED:\n break;\n default:\n throw new Error('b3dm: Illegal glTF format field');\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-3d-tile-gltf-view.js","names":["GLTFLoader","sliceArrayBuffer","GLTF_FORMAT","URI","EMBEDDED","parse3DTileGLTFViewSync","tile","arrayBuffer","byteOffset","options","rotateYtoZ","gltfByteLength","byteLength","Error","gltfUpAxis","assetGltfUpAxis","gltfArrayBuffer","gltfByteOffset","console","warn","concat","type","extractGLTF","gltfFormat","context","tile3DOptions","extractGLTFBufferOrURL","loadGLTF","parse","fetch","gltfUrl","gltf","gltfUrlBytes","Uint8Array","textDecoder","TextDecoder","decode","replace"],"sources":["../../../../../src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts"],"sourcesContent":["// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n// TODO - should we automatically parse the embedded glTF or leave it to the app?\n// - I.e. some apps might work directly on a GLB, in that case no need for us to decode...\n// - And if we decode, do we still keep the GLB in case it is needed?\n// - Do we add an option to control this?\n// - Also, should we have hard dependency on gltf module or use injection or auto-discovery for gltf parser?\n\nimport {GLTFLoader} from '@loaders.gl/gltf';\nimport {sliceArrayBuffer} from '@loaders.gl/loader-utils';\n\nexport const GLTF_FORMAT = {\n URI: 0,\n EMBEDDED: 1\n};\n\nexport function parse3DTileGLTFViewSync(tile, arrayBuffer, byteOffset, options) {\n // Set flags\n // glTF models need to be rotated from Y to Z up\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up\n tile.rotateYtoZ = true;\n\n // Assume glTF consumes rest of tile\n const gltfByteLength = tile.byteOffset + tile.byteLength - byteOffset;\n if (gltfByteLength === 0) {\n throw new Error('glTF byte length must be greater than 0.');\n }\n\n // Save gltf up axis\n tile.gltfUpAxis =\n options['3d-tiles'] && options['3d-tiles'].assetGltfUpAxis\n ? options['3d-tiles'].assetGltfUpAxis\n : 'Y';\n\n // TODO - We can avoid copy if already 4-byte aligned...\n // However the rest of the code may not be able to accept byteOffsets, so copy anyway\n tile.gltfArrayBuffer = sliceArrayBuffer(arrayBuffer, byteOffset, gltfByteLength);\n tile.gltfByteOffset = 0;\n tile.gltfByteLength = gltfByteLength;\n\n if (byteOffset % 4 === 0) {\n // tile.gltfArrayBuffer = arrayBuffer;\n // tile.gltfByteOffset = byteOffset;\n // tile.gltfByteLength = gltfByteLength;\n } else {\n // Create a copy of the glb so that it is 4-byte aligned\n // eslint-disable-next-line\n console.warn(`${tile.type}: embedded glb is not aligned to a 4-byte boundary.`);\n }\n\n // Entire tile is consumed\n return tile.byteOffset + tile.byteLength;\n}\n\nexport async function extractGLTF(tile, gltfFormat, options, context) {\n const tile3DOptions = options['3d-tiles'] || {};\n\n extractGLTFBufferOrURL(tile, gltfFormat, options);\n\n if (tile3DOptions.loadGLTF) {\n const {parse, fetch} = context;\n if (tile.gltfUrl) {\n tile.gltfArrayBuffer = await fetch(tile.gltfUrl, options);\n tile.gltfByteOffset = 0;\n }\n if (tile.gltfArrayBuffer) {\n // TODO - Should handle byteOffset... However, not used now...\n tile.gltf = await parse(tile.gltfArrayBuffer, GLTFLoader, options, context);\n delete tile.gltfArrayBuffer;\n delete tile.gltfByteOffset;\n delete tile.gltfByteLength;\n }\n }\n}\n\nfunction extractGLTFBufferOrURL(tile, gltfFormat, options) {\n switch (gltfFormat) {\n case GLTF_FORMAT.URI:\n // We need to remove padding from the end of the model URL in case this tile was part of a composite tile.\n // This removes all white space and null characters from the end of the string.\n const gltfUrlBytes = new Uint8Array(tile.gltfArrayBuffer, tile.gltfByteOffset);\n const textDecoder = new TextDecoder();\n const gltfUrl = textDecoder.decode(gltfUrlBytes);\n tile.gltfUrl = gltfUrl.replace(/[\\s\\0]+$/, '');\n delete tile.gltfArrayBuffer;\n delete tile.gltfByteOffset;\n delete tile.gltfByteLength;\n break;\n case GLTF_FORMAT.EMBEDDED:\n break;\n default:\n throw new Error('b3dm: Illegal glTF format field');\n }\n}\n"],"mappings":"AASA,SAAQA,UAAU,QAAO,kBAAkB;AAC3C,SAAQC,gBAAgB,QAAO,0BAA0B;AAEzD,OAAO,MAAMC,WAAW,GAAG;EACzBC,GAAG,EAAE,CAAC;EACNC,QAAQ,EAAE;AACZ,CAAC;AAED,OAAO,SAASC,uBAAuBA,CAACC,IAAI,EAAEC,WAAW,EAAEC,UAAU,EAAEC,OAAO,EAAE;EAI9EH,IAAI,CAACI,UAAU,GAAG,IAAI;EAGtB,MAAMC,cAAc,GAAGL,IAAI,CAACE,UAAU,GAAGF,IAAI,CAACM,UAAU,GAAGJ,UAAU;EACrE,IAAIG,cAAc,KAAK,CAAC,EAAE;IACxB,MAAM,IAAIE,KAAK,CAAC,0CAA0C,CAAC;EAC7D;EAGAP,IAAI,CAACQ,UAAU,GACbL,OAAO,CAAC,UAAU,CAAC,IAAIA,OAAO,CAAC,UAAU,CAAC,CAAC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,EAAEiB,UAAU,EAAEd,OAAO,EAAE;EACzD,QAAQc,UAAU;IAChB,KAAKrB,WAAW,CAACC,GAAG;MAGlB,MAAM6B,YAAY,GAAG,IAAIC,UAAU,CAAC3B,IAAI,CAACU,eAAe,EAAEV,IAAI,CAACW,cAAc,CAAC;MAC9E,MAAMiB,WAAW,GAAG,IAAIC,WAAW,EAAE;MACrC,MAAML,OAAO,GAAGI,WAAW,CAACE,MAAM,CAACJ,YAAY,CAAC;MAChD1B,IAAI,CAACwB,OAAO,GAAGA,OAAO,CAACO,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;MAC9C,OAAO/B,IAAI,CAACU,eAAe;MAC3B,OAAOV,IAAI,CAACW,cAAc;MAC1B,OAAOX,IAAI,CAACK,cAAc;MAC1B;IACF,KAAKT,WAAW,CAACE,QAAQ;MACvB;IACF;MACE,MAAM,IAAIS,KAAK,CAAC,iCAAiC,CAAC;EAAC;AAEzD"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
const SIZEOF_UINT32 = 4;
|
|
4
|
-
|
|
5
2
|
export function parse3DTileHeaderSync(tile, arrayBuffer) {
|
|
6
3
|
let byteOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
7
4
|
const view = new DataView(arrayBuffer);
|
|
@@ -11,7 +8,6 @@ export function parse3DTileHeaderSync(tile, arrayBuffer) {
|
|
|
11
8
|
byteOffset += SIZEOF_UINT32;
|
|
12
9
|
tile.byteLength = view.getUint32(byteOffset, true);
|
|
13
10
|
byteOffset += SIZEOF_UINT32;
|
|
14
|
-
|
|
15
11
|
if (tile.version !== 1) {
|
|
16
12
|
throw new Error("3D Tile Version ".concat(tile.version, " not supported"));
|
|
17
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-3d-tile-header.js","names":["SIZEOF_UINT32","parse3DTileHeaderSync","tile","arrayBuffer","byteOffset","view","DataView","magic","getUint32","version","byteLength","Error"],"sources":["../../../../../src/lib/parsers/helpers/parse-3d-tile-header.ts"],"sourcesContent":["// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\nconst SIZEOF_UINT32 = 4;\n\n/* PARSE FIXED HEADER:\nPopulates\n magic, // identifies type of tile\n type, // String version of magic\n version,\n byteLength\n */\nexport function parse3DTileHeaderSync(tile, arrayBuffer, byteOffset = 0) {\n const view = new DataView(arrayBuffer);\n\n tile.magic = view.getUint32(byteOffset, true);\n byteOffset += SIZEOF_UINT32;\n\n tile.version = view.getUint32(byteOffset, true);\n byteOffset += SIZEOF_UINT32;\n\n tile.byteLength = view.getUint32(byteOffset, true);\n byteOffset += SIZEOF_UINT32;\n\n // TODO - move version check into each tile parser?\n if (tile.version !== 1) {\n throw new Error(`3D Tile Version ${tile.version} not supported`);\n }\n\n return byteOffset; // Indicates where the parsing ended\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-3d-tile-header.js","names":["SIZEOF_UINT32","parse3DTileHeaderSync","tile","arrayBuffer","byteOffset","arguments","length","undefined","view","DataView","magic","getUint32","version","byteLength","Error","concat"],"sources":["../../../../../src/lib/parsers/helpers/parse-3d-tile-header.ts"],"sourcesContent":["// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\nconst SIZEOF_UINT32 = 4;\n\n/* PARSE FIXED HEADER:\nPopulates\n magic, // identifies type of tile\n type, // String version of magic\n version,\n byteLength\n */\nexport function parse3DTileHeaderSync(tile, arrayBuffer, byteOffset = 0) {\n const view = new DataView(arrayBuffer);\n\n tile.magic = view.getUint32(byteOffset, true);\n byteOffset += SIZEOF_UINT32;\n\n tile.version = view.getUint32(byteOffset, true);\n byteOffset += SIZEOF_UINT32;\n\n tile.byteLength = view.getUint32(byteOffset, true);\n byteOffset += SIZEOF_UINT32;\n\n // TODO - move version check into each tile parser?\n if (tile.version !== 1) {\n throw new Error(`3D Tile Version ${tile.version} not supported`);\n }\n\n return byteOffset; // Indicates where the parsing ended\n}\n"],"mappings":"AAGA,MAAMA,aAAa,GAAG,CAAC;AASvB,OAAO,SAASC,qBAAqBA,CAACC,IAAI,EAAEC,WAAW,EAAkB;EAAA,IAAhBC,UAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EACrE,MAAMG,IAAI,GAAG,IAAIC,QAAQ,CAACN,WAAW,CAAC;EAEtCD,IAAI,CAACQ,KAAK,GAAGF,IAAI,CAACG,SAAS,CAACP,UAAU,EAAE,IAAI,CAAC;EAC7CA,UAAU,IAAIJ,aAAa;EAE3BE,IAAI,CAACU,OAAO,GAAGJ,IAAI,CAACG,SAAS,CAACP,UAAU,EAAE,IAAI,CAAC;EAC/CA,UAAU,IAAIJ,aAAa;EAE3BE,IAAI,CAACW,UAAU,GAAGL,IAAI,CAACG,SAAS,CAACP,UAAU,EAAE,IAAI,CAAC;EAClDA,UAAU,IAAIJ,aAAa;EAG3B,IAAIE,IAAI,CAACU,OAAO,KAAK,CAAC,EAAE;IACtB,MAAM,IAAIE,KAAK,oBAAAC,MAAA,CAAoBb,IAAI,CAACU,OAAO,oBAAiB;EAClE;EAEA,OAAOR,UAAU;AACnB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const SUBTREE_FILE_MAGIC = 0x74627573;
|
|
2
2
|
const SUBTREE_FILE_VERSION = 1;
|
|
3
|
-
|
|
4
3
|
export default async function parse3DTilesSubtree(data, options, context) {
|
|
5
4
|
const magic = new Uint32Array(data.slice(0, 4));
|
|
6
5
|
if (magic[0] !== SUBTREE_FILE_MAGIC) {
|
|
@@ -31,19 +30,16 @@ export default async function parse3DTilesSubtree(data, options, context) {
|
|
|
31
30
|
}
|
|
32
31
|
return subtree;
|
|
33
32
|
}
|
|
34
|
-
|
|
35
33
|
function resolveBufferUri(bitstreamRelativeUri, basePath) {
|
|
36
34
|
const hasProtocol = basePath.startsWith('http');
|
|
37
35
|
if (hasProtocol) {
|
|
38
36
|
const resolvedUri = new URL(bitstreamRelativeUri, basePath);
|
|
39
37
|
return decodeURI(resolvedUri.toString());
|
|
40
38
|
}
|
|
41
|
-
|
|
42
39
|
const basePathWithProtocol = "http://".concat(basePath);
|
|
43
40
|
const resolvedUri = new URL(bitstreamRelativeUri, basePathWithProtocol);
|
|
44
41
|
return "/".concat(resolvedUri.host).concat(resolvedUri.pathname);
|
|
45
42
|
}
|
|
46
|
-
|
|
47
43
|
async function getExplicitBitstream(subtree, name, internalBinaryBuffer, context) {
|
|
48
44
|
const bufferViewIndex = subtree[name].bufferView;
|
|
49
45
|
const bufferView = subtree.bufferViews[bufferViewIndex];
|
|
@@ -54,7 +50,6 @@ async function getExplicitBitstream(subtree, name, internalBinaryBuffer, context
|
|
|
54
50
|
if (!context.fetch) {
|
|
55
51
|
throw new Error('fetch is not provided');
|
|
56
52
|
}
|
|
57
|
-
|
|
58
53
|
if (buffer.uri) {
|
|
59
54
|
const bufferUri = resolveBufferUri(buffer.uri, context === null || context === void 0 ? void 0 : context.url);
|
|
60
55
|
const response = await context.fetch(bufferUri);
|
|
@@ -63,7 +58,6 @@ async function getExplicitBitstream(subtree, name, internalBinaryBuffer, context
|
|
|
63
58
|
}
|
|
64
59
|
return new Uint8Array(internalBinaryBuffer, bufferView.byteOffset, bufferView.byteLength);
|
|
65
60
|
}
|
|
66
|
-
|
|
67
61
|
function parseUint64Value(buffer) {
|
|
68
62
|
const dataView = new DataView(buffer);
|
|
69
63
|
const left = dataView.getUint32(0, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-3d-tile-subtree.js","names":["SUBTREE_FILE_MAGIC","SUBTREE_FILE_VERSION","parse3DTilesSubtree","data","options","context","magic","Uint32Array","slice","Error","version","jsonByteLength","parseUint64Value","stringAttribute","Uint8Array","textDecoder","TextDecoder","string","decode","subtree","JSON","parse","binaryByteLength","internalBinaryBuffer","ArrayBuffer","tileAvailability","explicitBitstream","getExplicitBitstream","contentAvailability","childSubtreeAvailability","resolveBufferUri","bitstreamRelativeUri","basePath","hasProtocol","startsWith","resolvedUri","URL","decodeURI","toString","basePathWithProtocol","host","pathname","name","bufferViewIndex","bufferView","bufferViews","buffer","buffers","url","fetch","uri","bufferUri","response","arrayBuffer","byteOffset","byteLength","dataView","DataView","left","getUint32","right"],"sources":["../../../../../src/lib/parsers/helpers/parse-3d-tile-subtree.ts"],"sourcesContent":["import type {Subtree, ExplicitBitstream} from '../../../types';\nimport type {LoaderContext, LoaderOptions} from '@loaders.gl/loader-utils';\n\nconst SUBTREE_FILE_MAGIC = 0x74627573;\nconst SUBTREE_FILE_VERSION = 1;\n\n/**\n * Parse subtree file\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subtree-file-format\n * @param data\n * @returns\n */\n// eslint-disable-next-line max-statements\nexport default async function parse3DTilesSubtree(\n data: ArrayBuffer,\n options: LoaderOptions | undefined,\n context: LoaderContext | undefined\n): Promise<Subtree> {\n const magic = new Uint32Array(data.slice(0, 4));\n\n if (magic[0] !== SUBTREE_FILE_MAGIC) {\n throw new Error('Wrong subtree file magic number');\n }\n\n const version = new Uint32Array(data.slice(4, 8));\n\n if (version[0] !== SUBTREE_FILE_VERSION) {\n throw new Error('Wrong subtree file verson, must be 1');\n }\n\n const jsonByteLength = parseUint64Value(data.slice(8, 16));\n const stringAttribute = new Uint8Array(data, 24, jsonByteLength);\n\n const textDecoder = new TextDecoder('utf8');\n const string = textDecoder.decode(stringAttribute);\n const subtree = JSON.parse(string);\n\n const binaryByteLength = parseUint64Value(data.slice(16, 24));\n let internalBinaryBuffer = new ArrayBuffer(0);\n\n if (binaryByteLength) {\n internalBinaryBuffer = data.slice(24 + jsonByteLength);\n }\n\n if ('bufferView' in subtree.tileAvailability) {\n subtree.tileAvailability.explicitBitstream = await getExplicitBitstream(\n subtree,\n 'tileAvailability',\n internalBinaryBuffer,\n context\n );\n }\n\n if ('bufferView' in subtree.contentAvailability) {\n subtree.contentAvailability.explicitBitstream = await getExplicitBitstream(\n subtree,\n 'contentAvailability',\n internalBinaryBuffer,\n context\n );\n }\n\n if ('bufferView' in subtree.childSubtreeAvailability) {\n subtree.childSubtreeAvailability.explicitBitstream = await getExplicitBitstream(\n subtree,\n 'childSubtreeAvailability',\n internalBinaryBuffer,\n context\n );\n }\n\n return subtree;\n}\n\n/**\n * Get url for bitstream downloading\n * @param bitstreamRelativeUri\n * @param baseUri\n * @returns\n */\nfunction resolveBufferUri(bitstreamRelativeUri: string, basePath: string): string {\n const hasProtocol = basePath.startsWith('http');\n\n if (hasProtocol) {\n const resolvedUri = new URL(bitstreamRelativeUri, basePath);\n return decodeURI(resolvedUri.toString());\n }\n\n /**\n * Adding http protocol only for new URL constructor usage.\n * It allows to resolve relative paths like ../../example with basePath.\n */\n const basePathWithProtocol = `http://${basePath}`;\n const resolvedUri = new URL(bitstreamRelativeUri, basePathWithProtocol);\n /**\n * Drop protocol and use just relative path.\n */\n return `/${resolvedUri.host}${resolvedUri.pathname}`;\n}\n\n/**\n * Get explicit bitstream for subtree availability data.\n * @param subtree\n * @param name\n * @param internalBinaryBuffer\n */\nasync function getExplicitBitstream(\n subtree: Subtree,\n name: string,\n internalBinaryBuffer: ArrayBuffer,\n context: LoaderContext | undefined\n): Promise<ExplicitBitstream> {\n const bufferViewIndex = subtree[name].bufferView;\n const bufferView = subtree.bufferViews[bufferViewIndex];\n const buffer = subtree.buffers[bufferView.buffer];\n\n if (!context?.url || !context.fetch) {\n throw new Error('Url is not provided');\n }\n\n if (!context.fetch) {\n throw new Error('fetch is not provided');\n }\n\n // External bitstream loading\n if (buffer.uri) {\n const bufferUri = resolveBufferUri(buffer.uri, context?.url);\n const response = await context.fetch(bufferUri);\n const data = await response.arrayBuffer();\n // Return view of bitstream.\n return new Uint8Array(data, bufferView.byteOffset, bufferView.byteLength);\n }\n // Return view of bitstream.\n return new Uint8Array(internalBinaryBuffer, bufferView.byteOffset, bufferView.byteLength);\n}\n\n/**\n * Parse buffer to return uint64 value\n * @param buffer\n * @returns 64-bit value until precision is lost after Number.MAX_SAFE_INTEGER\n */\nfunction parseUint64Value(buffer: ArrayBuffer): number {\n const dataView = new DataView(buffer);\n const left = dataView.getUint32(0, true);\n const right = dataView.getUint32(4, true);\n // combine the two 32-bit values\n return left + 2 ** 32 * right;\n}\n"],"mappings":"AAGA,MAAMA,kBAAkB,GAAG,UAAU;AACrC,MAAMC,oBAAoB,GAAG,CAAC
|
|
1
|
+
{"version":3,"file":"parse-3d-tile-subtree.js","names":["SUBTREE_FILE_MAGIC","SUBTREE_FILE_VERSION","parse3DTilesSubtree","data","options","context","magic","Uint32Array","slice","Error","version","jsonByteLength","parseUint64Value","stringAttribute","Uint8Array","textDecoder","TextDecoder","string","decode","subtree","JSON","parse","binaryByteLength","internalBinaryBuffer","ArrayBuffer","tileAvailability","explicitBitstream","getExplicitBitstream","contentAvailability","childSubtreeAvailability","resolveBufferUri","bitstreamRelativeUri","basePath","hasProtocol","startsWith","resolvedUri","URL","decodeURI","toString","basePathWithProtocol","concat","host","pathname","name","bufferViewIndex","bufferView","bufferViews","buffer","buffers","url","fetch","uri","bufferUri","response","arrayBuffer","byteOffset","byteLength","dataView","DataView","left","getUint32","right"],"sources":["../../../../../src/lib/parsers/helpers/parse-3d-tile-subtree.ts"],"sourcesContent":["import type {Subtree, ExplicitBitstream} from '../../../types';\nimport type {LoaderContext, LoaderOptions} from '@loaders.gl/loader-utils';\n\nconst SUBTREE_FILE_MAGIC = 0x74627573;\nconst SUBTREE_FILE_VERSION = 1;\n\n/**\n * Parse subtree file\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subtree-file-format\n * @param data\n * @returns\n */\n// eslint-disable-next-line max-statements\nexport default async function parse3DTilesSubtree(\n data: ArrayBuffer,\n options: LoaderOptions | undefined,\n context: LoaderContext | undefined\n): Promise<Subtree> {\n const magic = new Uint32Array(data.slice(0, 4));\n\n if (magic[0] !== SUBTREE_FILE_MAGIC) {\n throw new Error('Wrong subtree file magic number');\n }\n\n const version = new Uint32Array(data.slice(4, 8));\n\n if (version[0] !== SUBTREE_FILE_VERSION) {\n throw new Error('Wrong subtree file verson, must be 1');\n }\n\n const jsonByteLength = parseUint64Value(data.slice(8, 16));\n const stringAttribute = new Uint8Array(data, 24, jsonByteLength);\n\n const textDecoder = new TextDecoder('utf8');\n const string = textDecoder.decode(stringAttribute);\n const subtree = JSON.parse(string);\n\n const binaryByteLength = parseUint64Value(data.slice(16, 24));\n let internalBinaryBuffer = new ArrayBuffer(0);\n\n if (binaryByteLength) {\n internalBinaryBuffer = data.slice(24 + jsonByteLength);\n }\n\n if ('bufferView' in subtree.tileAvailability) {\n subtree.tileAvailability.explicitBitstream = await getExplicitBitstream(\n subtree,\n 'tileAvailability',\n internalBinaryBuffer,\n context\n );\n }\n\n if ('bufferView' in subtree.contentAvailability) {\n subtree.contentAvailability.explicitBitstream = await getExplicitBitstream(\n subtree,\n 'contentAvailability',\n internalBinaryBuffer,\n context\n );\n }\n\n if ('bufferView' in subtree.childSubtreeAvailability) {\n subtree.childSubtreeAvailability.explicitBitstream = await getExplicitBitstream(\n subtree,\n 'childSubtreeAvailability',\n internalBinaryBuffer,\n context\n );\n }\n\n return subtree;\n}\n\n/**\n * Get url for bitstream downloading\n * @param bitstreamRelativeUri\n * @param baseUri\n * @returns\n */\nfunction resolveBufferUri(bitstreamRelativeUri: string, basePath: string): string {\n const hasProtocol = basePath.startsWith('http');\n\n if (hasProtocol) {\n const resolvedUri = new URL(bitstreamRelativeUri, basePath);\n return decodeURI(resolvedUri.toString());\n }\n\n /**\n * Adding http protocol only for new URL constructor usage.\n * It allows to resolve relative paths like ../../example with basePath.\n */\n const basePathWithProtocol = `http://${basePath}`;\n const resolvedUri = new URL(bitstreamRelativeUri, basePathWithProtocol);\n /**\n * Drop protocol and use just relative path.\n */\n return `/${resolvedUri.host}${resolvedUri.pathname}`;\n}\n\n/**\n * Get explicit bitstream for subtree availability data.\n * @param subtree\n * @param name\n * @param internalBinaryBuffer\n */\nasync function getExplicitBitstream(\n subtree: Subtree,\n name: string,\n internalBinaryBuffer: ArrayBuffer,\n context: LoaderContext | undefined\n): Promise<ExplicitBitstream> {\n const bufferViewIndex = subtree[name].bufferView;\n const bufferView = subtree.bufferViews[bufferViewIndex];\n const buffer = subtree.buffers[bufferView.buffer];\n\n if (!context?.url || !context.fetch) {\n throw new Error('Url is not provided');\n }\n\n if (!context.fetch) {\n throw new Error('fetch is not provided');\n }\n\n // External bitstream loading\n if (buffer.uri) {\n const bufferUri = resolveBufferUri(buffer.uri, context?.url);\n const response = await context.fetch(bufferUri);\n const data = await response.arrayBuffer();\n // Return view of bitstream.\n return new Uint8Array(data, bufferView.byteOffset, bufferView.byteLength);\n }\n // Return view of bitstream.\n return new Uint8Array(internalBinaryBuffer, bufferView.byteOffset, bufferView.byteLength);\n}\n\n/**\n * Parse buffer to return uint64 value\n * @param buffer\n * @returns 64-bit value until precision is lost after Number.MAX_SAFE_INTEGER\n */\nfunction parseUint64Value(buffer: ArrayBuffer): number {\n const dataView = new DataView(buffer);\n const left = dataView.getUint32(0, true);\n const right = dataView.getUint32(4, true);\n // combine the two 32-bit values\n return left + 2 ** 32 * right;\n}\n"],"mappings":"AAGA,MAAMA,kBAAkB,GAAG,UAAU;AACrC,MAAMC,oBAAoB,GAAG,CAAC;AAS9B,eAAe,eAAeC,mBAAmBA,CAC/CC,IAAiB,EACjBC,OAAkC,EAClCC,OAAkC,EAChB;EAClB,MAAMC,KAAK,GAAG,IAAIC,WAAW,CAACJ,IAAI,CAACK,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EAE/C,IAAIF,KAAK,CAAC,CAAC,CAAC,KAAKN,kBAAkB,EAAE;IACnC,MAAM,IAAIS,KAAK,CAAC,iCAAiC,CAAC;EACpD;EAEA,MAAMC,OA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EAGA,IAAIsC,MAAM,CAACI,GAAG,EAAE;IACd,MAAMC,SAAS,GAAGtB,gBAAgB,CAACiB,MAAM,CAACI,GAAG,EAAE9C,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAE4C,GAAG,CAAC;IAC5D,MAAMI,QAAQ,GAAG,MAAMhD,OAAO,CAAC6C,KAAK,CAACE,SAAS,CAAC;IAC/C,MAAMjD,IAAI,GAAG,MAAMkD,QAAQ,CAACC,WAAW,EAAE;IAEzC,OAAO,IAAIxC,UAAU,CAACX,IAAI,EAAE0C,UAAU,CAACU,UAAU,EAAEV,UAAU,CAACW,UAAU,CAAC;EAC3E;EAEA,OAAO,IAAI1C,UAAU,CAACS,oBAAoB,EAAEsB,UAAU,CAACU,UAAU,EAAEV,UAAU,CAACW,UAAU,CAAC;AAC3F;AAOA,SAAS5C,gBAAgBA,CAACmC,MAAmB,EAAU;EACrD,MAAMU,QAAQ,GAAG,IAAIC,QAAQ,CAACX,MAAM,CAAC;EACrC,MAAMY,IAAI,GAAGF,QAAQ,CAACG,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;EACxC,MAAMC,KAAK,GAAGJ,QAAQ,CAACG,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;EAEzC,OAAOD,IAAI,GAAG,CAAC,IAAI,EAAE,GAAGE,KAAK;AAC/B"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
import { getStringFromArrayBuffer } from './parse-utils';
|
|
4
2
|
const SIZEOF_UINT32 = 4;
|
|
5
3
|
const DEPRECATION_WARNING = 'b3dm tile in legacy format.';
|
|
6
|
-
|
|
7
4
|
export function parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset) {
|
|
8
5
|
const view = new DataView(arrayBuffer);
|
|
9
6
|
let batchLength;
|
|
@@ -16,7 +13,6 @@ export function parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset) {
|
|
|
16
13
|
byteOffset += SIZEOF_UINT32;
|
|
17
14
|
let batchTableBinaryByteLength = view.getUint32(byteOffset, true);
|
|
18
15
|
byteOffset += SIZEOF_UINT32;
|
|
19
|
-
|
|
20
16
|
if (batchTableJsonByteLength >= 570425344) {
|
|
21
17
|
byteOffset -= SIZEOF_UINT32 * 2;
|
|
22
18
|
batchLength = featureTableJsonByteLength;
|
|
@@ -34,7 +30,6 @@ export function parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset) {
|
|
|
34
30
|
featureTableBinaryByteLength = 0;
|
|
35
31
|
console.warn(DEPRECATION_WARNING);
|
|
36
32
|
}
|
|
37
|
-
|
|
38
33
|
tile.header.featureTableJsonByteLength = featureTableJsonByteLength;
|
|
39
34
|
tile.header.featureTableBinaryByteLength = featureTableBinaryByteLength;
|
|
40
35
|
tile.header.batchTableJsonByteLength = batchTableJsonByteLength;
|
|
@@ -63,7 +58,6 @@ function parse3DTileFeatureTable(tile, arrayBuffer, byteOffset, options) {
|
|
|
63
58
|
byteOffset += featureTableJsonByteLength;
|
|
64
59
|
tile.featureTableBinary = new Uint8Array(arrayBuffer, byteOffset, featureTableBinaryByteLength);
|
|
65
60
|
byteOffset += featureTableBinaryByteLength;
|
|
66
|
-
|
|
67
61
|
return byteOffset;
|
|
68
62
|
}
|
|
69
63
|
function parse3DTileBatchTable(tile, arrayBuffer, byteOffset, options) {
|