Recommended Posts

Hello everybody,

I'm currently trying to get a mesh by clicking on the canvas. So far, it works really great but I still have a problem:

On click, the mesh gets highlighted. Fine but when I drag the mouse on the canvas in order to move the cam, when I release the button of the mouse, a click event is triggered and the mesh beneath it get selected.

I tried to add an event listener on 'mouseup' to stop propagation to the click event but it seems BJS already "intercepts" this event so it is never triggered. I created a codepen to illustrate :

https://codepen.io/3dos/pen/mLEEdq

On the left is an empty canvas on which the mouse events are triggered.

On the right is a babylon canvas on which the mouseup event is not triggered.

Is there a simple way to avoid selecting meshes on drag ? (also tried the dragend event with no success either)

Thanks to everybody who already helped me :P

PS: I joined a screenshot of the console illustrating what I'm telling (did the exact same actions on the 2 canvas)

Screen Shot 2018-04-25 at 10.42.06.png

Share this post


Link to post
Share on other sites

Thank you very much JohnK (for the welcome message and the help)

Looks like this is what I was searching for :) 

Just a little note about that for every dev landing on this question : don't forget to use PEP in order to have this working on Safari as it doesn't support pointer events yet

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.