Hi, how to find nearest vertex in mesh. Please anyone guide me…

Thankyou

Hi, how to find nearest vertex in mesh. Please anyone guide me…

Thankyou

Hi @Jenifer

Can you please be more explicit? Do you want to do picking from the mouse pointer or get the nearest vertex from a particular Vector3 position? or something else?

Hi, @Cedric want to get the nearest vertex from a particular Vector3 position.

i have one curve, the curve have 4 vertex and having a another object. that object have a more vertex, i take one curve vector to compare a nearest vertex from another object…

To get the nearest position from mesh vertices, you first need to get its position data:

```
var geometry = mesh.geometry;
var positions = geometry.getVertexBuffer(BABYLON.VertexBuffer.PositionKind);
var positionData = positions.getData();
```

positionData is an array containing x1,y1,z1, x2,y2,z2, …xn,yn,zn;

Then, iteration on each position and get the distance for each. Keep the small distance.

You can use Vector3 Distance method:

1 Like