Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Rendering a Planet in the Browser: MapLibre, WebGL, and Keeping a Globe at 60 FPS

You can render a live planet in the browser at 60 frames per second — even with tens of thousands of points on it — if you treat the map as a WebGL scene with a strict 16.6 ms frame budget, not as a pile of DOM elements. The trick is sending the GPU one big buffer, clustering aggressively at low zoom, and never doing layout work inside the render loop. I learned this building WorldEye , a…

Achieving a real-time, live rendering of a planet within a browser at a consistent 60 frames per second is made possible through the implementation of WebGL and a strategic approach to handling vast datasets. This technique is exemplified in the development of WorldEye, a real-time globe that integrates 74,229 live public cameras, flights, satellites, weather phenomena, earthquakes, and fires.

To accomplish this feat, the map must be viewed not as a collection of DOM elements, but as a WebGL scene, adhering to a strict frame budget of 16.6 milliseconds per frame. This budget encompasses all necessary computations, including JavaScript logic, layout adjustments, painting operations, and GPU rendering. Given that mid-range phones with a devicePixelRatio of 2 or 3 have a significantly reduced frame budget, optimization is crucial.

The dataset, consisting of 74,229 camera points, is not rendered as individual icons. Instead, it is clustered aggressively at lower zoom levels, meaning that features deemed significant at typical zoom levels (ranging from ~200 to 800) are displayed as distinct symbols. Anything beyond this threshold is either clustered or culled, reducing the rendering load.

MapLibre GL JS plays a pivotal role in this process by enabling the rendering of GeoJSON data sources directly in WebGL. This allows for batch processing of data, which is essential for efficient rendering. The challenge of rendering a globe is amplified due to three main factors: projection costs, the horizon culling requirement, and density variations.

Projection costs arise because vertices need to be transformed in real time as the globe rotates, a task that is more demanding in JavaScript when dealing with thousands of points. The horizon cull addresses the issue of rendering points that are not visible due to the curvature of the Earth, necessitating smart filtering to exclude such points from drawing operations.

Lastly, the density of points along world zoom levels creates clusters of overlapping icons, especially in populated areas, which can lead to overdraw—where pixels are drawn multiple times, consuming GPU resources.

The core solution involves using a single GeoJSON source for live layers, which is updated and styled declaratively. The implementation involves initializing a map with a globe projection, setting up a single clustered source for the cameras, and adding three distinct layers: one for clustered data, another for showing individual camera points with varying opacity based on their point count, and a third for rendering camera points as small circles.

By clustering points and offloading aggregation to MapLibre's worker thread, the main thread remains free to handle other tasks, thus significantly improving performance.

Key strategies include:

- Using one GeoJSON source per live layer and updating it as a whole rather than individually, to minimize the workload on the main thread.

- Leveraging cluster functionality within MapLibre GL JS to handle aggregation and reduce the number of draw calls.

- Designing a data-driven styling mechanism that utilizes step functions to manage symbol visibility based on point counts, allowing the GPU to efficiently process these decisions without the overhead of individual callbacks.

- Implementing a queue system for updating camera data to ensure that updates are processed in batches, rather than individually, preventing the browser from becoming overwhelmed.

By adhering to these principles—treating the map as a WebGL scene, utilizing clustering for large datasets, minimizing DOM interactions, and offloading complex computations to the GPU—developers can render detailed, live globes within browsers at high frame rates. This approach not only optimizes performance but also enhances the user experience by providing a smooth, interactive globe that remains responsive even under heavy data loads.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Digital Natives: Vulnerable Targets in a Scam-Filled World - SmarterArticles S1E31

Written by Tim Green, narrated by AI. Listen to the full episode here . 🎙️ Season 1, Episode 31 | Duration: 20:11 JPMorganChase told students returning to campus this autumn that their lifelong…

  • JPMorgan warns college students about online fraud despite tech skills.
  • FBI data shows $500M+ lost to internet crimes by 20-29 year olds in 2025.
  • Overconfidence in spotting scams due to AI-generated phishing emails.

Upload2Shell: check your Ghostscript version and stop trusting safe image pipelines

Upload2Shell, tracked as CVE-2026-125396, is a use-after-free in the Type 1 font loader of Ghostscript. A crafted document can escape the dSAFER sandbox.

  • CVE-2026-125396 is a use-after-free vulnerability in Ghostscript's Type 1 font loader
  • Exploited in Debian 13 CUPS, Roundcube 1.7.2, MediaWiki, and WordPress 7.0.0 to 7.0.3
  • Patched in Ghostscript version 10.08.0 on September 8th, 2026

More from Monday 23 November →