kitchen-simulator 4.0.4-react-18 → 4.0.4

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 (192) hide show
  1. package/README.md +3 -0
  2. package/es/AppContext.js +1 -1
  3. package/es/LiteKitchenConfigurator.js +161 -104
  4. package/es/LiteRenderer.js +161 -129
  5. package/es/actions/export.js +25 -12
  6. package/es/assets/gltf/door_sliding.bin +0 -0
  7. package/es/assets/img/png/helper/video_preview_start.png +0 -0
  8. package/es/assets/img/svg/bottombar/elevation.svg +12 -5
  9. package/es/catalog/catalog.js +21 -5
  10. package/es/catalog/holes/window-clear/planner-element.js +2 -2
  11. package/es/catalog/properties/export.js +21 -0
  12. package/es/catalog/properties/property-checkbox.js +68 -0
  13. package/es/catalog/properties/property-color.js +39 -0
  14. package/es/catalog/properties/property-enum.js +50 -0
  15. package/es/catalog/properties/property-hidden.js +19 -0
  16. package/es/catalog/properties/property-lenght-measure.js +100 -0
  17. package/es/catalog/properties/property-length-measure.js +84 -0
  18. package/es/catalog/properties/property-length-measure_hole.js +100 -0
  19. package/es/catalog/properties/property-number.js +48 -0
  20. package/es/catalog/properties/property-read-only.js +26 -0
  21. package/es/catalog/properties/property-string.js +48 -0
  22. package/es/catalog/properties/property-toggle.js +39 -0
  23. package/es/catalog/properties/shared-property-style.js +14 -0
  24. package/es/catalog/utils/exporter.js +1 -0
  25. package/es/catalog/utils/item-loader.js +35 -26
  26. package/es/class/hole.js +0 -2
  27. package/es/class/item.js +95 -69
  28. package/es/class/line.js +4 -8
  29. package/es/class/project.js +93 -80
  30. package/es/components/content.js +5 -93
  31. package/es/components/export.js +4 -6
  32. package/es/components/style/button.js +106 -0
  33. package/es/components/style/cancel-button.js +21 -0
  34. package/es/components/style/content-container.js +30 -0
  35. package/es/components/style/content-title.js +25 -0
  36. package/es/components/style/delete-button.js +24 -0
  37. package/es/components/style/export.js +28 -2
  38. package/es/components/style/form-block.js +20 -0
  39. package/es/components/style/form-color-input.js +26 -0
  40. package/es/components/style/form-label.js +22 -0
  41. package/es/components/style/form-number-input.js +29 -27
  42. package/es/components/style/form-number-input_2.js +200 -0
  43. package/es/components/style/form-select.js +19 -0
  44. package/es/components/style/form-slider.js +60 -0
  45. package/es/components/style/form-submit-button.js +25 -0
  46. package/es/components/style/form-text-input.js +69 -0
  47. package/es/components/viewer2d/grids/grid-streak.js +1 -1
  48. package/es/components/viewer2d/group.js +5 -4
  49. package/es/components/viewer2d/item.js +155 -359
  50. package/es/components/viewer2d/layer.js +1 -1
  51. package/es/components/viewer2d/line.js +17 -47
  52. package/es/components/viewer2d/ruler.js +5 -3
  53. package/es/components/viewer2d/rulerDist.js +8 -7
  54. package/es/components/viewer2d/rulerX.js +4 -2
  55. package/es/components/viewer2d/rulerY.js +3 -0
  56. package/es/components/viewer2d/scene.js +17 -12
  57. package/es/components/viewer2d/state.js +1 -1
  58. package/es/components/viewer2d/utils.js +2 -2
  59. package/es/components/viewer2d/vertex.js +3 -2
  60. package/es/components/viewer2d/viewer2d.js +51 -87
  61. package/es/components/viewer3d/ruler-utils/scene3D.js +1 -1
  62. package/es/components/viewer3d/scene-creator.js +59 -18
  63. package/es/components/viewer3d/viewer3d-first-person.js +24 -26
  64. package/es/components/viewer3d/viewer3d.js +100 -112
  65. package/es/constants.js +6 -2
  66. package/es/devLiteRenderer.js +491 -150
  67. package/es/index.js +566 -25
  68. package/es/models.js +3 -2
  69. package/es/plugins/SVGLoader.js +1414 -0
  70. package/es/plugins/console-debugger.js +34 -0
  71. package/es/plugins/export.js +7 -0
  72. package/es/plugins/keyboard.js +110 -0
  73. package/es/reducers/project-reducer.js +3 -0
  74. package/es/styles/export.js +5 -0
  75. package/es/styles/tabs.css +40 -0
  76. package/es/utils/geometry.js +72 -114
  77. package/es/utils/helper.js +38 -1
  78. package/es/utils/isolate-event-handler.js +826 -606
  79. package/es/utils/molding.js +457 -11
  80. package/lib/AppContext.js +1 -1
  81. package/lib/LiteKitchenConfigurator.js +160 -104
  82. package/lib/LiteRenderer.js +160 -129
  83. package/lib/actions/export.js +35 -39
  84. package/lib/assets/gltf/door_sliding.bin +0 -0
  85. package/lib/assets/img/png/helper/video_preview_start.png +0 -0
  86. package/lib/assets/img/svg/bottombar/elevation.svg +12 -5
  87. package/lib/catalog/catalog.js +20 -4
  88. package/lib/catalog/holes/window-clear/planner-element.js +2 -2
  89. package/lib/catalog/properties/export.js +81 -0
  90. package/lib/catalog/properties/property-checkbox.js +76 -0
  91. package/lib/catalog/properties/property-color.js +47 -0
  92. package/lib/catalog/properties/property-enum.js +58 -0
  93. package/lib/catalog/properties/property-hidden.js +27 -0
  94. package/lib/catalog/properties/property-lenght-measure.js +108 -0
  95. package/lib/catalog/properties/property-length-measure.js +92 -0
  96. package/lib/catalog/properties/property-length-measure_hole.js +108 -0
  97. package/lib/catalog/properties/property-number.js +56 -0
  98. package/lib/catalog/properties/property-read-only.js +34 -0
  99. package/lib/catalog/properties/property-string.js +56 -0
  100. package/lib/catalog/properties/property-toggle.js +47 -0
  101. package/lib/catalog/properties/shared-property-style.js +21 -0
  102. package/lib/catalog/utils/exporter.js +1 -0
  103. package/lib/catalog/utils/item-loader.js +35 -26
  104. package/lib/class/hole.js +0 -2
  105. package/lib/class/item.js +93 -67
  106. package/lib/class/line.js +3 -7
  107. package/lib/class/project.js +93 -80
  108. package/lib/components/content.js +5 -93
  109. package/lib/components/export.js +6 -26
  110. package/lib/components/style/button.js +115 -0
  111. package/lib/components/style/cancel-button.js +29 -0
  112. package/lib/components/style/content-container.js +38 -0
  113. package/lib/components/style/content-title.js +35 -0
  114. package/lib/components/style/delete-button.js +34 -0
  115. package/lib/components/style/export.js +105 -1
  116. package/lib/components/style/form-block.js +28 -0
  117. package/lib/components/style/form-color-input.js +34 -0
  118. package/lib/components/style/form-label.js +30 -0
  119. package/lib/components/style/form-number-input.js +29 -27
  120. package/lib/components/style/form-number-input_2.js +209 -0
  121. package/lib/components/style/form-select.js +29 -0
  122. package/lib/components/style/form-slider.js +68 -0
  123. package/lib/components/style/form-submit-button.js +35 -0
  124. package/lib/components/style/form-text-input.js +78 -0
  125. package/lib/components/viewer2d/grids/grid-streak.js +1 -1
  126. package/lib/components/viewer2d/group.js +5 -4
  127. package/lib/components/viewer2d/item.js +152 -356
  128. package/lib/components/viewer2d/layer.js +1 -1
  129. package/lib/components/viewer2d/line.js +17 -47
  130. package/lib/components/viewer2d/ruler.js +4 -2
  131. package/lib/components/viewer2d/rulerDist.js +8 -7
  132. package/lib/components/viewer2d/rulerX.js +4 -2
  133. package/lib/components/viewer2d/rulerY.js +3 -0
  134. package/lib/components/viewer2d/scene.js +17 -12
  135. package/lib/components/viewer2d/state.js +1 -1
  136. package/lib/components/viewer2d/utils.js +2 -2
  137. package/lib/components/viewer2d/vertex.js +3 -2
  138. package/lib/components/viewer2d/viewer2d.js +49 -84
  139. package/lib/components/viewer3d/ruler-utils/scene3D.js +1 -1
  140. package/lib/components/viewer3d/scene-creator.js +57 -16
  141. package/lib/components/viewer3d/viewer3d-first-person.js +24 -26
  142. package/lib/components/viewer3d/viewer3d.js +97 -108
  143. package/lib/constants.js +11 -7
  144. package/lib/devLiteRenderer.js +489 -148
  145. package/lib/index.js +566 -25
  146. package/lib/models.js +3 -2
  147. package/lib/plugins/SVGLoader.js +1419 -0
  148. package/lib/plugins/console-debugger.js +42 -0
  149. package/lib/plugins/export.js +25 -0
  150. package/lib/plugins/keyboard.js +117 -0
  151. package/lib/reducers/project-reducer.js +3 -0
  152. package/lib/styles/export.js +13 -0
  153. package/lib/styles/tabs.css +40 -0
  154. package/lib/utils/geometry.js +72 -114
  155. package/lib/utils/helper.js +40 -1
  156. package/lib/utils/isolate-event-handler.js +826 -605
  157. package/lib/utils/molding.js +458 -9
  158. package/package.json +21 -16
  159. package/es/mocks/appliancePayload.json +0 -27
  160. package/es/mocks/cabinetPayload.json +0 -1914
  161. package/es/mocks/cabinetPayload2.json +0 -76
  162. package/es/mocks/dataBundle2.json +0 -4
  163. package/es/mocks/distancePayload.json +0 -6
  164. package/es/mocks/doorStylePayload2.json +0 -84
  165. package/es/mocks/furnishingPayload.json +0 -23
  166. package/es/mocks/itemCDSPayload.json +0 -27
  167. package/es/mocks/lightingPayload.json +0 -23
  168. package/es/mocks/mockProps.json +0 -43
  169. package/es/mocks/mockProps2.json +0 -9
  170. package/es/mocks/moldingPayload.json +0 -19
  171. package/es/mocks/projectItemsCatalog.json +0 -133
  172. package/es/mocks/rectangleShape.json +0 -238
  173. package/es/mocks/replaceCabinetPayload.json +0 -81
  174. package/es/mocks/roomShapePayload.json +0 -5
  175. package/es/useAppContext.js +0 -8
  176. package/lib/mocks/appliancePayload.json +0 -27
  177. package/lib/mocks/cabinetPayload.json +0 -1914
  178. package/lib/mocks/cabinetPayload2.json +0 -76
  179. package/lib/mocks/dataBundle2.json +0 -4
  180. package/lib/mocks/distancePayload.json +0 -6
  181. package/lib/mocks/doorStylePayload2.json +0 -84
  182. package/lib/mocks/furnishingPayload.json +0 -23
  183. package/lib/mocks/itemCDSPayload.json +0 -27
  184. package/lib/mocks/lightingPayload.json +0 -23
  185. package/lib/mocks/mockProps.json +0 -43
  186. package/lib/mocks/mockProps2.json +0 -9
  187. package/lib/mocks/moldingPayload.json +0 -19
  188. package/lib/mocks/projectItemsCatalog.json +0 -133
  189. package/lib/mocks/rectangleShape.json +0 -238
  190. package/lib/mocks/replaceCabinetPayload.json +0 -81
  191. package/lib/mocks/roomShapePayload.json +0 -5
  192. package/lib/useAppContext.js +0 -16
