Skip to content

Commit

Permalink
fix: optional chaining on object pointer events
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed Apr 6, 2023
1 parent 3b960f5 commit 421a7d5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/TresScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ export const TresScene = defineComponent<TresSceneProps>({
if (intersects.length > 0) {
currentInstance = intersects[0]
if (prevInstance === null) {
currentInstance.object.events.onPointerEnter?.(currentInstance)
currentInstance.object?.events?.onPointerEnter?.(currentInstance)
}
} else {
if (prevInstance !== null) {
currentInstance?.object.events.onPointerLeave?.(prevInstance)
currentInstance?.object?.events?.onPointerLeave?.(prevInstance)
currentInstance = null
}
}
Expand All @@ -112,7 +112,7 @@ export const TresScene = defineComponent<TresSceneProps>({

useEventListener(canvas.value, 'click', () => {
if (currentInstance === null) return
currentInstance.object.events.onClick?.(currentInstance)
currentInstance.object?.events?.onClick?.(currentInstance)
})
}

Expand Down

0 comments on commit 421a7d5

Please sign in to comment.