Sometimes, we want to add a transparent background with three.js and JavaScript.
In this article, we’ll look at how to add a transparent background with three.js and JavaScript.
How to add a transparent background with three.js and JavaScript?
To add a transparent background with three.js and JavaScript, we create a rendered object and call setClearColor
on it.
For instance, we write
const renderer = new THREE.WebGLRenderer({ alpha: true });
renderer.setClearColor(0x000000, 0);
to create a renderer
with the THREE.WebGLRenderer
constructor.
Then we call setClearColor
to add a transparent background.
Conclusion
To add a transparent background with three.js and JavaScript, we create a rendered object and call setClearColor
on it.