modeling/src/geometries/poly3/create.js

  1. /**
  2. * Represents a convex 3D polygon. The vertices used to initialize a polygon must
  3. * be coplanar and form a convex shape. The vertices do not have to be `vec3`
  4. * instances but they must behave similarly.
  5. * @typedef {Object} poly3
  6. * @property {Array} vertices - list of ordered vertices (3D)
  7. */
  8. /**
  9. * Creates a new 3D polygon with initial values.
  10. *
  11. * @param {Array} [vertices] - a list of vertices (3D)
  12. * @returns {poly3} a new polygon
  13. * @alias module:modeling/geometries/poly3.create
  14. */
  15. const create = (vertices) => {
  16. if (vertices === undefined || vertices.length < 3) {
  17. vertices = [] // empty contents
  18. }
  19. return { vertices }
  20. }
  21. module.exports = create