kitchen-simulator 4.0.0-queuedEvents → 4.0.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.
- package/es/LiteKitchenConfigurator.js +141 -288
- package/es/LiteRenderer.js +159 -398
- package/es/actions/items-actions.js +10 -6
- package/es/actions/lines-actions.js +3 -1
- package/es/actions/project-actions.js +15 -5
- package/es/assets/img/svg/bottombar/elevation.svg +12 -5
- package/es/catalog/areas/area/planner-element.js +10 -5
- package/es/catalog/catalog.js +1 -4
- package/es/catalog/factories/area-factory-3d.js +2 -1
- package/es/catalog/factories/wall-factory-3d.js +2 -2
- package/es/catalog/factories/wall-factory.js +8 -8
- package/es/catalog/lines/wall/planner-element.js +18 -9
- package/es/catalog/utils/exporter.js +7 -3
- package/es/catalog/utils/item-loader.js +24 -14
- package/es/catalog/utils/mtl-loader.js +2 -2
- package/es/catalog/utils/obj-loader.js +2 -2
- package/es/class/hole.js +0 -2
- package/es/class/item.js +183 -184
- package/es/class/line.js +11 -3
- package/es/class/project.js +165 -48
- package/es/components/content.js +19 -6
- package/es/components/viewer2d/grids/grid-streak.js +1 -1
- package/es/components/viewer2d/item.js +84 -51
- package/es/components/viewer2d/line.js +315 -243
- package/es/components/viewer2d/ruler.js +20 -38
- package/es/components/viewer2d/rulerDist.js +48 -78
- package/es/components/viewer2d/utils.js +6 -0
- package/es/components/viewer2d/viewer2d.js +298 -220
- package/es/components/viewer3d/front3D.js +3 -2
- package/es/components/viewer3d/libs/mtl-loader.js +2 -2
- package/es/components/viewer3d/libs/obj-loader.js +2 -2
- package/es/components/viewer3d/libs/orbit-controls.js +3 -4
- package/es/components/viewer3d/libs/pointer-lock-controls.js +6 -7
- package/es/components/viewer3d/scene-creator.js +51 -15
- package/es/components/viewer3d/viewer3d.js +121 -82
- package/es/constants.js +111 -3
- package/es/devLiteRenderer.js +688 -31
- package/es/index.js +567 -87
- package/es/models.js +9 -5
- package/es/plugins/SVGLoader.js +7 -5
- package/es/plugins/console-debugger.js +0 -2
- package/es/plugins/keyboard.js +15 -6
- package/es/reducers/items-reducer.js +5 -5
- package/es/reducers/lines-reducer.js +1 -1
- package/es/reducers/project-reducer.js +5 -3
- package/es/shared-style.js +4 -4
- package/es/utils/geometry.js +163 -2
- package/es/utils/get-edges-of-subgraphs.js +1 -1
- package/es/utils/graph-cycles.js +1 -1
- package/es/utils/graph.js +1 -1
- package/es/utils/helper.js +105 -3
- package/es/utils/isolate-event-handler.js +1542 -164
- package/es/utils/molding.js +461 -11
- package/lib/LiteKitchenConfigurator.js +141 -289
- package/lib/LiteRenderer.js +159 -399
- package/lib/actions/items-actions.js +10 -6
- package/lib/actions/lines-actions.js +3 -1
- package/lib/actions/project-actions.js +15 -4
- package/lib/assets/img/svg/bottombar/elevation.svg +12 -5
- package/lib/catalog/areas/area/planner-element.js +11 -5
- package/lib/catalog/catalog.js +1 -4
- package/lib/catalog/factories/area-factory-3d.js +2 -1
- package/lib/catalog/factories/wall-factory-3d.js +2 -2
- package/lib/catalog/factories/wall-factory.js +8 -8
- package/lib/catalog/lines/wall/planner-element.js +19 -9
- package/lib/catalog/utils/exporter.js +7 -3
- package/lib/catalog/utils/item-loader.js +24 -14
- package/lib/catalog/utils/mtl-loader.js +9 -2
- package/lib/catalog/utils/obj-loader.js +10 -2
- package/lib/class/hole.js +0 -2
- package/lib/class/item.js +180 -181
- package/lib/class/line.js +9 -1
- package/lib/class/project.js +164 -47
- package/lib/components/content.js +19 -6
- package/lib/components/viewer2d/grids/grid-streak.js +1 -1
- package/lib/components/viewer2d/item.js +83 -50
- package/lib/components/viewer2d/line.js +315 -242
- package/lib/components/viewer2d/ruler.js +19 -37
- package/lib/components/viewer2d/rulerDist.js +48 -78
- package/lib/components/viewer2d/utils.js +7 -0
- package/lib/components/viewer2d/viewer2d.js +296 -219
- package/lib/components/viewer3d/front3D.js +3 -2
- package/lib/components/viewer3d/libs/mtl-loader.js +9 -2
- package/lib/components/viewer3d/libs/obj-loader.js +9 -2
- package/lib/components/viewer3d/libs/orbit-controls.js +11 -5
- package/lib/components/viewer3d/libs/pointer-lock-controls.js +13 -7
- package/lib/components/viewer3d/scene-creator.js +49 -13
- package/lib/components/viewer3d/viewer3d.js +119 -80
- package/lib/constants.js +116 -7
- package/lib/devLiteRenderer.js +687 -30
- package/lib/index.js +567 -87
- package/lib/models.js +9 -5
- package/lib/plugins/SVGLoader.js +7 -5
- package/lib/plugins/console-debugger.js +0 -2
- package/lib/plugins/keyboard.js +15 -6
- package/lib/reducers/items-reducer.js +5 -5
- package/lib/reducers/lines-reducer.js +1 -1
- package/lib/reducers/project-reducer.js +4 -2
- package/lib/shared-style.js +4 -4
- package/lib/utils/geometry.js +164 -2
- package/lib/utils/get-edges-of-subgraphs.js +6 -1
- package/lib/utils/graph-cycles.js +7 -8
- package/lib/utils/graph.js +6 -1
- package/lib/utils/helper.js +108 -2
- package/lib/utils/isolate-event-handler.js +1538 -159
- package/lib/utils/molding.js +463 -9
- package/package.json +1 -1
- package/es/assets/Window.hdr +0 -2100
- package/es/assets/img/1.jpg +0 -0
- package/lib/assets/Window.hdr +0 -2100
- package/lib/assets/img/1.jpg +0 -0
package/lib/utils/molding.js
CHANGED
|
@@ -12,7 +12,11 @@ exports.getItemRect = getItemRect;
|
|
|
12
12
|
exports.getLinesFromItems = getLinesFromItems;
|
|
13
13
|
exports.getLinesFromItems2 = getLinesFromItems2;
|
|
14
14
|
exports.getLinesOfItem = getLinesOfItem;
|
|
15
|
+
exports.getLinesOfItem2 = getLinesOfItem2;
|
|
16
|
+
exports.getMoldingDataOfScene = getMoldingDataOfScene;
|
|
17
|
+
exports.getMoldingDataOfScene2 = getMoldingDataOfScene2;
|
|
15
18
|
exports.hasMoldingLayout = hasMoldingLayout;
|
|
19
|
+
exports.isAttachedWall = isAttachedWall;
|
|
16
20
|
exports.isEnableItemForMolding = isEnableItemForMolding;
|
|
17
21
|
exports.isItemSameItemByLocation = isItemSameItemByLocation;
|
|
18
22
|
exports.isItemSnappedGroup = isItemSnappedGroup;
|
|
@@ -87,6 +91,10 @@ function isEnableItemForMolding(layer, selItem) {
|
|
|
87
91
|
// check this item is enable for specified molding
|
|
88
92
|
else return result && hasMoldingLayout(molding, selItem.layoutpos);
|
|
89
93
|
}
|
|
94
|
+
function isAttachedWall(layer, selItem) {
|
|
95
|
+
var allLineRects = _export.GeometryUtils.buildRectFromLines(layer, _export.GeometryUtils.getAllLines(layer));
|
|
96
|
+
return _export.GeometryUtils.isSnappedLine(getItemRect(selItem), allLineRects);
|
|
97
|
+
}
|
|
90
98
|
|
|
91
99
|
/**
|
|
92
100
|
* Check two line segments are overlap. The direction of the two line segments must be opposite.
|
|
@@ -325,6 +333,74 @@ function getLinesOfItem(item, allLineRects, catalog) {
|
|
|
325
333
|
}
|
|
326
334
|
return lines;
|
|
327
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
|
+
}
|
|
328
404
|
function isParallelLines(line1, line2) {
|
|
329
405
|
var isParallel = false;
|
|
330
406
|
if (Math.abs(line1[0].y - line1[1].y) <= _constants.EPSILON && Math.abs(line2[0].y - line2[1].y) <= _constants.EPSILON) isParallel = true;
|
|
@@ -506,20 +582,20 @@ function getLinesFromItems2(moldingGroup, layer, catalog) {
|
|
|
506
582
|
// merge the collinear linked lines to one line
|
|
507
583
|
var newMGlines = [];
|
|
508
584
|
var filteredMGlines = MGlines;
|
|
509
|
-
var _loop3 = function _loop3(
|
|
585
|
+
var _loop3 = function _loop3(_i3) {
|
|
510
586
|
if (filteredMGlines.length < 1) return 0; // break
|
|
511
587
|
if (!filteredMGlines.some(function (v) {
|
|
512
|
-
return v[2] === MGlines[
|
|
588
|
+
return v[2] === MGlines[_i3][2];
|
|
513
589
|
})) return 1; // continue
|
|
514
|
-
var mergedResult = getMergedLine(MGlines[
|
|
590
|
+
var mergedResult = getMergedLine(MGlines[_i3], filteredMGlines, 0);
|
|
515
591
|
if (mergedResult) {
|
|
516
592
|
newMGlines.push(mergedResult.mergedLine);
|
|
517
593
|
filteredMGlines = mergedResult.filteredMGlines;
|
|
518
594
|
}
|
|
519
595
|
},
|
|
520
596
|
_ret;
|
|
521
|
-
for (var
|
|
522
|
-
_ret = _loop3(
|
|
597
|
+
for (var _i3 = 0; _i3 < MGlines.length; _i3++) {
|
|
598
|
+
_ret = _loop3(_i3);
|
|
523
599
|
if (_ret === 0) break;
|
|
524
600
|
if (_ret === 1) continue;
|
|
525
601
|
}
|
|
@@ -608,11 +684,12 @@ function getTrimmedContourLineSegs(lineSegs, otherLines, cnt) {
|
|
|
608
684
|
};
|
|
609
685
|
var bContourSeg = true;
|
|
610
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;
|
|
611
688
|
var destLine = {
|
|
612
|
-
x1: otherLines[j][0].x,
|
|
613
|
-
y1: otherLines[j][0].y,
|
|
614
|
-
x2: otherLines[j][1].x,
|
|
615
|
-
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
|
|
616
693
|
};
|
|
617
694
|
var rst = _export.GeometryUtils.relationshipOfTwoOverlappedLines(srcLine, destLine);
|
|
618
695
|
if (rst.result == _constants.OVERLAP_SAME || rst.result == _constants.OVERLAP_INCLUDED) {
|
|
@@ -887,4 +964,381 @@ function createMonldingGroup(oldMG, layer, molding, catalog) {
|
|
|
887
964
|
newMG.lines.reverse();
|
|
888
965
|
newMG = getMDPoints(newMG);
|
|
889
966
|
return newMG;
|
|
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
|
+
}
|
|
1113
|
+
function getMoldingDataOfScene(layer, catalog, doorStyle) {
|
|
1114
|
+
var moldingData = [];
|
|
1115
|
+
var items = layer.items.toArray();
|
|
1116
|
+
var moldings = [];
|
|
1117
|
+
// get all moldings info
|
|
1118
|
+
items.forEach(function (itemCat) {
|
|
1119
|
+
var _itemCat$molding;
|
|
1120
|
+
itemCat === null || itemCat === void 0 || (_itemCat$molding = itemCat.molding) === null || _itemCat$molding === void 0 || _itemCat$molding.forEach(function (molding) {
|
|
1121
|
+
if (!moldings.some(function (m) {
|
|
1122
|
+
return m.name === molding.name;
|
|
1123
|
+
})) moldings.push(molding);
|
|
1124
|
+
});
|
|
1125
|
+
});
|
|
1126
|
+
|
|
1127
|
+
// calc normal molding
|
|
1128
|
+
moldings.forEach(function (molding) {
|
|
1129
|
+
var itemGroups = [];
|
|
1130
|
+
var temp_items = [];
|
|
1131
|
+
items.forEach(function (item) {
|
|
1132
|
+
if (item.molding.some(function (mol) {
|
|
1133
|
+
return mol.itemID === molding.itemID;
|
|
1134
|
+
}) && isEnableItemForMolding(layer, item)) {
|
|
1135
|
+
temp_items.push(item);
|
|
1136
|
+
}
|
|
1137
|
+
});
|
|
1138
|
+
if (temp_items.length) {
|
|
1139
|
+
while (temp_items.length > 0) {
|
|
1140
|
+
var itemGroup = [temp_items[0]];
|
|
1141
|
+
var _loop10 = function _loop10(_idx) {
|
|
1142
|
+
if (!itemGroup.some(function (it) {
|
|
1143
|
+
return it.id === temp_items[_idx].id;
|
|
1144
|
+
}) && isItemSnappedGroup(temp_items[_idx], itemGroup)) {
|
|
1145
|
+
itemGroup.push(temp_items[_idx]);
|
|
1146
|
+
_idx = 0;
|
|
1147
|
+
}
|
|
1148
|
+
idx = _idx;
|
|
1149
|
+
};
|
|
1150
|
+
for (var idx = 0; idx < temp_items.length; idx++) {
|
|
1151
|
+
_loop10(idx);
|
|
1152
|
+
}
|
|
1153
|
+
itemGroup.forEach(function (item) {
|
|
1154
|
+
var index = temp_items.findIndex(function (it) {
|
|
1155
|
+
return it.id === item.id;
|
|
1156
|
+
});
|
|
1157
|
+
if (index > -1) {
|
|
1158
|
+
temp_items.splice(index, 1);
|
|
1159
|
+
}
|
|
1160
|
+
});
|
|
1161
|
+
itemGroups.push(itemGroup);
|
|
1162
|
+
}
|
|
1163
|
+
var molding_totalLength = 0;
|
|
1164
|
+
itemGroups.forEach(function (itemgroup) {
|
|
1165
|
+
var allLineRects = _export.GeometryUtils.buildRectFromLines(layer, _export.GeometryUtils.getAllLines(layer));
|
|
1166
|
+
var items = (0, _toConsumableArray2["default"])(itemgroup);
|
|
1167
|
+
var MGlines = getLinesOfItem(items[0], allLineRects, catalog);
|
|
1168
|
+
items = sortItemsByDistance(items, items[0]);
|
|
1169
|
+
var _loop11 = function _loop11() {
|
|
1170
|
+
var itemLines = getLinesOfItem(items[i], allLineRects, catalog);
|
|
1171
|
+
var temp_MGLines = [];
|
|
1172
|
+
MGlines.forEach(function (line) {
|
|
1173
|
+
var idx = itemLines.findIndex(function (itemLine) {
|
|
1174
|
+
return isLinesOverlapped(line, itemLine);
|
|
1175
|
+
});
|
|
1176
|
+
var curItemLine = itemLines[idx];
|
|
1177
|
+
if (idx > -1) {
|
|
1178
|
+
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]))) {
|
|
1179
|
+
var MGLine = mergeOverlappedLines(line, curItemLine);
|
|
1180
|
+
temp_MGLines.push(MGLine);
|
|
1181
|
+
}
|
|
1182
|
+
itemLines.splice(idx, 1);
|
|
1183
|
+
} else {
|
|
1184
|
+
temp_MGLines.push(line);
|
|
1185
|
+
}
|
|
1186
|
+
});
|
|
1187
|
+
itemLines.forEach(function (itemLine) {
|
|
1188
|
+
return temp_MGLines.push(itemLine);
|
|
1189
|
+
});
|
|
1190
|
+
MGlines = [].concat(temp_MGLines);
|
|
1191
|
+
};
|
|
1192
|
+
for (var i = 1; i < items.length; i++) {
|
|
1193
|
+
_loop11();
|
|
1194
|
+
}
|
|
1195
|
+
MGlines.forEach(function (line) {
|
|
1196
|
+
molding_totalLength += _export.GeometryUtils.verticesDistance(line[0], line[1]);
|
|
1197
|
+
});
|
|
1198
|
+
});
|
|
1199
|
+
molding_totalLength = (0, _convertUnitsLite.convert)(molding_totalLength).from('cm').to('in');
|
|
1200
|
+
moldingData.push(_objectSpread(_objectSpread({}, molding), {}, {
|
|
1201
|
+
doorStyle: doorStyle,
|
|
1202
|
+
count: Math.ceil(molding_totalLength * 1.1 / 96)
|
|
1203
|
+
}));
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
|
|
1207
|
+
// calc toe kick molding
|
|
1208
|
+
var tmp = [];
|
|
1209
|
+
items.forEach(function (item) {
|
|
1210
|
+
if (item.category === 'cabinet' && !item.cabinet_category.toLowerCase().includes('microwave')) {
|
|
1211
|
+
tmp.push(item);
|
|
1212
|
+
}
|
|
1213
|
+
});
|
|
1214
|
+
var tmpMoldingData = [];
|
|
1215
|
+
var toedoorStyles = [];
|
|
1216
|
+
tmp.map(function (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))) {
|
|
1219
|
+
var w = item.properties.get('width').get('_length');
|
|
1220
|
+
var wUnit = item.properties.get('width').get('_unit') || 'cm';
|
|
1221
|
+
w = (0, _convertUnitsLite.convert)(w / 2).from(wUnit).to('cm');
|
|
1222
|
+
var h = item.properties.get('depth').get('_length');
|
|
1223
|
+
var hUnit = item.properties.get('depth').get('_unit') || 'cm';
|
|
1224
|
+
h = (0, _convertUnitsLite.convert)(h / 2).from(hUnit).to('cm');
|
|
1225
|
+
var outline = null;
|
|
1226
|
+
var element = catalog.elements[item.get('type')];
|
|
1227
|
+
if (!element) element = catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(item.get('type'))];
|
|
1228
|
+
outline = element.info.outline;
|
|
1229
|
+
var len = 0;
|
|
1230
|
+
if (outline) {
|
|
1231
|
+
// Extract Points from `outline`
|
|
1232
|
+
var outlinePaths = outline.paths;
|
|
1233
|
+
var outlineWidth = outline.svgWidth;
|
|
1234
|
+
var outlineHeight = outline.svgHeight;
|
|
1235
|
+
var outlinePoints = []; // Hold Points Of SVG
|
|
1236
|
+
var _iterator5 = _createForOfIteratorHelper(outlinePaths),
|
|
1237
|
+
_step5;
|
|
1238
|
+
try {
|
|
1239
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
1240
|
+
var path = _step5.value;
|
|
1241
|
+
var _iterator6 = _createForOfIteratorHelper(path.subPaths),
|
|
1242
|
+
_step6;
|
|
1243
|
+
try {
|
|
1244
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
1245
|
+
var subPath = _step6.value;
|
|
1246
|
+
outlinePoints = outlinePoints.concat(subPath.getPoints());
|
|
1247
|
+
}
|
|
1248
|
+
} catch (err) {
|
|
1249
|
+
_iterator6.e(err);
|
|
1250
|
+
} finally {
|
|
1251
|
+
_iterator6.f();
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
} catch (err) {
|
|
1255
|
+
_iterator5.e(err);
|
|
1256
|
+
} finally {
|
|
1257
|
+
_iterator5.f();
|
|
1258
|
+
}
|
|
1259
|
+
var maxX = outlinePoints[0].x,
|
|
1260
|
+
minX = outlinePoints[0].x;
|
|
1261
|
+
var maxY = outlinePoints[0].y,
|
|
1262
|
+
minY = outlinePoints[0].y;
|
|
1263
|
+
outlinePoints.forEach(function (point) {
|
|
1264
|
+
if (point.x > maxX) {
|
|
1265
|
+
maxX = point.x;
|
|
1266
|
+
}
|
|
1267
|
+
if (point.x < minX) {
|
|
1268
|
+
minX = point.x;
|
|
1269
|
+
}
|
|
1270
|
+
if (point.y > maxY) {
|
|
1271
|
+
maxY = point.y;
|
|
1272
|
+
}
|
|
1273
|
+
if (point.y < minY) {
|
|
1274
|
+
minY = point.y;
|
|
1275
|
+
}
|
|
1276
|
+
});
|
|
1277
|
+
outlinePoints.forEach(function (point) {
|
|
1278
|
+
if (_export.GeometryUtils.isPointInRect([{
|
|
1279
|
+
x: minX,
|
|
1280
|
+
y: minY
|
|
1281
|
+
}, {
|
|
1282
|
+
x: minX,
|
|
1283
|
+
y: maxY
|
|
1284
|
+
}, {
|
|
1285
|
+
x: maxX,
|
|
1286
|
+
y: maxY
|
|
1287
|
+
}, {
|
|
1288
|
+
x: maxX,
|
|
1289
|
+
y: minY
|
|
1290
|
+
}], point)) {
|
|
1291
|
+
if (point.x > 10) len += (point.x / outlineWidth - 0.5) * w * 2 + h * 2 - (point.y / outlineHeight - 0.5) * h * 2;
|
|
1292
|
+
}
|
|
1293
|
+
});
|
|
1294
|
+
len = (0, _convertUnitsLite.convert)(len).from('cm').to('in');
|
|
1295
|
+
} else {
|
|
1296
|
+
w = (0, _convertUnitsLite.convert)(w * 2).from('cm').to('in');
|
|
1297
|
+
len += w;
|
|
1298
|
+
}
|
|
1299
|
+
var doorIndex = toedoorStyles.findIndex(function (a) {
|
|
1300
|
+
var iDS = item === null || item === void 0 ? void 0 : item.doorStyle;
|
|
1301
|
+
if (!iDS) return false;
|
|
1302
|
+
if (!iDS.hasOwnProperty('id')) {
|
|
1303
|
+
iDS = iDS.toJS();
|
|
1304
|
+
}
|
|
1305
|
+
return a.doorStyle.id === iDS.id && (0, _utils.isEqualInstallationType)(a.doorStyle, iDS);
|
|
1306
|
+
});
|
|
1307
|
+
if (doorIndex > -1) {
|
|
1308
|
+
toedoorStyles[doorIndex].totalLength += len;
|
|
1309
|
+
} else {
|
|
1310
|
+
toedoorStyles.push({
|
|
1311
|
+
doorStyle: item.doorStyle.hasOwnProperty('id') ? item.doorStyle : item.doorStyle && item.doorStyle.toJS(),
|
|
1312
|
+
totalLength: len
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
});
|
|
1317
|
+
toedoorStyles.forEach(function (doorStyle) {
|
|
1318
|
+
var skuName = (0, _utils.getToeKickSKU)(doorStyle.doorStyle, catalog);
|
|
1319
|
+
var thumbnail = skuName ? skuName : '';
|
|
1320
|
+
// moldings.forEach(molding => {
|
|
1321
|
+
// if (
|
|
1322
|
+
// molding.name ===
|
|
1323
|
+
// getToeKickSKU(
|
|
1324
|
+
// doorStyle.doorStyle,
|
|
1325
|
+
// catalog,
|
|
1326
|
+
// true
|
|
1327
|
+
// )
|
|
1328
|
+
// )
|
|
1329
|
+
// thumbnail = molding.thumbnail;
|
|
1330
|
+
// });
|
|
1331
|
+
|
|
1332
|
+
doorStyle.totalLength && tmpMoldingData.push({
|
|
1333
|
+
name: _constants.TOE_KICK_MOLDING,
|
|
1334
|
+
sku: (0, _utils.getToeKickSKU)(doorStyle.doorStyle, catalog),
|
|
1335
|
+
thumbnail: thumbnail,
|
|
1336
|
+
category: 'molding',
|
|
1337
|
+
type: 'cabinet',
|
|
1338
|
+
doorStyle: doorStyle.doorStyle,
|
|
1339
|
+
count: Math.ceil(doorStyle.totalLength * 1.1 / 96)
|
|
1340
|
+
});
|
|
1341
|
+
});
|
|
1342
|
+
if (tmpMoldingData.length > 0) moldingData = [].concat((0, _toConsumableArray2["default"])(moldingData), tmpMoldingData);
|
|
1343
|
+
return moldingData;
|
|
890
1344
|
}
|