setFromObject method

ConvexHull setFromObject(
  1. Object3D object
)

Implementation

ConvexHull setFromObject(Object3D object) {
  List<Vector3> points = [];

  object.updateMatrixWorld(true);

  object.traverse((node) {
    Vector3 point;

    var geometry = node.geometry;

    if (geometry != null) {
      // if (geometry.isGeometry) {
      //   var vertices = geometry.vertices;

      //   for (var i = 0, l = vertices.length; i < l; i++) {
      //     point = vertices[i].clone();
      //     point.applyMatrix4(node.matrixWorld);

      //     points.add(point);
      //   }
      // } else
      if (geometry is BufferGeometry) {
        var attribute = geometry.attributes['position'];

        if (attribute != null) {
          for (var i = 0, l = attribute.count; i < l; i++) {
            point = Vector3.init();

            point.fromBufferAttribute(attribute, i).applyMatrix4(node.matrixWorld);

            points.add(point);
          }
        }
      }
    }
  });

  return setFromPoints(points);
}