[SOLVED]Mesure distance between two points on a object by clicking

Hi,
I’m trying to develop an application with Three.js where I can measure the distance between two points on an object by clicking. Like here You can select the distance measurement from selecting the 5th button (ruler) from the top left.
I’ve tried for hours with these answers but got no where because there aren’t any complete answers, only pieces. So could you please help me add this functionality to this pen ?
Thanks so much

1 Like

Hi!
What point did you stuck at?
Use THREE.Raycaster() for clicking.

  1. Click on the model, get the point of intersection, save it in a variable.
  2. Click on the model, get the point of intersection, call .distanceTo() method to get the distance between the curren point and the previously saved one.
5 Likes

Hi,
I’m stuck at the first step. I can’t figure out how to save 2 points as variable by getting the point of intersection.
Thank you

Could you add that functionality in your codepen: when you click on the model, you set a visual marker (a sphere, for example) at the point of intersection?

I was working on local file. So didn’t have codepen for it. I just copied code from it to codepen just to show you what I’m trying to do.
Thank you

Any chance to make that codepen working?
Or do you offer me to do it for you? :slight_smile:

2 Likes

Trying :sweat_smile::sweat_smile::sweat_smile:

It’s working now. :sweat_smile::grin:
I mean the pen. Not the distance measurement :upside_down_face::cry::cry:

Check this codepen with a very rough concept:

7 Likes

You’re such a wonderful person. Can’t thank you enough for times you helped me out. Thank you so much again for the help. I really appreciate it.
Cheers
:+1::ok_hand::pray::raised_hands:

1 Like

You’re welcome :slight_smile: :beers:

2 Likes

can we apply raycasting on instancedBufferGometry object and how to do it

There is no raycasting for instanced buffer geometries, but THREE.InstancedMesh() has implementation of raycast in the latest release (r111). https://threejs.org/examples/?q=instancing#webgl_instancing_raycast

thank you for this second thing is can we apply vertex point snapping on instanced buffer geometry object and how to do it please provide example

sir when is use new THREE.InstancedMesh in place of new THREE.mesh then show error

"Attempted import error: 'InstancedMesh' is not exported from 'three' (imported as 'THREE')"

what can i do

Hi ,
I got your logic
Here we can click any two point on the model.
But I want two point will be opposite to each other ,which is selectable
other than that two point we cannot select any point on the model
Is it possible ?
Can you give me suggestion for it
Thanks

@sonali_funde1
I didn’t get what you want to achieve. Any explanatory pictures?

As per discussion we can click any two points on the model.
if i click on epoint on the model
then 2nd clickable point must be opposite to that first point
in short that two clickable point must be opposite to each other.

@sonali_funde1
I still have no idea what you mean. The second clickable point is the point of intersection of a ray, casted from the first point into direction of negated normal of intersected face for the first point, with the model itself. Is it correct? Would you mind to provide an explanatory picture for better understanding?

yes correct
Actully i wnat to find hole diameter for uplaoded stl file
can you see this link

Hi this works fine. I want that line between two points to be visible.

Here line is hidden inside dolphin. How to make this line visible alaways even if it is inside another object like in this image?

Thanks in advance