From 5f2144f38ed3165e7108797e95b77489a4d8cd50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Tue, 17 Dec 2024 17:45:13 +0100 Subject: [PATCH] allow to update uniforms --- src/shaderview.ts | 9 ++++++++- web/index.html | 12 ++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/shaderview.ts b/src/shaderview.ts index 7892242..d5523ed 100644 --- a/src/shaderview.ts +++ b/src/shaderview.ts @@ -40,6 +40,13 @@ export class ShaderView { this.finalShader = this.preprocessShaderCode(shaderString); + const all_uniforms = this.listUniforms(); + for (const uniform_name of Object.keys(all_uniforms)) { + if (!this.uniforms[uniform_name]) { + this.uniforms[uniform_name] = all_uniforms[uniform_name]; + } + } + if (!options?.noRender) { this.render = new ShaderViewRender(this.finalShader, this.uniforms); } @@ -96,7 +103,7 @@ export class ShaderView { } setUniform(name: string, value: any): void { - this.uniforms[name]; + this.uniforms[name].value = value; } setParent(parent: HTMLElement): void { diff --git a/web/index.html b/web/index.html index e655f40..ab5ca26 100644 --- a/web/index.html +++ b/web/index.html @@ -3,24 +3,32 @@ +