Skip to content

Commit

Permalink
fix: safely remove helpers in vDistanceTo and vLightHelper directives
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed Feb 1, 2025
1 parent 009b4ba commit d24d2e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/directives/vDistanceTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export const vDistanceTo = {
},
unmounted: (el: TresObject) => {
arrowHelper?.dispose()
el.parent.remove(arrowHelper)
if (el.parent) {
el.parent.remove(arrowHelper)
}
},
}
6 changes: 3 additions & 3 deletions src/directives/vLightHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ export const vLightHelper = {
logWarning(`${el.type} is not a light`)
return
}
currentInstance = el.parent.children.find((child: TresObject) => child instanceof CurrentHelper)

if (currentInstance && currentInstance.dispose) {
currentInstance.dispose()
}
el.parent.remove(currentInstance)
if (el.parent) {
el.parent.remove(currentInstance)
}
},
}

0 comments on commit d24d2e9

Please sign in to comment.