kitchen-simulator 1.1.1-test.62 → 1.1.1-test.64

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 (306) hide show
  1. package/es/@history.js +2 -10
  2. package/es/AppContext.js +3 -10
  3. package/es/KitchenConfigurator.js +70 -79
  4. package/es/KitchenConfiguratorApp.js +98 -107
  5. package/es/actions/area-actions.js +5 -12
  6. package/es/actions/export.js +12 -29
  7. package/es/actions/groups-actions.js +27 -45
  8. package/es/actions/holes-actions.js +34 -55
  9. package/es/actions/items-actions.js +94 -145
  10. package/es/actions/lines-actions.js +21 -36
  11. package/es/actions/project-actions.js +94 -145
  12. package/es/actions/scene-actions.js +11 -21
  13. package/es/actions/vertices-actions.js +7 -15
  14. package/es/actions/viewer2d-actions.js +21 -36
  15. package/es/actions/viewer3d-actions.js +9 -18
  16. package/es/catalog/areas/area/planner-element.js +2 -9
  17. package/es/catalog/catalog.js +15 -21
  18. package/es/catalog/factories/area-factory-3d.js +22 -31
  19. package/es/catalog/factories/area-factory.js +11 -20
  20. package/es/catalog/factories/export.js +6 -24
  21. package/es/catalog/factories/wall-factory-3d.js +31 -41
  22. package/es/catalog/factories/wall-factory.js +21 -31
  23. package/es/catalog/holes/door-closet/planner-element.js +15 -24
  24. package/es/catalog/holes/door-double/planner-element.js +15 -24
  25. package/es/catalog/holes/door-exterior/planner-element.js +16 -25
  26. package/es/catalog/holes/door-interior/planner-element.js +16 -25
  27. package/es/catalog/holes/door-panic/planner-element.js +7 -16
  28. package/es/catalog/holes/door-panic-double/planner-element.js +15 -24
  29. package/es/catalog/holes/door-sliding/planner-element.js +16 -25
  30. package/es/catalog/holes/doorway-framed/planner-element.js +11 -20
  31. package/es/catalog/holes/doorway-frameless/planner-element.js +7 -16
  32. package/es/catalog/holes/export.js +13 -97
  33. package/es/catalog/holes/window-clear/planner-element.js +10 -19
  34. package/es/catalog/holes/window-cross/planner-element.js +10 -19
  35. package/es/catalog/holes/window-double-hung/planner-element.js +10 -19
  36. package/es/catalog/holes/window-vertical/planner-element.js +10 -19
  37. package/es/catalog/lines/wall/planner-element.js +2 -9
  38. package/es/catalog/molding/molding-dcm/planner-element.js +5 -14
  39. package/es/catalog/molding/molding-fbm/planner-element.js +5 -14
  40. package/es/catalog/molding/molding-lrm/planner-element.js +5 -14
  41. package/es/catalog/properties/export.js +20 -80
  42. package/es/catalog/properties/property-checkbox.js +24 -31
  43. package/es/catalog/properties/property-color.js +16 -23
  44. package/es/catalog/properties/property-enum.js +24 -31
  45. package/es/catalog/properties/property-hidden.js +9 -16
  46. package/es/catalog/properties/property-lenght-measure.js +38 -45
  47. package/es/catalog/properties/property-length-measure.js +36 -43
  48. package/es/catalog/properties/property-length-measure_hole.js +38 -45
  49. package/es/catalog/properties/property-number.js +17 -24
  50. package/es/catalog/properties/property-read-only.js +16 -23
  51. package/es/catalog/properties/property-string.js +16 -23
  52. package/es/catalog/properties/property-toggle.js +16 -23
  53. package/es/catalog/properties/shared-property-style.js +1 -7
  54. package/es/catalog/utils/FuseUtils.js +8 -15
  55. package/es/catalog/utils/exporter.js +8 -15
  56. package/es/catalog/utils/geom-utils.js +13 -29
  57. package/es/catalog/utils/item-loader.js +84 -97
  58. package/es/catalog/utils/load-obj.js +20 -28
  59. package/es/catalog/utils/mtl-loader.js +3 -8
  60. package/es/catalog/utils/obj-loader.js +3 -8
  61. package/es/class/FuseUtils.js +8 -15
  62. package/es/class/area.js +22 -28
  63. package/es/class/export.js +23 -95
  64. package/es/class/group.js +53 -59
  65. package/es/class/guide.js +15 -21
  66. package/es/class/hole.js +83 -89
  67. package/es/class/item.js +141 -147
  68. package/es/class/layer.js +59 -65
  69. package/es/class/line.js +135 -143
  70. package/es/class/project.js +90 -98
  71. package/es/class/vertex.js +29 -35
  72. package/es/components/content.js +19 -28
  73. package/es/components/disclaimer/disclaimer.js +10 -18
  74. package/es/components/export.js +8 -32
  75. package/es/components/style/button.js +23 -31
  76. package/es/components/style/cancel-button.js +7 -14
  77. package/es/components/style/content-container.js +9 -16
  78. package/es/components/style/content-title.js +11 -20
  79. package/es/components/style/delete-button.js +8 -17
  80. package/es/components/style/export.js +30 -120
  81. package/es/components/style/form-block.js +8 -15
  82. package/es/components/style/form-color-input.js +7 -14
  83. package/es/components/style/form-label.js +8 -15
  84. package/es/components/style/form-number-input.js +41 -49
  85. package/es/components/style/form-number-input_2.js +36 -44
  86. package/es/components/style/form-select.js +17 -24
  87. package/es/components/style/form-slider.js +10 -17
  88. package/es/components/style/form-submit-button.js +8 -17
  89. package/es/components/style/form-text-input.js +26 -34
  90. package/es/components/viewer2d/area.js +17 -24
  91. package/es/components/viewer2d/export.js +30 -120
  92. package/es/components/viewer2d/grids/grid-horizontal-streak.js +10 -17
  93. package/es/components/viewer2d/grids/grid-streak.js +10 -17
  94. package/es/components/viewer2d/grids/grid-vertical-streak.js +10 -17
  95. package/es/components/viewer2d/grids/grids.js +10 -19
  96. package/es/components/viewer2d/group.js +15 -24
  97. package/es/components/viewer2d/item.js +61 -70
  98. package/es/components/viewer2d/layer.js +23 -30
  99. package/es/components/viewer2d/line.js +101 -111
  100. package/es/components/viewer2d/ruler.js +22 -29
  101. package/es/components/viewer2d/rulerDist.js +21 -28
  102. package/es/components/viewer2d/rulerX.js +39 -47
  103. package/es/components/viewer2d/rulerY.js +37 -45
  104. package/es/components/viewer2d/scene.js +30 -38
  105. package/es/components/viewer2d/snap.js +13 -22
  106. package/es/components/viewer2d/state.js +18 -27
  107. package/es/components/viewer2d/utils.js +24 -37
  108. package/es/components/viewer2d/vertex.js +8 -17
  109. package/es/components/viewer2d/viewer2d.js +153 -163
  110. package/es/components/viewer3d/camera-controls-module/camera-controls.module.js +17 -23
  111. package/es/components/viewer3d/dcm.js +1 -7
  112. package/es/components/viewer3d/fbm.js +1 -7
  113. package/es/components/viewer3d/front3D.js +12 -21
  114. package/es/components/viewer3d/grid-creator.js +8 -17
  115. package/es/components/viewer3d/grids/grid-horizontal-streak.js +6 -14
  116. package/es/components/viewer3d/grids/grid-streak.js +5 -13
  117. package/es/components/viewer3d/grids/grid-vertical-streak.js +6 -14
  118. package/es/components/viewer3d/libs/first-person-controls.js +2 -9
  119. package/es/components/viewer3d/libs/helvetiker_regular.typeface.js +1 -7
  120. package/es/components/viewer3d/libs/mtl-loader.js +1 -7
  121. package/es/components/viewer3d/libs/obj-loader.js +1 -7
  122. package/es/components/viewer3d/libs/orbit-controls.js +2 -8
  123. package/es/components/viewer3d/libs/pointer-lock-controls.js +2 -8
  124. package/es/components/viewer3d/lrm.js +1 -7
  125. package/es/components/viewer3d/model.js +1 -7
  126. package/es/components/viewer3d/pointer-lock-navigation.js +3 -10
  127. package/es/components/viewer3d/ruler-utils/itemRect.js +18 -25
  128. package/es/components/viewer3d/ruler-utils/layer3D.js +59 -66
  129. package/es/components/viewer3d/ruler-utils/ruler3D.js +39 -46
  130. package/es/components/viewer3d/ruler-utils/scene3D.js +9 -17
  131. package/es/components/viewer3d/ruler-utils/state3D.js +4 -11
  132. package/es/components/viewer3d/scene-creator.js +191 -226
  133. package/es/components/viewer3d/three-memory-cleaner.js +3 -12
  134. package/es/components/viewer3d/viewer3d-first-person.js +40 -46
  135. package/es/components/viewer3d/viewer3d.js +196 -202
  136. package/es/constants.js +349 -358
  137. package/es/index.js +7 -15
  138. package/es/models.js +177 -184
  139. package/es/plugins/SVGLoader.js +48 -53
  140. package/es/plugins/autosave.js +3 -9
  141. package/es/plugins/console-debugger.js +5 -12
  142. package/es/plugins/export.js +8 -32
  143. package/es/plugins/keyboard.js +29 -35
  144. package/es/reducers/areas-reducer.js +7 -13
  145. package/es/reducers/export.js +24 -96
  146. package/es/reducers/groups-reducer.js +31 -37
  147. package/es/reducers/holes-reducer.js +43 -49
  148. package/es/reducers/items-reducer.js +106 -112
  149. package/es/reducers/lines-reducer.js +28 -34
  150. package/es/reducers/project-reducer.js +105 -111
  151. package/es/reducers/reducer.js +16 -23
  152. package/es/reducers/scene-reducer.js +15 -21
  153. package/es/reducers/user-reducer.js +5 -11
  154. package/es/reducers/vertices-reducer.js +11 -17
  155. package/es/reducers/viewer2d-reducer.js +18 -24
  156. package/es/reducers/viewer3d-reducer.js +16 -22
  157. package/es/shared-style.js +10 -16
  158. package/es/styles/export.js +3 -11
  159. package/es/translator/en.js +1 -7
  160. package/es/translator/it.js +1 -7
  161. package/es/translator/ru.js +1 -7
  162. package/es/translator/translator.js +13 -19
  163. package/es/utils/browser.js +2 -9
  164. package/es/utils/convert-units-lite.js +1 -7
  165. package/es/utils/email-validator.js +1 -7
  166. package/es/utils/export.js +15 -46
  167. package/es/utils/geometry.js +181 -278
  168. package/es/utils/get-edges-of-subgraphs.js +2 -9
  169. package/es/utils/graph-cycles.js +8 -11
  170. package/es/utils/graph-inner-cycles.js +10 -18
  171. package/es/utils/graph.js +9 -17
  172. package/es/utils/helper.js +39 -63
  173. package/es/utils/history.js +8 -15
  174. package/es/utils/id-broker.js +8 -15
  175. package/es/utils/logger.js +1 -7
  176. package/es/utils/math.js +5 -12
  177. package/es/utils/molding.js +119 -144
  178. package/es/utils/name-generator.js +7 -13
  179. package/es/utils/objects-utils.js +7 -19
  180. package/es/utils/phone-validator.js +1 -7
  181. package/es/utils/process-black-list.js +3 -10
  182. package/es/utils/react-if.js +6 -12
  183. package/es/utils/snap-scene.js +27 -34
  184. package/es/utils/snap.js +45 -59
  185. package/es/utils/summarizeCart.js +1 -7
  186. package/es/utils/threeCSG.es6.js +13 -22
  187. package/es/version.js +1 -7
  188. package/lib/@history.js +2 -1
  189. package/lib/AppContext.js +2 -1
  190. package/lib/KitchenConfigurator.js +2 -1
  191. package/lib/KitchenConfiguratorApp.js +2 -1
  192. package/lib/catalog/areas/area/planner-element.js +2 -1
  193. package/lib/catalog/catalog.js +2 -1
  194. package/lib/catalog/factories/area-factory.js +2 -1
  195. package/lib/catalog/factories/wall-factory.js +2 -1
  196. package/lib/catalog/holes/door-closet/planner-element.js +2 -1
  197. package/lib/catalog/holes/door-double/planner-element.js +2 -1
  198. package/lib/catalog/holes/door-exterior/planner-element.js +2 -1
  199. package/lib/catalog/holes/door-interior/planner-element.js +2 -1
  200. package/lib/catalog/holes/door-panic/planner-element.js +2 -1
  201. package/lib/catalog/holes/door-panic-double/planner-element.js +2 -1
  202. package/lib/catalog/holes/door-sliding/planner-element.js +2 -1
  203. package/lib/catalog/holes/doorway-framed/planner-element.js +2 -1
  204. package/lib/catalog/holes/doorway-frameless/planner-element.js +2 -1
  205. package/lib/catalog/holes/window-clear/planner-element.js +2 -1
  206. package/lib/catalog/holes/window-cross/planner-element.js +2 -1
  207. package/lib/catalog/holes/window-double-hung/planner-element.js +2 -1
  208. package/lib/catalog/holes/window-vertical/planner-element.js +2 -1
  209. package/lib/catalog/lines/wall/planner-element.js +2 -1
  210. package/lib/catalog/molding/molding-dcm/planner-element.js +2 -1
  211. package/lib/catalog/molding/molding-fbm/planner-element.js +2 -1
  212. package/lib/catalog/molding/molding-lrm/planner-element.js +2 -1
  213. package/lib/catalog/properties/property-checkbox.js +2 -1
  214. package/lib/catalog/properties/property-color.js +2 -1
  215. package/lib/catalog/properties/property-enum.js +2 -1
  216. package/lib/catalog/properties/property-hidden.js +2 -1
  217. package/lib/catalog/properties/property-lenght-measure.js +2 -1
  218. package/lib/catalog/properties/property-length-measure.js +2 -1
  219. package/lib/catalog/properties/property-length-measure_hole.js +2 -1
  220. package/lib/catalog/properties/property-number.js +2 -1
  221. package/lib/catalog/properties/property-read-only.js +2 -1
  222. package/lib/catalog/properties/property-string.js +2 -1
  223. package/lib/catalog/properties/property-toggle.js +2 -1
  224. package/lib/catalog/properties/shared-property-style.js +2 -1
  225. package/lib/catalog/utils/FuseUtils.js +2 -1
  226. package/lib/catalog/utils/exporter.js +2 -1
  227. package/lib/class/FuseUtils.js +2 -1
  228. package/lib/class/area.js +2 -1
  229. package/lib/class/group.js +2 -1
  230. package/lib/class/hole.js +2 -1
  231. package/lib/class/item.js +2 -1
  232. package/lib/class/layer.js +2 -1
  233. package/lib/class/line.js +2 -1
  234. package/lib/class/project.js +2 -1
  235. package/lib/class/vertex.js +2 -1
  236. package/lib/components/content.js +2 -1
  237. package/lib/components/disclaimer/disclaimer.js +2 -1
  238. package/lib/components/style/button.js +2 -1
  239. package/lib/components/style/cancel-button.js +2 -1
  240. package/lib/components/style/content-container.js +2 -1
  241. package/lib/components/style/content-title.js +2 -1
  242. package/lib/components/style/delete-button.js +2 -1
  243. package/lib/components/style/form-block.js +2 -1
  244. package/lib/components/style/form-color-input.js +2 -1
  245. package/lib/components/style/form-label.js +2 -1
  246. package/lib/components/style/form-number-input.js +2 -1
  247. package/lib/components/style/form-number-input_2.js +2 -1
  248. package/lib/components/style/form-select.js +2 -1
  249. package/lib/components/style/form-slider.js +2 -1
  250. package/lib/components/style/form-submit-button.js +2 -1
  251. package/lib/components/style/form-text-input.js +2 -1
  252. package/lib/components/viewer2d/area.js +2 -1
  253. package/lib/components/viewer2d/grids/grid-horizontal-streak.js +2 -1
  254. package/lib/components/viewer2d/grids/grid-streak.js +2 -1
  255. package/lib/components/viewer2d/grids/grid-vertical-streak.js +2 -1
  256. package/lib/components/viewer2d/grids/grids.js +2 -1
  257. package/lib/components/viewer2d/group.js +2 -1
  258. package/lib/components/viewer2d/item.js +2 -1
  259. package/lib/components/viewer2d/layer.js +2 -1
  260. package/lib/components/viewer2d/ruler.js +2 -1
  261. package/lib/components/viewer2d/rulerDist.js +2 -1
  262. package/lib/components/viewer2d/rulerX.js +2 -1
  263. package/lib/components/viewer2d/rulerY.js +2 -1
  264. package/lib/components/viewer2d/scene.js +2 -1
  265. package/lib/components/viewer2d/snap.js +2 -1
  266. package/lib/components/viewer2d/state.js +2 -1
  267. package/lib/components/viewer2d/vertex.js +2 -1
  268. package/lib/components/viewer2d/viewer2d.js +2 -1
  269. package/lib/components/viewer3d/dcm.js +2 -1
  270. package/lib/components/viewer3d/fbm.js +2 -1
  271. package/lib/components/viewer3d/front3D.js +2 -1
  272. package/lib/components/viewer3d/grid-creator.js +2 -1
  273. package/lib/components/viewer3d/grids/grid-horizontal-streak.js +2 -1
  274. package/lib/components/viewer3d/grids/grid-streak.js +2 -1
  275. package/lib/components/viewer3d/grids/grid-vertical-streak.js +2 -1
  276. package/lib/components/viewer3d/libs/mtl-loader.js +2 -1
  277. package/lib/components/viewer3d/libs/obj-loader.js +2 -1
  278. package/lib/components/viewer3d/lrm.js +2 -1
  279. package/lib/components/viewer3d/ruler-utils/itemRect.js +2 -1
  280. package/lib/components/viewer3d/ruler-utils/layer3D.js +2 -1
  281. package/lib/components/viewer3d/ruler-utils/ruler3D.js +2 -1
  282. package/lib/components/viewer3d/ruler-utils/state3D.js +2 -1
  283. package/lib/components/viewer3d/viewer3d-first-person.js +2 -1
  284. package/lib/components/viewer3d/viewer3d.js +2 -1
  285. package/lib/plugins/autosave.js +2 -1
  286. package/lib/plugins/console-debugger.js +2 -1
  287. package/lib/plugins/keyboard.js +2 -1
  288. package/lib/reducers/areas-reducer.js +2 -1
  289. package/lib/reducers/groups-reducer.js +2 -1
  290. package/lib/reducers/holes-reducer.js +2 -1
  291. package/lib/reducers/items-reducer.js +2 -1
  292. package/lib/reducers/lines-reducer.js +2 -1
  293. package/lib/reducers/project-reducer.js +2 -1
  294. package/lib/reducers/scene-reducer.js +2 -1
  295. package/lib/reducers/user-reducer.js +2 -1
  296. package/lib/reducers/vertices-reducer.js +2 -1
  297. package/lib/reducers/viewer2d-reducer.js +2 -1
  298. package/lib/reducers/viewer3d-reducer.js +2 -1
  299. package/lib/translator/en.js +2 -1
  300. package/lib/translator/it.js +2 -1
  301. package/lib/translator/ru.js +2 -1
  302. package/lib/translator/translator.js +2 -1
  303. package/lib/utils/name-generator.js +2 -1
  304. package/lib/utils/react-if.js +2 -1
  305. package/lib/utils/threeCSG.es6.js +2 -1
  306. package/package.json +2 -1
