@loaders.gl/3d-tiles 3.4.13 → 3.4.15
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/dist.min.js +117 -120
- package/dist/es5/bundle.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/cesium-ion-loader.js +27 -61
- package/dist/es5/cesium-ion-loader.js.map +1 -1
- package/dist/es5/index.js +8 -8
- package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js +30 -42
- 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 +57 -59
- package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -1
- package/dist/es5/lib/classes/tile-3d-batch-table.js +177 -223
- package/dist/es5/lib/classes/tile-3d-batch-table.js.map +1 -1
- package/dist/es5/lib/classes/tile-3d-feature-table.js +52 -71
- package/dist/es5/lib/classes/tile-3d-feature-table.js.map +1 -1
- package/dist/es5/lib/constants.js +4 -4
- package/dist/es5/lib/constants.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js +15 -18
- package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile-composite.js +6 -9
- package/dist/es5/lib/encoders/encode-3d-tile-composite.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js +14 -19
- 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 +15 -18
- package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile.js +3 -3
- package/dist/es5/lib/encoders/encode-3d-tile.js.map +1 -1
- package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js +6 -6
- package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js.map +1 -1
- package/dist/es5/lib/ion/ion.js +63 -155
- package/dist/es5/lib/ion/ion.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js +17 -17
- 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 +3 -3
- 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 +3 -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 +166 -198
- 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 +25 -53
- 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 +3 -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 +57 -129
- 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 +19 -17
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-utils.js +7 -7
- package/dist/es5/lib/parsers/helpers/parse-utils.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js +10 -29
- package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js +12 -39
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +8 -27
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-header.js +99 -197
- package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js +37 -55
- 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 +110 -162
- package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile.js +21 -59
- package/dist/es5/lib/parsers/parse-3d-tile.js.map +1 -1
- package/dist/es5/lib/utils/obb/s2-corners-to-obb.js +10 -12
- package/dist/es5/lib/utils/obb/s2-corners-to-obb.js.map +1 -1
- package/dist/es5/lib/utils/s2/converters/s2-to-boundary.js +22 -20
- package/dist/es5/lib/utils/s2/converters/s2-to-boundary.js.map +1 -1
- package/dist/es5/lib/utils/s2/converters/s2-to-obb-points.js +9 -9
- package/dist/es5/lib/utils/s2/converters/s2-to-obb-points.js.map +1 -1
- package/dist/es5/lib/utils/s2/converters/s2-to-region.js +14 -18
- package/dist/es5/lib/utils/s2/converters/s2-to-region.js.map +1 -1
- package/dist/es5/lib/utils/s2/index.js +13 -13
- package/dist/es5/lib/utils/s2/s2-geometry-functions.js +2 -2
- package/dist/es5/lib/utils/s2/s2-geometry-functions.js.map +1 -1
- package/dist/es5/lib/utils/s2/s2-token-functions.js +10 -10
- package/dist/es5/lib/utils/s2/s2-token-functions.js.map +1 -1
- package/dist/es5/lib/utils/s2/s2geometry/s2-cell-utils.js +3 -3
- package/dist/es5/lib/utils/s2/s2geometry/s2-cell-utils.js.map +1 -1
- package/dist/es5/lib/utils/s2/s2geometry/s2-geometry.js +48 -54
- package/dist/es5/lib/utils/s2/s2geometry/s2-geometry.js.map +1 -1
- 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 +1 -1
- package/dist/es5/tile-3d-subtree-loader.js.map +1 -1
- package/dist/es5/tile-3d-writer.js +5 -4
- package/dist/es5/tile-3d-writer.js.map +1 -1
- package/dist/es5/tiles-3d-loader.js +37 -100
- package/dist/es5/tiles-3d-loader.js.map +1 -1
- package/dist/esm/lib/utils/version.js +1 -1
- package/package.json +7 -7
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.GLTF_FORMAT = void 0;
|
|
8
7
|
exports.extractGLTF = extractGLTF;
|
|
9
8
|
exports.parse3DTileGLTFViewSync = parse3DTileGLTFViewSync;
|
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
9
|
var _gltf = require("@loaders.gl/gltf");
|
|
13
10
|
var _loaderUtils = require("@loaders.gl/loader-utils");
|
|
14
|
-
|
|
11
|
+
const GLTF_FORMAT = {
|
|
15
12
|
URI: 0,
|
|
16
13
|
EMBEDDED: 1
|
|
17
14
|
};
|
|
18
15
|
exports.GLTF_FORMAT = GLTF_FORMAT;
|
|
19
16
|
function parse3DTileGLTFViewSync(tile, arrayBuffer, byteOffset, options) {
|
|
20
17
|
tile.rotateYtoZ = true;
|
|
21
|
-
|
|
18
|
+
const gltfByteLength = tile.byteOffset + tile.byteLength - byteOffset;
|
|
22
19
|
if (gltfByteLength === 0) {
|
|
23
20
|
throw new Error('glTF byte length must be greater than 0.');
|
|
24
21
|
}
|
|
@@ -31,58 +28,33 @@ function parse3DTileGLTFViewSync(tile, arrayBuffer, byteOffset, options) {
|
|
|
31
28
|
}
|
|
32
29
|
return tile.byteOffset + tile.byteLength;
|
|
33
30
|
}
|
|
34
|
-
function extractGLTF(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
_context.next = 7;
|
|
55
|
-
return fetch(tile.gltfUrl, options);
|
|
56
|
-
case 7:
|
|
57
|
-
tile.gltfArrayBuffer = _context.sent;
|
|
58
|
-
tile.gltfByteOffset = 0;
|
|
59
|
-
case 9:
|
|
60
|
-
if (!tile.gltfArrayBuffer) {
|
|
61
|
-
_context.next = 17;
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
_context.next = 12;
|
|
65
|
-
return parse(tile.gltfArrayBuffer, _gltf.GLTFLoader, options, context);
|
|
66
|
-
case 12:
|
|
67
|
-
tile.gltf = _context.sent;
|
|
68
|
-
tile.gpuMemoryUsageInBytes = (0, _gltf._getMemoryUsageGLTF)(tile.gltf);
|
|
69
|
-
delete tile.gltfArrayBuffer;
|
|
70
|
-
delete tile.gltfByteOffset;
|
|
71
|
-
delete tile.gltfByteLength;
|
|
72
|
-
case 17:
|
|
73
|
-
case "end":
|
|
74
|
-
return _context.stop();
|
|
75
|
-
}
|
|
76
|
-
}, _callee);
|
|
77
|
-
}));
|
|
78
|
-
return _extractGLTF.apply(this, arguments);
|
|
31
|
+
async function extractGLTF(tile, gltfFormat, options, context) {
|
|
32
|
+
const tile3DOptions = options['3d-tiles'] || {};
|
|
33
|
+
extractGLTFBufferOrURL(tile, gltfFormat, options);
|
|
34
|
+
if (tile3DOptions.loadGLTF) {
|
|
35
|
+
const {
|
|
36
|
+
parse,
|
|
37
|
+
fetch
|
|
38
|
+
} = context;
|
|
39
|
+
if (tile.gltfUrl) {
|
|
40
|
+
tile.gltfArrayBuffer = await fetch(tile.gltfUrl, options);
|
|
41
|
+
tile.gltfByteOffset = 0;
|
|
42
|
+
}
|
|
43
|
+
if (tile.gltfArrayBuffer) {
|
|
44
|
+
tile.gltf = await parse(tile.gltfArrayBuffer, _gltf.GLTFLoader, options, context);
|
|
45
|
+
tile.gpuMemoryUsageInBytes = (0, _gltf._getMemoryUsageGLTF)(tile.gltf);
|
|
46
|
+
delete tile.gltfArrayBuffer;
|
|
47
|
+
delete tile.gltfByteOffset;
|
|
48
|
+
delete tile.gltfByteLength;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
79
51
|
}
|
|
80
52
|
function extractGLTFBufferOrURL(tile, gltfFormat, options) {
|
|
81
53
|
switch (gltfFormat) {
|
|
82
54
|
case GLTF_FORMAT.URI:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
55
|
+
const gltfUrlBytes = new Uint8Array(tile.gltfArrayBuffer, tile.gltfByteOffset);
|
|
56
|
+
const textDecoder = new TextDecoder();
|
|
57
|
+
const gltfUrl = textDecoder.decode(gltfUrlBytes);
|
|
86
58
|
tile.gltfUrl = gltfUrl.replace(/[\s\0]+$/, '');
|
|
87
59
|
delete tile.gltfArrayBuffer;
|
|
88
60
|
delete tile.gltfByteOffset;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-3d-tile-gltf-view.js","names":["_gltf","require","_loaderUtils","GLTF_FORMAT","URI","EMBEDDED","exports","parse3DTileGLTFViewSync","tile","arrayBuffer","byteOffset","options","rotateYtoZ","gltfByteLength","byteLength","Error","gltfUpAxis","assetGltfUpAxis","gltfArrayBuffer","sliceArrayBuffer","gltfByteOffset","console","warn","concat","type","extractGLTF","
|
|
1
|
+
{"version":3,"file":"parse-3d-tile-gltf-view.js","names":["_gltf","require","_loaderUtils","GLTF_FORMAT","URI","EMBEDDED","exports","parse3DTileGLTFViewSync","tile","arrayBuffer","byteOffset","options","rotateYtoZ","gltfByteLength","byteLength","Error","gltfUpAxis","assetGltfUpAxis","gltfArrayBuffer","sliceArrayBuffer","gltfByteOffset","console","warn","concat","type","extractGLTF","gltfFormat","context","tile3DOptions","extractGLTFBufferOrURL","loadGLTF","parse","fetch","gltfUrl","gltf","GLTFLoader","gpuMemoryUsageInBytes","_getMemoryUsageGLTF","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 {_getMemoryUsageGLTF, 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 tile.gpuMemoryUsageInBytes = _getMemoryUsageGLTF(tile.gltf);\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,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEO,MAAME,WAAW,GAAG;EACzBC,GAAG,EAAE,CAAC;EACNC,QAAQ,EAAE;AACZ,CAAC;AAACC,OAAA,CAAAH,WAAA,GAAAA,WAAA;AA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
|
+
const SIZEOF_UINT32 = 4;
|
|
8
8
|
function parse3DTileHeaderSync(tile, arrayBuffer) {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
let byteOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
10
|
+
const view = new DataView(arrayBuffer);
|
|
11
11
|
tile.magic = view.getUint32(byteOffset, true);
|
|
12
12
|
byteOffset += SIZEOF_UINT32;
|
|
13
13
|
tile.version = view.getUint32(byteOffset, true);
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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;AAShB,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,mBAAgB,CAAC;EAClE;EAEA,OAAOR,UAAU;AACnB"}
|
|
@@ -1,145 +1,73 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = parse3DTilesSubtree;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
subtree = JSON.parse(string);
|
|
40
|
-
binaryByteLength = parseUint64Value(data.slice(16, 24));
|
|
41
|
-
internalBinaryBuffer = new ArrayBuffer(0);
|
|
42
|
-
if (binaryByteLength) {
|
|
43
|
-
internalBinaryBuffer = data.slice(24 + jsonByteLength);
|
|
44
|
-
}
|
|
45
|
-
if (!('bufferView' in subtree.tileAvailability)) {
|
|
46
|
-
_context.next = 18;
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
_context.next = 17;
|
|
50
|
-
return getExplicitBitstream(subtree, 'tileAvailability', internalBinaryBuffer, context);
|
|
51
|
-
case 17:
|
|
52
|
-
subtree.tileAvailability.explicitBitstream = _context.sent;
|
|
53
|
-
case 18:
|
|
54
|
-
if (!('bufferView' in subtree.contentAvailability)) {
|
|
55
|
-
_context.next = 22;
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
_context.next = 21;
|
|
59
|
-
return getExplicitBitstream(subtree, 'contentAvailability', internalBinaryBuffer, context);
|
|
60
|
-
case 21:
|
|
61
|
-
subtree.contentAvailability.explicitBitstream = _context.sent;
|
|
62
|
-
case 22:
|
|
63
|
-
if (!('bufferView' in subtree.childSubtreeAvailability)) {
|
|
64
|
-
_context.next = 26;
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
_context.next = 25;
|
|
68
|
-
return getExplicitBitstream(subtree, 'childSubtreeAvailability', internalBinaryBuffer, context);
|
|
69
|
-
case 25:
|
|
70
|
-
subtree.childSubtreeAvailability.explicitBitstream = _context.sent;
|
|
71
|
-
case 26:
|
|
72
|
-
return _context.abrupt("return", subtree);
|
|
73
|
-
case 27:
|
|
74
|
-
case "end":
|
|
75
|
-
return _context.stop();
|
|
76
|
-
}
|
|
77
|
-
}, _callee);
|
|
78
|
-
}));
|
|
79
|
-
return _parse3DTilesSubtree.apply(this, arguments);
|
|
7
|
+
const SUBTREE_FILE_MAGIC = 0x74627573;
|
|
8
|
+
const SUBTREE_FILE_VERSION = 1;
|
|
9
|
+
async function parse3DTilesSubtree(data, options, context) {
|
|
10
|
+
const magic = new Uint32Array(data.slice(0, 4));
|
|
11
|
+
if (magic[0] !== SUBTREE_FILE_MAGIC) {
|
|
12
|
+
throw new Error('Wrong subtree file magic number');
|
|
13
|
+
}
|
|
14
|
+
const version = new Uint32Array(data.slice(4, 8));
|
|
15
|
+
if (version[0] !== SUBTREE_FILE_VERSION) {
|
|
16
|
+
throw new Error('Wrong subtree file verson, must be 1');
|
|
17
|
+
}
|
|
18
|
+
const jsonByteLength = parseUint64Value(data.slice(8, 16));
|
|
19
|
+
const stringAttribute = new Uint8Array(data, 24, jsonByteLength);
|
|
20
|
+
const textDecoder = new TextDecoder('utf8');
|
|
21
|
+
const string = textDecoder.decode(stringAttribute);
|
|
22
|
+
const subtree = JSON.parse(string);
|
|
23
|
+
const binaryByteLength = parseUint64Value(data.slice(16, 24));
|
|
24
|
+
let internalBinaryBuffer = new ArrayBuffer(0);
|
|
25
|
+
if (binaryByteLength) {
|
|
26
|
+
internalBinaryBuffer = data.slice(24 + jsonByteLength);
|
|
27
|
+
}
|
|
28
|
+
if ('bufferView' in subtree.tileAvailability) {
|
|
29
|
+
subtree.tileAvailability.explicitBitstream = await getExplicitBitstream(subtree, 'tileAvailability', internalBinaryBuffer, context);
|
|
30
|
+
}
|
|
31
|
+
if ('bufferView' in subtree.contentAvailability) {
|
|
32
|
+
subtree.contentAvailability.explicitBitstream = await getExplicitBitstream(subtree, 'contentAvailability', internalBinaryBuffer, context);
|
|
33
|
+
}
|
|
34
|
+
if ('bufferView' in subtree.childSubtreeAvailability) {
|
|
35
|
+
subtree.childSubtreeAvailability.explicitBitstream = await getExplicitBitstream(subtree, 'childSubtreeAvailability', internalBinaryBuffer, context);
|
|
36
|
+
}
|
|
37
|
+
return subtree;
|
|
80
38
|
}
|
|
81
39
|
function resolveBufferUri(bitstreamRelativeUri, basePath) {
|
|
82
|
-
|
|
40
|
+
const hasProtocol = basePath.startsWith('http');
|
|
83
41
|
if (hasProtocol) {
|
|
84
|
-
|
|
85
|
-
return decodeURI(
|
|
42
|
+
const resolvedUri = new URL(bitstreamRelativeUri, basePath);
|
|
43
|
+
return decodeURI(resolvedUri.toString());
|
|
86
44
|
}
|
|
87
|
-
|
|
88
|
-
|
|
45
|
+
const basePathWithProtocol = "http://".concat(basePath);
|
|
46
|
+
const resolvedUri = new URL(bitstreamRelativeUri, basePathWithProtocol);
|
|
89
47
|
return "/".concat(resolvedUri.host).concat(resolvedUri.pathname);
|
|
90
48
|
}
|
|
91
|
-
function getExplicitBitstream(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
case 5:
|
|
109
|
-
if (context.fetch) {
|
|
110
|
-
_context2.next = 7;
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
throw new Error('fetch is not provided');
|
|
114
|
-
case 7:
|
|
115
|
-
if (!buffer.uri) {
|
|
116
|
-
_context2.next = 16;
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
bufferUri = resolveBufferUri(buffer.uri, context === null || context === void 0 ? void 0 : context.url);
|
|
120
|
-
_context2.next = 11;
|
|
121
|
-
return context.fetch(bufferUri);
|
|
122
|
-
case 11:
|
|
123
|
-
response = _context2.sent;
|
|
124
|
-
_context2.next = 14;
|
|
125
|
-
return response.arrayBuffer();
|
|
126
|
-
case 14:
|
|
127
|
-
data = _context2.sent;
|
|
128
|
-
return _context2.abrupt("return", new Uint8Array(data, bufferView.byteOffset, bufferView.byteLength));
|
|
129
|
-
case 16:
|
|
130
|
-
return _context2.abrupt("return", new Uint8Array(internalBinaryBuffer, bufferView.byteOffset, bufferView.byteLength));
|
|
131
|
-
case 17:
|
|
132
|
-
case "end":
|
|
133
|
-
return _context2.stop();
|
|
134
|
-
}
|
|
135
|
-
}, _callee2);
|
|
136
|
-
}));
|
|
137
|
-
return _getExplicitBitstream.apply(this, arguments);
|
|
49
|
+
async function getExplicitBitstream(subtree, name, internalBinaryBuffer, context) {
|
|
50
|
+
const bufferViewIndex = subtree[name].bufferView;
|
|
51
|
+
const bufferView = subtree.bufferViews[bufferViewIndex];
|
|
52
|
+
const buffer = subtree.buffers[bufferView.buffer];
|
|
53
|
+
if (!(context !== null && context !== void 0 && context.url) || !context.fetch) {
|
|
54
|
+
throw new Error('Url is not provided');
|
|
55
|
+
}
|
|
56
|
+
if (!context.fetch) {
|
|
57
|
+
throw new Error('fetch is not provided');
|
|
58
|
+
}
|
|
59
|
+
if (buffer.uri) {
|
|
60
|
+
const bufferUri = resolveBufferUri(buffer.uri, context === null || context === void 0 ? void 0 : context.url);
|
|
61
|
+
const response = await context.fetch(bufferUri);
|
|
62
|
+
const data = await response.arrayBuffer();
|
|
63
|
+
return new Uint8Array(data, bufferView.byteOffset, bufferView.byteLength);
|
|
64
|
+
}
|
|
65
|
+
return new Uint8Array(internalBinaryBuffer, bufferView.byteOffset, bufferView.byteLength);
|
|
138
66
|
}
|
|
139
67
|
function parseUint64Value(buffer) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return left +
|
|
68
|
+
const dataView = new DataView(buffer);
|
|
69
|
+
const left = dataView.getUint32(0, true);
|
|
70
|
+
const right = dataView.getUint32(4, true);
|
|
71
|
+
return left + 2 ** 32 * right;
|
|
144
72
|
}
|
|
145
73
|
//# sourceMappingURL=parse-3d-tile-subtree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-3d-tile-subtree.js","names":["SUBTREE_FILE_MAGIC","SUBTREE_FILE_VERSION","parse3DTilesSubtree","_x","_x2","_x3","_parse3DTilesSubtree","apply","arguments","_asyncToGenerator2","default","_regenerator","mark","_callee","data","options","context","magic","version","jsonByteLength","stringAttribute","textDecoder","string","subtree","binaryByteLength","internalBinaryBuffer","wrap","_callee$","_context","prev","next","Uint32Array","slice","Error","parseUint64Value","Uint8Array","TextDecoder","decode","JSON","parse","ArrayBuffer","tileAvailability","getExplicitBitstream","explicitBitstream","sent","contentAvailability","childSubtreeAvailability","abrupt","stop","resolveBufferUri","bitstreamRelativeUri","basePath","hasProtocol","startsWith","resolvedUri","URL","decodeURI","toString","basePathWithProtocol","concat","host","pathname","_x4","_x5","_x6","_x7","_getExplicitBitstream","_callee2","name","bufferViewIndex","bufferView","buffer","bufferUri","response","_callee2$","_context2","bufferViews","buffers","url","fetch","uri","arrayBuffer","byteOffset","byteLength","dataView","DataView","left","getUint32","right","Math","pow"],"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 basePath\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,IAAMA,kBAAkB,GAAG,UAAU;AACrC,IAAMC,oBAAoB,GAAG,CAAC;AAAC,SASDC,mBAAmBA,CAAAC,EAAA,EA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AA;MAAA;IAAA,GAAAmB,QAAA;EAAA,CAC1F;EAAA,OAAAD,qBAAA,CAAA3D,KAAA,OAAAC,SAAA;AAAA;AAOD,SAAS0B,gBAAgBA,CAACqC,MAAmB,EAAU;EACrD,IAAMa,QAAQ,GAAG,IAAIC,QAAQ,CAACd,MAAM,CAAC;EACrC,IAAMe,IAAI,GAAGF,QAAQ,CAACG,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;EACxC,IAAMC,KAAK,GAAGJ,QAAQ,CAACG,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;EAEzC,OAAOD,IAAI,GAAGG,IAAA,CAAAC,GAAA,EAAC,EAAI,EAAE,IAAGF,KAAK;AAC/B"}
|
|
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 basePath\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;AASf,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,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AAO,CAAC6C,KAAK,EAAE;IAClB,MAAM,IAAIzC,KAAK,CAAC,uBAAuB,CAAC;EAC1C;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,CAAC,CAAC;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"}
|
|
@@ -6,19 +6,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.parse3DTileTablesHeaderSync = parse3DTileTablesHeaderSync;
|
|
7
7
|
exports.parse3DTileTablesSync = parse3DTileTablesSync;
|
|
8
8
|
var _parseUtils = require("./parse-utils");
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const SIZEOF_UINT32 = 4;
|
|
10
|
+
const DEPRECATION_WARNING = 'b3dm tile in legacy format.';
|
|
11
11
|
function parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const view = new DataView(arrayBuffer);
|
|
13
|
+
let batchLength;
|
|
14
14
|
tile.header = tile.header || {};
|
|
15
|
-
|
|
15
|
+
let featureTableJsonByteLength = view.getUint32(byteOffset, true);
|
|
16
16
|
byteOffset += SIZEOF_UINT32;
|
|
17
|
-
|
|
17
|
+
let featureTableBinaryByteLength = view.getUint32(byteOffset, true);
|
|
18
18
|
byteOffset += SIZEOF_UINT32;
|
|
19
|
-
|
|
19
|
+
let batchTableJsonByteLength = view.getUint32(byteOffset, true);
|
|
20
20
|
byteOffset += SIZEOF_UINT32;
|
|
21
|
-
|
|
21
|
+
let batchTableBinaryByteLength = view.getUint32(byteOffset, true);
|
|
22
22
|
byteOffset += SIZEOF_UINT32;
|
|
23
23
|
if (batchTableJsonByteLength >= 570425344) {
|
|
24
24
|
byteOffset -= SIZEOF_UINT32 * 2;
|
|
@@ -50,15 +50,16 @@ function parse3DTileTablesSync(tile, arrayBuffer, byteOffset, options) {
|
|
|
50
50
|
return byteOffset;
|
|
51
51
|
}
|
|
52
52
|
function parse3DTileFeatureTable(tile, arrayBuffer, byteOffset, options) {
|
|
53
|
-
|
|
54
|
-
featureTableJsonByteLength
|
|
55
|
-
featureTableBinaryByteLength
|
|
56
|
-
batchLength
|
|
53
|
+
const {
|
|
54
|
+
featureTableJsonByteLength,
|
|
55
|
+
featureTableBinaryByteLength,
|
|
56
|
+
batchLength
|
|
57
|
+
} = tile.header;
|
|
57
58
|
tile.featureTableJson = {
|
|
58
59
|
BATCH_LENGTH: batchLength || 0
|
|
59
60
|
};
|
|
60
61
|
if (featureTableJsonByteLength > 0) {
|
|
61
|
-
|
|
62
|
+
const featureTableString = (0, _parseUtils.getStringFromArrayBuffer)(arrayBuffer, byteOffset, featureTableJsonByteLength);
|
|
62
63
|
tile.featureTableJson = JSON.parse(featureTableString);
|
|
63
64
|
}
|
|
64
65
|
byteOffset += featureTableJsonByteLength;
|
|
@@ -67,11 +68,12 @@ function parse3DTileFeatureTable(tile, arrayBuffer, byteOffset, options) {
|
|
|
67
68
|
return byteOffset;
|
|
68
69
|
}
|
|
69
70
|
function parse3DTileBatchTable(tile, arrayBuffer, byteOffset, options) {
|
|
70
|
-
|
|
71
|
-
batchTableJsonByteLength
|
|
72
|
-
batchTableBinaryByteLength
|
|
71
|
+
const {
|
|
72
|
+
batchTableJsonByteLength,
|
|
73
|
+
batchTableBinaryByteLength
|
|
74
|
+
} = tile.header;
|
|
73
75
|
if (batchTableJsonByteLength > 0) {
|
|
74
|
-
|
|
76
|
+
const batchTableString = (0, _parseUtils.getStringFromArrayBuffer)(arrayBuffer, byteOffset, batchTableJsonByteLength);
|
|
75
77
|
tile.batchTableJson = JSON.parse(batchTableString);
|
|
76
78
|
byteOffset += batchTableJsonByteLength;
|
|
77
79
|
if (batchTableBinaryByteLength > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-3d-tile-tables.js","names":["_parseUtils","require","SIZEOF_UINT32","DEPRECATION_WARNING","parse3DTileTablesHeaderSync","tile","arrayBuffer","byteOffset","view","DataView","batchLength","header","featureTableJsonByteLength","getUint32","featureTableBinaryByteLength","batchTableJsonByteLength","batchTableBinaryByteLength","console","warn","parse3DTileTablesSync","options","parse3DTileFeatureTable","parse3DTileBatchTable","
|
|
1
|
+
{"version":3,"file":"parse-3d-tile-tables.js","names":["_parseUtils","require","SIZEOF_UINT32","DEPRECATION_WARNING","parse3DTileTablesHeaderSync","tile","arrayBuffer","byteOffset","view","DataView","batchLength","header","featureTableJsonByteLength","getUint32","featureTableBinaryByteLength","batchTableJsonByteLength","batchTableBinaryByteLength","console","warn","parse3DTileTablesSync","options","parse3DTileFeatureTable","parse3DTileBatchTable","featureTableJson","BATCH_LENGTH","featureTableString","getStringFromArrayBuffer","JSON","parse","featureTableBinary","Uint8Array","batchTableString","batchTableJson","batchTableBinary"],"sources":["../../../../../src/lib/parsers/helpers/parse-3d-tile-tables.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\nimport {getStringFromArrayBuffer} from './parse-utils';\n\nconst SIZEOF_UINT32 = 4;\nconst DEPRECATION_WARNING = 'b3dm tile in legacy format.';\n\n// eslint-disable-next-line max-statements\nexport function parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset) {\n const view = new DataView(arrayBuffer);\n let batchLength;\n\n tile.header = tile.header || {};\n\n let featureTableJsonByteLength = view.getUint32(byteOffset, true);\n byteOffset += SIZEOF_UINT32;\n\n let featureTableBinaryByteLength = view.getUint32(byteOffset, true);\n byteOffset += SIZEOF_UINT32;\n\n let batchTableJsonByteLength = view.getUint32(byteOffset, true);\n byteOffset += SIZEOF_UINT32;\n\n let batchTableBinaryByteLength = view.getUint32(byteOffset, true);\n byteOffset += SIZEOF_UINT32;\n\n // First legacy header format - [batchLength] [batchTableByteLength] ('batchTableJsonByteLength': JSON starts with a quotation mark or the glTF magic)\n // Second legacy format - [batchTableJsonByteLength] [batchTableBinaryByteLength] [batchLength] (Second legacy format is similar as first but here we check 'batchTableBinaryByteLength' instead)\n // Current header format - [featureTableJsonByteLength] [featureTableBinaryByteLength] [batchTableJsonByteLength] [batchTableBinaryByteLength]\n // First byte will be 0x22 or 0x67. The minimum uint32 expected is 0x22000000 = 570425344 = 570MB.\n if (batchTableJsonByteLength >= 570425344) {\n byteOffset -= SIZEOF_UINT32 * 2;\n batchLength = featureTableJsonByteLength;\n batchTableJsonByteLength = featureTableBinaryByteLength;\n batchTableBinaryByteLength = 0;\n featureTableJsonByteLength = 0;\n featureTableBinaryByteLength = 0;\n\n console.warn(DEPRECATION_WARNING); // eslint-disable-line\n } else if (batchTableBinaryByteLength >= 570425344) {\n byteOffset -= SIZEOF_UINT32;\n batchLength = batchTableJsonByteLength;\n batchTableJsonByteLength = featureTableJsonByteLength;\n batchTableBinaryByteLength = featureTableBinaryByteLength;\n featureTableJsonByteLength = 0;\n featureTableBinaryByteLength = 0;\n\n console.warn(DEPRECATION_WARNING); // eslint-disable-line\n }\n\n tile.header.featureTableJsonByteLength = featureTableJsonByteLength;\n tile.header.featureTableBinaryByteLength = featureTableBinaryByteLength;\n tile.header.batchTableJsonByteLength = batchTableJsonByteLength;\n tile.header.batchTableBinaryByteLength = batchTableBinaryByteLength;\n tile.header.batchLength = batchLength;\n\n return byteOffset;\n}\n\nexport function parse3DTileTablesSync(tile, arrayBuffer, byteOffset, options) {\n byteOffset = parse3DTileFeatureTable(tile, arrayBuffer, byteOffset, options);\n byteOffset = parse3DTileBatchTable(tile, arrayBuffer, byteOffset, options);\n return byteOffset;\n}\n\nfunction parse3DTileFeatureTable(tile, arrayBuffer, byteOffset, options) {\n const {featureTableJsonByteLength, featureTableBinaryByteLength, batchLength} = tile.header;\n\n tile.featureTableJson = {\n BATCH_LENGTH: batchLength || 0\n };\n\n if (featureTableJsonByteLength > 0) {\n const featureTableString = getStringFromArrayBuffer(\n arrayBuffer,\n byteOffset,\n featureTableJsonByteLength\n );\n tile.featureTableJson = JSON.parse(featureTableString);\n }\n byteOffset += featureTableJsonByteLength;\n\n tile.featureTableBinary = new Uint8Array(arrayBuffer, byteOffset, featureTableBinaryByteLength);\n byteOffset += featureTableBinaryByteLength;\n\n /*\n const featureTable = parseFeatureTable(featureTableJson, featureTableBinary);\n\n const batchLength = featureTable.getGlobalProperty('BATCH_LENGTH');\n featureTable.featuresLength = batchLength;\n */\n\n return byteOffset;\n}\n\nfunction parse3DTileBatchTable(tile, arrayBuffer, byteOffset, options) {\n const {batchTableJsonByteLength, batchTableBinaryByteLength} = tile.header;\n\n if (batchTableJsonByteLength > 0) {\n const batchTableString = getStringFromArrayBuffer(\n arrayBuffer,\n byteOffset,\n batchTableJsonByteLength\n );\n tile.batchTableJson = JSON.parse(batchTableString);\n byteOffset += batchTableJsonByteLength;\n\n if (batchTableBinaryByteLength > 0) {\n // Has a batch table binary\n tile.batchTableBinary = new Uint8Array(arrayBuffer, byteOffset, batchTableBinaryByteLength);\n // Copy the batchTableBinary section and let the underlying ArrayBuffer be freed\n tile.batchTableBinary = new Uint8Array(tile.batchTableBinary);\n\n byteOffset += batchTableBinaryByteLength;\n }\n }\n\n return byteOffset;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GAAG,CAAC;AACvB,MAAMC,mBAAmB,GAAG,6BAA6B;AAGlD,SAASC,2BAA2BA,CAACC,IAAI,EAAEC,WAAW,EAAEC,UAAU,EAAE;EACzE,MAAMC,IAAI,GAAG,IAAIC,QAAQ,CAACH,WAAW,CAAC;EACtC,IAAII,WAAW;EAEfL,IAAI,CAACM,MAAM,GAAGN,IAAI,CAACM,MAAM,IAAI,CAAC,CAAC;EAE/B,IAAIC,0BAA0B,GAAGJ,IAAI,CAACK,SAAS,CAACN,UAAU,EAAE,IAAI,CAAC;EACjEA,UAAU,IAAIL,aAAa;EAE3B,IAAIY,4BAA4B,GAAGN,IAAI,CAACK,SAAS,CAACN,UAAU,EAAE,IAAI,CAAC;EACnEA,UAAU,IAAIL,aAAa;EAE3B,IAAIa,wBAAwB,GAAGP,IAAI,CAACK,SAAS,CAACN,UAAU,EAAE,IAAI,CAAC;EAC/DA,UAAU,IAAIL,aAAa;EAE3B,IAAIc,0BAA0B,GAAGR,IAAI,CAACK,SAAS,CAACN,UAAU,EAAE,IAAI,CAAC;EACjEA,UAAU,IAAIL,aAAa;EAM3B,IAAIa,wBAAwB,IAAI,SAAS,EAAE;IACzCR,UAAU,IAAIL,aAAa,GAAG,CAAC;IAC/BQ,WAAW,GAAGE,0BAA0B;IACxCG,wBAAwB,GAAGD,4BAA4B;IACvDE,0BAA0B,GAAG,CAAC;IAC9BJ,0BAA0B,GAAG,CAAC;IAC9BE,4BAA4B,GAAG,CAAC;IAEhCG,OAAO,CAACC,IAAI,CAACf,mBAAmB,CAAC;EACnC,CAAC,MA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,IAAI,CAACkB,gBAAgB,GAAGI,IAAI,CAACC,KAAK,CAACH,kBAAkB,CAAC;EACxD;EACAlB,UAAU,IAAIK,0BAA0B;EAExCP,IAAI,CAACwB,kBAAkB,GAAG,IAAIC,UAAU,CAACxB,WAAW,EAAEC,UAAU,EAAEO,4BAA4B,CAAC;EAC/FP,UAAU,IAAIO,4BAA4B;EAS1C,OAAOP,UAAU;AACnB;AAEA,SAASe,qBAAqBA,CAACjB,IAAI,EAAEC,WAAW,EAAEC,UAAU,EAAEa,OAAO,EAAE;EACrE,MAAM;IAACL,wBAAwB;IAAEC;EAA0B,CAAC,GAAGX,IAAI,CAACM,MAAM;EAE1E,IAAII,wBAAwB,GAAG,CAAC,EAAE;IAChC,MAAMgB,gBAAgB,GAAG,IAAAL,oCAAwB,EAC/CpB,WAAW,EACXC,UAAU,EACVQ,wBACF,CAAC;IACDV,IAAI,CAAC2B,cAAc,GAAGL,IAAI,CAACC,KAAK,CAACG,gBAAgB,CAAC;IAClDxB,UAAU,IAAIQ,wBAAwB;IAEtC,IAAIC,0BAA0B,GAAG,CAAC,EAAE;MAElCX,IAAI,CAAC4B,gBAAgB,GAAG,IAAIH,UAAU,CAACxB,WAAW,EAAEC,UAAU,EAAES,0BAA0B,CAAC;MAE3FX,IAAI,CAAC4B,gBAAgB,GAAG,IAAIH,UAAU,CAACzB,IAAI,CAAC4B,gBAAgB,CAAC;MAE7D1B,UAAU,IAAIS,0BAA0B;IAC1C;EACF;EAEA,OAAOT,UAAU;AACnB"}
|
|
@@ -9,20 +9,20 @@ exports.getStringFromTypedArray = getStringFromTypedArray;
|
|
|
9
9
|
var _loaderUtils = require("@loaders.gl/loader-utils");
|
|
10
10
|
function getStringFromArrayBuffer(arrayBuffer, byteOffset, byteLength) {
|
|
11
11
|
(0, _loaderUtils.assert)(arrayBuffer instanceof ArrayBuffer);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const textDecoder = new TextDecoder('utf8');
|
|
13
|
+
const typedArray = new Uint8Array(arrayBuffer, byteOffset, byteLength);
|
|
14
|
+
const string = textDecoder.decode(typedArray);
|
|
15
15
|
return string;
|
|
16
16
|
}
|
|
17
17
|
function getStringFromTypedArray(typedArray) {
|
|
18
18
|
(0, _loaderUtils.assert)(ArrayBuffer.isView(typedArray));
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const textDecoder = new TextDecoder('utf8');
|
|
20
|
+
const string = textDecoder.decode(typedArray);
|
|
21
21
|
return string;
|
|
22
22
|
}
|
|
23
23
|
function getMagicString(arrayBuffer) {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
let byteOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
25
|
+
const dataView = new DataView(arrayBuffer);
|
|
26
26
|
return "".concat(String.fromCharCode(dataView.getUint8(byteOffset + 0))).concat(String.fromCharCode(dataView.getUint8(byteOffset + 1))).concat(String.fromCharCode(dataView.getUint8(byteOffset + 2))).concat(String.fromCharCode(dataView.getUint8(byteOffset + 3)));
|
|
27
27
|
}
|
|
28
28
|
//# sourceMappingURL=parse-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-utils.js","names":["_loaderUtils","require","getStringFromArrayBuffer","arrayBuffer","byteOffset","byteLength","assert","ArrayBuffer","textDecoder","TextDecoder","typedArray","Uint8Array","string","decode","getStringFromTypedArray","isView","getMagicString","arguments","length","undefined","dataView","DataView","concat","String","fromCharCode","getUint8"],"sources":["../../../../../src/lib/parsers/helpers/parse-utils.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\nimport {assert} from '@loaders.gl/loader-utils';\n\n// Decode the JSON binary array into clear text\nexport function getStringFromArrayBuffer(arrayBuffer, byteOffset, byteLength) {\n assert(arrayBuffer instanceof ArrayBuffer);\n const textDecoder = new TextDecoder('utf8');\n const typedArray = new Uint8Array(arrayBuffer, byteOffset, byteLength);\n const string = textDecoder.decode(typedArray);\n return string;\n}\n\n// Decode the JSON binary array into clear text\nexport function getStringFromTypedArray(typedArray) {\n assert(ArrayBuffer.isView(typedArray));\n const textDecoder = new TextDecoder('utf8');\n const string = textDecoder.decode(typedArray);\n return string;\n}\n\nexport function getMagicString(arrayBuffer, byteOffset = 0) {\n const dataView = new DataView(arrayBuffer);\n return `\\\n${String.fromCharCode(dataView.getUint8(byteOffset + 0))}\\\n${String.fromCharCode(dataView.getUint8(byteOffset + 1))}\\\n${String.fromCharCode(dataView.getUint8(byteOffset + 2))}\\\n${String.fromCharCode(dataView.getUint8(byteOffset + 3))}`;\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAGO,SAASC,wBAAwBA,CAACC,WAAW,EAAEC,UAAU,EAAEC,UAAU,EAAE;EAC5E,IAAAC,mBAAM,EAACH,WAAW,YAAYI,WAAW,CAAC;EAC1C,
|
|
1
|
+
{"version":3,"file":"parse-utils.js","names":["_loaderUtils","require","getStringFromArrayBuffer","arrayBuffer","byteOffset","byteLength","assert","ArrayBuffer","textDecoder","TextDecoder","typedArray","Uint8Array","string","decode","getStringFromTypedArray","isView","getMagicString","arguments","length","undefined","dataView","DataView","concat","String","fromCharCode","getUint8"],"sources":["../../../../../src/lib/parsers/helpers/parse-utils.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\nimport {assert} from '@loaders.gl/loader-utils';\n\n// Decode the JSON binary array into clear text\nexport function getStringFromArrayBuffer(arrayBuffer, byteOffset, byteLength) {\n assert(arrayBuffer instanceof ArrayBuffer);\n const textDecoder = new TextDecoder('utf8');\n const typedArray = new Uint8Array(arrayBuffer, byteOffset, byteLength);\n const string = textDecoder.decode(typedArray);\n return string;\n}\n\n// Decode the JSON binary array into clear text\nexport function getStringFromTypedArray(typedArray) {\n assert(ArrayBuffer.isView(typedArray));\n const textDecoder = new TextDecoder('utf8');\n const string = textDecoder.decode(typedArray);\n return string;\n}\n\nexport function getMagicString(arrayBuffer, byteOffset = 0) {\n const dataView = new DataView(arrayBuffer);\n return `\\\n${String.fromCharCode(dataView.getUint8(byteOffset + 0))}\\\n${String.fromCharCode(dataView.getUint8(byteOffset + 1))}\\\n${String.fromCharCode(dataView.getUint8(byteOffset + 2))}\\\n${String.fromCharCode(dataView.getUint8(byteOffset + 3))}`;\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAGO,SAASC,wBAAwBA,CAACC,WAAW,EAAEC,UAAU,EAAEC,UAAU,EAAE;EAC5E,IAAAC,mBAAM,EAACH,WAAW,YAAYI,WAAW,CAAC;EAC1C,MAAMC,WAAW,GAAG,IAAIC,WAAW,CAAC,MAAM,CAAC;EAC3C,MAAMC,UAAU,GAAG,IAAIC,UAAU,CAACR,WAAW,EAAEC,UAAU,EAAEC,UAAU,CAAC;EACtE,MAAMO,MAAM,GAAGJ,WAAW,CAACK,MAAM,CAACH,UAAU,CAAC;EAC7C,OAAOE,MAAM;AACf;AAGO,SAASE,uBAAuBA,CAACJ,UAAU,EAAE;EAClD,IAAAJ,mBAAM,EAACC,WAAW,CAACQ,MAAM,CAACL,UAAU,CAAC,CAAC;EACtC,MAAMF,WAAW,GAAG,IAAIC,WAAW,CAAC,MAAM,CAAC;EAC3C,MAAMG,MAAM,GAAGJ,WAAW,CAACK,MAAM,CAACH,UAAU,CAAC;EAC7C,OAAOE,MAAM;AACf;AAEO,SAASI,cAAcA,CAACb,WAAW,EAAkB;EAAA,IAAhBC,UAAU,GAAAa,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EACxD,MAAMG,QAAQ,GAAG,IAAIC,QAAQ,CAAClB,WAAW,CAAC;EAC1C,UAAAmB,MAAA,CACAC,MAAM,CAACC,YAAY,CAACJ,QAAQ,CAACK,QAAQ,CA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