@loaders.gl/3d-tiles 4.0.0-alpha.17 → 4.0.0-alpha.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dist.min.js CHANGED
@@ -595,8 +595,7 @@
595
595
  }
596
596
  async function loadLibraryFromFile(libraryUrl) {
597
597
  if (libraryUrl.endsWith("wasm")) {
598
- const response2 = await fetch(libraryUrl);
599
- return await response2.arrayBuffer();
598
+ return await loadAsArrayBuffer(libraryUrl);
600
599
  }
601
600
  if (!isBrowser2) {
602
601
  try {
@@ -608,8 +607,7 @@
608
607
  if (isWorker) {
609
608
  return importScripts(libraryUrl);
610
609
  }
611
- const response = await fetch(libraryUrl);
612
- const scriptSource = await response.text();
610
+ const scriptSource = await loadAsText(libraryUrl);
613
611
  return loadLibraryFromString(scriptSource, libraryUrl);
614
612
  }
615
613
  function loadLibraryFromString(scriptSource, id) {
@@ -630,6 +628,20 @@
630
628
  document.body.appendChild(script);
631
629
  return null;
632
630
  }
631
+ async function loadAsArrayBuffer(url) {
632
+ if (!node.readFileAsArrayBuffer || url.startsWith("http")) {
633
+ const response = await fetch(url);
634
+ return await response.arrayBuffer();
635
+ }
636
+ return await node.readFileAsArrayBuffer(url);
637
+ }
638
+ async function loadAsText(url) {
639
+ if (!node.readFileAsText || url.startsWith("http")) {
640
+ const response = await fetch(url);
641
+ return await response.text();
642
+ }
643
+ return await node.readFileAsText(url);
644
+ }
633
645
  var node, LATEST, VERSION2, loadLibraryPromises;
634
646
  var init_library_utils = __esm({
635
647
  "../worker-utils/src/lib/library-utils/library-utils.ts"() {
@@ -5497,18 +5509,38 @@
5497
5509
  }
5498
5510
  });
5499
5511
 
5512
+ // (disabled):../core/src/lib/fetch/fetch-file.node
5513
+ var require_fetch_file = __commonJS({
5514
+ "(disabled):../core/src/lib/fetch/fetch-file.node"() {
5515
+ }
5516
+ });
5517
+
5500
5518
  // ../core/src/lib/fetch/fetch-file.ts
5519
+ function isNodePath(url) {
5520
+ return !isRequestURL(url) && !isDataURL(url);
5521
+ }
5522
+ function isRequestURL(url) {
5523
+ return url.startsWith("http:") || url.startsWith("https:");
5524
+ }
5525
+ function isDataURL(url) {
5526
+ return url.startsWith("data:");
5527
+ }
5501
5528
  async function fetchFile(urlOrData, fetchOptions) {
5502
5529
  if (typeof urlOrData === "string") {
5503
5530
  const url = resolvePath(urlOrData);
5531
+ if (isNodePath(url) && node3?.fetchFileNode) {
5532
+ return node3.fetchFileNode(url, fetchOptions);
5533
+ }
5504
5534
  return await fetch(url, fetchOptions);
5505
5535
  }
5506
5536
  return await makeResponse(urlOrData);
5507
5537
  }
5538
+ var node3;
5508
5539
  var init_fetch_file = __esm({
5509
5540
  "../core/src/lib/fetch/fetch-file.ts"() {
5510
5541
  init_src2();
5511
5542
  init_response_utils();
5543
+ node3 = __toModule(require_fetch_file());
5512
5544
  }
5513
5545
  });
5514
5546
 
@@ -9359,15 +9391,15 @@
9359
9391
  });
9360
9392
 
9361
9393
  // ../textures/src/lib/parsers/basis-module-loader.ts
