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:
- Make sure your GLB/mesh has vertex normals exported. Without normals, CesiumJS can’t compute shading, and the model will render flat.
- If you have very dark results after enabling enableLighting, the Light decrease even in day after enableLighting Globe thread has some useful context.
- An older thread, Sunset/Sunrise + Night Lighting for Terrains and Models, covers the same fundamentals and mentions that deeper per-model lighting customization requires custom shaders if you want things like warm sunset colors.
Let me know if you run into any issues!
Cheers!