kitchen-simulator 3.1.11 → 3.1.13
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/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 +197 -197
- package/es/components/viewer2d/item.js +36 -12
- package/es/components/viewer3d/viewer3d.js +46 -71
- package/es/constants.js +1 -1
- package/es/devLiteRenderer.js +108 -98
- package/es/utils/geometry.js +50 -94
- package/es/utils/isolate-event-handler.js +23 -7
- 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 +194 -194
- package/lib/components/viewer2d/item.js +36 -12
- package/lib/components/viewer3d/viewer3d.js +46 -71
- package/lib/constants.js +1 -1
- package/lib/devLiteRenderer.js +103 -93
- package/lib/utils/geometry.js +50 -94
- package/lib/utils/isolate-event-handler.js +23 -7
- package/package.json +1 -1
|
@@ -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
|
}
|
|
@@ -1187,12 +1187,12 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1187
1187
|
var sendInternalEvent = function sendInternalEvent(evtType, evtElement) {
|
|
1188
1188
|
var pointArray = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
1189
1189
|
if (!isEmpty(evtType) && !isEmpty(evtElement)) {
|
|
1190
|
-
var
|
|
1190
|
+
var _this2$props$onIntern, _this2$props;
|
|
1191
1191
|
var payload = evtElement === null || evtElement === void 0 ? void 0 : evtElement.toJS();
|
|
1192
|
-
if ((
|
|
1192
|
+
if ((evtElement === null || evtElement === void 0 ? void 0 : evtElement.prototype) === 'lines') {
|
|
1193
1193
|
// caculating length of selected line//
|
|
1194
|
-
var v_a = layer.vertices.get(
|
|
1195
|
-
var v_b = layer.vertices.get(
|
|
1194
|
+
var v_a = layer.vertices.get(evtElement.vertices.get(0));
|
|
1195
|
+
var v_b = layer.vertices.get(evtElement.vertices.get(1));
|
|
1196
1196
|
var distance = GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
|
|
1197
1197
|
var _length = convert(distance).from('cm').to('in');
|
|
1198
1198
|
payload.length = _length;
|
|
@@ -1296,7 +1296,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1296
1296
|
if (intersects[_i1] === undefined) {
|
|
1297
1297
|
if (transflag !== 0 && transflag !== 2) {
|
|
1298
1298
|
isSelected = false;
|
|
1299
|
-
|
|
1299
|
+
_this2.context.projectActions.unselectAll();
|
|
1300
1300
|
scene3D.remove(toolObj);
|
|
1301
1301
|
_this2.context.itemsActions.removeReplacingSupport();
|
|
1302
1302
|
return;
|
|
@@ -1363,16 +1363,11 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1363
1363
|
if (selectedFlag || toolIntersects.length > 0 && !isElevationView(mode)) {
|
|
1364
1364
|
cameraControls.mouseButtons.left = CameraControls.ACTION.NONE;
|
|
1365
1365
|
selectedFlag = false;
|
|
1366
|
-
} else {
|
|
1367
|
-
isSelected = false;
|
|
1368
|
-
// this.context.projectActions.unselectAll();
|
|
1369
|
-
scene3D.remove(toolObj);
|
|
1370
|
-
_this2.context.itemsActions.removeReplacingSupport();
|
|
1371
1366
|
}
|
|
1372
1367
|
}
|
|
1373
1368
|
} else {
|
|
1374
1369
|
isSelected = false;
|
|
1375
|
-
|
|
1370
|
+
_this2.context.projectActions.unselectAll();
|
|
1376
1371
|
scene3D.remove(toolObj);
|
|
1377
1372
|
_this2.context.itemsActions.removeReplacingSupport();
|
|
1378
1373
|
return;
|
|
@@ -1465,7 +1460,8 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1465
1460
|
});
|
|
1466
1461
|
});
|
|
1467
1462
|
var intersects = raycaster.intersectObjects(meshes, true);
|
|
1468
|
-
var _i10;
|
|
1463
|
+
var _i10; // index of warning object in intersects
|
|
1464
|
+
|
|
1469
1465
|
if (intersects.length > 0 && !isNaN(intersects[0].distance)) {
|
|
1470
1466
|
for (_i10 = 0; _i10 < intersects.length; _i10++) {
|
|
1471
1467
|
if (intersects[_i10].object.name === 'warningObj') break;
|
|
@@ -1493,6 +1489,19 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1493
1489
|
}
|
|
1494
1490
|
}
|
|
1495
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
|
+
};
|
|
1496
1505
|
if (Math.abs(mouse.x - _this2.lastMousePosition.x) <= 0.02 && Math.abs(mouse.y - _this2.lastMousePosition.y) <= 0.02 || bMove) {
|
|
1497
1506
|
if (intersects.length > 0 && !isNaN(intersects[0].distance)) {
|
|
1498
1507
|
if (intersects[_i10] === undefined) {
|
|
@@ -1516,36 +1525,17 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1516
1525
|
isSelected = true;
|
|
1517
1526
|
setTimeout(function () {
|
|
1518
1527
|
getDistances(layer);
|
|
1519
|
-
|
|
1520
|
-
if (isUndefined(selectedItem)) return;
|
|
1521
|
-
selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
|
|
1522
|
-
var itemPos = selectedItem.position.clone();
|
|
1523
|
-
if (intersects[_i10].object.parent && intersects[_i10].object.parent.parent.userData.itemId === selectedItem.userData.itemId) {
|
|
1524
|
-
toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
|
|
1525
|
-
} else {
|
|
1526
|
-
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);
|
|
1527
|
-
}
|
|
1528
|
-
scene3D.add(toolObj);
|
|
1528
|
+
addItemToolObj();
|
|
1529
1529
|
_this2.setState({
|
|
1530
1530
|
toolObj: toolObj
|
|
1531
1531
|
});
|
|
1532
1532
|
// showItemButtons(layer.getIn(['items', selectedObject.itemID]), currentObject, event, camera, this.renderer);
|
|
1533
|
-
var pointArray = []
|
|
1534
|
-
|
|
1535
|
-
pointArray.push([fVLine[
|
|
1536
|
-
pointArray.push([fVLine[
|
|
1537
|
-
pointArray.push([fVLine[
|
|
1538
|
-
pointArray.
|
|
1539
|
-
pointArray.forEach(function (pointElement, index) {
|
|
1540
|
-
if (pointElement[0] == undefined) pointArray[index][0] = 0;
|
|
1541
|
-
});
|
|
1542
|
-
pointArray.forEach(function (pointElement) {
|
|
1543
|
-
if (pointElement[0] == 0) cnt++;
|
|
1544
|
-
});
|
|
1545
|
-
if (cnt == 4 || cnt == 3) {
|
|
1546
|
-
pointArray[0][0] = 100;
|
|
1547
|
-
pointArray[1][0] = 100;
|
|
1548
|
-
}
|
|
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;
|
|
1549
1539
|
actions.itemsActions.storeDistArray(layer.id, selectedObject.itemID, pointArray);
|
|
1550
1540
|
internalType = internalType ? internalType : INTERNAL_EVENT_SELECT_ELEMENT;
|
|
1551
1541
|
sendInternalEvent(internalType, selectedElement, pointArray);
|
|
@@ -1578,15 +1568,20 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1578
1568
|
isSelected = false;
|
|
1579
1569
|
}
|
|
1580
1570
|
} else {
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
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
|
+
}
|
|
1590
1585
|
}
|
|
1591
1586
|
}
|
|
1592
1587
|
bMove = false;
|
|
@@ -1607,35 +1602,15 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1607
1602
|
}
|
|
1608
1603
|
getPoint(event, alti);
|
|
1609
1604
|
if (bRotate) {
|
|
1610
|
-
|
|
1611
|
-
var selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
|
|
1612
|
-
if (isUndefined(selectedItem)) return;
|
|
1613
|
-
selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
|
|
1614
|
-
var itemPos = selectedItem.position.clone();
|
|
1615
|
-
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) {
|
|
1616
|
-
toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
|
|
1617
|
-
} else {
|
|
1618
|
-
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);
|
|
1619
|
-
}
|
|
1620
|
-
scene3D.add(toolObj);
|
|
1605
|
+
addItemToolObj();
|
|
1621
1606
|
_this2.setState({
|
|
1622
1607
|
toolObj: toolObj
|
|
1623
1608
|
});
|
|
1624
1609
|
_this2.context.itemsActions.endRotatingItem3D(Point.x, Point.y);
|
|
1625
1610
|
bRotate = false;
|
|
1626
|
-
}
|
|
1627
|
-
if (bMove) {
|
|
1611
|
+
} else if (bMove) {
|
|
1628
1612
|
bMove = false;
|
|
1629
|
-
|
|
1630
|
-
if (isUndefined(_selectedItem)) return;
|
|
1631
|
-
selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
|
|
1632
|
-
var _itemPos = _selectedItem.position.clone();
|
|
1633
|
-
if (intersects[_i10].object.parent.parent.userData.itemId === _selectedItem.userData.itemId) {
|
|
1634
|
-
toolObj.position.set(intersects[_i10].point.x, intersects[_i10].point.y, intersects[_i10].point.z);
|
|
1635
|
-
} else {
|
|
1636
|
-
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);
|
|
1637
|
-
}
|
|
1638
|
-
scene3D.add(toolObj);
|
|
1613
|
+
addItemToolObj();
|
|
1639
1614
|
_this2.setState({
|
|
1640
1615
|
toolObj: toolObj
|
|
1641
1616
|
});
|
|
@@ -1655,7 +1630,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
1655
1630
|
_item3D.position.z = targetPoint.z;
|
|
1656
1631
|
_item3D.visible = true;
|
|
1657
1632
|
}
|
|
1658
|
-
}
|
|
1633
|
+
} else {}
|
|
1659
1634
|
if (bMoveUP) {
|
|
1660
1635
|
bMoveUP = false;
|
|
1661
1636
|
}
|
package/es/constants.js
CHANGED
|
@@ -653,7 +653,7 @@ export var PROJECT_SETTING_OPTION = {
|
|
|
653
653
|
CHANGE_WINDOW_DOOR_MEASURE: CHANGE_WINDOW_DOOR_MEASURE
|
|
654
654
|
};
|
|
655
655
|
export var HOLE_NAMES = {
|
|
656
|
-
WINDOW_CLEAR: '
|
|
656
|
+
WINDOW_CLEAR: 'Window',
|
|
657
657
|
WINDOW_CROSS: 'Cross Window',
|
|
658
658
|
WINDOW_DOUBLE_HUNG: 'Double Hung Window',
|
|
659
659
|
WINDOW_VERTICAL: 'window-vertical',
|