kitchen-simulator 2.0.7-unselected-drag.1 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/LiteRenderer.js +1 -3
- package/es/actions/items-actions.js +1 -1
- package/es/catalog/utils/exporter.js +0 -2
- package/es/class/item.js +3 -1
- package/es/components/viewer2d/viewer2d.js +2 -2
- package/es/components/viewer3d/viewer3d.js +2 -2
- package/es/constants.js +3 -5
- package/es/devLiteRenderer.js +33 -6
- package/es/models.js +1 -2
- package/es/reducers/items-reducer.js +1 -5
- package/es/utils/isolate-event-handler.js +207 -197
- package/lib/LiteRenderer.js +1 -3
- package/lib/catalog/utils/exporter.js +0 -2
- package/lib/class/item.js +3 -1
- package/lib/components/viewer2d/viewer2d.js +2 -2
- package/lib/components/viewer3d/viewer3d.js +2 -2
- package/lib/constants.js +6 -8
- package/lib/devLiteRenderer.js +32 -5
- package/lib/models.js +1 -2
- package/lib/reducers/items-reducer.js +0 -4
- package/lib/utils/isolate-event-handler.js +206 -196
- package/package.json +1 -1
- package/es/assets/Window.hdr +0 -2100
- package/es/assets/brown_photostudio_02_1k.hdr +0 -0
- package/es/assets/gltf/door_sliding.bin +0 -0
- package/es/assets/img/1.jpg +0 -0
- package/es/assets/img/png/helper/video_preview_start.png +0 -0
- package/lib/assets/Window.hdr +0 -2100
- package/lib/assets/brown_photostudio_02_1k.hdr +0 -0
- package/lib/assets/gltf/door_sliding.bin +0 -0
- package/lib/assets/img/1.jpg +0 -0
- package/lib/assets/img/png/helper/video_preview_start.png +0 -0
|
@@ -21,62 +21,30 @@ var _SVGLoader = require("three/addons/loaders/SVGLoader");
|
|
|
21
21
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
22
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
23
23
|
var PRECISION = 2;
|
|
24
|
-
var loadSVGsByItem = /*#__PURE__*/function () {
|
|
25
|
-
var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(item) {
|
|
26
|
-
var _parsed$xml$viewBox, _parsed$xml$viewBox2, response, svgText, loader, parsed, _t;
|
|
27
|
-
return _regenerator["default"].wrap(function (_context) {
|
|
28
|
-
while (1) switch (_context.prev = _context.next) {
|
|
29
|
-
case 0:
|
|
30
|
-
if (item.outline) {
|
|
31
|
-
_context.next = 1;
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
return _context.abrupt("return", null);
|
|
35
|
-
case 1:
|
|
36
|
-
_context.prev = 1;
|
|
37
|
-
_context.next = 2;
|
|
38
|
-
return fetch(item.outline, {
|
|
39
|
-
cache: 'no-store'
|
|
40
|
-
});
|
|
41
|
-
case 2:
|
|
42
|
-
response = _context.sent;
|
|
43
|
-
_context.next = 3;
|
|
44
|
-
return response.text();
|
|
45
|
-
case 3:
|
|
46
|
-
svgText = _context.sent;
|
|
47
|
-
loader = new _SVGLoader.SVGLoader();
|
|
48
|
-
parsed = loader.parse(svgText);
|
|
49
|
-
if (!(0, _helper.isEmpty)(parsed.paths)) {
|
|
50
|
-
_context.next = 4;
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
return _context.abrupt("return", null);
|
|
54
|
-
case 4:
|
|
55
|
-
return _context.abrupt("return", {
|
|
56
|
-
paths: parsed.paths,
|
|
57
|
-
svgWidth: parseFloat(parsed.xml.getAttribute('width')) || ((_parsed$xml$viewBox = parsed.xml.viewBox) === null || _parsed$xml$viewBox === void 0 || (_parsed$xml$viewBox = _parsed$xml$viewBox.animVal) === null || _parsed$xml$viewBox === void 0 ? void 0 : _parsed$xml$viewBox.width) || 0,
|
|
58
|
-
svgHeight: parseFloat(parsed.xml.getAttribute('height')) || ((_parsed$xml$viewBox2 = parsed.xml.viewBox) === null || _parsed$xml$viewBox2 === void 0 || (_parsed$xml$viewBox2 = _parsed$xml$viewBox2.animVal) === null || _parsed$xml$viewBox2 === void 0 ? void 0 : _parsed$xml$viewBox2.height) || 0,
|
|
59
|
-
reverse: !parseFloat(parsed.xml.getAttribute('height'))
|
|
60
|
-
});
|
|
61
|
-
case 5:
|
|
62
|
-
_context.prev = 5;
|
|
63
|
-
_t = _context["catch"](1);
|
|
64
|
-
console.error('Failed to load SVG:', item.outline, _t);
|
|
65
|
-
return _context.abrupt("return", null);
|
|
66
|
-
case 6:
|
|
67
|
-
case "end":
|
|
68
|
-
return _context.stop();
|
|
69
|
-
}
|
|
70
|
-
}, _callee, null, [[1, 5]]);
|
|
71
|
-
}));
|
|
72
|
-
return function loadSVGsByItem(_x) {
|
|
73
|
-
return _ref.apply(this, arguments);
|
|
74
|
-
};
|
|
75
|
-
}();
|
|
76
24
|
var compareSVGRect = function compareSVGRect(value) {
|
|
77
25
|
return value.e <= 10 && value.e + value.a * value.SVGWidth + 10 >= value.viewerWidth && value.f <= 80 && value.f + value.d * value.SVGHeight + 10 >= value.viewerHeight ? true : false;
|
|
78
26
|
};
|
|
79
|
-
function
|
|
27
|
+
var updateViwer2D = function updateViwer2D(value, viewer2DActions) {
|
|
28
|
+
var _zoomValue = parseInt((value.a - 0.5) / _constants.ZOOM_VARIABLE);
|
|
29
|
+
if (_zoomValue > 404) return;
|
|
30
|
+
if (_zoomValue < 35 || Number.isNaN(_zoomValue)) return;
|
|
31
|
+
|
|
32
|
+
// modify e, f to fit to SVG
|
|
33
|
+
while (!(value.e <= 10)) {
|
|
34
|
+
value.e -= 0.1;
|
|
35
|
+
}
|
|
36
|
+
while (!(value.e + value.a * value.SVGWidth + 10 >= value.viewerWidth)) {
|
|
37
|
+
value.e += 0.1;
|
|
38
|
+
}
|
|
39
|
+
while (!(value.f <= 80)) {
|
|
40
|
+
value.f -= 0.1;
|
|
41
|
+
}
|
|
42
|
+
while (!(value.f + value.a * value.SVGHeight + 10 >= value.viewerHeight)) {
|
|
43
|
+
value.f += 0.1;
|
|
44
|
+
}
|
|
45
|
+
if (compareSVGRect(value)) viewer2DActions.updateCameraView(value);
|
|
46
|
+
};
|
|
47
|
+
function loadJSON(_x) {
|
|
80
48
|
return _loadJSON.apply(this, arguments);
|
|
81
49
|
}
|
|
82
50
|
/********Parse TempPlaceholder from cabinetPayloadData **************/
|
|
@@ -107,7 +75,7 @@ function _loadJSON() {
|
|
|
107
75
|
}));
|
|
108
76
|
return _loadJSON.apply(this, arguments);
|
|
109
77
|
}
|
|
110
|
-
function parseTempPlaceholdersFromCabinetPayload(
|
|
78
|
+
function parseTempPlaceholdersFromCabinetPayload(_x2) {
|
|
111
79
|
return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
|
|
112
80
|
}
|
|
113
81
|
/***** Update cabinetPayloadData with updatedTempPlaceholders *****/
|
|
@@ -451,9 +419,9 @@ function _parseTempPlaceholdersFromCabinetPayload() {
|
|
|
451
419
|
}));
|
|
452
420
|
return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
|
|
453
421
|
}
|
|
454
|
-
function updateCabinetPayload(
|
|
422
|
+
function updateCabinetPayload(_x3) {
|
|
455
423
|
return _updateCabinetPayload.apply(this, arguments);
|
|
456
|
-
}
|
|
424
|
+
}
|
|
457
425
|
function _updateCabinetPayload() {
|
|
458
426
|
_updateCabinetPayload = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(cabinetPayload) {
|
|
459
427
|
var tempPlaceholders, cabinetPayloadKeys, i;
|
|
@@ -481,6 +449,112 @@ function _updateCabinetPayload() {
|
|
|
481
449
|
}));
|
|
482
450
|
return _updateCabinetPayload.apply(this, arguments);
|
|
483
451
|
}
|
|
452
|
+
var loadSVGsByItem = /*#__PURE__*/function () {
|
|
453
|
+
var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(item) {
|
|
454
|
+
var _parsed$xml$viewBox, _parsed$xml$viewBox2, response, svgText, loader, parsed, _t;
|
|
455
|
+
return _regenerator["default"].wrap(function (_context) {
|
|
456
|
+
while (1) switch (_context.prev = _context.next) {
|
|
457
|
+
case 0:
|
|
458
|
+
if (item.outline) {
|
|
459
|
+
_context.next = 1;
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
return _context.abrupt("return", null);
|
|
463
|
+
case 1:
|
|
464
|
+
_context.prev = 1;
|
|
465
|
+
_context.next = 2;
|
|
466
|
+
return fetch(item.outline, {
|
|
467
|
+
cache: 'no-store'
|
|
468
|
+
});
|
|
469
|
+
case 2:
|
|
470
|
+
response = _context.sent;
|
|
471
|
+
_context.next = 3;
|
|
472
|
+
return response.text();
|
|
473
|
+
case 3:
|
|
474
|
+
svgText = _context.sent;
|
|
475
|
+
loader = new _SVGLoader.SVGLoader();
|
|
476
|
+
parsed = loader.parse(svgText);
|
|
477
|
+
if (!(0, _helper.isEmpty)(parsed.paths)) {
|
|
478
|
+
_context.next = 4;
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
return _context.abrupt("return", null);
|
|
482
|
+
case 4:
|
|
483
|
+
return _context.abrupt("return", {
|
|
484
|
+
paths: parsed.paths,
|
|
485
|
+
svgWidth: parseFloat(parsed.xml.getAttribute('width')) || ((_parsed$xml$viewBox = parsed.xml.viewBox) === null || _parsed$xml$viewBox === void 0 || (_parsed$xml$viewBox = _parsed$xml$viewBox.animVal) === null || _parsed$xml$viewBox === void 0 ? void 0 : _parsed$xml$viewBox.width) || 0,
|
|
486
|
+
svgHeight: parseFloat(parsed.xml.getAttribute('height')) || ((_parsed$xml$viewBox2 = parsed.xml.viewBox) === null || _parsed$xml$viewBox2 === void 0 || (_parsed$xml$viewBox2 = _parsed$xml$viewBox2.animVal) === null || _parsed$xml$viewBox2 === void 0 ? void 0 : _parsed$xml$viewBox2.height) || 0,
|
|
487
|
+
reverse: !parseFloat(parsed.xml.getAttribute('height'))
|
|
488
|
+
});
|
|
489
|
+
case 5:
|
|
490
|
+
_context.prev = 5;
|
|
491
|
+
_t = _context["catch"](1);
|
|
492
|
+
console.error('Failed to load SVG:', item.outline, _t);
|
|
493
|
+
return _context.abrupt("return", null);
|
|
494
|
+
case 6:
|
|
495
|
+
case "end":
|
|
496
|
+
return _context.stop();
|
|
497
|
+
}
|
|
498
|
+
}, _callee, null, [[1, 5]]);
|
|
499
|
+
}));
|
|
500
|
+
return function loadSVGsByItem(_x4) {
|
|
501
|
+
return _ref.apply(this, arguments);
|
|
502
|
+
};
|
|
503
|
+
}();
|
|
504
|
+
function addItemToCatalog(_x5, _x6, _x7, _x8) {
|
|
505
|
+
return _addItemToCatalog.apply(this, arguments);
|
|
506
|
+
} // Get attributs of current selected element
|
|
507
|
+
function _addItemToCatalog() {
|
|
508
|
+
_addItemToCatalog = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(element, state, catalogInstance, projectActions) {
|
|
509
|
+
var elementJs, catalog, outlineSVGData, updatedStructureJson;
|
|
510
|
+
return _regenerator["default"].wrap(function (_context5) {
|
|
511
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
512
|
+
case 0:
|
|
513
|
+
elementJs = element;
|
|
514
|
+
catalog = state.getIn(['catalog']).toJS(); // add item to catalog of state
|
|
515
|
+
// if (isEmpty(catalog?.elements[element.name])) {
|
|
516
|
+
_context5.next = 1;
|
|
517
|
+
return loadSVGsByItem(element);
|
|
518
|
+
case 1:
|
|
519
|
+
outlineSVGData = _context5.sent;
|
|
520
|
+
if (!(element.type === 'cabinet')) {
|
|
521
|
+
_context5.next = 3;
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
// make placeholders of element and tempPlaceholder
|
|
525
|
+
updatedStructureJson = _objectSpread(_objectSpread({}, element.structure_json), element.structure_json.tempPlaceholders[0].structure);
|
|
526
|
+
element.structure_json = updatedStructureJson;
|
|
527
|
+
element = _objectSpread(_objectSpread({}, element), {}, {
|
|
528
|
+
cds: {
|
|
529
|
+
data: [_objectSpread({}, element.customer_property)],
|
|
530
|
+
itemID: element.itemID
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
_context5.next = 2;
|
|
534
|
+
return updateCabinetPayload(element);
|
|
535
|
+
case 2:
|
|
536
|
+
elementJs = _context5.sent;
|
|
537
|
+
case 3:
|
|
538
|
+
elementJs = _objectSpread(_objectSpread({}, elementJs), {}, {
|
|
539
|
+
outlineSVGData: outlineSVGData,
|
|
540
|
+
type: element.type,
|
|
541
|
+
render2DItem: _itemLoader.render2DItem
|
|
542
|
+
});
|
|
543
|
+
if (element.type === 'appliance' || element.type === 'furnishing') elementJs.render3DItem = _itemLoader.render3DApplianceItem;else if (element.type === 'lighting') elementJs.render3DItem = _itemLoader.render3DLightingItem;else elementJs.render3DItem = _itemLoader.render3DItem;
|
|
544
|
+
elementJs = (0, _exporter["default"])(elementJs);
|
|
545
|
+
if (catalogInstance !== null && catalogInstance !== void 0 && catalogInstance.validateElement(elementJs)) {
|
|
546
|
+
catalogInstance.registerElement(elementJs);
|
|
547
|
+
projectActions.addElementToCatalog(elementJs);
|
|
548
|
+
}
|
|
549
|
+
// }
|
|
550
|
+
case 4:
|
|
551
|
+
case "end":
|
|
552
|
+
return _context5.stop();
|
|
553
|
+
}
|
|
554
|
+
}, _callee5);
|
|
555
|
+
}));
|
|
556
|
+
return _addItemToCatalog.apply(this, arguments);
|
|
557
|
+
}
|
|
484
558
|
function initAttrData(element, layer, state) {
|
|
485
559
|
element = (0, _typeof2["default"])(element.misc) === 'object' ? element.set('misc', new _immutable.Map(element.misc)) : element;
|
|
486
560
|
switch (element.prototype) {
|
|
@@ -743,21 +817,21 @@ function updateAttributeOfSelectedElement(element, attrPayload, state, layer, pr
|
|
|
743
817
|
{
|
|
744
818
|
var _line = layer.lines.get(element.line);
|
|
745
819
|
var _layer$vertices$get5 = layer.vertices.get(_line.vertices.get(0)),
|
|
746
|
-
|
|
820
|
+
_x9 = _layer$vertices$get5.x,
|
|
747
821
|
_y = _layer$vertices$get5.y;
|
|
748
822
|
var _layer$vertices$get6 = layer.vertices.get(_line.vertices.get(1)),
|
|
749
|
-
|
|
823
|
+
_x0 = _layer$vertices$get6.x,
|
|
750
824
|
_y2 = _layer$vertices$get6.y;
|
|
751
|
-
var _alpha = _export.GeometryUtils.angleBetweenTwoPoints(
|
|
752
|
-
var _lineLength = _export.GeometryUtils.pointsDistance(
|
|
825
|
+
var _alpha = _export.GeometryUtils.angleBetweenTwoPoints(_x9, _y, _x0, _y2);
|
|
826
|
+
var _lineLength = _export.GeometryUtils.pointsDistance(_x9, _y, _x0, _y2);
|
|
753
827
|
var _widthLength = element.properties.get('width').get('length');
|
|
754
828
|
var _halfWidthLength = _widthLength / 2;
|
|
755
829
|
var _lengthValue = value.get('length');
|
|
756
830
|
_lengthValue = Math.max(_lengthValue, 0);
|
|
757
831
|
_lengthValue = Math.min(_lengthValue, _lineLength - _widthLength);
|
|
758
|
-
var _xp =
|
|
832
|
+
var _xp = _x0 - (_lengthValue + _halfWidthLength) * Math.cos(_alpha);
|
|
759
833
|
var _yp = _y2 - (_lengthValue + _halfWidthLength) * Math.sin(_alpha);
|
|
760
|
-
var _offset = _export.GeometryUtils.pointPositionOnLineSegment(
|
|
834
|
+
var _offset = _export.GeometryUtils.pointPositionOnLineSegment(_x9, _y, _x0, _y2, _xp, _yp);
|
|
761
835
|
/*
|
|
762
836
|
if (x0 > x1) offset = 1 - offset;
|
|
763
837
|
*/
|
|
@@ -829,67 +903,13 @@ projectActions) {
|
|
|
829
903
|
projectActions.setProperties(properties);
|
|
830
904
|
}
|
|
831
905
|
}
|
|
832
|
-
function addItemToCatalog(_x7, _x8, _x9, _x0) {
|
|
833
|
-
return _addItemToCatalog.apply(this, arguments);
|
|
834
|
-
}
|
|
835
|
-
function _addItemToCatalog() {
|
|
836
|
-
_addItemToCatalog = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(element, state, catalogInstance, projectActions) {
|
|
837
|
-
var elementJs, catalog, outlineSVGData, updatedStructureJson;
|
|
838
|
-
return _regenerator["default"].wrap(function (_context5) {
|
|
839
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
840
|
-
case 0:
|
|
841
|
-
elementJs = element;
|
|
842
|
-
catalog = state.getIn(['catalog']).toJS(); // add item to catalog of state
|
|
843
|
-
// if (isEmpty(catalog?.elements[element.name])) {
|
|
844
|
-
_context5.next = 1;
|
|
845
|
-
return loadSVGsByItem(element);
|
|
846
|
-
case 1:
|
|
847
|
-
outlineSVGData = _context5.sent;
|
|
848
|
-
if (!(element.type === 'cabinet')) {
|
|
849
|
-
_context5.next = 3;
|
|
850
|
-
break;
|
|
851
|
-
}
|
|
852
|
-
// make placeholders of element and tempPlaceholder
|
|
853
|
-
updatedStructureJson = _objectSpread(_objectSpread({}, element.structure_json), element.structure_json.tempPlaceholders[0].structure);
|
|
854
|
-
element.structure_json = updatedStructureJson;
|
|
855
|
-
element = _objectSpread(_objectSpread({}, element), {}, {
|
|
856
|
-
cds: {
|
|
857
|
-
data: [_objectSpread({}, element.customer_property)],
|
|
858
|
-
itemID: element.itemID
|
|
859
|
-
}
|
|
860
|
-
});
|
|
861
|
-
_context5.next = 2;
|
|
862
|
-
return updateCabinetPayload(element);
|
|
863
|
-
case 2:
|
|
864
|
-
elementJs = _context5.sent;
|
|
865
|
-
case 3:
|
|
866
|
-
elementJs = _objectSpread(_objectSpread({}, elementJs), {}, {
|
|
867
|
-
outlineSVGData: outlineSVGData,
|
|
868
|
-
type: element.type,
|
|
869
|
-
render2DItem: _itemLoader.render2DItem
|
|
870
|
-
});
|
|
871
|
-
if (element.type === 'appliance' || element.type === 'furnishing') elementJs.render3DItem = _itemLoader.render3DApplianceItem;else if (element.type === 'lighting') elementJs.render3DItem = _itemLoader.render3DLightingItem;else elementJs.render3DItem = _itemLoader.render3DItem;
|
|
872
|
-
elementJs = (0, _exporter["default"])(elementJs);
|
|
873
|
-
if (catalogInstance !== null && catalogInstance !== void 0 && catalogInstance.validateElement(elementJs)) {
|
|
874
|
-
catalogInstance.registerElement(elementJs);
|
|
875
|
-
projectActions.addElementToCatalog(elementJs);
|
|
876
|
-
}
|
|
877
|
-
// }
|
|
878
|
-
case 4:
|
|
879
|
-
case "end":
|
|
880
|
-
return _context5.stop();
|
|
881
|
-
}
|
|
882
|
-
}, _callee5);
|
|
883
|
-
}));
|
|
884
|
-
return _addItemToCatalog.apply(this, arguments);
|
|
885
|
-
}
|
|
886
906
|
function handleExternalEvent(_x1) {
|
|
887
907
|
return _handleExternalEvent.apply(this, arguments);
|
|
888
908
|
}
|
|
889
909
|
function _handleExternalEvent() {
|
|
890
910
|
_handleExternalEvent = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7(props) {
|
|
891
911
|
var _evt$payload3, _evt$payload4;
|
|
892
|
-
var evt, state, _evt$payload, cdsItems, itemKeys, _loop3, i, _props$onInternalEven, sLineCnt, element, _state$viewer2D, _evt$payload$initialP, mouseX, mouseY, v2d, vPosX, vPosY, layerID, _evt$payload5, moveType, moveValue, value, defaulTitle, _evt$payload6, doorStyle, itemCDS, isAll, _doorStyle, _value,
|
|
912
|
+
var evt, state, _evt$payload, cdsItems, itemKeys, _loop3, i, _props$onInternalEven, sLineCnt, element, _state$viewer2D, _evt$payload$initialP, mouseX, mouseY, v2d, vPosX, vPosY, layerID, _evt$payload5, moveType, moveValue, value, defaulTitle, _evt$payload6, doorStyle, itemCDS, isAll, _doorStyle, _value, _value2, layer, bb, w, h, viewer, _evt$payload7, moldingInfo, isGlobal, _evt$payload8, option, _value3, layerId, _layer, _layer$getIn, selectedLines, selectedHoles, selectedItems, _i2, _i3, _i4, _props$onInternalEven2, _t5, _t6;
|
|
893
913
|
return _regenerator["default"].wrap(function (_context8) {
|
|
894
914
|
while (1) switch (_context8.prev = _context8.next) {
|
|
895
915
|
case 0:
|
|
@@ -897,7 +917,7 @@ function _handleExternalEvent() {
|
|
|
897
917
|
evt = props.externalEvent;
|
|
898
918
|
state = props.state.get('KitchenConfigurator');
|
|
899
919
|
_t5 = evt === null || evt === void 0 ? void 0 : evt.type;
|
|
900
|
-
_context8.next = _t5 === _constants.EXTERNAL_EVENT_LOAD_PROJECT ? 1 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_3D ? 5 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_2D ? 6 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 7 : _t5 === _constants.EXTERNAL_EVENT_ADD_WALL ? 8 : _t5 === _constants.EXTERNAL_EVENT_ADD_ITEM ? 9 : _t5 === _constants.EXTERNAL_EVENT_ADD_HOLE ? 12 : _t5 === _constants.EXTERNAL_EVENT_MOVE_PAN ? 13 : _t5 === _constants.EXTERNAL_EVENT_NEW_PROJECT ? 19 : _t5 === _constants.EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 20 : _t5 === _constants.EXTERNAL_EVENT_SET_INITIAL_DATA ? 21 : _t5 === _constants.EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 22 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_IN ? 23 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_OUT ?
|
|
920
|
+
_context8.next = _t5 === _constants.EXTERNAL_EVENT_LOAD_PROJECT ? 1 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_3D ? 5 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_2D ? 6 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 7 : _t5 === _constants.EXTERNAL_EVENT_ADD_WALL ? 8 : _t5 === _constants.EXTERNAL_EVENT_ADD_ITEM ? 9 : _t5 === _constants.EXTERNAL_EVENT_ADD_HOLE ? 12 : _t5 === _constants.EXTERNAL_EVENT_MOVE_PAN ? 13 : _t5 === _constants.EXTERNAL_EVENT_NEW_PROJECT ? 19 : _t5 === _constants.EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 20 : _t5 === _constants.EXTERNAL_EVENT_SET_INITIAL_DATA ? 21 : _t5 === _constants.EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 22 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_IN ? 23 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_OUT ? 24 : _t5 === _constants.EXTERNAL_EVENT_CENTERING_2D ? 25 : _t5 === _constants.EXTERNAL_EVENT_UNDO ? 26 : _t5 === _constants.EXTERNAL_EVENT_REDO ? 27 : _t5 === _constants.EXTERNAL_EVENT_SET_MOLDING ? 28 : _t5 === _constants.EXTERNAL_EVENT_PROJECT_SETTING ? 29 : _t5 === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? 30 : _t5 === _constants.EXTERNAL_EVENT_UPDATE_PROPERTY ? 30 : _t5 === _constants.EXTERNAL_EVENT_SYNC_SCENE ? 31 : 32;
|
|
901
921
|
break;
|
|
902
922
|
case 1:
|
|
903
923
|
// prepare item data request
|
|
@@ -973,23 +993,23 @@ function _handleExternalEvent() {
|
|
|
973
993
|
};
|
|
974
994
|
}());
|
|
975
995
|
}
|
|
976
|
-
return _context8.abrupt("continue",
|
|
996
|
+
return _context8.abrupt("continue", 32);
|
|
977
997
|
case 5:
|
|
978
998
|
props.projectActions.setMode(_constants.MODE_IDLE_3D);
|
|
979
|
-
return _context8.abrupt("continue",
|
|
999
|
+
return _context8.abrupt("continue", 32);
|
|
980
1000
|
case 6:
|
|
981
1001
|
props.projectActions.setMode(_constants.MODE_IDLE);
|
|
982
|
-
return _context8.abrupt("continue",
|
|
1002
|
+
return _context8.abrupt("continue", 32);
|
|
983
1003
|
case 7:
|
|
984
1004
|
sLineCnt = state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size;
|
|
985
1005
|
if (sLineCnt > 0) props.projectActions.setMode(_constants.MODE_ELEVATION_VIEW);
|
|
986
|
-
return _context8.abrupt("continue",
|
|
1006
|
+
return _context8.abrupt("continue", 32);
|
|
987
1007
|
case 8:
|
|
988
1008
|
if (state.mode === _constants.MODE_IDLE || state.mode === _constants.MODE_2D_PAN) props.linesActions.selectToolDrawingLine('wall');else {
|
|
989
1009
|
props.projectActions.setMode(_constants.MODE_IDLE);
|
|
990
1010
|
props.linesActions.selectToolDrawingLine('wall');
|
|
991
1011
|
}
|
|
992
|
-
return _context8.abrupt("continue",
|
|
1012
|
+
return _context8.abrupt("continue", 32);
|
|
993
1013
|
case 9:
|
|
994
1014
|
if ((0, _helper.isEmpty)(evt === null || evt === void 0 ? void 0 : evt.payload)) {
|
|
995
1015
|
_context8.next = 11;
|
|
@@ -1020,10 +1040,10 @@ function _handleExternalEvent() {
|
|
|
1020
1040
|
props.projectActions.pushLastSelectedCatalogElementToHistory(element);
|
|
1021
1041
|
props.projectActions.setIsCabinetDrawing(true);
|
|
1022
1042
|
case 11:
|
|
1023
|
-
return _context8.abrupt("continue",
|
|
1043
|
+
return _context8.abrupt("continue", 32);
|
|
1024
1044
|
case 12:
|
|
1025
1045
|
_constants.ARRAY_3D_MODES.includes(state.mode) ? props.holesActions.selectToolDrawingHole3D(evt === null || evt === void 0 || (_evt$payload3 = evt.payload) === null || _evt$payload3 === void 0 ? void 0 : _evt$payload3.holeName) : props.holesActions.selectToolDrawingHole(evt === null || evt === void 0 || (_evt$payload4 = evt.payload) === null || _evt$payload4 === void 0 ? void 0 : _evt$payload4.holeName);
|
|
1026
|
-
return _context8.abrupt("continue",
|
|
1046
|
+
return _context8.abrupt("continue", 32);
|
|
1027
1047
|
case 13:
|
|
1028
1048
|
_evt$payload5 = evt.payload, moveType = _evt$payload5.moveType, moveValue = _evt$payload5.moveValue;
|
|
1029
1049
|
value = state.getIn(['viewer2D']).toJS();
|
|
@@ -1043,89 +1063,78 @@ function _handleExternalEvent() {
|
|
|
1043
1063
|
value.e -= moveValue;
|
|
1044
1064
|
return _context8.abrupt("continue", 18);
|
|
1045
1065
|
case 18:
|
|
1046
|
-
|
|
1047
|
-
return _context8.abrupt("continue",
|
|
1066
|
+
updateViwer2D(value, props.viewer2DActions);
|
|
1067
|
+
return _context8.abrupt("continue", 32);
|
|
1048
1068
|
case 19:
|
|
1049
1069
|
defaulTitle = 'Untitle';
|
|
1050
1070
|
props.projectActions.newProject();
|
|
1051
1071
|
props.projectActions.rename(defaulTitle);
|
|
1052
|
-
return _context8.abrupt("continue",
|
|
1072
|
+
return _context8.abrupt("continue", 32);
|
|
1053
1073
|
case 20:
|
|
1054
1074
|
_evt$payload6 = evt.payload, doorStyle = _evt$payload6.doorStyle, itemCDS = _evt$payload6.itemCDS, isAll = _evt$payload6.isAll;
|
|
1055
1075
|
props.itemsActions.setDoorStyle(doorStyle, itemCDS, isAll);
|
|
1056
|
-
return _context8.abrupt("continue",
|
|
1076
|
+
return _context8.abrupt("continue", 32);
|
|
1057
1077
|
case 21:
|
|
1058
1078
|
_doorStyle = evt.payload.doorStyle;
|
|
1059
1079
|
props.itemsActions.setInitialDoorStyle(_doorStyle.doorStyle);
|
|
1060
|
-
return _context8.abrupt("continue",
|
|
1080
|
+
return _context8.abrupt("continue", 32);
|
|
1061
1081
|
case 22:
|
|
1062
1082
|
props.projectActions.loadProject(evt.payload);
|
|
1063
|
-
return _context8.abrupt("continue",
|
|
1083
|
+
return _context8.abrupt("continue", 32);
|
|
1064
1084
|
case 23:
|
|
1065
1085
|
_value = state.getIn(['viewer2D']).toJS();
|
|
1066
|
-
_value.a
|
|
1067
|
-
_value.d
|
|
1068
|
-
_value.e
|
|
1069
|
-
_value.f
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
_context8.next = 24;
|
|
1073
|
-
break;
|
|
1074
|
-
}
|
|
1075
|
-
return _context8.abrupt("return");
|
|
1086
|
+
_value.a += 0.1;
|
|
1087
|
+
_value.d += 0.1;
|
|
1088
|
+
_value.e -= _value.SVGWidth * 0.1 / 2;
|
|
1089
|
+
_value.f -= _value.SVGHeight * 0.1 / 2;
|
|
1090
|
+
updateViwer2D(_value, props.viewer2DActions);
|
|
1091
|
+
return _context8.abrupt("continue", 32);
|
|
1076
1092
|
case 24:
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1093
|
+
_value2 = state.getIn(['viewer2D']).toJS();
|
|
1094
|
+
_value2.a -= 0.1;
|
|
1095
|
+
_value2.d -= 0.1;
|
|
1096
|
+
_value2.e += _value2.SVGWidth * 0.1 / 2;
|
|
1097
|
+
_value2.f += _value2.SVGHeight * 0.1 / 2;
|
|
1098
|
+
updateViwer2D(_value2, props.viewer2DActions);
|
|
1099
|
+
return _context8.abrupt("continue", 32);
|
|
1082
1100
|
case 25:
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1101
|
+
// calculate the bounding box of all elements in plan
|
|
1102
|
+
layer = state.scene.getIn(['layers', state.scene.selectedLayer]);
|
|
1103
|
+
bb = {
|
|
1104
|
+
minX: Infinity,
|
|
1105
|
+
maxX: -Infinity,
|
|
1106
|
+
minY: Infinity,
|
|
1107
|
+
maxY: -Infinity
|
|
1108
|
+
};
|
|
1109
|
+
bb = layer.vertices.reduce(function (pre, cur) {
|
|
1110
|
+
pre.minX = Math.min(pre.minX, cur.x);
|
|
1111
|
+
pre.maxX = Math.max(pre.maxX, cur.x);
|
|
1112
|
+
pre.minY = Math.min(pre.minY, cur.y);
|
|
1113
|
+
pre.maxY = Math.max(pre.maxY, cur.y);
|
|
1114
|
+
return pre;
|
|
1115
|
+
}, bb);
|
|
1116
|
+
w = bb.maxX - bb.minX;
|
|
1117
|
+
h = bb.maxY - bb.minY; // calc scale and offset to fit view
|
|
1118
|
+
viewer = state.getIn(['viewer2D']).toJS();
|
|
1119
|
+
if (w != 0 && Math.abs(w) != Infinity && h != 0 && Math.abs(h) != Infinity) {
|
|
1120
|
+
viewer.a = viewer.viewerHeight < h ? viewer.viewerHeight / h : viewer.viewerHeight / h * 3 / 5 / _constants.ZOOM_VARIABLE > 400 ? viewer.viewerHeight / h * 400 / (viewer.viewerHeight / h / _constants.ZOOM_VARIABLE) : viewer.viewerHeight / h * 3 / 5;
|
|
1121
|
+
viewer.d = viewer.a;
|
|
1122
|
+
viewer.e = (viewer.viewerWidth - (bb.maxX + bb.minX) * viewer.a) / 2;
|
|
1123
|
+
viewer.f = (viewer.viewerHeight - (bb.maxY + bb.minY) * viewer.a) / 2;
|
|
1124
|
+
updateViwer2D(viewer, props.viewer2DActions);
|
|
1091
1125
|
}
|
|
1092
|
-
|
|
1093
|
-
_value.f += 0.1;
|
|
1094
|
-
}
|
|
1095
|
-
if (compareSVGRect(_value)) props.viewer2DActions.updateCameraView(_value);
|
|
1096
|
-
return _context8.abrupt("continue", 35);
|
|
1126
|
+
return _context8.abrupt("continue", 32);
|
|
1097
1127
|
case 26:
|
|
1098
|
-
_value2 = state.getIn(['viewer2D']).toJS();
|
|
1099
|
-
_value2.a += 0.1;
|
|
1100
|
-
_value2.d += 0.1;
|
|
1101
|
-
_value2.e -= _value2.SVGWidth * 0.1 / 2;
|
|
1102
|
-
_value2.f -= _value2.SVGHeight * 0.1 / 2;
|
|
1103
|
-
_zoomValue2 = parseInt((_value2.a - 0.5) / _constants.ZOOM_VARIABLE);
|
|
1104
|
-
if (!(_zoomValue2 > 404)) {
|
|
1105
|
-
_context8.next = 27;
|
|
1106
|
-
break;
|
|
1107
|
-
}
|
|
1108
|
-
return _context8.abrupt("return");
|
|
1109
|
-
case 27:
|
|
1110
|
-
if (!(_zoomValue2 < 35 || Number.isNaN(_zoomValue2))) {
|
|
1111
|
-
_context8.next = 28;
|
|
1112
|
-
break;
|
|
1113
|
-
}
|
|
1114
|
-
return _context8.abrupt("return");
|
|
1115
|
-
case 28:
|
|
1116
|
-
if (compareSVGRect(_value2)) props.viewer2DActions.updateCameraView(_value2);
|
|
1117
|
-
return _context8.abrupt("continue", 35);
|
|
1118
|
-
case 29:
|
|
1119
1128
|
props.projectActions.undo();
|
|
1120
|
-
return _context8.abrupt("continue",
|
|
1121
|
-
case
|
|
1129
|
+
return _context8.abrupt("continue", 32);
|
|
1130
|
+
case 27:
|
|
1122
1131
|
props.projectActions.redo();
|
|
1123
|
-
return _context8.abrupt("continue",
|
|
1124
|
-
case
|
|
1132
|
+
return _context8.abrupt("continue", 32);
|
|
1133
|
+
case 28:
|
|
1125
1134
|
_evt$payload7 = evt.payload, moldingInfo = _evt$payload7.moldingInfo, isGlobal = _evt$payload7.isGlobal;
|
|
1126
1135
|
props.itemsActions.setMolding(moldingInfo, isGlobal);
|
|
1127
|
-
return _context8.abrupt("continue",
|
|
1128
|
-
case
|
|
1136
|
+
return _context8.abrupt("continue", 32);
|
|
1137
|
+
case 29:
|
|
1129
1138
|
_evt$payload8 = evt.payload, option = _evt$payload8.option, _value3 = _evt$payload8.value;
|
|
1130
1139
|
if (option === _constants.PROJECT_SETTING_OPTION.UPDATE_CEIL_HEIGHT) {
|
|
1131
1140
|
props.viewer2DActions.updateCeilHeight(_value3);
|
|
@@ -1139,16 +1148,16 @@ function _handleExternalEvent() {
|
|
|
1139
1148
|
} else if (option === _constants.PROJECT_SETTING_OPTION.CHANGE_WINDOW_DOOR_MEASURE) {
|
|
1140
1149
|
props.viewer2DActions.changeWindowDoorMeasure(_value3);
|
|
1141
1150
|
}
|
|
1142
|
-
return _context8.abrupt("continue",
|
|
1143
|
-
case
|
|
1151
|
+
return _context8.abrupt("continue", 32);
|
|
1152
|
+
case 30:
|
|
1144
1153
|
layerId = state.getIn(['scene', 'selectedLayer']);
|
|
1145
|
-
|
|
1146
|
-
_layer$getIn =
|
|
1147
|
-
for (_i2 = 0; _i2 < selectedLines.size; _i2++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(
|
|
1148
|
-
for (_i3 = 0; _i3 < selectedHoles.size; _i3++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(
|
|
1149
|
-
for (_i4 = 0; _i4 < selectedItems.size; _i4++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(
|
|
1150
|
-
return _context8.abrupt("continue",
|
|
1151
|
-
case
|
|
1154
|
+
_layer = state.getIn(['scene', 'layers', layerId]);
|
|
1155
|
+
_layer$getIn = _layer.getIn(['selected']), selectedLines = _layer$getIn.lines, selectedHoles = _layer$getIn.holes, selectedItems = _layer$getIn.items;
|
|
1156
|
+
for (_i2 = 0; _i2 < selectedLines.size; _i2++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(_layer.getIn(['lines', selectedLines.get(_i2)]), evt.payload, state, _layer, props.projectActions) : updatePropertyOfSelectedElement(_layer.getIn(['lines', selectedLines.get(_i2)]), evt.payload, props.catalog, props.projectActions);
|
|
1157
|
+
for (_i3 = 0; _i3 < selectedHoles.size; _i3++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(_layer.getIn(['holes', selectedHoles.get(_i3)]), evt.payload, state, _layer, props.projectActions) : updatePropertyOfSelectedElement(_layer.getIn(['holes', selectedHoles.get(_i3)]), evt.payload, props.catalog, props.projectActions);
|
|
1158
|
+
for (_i4 = 0; _i4 < selectedItems.size; _i4++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(_layer.getIn(['items', selectedItems.get(_i4)]), evt.payload, state, _layer, props.projectActions) : updatePropertyOfSelectedElement(_layer.getIn(['items', selectedItems.get(_i4)]), evt.payload, props.catalog, props.projectActions);
|
|
1159
|
+
return _context8.abrupt("continue", 32);
|
|
1160
|
+
case 31:
|
|
1152
1161
|
// send scene object from 3DTool to HostApp using internalEvent
|
|
1153
1162
|
(_props$onInternalEven2 = props.onInternalEvent) === null || _props$onInternalEven2 === void 0 || _props$onInternalEven2.call(props, {
|
|
1154
1163
|
type: _constants.INTERNAL_EVENT_SYNC_SCENE,
|
|
@@ -1156,7 +1165,8 @@ function _handleExternalEvent() {
|
|
|
1156
1165
|
scene: state.scene.toJS()
|
|
1157
1166
|
}
|
|
1158
1167
|
});
|
|
1159
|
-
|
|
1168
|
+
return _context8.abrupt("continue", 32);
|
|
1169
|
+
case 32:
|
|
1160
1170
|
case "end":
|
|
1161
1171
|
return _context8.stop();
|
|
1162
1172
|
}
|