Hi, How can I properly implement day and night cycles in Mesh and models?
Right now, my solution involves simply adjusting the brightness to make the image darker. Is there a better way?
Hi, How can I properly implement day and night cycles in Mesh and models?
Right now, my solution involves simply adjusting the brightness to make the image darker. Is there a better way?
Hey @Vitaliy_04,
Welcome to the forum!
CesiumJS has built-in sun-position lighting, so you don’t need to manually fake brightness changes. The key property is scene.globe.enableLighting = true. Once enabled, the globe and terrain shade based on the current sun position, which CesiumJS derives automatically from your viewer’s clock time. GLB models and meshes with proper normals will also respond to the scene’s directional light (a SunLight by default), darkening on the night side naturally.
// Enable sun-based shading on the globe and models
viewer.scene.globe.enableLighting = true;
// Set the clock to nighttime to see the effect immediately
viewer.clock.currentTime = Cesium.JulianDate.fromIso8601("2026-01-15T02:00:00Z");
// Or animate through day/night automaticallyviewer.clock.multiplier = 500; // 500x real timeviewer.clock.shouldAnimate = true;
If your models look too dark at night, you can tune the light intensity. The default SunLight intensity is 2.0:
// Increase intensity to prevent a pitch-black night side
viewer.scene.light = new Cesium.SunLight({ intensity: 3.0 });
A few things to check if lighting doesn’t look right on your models:
Let me know if you run into any issues!
Cheers!