Glossary · 3D on the web

WebGL

In short

WebGL (Web Graphics Library) is a JavaScript API that lets web pages draw hardware-accelerated 2D and 3D graphics in the browser without plug-ins. It renders into an HTML canvas element using the device's graphics hardware [1].

What WebGL is

WebGL closely follows OpenGL ES 2.0, a graphics interface for mobile and embedded devices. WebGL 2 is based on OpenGL ES 3.0 and adds features such as 3D textures and uniform buffer objects [1]. All modern browsers support WebGL, though the device also needs suitable graphics hardware [1].

How it is used

WebGL on its own is very low-level: create buffers, write shaders, issue draw commands. In practice almost every project uses a library such as three.js or Babylon.js that handles scenes, materials, cameras and glTF loading.

Limits worth knowing

  • GPU memory: large textures and many models can exhaust a phone's memory.
  • Context loss: the browser can lose a page's WebGL context, for example after a GPU driver reset or when resources run short; it reports this with the webglcontextlost event [3]. A good application catches it and restores the view.
  • Draw calls: many small draw calls slow things down; fewer, larger ones are generally faster [2].
  • No further core development: new graphics features arrive mainly in WebGPU.

Relevance to configurators

Our example configurators render with the three.js WebGL renderer. The spiral stair configurator (example configurator, fictional product) catches a context loss, shows a notice and restores the view without losing the visitor's selection.

Whether a new project should use WebGL or WebGPU is covered in the WebGPU entry.

The 3D product viewer page explains how a model gets onto your site.

Related terms

  • WebGPU

    WebGPU is a browser interface that lets web pages use the graphics card for rendering and general computation. It is regarded as the successor to WebGL and gives access to more modern GPU features.

  • three.js

    three.js is an open-source JavaScript library for 3D graphics in the browser. It handles the scene, camera, lighting, materials and model loading, and renders through WebGL or WebGPU.

  • Shader

    A shader is a small program that runs on the graphics card and calculates where geometry lands on screen and what colour each pixel receives. On the web, shaders are written in GLSL (WebGL) or WGSL (WebGPU).

  • Draw calls

    A draw call is a single drawing command sent to the graphics card, such as "draw this mesh with this material". Each call carries overhead, so a few large calls are generally faster than many small ones.

  • WebXR

    WebXR (the WebXR Device API) is a group of web standards that let a website render 3D scenes to VR headsets or overlay digital content on the real world (AR) – directly in the browser, without an app.

Examples to try

Example configurator · fictional product

Spiral stair configurator

Plan a spiral stair: enter floor height and opening, treads and rotation are calculated, choose diameter, direction, railing and materials – with an example check and a PDF enquiry.

Stairs & access · Dimensions and sizes · Materials and finishes · Options, modules and accessories

Sources

  1. MDN Web Docs: WebGL API
  2. MDN Web Docs: WebGL best practices
  3. MDN Web Docs: HTMLCanvasElement webglcontextlost event

← All terms in the glossary