kitchen-simulator 1.1.1-test.70 → 1.1.1-test.71

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