@loaders.gl/tiles-3d 5.0.0-beta.4 → 5.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +1 -1
  2. package/dist/3d-tiles/3d-tiles-archive-loader.js +1 -1
  3. package/dist/3d-tiles/dist.dev.js +891 -620
  4. package/dist/3d-tiles/dist.min.js +37 -37
  5. package/dist/3d-tiles/index.cjs +821 -943
  6. package/dist/3d-tiles/index.cjs.map +3 -3
  7. package/dist/3d-tiles/lib/parsers/parse-3d-tile-instanced-model.js +5 -1
  8. package/dist/3d-tiles/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
  9. package/dist/3d-tiles/lib/utils/version.js +1 -1
  10. package/dist/3d-tiles-archive-writer.cjs +1 -1
  11. package/dist/cesium-ion-loader-with-parser.cjs +820 -942
  12. package/dist/cesium-ion-loader-with-parser.cjs.map +3 -3
  13. package/dist/copc/copc-source-loader.js +2 -2
  14. package/dist/copc/copc-source-loader.js.map +1 -1
  15. package/dist/copc/copc-writer.js +1 -1
  16. package/dist/copc/index.cjs +24 -178
  17. package/dist/copc/index.cjs.map +3 -3
  18. package/dist/dist.dev.js +231 -38
  19. package/dist/dist.min.js +10 -10
  20. package/dist/i3s/arcgis-webscene-loader.js +1 -1
  21. package/dist/i3s/dist.dev.js +3080 -710
  22. package/dist/i3s/dist.min.js +47 -47
  23. package/dist/i3s/i3s-attribute-loader.js +1 -1
  24. package/dist/i3s/i3s-building-scene-layer-loader.js +1 -1
  25. package/dist/i3s/i3s-content-loader.js +1 -1
  26. package/dist/i3s/i3s-lepcc-loader-types.js +1 -1
  27. package/dist/i3s/i3s-loader.js +1 -1
  28. package/dist/i3s/i3s-node-page-loader.js +1 -1
  29. package/dist/i3s/i3s-slpk-loader.js +1 -1
  30. package/dist/i3s/i3s-slpk-writer.js +1 -1
  31. package/dist/i3s/index.cjs +1999 -541
  32. package/dist/i3s/index.cjs.map +3 -3
  33. package/dist/i3s-content-worker-node.js +11 -11
  34. package/dist/i3s-content-worker-node.js.map +4 -4
  35. package/dist/i3s-content-worker.js +767 -346
  36. package/dist/i3s-lepcc-worker-node.js +245 -12
  37. package/dist/i3s-lepcc-worker-node.js.map +4 -4
  38. package/dist/i3s-lepcc-worker.js +240 -12
  39. package/dist/i3s-mesh-writer.cjs +1748 -290
  40. package/dist/i3s-mesh-writer.cjs.map +3 -3
  41. package/dist/i3s-slpk-writer.cjs +1 -1
  42. package/dist/index.cjs +1 -1
  43. package/dist/point-cloud-tile-source-loader-types.js +1 -1
  44. package/dist/point-cloud-tile-source-loader.cjs +1 -1
  45. package/dist/potree/dist.dev.js +226 -82
  46. package/dist/potree/dist.min.js +30 -30
  47. package/dist/potree/index.cjs +13 -165
  48. package/dist/potree/index.cjs.map +3 -3
  49. package/dist/potree/potree-bin-loader.js +1 -1
  50. package/dist/potree/potree-hierarchy-chunk-loader.js +1 -1
  51. package/dist/potree/potree-loader-types.js +1 -1
  52. package/dist/potree/potree-source-loader.js +1 -1
  53. package/dist/potree/potree-writer.js +1 -1
  54. package/dist/potree-loader.cjs +1 -1
  55. package/package.json +13 -13
  56. package/src/3d-tiles/lib/parsers/parse-3d-tile-instanced-model.ts +4 -1
  57. package/src/copc/copc-source-loader.ts +1 -1
@@ -568,7 +568,7 @@
568
568
  "dist/i3s/i3s-lepcc-loader-types.js"() {
569
569
  "use strict";
570
570
  init_i3s_format();
571
- VERSION = true ? "5.0.0-beta.4" : "latest";
571
+ VERSION = true ? "5.0.0-beta.5" : "latest";
572
572
  I3SLEPCCLoader = {
573
573
  ...I3SLEPCCFormat2,
574
574
  dataType: null,
@@ -621,10 +621,10 @@
621
621
  }
622
622
  });
623
623
 
624
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/node/worker_threads-browser.js
624
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads-browser.js
625
625
  var parentPort = globalThis.process?.getBuiltinModule?.("node:worker_threads")?.parentPort ?? null;
626
626
 
627
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-utils/get-transfer-list.js
627
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js
628
628
  function getTransferList(object, recursive = true, transfers) {
629
629
  const transfersSet = transfers || /* @__PURE__ */ new Set();
630
630
  const seen = /* @__PURE__ */ new Set();
@@ -675,7 +675,7 @@
675
675
  return false;
676
676
  }
677
677
 
678
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-farm/worker-body.js
678
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-body.js
679
679
  async function getParentPort() {
680
680
  return parentPort;
681
681
  }
@@ -762,7 +762,7 @@
762
762
  return messageData && typeof messageData.source === "string" && messageData.source.startsWith("loaders.gl") ? messageData : null;
763
763
  }
764
764
 
765
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/async-queue/async-queue.js
765
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js
766
766
  var AsyncQueue = class {
767
767
  constructor() {
768
768
  this._values = [];
@@ -829,7 +829,7 @@
829
829
  }
830
830
  };
831
831
 
832
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/shared-state.js
832
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js
833
833
  var SharedWorkerState = class {
834
834
  constructor(buffer) {
835
835
  if (typeof SharedArrayBuffer === "undefined" || !(buffer instanceof SharedArrayBuffer) || buffer.byteLength !== 16)
@@ -868,14 +868,14 @@
868
868
  }
869
869
  };
870
870
 
871
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/validate-output-ownership.js
871
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js
872
872
  function validateOutputOwnership(ownership) {
873
873
  if (ownership !== void 0 && ownership !== "copy" && ownership !== "transfer") {
874
874
  throw new Error("Invalid worker output ownership");
875
875
  }
876
876
  }
877
877
 
878
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/create-worker.js
878
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js
879
879
  var requestId = 0;
880
880
  var activeController = null;
881
881
  var activeInputBatches = null;
@@ -1083,12 +1083,12 @@
1083
1083
  };
1084
1084
  }
1085
1085
 
1086
- // ../../node_modules/@math.gl/core/dist/worker-utils/index.js
1086
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/index.js
1087
1087
  var import_meta = {};
1088
1088
  var path = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
1089
1089
  var moduleUrl = path ? `file://${path.startsWith("/") ? "" : "/"}${encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F")}` : import_meta.url;
1090
1090
 
1091
- // ../../node_modules/@math.gl/core/dist/tasks/task-preload.js
1091
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js
1092
1092
  var pending = /* @__PURE__ */ new WeakMap();
1093
1093
  var loaded = /* @__PURE__ */ new WeakSet();
1094
1094
  function preloadTaskCode(task, signal) {
@@ -1125,17 +1125,182 @@
1125
1125
  });
1126
1126
  }
1127
1127
 
1128
- // ../../node_modules/@math.gl/core/dist/tasks/task-runtime.js
1128
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js
1129
+ var TaskRequestError = class extends Error {
1130
+ };
1131
+ var TaskChannel = class {
1132
+ constructor(options) {
1133
+ this.options = options;
1134
+ this.nextId = 1;
1135
+ this.pending = /* @__PURE__ */ new Map();
1136
+ this.incoming = /* @__PURE__ */ new Map();
1137
+ }
1138
+ /** Send a request without serializing other in-flight requests. */
1139
+ request(operation, value, signal, transfer = []) {
1140
+ if (this.failure)
1141
+ return Promise.reject(this.failure.reason);
1142
+ if (signal?.aborted)
1143
+ return Promise.reject(signal.reason);
1144
+ const id = this.nextId++;
1145
+ return new Promise((resolve, reject) => {
1146
+ const abort = () => {
1147
+ const pending2 = this.pending.get(id);
1148
+ if (!pending2)
1149
+ return;
1150
+ this.pending.delete(id);
1151
+ pending2.cleanup();
1152
+ reject(signal?.reason);
1153
+ this.send({ source: "math.gl/tasks", kind: "cancel", id });
1154
+ };
1155
+ this.pending.set(id, {
1156
+ resolve,
1157
+ reject,
1158
+ cleanup: () => signal?.removeEventListener("abort", abort)
1159
+ });
1160
+ signal?.addEventListener("abort", abort, { once: true });
1161
+ this.send({ source: "math.gl/tasks", kind: "request", id, operation, value }, transfer);
1162
+ });
1163
+ }
1164
+ /** Send a one-way notification. */
1165
+ emit(operation, value, transfer = []) {
1166
+ if (this.failure)
1167
+ throw this.failure.reason;
1168
+ this.send({ source: "math.gl/tasks", kind: "event", id: 0, operation, value }, transfer);
1169
+ }
1170
+ /** Dispatch a transport message; unrelated protocols are ignored. */
1171
+ receive(message) {
1172
+ if (this.failure || message?.source !== "math.gl/tasks")
1173
+ return;
1174
+ if (message.kind === "failure") {
1175
+ const reason = new Error(message.error?.message ?? "Task channel failed");
1176
+ this.close(reason);
1177
+ this.options.onFailure?.(reason);
1178
+ } else if (message.kind === "result" || message.kind === "error") {
1179
+ const pending2 = this.pending.get(message.id);
1180
+ if (!pending2)
1181
+ return;
1182
+ this.pending.delete(message.id);
1183
+ pending2.cleanup();
1184
+ if (message.kind === "result")
1185
+ pending2.resolve(message.value);
1186
+ else {
1187
+ const error = new TaskRequestError(message.error?.message ?? "Task request failed");
1188
+ error.name = message.error?.name ?? "Error";
1189
+ pending2.reject(error);
1190
+ }
1191
+ } else if (message.kind === "cancel") {
1192
+ this.incoming.get(message.id)?.abort(new DOMException("Task request cancelled", "AbortError"));
1193
+ } else if (message.kind === "event") {
1194
+ try {
1195
+ this.options.handleEvent?.(message.operation, message.value);
1196
+ } catch (error) {
1197
+ this.fail(error);
1198
+ }
1199
+ } else if (message.kind === "request") {
1200
+ if (this.incoming.has(message.id)) {
1201
+ this.fail(new Error("Duplicate task request identifier"));
1202
+ return;
1203
+ }
1204
+ const controller = new AbortController();
1205
+ this.incoming.set(message.id, controller);
1206
+ void Promise.resolve().then(() => {
1207
+ controller.signal.throwIfAborted();
1208
+ return this.options.handleRequest(message.operation, message.value, controller.signal);
1209
+ }).then((value) => {
1210
+ if (!controller.signal.aborted && !this.failure) {
1211
+ this.send({ source: "math.gl/tasks", kind: "result", id: message.id, value }, this.options.getResultTransferList?.(value, message.value));
1212
+ }
1213
+ }).catch((reason) => {
1214
+ if (!controller.signal.aborted && !this.failure) {
1215
+ this.send({
1216
+ source: "math.gl/tasks",
1217
+ kind: "error",
1218
+ id: message.id,
1219
+ error: {
1220
+ name: reason instanceof Error ? reason.name : "Error",
1221
+ message: reason instanceof Error ? reason.message : String(reason)
1222
+ }
1223
+ });
1224
+ }
1225
+ }).finally(() => this.incoming.delete(message.id));
1226
+ }
1227
+ }
1228
+ /** Reject all outstanding calls with a common cause and abort incoming callbacks. */
1229
+ close(reason = new Error("Task channel closed")) {
1230
+ if (this.failure)
1231
+ return;
1232
+ this.failure = { reason };
1233
+ for (const pending2 of this.pending.values()) {
1234
+ pending2.cleanup();
1235
+ pending2.reject(reason);
1236
+ }
1237
+ this.pending.clear();
1238
+ for (const controller of this.incoming.values())
1239
+ controller.abort(reason);
1240
+ this.incoming.clear();
1241
+ }
1242
+ send(message, transfer = []) {
1243
+ if (this.failure)
1244
+ return;
1245
+ try {
1246
+ this.options.send(message, transfer);
1247
+ } catch (error) {
1248
+ this.fail(error);
1249
+ }
1250
+ }
1251
+ /** Invalidate the channel and notify the peer when the transport still works. */
1252
+ fail(reason) {
1253
+ if (this.failure)
1254
+ return;
1255
+ this.close(reason);
1256
+ try {
1257
+ this.options.send({
1258
+ source: "math.gl/tasks",
1259
+ kind: "failure",
1260
+ id: 0,
1261
+ error: {
1262
+ name: reason instanceof Error ? reason.name : "Error",
1263
+ message: reason instanceof Error ? reason.message : String(reason)
1264
+ }
1265
+ }, []);
1266
+ } catch {
1267
+ }
1268
+ this.options.onFailure?.(reason);
1269
+ }
1270
+ };
1271
+
1272
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js
1129
1273
  function assertPayload(value) {
1130
1274
  if (!value || typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) {
1131
1275
  throw new TypeError("Task payloads must be plain objects with named fields");
1132
1276
  }
1133
1277
  }
