@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
@@ -8148,7 +8148,7 @@ var init_i3s_lepcc_loader_types = __esm({
8148
8148
  "dist/i3s/i3s-lepcc-loader-types.js"() {
8149
8149
  "use strict";
8150
8150
  init_i3s_format();
8151
- VERSION = true ? "5.0.0-beta.4" : "latest";
8151
+ VERSION = true ? "5.0.0-beta.5" : "latest";
8152
8152
  I3SLEPCCLoader = {
8153
8153
  ...I3SLEPCCFormat2,
8154
8154
  dataType: null,
@@ -10367,11 +10367,11 @@ globalThis.loaders.readFileAsText = readFileAsText;
10367
10367
  globalThis.loaders.requireFromFile = requireFromFile;
10368
10368
  globalThis.loaders.requireFromString = requireFromString;
10369
10369
 
10370
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/node/worker_threads.js
10370
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/node/worker_threads.js
10371
10371
  var import_worker_threads = require("worker_threads");
10372
10372
  var parentPort = import_worker_threads.parentPort;
10373
10373
 
10374
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-utils/get-transfer-list.js
10374
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-utils/get-transfer-list.js
10375
10375
  function getTransferList(object2, recursive = true, transfers) {
10376
10376
  const transfersSet = transfers || /* @__PURE__ */ new Set();
10377
10377
  const seen = /* @__PURE__ */ new Set();
@@ -10422,7 +10422,7 @@ function isTransferable(object2) {
10422
10422
  return false;
10423
10423
  }
10424
10424
 
10425
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-farm/worker-body.js
10425
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-farm/worker-body.js
10426
10426
  async function getParentPort() {
10427
10427
  return parentPort;
10428
10428
  }
@@ -10509,7 +10509,7 @@ function getWorkerMessageData(message) {
10509
10509
  return messageData && typeof messageData.source === "string" && messageData.source.startsWith("loaders.gl") ? messageData : null;
10510
10510
  }
10511
10511
 
10512
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/async-queue/async-queue.js
10512
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/async-queue/async-queue.js
10513
10513
  var AsyncQueue = class {
10514
10514
  constructor() {
10515
10515
  this._values = [];
@@ -10576,7 +10576,7 @@ var AsyncQueue = class {
10576
10576
  }
10577
10577
  };
10578
10578
 
10579
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/shared-state.js
10579
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/shared-state.js
10580
10580
  var SharedWorkerState = class {
10581
10581
  constructor(buffer2) {
10582
10582
  if (typeof SharedArrayBuffer === "undefined" || !(buffer2 instanceof SharedArrayBuffer) || buffer2.byteLength !== 16)
@@ -10615,14 +10615,14 @@ var SharedWorkerState = class {
10615
10615
  }
10616
10616
  };
10617
10617
 
10618
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/validate-output-ownership.js
10618
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/validate-output-ownership.js
10619
10619
  function validateOutputOwnership(ownership) {
10620
10620
  if (ownership !== void 0 && ownership !== "copy" && ownership !== "transfer") {
10621
10621
  throw new Error("Invalid worker output ownership");
10622
10622
  }
10623
10623
  }
10624
10624
 
10625
- // ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/create-worker.js
10625
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/lib/worker-api/create-worker.js
10626
10626
  var requestId = 0;
10627
10627
  var activeController = null;
10628
10628
  var activeInputBatches = null;
@@ -10831,12 +10831,12 @@ function createProgressReporter() {
10831
10831
  };
10832
10832
  }
10833
10833
 
10834
- // ../../node_modules/@math.gl/core/dist/worker-utils/index.js
10834
+ // ../../node_modules/@math.gl/tasks/dist/worker-utils/index.js
10835
10835
  var import_meta3 = {};
10836
10836
  var path3 = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
10837
10837
  var moduleUrl = path3 ? `file://${path3.startsWith("/") ? "" : "/"}${encodeURI(path3).replace(/#/g, "%23").replace(/\?/g, "%3F")}` : import_meta3.url;
10838
10838
 
10839
- // ../../node_modules/@math.gl/core/dist/tasks/task-preload.js
10839
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-preload.js
10840
10840
  var pending = /* @__PURE__ */ new WeakMap();
10841
10841
  var loaded = /* @__PURE__ */ new WeakSet();
10842
10842
  function preloadTaskCode(task, signal) {
@@ -10873,17 +10873,186 @@ function withSignal(operation, signal) {
10873
10873
  });
10874
10874
  }
10875
10875
 
10876
- // ../../node_modules/@math.gl/core/dist/tasks/task-runtime.js
10876
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-channel.js
10877
+ var TaskRequestError = class extends Error {
10878
+ };
10879
+ var TaskChannel = class {
10880
+ constructor(options) {
10881
+ this.options = options;
10882
+ this.nextId = 1;
10883
+ this.pending = /* @__PURE__ */ new Map();
10884
+ this.incoming = /* @__PURE__ */ new Map();
10885
+ }
10886
+ /** Send a request without serializing other in-flight requests. */
10887
+ request(operation, value, signal, transfer = []) {
10888
+ if (this.failure)
10889
+ return Promise.reject(this.failure.reason);
10890
+ if (signal == null ? void 0 : signal.aborted)
10891
+ return Promise.reject(signal.reason);
10892
+ const id = this.nextId++;
10893
+ return new Promise((resolve, reject) => {
10894
+ const abort = () => {
10895
+ const pending2 = this.pending.get(id);
10896
+ if (!pending2)
10897
+ return;
10898
+ this.pending.delete(id);
10899
+ pending2.cleanup();
10900
+ reject(signal == null ? void 0 : signal.reason);
10901
+ this.send({ source: "math.gl/tasks", kind: "cancel", id });
10902
+ };
10903
+ this.pending.set(id, {
10904
+ resolve,
10905
+ reject,
10906
+ cleanup: () => signal == null ? void 0 : signal.removeEventListener("abort", abort)
10907
+ });
10908
+ signal == null ? void 0 : signal.addEventListener("abort", abort, { once: true });
10909
+ this.send({ source: "math.gl/tasks", kind: "request", id, operation, value }, transfer);
10910
+ });
10911
+ }
10912
+ /** Send a one-way notification. */
10913
+ emit(operation, value, transfer = []) {
10914
+ if (this.failure)
10915
+ throw this.failure.reason;
10916
+ this.send({ source: "math.gl/tasks", kind: "event", id: 0, operation, value }, transfer);
10917
+ }
10918
+ /** Dispatch a transport message; unrelated protocols are ignored. */
10919
+ receive(message) {
10920
+ var _a, _b, _c, _d, _e, _f, _g, _h;
10921
+ if (this.failure || (message == null ? void 0 : message.source) !== "math.gl/tasks")
10922
+ return;
10923
+ if (message.kind === "failure") {
10924
+ const reason = new Error(((_a = message.error) == null ? void 0 : _a.message) ?? "Task channel failed");
10925
+ this.close(reason);
10926
+ (_c = (_b = this.options).onFailure) == null ? void 0 : _c.call(_b, reason);
10927
+ } else if (message.kind === "result" || message.kind === "error") {
10928
+ const pending2 = this.pending.get(message.id);
10929
+ if (!pending2)
10930
+ return;
10931
+ this.pending.delete(message.id);
10932
+ pending2.cleanup();
10933
+ if (message.kind === "result")
10934
+ pending2.resolve(message.value);
10935
+ else {
10936
+ const error = new TaskRequestError(((_d = message.error) == null ? void 0 : _d.message) ?? "Task request failed");
10937
+ error.name = ((_e = message.error) == null ? void 0 : _e.name) ?? "Error";
10938
+ pending2.reject(error);
10939
+ }
10940
+ } else if (message.kind === "cancel") {
10941
+ (_f = this.incoming.get(message.id)) == null ? void 0 : _f.abort(new DOMException("Task request cancelled", "AbortError"));
10942
+ } else if (message.kind === "event") {
10943
+ try {
10944
+ (_h = (_g = this.options).handleEvent) == null ? void 0 : _h.call(_g, message.operation, message.value);
10945
+ } catch (error) {
10946
+ this.fail(error);
10947
+ }
10948
+ } else if (message.kind === "request") {
10949
+ if (this.incoming.has(message.id)) {
10950
+ this.fail(new Error("Duplicate task request identifier"));
10951
+ return;
10952
+ }
10953
+ const controller = new AbortController();
10954
+ this.incoming.set(message.id, controller);
10955
+ void Promise.resolve().then(() => {
10956
+ controller.signal.throwIfAborted();
10957
+ return this.options.handleRequest(message.operation, message.value, controller.signal);
10958
+ }).then((value) => {
10959
+ var _a2, _b2;
10960
+ if (!controller.signal.aborted && !this.failure) {
10961
+ this.send({ source: "math.gl/tasks", kind: "result", id: message.id, value }, (_b2 = (_a2 = this.options).getResultTransferList) == null ? void 0 : _b2.call(_a2, value, message.value));
10962
+ }
10963
+ }).catch((reason) => {
10964
+ if (!controller.signal.aborted && !this.failure) {
10965
+ this.send({
10966
+ source: "math.gl/tasks",
10967
+ kind: "error",
10968
+ id: message.id,
10969
+ error: {
10970
+ name: reason instanceof Error ? reason.name : "Error",
10971
+ message: reason instanceof Error ? reason.message : String(reason)
10972
+ }
10973
+ });
10974
+ }
10975
+ }).finally(() => this.incoming.delete(message.id));
10976
+ }
10977
+ }
10978
+ /** Reject all outstanding calls with a common cause and abort incoming callbacks. */
10979
+ close(reason = new Error("Task channel closed")) {
10980
+ if (this.failure)
10981
+ return;
10982
+ this.failure = { reason };
10983
+ for (const pending2 of this.pending.values()) {
10984
+ pending2.cleanup();
10985
+ pending2.reject(reason);
10986
+ }
10987
+ this.pending.clear();
10988
+ for (const controller of this.incoming.values())
10989
+ controller.abort(reason);
10990
+ this.incoming.clear();
10991
+ }
10992
+ send(message, transfer = []) {
10993
+ if (this.failure)
10994
+ return;
10995
+ try {
10996
+ this.options.send(message, transfer);
10997
+ } catch (error) {
10998
+ this.fail(error);
10999
+ }
11000
+ }
11001
+ /** Invalidate the channel and notify the peer when the transport still works. */
11002
+ fail(reason) {
11003
+ var _a, _b;
11004
+ if (this.failure)
11005
+ return;
11006
+ this.close(reason);
11007
+ try {
11008
+ this.options.send({
11009
+ source: "math.gl/tasks",
11010
+ kind: "failure",
11011
+ id: 0,
11012
+ error: {
11013
+ name: reason instanceof Error ? reason.name : "Error",
11014
+ message: reason instanceof Error ? reason.message : String(reason)
11015
+ }
11016
+ }, []);
11017
+ } catch {
11018
+ }
11019
+ (_b = (_a = this.options).onFailure) == null ? void 0 : _b.call(_a, reason);
11020
+ }
11021
+ };
11022
+
11023
+ // ../../node_modules/@math.gl/tasks/dist/tasks/task-runtime.js
10877
11024
  function assertPayload(value) {
10878
11025
  if (!value || typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) {
10879
11026
  throw new TypeError("Task payloads must be plain objects with named fields");
10880
11027
  }
10881
11028
  }
11029
+ function clonePayload(value, ownership = "copy") {
11030
+ assertPayload(value);
11031
+ if (!["copy", "transfer", "share"].includes(ownership))
11032
+ throw new TypeError("Invalid input ownership");
11033
+ const transfer = getTransferList(value);
11034
+ if (ownership === "share" && transfer.length)
11035
+ throw new TypeError("Share requires shared storage");
11036
+ return structuredClone(value, {
11037
+ transfer: ownership === "transfer" ? transfer : []
11038
+ });
11039
+ }
10882
11040
  function taskContext(state, context = {}) {
10883
11041
  const signal = context.signal ?? new AbortController().signal;
10884
11042
  return {
10885
11043
  state,
10886
11044
  signal,
11045
+ requestHost: async (operation, payload, controls) => {
11046
+ signal.throwIfAborted();
11047
+ if (!context.requestHost)
11048
+ throw new Error("No host request handler configured");
11049
+ return context.requestHost(operation, payload, controls);
11050
+ },
11051
+ emitHost: (operation, payload) => {
11052
+ var _a;
11053
+ signal.throwIfAborted();
11054
+ (_a = context.emitHost) == null ? void 0 : _a.call(context, operation, payload);
11055
+ },
10887
11056
  throwIfAborted: () => {
10888
11057
  var _a;
10889
11058
  signal.throwIfAborted();
@@ -10954,6 +11123,70 @@ async function initializeTaskWorker(task) {
10954
11123
  throw new Error("A task is already installed in this worker");
10955
11124
  installed = true;
10956
11125
  const runtime = new TaskRuntime(task);
11126
+ let channelStream;
11127
+ const channel = new TaskChannel({
11128
+ getResultTransferList: (value, request) => request.outputOwnership === "transfer" ? getTransferList(value) : [],
11129
+ send: (message, transfer) => {
11130
+ const snapshot = structuredClone(message, { transfer });
11131
+ void WorkerBody.postMessage("task-channel", snapshot).catch((reason) => channel.fail(reason));
11132
+ },
11133
+ handleRequest: async (operation, value, signal) => {
11134
+ var _a;
11135
+ const request = value;
11136
+ const context = {
11137
+ signal,
11138
+ reportProgress: (progress) => channel.emit("task:progress", { id: request.progressId, progress }),
11139
+ requestHost: (operation2, payload, controls = {}) => {
11140
+ const request2 = {
11141
+ operation: operation2,
11142
+ payload: clonePayload(payload, controls.inputOwnership),
11143
+ outputOwnership: controls.outputOwnership ?? "copy"
11144
+ };
11145
+ return channel.request("task:host-request", request2, signal, getTransferList(request2));
11146
+ },
11147
+ emitHost: (operation2, payload) => channel.emit("task:host-event", { operation: operation2, payload, id: request.progressId })
11148
+ };
11149
+ switch (operation) {
11150
+ case "initialize":
11151
+ return runtime.initialize(request.input, context);
11152
+ case "process":
11153
+ return runtime.process(request.input, request.options, context);
11154
+ case "stream-open": {
11155
+ if (channelStream)
11156
+ throw new Error("A task stream is already open");
11157
+ async function* inputs() {
11158
+ while (true) {
11159
+ const result = await channel.request("task:next-input", { outputOwnership: "transfer" }, signal);
11160
+ if (result.done)
11161
+ return;
11162
+ yield result.value;
11163
+ }
11164
+ }
11165
+ channelStream = runtime.stream(inputs(), request.options, context)[Symbol.asyncIterator]();
11166
+ return {};
11167
+ }
11168
+ case "stream-next":
11169
+ if (!channelStream)
11170
+ throw new Error("No active task stream");
11171
+ return channelStream.next();
11172
+ case "stream-close":
11173
+ try {
11174
+ await ((_a = channelStream == null ? void 0 : channelStream.return) == null ? void 0 : _a.call(channelStream));
11175
+ } finally {
11176
+ channelStream = void 0;
11177
+ }
11178
+ return {};
11179
+ case "destroy":
11180
+ return runtime.destroy();
11181
+ default:
11182
+ throw new Error("Unknown task channel operation");
11183
+ }
11184
+ }
11185
+ });
11186
+ await WorkerBody.addEventListener((type, payload) => {
11187
+ if (type === "task-channel")
11188
+ channel.receive(payload);
11189
+ });
10957
11190
  let streamOptions = {};
10958
11191
  return createWorker(async (request, _options, context) => {
10959
11192
  switch (request.operation) {
@@ -11772,7 +12005,7 @@ var I3SBuildingSceneLayerFormat = json(
11772
12005
  );
11773
12006
 
11774
12007
  // src/i3s/i3s-lepcc-loader-types.ts
11775
- var VERSION2 = true ? "5.0.0-beta.4" : "latest";
12008
+ var VERSION2 = true ? "5.0.0-beta.5" : "latest";
11776
12009
  var I3SLEPCCLoader2 = {
11777
12010
  ...I3SLEPCCFormat,
11778
12011
  dataType: null,