Closed hawk86104 closed 5 months ago
feat(events)!: pointerevents manager and state #529 mentioned that the code no longer works, maybe in a certain version Is it working normally? But it cannot run for tresjs v4.0.1
https://github.com/Tresjs/tres/assets/59913119/a82860a4-bc57-43e5-bd16-58611cb9a459
feat(events)!: pointerevents manager and state #529 mentioned that the code no longer works, maybe in a certain version Is it working normally? But it cannot run for
tresjs v4.0.1
bandicam.2024-06-02.14-41-19-353.mp4
My current approach to solving this issue involves maintaining a collection to store objects that are no longer intersected by rays. This collection is then used to trigger the propogateEvent
function.
let prevIntersections: Intersection[] = []
let differenceSetObject: TresObject[] = []
onPointerMove((event) => {
// Current intersections mapped as meshes
const hits = event.intersections.map(({ object }) => object)
differenceSetObject = prevIntersections.filter((hit) => !hits.includes(hit))
differenceSetObject.forEach(() => {
propogateEvent('onPointerLeave', event)
propogateEvent('onPointerOut', event)
})
// .......
// Update previous intersections
prevIntersections = hits as unknown as Intersection[]
})
Hi!
Thanks for the reproduction, it's helped me nail down the issue
Looks like I had an oversight in the event system and relied too much on the intersections array. Since these are pointer-leave/out events we won't have intersections in array to propagate with.
Working on a fix now, will comment when a PR is up
I've got a PR up(#716) with the fix
@hawk86104 @hexianWeb The fix was released this morning is @tresjs/core
version 4.0.2
Please give that a try and report back when you get a chance 🙂
Thank you for the update! I will give @tresjs/core
version 4.0.2
a try and report back before this time tomorrow. (11pm in China,
So the reply might be a bit delayed. : )
LGTM, this was a timely and effective fix.
Describe the bug
As shown in the StackBlitz URL example,
onPointerLeave
was activating in version 3.9 and earlier. However, in version 4.0 and later, it is difficult to activate. How can I useonPointerLeave
?This way of using it is not a good practice.
Reproduction
https://stackblitz.com/edit/tresjs-minimal-reproduction-kentgx?file=src%2Fcomponents%2FTheExperience.vue,src%2FApp.vue
Steps to reproduce
No response
System Info
No response
Used Package Manager
yarn
Code of Conduct