Repair memory leak (materials)

This commit is contained in:
Tony Garnock-Jones 2023-02-03 21:42:19 +01:00
parent e23e964486
commit 44d30bece3
1 changed files with 3 additions and 1 deletions

View File

@ -277,10 +277,12 @@ export function build(name: string, scene: Scene, shape: Shapes.Shape, customize
const mat = new StandardMaterial(name + '.texture', scene); const mat = new StandardMaterial(name + '.texture', scene);
mat.diffuseColor = new Color3(shape.value.r, shape.value.g, shape.value.b); mat.diffuseColor = new Color3(shape.value.r, shape.value.g, shape.value.b);
if (shape.value._variant === "transparent") mat.alpha = shape.value.alpha; if (shape.value._variant === "transparent") mat.alpha = shape.value.alpha;
return build(name + '.inner', scene, shape.value.shape, { const t = build(name + '.inner', scene, shape.value.shape, {
... customize, ... customize,
material: async m => (await m.allnodes).forEach(n => n.material = mat), material: async m => (await m.allnodes).forEach(n => n.material = mat),
}); });
t.cleanups.push(() => mat.dispose());
return t;
} }
case "Sound": { case "Sound": {