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.
- package/es/LiteRenderer.js +15 -53
- package/es/catalog/factories/area-factory-3d.js +0 -4
- package/es/catalog/holes/door-double/door_double.png +0 -0
- package/es/catalog/holes/door-panic/panicDoor.png +0 -0
- package/es/catalog/holes/door-panic-double/panicDoorDouble.png +0 -0
- package/es/catalog/holes/gate/gate.jpg +0 -0
- package/es/catalog/holes/window-clear/texture.png +0 -0
- package/es/catalog/holes/window-cross/texture.png +0 -0
- package/es/catalog/holes/window-double-hung/texture.png +0 -0
- package/es/catalog/holes/window-vertical/texture.png +0 -0
- package/es/catalog/utils/item-loader.js +3 -22
- package/es/class/item.js +1 -1
- package/es/constants/catalog/skinPanel.js +9 -0
- package/es/constants.js +11 -13
- package/es/devLiteRenderer.js +91 -109
- package/es/mappings/external-events/mapExternalEventPayload.js +21 -0
- package/es/mappings/external-events/mappers/addItemMapper.js +86 -0
- package/es/mappings/external-events/mappers/ccdfMapper.js +101 -0
- package/es/mappings/external-events/mappers/changeDoorStyleMapper.js +65 -0
- package/es/mappings/holesToCatalog.js +139 -0
- package/es/models.js +3 -1
- package/es/utils/helper.js +18 -9
- package/es/utils/isolate-event-handler.js +621 -173
- package/es/utils/molding.js +20 -236
- package/es/utils/skinPanelEngine.js +230 -26
- package/lib/LiteRenderer.js +17 -55
- package/lib/catalog/factories/area-factory-3d.js +0 -4
- package/lib/catalog/holes/door-double/door_double.png +0 -0
- package/lib/catalog/holes/door-panic/panicDoor.png +0 -0
- package/lib/catalog/holes/door-panic-double/panicDoorDouble.png +0 -0
- package/lib/catalog/holes/gate/gate.jpg +0 -0
- package/lib/catalog/holes/window-clear/texture.png +0 -0
- package/lib/catalog/holes/window-cross/texture.png +0 -0
- package/lib/catalog/holes/window-double-hung/texture.png +0 -0
- package/lib/catalog/holes/window-vertical/texture.png +0 -0
- package/lib/catalog/utils/item-loader.js +2 -21
- package/lib/class/item.js +1 -1
- package/lib/constants/catalog/skinPanel.js +15 -0
- package/lib/constants.js +16 -18
- package/lib/devLiteRenderer.js +93 -111
- package/lib/mappings/external-events/mapExternalEventPayload.js +26 -0
- package/lib/mappings/external-events/mappers/addItemMapper.js +92 -0
- package/lib/mappings/external-events/mappers/ccdfMapper.js +108 -0
- package/lib/mappings/external-events/mappers/changeDoorStyleMapper.js +72 -0
- package/lib/mappings/holesToCatalog.js +148 -0
- package/lib/models.js +3 -1
- package/lib/utils/helper.js +20 -9
- package/lib/utils/isolate-event-handler.js +620 -172
- package/lib/utils/molding.js +20 -237
- package/lib/utils/skinPanelEngine.js +232 -28
- package/package.json +1 -1
package/es/utils/molding.js
CHANGED
|
@@ -563,7 +563,23 @@ export function getLinesFromItems2(moldingGroup, layer, catalog) {
|
|
|
563
563
|
})) return 1; // continue
|
|
564
564
|
var mergedResult = getMergedLine(MGlines[_i3], filteredMGlines, 0);
|
|
565
565
|
if (mergedResult) {
|
|
566
|
-
|
|
566
|
+
// keep origin line direction
|
|
567
|
+
var rstLine = mergedResult.mergedLine;
|
|
568
|
+
// if (
|
|
569
|
+
// (Math.abs(MGlines[i][0].x - rstLine[1].x) < EPSILON &&
|
|
570
|
+
// Math.abs(MGlines[i][0].y - rstLine[1].y) < EPSILON) ||
|
|
571
|
+
// (Math.abs(MGlines[i][1].x - rstLine[0].x) < EPSILON &&
|
|
572
|
+
// Math.abs(MGlines[i][1].y - rstLine[0].y) < EPSILON)
|
|
573
|
+
// ) {
|
|
574
|
+
// // swap two end points
|
|
575
|
+
// const tx = rstLine[0].x;
|
|
576
|
+
// const ty = rstLine[0].y;
|
|
577
|
+
// rstLine[0].x = rstLine[1].x;
|
|
578
|
+
// rstLine[0].y = rstLine[1].y;
|
|
579
|
+
// rstLine[1].x = tx;
|
|
580
|
+
// rstLine[1].y = ty;
|
|
581
|
+
// }
|
|
582
|
+
newMGlines.push(rstLine);
|
|
567
583
|
filteredMGlines = mergedResult.filteredMGlines;
|
|
568
584
|
}
|
|
569
585
|
},
|
|
@@ -939,7 +955,7 @@ export function createMonldingGroup(oldMG, layer, molding, catalog) {
|
|
|
939
955
|
newMG = getMDPoints(newMG);
|
|
940
956
|
return newMG;
|
|
941
957
|
}
|
|
942
|
-
export function getMoldingDataOfScene2(layer, catalog, doorStyle) {
|
|
958
|
+
export function getMoldingDataOfScene2(layer, catalog, doorStyle, moldingPieceLength) {
|
|
943
959
|
var _layer$items;
|
|
944
960
|
var moldingData = [];
|
|
945
961
|
var items = layer === null || layer === void 0 || (_layer$items = layer.items) === null || _layer$items === void 0 ? void 0 : _layer$items.toArray();
|
|
@@ -1101,10 +1117,10 @@ export function getMoldingDataOfScene2(layer, catalog, doorStyle) {
|
|
|
1101
1117
|
if (idx < 0) moldingData.push(_objectSpread(_objectSpread({}, ml.molding), {}, {
|
|
1102
1118
|
doorStyle: ml.doorStyle,
|
|
1103
1119
|
totalLength: mlLength,
|
|
1104
|
-
count: Math.ceil(mlLength * 1.1 /
|
|
1120
|
+
count: Math.ceil(mlLength * 1.1 / moldingPieceLength)
|
|
1105
1121
|
}));else {
|
|
1106
1122
|
moldingData[idx].totalLength += mlLength;
|
|
1107
|
-
moldingData[idx].count = Math.ceil(moldingData[idx].totalLength * 1.1 /
|
|
1123
|
+
moldingData[idx].count = Math.ceil(moldingData[idx].totalLength * 1.1 / moldingPieceLength);
|
|
1108
1124
|
}
|
|
1109
1125
|
};
|
|
1110
1126
|
for (var k = 0; k < moldingLines.length; k++) {
|
|
@@ -1112,237 +1128,5 @@ export function getMoldingDataOfScene2(layer, catalog, doorStyle) {
|
|
|
1112
1128
|
}
|
|
1113
1129
|
// console.log('moldingData: ', moldingData);
|
|
1114
1130
|
|
|
1115
|
-
return moldingData;
|
|
1116
|
-
}
|
|
1117
|
-
export function getMoldingDataOfScene(layer, catalog, doorStyle) {
|
|
1118
|
-
var moldingData = [];
|
|
1119
|
-
var items = layer.items.toArray();
|
|
1120
|
-
var moldings = [];
|
|
1121
|
-
// get all moldings info
|
|
1122
|
-
items.forEach(function (itemCat) {
|
|
1123
|
-
var _itemCat$molding;
|
|
1124
|
-
itemCat === null || itemCat === void 0 || (_itemCat$molding = itemCat.molding) === null || _itemCat$molding === void 0 || _itemCat$molding.forEach(function (molding) {
|
|
1125
|
-
if (!moldings.some(function (m) {
|
|
1126
|
-
return m.name === molding.name;
|
|
1127
|
-
})) moldings.push(molding);
|
|
1128
|
-
});
|
|
1129
|
-
});
|
|
1130
|
-
|
|
1131
|
-
// calc normal molding
|
|
1132
|
-
moldings.forEach(function (molding) {
|
|
1133
|
-
var itemGroups = [];
|
|
1134
|
-
var temp_items = [];
|
|
1135
|
-
items.forEach(function (item) {
|
|
1136
|
-
if (item.molding.some(function (mol) {
|
|
1137
|
-
return mol.itemID === molding.itemID;
|
|
1138
|
-
}) && isEnableItemForMolding(layer, item)) {
|
|
1139
|
-
temp_items.push(item);
|
|
1140
|
-
}
|
|
1141
|
-
});
|
|
1142
|
-
if (temp_items.length) {
|
|
1143
|
-
while (temp_items.length > 0) {
|
|
1144
|
-
var itemGroup = [temp_items[0]];
|
|
1145
|
-
var _loop10 = function _loop10(_idx) {
|
|
1146
|
-
if (!itemGroup.some(function (it) {
|
|
1147
|
-
return it.id === temp_items[_idx].id;
|
|
1148
|
-
}) && isItemSnappedGroup(temp_items[_idx], itemGroup)) {
|
|
1149
|
-
itemGroup.push(temp_items[_idx]);
|
|
1150
|
-
_idx = 0;
|
|
1151
|
-
}
|
|
1152
|
-
idx = _idx;
|
|
1153
|
-
};
|
|
1154
|
-
for (var idx = 0; idx < temp_items.length; idx++) {
|
|
1155
|
-
_loop10(idx);
|
|
1156
|
-
}
|
|
1157
|
-
itemGroup.forEach(function (item) {
|
|
1158
|
-
var index = temp_items.findIndex(function (it) {
|
|
1159
|
-
return it.id === item.id;
|
|
1160
|
-
});
|
|
1161
|
-
if (index > -1) {
|
|
1162
|
-
temp_items.splice(index, 1);
|
|
1163
|
-
}
|
|
1164
|
-
});
|
|
1165
|
-
itemGroups.push(itemGroup);
|
|
1166
|
-
}
|
|
1167
|
-
var molding_totalLength = 0;
|
|
1168
|
-
itemGroups.forEach(function (itemgroup) {
|
|
1169
|
-
var allLineRects = GeometryUtils.buildRectFromLines(layer, GeometryUtils.getAllLines(layer));
|
|
1170
|
-
var items = _toConsumableArray(itemgroup);
|
|
1171
|
-
var MGlines = getLinesOfItem(items[0], allLineRects, catalog);
|
|
1172
|
-
items = sortItemsByDistance(items, items[0]);
|
|
1173
|
-
var _loop11 = function _loop11() {
|
|
1174
|
-
var itemLines = getLinesOfItem(items[i], allLineRects, catalog);
|
|
1175
|
-
var temp_MGLines = [];
|
|
1176
|
-
MGlines.forEach(function (line) {
|
|
1177
|
-
var idx = itemLines.findIndex(function (itemLine) {
|
|
1178
|
-
return isLinesOverlapped(line, itemLine);
|
|
1179
|
-
});
|
|
1180
|
-
var curItemLine = itemLines[idx];
|
|
1181
|
-
if (idx > -1) {
|
|
1182
|
-
if (!(GeometryUtils.samePoints(line[0], curItemLine[0]) && GeometryUtils.samePoints(line[1], curItemLine[1]) || GeometryUtils.samePoints(line[0], curItemLine[1]) && GeometryUtils.samePoints(line[1], curItemLine[0]))) {
|
|
1183
|
-
var MGLine = mergeOverlappedLines(line, curItemLine);
|
|
1184
|
-
temp_MGLines.push(MGLine);
|
|
1185
|
-
}
|
|
1186
|
-
itemLines.splice(idx, 1);
|
|
1187
|
-
} else {
|
|
1188
|
-
temp_MGLines.push(line);
|
|
1189
|
-
}
|
|
1190
|
-
});
|
|
1191
|
-
itemLines.forEach(function (itemLine) {
|
|
1192
|
-
return temp_MGLines.push(itemLine);
|
|
1193
|
-
});
|
|
1194
|
-
MGlines = [].concat(temp_MGLines);
|
|
1195
|
-
};
|
|
1196
|
-
for (var i = 1; i < items.length; i++) {
|
|
1197
|
-
_loop11();
|
|
1198
|
-
}
|
|
1199
|
-
MGlines.forEach(function (line) {
|
|
1200
|
-
molding_totalLength += GeometryUtils.verticesDistance(line[0], line[1]);
|
|
1201
|
-
});
|
|
1202
|
-
});
|
|
1203
|
-
molding_totalLength = convert(molding_totalLength).from('cm').to('in');
|
|
1204
|
-
moldingData.push(_objectSpread(_objectSpread({}, molding), {}, {
|
|
1205
|
-
doorStyle: doorStyle,
|
|
1206
|
-
count: Math.ceil(molding_totalLength * 1.1 / 96)
|
|
1207
|
-
}));
|
|
1208
|
-
}
|
|
1209
|
-
});
|
|
1210
|
-
|
|
1211
|
-
// calc toe kick molding
|
|
1212
|
-
var tmp = [];
|
|
1213
|
-
items.forEach(function (item) {
|
|
1214
|
-
if (item.category === 'cabinet' && !item.cabinet_category.toLowerCase().includes('microwave')) {
|
|
1215
|
-
tmp.push(item);
|
|
1216
|
-
}
|
|
1217
|
-
});
|
|
1218
|
-
var tmpMoldingData = [];
|
|
1219
|
-
var toedoorStyles = [];
|
|
1220
|
-
tmp.map(function (item) {
|
|
1221
|
-
var _item$molding2;
|
|
1222
|
-
if (item.layoutpos === BASE_CABINET_LAYOUTPOS && (isEmpty(item.molding) || ((_item$molding2 = item.molding) === null || _item$molding2 === void 0 ? void 0 : _item$molding2.length) < 1 || !isEnableItemForMolding(layer, item))) {
|
|
1223
|
-
var w = item.properties.get('width').get('_length');
|
|
1224
|
-
var wUnit = item.properties.get('width').get('_unit') || 'cm';
|
|
1225
|
-
w = convert(w / 2).from(wUnit).to('cm');
|
|
1226
|
-
var h = item.properties.get('depth').get('_length');
|
|
1227
|
-
var hUnit = item.properties.get('depth').get('_unit') || 'cm';
|
|
1228
|
-
h = convert(h / 2).from(hUnit).to('cm');
|
|
1229
|
-
var outline = null;
|
|
1230
|
-
var element = catalog.elements[item.get('type')];
|
|
1231
|
-
if (!element) element = catalog.elements[returnReplaceableDeepSearchType(item.get('type'))];
|
|
1232
|
-
outline = element.info.outline;
|
|
1233
|
-
var len = 0;
|
|
1234
|
-
if (outline) {
|
|
1235
|
-
// Extract Points from `outline`
|
|
1236
|
-
var outlinePaths = outline.paths;
|
|
1237
|
-
var outlineWidth = outline.svgWidth;
|
|
1238
|
-
var outlineHeight = outline.svgHeight;
|
|
1239
|
-
var outlinePoints = []; // Hold Points Of SVG
|
|
1240
|
-
var _iterator5 = _createForOfIteratorHelper(outlinePaths),
|
|
1241
|
-
_step5;
|
|
1242
|
-
try {
|
|
1243
|
-
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
1244
|
-
var path = _step5.value;
|
|
1245
|
-
var _iterator6 = _createForOfIteratorHelper(path.subPaths),
|
|
1246
|
-
_step6;
|
|
1247
|
-
try {
|
|
1248
|
-
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
1249
|
-
var subPath = _step6.value;
|
|
1250
|
-
outlinePoints = outlinePoints.concat(subPath.getPoints());
|
|
1251
|
-
}
|
|
1252
|
-
} catch (err) {
|
|
1253
|
-
_iterator6.e(err);
|
|
1254
|
-
} finally {
|
|
1255
|
-
_iterator6.f();
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
} catch (err) {
|
|
1259
|
-
_iterator5.e(err);
|
|
1260
|
-
} finally {
|
|
1261
|
-
_iterator5.f();
|
|
1262
|
-
}
|
|
1263
|
-
var maxX = outlinePoints[0].x,
|
|
1264
|
-
minX = outlinePoints[0].x;
|
|
1265
|
-
var maxY = outlinePoints[0].y,
|
|
1266
|
-
minY = outlinePoints[0].y;
|
|
1267
|
-
outlinePoints.forEach(function (point) {
|
|
1268
|
-
if (point.x > maxX) {
|
|
1269
|
-
maxX = point.x;
|
|
1270
|
-
}
|
|
1271
|
-
if (point.x < minX) {
|
|
1272
|
-
minX = point.x;
|
|
1273
|
-
}
|
|
1274
|
-
if (point.y > maxY) {
|
|
1275
|
-
maxY = point.y;
|
|
1276
|
-
}
|
|
1277
|
-
if (point.y < minY) {
|
|
1278
|
-
minY = point.y;
|
|
1279
|
-
}
|
|
1280
|
-
});
|
|
1281
|
-
outlinePoints.forEach(function (point) {
|
|
1282
|
-
if (GeometryUtils.isPointInRect([{
|
|
1283
|
-
x: minX,
|
|
1284
|
-
y: minY
|
|
1285
|
-
}, {
|
|
1286
|
-
x: minX,
|
|
1287
|
-
y: maxY
|
|
1288
|
-
}, {
|
|
1289
|
-
x: maxX,
|
|
1290
|
-
y: maxY
|
|
1291
|
-
}, {
|
|
1292
|
-
x: maxX,
|
|
1293
|
-
y: minY
|
|
1294
|
-
}], point)) {
|
|
1295
|
-
if (point.x > 10) len += (point.x / outlineWidth - 0.5) * w * 2 + h * 2 - (point.y / outlineHeight - 0.5) * h * 2;
|
|
1296
|
-
}
|
|
1297
|
-
});
|
|
1298
|
-
len = convert(len).from('cm').to('in');
|
|
1299
|
-
} else {
|
|
1300
|
-
w = convert(w * 2).from('cm').to('in');
|
|
1301
|
-
len += w;
|
|
1302
|
-
}
|
|
1303
|
-
var doorIndex = toedoorStyles.findIndex(function (a) {
|
|
1304
|
-
var iDS = item === null || item === void 0 ? void 0 : item.doorStyle;
|
|
1305
|
-
if (!iDS) return false;
|
|
1306
|
-
if (!iDS.hasOwnProperty('id')) {
|
|
1307
|
-
iDS = iDS.toJS();
|
|
1308
|
-
}
|
|
1309
|
-
return a.doorStyle.id === iDS.id && isEqualInstallationType(a.doorStyle, iDS);
|
|
1310
|
-
});
|
|
1311
|
-
if (doorIndex > -1) {
|
|
1312
|
-
toedoorStyles[doorIndex].totalLength += len;
|
|
1313
|
-
} else {
|
|
1314
|
-
toedoorStyles.push({
|
|
1315
|
-
doorStyle: item.doorStyle.hasOwnProperty('id') ? item.doorStyle : item.doorStyle && item.doorStyle.toJS(),
|
|
1316
|
-
totalLength: len
|
|
1317
|
-
});
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
});
|
|
1321
|
-
toedoorStyles.forEach(function (doorStyle) {
|
|
1322
|
-
var skuName = getToeKickSKU(doorStyle.doorStyle, catalog);
|
|
1323
|
-
var thumbnail = skuName ? skuName : '';
|
|
1324
|
-
// moldings.forEach(molding => {
|
|
1325
|
-
// if (
|
|
1326
|
-
// molding.name ===
|
|
1327
|
-
// getToeKickSKU(
|
|
1328
|
-
// doorStyle.doorStyle,
|
|
1329
|
-
// catalog,
|
|
1330
|
-
// true
|
|
1331
|
-
// )
|
|
1332
|
-
// )
|
|
1333
|
-
// thumbnail = molding.thumbnail;
|
|
1334
|
-
// });
|
|
1335
|
-
|
|
1336
|
-
doorStyle.totalLength && tmpMoldingData.push({
|
|
1337
|
-
name: TOE_KICK_MOLDING,
|
|
1338
|
-
sku: getToeKickSKU(doorStyle.doorStyle, catalog),
|
|
1339
|
-
thumbnail: thumbnail,
|
|
1340
|
-
category: 'molding',
|
|
1341
|
-
type: 'cabinet',
|
|
1342
|
-
doorStyle: doorStyle.doorStyle,
|
|
1343
|
-
count: Math.ceil(doorStyle.totalLength * 1.1 / 96)
|
|
1344
|
-
});
|
|
1345
|
-
});
|
|
1346
|
-
if (tmpMoldingData.length > 0) moldingData = [].concat(_toConsumableArray(moldingData), tmpMoldingData);
|
|
1347
1131
|
return moldingData;
|
|
1348
1132
|
}
|
|
@@ -2,11 +2,12 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
2
2
|
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; } } }; }
|
|
3
3
|
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; } }
|
|
4
4
|
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; }
|
|
5
|
-
import { BASE_CABINET_LAYOUTPOS, WALL_CABINET_LAYOUTPOS, TALL_CABINET_LAYOUTPOS, OVERLAP_INCLUDED, OVERLAP_SAME, OVERLAP_LINK, OVERLAP_SOME, EPSILON,
|
|
5
|
+
import { BASE_CABINET_LAYOUTPOS, WALL_CABINET_LAYOUTPOS, TALL_CABINET_LAYOUTPOS, OVERLAP_INCLUDED, OVERLAP_SAME, OVERLAP_LINK, OVERLAP_SOME, EPSILON, VANITY_CABINET_LAYOUTPOS } from "../constants";
|
|
6
6
|
import { buildRectFromLines, getAllLines, pointsDistance, relationshipOfTwoOverlappedLines, rotatePointAroundPoint } from "./geometry";
|
|
7
7
|
import { MathUtils } from "./export";
|
|
8
8
|
import { convert } from "./convert-units-lite";
|
|
9
|
-
import { isEmpty } from "./helper";
|
|
9
|
+
import { getSkuAliasFromCatalog, isEmpty } from "./helper";
|
|
10
|
+
import { SKIN_SKU_BSV_24, SKIN_SKU_BSV_48, SKIN_SKU_WSV_1242, SKIN_SKU_WSV_2442, SKIN_SKU_WSV_2460, SKIN_SKU_USV245325, SKIN_HEIGHT_53_25 } from "../constants/catalog/skinPanel";
|
|
10
11
|
function toCm(item, prop) {
|
|
11
12
|
var unit = item.properties.get(prop).get('_unit') || 'cm';
|
|
12
13
|
var value = item.properties.get(prop).get('_length');
|
|
@@ -30,7 +31,8 @@ export function getSideFaces(item, layer) {
|
|
|
30
31
|
var overlapList = [OVERLAP_INCLUDED, OVERLAP_SAME, OVERLAP_SOME];
|
|
31
32
|
var pos = [[-1, -1], [1, -1], [1, 1], [-1, 1]];
|
|
32
33
|
for (var i = 0; i < 4; i++) {
|
|
33
|
-
if (i === 0
|
|
34
|
+
if (i === 0) continue; // only left & right & base cabinet's back
|
|
35
|
+
if (i === 2 && item.layoutpos !== BASE_CABINET_LAYOUTPOS) continue;
|
|
34
36
|
var isSnappedToWall = false;
|
|
35
37
|
var v0 = rotateCorner(pos[i], item, widthCm, depthCm);
|
|
36
38
|
var v1 = rotateCorner(pos[(i + 1) % 4], item, widthCm, depthCm);
|
|
@@ -64,7 +66,8 @@ export function getSideFaces(item, layer) {
|
|
|
64
66
|
var skinPanelSKU = 'unknown';
|
|
65
67
|
switch (item.layoutpos) {
|
|
66
68
|
case BASE_CABINET_LAYOUTPOS:
|
|
67
|
-
|
|
69
|
+
case VANITY_CABINET_LAYOUTPOS:
|
|
70
|
+
skinPanelSKU = i === 2 ? 'unknown' : SKIN_SKU_BSV_24;
|
|
68
71
|
break;
|
|
69
72
|
case WALL_CABINET_LAYOUTPOS:
|
|
70
73
|
if (Math.abs(depthInch - 12) <= 1) skinPanelSKU = SKIN_SKU_WSV_1242;else if (Math.abs(depthInch - 24) <= 1) skinPanelSKU = SKIN_SKU_WSV_2442;
|
|
@@ -84,6 +87,7 @@ export function getSideFaces(item, layer) {
|
|
|
84
87
|
// inch unit
|
|
85
88
|
height: heightInch,
|
|
86
89
|
// inch unit
|
|
90
|
+
isBackFace: i === 2 ? true : false,
|
|
87
91
|
skinPanelSKU: skinPanelSKU,
|
|
88
92
|
itemInfo: item.toJS()
|
|
89
93
|
});
|
|
@@ -93,7 +97,7 @@ export function getSideFaces(item, layer) {
|
|
|
93
97
|
}
|
|
94
98
|
function collectLayerItems(layer) {
|
|
95
99
|
var _layer$items;
|
|
96
|
-
var skinLayouts = new Set([BASE_CABINET_LAYOUTPOS, WALL_CABINET_LAYOUTPOS, TALL_CABINET_LAYOUTPOS]);
|
|
100
|
+
var skinLayouts = new Set([BASE_CABINET_LAYOUTPOS, WALL_CABINET_LAYOUTPOS, TALL_CABINET_LAYOUTPOS, VANITY_CABINET_LAYOUTPOS]);
|
|
97
101
|
var skinPanelItems = [];
|
|
98
102
|
var otherItems = [];
|
|
99
103
|
layer === null || layer === void 0 || (_layer$items = layer.items) === null || _layer$items === void 0 || _layer$items.forEach(function (it) {
|
|
@@ -113,26 +117,142 @@ function collectFaces(items, layer) {
|
|
|
113
117
|
}
|
|
114
118
|
return faces;
|
|
115
119
|
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @param {*} faceSegs
|
|
123
|
+
* @param {*} otherFaces
|
|
124
|
+
* @returns
|
|
125
|
+
*/
|
|
126
|
+
function getTrimmedFaceSegs(faceSegs, otherFaces, cnt) {
|
|
127
|
+
try {
|
|
128
|
+
cnt++;
|
|
129
|
+
if (cnt > 5000) {
|
|
130
|
+
console.log('getTrimmedFaceSegs has limited!');
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
var returnSegs = [];
|
|
134
|
+
var _loop = function _loop() {
|
|
135
|
+
var iFace = faceSegs[i];
|
|
136
|
+
var srcLine = iFace.sectionLine;
|
|
137
|
+
var bContourSeg = true;
|
|
138
|
+
var _loop2 = function _loop2(j) {
|
|
139
|
+
var destLine = otherFaces[j].sectionLine;
|
|
140
|
+
var rst = relationshipOfTwoOverlappedLines(srcLine, destLine);
|
|
141
|
+
if (rst.result == OVERLAP_SAME || rst.result == OVERLAP_INCLUDED) {
|
|
142
|
+
bContourSeg = false;
|
|
143
|
+
return 0; // break
|
|
144
|
+
} else if (rst.result == OVERLAP_SOME) {
|
|
145
|
+
var trimmedFaceSegs = [];
|
|
146
|
+
rst.trimmedSegs.forEach(function (lineSeg) {
|
|
147
|
+
trimmedFaceSegs.push({
|
|
148
|
+
sectionLine: lineSeg,
|
|
149
|
+
// cm unit
|
|
150
|
+
zBottom: iFace.zBottom,
|
|
151
|
+
// cm unit
|
|
152
|
+
zTop: iFace.zTop,
|
|
153
|
+
// cm unit
|
|
154
|
+
depth: iFace.depthInch,
|
|
155
|
+
// inch unit
|
|
156
|
+
height: iFace.heightInch,
|
|
157
|
+
// inch unit
|
|
158
|
+
isBackFace: iFace.isBackFace,
|
|
159
|
+
skinPanelSKU: iFace.skinPanelSKU,
|
|
160
|
+
itemInfo: iFace.itemInfo
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
var tFaceSegs = getTrimmedFaceSegs(trimmedFaceSegs, otherFaces.filter(function (v, idx) {
|
|
164
|
+
return idx !== j;
|
|
165
|
+
}), cnt);
|
|
166
|
+
if (tFaceSegs.length > 0) returnSegs = [].concat(_toConsumableArray(returnSegs), _toConsumableArray(tFaceSegs));
|
|
167
|
+
bContourSeg = false;
|
|
168
|
+
return 0; // break
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
_ret;
|
|
172
|
+
for (var j = 0; j < otherFaces.length; j++) {
|
|
173
|
+
_ret = _loop2(j);
|
|
174
|
+
if (_ret === 0) break;
|
|
175
|
+
}
|
|
176
|
+
if (bContourSeg) returnSegs.push(faceSegs[i]);
|
|
177
|
+
};
|
|
178
|
+
for (var i = 0; i < faceSegs.length; i++) {
|
|
179
|
+
_loop();
|
|
180
|
+
}
|
|
181
|
+
return returnSegs;
|
|
182
|
+
} catch (e) {
|
|
183
|
+
console.log('getTrimmedFaceSegs catched :', e);
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
116
187
|
function filterFacesBlockedByFaces(sourceFaces, blockingFaces) {
|
|
117
188
|
var overlapList = [OVERLAP_INCLUDED, OVERLAP_SAME];
|
|
118
189
|
var removeIdxs = [];
|
|
119
|
-
|
|
190
|
+
var newFaces = []; // new countour edge segment that except the overlapped part
|
|
191
|
+
var _loop3 = function _loop3(i) {
|
|
120
192
|
var iFace = sourceFaces[i];
|
|
121
193
|
for (var j = 0; j < blockingFaces.length; j++) {
|
|
194
|
+
var _relationship$trimmed;
|
|
122
195
|
if (sourceFaces === blockingFaces && i === j) continue;
|
|
123
196
|
var jFace = blockingFaces[j];
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
197
|
+
var verticallyIncluded = (iFace.zBottom > jFace.zBottom || Math.abs(iFace.zBottom - jFace.zBottom) < EPSILON) && (iFace.zTop < jFace.zTop || Math.abs(iFace.zTop - jFace.zTop) < EPSILON);
|
|
198
|
+
var verticallyOverlappedTopPart = jFace.zBottom < iFace.zTop && jFace.zBottom > iFace.zBottom && Math.abs(jFace.zBottom - iFace.zTop) > EPSILON && Math.abs(jFace.zBottom - iFace.zBottom) > EPSILON;
|
|
199
|
+
var verticallyOverlappedBottomPart = jFace.zTop < iFace.zTop && jFace.zTop > iFace.zBottom && Math.abs(jFace.zTop - iFace.zTop) > EPSILON && Math.abs(jFace.zTop - iFace.zBottom) > EPSILON;
|
|
200
|
+
var relationship = relationshipOfTwoOverlappedLines(iFace.sectionLine, jFace.sectionLine);
|
|
201
|
+
if (overlapList.includes(relationship.result)) {
|
|
202
|
+
if (verticallyIncluded) removeIdxs.push(i);else if (verticallyOverlappedTopPart) {
|
|
127
203
|
removeIdxs.push(i);
|
|
128
|
-
|
|
204
|
+
newFaces.push({
|
|
205
|
+
sectionLine: iFace.sectionLine,
|
|
206
|
+
// cm unit
|
|
207
|
+
zBottom: iFace.zBottom,
|
|
208
|
+
// cm unit
|
|
209
|
+
zTop: jFace.zBottom,
|
|
210
|
+
// cm unit
|
|
211
|
+
depth: iFace.depthInch,
|
|
212
|
+
// inch unit
|
|
213
|
+
height: toIn(jFace.zBottom - iFace.zBottom),
|
|
214
|
+
// inch unit
|
|
215
|
+
isBackFace: iFace.isBackFace,
|
|
216
|
+
skinPanelSKU: iFace.skinPanelSKU,
|
|
217
|
+
itemInfo: iFace.itemInfo
|
|
218
|
+
});
|
|
219
|
+
} else if (verticallyOverlappedBottomPart) {
|
|
220
|
+
removeIdxs.push(i);
|
|
221
|
+
newFaces.push({
|
|
222
|
+
sectionLine: iFace.sectionLine,
|
|
223
|
+
// cm unit
|
|
224
|
+
zBottom: jFace.zTop,
|
|
225
|
+
// cm unit
|
|
226
|
+
zTop: iFace.zTop,
|
|
227
|
+
// cm unit
|
|
228
|
+
depth: iFace.depthInch,
|
|
229
|
+
// inch unit
|
|
230
|
+
height: toIn(iFace.zTop - jFace.zTop),
|
|
231
|
+
// inch unit
|
|
232
|
+
isBackFace: iFace.isBackFace,
|
|
233
|
+
skinPanelSKU: iFace.skinPanelSKU,
|
|
234
|
+
itemInfo: iFace.itemInfo
|
|
235
|
+
});
|
|
129
236
|
}
|
|
237
|
+
break;
|
|
238
|
+
} else if (relationship.result === OVERLAP_SOME && ((_relationship$trimmed = relationship.trimmedSegs) === null || _relationship$trimmed === void 0 ? void 0 : _relationship$trimmed.length) > 0 && verticallyIncluded) {
|
|
239
|
+
removeIdxs.push(i);
|
|
240
|
+
var tFaceSegs = getTrimmedFaceSegs([iFace], sourceFaces === blockingFaces ? blockingFaces.filter(function (v, idx) {
|
|
241
|
+
return idx !== i;
|
|
242
|
+
}) : blockingFaces, 0);
|
|
243
|
+
if (tFaceSegs.length > 0) newFaces = [].concat(_toConsumableArray(newFaces), _toConsumableArray(tFaceSegs));
|
|
244
|
+
break;
|
|
130
245
|
}
|
|
131
246
|
}
|
|
247
|
+
};
|
|
248
|
+
for (var i = 0; i < sourceFaces.length; i++) {
|
|
249
|
+
_loop3(i);
|
|
132
250
|
}
|
|
133
|
-
|
|
251
|
+
sourceFaces = sourceFaces.filter(function (face, idx) {
|
|
134
252
|
return !removeIdxs.includes(idx);
|
|
135
253
|
});
|
|
254
|
+
if (newFaces.length > 0) sourceFaces = [].concat(_toConsumableArray(sourceFaces), _toConsumableArray(newFaces));
|
|
255
|
+
return sourceFaces;
|
|
136
256
|
}
|
|
137
257
|
function applyGroupingRules(faces) {
|
|
138
258
|
var _applyHorizontalGroup = applyHorizontalGrouping(faces),
|
|
@@ -173,7 +293,8 @@ function applyHorizontalGrouping(faces) {
|
|
|
173
293
|
// inch unit
|
|
174
294
|
height: jFace.height,
|
|
175
295
|
// inch unit
|
|
176
|
-
|
|
296
|
+
isBackFace: jFace.isBackFace,
|
|
297
|
+
skinPanelSKU: jFace.isBackFace ? 'unknown' : SKIN_SKU_BSV_48,
|
|
177
298
|
itemInfo: jFace.itemInfo // [TODO] how to select the doorstyle of grouped skin
|
|
178
299
|
});
|
|
179
300
|
removeIdxs.push(i);
|
|
@@ -216,6 +337,7 @@ function applyVerticalGrouping(faces) {
|
|
|
216
337
|
// inch unit
|
|
217
338
|
height: jFace.height,
|
|
218
339
|
// inch unit
|
|
340
|
+
isBackFace: jFace.isBackFace,
|
|
219
341
|
skinPanelSKU: SKIN_SKU_WSV_2460,
|
|
220
342
|
itemInfo: jFace.itemInfo // [TODO] how to select the doorstyle of grouped skin
|
|
221
343
|
});
|
|
@@ -243,9 +365,10 @@ function resolveTallCabinetBundle(face) {
|
|
|
243
365
|
if (isMP3TallCabinet(item.sku_number)) {
|
|
244
366
|
return [SKIN_SKU_BSV_24, SKIN_SKU_BSV_24, SKIN_SKU_WSV_2442];
|
|
245
367
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
368
|
+
if (face.height > SKIN_HEIGHT_53_25) {
|
|
369
|
+
return [SKIN_SKU_USV245325, SKIN_SKU_WSV_2442];
|
|
370
|
+
}
|
|
371
|
+
return face !== null && face !== void 0 && face.skinPanelSKU ? [face.skinPanelSKU] : [];
|
|
249
372
|
}
|
|
250
373
|
|
|
251
374
|
/**
|
|
@@ -263,34 +386,38 @@ function resolveSkinPanelSKU(face) {
|
|
|
263
386
|
* Make skin panel data with grouping skinPanelSKU & doorStyle
|
|
264
387
|
*/
|
|
265
388
|
function buildSkinPanelData(faces) {
|
|
266
|
-
var
|
|
267
|
-
var
|
|
389
|
+
var tempResult = [];
|
|
390
|
+
var _loop4 = function _loop4() {
|
|
268
391
|
var sf = faces[i];
|
|
269
392
|
var skus = resolveSkinPanelSKU(sf);
|
|
270
393
|
var _iterator = _createForOfIteratorHelper(skus),
|
|
271
394
|
_step;
|
|
272
395
|
try {
|
|
273
|
-
var
|
|
396
|
+
var _loop6 = function _loop6() {
|
|
274
397
|
var sku = _step.value;
|
|
275
|
-
var idx =
|
|
398
|
+
var idx = tempResult.findIndex(function (v) {
|
|
276
399
|
var _sf$itemInfo;
|
|
277
|
-
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);
|
|
400
|
+
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;
|
|
278
401
|
});
|
|
279
402
|
if (idx < 0) {
|
|
280
403
|
var _sf$itemInfo$doorStyl, _sf$itemInfo2, _sf$itemInfo$doorStyl2, _sf$itemInfo3;
|
|
281
|
-
|
|
404
|
+
tempResult.push({
|
|
282
405
|
itemSKU: sku,
|
|
283
406
|
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 : '',
|
|
284
407
|
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 : '',
|
|
285
408
|
installationType: 'standard',
|
|
286
|
-
quantity: 1
|
|
409
|
+
quantity: 1,
|
|
410
|
+
totalLength: toIn(pointsDistance(sf.sectionLine.x1, sf.sectionLine.y1, sf.sectionLine.x2, sf.sectionLine.y2)),
|
|
411
|
+
isBackFace: sf.isBackFace
|
|
287
412
|
});
|
|
288
413
|
} else {
|
|
289
|
-
|
|
414
|
+
var faceLength = pointsDistance(sf.sectionLine.x1, sf.sectionLine.y1, sf.sectionLine.x2, sf.sectionLine.y2);
|
|
415
|
+
tempResult[idx].totalLength += toIn(faceLength);
|
|
416
|
+
tempResult[idx].quantity += 1;
|
|
290
417
|
}
|
|
291
418
|
};
|
|
292
419
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
293
|
-
|
|
420
|
+
_loop6();
|
|
294
421
|
}
|
|
295
422
|
} catch (err) {
|
|
296
423
|
_iterator.e(err);
|
|
@@ -299,18 +426,95 @@ function buildSkinPanelData(faces) {
|
|
|
299
426
|
}
|
|
300
427
|
};
|
|
301
428
|
for (var i = 0; i < faces.length; i++) {
|
|
302
|
-
|
|
429
|
+
_loop4();
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// calculate back face panel quantity of island base cabinets
|
|
433
|
+
var removeIdxs = [];
|
|
434
|
+
var newDatas = [];
|
|
435
|
+
var _loop5 = function _loop5() {
|
|
436
|
+
var iData = tempResult[_i];
|
|
437
|
+
if (iData.isBackFace) {
|
|
438
|
+
removeIdxs.push(_i);
|
|
439
|
+
var count48 = Math.floor(iData.totalLength / 48);
|
|
440
|
+
var count24 = iData.totalLength % 48 > 0 ? 1 : 0;
|
|
441
|
+
var idx48 = tempResult.findIndex(function (v) {
|
|
442
|
+
return v.itemSKU === SKIN_SKU_BSV_48 && v.doorStyleId === iData.doorStyleId;
|
|
443
|
+
});
|
|
444
|
+
var idx24 = tempResult.findIndex(function (v) {
|
|
445
|
+
return v.itemSKU === SKIN_SKU_BSV_24 && v.doorStyleId === iData.doorStyleId;
|
|
446
|
+
});
|
|
447
|
+
if (idx48 < 0) {
|
|
448
|
+
if (count48 > 0) newDatas.push({
|
|
449
|
+
itemSKU: SKIN_SKU_BSV_48,
|
|
450
|
+
doorStyle: iData.doorStyle,
|
|
451
|
+
doorStyleId: iData.doorStyleId,
|
|
452
|
+
installationType: iData.installationType,
|
|
453
|
+
quantity: count48,
|
|
454
|
+
totalLength: count48 * 48,
|
|
455
|
+
isBackFace: iData.isBackFace
|
|
456
|
+
});
|
|
457
|
+
} else {
|
|
458
|
+
tempResult[idx48].quantity += count48;
|
|
459
|
+
tempResult[idx48].totalLength += count48 * 48;
|
|
460
|
+
}
|
|
461
|
+
if (idx24 < 0) {
|
|
462
|
+
if (count24 > 0) newDatas.push({
|
|
463
|
+
itemSKU: SKIN_SKU_BSV_24,
|
|
464
|
+
doorStyle: iData.doorStyle,
|
|
465
|
+
doorStyleId: iData.doorStyleId,
|
|
466
|
+
installationType: iData.installationType,
|
|
467
|
+
quantity: count24,
|
|
468
|
+
totalLength: count24 * 24,
|
|
469
|
+
isBackFace: iData.isBackFace
|
|
470
|
+
});
|
|
471
|
+
} else {
|
|
472
|
+
tempResult[idx24].quantity += count24;
|
|
473
|
+
tempResult[idx24].totalLength += count24 * 24;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
for (var _i = 0; _i < tempResult.length; _i++) {
|
|
478
|
+
_loop5();
|
|
303
479
|
}
|
|
480
|
+
tempResult = tempResult.filter(function (data, idx) {
|
|
481
|
+
return !removeIdxs.includes(idx);
|
|
482
|
+
});
|
|
483
|
+
if (newDatas.length > 0) tempResult = [].concat(_toConsumableArray(tempResult), newDatas);
|
|
484
|
+
var result = [];
|
|
485
|
+
tempResult.forEach(function (v) {
|
|
486
|
+
return result.push({
|
|
487
|
+
itemSKU: v.itemSKU,
|
|
488
|
+
doorStyle: v.doorStyle,
|
|
489
|
+
doorStyleId: v.doorStyleId,
|
|
490
|
+
installationType: v.installationType,
|
|
491
|
+
quantity: v.quantity
|
|
492
|
+
});
|
|
493
|
+
});
|
|
304
494
|
return result;
|
|
305
495
|
}
|
|
496
|
+
function shouldExcludeSkinPanel(itemJS, exclusionSet, catalog) {
|
|
497
|
+
var _itemJS$doorStyle;
|
|
498
|
+
var cabinetSku = getSkuAliasFromCatalog(catalog, itemJS);
|
|
499
|
+
var doorColorSku = itemJS === null || itemJS === void 0 || (_itemJS$doorStyle = itemJS.doorStyle) === null || _itemJS$doorStyle === void 0 ? void 0 : _itemJS$doorStyle.sku;
|
|
500
|
+
if (!cabinetSku || !doorColorSku) return false;
|
|
501
|
+
return exclusionSet.has("".concat(cabinetSku, "-").concat(doorColorSku));
|
|
502
|
+
}
|
|
306
503
|
export function computeSkinPanels(layer) {
|
|
504
|
+
var skinPanelExclusionSKUs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
505
|
+
var catalog = arguments.length > 2 ? arguments[2] : undefined;
|
|
506
|
+
var exclusionSet = new Set(skinPanelExclusionSKUs);
|
|
507
|
+
|
|
307
508
|
// Get candidate skin panel items and other items
|
|
308
509
|
var _collectLayerItems = collectLayerItems(layer),
|
|
309
510
|
skinPanelItems = _collectLayerItems.skinPanelItems,
|
|
310
511
|
otherItems = _collectLayerItems.otherItems;
|
|
512
|
+
var filteredSkinPanelItems = skinPanelItems.filter(function (item) {
|
|
513
|
+
return !shouldExcludeSkinPanel(item.toJS(), exclusionSet, catalog);
|
|
514
|
+
});
|
|
311
515
|
|
|
312
516
|
// Get all skin face list of [skinPanelItems] & [otherItems]
|
|
313
|
-
var skinFaces = collectFaces(
|
|
517
|
+
var skinFaces = collectFaces(filteredSkinPanelItems, layer);
|
|
314
518
|
var otherFaces = collectFaces(otherItems, layer);
|
|
315
519
|
skinFaces = filterFacesBlockedByFaces(skinFaces, skinFaces);
|
|
316
520
|
skinFaces = filterFacesBlockedByFaces(skinFaces, otherFaces);
|