@loaders.gl/tiles 4.0.0-alpha.9 → 4.0.0-beta.1

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 (33) hide show
  1. package/dist/dist.min.js +144 -80
  2. package/dist/es5/tileset/tileset-3d.js.map +1 -1
  3. package/dist/es5/tileset/tileset-traverser.js +1 -1
  4. package/dist/es5/tileset/tileset-traverser.js.map +1 -1
  5. package/dist/esm/tileset/tileset-3d.js.map +1 -1
  6. package/dist/esm/tileset/tileset-traverser.js +1 -1
  7. package/dist/esm/tileset/tileset-traverser.js.map +1 -1
  8. package/dist/tileset/tileset-3d.d.ts.map +1 -1
  9. package/package.json +4 -4
  10. package/src/tileset/tileset-3d.ts +1 -0
  11. package/src/tileset/tileset-traverser.ts +1 -1
  12. package/dist/bundle.js +0 -5
  13. package/dist/constants.js +0 -39
  14. package/dist/index.js +0 -26
  15. package/dist/tileset/format-3d-tiles/tileset-3d-traverser.js +0 -54
  16. package/dist/tileset/format-i3s/i3s-pending-tiles-register.js +0 -47
  17. package/dist/tileset/format-i3s/i3s-tile-manager.js +0 -80
  18. package/dist/tileset/format-i3s/i3s-tileset-traverser.js +0 -92
  19. package/dist/tileset/helpers/3d-tiles-options.js +0 -9
  20. package/dist/tileset/helpers/bounding-volume.js +0 -293
  21. package/dist/tileset/helpers/frame-state.js +0 -133
  22. package/dist/tileset/helpers/i3s-lod.js +0 -85
  23. package/dist/tileset/helpers/tiles-3d-lod.js +0 -117
  24. package/dist/tileset/helpers/transform-utils.js +0 -53
  25. package/dist/tileset/helpers/zoom.js +0 -89
  26. package/dist/tileset/tile-3d.js +0 -610
  27. package/dist/tileset/tileset-3d.js +0 -715
  28. package/dist/tileset/tileset-cache.js +0 -72
  29. package/dist/tileset/tileset-traverser.js +0 -300
  30. package/dist/types.js +0 -2
  31. package/dist/utils/doubly-linked-list-node.js +0 -18
  32. package/dist/utils/doubly-linked-list.js +0 -97
  33. package/dist/utils/managed-array.js +0 -152
package/dist/dist.min.js CHANGED
@@ -1,5 +1,10 @@
1
1
  (() => {
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
3
8
  var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
4
9
  var __esm = (fn, res) => function __init() {
5
10
  return fn && (res = (0, fn[Object.keys(fn)[0]])(fn = 0)), res;
@@ -12,6 +17,17 @@
12
17
  for (var name in all)
13
18
  __defProp(target, name, { get: all[name], enumerable: true });
14
19
  };
20
+ var __reExport = (target, module, desc) => {
21
+ if (module && typeof module === "object" || typeof module === "function") {
22
+ for (let key of __getOwnPropNames(module))
23
+ if (!__hasOwnProp.call(target, key) && key !== "default")
24
+ __defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
25
+ }
26
+ return target;
27
+ };
28
+ var __toModule = (module) => {
29
+ return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
30
+ };
15
31
 
16
32
  // ../../node_modules/@math.gl/core/dist/esm/lib/assert.js
17
33
  function assert(condition, message) {
@@ -3643,16 +3659,45 @@
3643
3659
  }
3644
3660
  });
3645
3661
 
3662
+ // ../loader-utils/src/lib/option-utils/merge-loader-options.ts
3663
+ function mergeLoaderOptions(baseOptions, newOptions) {
3664
+ return mergeOptionsRecursively(baseOptions || {}, newOptions);
3665
+ }
3666
+ function mergeOptionsRecursively(baseOptions, newOptions) {
3667
+ const options = { ...baseOptions };
3668
+ for (const [key, newValue] of Object.entries(newOptions)) {
3669
+ if (newValue && typeof newValue === "object" && !Array.isArray(newValue)) {
3670
+ options[key] = mergeOptionsRecursively(options[key] || {}, newOptions[key]);
3671
+ } else {
3672
+ options[key] = newOptions[key];
3673
+ }
3674
+ }
3675
+ return options;
3676
+ }
3677
+ var init_merge_loader_options = __esm({
3678
+ "../loader-utils/src/lib/option-utils/merge-loader-options.ts"() {
3679
+ }
3680
+ });
3681
+
3646
3682
  // ../worker-utils/src/lib/env-utils/version.ts
3647
- var DEFAULT_VERSION, VERSION;
3648
- var init_version = __esm({
3649
- "../worker-utils/src/lib/env-utils/version.ts"() {
3650
- DEFAULT_VERSION = "beta";
3651
- VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : DEFAULT_VERSION;
3683
+ function getVersion() {
3684
+ if (!globalThis._loadersgl_?.version) {
3685
+ globalThis._loadersgl_ = globalThis._loadersgl_ || {};
3652
3686
  if (typeof __VERSION__ === "undefined") {
3653
3687
  console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
3688
+ globalThis._loadersgl_.version = NPM_TAG;
3689
+ } else {
3690
+ globalThis._loadersgl_.version = __VERSION__;
3654
3691
  }
3655
3692
  }
3693
+ return globalThis._loadersgl_.version;
3694
+ }
3695
+ var NPM_TAG, VERSION;
3696
+ var init_version = __esm({
3697
+ "../worker-utils/src/lib/env-utils/version.ts"() {
3698
+ NPM_TAG = "beta";
3699
+ VERSION = getVersion();
3700
+ }
3656
3701
  });
3657
3702
 
3658
3703
  // ../worker-utils/src/lib/env-utils/assert.ts
@@ -4116,12 +4161,11 @@
4116
4161
  assert3(url);
4117
4162
  return url;
4118
4163
  }
4119
- var NPM_TAG;
4120
4164
  var init_get_worker_url = __esm({
4121
4165
  "../worker-utils/src/lib/worker-api/get-worker-url.ts"() {
4122
4166
  init_assert3();
4123
4167
  init_globals2();
4124
- NPM_TAG = "beta";
4168
+ init_version();
4125
4169
  }
4126
4170
  });
4127
4171
 
@@ -4793,6 +4837,7 @@
4793
4837
  "../loader-utils/src/index.ts"() {
4794
4838
  init_assert2();
4795
4839
  init_globals();
4840
+ init_merge_loader_options();
4796
4841
  init_parse_with_worker();
4797
4842
  init_array_buffer_utils();
4798
4843
  init_async_iteration();
@@ -4832,55 +4877,55 @@
4832
4877
  return this._length;
4833
4878
  }
4834
4879
  add(item) {
4835
- const node2 = new DoublyLinkedListNode(item, this.tail, null);
4880
+ const node3 = new DoublyLinkedListNode(item, this.tail, null);
4836
4881
  if (this.tail) {
4837
- this.tail.next = node2;
4838
- this.tail = node2;
4882
+ this.tail.next = node3;
4883
+ this.tail = node3;
4839
4884
  } else {
4840
- this.head = node2;
4841
- this.tail = node2;
4885
+ this.head = node3;
4886
+ this.tail = node3;
4842
4887
  }
4843
4888
  ++this._length;
4844
- return node2;
4889
+ return node3;
4845
4890
  }
4846
- remove(node2) {
4847
- if (!node2) {
4891
+ remove(node3) {
4892
+ if (!node3) {
4848
4893
  return;
4849
4894
  }
4850
- if (node2.previous && node2.next) {
4851
- node2.previous.next = node2.next;
4852
- node2.next.previous = node2.previous;
4853
- } else if (node2.previous) {
4854
- node2.previous.next = null;
4855
- this.tail = node2.previous;
4856
- } else if (node2.next) {
4857
- node2.next.previous = null;
4858
- this.head = node2.next;
4895
+ if (node3.previous && node3.next) {
4896
+ node3.previous.next = node3.next;
4897
+ node3.next.previous = node3.previous;
4898
+ } else if (node3.previous) {
4899
+ node3.previous.next = null;
4900
+ this.tail = node3.previous;
4901
+ } else if (node3.next) {
4902
+ node3.next.previous = null;
4903
+ this.head = node3.next;
4859
4904
  } else {
4860
4905
  this.head = null;
4861
4906
  this.tail = null;
4862
4907
  }
4863
- node2.next = null;
4864
- node2.previous = null;
4908
+ node3.next = null;
4909
+ node3.previous = null;
4865
4910
  --this._length;
4866
4911
  }
4867
- splice(node2, nextNode) {
4868
- if (node2 === nextNode) {
4912
+ splice(node3, nextNode) {
4913
+ if (node3 === nextNode) {
4869
4914
  return;
4870
4915
  }
4871
4916
  this.remove(nextNode);
4872
- this._insert(node2, nextNode);
4917
+ this._insert(node3, nextNode);
4873
4918
  }
4874
- _insert(node2, nextNode) {
4875
- const oldNodeNext = node2.next;
4876
- node2.next = nextNode;
4877
- if (this.tail === node2) {
4919
+ _insert(node3, nextNode) {
4920
+ const oldNodeNext = node3.next;
4921
+ node3.next = nextNode;
4922
+ if (this.tail === node3) {
4878
4923
  this.tail = nextNode;
4879
4924
  } else {
4880
4925
  oldNodeNext.previous = nextNode;
4881
4926
  }
4882
4927
  nextNode.next = oldNodeNext;
4883
- nextNode.previous = node2;
4928
+ nextNode.previous = node3;
4884
4929
  ++this._length;
4885
4930
  }
4886
4931
  };
@@ -4902,9 +4947,9 @@
4902
4947
  this._list.splice(this._list.tail, this._sentinel);
4903
4948
  }
4904
4949
  touch(tile) {
4905
- const node2 = tile._cacheNode;
4906
- if (node2) {
4907
- this._list.splice(this._sentinel, node2);
4950
+ const node3 = tile._cacheNode;
4951
+ if (node3) {
4952
+ this._list.splice(this._sentinel, node3);
4908
4953
  }
4909
4954
  }
4910
4955
  add(tileset, tile, addCallback) {
@@ -4916,11 +4961,11 @@
4916
4961
  }
4917
4962
  }
4918
4963
  unloadTile(tileset, tile, unloadCallback) {
4919
- const node2 = tile._cacheNode;
4920
- if (!node2) {
4964
+ const node3 = tile._cacheNode;
4965
+ if (!node3) {
4921
4966
  return;
4922
4967
  }
4923
- this._list.remove(node2);
4968
+ this._list.remove(node3);
4924
4969
  tile._cacheNode = null;
4925
4970
  if (unloadCallback) {
4926
4971
  unloadCallback(tileset, tile);
@@ -4932,10 +4977,10 @@
4932
4977
  const list = this._list;
4933
4978
  const maximumMemoryUsageInBytes = tileset.maximumMemoryUsage * 1024 * 1024;
4934
4979
  const sentinel = this._sentinel;
4935
- let node2 = list.head;
4936
- while (node2 !== sentinel && (tileset.gpuMemoryUsageInBytes > maximumMemoryUsageInBytes || trimTiles)) {
4937
- const tile = node2.item;
4938
- node2 = node2.next;
4980
+ let node3 = list.head;
4981
+ while (node3 !== sentinel && (tileset.gpuMemoryUsageInBytes > maximumMemoryUsageInBytes || trimTiles)) {
4982
+ const tile = node3.item;
4983
+ node3 = node3.next;
4939
4984
  this.unloadTile(tileset, tile, unloadCallback);
4940
4985
  }
4941
4986
  }
@@ -5713,7 +5758,7 @@
5713
5758
  isFunction = (x) => typeof x === "function";
5714
5759
  isObject = (x) => x !== null && typeof x === "object";
5715
5760
  isPureObject = (x) => isObject(x) && x.constructor === {}.constructor;
5716
- isIterable = (x) => x && typeof x[Symbol.iterator] === "function";
5761
+ isIterable = (x) => Boolean(x) && typeof x[Symbol.iterator] === "function";
5717
5762
  isAsyncIterable = (x) => x && typeof x[Symbol.asyncIterator] === "function";
5718
5763
  isResponse = (x) => typeof Response !== "undefined" && x instanceof Response || x && x.arrayBuffer && x.text && x.json;
5719
5764
  isBlob = (x) => typeof Blob !== "undefined" && x instanceof Blob;
@@ -5902,22 +5947,38 @@
5902
5947
  }
5903
5948
  });
5904
5949
 
5950
+ // (disabled):../core/src/lib/fetch/fetch-file.node
5951
+ var require_fetch_file = __commonJS({
5952
+ "(disabled):../core/src/lib/fetch/fetch-file.node"() {
5953
+ }
5954
+ });
5955
+
5905
5956
  // ../core/src/lib/fetch/fetch-file.ts
5906
- async function fetchFile(url, options) {
5907
- if (typeof url === "string") {
5908
- url = resolvePath(url);
5909
- let fetchOptions = options;
5910
- if (options?.fetch && typeof options?.fetch !== "function") {
5911
- fetchOptions = options.fetch;
5957
+ function isNodePath(url) {
5958
+ return !isRequestURL(url) && !isDataURL(url);
5959
+ }
5960
+ function isRequestURL(url) {
5961
+ return url.startsWith("http:") || url.startsWith("https:");
5962
+ }
5963
+ function isDataURL(url) {
5964
+ return url.startsWith("data:");
5965
+ }
5966
+ async function fetchFile(urlOrData, fetchOptions) {
5967
+ if (typeof urlOrData === "string") {
5968
+ const url = resolvePath(urlOrData);
5969
+ if (isNodePath(url) && node2?.fetchFileNode) {
5970
+ return node2.fetchFileNode(url, fetchOptions);
5912
5971
  }
5913
5972
  return await fetch(url, fetchOptions);
5914
5973
  }
5915
- return await makeResponse(url);
5974
+ return await makeResponse(urlOrData);
5916
5975
  }
5976
+ var node2;
5917
5977
  var init_fetch_file = __esm({
5918
5978
  "../core/src/lib/fetch/fetch-file.ts"() {
5919
5979
  init_src2();
5920
5980
  init_response_utils();
5981
+ node2 = __toModule(require_fetch_file());
5921
5982
  }
5922
5983
  });
5923
5984
 
@@ -6581,6 +6642,7 @@
6581
6642
  mimeType: void 0,
6582
6643
  nothrow: false,
6583
6644
  log: new ConsoleLog(),
6645
+ useLocalLibraries: false,
6584
6646
  CDN: "https://unpkg.com/@loaders.gl",
6585
6647
  worker: true,
6586
6648
  maxConcurrency: 3,
@@ -6622,6 +6684,11 @@
6622
6684
  loaders._state = loaders._state || {};
6623
6685
  return loaders._state;
6624
6686
  }
6687
+ function getGlobalLoaderOptions() {
6688
+ const state = getGlobalLoaderState();
6689
+ state.globalOptions = state.globalOptions || { ...DEFAULT_LOADER_OPTIONS };
6690
+ return state.globalOptions;
6691
+ }
6625
6692
  function normalizeOptions(options, loader, loaders, url) {
6626
6693
  loaders = loaders || [];
6627
6694
  loaders = Array.isArray(loaders) ? loaders : [loaders];
@@ -6702,17 +6769,11 @@
6702
6769
  options.baseUri = url;
6703
6770
  }
6704
6771
  }
6705
- var getGlobalLoaderOptions;
6706
6772
  var init_option_utils = __esm({
6707
6773
  "../core/src/lib/loader-utils/option-utils.ts"() {
6708
6774
  init_is_type();
6709
6775
  init_loggers();
6710
6776
  init_option_defaults();
6711
- getGlobalLoaderOptions = () => {
6712
- const state = getGlobalLoaderState();
6713
- state.globalOptions = state.globalOptions || { ...DEFAULT_LOADER_OPTIONS };
6714
- return state.globalOptions;
6715
- };
6716
6777
  }
6717
6778
  });
6718
6779
 
@@ -6833,8 +6894,10 @@
6833
6894
  reason = reason || (loader ? `matched MIME type ${type}` : "");
6834
6895
  loader = loader || findLoaderByInitialBytes(loaders, data);
6835
6896
  reason = reason || (loader ? `matched initial data ${getFirstCharacters(data)}` : "");
6836
- loader = loader || findLoaderByMIMEType(loaders, options?.fallbackMimeType);
6837
- reason = reason || (loader ? `matched fallback MIME type ${type}` : "");
6897
+ if (options?.fallbackMimeType) {
6898
+ loader = loader || findLoaderByMIMEType(loaders, options?.fallbackMimeType);
6899
+ reason = reason || (loader ? `matched fallback MIME type ${type}` : "");
6900
+ }
6838
6901
  if (reason) {
6839
6902
  log.log(1, `selectLoader selected ${loader?.name}: ${reason}.`);
6840
6903
  }
@@ -6930,7 +6993,7 @@
6930
6993
  }
6931
6994
  switch (typeof test) {
6932
6995
  case "function":
6933
- return test(data, loader);
6996
+ return test(data);
6934
6997
  case "string":
6935
6998
  const magic = getMagicString(data, byteOffset, test.length);
6936
6999
  return test === magic;
@@ -7161,12 +7224,12 @@
7161
7224
  // ../core/src/lib/loader-utils/get-fetch-function.ts
7162
7225
  function getFetchFunction(options, context) {
7163
7226
  const globalOptions = getGlobalLoaderOptions();
7164
- const fetchOptions = options || globalOptions;
7165
- if (typeof fetchOptions.fetch === "function") {
7166
- return fetchOptions.fetch;
7227
+ const loaderOptions = options || globalOptions;
7228
+ if (typeof loaderOptions.fetch === "function") {
7229
+ return loaderOptions.fetch;
7167
7230
  }
7168
- if (isObject(fetchOptions.fetch)) {
7169
- return (url) => fetchFile(url, fetchOptions);
7231
+ if (isObject(loaderOptions.fetch)) {
7232
+ return (url) => fetchFile(url, loaderOptions.fetch);
7170
7233
  }
7171
7234
  if (context?.fetch) {
7172
7235
  return context?.fetch;
@@ -7203,7 +7266,7 @@
7203
7266
  return newContext;
7204
7267
  }
7205
7268
  function getLoadersFromContext(loaders, context) {
7206
- if (!context && loaders && !Array.isArray(loaders)) {
7269
+ if (loaders && !Array.isArray(loaders)) {
7207
7270
  return loaders;
7208
7271
  }
7209
7272
  let candidateLoaders;
@@ -7214,7 +7277,7 @@
7214
7277
  const contextLoaders = Array.isArray(context.loaders) ? context.loaders : [context.loaders];
7215
7278
  candidateLoaders = candidateLoaders ? [...candidateLoaders, ...contextLoaders] : contextLoaders;
7216
7279
  }
7217
- return candidateLoaders && candidateLoaders.length ? candidateLoaders : null;
7280
+ return candidateLoaders && candidateLoaders.length ? candidateLoaders : void 0;
7218
7281
  }
7219
7282
  var init_loader_context = __esm({
7220
7283
  "../core/src/lib/loader-utils/loader-context.ts"() {
@@ -7226,7 +7289,6 @@
7226
7289
 
7227
7290
  // ../core/src/lib/api/parse.ts
7228
7291
  async function parse(data, loaders, options, context) {
7229
- assert3(!context || typeof context === "object");
7230
7292
  if (loaders && !Array.isArray(loaders) && !isLoaderObject(loaders)) {
7231
7293
  context = void 0;
7232
7294
  options = loaders;
@@ -7242,11 +7304,12 @@
7242
7304
  return null;
7243
7305
  }
7244
7306
  options = normalizeOptions(options, loader, candidateLoaders, url);
7245
- context = getLoaderContext({ url, parse, loaders: candidateLoaders }, options, context || null);
7307
+ context = getLoaderContext({ url, _parse: parse, loaders: candidateLoaders }, options, context || null);
7246
7308
  return await parseWithLoader(loader, data, options, context);
7247
7309
  }
7248
7310
  async function parseWithLoader(loader, data, options, context) {
7249
7311
  validateWorkerVersion(loader);
7312
+ options = mergeLoaderOptions(loader.options, options);
7250
7313
  if (isResponse(data)) {
7251
7314
  const response = data;
7252
7315
  const { ok, redirected, status, statusText, type, url } = response;
@@ -7254,29 +7317,30 @@
7254
7317
  context.response = { headers, ok, redirected, status, statusText, type, url };
7255
7318
  }
7256
7319
  data = await getArrayBufferOrStringFromData(data, loader, options);
7257
- if (loader.parseTextSync && typeof data === "string") {
7258
- options.dataType = "text";
7259
- return loader.parseTextSync(data, options, context, loader);
7320
+ const loaderWithParser = loader;
7321
+ if (loaderWithParser.parseTextSync && typeof data === "string") {
7322
+ return loaderWithParser.parseTextSync(data, options, context);
7260
7323
  }
7261
7324
  if (canParseWithWorker(loader, options)) {
7262
7325
  return await parseWithWorker(loader, data, options, context, parse);
7263
7326
  }
7264
- if (loader.parseText && typeof data === "string") {
7265
- return await loader.parseText(data, options, context, loader);
7327
+ if (loaderWithParser.parseText && typeof data === "string") {
7328
+ return await loaderWithParser.parseText(data, options, context);
7266
7329
  }
7267
- if (loader.parse) {
7268
- return await loader.parse(data, options, context, loader);
7330
+ if (loaderWithParser.parse) {
7331
+ return await loaderWithParser.parse(data, options, context);
7269
7332
  }
7270
- assert3(!loader.parseSync);
7333
+ assert3(!loaderWithParser.parseSync);
7271
7334
  throw new Error(`${loader.id} loader - no parser found and worker is disabled`);
7272
7335
  }
7273
7336
  var init_parse = __esm({
7274
7337
  "../core/src/lib/api/parse.ts"() {
7275
- init_src();
7276
7338
  init_src2();
7339
+ init_src();
7277
7340
  init_normalize_loader();
7278
7341
  init_is_type();
7279
7342
  init_option_utils();
7343
+ init_src2();
7280
7344
  init_get_data();
7281
7345
  init_loader_context();
7282
7346
  init_resource_utils();
@@ -7950,7 +8014,7 @@
7950
8014
  }
7951
8015
  stack.push(child);
7952
8016
  }
7953
- } else if (!tile.contentAvailable) {
8017
+ } else if (!tile.contentAvailable && !tile.hasEmptyContent) {
7954
8018
  allDescendantsLoaded = false;
7955
8019
  }
7956
8020
  }