Skip to content

Commit

Permalink
Fix patch material (#9)
Browse files Browse the repository at this point in the history
Fixed exception thrown when material to patch used 'this' within onBeforeMaterial.
  • Loading branch information
agargaro authored Sep 24, 2024
1 parent 2eab00f commit c74617a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/objects/InstancedMesh2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class InstancedMesh2<
protected patchMaterial(material: Material): void {
if (material.isInstancedMeshPatched) throw new Error('Cannot reuse already patched material.');

const onBeforeCompile = material.onBeforeCompile;
const onBeforeCompile = material.onBeforeCompile.bind(material);

material.onBeforeCompile = (shader: WebGLProgramParametersWithUniforms, renderer) => {
if (onBeforeCompile) onBeforeCompile(shader, renderer);
Expand Down

0 comments on commit c74617a

Please sign in to comment.