vlad
June 15, 2022, 8:31am
1
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();
}
} );
vlad
June 15, 2022, 12:43pm
3
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:
mrdoob:dev
← Mugen87:dev66
opened 07:50AM - 16 Jun 22 UTC
Related issue: https://discourse.threejs.org/t/arcballcontrols-gizmos-leaking-ge… ometries/39281
**Description**
A user in the forum noticed that `makeGizmos()` does not properly remove objects from the scene.
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 .
vlad
June 16, 2022, 9:19am
5
Thanks Mugen87, my GitHub user name is Vlad-Apostolov.
Regards, Vlad