Skip to content

Commit

Permalink
chore: add update method to helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
JaimeTorrealba committed Sep 18, 2023
1 parent fff82fd commit 5254ac2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/core/directives/vLightHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,25 @@ export const vLightHelper = {
logWarning(`${el.type} is not a light`)
return
}
const currentHelper = helpers[el.type]
currentHelper = helpers[el.type]
el.parent.add(new currentHelper(el))
},
updated: (el: any) => {
currentInstance = el.parent.children.find((child: any) => child instanceof currentHelper)
currentInstance.update()
},
unmounted: (el: any) => {
if (!el.isLight) {
logWarning(`${el.type} is not a light`)
return
}
const currentHelper = helpers[el.type]
const currentInstance = el.parent.children.find((child: any) => child instanceof currentHelper)
currentInstance = el.parent.children.find((child: any) => child instanceof currentHelper)
currentInstance.dispose()
el.parent.remove(currentInstance)
},
}

let currentHelper: any
let currentInstance: any
const helpers = {
DirectionalLight: DirectionalLightHelper,
PointLight: PointLightHelper,
Expand Down

0 comments on commit 5254ac2

Please sign in to comment.