@needle-tools/gltf-progressive 4.0.0-alpha.3 → 4.0.0-alpha.4

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/lib/loaders.js CHANGED
@@ -8,40 +8,30 @@ let DEFAULT_KTX2_TRANSCODER_LOCATION = "https://cdn.needle.tools/static/three/0.
8
8
  const defaultDraco = DEFAULT_DRACO_DECODER_LOCATION;
9
9
  const defaultKTX2 = DEFAULT_KTX2_TRANSCODER_LOCATION;
10
10
  // #region Online check
11
- const _remoteDracoDecoderUrl = new URL(DEFAULT_DRACO_DECODER_LOCATION + "draco_decoder.js");
12
- // if (typeof window !== "undefined") {
13
- // if (!window.navigator.onLine) {
14
- // // check if the default values have been changed by the user.
15
- // // If they didnt change / the default paths are not reachable, fall back to local versions
16
- // if (DEFAULT_DRACO_DECODER_LOCATION === defaultDraco)
17
- // DEFAULT_DRACO_DECODER_LOCATION = "./include/draco/";
18
- // if (DEFAULT_KTX2_TRANSCODER_LOCATION === defaultKTX2)
19
- // DEFAULT_KTX2_TRANSCODER_LOCATION = "./include/ktx2/";
20
- // }
21
- // prepareLoaders();
22
- // }
23
- // Avoid cache busting - if we don't do this chrome will clear the fully cached file (potentially)
24
- _remoteDracoDecoderUrl.searchParams.append("range", "true");
25
- fetch(_remoteDracoDecoderUrl, {
26
- method: "GET",
27
- headers: {
28
- "Range": "bytes=0-1"
29
- }
30
- })
31
- .catch(_ => {
32
- console.debug(`Failed to fetch remote Draco decoder from ${DEFAULT_DRACO_DECODER_LOCATION} (offline: ${(typeof navigator !== "undefined") ? navigator.onLine : "unknown"})`);
33
- // check if the default values have been changed by the user.
34
- // If they didnt change / the default paths are not reachable, fall back to local versions
35
- if (DEFAULT_DRACO_DECODER_LOCATION === defaultDraco) {
36
- setDracoDecoderLocation("./include/draco/");
37
- }
38
- if (DEFAULT_KTX2_TRANSCODER_LOCATION === defaultKTX2) {
39
- setKTX2TranscoderLocation("./include/ktx2/");
40
- }
41
- })
42
- .finally(() => {
43
- prepareLoaders();
44
- });
11
+ if (typeof window !== "undefined") {
12
+ const remoteDracoDecoderUrl = new URL(DEFAULT_DRACO_DECODER_LOCATION + "draco_decoder.js");
13
+ // Avoid cache busting. Otherwise Chrome can discard the fully cached decoder.
14
+ remoteDracoDecoderUrl.searchParams.append("range", "true");
15
+ fetch(remoteDracoDecoderUrl, {
16
+ method: "GET",
17
+ headers: {
18
+ "Range": "bytes=0-1"
19
+ }
20
+ })
21
+ .catch(_ => {
22
+ console.debug(`Failed to fetch remote Draco decoder from ${DEFAULT_DRACO_DECODER_LOCATION} (offline: ${navigator.onLine})`);
23
+ // Keep user-defined locations. Only replace the defaults when they are unavailable.
24
+ if (DEFAULT_DRACO_DECODER_LOCATION === defaultDraco) {
25
+ setDracoDecoderLocation("./include/draco/");
26
+ }
27
+ if (DEFAULT_KTX2_TRANSCODER_LOCATION === defaultKTX2) {
28
+ setKTX2TranscoderLocation("./include/ktx2/");
29
+ }
30
+ })
31
+ .finally(() => {
32
+ prepareLoaders();
33
+ });
34
+ }
45
35
  // #region Loader Configuration
46
36
  /**
47
37
  * Return the current loader configuration.
package/lib/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // replaced at build time
2
- export const version = "4.0.0-alpha.3";
2
+ export const version = "4.0.0-alpha.4";
3
3
  globalThis["GLTF_PROGRESSIVE_VERSION"] = version;
4
4
  console.debug(`[gltf-progressive] version ${version || "-"}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/gltf-progressive",
3
- "version": "4.0.0-alpha.3",
3
+ "version": "4.0.0-alpha.4",
4
4
  "description": "three.js support for loading glTF or GLB files that contain progressive loading data",
5
5
  "homepage": "https://needle.tools",
6
6
  "author": {