kitchen-simulator 4.0.0-react-18 → 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/README.md +3 -0
- package/es/AppContext.js +1 -1
- package/es/LiteKitchenConfigurator.js +156 -108
- package/es/LiteRenderer.js +159 -130
- package/es/actions/export.js +25 -12
- package/es/assets/gltf/door_sliding.bin +0 -0
- package/es/assets/img/png/helper/video_preview_start.png +0 -0
- package/es/assets/img/svg/bottombar/elevation.svg +12 -5
- package/es/catalog/catalog.js +21 -5
- package/es/catalog/holes/window-clear/planner-element.js +2 -2
- package/es/catalog/properties/export.js +21 -0
- package/es/catalog/properties/property-checkbox.js +68 -0
- package/es/catalog/properties/property-color.js +39 -0
- package/es/catalog/properties/property-enum.js +50 -0
- package/es/catalog/properties/property-hidden.js +19 -0
- package/es/catalog/properties/property-lenght-measure.js +100 -0
- package/es/catalog/properties/property-length-measure.js +84 -0
- package/es/catalog/properties/property-length-measure_hole.js +100 -0
- package/es/catalog/properties/property-number.js +48 -0
- package/es/catalog/properties/property-read-only.js +26 -0
- package/es/catalog/properties/property-string.js +48 -0
- package/es/catalog/properties/property-toggle.js +39 -0
- package/es/catalog/properties/shared-property-style.js +14 -0
- package/es/catalog/utils/exporter.js +1 -0
- package/es/catalog/utils/item-loader.js +17 -12
- package/es/class/hole.js +0 -2
- package/es/class/item.js +95 -69
- package/es/class/line.js +4 -8
- package/es/class/project.js +91 -80
- package/es/components/content.js +5 -2
- package/es/components/export.js +4 -6
- package/es/components/style/button.js +106 -0
- package/es/components/style/cancel-button.js +21 -0
- package/es/components/style/content-container.js +30 -0
- package/es/components/style/content-title.js +25 -0
- package/es/components/style/delete-button.js +24 -0
- package/es/components/style/export.js +28 -2
- package/es/components/style/form-block.js +20 -0
- package/es/components/style/form-color-input.js +26 -0
- package/es/components/style/form-label.js +22 -0
- package/es/components/style/form-number-input.js +11 -22
- package/es/components/style/form-number-input_2.js +200 -0
- package/es/components/style/form-select.js +19 -0
- package/es/components/style/form-slider.js +60 -0
- package/es/components/style/form-submit-button.js +25 -0
- package/es/components/style/form-text-input.js +69 -0
- package/es/components/viewer2d/group.js +5 -4
- package/es/components/viewer2d/item.js +41 -16
- package/es/components/viewer2d/layer.js +1 -1
- package/es/components/viewer2d/line.js +17 -47
- package/es/components/viewer2d/ruler.js +5 -3
- package/es/components/viewer2d/rulerDist.js +8 -7
- package/es/components/viewer2d/rulerX.js +3 -0
- package/es/components/viewer2d/rulerY.js +3 -0
- package/es/components/viewer2d/scene.js +4 -1
- package/es/components/viewer2d/state.js +1 -1
- package/es/components/viewer2d/utils.js +2 -2
- package/es/components/viewer2d/viewer2d.js +51 -84
- package/es/components/viewer3d/scene-creator.js +51 -15
- package/es/components/viewer3d/viewer3d-first-person.js +8 -0
- package/es/components/viewer3d/viewer3d.js +80 -88
- package/es/constants.js +6 -2
- package/es/devLiteRenderer.js +491 -150
- package/es/index.js +567 -25
- package/es/models.js +2 -1
- package/es/plugins/SVGLoader.js +1414 -0
- package/es/plugins/console-debugger.js +0 -2
- package/es/styles/export.js +5 -0
- package/es/styles/tabs.css +40 -0
- package/es/utils/geometry.js +52 -96
- package/es/utils/helper.js +38 -1
- package/es/utils/isolate-event-handler.js +781 -577
- package/es/utils/molding.js +457 -11
- package/lib/AppContext.js +1 -1
- package/lib/LiteKitchenConfigurator.js +155 -108
- package/lib/LiteRenderer.js +158 -130
- package/lib/actions/export.js +35 -39
- package/lib/assets/gltf/door_sliding.bin +0 -0
- package/lib/assets/img/png/helper/video_preview_start.png +0 -0
- package/lib/assets/img/svg/bottombar/elevation.svg +12 -5
- package/lib/catalog/catalog.js +20 -4
- package/lib/catalog/holes/window-clear/planner-element.js +2 -2
- package/lib/catalog/properties/export.js +81 -0
- package/lib/catalog/properties/property-checkbox.js +76 -0
- package/lib/catalog/properties/property-color.js +47 -0
- package/lib/catalog/properties/property-enum.js +58 -0
- package/lib/catalog/properties/property-hidden.js +27 -0
- package/lib/catalog/properties/property-lenght-measure.js +108 -0
- package/lib/catalog/properties/property-length-measure.js +92 -0
- package/lib/catalog/properties/property-length-measure_hole.js +108 -0
- package/lib/catalog/properties/property-number.js +56 -0
- package/lib/catalog/properties/property-read-only.js +34 -0
- package/lib/catalog/properties/property-string.js +56 -0
- package/lib/catalog/properties/property-toggle.js +47 -0
- package/lib/catalog/properties/shared-property-style.js +21 -0
- package/lib/catalog/utils/exporter.js +1 -0
- package/lib/catalog/utils/item-loader.js +17 -12
- package/lib/class/hole.js +0 -2
- package/lib/class/item.js +93 -67
- package/lib/class/line.js +3 -7
- package/lib/class/project.js +91 -80
- package/lib/components/content.js +5 -2
- package/lib/components/export.js +6 -26
- package/lib/components/style/button.js +115 -0
- package/lib/components/style/cancel-button.js +29 -0
- package/lib/components/style/content-container.js +38 -0
- package/lib/components/style/content-title.js +35 -0
- package/lib/components/style/delete-button.js +34 -0
- package/lib/components/style/export.js +105 -1
- package/lib/components/style/form-block.js +28 -0
- package/lib/components/style/form-color-input.js +34 -0
- package/lib/components/style/form-label.js +30 -0
- package/lib/components/style/form-number-input.js +11 -22
- package/lib/components/style/form-number-input_2.js +209 -0
- package/lib/components/style/form-select.js +29 -0
- package/lib/components/style/form-slider.js +68 -0
- package/lib/components/style/form-submit-button.js +35 -0
- package/lib/components/style/form-text-input.js +78 -0
- package/lib/components/viewer2d/group.js +5 -4
- package/lib/components/viewer2d/item.js +41 -16
- package/lib/components/viewer2d/layer.js +1 -1
- package/lib/components/viewer2d/line.js +17 -47
- package/lib/components/viewer2d/ruler.js +4 -2
- package/lib/components/viewer2d/rulerDist.js +8 -7
- package/lib/components/viewer2d/rulerX.js +3 -0
- package/lib/components/viewer2d/rulerY.js +3 -0
- package/lib/components/viewer2d/scene.js +4 -1
- package/lib/components/viewer2d/state.js +1 -1
- package/lib/components/viewer2d/utils.js +2 -2
- package/lib/components/viewer2d/viewer2d.js +49 -81
- package/lib/components/viewer3d/scene-creator.js +49 -13
- package/lib/components/viewer3d/viewer3d-first-person.js +8 -0
- package/lib/components/viewer3d/viewer3d.js +77 -84
- package/lib/constants.js +11 -7
- package/lib/devLiteRenderer.js +489 -148
- package/lib/index.js +567 -25
- package/lib/models.js +2 -1
- package/lib/plugins/SVGLoader.js +1419 -0
- package/lib/plugins/console-debugger.js +0 -2
- package/lib/styles/export.js +13 -0
- package/lib/styles/tabs.css +40 -0
- package/lib/utils/geometry.js +52 -96
- package/lib/utils/helper.js +40 -1
- package/lib/utils/isolate-event-handler.js +781 -576
- package/lib/utils/molding.js +458 -9
- package/package.json +21 -16
- package/es/mocks/appliancePayload.json +0 -27
- package/es/mocks/cabinetPayload.json +0 -1914
- package/es/mocks/cabinetPayload2.json +0 -76
- package/es/mocks/dataBundle2.json +0 -4
- package/es/mocks/distancePayload.json +0 -6
- package/es/mocks/doorStylePayload2.json +0 -84
- package/es/mocks/furnishingPayload.json +0 -23
- package/es/mocks/itemCDSPayload.json +0 -27
- package/es/mocks/lightingPayload.json +0 -23
- package/es/mocks/mockProps.json +0 -43
- package/es/mocks/mockProps2.json +0 -9
- package/es/mocks/moldingPayload.json +0 -19
- package/es/mocks/projectItemsCatalog.json +0 -133
- package/es/mocks/rectangleShape.json +0 -238
- package/es/mocks/replaceCabinetPayload.json +0 -81
- package/es/mocks/roomShapePayload.json +0 -5
- package/es/useAppContext.js +0 -8
- package/lib/mocks/appliancePayload.json +0 -27
- package/lib/mocks/cabinetPayload.json +0 -1914
- package/lib/mocks/cabinetPayload2.json +0 -76
- package/lib/mocks/dataBundle2.json +0 -4
- package/lib/mocks/distancePayload.json +0 -6
- package/lib/mocks/doorStylePayload2.json +0 -84
- package/lib/mocks/furnishingPayload.json +0 -23
- package/lib/mocks/itemCDSPayload.json +0 -27
- package/lib/mocks/lightingPayload.json +0 -23
- package/lib/mocks/mockProps.json +0 -43
- package/lib/mocks/mockProps2.json +0 -9
- package/lib/mocks/moldingPayload.json +0 -19
- package/lib/mocks/projectItemsCatalog.json +0 -133
- package/lib/mocks/rectangleShape.json +0 -238
- package/lib/mocks/replaceCabinetPayload.json +0 -81
- package/lib/mocks/roomShapePayload.json +0 -5
- package/lib/useAppContext.js +0 -16
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) {
|
|
@@ -304,6 +304,74 @@ export function getLinesOfItem(item, allLineRects, catalog) {
|
|
|
304
304
|
}
|
|
305
305
|
return lines;
|
|
306
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
|
+
}
|
|
307
375
|
function isParallelLines(line1, line2) {
|
|
308
376
|
var isParallel = false;
|
|
309
377
|
if (Math.abs(line1[0].y - line1[1].y) <= EPSILON && Math.abs(line2[0].y - line2[1].y) <= EPSILON) isParallel = true;
|
|
@@ -485,20 +553,20 @@ export function getLinesFromItems2(moldingGroup, layer, catalog) {
|
|
|
485
553
|
// merge the collinear linked lines to one line
|
|
486
554
|
var newMGlines = [];
|
|
487
555
|
var filteredMGlines = MGlines;
|
|
488
|
-
var _loop3 = function _loop3(
|
|
556
|
+
var _loop3 = function _loop3(_i3) {
|
|
489
557
|
if (filteredMGlines.length < 1) return 0; // break
|
|
490
558
|
if (!filteredMGlines.some(function (v) {
|
|
491
|
-
return v[2] === MGlines[
|
|
559
|
+
return v[2] === MGlines[_i3][2];
|
|
492
560
|
})) return 1; // continue
|
|
493
|
-
var mergedResult = getMergedLine(MGlines[
|
|
561
|
+
var mergedResult = getMergedLine(MGlines[_i3], filteredMGlines, 0);
|
|
494
562
|
if (mergedResult) {
|
|
495
563
|
newMGlines.push(mergedResult.mergedLine);
|
|
496
564
|
filteredMGlines = mergedResult.filteredMGlines;
|
|
497
565
|
}
|
|
498
566
|
},
|
|
499
567
|
_ret;
|
|
500
|
-
for (var
|
|
501
|
-
_ret = _loop3(
|
|
568
|
+
for (var _i3 = 0; _i3 < MGlines.length; _i3++) {
|
|
569
|
+
_ret = _loop3(_i3);
|
|
502
570
|
if (_ret === 0) break;
|
|
503
571
|
if (_ret === 1) continue;
|
|
504
572
|
}
|
|
@@ -587,11 +655,12 @@ function getTrimmedContourLineSegs(lineSegs, otherLines, cnt) {
|
|
|
587
655
|
};
|
|
588
656
|
var bContourSeg = true;
|
|
589
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;
|
|
590
659
|
var destLine = {
|
|
591
|
-
x1: otherLines[j][0].x,
|
|
592
|
-
y1: otherLines[j][0].y,
|
|
593
|
-
x2: otherLines[j][1].x,
|
|
594
|
-
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
|
|
595
664
|
};
|
|
596
665
|
var rst = GeometryUtils.relationshipOfTwoOverlappedLines(srcLine, destLine);
|
|
597
666
|
if (rst.result == OVERLAP_SAME || rst.result == OVERLAP_INCLUDED) {
|
|
@@ -866,4 +935,381 @@ export function createMonldingGroup(oldMG, layer, molding, catalog) {
|
|
|
866
935
|
newMG.lines.reverse();
|
|
867
936
|
newMG = getMDPoints(newMG);
|
|
868
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;
|
|
869
1315
|
}
|
package/lib/AppContext.js
CHANGED
|
@@ -6,6 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var AppContext = /*#__PURE__*/_react["default"].createContext(
|
|
9
|
+
var AppContext = /*#__PURE__*/_react["default"].createContext({});
|
|
10
10
|
var _default = exports["default"] = AppContext;
|
|
11
11
|
module.exports = exports.default;
|