kitchen-simulator 4.3.4 → 4.3.6

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.
@@ -1,8 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
4
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
5
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
6
3
  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; }
7
4
  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) { _defineProperty(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; }
8
5
  import * as Three from 'three';
@@ -3014,11 +3011,11 @@ export function createBacksplash(item, layer, planData, scene) {
3014
3011
  var wLines = getSnappedWallLines(item.itemInfo, layer, planData.catalog);
3015
3012
  var curLine = wLines.length > 0 ? wLines[0] : null;
3016
3013
 
3017
- // Get wall items
3014
+ // Get wall items which snapped to the curLine
3018
3015
 
3019
3016
  var i,
3020
3017
  wallItems = [];
3021
- var allWallItems = GeometryUtils.getAllItemSpecified(scene, planData.catalog, WALL_CABINET_LAYOUTPOS);
3018
+ var allWallItems = GeometryUtils.getAllItemSpecified(scene, planData.catalog, WALL_CABINET_LAYOUTPOS, curLine === null || curLine === void 0 ? void 0 : curLine.lineRect);
3022
3019
  for (i = 0; i < allWallItems.others.length; i++) wallItems.push(allWallItems.others[i]);
3023
3020
  if (allWallItems.cur) wallItems.push(allWallItems.cur);
3024
3021
 
@@ -3095,37 +3092,37 @@ export function createBacksplash(item, layer, planData, scene) {
3095
3092
 
3096
3093
  // Find mergeable other backsplashes
3097
3094
 
3098
- var info, wholeWidth, /** Width factor */factor, distance, halfWidth, /** To get new center */centerFactor;
3099
- var _iterator = _createForOfIteratorHelper(backsplashes),
3100
- _step;
3101
- try {
3102
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
3103
- var back = _step.value;
3104
- info = back.info;
3105
- if (info.height === splashHeight && info.rotY === rotY) {
3106
- factor = Math.cos(rotY) || 1;
3107
- distance = Math.hypot(posX - info.posX, posZ - info.posZ) / factor;
3108
- halfWidth = (info.width + splashWidth) / 2;
3109
- if (Math.abs(distance - halfWidth) < 1e-2) {
3110
- // dispose `back`
3111
- if (info.id) {
3112
- deleteSpecifiedMeshObjects('backsplash' + info.id);
3113
- }
3095
+ // let info,
3096
+ // wholeWidth,
3097
+ // /** Width factor */ factor,
3098
+ // distance,
3099
+ // halfWidth,
3100
+ // /** To get new center */ centerFactor;
3101
+
3102
+ // for (let back of backsplashes) {
3103
+ // info = back.info;
3104
+ // if (info.height === splashHeight && info.rotY === rotY) {
3105
+ // factor = Math.cos(rotY) || 1;
3106
+ // distance = Math.hypot(posX - info.posX, posZ - info.posZ) / factor;
3107
+ // halfWidth = (info.width + splashWidth) / 2;
3108
+
3109
+ // if (Math.abs(distance - halfWidth) < 1e-2) {
3110
+ // // dispose `back`
3111
+ // if (info.id) {
3112
+ // deleteSpecifiedMeshObjects('backsplash' + info.id);
3113
+ // }
3114
+
3115
+ // // Get center position
3116
+ // wholeWidth = info.width + splashWidth;
3117
+ // centerFactor = info.width / wholeWidth;
3118
+ // posX = posX + centerFactor * (info.posX - posX);
3119
+ // posZ = posZ + centerFactor * (info.posZ - posZ);
3120
+
3121
+ // splashWidth = wholeWidth;
3122
+ // }
3123
+ // }
3124
+ // }
3114
3125
 
3115
- // Get center position
3116
- wholeWidth = info.width + splashWidth;
3117
- centerFactor = info.width / wholeWidth;
3118
- posX = posX + centerFactor * (info.posX - posX);
3119
- posZ = posZ + centerFactor * (info.posZ - posZ);
3120
- splashWidth = wholeWidth;
3121
- }
3122
- }
3123
- }
3124
- } catch (err) {
3125
- _iterator.e(err);
3126
- } finally {
3127
- _iterator.f();
3128
- }
3129
3126
  itemToSave.info.posX = posX;
3130
3127
  itemToSave.info.posY = posY;
3131
3128
  itemToSave.info.posZ = posZ;
@@ -3174,9 +3171,9 @@ export function createBacksplash(item, layer, planData, scene) {
3174
3171
  }
3175
3172
  itemToSave.info.id = item.itemInfo.id;
3176
3173
  deleteSpecifiedMeshObjects('backsplash' + item.itemInfo.id);
3177
- if (item.rotRad % (Math.PI / 2) === 0) planData.plan.add(backsplash);
3174
+ if (Math.abs(item.rotRad % (Math.PI / 2)) < EPSILON) planData.plan.add(backsplash);
3178
3175
  backsplash.name = name;
3179
- backsplash.visible = item.itemInfo.get('backsplashVisible') && backsplashApplied && item.rotRad % (Math.PI / 2) === 0;
3176
+ backsplash.visible = item.itemInfo.get('backsplashVisible') && backsplashApplied && Math.abs(item.rotRad % (Math.PI / 2)) < EPSILON;
3180
3177
 
3181
3178
  // Save to scene graph
3182
3179
 
@@ -719,6 +719,7 @@ export function getAllItems(scene, catalog, allLineRects) {
719
719
  }
720
720
  export function getAllItemSpecified(scene, catalog, filter) {
721
721
  var _scene$layers, _scene$layers$get;
722
+ var snappedLineRect = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
722
723
  var layerID = scene === null || scene === void 0 ? void 0 : scene.selectedLayer;
723
724
  var layer = scene === null || scene === void 0 || (_scene$layers = scene.layers) === null || _scene$layers === void 0 || (_scene$layers$get = _scene$layers.get) === null || _scene$layers$get === void 0 ? void 0 : _scene$layers$get.call(_scene$layers, layerID);
724
725
  if (!layer || !layer.items) return {
@@ -765,6 +766,39 @@ export function getAllItemSpecified(scene, catalog, filter) {
765
766
 
766
767
  // Current vs others
767
768
  var rect = getCalcRectFromItem3D(val);
769
+
770
+ // check current item is snapped to the [snappedLineRect]
771
+ if (!isEmpty(snappedLineRect)) {
772
+ var isSnapped = false;
773
+ var overlapList = [OVERLAP_INCLUDED, OVERLAP_SAME, OVERLAP_SOME];
774
+ for (var i = 0; i < (rect === null || rect === void 0 || (_rect$rect = rect.rect) === null || _rect$rect === void 0 ? void 0 : _rect$rect.length); i++) {
775
+ var _rect$rect;
776
+ if (isSnapped) break;
777
+ var curItemPt = rect.rect[i];
778
+ var nextItemPt = i === rect.rect.length - 1 ? rect.rect[0] : rect.rect[i + 1];
779
+ var srcLine = {
780
+ x1: curItemPt.x,
781
+ y1: curItemPt.y,
782
+ x2: nextItemPt.x,
783
+ y2: nextItemPt.y
784
+ };
785
+ for (var j = 0; j < (snappedLineRect === null || snappedLineRect === void 0 ? void 0 : snappedLineRect.length); j++) {
786
+ var curLineRectPt = snappedLineRect[j];
787
+ var nextLineRectPt = j === snappedLineRect.length - 1 ? snappedLineRect[0] : snappedLineRect[j + 1];
788
+ var destLine = {
789
+ x1: curLineRectPt.x,
790
+ y1: curLineRectPt.y,
791
+ x2: nextLineRectPt.x,
792
+ y2: nextLineRectPt.y
793
+ };
794
+ if (overlapList.includes(relationshipOfTwoOverlappedLines(srcLine, destLine).result)) {
795
+ isSnapped = true;
796
+ break;
797
+ }
798
+ }
799
+ }
800
+ if (!isSnapped) return;
801
+ }
768
802
  if (item.selected) {
769
803
  curiteminfo = rect;
770
804
  } else {
@@ -2621,18 +2655,23 @@ export function calcDistancesFromHoleToNearestOneOrWall(curHole, layer) {
2621
2655
  var line = (_layer$lines = layer.lines) === null || _layer$lines === void 0 ? void 0 : _layer$lines.get(curHole.line);
2622
2656
  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
2657
  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));
2658
+ var lineLength = pointsDistance(v0.x, v0.y, v1.x, v1.y);
2624
2659
  if (isEmpty(line) || isEmpty(v0) || isEmpty(v1)) return distArray;
2625
2660
  var angle = angleBetweenTwoPoints(v0.x, v0.y, v1.x, v1.y);
2626
2661
 
2627
2662
  // start point and end point of current hole
2628
2663
  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;
2664
+ var chPt = {
2665
+ x: v0.x + lineLength * curHole.offset * Math.cos(angle),
2666
+ y: v0.y + lineLength * curHole.offset * Math.sin(angle)
2667
+ };
2629
2668
  var chsp = {
2630
- x: curHole.x - chw / 2 * Math.cos(angle),
2631
- y: curHole.y - chw / 2 * Math.sin(angle)
2669
+ x: chPt.x - chw / 2 * Math.cos(angle),
2670
+ y: chPt.y - chw / 2 * Math.sin(angle)
2632
2671
  };
2633
2672
  var chep = {
2634
- x: curHole.x + chw / 2 * Math.cos(angle),
2635
- y: curHole.y + chw / 2 * Math.sin(angle)
2673
+ x: chPt.x + chw / 2 * Math.cos(angle),
2674
+ y: chPt.y + chw / 2 * Math.sin(angle)
2636
2675
  };
2637
2676
  distArray.distLeft = pointsDistance(v0.x, v0.y, chsp.x, chsp.y);
2638
2677
  distArray.distRight = pointsDistance(v1.x, v1.y, chep.x, chep.y);
@@ -2642,13 +2681,17 @@ export function calcDistancesFromHoleToNearestOneOrWall(curHole, layer) {
2642
2681
  var hole = (_layer$holes = layer.holes) === null || _layer$holes === void 0 ? void 0 : _layer$holes.get(hId);
2643
2682
  // start point and end point of other hole
2644
2683
  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;
2684
+ var hPt = {
2685
+ x: v0.x + lineLength * hole.offset * Math.cos(angle),
2686
+ y: v0.y + lineLength * hole.offset * Math.sin(angle)
2687
+ };
2645
2688
  var hsp = {
2646
- x: hole.x - hw / 2 * Math.cos(angle),
2647
- y: hole.y - hw / 2 * Math.sin(angle)
2689
+ x: hPt.x - hw / 2 * Math.cos(angle),
2690
+ y: hPt.y - hw / 2 * Math.sin(angle)
2648
2691
  };
2649
2692
  var hep = {
2650
- x: hole.x + hw / 2 * Math.cos(angle),
2651
- y: hole.y + hw / 2 * Math.sin(angle)
2693
+ x: hPt.x + hw / 2 * Math.cos(angle),
2694
+ y: hPt.y + hw / 2 * Math.sin(angle)
2652
2695
  };
2653
2696
  var relation = relationshipOfTwoOverlappedLines({
2654
2697
  x1: chsp.x,
@@ -2734,15 +2777,15 @@ export function getSnappedWallLines(item, layer, catalog) {
2734
2777
  var _loop2 = function _loop2(j) {
2735
2778
  var destLine1 = {
2736
2779
  x1: rectLines[j].rect[2].x,
2737
- y1: rectLines[j].rect[3].y,
2738
- x2: v1.x,
2739
- y2: v1.y
2780
+ y1: rectLines[j].rect[2].y,
2781
+ x2: rectLines[j].rect[3].x,
2782
+ y2: rectLines[j].rect[3].y
2740
2783
  };
2741
2784
  var destLine2 = {
2742
2785
  x1: rectLines[j].rect[0].x,
2743
- y1: rectLines[j].rect[1].y,
2744
- x2: v1.x,
2745
- y2: v1.y
2786
+ y1: rectLines[j].rect[0].y,
2787
+ x2: rectLines[j].rect[1].x,
2788
+ y2: rectLines[j].rect[1].y
2746
2789
  };
2747
2790
  if (overlapList.includes(relationshipOfTwoOverlappedLines(srcLine, destLine1).result) || overlapList.includes(relationshipOfTwoOverlappedLines(srcLine, destLine2).result)) {
2748
2791
  var idx = snappedWallLines.findIndex(function (v) {
@@ -2751,6 +2794,7 @@ export function getSnappedWallLines(item, layer, catalog) {
2751
2794
  var snapSide = 'unknown';
2752
2795
  if (idx < 0) snappedWallLines.push({
2753
2796
  id: rectLines[j].lineId,
2797
+ lineRect: rectLines[j].rect,
2754
2798
  snapSide: snapSide
2755
2799
  });else snappedWallLines[idx].snapSide = snapSide;
2756
2800
  }
@@ -2790,6 +2834,7 @@ export function getSnappedWallLines(item, layer, catalog) {
2790
2834
  var snapSide = _i === 0 || _i === 2 ? 'front' : 'side';
2791
2835
  if (idx < 0) snappedWallLines.push({
2792
2836
  id: rectLines[_j].lineId,
2837
+ lineRect: rectLines[_j].rect,
2793
2838
  snapSide: snapSide
2794
2839
  });else snappedWallLines[idx].snapSide = snapSide;
2795
2840
  }
@@ -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 = {
@@ -48,9 +48,6 @@ var _utils = require("../viewer2d/utils");
48
48
  var _helper = require("../../utils/helper");
49
49
  var _math = require("../../utils/math");
50
50
  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); }
51
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
52
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
53
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
54
51
  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; }
55
52
  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; }
56
53
  var transformBox;
@@ -3049,11 +3046,11 @@ function createBacksplash(item, layer, planData, scene) {
3049
3046
  var wLines = (0, _geometry2.getSnappedWallLines)(item.itemInfo, layer, planData.catalog);
3050
3047
  var curLine = wLines.length > 0 ? wLines[0] : null;
3051
3048
 
3052
- // Get wall items
3049
+ // Get wall items which snapped to the curLine
3053
3050
 
3054
3051
  var i,
3055
3052
  wallItems = [];
3056
- var allWallItems = _export.GeometryUtils.getAllItemSpecified(scene, planData.catalog, _constants.WALL_CABINET_LAYOUTPOS);
3053
+ var allWallItems = _export.GeometryUtils.getAllItemSpecified(scene, planData.catalog, _constants.WALL_CABINET_LAYOUTPOS, curLine === null || curLine === void 0 ? void 0 : curLine.lineRect);
3057
3054
  for (i = 0; i < allWallItems.others.length; i++) wallItems.push(allWallItems.others[i]);
3058
3055
  if (allWallItems.cur) wallItems.push(allWallItems.cur);
3059
3056
 
@@ -3130,37 +3127,37 @@ function createBacksplash(item, layer, planData, scene) {
3130
3127
 
3131
3128
  // Find mergeable other backsplashes
3132
3129
 
3133
- var info, wholeWidth, /** Width factor */factor, distance, halfWidth, /** To get new center */centerFactor;
3134
- var _iterator = _createForOfIteratorHelper(backsplashes),
3135
- _step;
3136
- try {
3137
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
3138
- var back = _step.value;
3139
- info = back.info;
3140
- if (info.height === splashHeight && info.rotY === rotY) {
3141
- factor = Math.cos(rotY) || 1;
3142
- distance = Math.hypot(posX - info.posX, posZ - info.posZ) / factor;
3143
- halfWidth = (info.width + splashWidth) / 2;
3144
- if (Math.abs(distance - halfWidth) < 1e-2) {
3145
- // dispose `back`
3146
- if (info.id) {
3147
- deleteSpecifiedMeshObjects('backsplash' + info.id);
3148
- }
3130
+ // let info,
3131
+ // wholeWidth,
3132
+ // /** Width factor */ factor,
3133
+ // distance,
3134
+ // halfWidth,
3135
+ // /** To get new center */ centerFactor;
3136
+
3137
+ // for (let back of backsplashes) {
3138
+ // info = back.info;
3139
+ // if (info.height === splashHeight && info.rotY === rotY) {
3140
+ // factor = Math.cos(rotY) || 1;
3141
+ // distance = Math.hypot(posX - info.posX, posZ - info.posZ) / factor;
3142
+ // halfWidth = (info.width + splashWidth) / 2;
3143
+
3144
+ // if (Math.abs(distance - halfWidth) < 1e-2) {
3145
+ // // dispose `back`
3146
+ // if (info.id) {
3147
+ // deleteSpecifiedMeshObjects('backsplash' + info.id);
3148
+ // }
3149
+
3150
+ // // Get center position
3151
+ // wholeWidth = info.width + splashWidth;
3152
+ // centerFactor = info.width / wholeWidth;
3153
+ // posX = posX + centerFactor * (info.posX - posX);
3154
+ // posZ = posZ + centerFactor * (info.posZ - posZ);
3155
+
3156
+ // splashWidth = wholeWidth;
3157
+ // }
3158
+ // }
3159
+ // }
3149
3160
 
3150
- // Get center position
3151
- wholeWidth = info.width + splashWidth;
3152
- centerFactor = info.width / wholeWidth;
3153
- posX = posX + centerFactor * (info.posX - posX);
3154
- posZ = posZ + centerFactor * (info.posZ - posZ);
3155
- splashWidth = wholeWidth;
3156
- }
3157
- }
3158
- }
3159
- } catch (err) {
3160
- _iterator.e(err);
3161
- } finally {
3162
- _iterator.f();
3163
- }
3164
3161
  itemToSave.info.posX = posX;
3165
3162
  itemToSave.info.posY = posY;
3166
3163
  itemToSave.info.posZ = posZ;
@@ -3209,9 +3206,9 @@ function createBacksplash(item, layer, planData, scene) {
3209
3206
  }
3210
3207
  itemToSave.info.id = item.itemInfo.id;
3211
3208
  deleteSpecifiedMeshObjects('backsplash' + item.itemInfo.id);
3212
- if (item.rotRad % (Math.PI / 2) === 0) planData.plan.add(backsplash);
3209
+ if (Math.abs(item.rotRad % (Math.PI / 2)) < _constants.EPSILON) planData.plan.add(backsplash);
3213
3210
  backsplash.name = name;
3214
- backsplash.visible = item.itemInfo.get('backsplashVisible') && backsplashApplied && item.rotRad % (Math.PI / 2) === 0;
3211
+ backsplash.visible = item.itemInfo.get('backsplashVisible') && backsplashApplied && Math.abs(item.rotRad % (Math.PI / 2)) < _constants.EPSILON;
3215
3212
 
3216
3213
  // Save to scene graph
3217
3214
 
@@ -821,6 +821,7 @@ function getAllItems(scene, catalog, allLineRects) {
821
821
  }
822
822
  function getAllItemSpecified(scene, catalog, filter) {
823
823
  var _scene$layers, _scene$layers$get;
824
+ var snappedLineRect = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
824
825
  var layerID = scene === null || scene === void 0 ? void 0 : scene.selectedLayer;
825
826
  var layer = scene === null || scene === void 0 || (_scene$layers = scene.layers) === null || _scene$layers === void 0 || (_scene$layers$get = _scene$layers.get) === null || _scene$layers$get === void 0 ? void 0 : _scene$layers$get.call(_scene$layers, layerID);
826
827
  if (!layer || !layer.items) return {
@@ -867,6 +868,39 @@ function getAllItemSpecified(scene, catalog, filter) {
867
868
 
868
869
  // Current vs others
869
870
  var rect = getCalcRectFromItem3D(val);
871
+
872
+ // check current item is snapped to the [snappedLineRect]
873
+ if (!(0, _helper.isEmpty)(snappedLineRect)) {
874
+ var isSnapped = false;
875
+ var overlapList = [_constants.OVERLAP_INCLUDED, _constants.OVERLAP_SAME, _constants.OVERLAP_SOME];
876
+ for (var i = 0; i < (rect === null || rect === void 0 || (_rect$rect = rect.rect) === null || _rect$rect === void 0 ? void 0 : _rect$rect.length); i++) {
877
+ var _rect$rect;
878
+ if (isSnapped) break;
879
+ var curItemPt = rect.rect[i];
880
+ var nextItemPt = i === rect.rect.length - 1 ? rect.rect[0] : rect.rect[i + 1];
881
+ var srcLine = {
882
+ x1: curItemPt.x,
883
+ y1: curItemPt.y,
884
+ x2: nextItemPt.x,
885
+ y2: nextItemPt.y
886
+ };
887
+ for (var j = 0; j < (snappedLineRect === null || snappedLineRect === void 0 ? void 0 : snappedLineRect.length); j++) {
888
+ var curLineRectPt = snappedLineRect[j];
889
+ var nextLineRectPt = j === snappedLineRect.length - 1 ? snappedLineRect[0] : snappedLineRect[j + 1];
890
+ var destLine = {
891
+ x1: curLineRectPt.x,
892
+ y1: curLineRectPt.y,
893
+ x2: nextLineRectPt.x,
894
+ y2: nextLineRectPt.y
895
+ };
896
+ if (overlapList.includes(relationshipOfTwoOverlappedLines(srcLine, destLine).result)) {
897
+ isSnapped = true;
898
+ break;
899
+ }
900
+ }
901
+ }
902
+ if (!isSnapped) return;
903
+ }
870
904
  if (item.selected) {
871
905
  curiteminfo = rect;
872
906
  } else {
@@ -2723,18 +2757,23 @@ function calcDistancesFromHoleToNearestOneOrWall(curHole, layer) {
2723
2757
  var line = (_layer$lines = layer.lines) === null || _layer$lines === void 0 ? void 0 : _layer$lines.get(curHole.line);
2724
2758
  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
2759
  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));
2760
+ var lineLength = pointsDistance(v0.x, v0.y, v1.x, v1.y);
2726
2761
  if ((0, _helper.isEmpty)(line) || (0, _helper.isEmpty)(v0) || (0, _helper.isEmpty)(v1)) return distArray;
2727
2762
  var angle = angleBetweenTwoPoints(v0.x, v0.y, v1.x, v1.y);
2728
2763
 
2729
2764
  // start point and end point of current hole
2730
2765
  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;
2766
+ var chPt = {
2767
+ x: v0.x + lineLength * curHole.offset * Math.cos(angle),
2768
+ y: v0.y + lineLength * curHole.offset * Math.sin(angle)
2769
+ };
2731
2770
  var chsp = {
2732
- x: curHole.x - chw / 2 * Math.cos(angle),
2733
- y: curHole.y - chw / 2 * Math.sin(angle)
2771
+ x: chPt.x - chw / 2 * Math.cos(angle),
2772
+ y: chPt.y - chw / 2 * Math.sin(angle)
2734
2773
  };
2735
2774
  var chep = {
2736
- x: curHole.x + chw / 2 * Math.cos(angle),
2737
- y: curHole.y + chw / 2 * Math.sin(angle)
2775
+ x: chPt.x + chw / 2 * Math.cos(angle),
2776
+ y: chPt.y + chw / 2 * Math.sin(angle)
2738
2777
  };
2739
2778
  distArray.distLeft = pointsDistance(v0.x, v0.y, chsp.x, chsp.y);
2740
2779
  distArray.distRight = pointsDistance(v1.x, v1.y, chep.x, chep.y);
@@ -2744,13 +2783,17 @@ function calcDistancesFromHoleToNearestOneOrWall(curHole, layer) {
2744
2783
  var hole = (_layer$holes = layer.holes) === null || _layer$holes === void 0 ? void 0 : _layer$holes.get(hId);
2745
2784
  // start point and end point of other hole
2746
2785
  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;
2786
+ var hPt = {
2787
+ x: v0.x + lineLength * hole.offset * Math.cos(angle),
2788
+ y: v0.y + lineLength * hole.offset * Math.sin(angle)
2789
+ };
2747
2790
  var hsp = {
2748
- x: hole.x - hw / 2 * Math.cos(angle),
2749
- y: hole.y - hw / 2 * Math.sin(angle)
2791
+ x: hPt.x - hw / 2 * Math.cos(angle),
2792
+ y: hPt.y - hw / 2 * Math.sin(angle)
2750
2793
  };
2751
2794
  var hep = {
2752
- x: hole.x + hw / 2 * Math.cos(angle),
2753
- y: hole.y + hw / 2 * Math.sin(angle)
2795
+ x: hPt.x + hw / 2 * Math.cos(angle),
2796
+ y: hPt.y + hw / 2 * Math.sin(angle)
2754
2797
  };
2755
2798
  var relation = relationshipOfTwoOverlappedLines({
2756
2799
  x1: chsp.x,
@@ -2836,15 +2879,15 @@ function getSnappedWallLines(item, layer, catalog) {
2836
2879
  var _loop2 = function _loop2(j) {
2837
2880
  var destLine1 = {
2838
2881
  x1: rectLines[j].rect[2].x,
2839
- y1: rectLines[j].rect[3].y,
2840
- x2: v1.x,
2841
- y2: v1.y
2882
+ y1: rectLines[j].rect[2].y,
2883
+ x2: rectLines[j].rect[3].x,
2884
+ y2: rectLines[j].rect[3].y
2842
2885
  };
2843
2886
  var destLine2 = {
2844
2887
  x1: rectLines[j].rect[0].x,
2845
- y1: rectLines[j].rect[1].y,
2846
- x2: v1.x,
2847
- y2: v1.y
2888
+ y1: rectLines[j].rect[0].y,
2889
+ x2: rectLines[j].rect[1].x,
2890
+ y2: rectLines[j].rect[1].y
2848
2891
  };
2849
2892
  if (overlapList.includes(relationshipOfTwoOverlappedLines(srcLine, destLine1).result) || overlapList.includes(relationshipOfTwoOverlappedLines(srcLine, destLine2).result)) {
2850
2893
  var idx = snappedWallLines.findIndex(function (v) {
@@ -2853,6 +2896,7 @@ function getSnappedWallLines(item, layer, catalog) {
2853
2896
  var snapSide = 'unknown';
2854
2897
  if (idx < 0) snappedWallLines.push({
2855
2898
  id: rectLines[j].lineId,
2899
+ lineRect: rectLines[j].rect,
2856
2900
  snapSide: snapSide
2857
2901
  });else snappedWallLines[idx].snapSide = snapSide;
2858
2902
  }
@@ -2892,6 +2936,7 @@ function getSnappedWallLines(item, layer, catalog) {
2892
2936
  var snapSide = _i === 0 || _i === 2 ? 'front' : 'side';
2893
2937
  if (idx < 0) snappedWallLines.push({
2894
2938
  id: rectLines[_j].lineId,
2939
+ lineRect: rectLines[_j].rect,
2895
2940
  snapSide: snapSide
2896
2941
  });else snappedWallLines[idx].snapSide = snapSide;
2897
2942
  }
@@ -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.6",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",