Highlight/Snap the vertex of geometry on mouse hovering

Hi,
I want to find highlight points\vertex when mouse cursor hovers geometry.
I find few example link
http://3dhop.net/examples/demos/8.0_measurement_tool.php?title=Measurement%20Tool

But in above link, i only able to find distance between two random click on geometry.
In my case i want to find distance between two vertex when mouse highlight it. So that i can find exact distance between vertex.

Thanks

Hi!
Try to use barycentric coordinates of a triange that you can build from vertices.
It means you highlight a vertex that your point of intersection close to.

I suggest you represent all your vertices as points and perform ray intersection tests like in the following example:

https://threejs.org/examples/webgl_interactive_points.html

A rough example with using of barycentric coordinates of faces of a non-indexed buffer geometry (an STL-model from examples):
https://jsfiddle.net/prisoner849/jx9rfq5n/

1 Like

Hey,

Its Amazing,
Thanks :yum:

I Have one more doubt ,
In that your code the marker ( SphereBufferGeometry )
size depend on size of .stl model.
Can we fix it for all .stl model?

I want to find distance between two highlight vertex.

You can set the radius of the marker to 1 then scale it in proportion, for example, 0.025 of the longest side of bounding box of a model.

Any explanatory picture of the desired result? Or more detailed explanation?

file5.stl (6.7 KB)
Please add this file to your code.
you will get result.

That’s how you can scale the marker in dependence of the max dimension of a model:
https://jsfiddle.net/prisoner849/1wnsf4b7/

Thanks,
I used that ,i got error ,not able to solve that :expressionless:

Uncaught TypeError: tri.getBarycoord is not a function
** at setPos**
Can you suggest me?

Hello,
able to solve that problem.
thanks :yum:

Hey,
Can we add some geometry( box) on that highlighted a vertex after mouse click event on that point (onDocumentMouseDown)?
like this
https://threejs.org/examples/?q=inter#webgl_interactive_voxelpainter

I see no single reason why we can’t :slight_smile:
Create a box mesh, put it at some position that is surely never happen to be in the camera frustum at the beginning (kind of box.position.setScalar(10000)) then on a mouse down event just change the position of the box with copying the position of a marker: box.position.copy(marker.position);

Hey,
Its Working .
Actually i want to calculate distance between two point which is got after on mouse down event on two highlights vertex at once in scene.
In my scene i loaded .stl file.
i used this ,yet not implement.


Can you suggest me?
Thanks

Have a look at this topic: [SOLVED]Mesure distance between two points on a object by clicking

I have seen that topic
It work fine but i want that markers via highlighted vertex and after highlighted on mouse down event i want distance between that .
I tried it, yet stuck.
On highlighted vertex not able to add your markers.:expressionless:

Any live example of what you’ve tried?

Sorry ,On local i tried
So didn’t have codepen/live example for it.

Could you try to create one?

Trying :sweat_smile:

Sorry,
Not able to give Any live example.