three.js icon indicating copy to clipboard operation
three.js copied to clipboard

ImageUtils.loadTexture can't load image with full url path

Open kingseaeast opened this issue 15 years ago • 1 comments

I'm trying to load a image with ImageUtils.loadTexture.

The following works: THREE.ImageUtils.loadTexture( "img/me.png", THREE.UVMapping, callbackAvatar(x, y) );

The following doesn't: THREE.ImageUtils.loadTexture( "http://foobar.com/img/me.png", THREE.UVMapping, callbackAvatar(x, y) );

Any insight on why?

kingseaeast avatar Nov 18 '11 22:11 kingseaeast

If full URL path is at different domain than your HTML / JS than you can't use image from there in WebGL unless that server allows anonymous CORS requests.

http://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing http://www.khronos.org/registry/webgl/specs/latest/#4.2

If it's the same server, then there may be a bug somewhere.

There was a recent bug in Webkit / Chrome about anonymous CORS requests for the same server:

https://github.com/mrdoob/three.js/issues/687

It was fixed, but maybe there is a different code path for fully specified URLs.

alteredq avatar Nov 18 '11 22:11 alteredq