Skip to content

Incorrect type for terrain provider #13068

@dylantf

Description

@dylantf

What happened?

The TypeScript type for the terrainProvider property on the viewer, scene, and globe instances all indicates that it is a TerrainProvider, however in some cases it is undefined, as terrain appears to be loaded asynchronously and the property is set to undefined during this time. This can cause runtime errors if we believe the type that it is never undefined.

Reproduction steps

  1. Mount a Cesium viewer with terrain specified
  2. Log viewer.scene.terrainProvider

Sandcastle example

https://sandcastle.cesium.com/#c=jZBRS8MwFIX/yqVPrZQUX7e2CMMHYaDg0Je8ZMndFrxNRpJ2TPG/2zYtOJXh4z35zrknVzdH6wLcgPCwQq/bBnbONsATOU48WXLDjbTGB+g0ntBBBQZPE81eRi2d+ZU1QWiDjic5fHADENC5XlnMhk2c2bDm1TpSk5BmOTef2TIus4SM7L7PfTA6aEFzDhyd7bRCtxg2xEbMSzTIJuJpArKx+TVidRBmj4oJpe47NGGtfegxl6YZVHWsf1lm86MEyBjxrzLj55I8KX04E9ZD+p2O928dpYwVAZsjiYC+2LbyDQOT3g+mspgtpdIdaFX9cW+QJLzvX3Yt0bN+R57UZdHzFzayQmmzf+zQkTgPyOG2XkeRMVYW/fjbFaylrXDfEr8A

Environment

Browser: Chrome
CesiumJS Version: 1.136.0
Operating System: Linux/Fedora 43

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions