computeLineDistances method
LineSegments
computeLineDistances(
)
inherited
Implementation
@override
LineSegments computeLineDistances() {
var geometry = this.geometry;
if (geometry is BufferGeometry) {
// we assume non-indexed geometry
if (geometry.index == null) {
var positionAttribute = geometry.attributes["position"];
var lineDistances = Float32Array(positionAttribute.count);
for (var i = 0, l = positionAttribute.count; i < l; i += 2) {
_lsstart.fromBufferAttribute(positionAttribute, i);
_lsend.fromBufferAttribute(positionAttribute, i + 1);
lineDistances[i] = (i == 0) ? 0 : lineDistances[i - 1];
lineDistances[i + 1] = lineDistances[i] + _lsstart.distanceTo(_lsend);
}
geometry.setAttribute('lineDistance', Float32BufferAttribute(lineDistances, 1, false));
} else {
print('three.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.');
}
}
// else if (geometry.isGeometry) {
// throw ('three.LineSegments.computeLineDistances() no longer supports three.Geometry. Use three.BufferGeometry instead.');
// }
return this;
}