GLB/GLTF models loading control (notificaitons, cancellation)

1. A concise explanation of the problem you’re experiencing.

If a developer would like to display 3d model (gltf-file) according to Cesium documentation (https://cesiumjs.org/Cesium/Build/Documentation/Entity.html) he has to provide URL to a file with 3d model. See example below. In this case Cesium downloads this model by itself and displays it on a map. Unfortunately, there is no ability to understand when Cesium has downloaded the files and is ready to render it. We need this event, callback or “promise” to start further actions.

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

image.png

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

There is a number of scenarios in which notifications about loading of models is required.

  1. We are monitoring the Camera and load models that supposedly appear attached to the visible part of the ground. When the camera moves away, we want to be able to remove the models from the view and, ideally, cancel the loading if it is still in progress. We are talking about hundreds of models, which translates to large number of requests from the browser to server. Better control of the network traffic appears to be critical to us.

4. The Cesium version you’re using, your operating system and browser.

We use the latest Cesium version, which we use within mainly Chrome, Firefox and Safari on Windows, Linux, Android and iOS.

So it looks like when you load a model with the Entity API, the engine will load it as a primitive behind the scenes (see here https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/DataSources/ModelVisualizer.js#L118-L130 )

The class Cesium.Model does contain a readyPromise (https://cesiumjs.org/Cesium/Build/Documentation/Model.html#readyPromise) that allows you to check once the model has been loaded and is ready to display. So if you need to access it you might need to construct the primitive yourself as described here: https://cesiumjs.org/tutorials/3D-Models-Tutorial/

I hope this helps!

Looks like this is already a requested feature for Cesium:

https://github.com/AnalyticalGraphicsInc/cesium/issues/4727

Thank you Omar,

much appreciated your answer!

Also Alex, it sounds like what you’re trying to accomplish – requesting models within certain views, prioritizing requests, and cancelling unneeded ones – is exactly what 3D Tiles does. Have you looked into them at all?

Blog post - https://cesium.com/blog/2015/08/10/introducing-3d-tiles/

Spec - https://github.com/AnalyticalGraphicsInc/3d-tiles