@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/CHANGELOG.md +3 -0
- package/gltf-progressive.js +125 -123
- package/gltf-progressive.min.js +8 -8
- package/gltf-progressive.umd.cjs +8 -8
- package/lib/loaders.js +24 -34
- package/lib/version.js +1 -1
- package/package.json +1 -1
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
|
-
|
|
12
|
-
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
package/package.json
CHANGED