@webex/ladon-ts 5.1.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -2
- package/build/module/lib/renderer/webgl-renderer.js +1 -1
- package/build/module/lib/renderer/webgl-renderer.js.map +1 -1
- package/build/module/lib/version.d.ts +1 -1
- package/build/module/lib/version.js +1 -1
- package/build/module/lib/version.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
## [5.
|
|
5
|
+
## [5.2.0](https://github.com/beyonddunbar/ladon-ts/compare/v5.0.1...v5.2.0) (2025-01-17)
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
### Features
|
|
@@ -12,10 +12,24 @@ All notable changes to this project will be documented in this file. See [standa
|
|
|
12
12
|
|
|
13
13
|
### Bug Fixes
|
|
14
14
|
|
|
15
|
-
* lint ([b904fd7](https://github.com/beyonddunbar/ladon-ts/commit/b904fd74dca183d8cfbd1bebb44d433868d8b606))
|
|
16
15
|
* publish missing worker files in build folder ([#18](https://github.com/beyonddunbar/ladon-ts/issues/18)) ([de1b8d9](https://github.com/beyonddunbar/ladon-ts/commit/de1b8d9122ff1b2f9eaf3883a3c52a96e56225a2))
|
|
16
|
+
* webgl syntax error ([#22](https://github.com/beyonddunbar/ladon-ts/issues/22)) ([5a7e513](https://github.com/beyonddunbar/ladon-ts/commit/5a7e513bfd2b39f2b5c1a5b8b9c892f99a017285))
|
|
17
17
|
* yarn build error ([#16](https://github.com/beyonddunbar/ladon-ts/issues/16)) ([38eb5af](https://github.com/beyonddunbar/ladon-ts/commit/38eb5afa8c37947187af3d0b4fe061971b8a2436))
|
|
18
18
|
|
|
19
|
+
## [5.1.0](https://github.com/beyonddunbar/ladon-ts/compare/v5.0.1...v5.1.0) (2025-01-15)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* passthrough with generator to support step away ([#20](https://github.com/beyonddunbar/ladon-ts/issues/20)) ([f7e6b58](https://github.com/beyonddunbar/ladon-ts/commit/f7e6b5814d75f42daee67c6174fc1eb80a684b54))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Bug Fixes
|
|
28
|
+
|
|
29
|
+
* lint ([b904fd7](https://github.com/beyonddunbar/ladon-ts/commit/b904fd74dca183d8cfbd1bebb44d433868d8b606))
|
|
30
|
+
* publish missing worker files in build folder ([#18](https://github.com/beyonddunbar/ladon-ts/issues/18)) ([de1b8d9](https://github.com/beyonddunbar/ladon-ts/commit/de1b8d9122ff1b2f9eaf3883a3c52a96e56225a2))
|
|
31
|
+
* yarn build error ([#16](https://github.com/beyonddunbar/ladon-ts/issues/16)) ([38eb5af](https://github.com/beyonddunbar/ladon-ts/commit/38eb5afa8c37947187af3d0b4fe061971b8a2436))
|
|
32
|
+
|
|
19
33
|
### [5.0.3](https://github.com/beyonddunbar/ladon-ts/compare/v5.0.1...v5.0.3) (2024-12-17)
|
|
20
34
|
|
|
21
35
|
|
|
@@ -44,7 +44,7 @@ uniform vec2 u_resolution;
|
|
|
44
44
|
`, this.shared_shader_functions = `
|
|
45
45
|
float get_mask(vec2 uv) {
|
|
46
46
|
float maskValue = texture(u_mask, uv).r;
|
|
47
|
-
return smoothstep(0.0, 1.0, maskValue)
|
|
47
|
+
return smoothstep(0.0, 1.0, maskValue);
|
|
48
48
|
}
|
|
49
49
|
`;
|
|
50
50
|
const e = this.output_canvas.getContext("webgl2", { antialias: !0 });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-renderer.js","sources":["../../../../src/lib/renderer/webgl-renderer.ts"],"sourcesContent":["// webgl-renderer.ts\n\nimport { PipelineConfig } from '../config-types';\nimport { FrameData, LadonOutput } from '../generator';\nimport { bilinearUpsample } from '../util';\n\ntype TextureInitializer = () => void;\nexport abstract class WebGLRenderer {\n protected intermediate_canvas?: HTMLCanvasElement;\n protected output_canvas_2d?: CanvasRenderingContext2D;\n\n protected gl: WebGL2RenderingContext;\n\n protected image_texture!: WebGLTexture;\n protected mask_texture!: WebGLTexture;\n\n protected verts = new Float32Array([\n -1.0,\n -1.0,\n 0.0, // Vertex 1\n -1.0,\n 1.0,\n 0.0, // Vertex 2\n 1.0,\n 1.0,\n 0.0, // Vertex 3\n 1.0,\n 1.0,\n 0.0, // Vertex 4\n 1.0,\n -1.0,\n 0.0, // Vertex 5\n -1.0,\n -1.0,\n 0.0, // Vertex 6\n ]);\n\n protected vertex_shader_src = `#version 300 es\n\nin vec4 position;\n\nvoid main() {\n gl_Position = position;\n}\n`;\n\n // Shared fragment shader code\n protected fragment_shader_header = `#version 300 es\nprecision highp float;\n\nout vec4 outColor;\n\nuniform sampler2D u_image;\nuniform sampler2D u_mask;\nuniform vec2 u_resolution;\n`;\n\n // Shared shader functions for enhanced edge blending\n protected shared_shader_functions = `\nfloat get_mask(vec2 uv) {\n float maskValue = texture(u_mask, uv).r;\n return smoothstep(0.0, 1.0, maskValue) ( );\n}\n`;\n\n constructor(public output_canvas: HTMLCanvasElement, public readonly config: PipelineConfig) {\n const gl = this.output_canvas.getContext('webgl2', { antialias: true });\n\n if (!gl) {\n const output_2d = this.output_canvas.getContext('2d');\n\n if (!output_2d) {\n throw new Error('[ladon-ts] - output canvas context must be webgl2 or 2d');\n }\n\n this.output_canvas_2d = output_2d;\n this.intermediate_canvas = document.createElement('canvas');\n this.intermediate_canvas.height = this.config.input.height;\n this.intermediate_canvas.width = this.config.input.width;\n\n const gl_intermediate = this.intermediate_canvas.getContext('webgl2', {\n antialias: true,\n });\n\n if (!gl_intermediate) {\n throw new Error('[ladon-ts] - error getting output context webgl');\n }\n\n this.gl = gl_intermediate;\n } else {\n this.gl = gl;\n }\n\n // Initialize textures and buffers\n this.initTexturesAndBuffers();\n }\n\n protected initTexturesAndBuffers() {\n // Initialize image texture\n this.image_texture = this.createTexture(\n this.gl.RGBA,\n this.config.input.width,\n this.config.input.height\n );\n\n // Initialize mask texture\n this.mask_texture = this.createTexture(\n this.gl.R8,\n this.config.mask.upscaleSize.width,\n this.config.mask.upscaleSize.height\n );\n\n // Create and bind vertex array\n const vertex_array = this.gl.createVertexArray();\n if (!vertex_array) {\n throw new Error('[ladon-ts] - error creating vertex array');\n }\n this.gl.bindVertexArray(vertex_array);\n\n // Create and bind buffer\n const buffer = this.gl.createBuffer();\n if (!buffer) {\n throw new Error('[ladon-ts] - error creating buffer');\n }\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, this.verts, this.gl.STATIC_DRAW);\n this.gl.vertexAttribPointer(0, 3, this.gl.FLOAT, false, 0, 0);\n this.gl.enableVertexAttribArray(0);\n\n this.gl.viewport(0, 0, this.config.input.width, this.config.input.height);\n }\n\n protected createTexture(\n internalFormat: number,\n width: number,\n height: number,\n initializeTexture: TextureInitializer = () => {\n // Default initializer creates an empty texture\n this.gl.texImage2D(\n this.gl.TEXTURE_2D,\n 0,\n internalFormat,\n width,\n height,\n 0,\n internalFormat === this.gl.RGBA ? this.gl.RGBA : this.gl.RED,\n this.gl.UNSIGNED_BYTE,\n null\n );\n }\n ): WebGLTexture {\n const texture = this.gl.createTexture();\n if (!texture) {\n throw new Error('[ladon-ts] - error creating texture');\n }\n\n this.gl.bindTexture(this.gl.TEXTURE_2D, texture);\n\n // Set texture parameters\n this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR);\n this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR);\n this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE);\n this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE);\n\n // Initialize the texture using the provided function\n initializeTexture();\n\n this.gl.bindTexture(this.gl.TEXTURE_2D, null);\n return texture;\n }\n\n protected getUVCalculation() {\n if (this.config.render.horizontalMirror) {\n // Flip both x and y coordinates when horizontal mirroring\n return `vec2 st = vec2(1.0 - gl_FragCoord.x / u_resolution.x, 1.0 - gl_FragCoord.y / u_resolution.y);`;\n }\n\n // Default behavior (no mirroring)\n return `vec2 st = vec2(gl_FragCoord.x / u_resolution.x, 1.0 - gl_FragCoord.y / u_resolution.y);`;\n }\n\n protected setSharedUniforms(program: WebGLProgram) {\n const u_resolution = this.gl.getUniformLocation(program, 'u_resolution');\n if (!u_resolution) {\n throw new Error('[ladon-ts] - error finding \"u_resolution\" uniform');\n }\n this.gl.uniform2f(u_resolution, this.config.input.width, this.config.input.height);\n\n const u_image = this.gl.getUniformLocation(program, 'u_image');\n if (!u_image) {\n throw new Error('[ladon-ts] - error finding \"u_image\" uniform');\n }\n this.gl.activeTexture(this.gl.TEXTURE0);\n this.gl.bindTexture(this.gl.TEXTURE_2D, this.image_texture);\n this.gl.uniform1i(u_image, 0);\n\n const u_mask = this.gl.getUniformLocation(program, 'u_mask');\n if (u_mask) {\n this.gl.activeTexture(this.gl.TEXTURE1);\n this.gl.bindTexture(this.gl.TEXTURE_2D, this.mask_texture);\n this.gl.uniform1i(u_mask, 1);\n }\n }\n\n protected uploadVideoStream(input: FrameData) {\n this.gl.activeTexture(this.gl.TEXTURE0);\n this.gl.bindTexture(this.gl.TEXTURE_2D, this.image_texture);\n\n // Upload video frame or image data to the texture\n if (input instanceof HTMLVideoElement) {\n this.gl.texImage2D(\n this.gl.TEXTURE_2D,\n 0,\n this.gl.RGBA,\n this.gl.RGBA,\n this.gl.UNSIGNED_BYTE,\n input\n );\n } else {\n this.gl.texImage2D(\n this.gl.TEXTURE_2D,\n 0,\n this.gl.RGBA,\n this.config.input.width,\n this.config.input.height,\n 0,\n this.gl.RGBA,\n this.gl.UNSIGNED_BYTE,\n input\n );\n }\n }\n\n protected uploadMask(mask?: LadonOutput) {\n // The mask may not be included if it has not been generated (e.g., frame skipped).\n if (mask?.warm) {\n const maskData = bilinearUpsample(\n mask.data,\n this.config.mask.outputSize.width,\n this.config.mask.outputSize.height,\n this.config.mask.upscaleSize.width,\n this.config.mask.upscaleSize.height\n );\n\n this.gl.activeTexture(this.gl.TEXTURE1);\n this.gl.bindTexture(this.gl.TEXTURE_2D, this.mask_texture);\n this.gl.texImage2D(\n this.gl.TEXTURE_2D,\n 0,\n this.gl.R8,\n this.config.mask.upscaleSize.width,\n this.config.mask.upscaleSize.height,\n 0,\n this.gl.RED,\n this.gl.UNSIGNED_BYTE,\n maskData\n );\n }\n }\n\n protected postDraw() {\n if (this.output_canvas_2d && this.intermediate_canvas) {\n this.output_canvas_2d.drawImage(\n this.intermediate_canvas,\n 0,\n 0,\n this.config.input.width,\n this.config.input.height\n );\n }\n }\n}\n"],"names":["WebGLRenderer","output_canvas","config","gl","output_2d","gl_intermediate","vertex_array","buffer","internalFormat","width","height","initializeTexture","texture","program","u_resolution","u_image","u_mask","input","mask","maskData","bilinearUpsample"],"mappings":";AAOO,MAAeA,EAAc;AAAA,EA0DhC,YAAmBC,GAAkDC,GAAwB;AAA1E,SAAA,gBAAAD,GAAkD,KAAA,SAAAC,GAjD3D,KAAA,QAAQ,IAAI,aAAa;AAAA,MAC/B;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,IAAA,CACH,GAED,KAAU,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAU9B,KAAU,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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KAAK,WAAW;AAAA,QAC5B,KAAK,OAAO,KAAK,YAAY;AAAA,QAC7B,KAAK,OAAO,KAAK,YAAY;AAAA,MACjC;AAEA,WAAK,GAAG,cAAc,KAAK,GAAG,QAAQ,GACtC,KAAK,GAAG,YAAY,KAAK,GAAG,YAAY,KAAK,YAAY,GACzD,KAAK,GAAG;AAAA,QACJ,KAAK,GAAG;AAAA,QACR;AAAA,QACA,KAAK,GAAG;AAAA,QACR,KAAK,OAAO,KAAK,YAAY;AAAA,QAC7B,KAAK,OAAO,KAAK,YAAY;AAAA,QAC7B;AAAA,QACA,KAAK,GAAG;AAAA,QACR,KAAK,GAAG;AAAA,QACRC;AAAA,MACJ;AAAA,IAAA;AAAA,EACJ;AAAA,EAGM,WAAW;AACb,IAAA,KAAK,oBAAoB,KAAK,uBAC9B,KAAK,iBAAiB;AAAA,MAClB,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA,KAAK,OAAO,MAAM;AAAA,MAClB,KAAK,OAAO,MAAM;AAAA,IACtB;AAAA,EACJ;AAER;"}
|
|
1
|
+
{"version":3,"file":"webgl-renderer.js","sources":["../../../../src/lib/renderer/webgl-renderer.ts"],"sourcesContent":["// webgl-renderer.ts\n\nimport { PipelineConfig } from '../config-types';\nimport { FrameData, LadonOutput } from '../generator';\nimport { bilinearUpsample } from '../util';\n\ntype TextureInitializer = () => void;\nexport abstract class WebGLRenderer {\n protected intermediate_canvas?: HTMLCanvasElement;\n protected output_canvas_2d?: CanvasRenderingContext2D;\n\n protected gl: WebGL2RenderingContext;\n\n protected image_texture!: WebGLTexture;\n protected mask_texture!: WebGLTexture;\n\n protected verts = new Float32Array([\n -1.0,\n -1.0,\n 0.0, // Vertex 1\n -1.0,\n 1.0,\n 0.0, // Vertex 2\n 1.0,\n 1.0,\n 0.0, // Vertex 3\n 1.0,\n 1.0,\n 0.0, // Vertex 4\n 1.0,\n -1.0,\n 0.0, // Vertex 5\n -1.0,\n -1.0,\n 0.0, // Vertex 6\n ]);\n\n protected vertex_shader_src = `#version 300 es\n\nin vec4 position;\n\nvoid main() {\n gl_Position = position;\n}\n`;\n\n // Shared fragment shader code\n protected fragment_shader_header = `#version 300 es\nprecision highp float;\n\nout vec4 outColor;\n\nuniform sampler2D u_image;\nuniform sampler2D u_mask;\nuniform vec2 u_resolution;\n`;\n\n // Shared shader functions for enhanced edge blending\n protected shared_shader_functions = `\nfloat get_mask(vec2 uv) {\n float maskValue = texture(u_mask, uv).r;\n return smoothstep(0.0, 1.0, maskValue);\n}\n`;\n\n constructor(public output_canvas: HTMLCanvasElement, public readonly config: PipelineConfig) {\n const gl = this.output_canvas.getContext('webgl2', { antialias: true });\n\n if (!gl) {\n const output_2d = this.output_canvas.getContext('2d');\n\n if (!output_2d) {\n throw new Error('[ladon-ts] - output canvas context must be webgl2 or 2d');\n }\n\n this.output_canvas_2d = output_2d;\n this.intermediate_canvas = document.createElement('canvas');\n this.intermediate_canvas.height = this.config.input.height;\n this.intermediate_canvas.width = this.config.input.width;\n\n const gl_intermediate = this.intermediate_canvas.getContext('webgl2', {\n antialias: true,\n });\n\n if (!gl_intermediate) {\n throw new Error('[ladon-ts] - error getting output context webgl');\n }\n\n this.gl = gl_intermediate;\n } else {\n this.gl = gl;\n }\n\n // Initialize textures and buffers\n this.initTexturesAndBuffers();\n }\n\n protected initTexturesAndBuffers() {\n // Initialize image texture\n this.image_texture = this.createTexture(\n this.gl.RGBA,\n this.config.input.width,\n this.config.input.height\n );\n\n // Initialize mask texture\n this.mask_texture = this.createTexture(\n this.gl.R8,\n this.config.mask.upscaleSize.width,\n this.config.mask.upscaleSize.height\n );\n\n // Create and bind vertex array\n const vertex_array = this.gl.createVertexArray();\n if (!vertex_array) {\n throw new Error('[ladon-ts] - error creating vertex array');\n }\n this.gl.bindVertexArray(vertex_array);\n\n // Create and bind buffer\n const buffer = this.gl.createBuffer();\n if (!buffer) {\n throw new Error('[ladon-ts] - error creating buffer');\n }\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, buffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, this.verts, this.gl.STATIC_DRAW);\n this.gl.vertexAttribPointer(0, 3, this.gl.FLOAT, false, 0, 0);\n this.gl.enableVertexAttribArray(0);\n\n this.gl.viewport(0, 0, this.config.input.width, this.config.input.height);\n }\n\n protected createTexture(\n internalFormat: number,\n width: number,\n height: number,\n initializeTexture: TextureInitializer = () => {\n // Default initializer creates an empty texture\n this.gl.texImage2D(\n this.gl.TEXTURE_2D,\n 0,\n internalFormat,\n width,\n height,\n 0,\n internalFormat === this.gl.RGBA ? this.gl.RGBA : this.gl.RED,\n this.gl.UNSIGNED_BYTE,\n null\n );\n }\n ): WebGLTexture {\n const texture = this.gl.createTexture();\n if (!texture) {\n throw new Error('[ladon-ts] - error creating texture');\n }\n\n this.gl.bindTexture(this.gl.TEXTURE_2D, texture);\n\n // Set texture parameters\n this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR);\n this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR);\n this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE);\n this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE);\n\n // Initialize the texture using the provided function\n initializeTexture();\n\n this.gl.bindTexture(this.gl.TEXTURE_2D, null);\n return texture;\n }\n\n protected getUVCalculation() {\n if (this.config.render.horizontalMirror) {\n // Flip both x and y coordinates when horizontal mirroring\n return `vec2 st = vec2(1.0 - gl_FragCoord.x / u_resolution.x, 1.0 - gl_FragCoord.y / u_resolution.y);`;\n }\n\n // Default behavior (no mirroring)\n return `vec2 st = vec2(gl_FragCoord.x / u_resolution.x, 1.0 - gl_FragCoord.y / u_resolution.y);`;\n }\n\n protected setSharedUniforms(program: WebGLProgram) {\n const u_resolution = this.gl.getUniformLocation(program, 'u_resolution');\n if (!u_resolution) {\n throw new Error('[ladon-ts] - error finding \"u_resolution\" uniform');\n }\n this.gl.uniform2f(u_resolution, this.config.input.width, this.config.input.height);\n\n const u_image = this.gl.getUniformLocation(program, 'u_image');\n if (!u_image) {\n throw new Error('[ladon-ts] - error finding \"u_image\" uniform');\n }\n this.gl.activeTexture(this.gl.TEXTURE0);\n this.gl.bindTexture(this.gl.TEXTURE_2D, this.image_texture);\n this.gl.uniform1i(u_image, 0);\n\n const u_mask = this.gl.getUniformLocation(program, 'u_mask');\n if (u_mask) {\n this.gl.activeTexture(this.gl.TEXTURE1);\n this.gl.bindTexture(this.gl.TEXTURE_2D, this.mask_texture);\n this.gl.uniform1i(u_mask, 1);\n }\n }\n\n protected uploadVideoStream(input: FrameData) {\n this.gl.activeTexture(this.gl.TEXTURE0);\n this.gl.bindTexture(this.gl.TEXTURE_2D, this.image_texture);\n\n // Upload video frame or image data to the texture\n if (input instanceof HTMLVideoElement) {\n this.gl.texImage2D(\n this.gl.TEXTURE_2D,\n 0,\n this.gl.RGBA,\n this.gl.RGBA,\n this.gl.UNSIGNED_BYTE,\n input\n );\n } else {\n this.gl.texImage2D(\n this.gl.TEXTURE_2D,\n 0,\n this.gl.RGBA,\n this.config.input.width,\n this.config.input.height,\n 0,\n this.gl.RGBA,\n this.gl.UNSIGNED_BYTE,\n input\n );\n }\n }\n\n protected uploadMask(mask?: LadonOutput) {\n // The mask may not be included if it has not been generated (e.g., frame skipped).\n if (mask?.warm) {\n const maskData = bilinearUpsample(\n mask.data,\n this.config.mask.outputSize.width,\n this.config.mask.outputSize.height,\n this.config.mask.upscaleSize.width,\n this.config.mask.upscaleSize.height\n );\n\n this.gl.activeTexture(this.gl.TEXTURE1);\n this.gl.bindTexture(this.gl.TEXTURE_2D, this.mask_texture);\n this.gl.texImage2D(\n this.gl.TEXTURE_2D,\n 0,\n this.gl.R8,\n this.config.mask.upscaleSize.width,\n this.config.mask.upscaleSize.height,\n 0,\n this.gl.RED,\n this.gl.UNSIGNED_BYTE,\n maskData\n );\n }\n }\n\n protected postDraw() {\n if (this.output_canvas_2d && this.intermediate_canvas) {\n this.output_canvas_2d.drawImage(\n this.intermediate_canvas,\n 0,\n 0,\n this.config.input.width,\n this.config.input.height\n );\n }\n }\n}\n"],"names":["WebGLRenderer","output_canvas","config","gl","output_2d","gl_intermediate","vertex_array","buffer","internalFormat","width","height","initializeTexture","texture","program","u_resolution","u_image","u_mask","input","mask","maskData","bilinearUpsample"],"mappings":";AAOO,MAAeA,EAAc;AAAA,EA0DhC,YAAmBC,GAAkDC,GAAwB;AAA1E,SAAA,gBAAAD,GAAkD,KAAA,SAAAC,GAjD3D,KAAA,QAAQ,IAAI,aAAa;AAAA,MAC/B;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,IAAA,CACH,GAED,KAAU,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAU9B,KAAU,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAWnC,KAAU,0BAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAQ1B,UAAAC,IAAK,KAAK,cAAc,WAAW,UAAU,EAAE,WAAW,IAAM;AAEtE,QAAKA;AAsBD,WAAK,KAAKA;AAAA,SAtBL;AACL,YAAMC,IAAY,KAAK,cAAc,WAAW,IAAI;AAEpD,UAAI,CAACA;AACK,cAAA,IAAI,MAAM,yDAAyD;AAG7E,WAAK,mBAAmBA,GACnB,KAAA,sBAAsB,SAAS,cAAc,QAAQ,GAC1D,KAAK,oBAAoB,SAAS,KAAK,OAAO,MAAM,QACpD,KAAK,oBAAoB,QAAQ,KAAK,OAAO,MAAM;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J;AAAA,IAAA;AAAA,EACJ;AAAA,EAGM,WAAW;AACb,IAAA,KAAK,oBAAoB,KAAK,uBAC9B,KAAK,iBAAiB;AAAA,MAClB,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA,KAAK,OAAO,MAAM;AAAA,MAClB,KAAK,OAAO,MAAM;AAAA,IACtB;AAAA,EACJ;AAER;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "5.
|
|
1
|
+
export declare const LIB_VERSION = "5.2.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../../../src/lib/version.ts"],"sourcesContent":["export const LIB_VERSION = '5.
|
|
1
|
+
{"version":3,"file":"version.js","sources":["../../../src/lib/version.ts"],"sourcesContent":["export const LIB_VERSION = '5.2.0';\n"],"names":["LIB_VERSION"],"mappings":"AAAO,MAAMA,IAAc;"}
|