@loaders.gl/i3s 4.0.0-alpha.1 → 4.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arcgis-webscene-loader.d.ts +7 -0
- package/dist/arcgis-webscene-loader.d.ts.map +1 -0
- package/dist/arcgis-webscene-loader.js +28 -0
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +2 -2
- package/dist/dist.min.js +15501 -0
- package/dist/es5/arcgis-webscene-loader.js +40 -0
- package/dist/es5/arcgis-webscene-loader.js.map +1 -0
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/i3s-attribute-loader.js +195 -0
- package/dist/es5/i3s-attribute-loader.js.map +1 -0
- package/dist/es5/i3s-building-scene-layer-loader.js +46 -0
- package/dist/es5/i3s-building-scene-layer-loader.js.map +1 -0
- package/dist/es5/i3s-content-loader.js +56 -0
- package/dist/es5/i3s-content-loader.js.map +1 -0
- package/dist/es5/i3s-loader.js +193 -0
- package/dist/es5/i3s-loader.js.map +1 -0
- package/dist/es5/i3s-node-page-loader.js +39 -0
- package/dist/es5/i3s-node-page-loader.js.map +1 -0
- package/dist/es5/i3s-slpk-loader.js +20 -0
- package/dist/es5/i3s-slpk-loader.js.map +1 -0
- package/dist/es5/index.js +82 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +312 -0
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +1 -0
- package/dist/es5/lib/parsers/constants.js +72 -0
- package/dist/es5/lib/parsers/constants.js.map +1 -0
- package/dist/es5/lib/parsers/parse-arcgis-webscene.js +158 -0
- package/dist/es5/lib/parsers/parse-arcgis-webscene.js.map +1 -0
- package/dist/es5/lib/parsers/parse-i3s-attribute.js +76 -0
- package/dist/es5/lib/parsers/parse-i3s-attribute.js.map +1 -0
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js +65 -0
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -0
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js +510 -0
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -0
- package/dist/es5/lib/parsers/parse-i3s.js +116 -0
- package/dist/es5/lib/parsers/parse-i3s.js.map +1 -0
- package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js +107 -0
- package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js.map +1 -0
- package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js +258 -0
- package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js.map +1 -0
- package/dist/es5/lib/parsers/parse-zip/buffer-file-provider.js +46 -0
- package/dist/es5/lib/parsers/parse-zip/buffer-file-provider.js.map +1 -0
- package/dist/es5/lib/parsers/parse-zip/cd-file-header.js +84 -0
- package/dist/es5/lib/parsers/parse-zip/cd-file-header.js.map +1 -0
- package/dist/es5/lib/parsers/parse-zip/file-provider.js +2 -0
- package/dist/es5/lib/parsers/parse-zip/file-provider.js.map +1 -0
- package/dist/es5/lib/parsers/parse-zip/local-file-header.js +72 -0
- package/dist/es5/lib/parsers/parse-zip/local-file-header.js.map +1 -0
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js +17 -0
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -0
- package/dist/es5/lib/utils/customize-/321/201olors.js +184 -0
- package/dist/es5/lib/utils/customize-/321/201olors.js.map +1 -0
- package/dist/es5/lib/utils/url-utils.js +33 -0
- package/dist/es5/lib/utils/url-utils.js.map +1 -0
- package/dist/es5/types.js +26 -0
- package/dist/es5/types.js.map +1 -0
- package/dist/es5/workers/i3s-content-worker-node.js +7 -0
- package/dist/es5/workers/i3s-content-worker-node.js.map +1 -0
- package/dist/es5/workers/i3s-content-worker.js +6 -0
- package/dist/es5/workers/i3s-content-worker.js.map +1 -0
- package/dist/esm/arcgis-webscene-loader.js +16 -0
- package/dist/esm/arcgis-webscene-loader.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/i3s-attribute-loader.js +119 -0
- package/dist/esm/i3s-attribute-loader.js.map +1 -0
- package/dist/esm/i3s-building-scene-layer-loader.js +19 -0
- package/dist/esm/i3s-building-scene-layer-loader.js.map +1 -0
- package/dist/esm/i3s-content-loader.js +30 -0
- package/dist/esm/i3s-content-loader.js.map +1 -0
- package/dist/esm/i3s-loader.js +87 -0
- package/dist/esm/i3s-loader.js.map +1 -0
- package/dist/esm/i3s-node-page-loader.js +15 -0
- package/dist/esm/i3s-node-page-loader.js.map +1 -0
- package/dist/esm/i3s-slpk-loader.js +13 -0
- package/dist/esm/i3s-slpk-loader.js.map +1 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js +198 -0
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js.map +1 -0
- package/dist/esm/lib/parsers/constants.js +57 -0
- package/dist/esm/lib/parsers/constants.js.map +1 -0
- package/dist/esm/lib/parsers/parse-arcgis-webscene.js +70 -0
- package/dist/esm/lib/parsers/parse-arcgis-webscene.js.map +1 -0
- package/dist/esm/lib/parsers/parse-i3s-attribute.js +60 -0
- package/dist/esm/lib/parsers/parse-i3s-attribute.js.map +1 -0
- package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js +39 -0
- package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -0
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js +435 -0
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -0
- package/dist/esm/lib/parsers/parse-i3s.js +83 -0
- package/dist/esm/lib/parsers/parse-i3s.js.map +1 -0
- package/dist/esm/lib/parsers/parse-slpk/parse-slpk.js +41 -0
- package/dist/esm/lib/parsers/parse-slpk/parse-slpk.js.map +1 -0
- package/dist/esm/lib/parsers/parse-slpk/slpk-archieve.js +107 -0
- package/dist/esm/lib/parsers/parse-slpk/slpk-archieve.js.map +1 -0
- package/dist/esm/lib/parsers/parse-zip/buffer-file-provider.js +23 -0
- package/dist/esm/lib/parsers/parse-zip/buffer-file-provider.js.map +1 -0
- package/dist/esm/lib/parsers/parse-zip/cd-file-header.js +37 -0
- package/dist/esm/lib/parsers/parse-zip/cd-file-header.js.map +1 -0
- package/dist/esm/lib/parsers/parse-zip/file-provider.js +2 -0
- package/dist/esm/lib/parsers/parse-zip/file-provider.js.map +1 -0
- package/dist/esm/lib/parsers/parse-zip/local-file-header.js +25 -0
- package/dist/esm/lib/parsers/parse-zip/local-file-header.js.map +1 -0
- package/dist/esm/lib/utils/convert-i3s-obb-to-mbs.js +9 -0
- package/dist/esm/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -0
- package/dist/esm/lib/utils/customize-/321/201olors.js +98 -0
- package/dist/esm/lib/utils/customize-/321/201olors.js.map +1 -0
- package/dist/esm/lib/utils/url-utils.js +28 -0
- package/dist/esm/lib/utils/url-utils.js.map +1 -0
- package/dist/esm/types.js +18 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/workers/i3s-content-worker-node.js +5 -0
- package/dist/esm/workers/i3s-content-worker-node.js.map +1 -0
- package/dist/esm/workers/i3s-content-worker.js +4 -0
- package/dist/esm/workers/i3s-content-worker.js.map +1 -0
- package/dist/i3s-attribute-loader.d.ts +21 -0
- package/dist/i3s-attribute-loader.d.ts.map +1 -0
- package/dist/i3s-attribute-loader.js +155 -132
- package/dist/i3s-building-scene-layer-loader.d.ts +6 -0
- package/dist/i3s-building-scene-layer-loader.d.ts.map +1 -0
- package/dist/i3s-building-scene-layer-loader.js +23 -18
- package/dist/i3s-content-loader.d.ts +6 -0
- package/dist/i3s-content-loader.d.ts.map +1 -0
- package/dist/i3s-content-loader.js +29 -22
- package/dist/i3s-content-worker-node.js +197 -0
- package/dist/i3s-content-worker-node.js.map +7 -0
- package/dist/i3s-content-worker.js +2308 -1376
- package/dist/i3s-loader.d.ts +11 -0
- package/dist/i3s-loader.d.ts.map +1 -0
- package/dist/i3s-loader.js +88 -81
- package/dist/i3s-node-page-loader.d.ts +7 -0
- package/dist/i3s-node-page-loader.d.ts.map +1 -0
- package/dist/i3s-node-page-loader.js +20 -20
- package/dist/i3s-slpk-loader.d.ts +13 -0
- package/dist/i3s-slpk-loader.d.ts.map +1 -0
- package/dist/i3s-slpk-loader.js +20 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -5
- package/dist/lib/helpers/i3s-nodepages-tiles.d.ts +74 -0
- package/dist/lib/helpers/i3s-nodepages-tiles.d.ts.map +1 -0
- package/dist/lib/helpers/i3s-nodepages-tiles.js +232 -219
- package/dist/lib/parsers/constants.d.ts +40 -0
- package/dist/lib/parsers/constants.d.ts.map +1 -0
- package/dist/lib/parsers/constants.js +87 -42
- package/dist/lib/parsers/parse-arcgis-webscene.d.ts +7 -0
- package/dist/lib/parsers/parse-arcgis-webscene.d.ts.map +1 -0
- package/dist/lib/parsers/parse-arcgis-webscene.js +88 -0
- package/dist/lib/parsers/parse-i3s-attribute.d.ts +12 -0
- package/dist/lib/parsers/parse-i3s-attribute.d.ts.map +1 -0
- package/dist/lib/parsers/parse-i3s-attribute.js +87 -62
- package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts +9 -0
- package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts.map +1 -0
- package/dist/lib/parsers/parse-i3s-building-scene-layer.js +41 -38
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts +4 -0
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -0
- package/dist/lib/parsers/parse-i3s-tile-content.js +460 -415
- package/dist/lib/parsers/parse-i3s.d.ts +6 -0
- package/dist/lib/parsers/parse-i3s.d.ts.map +1 -0
- package/dist/lib/parsers/parse-i3s.js +92 -73
- package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts +4 -0
- package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts.map +1 -0
- package/dist/lib/parsers/parse-slpk/parse-slpk.js +54 -0
- package/dist/lib/parsers/parse-slpk/slpk-archieve.d.ts +38 -0
- package/dist/lib/parsers/parse-slpk/slpk-archieve.d.ts.map +1 -0
- package/dist/lib/parsers/parse-slpk/slpk-archieve.js +142 -0
- package/dist/lib/parsers/parse-zip/buffer-file-provider.d.ts +37 -0
- package/dist/lib/parsers/parse-zip/buffer-file-provider.d.ts.map +1 -0
- package/dist/lib/parsers/parse-zip/buffer-file-provider.js +47 -0
- package/dist/lib/parsers/parse-zip/cd-file-header.d.ts +27 -0
- package/dist/lib/parsers/parse-zip/cd-file-header.d.ts.map +1 -0
- package/dist/lib/parsers/parse-zip/cd-file-header.js +48 -0
- package/dist/lib/parsers/parse-zip/file-provider.d.ts +31 -0
- package/dist/lib/parsers/parse-zip/file-provider.d.ts.map +1 -0
- package/dist/lib/parsers/parse-zip/file-provider.js +2 -0
- package/dist/lib/parsers/parse-zip/local-file-header.d.ts +25 -0
- package/dist/lib/parsers/parse-zip/local-file-header.d.ts.map +1 -0
- package/dist/lib/parsers/parse-zip/local-file-header.js +34 -0
- package/dist/lib/utils/convert-i3s-obb-to-mbs.d.ts +2 -0
- package/dist/lib/utils/convert-i3s-obb-to-mbs.d.ts.map +1 -0
- package/dist/lib/utils/convert-i3s-obb-to-mbs.js +19 -8
- package/dist/lib/utils/customize-/321/201olors.d.ts +14 -0
- package/dist/lib/utils/customize-/321/201olors.d.ts.map +1 -0
- package/dist/lib/utils/customize-/321/201olors.js +104 -0
- package/dist/lib/utils/url-utils.d.ts +22 -0
- package/dist/lib/utils/url-utils.d.ts.map +1 -0
- package/dist/lib/utils/url-utils.js +41 -29
- package/dist/types.d.ts +1065 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +20 -2
- package/dist/workers/i3s-content-worker-node.d.ts +2 -0
- package/dist/workers/i3s-content-worker-node.d.ts.map +1 -0
- package/dist/workers/i3s-content-worker-node.js +7 -0
- package/dist/workers/i3s-content-worker.d.ts +2 -0
- package/dist/workers/i3s-content-worker.d.ts.map +1 -0
- package/dist/workers/i3s-content-worker.js +5 -4
- package/package.json +18 -16
- package/src/arcgis-webscene-loader.ts +31 -0
- package/src/i3s-attribute-loader.ts +9 -9
- package/src/i3s-content-loader.ts +17 -5
- package/src/i3s-loader.ts +24 -13
- package/src/i3s-node-page-loader.ts +6 -10
- package/src/i3s-slpk-loader.ts +27 -0
- package/src/index.ts +28 -7
- package/src/lib/helpers/i3s-nodepages-tiles.ts +84 -57
- package/src/lib/parsers/constants.ts +71 -37
- package/src/lib/parsers/parse-arcgis-webscene.ts +102 -0
- package/src/lib/parsers/parse-i3s-attribute.ts +21 -14
- package/src/lib/parsers/parse-i3s-building-scene-layer.ts +2 -1
- package/src/lib/parsers/parse-i3s-tile-content.ts +278 -194
- package/src/lib/parsers/parse-i3s.ts +55 -39
- package/src/lib/parsers/parse-slpk/parse-slpk.ts +72 -0
- package/src/lib/parsers/parse-slpk/slpk-archieve.ts +173 -0
- package/src/lib/parsers/parse-zip/buffer-file-provider.ts +55 -0
- package/src/lib/parsers/parse-zip/cd-file-header.ts +86 -0
- package/src/lib/parsers/parse-zip/file-provider.ts +34 -0
- package/src/lib/parsers/parse-zip/local-file-header.ts +65 -0
- package/src/lib/utils/customize-/321/201olors.ts +144 -0
- package/src/lib/utils/url-utils.ts +7 -7
- package/src/types.ts +875 -86
- package/src/workers/i3s-content-worker-node.ts +6 -0
- package/dist/bundle.js.map +0 -1
- package/dist/i3s-attribute-loader.js.map +0 -1
- package/dist/i3s-building-scene-layer-loader.js.map +0 -1
- package/dist/i3s-content-loader.js.map +0 -1
- package/dist/i3s-loader.js.map +0 -1
- package/dist/i3s-node-page-loader.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/helpers/i3s-nodepages-tiles.js.map +0 -1
- package/dist/lib/parsers/constants.js.map +0 -1
- package/dist/lib/parsers/parse-i3s-attribute.js.map +0 -1
- package/dist/lib/parsers/parse-i3s-building-scene-layer.js.map +0 -1
- package/dist/lib/parsers/parse-i3s-tile-content.js.map +0 -1
- package/dist/lib/parsers/parse-i3s.js.map +0 -1
- package/dist/lib/utils/convert-i3s-obb-to-mbs.js.map +0 -1
- package/dist/lib/utils/url-utils.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/workers/i3s-content-worker.js.map +0 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DataViewFileProvider } from '../parse-zip/buffer-file-provider';
|
|
2
|
+
import { parseZipCDFileHeader } from '../parse-zip/cd-file-header';
|
|
3
|
+
import { parseZipLocalFileHeader } from '../parse-zip/local-file-header';
|
|
4
|
+
import { SLPKArchive } from './slpk-archieve';
|
|
5
|
+
const getByteAt = (offset, buffer) => {
|
|
6
|
+
return buffer.getUint8(buffer.byteOffset + offset);
|
|
7
|
+
};
|
|
8
|
+
export async function parseSLPK(data) {
|
|
9
|
+
var _options$slpk$path, _options$slpk, _options$slpk2;
|
|
10
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
11
|
+
const archive = new DataView(data);
|
|
12
|
+
const cdFileHeaderSignature = [80, 75, 1, 2];
|
|
13
|
+
const searchWindow = [getByteAt(archive.byteLength - 1, archive), getByteAt(archive.byteLength - 2, archive), getByteAt(archive.byteLength - 3, archive), undefined];
|
|
14
|
+
let hashCDOffset = 0;
|
|
15
|
+
for (let i = archive.byteLength - 4; i > -1; i--) {
|
|
16
|
+
searchWindow[3] = searchWindow[2];
|
|
17
|
+
searchWindow[2] = searchWindow[1];
|
|
18
|
+
searchWindow[1] = searchWindow[0];
|
|
19
|
+
searchWindow[0] = getByteAt(i, archive);
|
|
20
|
+
if (searchWindow.every((val, index) => val === cdFileHeaderSignature[index])) {
|
|
21
|
+
hashCDOffset = i;
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const fileProvider = new DataViewFileProvider(archive);
|
|
26
|
+
const cdFileHeader = await parseZipCDFileHeader(hashCDOffset, fileProvider);
|
|
27
|
+
if (cdFileHeader.fileName !== '@specialIndexFileHASH128@') {
|
|
28
|
+
throw new Error('No hash file in slpk');
|
|
29
|
+
}
|
|
30
|
+
const localFileHeader = await parseZipLocalFileHeader(cdFileHeader.localHeaderOffset, fileProvider);
|
|
31
|
+
if (!localFileHeader) {
|
|
32
|
+
throw new Error('No hash file in slpk');
|
|
33
|
+
}
|
|
34
|
+
const fileDataOffset = localFileHeader.fileDataOffset;
|
|
35
|
+
const hashFile = archive.buffer.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
|
|
36
|
+
if (!hashFile) {
|
|
37
|
+
throw new Error('No hash file in slpk');
|
|
38
|
+
}
|
|
39
|
+
return await new SLPKArchive(data, hashFile).getFile((_options$slpk$path = (_options$slpk = options.slpk) === null || _options$slpk === void 0 ? void 0 : _options$slpk.path) !== null && _options$slpk$path !== void 0 ? _options$slpk$path : '', (_options$slpk2 = options.slpk) === null || _options$slpk2 === void 0 ? void 0 : _options$slpk2.pathMode);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=parse-slpk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-slpk.js","names":["DataViewFileProvider","parseZipCDFileHeader","parseZipLocalFileHeader","SLPKArchive","getByteAt","offset","buffer","getUint8","byteOffset","parseSLPK","data","_options$slpk$path","_options$slpk","_options$slpk2","options","arguments","length","undefined","archive","DataView","cdFileHeaderSignature","searchWindow","byteLength","hashCDOffset","i","every","val","index","fileProvider","cdFileHeader","fileName","Error","localFileHeader","localHeaderOffset","fileDataOffset","hashFile","slice","compressedSize","getFile","slpk","path","pathMode"],"sources":["../../../../../src/lib/parsers/parse-slpk/parse-slpk.ts"],"sourcesContent":["import type {SLPKLoaderOptions} from '../../../i3s-slpk-loader';\nimport {DataViewFileProvider} from '../parse-zip/buffer-file-provider';\nimport {parseZipCDFileHeader} from '../parse-zip/cd-file-header';\nimport {parseZipLocalFileHeader} from '../parse-zip/local-file-header';\nimport {SLPKArchive} from './slpk-archieve';\n\n/**\n * Returns one byte from the provided buffer at the provided position\n * @param offset - position where to read\n * @param buffer - buffer to read\n * @returns one byte from the provided buffer at the provided position\n */\nconst getByteAt = (offset: number, buffer: DataView): number => {\n return buffer.getUint8(buffer.byteOffset + offset);\n};\n\nexport async function parseSLPK(data: ArrayBuffer, options: SLPKLoaderOptions = {}) {\n const archive = new DataView(data);\n const cdFileHeaderSignature = [80, 75, 1, 2];\n\n const searchWindow = [\n getByteAt(archive.byteLength - 1, archive),\n getByteAt(archive.byteLength - 2, archive),\n getByteAt(archive.byteLength - 3, archive),\n undefined\n ];\n\n let hashCDOffset = 0;\n\n // looking for the last record in the central directory\n for (let i = archive.byteLength - 4; i > -1; i--) {\n searchWindow[3] = searchWindow[2];\n searchWindow[2] = searchWindow[1];\n searchWindow[1] = searchWindow[0];\n searchWindow[0] = getByteAt(i, archive);\n if (searchWindow.every((val, index) => val === cdFileHeaderSignature[index])) {\n hashCDOffset = i;\n break;\n }\n }\n\n const fileProvider = new DataViewFileProvider(archive);\n\n const cdFileHeader = await parseZipCDFileHeader(hashCDOffset, fileProvider);\n\n if (cdFileHeader.fileName !== '@specialIndexFileHASH128@') {\n throw new Error('No hash file in slpk');\n }\n\n const localFileHeader = await parseZipLocalFileHeader(\n cdFileHeader.localHeaderOffset,\n fileProvider\n );\n if (!localFileHeader) {\n throw new Error('No hash file in slpk');\n }\n\n const fileDataOffset = localFileHeader.fileDataOffset;\n const hashFile = archive.buffer.slice(\n fileDataOffset,\n fileDataOffset + localFileHeader.compressedSize\n );\n\n if (!hashFile) {\n throw new Error('No hash file in slpk');\n }\n\n return await new SLPKArchive(data, hashFile).getFile(\n options.slpk?.path ?? '',\n options.slpk?.pathMode\n );\n}\n"],"mappings":"AACA,SAAQA,oBAAoB,QAAO,mCAAmC;AACtE,SAAQC,oBAAoB,QAAO,6BAA6B;AAChE,SAAQC,uBAAuB,Q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import { parseZipLocalFileHeader } from '../parse-zip/local-file-header';
|
|
4
|
+
import { DataViewFileProvider } from '../parse-zip/buffer-file-provider';
|
|
5
|
+
import { GZipCompression } from '@loaders.gl/compression';
|
|
6
|
+
const PATH_DESCRIPTIONS = [{
|
|
7
|
+
test: /^$/,
|
|
8
|
+
extensions: ['3dSceneLayer.json.gz']
|
|
9
|
+
}, {
|
|
10
|
+
test: /^nodepages\/\d+$/,
|
|
11
|
+
extensions: ['.json.gz']
|
|
12
|
+
}, {
|
|
13
|
+
test: /^nodes\/\d+$/,
|
|
14
|
+
extensions: ['/3dNodeIndexDocument.json.gz']
|
|
15
|
+
}, {
|
|
16
|
+
test: /^nodes\/\d+\/textures\/.+$/,
|
|
17
|
+
extensions: ['.jpg', '.png', '.bin.dds.gz', '.ktx']
|
|
18
|
+
}, {
|
|
19
|
+
test: /^nodes\/\d+\/geometries\/\d+$/,
|
|
20
|
+
extensions: ['.bin.gz', '.draco.gz']
|
|
21
|
+
}, {
|
|
22
|
+
test: /^nodes\/\d+\/attributes\/f_\d+\/\d+$/,
|
|
23
|
+
extensions: ['.bin.gz']
|
|
24
|
+
}, {
|
|
25
|
+
test: /^statistics\/f_\d+\/\d+$/,
|
|
26
|
+
extensions: ['.json.gz']
|
|
27
|
+
}, {
|
|
28
|
+
test: /^nodes\/\d+\/shared$/,
|
|
29
|
+
extensions: ['/sharedResource.json.gz']
|
|
30
|
+
}];
|
|
31
|
+
export class SLPKArchive {
|
|
32
|
+
constructor(slpkArchiveBuffer, hashFile) {
|
|
33
|
+
_defineProperty(this, "slpkArchive", void 0);
|
|
34
|
+
_defineProperty(this, "hashArray", void 0);
|
|
35
|
+
this.slpkArchive = new DataView(slpkArchiveBuffer);
|
|
36
|
+
this.hashArray = this.parseHashFile(hashFile);
|
|
37
|
+
}
|
|
38
|
+
parseHashFile(hashFile) {
|
|
39
|
+
const hashFileBuffer = Buffer.from(hashFile);
|
|
40
|
+
const hashArray = [];
|
|
41
|
+
for (let i = 0; i < hashFileBuffer.buffer.byteLength; i = i + 24) {
|
|
42
|
+
const offsetBuffer = new DataView(hashFileBuffer.buffer.slice(hashFileBuffer.byteOffset + i + 16, hashFileBuffer.byteOffset + i + 24));
|
|
43
|
+
const offset = offsetBuffer.getUint32(offsetBuffer.byteOffset, true);
|
|
44
|
+
hashArray.push({
|
|
45
|
+
hash: Buffer.from(hashFileBuffer.subarray(hashFileBuffer.byteOffset + i, hashFileBuffer.byteOffset + i + 16)),
|
|
46
|
+
offset
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return hashArray;
|
|
50
|
+
}
|
|
51
|
+
async getFile(path) {
|
|
52
|
+
let mode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'raw';
|
|
53
|
+
if (mode === 'http') {
|
|
54
|
+
var _PATH_DESCRIPTIONS$fi;
|
|
55
|
+
const extensions = (_PATH_DESCRIPTIONS$fi = PATH_DESCRIPTIONS.find(val => val.test.test(path))) === null || _PATH_DESCRIPTIONS$fi === void 0 ? void 0 : _PATH_DESCRIPTIONS$fi.extensions;
|
|
56
|
+
if (extensions) {
|
|
57
|
+
let data;
|
|
58
|
+
for (const ext of extensions) {
|
|
59
|
+
data = await this.getDataByPath("".concat(path).concat(ext));
|
|
60
|
+
if (data) {
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (data) {
|
|
65
|
+
return Buffer.from(data);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (mode === 'raw') {
|
|
70
|
+
const decompressedFile = await this.getDataByPath("".concat(path, ".gz"));
|
|
71
|
+
if (decompressedFile) {
|
|
72
|
+
return Buffer.from(decompressedFile);
|
|
73
|
+
}
|
|
74
|
+
const fileWithoutCompression = await this.getFileBytes(path);
|
|
75
|
+
if (fileWithoutCompression) {
|
|
76
|
+
return Buffer.from(fileWithoutCompression);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
throw new Error('No such file in the archieve');
|
|
80
|
+
}
|
|
81
|
+
async getDataByPath(path) {
|
|
82
|
+
const data = await this.getFileBytes(path);
|
|
83
|
+
if (!data) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
if (/\.gz$/.test(path)) {
|
|
87
|
+
const compression = new GZipCompression();
|
|
88
|
+
const decompressedData = await compression.decompress(data);
|
|
89
|
+
return decompressedData;
|
|
90
|
+
}
|
|
91
|
+
return Buffer.from(data);
|
|
92
|
+
}
|
|
93
|
+
async getFileBytes(path) {
|
|
94
|
+
const nameHash = Buffer.from(md5(path), 'hex');
|
|
95
|
+
const fileInfo = this.hashArray.find(val => Buffer.compare(val.hash, nameHash) === 0);
|
|
96
|
+
if (!fileInfo) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
const localFileHeader = await parseZipLocalFileHeader(this.slpkArchive.byteOffset + (fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.offset), new DataViewFileProvider(this.slpkArchive));
|
|
100
|
+
if (!localFileHeader) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
const compressedFile = this.slpkArchive.buffer.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
|
|
104
|
+
return compressedFile;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=slpk-archieve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slpk-archieve.js","names":["md5","parseZipLocalFileHeader","DataViewFileProvider","GZipCompression","PATH_DESCRIPTIONS","test","extensions","SLPKArchive","constructor","slpkArchiveBuffer","hashFile","_defineProperty","slpkArchive","DataView","hashArray","parseHashFile","hashFileBuffer","Buffer","from","i","buffer","byteLength","offsetBuffer","slice","byteOffset","offset","getUint32","push","hash","subarray","getFile","path","mode","arguments","length","undefined","_PATH_DESCRIPTIONS$fi","find","val","data","ext","getDataByPath","concat","decompressedFile","fileWithoutCompression","getFileBytes","Error","compression","decompressedData","decompress","nameHash","fileInfo","compare","localFileHeader","compressedFile","fileDataOffset","compressedSize"],"sources":["../../../../../src/lib/parsers/parse-slpk/slpk-archieve.ts"],"sourcesContent":["import md5 from 'md5';\nimport {parseZipLocalFileHeader} from '../parse-zip/local-file-header';\nimport {DataViewFileProvider} from '../parse-zip/buffer-file-provider';\nimport {GZipCompression} from '@loaders.gl/compression';\n\n/** Element of hash array */\ntype HashElement = {\n /**\n * File name hash\n */\n hash: Buffer;\n /**\n * File offset in the archive\n */\n offset: number;\n};\n\n/** Description of real paths for different file types */\nconst PATH_DESCRIPTIONS: {test: RegExp; extensions: string[]}[] = [\n {\n test: /^$/,\n extensions: ['3dSceneLayer.json.gz']\n },\n {\n test: /^nodepages\\/\\d+$/,\n extensions: ['.json.gz']\n },\n {\n test: /^nodes\\/\\d+$/,\n extensions: ['/3dNodeIndexDocument.json.gz']\n },\n {\n test: /^nodes\\/\\d+\\/textures\\/.+$/,\n extensions: ['.jpg', '.png', '.bin.dds.gz', '.ktx']\n },\n {\n test: /^nodes\\/\\d+\\/geometries\\/\\d+$/,\n extensions: ['.bin.gz', '.draco.gz']\n },\n {\n test: /^nodes\\/\\d+\\/attributes\\/f_\\d+\\/\\d+$/,\n extensions: ['.bin.gz']\n },\n {\n test: /^statistics\\/f_\\d+\\/\\d+$/,\n extensions: ['.json.gz']\n },\n {\n test: /^nodes\\/\\d+\\/shared$/,\n extensions: ['/sharedResource.json.gz']\n }\n];\n\n/**\n * Class for handling information about slpk file\n */\nexport class SLPKArchive {\n slpkArchive: DataView;\n hashArray: {hash: Buffer; offset: number}[];\n constructor(slpkArchiveBuffer: ArrayBuffer, hashFile: ArrayBuffer) {\n this.slpkArchive = new DataView(slpkArchiveBuffer);\n this.hashArray = this.parseHashFile(hashFile);\n }\n\n /**\n * Reads hash file from buffer and returns it in ready-to-use form\n * @param hashFile - bufer containing hash file\n * @returns Array containing file info\n */\n private parseHashFile(hashFile: ArrayBuffer): HashElement[] {\n const hashFileBuffer = Buffer.from(hashFile);\n const hashArray: HashElement[] = [];\n for (let i = 0; i < hashFileBuffer.buffer.byteLength; i = i + 24) {\n const offsetBuffer = new DataView(\n hashFileBuffer.buffer.slice(\n hashFileBuffer.byteOffset + i + 16,\n hashFileBuffer.byteOffset + i + 24\n )\n );\n const offset = offsetBuffer.getUint32(offsetBuffer.byteOffset, true);\n hashArray.push({\n hash: Buffer.from(\n hashFileBuffer.subarray(hashFileBuffer.byteOffset + i, hashFileBuffer.byteOffset + i + 16)\n ),\n offset\n });\n }\n return hashArray;\n }\n\n /**\n * Returns file with the given path from slpk archive\n * @param path - path inside the slpk\n * @param mode - currently only raw mode supported\n * @returns buffer with ready to use file\n */\n async getFile(path: string, mode: 'http' | 'raw' = 'raw'): Promise<Buffer> {\n if (mode === 'http') {\n const extensions = PATH_DESCRIPTIONS.find((val) => val.test.test(path))?.extensions;\n if (extensions) {\n let data: ArrayBuffer | undefined;\n for (const ext of extensions) {\n data = await this.getDataByPath(`${path}${ext}`);\n if (data) {\n break;\n }\n }\n if (data) {\n return Buffer.from(data);\n }\n }\n }\n if (mode === 'raw') {\n const decompressedFile = await this.getDataByPath(`${path}.gz`);\n if (decompressedFile) {\n return Buffer.from(decompressedFile);\n }\n const fileWithoutCompression = await this.getFileBytes(path);\n if (fileWithoutCompression) {\n return Buffer.from(fileWithoutCompression);\n }\n }\n\n throw new Error('No such file in the archieve');\n }\n\n /**\n * returning uncompressed data for paths that ends with .gz and raw data for all other paths\n * @param path - path inside the archive\n * @returns buffer with the file data\n */\n private async getDataByPath(path: string): Promise<ArrayBuffer | undefined> {\n const data = await this.getFileBytes(path);\n if (!data) {\n return undefined;\n }\n if (/\\.gz$/.test(path)) {\n const compression = new GZipCompression();\n\n const decompressedData = await compression.decompress(data);\n return decompressedData;\n }\n return Buffer.from(data);\n }\n\n /**\n * Trying to get raw file data by adress\n * @param path - path inside the archive\n * @returns buffer with the raw file data\n */\n private async getFileBytes(path: string): Promise<ArrayBuffer | undefined> {\n const nameHash = Buffer.from(md5(path), 'hex');\n const fileInfo = this.hashArray.find((val) => Buffer.compare(val.hash, nameHash) === 0);\n if (!fileInfo) {\n return undefined;\n }\n\n const localFileHeader = await parseZipLocalFileHeader(\n this.slpkArchive.byteOffset + fileInfo?.offset,\n new DataViewFileProvider(this.slpkArchive)\n );\n if (!localFileHeader) {\n return undefined;\n }\n\n const compressedFile = this.slpkArchive.buffer.slice(\n localFileHeader.fileDataOffset,\n localFileHeader.fileDataOffset + localFileHeader.compressedSize\n );\n\n return compressedFile;\n }\n}\n"],"mappings":";AAAA,OAAOA,GAAG,MAAM,KAAK;AACrB,SAAQC,uBAAuB,QAAO,gCAAgC;AACtE,SAAQC,oBAAoB,QAAO,mCAAmC;AACtE,SAAQC,eAAe,QAAO,yBAAyB;AAevD,MAAMC,iBAAyD,GAAG,CAChE;EACEC,IAAI,EAAE,IAAI;EACVC,UAAU,EAAE,CAAC,sBAAsB;AACrC,CAAC,EACD;EACED,IAAI,EAAE,kBAAkB;EACxBC,UAAU,EAAE,CAAC,UAAU;AACzB,CAAC,EACD;EACED,IAAI,EAAE,cAAc;EACpBC,UAAU,EAAE,CAAC,8BAA8B;AAC7C,CAAC,EACD;EACED,IAAI,EAAE,4BAA4B;EAClCC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;AACpD,CAAC,EACD;EACED,IAAI,EAAE,+BAA+B;EACrCC,UAAU,EAAE,CAAC,SAAS,EAAE,WAAW;AACrC,CAAC,EACD;EACED,IAAI,EAAE,sCAAsC;EAC5CC,UAAU,EAAE,CAAC,SAAS;AACxB,CAAC,EACD;EACED,IAAI,EAAE,0BAA0B;EAChCC,UAAU,EAAE,CAAC,UAAU;AACzB,CAAC,EACD;EACED,IAAI,EAAE,sBAAsB;EAC5BC,UAAU,EAAE,CAAC,yBAAyB;AACxC,CAAC,CACF;AAKD,OAAO,MAAMC,WAAW,CAAC;EAGvBC,WAAWA,CAACC,iBAA8B,EAAEC,QAAq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AAI,CAAC;MAC3D,OAAOS,gBAAgB;IACzB;IACA,OAAO/B,MAAM,CAACC,IAAI,CAACqB,IAAI,CAAC;EAC1B;EAOA,MAAcM,YAAYA,CAACd,IAAY,EAAoC;IACzE,MAAMmB,QAAQ,GAAGjC,MAAM,CAACC,IAAI,CAAClB,GAAG,CAAC+B,IAAI,CAAC,EAAE,KAAK,CAAC;IAC9C,MAAMoB,QAAQ,GAAG,IAAI,CAACrC,SAAS,CAACuB,IAAI,CAAEC,GAAG,IAAKrB,MAAM,CAACmC,OAAO,CAACd,GAAG,CAACV,IAAI,EAAEsB,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvF,IAAI,CAACC,QAAQ,EAAE;MACb,OAAOhB,SAAS;IAClB;IAEA,MAAMkB,eAAe,GAAG,MAAMpD,uBAAuB,CACnD,IAAI,CAACW,WAAW,CAACY,UAAU,IAAG2B,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAE1B,MAAM,GAC9C,IAAIvB,oBAAoB,CAAC,IAAI,CAACU,WAAW,CAC3C,CAAC;IACD,IAAI,CAACyC,eAAe,EAAE;MACpB,OAAOlB,SAAS;IAClB;IAEA,MAAMmB,cAAc,GAAG,IAAI,CAAC1C,WAAW,CAACQ,MAAM,CAACG,KAAK,CAClD8B,eAAe,CAACE,cAAc,EAC9BF,eAAe,CAACE,cAAc,GAAGF,eAAe,CAACG,cACnD,CAAC;IAED,OAAOF,cAAc;EACvB;AACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
export class DataViewFileProvider {
|
|
3
|
+
constructor(file) {
|
|
4
|
+
_defineProperty(this, "file", void 0);
|
|
5
|
+
this.file = file;
|
|
6
|
+
}
|
|
7
|
+
getUint8(offset) {
|
|
8
|
+
return Promise.resolve(this.file.getUint8(offset));
|
|
9
|
+
}
|
|
10
|
+
getUint16(offset) {
|
|
11
|
+
return Promise.resolve(this.file.getUint16(offset, true));
|
|
12
|
+
}
|
|
13
|
+
getUint32(offset) {
|
|
14
|
+
return Promise.resolve(this.file.getUint32(offset, true));
|
|
15
|
+
}
|
|
16
|
+
slice(startOffset, endOffset) {
|
|
17
|
+
return Promise.resolve(this.file.buffer.slice(startOffset, endOffset));
|
|
18
|
+
}
|
|
19
|
+
get length() {
|
|
20
|
+
return this.file.byteLength;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=buffer-file-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer-file-provider.js","names":["DataViewFileProvider","constructor","file","_defineProperty","getUint8","offset","Promise","resolve","getUint16","getUint32","slice","startOffset","endOffset","buffer","length","byteLength"],"sources":["../../../../../src/lib/parsers/parse-zip/buffer-file-provider.ts"],"sourcesContent":["import {FileProvider} from './file-provider';\n\n/**\n * Provides file data using DataView\n */\nexport class DataViewFileProvider implements FileProvider {\n /**\n * The DataView from which data is provided\n */\n private file: DataView;\n\n constructor(file: DataView) {\n this.file = file;\n }\n\n /**\n * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n getUint8(offset: number): Promise<number> {\n return Promise.resolve(this.file.getUint8(offset));\n }\n\n /**\n * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n getUint16(offset: number): Promise<number> {\n return Promise.resolve(this.file.getUint16(offset, true));\n }\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n getUint32(offset: number): Promise<number> {\n return Promise.resolve(this.file.getUint32(offset, true));\n }\n\n /**\n * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.\n * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.\n * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.\n */\n slice(startOffset: number, endOffset: number): Promise<ArrayBuffer> {\n return Promise.resolve(this.file.buffer.slice(startOffset, endOffset));\n }\n\n /**\n * the length (in bytes) of the data.\n */\n get length() {\n return this.file.byteLength;\n }\n}\n"],"mappings":";AAKA,OAAO,MAAMA,oBAAoB,CAAyB;EAMxDC,WAAWA,CAACC,IAAc,EAAE;IAAAC,eAAA;IAC1B,IAAI,CAACD,IAAI,GAAGA,IAAI;EAClB;EAMAE,QAAQA,CAACC,MAAc,EAAmB;IACxC,OAAOC,OAAO,CAACC,OAAO,CAAC,IAAI,CAACL,IAAI,CAACE,QAAQ,CAACC,MAAM,CAAC,CAAC;EACpD;EAMAG,SAASA,CAACH,MAAc,EAAmB;IACzC,OAAOC,OAAO,CAACC,OAAO,CAAC,IAAI,CAACL,IAAI,CAACM,SAAS,CAACH,MAAM,EAAE,IAAI,CAAC,CAAC;EAC3D;EAMAI,SAASA,CAACJ,MAAc,EAAmB;IACzC,OAAOC,OAAO,CAACC,OAAO,CAAC,IAAI,CAACL,IAAI,CAACO,SAAS,CAACJ,MAAM,EAAE,IAAI,CAAC,CAAC;EAC3D;EAOAK,KAAKA,CAACC,WAAmB,EAAEC,SAAiB,EAAwB;IAClE,OAAON,OAAO,CAACC,OAAO,CAAC,IAAI,CAACL,IAAI,CAACW,MAAM,CAACH,KAAK,CAACC,WAAW,EAAEC,SAAS,CAAC,CAAC;EACxE;EAKA,IAAIE,MAAMA,CAAA,EAAG;IACX,OAAO,IAAI,CAACZ,IAAI,CAACa,UAAU;EAC7B;AACF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const parseZipCDFileHeader = async (headerOffset, buffer) => {
|
|
2
|
+
const offsets = {
|
|
3
|
+
CD_COMPRESSED_SIZE_OFFSET: 20,
|
|
4
|
+
CD_UNCOMPRESSED_SIZE_OFFSET: 24,
|
|
5
|
+
CD_FILE_NAME_LENGTH_OFFSET: 28,
|
|
6
|
+
CD_EXTRA_FIELD_LENGTH_OFFSET: 30,
|
|
7
|
+
CD_LOCAL_HEADER_OFFSET_OFFSET: 42,
|
|
8
|
+
CD_FILE_NAME_OFFSET: 46
|
|
9
|
+
};
|
|
10
|
+
const compressedSize = await buffer.getUint32(headerOffset + offsets.CD_COMPRESSED_SIZE_OFFSET);
|
|
11
|
+
const uncompressedSize = await buffer.getUint32(headerOffset + offsets.CD_UNCOMPRESSED_SIZE_OFFSET);
|
|
12
|
+
const fileNameLength = await buffer.getUint16(headerOffset + offsets.CD_FILE_NAME_LENGTH_OFFSET);
|
|
13
|
+
const fileName = new TextDecoder().decode(await buffer.slice(headerOffset + offsets.CD_FILE_NAME_OFFSET, headerOffset + offsets.CD_FILE_NAME_OFFSET + fileNameLength));
|
|
14
|
+
const extraOffset = headerOffset + offsets.CD_FILE_NAME_OFFSET + fileNameLength;
|
|
15
|
+
const oldFormatOffset = await buffer.getUint32(headerOffset + offsets.CD_LOCAL_HEADER_OFFSET_OFFSET);
|
|
16
|
+
let fileDataOffset = oldFormatOffset;
|
|
17
|
+
if (fileDataOffset === 0xffffffff) {
|
|
18
|
+
let offsetInZip64Data = 4;
|
|
19
|
+
if (compressedSize === 0xffffffff) {
|
|
20
|
+
offsetInZip64Data += 8;
|
|
21
|
+
}
|
|
22
|
+
if (uncompressedSize === 0xffffffff) {
|
|
23
|
+
offsetInZip64Data += 8;
|
|
24
|
+
}
|
|
25
|
+
fileDataOffset = await buffer.getUint32(extraOffset + offsetInZip64Data);
|
|
26
|
+
}
|
|
27
|
+
const localHeaderOffset = fileDataOffset;
|
|
28
|
+
return {
|
|
29
|
+
compressedSize,
|
|
30
|
+
uncompressedSize,
|
|
31
|
+
fileNameLength,
|
|
32
|
+
fileName,
|
|
33
|
+
extraOffset,
|
|
34
|
+
localHeaderOffset
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=cd-file-header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cd-file-header.js","names":["parseZipCDFileHeader","headerOffset","buffer","offsets","CD_COMPRESSED_SIZE_OFFSET","CD_UNCOMPRESSED_SIZE_OFFSET","CD_FILE_NAME_LENGTH_OFFSET","CD_EXTRA_FIELD_LENGTH_OFFSET","CD_LOCAL_HEADER_OFFSET_OFFSET","CD_FILE_NAME_OFFSET","compressedSize","getUint32","uncompressedSize","fileNameLength","getUint16","fileName","TextDecoder","decode","slice","extraOffset","oldFormatOffset","fileDataOffset","offsetInZip64Data","localHeaderOffset"],"sources":["../../../../../src/lib/parsers/parse-zip/cd-file-header.ts"],"sourcesContent":["import {FileProvider} from './file-provider';\n\n/**\n * zip central directory file header info\n * according to https://en.wikipedia.org/wiki/ZIP_(file_format)\n */\nexport type ZipCDFileHeader = {\n /** Compressed size */\n compressedSize: number;\n /** Uncompressed size */\n uncompressedSize: number;\n /** File name length */\n fileNameLength: number;\n /** File name */\n fileName: string;\n /** Extra field offset */\n extraOffset: number;\n /** Relative offset of local file header */\n localHeaderOffset: number;\n};\n\n/**\n * Parses central directory file header of zip file\n * @param headerOffset - offset in the archive where header starts\n * @param buffer - buffer containing whole array\n * @returns Info from the header\n */\nexport const parseZipCDFileHeader = async (\n headerOffset: number,\n buffer: FileProvider\n): Promise<ZipCDFileHeader> => {\n const offsets = {\n CD_COMPRESSED_SIZE_OFFSET: 20,\n CD_UNCOMPRESSED_SIZE_OFFSET: 24,\n CD_FILE_NAME_LENGTH_OFFSET: 28,\n CD_EXTRA_FIELD_LENGTH_OFFSET: 30,\n CD_LOCAL_HEADER_OFFSET_OFFSET: 42,\n CD_FILE_NAME_OFFSET: 46\n };\n\n const compressedSize = await buffer.getUint32(headerOffset + offsets.CD_COMPRESSED_SIZE_OFFSET);\n\n const uncompressedSize = await buffer.getUint32(\n headerOffset + offsets.CD_UNCOMPRESSED_SIZE_OFFSET\n );\n\n const fileNameLength = await buffer.getUint16(headerOffset + offsets.CD_FILE_NAME_LENGTH_OFFSET);\n\n const fileName = new TextDecoder().decode(\n await buffer.slice(\n headerOffset + offsets.CD_FILE_NAME_OFFSET,\n headerOffset + offsets.CD_FILE_NAME_OFFSET + fileNameLength\n )\n );\n\n const extraOffset = headerOffset + offsets.CD_FILE_NAME_OFFSET + fileNameLength;\n\n const oldFormatOffset = await buffer.getUint32(\n headerOffset + offsets.CD_LOCAL_HEADER_OFFSET_OFFSET\n );\n\n let fileDataOffset = oldFormatOffset;\n if (fileDataOffset === 0xffffffff) {\n let offsetInZip64Data = 4;\n // looking for info that might be also be in zip64 extra field\n if (compressedSize === 0xffffffff) {\n offsetInZip64Data += 8;\n }\n if (uncompressedSize === 0xffffffff) {\n offsetInZip64Data += 8;\n }\n\n // getUint32 needs to be replaced with getBigUint64 for archieves bigger than 2gb\n fileDataOffset = await buffer.getUint32(extraOffset + offsetInZip64Data); // setting it to the one from zip64\n }\n const localHeaderOffset = fileDataOffset;\n\n return {\n compressedSize,\n uncompressedSize,\n fileNameLength,\n fileName,\n extraOffset,\n localHeaderOffset\n };\n};\n"],"mappings":"AA2BA,OAAO,MAAMA,oBAAoB,GAAG,MAAAA,CAClCC,YAAoB,EACpBC,MAAoB,KACS;EAC7B,MAAMC,OAAO,GAAG;IACdC,yBAAyB,EAAE,EAAE;IAC7BC,2BAA2B,EAAE,EAAE;IAC/BC,0BAA0B,EAAE,EAAE;IAC9BC,4BAA4B,EAAE,EAAE;IAChCC,6BAA6B,EAAE,EAAE;IACjCC,mBAAmB,EAAE;EACvB,CAAC;EAED,MAAMC,cAAc,GAAG,MAAMR,MAAM,CAACS,SAAS,CAACV,YAAY,GAAGE,OAAO,CAACC,yBAAyB,CAAC;EAE/F,MAAMQ,gBAAgB,GAAG,MAAMV,MAAM,CAACS,SAAS,CAC7CV,YAAY,GAAGE,OAAO,CAACE,2BACzB,CAAC;EAED,MAAMQ,cAAc,GAAG,MAAMX,MAAM,CAACY,SAAS,CAACb,YAAY,GAAGE,OAAO,CAACG,0BAA0B,CAAC;EAEhG,MAAMS,QAAQ,GAAG,IAAIC,WAAW,CAAC,CAAC,CAACC,MAAM,CACvC,MAAMf,MAAM,CAACgB,KAAK,CAChBjB,YAAY,GAAGE,OAAO,CAACM,mBAAmB,EAC1CR,YAAY,GAAGE,OAAO,CAACM,mBAAmB,GAAGI,cAC/C,CACF,CAAC;EAED,MAAMM,WAAW,GAAGlB,YAAY,GAAGE,OAAO,CAACM,mBAAmB,GAAGI,cAAc;EAE/E,MAAMO,eAAe,GAAG,MAAMlB,MAAM,CAACS,SAAS,CAC5CV,YAAY,GAAGE,OAAO,CAACK,6BACzB,CAAC;EAED,IAAIa,cAAc,GAAGD,eAAe;EACpC,IAAIC,cAAc,KAAK,UAAU,EAAE;IACjC,IAAIC,iBAAiB,GAAG,CAAC;IAEzB,IAAIZ,cAAc,KAAK,UAAU,EAAE;MACjCY,iBAAiB,IAAI,CAAC;IACxB;IACA,IAAIV,gBAAgB,KAAK,UAAU,EAAE;MACnCU,iBAAiB,IAAI,CAAC;IACxB;IAGAD,cAAc,GAAG,MAAMnB,MAAM,CAACS,SAAS,CAACQ,WAAW,GAAGG,iBAAiB,CAAC;EAC1E;EACA,MAAMC,iBAAiB,GAAGF,cAAc;EAExC,OAAO;IACLX,cAAc;IACdE,gBAAgB;IAChBC,cAAc;IACdE,QAAQ;IACRI,WAAW;IACXI;EACF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-provider.js","names":[],"sources":["../../../../../src/lib/parsers/parse-zip/file-provider.ts"],"sourcesContent":["/**\n * Interface for providing file data\n */\nexport interface FileProvider {\n /**\n * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n getUint8(offset: number): Promise<number>;\n\n /**\n * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n getUint16(offset: number): Promise<number>;\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the file of the view where to read the data.\n */\n getUint32(offset: number): Promise<number>;\n\n /**\n * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.\n * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.\n * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.\n */\n slice(startOffset: number, endOffset: number): Promise<ArrayBuffer>;\n\n /**\n * the length (in bytes) of the data.\n */\n length: number;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const offsets = {
|
|
2
|
+
COMPRESSED_SIZE_OFFSET: 18,
|
|
3
|
+
FILE_NAME_LENGTH_OFFSET: 26,
|
|
4
|
+
EXTRA_FIELD_LENGTH_OFFSET: 28,
|
|
5
|
+
FILE_NAME_OFFSET: 30
|
|
6
|
+
};
|
|
7
|
+
const signature = Buffer.from([0x50, 0x4b, 0x03, 0x04]);
|
|
8
|
+
export const parseZipLocalFileHeader = async (headerOffset, buffer) => {
|
|
9
|
+
if (Buffer.from(await buffer.slice(headerOffset, headerOffset + 4)).compare(signature) !== 0) {
|
|
10
|
+
return Promise.resolve(undefined);
|
|
11
|
+
}
|
|
12
|
+
const fileNameLength = await buffer.getUint16(headerOffset + offsets.FILE_NAME_LENGTH_OFFSET);
|
|
13
|
+
const fileName = new TextDecoder().decode(await buffer.slice(headerOffset + offsets.FILE_NAME_OFFSET, headerOffset + offsets.FILE_NAME_OFFSET + fileNameLength));
|
|
14
|
+
const extraFieldLength = await buffer.getUint16(headerOffset + offsets.EXTRA_FIELD_LENGTH_OFFSET);
|
|
15
|
+
const fileDataOffset = headerOffset + offsets.FILE_NAME_OFFSET + fileNameLength + extraFieldLength;
|
|
16
|
+
const compressedSize = await buffer.getUint32(headerOffset + offsets.COMPRESSED_SIZE_OFFSET);
|
|
17
|
+
return {
|
|
18
|
+
fileNameLength,
|
|
19
|
+
fileName,
|
|
20
|
+
extraFieldLength,
|
|
21
|
+
fileDataOffset,
|
|
22
|
+
compressedSize
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=local-file-header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-file-header.js","names":["offsets","COMPRESSED_SIZE_OFFSET","FILE_NAME_LENGTH_OFFSET","EXTRA_FIELD_LENGTH_OFFSET","FILE_NAME_OFFSET","signature","Buffer","from","parseZipLocalFileHeader","headerOffset","buffer","slice","compare","Promise","resolve","undefined","fileNameLength","getUint16","fileName","TextDecoder","decode","extraFieldLength","fileDataOffset","compressedSize","getUint32"],"sources":["../../../../../src/lib/parsers/parse-zip/local-file-header.ts"],"sourcesContent":["import {FileProvider} from './file-provider';\n\n/**\n * zip local file header info\n * according to https://en.wikipedia.org/wiki/ZIP_(file_format)\n */\nexport type ZipLocalFileHeader = {\n /** File name length */\n fileNameLength: number;\n /** File name */\n fileName: string;\n /** Extra field length */\n extraFieldLength: number;\n /** Offset of the file data */\n fileDataOffset: number;\n /** Compressed size */\n compressedSize: number;\n};\n\nconst offsets = {\n COMPRESSED_SIZE_OFFSET: 18,\n FILE_NAME_LENGTH_OFFSET: 26,\n EXTRA_FIELD_LENGTH_OFFSET: 28,\n FILE_NAME_OFFSET: 30\n};\n\nconst signature = Buffer.from([0x50, 0x4b, 0x03, 0x04]);\n\n/**\n * Parses local file header of zip file\n * @param headerOffset - offset in the archive where header starts\n * @param buffer - buffer containing whole array\n * @returns Info from the header\n */\nexport const parseZipLocalFileHeader = async (\n headerOffset: number,\n buffer: FileProvider\n): Promise<ZipLocalFileHeader | undefined> => {\n if (Buffer.from(await buffer.slice(headerOffset, headerOffset + 4)).compare(signature) !== 0) {\n return Promise.resolve(undefined);\n }\n\n const fileNameLength = await buffer.getUint16(headerOffset + offsets.FILE_NAME_LENGTH_OFFSET);\n\n const fileName = new TextDecoder().decode(\n await buffer.slice(\n headerOffset + offsets.FILE_NAME_OFFSET,\n headerOffset + offsets.FILE_NAME_OFFSET + fileNameLength\n )\n );\n const extraFieldLength = await buffer.getUint16(headerOffset + offsets.EXTRA_FIELD_LENGTH_OFFSET);\n\n const fileDataOffset =\n headerOffset + offsets.FILE_NAME_OFFSET + fileNameLength + extraFieldLength;\n\n const compressedSize = await buffer.getUint32(headerOffset + offsets.COMPRESSED_SIZE_OFFSET);\n\n return {\n fileNameLength,\n fileName,\n extraFieldLength,\n fileDataOffset,\n compressedSize\n };\n};\n"],"mappings":"AAmBA,MAAMA,OAAO,GAAG;EACdC,sBAAsB,EAAE,EAAE;EAC1BC,uBAAuB,EAAE,EAAE;EAC3BC,yBAAyB,EAAE,EAAE;EAC7BC,gBAAgB,EAAE;AACpB,CAAC;AAED,MAAMC,SAAS,GAAGC,MAAM,CAACC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAQvD,OAAO,MAAMC,uBAAuB,GAAG,MAAAA,CACrCC,YAAoB,EACpBC,MAAoB,KACwB;EAC5C,IAAIJ,MAAM,CAACC,IAAI,CAAC,MAAMG,MAAM,CAACC,KAAK,CAACF,YAAY,EAAEA,YAAY,GAAG,CAAC,CAAC,CAAC,CAACG,OAAO,CAACP,SAAS,CAAC,KAAK,CAAC,EAAE;IAC5F,OAAOQ,OAAO,CAACC,OAAO,CAACC,SAAS,CAAC;EACnC;EAEA,MAAMC,cAAc,GAAG,MAAMN,MAAM,CAACO,SAAS,CAACR,YAAY,GAAGT,OAAO,CAACE,uBAAuB,CAAC;EAE7F,MAAMgB,QAAQ,GAAG,IAAIC,WAAW,CAAC,CAAC,CAACC,MAAM,CACvC,MAAMV,MAAM,CAACC,KAAK,CAChBF,YAAY,GAAGT,OAAO,CAACI,gBAAgB,EACvCK,YAAY,GAAGT,OAAO,CAACI,gBAAgB,GAAGY,cAC5C,CACF,CAAC;EACD,MAAMK,gBAAgB,GAAG,MAAMX,MAAM,CAACO,SAAS,CAACR,YAAY,GAAGT,OAAO,CAACG,yBAAyB,CAAC;EAEjG,MAAMmB,cAAc,GAClBb,YAAY,GAAGT,OAAO,CAACI,gBAAgB,GAAGY,cAAc,GAAGK,gBAAgB;EAE7E,MAAME,cAAc,GAAG,MAAMb,MAAM,CAACc,SAAS,CAACf,YAAY,GAAGT,OAAO,CAACC,sBAAsB,CAAC;EAE5F,OAAO;IACLe,cAAc;IACdE,QAAQ;IACRG,gBAAgB;IAChBC,cAAc;IACdC;EACF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BoundingSphere } from '@math.gl/culling';
|
|
2
|
+
import { Ellipsoid } from '@math.gl/geospatial';
|
|
3
|
+
export function convertI3SObbToMbs(obb) {
|
|
4
|
+
const halfSize = obb.halfSize;
|
|
5
|
+
const centerCartesian = Ellipsoid.WGS84.cartographicToCartesian(obb.center);
|
|
6
|
+
const sphere = new BoundingSphere().fromCornerPoints([centerCartesian[0] - halfSize[0], centerCartesian[1] - halfSize[1], centerCartesian[2] - halfSize[2]], [centerCartesian[0] + halfSize[0], centerCartesian[1] + halfSize[1], centerCartesian[2] + halfSize[2]]);
|
|
7
|
+
return [...obb.center, sphere.radius];
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=convert-i3s-obb-to-mbs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-i3s-obb-to-mbs.js","names":["BoundingSphere","Ellipsoid","convertI3SObbToMbs","obb","halfSize","centerCartesian","WGS84","cartographicToCartesian","center","sphere","fromCornerPoints","radius"],"sources":["../../../../src/lib/utils/convert-i3s-obb-to-mbs.ts"],"sourcesContent":["import {BoundingSphere} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\n\nexport function convertI3SObbToMbs(obb) {\n const halfSize = obb.halfSize;\n const centerCartesian = Ellipsoid.WGS84.cartographicToCartesian(obb.center);\n const sphere = new BoundingSphere().fromCornerPoints(\n [\n centerCartesian[0] - halfSize[0],\n centerCartesian[1] - halfSize[1],\n centerCartesian[2] - halfSize[2]\n ],\n [\n centerCartesian[0] + halfSize[0],\n centerCartesian[1] + halfSize[1],\n centerCartesian[2] + halfSize[2]\n ]\n );\n return [...obb.center, sphere.radius];\n}\n"],"mappings":"AAAA,SAAQA,cAAc,QAAO,kBAAkB;AAC/C,SAAQC,SAAS,QAAO,qBAAqB;AAE7C,OAAO,SAASC,kBAAkBA,CAACC,GAAG,EAAE;EACtC,MAAMC,QAAQ,GAAGD,GAAG,CAACC,QAAQ;EAC7B,MAAMC,eAAe,GAAGJ,SAAS,CAACK,KAAK,CAACC,uBAAuB,CAACJ,GAAG,CAACK,MAAM,CAAC;EAC3E,MAAMC,MAAM,GAAG,IAAIT,cAAc,CAAC,CAAC,CAACU,gBAAgB,CAClD,CACEL,eAAe,CAAC,CAAC,CAAC,GAAGD,QAAQ,CAAC,CAAC,CAAC,EAChCC,eAAe,CAAC,CAAC,CAAC,GAAGD,QAAQ,CAAC,CAAC,CAAC,EAChCC,eAAe,CAAC,CAAC,CAAC,GAAGD,QAAQ,CAAC,CAAC,CAAC,CACjC,EACD,CACEC,eAAe,CAAC,CAAC,CAAC,GAAGD,QAAQ,CAAC,CAAC,CAAC,EAChCC,eAAe,CAAC,CAAC,CAAC,GAAGD,QAAQ,CAAC,CAAC,CAAC,EAChCC,eAAe,CAAC,CAAC,CAAC,GAAGD,QAAQ,CAAC,CAAC,CAAC,CAEpC,CAAC;EACD,OAAO,CAAC,GAAGD,GAAG,CAACK,MAAM,EAAEC,MAAM,CAACE,MAAM,CAAC;AACvC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { load } from '@loaders.gl/core';
|
|
2
|
+
import { getAttributeValueType, I3SAttributeLoader } from '../../i3s-attribute-loader';
|
|
3
|
+
import { getUrlWithToken } from './url-utils';
|
|
4
|
+
export async function customizeColors(colors, featureIds, tileOptions, tilesetOptions, options) {
|
|
5
|
+
var _options$i3s;
|
|
6
|
+
if (!(options !== null && options !== void 0 && (_options$i3s = options.i3s) !== null && _options$i3s !== void 0 && _options$i3s.colorsByAttribute)) {
|
|
7
|
+
return colors;
|
|
8
|
+
}
|
|
9
|
+
const colorizeAttributeField = tilesetOptions.fields.find(_ref => {
|
|
10
|
+
var _options$i3s2, _options$i3s2$colorsB;
|
|
11
|
+
let {
|
|
12
|
+
name
|
|
13
|
+
} = _ref;
|
|
14
|
+
return name === (options === null || options === void 0 ? void 0 : (_options$i3s2 = options.i3s) === null || _options$i3s2 === void 0 ? void 0 : (_options$i3s2$colorsB = _options$i3s2.colorsByAttribute) === null || _options$i3s2$colorsB === void 0 ? void 0 : _options$i3s2$colorsB.attributeName);
|
|
15
|
+
});
|
|
16
|
+
if (!colorizeAttributeField || !['esriFieldTypeDouble', 'esriFieldTypeInteger', 'esriFieldTypeSmallInteger'].includes(colorizeAttributeField.type)) {
|
|
17
|
+
return colors;
|
|
18
|
+
}
|
|
19
|
+
const colorizeAttributeData = await loadFeatureAttributeData(colorizeAttributeField.name, tileOptions, tilesetOptions, options);
|
|
20
|
+
if (!colorizeAttributeData) {
|
|
21
|
+
return colors;
|
|
22
|
+
}
|
|
23
|
+
const objectIdField = tilesetOptions.fields.find(_ref2 => {
|
|
24
|
+
let {
|
|
25
|
+
type
|
|
26
|
+
} = _ref2;
|
|
27
|
+
return type === 'esriFieldTypeOID';
|
|
28
|
+
});
|
|
29
|
+
if (!objectIdField) {
|
|
30
|
+
return colors;
|
|
31
|
+
}
|
|
32
|
+
const objectIdAttributeData = await loadFeatureAttributeData(objectIdField.name, tileOptions, tilesetOptions, options);
|
|
33
|
+
if (!objectIdAttributeData) {
|
|
34
|
+
return colors;
|
|
35
|
+
}
|
|
36
|
+
const attributeValuesMap = {};
|
|
37
|
+
for (let i = 0; i < objectIdAttributeData[objectIdField.name].length; i++) {
|
|
38
|
+
attributeValuesMap[objectIdAttributeData[objectIdField.name][i]] = calculateColorForAttribute(colorizeAttributeData[colorizeAttributeField.name][i], options);
|
|
39
|
+
}
|
|
40
|
+
for (let i = 0; i < featureIds.value.length; i++) {
|
|
41
|
+
const color = attributeValuesMap[featureIds.value[i]];
|
|
42
|
+
if (!color) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (options.i3s.colorsByAttribute.mode === 'multiply') {
|
|
46
|
+
color.forEach((colorItem, index) => {
|
|
47
|
+
colors.value[i * 4 + index] = colors.value[i * 4 + index] * colorItem / 255;
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
colors.value.set(color, i * 4);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return colors;
|
|
54
|
+
}
|
|
55
|
+
function calculateColorForAttribute(attributeValue, options) {
|
|
56
|
+
var _options$i3s3;
|
|
57
|
+
if (!(options !== null && options !== void 0 && (_options$i3s3 = options.i3s) !== null && _options$i3s3 !== void 0 && _options$i3s3.colorsByAttribute)) {
|
|
58
|
+
return [255, 255, 255, 255];
|
|
59
|
+
}
|
|
60
|
+
const {
|
|
61
|
+
minValue,
|
|
62
|
+
maxValue,
|
|
63
|
+
minColor,
|
|
64
|
+
maxColor
|
|
65
|
+
} = options.i3s.colorsByAttribute;
|
|
66
|
+
const rate = (attributeValue - minValue) / (maxValue - minValue);
|
|
67
|
+
const color = [255, 255, 255, 255];
|
|
68
|
+
for (let i = 0; i < minColor.length; i++) {
|
|
69
|
+
color[i] = Math.round((maxColor[i] - minColor[i]) * rate + minColor[i]);
|
|
70
|
+
}
|
|
71
|
+
return color;
|
|
72
|
+
}
|
|
73
|
+
async function loadFeatureAttributeData(attributeName, _ref3, _ref4, options) {
|
|
74
|
+
var _options$i3s4;
|
|
75
|
+
let {
|
|
76
|
+
attributeUrls
|
|
77
|
+
} = _ref3;
|
|
78
|
+
let {
|
|
79
|
+
attributeStorageInfo
|
|
80
|
+
} = _ref4;
|
|
81
|
+
const attributeIndex = attributeStorageInfo.findIndex(_ref5 => {
|
|
82
|
+
let {
|
|
83
|
+
name
|
|
84
|
+
} = _ref5;
|
|
85
|
+
return attributeName === name;
|
|
86
|
+
});
|
|
87
|
+
if (attributeIndex === -1) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const objectIdAttributeUrl = getUrlWithToken(attributeUrls[attributeIndex], options === null || options === void 0 ? void 0 : (_options$i3s4 = options.i3s) === null || _options$i3s4 === void 0 ? void 0 : _options$i3s4.token);
|
|
91
|
+
const attributeType = getAttributeValueType(attributeStorageInfo[attributeIndex]);
|
|
92
|
+
const objectIdAttributeData = await load(objectIdAttributeUrl, I3SAttributeLoader, {
|
|
93
|
+
attributeName,
|
|
94
|
+
attributeType
|
|
95
|
+
});
|
|
96
|
+
return objectIdAttributeData;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=customize-сolors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customize-сolors.js","names":["load","getAttributeValueType","I3SAttributeLoader","getUrlWithToken","customizeColors","colors","featureIds","tileOptions","tilesetOptions","options","_options$i3s","i3s","colorsByAttribute","colorizeAttributeField","fields","find","_ref","_options$i3s2","_options$i3s2$colorsB","name","attributeName","includes","type","colorizeAttributeData","loadFeatureAttributeData","objectIdField","_ref2","objectIdAttributeData","attributeValuesMap","i","length","calculateColorForAttribute","value","color","mode","forEach","colorItem","index","set","attributeValue","_options$i3s3","minValue","maxValue","minColor","maxColor","rate","Math","round","_ref3","_ref4","_options$i3s4","attributeUrls","attributeStorageInfo","attributeIndex","findIndex","_ref5","objectIdAttributeUrl","token","attributeType"],"sources":["../../../../src/lib/utils/customize-сolors.ts"],"sourcesContent":["import type {MeshAttribute} from '@loaders.gl/schema';\nimport type {COLOR, I3STileOptions, I3STilesetOptions} from '../../types';\n\nimport {load} from '@loaders.gl/core';\nimport {getAttributeValueType, I3SAttributeLoader} from '../../i3s-attribute-loader';\nimport {I3SLoaderOptions} from '../../i3s-loader';\nimport {getUrlWithToken} from './url-utils';\n\n/**\n * Modify vertex colors array to visualize 3D objects in a attribute driven way\n * @param colors - vertex colors attribute\n * @param featureIds - feature Ids attribute\n * @param tileOptions - tile - related options\n * @param tilesetOptions - tileset-related options\n * @param options - loader options\n * @returns midified colors attribute\n */\nexport async function customizeColors(\n colors: MeshAttribute,\n featureIds: MeshAttribute,\n tileOptions: I3STileOptions,\n tilesetOptions: I3STilesetOptions,\n options?: I3SLoaderOptions\n): Promise<MeshAttribute> {\n if (!options?.i3s?.colorsByAttribute) {\n return colors;\n }\n\n const colorizeAttributeField = tilesetOptions.fields.find(\n ({name}) => name === options?.i3s?.colorsByAttribute?.attributeName\n );\n if (\n !colorizeAttributeField ||\n !['esriFieldTypeDouble', 'esriFieldTypeInteger', 'esriFieldTypeSmallInteger'].includes(\n colorizeAttributeField.type\n )\n ) {\n return colors;\n }\n\n const colorizeAttributeData = await loadFeatureAttributeData(\n colorizeAttributeField.name,\n tileOptions,\n tilesetOptions,\n options\n );\n if (!colorizeAttributeData) {\n return colors;\n }\n\n const objectIdField = tilesetOptions.fields.find(({type}) => type === 'esriFieldTypeOID');\n if (!objectIdField) {\n return colors;\n }\n\n const objectIdAttributeData = await loadFeatureAttributeData(\n objectIdField.name,\n tileOptions,\n tilesetOptions,\n options\n );\n if (!objectIdAttributeData) {\n return colors;\n }\n\n const attributeValuesMap: {[key: number]: COLOR} = {};\n // @ts-expect-error\n for (let i = 0; i < objectIdAttributeData[objectIdField.name].length; i++) {\n // @ts-expect-error\n attributeValuesMap[objectIdAttributeData[objectIdField.name][i]] = calculateColorForAttribute(\n // @ts-expect-error\n colorizeAttributeData[colorizeAttributeField.name][i] as number,\n options\n );\n }\n\n for (let i = 0; i < featureIds.value.length; i++) {\n const color = attributeValuesMap[featureIds.value[i]];\n if (!color) {\n continue; // eslint-disable-line no-continue\n }\n\n /* eslint max-statements: [\"error\", 30] */\n /* eslint complexity: [\"error\", 12] */\n if (options.i3s.colorsByAttribute.mode === 'multiply') {\n // multiplying original mesh and calculated for attribute rgba colors in range 0-255\n color.forEach((colorItem, index) => {\n colors.value[i * 4 + index] = (colors.value[i * 4 + index] * colorItem) / 255;\n });\n } else {\n colors.value.set(color, i * 4);\n }\n }\n\n return colors;\n}\n\n/**\n * Calculate rgba color from the attribute value\n * @param attributeValue - value of the attribute\n * @param options - loader options\n * @returns - color array for a specific attribute value\n */\nfunction calculateColorForAttribute(attributeValue: number, options?: I3SLoaderOptions): COLOR {\n if (!options?.i3s?.colorsByAttribute) {\n return [255, 255, 255, 255];\n }\n const {minValue, maxValue, minColor, maxColor} = options.i3s.colorsByAttribute;\n const rate = (attributeValue - minValue) / (maxValue - minValue);\n const color: COLOR = [255, 255, 255, 255];\n for (let i = 0; i < minColor.length; i++) {\n color[i] = Math.round((maxColor[i] - minColor[i]) * rate + minColor[i]);\n }\n return color;\n}\n\n/**\n * Load feature attribute data from the ArcGIS rest service\n * @param attributeName - attribute name\n * @param tileOptions - tile-related options\n * @param tilesetOptions - tileset-related options\n * @param options - loader options\n * @returns - Array-like list of the attribute values\n */\nasync function loadFeatureAttributeData(\n attributeName: string,\n {attributeUrls}: I3STileOptions,\n {attributeStorageInfo}: I3STilesetOptions,\n options?: I3SLoaderOptions\n): Promise<{[key: string]: string[] | Uint32Array | Uint16Array | Float64Array | null} | null> {\n const attributeIndex = attributeStorageInfo.findIndex(({name}) => attributeName === name);\n if (attributeIndex === -1) {\n return null;\n }\n const objectIdAttributeUrl = getUrlWithToken(attributeUrls[attributeIndex], options?.i3s?.token);\n const attributeType = getAttributeValueType(attributeStorageInfo[attributeIndex]);\n const objectIdAttributeData = await load(objectIdAttributeUrl, I3SAttributeLoader, {\n attributeName,\n attributeType\n });\n\n // @ts-expect-error TODO action engine\n return objectIdAttributeData;\n}\n"],"mappings":"AAGA,SAAQA,IAAI,QAAO,kBAAkB;AACrC,SAAQC,qBAAqB,EAAEC,kBAAkB,QAAO,4BAA4B;AAEpF,SAAQC,eAAe,QAAO,aAAa;AAW3C,OAAO,eAAeC,eAAeA,CACnCC,MAAqB,EACrBC,UAAyB,EACzBC,WAA2B,EAC3BC,cAAiC,EACjCC,OAA0B,EACF;EAAA,IAAAC,YAAA;EACxB,IAAI,EAACD,OAAO,aA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yC,aAAA,GAAPzC,OAAO,CAAEE,GAAG,cAAAuC,aAAA,uBAAZA,aAAA,CAAcO,KAAK,CAAC;EAChG,MAAMC,aAAa,GAAGzD,qBAAqB,CAACmD,oBAAoB,CAACC,cAAc,CAAC,CAAC;EACjF,MAAM1B,qBAAqB,GAAG,MAAM3B,IAAI,CAACwD,oBAAoB,EAAEtD,kBAAkB,EAAE;IACjFkB,aAAa;IACbsC;EACF,CAAC,CAAC;EAGF,OAAO/B,qBAAqB;AAC9B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function getUrlWithToken(url) {
|
|
2
|
+
let token = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
3
|
+
return token ? "".concat(url, "?token=").concat(token) : url;
|
|
4
|
+
}
|
|
5
|
+
export function generateTileAttributeUrls(url, tile) {
|
|
6
|
+
const {
|
|
7
|
+
attributeData = []
|
|
8
|
+
} = tile;
|
|
9
|
+
const attributeUrls = [];
|
|
10
|
+
for (let index = 0; index < attributeData.length; index++) {
|
|
11
|
+
const attributeUrl = attributeData[index].href.replace('./', '');
|
|
12
|
+
attributeUrls.push("".concat(url, "/").concat(attributeUrl));
|
|
13
|
+
}
|
|
14
|
+
return attributeUrls;
|
|
15
|
+
}
|
|
16
|
+
export function generateTilesetAttributeUrls(tileset, resource) {
|
|
17
|
+
const attributeUrls = [];
|
|
18
|
+
const {
|
|
19
|
+
attributeStorageInfo,
|
|
20
|
+
url
|
|
21
|
+
} = tileset;
|
|
22
|
+
for (let index = 0; index < attributeStorageInfo.length; index++) {
|
|
23
|
+
const fileName = attributeStorageInfo[index].key;
|
|
24
|
+
attributeUrls.push("".concat(url, "/nodes/").concat(resource, "/attributes/").concat(fileName, "/0"));
|
|
25
|
+
}
|
|
26
|
+
return attributeUrls;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=url-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-utils.js","names":["getUrlWithToken","url","token","arguments","length","undefined","concat","generateTileAttributeUrls","tile","attributeData","attributeUrls","index","attributeUrl","href","replace","push","generateTilesetAttributeUrls","tileset","resource","attributeStorageInfo","fileName","key"],"sources":["../../../../src/lib/utils/url-utils.ts"],"sourcesContent":["import {Node3DIndexDocument} from '../../types';\n\n/**\n * Generates url with token if it is exists.\n * @param url\n * @param token\n * @returns\n */\nexport function getUrlWithToken(url: string, token: string | null = null): string {\n return token ? `${url}?token=${token}` : url;\n}\n\n/**\n * Generates attribute urls for tile.\n * @param tile\n * @returns list of attribute urls\n */\nexport function generateTileAttributeUrls(url: string, tile: Node3DIndexDocument): string[] {\n const {attributeData = []} = tile;\n const attributeUrls: string[] = [];\n\n for (let index = 0; index < attributeData.length; index++) {\n const attributeUrl = attributeData[index].href.replace('./', '');\n attributeUrls.push(`${url}/${attributeUrl}`);\n }\n\n return attributeUrls;\n}\n\n/**\n * Generates attribute urls for tileset based on tileset and resource\n * @param {Object} tileset\n * @param {number} resource\n * @returns {Array}\n */\nexport function generateTilesetAttributeUrls(tileset, resource) {\n const attributeUrls: string[] = [];\n const {attributeStorageInfo, url} = tileset;\n\n for (let index = 0; index < attributeStorageInfo.length; index++) {\n const fileName = attributeStorageInfo[index].key;\n attributeUrls.push(`${url}/nodes/${resource}/attributes/${fileName}/0`);\n }\n\n return attributeUrls;\n}\n"],"mappings":"AAQA,OAAO,SAASA,eAAeA,CAACC,GAAW,EAAuC;EAAA,IAArCC,KAAoB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;EACtE,OAAOD,KAAK,MAAAI,MAAA,CAAML,GAAG,aAAAK,MAAA,CAAUJ,KAAK,IAAKD,GAAG;AAC9C;AAOA,OAAO,SAASM,yBAAyBA,CAACN,GAAW,EAAEO,IAAyB,EAAY;EAC1F,MAAM;IAACC,aAAa,GAAG;EAAE,CAAC,GAAGD,IAAI;EACjC,MAAME,aAAuB,GAAG,EAAE;EAElC,KAAK,IAAIC,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGF,aAAa,CAACL,MAAM,EAAEO,KAAK,EAAE,EAAE;IACzD,MAAMC,YAAY,GAAGH,aAAa,CAACE,KAAK,CAAC,CAACE,IAAI,CAACC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;IAChEJ,aAAa,CAACK,IAAI,IAAAT,MAAA,CAAIL,GAAG,OAAAK,MAAA,CAAIM,YAAY,CAAE,CAAC;EAC9C;EAEA,OAAOF,aAAa;AACtB;AAQA,OAAO,SAASM,4BAA4BA,CAACC,OAAO,EAAEC,QAAQ,EAAE;EAC9D,MAAMR,aAAuB,GAAG,EAAE;EAClC,MAAM;IAACS,oBAAoB;IAAElB;EAAG,CAAC,GAAGgB,OAAO;EAE3C,KAAK,IAAIN,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGQ,oBAAoB,CAACf,MAAM,EAAEO,KAAK,EAAE,EAAE;IAChE,MAAMS,QAAQ,GAAGD,oBAAoB,CAACR,KAAK,CAAC,CAACU,GAAG;IAChDX,aAAa,CAACK,IAAI,IAAAT,MAAA,CAAIL,GAAG,aAAAK,MAAA,CAAUY,QAAQ,kBAAAZ,MAAA,CAAec,QAAQ,OAAI,CAAC;EACzE;EAEA,OAAOV,aAAa;AACtB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export let DATA_TYPE = function (DATA_TYPE) {
|
|
2
|
+
DATA_TYPE["UInt8"] = "UInt8";
|
|
3
|
+
DATA_TYPE["UInt16"] = "UInt16";
|
|
4
|
+
DATA_TYPE["UInt32"] = "UInt32";
|
|
5
|
+
DATA_TYPE["UInt64"] = "UInt64";
|
|
6
|
+
DATA_TYPE["Int16"] = "Int16";
|
|
7
|
+
DATA_TYPE["Int32"] = "Int32";
|
|
8
|
+
DATA_TYPE["Int64"] = "Int64";
|
|
9
|
+
DATA_TYPE["Float32"] = "Float32";
|
|
10
|
+
DATA_TYPE["Float64"] = "Float64";
|
|
11
|
+
return DATA_TYPE;
|
|
12
|
+
}({});
|
|
13
|
+
export let HeaderAttributeProperty = function (HeaderAttributeProperty) {
|
|
14
|
+
HeaderAttributeProperty["vertexCount"] = "vertexCount";
|
|
15
|
+
HeaderAttributeProperty["featureCount"] = "featureCount";
|
|
16
|
+
return HeaderAttributeProperty;
|
|
17
|
+
}({});
|
|
18
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":["DATA_TYPE","HeaderAttributeProperty"],"sources":["../../src/types.ts"],"sourcesContent":["import type {Matrix4, Quaternion, Vector3} from '@math.gl/core';\nimport type {TypedArray, MeshAttribute, TextureLevel} from '@loaders.gl/schema';\nimport {Tile3D, Tileset3D} from '@loaders.gl/tiles';\n\nexport enum DATA_TYPE {\n UInt8 = 'UInt8',\n UInt16 = 'UInt16',\n UInt32 = 'UInt32',\n UInt64 = 'UInt64',\n Int16 = 'Int16',\n Int32 = 'Int32',\n Int64 = 'Int64',\n Float32 = 'Float32',\n Float64 = 'Float64'\n}\n\nexport type COLOR = [number, number, number, number];\n\n/**\n * spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/3DSceneLayer.cmn.md\n */\n// TODO Replace \"[key: string]: any\" with actual defenition\nexport interface I3STilesetHeader extends SceneLayer3D {\n /** Not in spec, but is necessary for woking */\n url?: string;\n [key: string]: any;\n}\n/** https://github.com/Esri/i3s-spec/blob/master/docs/1.8/nodePage.cmn.md */\nexport type NodePage = {\n /** Array of nodes. */\n nodes: NodeInPage[];\n};\n/**\n * Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/mesh.cmn.md\n */\ntype NodeMesh = {\n /**\n * The material definition.\n */\n material: MeshMaterial;\n /** The geometry definition. */\n geometry: MeshGeometry;\n /** The attribute set definition. */\n attribute: meshAttribute;\n};\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/meshMaterial.cmn.md */\nexport type MeshMaterial = {\n /** The index in layer.materialDefinitions array. */\n definition: number;\n /** Resource id for the material textures. i.e: layers/0/nodes/{material.resource}/textures/{tex_name}. Is required if material declares any textures. */\n resource?: number;\n /** Estimated number of texel for the highest resolution base color texture. */\n texelCountHint?: number;\n};\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/meshGeometry.cmn.md */\nexport type MeshGeometry = {\n /** The index in layer.geometryDefinitions array */\n definition: number;\n /** The resource locator to be used to query geometry resources: layers/0/nodes/{this.resource}/geometries/{layer.geometryDefinitions[this.definition].geometryBuffers[0 or 1]}. */\n resource: number;\n /** Number of vertices in the geometry buffer of this mesh for the umcompressed mesh buffer. Please note that Draco compressed meshes may have less vertices due to de-duplication (actual number of vertices is part of the Draco binary blob). Default=0 */\n vertexCount?: number;\n /** Number of features for this mesh. Default=0. (Must omit or set to 0 if mesh doesn't use features.) */\n featureCount?: number;\n};\n/** https://github.com/Esri/i3s-spec/blob/master/docs/1.8/meshAttribute.cmn.md */\ntype meshAttribute = {\n /** The resource identifier to be used to locate attribute resources of this mesh. i.e. layers/0/nodes/<resource id>/attributes/... */\n resource: number;\n};\n\nexport type I3STextureFormat = 'jpg' | 'png' | 'ktx-etc2' | 'dds' | 'ktx2';\n\n// TODO Replace \"[key: string]: any\" with actual defenition\nexport type I3STileHeader = {\n isDracoGeometry: boolean;\n textureUrl?: string;\n url?: string;\n textureFormat?: I3STextureFormat;\n textureLoaderOptions?: any;\n materialDefinition?: I3SMaterialDefinition;\n mbs: Mbs;\n obb?: Obb;\n lodSelection?: LodSelection[];\n [key: string]: any;\n};\n\nexport type I3SParseOptions = {\n /** ArcGIS access token */\n token?: string;\n /** Is 3DSceneLayer json expected in response */\n isTileset?: string;\n /** Is 3DNodeIndexDocument json expected in response */\n isTileHeader?: string;\n /** Tile3D instance. This property used only to load tile content */\n /** Tile-specific options */\n _tileOptions?: I3STileOptions;\n /** Tileset-specific options */\n _tilesetOptions?: I3STilesetOptions;\n /** Load Draco Compressed geometry if available */\n useDracoGeometry?: boolean;\n /** Load compressed textures if available */\n useCompressedTextures?: boolean;\n /** Set false if don't need to parse textures */\n decodeTextures?: boolean;\n /** deck.gl compatible coordinate system.\n * https://github.com/visgl/deck.gl/blob/master/docs/developer-guide/coordinate-systems.md\n * Supported coordinate systems: METER_OFFSETS, LNGLAT_OFFSETS\n */\n coordinateSystem?: number;\n colorsByAttribute?: {\n attributeName: string;\n minValue: number;\n maxValue: number;\n minColor: COLOR;\n maxColor: COLOR;\n mode: string;\n };\n\n /** @deprecated */\n tile?: Tile3D | I3STileOptions;\n /** Tileset3D instance. This property used only to load tile content */\n /** @deprecated */\n tileset?: Tileset3D | I3STilesetOptions;\n};\n\nexport type I3STileOptions = {\n isDracoGeometry: boolean;\n textureUrl?: string;\n textureFormat?: I3STextureFormat;\n textureLoaderOptions?: any;\n materialDefinition?: I3SMaterialDefinition;\n attributeUrls: string[];\n mbs: Mbs;\n};\n\nexport type I3STilesetOptions = {\n store: Store;\n attributeStorageInfo: AttributeStorageInfo[];\n fields: Field[];\n};\n\n// TODO Replace \"[key: string]: any\" with actual defenition\nexport type I3STileContent = {\n attributes: I3SMeshAttributes;\n indices: TypedArray | null;\n featureIds: number[] | TypedArray;\n vertexCount: number;\n modelMatrix: Matrix4;\n coordinateSystem: number;\n byteLength: number;\n texture: TileContentTexture;\n [key: string]: any;\n};\n\nexport type TileContentTexture =\n | ArrayBuffer\n | {\n compressed: boolean;\n mipmaps: boolean;\n width: number;\n height: number;\n data: TextureLevel[];\n }\n | null;\n\nexport type BoundingVolumes = {\n mbs: Mbs;\n obb: Obb;\n};\n\nexport type Obb = {\n center: number[] | Vector3;\n halfSize: number[] | Vector3;\n quaternion: number[] | Quaternion;\n};\n\nexport type Mbs = [number, number, number, number];\n\n/** SceneLayer3D based on I3S specification - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/3DSceneLayer.cmn.md */\nexport type SceneLayer3D = {\n /** Unique numeric ID of the layer. */\n id: number;\n /** The relative URL to the 3DSceneLayerResource. Only present as part of the SceneServiceInfo resource. */\n href?: string;\n /** The user-visible layer type */\n layerType: '3DObject' | 'IntegratedMesh';\n /** The spatialReference of the layer including the vertical coordinate reference system (CRS). Well Known Text (WKT) for CRS is included to support custom CRS. */\n spatialReference?: SpatialReference;\n /** Enables consuming clients to quickly determine whether this layer is compatible (with respect to its horizontal and vertical coordinate system) with existing content. */\n heightModelInfo?: HeightModelInfo;\n /** The ID of the last update session in which any resource belonging to this layer has been updated. */\n version: string;\n /** The name of this layer. */\n name?: string;\n /** The time of the last update. */\n serviceUpdateTimeStamp?: {lastUpdate: number};\n /** The display alias to be used for this layer. */\n alias?: string;\n /** Description string for this layer. */\n description?: string;\n /** Copyright and usage information for the data in this layer. */\n copyrightText?: string;\n /** Capabilities supported by this layer. */\n capabilities: string[];\n /** ZFactor to define conversion factor for elevation unit. */\n ZFactor?: number;\n /** Indicates if any styling information represented as drawingInfo is captured as part of the binary mesh representation. */\n cachedDrawingInfo?: CachedDrawingInfo;\n /** An object containing drawing information. */\n drawingInfo?: DrawingInfo;\n /** An object containing elevation drawing information. If absent, any content of the scene layer is drawn at its z coordinate. */\n elevationInfo?: ElevationInfo;\n /** PopupInfo of the scene layer. */\n popupInfo?: PopupInfo;\n /** Indicates if client application will show the popup information. Default is FALSE. */\n disablePopup: boolean;\n /**\n * The store object describes the exact physical storage of a layer and\n * enables the client to detect when multiple layers are served from\n * the same store.\n */\n store: Store;\n /** A collection of objects that describe each attribute field regarding its field name, datatype, and a user friendly name {name,type,alias}. */\n fields?: Field[];\n /** Provides the schema and layout used for storing attribute content in binary format in I3S. */\n attributeStorageInfo?: AttributeStorageInfo[];\n /** Contains the statistical information for a layer. */\n statisticsInfo?: StatisticsInfo[];\n /** The paged-access index description. */\n nodePages?: NodePageDefinition;\n /** List of materials classes used in this layer. */\n materialDefinitions?: I3SMaterialDefinition[];\n /** Defines the set of textures that can be referenced by meshes. */\n textureSetDefinitions?: TextureSetDefinition[];\n /** Define the layouts of mesh geometry and its attributes */\n geometryDefinitions?: GeometryDefinition[];\n /** 3D extent. */\n fullExtent?: FullExtent;\n};\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/cachedDrawingInfo.cmn.md */\nexport type CachedDrawingInfo = {\n /** If true, the drawingInfo is captured as part of the binary scene layer representation. */\n color: boolean;\n};\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/drawingInfo.cmn.md */\nexport type DrawingInfo = {\n /** An object defining the symbology for the layer. See more information about supported renderer types in ArcGIS clients. */\n renderer: any;\n /** Scale symbols for the layer. */\n scaleSymbols: boolean;\n};\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/elevationInfo.cmn.md */\nexport type ElevationInfo = {\n mode: 'relativeToGround' | 'absoluteHeight' | 'onTheGround' | 'relativeToScene';\n /** Offset is always added to the result of the above logic except for onTheGround where offset is ignored. */\n offset: number;\n /** A string value indicating the unit for the values in elevationInfo */\n unit: string;\n};\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/statisticsInfo.cmn.md */\nexport type StatisticsInfo = {\n /** Key indicating the resource of the statistics. */\n key: string;\n /** Name of the field of the statistical information. */\n name: string;\n /** The URL to the statistics information. */\n href: string;\n};\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/nodePageDefinition.cmn.md */\nexport type NodePageDefinition = {\n /** Number of nodes per page for this layer. Must be a power-of-two less than 4096 */\n nodesPerPage: number;\n /** Index of the root node. Default = 0. */\n rootIndex?: number;\n /** Defines the meaning of nodes[].lodThreshold for this layer. */\n lodSelectionMetricType: 'maxScreenThresholdSQ';\n};\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/materialDefinitions.cmn.md */\nexport type I3SMaterialDefinition = {\n /** A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology. When not specified, all the default values of pbrMetallicRoughness apply. */\n pbrMetallicRoughness: I3SPbrMetallicRoughness;\n /** The normal texture map. */\n normalTexture?: I3SMaterialTexture;\n /** The occlusion texture map. */\n occlusionTexture?: I3SMaterialTexture;\n /** The emissive texture map. */\n emissiveTexture?: I3SMaterialTexture;\n /** The emissive color of the material. */\n emissiveFactor?: [number, number, number];\n /** Defines the meaning of the alpha-channel/alpha-mask. */\n alphaMode: 'opaque' | 'mask' | 'blend';\n /** The alpha cutoff value of the material. */\n alphaCutoff?: number;\n /** Specifies whether the material is double sided. */\n doubleSided?: boolean;\n /** Winding order is counterclockwise. */\n cullFace?: 'none' | 'front' | 'back';\n};\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/pbrMetallicRoughness.cmn.md */\nexport type I3SPbrMetallicRoughness = {\n /** The material's base color factor. default=[1,1,1,1] */\n baseColorFactor?: [number, number, number, number];\n /** The base color texture. */\n baseColorTexture?: I3SMaterialTexture;\n /** the metalness of the material. default=1.0 */\n metallicFactor: number;\n /** the roughness of the material. default=1.0 */\n roughnessFactor: number;\n /** the metallic-roughness texture. */\n metallicRoughnessTexture?: I3SMaterialTexture;\n};\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/materialTexture.cmn.md */\nexport type I3SMaterialTexture = {\n /** The index in layer.textureSetDefinitions. */\n textureSetDefinitionId: number;\n /** The set index of texture's TEXCOORD attribute used for texture coordinate mapping. Default is 0. Deprecated. */\n texCoord?: number;\n /** The normal texture: scalar multiplier applied to each normal vector of the normal texture. For occlusion texture,scalar multiplier controlling the amount of occlusion applied. Default=1 */\n factor?: number;\n};\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/attributeStorageInfo.cmn.md */\nexport type AttributeStorageInfo = {\n key: string;\n name: string;\n header: {property: string; valueType: string}[];\n ordering?: string[];\n attributeValues?: AttributeValue;\n attributeByteCounts?: AttributeValue;\n objectIds?: AttributeValue;\n};\n\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/field.cmn.md */\nexport type Field = {\n name: string;\n type: ESRIField;\n alias?: string;\n domain?: Domain;\n};\n\nexport type ESRIField =\n | 'esriFieldTypeDate'\n | 'esriFieldTypeSingle'\n | 'esriFieldTypeDouble'\n | 'esriFieldTypeGUID'\n | 'esriFieldTypeGlobalID'\n | 'esriFieldTypeInteger'\n | 'esriFieldTypeOID'\n | 'esriFieldTypeSmallInteger'\n | 'esriFieldTypeString';\n\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/popupInfo.cmn.md */\nexport type PopupInfo = {\n title?: string;\n description?: string;\n expressionInfos?: any[];\n fieldInfos?: FieldInfo[];\n mediaInfos?: any[];\n popupElements?: {text?: string; type?: string; fieldInfos?: FieldInfo[]}[];\n};\n\n/**\n * Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md\n */\nexport type Node3DIndexDocument = {\n id: string;\n version?: string;\n level?: number;\n mbs?: Mbs;\n obb?: Obb;\n lodSelection?: LodSelection[];\n children?: NodeReference[];\n neighbors?: NodeReference[];\n parentNode?: NodeReference;\n sharedResource?: Resource;\n featureData?: Resource[];\n geometryData?: Resource[];\n textureData?: Resource[];\n attributeData?: Resource[];\n created?: string;\n expires?: string;\n};\n\n/**\n * Minimal I3S node data is needed for loading\n */\nexport type I3SMinimalNodeData = {\n id: string;\n url?: string;\n transform?: number[];\n lodSelection?: LodSelection[];\n obb?: Obb;\n mbs?: Mbs;\n contentUrl?: string;\n textureUrl?: string;\n attributeUrls?: string[];\n materialDefinition?: I3SMaterialDefinition;\n textureFormat?: I3STextureFormat;\n textureLoaderOptions?: {[key: string]: any};\n children?: NodeReference[];\n isDracoGeometry: boolean;\n};\n\nexport type LodSelection = {\n metricType?: string;\n maxError: number;\n};\n\nexport type NodeReference = {\n id: string;\n version?: string;\n mbs?: Mbs;\n obb?: Obb;\n href?: string;\n};\n\nexport type Resource = {\n href: string;\n layerContent?: string[];\n featureRange?: number[];\n multiTextureBundle?: string;\n vertexElements?: number[];\n faceElements?: number[];\n nodePath?: string;\n};\n\nexport type MaxScreenThresholdSQ = {\n maxError: number;\n};\n\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/node.cmn.md */\nexport type NodeInPage = {\n /**\n * The index in the node array. May be different than material, geometry and attribute resource id. See mesh for more information.\n */\n index: number;\n /**\n * The index of the parent node in the node array.\n */\n parentIndex?: number;\n /**\n * When to switch LoD. See https://github.com/Esri/i3s-spec/blob/master/docs/1.8/nodePageDefinition.cmn.md for more information.\n */\n lodThreshold?: number;\n /**\n * Oriented bounding box for this node.\n */\n obb: Obb;\n /**\n * index of the children nodes indices.\n */\n children?: number[];\n /**\n * The mesh for this node. WARNING: only SINGLE mesh is supported at version 1.7 (i.e. length must be 0 or 1).\n */\n mesh?: NodeMesh;\n};\n\n/**\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.8/materialDefinitionInfo.cmn.md\n */\nexport type MaterialDefinitionInfo = {\n /** A name for the material as assigned in the creating application. */\n name?: string;\n /** Indicates the material type, chosen from the supported values. */\n type?: 'standard' | 'water' | 'billboard' | 'leafcard' | 'reference';\n /** The href that resolves to the shared resource bundle in which the material definition is contained. */\n $ref?: string;\n /** Parameter defined for the material.\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.8/materialParams.cmn.md\n */\n params: {\n /** Indicates transparency of this material; 0 = opaque, 1 = fully transparent. */\n transparency?: number;\n /** Indicates reflectivity of this material. */\n reflectivity?: number;\n /** Indicates shininess of this material. */\n shininess?: number;\n /** Ambient color of this material. Ambient color is the color of an object where it is in shadow.\n * This color is what the object reflects when illuminated by ambient light rather than direct light. */\n ambient?: number[];\n /** Diffuse color of this material. Diffuse color is the most instinctive meaning of the color of an object.\n * It is that essential color that the object reveals under pure white light. It is perceived as the color\n * of the object itself rather than a reflection of the light. */\n diffuse?: number[];\n /** Specular color of this material. Specular color is the color of the light of a specular reflection\n * (specular reflection is the type of reflection that is characteristic of light reflected from a shiny\n * surface). */\n specular?: number[];\n /** Rendering mode. */\n renderMode: 'textured' | 'solid' | 'untextured' | 'wireframe';\n /** TRUE if features with this material should cast shadows. */\n castShadows?: boolean;\n /** TRUE if features with this material should receive shadows */\n receiveShadows?: boolean;\n /** Indicates the material culling options {back, front, none}. */\n cullFace?: string;\n /** This flag indicates that the vertex color attribute of the geometry should be used to color the geometry\n * for rendering. If texture is present, the vertex colors are multiplied by this color.\n * e.g. pixel_color = [interpolated]vertex_color * texel_color. Default is false. */\n vertexColors?: boolean;\n /** This flag indicates that the geometry has uv region vertex attributes. These are used for adressing\n * subtextures in a texture atlas. The uv coordinates are relative to this subtexture in this case.\n * This is mostly useful for repeated textures in a texture atlas. Default is false. */\n vertexRegions?: boolean;\n /** Indicates whether Vertex Colors also contain a transparency channel. Default is false. */\n useVertexColorAlpha?: boolean;\n };\n};\n\n/** https://github.com/Esri/i3s-spec/blob/master/docs/1.8/sharedResource.cmn.md */\nexport type SharedResources = {\n /** Materials describe how a Feature or a set of Features is to be rendered. */\n materialDefinitions?: {[key: string]: MaterialDefinitionInfo};\n /** A Texture is a set of images, with some parameters specific to the texture/uv mapping to geometries. */\n textureDefinitions?: {[key: string]: TextureDefinitionInfo};\n};\n\n/** https://github.com/Esri/i3s-spec/blob/master/docs/1.8/image.cmn.md */\ntype TextureImage = {\n /** A unique ID for each image. Generated using the BuildID function. */\n id: string;\n /** width of this image, in pixels. */\n size?: number;\n /** The maximum size of a single pixel in world units.\n * This property is used by the client to pick the image to load and render. */\n pixelInWorldUnits?: number;\n /** The href to the image(s), one per encoding, in the same order as the encodings. */\n href?: string[];\n /** The byte offset of this image's encodings. There is one per encoding,\n * in the same order as the encodings, in the block in which this texture image resides. */\n byteOffset?: string[];\n /** The length in bytes of this image's encodings. There is one per encoding,\n * in the same order as the encodings. */\n length?: number[];\n};\n\nexport type Attribute = 'OBJECTID' | 'string' | 'double' | 'Int32' | string;\n\nexport type Extent = [number, number, number, number];\n\nexport type FeatureAttribute = {\n id: AttributeValue;\n faceRange: AttributeValue;\n};\n\nexport type BuildingSceneLayerTileset = {\n header: BuildingSceneLayer;\n sublayers: BuildingSceneSublayer[];\n};\n\nexport type BuildingSceneLayer = {\n id: number;\n name: string;\n version: string;\n alias?: string;\n layerType: 'Building';\n description?: string;\n copyrightText?: string;\n fullExtent: FullExtent;\n spatialReference: SpatialReference;\n heightModelInfo?: HeightModelInfo;\n sublayers: BuildingSceneSublayer[];\n filters?: Filter[];\n activeFilterID?: string;\n statisticsHRef?: string;\n};\n\nexport type BuildingSceneSublayer = {\n id: number;\n name: string;\n alias?: string;\n discipline?: 'Mechanical' | 'Architectural' | 'Piping' | 'Electrical' | 'Structural';\n modelName?: string;\n layerType: 'group' | '3DObject' | 'Point';\n visibility?: boolean;\n sublayers?: BuildingSceneSublayer[];\n isEmpty?: boolean;\n url?: string;\n};\n\ntype Filter = {\n id: string;\n name: string;\n description: string;\n isDefaultFilter?: boolean;\n isVisible?: boolean;\n filterBlocks: FilterBlock[];\n filterAuthoringInfo?: FilterAuthoringInfo;\n};\n\ntype FilterAuthoringInfo = {\n type: string;\n filterBlocks: FilterBlockAuthoringInfo[];\n};\n\ntype FilterBlockAuthoringInfo = {\n filterTypes: FilterType[];\n};\n\ntype FilterType = {\n filterType: string;\n filterValues: string[];\n};\n\ntype FilterBlock = {\n title: string;\n filterMode: FilterModeSolid | FilterModeWireFrame;\n filterExpression: string;\n};\n\ntype Edges = {\n type: string;\n color: number[];\n size: number;\n transparency: number;\n extensionLength: number;\n};\n\ntype FilterModeSolid = {\n type: 'solid';\n};\n\ntype FilterModeWireFrame = {\n type: 'wireFrame';\n edges: Edges;\n};\n\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/spatialReference.cmn.md */\nexport type SpatialReference = {\n /** The current WKID value of the vertical coordinate system. */\n latestVcsWkid: number;\n /** dentifies the current WKID value associated with the same spatial reference. */\n latestWkid: number;\n /** The WKID value of the vertical coordinate system. */\n vcsWkid: number;\n /** WKID, or Well-Known ID, of the CRS. Specify either WKID or WKT of the CRS. */\n wkid: number;\n /** WKT, or Well-Known Text, of the CRS. Specify either WKT or WKID of the CRS but not both. */\n wkt?: string;\n};\n\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/fullExtent.cmn.md */\nexport type FullExtent = {\n /** left longitude in decimal degrees */\n xmin: number;\n /** right longitude in decimal degrees */\n xmax: number;\n /** bottom latitude in decimal degrees*/\n ymin: number;\n /** top latitude in decimal degrees*/\n ymax: number;\n /** lowest elevation in meters */\n zmin: number;\n /** highest elevation in meters */\n zmax: number;\n spatialReference?: SpatialReference;\n};\n\n/**\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.8/textureDefinitionInfo.cmn.md\n */\nexport type TextureDefinitionInfo = {\n /** MIMEtype - The encoding/content type that is used by all images in this map */\n encoding?: string[];\n /** UV wrapping modes, from {none, repeat, mirror}. */\n wrap?: string[];\n /** TRUE if the Map represents a texture atlas. */\n atlas?: boolean;\n /** The name of the UV set to be used as texture coordinates. */\n uvSet?: string;\n /** Indicates channels description. */\n channels?: 'rbg' | 'rgba' | string;\n /** An image is a binary resource, containing a single raster that can be used to texture a feature or symbol. */\n images: TextureImage[];\n};\n\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/domain.cmn.md */\ntype Domain = {\n type: string;\n name: string;\n description?: string;\n fieldType?: string;\n range?: [number, number];\n codedValues?: {name: string; code: string | number}[];\n mergePolicy?: string;\n splitPolicy?: string;\n};\n/**\n * spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/store.cmn.md\n */\ntype Store = {\n id: string | number;\n profile: string;\n version: number | string;\n resourcePattern: string[];\n rootNode: string;\n extent: number[];\n indexCRS: string;\n vertexCRS: string;\n normalReferenceFrame: string;\n attributeEncoding: string;\n textureEncoding: string[];\n lodType: string;\n lodModel: string;\n defaultGeometrySchema: DefaultGeometrySchema;\n};\n/**\n * Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/defaultGeometrySchema.cmn.md\n */\ntype DefaultGeometrySchema = {\n geometryType?: 'triangles';\n topology: 'PerAttributeArray' | 'Indexed';\n header: HeaderAttribute[];\n ordering: string[];\n vertexAttributes: VertexAttribute;\n faces?: VertexAttribute;\n featureAttributeOrder: string[];\n featureAttributes: FeatureAttribute;\n // TODO Do we realy need this Property?\n attributesOrder?: string[];\n};\n/**\n * spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/headerAttribute.cmn.md\n */\nexport type HeaderAttribute = {\n property: HeaderAttributeProperty.vertexCount | HeaderAttributeProperty.featureCount | string;\n type:\n | DATA_TYPE.UInt8\n | DATA_TYPE.UInt16\n | DATA_TYPE.UInt32\n | DATA_TYPE.UInt64\n | DATA_TYPE.Int16\n | DATA_TYPE.Int32\n | DATA_TYPE.Int64\n | DATA_TYPE.Float32\n | DATA_TYPE.Float64;\n};\nexport enum HeaderAttributeProperty {\n vertexCount = 'vertexCount',\n featureCount = 'featureCount'\n}\nexport type VertexAttribute = {\n position: GeometryAttribute;\n normal: GeometryAttribute;\n uv0: GeometryAttribute;\n color: GeometryAttribute;\n region?: GeometryAttribute;\n};\nexport type GeometryAttribute = {\n byteOffset?: number;\n valueType:\n | DATA_TYPE.UInt8\n | DATA_TYPE.UInt16\n | DATA_TYPE.Int16\n | DATA_TYPE.Int32\n | DATA_TYPE.Int64\n | DATA_TYPE.Float32\n | DATA_TYPE.Float64;\n valuesPerElement: number;\n};\nexport type I3SMeshAttributes = {\n [key: string]: I3SMeshAttribute;\n};\nexport interface I3SMeshAttribute extends MeshAttribute {\n type?: number;\n metadata?: any;\n}\n/** https://github.com/Esri/i3s-spec/blob/master/docs/1.8/heightModelInfo.cmn.md */\ntype HeightModelInfo = {\n heightModel: 'gravity_related_height' | 'ellipsoidal';\n vertCRS: string;\n heightUnit:\n | 'meter'\n | 'us-foot'\n | 'foot'\n | 'clarke-foot'\n | 'clarke-yard'\n | 'clarke-link'\n | 'sears-yard'\n | 'sears-foot'\n | 'sears-chain'\n | 'benoit-1895-b-chain'\n | 'indian-yard'\n | 'indian-1937-yard'\n | 'gold-coast-foot'\n | 'sears-1922-truncated-chain'\n | 'us-inch'\n | 'us-mile'\n | 'us-yard'\n | 'millimeter'\n | 'decimeter'\n | 'centimeter'\n | 'kilometer';\n};\n\nexport type TextureSetDefinitionFormats = {name: string; format: I3STextureFormat}[];\n\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/textureSetDefinition.cmn.md */\ntype TextureSetDefinition = {\n formats: TextureSetDefinitionFormats;\n atlas?: boolean;\n};\n\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/geometryDefinition.cmn.md */\ntype GeometryDefinition = {\n topology: 'triangle' | string;\n geometryBuffers: GeometryBuffer[];\n};\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/geometryBuffer.cmn.md */\ntype GeometryBuffer = {\n offset?: number;\n position?: GeometryBufferItem;\n normal?: GeometryBufferItem;\n uv0?: GeometryBufferItem;\n color?: GeometryBufferItem;\n uvRegion?: GeometryBufferItem;\n featureId?: GeometryBufferItem;\n faceRange?: GeometryBufferItem;\n compressedAttributes?: {encoding: string; attributes: string[]};\n};\n\ntype GeometryBufferItem = {type: string; component: number; encoding?: string; binding: string};\n\ntype AttributeValue = {valueType: string; encoding?: string; valuesPerElement?: number};\n\nexport type FieldInfo = {\n fieldName: string;\n visible: boolean;\n isEditable: boolean;\n label: string;\n};\n\nexport type ArcGisWebSceneData = {\n header: ArcGisWebScene;\n layers: OperationalLayer[];\n unsupportedLayers: OperationalLayer[];\n};\n\n/**\n * ArcGis WebScene spec - https://developers.arcgis.com/web-scene-specification/objects/webscene/\n */\nexport type ArcGisWebScene = {\n /**\n * @todo add type.\n * Spec - https://developers.arcgis.com/web-scene-specification/objects/applicationProperties/\n * Configuration of application and UI elements.\n */\n applicationProperties?: any;\n /**\n * Operational layers contain business data which are used to make thematic scenes.\n */\n operationalLayers: OperationalLayer[];\n /**\n * Basemaps give the web scene a geographic context.\n */\n baseMap: BaseMap;\n /**\n * Ground defines the main surface of the web scene, based on elevation layers.\n */\n ground: Ground;\n /**\n * An object that defines the characteristics of the vertical coordinate system used by the web scene.\n */\n heightModelInfo: HeightModelInfo;\n /**\n * Root element in the web scene specifying a string value indicating the web scene version.\n * Valid values: 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19, 1.20, 1.21, 1.22, 1.23, 1.24, 1.25, 1.26, 1.27\n */\n version: string;\n /**\n * String value indicating the application which authored the webmap\n */\n authoringApp: string;\n /**\n * String value indicating the authoring App's version number.\n */\n authoringAppVersion: string;\n /**\n * A presentation consists of multiple slides, where each slide is a specific view into the web scene.\n * Spec - https://developers.arcgis.com/web-scene-specification/objects/presentation/\n * @todo Add presentation type.\n */\n presentation: ArcGisPresentation;\n /**\n * An object that provides information about the initial environment settings and viewpoint of the web scene.\n */\n initialState: InitialState;\n /**\n * An object used to specify the spatial reference of the given geometry.\n */\n spatialReference: SpatialReference;\n viewingMode: 'global' | 'local';\n /**\n * @todo add type.\n * Defines area to be clipped for display.\n */\n clippingArea?: any;\n /**\n * @todo add type.\n * Spec - https://developers.arcgis.com/web-scene-specification/objects/mapFloorInfo/\n * Contains floor-awareness information for the web scene.\n */\n mapFloorInfo?: any;\n /**\n * @todo add type.\n * Spec - https://developers.arcgis.com/web-scene-specification/objects/mapRangeInfo/\n * Map Range Information\n */\n mapRangeInfo?: any;\n /**\n * @todo add type.\n * Spec - https://developers.arcgis.com/web-scene-specification/objects/table/\n * An array of table objects.\n */\n tables?: any;\n /**\n * @todo add type.\n * Spec - https://developers.arcgis.com/web-scene-specification/objects/transportationNetwork/\n * Used to specify the transportation networks of the scene.\n */\n transportationNetworks?: any;\n /**\n * @todo add type.\n * Spec - https://developers.arcgis.com/web-scene-specification/objects/widgets/\n * The widgets object contains widgets that should be exposed to the user.\n */\n widgets?: any;\n};\n\n/**\n * Spec - https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Presentation.html\n */\ntype ArcGisPresentation = {\n slides: Slide[];\n};\n\n/**\n * A slide stores a snapshot of several pre-set properties of the WebScene and SceneView,\n * such as the basemap, viewpoint and visible layers.\n * Spec - https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html\n */\ntype Slide = {\n id: string;\n title: {\n text: string;\n };\n thumbnail: {\n url: string;\n };\n description: {\n text: string;\n };\n ground: {\n transparency: number;\n };\n baseMap: ArcGisBaseMap;\n visibleLayers: ArcGisVisibleLayer[];\n viewpoint: ArcGisViewPoint;\n};\n\n/**\n * The basemap of the scene. Only the base and reference layers of the basemap are stored in a slide.\n * Spec - https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html\n */\ntype ArcGisBaseMap = {\n id: string;\n title: string;\n baseMapLayers: ArcGisBaseMapLayer[];\n};\n\n/**\n * The visible layers of the scene.\n * Spec - https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#visibleLayers\n */\ntype ArcGisVisibleLayer = {\n id: string;\n sublayerIds: number[];\n};\n/**\n * The basemap of the scene.\n * Spec - https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html\n */\ntype ArcGisBaseMapLayer = {\n id: string;\n title: string;\n url: string;\n layerType: string;\n visibility: boolean;\n};\n\n/**\n * The viewpoint of the slide. This acts like a bookmark, saving a predefined location or point of view from which to view the scene.\n * Spec - https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html\n */\ntype ArcGisViewPoint = {\n scale: number;\n rotation?: number;\n /**\n * Spec - https://developers.arcgis.com/web-scene-specification/objects/viewpoint/\n */\n targetGeometry: any;\n camera: ArcGisCamera;\n};\n\n/**\n * The camera defines the position, tilt, and heading of the point from which the SceneView's visible extent is observed.\n * It is not associated with device hardware. This class only applies to 3D SceneViews.\n * Spec - https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html\n */\nexport type ArcGisCamera = {\n position: {\n x: number;\n y: number;\n z: number;\n };\n spatialReference: {\n wkid: number;\n latestWkid: number;\n };\n heading: number;\n tilt: number;\n};\n\n/**\n * Operational layers contain your data. Usually, a basemap sits beneath your operational layers to give them geographic context.\n * Spec- https://developers.arcgis.com/web-scene-specification/objects/operationalLayers/\n */\nexport type OperationalLayer = {\n id: string;\n opacity: number;\n title: string;\n url: string;\n visibility: boolean;\n itemId: string;\n layerType: string;\n LayerDefinition: LayerDefinition;\n screenSizePerspective: boolean;\n showLabels?: boolean;\n disablePopup?: boolean;\n showLegend?: boolean;\n layers?: OperationalLayer[];\n};\n\ntype LayerDefinition = {\n elevationInfo: ElevationInfo;\n drawingInfo: DrawingInfo;\n};\n\ntype BaseMap = {\n id: string;\n title: string;\n baseMapLayers: BaseMapLayer[];\n elevationLayers: ElevationLayer[];\n};\n\ntype BaseMapLayer = {\n id: string;\n opacity: number;\n title: string;\n url: string;\n visibility: boolean;\n layerType: string;\n};\n\ntype ElevationLayer = {\n id: string;\n listMode: string;\n title: string;\n url: string;\n visibility: boolean;\n layerType: string;\n};\n\ntype Ground = {\n layers: ElevationLayer[];\n transparency: number;\n navigationConstraint: NavigationConstraint;\n};\n\ntype NavigationConstraint = {\n type: string;\n};\n\ntype InitialState = {\n environment: Enviroment;\n viewpoint: ViewPoint;\n};\n\ntype Enviroment = {\n lighting: Lighting;\n atmosphereEnabled?: string;\n starsEnabled?: string;\n};\n\ntype Lighting = {\n datetime?: number;\n displayUTCOffset?: number;\n};\n\ntype ViewPoint = {\n camera: Camera;\n};\n\ntype Camera = {\n position: CameraPosition;\n heading: number;\n tilt: number;\n};\n\ntype CameraPosition = {\n spatialReference: SpatialReference;\n x: number;\n y: number;\n z: number;\n};\n\n/**\n * Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/statsInfo.cmn.md\n */\nexport type StatsInfo = {\n /** Represents the count of the value. */\n totalValuesCount?: number;\n /** Minimum attribute value for the entire layer. */\n min?: number;\n /** Maximum attribute value for the entire layer. */\n max?: number;\n /** Count for the entire layer. */\n count?: number;\n /** Sum of the attribute values over the entire layer. */\n sum?: number;\n /** Representing average or mean value. For example, sum/count. */\n avg?: number;\n /** Representing the standard deviation. */\n stddev?: number;\n /**\tRepresenting variance. For example, stats.stddev *stats.stddev. */\n variance?: number;\n /** Represents the histogram. */\n histogram?: Histogram;\n /** An array of most frequently used values within the point cloud scene layer. */\n mostFrequentValues?: ValueCount[];\n};\n\n/** Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/histogram.cmn.md */\nexport type Histogram = {\n /** Minimum attribute value for the entire layer. */\n minimum: number;\n /** Maximum attribute value for the entire layer. Maximum array size for stats.histo.counts is 256. */\n maximum: number;\n /** Count for the entire layer. */\n counts: number[];\n};\n\nexport type ValueCount = {\n /** Type of the attribute values after decompression, if applicable. Please note that string is not supported for point cloud scene layer attributes. */\n value: number | string;\n /** Count of the number of values. May exceed 32 bits. */\n count: number;\n};\n"],"mappings":"AAIA,WAAYA,SAAS,aAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAAA,OAATA,SAAS;AAAA;AA8tBrB,WAAYC,uBAAuB,aAAvBA,uBAAuB;EAAvBA,uBAAuB;EAAvBA,uBAAuB;EAAA,OAAvBA,uBAAuB;AAAA"}
|