@threekit-tools/treble 0.0.90 → 0.0.91-next-01

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 (205) hide show
  1. package/dist/Treble/Treble.d.ts +2 -2
  2. package/dist/Treble/Treble.js +2 -2
  3. package/dist/Treble/index.d.ts +1 -1
  4. package/dist/Treble/index.js +1 -1
  5. package/dist/components/BreatheAnimation/index.js +2 -2
  6. package/dist/components/TurntableAnimation/index.js +2 -2
  7. package/dist/components/containers/formInputContainer.js +3 -3
  8. package/dist/hooks/useAttribute/index.js +1 -5
  9. package/dist/hooks/useConfigurationChangeStatus/index.d.ts +2 -0
  10. package/dist/hooks/{usePlayerLoadingStatus → useConfigurationChangeStatus}/index.js +2 -2
  11. package/dist/hooks/useNestedConfigurator/index.js +1 -2
  12. package/dist/hooks/usePlayerReady/index.d.ts +2 -0
  13. package/dist/hooks/{useAnimationStart → usePlayerReady}/index.js +2 -2
  14. package/dist/hooks/useSpaces/Canvas.d.ts +37 -0
  15. package/dist/hooks/useSpaces/Canvas.js +199 -0
  16. package/dist/hooks/useSpaces/SpacesLayout.d.ts +11 -0
  17. package/dist/hooks/useSpaces/SpacesLayout.js +74 -0
  18. package/dist/hooks/useSpaces/SpacesState.d.ts +162 -0
  19. package/dist/hooks/useSpaces/SpacesState.js +1791 -0
  20. package/dist/hooks/useSpaces/constants.d.ts +44 -0
  21. package/dist/hooks/useSpaces/constants.js +105 -0
  22. package/dist/hooks/{useRoomBuilder → useSpaces}/dataHandlers.d.ts +6 -4
  23. package/dist/hooks/{useRoomBuilder → useSpaces}/dataHandlers.js +104 -42
  24. package/dist/hooks/useSpaces/draw/clearCanvas.d.ts +2 -0
  25. package/dist/hooks/useSpaces/draw/clearCanvas.js +9 -0
  26. package/dist/hooks/useSpaces/draw/drawBackground.d.ts +2 -0
  27. package/dist/hooks/useSpaces/draw/drawBackground.js +12 -0
  28. package/dist/hooks/useSpaces/draw/drawDimensions.d.ts +3 -0
  29. package/dist/hooks/useSpaces/draw/drawDimensions.js +53 -0
  30. package/dist/hooks/useSpaces/draw/drawDoors.d.ts +9 -0
  31. package/dist/hooks/useSpaces/draw/drawDoors.js +93 -0
  32. package/dist/hooks/useSpaces/draw/drawFloor.d.ts +3 -0
  33. package/dist/hooks/useSpaces/draw/drawFloor.js +36 -0
  34. package/dist/hooks/useSpaces/draw/drawGrid.d.ts +3 -0
  35. package/dist/hooks/useSpaces/draw/drawGrid.js +31 -0
  36. package/dist/hooks/useSpaces/draw/drawGuides.d.ts +3 -0
  37. package/dist/hooks/useSpaces/draw/drawGuides.js +23 -0
  38. package/dist/hooks/useSpaces/draw/drawOpenings.d.ts +9 -0
  39. package/dist/hooks/useSpaces/draw/drawOpenings.js +72 -0
  40. package/dist/hooks/useSpaces/draw/drawVertices.d.ts +8 -0
  41. package/dist/hooks/useSpaces/draw/drawVertices.js +61 -0
  42. package/dist/hooks/useSpaces/draw/drawWalls.d.ts +10 -0
  43. package/dist/hooks/useSpaces/draw/drawWalls.js +64 -0
  44. package/dist/hooks/useSpaces/draw/drawWindows.d.ts +9 -0
  45. package/dist/hooks/useSpaces/draw/drawWindows.js +82 -0
  46. package/dist/hooks/useSpaces/draw/index.d.ts +11 -0
  47. package/dist/hooks/useSpaces/draw/index.js +129 -0
  48. package/dist/hooks/useSpaces/geometry/addThicknessToLine.d.ts +3 -0
  49. package/dist/hooks/useSpaces/geometry/addThicknessToLine.js +13 -0
  50. package/dist/hooks/useSpaces/geometry/areLinesEqual.d.ts +3 -0
  51. package/dist/hooks/useSpaces/geometry/areLinesEqual.js +17 -0
  52. package/dist/hooks/useSpaces/geometry/arePointsEqual.d.ts +3 -0
  53. package/dist/hooks/useSpaces/geometry/arePointsEqual.js +8 -0
  54. package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.d.ts +3 -0
  55. package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.js +11 -0
  56. package/dist/hooks/useSpaces/geometry/closestPointOnLine.d.ts +3 -0
  57. package/dist/hooks/useSpaces/geometry/closestPointOnLine.js +13 -0
  58. package/dist/hooks/useSpaces/geometry/doLinesOverlap.d.ts +2 -0
  59. package/dist/hooks/useSpaces/geometry/doLinesOverlap.js +16 -0
  60. package/dist/hooks/useSpaces/geometry/euclideanMod.d.ts +2 -0
  61. package/dist/hooks/useSpaces/geometry/euclideanMod.js +6 -0
  62. package/dist/hooks/useSpaces/geometry/findLoops.d.ts +6 -0
  63. package/dist/hooks/{useRoomBuilder → useSpaces/geometry}/findLoops.js +14 -9
  64. package/dist/hooks/useSpaces/geometry/getAllLineIntersections.d.ts +6 -0
  65. package/dist/hooks/useSpaces/geometry/getAllLineIntersections.js +23 -0
  66. package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.d.ts +3 -0
  67. package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.js +7 -0
  68. package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.d.ts +3 -0
  69. package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.js +17 -0
  70. package/dist/hooks/useSpaces/geometry/getDistanceToLine.d.ts +3 -0
  71. package/dist/hooks/useSpaces/geometry/getDistanceToLine.js +10 -0
  72. package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.d.ts +3 -0
  73. package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.js +7 -0
  74. package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.d.ts +3 -0
  75. package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.js +17 -0
  76. package/dist/hooks/useSpaces/geometry/getLineOtherPoint.d.ts +3 -0
  77. package/dist/hooks/useSpaces/geometry/getLineOtherPoint.js +11 -0
  78. package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.d.ts +3 -0
  79. package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.js +43 -0
  80. package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.d.ts +3 -0
  81. package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.js +9 -0
  82. package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.d.ts +3 -0
  83. package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.js +20 -0
  84. package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.d.ts +3 -0
  85. package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.js +11 -0
  86. package/dist/hooks/useSpaces/geometry/getPolygonArea.d.ts +3 -0
  87. package/dist/hooks/useSpaces/geometry/getPolygonArea.js +15 -0
  88. package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.d.ts +3 -0
  89. package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.js +16 -0
  90. package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.d.ts +6 -0
  91. package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.js +17 -0
  92. package/dist/hooks/useSpaces/geometry/getTriangleArea.d.ts +3 -0
  93. package/dist/hooks/useSpaces/geometry/getTriangleArea.js +9 -0
  94. package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.d.ts +3 -0
  95. package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.js +12 -0
  96. package/dist/hooks/useSpaces/geometry/index.d.ts +30 -0
  97. package/dist/hooks/useSpaces/geometry/index.js +64 -0
  98. package/dist/hooks/useSpaces/geometry/isPointInPolygon.d.ts +3 -0
  99. package/dist/hooks/useSpaces/geometry/isPointInPolygon.js +21 -0
  100. package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.d.ts +3 -0
  101. package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.js +25 -0
  102. package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.d.ts +3 -0
  103. package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.js +11 -0
  104. package/dist/hooks/useSpaces/geometry/splitLineAtOffset.d.ts +3 -0
  105. package/dist/hooks/useSpaces/geometry/splitLineAtOffset.js +12 -0
  106. package/dist/hooks/useSpaces/geometry/splitLineAtPoint.d.ts +3 -0
  107. package/dist/hooks/useSpaces/geometry/splitLineAtPoint.js +9 -0
  108. package/dist/hooks/useSpaces/geometry/splitLineAtPoints.d.ts +3 -0
  109. package/dist/hooks/useSpaces/geometry/splitLineAtPoints.js +28 -0
  110. package/dist/hooks/useSpaces/index.d.ts +76 -0
  111. package/dist/hooks/useSpaces/index.js +475 -0
  112. package/dist/hooks/useSpaces/themes/blueprint.d.ts +3 -0
  113. package/dist/hooks/useSpaces/themes/blueprint.js +96 -0
  114. package/dist/hooks/useSpaces/themes/default.d.ts +3 -0
  115. package/dist/hooks/useSpaces/themes/default.js +96 -0
  116. package/dist/hooks/{useRoomBuilder/themes.d.ts → useSpaces/themes/index.d.ts} +3 -4
  117. package/dist/hooks/useSpaces/themes/index.js +21 -0
  118. package/dist/hooks/useSpaces/themes/light.d.ts +3 -0
  119. package/dist/hooks/useSpaces/themes/light.js +96 -0
  120. package/dist/hooks/{useRoomBuilder → useSpaces}/types.d.ts +131 -35
  121. package/dist/hooks/{useRoomBuilder → useSpaces}/types.js +13 -1
  122. package/dist/hooks/useSpaces/validators/areWallsDuplicated.d.ts +3 -0
  123. package/dist/hooks/useSpaces/validators/areWallsDuplicated.js +61 -0
  124. package/dist/hooks/useSpaces/validators/areWallsIntersecting.d.ts +3 -0
  125. package/dist/hooks/useSpaces/validators/areWallsIntersecting.js +42 -0
  126. package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.d.ts +3 -0
  127. package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.js +52 -0
  128. package/dist/hooks/useSpaces/validators/areWallsTooShort.d.ts +3 -0
  129. package/dist/hooks/useSpaces/validators/areWallsTooShort.js +37 -0
  130. package/dist/hooks/useSpaces/validators/index.d.ts +15 -0
  131. package/dist/hooks/useSpaces/validators/index.js +40 -0
  132. package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.d.ts +3 -0
  133. package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.js +31 -0
  134. package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.d.ts +3 -0
  135. package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.js +19 -0
  136. package/dist/hooks/useSpaces/validators/isLineTooShort.d.ts +3 -0
  137. package/dist/hooks/useSpaces/validators/isLineTooShort.js +26 -0
  138. package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.d.ts +4 -0
  139. package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.js +19 -0
  140. package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.d.ts +3 -0
  141. package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.js +19 -0
  142. package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.d.ts +3 -0
  143. package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.js +41 -0
  144. package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.d.ts +3 -0
  145. package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.js +54 -0
  146. package/dist/hooks/useSpaces/validators/isWallTooShort.d.ts +3 -0
  147. package/dist/hooks/useSpaces/validators/isWallTooShort.js +10 -0
  148. package/dist/hooks/{useRoomBuilder → useSpaces/validators}/messaging.js +1 -1
  149. package/dist/icons/AngleSnapping.d.ts +3 -0
  150. package/dist/icons/AngleSnapping.js +28 -0
  151. package/dist/icons/Center.d.ts +3 -0
  152. package/dist/icons/Center.js +24 -0
  153. package/dist/icons/Draw.js +3 -3
  154. package/dist/icons/GridSnapping.d.ts +3 -0
  155. package/dist/icons/GridSnapping.js +28 -0
  156. package/dist/icons/LayoutAlt.d.ts +3 -0
  157. package/dist/icons/LayoutAlt.js +21 -0
  158. package/dist/icons/Magnet.d.ts +3 -0
  159. package/dist/icons/Magnet.js +27 -0
  160. package/dist/icons/Player3D.d.ts +3 -0
  161. package/dist/icons/Player3D.js +21 -0
  162. package/dist/icons/Save.d.ts +3 -0
  163. package/dist/icons/Save.js +21 -0
  164. package/dist/icons/UnitCm.d.ts +3 -0
  165. package/dist/icons/UnitCm.js +22 -0
  166. package/dist/icons/UnitFeet.d.ts +3 -0
  167. package/dist/icons/UnitFeet.js +22 -0
  168. package/dist/icons/UnitInch.d.ts +3 -0
  169. package/dist/icons/UnitInch.js +22 -0
  170. package/dist/icons/UnitMeter.d.ts +3 -0
  171. package/dist/icons/UnitMeter.js +21 -0
  172. package/dist/icons/Window.js +4 -4
  173. package/dist/icons/index.js +22 -0
  174. package/dist/icons/types.d.ts +1 -1
  175. package/dist/index.d.ts +17 -3
  176. package/dist/index.js +35 -7
  177. package/dist/store/attributes.d.ts +1 -0
  178. package/dist/store/index.d.ts +39 -8
  179. package/dist/store/index.js +3 -1
  180. package/dist/store/product.js +4 -7
  181. package/dist/store/spaces.d.ts +47 -0
  182. package/dist/store/spaces.js +197 -0
  183. package/dist/store/treble.d.ts +1 -1
  184. package/dist/store/treble.js +24 -26
  185. package/dist/types.d.ts +6 -0
  186. package/package.json +1 -1
  187. package/dist/hooks/useAnimationStart/index.d.ts +0 -2
  188. package/dist/hooks/usePlayerLoadingStatus/index.d.ts +0 -2
  189. package/dist/hooks/useRoomBuilder/RoomBuilderState.d.ts +0 -95
  190. package/dist/hooks/useRoomBuilder/RoomBuilderState.js +0 -1237
  191. package/dist/hooks/useRoomBuilder/constants.d.ts +0 -41
  192. package/dist/hooks/useRoomBuilder/constants.js +0 -48
  193. package/dist/hooks/useRoomBuilder/draw.d.ts +0 -55
  194. package/dist/hooks/useRoomBuilder/draw.js +0 -573
  195. package/dist/hooks/useRoomBuilder/findLoops.d.ts +0 -5
  196. package/dist/hooks/useRoomBuilder/geometry.d.ts +0 -33
  197. package/dist/hooks/useRoomBuilder/geometry.js +0 -325
  198. package/dist/hooks/useRoomBuilder/index.d.ts +0 -40
  199. package/dist/hooks/useRoomBuilder/index.js +0 -303
  200. package/dist/hooks/useRoomBuilder/themes.js +0 -273
  201. package/dist/hooks/useRoomBuilder/validators.d.ts +0 -36
  202. package/dist/hooks/useRoomBuilder/validators.js +0 -362
  203. /package/dist/Treble/{snapshots.d.ts → snapshot.d.ts} +0 -0
  204. /package/dist/Treble/{snapshots.js → snapshot.js} +0 -0
  205. /package/dist/hooks/{useRoomBuilder → useSpaces/validators}/messaging.d.ts +0 -0
@@ -0,0 +1,44 @@
1
+ import { ICoordinate2D, ISpacesAttributes, IWallsValidationConfig } from './types';
2
+ export declare enum WallMetadata {
3
+ MIN_LENGTH = "_tkSpace_minLength",
4
+ PADDING = "_tkSpace_padding"
5
+ }
6
+ export declare enum DoorOrientations {
7
+ LEFT = "Left",
8
+ RIGHT = "Right"
9
+ }
10
+ export declare enum DoorOpeningDirections {
11
+ INSIDE = "inside",
12
+ OUTSIDE = "outside"
13
+ }
14
+ export declare const ATTRIBUTE_NAME_DEFAULTS: ISpacesAttributes;
15
+ export declare const SCALE = 0.02;
16
+ export declare const SNAP_PROXIMITY = 16;
17
+ export declare const ZOOM_MAX = 100;
18
+ export declare const ZOOM_MIN = 20;
19
+ export declare const ZOOM_DEFAULT = 40;
20
+ export declare const ZOOM_SENSITIVITY = 0.8;
21
+ export declare const TRANSLATE_MAX: ICoordinate2D;
22
+ export declare const TRANSLATE_MIN: ICoordinate2D;
23
+ export declare const TRANSLATE_DEFAULT: ICoordinate2D;
24
+ export declare const UNIT_LABELS: {
25
+ feet: string;
26
+ meter: string;
27
+ inch: string;
28
+ cm: string;
29
+ };
30
+ export declare const UNIT_FACTORS: {
31
+ cm: number;
32
+ meter: number;
33
+ feet: number;
34
+ inch: number;
35
+ };
36
+ export declare const FEATURE_LABELS: {
37
+ windows: string;
38
+ doors: string;
39
+ openings: string;
40
+ };
41
+ export declare const VALIDATION_CONFIG_DEFAULT: IWallsValidationConfig;
42
+ export declare const FEATURE_LENGTH = 120;
43
+ export declare const UI_ANCHOR_DISTANCE = -60;
44
+ export declare const WALL_SNAP_DISTANCE = 12;
@@ -0,0 +1,105 @@
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.WallMetadata = 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 WallAttributes;
14
+ (function (WallAttributes) {
15
+ WallAttributes["START_X"] = "_tkSpace_startX";
16
+ WallAttributes["START_Y"] = "_tkSpace_startY";
17
+ WallAttributes["START_Z"] = "_tkSpace_startZ";
18
+ WallAttributes["END_X"] = "_tkSpace_endX";
19
+ WallAttributes["END_Y"] = "_tkSpace_endY";
20
+ WallAttributes["END_Z"] = "_tkSpace_endZ";
21
+ WallAttributes["CONNECTIONS"] = "_tkSpace_connections";
22
+ WallAttributes["WALL_HEIGHT"] = "_tkSpace_wallHeight";
23
+ WallAttributes["WALL_THICKNESS"] = "_tkSpace_wallThickness";
24
+ })(WallAttributes || (WallAttributes = {}));
25
+ var WallMetadata;
26
+ (function (WallMetadata) {
27
+ WallMetadata["MIN_LENGTH"] = "_tkSpace_minLength";
28
+ WallMetadata["PADDING"] = "_tkSpace_padding";
29
+ })(WallMetadata = exports.WallMetadata || (exports.WallMetadata = {}));
30
+ var FeatureAttributes;
31
+ (function (FeatureAttributes) {
32
+ FeatureAttributes["POSITION_X"] = "_tkSpace_offsetX";
33
+ FeatureAttributes["POSITION_Y"] = "_tkSpace_offsetY";
34
+ FeatureAttributes["CONNECTED_TO"] = "_tkSpace_connectedTo";
35
+ FeatureAttributes["FEATURE_HEIGHT"] = "_tkSpace_featureHeight";
36
+ FeatureAttributes["FEATURE_LENGTH"] = "_tkSpace_featureWidth";
37
+ })(FeatureAttributes || (FeatureAttributes = {}));
38
+ var DoorAttributes;
39
+ (function (DoorAttributes) {
40
+ DoorAttributes["ORIENTATION"] = "_tkSpace_doorOrientation";
41
+ DoorAttributes["OPENING_DIRECTION"] = "_tkSpace_doorOpeningDirection";
42
+ })(DoorAttributes || (DoorAttributes = {}));
43
+ var DoorOrientations;
44
+ (function (DoorOrientations) {
45
+ DoorOrientations["LEFT"] = "Left";
46
+ DoorOrientations["RIGHT"] = "Right";
47
+ })(DoorOrientations = exports.DoorOrientations || (exports.DoorOrientations = {}));
48
+ var DoorOpeningDirections;
49
+ (function (DoorOpeningDirections) {
50
+ DoorOpeningDirections["INSIDE"] = "inside";
51
+ DoorOpeningDirections["OUTSIDE"] = "outside";
52
+ })(DoorOpeningDirections = exports.DoorOpeningDirections || (exports.DoorOpeningDirections = {}));
53
+ exports.ATTRIBUTE_NAME_DEFAULTS = (_a = {},
54
+ _a[types_1.IElements.WALL] = SpacesAttributes.WALLS,
55
+ _a[types_1.IElements.WINDOW] = SpacesAttributes.WINDOWS,
56
+ _a[types_1.IElements.OPENING] = SpacesAttributes.OPENINGS,
57
+ _a[types_1.IElements.DOOR] = SpacesAttributes.DOORS,
58
+ _a.featurePositionX = FeatureAttributes.POSITION_X,
59
+ _a.featurePositionY = FeatureAttributes.POSITION_Y,
60
+ _a.featureConnectedTo = FeatureAttributes.CONNECTED_TO,
61
+ _a.featureHeight = FeatureAttributes.FEATURE_HEIGHT,
62
+ _a.featureLength = FeatureAttributes.FEATURE_LENGTH,
63
+ _a.wallStartX = WallAttributes.START_X,
64
+ _a.wallStartY = WallAttributes.START_Y,
65
+ _a.wallStartZ = WallAttributes.START_Z,
66
+ _a.wallEndX = WallAttributes.END_X,
67
+ _a.wallEndY = WallAttributes.END_Y,
68
+ _a.wallEndZ = WallAttributes.END_Z,
69
+ _a.wallConnections = WallAttributes.CONNECTIONS,
70
+ _a.doorOrientation = DoorAttributes.ORIENTATION,
71
+ _a.doorOpeningDirection = DoorAttributes.OPENING_DIRECTION,
72
+ _a);
73
+ exports.SCALE = 0.02;
74
+ exports.SNAP_PROXIMITY = 16;
75
+ exports.ZOOM_MAX = 100;
76
+ exports.ZOOM_MIN = 20;
77
+ exports.ZOOM_DEFAULT = 40;
78
+ exports.ZOOM_SENSITIVITY = 0.8;
79
+ exports.TRANSLATE_MAX = [-400, -400];
80
+ exports.TRANSLATE_MIN = [400, 400];
81
+ exports.TRANSLATE_DEFAULT = [-200, -200];
82
+ exports.UNIT_LABELS = (_b = {},
83
+ _b[types_1.IUnits.FEET] = 'ft',
84
+ _b[types_1.IUnits.METER] = 'm',
85
+ _b[types_1.IUnits.INCH] = 'in',
86
+ _b[types_1.IUnits.CM] = 'cm',
87
+ _b);
88
+ exports.UNIT_FACTORS = (_c = {},
89
+ _c[types_1.IUnits.CM] = 100,
90
+ _c[types_1.IUnits.METER] = 1,
91
+ _c[types_1.IUnits.FEET] = 3.28084,
92
+ _c[types_1.IUnits.INCH] = 39.37,
93
+ _c);
94
+ exports.FEATURE_LABELS = (_d = {},
95
+ _d[types_1.IElements.WINDOW] = 'Window',
96
+ _d[types_1.IElements.DOOR] = 'Door',
97
+ _d[types_1.IElements.OPENING] = 'Opening',
98
+ _d);
99
+ exports.VALIDATION_CONFIG_DEFAULT = {
100
+ padding: 0.2,
101
+ minLength: 0.5,
102
+ };
103
+ exports.FEATURE_LENGTH = 120;
104
+ exports.UI_ANCHOR_DISTANCE = -60;
105
+ exports.WALL_SNAP_DISTANCE = 12;
@@ -1,12 +1,14 @@
1
- import type { IWalls, IRoomBuilderStateProps, IVerticesState, IFeatures } from './types';
1
+ import type { IWalls, ISpacesStateProps, IVerticesState, IFeatures, IWallsValidationConfig, IAttributeDefaults } from './types';
2
2
  import { IUnits } from './types';
