@threekit-tools/treble 0.0.90 → 0.0.91-next-02
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/dist/Treble/Treble.d.ts +2 -2
- package/dist/Treble/Treble.js +3 -3
- package/dist/Treble/index.d.ts +1 -1
- package/dist/Treble/index.js +1 -1
- package/dist/Treble/{snapshots.d.ts → snapshot.d.ts} +1 -1
- package/dist/Treble/{snapshots.js → snapshot.js} +1 -1
- package/dist/Treble/wishlist.d.ts +1 -1
- package/dist/Treble/wishlist.js +1 -1
- package/dist/api/catalog.js +1 -1
- package/dist/api/configurations.js +1 -1
- package/dist/api/datatables.js +1 -1
- package/dist/api/orders.js +1 -1
- package/dist/api/price.js +1 -1
- package/dist/api/products.d.ts +2 -2
- package/dist/api/products.js +1 -1
- package/dist/components/BreatheAnimation/index.js +3 -3
- package/dist/components/Button/index.d.ts +2 -2
- package/dist/components/DraggableHint/draggableIndicator.styles.d.ts +1 -1
- package/dist/components/PlayerLoadingSpinner/playerLoadingSpinner.styles.d.ts +1 -1
- package/dist/components/Share/index.js +1 -1
- package/dist/components/Share/share.styles.d.ts +1 -1
- package/dist/components/TurntableAnimation/index.js +3 -3
- package/dist/components/Upload/index.js +1 -1
- package/dist/components/UploadArea/index.js +1 -1
- package/dist/components/Wishlist/index.js +1 -1
- package/dist/components/containers/formInputContainer.js +3 -3
- package/dist/connection.js +1 -1
- package/dist/hooks/useAttribute/index.d.ts +4 -4
- package/dist/hooks/useAttribute/index.js +1 -1
- package/dist/hooks/useConfigurationChangeStatus/index.d.ts +2 -0
- package/dist/hooks/{usePlayerLoadingStatus → useConfigurationChangeStatus}/index.js +2 -2
- package/dist/hooks/useConfigurationLoader/index.js +1 -1
- package/dist/hooks/useConfigurator/index.d.ts +3 -3
- package/dist/hooks/useDevTools/index.d.ts +1 -1
- package/dist/hooks/useNestedConfigurator/index.d.ts +2 -2
- package/dist/hooks/useNestedConfigurator/index.js +2 -3
- package/dist/hooks/usePlayer/index.d.ts +1 -1
- package/dist/hooks/usePlayerPortal/index.d.ts +1 -1
- package/dist/hooks/usePlayerReady/index.d.ts +2 -0
- package/dist/hooks/{useAnimationStart → usePlayerReady}/index.js +2 -2
- package/dist/hooks/useProductCache/index.js +1 -1
- package/dist/hooks/useResetProduct/index.d.ts +1 -1
- package/dist/hooks/useResetProduct/index.js +1 -1
- package/dist/hooks/useShare/index.d.ts +1 -1
- package/dist/hooks/useShare/index.js +1 -1
- package/dist/hooks/useSingleAnimation/index.js +1 -1
- package/dist/hooks/useSpaces/SpacesLayout.d.ts +11 -0
- package/dist/hooks/useSpaces/SpacesLayout.js +74 -0
- package/dist/hooks/useSpaces/SpacesState.d.ts +164 -0
- package/dist/hooks/useSpaces/SpacesState.js +1751 -0
- package/dist/hooks/useSpaces/constants.d.ts +64 -0
- package/dist/hooks/useSpaces/constants.js +109 -0
- package/dist/hooks/{useRoomBuilder → useSpaces}/dataHandlers.d.ts +6 -4
- package/dist/hooks/useSpaces/dataHandlers.js +254 -0
- package/dist/hooks/useSpaces/draw/clearCanvas.d.ts +2 -0
- package/dist/hooks/useSpaces/draw/clearCanvas.js +9 -0
- package/dist/hooks/useSpaces/draw/drawBackground.d.ts +2 -0
- package/dist/hooks/useSpaces/draw/drawBackground.js +12 -0
- package/dist/hooks/useSpaces/draw/drawDimensions.d.ts +3 -0
- package/dist/hooks/useSpaces/draw/drawDimensions.js +53 -0
- package/dist/hooks/useSpaces/draw/drawDoors.d.ts +9 -0
- package/dist/hooks/useSpaces/draw/drawDoors.js +99 -0
- package/dist/hooks/useSpaces/draw/drawFloor.d.ts +3 -0
- package/dist/hooks/useSpaces/draw/drawFloor.js +36 -0
- package/dist/hooks/useSpaces/draw/drawGrid.d.ts +3 -0
- package/dist/hooks/useSpaces/draw/drawGrid.js +33 -0
- package/dist/hooks/useSpaces/draw/drawGuides.d.ts +3 -0
- package/dist/hooks/useSpaces/draw/drawGuides.js +23 -0
- package/dist/hooks/useSpaces/draw/drawOpenings.d.ts +9 -0
- package/dist/hooks/useSpaces/draw/drawOpenings.js +72 -0
- package/dist/hooks/useSpaces/draw/drawVertices.d.ts +8 -0
- package/dist/hooks/useSpaces/draw/drawVertices.js +61 -0
- package/dist/hooks/useSpaces/draw/drawWalls.d.ts +10 -0
- package/dist/hooks/useSpaces/draw/drawWalls.js +88 -0
- package/dist/hooks/useSpaces/draw/drawWindows.d.ts +9 -0
- package/dist/hooks/useSpaces/draw/drawWindows.js +82 -0
- package/dist/hooks/useSpaces/draw/index.d.ts +11 -0
- package/dist/hooks/useSpaces/draw/index.js +129 -0
- package/dist/hooks/useSpaces/geometry/addThicknessToLine.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/addThicknessToLine.js +13 -0
- package/dist/hooks/useSpaces/geometry/areLinesEqual.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/areLinesEqual.js +17 -0
- package/dist/hooks/useSpaces/geometry/arePointsEqual.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/arePointsEqual.js +8 -0
- package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.js +11 -0
- package/dist/hooks/useSpaces/geometry/closestPointOnLine.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/closestPointOnLine.js +13 -0
- package/dist/hooks/useSpaces/geometry/doLinesOverlap.d.ts +2 -0
- package/dist/hooks/useSpaces/geometry/doLinesOverlap.js +16 -0
- package/dist/hooks/useSpaces/geometry/euclideanMod.d.ts +2 -0
- package/dist/hooks/useSpaces/geometry/euclideanMod.js +6 -0
- package/dist/hooks/useSpaces/geometry/findLoops.d.ts +6 -0
- package/dist/hooks/{useRoomBuilder → useSpaces/geometry}/findLoops.js +31 -13
- package/dist/hooks/useSpaces/geometry/getAllLineIntersections.d.ts +6 -0
- package/dist/hooks/useSpaces/geometry/getAllLineIntersections.js +23 -0
- package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.js +7 -0
- package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.js +17 -0
- package/dist/hooks/useSpaces/geometry/getDistanceToLine.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getDistanceToLine.js +10 -0
- package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.js +7 -0
- package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.js +17 -0
- package/dist/hooks/useSpaces/geometry/getLineOtherPoint.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getLineOtherPoint.js +11 -0
- package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.js +43 -0
- package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.js +9 -0
- package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.js +20 -0
- package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.js +11 -0
- package/dist/hooks/useSpaces/geometry/getPolygonArea.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getPolygonArea.js +15 -0
- package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.js +16 -0
- package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.d.ts +6 -0
- package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.js +17 -0
- package/dist/hooks/useSpaces/geometry/getTriangleArea.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getTriangleArea.js +9 -0
- package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.js +12 -0
- package/dist/hooks/useSpaces/geometry/index.d.ts +30 -0
- package/dist/hooks/useSpaces/geometry/index.js +64 -0
- package/dist/hooks/useSpaces/geometry/isPointInPolygon.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/isPointInPolygon.js +21 -0
- package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.js +25 -0
- package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.js +11 -0
- package/dist/hooks/useSpaces/geometry/splitLineAtOffset.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/splitLineAtOffset.js +12 -0
- package/dist/hooks/useSpaces/geometry/splitLineAtPoint.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/splitLineAtPoint.js +9 -0
- package/dist/hooks/useSpaces/geometry/splitLineAtPoints.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/splitLineAtPoints.js +28 -0
- package/dist/hooks/useSpaces/index.d.ts +76 -0
- package/dist/hooks/useSpaces/index.js +475 -0
- package/dist/hooks/useSpaces/themes/blueprint.d.ts +3 -0
- package/dist/hooks/useSpaces/themes/blueprint.js +96 -0
- package/dist/hooks/useSpaces/themes/default.d.ts +3 -0
- package/dist/hooks/useSpaces/themes/default.js +96 -0
- package/dist/hooks/{useRoomBuilder/themes.d.ts → useSpaces/themes/index.d.ts} +3 -4
- package/dist/hooks/useSpaces/themes/index.js +21 -0
- package/dist/hooks/useSpaces/themes/light.d.ts +3 -0
- package/dist/hooks/useSpaces/themes/light.js +96 -0
- package/dist/hooks/useSpaces/types.d.ts +334 -0
- package/dist/hooks/{useRoomBuilder → useSpaces}/types.js +13 -1
- package/dist/hooks/useSpaces/validators/areWallsDuplicated.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/areWallsDuplicated.js +61 -0
- package/dist/hooks/useSpaces/validators/areWallsIntersecting.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/areWallsIntersecting.js +42 -0
- package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.js +52 -0
- package/dist/hooks/useSpaces/validators/areWallsTooShort.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/areWallsTooShort.js +37 -0
- package/dist/hooks/useSpaces/validators/index.d.ts +15 -0
- package/dist/hooks/useSpaces/validators/index.js +40 -0
- package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.js +31 -0
- package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.js +19 -0
- package/dist/hooks/useSpaces/validators/isLineTooShort.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isLineTooShort.js +26 -0
- package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.d.ts +4 -0
- package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.js +19 -0
- package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.js +19 -0
- package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.js +41 -0
- package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.js +54 -0
- package/dist/hooks/useSpaces/validators/isWallTooShort.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isWallTooShort.js +10 -0
- package/dist/hooks/{useRoomBuilder → useSpaces/validators}/messaging.js +1 -1
- package/dist/hooks/useWishlist/index.d.ts +1 -1
- package/dist/hooks/useZoom/index.d.ts +1 -1
- package/dist/http/orders.d.ts +1 -1
- package/dist/icons/AngleSnapping.d.ts +3 -0
- package/dist/icons/AngleSnapping.js +28 -0
- package/dist/icons/Center.d.ts +3 -0
- package/dist/icons/Center.js +24 -0
- package/dist/icons/Draw.js +3 -3
- package/dist/icons/GridSnapping.d.ts +3 -0
- package/dist/icons/GridSnapping.js +28 -0
- package/dist/icons/LayoutAlt.d.ts +3 -0
- package/dist/icons/LayoutAlt.js +21 -0
- package/dist/icons/Magnet.d.ts +3 -0
- package/dist/icons/Magnet.js +27 -0
- package/dist/icons/Player3D.d.ts +3 -0
- package/dist/icons/Player3D.js +21 -0
- package/dist/icons/Save.d.ts +3 -0
- package/dist/icons/Save.js +21 -0
- package/dist/icons/UnitCm.d.ts +3 -0
- package/dist/icons/UnitCm.js +22 -0
- package/dist/icons/UnitFeet.d.ts +3 -0
- package/dist/icons/UnitFeet.js +22 -0
- package/dist/icons/UnitInch.d.ts +3 -0
- package/dist/icons/UnitInch.js +22 -0
- package/dist/icons/UnitMeter.d.ts +3 -0
- package/dist/icons/UnitMeter.js +21 -0
- package/dist/icons/Window.js +4 -4
- package/dist/icons/index.js +22 -0
- package/dist/icons/types.d.ts +1 -1
- package/dist/index.d.ts +17 -3
- package/dist/index.js +35 -7
- package/dist/store/attributes.d.ts +3 -2
- package/dist/store/attributes.js +1 -1
- package/dist/store/index.d.ts +15 -8
- package/dist/store/index.js +3 -1
- package/dist/store/price.js +1 -1
- package/dist/store/product.d.ts +1 -1
- package/dist/store/product.js +5 -8
- package/dist/store/spaces.d.ts +47 -0
- package/dist/store/spaces.js +197 -0
- package/dist/store/translations.js +1 -1
- package/dist/store/treble.d.ts +1 -1
- package/dist/store/treble.js +27 -27
- package/dist/store/wishlist.d.ts +21 -3
- package/dist/store/wishlist.js +1 -1
- package/dist/types.d.ts +25 -17
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/hooks/useAnimationStart/index.d.ts +0 -2
- package/dist/hooks/usePlayerLoadingStatus/index.d.ts +0 -2
- package/dist/hooks/useRoomBuilder/RoomBuilderState.d.ts +0 -95
- package/dist/hooks/useRoomBuilder/RoomBuilderState.js +0 -1237
- package/dist/hooks/useRoomBuilder/constants.d.ts +0 -41
- package/dist/hooks/useRoomBuilder/constants.js +0 -48
- package/dist/hooks/useRoomBuilder/dataHandlers.js +0 -187
- package/dist/hooks/useRoomBuilder/draw.d.ts +0 -55
- package/dist/hooks/useRoomBuilder/draw.js +0 -573
- package/dist/hooks/useRoomBuilder/findLoops.d.ts +0 -5
- package/dist/hooks/useRoomBuilder/geometry.d.ts +0 -33
- package/dist/hooks/useRoomBuilder/geometry.js +0 -325
- package/dist/hooks/useRoomBuilder/index.d.ts +0 -40
- package/dist/hooks/useRoomBuilder/index.js +0 -303
- package/dist/hooks/useRoomBuilder/themes.js +0 -273
- package/dist/hooks/useRoomBuilder/types.d.ts +0 -238
- package/dist/hooks/useRoomBuilder/validators.d.ts +0 -36
- package/dist/hooks/useRoomBuilder/validators.js +0 -362
- /package/dist/hooks/{useRoomBuilder → useSpaces/validators}/messaging.d.ts +0 -0
|
@@ -0,0 +1,1751 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
58
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
+
exports.SpacesState = void 0;
|
|
60
|
+
var types_1 = require("./types");
|
|
61
|
+
var validators_1 = require("./validators");
|
|
62
|
+
var geometry_1 = require("./geometry");
|
|
63
|
+
var draw_1 = require("./draw");
|
|
64
|
+
var dataHandlers_1 = require("./dataHandlers");
|
|
65
|
+
var __1 = require("../..");
|
|
66
|
+
var constants_1 = require("./constants");
|
|
67
|
+
var SpacesState = (function () {
|
|
68
|
+
function SpacesState(config) {
|
|
69
|
+
var _a;
|
|
70
|
+
var _this = this;
|
|
71
|
+
this.moveActiveVertex = function (canvas, point) {
|
|
72
|
+
var _a, _b, _c, _d;
|
|
73
|
+
if (!canvas)
|
|
74
|
+
return;
|
|
75
|
+
if (((_a = _this._activeElement) === null || _a === void 0 ? void 0 : _a.type) !== types_1.IElements.VERTEX)
|
|
76
|
+
return;
|
|
77
|
+
var snapPoint = _this.getSnapPointToElementInProximity(point);
|
|
78
|
+
snapPoint = _this.getSnapActiveVertexToGuideInProximity(snapPoint);
|
|
79
|
+
snapPoint = _this.getSnapPointToGridInProximity(snapPoint);
|
|
80
|
+
if (snapPoint.type === types_1.SNAPPING_TYPES.GUIDE ||
|
|
81
|
+
snapPoint.type === types_1.SNAPPING_TYPES.GRID)
|
|
82
|
+
_this.guides = snapPoint;
|
|
83
|
+
else if (_this.guides)
|
|
84
|
+
_this.guides = null;
|
|
85
|
+
var vertex = _this.getVertex(_this._activeElement.index);
|
|
86
|
+
if (!vertex)
|
|
87
|
+
return;
|
|
88
|
+
var validationData = {
|
|
89
|
+
vertex: vertex,
|
|
90
|
+
updatedPosition: snapPoint,
|
|
91
|
+
};
|
|
92
|
+
_this._errorElement = _this.runValidators([
|
|
93
|
+
validators_1.isVertexLandingOnFeature,
|
|
94
|
+
validators_1.areWallsTooShort,
|
|
95
|
+
validators_1.areWallsIntersecting,
|
|
96
|
+
validators_1.areWallsOrphaningFeatures,
|
|
97
|
+
validators_1.areWallsDuplicated,
|
|
98
|
+
], validationData);
|
|
99
|
+
var errorType = ((_b = _this._errorElement) === null || _b === void 0 ? void 0 : _b[0].type) || null;
|
|
100
|
+
switch (errorType) {
|
|
101
|
+
case types_1.IErrorTypes.HARD:
|
|
102
|
+
return;
|
|
103
|
+
case types_1.IErrorTypes.SOFT:
|
|
104
|
+
case types_1.IErrorTypes.WARN:
|
|
105
|
+
case null:
|
|
106
|
+
default:
|
|
107
|
+
_this._activeElement.snapPoint = snapPoint;
|
|
108
|
+
_this.repositionVertex(_this._activeElement.index, (_c = snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.point) !== null && _c !== void 0 ? _c : point);
|
|
109
|
+
_this.drawSpaces(canvas);
|
|
110
|
+
(0, draw_1.drawVertex)(canvas, _this.transformPointToCanvas((_d = snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.point) !== null && _d !== void 0 ? _d : point), _this.styles.vertex, types_1.IElementStyleModes.HIGHLIGHT);
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
this.finishMoveActiveVertex = function () {
|
|
115
|
+
var _a, _b;
|
|
116
|
+
if (((_a = _this._activeElement) === null || _a === void 0 ? void 0 : _a.type) !== types_1.IElements.VERTEX)
|
|
117
|
+
return;
|
|
118
|
+
if (((_b = _this._activeElement.snapPoint) === null || _b === void 0 ? void 0 : _b.type) === types_1.IElements.WALL)
|
|
119
|
+
_this.splitWallAtPoint(_this._activeElement.snapPoint.index, _this._activeElement.snapPoint.point);
|
|
120
|
+
_this.guides = null;
|
|
121
|
+
_this.pushStateToConfigurator();
|
|
122
|
+
};
|
|
123
|
+
this.moveActiveFeature = function (canvas, moveToPoint) {
|
|
124
|
+
var _a, _b;
|
|
125
|
+
if (_this._activeElement === null)
|
|
126
|
+
return;
|
|
127
|
+
var _c = _this._activeElement, type = _c.type, index = _c.index;
|
|
128
|
+
if (type !== types_1.IElements.WINDOW &&
|
|
129
|
+
type !== types_1.IElements.DOOR &&
|
|
130
|
+
type !== types_1.IElements.OPENING)
|
|
131
|
+
return;
|
|
132
|
+
var feature = _this.getFeature(type, index);
|
|
133
|
+
if (!feature)
|
|
134
|
+
return;
|
|
135
|
+
var wallIndex = (_a = _this.getWallIndexInProximity(moveToPoint)) !== null && _a !== void 0 ? _a : feature.connectedTo[1];
|
|
136
|
+
var wall = _this.getWall(wallIndex);
|
|
137
|
+
if (!wall)
|
|
138
|
+
return;
|
|
139
|
+
var intersection = (0, geometry_1.getTangetIntersectionAndOffset)(wall.line, moveToPoint);
|
|
140
|
+
if (!intersection)
|
|
141
|
+
return;
|
|
142
|
+
var padding = _this.validationConfig.padding;
|
|
143
|
+
var minOffset = padding;
|
|
144
|
+
var maxOffset = (0, geometry_1.getLengthOfLineSegment)(wall.line) - (padding + feature.length);
|
|
145
|
+
var newOffset = intersection.offset - feature.length / 2;
|
|
146
|
+
if (newOffset < minOffset)
|
|
147
|
+
newOffset = minOffset;
|
|
148
|
+
else if (newOffset > maxOffset)
|
|
149
|
+
newOffset = maxOffset;
|
|
150
|
+
var validationData = {
|
|
151
|
+
wall: wall,
|
|
152
|
+
updatedFeature: {
|
|
153
|
+
length: feature.length,
|
|
154
|
+
offset: newOffset,
|
|
155
|
+
address: { type: type, index: index },
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
_this._errorElement = _this.runValidators([validators_1.isFeatureCollidingWithExistingFeature], validationData);
|
|
159
|
+
var errorType = ((_b = _this._errorElement) === null || _b === void 0 ? void 0 : _b[0].type) || null;
|
|
160
|
+
switch (errorType) {
|
|
161
|
+
case types_1.IErrorTypes.HARD:
|
|
162
|
+
return;
|
|
163
|
+
case types_1.IErrorTypes.SOFT:
|
|
164
|
+
_this.drawSpaces(canvas);
|
|
165
|
+
break;
|
|
166
|
+
case types_1.IErrorTypes.WARN:
|
|
167
|
+
case null:
|
|
168
|
+
default:
|
|
169
|
+
_this.repositionFeature([type, index], newOffset, wallIndex);
|
|
170
|
+
_this.drawSpaces(canvas);
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
this.finishMoveActiveFeature = function () {
|
|
175
|
+
var _a;
|
|
176
|
+
var type = (_a = _this._activeElement) === null || _a === void 0 ? void 0 : _a.type;
|
|
177
|
+
if (!type)
|
|
178
|
+
return;
|
|
179
|
+
if (type !== types_1.IElements.WINDOW &&
|
|
180
|
+
type !== types_1.IElements.DOOR &&
|
|
181
|
+
type !== types_1.IElements.OPENING)
|
|
182
|
+
return;
|
|
183
|
+
_this.pushStateToConfigurator();
|
|
184
|
+
};
|
|
185
|
+
this._config = config;
|
|
186
|
+
this._newWall = null;
|
|
187
|
+
this._activeElement = null;
|
|
188
|
+
this._selectedElement = null;
|
|
189
|
+
this._highlightedElement = null;
|
|
190
|
+
this._errorElement = null;
|
|
191
|
+
this._attributeDefaults = {};
|
|
192
|
+
this._state = (_a = {},
|
|
193
|
+
_a[types_1.IElements.WALL] = [],
|
|
194
|
+
_a[types_1.IElements.VERTEX] = {},
|
|
195
|
+
_a[types_1.IElements.FEATURE] = {},
|
|
196
|
+
_a);
|
|
197
|
+
this._showDimensions = true;
|
|
198
|
+
this._angleSnappingEnabled = true;
|
|
199
|
+
this._guideSnappingEnabled = !config.config.disableGuides;
|
|
200
|
+
this._guides = null;
|
|
201
|
+
this._attributesState = null;
|
|
202
|
+
this._canvasDimensions = [0, 0];
|
|
203
|
+
this._zoom = config.config.zoomDefault;
|
|
204
|
+
this._zoomLimits = [constants_1.ZOOM_MIN, constants_1.ZOOM_MAX];
|
|
205
|
+
this._translate = config.config.translateDefault;
|
|
206
|
+
this._translateLimits = [constants_1.TRANSLATE_MIN, constants_1.TRANSLATE_MAX];
|
|
207
|
+
}
|
|
208
|
+
Object.defineProperty(SpacesState.prototype, "styles", {
|
|
209
|
+
get: function () {
|
|
210
|
+
return this._config.config.styles;
|
|
211
|
+
},
|
|
212
|
+
enumerable: false,
|
|
213
|
+
configurable: true
|
|
214
|
+
});
|
|
215
|
+
Object.defineProperty(SpacesState.prototype, "attributeDefaults", {
|
|
216
|
+
get: function () {
|
|
217
|
+
return this._attributeDefaults;
|
|
218
|
+
},
|
|
219
|
+
set: function (val) {
|
|
220
|
+
this._attributeDefaults = val;
|
|
221
|
+
},
|
|
222
|
+
enumerable: false,
|
|
223
|
+
configurable: true
|
|
224
|
+
});
|
|
225
|
+
Object.defineProperty(SpacesState.prototype, "scale", {
|
|
226
|
+
get: function () {
|
|
227
|
+
return this._config.config.scale;
|
|
228
|
+
},
|
|
229
|
+
enumerable: false,
|
|
230
|
+
configurable: true
|
|
231
|
+
});
|
|
232
|
+
Object.defineProperty(SpacesState.prototype, "snapProximity", {
|
|
233
|
+
get: function () {
|
|
234
|
+
return this.transformLengthFromCanvas(this._config.config.snapProximity);
|
|
235
|
+
},
|
|
236
|
+
enumerable: false,
|
|
237
|
+
configurable: true
|
|
238
|
+
});
|
|
239
|
+
Object.defineProperty(SpacesState.prototype, "gridUnitLength", {
|
|
240
|
+
get: function () {
|
|
241
|
+
var length = [types_1.IUnits.FEET, types_1.IUnits.INCH].includes(this.unit)
|
|
242
|
+
? (0, dataHandlers_1.convertLengthUnit)(1, types_1.IUnits.FEET, types_1.IUnits.METER)
|
|
243
|
+
: 1;
|
|
244
|
+
return length / this.scale;
|
|
245
|
+
},
|
|
246
|
+
enumerable: false,
|
|
247
|
+
configurable: true
|
|
248
|
+
});
|
|
249
|
+
Object.defineProperty(SpacesState.prototype, "gridUnitLengthToDraw", {
|
|
250
|
+
get: function () {
|
|
251
|
+
return this.transformLengthToCanvas(this.gridUnitLength);
|
|
252
|
+
},
|
|
253
|
+
enumerable: false,
|
|
254
|
+
configurable: true
|
|
255
|
+
});
|
|
256
|
+
Object.defineProperty(SpacesState.prototype, "gridOffset", {
|
|
257
|
+
get: function () {
|
|
258
|
+
var gridLength = this.gridUnitLengthToDraw;
|
|
259
|
+
var translate = this.transformPointToCanvas([0, 0]);
|
|
260
|
+
return [
|
|
261
|
+
((translate[0] % gridLength) + gridLength) % gridLength,
|
|
262
|
+
((translate[1] % gridLength) + gridLength) % gridLength,
|
|
263
|
+
];
|
|
264
|
+
},
|
|
265
|
+
enumerable: false,
|
|
266
|
+
configurable: true
|
|
267
|
+
});
|
|
268
|
+
Object.defineProperty(SpacesState.prototype, "gridToDraw", {
|
|
269
|
+
get: function () {
|
|
270
|
+
var unitLength = this.gridUnitLengthToDraw;
|
|
271
|
+
var subdivisions = [types_1.IUnits.FEET, types_1.IUnits.INCH].includes(this.unit) ? 4 : 5;
|
|
272
|
+
return {
|
|
273
|
+
unitLength: unitLength,
|
|
274
|
+
offset: this.gridOffset,
|
|
275
|
+
subdivisions: subdivisions,
|
|
276
|
+
showSubdivisions: this.styles.grid.showSubdivisions &&
|
|
277
|
+
unitLength / subdivisions > this.styles.grid.subdivisionThreshold,
|
|
278
|
+
};
|
|
279
|
+
},
|
|
280
|
+
enumerable: false,
|
|
281
|
+
configurable: true
|
|
282
|
+
});
|
|
283
|
+
Object.defineProperty(SpacesState.prototype, "walls", {
|
|
284
|
+
get: function () {
|
|
285
|
+
return this._state[types_1.IElements.WALL];
|
|
286
|
+
},
|
|
287
|
+
set: function (walls) {
|
|
288
|
+
this._state[types_1.IElements.WALL] = walls;
|
|
289
|
+
},
|
|
290
|
+
enumerable: false,
|
|
291
|
+
configurable: true
|
|
292
|
+
});
|
|
293
|
+
Object.defineProperty(SpacesState.prototype, "wallsToDraw", {
|
|
294
|
+
get: function () {
|
|
295
|
+
var _this = this;
|
|
296
|
+
return this._state[types_1.IElements.WALL].map(function (wall) { return (__assign(__assign({}, wall), { line: _this.transformLineToCanvas(wall.line), path: undefined })); });
|
|
297
|
+
},
|
|
298
|
+
enumerable: false,
|
|
299
|
+
configurable: true
|
|
300
|
+
});
|
|
301
|
+
Object.defineProperty(SpacesState.prototype, "wallCount", {
|
|
302
|
+
get: function () {
|
|
303
|
+
return this.walls.length;
|
|
304
|
+
},
|
|
305
|
+
enumerable: false,
|
|
306
|
+
configurable: true
|
|
307
|
+
});
|
|
308
|
+
Object.defineProperty(SpacesState.prototype, "wallLines", {
|
|
309
|
+
get: function () {
|
|
310
|
+
return this.walls.map(function (_a) {
|
|
311
|
+
var line = _a.line;
|
|
312
|
+
return line;
|
|
313
|
+
});
|
|
314
|
+
},
|
|
315
|
+
enumerable: false,
|
|
316
|
+
configurable: true
|
|
317
|
+
});
|
|
318
|
+
Object.defineProperty(SpacesState.prototype, "vertices", {
|
|
319
|
+
get: function () {
|
|
320
|
+
return this._state[types_1.IElements.VERTEX];
|
|
321
|
+
},
|
|
322
|
+
set: function (vertices) {
|
|
323
|
+
this._state[types_1.IElements.VERTEX] = vertices;
|
|
324
|
+
},
|
|
325
|
+
enumerable: false,
|
|
326
|
+
configurable: true
|
|
327
|
+
});
|
|
328
|
+
Object.defineProperty(SpacesState.prototype, "verticesToDraw", {
|
|
329
|
+
get: function () {
|
|
330
|
+
return this._state[types_1.IElements.VERTEX];
|
|
331
|
+
},
|
|
332
|
+
enumerable: false,
|
|
333
|
+
configurable: true
|
|
334
|
+
});
|
|
335
|
+
Object.defineProperty(SpacesState.prototype, "verticesList", {
|
|
336
|
+
get: function () {
|
|
337
|
+
return Object.entries(this.vertices).map(function (_a) {
|
|
338
|
+
var pointStr = _a[0], connections = _a[1];
|
|
339
|
+
return ({
|
|
340
|
+
point: JSON.parse(pointStr),
|
|
341
|
+
connections: connections,
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
},
|
|
345
|
+
enumerable: false,
|
|
346
|
+
configurable: true
|
|
347
|
+
});
|
|
348
|
+
Object.defineProperty(SpacesState.prototype, "verticesListToDraw", {
|
|
349
|
+
get: function () {
|
|
350
|
+
var _this = this;
|
|
351
|
+
return this.verticesList.map(function (vertex) { return (__assign(__assign({}, vertex), { point: _this.transformPointToCanvas(vertex.point) })); });
|
|
352
|
+
},
|
|
353
|
+
enumerable: false,
|
|
354
|
+
configurable: true
|
|
355
|
+
});
|
|
356
|
+
Object.defineProperty(SpacesState.prototype, "features", {
|
|
357
|
+
get: function () {
|
|
358
|
+
return this._state[types_1.IElements.FEATURE];
|
|
359
|
+
},
|
|
360
|
+
set: function (features) {
|
|
361
|
+
this._state[types_1.IElements.FEATURE] = features;
|
|
362
|
+
},
|
|
363
|
+
enumerable: false,
|
|
364
|
+
configurable: true
|
|
365
|
+
});
|
|
366
|
+
Object.defineProperty(SpacesState.prototype, "featuresToDraw", {
|
|
367
|
+
get: function () {
|
|
368
|
+
var _this = this;
|
|
369
|
+
return Object.entries(this.features).reduce(function (output, _a) {
|
|
370
|
+
var _b;
|
|
371
|
+
var type = _a[0], featureArr = _a[1];
|
|
372
|
+
return Object.assign(output, (_b = {},
|
|
373
|
+
_b[type] = featureArr.map(function (feature) { return (__assign(__assign({}, feature), { path: undefined, offset: _this.transformLengthToCanvas(feature.offset), length: _this.transformLengthToCanvas(feature.length) })); }),
|
|
374
|
+
_b));
|
|
375
|
+
}, {});
|
|
376
|
+
},
|
|
377
|
+
enumerable: false,
|
|
378
|
+
configurable: true
|
|
379
|
+
});
|
|
380
|
+
Object.defineProperty(SpacesState.prototype, "getHydratedFeatures", {
|
|
381
|
+
get: function () {
|
|
382
|
+
var _this = this;
|
|
383
|
+
return Object.entries(this.features).reduce(function (output, _a) {
|
|
384
|
+
var _b;
|
|
385
|
+
var type = _a[0], featureArr = _a[1];
|
|
386
|
+
return Object.assign(output, (_b = {},
|
|
387
|
+
_b[type] = featureArr.map(function (feature) {
|
|
388
|
+
var wall = _this.getWall(feature.connectedTo[1]);
|
|
389
|
+
if (!wall)
|
|
390
|
+
return;
|
|
391
|
+
var line = (0, geometry_1.getLineAtOffsetOnLineSegment)(wall.line, feature.offset, feature.length);
|
|
392
|
+
return __assign(__assign({}, feature), { line: line });
|
|
393
|
+
}),
|
|
394
|
+
_b));
|
|
395
|
+
}, {});
|
|
396
|
+
},
|
|
397
|
+
enumerable: false,
|
|
398
|
+
configurable: true
|
|
399
|
+
});
|
|
400
|
+
Object.defineProperty(SpacesState.prototype, "featureCount", {
|
|
401
|
+
get: function () {
|
|
402
|
+
return Object.values(this.features).flat().length;
|
|
403
|
+
},
|
|
404
|
+
enumerable: false,
|
|
405
|
+
configurable: true
|
|
406
|
+
});
|
|
407
|
+
Object.defineProperty(SpacesState.prototype, "activeElement", {
|
|
408
|
+
get: function () {
|
|
409
|
+
return this._activeElement;
|
|
410
|
+
},
|
|
411
|
+
enumerable: false,
|
|
412
|
+
configurable: true
|
|
413
|
+
});
|
|
414
|
+
Object.defineProperty(SpacesState.prototype, "selectedElement", {
|
|
415
|
+
get: function () {
|
|
416
|
+
return this._selectedElement;
|
|
417
|
+
},
|
|
418
|
+
set: function (element) {
|
|
419
|
+
this._selectedElement = element;
|
|
420
|
+
},
|
|
421
|
+
enumerable: false,
|
|
422
|
+
configurable: true
|
|
423
|
+
});
|
|
424
|
+
Object.defineProperty(SpacesState.prototype, "showDimensions", {
|
|
425
|
+
get: function () {
|
|
426
|
+
return this._showDimensions;
|
|
427
|
+
},
|
|
428
|
+
set: function (val) {
|
|
429
|
+
this._showDimensions = val;
|
|
430
|
+
},
|
|
431
|
+
enumerable: false,
|
|
432
|
+
configurable: true
|
|
433
|
+
});
|
|
434
|
+
Object.defineProperty(SpacesState.prototype, "angleSnappingEnabled", {
|
|
435
|
+
get: function () {
|
|
436
|
+
return this._angleSnappingEnabled;
|
|
437
|
+
},
|
|
438
|
+
set: function (val) {
|
|
439
|
+
this._angleSnappingEnabled = val;
|
|
440
|
+
},
|
|
441
|
+
enumerable: false,
|
|
442
|
+
configurable: true
|
|
443
|
+
});
|
|
444
|
+
Object.defineProperty(SpacesState.prototype, "guideSnappingEnabled", {
|
|
445
|
+
get: function () {
|
|
446
|
+
return this._guideSnappingEnabled;
|
|
447
|
+
},
|
|
448
|
+
set: function (val) {
|
|
449
|
+
this._guideSnappingEnabled = val;
|
|
450
|
+
},
|
|
451
|
+
enumerable: false,
|
|
452
|
+
configurable: true
|
|
453
|
+
});
|
|
454
|
+
Object.defineProperty(SpacesState.prototype, "gridSnappingEnabled", {
|
|
455
|
+
get: function () {
|
|
456
|
+
return this._gridSnappingEnabled;
|
|
457
|
+
},
|
|
458
|
+
set: function (val) {
|
|
459
|
+
this._gridSnappingEnabled = val;
|
|
460
|
+
},
|
|
461
|
+
enumerable: false,
|
|
462
|
+
configurable: true
|
|
463
|
+
});
|
|
464
|
+
Object.defineProperty(SpacesState.prototype, "guides", {
|
|
465
|
+
get: function () {
|
|
466
|
+
return this._guides;
|
|
467
|
+
},
|
|
468
|
+
set: function (val) {
|
|
469
|
+
this._guides = val;
|
|
470
|
+
},
|
|
471
|
+
enumerable: false,
|
|
472
|
+
configurable: true
|
|
473
|
+
});
|
|
474
|
+
Object.defineProperty(SpacesState.prototype, "enclosedSpacesToDraw", {
|
|
475
|
+
get: function () {
|
|
476
|
+
var _this = this;
|
|
477
|
+
var loops = (0, geometry_1.findLoops)(this.wallLines).inner;
|
|
478
|
+
return loops.reduce(function (output, loop) {
|
|
479
|
+
var screenSpaceArea = Math.round((0, geometry_1.getPolygonArea)(loop));
|
|
480
|
+
var area = screenSpaceArea * Math.pow(_this.scale, 2);
|
|
481
|
+
var convertedArea = (0, dataHandlers_1.convertAreaUnit)(area, types_1.IUnits.METER, _this.unit);
|
|
482
|
+
var enclosedSpace = {
|
|
483
|
+
loop: loop.map(function (point) { return _this.transformPointToCanvas(point); }),
|
|
484
|
+
area: (0, dataHandlers_1.prepAreaForUser)(convertedArea, _this.unit),
|
|
485
|
+
center: loop.reduce(function (centerPoint, point) {
|
|
486
|
+
centerPoint[0] += point[0] / loop.length;
|
|
487
|
+
centerPoint[1] += point[1] / loop.length;
|
|
488
|
+
return centerPoint;
|
|
489
|
+
}, [0, 0]),
|
|
490
|
+
};
|
|
491
|
+
enclosedSpace.center = _this.transformPointToCanvas(enclosedSpace.center);
|
|
492
|
+
output.push(enclosedSpace);
|
|
493
|
+
return output;
|
|
494
|
+
}, []);
|
|
495
|
+
},
|
|
496
|
+
enumerable: false,
|
|
497
|
+
configurable: true
|
|
498
|
+
});
|
|
499
|
+
Object.defineProperty(SpacesState.prototype, "canvasDimensions", {
|
|
500
|
+
get: function () {
|
|
501
|
+
return this._canvasDimensions;
|
|
502
|
+
},
|
|
503
|
+
set: function (dimensions) {
|
|
504
|
+
this._canvasDimensions = dimensions;
|
|
505
|
+
},
|
|
506
|
+
enumerable: false,
|
|
507
|
+
configurable: true
|
|
508
|
+
});
|
|
509
|
+
Object.defineProperty(SpacesState.prototype, "canvasWidth", {
|
|
510
|
+
get: function () {
|
|
511
|
+
return this.canvasDimensions[0];
|
|
512
|
+
},
|
|
513
|
+
enumerable: false,
|
|
514
|
+
configurable: true
|
|
515
|
+
});
|
|
516
|
+
Object.defineProperty(SpacesState.prototype, "canvasHeight", {
|
|
517
|
+
get: function () {
|
|
518
|
+
return this.canvasDimensions[1];
|
|
519
|
+
},
|
|
520
|
+
enumerable: false,
|
|
521
|
+
configurable: true
|
|
522
|
+
});
|
|
523
|
+
Object.defineProperty(SpacesState.prototype, "zoom", {
|
|
524
|
+
get: function () {
|
|
525
|
+
return this._zoom;
|
|
526
|
+
},
|
|
527
|
+
set: function (delta) {
|
|
528
|
+
var newZoom = this.zoom + delta;
|
|
529
|
+
var preppedZoom = newZoom < this.zoomMin
|
|
530
|
+
? this.zoomMin
|
|
531
|
+
: newZoom > this.zoomMax
|
|
532
|
+
? this.zoomMax
|
|
533
|
+
: newZoom;
|
|
534
|
+
if (preppedZoom === this.zoom)
|
|
535
|
+
return;
|
|
536
|
+
this._zoom = preppedZoom;
|
|
537
|
+
},
|
|
538
|
+
enumerable: false,
|
|
539
|
+
configurable: true
|
|
540
|
+
});
|
|
541
|
+
Object.defineProperty(SpacesState.prototype, "zoomFactor", {
|
|
542
|
+
get: function () {
|
|
543
|
+
return this._zoom / this.zoomMin;
|
|
544
|
+
},
|
|
545
|
+
set: function (val) {
|
|
546
|
+
var newZoom = val * this.zoomMin;
|
|
547
|
+
var validatedZoom = newZoom < this.zoomMin
|
|
548
|
+
? this.zoomMin
|
|
549
|
+
: newZoom > this.zoomMax
|
|
550
|
+
? this.zoomMax
|
|
551
|
+
: newZoom;
|
|
552
|
+
this._zoom = validatedZoom;
|
|
553
|
+
},
|
|
554
|
+
enumerable: false,
|
|
555
|
+
configurable: true
|
|
556
|
+
});
|
|
557
|
+
Object.defineProperty(SpacesState.prototype, "zoomMin", {
|
|
558
|
+
get: function () {
|
|
559
|
+
return this._zoomLimits[0];
|
|
560
|
+
},
|
|
561
|
+
enumerable: false,
|
|
562
|
+
configurable: true
|
|
563
|
+
});
|
|
564
|
+
Object.defineProperty(SpacesState.prototype, "zoomMax", {
|
|
565
|
+
get: function () {
|
|
566
|
+
return this._zoomLimits[1];
|
|
567
|
+
},
|
|
568
|
+
enumerable: false,
|
|
569
|
+
configurable: true
|
|
570
|
+
});
|
|
571
|
+
Object.defineProperty(SpacesState.prototype, "unit", {
|
|
572
|
+
get: function () {
|
|
573
|
+
return this._unit;
|
|
574
|
+
},
|
|
575
|
+
set: function (unit) {
|
|
576
|
+
this._unit = unit;
|
|
577
|
+
},
|
|
578
|
+
enumerable: false,
|
|
579
|
+
configurable: true
|
|
580
|
+
});
|
|
581
|
+
Object.defineProperty(SpacesState.prototype, "translate", {
|
|
582
|
+
get: function () {
|
|
583
|
+
return this._translate;
|
|
584
|
+
},
|
|
585
|
+
set: function (position) {
|
|
586
|
+
var zoomFactor = this._zoom / this.zoomMin;
|
|
587
|
+
var delta = [
|
|
588
|
+
(position[0] - this._translate[0]) / zoomFactor,
|
|
589
|
+
(position[1] - this._translate[1]) / zoomFactor,
|
|
590
|
+
];
|
|
591
|
+
this._translate = [
|
|
592
|
+
this._translate[0] + delta[0],
|
|
593
|
+
this._translate[1] + delta[1],
|
|
594
|
+
];
|
|
595
|
+
},
|
|
596
|
+
enumerable: false,
|
|
597
|
+
configurable: true
|
|
598
|
+
});
|
|
599
|
+
Object.defineProperty(SpacesState.prototype, "translateMin", {
|
|
600
|
+
get: function () {
|
|
601
|
+
return this._translateLimits[0];
|
|
602
|
+
},
|
|
603
|
+
enumerable: false,
|
|
604
|
+
configurable: true
|
|
605
|
+
});
|
|
606
|
+
Object.defineProperty(SpacesState.prototype, "translateMax", {
|
|
607
|
+
get: function () {
|
|
608
|
+
return this._translateLimits[1];
|
|
609
|
+
},
|
|
610
|
+
enumerable: false,
|
|
611
|
+
configurable: true
|
|
612
|
+
});
|
|
613
|
+
Object.defineProperty(SpacesState.prototype, "isDrawWallActive", {
|
|
614
|
+
get: function () {
|
|
615
|
+
return !!this._newWall;
|
|
616
|
+
},
|
|
617
|
+
enumerable: false,
|
|
618
|
+
configurable: true
|
|
619
|
+
});
|
|
620
|
+
Object.defineProperty(SpacesState.prototype, "validationConfig", {
|
|
621
|
+
get: function () {
|
|
622
|
+
return this._validationConfig;
|
|
623
|
+
},
|
|
624
|
+
set: function (config) {
|
|
625
|
+
this._validationConfig = config;
|
|
626
|
+
},
|
|
627
|
+
enumerable: false,
|
|
628
|
+
configurable: true
|
|
629
|
+
});
|
|
630
|
+
SpacesState.prototype.transformLengthFromCanvas = function (length) {
|
|
631
|
+
return length / this.zoomFactor;
|
|
632
|
+
};
|
|
633
|
+
SpacesState.prototype.transformLengthToCanvas = function (length) {
|
|
634
|
+
return length * this.zoomFactor;
|
|
635
|
+
};
|
|
636
|
+
SpacesState.prototype.transformPointToCanvas = function (point) {
|
|
637
|
+
var widthOffset = this.canvasWidth / 2;
|
|
638
|
+
var heightOffset = this.canvasHeight / 2;
|
|
639
|
+
return [
|
|
640
|
+
this.transformLengthToCanvas(point[0] + this.translate[0]) -
|
|
641
|
+
widthOffset * (this.zoomFactor - 1),
|
|
642
|
+
this.transformLengthToCanvas(point[1] + this.translate[1]) -
|
|
643
|
+
heightOffset * (this.zoomFactor - 1),
|
|
644
|
+
];
|
|
645
|
+
};
|
|
646
|
+
SpacesState.prototype.transformPointFromCanvas = function (point) {
|
|
647
|
+
var widthOffset = this.canvasWidth / 2;
|
|
648
|
+
var heightOffset = this.canvasHeight / 2;
|
|
649
|
+
return [
|
|
650
|
+
this.transformLengthFromCanvas(point[0] + widthOffset * (this.zoomFactor - 1)) - this.translate[0],
|
|
651
|
+
this.transformLengthFromCanvas(point[1] + heightOffset * (this.zoomFactor - 1)) - this.translate[1],
|
|
652
|
+
];
|
|
653
|
+
};
|
|
654
|
+
SpacesState.prototype.transformLineToCanvas = function (line) {
|
|
655
|
+
return [
|
|
656
|
+
this.transformPointToCanvas(line[0]),
|
|
657
|
+
this.transformPointToCanvas(line[1]),
|
|
658
|
+
];
|
|
659
|
+
};
|
|
660
|
+
SpacesState.prototype.prepLineLength = function (line) {
|
|
661
|
+
var lineLength = (0, geometry_1.getLengthOfLineSegment)(line) * this.scale;
|
|
662
|
+
var convertedVal = (0, dataHandlers_1.convertLengthUnit)(lineLength, types_1.IUnits.METER, this.unit);
|
|
663
|
+
return convertedVal;
|
|
664
|
+
};
|
|
665
|
+
SpacesState.prototype.getWall = function (index) {
|
|
666
|
+
return this.walls[index];
|
|
667
|
+
};
|
|
668
|
+
SpacesState.prototype.addWall = function (wall) {
|
|
669
|
+
if (!wall)
|
|
670
|
+
return;
|
|
671
|
+
var updatedWalls = this.walls;
|
|
672
|
+
updatedWalls.push(wall);
|
|
673
|
+
this.walls = updatedWalls;
|
|
674
|
+
};
|
|
675
|
+
SpacesState.prototype.addWalls = function (walls) {
|
|
676
|
+
var _this = this;
|
|
677
|
+
if (!(walls === null || walls === void 0 ? void 0 : walls.length))
|
|
678
|
+
return;
|
|
679
|
+
walls.forEach(function (wall) { return _this.addWall(wall); });
|
|
680
|
+
};
|
|
681
|
+
SpacesState.prototype.updateWall = function (index, wall) {
|
|
682
|
+
var currentWall = this.walls[index];
|
|
683
|
+
if (!currentWall)
|
|
684
|
+
return;
|
|
685
|
+
this._state[types_1.IElements.WALL][index] = Object.assign({}, currentWall, wall);
|
|
686
|
+
};
|
|
687
|
+
SpacesState.prototype.getWallConnectionCount = function (index) {
|
|
688
|
+
var wall = this.getWall(index);
|
|
689
|
+
return (wall === null || wall === void 0 ? void 0 : wall.connections.length) || 0;
|
|
690
|
+
};
|
|
691
|
+
SpacesState.prototype.getWallConnectionsHydrated = function (index) {
|
|
692
|
+
var _this = this;
|
|
693
|
+
var _a;
|
|
694
|
+
var connections = (_a = this.getWall(index)) === null || _a === void 0 ? void 0 : _a.connections;
|
|
695
|
+
if (!connections)
|
|
696
|
+
return undefined;
|
|
697
|
+
return connections.reduce(function (output, connection) {
|
|
698
|
+
var feature = _this.getFeature.apply(_this, connection);
|
|
699
|
+
if (feature)
|
|
700
|
+
output.push(feature);
|
|
701
|
+
return output;
|
|
702
|
+
}, []);
|
|
703
|
+
};
|
|
704
|
+
SpacesState.prototype.getWallDimensions = function (line) {
|
|
705
|
+
var lineLength = this.prepLineLength(line);
|
|
706
|
+
return {
|
|
707
|
+
line: line,
|
|
708
|
+
label: (0, dataHandlers_1.prepLengthForUser)(lineLength, this.unit),
|
|
709
|
+
};
|
|
710
|
+
};
|
|
711
|
+
SpacesState.prototype.getWallDimensionsByIndex = function (index) {
|
|
712
|
+
var _a;
|
|
713
|
+
var line = (_a = this.getWall(index)) === null || _a === void 0 ? void 0 : _a.line;
|
|
714
|
+
if (!line)
|
|
715
|
+
return undefined;
|
|
716
|
+
return this.getWallDimensions(line);
|
|
717
|
+
};
|
|
718
|
+
SpacesState.prototype.getWallDetailedDimensionsByIndex = function (index) {
|
|
719
|
+
var _this = this;
|
|
720
|
+
var _a;
|
|
721
|
+
var line = (_a = this.getWall(index)) === null || _a === void 0 ? void 0 : _a.line;
|
|
722
|
+
var features = this.getWallConnectionsHydrated(index);
|
|
723
|
+
if (!line || !features)
|
|
724
|
+
return undefined;
|
|
725
|
+
var prepLength = function (val) { return val.toFixed(2); };
|
|
726
|
+
var lines = features
|
|
727
|
+
.sort(function (a, b) { return a.offset - b.offset; })
|
|
728
|
+
.reduce(function (output, _a, i) {
|
|
729
|
+
var offset = _a.offset, length = _a.length;
|
|
730
|
+
var featureLine = (0, geometry_1.getLineAtOffsetOnLineSegment)(line, offset, length);
|
|
731
|
+
var featureLength = _this.prepLineLength(featureLine);
|
|
732
|
+
var unit = constants_1.UNIT_LABELS[_this.unit];
|
|
733
|
+
if (!i) {
|
|
734
|
+
var startLine = [line[0], featureLine[0]];
|
|
735
|
+
var startLineLength = _this.prepLineLength(startLine);
|
|
736
|
+
output.push({
|
|
737
|
+
line: startLine,
|
|
738
|
+
label: "".concat(prepLength(startLineLength), " ").concat(unit),
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
else {
|
|
742
|
+
var previousLine = [
|
|
743
|
+
output[output.length - 1].line[1],
|
|
744
|
+
featureLine[0],
|
|
745
|
+
];
|
|
746
|
+
var previousLineLength = _this.prepLineLength(previousLine);
|
|
747
|
+
output.push({
|
|
748
|
+
line: previousLine,
|
|
749
|
+
label: "".concat(prepLength(previousLineLength), " ").concat(unit),
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
output.push({
|
|
753
|
+
line: featureLine,
|
|
754
|
+
label: "".concat(prepLength(featureLength), " ").concat(unit),
|
|
755
|
+
});
|
|
756
|
+
if (i === features.length - 1) {
|
|
757
|
+
var endLine = [featureLine[1], line[1]];
|
|
758
|
+
var endLineLength = _this.prepLineLength(endLine);
|
|
759
|
+
output.push({
|
|
760
|
+
line: endLine,
|
|
761
|
+
label: "".concat(prepLength(endLineLength), " ").concat(unit),
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
return output;
|
|
765
|
+
}, []);
|
|
766
|
+
return lines;
|
|
767
|
+
};
|
|
768
|
+
SpacesState.prototype.getAllWallDimensionsToDraw = function (detailedWallsIndexes) {
|
|
769
|
+
var _this = this;
|
|
770
|
+
if (detailedWallsIndexes === void 0) { detailedWallsIndexes = []; }
|
|
771
|
+
var indexes = new Set([detailedWallsIndexes].flat());
|
|
772
|
+
var dimensionsList = this.walls.reduce(function (output, _, i) {
|
|
773
|
+
var dimensions = indexes.has(i)
|
|
774
|
+
? _this.getWallDetailedDimensionsByIndex(i)
|
|
775
|
+
: _this.getWallDimensionsByIndex(i);
|
|
776
|
+
if (!dimensions)
|
|
777
|
+
return output;
|
|
778
|
+
if (Array.isArray(dimensions))
|
|
779
|
+
output.push.apply(output, dimensions);
|
|
780
|
+
else
|
|
781
|
+
output.push(dimensions);
|
|
782
|
+
return output;
|
|
783
|
+
}, []);
|
|
784
|
+
return dimensionsList.map(function (dimension) { return (__assign(__assign({}, dimension), { line: _this.transformLineToCanvas(dimension.line) })); });
|
|
785
|
+
};
|
|
786
|
+
SpacesState.prototype.shiftAllFeaturesOnWall = function (index, shift) {
|
|
787
|
+
var _this = this;
|
|
788
|
+
var _a;
|
|
789
|
+
var connections = (_a = this.getWall(index)) === null || _a === void 0 ? void 0 : _a.connections;
|
|
790
|
+
if (!connections)
|
|
791
|
+
return;
|
|
792
|
+
connections.forEach(function (_a) {
|
|
793
|
+
var type = _a[0], featureIndex = _a[1];
|
|
794
|
+
var feature = _this.getFeature(type, featureIndex);
|
|
795
|
+
if (!feature)
|
|
796
|
+
return;
|
|
797
|
+
_this.updateFeature(type, featureIndex, {
|
|
798
|
+
offset: feature.offset + shift,
|
|
799
|
+
});
|
|
800
|
+
});
|
|
801
|
+
};
|
|
802
|
+
SpacesState.prototype.addFeatureToWall = function (index, featurePath) {
|
|
803
|
+
var _a;
|
|
804
|
+
var updatedWalls = this.walls;
|
|
805
|
+
(_a = updatedWalls[index]) === null || _a === void 0 ? void 0 : _a.connections.push(featurePath);
|
|
806
|
+
this.walls = updatedWalls;
|
|
807
|
+
};
|
|
808
|
+
SpacesState.prototype.removeFeatureFromWall = function (index, featurePath) {
|
|
809
|
+
var updatedWalls = this.walls;
|
|
810
|
+
if (!updatedWalls[index])
|
|
811
|
+
return;
|
|
812
|
+
updatedWalls[index].connections = updatedWalls[index].connections.filter(function (connection) {
|
|
813
|
+
return connection[0] !== featurePath[0] || connection[1] !== featurePath[1];
|
|
814
|
+
});
|
|
815
|
+
this.walls = updatedWalls;
|
|
816
|
+
};
|
|
817
|
+
SpacesState.prototype.splitWallAtOffset = function (wallIndex, offset) {
|
|
818
|
+
var wall = this.getWall(wallIndex);
|
|
819
|
+
if (!wall)
|
|
820
|
+
return;
|
|
821
|
+
var point = offset
|
|
822
|
+
? (0, geometry_1.getPointAtOffsetOnLineSegment)(wall.line, offset)
|
|
823
|
+
: (0, geometry_1.getMidpointOfLineSegment)(wall.line);
|
|
824
|
+
this.splitWallAtPoint(wallIndex, point);
|
|
825
|
+
this.pushStateToConfigurator();
|
|
826
|
+
};
|
|
827
|
+
SpacesState.prototype.splitWallAtPoint = function (wallIndex, point) {
|
|
828
|
+
var _this = this;
|
|
829
|
+
var originalWall = this.getWall(wallIndex);
|
|
830
|
+
if (!originalWall)
|
|
831
|
+
return;
|
|
832
|
+
var offset = (0, geometry_1.getLengthOfLineSegment)([originalWall.line[0], point]);
|
|
833
|
+
var _a = (0, geometry_1.splitLineAtPoint)(originalWall.line, point), line1 = _a[0], line2 = _a[1];
|
|
834
|
+
var newWallIndex = this.wallCount;
|
|
835
|
+
var splitWallsShared = {
|
|
836
|
+
assetId: originalWall.assetId,
|
|
837
|
+
restConfiguration: originalWall.restConfiguration,
|
|
838
|
+
visible: originalWall.visible,
|
|
839
|
+
};
|
|
840
|
+
var wall1 = __assign(__assign({}, splitWallsShared), { line: line1, connections: originalWall.connections });
|
|
841
|
+
var wall2 = __assign(__assign({}, splitWallsShared), { line: line2, connections: [] });
|
|
842
|
+
this.updateWall(wallIndex, wall1);
|
|
843
|
+
this.addWall(wall2);
|
|
844
|
+
originalWall.connections.forEach(function (connection) {
|
|
845
|
+
var feature = _this.getFeature.apply(_this, connection);
|
|
846
|
+
if (!feature)
|
|
847
|
+
return;
|
|
848
|
+
var updatedOffset = feature.offset - offset;
|
|
849
|
+
if (updatedOffset > 0)
|
|
850
|
+
_this.repositionFeature(connection, updatedOffset, newWallIndex);
|
|
851
|
+
});
|
|
852
|
+
};
|
|
853
|
+
SpacesState.prototype.deleteWall = function (index) {
|
|
854
|
+
var wall = this.getWall(index);
|
|
855
|
+
if (!wall)
|
|
856
|
+
return;
|
|
857
|
+
if (wall.connections.length) {
|
|
858
|
+
var currentFeatures_1 = this.features;
|
|
859
|
+
var deleteMap = wall.connections.reduce(function (output, _a) {
|
|
860
|
+
var type = _a[0], index = _a[1];
|
|
861
|
+
if (output[type])
|
|
862
|
+
output[type].push(index);
|
|
863
|
+
else
|
|
864
|
+
output[type] = [index];
|
|
865
|
+
return output;
|
|
866
|
+
}, {});
|
|
867
|
+
var updatedFeatures = Object.entries(deleteMap).reduce(function (output, _a) {
|
|
868
|
+
var _b;
|
|
869
|
+
var type = _a[0], deletionIndexes = _a[1];
|
|
870
|
+
output[type] = (_b = currentFeatures_1[type]) === null || _b === void 0 ? void 0 : _b.filter(function (_, i) { return !deletionIndexes.includes(i); });
|
|
871
|
+
return output;
|
|
872
|
+
}, __assign({}, currentFeatures_1));
|
|
873
|
+
this.features = updatedFeatures;
|
|
874
|
+
}
|
|
875
|
+
var updatedWalls = this.walls;
|
|
876
|
+
updatedWalls.splice(index, 1);
|
|
877
|
+
this.walls = updatedWalls;
|
|
878
|
+
var reevaluatedFeatures = Object.entries(this.features).reduce(function (output, _a) {
|
|
879
|
+
var type = _a[0], featuresArr = _a[1];
|
|
880
|
+
output[type] = featuresArr.map(function (feature) {
|
|
881
|
+
return feature.connectedTo[1] > index
|
|
882
|
+
? Object.assign({}, feature, {
|
|
883
|
+
connectedTo: [
|
|
884
|
+
feature.connectedTo[0],
|
|
885
|
+
feature.connectedTo[1] - 1,
|
|
886
|
+
],
|
|
887
|
+
})
|
|
888
|
+
: feature;
|
|
889
|
+
});
|
|
890
|
+
return output;
|
|
891
|
+
}, {});
|
|
892
|
+
this.features = reevaluatedFeatures;
|
|
893
|
+
this.reevaluateFeatureConnections();
|
|
894
|
+
this.pushStateToConfigurator();
|
|
895
|
+
};
|
|
896
|
+
SpacesState.prototype.getFirstVacantLocationOnWallIndex = function (length, wallIndex) {
|
|
897
|
+
var _a, _b;
|
|
898
|
+
var _c = this, walls = _c.walls, validationConfig = _c.validationConfig;
|
|
899
|
+
var padding = validationConfig.padding;
|
|
900
|
+
var wallLength = (0, geometry_1.getLengthOfLineSegment)(walls[wallIndex].line);
|
|
901
|
+
var features = (_b = (_a = this.getWallConnectionsHydrated(wallIndex)) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return a.offset - b.offset; })) !== null && _b !== void 0 ? _b : [];
|
|
902
|
+
for (var j = 0; j <= features.length; j++) {
|
|
903
|
+
var prev = features[j - 1];
|
|
904
|
+
var next = features[j];
|
|
905
|
+
var slotStart = prev ? prev.offset + prev.length : padding;
|
|
906
|
+
var slotEnd = next ? next.offset : wallLength - padding;
|
|
907
|
+
if (slotEnd - slotStart > length) {
|
|
908
|
+
return (slotStart + slotEnd) / 2 - length / 2;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
return undefined;
|
|
912
|
+
};
|
|
913
|
+
SpacesState.prototype.getFirstVacantLocation = function (length, wallIndex) {
|
|
914
|
+
if (wallIndex !== undefined) {
|
|
915
|
+
var offset = this.getFirstVacantLocationOnWallIndex(length, wallIndex);
|
|
916
|
+
if (offset != null)
|
|
917
|
+
return {
|
|
918
|
+
wallIndex: wallIndex,
|
|
919
|
+
offset: offset,
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
for (var i = 0; i < this.walls.length; i++) {
|
|
923
|
+
var offset = this.getFirstVacantLocationOnWallIndex(length, i);
|
|
924
|
+
if (offset != null)
|
|
925
|
+
return {
|
|
926
|
+
wallIndex: i,
|
|
927
|
+
offset: offset,
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
return false;
|
|
931
|
+
};
|
|
932
|
+
SpacesState.prototype.getWallUiAnchorPoint = function (index) {
|
|
933
|
+
var wall = this.getWall(index);
|
|
934
|
+
if (!wall)
|
|
935
|
+
return undefined;
|
|
936
|
+
var line = (0, geometry_1.getParallelLineSegmentAtDistance)(wall.line, constants_1.UI_ANCHOR_DISTANCE);
|
|
937
|
+
var point = (0, geometry_1.getMidpointOfLineSegment)(line);
|
|
938
|
+
return this.transformPointToCanvas(point);
|
|
939
|
+
};
|
|
940
|
+
SpacesState.prototype.getVertex = function (index) {
|
|
941
|
+
return this.verticesList[index];
|
|
942
|
+
};
|
|
943
|
+
SpacesState.prototype.getWallsConnectedToVertex = function (index) {
|
|
944
|
+
if (index === undefined)
|
|
945
|
+
return [];
|
|
946
|
+
var vertex = this.getVertex(index);
|
|
947
|
+
if (!vertex)
|
|
948
|
+
return [];
|
|
949
|
+
return vertex.connections.map(function (_a) {
|
|
950
|
+
var index = _a[0];
|
|
951
|
+
return index;
|
|
952
|
+
});
|
|
953
|
+
};
|
|
954
|
+
SpacesState.prototype.repositionVertex = function (index, newCoordinates) {
|
|
955
|
+
var _this = this;
|
|
956
|
+
var _a;
|
|
957
|
+
var connections = (_a = this.getVertex(index)) === null || _a === void 0 ? void 0 : _a.connections;
|
|
958
|
+
if (!connections)
|
|
959
|
+
return;
|
|
960
|
+
connections.forEach(function (_a) {
|
|
961
|
+
var wallIdx = _a[0], vertexIdx = _a[1];
|
|
962
|
+
var updatedLine = JSON.parse(JSON.stringify(_this.walls[wallIdx].line));
|
|
963
|
+
var currentLine = JSON.parse(JSON.stringify(_this.walls[wallIdx].line));
|
|
964
|
+
updatedLine[vertexIdx] = newCoordinates;
|
|
965
|
+
if (_this.getWallConnectionCount(wallIdx) && vertexIdx === 0) {
|
|
966
|
+
var delta = (0, geometry_1.getLengthOfLineSegment)(updatedLine) -
|
|
967
|
+
(0, geometry_1.getLengthOfLineSegment)(currentLine);
|
|
968
|
+
_this.shiftAllFeaturesOnWall(wallIdx, delta);
|
|
969
|
+
}
|
|
970
|
+
_this.updateWall(wallIdx, {
|
|
971
|
+
line: updatedLine,
|
|
972
|
+
path: undefined,
|
|
973
|
+
});
|
|
974
|
+
});
|
|
975
|
+
};
|
|
976
|
+
SpacesState.prototype.getFeatureType = function (type) {
|
|
977
|
+
return this.features[type];
|
|
978
|
+
};
|
|
979
|
+
SpacesState.prototype.setFeatureType = function (type, features) {
|
|
980
|
+
var updatedFeatures = this.features;
|
|
981
|
+
updatedFeatures[type] = features;
|
|
982
|
+
this.features = updatedFeatures;
|
|
983
|
+
this.reevaluateFeatureConnections();
|
|
984
|
+
};
|
|
985
|
+
SpacesState.prototype.getFeature = function (type, index) {
|
|
986
|
+
var _a;
|
|
987
|
+
return (_a = this.features[type]) === null || _a === void 0 ? void 0 : _a[index];
|
|
988
|
+
};
|
|
989
|
+
SpacesState.prototype.updateFeature = function (type, index, feature) {
|
|
990
|
+
var currentFeature = this._state[types_1.IElements.FEATURE][type][index];
|
|
991
|
+
if (!currentFeature)
|
|
992
|
+
return;
|
|
993
|
+
this._state[types_1.IElements.FEATURE][type][index] = Object.assign({}, currentFeature, feature);
|
|
994
|
+
};
|
|
995
|
+
SpacesState.prototype.repositionFeature = function (featurePath, offset, moveToWallIndex) {
|
|
996
|
+
var type = featurePath[0], index = featurePath[1];
|
|
997
|
+
var feature = this.getFeature(type, index);
|
|
998
|
+
if (!feature)
|
|
999
|
+
return;
|
|
1000
|
+
this.updateFeature(type, index, { offset: offset, path: undefined });
|
|
1001
|
+
if (moveToWallIndex === feature.connectedTo[1])
|
|
1002
|
+
return;
|
|
1003
|
+
this.removeFeatureFromWall(index, featurePath);
|
|
1004
|
+
this.addFeatureToWall(moveToWallIndex, featurePath);
|
|
1005
|
+
this.updateFeature(type, index, {
|
|
1006
|
+
connectedTo: [types_1.IElements.WALL, moveToWallIndex],
|
|
1007
|
+
});
|
|
1008
|
+
};
|
|
1009
|
+
SpacesState.prototype.addFeature = function (type, addToWallIndex, feature) {
|
|
1010
|
+
var _a;
|
|
1011
|
+
var assetId = (feature === null || feature === void 0 ? void 0 : feature.assetId) || this.attributeDefaults[type];
|
|
1012
|
+
if (!assetId)
|
|
1013
|
+
return;
|
|
1014
|
+
var offset = undefined;
|
|
1015
|
+
var index = undefined;
|
|
1016
|
+
var length = (feature === null || feature === void 0 ? void 0 : feature.length) || constants_1.FEATURE_LENGTH;
|
|
1017
|
+
if (addToWallIndex !== undefined && (feature === null || feature === void 0 ? void 0 : feature.offset) !== undefined) {
|
|
1018
|
+
var wall = this.getWall(addToWallIndex);
|
|
1019
|
+
if (wall) {
|
|
1020
|
+
var isColliding = (0, validators_1.isFeatureCollidingWithExistingFeature)({
|
|
1021
|
+
wall: wall,
|
|
1022
|
+
updatedFeature: {
|
|
1023
|
+
length: length,
|
|
1024
|
+
offset: feature.offset,
|
|
1025
|
+
address: { type: types_1.IElements.WALL, index: addToWallIndex },
|
|
1026
|
+
},
|
|
1027
|
+
}, {
|
|
1028
|
+
walls: this.walls,
|
|
1029
|
+
features: this.features,
|
|
1030
|
+
});
|
|
1031
|
+
if (!isColliding) {
|
|
1032
|
+
offset = feature.offset;
|
|
1033
|
+
index = addToWallIndex;
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
if (offset === undefined) {
|
|
1038
|
+
var availableSlot = this.getFirstVacantLocation(length, addToWallIndex);
|
|
1039
|
+
if (!availableSlot)
|
|
1040
|
+
return;
|
|
1041
|
+
offset = availableSlot.offset;
|
|
1042
|
+
index = availableSlot.wallIndex;
|
|
1043
|
+
}
|
|
1044
|
+
if (index === undefined || offset === undefined)
|
|
1045
|
+
return;
|
|
1046
|
+
var newFeature = __assign(__assign({}, feature), { assetId: assetId, offset: offset, length: length, height: (feature === null || feature === void 0 ? void 0 : feature.height) || 0, altitude: (feature === null || feature === void 0 ? void 0 : feature.altitude) || 0, connectedTo: [types_1.IElements.WALL, index], restConfiguration: '{}' });
|
|
1047
|
+
if (type === types_1.IElements.DOOR) {
|
|
1048
|
+
newFeature.orientation = 'left';
|
|
1049
|
+
newFeature.openingDirection = 'inside';
|
|
1050
|
+
}
|
|
1051
|
+
var newFeatureIndex;
|
|
1052
|
+
if ((_a = this._state[types_1.IElements.FEATURE][type]) === null || _a === void 0 ? void 0 : _a.length)
|
|
1053
|
+
newFeatureIndex = this._state[types_1.IElements.FEATURE][type].length;
|
|
1054
|
+
else {
|
|
1055
|
+
this._state[types_1.IElements.FEATURE][type] = [];
|
|
1056
|
+
newFeatureIndex = 0;
|
|
1057
|
+
}
|
|
1058
|
+
this._state[types_1.IElements.FEATURE][type].push(newFeature);
|
|
1059
|
+
this.addFeatureToWall(index, [type, newFeatureIndex]);
|
|
1060
|
+
this.pushStateToConfigurator();
|
|
1061
|
+
};
|
|
1062
|
+
SpacesState.prototype.deleteFeature = function (type, index) {
|
|
1063
|
+
var features = this.getFeatureType(type);
|
|
1064
|
+
if (!(features === null || features === void 0 ? void 0 : features[index]))
|
|
1065
|
+
return;
|
|
1066
|
+
var deletedFeature = features.splice(index, 1)[0];
|
|
1067
|
+
this.setFeatureType(type, features);
|
|
1068
|
+
var wallToUpdate = this.getWall(deletedFeature.connectedTo[1]);
|
|
1069
|
+
if (!wallToUpdate)
|
|
1070
|
+
return;
|
|
1071
|
+
this.updateWall(deletedFeature.connectedTo[1], {
|
|
1072
|
+
connections: wallToUpdate.connections.filter(function (connection) { return connection[0] === type && connection[1] !== index; }),
|
|
1073
|
+
});
|
|
1074
|
+
this.pushStateToConfigurator();
|
|
1075
|
+
};
|
|
1076
|
+
SpacesState.prototype.getHydratedFeature = function (type, index) {
|
|
1077
|
+
var feature = this.getFeature(type, index);
|
|
1078
|
+
if (!feature)
|
|
1079
|
+
return;
|
|
1080
|
+
var wall = this.getWall(feature.connectedTo[1]);
|
|
1081
|
+
if (!wall)
|
|
1082
|
+
return;
|
|
1083
|
+
var line = (0, geometry_1.getLineAtOffsetOnLineSegment)(wall.line, feature.offset, feature.length);
|
|
1084
|
+
return __assign(__assign({}, feature), { line: line });
|
|
1085
|
+
};
|
|
1086
|
+
SpacesState.prototype.getFeatureUiAnchorPoint = function (type, index) {
|
|
1087
|
+
var feature = this.getHydratedFeature(type, index);
|
|
1088
|
+
if (!feature)
|
|
1089
|
+
return;
|
|
1090
|
+
var line = (0, geometry_1.getParallelLineSegmentAtDistance)(feature.line, constants_1.UI_ANCHOR_DISTANCE);
|
|
1091
|
+
var point = (0, geometry_1.getMidpointOfLineSegment)(line);
|
|
1092
|
+
return this.transformPointToCanvas(point);
|
|
1093
|
+
};
|
|
1094
|
+
SpacesState.prototype.deleteElement = function (type, index) {
|
|
1095
|
+
if (type === types_1.IElements.VERTEX)
|
|
1096
|
+
return;
|
|
1097
|
+
if (type === types_1.IElements.WALL)
|
|
1098
|
+
this.deleteWall(index);
|
|
1099
|
+
else
|
|
1100
|
+
this.deleteFeature(type, index);
|
|
1101
|
+
};
|
|
1102
|
+
SpacesState.prototype.getVertexIndexInProximity = function (point) {
|
|
1103
|
+
if (!point)
|
|
1104
|
+
return undefined;
|
|
1105
|
+
var snapProximity = this.snapProximity;
|
|
1106
|
+
var index = this.verticesList.findIndex(function (vertex) {
|
|
1107
|
+
return (0, geometry_1.arePointsWithinProximity)(vertex.point, point, snapProximity);
|
|
1108
|
+
});
|
|
1109
|
+
if (index === -1)
|
|
1110
|
+
return undefined;
|
|
1111
|
+
return index;
|
|
1112
|
+
};
|
|
1113
|
+
SpacesState.prototype.getWallIndexInProximity = function (point) {
|
|
1114
|
+
var _this = this;
|
|
1115
|
+
var index = this.walls.findIndex(function (wall) {
|
|
1116
|
+
var path = (0, geometry_1.addThicknessToLine)(wall.line, _this.styles.wall.thickness + constants_1.WALL_SNAP_DISTANCE);
|
|
1117
|
+
return (0, geometry_1.isPointInQuadrilateral)(path, point);
|
|
1118
|
+
});
|
|
1119
|
+
if (index === -1)
|
|
1120
|
+
return undefined;
|
|
1121
|
+
return index;
|
|
1122
|
+
};
|
|
1123
|
+
SpacesState.prototype.getSnapPointToVertexInProximity = function (point) {
|
|
1124
|
+
var _a, _b;
|
|
1125
|
+
if (!point)
|
|
1126
|
+
return undefined;
|
|
1127
|
+
var index = this.getVertexIndexInProximity(point);
|
|
1128
|
+
if (index === undefined)
|
|
1129
|
+
return undefined;
|
|
1130
|
+
if (((_a = this._activeElement) === null || _a === void 0 ? void 0 : _a.type) === types_1.IElements.VERTEX &&
|
|
1131
|
+
((_b = this._activeElement) === null || _b === void 0 ? void 0 : _b.index) === index)
|
|
1132
|
+
return undefined;
|
|
1133
|
+
var vertex = this.getVertex(index);
|
|
1134
|
+
if (!vertex)
|
|
1135
|
+
return undefined;
|
|
1136
|
+
return {
|
|
1137
|
+
type: types_1.IElements.VERTEX,
|
|
1138
|
+
index: index,
|
|
1139
|
+
point: vertex.point,
|
|
1140
|
+
locked: [true, true],
|
|
1141
|
+
};
|
|
1142
|
+
};
|
|
1143
|
+
SpacesState.prototype.getSnapPointToWallInProximity = function (point) {
|
|
1144
|
+
var index = this.getWallIndexInProximity(point);
|
|
1145
|
+
if (index === undefined)
|
|
1146
|
+
return undefined;
|
|
1147
|
+
if (this._activeElement) {
|
|
1148
|
+
if (this._activeElement.type === types_1.IElements.WALL &&
|
|
1149
|
+
this._activeElement.index === index)
|
|
1150
|
+
return undefined;
|
|
1151
|
+
if (this._activeElement.type === types_1.IElements.VERTEX) {
|
|
1152
|
+
var vertex = this.getVertex(this._activeElement.index);
|
|
1153
|
+
if (vertex)
|
|
1154
|
+
for (var i = 0; i < vertex.connections.length; i++) {
|
|
1155
|
+
if (vertex.connections[i][0] === index)
|
|
1156
|
+
return undefined;
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
var intersection = (0, geometry_1.getTangetIntersectionAndOffset)(this.getWall(index).line, point);
|
|
1161
|
+
if (!intersection)
|
|
1162
|
+
return undefined;
|
|
1163
|
+
return __assign(__assign({ type: types_1.IElements.WALL, index: index }, intersection), { locked: [true, true] });
|
|
1164
|
+
};
|
|
1165
|
+
SpacesState.prototype.getSnapPointToAngleInProximity = function (snapPoint, anchorPoint, angle) {
|
|
1166
|
+
var _a;
|
|
1167
|
+
if (anchorPoint === void 0) { anchorPoint = ((_a = this._newWall) === null || _a === void 0 ? void 0 : _a.start.point) ||
|
|
1168
|
+
undefined; }
|
|
1169
|
+
if (angle === void 0) { angle = 30; }
|
|
1170
|
+
if (!this.angleSnappingEnabled)
|
|
1171
|
+
return snapPoint;
|
|
1172
|
+
var point = snapPoint.point, locked = snapPoint.locked;
|
|
1173
|
+
if (locked[0] || locked[1])
|
|
1174
|
+
return snapPoint;
|
|
1175
|
+
if (!anchorPoint)
|
|
1176
|
+
return snapPoint;
|
|
1177
|
+
if (Math.abs(point[0] - anchorPoint[0]) < this.snapProximity) {
|
|
1178
|
+
return {
|
|
1179
|
+
type: types_1.SNAPPING_TYPES.ANGLE,
|
|
1180
|
+
point: [anchorPoint[0], point[1]],
|
|
1181
|
+
orientations: [types_1.GUIDE_ORIENTATIONS.VERTICAL],
|
|
1182
|
+
locked: [true, true],
|
|
1183
|
+
};
|
|
1184
|
+
}
|
|
1185
|
+
else if (Math.abs(point[1] - anchorPoint[1]) < this.snapProximity) {
|
|
1186
|
+
return {
|
|
1187
|
+
type: types_1.SNAPPING_TYPES.ANGLE,
|
|
1188
|
+
point: [point[0], anchorPoint[1]],
|
|
1189
|
+
orientations: [types_1.GUIDE_ORIENTATIONS.HORIZONTAL],
|
|
1190
|
+
locked: [true, true],
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
for (var degrees = 0; degrees < 360; degrees += angle) {
|
|
1194
|
+
if (degrees === 0 || degrees % 90 === 0)
|
|
1195
|
+
continue;
|
|
1196
|
+
var radians = degrees * (Math.PI / 180);
|
|
1197
|
+
if ((0, geometry_1.getDistanceToLine)(anchorPoint, radians, point) < this.snapProximity)
|
|
1198
|
+
return {
|
|
1199
|
+
type: types_1.SNAPPING_TYPES.ANGLE,
|
|
1200
|
+
point: (0, geometry_1.closestPointOnLine)(anchorPoint, radians, point),
|
|
1201
|
+
orientations: [],
|
|
1202
|
+
locked: [true, true],
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
return snapPoint;
|
|
1206
|
+
};
|
|
1207
|
+
SpacesState.prototype.getSnapVertexToGuideInProximity = function (snapPoint, vertexIndex) {
|
|
1208
|
+
if (!this.guideSnappingEnabled)
|
|
1209
|
+
return snapPoint;
|
|
1210
|
+
var locked = snapPoint.locked, point = snapPoint.point;
|
|
1211
|
+
if (locked[0] && locked[1])
|
|
1212
|
+
return snapPoint;
|
|
1213
|
+
var x = point[0], y = point[1];
|
|
1214
|
+
var outputSnapPoint;
|
|
1215
|
+
var anchorPoints = [];
|
|
1216
|
+
var orientations = new Set();
|
|
1217
|
+
var vertices = __spreadArray([], this.verticesList.map(function (_a) {
|
|
1218
|
+
var point = _a.point;
|
|
1219
|
+
return point;
|
|
1220
|
+
}), true);
|
|
1221
|
+
if (this._newWall)
|
|
1222
|
+
vertices.push(this._newWall.start.point);
|
|
1223
|
+
for (var i = 0; i < vertices.length &&
|
|
1224
|
+
(!orientations.has(types_1.GUIDE_ORIENTATIONS.VERTICAL) ||
|
|
1225
|
+
!orientations.has(types_1.GUIDE_ORIENTATIONS.HORIZONTAL)); i++) {
|
|
1226
|
+
if (vertexIndex === i)
|
|
1227
|
+
continue;
|
|
1228
|
+
var _a = vertices[i], xAnchor = _a[0], yAnchor = _a[1];
|
|
1229
|
+
if (!orientations.has(types_1.GUIDE_ORIENTATIONS.VERTICAL) &&
|
|
1230
|
+
Math.abs(x - xAnchor) < this.snapProximity) {
|
|
1231
|
+
outputSnapPoint = orientations.has(types_1.GUIDE_ORIENTATIONS.HORIZONTAL)
|
|
1232
|
+
? [xAnchor, outputSnapPoint[1]]
|
|
1233
|
+
: [xAnchor, y];
|
|
1234
|
+
anchorPoints.push(vertices[i]);
|
|
1235
|
+
orientations.add(types_1.GUIDE_ORIENTATIONS.VERTICAL);
|
|
1236
|
+
locked[0] = true;
|
|
1237
|
+
}
|
|
1238
|
+
else if (!orientations.has(types_1.GUIDE_ORIENTATIONS.HORIZONTAL) &&
|
|
1239
|
+
Math.abs(y - yAnchor) < this.snapProximity) {
|
|
1240
|
+
outputSnapPoint = orientations.has(types_1.GUIDE_ORIENTATIONS.VERTICAL)
|
|
1241
|
+
? [outputSnapPoint[0], yAnchor]
|
|
1242
|
+
: [x, yAnchor];
|
|
1243
|
+
anchorPoints.push(vertices[i]);
|
|
1244
|
+
orientations.add(types_1.GUIDE_ORIENTATIONS.HORIZONTAL);
|
|
1245
|
+
locked[1] = true;
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
if (!outputSnapPoint)
|
|
1249
|
+
return snapPoint;
|
|
1250
|
+
return {
|
|
1251
|
+
type: types_1.SNAPPING_TYPES.GUIDE,
|
|
1252
|
+
point: outputSnapPoint,
|
|
1253
|
+
orientations: Array.from(orientations),
|
|
1254
|
+
locked: locked,
|
|
1255
|
+
};
|
|
1256
|
+
};
|
|
1257
|
+
SpacesState.prototype.getSnapActiveVertexToGuideInProximity = function (snapPoint) {
|
|
1258
|
+
if (!this._activeElement)
|
|
1259
|
+
return snapPoint;
|
|
1260
|
+
return this.getSnapVertexToGuideInProximity(snapPoint, this._activeElement.index);
|
|
1261
|
+
};
|
|
1262
|
+
SpacesState.prototype.getSnapPointToGridInProximity = function (snapPoint) {
|
|
1263
|
+
if (!this.gridSnappingEnabled)
|
|
1264
|
+
return snapPoint;
|
|
1265
|
+
var locked = snapPoint.locked, point = snapPoint.point;
|
|
1266
|
+
if (locked[0] && locked[1])
|
|
1267
|
+
return snapPoint;
|
|
1268
|
+
var _a = this.gridToDraw, showSubdivisions = _a.showSubdivisions, subdivisions = _a.subdivisions;
|
|
1269
|
+
var gridUnitLength = showSubdivisions
|
|
1270
|
+
? this.gridUnitLength / subdivisions
|
|
1271
|
+
: this.gridUnitLength;
|
|
1272
|
+
var gridPoint = point.map(function (axis) { return Math.round(axis / gridUnitLength) * gridUnitLength; });
|
|
1273
|
+
if ((0, geometry_1.getLengthOfLineSegment)([point, gridPoint]) > this.snapProximity)
|
|
1274
|
+
return snapPoint;
|
|
1275
|
+
if ((!locked[0] && !locked[1]) ||
|
|
1276
|
+
(locked[0] && gridPoint[0] === point[0]) ||
|
|
1277
|
+
(locked[1] && gridPoint[1] === point[1]))
|
|
1278
|
+
return {
|
|
1279
|
+
type: types_1.SNAPPING_TYPES.GRID,
|
|
1280
|
+
point: gridPoint,
|
|
1281
|
+
locked: [true, true],
|
|
1282
|
+
orientations: types_1.SNAPPING_TYPES.ANGLE === snapPoint.type ||
|
|
1283
|
+
types_1.SNAPPING_TYPES.GUIDE === snapPoint.type
|
|
1284
|
+
? snapPoint.orientations
|
|
1285
|
+
: [],
|
|
1286
|
+
};
|
|
1287
|
+
return snapPoint;
|
|
1288
|
+
};
|
|
1289
|
+
SpacesState.prototype.getFeatureAtPoint = function (point) {
|
|
1290
|
+
var _this = this;
|
|
1291
|
+
if (!point)
|
|
1292
|
+
return undefined;
|
|
1293
|
+
if (!this.featureCount)
|
|
1294
|
+
return undefined;
|
|
1295
|
+
var featuresMap = Object.entries(this.features);
|
|
1296
|
+
for (var i = 0; i < featuresMap.length; i++) {
|
|
1297
|
+
var _a = featuresMap[i], name_1 = _a[0], feature = _a[1];
|
|
1298
|
+
var index = feature.findIndex(function (feature) {
|
|
1299
|
+
var path = feature.path;
|
|
1300
|
+
if (!path) {
|
|
1301
|
+
var wallIndex = feature.connectedTo[1];
|
|
1302
|
+
var featureLine = (0, geometry_1.getLineAtOffsetOnLineSegment)(_this.getWall(wallIndex).line, feature.offset, feature.length);
|
|
1303
|
+
path = (0, geometry_1.addThicknessToLine)(featureLine, _this.styles.feature.thickness);
|
|
1304
|
+
}
|
|
1305
|
+
return (0, geometry_1.isPointInQuadrilateral)(path, point);
|
|
1306
|
+
});
|
|
1307
|
+
if (index !== -1)
|
|
1308
|
+
return {
|
|
1309
|
+
type: name_1,
|
|
1310
|
+
index: index,
|
|
1311
|
+
};
|
|
1312
|
+
}
|
|
1313
|
+
return undefined;
|
|
1314
|
+
};
|
|
1315
|
+
SpacesState.prototype.getElementAddressAtPoint = function (point) {
|
|
1316
|
+
if (!point)
|
|
1317
|
+
return undefined;
|
|
1318
|
+
var snapToVertex = this.getSnapPointToVertexInProximity(point);
|
|
1319
|
+
if (snapToVertex !== undefined)
|
|
1320
|
+
return snapToVertex;
|
|
1321
|
+
if (this.featureCount) {
|
|
1322
|
+
var featureInProximity = this.getFeatureAtPoint(point);
|
|
1323
|
+
if (featureInProximity)
|
|
1324
|
+
return featureInProximity;
|
|
1325
|
+
}
|
|
1326
|
+
var wallInProximity = this.getWallIndexInProximity(point);
|
|
1327
|
+
if (wallInProximity !== undefined)
|
|
1328
|
+
return { type: types_1.IElements.WALL, index: wallInProximity };
|
|
1329
|
+
return undefined;
|
|
1330
|
+
};
|
|
1331
|
+
SpacesState.prototype.getElementUiAtPoint = function (cursorPoint) {
|
|
1332
|
+
var point = this.transformPointFromCanvas(cursorPoint);
|
|
1333
|
+
var element = this.getElementAddressAtPoint(point);
|
|
1334
|
+
if (!element)
|
|
1335
|
+
return;
|
|
1336
|
+
var uiAnchor;
|
|
1337
|
+
if (element.type === types_1.IElements.VERTEX)
|
|
1338
|
+
return;
|
|
1339
|
+
if (element.type === types_1.IElements.WALL)
|
|
1340
|
+
uiAnchor = this.getWallUiAnchorPoint(element.index);
|
|
1341
|
+
else
|
|
1342
|
+
uiAnchor = this.getFeatureUiAnchorPoint(element.type, element.index);
|
|
1343
|
+
if (!uiAnchor)
|
|
1344
|
+
return undefined;
|
|
1345
|
+
return {
|
|
1346
|
+
path: [element.type, element.index],
|
|
1347
|
+
uiAnchor: uiAnchor,
|
|
1348
|
+
};
|
|
1349
|
+
};
|
|
1350
|
+
SpacesState.prototype.getSnapPointToElementInProximity = function (point) {
|
|
1351
|
+
var feature = this.getFeatureAtPoint(point);
|
|
1352
|
+
if (feature)
|
|
1353
|
+
return __assign(__assign({}, feature), { point: point, locked: [true, true] });
|
|
1354
|
+
var snapToVertex = this.getSnapPointToVertexInProximity(point);
|
|
1355
|
+
if (snapToVertex)
|
|
1356
|
+
return snapToVertex;
|
|
1357
|
+
var snapToWall = this.getSnapPointToWallInProximity(point);
|
|
1358
|
+
if (snapToWall)
|
|
1359
|
+
return snapToWall;
|
|
1360
|
+
return {
|
|
1361
|
+
type: types_1.SNAPPING_TYPES.NONE,
|
|
1362
|
+
point: point,
|
|
1363
|
+
locked: [false, false],
|
|
1364
|
+
};
|
|
1365
|
+
};
|
|
1366
|
+
SpacesState.prototype.runValidators = function (validators, input) {
|
|
1367
|
+
return (0, validators_1.runValidators)(validators, input, { walls: this.walls, features: this.features }, this.validationConfig);
|
|
1368
|
+
};
|
|
1369
|
+
SpacesState.prototype.reevaluateFeatureConnections = function () {
|
|
1370
|
+
var _this = this;
|
|
1371
|
+
this.walls.forEach(function (_, i) { return _this.updateWall(i, { connections: [] }); });
|
|
1372
|
+
Object.entries(this.features).forEach(function (_a) {
|
|
1373
|
+
var type = _a[0], featuresArr = _a[1];
|
|
1374
|
+
return featuresArr.forEach(function (feature, i) {
|
|
1375
|
+
return _this.addFeatureToWall(feature.connectedTo[1], [type, i]);
|
|
1376
|
+
});
|
|
1377
|
+
});
|
|
1378
|
+
};
|
|
1379
|
+
SpacesState.prototype.pushStateToConfigurator = function () {
|
|
1380
|
+
var configuration = (0, dataHandlers_1.prepAttributesOutgoing)(this.walls, this.features, this._config);
|
|
1381
|
+
window.threekit.configurator.setConfiguration(configuration);
|
|
1382
|
+
};
|
|
1383
|
+
SpacesState.prototype.setAttributesToState = function (attributes) {
|
|
1384
|
+
if (!attributes)
|
|
1385
|
+
return;
|
|
1386
|
+
this._attributesState = attributes;
|
|
1387
|
+
var data = (0, dataHandlers_1.prepAttributesIncoming)(attributes, this._config);
|
|
1388
|
+
if (!Object.keys(this.attributeDefaults).length)
|
|
1389
|
+
this.attributeDefaults = (0, dataHandlers_1.getAttributeDefaults)(attributes, this._config);
|
|
1390
|
+
this.validationConfig = data.validationConfig;
|
|
1391
|
+
this.walls = data[types_1.IElements.WALL];
|
|
1392
|
+
this.vertices = data[types_1.IElements.VERTEX];
|
|
1393
|
+
this.features = data[types_1.IElements.FEATURE];
|
|
1394
|
+
this.reevaluateFeatureConnections();
|
|
1395
|
+
};
|
|
1396
|
+
SpacesState.prototype.deleteAll = function () {
|
|
1397
|
+
this.walls = [];
|
|
1398
|
+
this.vertices = {};
|
|
1399
|
+
this.features = Object.keys(this.features).reduce(function (output, type) {
|
|
1400
|
+
var _a;
|
|
1401
|
+
return Object.assign(output, (_a = {}, _a[type] = [], _a));
|
|
1402
|
+
}, {});
|
|
1403
|
+
this.pushStateToConfigurator();
|
|
1404
|
+
};
|
|
1405
|
+
SpacesState.prototype.resetInternalState = function () {
|
|
1406
|
+
if (this._attributesState)
|
|
1407
|
+
this.setAttributesToState(this._attributesState);
|
|
1408
|
+
};
|
|
1409
|
+
SpacesState.prototype.highlightElementIfInProximity = function (canvas, cursorPoint) {
|
|
1410
|
+
var _a, _b;
|
|
1411
|
+
var point = this.transformPointFromCanvas(cursorPoint);
|
|
1412
|
+
var elementAtPoint = this.getElementAddressAtPoint(point);
|
|
1413
|
+
if ((!elementAtPoint && !this._highlightedElement) ||
|
|
1414
|
+
Array.isArray(this._highlightedElement))
|
|
1415
|
+
return;
|
|
1416
|
+
if (elementAtPoint) {
|
|
1417
|
+
var type = elementAtPoint.type, index = elementAtPoint.index;
|
|
1418
|
+
if (((_a = this._highlightedElement) === null || _a === void 0 ? void 0 : _a.type) === type &&
|
|
1419
|
+
((_b = this._highlightedElement) === null || _b === void 0 ? void 0 : _b.index) === index)
|
|
1420
|
+
return;
|
|
1421
|
+
}
|
|
1422
|
+
this._highlightedElement = elementAtPoint !== null && elementAtPoint !== void 0 ? elementAtPoint : null;
|
|
1423
|
+
this.drawSpaces(canvas);
|
|
1424
|
+
};
|
|
1425
|
+
SpacesState.prototype.centerSpace = function (canvas, zoomToFit) {
|
|
1426
|
+
if (zoomToFit === void 0) { zoomToFit = true; }
|
|
1427
|
+
if (!canvas)
|
|
1428
|
+
return;
|
|
1429
|
+
if (!this.verticesList.length)
|
|
1430
|
+
return;
|
|
1431
|
+
var _a = this.verticesList.reduce(function (output, _a, i) {
|
|
1432
|
+
var point = _a.point;
|
|
1433
|
+
if (!i)
|
|
1434
|
+
return {
|
|
1435
|
+
xMin: point[0],
|
|
1436
|
+
yMin: point[1],
|
|
1437
|
+
xMax: point[0],
|
|
1438
|
+
yMax: point[1],
|
|
1439
|
+
};
|
|
1440
|
+
if (point[0] < output.xMin)
|
|
1441
|
+
output.xMin = point[0];
|
|
1442
|
+
if (point[1] < output.yMin)
|
|
1443
|
+
output.yMin = point[1];
|
|
1444
|
+
if (point[0] > output.xMax)
|
|
1445
|
+
output.xMax = point[0];
|
|
1446
|
+
if (point[1] > output.yMax)
|
|
1447
|
+
output.yMax = point[1];
|
|
1448
|
+
return output;
|
|
1449
|
+
}, { xMin: 0, yMin: 0, xMax: 0, yMax: 0 }), xMin = _a.xMin, yMin = _a.yMin, xMax = _a.xMax, yMax = _a.yMax;
|
|
1450
|
+
var centerPoint = [(xMin + xMax) / 2, (yMin + yMax) / 2];
|
|
1451
|
+
this._translate = [
|
|
1452
|
+
canvas.width / 2 - centerPoint[0],
|
|
1453
|
+
canvas.height / 2 - centerPoint[1],
|
|
1454
|
+
];
|
|
1455
|
+
if (zoomToFit)
|
|
1456
|
+
this.zoomFactor = Math.min((canvas.width - 80) / (xMax - xMin), (canvas.height - 80) / (yMax - yMin));
|
|
1457
|
+
this.drawSpaces(canvas);
|
|
1458
|
+
};
|
|
1459
|
+
SpacesState.prototype.showGuideAtPoint = function (canvas, cursorPoint) {
|
|
1460
|
+
var _this = this;
|
|
1461
|
+
if (!this.guideSnappingEnabled)
|
|
1462
|
+
return;
|
|
1463
|
+
var clearGuides = function () {
|
|
1464
|
+
if (!_this.guides)
|
|
1465
|
+
return;
|
|
1466
|
+
_this.guides = null;
|
|
1467
|
+
_this.drawSpaces(canvas);
|
|
1468
|
+
};
|
|
1469
|
+
var point = this.transformPointFromCanvas(cursorPoint);
|
|
1470
|
+
var elementAtPoint = this.getElementAddressAtPoint(point);
|
|
1471
|
+
if (elementAtPoint) {
|
|
1472
|
+
clearGuides();
|
|
1473
|
+
if (elementAtPoint.type === types_1.IElements.WALL ||
|
|
1474
|
+
elementAtPoint.type === types_1.IElements.VERTEX) {
|
|
1475
|
+
this._highlightedElement = elementAtPoint;
|
|
1476
|
+
this.drawSpaces(canvas);
|
|
1477
|
+
}
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
else if (this._highlightedElement) {
|
|
1481
|
+
this._highlightedElement = null;
|
|
1482
|
+
this.drawSpaces(canvas);
|
|
1483
|
+
}
|
|
1484
|
+
var snapPoint = this.getSnapVertexToGuideInProximity({
|
|
1485
|
+
type: types_1.SNAPPING_TYPES.NONE,
|
|
1486
|
+
point: point,
|
|
1487
|
+
locked: [false, false],
|
|
1488
|
+
}) || null;
|
|
1489
|
+
if (snapPoint.type === types_1.SNAPPING_TYPES.NONE) {
|
|
1490
|
+
clearGuides();
|
|
1491
|
+
return;
|
|
1492
|
+
}
|
|
1493
|
+
else if (snapPoint.type === types_1.SNAPPING_TYPES.GUIDE) {
|
|
1494
|
+
this.guides = snapPoint;
|
|
1495
|
+
this.drawSpaces(canvas);
|
|
1496
|
+
}
|
|
1497
|
+
};
|
|
1498
|
+
SpacesState.prototype.startDrawNewWall = function (startPoint) {
|
|
1499
|
+
if (this.guides) {
|
|
1500
|
+
this._newWall = {
|
|
1501
|
+
start: __assign(__assign({ type: types_1.SNAPPING_TYPES.GUIDE }, this.guides), { locked: [true, true] }),
|
|
1502
|
+
};
|
|
1503
|
+
return;
|
|
1504
|
+
}
|
|
1505
|
+
var point = this.transformPointFromCanvas(startPoint);
|
|
1506
|
+
var snapPoint = this.getSnapPointToElementInProximity(point);
|
|
1507
|
+
snapPoint = this.getSnapPointToGridInProximity(snapPoint);
|
|
1508
|
+
if (snapPoint.type === types_1.IElements.WINDOW ||
|
|
1509
|
+
snapPoint.type === types_1.IElements.DOOR ||
|
|
1510
|
+
snapPoint.type === types_1.IElements.OPENING)
|
|
1511
|
+
return;
|
|
1512
|
+
this._newWall = {
|
|
1513
|
+
start: snapPoint,
|
|
1514
|
+
};
|
|
1515
|
+
};
|
|
1516
|
+
SpacesState.prototype.drawNewWall = function (canvas, endPoint) {
|
|
1517
|
+
var _a;
|
|
1518
|
+
if (!this._newWall)
|
|
1519
|
+
return;
|
|
1520
|
+
var point = this.transformPointFromCanvas(endPoint);
|
|
1521
|
+
var snapPoint = this.getSnapPointToElementInProximity(point);
|
|
1522
|
+
snapPoint = this.getSnapVertexToGuideInProximity(snapPoint);
|
|
1523
|
+
snapPoint = this.getSnapPointToAngleInProximity(snapPoint);
|
|
1524
|
+
snapPoint = this.getSnapPointToGridInProximity(snapPoint);
|
|
1525
|
+
if (this.guideSnappingEnabled) {
|
|
1526
|
+
if (snapPoint.type === types_1.SNAPPING_TYPES.GUIDE ||
|
|
1527
|
+
snapPoint.type === types_1.SNAPPING_TYPES.ANGLE ||
|
|
1528
|
+
snapPoint.type === types_1.SNAPPING_TYPES.GRID)
|
|
1529
|
+
this.guides = snapPoint;
|
|
1530
|
+
else if (this.guides)
|
|
1531
|
+
this.guides = null;
|
|
1532
|
+
}
|
|
1533
|
+
var wallLine = [
|
|
1534
|
+
this._newWall.start.point,
|
|
1535
|
+
snapPoint.point,
|
|
1536
|
+
];
|
|
1537
|
+
var validationData = {
|
|
1538
|
+
newWall: __assign({ line: wallLine }, this._newWall),
|
|
1539
|
+
};
|
|
1540
|
+
this._errorElement = this.runValidators([
|
|
1541
|
+
validators_1.isWallEndingOnFeature,
|
|
1542
|
+
validators_1.isWallTooShort,
|
|
1543
|
+
validators_1.isWallOverlappingExisitingWalls,
|
|
1544
|
+
validators_1.isWallIntersectingFeature,
|
|
1545
|
+
], validationData);
|
|
1546
|
+
var errorType = ((_a = this._errorElement) === null || _a === void 0 ? void 0 : _a[0].type) || null;
|
|
1547
|
+
switch (errorType) {
|
|
1548
|
+
case types_1.IErrorTypes.HARD:
|
|
1549
|
+
return;
|
|
1550
|
+
case types_1.IErrorTypes.SOFT:
|
|
1551
|
+
case types_1.IErrorTypes.WARN:
|
|
1552
|
+
case null:
|
|
1553
|
+
default:
|
|
1554
|
+
this._newWall.end = snapPoint || { type: types_1.SNAPPING_TYPES.NONE, point: point };
|
|
1555
|
+
this.drawSpaces(canvas);
|
|
1556
|
+
break;
|
|
1557
|
+
}
|
|
1558
|
+
};
|
|
1559
|
+
SpacesState.prototype.cancelDrawNewWall = function (canvas) {
|
|
1560
|
+
this._newWall = null;
|
|
1561
|
+
this._errorElement = null;
|
|
1562
|
+
this._highlightedElement = null;
|
|
1563
|
+
this.guides = null;
|
|
1564
|
+
this.drawSpaces(canvas);
|
|
1565
|
+
};
|
|
1566
|
+
SpacesState.prototype.finishDrawNewWall = function (canvas, assetId) {
|
|
1567
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1568
|
+
var newWallAssetId, _a, start, end, wallsToExclude, filteredWalls, intersections, newWallLines;
|
|
1569
|
+
var _this = this;
|
|
1570
|
+
return __generator(this, function (_b) {
|
|
1571
|
+
if (this._errorElement) {
|
|
1572
|
+
if ([this._errorElement].flat()[0].message)
|
|
1573
|
+
__1.message.info([this._errorElement].flat()[0].message);
|
|
1574
|
+
this._newWall = null;
|
|
1575
|
+
this._errorElement = null;
|
|
1576
|
+
this._highlightedElement = null;
|
|
1577
|
+
this.drawSpaces(canvas);
|
|
1578
|
+
return [2];
|
|
1579
|
+
}
|
|
1580
|
+
newWallAssetId = assetId || this.attributeDefaults[types_1.IElements.WALL];
|
|
1581
|
+
if (!newWallAssetId)
|
|
1582
|
+
return [2];
|
|
1583
|
+
_a = this._newWall || {}, start = _a.start, end = _a.end;
|
|
1584
|
+
if (!start || !end) {
|
|
1585
|
+
this._newWall = null;
|
|
1586
|
+
this._errorElement = null;
|
|
1587
|
+
this._highlightedElement = null;
|
|
1588
|
+
return [2];
|
|
1589
|
+
}
|
|
1590
|
+
wallsToExclude = new Set([]);
|
|
1591
|
+
if (start.type === types_1.IElements.WALL) {
|
|
1592
|
+
this.splitWallAtPoint(start.index, start.point);
|
|
1593
|
+
wallsToExclude.add(start.index);
|
|
1594
|
+
}
|
|
1595
|
+
if (end.type === types_1.IElements.WALL) {
|
|
1596
|
+
this.splitWallAtPoint(end.index, end.point);
|
|
1597
|
+
wallsToExclude.add(end.index);
|
|
1598
|
+
}
|
|
1599
|
+
if (wallsToExclude.size === 1)
|
|
1600
|
+
wallsToExclude.add(this.wallCount - 1);
|
|
1601
|
+
else if (wallsToExclude.size === 2)
|
|
1602
|
+
wallsToExclude.add(this.wallCount - 1).add(this.wallCount - 2);
|
|
1603
|
+
filteredWalls = this.walls.map(function (wall, i) {
|
|
1604
|
+
return wallsToExclude.has(i) ? null : wall.line;
|
|
1605
|
+
});
|
|
1606
|
+
intersections = (0, geometry_1.getAllLineIntersections)([start.point, end.point], filteredWalls);
|
|
1607
|
+
intersections.forEach(function (_a) {
|
|
1608
|
+
var index = _a.index, point = _a.point;
|
|
1609
|
+
return _this.splitWallAtPoint(index, point);
|
|
1610
|
+
});
|
|
1611
|
+
newWallLines = (0, geometry_1.splitLineAtPoints)([start.point, end.point], intersections.map(function (_a) {
|
|
1612
|
+
var point = _a.point;
|
|
1613
|
+
return point;
|
|
1614
|
+
}));
|
|
1615
|
+
this.addWalls(newWallLines.map(function (line) { return ({
|
|
1616
|
+
assetId: newWallAssetId,
|
|
1617
|
+
line: line,
|
|
1618
|
+
connections: [],
|
|
1619
|
+
restConfiguration: JSON.stringify({}),
|
|
1620
|
+
visible: true,
|
|
1621
|
+
}); }));
|
|
1622
|
+
this._newWall = null;
|
|
1623
|
+
this._errorElement = null;
|
|
1624
|
+
this._highlightedElement = null;
|
|
1625
|
+
this.guides = null;
|
|
1626
|
+
this.pushStateToConfigurator();
|
|
1627
|
+
return [2];
|
|
1628
|
+
});
|
|
1629
|
+
});
|
|
1630
|
+
};
|
|
1631
|
+
SpacesState.prototype.selectElementIfInProximity = function (canvas, cursorPoint) {
|
|
1632
|
+
var point = this.transformPointFromCanvas(cursorPoint);
|
|
1633
|
+
var elementAtPoint = this.getElementAddressAtPoint(point);
|
|
1634
|
+
if (!elementAtPoint || elementAtPoint.type === types_1.IElements.WALL)
|
|
1635
|
+
return;
|
|
1636
|
+
this._activeElement = elementAtPoint;
|
|
1637
|
+
if (elementAtPoint.type === types_1.IElements.VERTEX) {
|
|
1638
|
+
var wallIndexes = this.getWallsConnectedToVertex(elementAtPoint.index);
|
|
1639
|
+
this._highlightedElement = wallIndexes.map(function (index) { return ({
|
|
1640
|
+
type: types_1.IElements.WALL,
|
|
1641
|
+
index: index,
|
|
1642
|
+
}); });
|
|
1643
|
+
}
|
|
1644
|
+
this.drawSpaces(canvas);
|
|
1645
|
+
};
|
|
1646
|
+
SpacesState.prototype.moveActiveElement = function (canvas, moveToPoint) {
|
|
1647
|
+
if (!canvas)
|
|
1648
|
+
return;
|
|
1649
|
+
if (!this._activeElement)
|
|
1650
|
+
return;
|
|
1651
|
+
var point = this.transformPointFromCanvas(moveToPoint);
|
|
1652
|
+
var type = this._activeElement.type;
|
|
1653
|
+
if (type === types_1.IElements.VERTEX)
|
|
1654
|
+
this.moveActiveVertex(canvas, point);
|
|
1655
|
+
else if (type === types_1.IElements.WINDOW ||
|
|
1656
|
+
type === types_1.IElements.DOOR ||
|
|
1657
|
+
type === types_1.IElements.OPENING)
|
|
1658
|
+
this.moveActiveFeature(canvas, point);
|
|
1659
|
+
};
|
|
1660
|
+
SpacesState.prototype.finishMoveActiveElement = function (canvas) {
|
|
1661
|
+
if (!this._activeElement)
|
|
1662
|
+
return;
|
|
1663
|
+
if (this._errorElement) {
|
|
1664
|
+
if ([this._errorElement].flat()[0].message)
|
|
1665
|
+
__1.message.info([this._errorElement].flat()[0].message);
|
|
1666
|
+
this._activeElement = null;
|
|
1667
|
+
this._errorElement = null;
|
|
1668
|
+
this._highlightedElement = null;
|
|
1669
|
+
this.resetInternalState();
|
|
1670
|
+
this.drawSpaces(canvas);
|
|
1671
|
+
return;
|
|
1672
|
+
}
|
|
1673
|
+
var type = this._activeElement.type;
|
|
1674
|
+
if (type === types_1.IElements.VERTEX)
|
|
1675
|
+
this.finishMoveActiveVertex();
|
|
1676
|
+
else if (type === types_1.IElements.WINDOW ||
|
|
1677
|
+
type === types_1.IElements.DOOR ||
|
|
1678
|
+
type === types_1.IElements.OPENING)
|
|
1679
|
+
this.finishMoveActiveFeature();
|
|
1680
|
+
this._activeElement = null;
|
|
1681
|
+
this._errorElement = null;
|
|
1682
|
+
this._highlightedElement = null;
|
|
1683
|
+
this.drawSpaces(canvas);
|
|
1684
|
+
};
|
|
1685
|
+
SpacesState.prototype.cancelMoveActiveElement = function (canvas) {
|
|
1686
|
+
this._activeElement = null;
|
|
1687
|
+
this._errorElement = null;
|
|
1688
|
+
this._highlightedElement = null;
|
|
1689
|
+
this.resetInternalState();
|
|
1690
|
+
this.drawSpaces(canvas);
|
|
1691
|
+
};
|
|
1692
|
+
SpacesState.prototype.drawSpaces = function (canvas) {
|
|
1693
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1694
|
+
if (!canvas)
|
|
1695
|
+
return;
|
|
1696
|
+
var highlighted = this._highlightedElement
|
|
1697
|
+
? [this._highlightedElement].flat()
|
|
1698
|
+
: [];
|
|
1699
|
+
var active = this._activeElement && this._activeElement.type !== types_1.IElements.VERTEX
|
|
1700
|
+
? [this._activeElement]
|
|
1701
|
+
: [];
|
|
1702
|
+
var error = this._errorElement
|
|
1703
|
+
? [this._errorElement]
|
|
1704
|
+
.flat()
|
|
1705
|
+
.reduce(function (output, _a) {
|
|
1706
|
+
var address = _a.address;
|
|
1707
|
+
return (address ? __spreadArray(__spreadArray([], output, true), [address], false) : output);
|
|
1708
|
+
}, [])
|
|
1709
|
+
: [];
|
|
1710
|
+
var hidden = ((_a = this._activeElement) === null || _a === void 0 ? void 0 : _a.type) === types_1.IElements.VERTEX
|
|
1711
|
+
? [this._activeElement]
|
|
1712
|
+
: [];
|
|
1713
|
+
if (this.selectedElement)
|
|
1714
|
+
highlighted.push(this.selectedElement);
|
|
1715
|
+
var selection = {
|
|
1716
|
+
highlighted: highlighted,
|
|
1717
|
+
active: active,
|
|
1718
|
+
error: error,
|
|
1719
|
+
hidden: hidden,
|
|
1720
|
+
};
|
|
1721
|
+
var activeWallIndex;
|
|
1722
|
+
if (this._showDimensions &&
|
|
1723
|
+
(((_b = this._activeElement) === null || _b === void 0 ? void 0 : _b.type) === types_1.IElements.WINDOW ||
|
|
1724
|
+
((_c = this._activeElement) === null || _c === void 0 ? void 0 : _c.type) === types_1.IElements.DOOR ||
|
|
1725
|
+
((_d = this._activeElement) === null || _d === void 0 ? void 0 : _d.type) === types_1.IElements.OPENING))
|
|
1726
|
+
activeWallIndex = (_e = this.getFeature(this._activeElement.type, this._activeElement.index)) === null || _e === void 0 ? void 0 : _e.connectedTo[1];
|
|
1727
|
+
var guides = this.guides
|
|
1728
|
+
? __assign(__assign({}, this.guides), { point: this.transformPointToCanvas(this.guides.point) }) : this.guides;
|
|
1729
|
+
(0, draw_1.drawSpaces)(canvas, this.gridToDraw, this.enclosedSpacesToDraw, this.wallsToDraw, this.verticesListToDraw, this.featuresToDraw, this._showDimensions
|
|
1730
|
+
? this.getAllWallDimensionsToDraw(activeWallIndex)
|
|
1731
|
+
: undefined, guides, selection, this._config.config);
|
|
1732
|
+
if (((_f = this._newWall) === null || _f === void 0 ? void 0 : _f.start) && ((_g = this._newWall) === null || _g === void 0 ? void 0 : _g.end)) {
|
|
1733
|
+
var newWallLine = [
|
|
1734
|
+
this._newWall.start.point,
|
|
1735
|
+
this._newWall.end.point,
|
|
1736
|
+
];
|
|
1737
|
+
(0, draw_1.drawNewWall)(canvas, this.transformLineToCanvas(newWallLine), this.styles, this._errorElement ? types_1.IElementStyleModes.ERROR : undefined);
|
|
1738
|
+
if (this._showDimensions) {
|
|
1739
|
+
(0, draw_1.drawDimensions)(canvas, [
|
|
1740
|
+
{
|
|
1741
|
+
label: this.getWallDimensions(newWallLine).label,
|
|
1742
|
+
line: this.transformLineToCanvas(newWallLine),
|
|
1743
|
+
},
|
|
1744
|
+
], this._config.config);
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
};
|
|
1748
|
+
return SpacesState;
|
|
1749
|
+
}());
|
|
1750
|
+
exports.SpacesState = SpacesState;
|
|
1751
|
+
exports.default = SpacesState;
|