kitchen-simulator 3.0.1 → 3.1.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 +42 -9
- package/es/LiteRenderer.js +5 -8
- package/es/actions/lines-actions.js +3 -1
- package/es/assets/img/png/helper/video_preview_start.png +0 -0
- package/es/catalog/factories/area-factory-3d.js +17 -17
- package/es/catalog/holes/window-clear/planner-element.js +2 -2
- package/es/catalog/utils/item-loader.js +198 -197
- package/es/class/item.js +11 -0
- package/es/class/line.js +14 -2
- package/es/components/viewer2d/item.js +41 -14
- package/es/components/viewer2d/rulerDist.js +1 -1
- package/es/components/viewer2d/utils.js +2 -2
- package/es/components/viewer2d/viewer2d.js +13 -11
- package/es/components/viewer3d/viewer3d.js +98 -96
- package/es/constants.js +6 -2
- package/es/devLiteRenderer.js +192 -98
- package/es/index.js +82 -13
- package/es/reducers/lines-reducer.js +1 -1
- package/es/utils/geometry.js +161 -0
- package/es/utils/isolate-event-handler.js +273 -116
- package/es/utils/molding.js +234 -2
- package/lib/LiteKitchenConfigurator.js +42 -9
- package/lib/LiteRenderer.js +5 -8
- package/lib/actions/lines-actions.js +3 -1
- package/lib/assets/img/png/helper/video_preview_start.png +0 -0
- package/lib/catalog/factories/area-factory-3d.js +14 -14
- package/lib/catalog/holes/window-clear/planner-element.js +2 -2
- package/lib/catalog/utils/item-loader.js +195 -194
- package/lib/class/item.js +11 -0
- package/lib/class/line.js +13 -1
- package/lib/components/viewer2d/item.js +40 -13
- package/lib/components/viewer2d/rulerDist.js +1 -1
- package/lib/components/viewer2d/utils.js +2 -2
- package/lib/components/viewer2d/viewer2d.js +13 -11
- package/lib/components/viewer3d/viewer3d.js +98 -96
- package/lib/constants.js +11 -7
- package/lib/devLiteRenderer.js +186 -92
- package/lib/index.js +82 -13
- package/lib/reducers/lines-reducer.js +1 -1
- package/lib/utils/geometry.js +162 -0
- package/lib/utils/isolate-event-handler.js +272 -115
- package/lib/utils/molding.js +233 -0
- package/package.json +1 -1
package/es/class/item.js
CHANGED
|
@@ -13,6 +13,7 @@ import { debugUtil } from "../utils/helper";
|
|
|
13
13
|
import { isUndefined } from 'util';
|
|
14
14
|
import { hasMoldingLayout } from "../utils/molding";
|
|
15
15
|
import { getInstallationSuffix, isWarningItem } from "../components/viewer2d/utils";
|
|
16
|
+
import { historyPush } from "../utils/history";
|
|
16
17
|
var allItemRect;
|
|
17
18
|
var allItemSnap;
|
|
18
19
|
var allLines;
|
|
@@ -479,6 +480,9 @@ var Item = /*#__PURE__*/function () {
|
|
|
479
480
|
key: "storeDistArray",
|
|
480
481
|
value: function storeDistArray(state, layerID, itemID, distArray) {
|
|
481
482
|
var curDistArray = state.getIn(['scene', 'layers', layerID, 'items', itemID, 'distArray']);
|
|
483
|
+
distArray.forEach(function (dist) {
|
|
484
|
+
dist[0] < 0 ? dist[0] = 0 : dist[0];
|
|
485
|
+
});
|
|
482
486
|
var isEqualDist = function isEqualDist(a, b) {
|
|
483
487
|
return a == b;
|
|
484
488
|
};
|
|
@@ -1145,6 +1149,7 @@ var Item = /*#__PURE__*/function () {
|
|
|
1145
1149
|
for (var x in keys) {
|
|
1146
1150
|
tmp[keys[x]] = doorStyle.doorStyles[keys[x]];
|
|
1147
1151
|
}
|
|
1152
|
+
doorStyle.cds = itemCDS;
|
|
1148
1153
|
state = state.setIn(['scene', 'layers', state.scene.selectedLayer, 'doorStyle'], doorStyle);
|
|
1149
1154
|
state = state.merge({
|
|
1150
1155
|
doorStyle: doorStyle
|
|
@@ -1537,6 +1542,9 @@ var Item = /*#__PURE__*/function () {
|
|
|
1537
1542
|
});
|
|
1538
1543
|
}
|
|
1539
1544
|
}
|
|
1545
|
+
state = state.merge({
|
|
1546
|
+
sceneHistory: historyPush(state.sceneHistory, state.scene)
|
|
1547
|
+
});
|
|
1540
1548
|
return {
|
|
1541
1549
|
updatedState: state
|
|
1542
1550
|
};
|
|
@@ -1659,6 +1667,9 @@ var Item = /*#__PURE__*/function () {
|
|
|
1659
1667
|
updateSelectItemMolding();
|
|
1660
1668
|
}
|
|
1661
1669
|
}
|
|
1670
|
+
state = state.merge({
|
|
1671
|
+
sceneHistory: historyPush(state.sceneHistory, state.scene)
|
|
1672
|
+
});
|
|
1662
1673
|
return {
|
|
1663
1674
|
updatedState: state
|
|
1664
1675
|
};
|
package/es/class/line.js
CHANGED
|
@@ -5,8 +5,9 @@ import { fromJS, List, Map } from 'immutable';
|
|
|
5
5
|
import { Group, Hole, Layer, Vertex } from "./export";
|
|
6
6
|
import { GeometryUtils, history, IDBroker, NameGenerator, SnapSceneUtils, SnapUtils } from "../utils/export";
|
|
7
7
|
import * as Three from 'three';
|
|
8
|
-
import { END_DRAGGING_LINE, END_DRAGGING_VERTEX, END_DRAWING_LINE, EPSILON, MIN_ANGLE_DISALLOW_DRAW_WALL, MODE_DRAGGING_LINE, MODE_DRAWING_LINE, MODE_IDLE, MODE_WAITING_DRAWING_LINE, UNIT_ANGLE } from "../constants";
|
|
8
|
+
import { END_DRAGGING_LINE, END_DRAGGING_VERTEX, END_DRAWING_LINE, EPSILON, INTERNAL_EVENT_START_DRAW_WALL, MIN_ANGLE_DISALLOW_DRAW_WALL, MODE_DRAGGING_LINE, MODE_DRAWING_LINE, MODE_IDLE, MODE_WAITING_DRAWING_LINE, UNIT_ANGLE } from "../constants";
|
|
9
9
|
import { isEmpty } from "../utils/helper";
|
|
10
|
+
import { convert } from "../utils/convert-units-lite";
|
|
10
11
|
var timeGlobal = 0;
|
|
11
12
|
var TimeRecorder = /*#__PURE__*/function () {
|
|
12
13
|
function TimeRecorder(name) {
|
|
@@ -426,7 +427,7 @@ var Line = /*#__PURE__*/function () {
|
|
|
426
427
|
}
|
|
427
428
|
}, {
|
|
428
429
|
key: "beginDrawingLine",
|
|
429
|
-
value: function beginDrawingLine(state, layerID, x, y) {
|
|
430
|
+
value: function beginDrawingLine(state, layerID, x, y, onInternalEvent) {
|
|
430
431
|
// if end drawing by created area
|
|
431
432
|
if (state.mode == MODE_IDLE) {
|
|
432
433
|
return {
|
|
@@ -479,6 +480,17 @@ var Line = /*#__PURE__*/function () {
|
|
|
479
480
|
activeSnapElement: snap ? snap.snap : null,
|
|
480
481
|
drawingSupport: drawingSupport
|
|
481
482
|
});
|
|
483
|
+
var layer = state.getIn(['scene', 'layers', layerID]);
|
|
484
|
+
var payload = line.toJS();
|
|
485
|
+
var v_a = layer.vertices.get(line.vertices.get(0));
|
|
486
|
+
var v_b = layer.vertices.get(line.vertices.get(1));
|
|
487
|
+
var distance = GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
|
|
488
|
+
var _length = convert(distance).from('cm').to(layer.unit);
|
|
489
|
+
payload.length = _length;
|
|
490
|
+
if (onInternalEvent) onInternalEvent({
|
|
491
|
+
type: INTERNAL_EVENT_START_DRAW_WALL,
|
|
492
|
+
value: payload
|
|
493
|
+
});
|
|
482
494
|
return {
|
|
483
495
|
updatedState: state
|
|
484
496
|
};
|
|
@@ -5,7 +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, returnReplaceableDeepSearchType } from "./utils";
|
|
8
|
+
import { isEmpty, isWarningItem, returnReplaceableDeepSearchType } from "./utils";
|
|
9
9
|
import { findCatalogElement } from "../../utils/geometry";
|
|
10
10
|
var STYLE_LINE = {
|
|
11
11
|
fill: '#0096fd',
|
|
@@ -238,25 +238,38 @@ export default function Item(_ref, _ref2) {
|
|
|
238
238
|
*/
|
|
239
239
|
var getDistant = function getDistant(x, y, rotRad) {
|
|
240
240
|
var center_h = 3 * height / 8;
|
|
241
|
-
var center_x = x;
|
|
241
|
+
var center_x = x; // middle of front line of cabinet rect
|
|
242
242
|
var center_y = y;
|
|
243
|
-
var center_x1 = x - center_h * Math.sin(rotRad);
|
|
243
|
+
var center_x1 = x - center_h * Math.sin(rotRad); // center point of cabinet rect
|
|
244
244
|
var center_y1 = y + center_h * Math.cos(rotRad);
|
|
245
245
|
var PointArray = [];
|
|
246
|
-
|
|
247
|
-
var
|
|
246
|
+
var _loop = function _loop(i) {
|
|
247
|
+
var centerpoint = curiteminfo.rectCenterPoint[i];
|
|
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)
|
|
248
250
|
var a;
|
|
249
|
-
var RectLineFuction;
|
|
251
|
+
var RectLineFuction; // normal line of cabinet rect edge
|
|
250
252
|
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);
|
|
251
253
|
allRect.forEach(function (linerect) {
|
|
254
|
+
// calc distance to all other lines
|
|
252
255
|
var p0 = GeometryUtils.clone_point(linerect.rect[2]);
|
|
253
256
|
var p1 = GeometryUtils.clone_point(linerect.rect[3]);
|
|
254
|
-
var lineFunction = {};
|
|
257
|
+
var lineFunction = {}; // other line function
|
|
255
258
|
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
|
|
256
260
|
var coordinatePoint = GeometryUtils.twoLinesIntersection(lineFunction.a, lineFunction.b, lineFunction.c, RectLineFuction.a, RectLineFuction.b, RectLineFuction.c);
|
|
257
261
|
if (coordinatePoint !== undefined) {
|
|
258
|
-
if (
|
|
259
|
-
|
|
262
|
+
if (
|
|
263
|
+
// intersection point is on the other line
|
|
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)) {
|
|
260
273
|
comparelength.push(GeometryUtils.pointsDistance(centerpoint[0].x, centerpoint[0].y, coordinatePoint.x, coordinatePoint.y));
|
|
261
274
|
a = Math.min.apply(null, comparelength);
|
|
262
275
|
}
|
|
@@ -264,7 +277,10 @@ export default function Item(_ref, _ref2) {
|
|
|
264
277
|
}
|
|
265
278
|
});
|
|
266
279
|
PointArray.push([a, centerpoint[1]]);
|
|
267
|
-
}
|
|
280
|
+
};
|
|
281
|
+
for (var i = 0; i < curiteminfo.rectCenterPoint.length; i++) {
|
|
282
|
+
_loop(i);
|
|
283
|
+
}
|
|
268
284
|
return {
|
|
269
285
|
PointArray: PointArray
|
|
270
286
|
};
|
|
@@ -277,10 +293,18 @@ export default function Item(_ref, _ref2) {
|
|
|
277
293
|
var cat = catalog.elements[catid];
|
|
278
294
|
PointArray.forEach(function (pointElement, index) {
|
|
279
295
|
if (pointElement[0] == undefined) PointArray[index][0] = 0;
|
|
280
|
-
if (pointElement[1] === -90 && cat.info.is_corner !== 1) {
|
|
281
|
-
|
|
282
|
-
}
|
|
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++;
|
|
283
303
|
});
|
|
304
|
+
if (cnt == 4 || cnt == 3) {
|
|
305
|
+
PointArray[0][0] = 100;
|
|
306
|
+
PointArray[1][0] = 100;
|
|
307
|
+
}
|
|
284
308
|
if (Array.isArray(PointArray)) {
|
|
285
309
|
itemsActions.storeDistArray(layerID, id, PointArray);
|
|
286
310
|
}
|
|
@@ -390,7 +414,10 @@ export default function Item(_ref, _ref2) {
|
|
|
390
414
|
y: "-19",
|
|
391
415
|
height: "16",
|
|
392
416
|
width: "16",
|
|
393
|
-
style: {
|
|
417
|
+
style: isWarningItem(item) ? {
|
|
418
|
+
transform: 'rotateX(180deg)',
|
|
419
|
+
opacity: 0.5
|
|
420
|
+
} : {
|
|
394
421
|
transform: 'rotateX(180deg)'
|
|
395
422
|
}
|
|
396
423
|
})), /*#__PURE__*/React.createElement("g", {
|
|
@@ -34,7 +34,7 @@ export default function RulerDist(_ref) {
|
|
|
34
34
|
var _unit = 'in';
|
|
35
35
|
// let _length = convert(length).from(unit).to(rulerUnit);
|
|
36
36
|
var distanceText = "".concat(convert(length).from('cm').to(rulerUnit).toFixed(0));
|
|
37
|
-
var textLength = (distanceText.length + layer.unit.length) *
|
|
37
|
+
var textLength = (distanceText.length + layer.unit.length) * 8;
|
|
38
38
|
var textangle = angle + 90;
|
|
39
39
|
var textRotation = 1;
|
|
40
40
|
var ay = 2;
|
|
@@ -187,7 +187,7 @@ export var areaPolygon = function areaPolygon(points) {
|
|
|
187
187
|
};
|
|
188
188
|
export var isWarningItem = function isWarningItem(item) {
|
|
189
189
|
var _item$toJS$doorStyle;
|
|
190
|
-
return !(item !== null && item !== void 0 && (_item$toJS$doorStyle = item.toJS().doorStyle) !== null && _item$toJS$doorStyle !== void 0 && (_item$toJS$doorStyle = _item$toJS$doorStyle.doorStyles) !== null && _item$toJS$doorStyle !== void 0 && (_item$toJS$doorStyle = _item$toJS$doorStyle.cds) !== null && _item$toJS$doorStyle !== void 0 && _item$toJS$doorStyle.filter(function (cd) {
|
|
190
|
+
if (item.category === 'cabinet') return !(item !== null && item !== void 0 && (_item$toJS$doorStyle = item.toJS().doorStyle) !== null && _item$toJS$doorStyle !== void 0 && (_item$toJS$doorStyle = _item$toJS$doorStyle.doorStyles) !== null && _item$toJS$doorStyle !== void 0 && (_item$toJS$doorStyle = _item$toJS$doorStyle.cds) !== null && _item$toJS$doorStyle !== void 0 && _item$toJS$doorStyle.filter(function (cd) {
|
|
191
191
|
return cd.itemID == (item === null || item === void 0 ? void 0 : item.getIn(['itemID']));
|
|
192
|
-
}).length) > 0;
|
|
192
|
+
}).length) > 0;else return false;
|
|
193
193
|
};
|
|
@@ -948,7 +948,7 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
948
948
|
case 'items':
|
|
949
949
|
if (elementData.part === 'duplicate') {
|
|
950
950
|
var currentObject = state.getIn(['scene', 'layers', layerID, 'items', elementData.id]);
|
|
951
|
-
itemsActions.duplicateSelected(currentObject, onInternalEvent); // send draw internal event when duplicating
|
|
951
|
+
if (!isWarningItem(currentObject)) itemsActions.duplicateSelected(currentObject, onInternalEvent); // send draw internal event when duplicating
|
|
952
952
|
break;
|
|
953
953
|
} else if (elementData.part === 'remove') {
|
|
954
954
|
projectActions.remove();
|
|
@@ -973,7 +973,7 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
973
973
|
id: "ruler_numberInput",
|
|
974
974
|
style: {
|
|
975
975
|
position: 'absolute',
|
|
976
|
-
left: bbox.left - (
|
|
976
|
+
left: bbox.left - (200 - bbox.width) / 2,
|
|
977
977
|
top: bbox.top - (50 - bbox.height) / 2,
|
|
978
978
|
zIndex: 1000
|
|
979
979
|
}
|
|
@@ -1005,7 +1005,7 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
1005
1005
|
id: "ruler_numberInput",
|
|
1006
1006
|
style: {
|
|
1007
1007
|
position: 'absolute',
|
|
1008
|
-
left: bbox.left - (
|
|
1008
|
+
left: bbox.left - (200 - bbox.width) / 2,
|
|
1009
1009
|
top: bbox.top - (50 - bbox.height) / 2,
|
|
1010
1010
|
zIndex: 1000
|
|
1011
1011
|
}
|
|
@@ -1038,7 +1038,7 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
1038
1038
|
id: "ruler_numberInput",
|
|
1039
1039
|
style: {
|
|
1040
1040
|
position: 'absolute',
|
|
1041
|
-
left: bbox.left - (
|
|
1041
|
+
left: bbox.left - (200 - bbox.width) / 2,
|
|
1042
1042
|
top: bbox.top - (50 - bbox.height) / 2,
|
|
1043
1043
|
zIndex: 1000
|
|
1044
1044
|
}
|
|
@@ -1071,7 +1071,7 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
1071
1071
|
id: "ruler_numberInput",
|
|
1072
1072
|
style: {
|
|
1073
1073
|
position: 'absolute',
|
|
1074
|
-
left: bbox.left - (
|
|
1074
|
+
left: bbox.left - (200 - bbox.width) / 2,
|
|
1075
1075
|
top: bbox.top - (50 - bbox.height) / 2,
|
|
1076
1076
|
zIndex: 1000
|
|
1077
1077
|
}
|
|
@@ -1104,7 +1104,7 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
1104
1104
|
id: "ruler_numberInput",
|
|
1105
1105
|
style: {
|
|
1106
1106
|
position: 'absolute',
|
|
1107
|
-
left: bbox.left - (
|
|
1107
|
+
left: bbox.left - (200 - bbox.width) / 2,
|
|
1108
1108
|
top: bbox.top - (50 - bbox.height) / 2,
|
|
1109
1109
|
zIndex: 1000
|
|
1110
1110
|
}
|
|
@@ -1137,7 +1137,7 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
1137
1137
|
id: "ruler_numberInput",
|
|
1138
1138
|
style: {
|
|
1139
1139
|
position: 'absolute',
|
|
1140
|
-
left: bbox.left - (
|
|
1140
|
+
left: bbox.left - (200 - bbox.width) / 2,
|
|
1141
1141
|
top: bbox.top - (50 - bbox.height) / 2,
|
|
1142
1142
|
zIndex: 1000
|
|
1143
1143
|
}
|
|
@@ -1169,7 +1169,7 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
1169
1169
|
id: "ruler_numberInput",
|
|
1170
1170
|
style: {
|
|
1171
1171
|
position: 'absolute',
|
|
1172
|
-
left: bbox.left - (
|
|
1172
|
+
left: bbox.left - (200 - bbox.width) / 2,
|
|
1173
1173
|
top: bbox.top - (50 - bbox.height) / 2,
|
|
1174
1174
|
zIndex: 1000
|
|
1175
1175
|
}
|
|
@@ -1199,7 +1199,7 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
1199
1199
|
break;
|
|
1200
1200
|
case constants.MODE_WAITING_DRAWING_LINE:
|
|
1201
1201
|
setdrawStart(true);
|
|
1202
|
-
linesActions.beginDrawingLine(layerID, x, y, state.snapMask);
|
|
1202
|
+
linesActions.beginDrawingLine(layerID, x, y, state.snapMask, onInternalEvent);
|
|
1203
1203
|
break;
|
|
1204
1204
|
case constants.MODE_DRAWING_LINE:
|
|
1205
1205
|
// Blocked 90 degree snap.
|
|
@@ -1213,7 +1213,7 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
1213
1213
|
getConnectedLines();
|
|
1214
1214
|
var endInfor = getEndPoint(vertices, x, y, 'END_DRAWIN_LINE');
|
|
1215
1215
|
linesActions.endDrawingLine(endInfor.x, endInfor.y, state.snapMask);
|
|
1216
|
-
linesActions.beginDrawingLine(layerID, endInfor.x, endInfor.y, state.snapMask);
|
|
1216
|
+
linesActions.beginDrawingLine(layerID, endInfor.x, endInfor.y, state.snapMask, onInternalEvent);
|
|
1217
1217
|
break;
|
|
1218
1218
|
case constants.MODE_DRAWING_HOLE:
|
|
1219
1219
|
holesActions.endDrawingHole(layerID, x, y);
|
|
@@ -1258,12 +1258,14 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
1258
1258
|
var v_a = layer.vertices.get(_currentObject.vertices.get(0));
|
|
1259
1259
|
var v_b = layer.vertices.get(_currentObject.vertices.get(1));
|
|
1260
1260
|
var distance = GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
|
|
1261
|
-
var _length3 = convert(distance).from('cm').to(
|
|
1261
|
+
var _length3 = convert(distance).from('cm').to(layer.unit);
|
|
1262
1262
|
payload.length = _length3;
|
|
1263
1263
|
//////////////////////////////////////
|
|
1264
1264
|
} else if (((_currentObject5 = _currentObject) === null || _currentObject5 === void 0 ? void 0 : _currentObject5.prototype) === 'items') {
|
|
1265
1265
|
// check this cabinet has warning box
|
|
1266
1266
|
payload.isWarning = isWarningItem(_currentObject);
|
|
1267
|
+
// check this item is available molding
|
|
1268
|
+
payload.isMoldingAvailable = MoldingUtils.isEnableItemForMolding(layer, _currentObject);
|
|
1267
1269
|
// check this item is snapped to wall
|
|
1268
1270
|
payload.isAttachedWall = MoldingUtils.isAttachedWall(layer, _currentObject);
|
|
1269
1271
|
}
|
|
@@ -1184,6 +1184,34 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1184
1184
|
itemID: selItemId
|
|
1185
1185
|
};
|
|
1186
1186
|
};
|
|
1187
|
+
var sendInternalEvent = function sendInternalEvent(evtType, evtElement) {
|
|
1188
|
+
var pointArray = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
1189
|
+
if (!isEmpty(evtType) && !isEmpty(evtElement)) {
|
|
1190
|
+
var _this2$props$onIntern, _this2$props;
|
|
1191
|
+
var payload = evtElement === null || evtElement === void 0 ? void 0 : evtElement.toJS();
|
|
1192
|
+
if ((evtElement === null || evtElement === void 0 ? void 0 : evtElement.prototype) === 'lines') {
|
|
1193
|
+
// caculating length of selected line//
|
|
1194
|
+
var v_a = layer.vertices.get(evtElement.vertices.get(0));
|
|
1195
|
+
var v_b = layer.vertices.get(evtElement.vertices.get(1));
|
|
1196
|
+
var distance = GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
|
|
1197
|
+
var _length = convert(distance).from('cm').to(layer.unit);
|
|
1198
|
+
payload.length = _length;
|
|
1199
|
+
//////////////////////////////////////
|
|
1200
|
+
} else if ((evtElement === null || evtElement === void 0 ? void 0 : evtElement.prototype) === 'items') {
|
|
1201
|
+
// check this cabinet has warning box
|
|
1202
|
+
payload.isWarning = isWarningItem(evtElement);
|
|
1203
|
+
// check this item is available molding
|
|
1204
|
+
payload.isMoldingAvailable = MoldingUtils.isEnableItemForMolding(layer, evtElement); // check this item is snapped to wall
|
|
1205
|
+
payload.isAttachedWall = MoldingUtils.isAttachedWall(layer, evtElement);
|
|
1206
|
+
// update distArray
|
|
1207
|
+
if (pointArray) payload.distArray = pointArray;
|
|
1208
|
+
}
|
|
1209
|
+
(_this2$props$onIntern = (_this2$props = _this2.props).onInternalEvent) === null || _this2$props$onIntern === void 0 || _this2$props$onIntern.call(_this2$props, {
|
|
1210
|
+
type: evtType,
|
|
1211
|
+
value: payload
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1187
1215
|
this.mouseDownEvent = function (event) {
|
|
1188
1216
|
gridPlanOrigin = gridPlane.position;
|
|
1189
1217
|
gridMatrix.copy(gridPlane.matrixWorld).invert();
|
|
@@ -1335,11 +1363,6 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1335
1363
|
if (selectedFlag || toolIntersects.length > 0 && !isElevationView(mode)) {
|
|
1336
1364
|
cameraControls.mouseButtons.left = CameraControls.ACTION.NONE;
|
|
1337
1365
|
selectedFlag = false;
|
|
1338
|
-
} else {
|
|
1339
|
-
isSelected = false;
|
|
1340
|
-
_this2.context.projectActions.unselectAll();
|
|
1341
|
-
scene3D.remove(toolObj);
|
|
1342
|
-
_this2.context.itemsActions.removeReplacingSupport();
|
|
1343
1366
|
}
|
|
1344
1367
|
}
|
|
1345
1368
|
} else {
|
|
@@ -1392,11 +1415,18 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1392
1415
|
}
|
|
1393
1416
|
switch (_this2.props.state.mode) {
|
|
1394
1417
|
case MODE_DRAGGING_ITEM_3D:
|
|
1418
|
+
case MODE_DRAGGING_HOLE_3D:
|
|
1395
1419
|
internalType = INTERNAL_EVENT_DRAG_ELEMENT;
|
|
1396
1420
|
break;
|
|
1397
1421
|
case MODE_ROTATING_ITEM_3D:
|
|
1398
1422
|
internalType = INTERNAL_EVENT_ROTATE_ELEMENT;
|
|
1399
1423
|
break;
|
|
1424
|
+
case MODE_DRAWING_HOLE_3D:
|
|
1425
|
+
internalType = INTERNAL_EVENT_DRAW_ELEMENT;
|
|
1426
|
+
break;
|
|
1427
|
+
case MODE_IDLE_3D:
|
|
1428
|
+
internalType = INTERNAL_EVENT_SELECT_ELEMENT;
|
|
1429
|
+
break;
|
|
1400
1430
|
}
|
|
1401
1431
|
if (_this2.props.state.mode == MODE_DRAGGING_ITEM_3D) {
|
|
1402
1432
|
_this2.context.itemsActions.endDraggingItem3D();
|
|
@@ -1430,7 +1460,8 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1430
1460
|
});
|
|
1431
1461
|
});
|
|
1432
1462
|
var intersects = raycaster.intersectObjects(meshes, true);
|
|
1433
|
-
var _i10;
|
|
1463
|
+
var _i10; // index of warning object in intersects
|
|
1464
|
+
|
|
1434
1465
|
if (intersects.length > 0 && !isNaN(intersects[0].distance)) {
|
|
1435
1466
|
for (_i10 = 0; _i10 < intersects.length; _i10++) {
|
|
1436
1467
|
if (intersects[_i10].object.name === 'warningObj') break;
|
|
@@ -1458,6 +1489,19 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1458
1489
|
}
|
|
1459
1490
|
}
|
|
1460
1491
|
gridMatrix.copy(gridPlane.matrixWorld).invert();
|
|
1492
|
+
var addItemToolObj = function addItemToolObj() {
|
|
1493
|
+
var _intersects$_i;
|
|
1494
|
+
var selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
|
|
1495
|
+
if (isUndefined(selectedItem)) return;
|
|
1496
|
+
selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
|
|
1497
|
+
var itemPos = selectedItem.position.clone();
|
|
1498
|
+
if (((_intersects$_i = intersects[_i10]) === null || _intersects$_i === void 0 || (_intersects$_i = _intersects$_i.object) === null || _intersects$_i === void 0 || (_intersects$_i = _intersects$_i.parent) === null || _intersects$_i === void 0 || (_intersects$_i = _intersects$_i.parent) === null || _intersects$_i === void 0 || (_intersects$_i = _intersects$_i.userData) === null || _intersects$_i === void 0 ? void 0 : _intersects$_i.itemId) === selectedItem.userData.itemId) {
|
|
1499
|
+
toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
|
|
1500
|
+
} else {
|
|
1501
|
+
toolObj.position.set(planData.plan.position.x + itemPos.x, selectedElement.category === 'lighting' ? -planData.plan.position.y - selectedElement.properties.get('height').get('length') : planData.plan.position.y + selectedItem.children[0].position.y, planData.plan.position.z + itemPos.z);
|
|
1502
|
+
}
|
|
1503
|
+
scene3D.add(toolObj);
|
|
1504
|
+
};
|
|
1461
1505
|
if (Math.abs(mouse.x - _this2.lastMousePosition.x) <= 0.02 && Math.abs(mouse.y - _this2.lastMousePosition.y) <= 0.02 || bMove) {
|
|
1462
1506
|
if (intersects.length > 0 && !isNaN(intersects[0].distance)) {
|
|
1463
1507
|
if (intersects[_i10] === undefined) {
|
|
@@ -1479,55 +1523,40 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1479
1523
|
currentObject = currentObject.parent;
|
|
1480
1524
|
}
|
|
1481
1525
|
isSelected = true;
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
cnt = 0;
|
|
1499
|
-
pointArray.push([fVLine[0].userData.distance, 90]);
|
|
1500
|
-
pointArray.push([fVLine[1].userData.distance, -90]);
|
|
1501
|
-
pointArray.push([fVLine[2].userData.distance, 180]);
|
|
1502
|
-
pointArray.push([fVLine[3].userData.distance, 0]);
|
|
1503
|
-
pointArray.forEach(function (pointElement, index) {
|
|
1504
|
-
if (pointElement[0] == undefined) pointArray[index][0] = 0;
|
|
1505
|
-
});
|
|
1506
|
-
pointArray.forEach(function (pointElement) {
|
|
1507
|
-
if (pointElement[0] == 0) cnt++;
|
|
1526
|
+
setTimeout(function () {
|
|
1527
|
+
getDistances(layer);
|
|
1528
|
+
addItemToolObj();
|
|
1529
|
+
_this2.setState({
|
|
1530
|
+
toolObj: toolObj
|
|
1531
|
+
});
|
|
1532
|
+
// showItemButtons(layer.getIn(['items', selectedObject.itemID]), currentObject, event, camera, this.renderer);
|
|
1533
|
+
var pointArray = [];
|
|
1534
|
+
// pointArray.push([fVLine[0].userData.distance, 90]);
|
|
1535
|
+
// pointArray.push([fVLine[1].userData.distance, -90]);
|
|
1536
|
+
// pointArray.push([fVLine[2].userData.distance, 180]);
|
|
1537
|
+
// pointArray.push([fVLine[3].userData.distance, 0]);
|
|
1538
|
+
pointArray = GeometryUtils.calcDistancesFromItemToWalls(selectedElement, layer).PointArray;
|
|
1539
|
+
actions.itemsActions.storeDistArray(layer.id, selectedObject.itemID, pointArray);
|
|
1540
|
+
internalType = internalType ? internalType : INTERNAL_EVENT_SELECT_ELEMENT;
|
|
1541
|
+
sendInternalEvent(internalType, selectedElement, pointArray);
|
|
1508
1542
|
});
|
|
1509
|
-
if (cnt == 4 || cnt == 3) {
|
|
1510
|
-
pointArray[0][0] = 100;
|
|
1511
|
-
pointArray[1][0] = 100;
|
|
1512
|
-
}
|
|
1513
|
-
actions.itemsActions.storeDistArray(layer.id, selectedObject.itemID, pointArray);
|
|
1514
|
-
internalType = internalType ? internalType : INTERNAL_EVENT_SELECT_ELEMENT;
|
|
1515
1543
|
} else {
|
|
1516
1544
|
if (selectedObject) {
|
|
1517
1545
|
var elementID = null;
|
|
1518
1546
|
var elementPrototype = null;
|
|
1519
1547
|
switch (true) {
|
|
1520
1548
|
case 'holeID' in selectedObject:
|
|
1521
|
-
|
|
1549
|
+
elementID = selectedObject.holeID;
|
|
1550
|
+
elementPrototype = 'holes';
|
|
1522
1551
|
if (_this2.props.state.mode === MODE_DRAGGING_HOLE_3D) {
|
|
1523
1552
|
actions.holesActions.endDraggingHole3D(sPoint.x, sPoint.y);
|
|
1524
|
-
internalType = INTERNAL_EVENT_SELECT_ELEMENT;
|
|
1525
|
-
elementID = selectedObject.holeID;
|
|
1526
|
-
elementPrototype = 'holes';
|
|
1527
1553
|
}
|
|
1528
1554
|
break;
|
|
1555
|
+
case 'lineID' in selectedObject:
|
|
1556
|
+
elementID = selectedObject.lineID;
|
|
1557
|
+
elementPrototype = 'lines';
|
|
1558
|
+
break;
|
|
1529
1559
|
case 'areaID' in selectedObject:
|
|
1530
|
-
internalType = INTERNAL_EVENT_SELECT_ELEMENT;
|
|
1531
1560
|
elementID = selectedObject.areaID;
|
|
1532
1561
|
elementPrototype = 'areas';
|
|
1533
1562
|
break;
|
|
@@ -1539,15 +1568,20 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1539
1568
|
isSelected = false;
|
|
1540
1569
|
}
|
|
1541
1570
|
} else {
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1571
|
+
var selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
|
|
1572
|
+
if (bMove && !isEmpty(selectedItem)) {
|
|
1573
|
+
addItemToolObj();
|
|
1574
|
+
} else {
|
|
1575
|
+
isSelected = false;
|
|
1576
|
+
_this2.context.projectActions.unselectAll();
|
|
1577
|
+
switch (true) {
|
|
1578
|
+
case 'holeID' in selectedObject:
|
|
1579
|
+
actions.holesActions.endDraggingHole3D(sPoint.x, sPoint.y);
|
|
1580
|
+
break;
|
|
1581
|
+
default:
|
|
1582
|
+
_this2.context.itemsActions.removeReplacingSupport();
|
|
1583
|
+
break;
|
|
1584
|
+
}
|
|
1551
1585
|
}
|
|
1552
1586
|
}
|
|
1553
1587
|
bMove = false;
|
|
@@ -1568,35 +1602,15 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1568
1602
|
}
|
|
1569
1603
|
getPoint(event, alti);
|
|
1570
1604
|
if (bRotate) {
|
|
1571
|
-
|
|
1572
|
-
var _selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
|
|
1573
|
-
if (isUndefined(_selectedItem)) return;
|
|
1574
|
-
selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
|
|
1575
|
-
var _itemPos = _selectedItem.position.clone();
|
|
1576
|
-
if (((_intersects$_i = intersects[_i10]) === null || _intersects$_i === void 0 || (_intersects$_i = _intersects$_i.object) === null || _intersects$_i === void 0 || (_intersects$_i = _intersects$_i.parent) === null || _intersects$_i === void 0 || (_intersects$_i = _intersects$_i.parent) === null || _intersects$_i === void 0 || (_intersects$_i = _intersects$_i.userData) === null || _intersects$_i === void 0 ? void 0 : _intersects$_i.itemId) === _selectedItem.userData.itemId) {
|
|
1577
|
-
toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
|
|
1578
|
-
} else {
|
|
1579
|
-
toolObj.position.set(planData.plan.position.x + _itemPos.x, selectedElement.category === 'lighting' ? -planData.plan.position.y - selectedElement.properties.get('height').get('length') : planData.plan.position.y + _selectedItem.children[0].position.y, planData.plan.position.z + _itemPos.z);
|
|
1580
|
-
}
|
|
1581
|
-
scene3D.add(toolObj);
|
|
1605
|
+
addItemToolObj();
|
|
1582
1606
|
_this2.setState({
|
|
1583
1607
|
toolObj: toolObj
|
|
1584
1608
|
});
|
|
1585
1609
|
_this2.context.itemsActions.endRotatingItem3D(Point.x, Point.y);
|
|
1586
1610
|
bRotate = false;
|
|
1587
|
-
}
|
|
1588
|
-
if (bMove) {
|
|
1611
|
+
} else if (bMove) {
|
|
1589
1612
|
bMove = false;
|
|
1590
|
-
|
|
1591
|
-
if (isUndefined(_selectedItem2)) return;
|
|
1592
|
-
selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
|
|
1593
|
-
var _itemPos2 = _selectedItem2.position.clone();
|
|
1594
|
-
if (intersects[_i10].object.parent.parent.userData.itemId === _selectedItem2.userData.itemId) {
|
|
1595
|
-
toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
|
|
1596
|
-
} else {
|
|
1597
|
-
toolObj.position.set(planData.plan.position.x + _itemPos2.x, selectedElement.category === 'lighting' ? -planData.plan.position.y - selectedElement.properties.get('height').get('length') : planData.plan.position.y + _selectedItem2.children[0].position.y, planData.plan.position.z + _itemPos2.z);
|
|
1598
|
-
}
|
|
1599
|
-
scene3D.add(toolObj);
|
|
1613
|
+
addItemToolObj();
|
|
1600
1614
|
_this2.setState({
|
|
1601
1615
|
toolObj: toolObj
|
|
1602
1616
|
});
|
|
@@ -1616,7 +1630,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1616
1630
|
_item3D.position.z = targetPoint.z;
|
|
1617
1631
|
_item3D.visible = true;
|
|
1618
1632
|
}
|
|
1619
|
-
}
|
|
1633
|
+
} else {}
|
|
1620
1634
|
if (bMoveUP) {
|
|
1621
1635
|
bMoveUP = false;
|
|
1622
1636
|
}
|
|
@@ -1628,20 +1642,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1628
1642
|
selectedObj = allItemRect.cur;
|
|
1629
1643
|
}
|
|
1630
1644
|
}
|
|
1631
|
-
|
|
1632
|
-
var _selectedElement, _selectedElement2, _this2$props$onIntern, _this2$props;
|
|
1633
|
-
var payload = (_selectedElement = selectedElement) === null || _selectedElement === void 0 ? void 0 : _selectedElement.toJS();
|
|
1634
|
-
if (((_selectedElement2 = selectedElement) === null || _selectedElement2 === void 0 ? void 0 : _selectedElement2.prototype) === 'items') {
|
|
1635
|
-
// check this cabinet has warning box
|
|
1636
|
-
payload.isWarning = isWarningItem(selectedElement);
|
|
1637
|
-
// check this item is snapped to wall
|
|
1638
|
-
payload.isAttachedWall = MoldingUtils.isAttachedWall(layer, selectedElement);
|
|
1639
|
-
}
|
|
1640
|
-
(_this2$props$onIntern = (_this2$props = _this2.props).onInternalEvent) === null || _this2$props$onIntern === void 0 || _this2$props$onIntern.call(_this2$props, {
|
|
1641
|
-
type: internalType,
|
|
1642
|
-
value: payload
|
|
1643
|
-
});
|
|
1644
|
-
}
|
|
1645
|
+
sendInternalEvent(internalType, selectedElement);
|
|
1645
1646
|
};
|
|
1646
1647
|
this.mouseEnterEvent = function (event) {
|
|
1647
1648
|
if (_this2.props.state.mode !== MODE_DRAWING_ITEM_3D) return;
|
|
@@ -2076,7 +2077,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
2076
2077
|
if (minDis < snapDelta && !snapFlag) {
|
|
2077
2078
|
_this2.snap(snapObj, layer);
|
|
2078
2079
|
snapFlag = true;
|
|
2079
|
-
getDistances(layer
|
|
2080
|
+
getDistances(layer);
|
|
2080
2081
|
var _i13 = 0;
|
|
2081
2082
|
for (_i13 = 0; _i13 < fVLine.length; _i13++) {
|
|
2082
2083
|
if (fVLine[_i13].userData.distance < snapDelta) {
|
|
@@ -2609,9 +2610,10 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
2609
2610
|
}, /*#__PURE__*/React.createElement("img", {
|
|
2610
2611
|
style: {
|
|
2611
2612
|
animation: 'spin 2s linear infinite',
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2613
|
+
position: "absolute",
|
|
2614
|
+
top: "50%",
|
|
2615
|
+
width: '70px',
|
|
2616
|
+
height: '70px'
|
|
2615
2617
|
},
|
|
2616
2618
|
src: '/assets/img/loading/loading.gif',
|
|
2617
2619
|
alt: "img"
|
|
@@ -2631,8 +2633,8 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
2631
2633
|
animation: 'spin 2s linear infinite',
|
|
2632
2634
|
position: "absolute",
|
|
2633
2635
|
top: "50%",
|
|
2634
|
-
width: '
|
|
2635
|
-
height: '
|
|
2636
|
+
width: '70px',
|
|
2637
|
+
height: '70px'
|
|
2636
2638
|
},
|
|
2637
2639
|
src: '/assets/img/loading/loading.gif',
|
|
2638
2640
|
alt: "img"
|