How can I get Cesium to wait for construction of buildings before loading next tile

Hi all!

I have created an application that shows buildings in 3D. It is working quite allright for the moment.

Basic setup is as follows:

  • Buildings get rendered using a tiling scheme, the tile gets “activated” with the use of the position of the camera

  • When the tile is activated, a WFS request is sent.

  • Buildings get rendered with the use of the JSON response

What I want to add is: when all buildings of the activated tile are rendered, the app automatically starts loading the eight neighbouring tiles (cardinal & diagonal).

I’m facing a problem here:

  1. I would like the eight additional request to be loaded one by one in some kind of loop. So: sent out a WFS request, render the buildings of this tile, sent out next request, …

How can I do this?

This is my code so far

for (var x = -1; x < 2; x++) {

for (var y = -1; y < 2; y++) {

// Code to make the request

var promise = Cesium.loadJson(request);

promise.then(function(geoJson) {

// Construction of buildings

}

}

}

So far, this code just makes the 8 requests and loads them simultaneously, but this is slowing things down…

Any help is appreciated!

Wout