Google Chrome and Firefox are blocking cross-domain image in WebGL (because of a security issue). This is really annoying when you want to display image from other domain in WebGL. To bypass this same-origin-policy restriction you have several options:
- Ask the other domain to add a CORS http header
- Use a proxy
- Use my trick
Ok, to be honest my “trick” only work for browser extensions (tested with Google Chrome extension only). How is it working?
- Add the domain in the list of allowed cross-domain ajax call in the manifest of the extension.
- Do a binary ajax request on the jpeg
- Fill the WebGL texture with the jpeg decoded in JS
The drawbacks are that it can only be used by browser extensions and that JS jpeg decoding is slow compared to native decoding.
I’ve used this workaround to add the pictures in my WebGL PhotoSynth Viewer extension.
I’ve posted a new version which is really much faster.