setFromPoints method

BufferGeometry setFromPoints(
  1. dynamic points
)
inherited

Sets the attributes for this BufferGeometry from an array of points.

Implementation

BufferGeometry setFromPoints(points) {
  List<double> position = [];

  for (int i = 0, l = points.length; i < l; i++) {
    final point = points[i];

    if (point is Vector2) {
      position.addAll([point.x.toDouble(), point.y.toDouble(), 0.0]);
    }
    else {
      position.addAll([point.x.toDouble(), point.y.toDouble(), (point.z ?? 0).toDouble()]);
    }
  }

  setAttributeFromString('position', Float32BufferAttribute.fromList(position, 3, false));

  return this;
}