Setup Post Processing
The <model-viewer-effects>
library addon for <model-viewer>
provides
you with a easy-to-use postprocessing workflow for spicing up your models.
The list of currently
support effects is: SMAA, FXAA, Pixelate, Outline, Glitch, SSAO, Bloom (Global/Selective), and Color Grade.
In order to avoid package collisions, you will be required to add an
import-map
for the Three.js package, and use the module version of <model-viewer>
.
Safari does not support import maps
, the following script will make your code work universally:
Bring Three.js
from any cdn - cdnjs, unpkg, or jsdelivr:
Now import the <model-viewer>
module version which doesn't package three, and the <model-viewer-effects>
addon:
Setting up post-processing effects is as simple as adding an <effect-composer>
component inside your <model-viewer>
element.
From here, simply add any of the supported effects inside the <effect-composer>
.
See the
API Reference for a list of all supported effects.