kitchen-simulator 3.1.15 → 3.2.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.
@@ -137,6 +137,7 @@ export default function (_ref) {
137
137
  img: base,
138
138
  obj: obj_property,
139
139
  cds: cds,
140
+ structure_json: structure_json,
140
141
  render2D: function render2D(element, layer, scene) {
141
142
  return render2DItem.call(this, element, layer, scene, sizeinfo, layoutpos, is_corner, shape_svg);
142
143
  },
@@ -16,7 +16,7 @@ import { verticesDistance } from "../../utils/geometry";
16
16
  import * as GeomUtils from "../../catalog/utils/geom-utils";
17
17
  import { loadTexture } from "../../catalog/utils/item-loader";
18
18
  import { returnReplaceableDeepSearchType } from "../viewer2d/utils";
19
- import { animateDoor, isElevationView, isEmpty, replaceMeshesWithLineSegments, translateDrawer } from "../../utils/helper";
19
+ import { animateDoor, isElevationView, isEmpty, isImmutable, replaceMeshesWithLineSegments, translateDrawer } from "../../utils/helper";
20
20
  import { formatNumber } from "../../utils/math";
21
21
  var transformBox;
22
22
  export var fVLine = [];
@@ -187,6 +187,31 @@ export function createWarningObject() {
187
187
  warningObj.name = 'warningObj';
188
188
  return warningObj;
189
189
  }
190
+ function swapLengthProperty(diffs) {
191
+ var idx1 = diffs.findIndex(function (v) {
192
+ return v.path[v.path.length - 1] === 'length';
193
+ });
194
+ var idx2 = diffs.findIndex(function (v) {
195
+ return v.path[v.path.length - 1] === '_length';
196
+ });
197
+ if (idx1 < 0 || idx2 < 0) return diffs;
198
+ if (idx1 > idx2) return diffs;
199
+ if (diffs[idx1].op === diffs[idx2].op) {
200
+ var isSwap = true;
201
+ for (var i = 0; i < diffs[idx1].path.length - 2; i++) {
202
+ if (diffs[idx1].path[i] !== diffs[idx2].path[i]) {
203
+ isSwap = false;
204
+ break;
205
+ }
206
+ }
207
+ if (isSwap) {
208
+ var temp = diffs[idx1];
209
+ diffs[idx1] = diffs[idx2];
210
+ diffs[idx2] = temp;
211
+ }
212
+ }
213
+ return diffs;
214
+ }
190
215
  export function updateScene(planData, sceneData, oldSceneData, diffArray, actions, catalog) {
191
216
  var _draggingItem$toJS, _filteredDiffs, _filteredDiffs2;
192
217
  var mode = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
@@ -204,6 +229,9 @@ export function updateScene(planData, sceneData, oldSceneData, diffArray, action
204
229
  value: el.value
205
230
  };
206
231
  });
232
+
233
+ // move "length" to after "_length"
234
+ splitted = swapLengthProperty(splitted);
207
235
  var filteredDiffs = filterDiffs(splitted, sceneData, oldSceneData);
208
236
  //***testing additional filter***
209
237
  filteredDiffs = filteredDiffs.filter(function (_ref) {
@@ -3418,9 +3446,11 @@ export function updateMoldingGroupArray(MGArray, selItem, planData, layer) {
3418
3446
  // refresh mesh of the updating molding groups
3419
3447
  new_MGArray.forEach(function (mg, index) {
3420
3448
  if (mg.items[0].molding.some(function (mol) {
3421
- return mol.location_type === mg.location_type;
3449
+ return isImmutable(mol) ? mol.toJS().location_type === mg.location_type : mol.location_type === mg.location_type;
3422
3450
  })) {
3423
- var molding = mg.items[0].molding.filter(function (mol) {
3451
+ var molding = isImmutable(mg.items[0].molding) ? mg.items[0].molding.filter(function (mol) {
3452
+ return mol.toJS().location_type === mg.location_type;
3453
+ }).toJS()[0] : mg.items[0].molding.filter(function (mol) {
3424
3454
  return mol.location_type === mg.location_type;
3425
3455
  })[0];
3426
3456
  if (mg.molding === null || mg.molding.itemID !== mol.itemID || mg.lines === null || mg.points === null) {
@@ -1490,8 +1490,8 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1490
1490
  }
1491
1491
  gridMatrix.copy(gridPlane.matrixWorld).invert();
1492
1492
  var addItemToolObj = function addItemToolObj() {
1493
- var _intersects$_i;
1494
- var selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1493
+ var _planData$sceneGraph, _selectedObject, _intersects$_i;
1494
+ var selectedItem = (_planData$sceneGraph = planData.sceneGraph) === null || _planData$sceneGraph === void 0 || (_planData$sceneGraph = _planData$sceneGraph.layers[selectedObject.layerID]) === null || _planData$sceneGraph === void 0 ? void 0 : _planData$sceneGraph.items[(_selectedObject = selectedObject) === null || _selectedObject === void 0 ? void 0 : _selectedObject.itemID];
1495
1495
  if (isUndefined(selectedItem)) return;
1496
1496
  selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1497
1497
  var itemPos = selectedItem.position.clone();
@@ -1592,6 +1592,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1592
1592
  selectedObj = allItemRect.cur;
1593
1593
  }
1594
1594
  } else {
1595
+ var _planData$sceneGraph2, _selectedObject2, _selectedObject3;
1595
1596
  visibleTransformBox(false);
1596
1597
  var alti = 0;
1597
1598
  if (allItemRect && allItemRect.cur && allItemRect.cur.itemInfo !== undefined) {
@@ -1601,16 +1602,17 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1601
1602
  alti = convert(alti).from(_unit2).to(_this2.props.state.scene.unit);
1602
1603
  }
1603
1604
  getPoint(event, alti);
1605
+ var _selectedItem = planData === null || planData === void 0 || (_planData$sceneGraph2 = planData.sceneGraph) === null || _planData$sceneGraph2 === void 0 || (_planData$sceneGraph2 = _planData$sceneGraph2.layers[(_selectedObject2 = selectedObject) === null || _selectedObject2 === void 0 ? void 0 : _selectedObject2.layerID]) === null || _planData$sceneGraph2 === void 0 ? void 0 : _planData$sceneGraph2.items[(_selectedObject3 = selectedObject) === null || _selectedObject3 === void 0 ? void 0 : _selectedObject3.itemID];
1606
+ if (isSelected && !isEmpty(_selectedItem)) addItemToolObj();
1604
1607
  if (bRotate) {
1605
- addItemToolObj();
1606
1608
  _this2.setState({
1607
1609
  toolObj: toolObj
1608
1610
  });
1609
1611
  _this2.context.itemsActions.endRotatingItem3D(Point.x, Point.y);
1610
1612
  bRotate = false;
1611
- } else if (bMove) {
1613
+ }
1614
+ if (bMove) {
1612
1615
  bMove = false;
1613
- addItemToolObj();
1614
1616
  _this2.setState({
1615
1617
  toolObj: toolObj
1616
1618
  });
@@ -1630,7 +1632,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1630
1632
  _item3D.position.z = targetPoint.z;
1631
1633
  _item3D.visible = true;
1632
1634
  }
1633
- } else {}
1635
+ }
1634
1636
  if (bMoveUP) {
1635
1637
  bMoveUP = false;
1636
1638
  }
package/es/models.js CHANGED
@@ -341,7 +341,8 @@ export var CatalogElement = /*#__PURE__*/function (_Record1) {
341
341
  properties: new Map(),
342
342
  obj: new Map(),
343
343
  type: '',
344
- cds: new Map()
344
+ cds: new Map(),
345
+ structure_json: {}
345
346
  }, 'CatalogElement'));
346
347
  export var Catalog = /*#__PURE__*/function (_Record10) {
347
348
  function Catalog() {
@@ -1,3 +1,4 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
1
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
3
  import _typeof from "@babel/runtime/helpers/esm/typeof";
3
4
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
@@ -481,59 +482,116 @@ function addItemToCatalog(_x5, _x6, _x7, _x8) {
481
482
  } // Get attributs of current selected element
482
483
  function _addItemToCatalog() {
483
484
  _addItemToCatalog = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(element, state, catalogInstance, projectActions) {
484
- var _element, _element2;
485
- var elementJs, catalog, outlineSVGData, _element$structure_js, _element$structure_js2, _element$structure_js3, updatedStructureJson;
485
+ var _elementJs, _elementJs3;
486
+ var elementJs, outlineSVGData, _state$getIn, _elementJs$structure_, _elementJs$structure_2, _elementJs$structure_3, cds, _cds$find, _elementJs2, currentCdsId, cdsIdx, ttph, updatedStructureJson, catalogElements, catalogElementKeys, catalogItem, k, _catalogElements$cata, tempPlaceholderArray, _catalogItem$structur, newTempPlaceholderArray, mergedTempPlaceholder;
486
487
  return _regeneratorRuntime.wrap(function (_context5) {
487
488
  while (1) switch (_context5.prev = _context5.next) {
488
489
  case 0:
489
- if (!isEmpty((_element = element) === null || _element === void 0 ? void 0 : _element.name)) {
490
+ if (!isEmpty(element === null || element === void 0 ? void 0 : element.name)) {
490
491
  _context5.next = 1;
491
492
  break;
492
493
  }
493
494
  return _context5.abrupt("return");
494
495
  case 1:
495
- elementJs = element;
496
- catalog = state.getIn(['catalog']).toJS(); // add item to catalog of state
497
- // if (isEmpty(catalog?.elements[element.name])) {
496
+ // clone element
497
+ elementJs = Object.assign({}, element); // if (isEmpty(catalog?.elements[element.name])) {
498
498
  _context5.next = 2;
499
- return loadSVGsByItem(element);
499
+ return loadSVGsByItem(elementJs);
500
500
  case 2:
501
501
  outlineSVGData = _context5.sent;
502
- if (!(((_element2 = element) === null || _element2 === void 0 ? void 0 : _element2.type) === 'cabinet')) {
502
+ if (!(((_elementJs = elementJs) === null || _elementJs === void 0 ? void 0 : _elementJs.type) === 'cabinet')) {
503
503
  _context5.next = 4;
504
504
  break;
505
505
  }
506
+ // move the tempPlaceholder of current door style to first of tempPlaceholders array
507
+ cds = (_state$getIn = state.getIn(['scene', 'layers', 'layer-1', 'doorStyle'])) === null || _state$getIn === void 0 ? void 0 : _state$getIn.cds;
508
+ if (cds) {
509
+ currentCdsId = (_cds$find = cds.find(function (c) {
510
+ return c.itemID === elementJs.itemID;
511
+ })) === null || _cds$find === void 0 ? void 0 : _cds$find.cabinet_door_style_id;
512
+ cdsIdx = (_elementJs2 = elementJs) === null || _elementJs2 === void 0 || (_elementJs2 = _elementJs2.structure_json) === null || _elementJs2 === void 0 || (_elementJs2 = _elementJs2.tempPlaceholders) === null || _elementJs2 === void 0 ? void 0 : _elementJs2.findIndex(function (tph) {
513
+ return tph.id === currentCdsId;
514
+ }); // swap
515
+ if (currentCdsId && cdsIdx >= 0) {
516
+ ttph = elementJs.structure_json.tempPlaceholders[0];
517
+ elementJs.structure_json.tempPlaceholders[0] = elementJs.structure_json.tempPlaceholders[cdsIdx];
518
+ elementJs.structure_json.tempPlaceholders[cdsIdx] = ttph;
519
+ }
520
+ }
506
521
  // make placeholders of element and tempPlaceholder
507
- updatedStructureJson = _objectSpread(_objectSpread({}, element.structure_json), (_element$structure_js = (_element$structure_js2 = element.structure_json) === null || _element$structure_js2 === void 0 || (_element$structure_js2 = _element$structure_js2.tempPlaceholders[0]) === null || _element$structure_js2 === void 0 ? void 0 : _element$structure_js2.structure) !== null && _element$structure_js !== void 0 ? _element$structure_js : {});
508
- element.structure_json = updatedStructureJson;
509
- element = _objectSpread(_objectSpread({}, element), {}, {
522
+ updatedStructureJson = _objectSpread(_objectSpread({}, elementJs.structure_json), (_elementJs$structure_ = (_elementJs$structure_2 = elementJs.structure_json) === null || _elementJs$structure_2 === void 0 || (_elementJs$structure_2 = _elementJs$structure_2.tempPlaceholders[0]) === null || _elementJs$structure_2 === void 0 ? void 0 : _elementJs$structure_2.structure) !== null && _elementJs$structure_ !== void 0 ? _elementJs$structure_ : {});
523
+ elementJs.structure_json = updatedStructureJson;
524
+ elementJs = _objectSpread(_objectSpread({}, elementJs), {}, {
510
525
  cds: {
511
- data: [_objectSpread({}, element.customer_property)],
512
- itemID: element.itemID
526
+ data: [_objectSpread({}, elementJs.customer_property)],
527
+ itemID: elementJs.itemID
513
528
  }
514
529
  });
515
- if (isEmpty((_element$structure_js3 = element.structure_json) === null || _element$structure_js3 === void 0 ? void 0 : _element$structure_js3.tempPlaceholders)) {
530
+ if (isEmpty((_elementJs$structure_3 = elementJs.structure_json) === null || _elementJs$structure_3 === void 0 ? void 0 : _elementJs$structure_3.tempPlaceholders)) {
516
531
  _context5.next = 4;
517
532
  break;
518
533
  }
519
534
  _context5.next = 3;
520
- return updateCabinetPayload(element);
535
+ return updateCabinetPayload(elementJs);
521
536
  case 3:
522
537
  elementJs = _context5.sent;
523
538
  case 4:
524
539
  elementJs = _objectSpread(_objectSpread({}, elementJs), {}, {
525
540
  outlineSVGData: outlineSVGData,
526
- type: element.type,
541
+ type: elementJs.type,
527
542
  render2DItem: render2DItem
528
543
  });
529
- if (element.type === 'appliance' || element.type === 'furnishing') elementJs.render3DItem = render3DApplianceItem;else if (element.type === 'lighting') elementJs.render3DItem = render3DLightingItem;else elementJs.render3DItem = render3DItem;
544
+ if (elementJs.type === 'appliance' || elementJs.type === 'furnishing') elementJs.render3DItem = render3DApplianceItem;else if (elementJs.type === 'lighting') elementJs.render3DItem = render3DLightingItem;else elementJs.render3DItem = render3DItem;
545
+
546
+ /***** join new tempPlaceholder to the old element - start *****/
547
+ // get catalog item by itemID
548
+ catalogElements = state.getIn(['catalog', 'elements']).toJS();
549
+ catalogElementKeys = Object.keys(catalogElements);
550
+ catalogItem = null;
551
+ k = 0;
552
+ case 5:
553
+ if (!(k < catalogElementKeys.length)) {
554
+ _context5.next = 7;
555
+ break;
556
+ }
557
+ if (!(((_catalogElements$cata = catalogElements[catalogElementKeys[k]]) === null || _catalogElements$cata === void 0 ? void 0 : _catalogElements$cata.itemID) === elementJs.itemID)) {
558
+ _context5.next = 6;
559
+ break;
560
+ }
561
+ catalogItem = catalogElements[catalogElementKeys[k]];
562
+ return _context5.abrupt("continue", 7);
563
+ case 6:
564
+ k++;
565
+ _context5.next = 5;
566
+ break;
567
+ case 7:
568
+ // get old tempPlaceholder array from catalog item
569
+ tempPlaceholderArray = null;
570
+ if (!isEmpty(catalogItem)) {
571
+ tempPlaceholderArray = (_catalogItem$structur = catalogItem.structure_json) === null || _catalogItem$structur === void 0 ? void 0 : _catalogItem$structur.tempPlaceholders;
572
+ }
573
+
574
+ // join new tempPlaceholder array to old one
575
+ newTempPlaceholderArray = [];
576
+ (_elementJs3 = elementJs) === null || _elementJs3 === void 0 || (_elementJs3 = _elementJs3.structure_json) === null || _elementJs3 === void 0 || (_elementJs3 = _elementJs3.tempPlaceholders) === null || _elementJs3 === void 0 || _elementJs3.forEach(function (tph) {
577
+ var _tempPlaceholderArray;
578
+ if (!((_tempPlaceholderArray = tempPlaceholderArray) !== null && _tempPlaceholderArray !== void 0 && _tempPlaceholderArray.some(function (otph) {
579
+ return otph.id === tph.id;
580
+ }))) newTempPlaceholderArray.push(tph);
581
+ });
582
+ mergedTempPlaceholder = null;
583
+ if (isEmpty(tempPlaceholderArray)) mergedTempPlaceholder = newTempPlaceholderArray;else if (isEmpty(newTempPlaceholderArray)) mergedTempPlaceholder = tempPlaceholderArray;else mergedTempPlaceholder = [].concat(_toConsumableArray(tempPlaceholderArray), newTempPlaceholderArray);
584
+
585
+ // rplace new array to the elementJS
586
+ if (!isEmpty(mergedTempPlaceholder)) elementJs.structure_json.tempPlaceholders = mergedTempPlaceholder;
587
+ /***** join new tempPlaceholder to the old element - end *****/
588
+
530
589
  elementJs = exporter(elementJs);
531
590
  if (catalogInstance !== null && catalogInstance !== void 0 && catalogInstance.validateElement(elementJs)) {
532
591
  catalogInstance.registerElement(elementJs);
533
592
  projectActions.addElementToCatalog(elementJs);
534
593
  }
535
- // }
536
- case 5:
594
+ case 8:
537
595
  case "end":
538
596
  return _context5.stop();
539
597
  }
@@ -722,11 +780,11 @@ function updateAttributeOfSelectedElement(element, attrPayload, state, layer, ca
722
780
  attributesFormData = attributesFormData.set('y', yVal);
723
781
  } else {
724
782
  attributesFormData = attributesFormData.set(attributeName, value);
725
- // update the distances from wall
726
- var _GeometryUtils$calcDi = GeometryUtils.calcDistancesFromItemToWalls(attributesFormData, layer),
727
- PointArray = _GeometryUtils$calcDi.PointArray;
728
- attributesFormData = attributesFormData.set('distArray', PointArray);
729
783
  }
784
+ // update the distances from wall
785
+ var _GeometryUtils$calcDi = GeometryUtils.calcDistancesFromItemToWalls(attributesFormData, layer),
786
+ PointArray = _GeometryUtils$calcDi.PointArray;
787
+ attributesFormData = attributesFormData.set('distArray', PointArray);
730
788
  break;
731
789
  }
732
790
  case 'lines':
@@ -1093,7 +1151,7 @@ export function handleExternalEvent(_x10) {
1093
1151
  function _handleExternalEvent() {
1094
1152
  _handleExternalEvent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(props) {
1095
1153
  var _evt$payload3, _evt$payload4;
1096
- var evt, state, layerId, layer, _evt$payload, cdsItems, itemKeys, _loop3, i, _props$onInternalEven, sLineCnt, _state$getIn, element, cds, _cds$find, currentCdsId, _state$viewer2D, _evt$payload$initialP, mouseX, mouseY, v2d, vPosX, vPosY, layerID, defaulTitle, _Object$keys, _evt$payload5, doorStyle, itemCDS, isAll, _layerId, _cdsItems, allItems, selectedItemId, _itemKeys, _loop4, _i2, _props$onInternalEven2, _evt$payload6, roomShapeType, width, height, _doorStyle, value, _value, _evt$payload7, moldingInfo, isGlobal, distElement, _distElement, _evt$payload8, option, _value2, _layerId2, _layer, _layer$getIn, selectedLines, selectedHoles, selectedItems, _i4, _i5, _i6, _evt$payload9, _evt$payload0, _evt$payload1, _evt$payload10, _layerID, _layer2, orginalItemInfo, originalItem, originalItemPos, replaceItem, _props$onInternalEven3, sceneData, currentTexture, _t5, _t6;
1154
+ var evt, state, layerId, layer, _evt$payload, cdsItems, itemKeys, _loop3, i, _props$onInternalEven, sLineCnt, element, _state$viewer2D, _evt$payload$initialP, mouseX, mouseY, v2d, vPosX, vPosY, layerID, defaulTitle, _Object$keys, _evt$payload5, doorStyle, itemCDS, isAll, _layerId, _cdsItems, allItems, selectedItemId, _itemKeys, _loop4, _i2, _props$onInternalEven2, _evt$payload6, roomShapeType, width, height, _doorStyle, value, _value, _evt$payload7, moldingInfo, isGlobal, distElement, _distElement, _evt$payload8, option, _value2, _layerId2, _layer, _layer$getIn, selectedLines, selectedHoles, selectedItems, _i4, _i5, _i6, _evt$payload9, _evt$payload0, _evt$payload1, _evt$payload10, _layerID, _layer2, orginalItemInfo, originalItem, originalItemPos, replaceItem, _props$onInternalEven3, sceneData, currentTexture, _t5, _t6;
1097
1155
  return _regeneratorRuntime.wrap(function (_context1) {
1098
1156
  while (1) switch (_context1.prev = _context1.next) {
1099
1157
  case 0:
@@ -1210,19 +1268,7 @@ function _handleExternalEvent() {
1210
1268
  _context1.next = 11;
1211
1269
  break;
1212
1270
  }
1213
- element = evt.payload; ///// filter the tempPlaceholders using layer-doorstyle-cds
1214
- cds = (_state$getIn = state.getIn(['scene', 'layers', 'layer-1', 'doorStyle'])) === null || _state$getIn === void 0 ? void 0 : _state$getIn.cds;
1215
- if (cds) {
1216
- currentCdsId = (_cds$find = cds.find(function (c) {
1217
- return c.itemID === element.itemID;
1218
- })) === null || _cds$find === void 0 ? void 0 : _cds$find.cabinet_door_style_id;
1219
- if (currentCdsId && element.structure_json.tempPlaceholders.length > 0) {
1220
- element.structure_json.tempPlaceholders[0] = element.structure_json.tempPlaceholders.find(function (tPlaceholder) {
1221
- return tPlaceholder.id === currentCdsId;
1222
- });
1223
- }
1224
- }
1225
- /////
1271
+ element = evt.payload;
1226
1272
  _context1.next = 10;
1227
1273
  return addItemToCatalog(element, state, props.catalog, props.projectActions);
1228
1274
  case 10:
@@ -144,6 +144,7 @@ function _default(_ref) {
144
144
  img: base,
145
145
  obj: obj_property,
146
146
  cds: cds,
147
+ structure_json: structure_json,
147
148
  render2D: function render2D(element, layer, scene) {
148
149
  return render2DItem.call(this, element, layer, scene, sizeinfo, layoutpos, is_corner, shape_svg);
149
150
  },
@@ -222,6 +222,31 @@ function createWarningObject() {
222
222
  warningObj.name = 'warningObj';
223
223
  return warningObj;
224
224
  }
225
+ function swapLengthProperty(diffs) {
226
+ var idx1 = diffs.findIndex(function (v) {
227
+ return v.path[v.path.length - 1] === 'length';
228
+ });
229
+ var idx2 = diffs.findIndex(function (v) {
230
+ return v.path[v.path.length - 1] === '_length';
231
+ });
232
+ if (idx1 < 0 || idx2 < 0) return diffs;
233
+ if (idx1 > idx2) return diffs;
234
+ if (diffs[idx1].op === diffs[idx2].op) {
235
+ var isSwap = true;
236
+ for (var i = 0; i < diffs[idx1].path.length - 2; i++) {
237
+ if (diffs[idx1].path[i] !== diffs[idx2].path[i]) {
238
+ isSwap = false;
239
+ break;
240
+ }
241
+ }
242
+ if (isSwap) {
243
+ var temp = diffs[idx1];
244
+ diffs[idx1] = diffs[idx2];
245
+ diffs[idx2] = temp;
246
+ }
247
+ }
248
+ return diffs;
249
+ }
225
250
  function updateScene(planData, sceneData, oldSceneData, diffArray, actions, catalog) {
226
251
  var _draggingItem$toJS, _filteredDiffs, _filteredDiffs2;
227
252
  var mode = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
@@ -239,6 +264,9 @@ function updateScene(planData, sceneData, oldSceneData, diffArray, actions, cata
239
264
  value: el.value
240
265
  };
241
266
  });
267
+
268
+ // move "length" to after "_length"
269
+ splitted = swapLengthProperty(splitted);
242
270
  var filteredDiffs = filterDiffs(splitted, sceneData, oldSceneData);
243
271
  //***testing additional filter***
244
272
  filteredDiffs = filteredDiffs.filter(function (_ref) {
@@ -3453,9 +3481,11 @@ function updateMoldingGroupArray(MGArray, selItem, planData, layer) {
3453
3481
  // refresh mesh of the updating molding groups
3454
3482
  new_MGArray.forEach(function (mg, index) {
3455
3483
  if (mg.items[0].molding.some(function (mol) {
3456
- return mol.location_type === mg.location_type;
3484
+ return (0, _helper.isImmutable)(mol) ? mol.toJS().location_type === mg.location_type : mol.location_type === mg.location_type;
3457
3485
  })) {
3458
- var molding = mg.items[0].molding.filter(function (mol) {
3486
+ var molding = (0, _helper.isImmutable)(mg.items[0].molding) ? mg.items[0].molding.filter(function (mol) {
3487
+ return mol.toJS().location_type === mg.location_type;
3488
+ }).toJS()[0] : mg.items[0].molding.filter(function (mol) {
3459
3489
  return mol.location_type === mg.location_type;
3460
3490
  })[0];
3461
3491
  if (mg.molding === null || mg.molding.itemID !== mol.itemID || mg.lines === null || mg.points === null) {
@@ -1496,8 +1496,8 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1496
1496
  }
1497
1497
  gridMatrix.copy(gridPlane.matrixWorld).invert();
1498
1498
  var addItemToolObj = function addItemToolObj() {
1499
- var _intersects$_i;
1500
- var selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1499
+ var _planData$sceneGraph, _selectedObject, _intersects$_i;
1500
+ var selectedItem = (_planData$sceneGraph = planData.sceneGraph) === null || _planData$sceneGraph === void 0 || (_planData$sceneGraph = _planData$sceneGraph.layers[selectedObject.layerID]) === null || _planData$sceneGraph === void 0 ? void 0 : _planData$sceneGraph.items[(_selectedObject = selectedObject) === null || _selectedObject === void 0 ? void 0 : _selectedObject.itemID];
1501
1501
  if ((0, _util.isUndefined)(selectedItem)) return;
1502
1502
  selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1503
1503
  var itemPos = selectedItem.position.clone();
@@ -1598,6 +1598,7 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1598
1598
  selectedObj = allItemRect.cur;
1599
1599
  }
1600
1600
  } else {
1601
+ var _planData$sceneGraph2, _selectedObject2, _selectedObject3;
1601
1602
  (0, _sceneCreator.visibleTransformBox)(false);
1602
1603
  var alti = 0;
1603
1604
  if (allItemRect && allItemRect.cur && allItemRect.cur.itemInfo !== undefined) {
@@ -1607,16 +1608,17 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1607
1608
  alti = (0, _convertUnitsLite.convert)(alti).from(_unit2).to(_this2.props.state.scene.unit);
1608
1609
  }
1609
1610
  getPoint(event, alti);
1611
+ var _selectedItem = planData === null || planData === void 0 || (_planData$sceneGraph2 = planData.sceneGraph) === null || _planData$sceneGraph2 === void 0 || (_planData$sceneGraph2 = _planData$sceneGraph2.layers[(_selectedObject2 = selectedObject) === null || _selectedObject2 === void 0 ? void 0 : _selectedObject2.layerID]) === null || _planData$sceneGraph2 === void 0 ? void 0 : _planData$sceneGraph2.items[(_selectedObject3 = selectedObject) === null || _selectedObject3 === void 0 ? void 0 : _selectedObject3.itemID];
1612
+ if (isSelected && !(0, _helper.isEmpty)(_selectedItem)) addItemToolObj();
1610
1613
  if (bRotate) {
1611
- addItemToolObj();
1612
1614
  _this2.setState({
1613
1615
  toolObj: toolObj
1614
1616
  });
1615
1617
  _this2.context.itemsActions.endRotatingItem3D(Point.x, Point.y);
1616
1618
  bRotate = false;
1617
- } else if (bMove) {
1619
+ }
1620
+ if (bMove) {
1618
1621
  bMove = false;
1619
- addItemToolObj();
1620
1622
  _this2.setState({
1621
1623
  toolObj: toolObj
1622
1624
  });
@@ -1636,7 +1638,7 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1636
1638
  _item3D.position.z = targetPoint.z;
1637
1639
  _item3D.visible = true;
1638
1640
  }
1639
- } else {}
1641
+ }
1640
1642
  if (bMoveUP) {
1641
1643
  bMoveUP = false;
1642
1644
  }
package/lib/models.js CHANGED
@@ -348,7 +348,8 @@ var CatalogElement = exports.CatalogElement = /*#__PURE__*/function (_Record1) {
348
348
  properties: new _immutable.Map(),
349
349
  obj: new _immutable.Map(),
350
350
  type: '',
351
- cds: new _immutable.Map()
351
+ cds: new _immutable.Map(),
352
+ structure_json: {}
352
353
  }, 'CatalogElement'));
353
354
  var Catalog = exports.Catalog = /*#__PURE__*/function (_Record10) {
354
355
  function Catalog() {
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.handleExternalEvent = handleExternalEvent;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
11
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
12
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
@@ -488,59 +489,116 @@ function addItemToCatalog(_x5, _x6, _x7, _x8) {
488
489
  } // Get attributs of current selected element
489
490
  function _addItemToCatalog() {
490
491
  _addItemToCatalog = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(element, state, catalogInstance, projectActions) {
491
- var _element, _element2;
492
- var elementJs, catalog, outlineSVGData, _element$structure_js, _element$structure_js2, _element$structure_js3, updatedStructureJson;
492
+ var _elementJs, _elementJs3;
493
+ var elementJs, outlineSVGData, _state$getIn, _elementJs$structure_, _elementJs$structure_2, _elementJs$structure_3, cds, _cds$find, _elementJs2, currentCdsId, cdsIdx, ttph, updatedStructureJson, catalogElements, catalogElementKeys, catalogItem, k, _catalogElements$cata, tempPlaceholderArray, _catalogItem$structur, newTempPlaceholderArray, mergedTempPlaceholder;
493
494
  return _regenerator["default"].wrap(function (_context5) {
494
495
  while (1) switch (_context5.prev = _context5.next) {
495
496
  case 0:
496
- if (!(0, _helper.isEmpty)((_element = element) === null || _element === void 0 ? void 0 : _element.name)) {
497
+ if (!(0, _helper.isEmpty)(element === null || element === void 0 ? void 0 : element.name)) {
497
498
  _context5.next = 1;
498
499
  break;
499
500
  }
500
501
  return _context5.abrupt("return");
501
502
  case 1:
502
- elementJs = element;
503
- catalog = state.getIn(['catalog']).toJS(); // add item to catalog of state
504
- // if (isEmpty(catalog?.elements[element.name])) {
503
+ // clone element
504
+ elementJs = Object.assign({}, element); // if (isEmpty(catalog?.elements[element.name])) {
505
505
  _context5.next = 2;
506
- return loadSVGsByItem(element);
506
+ return loadSVGsByItem(elementJs);
507
507
  case 2:
508
508
  outlineSVGData = _context5.sent;
509
- if (!(((_element2 = element) === null || _element2 === void 0 ? void 0 : _element2.type) === 'cabinet')) {
509
+ if (!(((_elementJs = elementJs) === null || _elementJs === void 0 ? void 0 : _elementJs.type) === 'cabinet')) {
510
510
  _context5.next = 4;
511
511
  break;
512
512
  }
513
+ // move the tempPlaceholder of current door style to first of tempPlaceholders array
514
+ cds = (_state$getIn = state.getIn(['scene', 'layers', 'layer-1', 'doorStyle'])) === null || _state$getIn === void 0 ? void 0 : _state$getIn.cds;
515
+ if (cds) {
516
+ currentCdsId = (_cds$find = cds.find(function (c) {
517
+ return c.itemID === elementJs.itemID;
518
+ })) === null || _cds$find === void 0 ? void 0 : _cds$find.cabinet_door_style_id;
519
+ cdsIdx = (_elementJs2 = elementJs) === null || _elementJs2 === void 0 || (_elementJs2 = _elementJs2.structure_json) === null || _elementJs2 === void 0 || (_elementJs2 = _elementJs2.tempPlaceholders) === null || _elementJs2 === void 0 ? void 0 : _elementJs2.findIndex(function (tph) {
520
+ return tph.id === currentCdsId;
521
+ }); // swap
522
+ if (currentCdsId && cdsIdx >= 0) {
523
+ ttph = elementJs.structure_json.tempPlaceholders[0];
524
+ elementJs.structure_json.tempPlaceholders[0] = elementJs.structure_json.tempPlaceholders[cdsIdx];
525
+ elementJs.structure_json.tempPlaceholders[cdsIdx] = ttph;
526
+ }
527
+ }
513
528
  // make placeholders of element and tempPlaceholder
514
- updatedStructureJson = _objectSpread(_objectSpread({}, element.structure_json), (_element$structure_js = (_element$structure_js2 = element.structure_json) === null || _element$structure_js2 === void 0 || (_element$structure_js2 = _element$structure_js2.tempPlaceholders[0]) === null || _element$structure_js2 === void 0 ? void 0 : _element$structure_js2.structure) !== null && _element$structure_js !== void 0 ? _element$structure_js : {});
515
- element.structure_json = updatedStructureJson;
516
- element = _objectSpread(_objectSpread({}, element), {}, {
529
+ updatedStructureJson = _objectSpread(_objectSpread({}, elementJs.structure_json), (_elementJs$structure_ = (_elementJs$structure_2 = elementJs.structure_json) === null || _elementJs$structure_2 === void 0 || (_elementJs$structure_2 = _elementJs$structure_2.tempPlaceholders[0]) === null || _elementJs$structure_2 === void 0 ? void 0 : _elementJs$structure_2.structure) !== null && _elementJs$structure_ !== void 0 ? _elementJs$structure_ : {});
530
+ elementJs.structure_json = updatedStructureJson;
531
+ elementJs = _objectSpread(_objectSpread({}, elementJs), {}, {
517
532
  cds: {
518
- data: [_objectSpread({}, element.customer_property)],
519
- itemID: element.itemID
533
+ data: [_objectSpread({}, elementJs.customer_property)],
534
+ itemID: elementJs.itemID
520
535
  }
521
536
  });
522
- if ((0, _helper.isEmpty)((_element$structure_js3 = element.structure_json) === null || _element$structure_js3 === void 0 ? void 0 : _element$structure_js3.tempPlaceholders)) {
537
+ if ((0, _helper.isEmpty)((_elementJs$structure_3 = elementJs.structure_json) === null || _elementJs$structure_3 === void 0 ? void 0 : _elementJs$structure_3.tempPlaceholders)) {
523
538
  _context5.next = 4;
524
539
  break;
525
540
  }
526
541
  _context5.next = 3;
527
- return updateCabinetPayload(element);
542
+ return updateCabinetPayload(elementJs);
528
543
  case 3:
529
544
  elementJs = _context5.sent;
530
545
  case 4:
531
546
  elementJs = _objectSpread(_objectSpread({}, elementJs), {}, {
532
547
  outlineSVGData: outlineSVGData,
533
- type: element.type,
548
+ type: elementJs.type,
534
549
  render2DItem: _itemLoader.render2DItem
535
550
  });
536
- if (element.type === 'appliance' || element.type === 'furnishing') elementJs.render3DItem = _itemLoader.render3DApplianceItem;else if (element.type === 'lighting') elementJs.render3DItem = _itemLoader.render3DLightingItem;else elementJs.render3DItem = _itemLoader.render3DItem;
551
+ if (elementJs.type === 'appliance' || elementJs.type === 'furnishing') elementJs.render3DItem = _itemLoader.render3DApplianceItem;else if (elementJs.type === 'lighting') elementJs.render3DItem = _itemLoader.render3DLightingItem;else elementJs.render3DItem = _itemLoader.render3DItem;
552
+
553
+ /***** join new tempPlaceholder to the old element - start *****/
554
+ // get catalog item by itemID
555
+ catalogElements = state.getIn(['catalog', 'elements']).toJS();
556
+ catalogElementKeys = Object.keys(catalogElements);
557
+ catalogItem = null;
558
+ k = 0;
559
+ case 5:
560
+ if (!(k < catalogElementKeys.length)) {
561
+ _context5.next = 7;
562
+ break;
563
+ }
564
+ if (!(((_catalogElements$cata = catalogElements[catalogElementKeys[k]]) === null || _catalogElements$cata === void 0 ? void 0 : _catalogElements$cata.itemID) === elementJs.itemID)) {
565
+ _context5.next = 6;
566
+ break;
567
+ }
568
+ catalogItem = catalogElements[catalogElementKeys[k]];
569
+ return _context5.abrupt("continue", 7);
570
+ case 6:
571
+ k++;
572
+ _context5.next = 5;
573
+ break;
574
+ case 7:
575
+ // get old tempPlaceholder array from catalog item
576
+ tempPlaceholderArray = null;
577
+ if (!(0, _helper.isEmpty)(catalogItem)) {
578
+ tempPlaceholderArray = (_catalogItem$structur = catalogItem.structure_json) === null || _catalogItem$structur === void 0 ? void 0 : _catalogItem$structur.tempPlaceholders;
579
+ }
580
+
581
+ // join new tempPlaceholder array to old one
582
+ newTempPlaceholderArray = [];
583
+ (_elementJs3 = elementJs) === null || _elementJs3 === void 0 || (_elementJs3 = _elementJs3.structure_json) === null || _elementJs3 === void 0 || (_elementJs3 = _elementJs3.tempPlaceholders) === null || _elementJs3 === void 0 || _elementJs3.forEach(function (tph) {
584
+ var _tempPlaceholderArray;
585
+ if (!((_tempPlaceholderArray = tempPlaceholderArray) !== null && _tempPlaceholderArray !== void 0 && _tempPlaceholderArray.some(function (otph) {
586
+ return otph.id === tph.id;
587
+ }))) newTempPlaceholderArray.push(tph);
588
+ });
589
+ mergedTempPlaceholder = null;
590
+ if ((0, _helper.isEmpty)(tempPlaceholderArray)) mergedTempPlaceholder = newTempPlaceholderArray;else if ((0, _helper.isEmpty)(newTempPlaceholderArray)) mergedTempPlaceholder = tempPlaceholderArray;else mergedTempPlaceholder = [].concat((0, _toConsumableArray2["default"])(tempPlaceholderArray), newTempPlaceholderArray);
591
+
592
+ // rplace new array to the elementJS
593
+ if (!(0, _helper.isEmpty)(mergedTempPlaceholder)) elementJs.structure_json.tempPlaceholders = mergedTempPlaceholder;
594
+ /***** join new tempPlaceholder to the old element - end *****/
595
+
537
596
  elementJs = (0, _exporter["default"])(elementJs);
538
597
  if (catalogInstance !== null && catalogInstance !== void 0 && catalogInstance.validateElement(elementJs)) {
539
598
  catalogInstance.registerElement(elementJs);
540
599
  projectActions.addElementToCatalog(elementJs);
541
600
  }
542
- // }
543
- case 5:
601
+ case 8:
544
602
  case "end":
545
603
  return _context5.stop();
546
604
  }
@@ -729,11 +787,11 @@ function updateAttributeOfSelectedElement(element, attrPayload, state, layer, ca
729
787
  attributesFormData = attributesFormData.set('y', yVal);
730
788
  } else {
731
789
  attributesFormData = attributesFormData.set(attributeName, value);
732
- // update the distances from wall
733
- var _GeometryUtils$calcDi = _export.GeometryUtils.calcDistancesFromItemToWalls(attributesFormData, layer),
734
- PointArray = _GeometryUtils$calcDi.PointArray;
735
- attributesFormData = attributesFormData.set('distArray', PointArray);
736
790
  }
791
+ // update the distances from wall
792
+ var _GeometryUtils$calcDi = _export.GeometryUtils.calcDistancesFromItemToWalls(attributesFormData, layer),
793
+ PointArray = _GeometryUtils$calcDi.PointArray;
794
+ attributesFormData = attributesFormData.set('distArray', PointArray);
737
795
  break;
738
796
  }
739
797
  case 'lines':
@@ -1100,7 +1158,7 @@ function handleExternalEvent(_x10) {
1100
1158
  function _handleExternalEvent() {
1101
1159
  _handleExternalEvent = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee9(props) {
1102
1160
  var _evt$payload3, _evt$payload4;
1103
- var evt, state, layerId, layer, _evt$payload, cdsItems, itemKeys, _loop3, i, _props$onInternalEven, sLineCnt, _state$getIn, element, cds, _cds$find, currentCdsId, _state$viewer2D, _evt$payload$initialP, mouseX, mouseY, v2d, vPosX, vPosY, layerID, defaulTitle, _Object$keys, _evt$payload5, doorStyle, itemCDS, isAll, _layerId, _cdsItems, allItems, selectedItemId, _itemKeys, _loop4, _i2, _props$onInternalEven2, _evt$payload6, roomShapeType, width, height, _doorStyle, value, _value, _evt$payload7, moldingInfo, isGlobal, distElement, _distElement, _evt$payload8, option, _value2, _layerId2, _layer, _layer$getIn, selectedLines, selectedHoles, selectedItems, _i4, _i5, _i6, _evt$payload9, _evt$payload0, _evt$payload1, _evt$payload10, _layerID, _layer2, orginalItemInfo, originalItem, originalItemPos, replaceItem, _props$onInternalEven3, sceneData, currentTexture, _t5, _t6;
1161
+ var evt, state, layerId, layer, _evt$payload, cdsItems, itemKeys, _loop3, i, _props$onInternalEven, sLineCnt, element, _state$viewer2D, _evt$payload$initialP, mouseX, mouseY, v2d, vPosX, vPosY, layerID, defaulTitle, _Object$keys, _evt$payload5, doorStyle, itemCDS, isAll, _layerId, _cdsItems, allItems, selectedItemId, _itemKeys, _loop4, _i2, _props$onInternalEven2, _evt$payload6, roomShapeType, width, height, _doorStyle, value, _value, _evt$payload7, moldingInfo, isGlobal, distElement, _distElement, _evt$payload8, option, _value2, _layerId2, _layer, _layer$getIn, selectedLines, selectedHoles, selectedItems, _i4, _i5, _i6, _evt$payload9, _evt$payload0, _evt$payload1, _evt$payload10, _layerID, _layer2, orginalItemInfo, originalItem, originalItemPos, replaceItem, _props$onInternalEven3, sceneData, currentTexture, _t5, _t6;
1104
1162
  return _regenerator["default"].wrap(function (_context1) {
1105
1163
  while (1) switch (_context1.prev = _context1.next) {
1106
1164
  case 0:
@@ -1217,19 +1275,7 @@ function _handleExternalEvent() {
1217
1275
  _context1.next = 11;
1218
1276
  break;
1219
1277
  }
1220
- element = evt.payload; ///// filter the tempPlaceholders using layer-doorstyle-cds
1221
- cds = (_state$getIn = state.getIn(['scene', 'layers', 'layer-1', 'doorStyle'])) === null || _state$getIn === void 0 ? void 0 : _state$getIn.cds;
1222
- if (cds) {
1223
- currentCdsId = (_cds$find = cds.find(function (c) {
1224
- return c.itemID === element.itemID;
1225
- })) === null || _cds$find === void 0 ? void 0 : _cds$find.cabinet_door_style_id;
1226
- if (currentCdsId && element.structure_json.tempPlaceholders.length > 0) {
1227
- element.structure_json.tempPlaceholders[0] = element.structure_json.tempPlaceholders.find(function (tPlaceholder) {
1228
- return tPlaceholder.id === currentCdsId;
1229
- });
1230
- }
1231
- }
1232
- /////
1278
+ element = evt.payload;
1233
1279
  _context1.next = 10;
1234
1280
  return addItemToCatalog(element, state, props.catalog, props.projectActions);
1235
1281
  case 10:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "3.1.15",
3
+ "version": "3.2.0",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",