@@ -4,7 +4,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
4
4
  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; }
5
5
  import React, { useEffect, useRef, useState } from 'react';
6
6
  import PropTypes from 'prop-types';
7
- import { INITIAL_VALUE, POSITION_NONE, ReactSVGPanZoom, TOOL_AUTO, TOOL_NONE, TOOL_PAN, TOOL_ZOOM_IN, TOOL_ZOOM_OUT } from 'react-svg-pan-zoom';
7
+ import { ReactSVGPanZoom, TOOL_AUTO, TOOL_NONE, TOOL_PAN, TOOL_ZOOM_IN, TOOL_ZOOM_OUT } from 'react-svg-pan-zoom';
8
8
  import * as constants from "../../constants";
9
9
  import { DECIMAL_PLACES_2, LINE_THICKNESS, MIN_ANGLE_DISALLOW_DRAW_WALL, MODE_ELEVATION_VIEW, MODE_IDLE, UNIT_ANGLE, INTERNAL_EVENT_SELECT_ELEMENT, INTERNAL_EVENT_DRAG_ELEMENT, INTERNAL_EVENT_DRAW_ELEMENT, INTERNAL_EVENT_ROTATE_ELEMENT } from "../../constants";
10
10
  import State from "./state";
@@ -15,10 +15,8 @@ import FormNumberInput from "../style/form-number-input";
15
15
  import { convert } from "../../utils/convert-units-lite";
