@loaders.gl/i3s 3.2.0-alpha.3 → 3.2.0-alpha.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 +7 -0
- package/dist/arcgis-webscene-loader.d.ts.map +1 -0
- package/dist/arcgis-webscene-loader.js +28 -0
- package/dist/dist.min.js +62 -0
- package/dist/es5/arcgis-webscene-loader.js +50 -0
- package/dist/es5/arcgis-webscene-loader.js.map +1 -0
- package/dist/es5/i3s-attribute-loader.js +1 -1
- package/dist/es5/i3s-building-scene-layer-loader.js +1 -1
- package/dist/es5/i3s-content-loader.js +1 -1
- package/dist/es5/i3s-loader.js +1 -1
- package/dist/es5/i3s-node-page-loader.js +1 -1
- package/dist/es5/index.js +8 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +10 -7
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
- package/dist/es5/lib/parsers/parse-arcgis-webscene.js +68 -0
- package/dist/es5/lib/parsers/parse-arcgis-webscene.js.map +1 -0
- package/dist/es5/types.js.map +1 -1
- package/dist/esm/arcgis-webscene-loader.js +17 -0
- package/dist/esm/arcgis-webscene-loader.js.map +1 -0
- package/dist/esm/i3s-attribute-loader.js +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
- package/dist/esm/i3s-content-loader.js +1 -1
- package/dist/esm/i3s-loader.js +1 -1
- package/dist/esm/i3s-node-page-loader.js +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js +4 -0
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
- package/dist/esm/lib/parsers/parse-arcgis-webscene.js +35 -0
- package/dist/esm/lib/parsers/parse-arcgis-webscene.js.map +1 -0
- package/dist/esm/types.js.map +1 -1
- package/dist/i3s-content-worker.js +8 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/helpers/i3s-nodepages-tiles.d.ts +1 -0
- package/dist/lib/helpers/i3s-nodepages-tiles.d.ts.map +1 -1
- package/dist/lib/helpers/i3s-nodepages-tiles.js +2 -0
- package/dist/lib/parsers/parse-arcgis-webscene.d.ts +7 -0
- package/dist/lib/parsers/parse-arcgis-webscene.d.ts.map +1 -0
- package/dist/lib/parsers/parse-arcgis-webscene.js +45 -0
- package/dist/types.d.ts +174 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/arcgis-webscene-loader.ts +31 -0
- package/src/index.ts +1 -0
- package/src/lib/helpers/i3s-nodepages-tiles.ts +3 -0
- package/src/lib/parsers/parse-arcgis-webscene.ts +51 -0
- package/src/types.ts +189 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LoaderWithParser } from '@loaders.gl/loader-utils';
|
|
2
|
+
/**
|
|
3
|
+
* Loader for ArcGis WebScene
|
|
4
|
+
* Spec - https://developers.arcgis.com/web-scene-specification/objects/webscene/
|
|
5
|
+
*/
|
|
6
|
+
export declare const ArcGisWebSceneLoader: LoaderWithParser;
|
|
7
|
+
//# sourceMappingURL=arcgis-webscene-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arcgis-webscene-loader.d.ts","sourceRoot":"","sources":["../src/arcgis-webscene-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAS/D;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,gBASlC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArcGisWebSceneLoader = void 0;
|
|
4
|
+
const parse_arcgis_webscene_1 = require("./lib/parsers/parse-arcgis-webscene");
|
|
5
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
6
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
7
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';
|
|
8
|
+
/**
|
|
9
|
+
* Loader for ArcGis WebScene
|
|
10
|
+
* Spec - https://developers.arcgis.com/web-scene-specification/objects/webscene/
|
|
11
|
+
*/
|
|
12
|
+
exports.ArcGisWebSceneLoader = {
|
|
13
|
+
name: 'ArcGIS Web Scene Loader',
|
|
14
|
+
id: 'arcgis-web-scene',
|
|
15
|
+
module: 'i3s',
|
|
16
|
+
version: VERSION,
|
|
17
|
+
mimeTypes: ['application/json'],
|
|
18
|
+
parse,
|
|
19
|
+
extensions: ['json'],
|
|
20
|
+
options: {}
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Parse ArcGis webscene
|
|
24
|
+
* @param data
|
|
25
|
+
*/
|
|
26
|
+
async function parse(data) {
|
|
27
|
+
return (0, parse_arcgis_webscene_1.parseWebscene)(data);
|
|
28
|
+
}
|
package/dist/dist.min.js
CHANGED
|
@@ -10502,6 +10502,7 @@
|
|
|
10502
10502
|
this.nodesPerPage = tileset.nodePages?.nodesPerPage || 64;
|
|
10503
10503
|
this.lodSelectionMetricType = tileset.nodePages?.lodSelectionMetricType;
|
|
10504
10504
|
this.options = options;
|
|
10505
|
+
this.nodesInNodePages = 0;
|
|
10505
10506
|
this.initSelectedFormatsForTextureDefinitions(tileset);
|
|
10506
10507
|
}
|
|
10507
10508
|
async getNodeById(id) {
|
|
@@ -10513,6 +10514,7 @@
|
|
|
10513
10514
|
promise: load(nodePageUrl, I3SNodePageLoader, this.options)
|
|
10514
10515
|
};
|
|
10515
10516
|
this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;
|
|
10517
|
+
this.nodesInNodePages += this.nodePages[pageIndex].nodes.length;
|
|
10516
10518
|
this.pendingNodePages[pageIndex].status = "Done";
|
|
10517
10519
|
}
|
|
10518
10520
|
if (this.pendingNodePages[pageIndex].status === "Pending") {
|
|
@@ -11072,9 +11074,68 @@
|
|
|
11072
11074
|
}
|
|
11073
11075
|
});
|
|
11074
11076
|
|
|
11077
|
+
// src/lib/parsers/parse-arcgis-webscene.ts
|
|
11078
|
+
async function parseWebscene(data) {
|
|
11079
|
+
const layer0 = JSON.parse(new TextDecoder().decode(data));
|
|
11080
|
+
const { operationalLayers } = layer0;
|
|
11081
|
+
return {
|
|
11082
|
+
header: layer0,
|
|
11083
|
+
layers: parseOperationalLayers(operationalLayers)
|
|
11084
|
+
};
|
|
11085
|
+
}
|
|
11086
|
+
function parseOperationalLayers(layersList) {
|
|
11087
|
+
let layers = [];
|
|
11088
|
+
for (let index = 0; index < layersList.length; index++) {
|
|
11089
|
+
const layer = layersList[index];
|
|
11090
|
+
if (SUPPORTED_LAYERS_TYPES.includes(layer.layerType)) {
|
|
11091
|
+
layers.push(layer);
|
|
11092
|
+
}
|
|
11093
|
+
if (layer.layers?.length) {
|
|
11094
|
+
layers = [...layers, ...parseOperationalLayers(layer.layers)];
|
|
11095
|
+
}
|
|
11096
|
+
}
|
|
11097
|
+
return layers;
|
|
11098
|
+
}
|
|
11099
|
+
var ARCGIS_SCENE_SERVER_LAYER_TYPE, BUILDING_SCENE_LAYER, INTEGRATED_MESH_LAYER, SUPPORTED_LAYERS_TYPES;
|
|
11100
|
+
var init_parse_arcgis_webscene = __esm({
|
|
11101
|
+
"src/lib/parsers/parse-arcgis-webscene.ts"() {
|
|
11102
|
+
ARCGIS_SCENE_SERVER_LAYER_TYPE = "ArcGISSceneServiceLayer";
|
|
11103
|
+
BUILDING_SCENE_LAYER = "BuildingSceneLayer";
|
|
11104
|
+
INTEGRATED_MESH_LAYER = "IntegratedMeshLayer";
|
|
11105
|
+
SUPPORTED_LAYERS_TYPES = [
|
|
11106
|
+
ARCGIS_SCENE_SERVER_LAYER_TYPE,
|
|
11107
|
+
INTEGRATED_MESH_LAYER,
|
|
11108
|
+
BUILDING_SCENE_LAYER
|
|
11109
|
+
];
|
|
11110
|
+
}
|
|
11111
|
+
});
|
|
11112
|
+
|
|
11113
|
+
// src/arcgis-webscene-loader.ts
|
|
11114
|
+
async function parse7(data) {
|
|
11115
|
+
return parseWebscene(data);
|
|
11116
|
+
}
|
|
11117
|
+
var VERSION14, ArcGisWebSceneLoader;
|
|
11118
|
+
var init_arcgis_webscene_loader = __esm({
|
|
11119
|
+
"src/arcgis-webscene-loader.ts"() {
|
|
11120
|
+
init_parse_arcgis_webscene();
|
|
11121
|
+
VERSION14 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
|
|
11122
|
+
ArcGisWebSceneLoader = {
|
|
11123
|
+
name: "ArcGIS Web Scene Loader",
|
|
11124
|
+
id: "arcgis-web-scene",
|
|
11125
|
+
module: "i3s",
|
|
11126
|
+
version: VERSION14,
|
|
11127
|
+
mimeTypes: ["application/json"],
|
|
11128
|
+
parse: parse7,
|
|
11129
|
+
extensions: ["json"],
|
|
11130
|
+
options: {}
|
|
11131
|
+
};
|
|
11132
|
+
}
|
|
11133
|
+
});
|
|
11134
|
+
|
|
11075
11135
|
// src/index.ts
|
|
11076
11136
|
var src_exports = {};
|
|
11077
11137
|
__export(src_exports, {
|
|
11138
|
+
ArcGisWebSceneLoader: () => ArcGisWebSceneLoader,
|
|
11078
11139
|
COORDINATE_SYSTEM: () => COORDINATE_SYSTEM,
|
|
11079
11140
|
I3SAttributeLoader: () => I3SAttributeLoader,
|
|
11080
11141
|
I3SBuildingSceneLayerLoader: () => I3SBuildingSceneLayerLoader,
|
|
@@ -11088,6 +11149,7 @@
|
|
|
11088
11149
|
init_i3s_content_loader();
|
|
11089
11150
|
init_i3s_attribute_loader();
|
|
11090
11151
|
init_i3s_building_scene_layer_loader();
|
|
11152
|
+
init_arcgis_webscene_loader();
|
|
11091
11153
|
init_constants2();
|
|
11092
11154
|
}
|
|
11093
11155
|
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.ArcGisWebSceneLoader = void 0;
|
|
9
|
+
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
|
|
14
|
+
var _parseArcgisWebscene = require("./lib/parsers/parse-arcgis-webscene");
|
|
15
|
+
|
|
16
|
+
var VERSION = typeof "3.2.0-alpha.4" !== 'undefined' ? "3.2.0-alpha.4" : 'beta';
|
|
17
|
+
var ArcGisWebSceneLoader = {
|
|
18
|
+
name: 'ArcGIS Web Scene Loader',
|
|
19
|
+
id: 'arcgis-web-scene',
|
|
20
|
+
module: 'i3s',
|
|
21
|
+
version: VERSION,
|
|
22
|
+
mimeTypes: ['application/json'],
|
|
23
|
+
parse: parse,
|
|
24
|
+
extensions: ['json'],
|
|
25
|
+
options: {}
|
|
26
|
+
};
|
|
27
|
+
exports.ArcGisWebSceneLoader = ArcGisWebSceneLoader;
|
|
28
|
+
|
|
29
|
+
function parse(_x) {
|
|
30
|
+
return _parse.apply(this, arguments);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function _parse() {
|
|
34
|
+
_parse = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(data) {
|
|
35
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
36
|
+
while (1) {
|
|
37
|
+
switch (_context.prev = _context.next) {
|
|
38
|
+
case 0:
|
|
39
|
+
return _context.abrupt("return", (0, _parseArcgisWebscene.parseWebscene)(data));
|
|
40
|
+
|
|
41
|
+
case 1:
|
|
42
|
+
case "end":
|
|
43
|
+
return _context.stop();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}, _callee);
|
|
47
|
+
}));
|
|
48
|
+
return _parse.apply(this, arguments);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=arcgis-webscene-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/arcgis-webscene-loader.ts"],"names":["VERSION","ArcGisWebSceneLoader","name","id","module","version","mimeTypes","parse","extensions","options","data"],"mappings":";;;;;;;;;;;;;AAGA;;AAIA,IAAMA,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,MAAnE;AAMO,IAAMC,oBAAsC,GAAG;AACpDC,EAAAA,IAAI,EAAE,yBAD8C;AAEpDC,EAAAA,EAAE,EAAE,kBAFgD;AAGpDC,EAAAA,MAAM,EAAE,KAH4C;AAIpDC,EAAAA,OAAO,EAAEL,OAJ2C;AAKpDM,EAAAA,SAAS,EAAE,CAAC,kBAAD,CALyC;AAMpDC,EAAAA,KAAK,EAALA,KANoD;AAOpDC,EAAAA,UAAU,EAAE,CAAC,MAAD,CAPwC;AAQpDC,EAAAA,OAAO,EAAE;AAR2C,CAA/C;;;SAeQF,K;;;;;qEAAf,iBAAqBG,IAArB;AAAA;AAAA;AAAA;AAAA;AAAA,6CACS,wCAAcA,IAAd,CADT;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {ArcGisWebSceneData} from './types';\n\nimport {parseWebscene} from './lib/parsers/parse-arcgis-webscene';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';\n\n/**\n * Loader for ArcGis WebScene\n * Spec - https://developers.arcgis.com/web-scene-specification/objects/webscene/\n */\nexport const ArcGisWebSceneLoader: LoaderWithParser = {\n name: 'ArcGIS Web Scene Loader',\n id: 'arcgis-web-scene',\n module: 'i3s',\n version: VERSION,\n mimeTypes: ['application/json'],\n parse,\n extensions: ['json'],\n options: {}\n};\n\n/**\n * Parse ArcGis webscene\n * @param data\n */\nasync function parse(data: ArrayBuffer): Promise<ArcGisWebSceneData> {\n return parseWebscene(data);\n}\n"],"file":"arcgis-webscene-loader.js"}
|
|
@@ -24,7 +24,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
24
24
|
|
|
25
25
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
26
26
|
|
|
27
|
-
var VERSION = typeof "3.2.0-alpha.
|
|
27
|
+
var VERSION = typeof "3.2.0-alpha.4" !== 'undefined' ? "3.2.0-alpha.4" : 'latest';
|
|
28
28
|
var EMPTY_VALUE = '';
|
|
29
29
|
var REJECTED_STATUS = 'rejected';
|
|
30
30
|
var I3SAttributeLoader = {
|
|
@@ -13,7 +13,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
13
13
|
|
|
14
14
|
var _parseI3sBuildingSceneLayer = require("./lib/parsers/parse-i3s-building-scene-layer");
|
|
15
15
|
|
|
16
|
-
var VERSION = typeof "3.2.0-alpha.
|
|
16
|
+
var VERSION = typeof "3.2.0-alpha.4" !== 'undefined' ? "3.2.0-alpha.4" : 'beta';
|
|
17
17
|
var I3SBuildingSceneLayerLoader = {
|
|
18
18
|
name: 'I3S Building Scene Layer',
|
|
19
19
|
id: 'i3s-building-scene-layer',
|
|
@@ -13,7 +13,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
13
13
|
|
|
14
14
|
var _parseI3sTileContent = require("./lib/parsers/parse-i3s-tile-content");
|
|
15
15
|
|
|
16
|
-
var VERSION = typeof "3.2.0-alpha.
|
|
16
|
+
var VERSION = typeof "3.2.0-alpha.4" !== 'undefined' ? "3.2.0-alpha.4" : 'beta';
|
|
17
17
|
var I3SContentLoader = {
|
|
18
18
|
name: 'I3S Content (Indexed Scene Layers)',
|
|
19
19
|
id: 'i3s-content',
|
package/dist/es5/i3s-loader.js
CHANGED
|
@@ -21,7 +21,7 @@ var _parseI3s = require("./lib/parsers/parse-i3s");
|
|
|
21
21
|
|
|
22
22
|
var _constants = require("./lib/parsers/constants");
|
|
23
23
|
|
|
24
|
-
var VERSION = typeof "3.2.0-alpha.
|
|
24
|
+
var VERSION = typeof "3.2.0-alpha.4" !== 'undefined' ? "3.2.0-alpha.4" : 'latest';
|
|
25
25
|
var TILESET_REGEX = /layers\/[0-9]+$/;
|
|
26
26
|
var TILE_HEADER_REGEX = /nodes\/([0-9-]+|root)$/;
|
|
27
27
|
var SLPK_HEX = '504b0304';
|
|
@@ -11,7 +11,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
11
11
|
|
|
12
12
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
13
|
|
|
14
|
-
var VERSION = typeof "3.2.0-alpha.
|
|
14
|
+
var VERSION = typeof "3.2.0-alpha.4" !== 'undefined' ? "3.2.0-alpha.4" : 'latest';
|
|
15
15
|
|
|
16
16
|
function parseNodePage(_x) {
|
|
17
17
|
return _parseNodePage.apply(this, arguments);
|
package/dist/es5/index.js
CHANGED
|
@@ -33,6 +33,12 @@ Object.defineProperty(exports, "I3SBuildingSceneLayerLoader", {
|
|
|
33
33
|
return _i3sBuildingSceneLayerLoader.I3SBuildingSceneLayerLoader;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
+
Object.defineProperty(exports, "ArcGisWebSceneLoader", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _arcgisWebsceneLoader.ArcGisWebSceneLoader;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
36
42
|
Object.defineProperty(exports, "COORDINATE_SYSTEM", {
|
|
37
43
|
enumerable: true,
|
|
38
44
|
get: function get() {
|
|
@@ -48,5 +54,7 @@ var _i3sAttributeLoader = require("./i3s-attribute-loader");
|
|
|
48
54
|
|
|
49
55
|
var _i3sBuildingSceneLayerLoader = require("./i3s-building-scene-layer-loader");
|
|
50
56
|
|
|
57
|
+
var _arcgisWebsceneLoader = require("./arcgis-webscene-loader");
|
|
58
|
+
|
|
51
59
|
var _constants = require("./lib/parsers/constants");
|
|
52
60
|
//# sourceMappingURL=index.js.map
|
package/dist/es5/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AA0BA","sourcesContent":["export {I3SLoader} from './i3s-loader';\nexport {I3SContentLoader} from './i3s-content-loader';\nexport {I3SAttributeLoader, loadFeatureAttributes} from './i3s-attribute-loader';\nexport {I3SBuildingSceneLayerLoader} from './i3s-building-scene-layer-loader';\nexport {ArcGisWebSceneLoader} from './arcgis-webscene-loader';\nexport type {\n BoundingVolumes,\n Mbs,\n Obb,\n SceneLayer3D,\n AttributeStorageInfo,\n Field,\n ESRIField,\n PopupInfo,\n Node3DIndexDocument,\n LodSelection,\n NodeReference,\n Resource,\n MaxScreenThresholdSQ,\n NodeInPage,\n SharedResources,\n Attribute,\n Extent,\n FeatureAttribute,\n FieldInfo,\n I3SMaterialDefinition,\n TextureDefinitionInfo,\n MaterialDefinitionInfo,\n FullExtent\n} from './types';\nexport {COORDINATE_SYSTEM} from './lib/parsers/constants';\n"],"file":"index.js"}
|
|
@@ -49,11 +49,13 @@ var I3SNodePagesTiles = function () {
|
|
|
49
49
|
(0, _defineProperty2.default)(this, "options", void 0);
|
|
50
50
|
(0, _defineProperty2.default)(this, "lodSelectionMetricType", void 0);
|
|
51
51
|
(0, _defineProperty2.default)(this, "textureDefinitionsSelectedFormats", []);
|
|
52
|
+
(0, _defineProperty2.default)(this, "nodesInNodePages", void 0);
|
|
52
53
|
(0, _defineProperty2.default)(this, "textureLoaderOptions", {});
|
|
53
54
|
this.tileset = _objectSpread({}, tileset);
|
|
54
55
|
this.nodesPerPage = ((_tileset$nodePages = tileset.nodePages) === null || _tileset$nodePages === void 0 ? void 0 : _tileset$nodePages.nodesPerPage) || 64;
|
|
55
56
|
this.lodSelectionMetricType = (_tileset$nodePages2 = tileset.nodePages) === null || _tileset$nodePages2 === void 0 ? void 0 : _tileset$nodePages2.lodSelectionMetricType;
|
|
56
57
|
this.options = options;
|
|
58
|
+
this.nodesInNodePages = 0;
|
|
57
59
|
this.initSelectedFormatsForTextureDefinitions(tileset);
|
|
58
60
|
}
|
|
59
61
|
|
|
@@ -70,7 +72,7 @@ var I3SNodePagesTiles = function () {
|
|
|
70
72
|
pageIndex = Math.floor(id / this.nodesPerPage);
|
|
71
73
|
|
|
72
74
|
if (!(!this.nodePages[pageIndex] && !this.pendingNodePages[pageIndex])) {
|
|
73
|
-
_context.next =
|
|
75
|
+
_context.next = 9;
|
|
74
76
|
break;
|
|
75
77
|
}
|
|
76
78
|
|
|
@@ -84,25 +86,26 @@ var I3SNodePagesTiles = function () {
|
|
|
84
86
|
|
|
85
87
|
case 6:
|
|
86
88
|
this.nodePages[pageIndex] = _context.sent;
|
|
89
|
+
this.nodesInNodePages += this.nodePages[pageIndex].nodes.length;
|
|
87
90
|
this.pendingNodePages[pageIndex].status = 'Done';
|
|
88
91
|
|
|
89
|
-
case
|
|
92
|
+
case 9:
|
|
90
93
|
if (!(this.pendingNodePages[pageIndex].status === 'Pending')) {
|
|
91
|
-
_context.next =
|
|
94
|
+
_context.next = 13;
|
|
92
95
|
break;
|
|
93
96
|
}
|
|
94
97
|
|
|
95
|
-
_context.next =
|
|
98
|
+
_context.next = 12;
|
|
96
99
|
return this.pendingNodePages[pageIndex].promise;
|
|
97
100
|
|
|
98
|
-
case
|
|
101
|
+
case 12:
|
|
99
102
|
this.nodePages[pageIndex] = _context.sent;
|
|
100
103
|
|
|
101
|
-
case
|
|
104
|
+
case 13:
|
|
102
105
|
nodeIndex = id % this.nodesPerPage;
|
|
103
106
|
return _context.abrupt("return", this.nodePages[pageIndex].nodes[nodeIndex]);
|
|
104
107
|
|
|
105
|
-
case
|
|
108
|
+
case 15:
|
|
106
109
|
case "end":
|
|
107
110
|
return _context.stop();
|
|
108
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/helpers/i3s-nodepages-tiles.ts"],"names":["I3SNodePagesTiles","tileset","options","nodesPerPage","nodePages","lodSelectionMetricType","initSelectedFormatsForTextureDefinitions","id","pageIndex","Math","floor","pendingNodePages","nodePageUrl","url","i3s","token","status","promise","I3SNodePageLoader","nodeIndex","nodes","getNodeById","node","children","childNodesPromises","child","push","Promise","all","childNodes","childNode","index","toString","obb","textureFormat","attributeUrls","isDracoGeometry","mesh","geometry","getContentUrl","isDracoGeometryResult","contentUrl","getInformationFromMaterial","material","textureData","nodeMaterialDefinition","materialDefinition","format","name","textureUrl","resource","attributeStorageInfo","attribute","lodSelection","getLodSelection","textureLoaderOptions","meshGeometryData","result","geometryDefinition","geometryDefinitions","definition","geometryIndex","useDracoGeometry","geometryBuffers","findIndex","buffer","compressedAttributes","encoding","Boolean","metricType","maxError","sqrt","lodThreshold","PI","informationFromMaterial","materialDefinitions","textureSetDefinitionIndex","pbrMetallicRoughness","baseColorTexture","textureSetDefinitionId","textureDefinitionsSelectedFormats","possibleI3sFormats","getSupportedTextureFormats","textureSetDefinitions","textureSetDefinition","formats","selectedFormat","i3sFormat","find","value","basis","containerFormat","module","useCompressedTextures","supportedCompressedFormats","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AAM,EAAE;AAHwB,aAAlC;AAKD;;AAED,eAAKZ,iCAAL,CAAuCtD,IAAvC,CAA4C4D,cAA5C;AACD;AAxB+E;AAAA;AAAA;AAAA;AAAA;AAyBjF;;;WAMD,sCAAyD;AACvD,UAAMD,OAA2B,GAAG,EAApC;;AACA,UAAI,CAAC,KAAKnF,OAAL,CAAaY,GAAd,IAAqB,KAAKZ,OAAL,CAAaY,GAAb,CAAiB+E,qBAA1C,EAAiE;AAE/D,YAAMC,0BAA0B,GAAG,8CAAnC;;AAGA,YAAIA,0BAA0B,CAACC,GAA3B,CAA+B,MAA/B,CAAJ,EAA4C;AAC1CV,UAAAA,OAAO,CAAC3D,IAAR,CAAa,UAAb;AACD;;AACD,YAAIoE,0BAA0B,CAACC,GAA3B,CAA+B,KAA/B,CAAJ,EAA2C;AACzCV,UAAAA,OAAO,CAAC3D,IAAR,CAAa,KAAb;AACD;;AAID2D,QAAAA,OAAO,CAAC3D,IAAR,CAAa,MAAb;AACD;;AAED2D,MAAAA,OAAO,CAAC3D,IAAR,CAAa,KAAb;AACA2D,MAAAA,OAAO,CAAC3D,IAAR,CAAa,KAAb;AACA,aAAO2D,OAAP;AACD","sourcesContent":["import {load} from '@loaders.gl/core';\nimport {getSupportedGPUTextureFormats, selectSupportedBasisFormat} from '@loaders.gl/textures';\nimport {I3SNodePageLoader} from '../../i3s-node-page-loader';\nimport {normalizeTileNonUrlData} from '../parsers/parse-i3s';\nimport {getUrlWithToken, generateTilesetAttributeUrls} from '../utils/url-utils';\nimport type {LoaderOptions} from '@loaders.gl/loader-utils';\nimport {\n I3STilesetHeader,\n LodSelection,\n NodePage,\n NodeInPage,\n Obb,\n MeshMaterial,\n I3SMaterialDefinition,\n I3STextureFormat,\n MeshGeometry,\n I3STileHeader\n} from '../../types';\n\n/**\n * class I3SNodePagesTiles - loads nodePages and form i3s tiles from them\n */\nexport default class I3SNodePagesTiles {\n tileset: I3STilesetHeader;\n nodePages: NodePage[] = [];\n pendingNodePages: {promise: Promise<NodePage>; status: 'Pending' | 'Done'}[] = [];\n nodesPerPage: number;\n options: LoaderOptions;\n lodSelectionMetricType?: string;\n textureDefinitionsSelectedFormats: ({format: I3STextureFormat; name: string} | null)[] = [];\n private textureLoaderOptions: {[key: string]: any} = {};\n\n /**\n * @constructs\n * Create a I3SNodePagesTiles instance.\n * @param tileset - i3s tileset header ('layers/0')\n * @param options - i3s loader options\n */\n constructor(tileset: I3STilesetHeader, options: LoaderOptions) {\n this.tileset = {...tileset}; // spread the tileset to avoid circular reference\n this.nodesPerPage = tileset.nodePages?.nodesPerPage || 64;\n this.lodSelectionMetricType = tileset.nodePages?.lodSelectionMetricType;\n this.options = options;\n\n this.initSelectedFormatsForTextureDefinitions(tileset);\n }\n\n /**\n * Loads some nodePage and return a particular node from it\n * @param id - id of node through all node pages\n */\n async getNodeById(id: number): Promise<NodeInPage> {\n const pageIndex = Math.floor(id / this.nodesPerPage);\n if (!this.nodePages[pageIndex] && !this.pendingNodePages[pageIndex]) {\n const nodePageUrl = getUrlWithToken(\n `${this.tileset.url}/nodepages/${pageIndex}`,\n this.options.i3s?.token\n );\n this.pendingNodePages[pageIndex] = {\n status: 'Pending',\n promise: load(nodePageUrl, I3SNodePageLoader, this.options)\n };\n this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;\n this.pendingNodePages[pageIndex].status = 'Done';\n }\n if (this.pendingNodePages[pageIndex].status === 'Pending') {\n this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;\n }\n const nodeIndex = id % this.nodesPerPage;\n return this.nodePages[pageIndex].nodes[nodeIndex];\n }\n\n /**\n * Forms tile header using node and tileset data\n * @param id - id of node through all node pages\n */\n // eslint-disable-next-line complexity, max-statements\n async formTileFromNodePages(id: number): Promise<I3STileHeader> {\n const node: NodeInPage = await this.getNodeById(id);\n const children: {id: string; obb: Obb}[] = [];\n const childNodesPromises: Promise<NodeInPage>[] = [];\n for (const child of node.children || []) {\n childNodesPromises.push(this.getNodeById(child));\n }\n\n const childNodes = await Promise.all(childNodesPromises);\n for (const childNode of childNodes) {\n children.push({\n id: childNode.index.toString(),\n obb: childNode.obb\n });\n }\n\n let contentUrl: string | undefined;\n let textureUrl: string | undefined;\n let materialDefinition: I3SMaterialDefinition | undefined;\n let textureFormat: I3STextureFormat = 'jpg';\n let attributeUrls: string[] = [];\n let isDracoGeometry: boolean = false;\n\n if (node && node.mesh) {\n // Get geometry resource URL and type (compressed / non-compressed)\n const {url, isDracoGeometry: isDracoGeometryResult} = (node.mesh.geometry &&\n this.getContentUrl(node.mesh.geometry)) || {isDracoGeometry: false};\n contentUrl = url;\n isDracoGeometry = isDracoGeometryResult;\n\n const {textureData, materialDefinition: nodeMaterialDefinition} =\n this.getInformationFromMaterial(node.mesh.material);\n materialDefinition = nodeMaterialDefinition;\n textureFormat = textureData.format || textureFormat;\n if (textureData.name) {\n textureUrl = `${this.tileset.url}/nodes/${node.mesh.material.resource}/textures/${textureData.name}`;\n }\n\n if (this.tileset.attributeStorageInfo) {\n attributeUrls = generateTilesetAttributeUrls(this.tileset, node.mesh.attribute.resource);\n }\n }\n\n const lodSelection = this.getLodSelection(node);\n\n return normalizeTileNonUrlData({\n id: id.toString(),\n lodSelection,\n obb: node.obb,\n contentUrl,\n textureUrl,\n attributeUrls,\n materialDefinition,\n textureFormat,\n textureLoaderOptions: this.textureLoaderOptions,\n children,\n isDracoGeometry\n });\n }\n\n /**\n * Forms url and type of geometry resource by nodepage's data and `geometryDefinitions` in the tileset\n * @param - data about the node's mesh from the nodepage\n * @returns -\n * {string} url - url to the geometry resource\n * {boolean} isDracoGeometry - whether the geometry resource contain DRACO compressed geometry\n */\n private getContentUrl(meshGeometryData: MeshGeometry) {\n let result: {url: string; isDracoGeometry: boolean} | null = null;\n // @ts-ignore\n const geometryDefinition = this.tileset.geometryDefinitions[meshGeometryData.definition];\n let geometryIndex = -1;\n // Try to find DRACO geometryDefinition of `useDracoGeometry` option is set\n if (this.options.i3s && this.options.i3s.useDracoGeometry) {\n geometryIndex = geometryDefinition.geometryBuffers.findIndex(\n (buffer) => buffer.compressedAttributes && buffer.compressedAttributes.encoding === 'draco'\n );\n }\n // If DRACO geometry is not applicable try to select non-compressed geometry\n if (geometryIndex === -1) {\n geometryIndex = geometryDefinition.geometryBuffers.findIndex(\n (buffer) => !buffer.compressedAttributes\n );\n }\n if (geometryIndex !== -1) {\n const isDracoGeometry = Boolean(\n geometryDefinition.geometryBuffers[geometryIndex].compressedAttributes\n );\n result = {\n url: `${this.tileset.url}/nodes/${meshGeometryData.resource}/geometries/${geometryIndex}`,\n isDracoGeometry\n };\n }\n return result;\n }\n\n /**\n * Forms 1.6 compatible LOD selection object from a nodepage's node data\n * @param node - a node from nodepage\n * @returns- Array of LodSelection\n */\n private getLodSelection(node: NodeInPage): LodSelection[] {\n const lodSelection: LodSelection[] = [];\n if (this.lodSelectionMetricType === 'maxScreenThresholdSQ') {\n lodSelection.push({\n metricType: 'maxScreenThreshold',\n // @ts-ignore\n maxError: Math.sqrt(node.lodThreshold / (Math.PI * 0.25))\n });\n }\n lodSelection.push({\n metricType: this.lodSelectionMetricType,\n // @ts-ignore\n maxError: node.lodThreshold\n });\n return lodSelection;\n }\n\n /**\n * Returns information about texture and material from `materialDefinitions`\n * @param material - material data from nodepage\n * @returns - Couple {textureData, materialDefinition}\n * {string} textureData.name - path name of the texture\n * {string} textureData.format - format of the texture\n * materialDefinition - PBR-like material definition from `materialDefinitions`\n */\n private getInformationFromMaterial(material: MeshMaterial) {\n const informationFromMaterial: {\n textureData: {name: string | null; format?: I3STextureFormat};\n materialDefinition?: I3SMaterialDefinition;\n } = {textureData: {name: null}};\n\n if (material) {\n const materialDefinition = this.tileset.materialDefinitions?.[material.definition];\n if (materialDefinition) {\n informationFromMaterial.materialDefinition = materialDefinition;\n const textureSetDefinitionIndex =\n materialDefinition?.pbrMetallicRoughness?.baseColorTexture?.textureSetDefinitionId;\n\n if (typeof textureSetDefinitionIndex === 'number') {\n informationFromMaterial.textureData =\n this.textureDefinitionsSelectedFormats[textureSetDefinitionIndex] ||\n informationFromMaterial.textureData;\n }\n }\n }\n return informationFromMaterial;\n }\n\n /**\n * Sets preferable and supported format for each textureDefinition of the tileset\n * @param tileset - I3S layer data\n * @returns\n */\n private initSelectedFormatsForTextureDefinitions(tileset: I3STilesetHeader): void {\n this.textureDefinitionsSelectedFormats = [];\n const possibleI3sFormats = this.getSupportedTextureFormats();\n const textureSetDefinitions = tileset.textureSetDefinitions || [];\n for (const textureSetDefinition of textureSetDefinitions) {\n const formats = (textureSetDefinition && textureSetDefinition.formats) || [];\n let selectedFormat: {name: string; format: I3STextureFormat} | null = null;\n for (const i3sFormat of possibleI3sFormats) {\n const format = formats.find((value) => value.format === i3sFormat);\n if (format) {\n selectedFormat = format;\n break;\n }\n }\n // For I3S 1.8 need to define basis target format to decode\n if (selectedFormat && selectedFormat.format === 'ktx2') {\n this.textureLoaderOptions.basis = {\n format: selectSupportedBasisFormat(),\n containerFormat: 'ktx2',\n module: 'encoder'\n };\n }\n\n this.textureDefinitionsSelectedFormats.push(selectedFormat);\n }\n }\n\n /**\n * Returns the array of supported texture format\n * @returns list of format strings\n */\n private getSupportedTextureFormats(): I3STextureFormat[] {\n const formats: I3STextureFormat[] = [];\n if (!this.options.i3s || this.options.i3s.useCompressedTextures) {\n // I3S 1.7 selection\n const supportedCompressedFormats = getSupportedGPUTextureFormats();\n // List of possible in i3s formats:\n // https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md\n if (supportedCompressedFormats.has('etc2')) {\n formats.push('ktx-etc2');\n }\n if (supportedCompressedFormats.has('dxt')) {\n formats.push('dds');\n }\n\n // I3S 1.8 selection\n // ktx2 wraps basis texture which at the edge case can be decoded as uncompressed image\n formats.push('ktx2');\n }\n\n formats.push('jpg');\n formats.push('png');\n return formats;\n }\n}\n"],"file":"i3s-nodepages-tiles.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/helpers/i3s-nodepages-tiles.ts"],"names":["I3SNodePagesTiles","tileset","options","nodesPerPage","nodePages","lodSelectionMetricType","nodesInNodePages","initSelectedFormatsForTextureDefinitions","id","pageIndex","Math","floor","pendingNodePages","nodePageUrl","url","i3s","token","status","promise","I3SNodePageLoader","nodes","length","nodeIndex","getNodeById","node","children","childNodesPromises","child","push","Promise","all","childNodes","childNode","index","toString","obb","textureFormat","attributeUrls","isDracoGeometry","mesh","geometry","getContentUrl","isDracoGeometryResult","contentUrl","getInformationFromMaterial","material","textureData","nodeMaterialDefinition","materialDefinition","format","name","textureUrl","resource","attributeStorageInfo","attribute","lodSelection","getLodSelection","textureLoaderOptions","meshGeometryData","result","geometryDefinition","geometryDefinitions","definition","geometryIndex","useDracoGeometry","geometryBuffers","findIndex","buffer","compressedAttributes","encoding","Boolean","metricType","maxError","sqrt","lodThreshold","PI","informationFromMaterial","materialDefinitions","textureSetDefinitionIndex","pbrMetallicRoughness","baseColorTexture","textureSetDefinitionId","textureDefinitionsSelectedFormats","possibleI3sFormats","getSupportedTextureFormats","textureSetDefinitions","textureSetDefinition","formats","selectedFormat","i3sFormat","find","value","basis","containerFormat","module","useCompressedTextures","supportedCompressedFormats","has"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;IAkBqBA,iB;AAiBnB,6BAAYC,OAAZ,EAAuCC,OAAvC,EAA+D;AAAA;;AAAA;AAAA;AAAA,qDAfvC,EAeuC;AAAA,4DAdgB,EAchB;AAAA;AAAA;AAAA;AAAA,6EAV0B,EAU1B;AAAA;AAAA,gEARV,EAQU;AAC7D,SAAKD,OAAL,qBAAmBA,OAAnB;AACA,SAAKE,YAAL,GAAoB,uBAAAF,OAAO,CAACG,SAAR,0EAAmBD,YAAnB,KAAmC,EAAvD;AACA,SAAKE,sBAAL,0BAA8BJ,OAAO,CAACG,SAAtC,wDAA8B,oBAAmBC,sBAAjD;AACA,SAAKH,OAAL,GAAeA,OAAf;AACA,SAAKI,gBAAL,GA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EAA4C;AAC1CV,UAAAA,OAAO,CAAC3D,IAAR,CAAa,UAAb;AACD;;AACD,YAAIoE,0BAA0B,CAACC,GAA3B,CAA+B,KAA/B,CAAJ,EAA2C;AACzCV,UAAAA,OAAO,CAAC3D,IAAR,CAAa,KAAb;AACD;;AAID2D,QAAAA,OAAO,CAAC3D,IAAR,CAAa,MAAb;AACD;;AAED2D,MAAAA,OAAO,CAAC3D,IAAR,CAAa,KAAb;AACA2D,MAAAA,OAAO,CAAC3D,IAAR,CAAa,KAAb;AACA,aAAO2D,OAAP;AACD","sourcesContent":["import {load} from '@loaders.gl/core';\nimport {getSupportedGPUTextureFormats, selectSupportedBasisFormat} from '@loaders.gl/textures';\nimport {I3SNodePageLoader} from '../../i3s-node-page-loader';\nimport {normalizeTileNonUrlData} from '../parsers/parse-i3s';\nimport {getUrlWithToken, generateTilesetAttributeUrls} from '../utils/url-utils';\nimport type {LoaderOptions} from '@loaders.gl/loader-utils';\nimport {\n I3STilesetHeader,\n LodSelection,\n NodePage,\n NodeInPage,\n Obb,\n MeshMaterial,\n I3SMaterialDefinition,\n I3STextureFormat,\n MeshGeometry,\n I3STileHeader\n} from '../../types';\n\n/**\n * class I3SNodePagesTiles - loads nodePages and form i3s tiles from them\n */\nexport default class I3SNodePagesTiles {\n tileset: I3STilesetHeader;\n nodePages: NodePage[] = [];\n pendingNodePages: {promise: Promise<NodePage>; status: 'Pending' | 'Done'}[] = [];\n nodesPerPage: number;\n options: LoaderOptions;\n lodSelectionMetricType?: string;\n textureDefinitionsSelectedFormats: ({format: I3STextureFormat; name: string} | null)[] = [];\n nodesInNodePages: number;\n private textureLoaderOptions: {[key: string]: any} = {};\n\n /**\n * @constructs\n * Create a I3SNodePagesTiles instance.\n * @param tileset - i3s tileset header ('layers/0')\n * @param options - i3s loader options\n */\n constructor(tileset: I3STilesetHeader, options: LoaderOptions) {\n this.tileset = {...tileset}; // spread the tileset to avoid circular reference\n this.nodesPerPage = tileset.nodePages?.nodesPerPage || 64;\n this.lodSelectionMetricType = tileset.nodePages?.lodSelectionMetricType;\n this.options = options;\n this.nodesInNodePages = 0;\n\n this.initSelectedFormatsForTextureDefinitions(tileset);\n }\n\n /**\n * Loads some nodePage and return a particular node from it\n * @param id - id of node through all node pages\n */\n async getNodeById(id: number): Promise<NodeInPage> {\n const pageIndex = Math.floor(id / this.nodesPerPage);\n if (!this.nodePages[pageIndex] && !this.pendingNodePages[pageIndex]) {\n const nodePageUrl = getUrlWithToken(\n `${this.tileset.url}/nodepages/${pageIndex}`,\n this.options.i3s?.token\n );\n this.pendingNodePages[pageIndex] = {\n status: 'Pending',\n promise: load(nodePageUrl, I3SNodePageLoader, this.options)\n };\n this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;\n this.nodesInNodePages += this.nodePages[pageIndex].nodes.length;\n this.pendingNodePages[pageIndex].status = 'Done';\n }\n if (this.pendingNodePages[pageIndex].status === 'Pending') {\n this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;\n }\n const nodeIndex = id % this.nodesPerPage;\n return this.nodePages[pageIndex].nodes[nodeIndex];\n }\n\n /**\n * Forms tile header using node and tileset data\n * @param id - id of node through all node pages\n */\n // eslint-disable-next-line complexity, max-statements\n async formTileFromNodePages(id: number): Promise<I3STileHeader> {\n const node: NodeInPage = await this.getNodeById(id);\n const children: {id: string; obb: Obb}[] = [];\n const childNodesPromises: Promise<NodeInPage>[] = [];\n for (const child of node.children || []) {\n childNodesPromises.push(this.getNodeById(child));\n }\n\n const childNodes = await Promise.all(childNodesPromises);\n for (const childNode of childNodes) {\n children.push({\n id: childNode.index.toString(),\n obb: childNode.obb\n });\n }\n\n let contentUrl: string | undefined;\n let textureUrl: string | undefined;\n let materialDefinition: I3SMaterialDefinition | undefined;\n let textureFormat: I3STextureFormat = 'jpg';\n let attributeUrls: string[] = [];\n let isDracoGeometry: boolean = false;\n\n if (node && node.mesh) {\n // Get geometry resource URL and type (compressed / non-compressed)\n const {url, isDracoGeometry: isDracoGeometryResult} = (node.mesh.geometry &&\n this.getContentUrl(node.mesh.geometry)) || {isDracoGeometry: false};\n contentUrl = url;\n isDracoGeometry = isDracoGeometryResult;\n\n const {textureData, materialDefinition: nodeMaterialDefinition} =\n this.getInformationFromMaterial(node.mesh.material);\n materialDefinition = nodeMaterialDefinition;\n textureFormat = textureData.format || textureFormat;\n if (textureData.name) {\n textureUrl = `${this.tileset.url}/nodes/${node.mesh.material.resource}/textures/${textureData.name}`;\n }\n\n if (this.tileset.attributeStorageInfo) {\n attributeUrls = generateTilesetAttributeUrls(this.tileset, node.mesh.attribute.resource);\n }\n }\n\n const lodSelection = this.getLodSelection(node);\n\n return normalizeTileNonUrlData({\n id: id.toString(),\n lodSelection,\n obb: node.obb,\n contentUrl,\n textureUrl,\n attributeUrls,\n materialDefinition,\n textureFormat,\n textureLoaderOptions: this.textureLoaderOptions,\n children,\n isDracoGeometry\n });\n }\n\n /**\n * Forms url and type of geometry resource by nodepage's data and `geometryDefinitions` in the tileset\n * @param - data about the node's mesh from the nodepage\n * @returns -\n * {string} url - url to the geometry resource\n * {boolean} isDracoGeometry - whether the geometry resource contain DRACO compressed geometry\n */\n private getContentUrl(meshGeometryData: MeshGeometry) {\n let result: {url: string; isDracoGeometry: boolean} | null = null;\n // @ts-ignore\n const geometryDefinition = this.tileset.geometryDefinitions[meshGeometryData.definition];\n let geometryIndex = -1;\n // Try to find DRACO geometryDefinition of `useDracoGeometry` option is set\n if (this.options.i3s && this.options.i3s.useDracoGeometry) {\n geometryIndex = geometryDefinition.geometryBuffers.findIndex(\n (buffer) => buffer.compressedAttributes && buffer.compressedAttributes.encoding === 'draco'\n );\n }\n // If DRACO geometry is not applicable try to select non-compressed geometry\n if (geometryIndex === -1) {\n geometryIndex = geometryDefinition.geometryBuffers.findIndex(\n (buffer) => !buffer.compressedAttributes\n );\n }\n if (geometryIndex !== -1) {\n const isDracoGeometry = Boolean(\n geometryDefinition.geometryBuffers[geometryIndex].compressedAttributes\n );\n result = {\n url: `${this.tileset.url}/nodes/${meshGeometryData.resource}/geometries/${geometryIndex}`,\n isDracoGeometry\n };\n }\n return result;\n }\n\n /**\n * Forms 1.6 compatible LOD selection object from a nodepage's node data\n * @param node - a node from nodepage\n * @returns- Array of LodSelection\n */\n private getLodSelection(node: NodeInPage): LodSelection[] {\n const lodSelection: LodSelection[] = [];\n if (this.lodSelectionMetricType === 'maxScreenThresholdSQ') {\n lodSelection.push({\n metricType: 'maxScreenThreshold',\n // @ts-ignore\n maxError: Math.sqrt(node.lodThreshold / (Math.PI * 0.25))\n });\n }\n lodSelection.push({\n metricType: this.lodSelectionMetricType,\n // @ts-ignore\n maxError: node.lodThreshold\n });\n return lodSelection;\n }\n\n /**\n * Returns information about texture and material from `materialDefinitions`\n * @param material - material data from nodepage\n * @returns - Couple {textureData, materialDefinition}\n * {string} textureData.name - path name of the texture\n * {string} textureData.format - format of the texture\n * materialDefinition - PBR-like material definition from `materialDefinitions`\n */\n private getInformationFromMaterial(material: MeshMaterial) {\n const informationFromMaterial: {\n textureData: {name: string | null; format?: I3STextureFormat};\n materialDefinition?: I3SMaterialDefinition;\n } = {textureData: {name: null}};\n\n if (material) {\n const materialDefinition = this.tileset.materialDefinitions?.[material.definition];\n if (materialDefinition) {\n informationFromMaterial.materialDefinition = materialDefinition;\n const textureSetDefinitionIndex =\n materialDefinition?.pbrMetallicRoughness?.baseColorTexture?.textureSetDefinitionId;\n\n if (typeof textureSetDefinitionIndex === 'number') {\n informationFromMaterial.textureData =\n this.textureDefinitionsSelectedFormats[textureSetDefinitionIndex] ||\n informationFromMaterial.textureData;\n }\n }\n }\n return informationFromMaterial;\n }\n\n /**\n * Sets preferable and supported format for each textureDefinition of the tileset\n * @param tileset - I3S layer data\n * @returns\n */\n private initSelectedFormatsForTextureDefinitions(tileset: I3STilesetHeader): void {\n this.textureDefinitionsSelectedFormats = [];\n const possibleI3sFormats = this.getSupportedTextureFormats();\n const textureSetDefinitions = tileset.textureSetDefinitions || [];\n for (const textureSetDefinition of textureSetDefinitions) {\n const formats = (textureSetDefinition && textureSetDefinition.formats) || [];\n let selectedFormat: {name: string; format: I3STextureFormat} | null = null;\n for (const i3sFormat of possibleI3sFormats) {\n const format = formats.find((value) => value.format === i3sFormat);\n if (format) {\n selectedFormat = format;\n break;\n }\n }\n // For I3S 1.8 need to define basis target format to decode\n if (selectedFormat && selectedFormat.format === 'ktx2') {\n this.textureLoaderOptions.basis = {\n format: selectSupportedBasisFormat(),\n containerFormat: 'ktx2',\n module: 'encoder'\n };\n }\n\n this.textureDefinitionsSelectedFormats.push(selectedFormat);\n }\n }\n\n /**\n * Returns the array of supported texture format\n * @returns list of format strings\n */\n private getSupportedTextureFormats(): I3STextureFormat[] {\n const formats: I3STextureFormat[] = [];\n if (!this.options.i3s || this.options.i3s.useCompressedTextures) {\n // I3S 1.7 selection\n const supportedCompressedFormats = getSupportedGPUTextureFormats();\n // List of possible in i3s formats:\n // https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md\n if (supportedCompressedFormats.has('etc2')) {\n formats.push('ktx-etc2');\n }\n if (supportedCompressedFormats.has('dxt')) {\n formats.push('dds');\n }\n\n // I3S 1.8 selection\n // ktx2 wraps basis texture which at the edge case can be decoded as uncompressed image\n formats.push('ktx2');\n }\n\n formats.push('jpg');\n formats.push('png');\n return formats;\n }\n}\n"],"file":"i3s-nodepages-tiles.js"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.parseWebscene = parseWebscene;
|
|
9
|
+
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
+
|
|
14
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
+
|
|
16
|
+
var ARCGIS_SCENE_SERVER_LAYER_TYPE = 'ArcGISSceneServiceLayer';
|
|
17
|
+
var BUILDING_SCENE_LAYER = 'BuildingSceneLayer';
|
|
18
|
+
var INTEGRATED_MESH_LAYER = 'IntegratedMeshLayer';
|
|
19
|
+
var SUPPORTED_LAYERS_TYPES = [ARCGIS_SCENE_SERVER_LAYER_TYPE, INTEGRATED_MESH_LAYER, BUILDING_SCENE_LAYER];
|
|
20
|
+
|
|
21
|
+
function parseWebscene(_x) {
|
|
22
|
+
return _parseWebscene.apply(this, arguments);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function _parseWebscene() {
|
|
26
|
+
_parseWebscene = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(data) {
|
|
27
|
+
var layer0, operationalLayers;
|
|
28
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
29
|
+
while (1) {
|
|
30
|
+
switch (_context.prev = _context.next) {
|
|
31
|
+
case 0:
|
|
32
|
+
layer0 = JSON.parse(new TextDecoder().decode(data));
|
|
33
|
+
operationalLayers = layer0.operationalLayers;
|
|
34
|
+
return _context.abrupt("return", {
|
|
35
|
+
header: layer0,
|
|
36
|
+
layers: parseOperationalLayers(operationalLayers)
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
case 3:
|
|
40
|
+
case "end":
|
|
41
|
+
return _context.stop();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}, _callee);
|
|
45
|
+
}));
|
|
46
|
+
return _parseWebscene.apply(this, arguments);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function parseOperationalLayers(layersList) {
|
|
50
|
+
var layers = [];
|
|
51
|
+
|
|
52
|
+
for (var index = 0; index < layersList.length; index++) {
|
|
53
|
+
var _layer$layers;
|
|
54
|
+
|
|
55
|
+
var layer = layersList[index];
|
|
56
|
+
|
|
57
|
+
if (SUPPORTED_LAYERS_TYPES.includes(layer.layerType)) {
|
|
58
|
+
layers.push(layer);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if ((_layer$layers = layer.layers) !== null && _layer$layers !== void 0 && _layer$layers.length) {
|
|
62
|
+
layers = [].concat((0, _toConsumableArray2.default)(layers), (0, _toConsumableArray2.default)(parseOperationalLayers(layer.layers)));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return layers;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=parse-arcgis-webscene.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/parsers/parse-arcgis-webscene.ts"],"names":["ARCGIS_SCENE_SERVER_LAYER_TYPE","BUILDING_SCENE_LAYER","INTEGRATED_MESH_LAYER","SUPPORTED_LAYERS_TYPES","parseWebscene","data","layer0","JSON","parse","TextDecoder","decode","operationalLayers","header","layers","parseOperationalLayers","layersList","index","length","layer","includes","layerType","push"],"mappings":";;;;;;;;;;;;;;;AAEA,IAAMA,8BAA8B,GAAG,yBAAvC;AACA,IAAMC,oBAAoB,GAAG,oBAA7B;AACA,IAAMC,qBAAqB,GAAG,qBAA9B;AAMA,IAAMC,sBAAsB,GAAG,CAC7BH,8BAD6B,EAE7BE,qBAF6B,EAG7BD,oBAH6B,CAA/B;;SAUsBG,a;;;;;6EAAf,iBAA6BC,IAA7B;AAAA;AAAA;AAAA;AAAA;AAAA;AACCC,YAAAA,MADD,GACUC,IAAI,CAACC,KAAL,CAAW,IAAIC,WAAJ,GAAkBC,MAAlB,CAAyBL,IAAzB,CAAX,CADV;AAEEM,YAAAA,iBAFF,GAEuBL,MAFvB,CAEEK,iBAFF;AAAA,6CAIE;AACLC,cAAAA,MAAM,EAAEN,MADH;AAELO,cAAAA,MAAM,EAAEC,sBAAsB,CAACH,iBAAD;AAFzB,aAJF;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G;;;;AAcP,SAASG,sBAAT,CAAgCC,UAAhC,EAAoF;AAClF,MAAIF,MAA0B,GAAG,EAAjC;;AAEA,OAAK,IAAIG,KAAK,GAAG,CAAjB,EAAoBA,KAAK,GAAGD,UAAU,CAACE,MAAvC,EAA+CD,KAAK,EAApD,EAAwD;AAAA;;AACtD,QAAME,KAAK,GAAGH,UAAU,CAACC,KAAD,CAAxB;;AAEA,QAAIb,sBAAsB,CAACgB,QAAvB,CAAgCD,KAAK,CAACE,SAAtC,CAAJ,EAAsD;AACpDP,MAAAA,MAAM,CAACQ,IAAP,CAAYH,KAAZ;AACD;;AAED,yBAAIA,KAAK,CAACL,MAAV,0CAAI,cAAcI,MAAlB,EAA0B;AACxBJ,MAAAA,MAAM,8CAAOA,MAAP,oCAAkBC,sBAAsB,CAACI,KAAK,CAACL,MAAP,CAAxC,EAAN;AACD;AACF;;AAED,SAAOA,MAAP;AACD","sourcesContent":["import type {ArcGisWebSceneData, OperationalLayer} from '../../types';\n\nconst ARCGIS_SCENE_SERVER_LAYER_TYPE = 'ArcGISSceneServiceLayer';\nconst BUILDING_SCENE_LAYER = 'BuildingSceneLayer';\nconst INTEGRATED_MESH_LAYER = 'IntegratedMeshLayer';\n\n/**\n * Supported layers list\n * Possible operational layers in WebScene: https://developers.arcgis.com/web-scene-specification/objects/operationalLayers/\n */\nconst SUPPORTED_LAYERS_TYPES = [\n ARCGIS_SCENE_SERVER_LAYER_TYPE,\n INTEGRATED_MESH_LAYER,\n BUILDING_SCENE_LAYER\n];\n\n/**\n * Parses ArcGIS WebScene\n * @param data\n */\nexport async function parseWebscene(data: ArrayBuffer): Promise<ArcGisWebSceneData> {\n const layer0 = JSON.parse(new TextDecoder().decode(data));\n const {operationalLayers} = layer0;\n\n return {\n header: layer0,\n layers: parseOperationalLayers(operationalLayers)\n };\n}\n\n/**\n * Recursively parses WebScene operational layers.\n * @param layersList\n */\nfunction parseOperationalLayers(layersList: OperationalLayer[]): OperationalLayer[] {\n let layers: OperationalLayer[] = [];\n\n for (let index = 0; index < layersList.length; index++) {\n const layer = layersList[index];\n\n if (SUPPORTED_LAYERS_TYPES.includes(layer.layerType)) {\n layers.push(layer);\n }\n\n if (layer.layers?.length) {\n layers = [...layers, ...parseOperationalLayers(layer.layers)];\n }\n }\n\n return layers;\n}\n"],"file":"parse-arcgis-webscene.js"}
|