How to simulate flight with good FPS

I have my flight sim model that I’m feeding into Cesium. As you can see below I’m then calling camera.setView() every 200ms. However this is terribly slow, both the frame rate and the actual render in Chrome and in IE. Is there a way to speed this up, maybe use camera.move() instead? Or shall I try with requestAnimationFrame instead of setInterval? Something has to be possible :slight_smile:

var cameraInterval = setInterval(updateCamera, 200);

function updateCamera(){

var lat = flightModel.latitude;

var lon = flightModel.longitude;

var height = ModelContainer.acm.airdata.altitude;

var heading = flightModel.trueHeading;

var pitch = flightModel.pitch;

var roll = flightModel.roll;

var initialPosition = new Cesium.Cartesian3.fromDegrees(lon, lat, height);

var initialOrientation = new Cesium.HeadingPitchRoll.fromDegrees(heading, pitch, roll);

var camView = {

destination : initialPosition,

orientation : {

heading : initialOrientation.heading,

pitch : initialOrientation.pitch,

roll : initialOrientation.roll



// Set the initial view );


Hi there,

I’d avoiding using setInterval or even requestAnimationFrame directly. Instead try calling setView only when your flightModel properties change, or when you get user input. We have a camera tutorial with some examples of updating the camera based on input, hopefully that’s relevant to your application.



I’m already doing that. the flight model changes 5 times a second, and I’m trying to update camera with setView() 5 times a second. It’s still unbelievably slow.

Attaching the update to Scene.preRender rather than setInterval or requestAnimationFrame will help I think.