kitchen-simulator 4.4.0 → 4.4.1
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 +3 -4
- package/es/components/viewer3d/scene-creator.js +34 -5
- package/es/utils/geometry.js +79 -0
- package/es/utils/isolate-event-handler.js +122 -502
- package/lib/components/viewer2d/viewer2d.js +3 -4
- package/lib/components/viewer3d/scene-creator.js +33 -4
- package/lib/utils/geometry.js +81 -0
- package/lib/utils/isolate-event-handler.js +122 -502
- package/package.json +1 -1
|
@@ -1410,10 +1410,9 @@ export default function Viewer2D(_ref, _ref2) {
|
|
|
1410
1410
|
detectAutoPan: mode2DetectAutopan(mode),
|
|
1411
1411
|
onMouseDown: onMouseDown,
|
|
1412
1412
|
onMouseMove: onMouseMove,
|
|
1413
|
-
onMouseUp: onMouseUp
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
,
|
|
1413
|
+
onMouseUp: onMouseUp,
|
|
1414
|
+
miniaturePosition: "none",
|
|
1415
|
+
toolbarPosition: "none",
|
|
1417
1416
|
detectPinchGesture: false,
|
|
1418
1417
|
disableDoubleClickZoomWithToolAuto: true,
|
|
1419
1418
|
ref: Viewer
|
|
@@ -9,7 +9,7 @@ import { disposeObject } from "./three-memory-cleaner";
|
|
|
9
9
|
import { ANIMATE_STEP_MAX, ANIMATE_STEP_MIN, ARRAY_3D_MODES, ARROW_TEXT_BACKCOLOR, ARROW_TEXT_FONTFACE, ARROW_TEXT_FORECOLOR, BASE_CABINET_LAYOUTPOS, BOTTOM_MOLDING_LOCATION, DECIMAL_PLACES_2, DIFFERENT_VALUES_PATH_LENGTH, DISTANCE_EPSILON, EPSILON, MIDDLE_MOLDING_LOCATION, MODE_DRAGGING_ITEM_3D, MODE_DRAWING_ITEM_3D, MODE_IDLE, MODE_IDLE_3D, MODE_ROTATING_ITEM_3D, OBJTYPE_MESH, SHADE_DARK_PURPLE_COLOR, TOP_MOLDING_LOCATION, UNIT_CENTIMETER, UNIT_FOOT, UNIT_INCH, UNIT_METER, WALL_CABINET_LAYOUTPOS } from "../../constants";
|
|
10
10
|
import { GeometryUtils, IDBroker, MoldingUtils } from "../../utils/export";
|
|
11
11
|
import { convert } from "../../utils/convert-units-lite";
|
|
12
|
-
import { calcDistancesFromItemToWalls, getSnappedWallLines, verticesDistance } from "../../utils/geometry";
|
|
12
|
+
import { calcDistancesFromItemToWalls, getLineSnapPointsOfItem, getSnappedWallLines, isOverlappedTwoItemsOnOneLine, pointsDistance, verticesDistance } from "../../utils/geometry";
|
|
13
13
|
import * as GeomUtils from "../../catalog/utils/geom-utils";
|
|
14
14
|
import { loadTexture } from "../../catalog/utils/item-loader";
|
|
15
15
|
import { returnReplaceableDeepSearchType } from "../viewer2d/utils";
|
|
@@ -3035,13 +3035,23 @@ export function createBacksplash(item, layer, planData, scene) {
|
|
|
3035
3035
|
*/
|
|
3036
3036
|
var altItems = [],
|
|
3037
3037
|
flag = false;
|
|
3038
|
+
var D0 = {},
|
|
3039
|
+
D1 = {};
|
|
3038
3040
|
wallItems.map(function (wallItem) {
|
|
3039
3041
|
var _wallItem$itemInfo, _wallItem$itemInfo2;
|
|
3040
3042
|
var altitude = (_wallItem$itemInfo = wallItem.itemInfo) === null || _wallItem$itemInfo === void 0 || (_wallItem$itemInfo = _wallItem$itemInfo.properties) === null || _wallItem$itemInfo === void 0 ? void 0 : _wallItem$itemInfo.get('altitude').get('_length');
|
|
3041
3043
|
var altitudeUnit = ((_wallItem$itemInfo2 = wallItem.itemInfo) === null || _wallItem$itemInfo2 === void 0 || (_wallItem$itemInfo2 = _wallItem$itemInfo2.properties) === null || _wallItem$itemInfo2 === void 0 ? void 0 : _wallItem$itemInfo2.get('altitude').get('_unit')) || 'cm';
|
|
3042
3044
|
if (!isEmpty(altitude) && !isEmpty(altitudeUnit)) {
|
|
3043
3045
|
altitude = convert(altitude).from(altitudeUnit).to('cm');
|
|
3046
|
+
var altPoints = getLineSnapPointsOfItem(layer, curLine, wallItem);
|
|
3047
|
+
if (altPoints.length > 1) {
|
|
3048
|
+
D0 = altPoints[0];
|
|
3049
|
+
D1 = altPoints[1];
|
|
3050
|
+
}
|
|
3044
3051
|
altItems.push({
|
|
3052
|
+
D0: D0,
|
|
3053
|
+
// D0, D1: item's snapped points with line
|
|
3054
|
+
D1: D1,
|
|
3045
3055
|
x: wallItem.pos.x,
|
|
3046
3056
|
width: wallItem.size.width,
|
|
3047
3057
|
altitude: altitude
|
|
@@ -3049,10 +3059,29 @@ export function createBacksplash(item, layer, planData, scene) {
|
|
|
3049
3059
|
}
|
|
3050
3060
|
});
|
|
3051
3061
|
layer.holes.map(function (hole) {
|
|
3052
|
-
var _hole$properties, _hole$properties2;
|
|
3062
|
+
var _hole$properties, _hole$properties2, _layer$lines, _layer$vertices, _line$vertices, _layer$vertices2, _line$vertices2;
|
|
3053
3063
|
var width = (_hole$properties = hole.properties) === null || _hole$properties === void 0 ? void 0 : _hole$properties.getIn(['width', 'length']);
|
|
3054
3064
|
var altitude = (_hole$properties2 = hole.properties) === null || _hole$properties2 === void 0 ? void 0 : _hole$properties2.getIn(['altitude', 'length']);
|
|
3065
|
+
var line = (_layer$lines = layer.lines) === null || _layer$lines === void 0 ? void 0 : _layer$lines.get(curLine === null || curLine === void 0 ? void 0 : curLine.id);
|
|
3066
|
+
var v0 = (_layer$vertices = layer.vertices) === null || _layer$vertices === void 0 ? void 0 : _layer$vertices.get(line === null || line === void 0 || (_line$vertices = line.vertices) === null || _line$vertices === void 0 ? void 0 : _line$vertices.get(0));
|
|
3067
|
+
var v1 = (_layer$vertices2 = layer.vertices) === null || _layer$vertices2 === void 0 ? void 0 : _layer$vertices2.get(line === null || line === void 0 || (_line$vertices2 = line.vertices) === null || _line$vertices2 === void 0 ? void 0 : _line$vertices2.get(1));
|
|
3068
|
+
if (!isEmpty(v0) || !isEmpty(v1)) {
|
|
3069
|
+
var lineLength = pointsDistance(v0.x, v0.y, v1.x, v1.y);
|
|
3070
|
+
var disD0 = lineLength * hole.offset - width / 2;
|
|
3071
|
+
var disD1 = lineLength * hole.offset + width / 2;
|
|
3072
|
+
D0 = {
|
|
3073
|
+
x: v0.x + disD0 * Math.cos(hole.rotRad),
|
|
3074
|
+
y: v0.y + disD0 * Math.sin(hole.rotRad)
|
|
3075
|
+
};
|
|
3076
|
+
D1 = {
|
|
3077
|
+
x: v0.x + disD1 * Math.cos(hole.rotRad),
|
|
3078
|
+
y: v0.y + disD1 * Math.sin(hole.rotRad)
|
|
3079
|
+
};
|
|
3080
|
+
}
|
|
3055
3081
|
if (!isEmpty(width) && !isEmpty(altitude) && hole.line === (curLine === null || curLine === void 0 ? void 0 : curLine.id)) altItems.push({
|
|
3082
|
+
D0: D0,
|
|
3083
|
+
// D0, D1: hole's two points
|
|
3084
|
+
D1: D1,
|
|
3056
3085
|
x: hole.x,
|
|
3057
3086
|
width: width,
|
|
3058
3087
|
altitude: altitude
|
|
@@ -3061,7 +3090,7 @@ export function createBacksplash(item, layer, planData, scene) {
|
|
|
3061
3090
|
if (altItems.length > 0) {
|
|
3062
3091
|
depth = altItems[0].altitude;
|
|
3063
3092
|
altItems.map(function (altItem) {
|
|
3064
|
-
if (
|
|
3093
|
+
if (isOverlappedTwoItemsOnOneLine(layer, curLine, item, altItem)) {
|
|
3065
3094
|
if (depth >= altItem.altitude) {
|
|
3066
3095
|
depth = altItem.altitude;
|
|
3067
3096
|
flag = true;
|
|
@@ -3171,9 +3200,9 @@ export function createBacksplash(item, layer, planData, scene) {
|
|
|
3171
3200
|
}
|
|
3172
3201
|
itemToSave.info.id = item.itemInfo.id;
|
|
3173
3202
|
deleteSpecifiedMeshObjects('backsplash' + item.itemInfo.id);
|
|
3174
|
-
if (Math.abs(item.rotRad % (Math.PI / 2)) < EPSILON) planData.plan.add(backsplash);
|
|
3203
|
+
if (Math.abs(item.rotRad % (Math.PI / 2)) < EPSILON || Math.abs(item.rotRad % (Math.PI / 2) - Math.PI / 2) < EPSILON) planData.plan.add(backsplash);
|
|
3175
3204
|
backsplash.name = name;
|
|
3176
|
-
backsplash.visible = item.itemInfo.get('backsplashVisible') && backsplashApplied && Math.abs(item.rotRad % (Math.PI / 2)) < EPSILON;
|
|
3205
|
+
backsplash.visible = item.itemInfo.get('backsplashVisible') && backsplashApplied && Math.abs(item.rotRad % (Math.PI / 2)) < EPSILON || Math.abs(item.rotRad % (Math.PI / 2) - Math.PI / 2) < EPSILON;
|
|
3177
3206
|
|
|
3178
3207
|
// Save to scene graph
|
|
3179
3208
|
|
package/es/utils/geometry.js
CHANGED
|
@@ -2845,4 +2845,83 @@ export function getSnappedWallLines(item, layer, catalog) {
|
|
|
2845
2845
|
}
|
|
2846
2846
|
}
|
|
2847
2847
|
return snappedWallLines;
|
|
2848
|
+
}
|
|
2849
|
+
export function getLineSnapPointsOfItem(layer, curLine, item) {
|
|
2850
|
+
var _layer$lines2, _layer$vertices4, _line$vertices3, _layer$vertices5, _line$vertices4;
|
|
2851
|
+
// V0
|
|
2852
|
+
// /|
|
|
2853
|
+
// D0 /|-----------|
|
|
2854
|
+
// /| |
|
|
2855
|
+
// /| Item | ====> get D0, D1
|
|
2856
|
+
// /| |
|
|
2857
|
+
// D1 /|-----------|
|
|
2858
|
+
// /|
|
|
2859
|
+
// get v0, v1 of line
|
|
2860
|
+
var line = (_layer$lines2 = layer.lines) === null || _layer$lines2 === void 0 ? void 0 : _layer$lines2.get(curLine === null || curLine === void 0 ? void 0 : curLine.id);
|
|
2861
|
+
var v0 = (_layer$vertices4 = layer.vertices) === null || _layer$vertices4 === void 0 ? void 0 : _layer$vertices4.get(line === null || line === void 0 || (_line$vertices3 = line.vertices) === null || _line$vertices3 === void 0 ? void 0 : _line$vertices3.get(0));
|
|
2862
|
+
var v1 = (_layer$vertices5 = layer.vertices) === null || _layer$vertices5 === void 0 ? void 0 : _layer$vertices5.get(line === null || line === void 0 || (_line$vertices4 = line.vertices) === null || _line$vertices4 === void 0 ? void 0 : _line$vertices4.get(1));
|
|
2863
|
+
var pointGroup = [];
|
|
2864
|
+
if (isEmpty(v0) || isEmpty(v1)) return pointGroup;
|
|
2865
|
+
var itemRect = item === null || item === void 0 ? void 0 : item.rect;
|
|
2866
|
+
if (!isEmpty(itemRect)) {
|
|
2867
|
+
for (var i = 0; i < itemRect.length; i++) {
|
|
2868
|
+
if (distancePointFromLineSegment(v0, v1, itemRect[i].x, itemRect[i].y) < EPSILON) {
|
|
2869
|
+
pointGroup.push(itemRect[i]);
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2872
|
+
}
|
|
2873
|
+
return pointGroup;
|
|
2874
|
+
}
|
|
2875
|
+
export function isOverlappedTwoItemsOnOneLine(layer, curLine, srcItem, desItem) {
|
|
2876
|
+
var _layer$lines3, _layer$vertices6, _line$vertices5, _layer$vertices7, _line$vertices6, _S, _S2, _S3, _S4;
|
|
2877
|
+
if (isEmpty(layer) || isEmpty(curLine) || isEmpty(srcItem) || isEmpty(desItem) || isEmpty(desItem.D0) || isEmpty(desItem.D1)) return false;
|
|
2878
|
+
// get v0, v1 of line
|
|
2879
|
+
var line = (_layer$lines3 = layer.lines) === null || _layer$lines3 === void 0 ? void 0 : _layer$lines3.get(curLine === null || curLine === void 0 ? void 0 : curLine.id);
|
|
2880
|
+
var v0 = (_layer$vertices6 = layer.vertices) === null || _layer$vertices6 === void 0 ? void 0 : _layer$vertices6.get(line === null || line === void 0 || (_line$vertices5 = line.vertices) === null || _line$vertices5 === void 0 ? void 0 : _line$vertices5.get(0));
|
|
2881
|
+
var v1 = (_layer$vertices7 = layer.vertices) === null || _layer$vertices7 === void 0 ? void 0 : _layer$vertices7.get(line === null || line === void 0 || (_line$vertices6 = line.vertices) === null || _line$vertices6 === void 0 ? void 0 : _line$vertices6.get(1));
|
|
2882
|
+
var S0,
|
|
2883
|
+
S1,
|
|
2884
|
+
D0 = desItem === null || desItem === void 0 ? void 0 : desItem.D0,
|
|
2885
|
+
D1 = desItem === null || desItem === void 0 ? void 0 : desItem.D1;
|
|
2886
|
+
if (isEmpty(v0) || isEmpty(v1)) return false;
|
|
2887
|
+
// get distance from v0 to srcItem's S0, S1 and desItem(item or hole)'s D0, D1 are placed on line
|
|
2888
|
+
var srcPoints = getLineSnapPointsOfItem(layer, curLine, srcItem);
|
|
2889
|
+
if (srcPoints.length > 1) {
|
|
2890
|
+
S0 = srcPoints[0];
|
|
2891
|
+
S1 = srcPoints[1];
|
|
2892
|
+
}
|
|
2893
|
+
var disV0S0 = pointsDistance(v0.x, v0.y, (_S = S0) === null || _S === void 0 ? void 0 : _S.x, (_S2 = S0) === null || _S2 === void 0 ? void 0 : _S2.y);
|
|
2894
|
+
var disV0S1 = pointsDistance(v0.x, v0.y, (_S3 = S1) === null || _S3 === void 0 ? void 0 : _S3.x, (_S4 = S1) === null || _S4 === void 0 ? void 0 : _S4.y);
|
|
2895
|
+
var disV0D0 = pointsDistance(v0.x, v0.y, D0.x, D0.y);
|
|
2896
|
+
var disV0D1 = pointsDistance(v0.x, v0.y, D1.x, D1.y);
|
|
2897
|
+
// detect two items are overlapped
|
|
2898
|
+
var maxDisV0S = Math.max(disV0S0, disV0S1);
|
|
2899
|
+
var minDisV0S = Math.min(disV0S0, disV0S1);
|
|
2900
|
+
var maxDisV0D = Math.max(disV0D0, disV0D1);
|
|
2901
|
+
var minDisV0D = Math.min(disV0D0, disV0D1);
|
|
2902
|
+
if (maxDisV0S > maxDisV0D && maxDisV0D - minDisV0S > EPSILON) {
|
|
2903
|
+
// d0 s0 d1 s1 ===> maxDisV0S: v0s1, minDisV0S: v0s0, maxDisV0D: v0d1, minDisV0D: v0d0
|
|
2904
|
+
// v0 __________________________ v1
|
|
2905
|
+
// | | | |
|
|
2906
|
+
// | | | |
|
|
2907
|
+
// |__DI__|__| |
|
|
2908
|
+
// |__SI__|
|
|
2909
|
+
/////////////////////////////////////////
|
|
2910
|
+
// s0 d0 d1 s1 ===> maxDisV0S: v0s1, minDisV0S: v0s0, maxDisV0D: v0d1, minDisV0D: v0d0
|
|
2911
|
+
// v0 __________________________ v1
|
|
2912
|
+
// | | | |
|
|
2913
|
+
// | |__DI__| |
|
|
2914
|
+
// |_________SI_______|
|
|
2915
|
+
return true;
|
|
2916
|
+
} else if (minDisV0S < minDisV0D && maxDisV0S - minDisV0D > EPSILON) {
|
|
2917
|
+
// s0 d0 s1 d1 ===> maxDisV0S: v0s1, minDisV0S: v0s0, maxDisV0D: v0d1, minDisV0D: v0d0
|
|
2918
|
+
// v0 __________________________ v1
|
|
2919
|
+
// | | | |
|
|
2920
|
+
// | |__DI__|
|
|
2921
|
+
// |__SI_____|
|
|
2922
|
+
//
|
|
2923
|
+
return true;
|
|
2924
|
+
} else {
|
|
2925
|
+
return false;
|
|
2926
|
+
}
|
|
2848
2927
|
}
|