[solved] computeLineDistances() throwing an error

I’m trying to draw a dashed line with three vertices, but when I call computeLineDistances() I get an error:

TypeError: d[f-1].distanceTo is not a function. (In 'd[f-1].distanceTo(d[f])', 'd[f-1].distanceTo' is undefined)

Here is a simplified version of my code:

// In the actual program, numerical values are assigned to the individual points in guidelinePoints, instead of x, y and z.
let guidelinePoints = [{x: x, y: y, z: z}, {x: x, y: y, z: z}, {x: x, y: y, z: z}];
let guidelineMaterial = new THREE.LineDashedMaterial({color: '#000000', transparent: true, opacity: 0.3, linewidth: 1, scale: 1, dashSize: 4, gapSize: 4});
let guidelineGeometry = new THREE.Geometry();
guidelineGeometry.vertices.push(guidelinePoints[0]);
guidelineGeometry.vertices.push(guidelinePoints[1]);
guidelineGeometry.vertices.push(guidelinePoints[2]);
let guideline = new THREE.Line(guidelineGeometry, guidelineMaterial);
guideline.computeLineDistances(); // !! Throws an error
guidelines.push(guideline);
group.add(guideline);

Any help solving this issue would be appreciated!

Hi!
Maybe it’s because the points should be of THREE.Vector3() type, as that type has .distanceTo() method.

1 Like

Yep, that’s it :grin:

1 Like

That worked – thanks a lot!

You’re welcome :slight_smile: