@loaders.gl/i3s 4.0.0-beta.2 → 4.0.0-beta.4
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.map +1 -0
- package/dist/{esm/arcgis-webscene-loader.js → arcgis-webscene-loader.js} +2 -2
- package/dist/arcgis-webscene-loader.js.map +1 -0
- package/dist/dist.dev.js +14346 -0
- package/dist/i3s-attribute-loader.d.ts.map +1 -0
- package/dist/{esm/i3s-attribute-loader.js → i3s-attribute-loader.js} +3 -3
- package/dist/i3s-attribute-loader.js.map +1 -0
- package/dist/i3s-building-scene-layer-loader.d.ts.map +1 -0
- package/dist/{esm/i3s-building-scene-layer-loader.js → i3s-building-scene-layer-loader.js} +2 -2
- package/dist/i3s-building-scene-layer-loader.js.map +1 -0
- package/dist/i3s-content-loader.d.ts.map +1 -0
- package/dist/{esm/i3s-content-loader.js → i3s-content-loader.js} +2 -2
- package/dist/i3s-content-loader.js.map +1 -0
- package/dist/i3s-content-worker-node.js +300 -155
- package/dist/i3s-content-worker-node.js.map +4 -4
- package/dist/i3s-content-worker.js +1343 -489
- package/dist/i3s-loader.d.ts.map +1 -0
- package/dist/{esm/i3s-loader.js → i3s-loader.js} +8 -6
- package/dist/i3s-loader.js.map +1 -0
- package/dist/i3s-node-page-loader.d.ts.map +1 -0
- package/dist/{esm/i3s-node-page-loader.js → i3s-node-page-loader.js} +1 -1
- package/dist/i3s-node-page-loader.js.map +1 -0
- package/dist/{src/i3s-slpk-loader.d.ts → i3s-slpk-loader.d.ts} +3 -1
- package/dist/i3s-slpk-loader.d.ts.map +1 -0
- package/dist/i3s-slpk-loader.js +19 -0
- package/dist/i3s-slpk-loader.js.map +1 -0
- package/dist/index.cjs +1597 -0
- package/dist/{src/index.d.ts → index.d.ts} +2 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/helpers/i3s-nodepages-tiles.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/helpers/i3s-nodepages-tiles.js +16 -17
- package/dist/lib/helpers/i3s-nodepages-tiles.js.map +1 -0
- package/dist/lib/parsers/constants.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/parsers/constants.js +2 -2
- package/dist/lib/parsers/constants.js.map +1 -0
- package/dist/lib/parsers/parse-arcgis-webscene.d.ts.map +1 -0
- package/dist/lib/parsers/parse-arcgis-webscene.js.map +1 -0
- package/dist/lib/parsers/parse-i3s-attribute.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/parsers/parse-i3s-attribute.js +1 -1
- package/dist/lib/parsers/parse-i3s-attribute.js.map +1 -0
- package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/parsers/parse-i3s-building-scene-layer.js +1 -1
- package/dist/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -0
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/parsers/parse-i3s-tile-content.js +6 -5
- package/dist/lib/parsers/parse-i3s-tile-content.js.map +1 -0
- package/dist/lib/parsers/parse-i3s.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/parsers/parse-i3s.js +7 -7
- package/dist/lib/parsers/parse-i3s.js.map +1 -0
- package/dist/{src/lib → lib}/parsers/parse-slpk/parse-slpk.d.ts +1 -1
- package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/parsers/parse-slpk/parse-slpk.js +9 -11
- package/dist/lib/parsers/parse-slpk/parse-slpk.js.map +1 -0
- package/dist/{src/lib → lib}/parsers/parse-slpk/slpk-archieve.d.ts +10 -7
- package/dist/lib/parsers/parse-slpk/slpk-archieve.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/parsers/parse-slpk/slpk-archieve.js +21 -21
- package/dist/lib/parsers/parse-slpk/slpk-archieve.js.map +1 -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.map +1 -0
- package/dist/lib/utils/customize-/321/201olors.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/utils/customize-/321/201olors.js +2 -2
- package/dist/lib/utils/customize-/321/201olors.js.map +1 -0
- package/dist/{src/lib → lib}/utils/url-utils.d.ts +6 -0
- package/dist/lib/utils/url-utils.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/utils/url-utils.js +11 -3
- package/dist/lib/utils/url-utils.js.map +1 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js.map +1 -0
- package/dist/workers/i3s-content-worker-node.d.ts.map +1 -0
- package/dist/{esm/workers → workers}/i3s-content-worker-node.js +1 -1
- package/dist/workers/i3s-content-worker-node.js.map +1 -0
- package/dist/workers/i3s-content-worker.d.ts.map +1 -0
- package/dist/workers/i3s-content-worker.js +4 -0
- package/dist/workers/i3s-content-worker.js.map +1 -0
- package/package.json +26 -18
- package/src/i3s-loader.ts +5 -2
- package/src/i3s-slpk-loader.ts +9 -18
- package/src/index.ts +3 -1
- package/src/lib/parsers/parse-i3s-tile-content.ts +2 -1
- package/src/lib/parsers/parse-i3s.ts +2 -2
- package/src/lib/parsers/parse-slpk/parse-slpk.ts +13 -13
- package/src/lib/parsers/parse-slpk/slpk-archieve.ts +27 -19
- package/src/lib/utils/url-utils.ts +17 -0
- package/dist/dist.min.js +0 -15742
- package/dist/es5/arcgis-webscene-loader.js +0 -40
- package/dist/es5/arcgis-webscene-loader.js.map +0 -1
- package/dist/es5/bundle.js +0 -6
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/i3s-attribute-loader.js +0 -195
- package/dist/es5/i3s-attribute-loader.js.map +0 -1
- package/dist/es5/i3s-building-scene-layer-loader.js +0 -46
- package/dist/es5/i3s-building-scene-layer-loader.js.map +0 -1
- package/dist/es5/i3s-content-loader.js +0 -56
- package/dist/es5/i3s-content-loader.js.map +0 -1
- package/dist/es5/i3s-loader.js +0 -193
- package/dist/es5/i3s-loader.js.map +0 -1
- package/dist/es5/i3s-node-page-loader.js +0 -41
- package/dist/es5/i3s-node-page-loader.js.map +0 -1
- package/dist/es5/i3s-slpk-loader.js +0 -48
- package/dist/es5/i3s-slpk-loader.js.map +0 -1
- package/dist/es5/index.js +0 -75
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +0 -316
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +0 -1
- package/dist/es5/lib/parsers/constants.js +0 -71
- package/dist/es5/lib/parsers/constants.js.map +0 -1
- package/dist/es5/lib/parsers/parse-arcgis-webscene.js +0 -158
- package/dist/es5/lib/parsers/parse-arcgis-webscene.js.map +0 -1
- package/dist/es5/lib/parsers/parse-i3s-attribute.js +0 -76
- package/dist/es5/lib/parsers/parse-i3s-attribute.js.map +0 -1
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js +0 -65
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js.map +0 -1
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js +0 -513
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +0 -1
- package/dist/es5/lib/parsers/parse-i3s.js +0 -128
- package/dist/es5/lib/parsers/parse-i3s.js.map +0 -1
- package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js +0 -69
- package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js.map +0 -1
- package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js +0 -254
- package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js.map +0 -1
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js +0 -17
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js.map +0 -1
- package/dist/es5/lib/utils/customize-/321/201olors.js +0 -184
- package/dist/es5/lib/utils/customize-/321/201olors.js.map +0 -1
- package/dist/es5/lib/utils/url-utils.js +0 -33
- package/dist/es5/lib/utils/url-utils.js.map +0 -1
- package/dist/es5/types.js +0 -13
- package/dist/es5/types.js.map +0 -1
- package/dist/es5/workers/i3s-content-worker-node.js +0 -7
- package/dist/es5/workers/i3s-content-worker-node.js.map +0 -1
- package/dist/es5/workers/i3s-content-worker.js +0 -6
- package/dist/es5/workers/i3s-content-worker.js.map +0 -1
- package/dist/esm/arcgis-webscene-loader.js.map +0 -1
- package/dist/esm/bundle.js +0 -4
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/i3s-attribute-loader.js.map +0 -1
- package/dist/esm/i3s-building-scene-layer-loader.js.map +0 -1
- package/dist/esm/i3s-content-loader.js.map +0 -1
- package/dist/esm/i3s-loader.js.map +0 -1
- package/dist/esm/i3s-node-page-loader.js.map +0 -1
- package/dist/esm/i3s-slpk-loader.js +0 -19
- package/dist/esm/i3s-slpk-loader.js.map +0 -1
- package/dist/esm/index.js +0 -10
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js.map +0 -1
- package/dist/esm/lib/parsers/constants.js.map +0 -1
- package/dist/esm/lib/parsers/parse-arcgis-webscene.js.map +0 -1
- package/dist/esm/lib/parsers/parse-i3s-attribute.js.map +0 -1
- package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js.map +0 -1
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +0 -1
- package/dist/esm/lib/parsers/parse-i3s.js.map +0 -1
- package/dist/esm/lib/parsers/parse-slpk/parse-slpk.js.map +0 -1
- package/dist/esm/lib/parsers/parse-slpk/slpk-archieve.js.map +0 -1
- package/dist/esm/lib/utils/convert-i3s-obb-to-mbs.js.map +0 -1
- package/dist/esm/lib/utils/customize-/321/201olors.js.map +0 -1
- package/dist/esm/lib/utils/url-utils.js.map +0 -1
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/workers/i3s-content-worker-node.js.map +0 -1
- package/dist/esm/workers/i3s-content-worker.js +0 -4
- package/dist/esm/workers/i3s-content-worker.js.map +0 -1
- package/dist/src/arcgis-webscene-loader.d.ts.map +0 -1
- package/dist/src/bundle.d.ts +0 -2
- package/dist/src/bundle.d.ts.map +0 -1
- package/dist/src/i3s-attribute-loader.d.ts.map +0 -1
- package/dist/src/i3s-building-scene-layer-loader.d.ts.map +0 -1
- package/dist/src/i3s-content-loader.d.ts.map +0 -1
- package/dist/src/i3s-loader.d.ts.map +0 -1
- package/dist/src/i3s-node-page-loader.d.ts.map +0 -1
- package/dist/src/i3s-slpk-loader.d.ts.map +0 -1
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/lib/helpers/i3s-nodepages-tiles.d.ts.map +0 -1
- package/dist/src/lib/parsers/constants.d.ts.map +0 -1
- package/dist/src/lib/parsers/parse-arcgis-webscene.d.ts.map +0 -1
- package/dist/src/lib/parsers/parse-i3s-attribute.d.ts.map +0 -1
- package/dist/src/lib/parsers/parse-i3s-building-scene-layer.d.ts.map +0 -1
- package/dist/src/lib/parsers/parse-i3s-tile-content.d.ts.map +0 -1
- package/dist/src/lib/parsers/parse-i3s.d.ts.map +0 -1
- package/dist/src/lib/parsers/parse-slpk/parse-slpk.d.ts.map +0 -1
- package/dist/src/lib/parsers/parse-slpk/slpk-archieve.d.ts.map +0 -1
- package/dist/src/lib/utils/convert-i3s-obb-to-mbs.d.ts.map +0 -1
- package/dist/src/lib/utils/customize-/321/201olors.d.ts.map +0 -1
- package/dist/src/lib/utils/url-utils.d.ts.map +0 -1
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/workers/i3s-content-worker-node.d.ts.map +0 -1
- package/dist/src/workers/i3s-content-worker.d.ts.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/bundle.ts +0 -4
- /package/dist/{src/arcgis-webscene-loader.d.ts → arcgis-webscene-loader.d.ts} +0 -0
- /package/dist/{src/i3s-attribute-loader.d.ts → i3s-attribute-loader.d.ts} +0 -0
- /package/dist/{src/i3s-building-scene-layer-loader.d.ts → i3s-building-scene-layer-loader.d.ts} +0 -0
- /package/dist/{src/i3s-content-loader.d.ts → i3s-content-loader.d.ts} +0 -0
- /package/dist/{src/i3s-loader.d.ts → i3s-loader.d.ts} +0 -0
- /package/dist/{src/i3s-node-page-loader.d.ts → i3s-node-page-loader.d.ts} +0 -0
- /package/dist/{src/lib → lib}/helpers/i3s-nodepages-tiles.d.ts +0 -0
- /package/dist/{src/lib → lib}/parsers/constants.d.ts +0 -0
- /package/dist/{src/lib → lib}/parsers/parse-arcgis-webscene.d.ts +0 -0
- /package/dist/{esm/lib → lib}/parsers/parse-arcgis-webscene.js +0 -0
- /package/dist/{src/lib → lib}/parsers/parse-i3s-attribute.d.ts +0 -0
- /package/dist/{src/lib → lib}/parsers/parse-i3s-building-scene-layer.d.ts +0 -0
- /package/dist/{src/lib → lib}/parsers/parse-i3s-tile-content.d.ts +0 -0
- /package/dist/{src/lib → lib}/parsers/parse-i3s.d.ts +0 -0
- /package/dist/{src/lib → lib}/utils/convert-i3s-obb-to-mbs.d.ts +0 -0
- /package/dist/{esm/lib → lib}/utils/convert-i3s-obb-to-mbs.js +0 -0
- /package/dist/{src/lib → lib}/utils/customize-/321/201olors.d.ts" +0 -0
- /package/dist/{src/types.d.ts → types.d.ts} +0 -0
- /package/dist/{esm/types.js → types.js} +0 -0
- /package/dist/{src/workers → workers}/i3s-content-worker-node.d.ts +0 -0
- /package/dist/{src/workers → workers}/i3s-content-worker.d.ts +0 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1597 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
ArcGISWebSceneLoader: () => ArcGISWebSceneLoader,
|
|
34
|
+
COORDINATE_SYSTEM: () => COORDINATE_SYSTEM,
|
|
35
|
+
I3SAttributeLoader: () => I3SAttributeLoader,
|
|
36
|
+
I3SBuildingSceneLayerLoader: () => I3SBuildingSceneLayerLoader,
|
|
37
|
+
I3SContentLoader: () => I3SContentLoader,
|
|
38
|
+
I3SLoader: () => I3SLoader,
|
|
39
|
+
I3SNodePageLoader: () => I3SNodePageLoader,
|
|
40
|
+
SLPKLoader: () => SLPKLoader,
|
|
41
|
+
loadFeatureAttributes: () => loadFeatureAttributes,
|
|
42
|
+
parseSLPKArchive: () => parseSLPKArchive
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(src_exports);
|
|
45
|
+
|
|
46
|
+
// src/lib/parsers/constants.ts
|
|
47
|
+
var import_constants = __toESM(require("@luma.gl/constants"), 1);
|
|
48
|
+
function getConstructorForDataFormat(dataType) {
|
|
49
|
+
switch (dataType) {
|
|
50
|
+
case "UInt8":
|
|
51
|
+
return Uint8Array;
|
|
52
|
+
case "UInt16":
|
|
53
|
+
return Uint16Array;
|
|
54
|
+
case "UInt32":
|
|
55
|
+
return Uint32Array;
|
|
56
|
+
case "Float32":
|
|
57
|
+
return Float32Array;
|
|
58
|
+
case "UInt64":
|
|
59
|
+
return Float64Array;
|
|
60
|
+
default:
|
|
61
|
+
throw new Error(`parse i3s tile content: unknown type of data: ${dataType}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
var GL_TYPE_MAP = {
|
|
65
|
+
UInt8: import_constants.default.UNSIGNED_BYTE,
|
|
66
|
+
UInt16: import_constants.default.UNSIGNED_SHORT,
|
|
67
|
+
Float32: import_constants.default.FLOAT,
|
|
68
|
+
UInt32: import_constants.default.UNSIGNED_INT,
|
|
69
|
+
UInt64: import_constants.default.DOUBLE
|
|
70
|
+
};
|
|
71
|
+
function sizeOf(dataType) {
|
|
72
|
+
switch (dataType) {
|
|
73
|
+
case "UInt8":
|
|
74
|
+
return 1;
|
|
75
|
+
case "UInt16":
|
|
76
|
+
case "Int16":
|
|
77
|
+
return 2;
|
|
78
|
+
case "UInt32":
|
|
79
|
+
case "Int32":
|
|
80
|
+
case "Float32":
|
|
81
|
+
return 4;
|
|
82
|
+
case "UInt64":
|
|
83
|
+
case "Int64":
|
|
84
|
+
case "Float64":
|
|
85
|
+
return 8;
|
|
86
|
+
default:
|
|
87
|
+
throw new Error(`parse i3s tile content: unknown size of data: ${dataType}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
var STRING_ATTRIBUTE_TYPE = "String";
|
|
91
|
+
var OBJECT_ID_ATTRIBUTE_TYPE = "Oid32";
|
|
92
|
+
var FLOAT_64_TYPE = "Float64";
|
|
93
|
+
var INT_16_ATTRIBUTE_TYPE = "Int16";
|
|
94
|
+
var COORDINATE_SYSTEM = /* @__PURE__ */ ((COORDINATE_SYSTEM2) => {
|
|
95
|
+
COORDINATE_SYSTEM2[COORDINATE_SYSTEM2["DEFAULT"] = -1] = "DEFAULT";
|
|
96
|
+
COORDINATE_SYSTEM2[COORDINATE_SYSTEM2["LNGLAT"] = 1] = "LNGLAT";
|
|
97
|
+
COORDINATE_SYSTEM2[COORDINATE_SYSTEM2["METER_OFFSETS"] = 2] = "METER_OFFSETS";
|
|
98
|
+
COORDINATE_SYSTEM2[COORDINATE_SYSTEM2["LNGLAT_OFFSETS"] = 3] = "LNGLAT_OFFSETS";
|
|
99
|
+
COORDINATE_SYSTEM2[COORDINATE_SYSTEM2["CARTESIAN"] = 0] = "CARTESIAN";
|
|
100
|
+
return COORDINATE_SYSTEM2;
|
|
101
|
+
})(COORDINATE_SYSTEM || {});
|
|
102
|
+
|
|
103
|
+
// src/i3s-loader.ts
|
|
104
|
+
var import_core7 = require("@loaders.gl/core");
|
|
105
|
+
|
|
106
|
+
// src/lib/parsers/parse-i3s-tile-content.ts
|
|
107
|
+
var import_core3 = require("@loaders.gl/core");
|
|
108
|
+
var import_core4 = require("@math.gl/core");
|
|
109
|
+
var import_geospatial = require("@math.gl/geospatial");
|
|
110
|
+
var import_loader_utils = require("@loaders.gl/loader-utils");
|
|
111
|
+
var import_images = require("@loaders.gl/images");
|
|
112
|
+
var import_draco = require("@loaders.gl/draco");
|
|
113
|
+
var import_textures = require("@loaders.gl/textures");
|
|
114
|
+
|
|
115
|
+
// src/lib/utils/url-utils.ts
|
|
116
|
+
function getUrlWithoutParams(url) {
|
|
117
|
+
let urlWithoutParams;
|
|
118
|
+
try {
|
|
119
|
+
const urlObj = new URL(url);
|
|
120
|
+
urlWithoutParams = `${urlObj.origin}${urlObj.pathname}`;
|
|
121
|
+
} catch (e) {
|
|
122
|
+
}
|
|
123
|
+
return urlWithoutParams || url;
|
|
124
|
+
}
|
|
125
|
+
function getUrlWithToken(url, token = null) {
|
|
126
|
+
return token ? `${url}?token=${token}` : url;
|
|
127
|
+
}
|
|
128
|
+
function generateTileAttributeUrls(url, tile) {
|
|
129
|
+
const { attributeData = [] } = tile;
|
|
130
|
+
const attributeUrls = [];
|
|
131
|
+
for (let index = 0; index < attributeData.length; index++) {
|
|
132
|
+
const attributeUrl = attributeData[index].href.replace("./", "");
|
|
133
|
+
attributeUrls.push(`${url}/${attributeUrl}`);
|
|
134
|
+
}
|
|
135
|
+
return attributeUrls;
|
|
136
|
+
}
|
|
137
|
+
function generateTilesetAttributeUrls(tileset, url, resource) {
|
|
138
|
+
const attributeUrls = [];
|
|
139
|
+
const { attributeStorageInfo = [] } = tileset;
|
|
140
|
+
for (let index = 0; index < attributeStorageInfo.length; index++) {
|
|
141
|
+
const fileName = attributeStorageInfo[index].key;
|
|
142
|
+
attributeUrls.push(`${url}/nodes/${resource}/attributes/${fileName}/0`);
|
|
143
|
+
}
|
|
144
|
+
return attributeUrls;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// src/lib/utils/customize-сolors.ts
|
|
148
|
+
var import_core2 = require("@loaders.gl/core");
|
|
149
|
+
|
|
150
|
+
// src/i3s-attribute-loader.ts
|
|
151
|
+
var import_core = require("@loaders.gl/core");
|
|
152
|
+
|
|
153
|
+
// src/lib/parsers/parse-i3s-attribute.ts
|
|
154
|
+
function parseI3STileAttribute(arrayBuffer, options) {
|
|
155
|
+
const { attributeName, attributeType } = options;
|
|
156
|
+
if (!attributeName) {
|
|
157
|
+
return {};
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
[attributeName]: attributeType ? parseAttribute(attributeType, arrayBuffer) : null
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function parseAttribute(attributeType, arrayBuffer) {
|
|
164
|
+
switch (attributeType) {
|
|
165
|
+
case STRING_ATTRIBUTE_TYPE:
|
|
166
|
+
return parseStringsAttribute(arrayBuffer);
|
|
167
|
+
case OBJECT_ID_ATTRIBUTE_TYPE:
|
|
168
|
+
return parseShortNumberAttribute(arrayBuffer);
|
|
169
|
+
case FLOAT_64_TYPE:
|
|
170
|
+
return parseFloatAttribute(arrayBuffer);
|
|
171
|
+
case INT_16_ATTRIBUTE_TYPE:
|
|
172
|
+
return parseInt16ShortNumberAttribute(arrayBuffer);
|
|
173
|
+
default:
|
|
174
|
+
return parseShortNumberAttribute(arrayBuffer);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function parseShortNumberAttribute(arrayBuffer) {
|
|
178
|
+
const countOffset = 4;
|
|
179
|
+
return new Uint32Array(arrayBuffer, countOffset);
|
|
180
|
+
}
|
|
181
|
+
function parseInt16ShortNumberAttribute(arrayBuffer) {
|
|
182
|
+
const countOffset = 4;
|
|
183
|
+
return new Int16Array(arrayBuffer, countOffset);
|
|
184
|
+
}
|
|
185
|
+
function parseFloatAttribute(arrayBuffer) {
|
|
186
|
+
const countOffset = 8;
|
|
187
|
+
return new Float64Array(arrayBuffer, countOffset);
|
|
188
|
+
}
|
|
189
|
+
function parseStringsAttribute(arrayBuffer) {
|
|
190
|
+
const stringsCountOffset = 0;
|
|
191
|
+
const dataOffset = 8;
|
|
192
|
+
const bytesPerStringSize = 4;
|
|
193
|
+
const stringsArray = [];
|
|
194
|
+
try {
|
|
195
|
+
const stringsCount = new DataView(
|
|
196
|
+
arrayBuffer,
|
|
197
|
+
stringsCountOffset,
|
|
198
|
+
bytesPerStringSize
|
|
199
|
+
).getUint32(stringsCountOffset, true);
|
|
200
|
+
const stringSizes = new Uint32Array(arrayBuffer, dataOffset, stringsCount);
|
|
201
|
+
let stringOffset = dataOffset + stringsCount * bytesPerStringSize;
|
|
202
|
+
for (const stringByteSize of stringSizes) {
|
|
203
|
+
const textDecoder = new TextDecoder("utf-8");
|
|
204
|
+
const stringAttribute = new Uint8Array(arrayBuffer, stringOffset, stringByteSize);
|
|
205
|
+
stringsArray.push(textDecoder.decode(stringAttribute));
|
|
206
|
+
stringOffset += stringByteSize;
|
|
207
|
+
}
|
|
208
|
+
} catch (error) {
|
|
209
|
+
console.error("Parse string attribute error: ", error.message);
|
|
210
|
+
}
|
|
211
|
+
return stringsArray;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// src/i3s-attribute-loader.ts
|
|
215
|
+
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
216
|
+
var EMPTY_VALUE = "";
|
|
217
|
+
var REJECTED_STATUS = "rejected";
|
|
218
|
+
var I3SAttributeLoader = {
|
|
219
|
+
name: "I3S Attribute",
|
|
220
|
+
id: "i3s-attribute",
|
|
221
|
+
module: "i3s",
|
|
222
|
+
version: VERSION,
|
|
223
|
+
mimeTypes: ["application/binary"],
|
|
224
|
+
parse: async (arrayBuffer, options) => parseI3STileAttribute(arrayBuffer, options),
|
|
225
|
+
extensions: ["bin"],
|
|
226
|
+
options: {},
|
|
227
|
+
binary: true
|
|
228
|
+
};
|
|
229
|
+
async function loadFeatureAttributes(tile, featureId, options = {}) {
|
|
230
|
+
var _a;
|
|
231
|
+
const { attributeStorageInfo, attributeUrls, tilesetFields } = getAttributesData(tile);
|
|
232
|
+
if (!attributeStorageInfo || !attributeUrls || featureId < 0) {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
let attributes = [];
|
|
236
|
+
const attributeLoadPromises = [];
|
|
237
|
+
for (let index = 0; index < attributeStorageInfo.length; index++) {
|
|
238
|
+
const url = getUrlWithToken(attributeUrls[index], (_a = options.i3s) == null ? void 0 : _a.token);
|
|
239
|
+
const attributeName = attributeStorageInfo[index].name;
|
|
240
|
+
const attributeType = getAttributeValueType(attributeStorageInfo[index]);
|
|
241
|
+
const loadOptions = { ...options, attributeName, attributeType };
|
|
242
|
+
const promise = (0, import_core.load)(url, I3SAttributeLoader, loadOptions);
|
|
243
|
+
attributeLoadPromises.push(promise);
|
|
244
|
+
}
|
|
245
|
+
try {
|
|
246
|
+
attributes = await Promise.allSettled(attributeLoadPromises);
|
|
247
|
+
} catch (error) {
|
|
248
|
+
}
|
|
249
|
+
if (!attributes.length) {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
return generateAttributesByFeatureId(attributes, attributeStorageInfo, featureId, tilesetFields);
|
|
253
|
+
}
|
|
254
|
+
function getAttributesData(tile) {
|
|
255
|
+
var _a, _b, _c, _d, _e;
|
|
256
|
+
const attributeStorageInfo = (_b = (_a = tile.tileset) == null ? void 0 : _a.tileset) == null ? void 0 : _b.attributeStorageInfo;
|
|
257
|
+
const attributeUrls = (_c = tile.header) == null ? void 0 : _c.attributeUrls;
|
|
258
|
+
const tilesetFields = ((_e = (_d = tile.tileset) == null ? void 0 : _d.tileset) == null ? void 0 : _e.fields) || [];
|
|
259
|
+
return { attributeStorageInfo, attributeUrls, tilesetFields };
|
|
260
|
+
}
|
|
261
|
+
function getAttributeValueType(attribute) {
|
|
262
|
+
if (attribute.hasOwnProperty("objectIds")) {
|
|
263
|
+
return "Oid32";
|
|
264
|
+
} else if (attribute.hasOwnProperty("attributeValues")) {
|
|
265
|
+
return attribute.attributeValues.valueType;
|
|
266
|
+
}
|
|
267
|
+
return "";
|
|
268
|
+
}
|
|
269
|
+
function getFeatureIdsAttributeName(attributeStorageInfo) {
|
|
270
|
+
const objectIdsAttribute = attributeStorageInfo.find((attribute) => attribute.name.includes("OBJECTID"));
|
|
271
|
+
return objectIdsAttribute == null ? void 0 : objectIdsAttribute.name;
|
|
272
|
+
}
|
|
273
|
+
function generateAttributesByFeatureId(attributes, attributeStorageInfo, featureId, tilesetFields) {
|
|
274
|
+
const objectIdsAttributeName = getFeatureIdsAttributeName(attributeStorageInfo);
|
|
275
|
+
const objectIds = attributes.find((attribute) => attribute.value[objectIdsAttributeName]);
|
|
276
|
+
if (!objectIds) {
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
const attributeIndex = objectIds.value[objectIdsAttributeName].indexOf(featureId);
|
|
280
|
+
if (attributeIndex < 0) {
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
return getFeatureAttributesByIndex(attributes, attributeIndex, attributeStorageInfo, tilesetFields);
|
|
284
|
+
}
|
|
285
|
+
function getFeatureAttributesByIndex(attributes, featureIdIndex, attributeStorageInfo, tilesetFields) {
|
|
286
|
+
const attributesObject = {};
|
|
287
|
+
for (let index = 0; index < attributeStorageInfo.length; index++) {
|
|
288
|
+
const attributeName = attributeStorageInfo[index].name;
|
|
289
|
+
const codedValues = getAttributeCodedValues(attributeName, tilesetFields);
|
|
290
|
+
const attribute = getAttributeByIndexAndAttributeName(attributes, index, attributeName);
|
|
291
|
+
attributesObject[attributeName] = formatAttributeValue(attribute, featureIdIndex, codedValues);
|
|
292
|
+
}
|
|
293
|
+
return attributesObject;
|
|
294
|
+
}
|
|
295
|
+
function getAttributeCodedValues(attributeName, tilesetFields) {
|
|
296
|
+
var _a;
|
|
297
|
+
const attributeField = tilesetFields.find((field) => field.name === attributeName || field.alias === attributeName);
|
|
298
|
+
return ((_a = attributeField == null ? void 0 : attributeField.domain) == null ? void 0 : _a.codedValues) || [];
|
|
299
|
+
}
|
|
300
|
+
function getAttributeByIndexAndAttributeName(attributes, index, attributesName) {
|
|
301
|
+
const attributeObject = attributes[index];
|
|
302
|
+
if (attributeObject.status === REJECTED_STATUS) {
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
return attributeObject.value[attributesName];
|
|
306
|
+
}
|
|
307
|
+
function formatAttributeValue(attribute, featureIdIndex, codedValues) {
|
|
308
|
+
let value = EMPTY_VALUE;
|
|
309
|
+
if (attribute && featureIdIndex in attribute) {
|
|
310
|
+
value = String(attribute[featureIdIndex]).replace(/\u0000|NaN/g, "").trim();
|
|
311
|
+
}
|
|
312
|
+
if (codedValues.length) {
|
|
313
|
+
const codeValue = codedValues.find((codedValue) => codedValue.code === Number(value));
|
|
314
|
+
value = (codeValue == null ? void 0 : codeValue.name) || EMPTY_VALUE;
|
|
315
|
+
}
|
|
316
|
+
return value;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// src/lib/utils/customize-сolors.ts
|
|
320
|
+
async function customizeColors(colors, featureIds, tileOptions, tilesetOptions, options) {
|
|
321
|
+
var _a;
|
|
322
|
+
if (!((_a = options == null ? void 0 : options.i3s) == null ? void 0 : _a.colorsByAttribute)) {
|
|
323
|
+
return colors;
|
|
324
|
+
}
|
|
325
|
+
const colorizeAttributeField = tilesetOptions.fields.find(
|
|
326
|
+
({ name }) => {
|
|
327
|
+
var _a2, _b;
|
|
328
|
+
return name === ((_b = (_a2 = options == null ? void 0 : options.i3s) == null ? void 0 : _a2.colorsByAttribute) == null ? void 0 : _b.attributeName);
|
|
329
|
+
}
|
|
330
|
+
);
|
|
331
|
+
if (!colorizeAttributeField || !["esriFieldTypeDouble", "esriFieldTypeInteger", "esriFieldTypeSmallInteger"].includes(
|
|
332
|
+
colorizeAttributeField.type
|
|
333
|
+
)) {
|
|
334
|
+
return colors;
|
|
335
|
+
}
|
|
336
|
+
const colorizeAttributeData = await loadFeatureAttributeData(
|
|
337
|
+
colorizeAttributeField.name,
|
|
338
|
+
tileOptions,
|
|
339
|
+
tilesetOptions,
|
|
340
|
+
options
|
|
341
|
+
);
|
|
342
|
+
if (!colorizeAttributeData) {
|
|
343
|
+
return colors;
|
|
344
|
+
}
|
|
345
|
+
const objectIdField = tilesetOptions.fields.find(({ type }) => type === "esriFieldTypeOID");
|
|
346
|
+
if (!objectIdField) {
|
|
347
|
+
return colors;
|
|
348
|
+
}
|
|
349
|
+
const objectIdAttributeData = await loadFeatureAttributeData(
|
|
350
|
+
objectIdField.name,
|
|
351
|
+
tileOptions,
|
|
352
|
+
tilesetOptions,
|
|
353
|
+
options
|
|
354
|
+
);
|
|
355
|
+
if (!objectIdAttributeData) {
|
|
356
|
+
return colors;
|
|
357
|
+
}
|
|
358
|
+
const attributeValuesMap = {};
|
|
359
|
+
for (let i = 0; i < objectIdAttributeData[objectIdField.name].length; i++) {
|
|
360
|
+
attributeValuesMap[objectIdAttributeData[objectIdField.name][i]] = calculateColorForAttribute(
|
|
361
|
+
// @ts-expect-error
|
|
362
|
+
colorizeAttributeData[colorizeAttributeField.name][i],
|
|
363
|
+
options
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
for (let i = 0; i < featureIds.value.length; i++) {
|
|
367
|
+
const color = attributeValuesMap[featureIds.value[i]];
|
|
368
|
+
if (!color) {
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
if (options.i3s.colorsByAttribute.mode === "multiply") {
|
|
372
|
+
color.forEach((colorItem, index) => {
|
|
373
|
+
colors.value[i * 4 + index] = colors.value[i * 4 + index] * colorItem / 255;
|
|
374
|
+
});
|
|
375
|
+
} else {
|
|
376
|
+
colors.value.set(color, i * 4);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return colors;
|
|
380
|
+
}
|
|
381
|
+
function calculateColorForAttribute(attributeValue, options) {
|
|
382
|
+
var _a;
|
|
383
|
+
if (!((_a = options == null ? void 0 : options.i3s) == null ? void 0 : _a.colorsByAttribute)) {
|
|
384
|
+
return [255, 255, 255, 255];
|
|
385
|
+
}
|
|
386
|
+
const { minValue, maxValue, minColor, maxColor } = options.i3s.colorsByAttribute;
|
|
387
|
+
const rate = (attributeValue - minValue) / (maxValue - minValue);
|
|
388
|
+
const color = [255, 255, 255, 255];
|
|
389
|
+
for (let i = 0; i < minColor.length; i++) {
|
|
390
|
+
color[i] = Math.round((maxColor[i] - minColor[i]) * rate + minColor[i]);
|
|
391
|
+
}
|
|
392
|
+
return color;
|
|
393
|
+
}
|
|
394
|
+
async function loadFeatureAttributeData(attributeName, { attributeUrls }, { attributeStorageInfo }, options) {
|
|
395
|
+
var _a;
|
|
396
|
+
const attributeIndex = attributeStorageInfo.findIndex(({ name }) => attributeName === name);
|
|
397
|
+
if (attributeIndex === -1) {
|
|
398
|
+
return null;
|
|
399
|
+
}
|
|
400
|
+
const objectIdAttributeUrl = getUrlWithToken(attributeUrls[attributeIndex], (_a = options == null ? void 0 : options.i3s) == null ? void 0 : _a.token);
|
|
401
|
+
const attributeType = getAttributeValueType(attributeStorageInfo[attributeIndex]);
|
|
402
|
+
const objectIdAttributeData = await (0, import_core2.load)(objectIdAttributeUrl, I3SAttributeLoader, {
|
|
403
|
+
attributeName,
|
|
404
|
+
attributeType
|
|
405
|
+
});
|
|
406
|
+
return objectIdAttributeData;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// src/lib/parsers/parse-i3s-tile-content.ts
|
|
410
|
+
var scratchVector = new import_core4.Vector3([0, 0, 0]);
|
|
411
|
+
function getLoaderForTextureFormat(textureFormat) {
|
|
412
|
+
switch (textureFormat) {
|
|
413
|
+
case "ktx-etc2":
|
|
414
|
+
case "dds":
|
|
415
|
+
return import_textures.CompressedTextureLoader;
|
|
416
|
+
case "ktx2":
|
|
417
|
+
return import_textures.BasisLoader;
|
|
418
|
+
case "jpg":
|
|
419
|
+
case "png":
|
|
420
|
+
default:
|
|
421
|
+
return import_images.ImageLoader;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
var I3S_ATTRIBUTE_TYPE = "i3s-attribute-type";
|
|
425
|
+
async function parseI3STileContent(arrayBuffer, tileOptions, tilesetOptions, options, context) {
|
|
426
|
+
var _a;
|
|
427
|
+
const content = {
|
|
428
|
+
attributes: {},
|
|
429
|
+
indices: null,
|
|
430
|
+
featureIds: [],
|
|
431
|
+
vertexCount: 0,
|
|
432
|
+
modelMatrix: new import_core4.Matrix4(),
|
|
433
|
+
coordinateSystem: 0,
|
|
434
|
+
byteLength: 0,
|
|
435
|
+
texture: null
|
|
436
|
+
};
|
|
437
|
+
if (tileOptions.textureUrl) {
|
|
438
|
+
const url = getUrlWithToken(tileOptions.textureUrl, (_a = options == null ? void 0 : options.i3s) == null ? void 0 : _a.token);
|
|
439
|
+
const loader = getLoaderForTextureFormat(tileOptions.textureFormat);
|
|
440
|
+
const fetch = context == null ? void 0 : context.fetch;
|
|
441
|
+
const response = await fetch(url);
|
|
442
|
+
const arrayBuffer2 = await response.arrayBuffer();
|
|
443
|
+
if (options == null ? void 0 : options.i3s.decodeTextures) {
|
|
444
|
+
if (loader === import_images.ImageLoader) {
|
|
445
|
+
const options2 = { ...tileOptions.textureLoaderOptions, image: { type: "data" } };
|
|
446
|
+
try {
|
|
447
|
+
const texture = await (0, import_loader_utils.parseFromContext)(arrayBuffer2, [], options2, context);
|
|
448
|
+
content.texture = texture;
|
|
449
|
+
} catch (e) {
|
|
450
|
+
const texture = await (0, import_core3.parse)(arrayBuffer2, loader, options2, context);
|
|
451
|
+
content.texture = texture;
|
|
452
|
+
}
|
|
453
|
+
} else if (loader === import_textures.CompressedTextureLoader || loader === import_textures.BasisLoader) {
|
|
454
|
+
let texture = await (0, import_core3.load)(arrayBuffer2, loader, tileOptions.textureLoaderOptions);
|
|
455
|
+
if (loader === import_textures.BasisLoader) {
|
|
456
|
+
texture = texture[0];
|
|
457
|
+
}
|
|
458
|
+
content.texture = {
|
|
459
|
+
compressed: true,
|
|
460
|
+
mipmaps: false,
|
|
461
|
+
width: texture[0].width,
|
|
462
|
+
height: texture[0].height,
|
|
463
|
+
data: texture
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
} else {
|
|
467
|
+
content.texture = arrayBuffer2;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
content.material = makePbrMaterial(tileOptions.materialDefinition, content.texture);
|
|
471
|
+
if (content.material) {
|
|
472
|
+
content.texture = null;
|
|
473
|
+
}
|
|
474
|
+
return await parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options);
|
|
475
|
+
}
|
|
476
|
+
async function parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options) {
|
|
477
|
+
var _a, _b;
|
|
478
|
+
const contentByteLength = arrayBuffer.byteLength;
|
|
479
|
+
let attributes;
|
|
480
|
+
let vertexCount;
|
|
481
|
+
let byteOffset = 0;
|
|
482
|
+
let featureCount = 0;
|
|
483
|
+
let indices;
|
|
484
|
+
if (tileOptions.isDracoGeometry) {
|
|
485
|
+
const decompressedGeometry = await (0, import_core3.parse)(arrayBuffer, import_draco.DracoLoader, {
|
|
486
|
+
draco: {
|
|
487
|
+
attributeNameEntry: I3S_ATTRIBUTE_TYPE
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
vertexCount = decompressedGeometry.header.vertexCount;
|
|
491
|
+
indices = (_a = decompressedGeometry.indices) == null ? void 0 : _a.value;
|
|
492
|
+
const {
|
|
493
|
+
POSITION,
|
|
494
|
+
NORMAL,
|
|
495
|
+
COLOR_0,
|
|
496
|
+
TEXCOORD_0,
|
|
497
|
+
["feature-index"]: featureIndex,
|
|
498
|
+
["uv-region"]: uvRegion
|
|
499
|
+
} = decompressedGeometry.attributes;
|
|
500
|
+
attributes = {
|
|
501
|
+
position: POSITION,
|
|
502
|
+
normal: NORMAL,
|
|
503
|
+
color: COLOR_0,
|
|
504
|
+
uv0: TEXCOORD_0,
|
|
505
|
+
uvRegion,
|
|
506
|
+
id: featureIndex
|
|
507
|
+
};
|
|
508
|
+
updateAttributesMetadata(attributes, decompressedGeometry);
|
|
509
|
+
const featureIds = getFeatureIdsFromFeatureIndexMetadata(featureIndex);
|
|
510
|
+
if (featureIds) {
|
|
511
|
+
flattenFeatureIdsByFeatureIndices(attributes, featureIds);
|
|
512
|
+
}
|
|
513
|
+
} else {
|
|
514
|
+
const {
|
|
515
|
+
vertexAttributes,
|
|
516
|
+
ordering: attributesOrder,
|
|
517
|
+
featureAttributes,
|
|
518
|
+
featureAttributeOrder
|
|
519
|
+
} = tilesetOptions.store.defaultGeometrySchema;
|
|
520
|
+
const headers = parseHeaders(arrayBuffer, tilesetOptions);
|
|
521
|
+
byteOffset = headers.byteOffset;
|
|
522
|
+
vertexCount = headers.vertexCount;
|
|
523
|
+
featureCount = headers.featureCount;
|
|
524
|
+
const { attributes: normalizedVertexAttributes, byteOffset: offset } = normalizeAttributes(
|
|
525
|
+
arrayBuffer,
|
|
526
|
+
byteOffset,
|
|
527
|
+
vertexAttributes,
|
|
528
|
+
vertexCount,
|
|
529
|
+
attributesOrder
|
|
530
|
+
);
|
|
531
|
+
const { attributes: normalizedFeatureAttributes } = normalizeAttributes(
|
|
532
|
+
arrayBuffer,
|
|
533
|
+
offset,
|
|
534
|
+
featureAttributes,
|
|
535
|
+
featureCount,
|
|
536
|
+
featureAttributeOrder
|
|
537
|
+
);
|
|
538
|
+
flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes);
|
|
539
|
+
attributes = concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes);
|
|
540
|
+
}
|
|
541
|
+
if (!((_b = options == null ? void 0 : options.i3s) == null ? void 0 : _b.coordinateSystem) || options.i3s.coordinateSystem === 2 /* METER_OFFSETS */) {
|
|
542
|
+
const enuMatrix = parsePositions(attributes.position, tileOptions);
|
|
543
|
+
content.modelMatrix = enuMatrix.invert();
|
|
544
|
+
content.coordinateSystem = 2 /* METER_OFFSETS */;
|
|
545
|
+
} else {
|
|
546
|
+
content.modelMatrix = getModelMatrix(attributes.position);
|
|
547
|
+
content.coordinateSystem = 3 /* LNGLAT_OFFSETS */;
|
|
548
|
+
}
|
|
549
|
+
attributes.color = await customizeColors(
|
|
550
|
+
attributes.color,
|
|
551
|
+
attributes.id,
|
|
552
|
+
tileOptions,
|
|
553
|
+
tilesetOptions,
|
|
554
|
+
options
|
|
555
|
+
);
|
|
556
|
+
content.attributes = {
|
|
557
|
+
positions: attributes.position,
|
|
558
|
+
normals: attributes.normal,
|
|
559
|
+
colors: normalizeAttribute(attributes.color),
|
|
560
|
+
// Normalize from UInt8
|
|
561
|
+
texCoords: attributes.uv0,
|
|
562
|
+
uvRegions: normalizeAttribute(attributes.uvRegion || attributes.region)
|
|
563
|
+
// Normalize from UInt16
|
|
564
|
+
};
|
|
565
|
+
content.indices = indices || null;
|
|
566
|
+
if (attributes.id && attributes.id.value) {
|
|
567
|
+
content.featureIds = attributes.id.value;
|
|
568
|
+
}
|
|
569
|
+
for (const attributeIndex in content.attributes) {
|
|
570
|
+
if (!content.attributes[attributeIndex]) {
|
|
571
|
+
delete content.attributes[attributeIndex];
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
content.vertexCount = vertexCount;
|
|
575
|
+
content.byteLength = contentByteLength;
|
|
576
|
+
return content;
|
|
577
|
+
}
|
|
578
|
+
function updateAttributesMetadata(attributes, decompressedGeometry) {
|
|
579
|
+
for (const key in decompressedGeometry.loaderData.attributes) {
|
|
580
|
+
const dracoAttribute = decompressedGeometry.loaderData.attributes[key];
|
|
581
|
+
switch (dracoAttribute.name) {
|
|
582
|
+
case "POSITION":
|
|
583
|
+
attributes.position.metadata = dracoAttribute.metadata;
|
|
584
|
+
break;
|
|
585
|
+
case "feature-index":
|
|
586
|
+
attributes.id.metadata = dracoAttribute.metadata;
|
|
587
|
+
break;
|
|
588
|
+
default:
|
|
589
|
+
break;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
function concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes) {
|
|
594
|
+
return { ...normalizedVertexAttributes, ...normalizedFeatureAttributes };
|
|
595
|
+
}
|
|
596
|
+
function normalizeAttribute(attribute) {
|
|
597
|
+
if (!attribute) {
|
|
598
|
+
return attribute;
|
|
599
|
+
}
|
|
600
|
+
attribute.normalized = true;
|
|
601
|
+
return attribute;
|
|
602
|
+
}
|
|
603
|
+
function parseHeaders(arrayBuffer, options) {
|
|
604
|
+
let byteOffset = 0;
|
|
605
|
+
let vertexCount = 0;
|
|
606
|
+
let featureCount = 0;
|
|
607
|
+
for (const { property, type } of options.store.defaultGeometrySchema.header) {
|
|
608
|
+
const TypedArrayTypeHeader = getConstructorForDataFormat(type);
|
|
609
|
+
switch (property) {
|
|
610
|
+
case "vertexCount" /* vertexCount */:
|
|
611
|
+
vertexCount = new TypedArrayTypeHeader(arrayBuffer, 0, 4)[0];
|
|
612
|
+
byteOffset += sizeOf(type);
|
|
613
|
+
break;
|
|
614
|
+
case "featureCount" /* featureCount */:
|
|
615
|
+
featureCount = new TypedArrayTypeHeader(arrayBuffer, 4, 4)[0];
|
|
616
|
+
byteOffset += sizeOf(type);
|
|
617
|
+
break;
|
|
618
|
+
default:
|
|
619
|
+
break;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return {
|
|
623
|
+
vertexCount,
|
|
624
|
+
featureCount,
|
|
625
|
+
byteOffset
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
function normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, attributeCount, attributesOrder) {
|
|
629
|
+
const attributes = {};
|
|
630
|
+
for (const attribute of attributesOrder) {
|
|
631
|
+
if (vertexAttributes[attribute]) {
|
|
632
|
+
const { valueType, valuesPerElement } = vertexAttributes[attribute];
|
|
633
|
+
if (byteOffset + attributeCount * valuesPerElement * sizeOf(valueType) <= arrayBuffer.byteLength) {
|
|
634
|
+
const buffer = arrayBuffer.slice(byteOffset);
|
|
635
|
+
let value;
|
|
636
|
+
if (valueType === "UInt64") {
|
|
637
|
+
value = parseUint64Values(buffer, attributeCount * valuesPerElement, sizeOf(valueType));
|
|
638
|
+
} else {
|
|
639
|
+
const TypedArrayType = getConstructorForDataFormat(valueType);
|
|
640
|
+
value = new TypedArrayType(buffer, 0, attributeCount * valuesPerElement);
|
|
641
|
+
}
|
|
642
|
+
attributes[attribute] = {
|
|
643
|
+
value,
|
|
644
|
+
type: GL_TYPE_MAP[valueType],
|
|
645
|
+
size: valuesPerElement
|
|
646
|
+
};
|
|
647
|
+
switch (attribute) {
|
|
648
|
+
case "color":
|
|
649
|
+
attributes.color.normalized = true;
|
|
650
|
+
break;
|
|
651
|
+
case "position":
|
|
652
|
+
case "region":
|
|
653
|
+
case "normal":
|
|
654
|
+
default:
|
|
655
|
+
}
|
|
656
|
+
byteOffset = byteOffset + attributeCount * valuesPerElement * sizeOf(valueType);
|
|
657
|
+
} else if (attribute !== "uv0") {
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
return { attributes, byteOffset };
|
|
663
|
+
}
|
|
664
|
+
function parseUint64Values(buffer, elementsCount, attributeSize) {
|
|
665
|
+
const values = [];
|
|
666
|
+
const dataView = new DataView(buffer);
|
|
667
|
+
let offset = 0;
|
|
668
|
+
for (let index = 0; index < elementsCount; index++) {
|
|
669
|
+
const left = dataView.getUint32(offset, true);
|
|
670
|
+
const right = dataView.getUint32(offset + 4, true);
|
|
671
|
+
const value = left + 2 ** 32 * right;
|
|
672
|
+
values.push(value);
|
|
673
|
+
offset += attributeSize;
|
|
674
|
+
}
|
|
675
|
+
return new Uint32Array(values);
|
|
676
|
+
}
|
|
677
|
+
function parsePositions(attribute, options) {
|
|
678
|
+
const mbs = options.mbs;
|
|
679
|
+
const value = attribute.value;
|
|
680
|
+
const metadata = attribute.metadata;
|
|
681
|
+
const enuMatrix = new import_core4.Matrix4();
|
|
682
|
+
const cartographicOrigin = new import_core4.Vector3(mbs[0], mbs[1], mbs[2]);
|
|
683
|
+
const cartesianOrigin = new import_core4.Vector3();
|
|
684
|
+
import_geospatial.Ellipsoid.WGS84.cartographicToCartesian(cartographicOrigin, cartesianOrigin);
|
|
685
|
+
import_geospatial.Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin, enuMatrix);
|
|
686
|
+
attribute.value = offsetsToCartesians(value, metadata, cartographicOrigin);
|
|
687
|
+
return enuMatrix;
|
|
688
|
+
}
|
|
689
|
+
function offsetsToCartesians(vertices, metadata = {}, cartographicOrigin) {
|
|
690
|
+
const positions = new Float64Array(vertices.length);
|
|
691
|
+
const scaleX = metadata["i3s-scale_x"] && metadata["i3s-scale_x"].double || 1;
|
|
692
|
+
const scaleY = metadata["i3s-scale_y"] && metadata["i3s-scale_y"].double || 1;
|
|
693
|
+
for (let i = 0; i < positions.length; i += 3) {
|
|
694
|
+
positions[i] = vertices[i] * scaleX + cartographicOrigin.x;
|
|
695
|
+
positions[i + 1] = vertices[i + 1] * scaleY + cartographicOrigin.y;
|
|
696
|
+
positions[i + 2] = vertices[i + 2] + cartographicOrigin.z;
|
|
697
|
+
}
|
|
698
|
+
for (let i = 0; i < positions.length; i += 3) {
|
|
699
|
+
import_geospatial.Ellipsoid.WGS84.cartographicToCartesian(positions.subarray(i, i + 3), scratchVector);
|
|
700
|
+
positions[i] = scratchVector.x;
|
|
701
|
+
positions[i + 1] = scratchVector.y;
|
|
702
|
+
positions[i + 2] = scratchVector.z;
|
|
703
|
+
}
|
|
704
|
+
return positions;
|
|
705
|
+
}
|
|
706
|
+
function getModelMatrix(positions) {
|
|
707
|
+
var _a, _b;
|
|
708
|
+
const metadata = positions.metadata;
|
|
709
|
+
const scaleX = ((_a = metadata == null ? void 0 : metadata["i3s-scale_x"]) == null ? void 0 : _a.double) || 1;
|
|
710
|
+
const scaleY = ((_b = metadata == null ? void 0 : metadata["i3s-scale_y"]) == null ? void 0 : _b.double) || 1;
|
|
711
|
+
const modelMatrix = new import_core4.Matrix4();
|
|
712
|
+
modelMatrix[0] = scaleX;
|
|
713
|
+
modelMatrix[5] = scaleY;
|
|
714
|
+
return modelMatrix;
|
|
715
|
+
}
|
|
716
|
+
function makePbrMaterial(materialDefinition, texture) {
|
|
717
|
+
let pbrMaterial;
|
|
718
|
+
if (materialDefinition) {
|
|
719
|
+
pbrMaterial = {
|
|
720
|
+
...materialDefinition,
|
|
721
|
+
pbrMetallicRoughness: materialDefinition.pbrMetallicRoughness ? { ...materialDefinition.pbrMetallicRoughness } : { baseColorFactor: [255, 255, 255, 255] }
|
|
722
|
+
};
|
|
723
|
+
} else {
|
|
724
|
+
pbrMaterial = {
|
|
725
|
+
pbrMetallicRoughness: {}
|
|
726
|
+
};
|
|
727
|
+
if (texture) {
|
|
728
|
+
pbrMaterial.pbrMetallicRoughness.baseColorTexture = { texCoord: 0 };
|
|
729
|
+
} else {
|
|
730
|
+
pbrMaterial.pbrMetallicRoughness.baseColorFactor = [255, 255, 255, 255];
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
pbrMaterial.alphaCutoff = pbrMaterial.alphaCutoff || 0.25;
|
|
734
|
+
if (pbrMaterial.alphaMode) {
|
|
735
|
+
pbrMaterial.alphaMode = pbrMaterial.alphaMode.toUpperCase();
|
|
736
|
+
}
|
|
737
|
+
if (pbrMaterial.emissiveFactor) {
|
|
738
|
+
pbrMaterial.emissiveFactor = convertColorFormat(pbrMaterial.emissiveFactor);
|
|
739
|
+
}
|
|
740
|
+
if (pbrMaterial.pbrMetallicRoughness && pbrMaterial.pbrMetallicRoughness.baseColorFactor) {
|
|
741
|
+
pbrMaterial.pbrMetallicRoughness.baseColorFactor = convertColorFormat(
|
|
742
|
+
pbrMaterial.pbrMetallicRoughness.baseColorFactor
|
|
743
|
+
);
|
|
744
|
+
}
|
|
745
|
+
if (texture) {
|
|
746
|
+
setMaterialTexture(pbrMaterial, texture);
|
|
747
|
+
}
|
|
748
|
+
return pbrMaterial;
|
|
749
|
+
}
|
|
750
|
+
function convertColorFormat(colorFactor) {
|
|
751
|
+
const normalizedColor = [...colorFactor];
|
|
752
|
+
for (let index = 0; index < colorFactor.length; index++) {
|
|
753
|
+
normalizedColor[index] = colorFactor[index] / 255;
|
|
754
|
+
}
|
|
755
|
+
return normalizedColor;
|
|
756
|
+
}
|
|
757
|
+
function setMaterialTexture(material, image) {
|
|
758
|
+
const texture = { source: { image } };
|
|
759
|
+
if (material.pbrMetallicRoughness && material.pbrMetallicRoughness.baseColorTexture) {
|
|
760
|
+
material.pbrMetallicRoughness.baseColorTexture = {
|
|
761
|
+
...material.pbrMetallicRoughness.baseColorTexture,
|
|
762
|
+
texture
|
|
763
|
+
};
|
|
764
|
+
} else if (material.emissiveTexture) {
|
|
765
|
+
material.emissiveTexture = { ...material.emissiveTexture, texture };
|
|
766
|
+
} else if (material.pbrMetallicRoughness && material.pbrMetallicRoughness.metallicRoughnessTexture) {
|
|
767
|
+
material.pbrMetallicRoughness.metallicRoughnessTexture = {
|
|
768
|
+
...material.pbrMetallicRoughness.metallicRoughnessTexture,
|
|
769
|
+
texture
|
|
770
|
+
};
|
|
771
|
+
} else if (material.normalTexture) {
|
|
772
|
+
material.normalTexture = { ...material.normalTexture, texture };
|
|
773
|
+
} else if (material.occlusionTexture) {
|
|
774
|
+
material.occlusionTexture = { ...material.occlusionTexture, texture };
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
function flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes) {
|
|
778
|
+
const { id, faceRange } = normalizedFeatureAttributes;
|
|
779
|
+
if (!id || !faceRange) {
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
const featureIds = id.value;
|
|
783
|
+
const range = faceRange.value;
|
|
784
|
+
const featureIdsLength = range[range.length - 1] + 1;
|
|
785
|
+
const orderedFeatureIndices = new Uint32Array(featureIdsLength * 3);
|
|
786
|
+
let featureIndex = 0;
|
|
787
|
+
let startIndex = 0;
|
|
788
|
+
for (let index = 1; index < range.length; index += 2) {
|
|
789
|
+
const fillId = Number(featureIds[featureIndex]);
|
|
790
|
+
const endValue = range[index];
|
|
791
|
+
const prevValue = range[index - 1];
|
|
792
|
+
const trianglesCount = endValue - prevValue + 1;
|
|
793
|
+
const endIndex = startIndex + trianglesCount * 3;
|
|
794
|
+
orderedFeatureIndices.fill(fillId, startIndex, endIndex);
|
|
795
|
+
featureIndex++;
|
|
796
|
+
startIndex = endIndex;
|
|
797
|
+
}
|
|
798
|
+
normalizedFeatureAttributes.id.value = orderedFeatureIndices;
|
|
799
|
+
}
|
|
800
|
+
function flattenFeatureIdsByFeatureIndices(attributes, featureIds) {
|
|
801
|
+
const featureIndices = attributes.id.value;
|
|
802
|
+
const result = new Float32Array(featureIndices.length);
|
|
803
|
+
for (let index = 0; index < featureIndices.length; index++) {
|
|
804
|
+
result[index] = featureIds[featureIndices[index]];
|
|
805
|
+
}
|
|
806
|
+
attributes.id.value = result;
|
|
807
|
+
}
|
|
808
|
+
function getFeatureIdsFromFeatureIndexMetadata(featureIndex) {
|
|
809
|
+
var _a, _b;
|
|
810
|
+
return (_b = (_a = featureIndex == null ? void 0 : featureIndex.metadata) == null ? void 0 : _a["i3s-feature-ids"]) == null ? void 0 : _b.intArray;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
// src/i3s-content-loader.ts
|
|
814
|
+
var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
|
|
815
|
+
var I3SContentLoader = {
|
|
816
|
+
name: "I3S Content (Indexed Scene Layers)",
|
|
817
|
+
id: "i3s-content",
|
|
818
|
+
module: "i3s",
|
|
819
|
+
worker: true,
|
|
820
|
+
version: VERSION2,
|
|
821
|
+
mimeTypes: ["application/octet-stream"],
|
|
822
|
+
parse: parse2,
|
|
823
|
+
extensions: ["bin"],
|
|
824
|
+
options: {
|
|
825
|
+
"i3s-content": {}
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
async function parse2(data, options, context) {
|
|
829
|
+
const { tile, _tileOptions, tileset, _tilesetOptions } = (options == null ? void 0 : options.i3s) || {};
|
|
830
|
+
const tileOptions = _tileOptions || tile;
|
|
831
|
+
const tilesetOptions = _tilesetOptions || tileset;
|
|
832
|
+
if (!tileOptions || !tilesetOptions) {
|
|
833
|
+
return null;
|
|
834
|
+
}
|
|
835
|
+
return await parseI3STileContent(
|
|
836
|
+
data,
|
|
837
|
+
tileOptions,
|
|
838
|
+
tilesetOptions,
|
|
839
|
+
options,
|
|
840
|
+
context
|
|
841
|
+
);
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
// src/lib/parsers/parse-i3s.ts
|
|
845
|
+
var import_culling = require("@math.gl/culling");
|
|
846
|
+
var import_geospatial2 = require("@math.gl/geospatial");
|
|
847
|
+
var import_core6 = require("@loaders.gl/core");
|
|
848
|
+
var import_tiles = require("@loaders.gl/tiles");
|
|
849
|
+
|
|
850
|
+
// src/lib/helpers/i3s-nodepages-tiles.ts
|
|
851
|
+
var import_core5 = require("@loaders.gl/core");
|
|
852
|
+
var import_textures2 = require("@loaders.gl/textures");
|
|
853
|
+
|
|
854
|
+
// src/i3s-node-page-loader.ts
|
|
855
|
+
var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
856
|
+
var I3SNodePageLoader = {
|
|
857
|
+
name: "I3S Node Page",
|
|
858
|
+
id: "i3s-node-page",
|
|
859
|
+
module: "i3s",
|
|
860
|
+
version: VERSION3,
|
|
861
|
+
mimeTypes: ["application/json"],
|
|
862
|
+
parse: parseNodePage,
|
|
863
|
+
extensions: ["json"],
|
|
864
|
+
options: {
|
|
865
|
+
i3s: {}
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
async function parseNodePage(data, options) {
|
|
869
|
+
return JSON.parse(new TextDecoder().decode(data));
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
// src/lib/helpers/i3s-nodepages-tiles.ts
|
|
873
|
+
var I3SNodePagesTiles = class {
|
|
874
|
+
/**
|
|
875
|
+
* @constructs
|
|
876
|
+
* Create a I3SNodePagesTiles instance.
|
|
877
|
+
* @param tileset - i3s tileset header ('layers/0')
|
|
878
|
+
* @param url - tileset url
|
|
879
|
+
* @param options - i3s loader options
|
|
880
|
+
*/
|
|
881
|
+
constructor(tileset, url = "", options) {
|
|
882
|
+
this.nodePages = [];
|
|
883
|
+
this.pendingNodePages = [];
|
|
884
|
+
this.textureDefinitionsSelectedFormats = [];
|
|
885
|
+
this.textureLoaderOptions = {};
|
|
886
|
+
var _a, _b;
|
|
887
|
+
this.tileset = { ...tileset };
|
|
888
|
+
this.url = url;
|
|
889
|
+
this.nodesPerPage = ((_a = tileset.nodePages) == null ? void 0 : _a.nodesPerPage) || 64;
|
|
890
|
+
this.lodSelectionMetricType = (_b = tileset.nodePages) == null ? void 0 : _b.lodSelectionMetricType;
|
|
891
|
+
this.options = options;
|
|
892
|
+
this.nodesInNodePages = 0;
|
|
893
|
+
this.initSelectedFormatsForTextureDefinitions(tileset);
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Loads some nodePage and return a particular node from it
|
|
897
|
+
* @param id - id of node through all node pages
|
|
898
|
+
*/
|
|
899
|
+
async getNodeById(id) {
|
|
900
|
+
var _a;
|
|
901
|
+
const pageIndex = Math.floor(id / this.nodesPerPage);
|
|
902
|
+
if (!this.nodePages[pageIndex] && !this.pendingNodePages[pageIndex]) {
|
|
903
|
+
const nodePageUrl = getUrlWithToken(
|
|
904
|
+
`${this.url}/nodepages/${pageIndex}`,
|
|
905
|
+
// @ts-expect-error this.options is not properly typed
|
|
906
|
+
(_a = this.options.i3s) == null ? void 0 : _a.token
|
|
907
|
+
);
|
|
908
|
+
this.pendingNodePages[pageIndex] = {
|
|
909
|
+
status: "Pending",
|
|
910
|
+
promise: (0, import_core5.load)(nodePageUrl, I3SNodePageLoader, this.options)
|
|
911
|
+
};
|
|
912
|
+
this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;
|
|
913
|
+
this.nodesInNodePages += this.nodePages[pageIndex].nodes.length;
|
|
914
|
+
this.pendingNodePages[pageIndex].status = "Done";
|
|
915
|
+
}
|
|
916
|
+
if (this.pendingNodePages[pageIndex].status === "Pending") {
|
|
917
|
+
this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;
|
|
918
|
+
}
|
|
919
|
+
const nodeIndex = id % this.nodesPerPage;
|
|
920
|
+
return this.nodePages[pageIndex].nodes[nodeIndex];
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Forms tile header using node and tileset data
|
|
924
|
+
* @param id - id of node through all node pages
|
|
925
|
+
*/
|
|
926
|
+
// eslint-disable-next-line complexity, max-statements
|
|
927
|
+
async formTileFromNodePages(id) {
|
|
928
|
+
const node = await this.getNodeById(id);
|
|
929
|
+
const children = [];
|
|
930
|
+
const childNodesPromises = [];
|
|
931
|
+
for (const child of node.children || []) {
|
|
932
|
+
childNodesPromises.push(this.getNodeById(child));
|
|
933
|
+
}
|
|
934
|
+
const childNodes = await Promise.all(childNodesPromises);
|
|
935
|
+
for (const childNode of childNodes) {
|
|
936
|
+
children.push({
|
|
937
|
+
id: childNode.index.toString(),
|
|
938
|
+
obb: childNode.obb
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
let contentUrl;
|
|
942
|
+
let textureUrl;
|
|
943
|
+
let materialDefinition;
|
|
944
|
+
let textureFormat = "jpg";
|
|
945
|
+
let attributeUrls = [];
|
|
946
|
+
let isDracoGeometry = false;
|
|
947
|
+
if (node && node.mesh) {
|
|
948
|
+
const { url, isDracoGeometry: isDracoGeometryResult } = node.mesh.geometry && this.getContentUrl(node.mesh.geometry) || { isDracoGeometry: false };
|
|
949
|
+
contentUrl = url;
|
|
950
|
+
isDracoGeometry = isDracoGeometryResult;
|
|
951
|
+
const { textureData, materialDefinition: nodeMaterialDefinition } = this.getInformationFromMaterial(node.mesh.material);
|
|
952
|
+
materialDefinition = nodeMaterialDefinition;
|
|
953
|
+
textureFormat = textureData.format || textureFormat;
|
|
954
|
+
if (textureData.name) {
|
|
955
|
+
textureUrl = `${this.url}/nodes/${node.mesh.material.resource}/textures/${textureData.name}`;
|
|
956
|
+
}
|
|
957
|
+
if (this.tileset.attributeStorageInfo) {
|
|
958
|
+
attributeUrls = generateTilesetAttributeUrls(
|
|
959
|
+
this.tileset,
|
|
960
|
+
this.url,
|
|
961
|
+
node.mesh.attribute.resource
|
|
962
|
+
);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
const lodSelection = this.getLodSelection(node);
|
|
966
|
+
return normalizeTileNonUrlData({
|
|
967
|
+
id: id.toString(),
|
|
968
|
+
lodSelection,
|
|
969
|
+
obb: node.obb,
|
|
970
|
+
contentUrl,
|
|
971
|
+
textureUrl,
|
|
972
|
+
attributeUrls,
|
|
973
|
+
materialDefinition,
|
|
974
|
+
textureFormat,
|
|
975
|
+
textureLoaderOptions: this.textureLoaderOptions,
|
|
976
|
+
children,
|
|
977
|
+
isDracoGeometry
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* Forms url and type of geometry resource by nodepage's data and `geometryDefinitions` in the tileset
|
|
982
|
+
* @param - data about the node's mesh from the nodepage
|
|
983
|
+
* @returns -
|
|
984
|
+
* {string} url - url to the geometry resource
|
|
985
|
+
* {boolean} isDracoGeometry - whether the geometry resource contain DRACO compressed geometry
|
|
986
|
+
*/
|
|
987
|
+
getContentUrl(meshGeometryData) {
|
|
988
|
+
let result = null;
|
|
989
|
+
const geometryDefinition = this.tileset.geometryDefinitions[meshGeometryData.definition];
|
|
990
|
+
let geometryIndex = -1;
|
|
991
|
+
if (this.options.i3s && this.options.i3s.useDracoGeometry) {
|
|
992
|
+
geometryIndex = geometryDefinition.geometryBuffers.findIndex(
|
|
993
|
+
(buffer) => buffer.compressedAttributes && buffer.compressedAttributes.encoding === "draco"
|
|
994
|
+
);
|
|
995
|
+
}
|
|
996
|
+
if (geometryIndex === -1) {
|
|
997
|
+
geometryIndex = geometryDefinition.geometryBuffers.findIndex(
|
|
998
|
+
(buffer) => !buffer.compressedAttributes
|
|
999
|
+
);
|
|
1000
|
+
}
|
|
1001
|
+
if (geometryIndex !== -1) {
|
|
1002
|
+
const isDracoGeometry = Boolean(
|
|
1003
|
+
geometryDefinition.geometryBuffers[geometryIndex].compressedAttributes
|
|
1004
|
+
);
|
|
1005
|
+
result = {
|
|
1006
|
+
url: `${this.url}/nodes/${meshGeometryData.resource}/geometries/${geometryIndex}`,
|
|
1007
|
+
isDracoGeometry
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
return result;
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Forms 1.6 compatible LOD selection object from a nodepage's node data
|
|
1014
|
+
* @param node - a node from nodepage
|
|
1015
|
+
* @returns- Array of LodSelection
|
|
1016
|
+
*/
|
|
1017
|
+
getLodSelection(node) {
|
|
1018
|
+
const lodSelection = [];
|
|
1019
|
+
if (this.lodSelectionMetricType === "maxScreenThresholdSQ") {
|
|
1020
|
+
lodSelection.push({
|
|
1021
|
+
metricType: "maxScreenThreshold",
|
|
1022
|
+
// @ts-ignore
|
|
1023
|
+
maxError: Math.sqrt(node.lodThreshold / (Math.PI * 0.25))
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
lodSelection.push({
|
|
1027
|
+
metricType: this.lodSelectionMetricType,
|
|
1028
|
+
// @ts-ignore
|
|
1029
|
+
maxError: node.lodThreshold
|
|
1030
|
+
});
|
|
1031
|
+
return lodSelection;
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* Returns information about texture and material from `materialDefinitions`
|
|
1035
|
+
* @param material - material data from nodepage
|
|
1036
|
+
* @returns - Couple {textureData, materialDefinition}
|
|
1037
|
+
* {string} textureData.name - path name of the texture
|
|
1038
|
+
* {string} textureData.format - format of the texture
|
|
1039
|
+
* materialDefinition - PBR-like material definition from `materialDefinitions`
|
|
1040
|
+
*/
|
|
1041
|
+
getInformationFromMaterial(material) {
|
|
1042
|
+
var _a, _b, _c;
|
|
1043
|
+
const informationFromMaterial = { textureData: { name: null } };
|
|
1044
|
+
if (material) {
|
|
1045
|
+
const materialDefinition = (_a = this.tileset.materialDefinitions) == null ? void 0 : _a[material.definition];
|
|
1046
|
+
if (materialDefinition) {
|
|
1047
|
+
informationFromMaterial.materialDefinition = materialDefinition;
|
|
1048
|
+
const textureSetDefinitionIndex = (_c = (_b = materialDefinition == null ? void 0 : materialDefinition.pbrMetallicRoughness) == null ? void 0 : _b.baseColorTexture) == null ? void 0 : _c.textureSetDefinitionId;
|
|
1049
|
+
if (typeof textureSetDefinitionIndex === "number") {
|
|
1050
|
+
informationFromMaterial.textureData = this.textureDefinitionsSelectedFormats[textureSetDefinitionIndex] || informationFromMaterial.textureData;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
return informationFromMaterial;
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Sets preferable and supported format for each textureDefinition of the tileset
|
|
1058
|
+
* @param tileset - I3S layer data
|
|
1059
|
+
* @returns
|
|
1060
|
+
*/
|
|
1061
|
+
initSelectedFormatsForTextureDefinitions(tileset) {
|
|
1062
|
+
this.textureDefinitionsSelectedFormats = [];
|
|
1063
|
+
const possibleI3sFormats = this.getSupportedTextureFormats();
|
|
1064
|
+
const textureSetDefinitions = tileset.textureSetDefinitions || [];
|
|
1065
|
+
for (const textureSetDefinition of textureSetDefinitions) {
|
|
1066
|
+
const formats = textureSetDefinition && textureSetDefinition.formats || [];
|
|
1067
|
+
let selectedFormat = null;
|
|
1068
|
+
for (const i3sFormat of possibleI3sFormats) {
|
|
1069
|
+
const format = formats.find((value) => value.format === i3sFormat);
|
|
1070
|
+
if (format) {
|
|
1071
|
+
selectedFormat = format;
|
|
1072
|
+
break;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
if (selectedFormat && selectedFormat.format === "ktx2") {
|
|
1076
|
+
this.textureLoaderOptions.basis = {
|
|
1077
|
+
format: (0, import_textures2.selectSupportedBasisFormat)(),
|
|
1078
|
+
containerFormat: "ktx2",
|
|
1079
|
+
module: "encoder"
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1082
|
+
this.textureDefinitionsSelectedFormats.push(selectedFormat);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Returns the array of supported texture format
|
|
1087
|
+
* @returns list of format strings
|
|
1088
|
+
*/
|
|
1089
|
+
getSupportedTextureFormats() {
|
|
1090
|
+
const formats = [];
|
|
1091
|
+
if (!this.options.i3s || this.options.i3s.useCompressedTextures) {
|
|
1092
|
+
const supportedCompressedFormats = (0, import_textures2.getSupportedGPUTextureFormats)();
|
|
1093
|
+
if (supportedCompressedFormats.has("etc2")) {
|
|
1094
|
+
formats.push("ktx-etc2");
|
|
1095
|
+
}
|
|
1096
|
+
if (supportedCompressedFormats.has("dxt")) {
|
|
1097
|
+
formats.push("dds");
|
|
1098
|
+
}
|
|
1099
|
+
formats.push("ktx2");
|
|
1100
|
+
}
|
|
1101
|
+
formats.push("jpg");
|
|
1102
|
+
formats.push("png");
|
|
1103
|
+
return formats;
|
|
1104
|
+
}
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1107
|
+
// src/lib/parsers/parse-i3s.ts
|
|
1108
|
+
function normalizeTileData(tile, context) {
|
|
1109
|
+
const url = context.url || "";
|
|
1110
|
+
let contentUrl;
|
|
1111
|
+
if (tile.geometryData) {
|
|
1112
|
+
contentUrl = `${url}/${tile.geometryData[0].href}`;
|
|
1113
|
+
}
|
|
1114
|
+
let textureUrl;
|
|
1115
|
+
if (tile.textureData) {
|
|
1116
|
+
textureUrl = `${url}/${tile.textureData[0].href}`;
|
|
1117
|
+
}
|
|
1118
|
+
let attributeUrls;
|
|
1119
|
+
if (tile.attributeData) {
|
|
1120
|
+
attributeUrls = generateTileAttributeUrls(url, tile);
|
|
1121
|
+
}
|
|
1122
|
+
const children = tile.children || [];
|
|
1123
|
+
return normalizeTileNonUrlData({
|
|
1124
|
+
...tile,
|
|
1125
|
+
children,
|
|
1126
|
+
url,
|
|
1127
|
+
contentUrl,
|
|
1128
|
+
textureUrl,
|
|
1129
|
+
textureFormat: "jpg",
|
|
1130
|
+
// `jpg` format will cause `ImageLoader` usage that will be able to handle `png` as well
|
|
1131
|
+
attributeUrls,
|
|
1132
|
+
isDracoGeometry: false
|
|
1133
|
+
});
|
|
1134
|
+
}
|
|
1135
|
+
function normalizeTileNonUrlData(tile) {
|
|
1136
|
+
var _a, _b;
|
|
1137
|
+
const boundingVolume = {};
|
|
1138
|
+
let mbs = [0, 0, 0, 1];
|
|
1139
|
+
if (tile.mbs) {
|
|
1140
|
+
mbs = tile.mbs;
|
|
1141
|
+
boundingVolume.sphere = [
|
|
1142
|
+
...import_geospatial2.Ellipsoid.WGS84.cartographicToCartesian(tile.mbs.slice(0, 3)),
|
|
1143
|
+
// cartesian center of sphere
|
|
1144
|
+
tile.mbs[3]
|
|
1145
|
+
// radius of sphere
|
|
1146
|
+
];
|
|
1147
|
+
} else if (tile.obb) {
|
|
1148
|
+
boundingVolume.box = [
|
|
1149
|
+
...import_geospatial2.Ellipsoid.WGS84.cartographicToCartesian(tile.obb.center),
|
|
1150
|
+
// cartesian center of box
|
|
1151
|
+
...tile.obb.halfSize,
|
|
1152
|
+
// halfSize
|
|
1153
|
+
...tile.obb.quaternion
|
|
1154
|
+
// quaternion
|
|
1155
|
+
];
|
|
1156
|
+
const obb = new import_culling.OrientedBoundingBox().fromCenterHalfSizeQuaternion(
|
|
1157
|
+
boundingVolume.box.slice(0, 3),
|
|
1158
|
+
tile.obb.halfSize,
|
|
1159
|
+
tile.obb.quaternion
|
|
1160
|
+
);
|
|
1161
|
+
const boundingSphere = obb.getBoundingSphere();
|
|
1162
|
+
boundingVolume.sphere = [...boundingSphere.center, boundingSphere.radius];
|
|
1163
|
+
mbs = [...tile.obb.center, boundingSphere.radius];
|
|
1164
|
+
}
|
|
1165
|
+
const lodMetricType = (_a = tile.lodSelection) == null ? void 0 : _a[0].metricType;
|
|
1166
|
+
const lodMetricValue = (_b = tile.lodSelection) == null ? void 0 : _b[0].maxError;
|
|
1167
|
+
const type = import_tiles.TILE_TYPE.MESH;
|
|
1168
|
+
const refine = import_tiles.TILE_REFINEMENT.REPLACE;
|
|
1169
|
+
return { ...tile, mbs, boundingVolume, lodMetricType, lodMetricValue, type, refine };
|
|
1170
|
+
}
|
|
1171
|
+
async function normalizeTilesetData(tileset, options, context) {
|
|
1172
|
+
const url = getUrlWithoutParams(context.url || "");
|
|
1173
|
+
let nodePagesTile;
|
|
1174
|
+
let root;
|
|
1175
|
+
if (tileset.nodePages) {
|
|
1176
|
+
nodePagesTile = new I3SNodePagesTiles(tileset, url, options);
|
|
1177
|
+
root = await nodePagesTile.formTileFromNodePages(0);
|
|
1178
|
+
} else {
|
|
1179
|
+
const parseOptions = options.i3s;
|
|
1180
|
+
const rootNodeUrl = getUrlWithToken(`${url}/nodes/root`, parseOptions.token);
|
|
1181
|
+
root = await (0, import_core6.load)(rootNodeUrl, I3SLoader, {
|
|
1182
|
+
...options,
|
|
1183
|
+
i3s: {
|
|
1184
|
+
// @ts-expect-error options is not properly typed
|
|
1185
|
+
...options.i3s,
|
|
1186
|
+
loadContent: false,
|
|
1187
|
+
isTileHeader: true,
|
|
1188
|
+
isTileset: false
|
|
1189
|
+
}
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
return {
|
|
1193
|
+
...tileset,
|
|
1194
|
+
loader: I3SLoader,
|
|
1195
|
+
url,
|
|
1196
|
+
basePath: url,
|
|
1197
|
+
type: import_tiles.TILESET_TYPE.I3S,
|
|
1198
|
+
nodePagesTile,
|
|
1199
|
+
// @ts-expect-error
|
|
1200
|
+
root,
|
|
1201
|
+
lodMetricType: root.lodMetricType,
|
|
1202
|
+
lodMetricValue: root.lodMetricValue
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
// src/i3s-loader.ts
|
|
1207
|
+
var VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
1208
|
+
var TILESET_REGEX = /layers\/[0-9]+$/;
|
|
1209
|
+
var TILE_HEADER_REGEX = /nodes\/([0-9-]+|root)$/;
|
|
1210
|
+
var SLPK_HEX = "504b0304";
|
|
1211
|
+
var POINT_CLOUD = "PointCloud";
|
|
1212
|
+
var I3SLoader = {
|
|
1213
|
+
name: "I3S (Indexed Scene Layers)",
|
|
1214
|
+
id: "i3s",
|
|
1215
|
+
module: "i3s",
|
|
1216
|
+
version: VERSION4,
|
|
1217
|
+
mimeTypes: ["application/octet-stream"],
|
|
1218
|
+
parse: parseI3S,
|
|
1219
|
+
extensions: ["bin"],
|
|
1220
|
+
options: {
|
|
1221
|
+
i3s: {
|
|
1222
|
+
token: null,
|
|
1223
|
+
isTileset: "auto",
|
|
1224
|
+
isTileHeader: "auto",
|
|
1225
|
+
tile: null,
|
|
1226
|
+
tileset: null,
|
|
1227
|
+
_tileOptions: null,
|
|
1228
|
+
_tilesetOptions: null,
|
|
1229
|
+
useDracoGeometry: true,
|
|
1230
|
+
useCompressedTextures: true,
|
|
1231
|
+
decodeTextures: true,
|
|
1232
|
+
coordinateSystem: 2 /* METER_OFFSETS */,
|
|
1233
|
+
colorsByAttribute: null
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
async function parseI3S(data, options = {}, context) {
|
|
1238
|
+
const url = context.url;
|
|
1239
|
+
options.i3s = options.i3s || {};
|
|
1240
|
+
const magicNumber = getMagicNumber(data);
|
|
1241
|
+
if (magicNumber === SLPK_HEX) {
|
|
1242
|
+
throw new Error("Files with .slpk extention currently are not supported by I3SLoader");
|
|
1243
|
+
}
|
|
1244
|
+
const urlWithoutParams = getUrlWithoutParams(url);
|
|
1245
|
+
let isTileset;
|
|
1246
|
+
if (options.i3s.isTileset === "auto") {
|
|
1247
|
+
isTileset = TILESET_REGEX.test(urlWithoutParams);
|
|
1248
|
+
} else {
|
|
1249
|
+
isTileset = options.i3s.isTileset;
|
|
1250
|
+
}
|
|
1251
|
+
let isTileHeader;
|
|
1252
|
+
if (options.isTileHeader === "auto") {
|
|
1253
|
+
isTileHeader = TILE_HEADER_REGEX.test(urlWithoutParams);
|
|
1254
|
+
} else {
|
|
1255
|
+
isTileHeader = options.i3s.isTileHeader;
|
|
1256
|
+
}
|
|
1257
|
+
if (isTileset) {
|
|
1258
|
+
data = await parseTileset(data, options, context);
|
|
1259
|
+
} else if (isTileHeader) {
|
|
1260
|
+
data = await parseTile(data, context);
|
|
1261
|
+
} else {
|
|
1262
|
+
data = await parseTileContent(data, options);
|
|
1263
|
+
}
|
|
1264
|
+
return data;
|
|
1265
|
+
}
|
|
1266
|
+
async function parseTileContent(arrayBuffer, options) {
|
|
1267
|
+
return await (0, import_core7.parse)(arrayBuffer, I3SContentLoader, options);
|
|
1268
|
+
}
|
|
1269
|
+
async function parseTileset(data, options, context) {
|
|
1270
|
+
const tilesetJson = JSON.parse(new TextDecoder().decode(data));
|
|
1271
|
+
if ((tilesetJson == null ? void 0 : tilesetJson.layerType) === POINT_CLOUD) {
|
|
1272
|
+
throw new Error("Point Cloud layers currently are not supported by I3SLoader");
|
|
1273
|
+
}
|
|
1274
|
+
const tilesetPostprocessed = await normalizeTilesetData(tilesetJson, options, context);
|
|
1275
|
+
return tilesetPostprocessed;
|
|
1276
|
+
}
|
|
1277
|
+
async function parseTile(data, context) {
|
|
1278
|
+
data = JSON.parse(new TextDecoder().decode(data));
|
|
1279
|
+
return normalizeTileData(data, context);
|
|
1280
|
+
}
|
|
1281
|
+
function getMagicNumber(data) {
|
|
1282
|
+
if (data instanceof ArrayBuffer) {
|
|
1283
|
+
return [...new Uint8Array(data, 0, 4)].map((value) => value.toString(16).padStart(2, "0")).join("");
|
|
1284
|
+
}
|
|
1285
|
+
return null;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
// src/i3s-slpk-loader.ts
|
|
1289
|
+
var import_loader_utils2 = require("@loaders.gl/loader-utils");
|
|
1290
|
+
|
|
1291
|
+
// src/lib/parsers/parse-slpk/parse-slpk.ts
|
|
1292
|
+
var import_zip2 = require("@loaders.gl/zip");
|
|
1293
|
+
|
|
1294
|
+
// src/lib/parsers/parse-slpk/slpk-archieve.ts
|
|
1295
|
+
var import_crypto = require("@loaders.gl/crypto");
|
|
1296
|
+
var import_zip = require("@loaders.gl/zip");
|
|
1297
|
+
var import_compression = require("@loaders.gl/compression");
|
|
1298
|
+
var PATH_DESCRIPTIONS = [
|
|
1299
|
+
{
|
|
1300
|
+
test: /^$/,
|
|
1301
|
+
extensions: ["3dSceneLayer.json.gz"]
|
|
1302
|
+
},
|
|
1303
|
+
{
|
|
1304
|
+
test: /^nodepages\/\d+$/,
|
|
1305
|
+
extensions: [".json.gz"]
|
|
1306
|
+
},
|
|
1307
|
+
{
|
|
1308
|
+
test: /^nodes\/(\d+|root)$/,
|
|
1309
|
+
extensions: ["/3dNodeIndexDocument.json.gz"]
|
|
1310
|
+
},
|
|
1311
|
+
{
|
|
1312
|
+
test: /^nodes\/\d+\/textures\/.+$/,
|
|
1313
|
+
extensions: [".jpg", ".png", ".bin.dds.gz", ".ktx"]
|
|
1314
|
+
},
|
|
1315
|
+
{
|
|
1316
|
+
test: /^nodes\/\d+\/geometries\/\d+$/,
|
|
1317
|
+
extensions: [".bin.gz", ".draco.gz"]
|
|
1318
|
+
},
|
|
1319
|
+
{
|
|
1320
|
+
test: /^nodes\/\d+\/attributes\/f_\d+\/\d+$/,
|
|
1321
|
+
extensions: [".bin.gz"]
|
|
1322
|
+
},
|
|
1323
|
+
{
|
|
1324
|
+
test: /^statistics\/f_\d+\/\d+$/,
|
|
1325
|
+
extensions: [".json.gz"]
|
|
1326
|
+
},
|
|
1327
|
+
{
|
|
1328
|
+
test: /^nodes\/\d+\/shared$/,
|
|
1329
|
+
extensions: ["/sharedResource.json.gz"]
|
|
1330
|
+
}
|
|
1331
|
+
];
|
|
1332
|
+
var SLPKArchive = class {
|
|
1333
|
+
constructor(slpkArchive, hashTable) {
|
|
1334
|
+
/** Array of hashes and offsets into archive */
|
|
1335
|
+
// hashToOffsetMap: Record<string, number>;
|
|
1336
|
+
this._textEncoder = new TextEncoder();
|
|
1337
|
+
this._textDecoder = new TextDecoder();
|
|
1338
|
+
this._md5Hash = new import_crypto.MD5Hash();
|
|
1339
|
+
this.slpkArchive = slpkArchive;
|
|
1340
|
+
this.hashTable = hashTable;
|
|
1341
|
+
}
|
|
1342
|
+
/**
|
|
1343
|
+
* Returns file with the given path from slpk archive
|
|
1344
|
+
* @param path - path inside the slpk
|
|
1345
|
+
* @param mode - currently only raw mode supported
|
|
1346
|
+
* @returns buffer with ready to use file
|
|
1347
|
+
*/
|
|
1348
|
+
async getFile(path, mode = "raw") {
|
|
1349
|
+
var _a;
|
|
1350
|
+
if (mode === "http") {
|
|
1351
|
+
const extensions = (_a = PATH_DESCRIPTIONS.find((val) => val.test.test(path))) == null ? void 0 : _a.extensions;
|
|
1352
|
+
if (extensions) {
|
|
1353
|
+
let data;
|
|
1354
|
+
for (const ext of extensions) {
|
|
1355
|
+
data = await this.getDataByPath(`${path}${ext}`);
|
|
1356
|
+
if (data) {
|
|
1357
|
+
break;
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
if (data) {
|
|
1361
|
+
return data;
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
if (mode === "raw") {
|
|
1366
|
+
const decompressedFile = await this.getDataByPath(`${path}.gz`);
|
|
1367
|
+
if (decompressedFile) {
|
|
1368
|
+
return decompressedFile;
|
|
1369
|
+
}
|
|
1370
|
+
const fileWithoutCompression = await this.getFileBytes(path);
|
|
1371
|
+
if (fileWithoutCompression) {
|
|
1372
|
+
return fileWithoutCompression;
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
throw new Error(`No such file in the archive: ${path}`);
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1378
|
+
* returning uncompressed data for paths that ends with .gz and raw data for all other paths
|
|
1379
|
+
* @param path - path inside the archive
|
|
1380
|
+
* @returns buffer with the file data
|
|
1381
|
+
*/
|
|
1382
|
+
async getDataByPath(path) {
|
|
1383
|
+
let data = await this.getFileBytes(path.toLocaleLowerCase());
|
|
1384
|
+
if (!data) {
|
|
1385
|
+
data = await this.getFileBytes(path);
|
|
1386
|
+
}
|
|
1387
|
+
if (!data) {
|
|
1388
|
+
return void 0;
|
|
1389
|
+
}
|
|
1390
|
+
if (/\.gz$/.test(path)) {
|
|
1391
|
+
const compression = new import_compression.GZipCompression();
|
|
1392
|
+
const decompressedData = await compression.decompress(data);
|
|
1393
|
+
return decompressedData;
|
|
1394
|
+
}
|
|
1395
|
+
return data;
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Trying to get raw file data by address
|
|
1399
|
+
* @param path - path inside the archive
|
|
1400
|
+
* @returns buffer with the raw file data
|
|
1401
|
+
*/
|
|
1402
|
+
async getFileBytes(path) {
|
|
1403
|
+
const binaryPath = this._textEncoder.encode(path);
|
|
1404
|
+
const nameHash = await this._md5Hash.hash(binaryPath.buffer, "hex");
|
|
1405
|
+
const offset = this.hashTable[nameHash];
|
|
1406
|
+
if (offset === void 0) {
|
|
1407
|
+
return void 0;
|
|
1408
|
+
}
|
|
1409
|
+
const localFileHeader = await (0, import_zip.parseZipLocalFileHeader)(offset, this.slpkArchive);
|
|
1410
|
+
if (!localFileHeader) {
|
|
1411
|
+
return void 0;
|
|
1412
|
+
}
|
|
1413
|
+
const compressedFile = this.slpkArchive.slice(
|
|
1414
|
+
localFileHeader.fileDataOffset,
|
|
1415
|
+
localFileHeader.fileDataOffset + localFileHeader.compressedSize
|
|
1416
|
+
);
|
|
1417
|
+
return compressedFile;
|
|
1418
|
+
}
|
|
1419
|
+
};
|
|
1420
|
+
|
|
1421
|
+
// src/lib/parsers/parse-slpk/parse-slpk.ts
|
|
1422
|
+
async function parseSLPKArchive(fileProvider, cb) {
|
|
1423
|
+
const hashCDOffset = await (0, import_zip2.searchFromTheEnd)(fileProvider, import_zip2.cdSignature);
|
|
1424
|
+
const cdFileHeader = await (0, import_zip2.parseZipCDFileHeader)(hashCDOffset, fileProvider);
|
|
1425
|
+
let hashTable;
|
|
1426
|
+
if ((cdFileHeader == null ? void 0 : cdFileHeader.fileName) !== "@specialIndexFileHASH128@") {
|
|
1427
|
+
hashTable = await (0, import_zip2.makeHashTableFromZipHeaders)(fileProvider);
|
|
1428
|
+
cb == null ? void 0 : cb(
|
|
1429
|
+
"SLPK doesnt contain hash file, hash info has been composed according to zip archive headers"
|
|
1430
|
+
);
|
|
1431
|
+
} else {
|
|
1432
|
+
const localFileHeader = await (0, import_zip2.parseZipLocalFileHeader)(
|
|
1433
|
+
cdFileHeader.localHeaderOffset,
|
|
1434
|
+
fileProvider
|
|
1435
|
+
);
|
|
1436
|
+
if (!localFileHeader) {
|
|
1437
|
+
throw new Error("corrupted SLPK");
|
|
1438
|
+
}
|
|
1439
|
+
const fileDataOffset = localFileHeader.fileDataOffset;
|
|
1440
|
+
const hashFile = await fileProvider.slice(
|
|
1441
|
+
fileDataOffset,
|
|
1442
|
+
fileDataOffset + localFileHeader.compressedSize
|
|
1443
|
+
);
|
|
1444
|
+
hashTable = (0, import_zip2.parseHashTable)(hashFile);
|
|
1445
|
+
}
|
|
1446
|
+
return new SLPKArchive(fileProvider, hashTable);
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
// src/i3s-slpk-loader.ts
|
|
1450
|
+
var VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
1451
|
+
var SLPKLoader = {
|
|
1452
|
+
name: "I3S SLPK (Scene Layer Package)",
|
|
1453
|
+
id: "slpk",
|
|
1454
|
+
module: "i3s",
|
|
1455
|
+
version: VERSION5,
|
|
1456
|
+
mimeTypes: ["application/octet-stream"],
|
|
1457
|
+
extensions: ["slpk"],
|
|
1458
|
+
options: {},
|
|
1459
|
+
parse: async (data, options = {}) => {
|
|
1460
|
+
var _a, _b;
|
|
1461
|
+
const archive = await parseSLPKArchive(new import_loader_utils2.DataViewFile(new DataView(data)));
|
|
1462
|
+
return archive.getFile(((_a = options.slpk) == null ? void 0 : _a.path) ?? "", (_b = options.slpk) == null ? void 0 : _b.pathMode);
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1465
|
+
|
|
1466
|
+
// src/lib/parsers/parse-i3s-building-scene-layer.ts
|
|
1467
|
+
var OBJECT_3D_LAYER_TYPE = "3DObject";
|
|
1468
|
+
async function parseBuildingSceneLayer(data, url) {
|
|
1469
|
+
const layer0 = JSON.parse(new TextDecoder().decode(data));
|
|
1470
|
+
const { sublayers } = layer0;
|
|
1471
|
+
return {
|
|
1472
|
+
header: layer0,
|
|
1473
|
+
sublayers: parseSublayersTree(sublayers, url)
|
|
1474
|
+
};
|
|
1475
|
+
}
|
|
1476
|
+
function parseSublayersTree(sublayers, url) {
|
|
1477
|
+
var _a;
|
|
1478
|
+
let layers = [];
|
|
1479
|
+
for (let index = 0; index < sublayers.length; index++) {
|
|
1480
|
+
const subLayer = sublayers[index];
|
|
1481
|
+
const { id, layerType, visibility = true, ...rest } = subLayer;
|
|
1482
|
+
if (layerType === OBJECT_3D_LAYER_TYPE) {
|
|
1483
|
+
const sublayerUrl = `${url}/sublayers/${id}`;
|
|
1484
|
+
layers.push({
|
|
1485
|
+
url: sublayerUrl,
|
|
1486
|
+
id,
|
|
1487
|
+
layerType,
|
|
1488
|
+
visibility,
|
|
1489
|
+
...rest
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
if ((_a = subLayer == null ? void 0 : subLayer.sublayers) == null ? void 0 : _a.length) {
|
|
1493
|
+
layers = [...layers, ...parseSublayersTree(subLayer.sublayers, url)];
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
return layers;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
// src/i3s-building-scene-layer-loader.ts
|
|
1500
|
+
var VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
|
|
1501
|
+
var I3SBuildingSceneLayerLoader = {
|
|
1502
|
+
name: "I3S Building Scene Layer",
|
|
1503
|
+
id: "i3s-building-scene-layer",
|
|
1504
|
+
module: "i3s",
|
|
1505
|
+
version: VERSION6,
|
|
1506
|
+
mimeTypes: ["application/json"],
|
|
1507
|
+
parse: parse4,
|
|
1508
|
+
extensions: ["json"],
|
|
1509
|
+
options: {}
|
|
1510
|
+
};
|
|
1511
|
+
async function parse4(data, options, context) {
|
|
1512
|
+
if (!(context == null ? void 0 : context.url)) {
|
|
1513
|
+
throw new Error("Url is not provided");
|
|
1514
|
+
}
|
|
1515
|
+
return parseBuildingSceneLayer(data, context.url);
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
// src/lib/parsers/parse-arcgis-webscene.ts
|
|
1519
|
+
var import_core8 = require("@loaders.gl/core");
|
|
1520
|
+
var SUPPORTED_WKID = 4326;
|
|
1521
|
+
var ARCGIS_SCENE_SERVER_LAYER_TYPE = "ArcGISSceneServiceLayer";
|
|
1522
|
+
var BUILDING_SCENE_LAYER = "BuildingSceneLayer";
|
|
1523
|
+
var INTEGRATED_MESH_LAYER = "IntegratedMeshLayer";
|
|
1524
|
+
var GROUP_LAYER = "GroupLayer";
|
|
1525
|
+
var SUPPORTED_LAYERS_TYPES = [
|
|
1526
|
+
ARCGIS_SCENE_SERVER_LAYER_TYPE,
|
|
1527
|
+
INTEGRATED_MESH_LAYER,
|
|
1528
|
+
BUILDING_SCENE_LAYER,
|
|
1529
|
+
GROUP_LAYER
|
|
1530
|
+
];
|
|
1531
|
+
var NO_AVAILABLE_SUPPORTED_LAYERS_ERROR = "NO_AVAILABLE_SUPPORTED_LAYERS_ERROR";
|
|
1532
|
+
var NOT_SUPPORTED_CRS_ERROR = "NOT_SUPPORTED_CRS_ERROR";
|
|
1533
|
+
async function parseWebscene(data) {
|
|
1534
|
+
const layer0 = JSON.parse(new TextDecoder().decode(data));
|
|
1535
|
+
const { operationalLayers } = layer0;
|
|
1536
|
+
const { layers, unsupportedLayers } = await parseOperationalLayers(operationalLayers, true);
|
|
1537
|
+
if (!layers.length) {
|
|
1538
|
+
throw new Error(NO_AVAILABLE_SUPPORTED_LAYERS_ERROR);
|
|
1539
|
+
}
|
|
1540
|
+
return {
|
|
1541
|
+
header: layer0,
|
|
1542
|
+
layers,
|
|
1543
|
+
unsupportedLayers
|
|
1544
|
+
};
|
|
1545
|
+
}
|
|
1546
|
+
async function parseOperationalLayers(layersList, needToCheckCRS) {
|
|
1547
|
+
var _a;
|
|
1548
|
+
const layers = [];
|
|
1549
|
+
let unsupportedLayers = [];
|
|
1550
|
+
for (let index = 0; index < layersList.length; index++) {
|
|
1551
|
+
const layer = layersList[index];
|
|
1552
|
+
const isLayerSupported = SUPPORTED_LAYERS_TYPES.includes(layer.layerType);
|
|
1553
|
+
if (isLayerSupported) {
|
|
1554
|
+
if (needToCheckCRS && layer.layerType !== GROUP_LAYER) {
|
|
1555
|
+
await checkSupportedIndexCRS(layer);
|
|
1556
|
+
needToCheckCRS = false;
|
|
1557
|
+
}
|
|
1558
|
+
layers.push(layer);
|
|
1559
|
+
} else {
|
|
1560
|
+
unsupportedLayers.push(layer);
|
|
1561
|
+
}
|
|
1562
|
+
if ((_a = layer.layers) == null ? void 0 : _a.length) {
|
|
1563
|
+
const { layers: childLayers, unsupportedLayers: childUnsupportedLayers } = await parseOperationalLayers(layer.layers, needToCheckCRS);
|
|
1564
|
+
layer.layers = childLayers;
|
|
1565
|
+
unsupportedLayers = [...unsupportedLayers, ...childUnsupportedLayers];
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
return { layers, unsupportedLayers };
|
|
1569
|
+
}
|
|
1570
|
+
async function checkSupportedIndexCRS(layer) {
|
|
1571
|
+
var _a;
|
|
1572
|
+
try {
|
|
1573
|
+
const layerJson = await (0, import_core8.load)(layer.url, import_core8.JSONLoader);
|
|
1574
|
+
const wkid = (_a = layerJson == null ? void 0 : layerJson.spatialReference) == null ? void 0 : _a.wkid;
|
|
1575
|
+
if (wkid !== SUPPORTED_WKID) {
|
|
1576
|
+
throw new Error(NOT_SUPPORTED_CRS_ERROR);
|
|
1577
|
+
}
|
|
1578
|
+
} catch (error) {
|
|
1579
|
+
throw error;
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
// src/arcgis-webscene-loader.ts
|
|
1584
|
+
var VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
|
|
1585
|
+
var ArcGISWebSceneLoader = {
|
|
1586
|
+
name: "ArcGIS Web Scene Loader",
|
|
1587
|
+
id: "arcgis-web-scene",
|
|
1588
|
+
module: "i3s",
|
|
1589
|
+
version: VERSION7,
|
|
1590
|
+
mimeTypes: ["application/json"],
|
|
1591
|
+
parse: parse5,
|
|
1592
|
+
extensions: ["json"],
|
|
1593
|
+
options: {}
|
|
1594
|
+
};
|
|
1595
|
+
async function parse5(data) {
|
|
1596
|
+
return parseWebscene(data);
|
|
1597
|
+
}
|