kitchen-simulator 3.0.1 → 3.1.0

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.
@@ -13,12 +13,14 @@ export function selectToolDrawingLine(sceneComponentType) {
13
13
  };
14
14
  }
15
15
  export function beginDrawingLine(layerID, x, y, snapMask) {
16
+ var onInternalEvent = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
16
17
  return {
17
18
  type: BEGIN_DRAWING_LINE,
18
19
  layerID: layerID,
19
20
  x: x,
20
21
  y: y,
21
- snapMask: snapMask
22
+ snapMask: snapMask,
23
+ onInternalEvent: onInternalEvent
22
24
  };
23
25
  }
24
26
  export function updateDrawingLine(x, y, relatedLines, snapMask) {
@@ -450,6 +450,7 @@ export function render3DItem(element, layer, scene, sizeinfo, structure_json, is
450
450
  var tempPlaceholders = structure.tempPlaceholders;
451
451
  var tPlaceholders = tempPlaceholders.find(function (el) {
452
452
  return el.id === tempDoorStyles.cabinet_door_style_id;
453
+ // return el.id === tempDoorStyles.cds[0].cabinet_door_style_id;
453
454
  });
454
455
  if (tPlaceholders !== undefined) {
455
456
  placeholders = tPlaceholders.placeholders;
package/es/class/item.js CHANGED
@@ -479,6 +479,9 @@ var Item = /*#__PURE__*/function () {
479
479
  key: "storeDistArray",
480
480
  value: function storeDistArray(state, layerID, itemID, distArray) {
481
481
  var curDistArray = state.getIn(['scene', 'layers', layerID, 'items', itemID, 'distArray']);
482
+ distArray.forEach(function (dist) {
483
+ dist[0] < 0 ? dist[0] = 0 : dist[0];
484
+ });
482
485
  var isEqualDist = function isEqualDist(a, b) {
483
486
  return a == b;
484
487
  };
@@ -1145,6 +1148,7 @@ var Item = /*#__PURE__*/function () {
1145
1148
  for (var x in keys) {
1146
1149
  tmp[keys[x]] = doorStyle.doorStyles[keys[x]];
1147
1150
  }
1151
+ doorStyle.cds = itemCDS;
1148
1152
  state = state.setIn(['scene', 'layers', state.scene.selectedLayer, 'doorStyle'], doorStyle);
1149
1153
  state = state.merge({
1150
1154
  doorStyle: doorStyle
package/es/class/line.js CHANGED
@@ -5,8 +5,9 @@ import { fromJS, List, Map } from 'immutable';
5
5
  import { Group, Hole, Layer, Vertex } from "./export";
6
6
  import { GeometryUtils, history, IDBroker, NameGenerator, SnapSceneUtils, SnapUtils } from "../utils/export";
7
7
  import * as Three from 'three';
8
- import { END_DRAGGING_LINE, END_DRAGGING_VERTEX, END_DRAWING_LINE, EPSILON, MIN_ANGLE_DISALLOW_DRAW_WALL, MODE_DRAGGING_LINE, MODE_DRAWING_LINE, MODE_IDLE, MODE_WAITING_DRAWING_LINE, UNIT_ANGLE } from "../constants";
8
+ import { END_DRAGGING_LINE, END_DRAGGING_VERTEX, END_DRAWING_LINE, EPSILON, INTERNAL_EVENT_START_DRAW_WALL, MIN_ANGLE_DISALLOW_DRAW_WALL, MODE_DRAGGING_LINE, MODE_DRAWING_LINE, MODE_IDLE, MODE_WAITING_DRAWING_LINE, UNIT_ANGLE } from "../constants";
9
9
  import { isEmpty } from "../utils/helper";
10
+ import { convert } from "../utils/convert-units-lite";
10
11
  var timeGlobal = 0;
11
12
  var TimeRecorder = /*#__PURE__*/function () {
12
13
  function TimeRecorder(name) {
@@ -426,7 +427,7 @@ var Line = /*#__PURE__*/function () {
426
427
  }
427
428
  }, {
428
429
  key: "beginDrawingLine",
429
- value: function beginDrawingLine(state, layerID, x, y) {
430
+ value: function beginDrawingLine(state, layerID, x, y, onInternalEvent) {
430
431
  // if end drawing by created area
431
432
  if (state.mode == MODE_IDLE) {
432
433
  return {
@@ -479,6 +480,17 @@ var Line = /*#__PURE__*/function () {
479
480
  activeSnapElement: snap ? snap.snap : null,
480
481
  drawingSupport: drawingSupport
481
482
  });
483
+ var layer = state.getIn(['scene', 'layers', layerID]);
484
+ var payload = line.toJS();
485
+ var v_a = layer.vertices.get(line.vertices.get(0));
486
+ var v_b = layer.vertices.get(line.vertices.get(1));
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');
489
+ payload.length = _length;
490
+ if (onInternalEvent) onInternalEvent({
491
+ type: INTERNAL_EVENT_START_DRAW_WALL,
492
+ value: payload
493
+ });
482
494
  return {
483
495
  updatedState: state
484
496
  };
@@ -5,7 +5,7 @@ import RulerDist from "./rulerDist";
5
5
  import { convert } from "../../utils/convert-units-lite";
6
6
  import { GeometryUtils } from "../../utils/export";
7
7
  import { MODE_ROTATING_ITEM, WALL_CABINET_LAYOUTPOS } from "../../constants";
8
- import { isEmpty, returnReplaceableDeepSearchType } from "./utils";
8
+ import { isEmpty, isWarningItem, returnReplaceableDeepSearchType } from "./utils";
9
9
  import { findCatalogElement } from "../../utils/geometry";
10
10
  var STYLE_LINE = {
11
11
  fill: '#0096fd',
@@ -390,7 +390,10 @@ export default function Item(_ref, _ref2) {
390
390
  y: "-19",
391
391
  height: "16",
392
392
  width: "16",
393
- style: {
393
+ style: isWarningItem(item) ? {
394
+ transform: 'rotateX(180deg)',
395
+ opacity: 0.5
396
+ } : {
394
397
  transform: 'rotateX(180deg)'
395
398
  }
396
399
  })), /*#__PURE__*/React.createElement("g", {
@@ -34,7 +34,7 @@ export default function RulerDist(_ref) {
34
34
  var _unit = 'in';
35
35
  // let _length = convert(length).from(unit).to(rulerUnit);
36
36
  var distanceText = "".concat(convert(length).from('cm').to(rulerUnit).toFixed(0));
37
- var textLength = (distanceText.length + layer.unit.length) * 18;
37
+ var textLength = (distanceText.length + layer.unit.length) * 8;
38
38
  var textangle = angle + 90;
39
39
  var textRotation = 1;
40
40
  var ay = 2;
@@ -948,7 +948,7 @@ export default function Viewer2D(_ref, _ref2) {
948
948
  case 'items':
949
949
  if (elementData.part === 'duplicate') {
950
950
  var currentObject = state.getIn(['scene', 'layers', layerID, 'items', elementData.id]);
951
- itemsActions.duplicateSelected(currentObject, onInternalEvent); // send draw internal event when duplicating
951
+ if (!isWarningItem(currentObject)) itemsActions.duplicateSelected(currentObject, onInternalEvent); // send draw internal event when duplicating
952
952
  break;
953
953
  } else if (elementData.part === 'remove') {
954
954
  projectActions.remove();
@@ -1199,7 +1199,7 @@ export default function Viewer2D(_ref, _ref2) {
1199
1199
  break;
1200
1200
  case constants.MODE_WAITING_DRAWING_LINE:
1201
1201
  setdrawStart(true);
1202
- linesActions.beginDrawingLine(layerID, x, y, state.snapMask);
1202
+ linesActions.beginDrawingLine(layerID, x, y, state.snapMask, onInternalEvent);
1203
1203
  break;
1204
1204
  case constants.MODE_DRAWING_LINE:
1205
1205
  // Blocked 90 degree snap.
@@ -1213,7 +1213,7 @@ export default function Viewer2D(_ref, _ref2) {
1213
1213
  getConnectedLines();
1214
1214
  var endInfor = getEndPoint(vertices, x, y, 'END_DRAWIN_LINE');
1215
1215
  linesActions.endDrawingLine(endInfor.x, endInfor.y, state.snapMask);
1216
- linesActions.beginDrawingLine(layerID, endInfor.x, endInfor.y, state.snapMask);
1216
+ linesActions.beginDrawingLine(layerID, endInfor.x, endInfor.y, state.snapMask, onInternalEvent);
1217
1217
  break;
1218
1218
  case constants.MODE_DRAWING_HOLE:
1219
1219
  holesActions.endDrawingHole(layerID, x, y);
@@ -1264,6 +1264,8 @@ export default function Viewer2D(_ref, _ref2) {
1264
1264
  } else if (((_currentObject5 = _currentObject) === null || _currentObject5 === void 0 ? void 0 : _currentObject5.prototype) === 'items') {
1265
1265
  // check this cabinet has warning box
1266
1266
  payload.isWarning = isWarningItem(_currentObject);
1267
+ // check this item is available molding
1268
+ payload.isMoldingAvailable = MoldingUtils.isEnableItemForMolding(layer, _currentObject);
1267
1269
  // check this item is snapped to wall
1268
1270
  payload.isAttachedWall = MoldingUtils.isAttachedWall(layer, _currentObject);
1269
1271
  }
@@ -1184,6 +1184,26 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1184
1184
  itemID: selItemId
1185
1185
  };
1186
1186
  };
1187
+ var sendInternalEvent = function sendInternalEvent(evtType, evtElement) {
1188
+ var pointArray = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
1189
+ if (!isEmpty(evtType)) {
1190
+ var _this2$props$onIntern, _this2$props;
1191
+ var payload = evtElement === null || evtElement === void 0 ? void 0 : evtElement.toJS();
1192
+ if ((evtElement === null || evtElement === void 0 ? void 0 : evtElement.prototype) === 'items') {
1193
+ // check this cabinet has warning box
1194
+ payload.isWarning = isWarningItem(evtElement);
1195
+ // check this item is available molding
1196
+ payload.isMoldingAvailable = MoldingUtils.isEnableItemForMolding(layer, evtElement); // check this item is snapped to wall
1197
+ payload.isAttachedWall = MoldingUtils.isAttachedWall(layer, evtElement);
1198
+ // update distArray
1199
+ if (pointArray) payload.distArray = pointArray;
1200
+ }
1201
+ (_this2$props$onIntern = (_this2$props = _this2.props).onInternalEvent) === null || _this2$props$onIntern === void 0 || _this2$props$onIntern.call(_this2$props, {
1202
+ type: evtType,
1203
+ value: payload
1204
+ });
1205
+ }
1206
+ };
1187
1207
  this.mouseDownEvent = function (event) {
1188
1208
  gridPlanOrigin = gridPlane.position;
1189
1209
  gridMatrix.copy(gridPlane.matrixWorld).invert();
@@ -1479,39 +1499,42 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1479
1499
  currentObject = currentObject.parent;
1480
1500
  }
1481
1501
  isSelected = true;
1482
- getDistances(layer);
1483
- var selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1484
- if (isUndefined(selectedItem)) return;
1485
- selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1486
- var itemPos = selectedItem.position.clone();
1487
- if (intersects[_i10].object.parent && intersects[_i10].object.parent.parent.userData.itemId === selectedItem.userData.itemId) {
1488
- toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
1489
- } else {
1490
- 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);
1491
- }
1492
- scene3D.add(toolObj);
1493
- _this2.setState({
1494
- toolObj: toolObj
1495
- });
1496
- // showItemButtons(layer.getIn(['items', selectedObject.itemID]), currentObject, event, camera, this.renderer);
1497
- var pointArray = [],
1498
- cnt = 0;
1499
- pointArray.push([fVLine[0].userData.distance, 90]);
1500
- pointArray.push([fVLine[1].userData.distance, -90]);
1501
- pointArray.push([fVLine[2].userData.distance, 180]);
1502
- pointArray.push([fVLine[3].userData.distance, 0]);
1503
- pointArray.forEach(function (pointElement, index) {
1504
- if (pointElement[0] == undefined) pointArray[index][0] = 0;
1505
- });
1506
- pointArray.forEach(function (pointElement) {
1507
- if (pointElement[0] == 0) cnt++;
1502
+ setTimeout(function () {
1503
+ getDistances(layer);
1504
+ var selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1505
+ if (isUndefined(selectedItem)) return;
1506
+ selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1507
+ var itemPos = selectedItem.position.clone();
1508
+ if (intersects[_i10].object.parent && intersects[_i10].object.parent.parent.userData.itemId === selectedItem.userData.itemId) {
1509
+ toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
1510
+ } else {
1511
+ 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);
1512
+ }
1513
+ scene3D.add(toolObj);
1514
+ _this2.setState({
1515
+ toolObj: toolObj
1516
+ });
1517
+ // showItemButtons(layer.getIn(['items', selectedObject.itemID]), currentObject, event, camera, this.renderer);
1518
+ var pointArray = [],
1519
+ cnt = 0;
1520
+ pointArray.push([fVLine[0].userData.distance, 90]);
1521
+ pointArray.push([fVLine[1].userData.distance, -90]);
1522
+ pointArray.push([fVLine[2].userData.distance, 180]);
1523
+ pointArray.push([fVLine[3].userData.distance, 0]);
1524
+ pointArray.forEach(function (pointElement, index) {
1525
+ if (pointElement[0] == undefined) pointArray[index][0] = 0;
1526
+ });
1527
+ pointArray.forEach(function (pointElement) {
1528
+ if (pointElement[0] == 0) cnt++;
1529
+ });
1530
+ if (cnt == 4 || cnt == 3) {
1531
+ pointArray[0][0] = 100;
1532
+ pointArray[1][0] = 100;
1533
+ }
1534
+ actions.itemsActions.storeDistArray(layer.id, selectedObject.itemID, pointArray);
1535
+ internalType = internalType ? internalType : INTERNAL_EVENT_SELECT_ELEMENT;
1536
+ sendInternalEvent(internalType, selectedElement, pointArray);
1508
1537
  });
1509
- if (cnt == 4 || cnt == 3) {
1510
- pointArray[0][0] = 100;
1511
- pointArray[1][0] = 100;
1512
- }
1513
- actions.itemsActions.storeDistArray(layer.id, selectedObject.itemID, pointArray);
1514
- internalType = internalType ? internalType : INTERNAL_EVENT_SELECT_ELEMENT;
1515
1538
  } else {
1516
1539
  if (selectedObject) {
1517
1540
  var elementID = null;
@@ -1569,14 +1592,14 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1569
1592
  getPoint(event, alti);
1570
1593
  if (bRotate) {
1571
1594
  var _intersects$_i;
1572
- var _selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1573
- if (isUndefined(_selectedItem)) return;
1595
+ var selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1596
+ if (isUndefined(selectedItem)) return;
1574
1597
  selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1575
- var _itemPos = _selectedItem.position.clone();
1576
- 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) {
1598
+ var itemPos = selectedItem.position.clone();
1599
+ 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) {
1577
1600
  toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
1578
1601
  } else {
1579
- 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);
1602
+ 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);
1580
1603
  }
1581
1604
  scene3D.add(toolObj);
1582
1605
  _this2.setState({
@@ -1587,14 +1610,14 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1587
1610
  }
1588
1611
  if (bMove) {
1589
1612
  bMove = false;
1590
- var _selectedItem2 = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1591
- if (isUndefined(_selectedItem2)) return;
1613
+ var _selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1614
+ if (isUndefined(_selectedItem)) return;
1592
1615
  selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1593
- var _itemPos2 = _selectedItem2.position.clone();
1594
- if (intersects[_i10].object.parent.parent.userData.itemId === _selectedItem2.userData.itemId) {
1616
+ var _itemPos = _selectedItem.position.clone();
1617
+ if (intersects[_i10].object.parent.parent.userData.itemId === _selectedItem.userData.itemId) {
1595
1618
  toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
1596
1619
  } else {
1597
- 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);
1620
+ 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);
1598
1621
  }
1599
1622
  scene3D.add(toolObj);
1600
1623
  _this2.setState({
@@ -1628,20 +1651,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1628
1651
  selectedObj = allItemRect.cur;
1629
1652
  }
1630
1653
  }
1631
- if (!isEmpty(internalType)) {
1632
- var _selectedElement, _selectedElement2, _this2$props$onIntern, _this2$props;
1633
- var payload = (_selectedElement = selectedElement) === null || _selectedElement === void 0 ? void 0 : _selectedElement.toJS();
1634
- if (((_selectedElement2 = selectedElement) === null || _selectedElement2 === void 0 ? void 0 : _selectedElement2.prototype) === 'items') {
1635
- // check this cabinet has warning box
1636
- payload.isWarning = isWarningItem(selectedElement);
1637
- // check this item is snapped to wall
1638
- payload.isAttachedWall = MoldingUtils.isAttachedWall(layer, selectedElement);
1639
- }
1640
- (_this2$props$onIntern = (_this2$props = _this2.props).onInternalEvent) === null || _this2$props$onIntern === void 0 || _this2$props$onIntern.call(_this2$props, {
1641
- type: internalType,
1642
- value: payload
1643
- });
1644
- }
1654
+ sendInternalEvent(internalType, selectedElement);
1645
1655
  };
1646
1656
  this.mouseEnterEvent = function (event) {
1647
1657
  if (_this2.props.state.mode !== MODE_DRAWING_ITEM_3D) return;
@@ -2609,9 +2619,10 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
2609
2619
  }, /*#__PURE__*/React.createElement("img", {
2610
2620
  style: {
2611
2621
  animation: 'spin 2s linear infinite',
2612
- marginTop: "50%",
2613
- width: '50px',
2614
- height: '50px'
2622
+ position: "absolute",
2623
+ top: "50%",
2624
+ width: '70px',
2625
+ height: '70px'
2615
2626
  },
2616
2627
  src: '/assets/img/loading/loading.gif',
2617
2628
  alt: "img"
@@ -2631,8 +2642,8 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
2631
2642
  animation: 'spin 2s linear infinite',
2632
2643
  position: "absolute",
2633
2644
  top: "50%",
2634
- width: '50px',
2635
- height: '50px'
2645
+ width: '70px',
2646
+ height: '70px'
2636
2647
  },
2637
2648
  src: '/assets/img/loading/loading.gif',
2638
2649
  alt: "img"
package/es/constants.js CHANGED
@@ -747,6 +747,7 @@ export var INTERNAL_EVENT_DRAG_ELEMENT = 'INTERNAL_EVENT_DRAG_ELEMENT';
747
747
  export var INTERNAL_EVENT_DRAW_ELEMENT = 'INTERNAL_EVENT_DRAW_ELEMENT';
748
748
  export var INTERNAL_EVENT_ROTATE_ELEMENT = 'INTERNAL_EVENT_ROTATE_ELEMENT';
749
749
  export var INTERNAL_EVENT_REPLACE_CABINET = 'INTERNAL_EVENT_REPLACE_CABINET';
750
+ export var INTERNAL_EVENT_START_DRAW_WALL = 'INTERNAL_EVENT_START_DRAW_WALL';
750
751
 
751
752
  // room shape type
752
753
  export var ROOM_SHAPE_TYPE = {
@@ -13,7 +13,7 @@ export default function (state, action) {
13
13
  state = state.merge({
14
14
  sceneHistory: history.historyPush(state.sceneHistory, state.scene)
15
15
  });
16
- return Line.beginDrawingLine(state, action.layerID, action.x, action.y).updatedState;
16
+ return Line.beginDrawingLine(state, action.layerID, action.x, action.y, action.onInternalEvent).updatedState;
17
17
  case UPDATE_DRAWING_LINE:
18
18
  return Line.updateDrawingLine(state, action.x, action.y, action.relatedLines).updatedState;
19
19
  case STOP_DRAWING_LINE: