From aa2a2271c2c0367b6a4823118f8374dade13322a Mon Sep 17 00:00:00 2001 From: Reinder Nijhoff Date: Wed, 18 Sep 2024 10:35:17 +0200 Subject: [PATCH] VideoFrame fix for firefox --- src/lib/Renderer.ts | 24 ++++++++++++------------ src/lib/RendererInstance.ts | 11 ++++------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/lib/Renderer.ts b/src/lib/Renderer.ts index 858b8f1..9e612bb 100644 --- a/src/lib/Renderer.ts +++ b/src/lib/Renderer.ts @@ -26,11 +26,11 @@ export type ImageOptions = { } export const defaultImageOptions: ImageOptions = { - clampX: true, - clampY: true, - flipY: false, - useMipmap: true, - useCache: true, + clampX: true, + clampY: true, + flipY: false, + useMipmap: true, + useCache: true, minFilterLinear: true, magFilterLinear: true, }; @@ -81,12 +81,12 @@ export class Renderer { this.setUniformInt(`iChannel${slotIndex}`, slotIndex); // get image width and height let width, height; - if (image instanceof VideoFrame) { + if (typeof VideoFrame !== 'undefined' && image instanceof VideoFrame) { width = image.displayWidth; height = image.displayHeight; } else { - width = image.width; - height = image.height; + width = (image as any).width; + height = (image as any).height; } this.setUniformVec2(`iChannelResolution${slotIndex}`, width, height); @@ -102,8 +102,8 @@ export class Renderer { this.textures[slotIndex] = { texture: undefined, - buffer: image, - cached: false, + buffer: image, + cached: false, }; this.gl.setTextureParameter(image.src.texture, bufferOptions); @@ -125,8 +125,8 @@ export class Renderer { } this.textures[slotIndex] = { texture: texture, - buffer: undefined, - cached: imageOptions.useCache, + buffer: undefined, + cached: imageOptions.useCache, }; context.bindTexture(context.TEXTURE_2D, texture); context.pixelStorei(context.UNPACK_FLIP_Y_WEBGL, options.flipY ? 1 : 0); diff --git a/src/lib/RendererInstance.ts b/src/lib/RendererInstance.ts index f8a304a..5eda194 100644 --- a/src/lib/RendererInstance.ts +++ b/src/lib/RendererInstance.ts @@ -13,8 +13,6 @@ export class RendererInstance extends Renderer { public options: ImageEffectRendererOptions; public time: number = 0; - private index: number; - private tickFuncs: ((dt: number) => void) [] = []; private readyFuncs: (() => void) [] = []; @@ -30,7 +28,6 @@ export class RendererInstance extends Renderer { super(glInstance); this.options = {...options}; - this.index = RendererInstance.index++; this.container = container; this.main = this; @@ -43,10 +40,10 @@ export class RendererInstance extends Renderer { this.canvas = this.gl.canvas; } Object.assign(this.canvas.style, { - inset: '0', - width: '100%', - height: '100%', - margin: '0', + inset: '0', + width: '100%', + height: '100%', + margin: '0', display: 'block', });