9362
- async function loadBasisTrascoderModule(options) {
9394
+ async function loadBasisTranscoderModule(options) {
9363
9395
  const modules = options.modules || {};
9364
9396
  if (modules.basis) {
9365
9397
  return modules.basis;
9366
9398
  }
9367
- loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTrascoder(options);
9399
+ loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTranscoder(options);
9368
9400
  return await loadBasisTranscoderPromise;
9369
9401
  }
9370
- async function loadBasisTrascoder(options) {
9402
+ async function loadBasisTranscoder(options) {
9371
9403
  let BASIS = null;
9372
9404
  let wasmBinary = null;
9373
9405
  [BASIS, wasmBinary] = await Promise.all([
@@ -9375,9 +9407,9 @@
9375
9407
  await loadLibrary("basis_transcoder.wasm", "textures", options)
9376
9408
  ]);
9377
9409
  BASIS = BASIS || globalThis.BASIS;
9378
- return await initializeBasisTrascoderModule(BASIS, wasmBinary);
9410
+ return await initializeBasisTranscoderModule(BASIS, wasmBinary);
9379
9411
  }
9380
- function initializeBasisTrascoderModule(BasisModule, wasmBinary) {
9412
+ function initializeBasisTranscoderModule(BasisModule, wasmBinary) {
9381
9413
  const options = {};
9382
9414
  if (wasmBinary) {
9383
9415
  options.wasmBinary = wasmBinary;
@@ -9599,7 +9631,7 @@
9599
9631
  const fileConstructors = await loadBasisEncoderModule(options);
9600
9632
  return parseKTX2File(fileConstructors.KTX2File, data, options);
9601
9633
  }
9602
- const { BasisFile } = await loadBasisTrascoderModule(options);
9634
+ const { BasisFile } = await loadBasisTranscoderModule(options);
9603
9635
  return parseBasisFile(BasisFile, data, options);
9604
9636
  }
9605
9637
  switch (options.basis.module) {
@@ -9614,7 +9646,7 @@
9614
9646
  }
9615
9647
  case "transcoder":
9616
9648
  default:
9617
- const { BasisFile } = await loadBasisTrascoderModule(options);
9649
+ const { BasisFile } = await loadBasisTranscoderModule(options);
9618
9650
  return parseBasisFile(BasisFile, data, options);
9619
9651
  }
9620
9652
  }
@@ -10278,8 +10310,8 @@
10278
10310
  this.json.scenes.push({ nodes: nodeIndices });
10279
10311
  return this.json.scenes.length - 1;
10280
10312
  }
10281
- addNode(node3) {
10282
- const { meshIndex, matrix } = node3;
10313
+ addNode(node4) {
10314
+ const { meshIndex, matrix } = node4;
10283
10315
  this.json.nodes = this.json.nodes || [];
10284
10316
  const nodeData = { mesh: meshIndex };
10285
10317
  if (matrix) {
@@ -11149,12 +11181,12 @@
11149
11181
  gltfScenegraph.json.lights = extension.lights;
11150
11182
  gltfScenegraph.removeExtension(KHR_LIGHTS_PUNCTUAL);
11151
11183
  }
11152
- for (const node3 of json.nodes || []) {
11153
- const nodeExtension = gltfScenegraph.getObjectExtension(node3, KHR_LIGHTS_PUNCTUAL);
11184
+ for (const node4 of json.nodes || []) {
11185
+ const nodeExtension = gltfScenegraph.getObjectExtension(node4, KHR_LIGHTS_PUNCTUAL);
11154
11186
  if (nodeExtension) {
11155
- node3.light = nodeExtension.light;
11187
+ node4.light = nodeExtension.light;
11156
11188
  }
11157
- gltfScenegraph.removeObjectExtension(node3, KHR_LIGHTS_PUNCTUAL);
11189
+ gltfScenegraph.removeObjectExtension(node4, KHR_LIGHTS_PUNCTUAL);
11158
11190
  }
11159
11191
  }
11160
11192
  async function encode2(gltfData) {
@@ -11168,8 +11200,8 @@
11168
11200
  }
11169
11201
  if (gltfScenegraph.json.lights) {
11170
11202
  for (const light of gltfScenegraph.json.lights) {
11171
- const node3 = light.node;
11172
- gltfScenegraph.addObjectExtension(node3, KHR_LIGHTS_PUNCTUAL, light);
11203
+ const node4 = light.node;
11204
+ gltfScenegraph.addObjectExtension(node4, KHR_LIGHTS_PUNCTUAL, light);
11173
11205
  }
11174
11206
  delete gltfScenegraph.json.lights;
11175
11207
  }
@@ -11688,11 +11720,11 @@
11688
11720
  for (const mesh of json.meshes) {
11689
11721
  this._convertMeshIds(mesh);
11690
11722
  }
11691
- for (const node3 of json.nodes) {
11692
- this._convertNodeIds(node3);
11723
+ for (const node4 of json.nodes) {
11724
+ this._convertNodeIds(node4);
11693
11725
  }
11694
- for (const node3 of json.scenes) {
11695
- this._convertSceneIds(node3);
11726
+ for (const node4 of json.scenes) {
11727
+ this._convertSceneIds(node4);
11696
11728
  }
11697
11729
  }
11698
11730
  _convertTextureIds(texture) {
@@ -11714,17 +11746,17 @@
11714
11746
  }
11715
11747
  }
11716
11748
  }
11717
- _convertNodeIds(node3) {
11718
- if (node3.children) {
11719
- node3.children = node3.children.map((child) => this._convertIdToIndex(child, "node"));
11749
+ _convertNodeIds(node4) {
11750
+ if (node4.children) {
11751
+ node4.children = node4.children.map((child) => this._convertIdToIndex(child, "node"));
11720
11752
  }
11721
- if (node3.meshes) {
11722
- node3.meshes = node3.meshes.map((mesh) => this._convertIdToIndex(mesh, "mesh"));
11753
+ if (node4.meshes) {
11754
+ node4.meshes = node4.meshes.map((mesh) => this._convertIdToIndex(mesh, "mesh"));
11723
11755
  }
11724
11756
  }
11725
11757
  _convertSceneIds(scene) {
11726
11758
  if (scene.nodes) {
11727
- scene.nodes = scene.nodes.map((node3) => this._convertIdToIndex(node3, "node"));
11759
+ scene.nodes = scene.nodes.map((node4) => this._convertIdToIndex(node4, "node"));
11728
11760
  }
11729
11761
  }
11730
11762
  _convertIdsToIndices(json, topLevelArrayName) {
@@ -12055,8 +12087,8 @@
12055
12087
  json.meshes = gltf.meshes.map((mesh, i2) => this._resolveMesh(mesh, i2));
12056
12088
  }
12057
12089
  if (gltf.nodes) {
12058
- json.nodes = gltf.nodes.map((node3, i2) => this._resolveNode(node3, i2));
12059
- json.nodes = json.nodes.map((node3, i2) => this._resolveNodeChildren(node3));
12090
+ json.nodes = gltf.nodes.map((node4, i2) => this._resolveNode(node4, i2));
12091
+ json.nodes = json.nodes.map((node4, i2) => this._resolveNodeChildren(node4));
12060
12092
  }
12061
12093
  if (gltf.skins) {
12062
12094
  json.skins = gltf.skins.map((skin, i2) => this._resolveSkin(skin, i2));
@@ -12119,38 +12151,38 @@
12119
12151
  return {
12120
12152
  ...scene,
12121
12153
  id: scene.id || `scene-${index}`,
12122
- nodes: (scene.nodes || []).map((node3) => this.getNode(node3))
12154
+ nodes: (scene.nodes || []).map((node4) => this.getNode(node4))
12123
12155
  };
12124
12156
  }
12125
12157
  _resolveNode(gltfNode, index) {
12126
- const node3 = {
12158
+ const node4 = {
12127
12159
  ...gltfNode,
12128
12160
  id: gltfNode?.id || `node-${index}`
12129
12161
  };
12130
12162
  if (gltfNode.mesh !== void 0) {
12131
- node3.mesh = this.getMesh(gltfNode.mesh);
12163
+ node4.mesh = this.getMesh(gltfNode.mesh);
12132
12164
  }
12133
12165
  if (gltfNode.camera !== void 0) {
12134
- node3.camera = this.getCamera(gltfNode.camera);
12166
+ node4.camera = this.getCamera(gltfNode.camera);
12135
12167
  }
12136
12168
  if (gltfNode.skin !== void 0) {
12137
- node3.skin = this.getSkin(gltfNode.skin);
12169
+ node4.skin = this.getSkin(gltfNode.skin);
12138
12170
  }
12139
12171
  if (gltfNode.meshes !== void 0 && gltfNode.meshes.length) {
12140
- node3.mesh = gltfNode.meshes.reduce((accum, meshIndex) => {
12172
+ node4.mesh = gltfNode.meshes.reduce((accum, meshIndex) => {
12141
12173
  const mesh = this.getMesh(meshIndex);
12142
12174
  accum.id = mesh.id;
12143
12175
  accum.primitives = accum.primitives.concat(mesh.primitives);
12144
12176
  return accum;
12145
12177
  }, { primitives: [] });
12146
12178
  }
12147
- return node3;
12179
+ return node4;
12148
12180
  }
12149
- _resolveNodeChildren(node3) {
12150
- if (node3.children) {
12151
- node3.children = node3.children.map((child) => this.getNode(child));
12181
+ _resolveNodeChildren(node4) {
12182
+ if (node4.children) {
12183
+ node4.children = node4.children.map((child) => this.getNode(child));
12152
12184
  }
12153
- return node3;
12185
+ return node4;
12154
12186
  }
12155
12187
  _resolveSkin(gltfSkin, index) {
12156
12188
  const inverseBindMatrices = typeof gltfSkin.inverseBindMatrices === "number" ? this.getAccessor(gltfSkin.inverseBindMatrices) : void 0;
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.VERSION = void 0;
7
- var VERSION = typeof "4.0.0-alpha.17" !== 'undefined' ? "4.0.0-alpha.17" : 'latest';
7
+ var VERSION = typeof "4.0.0-alpha.18" !== 'undefined' ? "4.0.0-alpha.18" : 'latest';
8
8
  exports.VERSION = VERSION;
9
9
  //# sourceMappingURL=version.js.map
@@ -1,2 +1,2 @@
1
- export const VERSION = typeof "4.0.0-alpha.17" !== 'undefined' ? "4.0.0-alpha.17" : 'latest';
1
+ export const VERSION = typeof "4.0.0-alpha.18" !== 'undefined' ? "4.0.0-alpha.18" : 'latest';
2
2
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/3d-tiles",
3
- "version": "4.0.0-alpha.17",
3
+ "version": "4.0.0-alpha.18",
4
4
  "description": "3D Tiles, an open standard for streaming massive heterogeneous 3D geospatial datasets.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -34,11 +34,11 @@
34
34
  "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/dist.min.js"
35
35
  },
36
36
  "dependencies": {
37
- "@loaders.gl/draco": "4.0.0-alpha.17",
38
- "@loaders.gl/gltf": "4.0.0-alpha.17",
39
- "@loaders.gl/loader-utils": "4.0.0-alpha.17",
40
- "@loaders.gl/math": "4.0.0-alpha.17",
41
- "@loaders.gl/tiles": "4.0.0-alpha.17",
37
+ "@loaders.gl/draco": "4.0.0-alpha.18",
38
+ "@loaders.gl/gltf": "4.0.0-alpha.18",
39
+ "@loaders.gl/loader-utils": "4.0.0-alpha.18",
40
+ "@loaders.gl/math": "4.0.0-alpha.18",
41
+ "@loaders.gl/tiles": "4.0.0-alpha.18",
42
42
  "@math.gl/core": "^3.5.1",
43
43
  "@math.gl/geospatial": "^3.5.1",
44
44
  "@probe.gl/log": "^4.0.4",
@@ -47,5 +47,5 @@
47
47
  "peerDependencies": {
48
48
  "@loaders.gl/core": "^4.0.0-alpha.8"
49
49
  },
50
- "gitHead": "68a743e2460cc89bf89edabfd08b395380d7d10c"
50
+ "gitHead": "7bc633f46560f661bdd46cf1015ea27b3694ebce"
51
51
  }