3
3
  import type { IConfiguration, IHydratedAttribute } from '../../types';
4
- export declare function prepAttributesIncoming(attributes: Record<string, IHydratedAttribute>, config: IRoomBuilderStateProps): {
5
- features: IFeatures;
4
+ export declare function prepAttributesIncoming(attributes: Record<string, IHydratedAttribute>, config: ISpacesStateProps): {
5
+ validationConfig: IWallsValidationConfig;
6
+ features: {};
6
7
  walls: IWalls;
7
8
  vertex: IVerticesState;
8
9
  };
9
- export declare function prepAttributesOutgoing(walls: IWalls, features: IFeatures, config: IRoomBuilderStateProps): {
10
+ export declare function getAttributeDefaults(attributes: Record<string, IHydratedAttribute>, config: ISpacesStateProps): IAttributeDefaults;
11
+ export declare function prepAttributesOutgoing(walls: IWalls, features: IFeatures, config: ISpacesStateProps): {
10
12
  [x: string]: import("../../types").IConfigurationAttribute | {
11
13
  assetId: string;
12
14
  configuration: IConfiguration;
@@ -11,10 +11,21 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.prepAreaForUser = exports.prepLengthForUser = exports.convertAreaUnit = exports.convertLengthUnit = exports.prepAttributesOutgoing = exports.prepAttributesIncoming = void 0;
14
+ exports.prepAreaForUser = exports.prepLengthForUser = exports.convertAreaUnit = exports.convertLengthUnit = exports.prepAttributesOutgoing = exports.getAttributeDefaults = exports.prepAttributesIncoming = void 0;
15
15
  var types_1 = require("./types");
16
16
  var constants_1 = require("./constants");
17
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
+ }
18
29
  function prepConnectionOutgoing(connection) {
19
30
  return "".concat(connection[0], ".").concat(connection[1]);
20
31
  }
@@ -26,15 +37,16 @@ function prepWallsAndVerticesIncoming(wallsAttribute, config) {
26
37
  var _a;
27
38
  var walls = [];
28
39
  var vertices = {};
40
+ var attributeName = config.attributes;
29
41
  ((wallsAttribute === null || wallsAttribute === void 0 ? void 0 : wallsAttribute.value) || []).forEach(function (_a, i) {
30
42
  var assetId = _a.assetId, configuration = _a.configuration;
31
43
  var point1 = [
32
- (configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IWallAttributes.START_X]) / config.config.scale,
33
- (configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IWallAttributes.START_Z]) / config.config.scale,
44
+ (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.wallStartX]) / config.config.scale,
45
+ (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.wallStartZ]) / config.config.scale,
34
46
  ];
35
47
  var point2 = [
36
- (configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IWallAttributes.END_X]) / config.config.scale,
37
- (configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IWallAttributes.END_Z]) / config.config.scale,
48
+ (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.wallEndX]) / config.config.scale,
49
+ (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.wallEndZ]) / config.config.scale,
38
50
  ];
