kitchen-simulator 2.0.7-unselected-drag.1 → 2.0.11
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/actions/project-actions.js +3 -1
- package/es/catalog/utils/exporter.js +0 -2
- package/es/class/item.js +3 -1
- package/es/class/project.js +40 -17
- package/es/components/viewer2d/viewer2d.js +2 -2
- package/es/components/viewer3d/viewer3d.js +2 -2
- package/es/constants.js +11 -4
- package/es/devLiteRenderer.js +57 -6
- package/es/models.js +1 -2
- package/es/reducers/items-reducer.js +1 -5
- package/es/reducers/project-reducer.js +1 -1
- package/es/utils/isolate-event-handler.js +247 -193
- package/lib/LiteRenderer.js +1 -3
- package/lib/actions/project-actions.js +3 -1
- package/lib/catalog/utils/exporter.js +0 -2
- package/lib/class/item.js +3 -1
- package/lib/class/project.js +40 -17
- package/lib/components/viewer2d/viewer2d.js +2 -2
- package/lib/components/viewer3d/viewer3d.js +2 -2
- package/lib/constants.js +16 -9
- package/lib/devLiteRenderer.js +56 -5
- package/lib/models.js +1 -2
- package/lib/reducers/items-reducer.js +0 -4
- package/lib/reducers/project-reducer.js +1 -1
- package/lib/utils/isolate-event-handler.js +246 -192
- 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,59 +903,41 @@ projectActions) {
|
|
|
829
903
|
projectActions.setProperties(properties);
|
|
830
904
|
}
|
|
831
905
|
}
|
|
832
|
-
function
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
var
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
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
|
|
906
|
+
function getElement(objProps, state) {
|
|
907
|
+
var layerID = state.scene.selectedLayer;
|
|
908
|
+
var curObject = null;
|
|
909
|
+
if (!(0, _helper.isEmpty)(objProps === null || objProps === void 0 ? void 0 : objProps.elementPrototype) && !(0, _helper.isEmpty)(objProps === null || objProps === void 0 ? void 0 : objProps.elementId)) curObject = state.getIn(['scene', 'layers', layerID, objProps.elementPrototype, objProps.elementId]);else {
|
|
910
|
+
// if no specified object property then get the first selected element
|
|
911
|
+
var layer = state.scene.layers.get(state.scene.selectedLayer);
|
|
912
|
+
var selected = [];
|
|
913
|
+
layer.selected.forEach(function (data, prototype) {
|
|
914
|
+
if (prototype == 'vertices') return;
|
|
915
|
+
if (data.size > 0) {
|
|
916
|
+
var values = data.toJS();
|
|
917
|
+
for (var i = 0; i < values.length; i++) {
|
|
918
|
+
selected.push({
|
|
919
|
+
type: prototype,
|
|
920
|
+
id: values[i]
|
|
870
921
|
});
|
|
871
|
-
|
|
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();
|
|
922
|
+
}
|
|
881
923
|
}
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
|
|
924
|
+
});
|
|
925
|
+
if (selected.length === 1) {
|
|
926
|
+
var selData = selected[0];
|
|
927
|
+
switch (selData.type) {
|
|
928
|
+
case _constants.ELEMENT_HOLE:
|
|
929
|
+
curObject = layer.holes.get(selData.id);
|
|
930
|
+
break;
|
|
931
|
+
case _constants.ELEMENT_ITEM:
|
|
932
|
+
curObject = layer.items.get(selData.id);
|
|
933
|
+
break;
|
|
934
|
+
case _constants.ELEMENT_LINE:
|
|
935
|
+
curObject = layer.lines.get(selData.id);
|
|
936
|
+
break;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
return curObject;
|
|
885
941
|
}
|
|
886
942
|
function handleExternalEvent(_x1) {
|
|
887
943
|
return _handleExternalEvent.apply(this, arguments);
|
|
@@ -889,7 +945,7 @@ function handleExternalEvent(_x1) {
|
|
|
889
945
|
function _handleExternalEvent() {
|
|
890
946
|
_handleExternalEvent = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7(props) {
|
|
891
947
|
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,
|
|
948
|
+
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, distElement, _distElement, _evt$payload8, option, _value3, layerId, _layer, _layer$getIn, selectedLines, selectedHoles, selectedItems, _i2, _i3, _i4, _props$onInternalEven2, _t5, _t6;
|
|
893
949
|
return _regenerator["default"].wrap(function (_context8) {
|
|
894
950
|
while (1) switch (_context8.prev = _context8.next) {
|
|
895
951
|
case 0:
|
|
@@ -897,7 +953,7 @@ function _handleExternalEvent() {
|
|
|
897
953
|
evt = props.externalEvent;
|
|
898
954
|
state = props.state.get('KitchenConfigurator');
|
|
899
955
|
_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 ?
|
|
956
|
+
_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_DUPLICATE_ELEMENT ? 29 : _t5 === _constants.EXTERNAL_EVENT_DELETE_ELEMENT ? 30 : _t5 === _constants.EXTERNAL_EVENT_PROJECT_SETTING ? 31 : _t5 === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? 32 : _t5 === _constants.EXTERNAL_EVENT_UPDATE_PROPERTY ? 32 : _t5 === _constants.EXTERNAL_EVENT_SYNC_SCENE ? 33 : 34;
|
|
901
957
|
break;
|
|
902
958
|
case 1:
|
|
903
959
|
// prepare item data request
|
|
@@ -973,23 +1029,23 @@ function _handleExternalEvent() {
|
|
|
973
1029
|
};
|
|
974
1030
|
}());
|
|
975
1031
|
}
|
|
976
|
-
return _context8.abrupt("continue",
|
|
1032
|
+
return _context8.abrupt("continue", 34);
|
|
977
1033
|
case 5:
|
|
978
1034
|
props.projectActions.setMode(_constants.MODE_IDLE_3D);
|
|
979
|
-
return _context8.abrupt("continue",
|
|
1035
|
+
return _context8.abrupt("continue", 34);
|
|
980
1036
|
case 6:
|
|
981
1037
|
props.projectActions.setMode(_constants.MODE_IDLE);
|
|
982
|
-
return _context8.abrupt("continue",
|
|
1038
|
+
return _context8.abrupt("continue", 34);
|
|
983
1039
|
case 7:
|
|
984
1040
|
sLineCnt = state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size;
|
|
985
1041
|
if (sLineCnt > 0) props.projectActions.setMode(_constants.MODE_ELEVATION_VIEW);
|
|
986
|
-
return _context8.abrupt("continue",
|
|
1042
|
+
return _context8.abrupt("continue", 34);
|
|
987
1043
|
case 8:
|
|
988
1044
|
if (state.mode === _constants.MODE_IDLE || state.mode === _constants.MODE_2D_PAN) props.linesActions.selectToolDrawingLine('wall');else {
|
|
989
1045
|
props.projectActions.setMode(_constants.MODE_IDLE);
|
|
990
1046
|
props.linesActions.selectToolDrawingLine('wall');
|
|
991
1047
|
}
|
|
992
|
-
return _context8.abrupt("continue",
|
|
1048
|
+
return _context8.abrupt("continue", 34);
|
|
993
1049
|
case 9:
|
|
994
1050
|
if ((0, _helper.isEmpty)(evt === null || evt === void 0 ? void 0 : evt.payload)) {
|
|
995
1051
|
_context8.next = 11;
|
|
@@ -1020,10 +1076,10 @@ function _handleExternalEvent() {
|
|
|
1020
1076
|
props.projectActions.pushLastSelectedCatalogElementToHistory(element);
|
|
1021
1077
|
props.projectActions.setIsCabinetDrawing(true);
|
|
1022
1078
|
case 11:
|
|
1023
|
-
return _context8.abrupt("continue",
|
|
1079
|
+
return _context8.abrupt("continue", 34);
|
|
1024
1080
|
case 12:
|
|
1025
1081
|
_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",
|
|
1082
|
+
return _context8.abrupt("continue", 34);
|
|
1027
1083
|
case 13:
|
|
1028
1084
|
_evt$payload5 = evt.payload, moveType = _evt$payload5.moveType, moveValue = _evt$payload5.moveValue;
|
|
1029
1085
|
value = state.getIn(['viewer2D']).toJS();
|
|
@@ -1043,89 +1099,86 @@ function _handleExternalEvent() {
|
|
|
1043
1099
|
value.e -= moveValue;
|
|
1044
1100
|
return _context8.abrupt("continue", 18);
|
|
1045
1101
|
case 18:
|
|
1046
|
-
|
|
1047
|
-
return _context8.abrupt("continue",
|
|
1102
|
+
updateViwer2D(value, props.viewer2DActions);
|
|
1103
|
+
return _context8.abrupt("continue", 34);
|
|
1048
1104
|
case 19:
|
|
1049
1105
|
defaulTitle = 'Untitle';
|
|
1050
1106
|
props.projectActions.newProject();
|
|
1051
1107
|
props.projectActions.rename(defaulTitle);
|
|
1052
|
-
return _context8.abrupt("continue",
|
|
1108
|
+
return _context8.abrupt("continue", 34);
|
|
1053
1109
|
case 20:
|
|
1054
1110
|
_evt$payload6 = evt.payload, doorStyle = _evt$payload6.doorStyle, itemCDS = _evt$payload6.itemCDS, isAll = _evt$payload6.isAll;
|
|
1055
1111
|
props.itemsActions.setDoorStyle(doorStyle, itemCDS, isAll);
|
|
1056
|
-
return _context8.abrupt("continue",
|
|
1112
|
+
return _context8.abrupt("continue", 34);
|
|
1057
1113
|
case 21:
|
|
1058
1114
|
_doorStyle = evt.payload.doorStyle;
|
|
1059
1115
|
props.itemsActions.setInitialDoorStyle(_doorStyle.doorStyle);
|
|
1060
|
-
return _context8.abrupt("continue",
|
|
1116
|
+
return _context8.abrupt("continue", 34);
|
|
1061
1117
|
case 22:
|
|
1062
1118
|
props.projectActions.loadProject(evt.payload);
|
|
1063
|
-
return _context8.abrupt("continue",
|
|
1119
|
+
return _context8.abrupt("continue", 34);
|
|
1064
1120
|
case 23:
|
|
1065
1121
|
_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");
|
|
1122
|
+
_value.a += 0.1;
|
|
1123
|
+
_value.d += 0.1;
|
|
1124
|
+
_value.e -= _value.SVGWidth * 0.1 / 2;
|
|
1125
|
+
_value.f -= _value.SVGHeight * 0.1 / 2;
|
|
1126
|
+
updateViwer2D(_value, props.viewer2DActions);
|
|
1127
|
+
return _context8.abrupt("continue", 34);
|
|
1076
1128
|
case 24:
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1129
|
+
_value2 = state.getIn(['viewer2D']).toJS();
|
|
1130
|
+
_value2.a -= 0.1;
|
|
1131
|
+
_value2.d -= 0.1;
|
|
1132
|
+
_value2.e += _value2.SVGWidth * 0.1 / 2;
|
|
1133
|
+
_value2.f += _value2.SVGHeight * 0.1 / 2;
|
|
1134
|
+
updateViwer2D(_value2, props.viewer2DActions);
|
|
1135
|
+
return _context8.abrupt("continue", 34);
|
|
1082
1136
|
case 25:
|
|
1083
|
-
|
|
1084
|
-
|
|
1137
|
+
// calculate the bounding box of all elements in plan
|
|
1138
|
+
layer = state.scene.getIn(['layers', state.scene.selectedLayer]);
|
|
1139
|
+
bb = {
|
|
1140
|
+
minX: Infinity,
|
|
1141
|
+
maxX: -Infinity,
|
|
1142
|
+
minY: Infinity,
|
|
1143
|
+
maxY: -Infinity
|
|
1144
|
+
};
|
|
1145
|
+
bb = layer.vertices.reduce(function (pre, cur) {
|
|
1146
|
+
pre.minX = Math.min(pre.minX, cur.x);
|
|
1147
|
+
pre.maxX = Math.max(pre.maxX, cur.x);
|
|
1148
|
+
pre.minY = Math.min(pre.minY, cur.y);
|
|
1149
|
+
pre.maxY = Math.max(pre.maxY, cur.y);
|
|
1150
|
+
return pre;
|
|
1151
|
+
}, bb);
|
|
1152
|
+
w = bb.maxX - bb.minX;
|
|
1153
|
+
h = bb.maxY - bb.minY; // calc scale and offset to fit view
|
|
1154
|
+
viewer = state.getIn(['viewer2D']).toJS();
|
|
1155
|
+
if (w != 0 && Math.abs(w) != Infinity && h != 0 && Math.abs(h) != Infinity) {
|
|
1156
|
+
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;
|
|
1157
|
+
viewer.d = viewer.a;
|
|
1158
|
+
viewer.e = (viewer.viewerWidth - (bb.maxX + bb.minX) * viewer.a) / 2;
|
|
1159
|
+
viewer.f = (viewer.viewerHeight - (bb.maxY + bb.minY) * viewer.a) / 2;
|
|
1160
|
+
updateViwer2D(viewer, props.viewer2DActions);
|
|
1085
1161
|
}
|
|
1086
|
-
|
|
1087
|
-
_value.e += 0.1;
|
|
1088
|
-
}
|
|
1089
|
-
while (!(_value.f <= 80)) {
|
|
1090
|
-
_value.f -= 0.1;
|
|
1091
|
-
}
|
|
1092
|
-
while (!(_value.f + _value.a * _value.SVGHeight + 10 >= _value.viewerHeight)) {
|
|
1093
|
-
_value.f += 0.1;
|
|
1094
|
-
}
|
|
1095
|
-
if (compareSVGRect(_value)) props.viewer2DActions.updateCameraView(_value);
|
|
1096
|
-
return _context8.abrupt("continue", 35);
|
|
1162
|
+
return _context8.abrupt("continue", 34);
|
|
1097
1163
|
case 26:
|
|
1098
|
-
|
|
1099
|
-
|
|
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");
|
|
1164
|
+
props.projectActions.undo();
|
|
1165
|
+
return _context8.abrupt("continue", 34);
|
|
1109
1166
|
case 27:
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
break;
|
|
1113
|
-
}
|
|
1114
|
-
return _context8.abrupt("return");
|
|
1167
|
+
props.projectActions.redo();
|
|
1168
|
+
return _context8.abrupt("continue", 34);
|
|
1115
1169
|
case 28:
|
|
1116
|
-
|
|
1117
|
-
|
|
1170
|
+
_evt$payload7 = evt.payload, moldingInfo = _evt$payload7.moldingInfo, isGlobal = _evt$payload7.isGlobal;
|
|
1171
|
+
props.itemsActions.setMolding(moldingInfo, isGlobal);
|
|
1172
|
+
return _context8.abrupt("continue", 34);
|
|
1118
1173
|
case 29:
|
|
1119
|
-
|
|
1120
|
-
|
|
1174
|
+
distElement = getElement(evt.payload, state);
|
|
1175
|
+
if (distElement) props.itemsActions.duplicateSelected(distElement);
|
|
1176
|
+
return _context8.abrupt("continue", 34);
|
|
1121
1177
|
case 30:
|
|
1122
|
-
|
|
1123
|
-
|
|
1178
|
+
_distElement = getElement(evt.payload, state);
|
|
1179
|
+
if (_distElement) props.projectActions.remove(_distElement);
|
|
1180
|
+
return _context8.abrupt("continue", 34);
|
|
1124
1181
|
case 31:
|
|
1125
|
-
_evt$payload7 = evt.payload, moldingInfo = _evt$payload7.moldingInfo, isGlobal = _evt$payload7.isGlobal;
|
|
1126
|
-
props.itemsActions.setMolding(moldingInfo, isGlobal);
|
|
1127
|
-
return _context8.abrupt("continue", 35);
|
|
1128
|
-
case 32:
|
|
1129
1182
|
_evt$payload8 = evt.payload, option = _evt$payload8.option, _value3 = _evt$payload8.value;
|
|
1130
1183
|
if (option === _constants.PROJECT_SETTING_OPTION.UPDATE_CEIL_HEIGHT) {
|
|
1131
1184
|
props.viewer2DActions.updateCeilHeight(_value3);
|
|
@@ -1139,16 +1192,16 @@ function _handleExternalEvent() {
|
|
|
1139
1192
|
} else if (option === _constants.PROJECT_SETTING_OPTION.CHANGE_WINDOW_DOOR_MEASURE) {
|
|
1140
1193
|
props.viewer2DActions.changeWindowDoorMeasure(_value3);
|
|
1141
1194
|
}
|
|
1142
|
-
return _context8.abrupt("continue",
|
|
1143
|
-
case
|
|
1195
|
+
return _context8.abrupt("continue", 34);
|
|
1196
|
+
case 32:
|
|
1144
1197
|
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
|
|
1198
|
+
_layer = state.getIn(['scene', 'layers', layerId]);
|
|
1199
|
+
_layer$getIn = _layer.getIn(['selected']), selectedLines = _layer$getIn.lines, selectedHoles = _layer$getIn.holes, selectedItems = _layer$getIn.items;
|
|
1200
|
+
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);
|
|
1201
|
+
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);
|
|
1202
|
+
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);
|
|
1203
|
+
return _context8.abrupt("continue", 34);
|
|
1204
|
+
case 33:
|
|
1152
1205
|
// send scene object from 3DTool to HostApp using internalEvent
|
|
1153
1206
|
(_props$onInternalEven2 = props.onInternalEvent) === null || _props$onInternalEven2 === void 0 || _props$onInternalEven2.call(props, {
|
|
1154
1207
|
type: _constants.INTERNAL_EVENT_SYNC_SCENE,
|
|
@@ -1156,7 +1209,8 @@ function _handleExternalEvent() {
|
|
|
1156
1209
|
scene: state.scene.toJS()
|
|
1157
1210
|
}
|
|
1158
1211
|
});
|
|
1159
|
-
|
|
1212
|
+
return _context8.abrupt("continue", 34);
|
|
1213
|
+
case 34:
|
|
1160
1214
|
case "end":
|
|
1161
1215
|
return _context8.stop();
|
|
1162
1216
|
}
|