From 9c39a83cc4c2e3d83a8c9c6fc9013b2eae9fab67 Mon Sep 17 00:00:00 2001 From: Juan Cazala Date: Mon, 4 Nov 2024 14:17:42 -0300 Subject: [PATCH] fix: apply shader material to all meshes --- src/lib/babylon/render.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lib/babylon/render.ts b/src/lib/babylon/render.ts index 0e31711..9833ea2 100644 --- a/src/lib/babylon/render.ts +++ b/src/lib/babylon/render.ts @@ -89,6 +89,17 @@ export async function render(canvas: HTMLCanvasElement, config: PreviewConfig): center(scene) } + // shader + const shaderMaterial = scene.materials.find((material) => material.name === 'shader') + if (shaderMaterial) { + for (const mesh of scene.meshes) { + mesh.material = shaderMaterial + } + console.log(`Shader material applied to ${scene.meshes.length} meshes`) + } else { + throw new Error('Shader not found') + } + // return preview controller const controller: IPreviewController = { scene: sceneController,