39
51
  var point1Str = JSON.stringify(point1);
40
52
  var point2Str = JSON.stringify(point2);
@@ -51,66 +63,119 @@ function prepWallsAndVerticesIncoming(wallsAttribute, config) {
51
63
  assetId: assetId,
52
64
  line: [point1, point2],
53
65
  path: (0, geometry_1.addThicknessToLine)([point1, point2], config.config.styles.wall.thickness),
54
- height: configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IWallAttributes.HEIGHT],
55
- thickness: configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IWallAttributes.THICKNESS],
56
66
  connections: connections,
67
+ restConfiguration: JSON.stringify(filterRestConfiguration(configuration, config.attributes)),
57
68
  });
58
69
  });
59
70
  return _a = {}, _a[types_1.IElements.WALL] = walls, _a[types_1.IElements.VERTEX] = vertices, _a;
60
71
  }
61
- function prepFeatureIncoming(walls, featureAttribute, config) {
72
+ function getWallsVaidationConfig(wallsAttribute, config) {
73
+ var _a, _b;
74
+ var metadata = (wallsAttribute === null || wallsAttribute === void 0 ? void 0 : wallsAttribute.values[0].metadata) || {};
75
+ var validation = {
76
+ minLength: ((_a = metadata[constants_1.WallMetadata.MIN_LENGTH]) !== null && _a !== void 0 ? _a : constants_1.VALIDATION_CONFIG_DEFAULT.minLength) / config.config.scale,
77
+ padding: ((_b = metadata[constants_1.WallMetadata.PADDING]) !== null && _b !== void 0 ? _b : constants_1.VALIDATION_CONFIG_DEFAULT.padding) / config.config.scale,
78
+ };
79
+ return validation;
80
+ }
81
+ function prepFeatureIncoming(type, walls, featureAttribute, config) {
62
82
  var _a;
83
+ var attributeName = config.attributes;
63
84
  var feature = [];
64
85
  (_a = featureAttribute === null || featureAttribute === void 0 ? void 0 : featureAttribute.value) === null || _a === void 0 ? void 0 : _a.forEach(function (_a) {
65
86
  var assetId = _a.assetId, configuration = _a.configuration;
66
- var offset = (configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IFeatureAttribute.POSITION_X]) / config.config.scale;
67
- var length = (configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IFeatureAttribute.LENGTH]) / config.config.scale ||
68
- constants_1.FEATURE_LENGTH;
69
- var connectedTo = (configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IFeatureAttribute.CONNECTED_TO]) || '';
87
+ var offset = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featurePositionX]) / config.config.scale;
88
+ var length = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featureLength]) / config.config.scale;
89
+ var height = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featureHeight]) / config.config.scale;
90
+ var altitude = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featurePositionY]) / config.config.scale;
91
+ var connectedTo = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featureConnectedTo]) || '';
70
92
  var wallIndex = prepConnectionIncoming(connectedTo)[1];
