kitchen-simulator 4.3.4 → 4.3.5

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.
@@ -2621,18 +2621,23 @@ export function calcDistancesFromHoleToNearestOneOrWall(curHole, layer) {
2621
2621
  var line = (_layer$lines = layer.lines) === null || _layer$lines === void 0 ? void 0 : _layer$lines.get(curHole.line);
2622
2622
  var v0 = (_layer$vertices2 = layer.vertices) === null || _layer$vertices2 === void 0 ? void 0 : _layer$vertices2.get(line === null || line === void 0 || (_line$vertices = line.vertices) === null || _line$vertices === void 0 ? void 0 : _line$vertices.get(0));
2623
2623
  var v1 = (_layer$vertices3 = layer.vertices) === null || _layer$vertices3 === void 0 ? void 0 : _layer$vertices3.get(line === null || line === void 0 || (_line$vertices2 = line.vertices) === null || _line$vertices2 === void 0 ? void 0 : _line$vertices2.get(1));
2624
+ var lineLength = pointsDistance(v0.x, v0.y, v1.x, v1.y);
2624
2625
  if (isEmpty(line) || isEmpty(v0) || isEmpty(v1)) return distArray;
2625
2626
  var angle = angleBetweenTwoPoints(v0.x, v0.y, v1.x, v1.y);
2626
2627
 
2627
2628
  // start point and end point of current hole
2628
2629
  var chw = (_curHole$properties$g = (_curHole$properties = curHole.properties) === null || _curHole$properties === void 0 || (_curHole$properties = _curHole$properties.get('width')) === null || _curHole$properties === void 0 ? void 0 : _curHole$properties.get('length')) !== null && _curHole$properties$g !== void 0 ? _curHole$properties$g : 0;
2630
+ var chPt = {
2631
+ x: v0.x + lineLength * curHole.offset * Math.cos(angle),
2632
+ y: v0.y + lineLength * curHole.offset * Math.sin(angle)
2633
+ };
2629
2634
  var chsp = {
2630
- x: curHole.x - chw / 2 * Math.cos(angle),
2631
- y: curHole.y - chw / 2 * Math.sin(angle)
2635
+ x: chPt.x - chw / 2 * Math.cos(angle),
2636
+ y: chPt.y - chw / 2 * Math.sin(angle)
2632
2637
  };
2633
2638
  var chep = {
2634
- x: curHole.x + chw / 2 * Math.cos(angle),
2635
- y: curHole.y + chw / 2 * Math.sin(angle)
2639
+ x: chPt.x + chw / 2 * Math.cos(angle),
2640
+ y: chPt.y + chw / 2 * Math.sin(angle)
2636
2641
  };
2637
2642
  distArray.distLeft = pointsDistance(v0.x, v0.y, chsp.x, chsp.y);
2638
2643
  distArray.distRight = pointsDistance(v1.x, v1.y, chep.x, chep.y);
@@ -2642,13 +2647,17 @@ export function calcDistancesFromHoleToNearestOneOrWall(curHole, layer) {
2642
2647
  var hole = (_layer$holes = layer.holes) === null || _layer$holes === void 0 ? void 0 : _layer$holes.get(hId);
2643
2648
  // start point and end point of other hole
2644
2649
  var hw = (_hole$properties$get$ = (_hole$properties = hole.properties) === null || _hole$properties === void 0 || (_hole$properties = _hole$properties.get('width')) === null || _hole$properties === void 0 ? void 0 : _hole$properties.get('length')) !== null && _hole$properties$get$ !== void 0 ? _hole$properties$get$ : 0;
2650
+ var hPt = {
2651
+ x: v0.x + lineLength * hole.offset * Math.cos(angle),
2652
+ y: v0.y + lineLength * hole.offset * Math.sin(angle)
2653
+ };
2645
2654
  var hsp = {
2646
- x: hole.x - hw / 2 * Math.cos(angle),
2647
- y: hole.y - hw / 2 * Math.sin(angle)
2655
+ x: hPt.x - hw / 2 * Math.cos(angle),
2656
+ y: hPt.y - hw / 2 * Math.sin(angle)
2648
2657
  };
2649
2658
  var hep = {
2650
- x: hole.x + hw / 2 * Math.cos(angle),
2651
- y: hole.y + hw / 2 * Math.sin(angle)
2659
+ x: hPt.x + hw / 2 * Math.cos(angle),
2660
+ y: hPt.y + hw / 2 * Math.sin(angle)
2652
2661
  };
2653
2662
  var relation = relationshipOfTwoOverlappedLines({
2654
2663
  x1: chsp.x,
@@ -899,13 +899,14 @@ function updateAttributeOfSelectedElement(element, attrPayload, state, layer, ca
899
899
  x1 = _layer$vertices$get4.x,
900
900
  y1 = _layer$vertices$get4.y;
901
901
  var alpha = GeometryUtils.angleBetweenTwoPoints(x0, y0, x1, y1);
902
+ var lineLength = GeometryUtils.pointsDistance(x0, y0, x1, y1);
902
903
  // move curHole
903
904
  var _calcDistancesFromHol = calcDistancesFromHoleToNearestOneOrWall(curHole, layer),
904
905
  distLeft = _calcDistancesFromHol.distLeft,
905
906
  distRight = _calcDistancesFromHol.distRight; // old distArray
906
907
  var mDistance = attributeName === ATT_HOLE_OFFSET_A ? distLeft - value.get('length') : value.get('length') - distRight; // movement distance
907
- var xp = curHole.x - mDistance * Math.cos(alpha);
908
- var yp = curHole.y - mDistance * Math.sin(alpha);
908
+ var xp = x0 + (lineLength * curHole.offset - mDistance) * Math.cos(alpha);
909
+ var yp = y0 + (lineLength * curHole.offset - mDistance) * Math.sin(alpha);
909
910
  var offset = GeometryUtils.pointPositionOnLineSegment(x0, y0, x1, y1, xp, yp);
910
911
  // make temp hole for calc new distArray
911
912
  var newHole = {
@@ -2723,18 +2723,23 @@ function calcDistancesFromHoleToNearestOneOrWall(curHole, layer) {
2723
2723
  var line = (_layer$lines = layer.lines) === null || _layer$lines === void 0 ? void 0 : _layer$lines.get(curHole.line);
2724
2724
  var v0 = (_layer$vertices2 = layer.vertices) === null || _layer$vertices2 === void 0 ? void 0 : _layer$vertices2.get(line === null || line === void 0 || (_line$vertices = line.vertices) === null || _line$vertices === void 0 ? void 0 : _line$vertices.get(0));
2725
2725
  var v1 = (_layer$vertices3 = layer.vertices) === null || _layer$vertices3 === void 0 ? void 0 : _layer$vertices3.get(line === null || line === void 0 || (_line$vertices2 = line.vertices) === null || _line$vertices2 === void 0 ? void 0 : _line$vertices2.get(1));
2726
+ var lineLength = pointsDistance(v0.x, v0.y, v1.x, v1.y);
2726
2727
  if ((0, _helper.isEmpty)(line) || (0, _helper.isEmpty)(v0) || (0, _helper.isEmpty)(v1)) return distArray;
2727
2728
  var angle = angleBetweenTwoPoints(v0.x, v0.y, v1.x, v1.y);
2728
2729
 
2729
2730
  // start point and end point of current hole
2730
2731
  var chw = (_curHole$properties$g = (_curHole$properties = curHole.properties) === null || _curHole$properties === void 0 || (_curHole$properties = _curHole$properties.get('width')) === null || _curHole$properties === void 0 ? void 0 : _curHole$properties.get('length')) !== null && _curHole$properties$g !== void 0 ? _curHole$properties$g : 0;
2732
+ var chPt = {
2733
+ x: v0.x + lineLength * curHole.offset * Math.cos(angle),
2734
+ y: v0.y + lineLength * curHole.offset * Math.sin(angle)
2735
+ };
2731
2736
  var chsp = {
2732
- x: curHole.x - chw / 2 * Math.cos(angle),
2733
- y: curHole.y - chw / 2 * Math.sin(angle)
2737
+ x: chPt.x - chw / 2 * Math.cos(angle),
2738
+ y: chPt.y - chw / 2 * Math.sin(angle)
2734
2739
  };
2735
2740
  var chep = {
2736
- x: curHole.x + chw / 2 * Math.cos(angle),
2737
- y: curHole.y + chw / 2 * Math.sin(angle)
2741
+ x: chPt.x + chw / 2 * Math.cos(angle),
2742
+ y: chPt.y + chw / 2 * Math.sin(angle)
2738
2743
  };
2739
2744
  distArray.distLeft = pointsDistance(v0.x, v0.y, chsp.x, chsp.y);
2740
2745
  distArray.distRight = pointsDistance(v1.x, v1.y, chep.x, chep.y);
@@ -2744,13 +2749,17 @@ function calcDistancesFromHoleToNearestOneOrWall(curHole, layer) {
2744
2749
  var hole = (_layer$holes = layer.holes) === null || _layer$holes === void 0 ? void 0 : _layer$holes.get(hId);
2745
2750
  // start point and end point of other hole
2746
2751
  var hw = (_hole$properties$get$ = (_hole$properties = hole.properties) === null || _hole$properties === void 0 || (_hole$properties = _hole$properties.get('width')) === null || _hole$properties === void 0 ? void 0 : _hole$properties.get('length')) !== null && _hole$properties$get$ !== void 0 ? _hole$properties$get$ : 0;
2752
+ var hPt = {
2753
+ x: v0.x + lineLength * hole.offset * Math.cos(angle),
2754
+ y: v0.y + lineLength * hole.offset * Math.sin(angle)
2755
+ };
2747
2756
  var hsp = {
2748
- x: hole.x - hw / 2 * Math.cos(angle),
2749
- y: hole.y - hw / 2 * Math.sin(angle)
2757
+ x: hPt.x - hw / 2 * Math.cos(angle),
2758
+ y: hPt.y - hw / 2 * Math.sin(angle)
2750
2759
  };
2751
2760
  var hep = {
2752
- x: hole.x + hw / 2 * Math.cos(angle),
2753
- y: hole.y + hw / 2 * Math.sin(angle)
2761
+ x: hPt.x + hw / 2 * Math.cos(angle),
2762
+ y: hPt.y + hw / 2 * Math.sin(angle)
2754
2763
  };
2755
2764
  var relation = relationshipOfTwoOverlappedLines({
2756
2765
  x1: chsp.x,
@@ -907,13 +907,14 @@ function updateAttributeOfSelectedElement(element, attrPayload, state, layer, ca
907
907
  x1 = _layer$vertices$get4.x,
908
908
  y1 = _layer$vertices$get4.y;
909
909
  var alpha = _export.GeometryUtils.angleBetweenTwoPoints(x0, y0, x1, y1);
910
+ var lineLength = _export.GeometryUtils.pointsDistance(x0, y0, x1, y1);
910
911
  // move curHole
911
912
  var _calcDistancesFromHol = (0, _geometry.calcDistancesFromHoleToNearestOneOrWall)(curHole, layer),
912
913
  distLeft = _calcDistancesFromHol.distLeft,
913
914
  distRight = _calcDistancesFromHol.distRight; // old distArray
914
915
  var mDistance = attributeName === _constants.ATT_HOLE_OFFSET_A ? distLeft - value.get('length') : value.get('length') - distRight; // movement distance
915
- var xp = curHole.x - mDistance * Math.cos(alpha);
916
- var yp = curHole.y - mDistance * Math.sin(alpha);
916
+ var xp = x0 + (lineLength * curHole.offset - mDistance) * Math.cos(alpha);
917
+ var yp = y0 + (lineLength * curHole.offset - mDistance) * Math.sin(alpha);
917
918
  var offset = _export.GeometryUtils.pointPositionOnLineSegment(x0, y0, x1, y1, xp, yp);
918
919
  // make temp hole for calc new distArray
919
920
  var newHole = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "4.3.4",
3
+ "version": "4.3.5",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",