Hey,
i searched for hours to find an example for a custom render loop in cesium.
I want to update some data depend on the time in the Viewer.
All i found is this:
viewer = new Cesium.Viewer('globe-div', {
fullscreenButton: false,
timeline: false,
animation: false,
useDefaultRenderLoop:false
});
var ac = viewer.animationController;
function tick() {
// Uncaught TypeError: Cannot read property 'update' of undefined
var time = ac.update();
viewer.update(time);
viewer.render();
Cesium.requestAnimationFrame(tick);
}
tick();
But animationController is undefined
How is it possible to do something every frame, especially i need the time and i want to change some camera settings.
Thanks for your help
Okay, sorry for the new topic.... i just found the solution
function tick() {
viewer.render();
Cesium.requestAnimationFrame(tick);
}
Cesium.requestAnimationFrame(tick);
works great
Sorry, holiday weekend kept me busy.
Yes, that is exactly the appropriate method for maintaining your own custom animation loop.
I have a bit of followup to send your way
It sounds like what you actually want to do does not require a custom render loop. You would be better served by using the scene preRender or postRender events to do something every frame. Rarely will developers need a completely custom render loop and in general we always recommend against it.
If your application is an exception and the pre/post Render events will not provide you with the access you need, than I recommend referencing the CesiumWidget’s render loop for guidance.
One last piece of advice: Wrap your loops code in a try/catch block. If you don’t your render loop will not be able to report errors and you will only get silent failures making the debugging process in your application incredibly painful.
-Mike