Promise for images in materials?

Hi everybody,

Been chugging through the docs trying to find this, but my GoogleFoo is a bit lacking, so I’ll ask here;

Is there a way to get a promise for when you use images in materials / uniforms? I’m creating some primitive objects and use images for some of them;

material: new Cesium.Material({
            fabric: {
                type: 'DiffuseMap',
                uniforms: { image: url }

Some of these images are quite large and takes some time, so is there a way to either get a promise for them, or some other means of reporting when the image is starting to load / loading / finished loading?

I dug into Cesium.Resource, but didn’t find any documentation or examples of those working with material / uniform URLs. If I create a Resource, are they interchangable with image:url --> image:resource?

Any ideas?



So, to answer my own question: yes, Cesium.Resource is the way;

Cesium.Resource.fetchImage({ url: myUrl}).then( image => { ... });

And it creates a safe Resource (in this case a DOM Image object) which matieral -> uniform accepts. Still trying to work out if the image is cached (and still available for canvas/context manipulation), or locked in, but one thing at a time.