How God’s Eye View Caps the CesiumJS Render Loop at 60 FPS for Performance
God’s Eye View leverages CesiumJS’s requestRenderMode and maximumRenderTimeChange options to throttle the render loop to a maximum of 60 frames per second, eliminating unnecessary GPU work when the 3D scene is static.
The open-source bilawalsidhu/gods-eye-view repository visualizes complex geospatial datasets using CesiumJS, where unchecked render loops can drain battery and overheat GPUs during idle periods. By configuring the Cesium Viewer initialization in src/main.js, the project enforces a hard 60 FPS ceiling that respects browser paint scheduling while maintaining smooth interactivity during camera movements and layer updates.
Understanding CesiumJS Render Loop Throttling
CesiumJS defaults to a continuous requestAnimationFrame loop that redraws as fast as hardware allows, often exceeding 60 FPS on high-refresh displays. To cap the CesiumJS render loop at 60 FPS, God’s Eye View passes two critical configuration options to the Viewer constructor:
requestRenderMode: When set totrue, this switches the engine from continuous rendering to demand-based rendering. Frames are only drawn when the camera, entities, or imagery layers change.maximumRenderTimeChange: Set to1 / 60(approximately 0.0167 seconds), this defines the maximum allowed interval between render calls, effectively enforcing the 60 FPS limit even during active interaction.
This combination ensures that if the globe is idle, Cesium skips frames entirely rather than wasting cycles re-drawing identical pixels.
Implementation in the Source Code
Viewer Initialization in src/main.js
The primary configuration occurs when instantiating the global viewer object. In src/main.js, the constructor receives the throttling parameters that activate the capped render loop:
// src/main.js
const viewer = new Cesium.Viewer('cesiumContainer', {
requestRenderMode: true,
maximumRenderTimeChange: 1 / 60,
// additional Cesium configuration...
});
By enabling requestRenderMode, the code disables Cesium’s default behavior of calling requestAnimationFrame indefinitely. The maximumRenderTimeChange parameter guarantees that even when continuous updates are required—such as during camera flights—the engine never exceeds the 60 FPS budget.
Camera and Scene Updates
When requestRenderMode is active, Cesium relies on explicit change notifications to trigger new frames. The repository handles camera movements and layer updates in src/camera.js, where interactions forcing a re-render include:
- User zoom or rotate operations
- Terrain tile loading completions
- Entity property modifications
These events implicitly call viewer.scene.requestRender(), queuing a single frame that respects the maximumRenderTimeChange constraint defined in the initialization. For heavy UI operations, optional governor logic in src/renderGovernor.js may further suppress unnecessary render calls.
Runtime Configuration and Animation Overrides
While the default cap improves battery life, certain workflows—such as high-speed flythroughs—require temporary frame-rate boosts. You can dynamically adjust the CesiumJS 60 FPS cap at runtime by modifying the Scene instance:
// Temporarily increase to 120 FPS for smooth animation
viewer.scene.requestRenderMode = false;
viewer.scene.maximumRenderTimeChange = 1 / 120;
// Re-enable the 60 FPS cap after animation completes
viewer.scene.requestRenderMode = true;
viewer.scene.maximumRenderTimeChange = 1 / 60;
This approach allows God’s Eye View to balance performance and visual fidelity without restarting the Viewer or reloading terrain tiles.
Summary
- God’s Eye View configures CesiumJS with
requestRenderMode: trueandmaximumRenderTimeChange: 1/60insrc/main.jsto enforce a 60 FPS ceiling. - The
requestRenderModeoption eliminates redundant rendering when the scene is static, reducing GPU utilization during idle periods. maximumRenderTimeChangeguarantees the frame rate never exceeds 60 FPS, even during continuous camera movement or data updates.- Runtime adjustments to
viewer.scene.maximumRenderTimeChangeallow temporary frame-rate increases for specific animations or high-refresh displays.
Frequently Asked Questions
What does requestRenderMode do in CesiumJS?
requestRenderMode converts Cesium from a continuous render loop to a demand-based system. When enabled, the engine only schedules new frames after detecting changes to the camera, entities, or imagery layers, significantly reducing CPU and GPU load during idle states according to the God’s Eye View source code.
How does maximumRenderTimeChange limit frame rate?
maximumRenderTimeChange specifies the maximum time in seconds that should elapse between render calls. Setting this value to 1/60 ensures Cesium never renders more than 60 frames per second, effectively capping the refresh rate regardless of display capabilities or hardware performance.
Can I disable the 60 FPS cap for high-refresh monitors?
Yes. You can disable the cap by setting viewer.scene.requestRenderMode = false, which restores Cesium’s default unlimited frame-rate behavior, or by decreasing maximumRenderTimeChange to 1/120 or 1/144 to match high-refresh displays. These properties can be toggled at runtime without reinitializing the Viewer.
Where is the render loop configured in God’s Eye View?
The render loop configuration resides in src/main.js, where the Cesium.Viewer constructor receives the requestRenderMode and maximumRenderTimeChange options. Camera interactions that trigger re-renders are handled in src/camera.js, while optional governor logic may reside in src/renderGovernor.js to pause rendering during intensive UI operations.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →