ImageLoader does not URL-escape “+”

Description of the problem

AWS S3 rejects + in URLs (on GETs), nonconformant to spec. See https://forums.aws.amazon.com/thread.jspa?messageID=722673

It would be nice if there was maybe a way to configure ImageLoader to escape its url’s. It’s unclear if it would be safe to just change ImageLoader to escape its url’s. It would probably break people’s stuff.

Since my app directly loads from S3 for the time being, I see no quick way to fix this without continually patching my three.js from now on. Kind of lame, so I’m sort of just asking folks for how they would address this type of issue. Thanks.

I’m even considering hacking my MTL file data (which contain the relative paths to the particular jpgs in question here) to escape those pluses, just so I can avoid maintaining an additional patch on a core dependency. Only because it turns out that this is still practical for me to do at this time.

Three.js version
  • Dev
  • r89
  • r88

Author: Fantashit

1 thought on “ImageLoader does not URL-escape “+”

  1. You can override request URLs for any of the loaders using a LoadingManager, as long as the loader uses its manager correctly;

    var manager = new THREE.LoadingManager();
    manager.setURLModifier( ( url ) => url.replace( /\+/g, '%%2B' ) );
    
    var mtlLoader = new THREE.MTLLoader( manager );
    mtlLoader.load( 'my+materials.mtl', function () { ... } );  // '+' in URL will be escaped.

Comments are closed.