kitchen-simulator 3.1.12 → 3.1.14

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.
@@ -7,7 +7,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
7
7
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
8
8
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
9
9
  import _inherits from "@babel/runtime/helpers/esm/inherits";
10
- var _excluded = ["width", "height", "state", "stateExtractor"];
10
+ var _excluded = ["width", "height", "state", "stateExtractor", "measurementUnit"];
11
11
  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; }
12
12
  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; }
13
13
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
@@ -362,6 +362,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
362
362
  height = _this$props2.height,
363
363
  state = _this$props2.state,
364
364
  stateExtractor = _this$props2.stateExtractor,
365
+ measurementUnit = _this$props2.measurementUnit,
365
366
  props = _objectWithoutProperties(_this$props2, _excluded);
366
367
  var _this$state = this.state,
367
368
  savePopupVisible = _this$state.savePopupVisible,
@@ -404,6 +405,9 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
404
405
  extractedState = extractedState.merge({
405
406
  viewer2D: _viewer2D
406
407
  });
408
+
409
+ // set the measurement unit after project setup
410
+ if (measurementUnit) this.props.viewer2DActions.updateCeilHeightUnit(measurementUnit);
407
411
  return /*#__PURE__*/React.createElement("section", null, /*#__PURE__*/React.createElement("div", {
408
412
  style: _objectSpread(_objectSpread({}, wrapperStyle), {}, {
409
413
  height: height,
@@ -4,12 +4,12 @@ import { loadGLTF, scaleObject } from "../../utils/load-obj";
4
4
  import { OBJTYPE_MESH } from "../../../constants";
5
5
  var cached3DWindow = null;
6
6
  export default {
7
- name: 'Clear Window',
7
+ name: 'Window',
8
8
  prototype: 'holes',
9
9
  info: {
10
10
  title: 'Clear',
11
11
  tag: ['window'],
12
- description: 'Clear Window',
12
+ description: 'Window',
13
13
  image: '/assets/img/svg/window/Clear.svg',
14
14
  url: '/assets/gltf/window_clear.gltf'
15
15
  },
package/es/class/line.js CHANGED
@@ -485,7 +485,7 @@ var Line = /*#__PURE__*/function () {
485
485
  var v_a = layer.vertices.get(line.vertices.get(0));
486
486
  var v_b = layer.vertices.get(line.vertices.get(1));
487
487
  var distance = GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
488
- var _length = convert(distance).from('cm').to('in');
488
+ var _length = convert(distance).from('cm').to(layer.unit);
489
489
  payload.length = _length;
490
490
  if (onInternalEvent) onInternalEvent({
491
491
  type: INTERNAL_EVENT_START_DRAW_WALL,
@@ -238,25 +238,38 @@ export default function Item(_ref, _ref2) {
238
238
  */
239
239
  var getDistant = function getDistant(x, y, rotRad) {
240
240
  var center_h = 3 * height / 8;
241
- var center_x = x;
241
+ var center_x = x; // middle of front line of cabinet rect
242
242
  var center_y = y;
243
- var center_x1 = x - center_h * Math.sin(rotRad);
243
+ var center_x1 = x - center_h * Math.sin(rotRad); // center point of cabinet rect
244
244
  var center_y1 = y + center_h * Math.cos(rotRad);
245
245
  var PointArray = [];
246
- curiteminfo.rectCenterPoint.forEach(function (centerpoint) {
247
- var comparelength = [];
246
+ var _loop = function _loop(i) {
247
+ var centerpoint = curiteminfo.rectCenterPoint[i];
248
+ // [rectCenterPoint] has four middle points of cabinet rect edges
249
+ var comparelength = []; // distance array from rectCenterPoint[i] to other lines(walls, other cabinet rect edges)
248
250
  var a;
249
- var RectLineFuction;
251
+ var RectLineFuction; // normal line of cabinet rect edge
250
252
  if (centerpoint[1] === 180 || centerpoint[1] === 0) RectLineFuction = GeometryUtils.linePassingThroughTwoPoints(centerpoint[0].x, centerpoint[0].y, center_x1, center_y1);else RectLineFuction = GeometryUtils.linePassingThroughTwoPoints(centerpoint[0].x, centerpoint[0].y, center_x, center_y);
251
253
  allRect.forEach(function (linerect) {
254
+ // calc distance to all other lines
252
255
  var p0 = GeometryUtils.clone_point(linerect.rect[2]);
253
256
  var p1 = GeometryUtils.clone_point(linerect.rect[3]);
254
- var lineFunction = {};
257
+ var lineFunction = {}; // other line function
255
258
  if (p0.x !== p1.x || p0.y !== p1.y) lineFunction = GeometryUtils.linePassingThroughTwoPoints(p0.x, p0.y, p1.x, p1.y);
259
+ // intersection between normal line and other line
256
260
  var coordinatePoint = GeometryUtils.twoLinesIntersection(lineFunction.a, lineFunction.b, lineFunction.c, RectLineFuction.a, RectLineFuction.b, RectLineFuction.c);
257
261
  if (coordinatePoint !== undefined) {
258
- if (GeometryUtils.pointsDistance(p0.x, p0.y, p1.x, p1.y) > GeometryUtils.pointsDistance(p0.x, p0.y, coordinatePoint.x, coordinatePoint.y) && GeometryUtils.pointsDistance(p0.x, p0.y, p1.x, p1.y) > GeometryUtils.pointsDistance(p1.x, p1.y, coordinatePoint.x, coordinatePoint.y)) {
259
- if (GeometryUtils.pointsDistance(coordinatePoint.x, coordinatePoint.y, center_x, center_y) > GeometryUtils.pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y)) {
262
+ if (
263
+ // intersection point is on the other line
264
+ GeometryUtils.pointsDistance(p0.x, p0.y, p1.x, p1.y) > GeometryUtils.pointsDistance(p0.x, p0.y, coordinatePoint.x, coordinatePoint.y) && GeometryUtils.pointsDistance(p0.x, p0.y, p1.x, p1.y) > GeometryUtils.pointsDistance(p1.x, p1.y, coordinatePoint.x, coordinatePoint.y)) {
265
+ // check the intersection point is outside direction of edge
266
+ var isOutside = true;
267
+ for (var j = 0; j < curiteminfo.rectCenterPoint.length; j++) {
268
+ if (j === i) continue;
269
+ var otherCenterPoint = curiteminfo.rectCenterPoint[j];
270
+ if (GeometryUtils.isPointOnLineSegment(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y, otherCenterPoint[0].x, otherCenterPoint[0].y)) isOutside = false;
271
+ }
272
+ if (isOutside && GeometryUtils.pointsDistance(coordinatePoint.x, coordinatePoint.y, center_x, center_y) > GeometryUtils.pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y)) {
260
273
  comparelength.push(GeometryUtils.pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y));
261
274
  a = Math.min.apply(null, comparelength);
262
275
  }
@@ -264,7 +277,10 @@ export default function Item(_ref, _ref2) {
264
277
  }
265
278
  });
266
279
  PointArray.push([a, centerpoint[1]]);
267
- });
280
+ };
281
+ for (var i = 0; i < curiteminfo.rectCenterPoint.length; i++) {
282
+ _loop(i);
283
+ }
268
284
  return {
269
285
  PointArray: PointArray
270
286
  };
@@ -187,7 +187,7 @@ export var areaPolygon = function areaPolygon(points) {
187
187
  };
188
188
  export var isWarningItem = function isWarningItem(item) {
189
189
  var _item$toJS$doorStyle;
190
- 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) {
190
+ 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) {
191
191
  return cd.itemID == (item === null || item === void 0 ? void 0 : item.getIn(['itemID']));
192
- }).length) > 0;
192
+ }).length) > 0;else return false;
193
193
  };
@@ -1258,7 +1258,7 @@ export default function Viewer2D(_ref, _ref2) {
1258
1258
  var v_a = layer.vertices.get(_currentObject.vertices.get(0));
1259
1259
  var v_b = layer.vertices.get(_currentObject.vertices.get(1));
1260
1260
  var distance = GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
1261
- var _length3 = convert(distance).from('cm').to('in');
1261
+ var _length3 = convert(distance).from('cm').to(layer.unit);
1262
1262
  payload.length = _length3;
1263
1263
  //////////////////////////////////////
1264
1264
  } else if (((_currentObject5 = _currentObject) === null || _currentObject5 === void 0 ? void 0 : _currentObject5.prototype) === 'items') {
@@ -1194,7 +1194,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1194
1194
  var v_a = layer.vertices.get(evtElement.vertices.get(0));
1195
1195
  var v_b = layer.vertices.get(evtElement.vertices.get(1));
1196
1196
  var distance = GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
1197
- var _length = convert(distance).from('cm').to('in');
1197
+ var _length = convert(distance).from('cm').to(layer.unit);
1198
1198
  payload.length = _length;
1199
1199
  //////////////////////////////////////
1200
1200
  } else if ((evtElement === null || evtElement === void 0 ? void 0 : evtElement.prototype) === 'items') {
@@ -1386,7 +1386,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1386
1386
  altitude = convert(altitude).from(unit).to(_this2.props.state.scene.unit);
1387
1387
  }
1388
1388
  scene3D.remove(angleObj);
1389
- // scene3D.remove(toolObj);
1389
+ scene3D.remove(toolObj);
1390
1390
  if (!_this2.props.downloadFlag && !_this2.props.state.mode.includes('ING')) {
1391
1391
  _this2.props.setToolbar('');
1392
1392
  }
@@ -1460,7 +1460,8 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1460
1460
  });
1461
1461
  });
1462
1462
  var intersects = raycaster.intersectObjects(meshes, true);
1463
- var _i10;
1463
+ var _i10; // index of warning object in intersects
1464
+
1464
1465
  if (intersects.length > 0 && !isNaN(intersects[0].distance)) {
1465
1466
  for (_i10 = 0; _i10 < intersects.length; _i10++) {
1466
1467
  if (intersects[_i10].object.name === 'warningObj') break;
@@ -1488,6 +1489,19 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1488
1489
  }
1489
1490
  }
1490
1491
  gridMatrix.copy(gridPlane.matrixWorld).invert();
1492
+ var addItemToolObj = function addItemToolObj() {
1493
+ var _intersects$_i;
1494
+ var selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1495
+ if (isUndefined(selectedItem)) return;
1496
+ selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1497
+ var itemPos = selectedItem.position.clone();
1498
+ 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) {
1499
+ toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
1500
+ } else {
1501
+ 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);
1502
+ }
1503
+ scene3D.add(toolObj);
1504
+ };
1491
1505
  if (Math.abs(mouse.x - _this2.lastMousePosition.x) <= 0.02 && Math.abs(mouse.y - _this2.lastMousePosition.y) <= 0.02 || bMove) {
1492
1506
  if (intersects.length > 0 && !isNaN(intersects[0].distance)) {
1493
1507
  if (intersects[_i10] === undefined) {
@@ -1511,16 +1525,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1511
1525
  isSelected = true;
1512
1526
  setTimeout(function () {
1513
1527
  getDistances(layer);
1514
- var selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1515
- if (isUndefined(selectedItem)) return;
1516
- selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1517
- var itemPos = selectedItem.position.clone();
1518
- if (intersects[_i10].object.parent && intersects[_i10].object.parent.parent.userData.itemId === selectedItem.userData.itemId) {
1519
- toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
1520
- } else {
1521
- 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);
1522
- }
1523
- scene3D.add(toolObj);
1528
+ addItemToolObj();
1524
1529
  _this2.setState({
1525
1530
  toolObj: toolObj
1526
1531
  });
@@ -1543,7 +1548,6 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1543
1548
  case 'holeID' in selectedObject:
1544
1549
  elementID = selectedObject.holeID;
1545
1550
  elementPrototype = 'holes';
1546
- scene3D.remove(toolObj);
1547
1551
  if (_this2.props.state.mode === MODE_DRAGGING_HOLE_3D) {
1548
1552
  actions.holesActions.endDraggingHole3D(sPoint.x, sPoint.y);
1549
1553
  }
@@ -1551,12 +1555,10 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1551
1555
  case 'lineID' in selectedObject:
1552
1556
  elementID = selectedObject.lineID;
1553
1557
  elementPrototype = 'lines';
1554
- scene3D.remove(toolObj);
1555
1558
  break;
1556
1559
  case 'areaID' in selectedObject:
1557
1560
  elementID = selectedObject.areaID;
1558
1561
  elementPrototype = 'areas';
1559
- scene3D.remove(toolObj);
1560
1562
  break;
1561
1563
  default:
1562
1564
  break;
@@ -1566,24 +1568,22 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1566
1568
  isSelected = false;
1567
1569
  }
1568
1570
  } else {
1569
- // isSelected = false;
1570
- // this.context.projectActions.unselectAll();
1571
- switch (true) {
1572
- case 'holeID' in selectedObject:
1573
- actions.holesActions.endDraggingHole3D(sPoint.x, sPoint.y);
1574
- break;
1575
- default:
1576
- _this2.context.itemsActions.removeReplacingSupport();
1577
- break;
1571
+ var selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1572
+ if (bMove && !isEmpty(selectedItem)) {
1573
+ addItemToolObj();
1574
+ } else {
1575
+ isSelected = false;
1576
+ _this2.context.projectActions.unselectAll();
1577
+ switch (true) {
1578
+ case 'holeID' in selectedObject:
1579
+ actions.holesActions.endDraggingHole3D(sPoint.x, sPoint.y);
1580
+ break;
1581
+ default:
1582
+ _this2.context.itemsActions.removeReplacingSupport();
1583
+ break;
1584
+ }
1578
1585
  }
1579
1586
  }
1580
- var selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1581
- if (selectedItem) {
1582
- selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1583
- var itemPos = selectedItem.position.clone();
1584
- 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);
1585
- scene3D.add(toolObj);
1586
- }
1587
1587
  bMove = false;
1588
1588
  bRotate = false;
1589
1589
  bMoveUP = false;
@@ -1602,35 +1602,15 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1602
1602
  }
1603
1603
  getPoint(event, alti);
1604
1604
  if (bRotate) {
1605
- var _intersects$_i;
1606
- var _selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1607
- if (isUndefined(_selectedItem)) return;
1608
- selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1609
- var _itemPos = _selectedItem.position.clone();
1610
- 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) {
1611
- toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
1612
- } else {
1613
- 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);
1614
- }
1615
- scene3D.add(toolObj);
1605
+ addItemToolObj();
1616
1606
  _this2.setState({
1617
1607
  toolObj: toolObj
1618
1608
  });
1619
1609
  _this2.context.itemsActions.endRotatingItem3D(Point.x, Point.y);
1620
1610
  bRotate = false;
1621
- }
1622
- if (bMove) {
1611
+ } else if (bMove) {
1623
1612
  bMove = false;
1624
- var _selectedItem2 = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1625
- if (isUndefined(_selectedItem2)) return;
1626
- selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1627
- var _itemPos2 = _selectedItem2.position.clone();
1628
- if (intersects[_i10].object.parent.parent.userData.itemId === _selectedItem2.userData.itemId) {
1629
- toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
1630
- } else {
1631
- 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);
1632
- }
1633
- scene3D.add(toolObj);
1613
+ addItemToolObj();
1634
1614
  _this2.setState({
1635
1615
  toolObj: toolObj
1636
1616
  });
@@ -1650,7 +1630,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1650
1630
  _item3D.position.z = targetPoint.z;
1651
1631
  _item3D.visible = true;
1652
1632
  }
1653
- }
1633
+ } else {}
1654
1634
  if (bMoveUP) {
1655
1635
  bMoveUP = false;
1656
1636
  }
package/es/constants.js CHANGED
@@ -66,6 +66,7 @@ export var CHANGE_WALL_LENGTH_MEASURE = 'CHANGE_WALL_LENGTH_MEASURE';
66
66
  export var CHANGE_BASE_CABINET_MEASURE = 'CHANGE_BASE_CABINET_MEASURE';