16
16
  import { Map } from 'immutable';
17
17
  import { formatNumber } from "../../utils/math";
18
- import { isEmpty } from "../../utils/helper"; // variables
18
+ import { isEmpty, updatePayloadOfInternalEvent } from "../../utils/helper"; // variables
19
19
  import { isWarningItem } from "./utils";
20
- import { MoldingUtils } from "../../utils/export";
21
- import { useAppContext } from "../../useAppContext";
22
20
  // variables
23
21
  var pinFlag = false;
24
22
  var sFlag = false; //for all object move
@@ -122,22 +120,21 @@ function extractElementData(node) {
122
120
  direct: node.attributes.getNamedItem('data-direct') ? node.attributes.getNamedItem('data-direct').value : 0
123
121
  };
124
122
  }
125
- export default function Viewer2D(_ref) {
123
+ export default function Viewer2D(_ref, _ref2) {
126
124
  var state = _ref.state,
127
125
  width = _ref.width,
128
126
  height = _ref.height,
129
127
  setToolbar = _ref.setToolbar,
130
128
  replaceCabinet = _ref.replaceCabinet,
131
129
  onInternalEvent = _ref.onInternalEvent;
132
- var _useAppContext = useAppContext(),
133
- viewer2DActions = _useAppContext.viewer2DActions,
134
- linesActions = _useAppContext.linesActions,
135
- holesActions = _useAppContext.holesActions,
136
- verticesActions = _useAppContext.verticesActions,
137
- itemsActions = _useAppContext.itemsActions,
138
- areaActions = _useAppContext.areaActions,
139
- projectActions = _useAppContext.projectActions,
140
- catalog = _useAppContext.catalog;
130
+ var viewer2DActions = _ref2.viewer2DActions,
131
+ linesActions = _ref2.linesActions,
132
+ holesActions = _ref2.holesActions,
133
+ verticesActions = _ref2.verticesActions,
134
+ itemsActions = _ref2.itemsActions,
135
+ areaActions = _ref2.areaActions,
136
+ projectActions = _ref2.projectActions,
137
+ catalog = _ref2.catalog;
141
138
  var _useState = useState(null),
142
139
  _useState2 = _slicedToArray(_useState, 2),
143
140
  rulerEdit = _useState2[0],
@@ -160,26 +157,6 @@ export default function Viewer2D(_ref) {
160
157
  _useState8 = _slicedToArray(_useState7, 2),
161
158
  drawStart = _useState8[0],
162
159
  setdrawStart = _useState8[1];
163
- var _useState9 = useState(function () {
164
- return viewer2D && !viewer2D.isEmpty() ? viewer2D.toJS() : INITIAL_VALUE;
165
- }),
166
- _useState0 = _slicedToArray(_useState9, 2),
167
- svgValue = _useState0[0],
168
- setSvgValue = _useState0[1];
169
- var _useState1 = useState(function () {
170
- return mode2Tool(mode);
171
- }),
172
- _useState10 = _slicedToArray(_useState1, 2),
173
- svgTool = _useState10[0],
174
- setSvgTool = _useState10[1];
175
- useEffect(function () {
176
- // keep tool controlled from app mode
177
- setSvgTool(mode2Tool(mode));
178
- }, [mode]);
179
- useEffect(function () {
180
- // keep value controlled from store, but never null
181
- if (viewer2D && !viewer2D.isEmpty()) setSvgValue(viewer2D.toJS());
182
- }, [viewer2D]);
183
160
  useEffect(function () {
184
161
  // move viewer point to center
185
162
  var selectedLayer = state.scene.layers.get(state.scene.selectedLayer);
@@ -204,9 +181,9 @@ export default function Viewer2D(_ref) {
204
181
  var layerID = scene.selectedLayer;
205
182
  var wall_thickness = LINE_THICKNESS / 2;
206
183
  var layer = scene.getIn(['layers', layerID]);
207
- var mapCursorPosition = function mapCursorPosition(_ref2) {
208
- var x = _ref2.x,
209
- y = _ref2.y;
184
+ var mapCursorPosition = function mapCursorPosition(_ref3) {
185
+ var x = _ref3.x,
186
+ y = _ref3.y;
210
187
  return {
211
188
  x: x,
212
189
  y: -y + scene.height
@@ -855,15 +832,17 @@ export default function Viewer2D(_ref) {
855
832
  var onMouseUp = function onMouseUp(viewerEvent) {
856
833
  //set move all flag false
857
834
  sFlag = false;
858
- // //////////////////////
859
- // setRulerEdit(null);
860
835
  var event = viewerEvent.originalEvent;
861
- var bbox = event.target.getBoundingClientRect();
836
+ var parent = document.querySelector('#kitchen-simulator-container');
837
+ var targetRect = event.target.getBoundingClientRect();
838
+ var parentRect = parent.getBoundingClientRect();
839
+ var left = targetRect.left - parentRect.left;
840
+ var top = targetRect.top - parentRect.top;
841
+ left = left - (200 - targetRect.width) / 2;
842
+ top = top - (50 - targetRect.height) / 2;
862
843
  if (!mode.includes('ING')) {
863
844
  setToolbar('');
864
845
  }
865
- // bbox.width = event.target.getBBox().width;
866
- // bbox.height = event.target.getBBox().height;
867
846
  if (event.target.tagName === 'rect') {
868
847
  if (event.target.id) {
869
848
  setRulerEditID(event.target.id);
@@ -995,8 +974,8 @@ export default function Viewer2D(_ref) {
995
974
  id: "ruler_numberInput",
996
975
  style: {
997
976
  position: 'absolute',
998
- left: bbox.left - (150 - bbox.width) / 2,
999
- top: bbox.top - (50 - bbox.height) / 2,
977
+ left: left,
978
+ top: top,
1000
979
  zIndex: 1000
1001
980
  }
1002
981
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
@@ -1027,8 +1006,8 @@ export default function Viewer2D(_ref) {
1027
1006
  id: "ruler_numberInput",
1028
1007
  style: {
1029
1008
  position: 'absolute',
1030
- left: bbox.left - (150 - bbox.width) / 2,
1031
- top: bbox.top - (50 - bbox.height) / 2,
1009
+ left: left,
1010
+ top: top,
1032
1011
  zIndex: 1000
1033
1012
  }
1034
1013
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
@@ -1060,8 +1039,8 @@ export default function Viewer2D(_ref) {
1060
1039
  id: "ruler_numberInput",
1061
1040
  style: {
1062
1041
  position: 'absolute',
1063
- left: bbox.left - (150 - bbox.width) / 2,
1064
- top: bbox.top - (50 - bbox.height) / 2,
1042
+ left: left,
1043
+ top: top,
1065
1044
  zIndex: 1000
1066
1045
  }
1067
1046
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
@@ -1093,8 +1072,8 @@ export default function Viewer2D(_ref) {
1093
1072
  id: "ruler_numberInput",
1094
1073
  style: {
1095
1074
  position: 'absolute',
1096
- left: bbox.left - (150 - bbox.width) / 2,
1097
- top: bbox.top - (50 - bbox.height) / 2,
1075
+ left: left,
1076
+ top: top,
1098
1077
  zIndex: 1000
1099
1078
  }
1100
1079
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
@@ -1126,8 +1105,8 @@ export default function Viewer2D(_ref) {
1126
1105
  id: "ruler_numberInput",
1127
1106
  style: {
1128
1107
  position: 'absolute',
1129
- left: bbox.left - (150 - bbox.width) / 2,
1130
- top: bbox.top - (50 - bbox.height) / 2,
1108
+ left: left,
1109
+ top: top,
1131
1110
  zIndex: 1000
1132
1111
  }
1133
1112
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
@@ -1159,8 +1138,8 @@ export default function Viewer2D(_ref) {
1159
1138
  id: "ruler_numberInput",
1160
1139
  style: {
1161
1140
  position: 'absolute',
1162
- left: bbox.left - (150 - bbox.width) / 2,
1163
- top: bbox.top - (50 - bbox.height) / 2,
1141
+ left: left,
1142
+ top: top,
1164
1143
  zIndex: 1000
1165
1144
  }
1166
1145
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
@@ -1191,8 +1170,8 @@ export default function Viewer2D(_ref) {
1191
1170
  id: "ruler_numberInput",
1192
1171
  style: {
1193
1172
  position: 'absolute',
1194
- left: bbox.left - (150 - bbox.width) / 2,
1195
- top: bbox.top - (50 - bbox.height) / 2,
1173
+ left: left,
1174
+ top: top,
1196
1175
  zIndex: 1000
1197
1176
  }
1198
1177
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
@@ -1273,24 +1252,7 @@ export default function Viewer2D(_ref) {
1273
1252
  _currentObject = state.getIn(['scene', 'layers', layerID, elementPrototype, elementID]);
1274
1253
  }
1275
1254
  if (_currentObject) {
1276
- var _currentObject3, _currentObject4, _currentObject5;
1277
- var payload = (_currentObject3 = _currentObject) === null || _currentObject3 === void 0 ? void 0 : _currentObject3.toJS();
1278
- if (((_currentObject4 = _currentObject) === null || _currentObject4 === void 0 ? void 0 : _currentObject4.prototype) === 'lines') {
1279
- // caculating length of selected line//
1280
- var v_a = layer.vertices.get(_currentObject.vertices.get(0));
1281
- var v_b = layer.vertices.get(_currentObject.vertices.get(1));
1282
- var distance = GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
1283
- var _length3 = convert(distance).from('cm').to('in');
1284
- payload.length = _length3;
1285
- //////////////////////////////////////
1286
- } else if (((_currentObject5 = _currentObject) === null || _currentObject5 === void 0 ? void 0 : _currentObject5.prototype) === 'items') {
1287
- // check this cabinet has warning box
1288
- payload.isWarning = isWarningItem(_currentObject);
1289
- // check this item is available molding
1290
- payload.isMoldingAvailable = MoldingUtils.isEnableItemForMolding(layer, _currentObject);
1291
- // check this item is snapped to wall
1292
- payload.isAttachedWall = MoldingUtils.isAttachedWall(layer, _currentObject);
1293
- }
1255
+ var payload = updatePayloadOfInternalEvent(_currentObject, layer, catalog);
1294
1256
 
1295
1257
  // send selection event befor replace event
1296
1258
  if (internalType === constants.INTERNAL_EVENT_REPLACE_CABINET) {
@@ -1309,7 +1271,6 @@ export default function Viewer2D(_ref) {
1309
1271
  };
1310
1272
  var onChangeValue = function onChangeValue(value) {
1311
1273
  if (sFlag) return;
1312
- setSvgValue(value);
1313
1274
  var _zoomValue = parseInt((value.a - 0.5) / constants.ZOOM_VARIABLE);
1314
1275
  if (_zoomValue > constants.MAX_ZOOM_IN_SCALE) return;
1315
1276
  if (_zoomValue < 0 || Number.isNaN(_zoomValue)) return;
@@ -1322,8 +1283,6 @@ export default function Viewer2D(_ref) {
1322
1283
  var bbox;
1323
1284
  if (_rect && _rulerEdit) {
1324
1285
  bbox = _rect.getBoundingClientRect();
1325
- // bbox.width = _rect.getBBox().width;
1326
- // bbox.height = _rect.getBBox().height;
1327
1286
  _rulerEdit.style.left = "".concat(bbox.left - (150 - bbox.width) / 2, "px");
1328
1287
  _rulerEdit.style.top = "".concat(bbox.top - (50 - bbox.height) / 2, "px");
1329
1288
  }
@@ -1341,7 +1300,6 @@ export default function Viewer2D(_ref) {
1341
1300
  }
1342
1301
  };
1343
1302
  var onChangeTool = function onChangeTool(tool) {
1344
- setSvgTool(tool);
1345
1303
  switch (tool) {
1346
1304
  case TOOL_NONE:
1347
1305
  projectActions.selectToolEdit();
@@ -1440,23 +1398,19 @@ export default function Viewer2D(_ref) {
1440
1398
  },
1441
1399
  width: width - rulerSize,
1442
1400
  height: height - rulerSize,
1443
- value: svgValue,
1444
- tool: svgTool,
1401
+ value: viewer2D.isEmpty() ? null : viewer2D.toJS(),
1445
1402
  onChangeValue: onChangeValue,
1403
+ tool: mode2Tool(mode),
1446
1404
  onChangeTool: onChangeTool,
1447
1405
  detectAutoPan: mode2DetectAutopan(mode),
1448
1406
  onMouseDown: onMouseDown,
1449
1407
  onMouseMove: onMouseMove,
1450
1408
  onMouseUp: onMouseUp,
1409
+ miniaturePosition: "none",
1410
+ toolbarPosition: "none",
1451
1411
  detectPinchGesture: false,
1452
1412
  disableDoubleClickZoomWithToolAuto: true,
1453
- ref: Viewer,
1454
- miniatureProps: {
1455
- position: POSITION_NONE
1456
- },
1457
- toolbarProps: {
1458
- position: POSITION_NONE
1459
- }
1413
+ ref: Viewer
1460
1414
  }, /*#__PURE__*/React.createElement("svg", {
1461
1415
  width: scene.width,
1462
1416
  height: scene.height
@@ -1491,4 +1445,14 @@ Viewer2D.propTypes = {
1491
1445
  state: PropTypes.object.isRequired,
1492
1446
  width: PropTypes.number.isRequired,
1493
1447
  height: PropTypes.number.isRequired
1448
+ };
1449
+ Viewer2D.contextTypes = {
1450
+ viewer2DActions: PropTypes.object.isRequired,
1451
+ linesActions: PropTypes.object.isRequired,
1452
+ holesActions: PropTypes.object.isRequired,
1453
+ verticesActions: PropTypes.object.isRequired,
1454
+ itemsActions: PropTypes.object.isRequired,
1455
+ areaActions: PropTypes.object.isRequired,
1456
+ projectActions: PropTypes.object.isRequired,
1457
+ catalog: PropTypes.object.isRequired
1494
1458
  };
@@ -14,7 +14,7 @@ export default function Scene3D(_ref) {
14
14
  downloadFlag = _ref.downloadFlag;
15
15
  var layers = scene.layers;
16
16
  var selectedLayer = layers.get(scene.selectedLayer);
17
- var ceilHeight = selectedLayer.ceilHeight;
17
+ var ceilHeight = Number(selectedLayer.ceilHeight);
18
18
  var selectedLine = selectedLayer.lines.get(selectedLayer.selected.lines.toJS()[0]);
19
19
  var vertex0 = selectedLayer.vertices.get(selectedLine.vertices.get(0));
20
20
  var vertex1 = selectedLayer.vertices.get(selectedLine.vertices.get(1));
@@ -9,14 +9,14 @@ import * as Three from 'three';
9
9
  import { Color, Group } from 'three';
10
10
  import createGrid from "./grid-creator";
11
11
  import { disposeObject } from "./three-memory-cleaner";
12
- import { ANIMATE_STEP_MAX, ANIMATE_STEP_MIN, ARRAY_3D_MODES, ARROW_TEXT_BACKCOLOR, ARROW_TEXT_FONTFACE, ARROW_TEXT_FORECOLOR, BASE_CABINET_LAYOUTPOS, BOTTOM_MOLDING_LOCATION, DECIMAL_PLACES_2, DIFFERENT_VALUES_PATH_LENGTH, DISTANCE_EPSILON, EPSILON, MIDDLE_MOLDING_LOCATION, MODE_DRAGGING_ITEM_3D, MODE_DRAWING_ITEM_3D, MODE_IDLE, MODE_IDLE_3D, MODE_ROTATING_ITEM_3D, OBJTYPE_MESH, SHADE_DARK_PURPLE_COLOR, TOP_MOLDING_LOCATION, UNIT_CENTIMETER, WALL_CABINET_LAYOUTPOS } from "../../constants";
12
+ import { ANIMATE_STEP_MAX, ANIMATE_STEP_MIN, ARRAY_3D_MODES, ARROW_TEXT_BACKCOLOR, ARROW_TEXT_FONTFACE, ARROW_TEXT_FORECOLOR, BASE_CABINET_LAYOUTPOS, BOTTOM_MOLDING_LOCATION, DECIMAL_PLACES_2, DIFFERENT_VALUES_PATH_LENGTH, DISTANCE_EPSILON, EPSILON, MIDDLE_MOLDING_LOCATION, MODE_DRAGGING_ITEM_3D, MODE_DRAWING_ITEM_3D, MODE_IDLE, MODE_IDLE_3D, MODE_ROTATING_ITEM_3D, OBJTYPE_MESH, SHADE_DARK_PURPLE_COLOR, TOP_MOLDING_LOCATION, UNIT_CENTIMETER, UNIT_FOOT, UNIT_INCH, UNIT_METER, WALL_CABINET_LAYOUTPOS } from "../../constants";
13
13
  import { GeometryUtils, IDBroker, MoldingUtils } from "../../utils/export";
14
14
  import { convert } from "../../utils/convert-units-lite";
15
15
  import { verticesDistance } from "../../utils/geometry";
16
16
  import * as GeomUtils from "../../catalog/utils/geom-utils";
17
17
  import { loadTexture } from "../../catalog/utils/item-loader";
18
18
  import { returnReplaceableDeepSearchType } from "../viewer2d/utils";
19
- import { animateDoor, isElevationView, isEmpty, replaceMeshesWithLineSegments, translateDrawer } from "../../utils/helper";
19
+ import { animateDoor, isElevationView, isEmpty, isImmutable, replaceMeshesWithLineSegments, translateDrawer } from "../../utils/helper";
20
20
  import { formatNumber } from "../../utils/math";
21
21
  var transformBox;
22
22
  export var fVLine = [];
@@ -187,6 +187,31 @@ export function createWarningObject() {
187
187
  warningObj.name = 'warningObj';
188
188
  return warningObj;
189
189
  }
190
+ function swapLengthProperty(diffs) {
191
+ var idx1 = diffs.findIndex(function (v) {
192
+ return v.path[v.path.length - 1] === 'length';
193
+ });
194
+ var idx2 = diffs.findIndex(function (v) {
195
+ return v.path[v.path.length - 1] === '_length';
196
+ });
197
+ if (idx1 < 0 || idx2 < 0) return diffs;
198
+ if (idx1 > idx2) return diffs;
199
+ if (diffs[idx1].op === diffs[idx2].op) {
200
+ var isSwap = true;
201
+ for (var i = 0; i < diffs[idx1].path.length - 2; i++) {
202
+ if (diffs[idx1].path[i] !== diffs[idx2].path[i]) {
203
+ isSwap = false;
204
+ break;
205
+ }
206
+ }
207
+ if (isSwap) {
208
+ var temp = diffs[idx1];
209
+ diffs[idx1] = diffs[idx2];
210
+ diffs[idx2] = temp;
211
+ }
212
+ }
213
+ return diffs;
214
+ }
190
215
  export function updateScene(planData, sceneData, oldSceneData, diffArray, actions, catalog) {
191
216
  var _draggingItem$toJS, _filteredDiffs, _filteredDiffs2;
192
217
  var mode = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
@@ -204,6 +229,9 @@ export function updateScene(planData, sceneData, oldSceneData, diffArray, action
204
229
  value: el.value
205
230
  };
206
231
  });
232
+
233
+ // move "length" to after "_length"
234
+ splitted = swapLengthProperty(splitted);
207
235
  var filteredDiffs = filterDiffs(splitted, sceneData, oldSceneData);
208
236
  //***testing additional filter***
209
237
  filteredDiffs = filteredDiffs.filter(function (_ref) {
@@ -238,7 +266,7 @@ export function updateScene(planData, sceneData, oldSceneData, diffArray, action
238
266
  * Every 'doorStyle' change has a 'door_style_id' change.
239
267
  * So, if door_style_id changes, it indicates 'doorStyle' change.
240
268
  */
241
- if (['id'].includes(path[path.length - 1])) isSettingDoorStyle = true;
269
+ if (path[1] === 'layers' && path[3] === 'molding' || path[path.length - 2] === 'doorStyle' && path[path.length - 1] === 'id' || ['id'].includes(path[path.length - 1])) isSettingDoorStyle = true;
242
270
 
243
271
  // If there are any molding change of layer
244
272
  if (path[1] === 'layers' && path[3] === 'molding') isUpdateMolding = true;
@@ -614,10 +642,10 @@ function replaceObject(modifiedPath, layer, planData, actions, sceneData, oldSce
614
642
  vLine3.material.depthTest = false;
615
643
  var uVec = new Three.Vector3(-posVec.x / scalevec.x, -posVec.y / scalevec.y, -posVec.z / scalevec.z);
616
644
  var blLighting = item.type.includes('Light');
617
- vLine.translateY(blLighting ? 1.6 : 0.1);
618
- vLine1.translateY(blLighting ? 1.6 : 0.1);
619
- vLine2.translateY(blLighting ? 1.6 : 0.1);
620
- vLine3.translateY(blLighting ? 1.6 : 0.1);
645
+ vLine.translateY(blLighting ? 1.6 : boundingBox.min.y + 0.1);
646
+ vLine1.translateY(blLighting ? 1.6 : boundingBox.min.y + 0.1);
647
+ vLine2.translateY(blLighting ? 1.6 : boundingBox.min.y + 0.1);
648
+ vLine3.translateY(blLighting ? 1.6 : boundingBox.min.y + 0.1);
621
649
  upObj.translateOnAxis(uVec, 1);
622
650
  upObj.translateY(max.y - min.y);
623
651
  _mBox.name = 'TransformBox';
@@ -923,9 +951,9 @@ function getLineDistance(obj, layer, isCalcWall, index) {
923
951
  obj.geometry.attributes.position.needsUpdate = true;
924
952
  obj.geometry.computeBoundingSphere();
925
953
  obj.geometry.computeBoundingBox();
926
- var dist = formatNumber(convert(intersects[i].distance).from('cm').to('in'), DECIMAL_PLACES_2);
954
+ var dist = convert(intersects[i].distance).from('cm').to('in');
927
955
  if (dist > 3) {
928
- var _canvas = getTextCanvas(dist);
956
+ var _canvas = getDistanceCanvas(dist, layer);
929
957
  var wid = _canvas.width / window.innerWidth * 30;
930
958
  var hei = _canvas.height / window.innerHeight * 30;
931
959
  var texture = new Three.Texture(_canvas);
@@ -1047,7 +1075,7 @@ function getLineDistance(obj, layer, isCalcWall, index) {
1047
1075
  obj.geometry.attributes.position.needsUpdate = true;
1048
1076
  var _dist = formatNumber(distance, DECIMAL_PLACES_2);
1049
1077
  if (_dist > 3) {
1050
- var _canvas2 = getTextCanvas(_dist);
1078
+ var _canvas2 = getDistanceCanvas(_dist, layer);
1051
1079
  var _wid = _canvas2.width / window.innerWidth * 30;
1052
1080
  var _hei = _canvas2.height / window.innerHeight * 30;
1053
1081
  var _texture = new Three.Texture(_canvas2);
@@ -1175,12 +1203,18 @@ export function getIntersectPoint(opX, opY, pX, pY) {
1175
1203
  function gcd(a, b) {
1176
1204
  return a % b ? gcd(b, a % b) : b;
1177
1205
  }
1178
- function getTextCanvas(text) {
1179
- var parameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1206
+ function getDistanceCanvas(distance, layer) {
1207
+ var _layer$unit;
1208
+ var parameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1180
1209
  var canvas = document.createElement('canvas');
1181
1210
  var ctx = canvas.getContext('2d');
1211
+ var curUnit = (_layer$unit = layer === null || layer === void 0 ? void 0 : layer.unit) !== null && _layer$unit !== void 0 ? _layer$unit : UNIT_INCH;
1212
+ var fixedLength = (layer === null || layer === void 0 ? void 0 : layer.unit) === UNIT_METER || (layer === null || layer === void 0 ? void 0 : layer.unit) === UNIT_FOOT ? 2 : 0;
1213
+ var distText = String((Math.round(convert(distance).from('in').to(curUnit) * 100) / 100).toFixed(fixedLength));
1182
1214
  var fontSize = 16;
1183
- var integral = String(text) + "''";
1215
+ var integral = distText + curUnit;
1216
+ // let integral = String(distance) + "''";
1217
+
1184
1218
  parameters.fontName = parameters.fontName || ARROW_TEXT_FONTFACE;
1185
1219
 
1186
1220
  // Prepare the font to be able to measure
@@ -3417,14 +3451,21 @@ export function updateMoldingGroupArray(MGArray, selItem, planData, layer) {
3417
3451
  if (changeMoldings.length === 0 && isEnableMolding) {
3418
3452
  // refresh mesh of the updating molding groups
3419
3453
  new_MGArray.forEach(function (mg, index) {
3420
- if (mg.items[0].molding.some(function (mol) {
3421
- return mol.location_type === mg.location_type;
3454
+ var _mg$items$;
3455
+ if ((_mg$items$ = mg.items[0]) !== null && _mg$items$ !== void 0 && (_mg$items$ = _mg$items$.molding) !== null && _mg$items$ !== void 0 && _mg$items$.some(function (mol) {
3456
+ var _mol$toJS;
3457
+ return isImmutable(mol) ? (mol === null || mol === void 0 || (_mol$toJS = mol.toJS()) === null || _mol$toJS === void 0 ? void 0 : _mol$toJS.location_type) === mg.location_type : (mol === null || mol === void 0 ? void 0 : mol.location_type) === mg.location_type;
3422
3458
  })) {
3423
- var molding = mg.items[0].molding.filter(function (mol) {
3424
- return mol.location_type === mg.location_type;
3459
+ var _mg$items$2, _mg$items$3, _mg$items$4;
3460
+ var molding = isImmutable((_mg$items$2 = mg.items[0]) === null || _mg$items$2 === void 0 ? void 0 : _mg$items$2.molding) ? (_mg$items$3 = mg.items[0]) === null || _mg$items$3 === void 0 || (_mg$items$3 = _mg$items$3.molding) === null || _mg$items$3 === void 0 ? void 0 : _mg$items$3.filter(function (mol) {
3461
+ var _mol$toJS2;
3462
+ return (mol === null || mol === void 0 || (_mol$toJS2 = mol.toJS()) === null || _mol$toJS2 === void 0 ? void 0 : _mol$toJS2.location_type) === mg.location_type;
3463
+ }).toJS()[0] : (_mg$items$4 = mg.items[0]) === null || _mg$items$4 === void 0 || (_mg$items$4 = _mg$items$4.molding) === null || _mg$items$4 === void 0 ? void 0 : _mg$items$4.filter(function (mol) {
3464
+ return (mol === null || mol === void 0 ? void 0 : mol.location_type) === mg.location_type;
3425
3465
  })[0];
3426
3466
  if (mg.molding === null || mg.molding.itemID !== mol.itemID || mg.lines === null || mg.points === null) {
3427
- if (mg.molding !== null && mg.molding.itemID !== molding.itemID) {
3467
+ var _mg$molding;
3468
+ if (mg.molding !== null && ((_mg$molding = mg.molding) === null || _mg$molding === void 0 ? void 0 : _mg$molding.itemID) !== molding.itemID) {
3428
3469
  deleteMGMesh(mg, planData, mode);
3429
3470
  }
3430
3471
  mg = MoldingUtils.createMonldingGroup(mg, layer, molding, planData.catalog);
@@ -254,12 +254,10 @@ var Viewer3DFirstPerson = /*#__PURE__*/function (_React$Component) {
254
254
  this.renderer.renderLists.dispose();
255
255
  }
256
256
  }, {
257
- key: "componentDidUpdate",
258
- value: function componentDidUpdate(prevProps) {
259
- var _this$props = this.props,
260
- width = _this$props.width,
261
- height = _this$props.height,
262
- state = _this$props.state;
257
+ key: "componentWillReceiveProps",
258
+ value: function componentWillReceiveProps(nextProps) {
259
+ var width = nextProps.width,
260
+ height = nextProps.height;
263
261
  var camera = this.camera,
264
262
  renderer = this.renderer,
265
263
  scene3D = this.scene3D,
@@ -272,27 +270,19 @@ var Viewer3DFirstPerson = /*#__PURE__*/function (_React$Component) {
272
270
  linesActions: this.context.linesActions,
273
271
  projectActions: this.context.projectActions
274
272
  };
275
-
276
- // Handle width/height changes
277
- if (width !== prevProps.width || height !== prevProps.height) {
278
- this.width = width;
279
- this.height = height;
280
- camera.aspect = width / height;
281
- camera.updateProjectionMatrix();
282
- renderer.setSize(width, height);
283
- }
284
-
285
- // Handle scene changes
286
- if (state.scene !== prevProps.state.scene) {
287
- var changedValues = diff(prevProps.state.scene, state.scene);
288
- updateScene(planData, state.scene, prevProps.state.scene, changedValues.toJS(), actions, this.context.catalog);
273
+ this.width = width;
274
+ this.height = height;
275
+ camera.aspect = width / height;
276
+ camera.updateProjectionMatrix();
277
+ if (nextProps.scene !== this.props.state.scene) {
278
+ var changedValues = diff(this.props.state.scene, nextProps.state.scene);
279
+ updateScene(planData, nextProps.state.scene, this.props.state.scene, changedValues.toJS(), actions, this.context.catalog);
289
280
  }
290
-
291
- // Always re-render after updates
292
- renderer.clear();
293
- renderer.render(scene3D, camera);
294
- renderer.clearDepth();
295
- renderer.render(sceneOnTop, camera);
281
+ renderer.setSize(width, height);
282
+ renderer.clear(); // clear buffers
283
+ renderer.render(scene3D, camera); // render scene 1
284
+ renderer.clearDepth(); // clear depth buffer
285
+ renderer.render(sceneOnTop, camera); // render scene 2
296
286
  }
297
287
  }, {
298
288
  key: "render",
@@ -308,4 +298,12 @@ Viewer3DFirstPerson.propTypes = {
308
298
  state: PropTypes.object.isRequired,
309
299
  width: PropTypes.number.isRequired,
310
300
  height: PropTypes.number.isRequired
301
+ };
302
+ Viewer3DFirstPerson.contextTypes = {
303
+ areaActions: PropTypes.object.isRequired,
304
+ holesActions: PropTypes.object.isRequired,
305
+ itemsActions: PropTypes.object.isRequired,
306
+ linesActions: PropTypes.object.isRequired,
307
+ projectActions: PropTypes.object.isRequired,
308
+ catalog: PropTypes.object
311
309
  };