1278
+ function clonePayload(value, ownership = "copy") {
1279
+ assertPayload(value);
1280
+ if (!["copy", "transfer", "share"].includes(ownership))
1281
+ throw new TypeError("Invalid input ownership");
1282
+ const transfer = getTransferList(value);
1283
+ if (ownership === "share" && transfer.length)
1284
+ throw new TypeError("Share requires shared storage");
1285
+ return structuredClone(value, {
1286
+ transfer: ownership === "transfer" ? transfer : []
1287
+ });
1288
+ }
1134
1289
  function taskContext(state, context = {}) {
1135
1290
  const signal = context.signal ?? new AbortController().signal;
1136
1291
  return {
1137
1292
  state,
1138
1293
  signal,
1294
+ requestHost: async (operation, payload, controls) => {
1295
+ signal.throwIfAborted();
1296
+ if (!context.requestHost)
1297
+ throw new Error("No host request handler configured");
1298
+ return context.requestHost(operation, payload, controls);
1299
+ },
1300
+ emitHost: (operation, payload) => {
1301
+ signal.throwIfAborted();
1302
+ context.emitHost?.(operation, payload);
1303
+ },
1139
1304
  throwIfAborted: () => {
1140
1305
  signal.throwIfAborted();
1141
1306
  context.throwIfAborted?.();
@@ -1200,6 +1365,69 @@
1200
1365
  throw new Error("A task is already installed in this worker");
1201
1366
  installed = true;
1202
1367
  const runtime = new TaskRuntime(task);
1368
+ let channelStream;
1369
+ const channel = new TaskChannel({
1370
+ getResultTransferList: (value, request) => request.outputOwnership === "transfer" ? getTransferList(value) : [],
1371
+ send: (message, transfer) => {
1372
+ const snapshot = structuredClone(message, { transfer });
1373
+ void WorkerBody.postMessage("task-channel", snapshot).catch((reason) => channel.fail(reason));
1374
+ },
1375
+ handleRequest: async (operation, value, signal) => {
1376
+ const request = value;
1377
+ const context = {
1378
+ signal,
1379
+ reportProgress: (progress) => channel.emit("task:progress", { id: request.progressId, progress }),
1380
+ requestHost: (operation2, payload, controls = {}) => {
1381
+ const request2 = {
1382
+ operation: operation2,
1383
+ payload: clonePayload(payload, controls.inputOwnership),
1384
+ outputOwnership: controls.outputOwnership ?? "copy"
1385
+ };
1386
+ return channel.request("task:host-request", request2, signal, getTransferList(request2));
1387
+ },
1388
+ emitHost: (operation2, payload) => channel.emit("task:host-event", { operation: operation2, payload, id: request.progressId })
1389
+ };
1390
+ switch (operation) {
1391
+ case "initialize":
1392
+ return runtime.initialize(request.input, context);
1393
+ case "process":
1394
+ return runtime.process(request.input, request.options, context);
1395
+ case "stream-open": {
1396
+ if (channelStream)
1397
+ throw new Error("A task stream is already open");
1398
+ async function* inputs() {
1399
+ while (true) {
1400
+ const result = await channel.request("task:next-input", { outputOwnership: "transfer" }, signal);
1401
+ if (result.done)
1402
+ return;
1403
+ yield result.value;
1404
+ }
1405
+ }
1406
+ channelStream = runtime.stream(inputs(), request.options, context)[Symbol.asyncIterator]();
1407
+ return {};
1408
+ }
1409
+ case "stream-next":
1410
+ if (!channelStream)
1411
+ throw new Error("No active task stream");
1412
+ return channelStream.next();
1413
+ case "stream-close":
1414
+ try {
1415
+ await channelStream?.return?.();
1416
+ } finally {
1417
+ channelStream = void 0;
1418
+ }
1419
+ return {};
1420
+ case "destroy":
1421
+ return runtime.destroy();
1422
+ default:
1423
+ throw new Error("Unknown task channel operation");
1424
+ }
1425
+ }
1426
+ });
1427
+ await WorkerBody.addEventListener((type, payload) => {
1428
+ if (type === "task-channel")
1429
+ channel.receive(payload);
1430
+ });
1203
1431
  let streamOptions = {};
1204
1432
  return createWorker(async (request, _options, context) => {
1205
1433
  switch (request.operation) {
@@ -2013,7 +2241,7 @@
2013
2241
  );
2014
2242
 
2015
2243
  // src/i3s/i3s-lepcc-loader-types.ts
2016
- var VERSION2 = true ? "5.0.0-beta.4" : "latest";
2244
+ var VERSION2 = true ? "5.0.0-beta.5" : "latest";
2017
2245
  var I3SLEPCCLoader2 = {
2018
2246
  ...I3SLEPCCFormat,
2019
2247
  dataType: null,