patioTable2.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import {scene, Group, compute} from "setup";
  2. import Board from "Board";
  3. import * as three from "three";
  4. const boards = [];
  5. createLegs();
  6. createTop();
  7. //createBorder();
  8. //createInnerSupport();
  9. function createLegs(){
  10. let legs = [];
  11. for(let i = 0; i < 4; i++){
  12. let leg = new Board(scene, 4, 4, 30, boards);
  13. leg.rotate(90, 0, 0);
  14. legs.push(leg);
  15. }
  16. let posX = 16;
  17. let posZ = 16;
  18. legs[0].translate(posX, 0, posZ);
  19. legs[1].translate(posX, 0, -posZ);
  20. legs[2].translate(-posX, 0, posZ);
  21. legs[3].translate(-posX, 0, -posZ);
  22. return legs;
  23. }
  24. function createTop(){
  25. const board0 = new Board(scene, 2, 6, 36, boards, ["height", 45, true]);
  26. board0.translate(15, 16, 0);
  27. board0.rotate(0, 0, 90);
  28. const board1 = new Board(scene, 2, 6, 36, boards, ["height", 45, true]);
  29. board1.translate(0, 16, 15);
  30. board1.rotate(0, -90, 90);
  31. const board2 = new Board(scene, 2, 6, 36, boards, ["height", 45, true]);
  32. board2.translate(-15, 16, 0);
  33. board2.rotate(0, 0, -90);
  34. const board3 = new Board(scene, 2, 6, 36, boards, ["height", 45, true]);
  35. board3.translate(0, 16, -15);
  36. board3.rotate(0, 90, 90);
  37. const board5 = new Board(scene, 2, 6, 24, boards, ["height", 45, true]);
  38. board5.translate(0, 16, 9);
  39. board5.rotate(0, 90, -90);
  40. const board6 = new Board(scene, 2, 6, 24, boards, ["height", 45, true]);
  41. board6.translate(-9, 16, 0);
  42. board6.rotate(0, 0, -90);
  43. const board7 = new Board(scene, 2, 6, 24, boards, ["height", 45, true]);
  44. board7.translate(0, 16, -9);
  45. board7.rotate(0, 90, 90);
  46. const board8 = new Board(scene, 2, 6, 24, boards, ["height", 45, true]);
  47. board8.translate(9, 16, 0);
  48. board8.rotate(0, 0, 90);
  49. const board9 = new Board(scene, 2, 6, 12, boards, ["height", 45, true]);
  50. board9.translate(0, 16, 3);
  51. board9.rotate(0, 90, -90);
  52. const board10 = new Board(scene, 2, 6, 12, boards, ["height", 45, true]);
  53. board10.translate(-3, 16, 0);
  54. board10.rotate(0, 0, -90);
  55. const board11 = new Board(scene, 2, 6, 12, boards, ["height", 45, true]);
  56. board11.translate(0, 16, -3);
  57. board11.rotate(0, 90, 90);
  58. const board12 = new Board(scene, 2, 6, 12, boards, ["height", 45, true]);
  59. board12.translate(3, 16, 0);
  60. board12.rotate(0, 0, 90);
  61. /*const geometry = new three.CylinderGeometry(1, 1, 64, 32);
  62. const material = new three.MeshBasicMaterial({color: 0xffffff});
  63. const cylinder = new three.Mesh(geometry, material);
  64. cylinder.position.y += 16;
  65. scene.add(cylinder);*/
  66. }
  67. function createBorder(){
  68. const board0 = new Board(scene, 2, 4, 40, boards, ["width", 45, true]);
  69. board0.translate(0, 15, -19);
  70. board0.rotate(0, 90, 180);
  71. const board1 = new Board(scene, 2, 4, 40, boards, ["width", 45, true]);
  72. board1.translate(19, 15, 0);
  73. board1.rotate(0, 180, 0);
  74. const board2 = new Board(scene, 2, 4, 40, boards, ["width", 45, true]);
  75. board2.translate(0, 15, 19);
  76. board2.rotate(0, 90, 0);
  77. const board3 = new Board(scene, 2, 4, 40, boards, ["width", 45, true]);
  78. board3.translate(-19, 15, 0);
  79. }
  80. function createInnerSupport(){
  81. const board0 = new Board(scene, 2, 4, 36, boards);
  82. board0.translate(0, 14, 0);
  83. board0.rotate(0, 0, 90);
  84. const board1 = new Board(scene, 2, 4, 36, boards);
  85. board1.translate(0, 14, 0);
  86. board1.rotate(0, 90, 90);
  87. }
  88. compute(boards);