Jump to content

Mesh follow mouse pointer


benjydel
 Share

Recommended Posts

Hello, i would like to create a selector like this : http://threejs.org/examples/#webgl_interactive_voxelpainter
(I know it's three.js but I don't find it with babylon)

My goal is to allow the user to create a cube at the cursor position.

I manage to move the red mesh which represent the cursor but i don't know how to detect the collision and stop the movement of the mesh.

I tried to use moveWithCollisions but it don't work well when i move fast the pointer.


Do you have an issue ?

Thank you in advance

Link to comment
Share on other sites

Please take a look at picking collisions:

 

http://doc.babylonjs.com/tutorials/11._Picking_Collisions

 

 

If the canvas is not of width: 100% and height: 100%, then you might want to make sure you account for the offsetX and offsetY. (Refer to: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent for more information). This might have changed, but just in case.

Also for Mac users you will want to also pay attention to window.devicePixelRatio if you are doing any html element manipulation (this shouldn't be relevant for you, but depends what you want to do)

 

Hope this helps further!

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...