kitchen-simulator 7.0.10-react-18 → 11.0.0-react.18
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/LiteKitchenConfigurator.js +4 -5
- package/es/LiteRenderer.js +3 -4
- package/es/catalog/factories/wall-factory.js +1 -1
- package/es/class/project.js +2 -2
- package/es/components/viewer2d/utils.js +1 -5
- package/es/components/viewer3d/scene-creator.js +8 -3
- package/es/constants.js +1 -0
- package/es/index.js +1 -11
- package/es/utils/convert-units-lite.js +9 -0
- package/es/utils/geometry.js +198 -4
- package/es/utils/history.js +13 -1
- package/package.json +1 -1
|
@@ -303,19 +303,18 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
303
303
|
}, {
|
|
304
304
|
key: "componentDidUpdate",
|
|
305
305
|
value: function componentDidUpdate(prevProps) {
|
|
306
|
-
var _extractedState$getIn2
|
|
306
|
+
var _extractedState$getIn2;
|
|
307
307
|
var _this$props2 = this.props,
|
|
308
308
|
externalEvent = _this$props2.externalEvent,
|
|
309
309
|
extractedState = _this$props2.extractedState,
|
|
310
310
|
projectActions = _this$props2.projectActions,
|
|
311
|
-
catalog = _this$props2.catalog
|
|
312
|
-
|
|
313
|
-
onViewer2DChange === null || onViewer2DChange === void 0 || onViewer2DChange(extractedState === null || extractedState === void 0 || (_extractedState$getIn2 = extractedState.getIn) === null || _extractedState$getIn2 === void 0 ? void 0 : _extractedState$getIn2.call(extractedState, ['viewer2D']).toJS());
|
|
311
|
+
catalog = _this$props2.catalog;
|
|
312
|
+
|
|
314
313
|
// same behavior: handle external event when it changes
|
|
315
314
|
if (prevProps.externalEvent !== externalEvent) {
|
|
316
315
|
handleExternalEvent(this.props);
|
|
317
316
|
}
|
|
318
|
-
var catalogReady = extractedState === null || extractedState === void 0 || (_extractedState$
|
|
317
|
+
var catalogReady = extractedState === null || extractedState === void 0 || (_extractedState$getIn2 = extractedState.getIn) === null || _extractedState$getIn2 === void 0 ? void 0 : _extractedState$getIn2.call(extractedState, ['catalog', 'ready']);
|
|
319
318
|
if (!catalogReady) projectActions.initCatalog(catalog);
|
|
320
319
|
}
|
|
321
320
|
}, {
|
package/es/LiteRenderer.js
CHANGED
|
@@ -6,7 +6,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
8
8
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
9
|
-
var _excluded = ["width", "height", "configData", "externalEvent", "onInternalEvent", "onError"
|
|
9
|
+
var _excluded = ["width", "height", "configData", "externalEvent", "onInternalEvent", "onError"];
|
|
10
10
|
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; }
|
|
11
11
|
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; }
|
|
12
12
|
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; } } }; }
|
|
@@ -25,6 +25,7 @@ import * as THREE from 'three';
|
|
|
25
25
|
import * as Models from "./models";
|
|
26
26
|
import { State } from "./models";
|
|
27
27
|
import PlannerReducer from "./reducers/reducer";
|
|
28
|
+
import AppContext from "./AppContext";
|
|
28
29
|
import Catalog from "./catalog/catalog";
|
|
29
30
|
import * as Areas from "./catalog/areas/area/planner-element";
|
|
30
31
|
import * as Lines from "./catalog/lines/wall/planner-element";
|
|
@@ -163,7 +164,6 @@ export default function LiteRenderer(props) {
|
|
|
163
164
|
externalEvent = props.externalEvent,
|
|
164
165
|
onInternalEvent = props.onInternalEvent,
|
|
165
166
|
onError = props.onError,
|
|
166
|
-
onViewer2DChange = props.onViewer2DChange,
|
|
167
167
|
passThrough = _objectWithoutProperties(props, _excluded);
|
|
168
168
|
useEffect(function () {
|
|
169
169
|
return function () {
|
|
@@ -338,8 +338,7 @@ export default function LiteRenderer(props) {
|
|
|
338
338
|
},
|
|
339
339
|
configData: configData,
|
|
340
340
|
externalEvent: externalEvent,
|
|
341
|
-
onInternalEvent: onInternalEvent
|
|
342
|
-
onViewer2DChange: onViewer2DChange
|
|
341
|
+
onInternalEvent: onInternalEvent
|
|
343
342
|
}, passThrough))));
|
|
344
343
|
}
|
|
345
344
|
LiteRenderer.propTypes = {
|
package/es/class/project.js
CHANGED
|
@@ -857,8 +857,8 @@ var Project = /*#__PURE__*/function () {
|
|
|
857
857
|
if (isEmpty(viewer)) return {
|
|
858
858
|
updatedState: state
|
|
859
859
|
};
|
|
860
|
-
width = convert(width).from(measurementUnit).to('cm');
|
|
861
|
-
height = convert(height).from(measurementUnit).to('cm');
|
|
860
|
+
width = convert(width).from(measurementUnit !== null && measurementUnit !== void 0 ? measurementUnit : 'in').to('cm');
|
|
861
|
+
height = convert(height).from(measurementUnit !== null && measurementUnit !== void 0 ? measurementUnit : 'in').to('cm');
|
|
862
862
|
var halfWidth = width / 2;
|
|
863
863
|
var halfHeight = height / 2;
|
|
864
864
|
var viewerWidth = viewer.SVGWidth;
|
|
@@ -190,8 +190,4 @@ export var isWarningItem = function isWarningItem(item) {
|
|
|
190
190
|
if (item.category === 'cabinet') return !(item !== null && item !== void 0 && (_item$toJS$doorStyle = item.toJS().doorStyle) !== null && _item$toJS$doorStyle !== void 0 && (_item$toJS$doorStyle = _item$toJS$doorStyle.doorStyles) !== null && _item$toJS$doorStyle !== void 0 && (_item$toJS$doorStyle = _item$toJS$doorStyle.cds) !== null && _item$toJS$doorStyle !== void 0 && _item$toJS$doorStyle.filter(function (cd) {
|
|
191
191
|
return cd.itemID == (item === null || item === void 0 ? void 0 : item.getIn(['itemID']));
|
|
192
192
|
}).length) > 0;else return false;
|
|
193
|
-
};
|
|
194
|
-
export function shallowEqualViewer(a, b) {
|
|
195
|
-
if (!a || !b) return a === b;
|
|
196
|
-
return a.a === b.a && a.d === b.d && a.e === b.e && a.f === b.f && a.viewerWidth === b.viewerWidth && a.viewerHeight === b.viewerHeight && a.SVGWidth === b.SVGWidth && a.SVGHeight === b.SVGHeight;
|
|
197
|
-
}
|
|
193
|
+
};
|
|
@@ -12,7 +12,7 @@ import { disposeObject } from "./three-memory-cleaner";
|
|
|
12
12
|
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";
|
|
13
13
|
import { GeometryUtils, IDBroker, MoldingUtils } from "../../utils/export";
|
|
14
14
|
import { convert } from "../../utils/convert-units-lite";
|
|
15
|
-
import { calcDistancesFromItemToWalls, verticesDistance } from "../../utils/geometry";
|
|
15
|
+
import { calcDistancesFromItemToWalls, getSnappedWallLines, verticesDistance } from "../../utils/geometry";
|
|
16
16
|
import * as GeomUtils from "../../catalog/utils/geom-utils";
|
|
17
17
|
import { loadTexture } from "../../catalog/utils/item-loader";
|
|
18
18
|
import { returnReplaceableDeepSearchType } from "../viewer2d/utils";
|
|
@@ -3010,6 +3010,10 @@ export function createBacksplash(item, layer, planData, scene) {
|
|
|
3010
3010
|
return;
|
|
3011
3011
|
}
|
|
3012
3012
|
|
|
3013
|
+
// Get current wall line that item is snapped
|
|
3014
|
+
var wLines = getSnappedWallLines(item.itemInfo, layer, planData.catalog);
|
|
3015
|
+
var curLine = wLines.length > 0 ? wLines[0] : null;
|
|
3016
|
+
|
|
3013
3017
|
// Get wall items
|
|
3014
3018
|
|
|
3015
3019
|
var i,
|
|
@@ -3051,7 +3055,7 @@ export function createBacksplash(item, layer, planData, scene) {
|
|
|
3051
3055
|
var _hole$properties, _hole$properties2;
|
|
3052
3056
|
var width = (_hole$properties = hole.properties) === null || _hole$properties === void 0 ? void 0 : _hole$properties.getIn(['width', 'length']);
|
|
3053
3057
|
var altitude = (_hole$properties2 = hole.properties) === null || _hole$properties2 === void 0 ? void 0 : _hole$properties2.getIn(['altitude', 'length']);
|
|
3054
|
-
if (!isEmpty(width) && !isEmpty(altitude)) altItems.push({
|
|
3058
|
+
if (!isEmpty(width) && !isEmpty(altitude) && hole.line === (curLine === null || curLine === void 0 ? void 0 : curLine.id)) altItems.push({
|
|
3055
3059
|
x: hole.x,
|
|
3056
3060
|
width: width,
|
|
3057
3061
|
altitude: altitude
|
|
@@ -3068,7 +3072,8 @@ export function createBacksplash(item, layer, planData, scene) {
|
|
|
3068
3072
|
}
|
|
3069
3073
|
});
|
|
3070
3074
|
}
|
|
3071
|
-
|
|
3075
|
+
var DEFAULT_BACKSPLASH_HEIGHT = 52 * 2.54;
|
|
3076
|
+
if (!flag || depth > DEFAULT_BACKSPLASH_HEIGHT) depth = DEFAULT_BACKSPLASH_HEIGHT;
|
|
3072
3077
|
|
|
3073
3078
|
// Get backsplash info
|
|
3074
3079
|
|
package/es/constants.js
CHANGED
|
@@ -447,6 +447,7 @@ export var UNIT_MILLIMETER = 'mm';
|
|
|
447
447
|
export var UNIT_CENTIMETER = 'cm';
|
|
448
448
|
export var UNIT_METER = 'm';
|
|
449
449
|
export var UNIT_INCH = 'in';
|
|
450
|
+
export var UNIT_INCH_LONG = 'inch';
|
|
450
451
|
export var UNIT_FOOT = 'ft';
|
|
451
452
|
export var UNIT_MILE = 'mi';
|
|
452
453
|
export var UNITS_LENGTH = [UNIT_MILLIMETER, UNIT_CENTIMETER, UNIT_METER, UNIT_INCH, UNIT_FOOT, UNIT_MILE];
|
package/es/index.js
CHANGED
|
@@ -15,7 +15,6 @@ import React from 'react';
|
|
|
15
15
|
import * as Three from 'three';
|
|
16
16
|
import LiteRenderer from "./LiteRenderer";
|
|
17
17
|
import { createRoot } from 'react-dom/client';
|
|
18
|
-
import { shallowEqualViewer } from "./components/viewer2d/utils";
|
|
19
18
|
var ROOT_KEY = '__kitchenSimulatorRoot__';
|
|
20
19
|
var API_KEY = '__kitchenSimulatorApi__';
|
|
21
20
|
function nextFrame() {
|
|
@@ -369,7 +368,6 @@ export function renderKitchenSimulator(container) {
|
|
|
369
368
|
|
|
370
369
|
// ✅ Reuse root
|
|
371
370
|
var root = container[ROOT_KEY];
|
|
372
|
-
var latestViewer2D = null;
|
|
373
371
|
if (!root) {
|
|
374
372
|
root = createRoot(container);
|
|
375
373
|
container[ROOT_KEY] = root;
|
|
@@ -550,12 +548,7 @@ export function renderKitchenSimulator(container) {
|
|
|
550
548
|
key: "render",
|
|
551
549
|
value: function render() {
|
|
552
550
|
return /*#__PURE__*/React.createElement(LiteRenderer, _extends({}, this.props, {
|
|
553
|
-
externalEvent: this.state.externalEvent
|
|
554
|
-
onViewer2DChange: function onViewer2DChange(v) {
|
|
555
|
-
if (!shallowEqualViewer(v, latestViewer2D)) {
|
|
556
|
-
latestViewer2D = v;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
551
|
+
externalEvent: this.state.externalEvent
|
|
559
552
|
}));
|
|
560
553
|
}
|
|
561
554
|
}]);
|
|
@@ -564,9 +557,6 @@ export function renderKitchenSimulator(container) {
|
|
|
564
557
|
__render: function __render(nextProps) {
|
|
565
558
|
root.render(/*#__PURE__*/React.createElement(Wrapper, nextProps));
|
|
566
559
|
},
|
|
567
|
-
getViewer2D: function getViewer2D() {
|
|
568
|
-
return latestViewer2D;
|
|
569
|
-
},
|
|
570
560
|
// ✅ host can query current inFlight
|
|
571
561
|
getGltfInFlight: function getGltfInFlight() {
|
|
572
562
|
return gltfTracker.getInFlight();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UNIT_INCH, UNIT_INCH_LONG } from "../constants";
|
|
1
2
|
var lengthFactors = {
|
|
2
3
|
m: 1,
|
|
3
4
|
cm: 100,
|
|
@@ -13,11 +14,19 @@ var lengthFactors = {
|
|
|
13
14
|
// (39.3701^2)
|
|
14
15
|
ft2: 10.7639 // (3.28084^2)
|
|
15
16
|
};
|
|
17
|
+
function normalizeUnit(unit) {
|
|
18
|
+
if (!unit) return unit;
|
|
19
|
+
var u = unit.toLowerCase();
|
|
20
|
+
if (u === UNIT_INCH_LONG) return UNIT_INCH;
|
|
21
|
+
return u;
|
|
22
|
+
}
|
|
16
23
|
export function convert(value) {
|
|
17
24
|
return {
|
|
18
25
|
from: function from(fromUnit) {
|
|
19
26
|
return {
|
|
20
27
|
to: function to(toUnit) {
|
|
28
|
+
fromUnit = normalizeUnit(fromUnit);
|
|
29
|
+
toUnit = normalizeUnit(toUnit);
|
|
21
30
|
if (!(fromUnit in lengthFactors) || !(toUnit in lengthFactors)) {
|
|
22
31
|
throw new Error("Unsupported unit conversion: ".concat(fromUnit, " \u2192 ").concat(toUnit));
|
|
23
32
|
}
|
package/es/utils/geometry.js
CHANGED
|
@@ -759,7 +759,7 @@ export function getAllItemSpecified(scene, catalog, filter) {
|
|
|
759
759
|
// Filter check
|
|
760
760
|
if (Array.isArray(filter)) {
|
|
761
761
|
if (info && !filter.includes(info.layoutpos)) return;
|
|
762
|
-
} else if (info
|
|
762
|
+
} else if ((info === null || info === void 0 ? void 0 : info.layoutpos) !== filter || isEmpty(cat) || (cat === null || cat === void 0 ? void 0 : cat.type) === 'appliance' && ['Cook Top', 'Microwave'].includes(cat === null || cat === void 0 || (_cat$obj = cat.obj) === null || _cat$obj === void 0 ? void 0 : _cat$obj.category)) {
|
|
763
763
|
return;
|
|
764
764
|
}
|
|
765
765
|
|
|
@@ -995,9 +995,9 @@ export function getAllLines(layer) {
|
|
|
995
995
|
}
|
|
996
996
|
}
|
|
997
997
|
});
|
|
998
|
-
allLines.splice(addIdx, 0, [vertices, thick]);
|
|
998
|
+
allLines.splice(addIdx, 0, [vertices, thick, line.id]);
|
|
999
999
|
} else {
|
|
1000
|
-
allLines.push([allAreaLines[i], thick]);
|
|
1000
|
+
allLines.push([allAreaLines[i], thick, line.id]);
|
|
1001
1001
|
}
|
|
1002
1002
|
});
|
|
1003
1003
|
return allLines;
|
|
@@ -1039,7 +1039,9 @@ export function buildRectFromLines(layer, lines) {
|
|
|
1039
1039
|
var y0 = vxys[1];
|
|
1040
1040
|
var x1 = vxys[2];
|
|
1041
1041
|
var y1 = vxys[3];
|
|
1042
|
-
|
|
1042
|
+
var rectLine = getCalcRectFromLine(x0, y0, x1, y1, thick, layer);
|
|
1043
|
+
rectLine.lineId = line.length > 2 ? line[2] : null;
|
|
1044
|
+
rect.push(rectLine);
|
|
1043
1045
|
});
|
|
1044
1046
|
return rect;
|
|
1045
1047
|
}
|
|
@@ -2606,4 +2608,196 @@ export function calcDistancesFromItemToWalls(curItem, layer) {
|
|
|
2606
2608
|
return {
|
|
2607
2609
|
PointArray: PointArray
|
|
2608
2610
|
};
|
|
2611
|
+
}
|
|
2612
|
+
export function calcDistancesFromHoleToNearestOneOrWall(curHole, layer) {
|
|
2613
|
+
var _layer$lines, _layer$vertices2, _line$vertices, _layer$vertices3, _line$vertices2, _curHole$properties$g, _curHole$properties, _line$get;
|
|
2614
|
+
var distArray = {
|
|
2615
|
+
distLeft: 0,
|
|
2616
|
+
distRight: 0
|
|
2617
|
+
};
|
|
2618
|
+
if (isEmpty(curHole)) return distArray;
|
|
2619
|
+
/***** calculate Left & Right distance from nearest hole ******/
|
|
2620
|
+
// parent line of curHole
|
|
2621
|
+
var line = (_layer$lines = layer.lines) === null || _layer$lines === void 0 ? void 0 : _layer$lines.get(curHole.line);
|
|
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
|
+
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
|
+
if (isEmpty(line) || isEmpty(v0) || isEmpty(v1)) return distArray;
|
|
2625
|
+
var angle = angleBetweenTwoPoints(v0.x, v0.y, v1.x, v1.y);
|
|
2626
|
+
|
|
2627
|
+
// start point and end point of current hole
|
|
2628
|
+
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;
|
|
2629
|
+
var chsp = {
|
|
2630
|
+
x: curHole.x - chw / 2 * Math.cos(angle),
|
|
2631
|
+
y: curHole.y - chw / 2 * Math.sin(angle)
|
|
2632
|
+
};
|
|
2633
|
+
var chep = {
|
|
2634
|
+
x: curHole.x + chw / 2 * Math.cos(angle),
|
|
2635
|
+
y: curHole.y + chw / 2 * Math.sin(angle)
|
|
2636
|
+
};
|
|
2637
|
+
distArray.distLeft = pointsDistance(v0.x, v0.y, chsp.x, chsp.y);
|
|
2638
|
+
distArray.distRight = pointsDistance(v1.x, v1.y, chep.x, chep.y);
|
|
2639
|
+
(_line$get = line.get('holes')) === null || _line$get === void 0 || _line$get.forEach(function (hId) {
|
|
2640
|
+
if (hId !== curHole.id) {
|
|
2641
|
+
var _layer$holes, _hole$properties$get$, _hole$properties;
|
|
2642
|
+
var hole = (_layer$holes = layer.holes) === null || _layer$holes === void 0 ? void 0 : _layer$holes.get(hId);
|
|
2643
|
+
// start point and end point of other hole
|
|
2644
|
+
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;
|
|
2645
|
+
var hsp = {
|
|
2646
|
+
x: hole.x - hw / 2 * Math.cos(angle),
|
|
2647
|
+
y: hole.y - hw / 2 * Math.sin(angle)
|
|
2648
|
+
};
|
|
2649
|
+
var hep = {
|
|
2650
|
+
x: hole.x + hw / 2 * Math.cos(angle),
|
|
2651
|
+
y: hole.y + hw / 2 * Math.sin(angle)
|
|
2652
|
+
};
|
|
2653
|
+
var relation = relationshipOfTwoOverlappedLines({
|
|
2654
|
+
x1: chsp.x,
|
|
2655
|
+
y1: chsp.y,
|
|
2656
|
+
x2: chep.x,
|
|
2657
|
+
y2: chep.y
|
|
2658
|
+
}, {
|
|
2659
|
+
x1: hsp.x,
|
|
2660
|
+
y1: hsp.y,
|
|
2661
|
+
x2: hep.x,
|
|
2662
|
+
y2: hep.y
|
|
2663
|
+
});
|
|
2664
|
+
// two holes(current hole and other hole) are not overlaped, then get distance
|
|
2665
|
+
if (relation.result === OVERLAP_NONE || relation.result === OVERLAP_LINK) {
|
|
2666
|
+
if (hole.offset < curHole.offset)
|
|
2667
|
+
// other hole is on the left side
|
|
2668
|
+
distArray.distLeft = Math.min(distArray.distLeft, pointsDistance(chsp.x, chsp.y, hep.x, hep.y));
|
|
2669
|
+
// other hole is on the right side
|
|
2670
|
+
else distArray.distRight = Math.min(distArray.distRight, pointsDistance(chep.x, chep.y, hsp.x, hsp.y));
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
});
|
|
2674
|
+
return distArray;
|
|
2675
|
+
}
|
|
2676
|
+
export function getSnappedWallLines(item, layer, catalog) {
|
|
2677
|
+
var _element;
|
|
2678
|
+
var snappedWallLines = [];
|
|
2679
|
+
if (isEmpty(item)) return snappedWallLines;
|
|
2680
|
+
var vertexLines = getAllLines(layer);
|
|
2681
|
+
var rectLines = buildRectFromLines(layer, vertexLines);
|
|
2682
|
+
var outline = null;
|
|
2683
|
+
var element = catalog.elements[item.get('type')];
|
|
2684
|
+
if (!element) element = catalog.elements[returnReplaceableDeepSearchType(item.get('type'))];
|
|
2685
|
+
var newWidth = item.properties.get('width').get('_length');
|
|
2686
|
+
var wUnit = item.properties.get('width').get('_unit') || 'cm';
|
|
2687
|
+
newWidth = convert(newWidth).from(wUnit).to('cm');
|
|
2688
|
+
var newDepth = item.properties.get('depth').get('_length');
|
|
2689
|
+
var hUnit = item.properties.get('depth').get('_unit') || 'cm';
|
|
2690
|
+
newDepth = convert(newDepth).from(hUnit).to('cm');
|
|
2691
|
+
var overlapList = [OVERLAP_INCLUDED, OVERLAP_SAME, OVERLAP_SOME];
|
|
2692
|
+
|
|
2693
|
+
// Get Outline Data of Selected Item
|
|
2694
|
+
outline = (_element = element) === null || _element === void 0 || (_element = _element.info) === null || _element === void 0 ? void 0 : _element.outline;
|
|
2695
|
+
if (outline) {
|
|
2696
|
+
// Extract Points from `outline`
|
|
2697
|
+
var outlinePaths = outline.paths;
|
|
2698
|
+
var outlineWidth = outline.svgWidth;
|
|
2699
|
+
var outlineHeight = outline.svgHeight;
|
|
2700
|
+
var outlinePoints = []; // Hold Points Of SVG
|
|
2701
|
+
var _iterator7 = _createForOfIteratorHelper(outlinePaths),
|
|
2702
|
+
_step7;
|
|
2703
|
+
try {
|
|
2704
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
2705
|
+
var path = _step7.value;
|
|
2706
|
+
var _iterator8 = _createForOfIteratorHelper(path.subPaths),
|
|
2707
|
+
_step8;
|
|
2708
|
+
try {
|
|
2709
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
2710
|
+
var subPath = _step8.value;
|
|
2711
|
+
outlinePoints = outlinePoints.concat(subPath.getPoints());
|
|
2712
|
+
}
|
|
2713
|
+
} catch (err) {
|
|
2714
|
+
_iterator8.e(err);
|
|
2715
|
+
} finally {
|
|
2716
|
+
_iterator8.f();
|
|
2717
|
+
}
|
|
2718
|
+
}
|
|
2719
|
+
} catch (err) {
|
|
2720
|
+
_iterator7.e(err);
|
|
2721
|
+
} finally {
|
|
2722
|
+
_iterator7.f();
|
|
2723
|
+
}
|
|
2724
|
+
outline.reverse && outlinePoints.reverse();
|
|
2725
|
+
for (var i = 0; i < outlinePoints.length - 1; i++) {
|
|
2726
|
+
var v0 = rotatePointAroundPoint((outlinePoints[i].x / outlineWidth - 0.5) * newWidth + item.x, (outlinePoints[i].y / outlineHeight - 0.5) * newDepth + item.y, item.x, item.y, item.rotation + 90);
|
|
2727
|
+
var v1 = rotatePointAroundPoint((outlinePoints[i + 1].x / outlineWidth - 0.5) * newWidth + item.x, (outlinePoints[i + 1].y / outlineHeight - 0.5) * newDepth + item.y, item.x, item.y, item.rotation + 90);
|
|
2728
|
+
var srcLine = {
|
|
2729
|
+
x1: v0.x,
|
|
2730
|
+
y1: v0.y,
|
|
2731
|
+
x2: v1.x,
|
|
2732
|
+
y2: v1.y
|
|
2733
|
+
};
|
|
2734
|
+
var _loop2 = function _loop2(j) {
|
|
2735
|
+
var destLine1 = {
|
|
2736
|
+
x1: rectLines[j].rect[2].x,
|
|
2737
|
+
y1: rectLines[j].rect[3].y,
|
|
2738
|
+
x2: v1.x,
|
|
2739
|
+
y2: v1.y
|
|
2740
|
+
};
|
|
2741
|
+
var destLine2 = {
|
|
2742
|
+
x1: rectLines[j].rect[0].x,
|
|
2743
|
+
y1: rectLines[j].rect[1].y,
|
|
2744
|
+
x2: v1.x,
|
|
2745
|
+
y2: v1.y
|
|
2746
|
+
};
|
|
2747
|
+
if (overlapList.includes(relationshipOfTwoOverlappedLines(srcLine, destLine1).result) || overlapList.includes(relationshipOfTwoOverlappedLines(srcLine, destLine2).result)) {
|
|
2748
|
+
var idx = snappedWallLines.findIndex(function (v) {
|
|
2749
|
+
return v.id === rectLines[j].lineId;
|
|
2750
|
+
});
|
|
2751
|
+
var snapSide = 'unknown';
|
|
2752
|
+
if (idx < 0) snappedWallLines.push({
|
|
2753
|
+
id: rectLines[j].lineId,
|
|
2754
|
+
snapSide: snapSide
|
|
2755
|
+
});else snappedWallLines[idx].snapSide = snapSide;
|
|
2756
|
+
}
|
|
2757
|
+
};
|
|
2758
|
+
for (var j = 0; j < (rectLines === null || rectLines === void 0 ? void 0 : rectLines.length); j++) {
|
|
2759
|
+
_loop2(j);
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2762
|
+
} else {
|
|
2763
|
+
var pos = [[-1, -1], [1, -1], [1, 1], [-1, 1]];
|
|
2764
|
+
for (var _i = 0; _i < 4; _i++) {
|
|
2765
|
+
var _v = rotatePointAroundPoint(pos[_i][0] * newWidth / 2 + item.x, pos[_i][1] * newDepth / 2 + item.y, item.x, item.y, item.rotation);
|
|
2766
|
+
var _v2 = rotatePointAroundPoint(pos[(_i + 1) % 4][0] * newWidth / 2 + item.x, pos[(_i + 1) % 4][1] * newDepth / 2 + item.y, item.x, item.y, item.rotation);
|
|
2767
|
+
var _srcLine = {
|
|
2768
|
+
x1: _v.x,
|
|
2769
|
+
y1: _v.y,
|
|
2770
|
+
x2: _v2.x,
|
|
2771
|
+
y2: _v2.y
|
|
2772
|
+
};
|
|
2773
|
+
var _loop3 = function _loop3(_j) {
|
|
2774
|
+
var destLine1 = {
|
|
2775
|
+
x1: rectLines[_j].rect[2].x,
|
|
2776
|
+
y1: rectLines[_j].rect[2].y,
|
|
2777
|
+
x2: rectLines[_j].rect[3].x,
|
|
2778
|
+
y2: rectLines[_j].rect[3].y
|
|
2779
|
+
};
|
|
2780
|
+
var destLine2 = {
|
|
2781
|
+
x1: rectLines[_j].rect[0].x,
|
|
2782
|
+
y1: rectLines[_j].rect[0].y,
|
|
2783
|
+
x2: rectLines[_j].rect[1].x,
|
|
2784
|
+
y2: rectLines[_j].rect[1].y
|
|
2785
|
+
};
|
|
2786
|
+
if (overlapList.includes(relationshipOfTwoOverlappedLines(_srcLine, destLine1).result) || overlapList.includes(relationshipOfTwoOverlappedLines(_srcLine, destLine2).result)) {
|
|
2787
|
+
var idx = snappedWallLines.findIndex(function (v) {
|
|
2788
|
+
return v.id === rectLines[_j].lineId;
|
|
2789
|
+
});
|
|
2790
|
+
var snapSide = _i === 0 || _i === 2 ? 'front' : 'side';
|
|
2791
|
+
if (idx < 0) snappedWallLines.push({
|
|
2792
|
+
id: rectLines[_j].lineId,
|
|
2793
|
+
snapSide: snapSide
|
|
2794
|
+
});else snappedWallLines[idx].snapSide = snapSide;
|
|
2795
|
+
}
|
|
2796
|
+
};
|
|
2797
|
+
for (var _j = 0; _j < (rectLines === null || rectLines === void 0 ? void 0 : rectLines.length); _j++) {
|
|
2798
|
+
_loop3(_j);
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
return snappedWallLines;
|
|
2609
2803
|
}
|
package/es/utils/history.js
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
import { Map } from 'immutable';
|
|
1
|
+
import { List, Map } from 'immutable';
|
|
2
2
|
import diff from 'immutablediff';
|
|
3
3
|
import patch from 'immutablepatch';
|
|
4
4
|
export var historyPush = function historyPush(historyStructure, item) {
|
|
5
5
|
if (historyStructure.last) {
|
|
6
6
|
if (historyStructure.last.hashCode() !== item.hashCode()) {
|
|
7
|
+
var _toPush$get;
|
|
7
8
|
var toPush = new Map({
|
|
8
9
|
time: Date.now(),
|
|
9
10
|
diff: diff(historyStructure.last, item)
|
|
10
11
|
});
|
|
12
|
+
|
|
13
|
+
// convert map to object of the [value] field
|
|
14
|
+
if (List.isList(toPush.get('diff')) && ((_toPush$get = toPush.get('diff')) === null || _toPush$get === void 0 ? void 0 : _toPush$get.size) > 1) {
|
|
15
|
+
for (var i = 0; i < toPush.get('diff').size; i++) {
|
|
16
|
+
var mapValue = toPush.get('diff').get(i).get('value');
|
|
17
|
+
if (Map.isMap(mapValue)) {
|
|
18
|
+
var jsValue = mapValue.toJS();
|
|
19
|
+
toPush = toPush.setIn(['diff', i, 'value'], jsValue);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
11
23
|
historyStructure = historyStructure.set('last', item).set('list', historyStructure.list.push(toPush));
|
|
12
24
|
}
|
|
13
25
|
} else {
|