I would say that first, you could ray cast and found the closest vertices. once done you could create a box with our drag behavior and then keep in sync the chose vertex position with the box one. Would that not work for you ?
Hi @Sebavan , thank you for your reply. I think your sugestion could be a good approach to do what i want If is possible you can help me implement in pratice this approach ?
First: I started to add a event to pick the ray but i want āisolateā the mesh on pick, basically i want pick only if iĀ“m āinsideā cat mesh(in this case), but until now not working.
Second: how can i get the closest vertices arround the ray?
Start with creating a playground and use the picking or raycast to find what triangles your in. Then compute the distance to all the 3 vertices and keep the closest one. This gives you a position in local space. You can then convert in world space using the world matrix of the object and place a cube at this position. Once done attach a drag behavior to the cube so that you can move it. and on each frame transform back the cube position in object space using the inverse of the world matrix and update the position buffer of the object accordingly.
Hi @sebavan if iĀ“m not wrong, i think this is the approach we spoke i have this sample https://playground.babylonjs.com/#I0TSSC#6 where i add a point(yellow box) in mesh with picking ray (mouse right click) and we get the position, but now my doubt is, how i can attach the vertice or vertices closest to a point(yellow box) to be drag ?
17 ---- Cat has been loaded with non- zero position and has been scaled, so any positioning of a yellow box will need to take this into account. Remember that positions are stored as with zero origin and a unit scaling.
47 ----- stored positions transformed before use to position yellow box.
Note as you drag the yellow box the actual change in a vertex position may need scaling.