@threekit-tools/treble 0.0.91 → 0.0.92
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 +1 -1
- package/dist/Treble/snapshot.d.ts +22 -0
- package/dist/Treble/snapshot.js +247 -0
- package/dist/Treble/snapshots.d.ts +1 -1
- package/dist/components/ThreekitProvider/index.js +3 -2
- package/dist/connection.d.ts +4 -1
- package/dist/connection.js +16 -53
- package/dist/hooks/useAttribute/index.js +1 -5
- package/dist/hooks/useSnapshot/index.d.ts +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/useSpaces/dataHandlers.d.ts +20 -0
- 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/useSpaces/geometry/findLoops.js +117 -0
- 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 +82 -0
- package/dist/hooks/useSpaces/index.js +482 -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/useSpaces/themes/index.d.ts +11 -0
- 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 +339 -0
- package/dist/hooks/useSpaces/types.js +54 -0
- 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/useSpaces/validators/messaging.d.ts +8 -0
- package/dist/hooks/useSpaces/validators/messaging.js +18 -0
- package/dist/icons/Player3D.d.ts +3 -0
- package/dist/icons/Player3D.js +21 -0
- package/dist/icons/Ruler copy.d.ts +3 -0
- package/dist/icons/Ruler copy.js +22 -0
- package/dist/icons/RulerBlank.d.ts +3 -0
- package/dist/icons/RulerBlank.js +25 -0
- package/dist/icons/RulerDetailed copy.d.ts +3 -0
- package/dist/icons/RulerDetailed copy.js +27 -0
- package/dist/icons/RulerDetailed.d.ts +3 -0
- package/dist/icons/RulerDetailed.js +27 -0
- package/dist/icons/types.d.ts +1 -1
- package/dist/store/attributes.d.ts +1 -1
- package/dist/store/index.d.ts +10 -31
- package/dist/store/spaces.d.ts +47 -0
- package/dist/store/spaces.js +197 -0
- package/dist/store/treble.d.ts +3 -1
- package/dist/store/treble.js +45 -30
- package/dist/store/wishlist.d.ts +20 -2
- package/dist/types.d.ts +12 -3
- package/package.json +2 -1
- package/dist/hooks/useSpaces/Canvas.d.ts +0 -37
- package/dist/hooks/useSpaces/Canvas.js +0 -199
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
var _a;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.IThemes = void 0;
|
|
8
|
+
var default_1 = __importDefault(require("./default"));
|
|
9
|
+
var blueprint_1 = __importDefault(require("./blueprint"));
|
|
10
|
+
var light_1 = __importDefault(require("./light"));
|
|
11
|
+
var IThemes;
|
|
12
|
+
(function (IThemes) {
|
|
13
|
+
IThemes["DEFAULT"] = "default";
|
|
14
|
+
IThemes["BLUEPRINT"] = "blueprint";
|
|
15
|
+
IThemes["LIGHT"] = "light";
|
|
16
|
+
})(IThemes = exports.IThemes || (exports.IThemes = {}));
|
|
17
|
+
exports.default = (_a = {},
|
|
18
|
+
_a[IThemes.DEFAULT] = default_1.default,
|
|
19
|
+
_a[IThemes.BLUEPRINT] = blueprint_1.default,
|
|
20
|
+
_a[IThemes.LIGHT] = light_1.default,
|
|
21
|
+
_a);
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var HIGHCOLOR = '#36738E';
|
|
4
|
+
var ACTIVE_COLOR = 'green';
|
|
5
|
+
var ERROR_COLOR = 'red';
|
|
6
|
+
var WALL_THICKNESS = 8;
|
|
7
|
+
var VERTEX_RADIUS = (WALL_THICKNESS + 8) / 2;
|
|
8
|
+
var FEATURE_THICKNESS = WALL_THICKNESS + 4;
|
|
9
|
+
var theme = {
|
|
10
|
+
grid: {
|
|
11
|
+
lineThickness: 2,
|
|
12
|
+
lineColor: '#ddd',
|
|
13
|
+
showSubdivisions: true,
|
|
14
|
+
subdivisionLineThickness: 1,
|
|
15
|
+
subdivisionLineColor: '#ddd',
|
|
16
|
+
subdivisionThreshold: 20,
|
|
17
|
+
backgroundColor: '#fff',
|
|
18
|
+
},
|
|
19
|
+
guides: {
|
|
20
|
+
color: '#00F8FB',
|
|
21
|
+
thickness: 1,
|
|
22
|
+
},
|
|
23
|
+
floor: {
|
|
24
|
+
color: '#eee',
|
|
25
|
+
textColor: '#666',
|
|
26
|
+
},
|
|
27
|
+
dimensions: {
|
|
28
|
+
padding: WALL_THICKNESS / 2 + 12,
|
|
29
|
+
lineThickness: 1,
|
|
30
|
+
lineColor: '#444',
|
|
31
|
+
fontSize: 14,
|
|
32
|
+
font: 'Helvetica',
|
|
33
|
+
textColor: '#444',
|
|
34
|
+
textBackgroundColor: '#fff',
|
|
35
|
+
},
|
|
36
|
+
wall: {
|
|
37
|
+
fill: '#000',
|
|
38
|
+
stroke: '#000',
|
|
39
|
+
strokeWidth: 0,
|
|
40
|
+
thickness: WALL_THICKNESS,
|
|
41
|
+
highlight: {
|
|
42
|
+
fill: HIGHCOLOR,
|
|
43
|
+
stroke: HIGHCOLOR,
|
|
44
|
+
},
|
|
45
|
+
active: {
|
|
46
|
+
fill: ACTIVE_COLOR,
|
|
47
|
+
stroke: ACTIVE_COLOR,
|
|
48
|
+
},
|
|
49
|
+
error: {
|
|
50
|
+
fill: ERROR_COLOR,
|
|
51
|
+
stroke: ERROR_COLOR,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
vertex: {
|
|
55
|
+
innerFill: '#aaa',
|
|
56
|
+
outerFill: '#fff',
|
|
57
|
+
stroke: '#000',
|
|
58
|
+
strokeWidth: 1,
|
|
59
|
+
outerRadius: VERTEX_RADIUS,
|
|
60
|
+
innerRadius: (VERTEX_RADIUS / 5) * 3,
|
|
61
|
+
highlight: {
|
|
62
|
+
innerFill: HIGHCOLOR,
|
|
63
|
+
outerFill: '#fff',
|
|
64
|
+
stroke: '#000',
|
|
65
|
+
},
|
|
66
|
+
active: {
|
|
67
|
+
innerFill: ACTIVE_COLOR,
|
|
68
|
+
outerFill: '#fff',
|
|
69
|
+
stroke: '#000',
|
|
70
|
+
},
|
|
71
|
+
error: {
|
|
72
|
+
innerFill: ERROR_COLOR,
|
|
73
|
+
outerFill: ERROR_COLOR,
|
|
74
|
+
stroke: ERROR_COLOR,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
feature: {
|
|
78
|
+
fill: '#888',
|
|
79
|
+
stroke: '#888',
|
|
80
|
+
strokeWidth: 0,
|
|
81
|
+
thickness: FEATURE_THICKNESS,
|
|
82
|
+
highlight: {
|
|
83
|
+
fill: HIGHCOLOR,
|
|
84
|
+
stroke: HIGHCOLOR,
|
|
85
|
+
},
|
|
86
|
+
active: {
|
|
87
|
+
fill: ACTIVE_COLOR,
|
|
88
|
+
stroke: ACTIVE_COLOR,
|
|
89
|
+
},
|
|
90
|
+
error: {
|
|
91
|
+
fill: ERROR_COLOR,
|
|
92
|
+
stroke: ERROR_COLOR,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
exports.default = theme;
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
export type ICoordinate2D = [x: number, y: number];
|
|
2
|
+
export type ICoordinate3D = [x: number, y: number, z: number];
|
|
3
|
+
export type ICoordinatesLine = [
|
|
4
|
+
startPoint: ICoordinate2D,
|
|
5
|
+
endPoint: ICoordinate2D
|
|
6
|
+
];
|
|
7
|
+
export type ICoordinatesQuadrilateral = [
|
|
8
|
+
point1: ICoordinate2D,
|
|
9
|
+
point2: ICoordinate2D,
|
|
10
|
+
point3: ICoordinate2D,
|
|
11
|
+
point4: ICoordinate2D
|
|
12
|
+
];
|
|
13
|
+
export declare enum IElements {
|
|
14
|
+
WALL = "walls",
|
|
15
|
+
VERTEX = "vertex",
|
|
16
|
+
FEATURE = "features",
|
|
17
|
+
WINDOW = "windows",
|
|
18
|
+
DOOR = "doors",
|
|
19
|
+
OPENING = "openings"
|
|
20
|
+
}
|
|
21
|
+
export type IFeatureName = IElements.WINDOW | IElements.DOOR | IElements.OPENING;
|
|
22
|
+
export type IElementName = IElements.WALL | IElements.VERTEX | IFeatureName;
|
|
23
|
+
export interface IWall {
|
|
24
|
+
assetId: string;
|
|
25
|
+
line: ICoordinatesLine;
|
|
26
|
+
path?: ICoordinatesQuadrilateral;
|
|
27
|
+
connections: Array<[elementType: IFeatureName, index: number]>;
|
|
28
|
+
restConfiguration: string;
|
|
29
|
+
visible: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface IWalls extends Array<IWall> {
|
|
32
|
+
}
|
|
33
|
+
export interface INewWall {
|
|
34
|
+
start: ISnapPoint;
|
|
35
|
+
end?: ISnapPoint;
|
|
36
|
+
}
|
|
37
|
+
export interface IVertexConnections extends Array<[wallIndex: number, anchorIndex: number]> {
|
|
38
|
+
}
|
|
39
|
+
export interface IVerticesState extends Record<string, IVertexConnections> {
|
|
40
|
+
}
|
|
41
|
+
export interface IVertex {
|
|
42
|
+
point: ICoordinate2D;
|
|
43
|
+
connections: IVertexConnections;
|
|
44
|
+
}
|
|
45
|
+
export interface ILineDimensions {
|
|
46
|
+
label: string;
|
|
47
|
+
line: ICoordinatesLine;
|
|
48
|
+
}
|
|
49
|
+
export interface IEnclosedSpace {
|
|
50
|
+
area: string;
|
|
51
|
+
center: ICoordinate2D;
|
|
52
|
+
loop: Array<ICoordinate2D>;
|
|
53
|
+
}
|
|
54
|
+
export interface IFeature {
|
|
55
|
+
assetId: string;
|
|
56
|
+
offset: number;
|
|
57
|
+
length: number;
|
|
58
|
+
height: number;
|
|
59
|
+
altitude: number;
|
|
60
|
+
path?: ICoordinatesQuadrilateral;
|
|
61
|
+
connectedTo: [elementType: IElements.WALL, index: number];
|
|
62
|
+
restConfiguration: string;
|
|
63
|
+
}
|
|
64
|
+
export interface IFeatureDoor extends IFeature {
|
|
65
|
+
orientation: string;
|
|
66
|
+
openingDirection: string;
|
|
67
|
+
showSwing: boolean;
|
|
68
|
+
}
|
|
69
|
+
interface IFeatureHydratedShared {
|
|
70
|
+
line: ICoordinatesLine;
|
|
71
|
+
}
|
|
72
|
+
export interface IFeatureHydrated extends IFeature, IFeatureHydratedShared {
|
|
73
|
+
}
|
|
74
|
+
export interface IFeatureDoorHydrated extends IFeatureDoor, IFeatureHydratedShared {
|
|
75
|
+
}
|
|
76
|
+
export interface IFeaturesShared<T, D> {
|
|
77
|
+
[IElements.WINDOW]?: Array<T>;
|
|
78
|
+
[IElements.DOOR]?: Array<D>;
|
|
79
|
+
[IElements.OPENING]?: Array<T>;
|
|
80
|
+
}
|
|
81
|
+
export interface IFeatures extends IFeaturesShared<IFeature, IFeatureDoor> {
|
|
82
|
+
}
|
|
83
|
+
export interface IFeaturesHydrated extends IFeaturesShared<IFeatureHydrated, IFeatureDoorHydrated> {
|
|
84
|
+
}
|
|
85
|
+
export declare enum IElementStyleModes {
|
|
86
|
+
HIGHLIGHT = "highlight",
|
|
87
|
+
ACTIVE = "active",
|
|
88
|
+
ERROR = "error"
|
|
89
|
+
}
|
|
90
|
+
export interface ISpacesStylesShared {
|
|
91
|
+
fill: string;
|
|
92
|
+
stroke?: string;
|
|
93
|
+
strokeWidth?: number;
|
|
94
|
+
[IElementStyleModes.HIGHLIGHT]: {
|
|
95
|
+
fill: string;
|
|
96
|
+
stroke: string;
|
|
97
|
+
};
|
|
98
|
+
[IElementStyleModes.ACTIVE]: {
|
|
99
|
+
fill: string;
|
|
100
|
+
stroke: string;
|
|
101
|
+
};
|
|
102
|
+
[IElementStyleModes.ERROR]: {
|
|
103
|
+
fill: string;
|
|
104
|
+
stroke: string;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export interface IStylesGrid {
|
|
108
|
+
lineThickness: number;
|
|
109
|
+
lineColor: string;
|
|
110
|
+
showSubdivisions: boolean;
|
|
111
|
+
subdivisionLineThickness: number;
|
|
112
|
+
subdivisionLineColor: string;
|
|
113
|
+
subdivisionThreshold: number;
|
|
114
|
+
backgroundColor?: string;
|
|
115
|
+
}
|
|
116
|
+
export interface IStylesGuides {
|
|
117
|
+
color: string;
|
|
118
|
+
thickness: number;
|
|
119
|
+
}
|
|
120
|
+
export interface IStylesFloor {
|
|
121
|
+
color: string;
|
|
122
|
+
textColor: string;
|
|
123
|
+
}
|
|
124
|
+
export interface IStylesDimension {
|
|
125
|
+
padding: number;
|
|
126
|
+
lineThickness: number;
|
|
127
|
+
lineColor: string;
|
|
128
|
+
fontSize: number;
|
|
129
|
+
font: string;
|
|
130
|
+
textColor: string;
|
|
131
|
+
textBackgroundColor: string;
|
|
132
|
+
}
|
|
133
|
+
export interface IStylesWall extends ISpacesStylesShared {
|
|
134
|
+
thickness: number;
|
|
135
|
+
}
|
|
136
|
+
export interface IStylesVertex extends Omit<ISpacesStylesShared, 'fill' | IElementStyleModes.HIGHLIGHT | IElementStyleModes.ACTIVE | IElementStyleModes.ERROR> {
|
|
137
|
+
innerFill: string;
|
|
138
|
+
outerFill: string;
|
|
139
|
+
innerRadius: number;
|
|
140
|
+
outerRadius?: number;
|
|
141
|
+
[IElementStyleModes.HIGHLIGHT]: {
|
|
142
|
+
innerFill: string;
|
|
143
|
+
outerFill: string;
|
|
144
|
+
stroke?: string;
|
|
145
|
+
};
|
|
146
|
+
[IElementStyleModes.ACTIVE]: {
|
|
147
|
+
innerFill: string;
|
|
148
|
+
outerFill: string;
|
|
149
|
+
stroke?: string;
|
|
150
|
+
};
|
|
151
|
+
[IElementStyleModes.ERROR]: {
|
|
152
|
+
innerFill: string;
|
|
153
|
+
outerFill: string;
|
|
154
|
+
stroke?: string;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
export interface IStylesFeature extends IStylesWall {
|
|
158
|
+
}
|
|
159
|
+
export interface ISpacesStyles {
|
|
160
|
+
grid: IStylesGrid;
|
|
161
|
+
guides: IStylesGuides;
|
|
162
|
+
floor: IStylesFloor;
|
|
163
|
+
dimensions: IStylesDimension;
|
|
164
|
+
wall: IStylesWall;
|
|
165
|
+
vertex: IStylesVertex;
|
|
166
|
+
feature: IStylesFeature;
|
|
167
|
+
}
|
|
168
|
+
export interface ISpacesThemePartial {
|
|
169
|
+
grid: Partial<IStylesGrid>;
|
|
170
|
+
guides: Partial<IStylesGuides>;
|
|
171
|
+
floor: Partial<IStylesFloor>;
|
|
172
|
+
dimensions: Partial<IStylesDimension>;
|
|
173
|
+
wall: Partial<IStylesWall>;
|
|
174
|
+
vertex: Partial<IStylesVertex>;
|
|
175
|
+
feature: Partial<IStylesFeature>;
|
|
176
|
+
}
|
|
177
|
+
export interface IGridToDraw {
|
|
178
|
+
unitLength: number;
|
|
179
|
+
offset: ICoordinate2D;
|
|
180
|
+
subdivisions: number;
|
|
181
|
+
showSubdivisions: boolean;
|
|
182
|
+
}
|
|
183
|
+
export interface IWallsValidationConfig {
|
|
184
|
+
minLength: number;
|
|
185
|
+
padding: number;
|
|
186
|
+
}
|
|
187
|
+
export interface ISharedValidatorInput {
|
|
188
|
+
walls: IWalls;
|
|
189
|
+
features: IFeatures;
|
|
190
|
+
}
|
|
191
|
+
export interface IFeatureValidatorInput {
|
|
192
|
+
wall: IWall;
|
|
193
|
+
updatedFeature: Pick<IFeature, 'length' | 'offset'> & {
|
|
194
|
+
address: IElementAddress;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export interface IAddWallValidatorInput {
|
|
198
|
+
newWall: Pick<IWall, 'line'> & Pick<INewWall, 'start' | 'end'>;
|
|
199
|
+
}
|
|
200
|
+
export interface IMoveVertexValidatorInput {
|
|
201
|
+
updatedPosition: ISnapPoint;
|
|
202
|
+
vertex: IVertex;
|
|
203
|
+
}
|
|
204
|
+
export type IValidatorFunction<T> = (input: T, wallsAndFeatures: ISharedValidatorInput, validationConfig: IWallsValidationConfig) => false | IErrorElement;
|
|
205
|
+
export declare enum SNAPPING_TYPES {
|
|
206
|
+
NONE = "none",
|
|
207
|
+
ANGLE = "angle",
|
|
208
|
+
GUIDE = "guide",
|
|
209
|
+
GRID = "grid"
|
|
210
|
+
}
|
|
211
|
+
export declare enum GUIDE_ORIENTATIONS {
|
|
212
|
+
HORIZONTAL = "horizontal",
|
|
213
|
+
VERTICAL = "vertical"
|
|
214
|
+
}
|
|
215
|
+
export interface IGuides {
|
|
216
|
+
point: ICoordinate2D;
|
|
217
|
+
orientations: Array<GUIDE_ORIENTATIONS>;
|
|
218
|
+
}
|
|
219
|
+
export interface IElementAddress {
|
|
220
|
+
type: IElementName;
|
|
221
|
+
index: number;
|
|
222
|
+
}
|
|
223
|
+
export interface IFeatureAddress {
|
|
224
|
+
type: IFeatureName;
|
|
225
|
+
index: number;
|
|
226
|
+
}
|
|
227
|
+
export interface ISnapPointShared<T> {
|
|
228
|
+
type: T;
|
|
229
|
+
point: ICoordinate2D;
|
|
230
|
+
locked: [boolean, boolean];
|
|
231
|
+
}
|
|
232
|
+
export interface ISnapPointNone extends ISnapPointShared<SNAPPING_TYPES.NONE> {
|
|
233
|
+
locked: [false, false];
|
|
234
|
+
}
|
|
235
|
+
export interface ISnapPointVertex extends ISnapPointShared<IElements.VERTEX> {
|
|
236
|
+
index: number;
|
|
237
|
+
locked: [true, true];
|
|
238
|
+
}
|
|
239
|
+
export interface ISnapPointWall extends ISnapPointShared<IElements.WALL> {
|
|
240
|
+
offset: number;
|
|
241
|
+
index: number;
|
|
242
|
+
}
|
|
243
|
+
export interface ISnapPointFeature extends ISnapPointShared<IFeatureName> {
|
|
244
|
+
index: number;
|
|
245
|
+
}
|
|
246
|
+
export interface ISnapPointAngle extends ISnapPointShared<SNAPPING_TYPES.ANGLE>, Pick<IGuides, 'orientations'> {
|
|
247
|
+
}
|
|
248
|
+
export interface ISnapPointGuide extends ISnapPointShared<SNAPPING_TYPES.GUIDE>, Pick<IGuides, 'orientations'> {
|
|
249
|
+
}
|
|
250
|
+
export interface ISnapPointGrid extends ISnapPointShared<SNAPPING_TYPES.GRID>, Pick<IGuides, 'orientations'> {
|
|
251
|
+
locked: [true, true];
|
|
252
|
+
}
|
|
253
|
+
export type ISnapPoint = ISnapPointNone | ISnapPointVertex | ISnapPointWall | ISnapPointFeature | ISnapPointAngle | ISnapPointGuide | ISnapPointGrid;
|
|
254
|
+
export interface IActiveElement extends IElementAddress {
|
|
255
|
+
snapPoint?: ISnapPoint;
|
|
256
|
+
}
|
|
257
|
+
export declare enum IErrorTypes {
|
|
258
|
+
HARD = "hard",
|
|
259
|
+
SOFT = "soft",
|
|
260
|
+
WARN = "warning"
|
|
261
|
+
}
|
|
262
|
+
export interface IErrorElement {
|
|
263
|
+
address?: IElementAddress;
|
|
264
|
+
message: string;
|
|
265
|
+
type: IErrorTypes;
|
|
266
|
+
}
|
|
267
|
+
export interface IElementUi {
|
|
268
|
+
path: [type: IFeatureName | IElements.WALL, index: number];
|
|
269
|
+
uiAnchor: ICoordinate2D;
|
|
270
|
+
}
|
|
271
|
+
export interface IElementPublic extends Pick<IElementUi, 'uiAnchor'> {
|
|
272
|
+
path: [attribute: string, index: number];
|
|
273
|
+
type: IFeatureName | IElements.WALL;
|
|
274
|
+
deleteElement: () => void;
|
|
275
|
+
splitWall?: (offset?: number) => void;
|
|
276
|
+
addFeature?: (type: IFeatureName, feature?: Partial<IFeature>) => void;
|
|
277
|
+
}
|
|
278
|
+
export declare enum IModes {
|
|
279
|
+
SELECT = "select",
|
|
280
|
+
DRAW = "draw"
|
|
281
|
+
}
|
|
282
|
+
export declare enum IUnits {
|
|
283
|
+
FEET = "feet",
|
|
284
|
+
METER = "meter",
|
|
285
|
+
INCH = "inch",
|
|
286
|
+
CM = "cm"
|
|
287
|
+
}
|
|
288
|
+
export declare enum IDimensionOptions {
|
|
289
|
+
NONE = "none",
|
|
290
|
+
DEFAULT = "default",
|
|
291
|
+
DETAILED = "detailed"
|
|
292
|
+
}
|
|
293
|
+
export interface ISpacesConfigShared<T> {
|
|
294
|
+
scale: number;
|
|
295
|
+
unit: IUnits;
|
|
296
|
+
snapProximity: number;
|
|
297
|
+
styles: T;
|
|
298
|
+
zoomDefault: number;
|
|
299
|
+
translateDefault: ICoordinate2D;
|
|
300
|
+
disableGuides: boolean;
|
|
301
|
+
}
|
|
302
|
+
export interface ISpacesConfigInternal extends ISpacesConfigShared<ISpacesStyles> {
|
|
303
|
+
}
|
|
304
|
+
export interface ISpacesConfigUser extends ISpacesConfigShared<Partial<ISpacesStyles>> {
|
|
305
|
+
theme: string;
|
|
306
|
+
zoomDisabled: boolean;
|
|
307
|
+
translateDisabled: boolean;
|
|
308
|
+
zoomSensitivity: number;
|
|
309
|
+
}
|
|
310
|
+
export interface ISpacesAttributes {
|
|
311
|
+
[IElements.WALL]: string;
|
|
312
|
+
[IElements.WINDOW]: string;
|
|
313
|
+
[IElements.DOOR]: string;
|
|
314
|
+
[IElements.OPENING]: string;
|
|
315
|
+
featurePositionX: string;
|
|
316
|
+
featurePositionY: string;
|
|
317
|
+
featureConnectedTo: string;
|
|
318
|
+
featureHeight: string;
|
|
319
|
+
featureLength: string;
|
|
320
|
+
wallStartX: string;
|
|
321
|
+
wallStartY: string;
|
|
322
|
+
wallStartZ: string;
|
|
323
|
+
wallEndX: string;
|
|
324
|
+
wallEndY: string;
|
|
325
|
+
wallEndZ: string;
|
|
326
|
+
wallConnections: string;
|
|
327
|
+
}
|
|
328
|
+
export interface IAttributeDefaults extends Partial<Record<IElements.WALL | IElements.WINDOW | IElements.DOOR | IElements.OPENING, string>> {
|
|
329
|
+
}
|
|
330
|
+
interface ISpacesPropsShared<T, U> {
|
|
331
|
+
config: T;
|
|
332
|
+
attributes: U;
|
|
333
|
+
layouts?: Array<string>;
|
|
334
|
+
}
|
|
335
|
+
export interface ISpacesHookProps extends ISpacesPropsShared<undefined | Partial<ISpacesConfigUser>, undefined | Partial<ISpacesAttributes>> {
|
|
336
|
+
}
|
|
337
|
+
export interface ISpacesStateProps extends ISpacesPropsShared<ISpacesConfigInternal, ISpacesAttributes> {
|
|
338
|
+
}
|
|
339
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IDimensionOptions = exports.IUnits = exports.IModes = exports.IErrorTypes = exports.GUIDE_ORIENTATIONS = exports.SNAPPING_TYPES = exports.IElementStyleModes = exports.IElements = void 0;
|
|
4
|
+
var IElements;
|
|
5
|
+
(function (IElements) {
|
|
6
|
+
IElements["WALL"] = "walls";
|
|
7
|
+
IElements["VERTEX"] = "vertex";
|
|
8
|
+
IElements["FEATURE"] = "features";
|
|
9
|
+
IElements["WINDOW"] = "windows";
|
|
10
|
+
IElements["DOOR"] = "doors";
|
|
11
|
+
IElements["OPENING"] = "openings";
|
|
12
|
+
})(IElements = exports.IElements || (exports.IElements = {}));
|
|
13
|
+
var IElementStyleModes;
|
|
14
|
+
(function (IElementStyleModes) {
|
|
15
|
+
IElementStyleModes["HIGHLIGHT"] = "highlight";
|
|
16
|
+
IElementStyleModes["ACTIVE"] = "active";
|
|
17
|
+
IElementStyleModes["ERROR"] = "error";
|
|
18
|
+
})(IElementStyleModes = exports.IElementStyleModes || (exports.IElementStyleModes = {}));
|
|
19
|
+
var SNAPPING_TYPES;
|
|
20
|
+
(function (SNAPPING_TYPES) {
|
|
21
|
+
SNAPPING_TYPES["NONE"] = "none";
|
|
22
|
+
SNAPPING_TYPES["ANGLE"] = "angle";
|
|
23
|
+
SNAPPING_TYPES["GUIDE"] = "guide";
|
|
24
|
+
SNAPPING_TYPES["GRID"] = "grid";
|
|
25
|
+
})(SNAPPING_TYPES = exports.SNAPPING_TYPES || (exports.SNAPPING_TYPES = {}));
|
|
26
|
+
var GUIDE_ORIENTATIONS;
|
|
27
|
+
(function (GUIDE_ORIENTATIONS) {
|
|
28
|
+
GUIDE_ORIENTATIONS["HORIZONTAL"] = "horizontal";
|
|
29
|
+
GUIDE_ORIENTATIONS["VERTICAL"] = "vertical";
|
|
30
|
+
})(GUIDE_ORIENTATIONS = exports.GUIDE_ORIENTATIONS || (exports.GUIDE_ORIENTATIONS = {}));
|
|
31
|
+
var IErrorTypes;
|
|
32
|
+
(function (IErrorTypes) {
|
|
33
|
+
IErrorTypes["HARD"] = "hard";
|
|
34
|
+
IErrorTypes["SOFT"] = "soft";
|
|
35
|
+
IErrorTypes["WARN"] = "warning";
|
|
36
|
+
})(IErrorTypes = exports.IErrorTypes || (exports.IErrorTypes = {}));
|
|
37
|
+
var IModes;
|
|
38
|
+
(function (IModes) {
|
|
39
|
+
IModes["SELECT"] = "select";
|
|
40
|
+
IModes["DRAW"] = "draw";
|
|
41
|
+
})(IModes = exports.IModes || (exports.IModes = {}));
|
|
42
|
+
var IUnits;
|
|
43
|
+
(function (IUnits) {
|
|
44
|
+
IUnits["FEET"] = "feet";
|
|
45
|
+
IUnits["METER"] = "meter";
|
|
46
|
+
IUnits["INCH"] = "inch";
|
|
47
|
+
IUnits["CM"] = "cm";
|
|
48
|
+
})(IUnits = exports.IUnits || (exports.IUnits = {}));
|
|
49
|
+
var IDimensionOptions;
|
|
50
|
+
(function (IDimensionOptions) {
|
|
51
|
+
IDimensionOptions["NONE"] = "none";
|
|
52
|
+
IDimensionOptions["DEFAULT"] = "default";
|
|
53
|
+
IDimensionOptions["DETAILED"] = "detailed";
|
|
54
|
+
})(IDimensionOptions = exports.IDimensionOptions || (exports.IDimensionOptions = {}));
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var geometry_1 = require("../geometry");
|
|
4
|
+
var messaging_1 = require("./messaging");
|
|
5
|
+
var types_1 = require("../types");
|
|
6
|
+
function areWallsDuplicated(input, wallAndFeatures) {
|
|
7
|
+
var vertex = input.vertex, updatedPosition = input.updatedPosition;
|
|
8
|
+
var walls = wallAndFeatures.walls;
|
|
9
|
+
var point = updatedPosition.point;
|
|
10
|
+
var _a = vertex.connections.reduce(function (output, connection) {
|
|
11
|
+
var _a;
|
|
12
|
+
var wallIndex = connection[0], vertexIndex = connection[1];
|
|
13
|
+
output.wallIndexes.add(wallIndex);
|
|
14
|
+
output.updatedVerticesMap = Object.assign(output.updatedVerticesMap, (_a = {},
|
|
15
|
+
_a[wallIndex] = vertexIndex,
|
|
16
|
+
_a));
|
|
17
|
+
return output;
|
|
18
|
+
}, {
|
|
19
|
+
wallIndexes: new Set([]),
|
|
20
|
+
updatedVerticesMap: {},
|
|
21
|
+
}), wallIndexes = _a.wallIndexes, updatedVerticesMap = _a.updatedVerticesMap;
|
|
22
|
+
for (var _i = 0, _b = Array.from(wallIndexes); _i < _b.length; _i++) {
|
|
23
|
+
var wallIdx = _b[_i];
|
|
24
|
+
var wall = walls[wallIdx];
|
|
25
|
+
var updatedLine = JSON.parse(JSON.stringify(wall.line));
|
|
26
|
+
updatedLine[updatedVerticesMap[wallIdx]] = point;
|
|
27
|
+
if ((updatedPosition === null || updatedPosition === void 0 ? void 0 : updatedPosition.type) === types_1.IElements.WALL &&
|
|
28
|
+
updatedPosition.index !== wallIdx) {
|
|
29
|
+
var _c = walls[updatedPosition.index].line, xTest = _c[0], yTest = _c[1];
|
|
30
|
+
var unmovedPoint = updatedLine[updatedVerticesMap[wallIdx] === 1 ? 0 : 1];
|
|
31
|
+
if ((0, geometry_1.arePointsEqual)(unmovedPoint, xTest) ||
|
|
32
|
+
(0, geometry_1.arePointsEqual)(unmovedPoint, yTest))
|
|
33
|
+
return {
|
|
34
|
+
address: {
|
|
35
|
+
type: types_1.IElements.WALL,
|
|
36
|
+
index: updatedPosition.index,
|
|
37
|
+
},
|
|
38
|
+
type: types_1.IErrorTypes.SOFT,
|
|
39
|
+
message: messaging_1.errorMessages.wallsNotUnique(),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
for (var i = 0; i < walls.length; i++) {
|
|
43
|
+
if (wallIdx === i)
|
|
44
|
+
continue;
|
|
45
|
+
var existingWall = walls[i];
|
|
46
|
+
var error = {
|
|
47
|
+
address: { type: types_1.IElements.WALL, index: i },
|
|
48
|
+
type: types_1.IErrorTypes.SOFT,
|
|
49
|
+
message: messaging_1.errorMessages.wallsNotUnique(),
|
|
50
|
+
};
|
|
51
|
+
if (((0, geometry_1.arePointsEqual)(existingWall[0], wall.line[0]) &&
|
|
52
|
+
(0, geometry_1.arePointsEqual)(existingWall[1], wall.line[1])) ||
|
|
53
|
+
((0, geometry_1.arePointsEqual)(existingWall[0], wall.line[1]) &&
|
|
54
|
+
(0, geometry_1.arePointsEqual)(existingWall[1], wall.line[0]))) {
|
|
55
|
+
return error;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
exports.default = areWallsDuplicated;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var geometry_1 = require("../geometry");
|
|
4
|
+
var messaging_1 = require("./messaging");
|
|
5
|
+
var types_1 = require("../types");
|
|
6
|
+
function areWallsIntersecting(input, wallAndFeatures) {
|
|
7
|
+
var vertex = input.vertex, updatedPosition = input.updatedPosition;
|
|
8
|
+
var walls = wallAndFeatures.walls;
|
|
9
|
+
var _a = vertex.connections.reduce(function (output, connection) {
|
|
10
|
+
var _a;
|
|
11
|
+
var wallIndex = connection[0], vertexIndex = connection[1];
|
|
12
|
+
output.wallIndexes.add(wallIndex);
|
|
13
|
+
output.updatedVerticesMap = Object.assign(output.updatedVerticesMap, (_a = {},
|
|
14
|
+
_a[wallIndex] = vertexIndex,
|
|
15
|
+
_a));
|
|
16
|
+
return output;
|
|
17
|
+
}, {
|
|
18
|
+
wallIndexes: new Set([]),
|
|
19
|
+
updatedVerticesMap: {},
|
|
20
|
+
}), wallIndexes = _a.wallIndexes, updatedVerticesMap = _a.updatedVerticesMap;
|
|
21
|
+
for (var _i = 0, _b = Array.from(wallIndexes); _i < _b.length; _i++) {
|
|
22
|
+
var validateWallIndex = _b[_i];
|
|
23
|
+
var line = walls[validateWallIndex].line;
|
|
24
|
+
line[updatedVerticesMap[validateWallIndex]] = updatedPosition.point;
|
|
25
|
+
for (var i = 0; i < walls.length; i++) {
|
|
26
|
+
if (wallIndexes.has(i))
|
|
27
|
+
continue;
|
|
28
|
+
var wall = walls[i];
|
|
29
|
+
if (!wall)
|
|
30
|
+
continue;
|
|
31
|
+
var intersectionPoint = (0, geometry_1.getLineSegmentsIntersection)(line, wall.line);
|
|
32
|
+
if (intersectionPoint)
|
|
33
|
+
return {
|
|
34
|
+
address: { type: types_1.IElements.WALL, index: i },
|
|
35
|
+
message: messaging_1.errorMessages.addWallCollidingWithWall(),
|
|
36
|
+
type: types_1.IErrorTypes.SOFT,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
exports.default = areWallsIntersecting;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IErrorElement, IMoveVertexValidatorInput, ISharedValidatorInput, IWallsValidationConfig } from '../types';
|
|
2
|
+
declare function areWallsOrphaningFeatures(input: IMoveVertexValidatorInput, wallAndFeatures: ISharedValidatorInput, validationConfig: IWallsValidationConfig): false | IErrorElement;
|
|
3
|
+
export default areWallsOrphaningFeatures;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var geometry_1 = require("../geometry");
|
|
4
|
+
var types_1 = require("../types");
|
|
5
|
+
function areWallsOrphaningFeatures(input, wallAndFeatures, validationConfig) {
|
|
6
|
+
var _a;
|
|
7
|
+
var vertex = input.vertex, updatedPosition = input.updatedPosition;
|
|
8
|
+
var walls = wallAndFeatures.walls, features = wallAndFeatures.features;
|
|
9
|
+
var padding = validationConfig.padding;
|
|
10
|
+
var _b = vertex.connections.reduce(function (output, connection) {
|
|
11
|
+
var _a;
|
|
12
|
+
var wallIndex = connection[0], vertexIndex = connection[1];
|
|
13
|
+
output.wallIndexes.add(wallIndex);
|
|
14
|
+
output.updatedVerticesMap = Object.assign(output.updatedVerticesMap, (_a = {},
|
|
15
|
+
_a[wallIndex] = vertexIndex,
|
|
16
|
+
_a));
|
|
17
|
+
return output;
|
|
18
|
+
}, {
|
|
19
|
+
wallIndexes: new Set([]),
|
|
20
|
+
updatedVerticesMap: {},
|
|
21
|
+
}), wallIndexes = _b.wallIndexes, updatedVerticesMap = _b.updatedVerticesMap;
|
|
22
|
+
for (var _i = 0, _c = Array.from(wallIndexes); _i < _c.length; _i++) {
|
|
23
|
+
var wallIdx = _c[_i];
|
|
24
|
+
var wall = walls[wallIdx];
|
|
25
|
+
if (!wall.connections.length)
|
|
26
|
+
continue;
|
|
27
|
+
var updatedLine = JSON.parse(JSON.stringify(wall.line));
|
|
28
|
+
updatedLine[updatedVerticesMap[wallIdx]] = updatedPosition.point;
|
|
29
|
+
var currentWallLength = (0, geometry_1.getLengthOfLineSegment)(wall.line);
|
|
30
|
+
var updatedWallLength = (0, geometry_1.getLengthOfLineSegment)(updatedLine);
|
|
31
|
+
var wallLengthDelta = updatedWallLength - currentWallLength;
|
|
32
|
+
for (var i = 0; i < wall.connections.length; i++) {
|
|
33
|
+
var _d = wall.connections[i], type = _d[0], index = _d[1];
|
|
34
|
+
var feat = (_a = features[type]) === null || _a === void 0 ? void 0 : _a[index];
|
|
35
|
+
if (!feat)
|
|
36
|
+
continue;
|
|
37
|
+
var error = {
|
|
38
|
+
address: { type: type, index: index },
|
|
39
|
+
message: 'feature collision',
|
|
40
|
+
type: types_1.IErrorTypes.HARD,
|
|
41
|
+
};
|
|
42
|
+
if (updatedVerticesMap[wallIdx] === 0 &&
|
|
43
|
+
feat.offset - wallLengthDelta < padding)
|
|
44
|
+
return error;
|
|
45
|
+
else if (feat.offset + feat.length > updatedWallLength - padding) {
|
|
46
|
+
return error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
exports.default = areWallsOrphaningFeatures;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IErrorElement, IWallsValidationConfig, IMoveVertexValidatorInput, ISharedValidatorInput } from '../types';
|
|
2
|
+
declare function areWallsTooShort(input: IMoveVertexValidatorInput, wallAndFeatures: ISharedValidatorInput, validationConfig: IWallsValidationConfig): false | IErrorElement;
|
|
3
|
+
export default areWallsTooShort;
|