Atlaslog
Atlaslog / three.js / API reference / WebGLRenderer
three.js · API reference

WebGLRenderer

Quick answer

WebGLRenderer draws a Scene through a Camera into a canvas and manages the GPU context, color output, shadows, and render statistics. Configure antialias, pixel ratio, outputColorSpace, and toneMapping, then call render() each frame or register a loop with setAnimationLoop(). Call setSize() and setPixelRatio() on resize, and dispose() when tearing down the canvas.

Last verified 2026-11-03 · three.js 0.160.0 · Cite this page
new THREE.WebGLRenderer ( parameters ) → WebGLRenderer
Key points
Example
const stage = document.getElementById('stage');

const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(stage.clientWidth, stage.clientHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.1;

renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;

stage.appendChild(renderer.domElement);
function destroy() {
  renderer.setAnimationLoop(null);
  renderer.dispose();
  renderer.domElement.remove();
}
Notes
Runnable examplesChinese originalAll API references
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). WebGLRenderer. https://www.jingweizhi.com/en/three/api/webgl-renderer.html (accessed 2026-11-03).