@loaders.gl/tiles 5.0.0-alpha.11 → 5.0.0-alpha.12
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.dev.js +24723 -6715
- package/dist/dist.min.js +22 -3
- package/dist/index.cjs +498 -1970
- package/dist/index.cjs.map +4 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/point-cloud-tile-source-loader-types.d.ts +31 -0
- package/dist/point-cloud-tile-source-loader-types.d.ts.map +1 -0
- package/dist/point-cloud-tile-source-loader-types.js +34 -0
- package/dist/point-cloud-tile-source-loader-types.js.map +1 -0
- package/dist/point-cloud-tile-source-loader.cjs +81 -0
- package/dist/point-cloud-tile-source-loader.cjs.map +7 -0
- package/dist/point-cloud-tile-source-loader.d.ts +27 -0
- package/dist/point-cloud-tile-source-loader.d.ts.map +1 -0
- package/dist/point-cloud-tile-source-loader.js +17 -0
- package/dist/point-cloud-tile-source-loader.js.map +1 -0
- package/dist/point-cloud-tile-source-types.d.ts +15 -0
- package/dist/point-cloud-tile-source-types.d.ts.map +1 -0
- package/dist/point-cloud-tile-source-types.js +5 -0
- package/dist/point-cloud-tile-source-types.js.map +1 -0
- package/dist/point-cloud-tile-source.cjs +105 -0
- package/dist/point-cloud-tile-source.cjs.map +7 -0
- package/dist/point-cloud-tile-source.d.ts +36 -0
- package/dist/point-cloud-tile-source.d.ts.map +1 -0
- package/dist/point-cloud-tile-source.js +84 -0
- package/dist/point-cloud-tile-source.js.map +1 -0
- package/dist/spatial/spatial-coordinate-transformer.d.ts +3 -1
- package/dist/spatial/spatial-coordinate-transformer.d.ts.map +1 -1
- package/dist/spatial/spatial-coordinate-transformer.js +17 -1
- package/dist/spatial/spatial-coordinate-transformer.js.map +1 -1
- package/dist/tileset-2d.d.ts +2 -1
- package/dist/tileset-2d.d.ts.map +1 -1
- package/dist/tileset-2d.js +1 -1
- package/dist/tileset-2d.js.map +1 -1
- package/dist/tileset-3d/common/tileset-3d.d.ts +2 -0
- package/dist/tileset-3d/common/tileset-3d.d.ts.map +1 -1
- package/dist/tileset-3d/common/tileset-3d.js.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js +0 -3
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js.map +1 -1
- package/dist/tileset-3d/helpers/s2-bounding-volume.d.ts.map +1 -1
- package/dist/tileset-3d/helpers/s2-bounding-volume.js +0 -3
- package/dist/tileset-3d/helpers/s2-bounding-volume.js.map +1 -1
- package/package.json +25 -13
- package/src/index.ts +6 -0
- package/src/point-cloud-tile-source-loader-types.ts +53 -0
- package/src/point-cloud-tile-source-loader.ts +32 -0
- package/src/point-cloud-tile-source-types.ts +20 -0
- package/src/point-cloud-tile-source.ts +112 -0
- package/src/spatial/spatial-coordinate-transformer.ts +21 -1
- package/src/tileset-2d.ts +25 -1
- package/src/tileset-3d/common/tileset-3d.ts +2 -0
- package/src/tileset-3d/format-3d-tiles/implicit-tiling.ts +0 -3
- package/src/tileset-3d/helpers/s2-bounding-volume.ts +0 -3
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// dist/index.js
|
|
@@ -26,6 +36,7 @@ __export(index_exports, {
|
|
|
26
36
|
IndexedArchiveTilesetSource: () => IndexedArchiveTilesetSource,
|
|
27
37
|
LOD_METRIC_TYPE: () => LOD_METRIC_TYPE,
|
|
28
38
|
PointCloudTile: () => PointCloudTile,
|
|
39
|
+
PointCloudTileSourceLoader: () => PointCloudTileSourceLoader,
|
|
29
40
|
PointCloudTileset: () => PointCloudTileset,
|
|
30
41
|
RasterSet: () => RasterSet,
|
|
31
42
|
STRATEGY_DEFAULT: () => STRATEGY_DEFAULT,
|
|
@@ -72,1701 +83,202 @@ module.exports = __toCommonJS(index_exports);
|
|
|
72
83
|
// dist/tileset-3d/common/tileset-3d.js
|
|
73
84
|
var import_core5 = require("@math.gl/core");
|
|
74
85
|
var import_geospatial3 = require("@math.gl/geospatial");
|
|
75
|
-
var import_stats3 = require("@probe.gl/stats");
|
|
76
86
|
|
|
77
|
-
//
|
|
78
|
-
function
|
|
79
|
-
|
|
80
|
-
|
|
87
|
+
// ../../node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
|
|
88
|
+
function getHiResTimestamp() {
|
|
89
|
+
let timestamp;
|
|
90
|
+
if (typeof window !== "undefined" && window.performance) {
|
|
91
|
+
timestamp = window.performance.now();
|
|
92
|
+
} else if (typeof process !== "undefined" && process.hrtime) {
|
|
93
|
+
const timeParts = process.hrtime();
|
|
94
|
+
timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
|
|
95
|
+
} else {
|
|
96
|
+
timestamp = Date.now();
|
|
81
97
|
}
|
|
98
|
+
return timestamp;
|
|
82
99
|
}
|
|
83
100
|
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
/** The maximum number of simultaneous active requests. Un-throttled requests do not observe this limit. */
|
|
103
|
-
maxRequests: 6,
|
|
104
|
-
/**
|
|
105
|
-
* Specifies a debounce time, in milliseconds. All requests are queued, until no new requests have
|
|
106
|
-
* been added to the queue for this amount of time.
|
|
107
|
-
*/
|
|
108
|
-
debounceTime: 0
|
|
109
|
-
};
|
|
110
|
-
var RequestScheduler = class {
|
|
111
|
-
props;
|
|
112
|
-
stats;
|
|
113
|
-
activeRequestCount = 0;
|
|
114
|
-
/** Tracks the number of active requests and prioritizes/cancels queued requests. */
|
|
115
|
-
requestQueue = [];
|
|
116
|
-
requestMap = /* @__PURE__ */ new Map();
|
|
117
|
-
/** Pending arrival debounce or next-tick refill; only new arrivals replace this timer. */
|
|
118
|
-
updateTimer = null;
|
|
119
|
-
constructor(props = {}) {
|
|
120
|
-
this.props = { ...DEFAULT_PROPS, ...props };
|
|
121
|
-
this.stats = new import_stats.Stats({ id: this.props.id });
|
|
122
|
-
this.stats.get(STAT_QUEUED_REQUESTS);
|
|
123
|
-
this.stats.get(STAT_ACTIVE_REQUESTS);
|
|
124
|
-
this.stats.get(STAT_CANCELLED_REQUESTS);
|
|
125
|
-
this.stats.get(STAT_QUEUED_REQUESTS_EVER);
|
|
126
|
-
this.stats.get(STAT_ACTIVE_REQUESTS_EVER);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Update scheduler props. Preserves active and queued requests.
|
|
130
|
-
*/
|
|
131
|
-
setProps(props) {
|
|
132
|
-
if (props.throttleRequests !== void 0) {
|
|
133
|
-
this.props.throttleRequests = props.throttleRequests;
|
|
134
|
-
}
|
|
135
|
-
if (props.maxRequests !== void 0) {
|
|
136
|
-
this.props.maxRequests = props.maxRequests;
|
|
137
|
-
}
|
|
138
|
-
if (props.debounceTime !== void 0) {
|
|
139
|
-
this.props.debounceTime = props.debounceTime;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Called by an application that wants to issue a request, without having it deeply queued by the browser
|
|
144
|
-
*
|
|
145
|
-
* When the returned promise resolved, it is OK for the application to issue a request.
|
|
146
|
-
* The promise resolves to an object that contains a `done` method.
|
|
147
|
-
* When the application's request has completed (or failed), the application must call the `done` function
|
|
148
|
-
*
|
|
149
|
-
* @param handle
|
|
150
|
-
* @param getPriority will be called when request "slots" open up,
|
|
151
|
-
* allowing the caller to update priority or cancel the request
|
|
152
|
-
* Highest priority executes first, priority < 0 cancels the request
|
|
153
|
-
* @returns a promise
|
|
154
|
-
* - resolves to a object (with a `done` field) when the request can be issued without queueing,
|
|
155
|
-
* - resolves to `null` if the request has been cancelled (by the callback return < 0).
|
|
156
|
-
* In this case the application should not issue the request
|
|
157
|
-
*/
|
|
158
|
-
scheduleRequest(handle, getPriority = () => 0) {
|
|
159
|
-
if (!this.props.throttleRequests) {
|
|
160
|
-
return Promise.resolve({ done: () => {
|
|
161
|
-
} });
|
|
162
|
-
}
|
|
163
|
-
if (this.requestMap.has(handle)) {
|
|
164
|
-
return this.requestMap.get(handle);
|
|
165
|
-
}
|
|
166
|
-
const request = { handle, priority: 0, getPriority };
|
|
167
|
-
const promise = new Promise((resolve2) => {
|
|
168
|
-
request.resolve = resolve2;
|
|
169
|
-
return request;
|
|
170
|
-
});
|
|
171
|
-
this.requestQueue.push(request);
|
|
172
|
-
this.requestMap.set(handle, promise);
|
|
173
|
-
this._issueNewRequests();
|
|
174
|
-
return promise;
|
|
175
|
-
}
|
|
176
|
-
// PRIVATE
|
|
177
|
-
_issueRequest(request) {
|
|
178
|
-
const { handle, resolve: resolve2 } = request;
|
|
179
|
-
let isDone = false;
|
|
180
|
-
const done = () => {
|
|
181
|
-
if (!isDone) {
|
|
182
|
-
isDone = true;
|
|
183
|
-
this.requestMap.delete(handle);
|
|
184
|
-
this.activeRequestCount--;
|
|
185
|
-
this.scheduleRefill();
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
this.activeRequestCount++;
|
|
189
|
-
return resolve2 ? resolve2({ done }) : Promise.resolve({ done });
|
|
190
|
-
}
|
|
191
|
-
/** Refills freed slots on the next tick while preserving any pending arrival debounce. */
|
|
192
|
-
scheduleRefill() {
|
|
193
|
-
if (this.updateTimer !== null) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
this.updateTimer = setTimeout(() => this._issueNewRequestsAsync(), 0);
|
|
101
|
+
// ../../node_modules/@probe.gl/stats/dist/lib/stat.js
|
|
102
|
+
var Stat = class {
|
|
103
|
+
constructor(name, type) {
|
|
104
|
+
this.sampleSize = 1;
|
|
105
|
+
this.time = 0;
|
|
106
|
+
this.count = 0;
|
|
107
|
+
this.samples = 0;
|
|
108
|
+
this.lastTiming = 0;
|
|
109
|
+
this.lastSampleTime = 0;
|
|
110
|
+
this.lastSampleCount = 0;
|
|
111
|
+
this._count = 0;
|
|
112
|
+
this._time = 0;
|
|
113
|
+
this._samples = 0;
|
|
114
|
+
this._startTime = 0;
|
|
115
|
+
this._timerPending = false;
|
|
116
|
+
this.name = name;
|
|
117
|
+
this.type = type;
|
|
118
|
+
this.reset();
|
|
197
119
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
this.
|
|
120
|
+
reset() {
|
|
121
|
+
this.time = 0;
|
|
122
|
+
this.count = 0;
|
|
123
|
+
this.samples = 0;
|
|
124
|
+
this.lastTiming = 0;
|
|
125
|
+
this.lastSampleTime = 0;
|
|
126
|
+
this.lastSampleCount = 0;
|
|
127
|
+
this._count = 0;
|
|
128
|
+
this._time = 0;
|
|
129
|
+
this._samples = 0;
|
|
130
|
+
this._startTime = 0;
|
|
131
|
+
this._timerPending = false;
|
|
132
|
+
return this;
|
|
204
133
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
clearTimeout(this.updateTimer);
|
|
209
|
-
}
|
|
210
|
-
this.updateTimer = null;
|
|
211
|
-
const freeSlots = Math.max(this.props.maxRequests - this.activeRequestCount, 0);
|
|
212
|
-
if (freeSlots === 0) {
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
this._updateAllRequests();
|
|
216
|
-
for (let i = 0; i < freeSlots; ++i) {
|
|
217
|
-
const request = this.requestQueue.shift();
|
|
218
|
-
if (request) {
|
|
219
|
-
this._issueRequest(request);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
134
|
+
setSampleSize(samples) {
|
|
135
|
+
this.sampleSize = samples;
|
|
136
|
+
return this;
|
|
222
137
|
}
|
|
223
|
-
/**
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const request = requestQueue[i];
|
|
228
|
-
if (!this._updateRequest(request)) {
|
|
229
|
-
requestQueue.splice(i, 1);
|
|
230
|
-
this.requestMap.delete(request.handle);
|
|
231
|
-
i--;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
requestQueue.sort((a, b) => a.priority - b.priority);
|
|
138
|
+
/** Call to increment count (+1) */
|
|
139
|
+
incrementCount() {
|
|
140
|
+
this.addCount(1);
|
|
141
|
+
return this;
|
|
235
142
|
}
|
|
236
|
-
/**
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
request.resolve(null);
|
|
241
|
-
return false;
|
|
242
|
-
}
|
|
243
|
-
return true;
|
|
143
|
+
/** Call to decrement count (-1) */
|
|
144
|
+
decrementCount() {
|
|
145
|
+
this.subtractCount(1);
|
|
146
|
+
return this;
|
|
244
147
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
/** Maximum number of settled entries retained by this cache. */
|
|
252
|
-
maxEntries;
|
|
253
|
-
/** Maximum estimated bytes retained by this cache. */
|
|
254
|
-
maxBytes;
|
|
255
|
-
getByteLength;
|
|
256
|
-
onRemove;
|
|
257
|
-
entries = /* @__PURE__ */ new Map();
|
|
258
|
-
retainedByteLength = 0;
|
|
259
|
-
/** Creates a request cache with optional entry and byte limits. */
|
|
260
|
-
constructor(props = {}) {
|
|
261
|
-
this.maxEntries = validateLimit(props.maxEntries, DEFAULT_MAX_ENTRIES, "maxEntries");
|
|
262
|
-
this.maxBytes = validateLimit(props.maxBytes, DEFAULT_MAX_BYTES, "maxBytes");
|
|
263
|
-
this.getByteLength = props.getByteLength || (() => 0);
|
|
264
|
-
this.onRemove = props.onRemove;
|
|
265
|
-
}
|
|
266
|
-
/** Number of pending and settled entries currently tracked. */
|
|
267
|
-
get size() {
|
|
268
|
-
return this.entries.size;
|
|
148
|
+
/** Increase count */
|
|
149
|
+
addCount(value) {
|
|
150
|
+
this._count += value;
|
|
151
|
+
this._samples++;
|
|
152
|
+
this._checkSampling();
|
|
153
|
+
return this;
|
|
269
154
|
}
|
|
270
|
-
/**
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
return pendingSize;
|
|
155
|
+
/** Decrease count */
|
|
156
|
+
subtractCount(value) {
|
|
157
|
+
this._count -= value;
|
|
158
|
+
this._samples++;
|
|
159
|
+
this._checkSampling();
|
|
160
|
+
return this;
|
|
277
161
|
}
|
|
278
|
-
/**
|
|
279
|
-
|
|
280
|
-
|
|
162
|
+
/** Add an arbitrary timing and bump the count */
|
|
163
|
+
addTime(time) {
|
|
164
|
+
this._time += time;
|
|
165
|
+
this.lastTiming = time;
|
|
166
|
+
this._samples++;
|
|
167
|
+
this._checkSampling();
|
|
168
|
+
return this;
|
|
281
169
|
}
|
|
282
|
-
/**
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
this.touch(key, entry);
|
|
289
|
-
return this.waitForEntry(key, entry, signal);
|
|
290
|
-
}
|
|
291
|
-
/** Returns whether a pending or settled entry exists without updating its LRU position. */
|
|
292
|
-
has(key) {
|
|
293
|
-
return this.entries.has(key);
|
|
294
|
-
}
|
|
295
|
-
/** Stores an already available value and returns it. */
|
|
296
|
-
set(key, value) {
|
|
297
|
-
this.removeEntry(key, "replace");
|
|
298
|
-
const byteLength = getValidByteLength(this.getByteLength(value));
|
|
299
|
-
const entry = {
|
|
300
|
-
promise: Promise.resolve(value),
|
|
301
|
-
pending: false,
|
|
302
|
-
waiterCount: 0,
|
|
303
|
-
byteLength
|
|
304
|
-
};
|
|
305
|
-
this.entries.set(key, entry);
|
|
306
|
-
this.retainedByteLength += byteLength;
|
|
307
|
-
this.trim();
|
|
308
|
-
return value;
|
|
170
|
+
/** Start a timer */
|
|
171
|
+
timeStart() {
|
|
172
|
+
this._startTime = getHiResTimestamp();
|
|
173
|
+
this._timerPending = true;
|
|
174
|
+
return this;
|
|
309
175
|
}
|
|
310
|
-
/**
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
* the shared request is cancelled when no waiters remain.
|
|
315
|
-
*/
|
|
316
|
-
getOrLoad(key, load, signal) {
|
|
317
|
-
const cached = this.get(key, signal);
|
|
318
|
-
if (cached) {
|
|
319
|
-
return cached;
|
|
320
|
-
}
|
|
321
|
-
if (signal == null ? void 0 : signal.aborted) {
|
|
322
|
-
return Promise.reject(createAbortError());
|
|
323
|
-
}
|
|
324
|
-
const controller = new AbortController();
|
|
325
|
-
let resolveRequest;
|
|
326
|
-
let rejectRequest;
|
|
327
|
-
const promise = new Promise((resolve2, reject) => {
|
|
328
|
-
resolveRequest = resolve2;
|
|
329
|
-
rejectRequest = reject;
|
|
330
|
-
});
|
|
331
|
-
const entry = {
|
|
332
|
-
promise,
|
|
333
|
-
controller,
|
|
334
|
-
pending: true,
|
|
335
|
-
waiterCount: 0,
|
|
336
|
-
byteLength: 0
|
|
337
|
-
};
|
|
338
|
-
this.entries.set(key, entry);
|
|
339
|
-
void entry.promise.then(
|
|
340
|
-
(value) => this.handleLoadedValue(key, entry, value),
|
|
341
|
-
() => this.handleLoadError(key, entry)
|
|
342
|
-
);
|
|
343
|
-
try {
|
|
344
|
-
void Promise.resolve(load(controller.signal)).then(resolveRequest, rejectRequest);
|
|
345
|
-
} catch (error) {
|
|
346
|
-
rejectRequest(error);
|
|
176
|
+
/** End a timer. Adds to time and bumps the timing count. */
|
|
177
|
+
timeEnd() {
|
|
178
|
+
if (!this._timerPending) {
|
|
179
|
+
return this;
|
|
347
180
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
return this.removeEntry(key, "delete");
|
|
181
|
+
this.addTime(getHiResTimestamp() - this._startTime);
|
|
182
|
+
this._timerPending = false;
|
|
183
|
+
this._checkSampling();
|
|
184
|
+
return this;
|
|
353
185
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
for (const key of Array.from(this.entries.keys())) {
|
|
357
|
-
this.removeEntry(key, "clear");
|
|
358
|
-
}
|
|
186
|
+
getSampleAverageCount() {
|
|
187
|
+
return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0;
|
|
359
188
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
entry.pending = false;
|
|
365
|
-
entry.controller = void 0;
|
|
366
|
-
try {
|
|
367
|
-
entry.byteLength = getValidByteLength(this.getByteLength(value));
|
|
368
|
-
} catch {
|
|
369
|
-
this.removeEntry(key, "error");
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
this.retainedByteLength += entry.byteLength;
|
|
373
|
-
this.trim();
|
|
189
|
+
/** Calculate average time / count for the previous window */
|
|
190
|
+
getSampleAverageTime() {
|
|
191
|
+
return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0;
|
|
374
192
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
this.removeEntry(key, ((_a = entry.controller) == null ? void 0 : _a.signal.aborted) ? "abort" : "error");
|
|
379
|
-
}
|
|
193
|
+
/** Calculate counts per second for the previous window */
|
|
194
|
+
getSampleHz() {
|
|
195
|
+
return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1e3) : 0;
|
|
380
196
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
return Promise.reject(createAbortError());
|
|
384
|
-
}
|
|
385
|
-
if (!entry.pending) {
|
|
386
|
-
return entry.promise;
|
|
387
|
-
}
|
|
388
|
-
entry.waiterCount++;
|
|
389
|
-
return new Promise((resolve2, reject) => {
|
|
390
|
-
let waiting = true;
|
|
391
|
-
const finishWaiting = () => {
|
|
392
|
-
if (!waiting) return;
|
|
393
|
-
waiting = false;
|
|
394
|
-
signal == null ? void 0 : signal.removeEventListener("abort", handleAbort);
|
|
395
|
-
entry.waiterCount--;
|
|
396
|
-
};
|
|
397
|
-
const handleAbort = () => {
|
|
398
|
-
if (!waiting) return;
|
|
399
|
-
finishWaiting();
|
|
400
|
-
reject(createAbortError());
|
|
401
|
-
if (entry.pending && entry.waiterCount === 0 && this.entries.get(key) === entry) {
|
|
402
|
-
this.removeEntry(key, "abort");
|
|
403
|
-
}
|
|
404
|
-
};
|
|
405
|
-
signal == null ? void 0 : signal.addEventListener("abort", handleAbort, { once: true });
|
|
406
|
-
void entry.promise.then(
|
|
407
|
-
(value) => {
|
|
408
|
-
if (!waiting) return;
|
|
409
|
-
finishWaiting();
|
|
410
|
-
resolve2(value);
|
|
411
|
-
},
|
|
412
|
-
(error) => {
|
|
413
|
-
if (!waiting) return;
|
|
414
|
-
finishWaiting();
|
|
415
|
-
reject(error);
|
|
416
|
-
}
|
|
417
|
-
);
|
|
418
|
-
});
|
|
197
|
+
getAverageCount() {
|
|
198
|
+
return this.samples > 0 ? this.count / this.samples : 0;
|
|
419
199
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
this.
|
|
200
|
+
/** Calculate average time / count */
|
|
201
|
+
getAverageTime() {
|
|
202
|
+
return this.samples > 0 ? this.time / this.samples : 0;
|
|
423
203
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
for (const [key, entry] of this.entries) {
|
|
430
|
-
if (!entry.pending) {
|
|
431
|
-
this.removeEntry(key, "evict");
|
|
432
|
-
settledEntryCount--;
|
|
433
|
-
}
|
|
434
|
-
if (settledEntryCount <= this.maxEntries && this.retainedByteLength <= this.maxBytes) {
|
|
435
|
-
break;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
204
|
+
/** Calculate counts per second */
|
|
205
|
+
getHz() {
|
|
206
|
+
return this.time > 0 ? this.samples / (this.time / 1e3) : 0;
|
|
438
207
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
208
|
+
_checkSampling() {
|
|
209
|
+
if (this._samples === this.sampleSize) {
|
|
210
|
+
this.lastSampleTime = this._time;
|
|
211
|
+
this.lastSampleCount = this._count;
|
|
212
|
+
this.count += this._count;
|
|
213
|
+
this.time += this._time;
|
|
214
|
+
this.samples += this._samples;
|
|
215
|
+
this._time = 0;
|
|
216
|
+
this._count = 0;
|
|
217
|
+
this._samples = 0;
|
|
449
218
|
}
|
|
450
|
-
(_b = this.onRemove) == null ? void 0 : _b.call(this, key, reason);
|
|
451
|
-
return true;
|
|
452
219
|
}
|
|
453
220
|
};
|
|
454
|
-
function createAbortError() {
|
|
455
|
-
const error = new Error("Request aborted");
|
|
456
|
-
error.name = "AbortError";
|
|
457
|
-
return error;
|
|
458
|
-
}
|
|
459
|
-
function validateLimit(value, fallback, name) {
|
|
460
|
-
const limit = value ?? fallback;
|
|
461
|
-
if (limit < 0 || Number.isNaN(limit)) {
|
|
462
|
-
throw new Error(`${name} must be a non-negative number`);
|
|
463
|
-
}
|
|
464
|
-
return limit;
|
|
465
|
-
}
|
|
466
|
-
function getValidByteLength(value) {
|
|
467
|
-
if (!Number.isFinite(value) || value < 0) {
|
|
468
|
-
throw new Error("Request cache entry byte length must be a non-negative finite number");
|
|
469
|
-
}
|
|
470
|
-
return value;
|
|
471
|
-
}
|
|
472
221
|
|
|
473
|
-
//
|
|
474
|
-
var
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
requestedBytes: "Logical Range Request Bytes",
|
|
482
|
-
transportBytes: "Range Transport Bytes Requested",
|
|
483
|
-
responseBytes: "Range Response Bytes",
|
|
484
|
-
networkTimeMs: "Range Network Time",
|
|
485
|
-
overfetchBytes: "Range Overfetch Bytes",
|
|
486
|
-
failedTransportRanges: "Range Transport Requests Failed",
|
|
487
|
-
abortedLogicalRanges: "Aborted Logical Range Requests",
|
|
488
|
-
fullResponseFallbacks: "Full Response Fallbacks"
|
|
489
|
-
};
|
|
490
|
-
var DEFAULT_PROPS2 = {
|
|
491
|
-
batchDelayMs: 50,
|
|
492
|
-
maxGapBytes: 65536,
|
|
493
|
-
rangeExpansionBytes: 65536,
|
|
494
|
-
maxMergedBytes: 8388608,
|
|
495
|
-
maxConcurrency: 6,
|
|
496
|
-
maxQueueSize: 4096,
|
|
497
|
-
maxRangeBytes: 64 * 1024 * 1024,
|
|
498
|
-
stats: createRangeStats("range-request-scheduler-default"),
|
|
499
|
-
onEvent: () => {
|
|
500
|
-
}
|
|
501
|
-
};
|
|
502
|
-
var RangeRequestScheduler = class {
|
|
503
|
-
/** Runtime scheduler configuration with defaults filled in. */
|
|
504
|
-
props;
|
|
505
|
-
/** Runtime counters for range batching and transport behavior. */
|
|
506
|
-
stats;
|
|
507
|
-
/** Optional event callback for range batching diagnostics. */
|
|
508
|
-
onEvent;
|
|
509
|
-
pendingRequests = [];
|
|
510
|
-
/** Merged transports waiting for a concurrency slot. */
|
|
511
|
-
transportQueue = [];
|
|
512
|
-
/** Number of active transports. */
|
|
513
|
-
activeTransports = 0;
|
|
514
|
-
/** Number of unsettled logical requests. */
|
|
515
|
-
queuedRequests = 0;
|
|
516
|
-
/** Unsettled requests retained until completion or disposal. */
|
|
517
|
-
logicalRequests = /* @__PURE__ */ new Set();
|
|
518
|
-
/** Controllers for transports owned by this scheduler. */
|
|
519
|
-
transportControllers = /* @__PURE__ */ new Set();
|
|
520
|
-
/** Disposal prevents further enqueueing. */
|
|
521
|
-
finalized = false;
|
|
522
|
-
/** Pending batch window, independent of in-flight transport requests. */
|
|
523
|
-
flushTimer = null;
|
|
524
|
-
/** Creates a scheduler for one group of byte-range-addressable resources. */
|
|
525
|
-
constructor(props = {}) {
|
|
526
|
-
const rangeExpansionBytes = props.rangeExpansionBytes ?? props.maxGapBytes ?? DEFAULT_PROPS2.rangeExpansionBytes;
|
|
527
|
-
this.props = {
|
|
528
|
-
batchDelayMs: props.batchDelayMs ?? DEFAULT_PROPS2.batchDelayMs,
|
|
529
|
-
maxGapBytes: props.maxGapBytes ?? rangeExpansionBytes,
|
|
530
|
-
rangeExpansionBytes,
|
|
531
|
-
maxMergedBytes: props.maxMergedBytes ?? DEFAULT_PROPS2.maxMergedBytes,
|
|
532
|
-
maxConcurrency: props.maxConcurrency ?? 6,
|
|
533
|
-
maxQueueSize: props.maxQueueSize ?? 4096,
|
|
534
|
-
maxRangeBytes: props.maxRangeBytes ?? 64 * 1024 * 1024
|
|
535
|
-
};
|
|
536
|
-
for (const value of [
|
|
537
|
-
this.props.maxConcurrency,
|
|
538
|
-
this.props.maxQueueSize,
|
|
539
|
-
this.props.maxRangeBytes
|
|
540
|
-
]) {
|
|
541
|
-
if (!Number.isSafeInteger(value) || value <= 0)
|
|
542
|
-
throw new Error("Range scheduler limits must be positive integers");
|
|
543
|
-
}
|
|
544
|
-
this.stats = props.stats || createRangeStats("range-request-scheduler");
|
|
545
|
-
this.onEvent = props.onEvent;
|
|
546
|
-
initializeStats(this.stats);
|
|
547
|
-
}
|
|
548
|
-
/**
|
|
549
|
-
* Enqueues one byte range request and resolves with the exact requested byte slice.
|
|
550
|
-
*/
|
|
551
|
-
scheduleRequest(request) {
|
|
552
|
-
var _a;
|
|
553
|
-
if (this.finalized) return Promise.reject(new Error("Range scheduler is finalized"));
|
|
554
|
-
if (!Number.isSafeInteger(request.offset) || request.offset < 0 || !Number.isSafeInteger(request.length) || request.length > this.props.maxRangeBytes || !Number.isSafeInteger(request.offset + request.length))
|
|
555
|
-
return Promise.reject(new Error("Invalid or oversized byte range"));
|
|
556
|
-
if (this.queuedRequests >= this.props.maxQueueSize)
|
|
557
|
-
return Promise.reject(new Error("Range scheduler queue limit exceeded"));
|
|
558
|
-
if (request.length < 0) {
|
|
559
|
-
return Promise.reject(new Error("Byte range length cannot be negative"));
|
|
560
|
-
}
|
|
561
|
-
if ((_a = request.signal) == null ? void 0 : _a.aborted) {
|
|
562
|
-
return Promise.reject(request.signal.reason ?? createAbortError2());
|
|
563
|
-
}
|
|
564
|
-
if (request.length === 0) {
|
|
565
|
-
return Promise.resolve(new ArrayBuffer(0));
|
|
566
|
-
}
|
|
567
|
-
this.queuedRequests++;
|
|
568
|
-
let pendingRequest;
|
|
569
|
-
const promise = new Promise((resolve2, reject) => {
|
|
570
|
-
pendingRequest = { ...request, resolve: resolve2, reject, settled: false };
|
|
571
|
-
this.logicalRequests.add(pendingRequest);
|
|
572
|
-
if (request.signal) {
|
|
573
|
-
pendingRequest.abortListener = () => {
|
|
574
|
-
var _a2;
|
|
575
|
-
this.abortRequest(pendingRequest);
|
|
576
|
-
(_a2 = pendingRequest.onAbort) == null ? void 0 : _a2.call(pendingRequest);
|
|
577
|
-
};
|
|
578
|
-
request.signal.addEventListener("abort", pendingRequest.abortListener, { once: true });
|
|
579
|
-
}
|
|
580
|
-
this.pendingRequests.push(pendingRequest);
|
|
581
|
-
});
|
|
582
|
-
this.trackEvent({
|
|
583
|
-
type: "queued",
|
|
584
|
-
sourceId: request.sourceId,
|
|
585
|
-
offset: request.offset,
|
|
586
|
-
length: request.length,
|
|
587
|
-
logicalRequestCount: 1,
|
|
588
|
-
logicalBytes: request.length
|
|
589
|
-
});
|
|
590
|
-
this.scheduleFlush();
|
|
591
|
-
return promise.finally(() => {
|
|
592
|
-
var _a2;
|
|
593
|
-
if (pendingRequest.abortListener)
|
|
594
|
-
(_a2 = request.signal) == null ? void 0 : _a2.removeEventListener("abort", pendingRequest.abortListener);
|
|
595
|
-
this.queuedRequests--;
|
|
596
|
-
this.logicalRequests.delete(pendingRequest);
|
|
597
|
-
});
|
|
598
|
-
}
|
|
599
|
-
/**
|
|
600
|
-
* Enqueues one HTTP byte-range request and resolves with the exact requested byte slice.
|
|
601
|
-
*/
|
|
602
|
-
fetch(request) {
|
|
603
|
-
const fetchFunction = request.fetch || globalThis.fetch;
|
|
604
|
-
return this.scheduleRequest({
|
|
605
|
-
sourceId: request.sourceId || request.url,
|
|
606
|
-
offset: request.offset,
|
|
607
|
-
length: request.length,
|
|
608
|
-
signal: request.signal,
|
|
609
|
-
// Different fetch calls may carry different credentials or transport implementations.
|
|
610
|
-
// Sharing is therefore opt-in through an explicit common isolation key.
|
|
611
|
-
isolationKey: request.isolationKey ?? {},
|
|
612
|
-
fetchRange: (offset, length, signal) => fetchHttpRange({
|
|
613
|
-
url: request.url,
|
|
614
|
-
offset,
|
|
615
|
-
length,
|
|
616
|
-
signal,
|
|
617
|
-
fetch: fetchFunction,
|
|
618
|
-
fetchOptions: request.fetchOptions
|
|
619
|
-
})
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
|
-
/** Immediately starts loading the currently queued requests. */
|
|
623
|
-
flush() {
|
|
624
|
-
if (this.flushTimer !== null) {
|
|
625
|
-
clearTimeout(this.flushTimer);
|
|
626
|
-
this.flushTimer = null;
|
|
627
|
-
}
|
|
628
|
-
const pendingRequests = this.pendingRequests;
|
|
629
|
-
this.pendingRequests = [];
|
|
630
|
-
const activeRequests = pendingRequests.filter((request) => {
|
|
631
|
-
var _a;
|
|
632
|
-
if (request.settled || ((_a = request.signal) == null ? void 0 : _a.aborted)) {
|
|
633
|
-
this.abortRequest(request);
|
|
634
|
-
return false;
|
|
635
|
-
}
|
|
636
|
-
return true;
|
|
637
|
-
});
|
|
638
|
-
const mergedRequests = this.mergeRequests(activeRequests);
|
|
639
|
-
if (activeRequests.length > 0) {
|
|
640
|
-
this.trackBatch(activeRequests, mergedRequests);
|
|
641
|
-
}
|
|
642
|
-
this.transportQueue.push(...mergedRequests);
|
|
643
|
-
this.startQueuedTransports();
|
|
644
|
-
}
|
|
645
|
-
/** Cancels owned work and releases queued resources; borrowed users must not finalize shared schedulers. */
|
|
646
|
-
finalize() {
|
|
647
|
-
var _a;
|
|
648
|
-
this.finalized = true;
|
|
649
|
-
if (this.flushTimer !== null) clearTimeout(this.flushTimer);
|
|
650
|
-
this.flushTimer = null;
|
|
651
|
-
for (const request of this.logicalRequests) {
|
|
652
|
-
this.abortRequest(request);
|
|
653
|
-
if (request.abortListener)
|
|
654
|
-
(_a = request.signal) == null ? void 0 : _a.removeEventListener("abort", request.abortListener);
|
|
655
|
-
}
|
|
656
|
-
for (const controller of this.transportControllers) controller.abort();
|
|
657
|
-
this.transportQueue = [];
|
|
658
|
-
this.pendingRequests = [];
|
|
659
|
-
this.logicalRequests.clear();
|
|
660
|
-
}
|
|
661
|
-
/** Starts transports while respecting the configured concurrency bound. */
|
|
662
|
-
startQueuedTransports() {
|
|
663
|
-
while (this.activeTransports < this.props.maxConcurrency && this.transportQueue.length) {
|
|
664
|
-
const request = this.transportQueue.shift();
|
|
665
|
-
this.activeTransports++;
|
|
666
|
-
void this.fetchMergedRequest(request).finally(() => {
|
|
667
|
-
this.activeTransports--;
|
|
668
|
-
this.startQueuedTransports();
|
|
669
|
-
});
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
/** Starts a fixed batch window only when no flush is already scheduled. */
|
|
673
|
-
scheduleFlush() {
|
|
674
|
-
if (this.flushTimer !== null) {
|
|
675
|
-
return;
|
|
676
|
-
}
|
|
677
|
-
this.flushTimer = setTimeout(() => this.flush(), this.props.batchDelayMs);
|
|
222
|
+
// ../../node_modules/@probe.gl/stats/dist/lib/stats.js
|
|
223
|
+
var Stats = class {
|
|
224
|
+
constructor(options) {
|
|
225
|
+
this.stats = {};
|
|
226
|
+
this.id = options.id;
|
|
227
|
+
this.stats = {};
|
|
228
|
+
this._initializeStats(options.stats);
|
|
229
|
+
Object.seal(this);
|
|
678
230
|
}
|
|
679
|
-
/**
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
if (left.sourceId !== right.sourceId) {
|
|
683
|
-
return left.sourceId < right.sourceId ? -1 : 1;
|
|
684
|
-
}
|
|
685
|
-
return left.offset - right.offset;
|
|
686
|
-
});
|
|
687
|
-
const mergedRequests = [];
|
|
688
|
-
for (const request of requests) {
|
|
689
|
-
const requestEndOffset = request.offset + request.length;
|
|
690
|
-
const lastMergedRequest = mergedRequests[mergedRequests.length - 1];
|
|
691
|
-
if (lastMergedRequest && canMergeRequests(lastMergedRequest, request, this.props)) {
|
|
692
|
-
lastMergedRequest.endOffset = Math.max(lastMergedRequest.endOffset, requestEndOffset);
|
|
693
|
-
lastMergedRequest.requests.push(request);
|
|
694
|
-
} else {
|
|
695
|
-
mergedRequests.push({
|
|
696
|
-
sourceId: request.sourceId,
|
|
697
|
-
isolationKey: request.isolationKey ?? request.sourceId,
|
|
698
|
-
offset: request.offset,
|
|
699
|
-
endOffset: requestEndOffset,
|
|
700
|
-
fetchRange: request.fetchRange,
|
|
701
|
-
requests: [request]
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
return mergedRequests;
|
|
231
|
+
/** Acquire a stat. Create if it doesn't exist. */
|
|
232
|
+
get(name, type = "count") {
|
|
233
|
+
return this._getOrCreate({ name, type });
|
|
706
234
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
var _a, _b;
|
|
710
|
-
const { offset, endOffset, fetchRange, requests } = mergedRequest;
|
|
711
|
-
const abortController = new AbortController();
|
|
712
|
-
this.transportControllers.add(abortController);
|
|
713
|
-
const requestStartTime = getTimestamp();
|
|
714
|
-
const abortTransportIfUnused = () => {
|
|
715
|
-
if (requests.every((request) => {
|
|
716
|
-
var _a2;
|
|
717
|
-
return request.settled || ((_a2 = request.signal) == null ? void 0 : _a2.aborted);
|
|
718
|
-
})) {
|
|
719
|
-
abortController.abort();
|
|
720
|
-
}
|
|
721
|
-
};
|
|
722
|
-
try {
|
|
723
|
-
for (const request of requests) {
|
|
724
|
-
request.onAbort = abortTransportIfUnused;
|
|
725
|
-
}
|
|
726
|
-
abortTransportIfUnused();
|
|
727
|
-
if (requests.every((request) => request.settled)) {
|
|
728
|
-
return;
|
|
729
|
-
}
|
|
730
|
-
const logicalBytes = getLogicalRequestBytes(requests);
|
|
731
|
-
const length = endOffset - offset;
|
|
732
|
-
this.trackEvent({
|
|
733
|
-
type: "request",
|
|
734
|
-
sourceId: mergedRequest.sourceId,
|
|
735
|
-
offset,
|
|
736
|
-
length,
|
|
737
|
-
logicalRequestCount: requests.length,
|
|
738
|
-
logicalBytes,
|
|
739
|
-
transportBytes: length,
|
|
740
|
-
overfetchBytes: Math.max(length - logicalBytes, 0)
|
|
741
|
-
});
|
|
742
|
-
const transportResult = normalizeTransportResult(
|
|
743
|
-
await fetchRange(offset, length, abortController.signal)
|
|
744
|
-
);
|
|
745
|
-
const { arrayBuffer } = transportResult;
|
|
746
|
-
const isClampedFullResponse = transportResult.fullResponse && offset === 0 && arrayBuffer.byteLength < length;
|
|
747
|
-
const isClampedEndOfFile = arrayBuffer.byteLength < length && Number.isSafeInteger(transportResult.sourceByteLength) && offset + arrayBuffer.byteLength === transportResult.sourceByteLength;
|
|
748
|
-
if (arrayBuffer.byteLength !== length && !isClampedFullResponse && !isClampedEndOfFile) {
|
|
749
|
-
throw new Error(
|
|
750
|
-
`Byte-range transport returned ${arrayBuffer.byteLength} bytes; expected ${length}`
|
|
751
|
-
);
|
|
752
|
-
}
|
|
753
|
-
const networkTimeMs = transportResult.networkTimeMs ?? getTimestamp() - requestStartTime;
|
|
754
|
-
this.trackEvent({
|
|
755
|
-
type: "response",
|
|
756
|
-
sourceId: mergedRequest.sourceId,
|
|
757
|
-
offset,
|
|
758
|
-
length,
|
|
759
|
-
logicalRequestCount: requests.length,
|
|
760
|
-
logicalBytes,
|
|
761
|
-
transportBytes: length,
|
|
762
|
-
responseBytes: transportResult.transportBytes ?? arrayBuffer.byteLength,
|
|
763
|
-
networkTimeMs,
|
|
764
|
-
overfetchBytes: Math.max(length - logicalBytes, 0),
|
|
765
|
-
status: transportResult.status,
|
|
766
|
-
fullResponse: transportResult.fullResponse
|
|
767
|
-
});
|
|
768
|
-
for (const request of requests) {
|
|
769
|
-
if (request.settled) {
|
|
770
|
-
continue;
|
|
771
|
-
}
|
|
772
|
-
const start = request.offset - offset;
|
|
773
|
-
request.settled = true;
|
|
774
|
-
request.resolve(arrayBuffer.slice(start, start + request.length));
|
|
775
|
-
}
|
|
776
|
-
} catch (error) {
|
|
777
|
-
if (!abortController.signal.aborted) {
|
|
778
|
-
this.trackEvent({
|
|
779
|
-
type: "error",
|
|
780
|
-
sourceId: mergedRequest.sourceId,
|
|
781
|
-
offset,
|
|
782
|
-
length: endOffset - offset,
|
|
783
|
-
logicalRequestCount: requests.length,
|
|
784
|
-
logicalBytes: getLogicalRequestBytes(requests),
|
|
785
|
-
networkTimeMs: getTimestamp() - requestStartTime,
|
|
786
|
-
error
|
|
787
|
-
});
|
|
788
|
-
}
|
|
789
|
-
for (const request of requests) {
|
|
790
|
-
if (request.settled) {
|
|
791
|
-
continue;
|
|
792
|
-
}
|
|
793
|
-
if ((_a = request.signal) == null ? void 0 : _a.aborted) {
|
|
794
|
-
this.abortRequest(request);
|
|
795
|
-
} else {
|
|
796
|
-
request.settled = true;
|
|
797
|
-
request.reject(error);
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
} finally {
|
|
801
|
-
this.transportControllers.delete(abortController);
|
|
802
|
-
for (const request of requests) {
|
|
803
|
-
if (request.abortListener) {
|
|
804
|
-
(_b = request.signal) == null ? void 0 : _b.removeEventListener("abort", request.abortListener);
|
|
805
|
-
}
|
|
806
|
-
request.onAbort = void 0;
|
|
807
|
-
}
|
|
808
|
-
}
|
|
235
|
+
get size() {
|
|
236
|
+
return Object.keys(this.stats).length;
|
|
809
237
|
}
|
|
810
|
-
/**
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
return;
|
|
238
|
+
/** Reset all stats */
|
|
239
|
+
reset() {
|
|
240
|
+
for (const stat of Object.values(this.stats)) {
|
|
241
|
+
stat.reset();
|
|
815
242
|
}
|
|
816
|
-
|
|
817
|
-
this.pendingRequests = this.pendingRequests.filter((pending) => pending !== request);
|
|
818
|
-
for (const group of this.transportQueue) {
|
|
819
|
-
group.requests = group.requests.filter((pending) => !pending.settled);
|
|
820
|
-
if (group.requests.length) {
|
|
821
|
-
group.offset = Math.min(...group.requests.map((pending) => pending.offset));
|
|
822
|
-
group.endOffset = Math.max(
|
|
823
|
-
...group.requests.map((pending) => pending.offset + pending.length)
|
|
824
|
-
);
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
this.transportQueue = this.transportQueue.filter((group) => group.requests.length > 0);
|
|
828
|
-
request.reject(((_a = request.signal) == null ? void 0 : _a.reason) ?? createAbortError2());
|
|
829
|
-
this.trackEvent({
|
|
830
|
-
type: "abort",
|
|
831
|
-
sourceId: request.sourceId,
|
|
832
|
-
offset: request.offset,
|
|
833
|
-
length: request.length,
|
|
834
|
-
logicalRequestCount: 1,
|
|
835
|
-
logicalBytes: request.length
|
|
836
|
-
});
|
|
243
|
+
return this;
|
|
837
244
|
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
trackStatsEvent(this.stats, event);
|
|
842
|
-
try {
|
|
843
|
-
(_a = this.onEvent) == null ? void 0 : _a.call(this, event);
|
|
844
|
-
} catch {
|
|
245
|
+
forEach(fn) {
|
|
246
|
+
for (const stat of Object.values(this.stats)) {
|
|
247
|
+
fn(stat);
|
|
845
248
|
}
|
|
846
249
|
}
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
logicalRequestCount: activeRequests.length,
|
|
857
|
-
transportRequestCount: mergedRequests.length,
|
|
858
|
-
logicalBytes,
|
|
859
|
-
transportBytes,
|
|
860
|
-
overfetchBytes: Math.max(transportBytes - logicalBytes, 0)
|
|
250
|
+
getTable() {
|
|
251
|
+
const table = {};
|
|
252
|
+
this.forEach((stat) => {
|
|
253
|
+
table[stat.name] = {
|
|
254
|
+
time: stat.time || 0,
|
|
255
|
+
count: stat.count || 0,
|
|
256
|
+
average: stat.getAverageTime() || 0,
|
|
257
|
+
hz: stat.getHz() || 0
|
|
258
|
+
};
|
|
861
259
|
});
|
|
260
|
+
return table;
|
|
862
261
|
}
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
if ((event.type === "response" || event.type === "error") && event.networkTimeMs !== void 0) {
|
|
866
|
-
stats.get(RANGE_STATS_KEYS.networkTimeMs, "time").addTime(event.networkTimeMs);
|
|
867
|
-
}
|
|
868
|
-
switch (event.type) {
|
|
869
|
-
case "queued":
|
|
870
|
-
stats.get(RANGE_STATS_KEYS.logicalRanges, "count").incrementCount();
|
|
871
|
-
stats.get(RANGE_STATS_KEYS.requestedBytes, "count").addCount(event.logicalBytes || 0);
|
|
872
|
-
break;
|
|
873
|
-
case "batch":
|
|
874
|
-
stats.get(RANGE_STATS_KEYS.rangeBatches, "count").incrementCount();
|
|
875
|
-
stats.get("Logical Ranges Batched", "count").addCount(event.logicalRequestCount || 0);
|
|
876
|
-
stats.get(RANGE_STATS_KEYS.transportRanges, "count").addCount(event.transportRequestCount || 0);
|
|
877
|
-
stats.get(RANGE_STATS_KEYS.coalescedRanges, "count").addCount(
|
|
878
|
-
Math.max((event.logicalRequestCount || 0) - (event.transportRequestCount || 0), 0)
|
|
879
|
-
);
|
|
880
|
-
stats.get(RANGE_STATS_KEYS.transportBytes, "count").addCount(event.transportBytes || 0);
|
|
881
|
-
stats.get(RANGE_STATS_KEYS.overfetchBytes, "count").addCount(event.overfetchBytes || 0);
|
|
882
|
-
break;
|
|
883
|
-
case "response":
|
|
884
|
-
stats.get(RANGE_STATS_KEYS.completedTransportRanges, "count").incrementCount();
|
|
885
|
-
stats.get(RANGE_STATS_KEYS.responseBytes, "count").addCount(event.responseBytes || 0);
|
|
886
|
-
if (event.fullResponse) {
|
|
887
|
-
stats.get(RANGE_STATS_KEYS.fullResponseFallbacks, "count").incrementCount();
|
|
888
|
-
}
|
|
889
|
-
break;
|
|
890
|
-
case "error":
|
|
891
|
-
stats.get(RANGE_STATS_KEYS.failedTransportRanges, "count").incrementCount();
|
|
892
|
-
break;
|
|
893
|
-
case "abort":
|
|
894
|
-
stats.get(RANGE_STATS_KEYS.abortedLogicalRanges, "count").incrementCount();
|
|
895
|
-
break;
|
|
896
|
-
default:
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
function createRangeStats(id = "range-request-scheduler") {
|
|
900
|
-
const stats = new import_stats2.Stats({ id });
|
|
901
|
-
initializeStats(stats);
|
|
902
|
-
return stats;
|
|
903
|
-
}
|
|
904
|
-
async function fetchHttpRange(request) {
|
|
905
|
-
const abortContext = createAbortableFetchContext(request.signal);
|
|
906
|
-
const requestStartTime = getTimestamp();
|
|
907
|
-
try {
|
|
908
|
-
let fullResponse = false;
|
|
909
|
-
let response = await request.fetch(
|
|
910
|
-
request.url,
|
|
911
|
-
createRangeFetchOptions(
|
|
912
|
-
request.fetchOptions,
|
|
913
|
-
request.offset,
|
|
914
|
-
request.length,
|
|
915
|
-
abortContext.signal
|
|
916
|
-
)
|
|
917
|
-
);
|
|
918
|
-
if (response.status === 416 && request.offset === 0) {
|
|
919
|
-
const actualLength = parseUnsatisfiedContentRange(response.headers.get("Content-Range"));
|
|
920
|
-
if (!actualLength) {
|
|
921
|
-
throw new Error("Missing content-length on 416 response");
|
|
922
|
-
}
|
|
923
|
-
response = await request.fetch(
|
|
924
|
-
request.url,
|
|
925
|
-
createRangeFetchOptions(request.fetchOptions, 0, actualLength, abortContext.signal)
|
|
926
|
-
);
|
|
927
|
-
fullResponse = true;
|
|
928
|
-
}
|
|
929
|
-
if (response.status === 200) {
|
|
930
|
-
abortContext.abort();
|
|
931
|
-
await cancelIgnoredRangeResponse(response);
|
|
932
|
-
throw new Error("Byte-range request failed: server returned 200 instead of 206");
|
|
933
|
-
}
|
|
934
|
-
if (response.status !== 206 && !response.ok) {
|
|
935
|
-
throw new Error(`Bad response code: ${response.status}`);
|
|
936
|
-
}
|
|
937
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
938
|
-
const contentRangeHeader = response.headers.get("Content-Range");
|
|
939
|
-
const contentRange = parseSatisfiedContentRange(contentRangeHeader);
|
|
940
|
-
if (contentRangeHeader && !contentRange) {
|
|
941
|
-
throw new Error(`Invalid Content-Range header: ${contentRangeHeader}`);
|
|
942
|
-
}
|
|
943
|
-
if (contentRange) {
|
|
944
|
-
const responseLength = contentRange.endOffset - contentRange.offset + 1;
|
|
945
|
-
const requestedEndOffset = request.offset + request.length - 1;
|
|
946
|
-
if (contentRange.offset !== request.offset || contentRange.endOffset > requestedEndOffset || responseLength !== arrayBuffer.byteLength || contentRange.sourceByteLength !== void 0 && contentRange.endOffset >= contentRange.sourceByteLength) {
|
|
947
|
-
throw new Error(`Content-Range does not match requested range: ${contentRangeHeader}`);
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
return {
|
|
951
|
-
arrayBuffer,
|
|
952
|
-
status: response.status,
|
|
953
|
-
sourceByteLength: contentRange == null ? void 0 : contentRange.sourceByteLength,
|
|
954
|
-
transportBytes: arrayBuffer.byteLength,
|
|
955
|
-
networkTimeMs: getTimestamp() - requestStartTime,
|
|
956
|
-
fullResponse
|
|
957
|
-
};
|
|
958
|
-
} finally {
|
|
959
|
-
abortContext.removeAbortListener();
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
function canMergeRequests(mergedRequest, request, props) {
|
|
963
|
-
if (mergedRequest.sourceId !== request.sourceId) {
|
|
964
|
-
return false;
|
|
965
|
-
}
|
|
966
|
-
if (mergedRequest.isolationKey !== (request.isolationKey ?? request.sourceId)) {
|
|
967
|
-
return false;
|
|
968
|
-
}
|
|
969
|
-
const requestEndOffset = request.offset + request.length;
|
|
970
|
-
const gapBytes = request.offset - mergedRequest.endOffset;
|
|
971
|
-
const mergedBytes = Math.max(mergedRequest.endOffset, requestEndOffset) - mergedRequest.offset;
|
|
972
|
-
return gapBytes <= props.rangeExpansionBytes && mergedBytes <= props.maxMergedBytes;
|
|
973
|
-
}
|
|
974
|
-
function initializeStats(stats) {
|
|
975
|
-
stats.get(RANGE_STATS_KEYS.logicalRanges, "count");
|
|
976
|
-
stats.get(RANGE_STATS_KEYS.requestedBytes, "count");
|
|
977
|
-
stats.get(RANGE_STATS_KEYS.rangeBatches, "count");
|
|
978
|
-
stats.get("Logical Ranges Batched", "count");
|
|
979
|
-
stats.get(RANGE_STATS_KEYS.transportRanges, "count");
|
|
980
|
-
stats.get(RANGE_STATS_KEYS.coalescedRanges, "count");
|
|
981
|
-
stats.get(RANGE_STATS_KEYS.transportBytes, "count");
|
|
982
|
-
stats.get(RANGE_STATS_KEYS.completedTransportRanges, "count");
|
|
983
|
-
stats.get(RANGE_STATS_KEYS.responseBytes, "count");
|
|
984
|
-
stats.get(RANGE_STATS_KEYS.networkTimeMs, "time");
|
|
985
|
-
stats.get(RANGE_STATS_KEYS.overfetchBytes, "count");
|
|
986
|
-
stats.get(RANGE_STATS_KEYS.fullResponseFallbacks, "count");
|
|
987
|
-
stats.get(RANGE_STATS_KEYS.failedTransportRanges, "count");
|
|
988
|
-
stats.get(RANGE_STATS_KEYS.abortedLogicalRanges, "count");
|
|
989
|
-
}
|
|
990
|
-
function getLogicalRequestBytes(requests) {
|
|
991
|
-
return requests.reduce((sum, request) => sum + request.length, 0);
|
|
992
|
-
}
|
|
993
|
-
function normalizeTransportResult(result) {
|
|
994
|
-
return result instanceof ArrayBuffer ? { arrayBuffer: result } : result;
|
|
995
|
-
}
|
|
996
|
-
function createRangeFetchOptions(fetchOptions, offset, length, signal) {
|
|
997
|
-
return {
|
|
998
|
-
...fetchOptions,
|
|
999
|
-
signal,
|
|
1000
|
-
headers: {
|
|
1001
|
-
...getHeadersObject(fetchOptions == null ? void 0 : fetchOptions.headers),
|
|
1002
|
-
Range: `bytes=${offset}-${offset + length - 1}`
|
|
1003
|
-
}
|
|
1004
|
-
};
|
|
1005
|
-
}
|
|
1006
|
-
function getHeadersObject(headers) {
|
|
1007
|
-
if (!headers) {
|
|
1008
|
-
return {};
|
|
1009
|
-
}
|
|
1010
|
-
if (headers instanceof Headers) {
|
|
1011
|
-
return Object.fromEntries(headers.entries());
|
|
1012
|
-
}
|
|
1013
|
-
if (Array.isArray(headers)) {
|
|
1014
|
-
return Object.fromEntries(headers);
|
|
1015
|
-
}
|
|
1016
|
-
return headers;
|
|
1017
|
-
}
|
|
1018
|
-
function parseUnsatisfiedContentRange(contentRange) {
|
|
1019
|
-
const match = contentRange == null ? void 0 : contentRange.match(/^bytes \*\/(\d+)$/);
|
|
1020
|
-
return match ? Number(match[1]) : null;
|
|
1021
|
-
}
|
|
1022
|
-
function parseSatisfiedContentRange(contentRange) {
|
|
1023
|
-
const match = contentRange == null ? void 0 : contentRange.match(/^bytes (\d+)-(\d+)\/(\d+|\*)$/);
|
|
1024
|
-
if (!match) {
|
|
1025
|
-
return null;
|
|
262
|
+
_initializeStats(stats = []) {
|
|
263
|
+
stats.forEach((stat) => this._getOrCreate(stat));
|
|
1026
264
|
}
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
return { offset, endOffset, sourceByteLength };
|
|
1034
|
-
}
|
|
1035
|
-
function createAbortableFetchContext(parentSignal) {
|
|
1036
|
-
const abortController = new AbortController();
|
|
1037
|
-
const abortListener = () => abortController.abort(parentSignal == null ? void 0 : parentSignal.reason);
|
|
1038
|
-
if (parentSignal == null ? void 0 : parentSignal.aborted) {
|
|
1039
|
-
abortController.abort(parentSignal == null ? void 0 : parentSignal.reason);
|
|
1040
|
-
} else {
|
|
1041
|
-
parentSignal == null ? void 0 : parentSignal.addEventListener("abort", abortListener, { once: true });
|
|
1042
|
-
}
|
|
1043
|
-
return {
|
|
1044
|
-
signal: abortController.signal,
|
|
1045
|
-
abort: () => abortController.abort(),
|
|
1046
|
-
removeAbortListener: () => parentSignal == null ? void 0 : parentSignal.removeEventListener("abort", abortListener)
|
|
1047
|
-
};
|
|
1048
|
-
}
|
|
1049
|
-
async function cancelIgnoredRangeResponse(response) {
|
|
1050
|
-
var _a;
|
|
1051
|
-
await ((_a = response.body) == null ? void 0 : _a.cancel().catch(() => {
|
|
1052
|
-
}));
|
|
1053
|
-
}
|
|
1054
|
-
function getTimestamp() {
|
|
1055
|
-
var _a;
|
|
1056
|
-
return ((_a = globalThis.performance) == null ? void 0 : _a.now()) ?? Date.now();
|
|
1057
|
-
}
|
|
1058
|
-
function createAbortError2() {
|
|
1059
|
-
if (typeof DOMException !== "undefined") {
|
|
1060
|
-
return new DOMException("Request aborted", "AbortError");
|
|
1061
|
-
}
|
|
1062
|
-
const error = new Error("Request aborted");
|
|
1063
|
-
error.name = "AbortError";
|
|
1064
|
-
return error;
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
// ../loader-utils/src/lib/path-utils/path.ts
|
|
1068
|
-
var path_exports = {};
|
|
1069
|
-
__export(path_exports, {
|
|
1070
|
-
dirname: () => dirname,
|
|
1071
|
-
filename: () => filename,
|
|
1072
|
-
join: () => join,
|
|
1073
|
-
resolve: () => resolve
|
|
1074
|
-
});
|
|
1075
|
-
|
|
1076
|
-
// ../loader-utils/src/lib/path-utils/get-cwd.ts
|
|
1077
|
-
function getCWD() {
|
|
1078
|
-
var _a;
|
|
1079
|
-
if (typeof process !== "undefined" && typeof process.cwd !== "undefined") {
|
|
1080
|
-
return process.cwd();
|
|
1081
|
-
}
|
|
1082
|
-
const pathname = (_a = globalThis.location) == null ? void 0 : _a.pathname;
|
|
1083
|
-
return (pathname == null ? void 0 : pathname.slice(0, pathname.lastIndexOf("/") + 1)) || "";
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
// ../loader-utils/src/lib/path-utils/path.ts
|
|
1087
|
-
function filename(url) {
|
|
1088
|
-
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
1089
|
-
return slashIndex >= 0 ? url.substr(slashIndex + 1) : url;
|
|
1090
|
-
}
|
|
1091
|
-
function dirname(url) {
|
|
1092
|
-
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
1093
|
-
return slashIndex >= 0 ? url.substr(0, slashIndex) : "";
|
|
1094
|
-
}
|
|
1095
|
-
function join(...parts) {
|
|
1096
|
-
const separator = "/";
|
|
1097
|
-
parts = parts.map((part, index) => {
|
|
1098
|
-
if (index) {
|
|
1099
|
-
part = part.replace(new RegExp(`^${separator}`), "");
|
|
1100
|
-
}
|
|
1101
|
-
if (index !== parts.length - 1) {
|
|
1102
|
-
part = part.replace(new RegExp(`${separator}$`), "");
|
|
1103
|
-
}
|
|
1104
|
-
return part;
|
|
1105
|
-
});
|
|
1106
|
-
return parts.join(separator);
|
|
1107
|
-
}
|
|
1108
|
-
function resolve(...components) {
|
|
1109
|
-
const paths = [];
|
|
1110
|
-
for (let _i = 0; _i < components.length; _i++) {
|
|
1111
|
-
paths[_i] = components[_i];
|
|
1112
|
-
}
|
|
1113
|
-
let resolvedPath = "";
|
|
1114
|
-
let resolvedAbsolute = false;
|
|
1115
|
-
let cwd;
|
|
1116
|
-
for (let i = paths.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
1117
|
-
let path;
|
|
1118
|
-
if (i >= 0) {
|
|
1119
|
-
path = paths[i];
|
|
1120
|
-
} else {
|
|
1121
|
-
if (cwd === void 0) {
|
|
1122
|
-
cwd = getCWD();
|
|
1123
|
-
}
|
|
1124
|
-
path = cwd;
|
|
1125
|
-
}
|
|
1126
|
-
if (path.length === 0) {
|
|
1127
|
-
continue;
|
|
1128
|
-
}
|
|
1129
|
-
resolvedPath = `${path}/${resolvedPath}`;
|
|
1130
|
-
resolvedAbsolute = path.charCodeAt(0) === SLASH;
|
|
1131
|
-
}
|
|
1132
|
-
resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
|
|
1133
|
-
if (resolvedAbsolute) {
|
|
1134
|
-
return `/${resolvedPath}`;
|
|
1135
|
-
} else if (resolvedPath.length > 0) {
|
|
1136
|
-
return resolvedPath;
|
|
1137
|
-
}
|
|
1138
|
-
return ".";
|
|
1139
|
-
}
|
|
1140
|
-
var SLASH = 47;
|
|
1141
|
-
var DOT = 46;
|
|
1142
|
-
function normalizeStringPosix(path, allowAboveRoot) {
|
|
1143
|
-
let res = "";
|
|
1144
|
-
let lastSlash = -1;
|
|
1145
|
-
let dots = 0;
|
|
1146
|
-
let code;
|
|
1147
|
-
let isAboveRoot = false;
|
|
1148
|
-
for (let i = 0; i <= path.length; ++i) {
|
|
1149
|
-
if (i < path.length) {
|
|
1150
|
-
code = path.charCodeAt(i);
|
|
1151
|
-
} else if (code === SLASH) {
|
|
1152
|
-
break;
|
|
1153
|
-
} else {
|
|
1154
|
-
code = SLASH;
|
|
1155
|
-
}
|
|
1156
|
-
if (code === SLASH) {
|
|
1157
|
-
if (lastSlash === i - 1 || dots === 1) {
|
|
1158
|
-
} else if (lastSlash !== i - 1 && dots === 2) {
|
|
1159
|
-
if (res.length < 2 || !isAboveRoot || res.charCodeAt(res.length - 1) !== DOT || res.charCodeAt(res.length - 2) !== DOT) {
|
|
1160
|
-
if (res.length > 2) {
|
|
1161
|
-
const start = res.length - 1;
|
|
1162
|
-
let j = start;
|
|
1163
|
-
for (; j >= 0; --j) {
|
|
1164
|
-
if (res.charCodeAt(j) === SLASH) {
|
|
1165
|
-
break;
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
if (j !== start) {
|
|
1169
|
-
res = j === -1 ? "" : res.slice(0, j);
|
|
1170
|
-
lastSlash = i;
|
|
1171
|
-
dots = 0;
|
|
1172
|
-
isAboveRoot = false;
|
|
1173
|
-
continue;
|
|
1174
|
-
}
|
|
1175
|
-
} else if (res.length === 2 || res.length === 1) {
|
|
1176
|
-
res = "";
|
|
1177
|
-
lastSlash = i;
|
|
1178
|
-
dots = 0;
|
|
1179
|
-
isAboveRoot = false;
|
|
1180
|
-
continue;
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
if (allowAboveRoot) {
|
|
1184
|
-
if (res.length > 0) {
|
|
1185
|
-
res += "/..";
|
|
1186
|
-
} else {
|
|
1187
|
-
res = "..";
|
|
1188
|
-
}
|
|
1189
|
-
isAboveRoot = true;
|
|
1190
|
-
}
|
|
265
|
+
_getOrCreate(stat) {
|
|
266
|
+
const { name, type } = stat;
|
|
267
|
+
let result = this.stats[name];
|
|
268
|
+
if (!result) {
|
|
269
|
+
if (stat instanceof Stat) {
|
|
270
|
+
result = stat;
|
|
1191
271
|
} else {
|
|
1192
|
-
|
|
1193
|
-
if (res.length > 0) {
|
|
1194
|
-
res += `/${slice}`;
|
|
1195
|
-
} else {
|
|
1196
|
-
res = slice;
|
|
1197
|
-
}
|
|
1198
|
-
isAboveRoot = false;
|
|
1199
|
-
}
|
|
1200
|
-
lastSlash = i;
|
|
1201
|
-
dots = 0;
|
|
1202
|
-
} else if (code === DOT && dots !== -1) {
|
|
1203
|
-
++dots;
|
|
1204
|
-
} else {
|
|
1205
|
-
dots = -1;
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
return res;
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
// ../loader-utils/src/lib/files/blob-file.ts
|
|
1212
|
-
var BlobFile = class {
|
|
1213
|
-
handle;
|
|
1214
|
-
size;
|
|
1215
|
-
bigsize;
|
|
1216
|
-
url;
|
|
1217
|
-
constructor(blob) {
|
|
1218
|
-
this.handle = blob instanceof ArrayBuffer ? new Blob([blob]) : blob;
|
|
1219
|
-
this.size = blob instanceof ArrayBuffer ? blob.byteLength : blob.size;
|
|
1220
|
-
this.bigsize = BigInt(this.size);
|
|
1221
|
-
this.url = blob instanceof File ? blob.name : "";
|
|
1222
|
-
}
|
|
1223
|
-
async close() {
|
|
1224
|
-
}
|
|
1225
|
-
async stat() {
|
|
1226
|
-
return {
|
|
1227
|
-
size: this.handle.size,
|
|
1228
|
-
bigsize: BigInt(this.handle.size),
|
|
1229
|
-
isDirectory: false
|
|
1230
|
-
};
|
|
1231
|
-
}
|
|
1232
|
-
async read(start, length, signal) {
|
|
1233
|
-
if (signal == null ? void 0 : signal.aborted) {
|
|
1234
|
-
throw new Error("Request aborted");
|
|
1235
|
-
}
|
|
1236
|
-
const arrayBuffer = await this.handle.slice(Number(start), Number(start) + Number(length)).arrayBuffer();
|
|
1237
|
-
if (signal == null ? void 0 : signal.aborted) {
|
|
1238
|
-
throw new Error("Request aborted");
|
|
1239
|
-
}
|
|
1240
|
-
return arrayBuffer;
|
|
1241
|
-
}
|
|
1242
|
-
};
|
|
1243
|
-
|
|
1244
|
-
// ../loader-utils/src/lib/request-utils/abort-utils.ts
|
|
1245
|
-
function waitForPromiseWithSignal(promise, signal) {
|
|
1246
|
-
if (!signal) return promise;
|
|
1247
|
-
if (signal.aborted) {
|
|
1248
|
-
void promise.catch(() => {
|
|
1249
|
-
});
|
|
1250
|
-
return Promise.reject(signal.reason);
|
|
1251
|
-
}
|
|
1252
|
-
return new Promise((resolve2, reject) => {
|
|
1253
|
-
const abort = () => {
|
|
1254
|
-
signal.removeEventListener("abort", abort);
|
|
1255
|
-
reject(signal.reason);
|
|
1256
|
-
};
|
|
1257
|
-
signal.addEventListener("abort", abort, { once: true });
|
|
1258
|
-
void promise.then(
|
|
1259
|
-
(value) => {
|
|
1260
|
-
signal.removeEventListener("abort", abort);
|
|
1261
|
-
resolve2(value);
|
|
1262
|
-
},
|
|
1263
|
-
(error) => {
|
|
1264
|
-
signal.removeEventListener("abort", abort);
|
|
1265
|
-
reject(error);
|
|
1266
|
-
}
|
|
1267
|
-
);
|
|
1268
|
-
});
|
|
1269
|
-
}
|
|
1270
|
-
function waitForPromiseWithSignals(operation, signals) {
|
|
1271
|
-
const controller = new AbortController();
|
|
1272
|
-
const listeners = [];
|
|
1273
|
-
const cleanup = () => {
|
|
1274
|
-
for (const [signal, listener] of listeners) signal.removeEventListener("abort", listener);
|
|
1275
|
-
};
|
|
1276
|
-
for (const signal of signals) {
|
|
1277
|
-
if (!signal) continue;
|
|
1278
|
-
const listener = () => controller.abort(signal.reason);
|
|
1279
|
-
listeners.push([signal, listener]);
|
|
1280
|
-
signal.addEventListener("abort", listener, { once: true });
|
|
1281
|
-
if (signal.aborted) listener();
|
|
1282
|
-
}
|
|
1283
|
-
try {
|
|
1284
|
-
controller.signal.throwIfAborted();
|
|
1285
|
-
return waitForPromiseWithSignal(operation(controller.signal), controller.signal).catch((error) => {
|
|
1286
|
-
controller.abort(error);
|
|
1287
|
-
throw error;
|
|
1288
|
-
}).finally(cleanup);
|
|
1289
|
-
} catch (error) {
|
|
1290
|
-
controller.abort(error);
|
|
1291
|
-
cleanup();
|
|
1292
|
-
return Promise.reject(error);
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
// ../loader-utils/src/lib/files/http-file-transport.ts
|
|
1297
|
-
var HttpFileTransport = class {
|
|
1298
|
-
/** Remote object URL. */
|
|
1299
|
-
url;
|
|
1300
|
-
/** Fetch implementation used for range requests. */
|
|
1301
|
-
fetchFunction;
|
|
1302
|
-
/** Persistent fetch options copied from the caller. */
|
|
1303
|
-
fetchOptions;
|
|
1304
|
-
/** Validator enforcement mode. */
|
|
1305
|
-
consistency;
|
|
1306
|
-
/** Caller-supplied identity information. */
|
|
1307
|
-
identityHints;
|
|
1308
|
-
/** Failure objects already included in telemetry. */
|
|
1309
|
-
countedFailures = /* @__PURE__ */ new WeakSet();
|
|
1310
|
-
/** Mutable counters backing immutable telemetry snapshots. */
|
|
1311
|
-
telemetry = {
|
|
1312
|
-
requestedBytes: 0,
|
|
1313
|
-
downloadedBytes: 0,
|
|
1314
|
-
requestCount: 0,
|
|
1315
|
-
networkTimeMs: 0,
|
|
1316
|
-
abortCount: 0,
|
|
1317
|
-
errorCount: 0
|
|
1318
|
-
};
|
|
1319
|
-
/** Creates the transport for one remote object. */
|
|
1320
|
-
constructor(url, options) {
|
|
1321
|
-
validateKnownByteLength(options.byteLength);
|
|
1322
|
-
this.url = url;
|
|
1323
|
-
this.fetchFunction = options.fetch || ((input, init) => globalThis.fetch(input, init));
|
|
1324
|
-
this.fetchOptions = options.fetchOptions ? { ...options.fetchOptions, headers: new Headers(options.fetchOptions.headers) } : void 0;
|
|
1325
|
-
this.consistency = options.consistency || "best-effort";
|
|
1326
|
-
this.identityHints = {
|
|
1327
|
-
byteLength: options.byteLength,
|
|
1328
|
-
etag: normalizeHeaderValue(options.etag),
|
|
1329
|
-
lastModified: normalizeHeaderValue(options.lastModified)
|
|
1330
|
-
};
|
|
1331
|
-
}
|
|
1332
|
-
/** Returns an identity that is complete enough to avoid an opening request. */
|
|
1333
|
-
getInitialIdentity() {
|
|
1334
|
-
const { byteLength, etag, lastModified } = this.identityHints;
|
|
1335
|
-
if (byteLength !== void 0 && (etag !== void 0 || lastModified !== void 0)) {
|
|
1336
|
-
return createIdentity(byteLength, etag, lastModified);
|
|
1337
|
-
}
|
|
1338
|
-
if (byteLength === 0 && this.consistency === "best-effort") {
|
|
1339
|
-
return createIdentity(0);
|
|
1340
|
-
}
|
|
1341
|
-
return null;
|
|
1342
|
-
}
|
|
1343
|
-
/** Returns an immutable point-in-time copy of the transport counters. */
|
|
1344
|
-
getTelemetry() {
|
|
1345
|
-
return Object.freeze({ ...this.telemetry });
|
|
1346
|
-
}
|
|
1347
|
-
/** Counts each failure object once even when it passes through several async layers. */
|
|
1348
|
-
trackFailure(error) {
|
|
1349
|
-
if (typeof error === "object" && error !== null) {
|
|
1350
|
-
if (this.countedFailures.has(error)) {
|
|
1351
|
-
return;
|
|
1352
|
-
}
|
|
1353
|
-
this.countedFailures.add(error);
|
|
1354
|
-
}
|
|
1355
|
-
if (isAbortError(error)) {
|
|
1356
|
-
this.telemetry.abortCount++;
|
|
1357
|
-
} else {
|
|
1358
|
-
this.telemetry.errorCount++;
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
/** Performs and validates one exact HTTP range request. */
|
|
1362
|
-
async requestRange(offset, length, signal, expectedIdentity) {
|
|
1363
|
-
var _a;
|
|
1364
|
-
const requestStartTime = getTimestamp2();
|
|
1365
|
-
const abortContext = createCombinedAbortContext(signal, (_a = this.fetchOptions) == null ? void 0 : _a.signal);
|
|
1366
|
-
this.telemetry.requestCount++;
|
|
1367
|
-
this.telemetry.requestedBytes += length;
|
|
1368
|
-
try {
|
|
1369
|
-
const response = await this.fetchFunction(
|
|
1370
|
-
this.url,
|
|
1371
|
-
createFetchOptions(this.fetchOptions, offset, length, abortContext.signal)
|
|
1372
|
-
);
|
|
1373
|
-
if (isEmptyIdentityProbeResponse(response, offset, length, expectedIdentity)) {
|
|
1374
|
-
return await this.readEmptyIdentityProbe(response, requestStartTime);
|
|
1375
|
-
}
|
|
1376
|
-
if (response.status !== 206) {
|
|
1377
|
-
await cancelResponse(response);
|
|
1378
|
-
throw new Error(`HTTP byte-range request expected 206, received ${response.status}`);
|
|
1379
|
-
}
|
|
1380
|
-
const contentRange = await readContentRange(response);
|
|
1381
|
-
const responseIdentity = getResponseIdentity(response, contentRange.byteLength);
|
|
1382
|
-
const responseError = getIdentityError(
|
|
1383
|
-
expectedIdentity,
|
|
1384
|
-
responseIdentity,
|
|
1385
|
-
this.identityHints,
|
|
1386
|
-
this.consistency
|
|
1387
|
-
) || getRangeError(contentRange, offset, length);
|
|
1388
|
-
if (responseError) {
|
|
1389
|
-
await cancelResponse(response);
|
|
1390
|
-
throw new Error(responseError);
|
|
1391
|
-
}
|
|
1392
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
1393
|
-
this.telemetry.downloadedBytes += arrayBuffer.byteLength;
|
|
1394
|
-
if (arrayBuffer.byteLength !== length) {
|
|
1395
|
-
throw new Error(
|
|
1396
|
-
`HTTP byte-range response contained ${arrayBuffer.byteLength} bytes; expected ${length}`
|
|
1397
|
-
);
|
|
1398
|
-
}
|
|
1399
|
-
return {
|
|
1400
|
-
arrayBuffer,
|
|
1401
|
-
identity: resolveIdentity(expectedIdentity, responseIdentity, this.identityHints),
|
|
1402
|
-
status: response.status,
|
|
1403
|
-
transportBytes: arrayBuffer.byteLength,
|
|
1404
|
-
networkTimeMs: getTimestamp2() - requestStartTime
|
|
1405
|
-
};
|
|
1406
|
-
} catch (error) {
|
|
1407
|
-
if (expectedIdentity === null || !isAbortError(error)) {
|
|
1408
|
-
this.trackFailure(error);
|
|
272
|
+
result = new Stat(name, type);
|
|
1409
273
|
}
|
|
1410
|
-
|
|
1411
|
-
} finally {
|
|
1412
|
-
abortContext.removeAbortListeners();
|
|
1413
|
-
this.telemetry.networkTimeMs += getTimestamp2() - requestStartTime;
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1416
|
-
/** Validates and consumes the special empty-object identity response. */
|
|
1417
|
-
async readEmptyIdentityProbe(response, requestStartTime) {
|
|
1418
|
-
const responseIdentity = getResponseIdentity(response, 0);
|
|
1419
|
-
const identityError = getIdentityError(
|
|
1420
|
-
null,
|
|
1421
|
-
responseIdentity,
|
|
1422
|
-
this.identityHints,
|
|
1423
|
-
this.consistency
|
|
1424
|
-
);
|
|
1425
|
-
await cancelResponse(response);
|
|
1426
|
-
if (identityError) {
|
|
1427
|
-
throw new Error(identityError);
|
|
274
|
+
this.stats[name] = result;
|
|
1428
275
|
}
|
|
1429
|
-
return
|
|
1430
|
-
arrayBuffer: new ArrayBuffer(0),
|
|
1431
|
-
identity: resolveIdentity(null, responseIdentity, this.identityHints),
|
|
1432
|
-
status: response.status,
|
|
1433
|
-
transportBytes: 0,
|
|
1434
|
-
networkTimeMs: getTimestamp2() - requestStartTime
|
|
1435
|
-
};
|
|
276
|
+
return result;
|
|
1436
277
|
}
|
|
1437
278
|
};
|
|
1438
|
-
function createFetchOptions(fetchOptions, offset, length, signal) {
|
|
1439
|
-
const headers = new Headers(fetchOptions == null ? void 0 : fetchOptions.headers);
|
|
1440
|
-
headers.set("Range", `bytes=${offset}-${offset + length - 1}`);
|
|
1441
|
-
return {
|
|
1442
|
-
...fetchOptions,
|
|
1443
|
-
method: "GET",
|
|
1444
|
-
body: void 0,
|
|
1445
|
-
headers,
|
|
1446
|
-
signal
|
|
1447
|
-
};
|
|
1448
|
-
}
|
|
1449
|
-
function isEmptyIdentityProbeResponse(response, offset, length, expectedIdentity) {
|
|
1450
|
-
return response.status === 416 && expectedIdentity === null && offset === 0 && length === 1 && /^bytes \*\/0$/i.test(response.headers.get("Content-Range") || "");
|
|
1451
|
-
}
|
|
1452
|
-
async function readContentRange(response) {
|
|
1453
|
-
try {
|
|
1454
|
-
return parseContentRange(response.headers.get("Content-Range"));
|
|
1455
|
-
} catch (error) {
|
|
1456
|
-
await cancelResponse(response);
|
|
1457
|
-
throw error;
|
|
1458
|
-
}
|
|
1459
|
-
}
|
|
1460
|
-
function parseContentRange(contentRange) {
|
|
1461
|
-
const match = contentRange == null ? void 0 : contentRange.match(/^bytes (\d+)-(\d+)\/(\d+)$/);
|
|
1462
|
-
if (!match) {
|
|
1463
|
-
throw new Error("HTTP byte-range response has an invalid Content-Range header");
|
|
1464
|
-
}
|
|
1465
|
-
return {
|
|
1466
|
-
offset: Number(match[1]),
|
|
1467
|
-
endOffset: Number(match[2]),
|
|
1468
|
-
byteLength: Number(match[3])
|
|
1469
|
-
};
|
|
1470
|
-
}
|
|
1471
|
-
function getResponseIdentity(response, byteLength) {
|
|
1472
|
-
return createIdentity(
|
|
1473
|
-
byteLength,
|
|
1474
|
-
normalizeHeaderValue(response.headers.get("ETag")),
|
|
1475
|
-
normalizeHeaderValue(response.headers.get("Last-Modified"))
|
|
1476
|
-
);
|
|
1477
|
-
}
|
|
1478
|
-
function resolveIdentity(expectedIdentity, responseIdentity, identityHints) {
|
|
1479
|
-
return expectedIdentity || createIdentity(
|
|
1480
|
-
responseIdentity.byteLength,
|
|
1481
|
-
responseIdentity.etag ?? identityHints.etag,
|
|
1482
|
-
responseIdentity.lastModified ?? identityHints.lastModified
|
|
1483
|
-
);
|
|
1484
|
-
}
|
|
1485
|
-
function getRangeError(contentRange, offset, length) {
|
|
1486
|
-
if (!Number.isSafeInteger(contentRange.offset) || !Number.isSafeInteger(contentRange.endOffset) || !Number.isSafeInteger(contentRange.byteLength) || contentRange.offset < 0 || contentRange.endOffset < contentRange.offset || contentRange.endOffset >= contentRange.byteLength) {
|
|
1487
|
-
return "HTTP byte-range response has invalid range bounds";
|
|
1488
|
-
}
|
|
1489
|
-
if (contentRange.offset !== offset || contentRange.endOffset !== offset + length - 1) {
|
|
1490
|
-
return "HTTP byte-range response does not match the requested range";
|
|
1491
|
-
}
|
|
1492
|
-
return null;
|
|
1493
|
-
}
|
|
1494
|
-
function getIdentityError(expectedIdentity, responseIdentity, identityHints, consistency) {
|
|
1495
|
-
const expectedByteLength = (expectedIdentity == null ? void 0 : expectedIdentity.byteLength) ?? identityHints.byteLength;
|
|
1496
|
-
if (expectedByteLength !== void 0 && responseIdentity.byteLength !== expectedByteLength) {
|
|
1497
|
-
return "HTTP file length changed while the file was open";
|
|
1498
|
-
}
|
|
1499
|
-
const expectedEtag = (expectedIdentity == null ? void 0 : expectedIdentity.etag) ?? identityHints.etag;
|
|
1500
|
-
const expectedLastModified = (expectedIdentity == null ? void 0 : expectedIdentity.lastModified) ?? identityHints.lastModified;
|
|
1501
|
-
if (expectedEtag) {
|
|
1502
|
-
if (responseIdentity.etag) {
|
|
1503
|
-
return expectedEtag === responseIdentity.etag ? null : "HTTP file ETag changed while the file was open";
|
|
1504
|
-
}
|
|
1505
|
-
if (consistency === "strict") {
|
|
1506
|
-
return "HTTP byte-range response is missing the pinned ETag";
|
|
1507
|
-
}
|
|
1508
|
-
if (expectedLastModified && responseIdentity.lastModified && expectedLastModified !== responseIdentity.lastModified) {
|
|
1509
|
-
return "HTTP file Last-Modified value changed while the file was open";
|
|
1510
|
-
}
|
|
1511
|
-
return null;
|
|
1512
|
-
}
|
|
1513
|
-
if (expectedLastModified) {
|
|
1514
|
-
if (responseIdentity.lastModified && expectedLastModified !== responseIdentity.lastModified) {
|
|
1515
|
-
return "HTTP file Last-Modified value changed while the file was open";
|
|
1516
|
-
}
|
|
1517
|
-
if (consistency === "strict" && !responseIdentity.lastModified) {
|
|
1518
|
-
return "HTTP byte-range response is missing the pinned Last-Modified value";
|
|
1519
|
-
}
|
|
1520
|
-
return null;
|
|
1521
|
-
}
|
|
1522
|
-
if (consistency === "strict" && !responseIdentity.etag && !responseIdentity.lastModified) {
|
|
1523
|
-
return "HTTP byte-range response does not provide an ETag or Last-Modified validator";
|
|
1524
|
-
}
|
|
1525
|
-
return null;
|
|
1526
|
-
}
|
|
1527
|
-
function createIdentity(byteLength, etag, lastModified) {
|
|
1528
|
-
return Object.freeze({ byteLength, etag, lastModified });
|
|
1529
|
-
}
|
|
1530
|
-
function validateKnownByteLength(byteLength) {
|
|
1531
|
-
if (byteLength !== void 0 && (!Number.isSafeInteger(byteLength) || byteLength < 0)) {
|
|
1532
|
-
throw new Error("HttpFile byteLength must be a non-negative safe integer");
|
|
1533
|
-
}
|
|
1534
|
-
}
|
|
1535
|
-
async function cancelResponse(response) {
|
|
1536
|
-
var _a;
|
|
1537
|
-
await ((_a = response.body) == null ? void 0 : _a.cancel().catch(() => {
|
|
1538
|
-
}));
|
|
1539
|
-
}
|
|
1540
|
-
function normalizeHeaderValue(value) {
|
|
1541
|
-
return value || void 0;
|
|
1542
|
-
}
|
|
1543
|
-
function getTimestamp2() {
|
|
1544
|
-
var _a;
|
|
1545
|
-
return ((_a = globalThis.performance) == null ? void 0 : _a.now()) ?? Date.now();
|
|
1546
|
-
}
|
|
1547
|
-
function isAbortError(error) {
|
|
1548
|
-
return error instanceof Error && error.name === "AbortError" || error instanceof Error && /aborted/i.test(error.message);
|
|
1549
|
-
}
|
|
1550
|
-
function createCombinedAbortContext(...signals) {
|
|
1551
|
-
const abortController = new AbortController();
|
|
1552
|
-
const uniqueSignals = [
|
|
1553
|
-
...new Set(signals.filter((signal) => Boolean(signal)))
|
|
1554
|
-
];
|
|
1555
|
-
const abortListener = () => abortController.abort();
|
|
1556
|
-
for (const signal of uniqueSignals) {
|
|
1557
|
-
if (signal.aborted) {
|
|
1558
|
-
abortController.abort();
|
|
1559
|
-
} else {
|
|
1560
|
-
signal.addEventListener("abort", abortListener, { once: true });
|
|
1561
|
-
}
|
|
1562
|
-
}
|
|
1563
|
-
return {
|
|
1564
|
-
signal: abortController.signal,
|
|
1565
|
-
removeAbortListeners: () => {
|
|
1566
|
-
for (const signal of uniqueSignals) {
|
|
1567
|
-
signal.removeEventListener("abort", abortListener);
|
|
1568
|
-
}
|
|
1569
|
-
}
|
|
1570
|
-
};
|
|
1571
|
-
}
|
|
1572
279
|
|
|
1573
|
-
//
|
|
1574
|
-
var
|
|
1575
|
-
/** URL used as the ReadableFile handle. */
|
|
1576
|
-
handle;
|
|
1577
|
-
/** Remote object URL. */
|
|
1578
|
-
url;
|
|
1579
|
-
/** HTTP transport and response validator for this file. */
|
|
1580
|
-
transport;
|
|
1581
|
-
/** Scheduler used to coalesce compatible range reads. */
|
|
1582
|
-
rangeScheduler;
|
|
1583
|
-
/** Unique key that prevents coalescing across transport or credential contexts. */
|
|
1584
|
-
schedulerIsolationKey = {};
|
|
1585
|
-
/** Caller-supplied length available before identity discovery. */
|
|
1586
|
-
suppliedByteLength;
|
|
1587
|
-
/** Pinned remote object identity. */
|
|
1588
|
-
identity;
|
|
1589
|
-
/** Shared opening probe, while identity discovery is in progress. */
|
|
1590
|
-
openPromise = null;
|
|
1591
|
-
/** Whether the file has stopped accepting operations. */
|
|
1592
|
-
closed = false;
|
|
1593
|
-
/** Creates a lazy HTTP file. Use {@link HttpFile.open} when identity must be pinned immediately. */
|
|
1594
|
-
constructor(url, options = {}) {
|
|
1595
|
-
this.handle = url;
|
|
1596
|
-
this.url = url;
|
|
1597
|
-
this.transport = new HttpFileTransport(url, options);
|
|
1598
|
-
this.rangeScheduler = options.rangeScheduler || new RangeRequestScheduler({ batchDelayMs: 0, ...options.rangeSchedulerProps });
|
|
1599
|
-
this.suppliedByteLength = options.byteLength;
|
|
1600
|
-
this.identity = this.transport.getInitialIdentity();
|
|
1601
|
-
}
|
|
1602
|
-
/** Opens a file and pins its byte length and available validators. */
|
|
1603
|
-
static async open(url, options = {}, signal) {
|
|
1604
|
-
const file = new _HttpFile(url, options);
|
|
1605
|
-
await file.open(signal);
|
|
1606
|
-
return file;
|
|
1607
|
-
}
|
|
1608
|
-
/** Pins this file's byte length and available validators. */
|
|
1609
|
-
async open(signal) {
|
|
1610
|
-
this.assertOpen();
|
|
1611
|
-
if (signal == null ? void 0 : signal.aborted) {
|
|
1612
|
-
const error = createAbortError3();
|
|
1613
|
-
this.transport.trackFailure(error);
|
|
1614
|
-
throw error;
|
|
1615
|
-
}
|
|
1616
|
-
await this.getIdentity(signal);
|
|
1617
|
-
return this;
|
|
1618
|
-
}
|
|
1619
|
-
/** Pinned file length, or zero before a lazy file has opened. */
|
|
1620
|
-
get size() {
|
|
1621
|
-
var _a;
|
|
1622
|
-
return ((_a = this.identity) == null ? void 0 : _a.byteLength) ?? this.suppliedByteLength ?? 0;
|
|
1623
|
-
}
|
|
1624
|
-
/** Pinned file length as a bigint, or zero before a lazy file has opened. */
|
|
1625
|
-
get bigsize() {
|
|
1626
|
-
return BigInt(this.size);
|
|
1627
|
-
}
|
|
1628
|
-
/** Returns the pinned identity, or null before a lazy file has opened. */
|
|
1629
|
-
getIdentitySnapshot() {
|
|
1630
|
-
return this.identity;
|
|
1631
|
-
}
|
|
1632
|
-
/** Returns an immutable point-in-time copy of this file's transport counters. */
|
|
1633
|
-
getTelemetry() {
|
|
1634
|
-
return this.transport.getTelemetry();
|
|
1635
|
-
}
|
|
1636
|
-
/** Prevents new operations. Active fetches remain controlled by their read signals. */
|
|
1637
|
-
async close() {
|
|
1638
|
-
this.closed = true;
|
|
1639
|
-
}
|
|
1640
|
-
/** Returns pinned file information without issuing a HEAD request. */
|
|
1641
|
-
async stat() {
|
|
1642
|
-
this.assertOpen();
|
|
1643
|
-
const identity = await this.getIdentity();
|
|
1644
|
-
return {
|
|
1645
|
-
size: identity.byteLength,
|
|
1646
|
-
bigsize: BigInt(identity.byteLength),
|
|
1647
|
-
isDirectory: false
|
|
1648
|
-
};
|
|
1649
|
-
}
|
|
1650
|
-
/** Reads exactly one byte range, with optional cancellation. */
|
|
1651
|
-
async read(offset = 0, length = 0, signal) {
|
|
1652
|
-
this.assertOpen();
|
|
1653
|
-
if (signal == null ? void 0 : signal.aborted) {
|
|
1654
|
-
const error = createAbortError3();
|
|
1655
|
-
this.transport.trackFailure(error);
|
|
1656
|
-
throw error;
|
|
1657
|
-
}
|
|
1658
|
-
const identity = await this.getIdentity(signal);
|
|
1659
|
-
const numericOffset = normalizeOffset(offset);
|
|
1660
|
-
validateRange(numericOffset, length, identity.byteLength);
|
|
1661
|
-
if (length === 0) {
|
|
1662
|
-
return new ArrayBuffer(0);
|
|
1663
|
-
}
|
|
1664
|
-
try {
|
|
1665
|
-
return await this.rangeScheduler.scheduleRequest({
|
|
1666
|
-
sourceId: this.url,
|
|
1667
|
-
isolationKey: this.schedulerIsolationKey,
|
|
1668
|
-
offset: numericOffset,
|
|
1669
|
-
length,
|
|
1670
|
-
signal,
|
|
1671
|
-
fetchRange: this.fetchScheduledRange
|
|
1672
|
-
});
|
|
1673
|
-
} catch (error) {
|
|
1674
|
-
this.transport.trackFailure(error);
|
|
1675
|
-
throw error;
|
|
1676
|
-
}
|
|
1677
|
-
}
|
|
1678
|
-
/** Reads a range and returns a Response for legacy ReadableFile consumers. */
|
|
1679
|
-
async fetchRange(offset, length, signal) {
|
|
1680
|
-
const numericOffset = normalizeOffset(offset);
|
|
1681
|
-
const arrayBuffer = await this.read(numericOffset, length, signal);
|
|
1682
|
-
const headers = createIdentityHeaders(this.identity, numericOffset, length);
|
|
1683
|
-
return new Response(arrayBuffer, { status: 206, headers });
|
|
1684
|
-
}
|
|
1685
|
-
/** Stable scheduler callback used by every read from this file. */
|
|
1686
|
-
fetchScheduledRange = async (offset, length, signal) => {
|
|
1687
|
-
const identity = await this.getIdentity(signal);
|
|
1688
|
-
const result = await this.transport.requestRange(offset, length, signal, identity);
|
|
1689
|
-
return {
|
|
1690
|
-
arrayBuffer: result.arrayBuffer,
|
|
1691
|
-
status: result.status,
|
|
1692
|
-
transportBytes: result.transportBytes,
|
|
1693
|
-
networkTimeMs: result.networkTimeMs
|
|
1694
|
-
};
|
|
1695
|
-
};
|
|
1696
|
-
/** Returns the shared lazy identity promise, retrying after a failed probe. */
|
|
1697
|
-
getIdentity(signal) {
|
|
1698
|
-
if (this.identity) {
|
|
1699
|
-
return Promise.resolve(this.identity);
|
|
1700
|
-
}
|
|
1701
|
-
if (!this.openPromise) {
|
|
1702
|
-
const nextOpenPromise = this.probeIdentity();
|
|
1703
|
-
const cachedOpenPromise = nextOpenPromise.catch((error) => {
|
|
1704
|
-
if (this.openPromise === cachedOpenPromise) {
|
|
1705
|
-
this.openPromise = null;
|
|
1706
|
-
}
|
|
1707
|
-
throw error;
|
|
1708
|
-
});
|
|
1709
|
-
this.openPromise = cachedOpenPromise;
|
|
1710
|
-
}
|
|
1711
|
-
return waitForPromiseWithSignal(this.openPromise, signal).catch((error) => {
|
|
1712
|
-
this.transport.trackFailure(error);
|
|
1713
|
-
throw error;
|
|
1714
|
-
});
|
|
1715
|
-
}
|
|
1716
|
-
/** Uses a one-byte GET range to discover object length and validators. */
|
|
1717
|
-
async probeIdentity() {
|
|
1718
|
-
try {
|
|
1719
|
-
const result = await this.transport.requestRange(0, 1, void 0, null);
|
|
1720
|
-
this.identity = result.identity;
|
|
1721
|
-
return result.identity;
|
|
1722
|
-
} catch (error) {
|
|
1723
|
-
this.transport.trackFailure(error);
|
|
1724
|
-
throw error;
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
/** Throws when the file has been closed. */
|
|
1728
|
-
assertOpen() {
|
|
1729
|
-
if (this.closed) {
|
|
1730
|
-
throw new Error("HttpFile is closed");
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
};
|
|
1734
|
-
function createIdentityHeaders(identity, offset, length) {
|
|
1735
|
-
const headers = new Headers();
|
|
1736
|
-
if (length > 0 && identity) {
|
|
1737
|
-
headers.set("Content-Range", `bytes ${offset}-${offset + length - 1}/${identity.byteLength}`);
|
|
1738
|
-
}
|
|
1739
|
-
if (identity == null ? void 0 : identity.etag) {
|
|
1740
|
-
headers.set("ETag", identity.etag);
|
|
1741
|
-
}
|
|
1742
|
-
if (identity == null ? void 0 : identity.lastModified) {
|
|
1743
|
-
headers.set("Last-Modified", identity.lastModified);
|
|
1744
|
-
}
|
|
1745
|
-
return headers;
|
|
1746
|
-
}
|
|
1747
|
-
function normalizeOffset(offset) {
|
|
1748
|
-
const numericOffset = Number(offset);
|
|
1749
|
-
if (!Number.isSafeInteger(numericOffset) || numericOffset < 0) {
|
|
1750
|
-
throw new Error("HTTP byte-range offset must be a non-negative safe integer");
|
|
1751
|
-
}
|
|
1752
|
-
return numericOffset;
|
|
1753
|
-
}
|
|
1754
|
-
function validateRange(offset, length, byteLength) {
|
|
1755
|
-
if (!Number.isSafeInteger(length) || length < 0) {
|
|
1756
|
-
throw new Error("HTTP byte-range length must be a non-negative safe integer");
|
|
1757
|
-
}
|
|
1758
|
-
if (offset + length > byteLength) {
|
|
1759
|
-
throw new Error("HTTP byte range extends beyond the end of the file");
|
|
1760
|
-
}
|
|
1761
|
-
}
|
|
1762
|
-
function createAbortError3() {
|
|
1763
|
-
if (typeof DOMException !== "undefined") {
|
|
1764
|
-
return new DOMException("Request aborted", "AbortError");
|
|
1765
|
-
}
|
|
1766
|
-
const error = new Error("Request aborted");
|
|
1767
|
-
error.name = "AbortError";
|
|
1768
|
-
return error;
|
|
1769
|
-
}
|
|
280
|
+
// dist/tileset-3d/common/tileset-3d.js
|
|
281
|
+
var import_loader_utils2 = require("@loaders.gl/loader-utils");
|
|
1770
282
|
|
|
1771
283
|
// dist/utils/doubly-linked-list-node.js
|
|
1772
284
|
var DoublyLinkedListNode = class {
|
|
@@ -1924,9 +436,10 @@ var TilesetCache = class {
|
|
|
1924
436
|
// dist/tileset-3d/helpers/transform-utils.js
|
|
1925
437
|
var import_geospatial = require("@math.gl/geospatial");
|
|
1926
438
|
var import_core = require("@math.gl/core");
|
|
439
|
+
var import_loader_utils = require("@loaders.gl/loader-utils");
|
|
1927
440
|
function calculateTransformProps(tileHeader, tile) {
|
|
1928
|
-
assert(tileHeader);
|
|
1929
|
-
assert(tile);
|
|
441
|
+
(0, import_loader_utils.assert)(tileHeader);
|
|
442
|
+
(0, import_loader_utils.assert)(tile);
|
|
1930
443
|
const { rtcCenter, gltfUpAxis } = tile;
|
|
1931
444
|
const { computedTransform, boundingVolume: { center } } = tileHeader;
|
|
1932
445
|
let modelMatrix = new import_core.Matrix4(computedTransform);
|
|
@@ -1970,15 +483,14 @@ function calculateTransformProps(tileHeader, tile) {
|
|
|
1970
483
|
}
|
|
1971
484
|
var TRANSLATION_LIMIT_SQUARED = 1e6 ** 2;
|
|
1972
485
|
function _getRootNode(tile) {
|
|
1973
|
-
var _a, _b;
|
|
1974
486
|
const gltf = tile.gltf;
|
|
1975
487
|
if (!gltf) {
|
|
1976
488
|
return null;
|
|
1977
489
|
}
|
|
1978
490
|
const sceneIndex = typeof gltf.scene === "number" ? gltf.scene : 0;
|
|
1979
|
-
const scene =
|
|
1980
|
-
const rootNode =
|
|
1981
|
-
if (!
|
|
491
|
+
const scene = gltf.scenes?.[sceneIndex];
|
|
492
|
+
const rootNode = scene?.nodes?.[0];
|
|
493
|
+
if (!rootNode?.matrix)
|
|
1982
494
|
return null;
|
|
1983
495
|
const m = rootNode.matrix;
|
|
1984
496
|
const translationMagnitude = m[12] * m[12] + m[13] * m[13] + m[14] * m[14];
|
|
@@ -2067,7 +579,7 @@ function updateCameraMotionState(previousState, position, direction, currentTime
|
|
|
2067
579
|
const directionArray = Array.from(direction);
|
|
2068
580
|
const positionChanged = previousState ? positionArray.length !== previousState.position.length || positionArray.some((value, index) => Math.abs(value - previousState.position[index]) > CAMERA_POSITION_EPSILON) : false;
|
|
2069
581
|
const directionChanged = previousState ? directionArray.length !== previousState.direction.length || directionArray.some((value, index) => Math.abs(value - previousState.direction[index]) > CAMERA_DIRECTION_EPSILON) : false;
|
|
2070
|
-
const lastMovementTime = positionChanged || directionChanged ? currentTime :
|
|
582
|
+
const lastMovementTime = positionChanged || directionChanged ? currentTime : previousState?.lastMovementTime ?? Number.NEGATIVE_INFINITY;
|
|
2071
583
|
return {
|
|
2072
584
|
state: {
|
|
2073
585
|
position: positionArray,
|
|
@@ -2198,7 +710,7 @@ function getTiles3DScreenSpaceError(tile, frameState, useParentLodMetric, viewpo
|
|
|
2198
710
|
}
|
|
2199
711
|
function getOrthographicScreenSpaceError(lodMetricValue, frameState, lodScale, viewportHeightFraction) {
|
|
2200
712
|
const viewport = frameState.viewport;
|
|
2201
|
-
if (!
|
|
713
|
+
if (!viewport?.orthographic) {
|
|
2202
714
|
return null;
|
|
2203
715
|
}
|
|
2204
716
|
const metersPerPixel = viewport.metersPerPixel;
|
|
@@ -2208,8 +720,7 @@ function getOrthographicScreenSpaceError(lodMetricValue, frameState, lodScale, v
|
|
|
2208
720
|
return lodMetricValue * lodScale * viewportHeightFraction / metersPerPixel;
|
|
2209
721
|
}
|
|
2210
722
|
function getContentBoundingVolumeHeader(root) {
|
|
2211
|
-
|
|
2212
|
-
return ((_a = root.header.content) == null ? void 0 : _a.boundingVolume) || root.header.boundingVolume;
|
|
723
|
+
return root.header.content?.boundingVolume || root.header.boundingVolume;
|
|
2213
724
|
}
|
|
2214
725
|
function getRegionHeightRange(region, frameState) {
|
|
2215
726
|
const upDirection = scratchPositionNormal.copy(frameState.camera.position).normalize();
|
|
@@ -2411,7 +922,6 @@ function normalizeCrsIdentifier(identifier) {
|
|
|
2411
922
|
|
|
2412
923
|
// dist/spatial/get-spatial-coordinate-frame.js
|
|
2413
924
|
function getSpatialCoordinateFrame(definition) {
|
|
2414
|
-
var _a, _b;
|
|
2415
925
|
if (typeof definition === "string") {
|
|
2416
926
|
const representation = (0, import_crs.inferCRSRepresentation)(definition);
|
|
2417
927
|
if (representation === "wkt") {
|
|
@@ -2426,7 +936,7 @@ function getSpatialCoordinateFrame(definition) {
|
|
|
2426
936
|
if (projJsonDefinition.type === "BoundCRS" && projJsonDefinition.source_crs) {
|
|
2427
937
|
return getSpatialCoordinateFrame(projJsonDefinition.source_crs);
|
|
2428
938
|
}
|
|
2429
|
-
if (projJsonDefinition.type === "CompoundCRS" &&
|
|
939
|
+
if (projJsonDefinition.type === "CompoundCRS" && projJsonDefinition.components?.[0]) {
|
|
2430
940
|
return getSpatialCoordinateFrame(projJsonDefinition.components[0]);
|
|
2431
941
|
}
|
|
2432
942
|
if (String(projJsonDefinition.type).includes("Projected")) {
|
|
@@ -2436,7 +946,7 @@ function getSpatialCoordinateFrame(definition) {
|
|
|
2436
946
|
return "geographic";
|
|
2437
947
|
}
|
|
2438
948
|
if (String(projJsonDefinition.type).includes("Geodetic")) {
|
|
2439
|
-
return
|
|
949
|
+
return projJsonDefinition.coordinate_system?.subtype === "Cartesian" ? "geocentric" : "geographic";
|
|
2440
950
|
}
|
|
2441
951
|
return "unknown";
|
|
2442
952
|
}
|
|
@@ -2490,8 +1000,8 @@ function getWktCoordinateFrame(definition) {
|
|
|
2490
1000
|
case "GEODCRS":
|
|
2491
1001
|
case "GEODETICCRS": {
|
|
2492
1002
|
const coordinateSystem = root.values.find((value) => value.type === "node" && value.keyword.toUpperCase() === "CS");
|
|
2493
|
-
const subtype = coordinateSystem
|
|
2494
|
-
if (
|
|
1003
|
+
const subtype = coordinateSystem?.values[0];
|
|
1004
|
+
if (subtype?.type !== "enumeration" && subtype?.type !== "string") {
|
|
2495
1005
|
return "unknown";
|
|
2496
1006
|
}
|
|
2497
1007
|
return subtype.value.toUpperCase() === "CARTESIAN" ? "geocentric" : subtype.value.toUpperCase() === "ELLIPSOIDAL" ? "geographic" : "unknown";
|
|
@@ -2501,10 +1011,9 @@ function getWktCoordinateFrame(definition) {
|
|
|
2501
1011
|
}
|
|
2502
1012
|
}
|
|
2503
1013
|
function getProjStringCoordinateFrame(definition) {
|
|
2504
|
-
var _a;
|
|
2505
1014
|
try {
|
|
2506
|
-
const projection = (
|
|
2507
|
-
switch (projection
|
|
1015
|
+
const projection = (0, import_crs.parsePROJString)(definition).parameters.find((parameter) => parameter.name.toLowerCase() === "proj")?.value;
|
|
1016
|
+
switch (projection?.toLowerCase()) {
|
|
2508
1017
|
case "longlat":
|
|
2509
1018
|
case "latlong":
|
|
2510
1019
|
return "geographic";
|
|
@@ -2588,23 +1097,23 @@ function createTilesetSpatialReference(discovered, options = {}) {
|
|
|
2588
1097
|
}
|
|
2589
1098
|
function applyTilesetSpatialOptions(discovered, options = {}) {
|
|
2590
1099
|
return createTilesetSpatialReference({
|
|
2591
|
-
sourceCrs: discovered
|
|
2592
|
-
sourceCrsState: discovered
|
|
2593
|
-
sourceCrsRepresentation:
|
|
2594
|
-
sourceCrsAlternatives:
|
|
2595
|
-
verticalCrs: discovered
|
|
2596
|
-
units: discovered
|
|
2597
|
-
verticalUnitScale: discovered
|
|
2598
|
-
coordinateEpoch: discovered
|
|
2599
|
-
heightReference: discovered
|
|
2600
|
-
elevationMode: discovered
|
|
2601
|
-
elevationOffset: discovered
|
|
2602
|
-
elevationUnit: discovered
|
|
2603
|
-
elevationUnitScale: discovered
|
|
2604
|
-
coordinateFrame: discovered
|
|
2605
|
-
axisOrder: discovered
|
|
2606
|
-
provenance: discovered
|
|
2607
|
-
warnings: discovered
|
|
1100
|
+
sourceCrs: discovered?.sourceCrs,
|
|
1101
|
+
sourceCrsState: discovered?.crs.state,
|
|
1102
|
+
sourceCrsRepresentation: discovered?.crs.state === "explicit" || discovered?.crs.state === "default" ? discovered.crs.representation : void 0,
|
|
1103
|
+
sourceCrsAlternatives: discovered?.crs.state === "explicit" || discovered?.crs.state === "default" ? discovered.crs.alternatives : void 0,
|
|
1104
|
+
verticalCrs: discovered?.verticalCrs,
|
|
1105
|
+
units: discovered?.units,
|
|
1106
|
+
verticalUnitScale: discovered?.verticalUnitScale,
|
|
1107
|
+
coordinateEpoch: discovered?.coordinateEpoch,
|
|
1108
|
+
heightReference: discovered?.heightReference,
|
|
1109
|
+
elevationMode: discovered?.elevationMode,
|
|
1110
|
+
elevationOffset: discovered?.elevationOffset,
|
|
1111
|
+
elevationUnit: discovered?.elevationUnit,
|
|
1112
|
+
elevationUnitScale: discovered?.elevationUnitScale,
|
|
1113
|
+
coordinateFrame: discovered?.coordinateFrame,
|
|
1114
|
+
axisOrder: discovered?.axisOrder,
|
|
1115
|
+
provenance: discovered?.provenance,
|
|
1116
|
+
warnings: discovered?.warnings
|
|
2608
1117
|
}, options);
|
|
2609
1118
|
}
|
|
2610
1119
|
function getKnownCRSDefinition(reference) {
|
|
@@ -2669,7 +1178,7 @@ function resolveMaximumCacheOverflowBytes(options, fallbackOverflowBytes) {
|
|
|
2669
1178
|
const maximumCacheOverflowBytes = options.maximumCacheOverflowBytes ?? fallbackOverflowBytes;
|
|
2670
1179
|
return validateCacheByteLength(maximumCacheOverflowBytes, "maximumCacheOverflowBytes");
|
|
2671
1180
|
}
|
|
2672
|
-
var
|
|
1181
|
+
var DEFAULT_PROPS = {
|
|
2673
1182
|
description: "",
|
|
2674
1183
|
ellipsoid: import_geospatial3.Ellipsoid.WGS84,
|
|
2675
1184
|
modelMatrix: new import_core5.Matrix4(),
|
|
@@ -2812,12 +1321,12 @@ var Tileset3D = class {
|
|
|
2812
1321
|
}
|
|
2813
1322
|
const suppliedOptions = options || {};
|
|
2814
1323
|
const usesTiles3DCacheDefaults = source.type === TILESET_TYPE.TILES3D;
|
|
2815
|
-
const defaultCacheBytes = usesTiles3DCacheDefaults ?
|
|
2816
|
-
const defaultMaximumCacheOverflowBytes = usesTiles3DCacheDefaults ?
|
|
1324
|
+
const defaultCacheBytes = usesTiles3DCacheDefaults ? DEFAULT_PROPS.cacheBytes : DEFAULT_I3S_CACHE_BYTES;
|
|
1325
|
+
const defaultMaximumCacheOverflowBytes = usesTiles3DCacheDefaults ? DEFAULT_PROPS.maximumCacheOverflowBytes : DEFAULT_I3S_MAXIMUM_CACHE_OVERFLOW_BYTES;
|
|
2817
1326
|
const cacheBytes = resolveCacheBytes(suppliedOptions, defaultCacheBytes);
|
|
2818
1327
|
const maximumCacheOverflowBytes = resolveMaximumCacheOverflowBytes(suppliedOptions, defaultMaximumCacheOverflowBytes);
|
|
2819
1328
|
this.options = {
|
|
2820
|
-
...
|
|
1329
|
+
...DEFAULT_PROPS,
|
|
2821
1330
|
...suppliedOptions,
|
|
2822
1331
|
cacheBytes,
|
|
2823
1332
|
maximumCacheOverflowBytes,
|
|
@@ -2838,7 +1347,7 @@ var Tileset3D = class {
|
|
|
2838
1347
|
this.refine = "";
|
|
2839
1348
|
this.contentFormats = this.source.contentFormats;
|
|
2840
1349
|
this._traverser = this._initializeTraverser();
|
|
2841
|
-
this._requestScheduler = new RequestScheduler({
|
|
1350
|
+
this._requestScheduler = new import_loader_utils2.RequestScheduler({
|
|
2842
1351
|
throttleRequests: this.options.throttleRequests,
|
|
2843
1352
|
maxRequests: this.options.maxRequests
|
|
2844
1353
|
});
|
|
@@ -2849,14 +1358,13 @@ var Tileset3D = class {
|
|
|
2849
1358
|
if (metadata) {
|
|
2850
1359
|
this.spatialReference = applyTilesetSpatialOptions(metadata.spatialReference, this.options.spatial);
|
|
2851
1360
|
}
|
|
2852
|
-
this.stats = new
|
|
1361
|
+
this.stats = new Stats({ id: this.url });
|
|
2853
1362
|
this._initializeStats();
|
|
2854
1363
|
this.tilesetInitializationPromise = this._initializeTileSet();
|
|
2855
1364
|
}
|
|
2856
1365
|
destroy() {
|
|
2857
|
-
var _a, _b;
|
|
2858
1366
|
this._clearDeferredTraversal();
|
|
2859
|
-
|
|
1367
|
+
this.source.destroy?.();
|
|
2860
1368
|
this._destroy();
|
|
2861
1369
|
}
|
|
2862
1370
|
isLoaded() {
|
|
@@ -2941,8 +1449,7 @@ var Tileset3D = class {
|
|
|
2941
1449
|
return this.source.getTileUrl(tilePath);
|
|
2942
1450
|
}
|
|
2943
1451
|
hasExtension(extensionName) {
|
|
2944
|
-
|
|
2945
|
-
return Boolean((_b = (_a = this.source).hasExtension) == null ? void 0 : _b.call(_a, extensionName));
|
|
1452
|
+
return Boolean(this.source.hasExtension?.(extensionName));
|
|
2946
1453
|
}
|
|
2947
1454
|
update(viewports = null) {
|
|
2948
1455
|
this.tilesetInitializationPromise.then(() => {
|
|
@@ -2962,12 +1469,12 @@ var Tileset3D = class {
|
|
|
2962
1469
|
this.lastUpdatedVieports = viewports;
|
|
2963
1470
|
}
|
|
2964
1471
|
if (!this.updatePromise) {
|
|
2965
|
-
this.updatePromise = new Promise((
|
|
1472
|
+
this.updatePromise = new Promise((resolve) => {
|
|
2966
1473
|
setTimeout(() => {
|
|
2967
1474
|
if (this.lastUpdatedVieports) {
|
|
2968
1475
|
this.doUpdate(this.lastUpdatedVieports);
|
|
2969
1476
|
}
|
|
2970
|
-
|
|
1477
|
+
resolve(this._frameNumber);
|
|
2971
1478
|
this.updatePromise = null;
|
|
2972
1479
|
}, this.options.debounceTime);
|
|
2973
1480
|
});
|
|
@@ -3217,21 +1724,20 @@ var Tileset3D = class {
|
|
|
3217
1724
|
this.stats.get(MAXIMUM_SSE).count = this.memoryAdjustedScreenSpaceError;
|
|
3218
1725
|
}
|
|
3219
1726
|
async _initializeTileSet() {
|
|
3220
|
-
var _a, _b, _c, _d;
|
|
3221
1727
|
try {
|
|
3222
1728
|
const initializePromise = this.source.initialize();
|
|
3223
1729
|
const initialMetadata = this._getSourceMetadata();
|
|
3224
1730
|
if (initialMetadata) {
|
|
3225
1731
|
this._syncSourceState(initialMetadata);
|
|
3226
1732
|
}
|
|
3227
|
-
if (
|
|
1733
|
+
if (initialMetadata?.tileset?.root && typeof initialMetadata.tileset.root.then !== "function" && (!this.source.prepareTileset || this.spatialReference?.status === "native")) {
|
|
3228
1734
|
this.root = this._initializeTileHeaders(initialMetadata.tileset, null);
|
|
3229
1735
|
this._applyViewState();
|
|
3230
1736
|
}
|
|
3231
1737
|
await initializePromise;
|
|
3232
1738
|
const metadata = this.source.getMetadata();
|
|
3233
1739
|
this._syncSourceState(metadata);
|
|
3234
|
-
await
|
|
1740
|
+
await this.source.prepareTileset?.(this);
|
|
3235
1741
|
if (!this.root) {
|
|
3236
1742
|
this.root = this._initializeTileHeaders(metadata.tileset, null);
|
|
3237
1743
|
}
|
|
@@ -3317,16 +1823,15 @@ var Tileset3D = class {
|
|
|
3317
1823
|
this.options.onTilesetError(error, this);
|
|
3318
1824
|
}
|
|
3319
1825
|
_onTileLoad(tile, loadResult) {
|
|
3320
|
-
|
|
3321
|
-
if (!(loadResult == null ? void 0 : loadResult.loaded)) {
|
|
1826
|
+
if (!loadResult?.loaded) {
|
|
3322
1827
|
return;
|
|
3323
1828
|
}
|
|
3324
1829
|
if (tile.content) {
|
|
3325
1830
|
calculateTransformProps(tile, tile.content);
|
|
3326
1831
|
}
|
|
3327
|
-
|
|
1832
|
+
this.source.onTileLoaded?.(this, tile, loadResult);
|
|
3328
1833
|
this._syncSourceState(this.source.getMetadata());
|
|
3329
|
-
const totalTiles =
|
|
1834
|
+
const totalTiles = this.source.getTilesTotalCount?.();
|
|
3330
1835
|
if (totalTiles) {
|
|
3331
1836
|
this.stats.get(TILES_TOTAL).reset();
|
|
3332
1837
|
this.stats.get(TILES_TOTAL).addCount(totalTiles);
|
|
@@ -3396,7 +1901,6 @@ var Tileset3D = class {
|
|
|
3396
1901
|
tile.destroy();
|
|
3397
1902
|
}
|
|
3398
1903
|
_syncSourceState(metadata) {
|
|
3399
|
-
var _a;
|
|
3400
1904
|
this.tileset = metadata.tileset;
|
|
3401
1905
|
this.loader = metadata.loader;
|
|
3402
1906
|
this.type = metadata.type;
|
|
@@ -3417,25 +1921,24 @@ var Tileset3D = class {
|
|
|
3417
1921
|
this.spatialReference = preserveTransformedSpatialReference(this.spatialReference, spatialReference);
|
|
3418
1922
|
this.properties = this.source.properties ?? this.properties;
|
|
3419
1923
|
this.extras = this.source.extras ?? this.extras;
|
|
3420
|
-
if (
|
|
1924
|
+
if (this.options.attributions?.length) {
|
|
3421
1925
|
this.credits = { attributions: this.options.attributions };
|
|
3422
1926
|
} else {
|
|
3423
1927
|
this.credits = this.source.credits || this.credits;
|
|
3424
1928
|
}
|
|
3425
1929
|
}
|
|
3426
1930
|
_applyViewState() {
|
|
3427
|
-
var _a, _b;
|
|
3428
1931
|
const viewState = this.source.getViewState(this.root);
|
|
3429
1932
|
this.asset = viewState.asset || this.source.asset || {};
|
|
3430
1933
|
this.properties = viewState.properties ?? this.source.properties;
|
|
3431
1934
|
this.extras = viewState.extras ?? this.source.extras ?? null;
|
|
3432
1935
|
this.credits = viewState.credits || this.source.credits || this.credits || { attributions: this.options.attributions || [] };
|
|
3433
1936
|
this.description = viewState.description || this.options.description || "";
|
|
3434
|
-
this.boundingVolume = viewState.boundingVolume ||
|
|
1937
|
+
this.boundingVolume = viewState.boundingVolume || this.root?.boundingVolume || null;
|
|
3435
1938
|
this.cartographicCenter = viewState.cartographicCenter || new import_core5.Vector3();
|
|
3436
1939
|
this.cartesianCenter = viewState.cartesianCenter || null;
|
|
3437
1940
|
this.zoom = viewState.zoom || 1;
|
|
3438
|
-
this.geometricError =
|
|
1941
|
+
this.geometricError = this.tileset?.geometricError || 0;
|
|
3439
1942
|
}
|
|
3440
1943
|
/**
|
|
3441
1944
|
* Returns normalized source metadata when initialization has already populated it.
|
|
@@ -3449,12 +1952,11 @@ var Tileset3D = class {
|
|
|
3449
1952
|
}
|
|
3450
1953
|
};
|
|
3451
1954
|
function preserveTransformedSpatialReference(current, next) {
|
|
3452
|
-
return
|
|
1955
|
+
return current?.status === "transformed" && current.sourceCrs === next.sourceCrs && current.targetCrs === next.targetCrs && current.targetHeightReference === next.targetHeightReference && current.outputCoordinates === next.outputCoordinates ? current : next;
|
|
3453
1956
|
}
|
|
3454
1957
|
|
|
3455
1958
|
// dist/tileset-3d/common/tileset-observability.js
|
|
3456
1959
|
function getTileset3DTraversalSnapshot(tileset) {
|
|
3457
|
-
var _a;
|
|
3458
1960
|
const selectedTiles = tileset.selectedTiles.slice();
|
|
3459
1961
|
const requestedTiles = tileset.requestedTiles.slice();
|
|
3460
1962
|
const emptyTiles = tileset.emptyTiles.slice();
|
|
@@ -3464,7 +1966,7 @@ function getTileset3DTraversalSnapshot(tileset) {
|
|
|
3464
1966
|
return typeof count === "number" && Number.isFinite(count) ? count : 0;
|
|
3465
1967
|
};
|
|
3466
1968
|
const implicitTilingSource = tileset.source;
|
|
3467
|
-
const implicitTiling =
|
|
1969
|
+
const implicitTiling = implicitTilingSource.getImplicitTilingStats?.();
|
|
3468
1970
|
return {
|
|
3469
1971
|
frameNumber: tileset.frameNumber,
|
|
3470
1972
|
selectedTileIds: getTileIds(selectedTiles),
|
|
@@ -3484,7 +1986,6 @@ function getTileset3DTraversalSnapshot(tileset) {
|
|
|
3484
1986
|
|
|
3485
1987
|
// dist/tileset-3d/common/tileset-content-traversal.js
|
|
3486
1988
|
async function* traverseTilesetContents(tileset, options = {}) {
|
|
3487
|
-
var _a, _b;
|
|
3488
1989
|
await tileset.tilesetInitializationPromise;
|
|
3489
1990
|
throwIfAborted(options.signal);
|
|
3490
1991
|
if (!tileset.root) {
|
|
@@ -3525,7 +2026,7 @@ async function* traverseTilesetContents(tileset, options = {}) {
|
|
|
3525
2026
|
if (!loadResult.loaded) {
|
|
3526
2027
|
throw new Error(`Unable to load tile content for tile ${tile.id}`);
|
|
3527
2028
|
}
|
|
3528
|
-
|
|
2029
|
+
tileset.source.onTileLoaded?.(tileset, tile, loadResult);
|
|
3529
2030
|
}
|
|
3530
2031
|
yield { tile, contents: tile.contentEntries };
|
|
3531
2032
|
} finally {
|
|
@@ -3539,12 +2040,13 @@ async function* traverseTilesetContents(tileset, options = {}) {
|
|
|
3539
2040
|
}
|
|
3540
2041
|
}
|
|
3541
2042
|
function throwIfAborted(signal) {
|
|
3542
|
-
if (signal
|
|
2043
|
+
if (signal?.aborted) {
|
|
3543
2044
|
throw signal.reason ?? new DOMException("The operation was aborted", "AbortError");
|
|
3544
2045
|
}
|
|
3545
2046
|
}
|
|
3546
2047
|
|
|
3547
2048
|
// dist/tileset-3d/common/indexed-archive-tileset-source.js
|
|
2049
|
+
var import_loader_utils3 = require("@loaders.gl/loader-utils");
|
|
3548
2050
|
var IndexedArchiveTilesetSource = class {
|
|
3549
2051
|
/** URL exposed to the tileset source that owns this archive source. */
|
|
3550
2052
|
sourceUrl;
|
|
@@ -3612,30 +2114,30 @@ var IndexedArchiveTilesetSource = class {
|
|
|
3612
2114
|
async openArchiveReadableFile() {
|
|
3613
2115
|
const { data } = this.options;
|
|
3614
2116
|
if (typeof data !== "string") {
|
|
3615
|
-
return new BlobFile(data);
|
|
2117
|
+
return new import_loader_utils3.BlobFile(data);
|
|
3616
2118
|
}
|
|
3617
2119
|
if (/^https?:\/\//i.test(data)) {
|
|
3618
|
-
return new HttpFile(data);
|
|
2120
|
+
return new import_loader_utils3.HttpFile(data);
|
|
3619
2121
|
}
|
|
3620
2122
|
const coreApi = this.options.getCoreApi();
|
|
3621
2123
|
if (!coreApi) {
|
|
3622
2124
|
throw new Error(this.options.missingCoreApiMessage);
|
|
3623
2125
|
}
|
|
3624
2126
|
const response = await coreApi.fetchFile(data);
|
|
3625
|
-
return new BlobFile(await response.arrayBuffer());
|
|
2127
|
+
return new import_loader_utils3.BlobFile(await response.arrayBuffer());
|
|
3626
2128
|
}
|
|
3627
2129
|
resolveArchivePath(request, baseUrl) {
|
|
3628
2130
|
const requestWithoutQuery = stripQueryString(request);
|
|
3629
2131
|
const archiveRoot = stripQueryString(this.sourceUrl);
|
|
3630
2132
|
const baseWithoutQuery = stripQueryString(baseUrl);
|
|
3631
|
-
const basePath = baseWithoutQuery === archiveRoot ? archiveRoot :
|
|
2133
|
+
const basePath = baseWithoutQuery === archiveRoot ? archiveRoot : import_loader_utils3.path.dirname(baseWithoutQuery);
|
|
3632
2134
|
const markerExpression = new RegExp(`\\.${this.options.archiveExtension}/(.*)$`, "i");
|
|
3633
2135
|
const markerMatch = requestWithoutQuery.match(markerExpression);
|
|
3634
|
-
if (markerMatch
|
|
2136
|
+
if (markerMatch?.[1]) {
|
|
3635
2137
|
return markerMatch[1];
|
|
3636
2138
|
}
|
|
3637
2139
|
const isAbsoluteRequest = /^[a-z][a-z0-9+.-]*:/i.test(requestWithoutQuery) || requestWithoutQuery.startsWith("/");
|
|
3638
|
-
const absoluteRequest = requestWithoutQuery.startsWith(archiveRoot) ? requestWithoutQuery : baseWithoutQuery === archiveRoot && !isAbsoluteRequest ? `${archiveRoot}/${requestWithoutQuery}` : /^[a-z][a-z0-9+.-]*:\/\//i.test(baseWithoutQuery) ? new URL(requestWithoutQuery, baseWithoutQuery).href :
|
|
2140
|
+
const absoluteRequest = requestWithoutQuery.startsWith(archiveRoot) ? requestWithoutQuery : baseWithoutQuery === archiveRoot && !isAbsoluteRequest ? `${archiveRoot}/${requestWithoutQuery}` : /^[a-z][a-z0-9+.-]*:\/\//i.test(baseWithoutQuery) ? new URL(requestWithoutQuery, baseWithoutQuery).href : import_loader_utils3.path.resolve(basePath, requestWithoutQuery);
|
|
3639
2141
|
if (absoluteRequest === archiveRoot) {
|
|
3640
2142
|
return "";
|
|
3641
2143
|
}
|
|
@@ -3665,7 +2167,6 @@ function getTile3DFeatureIdSets(payload) {
|
|
|
3665
2167
|
const featureIdSets = [];
|
|
3666
2168
|
const visited = /* @__PURE__ */ new Set();
|
|
3667
2169
|
const visit = (value) => {
|
|
3668
|
-
var _a, _b;
|
|
3669
2170
|
if (!value || typeof value !== "object") {
|
|
3670
2171
|
return;
|
|
3671
2172
|
}
|
|
@@ -3674,7 +2175,7 @@ function getTile3DFeatureIdSets(payload) {
|
|
|
3674
2175
|
}
|
|
3675
2176
|
visited.add(value);
|
|
3676
2177
|
const record = value;
|
|
3677
|
-
const declarations =
|
|
2178
|
+
const declarations = record.extensions?.EXT_mesh_features?.featureIds;
|
|
3678
2179
|
if (Array.isArray(declarations)) {
|
|
3679
2180
|
for (const declaration of declarations) {
|
|
3680
2181
|
if (!declaration || typeof declaration !== "object") {
|
|
@@ -3705,6 +2206,7 @@ function getTile3DFeatureIdSets(payload) {
|
|
|
3705
2206
|
var import_core6 = require("@math.gl/core");
|
|
3706
2207
|
var import_culling3 = require("@math.gl/culling");
|
|
3707
2208
|
var import_geospatial4 = require("@math.gl/geospatial");
|
|
2209
|
+
var import_loader_utils4 = require("@loaders.gl/loader-utils");
|
|
3708
2210
|
function defined(x) {
|
|
3709
2211
|
return x !== void 0 && x !== null;
|
|
3710
2212
|
}
|
|
@@ -3712,7 +2214,7 @@ var scratchPoint = new import_core6.Vector3();
|
|
|
3712
2214
|
var scratchScale = new import_core6.Vector3();
|
|
3713
2215
|
var identityTransform = new import_core6.Matrix4();
|
|
3714
2216
|
function createBoundingVolume(boundingVolumeHeader, transform, result, initialTransform = transform) {
|
|
3715
|
-
assert(boundingVolumeHeader, "3D Tile: boundingVolume must be defined");
|
|
2217
|
+
(0, import_loader_utils4.assert)(boundingVolumeHeader, "3D Tile: boundingVolume must be defined");
|
|
3716
2218
|
if (boundingVolumeHeader.box) {
|
|
3717
2219
|
const boxTransform = boundingVolumeHeader.s2VolumeInfo ? identityTransform : transform;
|
|
3718
2220
|
return createBox(boundingVolumeHeader.box, boxTransform, result);
|
|
@@ -3930,6 +2432,7 @@ function getProjectedRadius(tile, frameState) {
|
|
|
3930
2432
|
}
|
|
3931
2433
|
|
|
3932
2434
|
// dist/utils/managed-array.js
|
|
2435
|
+
var import_loader_utils5 = require("@loaders.gl/loader-utils");
|
|
3933
2436
|
var ManagedArray = class {
|
|
3934
2437
|
_map = /* @__PURE__ */ new Map();
|
|
3935
2438
|
_array;
|
|
@@ -3970,7 +2473,7 @@ var ManagedArray = class {
|
|
|
3970
2473
|
* @param {Number} index The index to get.
|
|
3971
2474
|
*/
|
|
3972
2475
|
get(index) {
|
|
3973
|
-
assert(index < this._array.length);
|
|
2476
|
+
(0, import_loader_utils5.assert)(index < this._array.length);
|
|
3974
2477
|
return this._array[index];
|
|
3975
2478
|
}
|
|
3976
2479
|
/**
|
|
@@ -3980,7 +2483,7 @@ var ManagedArray = class {
|
|
|
3980
2483
|
* @param {*} element The element to set at index.
|
|
3981
2484
|
*/
|
|
3982
2485
|
set(index, element) {
|
|
3983
|
-
assert(index >= 0);
|
|
2486
|
+
(0, import_loader_utils5.assert)(index >= 0);
|
|
3984
2487
|
if (index >= this.length) {
|
|
3985
2488
|
this.length = index + 1;
|
|
3986
2489
|
}
|
|
@@ -4034,7 +2537,7 @@ var ManagedArray = class {
|
|
|
4034
2537
|
* @param {Number} length The length.
|
|
4035
2538
|
*/
|
|
4036
2539
|
reserve(length) {
|
|
4037
|
-
assert(length >= 0);
|
|
2540
|
+
(0, import_loader_utils5.assert)(length >= 0);
|
|
4038
2541
|
if (length > this._array.length) {
|
|
4039
2542
|
this._array.length = length;
|
|
4040
2543
|
}
|
|
@@ -4045,7 +2548,7 @@ var ManagedArray = class {
|
|
|
4045
2548
|
* @param {Number} length The length.
|
|
4046
2549
|
*/
|
|
4047
2550
|
resize(length) {
|
|
4048
|
-
assert(length >= 0);
|
|
2551
|
+
(0, import_loader_utils5.assert)(length >= 0);
|
|
4049
2552
|
this.length = length;
|
|
4050
2553
|
}
|
|
4051
2554
|
/**
|
|
@@ -4070,7 +2573,7 @@ var ManagedArray = class {
|
|
|
4070
2573
|
};
|
|
4071
2574
|
|
|
4072
2575
|
// dist/tileset-3d/common/tileset-traverser.js
|
|
4073
|
-
var
|
|
2576
|
+
var DEFAULT_PROPS2 = {
|
|
4074
2577
|
loadSiblings: false,
|
|
4075
2578
|
skipLevelOfDetail: false,
|
|
4076
2579
|
baseScreenSpaceError: 1024,
|
|
@@ -4110,7 +2613,7 @@ var TilesetTraverser = class {
|
|
|
4110
2613
|
}
|
|
4111
2614
|
// TODO nested props
|
|
4112
2615
|
constructor(options) {
|
|
4113
|
-
this.options = { ...
|
|
2616
|
+
this.options = { ...DEFAULT_PROPS2, ...options };
|
|
4114
2617
|
}
|
|
4115
2618
|
/** Returns whether skip-LOD traversal is enabled and supported by the loaded content. */
|
|
4116
2619
|
isSkipLevelOfDetailEnabled() {
|
|
@@ -4687,7 +3190,7 @@ var Tile3D = class {
|
|
|
4687
3190
|
*/
|
|
4688
3191
|
_getGpuMemoryUsageInBytes() {
|
|
4689
3192
|
const contents = this.contents.length ? this.contents : [this.content];
|
|
4690
|
-
return contents.reduce((total, content) => total + (
|
|
3193
|
+
return contents.reduce((total, content) => total + (content?.gpuMemoryUsageInBytes || content?.byteLength || 0), 0);
|
|
4691
3194
|
}
|
|
4692
3195
|
/**
|
|
4693
3196
|
* Returns scheduler priority for render-content requests.
|
|
@@ -4793,13 +3296,12 @@ var Tile3D = class {
|
|
|
4793
3296
|
}
|
|
4794
3297
|
/** Loads source content and updates the tile's renderer-neutral payload state. */
|
|
4795
3298
|
async _loadContentFromSource() {
|
|
4796
|
-
var _a;
|
|
4797
3299
|
const loadResult = await this.tileset.source.loadTileContent(this);
|
|
4798
3300
|
if (loadResult.contents) {
|
|
4799
3301
|
this.contents = loadResult.contents;
|
|
4800
3302
|
this.content = this.contents[0] || null;
|
|
4801
3303
|
}
|
|
4802
|
-
this.vectorContent =
|
|
3304
|
+
this.vectorContent = this.contents.find((content) => Boolean(content?.vectorContent))?.vectorContent || null;
|
|
4803
3305
|
if (this.tileset.options.contentLoader) {
|
|
4804
3306
|
await this.tileset.options.contentLoader(this);
|
|
4805
3307
|
}
|
|
@@ -4896,13 +3398,12 @@ var Tile3D = class {
|
|
|
4896
3398
|
}
|
|
4897
3399
|
/** Refreshes tile and content metadata from a source or materialized tile header. */
|
|
4898
3400
|
_initializeMetadata(header) {
|
|
4899
|
-
var _a;
|
|
4900
3401
|
this.metadata = header.metadata || null;
|
|
4901
3402
|
const contentHeaders = Array.isArray(header.content) ? header.content : [header.content];
|
|
4902
3403
|
this.contentMetadata = contentHeaders.filter(Boolean).map((contentHeader) => contentHeader.metadata || null);
|
|
4903
3404
|
const firstContentHeader = contentHeaders.find(Boolean) || {};
|
|
4904
3405
|
const groupReference = firstContentHeader.group;
|
|
4905
|
-
const group = typeof groupReference === "number" ?
|
|
3406
|
+
const group = typeof groupReference === "number" ? this.tileset.groups?.[groupReference] || null : groupReference || null;
|
|
4906
3407
|
const metadataContext = {
|
|
4907
3408
|
tileset: this.tileset.metadata || null,
|
|
4908
3409
|
group,
|
|
@@ -4918,17 +3419,14 @@ var Tile3D = class {
|
|
|
4918
3419
|
/** Updates payload and renderability while retaining immutable metadata descriptors. */
|
|
4919
3420
|
_updateContentEntriesAfterLoad(loadResult) {
|
|
4920
3421
|
if (loadResult.contentEntries) {
|
|
4921
|
-
this.contentEntries = loadResult.contentEntries.map((entry, index) => {
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
renderable: Boolean(entry.renderable !== false && (entry.payload ?? this.contents[index]) && !isNestedTilesetPayload(entry.payload ?? this.contents[index]))
|
|
4930
|
-
};
|
|
4931
|
-
});
|
|
3422
|
+
this.contentEntries = loadResult.contentEntries.map((entry, index) => ({
|
|
3423
|
+
...entry,
|
|
3424
|
+
index,
|
|
3425
|
+
boundingVolume: entry.boundingVolume || this._contentBoundingVolumes[index] || this.boundingVolume,
|
|
3426
|
+
payload: entry.payload ?? this.contents[index] ?? null,
|
|
3427
|
+
featureIds: entry.featureIds?.length ? entry.featureIds : getTile3DFeatureIdSets(entry.payload ?? this.contents[index]),
|
|
3428
|
+
renderable: Boolean(entry.renderable !== false && (entry.payload ?? this.contents[index]) && !isNestedTilesetPayload(entry.payload ?? this.contents[index]))
|
|
3429
|
+
}));
|
|
4932
3430
|
this.featureIdSets = this.contentEntries.flatMap((entry) => entry.featureIds);
|
|
4933
3431
|
return;
|
|
4934
3432
|
}
|
|
@@ -4946,8 +3444,7 @@ var Tile3D = class {
|
|
|
4946
3444
|
}
|
|
4947
3445
|
/** Returns whether an ordered content entry currently has renderable payload. */
|
|
4948
3446
|
isContentRenderable(index) {
|
|
4949
|
-
|
|
4950
|
-
return Boolean((_a = this.contentEntries[index]) == null ? void 0 : _a.renderable);
|
|
3447
|
+
return Boolean(this.contentEntries[index]?.renderable);
|
|
4951
3448
|
}
|
|
4952
3449
|
/** Initializes additive renderer-neutral descriptors from a normalized tile header. */
|
|
4953
3450
|
_initializeContentEntries(tileHeader) {
|
|
@@ -5030,7 +3527,6 @@ var Tile3D = class {
|
|
|
5030
3527
|
* @param frameState - Current camera and viewport measurements.
|
|
5031
3528
|
*/
|
|
5032
3529
|
_updateRequestPriorityMetrics(frameState) {
|
|
5033
|
-
var _a, _b, _c, _d, _e;
|
|
5034
3530
|
if (this.tileset.type !== TILESET_TYPE.TILES3D) {
|
|
5035
3531
|
this._screenSpaceErrorProgressiveResolution = this._screenSpaceError;
|
|
5036
3532
|
this._priorityProgressiveResolution = false;
|
|
@@ -5041,8 +3537,8 @@ var Tile3D = class {
|
|
|
5041
3537
|
const options = this.tileset.options;
|
|
5042
3538
|
const progressiveResolutionHeightFraction = options.progressiveResolutionHeightFraction;
|
|
5043
3539
|
this._screenSpaceErrorProgressiveResolution = this.getScreenSpaceError(frameState, false, progressiveResolutionHeightFraction);
|
|
5044
|
-
this._priorityProgressiveResolution = isProgressiveResolutionPriority(this._screenSpaceErrorProgressiveResolution,
|
|
5045
|
-
if (!options.foveatedScreenSpaceError ||
|
|
3540
|
+
this._priorityProgressiveResolution = isProgressiveResolutionPriority(this._screenSpaceErrorProgressiveResolution, this.parent?._screenSpaceErrorProgressiveResolution, this.tileset.memoryAdjustedScreenSpaceError, progressiveResolutionHeightFraction);
|
|
3541
|
+
if (!options.foveatedScreenSpaceError || frameState.viewport?.orthographic || !frameState.camera?.position || !frameState.camera?.direction) {
|
|
5046
3542
|
this._foveatedFactor = 0;
|
|
5047
3543
|
this.priorityDeferred = false;
|
|
5048
3544
|
return;
|
|
@@ -5060,7 +3556,7 @@ var Tile3D = class {
|
|
|
5060
3556
|
foveatedFactor: this._foveatedFactor,
|
|
5061
3557
|
verticalFieldOfView: frameState.camera.verticalFieldOfView,
|
|
5062
3558
|
screenSpaceError: this._screenSpaceError,
|
|
5063
|
-
parentScreenSpaceError:
|
|
3559
|
+
parentScreenSpaceError: this.parent?._screenSpaceError,
|
|
5064
3560
|
maximumScreenSpaceError: this.tileset.memoryAdjustedScreenSpaceError,
|
|
5065
3561
|
priorityProgressiveResolution: this._priorityProgressiveResolution
|
|
5066
3562
|
});
|
|
@@ -5132,8 +3628,7 @@ var Tile3D = class {
|
|
|
5132
3628
|
// INTERNAL METHODS
|
|
5133
3629
|
/** Initializes the tile's LOD metric from its header or its nearest available ancestor. */
|
|
5134
3630
|
_initializeLodMetric(header) {
|
|
5135
|
-
|
|
5136
|
-
this._scaleGeometricError = typeof header._scaleGeometricError === "boolean" ? header._scaleGeometricError : ((_a = this.parent) == null ? void 0 : _a._scaleGeometricError) ?? true;
|
|
3631
|
+
this._scaleGeometricError = typeof header._scaleGeometricError === "boolean" ? header._scaleGeometricError : this.parent?._scaleGeometricError ?? true;
|
|
5137
3632
|
if ("lodMetricType" in header) {
|
|
5138
3633
|
this.lodMetricType = header.lodMetricType;
|
|
5139
3634
|
} else {
|
|
@@ -5184,13 +3679,12 @@ var Tile3D = class {
|
|
|
5184
3679
|
this._updateBoundingVolume(tileHeader);
|
|
5185
3680
|
}
|
|
5186
3681
|
_initializeContent(tileHeader) {
|
|
5187
|
-
var _a;
|
|
5188
3682
|
this.content = { _tileset: this.tileset, _tile: this };
|
|
5189
3683
|
this.contents = [];
|
|
5190
3684
|
this.hasEmptyContent = true;
|
|
5191
3685
|
this.contentState = TILE_CONTENT_STATE.UNLOADED;
|
|
5192
3686
|
this.hasTilesetContent = false;
|
|
5193
|
-
if (tileHeader.contentUrl ||
|
|
3687
|
+
if (tileHeader.contentUrl || tileHeader.contentUrls?.length) {
|
|
5194
3688
|
this.content = null;
|
|
5195
3689
|
this.hasEmptyContent = false;
|
|
5196
3690
|
}
|
|
@@ -5229,7 +3723,7 @@ var Tile3D = class {
|
|
|
5229
3723
|
* `content`.
|
|
5230
3724
|
*/
|
|
5231
3725
|
_isTileset() {
|
|
5232
|
-
return (this.contents.length ? this.contents : [this.content]).some((content) =>
|
|
3726
|
+
return (this.contents.length ? this.contents : [this.content]).some((content) => content?.shape === "tileset3d");
|
|
5233
3727
|
}
|
|
5234
3728
|
_onContentLoaded() {
|
|
5235
3729
|
const contents = this.contents.length ? this.contents : [this.content];
|
|
@@ -5259,7 +3753,7 @@ var Tile3D = class {
|
|
|
5259
3753
|
this._contentBoundingVolumeHeaders = Array.isArray(content) ? content : [content];
|
|
5260
3754
|
}
|
|
5261
3755
|
const contentHeaders = content ? Array.isArray(content) ? content : [content] : this._contentBoundingVolumeHeaders;
|
|
5262
|
-
this._contentBoundingVolumes = contentHeaders.length ? contentHeaders.map((headerEntry) =>
|
|
3756
|
+
this._contentBoundingVolumes = contentHeaders.length ? contentHeaders.map((headerEntry) => headerEntry?.boundingVolume ? createBoundingVolume(headerEntry.boundingVolume, this.computedTransform, void 0, this._initialTransform) : this.boundingVolume) : [this.boundingVolume];
|
|
5263
3757
|
this._contentBoundingVolume = this._contentBoundingVolumes[0] || null;
|
|
5264
3758
|
}
|
|
5265
3759
|
/**
|
|
@@ -5279,6 +3773,7 @@ var Tile3D = class {
|
|
|
5279
3773
|
};
|
|
5280
3774
|
|
|
5281
3775
|
// dist/tileset-3d/format-3d-tiles/tiles-3d-source.js
|
|
3776
|
+
var import_loader_utils6 = require("@loaders.gl/loader-utils");
|
|
5282
3777
|
var import_geospatial9 = require("@math.gl/geospatial");
|
|
5283
3778
|
var import_core12 = require("@math.gl/core");
|
|
5284
3779
|
|
|
@@ -5508,8 +4003,7 @@ var Tileset3DTraverser = class extends TilesetTraverser {
|
|
|
5508
4003
|
* @param frameState - Current culling and LOD state.
|
|
5509
4004
|
*/
|
|
5510
4005
|
updateChildTiles(tile, frameState) {
|
|
5511
|
-
|
|
5512
|
-
const isImplicitHierarchyRoot = ((_a = tile.header.implicitSubtree) == null ? void 0 : _a.coordinates.level) === 0;
|
|
4006
|
+
const isImplicitHierarchyRoot = tile.header.implicitSubtree?.coordinates.level === 0;
|
|
5513
4007
|
if (tile.hasUnloadedChildren && tile.isVisibleAndInRequestVolume && (isImplicitHierarchyRoot || this.shouldRefine(tile, frameState))) {
|
|
5514
4008
|
const requestKey = `${frameState.viewport.id}:${tile.id}`;
|
|
5515
4009
|
if (!this.pendingImplicitSubtrees.has(requestKey)) {
|
|
@@ -5692,19 +4186,18 @@ function getI3SVerticalUnitScale(heightUnit, zFactor) {
|
|
|
5692
4186
|
|
|
5693
4187
|
// dist/spatial/format-spatial-reference.js
|
|
5694
4188
|
function getI3SSpatialReference(layer) {
|
|
5695
|
-
|
|
5696
|
-
const spatialReference = layer.spatialReference || ((_a = layer.fullExtent) == null ? void 0 : _a.spatialReference);
|
|
4189
|
+
const spatialReference = layer.spatialReference || layer.fullExtent?.spatialReference;
|
|
5697
4190
|
const sourceCrs = getI3SCrsDefinition(spatialReference);
|
|
5698
|
-
const verticalCrs =
|
|
5699
|
-
const heightModel =
|
|
5700
|
-
const verticalUnit =
|
|
4191
|
+
const verticalCrs = layer.heightModelInfo?.vertCRS || getI3SVerticalCrsDefinition(spatialReference);
|
|
4192
|
+
const heightModel = layer.heightModelInfo?.heightModel;
|
|
4193
|
+
const verticalUnit = layer.heightModelInfo?.heightUnit;
|
|
5701
4194
|
const verticalUnitScale = getI3SVerticalUnitScale(verticalUnit, layer.ZFactor);
|
|
5702
4195
|
const heightReference = heightModel === "ellipsoidal" ? "ellipsoidal" : heightModel === "gravity_related_height" ? "orthometric" : "unknown";
|
|
5703
4196
|
const sourceIdentifier = getCrsIdentifier(spatialReference);
|
|
5704
4197
|
const coordinateFrame = sourceIdentifier === void 0 ? sourceCrs ? getSpatialCoordinateFrame(sourceCrs) : "unknown" : getSpatialCoordinateFrame(`EPSG:${sourceIdentifier}`);
|
|
5705
4198
|
const units = getI3SCoordinateUnits(coordinateFrame, verticalUnit, layer.ZFactor);
|
|
5706
4199
|
const warnings = [];
|
|
5707
|
-
const elevationMode = getI3SElevationMode(
|
|
4200
|
+
const elevationMode = getI3SElevationMode(layer.elevationInfo?.mode);
|
|
5708
4201
|
const elevationUnit = layer.elevationInfo ? layer.elevationInfo.unit || "meter" : void 0;
|
|
5709
4202
|
const elevationUnitScale = getI3SLinearUnitScale(elevationUnit);
|
|
5710
4203
|
if (verticalUnitScale === void 0) {
|
|
@@ -5713,7 +4206,7 @@ function getI3SSpatialReference(layer) {
|
|
|
5713
4206
|
if (layer.elevationInfo && elevationUnitScale === void 0) {
|
|
5714
4207
|
warnings.push(`Unsupported I3S elevation unit ${elevationUnit}`);
|
|
5715
4208
|
}
|
|
5716
|
-
if (
|
|
4209
|
+
if (layer.elevationInfo?.mode && !elevationMode) {
|
|
5717
4210
|
warnings.push(`Unsupported I3S elevation mode ${layer.elevationInfo.mode}`);
|
|
5718
4211
|
}
|
|
5719
4212
|
if (elevationMode && elevationMode !== "absoluteHeight") {
|
|
@@ -5722,15 +4215,15 @@ function getI3SSpatialReference(layer) {
|
|
|
5722
4215
|
return createTilesetSpatialReference({
|
|
5723
4216
|
sourceCrs,
|
|
5724
4217
|
sourceCrsRepresentation: sourceIdentifier !== void 0 ? "identifier" : sourceCrs ? "wkt" : void 0,
|
|
5725
|
-
sourceCrsAlternatives: sourceIdentifier !== void 0 &&
|
|
4218
|
+
sourceCrsAlternatives: sourceIdentifier !== void 0 && spatialReference?.wkt ? [{ definition: spatialReference.wkt, representation: "wkt" }] : void 0,
|
|
5726
4219
|
verticalCrs,
|
|
5727
4220
|
units,
|
|
5728
4221
|
verticalUnitScale: verticalUnitScale ?? Number.NaN,
|
|
5729
4222
|
heightReference,
|
|
5730
4223
|
elevationMode,
|
|
5731
|
-
elevationOffset:
|
|
4224
|
+
elevationOffset: layer.elevationInfo?.offset,
|
|
5732
4225
|
elevationUnit,
|
|
5733
|
-
elevationUnitScale:
|
|
4226
|
+
elevationUnitScale: layer.elevationInfo?.mode && !elevationMode ? Number.NaN : elevationUnitScale ?? (layer.elevationInfo ? Number.NaN : 1),
|
|
5734
4227
|
coordinateFrame,
|
|
5735
4228
|
axisOrder: sourceCrs ? "xyz" : "unknown",
|
|
5736
4229
|
provenance: sourceCrs ? "metadata" : "unknown",
|
|
@@ -5758,7 +4251,6 @@ function getI3SElevationMode(mode) {
|
|
|
5758
4251
|
}
|
|
5759
4252
|
}
|
|
5760
4253
|
function get3DTilesSpatialReference(tileset) {
|
|
5761
|
-
var _a, _b;
|
|
5762
4254
|
const draftSpatialReference = getDraft3DTilesSpatialReference(tileset);
|
|
5763
4255
|
if (draftSpatialReference) {
|
|
5764
4256
|
return draftSpatialReference;
|
|
@@ -5777,7 +4269,7 @@ function get3DTilesSpatialReference(tileset) {
|
|
|
5777
4269
|
warnings.push("3D Tiles geocentric CRS is explicitly unknown");
|
|
5778
4270
|
provenance = "metadata";
|
|
5779
4271
|
sourceCrsState = "unknown";
|
|
5780
|
-
} else if (
|
|
4272
|
+
} else if (tileset.root?.boundingVolume?.region) {
|
|
5781
4273
|
sourceCrs = "EPSG:4978";
|
|
5782
4274
|
provenance = "format-default";
|
|
5783
4275
|
sourceCrsState = "default";
|
|
@@ -5801,8 +4293,7 @@ function get3DTilesSpatialReference(tileset) {
|
|
|
5801
4293
|
});
|
|
5802
4294
|
}
|
|
5803
4295
|
function getDraft3DTilesSpatialReference(tileset) {
|
|
5804
|
-
|
|
5805
|
-
const extension = (_a = tileset.extensions) == null ? void 0 : _a.EXT_geospatial_crs;
|
|
4296
|
+
const extension = tileset.extensions?.EXT_geospatial_crs;
|
|
5806
4297
|
if (!extension) {
|
|
5807
4298
|
return void 0;
|
|
5808
4299
|
}
|
|
@@ -5812,8 +4303,8 @@ function getDraft3DTilesSpatialReference(tileset) {
|
|
|
5812
4303
|
let epoch;
|
|
5813
4304
|
let representation;
|
|
5814
4305
|
if (extension.format === "wkid") {
|
|
5815
|
-
const wkidExtension =
|
|
5816
|
-
if (typeof
|
|
4306
|
+
const wkidExtension = extension.extensions?.EXT_geospatial_crs_wkid;
|
|
4307
|
+
if (typeof wkidExtension?.authority === "string" && Number.isInteger(wkidExtension.wkid)) {
|
|
5817
4308
|
sourceCrs = `${wkidExtension.authority}:${wkidExtension.wkid}`;
|
|
5818
4309
|
representation = "identifier";
|
|
5819
4310
|
if (Number.isInteger(wkidExtension.vcsWkid)) {
|
|
@@ -5827,8 +4318,8 @@ function getDraft3DTilesSpatialReference(tileset) {
|
|
|
5827
4318
|
warnings.push("EXT_geospatial_crs_wkid requires string authority and integer wkid");
|
|
5828
4319
|
}
|
|
5829
4320
|
} else if (extension.format === "wkt2") {
|
|
5830
|
-
const wktExtension =
|
|
5831
|
-
if (typeof
|
|
4321
|
+
const wktExtension = extension.extensions?.EXT_geospatial_crs_wkt2;
|
|
4322
|
+
if (typeof wktExtension?.wkt2 === "string" && wktExtension.wkt2.trim()) {
|
|
5832
4323
|
sourceCrs = wktExtension.wkt2;
|
|
5833
4324
|
representation = "wkt";
|
|
5834
4325
|
} else {
|
|
@@ -5842,7 +4333,7 @@ function getDraft3DTilesSpatialReference(tileset) {
|
|
|
5842
4333
|
if (verticalCrs && !verticalSemantics) {
|
|
5843
4334
|
warnings.push(`Unsupported vertical CRS ${String(verticalCrs)}; vertical unit and height reference are unknown`);
|
|
5844
4335
|
}
|
|
5845
|
-
const verticalUnit = verticalCrs ? verticalSemantics
|
|
4336
|
+
const verticalUnit = verticalCrs ? verticalSemantics?.unit : "meter";
|
|
5846
4337
|
return createTilesetSpatialReference({
|
|
5847
4338
|
sourceCrs,
|
|
5848
4339
|
sourceCrsState: sourceCrs ? "explicit" : "unknown",
|
|
@@ -5850,8 +4341,8 @@ function getDraft3DTilesSpatialReference(tileset) {
|
|
|
5850
4341
|
verticalCrs,
|
|
5851
4342
|
coordinateEpoch: epoch,
|
|
5852
4343
|
units: coordinateFrame === "geocentric" ? ["meter", "meter", "meter"] : coordinateFrame === "geographic" && verticalUnit ? ["degree", "degree", verticalUnit] : void 0,
|
|
5853
|
-
verticalUnitScale: verticalCrs ?
|
|
5854
|
-
heightReference: verticalCrs ?
|
|
4344
|
+
verticalUnitScale: verticalCrs ? verticalSemantics?.verticalUnitScale ?? Number.NaN : 1,
|
|
4345
|
+
heightReference: verticalCrs ? verticalSemantics?.heightReference ?? "unknown" : sourceCrs ? "ellipsoidal" : "unknown",
|
|
5855
4346
|
coordinateFrame,
|
|
5856
4347
|
axisOrder: sourceCrs ? "xyz" : "unknown",
|
|
5857
4348
|
provenance: "metadata",
|
|
@@ -5896,27 +4387,26 @@ function getI3SCrsDefinition(spatialReference) {
|
|
|
5896
4387
|
if (identifier !== void 0) {
|
|
5897
4388
|
return `EPSG:${identifier}`;
|
|
5898
4389
|
}
|
|
5899
|
-
return spatialReference
|
|
4390
|
+
return spatialReference?.wkt;
|
|
5900
4391
|
}
|
|
5901
4392
|
function getI3SVerticalCrsDefinition(spatialReference) {
|
|
5902
|
-
const identifier =
|
|
4393
|
+
const identifier = spatialReference?.latestVcsWkid ?? spatialReference?.vcsWkid;
|
|
5903
4394
|
return identifier === void 0 ? void 0 : `EPSG:${identifier}`;
|
|
5904
4395
|
}
|
|
5905
4396
|
function getCrsIdentifier(spatialReference) {
|
|
5906
|
-
return
|
|
4397
|
+
return spatialReference?.latestWkid ?? spatialReference?.wkid;
|
|
5907
4398
|
}
|
|
5908
4399
|
function getTilesetSemanticValue(tileset, semantic) {
|
|
5909
|
-
|
|
5910
|
-
const classIdentifier = (_a = tileset.metadata) == null ? void 0 : _a.class;
|
|
4400
|
+
const classIdentifier = tileset.metadata?.class;
|
|
5911
4401
|
if (!classIdentifier) {
|
|
5912
4402
|
return void 0;
|
|
5913
4403
|
}
|
|
5914
|
-
const classDefinition =
|
|
5915
|
-
const propertyDefinitions = classDefinition
|
|
5916
|
-
const propertyValues =
|
|
4404
|
+
const classDefinition = tileset.schema?.classes?.[classIdentifier];
|
|
4405
|
+
const propertyDefinitions = classDefinition?.properties;
|
|
4406
|
+
const propertyValues = tileset.metadata?.properties;
|
|
5917
4407
|
for (const [propertyIdentifier, propertyDefinition] of Object.entries(propertyDefinitions || {})) {
|
|
5918
4408
|
if (propertyDefinition.semantic === semantic) {
|
|
5919
|
-
return propertyValues
|
|
4409
|
+
return propertyValues?.[propertyIdentifier];
|
|
5920
4410
|
}
|
|
5921
4411
|
}
|
|
5922
4412
|
return void 0;
|
|
@@ -5925,6 +4415,7 @@ function getTilesetSemanticValue(tileset, semantic) {
|
|
|
5925
4415
|
// dist/spatial/spatial-coordinate-transformer.js
|
|
5926
4416
|
var import_core10 = require("@math.gl/core");
|
|
5927
4417
|
var import_geospatial7 = require("@math.gl/geospatial");
|
|
4418
|
+
var import_bulk = require("@math.gl/projection/bulk");
|
|
5928
4419
|
|
|
5929
4420
|
// dist/spatial/spatial-resource-registry.js
|
|
5930
4421
|
var import_geoid = require("@math.gl/geoid");
|
|
@@ -5970,6 +4461,8 @@ var SpatialCoordinateTransformer = class {
|
|
|
5970
4461
|
spatialReference;
|
|
5971
4462
|
/** Projection from the source CRS directly to the requested horizontal target CRS. */
|
|
5972
4463
|
horizontalProjection;
|
|
4464
|
+
/** Reusable packed xyz projection for horizontal-only coordinate batches. */
|
|
4465
|
+
horizontalProjectionBuffer;
|
|
5973
4466
|
/** Projection from the source CRS to geographic longitude, latitude, and ellipsoidal height. */
|
|
5974
4467
|
geographicProjection;
|
|
5975
4468
|
/** Projection from adjusted geographic coordinates to the requested output CRS. */
|
|
@@ -6005,6 +4498,12 @@ var SpatialCoordinateTransformer = class {
|
|
|
6005
4498
|
to: getHorizontalProjectionDefinition(spatialReference.targetCrs),
|
|
6006
4499
|
enforceAxis: false
|
|
6007
4500
|
});
|
|
4501
|
+
if (!requiresHeightTransformation(spatialReference)) {
|
|
4502
|
+
this.horizontalProjectionBuffer = new import_bulk.ProjectionBuffer({
|
|
4503
|
+
projection: this.horizontalProjection,
|
|
4504
|
+
dimension: 3
|
|
4505
|
+
});
|
|
4506
|
+
}
|
|
6008
4507
|
}
|
|
6009
4508
|
if (requiresHeightTransformation(spatialReference) || this.sourceIsGeocentric || this.outputIsGeocentric) {
|
|
6010
4509
|
if (!this.sourceIsGeographic && !this.sourceIsGeocentric) {
|
|
@@ -6060,12 +4559,18 @@ var SpatialCoordinateTransformer = class {
|
|
|
6060
4559
|
}
|
|
6061
4560
|
return result;
|
|
6062
4561
|
}
|
|
6063
|
-
/** Transform
|
|
4562
|
+
/** Transform packed xyz positions into owned Float64 storage, batching finite horizontal transforms. */
|
|
6064
4563
|
transformPositions(positions) {
|
|
6065
4564
|
if (positions.length % 3 !== 0) {
|
|
6066
4565
|
throw new Error("Packed spatial positions must contain a multiple of three components");
|
|
6067
4566
|
}
|
|
6068
4567
|
const transformedPositions = new Float64Array(positions.length);
|
|
4568
|
+
if (this.horizontalProjectionBuffer) {
|
|
4569
|
+
transformedPositions.set(positions);
|
|
4570
|
+
if (transformedPositions.every(Number.isFinite)) {
|
|
4571
|
+
return this.horizontalProjectionBuffer.projectFlatTo(transformedPositions, transformedPositions);
|
|
4572
|
+
}
|
|
4573
|
+
}
|
|
6069
4574
|
for (let index = 0; index < positions.length; index += 3) {
|
|
6070
4575
|
const transformed = this.transformPosition([
|
|
6071
4576
|
Number(positions[index]),
|
|
@@ -6531,7 +5036,6 @@ function createLazyImplicitTileHeader(subtree, descriptor, coordinates) {
|
|
|
6531
5036
|
};
|
|
6532
5037
|
}
|
|
6533
5038
|
function getSubtreeAttributeOverrides(attributes, rowIndex, scope) {
|
|
6534
|
-
var _a, _b;
|
|
6535
5039
|
if (!attributes || rowIndex < 0) {
|
|
6536
5040
|
return {};
|
|
6537
5041
|
}
|
|
@@ -6556,11 +5060,11 @@ function getSubtreeAttributeOverrides(attributes, rowIndex, scope) {
|
|
|
6556
5060
|
if (scope === "content") {
|
|
6557
5061
|
return { boundingVolume };
|
|
6558
5062
|
}
|
|
6559
|
-
const geometricError =
|
|
5063
|
+
const geometricError = getAttributeComponents(attributes.TILE_GEOMETRIC_ERROR, rowIndex, 1)?.[0];
|
|
6560
5064
|
if (geometricError !== void 0 && (!Number.isFinite(geometricError) || geometricError < 0)) {
|
|
6561
5065
|
throw new Error("3DTILES_subtree: TILE_GEOMETRIC_ERROR must be nonnegative");
|
|
6562
5066
|
}
|
|
6563
|
-
const refineValue =
|
|
5067
|
+
const refineValue = getAttributeComponents(attributes.TILE_REFINE, rowIndex, 1)?.[0];
|
|
6564
5068
|
if (refineValue !== void 0 && refineValue !== 0 && refineValue !== 1) {
|
|
6565
5069
|
throw new Error("3DTILES_subtree: TILE_REFINE must be 0 or 1");
|
|
6566
5070
|
}
|
|
@@ -6582,7 +5086,6 @@ function getAttributeComponents(values, rowIndex, componentCount) {
|
|
|
6582
5086
|
return Array.from({ length: componentCount }, (_unused, componentIndex) => Number(values[offset + componentIndex]));
|
|
6583
5087
|
}
|
|
6584
5088
|
function getAvailabilityRank(availability, index) {
|
|
6585
|
-
var _a;
|
|
6586
5089
|
if (availability.constant === 1) {
|
|
6587
5090
|
return index;
|
|
6588
5091
|
}
|
|
@@ -6591,7 +5094,7 @@ function getAvailabilityRank(availability, index) {
|
|
|
6591
5094
|
}
|
|
6592
5095
|
let ranks = AVAILABILITY_RANK_CACHE.get(availability);
|
|
6593
5096
|
if (!ranks) {
|
|
6594
|
-
const bitCount = (
|
|
5097
|
+
const bitCount = (availability.explicitBitstream?.byteLength || 0) * 8;
|
|
6595
5098
|
ranks = new Uint32Array(bitCount + 1);
|
|
6596
5099
|
for (let candidateIndex = 0; candidateIndex < bitCount; candidateIndex++) {
|
|
6597
5100
|
ranks[candidateIndex + 1] = ranks[candidateIndex] + Number(getAvailabilityValue(availability, candidateIndex));
|
|
@@ -6601,12 +5104,11 @@ function getAvailabilityRank(availability, index) {
|
|
|
6601
5104
|
return ranks[index];
|
|
6602
5105
|
}
|
|
6603
5106
|
function findImplicitPackageResource(files, resourceUrl) {
|
|
6604
|
-
|
|
6605
|
-
if (!(files == null ? void 0 : files.length)) {
|
|
5107
|
+
if (!files?.length) {
|
|
6606
5108
|
return void 0;
|
|
6607
5109
|
}
|
|
6608
5110
|
const urlWithoutQuery = resourceUrl.split("?")[0];
|
|
6609
|
-
const packageRelativePath =
|
|
5111
|
+
const packageRelativePath = /^gltf-package:\/\/[^/]+\/(.*)$/.exec(urlWithoutQuery)?.[1];
|
|
6610
5112
|
const exactFileIndex = files.findIndex((file) => {
|
|
6611
5113
|
const reference = file.originalUri || file.name;
|
|
6612
5114
|
return file.uri === urlWithoutQuery || Boolean(reference && (urlWithoutQuery === reference || packageRelativePath === reference));
|
|
@@ -6621,10 +5123,10 @@ function findImplicitPackageResource(files, resourceUrl) {
|
|
|
6621
5123
|
return fileIndex < 0 ? void 0 : { fileIndex, files };
|
|
6622
5124
|
}
|
|
6623
5125
|
function mergeImplicitPackageFiles(parentFiles, childFiles) {
|
|
6624
|
-
if (!
|
|
5126
|
+
if (!childFiles?.length) {
|
|
6625
5127
|
return parentFiles;
|
|
6626
5128
|
}
|
|
6627
|
-
if (!
|
|
5129
|
+
if (!parentFiles?.length) {
|
|
6628
5130
|
return childFiles;
|
|
6629
5131
|
}
|
|
6630
5132
|
const childReferences = new Set(childFiles.flatMap((file) => [file.uri, file.originalUri, file.name].filter(Boolean)));
|
|
@@ -6634,18 +5136,17 @@ function mergeImplicitPackageFiles(parentFiles, childFiles) {
|
|
|
6634
5136
|
];
|
|
6635
5137
|
}
|
|
6636
5138
|
function formatImplicitTileHeader(subtree, descriptor, reference, coordinates, availabilityIndex, contentAvailability, children) {
|
|
6637
|
-
var _a, _b, _c, _d, _e;
|
|
6638
5139
|
const tilePropertyIndex = getAvailabilityRank(subtree.tileAvailability, availabilityIndex);
|
|
6639
|
-
const tileProperties =
|
|
5140
|
+
const tileProperties = subtree.tilePropertyRows?.[tilePropertyIndex];
|
|
6640
5141
|
const primaryContentAvailability = Array.isArray(subtree.contentAvailability) ? subtree.contentAvailability[0] : subtree.contentAvailability;
|
|
6641
5142
|
const contentPropertyIndex = primaryContentAvailability && getAvailabilityValue(primaryContentAvailability, availabilityIndex) ? getAvailabilityRank(primaryContentAvailability, availabilityIndex) : -1;
|
|
6642
|
-
const contentProperties =
|
|
6643
|
-
const tileTemplateProperties =
|
|
6644
|
-
const contentTemplateProperties =
|
|
5143
|
+
const contentProperties = subtree.contentPropertyRows?.[contentPropertyIndex];
|
|
5144
|
+
const tileTemplateProperties = subtree.tileTemplatePropertyRows?.[tilePropertyIndex] || tileProperties;
|
|
5145
|
+
const contentTemplateProperties = subtree.contentTemplatePropertyRows?.[contentPropertyIndex] || contentProperties;
|
|
6645
5146
|
const templateProperties = { ...tileTemplateProperties, ...contentTemplateProperties };
|
|
6646
5147
|
const tileAttributes = getSubtreeAttributeOverrides(subtree.tileAttributes, tilePropertyIndex, "tile");
|
|
6647
5148
|
const contentAttributes = getSubtreeAttributeOverrides(subtree.contentAttributes, contentPropertyIndex, "content");
|
|
6648
|
-
const contentUrlTemplates =
|
|
5149
|
+
const contentUrlTemplates = descriptor.contentUrlTemplates?.length ? descriptor.contentUrlTemplates : [descriptor.contentUrlTemplate];
|
|
6649
5150
|
const contentEntries = contentUrlTemplates.map((templateUrl, contentIndex) => {
|
|
6650
5151
|
if (!contentAvailability[contentIndex] || !templateUrl) {
|
|
6651
5152
|
return null;
|
|
@@ -6662,10 +5163,9 @@ function formatImplicitTileHeader(subtree, descriptor, reference, coordinates, a
|
|
|
6662
5163
|
const availableContentUrls = contentEntries.map((entry) => entry.contentUrl);
|
|
6663
5164
|
const resourceFiles = mergeImplicitPackageFiles(descriptor.resourceFiles, subtree.resourceFiles);
|
|
6664
5165
|
const content = contentEntries.map(({ contentIndex, contentUrl: contentUrl2 }) => {
|
|
6665
|
-
var _a2;
|
|
6666
5166
|
const packageResource = findImplicitPackageResource(resourceFiles, contentUrl2);
|
|
6667
5167
|
return {
|
|
6668
|
-
...
|
|
5168
|
+
...descriptor.contentHeaders?.[contentIndex] || (contentIndex === 0 ? descriptor.contentHeader : {}) || {},
|
|
6669
5169
|
...contentAttributes,
|
|
6670
5170
|
uri: contentUrl2,
|
|
6671
5171
|
...contentProperties ? { metadata: { properties: contentProperties } } : {},
|
|
@@ -6713,10 +5213,10 @@ function getImplicitTileId(reference, coordinates) {
|
|
|
6713
5213
|
return `${reference.subtreeUrl}#implicit=${coordinates.level}/${coordinates.x}/${coordinates.y}/${coordinates.z}`;
|
|
6714
5214
|
}
|
|
6715
5215
|
function getAvailabilityValue(availability, index) {
|
|
6716
|
-
if (typeof
|
|
5216
|
+
if (typeof availability?.constant === "number") {
|
|
6717
5217
|
return Boolean(availability.constant);
|
|
6718
5218
|
}
|
|
6719
|
-
const bitstream = availability
|
|
5219
|
+
const bitstream = availability?.explicitBitstream;
|
|
6720
5220
|
if (!bitstream) {
|
|
6721
5221
|
return false;
|
|
6722
5222
|
}
|
|
@@ -6743,7 +5243,6 @@ function getImplicitChildCount(subdivisionScheme) {
|
|
|
6743
5243
|
return subdivisionScheme === "OCTREE" ? OCTREE_CHILD_COUNT : QUADTREE_CHILD_COUNT;
|
|
6744
5244
|
}
|
|
6745
5245
|
function calculateImplicitBoundingVolume(rootBoundingVolume, coordinates, subdivisionScheme) {
|
|
6746
|
-
var _a;
|
|
6747
5246
|
if (rootBoundingVolume.region) {
|
|
6748
5247
|
const [west, south, east, north, minimumHeight, maximumHeight] = rootBoundingVolume.region;
|
|
6749
5248
|
const divisionCount = 2 ** coordinates.level;
|
|
@@ -6775,7 +5274,7 @@ function calculateImplicitBoundingVolume(rootBoundingVolume, coordinates, subdiv
|
|
|
6775
5274
|
if (rootBoundingVolume.s2VolumeInfo) {
|
|
6776
5275
|
return calculateS2ImplicitBoundingVolume(rootBoundingVolume, coordinates, subdivisionScheme);
|
|
6777
5276
|
}
|
|
6778
|
-
if (
|
|
5277
|
+
if (rootBoundingVolume.extensions?.["3DTILES_shape_cylinder_region"]) {
|
|
6779
5278
|
return {
|
|
6780
5279
|
...rootBoundingVolume,
|
|
6781
5280
|
box: [...rootBoundingVolume.box]
|
|
@@ -6821,10 +5320,10 @@ function calculateS2ImplicitBoundingVolume(rootBoundingVolume, coordinates, subd
|
|
|
6821
5320
|
maximumHeight: rootS2VolumeInfo.minimumHeight + (subdivisionScheme === "OCTREE" ? heightSize * (coordinates.z + 1) : heightSize * divisionCount)
|
|
6822
5321
|
};
|
|
6823
5322
|
const extensions = rootBoundingVolume.extensions ? { ...rootBoundingVolume.extensions } : void 0;
|
|
6824
|
-
if (extensions
|
|
5323
|
+
if (extensions?.["3DTILES_bounding_volume_S2"]) {
|
|
6825
5324
|
extensions["3DTILES_bounding_volume_S2"] = childS2VolumeInfo;
|
|
6826
5325
|
}
|
|
6827
|
-
if (extensions
|
|
5326
|
+
if (extensions?.["3DTILES_shape_s2"]) {
|
|
6828
5327
|
extensions["3DTILES_shape_s2"] = childS2VolumeInfo;
|
|
6829
5328
|
}
|
|
6830
5329
|
return {
|
|
@@ -6845,11 +5344,10 @@ function normalizeRegionLongitude(longitude) {
|
|
|
6845
5344
|
return normalizedLongitude;
|
|
6846
5345
|
}
|
|
6847
5346
|
function getImplicitTileType(contentUrl) {
|
|
6848
|
-
var _a;
|
|
6849
5347
|
if (!contentUrl) {
|
|
6850
5348
|
return TILE_TYPE.EMPTY;
|
|
6851
5349
|
}
|
|
6852
|
-
const extension =
|
|
5350
|
+
const extension = contentUrl.split("?")[0].split(".").pop()?.toLowerCase();
|
|
6853
5351
|
switch (extension) {
|
|
6854
5352
|
case "pnts":
|
|
6855
5353
|
return TILE_TYPE.POINTCLOUD;
|
|
@@ -6944,19 +5442,18 @@ var Tiles3DSource = class {
|
|
|
6944
5442
|
* @param loadOptions Loader options forwarded to tile requests.
|
|
6945
5443
|
*/
|
|
6946
5444
|
constructor(input, loadOptions = {}) {
|
|
6947
|
-
var _a;
|
|
6948
5445
|
const request = normalizeTiles3DRequest(input);
|
|
6949
5446
|
this.rootTileset = isTilesetRequest(input) ? null : input;
|
|
6950
5447
|
this.tileset = this.rootTileset;
|
|
6951
5448
|
this.loader = request.loader;
|
|
6952
5449
|
this.url = request.url;
|
|
6953
|
-
this.basePath = request.basePath ||
|
|
5450
|
+
this.basePath = request.basePath || import_loader_utils6.path.dirname(request.url);
|
|
6954
5451
|
this.resolver = request.resolver;
|
|
6955
5452
|
this.coreApi = request.coreApi;
|
|
6956
5453
|
this.loadOptions = loadOptions;
|
|
6957
|
-
const maximumCachedSubtrees = Number(
|
|
5454
|
+
const maximumCachedSubtrees = Number(loadOptions["3d-tiles"]?.maximumCachedSubtrees);
|
|
6958
5455
|
const maximumCacheEntries = Number.isFinite(maximumCachedSubtrees) ? Math.max(0, Math.floor(maximumCachedSubtrees)) : DEFAULT_MAXIMUM_CACHED_SUBTREES;
|
|
6959
|
-
this.implicitSubtreeCache = new RequestCache({ maxEntries: maximumCacheEntries });
|
|
5456
|
+
this.implicitSubtreeCache = new import_loader_utils6.RequestCache({ maxEntries: maximumCacheEntries });
|
|
6960
5457
|
}
|
|
6961
5458
|
/**
|
|
6962
5459
|
* Releases URL and parsed-subtree caches and blocks late subtree installation.
|
|
@@ -6973,7 +5470,6 @@ var Tiles3DSource = class {
|
|
|
6973
5470
|
* Fetches and validates top-level metadata, then normalizes common fields used by {@link Tileset3D}.
|
|
6974
5471
|
*/
|
|
6975
5472
|
async initialize() {
|
|
6976
|
-
var _a;
|
|
6977
5473
|
if (!this.rootTileset) {
|
|
6978
5474
|
const loaderOptions = this.loadOptions[this.loader.id] || {};
|
|
6979
5475
|
this.rootTileset = await this.loadRootData(this.url, {
|
|
@@ -7013,7 +5509,7 @@ var Tiles3DSource = class {
|
|
|
7013
5509
|
tileset: this.rootTileset,
|
|
7014
5510
|
lodMetricType: this.rootTileset.lodMetricType,
|
|
7015
5511
|
lodMetricValue: this.rootTileset.lodMetricValue,
|
|
7016
|
-
refine:
|
|
5512
|
+
refine: this.rootTileset.root?.refine,
|
|
7017
5513
|
spatialReference: get3DTilesSpatialReference(this.rootTileset)
|
|
7018
5514
|
};
|
|
7019
5515
|
}
|
|
@@ -7049,7 +5545,6 @@ var Tiles3DSource = class {
|
|
|
7049
5545
|
* Builds explicit runtime headers while leaving implicit subtree references lazy.
|
|
7050
5546
|
*/
|
|
7051
5547
|
initializeTileHeaders(tileset, tilesetJson, parentTile) {
|
|
7052
|
-
var _a;
|
|
7053
5548
|
const rootHeader = parentTile ? tilesetJson.root : this.preparedRootHeader || tilesetJson.root;
|
|
7054
5549
|
const rootTile = new Tile3D(tileset, rootHeader, parentTile || void 0);
|
|
7055
5550
|
if (parentTile) {
|
|
@@ -7063,7 +5558,7 @@ var Tiles3DSource = class {
|
|
|
7063
5558
|
const children = tile.header.children || [];
|
|
7064
5559
|
for (const childHeader of children) {
|
|
7065
5560
|
const childTile = new Tile3D(tileset, childHeader, tile);
|
|
7066
|
-
if (
|
|
5561
|
+
if (childTile.contentUrl?.includes("?session=")) {
|
|
7067
5562
|
const url = new URL(childTile.contentUrl);
|
|
7068
5563
|
const session = url.searchParams.get("session");
|
|
7069
5564
|
if (session) {
|
|
@@ -7087,10 +5582,9 @@ var Tiles3DSource = class {
|
|
|
7087
5582
|
* Loads binary content or nested tileset JSON for a runtime tile.
|
|
7088
5583
|
*/
|
|
7089
5584
|
async loadTileContent(tile) {
|
|
7090
|
-
var _a, _b, _c, _d, _e, _f;
|
|
7091
5585
|
const contentUrls = (tile.contentUrls || [tile.contentUrl]).filter(Boolean);
|
|
7092
5586
|
const cachedContentHeaders = this.tileContentHeaders.get(tile);
|
|
7093
|
-
const contentHeaders = cachedContentHeaders || (Array.isArray(
|
|
5587
|
+
const contentHeaders = cachedContentHeaders || (Array.isArray(tile.header?.content) ? tile.header.content : tile.header?.content ? [tile.header.content] : []);
|
|
7094
5588
|
if (!cachedContentHeaders) {
|
|
7095
5589
|
this.tileContentHeaders.set(tile, contentHeaders);
|
|
7096
5590
|
}
|
|
@@ -7104,17 +5598,16 @@ var Tiles3DSource = class {
|
|
|
7104
5598
|
isTileset: "auto",
|
|
7105
5599
|
assetGltfUpAxis: this.asset && this.asset.gltfUpAxis || "Y",
|
|
7106
5600
|
_tilesetOptions: {
|
|
7107
|
-
spatialReference:
|
|
7108
|
-
spatialOptions:
|
|
7109
|
-
spatialTransform:
|
|
5601
|
+
spatialReference: tile.header?._spatialReference || tile.tileset?.spatialReference,
|
|
5602
|
+
spatialOptions: tile.tileset?.options.spatial,
|
|
5603
|
+
spatialTransform: tile.header?._spatialTransform
|
|
7110
5604
|
}
|
|
7111
5605
|
}
|
|
7112
5606
|
};
|
|
7113
5607
|
const contents = await Promise.all(contentUrls.map((contentUrl, contentIndex) => {
|
|
7114
|
-
var _a2;
|
|
7115
5608
|
const contentHeader = contentHeaders[contentIndex] || {};
|
|
7116
|
-
const vectorExtension =
|
|
7117
|
-
const vectorContent = contentHeader._vectorContent || (
|
|
5609
|
+
const vectorExtension = contentHeader.extensions?.["3DTILES_content_gltf_vector"];
|
|
5610
|
+
const vectorContent = contentHeader._vectorContent || (vectorExtension?.vector === true ? { clip: vectorExtension.clip === true } : void 0);
|
|
7118
5611
|
const contentOptions = vectorContent ? {
|
|
7119
5612
|
...options,
|
|
7120
5613
|
[this.loader.id]: {
|
|
@@ -7126,7 +5619,7 @@ var Tiles3DSource = class {
|
|
|
7126
5619
|
}));
|
|
7127
5620
|
tile.contents = contents;
|
|
7128
5621
|
tile.content = contents[0] || null;
|
|
7129
|
-
const nestedTilesets = contents.filter((content) =>
|
|
5622
|
+
const nestedTilesets = contents.filter((content) => content?.shape === "tileset3d");
|
|
7130
5623
|
return {
|
|
7131
5624
|
loaded: true,
|
|
7132
5625
|
contents,
|
|
@@ -7315,10 +5808,7 @@ var Tiles3DSource = class {
|
|
|
7315
5808
|
*/
|
|
7316
5809
|
onTileLoaded(tileset, tile, loadResult) {
|
|
7317
5810
|
const contents = tile.contents.length ? tile.contents : [tile.content];
|
|
7318
|
-
const extensionsRemoved = contents.flatMap((content) =>
|
|
7319
|
-
var _a;
|
|
7320
|
-
return ((_a = content == null ? void 0 : content.gltf) == null ? void 0 : _a.extensionsRemoved) || [];
|
|
7321
|
-
});
|
|
5811
|
+
const extensionsRemoved = contents.flatMap((content) => content?.gltf?.extensionsRemoved || []);
|
|
7322
5812
|
if (extensionsRemoved.includes("KHR_draco_mesh_compression")) {
|
|
7323
5813
|
this.contentFormats.draco = true;
|
|
7324
5814
|
}
|
|
@@ -7355,7 +5845,7 @@ var Tiles3DSource = class {
|
|
|
7355
5845
|
prepareNestedTileset(tileset, nestedTileset) {
|
|
7356
5846
|
const nestedSpatialReference = nestedTileset.spatialMetadata;
|
|
7357
5847
|
const parentSpatialReference = tileset.spatialReference;
|
|
7358
|
-
if (
|
|
5848
|
+
if (nestedSpatialReference?.status === "unresolved" || nestedSpatialReference?.crs.state === "unknown") {
|
|
7359
5849
|
throw new Error(nestedSpatialReference.warnings[0] || "Nested 3D Tiles CRS is explicitly unresolved and cannot be placed in the parent frame");
|
|
7360
5850
|
}
|
|
7361
5851
|
if (!nestedSpatialReference || !nestedSpatialReference.sourceCrs) {
|
|
@@ -7480,7 +5970,7 @@ var Tiles3DSource = class {
|
|
|
7480
5970
|
/** Resolves a retained package-file byte range without eagerly copying other package files. */
|
|
7481
5971
|
async getPackageFileData(file) {
|
|
7482
5972
|
if (file.data) {
|
|
7483
|
-
return sliceArrayBuffer(file.data, file.byteOffset, file.byteLength);
|
|
5973
|
+
return (0, import_loader_utils6.sliceArrayBuffer)(file.data, file.byteOffset, file.byteLength);
|
|
7484
5974
|
}
|
|
7485
5975
|
if (file.bufferUri && this.coreApi) {
|
|
7486
5976
|
const response = await this.coreApi.fetchFile(this.getTileUrl(file.bufferUri));
|
|
@@ -7488,7 +5978,7 @@ var Tiles3DSource = class {
|
|
|
7488
5978
|
throw new Error(`Failed to fetch 3D Tiles package buffer: HTTP ${response.status}`);
|
|
7489
5979
|
}
|
|
7490
5980
|
const buffer = await response.arrayBuffer();
|
|
7491
|
-
return sliceArrayBuffer(buffer, file.byteOffset, file.byteLength);
|
|
5981
|
+
return (0, import_loader_utils6.sliceArrayBuffer)(buffer, file.byteOffset, file.byteLength);
|
|
7492
5982
|
}
|
|
7493
5983
|
throw new Error("3D Tiles package file has no available byte source");
|
|
7494
5984
|
}
|
|
@@ -7528,7 +6018,6 @@ var Tiles3DSource = class {
|
|
|
7528
6018
|
* @returns Number of newly allocated runtime tile nodes.
|
|
7529
6019
|
*/
|
|
7530
6020
|
initializeMaterializedChildren(tileset, parentTile, childHeaders) {
|
|
7531
|
-
var _a;
|
|
7532
6021
|
let materializedTileCount = 0;
|
|
7533
6022
|
const stack = [
|
|
7534
6023
|
{ parentTile, childHeaders }
|
|
@@ -7541,7 +6030,7 @@ var Tiles3DSource = class {
|
|
|
7541
6030
|
childTile.depth = entry.parentTile.depth + 1;
|
|
7542
6031
|
tileset.stats.get("Tiles In Tileset(s)").incrementCount();
|
|
7543
6032
|
materializedTileCount++;
|
|
7544
|
-
if (
|
|
6033
|
+
if (childHeader.children?.length) {
|
|
7545
6034
|
stack.push({ parentTile: childTile, childHeaders: childHeader.children });
|
|
7546
6035
|
}
|
|
7547
6036
|
}
|
|
@@ -7550,7 +6039,7 @@ var Tiles3DSource = class {
|
|
|
7550
6039
|
}
|
|
7551
6040
|
};
|
|
7552
6041
|
function throwIfTraversalAborted(signal) {
|
|
7553
|
-
if (signal
|
|
6042
|
+
if (signal?.aborted) {
|
|
7554
6043
|
throw signal.reason ?? new DOMException("The operation was aborted", "AbortError");
|
|
7555
6044
|
}
|
|
7556
6045
|
}
|
|
@@ -7561,13 +6050,13 @@ function normalizeTiles3DRequest(input) {
|
|
|
7561
6050
|
if (isTilesetRequest(input)) {
|
|
7562
6051
|
return {
|
|
7563
6052
|
...input,
|
|
7564
|
-
basePath: input.basePath ||
|
|
6053
|
+
basePath: input.basePath || import_loader_utils6.path.dirname(input.url)
|
|
7565
6054
|
};
|
|
7566
6055
|
}
|
|
7567
6056
|
return {
|
|
7568
6057
|
url: input.url,
|
|
7569
6058
|
loader: input.loader,
|
|
7570
|
-
basePath: input.basePath ||
|
|
6059
|
+
basePath: input.basePath || import_loader_utils6.path.dirname(input.url),
|
|
7571
6060
|
resolver: input.resolver,
|
|
7572
6061
|
coreApi: input.coreApi
|
|
7573
6062
|
};
|
|
@@ -7586,6 +6075,7 @@ function addNestedSpatialReference(nestedTileset, spatialReference) {
|
|
|
7586
6075
|
}
|
|
7587
6076
|
|
|
7588
6077
|
// dist/tileset-3d/format-i3s/i3s-source.js
|
|
6078
|
+
var import_loader_utils7 = require("@loaders.gl/loader-utils");
|
|
7589
6079
|
var import_geospatial11 = require("@math.gl/geospatial");
|
|
7590
6080
|
var import_core14 = require("@math.gl/core");
|
|
7591
6081
|
|
|
@@ -7623,8 +6113,7 @@ var I3SPendingTilesRegister = class {
|
|
|
7623
6113
|
* @returns
|
|
7624
6114
|
*/
|
|
7625
6115
|
isZero(viewportId, frameNumber) {
|
|
7626
|
-
|
|
7627
|
-
const count = ((_a = this.frameNumberMap.get(viewportId)) == null ? void 0 : _a.get(frameNumber)) || 0;
|
|
6116
|
+
const count = this.frameNumberMap.get(viewportId)?.get(frameNumber) || 0;
|
|
7628
6117
|
return count === 0;
|
|
7629
6118
|
}
|
|
7630
6119
|
};
|
|
@@ -7723,10 +6212,7 @@ var I3STilesetTraverser = class extends TilesetTraverser {
|
|
|
7723
6212
|
const childTiles = tile.children;
|
|
7724
6213
|
for (const child of children) {
|
|
7725
6214
|
const extendedId = `${child.id}-${frameState.viewport.id}`;
|
|
7726
|
-
const childTile = childTiles && childTiles.find((t) =>
|
|
7727
|
-
var _a;
|
|
7728
|
-
return t.id === extendedId || ((_a = t.header) == null ? void 0 : _a.id) === child.id;
|
|
7729
|
-
});
|
|
6215
|
+
const childTile = childTiles && childTiles.find((t) => t.id === extendedId || t.header?.id === child.id);
|
|
7730
6216
|
if (!childTile) {
|
|
7731
6217
|
const request = () => this._loadTile(tile, child.id, frameState);
|
|
7732
6218
|
const cachedRequest = this._tileManager.find(extendedId);
|
|
@@ -7805,7 +6291,6 @@ var I3SSpatialTransformer = class {
|
|
|
7805
6291
|
* @param options - Registered geoid and custom resource options used by the shared transformer.
|
|
7806
6292
|
*/
|
|
7807
6293
|
constructor(spatialReference, options = {}) {
|
|
7808
|
-
var _a;
|
|
7809
6294
|
if (spatialReference.status !== "transformable" && spatialReference.status !== "transformed") {
|
|
7810
6295
|
throw new Error("I3SSpatialTransformer requires a requested, transformable spatial output");
|
|
7811
6296
|
}
|
|
@@ -7822,7 +6307,7 @@ var I3SSpatialTransformer = class {
|
|
|
7822
6307
|
if (this.elevationProvider && (typeof this.elevationProvider.sampleElevations !== "function" || typeof this.elevationProvider.getElevationRange !== "function")) {
|
|
7823
6308
|
throw new Error("An I3S elevation provider must implement sampleElevations() and getElevationRange()");
|
|
7824
6309
|
}
|
|
7825
|
-
const providerUnitScale = getI3SLinearUnitScale(
|
|
6310
|
+
const providerUnitScale = getI3SLinearUnitScale(this.elevationProvider?.unit || "meter");
|
|
7826
6311
|
if (this.elevationProvider && providerUnitScale === void 0) {
|
|
7827
6312
|
throw new Error(`Unsupported elevation-provider unit ${this.elevationProvider.unit}`);
|
|
7828
6313
|
}
|
|
@@ -8081,14 +6566,13 @@ var I3SSpatialTransformer = class {
|
|
|
8081
6566
|
}
|
|
8082
6567
|
/** Return a WGS84 geographic MBS used by the I3S screen-threshold calculation. */
|
|
8083
6568
|
transformBoundingSphereToGeographic(bounds) {
|
|
8084
|
-
|
|
8085
|
-
const sourceCenter = ((_a = bounds.mbs) == null ? void 0 : _a.length) ? Array.from(bounds.mbs).slice(0, 3) : bounds.obb ? Array.from(bounds.obb.center).slice(0, 3) : null;
|
|
6569
|
+
const sourceCenter = bounds.mbs?.length ? Array.from(bounds.mbs).slice(0, 3) : bounds.obb ? Array.from(bounds.obb.center).slice(0, 3) : null;
|
|
8086
6570
|
if (!sourceCenter) {
|
|
8087
6571
|
throw new Error("I3S spatial transformation requires an MBS or OBB bound");
|
|
8088
6572
|
}
|
|
8089
6573
|
const placedCenter = this.placeSourcePositionsSync(sourceCenter);
|
|
8090
6574
|
const geographicCenter = this.sourceToGeographicTransformer.transformPosition(Array.from(placedCenter));
|
|
8091
|
-
const radius =
|
|
6575
|
+
const radius = bounds.mbs?.length ? bounds.mbs[3] : Math.hypot(...Array.from(bounds.obb.halfSize).slice(0, 3));
|
|
8092
6576
|
return [geographicCenter[0], geographicCenter[1], geographicCenter[2], radius];
|
|
8093
6577
|
}
|
|
8094
6578
|
/** Return a placed WGS84 MBS used by the I3S screen-threshold calculation. */
|
|
@@ -8472,7 +6956,7 @@ var I3SSource = class {
|
|
|
8472
6956
|
this.loader = request.loader;
|
|
8473
6957
|
this.contentLoader = getI3SContentLoader(request.loader);
|
|
8474
6958
|
this.url = request.url;
|
|
8475
|
-
this.basePath = request.basePath ||
|
|
6959
|
+
this.basePath = request.basePath || import_loader_utils7.path.dirname(request.url);
|
|
8476
6960
|
this.resolver = request.resolver;
|
|
8477
6961
|
this.coreApi = request.coreApi;
|
|
8478
6962
|
this.loadOptions = loadOptions;
|
|
@@ -8482,7 +6966,6 @@ var I3SSource = class {
|
|
|
8482
6966
|
* Fetches and normalizes root I3S metadata for runtime consumption.
|
|
8483
6967
|
*/
|
|
8484
6968
|
async initialize() {
|
|
8485
|
-
var _a;
|
|
8486
6969
|
if (!this.rootTileset) {
|
|
8487
6970
|
this.rootTileset = await this.loadRootData(this.getTileUrl(this.url), {
|
|
8488
6971
|
...this.loadOptions,
|
|
@@ -8501,7 +6984,7 @@ var I3SSource = class {
|
|
|
8501
6984
|
tileset: this.rootTileset,
|
|
8502
6985
|
lodMetricType: this.rootTileset.lodMetricType,
|
|
8503
6986
|
lodMetricValue: this.rootTileset.lodMetricValue,
|
|
8504
|
-
refine:
|
|
6987
|
+
refine: this.rootTileset.root?.refine,
|
|
8505
6988
|
spatialReference: getI3SSpatialReference(this.rootTileset)
|
|
8506
6989
|
};
|
|
8507
6990
|
}
|
|
@@ -8635,10 +7118,7 @@ var I3SSource = class {
|
|
|
8635
7118
|
if (typeof childId !== "string" && typeof childId !== "number") {
|
|
8636
7119
|
throw new Error("I3S child header is missing its node ID");
|
|
8637
7120
|
}
|
|
8638
|
-
const existingChild = parentTile.children.find((tile) =>
|
|
8639
|
-
var _a;
|
|
8640
|
-
return tile.id === String(childId) || ((_a = tile.header) == null ? void 0 : _a.id) === childId;
|
|
8641
|
-
});
|
|
7121
|
+
const existingChild = parentTile.children.find((tile) => tile.id === String(childId) || tile.header?.id === childId);
|
|
8642
7122
|
if (existingChild) {
|
|
8643
7123
|
orderedChildren.push(existingChild);
|
|
8644
7124
|
continue;
|
|
@@ -8670,7 +7150,7 @@ var I3SSource = class {
|
|
|
8670
7150
|
const hash = hashIndex >= 0 ? tilePath.slice(hashIndex) : "";
|
|
8671
7151
|
const tilePathWithoutHash = hashIndex >= 0 ? tilePath.slice(0, hashIndex) : tilePath;
|
|
8672
7152
|
const queryDelimiterIndex = tilePathWithoutHash.indexOf("?");
|
|
8673
|
-
const
|
|
7153
|
+
const path4 = queryDelimiterIndex === -1 ? tilePathWithoutHash : tilePathWithoutHash.slice(0, queryDelimiterIndex);
|
|
8674
7154
|
const existingQuery = queryDelimiterIndex === -1 ? "" : tilePathWithoutHash.slice(queryDelimiterIndex + 1);
|
|
8675
7155
|
const existingQueryParams = new URLSearchParams(existingQuery);
|
|
8676
7156
|
const queryParams = new URLSearchParams();
|
|
@@ -8680,13 +7160,12 @@ var I3SSource = class {
|
|
|
8680
7160
|
}
|
|
8681
7161
|
}
|
|
8682
7162
|
const queryString = queryParams.toString();
|
|
8683
|
-
return `${
|
|
7163
|
+
return `${path4}${existingQuery ? `?${existingQuery}` : ""}${queryString ? `${existingQuery ? "&" : "?"}${queryString}` : ""}${hash}`;
|
|
8684
7164
|
}
|
|
8685
7165
|
/**
|
|
8686
7166
|
* Derives the default view state from full extent or store extent metadata.
|
|
8687
7167
|
*/
|
|
8688
7168
|
getViewState(rootTile) {
|
|
8689
|
-
var _a;
|
|
8690
7169
|
if (this.spatialTransformer && rootTile) {
|
|
8691
7170
|
const center = new import_core14.Vector3(rootTile.boundingVolume.center);
|
|
8692
7171
|
const cartographicCenter = new import_core14.Vector3(rootTile.header.i3sLodMbs.slice(0, 3));
|
|
@@ -8718,7 +7197,7 @@ var I3SSource = class {
|
|
|
8718
7197
|
zoom: getZoomFromFullExtent(fullExtent, cartographicCenter, cartesianCenter)
|
|
8719
7198
|
};
|
|
8720
7199
|
}
|
|
8721
|
-
const extent =
|
|
7200
|
+
const extent = metadata.tileset.store?.extent;
|
|
8722
7201
|
if (extent) {
|
|
8723
7202
|
const [xmin, ymin, xmax, ymax] = extent;
|
|
8724
7203
|
const cartographicCenter = new import_core14.Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, 0);
|
|
@@ -8757,9 +7236,8 @@ var I3SSource = class {
|
|
|
8757
7236
|
* Returns the total number of known tiles when node pages metadata is available.
|
|
8758
7237
|
*/
|
|
8759
7238
|
getTilesTotalCount() {
|
|
8760
|
-
var _a, _b;
|
|
8761
7239
|
const metadata = this.getMetadata();
|
|
8762
|
-
return
|
|
7240
|
+
return metadata.tileset?.nodePagesTile?.nodesInNodePages || null;
|
|
8763
7241
|
}
|
|
8764
7242
|
/**
|
|
8765
7243
|
* Loads data through injected core APIs so this module stays independent from `@loaders.gl/core`.
|
|
@@ -8806,14 +7284,13 @@ var I3SSource = class {
|
|
|
8806
7284
|
}
|
|
8807
7285
|
/** Transform one I3S header bound after target options and elevation providers are available. */
|
|
8808
7286
|
async transformTileHeader(header) {
|
|
8809
|
-
var _a;
|
|
8810
7287
|
if (!this.spatialTransformer) {
|
|
8811
7288
|
return header;
|
|
8812
7289
|
}
|
|
8813
7290
|
const sourceBounds = {
|
|
8814
7291
|
mbs: header.mbs,
|
|
8815
7292
|
obb: header.obb,
|
|
8816
|
-
normalReferenceFrame:
|
|
7293
|
+
normalReferenceFrame: this.getMetadata().tileset.store?.normalReferenceFrame
|
|
8817
7294
|
};
|
|
8818
7295
|
const transformedBounds = await this.spatialTransformer.transformBoundsAsync(sourceBounds);
|
|
8819
7296
|
return {
|
|
@@ -8827,7 +7304,7 @@ var I3SSource = class {
|
|
|
8827
7304
|
}
|
|
8828
7305
|
};
|
|
8829
7306
|
function throwIfTraversalAborted2(signal) {
|
|
8830
|
-
if (signal
|
|
7307
|
+
if (signal?.aborted) {
|
|
8831
7308
|
throw signal.reason ?? new DOMException("The operation was aborted", "AbortError");
|
|
8832
7309
|
}
|
|
8833
7310
|
}
|
|
@@ -8841,13 +7318,13 @@ function normalizeI3SRequest(input) {
|
|
|
8841
7318
|
if (isTilesetRequest2(input)) {
|
|
8842
7319
|
return {
|
|
8843
7320
|
...input,
|
|
8844
|
-
basePath: input.basePath ||
|
|
7321
|
+
basePath: input.basePath || import_loader_utils7.path.dirname(input.url)
|
|
8845
7322
|
};
|
|
8846
7323
|
}
|
|
8847
7324
|
return {
|
|
8848
7325
|
url: input.url,
|
|
8849
7326
|
loader: input.loader,
|
|
8850
|
-
basePath: input.basePath ||
|
|
7327
|
+
basePath: input.basePath || import_loader_utils7.path.dirname(input.url),
|
|
8851
7328
|
resolver: input.resolver,
|
|
8852
7329
|
coreApi: input.coreApi
|
|
8853
7330
|
};
|
|
@@ -9010,12 +7487,11 @@ var SharedTile2DHeader = class {
|
|
|
9010
7487
|
}
|
|
9011
7488
|
/** Cancels an in-flight tile request. */
|
|
9012
7489
|
abort() {
|
|
9013
|
-
var _a;
|
|
9014
7490
|
if (this.isLoaded) {
|
|
9015
7491
|
return;
|
|
9016
7492
|
}
|
|
9017
7493
|
this._isCancelled = true;
|
|
9018
|
-
|
|
7494
|
+
this._abortController?.abort();
|
|
9019
7495
|
}
|
|
9020
7496
|
};
|
|
9021
7497
|
function normalizeTileError(error) {
|
|
@@ -9029,7 +7505,7 @@ function normalizeTileError(error) {
|
|
|
9029
7505
|
}
|
|
9030
7506
|
|
|
9031
7507
|
// dist/tileset-2d/tileset-2d.js
|
|
9032
|
-
var
|
|
7508
|
+
var import_loader_utils8 = require("@loaders.gl/loader-utils");
|
|
9033
7509
|
var STRATEGY_NEVER = "never";
|
|
9034
7510
|
var STRATEGY_REPLACE = "no-overlap";
|
|
9035
7511
|
var STRATEGY_DEFAULT = "best-available";
|
|
@@ -9076,7 +7552,7 @@ var Tileset2D = class _Tileset2D {
|
|
|
9076
7552
|
_lastTileContext = null;
|
|
9077
7553
|
/** Creates a tileset from either `getTileData` or a loaders.gl `TileSource`. */
|
|
9078
7554
|
constructor(opts) {
|
|
9079
|
-
this.stats = new
|
|
7555
|
+
this.stats = new Stats({
|
|
9080
7556
|
id: "Tileset2D",
|
|
9081
7557
|
stats: [
|
|
9082
7558
|
{ name: "Tiles In Cache" },
|
|
@@ -9094,7 +7570,7 @@ var Tileset2D = class _Tileset2D {
|
|
|
9094
7570
|
getTileData: opts.getTileData || (() => null),
|
|
9095
7571
|
tileSource: opts.tileSource
|
|
9096
7572
|
};
|
|
9097
|
-
this._requestScheduler = new RequestScheduler({
|
|
7573
|
+
this._requestScheduler = new import_loader_utils8.RequestScheduler({
|
|
9098
7574
|
throttleRequests: this.opts.maxRequests > 0 || this.opts.debounceTime > 0,
|
|
9099
7575
|
maxRequests: this.opts.maxRequests,
|
|
9100
7576
|
debounceTime: this.opts.debounceTime
|
|
@@ -9187,7 +7663,7 @@ var Tileset2D = class _Tileset2D {
|
|
|
9187
7663
|
const previousDebounceTime = this.opts.debounceTime;
|
|
9188
7664
|
this._applyResolvedOptions();
|
|
9189
7665
|
if (previousMaxRequests !== this.opts.maxRequests || previousDebounceTime !== this.opts.debounceTime) {
|
|
9190
|
-
this._requestScheduler = new RequestScheduler({
|
|
7666
|
+
this._requestScheduler = new import_loader_utils8.RequestScheduler({
|
|
9191
7667
|
throttleRequests: this.opts.maxRequests > 0 || this.opts.debounceTime > 0,
|
|
9192
7668
|
maxRequests: this.opts.maxRequests,
|
|
9193
7669
|
debounceTime: this.opts.debounceTime
|
|
@@ -9371,51 +7847,45 @@ var Tileset2D = class _Tileset2D {
|
|
|
9371
7847
|
}
|
|
9372
7848
|
/** Handles successful tile loads. */
|
|
9373
7849
|
_handleTileLoad(tile) {
|
|
9374
|
-
|
|
9375
|
-
(_b = (_a = this.opts).onTileLoad) == null ? void 0 : _b.call(_a, tile);
|
|
7850
|
+
this.opts.onTileLoad?.(tile);
|
|
9376
7851
|
this._cacheByteSize = this._getCacheByteSize();
|
|
9377
7852
|
this._resizeCache();
|
|
9378
7853
|
for (const listener of this._listeners) {
|
|
9379
|
-
|
|
7854
|
+
listener.onTileLoad?.(tile);
|
|
9380
7855
|
}
|
|
9381
7856
|
this._updateStats();
|
|
9382
7857
|
}
|
|
9383
7858
|
/** Handles tile load failures. */
|
|
9384
7859
|
_handleTileError(error, tile) {
|
|
9385
|
-
|
|
9386
|
-
(_b = (_a = this.opts).onTileError) == null ? void 0 : _b.call(_a, error, tile);
|
|
7860
|
+
this.opts.onTileError?.(error, tile);
|
|
9387
7861
|
for (const listener of this._listeners) {
|
|
9388
|
-
|
|
7862
|
+
listener.onTileError?.(error, tile);
|
|
9389
7863
|
}
|
|
9390
7864
|
this._updateStats();
|
|
9391
7865
|
}
|
|
9392
7866
|
/** Handles tile eviction from cache. */
|
|
9393
7867
|
_handleTileUnload(tile) {
|
|
9394
|
-
var _a, _b, _c;
|
|
9395
7868
|
this._unloadedTileCount++;
|
|
9396
|
-
|
|
7869
|
+
this.opts.onTileUnload?.(tile);
|
|
9397
7870
|
for (const listener of this._listeners) {
|
|
9398
|
-
|
|
7871
|
+
listener.onTileUnload?.(tile);
|
|
9399
7872
|
}
|
|
9400
7873
|
this._updateStats();
|
|
9401
7874
|
}
|
|
9402
7875
|
/** Notifies listeners that metadata or effective options changed. */
|
|
9403
7876
|
_notifyUpdate() {
|
|
9404
|
-
var _a;
|
|
9405
7877
|
for (const listener of this._listeners) {
|
|
9406
|
-
|
|
7878
|
+
listener.onUpdate?.();
|
|
9407
7879
|
}
|
|
9408
7880
|
}
|
|
9409
7881
|
/** Notifies listeners about asynchronous metadata errors. */
|
|
9410
7882
|
_notifyError(error) {
|
|
9411
|
-
var _a;
|
|
9412
7883
|
for (const listener of this._listeners) {
|
|
9413
|
-
|
|
7884
|
+
listener.onError?.(error);
|
|
9414
7885
|
}
|
|
9415
7886
|
}
|
|
9416
7887
|
/** Recomputes absolute counter stats and notifies listeners. */
|
|
9417
7888
|
_updateStats() {
|
|
9418
|
-
var _a;
|
|
9419
7889
|
this._setStatCount("Tiles In Cache", this._cache.size);
|
|
9420
7890
|
this._setStatCount("Cache Size", this.cacheByteSize);
|
|
9421
7891
|
this._setStatCount("Visible Tiles", this.visibleTiles.length);
|
|
@@ -9424,7 +7894,7 @@ var Tileset2D = class _Tileset2D {
|
|
|
9424
7894
|
this._setStatCount("Unloaded Tiles", this._unloadedTileCount);
|
|
9425
7895
|
this._setStatCount("Consumers", this._consumers.size);
|
|
9426
7896
|
for (const listener of this._listeners) {
|
|
9427
|
-
|
|
7897
|
+
listener.onStatsChange?.(this.stats);
|
|
9428
7898
|
}
|
|
9429
7899
|
}
|
|
9430
7900
|
/** Writes an absolute count into a probe.gl stat. */
|
|
@@ -9498,7 +7968,7 @@ var Tileset2D = class _Tileset2D {
|
|
|
9498
7968
|
for (const tile of this._cache.values()) {
|
|
9499
7969
|
const parent = this._getNearestAncestor(tile);
|
|
9500
7970
|
tile.parent = parent;
|
|
9501
|
-
if (parent
|
|
7971
|
+
if (parent?.children) {
|
|
9502
7972
|
parent.children.push(tile);
|
|
9503
7973
|
}
|
|
9504
7974
|
}
|
|
@@ -9586,8 +8056,7 @@ var ImageSet = class _ImageSet {
|
|
|
9586
8056
|
}
|
|
9587
8057
|
/** Current accepted image, if any. */
|
|
9588
8058
|
get image() {
|
|
9589
|
-
|
|
9590
|
-
return ((_a = this._currentRequest) == null ? void 0 : _a.image) || null;
|
|
8059
|
+
return this._currentRequest?.image || null;
|
|
9591
8060
|
}
|
|
9592
8061
|
/** Current accepted request and image payload, if any. */
|
|
9593
8062
|
get currentRequest() {
|
|
@@ -9619,7 +8088,6 @@ var ImageSet = class _ImageSet {
|
|
|
9619
8088
|
}
|
|
9620
8089
|
/** Loads metadata from the current image source or callbacks. */
|
|
9621
8090
|
async loadMetadata() {
|
|
9622
|
-
var _a, _b;
|
|
9623
8091
|
this._startLoading();
|
|
9624
8092
|
try {
|
|
9625
8093
|
const metadata = await this._opts.getMetadata();
|
|
@@ -9628,7 +8096,7 @@ var ImageSet = class _ImageSet {
|
|
|
9628
8096
|
}
|
|
9629
8097
|
this.metadata = metadata;
|
|
9630
8098
|
for (const listener of this._listeners) {
|
|
9631
|
-
|
|
8099
|
+
listener.onMetadataLoad?.(metadata);
|
|
9632
8100
|
}
|
|
9633
8101
|
this._emitUpdate();
|
|
9634
8102
|
return metadata;
|
|
@@ -9636,7 +8104,7 @@ var ImageSet = class _ImageSet {
|
|
|
9636
8104
|
const normalizedError = normalizeImageSetError(error, "Image metadata request failed");
|
|
9637
8105
|
if (!this._finalized) {
|
|
9638
8106
|
for (const listener of this._listeners) {
|
|
9639
|
-
|
|
8107
|
+
listener.onMetadataLoadError?.(normalizedError);
|
|
9640
8108
|
}
|
|
9641
8109
|
}
|
|
9642
8110
|
throw normalizedError;
|
|
@@ -9668,13 +8136,12 @@ var ImageSet = class _ImageSet {
|
|
|
9668
8136
|
}
|
|
9669
8137
|
/** Loads an image immediately and accepts it only if it is the newest completed request. */
|
|
9670
8138
|
async _loadImage(requestId, parameters) {
|
|
9671
|
-
var _a, _b, _c, _d;
|
|
9672
8139
|
if (this._finalized) {
|
|
9673
8140
|
return;
|
|
9674
8141
|
}
|
|
9675
8142
|
this._startLoading();
|
|
9676
8143
|
for (const listener of this._listeners) {
|
|
9677
|
-
|
|
8144
|
+
listener.onImageLoadStart?.(requestId, parameters);
|
|
9678
8145
|
}
|
|
9679
8146
|
try {
|
|
9680
8147
|
const abortController = new AbortController();
|
|
@@ -9686,21 +8153,21 @@ var ImageSet = class _ImageSet {
|
|
|
9686
8153
|
this._lastAcceptedRequestId = requestId;
|
|
9687
8154
|
this._currentRequest = { requestId, parameters, image };
|
|
9688
8155
|
for (const listener of this._listeners) {
|
|
9689
|
-
|
|
8156
|
+
listener.onImageLoad?.(this._currentRequest);
|
|
9690
8157
|
}
|
|
9691
8158
|
this._emitUpdate();
|
|
9692
8159
|
} catch (error) {
|
|
9693
|
-
if (
|
|
8160
|
+
if (isAbortError(error)) {
|
|
9694
8161
|
return;
|
|
9695
8162
|
}
|
|
9696
8163
|
const normalizedError = normalizeImageSetError(error, "Image request failed");
|
|
9697
8164
|
if (!this._finalized) {
|
|
9698
8165
|
for (const listener of this._listeners) {
|
|
9699
|
-
|
|
8166
|
+
listener.onImageLoadError?.(requestId, normalizedError, parameters);
|
|
9700
8167
|
}
|
|
9701
8168
|
}
|
|
9702
8169
|
} finally {
|
|
9703
|
-
if (
|
|
8170
|
+
if (this._abortController?.signal === parameters.signal) {
|
|
9704
8171
|
this._abortController = null;
|
|
9705
8172
|
}
|
|
9706
8173
|
this._finishLoading();
|
|
@@ -9730,9 +8197,8 @@ var ImageSet = class _ImageSet {
|
|
|
9730
8197
|
}
|
|
9731
8198
|
/** Notifies listeners that current metadata or image output changed. */
|
|
9732
8199
|
_emitUpdate() {
|
|
9733
|
-
var _a;
|
|
9734
8200
|
for (const listener of this._listeners) {
|
|
9735
|
-
|
|
8201
|
+
listener.onUpdate?.();
|
|
9736
8202
|
}
|
|
9737
8203
|
}
|
|
9738
8204
|
/** Increments the active load count and emits loading changes. */
|
|
@@ -9755,9 +8221,8 @@ var ImageSet = class _ImageSet {
|
|
|
9755
8221
|
}
|
|
9756
8222
|
/** Notifies listeners when the overall loading state changes. */
|
|
9757
8223
|
_emitLoadingStateChange(isLoading) {
|
|
9758
|
-
var _a;
|
|
9759
8224
|
for (const listener of this._listeners) {
|
|
9760
|
-
|
|
8225
|
+
listener.onLoadingStateChange?.(isLoading);
|
|
9761
8226
|
}
|
|
9762
8227
|
}
|
|
9763
8228
|
/** Clears any pending debounced image request. */
|
|
@@ -9769,12 +8234,11 @@ var ImageSet = class _ImageSet {
|
|
|
9769
8234
|
}
|
|
9770
8235
|
/** Aborts the current in-flight image request, if any. */
|
|
9771
8236
|
_abortActiveRequest() {
|
|
9772
|
-
|
|
9773
|
-
(_a = this._abortController) == null ? void 0 : _a.abort();
|
|
8237
|
+
this._abortController?.abort();
|
|
9774
8238
|
this._abortController = null;
|
|
9775
8239
|
}
|
|
9776
8240
|
};
|
|
9777
|
-
function
|
|
8241
|
+
function isAbortError(error) {
|
|
9778
8242
|
return error instanceof Error && error.name === "AbortError";
|
|
9779
8243
|
}
|
|
9780
8244
|
function normalizeImageSetError(error, message) {
|
|
@@ -9788,6 +8252,7 @@ function normalizeImageSetError(error, message) {
|
|
|
9788
8252
|
}
|
|
9789
8253
|
|
|
9790
8254
|
// dist/raster-set.js
|
|
8255
|
+
var import_loader_utils9 = require("@loaders.gl/loader-utils");
|
|
9791
8256
|
var DEFAULT_RASTERSET_PROPS = {
|
|
9792
8257
|
getMetadata: async () => ({
|
|
9793
8258
|
width: 0,
|
|
@@ -9843,8 +8308,7 @@ var RasterSet = class _RasterSet {
|
|
|
9843
8308
|
}
|
|
9844
8309
|
/** Current accepted raster, if any. */
|
|
9845
8310
|
get raster() {
|
|
9846
|
-
|
|
9847
|
-
return ((_a = this._currentRequest) == null ? void 0 : _a.raster) || null;
|
|
8311
|
+
return this._currentRequest?.raster || null;
|
|
9848
8312
|
}
|
|
9849
8313
|
/** Current accepted request and raster payload, if any. */
|
|
9850
8314
|
get currentRequest() {
|
|
@@ -9861,7 +8325,6 @@ var RasterSet = class _RasterSet {
|
|
|
9861
8325
|
}
|
|
9862
8326
|
/** Updates source callbacks or debounce settings, resetting state when the source changes. */
|
|
9863
8327
|
setOptions(opts) {
|
|
9864
|
-
var _a;
|
|
9865
8328
|
const previousRasterSource = this._opts.rasterSource;
|
|
9866
8329
|
const mergedOptions = { ...this._opts, ...opts };
|
|
9867
8330
|
if (opts.rasterSource && opts.rasterSource !== previousRasterSource) {
|
|
@@ -9874,7 +8337,7 @@ var RasterSet = class _RasterSet {
|
|
|
9874
8337
|
if (sourceChanged) {
|
|
9875
8338
|
this._cancelScheduledRaster();
|
|
9876
8339
|
this._abortActiveRequest();
|
|
9877
|
-
|
|
8340
|
+
this._metadataAbortController?.abort();
|
|
9878
8341
|
this._sourceGeneration++;
|
|
9879
8342
|
this.metadata = null;
|
|
9880
8343
|
this._currentRequest = null;
|
|
@@ -9883,48 +8346,44 @@ var RasterSet = class _RasterSet {
|
|
|
9883
8346
|
}
|
|
9884
8347
|
/** Loads metadata from the current raster source or callbacks. */
|
|
9885
8348
|
async loadMetadata(options = {}) {
|
|
9886
|
-
var _a, _b, _c, _d, _e, _f;
|
|
9887
8349
|
if (this._finalized)
|
|
9888
8350
|
throw new Error("RasterSet is finalized");
|
|
9889
|
-
|
|
9890
|
-
|
|
8351
|
+
options.signal?.throwIfAborted();
|
|
8352
|
+
this._metadataAbortController?.abort();
|
|
9891
8353
|
const abortController = new AbortController();
|
|
9892
8354
|
this._metadataAbortController = abortController;
|
|
9893
|
-
const abortFromCaller = () =>
|
|
9894
|
-
|
|
9895
|
-
return abortController.abort((_a2 = options.signal) == null ? void 0 : _a2.reason);
|
|
9896
|
-
};
|
|
9897
|
-
(_c = options.signal) == null ? void 0 : _c.addEventListener("abort", abortFromCaller, { once: true });
|
|
8355
|
+
const abortFromCaller = () => abortController.abort(options.signal?.reason);
|
|
8356
|
+
options.signal?.addEventListener("abort", abortFromCaller, { once: true });
|
|
9898
8357
|
const metadataRequestId = ++this._metadataRequestId;
|
|
9899
8358
|
const generation = this._sourceGeneration;
|
|
9900
8359
|
try {
|
|
9901
8360
|
this._startLoading();
|
|
9902
8361
|
abortController.signal.throwIfAborted();
|
|
9903
|
-
const metadata = await waitForPromiseWithSignals((signal) => this._opts.getMetadata({ signal }), [abortController.signal]);
|
|
8362
|
+
const metadata = await (0, import_loader_utils9.waitForPromiseWithSignals)((signal) => this._opts.getMetadata({ signal }), [abortController.signal]);
|
|
9904
8363
|
abortController.signal.throwIfAborted();
|
|
9905
8364
|
if (this._finalized || generation !== this._sourceGeneration || metadataRequestId !== this._metadataRequestId) {
|
|
9906
8365
|
return metadata;
|
|
9907
8366
|
}
|
|
9908
8367
|
this.metadata = metadata;
|
|
9909
8368
|
for (const listener of this._listeners) {
|
|
9910
|
-
|
|
8369
|
+
listener.onMetadataLoad?.(metadata);
|
|
9911
8370
|
}
|
|
9912
8371
|
this._emitUpdate();
|
|
9913
8372
|
return metadata;
|
|
9914
8373
|
} catch (error) {
|
|
9915
8374
|
if (abortController.signal.aborted)
|
|
9916
8375
|
throw abortController.signal.reason;
|
|
9917
|
-
if (
|
|
8376
|
+
if (isAbortError2(error))
|
|
9918
8377
|
throw error;
|
|
9919
8378
|
const normalizedError = normalizeRasterSetError(error, "Raster metadata request failed");
|
|
9920
8379
|
if (!this._finalized && generation === this._sourceGeneration && metadataRequestId === this._metadataRequestId) {
|
|
9921
8380
|
for (const listener of this._listeners) {
|
|
9922
|
-
|
|
8381
|
+
listener.onMetadataLoadError?.(normalizedError);
|
|
9923
8382
|
}
|
|
9924
8383
|
}
|
|
9925
8384
|
throw normalizedError;
|
|
9926
8385
|
} finally {
|
|
9927
|
-
|
|
8386
|
+
options.signal?.removeEventListener("abort", abortFromCaller);
|
|
9928
8387
|
if (this._metadataAbortController === abortController)
|
|
9929
8388
|
this._metadataAbortController = null;
|
|
9930
8389
|
this._finishLoading();
|
|
@@ -9932,14 +8391,13 @@ var RasterSet = class _RasterSet {
|
|
|
9932
8391
|
}
|
|
9933
8392
|
/** Debounces and issues a new raster request for the supplied parameters. */
|
|
9934
8393
|
requestRaster(parameters, debounceTime = this._opts.debounceTime) {
|
|
9935
|
-
var _a;
|
|
9936
8394
|
if (this._finalized)
|
|
9937
8395
|
return -1;
|
|
9938
8396
|
if (!this.shouldRefetchRaster(parameters)) {
|
|
9939
8397
|
this._cancelScheduledRaster();
|
|
9940
8398
|
this._abortActiveRequest();
|
|
9941
8399
|
this._nextRequestId++;
|
|
9942
|
-
return
|
|
8400
|
+
return this._currentRequest?.requestId ?? -1;
|
|
9943
8401
|
}
|
|
9944
8402
|
const requestId = this._nextRequestId++;
|
|
9945
8403
|
this._cancelScheduledRaster();
|
|
@@ -9964,55 +8422,53 @@ var RasterSet = class _RasterSet {
|
|
|
9964
8422
|
}
|
|
9965
8423
|
/** Clears timers and listeners held by the manager. */
|
|
9966
8424
|
finalize() {
|
|
9967
|
-
var _a;
|
|
9968
8425
|
this._finalized = true;
|
|
9969
8426
|
this._cancelScheduledRaster();
|
|
9970
8427
|
this._abortActiveRequest();
|
|
9971
|
-
|
|
8428
|
+
this._metadataAbortController?.abort();
|
|
9972
8429
|
this._metadataAbortController = null;
|
|
9973
8430
|
this._loadCounter = 0;
|
|
9974
8431
|
this._listeners.clear();
|
|
9975
8432
|
}
|
|
9976
8433
|
/** Loads a raster immediately and accepts it only if it is the newest completed request. */
|
|
9977
8434
|
async _loadRaster(requestId, parameters) {
|
|
9978
|
-
var _a, _b, _c;
|
|
9979
8435
|
if (this._finalized) {
|
|
9980
8436
|
return;
|
|
9981
8437
|
}
|
|
9982
8438
|
const callerSignal = parameters.signal;
|
|
9983
|
-
if (callerSignal
|
|
8439
|
+
if (callerSignal?.aborted)
|
|
9984
8440
|
return;
|
|
9985
8441
|
const abortController = new AbortController();
|
|
9986
8442
|
this._abortController = abortController;
|
|
9987
|
-
const abortFromCaller = () => abortController.abort(callerSignal
|
|
9988
|
-
callerSignal
|
|
8443
|
+
const abortFromCaller = () => abortController.abort(callerSignal?.reason);
|
|
8444
|
+
callerSignal?.addEventListener("abort", abortFromCaller, { once: true });
|
|
9989
8445
|
this._startLoading();
|
|
9990
8446
|
try {
|
|
9991
8447
|
abortController.signal.throwIfAborted();
|
|
9992
8448
|
for (const listener of this._listeners)
|
|
9993
|
-
|
|
8449
|
+
listener.onRasterLoadStart?.(requestId, parameters);
|
|
9994
8450
|
abortController.signal.throwIfAborted();
|
|
9995
|
-
const raster = await waitForPromiseWithSignals((signal) => this._opts.getRaster(withAbortSignal(parameters, signal)), [abortController.signal]);
|
|
8451
|
+
const raster = await (0, import_loader_utils9.waitForPromiseWithSignals)((signal) => this._opts.getRaster(withAbortSignal(parameters, signal)), [abortController.signal]);
|
|
9996
8452
|
if (this._finalized || abortController.signal.aborted || requestId !== this._nextRequestId - 1) {
|
|
9997
8453
|
return;
|
|
9998
8454
|
}
|
|
9999
8455
|
this._currentRequest = { requestId, parameters, raster };
|
|
10000
8456
|
for (const listener of this._listeners) {
|
|
10001
|
-
|
|
8457
|
+
listener.onRasterLoad?.(this._currentRequest);
|
|
10002
8458
|
}
|
|
10003
8459
|
this._emitUpdate();
|
|
10004
8460
|
} catch (error) {
|
|
10005
|
-
if (abortController.signal.aborted ||
|
|
8461
|
+
if (abortController.signal.aborted || isAbortError2(error)) {
|
|
10006
8462
|
return;
|
|
10007
8463
|
}
|
|
10008
8464
|
const normalizedError = normalizeRasterSetError(error, "Raster request failed");
|
|
10009
8465
|
if (!this._finalized && requestId === this._nextRequestId - 1) {
|
|
10010
8466
|
for (const listener of this._listeners) {
|
|
10011
|
-
|
|
8467
|
+
listener.onRasterLoadError?.(requestId, normalizedError, parameters);
|
|
10012
8468
|
}
|
|
10013
8469
|
}
|
|
10014
8470
|
} finally {
|
|
10015
|
-
callerSignal
|
|
8471
|
+
callerSignal?.removeEventListener("abort", abortFromCaller);
|
|
10016
8472
|
if (this._abortController === abortController)
|
|
10017
8473
|
this._abortController = null;
|
|
10018
8474
|
this._finishLoading();
|
|
@@ -10043,20 +8499,18 @@ var RasterSet = class _RasterSet {
|
|
|
10043
8499
|
}
|
|
10044
8500
|
/** Emits one generic update notification to all subscribers. */
|
|
10045
8501
|
_emitUpdate() {
|
|
10046
|
-
var _a;
|
|
10047
8502
|
if (this._finalized)
|
|
10048
8503
|
return;
|
|
10049
8504
|
for (const listener of this._listeners) {
|
|
10050
|
-
|
|
8505
|
+
listener.onUpdate?.();
|
|
10051
8506
|
}
|
|
10052
8507
|
}
|
|
10053
8508
|
/** Emits one loading-state transition to all subscribers. */
|
|
10054
8509
|
_emitLoadingStateChange(isLoading) {
|
|
10055
|
-
var _a;
|
|
10056
8510
|
if (this._finalized)
|
|
10057
8511
|
return;
|
|
10058
8512
|
for (const listener of this._listeners) {
|
|
10059
|
-
|
|
8513
|
+
listener.onLoadingStateChange?.(isLoading);
|
|
10060
8514
|
}
|
|
10061
8515
|
}
|
|
10062
8516
|
/** Increments the active load count and emits loading-state transitions. */
|
|
@@ -10086,8 +8540,7 @@ var RasterSet = class _RasterSet {
|
|
|
10086
8540
|
}
|
|
10087
8541
|
/** Aborts the currently active raster request, if one exists. */
|
|
10088
8542
|
_abortActiveRequest() {
|
|
10089
|
-
|
|
10090
|
-
(_a = this._abortController) == null ? void 0 : _a.abort();
|
|
8543
|
+
this._abortController?.abort();
|
|
10091
8544
|
this._abortController = null;
|
|
10092
8545
|
}
|
|
10093
8546
|
};
|
|
@@ -10112,7 +8565,7 @@ function normalizeRasterSetError(error, message) {
|
|
|
10112
8565
|
}
|
|
10113
8566
|
return new Error(message);
|
|
10114
8567
|
}
|
|
10115
|
-
function
|
|
8568
|
+
function isAbortError2(error) {
|
|
10116
8569
|
return error instanceof Error && error.name === "AbortError";
|
|
10117
8570
|
}
|
|
10118
8571
|
|
|
@@ -10186,7 +8639,7 @@ var PointCloudTile = class {
|
|
|
10186
8639
|
};
|
|
10187
8640
|
|
|
10188
8641
|
// dist/point-cloud/point-cloud-tileset.js
|
|
10189
|
-
var
|
|
8642
|
+
var DEFAULT_PROPS3 = {
|
|
10190
8643
|
debounceTime: 0,
|
|
10191
8644
|
minimumNodePixelSize: 150,
|
|
10192
8645
|
maximumScreenSpaceError: 1,
|
|
@@ -10218,7 +8671,7 @@ var PointCloudTileset = class {
|
|
|
10218
8671
|
tilesMap = /* @__PURE__ */ new Map();
|
|
10219
8672
|
constructor(dataSource, options = {}) {
|
|
10220
8673
|
this.dataSource = dataSource;
|
|
10221
|
-
this.options = { ...
|
|
8674
|
+
this.options = { ...DEFAULT_PROPS3, ...options };
|
|
10222
8675
|
this.tilesetInitializationPromise = this.initialize();
|
|
10223
8676
|
}
|
|
10224
8677
|
tilesetInitializationPromise;
|
|
@@ -10274,15 +8727,14 @@ var PointCloudTileset = class {
|
|
|
10274
8727
|
* Initialize the underlying source and the root tile.
|
|
10275
8728
|
*/
|
|
10276
8729
|
async initialize() {
|
|
10277
|
-
var _a, _b;
|
|
10278
8730
|
await this.dataSource.initialize();
|
|
10279
8731
|
const rootHeader = await this.dataSource.getRootTile();
|
|
10280
8732
|
this.root = this.getOrCreateTile(rootHeader, null);
|
|
10281
|
-
const viewState = await
|
|
10282
|
-
this.boundingVolume =
|
|
10283
|
-
const center =
|
|
8733
|
+
const viewState = await this.dataSource.getViewState?.();
|
|
8734
|
+
this.boundingVolume = viewState?.boundingVolume || this.root.boundingVolume;
|
|
8735
|
+
const center = viewState?.cartographicCenter || this.root.boundingVolume.center;
|
|
10284
8736
|
this.cartographicCenter = new import_core15.Vector3(center);
|
|
10285
|
-
this.zoom =
|
|
8737
|
+
this.zoom = viewState?.zoom || this.estimateZoom(this.boundingVolume);
|
|
10286
8738
|
}
|
|
10287
8739
|
/**
|
|
10288
8740
|
* Debounced async tile selection.
|
|
@@ -10293,9 +8745,9 @@ var PointCloudTileset = class {
|
|
|
10293
8745
|
this.lastUpdatedViewports = viewports;
|
|
10294
8746
|
}
|
|
10295
8747
|
if (!this.updatePromise) {
|
|
10296
|
-
this.updatePromise = new Promise((
|
|
8748
|
+
this.updatePromise = new Promise((resolve, reject) => {
|
|
10297
8749
|
setTimeout(() => {
|
|
10298
|
-
this.doSelectTiles().then(() =>
|
|
8750
|
+
this.doSelectTiles().then(() => resolve(this.frameNumberValue)).catch(reject).finally(() => {
|
|
10299
8751
|
this.updatePromise = null;
|
|
10300
8752
|
});
|
|
10301
8753
|
}, this.options.debounceTime);
|
|
@@ -10633,8 +9085,7 @@ var PointCloudTileset = class {
|
|
|
10633
9085
|
* Build a culling volume directly from the viewport frustum in common space.
|
|
10634
9086
|
*/
|
|
10635
9087
|
getCullingVolume(viewport) {
|
|
10636
|
-
|
|
10637
|
-
const getFrustumPlanes = (_a = viewport.getFrustumPlanes) == null ? void 0 : _a.bind(viewport);
|
|
9088
|
+
const getFrustumPlanes = viewport.getFrustumPlanes?.bind(viewport);
|
|
10638
9089
|
if (!getFrustumPlanes) {
|
|
10639
9090
|
return null;
|
|
10640
9091
|
}
|
|
@@ -10654,8 +9105,7 @@ var PointCloudTileset = class {
|
|
|
10654
9105
|
* Approximate a tile AABB by a common-space bounding sphere for frustum culling.
|
|
10655
9106
|
*/
|
|
10656
9107
|
getCommonSpaceBoundingSphere(boundingVolume, viewport) {
|
|
10657
|
-
|
|
10658
|
-
const projectPosition = (_a = viewport.projectPosition) == null ? void 0 : _a.bind(viewport);
|
|
9108
|
+
const projectPosition = viewport.projectPosition?.bind(viewport);
|
|
10659
9109
|
if (!projectPosition) {
|
|
10660
9110
|
return null;
|
|
10661
9111
|
}
|
|
@@ -10688,4 +9138,82 @@ var PointCloudTileset = class {
|
|
|
10688
9138
|
return new import_culling6.BoundingSphere().fromCornerPoints([minX, minY, minZ], [maxX, maxY, maxZ]);
|
|
10689
9139
|
}
|
|
10690
9140
|
};
|
|
9141
|
+
|
|
9142
|
+
// dist/point-cloud-tile-source-loader-types.js
|
|
9143
|
+
var VERSION = true ? "5.0.0-alpha.12" : "latest";
|
|
9144
|
+
async function preloadPointCloudTileSource() {
|
|
9145
|
+
const { PointCloudTileSourceLoaderWithParser } = await import("@loaders.gl/tiles/point-cloud-tile-source-loader");
|
|
9146
|
+
return PointCloudTileSourceLoaderWithParser;
|
|
9147
|
+
}
|
|
9148
|
+
var PointCloudTileSourceLoader = {
|
|
9149
|
+
dataType: null,
|
|
9150
|
+
batchType: null,
|
|
9151
|
+
name: "PointCloudTiler",
|
|
9152
|
+
id: "point-cloud-tiler",
|
|
9153
|
+
module: "tiles",
|
|
9154
|
+
version: VERSION,
|
|
9155
|
+
extensions: [],
|
|
9156
|
+
mimeTypes: [],
|
|
9157
|
+
type: "point-cloud",
|
|
9158
|
+
fromUrl: false,
|
|
9159
|
+
fromBlob: false,
|
|
9160
|
+
testURL: () => false,
|
|
9161
|
+
options: { pointCloudTiler: {} },
|
|
9162
|
+
defaultOptions: { pointCloudTiler: {} },
|
|
9163
|
+
preload: preloadPointCloudTileSource,
|
|
9164
|
+
/** Direct construction requires the runtime rather than this metadata export. */
|
|
9165
|
+
createDataSource(_input, _options = {}, _coreApi) {
|
|
9166
|
+
throw new Error("PointCloudTileSourceLoader requires preload() or @loaders.gl/tiles/point-cloud-tile-source-loader");
|
|
9167
|
+
}
|
|
9168
|
+
};
|
|
9169
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
9170
|
+
0 && (module.exports = {
|
|
9171
|
+
I3SSource,
|
|
9172
|
+
I3SSpatialTransformer,
|
|
9173
|
+
ImageSet,
|
|
9174
|
+
IndexedArchiveTilesetSource,
|
|
9175
|
+
LOD_METRIC_TYPE,
|
|
9176
|
+
PointCloudTile,
|
|
9177
|
+
PointCloudTileSourceLoader,
|
|
9178
|
+
PointCloudTileset,
|
|
9179
|
+
RasterSet,
|
|
9180
|
+
STRATEGY_DEFAULT,
|
|
9181
|
+
STRATEGY_NEVER,
|
|
9182
|
+
STRATEGY_REPLACE,
|
|
9183
|
+
SharedTile2DHeader,
|
|
9184
|
+
SpatialCoordinateTransformer,
|
|
9185
|
+
TILESET_TYPE,
|
|
9186
|
+
TILE_CONTENT_STATE,
|
|
9187
|
+
TILE_REFINEMENT,
|
|
9188
|
+
TILE_TYPE,
|
|
9189
|
+
Tile3D,
|
|
9190
|
+
Tiles3DSource,
|
|
9191
|
+
Tiles3DSpatialTransformer,
|
|
9192
|
+
Tileset2D,
|
|
9193
|
+
Tileset3D,
|
|
9194
|
+
TilesetCache,
|
|
9195
|
+
TilesetTraverser,
|
|
9196
|
+
applyTilesetSpatialOptions,
|
|
9197
|
+
calculateTransformProps,
|
|
9198
|
+
convertS2BoundingVolumeToOBB,
|
|
9199
|
+
createBoundingVolume,
|
|
9200
|
+
createImplicitSubtreeReference,
|
|
9201
|
+
createTilesetSpatialReference,
|
|
9202
|
+
get3DTilesSpatialReference,
|
|
9203
|
+
getFrameState,
|
|
9204
|
+
getGeoidModel,
|
|
9205
|
+
getI3SSpatialReference,
|
|
9206
|
+
getLodStatus,
|
|
9207
|
+
getSpatialCoordinateFrame,
|
|
9208
|
+
getTileset3DTraversalSnapshot,
|
|
9209
|
+
isTileset3DSource,
|
|
9210
|
+
markTilesetSpatialReferenceTransformed,
|
|
9211
|
+
materializeImplicitSubtree,
|
|
9212
|
+
registerGeoidModel,
|
|
9213
|
+
registerGeoidModelFromPgm,
|
|
9214
|
+
registerSpatialCrs,
|
|
9215
|
+
registerSpatialDatumGrid,
|
|
9216
|
+
replaceImplicitUrlTemplate,
|
|
9217
|
+
traverseTilesetContents
|
|
9218
|
+
});
|
|
10691
9219
|
//# sourceMappingURL=index.cjs.map
|