diff --git a/README.md b/README.md index addb92e..091f1cb 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ window.CONFIG = { units: { temperature: 'C' }, // 'C' | 'F' credits: true, // data-attribution block in info box renderScale: 1, // 0.3..1 internal 3D resolution + maxFps: 30, // WebGL scene frame cap (0 = free) location: { // drives scene anchor, sun/moon, weather lat: 51.5074, // -90..+90, north positive diff --git a/background.html b/background.html index 4ea1cec..67456dc 100644 --- a/background.html +++ b/background.html @@ -569,17 +569,28 @@ window.__flightDir = _pickDir('flight'); window.__fetchDir = _pickDir('fetch'); // ---- WebGL scene (clouds3d.js) ------------------------------------------ +// CONFIG.maxFps caps the scene frame rate (default 30; 0 = free-running). +// All scene animation is time-based (cloud drift, traffic, bobbing), so a +// lower cap changes smoothness, never motion speed. The UI clock/theme +// loop is untouched. var sceneEl = document.getElementById('scene'); function sceneRender() { if (sceneEl && typeof window.clouds3dRender === 'function') { window.clouds3dRender(sceneEl); } } +var _maxFps = (window.CONFIG && typeof window.CONFIG.maxFps === 'number') + ? window.CONFIG.maxFps : 30; +var _frameGap = _maxFps > 0 ? 1000 / _maxFps : 0; +var _lastDraw = 0; sceneRender(); window.addEventListener('resize', sceneRender); (function sceneLoop() { - sceneRender(); window._sceneRaf = requestAnimationFrame(sceneLoop); + var t = performance.now(); + if (_frameGap && t - _lastDraw < _frameGap - 1) return; + _lastDraw = t; + sceneRender(); })(); function hexToRgb(h) { diff --git a/config.js b/config.js index b7c29c7..934a605 100644 --- a/config.js +++ b/config.js @@ -87,6 +87,9 @@ window.CONFIG = { // render the clouds/map shader at reduced resolution and upscale // via CSS - use it if fps is low (GPU-bound) despite a quiet CPU. renderScale: 1, + // WebGL scene frame cap (default 30; 0 = free-running/vsync). All + // scene motion is time-based, so the cap only changes smoothness. + maxFps: 30, location: { // Latitude and longitude for sun/moon calculations // Passau (vorher: Muenchen 48.1374/11.5755, Innsbruck 47.2692/11.4041)