CORS and Billboard.image

I have a Javascript Image() object that I’ve successfully loaded from a CORS-enabled server, but when I attempt to use that image as the “image” member for a Billboard object, I get this error:

Billboard.js:952 Error loading image for billboard: SecurityError: Failed to execute ‘texSubImage2D’ on ‘WebGLRenderingContext’: The cross-origin image at [myImageURL] may not be loaded.

This is really strange, because I’ve already successfully loaded it into a JS Image() object. Why would this be a problem?



Found the solution to my problem (supported in at least FireFox and Chrome).

// Before setting the .src of the image, set:

myImage.crossOrigin = ‘anonymous’;

Explained nicely here:

  • Dave

Yes, images are not loaded with CORS by default. You can also use Cesium’s loadImage function which handles CORS as well as adapting the Image callback to a Promise, which is commonly used in Cesium.