diff --git a/src/composables/usePointerEventHandler/index.ts b/src/composables/usePointerEventHandler/index.ts index 946202e62..069acb9ca 100644 --- a/src/composables/usePointerEventHandler/index.ts +++ b/src/composables/usePointerEventHandler/index.ts @@ -1,4 +1,4 @@ -import type { Intersection, Event, Object3D } from 'three' +import type { Intersection, Object3D, Object3DEventMap } from 'three' import type { TresScene } from 'src/types' import { computed, reactive, ref } from 'vue' import { uniqueBy } from '../../utils' @@ -6,8 +6,8 @@ import { useRaycaster } from '../useRaycaster' import type { TresContext } from '../useTresContextProvider' -type CallbackFn = (intersection: Intersection>, event: PointerEvent) => void -type CallbackFnPointerLeave = (object: Object3D, event: PointerEvent) => void +type CallbackFn = (intersection: Intersection>, event: PointerEvent) => void +type CallbackFnPointerLeave = (object: Object3D, event: PointerEvent) => void export interface EventProps { onClick?: CallbackFn @@ -24,10 +24,10 @@ export const usePointerEventHandler = ( }, ) => { const objectsWithEventListeners = reactive({ - click: new Map(), - pointerMove: new Map(), - pointerEnter: new Map(), - pointerLeave: new Map(), + click: new Map, CallbackFn>(), + pointerMove: new Map, CallbackFn>(), + pointerEnter: new Map, CallbackFn>(), + pointerLeave: new Map, CallbackFnPointerLeave>(), }) const blockingObjects = ref(new Set()) @@ -79,7 +79,7 @@ export const usePointerEventHandler = ( if (intersects.length) objectsWithEventListeners.click.get(intersects[0].object)?.(intersects[0], event) }) - let previouslyIntersectedObject: Object3D | null + let previouslyIntersectedObject: Object3D | null onPointerMove(({ intersects, event }) => { const firstObject = intersects?.[0]?.object diff --git a/src/composables/useRaycaster/index.ts b/src/composables/useRaycaster/index.ts index 26329cc00..44c155cd5 100644 --- a/src/composables/useRaycaster/index.ts +++ b/src/composables/useRaycaster/index.ts @@ -1,5 +1,5 @@ import { Vector2 } from 'three' -import type { Object3D, type Intersection } from 'three' +import type { Object3D, Intersection } from 'three' import type { Ref } from 'vue' import { computed, onUnmounted } from 'vue' import type { EventHook } from '@vueuse/core' @@ -7,7 +7,7 @@ import { createEventHook, useElementBounding, usePointer } from '@vueuse/core' import { type TresContext } from '../useTresContextProvider' -export type Intersects = Intersection>[] +export type Intersects = Intersection>[] interface PointerMoveEventPayload { intersects?: Intersects event: PointerEvent diff --git a/src/types/index.ts b/src/types/index.ts index 0de3110b1..b039e1827 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -38,7 +38,7 @@ interface TresBaseObject { } // Custom type for geometry and material properties in Object3D -export interface TresObject3D extends THREE.Object3D { +export interface TresObject3D extends THREE.Object3D { geometry?: THREE.BufferGeometry & TresBaseObject material?: THREE.Material & TresBaseObject userData: {