kitchen-simulator 11.0.0-react.18 → 11.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (707) hide show
  1. package/es/AppContext.js +1 -4
  2. package/es/LiteKitchenConfigurator.js +67 -23
  3. package/es/LiteRenderer.js +15 -64
  4. package/es/actions/export.js +25 -12
  5. package/es/actions/items-actions.js +18 -2
  6. package/es/analytics/ga4.js +188 -0
  7. package/es/analytics/posthog.js +60 -0
  8. package/es/assets/Window.hdr +2100 -0
  9. package/es/assets/img/default/maple.jpg +0 -0
  10. package/es/assets/img/default/steel.jpg +0 -0
  11. package/es/assets/img/loading/loading.gif +0 -0
  12. package/es/catalog/cabinet/cabinet-assembly-order.js +36 -0
  13. package/es/catalog/catalog.js +0 -2
  14. package/es/catalog/factories/area-factory-3d.js +1 -5
  15. package/es/catalog/factories/wall-factory.js +1 -1
  16. package/es/catalog/holes/door-double/door_double.png +0 -0
  17. package/es/catalog/holes/door-panic/panicDoor.png +0 -0
  18. package/es/catalog/holes/door-panic-double/panicDoorDouble.png +0 -0
  19. package/es/catalog/holes/gate/gate.jpg +0 -0
  20. package/es/catalog/holes/window-clear/texture.png +0 -0
  21. package/es/catalog/holes/window-cross/texture.png +0 -0
  22. package/es/catalog/holes/window-double-hung/texture.png +0 -0
  23. package/es/catalog/holes/window-vertical/texture.png +0 -0
  24. package/es/catalog/utils/exporter.js +4 -0
  25. package/es/catalog/utils/item-loader.js +12 -25
  26. package/es/class/area.js +0 -1
  27. package/es/class/export.js +1 -3
  28. package/es/class/item.js +211 -89
  29. package/es/class/line.js +1 -3
  30. package/es/class/project.js +15 -19
  31. package/es/components/content.js +20 -6
  32. package/es/components/export.js +3 -5
  33. package/es/components/style/export.js +2 -28
  34. package/es/components/style/form-number-input.js +34 -43
  35. package/es/components/viewer2d/group.js +12 -7
  36. package/es/components/viewer2d/item.js +159 -168
  37. package/es/components/viewer2d/line.js +18 -51
  38. package/es/components/viewer2d/rulerX.js +3 -0
  39. package/es/components/viewer2d/rulerY.js +3 -0
  40. package/es/components/viewer2d/scene.js +67 -47
  41. package/es/components/viewer2d/state.js +1 -1
  42. package/es/components/viewer2d/utils.js +0 -6
  43. package/es/components/viewer2d/viewer2d.js +566 -508
  44. package/es/components/viewer3d/front3D.js +1 -2
  45. package/es/components/viewer3d/pointer-lock-navigation.js +0 -90
  46. package/es/components/viewer3d/ruler-utils/layer3D.js +2 -2
  47. package/es/components/viewer3d/scene-creator.js +113 -120
  48. package/es/components/viewer3d/three-memory-cleaner.js +0 -14
  49. package/es/components/viewer3d/viewer3d-first-person.js +132 -134
  50. package/es/components/viewer3d/viewer3d.js +40 -28
  51. package/es/constants/catalog/skinPanel.js +9 -0
  52. package/es/constants.js +19 -8
  53. package/es/{WorkSpaceOriginal.js → devLiteRenderer.js} +241 -173
  54. package/es/events/external/handleExternalEvent.js +141 -0
  55. package/es/events/external/handleExternalEvent.util.js +1099 -0
  56. package/es/events/external/handlers.addItem.js +47 -0
  57. package/es/events/external/handlers.changeDoorStyle.js +140 -0
  58. package/es/events/external/handlers.elementOps.js +8 -0
  59. package/es/events/external/handlers.finishing.js +26 -0
  60. package/es/events/external/handlers.hole.js +4 -0
  61. package/es/events/external/handlers.loadProject.js +128 -0
  62. package/es/events/external/handlers.molding.js +24 -0
  63. package/es/events/external/handlers.projectLifecycle.js +11 -0
  64. package/es/events/external/handlers.projectSettings.js +32 -0
  65. package/es/events/external/handlers.replaceCabinet.js +41 -0
  66. package/es/events/external/handlers.roomShape.js +8 -0
  67. package/es/events/external/handlers.syncScene.js +21 -0
  68. package/es/events/external/handlers.updateSelectedElements.js +11 -0
  69. package/es/events/external/handlers.viewMode.js +11 -0
  70. package/es/events/external/handlers.viewerNavigation.js +108 -0
  71. package/es/events/external/handlers.wall.js +7 -0
  72. package/es/index.js +36 -76
  73. package/es/mappings/external-events/mapExternalEventPayload.js +28 -0
  74. package/es/mappings/external-events/mappers/addItemMapper.js +97 -0
  75. package/es/mappings/external-events/mappers/ccdfMapper.js +100 -0
  76. package/es/mappings/external-events/mappers/ccdfToCDSMapper.js +49 -0
  77. package/es/mappings/external-events/mappers/changeDoorStyleMapper.js +37 -0
  78. package/es/mappings/external-events/mappers/loadProjectMapper.js +62 -0
  79. package/es/mappings/holesToCatalog.js +139 -0
  80. package/es/models.js +16 -1
  81. package/es/plugins/keyboard.js +1 -1
  82. package/es/reducers/export.js +2 -4
  83. package/es/reducers/items-reducer.js +4 -2
  84. package/es/reducers/project-reducer.js +1 -1
  85. package/es/reducers/reducer.js +2 -3
  86. package/es/reducers/viewer2d-reducer.js +0 -2
  87. package/es/shared/domain/cabinet-warning.js +15 -0
  88. package/es/shared/objects/immutable.js +3 -0
  89. package/es/utils/geometry.js +418 -95
  90. package/es/utils/helper.js +41 -35
  91. package/es/utils/history.js +2 -2
  92. package/es/utils/molding.js +12 -241
  93. package/es/utils/name-generator.js +0 -3
  94. package/es/utils/skinPanelEngine.js +522 -0
  95. package/lib/@history.js +11 -0
  96. package/lib/AppContext.js +11 -0
  97. package/lib/LiteKitchenConfigurator.js +527 -0
  98. package/lib/LiteRenderer.js +323 -0
  99. package/lib/actions/area-actions.js +21 -0
  100. package/lib/actions/export.js +36 -0
  101. package/lib/actions/groups-actions.js +107 -0
  102. package/lib/actions/holes-actions.js +140 -0
  103. package/lib/actions/items-actions.js +383 -0
  104. package/lib/actions/lines-actions.js +98 -0
  105. package/lib/actions/project-actions.js +351 -0
  106. package/lib/actions/scene-actions.js +43 -0
  107. package/lib/actions/vertices-actions.js +35 -0
  108. package/lib/actions/viewer2d-actions.js +73 -0
  109. package/lib/actions/viewer3d-actions.js +32 -0
  110. package/lib/analytics/ga4.js +194 -0
  111. package/lib/analytics/posthog.js +68 -0
  112. package/lib/assets/Window.hdr +2100 -0
  113. package/lib/assets/brown_photostudio_02_1k.hdr +0 -0
  114. package/lib/assets/fonts/Rene Bieder Milliard Black Italic.woff +0 -0
  115. package/lib/assets/fonts/Rene Bieder Milliard Black.woff +0 -0
  116. package/lib/assets/fonts/Rene Bieder Milliard Bold Italic.woff +0 -0
  117. package/lib/assets/fonts/Rene Bieder Milliard Bold.woff +0 -0
  118. package/lib/assets/fonts/Rene Bieder Milliard Book Italic.woff +0 -0
  119. package/lib/assets/fonts/Rene Bieder Milliard Book.woff +0 -0
  120. package/lib/assets/fonts/Rene Bieder Milliard ExtraBold Italic.woff +0 -0
  121. package/lib/assets/fonts/Rene Bieder Milliard ExtraBold.woff +0 -0
  122. package/lib/assets/fonts/Rene Bieder Milliard ExtraLight Italic.woff +0 -0
  123. package/lib/assets/fonts/Rene Bieder Milliard ExtraLight.woff +0 -0
  124. package/lib/assets/fonts/Rene Bieder Milliard Hairline Italic.woff +0 -0
  125. package/lib/assets/fonts/Rene Bieder Milliard Hairline.woff +0 -0
  126. package/lib/assets/fonts/Rene Bieder Milliard Heavy Italic.woff +0 -0
  127. package/lib/assets/fonts/Rene Bieder Milliard Heavy.woff +0 -0
  128. package/lib/assets/fonts/Rene Bieder Milliard Light Italic.woff +0 -0
  129. package/lib/assets/fonts/Rene Bieder Milliard Light.woff +0 -0
  130. package/lib/assets/fonts/Rene Bieder Milliard Medium Italic.woff +0 -0
  131. package/lib/assets/fonts/Rene Bieder Milliard Medium.woff +0 -0
  132. package/lib/assets/fonts/Rene Bieder Milliard SemiBold Italic.woff +0 -0
  133. package/lib/assets/fonts/Rene Bieder Milliard SemiBold.woff +0 -0
  134. package/lib/assets/fonts/Rene Bieder Milliard Thin Italic.woff +0 -0
  135. package/lib/assets/fonts/Rene Bieder Milliard Thin.woff +0 -0
  136. package/lib/assets/fonts/style.css +177 -0
  137. package/lib/assets/gltf/door_closet.gltf +1 -0
  138. package/lib/assets/gltf/door_exterior.gltf +1 -0
  139. package/lib/assets/gltf/door_interior.gltf +1 -0
  140. package/lib/assets/gltf/door_sliding.gltf +1 -0
  141. package/lib/assets/gltf/doorway_framed.bin +0 -0
  142. package/lib/assets/gltf/doorway_framed.fbx +0 -0
  143. package/lib/assets/gltf/doorway_framed.gltf +1 -0
  144. package/lib/assets/gltf/window_clear.bin +0 -0
  145. package/lib/assets/gltf/window_clear.fbx +0 -0
  146. package/lib/assets/gltf/window_clear.gltf +1 -0
  147. package/lib/assets/gltf/window_cross.bin +0 -0
  148. package/lib/assets/gltf/window_cross.fbx +0 -0
  149. package/lib/assets/gltf/window_cross.gltf +1 -0
  150. package/lib/assets/gltf/window_double_hung.bin +0 -0
  151. package/lib/assets/gltf/window_double_hung.fbx +0 -0
  152. package/lib/assets/gltf/window_double_hung.gltf +1 -0
  153. package/lib/assets/gltf/window_vertical.bin +0 -0
  154. package/lib/assets/gltf/window_vertical.fbx +0 -0
  155. package/lib/assets/gltf/window_vertical.gltf +1 -0
  156. package/lib/assets/img/TKC_thumbnail.png +0 -0
  157. package/lib/assets/img/Toggle.png +0 -0
  158. package/lib/assets/img/default/maple.jpg +0 -0
  159. package/lib/assets/img/default/steel.jpg +0 -0
  160. package/lib/assets/img/loading/loading.gif +0 -0
  161. package/lib/assets/img/loading/loading_1.svg +11 -0
  162. package/lib/assets/img/loading_large.gif +0 -0
  163. package/lib/assets/img/png/door/closet.png +0 -0
  164. package/lib/assets/img/png/door/doorwaysframed.png +0 -0
  165. package/lib/assets/img/png/door/doorwaysframeles.png +0 -0
  166. package/lib/assets/img/png/door/doorwaysframeless.png +0 -0
  167. package/lib/assets/img/png/door/exterior.png +0 -0
  168. package/lib/assets/img/png/door/interior.png +0 -0
  169. package/lib/assets/img/png/door/sliding.png +0 -0
  170. package/lib/assets/img/png/helper/outcome.png +0 -0
  171. package/lib/assets/img/project_img.png +0 -0
  172. package/lib/assets/img/rta/rta_logo_box_blue.jpg +0 -0
  173. package/lib/assets/img/rta/rta_logo_box_blue_ico.jpg +0 -0
  174. package/lib/assets/img/rta/rta_logo_box_blue_ico.svg +55 -0
  175. package/lib/assets/img/rta/rta_logo_box_darkGray.jpg +0 -0
  176. package/lib/assets/img/rta/rta_logo_box_lightblue.png +0 -0
  177. package/lib/assets/img/rta/rta_logo_box_lightmaroon.png +0 -0
  178. package/lib/assets/img/rta/rta_logo_box_maroon.png +0 -0
  179. package/lib/assets/img/rta/rta_logo_box_white.png +0 -0
  180. package/lib/assets/img/rta_menu.png +0 -0
  181. package/lib/assets/img/step2.jpg +0 -0
  182. package/lib/assets/img/step3.jpg +0 -0
  183. package/lib/assets/img/step4.jpg +0 -0
  184. package/lib/assets/img/step5.jpg +0 -0
  185. package/lib/assets/img/step6.jpg +0 -0
  186. package/lib/assets/img/step7.jpg +0 -0
  187. package/lib/assets/img/step8.jpg +0 -0
  188. package/lib/assets/img/svg/2d_delete_object.svg +33 -0
  189. package/lib/assets/img/svg/2d_delete_object1.svg +33 -0
  190. package/lib/assets/img/svg/2d_lock_object.svg +33 -0
  191. package/lib/assets/img/svg/3d_item_move.svg +106 -0
  192. package/lib/assets/img/svg/3d_item_rotation.svg +76 -0
  193. package/lib/assets/img/svg/3d_item_warning_edit.svg +77 -0
  194. package/lib/assets/img/svg/3d_item_warning_info.svg +81 -0
  195. package/lib/assets/img/svg/accessories.svg +4 -0
  196. package/lib/assets/img/svg/angle_icon.svg +39 -0
  197. package/lib/assets/img/svg/blank_div.svg +14 -0
  198. package/lib/assets/img/svg/bottombar/2d3d_button.svg +3 -0
  199. package/lib/assets/img/svg/bottombar/2d3d_button_active.svg +3 -0
  200. package/lib/assets/img/svg/bottombar/2d3d_toggle.svg +4 -0
  201. package/lib/assets/img/svg/bottombar/2d3d_toggle_active.svg +4 -0
  202. package/lib/assets/img/svg/bottombar/arrow-down.svg +3 -0
  203. package/lib/assets/img/svg/bottombar/arrow-left.svg +3 -0
  204. package/lib/assets/img/svg/bottombar/arrow-minus.svg +3 -0
  205. package/lib/assets/img/svg/bottombar/arrow-plus.svg +11 -0
  206. package/lib/assets/img/svg/bottombar/arrow-right.svg +3 -0
  207. package/lib/assets/img/svg/bottombar/arrow-up.svg +3 -0
  208. package/lib/assets/img/svg/bottombar/collapse.svg +3 -0
  209. package/lib/assets/img/svg/bottombar/elevation-back.svg +6 -0
  210. package/lib/assets/img/svg/bottombar/elevation-front.svg +6 -0
  211. package/lib/assets/img/svg/bottombar/elevation-left.svg +6 -0
  212. package/lib/assets/img/svg/bottombar/elevation-right.svg +7 -0
  213. package/lib/assets/img/svg/bottombar/elevation.svg +13 -0
  214. package/lib/assets/img/svg/bottombar/expand.svg +3 -0
  215. package/lib/assets/img/svg/bottombar/help.svg +72 -0
  216. package/lib/assets/img/svg/bottombar/incm_toggle.svg +39 -0
  217. package/lib/assets/img/svg/bottombar/pan_1.svg +57 -0
  218. package/lib/assets/img/svg/bottombar/pan_2.svg +27 -0
  219. package/lib/assets/img/svg/bottombar/pan_3.svg +27 -0
  220. package/lib/assets/img/svg/bottombar/pan_4.svg +27 -0
  221. package/lib/assets/img/svg/bottombar/pan_5.svg +27 -0
  222. package/lib/assets/img/svg/bottombar/settings.svg +23 -0
  223. package/lib/assets/img/svg/bottombar/spin-down.svg +76 -0
  224. package/lib/assets/img/svg/bottombar/spin-left.svg +75 -0
  225. package/lib/assets/img/svg/bottombar/spin-right.svg +75 -0
  226. package/lib/assets/img/svg/bottombar/spin-up.svg +76 -0
  227. package/lib/assets/img/svg/bottombar/spin_1.svg +48 -0
  228. package/lib/assets/img/svg/bottombar/spin_2.svg +31 -0
  229. package/lib/assets/img/svg/bottombar/spin_3.svg +31 -0
  230. package/lib/assets/img/svg/bottombar/spin_4.svg +31 -0
  231. package/lib/assets/img/svg/bottombar/spin_5.svg +31 -0
  232. package/lib/assets/img/svg/bottombar/zoomin.svg +29 -0
  233. package/lib/assets/img/svg/bottombar/zoomout.svg +26 -0
  234. package/lib/assets/img/svg/check.svg +10 -0
  235. package/lib/assets/img/svg/close.svg +11 -0
  236. package/lib/assets/img/svg/color/Black.svg +3 -0
  237. package/lib/assets/img/svg/color/Blue.svg +3 -0
  238. package/lib/assets/img/svg/color/Cream.svg +3 -0
  239. package/lib/assets/img/svg/color/Gray.svg +3 -0
  240. package/lib/assets/img/svg/color/Green.svg +3 -0
  241. package/lib/assets/img/svg/color/White.svg +3 -0
  242. package/lib/assets/img/svg/color/White.svg.bak +3 -0
  243. package/lib/assets/img/svg/color/stone2.jpg +0 -0
  244. package/lib/assets/img/svg/color/wood2.jpg +0 -0
  245. package/lib/assets/img/svg/copy.svg +11 -0
  246. package/lib/assets/img/svg/delete.svg +3 -0
  247. package/lib/assets/img/svg/detail.svg +77 -0
  248. package/lib/assets/img/svg/disclaimer/background.svg +758 -0
  249. package/lib/assets/img/svg/disclaimer/logo-dots.svg +11 -0
  250. package/lib/assets/img/svg/door/Closet.svg +11 -0
  251. package/lib/assets/img/svg/door/Exterior.svg +5 -0
  252. package/lib/assets/img/svg/door/Framed_dorway.svg +5 -0
  253. package/lib/assets/img/svg/door/Frameless_dorway.svg +5 -0
  254. package/lib/assets/img/svg/door/Interior.svg +7 -0
  255. package/lib/assets/img/svg/door/Sliding.svg +5 -0
  256. package/lib/assets/img/svg/doors_closet.svg +47 -0
  257. package/lib/assets/img/svg/doors_exterior.svg +25 -0
  258. package/lib/assets/img/svg/doors_interior.svg +29 -0
  259. package/lib/assets/img/svg/doors_patio.svg +26 -0
  260. package/lib/assets/img/svg/duplicate.svg +11 -0
  261. package/lib/assets/img/svg/duplicate_object_left.svg +32 -0
  262. package/lib/assets/img/svg/duplicate_object_right.svg +32 -0
  263. package/lib/assets/img/svg/filtersActive.svg +19 -0
  264. package/lib/assets/img/svg/firstsetting/L.svg +3 -0
  265. package/lib/assets/img/svg/firstsetting/L2.svg +3 -0
  266. package/lib/assets/img/svg/firstsetting/Open.svg +3 -0
  267. package/lib/assets/img/svg/firstsetting/Square.svg +3 -0
  268. package/lib/assets/img/svg/firstsetting/bar-active.svg +9 -0
  269. package/lib/assets/img/svg/firstsetting/bar-normal.svg +3 -0
  270. package/lib/assets/img/svg/firstsetting/bullet-current.svg +3 -0
  271. package/lib/assets/img/svg/firstsetting/bullet-done.svg +3 -0
  272. package/lib/assets/img/svg/firstsetting/bullet-not-done.svg +3 -0
  273. package/lib/assets/img/svg/firstsetting/check-active.svg +3 -0
  274. package/lib/assets/img/svg/firstsetting/check-normal.svg +3 -0
  275. package/lib/assets/img/svg/firstsetting/pencil.svg +11 -0
  276. package/lib/assets/img/svg/green_checkmark.svg +27 -0
  277. package/lib/assets/img/svg/headerbar/assist.svg +3 -0
  278. package/lib/assets/img/svg/headerbar/cart.svg +3 -0
  279. package/lib/assets/img/svg/headerbar/check.svg +10 -0
  280. package/lib/assets/img/svg/headerbar/consult_designer.svg +45 -0
  281. package/lib/assets/img/svg/headerbar/edit_name.svg +26 -0
  282. package/lib/assets/img/svg/headerbar/file-dollar.svg +13 -0
  283. package/lib/assets/img/svg/headerbar/hamburger_menu.svg +32 -0
  284. package/lib/assets/img/svg/headerbar/plus.svg +11 -0
  285. package/lib/assets/img/svg/headerbar/review_quote.svg +44 -0
  286. package/lib/assets/img/svg/headerbar/ruler-measure.svg +11 -0
  287. package/lib/assets/img/svg/headerbar/save.svg +3 -0
  288. package/lib/assets/img/svg/headerbar/setting.svg +75 -0
  289. package/lib/assets/img/svg/help/check.svg +10 -0
  290. package/lib/assets/img/svg/help/search.svg +76 -0
  291. package/lib/assets/img/svg/intro/1-start-with-floorplan-whole.svg +27 -0
  292. package/lib/assets/img/svg/intro/1-start-with-floorplan.svg +26 -0
  293. package/lib/assets/img/svg/intro/2-start-from-scratch-whole.svg +28 -0
  294. package/lib/assets/img/svg/intro/2-start-from-scratch.svg +27 -0
  295. package/lib/assets/img/svg/intro/3-retrieve-project-whole.svg +19 -0
  296. package/lib/assets/img/svg/intro/3-retrieve-project.svg +18 -0
  297. package/lib/assets/img/svg/invert.svg +127 -0
  298. package/lib/assets/img/svg/lefttoolbar/appliance-active.svg +13 -0
  299. package/lib/assets/img/svg/lefttoolbar/appliance.svg +13 -0
  300. package/lib/assets/img/svg/lefttoolbar/cabinet-active.svg +10 -0
  301. package/lib/assets/img/svg/lefttoolbar/cabinet-category.svg +3 -0
  302. package/lib/assets/img/svg/lefttoolbar/cabinet-one.svg +3 -0
  303. package/lib/assets/img/svg/lefttoolbar/cabinet.svg +10 -0
  304. package/lib/assets/img/svg/lefttoolbar/disigner_assistance.svg +89 -0
  305. package/lib/assets/img/svg/lefttoolbar/door-style-active.svg +20 -0
  306. package/lib/assets/img/svg/lefttoolbar/door-style.svg +20 -0
  307. package/lib/assets/img/svg/lefttoolbar/door.svg +12 -0
  308. package/lib/assets/img/svg/lefttoolbar/error_icon.svg +81 -0
  309. package/lib/assets/img/svg/lefttoolbar/finishing-active.svg +13 -0
  310. package/lib/assets/img/svg/lefttoolbar/finishing.svg +13 -0
  311. package/lib/assets/img/svg/lefttoolbar/reviewforquote-active.svg +86 -0
  312. package/lib/assets/img/svg/lefttoolbar/reviewforquote.svg +12 -0
  313. package/lib/assets/img/svg/lefttoolbar/room-shape-L.svg +3 -0
  314. package/lib/assets/img/svg/lefttoolbar/room-shape-active.svg +18 -0
  315. package/lib/assets/img/svg/lefttoolbar/room-shape-custom.svg +12 -0
  316. package/lib/assets/img/svg/lefttoolbar/room-shape-irregular.svg +3 -0
  317. package/lib/assets/img/svg/lefttoolbar/room-shape-open.svg +3 -0
  318. package/lib/assets/img/svg/lefttoolbar/room-shape-square.svg +3 -0
  319. package/lib/assets/img/svg/lefttoolbar/room-shape.svg +18 -0
  320. package/lib/assets/img/svg/lefttoolbar/search.svg +76 -0
  321. package/lib/assets/img/svg/lefttoolbar/view_more.svg +86 -0
  322. package/lib/assets/img/svg/lefttoolbar/warning_icon.svg +81 -0
  323. package/lib/assets/img/svg/lefttoolbar/window.svg +12 -0
  324. package/lib/assets/img/svg/logo.svg +11 -0
  325. package/lib/assets/img/svg/logo_with_text.svg +25 -0
  326. package/lib/assets/img/svg/menubar/login.svg +84 -0
  327. package/lib/assets/img/svg/menubar/my_projects.svg +85 -0
  328. package/lib/assets/img/svg/menubar/new_project.svg +110 -0
  329. package/lib/assets/img/svg/menubar/save_project.svg +84 -0
  330. package/lib/assets/img/svg/options.svg +3 -0
  331. package/lib/assets/img/svg/positioning.svg +3 -0
  332. package/lib/assets/img/svg/rotate.png +0 -0
  333. package/lib/assets/img/svg/rotate.svg +17 -0
  334. package/lib/assets/img/svg/rotate_object_clockwise.svg +26 -0
  335. package/lib/assets/img/svg/rotate_object_counterclockwise.svg +26 -0
  336. package/lib/assets/img/svg/toggleFilters.svg +19 -0
  337. package/lib/assets/img/svg/toolbar/add_appliances_active.svg +64 -0
  338. package/lib/assets/img/svg/toolbar/add_appliances_inactive.svg +52 -0
  339. package/lib/assets/img/svg/toolbar/add_button.svg +36 -0
  340. package/lib/assets/img/svg/toolbar/add_cabinets_active.svg +59 -0
  341. package/lib/assets/img/svg/toolbar/add_cabinets_inactive.svg +49 -0
  342. package/lib/assets/img/svg/toolbar/add_items_doors.svg +25 -0
  343. package/lib/assets/img/svg/toolbar/add_items_doorways.svg +24 -0
  344. package/lib/assets/img/svg/toolbar/add_items_refrigerator.svg +32 -0
  345. package/lib/assets/img/svg/toolbar/add_items_windows.svg +28 -0
  346. package/lib/assets/img/svg/toolbar/apply_button.svg +38 -0
  347. package/lib/assets/img/svg/toolbar/arrow-plus.svg +11 -0
  348. package/lib/assets/img/svg/toolbar/backsplash.svg +8 -0
  349. package/lib/assets/img/svg/toolbar/cancel_button.svg +37 -0
  350. package/lib/assets/img/svg/toolbar/consult_a_designer_button.svg +47 -0
  351. package/lib/assets/img/svg/toolbar/countertop.svg +7 -0
  352. package/lib/assets/img/svg/toolbar/dcm.png +0 -0
  353. package/lib/assets/img/svg/toolbar/dcm_off.svg +12 -0
  354. package/lib/assets/img/svg/toolbar/dcm_on.svg +474 -0
  355. package/lib/assets/img/svg/toolbar/delete_button.svg +37 -0
  356. package/lib/assets/img/svg/toolbar/download.svg +77 -0
  357. package/lib/assets/img/svg/toolbar/draw_custom_floor.svg +31 -0
  358. package/lib/assets/img/svg/toolbar/edit_button.svg +75 -0
  359. package/lib/assets/img/svg/toolbar/email_quote_button.svg +44 -0
  360. package/lib/assets/img/svg/toolbar/fbm.png +0 -0
  361. package/lib/assets/img/svg/toolbar/finishing_touches_active.svg +54 -0
  362. package/lib/assets/img/svg/toolbar/finishing_touches_inactive.svg +42 -0
  363. package/lib/assets/img/svg/toolbar/floorstyle.svg +9 -0
  364. package/lib/assets/img/svg/toolbar/fmb.png +0 -0
  365. package/lib/assets/img/svg/toolbar/fmb_off.svg +12 -0
  366. package/lib/assets/img/svg/toolbar/fmb_on.svg +489 -0
  367. package/lib/assets/img/svg/toolbar/furnishings_icon.svg +6 -0
  368. package/lib/assets/img/svg/toolbar/get_started_button.svg +41 -0
  369. package/lib/assets/img/svg/toolbar/handles.svg +5 -0
  370. package/lib/assets/img/svg/toolbar/lighting.svg +7 -0
  371. package/lib/assets/img/svg/toolbar/lrm.png +0 -0
  372. package/lib/assets/img/svg/toolbar/lrm_off.svg +12 -0
  373. package/lib/assets/img/svg/toolbar/lrm_on.svg +470 -0
  374. package/lib/assets/img/svg/toolbar/make_floorplan_active.svg +66 -0
  375. package/lib/assets/img/svg/toolbar/make_floorplan_inactive.svg +52 -0
  376. package/lib/assets/img/svg/toolbar/predefined_room_l_shaped.svg +20 -0
  377. package/lib/assets/img/svg/toolbar/predefined_room_layout.svg +20 -0
  378. package/lib/assets/img/svg/toolbar/predefined_room_long_narrow.svg +20 -0
  379. package/lib/assets/img/svg/toolbar/predefined_room_open_l_shape.svg +20 -0
  380. package/lib/assets/img/svg/toolbar/predefined_room_open_pentagon.svg +20 -0
  381. package/lib/assets/img/svg/toolbar/predefined_room_open_rectangle.svg +20 -0
  382. package/lib/assets/img/svg/toolbar/predefined_room_open_rectangle_2.svg +20 -0
  383. package/lib/assets/img/svg/toolbar/predefined_room_pentagon.svg +20 -0
  384. package/lib/assets/img/svg/toolbar/predefined_room_rectangle.svg +20 -0
  385. package/lib/assets/img/svg/toolbar/predefined_room_rectangle_with_alcove.svg +20 -0
  386. package/lib/assets/img/svg/toolbar/redo_button.svg +75 -0
  387. package/lib/assets/img/svg/toolbar/redo_button1.svg +75 -0
  388. package/lib/assets/img/svg/toolbar/review_quote_active.svg +14 -0
  389. package/lib/assets/img/svg/toolbar/review_quote_inactive.svg +44 -0
  390. package/lib/assets/img/svg/toolbar/save_project_button.svg +44 -0
  391. package/lib/assets/img/svg/toolbar/select_doorstyle_active.svg +67 -0
  392. package/lib/assets/img/svg/toolbar/select_doorstyle_inactive.svg +57 -0
  393. package/lib/assets/img/svg/toolbar/shopping-cart.svg +13 -0
  394. package/lib/assets/img/svg/toolbar/style_change_button.svg +47 -0
  395. package/lib/assets/img/svg/toolbar/take_picture.svg +75 -0
  396. package/lib/assets/img/svg/toolbar/undo_button.svg +76 -0
  397. package/lib/assets/img/svg/toolbar/undo_button1.svg +76 -0
  398. package/lib/assets/img/svg/toolbar/use_button.svg +37 -0
  399. package/lib/assets/img/svg/toolbar/wall_color_icon.svg +6 -0
  400. package/lib/assets/img/svg/topbar/edit_active.svg +10 -0
  401. package/lib/assets/img/svg/topbar/edit_inactive.svg +10 -0
  402. package/lib/assets/img/svg/topbar/redo_active.svg +42 -0
  403. package/lib/assets/img/svg/topbar/redo_inactive.svg +23 -0
  404. package/lib/assets/img/svg/topbar/select_all_active.svg +50 -0
  405. package/lib/assets/img/svg/topbar/select_all_inactive.svg +32 -0
  406. package/lib/assets/img/svg/topbar/take_picture_active.svg +51 -0
  407. package/lib/assets/img/svg/topbar/take_picture_inactive.svg +26 -0
  408. package/lib/assets/img/svg/topbar/undo_active.svg +42 -0
  409. package/lib/assets/img/svg/topbar/undo_inactive.svg +23 -0
  410. package/lib/assets/img/svg/warning_info_2d.svg +81 -0
  411. package/lib/assets/img/svg/window/Clear.svg +3 -0
  412. package/lib/assets/img/svg/window/Cross.svg +5 -0
  413. package/lib/assets/img/svg/window/Double_hung.svg +4 -0
  414. package/lib/assets/img/svg/window/Vertical.svg +4 -0
  415. package/lib/assets/img/svg/windows_clear.svg +23 -0
  416. package/lib/assets/img/svg/windows_cross.svg +28 -0
  417. package/lib/assets/img/svg/windows_double_hung.svg +24 -0
  418. package/lib/assets/img/svg/windows_vertical.svg +24 -0
  419. package/lib/assets/img/svg/wizardstep/Custom.svg +3 -0
  420. package/lib/assets/img/svg/wizardstep/Dashed_line.svg +3 -0
  421. package/lib/assets/img/svg/wizardstep/L.svg +3 -0
  422. package/lib/assets/img/svg/wizardstep/L2.svg +3 -0
  423. package/lib/assets/img/svg/wizardstep/Open.svg +3 -0
  424. package/lib/assets/img/svg/wizardstep/Square.svg +3 -0
  425. package/lib/assets/img/svg/wizardstep/bar-active.svg +9 -0
  426. package/lib/assets/img/svg/wizardstep/bar-normal.svg +3 -0
  427. package/lib/assets/img/svg/wizardstep/bullet-current.svg +3 -0
  428. package/lib/assets/img/svg/wizardstep/bullet-done.svg +3 -0
  429. package/lib/assets/img/svg/wizardstep/bullet-not-done.svg +3 -0
  430. package/lib/assets/img/svg/wizardstep/check-active.svg +3 -0
  431. package/lib/assets/img/svg/wizardstep/check-normal.svg +3 -0
  432. package/lib/assets/img/svg/wizardstep/detail_view.svg +87 -0
  433. package/lib/assets/img/svg/wizardstep/pencil.svg +11 -0
  434. package/lib/assets/img/svg/wizardstep/tile_view.svg +95 -0
  435. package/lib/assets/img/texture/glass.jpg +0 -0
  436. package/lib/assets/img/texture/steel.jpg +0 -0
  437. package/lib/assets/img/texture/white1px.jpg +0 -0
  438. package/lib/assets/img/texture/wood.jpg +0 -0
  439. package/lib/assets/model/DCM.bin +0 -0
  440. package/lib/assets/model/DCM.fbx +0 -0
  441. package/lib/assets/model/DCM.gltf +1 -0
  442. package/lib/assets/model/FBM.bin +0 -0
  443. package/lib/assets/model/FBM.fbx +0 -0
  444. package/lib/assets/model/FBM.gltf +1 -0
  445. package/lib/assets/model/LRM.bin +0 -0
  446. package/lib/assets/model/LRM.fbx +0 -0
  447. package/lib/assets/model/LRM.gltf +1 -0
  448. package/lib/assets/rtastore_logo.png +0 -0
  449. package/lib/catalog/areas/area/planner-element.js +53 -0
  450. package/lib/catalog/areas/area/textures/ceramic-tile.jpg +0 -0
  451. package/lib/catalog/areas/area/textures/grass.jpg +0 -0
  452. package/lib/catalog/areas/area/textures/parquet.jpg +0 -0
  453. package/lib/catalog/areas/area/textures/strand-porcelain.jpg +0 -0
  454. package/lib/catalog/areas/area/textures/tile1.jpg +0 -0
  455. package/lib/catalog/back.png +0 -0
  456. package/lib/catalog/cabinet/cabinet-assembly-order.js +42 -0
  457. package/lib/catalog/catalog.js +270 -0
  458. package/lib/catalog/doors.png +0 -0
  459. package/lib/catalog/doorways.png +0 -0
  460. package/lib/catalog/envMap/nx.hdr +0 -0
  461. package/lib/catalog/envMap/ny.hdr +0 -0
  462. package/lib/catalog/envMap/nz.hdr +0 -0
  463. package/lib/catalog/envMap/px.hdr +0 -0
  464. package/lib/catalog/envMap/py.hdr +0 -0
  465. package/lib/catalog/envMap/pz.hdr +0 -0
  466. package/lib/catalog/export.js +1 -0
  467. package/lib/catalog/factories/area-factory-3d.js +187 -0
  468. package/lib/catalog/factories/area-factory.js +88 -0
  469. package/lib/catalog/factories/export.js +25 -0
  470. package/lib/catalog/factories/wall-factory-3d.js +212 -0
  471. package/lib/catalog/factories/wall-factory.js +279 -0
  472. package/lib/catalog/holes/door-closet/planner-element.js +232 -0
  473. package/lib/catalog/holes/door-double/door_double.png +0 -0
  474. package/lib/catalog/holes/door-double/planner-element.js +325 -0
  475. package/lib/catalog/holes/door-exterior/planner-element.js +225 -0
  476. package/lib/catalog/holes/door-interior/planner-element.js +237 -0
  477. package/lib/catalog/holes/door-panic/panicDoor.png +0 -0
  478. package/lib/catalog/holes/door-panic/planner-element.js +513 -0
  479. package/lib/catalog/holes/door-panic-double/panicDoorDouble.png +0 -0
  480. package/lib/catalog/holes/door-panic-double/planner-element.js +473 -0
  481. package/lib/catalog/holes/door-sliding/planner-element.js +235 -0
  482. package/lib/catalog/holes/doorway-framed/planner-element.js +155 -0
  483. package/lib/catalog/holes/doorway-frameless/planner-element.js +114 -0
  484. package/lib/catalog/holes/export.js +97 -0
  485. package/lib/catalog/holes/gate/gate.jpg +0 -0
  486. package/lib/catalog/holes/window-clear/planner-element.js +176 -0
  487. package/lib/catalog/holes/window-clear/texture.png +0 -0
  488. package/lib/catalog/holes/window-cross/planner-element.js +175 -0
  489. package/lib/catalog/holes/window-cross/texture.png +0 -0
  490. package/lib/catalog/holes/window-double-hung/planner-element.js +313 -0
  491. package/lib/catalog/holes/window-double-hung/texture.png +0 -0
  492. package/lib/catalog/holes/window-vertical/planner-element.js +286 -0
  493. package/lib/catalog/holes/window-vertical/texture.png +0 -0
  494. package/lib/catalog/lines/wall/planner-element.js +87 -0
  495. package/lib/catalog/lines/wall/textures/bricks-normal.jpg +0 -0
  496. package/lib/catalog/lines/wall/textures/bricks.jpg +0 -0
  497. package/lib/catalog/lines/wall/textures/bricks2.jpg +0 -0
  498. package/lib/catalog/lines/wall/textures/morden-normal.jpg +0 -0
  499. package/lib/catalog/lines/wall/textures/morden.jpg +0 -0
  500. package/lib/catalog/lines/wall/textures/painted.jpg +0 -0
  501. package/lib/catalog/lines/wall/textures/plaster-normal.jpg +0 -0
  502. package/lib/catalog/lines/wall/textures/plaster.jpg +0 -0
  503. package/lib/catalog/lines/wall/wall.png +0 -0
  504. package/lib/catalog/molding/molding-dcm/planner-element.js +33 -0
  505. package/lib/catalog/molding/molding-dcm/texture.png +0 -0
  506. package/lib/catalog/molding/molding-fbm/planner-element.js +33 -0
  507. package/lib/catalog/molding/molding-fbm/texture.png +0 -0
  508. package/lib/catalog/molding/molding-lrm/planner-element.js +33 -0
  509. package/lib/catalog/molding/molding-lrm/texture.png +0 -0
  510. package/lib/catalog/utils/exporter.js +173 -0
  511. package/lib/catalog/utils/geom-utils.js +205 -0
  512. package/lib/catalog/utils/item-loader.js +1603 -0
  513. package/lib/catalog/utils/load-obj.js +99 -0
  514. package/lib/catalog/utils/mtl-loader.js +366 -0
  515. package/lib/catalog/utils/obj-loader.js +486 -0
  516. package/lib/catalog/windows.png +0 -0
  517. package/lib/class/area.js +147 -0
  518. package/lib/class/export.js +88 -0
  519. package/lib/class/group.js +438 -0
  520. package/lib/class/guide.js +64 -0
  521. package/lib/class/hole.js +930 -0
  522. package/lib/class/item.js +2013 -0
  523. package/lib/class/layer.js +670 -0
  524. package/lib/class/line.js +1236 -0
  525. package/lib/class/project.js +949 -0
  526. package/lib/class/vertex.js +205 -0
  527. package/lib/components/content.js +160 -0
  528. package/lib/components/export.js +7 -0
  529. package/lib/components/style/export.js +17 -0
  530. package/lib/components/style/form-number-input.js +192 -0
  531. package/lib/components/style/form-submit-button.js +35 -0
  532. package/lib/components/viewer2d/area.js +89 -0
  533. package/lib/components/viewer2d/export.js +121 -0
  534. package/lib/components/viewer2d/grids/grid-horizontal-streak.js +44 -0
  535. package/lib/components/viewer2d/grids/grid-streak.js +44 -0
  536. package/lib/components/viewer2d/grids/grid-vertical-streak.js +44 -0
  537. package/lib/components/viewer2d/grids/grids.js +40 -0
  538. package/lib/components/viewer2d/group.js +63 -0
  539. package/lib/components/viewer2d/item.js +244 -0
  540. package/lib/components/viewer2d/layer.js +172 -0
  541. package/lib/components/viewer2d/line.js +975 -0
  542. package/lib/components/viewer2d/ruler.js +92 -0
  543. package/lib/components/viewer2d/rulerDist.js +110 -0
  544. package/lib/components/viewer2d/rulerX.js +154 -0
  545. package/lib/components/viewer2d/rulerY.js +156 -0
  546. package/lib/components/viewer2d/scene.js +137 -0
  547. package/lib/components/viewer2d/snap.js +84 -0
  548. package/lib/components/viewer2d/state.js +83 -0
  549. package/lib/components/viewer2d/utils.js +200 -0
  550. package/lib/components/viewer2d/vertex.js +76 -0
  551. package/lib/components/viewer2d/viewer2d.js +1472 -0
  552. package/lib/components/viewer3d/camera-controls-module/camera-controls.module.js +2591 -0
  553. package/lib/components/viewer3d/dcm.js +408 -0
  554. package/lib/components/viewer3d/fbm.js +421 -0
  555. package/lib/components/viewer3d/front3D.js +71 -0
  556. package/lib/components/viewer3d/grid-creator.js +35 -0
  557. package/lib/components/viewer3d/grids/grid-horizontal-streak.js +45 -0
  558. package/lib/components/viewer3d/grids/grid-streak.js +36 -0
  559. package/lib/components/viewer3d/grids/grid-vertical-streak.js +45 -0
  560. package/lib/components/viewer3d/libs/first-person-controls.js +74 -0
  561. package/lib/components/viewer3d/libs/helvetiker_regular.typeface.js +1287 -0
  562. package/lib/components/viewer3d/libs/mtl-loader.js +366 -0
  563. package/lib/components/viewer3d/libs/obj-loader.js +471 -0
  564. package/lib/components/viewer3d/libs/orbit-controls.js +706 -0
  565. package/lib/components/viewer3d/libs/pointer-lock-controls.js +53 -0
  566. package/lib/components/viewer3d/lrm.js +312 -0
  567. package/lib/components/viewer3d/model.js +714 -0
  568. package/lib/components/viewer3d/pointer-lock-navigation.js +32 -0
  569. package/lib/components/viewer3d/ruler-utils/itemRect.js +69 -0
  570. package/lib/components/viewer3d/ruler-utils/layer3D.js +503 -0
  571. package/lib/components/viewer3d/ruler-utils/ruler3D.js +232 -0
  572. package/lib/components/viewer3d/ruler-utils/scene3D.js +67 -0
  573. package/lib/components/viewer3d/ruler-utils/state3D.js +26 -0
  574. package/lib/components/viewer3d/scene-creator.js +3850 -0
  575. package/lib/components/viewer3d/three-memory-cleaner.js +46 -0
  576. package/lib/components/viewer3d/viewer3d-first-person.js +316 -0
  577. package/lib/components/viewer3d/viewer3d.js +2673 -0
  578. package/lib/constants/catalog/skinPanel.js +15 -0
  579. package/lib/constants.js +791 -0
  580. package/lib/devLiteRenderer.js +917 -0
  581. package/lib/events/external/handleExternalEvent.js +148 -0
  582. package/lib/events/external/handleExternalEvent.util.js +1110 -0
  583. package/lib/events/external/handlers.addItem.js +54 -0
  584. package/lib/events/external/handlers.changeDoorStyle.js +147 -0
  585. package/lib/events/external/handlers.elementOps.js +15 -0
  586. package/lib/events/external/handlers.finishing.js +32 -0
  587. package/lib/events/external/handlers.hole.js +10 -0
  588. package/lib/events/external/handlers.loadProject.js +135 -0
  589. package/lib/events/external/handlers.molding.js +31 -0
  590. package/lib/events/external/handlers.projectLifecycle.js +19 -0
  591. package/lib/events/external/handlers.projectSettings.js +38 -0
  592. package/lib/events/external/handlers.replaceCabinet.js +48 -0
  593. package/lib/events/external/handlers.roomShape.js +14 -0
  594. package/lib/events/external/handlers.syncScene.js +27 -0
  595. package/lib/events/external/handlers.updateSelectedElements.js +17 -0
  596. package/lib/events/external/handlers.viewMode.js +19 -0
  597. package/lib/events/external/handlers.viewerNavigation.js +117 -0
  598. package/lib/events/external/handlers.wall.js +13 -0
  599. package/lib/index.js +637 -0
  600. package/lib/mappings/external-events/mapExternalEventPayload.js +33 -0
  601. package/lib/mappings/external-events/mappers/addItemMapper.js +103 -0
  602. package/lib/mappings/external-events/mappers/ccdfMapper.js +107 -0
  603. package/lib/mappings/external-events/mappers/ccdfToCDSMapper.js +55 -0
  604. package/lib/mappings/external-events/mappers/changeDoorStyleMapper.js +44 -0
  605. package/lib/mappings/external-events/mappers/loadProjectMapper.js +70 -0
  606. package/lib/mappings/holesToCatalog.js +148 -0
  607. package/lib/models.js +534 -0
  608. package/lib/plugins/SVGLoader.js +1419 -0
  609. package/lib/plugins/console-debugger.js +42 -0
  610. package/lib/plugins/export.js +25 -0
  611. package/lib/plugins/keyboard.js +117 -0
  612. package/lib/reducers/areas-reducer.js +19 -0
  613. package/lib/reducers/export.js +89 -0
  614. package/lib/reducers/groups-reducer.js +45 -0
  615. package/lib/reducers/holes-reducer.js +69 -0
  616. package/lib/reducers/items-reducer.js +152 -0
  617. package/lib/reducers/lines-reducer.js +52 -0
  618. package/lib/reducers/project-reducer.js +143 -0
  619. package/lib/reducers/reducer.js +25 -0
  620. package/lib/reducers/scene-reducer.js +35 -0
  621. package/lib/reducers/vertices-reducer.js +26 -0
  622. package/lib/reducers/viewer2d-reducer.js +84 -0
  623. package/lib/reducers/viewer3d-reducer.js +65 -0
  624. package/lib/shared/domain/cabinet-warning.js +20 -0
  625. package/lib/shared/objects/immutable.js +9 -0
  626. package/lib/shared-style.js +72 -0
  627. package/lib/translator/en.js +111 -0
  628. package/lib/translator/it.js +86 -0
  629. package/lib/translator/ru.js +86 -0
  630. package/lib/translator/translator.js +87 -0
  631. package/lib/utils/browser.js +40 -0
  632. package/lib/utils/convert-units-lite.js +44 -0
  633. package/lib/utils/email-validator.js +10 -0
  634. package/lib/utils/export.js +56 -0
  635. package/lib/utils/geometry.js +3230 -0
  636. package/lib/utils/get-edges-of-subgraphs.js +33 -0
  637. package/lib/utils/graph-cycles.js +239 -0
  638. package/lib/utils/graph-inner-cycles.js +54 -0
  639. package/lib/utils/graph.js +153 -0
  640. package/lib/utils/helper.js +480 -0
  641. package/lib/utils/history.js +48 -0
  642. package/lib/utils/id-broker.js +22 -0
  643. package/lib/utils/logger.js +14 -0
  644. package/lib/utils/math.js +57 -0
  645. package/lib/utils/molding.js +1146 -0
  646. package/lib/utils/name-generator.js +21 -0
  647. package/lib/utils/objects-utils.js +62 -0
  648. package/lib/utils/phone-validator.js +10 -0
  649. package/lib/utils/process-black-list.js +22 -0
  650. package/lib/utils/react-if.js +25 -0
  651. package/lib/utils/ruler.js +63 -0
  652. package/lib/utils/skinPanelEngine.js +530 -0
  653. package/lib/utils/snap-scene.js +101 -0
  654. package/lib/utils/snap.js +245 -0
  655. package/lib/utils/summarizeCart.js +30 -0
  656. package/lib/utils/threeCSG.es6.js +504 -0
  657. package/lib/version.js +7 -0
  658. package/package.json +29 -24
  659. package/es/WorkSpace.js +0 -30
  660. package/es/WorkSpaceHostMimic.js +0 -132
  661. package/es/assets/gltf/door_closet.bin +0 -0
  662. package/es/assets/gltf/door_closet.fbx +0 -0
  663. package/es/assets/gltf/door_exterior.bin +0 -0
  664. package/es/assets/gltf/door_exterior.fbx +0 -0
  665. package/es/assets/gltf/door_interior.bin +0 -0
  666. package/es/assets/gltf/door_interior.fbx +0 -0
  667. package/es/assets/gltf/door_sliding.bin +0 -0
  668. package/es/assets/gltf/door_sliding.fbx +0 -0
  669. package/es/assets/img/png/helper/video_preview_3d.png +0 -0
  670. package/es/assets/img/png/helper/video_preview_start.png +0 -0
  671. package/es/assets/img/svg/color/Brown.svg +0 -9
  672. package/es/assets/img/svg/color/Dark.svg +0 -9
  673. package/es/assets/img/svg/color/Light.svg +0 -9
  674. package/es/assets/img/svg/color/Medium.svg +0 -9
  675. package/es/assets/img/svg/color/Unfinished.svg +0 -9
  676. package/es/catalog/lines/wall/textures/bricks3.jpg +0 -0
  677. package/es/catalog/properties/export.js +0 -21
  678. package/es/catalog/properties/property-checkbox.js +0 -68
  679. package/es/catalog/properties/property-color.js +0 -39
  680. package/es/catalog/properties/property-enum.js +0 -50
  681. package/es/catalog/properties/property-hidden.js +0 -19
  682. package/es/catalog/properties/property-lenght-measure.js +0 -96
  683. package/es/catalog/properties/property-length-measure.js +0 -80
  684. package/es/catalog/properties/property-length-measure_hole.js +0 -96
  685. package/es/catalog/properties/property-number.js +0 -48
  686. package/es/catalog/properties/property-read-only.js +0 -26
  687. package/es/catalog/properties/property-string.js +0 -48
  688. package/es/catalog/properties/property-toggle.js +0 -39
  689. package/es/catalog/properties/shared-property-style.js +0 -14
  690. package/es/catalog/utils/FuseUtils.js +0 -79
  691. package/es/class/FuseUtils.js +0 -79
  692. package/es/components/style/button.js +0 -106
  693. package/es/components/style/cancel-button.js +0 -21
  694. package/es/components/style/content-container.js +0 -30
  695. package/es/components/style/content-title.js +0 -25
  696. package/es/components/style/delete-button.js +0 -24
  697. package/es/components/style/form-block.js +0 -20
  698. package/es/components/style/form-color-input.js +0 -26
  699. package/es/components/style/form-label.js +0 -22
  700. package/es/components/style/form-number-input_2.js +0 -238
  701. package/es/components/style/form-select.js +0 -19
  702. package/es/components/style/form-slider.js +0 -60
  703. package/es/components/style/form-text-input.js +0 -69
  704. package/es/index.html.ejs +0 -264
  705. package/es/reducers/user-reducer.js +0 -41
  706. package/es/utils/isolate-event-handler.js +0 -1622
  707. /package/{es/catalog/lines/wall/textures/bricks-normal2.jpg → lib/catalog/lines/wall/textures/painted-normal.jpg} +0 -0
