Skip to content

Commit

Permalink
useHelper - dispose helpers (#1149)
Browse files Browse the repository at this point in the history
Dispose helper on destroy
  • Loading branch information
clementroche committed Nov 21, 2022
1 parent b47417b commit b0ce751
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/useHelper.tsx
Expand Up @@ -32,11 +32,17 @@ export function useHelper<T extends Constructor>(
*/
if (!object3D && helper.current) {
scene.remove(helper.current)
if(helper.current?.dispose) {
helper.current.dispose()
}
}

return () => {
if (helper.current) {
scene.remove(helper.current)
if(helper.current?.dispose) {
helper.current.dispose()
}
}
}
}, [scene, helperConstructor, object3D, ...args])
Expand Down

0 comments on commit b0ce751

Please sign in to comment.