Manually triggering pointer event intersections? #882
Replies: 2 comments 2 replies
-
yes, you can. const { intersect } = useThree()
...
intersect(event) it's defined as intersect: (event: DomEvent | undefined = {} as DomEvent, prepare = true) => handlePointerMove(event, prepare), it's kind of an escape hatch. you can inject a fake event (or a real one), you can in theory also call the real events directly, they're all part of the internal state const { events } = useThree()
...
events.onClick({ nativeEvent: { offsetX: 100, offsetY: 100 }, type: "click" })
events.onPointerOver(...)
events.onPinterMove(...)
... |
Beta Was this translation helpful? Give feedback.
-
The API in v6 seems to have changed for this use case What alternative method has this been replaced with? Is this the correct method now (un tested):
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello -- I'm using the event system to manage selection of objects in my scene (a user can mouse over an object, and drag it).
The user is also able to move the camera. However, when the camera moves, the pointer doesn't necessarily move, so no
onPointerMove
event occurs. This causes the perceived hovered element to be incorrect until the next pointer event occurs.Moving Mouse, WITHOUT camera movement:

Moving Mouse, WITH camera movement:

Ideally, I'd like to fully utilize the existing system by triggering another
onPointerMove
event. Initially I looked into manually creating a SyntheticEvent to trigger this via react, but it looks like that's not really possible outsound of using a test utility system for mocking an event.Is there a direct way of triggering an event (or RE triggering a previous event)?
Ideal scenario:
Beta Was this translation helpful? Give feedback.
All reactions