THREE Object Janitor - track objects & dispose of them

THREE Object Janitor

A janitor is a utility class that can be used to clean up resources, especially GPU allocated ones, that are no longer needed by your program.

I found this particularly useful when I have multiple complex scenes and the user is able to go back and forth and music has to stop and things need to unload etc. This simply helps me track all that.

const myObject = new THREE.Mesh(...);
// track an Object3D

// later on, dispose everything you have tracked
// Object3D disposal includes geometries, textures, materials

Works with other object types as well not just Object3D derived.

1 Like

Didn’t mean to bump with my edit but anyhow here we are. :slight_smile: Added tests, fixed a bug, and fixed the README. Cheers.

1 Like