modeling/src/operations/hulls/hullPoints3.js

  1. const poly3 = require('../../geometries/poly3')
  2. const quickhull = require('./quickhull')
  3. /**
  4. * Create a convex hull of the given set of points, where each point is an array of [x,y,z].
  5. *
  6. * @param {Array} uniquePoints - list of UNIQUE points from which to create a hull
  7. * @returns {Array} a list of polygons (poly3)
  8. * @alias module:modeling/hulls.hullPoints3
  9. */
  10. const hullPoints3 = (uniquePoints) => {
  11. const faces = quickhull(uniquePoints, { skipTriangulation: true })
  12. const polygons = faces.map((face) => {
  13. const vertices = face.map((index) => uniquePoints[index])
  14. return poly3.create(vertices)
  15. })
  16. return polygons
  17. }
  18. module.exports = hullPoints3