kitchen-simulator 2.0.60 → 3.0.0

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.
@@ -17,6 +17,7 @@ import { Map } from 'immutable';
17
17
  import { formatNumber } from "../../utils/math";
18
18
  import { isEmpty } from "../../utils/helper"; // variables
19
19
  import { isWarningItem } from "./utils";
20
+ import { MoldingUtils } from "../../utils/export";
20
21
  // variables
21
22
  var pinFlag = false;
22
23
  var sFlag = false; //for all object move
@@ -1263,6 +1264,8 @@ export default function Viewer2D(_ref, _ref2) {
1263
1264
  } else if (((_currentObject5 = _currentObject) === null || _currentObject5 === void 0 ? void 0 : _currentObject5.prototype) === 'items') {
1264
1265
  // check this cabinet has warning box
1265
1266
  payload.isWarning = isWarningItem(_currentObject);
1267
+ // check this item is snapped to wall
1268
+ payload.isAttachedWall = MoldingUtils.isAttachedWall(layer, _currentObject);
1266
1269
  }
1267
1270
 
1268
1271
  // send selection event befor replace event
@@ -27,8 +27,9 @@ import { GeometryUtils } from "../../utils/export";
27
27
  import { handleCamRect, isElevationView, isEmpty } from "../../utils/helper";
28
28
  import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader';
29
29
  import CameraControls from 'camera-controls';
30
- import { returnReplaceableDeepSearchType } from "../viewer2d/utils";
31
30
  import { getAllMeshes, vectorIntersectWithMesh } from "../../utils/objects-utils";
31
+ import { isWarningItem, returnReplaceableDeepSearchType } from "../viewer2d/utils";
32
+ import { MoldingUtils } from "../../utils/export";
32
33
  CameraControls.install({
33
34
  THREE: Three
34
35
  });
@@ -1522,7 +1523,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1522
1523
  actions.holesActions.endDraggingHole3D(sPoint.x, sPoint.y);
1523
1524
  internalType = INTERNAL_EVENT_SELECT_ELEMENT;
1524
1525
  elementID = selectedObject.holeID;
1525
- elementPrototype = 'holeID';
1526
+ elementPrototype = 'holes';
1526
1527
  }
1527
1528
  break;
1528
1529
  case 'areaID' in selectedObject:
@@ -1628,10 +1629,17 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1628
1629
  }
1629
1630
  }
1630
1631
  if (!isEmpty(internalType)) {
1631
- var _this2$props$onIntern, _this2$props, _selectedElement;
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
+ }
1632
1640
  (_this2$props$onIntern = (_this2$props = _this2.props).onInternalEvent) === null || _this2$props$onIntern === void 0 || _this2$props$onIntern.call(_this2$props, {
1633
1641
  type: internalType,
1634
- value: (_selectedElement = selectedElement) === null || _selectedElement === void 0 ? void 0 : _selectedElement.toJS()
1642
+ value: payload
1635
1643
  });
1636
1644
  }
1637
1645
  };
@@ -62,6 +62,10 @@ export function isEnableItemForMolding(layer, selItem) {
62
62
  // check this item is enable for specified molding
63
63
  else return result && hasMoldingLayout(molding, selItem.layoutpos);
64
64
  }
65
+ export function isAttachedWall(layer, selItem) {
66
+ var allLineRects = GeometryUtils.buildRectFromLines(layer, GeometryUtils.getAllLines(layer));
67
+ return GeometryUtils.isSnappedLine(getItemRect(selItem), allLineRects);
68
+ }
65
69
 
66
70
  /**
67
71
  * Check two line segments are overlap. The direction of the two line segments must be opposite.
@@ -1272,6 +1272,8 @@ function Viewer2D(_ref, _ref2) {
1272
1272
  } else if (((_currentObject5 = _currentObject) === null || _currentObject5 === void 0 ? void 0 : _currentObject5.prototype) === 'items') {
1273
1273
  // check this cabinet has warning box
1274
1274
  payload.isWarning = (0, _utils.isWarningItem)(_currentObject);
1275
+ // check this item is snapped to wall
1276
+ payload.isAttachedWall = _export2.MoldingUtils.isAttachedWall(layer, _currentObject);
1275
1277
  }
1276
1278
 
1277
1279
  // send selection event befor replace event
@@ -29,8 +29,8 @@ var _export = require("../../utils/export");
29
29
  var _helper = require("../../utils/helper");
30
30
  var _RGBELoader = require("three/examples/jsm/loaders/RGBELoader");
31
31
  var _cameraControls = _interopRequireDefault(require("camera-controls"));
32
- var _utils = require("../viewer2d/utils");
33
32
  var _objectsUtils = require("../../utils/objects-utils");
33
+ var _utils = require("../viewer2d/utils");
34
34
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
35
35
  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; }
36
36
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -1529,7 +1529,7 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1529
1529
  actions.holesActions.endDraggingHole3D(sPoint.x, sPoint.y);
1530
1530
  internalType = _constants.INTERNAL_EVENT_SELECT_ELEMENT;
1531
1531
  elementID = selectedObject.holeID;
1532
- elementPrototype = 'holeID';
1532
+ elementPrototype = 'holes';
1533
1533
  }
1534
1534
  break;
1535
1535
  case 'areaID' in selectedObject:
@@ -1635,10 +1635,17 @@ var Scene3DViewer = exports["default"] = /*#__PURE__*/function (_React$Component
1635
1635
  }
1636
1636
  }
1637
1637
  if (!(0, _helper.isEmpty)(internalType)) {
1638
- var _this2$props$onIntern, _this2$props, _selectedElement;
1638
+ var _selectedElement, _selectedElement2, _this2$props$onIntern, _this2$props;
1639
+ var payload = (_selectedElement = selectedElement) === null || _selectedElement === void 0 ? void 0 : _selectedElement.toJS();
1640
+ if (((_selectedElement2 = selectedElement) === null || _selectedElement2 === void 0 ? void 0 : _selectedElement2.prototype) === 'items') {
1641
+ // check this cabinet has warning box
1642
+ payload.isWarning = (0, _utils.isWarningItem)(selectedElement);
1643
+ // check this item is snapped to wall
1644
+ payload.isAttachedWall = _export.MoldingUtils.isAttachedWall(layer, selectedElement);
1645
+ }
1639
1646
  (_this2$props$onIntern = (_this2$props = _this2.props).onInternalEvent) === null || _this2$props$onIntern === void 0 || _this2$props$onIntern.call(_this2$props, {
1640
1647
  type: internalType,
1641
- value: (_selectedElement = selectedElement) === null || _selectedElement === void 0 ? void 0 : _selectedElement.toJS()
1648
+ value: payload
1642
1649
  });
1643
1650
  }
1644
1651
  };
@@ -13,6 +13,7 @@ exports.getLinesFromItems = getLinesFromItems;
13
13
  exports.getLinesFromItems2 = getLinesFromItems2;
14
14
  exports.getLinesOfItem = getLinesOfItem;
15
15
  exports.hasMoldingLayout = hasMoldingLayout;
16
+ exports.isAttachedWall = isAttachedWall;
16
17
  exports.isEnableItemForMolding = isEnableItemForMolding;
17
18
  exports.isItemSameItemByLocation = isItemSameItemByLocation;
18
19
  exports.isItemSnappedGroup = isItemSnappedGroup;
@@ -87,6 +88,10 @@ function isEnableItemForMolding(layer, selItem) {
87
88
  // check this item is enable for specified molding
88
89
  else return result && hasMoldingLayout(molding, selItem.layoutpos);
89
90
  }
91
+ function isAttachedWall(layer, selItem) {
92
+ var allLineRects = _export.GeometryUtils.buildRectFromLines(layer, _export.GeometryUtils.getAllLines(layer));
93
+ return _export.GeometryUtils.isSnappedLine(getItemRect(selItem), allLineRects);
94
+ }
90
95
 
91
96
  /**
92
97
  * Check two line segments are overlap. The direction of the two line segments must be opposite.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "2.0.60",
3
+ "version": "3.0.0",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",