@@ -0,0 +1,3850 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.addMolding = addMolding;
9
+ exports.addWarningBox = addWarningBox;
10
+ exports.checkCabinetOverlap = checkCabinetOverlap;
11
+ exports.createBacksplash = createBacksplash;
12
+ exports.createMDFromItem = createMDFromItem;
13
+ exports.createWarningObject = createWarningObject;
14
+ exports.deleteAllMolding = deleteAllMolding;
15
+ exports.deleteCountertop = deleteCountertop;
16
+ exports.deleteMGMesh = deleteMGMesh;
17
+ exports.deleteSpecifiedMeshObjects = deleteSpecifiedMeshObjects;
18
+ exports.fVLine = void 0;
19
+ exports.getDistanceBetweenLineSegment = getDistanceBetweenLineSegment;
20
+ exports.getDistances = getDistances;
21
+ exports.getIntersectPoint = getIntersectPoint;
22
+ exports.getMeshesFromScene = getMeshesFromScene;
23
+ exports.getTotalDistance = getTotalDistance;
24
+ exports.parseData = parseData;
25
+ exports.removeItem = removeItem;
26
+ exports.removeSelItemMesh = removeSelItemMesh;
27
+ exports.sameSign = sameSign;
28
+ exports.threedfabs = threedfabs;
29
+ exports.tryAdjacentMD = tryAdjacentMD;
30
+ exports.updateDoorHandleMesh = updateDoorHandleMesh;
31
+ exports.updateMoldingGroupArray = updateMoldingGroupArray;
32
+ exports.updateScene = updateScene;
33
+ exports.visibleTransformBox = visibleTransformBox;
34
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
35
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
36
+ var _three = _interopRequireWildcard(require("three"));
37
+ var Three = _three;
38
+ var _gridCreator = _interopRequireDefault(require("./grid-creator"));
39
+ var _threeMemoryCleaner = require("./three-memory-cleaner");
40
+ var _constants = require("../../constants");
41
+ var _export = require("../../utils/export");
42
+ var _convertUnitsLite = require("../../utils/convert-units-lite");
43
+ var _geometry2 = require("../../utils/geometry");
44
+ var GeomUtils = _interopRequireWildcard(require("../../catalog/utils/geom-utils"));
45
+ var _itemLoader = require("../../catalog/utils/item-loader");
46
+ var _cabinetWarning = require("../../shared/domain/cabinet-warning");
47
+ var _utils = require("../viewer2d/utils");
48
+ var _helper = require("../../utils/helper");
49
+ var _math = require("../../utils/math");
50
+ var _immutable = require("../../shared/objects/immutable");
51
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
52
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
53
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
54
+ var fVLine = exports.fVLine = [];
55
+ var scene_mode = null;
56
+ function parseData(sceneData, actions, catalog, camera, renderer, mode) {
57
+ var planData = {
58
+ catalog: catalog,
59
+ sceneData: sceneData
60
+ };
61
+ window.planData = planData;
62
+ planData.sceneGraph = {
63
+ unit: sceneData.unit,
64
+ layers: {},
65
+ busyResources: {
66
+ layers: {}
67
+ },
68
+ width: sceneData.width,
69
+ height: sceneData.height,
70
+ LODs: {}
71
+ };
72
+ planData.plan = new Three.Object3D();
73
+ planData.plan.name = 'plan';
74
+ planData.cam = new Three.Object3D();
75
+ planData.cam.name = 'cam';
76
+
77
+ // Add a grid to the plan
78
+ planData.grid = (0, _gridCreator["default"])(sceneData);
79
+ planData.grid.name = 'grid';
80
+ planData.boundingBox = new Three.Box3().setFromObject(planData.grid);
81
+ planData.boundingBox.name = 'boundingBox';
82
+ var promises = [];
83
+ sceneData.layers.forEach(function (layer) {
84
+ if (layer.id === sceneData.selectedLayer || layer.visible) {
85
+ promises = promises.concat(createLayerObjects(layer, planData, sceneData, actions, catalog, mode, camera, renderer));
86
+ }
87
+ });
88
+ var p1 = new Promise(function (resolve) {
89
+ Promise.all(promises).then(function (value) {
90
+ if (planData.plan.parent !== null && planData.plan.children.length !== 0) {
91
+ updateBoundingBox(planData, false, mode);
92
+
93
+ // if mode is elevation, build elevation scene
94
+ if ((0, _helper.isElevationView)(mode)) buildElevationScene(planData, mode);
95
+ }
96
+ resolve('success');
97
+ });
98
+ });
99
+ return {
100
+ promise: p1,
101
+ planData: planData
102
+ };
103
+
104
+ // return planData;
105
+ }
106
+ function visibleTransformBox(flag) {
107
+ // if (transformBox instanceof Three.Mesh)
108
+ // transformBox.visible = flag;
109
+ }
110
+ var buildElevationScene = function buildElevationScene(planData, mode) {
111
+ var scene = planData.plan.parent;
112
+ scene.updateMatrixWorld();
113
+ var ELEV_GRP = 'ELEV_GRP';
114
+ var oldElevationGroup = scene.getObjectByName(ELEV_GRP);
115
+ if (oldElevationGroup) oldElevationGroup.parent.remove(oldElevationGroup);
116
+ var elevationGroup = new Three.Group();
117
+ scene.traverse(function (obj) {
118
+ if (obj.name == 'MainObject') {
119
+ var clone = obj.clone();
120
+ clone.name = '';
121
+ clone.visible = obj.parent.visible;
122
+ clone.applyMatrix4(obj.parent.matrixWorld);
123
+ elevationGroup.add(clone);
124
+ }
125
+ });
126
+ elevationGroup.name = ELEV_GRP;
127
+ elevationGroup.visible = false;
128
+ planData.elevationGroup = elevationGroup;
129
+ scene.traverse(function (obj) {
130
+ if (obj.name == 'MainObject') {
131
+ (0, _helper.replaceMeshesWithLineSegments)(obj);
132
+ }
133
+ });
134
+ scene.add(elevationGroup);
135
+ };
136
+ function createLayerObjects(layer, planData, sceneData, actions, catalog, mode, camera, renderer) {
137
+ var promises = [];
138
+ var moldingGroups = _export.MoldingUtils.getAllMoldingGroups(layer);
139
+ planData.sceneGraph.layers[layer.id] = {
140
+ id: layer.id,
141
+ lines: {},
142
+ holes: {},
143
+ areas: {},
144
+ items: {},
145
+ countertops: [],
146
+ moldingGroups: moldingGroups,
147
+ backsplashes: [],
148
+ visible: layer.visible,
149
+ altitude: layer.altitude
150
+ };
151
+ planData.sceneGraph.busyResources.layers[layer.id] = {
152
+ id: layer.id,
153
+ lines: {},
154
+ holes: {},
155
+ areas: {},
156
+ items: {},
157
+ moldingGroups: {}
158
+ };
159
+ // Import lines
160
+ layer.lines.forEach(function (line) {
161
+ promises.push(addLine(sceneData, planData, layer, line.id, catalog, actions.linesActions, mode));
162
+ line.holes.forEach(function (holeID) {
163
+ promises.push(addHole(sceneData, planData, layer, holeID, catalog, actions.holesActions, mode));
164
+ });
165
+ });
166
+
167
+ // Import areas
168
+ layer.areas.forEach(function (area) {
169
+ promises.push(addArea(sceneData, planData, layer, area.id, catalog, actions.areaActions, mode));
170
+ });
171
+ // Import items
172
+ layer.items.forEach(function (item) {
173
+ promises.push(addItem(sceneData, planData, layer, item.id, catalog, actions.itemsActions, mode, null, null
174
+ // false
175
+ ));
176
+ });
177
+ return promises;
178
+ }
179
+ var canvas = document.createElement('canvas');
180
+ canvas.width = 50;
181
+ canvas.height = 100;
182
+ canvas.style.width = 50 + 'px';
183
+ canvas.style.height = 100 + 'px';
184
+ var ctx = canvas.getContext('2d');
185
+ ctx.fillStyle = '#FFFFFF';
186
+ ctx.strokeStyle = '#ff7400';
187
+ ctx.beginPath();
188
+ ctx.arc(25, 25, 20, 0, 2 * Math.PI);
189
+ ctx.fill();
190
+ ctx.stroke();
191
+ var img1 = new Image();
192
+ img1.crossOrigin = 'anonymous';
193
+ img1.src = '/assets/img/svg/3d_item_warning_info.svg';
194
+ img1.onload = function () {
195
+ ctx.drawImage(img1, 0, 0, 50, 50);
196
+ };
197
+ ctx.lineWidth = 4;
198
+ ctx.beginPath();
199
+ ctx.arc(25, 75, 20, 0, 2 * Math.PI);
200
+ ctx.fill();
201
+ ctx.stroke();
202
+ var img2 = new Image();
203
+ img2.crossOrigin = 'anonymous';
204
+ img2.src = '/assets/img/svg/3d_item_warning_edit.svg';
205
+ img2.onload = function () {
206
+ ctx.drawImage(img2, 8, 58, 34, 34);
207
+ };
208
+ function createWarningObject() {
209
+ var warningTexture = new Three.Texture(canvas);
210
+ warningTexture.needsUpdate = true;
211
+ var warningObj = new Three.Sprite(new Three.SpriteMaterial({
212
+ map: warningTexture,
213
+ sizeAttenuation: true
214
+ }));
215
+ warningObj.material.transparent = true;
216
+ warningObj.material.depthTest = false;
217
+ warningObj.scale.set(20, 40, 20);
218
+ warningObj.renderOrder = 3;
219
+ warningObj.name = 'warningObj';
220
+ return warningObj;
221
+ }
222
+ function swapLengthProperty(diffs) {
223
+ var idx1 = diffs.findIndex(function (v) {
224
+ return v.path[v.path.length - 1] === 'length';
225
+ });
226
+ var idx2 = diffs.findIndex(function (v) {
227
+ return v.path[v.path.length - 1] === '_length';
228
+ });
229
+ if (idx1 < 0 || idx2 < 0) return diffs;
230
+ if (idx1 > idx2) return diffs;
231
+ if (diffs[idx1].op === diffs[idx2].op) {
232
+ var isSwap = true;
233
+ for (var i = 0; i < diffs[idx1].path.length - 2; i++) {
234
+ if (diffs[idx1].path[i] !== diffs[idx2].path[i]) {
235
+ isSwap = false;
236
+ break;
237
+ }
238
+ }
239
+ if (isSwap) {
240
+ var temp = diffs[idx1];
241
+ diffs[idx1] = diffs[idx2];
242
+ diffs[idx2] = temp;
243
+ }
244
+ }
245
+ return diffs;
246
+ }
247
+ function updateScene(planData, sceneData, oldSceneData, diffArray, actions, catalog) {
248
+ var _draggingItem$toJS, _filteredDiffs, _filteredDiffs2;
249
+ var mode = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
250
+ var toolObj = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
251
+ var angleObj = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
252
+ var draggingItem = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : null;
253
+ var result = [];
254
+ if (mode != null) {
255
+ scene_mode = mode;
256
+ }
257
+ var splitted = diffArray.map(function (el) {
258
+ return {
259
+ op: el.op,
260
+ path: el.path.split('/'),
261
+ value: el.value
262
+ };
263
+ });
264
+
265
+ // move "length" to after "_length"
266
+ splitted = swapLengthProperty(splitted);
267
+ var filteredDiffs = filterDiffs(splitted, sceneData, oldSceneData);
268
+ //***testing additional filter***
269
+ filteredDiffs = filteredDiffs.filter(function (_ref) {
270
+ var path = _ref.path;
271
+ return path[3] !== 'selected';
272
+ });
273
+ filteredDiffs = filteredDiffs.filter(function (_ref2) {
274
+ var path = _ref2.path;
275
+ return path[1] !== 'groups';
276
+ });
277
+ //*******************************
278
+ //This is executed when dragging item is end and performs the updateing filteredDiffs.
279
+ if ((sceneData === null || sceneData === void 0 ? void 0 : sceneData.isEndDragging) === true && draggingItem && !(0, _helper.isEmpty)((_draggingItem$toJS = draggingItem.toJS) === null || _draggingItem$toJS === void 0 ? void 0 : _draggingItem$toJS.call(draggingItem)) && ((_filteredDiffs = filteredDiffs) === null || _filteredDiffs === void 0 || (_filteredDiffs = _filteredDiffs[0]) === null || _filteredDiffs === void 0 || (_filteredDiffs = _filteredDiffs.path) === null || _filteredDiffs === void 0 ? void 0 : _filteredDiffs.length) < _constants.DIFFERENT_VALUES_PATH_LENGTH && (_filteredDiffs2 = filteredDiffs) !== null && _filteredDiffs2 !== void 0 && (_filteredDiffs2 = _filteredDiffs2[0]) !== null && _filteredDiffs2 !== void 0 && (_filteredDiffs2 = _filteredDiffs2.path) !== null && _filteredDiffs2 !== void 0 && _filteredDiffs2.includes('showfg')) {
280
+ var _draggingItem$getIn, _draggingItem$getIn2;
281
+ var layerID = (_draggingItem$getIn = draggingItem.getIn) === null || _draggingItem$getIn === void 0 ? void 0 : _draggingItem$getIn.call(draggingItem, ['layerID']);
282
+ var itemID = (_draggingItem$getIn2 = draggingItem.getIn) === null || _draggingItem$getIn2 === void 0 ? void 0 : _draggingItem$getIn2.call(draggingItem, ['itemID']);
283
+ if (layerID && itemID) {
284
+ var _sceneData$getIn, _sceneData$getIn$toJS, _selLayer$items;
285
+ filteredDiffs[0].path = ['', 'layers', layerID, 'items', itemID, 'distArray'];
286
+ var selLayer = (_sceneData$getIn = sceneData.getIn) === null || _sceneData$getIn === void 0 || (_sceneData$getIn = _sceneData$getIn.call(sceneData, ['layers', layerID])) === null || _sceneData$getIn === void 0 || (_sceneData$getIn$toJS = _sceneData$getIn.toJS) === null || _sceneData$getIn$toJS === void 0 ? void 0 : _sceneData$getIn$toJS.call(_sceneData$getIn);
287
+ var distArray = selLayer === null || selLayer === void 0 || (_selLayer$items = selLayer.items) === null || _selLayer$items === void 0 || (_selLayer$items = _selLayer$items[itemID]) === null || _selLayer$items === void 0 ? void 0 : _selLayer$items.distArray;
288
+ filteredDiffs[0].value = distArray;
289
+ }
290
+ }
291
+
292
+ // Check to see if diffs includes changes associated with doorStyle and global molding simultaneously.
293
+ var isSettingDoorStyle = false; // If it includes any doorStyle change
294
+ var isUpdateMolding = false; // If it includes any global molding change
295
+ filteredDiffs.forEach(function (_ref3) {
296
+ var path = _ref3.path;
297
+ /**
298
+ * Every 'doorStyle' change has a 'door_style_id' change.
299
+ * So, if door_style_id changes, it indicates 'doorStyle' change.
300
+ */
301
+ if (path[1] === 'layers' && path[3] === 'molding' || path[path.length - 2] === 'doorStyle' && path[path.length - 1] === 'id' || ['id'].includes(path[path.length - 1])) isSettingDoorStyle = true;
302
+
303
+ // If there are any molding change of layer
304
+ if (path[1] === 'layers' && path[3] === 'molding') isUpdateMolding = true;
305
+ });
306
+ if (isSettingDoorStyle && isUpdateMolding)
307
+ /**
308
+ * If so, any other changes could be ignored.
309
+ * Because the molding change of layer invokes 'createLayerObject()'
310
+ * and that function re-renders an whole layer.
311
+ */
312
+ filteredDiffs = filteredDiffs.filter(function (_ref4) {
313
+ var path = _ref4.path;
314
+ return path[1] === 'layers' && path[3] === 'molding';
315
+ });
316
+ filteredDiffs.forEach(function (_ref5) {
317
+ var op = _ref5.op,
318
+ path = _ref5.path,
319
+ value = _ref5.value;
320
+ /* First of all I need to find the object I need to update */
321
+ if (path[1] === 'layers') {
322
+ var layer = sceneData.getIn(['layers', path[2]]);
323
+ if (path.length === 3 && op === 'remove') {
324
+ removeLayer(path[2], planData);
325
+ } else if (path.length > 3) {
326
+ if (path.length > 5) if (path[5] === 'submodule' || path[5] === 'doorStyle' || path[5] === 'properties') op = 'replace';
327
+ switch (op) {
328
+ case 'replace':
329
+ var promiseValue = replaceObject(path, layer, planData, actions, sceneData, oldSceneData, catalog, mode, value);
330
+ if (promiseValue !== undefined) {
331
+ result.push(promiseValue.promise);
332
+ }
333
+ break;
334
+ case 'add':
335
+ addObject(path, layer, planData, actions, sceneData, oldSceneData, catalog, mode, toolObj);
336
+ break;
337
+ case 'remove':
338
+ if (angleObj) planData.plan.parent.remove(angleObj);
339
+ if (toolObj) planData.plan.parent.remove(toolObj);
340
+ deleteSpecifiedMeshObjects('WarningBox' + path[4]);
341
+ deleteSpecifiedMeshObjects('backsplash' + path[4]);
342
+ var item = oldSceneData.getIn(['layers', path[2]]).getIn(['items', path[4]]);
343
+ deleteCountertop(planData.sceneGraph.layers[layer.id].countertops, item, planData, layer);
344
+ removeObject(path, layer, planData, actions, sceneData, oldSceneData, catalog);
345
+ break;
346
+ }
347
+ }
348
+ } else if (path[1] === 'selectedLayer') {
349
+ var layerSelectedID = value;
350
+ var layerSelected = sceneData.getIn(['layers', layerSelectedID]);
351
+ // First of all I check if the new selected layer is not visible
352
+ if (!layerSelected.visible) {
353
+ // I need to create the objects for this layer
354
+ var promises = createLayerObjects(layerSelected, planData, sceneData, actions, catalog, mode);
355
+ Promise.all(promises).then(function () {
356
+ return updateBoundingBox(planData, false, mode);
357
+ });
358
+ }
359
+ var layerGraph = planData.sceneGraph.layers[oldSceneData.selectedLayer];
360
+ if (layerGraph) {
361
+ if (!layerGraph.visible) {
362
+ // I need to remove the objects for this layer
363
+ for (var lineID in layerGraph.lines) removeLine(planData, layerGraph.id, lineID);
364
+ for (var areaID in layerGraph.areas) removeArea(planData, layerGraph.id, areaID);
365
+ for (var _itemID in layerGraph.items) removeItem(planData, layerGraph.id, _itemID);
366
+ for (var holeID in layerGraph.holes) removeHole(planData, layerGraph.id, holeID);
367
+ }
368
+ }
369
+ }
370
+ });
371
+ var p1 = new Promise(function (resolve) {
372
+ Promise.all(result).then(function (replaceValue) {
373
+ // if mode is elevation, build elevation scene
374
+ // When scene is updated, replaceValue is not empty.
375
+ if ((0, _helper.isElevationView)(mode) && !(0, _helper.isEmpty)(replaceValue)) buildElevationScene(planData, mode);
376
+ resolve('successPromise');
377
+ });
378
+ });
379
+ return {
380
+ promise: p1,
381
+ planData: planData
382
+ };
383
+ }
384
+ var animate_objects = {};
385
+ function myAnimRotate(obj, open_doors, item, isCorner) {
386
+ var animateStep = animate_objects[obj.name].animateStep;
387
+
388
+ // if open the door, animateStep increases to ANIMATE_STEP_MAX and if close the door, animateStep decreases to ANIMATE_STEP_MIN
389
+ animateStep = open_doors ? animateStep + 1 : animateStep - 1;
390
+
391
+ // clear interval when the opening or closing door is ended.
392
+ if (animateStep > _constants.ANIMATE_STEP_MAX || animateStep < _constants.ANIMATE_STEP_MIN) {
393
+ clearInterval(animate_objects[obj.name].animate_intervalID);
394
+ return;
395
+ }
396
+ animate_objects[obj.name].animateStep = animateStep;
397
+ (0, _helper.animateDoor)(animate_objects[obj.name].offset, obj, open_doors, item, isCorner, 'Opened3D');
398
+ }
399
+ function myAnimTranslate(obj, open_doors, item) {
400
+ var animateStep = animate_objects[obj.name].animateStep;
401
+ animateStep = open_doors ? animateStep + 1 : animateStep - 1;
402
+ if (animateStep > _constants.ANIMATE_STEP_MAX || animateStep < _constants.ANIMATE_STEP_MIN) {
403
+ clearInterval(animate_objects[obj.name].animate_intervalID);
404
+ return;
405
+ }
406
+ animate_objects[obj.name].animateStep = animateStep;
407
+ (0, _helper.translateDrawer)(item, obj, open_doors, 'Opened3D');
408
+ }
409
+ function replaceObject(modifiedPath, layer, planData, actions, sceneData, oldSceneData, catalog) {
410
+ var mode = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
411
+ var value = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
412
+ var promises = [];
413
+ var matchStr = /\d_(door[^LR1-9]*)(_[LR])?(_[1-9])?$/;
414
+ switch (modifiedPath[3]) {
415
+ case 'vertices':
416
+ if (modifiedPath[5] !== 'selected') {
417
+ var vertex = layer.getIn(['vertices', modifiedPath[4]]);
418
+ if (modifiedPath[5] === 'x' || modifiedPath[5] === 'y') {
419
+ vertex.lines.forEach(function (lineID) {
420
+ var lineHoles = oldSceneData.getIn(['layers', layer.id, 'lines', lineID, 'holes']);
421
+ if (lineHoles) lineHoles.forEach(function (holeID) {
422
+ replaceObject([0, 0, 0, 'holes', holeID, 'selected'], layer, planData, actions, sceneData, oldSceneData, catalog, mode);
423
+ });
424
+ return replaceObject([0, 0, 0, 'lines', lineID], layer, planData, actions, sceneData, oldSceneData, catalog, mode);
425
+ });
426
+ vertex.areas.forEach(function (areaID) {
427
+ return replaceObject([0, 0, 0, 'areas', areaID], layer, planData, actions, sceneData, oldSceneData, catalog, mode);
428
+ });
429
+ }
430
+ if (modifiedPath[5] === 'areas') {
431
+ var areaID = vertex.getIn(['areas', ~~modifiedPath[6]]);
432
+ replaceObject([0, 0, 0, 'areas', areaID], layer, planData, actions, sceneData, oldSceneData, catalog, mode);
433
+ }
434
+ }
435
+ break;
436
+ case 'holes':
437
+ var newHoleData = layer.getIn(['holes', modifiedPath[4]]);
438
+ if (catalog.getElement(newHoleData.type).updateRender3D) {
439
+ promises.push(updateHole(sceneData, oldSceneData, planData, layer, modifiedPath[4], modifiedPath.slice(5), catalog, actions.holesActions, function () {
440
+ return removeHole(planData, layer.id, newHoleData.id);
441
+ }, function () {
442
+ return addHole(sceneData, planData, layer, newHoleData.id, catalog, actions.holesActions, mode);
443
+ }));
444
+ } else {
445
+ var lineID = newHoleData.line;
446
+ if (modifiedPath[5] === 'selected' || scene_mode === 'MODE_DRAWING_HOLE_3D' || scene_mode === 'MODE_DRAGGING_HOLE_3D') {
447
+ // I remove only the hole without removing the wall
448
+ removeHole(planData, layer.id, newHoleData.id);
449
+ promises.push(addHole(sceneData, planData, layer, newHoleData.id, catalog, actions.holesActions, mode));
450
+ } else {
451
+ layer.getIn(['lines', lineID, 'holes']).forEach(function (holeID) {
452
+ removeHole(planData, layer.id, holeID);
453
+ });
454
+ removeLine(planData, layer.id, lineID);
455
+ promises.push(addLine(sceneData, planData, layer, lineID, catalog, actions.linesActions));
456
+ layer.getIn(['lines', lineID, 'holes']).forEach(function (holeID) {
457
+ promises.push(addHole(sceneData, planData, layer, holeID, catalog, actions.holesActions, mode));
458
+ });
459
+ }
460
+ }
461
+ break;
462
+ case 'lines':
463
+ var line = layer.getIn(['lines', modifiedPath[4]]);
464
+ if (catalog.getElement(line.type).updateRender3D) {
465
+ promises.push(updateLine(sceneData, oldSceneData, planData, layer, modifiedPath[4], modifiedPath.slice(5), catalog, actions.linesActions, function () {
466
+ return removeLine(planData, layer.id, modifiedPath[4]);
467
+ }, function () {
468
+ return addLine(sceneData, planData, layer, modifiedPath[4], catalog, actions.linesActions);
469
+ }));
470
+ } else {
471
+ removeLine(planData, layer.id, modifiedPath[4]);
472
+ promises.push(addLine(sceneData, planData, layer, modifiedPath[4], catalog, actions.linesActions));
473
+ }
474
+ break;
475
+ case 'areas':
476
+ var area = layer.getIn(['areas', modifiedPath[4]]);
477
+ if (catalog.getElement(area.type).updateRender3D) {
478
+ promises.push(updateArea(sceneData, oldSceneData, planData, layer, modifiedPath[4], modifiedPath.slice(5), catalog, actions.areaActions, function () {
479
+ return removeArea(planData, layer.id, modifiedPath[4]);
480
+ }, function () {
481
+ return addArea(sceneData, planData, layer, modifiedPath[4], catalog, actions.areaActions);
482
+ }));
483
+ } else {
484
+ if (planData.sceneGraph.layers[layer.id].areas[modifiedPath[4]]) {
485
+ removeArea(planData, layer.id, modifiedPath[4]);
486
+ }
487
+ promises.push(addArea(sceneData, planData, layer, modifiedPath[4], catalog, actions.areaActions));
488
+ }
489
+ break;
490
+ case 'items':
491
+ var item = layer.getIn(['items', modifiedPath[4]]);
492
+ if ((0, _helper.isEmpty)(item)) break;
493
+ deleteCountertop(planData.sceneGraph.layers[layer.id].countertops, item, planData, layer);
494
+ var tmpMoldings = (0, _toConsumableArray2["default"])(planData.sceneGraph.layers[layer.id].moldingGroups);
495
+ if (catalog.getElement(item.type).updateRender3D) {
496
+ promises.push(updateItem(sceneData, oldSceneData, planData, layer, modifiedPath[4], modifiedPath.slice(5), catalog, actions.itemsActions, function () {
497
+ return removeItem(planData, layer.id, modifiedPath[4], oldSceneData.getIn(['layers', layer.id]), layer);
498
+ }, function () {
499
+ return addItem(sceneData, planData, layer, modifiedPath[4], catalog, actions.itemsActions, mode);
500
+ }));
501
+ } else {
502
+ var item3D = null;
503
+ try {
504
+ item3D = planData.sceneGraph.layers[layer.id].items[modifiedPath[4]];
505
+ } catch (err) {
506
+ console.log('modifiedPath: ', modifiedPath, '\nError: ', err);
507
+ return;
508
+ }
509
+ if (!item3D) return;
510
+ var keyIndex = modifiedPath.length - 1;
511
+ if (modifiedPath[keyIndex] == 'rotation') {
512
+ item3D.rotation.set(0, value * Math.PI / 180 + Math.PI, 0);
513
+ setTimeout(function () {
514
+ getDistances(layer, item);
515
+ }, 50);
516
+ removeSelItemMesh(tmpMoldings, item, planData, mode);
517
+ } else if (modifiedPath[keyIndex] == 'x') {
518
+ item3D.position.x = value;
519
+ setTimeout(function () {
520
+ getDistances(layer, item);
521
+ }, 50);
522
+ removeSelItemMesh(tmpMoldings, item, planData, mode);
523
+ } else if (modifiedPath[keyIndex] == 'y') {
524
+ item3D.position.z = -value;
525
+ setTimeout(function () {
526
+ getDistances(layer, item);
527
+ }, 50);
528
+ removeSelItemMesh(tmpMoldings, item, planData, mode);
529
+ } else if (modifiedPath[keyIndex] == 'selected') {
530
+ var itemType = !!catalog.elements[item.type] ? catalog.elements[item.type].type : catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(item.type)].type;
531
+ if (value == false) {
532
+ item3D.children[0].children = item3D.children[0].children.filter(function (item3DElement) {
533
+ return item3DElement.name !== 'TransformBox' && item3DElement.name !== 'TransformGizmo';
534
+ });
535
+ if (item3D) {
536
+ if (item3D.children.length > 1) {
537
+ item3D.children.pop();
538
+ }
539
+ var mBoxColor = 0x99c3fb;
540
+ var _item = item.toJS();
541
+ if ((0, _cabinetWarning.isWarningCabinet)(_item)) {
542
+ mBoxColor = 'rgba(232,187,47,1)';
543
+ var mBox = GeomUtils.makeMBoxfromObject(item3D, mBoxColor);
544
+ var warningObj = createWarningObject();
545
+ warningObj.position.set(0, item.properties.get('height').get('length') / 3, 0);
546
+ if (mBox) {
547
+ mBox.add(warningObj);
548
+ item3D.add(mBox);
549
+ }
550
+ }
551
+ }
552
+ var temp_MGArray = planData.sceneGraph.layers[layer.id].moldingGroups;
553
+ } else {
554
+ if (item3D.name !== 'pivot' && item3D.children[0].children[item3D.children[0].children.length - 1].name == 'TransformGizmo') return;
555
+ if (item3D.children[0].children[item3D.children[0].children.length - 1].name == 'TransformGizmo') {
556
+ item3D.children[0].children.pop();
557
+ }
558
+ var object = item3D.children[0].clone();
559
+ if (item3D.children.length > 1) {
560
+ item3D.children.pop();
561
+ }
562
+ item3D.children.pop();
563
+ var altitude = item.properties.get('altitude').get('length');
564
+ var scalevec = new Three.Vector3(object.scale.x, object.scale.y, object.scale.z);
565
+ var posVec = new Three.Vector3(object.position.x, object.position.y, object.position.z);
566
+ var newAltitude = item.properties.get('altitude').get('_length');
567
+ var newUnit = item.properties.get('altitude').get('_unit') || 'in';
568
+ newAltitude = (0, _convertUnitsLite.convert)(newAltitude).from(newUnit).to(sceneData.unit);
569
+ var newWidth = item.properties.get('width').get('_length');
570
+ var newWidthUnit = item.properties.get('width').get('_unit') || 'in';
571
+ newWidth = (0, _convertUnitsLite.convert)(newWidth).from(newWidthUnit).to('in');
572
+ var newHeight = item.properties.get('height').get('_length');
573
+ var newHeightUnit = item.properties.get('height').get('_unit') || 'in';
574
+ newHeight = (0, _convertUnitsLite.convert)(newHeight).from(newHeightUnit).to('in');
575
+ var newDepth = item.properties.get('depth').get('_length');
576
+ var newDepthUnit = item.properties.get('depth').get('_unit') || 'in';
577
+ newDepth = (0, _convertUnitsLite.convert)(newDepth).from(newDepthUnit).to('in');
578
+ var sizeinfo = !!catalog.elements[item.type] ? catalog.elements[item.type].info.sizeinfo : catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(item.type)].info.sizeinfo;
579
+ object.scale.set(1 * newWidth / sizeinfo.width, 1 * newHeight / sizeinfo.height, 1 * newDepth / sizeinfo.depth);
580
+ object.position.set(0, 0, 0);
581
+ object.rotation.set(0, 0, 0);
582
+ var box = GeomUtils.baseBoxHelper(object, 0xffffff);
583
+ box.material.lineWidth = 0.01;
584
+ var boundingBox = GeomUtils.baseBox3FromObject(object);
585
+ var max = boundingBox.max;
586
+ var min = boundingBox.min;
587
+ var radius = Math.sqrt((boundingBox.max.x - boundingBox.min.x) * (boundingBox.max.x - boundingBox.min.x) + (boundingBox.max.z - boundingBox.min.z) * (boundingBox.max.z - boundingBox.min.z)) / 2;
588
+ var moveBox = new Three.BoxGeometry(max.x - min.x, max.y - min.y, max.z - min.z);
589
+
590
+ // translate Object
591
+ var controlGeom = GeomUtils.controlGeom();
592
+
593
+ // rotate Object //////////
594
+ var rotGeom = GeomUtils.rotGeoms(radius + 0.05);
595
+ // //////////////////////////////////
596
+ // upwards Geometry///////////
597
+ var upwardsGeom = GeomUtils.upwardsGeom();
598
+ var vLineGeom = new Three.BufferGeometry();
599
+ var vertices = [(max.x - min.x) / 2 + min.x, 0, max.z, (max.x - min.x) / 2 + min.x, 0, max.z + 1.3];
600
+ vLineGeom.setAttribute('position', new Three.BufferAttribute(new Float32Array(vertices), 3));
601
+ vLineGeom.attributes.position.needsUpdate = true;
602
+ var vLineGeom1 = new Three.BufferGeometry();
603
+ var vertices1 = [(max.x - min.x) / 2 + min.x, 0, min.z, (max.x - min.x) / 2 + min.x, 0, min.z - 1.3];
604
+ vLineGeom1.setAttribute('position', new Three.BufferAttribute(new Float32Array(vertices1), 3));
605
+ vLineGeom1.attributes.position.needsUpdate = true;
606
+ var vLineGeom2 = new Three.BufferGeometry();
607
+ var vertices2 = [max.x, 0, max.z - (max.z - min.z) / 2, max.x + 1.3, 0, max.z - (max.z - min.z) / 2];
608
+ vLineGeom2.setAttribute('position', new Three.BufferAttribute(new Float32Array(vertices2), 3));
609
+ var vLineGeom3 = new Three.BufferGeometry();
610
+ var vertices3 = [min.x, 0, max.z - (max.z - min.z) / 2, min.x - 1.3, 0, max.z - (max.z - min.z) / 2];
611
+ vLineGeom3.setAttribute('position', new Three.BufferAttribute(new Float32Array(vertices3), 3));
612
+ // ///////////////////////////////////////
613
+
614
+ // set names of transform object
615
+ var rotFillObj = new Three.Mesh(rotGeom.rotFill, new Three.MeshPhongMaterial({
616
+ color: 0x000000,
617
+ side: Three.DoubleSide,
618
+ colorWrite: true
619
+ }));
620
+ var rotStrokeObj = new Three.Line(rotGeom.rotStroke, new Three.LineBasicMaterial({
621
+ color: 0xffffff,
622
+ colorWrite: true
623
+ }));
624
+ rotFillObj.name = 'rotate';
625
+ var upObj = new Three.Mesh(upwardsGeom, new Three.MeshBasicMaterial({
626
+ color: 0x000000,
627
+ side: Three.DoubleSide
628
+ }));
629
+ // let upLine = new Three.Line(upwardsGeom, new Three.LineBasicMaterial({ color: 0x000000 }));
630
+ // upLine.name = "transUp";
631
+ // upObj.add(upLine);
632
+ upObj.name = 'transUp';
633
+ var upwardbox = new Three.BoxHelper(upObj, 0x326780);
634
+ upwardbox.material.lineWidth = 0.01;
635
+ exports.fVLine = fVLine = [];
636
+ // let obj = new Three.Mesh(controlGeom, new Three.MeshPhongMaterial({ color: 0xffffff, side: Three.DoubleSide, colorWrite: true }));
637
+ // obj.name = "translateX";
638
+ var color = _constants.SHADE_DARK_PURPLE_COLOR;
639
+ var _mBox = new Three.Mesh(moveBox, new Three.MeshBasicMaterial({
640
+ color: 0xdd6699,
641
+ side: Three.DoubleSide,
642
+ transparent: true,
643
+ opacity: 0.4
644
+ }));
645
+ var vLine = new Three.Line(vLineGeom, new Three.LineBasicMaterial({
646
+ color: color
647
+ }));
648
+ var vLine1 = new Three.Line(vLineGeom1, new Three.LineBasicMaterial({
649
+ color: color
650
+ }));
651
+ var vLine2 = new Three.Line(vLineGeom2, new Three.LineBasicMaterial({
652
+ color: color
653
+ }));
654
+ var vLine3 = new Three.Line(vLineGeom3, new Three.LineBasicMaterial({
655
+ color: color
656
+ }));
657
+ fVLine.push(vLine);
658
+ fVLine.push(vLine1);
659
+ fVLine.push(vLine2);
660
+ fVLine.push(vLine3);
661
+ vLine.renderOrder = 1;
662
+ vLine1.renderOrder = 1;
663
+ vLine2.renderOrder = 1;
664
+ vLine3.renderOrder = 1;
665
+ vLine.material.transparent = true;
666
+ vLine1.material.transparent = true;
667
+ vLine2.material.transparent = true;
668
+ vLine3.material.transparent = true;
669
+ vLine.material.depthTest = false;
670
+ vLine1.material.depthTest = false;
671
+ vLine2.material.depthTest = false;
672
+ vLine3.material.depthTest = false;
673
+ var uVec = new Three.Vector3(-posVec.x / scalevec.x, -posVec.y / scalevec.y, -posVec.z / scalevec.z);
674
+ var blLighting = item.type.includes('Light');
675
+ vLine.translateY(blLighting ? 1.6 : boundingBox.min.y + 0.1);
676
+ vLine1.translateY(blLighting ? 1.6 : boundingBox.min.y + 0.1);
677
+ vLine2.translateY(blLighting ? 1.6 : boundingBox.min.y + 0.1);
678
+ vLine3.translateY(blLighting ? 1.6 : boundingBox.min.y + 0.1);
679
+ upObj.translateOnAxis(uVec, 1);
680
+ upObj.translateY(max.y - min.y);
681
+ _mBox.name = 'TransformBox';
682
+ _mBox.translateOnAxis(new Three.Vector3(uVec.x, uVec.y + (max.y - min.y) / 2, uVec.z), 1);
683
+ _mBox.scale.set(1.01, 1.01, 1.01);
684
+ var rotFillObj1 = rotFillObj.clone();
685
+ var rotStrokeObj1 = rotStrokeObj.clone();
686
+ rotFillObj1.rotateY(Math.PI);
687
+ rotStrokeObj1.rotateY(Math.PI);
688
+ var asrtObj = new Three.Group();
689
+ // let asrtObj1 = new Three.Group();
690
+ // asrtObj.add(obj);
691
+ // asrtObj.add(obj1);
692
+ rotFillObj.translateY(blLighting ? 1.6 : 0.1);
693
+ rotFillObj1.translateY(blLighting ? 1.6 : 0.1);
694
+ rotStrokeObj.translateY(blLighting ? 1.6 : 0.1);
695
+ rotStrokeObj1.translateY(blLighting ? 1.6 : 0.1);
696
+ upObj.translateY(posVec.y / scalevec.y);
697
+ upObj.add(upwardbox);
698
+ //asrtObj.add(upObj);
699
+ // vLine.translateY(posVec.y / scalevec.y);
700
+ // vLine1.translateY(posVec.y / scalevec.y);
701
+ // vLine2.translateY(posVec.y / scalevec.y);
702
+ // vLine3.translateY(posVec.y / scalevec.y);
703
+
704
+ _mBox.translateY(posVec.y / scalevec.y);
705
+ // asrtObj.add(rotFillObj);
706
+ // asrtObj.add(rotFillObj1);
707
+ // asrtObj.add(rotStrokeObj);
708
+ // asrtObj.add(rotStrokeObj1);
709
+ asrtObj.add(vLine);
710
+ asrtObj.add(vLine1);
711
+ asrtObj.add(vLine2);
712
+ asrtObj.add(vLine3);
713
+ asrtObj.add(box);
714
+ asrtObj.scale.set(1 / object.scale.x, object.scale.y, 1 / object.scale.z);
715
+ _mBox.visible = false;
716
+ // transformBox = mBox;
717
+ // asrtObj.add(mBox);
718
+ asrtObj.name = 'TransformGizmo';
719
+ object.add(asrtObj);
720
+ object.position.x = posVec.x;
721
+ object.position.y = posVec.y;
722
+ object.position.z = posVec.z;
723
+ // object.rotation.y = Math.PI;
724
+ object.scale.set(scalevec.x, scalevec.y, scalevec.z);
725
+ item3D.add(object);
726
+ if (item3D) {
727
+ var _mBoxColor = 0x99c3fb;
728
+ var _item2 = item.toJS();
729
+ if ((0, _cabinetWarning.isWarningCabinet)(_item2)) {
730
+ _mBoxColor = 'rgba(232,187,47,1)';
731
+ var _mBox2 = GeomUtils.makeMBoxfromObject(item3D, _mBoxColor);
732
+ var _warningObj = createWarningObject();
733
+ _warningObj.position.set(0, item.properties.get('height').get('length') / 3, 0);
734
+ if (_mBox2) {
735
+ _mBox2.add(_warningObj);
736
+ item3D.add(_mBox2);
737
+ }
738
+ }
739
+ }
740
+ applyInteract(item3D, function () {
741
+ // closes the setting dialog
742
+ if (document.getElementById('setting_dialog')) {
743
+ document.getElementById('setting_dialog').style.display = 'none';
744
+ }
745
+ return actions.itemsActions.selectItem(layer.id, modifiedPath[4]);
746
+ });
747
+ setTimeout(function () {
748
+ getDistances(layer, item);
749
+ }, 100);
750
+ }
751
+ } else if (modifiedPath[keyIndex] == 'length') {
752
+ var _object = item3D.children[0];
753
+ var prevPos = _object.position;
754
+ _object.position.set(prevPos.x, value, prevPos.z);
755
+ } else if (modifiedPath[keyIndex] == 'flip_doorhandle') {
756
+ updateDoorHandleMesh(item, item3D, value);
757
+ var _object2 = item3D.children[0];
758
+ var door_animate_offset = _object2.userData.door_animate_offset;
759
+ var _loop = function _loop(it) {
760
+ if (_object2.children.filter(function (elem) {
761
+ return elem.name === it;
762
+ }).length) {
763
+ var door_match = it.match(matchStr);
764
+ var rotate_match_text = item.properties.toJS().flip_doorhandle ? 'rotate_L' : 'rotate_R';
765
+ if (door_match[2] === '_L') {
766
+ rotate_match_text = item.properties.toJS().flip_doorhandle ? 'rotate_R' : 'rotate_L';
767
+ }
768
+ _object2.children.filter(function (elem) {
769
+ return elem.name === it;
770
+ })[0].children[0].children.forEach(function (child) {
771
+ if (child.name.endsWith(rotate_match_text)) {
772
+ door_animate_offset[it] = {
773
+ x: child.position.x,
774
+ y: child.position.y,
775
+ z: child.position.z
776
+ };
777
+ }
778
+ });
779
+ }
780
+ };
781
+ for (var it in door_animate_offset) {
782
+ _loop(it);
783
+ }
784
+ _object2.userData.door_animate_offset = door_animate_offset;
785
+ } else if (modifiedPath[keyIndex] == 'animValue') {
786
+ return;
787
+ } else if (modifiedPath[keyIndex] == 'open_doors') {
788
+ var _object3 = item3D.children[0];
789
+ var userData = item3D.children[0].userData;
790
+ var moveObjectChildrens = [];
791
+ var selectedItem = layer.getIn(['items', layer.selected.toJS().items[0]]).toJS();
792
+ _object3.children.forEach(function (child, idx) {
793
+ var object_match = child.name.match(/\d_(interior_drawer[^LR1-9]*)(_[LR1-9])?$/) || child.name.match(matchStr);
794
+ if (object_match && object_match.length > 2) {
795
+ moveObjectChildrens.push({
796
+ type: object_match[1],
797
+ obj: child
798
+ });
799
+ animate_objects[child.name] = animate_objects[child.name] || {};
800
+ }
801
+ });
802
+ var temp = moveObjectChildrens.filter(function (item) {
803
+ var _object3$userData$doo;
804
+ return (_object3$userData$doo = _object3.userData.door_animate_offset[item.obj.name]) === null || _object3$userData$doo === void 0 ? void 0 : _object3$userData$doo.isCorner;
805
+ });
806
+ var isCorner = temp.length > 0;
807
+ moveObjectChildrens.forEach(function (element) {
808
+ var _animate_objects$elem, _animate_objects$elem2;
809
+ if (((_animate_objects$elem = animate_objects[element.obj.name]) === null || _animate_objects$elem === void 0 ? void 0 : _animate_objects$elem.animateStep) === undefined) {
810
+ animate_objects[element.obj.name].animateStep = selectedItem.properties.open_doors ? _constants.ANIMATE_STEP_MIN : _constants.ANIMATE_STEP_MAX;
811
+ }
812
+
813
+ // clear origin Interval.
814
+ if ((_animate_objects$elem2 = animate_objects[element.obj.name]) !== null && _animate_objects$elem2 !== void 0 && _animate_objects$elem2.animate_intervalID) {
815
+ var _animate_objects$elem3;
816
+ clearInterval((_animate_objects$elem3 = animate_objects[element.obj.name]) === null || _animate_objects$elem3 === void 0 ? void 0 : _animate_objects$elem3.animate_intervalID);
817
+ }
818
+ if (element.type === 'door') {
819
+ var _userData$door_animat, _element$obj;
820
+ // This is excuted when item has door.
821
+ var offset = userData === null || userData === void 0 || (_userData$door_animat = userData.door_animate_offset) === null || _userData$door_animat === void 0 ? void 0 : _userData$door_animat[element === null || element === void 0 || (_element$obj = element.obj) === null || _element$obj === void 0 ? void 0 : _element$obj.name];
822
+ if (offset) {
823
+ var _offset$x, _offset$y, _offset$z;
824
+ animate_objects[element.obj.name].offset = {
825
+ x: (_offset$x = offset.x) !== null && _offset$x !== void 0 ? _offset$x : 0,
826
+ y: (_offset$y = offset.y) !== null && _offset$y !== void 0 ? _offset$y : 0,
827
+ z: (_offset$z = offset.z) !== null && _offset$z !== void 0 ? _offset$z : 0
828
+ };
829
+ } else {
830
+ var _element$obj2;
831
+ console.warn('⚠ Missing door_animate_offset for', element === null || element === void 0 || (_element$obj2 = element.obj) === null || _element$obj2 === void 0 ? void 0 : _element$obj2.name);
832
+ animate_objects[element.obj.name].offset = {
833
+ x: 0,
834
+ y: 0,
835
+ z: 0
836
+ };
837
+ }
838
+
839
+ // Set the interval ID to new interval ID
840
+ animate_objects[element.obj.name].animate_intervalID = setInterval(function () {
841
+ myAnimRotate(element.obj, selectedItem.properties.open_doors, selectedItem, isCorner);
842
+ }, 30);
843
+ } else {
844
+ // This is excuted when item has drawer box
845
+ // Set the interval ID to new interval ID
846
+ animate_objects[element.obj.name].animate_intervalID = setInterval(function () {
847
+ myAnimTranslate(element.obj, selectedItem.properties.open_doors, selectedItem);
848
+ }, 30);
849
+ }
850
+ });
851
+ } else if (['_length', 'doorStyle', 'cabinet_door_style_id', 'counterTop', 'texture', 'drawer_door_handle_1_gltf'].includes(modifiedPath[keyIndex])) {
852
+ var rItem = planData.sceneGraph.layers[layer.id].items[modifiedPath[4]];
853
+ if (rItem) {
854
+ if (rItem.children.length > 1) {
855
+ rItem.children.pop();
856
+ }
857
+ var _mBoxColor2 = 0x99c3fb;
858
+ var _item3 = item.toJS();
859
+ if ((0, _cabinetWarning.isWarningCabinet)(_item3)) {
860
+ _mBoxColor2 = 'rgba(232,187,47,1)';
861
+ }
862
+ rItem.children[0].children.forEach(function (rItemElement) {
863
+ rItemElement.visible = false;
864
+ });
865
+ var _mBox3 = GeomUtils.makeMBoxfromObject(rItem, _mBoxColor2);
866
+ if (_mBox3) {
867
+ //rItem.add (mBox);
868
+ }
869
+ }
870
+ if (rItem != null) {
871
+ removeItemWithoutItem(planData, layer.id, modifiedPath[4]);
872
+ promises.push(addItem(sceneData, planData, layer, modifiedPath[4], catalog, actions.itemsActions, mode, null, rItem));
873
+ setTimeout(function () {
874
+ getDistances(layer, item);
875
+ }, 100);
876
+ }
877
+ break;
878
+ }
879
+ }
880
+ item = layer.getIn(['items', modifiedPath[4]]);
881
+ addCountertop(planData.sceneGraph.layers[layer.id].countertops, item, planData, layer);
882
+ // Toggle selection should not update molding
883
+ if (item.category === 'cabinet' && modifiedPath[modifiedPath.length - 1] !== 'selected' && !modifiedPath[modifiedPath.length - 1].includes('handle')) {
884
+ planData.sceneGraph.layers[layer.id].moldingGroups = addMolding(tmpMoldings, item, planData, layer, actions.itemsActions, mode) || (0, _toConsumableArray2["default"])(tmpMoldings);
885
+ }
886
+ break;
887
+ case 'visible':
888
+ if (!layer.visible) {
889
+ var _layerGraph = planData.sceneGraph.layers[layer.id];
890
+ for (var _lineID in _layerGraph.lines) removeLine(planData, layer.id, _lineID);
891
+ for (var _areaID in _layerGraph.areas) removeArea(planData, layer.id, _areaID);
892
+ for (var itemID in _layerGraph.items) removeItem(planData, layer.id, itemID);
893
+ for (var holeID in _layerGraph.holes) removeHole(planData, layer.id, holeID);
894
+ } else {
895
+ promises = promises.concat(createLayerObjects(layer, planData, sceneData, actions, catalog, mode));
896
+ }
897
+ break;
898
+ case 'unit':
899
+ case 'ceilHeight':
900
+ case 'opacity':
901
+ case 'altitude':
902
+ case 'molding':
903
+ var layerGraph = planData.sceneGraph.layers[layer.id];
904
+ for (var _lineID2 in layerGraph.lines) removeLine(planData, layer.id, _lineID2);
905
+ for (var _areaID2 in layerGraph.areas) removeArea(planData, layer.id, _areaID2);
906
+ for (var _itemID2 in layerGraph.items) removeItem(planData, layer.id, _itemID2);
907
+ for (var _holeID in layerGraph.holes) removeHole(planData, layer.id, _holeID);
908
+ promises = promises.concat(createLayerObjects(layer, planData, sceneData, actions, catalog, mode));
909
+ }
910
+ var p1 = new Promise(function (resolve) {
911
+ Promise.all(promises).then(function (values) {
912
+ updateBoundingBox(planData, true, mode);
913
+ resolve('replaceObject');
914
+ });
915
+ });
916
+ return {
917
+ promise: p1
918
+ };
919
+ }
920
+ function getDistances(layer, curItem, isCalcWall) {
921
+ // matching fvLine distance with OP
922
+ var pointArray = (0, _geometry2.calcDistancesFromItemToWalls)(curItem, layer).PointArray;
923
+ if ((pointArray === null || pointArray === void 0 ? void 0 : pointArray.length) > 0) {
924
+ var _loop2 = function _loop2() {
925
+ var direction = i === 0 ? 90 : i === 1 ? -90 : i === 2 ? 180 : 0;
926
+ if (fVLine[i].userData) {
927
+ var _pointArray$filter$;
928
+ var opDist = (_pointArray$filter$ = pointArray.filter(function (v) {
929
+ return v[1] === direction;
930
+ })[0]) !== null && _pointArray$filter$ !== void 0 ? _pointArray$filter$ : fVLine[i].userData.distance;
931
+ fVLine[i].userData.opDist = opDist[0];
932
+ }
933
+ };
934
+ for (var i = 0; i < ((_fVLine = fVLine) === null || _fVLine === void 0 ? void 0 : _fVLine.length); i++) {
935
+ var _fVLine;
936
+ _loop2();
937
+ }
938
+ }
939
+ fVLine.forEach(function (line, index) {
940
+ getLineDistance2(line, layer, (0, _helper.isEmpty)(isCalcWall) ? false : isCalcWall, index);
941
+ });
942
+ }
943
+ function getLineDistance2(obj, layer, isCalcWall, index) {
944
+ var _obj$userData$opDist, _obj$userData, _obj$userData2, _obj$userData$opDist2, _obj$userData3, _obj$userData4;
945
+ if (obj === undefined) return;
946
+ var positionAttribute = obj.geometry.attributes.position;
947
+ if (positionAttribute === undefined) return;
948
+ var wPoint0 = new Three.Vector3().fromBufferAttribute(positionAttribute, 0).applyMatrix4(obj.matrixWorld);
949
+ var wPoint1 = new Three.Vector3().fromBufferAttribute(positionAttribute, 1).applyMatrix4(obj.matrixWorld);
950
+ var raycaster = new Three.Raycaster(wPoint0, new Three.Vector3(wPoint1.x - wPoint0.x, wPoint1.y - wPoint0.y, wPoint1.z - wPoint0.z));
951
+ var rayDirection = raycaster.ray.direction;
952
+ raycaster.camera = new Three.Camera();
953
+ rayDirection.normalize();
954
+ var meshes = [];
955
+ planData.plan.traverse(function (child) {
956
+ if (child.isMesh && child.geometry) {
957
+ meshes.push(child);
958
+ }
959
+ });
960
+ var dx = wPoint0.x - wPoint1.x;
961
+ var dy = wPoint0.y - wPoint1.y;
962
+ var dz = wPoint0.z - wPoint1.z;
963
+ var length = Math.sqrt(dx * dx + dy * dy + dz * dz);
964
+ var scale = 1;
965
+ var extrudeSettings = {
966
+ steps: 2,
967
+ depth: 0.01,
968
+ bevelEnabled: false
969
+ };
970
+ var w = 0.2;
971
+ var h = w * (Math.sqrt(3) / 2);
972
+ var shape = new Three.Shape();
973
+ shape.moveTo(0, 0);
974
+ shape.lineTo(-w / 4, h / 2);
975
+ shape.lineTo(w / 4, h / 2);
976
+ var geom = new Three.ExtrudeGeometry(shape, extrudeSettings);
977
+ geom.center();
978
+ var opDist = (_obj$userData$opDist = (_obj$userData = obj.userData) === null || _obj$userData === void 0 ? void 0 : _obj$userData.opDist) !== null && _obj$userData$opDist !== void 0 ? _obj$userData$opDist : (_obj$userData2 = obj.userData) === null || _obj$userData2 === void 0 ? void 0 : _obj$userData2.distance;
979
+ scale = opDist / length;
980
+ if (opDist <= 0.1) {
981
+ scale = 0.1 / length;
982
+ }
983
+ obj.userData.distance = (_obj$userData$opDist2 = (_obj$userData3 = obj.userData) === null || _obj$userData3 === void 0 ? void 0 : _obj$userData3.opDist) !== null && _obj$userData$opDist2 !== void 0 ? _obj$userData$opDist2 : (_obj$userData4 = obj.userData) === null || _obj$userData4 === void 0 ? void 0 : _obj$userData4.distance;
984
+ // obj.userData.target = intersects[i].object;
985
+ var originPoint = obj.geometry.attributes.position.array.slice(0, 3);
986
+ var lx = obj.geometry.attributes.position.array[3] - obj.geometry.attributes.position.array[0];
987
+ var ly = obj.geometry.attributes.position.array[4] - obj.geometry.attributes.position.array[1];
988
+ var lz = obj.geometry.attributes.position.array[5] - obj.geometry.attributes.position.array[2];
989
+ var newVec = new Three.Vector3(originPoint[0] + lx * scale, originPoint[1] + ly * scale, originPoint[2] + lz * scale);
990
+ obj.geometry.attributes.position.array[3] = newVec.x;
991
+ obj.geometry.attributes.position.array[4] = newVec.y;
992
+ obj.geometry.attributes.position.array[5] = newVec.z;
993
+ obj.geometry.attributes.position.needsUpdate = true;
994
+ obj.geometry.computeBoundingSphere();
995
+ obj.geometry.computeBoundingBox();
996
+ var dist = (0, _convertUnitsLite.convert)(opDist).from('cm').to('in');
997
+ if (dist > 3) {
998
+ var _canvas = getDistanceCanvas(dist, layer);
999
+ var wid = _canvas.width / window.innerWidth * 30;
1000
+ var hei = _canvas.height / window.innerHeight * 30;
1001
+ var texture = new Three.Texture(_canvas);
1002
+ texture.minFilter = Three.LinearFilter;
1003
+ texture.needsUpdate = true;
1004
+ var geometry = new Three.PlaneGeometry(wid / 5, hei / 5);
1005
+ geometry.computeBoundingBox();
1006
+ var material = new Three.MeshBasicMaterial({
1007
+ map: texture,
1008
+ side: Three.DoubleSide
1009
+ });
1010
+ var textMesh = new Three.Mesh(geometry, material);
1011
+ for (; obj.children.length != 0;) {
1012
+ var temp = obj.children.pop();
1013
+ (0, _threeMemoryCleaner.disposeObject)(temp);
1014
+ }
1015
+ textMesh.rotation.set(Math.PI / 2, Math.PI, 0);
1016
+ // obj.add(textMesh);
1017
+ textMesh.position.set((obj.geometry.attributes.position.array[0] + obj.geometry.attributes.position.array[3]) / 2, 0.01, (obj.geometry.attributes.position.array[2] + obj.geometry.attributes.position.array[5]) / 2);
1018
+ textMesh.name = 'lineText';
1019
+ textMesh.renderOrder = 2;
1020
+ textMesh.material.depthTest = false;
1021
+ textMesh.material.transparent = true;
1022
+ var sprite1 = new Three.Sprite(new Three.SpriteMaterial({
1023
+ map: texture
1024
+ }));
1025
+ sprite1.position.set((obj.geometry.attributes.position.array[0] + obj.geometry.attributes.position.array[3]) / 2, 0.01, (obj.geometry.attributes.position.array[2] + obj.geometry.attributes.position.array[5]) / 2);
1026
+ sprite1.name = 'lineText';
1027
+ sprite1.renderOrder = 2;
1028
+ sprite1.scale.set(0.2, 0.1, 0.2);
1029
+ sprite1.layers.set(1);
1030
+ sprite1.material.depthTest = false;
1031
+ obj.add(sprite1);
1032
+ if (obj.parent != null) {
1033
+ // is not lighting
1034
+ var item3D = obj.parent.parent.parent;
1035
+ var max = item3D.children[0].userData.max;
1036
+ var min = item3D.children[0].userData.min;
1037
+ var objW = (max.x - min.x) / 100,
1038
+ objL = (max.z - min.z) / 100;
1039
+ var triangle = new Three.Mesh(geom, new Three.MeshBasicMaterial({
1040
+ color: _constants.SHADE_DARK_PURPLE_COLOR
1041
+ }));
1042
+ var triangle1 = new Three.Mesh(geom, new Three.MeshBasicMaterial({
1043
+ color: _constants.SHADE_DARK_PURPLE_COLOR
1044
+ }));
1045
+ triangle.position.set((index < 2 ? 0 : Math.sin((index === 2 ? 1 : -1) * Math.PI / 2)) * (obj.geometry.attributes.position.array[0] + h / 4 + (index % 2 === 0 ? 0 : objW)), newVec.y, (index < 2 ? Math.cos(index * Math.PI) : 0) * (obj.geometry.attributes.position.array[2] + h / 4 + (index % 2 === 0 ? 0 : objL)));
1046
+ triangle1.position.set(newVec.x - (index < 2 ? 0 : Math.sin((index === 2 ? 1 : -1) * Math.PI / 2)) * h / 4, newVec.y, newVec.z - (index < 2 ? Math.cos(index * Math.PI) : 0) * h / 4);
1047
+ if (index < 2) {
1048
+ triangle.rotation.x = Math.cos(index * Math.PI) * Math.PI / 2;
1049
+ triangle1.rotation.x = -Math.cos(index * Math.PI) * Math.PI / 2;
1050
+ } else {
1051
+ triangle.rotation.x = -Math.PI / 2;
1052
+ triangle.rotation.z = -(index === 2 ? 1 : -1) * Math.PI / 2;
1053
+ triangle1.rotation.x = Math.PI / 2;
1054
+ triangle1.rotation.z = (index === 2 ? 1 : -1) * Math.PI / 2;
1055
+ }
1056
+ triangle.name = 'lineText';
1057
+ triangle1.name = 'lineText';
1058
+ triangle.renderOrder = 2;
1059
+ triangle1.renderOrder = 2;
1060
+ triangle.material.transparent = true;
1061
+ triangle1.material.transparent = true;
1062
+ triangle.material.depthTest = false;
1063
+ triangle1.material.depthTest = false;
1064
+ obj.add(triangle);
1065
+ obj.add(triangle1);
1066
+ }
1067
+ }
1068
+
1069
+ // if (obj.userData.distance <= 50 && obj.userData.distance >= 0.5) {
1070
+ var real_target = obj.userData.target;
1071
+ for (; ((_real_target = real_target) === null || _real_target === void 0 ? void 0 : _real_target.name) != 'pivot';) {
1072
+ var _real_target, _real_target2, _real_target3;
1073
+ if (((_real_target2 = real_target) === null || _real_target2 === void 0 ? void 0 : _real_target2.parent) == null) break;
1074
+ real_target = (_real_target3 = real_target) === null || _real_target3 === void 0 ? void 0 : _real_target3.parent;
1075
+ }
1076
+ // let item3D = obj.parent.parent.parent;
1077
+ // let origin = obj.geometry.vertices[0].clone().applyMatrix4(obj.matrixWorld);
1078
+ // let target = obj.geometry.vertices[1].clone().applyMatrix4(obj.matrixWorld);
1079
+ // let uVec = new Three.Vector3(target.x - origin.x - 0.2, target.y - origin.y - 0.2, target.z - origin.z - 0.2);
1080
+ obj.visible = true;
1081
+ if (dist < 3) obj.visible = false;
1082
+ return obj;
1083
+ }
1084
+ function getLineDistance(obj, layer, isCalcWall, index) {
1085
+ if (obj === undefined) return;
1086
+ var positionAttribute = obj.geometry.attributes.position;
1087
+ if (positionAttribute === undefined) return;
1088
+ var wPoint0 = new Three.Vector3().fromBufferAttribute(positionAttribute, 0).applyMatrix4(obj.matrixWorld);
1089
+ var wPoint1 = new Three.Vector3().fromBufferAttribute(positionAttribute, 1).applyMatrix4(obj.matrixWorld);
1090
+ var raycaster = new Three.Raycaster(wPoint0, new Three.Vector3(wPoint1.x - wPoint0.x, wPoint1.y - wPoint0.y, wPoint1.z - wPoint0.z));
1091
+ var rayDirection = raycaster.ray.direction;
1092
+ raycaster.camera = new Three.Camera();
1093
+ rayDirection.normalize();
1094
+ var meshes = [];
1095
+ planData.plan.traverse(function (child) {
1096
+ if (child.isMesh && child.geometry) {
1097
+ meshes.push(child);
1098
+ }
1099
+ });
1100
+ var intersects = raycaster.intersectObjects(meshes, true);
1101
+ var lx = wPoint0.x - wPoint1.x;
1102
+ var ly = wPoint0.y - wPoint1.y;
1103
+ var lz = wPoint0.z - wPoint1.z;
1104
+ var length = Math.sqrt(lx * lx + ly * ly + lz * lz);
1105
+ var scale = 1;
1106
+ var extrudeSettings = {
1107
+ steps: 2,
1108
+ depth: 0.01,
1109
+ bevelEnabled: false
1110
+ };
1111
+ var w = 0.2;
1112
+ var h = w * (Math.sqrt(3) / 2);
1113
+ var shape = new Three.Shape();
1114
+ shape.moveTo(0, 0);
1115
+ shape.lineTo(-w / 4, h / 2);
1116
+ shape.lineTo(w / 4, h / 2);
1117
+ var geom = new Three.ExtrudeGeometry(shape, extrudeSettings);
1118
+ geom.center();
1119
+ if (!isCalcWall) {
1120
+ for (var i = 0; i < intersects.length; i++) {
1121
+ if (intersects[i].object.name != 'TransformBox' && !intersects[i].object.name.includes('WarningBox') && intersects[i].object.type != 'Line' && intersects[i].object.name != 'rotate' && intersects[i].object.name != 'lineText' && intersects[i].object.type != 'BoxHelper' && !intersects[i].object.name.includes('molding') && intersects[i].object.name != 'soul') {
1122
+ scale = intersects[i].distance / length;
1123
+ if (intersects[i].distance <= 0.1) {
1124
+ scale = 0.1 / length;
1125
+ }
1126
+ obj.userData.distance = intersects[i].distance;
1127
+ obj.userData.target = intersects[i].object;
1128
+ var originPoint = obj.geometry.attributes.position.array.slice(0, 3);
1129
+ var _lx = obj.geometry.attributes.position.array[3] - obj.geometry.attributes.position.array[0];
1130
+ var _ly = obj.geometry.attributes.position.array[4] - obj.geometry.attributes.position.array[1];
1131
+ var _lz = obj.geometry.attributes.position.array[5] - obj.geometry.attributes.position.array[2];
1132
+ var newVec = new Three.Vector3(originPoint[0] + _lx * scale, originPoint[1] + _ly * scale, originPoint[2] + _lz * scale);
1133
+ obj.geometry.attributes.position.array[3] = newVec.x;
1134
+ obj.geometry.attributes.position.array[4] = newVec.y;
1135
+ obj.geometry.attributes.position.array[5] = newVec.z;
1136
+ obj.geometry.attributes.position.needsUpdate = true;
1137
+ obj.geometry.computeBoundingSphere();
1138
+ obj.geometry.computeBoundingBox();
1139
+ var dist = (0, _convertUnitsLite.convert)(intersects[i].distance).from('cm').to('in');
1140
+ if (dist > 3) {
1141
+ var _canvas2 = getDistanceCanvas(dist, layer);
1142
+ var wid = _canvas2.width / window.innerWidth * 30;
1143
+ var hei = _canvas2.height / window.innerHeight * 30;
1144
+ var texture = new Three.Texture(_canvas2);
1145
+ texture.minFilter = Three.LinearFilter;
1146
+ texture.needsUpdate = true;
1147
+ var geometry = new Three.PlaneGeometry(wid / 5, hei / 5);
1148
+ geometry.computeBoundingBox();
1149
+ var material = new Three.MeshBasicMaterial({
1150
+ map: texture,
1151
+ side: Three.DoubleSide
1152
+ });
1153
+ var textMesh = new Three.Mesh(geometry, material);
1154
+ for (; obj.children.length != 0;) {
1155
+ var temp = obj.children.pop();
1156
+ (0, _threeMemoryCleaner.disposeObject)(temp);
1157
+ }
1158
+ textMesh.rotation.set(Math.PI / 2, Math.PI, 0);
1159
+ // obj.add(textMesh);
1160
+ textMesh.position.set((obj.geometry.attributes.position.array[0] + obj.geometry.attributes.position.array[3]) / 2, 0.01, (obj.geometry.attributes.position.array[2] + obj.geometry.attributes.position.array[5]) / 2);
1161
+ textMesh.name = 'lineText';
1162
+ textMesh.renderOrder = 2;
1163
+ textMesh.material.depthTest = false;
1164
+ textMesh.material.transparent = true;
1165
+ var sprite1 = new Three.Sprite(new Three.SpriteMaterial({
1166
+ map: texture
1167
+ }));
1168
+ sprite1.position.set((obj.geometry.attributes.position.array[0] + obj.geometry.attributes.position.array[3]) / 2, 0.01, (obj.geometry.attributes.position.array[2] + obj.geometry.attributes.position.array[5]) / 2);
1169
+ sprite1.name = 'lineText';
1170
+ sprite1.renderOrder = 2;
1171
+ sprite1.scale.set(0.2, 0.1, 0.2);
1172
+ sprite1.layers.set(1);
1173
+ sprite1.material.depthTest = false;
1174
+ obj.add(sprite1);
1175
+ if (obj.parent != null) {
1176
+ // is not lighting
1177
+ var item3D = obj.parent.parent.parent;
1178
+ var max = item3D.children[0].userData.max;
1179
+ var min = item3D.children[0].userData.min;
1180
+ var objW = (max.x - min.x) / 100,
1181
+ objL = (max.z - min.z) / 100;
1182
+ var triangle = new Three.Mesh(geom, new Three.MeshBasicMaterial({
1183
+ color: _constants.SHADE_DARK_PURPLE_COLOR
1184
+ }));
1185
+ var triangle1 = new Three.Mesh(geom, new Three.MeshBasicMaterial({
1186
+ color: _constants.SHADE_DARK_PURPLE_COLOR
1187
+ }));
1188
+ triangle.position.set((index < 2 ? 0 : Math.sin((index === 2 ? 1 : -1) * Math.PI / 2)) * (obj.geometry.attributes.position.array[0] + h / 4 + (index % 2 === 0 ? 0 : objW)), newVec.y, (index < 2 ? Math.cos(index * Math.PI) : 0) * (obj.geometry.attributes.position.array[2] + h / 4 + (index % 2 === 0 ? 0 : objL)));
1189
+ triangle1.position.set(newVec.x - (index < 2 ? 0 : Math.sin((index === 2 ? 1 : -1) * Math.PI / 2)) * h / 4, newVec.y, newVec.z - (index < 2 ? Math.cos(index * Math.PI) : 0) * h / 4);
1190
+ if (index < 2) {
1191
+ triangle.rotation.x = Math.cos(index * Math.PI) * Math.PI / 2;
1192
+ triangle1.rotation.x = -Math.cos(index * Math.PI) * Math.PI / 2;
1193
+ } else {
1194
+ triangle.rotation.x = -Math.PI / 2;
1195
+ triangle.rotation.z = -(index === 2 ? 1 : -1) * Math.PI / 2;
1196
+ triangle1.rotation.x = Math.PI / 2;
1197
+ triangle1.rotation.z = (index === 2 ? 1 : -1) * Math.PI / 2;
1198
+ }
1199
+ triangle.name = 'lineText';
1200
+ triangle1.name = 'lineText';
1201
+ triangle.renderOrder = 2;
1202
+ triangle1.renderOrder = 2;
1203
+ triangle.material.transparent = true;
1204
+ triangle1.material.transparent = true;
1205
+ triangle.material.depthTest = false;
1206
+ triangle1.material.depthTest = false;
1207
+ obj.add(triangle);
1208
+ obj.add(triangle1);
1209
+ }
1210
+ }
1211
+
1212
+ // if (obj.userData.distance <= 50 && obj.userData.distance >= 0.5) {
1213
+ var real_target = obj.userData.target;
1214
+ for (; real_target.name != 'pivot';) {
1215
+ if (real_target.parent == null) break;
1216
+ real_target = real_target.parent;
1217
+ }
1218
+ // let item3D = obj.parent.parent.parent;
1219
+ // let origin = obj.geometry.vertices[0].clone().applyMatrix4(obj.matrixWorld);
1220
+ // let target = obj.geometry.vertices[1].clone().applyMatrix4(obj.matrixWorld);
1221
+ // let uVec = new Three.Vector3(target.x - origin.x - 0.2, target.y - origin.y - 0.2, target.z - origin.z - 0.2);
1222
+ obj.visible = true;
1223
+ if (dist < 3) obj.visible = false;
1224
+ return obj;
1225
+ }
1226
+ }
1227
+ }
1228
+ var tX = wPoint0.x - planData.plan.position.x;
1229
+ var tZ = wPoint0.z - planData.plan.position.z;
1230
+ tZ = -tZ;
1231
+ var tX1 = wPoint1.x - planData.plan.position.x;
1232
+ var tZ1 = wPoint1.z - planData.plan.position.z;
1233
+ tZ1 = -tZ1;
1234
+ if (!layer) return;
1235
+ layer.lines.forEach(function (data) {
1236
+ var px = [];
1237
+ var py = [];
1238
+ var opX = [tX, tX1];
1239
+ var opY = [tZ, tZ1];
1240
+ data.vertices.forEach(function (vec) {
1241
+ var vertices = layer.vertices.get(vec);
1242
+ px.push(vertices.x);
1243
+ py.push(vertices.y);
1244
+ });
1245
+ var distance = getIntersectPoint(opX, opY, px, py);
1246
+ if (distance != null) {
1247
+ obj.userData.distance = distance;
1248
+ obj.userData.target = planData.sceneGraph.layers[layer.id].lines[data.get('id')];
1249
+ scale = distance / length;
1250
+ if (distance <= 0.1) {
1251
+ scale = 0.1 / length;
1252
+ }
1253
+ var _originPoint = obj.geometry.attributes.position.array.slice(0, 3);
1254
+ lx = obj.geometry.attributes.position.array[3] - obj.geometry.attributes.position.array[0];
1255
+ ly = obj.geometry.attributes.position.array[4] - obj.geometry.attributes.position.array[1];
1256
+ lz = obj.geometry.attributes.position.array[5] - obj.geometry.attributes.position.array[2];
1257
+ var _newVec = new Three.Vector3(_originPoint.x + lx * scale, _originPoint.y + ly * scale, _originPoint.z + lz * scale);
1258
+ obj.geometry.attributes.position.array[3] = _newVec.x;
1259
+ obj.geometry.attributes.position.array[4] = _newVec.y;
1260
+ obj.geometry.attributes.position.array[5] = _newVec.z;
1261
+ obj.geometry.attributes.position.needsUpdate = true;
1262
+ var _dist = (0, _convertUnitsLite.convert)((0, _math.formatNumber)(distance, _constants.DECIMAL_PLACES_2)).from('cm').to('in');
1263
+ if (_dist > 3) {
1264
+ var _canvas3 = getDistanceCanvas(_dist, layer);
1265
+ var _wid = _canvas3.width / window.innerWidth * 30;
1266
+ var _hei = _canvas3.height / window.innerHeight * 30;
1267
+ var _texture = new Three.Texture(_canvas3);
1268
+ _texture.needsUpdate = true;
1269
+ var _geometry = new Three.PlaneGeometry(_wid / 2, _hei / 2);
1270
+ _geometry.computeBoundingBox();
1271
+ var _material = new Three.MeshBasicMaterial({
1272
+ map: _texture,
1273
+ side: Three.DoubleSide
1274
+ });
1275
+ var _textMesh = new Three.Mesh(_geometry, _material);
1276
+ for (; obj.children.length != 0;) {
1277
+ var _temp = obj.children.pop();
1278
+ (0, _threeMemoryCleaner.disposeObject)(_temp);
1279
+ }
1280
+ _textMesh.rotation.set(Math.PI / 2, Math.PI, 0);
1281
+ // obj.add(textMesh);
1282
+ _textMesh.position.set((obj.geometry.attributes.position.array[0] + obj.geometry.attributes.position.array[3]) / 2, 0.01, (obj.geometry.attributes.position.array[2] + obj.geometry.attributes.position.array[5]) / 2);
1283
+ _textMesh.name = 'lineText';
1284
+ _textMesh.renderOrder = 2;
1285
+ _textMesh.material.depthTest = false;
1286
+ _textMesh.material.transparent = true;
1287
+ var _sprite = new Three.Sprite(new Three.SpriteMaterial({
1288
+ map: _texture
1289
+ }));
1290
+ _sprite.position.set((obj.geometry.attributes.position.array[0] + obj.geometry.attributes.position.array[3]) / 2, 0.01, (obj.geometry.attributes.position.array[2] + obj.geometry.attributes.position.array[5]) / 2);
1291
+ _sprite.name = 'lineText';
1292
+ _sprite.scale.set(0.2, 0.1, 0.2);
1293
+ _sprite.layers.set(1);
1294
+ obj.add(_sprite);
1295
+ var _item3D = obj.parent.parent.parent;
1296
+ var _max = _item3D.children[0].userData.max;
1297
+ var _min = _item3D.children[0].userData.min;
1298
+ var _objW = (_max.x - _min.x) / 100,
1299
+ _objL = (_max.z - _min.z) / 100;
1300
+ var triangle = new Three.Mesh(geom, new Three.MeshBasicMaterial({
1301
+ color: _constants.SHADE_DARK_PURPLE_COLOR
1302
+ }));
1303
+ var triangle1 = new Three.Mesh(geom, new Three.MeshBasicMaterial({
1304
+ color: _constants.SHADE_DARK_PURPLE_COLOR
1305
+ }));
1306
+ triangle.position.set((index < 2 ? 0 : Math.sin((index === 2 ? 1 : -1) * Math.PI / 2)) * (obj.geometry.attributes.position.array[0] + h / 4 + (index % 2 === 0 ? 0 : _objW)), _newVec.y, (index < 2 ? Math.cos(index * Math.PI) : 0) * (obj.geometry.attributes.position.array[2] + h / 4 + (index % 2 === 0 ? 0 : _objL)) - 0.02);
1307
+ triangle1.position.set(_newVec.x - (index < 2 ? 0 : Math.sin((index === 2 ? 1 : -1) * Math.PI / 2)) * h / 4, _newVec.y, _newVec.z - (index < 2 ? Math.cos(index * Math.PI) : 0) * h / 4);
1308
+ if (index < 2) {
1309
+ triangle.rotation.x = Math.cos(index * Math.PI) * Math.PI / 2;
1310
+ triangle1.rotation.x = -Math.cos(index * Math.PI) * Math.PI / 2;
1311
+ } else {
1312
+ triangle.rotation.x = -Math.PI / 2;
1313
+ triangle.rotation.z = -(index === 2 ? 1 : -1) * Math.PI / 2;
1314
+ triangle1.rotation.x = Math.PI / 2;
1315
+ triangle1.rotation.z = (index === 2 ? 1 : -1) * Math.PI / 2;
1316
+ }
1317
+ triangle.name = 'lineText';
1318
+ triangle1.name = 'lineText';
1319
+ triangle.renderOrder = 2;
1320
+ triangle1.renderOrder = 2;
1321
+ triangle.material.transparent = true;
1322
+ triangle1.material.transparent = true;
1323
+ triangle.material.depthTest = false;
1324
+ triangle1.material.depthTest = false;
1325
+ obj.add(triangle);
1326
+ obj.add(triangle1);
1327
+ }
1328
+ // if (obj.userData.distance <= 50 && obj.userData.distance >= 0.5) {
1329
+ // let item3D = obj.parent.parent.parent;
1330
+ // let pos = item3D.position.clone();
1331
+ // let origin = obj.geometry.vertices[0].clone().applyMatrix4(obj.matrixWorld);
1332
+ // let target = obj.geometry.vertices[1].clone().applyMatrix4(obj.matrixWorld);
1333
+ // let uVec = new Three.Vector3(target.x - origin.x - 0.2, target.y - origin.y - 0.2, target.z - origin.z - 0.2);
1334
+ obj.visible = true;
1335
+ if (_dist > 3) obj.visible = false;
1336
+ return obj;
1337
+ // itemsActions.updateDraggingItemChanged(pos.x - uVec.x, -pos.z + uVec.z);
1338
+ // }
1339
+ }
1340
+ });
1341
+ obj.visible = false;
1342
+ return obj;
1343
+ }
1344
+ function getIntersectPoint(opX, opY, pX, pY) {
1345
+ var oA;
1346
+ if (opX[1] == opX[0]) oA = null;else oA = (opY[1] - opY[0]) / (opX[1] - opX[0]);
1347
+ var A;
1348
+ if (pX[1] == pX[0]) A = null;else A = (pY[1] - pY[0]) / (pX[1] - pX[0]);
1349
+ if (oA == A) return null;
1350
+ if (oA != null && A != null) {
1351
+ var oB = opY[0] - oA * opX[0];
1352
+ var B = pY[0] - A * pX[0];
1353
+ var iX = (B - oB) / (oA - A);
1354
+ if (pX[0] <= iX && iX <= pX[1] || pX[0] >= iX && iX >= pX[1]) {
1355
+ if (opX[0] <= opX[1] && opX[0] <= iX || opX[0] >= opX[1] && opX[0] >= iX) {
1356
+ var iY = pY[0] + A * (iX - pX[0]);
1357
+ var distance = Math.sqrt((opX[0] - iX) * (opX[0] - iX) + (opY[0] - iY) * (opY[0] - iY));
1358
+ return distance;
1359
+ }
1360
+ return null;
1361
+ }
1362
+ }
1363
+ if (oA == null) {
1364
+ var _iX = opX[0];
1365
+ if (A != null) {
1366
+ if (pX[0] <= _iX && _iX <= pX[1] || pX[0] >= _iX && _iX >= pX[1]) {
1367
+ var _iY = pY[0] + A * (_iX - pX[0]);
1368
+ if (opY[0] <= _iY && opY[0] <= opY[1] || opY[0] >= _iY && opY[0] >= opY[1]) {
1369
+ var _distance = Math.sqrt((opX[0] - _iX) * (opX[0] - _iX) + (opY[0] - _iY) * (opY[0] - _iY));
1370
+ return _distance;
1371
+ }
1372
+ }
1373
+ }
1374
+ }
1375
+ if (A == null) {
1376
+ var _iX2 = pX[0];
1377
+ if (oA != null) {
1378
+ var _iY2 = _iX2 * oA + opY[0] - oA * opX[0];
1379
+ if (pY[0] <= _iY2 && _iY2 <= pY[1] || pY[0] >= _iY2 && _iY2 >= pY[1]) {
1380
+ if (opY[0] <= _iY2 && opY[0] <= opY[1] || opY[0] >= _iY2 && opY[0] >= opY[1]) {
1381
+ var _distance2 = Math.sqrt((opX[0] - _iX2) * (opX[0] - _iX2) + (opY[0] - _iY2) * (opY[0] - _iY2));
1382
+ return _distance2;
1383
+ }
1384
+ }
1385
+ }
1386
+ }
1387
+ return null;
1388
+ }
1389
+ function gcd(a, b) {
1390
+ return a % b ? gcd(b, a % b) : b;
1391
+ }
1392
+ function getDistanceCanvas(distance, layer) {
1393
+ var _layer$unit;
1394
+ var parameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1395
+ var canvas = document.createElement('canvas');
1396
+ var ctx = canvas.getContext('2d');
1397
+ var curUnit = (_layer$unit = layer === null || layer === void 0 ? void 0 : layer.unit) !== null && _layer$unit !== void 0 ? _layer$unit : _constants.UNIT_INCH;
1398
+ var fixedLength = (layer === null || layer === void 0 ? void 0 : layer.unit) === _constants.UNIT_METER || (layer === null || layer === void 0 ? void 0 : layer.unit) === _constants.UNIT_FOOT ? 2 : 0;
1399
+ var distText = String((Math.round((0, _convertUnitsLite.convert)(distance).from('in').to(curUnit) * 100) / 100).toFixed(fixedLength));
1400
+ var fontSize = 16;
1401
+ var integral = distText + curUnit;
1402
+ // let integral = String(distance) + "''";
1403
+
1404
+ parameters.fontName = parameters.fontName || _constants.ARROW_TEXT_FONTFACE;
1405
+
1406
+ // Prepare the font to be able to measure
1407
+ ctx.font = "".concat(fontSize, "px ") + parameters.fontName;
1408
+ if (parameters.italic) {
1409
+ ctx.font = "italic ".concat(fontSize, "px ") + parameters.fontName;
1410
+ }
1411
+ if (parameters.bold) {
1412
+ ctx.font = "bold ".concat(fontSize, "px ") + parameters.fontName;
1413
+ }
1414
+ if (parameters.bold && parameters.italic) {
1415
+ ctx.font = "italic bold ".concat(fontSize, "px ") + parameters.fontName;
1416
+ }
1417
+ var textMetrics = ctx.measureText(integral);
1418
+ var width = 70;
1419
+ var height = fontSize + 20;
1420
+
1421
+ // Resize canvas to match text size
1422
+ canvas.width = width;
1423
+ canvas.height = height;
1424
+ canvas.style.width = width + 'px';
1425
+ canvas.style.height = height + 'px';
1426
+
1427
+ // Re-apply font since canvas is resized.
1428
+ ctx.font = "".concat(fontSize, "px ") + parameters.fontName;
1429
+ if (parameters.italic) {
1430
+ ctx.font = "italic ".concat(fontSize, "px ") + parameters.fontName;
1431
+ }
1432
+ if (parameters.bold) {
1433
+ ctx.font = "bold ".concat(fontSize, "px ") + parameters.fontName;
1434
+ }
1435
+ if (parameters.bold && parameters.italic) {
1436
+ ctx.font = "italic bold ".concat(fontSize, "px ") + parameters.fontName;
1437
+ }
1438
+ //ctx.textAlign = parameters.align || "center";
1439
+ ctx.textBaseline = parameters.baseline || 'middle';
1440
+ var r = 10;
1441
+ // Make the canvas transparent for simplicity
1442
+ ctx.fillStyle = _constants.ARROW_TEXT_BACKCOLOR;
1443
+ // ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
1444
+ var w = ctx.canvas.width;
1445
+ var h = ctx.canvas.height;
1446
+ ctx.beginPath();
1447
+ ctx.moveTo(r, 0);
1448
+ ctx.lineTo(w - r, 0);
1449
+ ctx.arcTo(w, 0, w, r, r);
1450
+ ctx.lineTo(w, h - r);
1451
+ ctx.arcTo(w, h, w - r, h, r);
1452
+ ctx.lineTo(r, h);
1453
+ ctx.arcTo(0, h, 0, h - r, r);
1454
+ ctx.lineTo(0, r);
1455
+ ctx.arcTo(0, 0, r, 0, r);
1456
+ // ctx.arcTo(w+r, h+2*r, w+r, 0, r);
1457
+ ctx.fill();
1458
+ ctx.fillStyle = parameters.fillColor || _constants.ARROW_TEXT_FORECOLOR;
1459
+ ctx.fillText(integral, (width - textMetrics.width) / 2, height / 2);
1460
+ ctx.strokeStyle = parameters.strokeColor || _constants.ARROW_TEXT_FORECOLOR;
1461
+ ctx.strokeText(integral, (width - textMetrics.width) / 2, height / 2);
1462
+
1463
+ // ctx.font = `${fontSize - 5}px ` + parameters.fontName;
1464
+ // const denoMetrics = ctx.measureText(deno);
1465
+ // const numoMetrics = ctx.measureText(numo);
1466
+ // ctx.fillStyle = ARROW_TEXT_FORECOLOR;
1467
+ // ctx.fillRect(
1468
+ // ctx.canvas.width / 2 + 3,
1469
+ // ctx.canvas.height / 2 - 2,
1470
+ // denoMetrics.width,
1471
+ // 1
1472
+ // );
1473
+
1474
+ // const denoMetrics = ctx.measureText(deno);
1475
+ // ctx.fillStyle = ARROW_TEXT_FORECOLOR;
1476
+ // ctx.fillRect(
1477
+ // ctx.canvas.width / 2 + 3,
1478
+ // ctx.canvas.height / 2 - 2,
1479
+ // denoMetrics.width,
1480
+ // 1
1481
+ // );
1482
+
1483
+ // ctx.fillStyle = parameters.fillColor || ARROW_TEXT_FORECOLOR;
1484
+ // ctx.fillText(
1485
+ // numo,
1486
+ // ctx.canvas.width / 2 + 3 + (denoMetrics.width - numoMetrics.width) / 2,
1487
+ // height / 2 - 8
1488
+ // );
1489
+ // ctx.font = `${fontSize}px ` + parameters.fontName;
1490
+ // ctx.fillText(
1491
+ // "''",
1492
+ // ctx.canvas.width / 2 + 4 + denoMetrics.width,
1493
+ // height / 2 - 7
1494
+ // );
1495
+ // ctx.font = `${fontSize - 5}px ` + parameters.fontName;
1496
+
1497
+ // ctx.strokeStyle = parameters.strokeColor || ARROW_TEXT_FORECOLOR;
1498
+ // ctx.strokeText(
1499
+ // numo,
1500
+ // ctx.canvas.width / 2 + 3 + (denoMetrics.width - numoMetrics.width) / 2,
1501
+ // height / 2 - 8
1502
+ // );
1503
+
1504
+ // ctx.fillStyle = parameters.fillColor || ARROW_TEXT_FORECOLOR;
1505
+ // ctx.fillText(deno, ctx.canvas.width / 2 + 3, height / 2 + 8);
1506
+ // ctx.strokeStyle = parameters.strokeColor || ARROW_TEXT_FORECOLOR;
1507
+ // ctx.strokeText(deno, ctx.canvas.width / 2 + 3, height / 2 + 8);
1508
+ return canvas;
1509
+ }
1510
+ function removeObject(modifiedPath, layer, planData, actions, sceneData, oldSceneData, catalog) {
1511
+ var promises = [];
1512
+ switch (modifiedPath[3]) {
1513
+ case 'lines':
1514
+ // Here I remove the line with all its holes
1515
+ var lineID = modifiedPath[4];
1516
+ oldSceneData.getIn(['layers', layer.id, 'lines', lineID, 'holes']).forEach(function (holeID) {
1517
+ removeHole(planData, layer.id, holeID);
1518
+ });
1519
+ removeLine(planData, layer.id, lineID);
1520
+ var mode = oldSceneData.mode;
1521
+ if (_constants.ARRAY_3D_MODES.includes(mode)) mode = _constants.MODE_IDLE_3D;else mode = _constants.MODE_IDLE;
1522
+ if (modifiedPath.length > 5) {
1523
+ // I removed an hole, so I should add the new line
1524
+ promises.push(addLine(sceneData, planData, layer, lineID, catalog, actions.linesActions));
1525
+ layer.getIn(['lines', lineID, 'holes']).forEach(function (holeID) {
1526
+ promises.push(addHole(sceneData, planData, layer, holeID, catalog, actions.holesActions, mode));
1527
+ });
1528
+ }
1529
+ break;
1530
+ case 'areas':
1531
+ if (modifiedPath.length === 5) {
1532
+ // I am removing an entire area
1533
+ removeArea(planData, layer.id, modifiedPath[4]);
1534
+ }
1535
+ break;
1536
+ case 'items':
1537
+ if (modifiedPath.length === 5) {
1538
+ // I am removing an item
1539
+ removeItem(planData, layer.id, modifiedPath[4], oldSceneData.getIn(['layers', layer.id]), layer);
1540
+ }
1541
+ break;
1542
+ }
1543
+ Promise.all(promises).then(function (values) {
1544
+ return updateBoundingBox(planData);
1545
+ });
1546
+ }
1547
+ function removeLayer(layerId, planData) {
1548
+ var layerGraph = planData.sceneGraph.layers[layerId];
1549
+ for (var lineID in layerGraph.lines) removeLine(planData, layerId, lineID);
1550
+ for (var areaID in layerGraph.areas) removeArea(planData, layerId, areaID);
1551
+ for (var itemID in layerGraph.items) removeItem(planData, layerId, itemID);
1552
+ for (var holeID in layerGraph.holes) removeHole(planData, layerId, holeID);
1553
+ delete planData.sceneGraph.layers[layerId];
1554
+ }
1555
+ function removeHole(planData, layerId, holeID) {
1556
+ if (planData.sceneGraph.busyResources.layers[layerId].holes[holeID]) {
1557
+ setTimeout(function () {
1558
+ return removeHole(planData, layerId, holeID);
1559
+ }, 100);
1560
+ return;
1561
+ }
1562
+ planData.sceneGraph.busyResources.layers[layerId].holes[holeID] = true;
1563
+ var hole3D = planData.sceneGraph.layers[layerId].holes[holeID];
1564
+ if (hole3D) {
1565
+ planData.plan.remove(hole3D);
1566
+ (0, _threeMemoryCleaner.disposeObject)(hole3D);
1567
+ delete planData.sceneGraph.layers[layerId].holes[holeID];
1568
+ delete planData.sceneGraph.LODs[holeID];
1569
+ hole3D = null;
1570
+ updateBoundingBox(planData, true);
1571
+ }
1572
+ planData.sceneGraph.busyResources.layers[layerId].holes[holeID] = false;
1573
+ }
1574
+ function removeLine(planData, layerId, lineID) {
1575
+ if (planData.sceneGraph.busyResources.layers[layerId].lines[lineID]) {
1576
+ setTimeout(function () {
1577
+ return removeLine(planData, layerId, lineID);
1578
+ }, 100);
1579
+ return;
1580
+ }
1581
+ planData.sceneGraph.busyResources.layers[layerId].lines[lineID] = true;
1582
+ var line3D = planData.sceneGraph.layers[layerId].lines[lineID];
1583
+ if (line3D) {
1584
+ planData.plan.remove(line3D);
1585
+ (0, _threeMemoryCleaner.disposeObject)(line3D);
1586
+ delete planData.sceneGraph.layers[layerId].lines[lineID];
1587
+ delete planData.sceneGraph.LODs[lineID];
1588
+ line3D = null;
1589
+ updateBoundingBox(planData, true);
1590
+ }
1591
+ planData.sceneGraph.busyResources.layers[layerId].lines[lineID] = false;
1592
+ }
1593
+ function removeArea(planData, layerId, areaID) {
1594
+ if (planData.sceneGraph.busyResources.layers[layerId].areas[areaID]) {
1595
+ setTimeout(function () {
1596
+ return removeArea(planData, layerId, areaID);
1597
+ }, 100);
1598
+ return;
1599
+ }
1600
+ planData.sceneGraph.busyResources.layers[layerId].areas[areaID] = true;
1601
+ var area3D = planData.sceneGraph.layers[layerId].areas[areaID];
1602
+ if (area3D) {
1603
+ planData.plan.remove(area3D);
1604
+ (0, _threeMemoryCleaner.disposeObject)(area3D);
1605
+ delete planData.sceneGraph.layers[layerId].areas[areaID];
1606
+ delete planData.sceneGraph.LODs[areaID];
1607
+ area3D = null;
1608
+ updateBoundingBox(planData, true);
1609
+ }
1610
+ planData.sceneGraph.busyResources.layers[layerId].areas[areaID] = false;
1611
+ }
1612
+ function removeItem(planData, layerId, itemID) {
1613
+ var oldSceneLayer = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
1614
+ var newSceneLayer = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
1615
+ if (planData.sceneGraph.busyResources.layers[layerId].items[itemID]) {
1616
+ setTimeout(function () {
1617
+ return removeItem(planData, layerId, itemID, oldSceneLayer, newSceneLayer);
1618
+ }, 100);
1619
+ return;
1620
+ }
1621
+ planData.sceneGraph.busyResources.layers[layerId].items[itemID] = true;
1622
+
1623
+ // The layer variable is layer that contains the deleted item.
1624
+ var layer = oldSceneLayer ? oldSceneLayer : planData.sceneData.getIn(['layers', layerId]);
1625
+ var item = layer.getIn(['items', itemID]); // deleted item.
1626
+ deleteCountertop(planData.sceneGraph.layers[layerId].countertops, item, planData, layer);
1627
+ planData.sceneGraph.layers[layerId].moldingGroups = deleteAllMolding(planData.sceneGraph.layers[layerId].moldingGroups, item, planData, layer, newSceneLayer);
1628
+ var item3D = planData.sceneGraph.layers[layerId].items[itemID];
1629
+ if (item3D) {
1630
+ planData.plan.remove(item3D);
1631
+ (0, _threeMemoryCleaner.disposeObject)(item3D);
1632
+ delete planData.sceneGraph.layers[layerId].items[itemID];
1633
+ delete planData.sceneGraph.LODs[itemID];
1634
+ item3D = null;
1635
+ updateBoundingBox(planData, true);
1636
+ }
1637
+ planData.sceneGraph.busyResources.layers[layerId].items[itemID] = false;
1638
+ }
1639
+ function removeItemWithoutItem(planData, layerId, itemID) {
1640
+ if (planData.sceneGraph.busyResources.layers[layerId].items[itemID]) {
1641
+ setTimeout(function () {
1642
+ return removeItemWithoutItem(planData, layerId, itemID);
1643
+ }, 100);
1644
+ return;
1645
+ }
1646
+ planData.sceneGraph.busyResources.layers[layerId].items[itemID] = true;
1647
+ var layer = planData.sceneData.getIn(['layers', layerId]);
1648
+ var item = layer.getIn(['items', itemID]);
1649
+ deleteCountertop(planData.sceneGraph.layers[layerId].countertops, item, planData, layer);
1650
+ var item3D = planData.sceneGraph.layers[layerId].items[itemID];
1651
+ if (item3D) {
1652
+ planData.plan.remove(item3D);
1653
+ (0, _threeMemoryCleaner.disposeObject)(item3D);
1654
+ item3D = null;
1655
+ updateBoundingBox(planData);
1656
+ delete planData.sceneGraph.layers[layerId].items[itemID];
1657
+ delete planData.sceneGraph.LODs[itemID];
1658
+ }
1659
+ planData.sceneGraph.busyResources.layers[layerId].items[itemID] = false;
1660
+ }
1661
+
1662
+ //TODO generate an area's replace if vertex has been changed
1663
+ function addObject(modifiedPath, layer, planData, actions, sceneData, oldSceneData, catalog, mode, toolObj) {
1664
+ if (modifiedPath.length >= 5) {
1665
+ var addPromise = null,
1666
+ addAction = null;
1667
+ switch (modifiedPath[3]) {
1668
+ case 'lines':
1669
+ if (modifiedPath[5] === 'holes' && scene_mode !== 'MODE_DRAWING_HOLE_3D' && scene_mode !== 'MODE_DRAGGING_HOLE_3D') {
1670
+ removeLine(planData, layer.id, modifiedPath[4]);
1671
+ }
1672
+ if (scene_mode !== 'MODE_DRAWING_HOLE_3D' && scene_mode !== 'MODE_DRAGGING_HOLE_3D') {
1673
+ addPromise = addLine;
1674
+ }
1675
+ addAction = actions.linesActions;
1676
+ break;
1677
+ case 'areas':
1678
+ addPromise = addArea;
1679
+ addAction = actions.areaActions;
1680
+ break;
1681
+ case 'items':
1682
+ addPromise = addItem;
1683
+ addAction = actions.itemsActions;
1684
+ break;
1685
+ case 'holes':
1686
+ addPromise = addHole;
1687
+ addAction = actions.holesActions;
1688
+ break;
1689
+ }
1690
+ if (addPromise) {
1691
+ // if( addPromise(sceneData, planData, layer, modifiedPath[4], catalog, addAction) === undefined ) {
1692
+ // return;
1693
+ // }
1694
+ addPromise(sceneData, planData, layer, modifiedPath[4], catalog, addAction, mode, toolObj).then(function () {
1695
+ return updateBoundingBox(planData);
1696
+ });
1697
+ }
1698
+ }
1699
+ }
1700
+ function addHole(sceneData, planData, layer, holeID, catalog, holesActions, mode) {
1701
+ var toolObj = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
1702
+ var holeData = layer.getIn(['holes', holeID]);
1703
+
1704
+ // Create the hole object
1705
+ return holeData === undefined ? '' : catalog.getElement(holeData.type).render3D(holeData, layer, sceneData).then(function (object) {
1706
+ if (object instanceof Three.LOD) {
1707
+ planData.sceneGraph.LODs[holeID] = object;
1708
+ }
1709
+ object.children.forEach(function (item) {
1710
+ var name = item.name;
1711
+ item.castShadow = true;
1712
+ var texture;
1713
+ if (name.includes('_wood')) {
1714
+ texture = (0, _itemLoader.loadTexture)('/assets/img/texture/white1px.jpg');
1715
+ } else if (name.includes('_glass')) {
1716
+ var material = new Three.MeshPhysicalMaterial({
1717
+ roughness: 0.5,
1718
+ transmission: 1,
1719
+ thickness: 0.5,
1720
+ // Add refraction!
1721
+ transparency: 0.6
1722
+ });
1723
+ item.material = material;
1724
+ return item;
1725
+ } else if (name.includes('_steel')) {
1726
+ texture = (0, _itemLoader.loadTexture)('/assets/img/texture/steel.jpg');
1727
+ } else if (name.includes('_glass')) {
1728
+ var _material2 = new Three.MeshPhysicalMaterial({
1729
+ roughness: 0.5,
1730
+ transmission: 1,
1731
+ thickness: 0.5,
1732
+ // Add refraction!
1733
+ transparency: 0.6
1734
+ });
1735
+ item.material = _material2;
1736
+ return item;
1737
+ }
1738
+ });
1739
+ if (holeData.selected) {
1740
+ // if object is drawing in 3d mode and selected
1741
+ if (holeData.type === 'FrameLess Doorway') {
1742
+ var x, y, z;
1743
+ x = holeData.getIn(['properties', 'width', 'length']) || 0;
1744
+ y = holeData.getIn(['properties', 'height', 'length']) || 0;
1745
+ z = holeData.getIn(['properties', 'thickness', 'length']) || 0;
1746
+ var moveBox = new Three.BoxGeometry(x, y, z);
1747
+ var mBox = new Three.Mesh(moveBox, new Three.MeshBasicMaterial({
1748
+ color: 0x99c3fb,
1749
+ side: Three.DoubleSide,
1750
+ transparent: true,
1751
+ opacity: 0.4
1752
+ }));
1753
+ mBox.name = 'FrameLessDoormBox';
1754
+ mBox.renderOrder = 1;
1755
+ if (mBox !== undefined) {
1756
+ object.add(mBox);
1757
+ }
1758
+ } else {
1759
+ var _boundingBox = GeomUtils.baseBox3FromObject(object);
1760
+ if (_boundingBox === undefined) return;
1761
+ var max = _boundingBox.max;
1762
+ if (!Number.isFinite(max.x)) return;
1763
+ var transGroup = new Three.Group();
1764
+ var extrudeSettings = {
1765
+ depth: 1,
1766
+ bevelEnabled: true,
1767
+ bevelSegments: 2,
1768
+ steps: 2,
1769
+ bevelSize: 1,
1770
+ bevelThickness: 1
1771
+ };
1772
+ var triangleShape = new Three.Shape().moveTo(max.x, 15) // A
1773
+ .lineTo(max.x + 6, 15) // B
1774
+ .lineTo(max.x + 6, 30) // C
1775
+ .lineTo(max.x + 16, 0) // D
1776
+ .lineTo(max.x + 6, -29) // E
1777
+ .lineTo(max.x + 6, -15) // F
1778
+ .lineTo(max.x, -15) // G
1779
+ .lineTo(max.x, 15); // close path
1780
+ var transHole_Right = GeomUtils.addShape(triangleShape, extrudeSettings, scene_mode !== 'MODE_DRAGGING_HOLE_3D' ? 0x000000 : 0x99c3fb, 0, 0, 0, 0, 0, 0, 1);
1781
+ transHole_Right.name = 'transHole_Right';
1782
+ transGroup.add(transHole_Right);
1783
+ triangleShape = new Three.Shape().moveTo(-max.x, 15) // A
1784
+ .lineTo(-(max.x + 6), 15) // B
1785
+ .lineTo(-(max.x + 6), 30) // C
1786
+ .lineTo(-(max.x + 16), 0) // D
1787
+ .lineTo(-(max.x + 6), -29) // E
1788
+ .lineTo(-(max.x + 6), -15) // F
1789
+ .lineTo(-max.x, -15) // G
1790
+ .lineTo(-max.x, 15); // close path
1791
+ var transHole_Left = GeomUtils.addShape(triangleShape, extrudeSettings, scene_mode !== 'MODE_DRAGGING_HOLE_3D' ? 0x000000 : 0x99c3fb, 0, 0, 0, 0, 0, 0, 1);
1792
+ transHole_Left.name = 'transHole_Left';
1793
+ transGroup.add(transHole_Left);
1794
+ transGroup.scale.set(1 / object.scale.x, 1 / object.scale.y, 1 / object.scale.z);
1795
+ object.add(transGroup);
1796
+ }
1797
+ }
1798
+ var pivot = new Three.Object3D();
1799
+ pivot.name = 'pivot';
1800
+ if ((0, _helper.isElevationView)(mode)) {
1801
+ var lineID = holeData.getIn(['line']);
1802
+ if (planData.sceneGraph.layers['layer-1'].lines[lineID].visible) {
1803
+ pivot.visible = true;
1804
+ } else {
1805
+ pivot.visible = false;
1806
+ }
1807
+ object.traverse(function (obj) {
1808
+ (0, _helper.replaceMeshesWithLineSegments)(obj);
1809
+ });
1810
+ }
1811
+ pivot.add(object);
1812
+ var line = layer.getIn(['lines', holeData.line]);
1813
+
1814
+ // First of all I need to find the vertices of this line
1815
+ var vertex0 = layer.vertices.get(line.vertices.get(0));
1816
+ var vertex1 = layer.vertices.get(line.vertices.get(1));
1817
+ var offset = holeData.offset;
1818
+ if (vertex0.x > vertex1.x) {
1819
+ var tmp = vertex0;
1820
+ vertex0 = vertex1;
1821
+ vertex1 = tmp;
1822
+ offset = 1 - offset;
1823
+ }
1824
+ var distance = Math.sqrt(Math.pow(vertex0.x - vertex1.x, 2) + Math.pow(vertex0.y - vertex1.y, 2));
1825
+ var alpha = Math.asin((vertex1.y - vertex0.y) / distance);
1826
+ var boundingBox = new Three.Box3().setFromObject(pivot);
1827
+ var center = [(boundingBox.max.x - boundingBox.min.x) / 2 + boundingBox.min.x, (boundingBox.max.y - boundingBox.min.y) / 2 + boundingBox.min.y, (boundingBox.max.z - boundingBox.min.z) / 2 + boundingBox.min.z];
1828
+ var holeAltitude = holeData.properties.getIn(['altitude', 'length']);
1829
+ var holeHeight = holeData.properties.getIn(['height', 'length']);
1830
+ pivot.rotation.y = alpha;
1831
+ pivot.position.x = vertex0.x + distance * offset * Math.cos(alpha) - center[0] * Math.cos(alpha) - center[2] * Math.sin(alpha);
1832
+ pivot.position.y = holeAltitude + holeHeight / 2 - center[1] + layer.altitude;
1833
+ pivot.position.z = -vertex0.y - distance * offset * Math.sin(alpha) - center[2] * Math.cos(alpha) + center[0] * Math.sin(alpha);
1834
+ pivot.userData.type = 'hole';
1835
+ pivot.userData.layerId = layer.id;
1836
+ pivot.userData.holeId = holeData.id;
1837
+
1838
+ // if holeId is existing, remove it first
1839
+ var childLen = planData.plan.children.length;
1840
+ var children = [];
1841
+ for (var i = 0; i < childLen; i++) {
1842
+ if (planData.plan.children[i].userData.holeId != holeData.id) children.push(planData.plan.children[i]);
1843
+ }
1844
+ planData.plan.children = children;
1845
+ planData.plan.add(pivot);
1846
+ planData.sceneGraph.layers[layer.id].holes[holeData.id] = pivot;
1847
+ applyInteract(pivot, function () {
1848
+ if (document.getElementById('setting_dialog')) {
1849
+ document.getElementById('setting_dialog').style.display = 'none';
1850
+ }
1851
+ return holesActions.selectHole(layer.id, holeData.id);
1852
+ });
1853
+ var opacity = layer.opacity;
1854
+ if (holeData.selected) {
1855
+ opacity = 1;
1856
+ }
1857
+ applyOpacity(pivot, opacity);
1858
+ });
1859
+ }
1860
+ function updateHole(sceneData, oldSceneData, planData, layer, holeID, differences, catalog, holesActions, selfDestroy, selfBuild) {
1861
+ var hole = layer.getIn(['holes', holeID]);
1862
+ var oldHole = oldSceneData.getIn(['layers', layer.id, 'holes', holeID]);
1863
+ var mesh = planData.sceneGraph.layers[layer.id].holes[holeID];
1864
+ if (!mesh) return null;
1865
+ return catalog.getElement(hole.type).updateRender3D(hole, layer, sceneData, mesh, oldHole, differences, selfDestroy, selfBuild);
1866
+ }
1867
+ function addLine(sceneData, planData, layer, lineID, catalog, linesActions) {
1868
+ var mode = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
1869
+ var toolObj = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
1870
+ if (planData.sceneGraph.busyResources.layers[layer.id].lines[lineID]) {
1871
+ setTimeout(function () {
1872
+ return addLine(sceneData, planData, layer, lineID, catalog, linesActions, mode);
1873
+ }, 100);
1874
+ return;
1875
+ }
1876
+ planData.sceneGraph.busyResources.layers[layer.id].lines[lineID] = true;
1877
+ var line = layer.getIn(['lines', lineID]);
1878
+ line.userData.stateMode = scene_mode;
1879
+
1880
+ // First of all I need to find the vertices of this line
1881
+ var vertex0 = layer.vertices.get(line.vertices.get(0));
1882
+ var vertex1 = layer.vertices.get(line.vertices.get(1));
1883
+ if (vertex0.x > vertex1.x) {
1884
+ var tmp = vertex0;
1885
+ vertex0 = vertex1;
1886
+ vertex1 = tmp;
1887
+ }
1888
+ return catalog.getElement(line.type).render3D(line, layer, sceneData, mode).then(function (line3D) {
1889
+ if (line3D === null) {
1890
+ return;
1891
+ }
1892
+ if (line3D instanceof Three.LOD) {
1893
+ planData.sceneGraph.LODs[line.id] = line3D;
1894
+ }
1895
+ var pivot = new Three.Object3D();
1896
+ pivot.name = 'pivot';
1897
+ pivot.add(line3D);
1898
+ pivot.position.x = (vertex0.x + vertex1.x) / 2;
1899
+ pivot.position.y = layer.altitude;
1900
+ pivot.position.z = -(vertex0.y + vertex1.y) / 2;
1901
+ pivot.userData.type = 'line';
1902
+
1903
+ // In elevation view, show(visible = true) just selected wall pivot. If not, hidden(visible = false)
1904
+ if ((0, _helper.isElevationView)(mode)) {
1905
+ var lineVisible;
1906
+ if (line.selected) {
1907
+ pivot.traverse(function (obj) {
1908
+ (0, _helper.replaceMeshesWithLineSegments)(obj);
1909
+ });
1910
+ lineVisible = true;
1911
+ } else {
1912
+ lineVisible = false;
1913
+ }
1914
+ pivot.visible = lineVisible;
1915
+ }
1916
+ pivot.userData.layerId = layer.id;
1917
+ pivot.userData.lineId = lineID;
1918
+ planData.plan.add(pivot);
1919
+ planData.sceneGraph.layers[layer.id].lines[lineID] = pivot;
1920
+ applyInteract(pivot, function () {
1921
+ if (document.getElementById('setting_dialog')) {
1922
+ document.getElementById('setting_dialog').style.display = 'none';
1923
+ }
1924
+ return linesActions.selectLine(layer.id, line.id);
1925
+ });
1926
+ var opacity = layer.opacity;
1927
+ if (line.selected) {
1928
+ opacity = 1;
1929
+ }
1930
+ applyOpacity(pivot, opacity);
1931
+ planData.sceneGraph.busyResources.layers[layer.id].lines[lineID] = false;
1932
+ });
1933
+ }
1934
+ function updateLine(sceneData, oldSceneData, planData, layer, lineID, differences, catalog, linesActions, selfDestroy, selfBuild) {
1935
+ var line = layer.getIn(['lines', lineID]);
1936
+ var oldLine = oldSceneData.getIn(['layers', layer.id, 'lines', lineID]);
1937
+ var mesh = planData.sceneGraph.layers[layer.id].lines[lineID];
1938
+ if (!mesh) return null;
1939
+ return catalog.getElement(line.type).updateRender3D(line, layer, sceneData, mesh, oldLine, differences, selfDestroy, selfBuild);
1940
+ }
1941
+ function addArea(sceneData, planData, layer, areaID, catalog, areaActions, mode) {
1942
+ var toolObj = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
1943
+ if (planData.sceneGraph.busyResources.layers[layer.id].areas[areaID]) {
1944
+ setTimeout(function () {
1945
+ return addArea(sceneData, planData, layer, areaID, catalog, areaActions, mode);
1946
+ }, 100);
1947
+ return;
1948
+ }
1949
+ planData.sceneGraph.busyResources.layers[layer.id].areas[areaID] = true;
1950
+ var area = layer.getIn(['areas', areaID]);
1951
+ var interactFunction = function interactFunction() {
1952
+ return areaActions.selectArea(layer.id, areaID);
1953
+ };
1954
+ return catalog.getElement(area.type).render3D(area, layer, sceneData).then(function (area3D) {
1955
+ if (area3D instanceof Three.LOD) {
1956
+ planData.sceneGraph.LODs[areaID] = area3D;
1957
+ }
1958
+ var pivot = new Three.Object3D();
1959
+ var floorSupport = area3D.userData.floorSupport;
1960
+ floorSupport.onBeforeRender = function (renderer, scene, camera, geometry, material, group) {
1961
+ var floorMesh = this.parent.getObjectByName('floor');
1962
+ if (geometry.attributes.normal === undefined) return floorMesh.visible = false;
1963
+ geometry.computeVertexNormals();
1964
+ var normals = geometry.attributes.normal.array;
1965
+ var pos = new Three.Vector4(0, 0, 0, 1);
1966
+ pos = pos.applyMatrix4(this.matrixWorld);
1967
+ pos = pos.applyMatrix4(camera.matrixWorldInverse);
1968
+ var normal = new Three.Vector4(normals[0], normals[1], normals[2], 0);
1969
+ normal = normal.applyMatrix4(this.matrixWorld);
1970
+ normal = normal.applyMatrix4(camera.matrixWorldInverse);
1971
+ if (floorMesh) {
1972
+ if (normal.dot(pos) <= 0) {
1973
+ floorMesh.visible = true;
1974
+ } else {
1975
+ floorMesh.visible = false;
1976
+ }
1977
+ }
1978
+ };
1979
+ var ceil = area3D.userData.floorSupport.clone();
1980
+ var ceilMaterial = new Three.MeshStandardMaterial({
1981
+ color: 0xdfdfdf,
1982
+ side: Three.BackSide,
1983
+ roughness: 0.3,
1984
+ metalness: 0.4
1985
+ });
1986
+ ceil.name = 'ceil';
1987
+ ceil.material = ceilMaterial;
1988
+ var vertices = [];
1989
+ var lines = [];
1990
+ var height = 100;
1991
+ area.vertices.forEach(function (data) {
1992
+ vertices.push(data);
1993
+ });
1994
+ layer.lines.forEach(function (data) {
1995
+ lines.push(data);
1996
+ });
1997
+ var _loop3 = function _loop3() {
1998
+ var data = lines[i];
1999
+ var realVec = [];
2000
+ data.vertices.forEach(function (vec) {
2001
+ realVec.push(vec);
2002
+ });
2003
+ if (vertices.includes(realVec[0]) && vertices.includes(realVec[1])) {
2004
+ height = (0, _convertUnitsLite.convert)(layer.ceilHeight).from(layer.unit).to(_constants.UNIT_CENTIMETER);
2005
+ // height = data.properties.getIn(["height", "length"]);
2006
+ return 1; // break
2007
+ }
2008
+ };
2009
+ for (var i = 0; i < lines.length; i++) {
2010
+ if (_loop3()) break;
2011
+ }
2012
+ ceil.translateZ((0, _convertUnitsLite.convert)(layer.ceilHeight).from(layer.unit).to(_constants.UNIT_CENTIMETER));
2013
+ pivot.name = 'pivot';
2014
+ pivot.add(area3D);
2015
+ pivot.add(area3D.userData.floorSupport);
2016
+ pivot.add(ceil);
2017
+ pivot.position.y = layer.altitude;
2018
+
2019
+ // if elevation view, show just wall - not show floor and ceil
2020
+ if ((0, _helper.isElevationView)(mode)) pivot.visible = false;
2021
+ planData.plan.add(pivot);
2022
+ planData.sceneGraph.layers[layer.id].areas[areaID] = pivot;
2023
+ if (document.getElementById('setting_dialog')) {
2024
+ document.getElementById('setting_dialog').style.display = 'none';
2025
+ }
2026
+ applyInteract(pivot, interactFunction);
2027
+ var opacity = layer.opacity;
2028
+ if (area.selected) {
2029
+ opacity = 1;
2030
+ }
2031
+ applyOpacity(pivot, opacity);
2032
+ planData.sceneGraph.busyResources.layers[layer.id].areas[areaID] = false;
2033
+ });
2034
+ }
2035
+ function updateArea(sceneData, oldSceneData, planData, layer, areaID, differences, catalog, areaActions, selfDestroy, selfBuild) {
2036
+ var area = layer.getIn(['areas', areaID]);
2037
+ var oldArea = oldSceneData.getIn(['layers', layer.id, 'areas', areaID]);
2038
+ var mesh = planData.sceneGraph.layers[layer.id].areas[areaID];
2039
+ if (!mesh) return null;
2040
+ return catalog.getElement(area.type).updateRender3D(area, layer, sceneData, mesh, oldArea, differences, selfDestroy, selfBuild);
2041
+ }
2042
+ function addItem(sceneData, planData, layer, itemID, catalog, itemsActions) {
2043
+ var mode = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
2044
+ var toolObj = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
2045
+ var rItem = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
2046
+ var bAddMolding = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : true;
2047
+ if (planData.sceneGraph.busyResources.layers[layer.id].items[itemID]) {
2048
+ setTimeout(function () {
2049
+ return addItem(sceneData, planData, layer, itemID, catalog, itemsActions, mode, toolObj, rItem, bAddMolding);
2050
+ }, 100);
2051
+ return;
2052
+ }
2053
+ var item = layer.getIn(['items', itemID]);
2054
+ if (item.doorStyle === null) {
2055
+ console.log(item.name + 's doorStyle is null!');
2056
+ return;
2057
+ }
2058
+ if (!sceneData.loadFlag && scene_mode == _constants.MODE_DRAWING_ITEM_3D) {
2059
+ itemsActions.toggleLoadingCabinet();
2060
+ }
2061
+ var catalogElement = catalog.getElement(item.type);
2062
+ if (!catalogElement) catalogElement = catalog.getElement((0, _utils.returnReplaceableDeepSearchType)(item.type));
2063
+ if (!catalogElement) return false;
2064
+ return catalogElement.render3D(item, layer, sceneData, mode).then(function (item3D) {
2065
+ var _item$properties$getI, _item$properties$getI2, _item$properties$getI3;
2066
+ if (item3D instanceof Three.LOD) {
2067
+ planData.sceneGraph.LODs[itemID] = item3D;
2068
+ }
2069
+ if (rItem !== null) {
2070
+ planData.plan.remove(rItem);
2071
+ (0, _threeMemoryCleaner.disposeObject)(rItem);
2072
+ rItem = null;
2073
+ }
2074
+ var pivot = new Three.Object3D();
2075
+ pivot.name = 'pivot';
2076
+ pivot.add(item3D);
2077
+ if (pivot) {
2078
+ var mBoxColor = 0x99c3fb;
2079
+ var _item = item.toJS();
2080
+ if ((0, _cabinetWarning.isWarningCabinet)(_item)) {
2081
+ mBoxColor = 'rgba(232,187,47,1)';
2082
+ } else {
2083
+ pivot.children[0].children.forEach(function (pivotElement) {
2084
+ pivotElement.visible = false;
2085
+ });
2086
+ }
2087
+ var mBox = GeomUtils.makeMBoxfromObject(pivot, mBoxColor);
2088
+ var warningObj = createWarningObject();
2089
+ warningObj.position.set(0, item.properties.get('height').get('length') / 3, 0);
2090
+ if (mBox) {
2091
+ mBox.add(warningObj);
2092
+ pivot.add(mBox);
2093
+ }
2094
+ }
2095
+
2096
+ // if (item.selected) {
2097
+ // let tranformControl = item3D.children[item3D.children.length - 1];
2098
+ // transformBox =
2099
+ // tranformControl.children[tranformControl.children.length - 1];
2100
+ // }
2101
+
2102
+ pivot.rotation.y = item.rotation * Math.PI / 180 + Math.PI;
2103
+ // pivot.rotation.y = item.rotation;
2104
+ pivot.position.x = item.x;
2105
+ pivot.position.y = layer.altitude;
2106
+ pivot.position.z = -item.y;
2107
+ applyInteract(item3D, function () {
2108
+ // closes the setting dialog
2109
+ if (document.getElementById('setting_dialog')) {
2110
+ document.getElementById('setting_dialog').style.display = 'none';
2111
+ }
2112
+ return itemsActions.selectItem(layer.id, item.id);
2113
+ });
2114
+ var opacity = layer.opacity;
2115
+ if (item.selected) {
2116
+ opacity = 1;
2117
+ exports.fVLine = fVLine = [];
2118
+ var TransformGizmo = item3D.children[item3D.children.length - 1];
2119
+ TransformGizmo.children.forEach(function (child) {
2120
+ if (child.type === 'Line' && child.geometry.attributes !== undefined) fVLine.push(child);
2121
+ });
2122
+ setTimeout(function () {
2123
+ getDistances(layer, item);
2124
+ }, 50);
2125
+ }
2126
+ applyOpacity(pivot, opacity);
2127
+ pivot.userData.type = 'item';
2128
+ pivot.userData.layerId = layer.id;
2129
+ pivot.userData.itemId = item.id;
2130
+
2131
+ /**
2132
+ *
2133
+ * @param {array} itemRect Array of item's 4 side lines
2134
+ * @returns {boolean} true (if item is snapped into wall) or false (if item is not snapped into wall)
2135
+ */
2136
+ //////////////////
2137
+ ///// wall ///////
2138
+ // 3 ***** 2
2139
+ // * *
2140
+ // * item *
2141
+ // * *
2142
+ // 0 ***** 1
2143
+
2144
+ var getItemVisible = function getItemVisible(itemRect) {
2145
+ var selectedLine = layer.lines.get(layer.selected.lines.toJS()[0]);
2146
+ var itemVisible = false;
2147
+ var vertex0 = layer.vertices.get(selectedLine.vertices.get(0));
2148
+ var vertex1 = layer.vertices.get(selectedLine.vertices.get(1));
2149
+ var l0 = {
2150
+ x: vertex0.x,
2151
+ y: vertex0.y
2152
+ };
2153
+ var l1 = {
2154
+ x: vertex1.x,
2155
+ y: vertex1.y
2156
+ };
2157
+ var r0 = itemRect.rect[0];
2158
+ var r1 = itemRect.rect[1];
2159
+ var r2 = itemRect.rect[2];
2160
+ var r3 = itemRect.rect[3];
2161
+
2162
+ // it doesn't need consider distance between item's line01 (frontside - it has door) and wall
2163
+ var delta12 = _export.GeometryUtils.distancePointFromLineSegment(l0, l1, (r1.x + r2.x) / 2, (r1.y + r2.y) / 2); // distance between item's line12 and wall
2164
+ var delta23 = _export.GeometryUtils.distancePointFromLineSegment(l0, l1, (r2.x + r3.x) / 2, (r2.y + r3.y) / 2); // distance between item's line23 and wall
2165
+ var delta30 = _export.GeometryUtils.distancePointFromLineSegment(l0, l1, (r3.x + r0.x) / 2, (r3.y + r0.y) / 2); // distance between item's line30 and wall
2166
+
2167
+ if (delta12 < _constants.DISTANCE_EPSILON || delta23 < _constants.DISTANCE_EPSILON || delta30 < _constants.DISTANCE_EPSILON) {
2168
+ itemVisible = true;
2169
+ }
2170
+ return itemVisible;
2171
+ };
2172
+ var val = {
2173
+ pos: {
2174
+ x: item.x,
2175
+ y: item.y
2176
+ },
2177
+ rotRad: item.rotation / 180 * Math.PI
2178
+ };
2179
+ var catid = item.type;
2180
+ var cat = catalog.elements[catid];
2181
+ if (!cat) cat = catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(catid)];
2182
+ var width = (0, _convertUnitsLite.convert)(item.properties.getIn(['width', '_length'])).from((_item$properties$getI = item.properties.getIn(['width', '_unit'])) !== null && _item$properties$getI !== void 0 ? _item$properties$getI : 'in').to(sceneData.unit);
2183
+ var height = (0, _convertUnitsLite.convert)(item.properties.getIn(['height', '_length'])).from((_item$properties$getI2 = item.properties.getIn(['height', '_unit'])) !== null && _item$properties$getI2 !== void 0 ? _item$properties$getI2 : 'in').to(sceneData.unit);
2184
+ var depth = (0, _convertUnitsLite.convert)(item.properties.getIn(['depth', '_length'])).from((_item$properties$getI3 = item.properties.getIn(['depth', '_unit'])) !== null && _item$properties$getI3 !== void 0 ? _item$properties$getI3 : 'in').to(sceneData.unit);
2185
+ val.size = {
2186
+ width: width,
2187
+ height: height,
2188
+ depth: depth
2189
+ };
2190
+ val.layoutpos = item === null || item === void 0 ? void 0 : item.layoutpos;
2191
+ val.is_corner = item === null || item === void 0 ? void 0 : item.is_corner;
2192
+ val.item = item;
2193
+ var calcrect = _export.GeometryUtils.getCalcRectFromItem3D(val);
2194
+
2195
+ // In elevation view, determin if item show or not
2196
+ if ((0, _helper.isElevationView)(mode)) pivot.visible = getItemVisible(calcrect);
2197
+ planData.plan.add(pivot);
2198
+ planData.sceneGraph.layers[layer.id].items[item.id] = pivot;
2199
+ //In a 3D view, merge each couterTop of equal height into a single conuterTop.
2200
+ if (!(0, _helper.isElevationView)(mode)) {
2201
+ addCountertop(planData.sceneGraph.layers[layer.id].countertops, item, planData, layer);
2202
+ }
2203
+ if (bAddMolding && item.category === 'cabinet' && ((0, _helper.isElevationView)(mode) && getItemVisible(calcrect) || !(0, _helper.isElevationView)(mode))) {
2204
+ planData.sceneGraph.layers[layer.id].moldingGroups = addMolding(planData.sceneGraph.layers[layer.id].moldingGroups, item, planData, layer, itemsActions, mode) || planData.sceneGraph.layers[layer.id].moldingGroups;
2205
+ }
2206
+ if (pivot) {
2207
+ // update the tool object's position to selected object's position
2208
+ var selectedItem = planData.sceneGraph.layers[sceneData.selectedLayer].items[itemID];
2209
+ var itemPos = selectedItem.position.clone();
2210
+ if (!(0, _helper.isEmpty)(toolObj)) {
2211
+ toolObj.position.set(planData.plan.position.x + itemPos.x, selectedItem.category === 'lighting' ? -planData.plan.position.y - selectedItem.properties.get('height').get('length') : planData.plan.position.y + selectedItem.children[0].position.y, planData.plan.position.z + itemPos.z);
2212
+ }
2213
+ pivot.children[0].children.forEach(function (pivotElement) {
2214
+ pivotElement.visible = true;
2215
+ });
2216
+ if (pivot.children.length > 1) {
2217
+ var _item4 = item.toJS();
2218
+ if (_item4.category === _constants.ITEM_TYPE.CABINET) {
2219
+ if (!(0, _cabinetWarning.isWarningCabinet)(item)) {
2220
+ pivot.children.pop();
2221
+ } else {
2222
+ pivot.children.pop();
2223
+ }
2224
+ }
2225
+ }
2226
+ }
2227
+ applyInteract(pivot, function () {
2228
+ if (document.getElementById('setting_dialog')) {
2229
+ document.getElementById('setting_dialog').style.display = 'none';
2230
+ }
2231
+ return itemsActions.selectItem(layer.id, item.id);
2232
+ });
2233
+ setTimeout(function () {
2234
+ return getDistances(layer, item);
2235
+ }, 100);
2236
+ if (!sceneData.loadFlag && scene_mode == _constants.MODE_DRAWING_ITEM_3D) {
2237
+ itemsActions.endLoading();
2238
+ itemsActions.toggleLoadingCabinet();
2239
+ }
2240
+ });
2241
+ }
2242
+ function updateItem(sceneData, oldSceneData, planData, layer, itemID, differences, catalog, itemsActions, selfDestroy, selfBuild) {
2243
+ var item = layer.getIn(['items', itemID]);
2244
+ var oldItem = oldSceneData.getIn(['layers', layer.id, 'items', itemID]);
2245
+ var mesh = planData.sceneGraph.layers[layer.id].items[itemID];
2246
+ if (!mesh) return null;
2247
+ return catalog.getElement(item.type).updateRender3D(item, layer, sceneData, mesh, oldItem, differences, selfDestroy, selfBuild);
2248
+ }
2249
+
2250
+ // Apply interact function to children of an Object3D
2251
+ function applyInteract(object, interactFunction) {
2252
+ if (document.getElementById('setting_dialog')) {
2253
+ document.getElementById('setting_dialog').style.display = 'none';
2254
+ }
2255
+ object.traverse(function (child) {
2256
+ if (child instanceof Three.Mesh) {
2257
+ child.interact = interactFunction;
2258
+ }
2259
+ });
2260
+ }
2261
+
2262
+ // Apply opacity to children of an Object3D
2263
+ function applyOpacity(object, opacity) {
2264
+ object.traverse(function (child) {
2265
+ if (child instanceof Three.Mesh) {
2266
+ if (child.material && !Array.isArray(child.material)) {
2267
+ // child.material.materials.forEach(materialChild => {
2268
+ // materialChild.transparent = true;
2269
+ // if (materialChild.maxOpacity) {
2270
+ // materialChild.opacity = Math.min(materialChild.maxOpacity, opacity);
2271
+ // } else if (materialChild.opacity && materialChild.opacity > opacity) {
2272
+ // materialChild.maxOpacity = materialChild.opacity;
2273
+ // materialChild.opacity = opacity;
2274
+ // }
2275
+ // });
2276
+ } else if (child.material instanceof Array) {
2277
+ child.material.forEach(function (material) {
2278
+ material.transparent = true;
2279
+ if (material.maxOpacity) {
2280
+ material.opacity = Math.min(material.maxOpacity, opacity);
2281
+ } else if (material.opacity && material.opacity > opacity) {
2282
+ material.maxOpacity = material.opacity;
2283
+ material.opacity = opacity;
2284
+ }
2285
+ });
2286
+ } else {
2287
+ child.material.transparent = true;
2288
+ if (child.material.maxOpacity) {
2289
+ child.material.opacity = Math.min(child.material.maxOpacity, opacity);
2290
+ } else if (child.material.opacity && child.material.opacity > opacity) {
2291
+ child.material.maxOpacity = child.material.opacity;
2292
+ child.material.opacity = opacity;
2293
+ }
2294
+ }
2295
+ }
2296
+ });
2297
+ }
2298
+ function updateBoundingBox(planData) {
2299
+ var flag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2300
+ var mode = arguments.length > 2 ? arguments[2] : undefined;
2301
+ if (scene_mode == _constants.MODE_DRAWING_ITEM_3D) return;
2302
+ var newBoundingBox = new Three.Box3().setFromObject(planData.plan);
2303
+ if (isFinite(newBoundingBox.max.x) && isFinite(newBoundingBox.min.x) && isFinite(newBoundingBox.max.y) && isFinite(newBoundingBox.min.y) && isFinite(newBoundingBox.max.z) && isFinite(newBoundingBox.min.z)) {
2304
+ var newCenter = new Three.Vector3((newBoundingBox.max.x - newBoundingBox.min.x) / 2 + newBoundingBox.min.x, (newBoundingBox.max.y - newBoundingBox.min.y) / 2 + newBoundingBox.min.y, (newBoundingBox.max.z - newBoundingBox.min.z) / 2 + newBoundingBox.min.z);
2305
+ if (!flag) {
2306
+ planData.plan.position.sub(newCenter);
2307
+ planData.grid.position.sub(newCenter);
2308
+ if ((0, _helper.isElevationView)(mode)) {
2309
+ planData.cam.position.sub(newCenter);
2310
+ }
2311
+ }
2312
+ newBoundingBox.min.sub(newCenter);
2313
+ newBoundingBox.max.sub(newCenter);
2314
+ planData.boundingBox = newBoundingBox;
2315
+ }
2316
+ }
2317
+
2318
+ /**
2319
+ * Filter the array of diffs
2320
+ * @param diffArray
2321
+ * @param sceneData
2322
+ * @param oldSceneData
2323
+ * @returns {Array}
2324
+ */
2325
+ function filterDiffs(diffArray, sceneData, oldSceneData) {
2326
+ return minimizeRemoveDiffsWhenSwitchingLayers(minimizeChangePropertiesAfterSelectionsDiffs(minimizeChangePropertiesDiffs(diffArray, sceneData, oldSceneData), sceneData, oldSceneData), sceneData, oldSceneData);
2327
+ }
2328
+
2329
+ /**
2330
+ * Reduces the number of remove diffs when switching an hidden layer
2331
+ * @param diffArray the array of the diffs
2332
+ * @param sceneData
2333
+ * @param oldSceneData
2334
+ * @returns {Array}
2335
+ */
2336
+ function minimizeRemoveDiffsWhenSwitchingLayers(diffArray, sceneData, oldSceneData) {
2337
+ var foundDiff;
2338
+ var i;
2339
+ for (i = 0; i < diffArray.length && !foundDiff; i++) {
2340
+ if (diffArray[i].path[1] === 'selectedLayer') {
2341
+ foundDiff = diffArray[i];
2342
+ }
2343
+ }
2344
+ if (foundDiff) {
2345
+ if (!sceneData.getIn(['layers', oldSceneData.selectedLayer, 'visible'])) {
2346
+ return diffArray.filter(function (_ref6) {
2347
+ var op = _ref6.op,
2348
+ path = _ref6.path;
2349
+ return !(path[path.length - 1] === 'selected' && path[1] === 'layers' && path[2] === oldSceneData.selectedLayer) && !(op === 'remove' && path.indexOf(oldSceneData.selectedLayer) !== -1);
2350
+ });
2351
+ }
2352
+ }
2353
+ return diffArray;
2354
+ }
2355
+
2356
+ /**
2357
+ * Reduces the number of change properties diffs for selected elements
2358
+ * @param diffArray the array of the diffs
2359
+ * @param sceneData
2360
+ * @param oldSceneData
2361
+ * @returns {Array}
2362
+ */
2363
+ function minimizeChangePropertiesAfterSelectionsDiffs(diffArray, sceneData, oldSceneData) {
2364
+ var idsFound = {};
2365
+ diffArray.forEach(function (_ref7) {
2366
+ var path = _ref7.path;
2367
+ if (path[5] === 'selected') {
2368
+ idsFound[path[4]] = path[4];
2369
+ }
2370
+ });
2371
+ return diffArray.filter(function (_ref8) {
2372
+ var path = _ref8.path;
2373
+ if (path[5] === 'properties') {
2374
+ return idsFound[path[4]] ? false : true;
2375
+ }
2376
+ return true;
2377
+ });
2378
+ }
2379
+
2380
+ /**
2381
+ * Reduces the number of change properties diffs
2382
+ * @param diffArray the array of the diffs
2383
+ * @param sceneData
2384
+ * @param oldSceneData
2385
+ * @returns {Array}
2386
+ */
2387
+ function minimizeChangePropertiesDiffs(diffArray, sceneData, oldSceneData) {
2388
+ var idsFound = {};
2389
+ return diffArray.filter(function (_ref9) {
2390
+ var path = _ref9.path;
2391
+ if (path[5] === 'properties') {
2392
+ return idsFound[path[4]] ? false : idsFound[path[4]] = true;
2393
+ } else if (path[5] === 'misc') {
2394
+ // Remove misc changes
2395
+ return false;
2396
+ }
2397
+ return true;
2398
+ });
2399
+ }
2400
+
2401
+ // countertops:
2402
+ // o id:
2403
+ // o items: [itemid]
2404
+ // o ct3d: 3d object
2405
+ // o catid
2406
+ // o pos
2407
+ // o rotRad
2408
+ // o size
2409
+ function createCTFromItem(item, unit, catalog) {
2410
+ return createCTFromItems([item], unit, catalog);
2411
+ }
2412
+ function createCTFromItems(items, unit, catalog) {
2413
+ var item0 = items[0];
2414
+ var item1 = items[items.length - 1];
2415
+ var CTId = _export.IDBroker.acquireID();
2416
+ var ct3d = null;
2417
+ var catid = item0.type;
2418
+ var pos = {
2419
+ x: (item0.x + item1.x) / 2,
2420
+ y: (item0.y + item1.y) / 2
2421
+ };
2422
+ var rotRad = item0.rotation / 180 * Math.PI;
2423
+ var cat = catalog.elements[catid];
2424
+ // let width = convert(item0.properties.getIn(['width', '_length'])).from('in').to('cm');
2425
+ // let depth = convert(item0.properties.getIn(['depth', '_length'])).from('in').to('cm');
2426
+ // let height = convert(item0.properties.getIn(['height', '_length'])).from('in').to('cm');
2427
+ var width = item0.properties.get('width').get('_length');
2428
+ var widthUnit = item0.properties.get('width').get('_unit') || 'cm';
2429
+ width = (0, _convertUnitsLite.convert)(width).from(widthUnit).to('cm');
2430
+ var depth = item0.properties.get('depth').get('_length');
2431
+ var depthUnit = item0.properties.get('depth').get('_unit') || 'cm';
2432
+ depth = (0, _convertUnitsLite.convert)(depth).from(depthUnit).to('cm');
2433
+ var height = item0.properties.get('height').get('_length');
2434
+ var heightUnit = item0.properties.get('height').get('_unit') || 'cm';
2435
+ height = (0, _convertUnitsLite.convert)(height).from(heightUnit).to('cm');
2436
+ var size = {
2437
+ width: width * items.length,
2438
+ depth: depth,
2439
+ height: height
2440
+ };
2441
+ return {
2442
+ id: CTId,
2443
+ items: items,
2444
+ ct3d: ct3d,
2445
+ catid: catid,
2446
+ pos: pos,
2447
+ rotRad: rotRad,
2448
+ size: size
2449
+ };
2450
+ }
2451
+ function createMDFromItem(item, lines, molding) {
2452
+ var MDId = _export.IDBroker.acquireID();
2453
+ var z = item.properties.get('altitude').get('_length');
2454
+ var zUnit = item.properties.get('altitude').get('_unit') || 'cm';
2455
+ z = (0, _convertUnitsLite.convert)(z).from(zUnit).to('cm');
2456
+ var height = item.properties.get('height').get('_length');
2457
+ var heightUnit = item.properties.get('height').get('_unit') || 'cm';
2458
+ height = (0, _convertUnitsLite.convert)(height).from(heightUnit).to('cm');
2459
+ switch (molding.location_type) {
2460
+ case _constants.TOP_MOLDING_LOCATION:
2461
+ z += height;
2462
+ break;
2463
+ case _constants.MIDDLE_MOLDING_LOCATION:
2464
+ z += height / 2;
2465
+ break;
2466
+ case _constants.BOTTOM_MOLDING_LOCATION:
2467
+ z += 0;
2468
+ break;
2469
+ default:
2470
+ break;
2471
+ }
2472
+ return {
2473
+ id: MDId,
2474
+ items: [item],
2475
+ meshes: [],
2476
+ pos: {
2477
+ x: 0,
2478
+ y: 0,
2479
+ z: z
2480
+ },
2481
+ size: {
2482
+ width: 0,
2483
+ depth: 0,
2484
+ height: 0
2485
+ },
2486
+ lines: lines,
2487
+ molding: molding,
2488
+ pointGroups: []
2489
+ };
2490
+ }
2491
+ function tryAdjacent(ct1, ct2) {
2492
+ if (ct1.catid.includes('Dishwasher') && ct1.catid.includes('BF')) {
2493
+ var temp = ct1;
2494
+ ct1 = ct2;
2495
+ ct2 = temp;
2496
+ }
2497
+ log('----tryAdjacent', ct1.id, ct2.id);
2498
+ if (!ct2.catid.includes('Dishwasher') && !ct2.catid.includes('BF') && ct1.catid != ct2.catid) return false;
2499
+ if (ct1.rotRad != ct2.rotRad) return false;
2500
+ log('ct1', ct1.pos.x, ct1.pos.y, ct1.size.width);
2501
+ log('ct2', ct2.pos.x, ct2.pos.y, ct2.size.width);
2502
+ var dist = _export.GeometryUtils.verticesDistance(ct1.pos, ct2.pos);
2503
+ var totalwidth = ct1.size.width + ct2.size.width;
2504
+ log('epsilon', dist, totalwidth, Math.abs(2 * dist - totalwidth));
2505
+ if (Math.abs(2 * dist - totalwidth) / totalwidth > 1e-3) return false;
2506
+ log('----success');
2507
+ var newpos = {
2508
+ x: (ct1.pos.x * ct1.size.width + ct2.pos.x * ct2.size.width) / totalwidth,
2509
+ y: (ct1.pos.y * ct1.size.width + ct2.pos.y * ct2.size.width) / totalwidth
2510
+ };
2511
+ var newsize = {
2512
+ width: totalwidth,
2513
+ depth: ct1.size.depth,
2514
+ height: ct1.size.height
2515
+ };
2516
+ var CTId = _export.IDBroker.acquireID();
2517
+ var items = _export.GeometryUtils.compareVertices(ct1.pos, ct2.pos) > 0 ? [].concat((0, _toConsumableArray2["default"])(ct1.items), (0, _toConsumableArray2["default"])(ct2.items)) : [].concat((0, _toConsumableArray2["default"])(ct2.items), (0, _toConsumableArray2["default"])(ct1.items));
2518
+ var ct3d = null;
2519
+ var catid = ct1.catid;
2520
+ return {
2521
+ id: CTId,
2522
+ items: items,
2523
+ ct3d: ct3d,
2524
+ catid: catid,
2525
+ pos: newpos,
2526
+ rotRad: ct1.rotRad,
2527
+ size: newsize
2528
+ };
2529
+ }
2530
+ function isParallelLines(line1, line2) {
2531
+ var isParallel = false;
2532
+ if (Math.abs(line1[0].y - line1[1].y) <= _constants.EPSILON && Math.abs(line2[0].y - line2[1].y) <= _constants.EPSILON) isParallel = true;
2533
+ if (Math.abs(line1[0].x - line1[1].x) <= _constants.EPSILON && Math.abs(line2[0].x - line2[1].x) <= _constants.EPSILON) isParallel = true;
2534
+ if (Math.abs((line1[0].x - line1[1].x) / (line1[0].y - line1[1].y) - (line2[0].x - line2[1].x) / (line2[0].y - line2[1].y)) <= _constants.EPSILON) isParallel = true;
2535
+ if (isParallel) {
2536
+ return true;
2537
+ }
2538
+ return false;
2539
+ }
2540
+ function tryAdjacentMD(md1, md2, molding) {
2541
+ log('----tryAdjacent', md1.id, md2.id);
2542
+ if (Math.abs(md1.pos.z - md2.pos.z) > _constants.EPSILON) return false;
2543
+ var id1 = md1.items[0].doorStyle.hasOwnProperty('id') ? md1.items[0].doorStyle.id : md1.items[0].doorStyle.toJS().id,
2544
+ id2 = md2.items[0].doorStyle.hasOwnProperty('id') ? md2.items[0].doorStyle.id : md2.items[0].doorStyle.toJS().id;
2545
+ if (id1 !== id2) return false;
2546
+ var newLines = md1.lines.concat(md2.lines);
2547
+ var isMerge = false;
2548
+ md1.lines.forEach(function (line1) {
2549
+ md2.lines.map(function (line2) {
2550
+ // filter removed lines
2551
+ if (newLines.findIndex(function (a) {
2552
+ return a[2] === line1[2];
2553
+ }) === -1 || newLines.findIndex(function (a) {
2554
+ return a[2] === line2[2];
2555
+ }) === -1) return false;
2556
+ // is parallel two lines
2557
+ if (isParallelLines(line1, line2)) {
2558
+ var disLine1 = _export.GeometryUtils.verticesDistance(line1[0], line1[1]);
2559
+ var disLine2 = _export.GeometryUtils.verticesDistance(line2[0], line2[1]);
2560
+ if (_export.GeometryUtils.sameMDistances(_export.GeometryUtils.verticesDistance(line2[0], line1[0]) + _export.GeometryUtils.verticesDistance(line1[1], line2[1]), Math.abs(disLine2 - disLine1))) {
2561
+ newLines = newLines.filter(function (a) {
2562
+ return !(a[2] === line1[2] || a[2] === line2[2]);
2563
+ });
2564
+ if (!_export.GeometryUtils.sameMPoints(line1[0], line2[0])) newLines.push([line1[0], line2[0], _export.IDBroker.acquireID()]);
2565
+ if (!_export.GeometryUtils.sameMPoints(line1[1], line2[1])) newLines.push([line1[1], line2[1], _export.IDBroker.acquireID()]);
2566
+ isMerge = true;
2567
+ return false;
2568
+ }
2569
+ if (_export.GeometryUtils.sameMDistances(_export.GeometryUtils.verticesDistance(line2[0], line1[1]) + _export.GeometryUtils.verticesDistance(line1[0], line2[1]), Math.abs(disLine2 - disLine1))) {
2570
+ newLines = newLines.filter(function (a) {
2571
+ return !(a[2] === line1[2] || a[2] === line2[2]);
2572
+ });
2573
+ if (!_export.GeometryUtils.sameMPoints(line1[1], line2[0])) newLines.push([line1[1], line2[0], _export.IDBroker.acquireID()]);
2574
+ if (!_export.GeometryUtils.sameMPoints(line1[0], line2[1])) newLines.push([line1[0], line2[1], _export.IDBroker.acquireID()]);
2575
+ isMerge = true;
2576
+ return false;
2577
+ }
2578
+ var samePointNum = -1,
2579
+ i = 0;
2580
+ while (i < 4 && samePointNum === -1) {
2581
+ if (_export.GeometryUtils.sameMPoints(line1[Math.floor(i / 2)], line2[i % 2]) && _export.GeometryUtils.sameMDistances(disLine1 + disLine2, _export.GeometryUtils.verticesDistance(line1[Math.floor((3 - i) / 2)], line2[(3 - i) % 2]))) {
2582
+ samePointNum = 3 - i;
2583
+ } else {
2584
+ i++;
2585
+ }
2586
+ }
2587
+ if (samePointNum > -1) {
2588
+ newLines = newLines.filter(function (a) {
2589
+ return !(a[2] === line1[2] || a[2] === line2[2]);
2590
+ });
2591
+ newLines.push([_objectSpread({}, line1[Math.floor(samePointNum / 2)]), _objectSpread({}, line2[samePointNum % 2]), _export.IDBroker.acquireID()]);
2592
+ isMerge = true;
2593
+ return false;
2594
+ }
2595
+ var pointNum = -1,
2596
+ k = 0;
2597
+ while (k < 4 && pointNum === -1) {
2598
+ if (_export.GeometryUtils.sameMDistances(_export.GeometryUtils.verticesDistance(line1[Math.floor(k / 2)], line2[k % 2]) + _export.GeometryUtils.verticesDistance(line1[1 - Math.floor(k / 2)], line2[k % 2]), disLine1) && _export.GeometryUtils.sameMDistances(_export.GeometryUtils.verticesDistance(line1[1 - Math.floor(k / 2)], line2[k % 2]) + _export.GeometryUtils.verticesDistance(line1[1 - Math.floor(k / 2)], line2[1 - k % 2]), disLine2)) {
2599
+ pointNum = k;
2600
+ } else {
2601
+ k++;
2602
+ }
2603
+ }
2604
+ }
2605
+ return false;
2606
+ });
2607
+ });
2608
+ if (!newLines.length) return _objectSpread({}, md2);
2609
+ if (!isMerge) return false;
2610
+ return {
2611
+ id: _export.IDBroker.acquireID(),
2612
+ items: [].concat((0, _toConsumableArray2["default"])(md2.items.filter(function (item) {
2613
+ return md1.items.findIndex(function (it) {
2614
+ return it.id === item.id;
2615
+ }) === -1;
2616
+ })), (0, _toConsumableArray2["default"])(md1.items)),
2617
+ meshes: [],
2618
+ pos: md1.pos,
2619
+ size: md1.size,
2620
+ lines: newLines,
2621
+ molding: molding
2622
+ };
2623
+ }
2624
+ function showItemCT(item, CT, visible, planData, layer) {
2625
+ var item3D = planData.sceneGraph.layers[layer.id].items[item.id];
2626
+ if (item3D === undefined) return undefined;
2627
+ item3D.traverse(function (child) {
2628
+ if (child.name.includes('countertop')) {
2629
+ child.visible = visible;
2630
+ if (child.material.map === null) {
2631
+ var normalMap = item.counterTop.uri;
2632
+ var interiortexture = (0, _itemLoader.loadTexture)(normalMap);
2633
+ applyTexture(child.material, interiortexture, 100, 100);
2634
+ child.material.color = new _three.Color(1, 1, 1);
2635
+ return;
2636
+ }
2637
+ child.material.map.repeat.x = 1;
2638
+ }
2639
+ });
2640
+ }
2641
+ function getCountertopMesh(item, visible, planData, layer) {
2642
+ if (item.type.includes('Dishwasher')) return undefined;
2643
+ if (item.type.includes('BF')) return undefined;
2644
+ var item3D = planData.sceneGraph.layers[layer.id].items[item.id];
2645
+ var countertop = null;
2646
+ if (item3D === undefined) return undefined;
2647
+ item3D.traverse(function (child) {
2648
+ if (child.name.includes('countertop')) {
2649
+ countertop = child;
2650
+ }
2651
+ });
2652
+ return countertop;
2653
+ }
2654
+ function getDoorStyleMaterial(items, planData, layer, name) {
2655
+ var item3D = null;
2656
+ // find Item with visible = true, in elevation mode
2657
+ items.forEach(function (item) {
2658
+ var tempItem = null;
2659
+ tempItem = planData.sceneGraph.layers[layer.id].items[item.id];
2660
+ if (tempItem && tempItem.visible) {
2661
+ item3D = tempItem;
2662
+ }
2663
+ });
2664
+ var door_mesh = null;
2665
+ if (!item3D) return undefined;
2666
+ item3D.traverse(function (child) {
2667
+ if (!door_mesh && !child.name.includes('countertop') && !child.name.includes('_interior_') && !child.name.includes('handle') && child.type === _constants.OBJTYPE_MESH) {
2668
+ door_mesh = child;
2669
+ }
2670
+ });
2671
+ return door_mesh && door_mesh.material;
2672
+ }
2673
+ function addCTMesh(countertop, planData, layer) {
2674
+ if (countertop.items.length == 1) {
2675
+ showItemCT(countertop.items[0], countertop, true, planData, layer);
2676
+ } else {
2677
+ var ctMesh = null;
2678
+ countertop.items.some(function (item) {
2679
+ ctMesh = getCountertopMesh(item, true, planData, layer);
2680
+ return ctMesh != null;
2681
+ });
2682
+ if (!ctMesh) return;
2683
+ if (0) {
2684
+ var material = ctMesh.material;
2685
+ var thickness = 3.81;
2686
+ var geometry = new Three.BoxGeometry(countertop.size.width, thickness, countertop.size.depth);
2687
+ var ct3d = new Three.Mesh(geometry, material);
2688
+ countertop.ct3d = ct3d;
2689
+ planData.plan.add(ct3d);
2690
+ ct3d.position.x = countertop.pos.x;
2691
+ ct3d.position.z = -countertop.pos.y;
2692
+ ct3d.position.y = countertop.size.height + thickness / 2;
2693
+ ct3d.quaternion.setFromAxisAngle(new Three.Vector3(0, 1, 0), countertop.rotRad);
2694
+ ct3d.name = 'countertops';
2695
+ } else {
2696
+ var _ct3d = ctMesh.clone();
2697
+ countertop.ct3d = _ct3d;
2698
+ _ct3d.visible = true;
2699
+ _ct3d.material = ctMesh.material.clone();
2700
+ if (_ct3d.material.map !== null) {
2701
+ _ct3d.material.map.copy(ctMesh.material.map);
2702
+ _ct3d.material.map.repeat.x = countertop.items.length;
2703
+ }
2704
+ ctMesh.updateMatrix();
2705
+ ctMesh.parent.updateMatrix();
2706
+ ctMesh.parent.parent.updateMatrix();
2707
+ var ctmeshMat = ctMesh.matrix;
2708
+ var objMat = ctMesh.parent.matrix;
2709
+ var pivotMat = ctMesh.parent.parent.matrix;
2710
+ pivotMat.setPosition(new Three.Vector3(countertop.pos.x, 0, -countertop.pos.y));
2711
+ var width = countertop.items.find(function (ct) {
2712
+ return !ct.type.includes('Dishwasher') && !ct.type.includes('BF');
2713
+ }).properties.get('width').get('_length');
2714
+ var unit_width = countertop.items.find(function (ct) {
2715
+ return !ct.type.includes('Dishwasher') && !ct.type.includes('BF');
2716
+ }).properties.get('width').get('_unit') || 'cm';
2717
+ width = (0, _convertUnitsLite.convert)(width).from(unit_width).to('cm');
2718
+ pivotMat.scale(new Three.Vector3(countertop.size.width / width, 1, 1));
2719
+ var finalMat = objMat.premultiply(pivotMat);
2720
+ _ct3d.applyMatrix4(finalMat);
2721
+ planData.plan.add(_ct3d);
2722
+ _ct3d.name = 'countertops';
2723
+ }
2724
+ }
2725
+ }
2726
+ function getArea(a, b, c) {
2727
+ return a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y);
2728
+ }
2729
+ function isSingleQuadrilateral(groupCount, pointGroup) {
2730
+ return groupCount === 1 && pointGroup.length === 4;
2731
+ }
2732
+
2733
+ /**
2734
+ * @param MDV - molding points
2735
+ * @param width - cabinet width
2736
+ * @param depth - cabinet depth ( z axis )
2737
+ * @param model - molding info that appear in real 3D
2738
+ */
2739
+ function moldingVertices(mPointGroup, mdGeo, MDV, model, svg_width, svg_height, groupCount) {
2740
+ var pointGroup = mPointGroup;
2741
+ var length = pointGroup.length;
2742
+ var isSnap = true;
2743
+
2744
+ // Point O
2745
+ var o = new Three.Vector2(0, 0);
2746
+ if (_export.GeometryUtils.samePoints(pointGroup[0], pointGroup[length - 1])) {
2747
+ pointGroup = pointGroup.slice(0, length - 1);
2748
+ length--;
2749
+ isSnap = false;
2750
+ }
2751
+ var verticesArray = [];
2752
+ var t = [[-1, -1], [1, -1], [1, 1], [-1, 1]];
2753
+ if (!isSnap && isSingleQuadrilateral(groupCount, pointGroup)) {
2754
+ var tmp_pos = [];
2755
+ t.forEach(function (tmp) {
2756
+ pointGroup.forEach(function (point) {
2757
+ if (point.x * tmp[0] > 0 && point.y * tmp[1] > 0) {
2758
+ tmp_pos.push(point);
2759
+ }
2760
+ });
2761
+ });
2762
+ pointGroup = tmp_pos;
2763
+ }
2764
+ pointGroup.forEach(function (cur, i) {
2765
+ var prev = isSnap && i === 0 ? cur : pointGroup[(i + length - 1) % length];
2766
+ var next = isSnap && i === length - 1 ? cur : pointGroup[(i + 1) % length];
2767
+ var vecPC = cur.clone().sub(prev); // vector from point `prev` to point `cur`
2768
+ var vecNC = cur.clone().sub(next); // vector from point `next` to point `cur`
2769
+
2770
+ // Calculate normal vector to `vecPC`
2771
+ var vecNorm = new Three.Vector2(0, 1);
2772
+ if (vecPC.x) {
2773
+ if (vecPC.x > 0) {
2774
+ vecNorm = new Three.Vector2(-vecPC.y / vecPC.x, 1);
2775
+ } else {
2776
+ vecNorm = new Three.Vector2(vecPC.y / vecPC.x, -1);
2777
+ }
2778
+ } else {
2779
+ if (vecPC.y === 0) {
2780
+ if (vecNC.x) {
2781
+ if (vecNC.x > 0) {
2782
+ vecNorm = new Three.Vector2(vecNC.y / vecNC.x, -1);
2783
+ } else {
2784
+ vecNorm = new Three.Vector2(-vecNC.y / vecNC.x, 1);
2785
+ }
2786
+ } else {
2787
+ if (vecNC.y > 0) {
2788
+ vecNorm = new Three.Vector2(1, 0);
2789
+ } else {
2790
+ vecNorm = new Three.Vector2(-1, 0);
2791
+ }
2792
+ }
2793
+ } else {
2794
+ if (vecPC.y > 0) {
2795
+ vecNorm = new Three.Vector2(-1, 0);
2796
+ } else {
2797
+ vecNorm = new Three.Vector2(1, 0);
2798
+ }
2799
+ }
2800
+ }
2801
+ var p1 = cur.clone().add(vecNorm); // the point that's away from `cur` by `vecNorm`
2802
+ if (getArea(prev, p1, cur) > 0) {
2803
+ vecNorm.multiplyScalar(-1);
2804
+ }
2805
+ var area = 0.5 * getArea(prev, cur, next);
2806
+ var lenPN = next.clone().sub(prev).length();
2807
+ var lenNC = vecNC.length();
2808
+ var lenPC = vecPC.length();
2809
+ var alpha = Math.acos((lenNC * lenNC + lenPC * lenPC - lenPN * lenPN) / (2 * lenNC * lenPC));
2810
+ if (area < 0) alpha = 2 * Math.PI - alpha; // Exterior Angle
2811
+ alpha /= 2;
2812
+ if (isNaN(alpha)) {
2813
+ alpha = Math.PI / 2;
2814
+ }
2815
+ vecNorm.rotateAround(o, Math.PI / 2 - alpha);
2816
+ vecNorm.normalize();
2817
+ vecNorm.multiplyScalar(1 / Math.sin(alpha));
2818
+
2819
+ // Make 3D Points
2820
+ MDV.forEach(function (p) {
2821
+ var x = cur.x - vecNorm.x * ((p.x / svg_width - 0.5) * model.length);
2822
+ var y = (0.5 - p.y / svg_height) * model.width;
2823
+ var z = -cur.y + vecNorm.y * ((p.x / svg_width - 0.5) * model.length);
2824
+ if (mdGeo.attributes.hasOwnProperty('position')) verticesArray = mdGeo.attributes.position.array;
2825
+ verticesArray.push(x, y, z);
2826
+ });
2827
+ });
2828
+ var mdGeo1 = mdGeo.setAttribute('position', new Three.BufferAttribute(new Float32Array(verticesArray), 3));
2829
+ mdGeo1.needsUpdate = true;
2830
+ return mdGeo1;
2831
+ }
2832
+ var dcmFace = function dcmFace(a, leng, MDV) {
2833
+ for (var i = a; i < a + 2; i++) {
2834
+ var f_a1 = i;
2835
+ var f_b1 = i + leng;
2836
+ var f_c1 = i + leng + 1;
2837
+ var f_a2 = i;
2838
+ var f_b2 = i + 1;
2839
+ var f_c2 = f_c1;
2840
+ var _indices = Array.from(MDV.index.array);
2841
+ _indices.push(f_a1, f_b1, f_c1, f_c2, f_b2, f_a2);
2842
+ MDV.setIndex(_indices);
2843
+ }
2844
+ var indices = Array.from(MDV.index.array);
2845
+ indices.push(a + 2, a + leng + 2, a + leng + 4, a + leng + 4, a + 4, a + 2);
2846
+ MDV.setIndex(indices);
2847
+ for (var _i = a + 4; _i < a + 74; _i++) {
2848
+ var _f_a = _i;
2849
+ var _f_b = _i + leng;
2850
+ var _f_c = _i + leng + 1;
2851
+ var _f_a2 = _i;
2852
+ var _f_b2 = _i + 1;
2853
+ var _f_c2 = _f_c;
2854
+ var _indices2 = Array.from(MDV.index.array);
2855
+ _indices2.push(_f_a, _f_b, _f_c, _f_c2, _f_b2, _f_a2);
2856
+ MDV.setIndex(_indices2);
2857
+ }
2858
+ var faces = Array.from(MDV.index.array);
2859
+ faces.push(a + 50, a + 3, a + 103, a + 103, a + 150, a + 50);
2860
+ MDV.setIndex(faces);
2861
+ };
2862
+ var fbmFace = function fbmFace(a, leng, MDV) {
2863
+ var total_leng = leng * 4;
2864
+ for (var i = a; i < a + leng - 1; i++) {
2865
+ var f_a1 = i;
2866
+ var f_b1 = (i + leng) % total_leng;
2867
+ var f_c1 = (i + leng + 1) % total_leng;
2868
+ var f_a2 = i;
2869
+ var f_b2 = i + 1;
2870
+ var f_c2 = f_c1;
2871
+ var indices = [];
2872
+ if (MDV.index !== null) {
2873
+ indices = Array.from(MDV.index.array);
2874
+ }
2875
+ indices.push(f_a1, f_b1, f_c1, f_c2, f_b2, f_a2);
2876
+ MDV.setIndex(indices);
2877
+ }
2878
+ };
2879
+ var assignUVs = function assignUVs(geometry) {
2880
+ geometry.computeBoundingBox();
2881
+ var h = 400;
2882
+ var _geometry$boundingBox = geometry.boundingBox,
2883
+ min = _geometry$boundingBox.min,
2884
+ max = _geometry$boundingBox.max;
2885
+ var offset = new Three.Vector2(0 - min.x, 0 - min.z);
2886
+ var range = new Three.Vector2(max.x - min.x, max.z - min.z);
2887
+ geometry.faceVertexUvs[0] = geometry.faces.map(function (face) {
2888
+ var v1 = geometry.vertices[face.a];
2889
+ var v2 = geometry.vertices[face.b];
2890
+ var v3 = geometry.vertices[face.c];
2891
+ return [new Three.Vector2((v1.x + offset.x) / range.x, (v1.z + offset.y) / (range.y + h)), new Three.Vector2((v2.x + offset.x) / range.x, (v2.z + offset.y) / (range.y + h)), new Three.Vector2((v3.x + offset.x) / range.x, (v3.z + offset.y) / (range.y + h))];
2892
+ });
2893
+ geometry.uvsNeedUpdate = true;
2894
+ };
2895
+ var assignUVsA = function assignUVsA(geometry) {
2896
+ geometry.computeBoundingBox();
2897
+ var h = 200;
2898
+ var _geometry$boundingBox2 = geometry.boundingBox,
2899
+ min = _geometry$boundingBox2.min,
2900
+ max = _geometry$boundingBox2.max;
2901
+ var offset = new Three.Vector2(0 - min.x, 0 - min.y);
2902
+ var range = new Three.Vector2(max.x - min.x, max.y - min.y);
2903
+ geometry.faceVertexUvs[0] = geometry.faces.map(function (face) {
2904
+ var v1 = geometry.vertices[face.a];
2905
+ var v2 = geometry.vertices[face.b];
2906
+ var v3 = geometry.vertices[face.c];
2907
+ return [new Three.Vector2((v1.x + offset.x) / (range.x + h), (v1.y + offset.y) / (range.y + h)), new Three.Vector2((v2.x + offset.x) / (range.x + h), (v2.y + offset.y) / (range.y + h)), new Three.Vector2((v3.x + offset.x) / (range.x + h), (v3.y + offset.y) / (range.y + h))];
2908
+ });
2909
+ geometry.uvsNeedUpdate = true;
2910
+ };
2911
+
2912
+ /*
2913
+ Remove specified type of 3d object easily
2914
+ */
2915
+ function deleteSpecifiedMeshObjects(type) {
2916
+ var childLen = planData.plan.children.length;
2917
+ var children = [];
2918
+ for (var i = 0; i < childLen; i++) {
2919
+ if (planData.plan.children[i].name != type) children.push(planData.plan.children[i]);
2920
+ }
2921
+ planData.plan.children = children;
2922
+ }
2923
+ function getMeshesFromScene() {
2924
+ var childLen = planData.plan.children.length;
2925
+ var children = [];
2926
+ for (var i = 0; i < childLen; i++) {
2927
+ if (planData.plan.children[i].type == _constants.OBJTYPE_MESH) children.push(planData.plan.children[i]);
2928
+ }
2929
+ return children;
2930
+ }
2931
+ function threedfabs(a) {
2932
+ return a > 0 ? a : -a;
2933
+ }
2934
+ function getDistanceBetweenLineSegment(pos1, pos2, pos3, pos4) {
2935
+ if (pos1.x == pos2.x && pos3.x == pos4.x) return pos3.x - pos1.x;else if (pos1.y == pos2.y && pos3.y == pos4.y) return pos3.y - pos1.y;else return -1;
2936
+ }
2937
+ function isSimilar(a, b) {
2938
+ if (threedfabs(a - b) <= 0.01) return 1;
2939
+ return 0;
2940
+ }
2941
+ function sameSign(pos1, pos2, pos3) {
2942
+ var ch1 = 0.0;
2943
+ var ch2 = 1.0;
2944
+ if (isSimilar(pos1.x, pos2.x) && isSimilar(pos1.x, pos3.x)) {
2945
+ ch1 = (pos2.y - pos1.y) * (pos3.y - pos1.y);
2946
+ } else if (isSimilar(pos1.y, pos2.y) && isSimilar(pos1.y, pos3.y)) {
2947
+ ch1 = (pos2.x - pos1.x) * (pos3.x - pos1.x);
2948
+ } else {
2949
+ ch1 = (pos2.y - pos1.y) * 1.0 / (pos2.x - pos1.x);
2950
+ ch2 = (pos3.y - pos1.y) * 1.0 / (pos3.x - pos1.x);
2951
+ }
2952
+ if (ch1 * ch2 >= 0) return 1;
2953
+ return 0;
2954
+ }
2955
+ function getTotalDistance(pos, rect) {
2956
+ var sum = 0;
2957
+ for (var i = 0; i < rect.length; i++) {
2958
+ sum += (0, _geometry2.verticesDistance)(pos, rect[i]);
2959
+ }
2960
+ return sum;
2961
+ }
2962
+ var applyTexture = function applyTexture(material, texture, length, height) {
2963
+ if (texture) {
2964
+ material.map = texture;
2965
+ material.needsUpdate = true;
2966
+ material.map.wrapS = Three.RepeatWrapping;
2967
+ material.map.wrapT = Three.RepeatWrapping;
2968
+ material.map.repeat.set(length * 0.01, height * 0.01);
2969
+ if (texture.normal) {
2970
+ material.normalMap = (0, _itemLoader.loadTexture)(texture.normal.uri);
2971
+ material.normalScale = new Vector2(texture.normal.normalScaleX, texture.normal.normalScaleY);
2972
+ material.normalMap.wrapS = Three.RepeatWrapping;
2973
+ material.normalMap.wrapT = Three.RepeatWrapping;
2974
+ material.normalMap.repeat.set(length * texture.normal.lengthRepeatScale, height * texture.normal.heightRepeatScale);
2975
+ }
2976
+ }
2977
+ };
2978
+
2979
+ /**
2980
+ *
2981
+ * @param {{is_corner:number,itemInfo:Item,layoutpos:string,pos:{x:number,y:number},rect:[{x:number,y:number}],
2982
+ * rotRad:number,size:{depth:number,width:number,height:number}}} item
2983
+ * @param {Layer} layer
2984
+ * @param {{boundingBox:Box3,catalog:Catalog,grid: Object3D,plan: Object3D,sceneData: Scene,sceneGraph}} planData
2985
+ * @param {Scene} scene
2986
+ */
2987
+ function createBacksplash(item, layer, planData, scene) {
2988
+ var sceneGraph = planData.sceneGraph;
2989
+ var selectedLayer = planData.sceneData.selectedLayer;
2990
+ /**
2991
+ * @type {[{backsplash,info:{rotY:number,posX:number,posY:number,posZ:number,splashWidth:number,splashHeight:number,splashDepth:number,id:string}}]}
2992
+ */
2993
+ var backsplashes = sceneGraph.layers[selectedLayer].backsplashes;
2994
+ var backsplashApplied = layer.get('backsplashApplied');
2995
+ var name = 'backsplash' + item.itemInfo.id;
2996
+ var index = backsplashes.findIndex(function (item) {
2997
+ return item.backsplash.name === name;
2998
+ });
2999
+ var itemToSave = {
3000
+ backsplash: null,
3001
+ info: {}
3002
+ };
3003
+ if (!item.itemInfo.backsplashVisible) {
3004
+ // If backsplash is not visible
3005
+ if (index >= 0) {
3006
+ backsplashes.splice(index, 1); // Remove from backsplashes array
3007
+ }
3008
+ return;
3009
+ }
3010
+
3011
+ // Get current wall line that item is snapped
3012
+ var wLines = (0, _geometry2.getSnappedWallLines)(item.itemInfo, layer, planData.catalog);
3013
+ var curLine = wLines.length > 0 ? wLines[0] : null;
3014
+
3015
+ // Get wall items which snapped to the curLine
3016
+
3017
+ var i,
3018
+ wallItems = [];
3019
+ var allWallItems = _export.GeometryUtils.getAllItemSpecified(scene, planData.catalog, _constants.WALL_CABINET_LAYOUTPOS, curLine === null || curLine === void 0 ? void 0 : curLine.lineRect);
3020
+ for (i = 0; i < allWallItems.others.length; i++) wallItems.push(allWallItems.others[i]);
3021
+ if (allWallItems.cur) wallItems.push(allWallItems.cur);
3022
+
3023
+ // Get information of item itself
3024
+
3025
+ var altitude = item.itemInfo.properties.get('altitude').get('_length');
3026
+ var altitudeUnit = item.itemInfo.properties.get('altitude').get('_unit') || 'cm';
3027
+ altitude = (0, _convertUnitsLite.convert)(altitude).from(altitudeUnit).to('cm');
3028
+ var thickness = 1,
3029
+ /** Height --- altitude */depth;
3030
+
3031
+ // Calc wall & hole items info
3032
+
3033
+ /**
3034
+ * Wall & Hole items info
3035
+ * @type {[{x:number,width:number,altitude:number}]}
3036
+ */
3037
+ var altItems = [],
3038
+ flag = false;
3039
+ var D0 = {},
3040
+ D1 = {};
3041
+ wallItems.map(function (wallItem) {
3042
+ var _wallItem$itemInfo, _wallItem$itemInfo2;
3043
+ var altitude = (_wallItem$itemInfo = wallItem.itemInfo) === null || _wallItem$itemInfo === void 0 || (_wallItem$itemInfo = _wallItem$itemInfo.properties) === null || _wallItem$itemInfo === void 0 ? void 0 : _wallItem$itemInfo.get('altitude').get('_length');
3044
+ var altitudeUnit = ((_wallItem$itemInfo2 = wallItem.itemInfo) === null || _wallItem$itemInfo2 === void 0 || (_wallItem$itemInfo2 = _wallItem$itemInfo2.properties) === null || _wallItem$itemInfo2 === void 0 ? void 0 : _wallItem$itemInfo2.get('altitude').get('_unit')) || 'cm';
3045
+ if (!(0, _helper.isEmpty)(altitude) && !(0, _helper.isEmpty)(altitudeUnit)) {
3046
+ altitude = (0, _convertUnitsLite.convert)(altitude).from(altitudeUnit).to('cm');
3047
+ var altPoints = (0, _geometry2.getLineSnapPointsOfItem)(layer, curLine, wallItem);
3048
+ if (altPoints.length > 1) {
3049
+ D0 = altPoints[0];
3050
+ D1 = altPoints[1];
3051
+ }
3052
+ altItems.push({
3053
+ D0: D0,
3054
+ // D0, D1: item's snapped points with line
3055
+ D1: D1,
3056
+ x: wallItem.pos.x,
3057
+ width: wallItem.size.width,
3058
+ altitude: altitude
3059
+ });
3060
+ }
3061
+ });
3062
+ layer.holes.map(function (hole) {
3063
+ var _hole$properties, _hole$properties2, _layer$lines, _layer$vertices, _line$vertices, _layer$vertices2, _line$vertices2;
3064
+ var width = (_hole$properties = hole.properties) === null || _hole$properties === void 0 ? void 0 : _hole$properties.getIn(['width', 'length']);
3065
+ var altitude = (_hole$properties2 = hole.properties) === null || _hole$properties2 === void 0 ? void 0 : _hole$properties2.getIn(['altitude', 'length']);
3066
+ var line = (_layer$lines = layer.lines) === null || _layer$lines === void 0 ? void 0 : _layer$lines.get(curLine === null || curLine === void 0 ? void 0 : curLine.id);
3067
+ var v0 = (_layer$vertices = layer.vertices) === null || _layer$vertices === void 0 ? void 0 : _layer$vertices.get(line === null || line === void 0 || (_line$vertices = line.vertices) === null || _line$vertices === void 0 ? void 0 : _line$vertices.get(0));
3068
+ var v1 = (_layer$vertices2 = layer.vertices) === null || _layer$vertices2 === void 0 ? void 0 : _layer$vertices2.get(line === null || line === void 0 || (_line$vertices2 = line.vertices) === null || _line$vertices2 === void 0 ? void 0 : _line$vertices2.get(1));
3069
+ if (!(0, _helper.isEmpty)(v0) || !(0, _helper.isEmpty)(v1)) {
3070
+ var lineLength = (0, _geometry2.pointsDistance)(v0.x, v0.y, v1.x, v1.y);
3071
+ var disD0 = lineLength * hole.offset - width / 2;
3072
+ var disD1 = lineLength * hole.offset + width / 2;
3073
+ D0 = {
3074
+ x: v0.x + disD0 * Math.cos(hole.rotRad),
3075
+ y: v0.y + disD0 * Math.sin(hole.rotRad)
3076
+ };
3077
+ D1 = {
3078
+ x: v0.x + disD1 * Math.cos(hole.rotRad),
3079
+ y: v0.y + disD1 * Math.sin(hole.rotRad)
3080
+ };
3081
+ }
3082
+ if (!(0, _helper.isEmpty)(width) && !(0, _helper.isEmpty)(altitude) && hole.line === (curLine === null || curLine === void 0 ? void 0 : curLine.id)) altItems.push({
3083
+ D0: D0,
3084
+ // D0, D1: hole's two points
3085
+ D1: D1,
3086
+ x: hole.x,
3087
+ width: width,
3088
+ altitude: altitude
3089
+ });
3090
+ });
3091
+ if (altItems.length > 0) {
3092
+ depth = altItems[0].altitude;
3093
+ altItems.map(function (altItem) {
3094
+ if ((0, _geometry2.isOverlappedTwoItemsOnOneLine)(layer, curLine, item, altItem)) {
3095
+ if (depth >= altItem.altitude) {
3096
+ depth = altItem.altitude;
3097
+ flag = true;
3098
+ }
3099
+ }
3100
+ });
3101
+ }
3102
+ var DEFAULT_BACKSPLASH_HEIGHT = 52 * 2.54;
3103
+ if (!flag || depth > DEFAULT_BACKSPLASH_HEIGHT) depth = DEFAULT_BACKSPLASH_HEIGHT;
3104
+
3105
+ // Get backsplash info
3106
+
3107
+ var posX = item.pos.x - Math.sin(item.rotRad) * (item.size.depth / 2 - thickness);
3108
+ var posY = altitude + depth / 2;
3109
+ var posZ = -item.pos.y - Math.cos(item.rotRad) * (item.size.depth / 2 - thickness);
3110
+ // TODO If you want apply backsplash to walls that's not vertical or horizontal ( slope )
3111
+ // You must update this calcuating rotY
3112
+ var rotY = item.rotRad;
3113
+ var posX1 = item.pos.x + Math.cos(item.rotRad) * (item.size.width / 2 - thickness);
3114
+ var posY1 = altitude + depth / 2;
3115
+ var posZ1 = -item.pos.y - Math.sin(item.rotRad) * (item.size.width / 2 - thickness);
3116
+ // TODO If you want apply backsplash to walls that's not vertical or horizontal ( slope )
3117
+ // You must update this calcuating rotY
3118
+ var rotY1 = item.rotRad + Math.PI / 2;
3119
+ var splashWidth = item.size.width;
3120
+ var splashHeight = depth;
3121
+ var splashDepth = thickness;
3122
+
3123
+ // Find mergeable other backsplashes
3124
+
3125
+ // let info,
3126
+ // wholeWidth,
3127
+ // /** Width factor */ factor,
3128
+ // distance,
3129
+ // halfWidth,
3130
+ // /** To get new center */ centerFactor;
3131
+
3132
+ // for (let back of backsplashes) {
3133
+ // info = back.info;
3134
+ // if (info.height === splashHeight && info.rotY === rotY) {
3135
+ // factor = Math.cos(rotY) || 1;
3136
+ // distance = Math.hypot(posX - info.posX, posZ - info.posZ) / factor;
3137
+ // halfWidth = (info.width + splashWidth) / 2;
3138
+
3139
+ // if (Math.abs(distance - halfWidth) < 1e-2) {
3140
+ // // dispose `back`
3141
+ // if (info.id) {
3142
+ // deleteSpecifiedMeshObjects('backsplash' + info.id);
3143
+ // }
3144
+
3145
+ // // Get center position
3146
+ // wholeWidth = info.width + splashWidth;
3147
+ // centerFactor = info.width / wholeWidth;
3148
+ // posX = posX + centerFactor * (info.posX - posX);
3149
+ // posZ = posZ + centerFactor * (info.posZ - posZ);
3150
+
3151
+ // splashWidth = wholeWidth;
3152
+ // }
3153
+ // }
3154
+ // }
3155
+
3156
+ itemToSave.info.posX = posX;
3157
+ itemToSave.info.posY = posY;
3158
+ itemToSave.info.posZ = posZ;
3159
+ itemToSave.info.rotY = rotY;
3160
+ itemToSave.info.width = splashWidth;
3161
+ itemToSave.info.height = splashHeight;
3162
+ itemToSave.info.depth = splashDepth;
3163
+
3164
+ // Make material
3165
+
3166
+ var texture = layer.get('backsplash');
3167
+ var areaMaterial = new Three.MeshStandardMaterial({
3168
+ side: Three.DoubleSide,
3169
+ metalness: texture.metalness,
3170
+ roughness: texture.roughness
3171
+ });
3172
+ var interiortexture = (0, _itemLoader.loadTexture)(texture.uri);
3173
+ applyTexture(areaMaterial, interiortexture, splashWidth * 1.5, splashHeight * 1.5);
3174
+
3175
+ // Make geometry
3176
+ var geometry = new Three.BoxGeometry(splashWidth, splashHeight, splashDepth);
3177
+
3178
+ // Make backsplash mesh
3179
+
3180
+ var backsplash = itemToSave.backsplash = new Three.Mesh(geometry, areaMaterial);
3181
+ backsplash.position.x = itemToSave.info.posX;
3182
+ backsplash.position.y = itemToSave.info.posY;
3183
+ backsplash.position.z = itemToSave.info.posZ;
3184
+ backsplash.rotation.y = itemToSave.info.rotY;
3185
+ var allLines = _export.GeometryUtils.getAllLines(layer);
3186
+ var allLineRects = _export.GeometryUtils.buildRectFromLines(layer, allLines);
3187
+ if (item.is_corner && _export.GeometryUtils.isSnappedSideLine(item, allLineRects)) {
3188
+ // corner cabinet item.itemInfo.getIn(["cabinet_category"]) === "Corner Base Cabinets"
3189
+ var geometry1 = new Three.BoxGeometry(splashWidth, splashHeight, splashDepth);
3190
+ // Make backsplash mesh
3191
+ //console.log(sceneGraph.layers["layer-1"].lines);
3192
+ var backsplash1 = itemToSave.backsplash = new Three.Mesh(geometry1, areaMaterial);
3193
+ backsplash1.position.x = posX1;
3194
+ backsplash1.position.y = posY1;
3195
+ backsplash1.position.z = posZ1;
3196
+ backsplash1.rotation.y = rotY1;
3197
+ var newBacksplash = new _three.Group();
3198
+ newBacksplash.add(backsplash);
3199
+ newBacksplash.add(backsplash1);
3200
+ backsplash = newBacksplash;
3201
+ }
3202
+ itemToSave.info.id = item.itemInfo.id;
3203
+ deleteSpecifiedMeshObjects('backsplash' + item.itemInfo.id);
3204
+ if (Math.abs(item.rotRad % (Math.PI / 2)) < _constants.EPSILON || Math.abs(item.rotRad % (Math.PI / 2) - Math.PI / 2) < _constants.EPSILON) planData.plan.add(backsplash);
3205
+ backsplash.name = name;
3206
+ backsplash.visible = item.itemInfo.get('backsplashVisible') && backsplashApplied && Math.abs(item.rotRad % (Math.PI / 2)) < _constants.EPSILON || Math.abs(item.rotRad % (Math.PI / 2) - Math.PI / 2) < _constants.EPSILON;
3207
+
3208
+ // Save to scene graph
3209
+
3210
+ if (index < 0) {
3211
+ backsplashes.push(itemToSave);
3212
+ } else {
3213
+ (0, _threeMemoryCleaner.disposeObject)(backsplashes[index].backsplash);
3214
+ backsplashes.splice(index, 1, itemToSave);
3215
+ }
3216
+ }
3217
+
3218
+ /**
3219
+ * @param {Map} item - Selected Item
3220
+ */
3221
+ function addMGMesh(molding, planData, layer) {
3222
+ var _molding$molding;
3223
+ var flag = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
3224
+ var point = [];
3225
+ var data = molding === null || molding === void 0 || (_molding$molding = molding.molding) === null || _molding$molding === void 0 ? void 0 : _molding$molding.data;
3226
+ if ((0, _helper.isEmpty)(data)) return;
3227
+ var paths = data.paths,
3228
+ svg_width = data.svg_width,
3229
+ svg_height = data.svg_height;
3230
+ for (var i = 0; i < paths.length; i++) {
3231
+ var path = paths[i];
3232
+ for (var j = 0, jl = path.subPaths.length; j < jl; j++) {
3233
+ var subPath = new Three.Path();
3234
+ if (path.subPaths[j].hasOwnProperty('metadata')) {
3235
+ subPath.fromJSON(path.subPaths[j]);
3236
+ } else {
3237
+ subPath = path.subPaths[j];
3238
+ }
3239
+ point = subPath.getPoints();
3240
+ }
3241
+ }
3242
+ _addMGMesh(molding, planData, layer, point, svg_width, svg_height, flag);
3243
+ }
3244
+ var isBaseCabinet = function isBaseCabinet(item) {
3245
+ return item.layoutpos === _constants.BASE_CABINET_LAYOUTPOS;
3246
+ };
3247
+
3248
+ /**
3249
+ * @param data - Molding SVG Points
3250
+ */
3251
+
3252
+ // function assignUVs
3253
+ function _addMGMesh(molding, planData, layer, data, svg_width, svg_height, flag) {
3254
+ var child = molding.molding;
3255
+ var material = getDoorStyleMaterial(molding.items, planData, layer, child.name);
3256
+ if (!material) return;
3257
+ material = new Three.MeshStandardMaterial(material);
3258
+ // let texture = loadTexture(material.map.image.src);
3259
+ // var material1 = new Three.MeshLambertMaterial( { map:texture } );
3260
+ material.side = parseInt(Three.DoubleSide);
3261
+ // let layoutType = molding.items[0].layoutpos;
3262
+ // let visible = molding.items[0];
3263
+ molding.pointGroups.forEach(function (pointGroup) {
3264
+ var _child$width_unit, _child$height_unit, _child$length_unit;
3265
+ var geometry = new Three.BufferGeometry();
3266
+ var length = data.length; //point array
3267
+ var widthUnit = child.width_unit === 'inch' ? 'in' : (_child$width_unit = child.width_unit) !== null && _child$width_unit !== void 0 ? _child$width_unit : 'in';
3268
+ var heightUnit = child.height_unit === 'inch' ? 'in' : (_child$height_unit = child.height_unit) !== null && _child$height_unit !== void 0 ? _child$height_unit : 'in';
3269
+ var lengthUnit = child.length_unit === 'inch' ? 'in' : (_child$length_unit = child.length_unit) !== null && _child$length_unit !== void 0 ? _child$length_unit : 'in';
3270
+ child.height = (0, _convertUnitsLite.convert)(child.height).from(heightUnit).to('cm');
3271
+ child.height_unit = 'cm';
3272
+ child.width = (0, _convertUnitsLite.convert)(child.width).from(widthUnit).to('cm');
3273
+ child.width_unit = 'cm';
3274
+ child.length = (0, _convertUnitsLite.convert)(child.length).from(lengthUnit).to('cm');
3275
+ child.length_unit = 'cm';
3276
+ geometry.needsUpdate = true;
3277
+ geometry = moldingVertices(pointGroup, geometry, data, child, svg_width, svg_height, molding.pointGroups.length);
3278
+ var total = geometry.attributes.position.count;
3279
+ var len = geometry.attributes.position.count / length;
3280
+ if (!_export.GeometryUtils.samePoints(pointGroup[0], pointGroup[pointGroup.length - 1])) {
3281
+ len--;
3282
+ }
3283
+ for (var i = 0; i < len; i++) {
3284
+ for (var j = i * length; j < (i + 1) * length - 1; j++) {
3285
+ var f_a1 = j;
3286
+ var f_b1 = (j + length) % total;
3287
+ var f_c1 = (j + length + 1) % total;
3288
+ var f_a2 = j;
3289
+ var f_b2 = j + 1;
3290
+ var f_c2 = f_c1;
3291
+ var indices = [];
3292
+ if (geometry.index !== null) {
3293
+ indices = Array.from(geometry.index.array);
3294
+ }
3295
+ indices.push(f_a1, f_b1, f_c1, f_c2, f_b2, f_a2);
3296
+ geometry.setIndex(indices);
3297
+ }
3298
+ }
3299
+
3300
+ // handle molding texture
3301
+ // (0, e[i]) ------------- (1, e[i])
3302
+ // ----------- --- -----------
3303
+ // ----------- --- -----------
3304
+ // ----------- --- -----------
3305
+ // ----------- --- -----------
3306
+ // (0, e[i+1]) ------------- (1, e[i+1])
3307
+ geometry = geometry.toNonIndexed();
3308
+ var sumDistance = 0;
3309
+ var sumDistanceArray = [0];
3310
+ var finalDistance = 0;
3311
+ var uvs_element_array = [];
3312
+ for (var _i2 = 0; _i2 < data.length - 1; _i2++) {
3313
+ var v1 = {
3314
+ x: data[_i2].x,
3315
+ y: data[_i2].y
3316
+ };
3317
+ var v2 = {
3318
+ x: data[_i2 + 1].x,
3319
+ y: data[_i2 + 1].y
3320
+ };
3321
+ var posDistance = (0, _geometry2.verticesDistance)(v1, v2);
3322
+ sumDistance += posDistance;
3323
+ if (_i2 === data.length - 2) finalDistance = sumDistance;
3324
+ sumDistanceArray.push(sumDistance);
3325
+ }
3326
+ for (var _i3 = 0; _i3 < sumDistanceArray.length; _i3++) {
3327
+ uvs_element_array.push(sumDistanceArray[_i3] / finalDistance);
3328
+ }
3329
+ var uvs = [];
3330
+ var uvs_item = [];
3331
+ for (var _i4 = 0; _i4 < uvs_element_array.length - 1; _i4++) {
3332
+ uvs_item = [0, uvs_element_array[_i4], 1, uvs_element_array[_i4], 1, uvs_element_array[_i4 + 1], 1, uvs_element_array[_i4 + 1], 0, uvs_element_array[_i4 + 1], 0, uvs_element_array[_i4]];
3333
+ uvs.push.apply(uvs, (0, _toConsumableArray2["default"])(uvs_item));
3334
+ }
3335
+ var all_uvs = [];
3336
+ for (var _i5 = 0; _i5 < pointGroup.length; _i5++) {
3337
+ all_uvs.push.apply(all_uvs, uvs);
3338
+ }
3339
+ geometry.setAttribute('uv', new Three.BufferAttribute(new Float32Array(all_uvs), 2));
3340
+ geometry.computeVertexNormals();
3341
+ var fbm3d = new Three.Mesh(geometry, material);
3342
+ fbm3d.position.x = molding.pos.x;
3343
+ fbm3d.position.z = -molding.pos.y;
3344
+ fbm3d.position.y = molding.pos.z;
3345
+ planData.plan.add(fbm3d);
3346
+ fbm3d.name = child.name + molding.id + 'molding';
3347
+ molding.meshes.push(fbm3d);
3348
+ fbm3d.visible = true;
3349
+ fbm3d.castShadow = true;
3350
+ });
3351
+ }
3352
+ function deleteCTMesh(countertop, planData, layer) {
3353
+ log('--deleteCTMesh', countertop);
3354
+ if (countertop.items.length == 1) {
3355
+ showItemCT(countertop.items[0], countertop, false, planData, layer);
3356
+ } else {
3357
+ var ct3d = countertop.ct3d;
3358
+ if (ct3d) {
3359
+ planData.plan.remove(ct3d);
3360
+ (0, _threeMemoryCleaner.disposeObject)(ct3d);
3361
+ }
3362
+ }
3363
+ }
3364
+ function deleteMGMesh(molding, planData) {
3365
+ var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
3366
+ // mode is 3D or elevation
3367
+ molding.meshes.forEach(function (mesh) {
3368
+ if ((0, _helper.isElevationView)(mode)) {
3369
+ var _planData$plan$childr;
3370
+ // when elevation mode, remove obj same as selected global molding_name in platnData.plan
3371
+ (_planData$plan$childr = planData.plan.children) === null || _planData$plan$childr === void 0 || _planData$plan$childr.forEach(function (obj) {
3372
+ var parent = obj.parent;
3373
+ if (obj.name.match(mesh.name)) parent.remove(obj);
3374
+ });
3375
+ } else {
3376
+ // when 3D mode
3377
+ planData.plan.remove(mesh);
3378
+ (0, _threeMemoryCleaner.disposeObject)(mesh);
3379
+ }
3380
+ });
3381
+ molding.meshes = [];
3382
+ }
3383
+ function log() {
3384
+ // console.log(...arguments);
3385
+ }
3386
+ function addCountertop(CTArray, addItem, planData, layer) {
3387
+ log('addCountertop', (0, _toConsumableArray2["default"])(CTArray), addItem.id);
3388
+ var tmp = planData;
3389
+ tmp = tmp && tmp.catalog.getElement(addItem.type);
3390
+ if (!tmp) tmp = planData.catalog.getElement((0, _utils.returnReplaceableDeepSearchType)(addItem.type));
3391
+ var long_name = tmp && tmp.long_name;
3392
+ if (long_name.includes('Sink ')) return;
3393
+ var newCT = createCTFromItem(addItem, planData.sceneGraph.unit, planData.catalog);
3394
+ var oldCT = null;
3395
+ var extCT = false;
3396
+ var extCTIndex = -1;
3397
+ var tryMergeCT = function tryMergeCT() {
3398
+ extCTIndex = CTArray.findIndex(function (el) {
3399
+ extCT = tryAdjacent(newCT, el);
3400
+ return extCT != false;
3401
+ });
3402
+ return extCTIndex >= 0;
3403
+ };
3404
+ while (tryMergeCT()) {
3405
+ oldCT = CTArray.splice(extCTIndex, 1)[0];
3406
+ deleteCTMesh(newCT, planData, layer);
3407
+ deleteCTMesh(oldCT, planData, layer);
3408
+ newCT = extCT;
3409
+ }
3410
+ addCTMesh(newCT, planData, layer);
3411
+ CTArray.push(newCT);
3412
+ }
3413
+ function deleteCountertop(CTArray, delItem, planData, layer) {
3414
+ if (delItem == undefined) {
3415
+ return;
3416
+ }
3417
+ log('deleteCountertop', (0, _toConsumableArray2["default"])(CTArray), delItem.id);
3418
+ var delCT = null;
3419
+ var delItemIndex = -1;
3420
+ var delCTIndex = CTArray.findIndex(function (el) {
3421
+ delItemIndex = el.items.findIndex(function (el) {
3422
+ return el.id == delItem.id;
3423
+ });
3424
+ return delItemIndex >= 0;
3425
+ });
3426
+ if (delCTIndex < 0) return;
3427
+ delCT = CTArray.splice(delCTIndex, 1)[0];
3428
+ if (delCT.items.length > 1) {
3429
+ deleteCTMesh(delCT, planData, layer);
3430
+ var ct1 = delCT.items.slice(0, delItemIndex);
3431
+ var ct2 = delCT.items.slice(delItemIndex + 1);
3432
+ [ct1, ct2].forEach(function (cts) {
3433
+ if (cts.length == 0) return;
3434
+ var newCT = createCTFromItems(cts, planData.sceneGraph.unit, planData.catalog);
3435
+ CTArray.push(newCT);
3436
+ addCTMesh(newCT, planData, layer);
3437
+ });
3438
+ }
3439
+ }
3440
+ function deleteAllMolding(MGArray, delItem, planData, oldSceneLayer, newSceneLayer) {
3441
+ var tempMGArray = (0, _toConsumableArray2["default"])(MGArray);
3442
+ if ((0, _helper.isEmpty)(delItem)) {
3443
+ return tempMGArray;
3444
+ }
3445
+
3446
+ // remove the MGs which includes delItem
3447
+ tempMGArray = tempMGArray.filter(function (mg) {
3448
+ if (mg.items.some(function (it) {
3449
+ return it.id === delItem.id;
3450
+ })) {
3451
+ deleteMGMesh(mg, planData, null);
3452
+ return false;
3453
+ } else return true;
3454
+ });
3455
+ if (newSceneLayer !== null) {
3456
+ // find the snapped items with delItem
3457
+ var snappedItems = [];
3458
+ oldSceneLayer.items.toArray().forEach(function (oItem) {
3459
+ if (oItem.category === 'cabinet' && oItem.id !== delItem.id && _export.MoldingUtils.isItemSnappedItem(delItem, oItem)) {
3460
+ snappedItems.push(oItem);
3461
+ }
3462
+ });
3463
+
3464
+ // update molding group array with snapped items in the new scene layer
3465
+ for (var i = 0; i < snappedItems.length; i++) {
3466
+ tempMGArray = updateMoldingGroupArray(tempMGArray, snappedItems[i], planData, newSceneLayer, null, null, 0);
3467
+ }
3468
+ }
3469
+ return tempMGArray;
3470
+ }
3471
+ function addMolding(MGArray, addItem, planData, layer, itemActions, mode) {
3472
+ if (addItem.selected && [_constants.MODE_DRAGGING_ITEM_3D, _constants.MODE_ROTATING_ITEM_3D].includes(mode)) return false;
3473
+
3474
+ // If the item is not available for current doorStyle
3475
+ if ((0, _cabinetWarning.isWarningCabinet)(addItem))
3476
+ // Do not add molding to that item
3477
+ return MGArray;
3478
+
3479
+ // if (
3480
+ // !(
3481
+ // (addItem.layoutpos === BASE_CABINET_LAYOUTPOS &&
3482
+ // !GeometryUtils.isSnappedLine(
3483
+ // MoldingUtils.getItemRect(addItem),
3484
+ // GeometryUtils.buildRectFromLines(
3485
+ // layer,
3486
+ // GeometryUtils.getAllLines(layer)
3487
+ // )
3488
+ // )) ||
3489
+ // ((addItem.layoutpos === WALL_CABINET_LAYOUTPOS ||
3490
+ // addItem.layoutpos === TALL_CABINET_LAYOUTPOS) &&
3491
+ // GeometryUtils.isSnappedLine(
3492
+ // MoldingUtils.getItemRect(addItem),
3493
+ // GeometryUtils.buildRectFromLines(
3494
+ // layer,
3495
+ // GeometryUtils.getAllLines(layer)
3496
+ // )
3497
+ // ))
3498
+ // )
3499
+ // )
3500
+ // return false;
3501
+
3502
+ // update the molding group array.
3503
+ var temp_MGArray = updateMoldingGroupArray(MGArray, addItem, planData, layer, itemActions, mode, 0);
3504
+ temp_MGArray.forEach(function (mg) {
3505
+ var moldingMesh = mg.meshes[0];
3506
+ if ((0, _helper.isElevationView)(mode)) {
3507
+ if (!(0, _helper.isEmpty)(moldingMesh)) {
3508
+ (0, _helper.replaceMeshesWithLineSegments)(moldingMesh);
3509
+ }
3510
+ }
3511
+ });
3512
+ return temp_MGArray;
3513
+ }
3514
+ function updateMoldingGroupArray(MGArray, selItem, planData, layer) {
3515
+ var itemActions = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
3516
+ var mode = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
3517
+ var cnt = arguments.length > 6 ? arguments[6] : undefined;
3518
+ try {
3519
+ cnt++;
3520
+ if (cnt > 500) {
3521
+ console.log('updateMoldingGroupArray has limited!');
3522
+ return MGArray;
3523
+ }
3524
+ var temp_MGArray = (0, _toConsumableArray2["default"])(MGArray);
3525
+ if ((0, _helper.isEmpty)(selItem)) return temp_MGArray;
3526
+ var isEnableMolding = _export.MoldingUtils.isEnableItemForMolding(layer, selItem);
3527
+ // Make a items group with selItem to create the new MG(molding group) array of selItem
3528
+ var itemsForGroup = [selItem];
3529
+ var i = 0;
3530
+ while (i < itemsForGroup.length) {
3531
+ layer.items.toArray().forEach(function (curItem) {
3532
+ if (!itemsForGroup.some(function (it) {
3533
+ return it.id === curItem.id;
3534
+ }) && curItem.category === 'cabinet' && _export.MoldingUtils.isSameMoldingLayoutpos(curItem, itemsForGroup[i]) && _export.MoldingUtils.isItemSnappedItem(itemsForGroup[i], curItem)) {
3535
+ itemsForGroup.push(curItem);
3536
+ }
3537
+ });
3538
+ i++;
3539
+ }
3540
+
3541
+ // Create the new MG(molding group) array of selItem
3542
+ var new_MGArray = _export.MoldingUtils.getAllMoldingGroups(layer, itemsForGroup);
3543
+
3544
+ // get molding settings of update molding from adjoined item's molding
3545
+ var changeMoldings = [];
3546
+ new_MGArray.forEach(function (mg) {
3547
+ if (mg.items.some(function (it) {
3548
+ return it.id === selItem.id;
3549
+ }) && mg.items.length > 1) {
3550
+ var destItem = mg.items.find(function (it) {
3551
+ return it.id !== selItem.id;
3552
+ });
3553
+ var destMolding = destItem.molding.find(function (md) {
3554
+ return md.location_type === mg.location_type;
3555
+ });
3556
+
3557
+ // if current item has not destination molding then set it to the current molding
3558
+ if (!(0, _helper.isEmpty)(destMolding) && !selItem.molding.some(function (md) {
3559
+ return md.location_type === destMolding.location_type;
3560
+ })) {
3561
+ // only update with the same height cabinet or update the bottom molding setting
3562
+ // itemActions.setMolding(destMoldings[i], false);
3563
+ changeMoldings.push(destMolding);
3564
+ } else if ((0, _helper.isEmpty)(destMolding) && selItem.molding.some(function (md) {
3565
+ return md.location_type === mg.location_type;
3566
+ })) {
3567
+ // if current item has more molding than adjoined then remove theses moldings
3568
+ // itemActions.setMolding(selItem.molding[i], false);
3569
+ changeMoldings.push(selItem.molding.find(function (md) {
3570
+ return md.location_type === mg.location_type;
3571
+ }));
3572
+ }
3573
+ }
3574
+ });
3575
+ var regenMGItemList = [];
3576
+ // An old MG and a new MG include a same item && The location_type of Two MGs are same
3577
+ // Then replace the old MG with the new MG
3578
+ temp_MGArray = temp_MGArray.filter(function (oldMG) {
3579
+ var filteredNewMGList = new_MGArray.filter(function (mg) {
3580
+ return mg.location_type === oldMG.location_type;
3581
+ });
3582
+ if ((0, _helper.isEmpty)(filteredNewMGList)) {
3583
+ return true;
3584
+ }
3585
+ var _loop4 = function _loop4() {
3586
+ var newMG = filteredNewMGList[k];
3587
+ if (oldMG.items.some(function (it) {
3588
+ return it.id === selItem.id;
3589
+ })) {
3590
+ // if current action is a seprating item from group, then have to regenerate the MGs of old snapped items
3591
+ if (oldMG.items.filter(function (oIt) {
3592
+ return !newMG.items.some(function (nIt) {
3593
+ return nIt.id === oIt.id;
3594
+ });
3595
+ }).length > 0) {
3596
+ oldMG.items.forEach(function (oIt) {
3597
+ if (oIt.id !== selItem.id && !regenMGItemList.some(function (rIt) {
3598
+ return rIt.id === oIt.id;
3599
+ })) regenMGItemList.push(oIt);
3600
+ });
3601
+ }
3602
+ }
3603
+ // remove the old MG meshes
3604
+ for (var _i6 = 0; _i6 < oldMG.items.length; _i6++) {
3605
+ var oItem = oldMG.items[_i6];
3606
+ for (var j = 0; j < newMG.items.length; j++) {
3607
+ var nItem = newMG.items[j];
3608
+ if (oItem.id === nItem.id) {
3609
+ deleteMGMesh(oldMG, planData, mode);
3610
+ // if (oldMG.items.length > 1) {
3611
+ // // separating item from group
3612
+ // oldMG.items.splice(i, 1);
3613
+ // // update the old molding group info
3614
+ // const mIdx = oldMG.items[0].molding.findIndex(
3615
+ // m => m.location_type == oldMG.location_type
3616
+ // );
3617
+ // if (mIdx >= 0) {
3618
+ // let molding = oldMG.items[0].molding[mIdx];
3619
+ // oldMG = MoldingUtils.createMonldingGroup(
3620
+ // oldMG,
3621
+ // layer,
3622
+ // molding,
3623
+ // planData.catalog
3624
+ // );
3625
+ // addMGMesh(oldMG, planData, layer);
3626
+ // }
3627
+ // return true;
3628
+ // }
3629
+ return {
3630
+ v: false
3631
+ };
3632
+ }
3633
+ }
3634
+ }
3635
+ },
3636
+ _ret;
3637
+ for (var k = 0; k < filteredNewMGList.length; k++) {
3638
+ _ret = _loop4();
3639
+ if (_ret) return _ret.v;
3640
+ }
3641
+ return true;
3642
+ });
3643
+ if (changeMoldings.length === 0 && isEnableMolding) {
3644
+ // refresh mesh of the updating molding groups
3645
+ new_MGArray.forEach(function (mg, index) {
3646
+ var _mg$items$;
3647
+ if ((_mg$items$ = mg.items[0]) !== null && _mg$items$ !== void 0 && (_mg$items$ = _mg$items$.molding) !== null && _mg$items$ !== void 0 && _mg$items$.some(function (mol) {
3648
+ var _mol$toJS;
3649
+ return (0, _helper.isImmutable)(mol) ? (mol === null || mol === void 0 || (_mol$toJS = mol.toJS()) === null || _mol$toJS === void 0 ? void 0 : _mol$toJS.location_type) === mg.location_type : (mol === null || mol === void 0 ? void 0 : mol.location_type) === mg.location_type;
3650
+ })) {
3651
+ var _mg$items$2, _mg$items$3, _mg$items$4;
3652
+ var molding = (0, _helper.isImmutable)((_mg$items$2 = mg.items[0]) === null || _mg$items$2 === void 0 ? void 0 : _mg$items$2.molding) ? (_mg$items$3 = mg.items[0]) === null || _mg$items$3 === void 0 || (_mg$items$3 = _mg$items$3.molding) === null || _mg$items$3 === void 0 ? void 0 : _mg$items$3.filter(function (mol) {
3653
+ var _mol$toJS2;
3654
+ return (mol === null || mol === void 0 || (_mol$toJS2 = mol.toJS()) === null || _mol$toJS2 === void 0 ? void 0 : _mol$toJS2.location_type) === mg.location_type;
3655
+ }).toJS()[0] : (_mg$items$4 = mg.items[0]) === null || _mg$items$4 === void 0 || (_mg$items$4 = _mg$items$4.molding) === null || _mg$items$4 === void 0 ? void 0 : _mg$items$4.filter(function (mol) {
3656
+ return (mol === null || mol === void 0 ? void 0 : mol.location_type) === mg.location_type;
3657
+ })[0];
3658
+ if (mg.molding === null || mg.molding.itemID !== mol.itemID || mg.lines === null || mg.points === null) {
3659
+ var _mg$molding;
3660
+ if (mg.molding !== null && ((_mg$molding = mg.molding) === null || _mg$molding === void 0 ? void 0 : _mg$molding.itemID) !== molding.itemID) {
3661
+ deleteMGMesh(mg, planData, mode);
3662
+ }
3663
+ mg = _export.MoldingUtils.createMonldingGroup(mg, layer, molding, planData.catalog);
3664
+ }
3665
+ if (!mg.meshes.length) {
3666
+ addMGMesh(mg, planData, layer);
3667
+ }
3668
+ } else {
3669
+ deleteMGMesh(mg, planData, mode);
3670
+ }
3671
+ });
3672
+ }
3673
+ new_MGArray.forEach(function (mg) {
3674
+ return temp_MGArray.push(mg);
3675
+ });
3676
+ regenMGItemList.forEach(function (it) {
3677
+ temp_MGArray = updateMoldingGroupArray(temp_MGArray, it, planData, layer, itemActions, mode, cnt);
3678
+ });
3679
+ if (changeMoldings.length > 0 && itemActions !== null) {
3680
+ setTimeout(function () {
3681
+ changeMoldings.forEach(function (chMolding) {
3682
+ itemActions.setMolding(chMolding, false);
3683
+ });
3684
+ }, 200);
3685
+ }
3686
+ return temp_MGArray;
3687
+ } catch (e) {
3688
+ console.log('updateMoldingGroupArray catched :', e);
3689
+ return MGArray;
3690
+ }
3691
+ }
3692
+ function removeSelItemMesh(MGArray, selItem, planData, mode) {
3693
+ if (selItem) {
3694
+ if (!selItem.selected) {
3695
+ return;
3696
+ }
3697
+ MGArray.forEach(function (mg) {
3698
+ if (mg.items.some(function (it) {
3699
+ return it.id === selItem.id;
3700
+ })) deleteMGMesh(mg, planData, mode);
3701
+ });
3702
+ }
3703
+ }
3704
+
3705
+ /**
3706
+ * Flip door handle
3707
+ * @param item Scene state item ( redux )
3708
+ * @param item3D Mesh
3709
+ * @param {Boolean} flip Determines handle position.
3710
+ * @note When `flip` is set
3711
+ *
3712
+ * `true`
3713
+ * * Left side door - use left handle (LL)
3714
+ * * Right side door - use right handle (RR)
3715
+ *
3716
+ * `false`
3717
+ * * Left side door - use right handle (LR)
3718
+ * * Right side door - use left handle (RL)
3719
+ *
3720
+ * And one-door-cabinet is the same case with the left door of two-door-cabinet
3721
+ */
3722
+ function updateDoorHandleMesh(_, item3D, flip) {
3723
+ if (!item3D) {
3724
+ console.error('Item mesh is undefined.');
3725
+ return;
3726
+ }
3727
+
3728
+ /**
3729
+ * Mesh whose name pass this regexp is a place holder for a door
3730
+ * which is the parent or grand parent of a door mesh and its handles
3731
+ */
3732
+ var doorReg = /ph_.*[^(drawer)]_door(?:_(L|R))?(?:_[1-9])?$/;
3733
+ var doorHandleReg = /ph_.*_door_.*_handle_(L|R)?(_[1-9])?/;
3734
+ item3D.traverse(function (child) {
3735
+ /**
3736
+ * Hold the name of the place holder for door and its position
3737
+ * @type {[string,"L"|"R"|undefined]}
3738
+ */
3739
+ var doorRegResult = doorReg.exec(child.name);
3740
+ if (doorRegResult) {
3741
+ // `child` is place holder for door mesh, and also grand parent of on[0]e
3742
+ var phDoor = child.children[0];
3743
+ if (!phDoor) {
3744
+ return console.error('Group is no valid.');
3745
+ }
3746
+ var doorHandle = null;
3747
+ var phRight = null;
3748
+ var phLeft = null;
3749
+
3750
+ // Find door_handle, ph_left, ph_right 3D item
3751
+ phDoor.traverse(function (childOfDoor) {
3752
+ /**
3753
+ * @type {[string, "L"|"R"]}
3754
+ */
3755
+ var result = doorHandleReg.exec(childOfDoor.name);
3756
+ if (result !== null) {
3757
+ // `childOfDoor` is place holder for door handle
3758
+
3759
+ switch (result[1]) {
3760
+ case 'L':
3761
+ phLeft = childOfDoor;
3762
+ break;
3763
+ case 'R':
3764
+ phRight = childOfDoor;
3765
+ break;
3766
+ default:
3767
+ console.error('Place holder type should be L or R.');
3768
+ return;
3769
+ }
3770
+ if (childOfDoor.children.length !== 0) {
3771
+ // It has a door handle
3772
+ doorHandle = childOfDoor.children[0];
3773
+ }
3774
+ }
3775
+ });
3776
+
3777
+ // Change door handle position
3778
+ if (doorHandle && phLeft && phRight) {
3779
+ // Remove handles for re-addition
3780
+ if (phLeft.children.length) {
3781
+ phLeft.remove(doorHandle);
3782
+ }
3783
+ if (phRight.children.length) {
3784
+ phRight.remove(doorHandle);
3785
+ }
3786
+ switch (doorRegResult[1]) {
3787
+ case undefined: // Single door cabinet
3788
+ case 'R':
3789
+ // Right side door
3790
+ (flip ? phRight : phLeft).add(doorHandle);
3791
+ break;
3792
+ case 'L':
3793
+ // Left side door
3794
+ (flip ? phLeft : phRight).add(doorHandle);
3795
+ break;
3796
+ }
3797
+ } else {
3798
+ console.error('door_handle or ph_left or ph_right is null.');
3799
+ }
3800
+ }
3801
+ });
3802
+ }
3803
+ function addWarningBox(itemId, altitude, planData) {
3804
+ deleteSpecifiedMeshObjects('WarningBox' + itemId);
3805
+ var item3D = planData.sceneGraph.layers[planData.sceneData.selectedLayer].items[itemId];
3806
+ if (item3D == undefined) return;
3807
+ var altitudeLength = altitude;
3808
+ var sBounding = item3D.children[0].userData;
3809
+ var width = sBounding.max.x - sBounding.min.x;
3810
+ var height = sBounding.max.y - sBounding.min.y;
3811
+ var depth = sBounding.max.z - sBounding.min.z;
3812
+ var warnBoxGeom = new Three.BoxGeometry(width, height, depth);
3813
+ var warnBoxObj = new Three.Mesh(warnBoxGeom, new Three.MeshBasicMaterial({
3814
+ color: 0xff2200,
3815
+ opacity: 0.8,
3816
+ transparent: true,
3817
+ blending: Three.MultiplyBlending
3818
+ }));
3819
+ var box = new Three.BoxHelper(warnBoxObj, 0x000000);
3820
+ box.material.linewidth = 2;
3821
+ box.material.depthTest = false;
3822
+ box.renderOrder = 200;
3823
+ warnBoxObj.add(box);
3824
+ warnBoxObj.position.set(item3D.position.x, altitudeLength + item3D.position.y + height / 2, item3D.position.z);
3825
+ warnBoxObj.rotation.set(item3D.rotation.x, item3D.rotation.y, item3D.rotation.z);
3826
+ warnBoxObj.name = 'WarningBox' + itemId;
3827
+ // planData.plan.add(warnBoxObj);
3828
+ }
3829
+ function checkCabinetOverlap(itemPos, itemRect, holeItems, planData) {
3830
+ if (holeItems.length) {
3831
+ var depth = itemRect.size.depth;
3832
+ var i;
3833
+ for (i = 0; i < holeItems.length; i++) {
3834
+ var hole = holeItems[i];
3835
+ var holeAlti = hole.altitude;
3836
+ if (holeAlti >= depth) continue;
3837
+ if (Math.abs(Math.sin(itemRect.rotRad)) === 1) {
3838
+ if (itemPos.y + itemRect.size.width / 2 >= hole.y - hole.width / 2 && itemPos.y - itemRect.size.width / 2 <= hole.y + hole.width / 2 && (itemRect.rotRad == 0 || itemRect.rotRad == -Math.PI / 2 ? itemPos.x <= hole.x && itemPos.x + itemRect.size.height >= hole.x : itemPos.x >= hole.x && itemPos.x - itemRect.size.height <= hole.x)) break;
3839
+ } else {
3840
+ if (itemPos.x + itemRect.size.width / 2 >= hole.x - hole.width / 2 && itemPos.x - itemRect.size.width / 2 <= hole.x + hole.width / 2 && (itemRect.rotRad == 0 || itemRect.rotRad == -Math.PI / 2 ? itemPos.y <= hole.y && itemPos.y + itemRect.size.height >= hole.y : itemPos.y >= hole.y && itemPos.y - itemRect.size.height <= hole.y)) break;
3841
+ }
3842
+ }
3843
+ if (i != holeItems.length) {
3844
+ var altitude = itemRect.itemInfo.properties.get('altitude').get('_length');
3845
+ var altitudeUnit = itemRect.itemInfo.properties.get('altitude').get('_unit') || 'cm';
3846
+ altitude = (0, _convertUnitsLite.convert)(altitude).from(altitudeUnit).to('cm');
3847
+ addWarningBox(itemRect.itemInfo.id, altitude, planData);
3848
+ }
3849
+ }
3850
+ }