Show distance between Objects when attached to wall

Greetings, i am currently working on testing something which requires calculating the distance between each box when attached to the wall, as seen in the image below when I move the boxes I want to show the distance between all blocks attached to the wall.

currently, it appears like:

I want to show measurements like:

can somebody help to point me to a resource that explains fetching distance b/w objects in three.js?

thanks

Have you seen this? https://hofk.de/main/discourse.threejs/2019/MesureDistance/MesureDistance.html

https://hofk.de/main/discourse.threejs/2019/ClickLength/ClickLength.html (look at console)

See Collection of examples from discourse.threejs.org 2019

thanks @hofk i reviewed the provided examples, in my case user can attach an undefined number of boxes to the wall, i currently have it like:
for(product=0;product<productsWallConnect[wallName].length;product++) {
// find the product point for forward line
// change the line’s position to next nearer box

// find the product point for the previous line
// change the line’s position to the previous nearer box

}

i am currently clueless, how it can detect the nearest box and attach the line to its position.x

It seems your project takes place on one plane?

Maybe you can take something from this example?

its the top view of a 3d scene where users can add boxes via click and move them i have it a way like:

for(wallName in productsWallConnect) {

it stores all boxes in an array-like:

if I can find a way to auto draw a line from one array child to another and detect/measure the length of the line that will solve the problem