71
93
  var featureLine = (0, geometry_1.getLineAtOffsetOnLineSegment)(walls[wallIndex].line, offset, length);
72
- var path = (0, geometry_1.addThicknessToLine)(featureLine, config.config.styles.feature.thickness);
73
- feature.push({
94
+ var element = {
74
95
  assetId: assetId,
75
96
  offset: offset,
76
97
  length: length,
77
- path: path,
98
+ height: height,
99
+ altitude: altitude,
78
100
  connectedTo: [types_1.IElements.WALL, wallIndex],
79
- });
101
+ path: (0, geometry_1.addThicknessToLine)(featureLine, config.config.styles.feature.thickness),
102
+ restConfiguration: JSON.stringify(filterRestConfiguration(configuration, config.attributes)),
103
+ };
104
+ if (type === types_1.IElements.DOOR) {
105
+ element.orientation =
106
+ (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.doorOrientation]) || constants_1.DoorOrientations.LEFT;
107
+ element.openingDirection =
108
+ (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.doorOpeningDirection]) ||
109
+ constants_1.DoorOpeningDirections.INSIDE;
110
+ }
111
+ feature.push(element);
80
112
  });
81
113
  return feature;
82
114
  }
83
115
  function prepAttributesIncoming(attributes, config) {
84
116
  var _a;
85
- var featuresList = [types_1.IElements.WINDOW, types_1.IElements.DOOR, types_1.IElements.OPENING];
86
- var wallsAndVertices = prepWallsAndVerticesIncoming(attributes[config.attributes[types_1.IElements.WALL]], config);
117
+ var wallsAttribute = attributes[config.attributes[types_1.IElements.WALL]];
118
+ var wallsAndVertices = prepWallsAndVerticesIncoming(wallsAttribute, config);
119
+ var wallsValidation = getWallsVaidationConfig(wallsAttribute, config);
120
+ var featuresList = [
121
+ types_1.IElements.WINDOW,
122
+ types_1.IElements.DOOR,
123
+ types_1.IElements.OPENING,
124
+ ];
87
125
  var featuresData = featuresList.reduce(function (output, type) {
88
- output[type] = prepFeatureIncoming(wallsAndVertices[types_1.IElements.WALL], attributes[config.attributes[type]], config);
126
+ output[type] = prepFeatureIncoming(type, wallsAndVertices[types_1.IElements.WALL], attributes[config.attributes[type]], config);
89
127
  return output;
90
128
  }, {});
91
- return __assign(__assign({}, wallsAndVertices), (_a = {}, _a[types_1.IElements.FEATURE] = featuresData, _a));
129
+ return __assign(__assign({}, wallsAndVertices), (_a = { validationConfig: wallsValidation }, _a[types_1.IElements.FEATURE] = featuresData, _a));
92
130
  }
