@threekit-tools/treble 0.0.94-next-02 → 0.0.95

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 (202) 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/hooks/useNestedConfigurator/index.js +2 -1
  6. package/dist/hooks/useRoomBuilder/RoomBuilderState.d.ts +95 -0
  7. package/dist/hooks/useRoomBuilder/RoomBuilderState.js +1237 -0
  8. package/dist/hooks/useRoomBuilder/constants.d.ts +41 -0
  9. package/dist/hooks/useRoomBuilder/constants.js +48 -0
  10. package/dist/hooks/useRoomBuilder/dataHandlers.d.ts +18 -0
  11. package/dist/hooks/useRoomBuilder/dataHandlers.js +187 -0
  12. package/dist/hooks/useRoomBuilder/draw.d.ts +55 -0
  13. package/dist/hooks/useRoomBuilder/draw.js +573 -0
  14. package/dist/hooks/useRoomBuilder/findLoops.d.ts +5 -0
  15. package/dist/hooks/{useSpaces/geometry → useRoomBuilder}/findLoops.js +13 -31
  16. package/dist/hooks/useRoomBuilder/geometry.d.ts +33 -0
  17. package/dist/hooks/useRoomBuilder/geometry.js +325 -0
  18. package/dist/hooks/useRoomBuilder/index.d.ts +40 -0
  19. package/dist/hooks/useRoomBuilder/index.js +303 -0
  20. package/dist/hooks/{useSpaces/validators → useRoomBuilder}/messaging.js +1 -1
  21. package/dist/hooks/{useSpaces/themes/index.d.ts → useRoomBuilder/themes.d.ts} +4 -3
  22. package/dist/hooks/useRoomBuilder/themes.js +273 -0
  23. package/dist/hooks/useRoomBuilder/types.d.ts +238 -0
  24. package/dist/hooks/{useSpaces → useRoomBuilder}/types.js +1 -19
  25. package/dist/hooks/useRoomBuilder/validators.d.ts +36 -0
  26. package/dist/hooks/useRoomBuilder/validators.js +362 -0
  27. package/dist/icons/Draw.js +3 -3
  28. package/dist/icons/Window.js +4 -4
  29. package/dist/icons/index.js +0 -28
  30. package/dist/icons/types.d.ts +1 -1
  31. package/dist/index.d.ts +2 -17
  32. package/dist/index.js +5 -35
  33. package/dist/store/attributes.d.ts +0 -1
  34. package/dist/store/index.d.ts +0 -10
  35. package/dist/store/index.js +1 -3
  36. package/dist/store/product.js +7 -4
  37. package/dist/store/treble.d.ts +1 -1
  38. package/dist/store/treble.js +21 -14
  39. package/dist/types.d.ts +1 -3
  40. package/package.json +1 -1
  41. package/dist/hooks/useSpaces/SpacesLayout.d.ts +0 -11
  42. package/dist/hooks/useSpaces/SpacesLayout.js +0 -74
  43. package/dist/hooks/useSpaces/SpacesState.d.ts +0 -177
  44. package/dist/hooks/useSpaces/SpacesState.js +0 -1816
  45. package/dist/hooks/useSpaces/constants.d.ts +0 -79
  46. package/dist/hooks/useSpaces/constants.js +0 -130
  47. package/dist/hooks/useSpaces/dataHandlers.d.ts +0 -38
  48. package/dist/hooks/useSpaces/dataHandlers.js +0 -407
  49. package/dist/hooks/useSpaces/draw/clearCanvas.d.ts +0 -2
  50. package/dist/hooks/useSpaces/draw/clearCanvas.js +0 -9
  51. package/dist/hooks/useSpaces/draw/drawBackground.d.ts +0 -2
  52. package/dist/hooks/useSpaces/draw/drawBackground.js +0 -12
  53. package/dist/hooks/useSpaces/draw/drawDimensions.d.ts +0 -3
  54. package/dist/hooks/useSpaces/draw/drawDimensions.js +0 -53
  55. package/dist/hooks/useSpaces/draw/drawDoors.d.ts +0 -9
  56. package/dist/hooks/useSpaces/draw/drawDoors.js +0 -99
  57. package/dist/hooks/useSpaces/draw/drawFloor.d.ts +0 -3
  58. package/dist/hooks/useSpaces/draw/drawFloor.js +0 -36
  59. package/dist/hooks/useSpaces/draw/drawGrid.d.ts +0 -3
  60. package/dist/hooks/useSpaces/draw/drawGrid.js +0 -36
  61. package/dist/hooks/useSpaces/draw/drawGuides.d.ts +0 -3
  62. package/dist/hooks/useSpaces/draw/drawGuides.js +0 -23
  63. package/dist/hooks/useSpaces/draw/drawOpenings.d.ts +0 -9
  64. package/dist/hooks/useSpaces/draw/drawOpenings.js +0 -72
  65. package/dist/hooks/useSpaces/draw/drawVertices.d.ts +0 -8
  66. package/dist/hooks/useSpaces/draw/drawVertices.js +0 -61
  67. package/dist/hooks/useSpaces/draw/drawWalls.d.ts +0 -11
  68. package/dist/hooks/useSpaces/draw/drawWalls.js +0 -90
  69. package/dist/hooks/useSpaces/draw/drawWindows.d.ts +0 -9
  70. package/dist/hooks/useSpaces/draw/drawWindows.js +0 -82
  71. package/dist/hooks/useSpaces/draw/index.d.ts +0 -11
  72. package/dist/hooks/useSpaces/draw/index.js +0 -129
  73. package/dist/hooks/useSpaces/geometry/addThicknessToLine.d.ts +0 -3
  74. package/dist/hooks/useSpaces/geometry/addThicknessToLine.js +0 -13
  75. package/dist/hooks/useSpaces/geometry/areLinesEqual.d.ts +0 -3
  76. package/dist/hooks/useSpaces/geometry/areLinesEqual.js +0 -17
  77. package/dist/hooks/useSpaces/geometry/arePointsEqual.d.ts +0 -3
  78. package/dist/hooks/useSpaces/geometry/arePointsEqual.js +0 -8
  79. package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.d.ts +0 -3
  80. package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.js +0 -11
  81. package/dist/hooks/useSpaces/geometry/closestPointOnLine.d.ts +0 -3
  82. package/dist/hooks/useSpaces/geometry/closestPointOnLine.js +0 -13
  83. package/dist/hooks/useSpaces/geometry/doLinesOverlap.d.ts +0 -2
  84. package/dist/hooks/useSpaces/geometry/doLinesOverlap.js +0 -16
  85. package/dist/hooks/useSpaces/geometry/euclideanMod.d.ts +0 -2
  86. package/dist/hooks/useSpaces/geometry/euclideanMod.js +0 -6
  87. package/dist/hooks/useSpaces/geometry/findLoops.d.ts +0 -6
  88. package/dist/hooks/useSpaces/geometry/getAllLineIntersections.d.ts +0 -6
  89. package/dist/hooks/useSpaces/geometry/getAllLineIntersections.js +0 -23
  90. package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.d.ts +0 -3
  91. package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.js +0 -7
  92. package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.d.ts +0 -3
  93. package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.js +0 -17
  94. package/dist/hooks/useSpaces/geometry/getDistanceToLine.d.ts +0 -3
  95. package/dist/hooks/useSpaces/geometry/getDistanceToLine.js +0 -10
  96. package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.d.ts +0 -3
  97. package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.js +0 -7
  98. package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.d.ts +0 -3
  99. package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.js +0 -17
  100. package/dist/hooks/useSpaces/geometry/getLineOtherPoint.d.ts +0 -3
  101. package/dist/hooks/useSpaces/geometry/getLineOtherPoint.js +0 -11
  102. package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.d.ts +0 -3
  103. package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.js +0 -43
  104. package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.d.ts +0 -3
  105. package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.js +0 -9
  106. package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.d.ts +0 -3
  107. package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.js +0 -20
  108. package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.d.ts +0 -3
  109. package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.js +0 -11
  110. package/dist/hooks/useSpaces/geometry/getPolygonArea.d.ts +0 -3
  111. package/dist/hooks/useSpaces/geometry/getPolygonArea.js +0 -15
  112. package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.d.ts +0 -3
  113. package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.js +0 -16
  114. package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.d.ts +0 -6
  115. package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.js +0 -17
  116. package/dist/hooks/useSpaces/geometry/getTriangleArea.d.ts +0 -3
  117. package/dist/hooks/useSpaces/geometry/getTriangleArea.js +0 -9
  118. package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.d.ts +0 -3
  119. package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.js +0 -12
  120. package/dist/hooks/useSpaces/geometry/index.d.ts +0 -30
  121. package/dist/hooks/useSpaces/geometry/index.js +0 -64
  122. package/dist/hooks/useSpaces/geometry/isPointInPolygon.d.ts +0 -3
  123. package/dist/hooks/useSpaces/geometry/isPointInPolygon.js +0 -21
  124. package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.d.ts +0 -3
  125. package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.js +0 -25
  126. package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.d.ts +0 -3
  127. package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.js +0 -11
  128. package/dist/hooks/useSpaces/geometry/splitLineAtOffset.d.ts +0 -3
  129. package/dist/hooks/useSpaces/geometry/splitLineAtOffset.js +0 -12
  130. package/dist/hooks/useSpaces/geometry/splitLineAtPoint.d.ts +0 -3
  131. package/dist/hooks/useSpaces/geometry/splitLineAtPoint.js +0 -9
  132. package/dist/hooks/useSpaces/geometry/splitLineAtPoints.d.ts +0 -3
  133. package/dist/hooks/useSpaces/geometry/splitLineAtPoints.js +0 -28
  134. package/dist/hooks/useSpaces/index.d.ts +0 -95
  135. package/dist/hooks/useSpaces/index.js +0 -557
  136. package/dist/hooks/useSpaces/themes/blueprint.d.ts +0 -3
  137. package/dist/hooks/useSpaces/themes/blueprint.js +0 -96
  138. package/dist/hooks/useSpaces/themes/default.d.ts +0 -3
  139. package/dist/hooks/useSpaces/themes/default.js +0 -96
  140. package/dist/hooks/useSpaces/themes/index.js +0 -21
  141. package/dist/hooks/useSpaces/themes/light.d.ts +0 -3
  142. package/dist/hooks/useSpaces/themes/light.js +0 -96
  143. package/dist/hooks/useSpaces/types.d.ts +0 -378
  144. package/dist/hooks/useSpaces/validators/areWallsDuplicated.d.ts +0 -3
  145. package/dist/hooks/useSpaces/validators/areWallsDuplicated.js +0 -61
  146. package/dist/hooks/useSpaces/validators/areWallsIntersecting.d.ts +0 -3
  147. package/dist/hooks/useSpaces/validators/areWallsIntersecting.js +0 -42
  148. package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.d.ts +0 -3
  149. package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.js +0 -52
  150. package/dist/hooks/useSpaces/validators/areWallsTooShort.d.ts +0 -3
  151. package/dist/hooks/useSpaces/validators/areWallsTooShort.js +0 -37
  152. package/dist/hooks/useSpaces/validators/index.d.ts +0 -15
  153. package/dist/hooks/useSpaces/validators/index.js +0 -40
  154. package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.d.ts +0 -3
  155. package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.js +0 -31
  156. package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.d.ts +0 -3
  157. package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.js +0 -19
  158. package/dist/hooks/useSpaces/validators/isLineTooShort.d.ts +0 -3
  159. package/dist/hooks/useSpaces/validators/isLineTooShort.js +0 -26
  160. package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.d.ts +0 -4
  161. package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.js +0 -19
  162. package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.d.ts +0 -3
  163. package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.js +0 -19
  164. package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.d.ts +0 -3
  165. package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.js +0 -41
  166. package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.d.ts +0 -3
  167. package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.js +0 -54
  168. package/dist/hooks/useSpaces/validators/isWallTooShort.d.ts +0 -3
  169. package/dist/hooks/useSpaces/validators/isWallTooShort.js +0 -10
  170. package/dist/icons/AngleSnapping.d.ts +0 -3
  171. package/dist/icons/AngleSnapping.js +0 -28
  172. package/dist/icons/Boundary.d.ts +0 -3
  173. package/dist/icons/Boundary.js +0 -21
  174. package/dist/icons/Center.d.ts +0 -3
  175. package/dist/icons/Center.js +0 -24
  176. package/dist/icons/GridSnapping.d.ts +0 -3
  177. package/dist/icons/GridSnapping.js +0 -28
  178. package/dist/icons/LayoutAlt.d.ts +0 -3
  179. package/dist/icons/LayoutAlt.js +0 -21
  180. package/dist/icons/Magnet.d.ts +0 -3
  181. package/dist/icons/Magnet.js +0 -27
  182. package/dist/icons/Player3D.d.ts +0 -3
  183. package/dist/icons/Player3D.js +0 -21
  184. package/dist/icons/RulerBlank.d.ts +0 -3
  185. package/dist/icons/RulerBlank.js +0 -25
  186. package/dist/icons/RulerDetailed.d.ts +0 -3
  187. package/dist/icons/RulerDetailed.js +0 -27
  188. package/dist/icons/Save.d.ts +0 -3
  189. package/dist/icons/Save.js +0 -21
  190. package/dist/icons/UnitCm.d.ts +0 -3
  191. package/dist/icons/UnitCm.js +0 -22
  192. package/dist/icons/UnitFeet.d.ts +0 -3
  193. package/dist/icons/UnitFeet.js +0 -22
  194. package/dist/icons/UnitInch.d.ts +0 -3
  195. package/dist/icons/UnitInch.js +0 -22
  196. package/dist/icons/UnitMeter.d.ts +0 -3
  197. package/dist/icons/UnitMeter.js +0 -21
  198. package/dist/store/spaces.d.ts +0 -74
  199. package/dist/store/spaces.js +0 -354
  200. /package/dist/Treble/{snapshot.d.ts → snapshots.d.ts} +0 -0
  201. /package/dist/Treble/{snapshot.js → snapshots.js} +0 -0
  202. /package/dist/hooks/{useSpaces/validators → useRoomBuilder}/messaging.d.ts +0 -0
