GltfLoader crossOrigin=’use-credentials’ does not set withCredentials on FileLoader

Description of the problem

We are using cookies to authenticate requests to a data store. GLTFLoader is used to load 3D models from this data store. We have been trying to set crossOrigin = 'use-credentials or setCrossOrigin('use-credentials');, however, cookies are not being sent to download the GLB/GLTF file.

From reviewing the code for GLTFLoader it appears that withCredentials is not being set on FileLoader when crossOrigin === ‘use-credentials’. See these lines:

var loader = new THREE.FileLoader( scope.manager );
loader.setPath( this.path );
loader.setResponseType( ‘arraybuffer’ );
loader.load( url, function ( data ) {

It appears that the solution is to check if crossOrigin === 'use-credentials and call loader.setWithCredentials(true) around line 70.

Three.js version
  • [] Dev
  • r104
  • r97
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, …)

Author: Fantashit

1 thought on “GltfLoader crossOrigin=’use-credentials’ does not set withCredentials on FileLoader

Comments are closed.