ArcballControls gizmos leaking geometries

makeGizmos(), does not dispose the geometries by only doing:
_this._gizmos.clear();

It needs before _this._gizmos.clear():
_this._gizmos.children.forEach((gizmo) => {
if (gizmo.geometry) {
gizmo.geometry.dispose();
gizmo.material.dispose();
}
});

1 Like

Good catch!

BTW: Instead of using forEach(), it would be more consistent regarding the rest of the code base to use Object3D.traverse(). So:

this._gizmos.traverse( function( object ) {

    if ( object.isLine ) {

        object.geometry.dispose();
        object.material.dispose();

    }

} );

Yes, it is better to be consistent with the rest of the code.

I’ve went ahead and filed a PR at GitHub in order to fix this issue:

If you tell me your GitHub account, I’ll add you to the release notes since you’ve basically fixed the issue in the first place :+1:.

Thanks Mugen87, my GitHub user name is Vlad-Apostolov.
Regards, Vlad