@@ -1,178 +1,81 @@
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.calcSnap = calcSnap;
18
- exports.calcSnap1 = calcSnap1;
19
- exports.calcSnap2 = calcSnap2;
20
- exports.calcSnap3 = calcSnap3;
21
- exports.clone_point = clone_point;
22
- exports.closestPointFromLine = closestPointFromLine;
23
- exports.closestPointFromLineSegment = closestPointFromLineSegment;
24
- exports.compareVertices = compareVertices;
25
- exports.containLine = containLine;
26
- exports.containPointInRect = containPointInRect;
27
- exports.cosWithThreshold = cosWithThreshold;
28
- exports.crossprod = crossprod;
29
- exports.diff = diff;
30
- exports.distancePointFromLine = distancePointFromLine;
31
- exports.distancePointFromLineSegment = distancePointFromLineSegment;
32
- exports.dotprod = dotprod;
33
- exports.downcrossLine = downcrossLine;
34
- exports.extendLine = extendLine;
35
- exports.findCatalogElement = findCatalogElement;
36
- exports.getAllArea = getAllArea;
37
- exports.getAllAreaLines = getAllAreaLines;
38
- exports.getAllCurSnap = getAllCurSnap;
39
- exports.getAllHoleRect = getAllHoleRect;
40
- exports.getAllItemSnap = getAllItemSnap;
41
- exports.getAllItemSpecified = getAllItemSpecified;
42
- exports.getAllItems = getAllItems;
43
- exports.getAllLineSnap = getAllLineSnap;
44
- exports.getAllLines = getAllLines;
45
- exports.getCalcRectFromItem = getCalcRectFromItem;
46
- exports.getCalcRectFromItem3D = getCalcRectFromItem3D;
47
- exports.getCalcRectFromLine = getCalcRectFromLine;
48
- exports.getCentroidOfPolygon = getCentroidOfPolygon;
49
- exports.getHoleItems = getHoleItems;
50
- exports.getInterSect = getInterSect;
51
- exports.getLineInterSect = getLineInterSect;
52
- exports.getNormaline = getNormaline;
53
- exports.getRelatedLines = void 0;
54
- exports.getRelatedVertices = getRelatedVertices;
55
- exports.horizontalLine = horizontalLine;
56
- exports.intersectRect = intersectRect;
57
- exports.isBackWall = isBackWall;
58
- exports.isFrontWall = isFrontWall;
59
- exports.isLeftWall = isLeftWall;
60
- exports.isPointInArea = isPointInArea;
61
- exports.isPointInRect = isPointInRect;
62
- exports.isPointOnLineSegment = isPointOnLineSegment;
63
- exports.isRightWall = isRightWall;
64
- exports.isSnappedLine = isSnappedLine;
65
- exports.isSnappedSideLine = isSnappedSideLine;
66
- exports.itemInfo = itemInfo;
67
- exports.linePassingThroughTwoPoints = linePassingThroughTwoPoints;
68
- exports.mapRange = mapRange;
69
- exports.maxVertex = maxVertex;
70
- exports.midPoint = midPoint;
71
- exports.minVertex = minVertex;
72
- exports.needSnap = needSnap;
73
- exports.orderVertices = orderVertices;
74
- exports.pointPositionOnLineSegment = pointPositionOnLineSegment;
75
- exports.pointsDistance = pointsDistance;
76
- exports.relationshipOfTwoOverlappedLines = relationshipOfTwoOverlappedLines;
77
- exports.relationshipOfTwoOverlappedLines1 = relationshipOfTwoOverlappedLines1;
78
- exports.relationshipOfTwoOverlappedLines2 = relationshipOfTwoOverlappedLines2;
79
- exports.rotatePointAroundPoint = rotatePointAroundPoint;
80
- exports.roundVertex = roundVertex;
81
- exports.sameDistances = sameDistances;
82
- exports.sameMDistances = sameMDistances;
83
- exports.sameMPoints = sameMPoints;
84
- exports.samePoints = samePoints;
85
- exports.shrinkRect = shrinkRect;
86
- exports.sinWithThreshold = sinWithThreshold;
87
- exports.snapAngleByUnit = snapAngleByUnit;
88
- exports.twoLineSegmentsIntersection = twoLineSegmentsIntersection;
89
- exports.twoLinesIntersection = twoLinesIntersection;
90
- exports.upcrossLine = upcrossLine;
91
- exports.validInterSect = validInterSect;
92
- exports.validSnap = validSnap;
93
- exports.validateLineSnaps = validateLineSnaps;
94
- exports.validateSnaps = validateSnaps;
95
- exports.verticalLine = verticalLine;
96
- exports.verticesDistance = verticesDistance;
97
- exports.verticesMidPoint = verticesMidPoint;
98
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
99
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
100
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
101
- var _math = require("./math.js");
102
- var _constants = require("../constants");
103
- var _convertUnitsLite = require("./convert-units-lite");
104
- var Three = _interopRequireWildcard(require("three"));
105
- var _utils = require("../components/viewer2d/utils.js");
106
- var _helper = require("./helper.js");
107
- var _export = require("./export.js");
108
- 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); }
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
109
4
  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; }
