modeling/src/geometries/geom2/create.js

  1. const mat4 = require('../../maths/mat4')
  2. /**
  3. * Represents a 2D geometry consisting of a list of sides.
  4. * @typedef {Object} geom2
  5. * @property {Array} sides - list of sides, each side containing two points
  6. * @property {mat4} transforms - transforms to apply to the sides, see transform()
  7. */
  8. /**
  9. * Create a new 2D geometry composed of unordered sides (two connected points).
  10. * @param {Array} [sides] - list of sides where each side is an array of two points
  11. * @returns {geom2} a new geometry
  12. * @alias module:modeling/geometries/geom2.create
  13. */
  14. const create = (sides) => {
  15. if (sides === undefined) {
  16. sides = [] // empty contents
  17. }
  18. return {
  19. sides: sides,
  20. transforms: mat4.create()
  21. }
  22. }
  23. module.exports = create