@@ -0,0 +1,41 @@
1
+ export declare enum IWallAttributes {
2
+ START_X = "Start X",
3
+ START_Z = "Start Z",
4
+ END_X = "End X",
5
+ END_Z = "End Z",
6
+ HEIGHT = "Height",
7
+ THICKNESS = "Thickness",
8
+ CONNECTIONS = "Connections"
9
+ }
10
+ export declare enum IFeatureAttribute {
11
+ POSITION_X = "Start X",
12
+ POSITION_Y = "Start Y",
13
+ POSITION_Z = "Start Z",
14
+ HEIGHT = "Height",
15
+ LENGTH = "Length",
16
+ CONNECTED_TO = "Connected To"
17
+ }
18
+ export declare const SCALE = 0.02;
19
+ export declare const SNAP_PROXIMITY = 10;
20
+ export declare const MIN_WALL_LENGTH = 50;
21
+ export declare const WALL_PADDING_FOR_FEATURE = 20;
22
+ export declare const UNIT_LABELS: {
23
+ feet: string;
24
+ meter: string;
25
+ inch: string;
26
+ cm: string;
27
+ };
28
+ export declare const UNIT_FACTORS: {
29
+ cm: number;
30
+ meter: number;
31
+ feet: number;
32
+ inch: number;
33
+ };
34
+ export declare const FEATURE_LABELS: {
35
+ windows: string;
36
+ doors: string;
37
+ openings: string;
38
+ };
39
+ export declare const FEATURE_LENGTH = 120;
40
+ export declare const UI_ANCHOR_DISTANCE = -60;
41
+ export declare const WALL_SNAP_DISTANCE = 12;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var _a, _b, _c;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.WALL_SNAP_DISTANCE = exports.UI_ANCHOR_DISTANCE = exports.FEATURE_LENGTH = exports.FEATURE_LABELS = exports.UNIT_FACTORS = exports.UNIT_LABELS = exports.WALL_PADDING_FOR_FEATURE = exports.MIN_WALL_LENGTH = exports.SNAP_PROXIMITY = exports.SCALE = exports.IFeatureAttribute = exports.IWallAttributes = void 0;
5
+ var types_1 = require("./types");
6
+ var IWallAttributes;
7
+ (function (IWallAttributes) {
8
+ IWallAttributes["START_X"] = "Start X";
9
+ IWallAttributes["START_Z"] = "Start Z";
10
+ IWallAttributes["END_X"] = "End X";
11
+ IWallAttributes["END_Z"] = "End Z";
12
+ IWallAttributes["HEIGHT"] = "Height";
13
+ IWallAttributes["THICKNESS"] = "Thickness";
14
+ IWallAttributes["CONNECTIONS"] = "Connections";
15
+ })(IWallAttributes = exports.IWallAttributes || (exports.IWallAttributes = {}));
16
+ var IFeatureAttribute;
17
+ (function (IFeatureAttribute) {
18
+ IFeatureAttribute["POSITION_X"] = "Start X";
19
+ IFeatureAttribute["POSITION_Y"] = "Start Y";
20
+ IFeatureAttribute["POSITION_Z"] = "Start Z";
21
+ IFeatureAttribute["HEIGHT"] = "Height";
22
+ IFeatureAttribute["LENGTH"] = "Length";
23
+ IFeatureAttribute["CONNECTED_TO"] = "Connected To";
24
+ })(IFeatureAttribute = exports.IFeatureAttribute || (exports.IFeatureAttribute = {}));
25
+ exports.SCALE = 0.02;
26
+ exports.SNAP_PROXIMITY = 10;
27
+ exports.MIN_WALL_LENGTH = 50;
28
+ exports.WALL_PADDING_FOR_FEATURE = 20;
29
+ exports.UNIT_LABELS = (_a = {},
30
+ _a[types_1.IUnits.FEET] = 'ft',
31
+ _a[types_1.IUnits.METER] = 'm',
32
+ _a[types_1.IUnits.INCH] = 'in',
33
+ _a[types_1.IUnits.CM] = 'cm',
34
+ _a);
35
+ exports.UNIT_FACTORS = (_b = {},
36
+ _b[types_1.IUnits.CM] = 100,
37
+ _b[types_1.IUnits.METER] = 1,
38
+ _b[types_1.IUnits.FEET] = 3.28084,
39
+ _b[types_1.IUnits.INCH] = 39.37,
40
+ _b);
41
+ exports.FEATURE_LABELS = (_c = {},
42
+ _c[types_1.IElements.WINDOW] = 'Window',
43
+ _c[types_1.IElements.DOOR] = 'Door',
44
+ _c[types_1.IElements.OPENING] = 'Opening',
45
+ _c);
46
+ exports.FEATURE_LENGTH = 120;
47
+ exports.UI_ANCHOR_DISTANCE = -60;
48
+ exports.WALL_SNAP_DISTANCE = 12;
@@ -0,0 +1,18 @@
1
+ import type { IWalls, IRoomBuilderStateProps, IVerticesState, IFeatures } from './types';
2
+ import { IUnits } from './types';
3
+ import type { IConfiguration, IHydratedAttribute } from '../../types';
4
+ export declare function prepAttributesIncoming(attributes: Record<string, IHydratedAttribute>, config: IRoomBuilderStateProps): {
5
+ features: IFeatures;
6
+ walls: IWalls;
7
+ vertex: IVerticesState;
8
+ };
9
+ export declare function prepAttributesOutgoing(walls: IWalls, features: IFeatures, config: IRoomBuilderStateProps): {
10
+ [x: string]: import("../../types").IConfigurationAttribute | {
11
+ assetId: string;
12
+ configuration: IConfiguration;
13
+ }[];
14
+ };
15
+ export declare function convertLengthUnit(value: number, from: IUnits, to: IUnits): number;
16
+ export declare function convertAreaUnit(value: number, from: IUnits, to: IUnits): number;
17
+ export declare function prepLengthForUser(value: number, unit: IUnits): string;
18
+ export declare function prepAreaForUser(value: number, unit: IUnits): string;
@@ -0,0 +1,187 @@
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.prepAttributesIncoming = void 0;
15
+ var types_1 = require("./types");
16
+ var constants_1 = require("./constants");
17
+ var geometry_1 = require("./geometry");
18
+ function prepConnectionOutgoing(connection) {
19
+ return "".concat(connection[0], ".").concat(connection[1]);
20
+ }
21
+ function prepConnectionIncoming(connection) {
22
+ var _a = connection.split('.'), attributeName = _a[0], indexStr = _a[1];
23
+ return [attributeName, parseInt(indexStr)];
24
+ }
25
+ function prepWallsAndVerticesIncoming(wallsAttribute, config) {
26
+ var _a;
27
+ var walls = [];
28
+ var vertices = {};
29
+ ((wallsAttribute === null || wallsAttribute === void 0 ? void 0 : wallsAttribute.value) || []).forEach(function (_a, i) {
30
+ var assetId = _a.assetId, configuration = _a.configuration;
31
+ 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,
34
+ ];
35
+ 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,
38
+ ];
39
+ var point1Str = JSON.stringify(point1);
40
+ var point2Str = JSON.stringify(point2);
41
+ if (vertices[point1Str])
42
+ vertices[point1Str].push([i, 0]);
43
+ else
44
+ vertices[point1Str] = [[i, 0]];
45
+ if (vertices[point2Str])
46
+ vertices[point2Str].push([i, 1]);
47
+ else
48
+ vertices[point2Str] = [[i, 1]];
49
+ var connections = [];
50
+ walls.push({
51
+ assetId: assetId,
52
+ line: [point1, point2],
53
+ 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
+ connections: connections,
57
+ });
58
+ });
59
+ return _a = {}, _a[types_1.IElements.WALL] = walls, _a[types_1.IElements.VERTEX] = vertices, _a;
60
+ }
61
+ function prepFeatureIncoming(walls, featureAttribute, config) {
62
+ var _a;
63
+ var feature = [];
64
+ (_a = featureAttribute === null || featureAttribute === void 0 ? void 0 : featureAttribute.value) === null || _a === void 0 ? void 0 : _a.forEach(function (_a) {
65
+ 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]) || '';
70
+ var wallIndex = prepConnectionIncoming(connectedTo)[1];
71
+ 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({
74
+ assetId: assetId,
75
+ offset: offset,
76
+ length: length,
77
+ path: path,
78
+ connectedTo: [types_1.IElements.WALL, wallIndex],
79
+ });
80
+ });
81
+ return feature;
82
+ }
83
+ function prepAttributesIncoming(attributes, config) {
84
+ 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);
87
+ var featuresData = featuresList.reduce(function (output, type) {
88
+ output[type] = prepFeatureIncoming(wallsAndVertices[types_1.IElements.WALL], attributes[config.attributes[type]], config);
89
+ return output;
90
+ }, {});
91
+ return __assign(__assign({}, wallsAndVertices), (_a = {}, _a[types_1.IElements.FEATURE] = featuresData, _a));
92
+ }
93
+ exports.prepAttributesIncoming = prepAttributesIncoming;
94
+ function prepFeaturesOutgoing(features, config) {
95
+ return features.map(function (feature) {
96
+ var _a, _b;
97
+ var assetId = feature.assetId, offset = feature.offset, length = feature.length;
98
+ var connectedTo = prepConnectionOutgoing([
99
+ config.attributes[feature.connectedTo[0]],
100
+ feature.connectedTo[1],
101
+ ]);
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) {
106
+ var _b;
107
+ var key = _a[0], value = _a[1];
108
+ return Object.assign(output, (_b = {},
109
+ _b[key] = value ? value * config.config.scale : value,
110
+ _b));
111
+ }, (_b = {},
112
+ _b[constants_1.IFeatureAttribute.CONNECTED_TO] = connectedTo,
113
+ _b));
114
+ return {
115
+ assetId: assetId,
116
+ configuration: configuration,
117
+ };
118
+ });
119
+ }
120
+ function prepWallsOutgoing(walls, config) {
121
+ return walls.map(function (wall) {
122
+ var _a, _b;
123
+ var line = wall.line, height = wall.height, thickness = wall.thickness;
124
+ var connections = wall.connections.map(function (connection) {
125
+ var attributeName = config.attributes[connection[0]];
126
+ if (!attributeName)
127
+ return;
128
+ return prepConnectionOutgoing([attributeName, connection[1]]);
129
+ });
130
+ var _c = line.flat(), x1 = _c[0], y1 = _c[1], x2 = _c[2], y2 = _c[3];
131
+ 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,
138
+ _a)).reduce(function (output, _a) {
139
+ var _b;
140
+ var key = _a[0], value = _a[1];
141
+ return Object.assign(output, (_b = {},
142
+ _b[key] = value ? value * config.config.scale : value,
143
+ _b));
144
+ }, (_b = {},
145
+ _b[constants_1.IWallAttributes.CONNECTIONS] = JSON.stringify(connections),
146
+ _b));
147
+ return {
148
+ assetId: wall.assetId,
149
+ configuration: configuration,
150
+ };
151
+ });
152
+ }
153
+ function prepAttributesOutgoing(walls, features, config) {
154
+ var _a;
155
+ var wallsAttribute = prepWallsOutgoing(walls, config);
156
+ var featuresAttributes = Object.entries(features).reduce(function (output, _a) {
157
+ var type = _a[0], features = _a[1];
158
+ var attributeName = config.attributes[type];
159
+ if (!attributeName)
160
+ return output;
161
+ output[attributeName] = prepFeaturesOutgoing(features, config);
162
+ return output;
163
+ }, {});
164
+ return __assign(__assign({}, featuresAttributes), (_a = {}, _a[config.attributes[types_1.IElements.WALL]] = wallsAttribute, _a));
165
+ }
166
+ exports.prepAttributesOutgoing = prepAttributesOutgoing;
167
+ function convertLengthUnit(value, from, to) {
168
+ return (value / constants_1.UNIT_FACTORS[from]) * constants_1.UNIT_FACTORS[to];
169
+ }
170
+ exports.convertLengthUnit = convertLengthUnit;
171
+ function convertAreaUnit(value, from, to) {
172
+ return (value / constants_1.UNIT_FACTORS[from]) * Math.pow(constants_1.UNIT_FACTORS[to], 2);
173
+ }
174
+ exports.convertAreaUnit = convertAreaUnit;
175
+ function prepLengthForUser(value, unit) {
176
+ if (unit === types_1.IUnits.FEET) {
177
+ 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]);
180
+ }
181
+ return "".concat(value.toFixed(2), " ").concat(constants_1.UNIT_LABELS[unit]);
182
+ }
183
+ exports.prepLengthForUser = prepLengthForUser;
184
+ function prepAreaForUser(value, unit) {
185
+ return "".concat(value.toFixed(2), " sq-").concat(constants_1.UNIT_LABELS[unit]);
186
+ }
187
+ exports.prepAreaForUser = prepAreaForUser;
@@ -0,0 +1,55 @@
1
+ import { IWall, ICoordinate2D, ICoordinatesLine, IFeatures, IFeature, IElementAddress, IRoomBuilderStyles, IRoomBuilderConfigInternal, IStylesGrid, IStylesWall, IStylesVertex, ILineDimensions, IVertex, IElementStyleModes, IStylesFloor, IEnclosedSpace } from './types';
2
+ interface IWallToDraw extends Omit<IWall, 'assetId' | 'connections'> {
3
+ }
4
+ interface IWallsToDraw extends Array<IWallToDraw> {
5
+ }
6
+ export declare function clearCanvas(canvas: HTMLCanvasElement): void;
7
+ export declare function drawBackground(canvas: HTMLCanvasElement, color?: string): void;
8
+ export declare function drawGrid(canvas: HTMLCanvasElement, styles: IStylesGrid): void;
9
+ export declare function drawFloor(canvas: HTMLCanvasElement, enclosedSpaces: Array<IEnclosedSpace>, styles: IStylesFloor): void;
10
+ export declare function drawVertex(canvas: HTMLCanvasElement, point: ICoordinate2D, style: IStylesVertex, mode?: IElementStyleModes): void;
11
+ export declare function drawNewWall(canvas: HTMLCanvasElement, line: ICoordinatesLine, styles: IRoomBuilderStyles, mode?: IElementStyleModes.ERROR): void;
12
+ export declare function drawWalls(canvas: HTMLCanvasElement, walls: IWallsToDraw, selections: {
13
+ active: Array<number>;
14
+ highlighted: Array<number>;
15
+ error: Array<number>;
16
+ hidden: Array<number>;
17
+ }, styles: IStylesWall): void;
18
+ export declare function drawVertices(canvas: HTMLCanvasElement, vertices: Array<IVertex>, selections: {
19
+ active: Array<number>;
20
+ highlighted: Array<number>;
21
+ error: Array<number>;
22
+ hidden: Array<number>;
23
+ }, styles: IStylesVertex): void;
24
+ export declare function drawDimensions(canvas: HTMLCanvasElement, dimensions: Array<ILineDimensions>, config: IRoomBuilderConfigInternal): void;
25
+ export declare function drawWindows(canvas: HTMLCanvasElement, walls: IWallsToDraw, windows: Array<IFeature>, selections: {
26
+ active: Array<number>;
27
+ highlighted: Array<number>;
28
+ error: Array<number>;
29
+ hidden: Array<number>;
30
+ }, styles: IRoomBuilderStyles): void;
31
+ export declare function drawDoors(canvas: HTMLCanvasElement, walls: IWallsToDraw, doors: Array<IFeature>, selections: {
32
+ active: Array<number>;
33
+ highlighted: Array<number>;
34
+ error: Array<number>;
35
+ hidden: Array<number>;
36
+ }, styles: IRoomBuilderStyles): void;
37
+ export declare function drawOpenings(canvas: HTMLCanvasElement, walls: IWallsToDraw, openings: Array<IFeature>, selections: {
38
+ active: Array<number>;
39
+ highlighted: Array<number>;
40
+ error: Array<number>;
41
+ hidden: Array<number>;
42
+ }, styles: IRoomBuilderStyles): void;
43
+ export declare function drawElements(canvas: HTMLCanvasElement, walls: IWallsToDraw, vertices: Array<IVertex>, features: IFeatures, selections: {
44
+ active: Array<IElementAddress>;
45
+ highlighted: Array<IElementAddress>;
46
+ hidden: Array<IElementAddress>;
47
+ error: Array<IElementAddress>;
48
+ }, styles: IRoomBuilderStyles): void;
49
+ export declare function drawRoom(canvas: HTMLCanvasElement, enclosedSpaces: Array<IEnclosedSpace>, walls: IWallsToDraw, vertices: Array<IVertex>, features: IFeatures, dimensions: Array<ILineDimensions> | undefined, selections: {
50
+ active?: Array<IElementAddress> | IElementAddress;
51
+ highlighted?: Array<IElementAddress> | IElementAddress;
52
+ hidden?: Array<IElementAddress> | IElementAddress;
53
+ error?: Array<IElementAddress> | IElementAddress;
54
+ }, config: IRoomBuilderConfigInternal): void;
55
+ export {};