110
- 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; }
5
+ 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) { _defineProperty(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; }
111
6
  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; } } }; }
112
7
  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; } }
113
- 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
8
+ 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; }
9
+ /** @description Determines the distance between two points
114
10
  * @param {number} x0 Vertex 0 x
115
11
  * @param {number} y0 Vertex 0 y
116
12
  * @param {number} x1 Vertex 1 x
117
13
  * @param {number} y1 Vertex 1 y
118
14
  * @return {number}
119
15
  */
120
- function compareVertices(v0, v1) {
16
+ import { fAbs, toFixedFloat } from "./math.js";
17
+ import { BASE_CABINET_LAYOUTPOS, EPSILON, LINE_THICKNESS, MEPSILON, OVERLAP_INCLUDED, OVERLAP_LINK, OVERLAP_NONE, OVERLAP_SAME, OVERLAP_SOME, UNIT_ANGLE, WALL_CABINET_LAYOUTPOS } from "../constants";
18
+ import { convert } from "./convert-units-lite";
19
+ import * as Three from 'three';
20
+ import { returnReplaceableDeepSearchType } from "../components/viewer2d/utils.js";
21
+ import { isEmpty } from "./helper.js";
22
+ import { MathUtils } from "./export.js";
23
+ export function compareVertices(v0, v1) {
121
24
  return v0.x === v1.x ? v0.y - v1.y : v0.x - v1.x;
122
25
  }
123
- function minVertex(v0, v1) {
26
+ export function minVertex(v0, v1) {
124
27
  return compareVertices(v0, v1) > 0 ? v1 : v0;
125
28
  }
126
- function maxVertex(v0, v1) {
29
+ export function maxVertex(v0, v1) {
127
30
  return compareVertices(v0, v1) > 0 ? v0 : v1;
128
31
  }
129
- function orderVertices(vertices) {
32
+ export function orderVertices(vertices) {
130
33
  return vertices.sort(compareVertices);
131
34
  }
132
- function pointsDistance(x0, y0, x1, y1) {
35
+ export function pointsDistance(x0, y0, x1, y1) {
133
36
  var diff_x = x0 - x1;
134
37
  var diff_y = y0 - y1;
135
38
  return Math.sqrt(diff_x * diff_x + diff_y * diff_y);
136
39
  }
137
- function verticesDistance(v1, v2) {
40
+ export function verticesDistance(v1, v2) {
138
41
  var x0 = v1.x,
139
42
  y0 = v1.y;
140
43
  var x1 = v2.x,
141
44
  y1 = v2.y;
142
45
  return pointsDistance(x0, y0, x1, y1);
143
46
  }
144
- function horizontalLine(y) {
47
+ export function horizontalLine(y) {
145
48
  return {
146
49
  a: 0,
147
50
  b: 1,
148
51
  c: -y
149
52
  };
150
53
  }
151
- var almostEqual = exports.almostEqual = function almostEqual(x, y) {
152
- return Math.abs(x - y) < _constants.EPSILON;
54
+ export var almostEqual = function almostEqual(x, y) {
55
+ return Math.abs(x - y) < EPSILON;
153
56
  };
154
- function verticalLine(x) {
57
+ export function verticalLine(x) {
155
58
  return {
156
59
  a: 1,
157
60
  b: 0,
158
61
  c: -x
159
62
  };
160
63
  }
161
- function upcrossLine(x, y) {
64
+ export function upcrossLine(x, y) {
162
65
  return {
163
66
  a: 1,
164
67
  b: 1,
165
68
  c: -x - y
166
69
  };
167
70
  }
168
- function downcrossLine(x, y) {
71
+ export function downcrossLine(x, y) {
169
72
  return {
170
73
  a: 1,
171
74
  b: -1,
172
75
  c: -x + y
173
76
  };
174
77
  }
175
- function linePassingThroughTwoPoints(x1, y1, x2, y2) {
78
+ export function linePassingThroughTwoPoints(x1, y1, x2, y2) {
176
79
  if (x1 === x2 && y1 == y2) throw new Error('Geometry error');
177
80
  //if (x1 === x2) return verticalLine(x1);
178
81
  //if (y1 === y2) return horizontalLine(y1);
@@ -183,18 +86,18 @@ function linePassingThroughTwoPoints(x1, y1, x2, y2) {
183
86
  c: y2 * x1 - x2 * y1
184
87
  };
185
88
  }
186
- function getNormaline(x1, y1, x2, y2) {
89
+ export function getNormaline(x1, y1, x2, y2) {
187
90
  var lineFunction = linePassingThroughTwoPoints(x1, y1, x2, y2);
188
91
  return {
189
92
  x: lineFunction.a / Math.sqrt(lineFunction.a * lineFunction.a + lineFunction.b * lineFunction.b),
190
93
  y: lineFunction.b / Math.sqrt(lineFunction.a * lineFunction.a + lineFunction.b * lineFunction.b)
191
94
  };
192
95
  }
193
- function distancePointFromLine(a, b, c, x, y) {
96
+ export function distancePointFromLine(a, b, c, x, y) {
194
97
  //https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
195
- return (0, _math.fAbs)(a * x + b * y + c) / Math.sqrt(a * a + b * b);
98
+ return fAbs(a * x + b * y + c) / Math.sqrt(a * a + b * b);
196
99
  }
197
- function closestPointFromLine(a, b, c, x, y) {
100
+ export function closestPointFromLine(a, b, c, x, y) {
198
101
  //https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
199
102
  var denom = a * a + b * b;
200
103
  return {
@@ -212,7 +115,7 @@ function closestPointFromLine(a, b, c, x, y) {
212
115
  * @param {number} l costant of second line
213
116
  * @return {object} {x,y} point's coordinates
214
117
  */
215
- function twoLinesIntersection(a, b, c, j, k, l) {
118
+ export function twoLinesIntersection(a, b, c, j, k, l) {
216
119
  var angularCoefficientsDiff = b * j - a * k;
217
120
  if (angularCoefficientsDiff === 0) return undefined; //no intersection
218
121
 
@@ -223,10 +126,10 @@ function twoLinesIntersection(a, b, c, j, k, l) {
223
126
  y: y
224
127
  };
225
128
  }
226
- function twoLineSegmentsIntersection(p1, p2, p3, p4) {
129
+ export function twoLineSegmentsIntersection(p1, p2, p3, p4) {
227
130
  return _twoLineSegmentsIntersection(p1, p2, p3.toJS(), p4.toJS());
228
131
  }
229
- function _twoLineSegmentsIntersection(p1, p2, p3, p4) {
132
+ export function _twoLineSegmentsIntersection(p1, p2, p3, p4) {
230
133
  //https://github.com/psalaets/line-intersect/blob/master/lib/check-intersection.js
231
134
 
232
135
  var x1 = p1.x,
@@ -240,8 +143,8 @@ function _twoLineSegmentsIntersection(p1, p2, p3, p4) {
240
143
  var denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
241
144
  var numA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);
242
145
  var numB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3);
243
- if ((0, _math.fAbs)(denom) <= _constants.EPSILON) {
244
- if ((0, _math.fAbs)(numA) <= _constants.EPSILON && (0, _math.fAbs)(numB) <= _constants.EPSILON) {
146
+ if (fAbs(denom) <= EPSILON) {
147
+ if (fAbs(numA) <= EPSILON && fAbs(numB) <= EPSILON) {
245
148
  var comparator = function comparator(pa, pb) {
246
149
  return pa.x === pb.x ? pa.y - pb.y : pa.x - pb.x;
247
150
  };
@@ -250,7 +153,7 @@ function _twoLineSegmentsIntersection(p1, p2, p3, p4) {
250
153
  var _sort = [line0, line1].sort(function (lineA, lineB) {
251
154
  return comparator(lineA[0], lineB[0]);
252
155
  }),
253
- _sort2 = (0, _slicedToArray2["default"])(_sort, 2),
156
+ _sort2 = _slicedToArray(_sort, 2),
254
157
  lineSX = _sort2[0],
255
158
  lineDX = _sort2[1];
256
159
  comparator(lineSX[1], lineDX[0]) < 0 ? 'colinear' : 'none';
@@ -270,7 +173,7 @@ function _twoLineSegmentsIntersection(p1, p2, p3, p4) {
270
173
  }
271
174
  var uA = numA / denom;
272
175
  var uB = numB / denom;
273
- if (uA >= 0 - _constants.EPSILON && uA <= 1 + _constants.EPSILON && uB >= 0 - _constants.EPSILON && uB <= 1 + _constants.EPSILON) {
176
+ if (uA >= 0 - EPSILON && uA <= 1 + EPSILON && uB >= 0 - EPSILON && uB <= 1 + EPSILON) {
274
177
  var _point = {
275
178
  x: x1 + uA * (x2 - x1),
276
179
  y: y1 + uA * (y2 - y1)
@@ -284,7 +187,7 @@ function _twoLineSegmentsIntersection(p1, p2, p3, p4) {
284
187
  type: 'none'
285
188
  };
286
189
  }
287
- function distancePointFromLineSegment(v1, v2, xp, yp) {
190
+ export function distancePointFromLineSegment(v1, v2, xp, yp) {
288
191
  //http://stackoverflow.com/a/6853926/1398836
289
192
  var x1 = v1.x,
290
193
  y1 = v1.y;
@@ -327,8 +230,8 @@ function distancePointFromLineSegment(v1, v2, xp, yp) {
327
230
  * @param maxDistance {number} the epsilon value used for comparisons
328
231
  * @returns {boolean} true if the point lies on the line segment false otherwise
329
232
  */
330
- function isPointOnLineSegment(x1, y1, x2, y2, xp, yp) {
331
- var maxDistance = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : _constants.EPSILON;
233
+ export function isPointOnLineSegment(x1, y1, x2, y2, xp, yp) {
234
+ var maxDistance = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : EPSILON;
332
235
  return distancePointFromLineSegment({
333
236
  x: x1,
334
237
  y: y1
@@ -337,7 +240,7 @@ function isPointOnLineSegment(x1, y1, x2, y2, xp, yp) {
337
240
  y: y2
338
241
  }, xp, yp) <= maxDistance;
339
242
  }
340
- function closestPointFromLineSegment(x1, y1, x2, y2, xp, yp) {
243
+ export function closestPointFromLineSegment(x1, y1, x2, y2, xp, yp) {
341
244
  if (x1 === x2) return {
342
245
  x: x1,
343
246
  y: yp
@@ -357,7 +260,7 @@ function closestPointFromLineSegment(x1, y1, x2, y2, xp, yp) {
357
260
  y: y
358
261
  };
359
262
  }
360
- function pointPositionOnLineSegment(x1, y1, x2, y2, xp, yp) {
263
+ export function pointPositionOnLineSegment(x1, y1, x2, y2, xp, yp) {
361
264
  var length = pointsDistance(x1, y1, x2, y2);
362
265
  var distance = pointsDistance(x1, y1, xp, yp);
363
266
  var offset = distance / length;
@@ -367,16 +270,16 @@ function pointPositionOnLineSegment(x1, y1, x2, y2, xp, yp) {
367
270
  */
368
271
  return offset;
369
272
  }
370
- function mapRange(value, low1, high1, low2, high2) {
273
+ export function mapRange(value, low1, high1, low2, high2) {
371
274
  return low2 + (high2 - low2) * (value - low1) / (high1 - low1);
372
275
  }
373
- function angleBetweenTwoPointsAndOrigin(x1, y1, x2, y2) {
276
+ export function angleBetweenTwoPointsAndOrigin(x1, y1, x2, y2) {
374
277
  return -Math.atan2(y1 - y2, x2 - x1) * 180 / Math.PI;
375
278
  }
376
- function angleBetweenTwoPoints(x1, y1, x2, y2) {
279
+ export function angleBetweenTwoPoints(x1, y1, x2, y2) {
377
280
  return Math.atan2(y2 - y1, x2 - x1);
378
281
  }
379
- function angleBetweenTwoLines(line, drawingLine, vertices) {
282
+ export function angleBetweenTwoLines(line, drawingLine, vertices) {
380
283
  var points = [];
381
284
 
382
285
  // safety guards
@@ -434,7 +337,7 @@ function angleBetweenTwoLines(line, drawingLine, vertices) {
434
337
  var v = vertices === null || vertices === void 0 ? void 0 : vertices[idx];
435
338
  return v ? new Three.Vector2(v.x, v.y) : new Three.Vector2(0, 0);
436
339
  }),
437
- _points$slice$map2 = (0, _slicedToArray2["default"])(_points$slice$map, 3),
340
+ _points$slice$map2 = _slicedToArray(_points$slice$map, 3),
438
341
  c = _points$slice$map2[0],
439
342
  p1 = _points$slice$map2[1],
440
343
  p2 = _points$slice$map2[2];
@@ -442,7 +345,7 @@ function angleBetweenTwoLines(line, drawingLine, vertices) {
442
345
  var vec2 = p2.clone().sub(c).normalize();
443
346
  return Math.floor(vec1.angle() * 180 / Math.PI - vec2.angle() * 180 / Math.PI + 0.5);
444
347
  }
445
- var getRelatedLines = exports.getRelatedLines = function getRelatedLines(tlines, drawingLine, vertices, lines) {
348
+ export var getRelatedLines = function getRelatedLines(tlines, drawingLine, vertices, lines) {
446
349
  var exceptLineId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
447
350
  if (!(drawingLine !== null && drawingLine !== void 0 && drawingLine.vertices) || !Array.isArray(drawingLine.vertices)) return;
448
351
  var seen = new Set();
@@ -458,7 +361,7 @@ var getRelatedLines = exports.getRelatedLines = function getRelatedLines(tlines,
458
361
  try {
459
362
  for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
460
363
  var lineId = _step5.value;
461
- if (lineId !== drawingLine.id && lineId !== exceptLineId && !(0, _helper.isEmpty)(lines === null || lines === void 0 ? void 0 : lines[lineId]) && !seen.has(lineId)) {
364
+ if (lineId !== drawingLine.id && lineId !== exceptLineId && !isEmpty(lines === null || lines === void 0 ? void 0 : lines[lineId]) && !seen.has(lineId)) {
462
365
  seen.add(lineId);
463
366
  tlines.push(lines[lineId]);
464
367
  }
@@ -475,12 +378,12 @@ var getRelatedLines = exports.getRelatedLines = function getRelatedLines(tlines,
475
378
  _iterator4.f();
476
379
  }
477
380
  };
478
- function snapAngleByUnit(lineAngle, vertices, drawingLine, x, y, dragVertexId) {
381
+ export function snapAngleByUnit(lineAngle, vertices, drawingLine, x, y, dragVertexId) {
479
382
  var tx, ty;
480
383
  var absAngle = Math.abs(lineAngle);
481
384
  // angle snapping as a value of UNIT_ANGLE
482
- var rest = absAngle % _constants.UNIT_ANGLE;
483
- var missAngle = _constants.UNIT_ANGLE - rest;
385
+ var rest = absAngle % UNIT_ANGLE;
386
+ var missAngle = UNIT_ANGLE - rest;
484
387
  // the origin point of rotation(snapping)
485
388
  var originVerId = drawingLine.vertices.findIndex(function (vertice) {
486
389
  return vertice !== dragVertexId;
@@ -489,7 +392,7 @@ function snapAngleByUnit(lineAngle, vertices, drawingLine, x, y, dragVertexId) {
489
392
  var ox = vertices[originVerId].x;
490
393
  var oy = vertices[originVerId].y;
491
394
  // check whether the line is snapped to before point.
492
- if (rest <= _constants.UNIT_ANGLE / 2) {
395
+ if (rest <= UNIT_ANGLE / 2) {
493
396
  // determine the direction of rotation.
494
397
  rest = lineAngle > 0 ? rest : -rest;
495
398
  // rotate the current point to last point around the first point of drawing line.
@@ -497,7 +400,7 @@ function snapAngleByUnit(lineAngle, vertices, drawingLine, x, y, dragVertexId) {
497
400
  ty = rotatePointAroundPoint(x, y, ox, oy, rest).y;
498
401
  }
499
402
  // check whether the line is snapped to next new point.
500
- else if (rest > _constants.UNIT_ANGLE / 2) {
403
+ else if (rest > UNIT_ANGLE / 2) {
501
404
  // determine the direction of rotation.
502
405
  missAngle = lineAngle > 0 ? -missAngle : missAngle;
503
406
  // rotate the current point to last point around the first point of drawing line.
@@ -510,30 +413,30 @@ function snapAngleByUnit(lineAngle, vertices, drawingLine, x, y, dragVertexId) {
510
413
  };
511
414
  return resPoint;
512
415
  }
513
- function absAngleBetweenTwoPoints(x1, y1, x2, y2) {
416
+ export function absAngleBetweenTwoPoints(x1, y1, x2, y2) {
514
417
  return Math.atan2(y2 - y1, Math.abs(x2 - x1));
515
418
  }
516
- function samePoints(_ref, _ref2) {
419
+ export function samePoints(_ref, _ref2) {
517
420
  var x1 = _ref.x,
518
421
  y1 = _ref.y;
519
422
  var x2 = _ref2.x,
520
423
  y2 = _ref2.y;
521
- return (0, _math.fAbs)(x1 - x2) <= _constants.EPSILON && (0, _math.fAbs)(y1 - y2) <= _constants.EPSILON;
424
+ return fAbs(x1 - x2) <= EPSILON && fAbs(y1 - y2) <= EPSILON;
522
425
  }
523
- function sameDistances(dis1, dis2) {
524
- return (0, _math.fAbs)(dis1 - dis2) <= _constants.EPSILON;
426
+ export function sameDistances(dis1, dis2) {
427
+ return fAbs(dis1 - dis2) <= EPSILON;
525
428
  }
526
- function sameMPoints(_ref3, _ref4) {
429
+ export function sameMPoints(_ref3, _ref4) {
527
430
  var x1 = _ref3.x,
528
431
  y1 = _ref3.y;
529
432
  var x2 = _ref4.x,
530
433
  y2 = _ref4.y;
531
- return (0, _math.fAbs)(x1 - x2) <= _constants.MEPSILON && (0, _math.fAbs)(y1 - y2) <= _constants.MEPSILON;
434
+ return fAbs(x1 - x2) <= MEPSILON && fAbs(y1 - y2) <= MEPSILON;
532
435
  }
533
- function sameMDistances(dis1, dis2) {
534
- return (0, _math.fAbs)(dis1 - dis2) <= _constants.MEPSILON;
436
+ export function sameMDistances(dis1, dis2) {
437
+ return fAbs(dis1 - dis2) <= MEPSILON;
535
438
  }
536
- function isPointInRect(rect, point) {
439
+ export function isPointInRect(rect, point) {
537
440
  var result = true;
538
441
  for (var i = 0; i < rect.length; i++) {
539
442
  var pos1 = rect[i];
@@ -553,23 +456,23 @@ function isPointInRect(rect, point) {
553
456
  * @param {number} newDistance New line length
554
457
  * @return {object}
555
458
  */
556
- function extendLine(x1, y1, x2, y2, newDistance) {
459
+ export function extendLine(x1, y1, x2, y2, newDistance) {
557
460
  var precision = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 6;
558
461
  var rad = angleBetweenTwoPoints(x1, y1, x2, y2);
559
462
  return {
560
- x: (0, _math.toFixedFloat)(x1 + Math.cos(rad) * newDistance, precision),
561
- y: (0, _math.toFixedFloat)(y1 + Math.sin(rad) * newDistance, precision)
463
+ x: toFixedFloat(x1 + Math.cos(rad) * newDistance, precision),
464
+ y: toFixedFloat(y1 + Math.sin(rad) * newDistance, precision)
562
465
  };
563
466
  }
564
- function roundVertex(vertex) {
467
+ export function roundVertex(vertex) {
565
468
  var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
566
- vertex.set('x', (0, _math.toFixedFloat)(vertex.get('x'), precision));
567
- vertex.set('y', (0, _math.toFixedFloat)(vertex.get('y'), precision));
469
+ vertex.set('x', toFixedFloat(vertex.get('x'), precision));
470
+ vertex.set('y', toFixedFloat(vertex.get('y'), precision));
568
471
  return vertex;
569
472
  }
570
473
 
571
474
  //https://github.com/MartyWallace/PolyK
572
- function ContainsPoint(polygon, pointX, pointY) {
475
+ export function ContainsPoint(polygon, pointX, pointY) {
573
476
  var n = polygon.length >> 1;
574
477
  var ax, lup;
575
478
  var ay = polygon[2 * n - 3] - pointY;
@@ -608,21 +511,21 @@ function ContainsPoint(polygon, pointX, pointY) {
608
511
  }
609
512
  return (depth & 1) === 1;
610
513
  }
611
- function cosWithThreshold(alpha, threshold) {
514
+ export function cosWithThreshold(alpha, threshold) {
612
515
  var cos = Math.cos(alpha);
613
516
  return cos < threshold ? 0 : cos;
614
517
  }
615
- function sinWithThreshold(alpha, threshold) {
518
+ export function sinWithThreshold(alpha, threshold) {
616
519
  var sin = Math.sin(alpha);
617
520
  return sin < threshold ? 0 : sin;
618
521
  }
619
- function midPoint(x1, y1, x2, y2) {
522
+ export function midPoint(x1, y1, x2, y2) {
620
523
  return {
621
524
  x: (x1 + x2) / 2,
622
525
  y: (y1 + y2) / 2
623
526
  };
624
527
  }
625
- function verticesMidPoint(verticesArray) {
528
+ export function verticesMidPoint(verticesArray) {
626
529
  var res = verticesArray.reduce(function (incr, vertex) {
627
530
  return {
628
531
  x: incr.x + vertex.x,
@@ -637,7 +540,7 @@ function verticesMidPoint(verticesArray) {
637
540
  y: res.y / verticesArray.length
638
541
  };
639
542
  }
640
- function rotatePointAroundPoint(px, py, ox, oy, theta) {
543
+ export function rotatePointAroundPoint(px, py, ox, oy, theta) {
641
544
  var thetaRad = theta * Math.PI / 180;
642
545
  var cos = Math.cos(thetaRad);
643
546
  var sin = Math.sin(thetaRad);
@@ -671,7 +574,7 @@ function itemrectInfo(x, y, rotRad, size, layoutpos, is_corner) {
671
574
  is_corner: is_corner
672
575
  };
673
576
  }
674
- function getCalcRectFromItem(item) {
577
+ export function getCalcRectFromItem(item) {
675
578
  var itemInfo;
676
579
  if (item === undefined) itemInfo = [];else itemInfo = item.item;
677
580
  var x = item.pos.x;
@@ -699,7 +602,7 @@ function getCalcRectFromItem(item) {
699
602
  itemInfo: itemInfo
700
603
  };
701
604
  }
702
- function getCalcRectFromItem3D(item) {
605
+ export function getCalcRectFromItem3D(item) {
703
606
  var itemInfo;
704
607
  if (item === undefined) itemInfo = [];else itemInfo = item.item;
705
608
  var x = item.pos.x;
@@ -727,7 +630,7 @@ function getCalcRectFromItem3D(item) {
727
630
  itemInfo: itemInfo
728
631
  };
729
632
  }
730
- function getAllItems(scene, catalog, allLineRects) {
633
+ export function getAllItems(scene, catalog, allLineRects) {
731
634
  var layerID = scene.selectedLayer;
732
635
  var layer = scene.layers.get(layerID);
733
636
  var curiteminfo;
@@ -739,7 +642,7 @@ function getAllItems(scene, catalog, allLineRects) {
739
642
  selectedItem = layer.getIn(['items', layer.selected.items.get(0)]);
740
643
  var catid = selectedItem.type;
741
644
  var cat = catalog.elements[catid];
742
- if (!cat) cat = catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(catid)];
645
+ if (!cat) cat = catalog.elements[returnReplaceableDeepSearchType(catid)];
743
646
  currentItem = {
744
647
  selectedItem: selectedItem,
745
648
  cat: cat
@@ -756,7 +659,7 @@ function getAllItems(scene, catalog, allLineRects) {
756
659
  var catid = item.type;
757
660
  var cat = catalog.elements[catid];
758
661
  if (!cat) {
759
- cat = catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(catid)];
662
+ cat = catalog.elements[returnReplaceableDeepSearchType(catid)];
760
663
  }
761
664
  var sizeinfo = [];
762
665
  var width, height, depth;
@@ -772,9 +675,9 @@ function getAllItems(scene, catalog, allLineRects) {
772
675
  layoutpos: cat && cat.info.layoutpos,
773
676
  is_corner: cat && cat.info.is_corner
774
677
  });
775
- width = (0, _convertUnitsLite.convert)(sizeinfo.width).from(sizeinfo.widthUnit).to(scene.unit);
776
- height = (0, _convertUnitsLite.convert)(sizeinfo.depth).from(sizeinfo.depthUnit).to(scene.unit);
777
- depth = (0, _convertUnitsLite.convert)(sizeinfo.height).from(sizeinfo.heightUnit).to(scene.unit);
678
+ width = convert(sizeinfo.width).from(sizeinfo.widthUnit).to(scene.unit);
679
+ height = convert(sizeinfo.depth).from(sizeinfo.depthUnit).to(scene.unit);
680
+ depth = convert(sizeinfo.height).from(sizeinfo.heightUnit).to(scene.unit);
778
681
  val.size = {
779
682
  width: width,
780
683
  height: height,
@@ -807,7 +710,7 @@ function getAllItems(scene, catalog, allLineRects) {
807
710
  otherItems: otherItems
808
711
  };
809
712
  }
810
- function getAllItemSpecified(scene, catalog, filter) {
713
+ export function getAllItemSpecified(scene, catalog, filter) {
811
714
  var _scene$layers, _scene$layers$get;
812
715
  var layerID = scene === null || scene === void 0 ? void 0 : scene.selectedLayer;
813
716
  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);
@@ -833,7 +736,7 @@ function getAllItemSpecified(scene, catalog, filter) {
833
736
  var getSize = function getSize(key) {
834
737
  var _props$getIn;
835
738
  var length = props === null || props === void 0 || (_props$getIn = props.getIn) === null || _props$getIn === void 0 ? void 0 : _props$getIn.call(props, [key, '_length']);
836
- return length != null ? (0, _convertUnitsLite.convert)(length).from('in').to(scene.unit) : 0;
739
+ return length != null ? convert(length).from('in').to(scene.unit) : 0;
837
740
  };
838
741
  val.size = {
839
742
  width: getSize('width'),
@@ -866,13 +769,13 @@ function getAllItemSpecified(scene, catalog, filter) {
866
769
  others: iteminfo
867
770
  };
868
771
  }
869
- function findCatalogElement(catalog, elementName) {
772
+ export function findCatalogElement(catalog, elementName) {
870
773
  if (!elementName || !catalog) return null;
871
774
  var variants = [elementName, elementName.toLowerCase()];
872
775
  var deepVariants = variants.map(function (v) {
873
- return (0, _utils.returnReplaceableDeepSearchType)(v);
776
+ return returnReplaceableDeepSearchType(v);
874
777
  }).filter(Boolean);
875
- var allCandidates = [].concat(variants, (0, _toConsumableArray2["default"])(deepVariants));
778
+ var allCandidates = [].concat(variants, _toConsumableArray(deepVariants));
876
779
  var getElement = function getElement(catid) {
877
780
  if (!catid) return null;
878
781
 
@@ -902,7 +805,7 @@ function findCatalogElement(catalog, elementName) {
902
805
  }
903
806
  return null;
904
807
  }
905
- function isSnappedLine(calcrect, allLineRects) {
808
+ export function isSnappedLine(calcrect, allLineRects) {
906
809
  if (allLineRects === undefined) return false;
907
810
  var r2 = calcrect.rect[2];
908
811
  var r3 = calcrect.rect[3];
@@ -910,18 +813,18 @@ function isSnappedLine(calcrect, allLineRects) {
910
813
  var l2 = linerect.rect[2];
911
814
  var l3 = linerect.rect[3];
912
815
  var delta = verticesDistance(l2, r3) + verticesDistance(r3, r2) + verticesDistance(r2, l3) - verticesDistance(l3, l2);
913
- if (delta < _constants.EPSILON) {
816
+ if (delta < EPSILON) {
914
817
  return true;
915
818
  } else {
916
819
  l2 = linerect.rect[3];
917
820
  l3 = linerect.rect[2];
918
821
  delta = verticesDistance(l2, r3) + verticesDistance(r3, r2) + verticesDistance(r2, l3) - verticesDistance(l3, l2);
919
- return delta < _constants.EPSILON;
822
+ return delta < EPSILON;
920
823
  }
921
824
  });
922
825
  return result;
923
826
  }
924
- function isSnappedSideLine(calcrect, allLineRects) {
827
+ export function isSnappedSideLine(calcrect, allLineRects) {
925
828
  if (allLineRects === undefined) return 0;
926
829
  var r2 = calcrect.rect[1];
927
830
  var r3 = calcrect.rect[2];
@@ -929,13 +832,13 @@ function isSnappedSideLine(calcrect, allLineRects) {
929
832
  var l2 = linerect.rect[2];
930
833
  var l3 = linerect.rect[3];
931
834
  var delta = verticesDistance(l2, r3) + verticesDistance(r3, r2) + verticesDistance(r2, l3) - verticesDistance(l3, l2);
932
- return delta < _constants.EPSILON;
835
+ return delta < EPSILON;
933
836
  });
934
837
  return result;
935
838
  }
936
839
 
937
840
  /** Calculate candidate positions */
938
- function getAllItemSnap(allItemRects) {
841
+ export function getAllItemSnap(allItemRects) {
939
842
  var allItemSnap = [];
940
843
  var cur = allItemRects.cur;
941
844
 
@@ -1001,7 +904,7 @@ function getAllItemSnap(allItemRects) {
1001
904
  });
1002
905
  return allItemSnap;
1003
906
  }
1004
- function getAllArea(layer) {
907
+ export function getAllArea(layer) {
1005
908
  var allAreaLines = [];
1006
909
  var allLines = [];
1007
910
  var verticesArray = [];
@@ -1028,11 +931,11 @@ function getAllArea(layer) {
1028
931
  }
1029
932
 
1030
933
  /** Get all lines of the scene */
1031
- function getAllLines(layer) {
934
+ export function getAllLines(layer) {
1032
935
  var allAreaLines = getAllAreaLines(layer);
1033
936
  var allLines = [];
1034
937
  //let allNonAreaLines = [];
1035
- var thick = _constants.LINE_THICKNESS / 2;
938
+ var thick = LINE_THICKNESS / 2;
1036
939
  layer.lines.forEach(function (line) {
1037
940
  var i = containLine(allAreaLines, line);
1038
941
  // let thick = line.properties.getIn(['thickness', 'length']);
@@ -1086,7 +989,7 @@ function getAllLines(layer) {
1086
989
  }
1087
990
 
1088
991
  /** Get lines that wraps the area */
1089
- function getAllAreaLines(layer) {
992
+ export function getAllAreaLines(layer) {
1090
993
  var areainfo = [];
1091
994
  layer.areas.forEach(function (area) {
1092
995
  var sz = area.vertices.size;
@@ -1096,7 +999,7 @@ function getAllAreaLines(layer) {
1096
999
  });
1097
1000
  return areainfo;
1098
1001
  }
1099
- function containLine(lines, line) {
1002
+ export function containLine(lines, line) {
1100
1003
  // lines: [array]
1101
1004
  var sz = lines.length;
1102
1005
  for (var i = 0; i < sz; i++) {
@@ -1107,7 +1010,7 @@ function containLine(lines, line) {
1107
1010
  }
1108
1011
  return -1;
1109
1012
  }
1110
- function buildRectFromLines(layer, lines) {
1013
+ export function buildRectFromLines(layer, lines) {
1111
1014
  var rect = [];
1112
1015
  lines.forEach(function (line) {
1113
1016
  var vxys = []; // 0: x0, 1: y0, 2: x1, 3: y1
@@ -1125,7 +1028,7 @@ function buildRectFromLines(layer, lines) {
1125
1028
  });
1126
1029
  return rect;
1127
1030
  }
1128
- function getRelatedVertices(x0, y0, x1, y1, layer) {
1031
+ export function getRelatedVertices(x0, y0, x1, y1, layer) {
1129
1032
  var verticesArray = [];
1130
1033
  var mapVertIDtoIndex = {};
1131
1034
  layer.vertices.forEach(function (vertex) {
@@ -1145,7 +1048,7 @@ function getRelatedVertices(x0, y0, x1, y1, layer) {
1145
1048
  x: verticesArray[mapVertIDtoIndex[vertID1]][0],
1146
1049
  y: verticesArray[mapVertIDtoIndex[vertID1]][1]
1147
1050
  };
1148
- 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) {
1051
+ if (Math.abs(pt0.x - x0) < EPSILON && Math.abs(pt0.y - y0) < EPSILON && Math.abs(pt1.x - x1) < EPSILON && Math.abs(pt1.y - y1) < EPSILON || Math.abs(pt0.x - x1) < EPSILON && Math.abs(pt0.y - y1) < EPSILON && Math.abs(pt1.x - x0) < EPSILON && Math.abs(pt1.y - y0) < EPSILON) {
1149
1052
  if (line.relatedVertices.size == 2) {
1150
1053
  var relPt0 = point(x0, y0);
1151
1054
  var relPt1 = point(x1, y1);
@@ -1161,7 +1064,7 @@ function getRelatedVertices(x0, y0, x1, y1, layer) {
1161
1064
  });
1162
1065
  return relVerts;
1163
1066
  }
1164
- function getCalcRectFromLine(x0, y0, x1, y1, thick, layer) {
1067
+ export function getCalcRectFromLine(x0, y0, x1, y1, thick, layer) {
1165
1068
  // get line from vertex coordinate
1166
1069
  var relVerts = getRelatedVertices(x0, y0, x1, y1, layer);
1167
1070
  var dx = x1 - x0;
@@ -1207,7 +1110,7 @@ function getCalcRectFromLine(x0, y0, x1, y1, thick, layer) {
1207
1110
  }
1208
1111
  };
1209
1112
  }
1210
- function getAllLineSnap(allLineRects, curItemRect) {
1113
+ export function getAllLineSnap(allLineRects, curItemRect) {
1211
1114
  var allLineSnap = [];
1212
1115
  var cur = curItemRect;
1213
1116
  if (cur === undefined || cur === null) return;else allLineRects.forEach(function (rect) {
@@ -1231,7 +1134,7 @@ function getAllLineSnap(allLineRects, curItemRect) {
1231
1134
  });
1232
1135
  return allLineSnap;
1233
1136
  }
1234
- function validateSnaps(allSnaps, allRects) {
1137
+ export function validateSnaps(allSnaps, allRects) {
1235
1138
  var validSnaps = [];
1236
1139
  if (allSnaps !== undefined && allSnaps !== null && allSnaps.length > 0) allSnaps.forEach(function (snap) {
1237
1140
  if (validSnap(snap, allRects)) {
@@ -1240,7 +1143,7 @@ function validateSnaps(allSnaps, allRects) {
1240
1143
  });
1241
1144
  return validSnaps;
1242
1145
  }
1243
- function validateLineSnaps(allSnaps, allItemSnap, allLineSnap, allItemRects, allLineRects, allRects) {
1146
+ export function validateLineSnaps(allSnaps, allItemSnap, allLineSnap, allItemRects, allLineRects, allRects) {
1244
1147
  var validSnaps = [];
1245
1148
  allSnaps.forEach(function (snap) {
1246
1149
  if (validSnap(snap, allRects)) {
@@ -1256,13 +1159,13 @@ function validateLineSnaps(allSnaps, allItemSnap, allLineSnap, allItemRects, all
1256
1159
  });
1257
1160
  return validSnaps;
1258
1161
  }
1259
- function validSnap(snap, rects) {
1162
+ export function validSnap(snap, rects) {
1260
1163
  var snaprect = getCalcRectFromItem(snap);
1261
1164
  return rects.every(function (rect) {
1262
1165
  return !intersectRect(rect.rect, snaprect.rect);
1263
1166
  });
1264
1167
  }
1265
- function itemInfo(x, y, rotRad, size) {
1168
+ export function itemInfo(x, y, rotRad, size) {
1266
1169
  return {
1267
1170
  pos: {
1268
1171
  x: x,
@@ -1272,7 +1175,7 @@ function itemInfo(x, y, rotRad, size) {
1272
1175
  size: size
1273
1176
  };
1274
1177
  }
1275
- function intersectRect(rect1, rect2) {
1178
+ export function intersectRect(rect1, rect2) {
1276
1179
  var ret = false;
1277
1180
  rect1 = shrinkRect(rect1);
1278
1181
  rect2 = shrinkRect(rect2);
@@ -1285,7 +1188,7 @@ function intersectRect(rect1, rect2) {
1285
1188
  });
1286
1189
  return ret;
1287
1190
  }
1288
- function containPointInRect(point, rect) {
1191
+ export function containPointInRect(point, rect) {
1289
1192
  // true: contain, false: not contain
1290
1193
  for (var i = 0; i < rect.length; i++) {
1291
1194
  var ni = (i + 1) % rect.length;
@@ -1295,16 +1198,16 @@ function containPointInRect(point, rect) {
1295
1198
  }
1296
1199
  return true;
1297
1200
  }
1298
- function diff(v0, v1) {
1201
+ export function diff(v0, v1) {
1299
1202
  return {
1300
1203
  x: v0.x - v1.x,
1301
1204
  y: v0.y - v1.y
1302
1205
  };
1303
1206
  }
1304
- function crossprod(v0, v1) {
1207
+ export function crossprod(v0, v1) {
1305
1208
  return v0.x * v1.y - v0.y * v1.x;
1306
1209
  }
1307
- function shrinkRect(rect) {
1210
+ export function shrinkRect(rect) {
1308
1211
  var v02x = rect[2].x - rect[0].x;
1309
1212
  var v02y = rect[2].y - rect[0].y;
1310
1213
  var d02 = Math.sqrt(v02x * v02x + v02y * v02y);
@@ -1317,7 +1220,7 @@ function shrinkRect(rect) {
1317
1220
  var o13y = v13y / d13 * 0.1;
1318
1221
  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)];
1319
1222
  }
1320
- function getInterSect(shape1, shape2) {
1223
+ export function getInterSect(shape1, shape2) {
1321
1224
  // return result of intersect of two shape
1322
1225
  var count = 0;
1323
1226
  for (var i = 0; i < shape1.length; i++) {
@@ -1347,7 +1250,7 @@ function getInterSect(shape1, shape2) {
1347
1250
  }
1348
1251
  return false;
1349
1252
  }
1350
- function getLineInterSect(s1x, s1y, e1x, e1y, s2x, s2y, e2x, e2y) {
1253
+ export function getLineInterSect(s1x, s1y, e1x, e1y, s2x, s2y, e2x, e2y) {
1351
1254
  var ax = s1x;
1352
1255
  var ay = s1y;
1353
1256
  var bx = e1x - s1x;
@@ -1392,7 +1295,7 @@ function getLineInterSect(s1x, s1y, e1x, e1y, s2x, s2y, e2x, e2y) {
1392
1295
  return ret;
1393
1296
  }
1394
1297
  }
1395
- function isPointInArea(allArea, pt) {
1298
+ export function isPointInArea(allArea, pt) {
1396
1299
  var x = pt.x;
1397
1300
  var y = pt.y;
1398
1301
  var result = false;
@@ -1412,7 +1315,7 @@ function isPointInArea(allArea, pt) {
1412
1315
  x: x1 - x,
1413
1316
  y: y1 - y
1414
1317
  };
1415
- if (Math.abs(v0.x) < _constants.EPSILON && Math.abs(v0.y) < _constants.EPSILON)
1318
+ if (Math.abs(v0.x) < EPSILON && Math.abs(v0.y) < EPSILON)
1416
1319
  // check if pt is area point
1417
1320
  return true;
1418
1321
 
@@ -1425,18 +1328,18 @@ function isPointInArea(allArea, pt) {
1425
1328
  };
1426
1329
  var xE = x0 + vPt.x * lineLen;
1427
1330
  var yE = y0 + vPt.y * lineLen;
1428
- if (v0Len <= lineLen && Math.abs(xE - x1) < _constants.EPSILON && Math.abs(yE - y1) < _constants.EPSILON) return true;
1331
+ if (v0Len <= lineLen && Math.abs(xE - x1) < EPSILON && Math.abs(yE - y1) < EPSILON) return true;
1429
1332
  alpha = Math.atan2(v0.x * v1.y - v1.x * v0.y, v0.x * v1.x + v0.y * v1.y);
1430
1333
  sum += alpha;
1431
1334
  }
1432
- if (Math.abs(Math.abs(sum) - Math.PI * 2) < _constants.EPSILON) return true;
1335
+ if (Math.abs(Math.abs(sum) - Math.PI * 2) < EPSILON) return true;
1433
1336
  });
1434
1337
  return result;
1435
1338
  }
1436
- function calcSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allAreaLines) {
1339
+ export function calcSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allAreaLines) {
1437
1340
  return calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allAreaLines);
1438
1341
  }
1439
- function calcCreateSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, polygonPoint) {
1342
+ export function calcCreateSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, polygonPoint) {
1440
1343
  // Validate required input and guard against missing `.cur`
1441
1344
  if (!allItemRect || !allItemRect.cur) return;
1442
1345
  var cur = allItemRect.cur; // safe alias
@@ -1494,7 +1397,7 @@ function calcCreateSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, all
1494
1397
  }
1495
1398
 
1496
1399
  ////////////
1497
- function calcSnap1(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y) {
1400
+ export function calcSnap1(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y) {
1498
1401
  var cx = allItemRect.cur.pos.x;
1499
1402
  var cy = allItemRect.cur.pos.y;
1500
1403
  var nx = x;
@@ -1538,7 +1441,7 @@ function calcSnap1(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect,
1538
1441
  }
1539
1442
 
1540
1443
  ////////////
1541
- function calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allArea) {
1444
+ export function calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allArea) {
1542
1445
  var nx = x;
1543
1446
  var ny = y;
1544
1447
  var ndist = 20;
@@ -1682,7 +1585,7 @@ function calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect,
1682
1585
  return intersectRect(others.rect, curitem.rect);
1683
1586
  });
1684
1587
  intersects.forEach(function (rect) {
1685
- if (isPointInArea(allArea, rect.itemInfo) || !allArea.length) if (rect.itemInfo.layoutpos.includes(_constants.BASE_CABINET_LAYOUTPOS)) {
1588
+ if (isPointInArea(allArea, rect.itemInfo) || !allArea.length) if (rect.itemInfo.layoutpos.includes(BASE_CABINET_LAYOUTPOS)) {
1686
1589
  nx = rect.itemInfo.x;
1687
1590
  ny = rect.itemInfo.y;
1688
1591
  rotRad = rect.itemInfo.rotation * Math.PI / 180;
@@ -1709,7 +1612,7 @@ function calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect,
1709
1612
  //Check case.
1710
1613
  //If item is 'blind base cabinet', it must be pulled from other 3".
1711
1614
  if (allItemRect.cur && allItemRect.cur.itemInfo.sku_number.startsWith('BBC')) {
1712
- var offset3inch = (0, _convertUnitsLite.convert)(3).from('in').to('cm');
1615
+ var offset3inch = convert(3).from('in').to('cm');
1713
1616
  var tx = nx,
1714
1617
  ty = ny;
1715
1618
  if (allItemRect.cur && allItemRect.cur.itemInfo.sku_number.endsWith('-L')) {
@@ -1754,7 +1657,7 @@ function calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect,
1754
1657
  }
1755
1658
 
1756
1659
  ////////////
1757
- function calcSnap3(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y) {
1660
+ export function calcSnap3(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y) {
1758
1661
  // let layer = scene.layers.get(layerID);
1759
1662
  // let cx = allItemRect.cur.pos.x;
1760
1663
  // let cy = allItemRect.cur.pos.y;
@@ -1869,10 +1772,10 @@ function calcSnap3(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect,
1869
1772
  rotRad: rotRad
1870
1773
  };
1871
1774
  }
1872
- function getAllCurSnap(allLineRects, x, y, curItemRect) {
1775
+ export function getAllCurSnap(allLineRects, x, y, curItemRect) {
1873
1776
  if (!curItemRect) return;
1874
1777
  var allCurSnap = [];
1875
- var thick = _constants.LINE_THICKNESS / 2;
1778
+ var thick = LINE_THICKNESS / 2;
1876
1779
  allLineRects.forEach(function (linerect) {
1877
1780
  //allLineRects:left, right, top, bottom line
1878
1781
  var p0 = clone_point(linerect.rect[2]); //point 2(x, y) inside of line
@@ -1907,15 +1810,15 @@ function getAllCurSnap(allLineRects, x, y, curItemRect) {
1907
1810
  });
1908
1811
  return allCurSnap;
1909
1812
  }
1910
- function clone_point(pt) {
1813
+ export function clone_point(pt) {
1911
1814
  return point(pt.x, pt.y);
1912
1815
  }
1913
- function dotprod(v0, v1) {
1816
+ export function dotprod(v0, v1) {
1914
1817
  return v0.x * v1.x + v0.y * v1.y;
1915
1818
  }
1916
1819
 
1917
1820
  //////////
1918
- function validInterSect(rect, val) {
1821
+ export function validInterSect(rect, val) {
1919
1822
  var curitem = getCalcRectFromItem(val);
1920
1823
  var datas = [];
1921
1824
  rect.forEach(function (line) {
@@ -1945,7 +1848,7 @@ var lineRect = function lineRect(layer) {
1945
1848
  });
1946
1849
  return rect;
1947
1850
  };
1948
- function getAllHoleRect(scene, val) {
1851
+ export function getAllHoleRect(scene, val) {
1949
1852
  var layerID = scene.selectedLayer;
1950
1853
  var layer = scene.layers.get(layerID);
1951
1854
  var selectedItem = layer.getIn(['items', layer.selected.items.get(0)]);
@@ -1989,7 +1892,7 @@ function getAllHoleRect(scene, val) {
1989
1892
  y: vertice1.y
1990
1893
  };
1991
1894
  var rotation = Math.atan2(point1.y - point0.y, point1.x - point0.x);
1992
- var rectInfo = getCalcRectFromLine(point0.x, point0.y, point1.x, point1.y, _constants.LINE_THICKNESS, layer);
1895
+ var rectInfo = getCalcRectFromLine(point0.x, point0.y, point1.x, point1.y, LINE_THICKNESS, layer);
1993
1896
  var vN = point(rectInfo.rect[0].x - rectInfo.rect[3].x, rectInfo.rect[0].y - rectInfo.rect[3].y);
1994
1897
  var lenN = Math.sqrt(vN.x * vN.x + vN.y * vN.y);
1995
1898
  vN.x /= lenN;
@@ -2011,7 +1914,7 @@ function getAllHoleRect(scene, val) {
2011
1914
  };
2012
1915
  var hole_rect = getCalcRectFromItem(tval);
2013
1916
  if (intersectRect(itemRect.rect, hole_rect.rect)) {
2014
- if (tdepth > itemRect.size.depth && itemRect.layoutpos !== _constants.WALL_CABINET_LAYOUTPOS) {
1917
+ if (tdepth > itemRect.size.depth && itemRect.layoutpos !== WALL_CABINET_LAYOUTPOS) {
2015
1918
  var dist = itemRect.size.height / 2 + theight / 2;
2016
1919
  var snap = [];
2017
1920
  var p0 = {
@@ -2044,7 +1947,7 @@ function getAllHoleRect(scene, val) {
2044
1947
  snap: null
2045
1948
  };
2046
1949
  }
2047
- function getHoleItems(layer) {
1950
+ export function getHoleItems(layer) {
2048
1951
  var holeItems = [];
2049
1952
  layer.holes.map(function (hole) {
2050
1953
  var width = hole.properties.getIn(['width', 'length']);
@@ -2058,18 +1961,18 @@ function getHoleItems(layer) {
2058
1961
  });
2059
1962
  return holeItems;
2060
1963
  }
2061
- function needSnap(curItem, othItem) {
1964
+ export function needSnap(curItem, othItem) {
2062
1965
  var blSnap = false;
2063
1966
  if (curItem == undefined || curItem == null) return false;
2064
1967
  var altitude = curItem.selectedItem.properties.get('altitude');
2065
- var heightFromFloor = (0, _convertUnitsLite.convert)(altitude.get('_length')).from(altitude.get('_unit')).to('in');
1968
+ var heightFromFloor = convert(altitude.get('_length')).from(altitude.get('_unit')).to('in');
2066
1969
  var height = curItem.cat.info.sizeinfo.height;
2067
1970
  var currentItem = {
2068
1971
  heightFromFloor: heightFromFloor,
2069
1972
  height: height
2070
1973
  };
2071
1974
  altitude = othItem.item.properties.get('altitude');
2072
- heightFromFloor = (0, _convertUnitsLite.convert)(altitude.get('_length')).from(altitude.get('_unit')).to('in');
1975
+ heightFromFloor = convert(altitude.get('_length')).from(altitude.get('_unit')).to('in');
2073
1976
  height = othItem.cat && othItem.cat.info.sizeinfo.height;
2074
1977
  var otherItem = {
2075
1978
  heightFromFloor: heightFromFloor,
@@ -2087,7 +1990,7 @@ function needSnap(curItem, othItem) {
2087
1990
  }
2088
1991
  return blSnap;
2089
1992
  }
2090
- function isFrontWall(v0, v1) {
1993
+ export function isFrontWall(v0, v1) {
2091
1994
  var x1 = v0.x,
2092
1995
  y1 = v0.y;
2093
1996
  var x2 = v1.x,
@@ -2095,7 +1998,7 @@ function isFrontWall(v0, v1) {
2095
1998
  var alpha = angleBetweenTwoPoints(x1, y1, x2, y2);
2096
1999
  return almostEqual(y1, y2) && x1 < x2 || -Math.PI / 2 < alpha && alpha < Math.PI / 2;
2097
2000
  }
2098
- function isBackWall(v0, v1) {
2001
+ export function isBackWall(v0, v1) {
2099
2002
  var x1 = v0.x,
2100
2003
  y1 = v0.y;
2101
2004
  var x2 = v1.x,
@@ -2103,7 +2006,7 @@ function isBackWall(v0, v1) {
2103
2006
  var alpha = angleBetweenTwoPoints(x1, y1, x2, y2);
2104
2007
  return almostEqual(y1, y2) && x1 > x2 || -Math.PI / 2 > alpha || alpha > Math.PI / 2;
2105
2008
  }
2106
- function isLeftWall(v0, v1) {
2009
+ export function isLeftWall(v0, v1) {
2107
2010
  var x1 = v0.x,
2108
2011
  y1 = v0.y;
2109
2012
  var x2 = v1.x,
@@ -2111,7 +2014,7 @@ function isLeftWall(v0, v1) {
2111
2014
  var alpha = angleBetweenTwoPoints(x1, y1, x2, y2);
2112
2015
  return almostEqual(x1, x2) && y1 < y2 || Math.PI > alpha && alpha > 0;
2113
2016
  }
2114
- function isRightWall(v0, v1) {
2017
+ export function isRightWall(v0, v1) {
2115
2018
  var x1 = v0.x,
2116
2019
  y1 = v0.y;
2117
2020
  var x2 = v1.x,
@@ -2144,7 +2047,7 @@ function isRightWall(v0, v1) {
2144
2047
  //////// test - end /////////////
2145
2048
 
2146
2049
  */
2147
- function relationshipOfTwoOverlappedLines(srcLine, destLine) {
2050
+ export function relationshipOfTwoOverlappedLines(srcLine, destLine) {
2148
2051
  // let res1 = relationshipOfTwoOverlappedLines1(srcLine, destLine);
2149
2052
  var res2 = relationshipOfTwoOverlappedLines2(srcLine, destLine);
2150
2053
  // if (res1.result !== 0 || res2.result !== 0) {
@@ -2156,7 +2059,7 @@ function relationshipOfTwoOverlappedLines(srcLine, destLine) {
2156
2059
  // }
2157
2060
  return res2;
2158
2061
  }
2159
- function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
2062
+ export function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
2160
2063
  var p1 = {
2161
2064
  x: srcLine.x1,
2162
2065
  y: srcLine.y1
@@ -2184,10 +2087,10 @@ function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
2184
2087
  var denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
2185
2088
  var numA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);
2186
2089
  var numB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3);
2187
- if ((0, _math.fAbs)(denom) <= _constants.EPSILON) {
2188
- if ((0, _math.fAbs)(numA) <= _constants.EPSILON && (0, _math.fAbs)(numB) <= _constants.EPSILON) {
2090
+ if (fAbs(denom) <= EPSILON) {
2091
+ if (fAbs(numA) <= EPSILON && fAbs(numB) <= EPSILON) {
2189
2092
  var comparator = function comparator(pa, pb) {
2190
- return (0, _math.fAbs)(pa.x - pb.x) <= _constants.EPSILON ? pa.y - pb.y : pa.x - pb.x;
2093
+ return fAbs(pa.x - pb.x) <= EPSILON ? pa.y - pb.y : pa.x - pb.x;
2191
2094
  };
2192
2095
  var line0 = [p1, p2].sort(comparator);
2193
2096
  var line1 = [p3, p4].sort(comparator);
@@ -2196,7 +2099,7 @@ function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
2196
2099
  var _sort3 = [line0, line1].sort(function (lineA, lineB) {
2197
2100
  return comparator(lineA[0], lineB[0]);
2198
2101
  }),
2199
- _sort4 = (0, _slicedToArray2["default"])(_sort3, 2),
2102
+ _sort4 = _slicedToArray(_sort3, 2),
2200
2103
  lineSX = _sort4[0],
2201
2104
  lineDX = _sort4[1];
2202
2105
  var isReversedSrcLineIdx = false;
@@ -2204,17 +2107,17 @@ function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
2204
2107
  var compare0 = comparator(lineSX[0], lineDX[0]);
2205
2108
  var compare1 = comparator(lineSX[1], lineDX[0]);
2206
2109
  var compare2 = comparator(lineSX[1], lineDX[1]);
2207
- if (_export.MathUtils.fAbs(compare0) < _constants.EPSILON && _export.MathUtils.fAbs(compare2) < _constants.EPSILON) {
2110
+ if (MathUtils.fAbs(compare0) < EPSILON && MathUtils.fAbs(compare2) < EPSILON) {
2208
2111
  return {
2209
- result: _constants.OVERLAP_SAME
2112
+ result: OVERLAP_SAME
2210
2113
  };
2211
- } else if (_export.MathUtils.fAbs(compare0) < _constants.EPSILON && compare2 < 0) {
2114
+ } else if (MathUtils.fAbs(compare0) < EPSILON && compare2 < 0) {
2212
2115
  // lineDX includes lineSX
2213
2116
  if (!isReversedSrcLineIdx) {
2214
2117
  // dest === lineDX : dest includes src
2215
2118
  // return OVERLAP_INCLUDED; // lineSX[1] - lineDX[1]
2216
2119
  return {
2217
- result: _constants.OVERLAP_INCLUDED
2120
+ result: OVERLAP_INCLUDED
2218
2121
  };
2219
2122
  }
2220
2123
  // else {
@@ -2231,10 +2134,10 @@ function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
2231
2134
  // };
2232
2135
  // }
2233
2136
  }
2234
- if (_export.MathUtils.fAbs(compare1) < _constants.EPSILON) {
2137
+ if (MathUtils.fAbs(compare1) < EPSILON) {
2235
2138
  // return OVERLAP_LINK; // lineSX[1]
2236
2139
  return {
2237
- result: _constants.OVERLAP_LINK,
2140
+ result: OVERLAP_LINK,
2238
2141
  linkedLine: {
2239
2142
  x1: isReversedSrcLineDirection ? lineDX[1].x : lineSX[0].x,
2240
2143
  y1: isReversedSrcLineDirection ? lineDX[1].y : lineSX[0].y,
@@ -2244,16 +2147,16 @@ function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
2244
2147
  };
2245
2148
  } else if (compare1 < 0) {
2246
2149
  return {
2247
- result: _constants.OVERLAP_NONE
2150
+ result: OVERLAP_NONE
2248
2151
  };
2249
2152
  } else {
2250
- if (_export.MathUtils.fAbs(compare2) < _constants.EPSILON || compare2 > 0) {
2153
+ if (MathUtils.fAbs(compare2) < EPSILON || compare2 > 0) {
2251
2154
  // lineSX includes lineDX
2252
2155
  if (isReversedSrcLineIdx) {
2253
2156
  // dest === lineSX : dest includes src
2254
2157
  // return OVERLAP_INCLUDED; // lineDX[0] - lineDX[1]
2255
2158
  return {
2256
- result: _constants.OVERLAP_INCLUDED
2159
+ result: OVERLAP_INCLUDED
2257
2160
  };
2258
2161
  } else {
2259
2162
  // dest === lineDX : src includes dest
@@ -2272,7 +2175,7 @@ function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
2272
2175
  y2: isReversedSrcLineDirection ? lineDX[1].y : lineSX[1].y
2273
2176
  });
2274
2177
  return {
2275
- result: _constants.OVERLAP_SOME,
2178
+ result: OVERLAP_SOME,
2276
2179
  trimmedSegs: trimmedSegs
2277
2180
  };
2278
2181
  }
@@ -2293,7 +2196,7 @@ function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
2293
2196
  y2: isReversedSrcLineDirection ? lineSX[1].y : lineDX[1].y
2294
2197
  });
2295
2198
  return {
2296
- result: _constants.OVERLAP_SOME,
2199
+ result: OVERLAP_SOME,
2297
2200
  trimmedSegs: _trimmedSegs
2298
2201
  };
2299
2202
  }
@@ -2301,46 +2204,46 @@ function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
2301
2204
  }
2302
2205
  }
2303
2206
  return {
2304
- result: _constants.OVERLAP_NONE
2207
+ result: OVERLAP_NONE
2305
2208
  };
2306
2209
  }
2307
- function relationshipOfTwoOverlappedLines1(srcLine, destLine) {
2210
+ export function relationshipOfTwoOverlappedLines1(srcLine, destLine) {
2308
2211
  var INFINITY = 1000000;
2309
2212
  var ZERO_DELTA = 0.01;
2310
2213
  // geometric equation of srcLine
2311
2214
  var dx1 = srcLine.x2 - srcLine.x1;
2312
- dx1 = _export.MathUtils.fAbs(dx1) < ZERO_DELTA ? 0 : dx1;
2215
+ dx1 = MathUtils.fAbs(dx1) < ZERO_DELTA ? 0 : dx1;
2313
2216
  var dy1 = srcLine.y2 - srcLine.y1;
2314
- dy1 = _export.MathUtils.fAbs(dy1) < ZERO_DELTA ? 0 : dy1;
2217
+ dy1 = MathUtils.fAbs(dy1) < ZERO_DELTA ? 0 : dy1;
2315
2218
  var a1 = dx1 === 0 ? INFINITY : dy1 / dx1;
2316
2219
  var b1 = a1 === INFINITY ? srcLine.x1 : srcLine.y1 - a1 * srcLine.x1;
2317
2220
  // geometric equation of destLine
2318
2221
  var dx2 = destLine.x2 - destLine.x1;
2319
- dx2 = _export.MathUtils.fAbs(dx2) < ZERO_DELTA ? 0 : dx2;
2222
+ dx2 = MathUtils.fAbs(dx2) < ZERO_DELTA ? 0 : dx2;
2320
2223
  var dy2 = destLine.y2 - destLine.y1;
2321
- dy2 = _export.MathUtils.fAbs(dy2) < ZERO_DELTA ? 0 : dy2;
2224
+ dy2 = MathUtils.fAbs(dy2) < ZERO_DELTA ? 0 : dy2;
2322
2225
  var a2 = dx2 === 0 ? INFINITY : dy2 / dx2;
2323
2226
  var b2 = a2 === INFINITY ? destLine.x1 : destLine.y1 - a2 * destLine.x1;
2324
- if (_export.MathUtils.fAbs(_export.MathUtils.fAbs(a1) - _export.MathUtils.fAbs(a2)) > ZERO_DELTA)
2227
+ if (MathUtils.fAbs(MathUtils.fAbs(a1) - MathUtils.fAbs(a2)) > ZERO_DELTA)
2325
2228
  // two lines are not parallel
2326
2229
  return {
2327
- result: _constants.OVERLAP_NONE
2230
+ result: OVERLAP_NONE
2328
2231
  };
2329
- if (_export.MathUtils.fAbs(_export.MathUtils.fAbs(b1) - _export.MathUtils.fAbs(b2)) > ZERO_DELTA)
2232
+ if (MathUtils.fAbs(MathUtils.fAbs(b1) - MathUtils.fAbs(b2)) > ZERO_DELTA)
2330
2233
  // two lines are parallel but not overlap
2331
2234
  return {
2332
- result: _constants.OVERLAP_NONE
2235
+ result: OVERLAP_NONE
2333
2236
  };
2334
2237
 
2335
2238
  // parametric equation of destLine
2336
- var sk1 = dx1 === 0 ? INFINITY : _export.MathUtils.toFixedFloat((destLine.x1 - srcLine.x1) / dx1, 3);
2337
- var sk2 = dy1 === 0 ? INFINITY : _export.MathUtils.toFixedFloat((destLine.y1 - srcLine.y1) / dy1, 3);
2338
- var ek1 = dx1 === 0 ? INFINITY : _export.MathUtils.toFixedFloat((destLine.x2 - srcLine.x1) / dx1, 3);
2339
- var ek2 = dy1 === 0 ? INFINITY : _export.MathUtils.toFixedFloat((destLine.y2 - srcLine.y1) / dy1, 3);
2239
+ var sk1 = dx1 === 0 ? INFINITY : MathUtils.toFixedFloat((destLine.x1 - srcLine.x1) / dx1, 3);
2240
+ var sk2 = dy1 === 0 ? INFINITY : MathUtils.toFixedFloat((destLine.y1 - srcLine.y1) / dy1, 3);
2241
+ var ek1 = dx1 === 0 ? INFINITY : MathUtils.toFixedFloat((destLine.x2 - srcLine.x1) / dx1, 3);
2242
+ var ek2 = dy1 === 0 ? INFINITY : MathUtils.toFixedFloat((destLine.y2 - srcLine.y1) / dy1, 3);
2340
2243
  if (sk1 !== INFINITY && sk2 !== INFINITY && ek1 !== INFINITY && ek2 !== INFINITY && (sk1 !== sk2 || ek1 !== ek2))
2341
2244
  // destLine does not overlap with srcLine
2342
2245
  return {
2343
- result: _constants.OVERLAP_NONE
2246
+ result: OVERLAP_NONE
2344
2247
  };
2345
2248
 
2346
2249
  // parameter of destLine on the start and end points
@@ -2354,17 +2257,17 @@ function relationshipOfTwoOverlappedLines1(srcLine, destLine) {
2354
2257
  if (sk < 0 && ek < 0 || sk > 1 && ek > 1)
2355
2258
  // not overlap
2356
2259
  return {
2357
- result: _constants.OVERLAP_NONE
2260
+ result: OVERLAP_NONE
2358
2261
  };
2359
2262
  if (sk === 0 && ek === 1 || sk === 1 && ek === 0)
2360
2263
  // same lines
2361
2264
  return {
2362
- result: _constants.OVERLAP_SAME
2265
+ result: OVERLAP_SAME
2363
2266
  };
2364
2267
  if (sk <= 0 && ek >= 1 || sk >= 1 && ek <= 0)
2365
2268
  // destLine includes srcLine
2366
2269
  return {
2367
- result: _constants.OVERLAP_INCLUDED
2270
+ result: OVERLAP_INCLUDED
2368
2271
  };
2369
2272
  if (sk === 0 && ek < 0 || sk === 1 && ek > 1 || ek === 0 && sk < 0 || ek === 1 && sk > 1) {
2370
2273
  // linked with one common point
@@ -2407,14 +2310,14 @@ function relationshipOfTwoOverlappedLines1(srcLine, destLine) {
2407
2310
  };
2408
2311
  }
2409
2312
  return {
2410
- result: _constants.OVERLAP_LINK,
2313
+ result: OVERLAP_LINK,
2411
2314
  linkedLine: linkedLine
2412
2315
  };
2413
2316
  }
2414
2317
  var trimmedSegment1 = null;
2415
2318
  var trimmedSegment2 = null;
2416
2319
  var ret = {
2417
- result: _constants.OVERLAP_SOME,
2320
+ result: OVERLAP_SOME,
2418
2321
  trimmedSegs: []
2419
2322
  };
2420
2323
  if (0 <= sk && sk <= 1 && 0 <= ek && ek <= 1) {
@@ -2500,7 +2403,7 @@ function relationshipOfTwoOverlappedLines1(srcLine, destLine) {
2500
2403
  * @param {Array} points //points of polygon
2501
2404
  * @returns {Array} [centroid.x, centroid.y]
2502
2405
  */
2503
- function getCentroidOfPolygon(points) {
2406
+ export function getCentroidOfPolygon(points) {
2504
2407
  var center = points.reduce(function (x, y) {
2505
2408
  return [x[0] + y[0] / points.length, x[1] + y[1] / points.length];
2506
2409
  }, [0, 0]);