kitchen-simulator 7.0.9-react-18 → 10.0.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 (700) hide show
  1. package/es/AppContext.js +1 -4
  2. package/es/LiteKitchenConfigurator.js +67 -23
  3. package/es/LiteRenderer.js +15 -100
  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/catalog.js +0 -2
  13. package/es/catalog/factories/area-factory-3d.js +1 -5
  14. package/es/catalog/factories/wall-factory.js +1 -1
  15. package/es/catalog/holes/door-double/door_double.png +0 -0
  16. package/es/catalog/holes/door-panic/panicDoor.png +0 -0
  17. package/es/catalog/holes/door-panic-double/panicDoorDouble.png +0 -0
  18. package/es/catalog/holes/gate/gate.jpg +0 -0
  19. package/es/catalog/holes/window-clear/texture.png +0 -0
  20. package/es/catalog/holes/window-cross/texture.png +0 -0
  21. package/es/catalog/holes/window-double-hung/texture.png +0 -0
  22. package/es/catalog/holes/window-vertical/texture.png +0 -0
  23. package/es/catalog/utils/exporter.js +4 -0
  24. package/es/catalog/utils/item-loader.js +3 -22
  25. package/es/class/area.js +0 -1
  26. package/es/class/export.js +1 -3
  27. package/es/class/item.js +180 -86
  28. package/es/class/project.js +17 -21
  29. package/es/components/content.js +3 -1
  30. package/es/components/export.js +3 -5
  31. package/es/components/style/export.js +2 -28
  32. package/es/components/style/form-number-input.js +34 -43
  33. package/es/components/viewer2d/group.js +12 -7
  34. package/es/components/viewer2d/item.js +160 -168
  35. package/es/components/viewer2d/line.js +18 -51
  36. package/es/components/viewer2d/rulerX.js +3 -0
  37. package/es/components/viewer2d/rulerY.js +3 -0
  38. package/es/components/viewer2d/scene.js +67 -47
  39. package/es/components/viewer2d/state.js +1 -1
  40. package/es/components/viewer2d/viewer2d.js +564 -506
  41. package/es/components/viewer3d/front3D.js +1 -2
  42. package/es/components/viewer3d/pointer-lock-navigation.js +0 -90
  43. package/es/components/viewer3d/scene-creator.js +80 -47
  44. package/es/components/viewer3d/three-memory-cleaner.js +0 -14
  45. package/es/components/viewer3d/viewer3d-first-person.js +132 -134
  46. package/es/components/viewer3d/viewer3d.js +37 -22
  47. package/es/constants/catalog/skinPanel.js +9 -0
  48. package/es/constants.js +18 -7
  49. package/es/{WorkSpaceOriginal.js → devLiteRenderer.js} +228 -174
  50. package/es/events/external/handleExternalEvent.js +140 -0
  51. package/es/{utils/isolate-event-handler.js → events/external/handleExternalEvent.util.js} +87 -593
  52. package/es/events/external/handlers.addItem.js +47 -0
  53. package/es/events/external/handlers.changeDoorStyle.js +139 -0
  54. package/es/events/external/handlers.elementOps.js +8 -0
  55. package/es/events/external/handlers.finishing.js +26 -0
  56. package/es/events/external/handlers.hole.js +4 -0
  57. package/es/events/external/handlers.loadProject.js +128 -0
  58. package/es/events/external/handlers.molding.js +24 -0
  59. package/es/events/external/handlers.projectLifecycle.js +11 -0
  60. package/es/events/external/handlers.projectSettings.js +32 -0
  61. package/es/events/external/handlers.replaceCabinet.js +41 -0
  62. package/es/events/external/handlers.roomShape.js +8 -0
  63. package/es/events/external/handlers.syncScene.js +21 -0
  64. package/es/events/external/handlers.updateSelectedElements.js +11 -0
  65. package/es/events/external/handlers.viewMode.js +11 -0
  66. package/es/events/external/handlers.viewerNavigation.js +108 -0
  67. package/es/events/external/handlers.wall.js +7 -0
  68. package/es/index.js +37 -84
  69. package/es/mappings/external-events/mapExternalEventPayload.js +28 -0
  70. package/es/mappings/external-events/mappers/addItemMapper.js +95 -0
  71. package/es/mappings/external-events/mappers/ccdfMapper.js +86 -0
  72. package/es/mappings/external-events/mappers/ccdfToCDSMapper.js +31 -0
  73. package/es/mappings/external-events/mappers/changeDoorStyleMapper.js +37 -0
  74. package/es/mappings/external-events/mappers/loadProjectMapper.js +62 -0
  75. package/es/mappings/holesToCatalog.js +139 -0
  76. package/es/models.js +16 -1
  77. package/es/plugins/keyboard.js +1 -1
  78. package/es/reducers/export.js +2 -4
  79. package/es/reducers/items-reducer.js +4 -2
  80. package/es/reducers/project-reducer.js +1 -1
  81. package/es/reducers/reducer.js +2 -3
  82. package/es/reducers/viewer2d-reducer.js +0 -2
  83. package/es/shared/objects/immutable.js +3 -0
  84. package/es/utils/convert-units-lite.js +9 -0
  85. package/es/utils/geometry.js +598 -78
  86. package/es/utils/helper.js +45 -30
  87. package/es/utils/history.js +13 -1
  88. package/es/utils/molding.js +12 -241
  89. package/es/utils/name-generator.js +0 -3
  90. package/es/utils/skinPanelEngine.js +526 -0
  91. package/lib/@history.js +11 -0
  92. package/lib/AppContext.js +11 -0
  93. package/lib/LiteKitchenConfigurator.js +527 -0
  94. package/lib/LiteRenderer.js +323 -0
  95. package/lib/actions/area-actions.js +21 -0
  96. package/lib/actions/export.js +36 -0
  97. package/lib/actions/groups-actions.js +107 -0
  98. package/lib/actions/holes-actions.js +140 -0
  99. package/lib/actions/items-actions.js +383 -0
  100. package/lib/actions/lines-actions.js +98 -0
  101. package/lib/actions/project-actions.js +351 -0
  102. package/lib/actions/scene-actions.js +43 -0
  103. package/lib/actions/vertices-actions.js +35 -0
  104. package/lib/actions/viewer2d-actions.js +73 -0
  105. package/lib/actions/viewer3d-actions.js +32 -0
  106. package/lib/analytics/ga4.js +194 -0
  107. package/lib/analytics/posthog.js +68 -0
  108. package/lib/assets/Window.hdr +2100 -0
  109. package/lib/assets/brown_photostudio_02_1k.hdr +0 -0
  110. package/lib/assets/fonts/Rene Bieder Milliard Black Italic.woff +0 -0
  111. package/lib/assets/fonts/Rene Bieder Milliard Black.woff +0 -0
  112. package/lib/assets/fonts/Rene Bieder Milliard Bold Italic.woff +0 -0
  113. package/lib/assets/fonts/Rene Bieder Milliard Bold.woff +0 -0
  114. package/lib/assets/fonts/Rene Bieder Milliard Book Italic.woff +0 -0
  115. package/lib/assets/fonts/Rene Bieder Milliard Book.woff +0 -0
  116. package/lib/assets/fonts/Rene Bieder Milliard ExtraBold Italic.woff +0 -0
  117. package/lib/assets/fonts/Rene Bieder Milliard ExtraBold.woff +0 -0
  118. package/lib/assets/fonts/Rene Bieder Milliard ExtraLight Italic.woff +0 -0
  119. package/lib/assets/fonts/Rene Bieder Milliard ExtraLight.woff +0 -0
  120. package/lib/assets/fonts/Rene Bieder Milliard Hairline Italic.woff +0 -0
  121. package/lib/assets/fonts/Rene Bieder Milliard Hairline.woff +0 -0
  122. package/lib/assets/fonts/Rene Bieder Milliard Heavy Italic.woff +0 -0
  123. package/lib/assets/fonts/Rene Bieder Milliard Heavy.woff +0 -0
  124. package/lib/assets/fonts/Rene Bieder Milliard Light Italic.woff +0 -0
  125. package/lib/assets/fonts/Rene Bieder Milliard Light.woff +0 -0
  126. package/lib/assets/fonts/Rene Bieder Milliard Medium Italic.woff +0 -0
  127. package/lib/assets/fonts/Rene Bieder Milliard Medium.woff +0 -0
  128. package/lib/assets/fonts/Rene Bieder Milliard SemiBold Italic.woff +0 -0
  129. package/lib/assets/fonts/Rene Bieder Milliard SemiBold.woff +0 -0
  130. package/lib/assets/fonts/Rene Bieder Milliard Thin Italic.woff +0 -0
  131. package/lib/assets/fonts/Rene Bieder Milliard Thin.woff +0 -0
  132. package/lib/assets/fonts/style.css +177 -0
  133. package/lib/assets/gltf/door_closet.gltf +1 -0
  134. package/lib/assets/gltf/door_exterior.gltf +1 -0
  135. package/lib/assets/gltf/door_interior.gltf +1 -0
  136. package/lib/assets/gltf/door_sliding.gltf +1 -0
  137. package/lib/assets/gltf/doorway_framed.bin +0 -0
  138. package/lib/assets/gltf/doorway_framed.fbx +0 -0
  139. package/lib/assets/gltf/doorway_framed.gltf +1 -0
  140. package/lib/assets/gltf/window_clear.bin +0 -0
  141. package/lib/assets/gltf/window_clear.fbx +0 -0
  142. package/lib/assets/gltf/window_clear.gltf +1 -0
  143. package/lib/assets/gltf/window_cross.bin +0 -0
  144. package/lib/assets/gltf/window_cross.fbx +0 -0
  145. package/lib/assets/gltf/window_cross.gltf +1 -0
  146. package/lib/assets/gltf/window_double_hung.bin +0 -0
  147. package/lib/assets/gltf/window_double_hung.fbx +0 -0
  148. package/lib/assets/gltf/window_double_hung.gltf +1 -0
  149. package/lib/assets/gltf/window_vertical.bin +0 -0
  150. package/lib/assets/gltf/window_vertical.fbx +0 -0
  151. package/lib/assets/gltf/window_vertical.gltf +1 -0
  152. package/lib/assets/img/TKC_thumbnail.png +0 -0
  153. package/lib/assets/img/Toggle.png +0 -0
  154. package/lib/assets/img/default/maple.jpg +0 -0
  155. package/lib/assets/img/default/steel.jpg +0 -0
  156. package/lib/assets/img/loading/loading.gif +0 -0
  157. package/lib/assets/img/loading/loading_1.svg +11 -0
  158. package/lib/assets/img/loading_large.gif +0 -0
  159. package/lib/assets/img/png/door/closet.png +0 -0
  160. package/lib/assets/img/png/door/doorwaysframed.png +0 -0
  161. package/lib/assets/img/png/door/doorwaysframeles.png +0 -0
  162. package/lib/assets/img/png/door/doorwaysframeless.png +0 -0
  163. package/lib/assets/img/png/door/exterior.png +0 -0
  164. package/lib/assets/img/png/door/interior.png +0 -0
  165. package/lib/assets/img/png/door/sliding.png +0 -0
  166. package/lib/assets/img/png/helper/outcome.png +0 -0
  167. package/lib/assets/img/project_img.png +0 -0
  168. package/lib/assets/img/rta/rta_logo_box_blue.jpg +0 -0
  169. package/lib/assets/img/rta/rta_logo_box_blue_ico.jpg +0 -0
  170. package/lib/assets/img/rta/rta_logo_box_blue_ico.svg +55 -0
  171. package/lib/assets/img/rta/rta_logo_box_darkGray.jpg +0 -0
  172. package/lib/assets/img/rta/rta_logo_box_lightblue.png +0 -0
  173. package/lib/assets/img/rta/rta_logo_box_lightmaroon.png +0 -0
  174. package/lib/assets/img/rta/rta_logo_box_maroon.png +0 -0
  175. package/lib/assets/img/rta/rta_logo_box_white.png +0 -0
  176. package/lib/assets/img/rta_menu.png +0 -0
  177. package/lib/assets/img/step2.jpg +0 -0
  178. package/lib/assets/img/step3.jpg +0 -0
  179. package/lib/assets/img/step4.jpg +0 -0
  180. package/lib/assets/img/step5.jpg +0 -0
  181. package/lib/assets/img/step6.jpg +0 -0
  182. package/lib/assets/img/step7.jpg +0 -0
  183. package/lib/assets/img/step8.jpg +0 -0
  184. package/lib/assets/img/svg/2d_delete_object.svg +33 -0
  185. package/lib/assets/img/svg/2d_delete_object1.svg +33 -0
  186. package/lib/assets/img/svg/2d_lock_object.svg +33 -0
  187. package/lib/assets/img/svg/3d_item_move.svg +106 -0
  188. package/lib/assets/img/svg/3d_item_rotation.svg +76 -0
  189. package/lib/assets/img/svg/3d_item_warning_edit.svg +77 -0
  190. package/lib/assets/img/svg/3d_item_warning_info.svg +81 -0
  191. package/lib/assets/img/svg/accessories.svg +4 -0
  192. package/lib/assets/img/svg/angle_icon.svg +39 -0
  193. package/lib/assets/img/svg/blank_div.svg +14 -0
  194. package/lib/assets/img/svg/bottombar/2d3d_button.svg +3 -0
  195. package/lib/assets/img/svg/bottombar/2d3d_button_active.svg +3 -0
  196. package/lib/assets/img/svg/bottombar/2d3d_toggle.svg +4 -0
  197. package/lib/assets/img/svg/bottombar/2d3d_toggle_active.svg +4 -0
  198. package/lib/assets/img/svg/bottombar/arrow-down.svg +3 -0
  199. package/lib/assets/img/svg/bottombar/arrow-left.svg +3 -0
  200. package/lib/assets/img/svg/bottombar/arrow-minus.svg +3 -0
  201. package/lib/assets/img/svg/bottombar/arrow-plus.svg +11 -0
  202. package/lib/assets/img/svg/bottombar/arrow-right.svg +3 -0
  203. package/lib/assets/img/svg/bottombar/arrow-up.svg +3 -0
  204. package/lib/assets/img/svg/bottombar/collapse.svg +3 -0
  205. package/lib/assets/img/svg/bottombar/elevation-back.svg +6 -0
  206. package/lib/assets/img/svg/bottombar/elevation-front.svg +6 -0
  207. package/lib/assets/img/svg/bottombar/elevation-left.svg +6 -0
  208. package/lib/assets/img/svg/bottombar/elevation-right.svg +7 -0
  209. package/lib/assets/img/svg/bottombar/elevation.svg +13 -0
  210. package/lib/assets/img/svg/bottombar/expand.svg +3 -0
  211. package/lib/assets/img/svg/bottombar/help.svg +72 -0
  212. package/lib/assets/img/svg/bottombar/incm_toggle.svg +39 -0
  213. package/lib/assets/img/svg/bottombar/pan_1.svg +57 -0
  214. package/lib/assets/img/svg/bottombar/pan_2.svg +27 -0
  215. package/lib/assets/img/svg/bottombar/pan_3.svg +27 -0
  216. package/lib/assets/img/svg/bottombar/pan_4.svg +27 -0
  217. package/lib/assets/img/svg/bottombar/pan_5.svg +27 -0
  218. package/lib/assets/img/svg/bottombar/settings.svg +23 -0
  219. package/lib/assets/img/svg/bottombar/spin-down.svg +76 -0
  220. package/lib/assets/img/svg/bottombar/spin-left.svg +75 -0
  221. package/lib/assets/img/svg/bottombar/spin-right.svg +75 -0
  222. package/lib/assets/img/svg/bottombar/spin-up.svg +76 -0
  223. package/lib/assets/img/svg/bottombar/spin_1.svg +48 -0
  224. package/lib/assets/img/svg/bottombar/spin_2.svg +31 -0
  225. package/lib/assets/img/svg/bottombar/spin_3.svg +31 -0
  226. package/lib/assets/img/svg/bottombar/spin_4.svg +31 -0
  227. package/lib/assets/img/svg/bottombar/spin_5.svg +31 -0
  228. package/lib/assets/img/svg/bottombar/zoomin.svg +29 -0
  229. package/lib/assets/img/svg/bottombar/zoomout.svg +26 -0
  230. package/lib/assets/img/svg/check.svg +10 -0
  231. package/lib/assets/img/svg/close.svg +11 -0
  232. package/lib/assets/img/svg/color/Black.svg +3 -0
  233. package/lib/assets/img/svg/color/Blue.svg +3 -0
  234. package/lib/assets/img/svg/color/Cream.svg +3 -0
  235. package/lib/assets/img/svg/color/Gray.svg +3 -0
  236. package/lib/assets/img/svg/color/Green.svg +3 -0
  237. package/lib/assets/img/svg/color/White.svg +3 -0
  238. package/lib/assets/img/svg/color/White.svg.bak +3 -0
  239. package/lib/assets/img/svg/color/stone2.jpg +0 -0
  240. package/lib/assets/img/svg/color/wood2.jpg +0 -0
  241. package/lib/assets/img/svg/copy.svg +11 -0
  242. package/lib/assets/img/svg/delete.svg +3 -0
  243. package/lib/assets/img/svg/detail.svg +77 -0
  244. package/lib/assets/img/svg/disclaimer/background.svg +758 -0
  245. package/lib/assets/img/svg/disclaimer/logo-dots.svg +11 -0
  246. package/lib/assets/img/svg/door/Closet.svg +11 -0
  247. package/lib/assets/img/svg/door/Exterior.svg +5 -0
  248. package/lib/assets/img/svg/door/Framed_dorway.svg +5 -0
  249. package/lib/assets/img/svg/door/Frameless_dorway.svg +5 -0
  250. package/lib/assets/img/svg/door/Interior.svg +7 -0
  251. package/lib/assets/img/svg/door/Sliding.svg +5 -0
  252. package/lib/assets/img/svg/doors_closet.svg +47 -0
  253. package/lib/assets/img/svg/doors_exterior.svg +25 -0
  254. package/lib/assets/img/svg/doors_interior.svg +29 -0
  255. package/lib/assets/img/svg/doors_patio.svg +26 -0
  256. package/lib/assets/img/svg/duplicate.svg +11 -0
  257. package/lib/assets/img/svg/duplicate_object_left.svg +32 -0
  258. package/lib/assets/img/svg/duplicate_object_right.svg +32 -0
  259. package/lib/assets/img/svg/filtersActive.svg +19 -0
  260. package/lib/assets/img/svg/firstsetting/L.svg +3 -0
  261. package/lib/assets/img/svg/firstsetting/L2.svg +3 -0
  262. package/lib/assets/img/svg/firstsetting/Open.svg +3 -0
  263. package/lib/assets/img/svg/firstsetting/Square.svg +3 -0
  264. package/lib/assets/img/svg/firstsetting/bar-active.svg +9 -0
  265. package/lib/assets/img/svg/firstsetting/bar-normal.svg +3 -0
  266. package/lib/assets/img/svg/firstsetting/bullet-current.svg +3 -0
  267. package/lib/assets/img/svg/firstsetting/bullet-done.svg +3 -0
  268. package/lib/assets/img/svg/firstsetting/bullet-not-done.svg +3 -0
  269. package/lib/assets/img/svg/firstsetting/check-active.svg +3 -0
  270. package/lib/assets/img/svg/firstsetting/check-normal.svg +3 -0
  271. package/lib/assets/img/svg/firstsetting/pencil.svg +11 -0
  272. package/lib/assets/img/svg/green_checkmark.svg +27 -0
  273. package/lib/assets/img/svg/headerbar/assist.svg +3 -0
  274. package/lib/assets/img/svg/headerbar/cart.svg +3 -0
  275. package/lib/assets/img/svg/headerbar/check.svg +10 -0
  276. package/lib/assets/img/svg/headerbar/consult_designer.svg +45 -0
  277. package/lib/assets/img/svg/headerbar/edit_name.svg +26 -0
  278. package/lib/assets/img/svg/headerbar/file-dollar.svg +13 -0
  279. package/lib/assets/img/svg/headerbar/hamburger_menu.svg +32 -0
  280. package/lib/assets/img/svg/headerbar/plus.svg +11 -0
  281. package/lib/assets/img/svg/headerbar/review_quote.svg +44 -0
  282. package/lib/assets/img/svg/headerbar/ruler-measure.svg +11 -0
  283. package/lib/assets/img/svg/headerbar/save.svg +3 -0
  284. package/lib/assets/img/svg/headerbar/setting.svg +75 -0
  285. package/lib/assets/img/svg/help/check.svg +10 -0
  286. package/lib/assets/img/svg/help/search.svg +76 -0
  287. package/lib/assets/img/svg/intro/1-start-with-floorplan-whole.svg +27 -0
  288. package/lib/assets/img/svg/intro/1-start-with-floorplan.svg +26 -0
  289. package/lib/assets/img/svg/intro/2-start-from-scratch-whole.svg +28 -0
  290. package/lib/assets/img/svg/intro/2-start-from-scratch.svg +27 -0
  291. package/lib/assets/img/svg/intro/3-retrieve-project-whole.svg +19 -0
  292. package/lib/assets/img/svg/intro/3-retrieve-project.svg +18 -0
  293. package/lib/assets/img/svg/invert.svg +127 -0
  294. package/lib/assets/img/svg/lefttoolbar/appliance-active.svg +13 -0
  295. package/lib/assets/img/svg/lefttoolbar/appliance.svg +13 -0
  296. package/lib/assets/img/svg/lefttoolbar/cabinet-active.svg +10 -0
  297. package/lib/assets/img/svg/lefttoolbar/cabinet-category.svg +3 -0
  298. package/lib/assets/img/svg/lefttoolbar/cabinet-one.svg +3 -0
  299. package/lib/assets/img/svg/lefttoolbar/cabinet.svg +10 -0
  300. package/lib/assets/img/svg/lefttoolbar/disigner_assistance.svg +89 -0
  301. package/lib/assets/img/svg/lefttoolbar/door-style-active.svg +20 -0
  302. package/lib/assets/img/svg/lefttoolbar/door-style.svg +20 -0
  303. package/lib/assets/img/svg/lefttoolbar/door.svg +12 -0
  304. package/lib/assets/img/svg/lefttoolbar/error_icon.svg +81 -0
  305. package/lib/assets/img/svg/lefttoolbar/finishing-active.svg +13 -0
  306. package/lib/assets/img/svg/lefttoolbar/finishing.svg +13 -0
  307. package/lib/assets/img/svg/lefttoolbar/reviewforquote-active.svg +86 -0
  308. package/lib/assets/img/svg/lefttoolbar/reviewforquote.svg +12 -0
  309. package/lib/assets/img/svg/lefttoolbar/room-shape-L.svg +3 -0
  310. package/lib/assets/img/svg/lefttoolbar/room-shape-active.svg +18 -0
  311. package/lib/assets/img/svg/lefttoolbar/room-shape-custom.svg +12 -0
  312. package/lib/assets/img/svg/lefttoolbar/room-shape-irregular.svg +3 -0
  313. package/lib/assets/img/svg/lefttoolbar/room-shape-open.svg +3 -0
  314. package/lib/assets/img/svg/lefttoolbar/room-shape-square.svg +3 -0
  315. package/lib/assets/img/svg/lefttoolbar/room-shape.svg +18 -0
  316. package/lib/assets/img/svg/lefttoolbar/search.svg +76 -0
  317. package/lib/assets/img/svg/lefttoolbar/view_more.svg +86 -0
  318. package/lib/assets/img/svg/lefttoolbar/warning_icon.svg +81 -0
  319. package/lib/assets/img/svg/lefttoolbar/window.svg +12 -0
  320. package/lib/assets/img/svg/logo.svg +11 -0
  321. package/lib/assets/img/svg/logo_with_text.svg +25 -0
  322. package/lib/assets/img/svg/menubar/login.svg +84 -0
  323. package/lib/assets/img/svg/menubar/my_projects.svg +85 -0
  324. package/lib/assets/img/svg/menubar/new_project.svg +110 -0
  325. package/lib/assets/img/svg/menubar/save_project.svg +84 -0
  326. package/lib/assets/img/svg/options.svg +3 -0
  327. package/lib/assets/img/svg/positioning.svg +3 -0
  328. package/lib/assets/img/svg/rotate.png +0 -0
  329. package/lib/assets/img/svg/rotate.svg +17 -0
  330. package/lib/assets/img/svg/rotate_object_clockwise.svg +26 -0
  331. package/lib/assets/img/svg/rotate_object_counterclockwise.svg +26 -0
  332. package/lib/assets/img/svg/toggleFilters.svg +19 -0
  333. package/lib/assets/img/svg/toolbar/add_appliances_active.svg +64 -0
  334. package/lib/assets/img/svg/toolbar/add_appliances_inactive.svg +52 -0
  335. package/lib/assets/img/svg/toolbar/add_button.svg +36 -0
  336. package/lib/assets/img/svg/toolbar/add_cabinets_active.svg +59 -0
  337. package/lib/assets/img/svg/toolbar/add_cabinets_inactive.svg +49 -0
  338. package/lib/assets/img/svg/toolbar/add_items_doors.svg +25 -0
  339. package/lib/assets/img/svg/toolbar/add_items_doorways.svg +24 -0
  340. package/lib/assets/img/svg/toolbar/add_items_refrigerator.svg +32 -0
  341. package/lib/assets/img/svg/toolbar/add_items_windows.svg +28 -0
  342. package/lib/assets/img/svg/toolbar/apply_button.svg +38 -0
  343. package/lib/assets/img/svg/toolbar/arrow-plus.svg +11 -0
  344. package/lib/assets/img/svg/toolbar/backsplash.svg +8 -0
  345. package/lib/assets/img/svg/toolbar/cancel_button.svg +37 -0
  346. package/lib/assets/img/svg/toolbar/consult_a_designer_button.svg +47 -0
  347. package/lib/assets/img/svg/toolbar/countertop.svg +7 -0
  348. package/lib/assets/img/svg/toolbar/dcm.png +0 -0
  349. package/lib/assets/img/svg/toolbar/dcm_off.svg +12 -0
  350. package/lib/assets/img/svg/toolbar/dcm_on.svg +474 -0
  351. package/lib/assets/img/svg/toolbar/delete_button.svg +37 -0
  352. package/lib/assets/img/svg/toolbar/download.svg +77 -0
  353. package/lib/assets/img/svg/toolbar/draw_custom_floor.svg +31 -0
  354. package/lib/assets/img/svg/toolbar/edit_button.svg +75 -0
  355. package/lib/assets/img/svg/toolbar/email_quote_button.svg +44 -0
  356. package/lib/assets/img/svg/toolbar/fbm.png +0 -0
  357. package/lib/assets/img/svg/toolbar/finishing_touches_active.svg +54 -0
  358. package/lib/assets/img/svg/toolbar/finishing_touches_inactive.svg +42 -0
  359. package/lib/assets/img/svg/toolbar/floorstyle.svg +9 -0
  360. package/lib/assets/img/svg/toolbar/fmb.png +0 -0
  361. package/lib/assets/img/svg/toolbar/fmb_off.svg +12 -0
  362. package/lib/assets/img/svg/toolbar/fmb_on.svg +489 -0
  363. package/lib/assets/img/svg/toolbar/furnishings_icon.svg +6 -0
  364. package/lib/assets/img/svg/toolbar/get_started_button.svg +41 -0
  365. package/lib/assets/img/svg/toolbar/handles.svg +5 -0
  366. package/lib/assets/img/svg/toolbar/lighting.svg +7 -0
  367. package/lib/assets/img/svg/toolbar/lrm.png +0 -0
  368. package/lib/assets/img/svg/toolbar/lrm_off.svg +12 -0
  369. package/lib/assets/img/svg/toolbar/lrm_on.svg +470 -0
  370. package/lib/assets/img/svg/toolbar/make_floorplan_active.svg +66 -0
  371. package/lib/assets/img/svg/toolbar/make_floorplan_inactive.svg +52 -0
  372. package/lib/assets/img/svg/toolbar/predefined_room_l_shaped.svg +20 -0
  373. package/lib/assets/img/svg/toolbar/predefined_room_layout.svg +20 -0
  374. package/lib/assets/img/svg/toolbar/predefined_room_long_narrow.svg +20 -0
  375. package/lib/assets/img/svg/toolbar/predefined_room_open_l_shape.svg +20 -0
  376. package/lib/assets/img/svg/toolbar/predefined_room_open_pentagon.svg +20 -0
  377. package/lib/assets/img/svg/toolbar/predefined_room_open_rectangle.svg +20 -0
  378. package/lib/assets/img/svg/toolbar/predefined_room_open_rectangle_2.svg +20 -0
  379. package/lib/assets/img/svg/toolbar/predefined_room_pentagon.svg +20 -0
  380. package/lib/assets/img/svg/toolbar/predefined_room_rectangle.svg +20 -0
  381. package/lib/assets/img/svg/toolbar/predefined_room_rectangle_with_alcove.svg +20 -0
  382. package/lib/assets/img/svg/toolbar/redo_button.svg +75 -0
  383. package/lib/assets/img/svg/toolbar/redo_button1.svg +75 -0
  384. package/lib/assets/img/svg/toolbar/review_quote_active.svg +14 -0
  385. package/lib/assets/img/svg/toolbar/review_quote_inactive.svg +44 -0
  386. package/lib/assets/img/svg/toolbar/save_project_button.svg +44 -0
  387. package/lib/assets/img/svg/toolbar/select_doorstyle_active.svg +67 -0
  388. package/lib/assets/img/svg/toolbar/select_doorstyle_inactive.svg +57 -0
  389. package/lib/assets/img/svg/toolbar/shopping-cart.svg +13 -0
  390. package/lib/assets/img/svg/toolbar/style_change_button.svg +47 -0
  391. package/lib/assets/img/svg/toolbar/take_picture.svg +75 -0
  392. package/lib/assets/img/svg/toolbar/undo_button.svg +76 -0
  393. package/lib/assets/img/svg/toolbar/undo_button1.svg +76 -0
  394. package/lib/assets/img/svg/toolbar/use_button.svg +37 -0
  395. package/lib/assets/img/svg/toolbar/wall_color_icon.svg +6 -0
  396. package/lib/assets/img/svg/topbar/edit_active.svg +10 -0
  397. package/lib/assets/img/svg/topbar/edit_inactive.svg +10 -0
  398. package/lib/assets/img/svg/topbar/redo_active.svg +42 -0
  399. package/lib/assets/img/svg/topbar/redo_inactive.svg +23 -0
  400. package/lib/assets/img/svg/topbar/select_all_active.svg +50 -0
  401. package/lib/assets/img/svg/topbar/select_all_inactive.svg +32 -0
  402. package/lib/assets/img/svg/topbar/take_picture_active.svg +51 -0
  403. package/lib/assets/img/svg/topbar/take_picture_inactive.svg +26 -0
  404. package/lib/assets/img/svg/topbar/undo_active.svg +42 -0
  405. package/lib/assets/img/svg/topbar/undo_inactive.svg +23 -0
  406. package/lib/assets/img/svg/warning_info_2d.svg +81 -0
  407. package/lib/assets/img/svg/window/Clear.svg +3 -0
  408. package/lib/assets/img/svg/window/Cross.svg +5 -0
  409. package/lib/assets/img/svg/window/Double_hung.svg +4 -0
  410. package/lib/assets/img/svg/window/Vertical.svg +4 -0
  411. package/lib/assets/img/svg/windows_clear.svg +23 -0
  412. package/lib/assets/img/svg/windows_cross.svg +28 -0
  413. package/lib/assets/img/svg/windows_double_hung.svg +24 -0
  414. package/lib/assets/img/svg/windows_vertical.svg +24 -0
  415. package/lib/assets/img/svg/wizardstep/Custom.svg +3 -0
  416. package/lib/assets/img/svg/wizardstep/Dashed_line.svg +3 -0
  417. package/lib/assets/img/svg/wizardstep/L.svg +3 -0
  418. package/lib/assets/img/svg/wizardstep/L2.svg +3 -0
  419. package/lib/assets/img/svg/wizardstep/Open.svg +3 -0
  420. package/lib/assets/img/svg/wizardstep/Square.svg +3 -0
  421. package/lib/assets/img/svg/wizardstep/bar-active.svg +9 -0
  422. package/lib/assets/img/svg/wizardstep/bar-normal.svg +3 -0
  423. package/lib/assets/img/svg/wizardstep/bullet-current.svg +3 -0
  424. package/lib/assets/img/svg/wizardstep/bullet-done.svg +3 -0
  425. package/lib/assets/img/svg/wizardstep/bullet-not-done.svg +3 -0
  426. package/lib/assets/img/svg/wizardstep/check-active.svg +3 -0
  427. package/lib/assets/img/svg/wizardstep/check-normal.svg +3 -0
  428. package/lib/assets/img/svg/wizardstep/detail_view.svg +87 -0
  429. package/lib/assets/img/svg/wizardstep/pencil.svg +11 -0
  430. package/lib/assets/img/svg/wizardstep/tile_view.svg +95 -0
  431. package/lib/assets/img/texture/glass.jpg +0 -0
  432. package/lib/assets/img/texture/steel.jpg +0 -0
  433. package/lib/assets/img/texture/white1px.jpg +0 -0
  434. package/lib/assets/img/texture/wood.jpg +0 -0
  435. package/lib/assets/model/DCM.bin +0 -0
  436. package/lib/assets/model/DCM.fbx +0 -0
  437. package/lib/assets/model/DCM.gltf +1 -0
  438. package/lib/assets/model/FBM.bin +0 -0
  439. package/lib/assets/model/FBM.fbx +0 -0
  440. package/lib/assets/model/FBM.gltf +1 -0
  441. package/lib/assets/model/LRM.bin +0 -0
  442. package/lib/assets/model/LRM.fbx +0 -0
  443. package/lib/assets/model/LRM.gltf +1 -0
  444. package/lib/assets/rtastore_logo.png +0 -0
  445. package/lib/catalog/areas/area/planner-element.js +53 -0
  446. package/lib/catalog/areas/area/textures/ceramic-tile.jpg +0 -0
  447. package/lib/catalog/areas/area/textures/grass.jpg +0 -0
  448. package/lib/catalog/areas/area/textures/parquet.jpg +0 -0
  449. package/lib/catalog/areas/area/textures/strand-porcelain.jpg +0 -0
  450. package/lib/catalog/areas/area/textures/tile1.jpg +0 -0
  451. package/lib/catalog/back.png +0 -0
  452. package/lib/catalog/catalog.js +270 -0
  453. package/lib/catalog/doors.png +0 -0
  454. package/lib/catalog/doorways.png +0 -0
  455. package/lib/catalog/envMap/nx.hdr +0 -0
  456. package/lib/catalog/envMap/ny.hdr +0 -0
  457. package/lib/catalog/envMap/nz.hdr +0 -0
  458. package/lib/catalog/envMap/px.hdr +0 -0
  459. package/lib/catalog/envMap/py.hdr +0 -0
  460. package/lib/catalog/envMap/pz.hdr +0 -0
  461. package/lib/catalog/export.js +1 -0
  462. package/lib/catalog/factories/area-factory-3d.js +187 -0
  463. package/lib/catalog/factories/area-factory.js +88 -0
  464. package/lib/catalog/factories/export.js +25 -0
  465. package/lib/catalog/factories/wall-factory-3d.js +212 -0
  466. package/lib/catalog/factories/wall-factory.js +279 -0
  467. package/lib/catalog/holes/door-closet/planner-element.js +232 -0
  468. package/lib/catalog/holes/door-double/door_double.png +0 -0
  469. package/lib/catalog/holes/door-double/planner-element.js +325 -0
  470. package/lib/catalog/holes/door-exterior/planner-element.js +225 -0
  471. package/lib/catalog/holes/door-interior/planner-element.js +237 -0
  472. package/lib/catalog/holes/door-panic/panicDoor.png +0 -0
  473. package/lib/catalog/holes/door-panic/planner-element.js +513 -0
  474. package/lib/catalog/holes/door-panic-double/panicDoorDouble.png +0 -0
  475. package/lib/catalog/holes/door-panic-double/planner-element.js +473 -0
  476. package/lib/catalog/holes/door-sliding/planner-element.js +235 -0
  477. package/lib/catalog/holes/doorway-framed/planner-element.js +155 -0
  478. package/lib/catalog/holes/doorway-frameless/planner-element.js +114 -0
  479. package/lib/catalog/holes/export.js +97 -0
  480. package/lib/catalog/holes/gate/gate.jpg +0 -0
  481. package/lib/catalog/holes/window-clear/planner-element.js +176 -0
  482. package/lib/catalog/holes/window-clear/texture.png +0 -0
  483. package/lib/catalog/holes/window-cross/planner-element.js +175 -0
  484. package/lib/catalog/holes/window-cross/texture.png +0 -0
  485. package/lib/catalog/holes/window-double-hung/planner-element.js +313 -0
  486. package/lib/catalog/holes/window-double-hung/texture.png +0 -0
  487. package/lib/catalog/holes/window-vertical/planner-element.js +286 -0
  488. package/lib/catalog/holes/window-vertical/texture.png +0 -0
  489. package/lib/catalog/lines/wall/planner-element.js +87 -0
  490. package/lib/catalog/lines/wall/textures/bricks-normal.jpg +0 -0
  491. package/lib/catalog/lines/wall/textures/bricks.jpg +0 -0
  492. package/lib/catalog/lines/wall/textures/bricks2.jpg +0 -0
  493. package/lib/catalog/lines/wall/textures/morden-normal.jpg +0 -0
  494. package/lib/catalog/lines/wall/textures/morden.jpg +0 -0
  495. package/lib/catalog/lines/wall/textures/painted.jpg +0 -0
  496. package/lib/catalog/lines/wall/textures/plaster-normal.jpg +0 -0
  497. package/lib/catalog/lines/wall/textures/plaster.jpg +0 -0
  498. package/lib/catalog/lines/wall/wall.png +0 -0
  499. package/lib/catalog/molding/molding-dcm/planner-element.js +33 -0
  500. package/lib/catalog/molding/molding-dcm/texture.png +0 -0
  501. package/lib/catalog/molding/molding-fbm/planner-element.js +33 -0
  502. package/lib/catalog/molding/molding-fbm/texture.png +0 -0
  503. package/lib/catalog/molding/molding-lrm/planner-element.js +33 -0
  504. package/lib/catalog/molding/molding-lrm/texture.png +0 -0
  505. package/lib/catalog/utils/exporter.js +173 -0
  506. package/lib/catalog/utils/geom-utils.js +205 -0
  507. package/lib/catalog/utils/item-loader.js +1597 -0
  508. package/lib/catalog/utils/load-obj.js +99 -0
  509. package/lib/catalog/utils/mtl-loader.js +366 -0
  510. package/lib/catalog/utils/obj-loader.js +486 -0
  511. package/lib/catalog/windows.png +0 -0
  512. package/lib/class/area.js +147 -0
  513. package/lib/class/export.js +88 -0
  514. package/lib/class/group.js +438 -0
  515. package/lib/class/guide.js +64 -0
  516. package/lib/class/hole.js +930 -0
  517. package/lib/class/item.js +1985 -0
  518. package/lib/class/layer.js +670 -0
  519. package/lib/class/line.js +1238 -0
  520. package/lib/class/project.js +949 -0
  521. package/lib/class/vertex.js +205 -0
  522. package/lib/components/content.js +148 -0
  523. package/lib/components/export.js +7 -0
  524. package/lib/components/style/export.js +17 -0
  525. package/lib/components/style/form-number-input.js +192 -0
  526. package/lib/components/style/form-submit-button.js +35 -0
  527. package/lib/components/viewer2d/area.js +89 -0
  528. package/lib/components/viewer2d/export.js +121 -0
  529. package/lib/components/viewer2d/grids/grid-horizontal-streak.js +44 -0
  530. package/lib/components/viewer2d/grids/grid-streak.js +44 -0
  531. package/lib/components/viewer2d/grids/grid-vertical-streak.js +44 -0
  532. package/lib/components/viewer2d/grids/grids.js +40 -0
  533. package/lib/components/viewer2d/group.js +63 -0
  534. package/lib/components/viewer2d/item.js +245 -0
  535. package/lib/components/viewer2d/layer.js +172 -0
  536. package/lib/components/viewer2d/line.js +975 -0
  537. package/lib/components/viewer2d/ruler.js +92 -0
  538. package/lib/components/viewer2d/rulerDist.js +110 -0
  539. package/lib/components/viewer2d/rulerX.js +154 -0
  540. package/lib/components/viewer2d/rulerY.js +156 -0
  541. package/lib/components/viewer2d/scene.js +137 -0
  542. package/lib/components/viewer2d/snap.js +84 -0
  543. package/lib/components/viewer2d/state.js +83 -0
  544. package/lib/components/viewer2d/utils.js +207 -0
  545. package/lib/components/viewer2d/vertex.js +76 -0
  546. package/lib/components/viewer2d/viewer2d.js +1472 -0
  547. package/lib/components/viewer3d/camera-controls-module/camera-controls.module.js +2591 -0
  548. package/lib/components/viewer3d/dcm.js +408 -0
  549. package/lib/components/viewer3d/fbm.js +421 -0
  550. package/lib/components/viewer3d/front3D.js +71 -0
  551. package/lib/components/viewer3d/grid-creator.js +35 -0
  552. package/lib/components/viewer3d/grids/grid-horizontal-streak.js +45 -0
  553. package/lib/components/viewer3d/grids/grid-streak.js +36 -0
  554. package/lib/components/viewer3d/grids/grid-vertical-streak.js +45 -0
  555. package/lib/components/viewer3d/libs/first-person-controls.js +74 -0
  556. package/lib/components/viewer3d/libs/helvetiker_regular.typeface.js +1287 -0
  557. package/lib/components/viewer3d/libs/mtl-loader.js +366 -0
  558. package/lib/components/viewer3d/libs/obj-loader.js +471 -0
  559. package/lib/components/viewer3d/libs/orbit-controls.js +706 -0
  560. package/lib/components/viewer3d/libs/pointer-lock-controls.js +53 -0
  561. package/lib/components/viewer3d/lrm.js +312 -0
  562. package/lib/components/viewer3d/model.js +714 -0
  563. package/lib/components/viewer3d/pointer-lock-navigation.js +32 -0
  564. package/lib/components/viewer3d/ruler-utils/itemRect.js +69 -0
  565. package/lib/components/viewer3d/ruler-utils/layer3D.js +503 -0
  566. package/lib/components/viewer3d/ruler-utils/ruler3D.js +232 -0
  567. package/lib/components/viewer3d/ruler-utils/scene3D.js +67 -0
  568. package/lib/components/viewer3d/ruler-utils/state3D.js +26 -0
  569. package/lib/components/viewer3d/scene-creator.js +3886 -0
  570. package/lib/components/viewer3d/three-memory-cleaner.js +46 -0
  571. package/lib/components/viewer3d/viewer3d-first-person.js +316 -0
  572. package/lib/components/viewer3d/viewer3d.js +2676 -0
  573. package/lib/constants/catalog/skinPanel.js +15 -0
  574. package/lib/constants.js +790 -0
  575. package/lib/devLiteRenderer.js +903 -0
  576. package/lib/events/external/handleExternalEvent.js +147 -0
  577. package/lib/events/external/handleExternalEvent.util.js +1127 -0
  578. package/lib/events/external/handlers.addItem.js +54 -0
  579. package/lib/events/external/handlers.changeDoorStyle.js +146 -0
  580. package/lib/events/external/handlers.elementOps.js +15 -0
  581. package/lib/events/external/handlers.finishing.js +32 -0
  582. package/lib/events/external/handlers.hole.js +10 -0
  583. package/lib/events/external/handlers.loadProject.js +135 -0
  584. package/lib/events/external/handlers.molding.js +31 -0
  585. package/lib/events/external/handlers.projectLifecycle.js +19 -0
  586. package/lib/events/external/handlers.projectSettings.js +38 -0
  587. package/lib/events/external/handlers.replaceCabinet.js +48 -0
  588. package/lib/events/external/handlers.roomShape.js +14 -0
  589. package/lib/events/external/handlers.syncScene.js +27 -0
  590. package/lib/events/external/handlers.updateSelectedElements.js +17 -0
  591. package/lib/events/external/handlers.viewMode.js +19 -0
  592. package/lib/events/external/handlers.viewerNavigation.js +117 -0
  593. package/lib/events/external/handlers.wall.js +13 -0
  594. package/lib/index.js +637 -0
  595. package/lib/mappings/external-events/mapExternalEventPayload.js +33 -0
  596. package/lib/mappings/external-events/mappers/addItemMapper.js +101 -0
  597. package/lib/mappings/external-events/mappers/ccdfMapper.js +93 -0
  598. package/lib/mappings/external-events/mappers/ccdfToCDSMapper.js +37 -0
  599. package/lib/mappings/external-events/mappers/changeDoorStyleMapper.js +44 -0
  600. package/lib/mappings/external-events/mappers/loadProjectMapper.js +70 -0
  601. package/lib/mappings/holesToCatalog.js +148 -0
  602. package/lib/models.js +534 -0
  603. package/lib/plugins/SVGLoader.js +1419 -0
  604. package/lib/plugins/console-debugger.js +42 -0
  605. package/lib/plugins/export.js +25 -0
  606. package/lib/plugins/keyboard.js +117 -0
  607. package/lib/reducers/areas-reducer.js +19 -0
  608. package/lib/reducers/export.js +89 -0
  609. package/lib/reducers/groups-reducer.js +45 -0
  610. package/lib/reducers/holes-reducer.js +69 -0
  611. package/lib/reducers/items-reducer.js +152 -0
  612. package/lib/reducers/lines-reducer.js +52 -0
  613. package/lib/reducers/project-reducer.js +143 -0
  614. package/lib/reducers/reducer.js +25 -0
  615. package/lib/reducers/scene-reducer.js +35 -0
  616. package/lib/reducers/vertices-reducer.js +26 -0
  617. package/lib/reducers/viewer2d-reducer.js +84 -0
  618. package/lib/reducers/viewer3d-reducer.js +65 -0
  619. package/lib/shared/objects/immutable.js +9 -0
  620. package/lib/shared-style.js +72 -0
  621. package/lib/translator/en.js +111 -0
  622. package/lib/translator/it.js +86 -0
  623. package/lib/translator/ru.js +86 -0
  624. package/lib/translator/translator.js +87 -0
  625. package/lib/utils/browser.js +40 -0
  626. package/lib/utils/convert-units-lite.js +44 -0
  627. package/lib/utils/email-validator.js +10 -0
  628. package/lib/utils/export.js +56 -0
  629. package/lib/utils/geometry.js +3233 -0
  630. package/lib/utils/get-edges-of-subgraphs.js +33 -0
  631. package/lib/utils/graph-cycles.js +239 -0
  632. package/lib/utils/graph-inner-cycles.js +54 -0
  633. package/lib/utils/graph.js +153 -0
  634. package/lib/utils/helper.js +490 -0
  635. package/lib/utils/history.js +48 -0
  636. package/lib/utils/id-broker.js +22 -0
  637. package/lib/utils/logger.js +14 -0
  638. package/lib/utils/math.js +57 -0
  639. package/lib/utils/molding.js +1146 -0
  640. package/lib/utils/name-generator.js +21 -0
  641. package/lib/utils/objects-utils.js +62 -0
  642. package/lib/utils/phone-validator.js +10 -0
  643. package/lib/utils/process-black-list.js +22 -0
  644. package/lib/utils/react-if.js +25 -0
  645. package/lib/utils/ruler.js +63 -0
  646. package/lib/utils/skinPanelEngine.js +534 -0
  647. package/lib/utils/snap-scene.js +101 -0
  648. package/lib/utils/snap.js +245 -0
  649. package/lib/utils/summarizeCart.js +30 -0
  650. package/lib/utils/threeCSG.es6.js +504 -0
  651. package/lib/version.js +7 -0
  652. package/package.json +29 -24
  653. package/es/WorkSpace.js +0 -30
  654. package/es/WorkSpaceHostMimic.js +0 -132
  655. package/es/assets/gltf/door_closet.bin +0 -0
  656. package/es/assets/gltf/door_closet.fbx +0 -0
  657. package/es/assets/gltf/door_exterior.bin +0 -0
  658. package/es/assets/gltf/door_exterior.fbx +0 -0
  659. package/es/assets/gltf/door_interior.bin +0 -0
  660. package/es/assets/gltf/door_interior.fbx +0 -0
  661. package/es/assets/gltf/door_sliding.bin +0 -0
  662. package/es/assets/gltf/door_sliding.fbx +0 -0
  663. package/es/assets/img/png/helper/video_preview_3d.png +0 -0
  664. package/es/assets/img/png/helper/video_preview_start.png +0 -0
  665. package/es/assets/img/svg/color/Brown.svg +0 -9
  666. package/es/assets/img/svg/color/Dark.svg +0 -9
  667. package/es/assets/img/svg/color/Light.svg +0 -9
  668. package/es/assets/img/svg/color/Medium.svg +0 -9
  669. package/es/assets/img/svg/color/Unfinished.svg +0 -9
  670. package/es/catalog/lines/wall/textures/bricks3.jpg +0 -0
  671. package/es/catalog/properties/export.js +0 -21
  672. package/es/catalog/properties/property-checkbox.js +0 -68
  673. package/es/catalog/properties/property-color.js +0 -39
  674. package/es/catalog/properties/property-enum.js +0 -50
  675. package/es/catalog/properties/property-hidden.js +0 -19
  676. package/es/catalog/properties/property-lenght-measure.js +0 -96
  677. package/es/catalog/properties/property-length-measure.js +0 -80
  678. package/es/catalog/properties/property-length-measure_hole.js +0 -96
  679. package/es/catalog/properties/property-number.js +0 -48
  680. package/es/catalog/properties/property-read-only.js +0 -26
  681. package/es/catalog/properties/property-string.js +0 -48
  682. package/es/catalog/properties/property-toggle.js +0 -39
  683. package/es/catalog/properties/shared-property-style.js +0 -14
  684. package/es/catalog/utils/FuseUtils.js +0 -79
  685. package/es/class/FuseUtils.js +0 -79
  686. package/es/components/style/button.js +0 -106
  687. package/es/components/style/cancel-button.js +0 -21
  688. package/es/components/style/content-container.js +0 -30
  689. package/es/components/style/content-title.js +0 -25
  690. package/es/components/style/delete-button.js +0 -24
  691. package/es/components/style/form-block.js +0 -20
  692. package/es/components/style/form-color-input.js +0 -26
  693. package/es/components/style/form-label.js +0 -22
  694. package/es/components/style/form-number-input_2.js +0 -238
  695. package/es/components/style/form-select.js +0 -19
  696. package/es/components/style/form-slider.js +0 -60
  697. package/es/components/style/form-text-input.js +0 -69
  698. package/es/index.html.ejs +0 -264
  699. package/es/reducers/user-reducer.js +0 -41
  700. /package/{es/catalog/lines/wall/textures/bricks-normal2.jpg → lib/catalog/lines/wall/textures/painted-normal.jpg} +0 -0
