Renderers
Earlier, we switched from CanvasRenderer
to WebGLRenderer
in order to support shadows and fog. As a rule of thumb, WebGLRenderer
is faster and has the most features, while CanvasRenderer
has fewer features but broader browser support. One particularly nice feature of WebGLRenderer
is that it supports antialiasing to smooth out jagged edges. We can enable this for our cityscape by passing the option in to the renderer constructor:
renderer = new THREE.WebGLRenderer({antialias: true});
With that, our cityscape is finally complete, as shown in the next screenshot:
Three.js has several other renderers, most notably for CSS and SVG. These can be found in the examples/js/renderers
folder and are available as THREE.CSS3DRenderer
and THREE.SVGRenderer
, respectively, if their eponymous files are included in your HTML document. These renderers have a smaller set of supported features and are not as widely used, so they are not included in the main library, but they can be useful...