kitchen-simulator 3.1.14 → 4.0.0-alpha.12
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 +204 -24
- package/es/LiteRenderer.js +277 -12
- package/es/actions/items-actions.js +6 -10
- package/es/actions/lines-actions.js +1 -3
- package/es/actions/project-actions.js +5 -15
- package/es/assets/Window.hdr +2100 -0
- package/es/assets/gltf/door_sliding.bin +0 -0
- package/es/assets/img/1.jpg +0 -0
- package/es/catalog/areas/area/planner-element.js +5 -10
- package/es/catalog/catalog.js +4 -1
- package/es/catalog/factories/area-factory-3d.js +17 -18
- package/es/catalog/factories/wall-factory-3d.js +2 -2
- package/es/catalog/factories/wall-factory.js +8 -8
- package/es/catalog/lines/wall/planner-element.js +9 -18
- package/es/catalog/utils/exporter.js +3 -6
- package/es/catalog/utils/item-loader.js +197 -202
- package/es/catalog/utils/mtl-loader.js +2 -2
- package/es/catalog/utils/obj-loader.js +2 -2
- package/es/class/item.js +127 -107
- package/es/class/line.js +2 -14
- package/es/class/project.js +44 -150
- package/es/components/content.js +6 -19
- package/es/components/viewer2d/grids/grid-streak.js +1 -1
- package/es/components/viewer2d/item.js +51 -84
- package/es/components/viewer2d/line.js +243 -315
- package/es/components/viewer2d/ruler.js +36 -16
- package/es/components/viewer2d/rulerDist.js +75 -44
- package/es/components/viewer2d/utils.js +0 -6
- package/es/components/viewer2d/viewer2d.js +205 -301
- package/es/components/viewer3d/front3D.js +2 -3
- package/es/components/viewer3d/libs/mtl-loader.js +2 -2
- package/es/components/viewer3d/libs/obj-loader.js +2 -2
- package/es/components/viewer3d/libs/orbit-controls.js +4 -3
- package/es/components/viewer3d/libs/pointer-lock-controls.js +7 -6
- package/es/components/viewer3d/viewer3d.js +80 -127
- package/es/constants.js +3 -110
- package/es/devLiteRenderer.js +38 -597
- package/es/index.js +86 -16
- package/es/models.js +5 -8
- package/es/plugins/SVGLoader.js +5 -7
- package/es/plugins/keyboard.js +6 -15
- package/es/reducers/items-reducer.js +5 -5
- package/es/reducers/lines-reducer.js +1 -1
- package/es/reducers/project-reducer.js +3 -5
- package/es/shared-style.js +4 -4
- package/es/utils/geometry.js +0 -161
- package/es/utils/get-edges-of-subgraphs.js +1 -1
- package/es/utils/graph-cycles.js +1 -1
- package/es/utils/graph.js +1 -1
- package/es/utils/helper.js +2 -67
- package/es/utils/isolate-event-handler.js +124 -1367
- package/es/utils/molding.js +2 -238
- package/lib/LiteKitchenConfigurator.js +205 -25
- package/lib/LiteRenderer.js +278 -13
- package/lib/actions/items-actions.js +6 -10
- package/lib/actions/lines-actions.js +1 -3
- package/lib/actions/project-actions.js +4 -15
- package/lib/assets/Window.hdr +2100 -0
- package/lib/assets/gltf/door_sliding.bin +0 -0
- package/lib/assets/img/1.jpg +0 -0
- package/lib/catalog/areas/area/planner-element.js +5 -11
- package/lib/catalog/catalog.js +4 -1
- package/lib/catalog/factories/area-factory-3d.js +14 -15
- package/lib/catalog/factories/wall-factory-3d.js +2 -2
- package/lib/catalog/factories/wall-factory.js +8 -8
- package/lib/catalog/lines/wall/planner-element.js +9 -19
- package/lib/catalog/utils/exporter.js +3 -6
- package/lib/catalog/utils/item-loader.js +194 -199
- package/lib/catalog/utils/mtl-loader.js +2 -9
- package/lib/catalog/utils/obj-loader.js +2 -10
- package/lib/class/item.js +125 -105
- package/lib/class/line.js +1 -13
- package/lib/class/project.js +43 -149
- package/lib/components/content.js +6 -19
- package/lib/components/viewer2d/grids/grid-streak.js +1 -1
- package/lib/components/viewer2d/item.js +50 -83
- package/lib/components/viewer2d/line.js +242 -315
- package/lib/components/viewer2d/ruler.js +35 -15
- package/lib/components/viewer2d/rulerDist.js +75 -44
- package/lib/components/viewer2d/utils.js +0 -7
- package/lib/components/viewer2d/viewer2d.js +205 -299
- package/lib/components/viewer3d/front3D.js +2 -3
- package/lib/components/viewer3d/libs/mtl-loader.js +2 -9
- package/lib/components/viewer3d/libs/obj-loader.js +2 -9
- package/lib/components/viewer3d/libs/orbit-controls.js +5 -11
- package/lib/components/viewer3d/libs/pointer-lock-controls.js +7 -13
- package/lib/components/viewer3d/viewer3d.js +79 -125
- package/lib/constants.js +7 -115
- package/lib/devLiteRenderer.js +33 -592
- package/lib/index.js +86 -16
- package/lib/models.js +5 -8
- package/lib/plugins/SVGLoader.js +5 -7
- package/lib/plugins/keyboard.js +6 -15
- package/lib/reducers/items-reducer.js +5 -5
- package/lib/reducers/lines-reducer.js +1 -1
- package/lib/reducers/project-reducer.js +2 -4
- package/lib/shared-style.js +4 -4
- package/lib/utils/geometry.js +0 -162
- package/lib/utils/get-edges-of-subgraphs.js +1 -6
- package/lib/utils/graph-cycles.js +8 -7
- package/lib/utils/graph.js +1 -6
- package/lib/utils/helper.js +3 -70
- package/lib/utils/isolate-event-handler.js +121 -1364
- package/lib/utils/molding.js +0 -238
- package/package.json +1 -1
package/es/class/project.js
CHANGED
|
@@ -10,8 +10,7 @@ import { State, Catalog, Scene, safeLoadMapList, CatalogElement } from "../model
|
|
|
10
10
|
import { GeometryUtils, history } from "../utils/export";
|
|
11
11
|
import { Layer, Group, Line, Hole, Item, Area, HorizontalGuide, VerticalGuide } from "../class/export";
|
|
12
12
|
import * as viewer2DActions from "../actions/viewer2d-actions";
|
|
13
|
-
import {
|
|
14
|
-
import { convert } from "../utils/convert-units-lite";
|
|
13
|
+
import { isEmpty } from "../utils/helper";
|
|
15
14
|
var Project = /*#__PURE__*/function () {
|
|
16
15
|
function Project() {
|
|
17
16
|
_classCallCheck(this, Project);
|
|
@@ -35,6 +34,7 @@ var Project = /*#__PURE__*/function () {
|
|
|
35
34
|
key: "newProject",
|
|
36
35
|
value: function newProject(state) {
|
|
37
36
|
var doorStyle = state.toJS().doorStyle === null ? null : state.toJS().doorStyle;
|
|
37
|
+
var oStyle = state.oStyle;
|
|
38
38
|
// let counterTop = state.getIn(['scene', 'layers', layerID, 'counterTop']);
|
|
39
39
|
// let floorStyle = state.getIn(['scene', 'layers', layerID, 'floorStyle']);
|
|
40
40
|
var _viewer2D = state.viewer2D;
|
|
@@ -48,6 +48,7 @@ var Project = /*#__PURE__*/function () {
|
|
|
48
48
|
state = new State({});
|
|
49
49
|
state = state.merge({
|
|
50
50
|
doorStyle: doorStyle,
|
|
51
|
+
oStyle: oStyle,
|
|
51
52
|
viewer2D: _viewer2D
|
|
52
53
|
});
|
|
53
54
|
// state = Item.setCounterTop(state, counterTop).updatedState;
|
|
@@ -58,8 +59,9 @@ var Project = /*#__PURE__*/function () {
|
|
|
58
59
|
}
|
|
59
60
|
}, {
|
|
60
61
|
key: "loadProject",
|
|
61
|
-
value: function loadProject(state, sceneJSON) {
|
|
62
|
+
value: function loadProject(state, sceneJSON, categoryData) {
|
|
62
63
|
var doorStyle = state.doorStyle;
|
|
64
|
+
var oStyle = state.oStyle;
|
|
63
65
|
var layerID = state.scene.selectedLayer;
|
|
64
66
|
var _viewer2D = state.viewer2D;
|
|
65
67
|
var viewer = state.viewer2D.toJS();
|
|
@@ -91,17 +93,6 @@ var Project = /*#__PURE__*/function () {
|
|
|
91
93
|
for (var x in json_items) {
|
|
92
94
|
_loop(x);
|
|
93
95
|
}
|
|
94
|
-
|
|
95
|
-
// making layer's doorStyle when changing room shape
|
|
96
|
-
// THIS LOGIC WAS MOVED TO SET INITIAL DOOR STYLE
|
|
97
|
-
// if (isEmpty(sceneJSON?.layers[layerID]?.doorStyle)) {
|
|
98
|
-
// let newlayer = {
|
|
99
|
-
// ...sceneJSON?.layers[layerID],
|
|
100
|
-
// doorStyle: doorStyle.toJS()
|
|
101
|
-
// };
|
|
102
|
-
// sceneJSON && (sceneJSON.layers[layerID] = newlayer);
|
|
103
|
-
// }
|
|
104
|
-
|
|
105
96
|
var newScene = new Scene(sceneJSON);
|
|
106
97
|
state = new State({
|
|
107
98
|
scene: newScene.toJS(),
|
|
@@ -163,17 +154,35 @@ var Project = /*#__PURE__*/function () {
|
|
|
163
154
|
f: f
|
|
164
155
|
});
|
|
165
156
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
157
|
+
if (!doorStyle) {
|
|
158
|
+
if (state.getIn(['scene', 'layers', layerID, 'doorStyle'])) {
|
|
159
|
+
doorStyle = state.getIn(['scene', 'layers', layerID, 'doorStyle']);
|
|
160
|
+
}
|
|
170
161
|
}
|
|
171
162
|
state = state.merge({
|
|
172
163
|
doorStyle: doorStyle,
|
|
164
|
+
oStyle: oStyle,
|
|
173
165
|
viewer2D: _viewer2D
|
|
174
166
|
});
|
|
175
167
|
state = Item.setCounterTop(state, counterTop).updatedState;
|
|
176
168
|
state = Area.setFloorStyles(state, floorStyle).updatedState;
|
|
169
|
+
if (state.getIn(['scene', 'layers', layerID, 'doorStyle']) && !state.getIn(['scene', 'layers', layerID, 'doorStyle', 'install'])) {
|
|
170
|
+
var layerDoorStyle = state.getIn(['scene', 'layers', layerID, 'doorStyle']);
|
|
171
|
+
var install = '';
|
|
172
|
+
categoryData.data.doorStyles.items.forEach(function (category) {
|
|
173
|
+
category.items.forEach(function (element) {
|
|
174
|
+
if (element.items.filter(function (it) {
|
|
175
|
+
return it.id === layerDoorStyle.id && (layerDoorStyle.install ? category.name === layerDoorStyle.install : true);
|
|
176
|
+
}).length) {
|
|
177
|
+
install = category.name;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
layerDoorStyle = _objectSpread(_objectSpread({}, layerDoorStyle), {}, {
|
|
182
|
+
install: install
|
|
183
|
+
});
|
|
184
|
+
state = state.mergeIn(['scene', 'layers', layerID, 'doorStyle'], layerDoorStyle);
|
|
185
|
+
}
|
|
177
186
|
this.updateZoomScale(state, a);
|
|
178
187
|
viewer2DActions.updateCameraView(_viewer2D);
|
|
179
188
|
return {
|
|
@@ -306,52 +315,29 @@ var Project = /*#__PURE__*/function () {
|
|
|
306
315
|
}
|
|
307
316
|
}, {
|
|
308
317
|
key: "remove",
|
|
309
|
-
value: function remove(state
|
|
318
|
+
value: function remove(state) {
|
|
310
319
|
var selectedLayer = state.getIn(['scene', 'selectedLayer']);
|
|
311
320
|
var _state$getIn = state.getIn(['scene', 'layers', selectedLayer, 'selected']),
|
|
312
321
|
selectedLines = _state$getIn.lines,
|
|
313
322
|
selectedHoles = _state$getIn.holes,
|
|
314
323
|
selectedItems = _state$getIn.items;
|
|
324
|
+
var allVertices = state.getIn(['scene', 'layers', selectedLayer, 'vertices']).toJS();
|
|
325
|
+
var selLines = state.getIn(['scene', 'layers', selectedLayer, 'selected', 'lines']).toJS();
|
|
326
|
+
var lineID = selLines[0];
|
|
327
|
+
var delLine = !isEmpty(lineID) && state.getIn(['scene', 'layers', selectedLayer, 'lines', lineID]).toJS();
|
|
328
|
+
var allLines = state.getIn(['scene', 'layers', selectedLayer, 'lines']).toJS();
|
|
315
329
|
var relatedLines = [];
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
// delete element
|
|
328
|
-
if (delObject) {
|
|
329
|
-
switch (delObject.prototype) {
|
|
330
|
-
case constants.ELEMENT_LINE:
|
|
331
|
-
state = Line.remove(state, selectedLayer, delObject.id).updatedState;
|
|
332
|
-
break;
|
|
333
|
-
case constants.ELEMENT_HOLE:
|
|
334
|
-
state = Hole.remove(state, selectedLayer, delObject.id).updatedState;
|
|
335
|
-
break;
|
|
336
|
-
case constants.ELEMENT_ITEM:
|
|
337
|
-
state = Item.remove(state, selectedLayer, delObject.id).updatedState;
|
|
338
|
-
break;
|
|
339
|
-
}
|
|
340
|
-
} else {
|
|
341
|
-
// no specified object, then remove all selected elements
|
|
342
|
-
selectedLines.forEach(function (lineID) {
|
|
343
|
-
state = Line.remove(state, selectedLayer, lineID).updatedState;
|
|
344
|
-
});
|
|
345
|
-
selectedHoles.forEach(function (holeID) {
|
|
346
|
-
state = Hole.remove(state, selectedLayer, holeID).updatedState;
|
|
347
|
-
});
|
|
348
|
-
selectedItems.forEach(function (itemID) {
|
|
349
|
-
state = Item.remove(state, selectedLayer, itemID).updatedState;
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
// update wall if line removed
|
|
354
|
-
if (!isEmpty(relatedLines)) {
|
|
330
|
+
!isEmpty(delLine) && GeometryUtils.getRelatedLines(relatedLines, delLine, allVertices, allLines);
|
|
331
|
+
selectedLines.forEach(function (lineID) {
|
|
332
|
+
state = Line.remove(state, selectedLayer, lineID).updatedState;
|
|
333
|
+
});
|
|
334
|
+
selectedHoles.forEach(function (holeID) {
|
|
335
|
+
state = Hole.remove(state, selectedLayer, holeID).updatedState;
|
|
336
|
+
});
|
|
337
|
+
selectedItems.forEach(function (itemID) {
|
|
338
|
+
state = Item.remove(state, selectedLayer, itemID).updatedState;
|
|
339
|
+
});
|
|
340
|
+
if (!isEmpty(selectedLines) && !isEmpty(relatedLines)) {
|
|
355
341
|
state = state.setIn(['mode'], MODE_DRAWING_LINE);
|
|
356
342
|
relatedLines.forEach(function (relLine, index) {
|
|
357
343
|
state = Line.select(state, selectedLayer, relLine.id).updatedState;
|
|
@@ -825,98 +811,6 @@ var Project = /*#__PURE__*/function () {
|
|
|
825
811
|
updatedState: state
|
|
826
812
|
};
|
|
827
813
|
}
|
|
828
|
-
}, {
|
|
829
|
-
key: "createRoomWithShape",
|
|
830
|
-
value: function createRoomWithShape(state, roomShapeType, width, height, doorStyle) {
|
|
831
|
-
var catalog = state.catalog;
|
|
832
|
-
state = this.newProject(state).updatedState;
|
|
833
|
-
state = state.merge({
|
|
834
|
-
catalog: catalog
|
|
835
|
-
});
|
|
836
|
-
var _viewer2D = state.viewer2D;
|
|
837
|
-
var viewer = _viewer2D.toJS();
|
|
838
|
-
width = convert(width).from('in').to('cm');
|
|
839
|
-
height = convert(height).from('in').to('cm');
|
|
840
|
-
var layerID = state.scene.selectedLayer;
|
|
841
|
-
state = Item.setInitialDoorStyle(state, doorStyle).updatedState;
|
|
842
|
-
if (isEmpty(viewer)) return {
|
|
843
|
-
updatedState: state
|
|
844
|
-
};
|
|
845
|
-
var halfWidth = width / 2;
|
|
846
|
-
var halfHeight = height / 2;
|
|
847
|
-
var viewerWidth = viewer.SVGWidth;
|
|
848
|
-
var viewerHeight = viewer.SVGHeight;
|
|
849
|
-
var centerPos = {
|
|
850
|
-
x: viewerWidth / 2,
|
|
851
|
-
y: viewerHeight / 2
|
|
852
|
-
};
|
|
853
|
-
var vtLB = {
|
|
854
|
-
x: centerPos.x - halfWidth,
|
|
855
|
-
y: centerPos.y - halfHeight
|
|
856
|
-
};
|
|
857
|
-
var vtRB = {
|
|
858
|
-
x: centerPos.x + halfWidth,
|
|
859
|
-
y: centerPos.y - halfHeight
|
|
860
|
-
};
|
|
861
|
-
var vtRT = {
|
|
862
|
-
x: centerPos.x + halfWidth,
|
|
863
|
-
y: centerPos.y + halfHeight
|
|
864
|
-
};
|
|
865
|
-
var vtLT = {
|
|
866
|
-
x: centerPos.x - halfWidth,
|
|
867
|
-
y: centerPos.y + halfHeight
|
|
868
|
-
};
|
|
869
|
-
var vertices = [];
|
|
870
|
-
switch (roomShapeType) {
|
|
871
|
-
case 'rectangle':
|
|
872
|
-
vertices = [vtLB, vtLT, vtRT, vtRB];
|
|
873
|
-
break;
|
|
874
|
-
case constants.ROOM_SHAPE_TYPE.TWO_WALLS_RIGHT_BOTTOM:
|
|
875
|
-
vertices = [vtLB, vtRB, vtRT];
|
|
876
|
-
break;
|
|
877
|
-
case constants.ROOM_SHAPE_TYPE.TWO_WALLS_RIGHT_TOP:
|
|
878
|
-
vertices = [vtRB, vtRT, vtLT];
|
|
879
|
-
break;
|
|
880
|
-
case constants.ROOM_SHAPE_TYPE.TWO_WALLS_LEFT_TOP:
|
|
881
|
-
vertices = [vtRT, vtLT, vtLB];
|
|
882
|
-
break;
|
|
883
|
-
case constants.ROOM_SHAPE_TYPE.TWO_WALLS_LEFT_BOTTOM:
|
|
884
|
-
vertices = [vtLT, vtLB, vtRB];
|
|
885
|
-
break;
|
|
886
|
-
case constants.ROOM_SHAPE_TYPE.THREE_WALLS_LEFT_TOP_RIGHT:
|
|
887
|
-
vertices = [vtRB, vtRT, vtLT, vtLB];
|
|
888
|
-
break;
|
|
889
|
-
case constants.ROOM_SHAPE_TYPE.THREE_WALLS_TOP_RIGHT_BOTTOM:
|
|
890
|
-
vertices = [vtLB, vtRB, vtRT, vtLT];
|
|
891
|
-
break;
|
|
892
|
-
case constants.ROOM_SHAPE_TYPE.THREE_WALLS_RIGHT_BOTTOM_LEFT:
|
|
893
|
-
vertices = [vtLT, vtLB, vtRB, vtRT];
|
|
894
|
-
break;
|
|
895
|
-
case constants.ROOM_SHAPE_TYPE.THREE_WALLS_BOTTOM_LEFT_TOP:
|
|
896
|
-
vertices = [vtRT, vtLT, vtLB, vtRB];
|
|
897
|
-
break;
|
|
898
|
-
}
|
|
899
|
-
for (var i = 0; i < vertices.length - 1; i++) {
|
|
900
|
-
state = Line.create(state, layerID, 'wall', vertices[i].x, vertices[i].y, vertices[i + 1].x, vertices[i + 1].y).updatedState;
|
|
901
|
-
}
|
|
902
|
-
if (roomShapeType === constants.ROOM_SHAPE_TYPE.RECTANGLE) {
|
|
903
|
-
state = Line.create(state, layerID, 'wall', vertices[vertices.length - 1].x, vertices[vertices.length - 1].y, vertices[0].x, vertices[0].y).updatedState;
|
|
904
|
-
}
|
|
905
|
-
var layer = state.getIn(['scene', 'layers', layerID]);
|
|
906
|
-
var lines = layer.getIn(['lines']).toJS();
|
|
907
|
-
var drawingInfo = {};
|
|
908
|
-
var lineKey = Object.keys(lines);
|
|
909
|
-
for (var _i = 0; _i < lineKey.length; _i++) {
|
|
910
|
-
if (!isEmpty(lineKey)) {
|
|
911
|
-
drawingInfo.drawingLine = layer.getIn(['lines', lineKey[_i]]);
|
|
912
|
-
}
|
|
913
|
-
state = Layer.detectAndUpdateAreas(state, layerID, drawingInfo).updatedState;
|
|
914
|
-
}
|
|
915
|
-
state = centering2D(state);
|
|
916
|
-
return {
|
|
917
|
-
updatedState: state
|
|
918
|
-
};
|
|
919
|
-
}
|
|
920
814
|
}]);
|
|
921
815
|
}();
|
|
922
816
|
export { Project as default };
|
package/es/components/content.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import Viewer2D from "./viewer2d/viewer2d";
|
|
4
4
|
import Viewer3D from "./viewer3d/viewer3d";
|
|
@@ -16,18 +16,9 @@ export default function Content(_ref, _ref2) {
|
|
|
16
16
|
setToolbar = _ref.setToolbar,
|
|
17
17
|
replaceCabinet = _ref.replaceCabinet,
|
|
18
18
|
keyDownEnable = _ref.keyDownEnable,
|
|
19
|
-
catalog = _ref.catalog
|
|
20
|
-
onInternalEvent = _ref.onInternalEvent;
|
|
19
|
+
catalog = _ref.catalog;
|
|
21
20
|
var projectActions = _ref2.projectActions;
|
|
22
21
|
var mode = state.get('mode');
|
|
23
|
-
|
|
24
|
-
// Internal Event for unselect_all
|
|
25
|
-
useEffect(function () {
|
|
26
|
-
if (state.getIn(['scene', 'layers', 'layer-1', 'selected', 'vertices']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'holes']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'areas']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'items']).size < 1) onInternalEvent === null || onInternalEvent === void 0 || onInternalEvent({
|
|
27
|
-
type: constants.INTERNAL_EVENT_UNSELECT_ALL,
|
|
28
|
-
value: null
|
|
29
|
-
});
|
|
30
|
-
}, [state.getIn(['scene', 'layers', 'layer-1', 'selected'])]);
|
|
31
22
|
switch (mode) {
|
|
32
23
|
// this mode is when view elevation
|
|
33
24
|
case constants.MODE_ELEVATION_VIEW:
|
|
@@ -49,8 +40,7 @@ export default function Content(_ref, _ref2) {
|
|
|
49
40
|
setToolbar: setToolbar,
|
|
50
41
|
replaceCabinet: replaceCabinet,
|
|
51
42
|
keyDownEnable: keyDownEnable,
|
|
52
|
-
downloadFlag: false
|
|
53
|
-
onInternalEvent: onInternalEvent
|
|
43
|
+
downloadFlag: false
|
|
54
44
|
});
|
|
55
45
|
case constants.MODE_3D_FIRST_PERSON:
|
|
56
46
|
return /*#__PURE__*/React.createElement(Viewer3DFirstPerson, {
|
|
@@ -88,8 +78,7 @@ export default function Content(_ref, _ref2) {
|
|
|
88
78
|
width: width,
|
|
89
79
|
height: height,
|
|
90
80
|
setToolbar: setToolbar,
|
|
91
|
-
replaceCabinet: replaceCabinet
|
|
92
|
-
onInternalEvent: onInternalEvent
|
|
81
|
+
replaceCabinet: replaceCabinet
|
|
93
82
|
});
|
|
94
83
|
case constants.MODE_ROTATING_ITEM_3D:
|
|
95
84
|
case constants.MODE_DRAGGING_ITEM_3D:
|
|
@@ -105,8 +94,7 @@ export default function Content(_ref, _ref2) {
|
|
|
105
94
|
setToolbar: setToolbar,
|
|
106
95
|
replaceCabinet: replaceCabinet,
|
|
107
96
|
keyDownEnable: keyDownEnable,
|
|
108
|
-
downloadFlag: false
|
|
109
|
-
onInternalEvent: onInternalEvent
|
|
97
|
+
downloadFlag: false
|
|
110
98
|
});
|
|
111
99
|
|
|
112
100
|
// case constants.MODE_CONFIGURING_PROJECT:
|
|
@@ -131,8 +119,7 @@ Content.propTypes = {
|
|
|
131
119
|
state: PropTypes.object.isRequired,
|
|
132
120
|
width: PropTypes.number.isRequired,
|
|
133
121
|
height: PropTypes.number.isRequired,
|
|
134
|
-
replaceCabinet: PropTypes.func.isRequired
|
|
135
|
-
onInternalEvent: PropTypes.func.isRequired
|
|
122
|
+
replaceCabinet: PropTypes.func.isRequired
|
|
136
123
|
};
|
|
137
124
|
Content.contextTypes = {
|
|
138
125
|
projectActions: PropTypes.object.isRequired
|
|
@@ -5,8 +5,7 @@ import RulerDist from "./rulerDist";
|
|
|
5
5
|
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
|
-
import { isEmpty,
|
|
9
|
-
import { findCatalogElement } from "../../utils/geometry";
|
|
8
|
+
import { isEmpty, returnReplaceableDeepSearchType } from "./utils";
|
|
10
9
|
var STYLE_LINE = {
|
|
11
10
|
fill: '#0096fd',
|
|
12
11
|
stroke: '#0096fd'
|
|
@@ -22,7 +21,6 @@ var STYLE_CIRCLE2 = {
|
|
|
22
21
|
cursor: 'ew-resize'
|
|
23
22
|
};
|
|
24
23
|
export default function Item(_ref, _ref2) {
|
|
25
|
-
var _element$render2D;
|
|
26
24
|
var layer = _ref.layer,
|
|
27
25
|
item = _ref.item,
|
|
28
26
|
scene = _ref.scene,
|
|
@@ -32,8 +30,7 @@ export default function Item(_ref, _ref2) {
|
|
|
32
30
|
var x = item.x,
|
|
33
31
|
y = item.y,
|
|
34
32
|
rotation = item.rotation,
|
|
35
|
-
id = item.id
|
|
36
|
-
layoutpos = item.layoutpos;
|
|
33
|
+
id = item.id;
|
|
37
34
|
var showBaseCabinetMeasure = scene.showBaseCabinetMeasure,
|
|
38
35
|
showWallCabinetMeasure = scene.showWallCabinetMeasure;
|
|
39
36
|
var vertices = layer.vertices;
|
|
@@ -44,7 +41,6 @@ export default function Item(_ref, _ref2) {
|
|
|
44
41
|
var allLineRects;
|
|
45
42
|
var allItemRect;
|
|
46
43
|
var width, height;
|
|
47
|
-
var altitude = item.properties.getIn(['altitude', '_length']);
|
|
48
44
|
var _useState = useState(false),
|
|
49
45
|
_useState2 = _slicedToArray(_useState, 2),
|
|
50
46
|
clockRotateState = _useState2[0],
|
|
@@ -113,11 +109,16 @@ export default function Item(_ref, _ref2) {
|
|
|
113
109
|
var selectedItem;
|
|
114
110
|
if (layer.selected.items.size > 0) {
|
|
115
111
|
selectedItem = layer.getIn(['items', layer.selected.items.get(0)]);
|
|
116
|
-
var
|
|
117
|
-
var
|
|
112
|
+
var catid = selectedItem.type;
|
|
113
|
+
var cat = catalog.elements[catid];
|
|
114
|
+
if (!cat) cat = catalog.elements[returnReplaceableDeepSearchType(catid)];
|
|
115
|
+
if (cat === undefined || cat === null) {
|
|
116
|
+
cat = catalog.getIn(['elements', catid]);
|
|
117
|
+
if (!cat) cat = catalog.getIn(['elements', returnReplaceableDeepSearchType(catid)]);
|
|
118
|
+
}
|
|
118
119
|
currentItem = {
|
|
119
120
|
selectedItem: selectedItem,
|
|
120
|
-
cat:
|
|
121
|
+
cat: cat
|
|
121
122
|
};
|
|
122
123
|
}
|
|
123
124
|
layer.items.forEach(function (item) {
|
|
@@ -129,7 +130,8 @@ export default function Item(_ref, _ref2) {
|
|
|
129
130
|
rotRad: item.rotation / 180 * Math.PI
|
|
130
131
|
};
|
|
131
132
|
var catid = item.type;
|
|
132
|
-
var cat =
|
|
133
|
+
var cat = catalog.elements[catid];
|
|
134
|
+
if (!cat) cat = catalog.elements[returnReplaceableDeepSearchType(catid)];
|
|
133
135
|
var width = convert(item.properties.getIn(['width', '_length'])).from('in').to('cm');
|
|
134
136
|
var height = convert(item.properties.getIn(['depth', '_length'])).from('in').to('cm');
|
|
135
137
|
// let width = cat.info.sizeinfo.width;
|
|
@@ -148,36 +150,33 @@ export default function Item(_ref, _ref2) {
|
|
|
148
150
|
// }
|
|
149
151
|
|
|
150
152
|
if (!item.selected) {
|
|
151
|
-
var
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
rect: [point(x3, y3), point(x0, y0), point(x3, y3), point(x0, y0)]
|
|
179
|
-
});
|
|
180
|
-
}
|
|
153
|
+
var _x = val.pos.x;
|
|
154
|
+
var _y = val.pos.y;
|
|
155
|
+
var rotRad = val.rotRad;
|
|
156
|
+
var w = val.size.width / 2;
|
|
157
|
+
var h = val.size.height / 2;
|
|
158
|
+
var mx = _x - w * Math.cos(rotRad);
|
|
159
|
+
var my = _y - w * Math.sin(rotRad);
|
|
160
|
+
var x0 = mx + h * Math.sin(rotRad);
|
|
161
|
+
var y0 = my - h * Math.cos(rotRad);
|
|
162
|
+
var x3 = mx * 2 - x0;
|
|
163
|
+
var y3 = my * 2 - y0;
|
|
164
|
+
var x1 = _x * 2 - x3;
|
|
165
|
+
var y1 = _y * 2 - y3;
|
|
166
|
+
var x2 = _x * 2 - x0;
|
|
167
|
+
var y2 = _y * 2 - y0;
|
|
168
|
+
rectarray.push({
|
|
169
|
+
rect: [point(x0, y0), point(x1, y1), point(x0, y0), point(x1, y1)]
|
|
170
|
+
});
|
|
171
|
+
rectarray.push({
|
|
172
|
+
rect: [point(x1, y1), point(x2, y2), point(x1, y1), point(x2, y2)]
|
|
173
|
+
});
|
|
174
|
+
rectarray.push({
|
|
175
|
+
rect: [point(x2, y2), point(x3, y3), point(x2, y2), point(x3, y3)]
|
|
176
|
+
});
|
|
177
|
+
rectarray.push({
|
|
178
|
+
rect: [point(x3, y3), point(x0, y0), point(x3, y3), point(x0, y0)]
|
|
179
|
+
});
|
|
181
180
|
}
|
|
182
181
|
});
|
|
183
182
|
|
|
@@ -238,38 +237,25 @@ export default function Item(_ref, _ref2) {
|
|
|
238
237
|
*/
|
|
239
238
|
var getDistant = function getDistant(x, y, rotRad) {
|
|
240
239
|
var center_h = 3 * height / 8;
|
|
241
|
-
var center_x = x;
|
|
240
|
+
var center_x = x;
|
|
242
241
|
var center_y = y;
|
|
243
|
-
var center_x1 = x - center_h * Math.sin(rotRad);
|
|
242
|
+
var center_x1 = x - center_h * Math.sin(rotRad);
|
|
244
243
|
var center_y1 = y + center_h * Math.cos(rotRad);
|
|
245
244
|
var PointArray = [];
|
|
246
|
-
|
|
247
|
-
var
|
|
248
|
-
// [rectCenterPoint] has four middle points of cabinet rect edges
|
|
249
|
-
var comparelength = []; // distance array from rectCenterPoint[i] to other lines(walls, other cabinet rect edges)
|
|
245
|
+
curiteminfo.rectCenterPoint.forEach(function (centerpoint) {
|
|
246
|
+
var comparelength = [];
|
|
250
247
|
var a;
|
|
251
|
-
var RectLineFuction;
|
|
248
|
+
var RectLineFuction;
|
|
252
249
|
if (centerpoint[1] === 180 || centerpoint[1] === 0) RectLineFuction = GeometryUtils.linePassingThroughTwoPoints(centerpoint[0].x, centerpoint[0].y, center_x1, center_y1);else RectLineFuction = GeometryUtils.linePassingThroughTwoPoints(centerpoint[0].x, centerpoint[0].y, center_x, center_y);
|
|
253
250
|
allRect.forEach(function (linerect) {
|
|
254
|
-
// calc distance to all other lines
|
|
255
251
|
var p0 = GeometryUtils.clone_point(linerect.rect[2]);
|
|
256
252
|
var p1 = GeometryUtils.clone_point(linerect.rect[3]);
|
|
257
|
-
var lineFunction = {};
|
|
253
|
+
var lineFunction = {};
|
|
258
254
|
if (p0.x !== p1.x || p0.y !== p1.y) lineFunction = GeometryUtils.linePassingThroughTwoPoints(p0.x, p0.y, p1.x, p1.y);
|
|
259
|
-
// intersection between normal line and other line
|
|
260
255
|
var coordinatePoint = GeometryUtils.twoLinesIntersection(lineFunction.a, lineFunction.b, lineFunction.c, RectLineFuction.a, RectLineFuction.b, RectLineFuction.c);
|
|
261
256
|
if (coordinatePoint !== undefined) {
|
|
262
|
-
if (
|
|
263
|
-
|
|
264
|
-
GeometryUtils.pointsDistance(p0.x, p0.y, p1.x, p1.y) > GeometryUtils.pointsDistance(p0.x, p0.y, coordinatePoint.x, coordinatePoint.y) && GeometryUtils.pointsDistance(p0.x, p0.y, p1.x, p1.y) > GeometryUtils.pointsDistance(p1.x, p1.y, coordinatePoint.x, coordinatePoint.y)) {
|
|
265
|
-
// check the intersection point is outside direction of edge
|
|
266
|
-
var isOutside = true;
|
|
267
|
-
for (var j = 0; j < curiteminfo.rectCenterPoint.length; j++) {
|
|
268
|
-
if (j === i) continue;
|
|
269
|
-
var otherCenterPoint = curiteminfo.rectCenterPoint[j];
|
|
270
|
-
if (GeometryUtils.isPointOnLineSegment(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y, otherCenterPoint[0].x, otherCenterPoint[0].y)) isOutside = false;
|
|
271
|
-
}
|
|
272
|
-
if (isOutside && GeometryUtils.pointsDistance(coordinatePoint.x, coordinatePoint.y, center_x, center_y) > GeometryUtils.pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y)) {
|
|
257
|
+
if (GeometryUtils.pointsDistance(p0.x, p0.y, p1.x, p1.y) > GeometryUtils.pointsDistance(p0.x, p0.y, coordinatePoint.x, coordinatePoint.y) && GeometryUtils.pointsDistance(p0.x, p0.y, p1.x, p1.y) > GeometryUtils.pointsDistance(p1.x, p1.y, coordinatePoint.x, coordinatePoint.y)) {
|
|
258
|
+
if (GeometryUtils.pointsDistance(coordinatePoint.x, coordinatePoint.y, center_x, center_y) > GeometryUtils.pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y)) {
|
|
273
259
|
comparelength.push(GeometryUtils.pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y));
|
|
274
260
|
a = Math.min.apply(null, comparelength);
|
|
275
261
|
}
|
|
@@ -277,10 +263,7 @@ export default function Item(_ref, _ref2) {
|
|
|
277
263
|
}
|
|
278
264
|
});
|
|
279
265
|
PointArray.push([a, centerpoint[1]]);
|
|
280
|
-
};
|
|
281
|
-
for (var i = 0; i < curiteminfo.rectCenterPoint.length; i++) {
|
|
282
|
-
_loop(i);
|
|
283
|
-
}
|
|
266
|
+
});
|
|
284
267
|
return {
|
|
285
268
|
PointArray: PointArray
|
|
286
269
|
};
|
|
@@ -289,22 +272,9 @@ export default function Item(_ref, _ref2) {
|
|
|
289
272
|
var nh = height / 2;
|
|
290
273
|
var _getDistant = getDistant(x, y, val.rotRad),
|
|
291
274
|
PointArray = _getDistant.PointArray;
|
|
292
|
-
var catid = item.type;
|
|
293
|
-
var cat = catalog.elements[catid];
|
|
294
275
|
PointArray.forEach(function (pointElement, index) {
|
|
295
276
|
if (pointElement[0] == undefined) PointArray[index][0] = 0;
|
|
296
|
-
// if (pointElement[1] === -90 && cat.info.is_corner !== 1) {
|
|
297
|
-
// PointArray[index][0] -= 4;
|
|
298
|
-
// }
|
|
299
|
-
});
|
|
300
|
-
var cnt = 0;
|
|
301
|
-
PointArray.forEach(function (pointElement) {
|
|
302
|
-
if (pointElement[0] == 0) cnt++;
|
|
303
277
|
});
|
|
304
|
-
if (cnt == 4 || cnt == 3) {
|
|
305
|
-
PointArray[0][0] = 100;
|
|
306
|
-
PointArray[1][0] = 100;
|
|
307
|
-
}
|
|
308
278
|
if (Array.isArray(PointArray)) {
|
|
309
279
|
itemsActions.storeDistArray(layerID, id, PointArray);
|
|
310
280
|
}
|
|
@@ -332,12 +302,12 @@ export default function Item(_ref, _ref2) {
|
|
|
332
302
|
length: itemDistanceFromLine,
|
|
333
303
|
angle: rotation,
|
|
334
304
|
rotation: element[1],
|
|
335
|
-
transform: "translate(".concat(element[1] === 180 ? -nw : element[1] === 0 ? nw : 0, ", ").concat(element[1] === 90 ? nh : element[1] === -90 ?
|
|
305
|
+
transform: "translate(".concat(element[1] === 180 ? -nw : element[1] === 0 ? nw : 0, ", ").concat(element[1] === 90 ? nh : element[1] === -90 ? -nh : 3 * nh / 4, ") rotate(").concat(element[1], ", 0, 0)")
|
|
336
306
|
})));
|
|
337
307
|
}
|
|
338
308
|
});
|
|
339
309
|
}
|
|
340
|
-
var renderedItem = element
|
|
310
|
+
var renderedItem = element.render2D.call(element, item, layer, scene);
|
|
341
311
|
var isSmall = false;
|
|
342
312
|
if (width < 40) isSmall = true;
|
|
343
313
|
var parts = [];
|
|
@@ -414,10 +384,7 @@ export default function Item(_ref, _ref2) {
|
|
|
414
384
|
y: "-19",
|
|
415
385
|
height: "16",
|
|
416
386
|
width: "16",
|
|
417
|
-
style:
|
|
418
|
-
transform: 'rotateX(180deg)',
|
|
419
|
-
opacity: 0.5
|
|
420
|
-
} : {
|
|
387
|
+
style: {
|
|
421
388
|
transform: 'rotateX(180deg)'
|
|
422
389
|
}
|
|
423
390
|
})), /*#__PURE__*/React.createElement("g", {
|