Convert distance from 2 objects in meters

Hi guys ,

I have 2 models , and I want to get the distance between each one and the THREE.js camera.
From what I seen , the THREE.js camera is set by default with 0 , 0 , 0 coordinated and they aren’t changed no matter how much the camera is moving.

I’ve also found this method :

But it gives me NaN when I try to use it . What parameter is it using ? Is there a documentation for this ?

After I get the distance , I wonder how can I convert it into a real distance , like meters ? Is it possible ?

The distanceTo( Vector3 ) of object position expects a Vector3
So if you have obj1, obj2 and cam, you can do

var dist1ToCam = cam.position.distanceTo( obj1.position );
var dist2ToCam = cam.position.distanceTo( obj2.position );
var dist1To2 = obj1.position.distanceTo( obj2.position );

Please see: three js Vector3 docs


Hi @yombo , thank you for reply , from what I remeber I think I’ve tried that already and didn’t work…but I don’t know what error I got , I did something like this :


Anything about the distance converter from THREE.js into meters & vice versa ?(Please tell me there’s a way to do that)

Take a look at this topic: Units in Three.js