diff --git a/src/shapes.ts b/src/shapes.ts index 2bc42fe..7a4253d 100644 --- a/src/shapes.ts +++ b/src/shapes.ts @@ -277,10 +277,12 @@ export function build(name: string, scene: Scene, shape: Shapes.Shape, customize const mat = new StandardMaterial(name + '.texture', scene); mat.diffuseColor = new Color3(shape.value.r, shape.value.g, shape.value.b); 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, material: async m => (await m.allnodes).forEach(n => n.material = mat), }); + t.cleanups.push(() => mat.dispose()); + return t; } case "Sound": {