@loaders.gl/tiles 3.3.0-alpha.5 → 3.3.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.min.js +824 -1299
- package/dist/es5/bundle.js +0 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/constants.js +2 -1
- package/dist/es5/constants.js.map +1 -1
- package/dist/es5/index.js +26 -36
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/tileset/helpers/3d-tiles-options.js +0 -1
- package/dist/es5/tileset/helpers/3d-tiles-options.js.map +1 -1
- package/dist/es5/tileset/helpers/bounding-volume.js +7 -26
- package/dist/es5/tileset/helpers/bounding-volume.js.map +1 -1
- package/dist/es5/tileset/helpers/frame-state.js +22 -42
- package/dist/es5/tileset/helpers/frame-state.js.map +1 -1
- package/dist/es5/tileset/helpers/i3s-lod.js +0 -13
- package/dist/es5/tileset/helpers/i3s-lod.js.map +1 -1
- package/dist/es5/tileset/helpers/tiles-3d-lod.js +7 -16
- package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +1 -1
- package/dist/es5/tileset/helpers/transform-utils.js +2 -11
- package/dist/es5/tileset/helpers/transform-utils.js.map +1 -1
- package/dist/es5/tileset/helpers/zoom.js +6 -16
- package/dist/es5/tileset/helpers/zoom.js.map +1 -1
- package/dist/es5/tileset/tile-3d.js +95 -96
- package/dist/es5/tileset/tile-3d.js.map +1 -1
- package/dist/es5/tileset/tileset-3d.js +79 -186
- package/dist/es5/tileset/tileset-3d.js.map +1 -1
- package/dist/es5/tileset/tileset-cache.js +1 -14
- package/dist/es5/tileset/tileset-cache.js.map +1 -1
- package/dist/es5/tileset/traversers/i3s-pending-tiles-register.js +8 -13
- package/dist/es5/tileset/traversers/i3s-pending-tiles-register.js.map +1 -1
- package/dist/es5/tileset/traversers/i3s-tile-manager.js +20 -24
- package/dist/es5/tileset/traversers/i3s-tile-manager.js.map +1 -1
- package/dist/es5/tileset/traversers/i3s-tileset-traverser.js +7 -48
- package/dist/es5/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
- package/dist/es5/tileset/traversers/tileset-3d-traverser.js +0 -22
- package/dist/es5/tileset/traversers/tileset-3d-traverser.js.map +1 -1
- package/dist/es5/tileset/traversers/tileset-traverser.js +53 -76
- package/dist/es5/tileset/traversers/tileset-traverser.js.map +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/utils/doubly-linked-list-node.js +3 -7
- package/dist/es5/utils/doubly-linked-list-node.js.map +1 -1
- package/dist/es5/utils/doubly-linked-list.js +9 -17
- package/dist/es5/utils/doubly-linked-list.js.map +1 -1
- package/dist/es5/utils/managed-array.js +29 -30
- package/dist/es5/utils/managed-array.js.map +1 -1
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/constants.js +3 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tileset/helpers/3d-tiles-options.js.map +1 -1
- package/dist/esm/tileset/helpers/bounding-volume.js +4 -10
- package/dist/esm/tileset/helpers/bounding-volume.js.map +1 -1
- package/dist/esm/tileset/helpers/frame-state.js +16 -16
- package/dist/esm/tileset/helpers/frame-state.js.map +1 -1
- package/dist/esm/tileset/helpers/i3s-lod.js +4 -4
- package/dist/esm/tileset/helpers/i3s-lod.js.map +1 -1
- package/dist/esm/tileset/helpers/tiles-3d-lod.js +11 -8
- package/dist/esm/tileset/helpers/tiles-3d-lod.js.map +1 -1
- package/dist/esm/tileset/helpers/transform-utils.js +1 -3
- package/dist/esm/tileset/helpers/transform-utils.js.map +1 -1
- package/dist/esm/tileset/helpers/zoom.js +3 -2
- package/dist/esm/tileset/helpers/zoom.js.map +1 -1
- package/dist/esm/tileset/tile-3d.js +31 -107
- package/dist/esm/tileset/tile-3d.js.map +1 -1
- package/dist/esm/tileset/tileset-3d.js +22 -156
- package/dist/esm/tileset/tileset-3d.js.map +1 -1
- package/dist/esm/tileset/tileset-cache.js +2 -18
- package/dist/esm/tileset/tileset-cache.js.map +1 -1
- package/dist/esm/tileset/traversers/i3s-pending-tiles-register.js +0 -5
- package/dist/esm/tileset/traversers/i3s-pending-tiles-register.js.map +1 -1
- package/dist/esm/tileset/traversers/i3s-tile-manager.js +2 -4
- package/dist/esm/tileset/traversers/i3s-tile-manager.js.map +1 -1
- package/dist/esm/tileset/traversers/i3s-tileset-traverser.js +4 -17
- package/dist/esm/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
- package/dist/esm/tileset/traversers/tileset-3d-traverser.js +2 -9
- package/dist/esm/tileset/traversers/tileset-3d-traverser.js.map +1 -1
- package/dist/esm/tileset/traversers/tileset-traverser.js +18 -57
- package/dist/esm/tileset/traversers/tileset-traverser.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/doubly-linked-list-node.js +1 -4
- package/dist/esm/utils/doubly-linked-list-node.js.map +1 -1
- package/dist/esm/utils/doubly-linked-list.js +2 -11
- package/dist/esm/utils/doubly-linked-list.js.map +1 -1
- package/dist/esm/utils/managed-array.js +4 -22
- package/dist/esm/utils/managed-array.js.map +1 -1
- package/dist/tileset/helpers/frame-state.d.ts +4 -4
- package/dist/tileset/helpers/frame-state.d.ts.map +1 -1
- package/dist/tileset/helpers/frame-state.js +1 -0
- package/dist/tileset/tileset-3d.d.ts.map +1 -1
- package/dist/tileset/tileset-3d.js +1 -1
- package/dist/types.d.ts +18 -10
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/tileset/helpers/frame-state.ts +6 -5
- package/src/tileset/tileset-3d.ts +3 -3
- package/src/types.ts +19 -10
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
|
|
2
3
|
import { Matrix4, Vector3 } from '@math.gl/core';
|
|
3
4
|
import { Ellipsoid } from '@math.gl/geospatial';
|
|
4
5
|
import { Stats } from '@probe.gl/stats';
|
|
@@ -38,6 +39,7 @@ const DEFAULT_PROPS = {
|
|
|
38
39
|
basePath: '',
|
|
39
40
|
i3s: {}
|
|
40
41
|
};
|
|
42
|
+
|
|
41
43
|
const TILES_TOTAL = 'Tiles In Tileset(s)';
|
|
42
44
|
const TILES_IN_MEMORY = 'Tiles In Memory';
|
|
43
45
|
const TILES_IN_VIEW = 'Tiles In View';
|
|
@@ -49,101 +51,58 @@ const TILES_LOAD_FAILED = 'Failed Tile Loads';
|
|
|
49
51
|
const POINTS_COUNT = 'Points/Vertices';
|
|
50
52
|
const TILES_GPU_MEMORY = 'Tile Memory Use';
|
|
51
53
|
export default class Tileset3D {
|
|
54
|
+
|
|
52
55
|
constructor(json, options) {
|
|
53
56
|
_defineProperty(this, "options", void 0);
|
|
54
|
-
|
|
55
57
|
_defineProperty(this, "loadOptions", void 0);
|
|
56
|
-
|
|
57
58
|
_defineProperty(this, "type", void 0);
|
|
58
|
-
|
|
59
59
|
_defineProperty(this, "tileset", void 0);
|
|
60
|
-
|
|
61
60
|
_defineProperty(this, "loader", void 0);
|
|
62
|
-
|
|
63
61
|
_defineProperty(this, "url", void 0);
|
|
64
|
-
|
|
65
62
|
_defineProperty(this, "basePath", void 0);
|
|
66
|
-
|
|
67
63
|
_defineProperty(this, "modelMatrix", void 0);
|
|
68
|
-
|
|
69
64
|
_defineProperty(this, "ellipsoid", void 0);
|
|
70
|
-
|
|
71
65
|
_defineProperty(this, "lodMetricType", void 0);
|
|
72
|
-
|
|
73
66
|
_defineProperty(this, "lodMetricValue", void 0);
|
|
74
|
-
|
|
75
67
|
_defineProperty(this, "refine", void 0);
|
|
76
|
-
|
|
77
68
|
_defineProperty(this, "root", void 0);
|
|
78
|
-
|
|
79
69
|
_defineProperty(this, "roots", void 0);
|
|
80
|
-
|
|
81
70
|
_defineProperty(this, "asset", void 0);
|
|
82
|
-
|
|
83
71
|
_defineProperty(this, "description", void 0);
|
|
84
|
-
|
|
85
72
|
_defineProperty(this, "properties", void 0);
|
|
86
|
-
|
|
87
73
|
_defineProperty(this, "extras", void 0);
|
|
88
|
-
|
|
89
74
|
_defineProperty(this, "attributions", void 0);
|
|
90
|
-
|
|
91
75
|
_defineProperty(this, "credits", void 0);
|
|
92
|
-
|
|
93
76
|
_defineProperty(this, "stats", void 0);
|
|
94
|
-
|
|
95
77
|
_defineProperty(this, "traverseCounter", void 0);
|
|
96
|
-
|
|
97
78
|
_defineProperty(this, "geometricError", void 0);
|
|
98
|
-
|
|
99
79
|
_defineProperty(this, "selectedTiles", void 0);
|
|
100
|
-
|
|
101
80
|
_defineProperty(this, "updatePromise", null);
|
|
102
|
-
|
|
103
81
|
_defineProperty(this, "tilesetInitializationPromise", void 0);
|
|
104
|
-
|
|
105
82
|
_defineProperty(this, "cartographicCenter", void 0);
|
|
106
|
-
|
|
107
83
|
_defineProperty(this, "cartesianCenter", void 0);
|
|
108
|
-
|
|
109
84
|
_defineProperty(this, "zoom", void 0);
|
|
110
|
-
|
|
111
85
|
_defineProperty(this, "boundingVolume", void 0);
|
|
112
|
-
|
|
113
86
|
_defineProperty(this, "gpuMemoryUsageInBytes", void 0);
|
|
114
|
-
|
|
115
87
|
_defineProperty(this, "dynamicScreenSpaceErrorComputedDensity", void 0);
|
|
116
|
-
|
|
117
88
|
_defineProperty(this, "_traverser", void 0);
|
|
118
|
-
|
|
119
89
|
_defineProperty(this, "_cache", void 0);
|
|
120
|
-
|
|
121
90
|
_defineProperty(this, "_requestScheduler", void 0);
|
|
122
|
-
|
|
123
91
|
_defineProperty(this, "_frameNumber", void 0);
|
|
124
|
-
|
|
125
92
|
_defineProperty(this, "_queryParamsString", void 0);
|
|
126
|
-
|
|
127
93
|
_defineProperty(this, "_queryParams", void 0);
|
|
128
|
-
|
|
129
94
|
_defineProperty(this, "_extensionsUsed", void 0);
|
|
130
|
-
|
|
131
95
|
_defineProperty(this, "_tiles", void 0);
|
|
132
|
-
|
|
133
96
|
_defineProperty(this, "_pendingCount", void 0);
|
|
134
|
-
|
|
135
97
|
_defineProperty(this, "lastUpdatedVieports", void 0);
|
|
136
|
-
|
|
137
98
|
_defineProperty(this, "_requestedTiles", void 0);
|
|
138
|
-
|
|
139
99
|
_defineProperty(this, "_emptyTiles", void 0);
|
|
140
|
-
|
|
141
100
|
_defineProperty(this, "frameStateData", void 0);
|
|
142
|
-
|
|
143
101
|
_defineProperty(this, "maximumMemoryUsage", void 0);
|
|
144
|
-
|
|
145
102
|
assert(json);
|
|
146
|
-
|
|
103
|
+
|
|
104
|
+
this.options = {
|
|
105
|
+
...DEFAULT_PROPS,
|
|
147
106
|
...options
|
|
148
107
|
};
|
|
149
108
|
this.tileset = json;
|
|
@@ -153,6 +112,7 @@ export default class Tileset3D {
|
|
|
153
112
|
this.basePath = json.basePath || path.dirname(this.url);
|
|
154
113
|
this.modelMatrix = this.options.modelMatrix;
|
|
155
114
|
this.ellipsoid = this.options.ellipsoid;
|
|
115
|
+
|
|
156
116
|
this.lodMetricType = json.lodMetricType;
|
|
157
117
|
this.lodMetricValue = json.lodMetricValue;
|
|
158
118
|
this.refine = json.root.refine;
|
|
@@ -163,6 +123,7 @@ export default class Tileset3D {
|
|
|
163
123
|
this.cartesianCenter = null;
|
|
164
124
|
this.zoom = 1;
|
|
165
125
|
this.boundingVolume = null;
|
|
126
|
+
|
|
166
127
|
this.traverseCounter = 0;
|
|
167
128
|
this.geometricError = 0;
|
|
168
129
|
this._traverser = this._initializeTraverser();
|
|
@@ -172,7 +133,9 @@ export default class Tileset3D {
|
|
|
172
133
|
maxRequests: this.options.maxRequests
|
|
173
134
|
});
|
|
174
135
|
this._frameNumber = 0;
|
|
136
|
+
|
|
175
137
|
this._pendingCount = 0;
|
|
138
|
+
|
|
176
139
|
this._tiles = {};
|
|
177
140
|
this.selectedTiles = [];
|
|
178
141
|
this._emptyTiles = [];
|
|
@@ -181,12 +144,12 @@ export default class Tileset3D {
|
|
|
181
144
|
this.lastUpdatedVieports = null;
|
|
182
145
|
this._queryParams = {};
|
|
183
146
|
this._queryParamsString = '';
|
|
147
|
+
|
|
184
148
|
this.maximumMemoryUsage = this.options.maximumMemoryUsage || 32;
|
|
185
149
|
this.gpuMemoryUsageInBytes = 0;
|
|
186
150
|
this.stats = new Stats({
|
|
187
151
|
id: this.url
|
|
188
152
|
});
|
|
189
|
-
|
|
190
153
|
this._initializeStats();
|
|
191
154
|
|
|
192
155
|
this._extensionsUsed = undefined;
|
|
@@ -205,42 +168,37 @@ export default class Tileset3D {
|
|
|
205
168
|
isLoaded() {
|
|
206
169
|
return this._pendingCount === 0 && this._frameNumber !== 0 && this._requestedTiles.length === 0;
|
|
207
170
|
}
|
|
208
|
-
|
|
209
171
|
get tiles() {
|
|
210
172
|
return Object.values(this._tiles);
|
|
211
173
|
}
|
|
212
|
-
|
|
213
174
|
get frameNumber() {
|
|
214
175
|
return this._frameNumber;
|
|
215
176
|
}
|
|
216
|
-
|
|
217
177
|
get queryParams() {
|
|
218
178
|
if (!this._queryParamsString) {
|
|
219
179
|
this._queryParamsString = getQueryParamString(this._queryParams);
|
|
220
180
|
}
|
|
221
|
-
|
|
222
181
|
return this._queryParamsString;
|
|
223
182
|
}
|
|
224
|
-
|
|
225
183
|
setProps(props) {
|
|
226
|
-
this.options = {
|
|
184
|
+
this.options = {
|
|
185
|
+
...this.options,
|
|
227
186
|
...props
|
|
228
187
|
};
|
|
229
188
|
}
|
|
230
189
|
|
|
231
190
|
setOptions(options) {
|
|
232
|
-
this.options = {
|
|
191
|
+
this.options = {
|
|
192
|
+
...this.options,
|
|
233
193
|
...options
|
|
234
194
|
};
|
|
235
195
|
}
|
|
236
196
|
|
|
237
197
|
getTileUrl(tilePath) {
|
|
238
198
|
const isDataUrl = tilePath.startsWith('data:');
|
|
239
|
-
|
|
240
199
|
if (isDataUrl) {
|
|
241
200
|
return tilePath;
|
|
242
201
|
}
|
|
243
|
-
|
|
244
202
|
return "".concat(tilePath).concat(this.queryParams);
|
|
245
203
|
}
|
|
246
204
|
|
|
@@ -248,40 +206,37 @@ export default class Tileset3D {
|
|
|
248
206
|
return Boolean(this._extensionsUsed && this._extensionsUsed.indexOf(extensionName) > -1);
|
|
249
207
|
}
|
|
250
208
|
|
|
251
|
-
update(
|
|
209
|
+
update() {
|
|
210
|
+
let viewports = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
252
211
|
this.tilesetInitializationPromise.then(() => {
|
|
253
212
|
if (!viewports && this.lastUpdatedVieports) {
|
|
254
213
|
viewports = this.lastUpdatedVieports;
|
|
255
214
|
} else {
|
|
256
215
|
this.lastUpdatedVieports = viewports;
|
|
257
216
|
}
|
|
258
|
-
|
|
259
217
|
if (viewports) {
|
|
260
218
|
this.doUpdate(viewports);
|
|
261
219
|
}
|
|
262
220
|
});
|
|
263
221
|
}
|
|
264
222
|
|
|
265
|
-
async selectTiles(
|
|
223
|
+
async selectTiles() {
|
|
224
|
+
let viewports = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
266
225
|
await this.tilesetInitializationPromise;
|
|
267
|
-
|
|
268
226
|
if (viewports) {
|
|
269
227
|
this.lastUpdatedVieports = viewports;
|
|
270
228
|
}
|
|
271
|
-
|
|
272
229
|
if (!this.updatePromise) {
|
|
273
230
|
this.updatePromise = new Promise(resolve => {
|
|
274
231
|
setTimeout(() => {
|
|
275
232
|
if (this.lastUpdatedVieports) {
|
|
276
233
|
this.doUpdate(this.lastUpdatedVieports);
|
|
277
234
|
}
|
|
278
|
-
|
|
279
235
|
resolve(this._frameNumber);
|
|
280
236
|
this.updatePromise = null;
|
|
281
237
|
}, this.options.debounceTime);
|
|
282
238
|
});
|
|
283
239
|
}
|
|
284
|
-
|
|
285
240
|
return this.updatePromise;
|
|
286
241
|
}
|
|
287
242
|
|
|
@@ -289,22 +244,16 @@ export default class Tileset3D {
|
|
|
289
244
|
if ('loadTiles' in this.options && !this.options.loadTiles) {
|
|
290
245
|
return;
|
|
291
246
|
}
|
|
292
|
-
|
|
293
247
|
if (this.traverseCounter > 0) {
|
|
294
248
|
return;
|
|
295
249
|
}
|
|
296
|
-
|
|
297
250
|
const preparedViewports = viewports instanceof Array ? viewports : [viewports];
|
|
298
|
-
|
|
299
251
|
this._cache.reset();
|
|
300
|
-
|
|
301
252
|
this._frameNumber++;
|
|
302
253
|
this.traverseCounter = preparedViewports.length;
|
|
303
254
|
const viewportsToTraverse = [];
|
|
304
|
-
|
|
305
255
|
for (const viewport of preparedViewports) {
|
|
306
256
|
const id = viewport.id;
|
|
307
|
-
|
|
308
257
|
if (this._needTraverse(id)) {
|
|
309
258
|
viewportsToTraverse.push(id);
|
|
310
259
|
} else {
|
|
@@ -314,38 +263,31 @@ export default class Tileset3D {
|
|
|
314
263
|
|
|
315
264
|
for (const viewport of preparedViewports) {
|
|
316
265
|
const id = viewport.id;
|
|
317
|
-
|
|
318
266
|
if (!this.roots[id]) {
|
|
319
267
|
this.roots[id] = this._initializeTileHeaders(this.tileset, null);
|
|
320
268
|
}
|
|
321
|
-
|
|
322
269
|
if (!viewportsToTraverse.includes(id)) {
|
|
323
270
|
continue;
|
|
324
271
|
}
|
|
325
272
|
|
|
326
273
|
const frameState = getFrameState(viewport, this._frameNumber);
|
|
327
|
-
|
|
328
274
|
this._traverser.traverse(this.roots[id], frameState, this.options);
|
|
329
275
|
}
|
|
330
276
|
}
|
|
331
277
|
|
|
332
278
|
_needTraverse(viewportId) {
|
|
333
279
|
let traverserId = viewportId;
|
|
334
|
-
|
|
335
280
|
if (this.options.viewportTraversersMap) {
|
|
336
281
|
traverserId = this.options.viewportTraversersMap[viewportId];
|
|
337
282
|
}
|
|
338
|
-
|
|
339
283
|
if (traverserId !== viewportId) {
|
|
340
284
|
return false;
|
|
341
285
|
}
|
|
342
|
-
|
|
343
286
|
return true;
|
|
344
287
|
}
|
|
345
288
|
|
|
346
289
|
_onTraversalEnd(frameState) {
|
|
347
290
|
const id = frameState.viewport.id;
|
|
348
|
-
|
|
349
291
|
if (!this.frameStateData[id]) {
|
|
350
292
|
this.frameStateData[id] = {
|
|
351
293
|
selectedTiles: [],
|
|
@@ -353,24 +295,19 @@ export default class Tileset3D {
|
|
|
353
295
|
_emptyTiles: []
|
|
354
296
|
};
|
|
355
297
|
}
|
|
356
|
-
|
|
357
298
|
const currentFrameStateData = this.frameStateData[id];
|
|
358
299
|
const selectedTiles = Object.values(this._traverser.selectedTiles);
|
|
359
300
|
const [filteredSelectedTiles, unselectedTiles] = limitSelectedTiles(selectedTiles, frameState, this.options.maximumTilesSelected);
|
|
360
301
|
currentFrameStateData.selectedTiles = filteredSelectedTiles;
|
|
361
|
-
|
|
362
302
|
for (const tile of unselectedTiles) {
|
|
363
303
|
tile.unselect();
|
|
364
304
|
}
|
|
365
|
-
|
|
366
305
|
currentFrameStateData._requestedTiles = Object.values(this._traverser.requestedTiles);
|
|
367
306
|
currentFrameStateData._emptyTiles = Object.values(this._traverser.emptyTiles);
|
|
368
307
|
this.traverseCounter--;
|
|
369
|
-
|
|
370
308
|
if (this.traverseCounter > 0) {
|
|
371
309
|
return;
|
|
372
310
|
}
|
|
373
|
-
|
|
374
311
|
this._updateTiles();
|
|
375
312
|
}
|
|
376
313
|
|
|
@@ -378,39 +315,30 @@ export default class Tileset3D {
|
|
|
378
315
|
this.selectedTiles = [];
|
|
379
316
|
this._requestedTiles = [];
|
|
380
317
|
this._emptyTiles = [];
|
|
381
|
-
|
|
382
318
|
for (const frameStateKey in this.frameStateData) {
|
|
383
319
|
const frameStateDataValue = this.frameStateData[frameStateKey];
|
|
384
320
|
this.selectedTiles = this.selectedTiles.concat(frameStateDataValue.selectedTiles);
|
|
385
321
|
this._requestedTiles = this._requestedTiles.concat(frameStateDataValue._requestedTiles);
|
|
386
322
|
this._emptyTiles = this._emptyTiles.concat(frameStateDataValue._emptyTiles);
|
|
387
323
|
}
|
|
388
|
-
|
|
389
324
|
this.selectedTiles = this.options.onTraversalComplete(this.selectedTiles);
|
|
390
|
-
|
|
391
325
|
for (const tile of this.selectedTiles) {
|
|
392
326
|
this._tiles[tile.id] = tile;
|
|
393
327
|
}
|
|
394
|
-
|
|
395
328
|
this._loadTiles();
|
|
396
|
-
|
|
397
329
|
this._unloadTiles();
|
|
398
|
-
|
|
399
330
|
this._updateStats();
|
|
400
331
|
}
|
|
401
|
-
|
|
402
332
|
_tilesChanged(oldSelectedTiles, selectedTiles) {
|
|
403
333
|
if (oldSelectedTiles.length !== selectedTiles.length) {
|
|
404
334
|
return true;
|
|
405
335
|
}
|
|
406
|
-
|
|
407
336
|
const set1 = new Set(oldSelectedTiles.map(t => t.id));
|
|
408
337
|
const set2 = new Set(selectedTiles.map(t => t.id));
|
|
409
338
|
let changed = oldSelectedTiles.filter(x => !set2.has(x.id)).length > 0;
|
|
410
339
|
changed = changed || selectedTiles.filter(x => !set1.has(x.id)).length > 0;
|
|
411
340
|
return changed;
|
|
412
341
|
}
|
|
413
|
-
|
|
414
342
|
_loadTiles() {
|
|
415
343
|
for (const tile of this._requestedTiles) {
|
|
416
344
|
if (tile.contentUnloaded) {
|
|
@@ -418,19 +346,15 @@ export default class Tileset3D {
|
|
|
418
346
|
}
|
|
419
347
|
}
|
|
420
348
|
}
|
|
421
|
-
|
|
422
349
|
_unloadTiles() {
|
|
423
350
|
this._cache.unloadTiles(this, (tileset, tile) => tileset._unloadTile(tile));
|
|
424
351
|
}
|
|
425
|
-
|
|
426
352
|
_updateStats() {
|
|
427
353
|
let tilesRenderable = 0;
|
|
428
354
|
let pointsRenderable = 0;
|
|
429
|
-
|
|
430
355
|
for (const tile of this.selectedTiles) {
|
|
431
356
|
if (tile.contentAvailable && tile.content) {
|
|
432
357
|
tilesRenderable++;
|
|
433
|
-
|
|
434
358
|
if (tile.content.pointCount) {
|
|
435
359
|
pointsRenderable += tile.content.pointCount;
|
|
436
360
|
} else {
|
|
@@ -438,26 +362,20 @@ export default class Tileset3D {
|
|
|
438
362
|
}
|
|
439
363
|
}
|
|
440
364
|
}
|
|
441
|
-
|
|
442
365
|
this.stats.get(TILES_IN_VIEW).count = this.selectedTiles.length;
|
|
443
366
|
this.stats.get(TILES_RENDERABLE).count = tilesRenderable;
|
|
444
367
|
this.stats.get(POINTS_COUNT).count = pointsRenderable;
|
|
445
368
|
}
|
|
446
|
-
|
|
447
369
|
async _initializeTileSet(tilesetJson) {
|
|
448
370
|
if (this.type === TILESET_TYPE.I3S) {
|
|
449
371
|
this.calculateViewPropsI3S();
|
|
450
372
|
tilesetJson.root = await tilesetJson.root;
|
|
451
373
|
}
|
|
452
|
-
|
|
453
374
|
this.root = this._initializeTileHeaders(tilesetJson, null);
|
|
454
|
-
|
|
455
375
|
if (this.type === TILESET_TYPE.TILES3D) {
|
|
456
376
|
this._initializeTiles3DTileset(tilesetJson);
|
|
457
|
-
|
|
458
377
|
this.calculateViewPropsTiles3D();
|
|
459
378
|
}
|
|
460
|
-
|
|
461
379
|
if (this.type === TILESET_TYPE.I3S) {
|
|
462
380
|
this._initializeI3STileset();
|
|
463
381
|
}
|
|
@@ -465,9 +383,7 @@ export default class Tileset3D {
|
|
|
465
383
|
|
|
466
384
|
calculateViewPropsI3S() {
|
|
467
385
|
var _this$tileset$store;
|
|
468
|
-
|
|
469
386
|
const fullExtent = this.tileset.fullExtent;
|
|
470
|
-
|
|
471
387
|
if (fullExtent) {
|
|
472
388
|
const {
|
|
473
389
|
xmin,
|
|
@@ -482,9 +398,7 @@ export default class Tileset3D {
|
|
|
482
398
|
this.zoom = getZoomFromFullExtent(fullExtent, this.cartographicCenter, this.cartesianCenter);
|
|
483
399
|
return;
|
|
484
400
|
}
|
|
485
|
-
|
|
486
401
|
const extent = (_this$tileset$store = this.tileset.store) === null || _this$tileset$store === void 0 ? void 0 : _this$tileset$store.extent;
|
|
487
|
-
|
|
488
402
|
if (extent) {
|
|
489
403
|
const [xmin, ymin, xmax, ymax] = extent;
|
|
490
404
|
this.cartographicCenter = new Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, 0);
|
|
@@ -492,7 +406,6 @@ export default class Tileset3D {
|
|
|
492
406
|
this.zoom = getZoomFromExtent(extent, this.cartographicCenter, this.cartesianCenter);
|
|
493
407
|
return;
|
|
494
408
|
}
|
|
495
|
-
|
|
496
409
|
console.warn('Extent is not defined in the tileset header');
|
|
497
410
|
this.cartographicCenter = new Vector3();
|
|
498
411
|
this.zoom = 1;
|
|
@@ -505,7 +418,6 @@ export default class Tileset3D {
|
|
|
505
418
|
const {
|
|
506
419
|
center
|
|
507
420
|
} = root.boundingVolume;
|
|
508
|
-
|
|
509
421
|
if (!center) {
|
|
510
422
|
console.warn('center was not pre-calculated for the root tile');
|
|
511
423
|
this.cartographicCenter = new Vector3();
|
|
@@ -518,11 +430,9 @@ export default class Tileset3D {
|
|
|
518
430
|
} else {
|
|
519
431
|
this.cartographicCenter = new Vector3(0, 0, -Ellipsoid.WGS84.radii[0]);
|
|
520
432
|
}
|
|
521
|
-
|
|
522
433
|
this.cartesianCenter = center;
|
|
523
434
|
this.zoom = getZoomFromBoundingVolume(root.boundingVolume, this.cartographicCenter);
|
|
524
435
|
}
|
|
525
|
-
|
|
526
436
|
_initializeStats() {
|
|
527
437
|
this.stats.get(TILES_TOTAL);
|
|
528
438
|
this.stats.get(TILES_LOADING);
|
|
@@ -532,7 +442,7 @@ export default class Tileset3D {
|
|
|
532
442
|
this.stats.get(TILES_LOADED);
|
|
533
443
|
this.stats.get(TILES_UNLOADED);
|
|
534
444
|
this.stats.get(TILES_LOAD_FAILED);
|
|
535
|
-
this.stats.get(POINTS_COUNT
|
|
445
|
+
this.stats.get(POINTS_COUNT);
|
|
536
446
|
this.stats.get(TILES_GPU_MEMORY, 'memory');
|
|
537
447
|
}
|
|
538
448
|
|
|
@@ -547,12 +457,10 @@ export default class Tileset3D {
|
|
|
547
457
|
if (this.type === TILESET_TYPE.TILES3D) {
|
|
548
458
|
const stack = [];
|
|
549
459
|
stack.push(rootTile);
|
|
550
|
-
|
|
551
460
|
while (stack.length > 0) {
|
|
552
461
|
const tile = stack.pop();
|
|
553
462
|
this.stats.get(TILES_TOTAL).incrementCount();
|
|
554
463
|
const children = tile.header.children || [];
|
|
555
|
-
|
|
556
464
|
for (const childHeader of children) {
|
|
557
465
|
const childTile = new Tile3D(this, childHeader, tile);
|
|
558
466
|
tile.children.push(childTile);
|
|
@@ -561,53 +469,41 @@ export default class Tileset3D {
|
|
|
561
469
|
}
|
|
562
470
|
}
|
|
563
471
|
}
|
|
564
|
-
|
|
565
472
|
return rootTile;
|
|
566
473
|
}
|
|
567
|
-
|
|
568
474
|
_initializeTraverser() {
|
|
569
475
|
let TraverserClass;
|
|
570
476
|
const type = this.type;
|
|
571
|
-
|
|
572
477
|
switch (type) {
|
|
573
478
|
case TILESET_TYPE.TILES3D:
|
|
574
479
|
TraverserClass = Tileset3DTraverser;
|
|
575
480
|
break;
|
|
576
|
-
|
|
577
481
|
case TILESET_TYPE.I3S:
|
|
578
482
|
TraverserClass = I3SetTraverser;
|
|
579
483
|
break;
|
|
580
|
-
|
|
581
484
|
default:
|
|
582
485
|
TraverserClass = TilesetTraverser;
|
|
583
486
|
}
|
|
584
|
-
|
|
585
487
|
return new TraverserClass({
|
|
586
488
|
basePath: this.basePath,
|
|
587
489
|
onTraversalEnd: this._onTraversalEnd.bind(this)
|
|
588
490
|
});
|
|
589
491
|
}
|
|
590
|
-
|
|
591
492
|
_destroyTileHeaders(parentTile) {
|
|
592
493
|
this._destroySubtree(parentTile);
|
|
593
494
|
}
|
|
594
|
-
|
|
595
495
|
async _loadTile(tile) {
|
|
596
496
|
let loaded;
|
|
597
|
-
|
|
598
497
|
try {
|
|
599
498
|
this._onStartTileLoading();
|
|
600
|
-
|
|
601
499
|
loaded = await tile.loadContent();
|
|
602
500
|
} catch (error) {
|
|
603
501
|
this._onTileLoadError(tile, error);
|
|
604
502
|
} finally {
|
|
605
503
|
this._onEndTileLoading();
|
|
606
|
-
|
|
607
504
|
this._onTileLoad(tile, loaded);
|
|
608
505
|
}
|
|
609
506
|
}
|
|
610
|
-
|
|
611
507
|
_onTileLoadError(tile, error) {
|
|
612
508
|
this.stats.get(TILES_LOAD_FAILED).incrementCount();
|
|
613
509
|
const message = error.message || error.toString();
|
|
@@ -615,15 +511,12 @@ export default class Tileset3D {
|
|
|
615
511
|
console.error("A 3D tile failed to load: ".concat(tile.url, " ").concat(message));
|
|
616
512
|
this.options.onTileError(tile, message, url);
|
|
617
513
|
}
|
|
618
|
-
|
|
619
514
|
_onTileLoad(tile, loaded) {
|
|
620
515
|
if (!loaded) {
|
|
621
516
|
return;
|
|
622
517
|
}
|
|
623
|
-
|
|
624
518
|
if (this.type === TILESET_TYPE.I3S) {
|
|
625
519
|
var _this$tileset, _this$tileset$nodePag;
|
|
626
|
-
|
|
627
520
|
const nodesInNodePages = ((_this$tileset = this.tileset) === null || _this$tileset === void 0 ? void 0 : (_this$tileset$nodePag = _this$tileset.nodePagesTile) === null || _this$tileset$nodePag === void 0 ? void 0 : _this$tileset$nodePag.nodesInNodePages) || 0;
|
|
628
521
|
this.stats.get(TILES_TOTAL).reset();
|
|
629
522
|
this.stats.get(TILES_TOTAL).addCount(nodesInNodePages);
|
|
@@ -632,33 +525,27 @@ export default class Tileset3D {
|
|
|
632
525
|
if (tile && tile.content) {
|
|
633
526
|
calculateTransformProps(tile, tile.content);
|
|
634
527
|
}
|
|
635
|
-
|
|
636
528
|
this._addTileToCache(tile);
|
|
637
|
-
|
|
638
529
|
this.options.onTileLoad(tile);
|
|
639
530
|
}
|
|
640
|
-
|
|
641
531
|
_onStartTileLoading() {
|
|
642
532
|
this._pendingCount++;
|
|
643
533
|
this.stats.get(TILES_LOADING).incrementCount();
|
|
644
534
|
}
|
|
645
|
-
|
|
646
535
|
_onEndTileLoading() {
|
|
647
536
|
this._pendingCount--;
|
|
648
537
|
this.stats.get(TILES_LOADING).decrementCount();
|
|
649
538
|
}
|
|
650
|
-
|
|
651
539
|
_addTileToCache(tile) {
|
|
652
540
|
this._cache.add(this, tile, tileset => tileset._updateCacheStats(tile));
|
|
653
541
|
}
|
|
654
|
-
|
|
655
542
|
_updateCacheStats(tile) {
|
|
656
543
|
this.stats.get(TILES_LOADED).incrementCount();
|
|
657
544
|
this.stats.get(TILES_IN_MEMORY).incrementCount();
|
|
545
|
+
|
|
658
546
|
this.gpuMemoryUsageInBytes += tile.content.byteLength || 0;
|
|
659
547
|
this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
|
|
660
548
|
}
|
|
661
|
-
|
|
662
549
|
_unloadTile(tile) {
|
|
663
550
|
this.gpuMemoryUsageInBytes -= tile.content && tile.content.byteLength || 0;
|
|
664
551
|
this.stats.get(TILES_IN_MEMORY).decrementCount();
|
|
@@ -670,21 +557,16 @@ export default class Tileset3D {
|
|
|
670
557
|
|
|
671
558
|
_destroy() {
|
|
672
559
|
const stack = [];
|
|
673
|
-
|
|
674
560
|
if (this.root) {
|
|
675
561
|
stack.push(this.root);
|
|
676
562
|
}
|
|
677
|
-
|
|
678
563
|
while (stack.length > 0) {
|
|
679
564
|
const tile = stack.pop();
|
|
680
|
-
|
|
681
565
|
for (const child of tile.children) {
|
|
682
566
|
stack.push(child);
|
|
683
567
|
}
|
|
684
|
-
|
|
685
568
|
this._destroyTile(tile);
|
|
686
569
|
}
|
|
687
|
-
|
|
688
570
|
this.root = null;
|
|
689
571
|
}
|
|
690
572
|
|
|
@@ -692,37 +574,27 @@ export default class Tileset3D {
|
|
|
692
574
|
const root = tile;
|
|
693
575
|
const stack = [];
|
|
694
576
|
stack.push(root);
|
|
695
|
-
|
|
696
577
|
while (stack.length > 0) {
|
|
697
578
|
tile = stack.pop();
|
|
698
|
-
|
|
699
579
|
for (const child of tile.children) {
|
|
700
580
|
stack.push(child);
|
|
701
581
|
}
|
|
702
|
-
|
|
703
582
|
if (tile !== root) {
|
|
704
583
|
this._destroyTile(tile);
|
|
705
584
|
}
|
|
706
585
|
}
|
|
707
|
-
|
|
708
586
|
root.children = [];
|
|
709
587
|
}
|
|
710
|
-
|
|
711
588
|
_destroyTile(tile) {
|
|
712
589
|
this._cache.unloadTile(this, tile);
|
|
713
|
-
|
|
714
590
|
this._unloadTile(tile);
|
|
715
|
-
|
|
716
591
|
tile.destroy();
|
|
717
592
|
}
|
|
718
|
-
|
|
719
593
|
_initializeTiles3DTileset(tilesetJson) {
|
|
720
594
|
this.asset = tilesetJson.asset;
|
|
721
|
-
|
|
722
595
|
if (!this.asset) {
|
|
723
596
|
throw new Error('Tileset must have an asset property.');
|
|
724
597
|
}
|
|
725
|
-
|
|
726
598
|
if (this.asset.version !== '0.0' && this.asset.version !== '1.0') {
|
|
727
599
|
throw new Error('The tileset must be 3D Tiles version 0.0 or 1.0.');
|
|
728
600
|
}
|
|
@@ -735,34 +607,28 @@ export default class Tileset3D {
|
|
|
735
607
|
attributions: this.options.attributions || []
|
|
736
608
|
};
|
|
737
609
|
this.description = this.options.description || '';
|
|
610
|
+
|
|
738
611
|
this.properties = tilesetJson.properties;
|
|
739
612
|
this.geometricError = tilesetJson.geometricError;
|
|
740
613
|
this._extensionsUsed = tilesetJson.extensionsUsed;
|
|
741
614
|
this.extras = tilesetJson.extras;
|
|
742
615
|
}
|
|
743
|
-
|
|
744
616
|
_initializeI3STileset() {
|
|
745
617
|
if (this.loadOptions.i3s && 'token' in this.loadOptions.i3s) {
|
|
746
618
|
this._queryParams.token = this.loadOptions.i3s.token;
|
|
747
619
|
}
|
|
748
620
|
}
|
|
749
|
-
|
|
750
621
|
}
|
|
751
|
-
|
|
752
622
|
function getQueryParamString(queryParams) {
|
|
753
623
|
const queryParamStrings = [];
|
|
754
|
-
|
|
755
624
|
for (const key of Object.keys(queryParams)) {
|
|
756
625
|
queryParamStrings.push("".concat(key, "=").concat(queryParams[key]));
|
|
757
626
|
}
|
|
758
|
-
|
|
759
627
|
switch (queryParamStrings.length) {
|
|
760
628
|
case 0:
|
|
761
629
|
return '';
|
|
762
|
-
|
|
763
630
|
case 1:
|
|
764
631
|
return "?".concat(queryParamStrings[0]);
|
|
765
|
-
|
|
766
632
|
default:
|
|
767
633
|
return "?".concat(queryParamStrings.join('&'));
|
|
768
634
|
}
|