modeling/src/geometries/geom3/create.js

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