@@ -473,19 +473,22 @@ class RenderWebGL extends EventEmitter {
473473 * @param {number } red The red component for the background.
474474 * @param {number } green The green component for the background.
475475 * @param {number } blue The blue component for the background.
476- * @param {number } alpha The Alpha component for the background. (0-1)
476+ * @param {number } alpha The alpha component for the background.
477477 */
478- setBackgroundColor ( red , green , blue , alpha ) {
478+ setBackgroundColor ( red , green , blue , alpha = 1 ) {
479479 this . dirty = true ;
480480
481- this . _backgroundColor4f [ 0 ] = red ;
482- this . _backgroundColor4f [ 1 ] = green ;
483- this . _backgroundColor4f [ 2 ] = blue ;
484- this . _backgroundColor4f [ 3 ] = alpha ?? 1 ;
481+ // WebGL will want the color to be pre-multiplied.
482+
483+ this . _backgroundColor4f [ 0 ] = red * alpha ;
484+ this . _backgroundColor4f [ 1 ] = green * alpha ;
485+ this . _backgroundColor4f [ 2 ] = blue * alpha ;
486+ this . _backgroundColor4f [ 3 ] = alpha ;
487+
488+ this . _backgroundColor3b [ 0 ] = red * alpha * 255 ;
489+ this . _backgroundColor3b [ 1 ] = green * alpha * 255 ;
490+ this . _backgroundColor3b [ 2 ] = blue * alpha * 255 ;
485491
486- this . _backgroundColor3b [ 0 ] = red * 255 ;
487- this . _backgroundColor3b [ 1 ] = green * 255 ;
488- this . _backgroundColor3b [ 2 ] = blue * 255 ;
489492 }
490493
491494 /**
0 commit comments