|
|
@@ -60,6 +60,14 @@ export class Scene implements Disposable {
|
|
|
padding = new Padding(0, 0, 0, 0);
|
|
|
|
|
|
pendingDraw = false;
|
|
|
+ // clearColorValue: [number, number, number, number] = [1, 1, 1, 1]; // 默认白色
|
|
|
+ clearColorValue: [number, number, number, number] = [0, 0, 0, 0]; // 默认透明
|
|
|
+
|
|
|
+ /** 游戏完成后调用,将 canvas 底色改为透明,让 body 渐变色透出 */
|
|
|
+ setClearTransparent() {
|
|
|
+ this.clearColorValue = [0, 0, 0, 0];
|
|
|
+ this.invalidate();
|
|
|
+ }
|
|
|
|
|
|
constructor(
|
|
|
readonly gl: WebGL2RenderingContext,
|
|
|
@@ -200,8 +208,7 @@ export class Scene implements Disposable {
|
|
|
const gl = this.gl;
|
|
|
|
|
|
gl.viewport(0, 0, this.width, this.height);
|
|
|
- let a = 0xef / 255;
|
|
|
- gl.clearColor(a, a, a, 1);
|
|
|
+ gl.clearColor(...this.clearColorValue);
|
|
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
|
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
|
gl.enable(gl.BLEND);
|