@threekit-tools/treble 0.0.90-next-09 → 0.0.91
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 +2 -2
- package/dist/Treble/index.d.ts +1 -1
- package/dist/Treble/index.js +1 -1
- package/dist/hooks/useNestedConfigurator/index.js +2 -1
- package/dist/hooks/useRoomBuilder/RoomBuilderState.d.ts +95 -0
- package/dist/hooks/useRoomBuilder/RoomBuilderState.js +1237 -0
- package/dist/hooks/useRoomBuilder/constants.d.ts +41 -0
- package/dist/hooks/useRoomBuilder/constants.js +48 -0
- package/dist/hooks/{useSpaces → useRoomBuilder}/dataHandlers.d.ts +4 -6
- package/dist/hooks/{useSpaces → useRoomBuilder}/dataHandlers.js +40 -102
- package/dist/hooks/useRoomBuilder/draw.d.ts +55 -0
- package/dist/hooks/useRoomBuilder/draw.js +573 -0
- package/dist/hooks/useRoomBuilder/findLoops.d.ts +5 -0
- package/dist/hooks/{useSpaces/geometry → useRoomBuilder}/findLoops.js +9 -14
- package/dist/hooks/useRoomBuilder/geometry.d.ts +33 -0
- package/dist/hooks/useRoomBuilder/geometry.js +325 -0
- package/dist/hooks/useRoomBuilder/index.d.ts +40 -0
- package/dist/hooks/useRoomBuilder/index.js +303 -0
- package/dist/hooks/{useSpaces/validators → useRoomBuilder}/messaging.js +1 -1
- package/dist/hooks/{useSpaces/themes/index.d.ts → useRoomBuilder/themes.d.ts} +4 -3
- package/dist/hooks/useRoomBuilder/themes.js +273 -0
- package/dist/hooks/{useSpaces → useRoomBuilder}/types.d.ts +35 -130
- package/dist/hooks/{useSpaces → useRoomBuilder}/types.js +1 -13
- package/dist/hooks/useRoomBuilder/validators.d.ts +36 -0
- package/dist/hooks/useRoomBuilder/validators.js +362 -0
- package/dist/hooks/useSpaces/Canvas.d.ts +37 -0
- package/dist/hooks/useSpaces/Canvas.js +199 -0
- 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/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 +0 -2
- package/dist/icons/types.d.ts +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.js +5 -9
- package/dist/store/attributes.d.ts +0 -1
- package/dist/store/index.d.ts +0 -10
- package/dist/store/index.js +1 -3
- package/dist/store/treble.js +17 -21
- package/dist/types.d.ts +3 -5
- package/package.json +1 -1
- package/dist/hooks/useSpaces/SpacesLayout.d.ts +0 -11
- package/dist/hooks/useSpaces/SpacesLayout.js +0 -74
- package/dist/hooks/useSpaces/SpacesState.d.ts +0 -162
- package/dist/hooks/useSpaces/SpacesState.js +0 -1759
- package/dist/hooks/useSpaces/constants.d.ts +0 -44
- package/dist/hooks/useSpaces/constants.js +0 -105
- package/dist/hooks/useSpaces/draw/clearCanvas.d.ts +0 -2
- package/dist/hooks/useSpaces/draw/clearCanvas.js +0 -9
- package/dist/hooks/useSpaces/draw/drawBackground.d.ts +0 -2
- package/dist/hooks/useSpaces/draw/drawBackground.js +0 -12
- package/dist/hooks/useSpaces/draw/drawDimensions.d.ts +0 -3
- package/dist/hooks/useSpaces/draw/drawDimensions.js +0 -53
- package/dist/hooks/useSpaces/draw/drawDoors.d.ts +0 -9
- package/dist/hooks/useSpaces/draw/drawDoors.js +0 -93
- package/dist/hooks/useSpaces/draw/drawFloor.d.ts +0 -3
- package/dist/hooks/useSpaces/draw/drawFloor.js +0 -36
- package/dist/hooks/useSpaces/draw/drawGrid.d.ts +0 -3
- package/dist/hooks/useSpaces/draw/drawGrid.js +0 -33
- package/dist/hooks/useSpaces/draw/drawGuides.d.ts +0 -3
- package/dist/hooks/useSpaces/draw/drawGuides.js +0 -23
- package/dist/hooks/useSpaces/draw/drawOpenings.d.ts +0 -9
- package/dist/hooks/useSpaces/draw/drawOpenings.js +0 -72
- package/dist/hooks/useSpaces/draw/drawVertices.d.ts +0 -8
- package/dist/hooks/useSpaces/draw/drawVertices.js +0 -61
- package/dist/hooks/useSpaces/draw/drawWalls.d.ts +0 -10
- package/dist/hooks/useSpaces/draw/drawWalls.js +0 -64
- package/dist/hooks/useSpaces/draw/drawWindows.d.ts +0 -9
- package/dist/hooks/useSpaces/draw/drawWindows.js +0 -82
- package/dist/hooks/useSpaces/draw/index.d.ts +0 -11
- package/dist/hooks/useSpaces/draw/index.js +0 -129
- package/dist/hooks/useSpaces/geometry/addThicknessToLine.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/addThicknessToLine.js +0 -13
- package/dist/hooks/useSpaces/geometry/areLinesEqual.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/areLinesEqual.js +0 -17
- package/dist/hooks/useSpaces/geometry/arePointsEqual.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/arePointsEqual.js +0 -8
- package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.js +0 -11
- package/dist/hooks/useSpaces/geometry/closestPointOnLine.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/closestPointOnLine.js +0 -13
- package/dist/hooks/useSpaces/geometry/doLinesOverlap.d.ts +0 -2
- package/dist/hooks/useSpaces/geometry/doLinesOverlap.js +0 -16
- package/dist/hooks/useSpaces/geometry/euclideanMod.d.ts +0 -2
- package/dist/hooks/useSpaces/geometry/euclideanMod.js +0 -6
- package/dist/hooks/useSpaces/geometry/findLoops.d.ts +0 -6
- package/dist/hooks/useSpaces/geometry/getAllLineIntersections.d.ts +0 -6
- package/dist/hooks/useSpaces/geometry/getAllLineIntersections.js +0 -23
- package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.js +0 -7
- package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.js +0 -17
- package/dist/hooks/useSpaces/geometry/getDistanceToLine.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getDistanceToLine.js +0 -10
- package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.js +0 -7
- package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.js +0 -17
- package/dist/hooks/useSpaces/geometry/getLineOtherPoint.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getLineOtherPoint.js +0 -11
- package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.js +0 -43
- package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.js +0 -9
- package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.js +0 -20
- package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.js +0 -11
- package/dist/hooks/useSpaces/geometry/getPolygonArea.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getPolygonArea.js +0 -15
- package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.js +0 -16
- package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.d.ts +0 -6
- package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.js +0 -17
- package/dist/hooks/useSpaces/geometry/getTriangleArea.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getTriangleArea.js +0 -9
- package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.js +0 -12
- package/dist/hooks/useSpaces/geometry/index.d.ts +0 -30
- package/dist/hooks/useSpaces/geometry/index.js +0 -64
- package/dist/hooks/useSpaces/geometry/isPointInPolygon.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/isPointInPolygon.js +0 -21
- package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.js +0 -25
- package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.js +0 -11
- package/dist/hooks/useSpaces/geometry/splitLineAtOffset.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/splitLineAtOffset.js +0 -12
- package/dist/hooks/useSpaces/geometry/splitLineAtPoint.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/splitLineAtPoint.js +0 -9
- package/dist/hooks/useSpaces/geometry/splitLineAtPoints.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/splitLineAtPoints.js +0 -28
- package/dist/hooks/useSpaces/index.d.ts +0 -76
- package/dist/hooks/useSpaces/index.js +0 -474
- package/dist/hooks/useSpaces/themes/blueprint.d.ts +0 -3
- package/dist/hooks/useSpaces/themes/blueprint.js +0 -96
- package/dist/hooks/useSpaces/themes/default.d.ts +0 -3
- package/dist/hooks/useSpaces/themes/default.js +0 -96
- package/dist/hooks/useSpaces/themes/index.js +0 -21
- package/dist/hooks/useSpaces/themes/light.d.ts +0 -3
- package/dist/hooks/useSpaces/themes/light.js +0 -96
- package/dist/hooks/useSpaces/validators/areWallsDuplicated.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/areWallsDuplicated.js +0 -61
- package/dist/hooks/useSpaces/validators/areWallsIntersecting.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/areWallsIntersecting.js +0 -42
- package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.js +0 -52
- package/dist/hooks/useSpaces/validators/areWallsTooShort.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/areWallsTooShort.js +0 -37
- package/dist/hooks/useSpaces/validators/index.d.ts +0 -15
- package/dist/hooks/useSpaces/validators/index.js +0 -40
- package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.js +0 -31
- package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.js +0 -19
- package/dist/hooks/useSpaces/validators/isLineTooShort.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isLineTooShort.js +0 -26
- package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.d.ts +0 -4
- package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.js +0 -19
- package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.js +0 -19
- package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.js +0 -41
- package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.js +0 -54
- package/dist/hooks/useSpaces/validators/isWallTooShort.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isWallTooShort.js +0 -10
- package/dist/icons/Player3D.d.ts +0 -3
- package/dist/icons/Player3D.js +0 -21
- package/dist/store/spaces.d.ts +0 -47
- package/dist/store/spaces.js +0 -197
- /package/dist/Treble/{snapshot.d.ts → snapshots.d.ts} +0 -0
- /package/dist/Treble/{snapshot.js → snapshots.js} +0 -0
- /package/dist/hooks/{useSpaces/validators → useRoomBuilder}/messaging.d.ts +0 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.runValidators = exports.isVertexLandingOnFeature = exports.areWallsDuplicated = exports.areWallsOrphaningFeatures = exports.areWallsIntersecting = exports.areWallsTooShort = exports.isFeatureCollidingWithExistingFeature = exports.isFeatureOutsideWallBounds = exports.isWallEndingOnFeature = exports.isWallOverlappingExisitingWalls = exports.isWallIntersectingFeature = exports.isWallTooShort = void 0;
|
|
13
|
+
var types_1 = require("./types");
|
|
14
|
+
var geometry_1 = require("./geometry");
|
|
15
|
+
var messaging_1 = require("./messaging");
|
|
16
|
+
var constants_1 = require("./constants");
|
|
17
|
+
function isLineTooShort(wallOrLine) {
|
|
18
|
+
var minLength = constants_1.MIN_WALL_LENGTH;
|
|
19
|
+
var line = Array.isArray(wallOrLine) ? wallOrLine : wallOrLine.line;
|
|
20
|
+
var tooClose = geometry_1.arePointsWithinProximity.apply(void 0, __spreadArray(__spreadArray([], line, false), [minLength], false));
|
|
21
|
+
if (tooClose)
|
|
22
|
+
return {
|
|
23
|
+
message: messaging_1.errorMessages.wallTooShort(),
|
|
24
|
+
type: types_1.IErrorTypes.HARD,
|
|
25
|
+
};
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
function isWallTooShort(input) {
|
|
29
|
+
return isLineTooShort(input.newWall.line);
|
|
30
|
+
}
|
|
31
|
+
exports.isWallTooShort = isWallTooShort;
|
|
32
|
+
function isWallIntersectingFeature(input) {
|
|
33
|
+
var _a;
|
|
34
|
+
var newWall = input.newWall, walls = input.walls, features = input.features;
|
|
35
|
+
if (!walls.length || !Object.values(features).flat().length)
|
|
36
|
+
return false;
|
|
37
|
+
var intersectingFeature;
|
|
38
|
+
for (var i = 0; i < walls.length && !intersectingFeature; i++) {
|
|
39
|
+
if (!walls[i].connections)
|
|
40
|
+
continue;
|
|
41
|
+
var intersectionPoint = (0, geometry_1.getLineSegmentsIntersection)(newWall.line, walls[i].line);
|
|
42
|
+
if (!intersectionPoint)
|
|
43
|
+
continue;
|
|
44
|
+
var intersectionOffset = (0, geometry_1.getLengthOfLineSegment)([
|
|
45
|
+
walls[i].line[0],
|
|
46
|
+
intersectionPoint,
|
|
47
|
+
]);
|
|
48
|
+
for (var j = 0; j < walls[i].connections.length && !intersectingFeature; j++) {
|
|
49
|
+
var _b = walls[i].connections[j], type = _b[0], index = _b[1];
|
|
50
|
+
var feature = (_a = features[type]) === null || _a === void 0 ? void 0 : _a[index];
|
|
51
|
+
if (!feature)
|
|
52
|
+
continue;
|
|
53
|
+
if (feature.offset < intersectionOffset &&
|
|
54
|
+
intersectionOffset < feature.offset + feature.length)
|
|
55
|
+
intersectingFeature = { type: type, index: index };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!intersectingFeature)
|
|
59
|
+
return false;
|
|
60
|
+
return ({
|
|
61
|
+
address: intersectingFeature,
|
|
62
|
+
message: messaging_1.errorMessages.addWallCollidingWithFeature(intersectingFeature.type),
|
|
63
|
+
type: types_1.IErrorTypes.SOFT,
|
|
64
|
+
} || false);
|
|
65
|
+
}
|
|
66
|
+
exports.isWallIntersectingFeature = isWallIntersectingFeature;
|
|
67
|
+
function isWallOverlappingExisitingWalls(input) {
|
|
68
|
+
var newWall = input.newWall, walls = input.walls;
|
|
69
|
+
var snapStartTo = newWall.snapStartTo, snapEndTo = newWall.snapEndTo;
|
|
70
|
+
if ((snapStartTo === null || snapStartTo === void 0 ? void 0 : snapStartTo.type) === types_1.IElements.WALL &&
|
|
71
|
+
(snapEndTo === null || snapEndTo === void 0 ? void 0 : snapEndTo.type) === types_1.IElements.WALL &&
|
|
72
|
+
snapStartTo.index === snapEndTo.index) {
|
|
73
|
+
return {
|
|
74
|
+
address: {
|
|
75
|
+
type: types_1.IElements.WALL,
|
|
76
|
+
index: snapStartTo.index,
|
|
77
|
+
},
|
|
78
|
+
type: types_1.IErrorTypes.SOFT,
|
|
79
|
+
message: messaging_1.errorMessages.wallsNotUnique(),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
var overlappingIndex = walls.findIndex(function (wall, i) {
|
|
83
|
+
var line = wall.line;
|
|
84
|
+
if ((0, geometry_1.areLinesEqual)(line, newWall.line))
|
|
85
|
+
return true;
|
|
86
|
+
if ((snapStartTo === null || snapStartTo === void 0 ? void 0 : snapStartTo.type) === types_1.IElements.VERTEX &&
|
|
87
|
+
((0, geometry_1.arePointsEqual)(snapStartTo.point, line[0]) ||
|
|
88
|
+
(0, geometry_1.arePointsEqual)(snapStartTo.point, line[1])) &&
|
|
89
|
+
(snapEndTo === null || snapEndTo === void 0 ? void 0 : snapEndTo.type) === types_1.IElements.WALL &&
|
|
90
|
+
snapEndTo.index === i) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
if ((snapEndTo === null || snapEndTo === void 0 ? void 0 : snapEndTo.type) === types_1.IElements.VERTEX &&
|
|
94
|
+
((0, geometry_1.arePointsEqual)(snapEndTo.point, line[0]) ||
|
|
95
|
+
(0, geometry_1.arePointsEqual)(snapEndTo.point, line[1])) &&
|
|
96
|
+
(snapStartTo === null || snapStartTo === void 0 ? void 0 : snapStartTo.type) === types_1.IElements.WALL &&
|
|
97
|
+
snapStartTo.index === i) {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
return false;
|
|
101
|
+
});
|
|
102
|
+
if (overlappingIndex !== -1) {
|
|
103
|
+
return {
|
|
104
|
+
address: {
|
|
105
|
+
type: types_1.IElements.WALL,
|
|
106
|
+
index: overlappingIndex,
|
|
107
|
+
},
|
|
108
|
+
type: types_1.IErrorTypes.SOFT,
|
|
109
|
+
message: messaging_1.errorMessages.wallsNotUnique(),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
exports.isWallOverlappingExisitingWalls = isWallOverlappingExisitingWalls;
|
|
115
|
+
function isWallEndingOnFeature(input) {
|
|
116
|
+
var snapPoint = input.newWall.snapEndTo;
|
|
117
|
+
if (!snapPoint)
|
|
118
|
+
return false;
|
|
119
|
+
if (snapPoint.type === types_1.IElements.WINDOW ||
|
|
120
|
+
snapPoint.type === types_1.IElements.DOOR ||
|
|
121
|
+
snapPoint.type === types_1.IElements.OPENING)
|
|
122
|
+
return {
|
|
123
|
+
address: snapPoint,
|
|
124
|
+
message: messaging_1.errorMessages.addWallCollidingWithFeature(snapPoint.type),
|
|
125
|
+
type: types_1.IErrorTypes.SOFT,
|
|
126
|
+
};
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
exports.isWallEndingOnFeature = isWallEndingOnFeature;
|
|
130
|
+
function isFeatureOutsideWallBounds(input) {
|
|
131
|
+
var wall = input.wall, updatedFeature = input.updatedFeature;
|
|
132
|
+
var padding = constants_1.WALL_PADDING_FOR_FEATURE;
|
|
133
|
+
var wallLength = (0, geometry_1.getLengthOfLineSegment)(wall.line);
|
|
134
|
+
if (updatedFeature.offset < padding ||
|
|
135
|
+
updatedFeature.offset + updatedFeature.length > wallLength - padding)
|
|
136
|
+
return {
|
|
137
|
+
address: updatedFeature.address,
|
|
138
|
+
type: types_1.IErrorTypes.HARD,
|
|
139
|
+
message: messaging_1.errorMessages.featureOutsideWallBounds(),
|
|
140
|
+
};
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
exports.isFeatureOutsideWallBounds = isFeatureOutsideWallBounds;
|
|
144
|
+
function isFeatureCollidingWithExistingFeature(input) {
|
|
145
|
+
var _a, _b;
|
|
146
|
+
var features = input.features, wall = input.wall, updatedFeature = input.updatedFeature;
|
|
147
|
+
if (!features || !((_a = wall.connections) === null || _a === void 0 ? void 0 : _a.length))
|
|
148
|
+
return false;
|
|
149
|
+
if (!Object.values(updatedFeature).flat().length)
|
|
150
|
+
return false;
|
|
151
|
+
for (var i = 0; i < wall.connections.length; i++) {
|
|
152
|
+
var _c = wall.connections[i], type = _c[0], index = _c[1];
|
|
153
|
+
if (updatedFeature.address.type === type &&
|
|
154
|
+
updatedFeature.address.index === index)
|
|
155
|
+
continue;
|
|
156
|
+
var existingFeature = (_b = features[type]) === null || _b === void 0 ? void 0 : _b[index];
|
|
157
|
+
if (!existingFeature)
|
|
158
|
+
continue;
|
|
159
|
+
if ((0, geometry_1.doLinesOverlap)([updatedFeature.offset, updatedFeature.length], [existingFeature.offset, existingFeature.length]))
|
|
160
|
+
return {
|
|
161
|
+
address: { type: type, index: index },
|
|
162
|
+
type: types_1.IErrorTypes.SOFT,
|
|
163
|
+
message: messaging_1.errorMessages.featuresColliding(type),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
exports.isFeatureCollidingWithExistingFeature = isFeatureCollidingWithExistingFeature;
|
|
169
|
+
function areWallsTooShort(input) {
|
|
170
|
+
var walls = input.walls, vertex = input.vertex, updatedPosition = input.updatedPosition;
|
|
171
|
+
var _a = vertex.connections.reduce(function (output, connection) {
|
|
172
|
+
var _a;
|
|
173
|
+
var wallIndex = connection[0], vertexIndex = connection[1];
|
|
174
|
+
output.wallIndexes.push(wallIndex);
|
|
175
|
+
output.updatedVerticesMap = Object.assign(output.updatedVerticesMap, (_a = {},
|
|
176
|
+
_a[wallIndex] = vertexIndex,
|
|
177
|
+
_a));
|
|
178
|
+
return output;
|
|
179
|
+
}, {
|
|
180
|
+
wallIndexes: [],
|
|
181
|
+
updatedVerticesMap: {},
|
|
182
|
+
}), wallIndexes = _a.wallIndexes, updatedVerticesMap = _a.updatedVerticesMap;
|
|
183
|
+
for (var _i = 0, wallIndexes_1 = wallIndexes; _i < wallIndexes_1.length; _i++) {
|
|
184
|
+
var index = wallIndexes_1[_i];
|
|
185
|
+
var line = walls[index].line;
|
|
186
|
+
line[updatedVerticesMap[index]] = updatedPosition.point;
|
|
187
|
+
if (isLineTooShort(line))
|
|
188
|
+
return {
|
|
189
|
+
address: { type: types_1.IElements.WALL, index: index },
|
|
190
|
+
message: messaging_1.errorMessages.wallTooShort(),
|
|
191
|
+
type: types_1.IErrorTypes.HARD,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
exports.areWallsTooShort = areWallsTooShort;
|
|
197
|
+
function areWallsIntersecting(input) {
|
|
198
|
+
var walls = input.walls, vertex = input.vertex, updatedPosition = input.updatedPosition;
|
|
199
|
+
var _a = vertex.connections.reduce(function (output, connection) {
|
|
200
|
+
var _a;
|
|
201
|
+
var wallIndex = connection[0], vertexIndex = connection[1];
|
|
202
|
+
output.wallIndexes.add(wallIndex);
|
|
203
|
+
output.updatedVerticesMap = Object.assign(output.updatedVerticesMap, (_a = {},
|
|
204
|
+
_a[wallIndex] = vertexIndex,
|
|
205
|
+
_a));
|
|
206
|
+
return output;
|
|
207
|
+
}, {
|
|
208
|
+
wallIndexes: new Set([]),
|
|
209
|
+
updatedVerticesMap: {},
|
|
210
|
+
}), wallIndexes = _a.wallIndexes, updatedVerticesMap = _a.updatedVerticesMap;
|
|
211
|
+
for (var _i = 0, _b = Array.from(wallIndexes); _i < _b.length; _i++) {
|
|
212
|
+
var validateWallIndex = _b[_i];
|
|
213
|
+
var line = walls[validateWallIndex].line;
|
|
214
|
+
line[updatedVerticesMap[validateWallIndex]] = updatedPosition.point;
|
|
215
|
+
for (var i = 0; i < walls.length; i++) {
|
|
216
|
+
if (wallIndexes.has(i))
|
|
217
|
+
continue;
|
|
218
|
+
var wall = walls[i];
|
|
219
|
+
if (!wall)
|
|
220
|
+
continue;
|
|
221
|
+
var intersectionPoint = (0, geometry_1.getLineSegmentsIntersection)(line, wall.line);
|
|
222
|
+
if (intersectionPoint)
|
|
223
|
+
return {
|
|
224
|
+
address: { type: types_1.IElements.WALL, index: i },
|
|
225
|
+
message: messaging_1.errorMessages.addWallCollidingWithWall(),
|
|
226
|
+
type: types_1.IErrorTypes.SOFT,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
exports.areWallsIntersecting = areWallsIntersecting;
|
|
233
|
+
function areWallsOrphaningFeatures(input) {
|
|
234
|
+
var _a;
|
|
235
|
+
var walls = input.walls, vertex = input.vertex, features = input.features, updatedPosition = input.updatedPosition;
|
|
236
|
+
var _b = vertex.connections.reduce(function (output, connection) {
|
|
237
|
+
var _a;
|
|
238
|
+
var wallIndex = connection[0], vertexIndex = connection[1];
|
|
239
|
+
output.wallIndexes.add(wallIndex);
|
|
240
|
+
output.updatedVerticesMap = Object.assign(output.updatedVerticesMap, (_a = {},
|
|
241
|
+
_a[wallIndex] = vertexIndex,
|
|
242
|
+
_a));
|
|
243
|
+
return output;
|
|
244
|
+
}, {
|
|
245
|
+
wallIndexes: new Set([]),
|
|
246
|
+
updatedVerticesMap: {},
|
|
247
|
+
}), wallIndexes = _b.wallIndexes, updatedVerticesMap = _b.updatedVerticesMap;
|
|
248
|
+
for (var _i = 0, _c = Array.from(wallIndexes); _i < _c.length; _i++) {
|
|
249
|
+
var wallIdx = _c[_i];
|
|
250
|
+
var wall = walls[wallIdx];
|
|
251
|
+
if (!wall.connections.length)
|
|
252
|
+
continue;
|
|
253
|
+
var updatedLine = JSON.parse(JSON.stringify(wall.line));
|
|
254
|
+
updatedLine[updatedVerticesMap[wallIdx]] = updatedPosition.point;
|
|
255
|
+
var currentWallLength = (0, geometry_1.getLengthOfLineSegment)(wall.line);
|
|
256
|
+
var updatedWallLength = (0, geometry_1.getLengthOfLineSegment)(updatedLine);
|
|
257
|
+
var wallLengthDelta = updatedWallLength - currentWallLength;
|
|
258
|
+
for (var i = 0; i < wall.connections.length; i++) {
|
|
259
|
+
var _d = wall.connections[i], type = _d[0], index = _d[1];
|
|
260
|
+
var feat = (_a = features[type]) === null || _a === void 0 ? void 0 : _a[index];
|
|
261
|
+
if (!feat)
|
|
262
|
+
continue;
|
|
263
|
+
var error = {
|
|
264
|
+
address: { type: type, index: index },
|
|
265
|
+
message: 'feature collision',
|
|
266
|
+
type: types_1.IErrorTypes.HARD,
|
|
267
|
+
};
|
|
268
|
+
if (updatedVerticesMap[wallIdx] === 0 &&
|
|
269
|
+
feat.offset - wallLengthDelta < constants_1.WALL_PADDING_FOR_FEATURE)
|
|
270
|
+
return error;
|
|
271
|
+
else if (feat.offset + feat.length >
|
|
272
|
+
updatedWallLength - constants_1.WALL_PADDING_FOR_FEATURE) {
|
|
273
|
+
return error;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
exports.areWallsOrphaningFeatures = areWallsOrphaningFeatures;
|
|
280
|
+
function areWallsDuplicated(input) {
|
|
281
|
+
var _a, _b, _c;
|
|
282
|
+
var walls = input.walls, vertex = input.vertex, updatedPosition = input.updatedPosition;
|
|
283
|
+
var point = (_b = (_a = updatedPosition.snapTo) === null || _a === void 0 ? void 0 : _a.point) !== null && _b !== void 0 ? _b : updatedPosition.point;
|
|
284
|
+
var _d = vertex.connections.reduce(function (output, connection) {
|
|
285
|
+
var _a;
|
|
286
|
+
var wallIndex = connection[0], vertexIndex = connection[1];
|
|
287
|
+
output.wallIndexes.add(wallIndex);
|
|
288
|
+
output.updatedVerticesMap = Object.assign(output.updatedVerticesMap, (_a = {},
|
|
289
|
+
_a[wallIndex] = vertexIndex,
|
|
290
|
+
_a));
|
|
291
|
+
return output;
|
|
292
|
+
}, {
|
|
293
|
+
wallIndexes: new Set([]),
|
|
294
|
+
updatedVerticesMap: {},
|
|
295
|
+
}), wallIndexes = _d.wallIndexes, updatedVerticesMap = _d.updatedVerticesMap;
|
|
296
|
+
for (var _i = 0, _e = Array.from(wallIndexes); _i < _e.length; _i++) {
|
|
297
|
+
var wallIdx = _e[_i];
|
|
298
|
+
var wall = walls[wallIdx];
|
|
299
|
+
var updatedLine = JSON.parse(JSON.stringify(wall.line));
|
|
300
|
+
updatedLine[updatedVerticesMap[wallIdx]] = point;
|
|
301
|
+
if (((_c = updatedPosition.snapTo) === null || _c === void 0 ? void 0 : _c.type) === types_1.IElements.WALL &&
|
|
302
|
+
updatedPosition.snapTo.index !== wallIdx) {
|
|
303
|
+
var _f = walls[updatedPosition.snapTo.index].line, xTest = _f[0], yTest = _f[1];
|
|
304
|
+
var unmovedPoint = updatedLine[updatedVerticesMap[wallIdx] === 1 ? 0 : 1];
|
|
305
|
+
if ((0, geometry_1.arePointsEqual)(unmovedPoint, xTest) ||
|
|
306
|
+
(0, geometry_1.arePointsEqual)(unmovedPoint, yTest))
|
|
307
|
+
return {
|
|
308
|
+
address: {
|
|
309
|
+
type: types_1.IElements.WALL,
|
|
310
|
+
index: updatedPosition.snapTo.index,
|
|
311
|
+
},
|
|
312
|
+
type: types_1.IErrorTypes.SOFT,
|
|
313
|
+
message: messaging_1.errorMessages.wallsNotUnique(),
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
for (var i = 0; i < walls.length; i++) {
|
|
317
|
+
if (wallIdx === i)
|
|
318
|
+
continue;
|
|
319
|
+
var existingWall = walls[i];
|
|
320
|
+
var error = {
|
|
321
|
+
address: { type: types_1.IElements.WALL, index: i },
|
|
322
|
+
type: types_1.IErrorTypes.SOFT,
|
|
323
|
+
message: messaging_1.errorMessages.wallsNotUnique(),
|
|
324
|
+
};
|
|
325
|
+
if (((0, geometry_1.arePointsEqual)(existingWall[0], wall.line[0]) &&
|
|
326
|
+
(0, geometry_1.arePointsEqual)(existingWall[1], wall.line[1])) ||
|
|
327
|
+
((0, geometry_1.arePointsEqual)(existingWall[0], wall.line[1]) &&
|
|
328
|
+
(0, geometry_1.arePointsEqual)(existingWall[1], wall.line[0]))) {
|
|
329
|
+
return error;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
exports.areWallsDuplicated = areWallsDuplicated;
|
|
336
|
+
function isVertexLandingOnFeature(input) {
|
|
337
|
+
var snapPoint = input.updatedPosition.snapTo;
|
|
338
|
+
if (!snapPoint)
|
|
339
|
+
return false;
|
|
340
|
+
if (snapPoint.type === types_1.IElements.WINDOW ||
|
|
341
|
+
snapPoint.type === types_1.IElements.DOOR ||
|
|
342
|
+
snapPoint.type === types_1.IElements.OPENING)
|
|
343
|
+
return {
|
|
344
|
+
address: snapPoint,
|
|
345
|
+
message: messaging_1.errorMessages.addWallCollidingWithFeature(snapPoint.type),
|
|
346
|
+
type: types_1.IErrorTypes.SOFT,
|
|
347
|
+
};
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
exports.isVertexLandingOnFeature = isVertexLandingOnFeature;
|
|
351
|
+
function runValidators(validators, input) {
|
|
352
|
+
var errors = validators.reduce(function (output, validate) {
|
|
353
|
+
var error = validate(input);
|
|
354
|
+
if (error)
|
|
355
|
+
output.push(error);
|
|
356
|
+
return output;
|
|
357
|
+
}, []);
|
|
358
|
+
if (errors.length)
|
|
359
|
+
return errors;
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
exports.runValidators = runValidators;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ICoordinate2D, ICoordinatesLine, IGridToDraw, IUnits } from './types';
|
|
2
|
+
declare class Canvas {
|
|
3
|
+
private _scale;
|
|
4
|
+
private _dimensions;
|
|
5
|
+
private _zoom;
|
|
6
|
+
private _zoomLimits;
|
|
7
|
+
private _translate;
|
|
8
|
+
private _translateLimits;
|
|
9
|
+
private _unit;
|
|
10
|
+
constructor(scale: number, dimensions: ICoordinate2D, zoom: number, translate: ICoordinate2D, unit: IUnits);
|
|
11
|
+
get dimensions(): ICoordinate2D;
|
|
12
|
+
set dimensions(dimensions: ICoordinate2D);
|
|
13
|
+
get width(): ICoordinate2D;
|
|
14
|
+
get height(): ICoordinate2D;
|
|
15
|
+
get zoom(): number;
|
|
16
|
+
set zoom(delta: number);
|
|
17
|
+
get zoomFactor(): number;
|
|
18
|
+
set zoomFactor(val: number);
|
|
19
|
+
get zoomMin(): ICoordinate2D;
|
|
20
|
+
get zoomMax(): ICoordinate2D;
|
|
21
|
+
get translate(): ICoordinate2D;
|
|
22
|
+
get translateMin(): ICoordinatesLine;
|
|
23
|
+
get translateMax(): ICoordinatesLine;
|
|
24
|
+
set translate(position: ICoordinate2D);
|
|
25
|
+
get unit(): IUnits;
|
|
26
|
+
set unit(unit: IUnits);
|
|
27
|
+
get gridUnitLength(): number;
|
|
28
|
+
get gridUnitLengthToDraw(): number;
|
|
29
|
+
get gridOffset(): ICoordinate2D;
|
|
30
|
+
get gridToDraw(): IGridToDraw;
|
|
31
|
+
transformLengthFromCanvas(length: number): number;
|
|
32
|
+
transformLengthToCanvas(length: number): number;
|
|
33
|
+
transformPointToCanvas(point: ICoordinate2D): ICoordinate2D;
|
|
34
|
+
transformPointFromCanvas(point: ICoordinate2D): ICoordinate2D;
|
|
35
|
+
transformLineToCanvas(line: ICoordinatesLine): ICoordinatesLine;
|
|
36
|
+
}
|
|
37
|
+
export default Canvas;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var constants_1 = require("./constants");
|
|
4
|
+
var dataHandlers_1 = require("./dataHandlers");
|
|
5
|
+
var types_1 = require("./types");
|
|
6
|
+
var Canvas = (function () {
|
|
7
|
+
function Canvas(scale, dimensions, zoom, translate, unit) {
|
|
8
|
+
this._scale = scale;
|
|
9
|
+
this._dimensions = dimensions;
|
|
10
|
+
this._zoom = zoom;
|
|
11
|
+
this._zoomLimits = [constants_1.ZOOM_MIN, constants_1.ZOOM_MAX];
|
|
12
|
+
this._translate = translate;
|
|
13
|
+
this._translateLimits = [constants_1.TRANSLATE_MIN, constants_1.TRANSLATE_MAX];
|
|
14
|
+
this._unit = unit;
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(Canvas.prototype, "dimensions", {
|
|
17
|
+
get: function () {
|
|
18
|
+
return this._dimensions;
|
|
19
|
+
},
|
|
20
|
+
set: function (dimensions) {
|
|
21
|
+
this._dimensions = dimensions;
|
|
22
|
+
},
|
|
23
|
+
enumerable: false,
|
|
24
|
+
configurable: true
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(Canvas.prototype, "width", {
|
|
27
|
+
get: function () {
|
|
28
|
+
return this._dimensions[0];
|
|
29
|
+
},
|
|
30
|
+
enumerable: false,
|
|
31
|
+
configurable: true
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(Canvas.prototype, "height", {
|
|
34
|
+
get: function () {
|
|
35
|
+
return this._dimensions[1];
|
|
36
|
+
},
|
|
37
|
+
enumerable: false,
|
|
38
|
+
configurable: true
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(Canvas.prototype, "zoom", {
|
|
41
|
+
get: function () {
|
|
42
|
+
return this._zoom;
|
|
43
|
+
},
|
|
44
|
+
set: function (delta) {
|
|
45
|
+
var newZoom = this.zoom + delta;
|
|
46
|
+
var preppedZoom = newZoom < this.zoomMin
|
|
47
|
+
? this.zoomMin
|
|
48
|
+
: newZoom > this.zoomMax
|
|
49
|
+
? this.zoomMax
|
|
50
|
+
: newZoom;
|
|
51
|
+
if (preppedZoom === this.zoom)
|
|
52
|
+
return;
|
|
53
|
+
this._zoom = preppedZoom;
|
|
54
|
+
},
|
|
55
|
+
enumerable: false,
|
|
56
|
+
configurable: true
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(Canvas.prototype, "zoomFactor", {
|
|
59
|
+
get: function () {
|
|
60
|
+
return this._zoom / this.zoomMin;
|
|
61
|
+
},
|
|
62
|
+
set: function (val) {
|
|
63
|
+
var updatedZoom = val * this.zoomMin;
|
|
64
|
+
if (updatedZoom < this.zoomMin)
|
|
65
|
+
this._zoom = this.zoomMin;
|
|
66
|
+
else if (updatedZoom > this.zoomMax)
|
|
67
|
+
this._zoom = this.zoomMax;
|
|
68
|
+
else
|
|
69
|
+
this._zoom = updatedZoom;
|
|
70
|
+
},
|
|
71
|
+
enumerable: false,
|
|
72
|
+
configurable: true
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(Canvas.prototype, "zoomMin", {
|
|
75
|
+
get: function () {
|
|
76
|
+
return this._zoomLimits[0];
|
|
77
|
+
},
|
|
78
|
+
enumerable: false,
|
|
79
|
+
configurable: true
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(Canvas.prototype, "zoomMax", {
|
|
82
|
+
get: function () {
|
|
83
|
+
return this._zoomLimits[1];
|
|
84
|
+
},
|
|
85
|
+
enumerable: false,
|
|
86
|
+
configurable: true
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(Canvas.prototype, "translate", {
|
|
89
|
+
get: function () {
|
|
90
|
+
return this._translate;
|
|
91
|
+
},
|
|
92
|
+
set: function (position) {
|
|
93
|
+
var zoomFactor = this._zoom / this.zoomMin;
|
|
94
|
+
var delta = [
|
|
95
|
+
(position[0] - this._translate[0]) / zoomFactor,
|
|
96
|
+
(position[1] - this._translate[1]) / zoomFactor,
|
|
97
|
+
];
|
|
98
|
+
this._translate = [
|
|
99
|
+
this._translate[0] + delta[0],
|
|
100
|
+
this._translate[1] + delta[1],
|
|
101
|
+
];
|
|
102
|
+
},
|
|
103
|
+
enumerable: false,
|
|
104
|
+
configurable: true
|
|
105
|
+
});
|
|
106
|
+
Object.defineProperty(Canvas.prototype, "translateMin", {
|
|
107
|
+
get: function () {
|
|
108
|
+
return this._translateLimits[0];
|
|
109
|
+
},
|
|
110
|
+
enumerable: false,
|
|
111
|
+
configurable: true
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(Canvas.prototype, "translateMax", {
|
|
114
|
+
get: function () {
|
|
115
|
+
return this._translateLimits[1];
|
|
116
|
+
},
|
|
117
|
+
enumerable: false,
|
|
118
|
+
configurable: true
|
|
119
|
+
});
|
|
120
|
+
Object.defineProperty(Canvas.prototype, "unit", {
|
|
121
|
+
get: function () {
|
|
122
|
+
return this._unit;
|
|
123
|
+
},
|
|
124
|
+
set: function (unit) {
|
|
125
|
+
this._unit = unit;
|
|
126
|
+
},
|
|
127
|
+
enumerable: false,
|
|
128
|
+
configurable: true
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(Canvas.prototype, "gridUnitLength", {
|
|
131
|
+
get: function () {
|
|
132
|
+
var length = [types_1.IUnits.FEET, types_1.IUnits.INCH].includes(this.unit)
|
|
133
|
+
? (0, dataHandlers_1.convertLengthUnit)(1, types_1.IUnits.FEET, types_1.IUnits.METER)
|
|
134
|
+
: 1;
|
|
135
|
+
return length / this._scale;
|
|
136
|
+
},
|
|
137
|
+
enumerable: false,
|
|
138
|
+
configurable: true
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(Canvas.prototype, "gridUnitLengthToDraw", {
|
|
141
|
+
get: function () {
|
|
142
|
+
return this.transformLengthToCanvas(this.gridUnitLength);
|
|
143
|
+
},
|
|
144
|
+
enumerable: false,
|
|
145
|
+
configurable: true
|
|
146
|
+
});
|
|
147
|
+
Object.defineProperty(Canvas.prototype, "gridOffset", {
|
|
148
|
+
get: function () {
|
|
149
|
+
var gridLength = this.gridUnitLengthToDraw;
|
|
150
|
+
var translate = this.transformPointToCanvas([0, 0]);
|
|
151
|
+
return [translate[0] % gridLength, translate[1] % gridLength];
|
|
152
|
+
},
|
|
153
|
+
enumerable: false,
|
|
154
|
+
configurable: true
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(Canvas.prototype, "gridToDraw", {
|
|
157
|
+
get: function () {
|
|
158
|
+
return {
|
|
159
|
+
unitLength: this.gridUnitLengthToDraw,
|
|
160
|
+
offset: this.gridOffset,
|
|
161
|
+
subdivisions: [types_1.IUnits.FEET, types_1.IUnits.INCH].includes(this.unit) ? 4 : 5,
|
|
162
|
+
};
|
|
163
|
+
},
|
|
164
|
+
enumerable: false,
|
|
165
|
+
configurable: true
|
|
166
|
+
});
|
|
167
|
+
Canvas.prototype.transformLengthFromCanvas = function (length) {
|
|
168
|
+
return length / this.zoomFactor;
|
|
169
|
+
};
|
|
170
|
+
Canvas.prototype.transformLengthToCanvas = function (length) {
|
|
171
|
+
return length * this.zoomFactor;
|
|
172
|
+
};
|
|
173
|
+
Canvas.prototype.transformPointToCanvas = function (point) {
|
|
174
|
+
var widthOffset = this.width / 2;
|
|
175
|
+
var heightOffset = this.height / 2;
|
|
176
|
+
return [
|
|
177
|
+
this.transformLengthToCanvas(point[0] + this.translate[0]) -
|
|
178
|
+
widthOffset * (this.zoomFactor - 1),
|
|
179
|
+
this.transformLengthToCanvas(point[1] + this.translate[1]) -
|
|
180
|
+
heightOffset * (this.zoomFactor - 1),
|
|
181
|
+
];
|
|
182
|
+
};
|
|
183
|
+
Canvas.prototype.transformPointFromCanvas = function (point) {
|
|
184
|
+
var widthOffset = this.width / 2;
|
|
185
|
+
var heightOffset = this.height / 2;
|
|
186
|
+
return [
|
|
187
|
+
this.transformLengthFromCanvas(point[0] + widthOffset * (this.zoomFactor - 1)) - this.translate[0],
|
|
188
|
+
this.transformLengthFromCanvas(point[1] + heightOffset * (this.zoomFactor - 1)) - this.translate[1],
|
|
189
|
+
];
|
|
190
|
+
};
|
|
191
|
+
Canvas.prototype.transformLineToCanvas = function (line) {
|
|
192
|
+
return [
|
|
193
|
+
this.transformPointToCanvas(line[0]),
|
|
194
|
+
this.transformPointToCanvas(line[1]),
|
|
195
|
+
];
|
|
196
|
+
};
|
|
197
|
+
return Canvas;
|
|
198
|
+
}());
|
|
199
|
+
exports.default = Canvas;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.AngleSnapping = void 0;
|
|
11
|
+
var react_1 = __importDefault(require("react"));
|
|
12
|
+
var styled_components_1 = __importDefault(require("styled-components"));
|
|
13
|
+
var Path = styled_components_1.default.path(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n fill: ", ";\n"], ["\n fill: ", ";\n"])), function (props) { return props.color || props.theme.textColor; });
|
|
14
|
+
var AngleSnapping = function (props) {
|
|
15
|
+
return (react_1.default.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
16
|
+
react_1.default.createElement(Path, { color: props.color, fillRule: "evenodd", clipRule: "evenodd", d: "M7.45664 2.10874C7.58614 1.9779 7.78102 1.99096 7.89191 2.13791L18.7612 16.5419C18.8196 16.6192 18.8431 16.7182 18.8333 16.8137C18.8515 16.855 18.8616 16.9007 18.8615 16.9488C18.8611 17.1329 18.7116 17.2816 18.5275 17.2809L9.33325 17.2483V16.5817L12.7405 16.5937C12.7363 16.453 12.7372 16.2902 12.7486 16.1119C12.7862 15.5202 12.9395 14.743 13.409 14.0338C13.9153 13.2692 14.4387 12.8542 14.8471 12.6305C14.8805 12.6122 14.913 12.5953 14.9447 12.5795L7.42294 2.61173C7.31205 2.46478 7.32714 2.23959 7.45664 2.10874ZM15.3807 13.1573C15.3115 13.1845 15.231 13.221 15.1418 13.2698C14.8153 13.4486 14.3648 13.7971 13.9152 14.4761C13.5326 15.0539 13.4031 15.6943 13.371 16.1987C13.3617 16.3457 13.3607 16.4799 13.3639 16.596L17.9879 16.6124L15.3807 13.1573Z" }),
|
|
17
|
+
react_1.default.createElement(Path, { color: props.color, "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M1.66468 16.5545L1.60623 16.5543C1.42214 16.5536 1.2726 16.7023 1.27222 16.8864C1.27184 17.0705 1.42078 17.2203 1.60487 17.2209L1.93253 17.2221C2.09272 17.5251 2.29725 17.805 2.53549 18.0511C3.10732 18.6419 3.8835 19.0488 4.73024 19.1115C5.57476 19.1741 6.46997 18.8928 7.27794 18.1457L7.27956 18.1473L9.76024 15.6895C9.8647 15.586 9.8647 15.4182 9.76024 15.3147L9.61838 15.1742L9.61601 15.1765L8.81017 14.3782L8.81254 14.3758L8.67069 14.2353C8.56622 14.1318 8.39686 14.1318 8.2924 14.2353L5.91771 16.588C5.35754 17.0597 4.64816 16.9369 4.19905 16.5135C3.97593 16.3031 3.82824 16.0264 3.80058 15.7276C3.77376 15.4377 3.858 15.1085 4.12828 14.7765L6.48347 12.4431C6.58793 12.3396 6.58793 12.1718 6.48347 12.0683L6.34161 11.9277L6.33924 11.9301L5.53341 11.1317L5.53578 11.1293L5.39392 10.9888C5.28946 10.8853 5.1201 10.8853 5.01563 10.9888L2.59608 13.386L2.5952 13.3851C1.82198 14.1335 1.51256 15.0044 1.54953 15.8427C1.56022 16.0852 1.59981 16.3237 1.66468 16.5545ZM2.01719 15.8225C1.98628 15.1215 2.2403 14.3785 2.91927 13.7198L2.92021 13.7207L4.18812 12.4645L4.99396 13.2629L3.78537 14.4603L3.81872 14.4934L3.78202 14.4633C3.42861 14.8872 3.29485 15.3423 3.33442 15.7699C3.37364 16.1937 3.58121 16.5712 3.87635 16.8495C4.46377 17.4033 5.44326 17.5956 6.22055 16.941L6.20546 16.9234L6.22332 16.9411L7.39801 15.7773L8.20385 16.5756L6.97892 17.7892L6.97811 17.7884C6.25369 18.4671 5.47724 18.7018 4.76516 18.6491C4.04771 18.5959 3.37567 18.2491 2.87336 17.7301C2.37094 17.211 2.04839 16.53 2.01719 15.8225ZM5.31013 12.9497L6.02307 12.2433L5.21724 11.4449L4.50429 12.1513L5.31013 12.9497ZM9.29984 15.4898L8.52002 16.2624L7.71418 15.464L8.494 14.6914L9.29984 15.4898Z" }),
|
|
18
|
+
react_1.default.createElement(Path, { color: props.color, d: "M5.86834 8.88C5.73908 8.88 5.63429 8.98382 5.63429 9.11189V10.2382C5.63429 10.3663 5.73908 10.4701 5.86834 10.4701C5.99761 10.4701 6.1024 10.3663 6.1024 10.2382V9.11189C6.1024 8.98382 5.99761 8.88 5.86834 8.88Z" }),
|
|
19
|
+
react_1.default.createElement(Path, { color: props.color, d: "M9.21198 12.1927C9.08272 12.1927 8.97793 12.2966 8.97793 12.4246V13.5509C8.97793 13.679 9.08272 13.7828 9.21198 13.7828C9.34125 13.7828 9.44604 13.679 9.44604 13.5509V12.4246C9.44604 12.2966 9.34125 12.1927 9.21198 12.1927Z" }),
|
|
20
|
+
react_1.default.createElement(Path, { color: props.color, d: "M6.838 11.6958C6.838 11.8239 6.94279 11.9277 7.07205 11.9277H8.20889C8.33816 11.9277 8.44295 11.8239 8.44295 11.6958C8.44295 11.5678 8.33816 11.4639 8.20889 11.4639H7.07205C6.94279 11.4639 6.838 11.5678 6.838 11.6958Z" }),
|
|
21
|
+
react_1.default.createElement(Path, { color: props.color, d: "M10.1816 15.0085C10.1816 15.1366 10.2864 15.2404 10.4157 15.2404H11.5525C11.6818 15.2404 11.7866 15.1366 11.7866 15.0085C11.7866 14.8805 11.6818 14.7767 11.5525 14.7767H10.4157C10.2864 14.7767 10.1816 14.8805 10.1816 15.0085Z" }),
|
|
22
|
+
react_1.default.createElement(Path, { color: props.color, d: "M7.80401 9.57401C7.7126 9.48345 7.56441 9.48345 7.473 9.57401L6.66914 10.3704C6.57773 10.461 6.57773 10.6078 6.66914 10.6984C6.76054 10.7889 6.90874 10.7889 7.00014 10.6984L7.80401 9.90195C7.89541 9.81139 7.89541 9.66457 7.80401 9.57401Z" }),
|
|
23
|
+
react_1.default.createElement(Path, { color: props.color, d: "M11.1476 12.8867C11.0562 12.7962 10.908 12.7962 10.8166 12.8867L10.0128 13.6832C9.92137 13.7737 9.92137 13.9206 10.0128 14.0111C10.1042 14.1017 10.2524 14.1017 10.3438 14.0111L11.1476 13.2147C11.239 13.1241 11.239 12.9773 11.1476 12.8867Z" })));
|
|
24
|
+
};
|
|
25
|
+
exports.AngleSnapping = AngleSnapping;
|
|
26
|
+
exports.AngleSnapping.iconName = 'angle-snapping';
|
|
27
|
+
exports.default = exports.AngleSnapping;
|
|
28
|
+
var templateObject_1;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.Center = void 0;
|
|
11
|
+
var react_1 = __importDefault(require("react"));
|
|
12
|
+
var styled_components_1 = __importDefault(require("styled-components"));
|
|
13
|
+
var Path = styled_components_1.default.path(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n fill: ", ";\n"], ["\n fill: ", ";\n"])), function (props) { return props.color || props.theme.textColor || 'white'; });
|
|
14
|
+
var Center = function (props) {
|
|
15
|
+
return (react_1.default.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
16
|
+
react_1.default.createElement(Path, { color: props.color, d: "M1.52851 2.47141L5.72377 6.66666H3.99992C3.63173 6.66666 3.33325 6.96513 3.33325 7.33332C3.33325 7.70151 3.63173 7.99999 3.99992 7.99999H7.33325C7.70144 7.99999 7.99992 7.70151 7.99992 7.33332V3.99999C7.99992 3.6318 7.70144 3.33332 7.33325 3.33332C6.96506 3.33332 6.66659 3.6318 6.66659 3.99999V5.72386L2.47132 1.5286C2.21097 1.26825 1.78886 1.26825 1.52851 1.5286C1.26816 1.78895 1.26816 2.21106 1.52851 2.47141Z" }),
|
|
17
|
+
react_1.default.createElement(Path, { color: props.color, d: "M18.4713 2.47141L14.2761 6.66666H15.9999C16.3681 6.66666 16.6666 6.96513 16.6666 7.33332C16.6666 7.70151 16.3681 7.99999 15.9999 7.99999H12.6666C12.2984 7.99999 11.9999 7.70151 11.9999 7.33332V3.99999C11.9999 3.6318 12.2984 3.33332 12.6666 3.33332C13.0348 3.33332 13.3333 3.6318 13.3333 3.99999V5.72386L17.5285 1.5286C17.7889 1.26825 18.211 1.26825 18.4713 1.5286C18.7317 1.78895 18.7317 2.21106 18.4713 2.47141Z" }),
|
|
18
|
+
react_1.default.createElement(Path, { color: props.color, d: "M14.2761 13.3334L18.4713 17.5286C18.7317 17.7889 18.7317 18.2111 18.4713 18.4714C18.211 18.7318 17.7889 18.7318 17.5285 18.4714L13.3333 14.2761V16C13.3333 16.3682 13.0348 16.6667 12.6666 16.6667C12.2984 16.6667 11.9999 16.3682 11.9999 16V12.6667C11.9999 12.2985 12.2984 12 12.6666 12H15.9999C16.3681 12 16.6666 12.2985 16.6666 12.6667C16.6666 13.0349 16.3681 13.3334 15.9999 13.3334H14.2761Z" }),
|
|
19
|
+
react_1.default.createElement(Path, { color: props.color, d: "M1.52851 17.5286L5.72377 13.3334H3.99992C3.63173 13.3334 3.33325 13.0349 3.33325 12.6667C3.33325 12.2985 3.63173 12 3.99992 12H7.33325C7.70144 12 7.99992 12.2985 7.99992 12.6667V16C7.99992 16.3682 7.70144 16.6667 7.33325 16.6667C6.96506 16.6667 6.66659 16.3682 6.66659 16V14.2761L2.47132 18.4714C2.21097 18.7318 1.78886 18.7318 1.52851 18.4714C1.26816 18.2111 1.26816 17.7889 1.52851 17.5286Z" })));
|
|
20
|
+
};
|
|
21
|
+
exports.Center = Center;
|
|
22
|
+
exports.Center.iconName = 'center';
|
|
23
|
+
exports.default = exports.Center;
|
|
24
|
+
var templateObject_1;
|