kitchen-simulator 1.0.0-alin.4 → 1.0.0-alin.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/LiteKitchenConfigurator.js +14 -3
- package/es/LiteRenderer.js +13 -105
- package/es/actions/items-actions.js +1 -2
- package/es/catalog/catalog.js +4 -1
- package/es/class/item.js +1 -1
- package/es/class/project.js +8 -1
- package/es/components/viewer2d/item.js +10 -10
- package/es/components/viewer2d/layer.js +1 -1
- package/es/components/viewer2d/line.js +20 -17
- package/es/components/viewer2d/viewer2d.js +19 -55
- package/es/components/viewer3d/viewer3d.js +0 -2
- package/es/constants.js +7 -1
- package/es/devLiteRenderer.js +71 -6
- package/es/index.js +15 -13
- package/es/reducers/items-reducer.js +1 -1
- package/es/utils/geometry.js +6 -6
- package/es/utils/isolate-event-handler.js +86 -19
- package/lib/LiteKitchenConfigurator.js +14 -3
- package/lib/LiteRenderer.js +14 -106
- package/lib/actions/items-actions.js +1 -2
- package/lib/catalog/catalog.js +4 -1
- package/lib/class/item.js +1 -1
- package/lib/class/project.js +8 -1
- package/lib/components/viewer2d/item.js +10 -10
- package/lib/components/viewer2d/layer.js +1 -1
- package/lib/components/viewer2d/line.js +19 -16
- package/lib/components/viewer2d/viewer2d.js +19 -55
- package/lib/components/viewer3d/viewer3d.js +0 -2
- package/lib/constants.js +11 -5
- package/lib/devLiteRenderer.js +70 -5
- package/lib/index.js +16 -13
- package/lib/reducers/items-reducer.js +1 -1
- package/lib/utils/geometry.js +6 -6
- package/lib/utils/isolate-event-handler.js +85 -18
- package/package.json +3 -3
|
@@ -103,7 +103,8 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
103
103
|
redirectURL: '',
|
|
104
104
|
snackBarMessage: '',
|
|
105
105
|
isSaved: false,
|
|
106
|
-
isLeaving: false
|
|
106
|
+
isLeaving: false,
|
|
107
|
+
stateCatalog: _this.props.catalog
|
|
107
108
|
};
|
|
108
109
|
|
|
109
110
|
// For UTM tracking
|
|
@@ -467,6 +468,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
467
468
|
}, {
|
|
468
469
|
key: "componentWillReceiveProps",
|
|
469
470
|
value: function componentWillReceiveProps(nextProps) {
|
|
471
|
+
var _oldState$catalog, _plannerState$catalog;
|
|
470
472
|
var stateExtractor = nextProps.stateExtractor,
|
|
471
473
|
state = nextProps.state,
|
|
472
474
|
projectActions = nextProps.projectActions,
|
|
@@ -475,9 +477,18 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
475
477
|
|
|
476
478
|
// handle external events
|
|
477
479
|
if (this.props.externalEvent !== externalEvent) {
|
|
478
|
-
handleExternalEvent(
|
|
480
|
+
handleExternalEvent(nextProps);
|
|
479
481
|
}
|
|
480
482
|
var plannerState = stateExtractor(state);
|
|
483
|
+
var oldState = stateExtractor(this.props.state);
|
|
484
|
+
if ((oldState === null || oldState === void 0 || (_oldState$catalog = oldState.catalog) === null || _oldState$catalog === void 0 ? void 0 : _oldState$catalog.elements) !== (plannerState === null || plannerState === void 0 || (_plannerState$catalog = plannerState.catalog) === null || _plannerState$catalog === void 0 ? void 0 : _plannerState$catalog.elements)) {
|
|
485
|
+
// copy state.catalog to the props.catalog
|
|
486
|
+
// let catalog = this.state.stateCatalog;
|
|
487
|
+
// console.log('111111', plannerState?.catalog?.elements.toJS());
|
|
488
|
+
// catalog.elements = plannerState?.catalog?.elements.toJS();
|
|
489
|
+
// console.log('222222', catalog);
|
|
490
|
+
// this.setState({ stateCatalog: catalog });
|
|
491
|
+
}
|
|
481
492
|
var catalogReady = plannerState.getIn(['catalog', 'ready']);
|
|
482
493
|
if (!catalogReady) {
|
|
483
494
|
projectActions.initCatalog(catalog);
|
|
@@ -573,7 +584,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
573
584
|
}, /*#__PURE__*/React.createElement(Content, _extends({
|
|
574
585
|
width: contentW,
|
|
575
586
|
height: contentH,
|
|
576
|
-
catalog: this.
|
|
587
|
+
catalog: this.state.stateCatalog,
|
|
577
588
|
state: extractedState,
|
|
578
589
|
toolBar: this.state.toolbar,
|
|
579
590
|
setToolbar: this.setToolbar,
|
package/es/LiteRenderer.js
CHANGED
|
@@ -249,8 +249,6 @@ export default function LiteRenderer(props) {
|
|
|
249
249
|
colorAlias = _ref.colorAlias,
|
|
250
250
|
subgroups = _ref.subgroups;
|
|
251
251
|
var _ref2 = dataBundle || {},
|
|
252
|
-
_ref2$data = _ref2.data,
|
|
253
|
-
data = _ref2$data === void 0 ? [] : _ref2$data,
|
|
254
252
|
_ref2$appliances = _ref2.appliances,
|
|
255
253
|
appliances = _ref2$appliances === void 0 ? [] : _ref2$appliances,
|
|
256
254
|
_ref2$furnishing = _ref2.furnishing,
|
|
@@ -262,14 +260,10 @@ export default function LiteRenderer(props) {
|
|
|
262
260
|
var id = configData.id,
|
|
263
261
|
logoImg = configData.logoImg,
|
|
264
262
|
companyUrl = configData.companyUrl;
|
|
265
|
-
var _React$useState = React.useState(
|
|
263
|
+
var _React$useState = React.useState(false),
|
|
266
264
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
var _React$useState3 = React.useState(false),
|
|
270
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
271
|
-
catalogInitiated = _React$useState4[0],
|
|
272
|
-
setCatalogInitiated = _React$useState4[1];
|
|
265
|
+
catalogInitiated = _React$useState2[0],
|
|
266
|
+
setCatalogInitiated = _React$useState2[1];
|
|
273
267
|
useEffect(function () {
|
|
274
268
|
var initMyCatalog = /*#__PURE__*/function () {
|
|
275
269
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
@@ -388,103 +382,27 @@ export default function LiteRenderer(props) {
|
|
|
388
382
|
return _ref4.apply(this, arguments);
|
|
389
383
|
};
|
|
390
384
|
}();
|
|
391
|
-
var loadSVGs = /*#__PURE__*/function () {
|
|
392
|
-
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
393
|
-
var svgLoadPromises, outlineData;
|
|
394
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
395
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
396
|
-
case 0:
|
|
397
|
-
svgLoadPromises = data.map(/*#__PURE__*/function () {
|
|
398
|
-
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(item) {
|
|
399
|
-
var _parsed$xml$viewBox, _parsed$xml$viewBox2, response, svgText, loader, parsed, _t;
|
|
400
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
401
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
402
|
-
case 0:
|
|
403
|
-
if (item.outline) {
|
|
404
|
-
_context3.next = 1;
|
|
405
|
-
break;
|
|
406
|
-
}
|
|
407
|
-
return _context3.abrupt("return", null);
|
|
408
|
-
case 1:
|
|
409
|
-
_context3.prev = 1;
|
|
410
|
-
_context3.next = 2;
|
|
411
|
-
return fetch(item.outline, {
|
|
412
|
-
cache: 'no-store'
|
|
413
|
-
});
|
|
414
|
-
case 2:
|
|
415
|
-
response = _context3.sent;
|
|
416
|
-
_context3.next = 3;
|
|
417
|
-
return response.text();
|
|
418
|
-
case 3:
|
|
419
|
-
svgText = _context3.sent;
|
|
420
|
-
loader = new SVGLoader();
|
|
421
|
-
parsed = loader.parse(svgText);
|
|
422
|
-
if (!isEmpty(parsed.paths)) {
|
|
423
|
-
_context3.next = 4;
|
|
424
|
-
break;
|
|
425
|
-
}
|
|
426
|
-
return _context3.abrupt("return", null);
|
|
427
|
-
case 4:
|
|
428
|
-
return _context3.abrupt("return", {
|
|
429
|
-
paths: parsed.paths,
|
|
430
|
-
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,
|
|
431
|
-
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,
|
|
432
|
-
reverse: !parseFloat(parsed.xml.getAttribute('height'))
|
|
433
|
-
});
|
|
434
|
-
case 5:
|
|
435
|
-
_context3.prev = 5;
|
|
436
|
-
_t = _context3["catch"](1);
|
|
437
|
-
console.error('Failed to load SVG:', item.outline, _t);
|
|
438
|
-
return _context3.abrupt("return", null);
|
|
439
|
-
case 6:
|
|
440
|
-
case "end":
|
|
441
|
-
return _context3.stop();
|
|
442
|
-
}
|
|
443
|
-
}, _callee3, null, [[1, 5]]);
|
|
444
|
-
}));
|
|
445
|
-
return function (_x3) {
|
|
446
|
-
return _ref6.apply(this, arguments);
|
|
447
|
-
};
|
|
448
|
-
}());
|
|
449
|
-
_context4.next = 1;
|
|
450
|
-
return Promise.all(svgLoadPromises);
|
|
451
|
-
case 1:
|
|
452
|
-
outlineData = _context4.sent;
|
|
453
|
-
setOutlineSVGData(outlineData);
|
|
454
|
-
case 2:
|
|
455
|
-
case "end":
|
|
456
|
-
return _context4.stop();
|
|
457
|
-
}
|
|
458
|
-
}, _callee4);
|
|
459
|
-
}));
|
|
460
|
-
return function loadSVGs() {
|
|
461
|
-
return _ref5.apply(this, arguments);
|
|
462
|
-
};
|
|
463
|
-
}();
|
|
464
385
|
var initCatalog = /*#__PURE__*/function () {
|
|
465
|
-
var
|
|
466
|
-
return _regeneratorRuntime.wrap(function (
|
|
467
|
-
while (1) switch (
|
|
386
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
387
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
388
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
468
389
|
case 0:
|
|
469
390
|
setCatalogInitiated(false);
|
|
470
|
-
|
|
391
|
+
_context3.next = 1;
|
|
471
392
|
return initMyCatalog();
|
|
472
393
|
case 1:
|
|
473
|
-
|
|
394
|
+
_context3.next = 2;
|
|
474
395
|
return loadMoldings();
|
|
475
396
|
case 2:
|
|
476
|
-
_context5.next = 3;
|
|
477
|
-
return loadSVGs();
|
|
478
|
-
case 3:
|
|
479
397
|
setCatalogInitiated(true);
|
|
480
|
-
case
|
|
398
|
+
case 3:
|
|
481
399
|
case "end":
|
|
482
|
-
return
|
|
400
|
+
return _context3.stop();
|
|
483
401
|
}
|
|
484
|
-
},
|
|
402
|
+
}, _callee3);
|
|
485
403
|
}));
|
|
486
404
|
return function initCatalog() {
|
|
487
|
-
return
|
|
405
|
+
return _ref5.apply(this, arguments);
|
|
488
406
|
};
|
|
489
407
|
}();
|
|
490
408
|
initCatalog();
|
|
@@ -493,16 +411,7 @@ export default function LiteRenderer(props) {
|
|
|
493
411
|
|
|
494
412
|
// Register items once SVGs are loaded
|
|
495
413
|
useEffect(function () {
|
|
496
|
-
if (!outlineSVGData.length) return;
|
|
497
414
|
var Item = [];
|
|
498
|
-
data.forEach(function (obj, index) {
|
|
499
|
-
Item.push(exporter(_objectSpread(_objectSpread({}, obj), {}, {
|
|
500
|
-
type: 'cabinet',
|
|
501
|
-
outlineSVGData: outlineSVGData[index],
|
|
502
|
-
render2DItem: render2DItem,
|
|
503
|
-
render3DItem: render3DItem
|
|
504
|
-
})));
|
|
505
|
-
});
|
|
506
415
|
appliances.forEach(function (obj) {
|
|
507
416
|
Item.push(exporter(_objectSpread(_objectSpread({}, obj), {}, {
|
|
508
417
|
render2DItem: render2DItem,
|
|
@@ -525,7 +434,7 @@ export default function LiteRenderer(props) {
|
|
|
525
434
|
})));
|
|
526
435
|
});
|
|
527
436
|
for (var x in Item) MyCatalog.registerElement(Item[x]);
|
|
528
|
-
}, [
|
|
437
|
+
}, [appliances, furnishing, lighting]);
|
|
529
438
|
useEffect(function () {
|
|
530
439
|
if (projectElement.length === 0) return;
|
|
531
440
|
if (!catalogInitiated) return;
|
|
@@ -556,7 +465,6 @@ export default function LiteRenderer(props) {
|
|
|
556
465
|
return state.get('KitchenConfigurator');
|
|
557
466
|
},
|
|
558
467
|
categoryData: categoryData,
|
|
559
|
-
data: data,
|
|
560
468
|
configData: configData,
|
|
561
469
|
externalEvent: externalEvent
|
|
562
470
|
}, passThrough)))));
|
|
@@ -223,11 +223,10 @@ export function updateItemsAltitude(layerID, itemID, value) {
|
|
|
223
223
|
value: value
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
|
-
export function setDoorStyle(doorStyle,
|
|
226
|
+
export function setDoorStyle(doorStyle, isAll) {
|
|
227
227
|
return {
|
|
228
228
|
type: SET_DOOR_STYLE,
|
|
229
229
|
doorStyle: doorStyle,
|
|
230
|
-
pathes: pathes,
|
|
231
230
|
isAll: isAll
|
|
232
231
|
};
|
|
233
232
|
}
|
package/es/catalog/catalog.js
CHANGED
|
@@ -247,7 +247,10 @@ var Catalog = /*#__PURE__*/function () {
|
|
|
247
247
|
if (name === '') {
|
|
248
248
|
throw new Error('Category has empty name');
|
|
249
249
|
}
|
|
250
|
-
|
|
250
|
+
if (this.hasCategory(name)) {
|
|
251
|
+
throw new Error('Category has already been registered');
|
|
252
|
+
}
|
|
253
|
+
return true;
|
|
251
254
|
}
|
|
252
255
|
|
|
253
256
|
/**
|
package/es/class/item.js
CHANGED
|
@@ -1164,7 +1164,7 @@ var Item = /*#__PURE__*/function () {
|
|
|
1164
1164
|
}
|
|
1165
1165
|
}, {
|
|
1166
1166
|
key: "setDoorStyle",
|
|
1167
|
-
value: function setDoorStyle(state, doorStyle,
|
|
1167
|
+
value: function setDoorStyle(state, doorStyle, isAll) {
|
|
1168
1168
|
var _this2 = this;
|
|
1169
1169
|
var keys = Object.keys(doorStyle.doorStyles);
|
|
1170
1170
|
keys = keys.filter(function (elem) {
|
package/es/class/project.js
CHANGED
|
@@ -478,6 +478,10 @@ var Project = /*#__PURE__*/function () {
|
|
|
478
478
|
};
|
|
479
479
|
}
|
|
480
480
|
var mode;
|
|
481
|
+
var isLineAction = false;
|
|
482
|
+
if (state.mode.includes('LINE')) {
|
|
483
|
+
isLineAction = true;
|
|
484
|
+
}
|
|
481
485
|
if (state.mode == MODE_DRAWING_ITEM_3D) {
|
|
482
486
|
mode = MODE_IDLE_3D;
|
|
483
487
|
if (state.drawingSupport.has('currentID')) state = Layer.removeElement(state, state.scene.selectedLayer, 'items', state.drawingSupport.get('currentID')).updatedState;
|
|
@@ -520,6 +524,9 @@ var Project = /*#__PURE__*/function () {
|
|
|
520
524
|
draggingSupport: new Map(),
|
|
521
525
|
rotatingSupport: new Map()
|
|
522
526
|
});
|
|
527
|
+
if (isLineAction) {
|
|
528
|
+
state = Line.applyWallChanges(state, END_DRAWING_LINE).updatedState;
|
|
529
|
+
}
|
|
523
530
|
return {
|
|
524
531
|
updatedState: state
|
|
525
532
|
};
|
|
@@ -604,7 +611,7 @@ var Project = /*#__PURE__*/function () {
|
|
|
604
611
|
updatedState: state
|
|
605
612
|
};
|
|
606
613
|
} catch (error) {
|
|
607
|
-
console.log('
|
|
614
|
+
console.log('addElementToCatalogError', error);
|
|
608
615
|
return {
|
|
609
616
|
updatedState: state
|
|
610
617
|
};
|
|
@@ -6,6 +6,7 @@ import { convert } from "../../utils/convert-units-lite";
|
|
|
6
6
|
import { GeometryUtils } from "../../utils/export";
|
|
7
7
|
import { MODE_ROTATING_ITEM, WALL_CABINET_LAYOUTPOS } from "../../constants";
|
|
8
8
|
import { isEmpty, returnReplaceableDeepSearchType } from "./utils";
|
|
9
|
+
import { findCatalogElement } from "../../utils/geometry";
|
|
9
10
|
var STYLE_LINE = {
|
|
10
11
|
fill: '#0096fd',
|
|
11
12
|
stroke: '#0096fd'
|
|
@@ -21,6 +22,7 @@ var STYLE_CIRCLE2 = {
|
|
|
21
22
|
cursor: 'ew-resize'
|
|
22
23
|
};
|
|
23
24
|
export default function Item(_ref, _ref2) {
|
|
25
|
+
var _element$render2D;
|
|
24
26
|
var layer = _ref.layer,
|
|
25
27
|
item = _ref.item,
|
|
26
28
|
scene = _ref.scene,
|
|
@@ -29,7 +31,8 @@ export default function Item(_ref, _ref2) {
|
|
|
29
31
|
var itemsActions = _ref2.itemsActions;
|
|
30
32
|
var x = item.x,
|
|
31
33
|
y = item.y,
|
|
32
|
-
rotation = item.rotation
|
|
34
|
+
rotation = item.rotation,
|
|
35
|
+
id = item.id;
|
|
33
36
|
var showBaseCabinetMeasure = scene.showBaseCabinetMeasure,
|
|
34
37
|
showWallCabinetMeasure = scene.showWallCabinetMeasure;
|
|
35
38
|
var vertices = layer.vertices;
|
|
@@ -116,12 +119,7 @@ export default function Item(_ref, _ref2) {
|
|
|
116
119
|
if (layer.selected.items.size > 0) {
|
|
117
120
|
selectedItem = layer.getIn(['items', layer.selected.items.get(0)]);
|
|
118
121
|
var catid = selectedItem.type;
|
|
119
|
-
var cat = catalog
|
|
120
|
-
if (!cat) cat = catalog.elements[returnReplaceableDeepSearchType(catid)];
|
|
121
|
-
if (cat === undefined || cat === null) {
|
|
122
|
-
cat = catalog.getIn(['elements', catid]);
|
|
123
|
-
if (!cat) cat = catalog.getIn(['elements', returnReplaceableDeepSearchType(catid)]);
|
|
124
|
-
}
|
|
122
|
+
var cat = findCatalogElement(catalog, catid);
|
|
125
123
|
currentItem = {
|
|
126
124
|
selectedItem: selectedItem,
|
|
127
125
|
cat: cat
|
|
@@ -136,8 +134,7 @@ export default function Item(_ref, _ref2) {
|
|
|
136
134
|
rotRad: item.rotation / 180 * Math.PI
|
|
137
135
|
};
|
|
138
136
|
var catid = item.type;
|
|
139
|
-
var cat = catalog
|
|
140
|
-
if (!cat) cat = catalog.elements[returnReplaceableDeepSearchType(catid)];
|
|
137
|
+
var cat = findCatalogElement(catalog, catid);
|
|
141
138
|
var width = convert(item.properties.getIn(['width', '_length'])).from('in').to('cm');
|
|
142
139
|
var height = convert(item.properties.getIn(['depth', '_length'])).from('in').to('cm');
|
|
143
140
|
// let width = cat.info.sizeinfo.width;
|
|
@@ -281,6 +278,9 @@ export default function Item(_ref, _ref2) {
|
|
|
281
278
|
PointArray.forEach(function (pointElement, index) {
|
|
282
279
|
if (pointElement[0] == undefined) PointArray[index][0] = 0;
|
|
283
280
|
});
|
|
281
|
+
if (Array.isArray(PointArray)) {
|
|
282
|
+
itemsActions.storeDistArray(layerID, id, PointArray);
|
|
283
|
+
}
|
|
284
284
|
var renderedRuler = [];
|
|
285
285
|
var ep = 0.1;
|
|
286
286
|
if (item.selected) {
|
|
@@ -310,7 +310,7 @@ export default function Item(_ref, _ref2) {
|
|
|
310
310
|
}
|
|
311
311
|
});
|
|
312
312
|
}
|
|
313
|
-
var renderedItem = element.render2D.call(element, item, layer, scene);
|
|
313
|
+
var renderedItem = element === null || element === void 0 || (_element$render2D = element.render2D) === null || _element$render2D === void 0 ? void 0 : _element$render2D.call(element, item, layer, scene);
|
|
314
314
|
var isSmall = false;
|
|
315
315
|
if (width < 40) isSmall = true;
|
|
316
316
|
var parts = [];
|
|
@@ -137,7 +137,7 @@ export default function Layer(_ref) {
|
|
|
137
137
|
unit: unit,
|
|
138
138
|
catalog: catalog
|
|
139
139
|
});
|
|
140
|
-
}),
|
|
140
|
+
}), itemData, itemWall, lineData, itemSelected, mode !== MODE_DRAWING_LINE && vertices.valueSeq().filter(function (v) {
|
|
141
141
|
return v.selected;
|
|
142
142
|
}).map(function (vertex) {
|
|
143
143
|
return /*#__PURE__*/React.createElement(Vertex, {
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { GeometryUtils } from "../../utils/export";
|
|
4
4
|
import Ruler from "./ruler";
|
|
5
|
-
import { BASE_CABINET_LAYOUTPOS, LINE_THICKNESS, WALL_CABINET_LAYOUTPOS } from "../../constants";
|
|
5
|
+
import { BASE_CABINET_LAYOUTPOS, LINE_THICKNESS, MODE_DRAGGING_LINE, MODE_DRAWING_LINE, WALL_CABINET_LAYOUTPOS, MAX_ANGLE_SCALE } from "../../constants";
|
|
6
6
|
import * as Three from 'three';
|
|
7
7
|
import { isEmpty } from "./utils";
|
|
8
8
|
var STYLE = {
|
|
@@ -21,7 +21,7 @@ var STYLE_TEXT = {
|
|
|
21
21
|
textAnchor: 'middle',
|
|
22
22
|
fontSize: '7px',
|
|
23
23
|
fontWeight: 'middle',
|
|
24
|
-
fontFamily: "'
|
|
24
|
+
fontFamily: "'Courier New', Courier, monospace"
|
|
25
25
|
};
|
|
26
26
|
export function compareVertices(v0, v1) {
|
|
27
27
|
return v0.x === v1.x ? v0.y - v1.y : v0.x - v1.x;
|
|
@@ -710,22 +710,32 @@ export default function Line(_ref) {
|
|
|
710
710
|
"data-layer": layer.id,
|
|
711
711
|
"data-length": length
|
|
712
712
|
}, showWallLengthMeasure ? renderedRuler : null), line.selected && angleVertices.map(function (vertex, index) {
|
|
713
|
+
var _relateLineLengthArra2;
|
|
713
714
|
var lineGroup = vertex[0].lines;
|
|
714
715
|
var angles = [];
|
|
715
716
|
var thickness = [];
|
|
716
717
|
var vectories = [];
|
|
718
|
+
var relateLineLengthArray = [];
|
|
719
|
+
|
|
717
720
|
// get the vector of lines
|
|
718
721
|
lineGroup.forEach(function (line) {
|
|
722
|
+
var _relateLineLengthArra;
|
|
719
723
|
line = layer.lines.get(line);
|
|
720
724
|
var vertex0 = layer.vertices.get(line.vertices.get(0));
|
|
721
725
|
var vertex1 = layer.vertices.get(line.vertices.get(1));
|
|
722
726
|
var vec = vertex0 === vertex[0] ? new Three.Vector2(vertex1.x - vertex0.x, vertex1.y - vertex0.y) : new Three.Vector2(vertex0.x - vertex1.x, vertex0.y - vertex1.y);
|
|
727
|
+
(_relateLineLengthArra = relateLineLengthArray) === null || _relateLineLengthArra === void 0 || _relateLineLengthArra.push(GeometryUtils.verticesDistance(vertex0, vertex1));
|
|
723
728
|
var angle = vec.angle();
|
|
724
729
|
var thick = 15;
|
|
725
730
|
angles.push(angle);
|
|
726
731
|
thickness.push(thick);
|
|
727
732
|
vectories.push(vec.normalize());
|
|
728
733
|
});
|
|
734
|
+
relateLineLengthArray = (_relateLineLengthArra2 = relateLineLengthArray) === null || _relateLineLengthArra2 === void 0 ? void 0 : _relateLineLengthArra2.sort(function (a, b) {
|
|
735
|
+
return a - b;
|
|
736
|
+
});
|
|
737
|
+
var minLineLength = relateLineLengthArray[0] < MAX_ANGLE_SCALE * 2 ? relateLineLengthArray[0] / 2 // scale down to half of the smallest adjacent surface
|
|
738
|
+
: MAX_ANGLE_SCALE;
|
|
729
739
|
|
|
730
740
|
// calculate the angle between two lines
|
|
731
741
|
var center = new Three.Vector2(vertex[0].x, vertex[0].y);
|
|
@@ -744,16 +754,15 @@ export default function Line(_ref) {
|
|
|
744
754
|
var rotDir = vec1.cross(vec2) > 0; // true: rotate CCW, false: rotate CW
|
|
745
755
|
|
|
746
756
|
// Angle Text Position
|
|
747
|
-
|
|
748
757
|
var angleTextO = center.clone();
|
|
749
|
-
var textTranslation = vec1.clone().add(vec2).normalize().multiplyScalar(
|
|
758
|
+
var textTranslation = vec1.clone().add(vec2).normalize().multiplyScalar(minLineLength * 2 / 3);
|
|
750
759
|
angleTextO.add(textTranslation);
|
|
751
|
-
angleTextO.y -=
|
|
752
|
-
|
|
760
|
+
angleTextO.y -= minLineLength / 10; // half the height of text `angle`
|
|
761
|
+
angleTextO.x += minLineLength / 10;
|
|
753
762
|
var tx = 0;
|
|
754
763
|
var ty = 0;
|
|
755
|
-
vec = vec.multiplyScalar(
|
|
756
|
-
vec1 = vec1.multiplyScalar(
|
|
764
|
+
vec = vec.multiplyScalar(minLineLength);
|
|
765
|
+
vec1 = vec1.multiplyScalar(minLineLength);
|
|
757
766
|
var cen1 = center.clone(),
|
|
758
767
|
cen2 = center.clone();
|
|
759
768
|
center = center.add(vec);
|
|
@@ -766,7 +775,7 @@ export default function Line(_ref) {
|
|
|
766
775
|
// Angle SVG Path
|
|
767
776
|
lines.push(/*#__PURE__*/React.createElement("path", {
|
|
768
777
|
style: STYLE_ANGLE,
|
|
769
|
-
d: "\n M ".concat(vertex[0].x, ",").concat(vertex[0].y, " L ").concat(pos1.x, ",").concat(pos1.y, " A
|
|
778
|
+
d: "\n M ".concat(vertex[0].x, ",").concat(vertex[0].y, " L ").concat(pos1.x, ",").concat(pos1.y, " A ").concat(minLineLength, " ").concat(minLineLength, " ").concat(angle, " 0 ").concat(t > 0 ? 1 : 0, " ").concat(pos2.x, ",").concat(pos2.y, " z\n ")
|
|
770
779
|
}));
|
|
771
780
|
var length = angle;
|
|
772
781
|
// draw angle and angle text
|
|
@@ -780,15 +789,9 @@ export default function Line(_ref) {
|
|
|
780
789
|
"data-id": [vertex[0].id, vertex[1].id, rotDir],
|
|
781
790
|
"data-length": length
|
|
782
791
|
}, lines, /*#__PURE__*/React.createElement("text", {
|
|
783
|
-
transform: "translate(".concat(angleTextO.x, ", ").concat(angleTextO.y, ") scale(
|
|
792
|
+
transform: "translate(".concat(angleTextO.x, ", ").concat(angleTextO.y, ") scale(").concat(minLineLength / 20, ", ").concat(-minLineLength / 20, ")"),
|
|
784
793
|
style: STYLE_TEXT
|
|
785
|
-
}, angle
|
|
786
|
-
transform: "translate(".concat(angleTextO.x, ", ").concat(angleTextO.y, ") translate(10, 9)"),
|
|
787
|
-
fill: "transparent",
|
|
788
|
-
stroke: "rgb(77, 77, 77)",
|
|
789
|
-
strokeWidth: 1,
|
|
790
|
-
r: 2
|
|
791
|
-
}));
|
|
794
|
+
}, angle + '° '));
|
|
792
795
|
}), showWindowDoorMeasure ? renderedAllRuler : null, showBaseCabinetMeasure ? baseRuler : null, showWallCabinetMeasure ? wallRuler : null, /*#__PURE__*/React.createElement("g", {
|
|
793
796
|
"data-element-root": true,
|
|
794
797
|
"data-prototype": line.prototype,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
3
|
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; }
|
|
@@ -536,48 +535,18 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
536
535
|
rectCenterPoint: [[point(mx, my), 180], [point(m1x, m1y), -90], [point(m2x, m2y), 0], [point(m3x, m3y), 90]]
|
|
537
536
|
};
|
|
538
537
|
};
|
|
539
|
-
var
|
|
540
|
-
var
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
x: x,
|
|
552
|
-
y: y
|
|
553
|
-
},
|
|
554
|
-
rotRad: rotation / 180 * Math.PI
|
|
555
|
-
};
|
|
556
|
-
var _width = getProperties(item, 'width');
|
|
557
|
-
var depth = getProperties(item, 'depth');
|
|
558
|
-
val.size = {
|
|
559
|
-
width: _width,
|
|
560
|
-
height: depth
|
|
561
|
-
};
|
|
562
|
-
|
|
563
|
-
// collect geometry
|
|
564
|
-
var _allLines = GeometryUtils.getAllLines(layer) || [];
|
|
565
|
-
var _allLineRects = GeometryUtils.buildRectFromLines(layer, _allLines) || [];
|
|
566
|
-
var _allItemRect = GeometryUtils.getAllItems(scene, catalog, _allLineRects) || {
|
|
567
|
-
others: []
|
|
568
|
-
};
|
|
569
|
-
var _allRect = [].concat(_toConsumableArray(_allItemRect.others || []), _toConsumableArray(_allLineRects));
|
|
570
|
-
|
|
571
|
-
// current item
|
|
572
|
-
var curItemInfo = getCalcRectFromItem(val);
|
|
573
|
-
var pointArray = getDistant(x, y, val.rotRad, curItemInfo, _allRect);
|
|
574
|
-
|
|
575
|
-
// store results safely
|
|
576
|
-
if (Array.isArray(pointArray)) {
|
|
577
|
-
itemsActions.storeDistArray(layerID, id, pointArray);
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
});
|
|
538
|
+
var getConnectedLines = function getConnectedLines() {
|
|
539
|
+
var _state$getIn;
|
|
540
|
+
var vertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
|
|
541
|
+
var lines = state.getIn(['scene', 'layers', layerID, 'lines']).toJS();
|
|
542
|
+
var lineID = state.getIn(['scene', 'layers', layerID, 'selected', 'lines']).first();
|
|
543
|
+
var drawingLine = (_state$getIn = state.getIn(['scene', 'layers', layerID, 'lines', lineID])) === null || _state$getIn === void 0 ? void 0 : _state$getIn.toJS();
|
|
544
|
+
// get the lines that have same points with drawing line.
|
|
545
|
+
if (!isEmpty(drawingLine)) {
|
|
546
|
+
var tlines = [];
|
|
547
|
+
getRelatedLines(tlines, drawingLine, vertices, lines);
|
|
548
|
+
setRelatedLines(tlines);
|
|
549
|
+
}
|
|
581
550
|
};
|
|
582
551
|
var onMouseMove = function onMouseMove(viewerEvent) {
|
|
583
552
|
//workaround that allow imageful component to work
|
|
@@ -627,7 +596,6 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
627
596
|
holesActions.updateDrawingHole(layerID, x, y);
|
|
628
597
|
break;
|
|
629
598
|
case constants.MODE_DRAWING_ITEM:
|
|
630
|
-
calcDistanceArray();
|
|
631
599
|
var _layer = scene.layers.get(layerID);
|
|
632
600
|
var flag = false;
|
|
633
601
|
_layer.items.some(function (item) {
|
|
@@ -713,11 +681,11 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
713
681
|
break;
|
|
714
682
|
case constants.MODE_DRAGGING_VERTEX:
|
|
715
683
|
var vertices = state.getIn(['scene', 'layers', layerID, 'vertices']).toJS();
|
|
684
|
+
getConnectedLines();
|
|
716
685
|
var result = getEndPoint(vertices, x, y, 'DRAGGING_VERTEX');
|
|
717
686
|
verticesActions.updateDraggingVertex(result.x, result.y, state.snapMask);
|
|
718
687
|
break;
|
|
719
688
|
case constants.MODE_DRAGGING_ITEM:
|
|
720
|
-
calcDistanceArray();
|
|
721
689
|
prepareSnap();
|
|
722
690
|
var _GeometryUtils$calcSn2 = GeometryUtils.calcSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allArea),
|
|
723
691
|
nx = _GeometryUtils$calcSn2.nx,
|
|
@@ -889,10 +857,10 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
889
857
|
projectActions.setMode(_mode);
|
|
890
858
|
break;
|
|
891
859
|
} else {
|
|
892
|
-
var
|
|
893
|
-
var
|
|
894
|
-
getRelatedLines(
|
|
895
|
-
setRelatedLines(
|
|
860
|
+
var tlines = [];
|
|
861
|
+
var drawingLine = state.getIn(['scene', 'layers', layerID, 'lines', elementData.id]).toJS();
|
|
862
|
+
getRelatedLines(tlines, drawingLine, vertices, lines);
|
|
863
|
+
setRelatedLines(tlines);
|
|
896
864
|
linesActions.selectLine(elementData.layer, elementData.id);
|
|
897
865
|
break;
|
|
898
866
|
}
|
|
@@ -1178,12 +1146,7 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
1178
1146
|
// if (dx > dy) y = prevVertex.y
|
|
1179
1147
|
// else x = prevVertex.x;
|
|
1180
1148
|
setdrawStart(true);
|
|
1181
|
-
|
|
1182
|
-
var drawingLine = state.getIn(['scene', 'layers', layerID, 'lines', lineID]).toJS();
|
|
1183
|
-
// get the lines that have same points with drawing line.
|
|
1184
|
-
var tlines = [];
|
|
1185
|
-
getRelatedLines(tlines, drawingLine, vertices, lines);
|
|
1186
|
-
setRelatedLines(tlines);
|
|
1149
|
+
getConnectedLines();
|
|
1187
1150
|
var endInfor = getEndPoint(vertices, x, y, 'END_DRAWIN_LINE');
|
|
1188
1151
|
linesActions.endDrawingLine(endInfor.x, endInfor.y, state.snapMask);
|
|
1189
1152
|
linesActions.beginDrawingLine(layerID, endInfor.x, endInfor.y, state.snapMask);
|
|
@@ -1198,6 +1161,7 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
1198
1161
|
linesActions.endDraggingLine(x, y, relatedLines, state.snapMask);
|
|
1199
1162
|
break;
|
|
1200
1163
|
case constants.MODE_DRAGGING_VERTEX:
|
|
1164
|
+
getConnectedLines();
|
|
1201
1165
|
var result = getEndPoint(vertices, x, y, 'DRAGGING_VERTEX');
|
|
1202
1166
|
verticesActions.endDraggingVertex(result.x, result.y, state.snapMask);
|
|
1203
1167
|
break;
|
|
@@ -2559,7 +2559,6 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
2559
2559
|
}));
|
|
2560
2560
|
} else {
|
|
2561
2561
|
document.getElementById('front') && (document.getElementById('front').style.display = 'none');
|
|
2562
|
-
document.getElementById('error').style.display = 'none';
|
|
2563
2562
|
this.renderer.domElement.style.display = 'none';
|
|
2564
2563
|
return /*#__PURE__*/React.createElement("div", {
|
|
2565
2564
|
style: {
|
|
@@ -2594,7 +2593,6 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
2594
2593
|
alt: "img"
|
|
2595
2594
|
}));
|
|
2596
2595
|
} else {
|
|
2597
|
-
!this.props.downloadFlag && (document.getElementById('error').style.display = 'block');
|
|
2598
2596
|
this.renderer.domElement.style.pointerEvents = 'auto';
|
|
2599
2597
|
this.renderer.domElement.style.opacity = '1';
|
|
2600
2598
|
!this.props.downloadFlag && document.getElementById('front') && (document.getElementById('front').style.display = 'block');
|
package/es/constants.js
CHANGED
|
@@ -579,6 +579,7 @@ export var ANIMATE_OBJECT_OPEN_DOOR_ROTATION_UNIT = 0.1;
|
|
|
579
579
|
export var DIFFERENT_VALUES_PATH_LENGTH = 5;
|
|
580
580
|
export var MIN_ANGLE_DISALLOW_DRAW_WALL = 45;
|
|
581
581
|
export var UNIT_ANGLE = 5;
|
|
582
|
+
export var MAX_ANGLE_SCALE = 30;
|
|
582
583
|
export var HDR_URLS = ['px.hdr', 'nx.hdr', 'py.hdr', 'ny.hdr', 'pz.hdr', 'nz.hdr'];
|
|
583
584
|
export var SUBMIT_REQUEST_ASSIST = 'submit';
|
|
584
585
|
export var SUBMIT_ADD_CART = 'addCart';
|
|
@@ -650,4 +651,9 @@ export var EXTERNAL_EVENT_TOGGLE_TO_ELEVATION = 'EXTERNAL_EVENT_TOGGLE_TO_ELEVAT
|
|
|
650
651
|
export var EXTERNAL_EVENT_ADD_WALL = 'EXTERNAL_EVENT_ADD_WALL';
|
|
651
652
|
export var EXTERNAL_EVENT_ADD_ITEM = 'EXTERNAL_EVENT_ADD_ITEM';
|
|
652
653
|
export var EXTERNAL_EVENT_MOVE_PAN = 'EXTERNAL_EVENT_MOVE_PAN';
|
|
653
|
-
export var EXTERNAL_EVENT_NEW_PROJECT = 'EXTERNAL_EVENT_NEW_PROJECT';
|
|
654
|
+
export var EXTERNAL_EVENT_NEW_PROJECT = 'EXTERNAL_EVENT_NEW_PROJECT';
|
|
655
|
+
export var EXTERNAL_EVENT_CHANGE_DOORSTYLE = 'EXTERNAL_EVENT_CHANGE_DOORSTYLE';
|
|
656
|
+
export var EXTERNAL_EVENT_SET_INITIAL_DATA = 'EXTERNAL_EVENT_SET_INITIAL_DATA';
|
|
657
|
+
export var EXTERNAL_EVENT_ADD_ROOM_SHAPE = 'EXTERNAL_EVENT_ADD_ROOM_SHAPE';
|
|
658
|
+
export var EXTERNAL_EVENT_ZOOM_IN = 'EXTERNAL_EVENT_ZOOM_IN';
|
|
659
|
+
export var EXTERNAL_EVENT_ZOOM_OUT = 'EXTERNAL_EVENT_ZOOM_OUT';
|