67
67
  export var CHANGE_WALL_CABINET_MEASURE = 'CHANGE_WALL_CABINET_MEASURE';
68
68
  export var CHANGE_WINDOW_DOOR_MEASURE = 'CHANGE_WINDOW_DOOR_MEASURE';
69
+ export var CHANGE_MEASUREMENT_UNIT = 'CHANGE_MEASUREMENT_UNIT';
69
70
 
70
71
  //ACTIONS viewer3D
71
72
  export var SELECT_TOOL_3D_VIEW = 'SELECT_TOOL_3D_VIEW';
@@ -650,10 +651,11 @@ export var PROJECT_SETTING_OPTION = {
650
651
  CHANGE_WALL_LENGTH_MEASURE: CHANGE_WALL_LENGTH_MEASURE,
651
652
  CHANGE_BASE_CABINET_MEASURE: CHANGE_BASE_CABINET_MEASURE,
652
653
  CHANGE_WALL_CABINET_MEASURE: CHANGE_WALL_CABINET_MEASURE,
653
- CHANGE_WINDOW_DOOR_MEASURE: CHANGE_WINDOW_DOOR_MEASURE
654
+ CHANGE_WINDOW_DOOR_MEASURE: CHANGE_WINDOW_DOOR_MEASURE,
655
+ CHANGE_MEASUREMENT_UNIT: CHANGE_MEASUREMENT_UNIT
654
656
  };
