Computer >> Computer tutorials >  >> Programming >> HTML

Changing three.js background to transparent or another color in HTML


If you want a transparent background in three.js, you need a pass in the alpha parameter to the WebGLRenderer constructors in the below-given code −

var renderer = new THREE.WebGLRenderer( {alpha: true } );
// You can leave the clear color at the defaultvalue.
renderer.setClearColor( 0x000000, 0 ); //default

However, to set the background color,

renderer.setClearColor(0xb0f442 );