@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.
Files changed (165) hide show
  1. package/dist/Treble/Treble.d.ts +1 -1
  2. package/dist/Treble/snapshot.d.ts +22 -0
  3. package/dist/Treble/snapshot.js +247 -0
  4. package/dist/Treble/snapshots.d.ts +1 -1
  5. package/dist/components/ThreekitProvider/index.js +3 -2
  6. package/dist/connection.d.ts +4 -1
  7. package/dist/connection.js +16 -53
  8. package/dist/hooks/useAttribute/index.js +1 -5
  9. package/dist/hooks/useSnapshot/index.d.ts +1 -1
  10. package/dist/hooks/useSpaces/SpacesLayout.d.ts +11 -0
  11. package/dist/hooks/useSpaces/SpacesLayout.js +74 -0
  12. package/dist/hooks/useSpaces/SpacesState.d.ts +164 -0
  13. package/dist/hooks/useSpaces/SpacesState.js +1751 -0
  14. package/dist/hooks/useSpaces/constants.d.ts +64 -0
  15. package/dist/hooks/useSpaces/constants.js +109 -0
  16. package/dist/hooks/useSpaces/dataHandlers.d.ts +20 -0
  17. package/dist/hooks/useSpaces/dataHandlers.js +254 -0
  18. package/dist/hooks/useSpaces/draw/clearCanvas.d.ts +2 -0
  19. package/dist/hooks/useSpaces/draw/clearCanvas.js +9 -0
  20. package/dist/hooks/useSpaces/draw/drawBackground.d.ts +2 -0
  21. package/dist/hooks/useSpaces/draw/drawBackground.js +12 -0
  22. package/dist/hooks/useSpaces/draw/drawDimensions.d.ts +3 -0
  23. package/dist/hooks/useSpaces/draw/drawDimensions.js +53 -0
  24. package/dist/hooks/useSpaces/draw/drawDoors.d.ts +9 -0
  25. package/dist/hooks/useSpaces/draw/drawDoors.js +99 -0
  26. package/dist/hooks/useSpaces/draw/drawFloor.d.ts +3 -0
  27. package/dist/hooks/useSpaces/draw/drawFloor.js +36 -0
  28. package/dist/hooks/useSpaces/draw/drawGrid.d.ts +3 -0
  29. package/dist/hooks/useSpaces/draw/drawGrid.js +33 -0
  30. package/dist/hooks/useSpaces/draw/drawGuides.d.ts +3 -0
  31. package/dist/hooks/useSpaces/draw/drawGuides.js +23 -0
  32. package/dist/hooks/useSpaces/draw/drawOpenings.d.ts +9 -0
  33. package/dist/hooks/useSpaces/draw/drawOpenings.js +72 -0
  34. package/dist/hooks/useSpaces/draw/drawVertices.d.ts +8 -0
  35. package/dist/hooks/useSpaces/draw/drawVertices.js +61 -0
  36. package/dist/hooks/useSpaces/draw/drawWalls.d.ts +10 -0
  37. package/dist/hooks/useSpaces/draw/drawWalls.js +88 -0
  38. package/dist/hooks/useSpaces/draw/drawWindows.d.ts +9 -0
  39. package/dist/hooks/useSpaces/draw/drawWindows.js +82 -0
  40. package/dist/hooks/useSpaces/draw/index.d.ts +11 -0
  41. package/dist/hooks/useSpaces/draw/index.js +129 -0
  42. package/dist/hooks/useSpaces/geometry/addThicknessToLine.d.ts +3 -0
  43. package/dist/hooks/useSpaces/geometry/addThicknessToLine.js +13 -0
  44. package/dist/hooks/useSpaces/geometry/areLinesEqual.d.ts +3 -0
  45. package/dist/hooks/useSpaces/geometry/areLinesEqual.js +17 -0
  46. package/dist/hooks/useSpaces/geometry/arePointsEqual.d.ts +3 -0
  47. package/dist/hooks/useSpaces/geometry/arePointsEqual.js +8 -0
  48. package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.d.ts +3 -0
  49. package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.js +11 -0
  50. package/dist/hooks/useSpaces/geometry/closestPointOnLine.d.ts +3 -0
  51. package/dist/hooks/useSpaces/geometry/closestPointOnLine.js +13 -0
  52. package/dist/hooks/useSpaces/geometry/doLinesOverlap.d.ts +2 -0
  53. package/dist/hooks/useSpaces/geometry/doLinesOverlap.js +16 -0
  54. package/dist/hooks/useSpaces/geometry/euclideanMod.d.ts +2 -0
  55. package/dist/hooks/useSpaces/geometry/euclideanMod.js +6 -0
  56. package/dist/hooks/useSpaces/geometry/findLoops.d.ts +6 -0
  57. package/dist/hooks/useSpaces/geometry/findLoops.js +117 -0
  58. package/dist/hooks/useSpaces/geometry/getAllLineIntersections.d.ts +6 -0
  59. package/dist/hooks/useSpaces/geometry/getAllLineIntersections.js +23 -0
  60. package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.d.ts +3 -0
  61. package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.js +7 -0
  62. package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.d.ts +3 -0
  63. package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.js +17 -0
  64. package/dist/hooks/useSpaces/geometry/getDistanceToLine.d.ts +3 -0
  65. package/dist/hooks/useSpaces/geometry/getDistanceToLine.js +10 -0
  66. package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.d.ts +3 -0
  67. package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.js +7 -0
  68. package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.d.ts +3 -0
  69. package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.js +17 -0
  70. package/dist/hooks/useSpaces/geometry/getLineOtherPoint.d.ts +3 -0
  71. package/dist/hooks/useSpaces/geometry/getLineOtherPoint.js +11 -0
  72. package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.d.ts +3 -0
  73. package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.js +43 -0
  74. package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.d.ts +3 -0
  75. package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.js +9 -0
  76. package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.d.ts +3 -0
  77. package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.js +20 -0
  78. package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.d.ts +3 -0
  79. package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.js +11 -0
  80. package/dist/hooks/useSpaces/geometry/getPolygonArea.d.ts +3 -0
  81. package/dist/hooks/useSpaces/geometry/getPolygonArea.js +15 -0
  82. package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.d.ts +3 -0
  83. package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.js +16 -0
  84. package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.d.ts +6 -0
  85. package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.js +17 -0
  86. package/dist/hooks/useSpaces/geometry/getTriangleArea.d.ts +3 -0
  87. package/dist/hooks/useSpaces/geometry/getTriangleArea.js +9 -0
  88. package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.d.ts +3 -0
  89. package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.js +12 -0
  90. package/dist/hooks/useSpaces/geometry/index.d.ts +30 -0
  91. package/dist/hooks/useSpaces/geometry/index.js +64 -0
  92. package/dist/hooks/useSpaces/geometry/isPointInPolygon.d.ts +3 -0
  93. package/dist/hooks/useSpaces/geometry/isPointInPolygon.js +21 -0
  94. package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.d.ts +3 -0
  95. package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.js +25 -0
  96. package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.d.ts +3 -0
  97. package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.js +11 -0
  98. package/dist/hooks/useSpaces/geometry/splitLineAtOffset.d.ts +3 -0
  99. package/dist/hooks/useSpaces/geometry/splitLineAtOffset.js +12 -0
  100. package/dist/hooks/useSpaces/geometry/splitLineAtPoint.d.ts +3 -0
  101. package/dist/hooks/useSpaces/geometry/splitLineAtPoint.js +9 -0
  102. package/dist/hooks/useSpaces/geometry/splitLineAtPoints.d.ts +3 -0
  103. package/dist/hooks/useSpaces/geometry/splitLineAtPoints.js +28 -0
  104. package/dist/hooks/useSpaces/index.d.ts +82 -0
  105. package/dist/hooks/useSpaces/index.js +482 -0
  106. package/dist/hooks/useSpaces/themes/blueprint.d.ts +3 -0
  107. package/dist/hooks/useSpaces/themes/blueprint.js +96 -0
  108. package/dist/hooks/useSpaces/themes/default.d.ts +3 -0
  109. package/dist/hooks/useSpaces/themes/default.js +96 -0
  110. package/dist/hooks/useSpaces/themes/index.d.ts +11 -0
  111. package/dist/hooks/useSpaces/themes/index.js +21 -0
  112. package/dist/hooks/useSpaces/themes/light.d.ts +3 -0
  113. package/dist/hooks/useSpaces/themes/light.js +96 -0
  114. package/dist/hooks/useSpaces/types.d.ts +339 -0
  115. package/dist/hooks/useSpaces/types.js +54 -0
  116. package/dist/hooks/useSpaces/validators/areWallsDuplicated.d.ts +3 -0
  117. package/dist/hooks/useSpaces/validators/areWallsDuplicated.js +61 -0
  118. package/dist/hooks/useSpaces/validators/areWallsIntersecting.d.ts +3 -0
  119. package/dist/hooks/useSpaces/validators/areWallsIntersecting.js +42 -0
  120. package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.d.ts +3 -0
  121. package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.js +52 -0
  122. package/dist/hooks/useSpaces/validators/areWallsTooShort.d.ts +3 -0
  123. package/dist/hooks/useSpaces/validators/areWallsTooShort.js +37 -0
  124. package/dist/hooks/useSpaces/validators/index.d.ts +15 -0
  125. package/dist/hooks/useSpaces/validators/index.js +40 -0
  126. package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.d.ts +3 -0
  127. package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.js +31 -0
  128. package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.d.ts +3 -0
  129. package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.js +19 -0
  130. package/dist/hooks/useSpaces/validators/isLineTooShort.d.ts +3 -0
  131. package/dist/hooks/useSpaces/validators/isLineTooShort.js +26 -0
  132. package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.d.ts +4 -0
  133. package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.js +19 -0
  134. package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.d.ts +3 -0
  135. package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.js +19 -0
  136. package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.d.ts +3 -0
  137. package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.js +41 -0
  138. package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.d.ts +3 -0
  139. package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.js +54 -0
  140. package/dist/hooks/useSpaces/validators/isWallTooShort.d.ts +3 -0
  141. package/dist/hooks/useSpaces/validators/isWallTooShort.js +10 -0
  142. package/dist/hooks/useSpaces/validators/messaging.d.ts +8 -0
  143. package/dist/hooks/useSpaces/validators/messaging.js +18 -0
  144. package/dist/icons/Player3D.d.ts +3 -0
  145. package/dist/icons/Player3D.js +21 -0
  146. package/dist/icons/Ruler copy.d.ts +3 -0
  147. package/dist/icons/Ruler copy.js +22 -0
  148. package/dist/icons/RulerBlank.d.ts +3 -0
  149. package/dist/icons/RulerBlank.js +25 -0
  150. package/dist/icons/RulerDetailed copy.d.ts +3 -0
  151. package/dist/icons/RulerDetailed copy.js +27 -0
  152. package/dist/icons/RulerDetailed.d.ts +3 -0
  153. package/dist/icons/RulerDetailed.js +27 -0
  154. package/dist/icons/types.d.ts +1 -1
  155. package/dist/store/attributes.d.ts +1 -1
  156. package/dist/store/index.d.ts +10 -31
  157. package/dist/store/spaces.d.ts +47 -0
  158. package/dist/store/spaces.js +197 -0
  159. package/dist/store/treble.d.ts +3 -1
  160. package/dist/store/treble.js +45 -30
  161. package/dist/store/wishlist.d.ts +20 -2
  162. package/dist/types.d.ts +12 -3
  163. package/package.json +2 -1
  164. package/dist/hooks/useSpaces/Canvas.d.ts +0 -37
  165. package/dist/hooks/useSpaces/Canvas.js +0 -199