93
131
  exports.prepAttributesIncoming = prepAttributesIncoming;
94
- function prepFeaturesOutgoing(features, config) {
132
+ function getAttributeDefaults(attributes, config) {
133
+ return [
134
+ types_1.IElements.WALL,
135
+ types_1.IElements.WINDOW,
136
+ types_1.IElements.DOOR,
137
+ types_1.IElements.OPENING,
138
+ ].reduce(function (output, elementName) {
139
+ var _a;
140
+ if (!config.attributes[elementName])
141
+ return output;
142
+ var attribute = attributes[config.attributes[elementName]];
143
+ if (!attribute)
144
+ return output;
145
+ return Object.assign(output, (_a = {},
146
+ _a[elementName] = attribute.values[0].assetId,
147
+ _a));
148
+ }, {});
149
+ }
150
+ exports.getAttributeDefaults = getAttributeDefaults;
151
+ function prepFeaturesOutgoing(type, features, config) {
152
+ var attributeName = config.attributes;
95
153
  return features.map(function (feature) {
96
154
  var _a, _b;
97
- var assetId = feature.assetId, offset = feature.offset, length = feature.length;
155
+ var assetId = feature.assetId, offset = feature.offset, length = feature.length, height = feature.height, altitude = feature.altitude, restConfiguration = feature.restConfiguration;
98
156
  var connectedTo = prepConnectionOutgoing([
99
157
  config.attributes[feature.connectedTo[0]],
100
158
  feature.connectedTo[1],
101
159
  ]);
102
- var configuration = Object.entries((_a = {},
103
- _a[constants_1.IFeatureAttribute.LENGTH] = length,
104
- _a[constants_1.IFeatureAttribute.POSITION_X] = offset,
105
- _a)).reduce(function (output, _a) {
160
+ var configurationToScale = (_a = {},
161
+ _a[attributeName.featureLength] = length,
162
+ _a[attributeName.featurePositionX] = offset,
163
+ _a);
164
+ if (altitude)
165
+ configurationToScale[attributeName.featurePositionY] = altitude;
166
+ if (height)
167
+ configurationToScale[attributeName.featureHeight] = height;
168
+ var configuration = Object.entries(configurationToScale).reduce(function (output, _a) {
106
169
  var _b;
107
170
  var key = _a[0], value = _a[1];
108
171
  return Object.assign(output, (_b = {},
109
172
  _b[key] = value ? value * config.config.scale : value,
110
173
  _b));
111
- }, (_b = {},
112
- _b[constants_1.IFeatureAttribute.CONNECTED_TO] = connectedTo,
113
- _b));
174
+ }, __assign((_b = {}, _b[attributeName.featureConnectedTo] = connectedTo, _b), JSON.parse(restConfiguration)));
175
+ if (type === types_1.IElements.DOOR) {
176
+ configuration[attributeName.doorOrientation] = feature.orientation;
177
+ configuration[attributeName.doorOpeningDirection] = feature.openingDirection;
178
+ }
114
179
  return {
115
180
  assetId: assetId,
116
181
  configuration: configuration,
@@ -118,9 +183,10 @@ function prepFeaturesOutgoing(features, config) {
118
183
  });
119
184
  }
120
185
  function prepWallsOutgoing(walls, config) {
186
+ var attributeName = config.attributes;
121
187
  return walls.map(function (wall) {
122
188
  var _a, _b;
123
- var line = wall.line, height = wall.height, thickness = wall.thickness;
189
+ var line = wall.line, restConfiguration = wall.restConfiguration;
124
190
  var connections = wall.connections.map(function (connection) {
125
191
  var attributeName = config.attributes[connection[0]];
126
192
  if (!attributeName)
@@ -129,21 +195,17 @@ function prepWallsOutgoing(walls, config) {
129
195
  });
130
196
  var _c = line.flat(), x1 = _c[0], y1 = _c[1], x2 = _c[2], y2 = _c[3];
131
197
  var configuration = Object.entries((_a = {},
132
- _a[constants_1.IWallAttributes.START_X] = x1,
133
- _a[constants_1.IWallAttributes.START_Z] = y1,
134
- _a[constants_1.IWallAttributes.END_X] = x2,
135
- _a[constants_1.IWallAttributes.END_Z] = y2,
136
- _a[constants_1.IWallAttributes.HEIGHT] = height,
137
- _a[constants_1.IWallAttributes.THICKNESS] = thickness,
198
+ _a[attributeName.wallStartX] = x1,
199
+ _a[attributeName.wallStartZ] = y1,
200
+ _a[attributeName.wallEndX] = x2,
201
+ _a[attributeName.wallEndZ] = y2,
138
202
  _a)).reduce(function (output, _a) {
139
203
  var _b;
140
204
  var key = _a[0], value = _a[1];
141
205
  return Object.assign(output, (_b = {},
142
206
  _b[key] = value ? value * config.config.scale : value,
143
207
  _b));
144
- }, (_b = {},
145
- _b[constants_1.IWallAttributes.CONNECTIONS] = JSON.stringify(connections),
146
- _b));
208
+ }, __assign((_b = {}, _b[attributeName.wallConnections] = JSON.stringify(connections), _b), JSON.parse(restConfiguration)));
147
209
  return {
148
210
  assetId: wall.assetId,
149
211
  configuration: configuration,
@@ -158,7 +220,7 @@ function prepAttributesOutgoing(walls, features, config) {
158
220
  var attributeName = config.attributes[type];
159
221
  if (!attributeName)
160
222
  return output;
161
- output[attributeName] = prepFeaturesOutgoing(features, config);
223
+ output[attributeName] = prepFeaturesOutgoing(type, features, config);
162
224
  return output;
163
225
  }, {});
164
226
  return __assign(__assign({}, featuresAttributes), (_a = {}, _a[config.attributes[types_1.IElements.WALL]] = wallsAttribute, _a));
@@ -175,8 +237,8 @@ exports.convertAreaUnit = convertAreaUnit;
175
237
  function prepLengthForUser(value, unit) {
176
238
  if (unit === types_1.IUnits.FEET) {
177
239
  var feet = Math.floor(value);
178
- var inches = 1.2 * (value % 1);
179
- return "".concat(feet).concat(constants_1.UNIT_LABELS[types_1.IUnits.FEET], " ").concat(inches.toFixed(2)).concat(constants_1.UNIT_LABELS[types_1.IUnits.INCH]);
240
+ var inches = 12 * (value % 1);
241
+ 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]);
180
242
  }
181
243
  return "".concat(value.toFixed(2), " ").concat(constants_1.UNIT_LABELS[unit]);
182
244
  }
@@ -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,93 @@
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, 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
+ if (openingDirection === constants_1.DoorOpeningDirections.INSIDE) {
31
+ if (orientation === constants_1.DoorOrientations.LEFT) {
32
+ ctx.moveTo.apply(ctx, points[0]);
33
+ ctx.arc.apply(ctx, __spreadArray(__spreadArray([], points[0], false), [length, angle - Math.PI / 2, angle], false));
34
+ }
35
+ else {
36
+ ctx.moveTo.apply(ctx, points[1]);
37
+ ctx.arc.apply(ctx, __spreadArray(__spreadArray([], points[1], false), [length, angle - Math.PI / 2, angle - Math.PI, true], false));
38
+ }
39
+ }
40
+ else {
41
+ if (orientation === constants_1.DoorOrientations.LEFT) {
42
+ ctx.moveTo.apply(ctx, points[2]);
43
+ ctx.arc.apply(ctx, __spreadArray(__spreadArray([], points[2], false), [length, angle + Math.PI / 2, angle + Math.PI], false));
44
+ }
45
+ else {
46
+ ctx.moveTo.apply(ctx, points[3]);
47
+ ctx.arc.apply(ctx, __spreadArray(__spreadArray([], points[3], false), [length, angle + Math.PI / 2, angle, true], false));
48
+ }
49
+ }
50
+ ctx.stroke();
51
+ ctx.strokeStyle = stroke || fill;
52
+ ctx.fillStyle = fill;
53
+ ctx.lineWidth = strokeWidth || 1;
54
+ ctx.beginPath();
55
+ ctx.moveTo.apply(ctx, points[0]);
56
+ for (var i = 1; i < points.length; i++) {
57
+ ctx.lineTo.apply(ctx, points[i]);
58
+ }
59
+ ctx.lineTo.apply(ctx, points[0]);
60
+ ctx.fill();
61
+ if (style.stroke)
62
+ ctx.stroke();
63
+ }
64
+ function drawDoors(canvas, walls, doors, selections, styles) {
65
+ var styled = [
66
+ selections.active,
67
+ selections.highlighted,
68
+ selections.error,
69
+ selections.hidden,
70
+ ];
71
+ var defaultOpenings = doors.reduce(function (output, _, i) {
72
+ if (!styled.flat().includes(i))
73
+ output.push(i);
74
+ return output;
75
+ }, []);
76
+ var doorsMap = [
77
+ [types_1.IElementStyleModes.ACTIVE, selections.active],
78
+ [types_1.IElementStyleModes.HIGHLIGHT, selections.highlighted],
79
+ [types_1.IElementStyleModes.ERROR, selections.error],
80
+ [undefined, defaultOpenings],
81
+ ];
82
+ doorsMap.forEach(function (_a) {
83
+ var mode = _a[0], doorsIndexes = _a[1];
84
+ return doorsIndexes.forEach(function (index) {
85
+ var door = doors[index];
86
+ if (!(door === null || door === void 0 ? void 0 : door.connectedTo.length))
87
+ return;
88
+ var wallIndex = door.connectedTo[1];
89
+ drawDoor(canvas, walls[wallIndex], door.offset, door.length, door.openingDirection, door.orientation, styles.feature, mode);
90
+ });
91
+ });
92
+ }
93
+ 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;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.drawFloorArea = exports.drawFloor = void 0;
4
+ function drawFloor(canvas, enclosedSpaces, styles) {
5
+ var ctx = canvas.getContext('2d');
6
+ if (!ctx)
7
+ return;
8
+ if (!enclosedSpaces.length)
9
+ return;
10
+ for (var _i = 0, enclosedSpaces_1 = enclosedSpaces; _i < enclosedSpaces_1.length; _i++) {
11
+ var enclosedSpace = enclosedSpaces_1[_i];
12
+ var loop = enclosedSpace.loop;
13
+ ctx.fillStyle = styles.color;
14
+ ctx.beginPath();
15
+ ctx.moveTo.apply(ctx, loop[0]);
16
+ for (var i = 1; i < loop.length; i++)
17
+ ctx.lineTo.apply(ctx, loop[i]);
18
+ ctx.fill();
19
+ }
20
+ }
21
+ exports.drawFloor = drawFloor;
22
+ function drawFloorArea(canvas, enclosedSpaces, styles) {
23
+ var ctx = canvas.getContext('2d');
24
+ if (!ctx)
25
+ return;
26
+ if (!enclosedSpaces.length)
27
+ return;
28
+ for (var _i = 0, enclosedSpaces_2 = enclosedSpaces; _i < enclosedSpaces_2.length; _i++) {
29
+ var enclosedSpace = enclosedSpaces_2[_i];
30
+ var center = enclosedSpace.center, area = enclosedSpace.area;
31
+ ctx.font = '20px Arial';
32
+ ctx.fillStyle = styles.textColor;
33
+ ctx.fillText(area, center[0], center[1]);
34
+ }
35
+ }
36
+ exports.drawFloorArea = drawFloorArea;
@@ -0,0 +1,3 @@
1
+ import { IGridToDraw, IStylesGrid } from '../types';
2
+ declare function drawGrid(canvas: HTMLCanvasElement, grid: IGridToDraw, styles: IStylesGrid): void;
3
+ export default drawGrid;