kitchen-simulator 11.30.2 → 11.30.3
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/components/viewer2d/viewer2d.js +7 -22
- package/es/components/viewer3d/scene-creator.js +6 -5
- package/es/constants/applianceCategories.js +19 -0
- package/es/engine/2d/viewer-utils.js +20 -0
- package/es/utils/geometry.js +13 -12
- package/lib/components/viewer2d/viewer2d.js +7 -22
- package/lib/components/viewer3d/scene-creator.js +6 -5
- package/lib/constants/applianceCategories.js +25 -0
- package/lib/engine/2d/viewer-utils.js +25 -0
- package/lib/utils/geometry.js +13 -12
- package/package.json +1 -1
|
@@ -17,6 +17,7 @@ import { Map } from 'immutable';
|
|
|
17
17
|
import { formatNumber } from "../../utils/math";
|
|
18
18
|
import { isEmpty, updatePayloadOfInternalEvent } from "../../utils/helper"; // variables
|
|
19
19
|
import { isWarningCabinet } from "../../shared/domain/cabinet-warning";
|
|
20
|
+
import { shouldBypassItemIntersectionValidation } from "../../engine/2d/viewer-utils";
|
|
20
21
|
// variables
|
|
21
22
|
var pinFlag = false;
|
|
22
23
|
var sFlag = false; //for all object move
|
|
@@ -569,6 +570,7 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
569
570
|
}
|
|
570
571
|
};
|
|
571
572
|
var onMouseMove = function onMouseMove(viewerEvent) {
|
|
573
|
+
var _allItemRect$cur2;
|
|
572
574
|
//workaround that allow imageful component to work
|
|
573
575
|
|
|
574
576
|
// let evt = new Event('mousemove-planner-event');
|
|
@@ -632,6 +634,7 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
632
634
|
endPoint.x = x;
|
|
633
635
|
endPoint.y = y;
|
|
634
636
|
} else {
|
|
637
|
+
var _allItemRect$cur;
|
|
635
638
|
prepareSnap();
|
|
636
639
|
var _GeometryUtils$calcSn = GeometryUtils.calcSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allArea),
|
|
637
640
|
nx = _GeometryUtils$calcSn.nx,
|
|
@@ -675,19 +678,8 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
675
678
|
y: ny
|
|
676
679
|
};
|
|
677
680
|
var _isrectSect = GeometryUtils.validInterSect(allItemRect.others, _val);
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
|
|
681
|
-
endPoint.x = nx;
|
|
682
|
-
endPoint.y = ny;
|
|
683
|
-
}
|
|
684
|
-
if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('cabinet')) {
|
|
685
|
-
itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
|
|
686
|
-
itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
|
|
687
|
-
endPoint.x = nx;
|
|
688
|
-
endPoint.y = ny;
|
|
689
|
-
}
|
|
690
|
-
if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Hood') || allItemRect.cur.itemInfo.cabinet_category.toLowerCase().includes('hood') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Range') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top')) {
|
|
681
|
+
var _isCabinet = (_allItemRect$cur = allItemRect.cur) === null || _allItemRect$cur === void 0 ? void 0 : _allItemRect$cur.itemInfo.name.includes('cabinet');
|
|
682
|
+
if (_isrectSect && _isSect || _isCabinet || shouldBypassItemIntersectionValidation(allItemRect.cur)) {
|
|
691
683
|
itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
|
|
692
684
|
itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
|
|
693
685
|
endPoint.x = nx;
|
|
@@ -751,15 +743,8 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
751
743
|
y: ny
|
|
752
744
|
};
|
|
753
745
|
var isrectSect = GeometryUtils.validInterSect(allItemRect.others, val);
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
|
|
757
|
-
}
|
|
758
|
-
if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cabinet')) {
|
|
759
|
-
itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
|
|
760
|
-
itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
|
|
761
|
-
}
|
|
762
|
-
if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Hood') || allItemRect.cur.itemInfo.cabinet_category.toLowerCase().includes('hood') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Range') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top')) {
|
|
746
|
+
var isCabinet = (_allItemRect$cur2 = allItemRect.cur) === null || _allItemRect$cur2 === void 0 ? void 0 : _allItemRect$cur2.itemInfo.name.includes('Cabinet');
|
|
747
|
+
if (isrectSect && isSect || isCabinet || shouldBypassItemIntersectionValidation(allItemRect.cur)) {
|
|
763
748
|
itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
|
|
764
749
|
itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
|
|
765
750
|
}
|
|
@@ -18,6 +18,7 @@ import { animateDoor, isElevationView, isEmpty, isImmutable, replaceMeshesWithLi
|
|
|
18
18
|
import { formatNumber } from "../../utils/math";
|
|
19
19
|
import { toJSIfNeeded } from "../../shared/objects/immutable";
|
|
20
20
|
import { isCornerCabinet } from "../../shared/domain/cabinet-corner";
|
|
21
|
+
import { APPLIANCE_CATEGORY_DISHWASHER } from "../../constants/applianceCategories";
|
|
21
22
|
export var fVLine = [];
|
|
22
23
|
var scene_mode = null;
|
|
23
24
|
export function parseData(sceneData, actions, catalog, camera, renderer, mode) {
|
|
@@ -2474,13 +2475,13 @@ export function createMDFromItem(item, lines, molding) {
|
|
|
2474
2475
|
};
|
|
2475
2476
|
}
|
|
2476
2477
|
function tryAdjacent(ct1, ct2) {
|
|
2477
|
-
if (ct1.catid.includes(
|
|
2478
|
+
if (ct1.catid.includes(APPLIANCE_CATEGORY_DISHWASHER) && ct1.catid.includes('BF')) {
|
|
2478
2479
|
var temp = ct1;
|
|
2479
2480
|
ct1 = ct2;
|
|
2480
2481
|
ct2 = temp;
|
|
2481
2482
|
}
|
|
2482
2483
|
log('----tryAdjacent', ct1.id, ct2.id);
|
|
2483
|
-
if (!ct2.catid.includes(
|
|
2484
|
+
if (!ct2.catid.includes(APPLIANCE_CATEGORY_DISHWASHER) && !ct2.catid.includes('BF') && ct1.catid != ct2.catid) return false;
|
|
2484
2485
|
if (ct1.items[0].layoutpos === 'Vanity' || ct2.items[0].layoutpos === 'Vanity') return false;
|
|
2485
2486
|
if (ct1.rotRad != ct2.rotRad) return false;
|
|
2486
2487
|
log('ct1', ct1.pos.x, ct1.pos.y, ct1.size.width);
|
|
@@ -2625,7 +2626,7 @@ function showItemCT(item, CT, visible, planData, layer) {
|
|
|
2625
2626
|
});
|
|
2626
2627
|
}
|
|
2627
2628
|
function getCountertopMesh(item, visible, planData, layer) {
|
|
2628
|
-
if (item.type.includes(
|
|
2629
|
+
if (item.type.includes(APPLIANCE_CATEGORY_DISHWASHER)) return undefined;
|
|
2629
2630
|
if (item.type.includes('BF')) return undefined;
|
|
2630
2631
|
var item3D = planData.sceneGraph.layers[layer.id].items[item.id];
|
|
2631
2632
|
var countertop = null;
|
|
@@ -2695,10 +2696,10 @@ function addCTMesh(countertop, planData, layer) {
|
|
|
2695
2696
|
var pivotMat = ctMesh.parent.parent.matrix;
|
|
2696
2697
|
pivotMat.setPosition(new Three.Vector3(countertop.pos.x, 0, -countertop.pos.y));
|
|
2697
2698
|
var width = countertop.items.find(function (ct) {
|
|
2698
|
-
return !ct.type.includes(
|
|
2699
|
+
return !ct.type.includes(APPLIANCE_CATEGORY_DISHWASHER) && !ct.type.includes('BF');
|
|
2699
2700
|
}).properties.get('width').get('_length');
|
|
2700
2701
|
var unit_width = countertop.items.find(function (ct) {
|
|
2701
|
-
return !ct.type.includes(
|
|
2702
|
+
return !ct.type.includes(APPLIANCE_CATEGORY_DISHWASHER) && !ct.type.includes('BF');
|
|
2702
2703
|
}).properties.get('width').get('_unit') || 'cm';
|
|
2703
2704
|
width = convert(width).from(unit_width).to('cm');
|
|
2704
2705
|
pivotMat.scale(new Three.Vector3(countertop.size.width / width, 1, 1));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Appliance category/name constants
|
|
2
|
+
//
|
|
3
|
+
// NOTE: Keep these in a small dedicated module instead of adding more
|
|
4
|
+
// hardcoded strings into src/constants.js (which is already very large).
|
|
5
|
+
|
|
6
|
+
// wall-like appliances
|
|
7
|
+
export var APPLIANCE_CATEGORY_COOK_TOP = 'Cook Top';
|
|
8
|
+
export var APPLIANCE_CATEGORY_MICROWAVE = 'Microwave';
|
|
9
|
+
export var APPLIANCE_CATEGORY_HOOD = 'Hood';
|
|
10
|
+
|
|
11
|
+
// base-like appliances
|
|
12
|
+
export var APPLIANCE_CATEGORY_DISHWASHER = 'Dishwasher';
|
|
13
|
+
export var APPLIANCE_CATEGORY_REFRIGERATOR = 'Refrigerator';
|
|
14
|
+
export var APPLIANCE_CATEGORY_RANGE = 'Range';
|
|
15
|
+
|
|
16
|
+
// Categories that we exclude from some snapping/overlap logic.
|
|
17
|
+
// (exported as an array so call-sites can create their own Set and avoid
|
|
18
|
+
// accidental shared mutation)
|
|
19
|
+
export var EXCLUDED_APPLIANCE_CATEGORIES = Object.freeze([APPLIANCE_CATEGORY_COOK_TOP, APPLIANCE_CATEGORY_MICROWAVE, APPLIANCE_CATEGORY_HOOD]);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { APPLIANCE_CATEGORY_COOK_TOP, APPLIANCE_CATEGORY_HOOD, APPLIANCE_CATEGORY_RANGE } from "../../constants/applianceCategories";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns `true` for items that are intentionally allowed to overlap other
|
|
5
|
+
* elements while being placed/dragged in the 2D viewer.
|
|
6
|
+
*
|
|
7
|
+
* Why this exists:
|
|
8
|
+
* - `GeometryUtils.validInterSect(...)` is used as a collision/intersection gate.
|
|
9
|
+
* - Some appliances (e.g. cooktops/ranges/hoods) are expected to be placed "on"
|
|
10
|
+
* or "inside" cabinetry/countertops, so they must not be blocked by that gate.
|
|
11
|
+
*
|
|
12
|
+
* NOTE: This currently identifies items by the appliance category strings found
|
|
13
|
+
* in `itemInfo.name` / `itemInfo.cabinet_category`.
|
|
14
|
+
*/
|
|
15
|
+
export var shouldBypassItemIntersectionValidation = function shouldBypassItemIntersectionValidation(itemRect) {
|
|
16
|
+
var itemInfo = itemRect === null || itemRect === void 0 ? void 0 : itemRect.itemInfo;
|
|
17
|
+
var name = typeof (itemInfo === null || itemInfo === void 0 ? void 0 : itemInfo.name) === 'string' ? itemInfo.name : '';
|
|
18
|
+
var cabinetCategory = typeof (itemInfo === null || itemInfo === void 0 ? void 0 : itemInfo.cabinet_category) === 'string' ? itemInfo.cabinet_category : '';
|
|
19
|
+
return name.includes(APPLIANCE_CATEGORY_HOOD) || cabinetCategory.toLowerCase().includes(APPLIANCE_CATEGORY_HOOD.toLowerCase()) || name.includes(APPLIANCE_CATEGORY_RANGE) || name.includes(APPLIANCE_CATEGORY_COOK_TOP);
|
|
20
|
+
};
|
package/es/utils/geometry.js
CHANGED
|
@@ -15,6 +15,8 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
15
15
|
*/
|
|
16
16
|
import { fAbs, toFixedFloat } from "./math.js";
|
|
17
17
|
import { BASE_CABINET_LAYOUTPOS, EPSILON, LINE_THICKNESS, MEPSILON, OVERLAP_INCLUDED, OVERLAP_LINK, OVERLAP_NONE, OVERLAP_SAME, OVERLAP_SOME, UNIT_ANGLE, WALL_CABINET_LAYOUTPOS } from "../constants";
|
|
18
|
+
import { APPLIANCE_CATEGORY_COOK_TOP, APPLIANCE_CATEGORY_HOOD, EXCLUDED_APPLIANCE_CATEGORIES } from "../constants/applianceCategories";
|
|
19
|
+
import { shouldBypassItemIntersectionValidation } from "../engine/2d/viewer-utils.js";
|
|
18
20
|
import { convert } from "./convert-units-lite";
|
|
19
21
|
import * as Three from 'three';
|
|
20
22
|
import { returnReplaceableDeepSearchType } from "../components/viewer2d/utils.js";
|
|
@@ -729,8 +731,9 @@ export function getAllItemSpecified(scene, catalog, filter) {
|
|
|
729
731
|
};
|
|
730
732
|
var curiteminfo;
|
|
731
733
|
var iteminfo = [];
|
|
734
|
+
var excludedApplianceCategories = new Set(EXCLUDED_APPLIANCE_CATEGORIES);
|
|
732
735
|
layer.items.forEach(function (item) {
|
|
733
|
-
var _cat$obj;
|
|
736
|
+
var _cat$obj, _cat$obj2;
|
|
734
737
|
if (!item) return;
|
|
735
738
|
var val = {
|
|
736
739
|
pos: {
|
|
@@ -756,11 +759,9 @@ export function getAllItemSpecified(scene, catalog, filter) {
|
|
|
756
759
|
val.item = item;
|
|
757
760
|
|
|
758
761
|
// Filter check
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
return;
|
|
763
|
-
}
|
|
762
|
+
var isExcludedItem = isEmpty(cat) || (cat === null || cat === void 0 ? void 0 : cat.type) === 'appliance' && excludedApplianceCategories.has(cat === null || cat === void 0 || (_cat$obj = cat.obj) === null || _cat$obj === void 0 ? void 0 : _cat$obj.category) || excludedApplianceCategories.has(cat === null || cat === void 0 || (_cat$obj2 = cat.obj) === null || _cat$obj2 === void 0 ? void 0 : _cat$obj2.cabinet_category);
|
|
763
|
+
var layoutMatches = Array.isArray(filter) ? !!val.layoutpos && filter.includes(val.layoutpos) : val.layoutpos === filter;
|
|
764
|
+
if (!layoutMatches || isExcludedItem) return;
|
|
764
765
|
|
|
765
766
|
// Current vs others
|
|
766
767
|
var rect = getCalcRectFromItem3D(val);
|
|
@@ -1633,7 +1634,7 @@ export function calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, a
|
|
|
1633
1634
|
rotRad = snap.rotRad;
|
|
1634
1635
|
}
|
|
1635
1636
|
});
|
|
1636
|
-
if (allItemRect.cur.itemInfo.name.includes(
|
|
1637
|
+
if (allItemRect.cur.itemInfo.name.includes(APPLIANCE_CATEGORY_COOK_TOP)) {
|
|
1637
1638
|
var intersects = allItemRect.others.filter(function (others) {
|
|
1638
1639
|
return intersectRect(others.rect, curitem.rect);
|
|
1639
1640
|
});
|
|
@@ -1645,12 +1646,12 @@ export function calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, a
|
|
|
1645
1646
|
}
|
|
1646
1647
|
});
|
|
1647
1648
|
}
|
|
1648
|
-
if (
|
|
1649
|
+
if (shouldBypassItemIntersectionValidation(allItemRect.cur)) {
|
|
1649
1650
|
var _intersects = allItemRect.others.filter(function (others) {
|
|
1650
1651
|
return intersectRect(others.rect, curitem.rect);
|
|
1651
1652
|
});
|
|
1652
1653
|
_intersects.forEach(function (rect) {
|
|
1653
|
-
if (isPointInArea(allArea, rect.itemInfo) || !allArea.length)
|
|
1654
|
+
if ((isPointInArea(allArea, rect.itemInfo) || !allArea.length) && shouldBypassItemIntersectionValidation(rect)) {
|
|
1654
1655
|
nx = rect.itemInfo.x;
|
|
1655
1656
|
ny = rect.itemInfo.y;
|
|
1656
1657
|
rotRad = rect.itemInfo.rotation * Math.PI / 180;
|
|
@@ -2039,9 +2040,9 @@ export function needSnap(curItem, othItem) {
|
|
|
2039
2040
|
var isBlsnapOth = othItem.item.category === 'cabinet' && othItem.item.layoutpos === BASE_CABINET_LAYOUTPOS && Math.abs(curFloor - otherFloor) >= delta;
|
|
2040
2041
|
var isBlsnapCur = curItem.selectedItem.category === 'cabinet' && curItem.selectedItem.layoutpos === BASE_CABINET_LAYOUTPOS && Math.abs(curFloor - otherFloor) >= delta;
|
|
2041
2042
|
if (curItem.cat.hasOwnProperty('long_name') || othItem.cat && othItem.cat.hasOwnProperty('long_name')) {
|
|
2042
|
-
if (curItem.cat.long_name.includes(
|
|
2043
|
-
if (curItem.cat.long_name.includes(
|
|
2044
|
-
if (curItem.cat.long_name.includes(
|
|
2043
|
+
if (curItem.cat.long_name.includes(APPLIANCE_CATEGORY_HOOD) || othItem.cat && othItem.cat.long_name.includes(APPLIANCE_CATEGORY_HOOD)) blSnap = true;
|
|
2044
|
+
if (curItem.cat.long_name.includes(APPLIANCE_CATEGORY_HOOD) && othItem.cat && isBlsnapOth || isBlsnapCur && othItem.cat.long_name.includes(APPLIANCE_CATEGORY_HOOD)) blSnap = false;
|
|
2045
|
+
if (curItem.cat.long_name.includes(APPLIANCE_CATEGORY_COOK_TOP) && othItem.cat && othItem.cat.long_name.includes('Cabinet') || curItem.cat.long_name.includes('Cabinet') && othItem.cat && othItem.cat.long_name.includes(APPLIANCE_CATEGORY_COOK_TOP)) blSnap = true;
|
|
2045
2046
|
}
|
|
2046
2047
|
return blSnap;
|
|
2047
2048
|
}
|
|
@@ -23,6 +23,7 @@ var _immutable = require("immutable");
|
|
|
23
23
|
var _math = require("../../utils/math");
|
|
24
24
|
var _helper = require("../../utils/helper");
|
|
25
25
|
var _cabinetWarning = require("../../shared/domain/cabinet-warning");
|
|
26
|
+
var _viewerUtils = require("../../engine/2d/viewer-utils");
|
|
26
27
|
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); }
|
|
27
28
|
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; }
|
|
28
29
|
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; } // variables
|
|
@@ -578,6 +579,7 @@ function Viewer2D(_ref, _ref2) {
|
|
|
578
579
|
}
|
|
579
580
|
};
|
|
580
581
|
var onMouseMove = function onMouseMove(viewerEvent) {
|
|
582
|
+
var _allItemRect$cur2;
|
|
581
583
|
//workaround that allow imageful component to work
|
|
582
584
|
|
|
583
585
|
// let evt = new Event('mousemove-planner-event');
|
|
@@ -641,6 +643,7 @@ function Viewer2D(_ref, _ref2) {
|
|
|
641
643
|
endPoint.x = x;
|
|
642
644
|
endPoint.y = y;
|
|
643
645
|
} else {
|
|
646
|
+
var _allItemRect$cur;
|
|
644
647
|
prepareSnap();
|
|
645
648
|
var _GeometryUtils$calcSn = _export2.GeometryUtils.calcSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allArea),
|
|
646
649
|
nx = _GeometryUtils$calcSn.nx,
|
|
@@ -684,19 +687,8 @@ function Viewer2D(_ref, _ref2) {
|
|
|
684
687
|
y: ny
|
|
685
688
|
};
|
|
686
689
|
var _isrectSect = _export2.GeometryUtils.validInterSect(allItemRect.others, _val);
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
|
|
690
|
-
endPoint.x = nx;
|
|
691
|
-
endPoint.y = ny;
|
|
692
|
-
}
|
|
693
|
-
if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('cabinet')) {
|
|
694
|
-
itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
|
|
695
|
-
itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
|
|
696
|
-
endPoint.x = nx;
|
|
697
|
-
endPoint.y = ny;
|
|
698
|
-
}
|
|
699
|
-
if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Hood') || allItemRect.cur.itemInfo.cabinet_category.toLowerCase().includes('hood') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Range') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top')) {
|
|
690
|
+
var _isCabinet = (_allItemRect$cur = allItemRect.cur) === null || _allItemRect$cur === void 0 ? void 0 : _allItemRect$cur.itemInfo.name.includes('cabinet');
|
|
691
|
+
if (_isrectSect && _isSect || _isCabinet || (0, _viewerUtils.shouldBypassItemIntersectionValidation)(allItemRect.cur)) {
|
|
700
692
|
itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
|
|
701
693
|
itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
|
|
702
694
|
endPoint.x = nx;
|
|
@@ -760,15 +752,8 @@ function Viewer2D(_ref, _ref2) {
|
|
|
760
752
|
y: ny
|
|
761
753
|
};
|
|
762
754
|
var isrectSect = _export2.GeometryUtils.validInterSect(allItemRect.others, val);
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
|
|
766
|
-
}
|
|
767
|
-
if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cabinet')) {
|
|
768
|
-
itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
|
|
769
|
-
itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
|
|
770
|
-
}
|
|
771
|
-
if (allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Hood') || allItemRect.cur.itemInfo.cabinet_category.toLowerCase().includes('hood') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Range') || allItemRect.cur && allItemRect.cur.itemInfo.name.includes('Cook Top')) {
|
|
755
|
+
var isCabinet = (_allItemRect$cur2 = allItemRect.cur) === null || _allItemRect$cur2 === void 0 ? void 0 : _allItemRect$cur2.itemInfo.name.includes('Cabinet');
|
|
756
|
+
if (isrectSect && isSect || isCabinet || (0, _viewerUtils.shouldBypassItemIntersectionValidation)(allItemRect.cur)) {
|
|
772
757
|
itemsActions.updateDraggingItemChanged(nx, ny, layerID, current_sel_obj_id);
|
|
773
758
|
itemsActions.updateRotatingItemChanged(rot, layerID, current_sel_obj_id);
|
|
774
759
|
}
|
|
@@ -49,6 +49,7 @@ var _helper = require("../../utils/helper");
|
|
|
49
49
|
var _math = require("../../utils/math");
|
|
50
50
|
var _immutable = require("../../shared/objects/immutable");
|
|
51
51
|
var _cabinetCorner = require("../../shared/domain/cabinet-corner");
|
|
52
|
+
var _applianceCategories = require("../../constants/applianceCategories");
|
|
52
53
|
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); }
|
|
53
54
|
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; }
|
|
54
55
|
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; }
|
|
@@ -2508,13 +2509,13 @@ function createMDFromItem(item, lines, molding) {
|
|
|
2508
2509
|
};
|
|
2509
2510
|
}
|
|
2510
2511
|
function tryAdjacent(ct1, ct2) {
|
|
2511
|
-
if (ct1.catid.includes(
|
|
2512
|
+
if (ct1.catid.includes(_applianceCategories.APPLIANCE_CATEGORY_DISHWASHER) && ct1.catid.includes('BF')) {
|
|
2512
2513
|
var temp = ct1;
|
|
2513
2514
|
ct1 = ct2;
|
|
2514
2515
|
ct2 = temp;
|
|
2515
2516
|
}
|
|
2516
2517
|
log('----tryAdjacent', ct1.id, ct2.id);
|
|
2517
|
-
if (!ct2.catid.includes(
|
|
2518
|
+
if (!ct2.catid.includes(_applianceCategories.APPLIANCE_CATEGORY_DISHWASHER) && !ct2.catid.includes('BF') && ct1.catid != ct2.catid) return false;
|
|
2518
2519
|
if (ct1.items[0].layoutpos === 'Vanity' || ct2.items[0].layoutpos === 'Vanity') return false;
|
|
2519
2520
|
if (ct1.rotRad != ct2.rotRad) return false;
|
|
2520
2521
|
log('ct1', ct1.pos.x, ct1.pos.y, ct1.size.width);
|
|
@@ -2659,7 +2660,7 @@ function showItemCT(item, CT, visible, planData, layer) {
|
|
|
2659
2660
|
});
|
|
2660
2661
|
}
|
|
2661
2662
|
function getCountertopMesh(item, visible, planData, layer) {
|
|
2662
|
-
if (item.type.includes(
|
|
2663
|
+
if (item.type.includes(_applianceCategories.APPLIANCE_CATEGORY_DISHWASHER)) return undefined;
|
|
2663
2664
|
if (item.type.includes('BF')) return undefined;
|
|
2664
2665
|
var item3D = planData.sceneGraph.layers[layer.id].items[item.id];
|
|
2665
2666
|
var countertop = null;
|
|
@@ -2729,10 +2730,10 @@ function addCTMesh(countertop, planData, layer) {
|
|
|
2729
2730
|
var pivotMat = ctMesh.parent.parent.matrix;
|
|
2730
2731
|
pivotMat.setPosition(new Three.Vector3(countertop.pos.x, 0, -countertop.pos.y));
|
|
2731
2732
|
var width = countertop.items.find(function (ct) {
|
|
2732
|
-
return !ct.type.includes(
|
|
2733
|
+
return !ct.type.includes(_applianceCategories.APPLIANCE_CATEGORY_DISHWASHER) && !ct.type.includes('BF');
|
|
2733
2734
|
}).properties.get('width').get('_length');
|
|
2734
2735
|
var unit_width = countertop.items.find(function (ct) {
|
|
2735
|
-
return !ct.type.includes(
|
|
2736
|
+
return !ct.type.includes(_applianceCategories.APPLIANCE_CATEGORY_DISHWASHER) && !ct.type.includes('BF');
|
|
2736
2737
|
}).properties.get('width').get('_unit') || 'cm';
|
|
2737
2738
|
width = (0, _convertUnitsLite.convert)(width).from(unit_width).to('cm');
|
|
2738
2739
|
pivotMat.scale(new Three.Vector3(countertop.size.width / width, 1, 1));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EXCLUDED_APPLIANCE_CATEGORIES = exports.APPLIANCE_CATEGORY_REFRIGERATOR = exports.APPLIANCE_CATEGORY_RANGE = exports.APPLIANCE_CATEGORY_MICROWAVE = exports.APPLIANCE_CATEGORY_HOOD = exports.APPLIANCE_CATEGORY_DISHWASHER = exports.APPLIANCE_CATEGORY_COOK_TOP = void 0;
|
|
7
|
+
// Appliance category/name constants
|
|
8
|
+
//
|
|
9
|
+
// NOTE: Keep these in a small dedicated module instead of adding more
|
|
10
|
+
// hardcoded strings into src/constants.js (which is already very large).
|
|
11
|
+
|
|
12
|
+
// wall-like appliances
|
|
13
|
+
var APPLIANCE_CATEGORY_COOK_TOP = exports.APPLIANCE_CATEGORY_COOK_TOP = 'Cook Top';
|
|
14
|
+
var APPLIANCE_CATEGORY_MICROWAVE = exports.APPLIANCE_CATEGORY_MICROWAVE = 'Microwave';
|
|
15
|
+
var APPLIANCE_CATEGORY_HOOD = exports.APPLIANCE_CATEGORY_HOOD = 'Hood';
|
|
16
|
+
|
|
17
|
+
// base-like appliances
|
|
18
|
+
var APPLIANCE_CATEGORY_DISHWASHER = exports.APPLIANCE_CATEGORY_DISHWASHER = 'Dishwasher';
|
|
19
|
+
var APPLIANCE_CATEGORY_REFRIGERATOR = exports.APPLIANCE_CATEGORY_REFRIGERATOR = 'Refrigerator';
|
|
20
|
+
var APPLIANCE_CATEGORY_RANGE = exports.APPLIANCE_CATEGORY_RANGE = 'Range';
|
|
21
|
+
|
|
22
|
+
// Categories that we exclude from some snapping/overlap logic.
|
|
23
|
+
// (exported as an array so call-sites can create their own Set and avoid
|
|
24
|
+
// accidental shared mutation)
|
|
25
|
+
var EXCLUDED_APPLIANCE_CATEGORIES = exports.EXCLUDED_APPLIANCE_CATEGORIES = Object.freeze([APPLIANCE_CATEGORY_COOK_TOP, APPLIANCE_CATEGORY_MICROWAVE, APPLIANCE_CATEGORY_HOOD]);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.shouldBypassItemIntersectionValidation = void 0;
|
|
7
|
+
var _applianceCategories = require("../../constants/applianceCategories");
|
|
8
|
+
/**
|
|
9
|
+
* Returns `true` for items that are intentionally allowed to overlap other
|
|
10
|
+
* elements while being placed/dragged in the 2D viewer.
|
|
11
|
+
*
|
|
12
|
+
* Why this exists:
|
|
13
|
+
* - `GeometryUtils.validInterSect(...)` is used as a collision/intersection gate.
|
|
14
|
+
* - Some appliances (e.g. cooktops/ranges/hoods) are expected to be placed "on"
|
|
15
|
+
* or "inside" cabinetry/countertops, so they must not be blocked by that gate.
|
|
16
|
+
*
|
|
17
|
+
* NOTE: This currently identifies items by the appliance category strings found
|
|
18
|
+
* in `itemInfo.name` / `itemInfo.cabinet_category`.
|
|
19
|
+
*/
|
|
20
|
+
var shouldBypassItemIntersectionValidation = exports.shouldBypassItemIntersectionValidation = function shouldBypassItemIntersectionValidation(itemRect) {
|
|
21
|
+
var itemInfo = itemRect === null || itemRect === void 0 ? void 0 : itemRect.itemInfo;
|
|
22
|
+
var name = typeof (itemInfo === null || itemInfo === void 0 ? void 0 : itemInfo.name) === 'string' ? itemInfo.name : '';
|
|
23
|
+
var cabinetCategory = typeof (itemInfo === null || itemInfo === void 0 ? void 0 : itemInfo.cabinet_category) === 'string' ? itemInfo.cabinet_category : '';
|
|
24
|
+
return name.includes(_applianceCategories.APPLIANCE_CATEGORY_HOOD) || cabinetCategory.toLowerCase().includes(_applianceCategories.APPLIANCE_CATEGORY_HOOD.toLowerCase()) || name.includes(_applianceCategories.APPLIANCE_CATEGORY_RANGE) || name.includes(_applianceCategories.APPLIANCE_CATEGORY_COOK_TOP);
|
|
25
|
+
};
|
package/lib/utils/geometry.js
CHANGED
|
@@ -107,6 +107,8 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
107
107
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
108
108
|
var _math = require("./math.js");
|
|
109
109
|
var _constants = require("../constants");
|
|
110
|
+
var _applianceCategories = require("../constants/applianceCategories");
|
|
111
|
+
var _viewerUtils = require("../engine/2d/viewer-utils.js");
|
|
110
112
|
var _convertUnitsLite = require("./convert-units-lite");
|
|
111
113
|
var Three = _interopRequireWildcard(require("three"));
|
|
112
114
|
var _utils = require("../components/viewer2d/utils.js");
|
|
@@ -833,8 +835,9 @@ function getAllItemSpecified(scene, catalog, filter) {
|
|
|
833
835
|
};
|
|
834
836
|
var curiteminfo;
|
|
835
837
|
var iteminfo = [];
|
|
838
|
+
var excludedApplianceCategories = new Set(_applianceCategories.EXCLUDED_APPLIANCE_CATEGORIES);
|
|
836
839
|
layer.items.forEach(function (item) {
|
|
837
|
-
var _cat$obj;
|
|
840
|
+
var _cat$obj, _cat$obj2;
|
|
838
841
|
if (!item) return;
|
|
839
842
|
var val = {
|
|
840
843
|
pos: {
|
|
@@ -860,11 +863,9 @@ function getAllItemSpecified(scene, catalog, filter) {
|
|
|
860
863
|
val.item = item;
|
|
861
864
|
|
|
862
865
|
// Filter check
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
return;
|
|
867
|
-
}
|
|
866
|
+
var isExcludedItem = (0, _helper.isEmpty)(cat) || (cat === null || cat === void 0 ? void 0 : cat.type) === 'appliance' && excludedApplianceCategories.has(cat === null || cat === void 0 || (_cat$obj = cat.obj) === null || _cat$obj === void 0 ? void 0 : _cat$obj.category) || excludedApplianceCategories.has(cat === null || cat === void 0 || (_cat$obj2 = cat.obj) === null || _cat$obj2 === void 0 ? void 0 : _cat$obj2.cabinet_category);
|
|
867
|
+
var layoutMatches = Array.isArray(filter) ? !!val.layoutpos && filter.includes(val.layoutpos) : val.layoutpos === filter;
|
|
868
|
+
if (!layoutMatches || isExcludedItem) return;
|
|
868
869
|
|
|
869
870
|
// Current vs others
|
|
870
871
|
var rect = getCalcRectFromItem3D(val);
|
|
@@ -1737,7 +1738,7 @@ function calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect,
|
|
|
1737
1738
|
rotRad = snap.rotRad;
|
|
1738
1739
|
}
|
|
1739
1740
|
});
|
|
1740
|
-
if (allItemRect.cur.itemInfo.name.includes(
|
|
1741
|
+
if (allItemRect.cur.itemInfo.name.includes(_applianceCategories.APPLIANCE_CATEGORY_COOK_TOP)) {
|
|
1741
1742
|
var intersects = allItemRect.others.filter(function (others) {
|
|
1742
1743
|
return intersectRect(others.rect, curitem.rect);
|
|
1743
1744
|
});
|
|
@@ -1749,12 +1750,12 @@ function calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect,
|
|
|
1749
1750
|
}
|
|
1750
1751
|
});
|
|
1751
1752
|
}
|
|
1752
|
-
if (
|
|
1753
|
+
if ((0, _viewerUtils.shouldBypassItemIntersectionValidation)(allItemRect.cur)) {
|
|
1753
1754
|
var _intersects = allItemRect.others.filter(function (others) {
|
|
1754
1755
|
return intersectRect(others.rect, curitem.rect);
|
|
1755
1756
|
});
|
|
1756
1757
|
_intersects.forEach(function (rect) {
|
|
1757
|
-
if (isPointInArea(allArea, rect.itemInfo) || !allArea.length)
|
|
1758
|
+
if ((isPointInArea(allArea, rect.itemInfo) || !allArea.length) && (0, _viewerUtils.shouldBypassItemIntersectionValidation)(rect)) {
|
|
1758
1759
|
nx = rect.itemInfo.x;
|
|
1759
1760
|
ny = rect.itemInfo.y;
|
|
1760
1761
|
rotRad = rect.itemInfo.rotation * Math.PI / 180;
|
|
@@ -2143,9 +2144,9 @@ function needSnap(curItem, othItem) {
|
|
|
2143
2144
|
var isBlsnapOth = othItem.item.category === 'cabinet' && othItem.item.layoutpos === _constants.BASE_CABINET_LAYOUTPOS && Math.abs(curFloor - otherFloor) >= delta;
|
|
2144
2145
|
var isBlsnapCur = curItem.selectedItem.category === 'cabinet' && curItem.selectedItem.layoutpos === _constants.BASE_CABINET_LAYOUTPOS && Math.abs(curFloor - otherFloor) >= delta;
|
|
2145
2146
|
if (curItem.cat.hasOwnProperty('long_name') || othItem.cat && othItem.cat.hasOwnProperty('long_name')) {
|
|
2146
|
-
if (curItem.cat.long_name.includes(
|
|
2147
|
-
if (curItem.cat.long_name.includes(
|
|
2148
|
-
if (curItem.cat.long_name.includes(
|
|
2147
|
+
if (curItem.cat.long_name.includes(_applianceCategories.APPLIANCE_CATEGORY_HOOD) || othItem.cat && othItem.cat.long_name.includes(_applianceCategories.APPLIANCE_CATEGORY_HOOD)) blSnap = true;
|
|
2148
|
+
if (curItem.cat.long_name.includes(_applianceCategories.APPLIANCE_CATEGORY_HOOD) && othItem.cat && isBlsnapOth || isBlsnapCur && othItem.cat.long_name.includes(_applianceCategories.APPLIANCE_CATEGORY_HOOD)) blSnap = false;
|
|
2149
|
+
if (curItem.cat.long_name.includes(_applianceCategories.APPLIANCE_CATEGORY_COOK_TOP) && othItem.cat && othItem.cat.long_name.includes('Cabinet') || curItem.cat.long_name.includes('Cabinet') && othItem.cat && othItem.cat.long_name.includes(_applianceCategories.APPLIANCE_CATEGORY_COOK_TOP)) blSnap = true;
|
|
2149
2150
|
}
|
|
2150
2151
|
return blSnap;
|
|
2151
2152
|
}
|