瀏覽代碼

Merge pull request #192 from Tresjs/bugfix/189-problems-with-pointerevents

fix: problems with pointerevents
Alvaro Saburido 2 年之前
父節點
當前提交
eeec331259
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      src/components/TresScene.ts

+ 3 - 3
src/components/TresScene.ts

@@ -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
             }
           }
@@ -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)
       })
     }