kitchen-simulator 3.13.0 → 3.14.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.
@@ -12,7 +12,9 @@ exports.getItemRect = getItemRect;
12
12
  exports.getLinesFromItems = getLinesFromItems;
13
13
  exports.getLinesFromItems2 = getLinesFromItems2;
14
14
  exports.getLinesOfItem = getLinesOfItem;
15
+ exports.getLinesOfItem2 = getLinesOfItem2;
15
16
  exports.getMoldingDataOfScene = getMoldingDataOfScene;
17
+ exports.getMoldingDataOfScene2 = getMoldingDataOfScene2;
16
18
  exports.hasMoldingLayout = hasMoldingLayout;
17
19
  exports.isAttachedWall = isAttachedWall;
18
20
  exports.isEnableItemForMolding = isEnableItemForMolding;
@@ -331,6 +333,74 @@ function getLinesOfItem(item, allLineRects, catalog) {
331
333
  }
332
334
  return lines;
333
335
  }
336
+ function getLinesOfItem2(item, allLineRects, catalog) {
337
+ var lines = [];
338
+ var outline = null;
339
+ var element = catalog.elements[item.get('type')];
340
+ if (!element) element = catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(item.get('type'))];
341
+ // get edge lines
342
+ var newWidth = item.properties.get('width').get('_length');
343
+ var wUnit = item.properties.get('width').get('_unit') || 'cm';
344
+ newWidth = (0, _convertUnitsLite.convert)(newWidth).from(wUnit).to('cm');
345
+ var newDepth = item.properties.get('depth').get('_length');
346
+ var hUnit = item.properties.get('depth').get('_unit') || 'cm';
347
+ newDepth = (0, _convertUnitsLite.convert)(newDepth).from(hUnit).to('cm');
348
+ if (item) {
349
+ // Get Outline Data of Selected Item
350
+ outline = element.info.outline;
351
+ if (outline) {
352
+ // Extract Points from `outline`
353
+ var outlinePaths = outline.paths;
354
+ var outlineWidth = outline.svgWidth;
355
+ var outlineHeight = outline.svgHeight;
356
+ var outlinePoints = []; // Hold Points Of SVG
357
+ var _iterator3 = _createForOfIteratorHelper(outlinePaths),
358
+ _step3;
359
+ try {
360
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
361
+ var path = _step3.value;
362
+ var _iterator4 = _createForOfIteratorHelper(path.subPaths),
363
+ _step4;
364
+ try {
365
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
366
+ var subPath = _step4.value;
367
+ outlinePoints = outlinePoints.concat(subPath.getPoints());
368
+ }
369
+ } catch (err) {
370
+ _iterator4.e(err);
371
+ } finally {
372
+ _iterator4.f();
373
+ }
374
+ }
375
+ } catch (err) {
376
+ _iterator3.e(err);
377
+ } finally {
378
+ _iterator3.f();
379
+ }
380
+ outline.reverse && outlinePoints.reverse();
381
+ for (var i = 0; i < outlinePoints.length - 1; i++) {
382
+ lines.push([_export.GeometryUtils.rotatePointAroundPoint((outlinePoints[i].x / outlineWidth - 0.5) * newWidth + item.x, (outlinePoints[i].y / outlineHeight - 0.5) * newDepth + item.y, item.x, item.y, item.rotation + 90), _export.GeometryUtils.rotatePointAroundPoint((outlinePoints[i + 1].x / outlineWidth - 0.5) * newWidth + item.x, (outlinePoints[i + 1].y / outlineHeight - 0.5) * newDepth + item.y, item.x, item.y, item.rotation + 90), _idBroker["default"].acquireID()]);
383
+ }
384
+ } else {
385
+ var pos = [[-1, -1], [1, -1], [1, 1], [-1, 1]];
386
+ for (var _i2 = 0; _i2 < 4; _i2++) {
387
+ lines.push([_export.GeometryUtils.rotatePointAroundPoint(pos[_i2][0] * newWidth / 2 + item.x, pos[_i2][1] * newDepth / 2 + item.y, item.x, item.y, item.rotation), _export.GeometryUtils.rotatePointAroundPoint(pos[(_i2 + 1) % 4][0] * newWidth / 2 + item.x, pos[(_i2 + 1) % 4][1] * newDepth / 2 + item.y, item.x, item.y, item.rotation), _idBroker["default"].acquireID()]);
388
+ }
389
+ }
390
+ }
391
+ lines = lines.filter(function (line) {
392
+ return !_export.GeometryUtils.isSnappedLine({
393
+ rect: [{
394
+ x: 0,
395
+ y: 0
396
+ }, {
397
+ x: 0,
398
+ y: 0
399
+ }, line[0], line[1]]
400
+ }, allLineRects);
401
+ });
402
+ return lines;
403
+ }
334
404
  function isParallelLines(line1, line2) {
335
405
  var isParallel = false;
336
406
  if (Math.abs(line1[0].y - line1[1].y) <= _constants.EPSILON && Math.abs(line2[0].y - line2[1].y) <= _constants.EPSILON) isParallel = true;
@@ -512,20 +582,20 @@ function getLinesFromItems2(moldingGroup, layer, catalog) {
512
582
  // merge the collinear linked lines to one line
513
583
  var newMGlines = [];
514
584
  var filteredMGlines = MGlines;
515
- var _loop3 = function _loop3(_i2) {
585
+ var _loop3 = function _loop3(_i3) {
516
586
  if (filteredMGlines.length < 1) return 0; // break
517
587
  if (!filteredMGlines.some(function (v) {
518
- return v[2] === MGlines[_i2][2];
588
+ return v[2] === MGlines[_i3][2];
519
589
  })) return 1; // continue
520
- var mergedResult = getMergedLine(MGlines[_i2], filteredMGlines, 0);
590
+ var mergedResult = getMergedLine(MGlines[_i3], filteredMGlines, 0);
521
591
  if (mergedResult) {
522
592
  newMGlines.push(mergedResult.mergedLine);
523
593
  filteredMGlines = mergedResult.filteredMGlines;
524
594
  }
525
595
  },
526
596
  _ret;
527
- for (var _i2 = 0; _i2 < MGlines.length; _i2++) {
528
- _ret = _loop3(_i2);
597
+ for (var _i3 = 0; _i3 < MGlines.length; _i3++) {
598
+ _ret = _loop3(_i3);
529
599
  if (_ret === 0) break;
530
600
  if (_ret === 1) continue;
531
601
  }
@@ -614,11 +684,12 @@ function getTrimmedContourLineSegs(lineSegs, otherLines, cnt) {
614
684
  };
615
685
  var bContourSeg = true;
616
686
  var _loop6 = function _loop6(j) {
687
+ var _otherLines$j$0$x, _otherLines$j$, _otherLines$j$line$, _otherLines$j$0$y, _otherLines$j$2, _otherLines$j$line$2, _otherLines$j$1$x, _otherLines$j$3, _otherLines$j$line$3, _otherLines$j$1$y, _otherLines$j$4, _otherLines$j$line$4;
617
688
  var destLine = {
618
- x1: otherLines[j][0].x,
619
- y1: otherLines[j][0].y,
620
- x2: otherLines[j][1].x,
621
- y2: otherLines[j][1].y
689
+ x1: (_otherLines$j$0$x = (_otherLines$j$ = otherLines[j][0]) === null || _otherLines$j$ === void 0 ? void 0 : _otherLines$j$.x) !== null && _otherLines$j$0$x !== void 0 ? _otherLines$j$0$x : (_otherLines$j$line$ = otherLines[j].line[0]) === null || _otherLines$j$line$ === void 0 ? void 0 : _otherLines$j$line$.x,
690
+ y1: (_otherLines$j$0$y = (_otherLines$j$2 = otherLines[j][0]) === null || _otherLines$j$2 === void 0 ? void 0 : _otherLines$j$2.y) !== null && _otherLines$j$0$y !== void 0 ? _otherLines$j$0$y : (_otherLines$j$line$2 = otherLines[j].line[0]) === null || _otherLines$j$line$2 === void 0 ? void 0 : _otherLines$j$line$2.y,
691
+ x2: (_otherLines$j$1$x = (_otherLines$j$3 = otherLines[j][1]) === null || _otherLines$j$3 === void 0 ? void 0 : _otherLines$j$3.x) !== null && _otherLines$j$1$x !== void 0 ? _otherLines$j$1$x : (_otherLines$j$line$3 = otherLines[j].line[1]) === null || _otherLines$j$line$3 === void 0 ? void 0 : _otherLines$j$line$3.x,
692
+ y2: (_otherLines$j$1$y = (_otherLines$j$4 = otherLines[j][1]) === null || _otherLines$j$4 === void 0 ? void 0 : _otherLines$j$4.y) !== null && _otherLines$j$1$y !== void 0 ? _otherLines$j$1$y : (_otherLines$j$line$4 = otherLines[j].line[1]) === null || _otherLines$j$line$4 === void 0 ? void 0 : _otherLines$j$line$4.y
622
693
  };
623
694
  var rst = _export.GeometryUtils.relationshipOfTwoOverlappedLines(srcLine, destLine);
624
695
  if (rst.result == _constants.OVERLAP_SAME || rst.result == _constants.OVERLAP_INCLUDED) {
@@ -894,6 +965,151 @@ function createMonldingGroup(oldMG, layer, molding, catalog) {
894
965
  newMG = getMDPoints(newMG);
895
966
  return newMG;
896
967
  }
968
+ function getMoldingDataOfScene2(layer, catalog, doorStyle) {
969
+ var moldingData = [];
970
+ var items = layer.items.toArray();
971
+ var allLineRects = _export.GeometryUtils.buildRectFromLines(layer, _export.GeometryUtils.getAllLines(layer));
972
+
973
+ // get all molding line segments
974
+ var moldingLines = [];
975
+ items.forEach(function (item) {
976
+ if (item.category === _constants.ITEM_TYPE.CABINET) {
977
+ var _item$molding;
978
+ var MGlines = getLinesOfItem2(item, allLineRects, catalog); // exclude overlayed to wall
979
+ // z position of molding line
980
+ var z = item.properties.get('altitude').get('_length');
981
+ var zUnit = item.properties.get('altitude').get('_unit') || 'cm';
982
+ z = (0, _convertUnitsLite.convert)(z).from(zUnit).to('cm');
983
+ var h = item.properties.get('height').get('_length');
984
+ var hUnit = item.properties.get('height').get('_unit') || 'cm';
985
+ h = (0, _convertUnitsLite.convert)(h).from(hUnit).to('cm');
986
+ if (!(0, _helper.isEmpty)(item.molding) && isEnableItemForMolding(layer, item)) {
987
+ // calc normal molding line
988
+ item === null || item === void 0 || item.molding.forEach(function (molding) {
989
+ var lineZ = z;
990
+ switch (molding.location_type) {
991
+ case _constants.TOP_MOLDING_LOCATION:
992
+ lineZ = z + h;
993
+ break;
994
+ case _constants.MIDDLE_MOLDING_LOCATION:
995
+ lineZ = z + h / 2;
996
+ break;
997
+ }
998
+ MGlines === null || MGlines === void 0 || MGlines.forEach(function (line) {
999
+ return moldingLines.push({
1000
+ molding: _objectSpread({}, molding),
1001
+ doorStyle: item.doorStyle.hasOwnProperty('id') ? item.doorStyle : !(0, _helper.isEmpty)(item.doorStyle) && item.doorStyle.toJS(),
1002
+ line: line,
1003
+ z: lineZ
1004
+ });
1005
+ });
1006
+ });
1007
+ } else if (
1008
+ // calc toe kick molding line
1009
+ item.layoutpos === _constants.BASE_CABINET_LAYOUTPOS && ((0, _helper.isEmpty)(item.molding) || ((_item$molding = item.molding) === null || _item$molding === void 0 ? void 0 : _item$molding.length) < 1 || !isEnableItemForMolding(layer, item))) {
1010
+ var skuName = (0, _utils.getToeKickSKU)(item.doorStyle, catalog);
1011
+ var thumbnail = skuName ? skuName : '';
1012
+ MGlines === null || MGlines === void 0 || MGlines.forEach(function (line) {
1013
+ return moldingLines.push({
1014
+ molding: {
1015
+ name: _constants.TOE_KICK_MOLDING,
1016
+ sku: (0, _utils.getToeKickSKU)(item.doorStyle, catalog),
1017
+ thumbnail: thumbnail,
1018
+ category: 'molding',
1019
+ type: 'cabinet'
1020
+ },
1021
+ doorStyle: item.doorStyle.hasOwnProperty('id') ? item.doorStyle : !(0, _helper.isEmpty)(item.doorStyle) && item.doorStyle.toJS(),
1022
+ line: line,
1023
+ z: z
1024
+ });
1025
+ });
1026
+ }
1027
+ }
1028
+ });
1029
+
1030
+ // filter the real molding line segments
1031
+ var removeLineIds = []; // remove the line that fully overlapped to other line
1032
+ var newLines = []; // new countour line segment that except the overlapped part
1033
+ var _loop9 = function _loop9(i) {
1034
+ var srcLine = {
1035
+ x1: moldingLines[i].line[0].x,
1036
+ y1: moldingLines[i].line[0].y,
1037
+ x2: moldingLines[i].line[1].x,
1038
+ y2: moldingLines[i].line[1].y
1039
+ };
1040
+ var _loop1 = function _loop1(j) {
1041
+ if (i === j) return 0; // continue
1042
+ if (Math.abs(moldingLines[i].z - moldingLines[j].z) > _constants.EPSILON) return 0; // continue
1043
+ var destLine = {
1044
+ x1: moldingLines[j].line[0].x,
1045
+ y1: moldingLines[j].line[0].y,
1046
+ x2: moldingLines[j].line[1].x,
1047
+ y2: moldingLines[j].line[1].y
1048
+ };
1049
+ var rst = _export.GeometryUtils.relationshipOfTwoOverlappedLines(srcLine, destLine);
1050
+ if (rst.result === _constants.OVERLAP_SAME || rst.result === _constants.OVERLAP_INCLUDED) {
1051
+ removeLineIds.push(i);
1052
+ return 1; // break
1053
+ } else if (rst.result === _constants.OVERLAP_SOME) {
1054
+ removeLineIds.push(i);
1055
+ var lineSegs = getTrimmedContourLineSegs(rst.trimmedSegs, moldingLines.filter(function (v, idx) {
1056
+ return idx !== i && idx !== j && Math.abs(v.z - moldingLines[i].z) < _constants.EPSILON;
1057
+ }), 0);
1058
+ if (lineSegs.length > 0) {
1059
+ lineSegs.forEach(function (ls) {
1060
+ return newLines.push({
1061
+ molding: _objectSpread({}, moldingLines[i].molding),
1062
+ doorStyle: moldingLines[i].doorStyle,
1063
+ line: (0, _toConsumableArray2["default"])(ls),
1064
+ z: moldingLines[i].z
1065
+ });
1066
+ });
1067
+ }
1068
+ return 1; // break
1069
+ }
1070
+ },
1071
+ _ret4;
1072
+ for (var j = 0; j < moldingLines.length; j++) {
1073
+ _ret4 = _loop1(j);
1074
+ if (_ret4 === 0) continue;
1075
+ if (_ret4 === 1) break;
1076
+ }
1077
+ };
1078
+ for (var i = 0; i < moldingLines.length; i++) {
1079
+ _loop9(i);
1080
+ }
1081
+ moldingLines = moldingLines.filter(function (line, idx) {
1082
+ return !removeLineIds.some(function (id) {
1083
+ return idx === id;
1084
+ });
1085
+ });
1086
+ if (newLines.length > 0) moldingLines = [].concat((0, _toConsumableArray2["default"])(moldingLines), newLines);
1087
+ // console.log('moldingLines: ', moldingLines);
1088
+
1089
+ // make molding data with sorting molding & doorStyle
1090
+ var _loop0 = function _loop0() {
1091
+ var ml = moldingLines[k];
1092
+ var mlLength = (0, _convertUnitsLite.convert)(_export.GeometryUtils.verticesDistance(ml.line[0], ml.line[1])).from('cm').to('in');
1093
+ var idx = moldingData.findIndex(function (v) {
1094
+ var _ml$molding, _v$doorStyle, _ml$doorStyle;
1095
+ return (v === null || v === void 0 ? void 0 : v.name) === ((_ml$molding = ml.molding) === null || _ml$molding === void 0 ? void 0 : _ml$molding.name) && ((_v$doorStyle = v.doorStyle) === null || _v$doorStyle === void 0 ? void 0 : _v$doorStyle.id) === ((_ml$doorStyle = ml.doorStyle) === null || _ml$doorStyle === void 0 ? void 0 : _ml$doorStyle.id);
1096
+ });
1097
+ if (idx < 0) moldingData.push(_objectSpread(_objectSpread({}, ml.molding), {}, {
1098
+ doorStyle: ml.doorStyle,
1099
+ totalLength: mlLength,
1100
+ count: Math.ceil(mlLength * 1.1 / 96)
1101
+ }));else {
1102
+ moldingData[idx].totalLength += mlLength;
1103
+ moldingData[idx].count = Math.ceil(moldingData[idx].totalLength * 1.1 / 96);
1104
+ }
1105
+ };
1106
+ for (var k = 0; k < moldingLines.length; k++) {
1107
+ _loop0();
1108
+ }
1109
+ // console.log('moldingData: ', moldingData);
1110
+
1111
+ return moldingData;
1112
+ }
897
1113
  function getMoldingDataOfScene(layer, catalog, doorStyle) {
898
1114
  var moldingData = [];
899
1115
  var items = layer.items.toArray();
@@ -922,7 +1138,7 @@ function getMoldingDataOfScene(layer, catalog, doorStyle) {
922
1138
  if (temp_items.length) {
923
1139
  while (temp_items.length > 0) {
924
1140
  var itemGroup = [temp_items[0]];
925
- var _loop9 = function _loop9(_idx) {
1141
+ var _loop10 = function _loop10(_idx) {
926
1142
  if (!itemGroup.some(function (it) {
927
1143
  return it.id === temp_items[_idx].id;
928
1144
  }) && isItemSnappedGroup(temp_items[_idx], itemGroup)) {
@@ -932,7 +1148,7 @@ function getMoldingDataOfScene(layer, catalog, doorStyle) {
932
1148
  idx = _idx;
933
1149
  };
934
1150
  for (var idx = 0; idx < temp_items.length; idx++) {
935
- _loop9(idx);
1151
+ _loop10(idx);
936
1152
  }
937
1153
  itemGroup.forEach(function (item) {
938
1154
  var index = temp_items.findIndex(function (it) {
@@ -950,7 +1166,7 @@ function getMoldingDataOfScene(layer, catalog, doorStyle) {
950
1166
  var items = (0, _toConsumableArray2["default"])(itemgroup);
951
1167
  var MGlines = getLinesOfItem(items[0], allLineRects, catalog);
952
1168
  items = sortItemsByDistance(items, items[0]);
953
- var _loop0 = function _loop0() {
1169
+ var _loop11 = function _loop11() {
954
1170
  var itemLines = getLinesOfItem(items[i], allLineRects, catalog);
955
1171
  var temp_MGLines = [];
956
1172
  MGlines.forEach(function (line) {
@@ -974,7 +1190,7 @@ function getMoldingDataOfScene(layer, catalog, doorStyle) {
974
1190
  MGlines = [].concat(temp_MGLines);
975
1191
  };
976
1192
  for (var i = 1; i < items.length; i++) {
977
- _loop0();
1193
+ _loop11();
978
1194
  }
979
1195
  MGlines.forEach(function (line) {
980
1196
  molding_totalLength += _export.GeometryUtils.verticesDistance(line[0], line[1]);
@@ -998,8 +1214,8 @@ function getMoldingDataOfScene(layer, catalog, doorStyle) {
998
1214
  var tmpMoldingData = [];
999
1215
  var toedoorStyles = [];
1000
1216
  tmp.map(function (item) {
1001
- var _item$molding;
1002
- if (item.layoutpos === _constants.BASE_CABINET_LAYOUTPOS && ((0, _helper.isEmpty)(item.molding) || ((_item$molding = item.molding) === null || _item$molding === void 0 ? void 0 : _item$molding.length) < 1 || !isEnableItemForMolding(layer, item))) {
1217
+ var _item$molding2;
1218
+ if (item.layoutpos === _constants.BASE_CABINET_LAYOUTPOS && ((0, _helper.isEmpty)(item.molding) || ((_item$molding2 = item.molding) === null || _item$molding2 === void 0 ? void 0 : _item$molding2.length) < 1 || !isEnableItemForMolding(layer, item))) {
1003
1219
  var w = item.properties.get('width').get('_length');
1004
1220
  var wUnit = item.properties.get('width').get('_unit') || 'cm';
1005
1221
  w = (0, _convertUnitsLite.convert)(w / 2).from(wUnit).to('cm');
@@ -1017,28 +1233,28 @@ function getMoldingDataOfScene(layer, catalog, doorStyle) {
1017
1233
  var outlineWidth = outline.svgWidth;
1018
1234
  var outlineHeight = outline.svgHeight;
1019
1235
  var outlinePoints = []; // Hold Points Of SVG
1020
- var _iterator3 = _createForOfIteratorHelper(outlinePaths),
1021
- _step3;
1236
+ var _iterator5 = _createForOfIteratorHelper(outlinePaths),
1237
+ _step5;
1022
1238
  try {
1023
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1024
- var path = _step3.value;
1025
- var _iterator4 = _createForOfIteratorHelper(path.subPaths),
1026
- _step4;
1239
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1240
+ var path = _step5.value;
1241
+ var _iterator6 = _createForOfIteratorHelper(path.subPaths),
1242
+ _step6;
1027
1243
  try {
1028
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1029
- var subPath = _step4.value;
1244
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1245
+ var subPath = _step6.value;
1030
1246
  outlinePoints = outlinePoints.concat(subPath.getPoints());
1031
1247
  }
1032
1248
  } catch (err) {
1033
- _iterator4.e(err);
1249
+ _iterator6.e(err);
1034
1250
  } finally {
1035
- _iterator4.f();
1251
+ _iterator6.f();
1036
1252
  }
1037
1253
  }
1038
1254
  } catch (err) {
1039
- _iterator3.e(err);
1255
+ _iterator5.e(err);
1040
1256
  } finally {
1041
- _iterator3.f();
1257
+ _iterator5.f();
1042
1258
  }
1043
1259
  var maxX = outlinePoints[0].x,
1044
1260
  minX = outlinePoints[0].x;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "3.13.0",
3
+ "version": "3.14.0",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",