@loaders.gl/i3s 3.1.0-alpha.4 → 3.1.0-beta.5
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/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +10364 -0
- package/dist/es5/bundle.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/i3s-attribute-loader.js +89 -138
- package/dist/es5/i3s-attribute-loader.js.map +1 -1
- package/dist/es5/i3s-building-scene-layer-loader.js +8 -36
- package/dist/es5/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/es5/i3s-content-loader.js +10 -36
- package/dist/es5/i3s-content-loader.js.map +1 -1
- package/dist/es5/i3s-loader.js +56 -176
- package/dist/es5/i3s-loader.js.map +1 -1
- package/dist/es5/i3s-node-page-loader.js +8 -51
- package/dist/es5/i3s-node-page-loader.js.map +1 -1
- package/dist/es5/index.js +13 -5
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +172 -325
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
- package/dist/es5/lib/parsers/constants.js +71 -25
- package/dist/es5/lib/parsers/constants.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-attribute.js +34 -68
- package/dist/es5/lib/parsers/parse-i3s-attribute.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js +28 -59
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js +314 -415
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s.js +31 -70
- package/dist/es5/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js +4 -8
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -1
- package/dist/es5/lib/utils/url-utils.js +17 -14
- package/dist/es5/lib/utils/url-utils.js.map +1 -1
- package/dist/es5/types.js +19 -0
- package/dist/es5/types.js.map +1 -1
- package/dist/esm/i3s-attribute-loader.js +44 -14
- package/dist/esm/i3s-attribute-loader.js.map +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/esm/i3s-content-loader.js +1 -1
- package/dist/esm/i3s-content-loader.js.map +1 -1
- package/dist/esm/i3s-loader.js +5 -2
- package/dist/esm/i3s-loader.js.map +1 -1
- package/dist/esm/i3s-node-page-loader.js +1 -1
- package/dist/esm/i3s-node-page-loader.js.map +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 +3 -3
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
- package/dist/esm/lib/parsers/constants.js +55 -15
- package/dist/esm/lib/parsers/constants.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-attribute.js +9 -1
- package/dist/esm/lib/parsers/parse-i3s-attribute.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js +3 -1
- package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js +87 -61
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s.js +4 -4
- package/dist/esm/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/esm/lib/utils/url-utils.js +3 -3
- package/dist/esm/lib/utils/url-utils.js.map +1 -1
- package/dist/esm/types.js +13 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/i3s-attribute-loader.d.ts +14 -0
- package/dist/i3s-attribute-loader.d.ts.map +1 -0
- package/dist/i3s-attribute-loader.js +177 -0
- package/dist/i3s-building-scene-layer-loader.d.ts +6 -0
- package/dist/i3s-building-scene-layer-loader.d.ts.map +1 -0
- package/dist/i3s-building-scene-layer-loader.js +26 -0
- package/dist/i3s-content-loader.d.ts +6 -0
- package/dist/i3s-content-loader.d.ts.map +1 -0
- package/dist/i3s-content-loader.js +28 -0
- package/dist/i3s-content-worker.js +7657 -2
- package/dist/i3s-loader.d.ts +6 -0
- package/dist/i3s-loader.d.ts.map +1 -0
- package/dist/i3s-loader.js +100 -0
- package/dist/i3s-node-page-loader.d.ts +6 -0
- package/dist/i3s-node-page-loader.d.ts.map +1 -0
- package/dist/i3s-node-page-loader.js +26 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/lib/helpers/i3s-nodepages-tiles.d.ts +73 -0
- package/dist/lib/helpers/i3s-nodepages-tiles.d.ts.map +1 -0
- package/dist/lib/helpers/i3s-nodepages-tiles.js +231 -0
- package/dist/lib/parsers/constants.d.ts +56 -0
- package/dist/lib/parsers/constants.d.ts.map +1 -0
- package/dist/lib/parsers/constants.js +107 -0
- package/dist/lib/parsers/parse-i3s-attribute.d.ts +10 -0
- package/dist/lib/parsers/parse-i3s-attribute.d.ts.map +1 -0
- package/dist/lib/parsers/parse-i3s-attribute.js +98 -0
- package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts +9 -0
- package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts.map +1 -0
- package/dist/lib/parsers/parse-i3s-building-scene-layer.js +46 -0
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts +4 -0
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -0
- package/dist/lib/parsers/parse-i3s-tile-content.js +508 -0
- package/dist/lib/parsers/parse-i3s.d.ts +4 -0
- package/dist/lib/parsers/parse-i3s.d.ts.map +1 -0
- package/dist/lib/parsers/parse-i3s.js +84 -0
- package/dist/lib/utils/convert-i3s-obb-to-mbs.d.ts +2 -0
- package/dist/lib/utils/convert-i3s-obb-to-mbs.d.ts.map +1 -0
- package/dist/lib/utils/convert-i3s-obb-to-mbs.js +20 -0
- package/dist/lib/utils/url-utils.d.ts +22 -0
- package/dist/lib/utils/url-utils.d.ts.map +1 -0
- package/dist/lib/utils/url-utils.js +44 -0
- package/dist/types.d.ts +429 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +15 -0
- package/dist/workers/i3s-content-worker.d.ts +2 -0
- package/dist/workers/i3s-content-worker.d.ts.map +1 -0
- package/dist/workers/i3s-content-worker.js +5 -0
- package/package.json +14 -12
- package/src/i3s-attribute-loader.ts +56 -19
- package/src/i3s-loader.ts +4 -1
- package/src/index.ts +1 -0
- package/src/lib/parsers/constants.ts +73 -18
- package/src/lib/parsers/parse-i3s-attribute.ts +19 -1
- package/src/lib/parsers/parse-i3s-building-scene-layer.ts +2 -1
- package/src/lib/parsers/parse-i3s-tile-content.ts +159 -109
- package/src/lib/utils/url-utils.ts +1 -1
- package/src/types.ts +153 -22
- package/dist/dist.min.js +0 -2
- package/dist/dist.min.js.map +0 -1
- package/dist/i3s-content-worker.js.map +0 -1
|
@@ -7,16 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
|
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
-
|
|
14
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
-
|
|
16
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
17
|
-
|
|
18
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
19
|
-
|
|
20
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
11
|
|
|
22
12
|
var _core = require("@loaders.gl/core");
|
|
@@ -29,19 +19,8 @@ var _parseI3s = require("../parsers/parse-i3s");
|
|
|
29
19
|
|
|
30
20
|
var _urlUtils = require("../utils/url-utils");
|
|
31
21
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
35
|
-
|
|
36
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
37
|
-
|
|
38
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
39
|
-
|
|
40
|
-
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; }
|
|
41
|
-
|
|
42
|
-
var I3SNodePagesTiles = function () {
|
|
43
|
-
function I3SNodePagesTiles(tileset, options) {
|
|
44
|
-
(0, _classCallCheck2.default)(this, I3SNodePagesTiles);
|
|
22
|
+
class I3SNodePagesTiles {
|
|
23
|
+
constructor(tileset, options) {
|
|
45
24
|
(0, _defineProperty2.default)(this, "tileset", void 0);
|
|
46
25
|
(0, _defineProperty2.default)(this, "nodePages", []);
|
|
47
26
|
(0, _defineProperty2.default)(this, "pendingNodePages", []);
|
|
@@ -50,342 +29,210 @@ var I3SNodePagesTiles = function () {
|
|
|
50
29
|
(0, _defineProperty2.default)(this, "lodSelectionMetricType", void 0);
|
|
51
30
|
(0, _defineProperty2.default)(this, "textureDefinitionsSelectedFormats", []);
|
|
52
31
|
(0, _defineProperty2.default)(this, "textureLoaderOptions", {});
|
|
53
|
-
this.tileset =
|
|
32
|
+
this.tileset = { ...tileset
|
|
33
|
+
};
|
|
54
34
|
this.nodesPerPage = tileset.nodePages.nodesPerPage;
|
|
55
35
|
this.lodSelectionMetricType = tileset.nodePages.lodSelectionMetricType;
|
|
56
36
|
this.options = options;
|
|
57
37
|
this.initSelectedFormatsForTextureDefinitions(tileset);
|
|
58
38
|
}
|
|
59
39
|
|
|
60
|
-
(
|
|
61
|
-
|
|
62
|
-
value: function () {
|
|
63
|
-
var _getNodeById = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(id) {
|
|
64
|
-
var pageIndex, _this$options$i3s, nodePageUrl, nodeIndex;
|
|
65
|
-
|
|
66
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
67
|
-
while (1) {
|
|
68
|
-
switch (_context.prev = _context.next) {
|
|
69
|
-
case 0:
|
|
70
|
-
pageIndex = Math.floor(id / this.nodesPerPage);
|
|
71
|
-
|
|
72
|
-
if (!(!this.nodePages[pageIndex] && !this.pendingNodePages[pageIndex])) {
|
|
73
|
-
_context.next = 8;
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
nodePageUrl = (0, _urlUtils.getUrlWithToken)("".concat(this.tileset.url, "/nodepages/").concat(pageIndex), (_this$options$i3s = this.options.i3s) === null || _this$options$i3s === void 0 ? void 0 : _this$options$i3s.token);
|
|
78
|
-
this.pendingNodePages[pageIndex] = {
|
|
79
|
-
status: 'Pending',
|
|
80
|
-
promise: (0, _core.load)(nodePageUrl, _i3sNodePageLoader.I3SNodePageLoader, this.options)
|
|
81
|
-
};
|
|
82
|
-
_context.next = 6;
|
|
83
|
-
return this.pendingNodePages[pageIndex].promise;
|
|
84
|
-
|
|
85
|
-
case 6:
|
|
86
|
-
this.nodePages[pageIndex] = _context.sent;
|
|
87
|
-
this.pendingNodePages[pageIndex].status = 'Done';
|
|
88
|
-
|
|
89
|
-
case 8:
|
|
90
|
-
if (!(this.pendingNodePages[pageIndex].status === 'Pending')) {
|
|
91
|
-
_context.next = 12;
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
_context.next = 11;
|
|
96
|
-
return this.pendingNodePages[pageIndex].promise;
|
|
97
|
-
|
|
98
|
-
case 11:
|
|
99
|
-
this.nodePages[pageIndex] = _context.sent;
|
|
100
|
-
|
|
101
|
-
case 12:
|
|
102
|
-
nodeIndex = id % this.nodesPerPage;
|
|
103
|
-
return _context.abrupt("return", this.nodePages[pageIndex].nodes[nodeIndex]);
|
|
104
|
-
|
|
105
|
-
case 14:
|
|
106
|
-
case "end":
|
|
107
|
-
return _context.stop();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}, _callee, this);
|
|
111
|
-
}));
|
|
112
|
-
|
|
113
|
-
function getNodeById(_x) {
|
|
114
|
-
return _getNodeById.apply(this, arguments);
|
|
115
|
-
}
|
|
40
|
+
async getNodeById(id) {
|
|
41
|
+
const pageIndex = Math.floor(id / this.nodesPerPage);
|
|
116
42
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}, {
|
|
120
|
-
key: "formTileFromNodePages",
|
|
121
|
-
value: function () {
|
|
122
|
-
var _formTileFromNodePages = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(id) {
|
|
123
|
-
var node, children, _iterator, _step, child, childNode, contentUrl, textureUrl, materialDefinition, textureFormat, attributeUrls, isDracoGeometry, _ref, url, isDracoGeometryResult, _this$getInformationF, _this$getInformationF2, textureData, nodeMaterialDefinition, lodSelection;
|
|
124
|
-
|
|
125
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
126
|
-
while (1) {
|
|
127
|
-
switch (_context2.prev = _context2.next) {
|
|
128
|
-
case 0:
|
|
129
|
-
_context2.next = 2;
|
|
130
|
-
return this.getNodeById(id);
|
|
131
|
-
|
|
132
|
-
case 2:
|
|
133
|
-
node = _context2.sent;
|
|
134
|
-
children = [];
|
|
135
|
-
_iterator = _createForOfIteratorHelper(node.children || []);
|
|
136
|
-
_context2.prev = 5;
|
|
137
|
-
|
|
138
|
-
_iterator.s();
|
|
139
|
-
|
|
140
|
-
case 7:
|
|
141
|
-
if ((_step = _iterator.n()).done) {
|
|
142
|
-
_context2.next = 15;
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
child = _step.value;
|
|
147
|
-
_context2.next = 11;
|
|
148
|
-
return this.getNodeById(child);
|
|
149
|
-
|
|
150
|
-
case 11:
|
|
151
|
-
childNode = _context2.sent;
|
|
152
|
-
children.push({
|
|
153
|
-
id: child,
|
|
154
|
-
obb: childNode.obb
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
case 13:
|
|
158
|
-
_context2.next = 7;
|
|
159
|
-
break;
|
|
160
|
-
|
|
161
|
-
case 15:
|
|
162
|
-
_context2.next = 20;
|
|
163
|
-
break;
|
|
164
|
-
|
|
165
|
-
case 17:
|
|
166
|
-
_context2.prev = 17;
|
|
167
|
-
_context2.t0 = _context2["catch"](5);
|
|
168
|
-
|
|
169
|
-
_iterator.e(_context2.t0);
|
|
170
|
-
|
|
171
|
-
case 20:
|
|
172
|
-
_context2.prev = 20;
|
|
173
|
-
|
|
174
|
-
_iterator.f();
|
|
175
|
-
|
|
176
|
-
return _context2.finish(20);
|
|
177
|
-
|
|
178
|
-
case 23:
|
|
179
|
-
contentUrl = null;
|
|
180
|
-
textureUrl = null;
|
|
181
|
-
materialDefinition = null;
|
|
182
|
-
textureFormat = 'jpeg';
|
|
183
|
-
attributeUrls = [];
|
|
184
|
-
isDracoGeometry = false;
|
|
185
|
-
|
|
186
|
-
if (node && node.mesh) {
|
|
187
|
-
_ref = node.mesh.geometry && this.getContentUrl(node.mesh.geometry) || {
|
|
188
|
-
url: null,
|
|
189
|
-
isDracoGeometry: null
|
|
190
|
-
}, url = _ref.url, isDracoGeometryResult = _ref.isDracoGeometry;
|
|
191
|
-
contentUrl = url;
|
|
192
|
-
isDracoGeometry = isDracoGeometryResult;
|
|
193
|
-
_this$getInformationF = this.getInformationFromMaterial(node.mesh.material), _this$getInformationF2 = (0, _slicedToArray2.default)(_this$getInformationF, 2), textureData = _this$getInformationF2[0], nodeMaterialDefinition = _this$getInformationF2[1];
|
|
194
|
-
materialDefinition = nodeMaterialDefinition;
|
|
195
|
-
textureFormat = textureData.format || textureFormat;
|
|
196
|
-
|
|
197
|
-
if (textureData.name) {
|
|
198
|
-
textureUrl = "".concat(this.tileset.url, "/nodes/").concat(node.mesh.material.resource, "/textures/").concat(textureData.name);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
if (this.tileset.attributeStorageInfo) {
|
|
202
|
-
attributeUrls = (0, _urlUtils.generateTilesetAttributeUrls)(this.tileset, node.mesh.attribute.resource);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
lodSelection = this.getLodSelection(node);
|
|
207
|
-
return _context2.abrupt("return", (0, _parseI3s.normalizeTileNonUrlData)({
|
|
208
|
-
id: id,
|
|
209
|
-
lodSelection: lodSelection,
|
|
210
|
-
obb: node.obb,
|
|
211
|
-
contentUrl: contentUrl,
|
|
212
|
-
textureUrl: textureUrl,
|
|
213
|
-
attributeUrls: attributeUrls,
|
|
214
|
-
materialDefinition: materialDefinition,
|
|
215
|
-
textureFormat: textureFormat,
|
|
216
|
-
textureLoaderOptions: this.textureLoaderOptions,
|
|
217
|
-
children: children,
|
|
218
|
-
isDracoGeometry: isDracoGeometry
|
|
219
|
-
}));
|
|
220
|
-
|
|
221
|
-
case 32:
|
|
222
|
-
case "end":
|
|
223
|
-
return _context2.stop();
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}, _callee2, this, [[5, 17, 20, 23]]);
|
|
227
|
-
}));
|
|
228
|
-
|
|
229
|
-
function formTileFromNodePages(_x2) {
|
|
230
|
-
return _formTileFromNodePages.apply(this, arguments);
|
|
231
|
-
}
|
|
43
|
+
if (!this.nodePages[pageIndex] && !this.pendingNodePages[pageIndex]) {
|
|
44
|
+
var _this$options$i3s;
|
|
232
45
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
if (this.options.i3s && this.options.i3s.useDracoGeometry) {
|
|
243
|
-
geometryIndex = geometryDefinition.geometryBuffers.findIndex(function (buffer) {
|
|
244
|
-
return buffer.compressedAttributes && buffer.compressedAttributes.encoding === 'draco';
|
|
245
|
-
});
|
|
246
|
-
}
|
|
46
|
+
const nodePageUrl = (0, _urlUtils.getUrlWithToken)("".concat(this.tileset.url, "/nodepages/").concat(pageIndex), (_this$options$i3s = this.options.i3s) === null || _this$options$i3s === void 0 ? void 0 : _this$options$i3s.token);
|
|
47
|
+
this.pendingNodePages[pageIndex] = {
|
|
48
|
+
status: 'Pending',
|
|
49
|
+
promise: (0, _core.load)(nodePageUrl, _i3sNodePageLoader.I3SNodePageLoader, this.options)
|
|
50
|
+
};
|
|
51
|
+
this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;
|
|
52
|
+
this.pendingNodePages[pageIndex].status = 'Done';
|
|
53
|
+
}
|
|
247
54
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
55
|
+
if (this.pendingNodePages[pageIndex].status === 'Pending') {
|
|
56
|
+
this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const nodeIndex = id % this.nodesPerPage;
|
|
60
|
+
return this.nodePages[pageIndex].nodes[nodeIndex];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async formTileFromNodePages(id) {
|
|
64
|
+
const node = await this.getNodeById(id);
|
|
65
|
+
const children = [];
|
|
66
|
+
|
|
67
|
+
for (const child of node.children || []) {
|
|
68
|
+
const childNode = await this.getNodeById(child);
|
|
69
|
+
children.push({
|
|
70
|
+
id: child,
|
|
71
|
+
obb: childNode.obb
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let contentUrl = null;
|
|
76
|
+
let textureUrl = null;
|
|
77
|
+
let materialDefinition = null;
|
|
78
|
+
let textureFormat = 'jpeg';
|
|
79
|
+
let attributeUrls = [];
|
|
80
|
+
let isDracoGeometry = false;
|
|
81
|
+
|
|
82
|
+
if (node && node.mesh) {
|
|
83
|
+
const {
|
|
84
|
+
url,
|
|
85
|
+
isDracoGeometry: isDracoGeometryResult
|
|
86
|
+
} = node.mesh.geometry && this.getContentUrl(node.mesh.geometry) || {
|
|
87
|
+
url: null,
|
|
88
|
+
isDracoGeometry: null
|
|
89
|
+
};
|
|
90
|
+
contentUrl = url;
|
|
91
|
+
isDracoGeometry = isDracoGeometryResult;
|
|
92
|
+
const [textureData, nodeMaterialDefinition] = this.getInformationFromMaterial(node.mesh.material);
|
|
93
|
+
materialDefinition = nodeMaterialDefinition;
|
|
94
|
+
textureFormat = textureData.format || textureFormat;
|
|
95
|
+
|
|
96
|
+
if (textureData.name) {
|
|
97
|
+
textureUrl = "".concat(this.tileset.url, "/nodes/").concat(node.mesh.material.resource, "/textures/").concat(textureData.name);
|
|
252
98
|
}
|
|
253
99
|
|
|
254
|
-
if (
|
|
255
|
-
|
|
256
|
-
result = {
|
|
257
|
-
url: "".concat(this.tileset.url, "/nodes/").concat(meshGeometryData.resource, "/geometries/").concat(geometryIndex),
|
|
258
|
-
isDracoGeometry: isDracoGeometry
|
|
259
|
-
};
|
|
100
|
+
if (this.tileset.attributeStorageInfo) {
|
|
101
|
+
attributeUrls = (0, _urlUtils.generateTilesetAttributeUrls)(this.tileset, node.mesh.attribute.resource);
|
|
260
102
|
}
|
|
103
|
+
}
|
|
261
104
|
|
|
262
|
-
|
|
105
|
+
const lodSelection = this.getLodSelection(node);
|
|
106
|
+
return (0, _parseI3s.normalizeTileNonUrlData)({
|
|
107
|
+
id,
|
|
108
|
+
lodSelection,
|
|
109
|
+
obb: node.obb,
|
|
110
|
+
contentUrl,
|
|
111
|
+
textureUrl,
|
|
112
|
+
attributeUrls,
|
|
113
|
+
materialDefinition,
|
|
114
|
+
textureFormat,
|
|
115
|
+
textureLoaderOptions: this.textureLoaderOptions,
|
|
116
|
+
children,
|
|
117
|
+
isDracoGeometry
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
getContentUrl(meshGeometryData) {
|
|
122
|
+
let result = {};
|
|
123
|
+
const geometryDefinition = this.tileset.geometryDefinitions[meshGeometryData.definition];
|
|
124
|
+
let geometryIndex = -1;
|
|
125
|
+
|
|
126
|
+
if (this.options.i3s && this.options.i3s.useDracoGeometry) {
|
|
127
|
+
geometryIndex = geometryDefinition.geometryBuffers.findIndex(buffer => buffer.compressedAttributes && buffer.compressedAttributes.encoding === 'draco');
|
|
263
128
|
}
|
|
264
|
-
}, {
|
|
265
|
-
key: "getLodSelection",
|
|
266
|
-
value: function getLodSelection(node) {
|
|
267
|
-
var lodSelection = [];
|
|
268
|
-
|
|
269
|
-
if (this.lodSelectionMetricType === 'maxScreenThresholdSQ') {
|
|
270
|
-
lodSelection.push({
|
|
271
|
-
metricType: 'maxScreenThreshold',
|
|
272
|
-
maxError: Math.sqrt(node.lodThreshold / (Math.PI * 0.25))
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
129
|
|
|
130
|
+
if (geometryIndex === -1) {
|
|
131
|
+
geometryIndex = geometryDefinition.geometryBuffers.findIndex(buffer => !buffer.compressedAttributes);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (geometryIndex !== -1) {
|
|
135
|
+
const isDracoGeometry = Boolean(geometryDefinition.geometryBuffers[geometryIndex].compressedAttributes);
|
|
136
|
+
result = {
|
|
137
|
+
url: "".concat(this.tileset.url, "/nodes/").concat(meshGeometryData.resource, "/geometries/").concat(geometryIndex),
|
|
138
|
+
isDracoGeometry
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
getLodSelection(node) {
|
|
146
|
+
const lodSelection = [];
|
|
147
|
+
|
|
148
|
+
if (this.lodSelectionMetricType === 'maxScreenThresholdSQ') {
|
|
276
149
|
lodSelection.push({
|
|
277
|
-
metricType:
|
|
278
|
-
maxError: node.lodThreshold
|
|
150
|
+
metricType: 'maxScreenThreshold',
|
|
151
|
+
maxError: Math.sqrt(node.lodThreshold / (Math.PI * 0.25))
|
|
279
152
|
});
|
|
280
|
-
return lodSelection;
|
|
281
153
|
}
|
|
282
|
-
}, {
|
|
283
|
-
key: "getInformationFromMaterial",
|
|
284
|
-
value: function getInformationFromMaterial(material) {
|
|
285
|
-
var textureDataDefault = {
|
|
286
|
-
name: null,
|
|
287
|
-
format: null
|
|
288
|
-
};
|
|
289
154
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
155
|
+
lodSelection.push({
|
|
156
|
+
metricType: this.lodSelectionMetricType,
|
|
157
|
+
maxError: node.lodThreshold
|
|
158
|
+
});
|
|
159
|
+
return lodSelection;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
getInformationFromMaterial(material) {
|
|
163
|
+
const textureDataDefault = {
|
|
164
|
+
name: null,
|
|
165
|
+
format: null
|
|
166
|
+
};
|
|
293
167
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
168
|
+
if (material) {
|
|
169
|
+
const materialDefinition = this.tileset.materialDefinitions[material.definition];
|
|
170
|
+
const textureSetDefinitionIndex = materialDefinition && materialDefinition.pbrMetallicRoughness && materialDefinition.pbrMetallicRoughness.baseColorTexture && materialDefinition.pbrMetallicRoughness.baseColorTexture.textureSetDefinitionId;
|
|
298
171
|
|
|
299
|
-
|
|
172
|
+
if (textureSetDefinitionIndex || textureSetDefinitionIndex === 0) {
|
|
173
|
+
const textureData = this.textureDefinitionsSelectedFormats[textureSetDefinitionIndex] || textureDataDefault;
|
|
174
|
+
return [textureData, materialDefinition];
|
|
300
175
|
}
|
|
301
176
|
|
|
302
|
-
return [textureDataDefault,
|
|
177
|
+
return [textureDataDefault, materialDefinition];
|
|
303
178
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
try {
|
|
324
|
-
var _loop = function _loop() {
|
|
325
|
-
var i3sFormat = _step3.value;
|
|
326
|
-
var format = formats.find(function (value) {
|
|
327
|
-
return value.format === i3sFormat;
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
if (format) {
|
|
331
|
-
selectedFormat = format;
|
|
332
|
-
return "break";
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
337
|
-
var _ret = _loop();
|
|
338
|
-
|
|
339
|
-
if (_ret === "break") break;
|
|
340
|
-
}
|
|
341
|
-
} catch (err) {
|
|
342
|
-
_iterator3.e(err);
|
|
343
|
-
} finally {
|
|
344
|
-
_iterator3.f();
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
if (selectedFormat && selectedFormat.format === 'ktx2') {
|
|
348
|
-
this.textureLoaderOptions.basis = {
|
|
349
|
-
format: (0, _textures.selectSupportedBasisFormat)(),
|
|
350
|
-
containerFormat: 'ktx2',
|
|
351
|
-
module: 'encoder'
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
this.textureDefinitionsSelectedFormats.push(selectedFormat);
|
|
179
|
+
|
|
180
|
+
return [textureDataDefault, null];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
initSelectedFormatsForTextureDefinitions(tileset) {
|
|
184
|
+
this.textureDefinitionsSelectedFormats = [];
|
|
185
|
+
const possibleI3sFormats = this.getSupportedTextureFormats();
|
|
186
|
+
const textureSetDefinitions = tileset.textureSetDefinitions || [];
|
|
187
|
+
|
|
188
|
+
for (const textureSetDefinition of textureSetDefinitions) {
|
|
189
|
+
const formats = textureSetDefinition && textureSetDefinition.formats || [];
|
|
190
|
+
let selectedFormat = null;
|
|
191
|
+
|
|
192
|
+
for (const i3sFormat of possibleI3sFormats) {
|
|
193
|
+
const format = formats.find(value => value.format === i3sFormat);
|
|
194
|
+
|
|
195
|
+
if (format) {
|
|
196
|
+
selectedFormat = format;
|
|
197
|
+
break;
|
|
356
198
|
}
|
|
357
|
-
} catch (err) {
|
|
358
|
-
_iterator2.e(err);
|
|
359
|
-
} finally {
|
|
360
|
-
_iterator2.f();
|
|
361
199
|
}
|
|
200
|
+
|
|
201
|
+
if (selectedFormat && selectedFormat.format === 'ktx2') {
|
|
202
|
+
this.textureLoaderOptions.basis = {
|
|
203
|
+
format: (0, _textures.selectSupportedBasisFormat)(),
|
|
204
|
+
containerFormat: 'ktx2',
|
|
205
|
+
module: 'encoder'
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
this.textureDefinitionsSelectedFormats.push(selectedFormat);
|
|
362
210
|
}
|
|
363
|
-
}
|
|
364
|
-
key: "getSupportedTextureFormats",
|
|
365
|
-
value: function getSupportedTextureFormats() {
|
|
366
|
-
var formats = [];
|
|
211
|
+
}
|
|
367
212
|
|
|
368
|
-
|
|
369
|
-
|
|
213
|
+
getSupportedTextureFormats() {
|
|
214
|
+
const formats = [];
|
|
370
215
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}
|
|
216
|
+
if (!this.options.i3s || this.options.i3s.useCompressedTextures) {
|
|
217
|
+
const supportedCompressedFormats = (0, _textures.getSupportedGPUTextureFormats)();
|
|
374
218
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
219
|
+
if (supportedCompressedFormats.has('etc2')) {
|
|
220
|
+
formats.push('ktx-etc2');
|
|
221
|
+
}
|
|
378
222
|
|
|
379
|
-
|
|
223
|
+
if (supportedCompressedFormats.has('dxt')) {
|
|
224
|
+
formats.push('dds');
|
|
380
225
|
}
|
|
381
226
|
|
|
382
|
-
formats.push('
|
|
383
|
-
formats.push('png');
|
|
384
|
-
return formats;
|
|
227
|
+
formats.push('ktx2');
|
|
385
228
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
229
|
+
|
|
230
|
+
formats.push('jpg');
|
|
231
|
+
formats.push('png');
|
|
232
|
+
return formats;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
}
|
|
389
236
|
|
|
390
237
|
exports.default = I3SNodePagesTiles;
|
|
391
238
|
//# sourceMappingURL=i3s-nodepages-tiles.js.map
|
|
@@ -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","child","childNode","push","obb","contentUrl","textureUrl","materialDefinition","textureFormat","attributeUrls","isDracoGeometry","mesh","geometry","getContentUrl","isDracoGeometryResult","getInformationFromMaterial","material","textureData","nodeMaterialDefinition","format","name","resource","attributeStorageInfo","attribute","lodSelection","getLodSelection","textureLoaderOptions","meshGeometryData","result","geometryDefinition","geometryDefinitions","definition","geometryIndex","useDracoGeometry","geometryBuffers","findIndex","buffer","compressedAttributes","encoding","Boolean","metricType","maxError","sqrt","lodThreshold","PI","textureDataDefault","materialDefinitions","textureSetDefinitionIndex","pbrMetallicRoughness","baseColorTexture","textureSetDefinitionId","textureDefinitionsSelectedFormats","possibleI3sFormats","getSupportedTextureFormats","textureSetDefinitions","textureSetDefinition","formats","selectedFormat","i3sFormat","find","value","basis","containerFormat","module","useCompressedTextures","supportedCompressedFormats","has"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;;;IAKqBA,iB;AAgBnB,6BAAYC,OAAZ,EAA8BC,OAA9B,EAA+C;AAAA;AAAA;AAAA,qDAdvB,EAcuB;AAAA,4DAbgC,EAahC;AAAA;AAAA;AAAA;AAAA,6EATJ,EASI;AAAA,gEARM,EAQN;AAC7C,SAAKD,OAAL,qBAAmBA,OAAnB;AACA,SAAKE,YAAL,GAAoBF,OAAO,CAACG,SAAR,CAAkBD,YAAtC;AACA,SAAKE,sBAAL,GAA8BJ,OAAO,CAACG,SAAR,CAAkBC,sBAAhD;AACA,SAAKH,OAAL,GAAeA,OAAf;AAEA,SAAKI,wCAAL,CAA8CL,OAA9C;AACD;;;;;mFAMD,iBAAkBM,EAAlB;AAAA;;AAAA;AAAA;AAAA;AAAA;AACQC,gBAAAA,SADR,GACoBC,IAAI,CAACC,KAAL,CAAWH,EAAE,GAAG,KAAKJ,YAArB,CADpB;;AAAA,sBAEM,CAAC,KAAKC,SAAL,CAAeI,SAAf,CAAD,IAA8B,CAAC,KAAKG,gBAAL,CAAsBH,SAAtB,CAFrC;AAAA;AAAA;AAAA;;AAGUI,gBAAAA,WAHV,GAGwB,yCACf,KAAKX,OAAL,CAAaY,GADE,wBACeL,SADf,wBAElB,KAAKN,OAAL,CAAaY,GAFK,sDAElB,kBAAkBC,KAFA,CAHxB;AAOI,qBAAKJ,gBAAL,CAAsBH,SAAtB,IAAmC;AACjCQ,kBAAAA,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AAIA,cAAc,CAACtC,MAAf,KAA0B,MAAhD,EAAwD;AACtD,iBAAKO,oBAAL,CAA0BmC,KAA1B,GAAkC;AAChC1C,cAAAA,MAAM,EAAE,2CADwB;AAEhC2C,cAAAA,eAAe,EAAE,MAFe;AAGhCC,cAAAA,MAAM,EAAE;AAHwB,aAAlC;AAKD;;AAED,eAAKZ,iCAAL,CAAuChD,IAAvC,CAA4CsD,cAA5C;AACD;AAxBuD;AAAA;AAAA;AAAA;AAAA;AAyBzD;;;WAMD,sCAA+C;AAC7C,UAAMD,OAAiB,GAAG,EAA1B;;AACA,UAAI,CAAC,KAAK7E,OAAL,CAAaY,GAAd,IAAqB,KAAKZ,OAAL,CAAaY,GAAb,CAAiByE,qBAA1C,EAAiE;AAE/D,YAAMC,0BAA0B,GAAG,8CAAnC;;AAGA,YAAIA,0BAA0B,CAACC,GAA3B,CAA+B,MAA/B,CAAJ,EAA4C;AAC1CV,UAAAA,OAAO,CAACrD,IAAR,CAAa,UAAb;AACD;;AACD,YAAI8D,0BAA0B,CAACC,GAA3B,CAA+B,KAA/B,CAAJ,EAA2C;AACzCV,UAAAA,OAAO,CAACrD,IAAR,CAAa,KAAb;AACD;;AAIDqD,QAAAA,OAAO,CAACrD,IAAR,CAAa,MAAb;AACD;;AAEDqD,MAAAA,OAAO,CAACrD,IAAR,CAAa,KAAb;AACAqD,MAAAA,OAAO,CAACrD,IAAR,CAAa,KAAb;AACA,aAAOqD,OAAP;AACD","sourcesContent":["import {load} from '@loaders.gl/core';\nimport {getSupportedGPUTextureFormats, selectSupportedBasisFormat} from '@loaders.gl/textures';\nimport {Tileset, NodePage} from '../../types';\nimport {I3SNodePageLoader} from '../../i3s-node-page-loader';\nimport {normalizeTileNonUrlData} from '../parsers/parse-i3s';\nimport {getUrlWithToken, generateTilesetAttributeUrls} from '../utils/url-utils';\n\n/**\n * class I3SNodePagesTiles - loads nodePages and form i3s tiles from them\n */\nexport default class I3SNodePagesTiles {\n tileset: Tileset;\n nodePages: NodePage[] = [];\n pendingNodePages: {promise: Promise<NodePage>; status: 'Pending' | 'Done'}[] = [];\n nodesPerPage: number;\n options: {[key: string]: any};\n lodSelectionMetricType: any;\n textureDefinitionsSelectedFormats: any[] = [];\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: Tileset, options: object) {\n this.tileset = {...tileset}; // spread the tileset to avoid circular reference\n this.nodesPerPage = tileset.nodePages.nodesPerPage;\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) {\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\n async formTileFromNodePages(id: number) {\n const node = await this.getNodeById(id);\n const children: any[] = [];\n for (const child of node.children || []) {\n const childNode = await this.getNodeById(child);\n children.push({\n id: child,\n obb: childNode.obb\n });\n }\n\n let contentUrl = null;\n let textureUrl: string | null = null;\n let materialDefinition = null;\n let textureFormat = 'jpeg';\n let attributeUrls: string[] = [];\n let isDracoGeometry = 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)) || {url: null, isDracoGeometry: null};\n contentUrl = url;\n isDracoGeometry = isDracoGeometryResult;\n\n const [textureData, nodeMaterialDefinition] = this.getInformationFromMaterial(\n node.mesh.material\n );\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,\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 {Object} meshGeometryData - data about the node's mesh from the nodepage\n * @returns {Object} -\n * {string} url - url to the geometry resource\n * {boolean} isDracoGeometry - whether the geometry resource contain DRACO compressed geometry\n */\n private getContentUrl(meshGeometryData) {\n let result = {};\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 {Object} node - a node from nodepage\n * @returns {Object[]} - Array of object of following properties:\n * {string} metricType - the label of the LOD metric\n * {number} maxError - the value of the metric\n */\n private getLodSelection(node): object[] {\n const lodSelection: object[] = [];\n if (this.lodSelectionMetricType === 'maxScreenThresholdSQ') {\n lodSelection.push({\n metricType: 'maxScreenThreshold',\n maxError: Math.sqrt(node.lodThreshold / (Math.PI * 0.25))\n });\n }\n lodSelection.push({\n metricType: this.lodSelectionMetricType,\n maxError: node.lodThreshold\n });\n return lodSelection;\n }\n\n /**\n * Returns information about texture and material from `materialDefinitions`\n * @param {Object} material - material data from nodepage\n * @returns {Object[]} - 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) {\n const textureDataDefault = {name: null, format: null};\n if (material) {\n const materialDefinition = this.tileset.materialDefinitions[material.definition];\n const textureSetDefinitionIndex =\n materialDefinition &&\n materialDefinition.pbrMetallicRoughness &&\n materialDefinition.pbrMetallicRoughness.baseColorTexture &&\n materialDefinition.pbrMetallicRoughness.baseColorTexture.textureSetDefinitionId;\n if (textureSetDefinitionIndex || textureSetDefinitionIndex === 0) {\n const textureData =\n this.textureDefinitionsSelectedFormats[textureSetDefinitionIndex] || textureDataDefault;\n return [textureData, materialDefinition];\n }\n return [textureDataDefault, materialDefinition];\n }\n return [textureDataDefault, null];\n }\n\n /**\n * Sets preferable and supported format for each textureDefinition of the tileset\n * @param {Object} tileset - I3S layer data\n * @returns {void}\n */\n private initSelectedFormatsForTextureDefinitions(tileset) {\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: {format: string; name: string} | 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(): string[] {\n const formats: string[] = [];\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","constructor","tileset","options","nodesPerPage","nodePages","lodSelectionMetricType","initSelectedFormatsForTextureDefinitions","getNodeById","id","pageIndex","Math","floor","pendingNodePages","nodePageUrl","url","i3s","token","status","promise","I3SNodePageLoader","nodeIndex","nodes","formTileFromNodePages","node","children","child","childNode","push","obb","contentUrl","textureUrl","materialDefinition","textureFormat","attributeUrls","isDracoGeometry","mesh","isDracoGeometryResult","geometry","getContentUrl","textureData","nodeMaterialDefinition","getInformationFromMaterial","material","format","name","resource","attributeStorageInfo","attribute","lodSelection","getLodSelection","textureLoaderOptions","meshGeometryData","result","geometryDefinition","geometryDefinitions","definition","geometryIndex","useDracoGeometry","geometryBuffers","findIndex","buffer","compressedAttributes","encoding","Boolean","metricType","maxError","sqrt","lodThreshold","PI","textureDataDefault","materialDefinitions","textureSetDefinitionIndex","pbrMetallicRoughness","baseColorTexture","textureSetDefinitionId","textureDefinitionsSelectedFormats","possibleI3sFormats","getSupportedTextureFormats","textureSetDefinitions","textureSetDefinition","formats","selectedFormat","i3sFormat","find","value","basis","containerFormat","module","useCompressedTextures","supportedCompressedFormats","has"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AAKe,MAAMA,iBAAN,CAAwB;AAgBrCC,EAAAA,WAAW,CAACC,OAAD,EAAmBC,OAAnB,EAAoC;AAAA;AAAA,qDAdvB,EAcuB;AAAA,4DAbgC,EAahC;AAAA;AAAA;AAAA;AAAA,6EATJ,EASI;AAAA,gEARM,EAQN;AAC7C,SAAKD,OAAL,GAAe,EAAC,GAAGA;AAAJ,KAAf;AACA,SAAKE,YAAL,GAAoBF,OAAO,CAACG,SAAR,CAAkBD,YAAtC;AACA,SAAKE,sBAAL,GAA8BJ,OAAO,CAACG,SAAR,CAAkBC,sBAAhD;AACA,SAAKH,OAAL,GAAeA,OAAf;AAEA,SAAKI,wCAAL,CAA8CL,OAA9C;AACD;;AAMgB,QAAXM,WAAW,CAACC,EAAD,EAAa;AAC5B,UAAMC,SAAS,GAAGC,IAAI,CAACC,KAAL,CAAWH,EAAE,GAAG,KAAKL,YAArB,CAAlB;;AACA,QAAI,CAAC,KAAKC,SAAL,CAAeK,SAAf,CAAD,IAA8B,CAAC,KAAKG,gBAAL,CAAsBH,SAAtB,CAAnC,EAAqE;AAAA;;AACnE,YAAMI,WAAW,GAAG,yCACf,KAAKZ,OAAL,CAAaa,GADE,wBACeL,SADf,wBAElB,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AA/B,CAAJ,EAA2C;AACzCV,QAAAA,OAAO,CAACrD,IAAR,CAAa,KAAb;AACD;;AAIDqD,MAAAA,OAAO,CAACrD,IAAR,CAAa,MAAb;AACD;;AAEDqD,IAAAA,OAAO,CAACrD,IAAR,CAAa,KAAb;AACAqD,IAAAA,OAAO,CAACrD,IAAR,CAAa,KAAb;AACA,WAAOqD,OAAP;AACD;;AA7PoC","sourcesContent":["import {load} from '@loaders.gl/core';\nimport {getSupportedGPUTextureFormats, selectSupportedBasisFormat} from '@loaders.gl/textures';\nimport {Tileset, NodePage} from '../../types';\nimport {I3SNodePageLoader} from '../../i3s-node-page-loader';\nimport {normalizeTileNonUrlData} from '../parsers/parse-i3s';\nimport {getUrlWithToken, generateTilesetAttributeUrls} from '../utils/url-utils';\n\n/**\n * class I3SNodePagesTiles - loads nodePages and form i3s tiles from them\n */\nexport default class I3SNodePagesTiles {\n tileset: Tileset;\n nodePages: NodePage[] = [];\n pendingNodePages: {promise: Promise<NodePage>; status: 'Pending' | 'Done'}[] = [];\n nodesPerPage: number;\n options: {[key: string]: any};\n lodSelectionMetricType: any;\n textureDefinitionsSelectedFormats: any[] = [];\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: Tileset, options: object) {\n this.tileset = {...tileset}; // spread the tileset to avoid circular reference\n this.nodesPerPage = tileset.nodePages.nodesPerPage;\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) {\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\n async formTileFromNodePages(id: number) {\n const node = await this.getNodeById(id);\n const children: any[] = [];\n for (const child of node.children || []) {\n const childNode = await this.getNodeById(child);\n children.push({\n id: child,\n obb: childNode.obb\n });\n }\n\n let contentUrl = null;\n let textureUrl: string | null = null;\n let materialDefinition = null;\n let textureFormat = 'jpeg';\n let attributeUrls: string[] = [];\n let isDracoGeometry = 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)) || {url: null, isDracoGeometry: null};\n contentUrl = url;\n isDracoGeometry = isDracoGeometryResult;\n\n const [textureData, nodeMaterialDefinition] = this.getInformationFromMaterial(\n node.mesh.material\n );\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,\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 {Object} meshGeometryData - data about the node's mesh from the nodepage\n * @returns {Object} -\n * {string} url - url to the geometry resource\n * {boolean} isDracoGeometry - whether the geometry resource contain DRACO compressed geometry\n */\n private getContentUrl(meshGeometryData) {\n let result = {};\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 {Object} node - a node from nodepage\n * @returns {Object[]} - Array of object of following properties:\n * {string} metricType - the label of the LOD metric\n * {number} maxError - the value of the metric\n */\n private getLodSelection(node): object[] {\n const lodSelection: object[] = [];\n if (this.lodSelectionMetricType === 'maxScreenThresholdSQ') {\n lodSelection.push({\n metricType: 'maxScreenThreshold',\n maxError: Math.sqrt(node.lodThreshold / (Math.PI * 0.25))\n });\n }\n lodSelection.push({\n metricType: this.lodSelectionMetricType,\n maxError: node.lodThreshold\n });\n return lodSelection;\n }\n\n /**\n * Returns information about texture and material from `materialDefinitions`\n * @param {Object} material - material data from nodepage\n * @returns {Object[]} - 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) {\n const textureDataDefault = {name: null, format: null};\n if (material) {\n const materialDefinition = this.tileset.materialDefinitions[material.definition];\n const textureSetDefinitionIndex =\n materialDefinition &&\n materialDefinition.pbrMetallicRoughness &&\n materialDefinition.pbrMetallicRoughness.baseColorTexture &&\n materialDefinition.pbrMetallicRoughness.baseColorTexture.textureSetDefinitionId;\n if (textureSetDefinitionIndex || textureSetDefinitionIndex === 0) {\n const textureData =\n this.textureDefinitionsSelectedFormats[textureSetDefinitionIndex] || textureDataDefault;\n return [textureData, materialDefinition];\n }\n return [textureDataDefault, materialDefinition];\n }\n return [textureDataDefault, null];\n }\n\n /**\n * Sets preferable and supported format for each textureDefinition of the tileset\n * @param {Object} tileset - I3S layer data\n * @returns {void}\n */\n private initSelectedFormatsForTextureDefinitions(tileset) {\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: {format: string; name: string} | 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(): string[] {\n const formats: string[] = [];\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"}
|