kitchen-simulator 3.0.1 → 3.1.0-alpha.12

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 (43) hide show
  1. package/es/LiteKitchenConfigurator.js +42 -9
  2. package/es/LiteRenderer.js +5 -8
  3. package/es/actions/lines-actions.js +3 -1
  4. package/es/assets/img/png/helper/video_preview_start.png +0 -0
  5. package/es/catalog/factories/area-factory-3d.js +17 -17
  6. package/es/catalog/holes/window-clear/planner-element.js +2 -2
  7. package/es/catalog/utils/item-loader.js +198 -197
  8. package/es/class/item.js +11 -0
  9. package/es/class/line.js +14 -2
  10. package/es/components/viewer2d/item.js +41 -14
  11. package/es/components/viewer2d/rulerDist.js +1 -1
  12. package/es/components/viewer2d/utils.js +2 -2
  13. package/es/components/viewer2d/viewer2d.js +13 -11
  14. package/es/components/viewer3d/viewer3d.js +98 -96
  15. package/es/constants.js +6 -2
  16. package/es/devLiteRenderer.js +192 -98
  17. package/es/index.js +82 -13
  18. package/es/reducers/lines-reducer.js +1 -1
  19. package/es/utils/geometry.js +161 -0
  20. package/es/utils/isolate-event-handler.js +273 -116
  21. package/es/utils/molding.js +234 -2
  22. package/lib/LiteKitchenConfigurator.js +42 -9
  23. package/lib/LiteRenderer.js +5 -8
  24. package/lib/actions/lines-actions.js +3 -1
  25. package/lib/assets/img/png/helper/video_preview_start.png +0 -0
  26. package/lib/catalog/factories/area-factory-3d.js +14 -14
  27. package/lib/catalog/holes/window-clear/planner-element.js +2 -2
  28. package/lib/catalog/utils/item-loader.js +195 -194
  29. package/lib/class/item.js +11 -0
  30. package/lib/class/line.js +13 -1
  31. package/lib/components/viewer2d/item.js +40 -13
  32. package/lib/components/viewer2d/rulerDist.js +1 -1
  33. package/lib/components/viewer2d/utils.js +2 -2
  34. package/lib/components/viewer2d/viewer2d.js +13 -11
  35. package/lib/components/viewer3d/viewer3d.js +98 -96
  36. package/lib/constants.js +11 -7
  37. package/lib/devLiteRenderer.js +186 -92
  38. package/lib/index.js +82 -13
  39. package/lib/reducers/lines-reducer.js +1 -1
  40. package/lib/utils/geometry.js +162 -0
  41. package/lib/utils/isolate-event-handler.js +272 -115
  42. package/lib/utils/molding.js +233 -0
  43. package/package.json +1 -1
package/lib/class/item.js CHANGED
@@ -18,6 +18,7 @@ var _helper = require("../utils/helper");
18
18
  var _util = require("util");
19
19
  var _molding = require("../utils/molding");
20
20
  var _utils = require("../components/viewer2d/utils");
21
+ var _history = require("../utils/history");
21
22
  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; }
22
23
  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; }
23
24
  var allItemRect;
@@ -486,6 +487,9 @@ var Item = exports["default"] = /*#__PURE__*/function () {
486
487
  key: "storeDistArray",
487
488
  value: function storeDistArray(state, layerID, itemID, distArray) {
488
489
  var curDistArray = state.getIn(['scene', 'layers', layerID, 'items', itemID, 'distArray']);
490
+ distArray.forEach(function (dist) {
491
+ dist[0] < 0 ? dist[0] = 0 : dist[0];
492
+ });
489
493
  var isEqualDist = function isEqualDist(a, b) {
490
494
  return a == b;
491
495
  };
@@ -1152,6 +1156,7 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1152
1156
  for (var x in keys) {
1153
1157
  tmp[keys[x]] = doorStyle.doorStyles[keys[x]];
1154
1158
  }
1159
+ doorStyle.cds = itemCDS;
1155
1160
  state = state.setIn(['scene', 'layers', state.scene.selectedLayer, 'doorStyle'], doorStyle);
1156
1161
  state = state.merge({
1157
1162
  doorStyle: doorStyle
@@ -1544,6 +1549,9 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1544
1549
  });
1545
1550
  }
1546
1551
  }
1552
+ state = state.merge({
1553
+ sceneHistory: (0, _history.historyPush)(state.sceneHistory, state.scene)
1554
+ });
1547
1555
  return {
1548
1556
  updatedState: state
1549
1557
  };
@@ -1666,6 +1674,9 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1666
1674
  updateSelectItemMolding();
1667
1675
  }
1668
1676
  }
1677
+ state = state.merge({
1678
+ sceneHistory: (0, _history.historyPush)(state.sceneHistory, state.scene)
1679
+ });
1669
1680
  return {
1670
1681
  updatedState: state
1671
1682
  };
package/lib/class/line.js CHANGED
@@ -15,6 +15,7 @@ var _export2 = require("../utils/export");
15
15
  var Three = _interopRequireWildcard(require("three"));