@@ -0,0 +1,64 @@
1
+ import { ICoordinate2D, ISpacesAttributes, IWallsValidationConfig } from './types';
2
+ export declare enum SpacesMetadata {
3
+ VALUE = "_tkSpace_value"
4
+ }
5
+ export declare enum WallAttributes {
6
+ START_X = "_tkSpace_startX",
7
+ START_Y = "_tkSpace_startY",
8
+ START_Z = "_tkSpace_startZ",
9
+ END_X = "_tkSpace_endX",
10
+ END_Y = "_tkSpace_endY",
11
+ END_Z = "_tkSpace_endZ",
12
+ CONNECTIONS = "_tkSpace_connections",
13
+ WALL_HEIGHT = "_tkSpace_wallHeight",
14
+ WALL_THICKNESS = "_tkSpace_wallThickness",
15
+ VISIBILITY = "_tkSpace_visibility"
16
+ }
17
+ export declare enum WallMetadata {
18
+ MIN_LENGTH = "_tkSpace_minLength",
19
+ PADDING = "_tkSpace_padding"
20
+ }
21
+ export declare enum DoorAttributes {
22
+ ORIENTATION = "_tkSpace_doorOrientation",
23
+ OPENING_DIRECTION = "_tkSpace_doorOpeningDirection",
24
+ SHOW_SWING = "_tkSpace_doorShowSwing"
25
+ }
26
+ export declare enum DoorOrientations {
27
+ LEFT = "left",
28
+ RIGHT = "right"
29
+ }
30
+ export declare enum DoorOpeningDirections {
31
+ INSIDE = "inside",
32
+ OUTSIDE = "outside"
33
+ }
34
+ export declare const ATTRIBUTE_NAME_DEFAULTS: ISpacesAttributes;
35
+ export declare const SCALE = 0.02;
36
+ export declare const SNAP_PROXIMITY = 16;
37
+ export declare const ZOOM_MAX = 100;
38
+ export declare const ZOOM_MIN = 20;
39
+ export declare const ZOOM_DEFAULT = 40;
40
+ export declare const ZOOM_SENSITIVITY = 0.8;
41
+ export declare const TRANSLATE_MAX: ICoordinate2D;
42
+ export declare const TRANSLATE_MIN: ICoordinate2D;
43
+ export declare const TRANSLATE_DEFAULT: ICoordinate2D;
44
+ export declare const UNIT_LABELS: {
45
+ feet: string;
46
+ meter: string;
47
+ inch: string;
48
+ cm: string;
49
+ };
50
+ export declare const UNIT_FACTORS: {
51
+ cm: number;
52
+ meter: number;
53
+ feet: number;
54
+ inch: number;
55
+ };
56
+ export declare const FEATURE_LABELS: {
57
+ windows: string;
58
+ doors: string;
59
+ openings: string;
60
+ };
61
+ export declare const VALIDATION_CONFIG_DEFAULT: IWallsValidationConfig;
62
+ export declare const FEATURE_LENGTH = 120;
63
+ export declare const UI_ANCHOR_DISTANCE = -60;
64
+ export declare const WALL_SNAP_DISTANCE = 12;
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var _a, _b, _c, _d;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.WALL_SNAP_DISTANCE = exports.UI_ANCHOR_DISTANCE = exports.FEATURE_LENGTH = exports.VALIDATION_CONFIG_DEFAULT = exports.FEATURE_LABELS = exports.UNIT_FACTORS = exports.UNIT_LABELS = exports.TRANSLATE_DEFAULT = exports.TRANSLATE_MIN = exports.TRANSLATE_MAX = exports.ZOOM_SENSITIVITY = exports.ZOOM_DEFAULT = exports.ZOOM_MIN = exports.ZOOM_MAX = exports.SNAP_PROXIMITY = exports.SCALE = exports.ATTRIBUTE_NAME_DEFAULTS = exports.DoorOpeningDirections = exports.DoorOrientations = exports.DoorAttributes = exports.WallMetadata = exports.WallAttributes = exports.SpacesMetadata = void 0;
5
+ var types_1 = require("./types");
6
+ var SpacesAttributes;
7
+ (function (SpacesAttributes) {
8
+ SpacesAttributes["WALLS"] = "_tkSpace_walls";
9
+ SpacesAttributes["WINDOWS"] = "_tkSpace_windows";
10
+ SpacesAttributes["DOORS"] = "_tkSpace_doors";
11
+ SpacesAttributes["OPENINGS"] = "_tkSpace_openings";
12
+ })(SpacesAttributes || (SpacesAttributes = {}));
13
+ var SpacesMetadata;
14
+ (function (SpacesMetadata) {
15
+ SpacesMetadata["VALUE"] = "_tkSpace_value";
16
+ })(SpacesMetadata = exports.SpacesMetadata || (exports.SpacesMetadata = {}));
17
+ var WallAttributes;
18
+ (function (WallAttributes) {
19
+ WallAttributes["START_X"] = "_tkSpace_startX";
20
+ WallAttributes["START_Y"] = "_tkSpace_startY";
21
+ WallAttributes["START_Z"] = "_tkSpace_startZ";
22
+ WallAttributes["END_X"] = "_tkSpace_endX";
23
+ WallAttributes["END_Y"] = "_tkSpace_endY";
24
+ WallAttributes["END_Z"] = "_tkSpace_endZ";
25
+ WallAttributes["CONNECTIONS"] = "_tkSpace_connections";
26
+ WallAttributes["WALL_HEIGHT"] = "_tkSpace_wallHeight";
27
+ WallAttributes["WALL_THICKNESS"] = "_tkSpace_wallThickness";
28
+ WallAttributes["VISIBILITY"] = "_tkSpace_visibility";
29
+ })(WallAttributes = exports.WallAttributes || (exports.WallAttributes = {}));
30
+ var WallMetadata;
31
+ (function (WallMetadata) {
32
+ WallMetadata["MIN_LENGTH"] = "_tkSpace_minLength";
33
+ WallMetadata["PADDING"] = "_tkSpace_padding";
34
+ })(WallMetadata = exports.WallMetadata || (exports.WallMetadata = {}));
35
+ var FeatureAttributes;
36
+ (function (FeatureAttributes) {
37
+ FeatureAttributes["POSITION_X"] = "_tkSpace_offsetX";
38
+ FeatureAttributes["POSITION_Y"] = "_tkSpace_offsetY";
39
+ FeatureAttributes["CONNECTED_TO"] = "_tkSpace_connectedTo";
40
+ FeatureAttributes["FEATURE_HEIGHT"] = "_tkSpace_featureHeight";
41
+ FeatureAttributes["FEATURE_LENGTH"] = "_tkSpace_featureWidth";
42
+ })(FeatureAttributes || (FeatureAttributes = {}));
43
+ var DoorAttributes;
44
+ (function (DoorAttributes) {
45
+ DoorAttributes["ORIENTATION"] = "_tkSpace_doorOrientation";
46
+ DoorAttributes["OPENING_DIRECTION"] = "_tkSpace_doorOpeningDirection";
47
+ DoorAttributes["SHOW_SWING"] = "_tkSpace_doorShowSwing";
48
+ })(DoorAttributes = exports.DoorAttributes || (exports.DoorAttributes = {}));
49
+ var DoorOrientations;
50
+ (function (DoorOrientations) {
51
+ DoorOrientations["LEFT"] = "left";
52
+ DoorOrientations["RIGHT"] = "right";
53
+ })(DoorOrientations = exports.DoorOrientations || (exports.DoorOrientations = {}));
54
+ var DoorOpeningDirections;
55
+ (function (DoorOpeningDirections) {
56
+ DoorOpeningDirections["INSIDE"] = "inside";
57
+ DoorOpeningDirections["OUTSIDE"] = "outside";
58
+ })(DoorOpeningDirections = exports.DoorOpeningDirections || (exports.DoorOpeningDirections = {}));
59
+ exports.ATTRIBUTE_NAME_DEFAULTS = (_a = {},
60
+ _a[types_1.IElements.WALL] = SpacesAttributes.WALLS,
61
+ _a[types_1.IElements.WINDOW] = SpacesAttributes.WINDOWS,
62
+ _a[types_1.IElements.OPENING] = SpacesAttributes.OPENINGS,
63
+ _a[types_1.IElements.DOOR] = SpacesAttributes.DOORS,
64
+ _a.featurePositionX = FeatureAttributes.POSITION_X,
65
+ _a.featurePositionY = FeatureAttributes.POSITION_Y,
66
+ _a.featureConnectedTo = FeatureAttributes.CONNECTED_TO,
67
+ _a.featureHeight = FeatureAttributes.FEATURE_HEIGHT,
68
+ _a.featureLength = FeatureAttributes.FEATURE_LENGTH,
69
+ _a.wallStartX = WallAttributes.START_X,
70
+ _a.wallStartY = WallAttributes.START_Y,
71
+ _a.wallStartZ = WallAttributes.START_Z,
72
+ _a.wallEndX = WallAttributes.END_X,
73
+ _a.wallEndY = WallAttributes.END_Y,
74
+ _a.wallEndZ = WallAttributes.END_Z,
75
+ _a.wallConnections = WallAttributes.CONNECTIONS,
76
+ _a);
77
+ exports.SCALE = 0.02;
78
+ exports.SNAP_PROXIMITY = 16;
79
+ exports.ZOOM_MAX = 100;
80
+ exports.ZOOM_MIN = 20;
81
+ exports.ZOOM_DEFAULT = 40;
82
+ exports.ZOOM_SENSITIVITY = 0.8;
83
+ exports.TRANSLATE_MAX = [-400, -400];
84
+ exports.TRANSLATE_MIN = [400, 400];
85
+ exports.TRANSLATE_DEFAULT = [-200, -200];
86
+ exports.UNIT_LABELS = (_b = {},
87
+ _b[types_1.IUnits.FEET] = 'ft',
88
+ _b[types_1.IUnits.METER] = 'm',
89
+ _b[types_1.IUnits.INCH] = 'in',
90
+ _b[types_1.IUnits.CM] = 'cm',
91
+ _b);
92
+ exports.UNIT_FACTORS = (_c = {},
93
+ _c[types_1.IUnits.CM] = 100,
94
+ _c[types_1.IUnits.METER] = 1,
95
+ _c[types_1.IUnits.FEET] = 3.28084,
96
+ _c[types_1.IUnits.INCH] = 39.37,
97
+ _c);
98
+ exports.FEATURE_LABELS = (_d = {},
99
+ _d[types_1.IElements.WINDOW] = 'Window',
100
+ _d[types_1.IElements.DOOR] = 'Door',
101
+ _d[types_1.IElements.OPENING] = 'Opening',
102
+ _d);
103
+ exports.VALIDATION_CONFIG_DEFAULT = {
104
+ padding: 0.2,
105
+ minLength: 0.5,
106
+ };
107
+ exports.FEATURE_LENGTH = 120;
108
+ exports.UI_ANCHOR_DISTANCE = -60;
109
+ exports.WALL_SNAP_DISTANCE = 12;
@@ -0,0 +1,20 @@
1
+ import type { IWalls, ISpacesStateProps, IVerticesState, IFeatures, IWallsValidationConfig, IAttributeDefaults } from './types';
2
+ import { IUnits } from './types';
3
+ import type { IConfiguration, IHydratedAttribute } from '../../types';
4
+ export declare function prepAttributesIncoming(attributes: Record<string, IHydratedAttribute>, config: ISpacesStateProps): {
5
+ validationConfig: IWallsValidationConfig;
6
+ features: {};
7
+ walls: IWalls;
8
+ vertex: IVerticesState;
9
+ };
10
+ export declare function getAttributeDefaults(attributes: Record<string, IHydratedAttribute>, config: ISpacesStateProps): IAttributeDefaults;
11
+ export declare function prepAttributesOutgoing(walls: IWalls, features: IFeatures, config: ISpacesStateProps): {
12
+ [x: string]: import("../../types").IConfigurationAttribute | {
13
+ assetId: string;
14
+ configuration: IConfiguration;
15
+ }[];
16
+ };
17
+ export declare function convertLengthUnit(value: number, from: IUnits, to: IUnits): number;
18
+ export declare function convertAreaUnit(value: number, from: IUnits, to: IUnits): number;
19
+ export declare function prepLengthForUser(value: number, unit: IUnits): string;
20
+ export declare function prepAreaForUser(value: number, unit: IUnits): string;
@@ -0,0 +1,254 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.prepAreaForUser = exports.prepLengthForUser = exports.convertAreaUnit = exports.convertLengthUnit = exports.prepAttributesOutgoing = exports.getAttributeDefaults = exports.prepAttributesIncoming = void 0;
15
+ var types_1 = require("./types");
16
+ var constants_1 = require("./constants");
17
+ var geometry_1 = require("./geometry");
18
+ function filterRestConfiguration(configuration, attributeNames) {
19
+ var keysToFilter = new Set(Object.values(attributeNames));
20
+ var filteredConfiguration = Object.entries(configuration).reduce(function (output, _a) {
21
+ var _b;
22
+ var key = _a[0], value = _a[1];
23
+ if (keysToFilter.has(key))
24
+ return output;
25
+ return Object.assign(output, (_b = {}, _b[key] = value, _b));
26
+ }, {});
27
+ return filteredConfiguration;
28
+ }
29
+ function prepConnectionOutgoing(connection) {
30
+ return "".concat(connection[0], ".").concat(connection[1]);
31
+ }
32
+ function prepConnectionIncoming(connection) {
33
+ var _a = connection.split('.'), attributeName = _a[0], indexStr = _a[1];
34
+ return [attributeName, parseInt(indexStr)];
35
+ }
36
+ function prepWallsAndVerticesIncoming(wallsAttribute, config) {
37
+ var _a;
38
+ var walls = [];
39
+ var vertices = {};
40
+ var attributeName = config.attributes;
41
+ ((wallsAttribute === null || wallsAttribute === void 0 ? void 0 : wallsAttribute.value) || []).forEach(function (_a, i) {
42
+ var _b, _c, _d;
43
+ var assetId = _a.assetId, configuration = _a.configuration;
44
+ var point1 = [
45
+ (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.wallStartX]) / config.config.scale,
46
+ (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.wallStartZ]) / config.config.scale,
47
+ ];
48
+ var point2 = [
49
+ (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.wallEndX]) / config.config.scale,
50
+ (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.wallEndZ]) / config.config.scale,
51
+ ];
52
+ var point1Str = JSON.stringify(point1);
53
+ var point2Str = JSON.stringify(point2);
54
+ if (vertices[point1Str])
55
+ vertices[point1Str].push([i, 0]);
56
+ else
57
+ vertices[point1Str] = [[i, 0]];
58
+ if (vertices[point2Str])
59
+ vertices[point2Str].push([i, 1]);
60
+ else
61
+ vertices[point2Str] = [[i, 1]];
62
+ var connections = [];
63
+ var visible = ((_d = (_c = (_b = configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.WallAttributes.VISIBILITY]) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c[constants_1.SpacesMetadata.VALUE]) !== null && _d !== void 0 ? _d : 'true') === 'true';
64
+ walls.push({
65
+ assetId: assetId,
66
+ visible: visible,
67
+ line: [point1, point2],
68
+ path: (0, geometry_1.addThicknessToLine)([point1, point2], config.config.styles.wall.thickness),
69
+ connections: connections,
70
+ restConfiguration: JSON.stringify(filterRestConfiguration(configuration, config.attributes)),
71
+ });
72
+ });
73
+ return _a = {}, _a[types_1.IElements.WALL] = walls, _a[types_1.IElements.VERTEX] = vertices, _a;
74
+ }
75
+ function getWallsVaidationConfig(wallsAttribute, config) {
76
+ var _a, _b;
77
+ var metadata = (wallsAttribute === null || wallsAttribute === void 0 ? void 0 : wallsAttribute.values[0].metadata) || {};
78
+ var validation = {
79
+ minLength: ((_a = metadata[constants_1.WallMetadata.MIN_LENGTH]) !== null && _a !== void 0 ? _a : constants_1.VALIDATION_CONFIG_DEFAULT.minLength) / config.config.scale,
80
+ padding: ((_b = metadata[constants_1.WallMetadata.PADDING]) !== null && _b !== void 0 ? _b : constants_1.VALIDATION_CONFIG_DEFAULT.padding) / config.config.scale,
81
+ };
82
+ return validation;
83
+ }
84
+ function prepFeatureIncoming(type, walls, featureAttribute, config) {
85
+ var _a;
86
+ var attributeName = config.attributes;
87
+ var feature = [];
88
+ (_a = featureAttribute === null || featureAttribute === void 0 ? void 0 : featureAttribute.value) === null || _a === void 0 ? void 0 : _a.forEach(function (_a) {
89
+ var _b, _c, _d, _e, _f, _g;
90
+ var assetId = _a.assetId, configuration = _a.configuration;
91
+ var offset = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featurePositionX]) / config.config.scale;
92
+ var length = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featureLength]) / config.config.scale;
93
+ var height = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featureHeight]) / config.config.scale;
94
+ var altitude = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featurePositionY]) / config.config.scale;
95
+ var connectedTo = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featureConnectedTo]) || '';
96
+ var wallIndex = prepConnectionIncoming(connectedTo)[1];
97
+ var featureLine = (0, geometry_1.getLineAtOffsetOnLineSegment)(walls[wallIndex].line, offset, length);
98
+ var element = {
99
+ assetId: assetId,
100
+ offset: offset,
101
+ length: length,
102
+ height: height,
103
+ altitude: altitude,
104
+ connectedTo: [types_1.IElements.WALL, wallIndex],
105
+ path: (0, geometry_1.addThicknessToLine)(featureLine, config.config.styles.feature.thickness),
106
+ restConfiguration: JSON.stringify(filterRestConfiguration(configuration, config.attributes)),
107
+ };
108
+ if (type === types_1.IElements.DOOR) {
109
+ element.showSwing =
110
+ (((_c = (_b = configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.DoorAttributes.SHOW_SWING]) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c[constants_1.SpacesMetadata.VALUE]) || 'true') === 'true';
111
+ element.orientation =
112
+ ((_e = (_d = configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.DoorAttributes.ORIENTATION]) === null || _d === void 0 ? void 0 : _d.metadata) === null || _e === void 0 ? void 0 : _e[constants_1.SpacesMetadata.VALUE]) === constants_1.DoorOrientations.LEFT
113
+ ? constants_1.DoorOrientations.LEFT
114
+ : constants_1.DoorOrientations.RIGHT;
115
+ element.openingDirection =
116
+ ((_g = (_f = configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.DoorAttributes.OPENING_DIRECTION]) === null || _f === void 0 ? void 0 : _f.metadata) === null || _g === void 0 ? void 0 : _g[constants_1.SpacesMetadata.VALUE]) === constants_1.DoorOpeningDirections.INSIDE
117
+ ? constants_1.DoorOpeningDirections.INSIDE
118
+ : constants_1.DoorOpeningDirections.OUTSIDE;
119
+ }
120
+ feature.push(element);
121
+ });
122
+ return feature;
123
+ }
124
+ function prepAttributesIncoming(attributes, config) {
125
+ var _a;
126
+ var wallsAttribute = attributes[config.attributes[types_1.IElements.WALL]];
127
+ var wallsAndVertices = prepWallsAndVerticesIncoming(wallsAttribute, config);
128
+ var wallsValidation = getWallsVaidationConfig(wallsAttribute, config);
129
+ var featuresList = [
130
+ types_1.IElements.WINDOW,
131
+ types_1.IElements.DOOR,
132
+ types_1.IElements.OPENING,
133
+ ];
134
+ var featuresData = featuresList.reduce(function (output, type) {
135
+ output[type] = prepFeatureIncoming(type, wallsAndVertices[types_1.IElements.WALL], attributes[config.attributes[type]], config);
136
+ return output;
137
+ }, {});
138
+ return __assign(__assign({}, wallsAndVertices), (_a = { validationConfig: wallsValidation }, _a[types_1.IElements.FEATURE] = featuresData, _a));
139
+ }
140
+ exports.prepAttributesIncoming = prepAttributesIncoming;
141
+ function getAttributeDefaults(attributes, config) {
142
+ return [
143
+ types_1.IElements.WALL,
144
+ types_1.IElements.WINDOW,
145
+ types_1.IElements.DOOR,
146
+ types_1.IElements.OPENING,
147
+ ].reduce(function (output, elementName) {
148
+ var _a;
149
+ if (!config.attributes[elementName])
150
+ return output;
151
+ var attribute = attributes[config.attributes[elementName]];
152
+ if (!attribute)
153
+ return output;
154
+ return Object.assign(output, (_a = {},
155
+ _a[elementName] = attribute.values[0].assetId,
156
+ _a));
157
+ }, {});
158
+ }
159
+ exports.getAttributeDefaults = getAttributeDefaults;
160
+ function prepFeaturesOutgoing(features, config) {
161
+ var attributeName = config.attributes;
162
+ return features.map(function (feature) {
163
+ var _a, _b;
164
+ var assetId = feature.assetId, offset = feature.offset, length = feature.length, height = feature.height, altitude = feature.altitude, restConfiguration = feature.restConfiguration;
165
+ var connectedTo = prepConnectionOutgoing([
166
+ config.attributes[feature.connectedTo[0]],
167
+ feature.connectedTo[1],
168
+ ]);
169
+ var configurationToScale = (_a = {},
170
+ _a[attributeName.featureLength] = length,
171
+ _a[attributeName.featurePositionX] = offset,
172
+ _a);
173
+ if (altitude)
174
+ configurationToScale[attributeName.featurePositionY] = altitude;
175
+ if (height)
176
+ configurationToScale[attributeName.featureHeight] = height;
177
+ var configuration = Object.entries(configurationToScale).reduce(function (output, _a) {
178
+ var _b;
179
+ var key = _a[0], value = _a[1];
180
+ return Object.assign(output, (_b = {},
181
+ _b[key] = value ? value * config.config.scale : value,
182
+ _b));
183
+ }, __assign((_b = {}, _b[attributeName.featureConnectedTo] = connectedTo, _b), JSON.parse(restConfiguration)));
184
+ return {
185
+ assetId: assetId,
186
+ configuration: configuration,
187
+ };
188
+ });
189
+ }
190
+ function prepWallsOutgoing(walls, config) {
191
+ var attributeName = config.attributes;
192
+ return walls.map(function (wall) {
193
+ var _a, _b;
194
+ var line = wall.line, restConfiguration = wall.restConfiguration;
195
+ var connections = wall.connections.map(function (connection) {
196
+ var attributeName = config.attributes[connection[0]];
197
+ if (!attributeName)
198
+ return;
199
+ return prepConnectionOutgoing([attributeName, connection[1]]);
200
+ });
201
+ var _c = line.flat(), x1 = _c[0], y1 = _c[1], x2 = _c[2], y2 = _c[3];
202
+ var configuration = Object.entries((_a = {},
203
+ _a[attributeName.wallStartX] = x1,
204
+ _a[attributeName.wallStartZ] = y1,
205
+ _a[attributeName.wallEndX] = x2,
206
+ _a[attributeName.wallEndZ] = y2,
207
+ _a)).reduce(function (output, _a) {
208
+ var _b;
209
+ var key = _a[0], value = _a[1];
210
+ return Object.assign(output, (_b = {},
211
+ _b[key] = value ? value * config.config.scale : value,
212
+ _b));
213
+ }, __assign((_b = {}, _b[attributeName.wallConnections] = JSON.stringify(connections), _b), JSON.parse(restConfiguration)));
214
+ return {
215
+ assetId: wall.assetId,
216
+ configuration: configuration,
217
+ };
218
+ });
219
+ }
220
+ function prepAttributesOutgoing(walls, features, config) {
221
+ var _a;
222
+ var wallsAttribute = prepWallsOutgoing(walls, config);
223
+ var featuresAttributes = Object.entries(features).reduce(function (output, _a) {
224
+ var type = _a[0], features = _a[1];
225
+ var attributeName = config.attributes[type];
226
+ if (!attributeName)
227
+ return output;
228
+ output[attributeName] = prepFeaturesOutgoing(features, config);
229
+ return output;
230
+ }, {});
231
+ return __assign(__assign({}, featuresAttributes), (_a = {}, _a[config.attributes[types_1.IElements.WALL]] = wallsAttribute, _a));
232
+ }
233
+ exports.prepAttributesOutgoing = prepAttributesOutgoing;
234
+ function convertLengthUnit(value, from, to) {
235
+ return (value / constants_1.UNIT_FACTORS[from]) * constants_1.UNIT_FACTORS[to];
236
+ }
237
+ exports.convertLengthUnit = convertLengthUnit;
238
+ function convertAreaUnit(value, from, to) {
239
+ return (value / constants_1.UNIT_FACTORS[from]) * Math.pow(constants_1.UNIT_FACTORS[to], 2);
240
+ }
241
+ exports.convertAreaUnit = convertAreaUnit;
242
+ function prepLengthForUser(value, unit) {
243
+ if (unit === types_1.IUnits.FEET) {
244
+ var feet = Math.floor(value);
245
+ var inches = 12 * (value % 1);
246
+ return "".concat(feet).concat(constants_1.UNIT_LABELS[types_1.IUnits.FEET], " ").concat(inches.toFixed(1)).concat(constants_1.UNIT_LABELS[types_1.IUnits.INCH]);
247
+ }
248
+ return "".concat(value.toFixed(2), " ").concat(constants_1.UNIT_LABELS[unit]);
249
+ }
250
+ exports.prepLengthForUser = prepLengthForUser;
251
+ function prepAreaForUser(value, unit) {
252
+ return "".concat(value.toFixed(2), " sq-").concat(constants_1.UNIT_LABELS[unit]);
253
+ }
254
+ exports.prepAreaForUser = prepAreaForUser;
@@ -0,0 +1,2 @@
1
+ declare function clearCanvas(canvas: HTMLCanvasElement): void;
2
+ export default clearCanvas;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function clearCanvas(canvas) {
4
+ var ctx = canvas.getContext('2d');
5
+ if (!ctx)
6
+ return;
7
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
8
+ }
9
+ exports.default = clearCanvas;
@@ -0,0 +1,2 @@
1
+ declare function drawBackground(canvas: HTMLCanvasElement, color?: string): void;
2
+ export default drawBackground;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function drawBackground(canvas, color) {
4
+ if (!color)
5
+ return;
6
+ var ctx = canvas.getContext('2d');
7
+ if (!ctx)
8
+ return;
9
+ ctx.fillStyle = color;
10
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
11
+ }
12
+ exports.default = drawBackground;
@@ -0,0 +1,3 @@
1
+ import { ICoordinatesLine, ILineDimensions, ISpacesConfigInternal, IStylesDimension } from '../types';
2
+ export declare function drawDimension(canvas: HTMLCanvasElement, line: ICoordinatesLine, styles: IStylesDimension, message: string): void;
3
+ export declare function drawDimensions(canvas: HTMLCanvasElement, dimensions: Array<ILineDimensions>, config: ISpacesConfigInternal): void;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.drawDimensions = exports.drawDimension = void 0;
4
+ var geometry_1 = require("../geometry");
5
+ function drawDimension(canvas, line, styles, message) {
6
+ var ctx = canvas.getContext('2d');
7
+ if (!ctx)
8
+ return;
9
+ var dimensionsBoxHeight = styles.fontSize + 6;
10
+ var dimensionsHeight = dimensionsBoxHeight + 6;
11
+ var line1 = (0, geometry_1.getParallelLineSegmentAtDistance)(line, styles.padding);
12
+ var line2 = (0, geometry_1.getParallelLineSegmentAtDistance)(line, styles.padding + dimensionsHeight / 2);
13
+ var line3 = (0, geometry_1.getParallelLineSegmentAtDistance)(line, styles.padding + dimensionsHeight);
14
+ var textLine = (0, geometry_1.getParallelLineSegmentAtDistance)(line, styles.padding + dimensionsHeight / 3);
15
+ var textCoordinates = (0, geometry_1.getMidpointOfLineSegment)(textLine);
16
+ var textAngle = (0, geometry_1.getAngleOfLineSegment)(textLine);
17
+ if (2 < textAngle || textAngle < -2)
18
+ textAngle += Math.PI;
19
+ ctx.strokeStyle = styles.lineColor;
20
+ ctx.lineWidth = 1;
21
+ ctx.beginPath();
22
+ ctx.moveTo.apply(ctx, line2[0]);
23
+ ctx.lineTo.apply(ctx, line2[1]);
24
+ ctx.stroke();
25
+ ctx.beginPath();
26
+ ctx.moveTo.apply(ctx, line1[0]);
27
+ ctx.lineTo.apply(ctx, line3[0]);
28
+ ctx.stroke();
29
+ ctx.beginPath();
30
+ ctx.moveTo.apply(ctx, line1[1]);
31
+ ctx.lineTo.apply(ctx, line3[1]);
32
+ ctx.stroke();
33
+ ctx.beginPath();
34
+ ctx.font = "".concat(styles.fontSize, "px ").concat(styles.font);
35
+ ctx.font = "".concat(styles.fontSize, "px ").concat(styles.font);
36
+ ctx.translate.apply(ctx, textCoordinates);
37
+ ctx.rotate(textAngle);
38
+ ctx.fillStyle = styles.textBackgroundColor;
39
+ var textWidth = ctx.measureText(message).width + 12;
40
+ ctx.fillRect(-(textWidth / 2), -((dimensionsBoxHeight * 3) / 4), textWidth, dimensionsBoxHeight);
41
+ ctx.fillStyle = styles.textColor;
42
+ ctx.textAlign = 'center';
43
+ ctx.fillText(message, 0, 0);
44
+ ctx.resetTransform();
45
+ }
46
+ exports.drawDimension = drawDimension;
47
+ function drawDimensions(canvas, dimensions, config) {
48
+ dimensions.forEach(function (_a) {
49
+ var line = _a.line, label = _a.label;
50
+ drawDimension(canvas, line, config.styles.dimensions, label);
51
+ });
52
+ }
53
+ exports.drawDimensions = drawDimensions;
@@ -0,0 +1,9 @@
1
+ import { IFeatureDoor, ISpacesStyles } from '../types';
2
+ import { IWallToDraw } from './drawWalls';
3
+ declare function drawDoors(canvas: HTMLCanvasElement, walls: Array<IWallToDraw>, doors: Array<IFeatureDoor>, selections: {
4
+ active: Array<number>;
5
+ highlighted: Array<number>;
6
+ error: Array<number>;
7
+ hidden: Array<number>;
8
+ }, styles: ISpacesStyles): void;
9
+ export default drawDoors;
@@ -0,0 +1,99 @@
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
+ var constants_1 = require("../constants");
13
+ var geometry_1 = require("../geometry");
14
+ var types_1 = require("../types");
15
+ function drawDoor(canvas, wall, offset, length, showSwing, openingDirection, orientation, style, mode) {
16
+ var ctx = canvas.getContext('2d');
17
+ if (!ctx)
18
+ return;
19
+ var doorLine = (0, geometry_1.getLineAtOffsetOnLineSegment)(wall.line, offset, length);
20
+ var points = (0, geometry_1.addThicknessToLine)(doorLine, style.thickness);
21
+ var angle = (0, geometry_1.getAngleOfLineSegment)(doorLine);
22
+ var stroke = style.stroke, fill = style.fill, strokeWidth = style.strokeWidth;
23
+ if (mode) {
24
+ stroke = style[mode].stroke;
25
+ fill = style[mode].fill;
26
+ }
27
+ ctx.beginPath();
28
+ ctx.strokeStyle = stroke || fill;
29
+ ctx.lineWidth = 2;
30
+ var swingRatio = showSwing ? 2 : 48;
31
+ if (openingDirection === constants_1.DoorOpeningDirections.INSIDE) {
32
+ if (orientation === constants_1.DoorOrientations.LEFT) {
33
+ ctx.moveTo.apply(ctx, points[0]);
34
+ ctx.arc.apply(ctx, __spreadArray(__spreadArray([], points[0], false), [length, angle - Math.PI / swingRatio, angle], false));
35
+ }
36
+ else {
37
+ ctx.moveTo.apply(ctx, points[1]);
38
+ ctx.arc.apply(ctx, __spreadArray(__spreadArray([], points[1], false), [length,
39
+ angle - (Math.PI * (swingRatio - 1)) / swingRatio,
40
+ angle - Math.PI,
41
+ true], false));
42
+ }
43
+ }
44
+ else {
45
+ if (orientation === constants_1.DoorOrientations.LEFT) {
46
+ ctx.moveTo.apply(ctx, points[2]);
47
+ ctx.arc.apply(ctx, __spreadArray(__spreadArray([], points[2], false), [length,
48
+ angle + (Math.PI * (swingRatio - 1)) / swingRatio,
49
+ angle + Math.PI], false));
50
+ }
51
+ else {
52
+ ctx.moveTo.apply(ctx, points[3]);
53
+ ctx.arc.apply(ctx, __spreadArray(__spreadArray([], points[3], false), [length, angle + Math.PI / swingRatio, angle, true], false));
54
+ }
55
+ }
56
+ ctx.stroke();
57
+ ctx.strokeStyle = stroke || fill;
58
+ ctx.fillStyle = fill;
59
+ ctx.lineWidth = strokeWidth || 1;
60
+ ctx.beginPath();
61
+ ctx.moveTo.apply(ctx, points[0]);
62
+ for (var i = 1; i < points.length; i++) {
63
+ ctx.lineTo.apply(ctx, points[i]);
64
+ }
65
+ ctx.lineTo.apply(ctx, points[0]);
66
+ ctx.fill();
67
+ if (style.stroke)
68
+ ctx.stroke();
69
+ }
70
+ function drawDoors(canvas, walls, doors, selections, styles) {
71
+ var styled = [
72
+ selections.active,
73
+ selections.highlighted,
74
+ selections.error,
75
+ selections.hidden,
76
+ ];
77
+ var defaultOpenings = doors.reduce(function (output, _, i) {
78
+ if (!styled.flat().includes(i))
79
+ output.push(i);
80
+ return output;
81
+ }, []);
82
+ var doorsMap = [
83
+ [types_1.IElementStyleModes.ACTIVE, selections.active],
84
+ [types_1.IElementStyleModes.HIGHLIGHT, selections.highlighted],
85
+ [types_1.IElementStyleModes.ERROR, selections.error],
86
+ [undefined, defaultOpenings],
87
+ ];
88
+ doorsMap.forEach(function (_a) {
89
+ var mode = _a[0], doorsIndexes = _a[1];
90
+ return doorsIndexes.forEach(function (index) {
91
+ var door = doors[index];
92
+ if (!(door === null || door === void 0 ? void 0 : door.connectedTo.length))
93
+ return;
94
+ var wallIndex = door.connectedTo[1];
95
+ drawDoor(canvas, walls[wallIndex], door.offset, door.length, door.showSwing, door.openingDirection, door.orientation, styles.feature, mode);
96
+ });
97
+ });
98
+ }
99
+ exports.default = drawDoors;
@@ -0,0 +1,3 @@
1
+ import { IEnclosedSpace, IStylesFloor } from '../types';
2
+ export declare function drawFloor(canvas: HTMLCanvasElement, enclosedSpaces: Array<IEnclosedSpace>, styles: IStylesFloor): void;
3
+ export declare function drawFloorArea(canvas: HTMLCanvasElement, enclosedSpaces: Array<IEnclosedSpace>, styles: IStylesFloor): void;