655
657
  export var HOLE_NAMES = {
656
- WINDOW_CLEAR: 'Clear Window',
658
+ WINDOW_CLEAR: 'Window',
657
659
  WINDOW_CROSS: 'Cross Window',
658
660
  WINDOW_DOUBLE_HUNG: 'Double Hung Window',
659
661
  WINDOW_VERTICAL: 'window-vertical',
@@ -739,6 +741,7 @@ export var EXTERNAL_EVENT_UPDATE_ATTRIBUTE = 'EXTERNAL_EVENT_UPDATE_ATTRIBUTE';
739
741
  export var EXTERNAL_EVENT_UPDATE_PROPERTY = 'EXTERNAL_EVENT_UPDATE_PROPERTY'; // update the element's property (flip_doorhandle, open_doors...) in the property window
740
742
  export var EXTERNAL_EVENT_REPLACE_CABINET = 'EXTERNAL_EVENT_REPLACE_CABINET';
741
743
  export var EXTERNAL_EVENT_SET_FINISHING = 'EXTERNAL_EVENT_SET_FINISHING'; // set finishing(wallColor, floorStyle, doorHandle, backsplash, counterTop)
744
+ export var EXTERNAL_EVENT_ROTATE_PAN = 'EXTERNAL_EVENT_ROTATE_PAN'; // external event for rotate pan
742
745
 
743
746
  // internal event type
744
747
  export var INTERNAL_EVENT_UNSELECT_ALL = 'INTERNAL_EVENT_UNSELECT_ALL';
@@ -7,6 +7,7 @@ import ContainerDimensions from "react-container-dimensions";
7
7
  import projectItemsCatalog from "./mocks/projectItemsCatalog.json";
8
8
  import mockProps from "./mocks/mockProps.json";
9
9
  import cabinetPaylod from "./mocks/cabinetPayload2.json";
10
+ import cabinetW0940Payload from "./mocks/cabinetPayload.json";
10
11
  import appliancePaylod from "./mocks/appliancePayload.json";
11
12
  import doorStylePaylod2 from "./mocks/doorStylePayload2.json";
12
13
  import roomShapePayload from "./mocks/roomShapePayload.json";
@@ -19,7 +20,7 @@ import replaceCabinetPayload from "./mocks/replaceCabinetPayload.json";
19
20
  import ReactDOM from "react-dom";
20
21
  import LiteRenderer from "./LiteRenderer";
21
22
  import { Button } from "antd";
22
- import { LEFT, RIGHT, TOP, BOTTOM, EXTERNAL_EVENT_ADD_ITEM, EXTERNAL_EVENT_ADD_WALL, EXTERNAL_EVENT_TOGGLE_TO_3D, EXTERNAL_EVENT_TOGGLE_TO_2D, EXTERNAL_EVENT_TOGGLE_TO_ELEVATION, EXTERNAL_EVENT_MOVE_PAN, EXTERNAL_EVENT_NEW_PROJECT, EXTERNAL_EVENT_CHANGE_DOORSTYLE, EXTERNAL_EVENT_ADD_ROOM_SHAPE, EXTERNAL_EVENT_ZOOM_IN, EXTERNAL_EVENT_ZOOM_OUT, EXTERNAL_EVENT_UNDO, EXTERNAL_EVENT_REDO, EXTERNAL_EVENT_SET_MOLDING, EXTERNAL_EVENT_PROJECT_SETTING, PROJECT_SETTING_OPTION, EXTERNAL_EVENT_SYNC_SCENE, EXTERNAL_EVENT_UPDATE_ATTRIBUTE, BACK_DIST_ANG, ATT_ITEM_POS, ATT_ITEM_ROTATION, ATT_LINE_LENGTH, EXTERNAL_EVENT_UPDATE_PROPERTY, PROP_FLIP_DOOR_HANDLE, PROP_OPEN_DOORS, EXTERNAL_EVENT_LOAD_PROJECT, INTERNAL_EVENT_ITEMS_CATALOG, EXTERNAL_EVENT_ADD_HOLE, HOLE_NAMES, EXTERNAL_EVENT_CENTERING_2D, PROP_ALTITUDE, EXTERNAL_EVENT_DUPLICATE_ELEMENT, ELEMENT_ITEM, EXTERNAL_EVENT_DELETE_ELEMENT, PROP_RESIZE_WIDTH, EXTERNAL_EVENT_REPLACE_CABINET, EXTERNAL_EVENT_SET_FINISHING, FINISHING_TYPE } from "./constants";
23
+ import { LEFT, RIGHT, TOP, BOTTOM, EXTERNAL_EVENT_ADD_ITEM, EXTERNAL_EVENT_ADD_WALL, EXTERNAL_EVENT_TOGGLE_TO_3D, EXTERNAL_EVENT_TOGGLE_TO_2D, EXTERNAL_EVENT_TOGGLE_TO_ELEVATION, EXTERNAL_EVENT_MOVE_PAN, EXTERNAL_EVENT_NEW_PROJECT, EXTERNAL_EVENT_CHANGE_DOORSTYLE, EXTERNAL_EVENT_ADD_ROOM_SHAPE, EXTERNAL_EVENT_ZOOM_IN, EXTERNAL_EVENT_ZOOM_OUT, EXTERNAL_EVENT_UNDO, EXTERNAL_EVENT_REDO, EXTERNAL_EVENT_SET_MOLDING, EXTERNAL_EVENT_PROJECT_SETTING, PROJECT_SETTING_OPTION, EXTERNAL_EVENT_SYNC_SCENE, EXTERNAL_EVENT_UPDATE_ATTRIBUTE, BACK_DIST_ANG, ATT_ITEM_POS, ATT_ITEM_ROTATION, ATT_LINE_LENGTH, EXTERNAL_EVENT_UPDATE_PROPERTY, PROP_FLIP_DOOR_HANDLE, PROP_OPEN_DOORS, EXTERNAL_EVENT_LOAD_PROJECT, INTERNAL_EVENT_ITEMS_CATALOG, EXTERNAL_EVENT_ADD_HOLE, HOLE_NAMES, EXTERNAL_EVENT_CENTERING_2D, PROP_ALTITUDE, EXTERNAL_EVENT_DUPLICATE_ELEMENT, ELEMENT_ITEM, EXTERNAL_EVENT_DELETE_ELEMENT, PROP_RESIZE_WIDTH, EXTERNAL_EVENT_REPLACE_CABINET, EXTERNAL_EVENT_SET_FINISHING, FINISHING_TYPE, EXTERNAL_EVENT_ROTATE_PAN } from "./constants";
23
24
  import { convert } from "./utils/convert-units-lite";
24
25
 
25
26
  // --- renderer props ---
@@ -214,6 +215,15 @@ function WorkSpace(props) {
214
215
  setExternalEvent(evt);
215
216
  }
216
217
  }, "Add B12 Cabinet"), /*#__PURE__*/React.createElement(Button, {
218
+ actionType: "danger",
219
+ onClick: function onClick() {
220
+ var evt = {
221
+ type: EXTERNAL_EVENT_ADD_ITEM,
222
+ payload: cabinetW0940Payload
223
+ };
224
+ setExternalEvent(evt);
225
+ }
226
+ }, "Add W0930 Cabinet"), /*#__PURE__*/React.createElement(Button, {
217
227
  actionType: "danger",
218
228
  onClick: function onClick() {
219
229
  var evt = {
@@ -679,7 +689,71 @@ function WorkSpace(props) {
679
689
  };
680
690
  setExternalEvent(evt);
681
691
  }
682
- }, "random width")), /*#__PURE__*/React.createElement(LiteRenderer, {
692
+ }, "random width"), /*#__PURE__*/React.createElement(Button, {
693
+ actionType: "primary",
694
+ onClick: function onClick() {
695
+ var evt = {
696
+ type: EXTERNAL_EVENT_ROTATE_PAN,
697
+ payload: {
698
+ rotateType: RIGHT
699
+ }
700
+ };
701
+ setExternalEvent(evt);
702
+ }
703
+ }, /*#__PURE__*/React.createElement("img", {
704
+ src: "/assets/img/svg/bottombar/spin-right.svg"
705
+ })), /*#__PURE__*/React.createElement(Button, {
706
+ actionType: "primary",
707
+ onClick: function onClick() {
708
+ var evt = {
709
+ type: EXTERNAL_EVENT_ROTATE_PAN,
710
+ payload: {
711
+ rotateType: LEFT
712
+ }
713
+ };
714
+ setExternalEvent(evt);
715
+ }
716
+ }, /*#__PURE__*/React.createElement("img", {
717
+ src: "/assets/img/svg/bottombar/spin-left.svg"
718
+ })), /*#__PURE__*/React.createElement(Button, {
719
+ actionType: "primary",
720
+ onClick: function onClick() {
721
+ var evt = {
722
+ type: EXTERNAL_EVENT_ROTATE_PAN,
723
+ payload: {
724
+ rotateType: TOP
725
+ }
726
+ };
727
+ setExternalEvent(evt);
728
+ }
729
+ }, /*#__PURE__*/React.createElement("img", {
730
+ src: "/assets/img/svg/bottombar/spin-up.svg"
731
+ })), /*#__PURE__*/React.createElement(Button, {
732
+ actionType: "primary",
733
+ onClick: function onClick() {
734
+ var evt = {
735
+ type: EXTERNAL_EVENT_ROTATE_PAN,
736
+ payload: {
737
+ rotateType: BOTTOM
738
+ }
739
+ };
740
+ setExternalEvent(evt);
741
+ }
742
+ }, /*#__PURE__*/React.createElement("img", {
743
+ src: "/assets/img/svg/bottombar/spin-down.svg"
744
+ })), /*#__PURE__*/React.createElement(Button, {
745
+ actionType: "danger",
746
+ onClick: function onClick() {
747
+ var evt = {
748
+ type: EXTERNAL_EVENT_PROJECT_SETTING,
749
+ payload: {
750
+ option: PROJECT_SETTING_OPTION.CHANGE_MEASUREMENT_UNIT,
751
+ value: "cm"
752
+ }
753
+ };
754
+ setExternalEvent(evt);
755
+ }
756
+ }, "Setting-MeasurementUnit-'cm'")), /*#__PURE__*/React.createElement(LiteRenderer, {
683
757
  width: props.width,
684
758
  height: props.height,
685
759
  configData: mockProps.configData,
@@ -2481,7 +2481,7 @@ function getAllItems2(curItem, layer) {
2481
2481
  height: height
2482
2482
  };
2483
2483
  if (curItem.get('id') !== item.id) {
2484
- 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']);
2484
+ var detectObjectsAtSameAltitudeFlag = curItem.get('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']);
2485
2485
  if (detectObjectsAtSameAltitudeFlag) {
2486
2486
  var x = val.pos.x;
2487
2487
  var y = val.pos.y;
@@ -2531,9 +2531,9 @@ export function calcDistancesFromItemToWalls(curItem, layer) {
2531
2531
  height = convert(curItem.info.sizeinfo.depth).from('in').to('cm');
2532
2532
  }
2533
2533
  var center_h = 3 * height / 8;
2534
- var center_x = x;
2534
+ var center_x = x; // middle of front line of cabinet rect
2535
2535
  var center_y = y;
2536
- var center_x1 = x - center_h * Math.sin(rotRad);
2536
+ var center_x1 = x - center_h * Math.sin(rotRad); // center point of cabinet rect
2537
2537
  var center_y1 = y + center_h * Math.cos(rotRad);
2538
2538
  var PointArray = [];
2539
2539
  var itemInfo = {
@@ -2552,20 +2552,33 @@ export function calcDistancesFromItemToWalls(curItem, layer) {
2552
2552
  var allLines = getAllLines(layer);
2553
2553
  var allLineRects = buildRectFromLines(layer, allLines);
2554
2554
  var allRect = allLineRects.concat(allItemRect.others);
2555
- curiteminfo.rectCenterPoint.forEach(function (centerpoint) {
2556
- var comparelength = [];
2555
+ var _loop = function _loop(i) {
2556
+ // [rectCenterPoint] has four middle points of cabinet rect edges
2557
+ var centerpoint = curiteminfo.rectCenterPoint[i];
2558
+ var comparelength = []; // distance array from rectCenterPoint[i] to other lines(walls, other cabinet rect edges)
2557
2559
  var a;
2558
- var RectLineFuction;
2560
+ var RectLineFuction; // normal line of cabinet rect edge
2559
2561
  if (centerpoint[1] === 180 || centerpoint[1] === 0) RectLineFuction = linePassingThroughTwoPoints(centerpoint[0].x, centerpoint[0].y, center_x1, center_y1);else RectLineFuction = linePassingThroughTwoPoints(centerpoint[0].x, centerpoint[0].y, center_x, center_y);
2560
2562
  allRect.forEach(function (linerect) {
2563
+ // calc distance to all other lines
2561
2564
  var p0 = clone_point(linerect.rect[2]);
2562
2565
  var p1 = clone_point(linerect.rect[3]);
2563
- var lineFunction = {};
2566
+ var lineFunction = {}; // other line function
2564
2567
  if (p0.x !== p1.x || p0.y !== p1.y) lineFunction = linePassingThroughTwoPoints(p0.x, p0.y, p1.x, p1.y);
2568
+ // intersection between normal line and other line
2565
2569
  var coordinatePoint = twoLinesIntersection(lineFunction.a, lineFunction.b, lineFunction.c, RectLineFuction.a, RectLineFuction.b, RectLineFuction.c);
2566
2570
  if (coordinatePoint !== undefined) {
2567
- if (pointsDistance(p0.x, p0.y, p1.x, p1.y) > pointsDistance(p0.x, p0.y, coordinatePoint.x, coordinatePoint.y) && pointsDistance(p0.x, p0.y, p1.x, p1.y) > pointsDistance(p1.x, p1.y, coordinatePoint.x, coordinatePoint.y)) {
2568
- if (pointsDistance(coordinatePoint.x, coordinatePoint.y, center_x, center_y) > pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y)) {
2571
+ if (
2572
+ // intersection point is on the other line
2573
+ pointsDistance(p0.x, p0.y, p1.x, p1.y) > pointsDistance(p0.x, p0.y, coordinatePoint.x, coordinatePoint.y) && pointsDistance(p0.x, p0.y, p1.x, p1.y) > pointsDistance(p1.x, p1.y, coordinatePoint.x, coordinatePoint.y)) {
2574
+ // check the intersection point is outside direction of edge
2575
+ var isOutside = true;
2576
+ for (var j = 0; j < curiteminfo.rectCenterPoint.length; j++) {
2577
+ if (j === i) continue;
2578
+ var otherCenterPoint = curiteminfo.rectCenterPoint[j];
2579
+ if (isPointOnLineSegment(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y, otherCenterPoint[0].x, otherCenterPoint[0].y)) isOutside = false;
2580
+ }
2581
+ if (isOutside && pointsDistance(coordinatePoint.x, coordinatePoint.y, center_x, center_y) > pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y)) {
2569
2582
  comparelength.push(pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y));
2570
2583
  a = Math.min.apply(null, comparelength);
2571
2584
  }
@@ -2573,7 +2586,10 @@ export function calcDistancesFromItemToWalls(curItem, layer) {
2573
2586
  }
2574
2587
  });
2575
2588
  PointArray.push([a, centerpoint[1]]);
2576
- });
2589
+ };
2590
+ for (var i = 0; i < curiteminfo.rectCenterPoint.length; i++) {
2591
+ _loop(i);
2592
+ }
2577
2593
  PointArray.forEach(function (pointElement, index) {
2578
2594
  if (pointElement[0] == undefined) PointArray[index][0] = 0;
2579
2595
  });