Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4.0.1 The onPointerLeave function is not activating. #713

Closed
5 tasks done
hawk86104 opened this issue Jun 2, 2024 · 8 comments · Fixed by #716
Closed
5 tasks done

v4.0.1 The onPointerLeave function is not activating. #713

hawk86104 opened this issue Jun 2, 2024 · 8 comments · Fixed by #716
Assignees

Comments

@hawk86104
Copy link
Contributor

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 use onPointerLeave?

  <TresMesh
    @pointer-enter="onPointerEnter"
    @pointer-leave="onPointerLeave"
    name="box"
  >
    <TresBoxGeometry />
    <TresMeshBasicMaterial color="#006060" />
  </TresMesh>

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

@hexianWeb
Copy link
Contributor

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

@hexianWeb
Copy link
Contributor

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[]
  })

@hexianWeb
Copy link
Contributor

hexianWeb commented Jun 2, 2024

"It is work."
before

bandicam.2024-06-02.17-19-26-757.mp4

after

bandicam.2024-06-02.16-44-15-809.mp4

@garrlker garrlker self-assigned this Jun 2, 2024
@garrlker
Copy link
Collaborator

garrlker commented Jun 2, 2024

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

@garrlker
Copy link
Collaborator

garrlker commented Jun 2, 2024

I've got a PR up(#716) with the fix

@garrlker
Copy link
Collaborator

garrlker commented Jun 5, 2024

@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 🙂

@hexianWeb
Copy link
Contributor

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. : )

@hexianWeb
Copy link
Contributor

LGTM, this was a timely and effective fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants