Skip to content

Commit

Permalink
feat(core): use window pointer events
Browse files Browse the repository at this point in the history
  • Loading branch information
acvigue committed Mar 9, 2024
1 parent c870a3c commit 43cd1a4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/components/TresCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const props = withDefaults(defineProps<TresCanvasProps>(), {
stencil: undefined,
antialias: undefined,
windowSize: undefined,
useWindowPointer: undefined,
disableRender: undefined,
useLegacyLights: undefined,
preserveDrawingBuffer: undefined,
Expand Down
2 changes: 1 addition & 1 deletion src/composables/usePointerEventHandler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const usePointerEventHandler = (
{
scene: TresScene
contextParts: Pick<TresContext, 'renderer' | 'camera' | 'raycaster'>
isWindow: boolean
isWindow?: boolean
},
) => {
const objectsWithEventListeners = reactive({
Expand Down
5 changes: 3 additions & 2 deletions src/composables/useRaycaster/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface PointerClickEventPayload {
export const useRaycaster = (
objects: Ref<THREE.Object3D[]>,
{ renderer, camera, raycaster }: Pick<TresContext, 'renderer' | 'camera' | 'raycaster'>,
isWindow: boolean,
isWindow?: boolean,
) => {
// having a separate computed makes useElementBounding work
const canvas = computed(() => renderer.value.domElement as HTMLCanvasElement)
Expand Down Expand Up @@ -98,7 +98,8 @@ export const useRaycaster = (
window.addEventListener('pointerdown', onPointerDown)
window.addEventListener('pointermove', onPointerMove)
window.addEventListener('pointerleave', onPointerLeave)
} else {
}
else {
canvas.value.addEventListener('pointerup', onPointerUp)
canvas.value.addEventListener('pointerdown', onPointerDown)
canvas.value.addEventListener('pointermove', onPointerMove)
Expand Down

0 comments on commit 43cd1a4

Please sign in to comment.