@@ -0,0 +1,3233 @@
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.ContainsPoint = ContainsPoint;
9
+ exports._twoLineSegmentsIntersection = _twoLineSegmentsIntersection;
10
+ exports.absAngleBetweenTwoPoints = absAngleBetweenTwoPoints;
11
+ exports.almostEqual = void 0;
12
+ exports.angleBetweenTwoLines = angleBetweenTwoLines;
13
+ exports.angleBetweenTwoPoints = angleBetweenTwoPoints;
14
+ exports.angleBetweenTwoPointsAndOrigin = angleBetweenTwoPointsAndOrigin;
15
+ exports.buildRectFromLines = buildRectFromLines;
16
+ exports.calcCreateSnap = calcCreateSnap;
17
+ exports.calcDistancesFromHoleToNearestOneOrWall = calcDistancesFromHoleToNearestOneOrWall;
18
+ exports.calcDistancesFromItemToWalls = calcDistancesFromItemToWalls;
19
+ exports.calcSnap = calcSnap;
20
+ exports.calcSnap1 = calcSnap1;
21
+ exports.calcSnap2 = calcSnap2;
22
+ exports.calcSnap3 = calcSnap3;
23
+ exports.clone_point = clone_point;
24
+ exports.closestPointFromLine = closestPointFromLine;
25
+ exports.closestPointFromLineSegment = closestPointFromLineSegment;
26
+ exports.compareVertices = compareVertices;
27
+ exports.containLine = containLine;
28
+ exports.containPointInRect = containPointInRect;
29
+ exports.cosWithThreshold = cosWithThreshold;
30
+ exports.crossprod = crossprod;
31
+ exports.diff = diff;
32
+ exports.distancePointFromLine = distancePointFromLine;
33
+ exports.distancePointFromLineSegment = distancePointFromLineSegment;
34
+ exports.dotprod = dotprod;
35
+ exports.downcrossLine = downcrossLine;
36
+ exports.extendLine = extendLine;
37
+ exports.findCatalogElement = findCatalogElement;
38
+ exports.getAllArea = getAllArea;
39
+ exports.getAllAreaLines = getAllAreaLines;
40
+ exports.getAllCurSnap = getAllCurSnap;
41
+ exports.getAllHoleRect = getAllHoleRect;
42
+ exports.getAllItemSnap = getAllItemSnap;
43
+ exports.getAllItemSpecified = getAllItemSpecified;
44
+ exports.getAllItems = getAllItems;
45
+ exports.getAllLineSnap = getAllLineSnap;
46
+ exports.getAllLines = getAllLines;
47
+ exports.getCalcRectFromItem = getCalcRectFromItem;
48
+ exports.getCalcRectFromItem3D = getCalcRectFromItem3D;
49
+ exports.getCalcRectFromLine = getCalcRectFromLine;
50
+ exports.getCentroidOfPolygon = getCentroidOfPolygon;
51
+ exports.getHoleItems = getHoleItems;
52
+ exports.getInterSect = getInterSect;
53
+ exports.getLineInterSect = getLineInterSect;
54
+ exports.getLineSnapPointsOfItem = getLineSnapPointsOfItem;
55
+ exports.getNormaline = getNormaline;
56
+ exports.getPoylgonPoints = getPoylgonPoints;
57
+ exports.getRelatedLines = void 0;
58
+ exports.getRelatedVertices = getRelatedVertices;
59
+ exports.getSnappedWallLines = getSnappedWallLines;
60
+ exports.horizontalLine = horizontalLine;
61
+ exports.intersectRect = intersectRect;
62
+ exports.isBackWall = isBackWall;
63
+ exports.isFrontWall = isFrontWall;
64
+ exports.isLeftWall = isLeftWall;
65
+ exports.isOverlappedTwoItemsOnOneLine = isOverlappedTwoItemsOnOneLine;
66
+ exports.isPointInArea = isPointInArea;
67
+ exports.isPointInRect = isPointInRect;
68
+ exports.isPointOnLineSegment = isPointOnLineSegment;
69
+ exports.isRightWall = isRightWall;
70
+ exports.isSnappedLine = isSnappedLine;
71
+ exports.isSnappedSideLine = isSnappedSideLine;
72
+ exports.itemInfo = itemInfo;
73
+ exports.linePassingThroughTwoPoints = linePassingThroughTwoPoints;
74
+ exports.mapRange = mapRange;
75
+ exports.maxVertex = maxVertex;
76
+ exports.midPoint = midPoint;
77
+ exports.minVertex = minVertex;
78
+ exports.needSnap = needSnap;
79
+ exports.orderVertices = orderVertices;
80
+ exports.pointPositionOnLineSegment = pointPositionOnLineSegment;
81
+ exports.pointsDistance = pointsDistance;
82
+ exports.relationshipOfTwoOverlappedLines = relationshipOfTwoOverlappedLines;
83
+ exports.relationshipOfTwoOverlappedLines1 = relationshipOfTwoOverlappedLines1;
84
+ exports.relationshipOfTwoOverlappedLines2 = relationshipOfTwoOverlappedLines2;
85
+ exports.rotatePointAroundPoint = rotatePointAroundPoint;
86
+ exports.roundVertex = roundVertex;
87
+ exports.sameDistances = sameDistances;
88
+ exports.sameMDistances = sameMDistances;
89
+ exports.sameMPoints = sameMPoints;
90
+ exports.samePoints = samePoints;
91
+ exports.shrinkRect = shrinkRect;
92
+ exports.sinWithThreshold = sinWithThreshold;
93
+ exports.snapAngleByUnit = snapAngleByUnit;
94
+ exports.twoLineSegmentsIntersection = twoLineSegmentsIntersection;
95
+ exports.twoLinesIntersection = twoLinesIntersection;
96
+ exports.upcrossLine = upcrossLine;
97
+ exports.validInterSect = validInterSect;
98
+ exports.validRect = validRect;
99
+ exports.validSnap = validSnap;
100
+ exports.validateLineSnaps = validateLineSnaps;
101
+ exports.validateSnaps = validateSnaps;
102
+ exports.verticalLine = verticalLine;
103
+ exports.verticesDistance = verticesDistance;
104
+ exports.verticesMidPoint = verticesMidPoint;
105
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
106
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
107
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
108
+ var _math = require("./math.js");
109
+ var _constants = require("../constants");
110
+ var _convertUnitsLite = require("./convert-units-lite");
111
+ var Three = _interopRequireWildcard(require("three"));
112
+ var _utils = require("../components/viewer2d/utils.js");
113
+ var _helper = require("./helper.js");
114
+ var _export = require("./export.js");
115
+ 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); }
116
+ 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; }
117
+ 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; }
118
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
119
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
120
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } /** @description Determines the distance between two points
121
+ * @param {number} x0 Vertex 0 x
122
+ * @param {number} y0 Vertex 0 y
123
+ * @param {number} x1 Vertex 1 x
124
+ * @param {number} y1 Vertex 1 y
125
+ * @return {number}
126
+ */
127
+ function compareVertices(v0, v1) {
128
+ return v0.x === v1.x ? v0.y - v1.y : v0.x - v1.x;
129
+ }
130
+ function minVertex(v0, v1) {
131
+ return compareVertices(v0, v1) > 0 ? v1 : v0;
132
+ }
133
+ function maxVertex(v0, v1) {
134
+ return compareVertices(v0, v1) > 0 ? v0 : v1;
135
+ }
136
+ function orderVertices(vertices) {
137
+ return vertices.sort(compareVertices);
138
+ }
139
+ function pointsDistance(x0, y0, x1, y1) {
140
+ var diff_x = x0 - x1;
141
+ var diff_y = y0 - y1;
142
+ return Math.sqrt(diff_x * diff_x + diff_y * diff_y);
143
+ }
144
+ function verticesDistance(v1, v2) {
145
+ var x0 = v1.x,
146
+ y0 = v1.y;
147
+ var x1 = v2.x,
148
+ y1 = v2.y;
149
+ return pointsDistance(x0, y0, x1, y1);
150
+ }
151
+ function horizontalLine(y) {
152
+ return {
153
+ a: 0,
154
+ b: 1,
155
+ c: -y
156
+ };
157
+ }
158
+ var almostEqual = exports.almostEqual = function almostEqual(x, y) {
159
+ return Math.abs(x - y) < _constants.EPSILON;
160
+ };
161
+ function verticalLine(x) {
162
+ return {
163
+ a: 1,
164
+ b: 0,
165
+ c: -x
166
+ };
167
+ }
168
+ function upcrossLine(x, y) {
169
+ return {
170
+ a: 1,
171
+ b: 1,
172
+ c: -x - y
173
+ };
174
+ }
175
+ function downcrossLine(x, y) {
176
+ return {
177
+ a: 1,
178
+ b: -1,
179
+ c: -x + y
180
+ };
181
+ }
182
+ function linePassingThroughTwoPoints(x1, y1, x2, y2) {
183
+ if (x1 === x2 && y1 == y2) throw new Error('Geometry error');
184
+ //if (x1 === x2) return verticalLine(x1);
185
+ //if (y1 === y2) return horizontalLine(y1);
186
+
187
+ return {
188
+ a: y1 - y2,
189
+ b: x2 - x1,
190
+ c: y2 * x1 - x2 * y1
191
+ };
192
+ }
193
+ function getNormaline(x1, y1, x2, y2) {
194
+ var lineFunction = linePassingThroughTwoPoints(x1, y1, x2, y2);
195
+ return {
196
+ x: lineFunction.a / Math.sqrt(lineFunction.a * lineFunction.a + lineFunction.b * lineFunction.b),
197
+ y: lineFunction.b / Math.sqrt(lineFunction.a * lineFunction.a + lineFunction.b * lineFunction.b)
198
+ };
199
+ }
200
+ function distancePointFromLine(a, b, c, x, y) {
201
+ //https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
202
+ return (0, _math.fAbs)(a * x + b * y + c) / Math.sqrt(a * a + b * b);
203
+ }
204
+ function closestPointFromLine(a, b, c, x, y) {
205
+ //https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
206
+ var denom = a * a + b * b;
207
+ return {
208
+ x: (b * (b * x - a * y) - a * c) / denom,
209
+ y: (a * -b * x + a * y - b * c) / denom
210
+ };
211
+ }
212
+
213
+ /** @description Get point of intersection between two lines using ax+by+c line's equation
214
+ * @param {number} a x coefficent of first line
215
+ * @param {number} b y coefficent of first line
216
+ * @param {number} c costant of first line
217
+ * @param {number} j x coefficent of second line
218
+ * @param {number} k y coefficent of second line
219
+ * @param {number} l costant of second line
220
+ * @return {object} {x,y} point's coordinates
221
+ */
222
+ function twoLinesIntersection(a, b, c, j, k, l) {
223
+ var angularCoefficientsDiff = b * j - a * k;
224
+ if (angularCoefficientsDiff === 0) return undefined; //no intersection
225
+
226
+ var y = (a * l - c * j) / angularCoefficientsDiff;
227
+ var x = (c * k - b * l) / angularCoefficientsDiff;
228
+ return {
229
+ x: x,
230
+ y: y
231
+ };
232
+ }
233
+ function twoLineSegmentsIntersection(p1, p2, p3, p4) {
234
+ return _twoLineSegmentsIntersection(p1, p2, p3.toJS(), p4.toJS());
235
+ }
236
+ function _twoLineSegmentsIntersection(p1, p2, p3, p4) {
237
+ //https://github.com/psalaets/line-intersect/blob/master/lib/check-intersection.js
238
+
239
+ var x1 = p1.x,
240
+ y1 = p1.y;
241
+ var x2 = p2.x,
242
+ y2 = p2.y;
243
+ var x3 = p3.x,
244
+ y3 = p3.y;
245
+ var x4 = p4.x,
246
+ y4 = p4.y;
247
+ var denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
248
+ var numA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);
249
+ var numB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3);
250
+ if ((0, _math.fAbs)(denom) <= _constants.EPSILON) {
251
+ if ((0, _math.fAbs)(numA) <= _constants.EPSILON && (0, _math.fAbs)(numB) <= _constants.EPSILON) {
252
+ var comparator = function comparator(pa, pb) {
253
+ return pa.x === pb.x ? pa.y - pb.y : pa.x - pb.x;
254
+ };
255
+ var line0 = [p1, p2].sort(comparator);
256
+ var line1 = [p3, p4].sort(comparator);
257
+ var _sort = [line0, line1].sort(function (lineA, lineB) {
258
+ return comparator(lineA[0], lineB[0]);
259
+ }),
260
+ _sort2 = (0, _slicedToArray2["default"])(_sort, 2),
261
+ lineSX = _sort2[0],
262
+ lineDX = _sort2[1];
263
+ comparator(lineSX[1], lineDX[0]) < 0 ? 'colinear' : 'none';
264
+ if (lineSX[1].x === lineDX[0].x) {
265
+ return {
266
+ type: lineDX[0].y <= lineSX[1].y ? 'colinear' : 'none'
267
+ };
268
+ } else {
269
+ return {
270
+ type: lineDX[0].x <= lineSX[1].x ? 'colinear' : 'none'
271
+ };
272
+ }
273
+ }
274
+ return {
275
+ type: 'parallel'
276
+ };
277
+ }
278
+ var uA = numA / denom;
279
+ var uB = numB / denom;
280
+ if (uA >= 0 - _constants.EPSILON && uA <= 1 + _constants.EPSILON && uB >= 0 - _constants.EPSILON && uB <= 1 + _constants.EPSILON) {
281
+ var _point = {
282
+ x: x1 + uA * (x2 - x1),
283
+ y: y1 + uA * (y2 - y1)
284
+ };
285
+ return {
286
+ type: 'intersecting',
287
+ point: _point
288
+ };
289
+ }
290
+ return {
291
+ type: 'none'
292
+ };
293
+ }
294
+ function distancePointFromLineSegment(v1, v2, xp, yp) {
295
+ //http://stackoverflow.com/a/6853926/1398836
296
+ var x1 = v1.x,
297
+ y1 = v1.y;
298
+ var x2 = v2.x,
299
+ y2 = v2.y;
300
+ var A = xp - x1;
301
+ var B = yp - y1;
302
+ var C = x2 - x1;
303
+ var D = y2 - y1;
304
+ var dot = A * C + B * D;
305
+ var len_sq = C * C + D * D;
306
+ var param = -1;
307
+ if (len_sq != 0)
308
+ //in case of 0 length line
309
+ param = dot / len_sq;
310
+ var xx, yy;
311
+ if (param < 0) {
312
+ xx = x1;
313
+ yy = y1;
314
+ } else if (param > 1) {
315
+ xx = x2;
316
+ yy = y2;
317
+ } else {
318
+ xx = x1 + param * C;
319
+ yy = y1 + param * D;
320
+ }
321
+ var dx = xp - xx;
322
+ var dy = yp - yy;
323
+ return Math.sqrt(dx * dx + dy * dy);
324
+ }
325
+
326
+ /**
327
+ *
328
+ * @param x1 {number} x for first vertex of the segment
329
+ * @param y1 {number} y for first vertex of the segment
330
+ * @param x2 {number} x for second vertex of the segment
331
+ * @param y2 {number} y for second vertex of the segment
332
+ * @param xp {number} x for point we want to verify
333
+ * @param yp {number} y for point we want to verify
334
+ * @param maxDistance {number} the epsilon value used for comparisons
335
+ * @returns {boolean} true if the point lies on the line segment false otherwise
336
+ */
337
+ function isPointOnLineSegment(x1, y1, x2, y2, xp, yp) {
338
+ var maxDistance = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : _constants.EPSILON;
339
+ return distancePointFromLineSegment({
340
+ x: x1,
341
+ y: y1
342
+ }, {
343
+ x: x2,
344
+ y: y2
345
+ }, xp, yp) <= maxDistance;
346
+ }
347
+ function closestPointFromLineSegment(x1, y1, x2, y2, xp, yp) {
348
+ if (x1 === x2) return {
349
+ x: x1,
350
+ y: yp
351
+ };
352
+ if (y1 === y2) return {
353
+ x: xp,
354
+ y: y1
355
+ };
356
+ var m = (y2 - y1) / (x2 - x1);
357
+ var q = y1 - m * x1;
358
+ var mi = -1 / m;
359
+ var qi = yp - mi * xp;
360
+ var x = (qi - q) / (m - mi);
361
+ var y = m * x + q;
362
+ return {
363
+ x: x,
364
+ y: y
365
+ };
366
+ }
367
+ function pointPositionOnLineSegment(x1, y1, x2, y2, xp, yp) {
368
+ var length = pointsDistance(x1, y1, x2, y2);
369
+ var distance = pointsDistance(x1, y1, xp, yp);
370
+ var offset = distance / length;
371
+ /*
372
+ if (x1 > x2) offset = 1 - offset;
373
+ if (y1 > y2) offset = 1 - offset;
374
+ */
375
+ return offset;
376
+ }
377
+ function mapRange(value, low1, high1, low2, high2) {
378
+ return low2 + (high2 - low2) * (value - low1) / (high1 - low1);
379
+ }
380
+ function angleBetweenTwoPointsAndOrigin(x1, y1, x2, y2) {
381
+ return -Math.atan2(y1 - y2, x2 - x1) * 180 / Math.PI;
382
+ }
383
+ function angleBetweenTwoPoints(x1, y1, x2, y2) {
384
+ return Math.atan2(y2 - y1, x2 - x1);
385
+ }
386
+ function angleBetweenTwoLines(line, drawingLine, vertices) {
387
+ var points = [];
388
+
389
+ // safety guards
390
+ var lv = Array.isArray(line === null || line === void 0 ? void 0 : line.vertices) ? line.vertices : [];
391
+ var dv = Array.isArray(drawingLine === null || drawingLine === void 0 ? void 0 : drawingLine.vertices) ? drawingLine.vertices : [];
392
+
393
+ // 1) push common vertices (in order of line.vertices)
394
+ var _iterator = _createForOfIteratorHelper(lv),
395
+ _step;
396
+ try {
397
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
398
+ var vt = _step.value;
399
+ if (dv.includes(vt) && !points.includes(vt)) points.push(vt);
400
+ }
401
+
402
+ // 2) push remaining vertices from line.vertices
403
+ } catch (err) {
404
+ _iterator.e(err);
405
+ } finally {
406
+ _iterator.f();
407
+ }
408
+ var _iterator2 = _createForOfIteratorHelper(lv),
409
+ _step2;
410
+ try {
411
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
412
+ var _vt = _step2.value;
413
+ if (!points.includes(_vt)) points.push(_vt);
414
+ }
415
+
416
+ // 3) push remaining vertices from drawingLine.vertices
417
+ } catch (err) {
418
+ _iterator2.e(err);
419
+ } finally {
420
+ _iterator2.f();
421
+ }
422
+ var _iterator3 = _createForOfIteratorHelper(dv),
423
+ _step3;
424
+ try {
425
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
426
+ var _vt2 = _step3.value;
427
+ if (!points.includes(_vt2)) points.push(_vt2);
428
+ }
429
+
430
+ // If no points at all, nothing to compute — return 0 (safe fallback)
431
+ } catch (err) {
432
+ _iterator3.e(err);
433
+ } finally {
434
+ _iterator3.f();
435
+ }
436
+ if (points.length === 0) return 0;
437
+
438
+ // Ensure we have at least 3 entries (same behaviour as original)
439
+ while (points.length < 3) points.push(points[points.length - 1]);
440
+ var _points$slice$map = points.slice(0, 3).map(function (idx) {
441
+ var v = vertices === null || vertices === void 0 ? void 0 : vertices[idx];
442
+ return v ? new Three.Vector2(v.x, v.y) : new Three.Vector2(0, 0);
443
+ }),
444
+ _points$slice$map2 = (0, _slicedToArray2["default"])(_points$slice$map, 3),
445
+ c = _points$slice$map2[0],
446
+ p1 = _points$slice$map2[1],
447
+ p2 = _points$slice$map2[2];
448
+ var vec1 = p1.clone().sub(c).normalize();
449
+ var vec2 = p2.clone().sub(c).normalize();
450
+ return Math.floor(vec1.angle() * 180 / Math.PI - vec2.angle() * 180 / Math.PI + 0.5);
451
+ }
452
+ var getRelatedLines = exports.getRelatedLines = function getRelatedLines(tlines, drawingLine, vertices, lines) {
453
+ var exceptLineId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
454
+ if (!(drawingLine !== null && drawingLine !== void 0 && drawingLine.vertices) || !Array.isArray(drawingLine.vertices)) return;
455
+ var seen = new Set();
456
+ var _iterator4 = _createForOfIteratorHelper(drawingLine.vertices),
457
+ _step4;
458
+ try {
459
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
460
+ var vIdx = _step4.value;
461
+ var vertex = vertices === null || vertices === void 0 ? void 0 : vertices[vIdx];
462
+ if (!(vertex !== null && vertex !== void 0 && vertex.lines)) continue;
463
+ var _iterator5 = _createForOfIteratorHelper(vertex.lines),
464
+ _step5;
465
+ try {
466
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
467
+ var lineId = _step5.value;
468
+ if (lineId !== drawingLine.id && lineId !== exceptLineId && !(0, _helper.isEmpty)(lines === null || lines === void 0 ? void 0 : lines[lineId]) && !seen.has(lineId)) {
469
+ seen.add(lineId);
470
+ tlines.push(lines[lineId]);
471
+ }
472
+ }
473
+ } catch (err) {
474
+ _iterator5.e(err);
475
+ } finally {
476
+ _iterator5.f();
477
+ }
478
+ }
479
+ } catch (err) {
480
+ _iterator4.e(err);
481
+ } finally {
482
+ _iterator4.f();
483
+ }
484
+ };
485
+ function snapAngleByUnit(lineAngle, vertices, drawingLine, x, y, dragVertexId) {
486
+ var tx, ty;
487
+ var absAngle = Math.abs(lineAngle);
488
+ // angle snapping as a value of UNIT_ANGLE
489
+ var rest = absAngle % _constants.UNIT_ANGLE;
490
+ var missAngle = _constants.UNIT_ANGLE - rest;
491
+ var isSingleLine = !drawingLine.vertices.some(function (vetID) {
492
+ return vertices[vetID].lines.some(function (lineID) {
493
+ return lineID !== drawingLine.id;
494
+ });
495
+ });
496
+ // the origin point of rotation(snapping)
497
+ var originVerIndex = drawingLine.vertices.findIndex(function (vertice) {
498
+ return vertice !== dragVertexId;
499
+ });
500
+ var originVerId = originVerIndex < 0 ? drawingLine.vertices[0] : drawingLine.vertices[originVerIndex];
501
+ var ox = vertices[originVerId].x;
502
+ var oy = vertices[originVerId].y;
503
+ // check whether the line is snapped to before point.
504
+ if (rest <= _constants.UNIT_ANGLE / 2) {
505
+ // determine the direction of rotation.
506
+ rest = lineAngle > 0 ? rest : -rest;
507
+ rest = isSingleLine ? -rest : rest;
508
+ // rotate the current point to last point around the first point of drawing line.
509
+ tx = rotatePointAroundPoint(x, y, ox, oy, rest).x;
510
+ ty = rotatePointAroundPoint(x, y, ox, oy, rest).y;
511
+ }
512
+ // check whether the line is snapped to next new point.
513
+ else if (rest > _constants.UNIT_ANGLE / 2) {
514
+ // determine the direction of rotation.
515
+ missAngle = lineAngle > 0 ? -missAngle : missAngle;
516
+ missAngle = isSingleLine ? -missAngle : missAngle;
517
+ // rotate the current point to last point around the first point of drawing line.
518
+ tx = rotatePointAroundPoint(x, y, ox, oy, missAngle).x;
519
+ ty = rotatePointAroundPoint(x, y, ox, oy, missAngle).y;
520
+ }
521
+ var resPoint = {
522
+ x: tx,
523
+ y: ty
524
+ };
525
+ return resPoint;
526
+ }
527
+ function absAngleBetweenTwoPoints(x1, y1, x2, y2) {
528
+ return Math.atan2(y2 - y1, Math.abs(x2 - x1));
529
+ }
530
+ function samePoints(_ref, _ref2) {
531
+ var x1 = _ref.x,
532
+ y1 = _ref.y;
533
+ var x2 = _ref2.x,
534
+ y2 = _ref2.y;
535
+ return (0, _math.fAbs)(x1 - x2) <= _constants.EPSILON && (0, _math.fAbs)(y1 - y2) <= _constants.EPSILON;
536
+ }
537
+ function sameDistances(dis1, dis2) {
538
+ return (0, _math.fAbs)(dis1 - dis2) <= _constants.EPSILON;
539
+ }
540
+ function sameMPoints(_ref3, _ref4) {
541
+ var x1 = _ref3.x,
542
+ y1 = _ref3.y;
543
+ var x2 = _ref4.x,
544
+ y2 = _ref4.y;
545
+ return (0, _math.fAbs)(x1 - x2) <= _constants.MEPSILON && (0, _math.fAbs)(y1 - y2) <= _constants.MEPSILON;
546
+ }
547
+ function sameMDistances(dis1, dis2) {
548
+ return (0, _math.fAbs)(dis1 - dis2) <= _constants.MEPSILON;
549
+ }
550
+ function isPointInRect(rect, point) {
551
+ var result = true;
552
+ for (var i = 0; i < rect.length; i++) {
553
+ var pos1 = rect[i];
554
+ var pos2 = rect[(i + 1) % rect.length];
555
+ if (isPointOnLineSegment(pos1.x, pos1.y, pos2.x, pos2.y, point.x, point.y)) {
556
+ result = false;
557
+ }
558
+ }
559
+ return result;
560
+ }
561
+
562
+ /** @description Extend line based on coordinates and new line length
563
+ * @param {number} x1 Vertex 1 x
564
+ * @param {number} y1 Vertex 1 y
565
+ * @param {number} x2 Vertex 2 x
566
+ * @param {number} y2 Vertex 2 y
567
+ * @param {number} newDistance New line length
568
+ * @return {object}
569
+ */
570
+ function extendLine(x1, y1, x2, y2, newDistance) {
571
+ var precision = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 6;
572
+ var rad = angleBetweenTwoPoints(x1, y1, x2, y2);
573
+ return {
574
+ x: (0, _math.toFixedFloat)(x1 + Math.cos(rad) * newDistance, precision),
575
+ y: (0, _math.toFixedFloat)(y1 + Math.sin(rad) * newDistance, precision)
576
+ };
577
+ }
578
+ function roundVertex(vertex) {
579
+ var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
580
+ vertex.set('x', (0, _math.toFixedFloat)(vertex.get('x'), precision));
581
+ vertex.set('y', (0, _math.toFixedFloat)(vertex.get('y'), precision));
582
+ return vertex;
583
+ }
584
+
585
+ //https://github.com/MartyWallace/PolyK
586
+ function ContainsPoint(polygon, pointX, pointY) {
587
+ var n = polygon.length >> 1;
588
+ var ax, lup;
589
+ var ay = polygon[2 * n - 3] - pointY;
590
+ var bx = polygon[2 * n - 2] - pointX;
591
+ var by = polygon[2 * n - 1] - pointY;
592
+ if (bx === 0 && by === 0) return false; // point on edge
593
+
594
+ // let lup = by > ay;
595
+ for (var ii = 0; ii < n; ii++) {
596
+ ax = bx;
597
+ ay = by;
598
+ bx = polygon[2 * ii] - pointX;
599
+ by = polygon[2 * ii + 1] - pointY;
600
+ if (bx === 0 && by === 0) return false; // point on edge
601
+ if (ay === by) continue;
602
+ lup = by > ay;
603
+ }
604
+ var depth = 0;
605
+ for (var i = 0; i < n; i++) {
606
+ ax = bx;
607
+ ay = by;
608
+ bx = polygon[2 * i] - pointX;
609
+ by = polygon[2 * i + 1] - pointY;
610
+ if (ay < 0 && by < 0) continue; // both 'up' or both 'down'
611
+ if (ay > 0 && by > 0) continue; // both 'up' or both 'down'
612
+ if (ax < 0 && bx < 0) continue; // both points on the left
613
+
614
+ if (ay === by && Math.min(ax, bx) < 0) return true;
615
+ if (ay === by) continue;
616
+ var lx = ax + (bx - ax) * -ay / (by - ay);
617
+ if (lx === 0) return false; // point on edge
618
+ if (lx > 0) depth++;
619
+ if (ay === 0 && lup && by > ay) depth--; // hit vertex, both up
620
+ if (ay === 0 && !lup && by < ay) depth--; // hit vertex, both down
621
+ lup = by > ay;
622
+ }
623
+ return (depth & 1) === 1;
624
+ }
625
+ function cosWithThreshold(alpha, threshold) {
626
+ var cos = Math.cos(alpha);
627
+ return cos < threshold ? 0 : cos;
628
+ }
629
+ function sinWithThreshold(alpha, threshold) {
630
+ var sin = Math.sin(alpha);
631
+ return sin < threshold ? 0 : sin;
632
+ }
633
+ function midPoint(x1, y1, x2, y2) {
634
+ return {
635
+ x: (x1 + x2) / 2,
636
+ y: (y1 + y2) / 2
637
+ };
638
+ }
639
+ function verticesMidPoint(verticesArray) {
640
+ var res = verticesArray.reduce(function (incr, vertex) {
641
+ return {
642
+ x: incr.x + vertex.x,
643
+ y: incr.y + vertex.y
644
+ };
645
+ }, {
646
+ x: 0,
647
+ y: 0
648
+ });
649
+ return {
650
+ x: res.x / verticesArray.length,
651
+ y: res.y / verticesArray.length
652
+ };
653
+ }
654
+ function rotatePointAroundPoint(px, py, ox, oy, theta) {
655
+ var thetaRad = theta * Math.PI / 180;
656
+ var cos = Math.cos(thetaRad);
657
+ var sin = Math.sin(thetaRad);
658
+ var deltaX = px - ox;
659
+ var deltaY = py - oy;
660
+ return {
661
+ x: cos * deltaX - sin * deltaY + ox,
662
+ y: sin * deltaX + cos * deltaY + oy
663
+ };
664
+ }
665
+
666
+ // point: x,y
667
+ // itemrectInfo: pos(x,y),rotRad,size,layoutpos,is_corner
668
+ // calcRect: rect(point[4]),pos(x,y),rotRad,size,layoutpos,is_corner
669
+
670
+ function point(x, y) {
671
+ return {
672
+ x: x,
673
+ y: y
674
+ };
675
+ }
676
+ function itemrectInfo(x, y, rotRad, size, layoutpos, is_corner) {
677
+ return {
678
+ pos: {
679
+ x: x,
680
+ y: y
681
+ },
682
+ rotRad: rotRad,
683
+ size: size,
684
+ layoutpos: layoutpos,
685
+ is_corner: is_corner
686
+ };
687
+ }
688
+ function getCalcRectFromItem(item) {
689
+ var itemInfo;
690
+ if (item === undefined) itemInfo = [];else itemInfo = item.item;
691
+ var x = item.pos.x;
692
+ var y = item.pos.y;
693
+ var rotRad = item.rotRad;
694
+ var w = item.size && item.size.width / 2;
695
+ var h = item.size && item.size.height / 2;
696
+ var mx = x - w * Math.cos(rotRad);
697
+ var my = y - w * Math.sin(rotRad);
698
+ var x0 = mx + h * Math.sin(rotRad);
699
+ var y0 = my - h * Math.cos(rotRad);
700
+ var x3 = mx * 2 - x0;
701
+ var y3 = my * 2 - y0;
702
+ var x1 = x * 2 - x3;
703
+ var y1 = y * 2 - y3;
704
+ var x2 = x * 2 - x0;
705
+ var y2 = y * 2 - y0;
706
+ return {
707
+ rect: [point(x0, y0), point(x1, y1), point(x2, y2), point(x3, y3)],
708
+ pos: point(x, y),
709
+ rotRad: rotRad,
710
+ size: item.size,
711
+ layoutpos: item.layoutpos,
712
+ is_corner: item.is_corner,
713
+ itemInfo: itemInfo
714
+ };
715
+ }
716
+ function getCalcRectFromItem3D(item) {
717
+ var itemInfo;
718
+ if (item === undefined) itemInfo = [];else itemInfo = item.item;
719
+ var x = item.pos.x;
720
+ var y = item.pos.y;
721
+ var rotRad = item.rotRad;
722
+ var w = item.size.width / 2;
723
+ var h = item.size.depth / 2;
724
+ var mx = x - w * Math.cos(rotRad);
725
+ var my = y - w * Math.sin(rotRad);
726
+ var x0 = mx + h * Math.sin(rotRad);
727
+ var y0 = my - h * Math.cos(rotRad);
728
+ var x3 = mx * 2 - x0;
729
+ var y3 = my * 2 - y0;
730
+ var x1 = x * 2 - x3;
731
+ var y1 = y * 2 - y3;
732
+ var x2 = x * 2 - x0;
733
+ var y2 = y * 2 - y0;
734
+ return {
735
+ rect: [point(x0, y0), point(x1, y1), point(x2, y2), point(x3, y3)],
736
+ pos: point(x, y),
737
+ rotRad: rotRad,
738
+ size: item.size,
739
+ layoutpos: item.layoutpos,
740
+ is_corner: item.is_corner,
741
+ itemInfo: itemInfo
742
+ };
743
+ }
744
+ function getAllItems(scene, catalog, allLineRects) {
745
+ var layerID = scene.selectedLayer;
746
+ var layer = scene.layers.get(layerID);
747
+ var curiteminfo;
748
+ var iteminfo = [];
749
+ var otherItems = [];
750
+ var selectedItem;
751
+ var currentItem;
752
+ if (layer.selected.items.size > 0) {
753
+ selectedItem = layer.getIn(['items', layer.selected.items.get(0)]);
754
+ var catid = selectedItem.type;
755
+ var cat = catalog.elements[catid];
756
+ if (!cat) cat = catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(catid)];
757
+ currentItem = {
758
+ selectedItem: selectedItem,
759
+ cat: cat
760
+ };
761
+ }
762
+ layer.items.forEach(function (item) {
763
+ var val = {
764
+ pos: {
765
+ x: item.x,
766
+ y: item.y
767
+ },
768
+ rotRad: item.rotation / 180 * Math.PI
769
+ };
770
+ var catid = item.type;
771
+ var cat = catalog.elements[catid];
772
+ if (!cat) {
773
+ cat = catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(catid)];
774
+ }
775
+ var sizeinfo = [];
776
+ var width, height, depth;
777
+ sizeinfo = {
778
+ width: item.properties.get('width').get('_length'),
779
+ height: item.properties.get('height').get('_length'),
780
+ depth: item.properties.get('depth').get('_length'),
781
+ widthUnit: item.properties.get('width').get('_unit'),
782
+ heightUnit: item.properties.get('height').get('_unit'),
783
+ depthUnit: item.properties.get('depth').get('_unit')
784
+ };
785
+ sizeinfo = _objectSpread(_objectSpread({}, sizeinfo), {}, {
786
+ layoutpos: cat && cat.info.layoutpos,
787
+ is_corner: cat && cat.info.is_corner
788
+ });
789
+ width = (0, _convertUnitsLite.convert)(sizeinfo.width).from(sizeinfo.widthUnit).to(scene.unit);
790
+ height = (0, _convertUnitsLite.convert)(sizeinfo.depth).from(sizeinfo.depthUnit).to(scene.unit);
791
+ depth = (0, _convertUnitsLite.convert)(sizeinfo.height).from(sizeinfo.heightUnit).to(scene.unit);
792
+ val.size = {
793
+ width: width,
794
+ height: height,
795
+ depth: depth
796
+ };
797
+ val.layoutpos = sizeinfo.layoutpos;
798
+ val.is_corner = sizeinfo.is_corner;
799
+ val.doorStyle = item.doorStyle;
800
+ val.item = item;
801
+ var otherItem = {
802
+ item: item,
803
+ cat: cat
804
+ };
805
+ if (!needSnap(currentItem, otherItem)) {
806
+ return;
807
+ }
808
+ if (item.selected) {
809
+ curiteminfo = getCalcRectFromItem(val);
810
+ } else {
811
+ var calcrect = getCalcRectFromItem(val);
812
+ calcrect.isSnappedLine = isSnappedLine(calcrect, allLineRects);
813
+ iteminfo.push(calcrect);
814
+ otherItems.push(otherItem);
815
+ }
816
+ });
817
+ return {
818
+ cur: curiteminfo,
819
+ others: iteminfo,
820
+ currentItem: currentItem,
821
+ otherItems: otherItems
822
+ };
823
+ }
824
+ function getAllItemSpecified(scene, catalog, filter) {
825
+ var _scene$layers, _scene$layers$get;
826
+ var snappedLineRect = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
827
+ var layerID = scene === null || scene === void 0 ? void 0 : scene.selectedLayer;
828
+ var layer = scene === null || scene === void 0 || (_scene$layers = scene.layers) === null || _scene$layers === void 0 || (_scene$layers$get = _scene$layers.get) === null || _scene$layers$get === void 0 ? void 0 : _scene$layers$get.call(_scene$layers, layerID);
829
+ if (!layer || !layer.items) return {
830
+ cur: null,
831
+ others: []
832
+ };
833
+ var curiteminfo;
834
+ var iteminfo = [];
835
+ layer.items.forEach(function (item) {
836
+ var _cat$obj;
837
+ if (!item) return;
838
+ var val = {
839
+ pos: {
840
+ x: item.x,
841
+ y: item.y
842
+ },
843
+ rotRad: item.rotation / 180 * Math.PI
844
+ };
845
+ var cat = item.type ? findCatalogElement(catalog, item.type) : null;
846
+ var info = cat === null || cat === void 0 ? void 0 : cat.info;
847
+ var props = item.properties;
848
+ var getSize = function getSize(key) {
849
+ var _props$getIn, _props$getIn2, _props$getIn3;
850
+ var length = props === null || props === void 0 || (_props$getIn = props.getIn) === null || _props$getIn === void 0 ? void 0 : _props$getIn.call(props, [key, '_length']);
851
+ return length != null ? (0, _convertUnitsLite.convert)(length).from((_props$getIn2 = props === null || props === void 0 || (_props$getIn3 = props.getIn) === null || _props$getIn3 === void 0 ? void 0 : _props$getIn3.call(props, [key, '_unit'])) !== null && _props$getIn2 !== void 0 ? _props$getIn2 : 'in').to(scene.unit) : 0;
852
+ };
853
+ val.size = {
854
+ width: getSize('width'),
855
+ height: getSize('height'),
856
+ depth: getSize('depth')
857
+ };
858
+ val.item = item;
859
+ if (info) {
860
+ val.layoutpos = info.layoutpos;
861
+ val.is_corner = info.is_corner;
862
+ }
863
+
864
+ // Filter check
865
+ if (Array.isArray(filter)) {
866
+ if (info && !filter.includes(info.layoutpos)) return;
867
+ } else if ((info === null || info === void 0 ? void 0 : info.layoutpos) !== filter || (0, _helper.isEmpty)(cat) || (cat === null || cat === void 0 ? void 0 : cat.type) === 'appliance' && ['Cook Top', 'Microwave'].includes(cat === null || cat === void 0 || (_cat$obj = cat.obj) === null || _cat$obj === void 0 ? void 0 : _cat$obj.category)) {
868
+ return;
869
+ }
870
+
871
+ // Current vs others
872
+ var rect = getCalcRectFromItem3D(val);
873
+
874
+ // check current item is snapped to the [snappedLineRect]
875
+ if (!(0, _helper.isEmpty)(snappedLineRect)) {
876
+ var isSnapped = false;
877
+ var overlapList = [_constants.OVERLAP_INCLUDED, _constants.OVERLAP_SAME, _constants.OVERLAP_SOME];
878
+ for (var i = 0; i < (rect === null || rect === void 0 || (_rect$rect = rect.rect) === null || _rect$rect === void 0 ? void 0 : _rect$rect.length); i++) {
879
+ var _rect$rect;
880
+ if (isSnapped) break;
881
+ var curItemPt = rect.rect[i];
882
+ var nextItemPt = i === rect.rect.length - 1 ? rect.rect[0] : rect.rect[i + 1];
883
+ var srcLine = {
884
+ x1: curItemPt.x,
885
+ y1: curItemPt.y,
886
+ x2: nextItemPt.x,
887
+ y2: nextItemPt.y
888
+ };
889
+ for (var j = 0; j < (snappedLineRect === null || snappedLineRect === void 0 ? void 0 : snappedLineRect.length); j++) {
890
+ var curLineRectPt = snappedLineRect[j];
891
+ var nextLineRectPt = j === snappedLineRect.length - 1 ? snappedLineRect[0] : snappedLineRect[j + 1];
892
+ var destLine = {
893
+ x1: curLineRectPt.x,
894
+ y1: curLineRectPt.y,
895
+ x2: nextLineRectPt.x,
896
+ y2: nextLineRectPt.y
897
+ };
898
+ if (overlapList.includes(relationshipOfTwoOverlappedLines(srcLine, destLine).result)) {
899
+ isSnapped = true;
900
+ break;
901
+ }
902
+ }
903
+ }
904
+ if (!isSnapped) return;
905
+ }
906
+ if (item.selected) {
907
+ curiteminfo = rect;
908
+ } else {
909
+ iteminfo.push(rect);
910
+ }
911
+ });
912
+ return {
913
+ cur: curiteminfo,
914
+ others: iteminfo
915
+ };
916
+ }
917
+ function findCatalogElement(catalog, elementName) {
918
+ if (!elementName || !catalog) return null;
919
+ var variants = [elementName, elementName.toLowerCase()];
920
+ var deepVariants = variants.map(function (v) {
921
+ return (0, _utils.returnReplaceableDeepSearchType)(v);
922
+ }).filter(Boolean);
923
+ var allCandidates = [].concat(variants, (0, _toConsumableArray2["default"])(deepVariants));
924
+ var getElement = function getElement(catid) {
925
+ if (!catid) return null;
926
+
927
+ // Immutable.js Map
928
+ if (typeof catalog.getIn === 'function') {
929
+ return catalog.getIn(['elements', catid]);
930
+ }
931
+
932
+ // Plain JS object
933
+ if (catalog.elements && catalog.elements[catid]) {
934
+ return catalog.elements[catid];
935
+ }
936
+ return null;
937
+ };
938
+ var _iterator6 = _createForOfIteratorHelper(allCandidates),
939
+ _step6;
940
+ try {
941
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
942
+ var name = _step6.value;
943
+ var cat = getElement(name);
944
+ if (cat) return cat;
945
+ }
946
+ } catch (err) {
947
+ _iterator6.e(err);
948
+ } finally {
949
+ _iterator6.f();
950
+ }
951
+ return null;
952
+ }
953
+ function isSnappedLine(calcrect, allLineRects) {
954
+ if (allLineRects === undefined) return false;
955
+ var r2 = calcrect.rect[2];
956
+ var r3 = calcrect.rect[3];
957
+ var result = allLineRects.some(function (linerect) {
958
+ var l2 = linerect.rect[2];
959
+ var l3 = linerect.rect[3];
960
+ var delta = verticesDistance(l2, r3) + verticesDistance(r3, r2) + verticesDistance(r2, l3) - verticesDistance(l3, l2);
961
+ if (delta < _constants.EPSILON) {
962
+ return true;
963
+ } else {
964
+ l2 = linerect.rect[3];
965
+ l3 = linerect.rect[2];
966
+ delta = verticesDistance(l2, r3) + verticesDistance(r3, r2) + verticesDistance(r2, l3) - verticesDistance(l3, l2);
967
+ return delta < _constants.EPSILON;
968
+ }
969
+ });
970
+ return result;
971
+ }
972
+ function isSnappedSideLine(calcrect, allLineRects) {
973
+ if (allLineRects === undefined) return 0;
974
+ var r2 = calcrect.rect[1];
975
+ var r3 = calcrect.rect[2];
976
+ var result = allLineRects.some(function (linerect) {
977
+ var l2 = linerect.rect[2];
978
+ var l3 = linerect.rect[3];
979
+ var delta = verticesDistance(l2, r3) + verticesDistance(r3, r2) + verticesDistance(r2, l3) - verticesDistance(l3, l2);
980
+ return delta < _constants.EPSILON;
981
+ });
982
+ return result;
983
+ }
984
+
985
+ /** Calculate candidate positions */
986
+ function getAllItemSnap(allItemRects) {
987
+ var allItemSnap = [];
988
+ var cur = allItemRects.cur;
989
+
990
+ // For development
991
+ var otherItems = allItemRects.otherItems,
992
+ currentItem = allItemRects.currentItem;
993
+ allItemRects.others.forEach(function (rect, index) {
994
+ var cw = cur && cur.size.width / 2;
995
+ var ch = cur && cur.size.height / 2;
996
+ var cos = Math.cos(rect.rotRad);
997
+ var sin = Math.sin(rect.rotRad);
998
+ var ox0 = cw * cos - ch * sin; // (cw, ch) rot
999
+ var oy0 = cw * sin + ch * cos;
1000
+ var ox1 = -cw * cos - ch * sin; // (-cw, ch) rot
1001
+ var oy1 = -cw * sin + ch * cos;
1002
+ var ox2 = ch * sin - cw * cos;
1003
+ var oy2 = -ch * cos - cw * sin;
1004
+ var ox3 = ch * sin + cw * cos;
1005
+ var oy3 = -ch * cos + cw * sin;
1006
+ var nrot = rect.rotRad + Math.PI;
1007
+ if (nrot >= Math.PI) nrot -= Math.PI * 2;
1008
+ var snap1 = itemrectInfo(rect.rect[2].x + ox3, rect.rect[2].y + oy3, rect.rotRad, cur && cur.size, rect.layoutpos, rect.is_corner);
1009
+ var snap2 = itemrectInfo(rect.rect[3].x + ox2, rect.rect[3].y + oy2, rect.rotRad, cur && cur.size, rect.layoutpos, rect.is_corner);
1010
+ var snap3 = itemrectInfo(rect.rect[2].x + ox1, rect.rect[2].y + oy1, nrot, cur && cur.size, rect.layoutpos, rect.is_corner);
1011
+ var snap4 = itemrectInfo(rect.rect[3].x + ox0, rect.rect[3].y + oy0, nrot, cur && cur.size, rect.layoutpos, rect.is_corner);
1012
+ var sizeinfo = otherItems[index].cat && otherItems[index].cat.info.sizeinfo;
1013
+ if (sizeinfo) {
1014
+ var leftBlindLength = sizeinfo.leftBlindLength,
1015
+ rightBlindLength = sizeinfo.rightBlindLength;
1016
+ if (leftBlindLength > 0) {
1017
+ var vx = leftBlindLength - ch;
1018
+ var vy = cw;
1019
+ var dx = vx * cos + vy * sin;
1020
+ var dy = vx * sin - vy * cos;
1021
+ var snap6 = itemrectInfo(rect.rect[0].x + dx, rect.rect[0].y + dy, rect.rotRad + Math.PI / 2, cur && cur.size, rect.layoutpos, rect.is_corner);
1022
+ allItemSnap.push(snap6);
1023
+ }
1024
+ if (rightBlindLength > 0) {
1025
+ var _vx = ch - rightBlindLength;
1026
+ var _vy = cw;
1027
+ var _dx = _vx * cos + _vy * sin;
1028
+ var _dy = _vx * sin - _vy * cos;
1029
+ var snap7 = itemrectInfo(rect.rect[1].x + _dx, rect.rect[1].y + _dy, rect.rotRad - Math.PI / 2, cur && cur.size, rect.layoutpos, rect.is_corner);
1030
+ allItemSnap.push(snap7);
1031
+ }
1032
+ }
1033
+ if (rect.isSnappedLine) {
1034
+ snap1.isSnappedLine = true;
1035
+ snap2.isSnappedLine = true;
1036
+ }
1037
+ if (rect.is_corner) {
1038
+ var _nrot = rect.rotRad + Math.PI * 3 / 2;
1039
+ if (_nrot >= Math.PI) _nrot -= Math.PI * 2;
1040
+ var snap5 = itemrectInfo(rect.rect[1].x - oy1, rect.rect[1].y + ox1, _nrot, cur && cur.size, rect.layoutpos, rect.is_corner);
1041
+ allItemSnap.push(snap2);
1042
+ allItemSnap.push(snap5);
1043
+ } else {
1044
+ allItemSnap.push(snap1);
1045
+ allItemSnap.push(snap2);
1046
+ allItemSnap.push(snap3);
1047
+ allItemSnap.push(snap4);
1048
+ }
1049
+ });
1050
+ return allItemSnap;
1051
+ }
1052
+ function getAllArea(layer) {
1053
+ var allAreaLines = [];
1054
+ var allLines = [];
1055
+ var verticesArray = [];
1056
+ var vertexID_to_verticesArrayIndex = {};
1057
+ layer.vertices.forEach(function (vertex) {
1058
+ var verticesCount = verticesArray.push([vertex.x, vertex.y]);
1059
+ var latestVertexIndex = verticesCount - 1;
1060
+ vertexID_to_verticesArrayIndex[vertex.id] = latestVertexIndex;
1061
+ });
1062
+ layer.areas.forEach(function (area) {
1063
+ allAreaLines.push(area.vertices);
1064
+ });
1065
+ allAreaLines.forEach(function (area) {
1066
+ var pt = [];
1067
+ area.forEach(function (element) {
1068
+ pt.push({
1069
+ x: verticesArray[vertexID_to_verticesArrayIndex[element]][0],
1070
+ y: verticesArray[vertexID_to_verticesArrayIndex[element]][1]
1071
+ });
1072
+ });
1073
+ allLines.push(pt);
1074
+ });
1075
+ return allLines;
1076
+ }
1077
+
1078
+ /** Get all lines of the scene */
1079
+ function getAllLines(layer) {
1080
+ var allArea = getAllArea(layer);
1081
+ var allAreaLines = [];
1082
+ var allVertices = layer.get('vertices').toJS();
1083
+ layer.lines.forEach(function (tline) {
1084
+ var line = tline.toJS();
1085
+ if (isPointInArea(allArea, allVertices[line.vertices[0]]) || isPointInArea(allArea, allVertices[line.vertices[1]])) {
1086
+ allAreaLines.push(line.vertices.reverse());
1087
+ }
1088
+ });
1089
+ var allLines = [];
1090
+ //let allNonAreaLines = [];
1091
+ var thick = _constants.LINE_THICKNESS / 2;
1092
+ layer.lines.forEach(function (line) {
1093
+ var i = containLine(allAreaLines, line);
1094
+ // let thick = line.properties.getIn(['thickness', 'length']);
1095
+ if (i < 0) {
1096
+ var vertices = line.vertices.toJS();
1097
+ var tmp_vertices = {
1098
+ x1: layer.vertices.get(vertices[0]).x,
1099
+ y1: layer.vertices.get(vertices[0]).y,
1100
+ x2: layer.vertices.get(vertices[1]).x,
1101
+ y2: layer.vertices.get(vertices[1]).y
1102
+ };
1103
+ if (tmp_vertices.x1 == tmp_vertices.x2 && tmp_vertices.y1 == tmp_vertices.y2) return;
1104
+ var addIdx = allLines.length;
1105
+ var flag = 0;
1106
+ allLines.forEach(function (element, idx) {
1107
+ if (flag == 0) {
1108
+ var el = element[0];
1109
+ var tmp_el = {
1110
+ x1: layer.vertices.get(el[0]).x,
1111
+ y1: layer.vertices.get(el[0]).y,
1112
+ x2: layer.vertices.get(el[1]).x,
1113
+ y2: layer.vertices.get(el[1]).y
1114
+ };
1115
+ if (tmp_el.x1 == tmp_vertices.x1 && tmp_el.y1 == tmp_vertices.y1) {
1116
+ var tmp = vertices[0];
1117
+ vertices[0] = vertices[1];
1118
+ vertices[1] = tmp;
1119
+ addIdx = idx == 0 ? 0 : idx - 1;
1120
+ flag = 1;
1121
+ } else if (tmp_el.x2 == tmp_vertices.x1 && tmp_el.y2 == tmp_vertices.y1) {
1122
+ addIdx = idx;
1123
+ flag = 1;
1124
+ } else if (tmp_el.x1 == tmp_vertices.x2 && tmp_el.y1 == tmp_vertices.y2) {
1125
+ addIdx = idx == 0 ? 0 : idx - 1;
1126
+ flag = 1;
1127
+ } else if (tmp_el.x2 == tmp_vertices.x2 && tmp_el.y2 == tmp_vertices.y2) {
1128
+ var _tmp = vertices[0];
1129
+ vertices[0] = vertices[1];
1130
+ vertices[1] = _tmp;
1131
+ addIdx = idx;
1132
+ flag = 1;
1133
+ }
1134
+ }
1135
+ });
1136
+ allLines.splice(addIdx, 0, [vertices, thick, line.id]);
1137
+ } else {
1138
+ allLines.push([allAreaLines[i], thick, line.id]);
1139
+ }
1140
+ });
1141
+ return allLines;
1142
+ }
1143
+
1144
+ /** Get lines that wraps the area */
1145
+ function getAllAreaLines(layer) {
1146
+ var areainfo = [];
1147
+ layer.areas.forEach(function (area) {
1148
+ var sz = area.vertices.size;
1149
+ for (var i = 0; i < sz; i++) {
1150
+ areainfo.push([area.vertices.get(i), area.vertices.get((i + 1) % sz)]);
1151
+ }
1152
+ });
1153
+ return areainfo;
1154
+ }
1155
+ function containLine(lines, line) {
1156
+ // lines: [array]
1157
+ var sz = lines.length;
1158
+ for (var i = 0; i < sz; i++) {
1159
+ var l = lines[i];
1160
+ if (line.vertices.get(0) == l[0] && line.vertices.get(1) == l[1] || line.vertices.get(1) == l[0] && line.vertices.get(0) == l[1]) {
1161
+ return i;
1162
+ }
1163
+ }
1164
+ return -1;
1165
+ }
1166
+ function buildRectFromLines(layer, lines) {
1167
+ var rect = [];
1168
+ lines.forEach(function (line) {
1169
+ var vxys = []; // 0: x0, 1: y0, 2: x1, 3: y1
1170
+ line[0].forEach(function (vertex) {
1171
+ var vert = layer.vertices.get(vertex);
1172
+ vxys.push(vert.x);
1173
+ vxys.push(vert.y);
1174
+ });
1175
+ var thick = line[1];
1176
+ var x0 = vxys[0];
1177
+ var y0 = vxys[1];
1178
+ var x1 = vxys[2];
1179
+ var y1 = vxys[3];
1180
+ var rectLine = getCalcRectFromLine(x0, y0, x1, y1, thick, layer);
1181
+ rectLine.lineId = line.length > 2 ? line[2] : null;
1182
+ rect.push(rectLine);
1183
+ });
1184
+ return rect;
1185
+ }
1186
+ function getRelatedVertices(x0, y0, x1, y1, layer) {
1187
+ var verticesArray = [];
1188
+ var mapVertIDtoIndex = {};
1189
+ layer.vertices.forEach(function (vertex) {
1190
+ var verticesCount = verticesArray.push([vertex.x, vertex.y]);
1191
+ var latestVertexIndex = verticesCount - 1;
1192
+ mapVertIDtoIndex[vertex.id] = latestVertexIndex;
1193
+ });
1194
+ var relVerts = [];
1195
+ layer.lines.some(function (line) {
1196
+ var vertID0 = line.vertices.get(0);
1197
+ var vertID1 = line.vertices.get(1);
1198
+ var pt0 = {
1199
+ x: verticesArray[mapVertIDtoIndex[vertID0]][0],
1200
+ y: verticesArray[mapVertIDtoIndex[vertID0]][1]
1201
+ };
1202
+ var pt1 = {
1203
+ x: verticesArray[mapVertIDtoIndex[vertID1]][0],
1204
+ y: verticesArray[mapVertIDtoIndex[vertID1]][1]
1205
+ };
1206
+ if (Math.abs(pt0.x - x0) < _constants.EPSILON && Math.abs(pt0.y - y0) < _constants.EPSILON && Math.abs(pt1.x - x1) < _constants.EPSILON && Math.abs(pt1.y - y1) < _constants.EPSILON || Math.abs(pt0.x - x1) < _constants.EPSILON && Math.abs(pt0.y - y1) < _constants.EPSILON && Math.abs(pt1.x - x0) < _constants.EPSILON && Math.abs(pt1.y - y0) < _constants.EPSILON) {
1207
+ if (line.relatedVertices.size == 2) {
1208
+ var relPt0 = point(x0, y0);
1209
+ var relPt1 = point(x1, y1);
1210
+ line.relatedVertices.forEach(function (relatedVertice, index) {
1211
+ if (relatedVertice.index == undefined) relatedVertice = relatedVertice.toJSON();
1212
+ if (relatedVertice.index == 0) relPt0 = point(relatedVertice.point.x, relatedVertice.point.y);else relPt1 = point(relatedVertice.point.x, relatedVertice.point.y);
1213
+ });
1214
+ relVerts.push(relPt0);
1215
+ relVerts.push(relPt1);
1216
+ }
1217
+ return true;
1218
+ }
1219
+ });
1220
+ return relVerts;
1221
+ }
1222
+ function getCalcRectFromLine(x0, y0, x1, y1, thick, layer) {
1223
+ // get line from vertex coordinate
1224
+ var relVerts = getRelatedVertices(x0, y0, x1, y1, layer);
1225
+ var dx = x1 - x0;
1226
+ var dy = y1 - y0;
1227
+ var dl = Math.sqrt(dx * dx + dy * dy);
1228
+ var ox = -dy / dl * thick;
1229
+ var oy = dx / dl * thick;
1230
+ var rot = Math.atan2(dy, dx);
1231
+ if (relVerts.length == 2) {
1232
+ var vN = point(ox, oy);
1233
+ var vR = point(relVerts[0].x - x0, relVerts[0].y - y0);
1234
+ if (dotprod(vN, vR) < 0) {
1235
+ ox = -ox;
1236
+ oy = -oy;
1237
+ } else {
1238
+ rot += Math.PI;
1239
+ }
1240
+ } else {
1241
+ ox = -ox;
1242
+ oy = -oy;
1243
+ }
1244
+ return {
1245
+ rectEnd: [point(x0 + ox / 2, y0 + oy / 2), point(x1 + ox / 2, y1 + oy / 2)],
1246
+ rect: [point(x0 + ox, y0 + oy), point(x1 + ox, y1 + oy), point(x1, y1), point(x0, y0)],
1247
+ pos: point((x0 + x1 + ox) / 2, (y0 + y1 + ox) / 2),
1248
+ rotRad: rot,
1249
+ size: {
1250
+ width: dl,
1251
+ height: thick / 2
1252
+ }
1253
+ };
1254
+ }
1255
+ function getAllLineSnap(allLineRects, curItemRect) {
1256
+ var allLineSnap = [];
1257
+ var cur = curItemRect;
1258
+ if (cur === undefined || cur === null) return;else allLineRects.forEach(function (rect) {
1259
+ var cw = cur.size.width / 2;
1260
+ var ch = cur.size.height / 2;
1261
+ var cos = Math.cos(rect.rotRad);
1262
+ var sin = Math.sin(rect.rotRad);
1263
+ var ox0 = cw * cos - ch * sin; // (cw, ch) rot
1264
+ var oy0 = cw * sin + ch * cos;
1265
+ var ox1 = -cw * cos - ch * sin; // (-cw, ch) rot
1266
+ var oy1 = -cw * sin + ch * cos;
1267
+ var nrot = rect.rotRad + Math.PI;
1268
+ if (nrot >= Math.PI) nrot -= Math.PI * 2;
1269
+ var thick = rect.size.height;
1270
+ var snap3 = itemInfo(rect.rect[2].x + ox1, rect.rect[2].y + oy1, nrot, cur.size);
1271
+ var snap4 = itemInfo(rect.rect[3].x + ox0, rect.rect[3].y + oy0, nrot, cur.size);
1272
+ if (!cur.is_corner) {
1273
+ allLineSnap.push(snap3);
1274
+ }
1275
+ allLineSnap.push(snap4);
1276
+ });
1277
+ return allLineSnap;
1278
+ }
1279
+ function validateSnaps(allSnaps, allRects) {
1280
+ var validSnaps = [];
1281
+ if (allSnaps !== undefined && allSnaps !== null && allSnaps.length > 0) allSnaps.forEach(function (snap) {
1282
+ if (validSnap(snap, allRects)) {
1283
+ validSnaps.push(snap);
1284
+ }
1285
+ });
1286
+ return validSnaps;
1287
+ }
1288
+ function validateLineSnaps(allSnaps, allItemSnap, allLineSnap, allItemRects, allLineRects, allRects) {
1289
+ var validSnaps = [];
1290
+ var addFlag = true;
1291
+ allSnaps.forEach(function (snap) {
1292
+ if (validSnap(snap, allRects)) {
1293
+ validSnaps.push(snap);
1294
+ } else if (addFlag) {
1295
+ allItemSnap.forEach(function (snap) {
1296
+ validSnaps.push(snap);
1297
+ });
1298
+ allLineSnap.forEach(function (snap) {
1299
+ validSnaps.push(snap);
1300
+ });
1301
+ addFlag = false;
1302
+ }
1303
+ });
1304
+ return validSnaps;
1305
+ }
1306
+ function validSnap(snap, rects) {
1307
+ var snaprect = getCalcRectFromItem(snap);
1308
+ return rects.every(function (rect) {
1309
+ return !intersectRect(rect.rect, snaprect.rect);
1310
+ });
1311
+ }
1312
+ function itemInfo(x, y, rotRad, size) {
1313
+ return {
1314
+ pos: {
1315
+ x: x,
1316
+ y: y
1317
+ },
1318
+ rotRad: rotRad,
1319
+ size: size
1320
+ };
1321
+ }
1322
+ function intersectRect(rect1, rect2) {
1323
+ var ret = false;
1324
+ rect1 = shrinkRect(rect1);
1325
+ rect2 = shrinkRect(rect2);
1326
+ ret = ret || getInterSect(rect1, rect2);
1327
+ ret = ret || rect1.some(function (pt) {
1328
+ return containPointInRect(pt, rect2);
1329
+ });
1330
+ ret = ret || rect2.some(function (pt) {
1331
+ return containPointInRect(pt, rect1);
1332
+ });
1333
+ return ret;
1334
+ }
1335
+ function containPointInRect(point, rect) {
1336
+ // true: contain, false: not contain
1337
+ for (var i = 0; i < rect.length; i++) {
1338
+ var ni = (i + 1) % rect.length;
1339
+ if (crossprod(diff(point, rect[i]), diff(rect[i], rect[ni])) < 0) {
1340
+ return false;
1341
+ }
1342
+ }
1343
+ return true;
1344
+ }
1345
+ function diff(v0, v1) {
1346
+ return {
1347
+ x: v0.x - v1.x,
1348
+ y: v0.y - v1.y
1349
+ };
1350
+ }
1351
+ function crossprod(v0, v1) {
1352
+ return v0.x * v1.y - v0.y * v1.x;
1353
+ }
1354
+ function shrinkRect(rect) {
1355
+ var v02x = rect[2].x - rect[0].x;
1356
+ var v02y = rect[2].y - rect[0].y;
1357
+ var d02 = Math.sqrt(v02x * v02x + v02y * v02y);
1358
+ var o02x = v02x / d02 * 0.1;
1359
+ var o02y = v02y / d02 * 0.1;
1360
+ var v13x = rect[3].x - rect[1].x;
1361
+ var v13y = rect[3].y - rect[1].y;
1362
+ var d13 = Math.sqrt(v02x * v02x + v02y * v02y);
1363
+ var o13x = v13x / d13 * 0.1;
1364
+ var o13y = v13y / d13 * 0.1;
1365
+ return [point(rect[0].x + o02x, rect[0].y + o02y), point(rect[1].x + o13x, rect[1].y + o13y), point(rect[2].x - o02x, rect[2].y - o02y), point(rect[3].x - o13x, rect[3].y - o13y)];
1366
+ }
1367
+ function getInterSect(shape1, shape2) {
1368
+ // return result of intersect of two shape
1369
+ var count = 0;
1370
+ for (var i = 0; i < shape1.length; i++) {
1371
+ var sl1 = {
1372
+ x: shape1[i].x,
1373
+ y: shape1[i].y
1374
+ };
1375
+ var sl2 = {
1376
+ x: shape1[(i + 1) % shape1.length].x,
1377
+ y: shape1[(i + 1) % shape1.length].y
1378
+ };
1379
+ for (var j = 0; j < shape2.length; j++) {
1380
+ var el1 = {
1381
+ x: shape2[j].x,
1382
+ y: shape2[j].y
1383
+ };
1384
+ var el2 = {
1385
+ x: shape2[(j + 1) % shape2.length].x,
1386
+ y: shape2[(j + 1) % shape2.length].y
1387
+ };
1388
+ var flag = getLineInterSect(sl1.x, sl1.y, sl2.x, sl2.y, el1.x, el1.y, el2.x, el2.y);
1389
+ if (flag) {
1390
+ count++;
1391
+ if (count > 1) return true;
1392
+ }
1393
+ }
1394
+ }
1395
+ return false;
1396
+ }
1397
+ function getLineInterSect(s1x, s1y, e1x, e1y, s2x, s2y, e2x, e2y) {
1398
+ var ax = s1x;
1399
+ var ay = s1y;
1400
+ var bx = e1x - s1x;
1401
+ var by = e1y - s1y;
1402
+ var cx = s2x;
1403
+ var cy = s2y;
1404
+ var dx = e2x - s2x;
1405
+ var dy = e2y - s2y;
1406
+ if (Math.abs(bx * dy - by * dx) < 0.00000001) {
1407
+ if (Math.abs((cx - ax) * by - (cy - ay) * bx) < 0.00000001) {
1408
+ var maxX = ax;
1409
+ var minX = ax;
1410
+ var maxY = ay;
1411
+ var minY = ay;
1412
+ if (maxX < e1x) maxX = e1x;
1413
+ if (maxX < cx) maxX = cx;
1414
+ if (maxX < e2x) maxX = e2x;
1415
+ if (minX > e1x) minX = e1x;
1416
+ if (minX > cx) minX = cx;
1417
+ if (minX > e2x) minX = e2x;
1418
+ if (maxY < e1y) maxY = e1y;
1419
+ if (maxY < cy) maxY = cy;
1420
+ if (maxY < e2y) maxY = e2y;
1421
+ if (minY > e1y) minY = e1y;
1422
+ if (minY > cy) minY = cy;
1423
+ if (minY > e2y) minX = e2y;
1424
+ var len = Math.sqrt((maxX - minX) * (maxX - minX) + (maxY - minY) * (maxY - minY));
1425
+ var len1 = Math.sqrt(bx * bx + by * by);
1426
+ var len2 = Math.sqrt(dx * dx + dy * dy);
1427
+ if (len < len1 + len2) {
1428
+ return true;
1429
+ } else {
1430
+ return false;
1431
+ }
1432
+ } else {
1433
+ return false;
1434
+ }
1435
+ } else {
1436
+ var t = (dx * (ay - cy) + dy * (cx - ax)) / (bx * dy - by * dx);
1437
+ var u = (bx * (cy - ay) + by * (ax - cx)) / (dx * by - dy * bx);
1438
+ var ret = u < 1 && u > 0 && t > 0 && t < 1;
1439
+ return ret;
1440
+ }
1441
+ }
1442
+ function isPointInArea(allArea, pt) {
1443
+ var x = pt.x;
1444
+ var y = pt.y;
1445
+ var result = false;
1446
+ result = allArea.some(function (area) {
1447
+ var sum = 0,
1448
+ alpha = 0;
1449
+ for (var i = 0; i < area.length; i++) {
1450
+ var x0 = area[i].x;
1451
+ var y0 = area[i].y;
1452
+ var x1 = area[(i + 1) % area.length].x;
1453
+ var y1 = area[(i + 1) % area.length].y;
1454
+ var v0 = {
1455
+ x: x0 - x,
1456
+ y: y0 - y
1457
+ };
1458
+ var v1 = {
1459
+ x: x1 - x,
1460
+ y: y1 - y
1461
+ };
1462
+ if (Math.abs(v0.x) < _constants.EPSILON && Math.abs(v0.y) < _constants.EPSILON)
1463
+ // check if pt is area point
1464
+ return true;
1465
+
1466
+ // check if pt is in area line
1467
+ var lineLen = Math.sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
1468
+ var v0Len = Math.sqrt(v0.x * v0.x + v0.y * v0.y);
1469
+ var vPt = {
1470
+ x: -v0.x / v0Len,
1471
+ y: -v0.y / v0Len
1472
+ };
1473
+ var xE = x0 + vPt.x * lineLen;
1474
+ var yE = y0 + vPt.y * lineLen;
1475
+ if (v0Len <= lineLen && Math.abs(xE - x1) < _constants.EPSILON && Math.abs(yE - y1) < _constants.EPSILON) return true;
1476
+ alpha = Math.atan2(v0.x * v1.y - v1.x * v0.y, v0.x * v1.x + v0.y * v1.y);
1477
+ sum += alpha;
1478
+ }
1479
+ if (Math.abs(Math.abs(sum) - Math.PI * 2) < _constants.EPSILON) return true;
1480
+ });
1481
+ return result;
1482
+ }
1483
+ function calcSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allAreaLines) {
1484
+ return calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allAreaLines);
1485
+ }
1486
+ function calcCreateSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, polygonPoint) {
1487
+ // Validate required input and guard against missing `.cur`
1488
+ if (!allItemRect || !allItemRect.cur) return;
1489
+ var cur = allItemRect.cur; // safe alias
1490
+ var cx = x;
1491
+ var cy = y;
1492
+ var ndist = 5000;
1493
+ var rotRad = cur.rotRad;
1494
+
1495
+ // Get candidate snaps and validate them as before
1496
+ var allCurSnap = getAllCurSnap(allLineRects, x, y, cur);
1497
+ allCurSnap = validateLineSnaps(allCurSnap, allItemSnap, allLineSnap, allItemRect, allLineRects, allRect);
1498
+ var getSnap = false;
1499
+ var snapdist = [];
1500
+
1501
+ // Build distances for snaps that lie inside polygonPoint (if any)
1502
+ if (Array.isArray(allCurSnap)) {
1503
+ allCurSnap.forEach(function (snap) {
1504
+ if (!snap || !snap.pos) return;
1505
+ var inside = ContainsPoint(polygonPoint, snap.pos.x, snap.pos.y);
1506
+ if (inside) {
1507
+ var dx = snap.pos.x - x;
1508
+ var dy = snap.pos.y - y;
1509
+ snapdist.push(dx * dx + dy * dy);
1510
+ }
1511
+ });
1512
+ }
1513
+
1514
+ // Find minimum distance (Infinity if none)
1515
+ var edist = snapdist.length ? Math.min.apply(Math, snapdist) : Infinity;
1516
+
1517
+ // Choose the snap with distance === edist
1518
+ if (Array.isArray(allCurSnap)) {
1519
+ allCurSnap.forEach(function (snap) {
1520
+ if (!snap || !snap.pos) return;
1521
+ var dx = snap.pos.x - x;
1522
+ var dy = snap.pos.y - y;
1523
+ var dist = dx * dx + dy * dy;
1524
+ if (dist === edist) {
1525
+ var _snap$rotRad;
1526
+ ndist = dist;
1527
+ cx = snap.pos.x;
1528
+ cy = snap.pos.y;
1529
+ rotRad = (_snap$rotRad = snap.rotRad) !== null && _snap$rotRad !== void 0 ? _snap$rotRad : rotRad; // nullish coalescing
1530
+ getSnap = true;
1531
+ }
1532
+ });
1533
+ }
1534
+ var crot = rotRad / Math.PI * 180;
1535
+ return {
1536
+ cx: cx,
1537
+ cy: cy,
1538
+ crot: crot,
1539
+ rotRad: rotRad
1540
+ };
1541
+ }
1542
+
1543
+ ////////////
1544
+ function calcSnap1(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y) {
1545
+ var cx = allItemRect.cur.pos.x;
1546
+ var cy = allItemRect.cur.pos.y;
1547
+ var nx = x;
1548
+ var ny = y;
1549
+ var cursize = allItemRect.cur.size;
1550
+ var ndist = cursize.width * cursize.width + cursize.height * cursize.height;
1551
+ ndist = ndist / 4;
1552
+ var rotRad = allItemRect.cur.rotRad;
1553
+ var allCurSnap = getAllCurSnap(allLineRects, x, y, allItemRect.cur);
1554
+ allCurSnap = validateSnaps(allCurSnap, allRect);
1555
+ var getSnap = false;
1556
+ allCurSnap.forEach(function (snap) {
1557
+ var dist = (snap.pos.x - x) * (snap.pos.x - x) + (snap.pos.y - y) * (snap.pos.y - y);
1558
+ if (dist < ndist) {
1559
+ ndist = dist;
1560
+ nx = snap.pos.x;
1561
+ ny = snap.pos.y;
1562
+ rotRad = snap.rotRad;
1563
+ getSnap = true;
1564
+ }
1565
+ });
1566
+ if (!getSnap) {
1567
+ allLineSnap.concat(allItemSnap).forEach(function (snap) {
1568
+ var dist = (snap.pos.x - x) * (snap.pos.x - x) + (snap.pos.y - y) * (snap.pos.y - y);
1569
+ if (dist < ndist) {
1570
+ ndist = dist;
1571
+ nx = snap.pos.x;
1572
+ ny = snap.pos.y;
1573
+ rotRad = snap.rotRad;
1574
+ }
1575
+ });
1576
+ }
1577
+ var rot = rotRad / Math.PI * 180;
1578
+ var ret = {
1579
+ nx: nx,
1580
+ ny: ny,
1581
+ rot: rot,
1582
+ rotRad: rotRad
1583
+ };
1584
+ return ret;
1585
+ }
1586
+
1587
+ ////////////
1588
+ function calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allArea) {
1589
+ var nx = x;
1590
+ var ny = y;
1591
+ var ndist = 20;
1592
+ var rotRad = allItemRect.cur && allItemRect.cur.rotRad;
1593
+ var val = {
1594
+ pos: {
1595
+ x: x,
1596
+ y: y
1597
+ },
1598
+ rotRad: rotRad
1599
+ };
1600
+ val.size = allItemRect.cur && allItemRect.cur.size;
1601
+ val.layoutpos = allItemRect.cur && allItemRect.cur.layoutpos;
1602
+ val.is_corner = allItemRect.cur && allItemRect.cur.is_corner;
1603
+ var curitem = getCalcRectFromItem(val);
1604
+ var allCurSnap = [];
1605
+ allCurSnap = getAllCurSnap(allLineRects, x, y, allItemRect.cur);
1606
+ allCurSnap = validateSnaps(allCurSnap, allRect);
1607
+ var getSnap = false;
1608
+ var snapdist = [];
1609
+ //console.log("allItemSnap", allItemSnap.filter(e => e.isSnappedLine))
1610
+ //console.log("~~~~start~~~~");
1611
+ allItemSnap.filter(function (e) {
1612
+ return e.isSnappedLine;
1613
+ }).forEach(function (snap) {
1614
+ var dist = (snap.pos.x - x) * (snap.pos.x - x) + (snap.pos.y - y) * (snap.pos.y - y);
1615
+ snapdist.push(dist);
1616
+ //console.log("dist", snap)
1617
+ if (isPointInArea(allArea, snap.pos) || !allArea.length) if (dist < 100) {
1618
+ ndist = dist;
1619
+ nx = snap.pos.x;
1620
+ ny = snap.pos.y;
1621
+ rotRad = snap.rotRad;
1622
+ getSnap = true;
1623
+
1624
+ //console.log("SUCCESS!!!!");
1625
+ }
1626
+ });
1627
+ //console.log("====end====");
1628
+ if (getSnap == false) {
1629
+ allCurSnap.forEach(function (snap) {
1630
+ var dist = (snap.pos.x - x) * (snap.pos.x - x) + (snap.pos.y - y) * (snap.pos.y - y);
1631
+ snapdist.push(dist);
1632
+ if (isPointInArea(allArea, snap.pos) || !allArea.length) if (dist < ndist) {
1633
+ ndist = dist;
1634
+ nx = snap.pos.x;
1635
+ ny = snap.pos.y;
1636
+ rotRad = snap.rotRad;
1637
+ getSnap = true;
1638
+ //console.log("SUCCE!!!!");
1639
+ }
1640
+ });
1641
+ if (!getSnap && allLineRects.some(function (others) {
1642
+ return intersectRect(others.rect, curitem.rect);
1643
+ })) {
1644
+ var edist = Math.min.apply(null, snapdist);
1645
+ allCurSnap.forEach(function (snap) {
1646
+ var dist = (snap.pos.x - x) * (snap.pos.x - x) + (snap.pos.y - y) * (snap.pos.y - y);
1647
+ if (isPointInArea(allArea, snap.pos) || !allArea.length) if (dist === edist) {
1648
+ ndist = dist;
1649
+ nx = snap.pos.x;
1650
+ ny = snap.pos.y;
1651
+ rotRad = snap.rotRad;
1652
+ getSnap = true;
1653
+ }
1654
+ });
1655
+ }
1656
+ if (getSnap === false) {
1657
+ var nearRect = null;
1658
+ var minDist = Infinity;
1659
+ allLineRects.forEach(function (rect) {
1660
+ var e = rect.rectEnd[0];
1661
+ e = clone_point(e);
1662
+ e.x -= curitem.pos.x;
1663
+ e.y -= curitem.pos.y;
1664
+ var nRot = rect.rotRad + Math.PI / 2;
1665
+ var dist = Math.abs(e.x * Math.cos(nRot) + e.y * Math.sin(nRot));
1666
+ if (minDist > dist) {
1667
+ minDist = dist;
1668
+ nearRect = rect;
1669
+ }
1670
+ });
1671
+ var containrect = nearRect && intersectRect(nearRect.rect, curitem.rect);
1672
+ if (containrect) {
1673
+ var filter_func = function filter_func(snap) {
1674
+ var diff = Math.abs(snap.rotRad - nearRect.rotRad - Math.PI);
1675
+ return diff == 0 || diff == 2 * Math.PI;
1676
+ };
1677
+ var tempSnap = allLineSnap.filter(filter_func);
1678
+ tempSnap = tempSnap.concat(allLineSnap.filter(function (snap) {
1679
+ return !filter_func(snap);
1680
+ }));
1681
+ tempSnap.some(function (snap) {
1682
+ var dist = (snap.pos.x - x) * (snap.pos.x - x) + (snap.pos.y - y) * (snap.pos.y - y);
1683
+ if (isPointInArea(allArea, snap.pos) || !allArea.length) if (dist < 5000) {
1684
+ nx = snap.pos.x;
1685
+ ny = snap.pos.y;
1686
+ rotRad = snap.rotRad;
1687
+ getSnap = true;
1688
+ return true;
1689
+ }
1690
+ return false;
1691
+ });
1692
+ }
1693
+ }
1694
+ if (allItemRect.others.some(function (others) {
1695
+ return intersectRect(others.rect, curitem.rect);
1696
+ })) {
1697
+ getSnap = false;
1698
+ }
1699
+ if (!getSnap) {
1700
+ var _snapdist = [];
1701
+ allItemSnap.forEach(function (snap) {
1702
+ var dist = (snap.pos.x - x) * (snap.pos.x - x) + (snap.pos.y - y) * (snap.pos.y - y);
1703
+ _snapdist.push(dist);
1704
+ if (isPointInArea(allArea, snap.pos) || !allArea.length) if (dist < ndist) {
1705
+ ndist = dist;
1706
+ nx = snap.pos.x;
1707
+ ny = snap.pos.y;
1708
+ rotRad = snap.rotRad;
1709
+ getSnap = true;
1710
+ }
1711
+ });
1712
+ if (!getSnap && allItemRect.others.some(function (others) {
1713
+ return intersectRect(others.rect, curitem.rect);
1714
+ })) {
1715
+ var _edist = Math.min.apply(null, _snapdist);
1716
+ allItemSnap.forEach(function (snap) {
1717
+ var dist = (snap.pos.x - x) * (snap.pos.x - x) + (snap.pos.y - y) * (snap.pos.y - y);
1718
+ if (isPointInArea(allArea, snap.pos) || !allArea.length) if (dist === _edist) {
1719
+ ndist = dist;
1720
+ nx = snap.pos.x;
1721
+ ny = snap.pos.y;
1722
+ rotRad = snap.rotRad;
1723
+ }
1724
+ });
1725
+ if (allItemRect.cur.itemInfo.name.includes('Cook Top')) {
1726
+ var intersects = allItemRect.others.filter(function (others) {
1727
+ return intersectRect(others.rect, curitem.rect);
1728
+ });
1729
+ intersects.forEach(function (rect) {
1730
+ if (isPointInArea(allArea, rect.itemInfo) || !allArea.length) if (rect.itemInfo.layoutpos.includes(_constants.BASE_CABINET_LAYOUTPOS)) {
1731
+ nx = rect.itemInfo.x;
1732
+ ny = rect.itemInfo.y;
1733
+ rotRad = rect.itemInfo.rotation * Math.PI / 180;
1734
+ }
1735
+ });
1736
+ }
1737
+ if (allItemRect.cur.itemInfo.name.includes('Hood') || allItemRect.cur.itemInfo.name.includes('Range') || allItemRect.cur.itemInfo.name.includes('Cook Top')) {
1738
+ var _intersects = allItemRect.others.filter(function (others) {
1739
+ return intersectRect(others.rect, curitem.rect);
1740
+ });
1741
+ _intersects.forEach(function (rect) {
1742
+ if (isPointInArea(allArea, rect.itemInfo) || !allArea.length) if (rect.itemInfo.name.includes('Hood') || rect.itemInfo.name.includes('Range') || rect.itemInfo.name.includes('Cook Top')) {
1743
+ nx = rect.itemInfo.x;
1744
+ ny = rect.itemInfo.y;
1745
+ rotRad = rect.itemInfo.rotation * Math.PI / 180;
1746
+ }
1747
+ });
1748
+ }
1749
+ }
1750
+ }
1751
+ }
1752
+ var rot = rotRad / Math.PI * 180;
1753
+
1754
+ //Check case.
1755
+ //If item is 'blind base cabinet', it must be pulled from other 3".
1756
+ if (allItemRect.cur && allItemRect.cur.itemInfo.sku_number.startsWith('BBC')) {
1757
+ var offset3inch = (0, _convertUnitsLite.convert)(3).from('in').to('cm');
1758
+ var tx = nx,
1759
+ ty = ny;
1760
+ if (allItemRect.cur && allItemRect.cur.itemInfo.sku_number.endsWith('-L')) {
1761
+ if (rot == 0 || rot == -180) {
1762
+ tx -= offset3inch * Math.cos(rotRad);
1763
+ }
1764
+ if (rot == 90 || rot == -90) {
1765
+ ty -= offset3inch * Math.sin(rotRad);
1766
+ }
1767
+ }
1768
+ if (allItemRect.cur && allItemRect.cur.itemInfo.sku_number.endsWith('-R')) {
1769
+ if (rot == 0 || rot == -180) {
1770
+ tx += offset3inch * Math.cos(rotRad);
1771
+ }
1772
+ if (rot == 90 || rot == -90) {
1773
+ ty += offset3inch * Math.sin(rotRad);
1774
+ }
1775
+ }
1776
+ var t_val = {
1777
+ pos: {
1778
+ x: tx,
1779
+ y: ty
1780
+ },
1781
+ rotRad: rotRad,
1782
+ size: allItemRect.cur.size,
1783
+ layoutpos: allItemRect.cur.layoutpos,
1784
+ is_corner: allItemRect.cur.is_corner
1785
+ };
1786
+ var isItemRectSect = validInterSect(allItemRect.others, t_val);
1787
+ var isWallRectSect = validInterSect(allLineRects, t_val);
1788
+ if (isItemRectSect && isWallRectSect) {
1789
+ nx = tx;
1790
+ ny = ty;
1791
+ }
1792
+ }
1793
+ return {
1794
+ nx: nx,
1795
+ ny: ny,
1796
+ rot: rot,
1797
+ rotRad: rotRad
1798
+ };
1799
+ }
1800
+
1801
+ ////////////
1802
+ function calcSnap3(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y) {
1803
+ // let layer = scene.layers.get(layerID);
1804
+ // let cx = allItemRect.cur.pos.x;
1805
+ // let cy = allItemRect.cur.pos.y;
1806
+ var nx = x;
1807
+ var ny = y;
1808
+ var ndist = 20;
1809
+ var rotRad = allItemRect.cur.rotRad;
1810
+ var val = {
1811
+ pos: {
1812
+ x: x,
1813
+ y: y
1814
+ },
1815
+ rotRad: rotRad
1816
+ };
1817
+ val.size = allItemRect.cur.size;
1818
+ val.layoutpos = allItemRect.cur.layoutpos;
1819
+ val.is_corner = allItemRect.cur.is_corner;
1820
+ var curitem = getCalcRectFromItem3D(val);
1821
+ var allCurSnap = getAllCurSnap(allLineRects, x, y, allItemRect.cur);
1822
+ allCurSnap = validateSnaps(allCurSnap, allRect);
1823
+ var getSnap = false;
1824
+ var snapdist = [];
1825
+ allCurSnap.forEach(function (snap) {
1826
+ var dist = (snap.pos.x - x) * (snap.pos.x - x) + (snap.pos.y - y) * (snap.pos.y - y);
1827
+ snapdist.push(dist);
1828
+ if (dist < ndist) {
1829
+ ndist = dist;
1830
+ nx = snap.pos.x;
1831
+ ny = snap.pos.y;
1832
+ rotRad = snap.rotRad;
1833
+ getSnap = true;
1834
+ } else {
1835
+ var i = 0;
1836
+ allLineRects.forEach(function (others) {
1837
+ var containrect = intersectRect(others.rect, curitem.rect);
1838
+ if (containrect) {
1839
+ var edist = Math.min.apply(null, snapdist);
1840
+ allCurSnap.forEach(function (snap) {
1841
+ var dist = (snap.pos.x - x) * (snap.pos.x - x) + (snap.pos.y - y) * (snap.pos.y - y);
1842
+ if (dist === edist) {
1843
+ ndist = dist;
1844
+ nx = snap.pos.x;
1845
+ ny = snap.pos.y;
1846
+ rotRad = snap.rotRad;
1847
+ getSnap = true;
1848
+ }
1849
+ });
1850
+ }
1851
+ });
1852
+ }
1853
+ });
1854
+ if (getSnap === false) {
1855
+ allLineRects.forEach(function (others) {
1856
+ var containrect = intersectRect(others.rect, curitem.rect);
1857
+ if (containrect) {
1858
+ allLineSnap.forEach(function (snap) {
1859
+ var dist = (snap.pos.x - x) * (snap.pos.x - x) + (snap.pos.y - y) * (snap.pos.y - y);
1860
+ if (dist < 5000) {
1861
+ nx = snap.pos.x;
1862
+ ny = snap.pos.y;
1863
+ rotRad = snap.rotRad;
1864
+ getSnap = true;
1865
+ }
1866
+ });
1867
+ }
1868
+ });
1869
+ }
1870
+ allItemRect.others.forEach(function (others) {
1871
+ if (!(others.layoutpos === 'base' && allItemRect.cur.layoutpos === 'wall') || !(others.layoutpos === 'wall' && allItemRect.cur.layoutpos === 'base')) {
1872
+ var containrect = intersectRect(others.rect, curitem.rect);
1873
+ if (containrect) {
1874
+ getSnap = false;
1875
+ }
1876
+ }
1877
+ });
1878
+ if (!getSnap) {
1879
+ var _snapdist2 = [];
1880
+ allItemSnap.forEach(function (snap) {
1881
+ var dist = (snap.pos.x - x) * (snap.pos.x - x) + (snap.pos.y - y) * (snap.pos.y - y);
1882
+ _snapdist2.push(dist);
1883
+ if (dist < ndist) {
1884
+ ndist = dist;
1885
+ nx = snap.pos.x;
1886
+ ny = snap.pos.y;
1887
+ rotRad = snap.rotRad;
1888
+ } else {
1889
+ allItemRect.others.forEach(function (others) {
1890
+ if (!(others.layoutpos === 'base' && allItemRect.cur.layoutpos === 'wall') || !(others.layoutpos === 'wall' && allItemRect.cur.layoutpos === 'base')) {
1891
+ var containrect = intersectRect(others.rect, curitem.rect);
1892
+ if (containrect) {
1893
+ var edist = Math.min.apply(null, _snapdist2);
1894
+ allItemSnap.forEach(function (snap) {
1895
+ var dist = (snap.pos.x - x) * (snap.pos.x - x) + (snap.pos.y - y) * (snap.pos.y - y);
1896
+ if (dist === edist) {
1897
+ ndist = dist;
1898
+ nx = snap.pos.x;
1899
+ ny = snap.pos.y;
1900
+ rotRad = snap.rotRad;
1901
+ }
1902
+ });
1903
+ }
1904
+ }
1905
+ });
1906
+ }
1907
+ });
1908
+ }
1909
+ var rot = rotRad / Math.PI * 180;
1910
+ return {
1911
+ nx: nx,
1912
+ ny: ny,
1913
+ rot: rot,
1914
+ rotRad: rotRad
1915
+ };
1916
+ }
1917
+ function getAllCurSnap(allLineRects, x, y, curItemRect) {
1918
+ if (!curItemRect) return;
1919
+ var allCurSnap = [];
1920
+ var thick = _constants.LINE_THICKNESS / 2;
1921
+ allLineRects.forEach(function (linerect) {
1922
+ //allLineRects:left, right, top, bottom line
1923
+ var p0 = clone_point(linerect.rect[2]); //point 2(x, y) inside of line
1924
+ var p1 = clone_point(linerect.rect[3]); //point 3(x, y) inside of line
1925
+ var q = point(x, y); // point of item
1926
+ var cos = Math.cos(linerect.rotRad);
1927
+ var sin = Math.sin(linerect.rotRad);
1928
+ p0.x -= cos * curItemRect.size.width / 2;
1929
+ p0.y -= sin * curItemRect.size.width / 2;
1930
+ p1.x += cos * curItemRect.size.width / 2;
1931
+ p1.y += sin * curItemRect.size.width / 2;
1932
+ var n = point(-sin, cos);
1933
+ var v3to0 = {
1934
+ x: linerect.rect[0].x - p1.x,
1935
+ y: linerect.rect[0].y - p1.y
1936
+ };
1937
+ var fDot = dotprod(n, v3to0);
1938
+ if (fDot > 0) {
1939
+ // normal vector is crossing the wall
1940
+ n.x = -n.x;
1941
+ n.y = -n.y;
1942
+ }
1943
+ var dist = dotprod(diff(p1, q), n);
1944
+ var h = point(q.x + dist * n.x, q.y + dist * n.y);
1945
+ var nrot = linerect.rotRad + Math.PI;
1946
+ if (nrot >= Math.PI) nrot -= Math.PI * 2;
1947
+ var o = itemrectInfo(h.x + n.x * (curItemRect && curItemRect.size.height / 2), h.y + n.y * (curItemRect && curItemRect.size.height / 2), nrot, curItemRect && curItemRect.size, curItemRect && curItemRect.layoutpos, curItemRect && curItemRect.is_corner);
1948
+ allCurSnap.push(o);
1949
+ nrot = nrot + Math.PI;
1950
+ o = itemrectInfo(h.x - n.x * (curItemRect && curItemRect.size.height / 2 + thick), h.y - n.y * (curItemRect && curItemRect.size.height / 2 + thick), nrot, curItemRect && curItemRect.size, curItemRect && curItemRect.layoutpos, curItemRect && curItemRect.is_corner);
1951
+ allCurSnap.push(o);
1952
+ });
1953
+ return allCurSnap;
1954
+ }
1955
+ function clone_point(pt) {
1956
+ return point(pt.x, pt.y);
1957
+ }
1958
+ function dotprod(v0, v1) {
1959
+ return v0.x * v1.x + v0.y * v1.y;
1960
+ }
1961
+
1962
+ //////////
1963
+ function validInterSect(rect, val) {
1964
+ var curitem = getCalcRectFromItem(val);
1965
+ var datas = [];
1966
+ rect.forEach(function (line) {
1967
+ datas.push(line);
1968
+ });
1969
+ for (var i = 0; i < datas.length; i++) {
1970
+ var data = datas[i];
1971
+ var containrect = intersectRect(data.rect, curitem.rect);
1972
+ if (containrect) {
1973
+ return false;
1974
+ }
1975
+ }
1976
+ return true;
1977
+ }
1978
+ var lineRect = function lineRect(layer) {
1979
+ var areainfo = [];
1980
+ layer.areas.forEach(function (area) {
1981
+ var sz = area.vertices.size;
1982
+ for (var i = 0; i < sz; i++) {
1983
+ areainfo.push(area.vertices.get(i));
1984
+ }
1985
+ });
1986
+ var rect = [];
1987
+ areainfo.forEach(function (area) {
1988
+ var vert = layer.vertices.get(area);
1989
+ rect.push(vert.x, vert.y);
1990
+ });
1991
+ return rect;
1992
+ };
1993
+ function getAllHoleRect(scene, val) {
1994
+ var layerID = scene.selectedLayer;
1995
+ var layer = scene.layers.get(layerID);
1996
+ var selectedItem = layer.getIn(['items', layer.selected.items.get(0)]);
1997
+ if (selectedItem !== undefined) {
1998
+ if (selectedItem.category != 'cabinet') {
1999
+ // If selected Item type is not `cabinet` then do not snap at windows
2000
+ return {
2001
+ isSect: true,
2002
+ snap: null
2003
+ };
2004
+ }
2005
+ } else {
2006
+ return {
2007
+ isSect: false,
2008
+ snap: null
2009
+ };
2010
+ }
2011
+ var holes = [];
2012
+ var itemRect = getCalcRectFromItem(val);
2013
+ layer.lines.forEach(function (line) {
2014
+ line.holes.forEach(function (holeID) {
2015
+ var hole = layer.holes.get(holeID);
2016
+ if (hole) holes.push(hole);
2017
+ });
2018
+ });
2019
+ var i = 0;
2020
+ for (; i < holes.length; i++) {
2021
+ var twidth = holes[i].properties.getIn(['width', 'length']);
2022
+ var theight = holes[i].properties.getIn(['thickness', 'length']) + 1;
2023
+ var tdepth = holes[i].properties.getIn(['altitude', 'length']);
2024
+ //let trot = holes[i].rotation;
2025
+ var verticeIDs = scene.getIn(['layers', layerID, 'lines', holes[i].line, 'vertices'])._tail.array;
2026
+ var vertice0 = scene.getIn(['layers', layerID, 'vertices', verticeIDs[0]]);
2027
+ var vertice1 = scene.getIn(['layers', layerID, 'vertices', verticeIDs[1]]);
2028
+ var point0 = {
2029
+ x: vertice0.x,
2030
+ y: vertice0.y
2031
+ };
2032
+ var point1 = {
2033
+ x: vertice1.x,
2034
+ y: vertice1.y
2035
+ };
2036
+ var rotation = Math.atan2(point1.y - point0.y, point1.x - point0.x);
2037
+ var rectInfo = getCalcRectFromLine(point1.x, point1.y, point0.x, point0.y, _constants.LINE_THICKNESS, layer);
2038
+ var vN = point(rectInfo.rect[0].x - rectInfo.rect[3].x, rectInfo.rect[0].y - rectInfo.rect[3].y);
2039
+ var lenN = Math.sqrt(vN.x * vN.x + vN.y * vN.y);
2040
+ vN.x /= lenN;
2041
+ vN.y /= lenN;
2042
+ var hx = holes[i].x;
2043
+ var hy = holes[i].y;
2044
+ hx += theight / 2 * vN.x;
2045
+ hy += theight / 2 * vN.y;
2046
+ var tval = {
2047
+ pos: {
2048
+ x: hx,
2049
+ y: hy
2050
+ },
2051
+ rotRad: rotation
2052
+ };
2053
+ tval.size = {
2054
+ width: twidth,
2055
+ height: theight
2056
+ };
2057
+ var hole_rect = getCalcRectFromItem(tval);
2058
+ if (intersectRect(itemRect.rect, hole_rect.rect)) {
2059
+ if (tdepth > itemRect.size.depth && itemRect.layoutpos !== _constants.WALL_CABINET_LAYOUTPOS) {
2060
+ var dist = itemRect.size.height / 2 + theight / 2;
2061
+ var snap = [];
2062
+ var p0 = {
2063
+ x: hx + dist * Math.cos(rotation + Math.PI / 2),
2064
+ y: hy + dist * Math.sin(rotation + Math.PI / 2)
2065
+ };
2066
+ var p1 = {
2067
+ x: hx - dist * Math.cos(rotation + Math.PI / 2),
2068
+ y: hy - dist * Math.sin(rotation + Math.PI / 2)
2069
+ };
2070
+ var allArea = getAllArea(layer);
2071
+ if (isPointInArea(allArea, p0)) {
2072
+ snap.push(p0);
2073
+ }
2074
+ if (isPointInArea(allArea, p1)) {
2075
+ snap.push(p1);
2076
+ }
2077
+ return {
2078
+ isSect: true,
2079
+ snap: snap
2080
+ };
2081
+ } else return {
2082
+ isSect: false,
2083
+ snap: null
2084
+ };
2085
+ }
2086
+ }
2087
+ return {
2088
+ isSect: true,
2089
+ snap: null
2090
+ };
2091
+ }
2092
+ function getHoleItems(layer) {
2093
+ var holeItems = [];
2094
+ layer.holes.map(function (hole) {
2095
+ var width = hole.properties.getIn(['width', 'length']);
2096
+ var altitude = hole.properties.getIn(['altitude', 'length']);
2097
+ holeItems.push({
2098
+ x: hole.x,
2099
+ y: hole.y,
2100
+ width: width,
2101
+ altitude: altitude
2102
+ });
2103
+ });
2104
+ return holeItems;
2105
+ }
2106
+ function needSnap(curItem, othItem) {
2107
+ var blSnap = false;
2108
+ if (curItem == undefined || curItem == null) return false;
2109
+ var altitude = curItem.selectedItem.properties.get('altitude');
2110
+ var heightFromFloor = (0, _convertUnitsLite.convert)(altitude.get('_length')).from(altitude.get('_unit')).to('in');
2111
+ var height = curItem.cat.info.sizeinfo.height;
2112
+ var currentItem = {
2113
+ heightFromFloor: heightFromFloor,
2114
+ height: height
2115
+ };
2116
+ altitude = othItem.item.properties.get('altitude');
2117
+ heightFromFloor = (0, _convertUnitsLite.convert)(altitude.get('_length')).from(altitude.get('_unit')).to('in');
2118
+ height = othItem.cat && othItem.cat.info.sizeinfo.height;
2119
+ var otherItem = {
2120
+ heightFromFloor: heightFromFloor,
2121
+ height: height
2122
+ };
2123
+ var curFloor = currentItem.heightFromFloor;
2124
+ var otherFloor = otherItem.heightFromFloor;
2125
+ var delta;
2126
+ curFloor > otherFloor ? delta = otherItem.height : delta = currentItem.height;
2127
+ if (Math.abs(curFloor - otherFloor) < delta) blSnap = true;
2128
+ if (curItem.cat.hasOwnProperty('long_name') || othItem.cat && othItem.cat.hasOwnProperty('long_name')) {
2129
+ if (curItem.cat.long_name.includes('Hood') || othItem.cat && othItem.cat.long_name.includes('Hood')) blSnap = true;
2130
+ if (curItem.cat.long_name.includes('Hood') && othItem.cat && othItem.cat.long_name.includes('Base Cabinet') || curItem.cat.long_name.includes('Base Cabinet') && othItem.cat && othItem.cat.long_name.includes('Hood')) blSnap = false;
2131
+ if (curItem.cat.long_name.includes('Cook Top') && othItem.cat && othItem.cat.long_name.includes('Cabinet') || curItem.cat.long_name.includes('Cabinet') && othItem.cat && othItem.cat.long_name.includes('Cook Top')) blSnap = true;
2132
+ }
2133
+ return blSnap;
2134
+ }
2135
+ function isFrontWall(v0, v1) {
2136
+ var x1 = v0.x,
2137
+ y1 = v0.y;
2138
+ var x2 = v1.x,
2139
+ y2 = v1.y;
2140
+ var alpha = angleBetweenTwoPoints(x1, y1, x2, y2);
2141
+ return almostEqual(y1, y2) && x1 < x2 || -Math.PI / 2 < alpha && alpha < Math.PI / 2;
2142
+ }
2143
+ function isBackWall(v0, v1) {
2144
+ var x1 = v0.x,
2145
+ y1 = v0.y;
2146
+ var x2 = v1.x,
2147
+ y2 = v1.y;
2148
+ var alpha = angleBetweenTwoPoints(x1, y1, x2, y2);
2149
+ return almostEqual(y1, y2) && x1 > x2 || -Math.PI / 2 > alpha || alpha > Math.PI / 2;
2150
+ }
2151
+ function isLeftWall(v0, v1) {
2152
+ var x1 = v0.x,
2153
+ y1 = v0.y;
2154
+ var x2 = v1.x,
2155
+ y2 = v1.y;
2156
+ var alpha = angleBetweenTwoPoints(x1, y1, x2, y2);
2157
+ return almostEqual(x1, x2) && y1 < y2 || Math.PI > alpha && alpha > 0;
2158
+ }
2159
+ function isRightWall(v0, v1) {
2160
+ var x1 = v0.x,
2161
+ y1 = v0.y;
2162
+ var x2 = v1.x,
2163
+ y2 = v1.y;
2164
+ var alpha = angleBetweenTwoPoints(x1, y1, x2, y2);
2165
+ return almostEqual(x1, x2) && y1 > y2 || -Math.PI < alpha && alpha < 0;
2166
+ }
2167
+
2168
+ /**
2169
+ * Calculate the overlapping relationship of two lines
2170
+ * @param {*} srcLine // source line
2171
+ * @param {*} destLine // destination line
2172
+ * @returns overlapping status (OVERLAP_NONE | OVERLAP_SAME | OVERLAP_LINK | OVERLAP_INCLUDED | OVERLAP_SOME) and line segments of srcLine which broken with destLine
2173
+ * OVERLAP_NONE: two lines are not overlapped
2174
+ * OVERLAP_SAME: the start point and endpoint of two lines are same
2175
+ * OVERLAP_LINK: two lines are linked at the common point, so they can be merged to one line
2176
+ * OVERLAP_INCLUDED: destLine includes srcLine
2177
+ * OVERLAP_SOME: two lines are overlapped with some common range, then returns the trimmed segments of srcLine
2178
+ *
2179
+ * //////// test - start /////////////
2180
+ const p1 = { x1: 1413.1313131313132, y1: 1044.949494949495 };
2181
+ const p2 = { x1: 1476.2626262626263, y1: 1108.0808080808079 };
2182
+ const p3 = { x1: 1596.969696969697, y1: 1228.7878787878785 };
2183
+ const p4 = { x1: 1664.1414141414139, y1: 1295.9595959595958 };
2184
+ const tempRet = GeometryUtils.relationshipOfTwoOverlappedLines(
2185
+ { x1: p3.x1, y1: p3.y1, x2: p1.x1, y2: p1.y1 },
2186
+ { x1: p1.x1, y1: p1.y1, x2: p3.x1, y2: p3.y1 }
2187
+ );
2188
+ console.log(tempRet);
2189
+ //////// test - end /////////////
2190
+
2191
+ */
2192
+ function relationshipOfTwoOverlappedLines(srcLine, destLine) {
2193
+ // let res1 = relationshipOfTwoOverlappedLines1(srcLine, destLine);
2194
+ var res2 = relationshipOfTwoOverlappedLines2(srcLine, destLine);
2195
+ // if (res1.result !== 0 || res2.result !== 0) {
2196
+ // console.group(res1.result);
2197
+ // console.log(res1);
2198
+ // console.log(res2);
2199
+ // console.log(srcLine, destLine);
2200
+ // console.groupEnd();
2201
+ // }
2202
+ return res2;
2203
+ }
2204
+ function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
2205
+ var p1 = {
2206
+ x: Math.round(srcLine.x1 * 100) / 100,
2207
+ y: Math.round(srcLine.y1 * 100) / 100
2208
+ };
2209
+ var p2 = {
2210
+ x: Math.round(srcLine.x2 * 100) / 100,
2211
+ y: Math.round(srcLine.y2 * 100) / 100
2212
+ };
2213
+ var p3 = {
2214
+ x: Math.round(destLine.x1 * 100) / 100,
2215
+ y: Math.round(destLine.y1 * 100) / 100
2216
+ };
2217
+ var p4 = {
2218
+ x: Math.round(destLine.x2 * 100) / 100,
2219
+ y: Math.round(destLine.y2 * 100) / 100
2220
+ };
2221
+ var x1 = p1.x,
2222
+ y1 = p1.y;
2223
+ var x2 = p2.x,
2224
+ y2 = p2.y;
2225
+ var x3 = p3.x,
2226
+ y3 = p3.y;
2227
+ var x4 = p4.x,
2228
+ y4 = p4.y;
2229
+ var denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
2230
+ var numA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);
2231
+ var numB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3);
2232
+ if ((0, _math.fAbs)(denom) <= _constants.EPSILON) {
2233
+ if ((0, _math.fAbs)(numA) <= _constants.EPSILON && (0, _math.fAbs)(numB) <= _constants.EPSILON) {
2234
+ var comparator = function comparator(pa, pb) {
2235
+ return (0, _math.fAbs)(pa.x - pb.x) <= _constants.EPSILON ? pa.y - pb.y : pa.x - pb.x;
2236
+ };
2237
+ var line0 = [p1, p2].sort(comparator);
2238
+ var line1 = [p3, p4].sort(comparator);
2239
+ var _sort3 = [line0, line1].sort(function (lineA, lineB) {
2240
+ return comparator(lineA[0], lineB[0]);
2241
+ }),
2242
+ _sort4 = (0, _slicedToArray2["default"])(_sort3, 2),
2243
+ lineSX = _sort4[0],
2244
+ lineDX = _sort4[1];
2245
+ var isReversedSrcLineIdx = false;
2246
+ if (lineSX[0].x === line0[0].x && lineSX[0].y === line0[0].y) isReversedSrcLineIdx = false; // SX=srcLine, DX=destLine
2247
+ else if (lineSX[0].x === line1[0].x && lineSX[0].y === line1[0].y) isReversedSrcLineIdx = true; // DX=srcLine, SX=destLine
2248
+
2249
+ var compare0 = comparator(lineSX[0], lineDX[0]); // always <= 0
2250
+ var compare1 = comparator(lineSX[1], lineDX[0]);
2251
+ var compare2 = comparator(lineSX[1], lineDX[1]);
2252
+ var sp = null,
2253
+ ep = null;
2254
+ if (_export.MathUtils.fAbs(compare1) < _constants.EPSILON) {
2255
+ // SX
2256
+ // |----------|
2257
+ // DX
2258
+ // |------------|
2259
+ // link : lineSX[0] - lineDX[1]
2260
+ if (lineSX[0].x === p1.x && lineSX[0].y === p1.y || lineDX[1].x === p2.x && lineDX[1].y === p2.y) {
2261
+ sp = {
2262
+ x: lineSX[0].x,
2263
+ y: lineSX[0].y
2264
+ };
2265
+ ep = {
2266
+ x: lineDX[1].x,
2267
+ y: lineDX[1].y
2268
+ };
2269
+ } else {
2270
+ // srcLine Direction is reversed
2271
+ sp = {
2272
+ x: lineDX[1].x,
2273
+ y: lineDX[1].y
2274
+ };
2275
+ ep = {
2276
+ x: lineSX[0].x,
2277
+ y: lineSX[0].y
2278
+ };
2279
+ }
2280
+ return {
2281
+ result: _constants.OVERLAP_LINK,
2282
+ linkedLine: {
2283
+ x1: sp.x,
2284
+ y1: sp.y,
2285
+ x2: ep.x,
2286
+ y2: ep.y
2287
+ }
2288
+ };
2289
+ } else if (compare1 < 0) {
2290
+ // SX
2291
+ // |----------|
2292
+ // DX
2293
+ // |----------|
2294
+ // none
2295
+ return {
2296
+ result: _constants.OVERLAP_NONE
2297
+ };
2298
+ } else if (_export.MathUtils.fAbs(compare0) < _constants.EPSILON && _export.MathUtils.fAbs(compare2) < _constants.EPSILON) {
2299
+ // SX
2300
+ // |----------|
2301
+ // DX
2302
+ // |----------|
2303
+ return {
2304
+ result: _constants.OVERLAP_SAME
2305
+ };
2306
+ } else if (_export.MathUtils.fAbs(compare0) < _constants.EPSILON) {
2307
+ if (compare2 < 0 && isReversedSrcLineIdx) {
2308
+ // SX
2309
+ // |---------------|
2310
+ // DX
2311
+ // |-----------------------|
2312
+ // DX includes SX, DX=srcLine, SX=destLine : sx1 - dx1
2313
+ if (lineDX[1].x === p2.x && lineDX[1].y === p2.y) {
2314
+ sp = {
2315
+ x: lineSX[1].x,
2316
+ y: lineSX[1].y
2317
+ };
2318
+ ep = {
2319
+ x: lineDX[1].x,
2320
+ y: lineDX[1].y
2321
+ };
2322
+ } else {
2323
+ // srcLine Direction is reversed
2324
+ sp = {
2325
+ x: lineDX[1].x,
2326
+ y: lineDX[1].y
2327
+ };
2328
+ ep = {
2329
+ x: lineSX[1].x,
2330
+ y: lineSX[1].y
2331
+ };
2332
+ }
2333
+ return {
2334
+ result: _constants.OVERLAP_SOME,
2335
+ trimmedSegs: [{
2336
+ x1: sp.x,
2337
+ y1: sp.y,
2338
+ x2: ep.x,
2339
+ y2: ep.y
2340
+ }]
2341
+ };
2342
+ } else if (compare2 > 0 && !isReversedSrcLineIdx) {
2343
+ // SX
2344
+ // |-----------------------|
2345
+ // DX
2346
+ // |---------------|
2347
+ // SX includes DX, SX=srcLine, DX=destLine : dx1 - sx1
2348
+ if (lineSX[1].x === p2.x && lineSX[1].y === p2.y) {
2349
+ sp = {
2350
+ x: lineDX[1].x,
2351
+ y: lineDX[1].y
2352
+ };
2353
+ ep = {
2354
+ x: lineSX[1].x,
2355
+ y: lineSX[1].y
2356
+ };
2357
+ } else {
2358
+ // srcLine Direction is reversed
2359
+ sp = {
2360
+ x: lineSX[1].x,
2361
+ y: lineSX[1].y
2362
+ };
2363
+ ep = {
2364
+ x: lineDX[1].x,
2365
+ y: lineDX[1].y
2366
+ };
2367
+ }
2368
+ return {
2369
+ result: _constants.OVERLAP_SOME,
2370
+ trimmedSegs: [{
2371
+ x1: sp.x,
2372
+ y1: sp.y,
2373
+ x2: ep.x,
2374
+ y2: ep.y
2375
+ }]
2376
+ };
2377
+ } else {
2378
+ // srcLine
2379
+ // |---------------|
2380
+ // destLine
2381
+ // |-----------------------|
2382
+ // destLine includes srcLine
2383
+ return {
2384
+ result: _constants.OVERLAP_INCLUDED
2385
+ };
2386
+ }
2387
+ } else if (_export.MathUtils.fAbs(compare2) < _constants.EPSILON) {
2388
+ // SX
2389
+ // |-----------------------|
2390
+ // DX
2391
+ // |------------------|
2392
+ if (isReversedSrcLineIdx) {
2393
+ // SX includes DX, DX=srcLine, SX=destLine
2394
+ // destLine includes srcLine
2395
+ return {
2396
+ result: _constants.OVERLAP_INCLUDED
2397
+ };
2398
+ } else {
2399
+ // SX includes DX, SX=srcLine, DX=destLine
2400
+ // srcLine incluedes destLine : sx0 - dx0
2401
+ if (lineSX[1].x === p2.x && lineSX[1].y === p2.y) {
2402
+ sp = {
2403
+ x: lineSX[0].x,
2404
+ y: lineSX[0].y
2405
+ };
2406
+ ep = {
2407
+ x: lineDX[0].x,
2408
+ y: lineDX[0].y
2409
+ };
2410
+ } else {
2411
+ // srcLine direction is reversed
2412
+ sp = {
2413
+ x: lineDX[0].x,
2414
+ y: lineDX[0].y
2415
+ };
2416
+ ep = {
2417
+ x: lineSX[0].x,
2418
+ y: lineSX[0].y
2419
+ };
2420
+ }
2421
+ return {
2422
+ result: _constants.OVERLAP_SOME,
2423
+ trimmedSegs: [{
2424
+ x1: sp.x,
2425
+ y1: sp.y,
2426
+ x2: ep.x,
2427
+ y2: ep.y
2428
+ }]
2429
+ };
2430
+ }
2431
+ } else if (compare0 < 0 && compare2 > 0) {
2432
+ // SX
2433
+ // |-----------------------|
2434
+ // DX
2435
+ // |----------------|
2436
+ if (isReversedSrcLineIdx) {
2437
+ // SX includes DX, DX=srcLine, SX=destLine
2438
+ // destLine includes srcLine
2439
+ return {
2440
+ result: _constants.OVERLAP_INCLUDED
2441
+ };
2442
+ } else {
2443
+ // SX includes DX, SX=srcLine, DX=destLine
2444
+ // srcLine incluedes destLine : sx0 - dx0, dx1 - sx1
2445
+ if (lineSX[1].x === p2.x && lineSX[1].y === p2.y) {
2446
+ return {
2447
+ result: _constants.OVERLAP_SOME,
2448
+ trimmedSegs: [{
2449
+ x1: lineSX[0].x,
2450
+ y1: lineSX[0].y,
2451
+ x2: lineDX[0].x,
2452
+ y2: lineDX[0].y
2453
+ }, {
2454
+ x1: lineDX[1].x,
2455
+ y1: lineDX[1].y,
2456
+ x2: lineSX[1].x,
2457
+ y2: lineSX[1].y
2458
+ }]
2459
+ };
2460
+ } else {
2461
+ // srcLine direction is reversed
2462
+ return {
2463
+ result: _constants.OVERLAP_SOME,
2464
+ trimmedSegs: [{
2465
+ x1: lineDX[0].x,
2466
+ y1: lineDX[0].y,
2467
+ x2: lineSX[0].x,
2468
+ y2: lineSX[0].y
2469
+ }, {
2470
+ x1: lineSX[1].x,
2471
+ y1: lineSX[1].y,
2472
+ x2: lineDX[1].x,
2473
+ y2: lineDX[1].y
2474
+ }]
2475
+ };
2476
+ }
2477
+ }
2478
+ } else if (compare2 < 0) {
2479
+ // SX
2480
+ // |-----------------------|
2481
+ // DX
2482
+ // |----------------------------|
2483
+ // overlap some
2484
+ if (isReversedSrcLineIdx) {
2485
+ // DX=srcLine, SX=destLine
2486
+ if (lineDX[1].x === p2.x && lineDX[1].y === p2.y) {
2487
+ sp = {
2488
+ x: lineSX[1].x,
2489
+ y: lineSX[1].y
2490
+ };
2491
+ ep = {
2492
+ x: lineDX[1].x,
2493
+ y: lineDX[1].y
2494
+ };
2495
+ } else {
2496
+ // srcLine direction is reversed
2497
+ sp = {
2498
+ x: lineDX[1].x,
2499
+ y: lineDX[1].y
2500
+ };
2501
+ ep = {
2502
+ x: lineSX[1].x,
2503
+ y: lineSX[1].y
2504
+ };
2505
+ }
2506
+ return {
2507
+ result: _constants.OVERLAP_SOME,
2508
+ trimmedSegs: [{
2509
+ x1: sp.x,
2510
+ y1: sp.y,
2511
+ x2: ep.x,
2512
+ y2: ep.y
2513
+ }]
2514
+ };
2515
+ } else {
2516
+ // SX=srcLine, DX=destLine
2517
+ if (lineSX[1].x === p2.x && lineSX[1].y === p2.y) {
2518
+ sp = {
2519
+ x: lineSX[0].x,
2520
+ y: lineSX[0].y
2521
+ };
2522
+ ep = {
2523
+ x: lineDX[0].x,
2524
+ y: lineDX[0].y
2525
+ };
2526
+ } else {
2527
+ // srcLine direction is reversed
2528
+ sp = {
2529
+ x: lineDX[0].x,
2530
+ y: lineDX[0].y
2531
+ };
2532
+ ep = {
2533
+ x: lineSX[0].x,
2534
+ y: lineSX[0].y
2535
+ };
2536
+ }
2537
+ return {
2538
+ result: _constants.OVERLAP_SOME,
2539
+ trimmedSegs: [{
2540
+ x1: sp.x,
2541
+ y1: sp.y,
2542
+ x2: ep.x,
2543
+ y2: ep.y
2544
+ }]
2545
+ };
2546
+ }
2547
+ }
2548
+ }
2549
+ }
2550
+ return {
2551
+ result: _constants.OVERLAP_NONE
2552
+ };
2553
+ }
2554
+ function relationshipOfTwoOverlappedLines1(srcLine, destLine) {
2555
+ var INFINITY = 1000000;
2556
+ var ZERO_DELTA = 0.01;
2557
+ // geometric equation of srcLine
2558
+ var dx1 = srcLine.x2 - srcLine.x1;
2559
+ dx1 = _export.MathUtils.fAbs(dx1) < ZERO_DELTA ? 0 : dx1;
2560
+ var dy1 = srcLine.y2 - srcLine.y1;
2561
+ dy1 = _export.MathUtils.fAbs(dy1) < ZERO_DELTA ? 0 : dy1;
2562
+ var a1 = dx1 === 0 ? INFINITY : dy1 / dx1;
2563
+ var b1 = a1 === INFINITY ? srcLine.x1 : srcLine.y1 - a1 * srcLine.x1;
2564
+ // geometric equation of destLine
2565
+ var dx2 = destLine.x2 - destLine.x1;
2566
+ dx2 = _export.MathUtils.fAbs(dx2) < ZERO_DELTA ? 0 : dx2;
2567
+ var dy2 = destLine.y2 - destLine.y1;
2568
+ dy2 = _export.MathUtils.fAbs(dy2) < ZERO_DELTA ? 0 : dy2;
2569
+ var a2 = dx2 === 0 ? INFINITY : dy2 / dx2;
2570
+ var b2 = a2 === INFINITY ? destLine.x1 : destLine.y1 - a2 * destLine.x1;
2571
+ if (_export.MathUtils.fAbs(_export.MathUtils.fAbs(a1) - _export.MathUtils.fAbs(a2)) > ZERO_DELTA)
2572
+ // two lines are not parallel
2573
+ return {
2574
+ result: _constants.OVERLAP_NONE
2575
+ };
2576
+ if (_export.MathUtils.fAbs(_export.MathUtils.fAbs(b1) - _export.MathUtils.fAbs(b2)) > ZERO_DELTA)
2577
+ // two lines are parallel but not overlap
2578
+ return {
2579
+ result: _constants.OVERLAP_NONE
2580
+ };
2581
+
2582
+ // parametric equation of destLine
2583
+ var sk1 = dx1 === 0 ? INFINITY : _export.MathUtils.toFixedFloat((destLine.x1 - srcLine.x1) / dx1, 3);
2584
+ var sk2 = dy1 === 0 ? INFINITY : _export.MathUtils.toFixedFloat((destLine.y1 - srcLine.y1) / dy1, 3);
2585
+ var ek1 = dx1 === 0 ? INFINITY : _export.MathUtils.toFixedFloat((destLine.x2 - srcLine.x1) / dx1, 3);
2586
+ var ek2 = dy1 === 0 ? INFINITY : _export.MathUtils.toFixedFloat((destLine.y2 - srcLine.y1) / dy1, 3);
2587
+ if (sk1 !== INFINITY && sk2 !== INFINITY && ek1 !== INFINITY && ek2 !== INFINITY && (sk1 !== sk2 || ek1 !== ek2))
2588
+ // destLine does not overlap with srcLine
2589
+ return {
2590
+ result: _constants.OVERLAP_NONE
2591
+ };
2592
+
2593
+ // parameter of destLine on the start and end points
2594
+ var sk = Math.min(sk1, sk2);
2595
+ if (Math.abs(sk) < 0.05) sk = 0;else if (Math.abs(Math.abs(sk) - 1) < 0.05) sk = 1;
2596
+ var ek = Math.abs(Math.min(ek1, ek2)) > 0.05 ? Math.min(ek1, ek2) : 0;
2597
+ if (Math.abs(ek) < 0.05) ek = 0;else if (Math.abs(Math.abs(ek) - 1) < 0.05) ek = 1;
2598
+ // let ek = Math.min(ek1, ek2);
2599
+
2600
+ // check the relationship between srcLine and destLine
2601
+ if (sk < 0 && ek < 0 || sk > 1 && ek > 1)
2602
+ // not overlap
2603
+ return {
2604
+ result: _constants.OVERLAP_NONE
2605
+ };
2606
+ if (sk === 0 && ek === 1 || sk === 1 && ek === 0)
2607
+ // same lines
2608
+ return {
2609
+ result: _constants.OVERLAP_SAME
2610
+ };
2611
+ if (sk <= 0 && ek >= 1 || sk >= 1 && ek <= 0)
2612
+ // destLine includes srcLine
2613
+ return {
2614
+ result: _constants.OVERLAP_INCLUDED
2615
+ };
2616
+ if (sk === 0 && ek < 0 || sk === 1 && ek > 1 || ek === 0 && sk < 0 || ek === 1 && sk > 1) {
2617
+ // linked with one common point
2618
+ var linkedLine;
2619
+ if (sk === 0 && ek < 0) {
2620
+ // destE destS srcS srcE
2621
+ // |----------|------------|
2622
+ linkedLine = {
2623
+ x1: destLine.x2,
2624
+ y1: destLine.y2,
2625
+ x2: srcLine.x2,
2626
+ y2: srcLine.y2
2627
+ };
2628
+ } else if (sk === 1 && ek > 1) {
2629
+ // srcS srcE destS destE
2630
+ // |----------|------------|
2631
+ linkedLine = {
2632
+ x1: srcLine.x1,
2633
+ y1: srcLine.y1,
2634
+ x2: destLine.x2,
2635
+ y2: destLine.y2
2636
+ };
2637
+ } else if (ek === 0 && sk < 0) {
2638
+ // destS destE srcS srcE
2639
+ // |----------|------------|
2640
+ linkedLine = {
2641
+ x1: destLine.x1,
2642
+ y1: destLine.y1,
2643
+ x2: srcLine.x2,
2644
+ y2: srcLine.y2
2645
+ };
2646
+ } else if (ek === 1 && sk > 1) {
2647
+ // srcS srcE destE destS
2648
+ // |----------|------------|
2649
+ linkedLine = {
2650
+ x1: srcLine.x1,
2651
+ y1: srcLine.y1,
2652
+ x2: destLine.x1,
2653
+ y2: destLine.y1
2654
+ };
2655
+ }
2656
+ return {
2657
+ result: _constants.OVERLAP_LINK,
2658
+ linkedLine: linkedLine
2659
+ };
2660
+ }
2661
+ var trimmedSegment1 = null;
2662
+ var trimmedSegment2 = null;
2663
+ var ret = {
2664
+ result: _constants.OVERLAP_SOME,
2665
+ trimmedSegs: []
2666
+ };
2667
+ if (0 <= sk && sk <= 1 && 0 <= ek && ek <= 1) {
2668
+ // srcLine includes destLine
2669
+ if (sk < ek) {
2670
+ // srcS destS destE srcE
2671
+ // |------|---------|-------|
2672
+ if (sk > 0) trimmedSegment1 = {
2673
+ x1: srcLine.x1,
2674
+ y1: srcLine.y1,
2675
+ x2: destLine.x1,
2676
+ y2: destLine.y1
2677
+ };
2678
+ if (ek < 1) trimmedSegment2 = {
2679
+ x1: destLine.x2,
2680
+ y1: destLine.y2,
2681
+ x2: srcLine.x2,
2682
+ y2: srcLine.y2
2683
+ };
2684
+ } else {
2685
+ // srcS destE destS srcE
2686
+ // |------|---------|-------|
2687
+ if (ek > 0) trimmedSegment1 = {
2688
+ x1: srcLine.x1,
2689
+ y1: srcLine.y1,
2690
+ x2: destLine.x2,
2691
+ y2: destLine.y2
2692
+ };
2693
+ if (sk < 1) trimmedSegment2 = {
2694
+ x1: destLine.x1,
2695
+ y1: destLine.y1,
2696
+ x2: srcLine.x2,
2697
+ y2: srcLine.y2
2698
+ };
2699
+ }
2700
+ } else {
2701
+ // srcLine and destLine are overlapped with some range
2702
+ if (sk < 0) {
2703
+ // destS srcS destE srcE
2704
+ // |------|---------|-------|
2705
+ trimmedSegment1 = {
2706
+ x1: destLine.x2,
2707
+ y1: destLine.y2,
2708
+ x2: srcLine.x2,
2709
+ y2: srcLine.y2
2710
+ };
2711
+ } else if (ek < 0) {
2712
+ // destE srcS destS srcE
2713
+ // |------|---------|-------|
2714
+ trimmedSegment1 = {
2715
+ x1: destLine.x1,
2716
+ y1: destLine.y1,
2717
+ x2: srcLine.x2,
2718
+ y2: srcLine.y2
2719
+ };
2720
+ } else if (sk > 1) {
2721
+ // srcS destE srcE destS
2722
+ // |------|---------|-------|
2723
+ trimmedSegment1 = {
2724
+ x1: srcLine.x1,
2725
+ y1: srcLine.y1,
2726
+ x2: destLine.x2,
2727
+ y2: destLine.y2
2728
+ };
2729
+ } else if (ek > 1) {
2730
+ // srcS destS srcE destE
2731
+ // |------|---------|-------|
2732
+ trimmedSegment1 = {
2733
+ x1: srcLine.x1,
2734
+ y1: srcLine.y1,
2735
+ x2: destLine.x1,
2736
+ y2: destLine.y1
2737
+ };
2738
+ }
2739
+ }
2740
+ if (trimmedSegment1 !== null) ret.trimmedSegs.push(trimmedSegment1);
2741
+ if (trimmedSegment2 !== null) ret.trimmedSegs.push(trimmedSegment2);
2742
+ return ret;
2743
+ }
2744
+
2745
+ /**
2746
+ *
2747
+ * @param {Array} points points of polygon [[x0, y0], [x1, y1], ...]
2748
+ * @returns {Array} { x, y } position of centroid
2749
+ */
2750
+ function getCentroidOfPolygon(points) {
2751
+ var centroid = points.reduce(function (x, y) {
2752
+ return [x[0] + y[0] / points.length, x[1] + y[1] / points.length];
2753
+ }, [0, 0]);
2754
+ return {
2755
+ x: centroid[0],
2756
+ y: centroid[1]
2757
+ };
2758
+ }
2759
+
2760
+ /**
2761
+ * Return the polygon points of room
2762
+ * @param {Object} layer
2763
+ * @returns {Array} polygon points [x0, y0, x1, y1, ... ]
2764
+ */
2765
+ function getPoylgonPoints(layer) {
2766
+ var _layer$areas;
2767
+ var areainfo = [];
2768
+ (_layer$areas = layer.areas) === null || _layer$areas === void 0 || _layer$areas.forEach(function (area) {
2769
+ var _area$vertices;
2770
+ var sz = (_area$vertices = area.vertices) === null || _area$vertices === void 0 ? void 0 : _area$vertices.size;
2771
+ for (var i = 0; i < sz; i++) {
2772
+ areainfo.push(area.vertices.get(i));
2773
+ }
2774
+ });
2775
+ var rect = [];
2776
+ areainfo.forEach(function (area) {
2777
+ var _layer$vertices;
2778
+ var vert = (_layer$vertices = layer.vertices) === null || _layer$vertices === void 0 ? void 0 : _layer$vertices.get(area);
2779
+ rect.push(vert === null || vert === void 0 ? void 0 : vert.x, vert === null || vert === void 0 ? void 0 : vert.y);
2780
+ });
2781
+ return rect;
2782
+ }
2783
+ function validRect(itemRect, rects) {
2784
+ var updatedItemRect = getCalcRectFromItem(itemRect);
2785
+ return rects.every(function (rect) {
2786
+ return !intersectRect(rect.rect, updatedItemRect.rect);
2787
+ });
2788
+ }
2789
+ function getCalcRectFromItem2(itemInfo) {
2790
+ var x = itemInfo.pos.x;
2791
+ var y = itemInfo.pos.y;
2792
+ var w = itemInfo.size.width / 2;
2793
+ var h = itemInfo.size.height / 2;
2794
+ var rotRad = itemInfo.rotRad;
2795
+ var mx = x - w * Math.cos(rotRad);
2796
+ var my = y - w * Math.sin(rotRad);
2797
+ var m2x = x + w * Math.cos(rotRad);
2798
+ var m2y = y + w * Math.sin(rotRad);
2799
+ var m3x = x - h * Math.sin(rotRad);
2800
+ var m3y = y + h * Math.cos(rotRad);
2801
+ var m1x = x + h * Math.sin(rotRad);
2802
+ var m1y = y - h * Math.cos(rotRad);
2803
+ return {
2804
+ rectCenterPoint: [[point(mx, my), 180], [point(m1x, m1y), -90], [point(m2x, m2y), 0], [point(m3x, m3y), 90]]
2805
+ };
2806
+ }
2807
+ function getAllItems2(curItem, layer) {
2808
+ var rectarray = [];
2809
+ layer.items.forEach(function (item) {
2810
+ var val = {
2811
+ pos: {
2812
+ x: item.x,
2813
+ y: item.y
2814
+ },
2815
+ rotRad: item.rotation / 180 * Math.PI
2816
+ };
2817
+ var width = (0, _convertUnitsLite.convert)(item.properties.getIn(['width', '_length'])).from(curItem.get('properties').get('width').get('_unit')).to('cm');
2818
+ var height = (0, _convertUnitsLite.convert)(item.properties.getIn(['depth', '_length'])).from(curItem.get('properties').get('depth').get('_unit')).to('cm');
2819
+ val.size = {
2820
+ width: width,
2821
+ height: height
2822
+ };
2823
+ var curItemTall = (0, _convertUnitsLite.convert)(curItem.get('properties').get('height').get('_length')).from(curItem.get('properties').get('height').get('_unit')).to('cm');
2824
+ var zMinCurItem = (0, _convertUnitsLite.convert)(curItem.get('properties').get('altitude').get('_length')).from(curItem.get('properties').get('altitude').get('_unit')).to('cm');
2825
+ var zMaxCurItem = zMinCurItem + curItemTall;
2826
+ if (curItem.get('id') !== item.id) {
2827
+ var detectObjectsAtSameAltitudeFlag = false;
2828
+ var itemTall = (0, _convertUnitsLite.convert)(item.properties.getIn(['height', '_length'])).from(item.get('properties').get('height').get('_unit')).to('cm');
2829
+ var zMinItem = (0, _convertUnitsLite.convert)(item.properties.getIn(['altitude', '_length'])).from(item.get('properties').get('altitude').get('_unit')).to('cm');
2830
+ var zMaxItem = zMinItem + itemTall;
2831
+ if (zMinItem - zMinCurItem >= 0 && zMaxCurItem - zMinItem > _constants.EPSILON || zMinCurItem - zMinItem >= 0 && zMaxItem - zMinCurItem > _constants.EPSILON) detectObjectsAtSameAltitudeFlag = true;
2832
+ if (detectObjectsAtSameAltitudeFlag) {
2833
+ var x = val.pos.x;
2834
+ var y = val.pos.y;
2835
+ var rotRad = val.rotRad;
2836
+ var w = val.size.width / 2;
2837
+ var h = val.size.height / 2;
2838
+ var mx = x - w * Math.cos(rotRad);
2839
+ var my = y - w * Math.sin(rotRad);
2840
+ var x0 = mx + h * Math.sin(rotRad);
2841
+ var y0 = my - h * Math.cos(rotRad);
2842
+ var x3 = mx * 2 - x0;
2843
+ var y3 = my * 2 - y0;
2844
+ var x1 = x * 2 - x3;
2845
+ var y1 = y * 2 - y3;
2846
+ var x2 = x * 2 - x0;
2847
+ var y2 = y * 2 - y0;
2848
+ rectarray.push({
2849
+ rect: [point(x0, y0), point(x1, y1), point(x0, y0), point(x1, y1)]
2850
+ });
2851
+ rectarray.push({
2852
+ rect: [point(x1, y1), point(x2, y2), point(x1, y1), point(x2, y2)]
2853
+ });
2854
+ rectarray.push({
2855
+ rect: [point(x2, y2), point(x3, y3), point(x2, y2), point(x3, y3)]
2856
+ });
2857
+ rectarray.push({
2858
+ rect: [point(x3, y3), point(x0, y0), point(x3, y3), point(x0, y0)]
2859
+ });
2860
+ }
2861
+ }
2862
+ });
2863
+ return {
2864
+ others: rectarray
2865
+ };
2866
+ }
2867
+ function calcDistancesFromItemToWalls(curItem, layer) {
2868
+ if ((0, _helper.isEmpty)(curItem)) return [];
2869
+ var x = curItem.get('x');
2870
+ var y = curItem.get('y');
2871
+ var rotRad = curItem.get('rotation') / 180 * Math.PI;
2872
+ var width, height;
2873
+ if (curItem.get('properties').get('width') || curItem.get('properties').get('depth')) {
2874
+ width = (0, _convertUnitsLite.convert)(curItem.get('properties').get('width').get('_length')).from(curItem.get('properties').get('width').get('_unit')).to('cm');
2875
+ height = (0, _convertUnitsLite.convert)(curItem.get('properties').get('depth').get('_length')).from(curItem.get('properties').get('depth').get('_unit')).to('cm');
2876
+ } else {
2877
+ width = (0, _convertUnitsLite.convert)(curItem.info.sizeinfo.width).from('in').to('cm');
2878
+ height = (0, _convertUnitsLite.convert)(curItem.info.sizeinfo.depth).from('in').to('cm');
2879
+ }
2880
+ var center_x = x; // middle of front line of cabinet rect
2881
+ var center_y = y;
2882
+ var PointArray = [];
2883
+ var itemInfo = {
2884
+ pos: {
2885
+ x: x,
2886
+ y: y
2887
+ },
2888
+ rotRad: rotRad
2889
+ };
2890
+ itemInfo.size = {
2891
+ width: width,
2892
+ height: height
2893
+ };
2894
+ var curiteminfo = getCalcRectFromItem2(itemInfo);
2895
+ var allItemRect = getAllItems2(curItem, layer); // get all item edge rects
2896
+ var allLines = getAllLines(layer); // get all wall lines
2897
+ var allLineRects = buildRectFromLines(layer, allLines); // make line rects from wall lines
2898
+ var allRect = allLineRects.concat(allItemRect.others); // item edges + wall lines
2899
+ var _loop = function _loop(i) {
2900
+ // [rectCenterPoint] has four middle points of cabinet rect edges
2901
+ var centerpoint = curiteminfo.rectCenterPoint[i];
2902
+ var comparelength = []; // distance array from rectCenterPoint[i] to other lines(walls, other cabinet rect edges)
2903
+ var a;
2904
+ var RectLineFuction = linePassingThroughTwoPoints(centerpoint[0].x, centerpoint[0].y, center_x, center_y); // normal line of cabinet rect edge
2905
+
2906
+ allRect.forEach(function (linerect) {
2907
+ // calc distance to all other lines
2908
+ var p0 = clone_point(linerect.rect[2]);
2909
+ var p1 = clone_point(linerect.rect[3]);
2910
+ var lineFunction = {}; // other line function
2911
+ if (p0.x !== p1.x || p0.y !== p1.y) lineFunction = linePassingThroughTwoPoints(p0.x, p0.y, p1.x, p1.y);
2912
+ // intersection between normal line and other line
2913
+ var coordinatePoint = twoLinesIntersection(lineFunction.a, lineFunction.b, lineFunction.c, RectLineFuction.a, RectLineFuction.b, RectLineFuction.c);
2914
+ if (coordinatePoint !== undefined) {
2915
+ if (
2916
+ // intersection point is on the other line
2917
+ pointsDistance(p0.x, p0.y, p1.x, p1.y) > pointsDistance(p0.x, p0.y, coordinatePoint.x, coordinatePoint.y) && pointsDistance(p0.x, p0.y, p1.x, p1.y) > pointsDistance(p1.x, p1.y, coordinatePoint.x, coordinatePoint.y)) {
2918
+ // check the intersection point is outside direction of edge
2919
+ var isOutside = true;
2920
+ for (var j = 0; j < curiteminfo.rectCenterPoint.length; j++) {
2921
+ if (j === i) continue;
2922
+ var otherCenterPoint = curiteminfo.rectCenterPoint[j];
2923
+ if (isPointOnLineSegment(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y, otherCenterPoint[0].x, otherCenterPoint[0].y)) isOutside = false;
2924
+ }
2925
+ if (isOutside && pointsDistance(coordinatePoint.x, coordinatePoint.y, center_x, center_y) > pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y)) {
2926
+ comparelength.push(pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y));
2927
+ a = Math.min.apply(null, comparelength);
2928
+ }
2929
+ }
2930
+ }
2931
+ });
2932
+ PointArray.push([a, centerpoint[1]]);
2933
+ };
2934
+ for (var i = 0; i < curiteminfo.rectCenterPoint.length; i++) {
2935
+ _loop(i);
2936
+ }
2937
+ PointArray.forEach(function (pointElement, index) {
2938
+ if (pointElement[0] == undefined) PointArray[index][0] = 0;
2939
+ });
2940
+ var cnt = 0;
2941
+ PointArray.forEach(function (pointElement) {
2942
+ if (pointElement[0] == 0) cnt++;
2943
+ });
2944
+ if (cnt == 4 || cnt == 3) {
2945
+ PointArray[0][0] = 100;
2946
+ PointArray[1][0] = 100;
2947
+ }
2948
+ return {
2949
+ PointArray: PointArray
2950
+ };
2951
+ }
2952
+ function calcDistancesFromHoleToNearestOneOrWall(curHole, layer) {
2953
+ var _layer$lines, _layer$vertices2, _line$vertices, _layer$vertices3, _line$vertices2, _curHole$properties$g, _curHole$properties, _line$get;
2954
+ var distArray = {
2955
+ distLeft: 0,
2956
+ distRight: 0
2957
+ };
2958
+ if ((0, _helper.isEmpty)(curHole)) return distArray;
2959
+ /***** calculate Left & Right distance from nearest hole ******/
2960
+ // parent line of curHole
2961
+ var line = (_layer$lines = layer.lines) === null || _layer$lines === void 0 ? void 0 : _layer$lines.get(curHole.line);
2962
+ var v0 = (_layer$vertices2 = layer.vertices) === null || _layer$vertices2 === void 0 ? void 0 : _layer$vertices2.get(line === null || line === void 0 || (_line$vertices = line.vertices) === null || _line$vertices === void 0 ? void 0 : _line$vertices.get(0));
2963
+ var v1 = (_layer$vertices3 = layer.vertices) === null || _layer$vertices3 === void 0 ? void 0 : _layer$vertices3.get(line === null || line === void 0 || (_line$vertices2 = line.vertices) === null || _line$vertices2 === void 0 ? void 0 : _line$vertices2.get(1));
2964
+ var lineLength = pointsDistance(v0.x, v0.y, v1.x, v1.y);
2965
+ if ((0, _helper.isEmpty)(line) || (0, _helper.isEmpty)(v0) || (0, _helper.isEmpty)(v1)) return distArray;
2966
+ var angle = angleBetweenTwoPoints(v0.x, v0.y, v1.x, v1.y);
2967
+
2968
+ // start point and end point of current hole
2969
+ var chw = (_curHole$properties$g = (_curHole$properties = curHole.properties) === null || _curHole$properties === void 0 || (_curHole$properties = _curHole$properties.get('width')) === null || _curHole$properties === void 0 ? void 0 : _curHole$properties.get('length')) !== null && _curHole$properties$g !== void 0 ? _curHole$properties$g : 0;
2970
+ var chPt = {
2971
+ x: v0.x + lineLength * curHole.offset * Math.cos(angle),
2972
+ y: v0.y + lineLength * curHole.offset * Math.sin(angle)
2973
+ };
2974
+ var chsp = {
2975
+ x: chPt.x - chw / 2 * Math.cos(angle),
2976
+ y: chPt.y - chw / 2 * Math.sin(angle)
2977
+ };
2978
+ var chep = {
2979
+ x: chPt.x + chw / 2 * Math.cos(angle),
2980
+ y: chPt.y + chw / 2 * Math.sin(angle)
2981
+ };
2982
+ distArray.distLeft = pointsDistance(v0.x, v0.y, chsp.x, chsp.y);
2983
+ distArray.distRight = pointsDistance(v1.x, v1.y, chep.x, chep.y);
2984
+ (_line$get = line.get('holes')) === null || _line$get === void 0 || _line$get.forEach(function (hId) {
2985
+ if (hId !== curHole.id) {
2986
+ var _layer$holes, _hole$properties$get$, _hole$properties;
2987
+ var hole = (_layer$holes = layer.holes) === null || _layer$holes === void 0 ? void 0 : _layer$holes.get(hId);
2988
+ // start point and end point of other hole
2989
+ var hw = (_hole$properties$get$ = (_hole$properties = hole.properties) === null || _hole$properties === void 0 || (_hole$properties = _hole$properties.get('width')) === null || _hole$properties === void 0 ? void 0 : _hole$properties.get('length')) !== null && _hole$properties$get$ !== void 0 ? _hole$properties$get$ : 0;
2990
+ var hPt = {
2991
+ x: v0.x + lineLength * hole.offset * Math.cos(angle),
2992
+ y: v0.y + lineLength * hole.offset * Math.sin(angle)
2993
+ };
2994
+ var hsp = {
2995
+ x: hPt.x - hw / 2 * Math.cos(angle),
2996
+ y: hPt.y - hw / 2 * Math.sin(angle)
2997
+ };
2998
+ var hep = {
2999
+ x: hPt.x + hw / 2 * Math.cos(angle),
3000
+ y: hPt.y + hw / 2 * Math.sin(angle)
3001
+ };
3002
+ var relation = relationshipOfTwoOverlappedLines({
3003
+ x1: chsp.x,
3004
+ y1: chsp.y,
3005
+ x2: chep.x,
3006
+ y2: chep.y
3007
+ }, {
3008
+ x1: hsp.x,
3009
+ y1: hsp.y,
3010
+ x2: hep.x,
3011
+ y2: hep.y
3012
+ });
3013
+ // two holes(current hole and other hole) are not overlaped, then get distance
3014
+ if (relation.result === _constants.OVERLAP_NONE || relation.result === _constants.OVERLAP_LINK) {
3015
+ if (hole.offset < curHole.offset)
3016
+ // other hole is on the left side
3017
+ distArray.distLeft = Math.min(distArray.distLeft, pointsDistance(chsp.x, chsp.y, hep.x, hep.y));
3018
+ // other hole is on the right side
3019
+ else distArray.distRight = Math.min(distArray.distRight, pointsDistance(chep.x, chep.y, hsp.x, hsp.y));
3020
+ }
3021
+ }
3022
+ });
3023
+ return distArray;
3024
+ }
3025
+ function getSnappedWallLines(item, layer, catalog) {
3026
+ var _element;
3027
+ var snappedWallLines = [];
3028
+ if ((0, _helper.isEmpty)(item)) return snappedWallLines;
3029
+ var vertexLines = getAllLines(layer);
3030
+ var rectLines = buildRectFromLines(layer, vertexLines);
3031
+ var outline = null;
3032
+ var element = catalog.elements[item.get('type')];
3033
+ if (!element) element = catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(item.get('type'))];
3034
+ var newWidth = item.properties.get('width').get('_length');
3035
+ var wUnit = item.properties.get('width').get('_unit') || 'cm';
3036
+ newWidth = (0, _convertUnitsLite.convert)(newWidth).from(wUnit).to('cm');
3037
+ var newDepth = item.properties.get('depth').get('_length');
3038
+ var hUnit = item.properties.get('depth').get('_unit') || 'cm';
3039
+ newDepth = (0, _convertUnitsLite.convert)(newDepth).from(hUnit).to('cm');
3040
+ var overlapList = [_constants.OVERLAP_INCLUDED, _constants.OVERLAP_SAME, _constants.OVERLAP_SOME];
3041
+
3042
+ // Get Outline Data of Selected Item
3043
+ outline = (_element = element) === null || _element === void 0 || (_element = _element.info) === null || _element === void 0 ? void 0 : _element.outline;
3044
+ if (outline) {
3045
+ // Extract Points from `outline`
3046
+ var outlinePaths = outline.paths;
3047
+ var outlineWidth = outline.svgWidth;
3048
+ var outlineHeight = outline.svgHeight;
3049
+ var outlinePoints = []; // Hold Points Of SVG
3050
+ var _iterator7 = _createForOfIteratorHelper(outlinePaths),
3051
+ _step7;
3052
+ try {
3053
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
3054
+ var path = _step7.value;
3055
+ var _iterator8 = _createForOfIteratorHelper(path.subPaths),
3056
+ _step8;
3057
+ try {
3058
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
3059
+ var subPath = _step8.value;
3060
+ outlinePoints = outlinePoints.concat(subPath.getPoints());
3061
+ }
3062
+ } catch (err) {
3063
+ _iterator8.e(err);
3064
+ } finally {
3065
+ _iterator8.f();
3066
+ }
3067
+ }
3068
+ } catch (err) {
3069
+ _iterator7.e(err);
3070
+ } finally {
3071
+ _iterator7.f();
3072
+ }
3073
+ outline.reverse && outlinePoints.reverse();
3074
+ for (var i = 0; i < outlinePoints.length - 1; i++) {
3075
+ var v0 = rotatePointAroundPoint((outlinePoints[i].x / outlineWidth - 0.5) * newWidth + item.x, (outlinePoints[i].y / outlineHeight - 0.5) * newDepth + item.y, item.x, item.y, item.rotation + 90);
3076
+ var v1 = rotatePointAroundPoint((outlinePoints[i + 1].x / outlineWidth - 0.5) * newWidth + item.x, (outlinePoints[i + 1].y / outlineHeight - 0.5) * newDepth + item.y, item.x, item.y, item.rotation + 90);
3077
+ var srcLine = {
3078
+ x1: v0.x,
3079
+ y1: v0.y,
3080
+ x2: v1.x,
3081
+ y2: v1.y
3082
+ };
3083
+ var _loop2 = function _loop2(j) {
3084
+ var destLine1 = {
3085
+ x1: rectLines[j].rect[2].x,
3086
+ y1: rectLines[j].rect[2].y,
3087
+ x2: rectLines[j].rect[3].x,
3088
+ y2: rectLines[j].rect[3].y
3089
+ };
3090
+ var destLine2 = {
3091
+ x1: rectLines[j].rect[0].x,
3092
+ y1: rectLines[j].rect[0].y,
3093
+ x2: rectLines[j].rect[1].x,
3094
+ y2: rectLines[j].rect[1].y
3095
+ };
3096
+ if (overlapList.includes(relationshipOfTwoOverlappedLines(srcLine, destLine1).result) || overlapList.includes(relationshipOfTwoOverlappedLines(srcLine, destLine2).result)) {
3097
+ var idx = snappedWallLines.findIndex(function (v) {
3098
+ return v.id === rectLines[j].lineId;
3099
+ });
3100
+ var snapSide = 'unknown';
3101
+ if (idx < 0) snappedWallLines.push({
3102
+ id: rectLines[j].lineId,
3103
+ lineRect: rectLines[j].rect,
3104
+ snapSide: snapSide
3105
+ });else snappedWallLines[idx].snapSide = snapSide;
3106
+ }
3107
+ };
3108
+ for (var j = 0; j < (rectLines === null || rectLines === void 0 ? void 0 : rectLines.length); j++) {
3109
+ _loop2(j);
3110
+ }
3111
+ }
3112
+ } else {
3113
+ var pos = [[-1, -1], [1, -1], [1, 1], [-1, 1]];
3114
+ for (var _i = 0; _i < 4; _i++) {
3115
+ var _v = rotatePointAroundPoint(pos[_i][0] * newWidth / 2 + item.x, pos[_i][1] * newDepth / 2 + item.y, item.x, item.y, item.rotation);
3116
+ var _v2 = rotatePointAroundPoint(pos[(_i + 1) % 4][0] * newWidth / 2 + item.x, pos[(_i + 1) % 4][1] * newDepth / 2 + item.y, item.x, item.y, item.rotation);
3117
+ var _srcLine = {
3118
+ x1: _v.x,
3119
+ y1: _v.y,
3120
+ x2: _v2.x,
3121
+ y2: _v2.y
3122
+ };
3123
+ var _loop3 = function _loop3(_j) {
3124
+ var destLine1 = {
3125
+ x1: rectLines[_j].rect[2].x,
3126
+ y1: rectLines[_j].rect[2].y,
3127
+ x2: rectLines[_j].rect[3].x,
3128
+ y2: rectLines[_j].rect[3].y
3129
+ };
3130
+ var destLine2 = {
3131
+ x1: rectLines[_j].rect[0].x,
3132
+ y1: rectLines[_j].rect[0].y,
3133
+ x2: rectLines[_j].rect[1].x,
3134
+ y2: rectLines[_j].rect[1].y
3135
+ };
3136
+ if (overlapList.includes(relationshipOfTwoOverlappedLines(_srcLine, destLine1).result) || overlapList.includes(relationshipOfTwoOverlappedLines(_srcLine, destLine2).result)) {
3137
+ var idx = snappedWallLines.findIndex(function (v) {
3138
+ return v.id === rectLines[_j].lineId;
3139
+ });
3140
+ var snapSide = _i === 0 || _i === 2 ? 'front' : 'side';
3141
+ if (idx < 0) snappedWallLines.push({
3142
+ id: rectLines[_j].lineId,
3143
+ lineRect: rectLines[_j].rect,
3144
+ snapSide: snapSide
3145
+ });else snappedWallLines[idx].snapSide = snapSide;
3146
+ }
3147
+ };
3148
+ for (var _j = 0; _j < (rectLines === null || rectLines === void 0 ? void 0 : rectLines.length); _j++) {
3149
+ _loop3(_j);
3150
+ }
3151
+ }
3152
+ }
3153
+ return snappedWallLines;
3154
+ }
3155
+ function getLineSnapPointsOfItem(layer, curLine, item) {
3156
+ var _layer$lines2, _layer$vertices4, _line$vertices3, _layer$vertices5, _line$vertices4;
3157
+ // V0
3158
+ // /|
3159
+ // D0 /|-----------|
3160
+ // /| |
3161
+ // /| Item | ====> get D0, D1
3162
+ // /| |
3163
+ // D1 /|-----------|
3164
+ // /|
3165
+ // get v0, v1 of line
3166
+ var line = (_layer$lines2 = layer.lines) === null || _layer$lines2 === void 0 ? void 0 : _layer$lines2.get(curLine === null || curLine === void 0 ? void 0 : curLine.id);
3167
+ var v0 = (_layer$vertices4 = layer.vertices) === null || _layer$vertices4 === void 0 ? void 0 : _layer$vertices4.get(line === null || line === void 0 || (_line$vertices3 = line.vertices) === null || _line$vertices3 === void 0 ? void 0 : _line$vertices3.get(0));
3168
+ var v1 = (_layer$vertices5 = layer.vertices) === null || _layer$vertices5 === void 0 ? void 0 : _layer$vertices5.get(line === null || line === void 0 || (_line$vertices4 = line.vertices) === null || _line$vertices4 === void 0 ? void 0 : _line$vertices4.get(1));
3169
+ var pointGroup = [];
3170
+ if ((0, _helper.isEmpty)(v0) || (0, _helper.isEmpty)(v1)) return pointGroup;
3171
+ var itemRect = item === null || item === void 0 ? void 0 : item.rect;
3172
+ if (!(0, _helper.isEmpty)(itemRect)) {
3173
+ for (var i = 0; i < itemRect.length; i++) {
3174
+ if (distancePointFromLineSegment(v0, v1, itemRect[i].x, itemRect[i].y) < _constants.EPSILON) {
3175
+ pointGroup.push(itemRect[i]);
3176
+ }
3177
+ }
3178
+ }
3179
+ return pointGroup;
3180
+ }
3181
+ function isOverlappedTwoItemsOnOneLine(layer, curLine, srcItem, desItem) {
3182
+ var _layer$lines3, _layer$vertices6, _line$vertices5, _layer$vertices7, _line$vertices6, _S, _S2, _S3, _S4;
3183
+ if ((0, _helper.isEmpty)(layer) || (0, _helper.isEmpty)(curLine) || (0, _helper.isEmpty)(srcItem) || (0, _helper.isEmpty)(desItem) || (0, _helper.isEmpty)(desItem.D0) || (0, _helper.isEmpty)(desItem.D1)) return false;
3184
+ // get v0, v1 of line
3185
+ var line = (_layer$lines3 = layer.lines) === null || _layer$lines3 === void 0 ? void 0 : _layer$lines3.get(curLine === null || curLine === void 0 ? void 0 : curLine.id);
3186
+ var v0 = (_layer$vertices6 = layer.vertices) === null || _layer$vertices6 === void 0 ? void 0 : _layer$vertices6.get(line === null || line === void 0 || (_line$vertices5 = line.vertices) === null || _line$vertices5 === void 0 ? void 0 : _line$vertices5.get(0));
3187
+ var v1 = (_layer$vertices7 = layer.vertices) === null || _layer$vertices7 === void 0 ? void 0 : _layer$vertices7.get(line === null || line === void 0 || (_line$vertices6 = line.vertices) === null || _line$vertices6 === void 0 ? void 0 : _line$vertices6.get(1));
3188
+ var S0,
3189
+ S1,
3190
+ D0 = desItem === null || desItem === void 0 ? void 0 : desItem.D0,
3191
+ D1 = desItem === null || desItem === void 0 ? void 0 : desItem.D1;
3192
+ if ((0, _helper.isEmpty)(v0) || (0, _helper.isEmpty)(v1)) return false;
3193
+ // get distance from v0 to srcItem's S0, S1 and desItem(item or hole)'s D0, D1 are placed on line
3194
+ var srcPoints = getLineSnapPointsOfItem(layer, curLine, srcItem);
3195
+ if (srcPoints.length > 1) {
3196
+ S0 = srcPoints[0];
3197
+ S1 = srcPoints[1];
3198
+ }
3199
+ var disV0S0 = pointsDistance(v0.x, v0.y, (_S = S0) === null || _S === void 0 ? void 0 : _S.x, (_S2 = S0) === null || _S2 === void 0 ? void 0 : _S2.y);
3200
+ var disV0S1 = pointsDistance(v0.x, v0.y, (_S3 = S1) === null || _S3 === void 0 ? void 0 : _S3.x, (_S4 = S1) === null || _S4 === void 0 ? void 0 : _S4.y);
3201
+ var disV0D0 = pointsDistance(v0.x, v0.y, D0.x, D0.y);
3202
+ var disV0D1 = pointsDistance(v0.x, v0.y, D1.x, D1.y);
3203
+ // detect two items are overlapped
3204
+ var maxDisV0S = Math.max(disV0S0, disV0S1);
3205
+ var minDisV0S = Math.min(disV0S0, disV0S1);
3206
+ var maxDisV0D = Math.max(disV0D0, disV0D1);
3207
+ var minDisV0D = Math.min(disV0D0, disV0D1);
3208
+ if (maxDisV0S > maxDisV0D && maxDisV0D - minDisV0S > _constants.EPSILON) {
3209
+ // d0 s0 d1 s1 ===> maxDisV0S: v0s1, minDisV0S: v0s0, maxDisV0D: v0d1, minDisV0D: v0d0
3210
+ // v0 __________________________ v1
3211
+ // | | | |
3212
+ // | | | |
3213
+ // |__DI__|__| |
3214
+ // |__SI__|
3215
+ /////////////////////////////////////////
3216
+ // s0 d0 d1 s1 ===> maxDisV0S: v0s1, minDisV0S: v0s0, maxDisV0D: v0d1, minDisV0D: v0d0
3217
+ // v0 __________________________ v1
3218
+ // | | | |
3219
+ // | |__DI__| |
3220
+ // |_________SI_______|
3221
+ return true;
3222
+ } else if (minDisV0S < minDisV0D && maxDisV0S - minDisV0D > _constants.EPSILON) {
3223
+ // s0 d0 s1 d1 ===> maxDisV0S: v0s1, minDisV0S: v0s0, maxDisV0D: v0d1, minDisV0D: v0d0
3224
+ // v0 __________________________ v1
3225
+ // | | | |
3226
+ // | |__DI__|
3227
+ // |__SI_____|
3228
+ //
3229
+ return true;
3230
+ } else {
3231
+ return false;
3232
+ }
3233
+ }