modeling/src/geometries/path2/create.js

  1. const mat4 = require('../../maths/mat4')
  2. /**
  3. * Represents a 2D geometry consisting of a list of ordered points.
  4. * @typedef {Object} path2
  5. * @property {Array} points - list of ordered points
  6. * @property {Boolean} isClosed - true if the path is closed where start and end points are the same
  7. * @property {mat4} transforms - transforms to apply to the points, see transform()
  8. */
  9. /**
  10. * Create an empty, open path.
  11. * @returns {path2} a new path
  12. * @alias module:modeling/geometries/path2.create
  13. *
  14. * @example
  15. * let newpath = create()
  16. */
  17. const create = (points) => {
  18. if (points === undefined) {
  19. points = []
  20. }
  21. return {
  22. points: points,
  23. isClosed: false,
  24. transforms: mat4.create()
  25. }
  26. }
  27. module.exports = create