Skip to content

fix: guard verticalExaggeration against undefined to prevent Cesium crash#140

Merged
ZTongci merged 3 commits into
alphafrom
fix/verticalExaggeration
Jun 9, 2026
Merged

fix: guard verticalExaggeration against undefined to prevent Cesium crash#140
ZTongci merged 3 commits into
alphafrom
fix/verticalExaggeration

Conversation

@ZTongci

@ZTongci ZTongci commented Jun 8, 2026

Copy link
Copy Markdown

Bug

Enabling terrain for the first time when verticalExaggeration has not been
configured causes a Cesium crash:

  DeveloperError: scale must be a finite number.
      at VerticalExaggeration.getHeight
      at ScreenSpaceCameraController.update
      at Scene.initializeFrame

Root Cause

The previous code always passed property?.scene?.verticalExaggeration directly to <Scene>. When this value was never configured, it was always undefined — Resium saw no change between renders and never wrote anything to the Cesium scene, so Cesium kept its internal default of 1.0 untouched.

The terrain-disable fix changed this: when terrain is disabled we now explicitly pass 1, and when terrain is re-enabled we pass property?.scene?.verticalExaggeration. If no exaggeration is configured, the prop transitions from 1 (number) → undefined. Resium detects this as a prop change and actively calls scene.verticalExaggeration = undefined. Cesium's VerticalExaggeration.getHeight requires scale to be a finite number : undefined is not, so it throws a DeveloperError and halts rendering.

Fix

Add ?? 1 so undefined is never passed when terrain is enabled but no
exaggeration value has been set:

// Before
property?.terrain?.enabled ? property?.scene?.verticalExaggeration : 1

// After
property?.terrain?.enabled ? (property?.scene?.verticalExaggeration ?? 1) : 1

This ensures the prop is always a valid finite number, preventing Resium
from writing undefined into the Cesium scene.

@ZTongci ZTongci marked this pull request as ready for review June 8, 2026 11:18
airslice
airslice previously approved these changes Jun 9, 2026

@bnimit bnimit left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ZTongci ZTongci merged commit c15b693 into alpha Jun 9, 2026
2 of 3 checks passed
@ZTongci ZTongci deleted the fix/verticalExaggeration branch June 9, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants