getBoundingSphere() does not write value

Hi! I am trying to get the bounding box of an entity using the dataSourceDisplay.getBoundingSphere() function. On sandcastle, the function does not write any value to the bounding sphere object I pass in:


// create an entity
const blueBox = viewer.entities.add({
  name: "Blue box",
  position: Cesium.Cartesian3.fromDegrees(-114.0, 40.0, 300000.0),
  box: {
    dimensions: new Cesium.Cartesian3(400000.0, 300000.0, 500000.0),
    material: Cesium.Color.BLUE,

// get the bounding sphere
let boundingSphere = new Cesium.BoundingSphere();
const state = viewer.dataSourceDisplay.getBoundingSphere(


In my local environment, it raises a runtime error:

F12 trace to here

I am using windows with cesium@1.106.1, the codebase is just the cesium webpack example with similar code in the sandcastle example above added.

How should I get the bounding sphere of an entity?

Update for people who may run into the same issue in the future. There was no bug; the error happened simply because the entity was not ready yet. You can call this function later to resolve this issue. Since the model I wanted to load were pretty large and took up to dozens of seconds to load, I resolved the issue by setting up a setTimeout() function that returns and checks every second.