kitchen-simulator 4.4.1 → 4.4.2-new-json

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.
Files changed (51) hide show
  1. package/es/LiteRenderer.js +15 -53
  2. package/es/catalog/factories/area-factory-3d.js +0 -4
  3. package/es/catalog/holes/door-double/door_double.png +0 -0
  4. package/es/catalog/holes/door-panic/panicDoor.png +0 -0
  5. package/es/catalog/holes/door-panic-double/panicDoorDouble.png +0 -0
  6. package/es/catalog/holes/gate/gate.jpg +0 -0
  7. package/es/catalog/holes/window-clear/texture.png +0 -0
  8. package/es/catalog/holes/window-cross/texture.png +0 -0
  9. package/es/catalog/holes/window-double-hung/texture.png +0 -0
  10. package/es/catalog/holes/window-vertical/texture.png +0 -0
  11. package/es/catalog/utils/item-loader.js +3 -22
  12. package/es/class/item.js +1 -1
  13. package/es/constants/catalog/skinPanel.js +9 -0
  14. package/es/constants.js +11 -13
  15. package/es/devLiteRenderer.js +91 -109
  16. package/es/mappings/external-events/mapExternalEventPayload.js +21 -0
  17. package/es/mappings/external-events/mappers/addItemMapper.js +86 -0
  18. package/es/mappings/external-events/mappers/ccdfMapper.js +101 -0
  19. package/es/mappings/external-events/mappers/changeDoorStyleMapper.js +65 -0
  20. package/es/mappings/holesToCatalog.js +139 -0
  21. package/es/models.js +3 -1
  22. package/es/utils/helper.js +18 -9
  23. package/es/utils/isolate-event-handler.js +621 -173
  24. package/es/utils/molding.js +20 -236
  25. package/es/utils/skinPanelEngine.js +230 -26
  26. package/lib/LiteRenderer.js +17 -55
  27. package/lib/catalog/factories/area-factory-3d.js +0 -4
  28. package/lib/catalog/holes/door-double/door_double.png +0 -0
  29. package/lib/catalog/holes/door-panic/panicDoor.png +0 -0
  30. package/lib/catalog/holes/door-panic-double/panicDoorDouble.png +0 -0
  31. package/lib/catalog/holes/gate/gate.jpg +0 -0
  32. package/lib/catalog/holes/window-clear/texture.png +0 -0
  33. package/lib/catalog/holes/window-cross/texture.png +0 -0
  34. package/lib/catalog/holes/window-double-hung/texture.png +0 -0
  35. package/lib/catalog/holes/window-vertical/texture.png +0 -0
  36. package/lib/catalog/utils/item-loader.js +2 -21
  37. package/lib/class/item.js +1 -1
  38. package/lib/constants/catalog/skinPanel.js +15 -0
  39. package/lib/constants.js +16 -18
  40. package/lib/devLiteRenderer.js +93 -111
  41. package/lib/mappings/external-events/mapExternalEventPayload.js +26 -0
  42. package/lib/mappings/external-events/mappers/addItemMapper.js +92 -0
  43. package/lib/mappings/external-events/mappers/ccdfMapper.js +108 -0
  44. package/lib/mappings/external-events/mappers/changeDoorStyleMapper.js +72 -0
  45. package/lib/mappings/holesToCatalog.js +148 -0
  46. package/lib/models.js +3 -1
  47. package/lib/utils/helper.js +20 -9
  48. package/lib/utils/isolate-event-handler.js +620 -172
  49. package/lib/utils/molding.js +20 -237
  50. package/lib/utils/skinPanelEngine.js +232 -28
  51. package/package.json +1 -1
@@ -13,7 +13,6 @@ exports.getLinesFromItems = getLinesFromItems;
13
13
  exports.getLinesFromItems2 = getLinesFromItems2;
14
14
  exports.getLinesOfItem = getLinesOfItem;
15
15
  exports.getLinesOfItem2 = getLinesOfItem2;
16
- exports.getMoldingDataOfScene = getMoldingDataOfScene;
17
16
  exports.getMoldingDataOfScene2 = getMoldingDataOfScene2;
18
17
  exports.hasMoldingLayout = hasMoldingLayout;
19
18
  exports.isAttachedWall = isAttachedWall;
@@ -592,7 +591,23 @@ function getLinesFromItems2(moldingGroup, layer, catalog) {
592
591
  })) return 1; // continue
593
592
  var mergedResult = getMergedLine(MGlines[_i3], filteredMGlines, 0);
594
593
  if (mergedResult) {
595
- newMGlines.push(mergedResult.mergedLine);
594
+ // keep origin line direction
595
+ var rstLine = mergedResult.mergedLine;
596
+ // if (
597
+ // (Math.abs(MGlines[i][0].x - rstLine[1].x) < EPSILON &&
598
+ // Math.abs(MGlines[i][0].y - rstLine[1].y) < EPSILON) ||
599
+ // (Math.abs(MGlines[i][1].x - rstLine[0].x) < EPSILON &&
600
+ // Math.abs(MGlines[i][1].y - rstLine[0].y) < EPSILON)
601
+ // ) {
602
+ // // swap two end points
603
+ // const tx = rstLine[0].x;
604
+ // const ty = rstLine[0].y;
605
+ // rstLine[0].x = rstLine[1].x;
606
+ // rstLine[0].y = rstLine[1].y;
607
+ // rstLine[1].x = tx;
608
+ // rstLine[1].y = ty;
609
+ // }
610
+ newMGlines.push(rstLine);
596
611
  filteredMGlines = mergedResult.filteredMGlines;
597
612
  }
598
613
  },
@@ -968,7 +983,7 @@ function createMonldingGroup(oldMG, layer, molding, catalog) {
968
983
  newMG = getMDPoints(newMG);
969
984
  return newMG;
970
985
  }
971
- function getMoldingDataOfScene2(layer, catalog, doorStyle) {
986
+ function getMoldingDataOfScene2(layer, catalog, doorStyle, moldingPieceLength) {
972
987
  var _layer$items;
973
988
  var moldingData = [];
974
989
  var items = layer === null || layer === void 0 || (_layer$items = layer.items) === null || _layer$items === void 0 ? void 0 : _layer$items.toArray();
@@ -1130,10 +1145,10 @@ function getMoldingDataOfScene2(layer, catalog, doorStyle) {
1130
1145
  if (idx < 0) moldingData.push(_objectSpread(_objectSpread({}, ml.molding), {}, {
1131
1146
  doorStyle: ml.doorStyle,
1132
1147
  totalLength: mlLength,
1133
- count: Math.ceil(mlLength * 1.1 / 96)
1148
+ count: Math.ceil(mlLength * 1.1 / moldingPieceLength)
1134
1149
  }));else {
1135
1150
  moldingData[idx].totalLength += mlLength;
1136
- moldingData[idx].count = Math.ceil(moldingData[idx].totalLength * 1.1 / 96);
1151
+ moldingData[idx].count = Math.ceil(moldingData[idx].totalLength * 1.1 / moldingPieceLength);
1137
1152
  }
1138
1153
  };
1139
1154
  for (var k = 0; k < moldingLines.length; k++) {
@@ -1141,237 +1156,5 @@ function getMoldingDataOfScene2(layer, catalog, doorStyle) {
1141
1156
  }
1142
1157
  // console.log('moldingData: ', moldingData);
1143
1158
 
1144
- return moldingData;
1145
- }
1146
- function getMoldingDataOfScene(layer, catalog, doorStyle) {
1147
- var moldingData = [];
1148
- var items = layer.items.toArray();
1149
- var moldings = [];
1150
- // get all moldings info
1151
- items.forEach(function (itemCat) {
1152
- var _itemCat$molding;
1153
- itemCat === null || itemCat === void 0 || (_itemCat$molding = itemCat.molding) === null || _itemCat$molding === void 0 || _itemCat$molding.forEach(function (molding) {
1154
- if (!moldings.some(function (m) {
1155
- return m.name === molding.name;
1156
- })) moldings.push(molding);
1157
- });
1158
- });
1159
-
1160
- // calc normal molding
1161
- moldings.forEach(function (molding) {
1162
- var itemGroups = [];
1163
- var temp_items = [];
1164
- items.forEach(function (item) {
1165
- if (item.molding.some(function (mol) {
1166
- return mol.itemID === molding.itemID;
1167
- }) && isEnableItemForMolding(layer, item)) {
1168
- temp_items.push(item);
1169
- }
1170
- });
1171
- if (temp_items.length) {
1172
- while (temp_items.length > 0) {
1173
- var itemGroup = [temp_items[0]];
1174
- var _loop10 = function _loop10(_idx) {
1175
- if (!itemGroup.some(function (it) {
1176
- return it.id === temp_items[_idx].id;
1177
- }) && isItemSnappedGroup(temp_items[_idx], itemGroup)) {
1178
- itemGroup.push(temp_items[_idx]);
1179
- _idx = 0;
1180
- }
1181
- idx = _idx;
1182
- };
1183
- for (var idx = 0; idx < temp_items.length; idx++) {
1184
- _loop10(idx);
1185
- }
1186
- itemGroup.forEach(function (item) {
1187
- var index = temp_items.findIndex(function (it) {
1188
- return it.id === item.id;
1189
- });
1190
- if (index > -1) {
1191
- temp_items.splice(index, 1);
1192
- }
1193
- });
1194
- itemGroups.push(itemGroup);
1195
- }
1196
- var molding_totalLength = 0;
1197
- itemGroups.forEach(function (itemgroup) {
1198
- var allLineRects = _export.GeometryUtils.buildRectFromLines(layer, _export.GeometryUtils.getAllLines(layer));
1199
- var items = (0, _toConsumableArray2["default"])(itemgroup);
1200
- var MGlines = getLinesOfItem(items[0], allLineRects, catalog);
1201
- items = sortItemsByDistance(items, items[0]);
1202
- var _loop11 = function _loop11() {
1203
- var itemLines = getLinesOfItem(items[i], allLineRects, catalog);
1204
- var temp_MGLines = [];
1205
- MGlines.forEach(function (line) {
1206
- var idx = itemLines.findIndex(function (itemLine) {
1207
- return isLinesOverlapped(line, itemLine);
1208
- });
1209
- var curItemLine = itemLines[idx];
1210
- if (idx > -1) {
1211
- if (!(_export.GeometryUtils.samePoints(line[0], curItemLine[0]) && _export.GeometryUtils.samePoints(line[1], curItemLine[1]) || _export.GeometryUtils.samePoints(line[0], curItemLine[1]) && _export.GeometryUtils.samePoints(line[1], curItemLine[0]))) {
1212
- var MGLine = mergeOverlappedLines(line, curItemLine);
1213
- temp_MGLines.push(MGLine);
1214
- }
1215
- itemLines.splice(idx, 1);
1216
- } else {
1217
- temp_MGLines.push(line);
1218
- }
1219
- });
1220
- itemLines.forEach(function (itemLine) {
1221
- return temp_MGLines.push(itemLine);
1222
- });
1223
- MGlines = [].concat(temp_MGLines);
1224
- };
1225
- for (var i = 1; i < items.length; i++) {
1226
- _loop11();
1227
- }
1228
- MGlines.forEach(function (line) {
1229
- molding_totalLength += _export.GeometryUtils.verticesDistance(line[0], line[1]);
1230
- });
1231
- });
1232
- molding_totalLength = (0, _convertUnitsLite.convert)(molding_totalLength).from('cm').to('in');
1233
- moldingData.push(_objectSpread(_objectSpread({}, molding), {}, {
1234
- doorStyle: doorStyle,
1235
- count: Math.ceil(molding_totalLength * 1.1 / 96)
1236
- }));
1237
- }
1238
- });
1239
-
1240
- // calc toe kick molding
1241
- var tmp = [];
1242
- items.forEach(function (item) {
1243
- if (item.category === 'cabinet' && !item.cabinet_category.toLowerCase().includes('microwave')) {
1244
- tmp.push(item);
1245
- }
1246
- });
1247
- var tmpMoldingData = [];
1248
- var toedoorStyles = [];
1249
- tmp.map(function (item) {
1250
- var _item$molding2;
1251
- 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))) {
1252
- var w = item.properties.get('width').get('_length');
1253
- var wUnit = item.properties.get('width').get('_unit') || 'cm';
1254
- w = (0, _convertUnitsLite.convert)(w / 2).from(wUnit).to('cm');
1255
- var h = item.properties.get('depth').get('_length');
1256
- var hUnit = item.properties.get('depth').get('_unit') || 'cm';
1257
- h = (0, _convertUnitsLite.convert)(h / 2).from(hUnit).to('cm');
1258
- var outline = null;
1259
- var element = catalog.elements[item.get('type')];
1260
- if (!element) element = catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(item.get('type'))];
1261
- outline = element.info.outline;
1262
- var len = 0;
1263
- if (outline) {
1264
- // Extract Points from `outline`
1265
- var outlinePaths = outline.paths;
1266
- var outlineWidth = outline.svgWidth;
1267
- var outlineHeight = outline.svgHeight;
1268
- var outlinePoints = []; // Hold Points Of SVG
1269
- var _iterator5 = _createForOfIteratorHelper(outlinePaths),
1270
- _step5;
1271
- try {
1272
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1273
- var path = _step5.value;
1274
- var _iterator6 = _createForOfIteratorHelper(path.subPaths),
1275
- _step6;
1276
- try {
1277
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1278
- var subPath = _step6.value;
1279
- outlinePoints = outlinePoints.concat(subPath.getPoints());
1280
- }
1281
- } catch (err) {
1282
- _iterator6.e(err);
1283
- } finally {
1284
- _iterator6.f();
1285
- }
1286
- }
1287
- } catch (err) {
1288
- _iterator5.e(err);
1289
- } finally {
1290
- _iterator5.f();
1291
- }
1292
- var maxX = outlinePoints[0].x,
1293
- minX = outlinePoints[0].x;
1294
- var maxY = outlinePoints[0].y,
1295
- minY = outlinePoints[0].y;
1296
- outlinePoints.forEach(function (point) {
1297
- if (point.x > maxX) {
1298
- maxX = point.x;
1299
- }
1300
- if (point.x < minX) {
1301
- minX = point.x;
1302
- }
1303
- if (point.y > maxY) {
1304
- maxY = point.y;
1305
- }
1306
- if (point.y < minY) {
1307
- minY = point.y;
1308
- }
1309
- });
1310
- outlinePoints.forEach(function (point) {
1311
- if (_export.GeometryUtils.isPointInRect([{
1312
- x: minX,
1313
- y: minY
1314
- }, {
1315
- x: minX,
1316
- y: maxY
1317
- }, {
1318
- x: maxX,
1319
- y: maxY
1320
- }, {
1321
- x: maxX,
1322
- y: minY
1323
- }], point)) {
1324
- if (point.x > 10) len += (point.x / outlineWidth - 0.5) * w * 2 + h * 2 - (point.y / outlineHeight - 0.5) * h * 2;
1325
- }
1326
- });
1327
- len = (0, _convertUnitsLite.convert)(len).from('cm').to('in');
1328
- } else {
1329
- w = (0, _convertUnitsLite.convert)(w * 2).from('cm').to('in');
1330
- len += w;
1331
- }
1332
- var doorIndex = toedoorStyles.findIndex(function (a) {
1333
- var iDS = item === null || item === void 0 ? void 0 : item.doorStyle;
1334
- if (!iDS) return false;
1335
- if (!iDS.hasOwnProperty('id')) {
1336
- iDS = iDS.toJS();
1337
- }
1338
- return a.doorStyle.id === iDS.id && (0, _utils.isEqualInstallationType)(a.doorStyle, iDS);
1339
- });
1340
- if (doorIndex > -1) {
1341
- toedoorStyles[doorIndex].totalLength += len;
1342
- } else {
1343
- toedoorStyles.push({
1344
- doorStyle: item.doorStyle.hasOwnProperty('id') ? item.doorStyle : item.doorStyle && item.doorStyle.toJS(),
1345
- totalLength: len
1346
- });
1347
- }
1348
- }
1349
- });
1350
- toedoorStyles.forEach(function (doorStyle) {
1351
- var skuName = (0, _utils.getToeKickSKU)(doorStyle.doorStyle, catalog);
1352
- var thumbnail = skuName ? skuName : '';
1353
- // moldings.forEach(molding => {
1354
- // if (
1355
- // molding.name ===
1356
- // getToeKickSKU(
1357
- // doorStyle.doorStyle,
1358
- // catalog,
1359
- // true
1360
- // )
1361
- // )
1362
- // thumbnail = molding.thumbnail;
1363
- // });
1364
-
1365
- doorStyle.totalLength && tmpMoldingData.push({
1366
- name: _constants.TOE_KICK_MOLDING,
1367
- sku: (0, _utils.getToeKickSKU)(doorStyle.doorStyle, catalog),
1368
- thumbnail: thumbnail,
1369
- category: 'molding',
1370
- type: 'cabinet',
1371
- doorStyle: doorStyle.doorStyle,
1372
- count: Math.ceil(doorStyle.totalLength * 1.1 / 96)
1373
- });
1374
- });
1375
- if (tmpMoldingData.length > 0) moldingData = [].concat((0, _toConsumableArray2["default"])(moldingData), tmpMoldingData);
1376
1159
  return moldingData;
1377
1160
  }
@@ -12,6 +12,7 @@ var _geometry = require("./geometry");
12
12
  var _export = require("./export");
13
13
  var _convertUnitsLite = require("./convert-units-lite");
14
14
  var _helper = require("./helper");
15
+ var _skinPanel = require("../constants/catalog/skinPanel");
15
16
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
16
17
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
17
18
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
@@ -38,7 +39,8 @@ function getSideFaces(item, layer) {
38
39
  var overlapList = [_constants.OVERLAP_INCLUDED, _constants.OVERLAP_SAME, _constants.OVERLAP_SOME];
39
40
  var pos = [[-1, -1], [1, -1], [1, 1], [-1, 1]];
40
41
  for (var i = 0; i < 4; i++) {
41
- if (i === 0 || i === 2) continue; // only left & right
42
+ if (i === 0) continue; // only left & right & base cabinet's back
43
+ if (i === 2 && item.layoutpos !== _constants.BASE_CABINET_LAYOUTPOS) continue;
42
44
  var isSnappedToWall = false;
43
45
  var v0 = rotateCorner(pos[i], item, widthCm, depthCm);
44
46
  var v1 = rotateCorner(pos[(i + 1) % 4], item, widthCm, depthCm);
@@ -72,13 +74,14 @@ function getSideFaces(item, layer) {
72
74
  var skinPanelSKU = 'unknown';
73
75
  switch (item.layoutpos) {
74
76
  case _constants.BASE_CABINET_LAYOUTPOS:
75
- skinPanelSKU = _constants.SKIN_SKU_BSV_24;
77
+ case _constants.VANITY_CABINET_LAYOUTPOS:
78
+ skinPanelSKU = i === 2 ? 'unknown' : _skinPanel.SKIN_SKU_BSV_24;
76
79
  break;
77
80
  case _constants.WALL_CABINET_LAYOUTPOS:
78
- if (Math.abs(depthInch - 12) <= 1) skinPanelSKU = _constants.SKIN_SKU_WSV_1242;else if (Math.abs(depthInch - 24) <= 1) skinPanelSKU = _constants.SKIN_SKU_WSV_2442;
81
+ if (Math.abs(depthInch - 12) <= 1) skinPanelSKU = _skinPanel.SKIN_SKU_WSV_1242;else if (Math.abs(depthInch - 24) <= 1) skinPanelSKU = _skinPanel.SKIN_SKU_WSV_2442;
79
82
  break;
80
83
  case _constants.TALL_CABINET_LAYOUTPOS:
81
- skinPanelSKU = _constants.SKIN_SKU_USV245325;
84
+ skinPanelSKU = _skinPanel.SKIN_SKU_USV245325;
82
85
  break;
83
86
  }
84
87
  sideFaces.push({
@@ -92,6 +95,7 @@ function getSideFaces(item, layer) {
92
95
  // inch unit
93
96
  height: heightInch,
94
97
  // inch unit
98
+ isBackFace: i === 2 ? true : false,
95
99
  skinPanelSKU: skinPanelSKU,
96
100
  itemInfo: item.toJS()
97
101
  });
@@ -101,7 +105,7 @@ function getSideFaces(item, layer) {
101
105
  }
102
106
  function collectLayerItems(layer) {
103
107
  var _layer$items;
104
- var skinLayouts = new Set([_constants.BASE_CABINET_LAYOUTPOS, _constants.WALL_CABINET_LAYOUTPOS, _constants.TALL_CABINET_LAYOUTPOS]);
108
+ var skinLayouts = new Set([_constants.BASE_CABINET_LAYOUTPOS, _constants.WALL_CABINET_LAYOUTPOS, _constants.TALL_CABINET_LAYOUTPOS, _constants.VANITY_CABINET_LAYOUTPOS]);
105
109
  var skinPanelItems = [];
106
110
  var otherItems = [];
107
111
  layer === null || layer === void 0 || (_layer$items = layer.items) === null || _layer$items === void 0 || _layer$items.forEach(function (it) {
@@ -121,26 +125,142 @@ function collectFaces(items, layer) {
121
125
  }
122
126
  return faces;
123
127
  }
128
+
129
+ /**
130
+ * @param {*} faceSegs
131
+ * @param {*} otherFaces
132
+ * @returns
133
+ */
134
+ function getTrimmedFaceSegs(faceSegs, otherFaces, cnt) {
135
+ try {
136
+ cnt++;
137
+ if (cnt > 5000) {
138
+ console.log('getTrimmedFaceSegs has limited!');
139
+ return [];
140
+ }
141
+ var returnSegs = [];
142
+ var _loop = function _loop() {
143
+ var iFace = faceSegs[i];
144
+ var srcLine = iFace.sectionLine;
145
+ var bContourSeg = true;
146
+ var _loop2 = function _loop2(j) {
147
+ var destLine = otherFaces[j].sectionLine;
148
+ var rst = (0, _geometry.relationshipOfTwoOverlappedLines)(srcLine, destLine);
149
+ if (rst.result == _constants.OVERLAP_SAME || rst.result == _constants.OVERLAP_INCLUDED) {
150
+ bContourSeg = false;
151
+ return 0; // break
152
+ } else if (rst.result == _constants.OVERLAP_SOME) {
153
+ var trimmedFaceSegs = [];
154
+ rst.trimmedSegs.forEach(function (lineSeg) {
155
+ trimmedFaceSegs.push({
156
+ sectionLine: lineSeg,
157
+ // cm unit
158
+ zBottom: iFace.zBottom,
159
+ // cm unit
160
+ zTop: iFace.zTop,
161
+ // cm unit
162
+ depth: iFace.depthInch,
163
+ // inch unit
164
+ height: iFace.heightInch,
165
+ // inch unit
166
+ isBackFace: iFace.isBackFace,
167
+ skinPanelSKU: iFace.skinPanelSKU,
168
+ itemInfo: iFace.itemInfo
169
+ });
170
+ });
171
+ var tFaceSegs = getTrimmedFaceSegs(trimmedFaceSegs, otherFaces.filter(function (v, idx) {
172
+ return idx !== j;
173
+ }), cnt);
174
+ if (tFaceSegs.length > 0) returnSegs = [].concat((0, _toConsumableArray2["default"])(returnSegs), (0, _toConsumableArray2["default"])(tFaceSegs));
175
+ bContourSeg = false;
176
+ return 0; // break
177
+ }
178
+ },
179
+ _ret;
180
+ for (var j = 0; j < otherFaces.length; j++) {
181
+ _ret = _loop2(j);
182
+ if (_ret === 0) break;
183
+ }
184
+ if (bContourSeg) returnSegs.push(faceSegs[i]);
185
+ };
186
+ for (var i = 0; i < faceSegs.length; i++) {
187
+ _loop();
188
+ }
189
+ return returnSegs;
190
+ } catch (e) {
191
+ console.log('getTrimmedFaceSegs catched :', e);
192
+ return [];
193
+ }
194
+ }
124
195
  function filterFacesBlockedByFaces(sourceFaces, blockingFaces) {
125
196
  var overlapList = [_constants.OVERLAP_INCLUDED, _constants.OVERLAP_SAME];
126
197
  var removeIdxs = [];
127
- for (var i = 0; i < sourceFaces.length; i++) {
198
+ var newFaces = []; // new countour edge segment that except the overlapped part
199
+ var _loop3 = function _loop3(i) {
128
200
  var iFace = sourceFaces[i];
129
201
  for (var j = 0; j < blockingFaces.length; j++) {
202
+ var _relationship$trimmed;
130
203
  if (sourceFaces === blockingFaces && i === j) continue;
131
204
  var jFace = blockingFaces[j];
132
- if (overlapList.includes((0, _geometry.relationshipOfTwoOverlappedLines)(iFace.sectionLine, jFace.sectionLine).result)) {
133
- var verticallyIncluded = (iFace.zBottom > jFace.zBottom || Math.abs(iFace.zBottom - jFace.zBottom) < _constants.EPSILON) && (iFace.zTop < jFace.zTop || Math.abs(iFace.zTop - jFace.zTop) < _constants.EPSILON);
134
- if (verticallyIncluded) {
205
+ var verticallyIncluded = (iFace.zBottom > jFace.zBottom || Math.abs(iFace.zBottom - jFace.zBottom) < _constants.EPSILON) && (iFace.zTop < jFace.zTop || Math.abs(iFace.zTop - jFace.zTop) < _constants.EPSILON);
206
+ var verticallyOverlappedTopPart = jFace.zBottom < iFace.zTop && jFace.zBottom > iFace.zBottom && Math.abs(jFace.zBottom - iFace.zTop) > _constants.EPSILON && Math.abs(jFace.zBottom - iFace.zBottom) > _constants.EPSILON;
207
+ var verticallyOverlappedBottomPart = jFace.zTop < iFace.zTop && jFace.zTop > iFace.zBottom && Math.abs(jFace.zTop - iFace.zTop) > _constants.EPSILON && Math.abs(jFace.zTop - iFace.zBottom) > _constants.EPSILON;
208
+ var relationship = (0, _geometry.relationshipOfTwoOverlappedLines)(iFace.sectionLine, jFace.sectionLine);
209
+ if (overlapList.includes(relationship.result)) {
210
+ if (verticallyIncluded) removeIdxs.push(i);else if (verticallyOverlappedTopPart) {
135
211
  removeIdxs.push(i);
136
- break;
212
+ newFaces.push({
213
+ sectionLine: iFace.sectionLine,
214
+ // cm unit
215
+ zBottom: iFace.zBottom,
216
+ // cm unit
217
+ zTop: jFace.zBottom,
218
+ // cm unit
219
+ depth: iFace.depthInch,
220
+ // inch unit
221
+ height: toIn(jFace.zBottom - iFace.zBottom),
222
+ // inch unit
223
+ isBackFace: iFace.isBackFace,
224
+ skinPanelSKU: iFace.skinPanelSKU,
225
+ itemInfo: iFace.itemInfo
226
+ });
227
+ } else if (verticallyOverlappedBottomPart) {
228
+ removeIdxs.push(i);
229
+ newFaces.push({
230
+ sectionLine: iFace.sectionLine,
231
+ // cm unit
232
+ zBottom: jFace.zTop,
233
+ // cm unit
234
+ zTop: iFace.zTop,
235
+ // cm unit
236
+ depth: iFace.depthInch,
237
+ // inch unit
238
+ height: toIn(iFace.zTop - jFace.zTop),
239
+ // inch unit
240
+ isBackFace: iFace.isBackFace,
241
+ skinPanelSKU: iFace.skinPanelSKU,
242
+ itemInfo: iFace.itemInfo
243
+ });
137
244
  }
245
+ break;
246
+ } else if (relationship.result === _constants.OVERLAP_SOME && ((_relationship$trimmed = relationship.trimmedSegs) === null || _relationship$trimmed === void 0 ? void 0 : _relationship$trimmed.length) > 0 && verticallyIncluded) {
247
+ removeIdxs.push(i);
248
+ var tFaceSegs = getTrimmedFaceSegs([iFace], sourceFaces === blockingFaces ? blockingFaces.filter(function (v, idx) {
249
+ return idx !== i;
250
+ }) : blockingFaces, 0);
251
+ if (tFaceSegs.length > 0) newFaces = [].concat((0, _toConsumableArray2["default"])(newFaces), (0, _toConsumableArray2["default"])(tFaceSegs));
252
+ break;
138
253
  }
139
254
  }
255
+ };
256
+ for (var i = 0; i < sourceFaces.length; i++) {
257
+ _loop3(i);
140
258
  }
141
- return sourceFaces.filter(function (face, idx) {
259
+ sourceFaces = sourceFaces.filter(function (face, idx) {
142
260
  return !removeIdxs.includes(idx);
143
261
  });
262
+ if (newFaces.length > 0) sourceFaces = [].concat((0, _toConsumableArray2["default"])(sourceFaces), (0, _toConsumableArray2["default"])(newFaces));
263
+ return sourceFaces;
144
264
  }
145
265
  function applyGroupingRules(faces) {
146
266
  var _applyHorizontalGroup = applyHorizontalGrouping(faces),
@@ -181,7 +301,8 @@ function applyHorizontalGrouping(faces) {
181
301
  // inch unit
182
302
  height: jFace.height,
183
303
  // inch unit
184
- skinPanelSKU: _constants.SKIN_SKU_BSV_48,
304
+ isBackFace: jFace.isBackFace,
305
+ skinPanelSKU: jFace.isBackFace ? 'unknown' : _skinPanel.SKIN_SKU_BSV_48,
185
306
  itemInfo: jFace.itemInfo // [TODO] how to select the doorstyle of grouped skin
186
307
  });
187
308
  removeIdxs.push(i);
@@ -224,7 +345,8 @@ function applyVerticalGrouping(faces) {
224
345
  // inch unit
225
346
  height: jFace.height,
226
347
  // inch unit
227
- skinPanelSKU: _constants.SKIN_SKU_WSV_2460,
348
+ isBackFace: jFace.isBackFace,
349
+ skinPanelSKU: _skinPanel.SKIN_SKU_WSV_2460,
228
350
  itemInfo: jFace.itemInfo // [TODO] how to select the doorstyle of grouped skin
229
351
  });
230
352
  removeIdxs.push(i);
@@ -249,11 +371,12 @@ function isMP3TallCabinet(sku) {
249
371
  function resolveTallCabinetBundle(face) {
250
372
  var item = face.itemInfo;
251
373
  if (isMP3TallCabinet(item.sku_number)) {
252
- return [_constants.SKIN_SKU_BSV_24, _constants.SKIN_SKU_BSV_24, _constants.SKIN_SKU_WSV_2442];
374
+ return [_skinPanel.SKIN_SKU_BSV_24, _skinPanel.SKIN_SKU_BSV_24, _skinPanel.SKIN_SKU_WSV_2442];
253
375
  }
254
-
255
- // fallback
256
- return [_constants.SKIN_SKU_USV245325];
376
+ if (face.height > _skinPanel.SKIN_HEIGHT_53_25) {
377
+ return [_skinPanel.SKIN_SKU_USV245325, _skinPanel.SKIN_SKU_WSV_2442];
378
+ }
379
+ return face !== null && face !== void 0 && face.skinPanelSKU ? [face.skinPanelSKU] : [];
257
380
  }
258
381
 
259
382
  /**
@@ -271,34 +394,38 @@ function resolveSkinPanelSKU(face) {
271
394
  * Make skin panel data with grouping skinPanelSKU & doorStyle
272
395
  */
273
396
  function buildSkinPanelData(faces) {
274
- var result = [];
275
- var _loop = function _loop() {
397
+ var tempResult = [];
398
+ var _loop4 = function _loop4() {
276
399
  var sf = faces[i];
277
400
  var skus = resolveSkinPanelSKU(sf);
278
401
  var _iterator = _createForOfIteratorHelper(skus),
279
402
  _step;
280
403
  try {
281
- var _loop2 = function _loop2() {
404
+ var _loop6 = function _loop6() {
282
405
  var sku = _step.value;
283
- var idx = result.findIndex(function (v) {
406
+ var idx = tempResult.findIndex(function (v) {
284
407
  var _sf$itemInfo;
285
- return v.itemSKU === sku && v.doorStyleId === ((_sf$itemInfo = sf.itemInfo) === null || _sf$itemInfo === void 0 || (_sf$itemInfo = _sf$itemInfo.doorStyle) === null || _sf$itemInfo === void 0 ? void 0 : _sf$itemInfo.id);
408
+ return v.itemSKU === sku && v.doorStyleId === ((_sf$itemInfo = sf.itemInfo) === null || _sf$itemInfo === void 0 || (_sf$itemInfo = _sf$itemInfo.doorStyle) === null || _sf$itemInfo === void 0 ? void 0 : _sf$itemInfo.id) && v.isBackFace === sf.isBackFace;
286
409
  });
287
410
  if (idx < 0) {
288
411
  var _sf$itemInfo$doorStyl, _sf$itemInfo2, _sf$itemInfo$doorStyl2, _sf$itemInfo3;
289
- result.push({
412
+ tempResult.push({
290
413
  itemSKU: sku,
291
414
  doorStyle: (_sf$itemInfo$doorStyl = (_sf$itemInfo2 = sf.itemInfo) === null || _sf$itemInfo2 === void 0 || (_sf$itemInfo2 = _sf$itemInfo2.doorStyle) === null || _sf$itemInfo2 === void 0 ? void 0 : _sf$itemInfo2.name) !== null && _sf$itemInfo$doorStyl !== void 0 ? _sf$itemInfo$doorStyl : '',
292
415
  doorStyleId: (_sf$itemInfo$doorStyl2 = (_sf$itemInfo3 = sf.itemInfo) === null || _sf$itemInfo3 === void 0 || (_sf$itemInfo3 = _sf$itemInfo3.doorStyle) === null || _sf$itemInfo3 === void 0 ? void 0 : _sf$itemInfo3.id) !== null && _sf$itemInfo$doorStyl2 !== void 0 ? _sf$itemInfo$doorStyl2 : '',
293
416
  installationType: 'standard',
294
- quantity: 1
417
+ quantity: 1,
418
+ totalLength: toIn((0, _geometry.pointsDistance)(sf.sectionLine.x1, sf.sectionLine.y1, sf.sectionLine.x2, sf.sectionLine.y2)),
419
+ isBackFace: sf.isBackFace
295
420
  });
296
421
  } else {
297
- result[idx].quantity += 1;
422
+ var faceLength = (0, _geometry.pointsDistance)(sf.sectionLine.x1, sf.sectionLine.y1, sf.sectionLine.x2, sf.sectionLine.y2);
423
+ tempResult[idx].totalLength += toIn(faceLength);
424
+ tempResult[idx].quantity += 1;
298
425
  }
299
426
  };
300
427
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
301
- _loop2();
428
+ _loop6();
302
429
  }
303
430
  } catch (err) {
304
431
  _iterator.e(err);
@@ -307,18 +434,95 @@ function buildSkinPanelData(faces) {
307
434
  }
308
435
  };
309
436
  for (var i = 0; i < faces.length; i++) {
310
- _loop();
437
+ _loop4();
438
+ }
439
+
440
+ // calculate back face panel quantity of island base cabinets
441
+ var removeIdxs = [];
442
+ var newDatas = [];
443
+ var _loop5 = function _loop5() {
444
+ var iData = tempResult[_i];
445
+ if (iData.isBackFace) {
446
+ removeIdxs.push(_i);
447
+ var count48 = Math.floor(iData.totalLength / 48);
448
+ var count24 = iData.totalLength % 48 > 0 ? 1 : 0;
449
+ var idx48 = tempResult.findIndex(function (v) {
450
+ return v.itemSKU === _skinPanel.SKIN_SKU_BSV_48 && v.doorStyleId === iData.doorStyleId;
451
+ });
452
+ var idx24 = tempResult.findIndex(function (v) {
453
+ return v.itemSKU === _skinPanel.SKIN_SKU_BSV_24 && v.doorStyleId === iData.doorStyleId;
454
+ });
455
+ if (idx48 < 0) {
456
+ if (count48 > 0) newDatas.push({
457
+ itemSKU: _skinPanel.SKIN_SKU_BSV_48,
458
+ doorStyle: iData.doorStyle,
459
+ doorStyleId: iData.doorStyleId,
460
+ installationType: iData.installationType,
461
+ quantity: count48,
462
+ totalLength: count48 * 48,
463
+ isBackFace: iData.isBackFace
464
+ });
465
+ } else {
466
+ tempResult[idx48].quantity += count48;
467
+ tempResult[idx48].totalLength += count48 * 48;
468
+ }
469
+ if (idx24 < 0) {
470
+ if (count24 > 0) newDatas.push({
471
+ itemSKU: _skinPanel.SKIN_SKU_BSV_24,
472
+ doorStyle: iData.doorStyle,
473
+ doorStyleId: iData.doorStyleId,
474
+ installationType: iData.installationType,
475
+ quantity: count24,
476
+ totalLength: count24 * 24,
477
+ isBackFace: iData.isBackFace
478
+ });
479
+ } else {
480
+ tempResult[idx24].quantity += count24;
481
+ tempResult[idx24].totalLength += count24 * 24;
482
+ }
483
+ }
484
+ };
485
+ for (var _i = 0; _i < tempResult.length; _i++) {
486
+ _loop5();
311
487
  }
488
+ tempResult = tempResult.filter(function (data, idx) {
489
+ return !removeIdxs.includes(idx);
490
+ });
491
+ if (newDatas.length > 0) tempResult = [].concat((0, _toConsumableArray2["default"])(tempResult), newDatas);
492
+ var result = [];
493
+ tempResult.forEach(function (v) {
494
+ return result.push({
495
+ itemSKU: v.itemSKU,
496
+ doorStyle: v.doorStyle,
497
+ doorStyleId: v.doorStyleId,
498
+ installationType: v.installationType,
499
+ quantity: v.quantity
500
+ });
501
+ });
312
502
  return result;
313
503
  }
504
+ function shouldExcludeSkinPanel(itemJS, exclusionSet, catalog) {
505
+ var _itemJS$doorStyle;
506
+ var cabinetSku = (0, _helper.getSkuAliasFromCatalog)(catalog, itemJS);
507
+ var doorColorSku = itemJS === null || itemJS === void 0 || (_itemJS$doorStyle = itemJS.doorStyle) === null || _itemJS$doorStyle === void 0 ? void 0 : _itemJS$doorStyle.sku;
508
+ if (!cabinetSku || !doorColorSku) return false;
509
+ return exclusionSet.has("".concat(cabinetSku, "-").concat(doorColorSku));
510
+ }
314
511
  function computeSkinPanels(layer) {
512
+ var skinPanelExclusionSKUs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
513
+ var catalog = arguments.length > 2 ? arguments[2] : undefined;
514
+ var exclusionSet = new Set(skinPanelExclusionSKUs);
515
+
315
516
  // Get candidate skin panel items and other items
316
517
  var _collectLayerItems = collectLayerItems(layer),
317
518
  skinPanelItems = _collectLayerItems.skinPanelItems,
318
519
  otherItems = _collectLayerItems.otherItems;
520
+ var filteredSkinPanelItems = skinPanelItems.filter(function (item) {
521
+ return !shouldExcludeSkinPanel(item.toJS(), exclusionSet, catalog);
522
+ });
319
523
 
320
524
  // Get all skin face list of [skinPanelItems] & [otherItems]
321
- var skinFaces = collectFaces(skinPanelItems, layer);
525
+ var skinFaces = collectFaces(filteredSkinPanelItems, layer);
322
526
  var otherFaces = collectFaces(otherItems, layer);
323
527
  skinFaces = filterFacesBlockedByFaces(skinFaces, skinFaces);
324
528
  skinFaces = filterFacesBlockedByFaces(skinFaces, otherFaces);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "4.4.1",
3
+ "version": "4.4.2-new-json",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",