Hello all,
i am playing around with cesium and i am trying to swap the image of a SingleTileImageryProvider efficiently. I was able to do this right now by removing the layer, swapping the image and re-adding the provider to the scene. Basically like this:
scene.imageryLayers.remove(templayer);
imgprov._image = new_image;
templayer = scene.imageryLayers.addImageryProvider(imgprov);
This works fine in principle but it seems to take very roughly around 300ms on my machine.
Is there a way to set the state of the layer or imagery provider in order to refresh the image cache or texture (not exactly sure how this is handled) without having to remove and re-add it? Or any direct way to refresh? (Even if it is a little hacky and not really intended)
Any help would be greatly appreciated!
Thanks in advance!
There really is no good method to do this that I know of.
If you’re just trying to show animations on the imagery you would probably be better off going with a rectangle geometry and using an html canvas for the texture.
Is there a meaningful difference in behavior between the ImageryProvider and RectangleGraphics? It seems like RG doesn't actually properly drape over terrain the way the IP does, at least looking at some KML I've loaded that has a GroundOverlay.
Patrick is completely correct on the alpha, but unless you need terrain draping, RectangleGraphics will be much faster (you can do full on animation/movie textures with some custom code). Terrain draping will be available for RectangeGraphics in Cesium soon enough but it will still expect it to be faster that SingleTileImageryProvider.
Hello all,
thank you for your helpful pointers. I will experiment around with Rectangles and swapping the textures there. For now i dont actually have any need for terrain draping, so that is fine. Still that functionality would be pretty cool, cant wait to see it.
Related to Rectangles, i was experimenting with them related to another thing and i was quite surprised when using a nearly global rectangle my FPS dropped to half like 30 when adding it to the scene. I tried reducing the granularity of the primitive a lot (i.e. Cesium.Math.RADIANS_PER_DEGREE * 20) which didnt have to much effect (if what i did even makes sense, at least i could see a “low poly” rectangle over the globe). When using smaller rectangles (e.g. europe extent) i could create a lot without a high performance hit. Is there something to be considered or done for bigger rectangles?
Thanks again,
kind regards,
Daniel
Are you using the same resolution image in both cases? Or are you scaling the resolution of the image with the size of the rectangle. If it’s the former than I’m not sure what the problem may be. If it’s the latter, you may be running into GPU limitations on your particular system.