Skip to content

Commit

Permalink
Merge pull request #61 from StrandedKitty/fix/texture-disposal
Browse files Browse the repository at this point in the history
Dispose tile textures
  • Loading branch information
tentone committed Jul 10, 2023
2 parents 5a0f91f + 5e73677 commit 5b4c9d3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions source/nodes/MapHeightNodeShader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,16 @@ export class MapHeightNodeShader extends MapHeightNode
this.geometry = MapHeightNodeShader.geometry;
}
}

public dispose(): void
{
super.dispose();

// @ts-ignore
if (this.material.userData.heightMap.value && this.material.userData.heightMap.value !== MapHeightNodeShader.defaultHeightTexture)
{
// @ts-ignore
this.material.userData.heightMap.value.dispose();
}
}
}
7 changes: 7 additions & 0 deletions source/nodes/MapNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,13 @@ export abstract class MapNode extends Mesh
{
const material = self.material as Material;
material.dispose();

// @ts-ignore
if (material.map && material.map !== MapNode.defaultTexture)
{
// @ts-ignore
material.map.dispose();
}
}
catch (e) {}

Expand Down

0 comments on commit 5b4c9d3

Please sign in to comment.