Hello, I again seek help with my little squared house
https://www.babylonjs-playground.com/#Q9K825#21
Here, I need to find the 3 absolute positions of the vertex I just clicked.
So, I :
- pick
- listen to the pick.faceId
- get all the mesh’ vertices positions (corners)
- access the positions[faceId] index
- access the positions[faceId+1] index
- access the positions[faceId+2] index
- and cry
If I loop throug all my positions array (uncomment line 70), we can see that all my corners are here, but I’m unable to deduce the three that are related to the face I’m picking.
Do someone here have an idea ?
- how to deduce the three Vector3
- how to achieve this in another way
well the position is
- x = positions[faceId]
- y = positions[faceId + 1]
- z = positions[faceId + 2]
Also this is stored (in world space) with pick.pickedPoint
Okay for one position, but I need to find the three positions that creates the vertex.
I managed to find them !
https://www.babylonjs-playground.com/#Q9K825#22
- Create a plane aligned according to the picked point and normal
- Find (in the vertices positions array) those passing through the plane
\o/
2 Likes
Okay, but finally, this is not enough…
I’m trying to rebuild a mesh according to points passing through the plane :
I have the corners of the vertices I want
I’m not able to build a customMesh with these corners
It looks that the indices (vertexData.indices = indices
) I give are not in the right order or something …
How could we rebuild this indicies ?
https://www.babylonjs-playground.com/#Q9K825#23
- click on the closest roof triangle, it’s ok
- click on the wall with windows, and it’s not
I managed to achieve my goal at 75%. Not exactly by the way I intended :
https://www.babylonjs-playground.com/#Q9K825#27
- create a thin box (0.00001 thickness )
- align with picking vertex normal (don’t forget
true, true
! in getNormal(true, true))
- use CSG to grate a thin layer of the pickedMesh
-
It doesn’t work on some meshes (something with subMeshes, I guess)
-
if the mesh is curved, highlight the interior