diff --git a/src/gfx.ts b/src/gfx.ts index e1301b43d..4a497026c 100644 --- a/src/gfx.ts +++ b/src/gfx.ts @@ -166,6 +166,11 @@ export class FrameBuffer { return canvas.toDataURL() } + clear() { + const gl = this.ctx.gl + gl.clear(gl.COLOR_BUFFER_BIT) + } + draw(action: () => void) { this.bind() action() @@ -435,6 +440,7 @@ export class Mesh { function genStack(setFunc: (item: T) => void) { const stack: T[] = [] + // TODO: don't do anything if pushed item is the same as the one on top? const push = (item: T) => { stack.push(item) setFunc(item) diff --git a/src/types.ts b/src/types.ts index 8771906bd..5bbf93c52 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3219,6 +3219,7 @@ export declare class FrameBuffer { height: number toImageData(): ImageData toDataURL(): string + clear(): void draw(action: () => void): void bind(): void unbind(): void