three.js: WebGLBakground.setClearColor: Do not set alpha to 1 by default

I had a problem with making a transparent render target correctly. Called setClearAlpha(0) and setClearColor(0x000000) on the active rendertarget, but alpha was then returned to 1 because of the method below (in WebGLBackground). Could it be a better idea to use the value that setClearAlpha saved instead of 1? It might break code where users used a wrong setClearAlpha and the overwrote it with setClearColor by mistake (but with the wanted visual result), making some render targets transparent again when updating three.js.

setClearColor: function ( color, alpha ) {

	clearColor.set( color );
	clearAlpha = alpha !== undefined ? alpha : 1;
	setClear( clearColor, clearAlpha );

}

https://github.com/mrdoob/three.js/blob/dev/src/renderers/webgl/WebGLBackground.js#L210

Three.js version
  • [x ] Dev
  • r120
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Sure! Can put some thoughts into a PR, at least as a discussion starter.

You mean doing this, right?

setClearColor: function ( color, alpha ) {

	clearColor.set( color );
	if ( alpha !== undefined ) clearAlpha = alpha;
	setClear( clearColor, clearAlpha );

}