@loaders.gl/i3s 4.0.0-alpha.8 → 4.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.min.js +4925 -445
- package/dist/es5/arcgis-webscene-loader.js +4 -4
- package/dist/es5/arcgis-webscene-loader.js.map +1 -1
- package/dist/es5/i3s-attribute-loader.js +1 -1
- package/dist/es5/i3s-attribute-loader.js.map +1 -1
- package/dist/es5/i3s-building-scene-layer-loader.js +1 -1
- package/dist/es5/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/es5/i3s-content-loader.js +1 -1
- package/dist/es5/i3s-content-loader.js.map +1 -1
- package/dist/es5/i3s-loader.js +6 -6
- package/dist/es5/i3s-loader.js.map +1 -1
- package/dist/es5/i3s-node-page-loader.js +14 -12
- package/dist/es5/i3s-node-page-loader.js.map +1 -1
- package/dist/es5/i3s-slpk-loader.js +30 -2
- package/dist/es5/i3s-slpk-loader.js.map +1 -1
- package/dist/es5/index.js +9 -2
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +9 -5
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
- package/dist/es5/lib/parsers/constants.js +14 -15
- package/dist/es5/lib/parsers/constants.js.map +1 -1
- package/dist/es5/lib/parsers/parse-arcgis-webscene.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js +34 -31
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s.js +31 -19
- package/dist/es5/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js +42 -67
- package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js.map +1 -1
- package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js +76 -51
- package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js.map +1 -1
- package/dist/es5/lib/utils/customize-/321/201olors.js.map +1 -1
- package/dist/es5/lib/utils/url-utils.js +3 -3
- package/dist/es5/lib/utils/url-utils.js.map +1 -1
- package/dist/es5/types.js +1 -14
- package/dist/es5/types.js.map +1 -1
- package/dist/esm/arcgis-webscene-loader.js +2 -2
- package/dist/esm/arcgis-webscene-loader.js.map +1 -1
- package/dist/esm/i3s-attribute-loader.js +1 -1
- package/dist/esm/i3s-attribute-loader.js.map +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/esm/i3s-content-loader.js +1 -1
- package/dist/esm/i3s-content-loader.js.map +1 -1
- package/dist/esm/i3s-loader.js +3 -4
- package/dist/esm/i3s-loader.js.map +1 -1
- package/dist/esm/i3s-node-page-loader.js +7 -5
- package/dist/esm/i3s-node-page-loader.js.map +1 -1
- package/dist/esm/i3s-slpk-loader.js +8 -2
- package/dist/esm/i3s-slpk-loader.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js +9 -5
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
- package/dist/esm/lib/parsers/constants.js +14 -15
- package/dist/esm/lib/parsers/constants.js.map +1 -1
- package/dist/esm/lib/parsers/parse-arcgis-webscene.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js +5 -2
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s.js +23 -12
- package/dist/esm/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/esm/lib/parsers/parse-slpk/parse-slpk.js +19 -33
- package/dist/esm/lib/parsers/parse-slpk/parse-slpk.js.map +1 -1
- package/dist/esm/lib/parsers/parse-slpk/slpk-archieve.js +23 -32
- package/dist/esm/lib/parsers/parse-slpk/slpk-archieve.js.map +1 -1
- package/dist/esm/lib/utils/customize-/321/201olors.js.map +1 -1
- package/dist/esm/lib/utils/url-utils.js +2 -3
- package/dist/esm/lib/utils/url-utils.js.map +1 -1
- package/dist/esm/types.js +0 -12
- package/dist/esm/types.js.map +1 -1
- package/dist/i3s-content-worker-node.js +47 -47
- package/dist/i3s-content-worker-node.js.map +3 -3
- package/dist/i3s-content-worker.js +191 -126
- package/dist/src/arcgis-webscene-loader.d.ts +9 -0
- package/dist/src/arcgis-webscene-loader.d.ts.map +1 -0
- package/dist/src/bundle.d.ts.map +1 -0
- package/dist/{i3s-attribute-loader.d.ts → src/i3s-attribute-loader.d.ts} +3 -2
- package/dist/src/i3s-attribute-loader.d.ts.map +1 -0
- package/dist/src/i3s-building-scene-layer-loader.d.ts +8 -0
- package/dist/src/i3s-building-scene-layer-loader.d.ts.map +1 -0
- package/dist/src/i3s-content-loader.d.ts +8 -0
- package/dist/src/i3s-content-loader.d.ts.map +1 -0
- package/dist/src/i3s-loader.d.ts +11 -0
- package/dist/src/i3s-loader.d.ts.map +1 -0
- package/dist/src/i3s-node-page-loader.d.ts +8 -0
- package/dist/src/i3s-node-page-loader.d.ts.map +1 -0
- package/dist/src/i3s-slpk-loader.d.ts +15 -0
- package/dist/src/i3s-slpk-loader.d.ts.map +1 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/{lib → src/lib}/helpers/i3s-nodepages-tiles.d.ts +5 -3
- package/dist/src/lib/helpers/i3s-nodepages-tiles.d.ts.map +1 -0
- package/dist/src/lib/parsers/constants.d.ts.map +1 -0
- package/dist/src/lib/parsers/parse-arcgis-webscene.d.ts +7 -0
- package/dist/src/lib/parsers/parse-arcgis-webscene.d.ts.map +1 -0
- package/dist/src/lib/parsers/parse-i3s-attribute.d.ts.map +1 -0
- package/dist/src/lib/parsers/parse-i3s-building-scene-layer.d.ts.map +1 -0
- package/dist/{lib → src/lib}/parsers/parse-i3s-tile-content.d.ts +1 -1
- package/dist/src/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -0
- package/dist/{lib → src/lib}/parsers/parse-i3s.d.ts +2 -2
- package/dist/src/lib/parsers/parse-i3s.d.ts.map +1 -0
- package/dist/src/lib/parsers/parse-slpk/parse-slpk.d.ts +10 -0
- package/dist/src/lib/parsers/parse-slpk/parse-slpk.d.ts.map +1 -0
- package/dist/{lib → src/lib}/parsers/parse-slpk/slpk-archieve.d.ts +6 -12
- package/dist/src/lib/parsers/parse-slpk/slpk-archieve.d.ts.map +1 -0
- package/dist/src/lib/utils/convert-i3s-obb-to-mbs.d.ts.map +1 -0
- package/dist/src/lib/utils/customize-/321/201olors.d.ts.map +1 -0
- package/dist/{lib → src/lib}/utils/url-utils.d.ts +5 -4
- package/dist/src/lib/utils/url-utils.d.ts.map +1 -0
- package/dist/{types.d.ts → src/types.d.ts} +138 -74
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/workers/i3s-content-worker-node.d.ts.map +1 -0
- package/dist/src/workers/i3s-content-worker.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +10 -10
- package/src/arcgis-webscene-loader.ts +12 -6
- package/src/i3s-attribute-loader.ts +2 -1
- package/src/i3s-building-scene-layer-loader.ts +6 -1
- package/src/i3s-content-loader.ts +3 -2
- package/src/i3s-loader.ts +6 -8
- package/src/i3s-node-page-loader.ts +9 -6
- package/src/i3s-slpk-loader.ts +21 -3
- package/src/index.ts +6 -2
- package/src/lib/helpers/i3s-nodepages-tiles.ts +16 -9
- package/src/lib/parsers/constants.ts +14 -15
- package/src/lib/parsers/parse-arcgis-webscene.ts +2 -2
- package/src/lib/parsers/parse-i3s-tile-content.ts +7 -9
- package/src/lib/parsers/parse-i3s.ts +30 -18
- package/src/lib/parsers/parse-slpk/parse-slpk.ts +43 -55
- package/src/lib/parsers/parse-slpk/slpk-archieve.ts +30 -62
- package/src/lib/utils/customize-/321/201olors.ts +2 -2
- package/src/lib/utils/url-utils.ts +6 -5
- package/src/types.ts +143 -91
- package/dist/arcgis-webscene-loader.d.ts +0 -7
- package/dist/arcgis-webscene-loader.d.ts.map +0 -1
- package/dist/arcgis-webscene-loader.js +0 -28
- package/dist/bundle.d.ts.map +0 -1
- package/dist/bundle.js +0 -5
- package/dist/es5/lib/parsers/parse-zip/cd-file-header.js +0 -44
- package/dist/es5/lib/parsers/parse-zip/cd-file-header.js.map +0 -1
- package/dist/es5/lib/parsers/parse-zip/local-file-header.js +0 -26
- package/dist/es5/lib/parsers/parse-zip/local-file-header.js.map +0 -1
- package/dist/esm/lib/parsers/parse-zip/cd-file-header.js +0 -37
- package/dist/esm/lib/parsers/parse-zip/cd-file-header.js.map +0 -1
- package/dist/esm/lib/parsers/parse-zip/local-file-header.js +0 -19
- package/dist/esm/lib/parsers/parse-zip/local-file-header.js.map +0 -1
- package/dist/i3s-attribute-loader.d.ts.map +0 -1
- package/dist/i3s-attribute-loader.js +0 -175
- package/dist/i3s-building-scene-layer-loader.d.ts +0 -6
- package/dist/i3s-building-scene-layer-loader.d.ts.map +0 -1
- package/dist/i3s-building-scene-layer-loader.js +0 -26
- package/dist/i3s-content-loader.d.ts +0 -6
- package/dist/i3s-content-loader.d.ts.map +0 -1
- package/dist/i3s-content-loader.js +0 -32
- package/dist/i3s-loader.d.ts +0 -11
- package/dist/i3s-loader.d.ts.map +0 -1
- package/dist/i3s-loader.js +0 -102
- package/dist/i3s-node-page-loader.d.ts +0 -7
- package/dist/i3s-node-page-loader.d.ts.map +0 -1
- package/dist/i3s-node-page-loader.js +0 -22
- package/dist/i3s-slpk-loader.d.ts +0 -13
- package/dist/i3s-slpk-loader.d.ts.map +0 -1
- package/dist/i3s-slpk-loader.js +0 -20
- package/dist/index.d.ts +0 -10
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -21
- package/dist/lib/helpers/i3s-nodepages-tiles.d.ts.map +0 -1
- package/dist/lib/helpers/i3s-nodepages-tiles.js +0 -242
- package/dist/lib/parsers/constants.d.ts.map +0 -1
- package/dist/lib/parsers/constants.js +0 -89
- package/dist/lib/parsers/parse-arcgis-webscene.d.ts +0 -7
- package/dist/lib/parsers/parse-arcgis-webscene.d.ts.map +0 -1
- package/dist/lib/parsers/parse-arcgis-webscene.js +0 -88
- package/dist/lib/parsers/parse-i3s-attribute.d.ts.map +0 -1
- package/dist/lib/parsers/parse-i3s-attribute.js +0 -99
- package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts.map +0 -1
- package/dist/lib/parsers/parse-i3s-building-scene-layer.js +0 -46
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +0 -1
- package/dist/lib/parsers/parse-i3s-tile-content.js +0 -499
- package/dist/lib/parsers/parse-i3s.d.ts.map +0 -1
- package/dist/lib/parsers/parse-i3s.js +0 -95
- package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts +0 -4
- package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts.map +0 -1
- package/dist/lib/parsers/parse-slpk/parse-slpk.js +0 -50
- package/dist/lib/parsers/parse-slpk/slpk-archieve.d.ts.map +0 -1
- package/dist/lib/parsers/parse-slpk/slpk-archieve.js +0 -142
- package/dist/lib/parsers/parse-zip/cd-file-header.d.ts +0 -38
- package/dist/lib/parsers/parse-zip/cd-file-header.d.ts.map +0 -1
- package/dist/lib/parsers/parse-zip/cd-file-header.js +0 -48
- package/dist/lib/parsers/parse-zip/local-file-header.d.ts +0 -30
- package/dist/lib/parsers/parse-zip/local-file-header.d.ts.map +0 -1
- package/dist/lib/parsers/parse-zip/local-file-header.js +0 -28
- package/dist/lib/utils/convert-i3s-obb-to-mbs.d.ts.map +0 -1
- package/dist/lib/utils/convert-i3s-obb-to-mbs.js +0 -20
- package/dist/lib/utils/customize-/321/201olors.d.ts.map +0 -1
- package/dist/lib/utils/customize-/321/201olors.js +0 -104
- package/dist/lib/utils/url-utils.d.ts.map +0 -1
- package/dist/lib/utils/url-utils.js +0 -44
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -20
- package/dist/workers/i3s-content-worker-node.d.ts.map +0 -1
- package/dist/workers/i3s-content-worker-node.js +0 -7
- package/dist/workers/i3s-content-worker.d.ts.map +0 -1
- package/dist/workers/i3s-content-worker.js +0 -5
- package/src/lib/parsers/parse-zip/cd-file-header.ts +0 -93
- package/src/lib/parsers/parse-zip/local-file-header.ts +0 -56
- /package/dist/{bundle.d.ts → src/bundle.d.ts} +0 -0
- /package/dist/{lib → src/lib}/parsers/constants.d.ts +0 -0
- /package/dist/{lib → src/lib}/parsers/parse-i3s-attribute.d.ts +0 -0
- /package/dist/{lib → src/lib}/parsers/parse-i3s-building-scene-layer.d.ts +0 -0
- /package/dist/{lib → src/lib}/utils/convert-i3s-obb-to-mbs.d.ts +0 -0
- /package/dist/{lib → src/lib}/utils/customize-/321/201olors.d.ts" +0 -0
- /package/dist/{workers → src/workers}/i3s-content-worker-node.d.ts +0 -0
- /package/dist/{workers → src/workers}/i3s-content-worker.d.ts +0 -0
|
@@ -1,499 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseI3STileContent = void 0;
|
|
4
|
-
const core_1 = require("@loaders.gl/core");
|
|
5
|
-
const core_2 = require("@math.gl/core");
|
|
6
|
-
const geospatial_1 = require("@math.gl/geospatial");
|
|
7
|
-
const images_1 = require("@loaders.gl/images");
|
|
8
|
-
const draco_1 = require("@loaders.gl/draco");
|
|
9
|
-
const textures_1 = require("@loaders.gl/textures");
|
|
10
|
-
const types_1 = require("../../types");
|
|
11
|
-
const url_utils_1 = require("../utils/url-utils");
|
|
12
|
-
const constants_1 = require("./constants");
|
|
13
|
-
const customize__olors_1 = require("../utils/customize-\u0441olors");
|
|
14
|
-
const scratchVector = new core_2.Vector3([0, 0, 0]);
|
|
15
|
-
function getLoaderForTextureFormat(textureFormat) {
|
|
16
|
-
switch (textureFormat) {
|
|
17
|
-
case 'ktx-etc2':
|
|
18
|
-
case 'dds':
|
|
19
|
-
return textures_1.CompressedTextureLoader;
|
|
20
|
-
case 'ktx2':
|
|
21
|
-
return textures_1.BasisLoader;
|
|
22
|
-
case 'jpg':
|
|
23
|
-
case 'png':
|
|
24
|
-
default:
|
|
25
|
-
return images_1.ImageLoader;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const I3S_ATTRIBUTE_TYPE = 'i3s-attribute-type';
|
|
29
|
-
async function parseI3STileContent(arrayBuffer, tileOptions, tilesetOptions, options, context) {
|
|
30
|
-
const content = {
|
|
31
|
-
attributes: {},
|
|
32
|
-
indices: null,
|
|
33
|
-
featureIds: [],
|
|
34
|
-
vertexCount: 0,
|
|
35
|
-
modelMatrix: new core_2.Matrix4(),
|
|
36
|
-
coordinateSystem: 0,
|
|
37
|
-
byteLength: 0,
|
|
38
|
-
texture: null
|
|
39
|
-
};
|
|
40
|
-
if (tileOptions.textureUrl) {
|
|
41
|
-
// @ts-expect-error options is not properly typed
|
|
42
|
-
const url = (0, url_utils_1.getUrlWithToken)(tileOptions.textureUrl, options?.i3s?.token);
|
|
43
|
-
const loader = getLoaderForTextureFormat(tileOptions.textureFormat);
|
|
44
|
-
const response = await fetch(url, options?.fetch);
|
|
45
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
46
|
-
// @ts-expect-error options is not properly typed
|
|
47
|
-
if (options?.i3s.decodeTextures) {
|
|
48
|
-
if (loader === images_1.ImageLoader) {
|
|
49
|
-
const options = { ...tileOptions.textureLoaderOptions, image: { type: 'data' } };
|
|
50
|
-
try {
|
|
51
|
-
// @ts-ignore context must be defined
|
|
52
|
-
// Image constructor is not supported in worker thread.
|
|
53
|
-
// Do parsing image data on the main thread by using context to avoid worker issues.
|
|
54
|
-
content.texture = await context.parse(arrayBuffer, options);
|
|
55
|
-
}
|
|
56
|
-
catch (e) {
|
|
57
|
-
// context object is different between worker and node.js conversion script.
|
|
58
|
-
// To prevent error we parse data in ordinary way if it is not parsed by using context.
|
|
59
|
-
// @ts-expect-error
|
|
60
|
-
content.texture = await (0, core_1.parse)(arrayBuffer, loader, options);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else if (loader === textures_1.CompressedTextureLoader || loader === textures_1.BasisLoader) {
|
|
64
|
-
let texture = await (0, core_1.load)(arrayBuffer, loader, tileOptions.textureLoaderOptions);
|
|
65
|
-
if (loader === textures_1.BasisLoader) {
|
|
66
|
-
// @ts-expect-error
|
|
67
|
-
texture = texture[0];
|
|
68
|
-
}
|
|
69
|
-
content.texture = {
|
|
70
|
-
compressed: true,
|
|
71
|
-
mipmaps: false,
|
|
72
|
-
// @ts-expect-error
|
|
73
|
-
width: texture[0].width,
|
|
74
|
-
// @ts-expect-error
|
|
75
|
-
height: texture[0].height,
|
|
76
|
-
// @ts-expect-error
|
|
77
|
-
data: texture
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
content.texture = arrayBuffer;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
content.material = makePbrMaterial(tileOptions.materialDefinition, content.texture);
|
|
86
|
-
if (content.material) {
|
|
87
|
-
content.texture = null;
|
|
88
|
-
}
|
|
89
|
-
return await parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options);
|
|
90
|
-
}
|
|
91
|
-
exports.parseI3STileContent = parseI3STileContent;
|
|
92
|
-
/* eslint-disable max-statements */
|
|
93
|
-
async function parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options) {
|
|
94
|
-
const contentByteLength = arrayBuffer.byteLength;
|
|
95
|
-
let attributes;
|
|
96
|
-
let vertexCount;
|
|
97
|
-
let byteOffset = 0;
|
|
98
|
-
let featureCount = 0;
|
|
99
|
-
let indices;
|
|
100
|
-
if (tileOptions.isDracoGeometry) {
|
|
101
|
-
const decompressedGeometry = await (0, core_1.parse)(arrayBuffer, draco_1.DracoLoader, {
|
|
102
|
-
draco: {
|
|
103
|
-
attributeNameEntry: I3S_ATTRIBUTE_TYPE
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
// @ts-expect-error
|
|
107
|
-
vertexCount = decompressedGeometry.header.vertexCount;
|
|
108
|
-
indices = decompressedGeometry.indices?.value;
|
|
109
|
-
const { POSITION, NORMAL, COLOR_0, TEXCOORD_0, ['feature-index']: featureIndex, ['uv-region']: uvRegion } = decompressedGeometry.attributes;
|
|
110
|
-
attributes = {
|
|
111
|
-
position: POSITION,
|
|
112
|
-
normal: NORMAL,
|
|
113
|
-
color: COLOR_0,
|
|
114
|
-
uv0: TEXCOORD_0,
|
|
115
|
-
uvRegion,
|
|
116
|
-
id: featureIndex
|
|
117
|
-
};
|
|
118
|
-
updateAttributesMetadata(attributes, decompressedGeometry);
|
|
119
|
-
const featureIds = getFeatureIdsFromFeatureIndexMetadata(featureIndex);
|
|
120
|
-
if (featureIds) {
|
|
121
|
-
flattenFeatureIdsByFeatureIndices(attributes, featureIds);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
const { vertexAttributes, ordering: attributesOrder, featureAttributes, featureAttributeOrder } = tilesetOptions.store.defaultGeometrySchema;
|
|
126
|
-
// First 8 bytes reserved for header (vertexCount and featureCount)
|
|
127
|
-
const headers = parseHeaders(arrayBuffer, tilesetOptions);
|
|
128
|
-
byteOffset = headers.byteOffset;
|
|
129
|
-
vertexCount = headers.vertexCount;
|
|
130
|
-
featureCount = headers.featureCount;
|
|
131
|
-
// Getting vertex attributes such as positions, normals, colors, etc...
|
|
132
|
-
const { attributes: normalizedVertexAttributes, byteOffset: offset } = normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, vertexCount, attributesOrder);
|
|
133
|
-
// Getting feature attributes such as featureIds and faceRange
|
|
134
|
-
const { attributes: normalizedFeatureAttributes } = normalizeAttributes(arrayBuffer, offset, featureAttributes, featureCount, featureAttributeOrder);
|
|
135
|
-
flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes);
|
|
136
|
-
attributes = concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes);
|
|
137
|
-
}
|
|
138
|
-
if (!options?.i3s?.coordinateSystem ||
|
|
139
|
-
options.i3s.coordinateSystem === constants_1.COORDINATE_SYSTEM.METER_OFFSETS) {
|
|
140
|
-
const enuMatrix = parsePositions(attributes.position, tileOptions);
|
|
141
|
-
content.modelMatrix = enuMatrix.invert();
|
|
142
|
-
content.coordinateSystem = constants_1.COORDINATE_SYSTEM.METER_OFFSETS;
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
content.modelMatrix = getModelMatrix(attributes.position);
|
|
146
|
-
content.coordinateSystem = constants_1.COORDINATE_SYSTEM.LNGLAT_OFFSETS;
|
|
147
|
-
}
|
|
148
|
-
attributes.color = await (0, customize__olors_1.customizeColors)(attributes.color, attributes.id, tileOptions, tilesetOptions, options);
|
|
149
|
-
content.attributes = {
|
|
150
|
-
positions: attributes.position,
|
|
151
|
-
normals: attributes.normal,
|
|
152
|
-
colors: normalizeAttribute(attributes.color),
|
|
153
|
-
texCoords: attributes.uv0,
|
|
154
|
-
uvRegions: normalizeAttribute(attributes.uvRegion || attributes.region) // Normalize from UInt16
|
|
155
|
-
};
|
|
156
|
-
content.indices = indices || null;
|
|
157
|
-
if (attributes.id && attributes.id.value) {
|
|
158
|
-
content.featureIds = attributes.id.value;
|
|
159
|
-
}
|
|
160
|
-
// Remove undefined attributes
|
|
161
|
-
for (const attributeIndex in content.attributes) {
|
|
162
|
-
if (!content.attributes[attributeIndex]) {
|
|
163
|
-
delete content.attributes[attributeIndex];
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
content.vertexCount = vertexCount;
|
|
167
|
-
content.byteLength = contentByteLength;
|
|
168
|
-
return content;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Update attributes with metadata from decompressed geometry.
|
|
172
|
-
* @param decompressedGeometry
|
|
173
|
-
* @param attributes
|
|
174
|
-
*/
|
|
175
|
-
function updateAttributesMetadata(attributes, decompressedGeometry) {
|
|
176
|
-
for (const key in decompressedGeometry.loaderData.attributes) {
|
|
177
|
-
const dracoAttribute = decompressedGeometry.loaderData.attributes[key];
|
|
178
|
-
switch (dracoAttribute.name) {
|
|
179
|
-
case 'POSITION':
|
|
180
|
-
attributes.position.metadata = dracoAttribute.metadata;
|
|
181
|
-
break;
|
|
182
|
-
case 'feature-index':
|
|
183
|
-
attributes.id.metadata = dracoAttribute.metadata;
|
|
184
|
-
break;
|
|
185
|
-
default:
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Do concatenation of attribute objects.
|
|
192
|
-
* Done as separate fucntion to avoid ts errors.
|
|
193
|
-
* @param normalizedVertexAttributes
|
|
194
|
-
* @param normalizedFeatureAttributes
|
|
195
|
-
* @returns - result of attributes concatenation.
|
|
196
|
-
*/
|
|
197
|
-
function concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes) {
|
|
198
|
-
return { ...normalizedVertexAttributes, ...normalizedFeatureAttributes };
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Normalize attribute to range [0..1] . Eg. convert colors buffer from [255,255,255,255] to [1,1,1,1]
|
|
202
|
-
* @param attribute - geometry attribute
|
|
203
|
-
* @returns - geometry attribute in right format
|
|
204
|
-
*/
|
|
205
|
-
function normalizeAttribute(attribute) {
|
|
206
|
-
if (!attribute) {
|
|
207
|
-
return attribute;
|
|
208
|
-
}
|
|
209
|
-
attribute.normalized = true;
|
|
210
|
-
return attribute;
|
|
211
|
-
}
|
|
212
|
-
function parseHeaders(arrayBuffer, options) {
|
|
213
|
-
let byteOffset = 0;
|
|
214
|
-
// First 8 bytes reserved for header (vertexCount and featurecount)
|
|
215
|
-
let vertexCount = 0;
|
|
216
|
-
let featureCount = 0;
|
|
217
|
-
for (const { property, type } of options.store.defaultGeometrySchema.header) {
|
|
218
|
-
const TypedArrayTypeHeader = (0, constants_1.getConstructorForDataFormat)(type);
|
|
219
|
-
switch (property) {
|
|
220
|
-
case types_1.HeaderAttributeProperty.vertexCount:
|
|
221
|
-
vertexCount = new TypedArrayTypeHeader(arrayBuffer, 0, 4)[0];
|
|
222
|
-
byteOffset += (0, constants_1.sizeOf)(type);
|
|
223
|
-
break;
|
|
224
|
-
case types_1.HeaderAttributeProperty.featureCount:
|
|
225
|
-
featureCount = new TypedArrayTypeHeader(arrayBuffer, 4, 4)[0];
|
|
226
|
-
byteOffset += (0, constants_1.sizeOf)(type);
|
|
227
|
-
break;
|
|
228
|
-
default:
|
|
229
|
-
break;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return {
|
|
233
|
-
vertexCount,
|
|
234
|
-
featureCount,
|
|
235
|
-
byteOffset
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
/* eslint-enable max-statements */
|
|
239
|
-
function normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, attributeCount, attributesOrder) {
|
|
240
|
-
const attributes = {};
|
|
241
|
-
// the order of attributes depend on the order being added to the vertexAttributes object
|
|
242
|
-
for (const attribute of attributesOrder) {
|
|
243
|
-
if (vertexAttributes[attribute]) {
|
|
244
|
-
const { valueType, valuesPerElement } = vertexAttributes[attribute];
|
|
245
|
-
// protect from arrayBuffer read overunns by NOT assuming node has regions always even though its declared in defaultGeometrySchema.
|
|
246
|
-
// In i3s 1.6: client is required to decide that based on ./shared resource of the node (materialDefinitions.[Mat_id].params.vertexRegions == true)
|
|
247
|
-
// In i3s 1.7 the property has been rolled into the 3d scene layer json/node pages.
|
|
248
|
-
// Code below does not account when the bytelength is actually bigger than
|
|
249
|
-
// the calculated value (b\c the tile potentially could have mesh segmentation information).
|
|
250
|
-
// In those cases tiles without regions could fail or have garbage values.
|
|
251
|
-
if (byteOffset + attributeCount * valuesPerElement * (0, constants_1.sizeOf)(valueType) <=
|
|
252
|
-
arrayBuffer.byteLength) {
|
|
253
|
-
const buffer = arrayBuffer.slice(byteOffset);
|
|
254
|
-
let value;
|
|
255
|
-
if (valueType === 'UInt64') {
|
|
256
|
-
value = parseUint64Values(buffer, attributeCount * valuesPerElement, (0, constants_1.sizeOf)(valueType));
|
|
257
|
-
}
|
|
258
|
-
else {
|
|
259
|
-
const TypedArrayType = (0, constants_1.getConstructorForDataFormat)(valueType);
|
|
260
|
-
value = new TypedArrayType(buffer, 0, attributeCount * valuesPerElement);
|
|
261
|
-
}
|
|
262
|
-
attributes[attribute] = {
|
|
263
|
-
value,
|
|
264
|
-
type: constants_1.GL_TYPE_MAP[valueType],
|
|
265
|
-
size: valuesPerElement
|
|
266
|
-
};
|
|
267
|
-
switch (attribute) {
|
|
268
|
-
case 'color':
|
|
269
|
-
attributes.color.normalized = true;
|
|
270
|
-
break;
|
|
271
|
-
case 'position':
|
|
272
|
-
case 'region':
|
|
273
|
-
case 'normal':
|
|
274
|
-
default:
|
|
275
|
-
}
|
|
276
|
-
byteOffset = byteOffset + attributeCount * valuesPerElement * (0, constants_1.sizeOf)(valueType);
|
|
277
|
-
}
|
|
278
|
-
else if (attribute !== 'uv0') {
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
return { attributes, byteOffset };
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Parse buffer to return array of uint64 values
|
|
287
|
-
*
|
|
288
|
-
* @param buffer
|
|
289
|
-
* @param elementsCount
|
|
290
|
-
* @returns 64-bit array of values until precision is lost after Number.MAX_SAFE_INTEGER
|
|
291
|
-
*/
|
|
292
|
-
function parseUint64Values(buffer, elementsCount, attributeSize) {
|
|
293
|
-
const values = [];
|
|
294
|
-
const dataView = new DataView(buffer);
|
|
295
|
-
let offset = 0;
|
|
296
|
-
for (let index = 0; index < elementsCount; index++) {
|
|
297
|
-
// split 64-bit number into two 32-bit parts
|
|
298
|
-
const left = dataView.getUint32(offset, true);
|
|
299
|
-
const right = dataView.getUint32(offset + 4, true);
|
|
300
|
-
// combine the two 32-bit values
|
|
301
|
-
const value = left + 2 ** 32 * right;
|
|
302
|
-
values.push(value);
|
|
303
|
-
offset += attributeSize;
|
|
304
|
-
}
|
|
305
|
-
return new Uint32Array(values);
|
|
306
|
-
}
|
|
307
|
-
function parsePositions(attribute, options) {
|
|
308
|
-
const mbs = options.mbs;
|
|
309
|
-
const value = attribute.value;
|
|
310
|
-
const metadata = attribute.metadata;
|
|
311
|
-
const enuMatrix = new core_2.Matrix4();
|
|
312
|
-
const cartographicOrigin = new core_2.Vector3(mbs[0], mbs[1], mbs[2]);
|
|
313
|
-
const cartesianOrigin = new core_2.Vector3();
|
|
314
|
-
geospatial_1.Ellipsoid.WGS84.cartographicToCartesian(cartographicOrigin, cartesianOrigin);
|
|
315
|
-
geospatial_1.Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin, enuMatrix);
|
|
316
|
-
attribute.value = offsetsToCartesians(value, metadata, cartographicOrigin);
|
|
317
|
-
return enuMatrix;
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Converts position coordinates to absolute cartesian coordinates
|
|
321
|
-
* @param vertices - "position" attribute data
|
|
322
|
-
* @param metadata - When the geometry is DRACO compressed, contain position attribute's metadata
|
|
323
|
-
* https://github.com/Esri/i3s-spec/blob/master/docs/1.7/compressedAttributes.cmn.md
|
|
324
|
-
* @param cartographicOrigin - Cartographic origin coordinates
|
|
325
|
-
* @returns - converted "position" data
|
|
326
|
-
*/
|
|
327
|
-
function offsetsToCartesians(vertices, metadata = {}, cartographicOrigin) {
|
|
328
|
-
const positions = new Float64Array(vertices.length);
|
|
329
|
-
const scaleX = (metadata['i3s-scale_x'] && metadata['i3s-scale_x'].double) || 1;
|
|
330
|
-
const scaleY = (metadata['i3s-scale_y'] && metadata['i3s-scale_y'].double) || 1;
|
|
331
|
-
for (let i = 0; i < positions.length; i += 3) {
|
|
332
|
-
positions[i] = vertices[i] * scaleX + cartographicOrigin.x;
|
|
333
|
-
positions[i + 1] = vertices[i + 1] * scaleY + cartographicOrigin.y;
|
|
334
|
-
positions[i + 2] = vertices[i + 2] + cartographicOrigin.z;
|
|
335
|
-
}
|
|
336
|
-
for (let i = 0; i < positions.length; i += 3) {
|
|
337
|
-
// @ts-ignore
|
|
338
|
-
geospatial_1.Ellipsoid.WGS84.cartographicToCartesian(positions.subarray(i, i + 3), scratchVector);
|
|
339
|
-
positions[i] = scratchVector.x;
|
|
340
|
-
positions[i + 1] = scratchVector.y;
|
|
341
|
-
positions[i + 2] = scratchVector.z;
|
|
342
|
-
}
|
|
343
|
-
return positions;
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Get model matrix for loaded vertices
|
|
347
|
-
* @param positions positions attribute
|
|
348
|
-
* @returns Matrix4 - model matrix for geometry transformation
|
|
349
|
-
*/
|
|
350
|
-
function getModelMatrix(positions) {
|
|
351
|
-
const metadata = positions.metadata;
|
|
352
|
-
const scaleX = metadata?.['i3s-scale_x']?.double || 1;
|
|
353
|
-
const scaleY = metadata?.['i3s-scale_y']?.double || 1;
|
|
354
|
-
const modelMatrix = new core_2.Matrix4();
|
|
355
|
-
modelMatrix[0] = scaleX;
|
|
356
|
-
modelMatrix[5] = scaleY;
|
|
357
|
-
return modelMatrix;
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Makes a glTF-compatible PBR material from an I3S material definition
|
|
361
|
-
* @param materialDefinition - i3s material definition
|
|
362
|
-
* https://github.com/Esri/i3s-spec/blob/master/docs/1.7/materialDefinitions.cmn.md
|
|
363
|
-
* @param texture - texture image
|
|
364
|
-
* @returns {object}
|
|
365
|
-
*/
|
|
366
|
-
function makePbrMaterial(materialDefinition, texture) {
|
|
367
|
-
let pbrMaterial;
|
|
368
|
-
if (materialDefinition) {
|
|
369
|
-
pbrMaterial = {
|
|
370
|
-
...materialDefinition,
|
|
371
|
-
pbrMetallicRoughness: materialDefinition.pbrMetallicRoughness
|
|
372
|
-
? { ...materialDefinition.pbrMetallicRoughness }
|
|
373
|
-
: { baseColorFactor: [255, 255, 255, 255] }
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
else {
|
|
377
|
-
pbrMaterial = {
|
|
378
|
-
pbrMetallicRoughness: {}
|
|
379
|
-
};
|
|
380
|
-
if (texture) {
|
|
381
|
-
pbrMaterial.pbrMetallicRoughness.baseColorTexture = { texCoord: 0 };
|
|
382
|
-
}
|
|
383
|
-
else {
|
|
384
|
-
pbrMaterial.pbrMetallicRoughness.baseColorFactor = [255, 255, 255, 255];
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
// Set default 0.25 per spec https://github.com/Esri/i3s-spec/blob/master/docs/1.7/materialDefinitions.cmn.md
|
|
388
|
-
pbrMaterial.alphaCutoff = pbrMaterial.alphaCutoff || 0.25;
|
|
389
|
-
if (pbrMaterial.alphaMode) {
|
|
390
|
-
// I3S contain alphaMode in lowerCase
|
|
391
|
-
pbrMaterial.alphaMode = pbrMaterial.alphaMode.toUpperCase();
|
|
392
|
-
}
|
|
393
|
-
// Convert colors from [255,255,255,255] to [1,1,1,1]
|
|
394
|
-
if (pbrMaterial.emissiveFactor) {
|
|
395
|
-
pbrMaterial.emissiveFactor = convertColorFormat(pbrMaterial.emissiveFactor);
|
|
396
|
-
}
|
|
397
|
-
if (pbrMaterial.pbrMetallicRoughness && pbrMaterial.pbrMetallicRoughness.baseColorFactor) {
|
|
398
|
-
pbrMaterial.pbrMetallicRoughness.baseColorFactor = convertColorFormat(pbrMaterial.pbrMetallicRoughness.baseColorFactor);
|
|
399
|
-
}
|
|
400
|
-
if (texture) {
|
|
401
|
-
setMaterialTexture(pbrMaterial, texture);
|
|
402
|
-
}
|
|
403
|
-
return pbrMaterial;
|
|
404
|
-
}
|
|
405
|
-
/**
|
|
406
|
-
* Convert color from [255,255,255,255] to [1,1,1,1]
|
|
407
|
-
* @param colorFactor - color array
|
|
408
|
-
* @returns - new color array
|
|
409
|
-
*/
|
|
410
|
-
function convertColorFormat(colorFactor) {
|
|
411
|
-
const normalizedColor = [...colorFactor];
|
|
412
|
-
for (let index = 0; index < colorFactor.length; index++) {
|
|
413
|
-
normalizedColor[index] = colorFactor[index] / 255;
|
|
414
|
-
}
|
|
415
|
-
return normalizedColor;
|
|
416
|
-
}
|
|
417
|
-
/**
|
|
418
|
-
* Set texture in PBR material
|
|
419
|
-
* @param {object} material - i3s material definition
|
|
420
|
-
* @param image - texture image
|
|
421
|
-
* @returns
|
|
422
|
-
*/
|
|
423
|
-
function setMaterialTexture(material, image) {
|
|
424
|
-
const texture = { source: { image } };
|
|
425
|
-
// I3SLoader now support loading only one texture. This elseif sequence will assign this texture to one of
|
|
426
|
-
// properties defined in materialDefinition
|
|
427
|
-
if (material.pbrMetallicRoughness && material.pbrMetallicRoughness.baseColorTexture) {
|
|
428
|
-
material.pbrMetallicRoughness.baseColorTexture = {
|
|
429
|
-
...material.pbrMetallicRoughness.baseColorTexture,
|
|
430
|
-
texture
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
else if (material.emissiveTexture) {
|
|
434
|
-
material.emissiveTexture = { ...material.emissiveTexture, texture };
|
|
435
|
-
}
|
|
436
|
-
else if (material.pbrMetallicRoughness &&
|
|
437
|
-
material.pbrMetallicRoughness.metallicRoughnessTexture) {
|
|
438
|
-
material.pbrMetallicRoughness.metallicRoughnessTexture = {
|
|
439
|
-
...material.pbrMetallicRoughness.metallicRoughnessTexture,
|
|
440
|
-
texture
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
else if (material.normalTexture) {
|
|
444
|
-
material.normalTexture = { ...material.normalTexture, texture };
|
|
445
|
-
}
|
|
446
|
-
else if (material.occlusionTexture) {
|
|
447
|
-
material.occlusionTexture = { ...material.occlusionTexture, texture };
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* Flatten feature ids using face ranges
|
|
452
|
-
* @param normalizedFeatureAttributes
|
|
453
|
-
* @returns
|
|
454
|
-
*/
|
|
455
|
-
function flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes) {
|
|
456
|
-
const { id, faceRange } = normalizedFeatureAttributes;
|
|
457
|
-
if (!id || !faceRange) {
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
const featureIds = id.value;
|
|
461
|
-
const range = faceRange.value;
|
|
462
|
-
const featureIdsLength = range[range.length - 1] + 1;
|
|
463
|
-
const orderedFeatureIndices = new Uint32Array(featureIdsLength * 3);
|
|
464
|
-
let featureIndex = 0;
|
|
465
|
-
let startIndex = 0;
|
|
466
|
-
for (let index = 1; index < range.length; index += 2) {
|
|
467
|
-
const fillId = Number(featureIds[featureIndex]);
|
|
468
|
-
const endValue = range[index];
|
|
469
|
-
const prevValue = range[index - 1];
|
|
470
|
-
const trianglesCount = endValue - prevValue + 1;
|
|
471
|
-
const endIndex = startIndex + trianglesCount * 3;
|
|
472
|
-
orderedFeatureIndices.fill(fillId, startIndex, endIndex);
|
|
473
|
-
featureIndex++;
|
|
474
|
-
startIndex = endIndex;
|
|
475
|
-
}
|
|
476
|
-
normalizedFeatureAttributes.id.value = orderedFeatureIndices;
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Flatten feature ids using featureIndices
|
|
480
|
-
* @param attributes
|
|
481
|
-
* @param featureIds
|
|
482
|
-
* @returns
|
|
483
|
-
*/
|
|
484
|
-
function flattenFeatureIdsByFeatureIndices(attributes, featureIds) {
|
|
485
|
-
const featureIndices = attributes.id.value;
|
|
486
|
-
const result = new Float32Array(featureIndices.length);
|
|
487
|
-
for (let index = 0; index < featureIndices.length; index++) {
|
|
488
|
-
result[index] = featureIds[featureIndices[index]];
|
|
489
|
-
}
|
|
490
|
-
attributes.id.value = result;
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* Flatten feature ids using featureIndices
|
|
494
|
-
* @param featureIndex
|
|
495
|
-
* @returns
|
|
496
|
-
*/
|
|
497
|
-
function getFeatureIdsFromFeatureIndexMetadata(featureIndex) {
|
|
498
|
-
return featureIndex?.metadata?.['i3s-feature-ids']?.intArray;
|
|
499
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-i3s.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-i3s.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,gBAAgB,EAChB,aAAa,EAEb,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAE3E,wBAAgB,iBAAiB,CAAC,IAAI,EAAG,mBAAmB,EAAE,OAAO,EAAE,aAAa,GAAG,aAAa,CAyBnG;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAG,kBAAkB,GAAG,aAAa,CAmChF;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAG,gBAAgB,EAAE,OAAO,EAAG,aAAa,EAAE,OAAO,EAAE,aAAa,iBA0BrH"}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.normalizeTilesetData = exports.normalizeTileNonUrlData = exports.normalizeTileData = void 0;
|
|
7
|
-
const culling_1 = require("@math.gl/culling");
|
|
8
|
-
const geospatial_1 = require("@math.gl/geospatial");
|
|
9
|
-
const core_1 = require("@loaders.gl/core");
|
|
10
|
-
const tiles_1 = require("@loaders.gl/tiles");
|
|
11
|
-
const i3s_nodepages_tiles_1 = __importDefault(require("../helpers/i3s-nodepages-tiles"));
|
|
12
|
-
const url_utils_1 = require("../utils/url-utils");
|
|
13
|
-
function normalizeTileData(tile, context) {
|
|
14
|
-
const url = context.url || '';
|
|
15
|
-
let contentUrl;
|
|
16
|
-
if (tile.geometryData) {
|
|
17
|
-
contentUrl = `${url}/${tile.geometryData[0].href}`;
|
|
18
|
-
}
|
|
19
|
-
let textureUrl;
|
|
20
|
-
if (tile.textureData) {
|
|
21
|
-
textureUrl = `${url}/${tile.textureData[0].href}`;
|
|
22
|
-
}
|
|
23
|
-
let attributeUrls;
|
|
24
|
-
if (tile.attributeData) {
|
|
25
|
-
attributeUrls = (0, url_utils_1.generateTileAttributeUrls)(url, tile);
|
|
26
|
-
}
|
|
27
|
-
return normalizeTileNonUrlData({
|
|
28
|
-
...tile,
|
|
29
|
-
url,
|
|
30
|
-
contentUrl,
|
|
31
|
-
textureUrl,
|
|
32
|
-
attributeUrls,
|
|
33
|
-
isDracoGeometry: false
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
exports.normalizeTileData = normalizeTileData;
|
|
37
|
-
function normalizeTileNonUrlData(tile) {
|
|
38
|
-
const boundingVolume = {};
|
|
39
|
-
let mbs = [0, 0, 0, 1];
|
|
40
|
-
if (tile.mbs) {
|
|
41
|
-
mbs = tile.mbs;
|
|
42
|
-
boundingVolume.sphere = [
|
|
43
|
-
...geospatial_1.Ellipsoid.WGS84.cartographicToCartesian(tile.mbs.slice(0, 3)),
|
|
44
|
-
tile.mbs[3] // radius of sphere
|
|
45
|
-
];
|
|
46
|
-
}
|
|
47
|
-
else if (tile.obb) {
|
|
48
|
-
boundingVolume.box = [
|
|
49
|
-
...geospatial_1.Ellipsoid.WGS84.cartographicToCartesian(tile.obb.center),
|
|
50
|
-
...tile.obb.halfSize,
|
|
51
|
-
...tile.obb.quaternion // quaternion
|
|
52
|
-
];
|
|
53
|
-
const obb = new culling_1.OrientedBoundingBox().fromCenterHalfSizeQuaternion(boundingVolume.box.slice(0, 3), tile.obb.halfSize, tile.obb.quaternion);
|
|
54
|
-
const boundingSphere = obb.getBoundingSphere();
|
|
55
|
-
boundingVolume.sphere = [...boundingSphere.center, boundingSphere.radius];
|
|
56
|
-
mbs = [...tile.obb.center, boundingSphere.radius];
|
|
57
|
-
}
|
|
58
|
-
const lodMetricType = tile.lodSelection?.[0].metricType;
|
|
59
|
-
const lodMetricValue = tile.lodSelection?.[0].maxError;
|
|
60
|
-
const transformMatrix = tile.transform;
|
|
61
|
-
const type = tiles_1.TILE_TYPE.MESH;
|
|
62
|
-
/**
|
|
63
|
-
* I3S specification supports only REPLACE
|
|
64
|
-
*/
|
|
65
|
-
const refine = tiles_1.TILE_REFINEMENT.REPLACE;
|
|
66
|
-
return { ...tile, mbs, boundingVolume, lodMetricType, lodMetricValue, transformMatrix, type, refine };
|
|
67
|
-
}
|
|
68
|
-
exports.normalizeTileNonUrlData = normalizeTileNonUrlData;
|
|
69
|
-
async function normalizeTilesetData(tileset, options, context) {
|
|
70
|
-
tileset.url = context.url;
|
|
71
|
-
if (tileset.nodePages) {
|
|
72
|
-
tileset.nodePagesTile = new i3s_nodepages_tiles_1.default(tileset, options);
|
|
73
|
-
tileset.root = tileset.nodePagesTile.formTileFromNodePages(0);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
// @ts-expect-error options is not properly typed
|
|
77
|
-
const rootNodeUrl = (0, url_utils_1.getUrlWithToken)(`${tileset.url}/nodes/root`, options.i3s?.token);
|
|
78
|
-
// eslint-disable-next-line no-use-before-define
|
|
79
|
-
tileset.root = await (0, core_1.load)(rootNodeUrl, tileset.loader, {
|
|
80
|
-
...options,
|
|
81
|
-
i3s: {
|
|
82
|
-
// @ts-expect-error options is not properly typed
|
|
83
|
-
...options.i3s,
|
|
84
|
-
loadContent: false, isTileHeader: true, isTileset: false
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
// base path that non-absolute paths in tileset are relative to.
|
|
89
|
-
tileset.basePath = tileset.url;
|
|
90
|
-
tileset.type = tiles_1.TILESET_TYPE.I3S;
|
|
91
|
-
// populate from root node
|
|
92
|
-
tileset.lodMetricType = tileset.root.lodMetricType;
|
|
93
|
-
tileset.lodMetricValue = tileset.root.lodMetricValue;
|
|
94
|
-
}
|
|
95
|
-
exports.normalizeTilesetData = normalizeTilesetData;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-slpk.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-slpk/parse-slpk.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AAehE,wBAAsB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,GAAE,iBAAsB,mBAgDjF"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseSLPK = void 0;
|
|
4
|
-
const cd_file_header_1 = require("../parse-zip/cd-file-header");
|
|
5
|
-
const local_file_header_1 = require("../parse-zip/local-file-header");
|
|
6
|
-
const slpk_archieve_1 = require("./slpk-archieve");
|
|
7
|
-
/**
|
|
8
|
-
* Returns one byte from the provided buffer at the provided position
|
|
9
|
-
* @param offset - position where to read
|
|
10
|
-
* @param buffer - buffer to read
|
|
11
|
-
* @returns one byte from the provided buffer at the provided position
|
|
12
|
-
*/
|
|
13
|
-
const getByteAt = (offset, buffer) => {
|
|
14
|
-
return buffer.getUint8(buffer.byteOffset + offset);
|
|
15
|
-
};
|
|
16
|
-
async function parseSLPK(data, options = {}) {
|
|
17
|
-
const archive = new DataView(data);
|
|
18
|
-
const cdFileHeaderSignature = [80, 75, 1, 2];
|
|
19
|
-
const searchWindow = [
|
|
20
|
-
getByteAt(archive.byteLength - 1, archive),
|
|
21
|
-
getByteAt(archive.byteLength - 2, archive),
|
|
22
|
-
getByteAt(archive.byteLength - 3, archive),
|
|
23
|
-
undefined
|
|
24
|
-
];
|
|
25
|
-
let hashCDOffset = 0;
|
|
26
|
-
// looking for the last record in the central directory
|
|
27
|
-
for (let i = archive.byteLength - 4; i > -1; i--) {
|
|
28
|
-
searchWindow[3] = searchWindow[2];
|
|
29
|
-
searchWindow[2] = searchWindow[1];
|
|
30
|
-
searchWindow[1] = searchWindow[0];
|
|
31
|
-
searchWindow[0] = getByteAt(i, archive);
|
|
32
|
-
if (searchWindow.every((val, index) => val === cdFileHeaderSignature[index])) {
|
|
33
|
-
hashCDOffset = i;
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
const cdFileHeader = (0, cd_file_header_1.parseZipCDFileHeader)(hashCDOffset, archive);
|
|
38
|
-
const textDecoder = new TextDecoder();
|
|
39
|
-
if (textDecoder.decode(cdFileHeader.fileName) !== '@specialIndexFileHASH128@') {
|
|
40
|
-
throw new Error('No hash file in slpk');
|
|
41
|
-
}
|
|
42
|
-
const localFileHeader = (0, local_file_header_1.parseZipLocalFileHeader)(cdFileHeader.localHeaderOffset, archive);
|
|
43
|
-
const fileDataOffset = localFileHeader.fileDataOffset;
|
|
44
|
-
const hashFile = archive.buffer.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
|
|
45
|
-
if (!hashFile) {
|
|
46
|
-
throw new Error('No hash file in slpk');
|
|
47
|
-
}
|
|
48
|
-
return await new slpk_archieve_1.SLPKArchive(data, hashFile).getFile(options.slpk?.path ?? '', options.slpk?.pathMode);
|
|
49
|
-
}
|
|
50
|
-
exports.parseSLPK = parseSLPK;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"slpk-archieve.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-slpk/slpk-archieve.ts"],"names":[],"mappings":";AAoDA;;GAEG;AACH,qBAAa,WAAW;IACtB,WAAW,EAAE,QAAQ,CAAC;IACtB,SAAS,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;gBAChC,iBAAiB,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW;IAKjE;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAqBrB;;;;;OAKG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,GAAG,KAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IA8B1E;;;;OAIG;YACW,aAAa;IAiB3B;;;;OAIG;IACH,OAAO,CAAC,YAAY;CAmBrB"}
|