Scene ready event?

Dear community,

after the globe is rendered I want to do something with the view object. But I didn’t find an event for this. How is this done? The examples didn’t help me much. They all react on input and I cannot find an event to hook into when Cesium is done rendering the globe.

Something like this:

viewer.scene.readyEvent(function(){
//do something with viewer instance
});

How would you accomplish this?

Thanks in advance for your time and effort!

Best regards,

Stefanie

It depends on what you mean by “ready”. Most operations in Cesium can be performed immediately after constructing the Viewer or Scene, without any need for a callback.

If you need to do something before or after every frame is rendered, Scene provides two events - preRender and postRender. For example,

viewer.scene.postRender.addEventListener(function(scene, time) {

});

Hi Scott, I also encounter the same issue.
that is to say, I want to load a gif file till the datasource is ready,rendered (I can see within the globe).
I have used the event dataSources.dataSourcesAdded but it is fired very early before my datasource is rendered withing the globe, in conclusion, my gif file is just like showing and disappearing in one instant. I have tested the postRender event but I saw that the render function is always be called.
Which event can I use to solve the issue?

Thanks
Regards

Scott,

This eventListener example fires over and over and won’t work in Stephanie’s, Valimo’s or my case.
I too am looking for a solution to call a function when everything is rendered. I have KML data coming in that is dynamic in size and I’ll never know when the scene is ready. I don’t want to assume the scene is ready for me to perform another action until it actually is.

Any help is appreciated.

-Gerry