Tech

Three.js without the headache: our production setup

Close-up of a circuit board
Photo: Unsplash

WebGL scenes have a reputation for being beautiful demos and painful products. After shipping a dozen of them to real clients, we settled on a setup that keeps the beauty and removes most of the pain.

Content first, scene second

The page renders and becomes usable without the 3D layer. Three.js loads afterwards, deferred, and the canvas fades in when the first frame is ready. If WebGL is unavailable, a designed fallback image takes its place.

Our budgets

  • Under 150 KB of compressed JavaScript for the scene.
  • Pixel ratio capped at 1.5 — sharp enough, half the GPU work of 3×.
  • 60 fps on a three-year-old mid-range phone, or the effect is simplified.
  • The render loop pauses when the canvas leaves the screen.

Shaders over models

Where we can, we draw with shaders instead of loading heavy models. A full-screen fragment shader can produce a living, brand-coloured backdrop in a few kilobytes — the \”molten silk\” on our own homepage is one of them.

The best WebGL is the kind visitors feel before they notice.

Lucas Brandt, Creative Developer
Written by

admin

View all 13 stories

Leave a comment

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *