Skip to content

Commit 8d63780

Browse files
authored
set withCredentials for other loaders (#4085)
1 parent b6e8a11 commit 8d63780

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

packages/model-viewer/src/features/loading.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const DEFAULT_KTX2_TRANSCODER_LOCATION =
3434
'https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/';
3535

3636
const DEFAULT_LOTTIE_LOADER_LOCATION =
37-
'https://cdn.jsdelivr.net/npm/three@0.148.0/examples/jsm/loaders/LottieLoader.js';
37+
'https://cdn.jsdelivr.net/npm/three@0.149.0/examples/jsm/loaders/LottieLoader.js';
3838

3939
const RevealStrategy: {[index: string]: RevealAttributeValue} = {
4040
AUTO: 'auto',

packages/model-viewer/src/model-viewer-base.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,8 @@ export default class ModelViewerElementBase extends ReactiveElement {
397397
}
398398

399399
if (changedProperties.has('withCredentials')) {
400-
CachingGLTFLoader.withCredentials = this.withCredentials
400+
CachingGLTFLoader.withCredentials = this.withCredentials;
401+
this[$renderer].textureUtils!.withCredentials = this.withCredentials;
401402
}
402403

403404
if (changedProperties.has('generateSchema')) {

packages/model-viewer/src/three-components/TextureUtils.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* limitations under the License.
1414
*/
1515

16-
import {BackSide, BoxGeometry, CubeCamera, CubeTexture, EquirectangularReflectionMapping, EventDispatcher, HalfFloatType, LinearEncoding, Mesh, NoBlending, NoToneMapping, RGBAFormat, Scene, ShaderMaterial, sRGBEncoding, Texture, TextureLoader, Vector3, WebGLCubeRenderTarget, WebGLRenderer} from 'three';
16+
import {BackSide, BoxGeometry, CubeCamera, CubeTexture, EquirectangularReflectionMapping, EventDispatcher, HalfFloatType, LinearEncoding, Loader, Mesh, NoBlending, NoToneMapping, RGBAFormat, Scene, ShaderMaterial, sRGBEncoding, Texture, TextureLoader, Vector3, WebGLCubeRenderTarget, WebGLRenderer} from 'three';
1717
import {RGBELoader} from 'three/examples/jsm/loaders/RGBELoader.js';
1818

1919
import {deserializeUrl, timePasses} from '../utilities.js';
@@ -35,10 +35,11 @@ const HDR_FILE_RE = /\.hdr(\.js)?$/;
3535

3636
export default class TextureUtils extends EventDispatcher {
3737
public lottieLoaderUrl = '';
38+
public withCredentials = false;
3839

3940
private _ldrLoader: TextureLoader|null = null;
4041
private _hdrLoader: RGBELoader|null = null;
41-
private _lottieLoader = null;
42+
private _lottieLoader: Loader|null = null;
4243

4344
private generatedEnvironmentMap: Promise<CubeTexture>|null = null;
4445
private generatedEnvironmentMapAlt: Promise<CubeTexture>|null = null;
@@ -56,6 +57,7 @@ export default class TextureUtils extends EventDispatcher {
5657
if (this._ldrLoader == null) {
5758
this._ldrLoader = new TextureLoader();
5859
}
60+
this._ldrLoader.withCredentials = this.withCredentials;
5961
return this._ldrLoader;
6062
}
6163

@@ -64,14 +66,16 @@ export default class TextureUtils extends EventDispatcher {
6466
this._hdrLoader = new RGBELoader();
6567
this._hdrLoader.setDataType(HalfFloatType);
6668
}
69+
this._hdrLoader.withCredentials = this.withCredentials;
6770
return this._hdrLoader;
6871
}
6972

7073
async getLottieLoader(): Promise<any> {
7174
if (this._lottieLoader == null) {
7275
const {LottieLoader} = await import(this.lottieLoaderUrl);
73-
this._lottieLoader = new LottieLoader();
76+
this._lottieLoader = new LottieLoader() as Loader;
7477
}
78+
this._lottieLoader.withCredentials = this.withCredentials;
7579
return this._lottieLoader;
7680
}
7781

0 commit comments

Comments
 (0)