Home  >  Article  >  Web Front-end  >  Change background of three.js to transparent or other color in HTML

Change background of three.js to transparent or other color in HTML

PHPz
PHPzforward
2023-08-31 21:25:061395browse

Change background of three.js to transparent or other color in HTML

If you want to use transparent background in Three.js, you need to pass alpha parameter to WebGLRenderer constructor in the code given below -

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 );

The above is the detailed content of Change background of three.js to transparent or other color in HTML. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete