Skip to content

Commit

Permalink
fix: apply shader material to all meshes
Browse files Browse the repository at this point in the history
  • Loading branch information
cazala committed Nov 4, 2024
1 parent f09c816 commit 9c39a83
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/lib/babylon/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9c39a83

Please sign in to comment.