element_builder.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { type_manager } from "./functions.js";
  2. import { element } from "./element.js";
  3. import { order } from "./order.js";
  4. import { file } from "./file.js";
  5. class element_builder {
  6. #name;
  7. #description;
  8. #pictures;
  9. #meshes;
  10. #solids;
  11. #order;
  12. constructor() {
  13. this.#order = [];
  14. this.#solids = [];
  15. this.#meshes = [];
  16. this.#pictures = [];
  17. this.#name = undefined;
  18. this.#description = undefined;
  19. }
  20. set name(target) {
  21. if (!type_manager.is_string(target)) {
  22. throw "Element name must be an string.";
  23. }
  24. this.#name = target;
  25. }
  26. set description(target) {
  27. if (!type_manager.is_string(target)) {
  28. throw "Description of the element must be an string.";
  29. }
  30. this.#description = target;
  31. }
  32. add_solid(target) {
  33. this.#solids.push(new file(target));
  34. }
  35. add_mesh(target) {
  36. this.#meshes.push(new file(target));
  37. }
  38. add_picture(target) {
  39. this.#pictures.push(new file(target));
  40. }
  41. add_order(target) {
  42. this.#order.push(new order(target));
  43. }
  44. get result() {
  45. return new element(
  46. this.#name,
  47. this.#description,
  48. this.#pictures,
  49. this.#meshes,
  50. this.#solids,
  51. this.#order
  52. );
  53. }
  54. }
  55. export { element_builder };