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/es/utils/molding.js
CHANGED
|
@@ -5,11 +5,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
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; } } }; }
|
|
6
6
|
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; } }
|
|
7
7
|
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; }
|
|
8
|
-
import { BASE_CABINET_LAYOUTPOS, BOTTOM_MOLDING_LOCATION, EPSILON, MIDDLE_MOLDING_LOCATION, MOLDING_LOCATIONS, OVERLAP_INCLUDED, OVERLAP_LINK, OVERLAP_SAME, OVERLAP_SOME, TALL_CABINET_LAYOUTPOS, TOP_MOLDING_LOCATION, WALL_CABINET_LAYOUTPOS } from "../constants";
|
|
8
|
+
import { BASE_CABINET_LAYOUTPOS, BOTTOM_MOLDING_LOCATION, EPSILON, ITEM_TYPE, MIDDLE_MOLDING_LOCATION, MOLDING_LOCATIONS, OVERLAP_INCLUDED, OVERLAP_LINK, OVERLAP_SAME, OVERLAP_SOME, TALL_CABINET_LAYOUTPOS, TOE_KICK_MOLDING, TOP_MOLDING_LOCATION, WALL_CABINET_LAYOUTPOS } from "../constants";
|
|
9
9
|
import * as Three from 'three';
|
|
10
10
|
import { convert } from "./convert-units-lite";
|
|
11
11
|
import IDBroker from "./id-broker";
|
|
12
|
-
import { returnReplaceableDeepSearchType } from "../components/viewer2d/utils";
|
|
12
|
+
import { getToeKickSKU, isEqualInstallationType, returnReplaceableDeepSearchType } from "../components/viewer2d/utils";
|
|
13
13
|
import { GeometryUtils } from "./export";
|
|
14
14
|
import { isEmpty } from "./helper";
|
|
15
15
|
export function getItemRect(item) {
|
|
@@ -62,6 +62,10 @@ export function isEnableItemForMolding(layer, selItem) {
|
|
|
62
62
|
// check this item is enable for specified molding
|
|
63
63
|
else return result && hasMoldingLayout(molding, selItem.layoutpos);
|
|
64
64
|
}
|
|
65
|
+
export function isAttachedWall(layer, selItem) {
|
|
66
|
+
var allLineRects = GeometryUtils.buildRectFromLines(layer, GeometryUtils.getAllLines(layer));
|
|
67
|
+
return GeometryUtils.isSnappedLine(getItemRect(selItem), allLineRects);
|
|
68
|
+
}
|
|
65
69
|
|
|
66
70
|
/**
|
|
67
71
|
* Check two line segments are overlap. The direction of the two line segments must be opposite.
|
|
@@ -300,6 +304,74 @@ export function getLinesOfItem(item, allLineRects, catalog) {
|
|
|
300
304
|
}
|
|
301
305
|
return lines;
|
|
302
306
|
}
|
|
307
|
+
export function getLinesOfItem2(item, allLineRects, catalog) {
|
|
308
|
+
var lines = [];
|
|
309
|
+
var outline = null;
|
|
310
|
+
var element = catalog.elements[item.get('type')];
|
|
311
|
+
if (!element) element = catalog.elements[returnReplaceableDeepSearchType(item.get('type'))];
|
|
312
|
+
// get edge lines
|
|
313
|
+
var newWidth = item.properties.get('width').get('_length');
|
|
314
|
+
var wUnit = item.properties.get('width').get('_unit') || 'cm';
|
|
315
|
+
newWidth = convert(newWidth).from(wUnit).to('cm');
|
|
316
|
+
var newDepth = item.properties.get('depth').get('_length');
|
|
317
|
+
var hUnit = item.properties.get('depth').get('_unit') || 'cm';
|
|
318
|
+
newDepth = convert(newDepth).from(hUnit).to('cm');
|
|
319
|
+
if (item) {
|
|
320
|
+
// Get Outline Data of Selected Item
|
|
321
|
+
outline = element.info.outline;
|
|
322
|
+
if (outline) {
|
|
323
|
+
// Extract Points from `outline`
|
|
324
|
+
var outlinePaths = outline.paths;
|
|
325
|
+
var outlineWidth = outline.svgWidth;
|
|
326
|
+
var outlineHeight = outline.svgHeight;
|
|
327
|
+
var outlinePoints = []; // Hold Points Of SVG
|
|
328
|
+
var _iterator3 = _createForOfIteratorHelper(outlinePaths),
|
|
329
|
+
_step3;
|
|
330
|
+
try {
|
|
331
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
332
|
+
var path = _step3.value;
|
|
333
|
+
var _iterator4 = _createForOfIteratorHelper(path.subPaths),
|
|
334
|
+
_step4;
|
|
335
|
+
try {
|
|
336
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
337
|
+
var subPath = _step4.value;
|
|
338
|
+
outlinePoints = outlinePoints.concat(subPath.getPoints());
|
|
339
|
+
}
|
|
340
|
+
} catch (err) {
|
|
341
|
+
_iterator4.e(err);
|
|
342
|
+
} finally {
|
|
343
|
+
_iterator4.f();
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
} catch (err) {
|
|
347
|
+
_iterator3.e(err);
|
|
348
|
+
} finally {
|
|
349
|
+
_iterator3.f();
|
|
350
|
+
}
|
|
351
|
+
outline.reverse && outlinePoints.reverse();
|
|
352
|
+
for (var i = 0; i < outlinePoints.length - 1; i++) {
|
|
353
|
+
lines.push([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), 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.acquireID()]);
|
|
354
|
+
}
|
|
355
|
+
} else {
|
|
356
|
+
var pos = [[-1, -1], [1, -1], [1, 1], [-1, 1]];
|
|
357
|
+
for (var _i2 = 0; _i2 < 4; _i2++) {
|
|
358
|
+
lines.push([GeometryUtils.rotatePointAroundPoint(pos[_i2][0] * newWidth / 2 + item.x, pos[_i2][1] * newDepth / 2 + item.y, item.x, item.y, item.rotation), 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.acquireID()]);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
lines = lines.filter(function (line) {
|
|
363
|
+
return !GeometryUtils.isSnappedLine({
|
|
364
|
+
rect: [{
|
|
365
|
+
x: 0,
|
|
366
|
+
y: 0
|
|
367
|
+
}, {
|
|
368
|
+
x: 0,
|
|
369
|
+
y: 0
|
|
370
|
+
}, line[0], line[1]]
|
|
371
|
+
}, allLineRects);
|
|
372
|
+
});
|
|
373
|
+
return lines;
|
|
374
|
+
}
|
|
303
375
|
function isParallelLines(line1, line2) {
|
|
304
376
|
var isParallel = false;
|
|
305
377
|
if (Math.abs(line1[0].y - line1[1].y) <= EPSILON && Math.abs(line2[0].y - line2[1].y) <= EPSILON) isParallel = true;
|
|
@@ -481,20 +553,20 @@ export function getLinesFromItems2(moldingGroup, layer, catalog) {
|
|
|
481
553
|
// merge the collinear linked lines to one line
|
|
482
554
|
var newMGlines = [];
|
|
483
555
|
var filteredMGlines = MGlines;
|
|
484
|
-
var _loop3 = function _loop3(
|
|
556
|
+
var _loop3 = function _loop3(_i3) {
|
|
485
557
|
if (filteredMGlines.length < 1) return 0; // break
|
|
486
558
|
if (!filteredMGlines.some(function (v) {
|
|
487
|
-
return v[2] === MGlines[
|
|
559
|
+
return v[2] === MGlines[_i3][2];
|
|
488
560
|
})) return 1; // continue
|
|
489
|
-
var mergedResult = getMergedLine(MGlines[
|
|
561
|
+
var mergedResult = getMergedLine(MGlines[_i3], filteredMGlines, 0);
|
|
490
562
|
if (mergedResult) {
|
|
491
563
|
newMGlines.push(mergedResult.mergedLine);
|
|
492
564
|
filteredMGlines = mergedResult.filteredMGlines;
|
|
493
565
|
}
|
|
494
566
|
},
|
|
495
567
|
_ret;
|
|
496
|
-
for (var
|
|
497
|
-
_ret = _loop3(
|
|
568
|
+
for (var _i3 = 0; _i3 < MGlines.length; _i3++) {
|
|
569
|
+
_ret = _loop3(_i3);
|
|
498
570
|
if (_ret === 0) break;
|
|
499
571
|
if (_ret === 1) continue;
|
|
500
572
|
}
|
|
@@ -583,11 +655,12 @@ function getTrimmedContourLineSegs(lineSegs, otherLines, cnt) {
|
|
|
583
655
|
};
|
|
584
656
|
var bContourSeg = true;
|
|
585
657
|
var _loop6 = function _loop6(j) {
|
|
658
|
+
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;
|
|
586
659
|
var destLine = {
|
|
587
|
-
x1: otherLines[j][0].x,
|
|
588
|
-
y1: otherLines[j][0].y,
|
|
589
|
-
x2: otherLines[j][1].x,
|
|
590
|
-
y2: otherLines[j][1].y
|
|
660
|
+
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,
|
|
661
|
+
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,
|
|
662
|
+
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,
|
|
663
|
+
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
|
|
591
664
|
};
|
|
592
665
|
var rst = GeometryUtils.relationshipOfTwoOverlappedLines(srcLine, destLine);
|
|
593
666
|
if (rst.result == OVERLAP_SAME || rst.result == OVERLAP_INCLUDED) {
|
|
@@ -862,4 +935,381 @@ export function createMonldingGroup(oldMG, layer, molding, catalog) {
|
|
|
862
935
|
newMG.lines.reverse();
|
|
863
936
|
newMG = getMDPoints(newMG);
|
|
864
937
|
return newMG;
|
|
938
|
+
}
|
|
939
|
+
export function getMoldingDataOfScene2(layer, catalog, doorStyle) {
|
|
940
|
+
var moldingData = [];
|
|
941
|
+
var items = layer.items.toArray();
|
|
942
|
+
var allLineRects = GeometryUtils.buildRectFromLines(layer, GeometryUtils.getAllLines(layer));
|
|
943
|
+
|
|
944
|
+
// get all molding line segments
|
|
945
|
+
var moldingLines = [];
|
|
946
|
+
items.forEach(function (item) {
|
|
947
|
+
if (item.category === ITEM_TYPE.CABINET) {
|
|
948
|
+
var _item$molding;
|
|
949
|
+
var MGlines = getLinesOfItem2(item, allLineRects, catalog); // exclude overlayed to wall
|
|
950
|
+
// z position of molding line
|
|
951
|
+
var z = item.properties.get('altitude').get('_length');
|
|
952
|
+
var zUnit = item.properties.get('altitude').get('_unit') || 'cm';
|
|
953
|
+
z = convert(z).from(zUnit).to('cm');
|
|
954
|
+
var h = item.properties.get('height').get('_length');
|
|
955
|
+
var hUnit = item.properties.get('height').get('_unit') || 'cm';
|
|
956
|
+
h = convert(h).from(hUnit).to('cm');
|
|
957
|
+
if (!isEmpty(item.molding) && isEnableItemForMolding(layer, item)) {
|
|
958
|
+
// calc normal molding line
|
|
959
|
+
item === null || item === void 0 || item.molding.forEach(function (molding) {
|
|
960
|
+
var lineZ = z;
|
|
961
|
+
switch (molding.location_type) {
|
|
962
|
+
case TOP_MOLDING_LOCATION:
|
|
963
|
+
lineZ = z + h;
|
|
964
|
+
break;
|
|
965
|
+
case MIDDLE_MOLDING_LOCATION:
|
|
966
|
+
lineZ = z + h / 2;
|
|
967
|
+
break;
|
|
968
|
+
}
|
|
969
|
+
MGlines === null || MGlines === void 0 || MGlines.forEach(function (line) {
|
|
970
|
+
return moldingLines.push({
|
|
971
|
+
molding: _objectSpread({}, molding),
|
|
972
|
+
doorStyle: item.doorStyle.hasOwnProperty('id') ? item.doorStyle : !isEmpty(item.doorStyle) && item.doorStyle.toJS(),
|
|
973
|
+
line: line,
|
|
974
|
+
z: lineZ
|
|
975
|
+
});
|
|
976
|
+
});
|
|
977
|
+
});
|
|
978
|
+
} else if (
|
|
979
|
+
// calc toe kick molding line
|
|
980
|
+
item.layoutpos === BASE_CABINET_LAYOUTPOS && (isEmpty(item.molding) || ((_item$molding = item.molding) === null || _item$molding === void 0 ? void 0 : _item$molding.length) < 1 || !isEnableItemForMolding(layer, item))) {
|
|
981
|
+
var skuName = getToeKickSKU(item.doorStyle, catalog);
|
|
982
|
+
var thumbnail = skuName ? skuName : '';
|
|
983
|
+
MGlines === null || MGlines === void 0 || MGlines.forEach(function (line) {
|
|
984
|
+
return moldingLines.push({
|
|
985
|
+
molding: {
|
|
986
|
+
name: TOE_KICK_MOLDING,
|
|
987
|
+
sku: getToeKickSKU(item.doorStyle, catalog),
|
|
988
|
+
thumbnail: thumbnail,
|
|
989
|
+
category: 'molding',
|
|
990
|
+
type: 'cabinet'
|
|
991
|
+
},
|
|
992
|
+
doorStyle: item.doorStyle.hasOwnProperty('id') ? item.doorStyle : !isEmpty(item.doorStyle) && item.doorStyle.toJS(),
|
|
993
|
+
line: line,
|
|
994
|
+
z: z
|
|
995
|
+
});
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
});
|
|
1000
|
+
|
|
1001
|
+
// filter the real molding line segments
|
|
1002
|
+
var removeLineIds = []; // remove the line that fully overlapped to other line
|
|
1003
|
+
var newLines = []; // new countour line segment that except the overlapped part
|
|
1004
|
+
var _loop9 = function _loop9(i) {
|
|
1005
|
+
var srcLine = {
|
|
1006
|
+
x1: moldingLines[i].line[0].x,
|
|
1007
|
+
y1: moldingLines[i].line[0].y,
|
|
1008
|
+
x2: moldingLines[i].line[1].x,
|
|
1009
|
+
y2: moldingLines[i].line[1].y
|
|
1010
|
+
};
|
|
1011
|
+
var _loop1 = function _loop1(j) {
|
|
1012
|
+
if (i === j) return 0; // continue
|
|
1013
|
+
if (Math.abs(moldingLines[i].z - moldingLines[j].z) > EPSILON) return 0; // continue
|
|
1014
|
+
var destLine = {
|
|
1015
|
+
x1: moldingLines[j].line[0].x,
|
|
1016
|
+
y1: moldingLines[j].line[0].y,
|
|
1017
|
+
x2: moldingLines[j].line[1].x,
|
|
1018
|
+
y2: moldingLines[j].line[1].y
|
|
1019
|
+
};
|
|
1020
|
+
var rst = GeometryUtils.relationshipOfTwoOverlappedLines(srcLine, destLine);
|
|
1021
|
+
if (rst.result === OVERLAP_SAME || rst.result === OVERLAP_INCLUDED) {
|
|
1022
|
+
removeLineIds.push(i);
|
|
1023
|
+
return 1; // break
|
|
1024
|
+
} else if (rst.result === OVERLAP_SOME) {
|
|
1025
|
+
removeLineIds.push(i);
|
|
1026
|
+
var lineSegs = getTrimmedContourLineSegs(rst.trimmedSegs, moldingLines.filter(function (v, idx) {
|
|
1027
|
+
return idx !== i && idx !== j && Math.abs(v.z - moldingLines[i].z) < EPSILON;
|
|
1028
|
+
}), 0);
|
|
1029
|
+
if (lineSegs.length > 0) {
|
|
1030
|
+
lineSegs.forEach(function (ls) {
|
|
1031
|
+
return newLines.push({
|
|
1032
|
+
molding: _objectSpread({}, moldingLines[i].molding),
|
|
1033
|
+
doorStyle: moldingLines[i].doorStyle,
|
|
1034
|
+
line: _toConsumableArray(ls),
|
|
1035
|
+
z: moldingLines[i].z
|
|
1036
|
+
});
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
1039
|
+
return 1; // break
|
|
1040
|
+
}
|
|
1041
|
+
},
|
|
1042
|
+
_ret4;
|
|
1043
|
+
for (var j = 0; j < moldingLines.length; j++) {
|
|
1044
|
+
_ret4 = _loop1(j);
|
|
1045
|
+
if (_ret4 === 0) continue;
|
|
1046
|
+
if (_ret4 === 1) break;
|
|
1047
|
+
}
|
|
1048
|
+
};
|
|
1049
|
+
for (var i = 0; i < moldingLines.length; i++) {
|
|
1050
|
+
_loop9(i);
|
|
1051
|
+
}
|
|
1052
|
+
moldingLines = moldingLines.filter(function (line, idx) {
|
|
1053
|
+
return !removeLineIds.some(function (id) {
|
|
1054
|
+
return idx === id;
|
|
1055
|
+
});
|
|
1056
|
+
});
|
|
1057
|
+
if (newLines.length > 0) moldingLines = [].concat(_toConsumableArray(moldingLines), newLines);
|
|
1058
|
+
// console.log('moldingLines: ', moldingLines);
|
|
1059
|
+
|
|
1060
|
+
// make molding data with sorting molding & doorStyle
|
|
1061
|
+
var _loop0 = function _loop0() {
|
|
1062
|
+
var ml = moldingLines[k];
|
|
1063
|
+
var mlLength = convert(GeometryUtils.verticesDistance(ml.line[0], ml.line[1])).from('cm').to('in');
|
|
1064
|
+
var idx = moldingData.findIndex(function (v) {
|
|
1065
|
+
var _ml$molding, _v$doorStyle, _ml$doorStyle;
|
|
1066
|
+
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);
|
|
1067
|
+
});
|
|
1068
|
+
if (idx < 0) moldingData.push(_objectSpread(_objectSpread({}, ml.molding), {}, {
|
|
1069
|
+
doorStyle: ml.doorStyle,
|
|
1070
|
+
totalLength: mlLength,
|
|
1071
|
+
count: Math.ceil(mlLength * 1.1 / 96)
|
|
1072
|
+
}));else {
|
|
1073
|
+
moldingData[idx].totalLength += mlLength;
|
|
1074
|
+
moldingData[idx].count = Math.ceil(moldingData[idx].totalLength * 1.1 / 96);
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
for (var k = 0; k < moldingLines.length; k++) {
|
|
1078
|
+
_loop0();
|
|
1079
|
+
}
|
|
1080
|
+
// console.log('moldingData: ', moldingData);
|
|
1081
|
+
|
|
1082
|
+
return moldingData;
|
|
1083
|
+
}
|
|
1084
|
+
export function getMoldingDataOfScene(layer, catalog, doorStyle) {
|
|
1085
|
+
var moldingData = [];
|
|
1086
|
+
var items = layer.items.toArray();
|
|
1087
|
+
var moldings = [];
|
|
1088
|
+
// get all moldings info
|
|
1089
|
+
items.forEach(function (itemCat) {
|
|
1090
|
+
var _itemCat$molding;
|
|
1091
|
+
itemCat === null || itemCat === void 0 || (_itemCat$molding = itemCat.molding) === null || _itemCat$molding === void 0 || _itemCat$molding.forEach(function (molding) {
|
|
1092
|
+
if (!moldings.some(function (m) {
|
|
1093
|
+
return m.name === molding.name;
|
|
1094
|
+
})) moldings.push(molding);
|
|
1095
|
+
});
|
|
1096
|
+
});
|
|
1097
|
+
|
|
1098
|
+
// calc normal molding
|
|
1099
|
+
moldings.forEach(function (molding) {
|
|
1100
|
+
var itemGroups = [];
|
|
1101
|
+
var temp_items = [];
|
|
1102
|
+
items.forEach(function (item) {
|
|
1103
|
+
if (item.molding.some(function (mol) {
|
|
1104
|
+
return mol.itemID === molding.itemID;
|
|
1105
|
+
}) && isEnableItemForMolding(layer, item)) {
|
|
1106
|
+
temp_items.push(item);
|
|
1107
|
+
}
|
|
1108
|
+
});
|
|
1109
|
+
if (temp_items.length) {
|
|
1110
|
+
while (temp_items.length > 0) {
|
|
1111
|
+
var itemGroup = [temp_items[0]];
|
|
1112
|
+
var _loop10 = function _loop10(_idx) {
|
|
1113
|
+
if (!itemGroup.some(function (it) {
|
|
1114
|
+
return it.id === temp_items[_idx].id;
|
|
1115
|
+
}) && isItemSnappedGroup(temp_items[_idx], itemGroup)) {
|
|
1116
|
+
itemGroup.push(temp_items[_idx]);
|
|
1117
|
+
_idx = 0;
|
|
1118
|
+
}
|
|
1119
|
+
idx = _idx;
|
|
1120
|
+
};
|
|
1121
|
+
for (var idx = 0; idx < temp_items.length; idx++) {
|
|
1122
|
+
_loop10(idx);
|
|
1123
|
+
}
|
|
1124
|
+
itemGroup.forEach(function (item) {
|
|
1125
|
+
var index = temp_items.findIndex(function (it) {
|
|
1126
|
+
return it.id === item.id;
|
|
1127
|
+
});
|
|
1128
|
+
if (index > -1) {
|
|
1129
|
+
temp_items.splice(index, 1);
|
|
1130
|
+
}
|
|
1131
|
+
});
|
|
1132
|
+
itemGroups.push(itemGroup);
|
|
1133
|
+
}
|
|
1134
|
+
var molding_totalLength = 0;
|
|
1135
|
+
itemGroups.forEach(function (itemgroup) {
|
|
1136
|
+
var allLineRects = GeometryUtils.buildRectFromLines(layer, GeometryUtils.getAllLines(layer));
|
|
1137
|
+
var items = _toConsumableArray(itemgroup);
|
|
1138
|
+
var MGlines = getLinesOfItem(items[0], allLineRects, catalog);
|
|
1139
|
+
items = sortItemsByDistance(items, items[0]);
|
|
1140
|
+
var _loop11 = function _loop11() {
|
|
1141
|
+
var itemLines = getLinesOfItem(items[i], allLineRects, catalog);
|
|
1142
|
+
var temp_MGLines = [];
|
|
1143
|
+
MGlines.forEach(function (line) {
|
|
1144
|
+
var idx = itemLines.findIndex(function (itemLine) {
|
|
1145
|
+
return isLinesOverlapped(line, itemLine);
|
|
1146
|
+
});
|
|
1147
|
+
var curItemLine = itemLines[idx];
|
|
1148
|
+
if (idx > -1) {
|
|
1149
|
+
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]))) {
|
|
1150
|
+
var MGLine = mergeOverlappedLines(line, curItemLine);
|
|
1151
|
+
temp_MGLines.push(MGLine);
|
|
1152
|
+
}
|
|
1153
|
+
itemLines.splice(idx, 1);
|
|
1154
|
+
} else {
|
|
1155
|
+
temp_MGLines.push(line);
|
|
1156
|
+
}
|
|
1157
|
+
});
|
|
1158
|
+
itemLines.forEach(function (itemLine) {
|
|
1159
|
+
return temp_MGLines.push(itemLine);
|
|
1160
|
+
});
|
|
1161
|
+
MGlines = [].concat(temp_MGLines);
|
|
1162
|
+
};
|
|
1163
|
+
for (var i = 1; i < items.length; i++) {
|
|
1164
|
+
_loop11();
|
|
1165
|
+
}
|
|
1166
|
+
MGlines.forEach(function (line) {
|
|
1167
|
+
molding_totalLength += GeometryUtils.verticesDistance(line[0], line[1]);
|
|
1168
|
+
});
|
|
1169
|
+
});
|
|
1170
|
+
molding_totalLength = convert(molding_totalLength).from('cm').to('in');
|
|
1171
|
+
moldingData.push(_objectSpread(_objectSpread({}, molding), {}, {
|
|
1172
|
+
doorStyle: doorStyle,
|
|
1173
|
+
count: Math.ceil(molding_totalLength * 1.1 / 96)
|
|
1174
|
+
}));
|
|
1175
|
+
}
|
|
1176
|
+
});
|
|
1177
|
+
|
|
1178
|
+
// calc toe kick molding
|
|
1179
|
+
var tmp = [];
|
|
1180
|
+
items.forEach(function (item) {
|
|
1181
|
+
if (item.category === 'cabinet' && !item.cabinet_category.toLowerCase().includes('microwave')) {
|
|
1182
|
+
tmp.push(item);
|
|
1183
|
+
}
|
|
1184
|
+
});
|
|
1185
|
+
var tmpMoldingData = [];
|
|
1186
|
+
var toedoorStyles = [];
|
|
1187
|
+
tmp.map(function (item) {
|
|
1188
|
+
var _item$molding2;
|
|
1189
|
+
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))) {
|
|
1190
|
+
var w = item.properties.get('width').get('_length');
|
|
1191
|
+
var wUnit = item.properties.get('width').get('_unit') || 'cm';
|
|
1192
|
+
w = convert(w / 2).from(wUnit).to('cm');
|
|
1193
|
+
var h = item.properties.get('depth').get('_length');
|
|
1194
|
+
var hUnit = item.properties.get('depth').get('_unit') || 'cm';
|
|
1195
|
+
h = convert(h / 2).from(hUnit).to('cm');
|
|
1196
|
+
var outline = null;
|
|
1197
|
+
var element = catalog.elements[item.get('type')];
|
|
1198
|
+
if (!element) element = catalog.elements[returnReplaceableDeepSearchType(item.get('type'))];
|
|
1199
|
+
outline = element.info.outline;
|
|
1200
|
+
var len = 0;
|
|
1201
|
+
if (outline) {
|
|
1202
|
+
// Extract Points from `outline`
|
|
1203
|
+
var outlinePaths = outline.paths;
|
|
1204
|
+
var outlineWidth = outline.svgWidth;
|
|
1205
|
+
var outlineHeight = outline.svgHeight;
|
|
1206
|
+
var outlinePoints = []; // Hold Points Of SVG
|
|
1207
|
+
var _iterator5 = _createForOfIteratorHelper(outlinePaths),
|
|
1208
|
+
_step5;
|
|
1209
|
+
try {
|
|
1210
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
1211
|
+
var path = _step5.value;
|
|
1212
|
+
var _iterator6 = _createForOfIteratorHelper(path.subPaths),
|
|
1213
|
+
_step6;
|
|
1214
|
+
try {
|
|
1215
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
1216
|
+
var subPath = _step6.value;
|
|
1217
|
+
outlinePoints = outlinePoints.concat(subPath.getPoints());
|
|
1218
|
+
}
|
|
1219
|
+
} catch (err) {
|
|
1220
|
+
_iterator6.e(err);
|
|
1221
|
+
} finally {
|
|
1222
|
+
_iterator6.f();
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
} catch (err) {
|
|
1226
|
+
_iterator5.e(err);
|
|
1227
|
+
} finally {
|
|
1228
|
+
_iterator5.f();
|
|
1229
|
+
}
|
|
1230
|
+
var maxX = outlinePoints[0].x,
|
|
1231
|
+
minX = outlinePoints[0].x;
|
|
1232
|
+
var maxY = outlinePoints[0].y,
|
|
1233
|
+
minY = outlinePoints[0].y;
|
|
1234
|
+
outlinePoints.forEach(function (point) {
|
|
1235
|
+
if (point.x > maxX) {
|
|
1236
|
+
maxX = point.x;
|
|
1237
|
+
}
|
|
1238
|
+
if (point.x < minX) {
|
|
1239
|
+
minX = point.x;
|
|
1240
|
+
}
|
|
1241
|
+
if (point.y > maxY) {
|
|
1242
|
+
maxY = point.y;
|
|
1243
|
+
}
|
|
1244
|
+
if (point.y < minY) {
|
|
1245
|
+
minY = point.y;
|
|
1246
|
+
}
|
|
1247
|
+
});
|
|
1248
|
+
outlinePoints.forEach(function (point) {
|
|
1249
|
+
if (GeometryUtils.isPointInRect([{
|
|
1250
|
+
x: minX,
|
|
1251
|
+
y: minY
|
|
1252
|
+
}, {
|
|
1253
|
+
x: minX,
|
|
1254
|
+
y: maxY
|
|
1255
|
+
}, {
|
|
1256
|
+
x: maxX,
|
|
1257
|
+
y: maxY
|
|
1258
|
+
}, {
|
|
1259
|
+
x: maxX,
|
|
1260
|
+
y: minY
|
|
1261
|
+
}], point)) {
|
|
1262
|
+
if (point.x > 10) len += (point.x / outlineWidth - 0.5) * w * 2 + h * 2 - (point.y / outlineHeight - 0.5) * h * 2;
|
|
1263
|
+
}
|
|
1264
|
+
});
|
|
1265
|
+
len = convert(len).from('cm').to('in');
|
|
1266
|
+
} else {
|
|
1267
|
+
w = convert(w * 2).from('cm').to('in');
|
|
1268
|
+
len += w;
|
|
1269
|
+
}
|
|
1270
|
+
var doorIndex = toedoorStyles.findIndex(function (a) {
|
|
1271
|
+
var iDS = item === null || item === void 0 ? void 0 : item.doorStyle;
|
|
1272
|
+
if (!iDS) return false;
|
|
1273
|
+
if (!iDS.hasOwnProperty('id')) {
|
|
1274
|
+
iDS = iDS.toJS();
|
|
1275
|
+
}
|
|
1276
|
+
return a.doorStyle.id === iDS.id && isEqualInstallationType(a.doorStyle, iDS);
|
|
1277
|
+
});
|
|
1278
|
+
if (doorIndex > -1) {
|
|
1279
|
+
toedoorStyles[doorIndex].totalLength += len;
|
|
1280
|
+
} else {
|
|
1281
|
+
toedoorStyles.push({
|
|
1282
|
+
doorStyle: item.doorStyle.hasOwnProperty('id') ? item.doorStyle : item.doorStyle && item.doorStyle.toJS(),
|
|
1283
|
+
totalLength: len
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
});
|
|
1288
|
+
toedoorStyles.forEach(function (doorStyle) {
|
|
1289
|
+
var skuName = getToeKickSKU(doorStyle.doorStyle, catalog);
|
|
1290
|
+
var thumbnail = skuName ? skuName : '';
|
|
1291
|
+
// moldings.forEach(molding => {
|
|
1292
|
+
// if (
|
|
1293
|
+
// molding.name ===
|
|
1294
|
+
// getToeKickSKU(
|
|
1295
|
+
// doorStyle.doorStyle,
|
|
1296
|
+
// catalog,
|
|
1297
|
+
// true
|
|
1298
|
+
// )
|
|
1299
|
+
// )
|
|
1300
|
+
// thumbnail = molding.thumbnail;
|
|
1301
|
+
// });
|
|
1302
|
+
|
|
1303
|
+
doorStyle.totalLength && tmpMoldingData.push({
|
|
1304
|
+
name: TOE_KICK_MOLDING,
|
|
1305
|
+
sku: getToeKickSKU(doorStyle.doorStyle, catalog),
|
|
1306
|
+
thumbnail: thumbnail,
|
|
1307
|
+
category: 'molding',
|
|
1308
|
+
type: 'cabinet',
|
|
1309
|
+
doorStyle: doorStyle.doorStyle,
|
|
1310
|
+
count: Math.ceil(doorStyle.totalLength * 1.1 / 96)
|
|
1311
|
+
});
|
|
1312
|
+
});
|
|
1313
|
+
if (tmpMoldingData.length > 0) moldingData = [].concat(_toConsumableArray(moldingData), tmpMoldingData);
|
|
1314
|
+
return moldingData;
|
|
865
1315
|
}
|