16
16
  var _constants = require("../constants");
17
17
  var _helper = require("../utils/helper");
18
+ var _convertUnitsLite = require("../utils/convert-units-lite");
18
19
  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); }
19
20
  var timeGlobal = 0;
20
21
  var TimeRecorder = /*#__PURE__*/function () {
@@ -435,7 +436,7 @@ var Line = exports["default"] = /*#__PURE__*/function () {
435
436
  }
436
437
  }, {
437
438
  key: "beginDrawingLine",
438
- value: function beginDrawingLine(state, layerID, x, y) {
439
+ value: function beginDrawingLine(state, layerID, x, y, onInternalEvent) {
439
440
  // if end drawing by created area
440
441
  if (state.mode == _constants.MODE_IDLE) {
441
442
  return {
@@ -488,6 +489,17 @@ var Line = exports["default"] = /*#__PURE__*/function () {
488
489
  activeSnapElement: snap ? snap.snap : null,
489
490
  drawingSupport: drawingSupport
490
491
  });
492
+ var layer = state.getIn(['scene', 'layers', layerID]);
493
+ var payload = line.toJS();
494
+ var v_a = layer.vertices.get(line.vertices.get(0));
495
+ var v_b = layer.vertices.get(line.vertices.get(1));
496
+ var distance = _export2.GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
497
+ var _length = (0, _convertUnitsLite.convert)(distance).from('cm').to(layer.unit);
498
+ payload.length = _length;
499
+ if (onInternalEvent) onInternalEvent({
500
+ type: _constants.INTERNAL_EVENT_START_DRAW_WALL,
501
+ value: payload
502
+ });
491
503
  return {
492
504
  updatedState: state
493
505
  };
@@ -247,25 +247,38 @@ function Item(_ref, _ref2) {
247
247
  */
248
248
  var getDistant = function getDistant(x, y, rotRad) {
249
249
  var center_h = 3 * height / 8;
250
- var center_x = x;
250
+ var center_x = x; // middle of front line of cabinet rect
251
251
  var center_y = y;
252
- var center_x1 = x - center_h * Math.sin(rotRad);
252
+ var center_x1 = x - center_h * Math.sin(rotRad); // center point of cabinet rect
253
253
  var center_y1 = y + center_h * Math.cos(rotRad);
254
254
  var PointArray = [];
255
- curiteminfo.rectCenterPoint.forEach(function (centerpoint) {
256
- var comparelength = [];
255
+ var _loop = function _loop(i) {
256
+ var centerpoint = curiteminfo.rectCenterPoint[i];
257
+ // [rectCenterPoint] has four middle points of cabinet rect edges
258
+ var comparelength = []; // distance array from rectCenterPoint[i] to other lines(walls, other cabinet rect edges)
257
259
  var a;
258
- var RectLineFuction;
260
+ var RectLineFuction; // normal line of cabinet rect edge
259
261
  if (centerpoint[1] === 180 || centerpoint[1] === 0) RectLineFuction = _export.GeometryUtils.linePassingThroughTwoPoints(centerpoint[0].x, centerpoint[0].y, center_x1, center_y1);else RectLineFuction = _export.GeometryUtils.linePassingThroughTwoPoints(centerpoint[0].x, centerpoint[0].y, center_x, center_y);
260
262
  allRect.forEach(function (linerect) {
263
+ // calc distance to all other lines
261
264
  var p0 = _export.GeometryUtils.clone_point(linerect.rect[2]);
262
265
  var p1 = _export.GeometryUtils.clone_point(linerect.rect[3]);
263
- var lineFunction = {};
266
+ var lineFunction = {}; // other line function
264
267
  if (p0.x !== p1.x || p0.y !== p1.y) lineFunction = _export.GeometryUtils.linePassingThroughTwoPoints(p0.x, p0.y, p1.x, p1.y);
268
+ // intersection between normal line and other line
265
269
  var coordinatePoint = _export.GeometryUtils.twoLinesIntersection(lineFunction.a, lineFunction.b, lineFunction.c, RectLineFuction.a, RectLineFuction.b, RectLineFuction.c);
266
270
  if (coordinatePoint !== undefined) {
267
- if (_export.GeometryUtils.pointsDistance(p0.x, p0.y, p1.x, p1.y) > _export.GeometryUtils.pointsDistance(p0.x, p0.y, coordinatePoint.x, coordinatePoint.y) && _export.GeometryUtils.pointsDistance(p0.x, p0.y, p1.x, p1.y) > _export.GeometryUtils.pointsDistance(p1.x, p1.y, coordinatePoint.x, coordinatePoint.y)) {
268
- if (_export.GeometryUtils.pointsDistance(coordinatePoint.x, coordinatePoint.y, center_x, center_y) > _export.GeometryUtils.pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y)) {
271
+ if (
272
+ // intersection point is on the other line
273
+ _export.GeometryUtils.pointsDistance(p0.x, p0.y, p1.x, p1.y) > _export.GeometryUtils.pointsDistance(p0.x, p0.y, coordinatePoint.x, coordinatePoint.y) && _export.GeometryUtils.pointsDistance(p0.x, p0.y, p1.x, p1.y) > _export.GeometryUtils.pointsDistance(p1.x, p1.y, coordinatePoint.x, coordinatePoint.y)) {
274
+ // check the intersection point is outside direction of edge
275
+ var isOutside = true;
276
+ for (var j = 0; j < curiteminfo.rectCenterPoint.length; j++) {
277
+ if (j === i) continue;
278
+ var otherCenterPoint = curiteminfo.rectCenterPoint[j];
279
+ if (_export.GeometryUtils.isPointOnLineSegment(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y, otherCenterPoint[0].x, otherCenterPoint[0].y)) isOutside = false;
280
+ }
281
+ if (isOutside && _export.GeometryUtils.pointsDistance(coordinatePoint.x, coordinatePoint.y, center_x, center_y) > _export.GeometryUtils.pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y)) {
269
282
  comparelength.push(_export.GeometryUtils.pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y));
270
283
  a = Math.min.apply(null, comparelength);
271
284
  }
@@ -273,7 +286,10 @@ function Item(_ref, _ref2) {
273
286
  }
274
287
  });
275
288
  PointArray.push([a, centerpoint[1]]);
276
- });
289
+ };
290
+ for (var i = 0; i < curiteminfo.rectCenterPoint.length; i++) {
291
+ _loop(i);
292
+ }
277
293
  return {
278
294
  PointArray: PointArray
279
295
  };
@@ -286,10 +302,18 @@ function Item(_ref, _ref2) {
286
302
  var cat = catalog.elements[catid];
287
303
  PointArray.forEach(function (pointElement, index) {
288
304
  if (pointElement[0] == undefined) PointArray[index][0] = 0;
289
- if (pointElement[1] === -90 && cat.info.is_corner !== 1) {
290
- PointArray[index][0] -= 4;
291
- }
305
+ // if (pointElement[1] === -90 && cat.info.is_corner !== 1) {
306
+ // PointArray[index][0] -= 4;
307
+ // }
308
+ });
309
+ var cnt = 0;
310
+ PointArray.forEach(function (pointElement) {
311
+ if (pointElement[0] == 0) cnt++;
292
312
  });
313
+ if (cnt == 4 || cnt == 3) {
314
+ PointArray[0][0] = 100;
315
+ PointArray[1][0] = 100;
316
+ }
293
317
  if (Array.isArray(PointArray)) {
294
318
  itemsActions.storeDistArray(layerID, id, PointArray);
295
319
  }
@@ -399,7 +423,10 @@ function Item(_ref, _ref2) {
399
423
  y: "-19",
400
424
  height: "16",
401
425
  width: "16",
402
- style: {
426
+ style: (0, _utils.isWarningItem)(item) ? {
427
+ transform: 'rotateX(180deg)',
428
+ opacity: 0.5
429
+ } : {
403
430
  transform: 'rotateX(180deg)'
404
431
  }
405
432
  })), /*#__PURE__*/_react["default"].createElement("g", {
@@ -41,7 +41,7 @@ function RulerDist(_ref) {
41
41
  var _unit = 'in';
42
42
  // let _length = convert(length).from(unit).to(rulerUnit);
43
43
  var distanceText = "".concat((0, _convertUnitsLite.convert)(length).from('cm').to(rulerUnit).toFixed(0));
44
- var textLength = (distanceText.length + layer.unit.length) * 18;
44
+ var textLength = (distanceText.length + layer.unit.length) * 8;
45
45
  var textangle = angle + 90;
46
46
  var textRotation = 1;
47
47
  var ay = 2;
@@ -201,7 +201,7 @@ var areaPolygon = exports.areaPolygon = function areaPolygon(points) {
201
201
  };
202
202
  var isWarningItem = exports.isWarningItem = function isWarningItem(item) {
203
203
  var _item$toJS$doorStyle;
204
- return !(item !== null && item !== void 0 && (_item$toJS$doorStyle = item.toJS().doorStyle) !== null && _item$toJS$doorStyle !== void 0 && (_item$toJS$doorStyle = _item$toJS$doorStyle.doorStyles) !== null && _item$toJS$doorStyle !== void 0 && (_item$toJS$doorStyle = _item$toJS$doorStyle.cds) !== null && _item$toJS$doorStyle !== void 0 && _item$toJS$doorStyle.filter(function (cd) {
204
+ if (item.category === 'cabinet') return !(item !== null && item !== void 0 && (_item$toJS$doorStyle = item.toJS().doorStyle) !== null && _item$toJS$doorStyle !== void 0 && (_item$toJS$doorStyle = _item$toJS$doorStyle.doorStyles) !== null && _item$toJS$doorStyle !== void 0 && (_item$toJS$doorStyle = _item$toJS$doorStyle.cds) !== null && _item$toJS$doorStyle !== void 0 && _item$toJS$doorStyle.filter(function (cd) {
205
205
  return cd.itemID == (item === null || item === void 0 ? void 0 : item.getIn(['itemID']));
206
- }).length) > 0;
206
+ }).length) > 0;else return false;
207
207
  };
@@ -956,7 +956,7 @@ function Viewer2D(_ref, _ref2) {
956
956
  case 'items':
957
957
  if (elementData.part === 'duplicate') {
958
958
  var currentObject = state.getIn(['scene', 'layers', layerID, 'items', elementData.id]);
959
- itemsActions.duplicateSelected(currentObject, onInternalEvent); // send draw internal event when duplicating
959
+ if (!(0, _utils.isWarningItem)(currentObject)) itemsActions.duplicateSelected(currentObject, onInternalEvent); // send draw internal event when duplicating
960
960
  break;
961
961
  } else if (elementData.part === 'remove') {
962
962
  projectActions.remove();
@@ -981,7 +981,7 @@ function Viewer2D(_ref, _ref2) {
981
981
  id: "ruler_numberInput",
982
982
  style: {
983
983
  position: 'absolute',
984
- left: bbox.left - (150 - bbox.width) / 2,
984
+ left: bbox.left - (200 - bbox.width) / 2,
985
985
  top: bbox.top - (50 - bbox.height) / 2,
986
986
  zIndex: 1000
987
987
  }
@@ -1013,7 +1013,7 @@ function Viewer2D(_ref, _ref2) {
1013
1013
  id: "ruler_numberInput",
1014
1014
  style: {
1015
1015
  position: 'absolute',
1016
- left: bbox.left - (150 - bbox.width) / 2,
1016
+ left: bbox.left - (200 - bbox.width) / 2,
1017
1017
  top: bbox.top - (50 - bbox.height) / 2,
1018
1018
  zIndex: 1000
1019
1019
  }
@@ -1046,7 +1046,7 @@ function Viewer2D(_ref, _ref2) {
1046
1046
  id: "ruler_numberInput",
1047
1047
  style: {
1048
1048
  position: 'absolute',
1049
- left: bbox.left - (150 - bbox.width) / 2,
1049
+ left: bbox.left - (200 - bbox.width) / 2,
1050
1050
  top: bbox.top - (50 - bbox.height) / 2,
1051
1051
  zIndex: 1000
1052
1052
  }
@@ -1079,7 +1079,7 @@ function Viewer2D(_ref, _ref2) {
1079
1079
  id: "ruler_numberInput",
1080
1080
  style: {
1081
1081
  position: 'absolute',
1082
- left: bbox.left - (150 - bbox.width) / 2,
1082
+ left: bbox.left - (200 - bbox.width) / 2,
1083
1083
  top: bbox.top - (50 - bbox.height) / 2,
1084
1084
  zIndex: 1000
1085
1085
  }
@@ -1112,7 +1112,7 @@ function Viewer2D(_ref, _ref2) {
1112
1112
  id: "ruler_numberInput",
1113
1113
  style: {
1114
1114
  position: 'absolute',
1115
- left: bbox.left - (150 - bbox.width) / 2,
1115
+ left: bbox.left - (200 - bbox.width) / 2,
1116
1116
  top: bbox.top - (50 - bbox.height) / 2,
1117
1117
  zIndex: 1000
1118
1118
  }
@@ -1145,7 +1145,7 @@ function Viewer2D(_ref, _ref2) {
1145
1145
  id: "ruler_numberInput",
1146
1146
  style: {
1147
1147
  position: 'absolute',
1148
- left: bbox.left - (150 - bbox.width) / 2,
1148
+ left: bbox.left - (200 - bbox.width) / 2,
1149
1149
  top: bbox.top - (50 - bbox.height) / 2,
1150
1150
  zIndex: 1000
1151
1151
  }
@@ -1177,7 +1177,7 @@ function Viewer2D(_ref, _ref2) {
1177
1177
  id: "ruler_numberInput",
1178
1178
  style: {
1179
1179
  position: 'absolute',
1180
- left: bbox.left - (150 - bbox.width) / 2,
1180
+ left: bbox.left - (200 - bbox.width) / 2,
1181
1181
  top: bbox.top - (50 - bbox.height) / 2,
1182
1182
  zIndex: 1000
1183
1183
  }
@@ -1207,7 +1207,7 @@ function Viewer2D(_ref, _ref2) {
1207
1207
  break;
1208
1208
  case constants.MODE_WAITING_DRAWING_LINE:
1209
1209
  setdrawStart(true);
1210
- linesActions.beginDrawingLine(layerID, x, y, state.snapMask);
1210
+ linesActions.beginDrawingLine(layerID, x, y, state.snapMask, onInternalEvent);
1211
1211
  break;
1212
1212
  case constants.MODE_DRAWING_LINE:
1213
1213
  // Blocked 90 degree snap.
@@ -1221,7 +1221,7 @@ function Viewer2D(_ref, _ref2) {
1221
1221
  getConnectedLines();
1222
1222
  var endInfor = getEndPoint(vertices, x, y, 'END_DRAWIN_LINE');
1223
1223
  linesActions.endDrawingLine(endInfor.x, endInfor.y, state.snapMask);
1224
- linesActions.beginDrawingLine(layerID, endInfor.x, endInfor.y, state.snapMask);
1224
+ linesActions.beginDrawingLine(layerID, endInfor.x, endInfor.y, state.snapMask, onInternalEvent);
1225
1225
  break;
1226
1226
  case constants.MODE_DRAWING_HOLE:
1227
1227
  holesActions.endDrawingHole(layerID, x, y);
@@ -1266,12 +1266,14 @@ function Viewer2D(_ref, _ref2) {
1266
1266
  var v_a = layer.vertices.get(_currentObject.vertices.get(0));
1267
1267
  var v_b = layer.vertices.get(_currentObject.vertices.get(1));
1268
1268
  var distance = _export2.GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
1269
- var _length3 = (0, _convertUnitsLite.convert)(distance).from('cm').to('in');
1269
+ var _length3 = (0, _convertUnitsLite.convert)(distance).from('cm').to(layer.unit);
1270
1270
  payload.length = _length3;
1271
1271
  //////////////////////////////////////
1272
1272
  } else if (((_currentObject5 = _currentObject) === null || _currentObject5 === void 0 ? void 0 : _currentObject5.prototype) === 'items') {
1273
1273
  // check this cabinet has warning box
1274
1274
  payload.isWarning = (0, _utils.isWarningItem)(_currentObject);
1275
+ // check this item is available molding
1276
+ payload.isMoldingAvailable = _export2.MoldingUtils.isEnableItemForMolding(layer, _currentObject);
1275
1277
  // check this item is snapped to wall
1276
1278
  payload.isAttachedWall = _export2.MoldingUtils.isAttachedWall(layer, _currentObject);
1277
1279
  }
@@ -1190,6 +1190,34 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1190
1190
  itemID: selItemId
1191
1191
  };
1192
1192
  };
1193
+ var sendInternalEvent = function sendInternalEvent(evtType, evtElement) {
1194
+ var pointArray = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
1195
+ if (!(0, _helper.isEmpty)(evtType) && !(0, _helper.isEmpty)(evtElement)) {
1196
+ var _this2$props$onIntern, _this2$props;
1197
+ var payload = evtElement === null || evtElement === void 0 ? void 0 : evtElement.toJS();
1198
+ if ((evtElement === null || evtElement === void 0 ? void 0 : evtElement.prototype) === 'lines') {
1199
+ // caculating length of selected line//
1200
+ var v_a = layer.vertices.get(evtElement.vertices.get(0));
1201
+ var v_b = layer.vertices.get(evtElement.vertices.get(1));
1202
+ var distance = _export.GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
1203
+ var _length = (0, _convertUnitsLite.convert)(distance).from('cm').to(layer.unit);
1204
+ payload.length = _length;
1205
+ //////////////////////////////////////
1206
+ } else if ((evtElement === null || evtElement === void 0 ? void 0 : evtElement.prototype) === 'items') {
1207
+ // check this cabinet has warning box
1208
+ payload.isWarning = (0, _utils.isWarningItem)(evtElement);
1209
+ // check this item is available molding
1210
+ payload.isMoldingAvailable = _export.MoldingUtils.isEnableItemForMolding(layer, evtElement); // check this item is snapped to wall
1211
+ payload.isAttachedWall = _export.MoldingUtils.isAttachedWall(layer, evtElement);
1212
+ // update distArray
1213
+ if (pointArray) payload.distArray = pointArray;
1214
+ }
1215
+ (_this2$props$onIntern = (_this2$props = _this2.props).onInternalEvent) === null || _this2$props$onIntern === void 0 || _this2$props$onIntern.call(_this2$props, {
1216
+ type: evtType,
1217
+ value: payload
1218
+ });
1219
+ }
1220
+ };
1193
1221
  this.mouseDownEvent = function (event) {
1194
1222
  gridPlanOrigin = gridPlane.position;
1195
1223
  gridMatrix.copy(gridPlane.matrixWorld).invert();
@@ -1341,11 +1369,6 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1341
1369
  if (selectedFlag || toolIntersects.length > 0 && !(0, _helper.isElevationView)(mode)) {
1342
1370
  cameraControls.mouseButtons.left = _cameraControls["default"].ACTION.NONE;
1343
1371
  selectedFlag = false;
1344
- } else {
1345
- isSelected = false;
1346
- _this2.context.projectActions.unselectAll();
1347
- scene3D.remove(toolObj);
1348
- _this2.context.itemsActions.removeReplacingSupport();
1349
1372
  }
1350
1373
  }
1351
1374
  } else {
@@ -1398,11 +1421,18 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1398
1421
  }
1399
1422
  switch (_this2.props.state.mode) {
1400
1423
  case _constants.MODE_DRAGGING_ITEM_3D:
1424
+ case _constants.MODE_DRAGGING_HOLE_3D:
1401
1425
  internalType = _constants.INTERNAL_EVENT_DRAG_ELEMENT;
1402
1426
  break;
1403
1427
  case _constants.MODE_ROTATING_ITEM_3D:
1404
1428
  internalType = _constants.INTERNAL_EVENT_ROTATE_ELEMENT;
1405
1429
  break;
1430
+ case _constants.MODE_DRAWING_HOLE_3D:
1431
+ internalType = _constants.INTERNAL_EVENT_DRAW_ELEMENT;
1432
+ break;
1433
+ case _constants.MODE_IDLE_3D:
1434
+ internalType = _constants.INTERNAL_EVENT_SELECT_ELEMENT;
1435
+ break;
1406
1436
  }
1407
1437
  if (_this2.props.state.mode == _constants.MODE_DRAGGING_ITEM_3D) {
1408
1438
  _this2.context.itemsActions.endDraggingItem3D();
@@ -1436,7 +1466,8 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1436
1466
  });
1437
1467
  });
1438
1468
  var intersects = raycaster.intersectObjects(meshes, true);
1439
- var _i10;
1469
+ var _i10; // index of warning object in intersects
1470
+
1440
1471
  if (intersects.length > 0 && !isNaN(intersects[0].distance)) {
1441
1472
  for (_i10 = 0; _i10 < intersects.length; _i10++) {
1442
1473
  if (intersects[_i10].object.name === 'warningObj') break;
@@ -1464,6 +1495,19 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1464
1495
  }
1465
1496
  }
1466
1497
  gridMatrix.copy(gridPlane.matrixWorld).invert();
1498
+ var addItemToolObj = function addItemToolObj() {
1499
+ var _intersects$_i;
1500
+ var selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1501
+ if ((0, _util.isUndefined)(selectedItem)) return;
1502
+ selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1503
+ var itemPos = selectedItem.position.clone();
1504
+ if (((_intersects$_i = intersects[_i10]) === null || _intersects$_i === void 0 || (_intersects$_i = _intersects$_i.object) === null || _intersects$_i === void 0 || (_intersects$_i = _intersects$_i.parent) === null || _intersects$_i === void 0 || (_intersects$_i = _intersects$_i.parent) === null || _intersects$_i === void 0 || (_intersects$_i = _intersects$_i.userData) === null || _intersects$_i === void 0 ? void 0 : _intersects$_i.itemId) === selectedItem.userData.itemId) {
1505
+ toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
1506
+ } else {
1507
+ toolObj.position.set(planData.plan.position.x + itemPos.x, selectedElement.category === 'lighting' ? -planData.plan.position.y - selectedElement.properties.get('height').get('length') : planData.plan.position.y + selectedItem.children[0].position.y, planData.plan.position.z + itemPos.z);
1508
+ }
1509
+ scene3D.add(toolObj);
1510
+ };
1467
1511
  if (Math.abs(mouse.x - _this2.lastMousePosition.x) <= 0.02 && Math.abs(mouse.y - _this2.lastMousePosition.y) <= 0.02 || bMove) {
1468
1512
  if (intersects.length > 0 && !isNaN(intersects[0].distance)) {
1469
1513
  if (intersects[_i10] === undefined) {
@@ -1485,55 +1529,40 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1485
1529
  currentObject = currentObject.parent;
1486
1530
  }
1487
1531
  isSelected = true;
1488
- (0, _sceneCreator.getDistances)(layer);
1489
- var selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1490
- if ((0, _util.isUndefined)(selectedItem)) return;
1491
- selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1492
- var itemPos = selectedItem.position.clone();
1493
- if (intersects[_i10].object.parent && intersects[_i10].object.parent.parent.userData.itemId === selectedItem.userData.itemId) {
1494
- toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
1495
- } else {
1496
- toolObj.position.set(planData.plan.position.x + itemPos.x, selectedElement.category === 'lighting' ? -planData.plan.position.y - selectedElement.properties.get('height').get('length') : planData.plan.position.y + selectedItem.children[0].position.y, planData.plan.position.z + itemPos.z);
1497
- }
1498
- scene3D.add(toolObj);
1499
- _this2.setState({
1500
- toolObj: toolObj
1501
- });
1502
- // showItemButtons(layer.getIn(['items', selectedObject.itemID]), currentObject, event, camera, this.renderer);
1503
- var pointArray = [],
1504
- cnt = 0;
1505
- pointArray.push([_sceneCreator.fVLine[0].userData.distance, 90]);
1506
- pointArray.push([_sceneCreator.fVLine[1].userData.distance, -90]);
1507
- pointArray.push([_sceneCreator.fVLine[2].userData.distance, 180]);
1508
- pointArray.push([_sceneCreator.fVLine[3].userData.distance, 0]);
1509
- pointArray.forEach(function (pointElement, index) {
1510
- if (pointElement[0] == undefined) pointArray[index][0] = 0;
1511
- });
1512
- pointArray.forEach(function (pointElement) {
1513
- if (pointElement[0] == 0) cnt++;
1532
+ setTimeout(function () {
1533
+ (0, _sceneCreator.getDistances)(layer);
1534
+ addItemToolObj();
1535
+ _this2.setState({
1536
+ toolObj: toolObj
1537
+ });
1538
+ // showItemButtons(layer.getIn(['items', selectedObject.itemID]), currentObject, event, camera, this.renderer);
1539
+ var pointArray = [];
1540
+ // pointArray.push([fVLine[0].userData.distance, 90]);
1541
+ // pointArray.push([fVLine[1].userData.distance, -90]);
1542
+ // pointArray.push([fVLine[2].userData.distance, 180]);
1543
+ // pointArray.push([fVLine[3].userData.distance, 0]);
1544
+ pointArray = _export.GeometryUtils.calcDistancesFromItemToWalls(selectedElement, layer).PointArray;
1545
+ actions.itemsActions.storeDistArray(layer.id, selectedObject.itemID, pointArray);
1546
+ internalType = internalType ? internalType : _constants.INTERNAL_EVENT_SELECT_ELEMENT;
1547
+ sendInternalEvent(internalType, selectedElement, pointArray);
1514
1548
  });
1515
- if (cnt == 4 || cnt == 3) {
1516
- pointArray[0][0] = 100;
1517
- pointArray[1][0] = 100;
1518
- }
1519
- actions.itemsActions.storeDistArray(layer.id, selectedObject.itemID, pointArray);
1520
- internalType = internalType ? internalType : _constants.INTERNAL_EVENT_SELECT_ELEMENT;
1521
1549
  } else {
1522
1550
  if (selectedObject) {
1523
1551
  var elementID = null;
1524
1552
  var elementPrototype = null;
1525
1553
  switch (true) {
1526
1554
  case 'holeID' in selectedObject:
1527
- case 'lineID' in selectedObject:
1555
+ elementID = selectedObject.holeID;
1556
+ elementPrototype = 'holes';
1528
1557
  if (_this2.props.state.mode === _constants.MODE_DRAGGING_HOLE_3D) {
1529
1558
  actions.holesActions.endDraggingHole3D(sPoint.x, sPoint.y);
1530
- internalType = _constants.INTERNAL_EVENT_SELECT_ELEMENT;
1531
- elementID = selectedObject.holeID;
1532
- elementPrototype = 'holes';
1533
1559
  }
1534
1560
  break;
1561
+ case 'lineID' in selectedObject:
1562
+ elementID = selectedObject.lineID;
1563
+ elementPrototype = 'lines';
1564
+ break;
1535
1565
  case 'areaID' in selectedObject:
1536
- internalType = _constants.INTERNAL_EVENT_SELECT_ELEMENT;
1537
1566
  elementID = selectedObject.areaID;
1538
1567
  elementPrototype = 'areas';
1539
1568
  break;
@@ -1545,15 +1574,20 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1545
1574
  isSelected = false;
1546
1575
  }
1547
1576
  } else {
1548
- isSelected = false;
1549
- _this2.context.projectActions.unselectAll();
1550
- switch (true) {
1551
- case 'holeID' in selectedObject:
1552
- actions.holesActions.endDraggingHole3D(sPoint.x, sPoint.y);
1553
- break;
1554
- default:
1555
- _this2.context.itemsActions.removeReplacingSupport();
1556
- break;
1577
+ var selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1578
+ if (bMove && !(0, _helper.isEmpty)(selectedItem)) {
1579
+ addItemToolObj();
1580
+ } else {
1581
+ isSelected = false;
1582
+ _this2.context.projectActions.unselectAll();
1583
+ switch (true) {
1584
+ case 'holeID' in selectedObject:
1585
+ actions.holesActions.endDraggingHole3D(sPoint.x, sPoint.y);
1586
+ break;
1587
+ default:
1588
+ _this2.context.itemsActions.removeReplacingSupport();
1589
+ break;
1590
+ }
1557
1591
  }
1558
1592
  }
1559
1593
  bMove = false;
@@ -1574,35 +1608,15 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1574
1608
  }
1575
1609
  getPoint(event, alti);
1576
1610
  if (bRotate) {
1577
- var _intersects$_i;
1578
- var _selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1579
- if ((0, _util.isUndefined)(_selectedItem)) return;
1580
- selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1581
- var _itemPos = _selectedItem.position.clone();
1582
- if (((_intersects$_i = intersects[_i10]) === null || _intersects$_i === void 0 || (_intersects$_i = _intersects$_i.object) === null || _intersects$_i === void 0 || (_intersects$_i = _intersects$_i.parent) === null || _intersects$_i === void 0 || (_intersects$_i = _intersects$_i.parent) === null || _intersects$_i === void 0 || (_intersects$_i = _intersects$_i.userData) === null || _intersects$_i === void 0 ? void 0 : _intersects$_i.itemId) === _selectedItem.userData.itemId) {
1583
- toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
1584
- } else {
1585
- toolObj.position.set(planData.plan.position.x + _itemPos.x, selectedElement.category === 'lighting' ? -planData.plan.position.y - selectedElement.properties.get('height').get('length') : planData.plan.position.y + _selectedItem.children[0].position.y, planData.plan.position.z + _itemPos.z);
1586
- }
1587
- scene3D.add(toolObj);
1611
+ addItemToolObj();
1588
1612
  _this2.setState({
1589
1613
  toolObj: toolObj
1590
1614
  });
1591
1615
  _this2.context.itemsActions.endRotatingItem3D(Point.x, Point.y);
1592
1616
  bRotate = false;
1593
- }
1594
- if (bMove) {
1617
+ } else if (bMove) {
1595
1618
  bMove = false;
1596
- var _selectedItem2 = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1597
- if ((0, _util.isUndefined)(_selectedItem2)) return;
1598
- selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1599
- var _itemPos2 = _selectedItem2.position.clone();
1600
- if (intersects[_i10].object.parent.parent.userData.itemId === _selectedItem2.userData.itemId) {
1601
- toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
1602
- } else {
1603
- toolObj.position.set(planData.plan.position.x + _itemPos2.x, selectedElement.category === 'lighting' ? -planData.plan.position.y - selectedElement.properties.get('height').get('length') : planData.plan.position.y + _selectedItem2.children[0].position.y, planData.plan.position.z + _itemPos2.z);
1604
- }
1605
- scene3D.add(toolObj);
1619
+ addItemToolObj();
1606
1620
  _this2.setState({
1607
1621
  toolObj: toolObj
1608
1622
  });
@@ -1622,7 +1636,7 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1622
1636
  _item3D.position.z = targetPoint.z;
1623
1637
  _item3D.visible = true;
1624
1638
  }
1625
- }
1639
+ } else {}
1626
1640
  if (bMoveUP) {
1627
1641
  bMoveUP = false;
1628
1642
  }
@@ -1634,20 +1648,7 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1634
1648
  selectedObj = allItemRect.cur;
1635
1649
  }
1636
1650
  }
1637
- if (!(0, _helper.isEmpty)(internalType)) {
1638
- var _selectedElement, _selectedElement2, _this2$props$onIntern, _this2$props;
1639
- var payload = (_selectedElement = selectedElement) === null || _selectedElement === void 0 ? void 0 : _selectedElement.toJS();
1640
- if (((_selectedElement2 = selectedElement) === null || _selectedElement2 === void 0 ? void 0 : _selectedElement2.prototype) === 'items') {
1641
- // check this cabinet has warning box
1642
- payload.isWarning = (0, _utils.isWarningItem)(selectedElement);
1643
- // check this item is snapped to wall
1644
- payload.isAttachedWall = _export.MoldingUtils.isAttachedWall(layer, selectedElement);
1645
- }
1646
- (_this2$props$onIntern = (_this2$props = _this2.props).onInternalEvent) === null || _this2$props$onIntern === void 0 || _this2$props$onIntern.call(_this2$props, {
1647
- type: internalType,
1648
- value: payload
1649
- });
1650
- }
1651
+ sendInternalEvent(internalType, selectedElement);
1651
1652
  };
1652
1653
  this.mouseEnterEvent = function (event) {
1653
1654
  if (_this2.props.state.mode !== _constants.MODE_DRAWING_ITEM_3D) return;
@@ -2082,7 +2083,7 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
2082
2083
  if (minDis < snapDelta && !snapFlag) {
2083
2084
  _this2.snap(snapObj, layer);
2084
2085
  snapFlag = true;
2085
- (0, _sceneCreator.getDistances)(layer, true);
2086
+ (0, _sceneCreator.getDistances)(layer);
2086
2087
  var _i13 = 0;
2087
2088
  for (_i13 = 0; _i13 < _sceneCreator.fVLine.length; _i13++) {
2088
2089
  if (_sceneCreator.fVLine[_i13].userData.distance < snapDelta) {
@@ -2615,9 +2616,10 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
2615
2616
  }, /*#__PURE__*/_react["default"].createElement("img", {
2616
2617
  style: {
2617
2618
  animation: 'spin 2s linear infinite',
2618
- marginTop: "50%",
2619
- width: '50px',
2620
- height: '50px'
2619
+ position: "absolute",
2620
+ top: "50%",
2621
+ width: '70px',
2622
+ height: '70px'
2621
2623
  },
2622
2624
  src: '/assets/img/loading/loading.gif',
2623
2625
  alt: "img"
@@ -2637,8 +2639,8 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
2637
2639
  animation: 'spin 2s linear infinite',
2638
2640
  position: "absolute",
2639
2641
  top: "50%",
2640
- width: '50px',
2641
- height: '50px'
2642
+ width: '70px',
2643
+ height: '70px'
2642
2644
  },
2643
2645
  src: '/assets/img/loading/loading.gif',
2644
2646
  alt: "img"