There is an error flying to entity in the event of waiting for the map to be loaded

There is an error flying to entity in the event of waiting for the map to be loaded.
sandcastle Demo
This is my code.

    const helper = new Cesium.EventHelper()
    helper.add(viewer.scene.globe.tileLoadProgressEvent, (e) => {

      if (e === 0) {

        helper.removeAll()

        const entity = viewer.entities.add({
          position: Cesium.Cartesian3.fromDegrees(117, 30, 39),
          point: {
            color: Cesium.Color.RED,
            size: 6
          }
        })

        viewer.flyTo(entity)

      }
    })


Entity has been added to entities. Why is the array here empty

Replace this line with:

setTimeout(()=>{
  viewer.flyTo(entity);
},10);

Sometimes we invoke some task before completing the render process. Iā€™m not sure if it will work, but you can try this approach.

This means that the map does not start rendering after loading. Can I manually call the rendering function before the flyto method? Of course, using setimeout can solve this problem :thinking:

Yes you can call viewer.scene.requestRender();

1 Like

@Jacky, thanks for the input :pray: