kitchen-simulator 3.1.10 → 3.1.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.
@@ -5,11 +5,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
5
5
  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; } } }; }
6
6
  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; } }
7
7
  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; }
8
- import { BASE_CABINET_LAYOUTPOS, BOTTOM_MOLDING_LOCATION, EPSILON, MIDDLE_MOLDING_LOCATION, MOLDING_LOCATIONS, OVERLAP_INCLUDED, OVERLAP_LINK, OVERLAP_SAME, OVERLAP_SOME, TALL_CABINET_LAYOUTPOS, TOP_MOLDING_LOCATION, WALL_CABINET_LAYOUTPOS } from "../constants";
8
+ import { BASE_CABINET_LAYOUTPOS, BOTTOM_MOLDING_LOCATION, EPSILON, MIDDLE_MOLDING_LOCATION, MOLDING_LOCATIONS, OVERLAP_INCLUDED, OVERLAP_LINK, OVERLAP_SAME, OVERLAP_SOME, TALL_CABINET_LAYOUTPOS, TOE_KICK_MOLDING, TOP_MOLDING_LOCATION, WALL_CABINET_LAYOUTPOS } from "../constants";
9
9
  import * as Three from 'three';
10
10
  import { convert } from "./convert-units-lite";
11
11
  import IDBroker from "./id-broker";
12
- import { returnReplaceableDeepSearchType } from "../components/viewer2d/utils";
12
+ import { getToeKickSKU, isEqualInstallationType, returnReplaceableDeepSearchType } from "../components/viewer2d/utils";
13
13
  import { GeometryUtils } from "./export";
14
14
  import { isEmpty } from "./helper";
15
15
  export function getItemRect(item) {
@@ -866,4 +866,236 @@ export function createMonldingGroup(oldMG, layer, molding, catalog) {
866
866
  newMG.lines.reverse();
867
867
  newMG = getMDPoints(newMG);
868
868
  return newMG;
869
+ }
870
+ export function getMoldingDataOfScene(layer, catalog, doorStyle) {
871
+ var moldingData = [];
872
+ var items = layer.items.toArray();
873
+ var moldings = [];
874
+ // get all moldings info
875
+ items.forEach(function (itemCat) {
876
+ var _itemCat$molding;
877
+ itemCat === null || itemCat === void 0 || (_itemCat$molding = itemCat.molding) === null || _itemCat$molding === void 0 || _itemCat$molding.forEach(function (molding) {
878
+ if (!moldings.some(function (m) {
879
+ return m.name === molding.name;
880
+ })) moldings.push(molding);
881
+ });
882
+ });
883
+
884
+ // calc normal molding
885
+ moldings.forEach(function (molding) {
886
+ var itemGroups = [];
887
+ var temp_items = [];
888
+ items.forEach(function (item) {
889
+ if (item.molding.some(function (mol) {
890
+ return mol.itemID === molding.itemID;
891
+ }) && isEnableItemForMolding(layer, item)) {
892
+ temp_items.push(item);
893
+ }
894
+ });
895
+ if (temp_items.length) {
896
+ while (temp_items.length > 0) {
897
+ var itemGroup = [temp_items[0]];
898
+ var _loop9 = function _loop9(_idx) {
899
+ if (!itemGroup.some(function (it) {
900
+ return it.id === temp_items[_idx].id;
901
+ }) && isItemSnappedGroup(temp_items[_idx], itemGroup)) {
902
+ itemGroup.push(temp_items[_idx]);
903
+ _idx = 0;
904
+ }
905
+ idx = _idx;
906
+ };
907
+ for (var idx = 0; idx < temp_items.length; idx++) {
908
+ _loop9(idx);
909
+ }
910
+ itemGroup.forEach(function (item) {
911
+ var index = temp_items.findIndex(function (it) {
912
+ return it.id === item.id;
913
+ });
914
+ if (index > -1) {
915
+ temp_items.splice(index, 1);
916
+ }
917
+ });
918
+ itemGroups.push(itemGroup);
919
+ }
920
+ var molding_totalLength = 0;
921
+ itemGroups.forEach(function (itemgroup) {
922
+ var allLineRects = GeometryUtils.buildRectFromLines(layer, GeometryUtils.getAllLines(layer));
923
+ var items = _toConsumableArray(itemgroup);
924
+ var MGlines = getLinesOfItem(items[0], allLineRects, catalog);
925
+ items = sortItemsByDistance(items, items[0]);
926
+ var _loop0 = function _loop0() {
927
+ var itemLines = getLinesOfItem(items[i], allLineRects, catalog);
928
+ var temp_MGLines = [];
929
+ MGlines.forEach(function (line) {
930
+ var idx = itemLines.findIndex(function (itemLine) {
931
+ return isLinesOverlapped(line, itemLine);
932
+ });
933
+ var curItemLine = itemLines[idx];
934
+ if (idx > -1) {
935
+ if (!(GeometryUtils.samePoints(line[0], curItemLine[0]) && GeometryUtils.samePoints(line[1], curItemLine[1]) || GeometryUtils.samePoints(line[0], curItemLine[1]) && GeometryUtils.samePoints(line[1], curItemLine[0]))) {
936
+ var MGLine = mergeOverlappedLines(line, curItemLine);
937
+ temp_MGLines.push(MGLine);
938
+ }
939
+ itemLines.splice(idx, 1);
940
+ } else {
941
+ temp_MGLines.push(line);
942
+ }
943
+ });
944
+ itemLines.forEach(function (itemLine) {
945
+ return temp_MGLines.push(itemLine);
946
+ });
947
+ MGlines = [].concat(temp_MGLines);
948
+ };
949
+ for (var i = 1; i < items.length; i++) {
950
+ _loop0();
951
+ }
952
+ MGlines.forEach(function (line) {
953
+ molding_totalLength += GeometryUtils.verticesDistance(line[0], line[1]);
954
+ });
955
+ });
956
+ molding_totalLength = convert(molding_totalLength).from('cm').to('in');
957
+ moldingData.push(_objectSpread(_objectSpread({}, molding), {}, {
958
+ doorStyle: doorStyle,
959
+ count: Math.ceil(molding_totalLength * 1.1 / 96)
960
+ }));
961
+ }
962
+ });
963
+
964
+ // calc toe kick molding
965
+ var tmp = [];
966
+ items.forEach(function (item) {
967
+ if (item.category === 'cabinet' && !item.cabinet_category.toLowerCase().includes('microwave')) {
968
+ tmp.push(item);
969
+ }
970
+ });
971
+ var tmpMoldingData = [];
972
+ var toedoorStyles = [];
973
+ tmp.map(function (item) {
974
+ var _item$molding;
975
+ if (item.layoutpos === BASE_CABINET_LAYOUTPOS && (isEmpty(item.molding) || ((_item$molding = item.molding) === null || _item$molding === void 0 ? void 0 : _item$molding.length) < 1 || !isEnableItemForMolding(layer, item))) {
976
+ var w = item.properties.get('width').get('_length');
977
+ var wUnit = item.properties.get('width').get('_unit') || 'cm';
978
+ w = convert(w / 2).from(wUnit).to('cm');
979
+ var h = item.properties.get('depth').get('_length');
980
+ var hUnit = item.properties.get('depth').get('_unit') || 'cm';
981
+ h = convert(h / 2).from(hUnit).to('cm');
982
+ var outline = null;
983
+ var element = catalog.elements[item.get('type')];
984
+ if (!element) element = catalog.elements[returnReplaceableDeepSearchType(item.get('type'))];
985
+ outline = element.info.outline;
986
+ var len = 0;
987
+ if (outline) {
988
+ // Extract Points from `outline`
989
+ var outlinePaths = outline.paths;
990
+ var outlineWidth = outline.svgWidth;
991
+ var outlineHeight = outline.svgHeight;
992
+ var outlinePoints = []; // Hold Points Of SVG
993
+ var _iterator3 = _createForOfIteratorHelper(outlinePaths),
994
+ _step3;
995
+ try {
996
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
997
+ var path = _step3.value;
998
+ var _iterator4 = _createForOfIteratorHelper(path.subPaths),
999
+ _step4;
1000
+ try {
1001
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1002
+ var subPath = _step4.value;
1003
+ outlinePoints = outlinePoints.concat(subPath.getPoints());
1004
+ }
1005
+ } catch (err) {
1006
+ _iterator4.e(err);
1007
+ } finally {
1008
+ _iterator4.f();
1009
+ }
1010
+ }
1011
+ } catch (err) {
1012
+ _iterator3.e(err);
1013
+ } finally {
1014
+ _iterator3.f();
1015
+ }
1016
+ var maxX = outlinePoints[0].x,
1017
+ minX = outlinePoints[0].x;
1018
+ var maxY = outlinePoints[0].y,
1019
+ minY = outlinePoints[0].y;
1020
+ outlinePoints.forEach(function (point) {
1021
+ if (point.x > maxX) {
1022
+ maxX = point.x;
1023
+ }
1024
+ if (point.x < minX) {
1025
+ minX = point.x;
1026
+ }
1027
+ if (point.y > maxY) {
1028
+ maxY = point.y;
1029
+ }
1030
+ if (point.y < minY) {
1031
+ minY = point.y;
1032
+ }
1033
+ });
1034
+ outlinePoints.forEach(function (point) {
1035
+ if (GeometryUtils.isPointInRect([{
1036
+ x: minX,
1037
+ y: minY
1038
+ }, {
1039
+ x: minX,
1040
+ y: maxY
1041
+ }, {
1042
+ x: maxX,
1043
+ y: maxY
1044
+ }, {
1045
+ x: maxX,
1046
+ y: minY
1047
+ }], point)) {
1048
+ if (point.x > 10) len += (point.x / outlineWidth - 0.5) * w * 2 + h * 2 - (point.y / outlineHeight - 0.5) * h * 2;
1049
+ }
1050
+ });
1051
+ len = convert(len).from('cm').to('in');
1052
+ } else {
1053
+ w = convert(w * 2).from('cm').to('in');
1054
+ len += w;
1055
+ }
1056
+ var doorIndex = toedoorStyles.findIndex(function (a) {
1057
+ var iDS = item === null || item === void 0 ? void 0 : item.doorStyle;
1058
+ if (!iDS) return false;
1059
+ if (!iDS.hasOwnProperty('id')) {
1060
+ iDS = iDS.toJS();
1061
+ }
1062
+ return a.doorStyle.id === iDS.id && isEqualInstallationType(a.doorStyle, iDS);
1063
+ });
1064
+ if (doorIndex > -1) {
1065
+ toedoorStyles[doorIndex].totalLength += len;
1066
+ } else {
1067
+ toedoorStyles.push({
1068
+ doorStyle: item.doorStyle.hasOwnProperty('id') ? item.doorStyle : item.doorStyle && item.doorStyle.toJS(),
1069
+ totalLength: len
1070
+ });
1071
+ }
1072
+ }
1073
+ });
1074
+ toedoorStyles.forEach(function (doorStyle) {
1075
+ var skuName = getToeKickSKU(doorStyle.doorStyle, catalog);
1076
+ var thumbnail = skuName ? skuName : '';
1077
+ // moldings.forEach(molding => {
1078
+ // if (
1079
+ // molding.name ===
1080
+ // getToeKickSKU(
1081
+ // doorStyle.doorStyle,
1082
+ // catalog,
1083
+ // true
1084
+ // )
1085
+ // )
1086
+ // thumbnail = molding.thumbnail;
1087
+ // });
1088
+
1089
+ doorStyle.totalLength && tmpMoldingData.push({
1090
+ name: TOE_KICK_MOLDING,
1091
+ sku: getToeKickSKU(doorStyle.doorStyle, catalog),
1092
+ thumbnail: thumbnail,
1093
+ category: 'molding',
1094
+ type: 'cabinet',
1095
+ doorStyle: doorStyle.doorStyle,
1096
+ count: Math.ceil(doorStyle.totalLength * 1.1 / 96)
1097
+ });
1098
+ });
1099
+ if (tmpMoldingData.length > 0) moldingData = [].concat(_toConsumableArray(moldingData), tmpMoldingData);
1100
+ return moldingData;
869
1101
  }
@@ -286,10 +286,18 @@ function Item(_ref, _ref2) {
286
286
  var cat = catalog.elements[catid];
287
287
  PointArray.forEach(function (pointElement, index) {
288
288
  if (pointElement[0] == undefined) PointArray[index][0] = 0;
289
- if (pointElement[1] === -90 && cat.info.is_corner !== 1) {
290
- PointArray[index][0] -= 4;
291
- }
289
+ // if (pointElement[1] === -90 && cat.info.is_corner !== 1) {
290
+ // PointArray[index][0] -= 4;
291
+ // }
292
+ });
293
+ var cnt = 0;
294
+ PointArray.forEach(function (pointElement) {
295
+ if (pointElement[0] == 0) cnt++;
292
296
  });
297
+ if (cnt == 4 || cnt == 3) {
298
+ PointArray[0][0] = 100;
299
+ PointArray[1][0] = 100;
300
+ }
293
301
  if (Array.isArray(PointArray)) {
294
302
  itemsActions.storeDistArray(layerID, id, PointArray);
295
303
  }
@@ -1193,12 +1193,12 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1193
1193
  var sendInternalEvent = function sendInternalEvent(evtType, evtElement) {
1194
1194
  var pointArray = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
1195
1195
  if (!(0, _helper.isEmpty)(evtType) && !(0, _helper.isEmpty)(evtElement)) {
1196
- var _currentObject, _this2$props$onIntern, _this2$props;
1196
+ var _this2$props$onIntern, _this2$props;
1197
1197
  var payload = evtElement === null || evtElement === void 0 ? void 0 : evtElement.toJS();
1198
- if (((_currentObject = currentObject) === null || _currentObject === void 0 ? void 0 : _currentObject.prototype) === 'lines') {
1198
+ if ((evtElement === null || evtElement === void 0 ? void 0 : evtElement.prototype) === 'lines') {
1199
1199
  // caculating length of selected line//
1200
- var v_a = layer.vertices.get(currentObject.vertices.get(0));
1201
- var v_b = layer.vertices.get(currentObject.vertices.get(1));
1200
+ var v_a = layer.vertices.get(evtElement.vertices.get(0));
1201
+ var v_b = layer.vertices.get(evtElement.vertices.get(1));
1202
1202
  var distance = _export.GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
1203
1203
  var _length = (0, _convertUnitsLite.convert)(distance).from('cm').to('in');
1204
1204
  payload.length = _length;
@@ -1302,7 +1302,7 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1302
1302
  if (intersects[_i1] === undefined) {
1303
1303
  if (transflag !== 0 && transflag !== 2) {
1304
1304
  isSelected = false;
1305
- // this.context.projectActions.unselectAll();
1305
+ _this2.context.projectActions.unselectAll();
1306
1306
  scene3D.remove(toolObj);
1307
1307
  _this2.context.itemsActions.removeReplacingSupport();
1308
1308
  return;
@@ -1369,16 +1369,11 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1369
1369
  if (selectedFlag || toolIntersects.length > 0 && !(0, _helper.isElevationView)(mode)) {
1370
1370
  cameraControls.mouseButtons.left = _cameraControls["default"].ACTION.NONE;
1371
1371
  selectedFlag = false;
1372
- } else {
1373
- isSelected = false;
1374
- // this.context.projectActions.unselectAll();
1375
- scene3D.remove(toolObj);
1376
- _this2.context.itemsActions.removeReplacingSupport();
1377
1372
  }
1378
1373
  }
1379
1374
  } else {
1380
1375
  isSelected = false;
1381
- // this.context.projectActions.unselectAll();
1376
+ _this2.context.projectActions.unselectAll();
1382
1377
  scene3D.remove(toolObj);
1383
1378
  _this2.context.itemsActions.removeReplacingSupport();
1384
1379
  return;
@@ -1397,7 +1392,7 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1397
1392
  altitude = (0, _convertUnitsLite.convert)(altitude).from(unit).to(_this2.props.state.scene.unit);
1398
1393
  }
1399
1394
  scene3D.remove(angleObj);
1400
- scene3D.remove(toolObj);
1395
+ // scene3D.remove(toolObj);
1401
1396
  if (!_this2.props.downloadFlag && !_this2.props.state.mode.includes('ING')) {
1402
1397
  _this2.props.setToolbar('');
1403
1398
  }
@@ -1536,22 +1531,12 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1536
1531
  toolObj: toolObj
1537
1532
  });
1538
1533
  // showItemButtons(layer.getIn(['items', selectedObject.itemID]), currentObject, event, camera, this.renderer);
1539
- var pointArray = [],
1540
- cnt = 0;
1541
- pointArray.push([_sceneCreator.fVLine[0].userData.distance, 90]);
1542
- pointArray.push([_sceneCreator.fVLine[1].userData.distance, -90]);
1543
- pointArray.push([_sceneCreator.fVLine[2].userData.distance, 180]);
1544
- pointArray.push([_sceneCreator.fVLine[3].userData.distance, 0]);
1545
- pointArray.forEach(function (pointElement, index) {
1546
- if (pointElement[0] == undefined) pointArray[index][0] = 0;
1547
- });
1548
- pointArray.forEach(function (pointElement) {
1549
- if (pointElement[0] == 0) cnt++;
1550
- });
1551
- if (cnt == 4 || cnt == 3) {
1552
- pointArray[0][0] = 100;
1553
- pointArray[1][0] = 100;
1554
- }
1534
+ var pointArray = [];
1535
+ // pointArray.push([fVLine[0].userData.distance, 90]);
1536
+ // pointArray.push([fVLine[1].userData.distance, -90]);
1537
+ // pointArray.push([fVLine[2].userData.distance, 180]);
1538
+ // pointArray.push([fVLine[3].userData.distance, 0]);
1539
+ pointArray = _export.GeometryUtils.calcDistancesFromItemToWalls(selectedElement, layer).PointArray;
1555
1540
  actions.itemsActions.storeDistArray(layer.id, selectedObject.itemID, pointArray);
1556
1541
  internalType = internalType ? internalType : _constants.INTERNAL_EVENT_SELECT_ELEMENT;
1557
1542
  sendInternalEvent(internalType, selectedElement, pointArray);
@@ -1564,6 +1549,7 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1564
1549
  case 'holeID' in selectedObject:
1565
1550
  elementID = selectedObject.holeID;
1566
1551
  elementPrototype = 'holes';
1552
+ scene3D.remove(toolObj);
1567
1553
  if (_this2.props.state.mode === _constants.MODE_DRAGGING_HOLE_3D) {
1568
1554
  actions.holesActions.endDraggingHole3D(sPoint.x, sPoint.y);
1569
1555
  }
@@ -1571,10 +1557,12 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1571
1557
  case 'lineID' in selectedObject:
1572
1558
  elementID = selectedObject.lineID;
1573
1559
  elementPrototype = 'lines';
1560
+ scene3D.remove(toolObj);
1574
1561
  break;
1575
1562
  case 'areaID' in selectedObject:
1576
1563
  elementID = selectedObject.areaID;
1577
1564
  elementPrototype = 'areas';
1565
+ scene3D.remove(toolObj);
1578
1566
  break;
1579
1567
  default:
1580
1568
  break;
@@ -1584,8 +1572,8 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1584
1572
  isSelected = false;
1585
1573
  }
1586
1574
  } else {
1587
- isSelected = false;
1588
- _this2.context.projectActions.unselectAll();
1575
+ // isSelected = false;
1576
+ // this.context.projectActions.unselectAll();
1589
1577
  switch (true) {
1590
1578
  case 'holeID' in selectedObject:
1591
1579
  actions.holesActions.endDraggingHole3D(sPoint.x, sPoint.y);
@@ -1595,6 +1583,13 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1595
1583
  break;
1596
1584
  }
1597
1585
  }
1586
+ var selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1587
+ if (selectedItem) {
1588
+ selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1589
+ var itemPos = selectedItem.position.clone();
1590
+ 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);
1591
+ scene3D.add(toolObj);
1592
+ }
1598
1593
  bMove = false;
1599
1594
  bRotate = false;
1600
1595
  bMoveUP = false;
@@ -1614,14 +1609,14 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1614
1609
  getPoint(event, alti);
1615
1610
  if (bRotate) {
1616
1611
  var _intersects$_i;
1617
- var selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1618
- if ((0, _util.isUndefined)(selectedItem)) return;
1612
+ var _selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1613
+ if ((0, _util.isUndefined)(_selectedItem)) return;
1619
1614
  selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1620
- var itemPos = selectedItem.position.clone();
1621
- 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) {
1615
+ var _itemPos = _selectedItem.position.clone();
1616
+ 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) {
1622
1617
  toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
1623
1618
  } else {
1624
- 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);
1619
+ 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);
1625
1620
  }
1626
1621
  scene3D.add(toolObj);
1627
1622
  _this2.setState({
@@ -1632,14 +1627,14 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1632
1627
  }
1633
1628
  if (bMove) {
1634
1629
  bMove = false;
1635
- var _selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1636
- if ((0, _util.isUndefined)(_selectedItem)) return;
1630
+ var _selectedItem2 = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1631
+ if ((0, _util.isUndefined)(_selectedItem2)) return;
1637
1632
  selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1638
- var _itemPos = _selectedItem.position.clone();
1639
- if (intersects[_i10].object.parent.parent.userData.itemId === _selectedItem.userData.itemId) {
1633
+ var _itemPos2 = _selectedItem2.position.clone();
1634
+ if (intersects[_i10].object.parent.parent.userData.itemId === _selectedItem2.userData.itemId) {
1640
1635
  toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
1641
1636
  } else {
1642
- 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);
1637
+ 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);
1643
1638
  }
1644
1639
  scene3D.add(toolObj);
1645
1640
  _this2.setState({
@@ -2559,31 +2559,13 @@ function getCalcRectFromItem2(itemInfo) {
2559
2559
  var m3y = y + h * Math.cos(rotRad);
2560
2560
  var m1x = x + h * Math.sin(rotRad);
2561
2561
  var m1y = y - h * Math.cos(rotRad);
2562
- var x0 = mx + h * Math.sin(rotRad);
2563
- var y0 = my - h * Math.cos(rotRad);
2564
- var x3 = mx * 2 - x0;
2565
- var y3 = my * 2 - y0;
2566
- var x1 = x * 2 - x3;
2567
- var y1 = y * 2 - y3;
2568
- var x2 = x * 2 - x0;
2569
- var y2 = y * 2 - y0;
2570
2562
  return {
2571
2563
  rectCenterPoint: [[point(mx, my), 180], [point(m1x, m1y), -90], [point(m2x, m2y), 0], [point(m3x, m3y), 90]]
2572
2564
  };
2573
2565
  }
2574
- function getAllItems2(layer, catalog) {
2566
+ function getAllItems2(curItem, layer) {
2575
2567
  var rectarray = [];
2576
- var currentItem;
2577
- var selectedItem;
2578
- if (layer.selected.items.size > 0) {
2579
- selectedItem = layer.getIn(['items', layer.selected.items.get(0)]);
2580
- var catid = selectedItem.type;
2581
- var cat = findCatalogElement(catalog, catid);
2582
- currentItem = {
2583
- selectedItem: selectedItem,
2584
- cat: cat
2585
- };
2586
- }
2568
+ var tempHeight = curItem.get('properties').get('depth');
2587
2569
  layer.items.forEach(function (item) {
2588
2570
  var val = {
2589
2571
  pos: {
@@ -2592,27 +2574,14 @@ function getAllItems2(layer, catalog) {
2592
2574
  },
2593
2575
  rotRad: item.rotation / 180 * Math.PI
2594
2576
  };
2595
- var catid = item.type;
2596
- var cat = findCatalogElement(catalog, catid);
2597
2577
  var width = (0, _convertUnitsLite.convert)(item.properties.getIn(['width', '_length'])).from('in').to('cm');
2598
2578
  var height = (0, _convertUnitsLite.convert)(item.properties.getIn(['depth', '_length'])).from('in').to('cm');
2599
- // let width = cat.info.sizeinfo.width;
2600
- // let height = cat.info.sizeinfo.depth;
2601
2579
  val.size = {
2602
2580
  width: width,
2603
2581
  height: height
2604
2582
  };
2605
- var otherItem = {
2606
- item: item,
2607
- cat: cat
2608
- };
2609
-
2610
- // if (!GeometryUtils.needSnap(currentItem, otherItem)) {
2611
- // return;
2612
- // }
2613
-
2614
- if (!item.selected) {
2615
- var detectObjectsAtSameAltitudeFlag = layoutpos === 'Base' ? item.properties.getIn(['altitude', '_length']) <= altitude + tempHeight.get('_length') : item.properties.getIn(['altitude', '_length']) + item.properties.getIn(['height', '_length']) >= altitude;
2583
+ if (curItem.get('id') !== item.id) {
2584
+ var detectObjectsAtSameAltitudeFlag = item.layoutpos === 'Base' ? item.properties.getIn(['altitude', '_length']) <= curItem.get('properties').getIn(['altitude', '_length']) + tempHeight.get('_length') : item.properties.getIn(['altitude', '_length']) + item.properties.getIn(['height', '_length']) >= curItem.get('properties').getIn(['altitude', '_length']);
2616
2585
  if (detectObjectsAtSameAltitudeFlag) {
2617
2586
  var x = val.pos.x;
2618
2587
  var y = val.pos.y;
@@ -2644,62 +2613,22 @@ function getAllItems2(layer, catalog) {
2644
2613
  }
2645
2614
  }
2646
2615
  });
2647
-
2648
- // layer.holes.forEach(hole => {
2649
- // let val = {pos:{x:hole.x, y:hole.y}, rotRad:hole.rotation};
2650
- // let catid = hole.type;
2651
- // let cat = catalog.elements[catid];
2652
- // let width = hole.properties.getIn(['width']).getIn(['length']);
2653
- // let height = hole.properties.getIn(['height']).getIn(['length']);
2654
- // val.size = {width, height};
2655
- // let otherItem = {
2656
- // hole,
2657
- // cat
2658
- // }
2659
-
2660
- // // if (!GeometryUtils.needSnap(currentItem, otherItem)) {
2661
- // // return;
2662
- // // }
2663
-
2664
- // if (!hole.selected) {
2665
- // let x = val.pos.x;
2666
- // let y = val.pos.y;
2667
- // let rotRad = val.rotRad;
2668
- // let w = val.size.width / 2;
2669
- // let mx = x - w * Math.cos(rotRad);
2670
- // let my = y - w * Math.sin(rotRad);
2671
- // let kx = x + w * Math.cos(rotRad);
2672
- // let ky = y + w * Math.sin(rotRad);
2673
- // let x0 = mx - 10 * Math.sin(rotRad);
2674
- // let y0 = my + 10 * Math.cos(rotRad);
2675
- // let x3 = mx + 10 * Math.sin(rotRad);
2676
- // let y3 = my - 10 * Math.cos(rotRad);
2677
- // let x1 = kx - 10 * Math.sin(rotRad);
2678
- // let y1 = ky + 10 * Math.cos(rotRad);
2679
- // let x2 = kx + 10 * Math.sin(rotRad);
2680
- // let y2 = ky - 10 * Math.cos(rotRad);
2681
- // rectarray.push({'rect':[point(x0,y0), point(x1,y1) ,point(x0,y0), point(x1,y1)]});
2682
- // rectarray.push({'rect':[point(x1,y1), point(x2,y2), point(x1,y1), point(x2,y2)]}); // right
2683
- // rectarray.push({'rect':[point(x2,y2), point(x3,y3), point(x2,y2), point(x3,y3)]}); // front
2684
- // rectarray.push({'rect':[point(x3,y3), point(x0,y0), point(x3,y3), point(x0,y0)]}); // left
2685
- // }
2686
- // });
2687
2616
  return {
2688
2617
  others: rectarray
2689
2618
  };
2690
2619
  }
2691
- function calcDistancesFromItemToWalls(attributesFormData, layer, catalog) {
2692
- if ((0, _helper.isEmpty)(attributesFormData)) return [];
2693
- var x = attributesFormData.get('x');
2694
- var y = attributesFormData.get('y');
2695
- var rotRad = attributesFormData.get('rotation') / 180 * Math.PI;
2620
+ function calcDistancesFromItemToWalls(curItem, layer) {
2621
+ if ((0, _helper.isEmpty)(curItem)) return [];
2622
+ var x = curItem.get('x');
2623
+ var y = curItem.get('y');
2624
+ var rotRad = curItem.get('rotation') / 180 * Math.PI;
2696
2625
  var width, height;
2697
- if (attributesFormData.get('properties').get('width') || attributesFormData.get('properties').get('depth')) {
2698
- width = (0, _convertUnitsLite.convert)(attributesFormData.get('properties').get('width').get('_length')).from(attributesFormData.get('properties').get('width').get('_unit')).to('cm');
2699
- height = (0, _convertUnitsLite.convert)(attributesFormData.get('properties').get('depth').get('_length')).from(attributesFormData.get('properties').get('depth').get('_unit')).to('cm');
2626
+ if (curItem.get('properties').get('width') || curItem.get('properties').get('depth')) {
2627
+ width = (0, _convertUnitsLite.convert)(curItem.get('properties').get('width').get('_length')).from(curItem.get('properties').get('width').get('_unit')).to('cm');
2628
+ height = (0, _convertUnitsLite.convert)(curItem.get('properties').get('depth').get('_length')).from(curItem.get('properties').get('depth').get('_unit')).to('cm');
2700
2629
  } else {
2701
- width = (0, _convertUnitsLite.convert)(attributesFormData.info.sizeinfo.width).from('in').to('cm');
2702
- height = (0, _convertUnitsLite.convert)(attributesFormData.info.sizeinfo.depth).from('in').to('cm');
2630
+ width = (0, _convertUnitsLite.convert)(curItem.info.sizeinfo.width).from('in').to('cm');
2631
+ height = (0, _convertUnitsLite.convert)(curItem.info.sizeinfo.depth).from('in').to('cm');
2703
2632
  }
2704
2633
  var center_h = 3 * height / 8;
2705
2634
  var center_x = x;
@@ -2719,7 +2648,7 @@ function calcDistancesFromItemToWalls(attributesFormData, layer, catalog) {
2719
2648
  height: height
2720
2649
  };
2721
2650
  var curiteminfo = getCalcRectFromItem2(itemInfo);
2722
- var allItemRect = getAllItems2(layer, catalog);
2651
+ var allItemRect = getAllItems2(curItem, layer);
2723
2652
  var allLines = getAllLines(layer);
2724
2653
  var allLineRects = buildRectFromLines(layer, allLines);
2725
2654
  var allRect = allLineRects.concat(allItemRect.others);
@@ -2745,6 +2674,17 @@ function calcDistancesFromItemToWalls(attributesFormData, layer, catalog) {
2745
2674
  });
2746
2675
  PointArray.push([a, centerpoint[1]]);
2747
2676
  });
2677
+ PointArray.forEach(function (pointElement, index) {
2678
+ if (pointElement[0] == undefined) PointArray[index][0] = 0;
2679
+ });
2680
+ var cnt = 0;
2681
+ PointArray.forEach(function (pointElement) {
2682
+ if (pointElement[0] == 0) cnt++;
2683
+ });
2684
+ if (cnt == 4 || cnt == 3) {
2685
+ PointArray[0][0] = 100;
2686
+ PointArray[1][0] = 100;
2687
+ }
2748
2688
  return {
2749
2689
  PointArray: PointArray
2750
2690
  };