I have some complex animation running in cesium like constant camera rotation, billboard and polyline animation with interpolation, and at the same time i am capturing cesium canvas as base64 string at 30 fps because latter i have to make a video using those images. For some reason it produces lag and freezing in my animations and without the capturing stuff the animations run fine. Here is the code for capturing the canvas at 30 fps:
function PNGSequence( canvas ){
this.canvas = canvas;
this.sequence = ;
};
PNGSequence.prototype.capture = function( fps ){
var cap = this;
this.sequence.length=0;
this.timer = setInterval(function(){
cap.sequence.push( cap.canvas.toDataURL(“image/png”) );
},1000/fps);
};
PNGSequence.prototype.stop = function(){
if (this.timer) clearInterval(this.timer);
delete this.timer;
return this.sequence;
};
var myCanvas = viewer.canvas;
var recorder = new PNGSequence( myCanvas );
recorder.capture(30);
``
How should i prevent it from produces lag in animations? Can I run it on seperate thread? Is there any solution for this problem, or i need to find a different way of capturing frames?