<h5 dir="auto">Description of the problem</h5>
<p dir="auto">Hello ! This is my first post on this Github, and first, I realy want to congratulate mrdoob and all of contributors for this awesome project.<br>
This isnt an real issue, because i found a way to do what i wanted.</p>
<p dir="auto">So the problem is that TextureLoader and more precisely ImageLoader doesnt allow to add custom headers to get an image from an url. I needed to add headers because in my application, i get all textures from an api that authenticate users on each request with a JWT Token.</p>
<p dir="auto">To succeed I decided to change TextureLoader and ImageLoader load function this way :</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="/**
* @author mrdoob / http://mrdoob.com/
*/

function ImageLoader( manager ) {

 this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;

}

Object.assign( ImageLoader.prototype, {

 load: function ( url, onLoad, onProgress, onError, customHeaders ) {
	 console.log(url, 'TEST LOAD');

	 if ( url === undefined ) url = '';

	 if ( this.path !== undefined ) url = this.path + url;

	 var scope = this;

	 var cached = Cache.get( url );

	 if ( cached !== undefined ) {

		 scope.manager.itemStart( url );

		 setTimeout( function () {

			 if ( onLoad ) onLoad( cached );

			 scope.manager.itemEnd( url );

		 }, 0 );

		 return cached;

	 }

	 var image = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'img' );

	 image.addEventListener( 'load', function () {

		 Cache.add( url, this );

		 if ( onLoad ) onLoad( this );

		 scope.manager.itemEnd( url );

	 }, false );

	 
	 // image.addEventListener( 'progress', function ( event ) {

	 // 	if ( onProgress ) onProgress( event );

	 // }, false );
	 

	 image.addEventListener( 'error', function ( event ) {

		 if ( onError ) onError( event );

		 scope.manager.itemEnd( url );
		 scope.manager.itemError( url );

	 }, false );

	 if ( url.substr( 0, 5 ) !== 'data:' ) {

		 if ( this.crossOrigin !== undefined ) image.crossOrigin = this.crossOrigin;

	 }

	 scope.manager.itemStart( url );
	 console.log(customHeaders);
	 const options = {
		 headers: customHeaders
	 };
	 
	 fetch(url, options)
	 .then(res =&gt; res.blob())
	 .then(blob =&gt; {
		 image.src = URL.createObjectURL(blob);
	 });

	 // image.src = url;

	 return image;

 },

 setCrossOrigin: function ( value ) {

	 this.crossOrigin = value;
	 return this;

 },

 setPath: function ( value ) {

	 this.path = value;
	 return this;

 }

} );"><pre class="notranslate"><span class="pl-c">/**</span>
<span class="pl-c">* <span class="pl-k">@author</span> mrdoob / http://mrdoob.com/</span>
<span class="pl-c">*/</span>

<span class="pl-k">function</span> <span class="pl-v">ImageLoader</span><span class="pl-kos">(</span> <span class="pl-s1">manager</span> <span class="pl-kos">)</span> <span class="pl-kos">{</span>

 <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">manager</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span> <span class="pl-s1">manager</span> <span class="pl-c1">!==</span> <span class="pl-c1">undefined</span> <span class="pl-kos">)</span> ? <span class="pl-s1">manager</span> : <span class="pl-v">DefaultLoadingManager</span><span class="pl-kos">;</span>

<span class="pl-kos">}</span>

<span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">assign</span><span class="pl-kos">(</span> <span class="pl-v">ImageLoader</span><span class="pl-kos">.</span><span class="pl-c1">prototype</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>

 <span class="pl-en">load</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span> <span class="pl-s1">url</span><span class="pl-kos">,</span> <span class="pl-s1">onLoad</span><span class="pl-kos">,</span> <span class="pl-s1">onProgress</span><span class="pl-kos">,</span> <span class="pl-s1">onError</span><span class="pl-kos">,</span> <span class="pl-s1">customHeaders</span> <span class="pl-kos">)</span> <span class="pl-kos">{</span>
	 <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">url</span><span class="pl-kos">,</span> <span class="pl-s">'TEST LOAD'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

	 <span class="pl-k">if</span> <span class="pl-kos">(</span> <span class="pl-s1">url</span> <span class="pl-c1">===</span> <span class="pl-c1">undefined</span> <span class="pl-kos">)</span> <span class="pl-s1">url</span> <span class="pl-c1">=</span> <span class="pl-s">''</span><span class="pl-kos">;</span>

	 <span class="pl-k">if</span> <span class="pl-kos">(</span> <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">path</span> <span class="pl-c1">!==</span> <span class="pl-c1">undefined</span> <span class="pl-kos">)</span> <span class="pl-s1">url</span> <span class="pl-c1">=</span> <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">path</span> <span class="pl-c1">+</span> <span class="pl-s1">url</span><span class="pl-kos">;</span>

	 <span class="pl-k">var</span> <span class="pl-s1">scope</span> <span class="pl-c1">=</span> <span class="pl-smi">this</span><span class="pl-kos">;</span>

	 <span class="pl-k">var</span> <span class="pl-s1">cached</span> <span class="pl-c1">=</span> <span class="pl-v">Cache</span><span class="pl-kos">.</span><span class="pl-en">get</span><span class="pl-kos">(</span> <span class="pl-s1">url</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>

	 <span class="pl-k">if</span> <span class="pl-kos">(</span> <span class="pl-s1">cached</span> <span class="pl-c1">!==</span> <span class="pl-c1">undefined</span> <span class="pl-kos">)</span> <span class="pl-kos">{</span>

		 <span class="pl-s1">scope</span><span class="pl-kos">.</span><span class="pl-c1">manager</span><span class="pl-kos">.</span><span class="pl-en">itemStart</span><span class="pl-kos">(</span> <span class="pl-s1">url</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>

		 <span class="pl-en">setTimeout</span><span class="pl-kos">(</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>

			 <span class="pl-k">if</span> <span class="pl-kos">(</span> <span class="pl-s1">onLoad</span> <span class="pl-kos">)</span> <span class="pl-s1">onLoad</span><span class="pl-kos">(</span> <span class="pl-s1">cached</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>

			 <span class="pl-s1">scope</span><span class="pl-kos">.</span><span class="pl-c1">manager</span><span class="pl-kos">.</span><span class="pl-en">itemEnd</span><span class="pl-kos">(</span> <span class="pl-s1">url</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>

		 <span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-c1">0</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>

		 <span class="pl-k">return</span> <span class="pl-s1">cached</span><span class="pl-kos">;</span>

	 <span class="pl-kos">}</span>

	 <span class="pl-k">var</span> <span class="pl-s1">image</span> <span class="pl-c1">=</span> <span class="pl-smi">document</span><span class="pl-kos">.</span><span class="pl-en">createElementNS</span><span class="pl-kos">(</span> <span class="pl-s">'http://www.w3.org/1999/xhtml'</span><span class="pl-kos">,</span> <span class="pl-s">'img'</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>

	 <span class="pl-s1">image</span><span class="pl-kos">.</span><span class="pl-en">addEventListener</span><span class="pl-kos">(</span> <span class="pl-s">'load'</span><span class="pl-kos">,</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>

		 <span class="pl-v">Cache</span><span class="pl-kos">.</span><span class="pl-en">add</span><span class="pl-kos">(</span> <span class="pl-s1">url</span><span class="pl-kos">,</span> <span class="pl-smi">this</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>

		 <span class="pl-k">if</span> <span class="pl-kos">(</span> <span class="pl-s1">onLoad</span> <span class="pl-kos">)</span> <span class="pl-s1">onLoad</span><span class="pl-kos">(</span> <span class="pl-smi">this</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>

		 <span class="pl-s1">scope</span><span class="pl-kos">.</span><span class="pl-c1">manager</span><span class="pl-kos">.</span><span class="pl-en">itemEnd</span><span class="pl-kos">(</span> <span class="pl-s1">url</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>

	 <span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-c1">false</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>

	 
	 <span class="pl-c">// image.addEventListener( 'progress', function ( event ) {</span>

	 <span class="pl-c">// 	if ( onProgress ) onProgress( event );</span>

	 <span class="pl-c">// }, false );</span>
	 

	 <span class="pl-s1">image</span><span class="pl-kos">.</span><span class="pl-en">addEventListener</span><span class="pl-kos">(</span> <span class="pl-s">'error'</span><span class="pl-kos">,</span> <span class="pl-k">function</span> <span class="pl-kos">(</span> <span class="pl-s1">event</span> <span class="pl-kos">)</span> <span class="pl-kos">{</span>

		 <span class="pl-k">if</span> <span class="pl-kos">(</span> <span class="pl-s1">onError</span> <span class="pl-kos">)</span> <span class="pl-s1">onError</span><span class="pl-kos">(</span> <span class="pl-s1">event</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>

		 <span class="pl-s1">scope</span><span class="pl-kos">.</span><span class="pl-c1">manager</span><span class="pl-kos">.</span><span class="pl-en">itemEnd</span><span class="pl-kos">(</span> <span class="pl-s1">url</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>
		 <span class="pl-s1">scope</span><span class="pl-kos">.</span><span class="pl-c1">manager</span><span class="pl-kos">.</span><span class="pl-en">itemError</span><span class="pl-kos">(</span> <span class="pl-s1">url</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>

	 <span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-c1">false</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>

	 <span class="pl-k">if</span> <span class="pl-kos">(</span> <span class="pl-s1">url</span><span class="pl-kos">.</span><span class="pl-en">substr</span><span class="pl-kos">(</span> <span class="pl-c1">0</span><span class="pl-kos">,</span> <span class="pl-c1">5</span> <span class="pl-kos">)</span> <span class="pl-c1">!==</span> <span class="pl-s">'data:'</span> <span class="pl-kos">)</span> <span class="pl-kos">{</span>

		 <span class="pl-k">if</span> <span class="pl-kos">(</span> <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">crossOrigin</span> <span class="pl-c1">!==</span> <span class="pl-c1">undefined</span> <span class="pl-kos">)</span> <span class="pl-s1">image</span><span class="pl-kos">.</span><span class="pl-c1">crossOrigin</span> <span class="pl-c1">=</span> <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">crossOrigin</span><span class="pl-kos">;</span>

	 <span class="pl-kos">}</span>

	 <span class="pl-s1">scope</span><span class="pl-kos">.</span><span class="pl-c1">manager</span><span class="pl-kos">.</span><span class="pl-en">itemStart</span><span class="pl-kos">(</span> <span class="pl-s1">url</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>
	 <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">customHeaders</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
	 <span class="pl-k">const</span> <span class="pl-s1">options</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
		 <span class="pl-c1">headers</span>: <span class="pl-s1">customHeaders</span>
	 <span class="pl-kos">}</span><span class="pl-kos">;</span>
	 
	 <span class="pl-en">fetch</span><span class="pl-kos">(</span><span class="pl-s1">url</span><span class="pl-kos">,</span> <span class="pl-s1">options</span><span class="pl-kos">)</span>
	 <span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-s1">res</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">res</span><span class="pl-kos">.</span><span class="pl-en">blob</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span>
	 <span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-s1">blob</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
		 <span class="pl-s1">image</span><span class="pl-kos">.</span><span class="pl-c1">src</span> <span class="pl-c1">=</span> <span class="pl-c1">URL</span><span class="pl-kos">.</span><span class="pl-en">createObjectURL</span><span class="pl-kos">(</span><span class="pl-s1">blob</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
	 <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

	 <span class="pl-c">// image.src = url;</span>

	 <span class="pl-k">return</span> <span class="pl-s1">image</span><span class="pl-kos">;</span>

 <span class="pl-kos">}</span><span class="pl-kos">,</span>

 <span class="pl-en">setCrossOrigin</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span> <span class="pl-s1">value</span> <span class="pl-kos">)</span> <span class="pl-kos">{</span>

	 <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">crossOrigin</span> <span class="pl-c1">=</span> <span class="pl-s1">value</span><span class="pl-kos">;</span>
	 <span class="pl-k">return</span> <span class="pl-smi">this</span><span class="pl-kos">;</span>

 <span class="pl-kos">}</span><span class="pl-kos">,</span>

 <span class="pl-en">setPath</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span> <span class="pl-s1">value</span> <span class="pl-kos">)</span> <span class="pl-kos">{</span>

	 <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">path</span> <span class="pl-c1">=</span> <span class="pl-s1">value</span><span class="pl-kos">;</span>
	 <span class="pl-k">return</span> <span class="pl-smi">this</span><span class="pl-kos">;</span>

 <span class="pl-kos">}</span>

<span class="pl-kos">}</span> <span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<h5 dir="auto">Three.js version</h5>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Dev</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> r110</li>
<li>[x ] old version</li>
</ul>
<h5 dir="auto">Browser</h5>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> All of them</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Chrome</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Firefox</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Internet Explorer</li>
</ul>
<h5 dir="auto">OS</h5>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> All of them</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Windows</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> macOS</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Linux</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Android</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> iOS</li>
</ul>
<h5 dir="auto">Hardware Requirements (graphics card, VR Device, ...)</h5>
<p dir="auto">Hi, this is my first post so first I want to thank mrdoob and all the contributors for this fantastic library.</p>
<h5 dir="auto">Description of the problem</h5>
<p dir="auto">I need to send specific headers with my TextureLoader request (XMLHttpRequest.setRequestHeader()) but I do not see any way to do that (I'm currently using r80).</p>
<h5 dir="auto">Three.js version</h5>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> r80</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> ...</li>
</ul>
<h5 dir="auto">Browser</h5>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> All of them</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Chrome</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Firefox</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Internet Explorer</li>
</ul>
<h5 dir="auto">OS</h5>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> All of them</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Windows</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Linux</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Android</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> IOS</li>
</ul>
<h5 dir="auto">Hardware Requirements (graphics card, VR Device, ...)</h5>