@threekit-tools/treble 0.0.90-next-05 → 0.0.90-next-07

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.
@@ -1,4 +1,4 @@
1
- import { IWalls, IVerticesState, ICoordinate2D, IFeature, IFeatures, ICoordinatesLine, ISpacesStateProps, IElementAddress, IFeatureName, IVertex, IFeaturesHydrated, IElementUi, IElementName, IActiveElement, IEnclosedSpace } from './types';
1
+ import { IWalls, IVerticesState, ICoordinate2D, IFeature, IFeatures, ICoordinatesLine, ISpacesStateProps, IElementAddress, IFeatureName, IVertex, IFeaturesHydrated, IElementUi, IElementName, IActiveElement, IEnclosedSpace, IFeatureDoor, IWallsValidationConfig } from './types';
2
2
  import type { IHydratedAttribute } from '../../types';
3
3
  export declare class SpacesState {
4
4
  private _config;
@@ -15,6 +15,7 @@ export declare class SpacesState {
15
15
  private _zoomLimits;
16
16
  private _translate;
17
17
  private _translateLimits;
18
+ private _validationConfig;
18
19
  private _state;
19
20
  constructor(config: ISpacesStateProps);
20
21
  get walls(): IWalls;
@@ -34,7 +35,7 @@ export declare class SpacesState {
34
35
  get verticesList(): Array<IVertex>;
35
36
  get verticesListToDraw(): Array<IVertex>;
36
37
  get features(): IFeatures;
37
- get featuresToDraw(): Record<string, IFeature[]>;
38
+ get featuresToDraw(): Record<string, IFeature[] | IFeatureDoor[]>;
38
39
  set features(features: IFeatures);
39
40
  get getHydratedFeatures(): undefined | IFeaturesHydrated;
40
41
  get featureCount(): number;
@@ -60,6 +61,8 @@ export declare class SpacesState {
60
61
  get translateMax(): ICoordinate2D;
61
62
  set translate(position: ICoordinate2D);
62
63
  get isDrawWallActive(): boolean;
64
+ get validationConfig(): IWallsValidationConfig;
65
+ set validationConfig(config: IWallsValidationConfig);
63
66
  transformLengthFromCanvas(length: number): number;
64
67
  transformLengthToCanvas(length: number): number;
65
68
  transformPointToCanvas(point: ICoordinate2D): ICoordinate2D;
@@ -73,7 +76,8 @@ export declare class SpacesState {
73
76
  private getWallConnectionCount;
74
77
  private getWallConnectionsHydrated;
75
78
  private getWallDimensions;
76
- private getWallDetailedDimensions;
79
+ private getWallDimensionsByIndex;
80
+ private getWallDetailedDimensionsByIndex;
77
81
  private getAllWallDimensionsToDraw;
78
82
  private shiftAllFeaturesOnWall;
79
83
  private addFeatureToWall;
@@ -90,8 +94,10 @@ export declare class SpacesState {
90
94
  private getFeature;
91
95
  private updateFeature;
92
96
  private repositionFeature;
93
- addFeature(type: IFeatureName, feature: Omit<IFeature, 'path' | 'connectedTo' | 'offset'> & {
97
+ addFeature(type: IFeatureName, feature: Pick<IFeature, 'assetId' | 'length'> & {
94
98
  offset?: number;
99
+ height?: number;
100
+ altitude?: number;
95
101
  }, addToWallIndex?: number): void;
96
102
  deleteFeature(type: IFeatureName, index: number): void;
97
103
  private getHydratedFeature;
@@ -97,7 +97,7 @@ var SpacesState = (function () {
97
97
  validators_1.areWallsIntersecting,
98
98
  validators_1.areWallsOrphaningFeatures,
99
99
  validators_1.areWallsDuplicated,
100
- ], validationData);
100
+ ], validationData, _this.validationConfig);
101
101
  var errorType = ((_b = _this._errorElement) === null || _b === void 0 ? void 0 : _b[0].type) || null;
102
102
  switch (errorType) {
103
103
  case types_1.IErrorTypes.HARD:
@@ -150,7 +150,7 @@ var SpacesState = (function () {
150
150
  wall: wall,
151
151
  features: _this.features,
152
152
  updatedFeature: featureUpdatesToValidate,
153
- });
153
+ }, _this.validationConfig);
154
154
  var errorType = ((_b = _this._errorElement) === null || _b === void 0 ? void 0 : _b[0].type) || null;
155
155
  switch (errorType) {
156
156
  case types_1.IErrorTypes.HARD:
@@ -486,6 +486,16 @@ var SpacesState = (function () {
486
486
  enumerable: false,
487
487
  configurable: true
488
488
  });
489
+ Object.defineProperty(SpacesState.prototype, "validationConfig", {
490
+ get: function () {
491
+ return this._validationConfig;
492
+ },
493
+ set: function (config) {
494
+ this._validationConfig = config;
495
+ },
496
+ enumerable: false,
497
+ configurable: true
498
+ });
489
499
  SpacesState.prototype.transformLengthFromCanvas = function (length) {
490
500
  return length / this.zoomFactor;
491
501
  };
@@ -561,11 +571,7 @@ var SpacesState = (function () {
561
571
  return output;
562
572
  }, []);
563
573
  };
564
- SpacesState.prototype.getWallDimensions = function (index) {
565
- var _a;
566
- var line = (_a = this.getWall(index)) === null || _a === void 0 ? void 0 : _a.line;
567
- if (!line)
568
- return undefined;
574
+ SpacesState.prototype.getWallDimensions = function (line) {
569
575
  var lineLength = (0, geometry_1.getLengthOfLineSegment)(line) * this._config.config.scale;
570
576
  var convertedVal = (0, dataHandlers_1.convertLengthUnit)(lineLength, types_1.IUnits.METER, this._config.config.unit);
571
577
  return {
@@ -573,7 +579,14 @@ var SpacesState = (function () {
573
579
  label: (0, dataHandlers_1.prepLengthForUser)(convertedVal, this._config.config.unit),
574
580
  };
575
581
  };
576
- SpacesState.prototype.getWallDetailedDimensions = function (index) {
582
+ SpacesState.prototype.getWallDimensionsByIndex = function (index) {
583
+ var _a;
584
+ var line = (_a = this.getWall(index)) === null || _a === void 0 ? void 0 : _a.line;
585
+ if (!line)
586
+ return undefined;
587
+ return this.getWallDimensions(line);
588
+ };
589
+ SpacesState.prototype.getWallDetailedDimensionsByIndex = function (index) {
577
590
  var _this = this;
578
591
  var _a;
579
592
  var line = (_a = this.getWall(index)) === null || _a === void 0 ? void 0 : _a.line;
@@ -630,8 +643,8 @@ var SpacesState = (function () {
630
643
  var indexes = new Set([detailedWallsIndexes].flat());
631
644
  var dimensionsList = this.walls.reduce(function (output, _, i) {
632
645
  var dimensions = indexes.has(i)
633
- ? _this.getWallDetailedDimensions(i)
634
- : _this.getWallDimensions(i);
646
+ ? _this.getWallDetailedDimensionsByIndex(i)
647
+ : _this.getWallDimensionsByIndex(i);
635
648
  if (!dimensions)
636
649
  return output;
637
650
  if (Array.isArray(dimensions))
@@ -750,20 +763,21 @@ var SpacesState = (function () {
750
763
  SpacesState.prototype.getFirstVacantLocation = function (length) {
751
764
  var _a;
752
765
  var walls = this.walls;
766
+ var padding = this.validationConfig.padding;
753
767
  var offset = undefined;
754
768
  for (var i = 0; i < walls.length; i++) {
755
769
  var wallLength = (0, geometry_1.getLengthOfLineSegment)(walls[i].line);
756
770
  var features = (_a = this.getWallConnectionsHydrated(i)) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return a.offset - b.offset; });
757
771
  if (!(features === null || features === void 0 ? void 0 : features.length)) {
758
- if (length < wallLength - 2 * constants_1.WALL_PADDING_FOR_FEATURE)
759
- offset = (wallLength - 2 * constants_1.WALL_PADDING_FOR_FEATURE) / 2 - length / 2;
772
+ if (length < wallLength - 2 * padding)
773
+ offset = (wallLength - 2 * padding) / 2 - length / 2;
760
774
  }
761
775
  else {
762
776
  for (var j = 0; j < features.length && offset === undefined; j++) {
763
777
  var _b = features[j], currentOffset = _b.offset, currentLength = _b.length;
764
778
  if (!j) {
765
- if (constants_1.WALL_PADDING_FOR_FEATURE + length < currentOffset) {
766
- var slotStart = constants_1.WALL_PADDING_FOR_FEATURE;
779
+ if (padding + length < currentOffset) {
780
+ var slotStart = padding;
767
781
  var slotEnd = currentOffset;
768
782
  offset = slotStart + (slotEnd - slotStart) / 2 - length / 2;
769
783
  continue;
@@ -780,11 +794,9 @@ var SpacesState = (function () {
780
794
  }
781
795
  if (j === features.length - 1) {
782
796
  if (length <
783
- wallLength -
784
- constants_1.WALL_PADDING_FOR_FEATURE -
785
- (currentOffset + currentLength)) {
797
+ wallLength - padding - (currentOffset + currentLength)) {
786
798
  var slotStart = currentOffset + currentLength;
787
- var slotEnd = wallLength - constants_1.WALL_PADDING_FOR_FEATURE;
799
+ var slotEnd = wallLength - padding;
788
800
  offset = slotStart + (slotEnd - slotStart) / 2 - length / 2;
789
801
  }
790
802
  }
@@ -902,16 +914,19 @@ var SpacesState = (function () {
902
914
  }
903
915
  if (index === undefined || offset === undefined)
904
916
  return;
905
- var newFeature = __assign(__assign({}, feature), { offset: offset, connectedTo: [types_2.IElements.WALL, index] });
917
+ var newFeature = __assign(__assign({}, feature), { offset: offset, height: feature.height || 0, altitude: feature.altitude || 0, connectedTo: [types_2.IElements.WALL, index], restConfiguration: '{}' });
918
+ if (type === types_2.IElements.DOOR) {
919
+ newFeature.orientation = 'left';
920
+ newFeature.openingDirection = 'inside';
921
+ }
906
922
  var newFeatureIndex;
907
- if ((_a = this._state[types_2.IElements.FEATURE][type]) === null || _a === void 0 ? void 0 : _a.length) {
923
+ if ((_a = this._state[types_2.IElements.FEATURE][type]) === null || _a === void 0 ? void 0 : _a.length)
908
924
  newFeatureIndex = this._state[types_2.IElements.FEATURE][type].length;
909
- this._state[types_2.IElements.FEATURE][type].push(newFeature);
910
- }
911
925
  else {
912
- this._state[types_2.IElements.FEATURE][type] = [newFeature];
926
+ this._state[types_2.IElements.FEATURE][type] = [];
913
927
  newFeatureIndex = 0;
914
928
  }
929
+ this._state[types_2.IElements.FEATURE][type].push(newFeature);
915
930
  this.addFeatureToWall(index, [type, newFeatureIndex]);
916
931
  this.pushStateToConfigurator();
917
932
  };
@@ -1162,6 +1177,7 @@ var SpacesState = (function () {
1162
1177
  return;
1163
1178
  this._attributesState = attributes;
1164
1179
  var data = (0, dataHandlers_1.prepAttributesIncoming)(attributes, this._config);
1180
+ this.validationConfig = data.validationConfig;
1165
1181
  this.walls = data[types_2.IElements.WALL];
1166
1182
  this.vertices = data[types_2.IElements.VERTEX];
1167
1183
  this.features = data[types_2.IElements.FEATURE];
@@ -1235,7 +1251,7 @@ var SpacesState = (function () {
1235
1251
  validators_1.isWallTooShort,
1236
1252
  validators_1.isWallOverlappingExisitingWalls,
1237
1253
  validators_1.isWallIntersectingFeature,
1238
- ], validationData);
1254
+ ], validationData, this.validationConfig);
1239
1255
  var errorType = ((_d = this._errorElement) === null || _d === void 0 ? void 0 : _d[0].type) || null;
1240
1256
  switch (errorType) {
1241
1257
  case types_1.IErrorTypes.HARD:
@@ -1421,7 +1437,16 @@ var SpacesState = (function () {
1421
1437
  ? this.getAllWallDimensionsToDraw(activeWallIndex)
1422
1438
  : undefined, selection, this._config.config);
1423
1439
  if (((_f = this._newWall) === null || _f === void 0 ? void 0 : _f.start) && ((_g = this._newWall) === null || _g === void 0 ? void 0 : _g.end)) {
1424
- (0, draw_1.drawNewWall)(canvas, this.transformLineToCanvas([this._newWall.start, this._newWall.end]), this._config.config.styles, this._errorElement ? types_1.IElementStyleModes.ERROR : undefined);
1440
+ var newWallLine = [
1441
+ this._newWall.start,
1442
+ this._newWall.end,
1443
+ ];
1444
+ (0, draw_1.drawNewWall)(canvas, this.transformLineToCanvas(newWallLine), this._config.config.styles, this._errorElement ? types_1.IElementStyleModes.ERROR : undefined);
1445
+ if (this._showDimensions) {
1446
+ var preppedNewWallLine = this.transformLineToCanvas(newWallLine);
1447
+ var newWallDimensions = this.getWallDimensions(preppedNewWallLine);
1448
+ (0, draw_1.drawDimensions)(canvas, [newWallDimensions], this._config.config);
1449
+ }
1425
1450
  }
1426
1451
  };
1427
1452
  return SpacesState;
@@ -1,4 +1,16 @@
1
- import { ICoordinate2D, ISpacesAttributes } from './types';
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
+ }
2
14
  export declare const attributeNameDefaults: ISpacesAttributes;
3
15
  export declare const SCALE = 0.02;
4
16
  export declare const SNAP_PROXIMITY = 16;
@@ -9,8 +21,6 @@ export declare const ZOOM_SENSITIVITY = 0.8;
9
21
  export declare const TRANSLATE_MAX: ICoordinate2D;
10
22
  export declare const TRANSLATE_MIN: ICoordinate2D;
11
23
  export declare const TRANSLATE_DEFAULT: ICoordinate2D;
12
- export declare const MIN_WALL_LENGTH = 50;
13
- export declare const WALL_PADDING_FOR_FEATURE = 20;
14
24
  export declare const UNIT_LABELS: {
15
25
  feet: string;
16
26
  meter: string;
@@ -28,6 +38,7 @@ export declare const FEATURE_LABELS: {
28
38
  doors: string;
29
39
  openings: string;
30
40
  };
41
+ export declare const VALIDATION_CONFIG_DEFAULT: IWallsValidationConfig;
31
42
  export declare const FEATURE_LENGTH = 120;
32
43
  export declare const UI_ANCHOR_DISTANCE = -60;
33
44
  export declare const WALL_SNAP_DISTANCE = 12;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a, _b, _c, _d;
3
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.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.attributeNameDefaults = void 0;
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.attributeNameDefaults = exports.DoorOpeningDirections = exports.DoorOrientations = exports.WallMetadata = void 0;
5
5
  var types_1 = require("./types");
6
6
  var SpacesAttributes;
7
7
  (function (SpacesAttributes) {
@@ -22,26 +22,44 @@ var WallAttributes;
22
22
  WallAttributes["WALL_HEIGHT"] = "_tkSpace_wallHeight";
23
23
  WallAttributes["WALL_THICKNESS"] = "_tkSpace_wallThickness";
24
24
  })(WallAttributes || (WallAttributes = {}));
25
- var FeatureAttribute;
26
- (function (FeatureAttribute) {
27
- FeatureAttribute["POSITION_X"] = "_tkSpace_offsetX";
28
- FeatureAttribute["POSITION_Y"] = "_tkSpace_offsetY";
29
- FeatureAttribute["POSITION_Z"] = "_tkSpace_offsetZ";
30
- FeatureAttribute["CONNECTED_TO"] = "_tkSpace_connectedTo";
31
- FeatureAttribute["FEATURE_HEIGHT"] = "_tkSpace_featureHeight";
32
- FeatureAttribute["FEATURE_LENGTH"] = "_tkSpace_featureWidth";
33
- })(FeatureAttribute || (FeatureAttribute = {}));
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 = {}));
34
53
  exports.attributeNameDefaults = (_a = {},
35
54
  _a[types_1.IElements.WALL] = SpacesAttributes.WALLS,
36
55
  _a[types_1.IElements.WINDOW] = SpacesAttributes.WINDOWS,
37
56
  _a[types_1.IElements.OPENING] = SpacesAttributes.OPENINGS,
38
57
  _a[types_1.IElements.DOOR] = SpacesAttributes.DOORS,
39
- _a.featurePositionX = FeatureAttribute.POSITION_X,
40
- _a.featurePositionY = FeatureAttribute.POSITION_Y,
41
- _a.featurePositionZ = FeatureAttribute.POSITION_Z,
42
- _a.featureConnectedTo = FeatureAttribute.CONNECTED_TO,
43
- _a.featureHeight = FeatureAttribute.FEATURE_HEIGHT,
44
- _a.featureLength = FeatureAttribute.FEATURE_LENGTH,
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,
45
63
  _a.wallStartX = WallAttributes.START_X,
46
64
  _a.wallStartY = WallAttributes.START_Y,
47
65
  _a.wallStartZ = WallAttributes.START_Z,
@@ -49,6 +67,8 @@ exports.attributeNameDefaults = (_a = {},
49
67
  _a.wallEndY = WallAttributes.END_Y,
50
68
  _a.wallEndZ = WallAttributes.END_Z,
51
69
  _a.wallConnections = WallAttributes.CONNECTIONS,
70
+ _a.doorOrientation = DoorAttributes.ORIENTATION,
71
+ _a.doorOpeningDirection = DoorAttributes.OPENING_DIRECTION,
52
72
  _a);
53
73
  exports.SCALE = 0.02;
54
74
  exports.SNAP_PROXIMITY = 16;
@@ -59,8 +79,6 @@ exports.ZOOM_SENSITIVITY = 0.8;
59
79
  exports.TRANSLATE_MAX = [-400, -400];
60
80
  exports.TRANSLATE_MIN = [400, 400];
61
81
  exports.TRANSLATE_DEFAULT = [-200, -200];
62
- exports.MIN_WALL_LENGTH = 50;
63
- exports.WALL_PADDING_FOR_FEATURE = 20;
64
82
  exports.UNIT_LABELS = (_b = {},
65
83
  _b[types_1.IUnits.FEET] = 'ft',
66
84
  _b[types_1.IUnits.METER] = 'm',
@@ -78,6 +96,10 @@ exports.FEATURE_LABELS = (_d = {},
78
96
  _d[types_1.IElements.DOOR] = 'Door',
79
97
  _d[types_1.IElements.OPENING] = 'Opening',
80
98
  _d);
99
+ exports.VALIDATION_CONFIG_DEFAULT = {
100
+ padding: 20,
101
+ minLength: 50,
102
+ };
81
103
  exports.FEATURE_LENGTH = 120;
82
104
  exports.UI_ANCHOR_DISTANCE = -60;
83
105
  exports.WALL_SNAP_DISTANCE = 12;
@@ -1,8 +1,9 @@
1
- import type { IWalls, ISpacesStateProps, IVerticesState, IFeatures } from './types';
1
+ import type { IWalls, ISpacesStateProps, IVerticesState, IFeatures, IWallsValidationConfig } from './types';
2
2
  import { IUnits } from './types';
3
3
  import type { IConfiguration, IHydratedAttribute } from '../../types';
4
4
  export declare function prepAttributesIncoming(attributes: Record<string, IHydratedAttribute>, config: ISpacesStateProps): {
5
- features: IFeatures;
5
+ validationConfig: IWallsValidationConfig;
6
+ features: {};
6
7
  walls: IWalls;
7
8
  vertex: IVerticesState;
8
9
  };
@@ -69,61 +69,94 @@ function prepWallsAndVerticesIncoming(wallsAttribute, config) {
69
69
  });
70
70
  return _a = {}, _a[types_1.IElements.WALL] = walls, _a[types_1.IElements.VERTEX] = vertices, _a;
71
71
  }
72
- 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) {
73
82
  var _a;
74
83
  var attributeName = config.attributes;
75
84
  var feature = [];
76
85
  (_a = featureAttribute === null || featureAttribute === void 0 ? void 0 : featureAttribute.value) === null || _a === void 0 ? void 0 : _a.forEach(function (_a) {
77
86
  var assetId = _a.assetId, configuration = _a.configuration;
78
87
  var offset = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featurePositionX]) / config.config.scale;
79
- var length = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featureLength]) / config.config.scale ||
80
- constants_1.FEATURE_LENGTH;
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;
81
91
  var connectedTo = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featureConnectedTo]) || '';
82
92
  var wallIndex = prepConnectionIncoming(connectedTo)[1];
83
93
  var featureLine = (0, geometry_1.getLineAtOffsetOnLineSegment)(walls[wallIndex].line, offset, length);
84
- var path = (0, geometry_1.addThicknessToLine)(featureLine, config.config.styles.feature.thickness);
85
- feature.push({
94
+ var element = {
86
95
  assetId: assetId,
87
96
  offset: offset,
88
97
  length: length,
89
- path: path,
98
+ height: height,
99
+ altitude: altitude,
90
100
  connectedTo: [types_1.IElements.WALL, wallIndex],
91
- });
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);
92
112
  });
93
113
  return feature;
94
114
  }
95
115
  function prepAttributesIncoming(attributes, config) {
96
116
  var _a;
97
- var featuresList = [types_1.IElements.WINDOW, types_1.IElements.DOOR, types_1.IElements.OPENING];
98
- 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
+ ];
99
125
  var featuresData = featuresList.reduce(function (output, type) {
100
- 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);
101
127
  return output;
102
128
  }, {});
103
- 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));
104
130
  }
105
131
  exports.prepAttributesIncoming = prepAttributesIncoming;
106
- function prepFeaturesOutgoing(features, config) {
132
+ function prepFeaturesOutgoing(type, features, config) {
107
133
  var attributeName = config.attributes;
108
134
  return features.map(function (feature) {
109
135
  var _a, _b;
110
- var assetId = feature.assetId, offset = feature.offset, length = feature.length;
136
+ var assetId = feature.assetId, offset = feature.offset, length = feature.length, height = feature.height, altitude = feature.altitude, restConfiguration = feature.restConfiguration;
111
137
  var connectedTo = prepConnectionOutgoing([
112
138
  config.attributes[feature.connectedTo[0]],
113
139
  feature.connectedTo[1],
114
140
  ]);
115
- var configuration = Object.entries((_a = {},
141
+ var configurationToScale = (_a = {},
116
142
  _a[attributeName.featureLength] = length,
117
143
  _a[attributeName.featurePositionX] = offset,
118
- _a)).reduce(function (output, _a) {
144
+ _a);
145
+ if (altitude)
146
+ configurationToScale[attributeName.featurePositionY] = altitude;
147
+ if (height)
148
+ configurationToScale[attributeName.featureHeight] = height;
149
+ var configuration = Object.entries(configurationToScale).reduce(function (output, _a) {
119
150
  var _b;
120
151
  var key = _a[0], value = _a[1];
121
152
  return Object.assign(output, (_b = {},
122
153
  _b[key] = value ? value * config.config.scale : value,
123
154
  _b));
124
- }, (_b = {},
125
- _b[attributeName.featureConnectedTo] = connectedTo,
126
- _b));
155
+ }, __assign((_b = {}, _b[attributeName.featureConnectedTo] = connectedTo, _b), JSON.parse(restConfiguration)));
156
+ if (type === types_1.IElements.DOOR) {
157
+ configuration[attributeName.doorOrientation] = feature.orientation;
158
+ configuration[attributeName.doorOpeningDirection] = feature.openingDirection;
159
+ }
127
160
  return {
128
161
  assetId: assetId,
129
162
  configuration: configuration,
@@ -168,7 +201,7 @@ function prepAttributesOutgoing(walls, features, config) {
168
201
  var attributeName = config.attributes[type];
169
202
  if (!attributeName)
170
203
  return output;
171
- output[attributeName] = prepFeaturesOutgoing(features, config);
204
+ output[attributeName] = prepFeaturesOutgoing(type, features, config);
172
205
  return output;
173
206
  }, {});
174
207
  return __assign(__assign({}, featuresAttributes), (_a = {}, _a[config.attributes[types_1.IElements.WALL]] = wallsAttribute, _a));
@@ -1,4 +1,4 @@
1
- import { IWall, ICoordinate2D, ICoordinatesLine, IFeatures, IFeature, IElementAddress, ISpacesStyles, ISpacesConfigInternal, IStylesGrid, IStylesWall, IStylesVertex, ILineDimensions, IVertex, IElementStyleModes, IStylesFloor, IEnclosedSpace } from './types';
1
+ import { IWall, ICoordinate2D, ICoordinatesLine, IFeatures, IFeature, IElementAddress, ISpacesStyles, ISpacesConfigInternal, IStylesGrid, IStylesWall, IStylesVertex, IStylesDimension, ILineDimensions, IVertex, IElementStyleModes, IStylesFloor, IEnclosedSpace, IFeatureDoor } from './types';
2
2
  interface IWallToDraw extends Pick<IWall, 'line' | 'path'> {
3
3
  }
4
4
  interface IWallsToDraw extends Array<IWallToDraw> {
@@ -7,6 +7,7 @@ export declare function clearCanvas(canvas: HTMLCanvasElement): void;
7
7
  export declare function drawBackground(canvas: HTMLCanvasElement, color?: string): void;
8
8
  export declare function drawGrid(canvas: HTMLCanvasElement, styles: IStylesGrid): void;
9
9
  export declare function drawFloor(canvas: HTMLCanvasElement, enclosedSpaces: Array<IEnclosedSpace>, styles: IStylesFloor): void;
10
+ export declare function drawDimension(canvas: HTMLCanvasElement, line: ICoordinatesLine, styles: IStylesDimension, message: string): void;
10
11
  export declare function drawVertex(canvas: HTMLCanvasElement, point: ICoordinate2D, style: IStylesVertex, mode?: IElementStyleModes): void;
11
12
  export declare function drawNewWall(canvas: HTMLCanvasElement, line: ICoordinatesLine, styles: ISpacesStyles, mode?: IElementStyleModes.ERROR): void;
12
13
  export declare function drawWalls(canvas: HTMLCanvasElement, walls: IWallsToDraw, selections: {
@@ -28,7 +29,7 @@ export declare function drawWindows(canvas: HTMLCanvasElement, walls: IWallsToDr
28
29
  error: Array<number>;
29
30
  hidden: Array<number>;
30
31
  }, styles: ISpacesStyles): void;
31
- export declare function drawDoors(canvas: HTMLCanvasElement, walls: IWallsToDraw, doors: Array<IFeature>, selections: {
32
+ export declare function drawDoors(canvas: HTMLCanvasElement, walls: IWallsToDraw, doors: Array<IFeatureDoor>, selections: {
32
33
  active: Array<number>;
33
34
  highlighted: Array<number>;
34
35
  error: Array<number>;
@@ -9,10 +9,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
9
9
  return to.concat(ar || Array.prototype.slice.call(from));
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.drawSpaces = exports.drawElements = exports.drawOpenings = exports.drawDoors = exports.drawWindows = exports.drawDimensions = exports.drawVertices = exports.drawWalls = exports.drawNewWall = exports.drawVertex = exports.drawFloor = exports.drawGrid = exports.drawBackground = exports.clearCanvas = void 0;
12
+ exports.drawSpaces = exports.drawElements = exports.drawOpenings = exports.drawDoors = exports.drawWindows = exports.drawDimensions = exports.drawVertices = exports.drawWalls = exports.drawNewWall = exports.drawVertex = exports.drawDimension = exports.drawFloor = exports.drawGrid = exports.drawBackground = exports.clearCanvas = void 0;
13
13
  var types_1 = require("./types");
14
14
  var types_2 = require("./types");
15
15
  var geometry_1 = require("./geometry");
16
+ var constants_1 = require("./constants");
16
17
  var debug = false;
17
18
  function clearCanvas(canvas) {
18
19
  var ctx = canvas.getContext('2d');
@@ -161,6 +162,7 @@ function drawDimension(canvas, line, styles, message) {
161
162
  ctx.fillText(message, 0, 0);
162
163
  ctx.resetTransform();
163
164
  }
165
+ exports.drawDimension = drawDimension;
164
166
  function drawVertex(canvas, point, style, mode) {
165
167
  var ctx = canvas.getContext('2d');
166
168
  if (!ctx)
@@ -244,17 +246,42 @@ function drawWindow(canvas, wall, offset, length, style, mode) {
244
246
  ctx.arc(windowLine[1][0], windowLine[1][1], style.thickness / 2, angle + Math.PI / 2, angle - Math.PI / 2);
245
247
  ctx.fill();
246
248
  }
247
- function drawDoor(canvas, wall, offset, length, style, mode) {
249
+ function drawDoor(canvas, wall, offset, length, openingDirection, orientation, style, mode) {
248
250
  var ctx = canvas.getContext('2d');
249
251
  if (!ctx)
250
252
  return;
251
253
  var doorLine = (0, geometry_1.getLineAtOffsetOnLineSegment)(wall.line, offset, length);
252
254
  var points = (0, geometry_1.addThicknessToLine)(doorLine, style.thickness);
255
+ var angle = (0, geometry_1.getAngleOfLineSegment)(doorLine);
253
256
  var stroke = style.stroke, fill = style.fill, strokeWidth = style.strokeWidth;
254
257
  if (mode) {
255
258
  stroke = style[mode].stroke;
256
259
  fill = style[mode].fill;
257
260
  }
261
+ ctx.beginPath();
262
+ ctx.strokeStyle = stroke || fill;
263
+ ctx.lineWidth = 2;
264
+ if (openingDirection === constants_1.DoorOpeningDirections.INSIDE) {
265
+ if (orientation === constants_1.DoorOrientations.LEFT) {
266
+ ctx.moveTo.apply(ctx, points[0]);
267
+ ctx.arc.apply(ctx, __spreadArray(__spreadArray([], points[0], false), [length, angle - Math.PI / 2, angle], false));
268
+ }
269
+ else {
270
+ ctx.moveTo.apply(ctx, points[1]);
271
+ ctx.arc.apply(ctx, __spreadArray(__spreadArray([], points[1], false), [length, angle - Math.PI / 2, angle - Math.PI, true], false));
272
+ }
273
+ }
274
+ else {
275
+ if (orientation === constants_1.DoorOrientations.LEFT) {
276
+ ctx.moveTo.apply(ctx, points[2]);
277
+ ctx.arc.apply(ctx, __spreadArray(__spreadArray([], points[2], false), [length, angle + Math.PI / 2, angle + Math.PI], false));
278
+ }
279
+ else {
280
+ ctx.moveTo.apply(ctx, points[3]);
281
+ ctx.arc.apply(ctx, __spreadArray(__spreadArray([], points[3], false), [length, angle + Math.PI / 2, angle, true], false));
282
+ }
283
+ }
284
+ ctx.stroke();
258
285
  ctx.strokeStyle = stroke || fill;
259
286
  ctx.fillStyle = fill;
260
287
  ctx.lineWidth = strokeWidth || 1;
@@ -429,7 +456,7 @@ function drawDoors(canvas, walls, doors, selections, styles) {
429
456
  if (!(door === null || door === void 0 ? void 0 : door.connectedTo.length))
430
457
  return;
431
458
  var wallIndex = door.connectedTo[1];
432
- drawDoor(canvas, walls[wallIndex], door.offset, door.length, styles.feature, mode);
459
+ drawDoor(canvas, walls[wallIndex], door.offset, door.length, door.openingDirection, door.orientation, styles.feature, mode);
433
460
  });
434
461
  });
435
462
  }
@@ -159,10 +159,12 @@ var useSpaces = function (props) {
159
159
  drawSpaces();
160
160
  };
161
161
  var handleScrollToZoom = function (e) {
162
- var _a;
162
+ var _a, _b;
163
163
  if (!canvasRef.current)
164
164
  return;
165
165
  var zoomSensitivity = ((_a = props.config) === null || _a === void 0 ? void 0 : _a.zoomSensitivity) || constants_1.ZOOM_SENSITIVITY;
166
+ if ((_b = props.config) === null || _b === void 0 ? void 0 : _b.reverseZoom)
167
+ zoomSensitivity = -1 * zoomSensitivity;
166
168
  updateZoom(e.deltaY * zoomSensitivity);
167
169
  };
168
170
  var handleSelectModeHover = function (e) {
@@ -185,12 +187,12 @@ var useSpaces = function (props) {
185
187
  return;
186
188
  var cursorPoint = [e.offsetX, e.offsetY];
187
189
  spacesRef.current.selectElementIfInProximity(canvasRef.current, cursorPoint);
188
- if (!((_a = props.config) === null || _a === void 0 ? void 0 : _a.translateDisabled) && !spacesRef.current.activeElement)
189
- translationAnchorRef.current = cursorPoint;
190
190
  var element = spacesRef.current.getClickedElement(cursorPoint);
191
191
  if (!element) {
192
192
  if (selectedElement !== null)
193
193
  setSelectedElement(null);
194
+ if (!((_a = props.config) === null || _a === void 0 ? void 0 : _a.translateDisabled) && !spacesRef.current.activeElement)
195
+ translationAnchorRef.current = cursorPoint;
194
196
  return;
195
197
  }
196
198
  if (spacesRef.current.activeElement ||
@@ -56,20 +56,31 @@ export interface IFeature {
56
56
  assetId: string;
57
57
  offset: number;
58
58
  length: number;
59
+ height: number;
60
+ altitude: number;
59
61
  path?: ICoordinatesQuadrilateral;
60
62
  connectedTo: [elementType: IElements.WALL, index: number];
63
+ restConfiguration: string;
64
+ }
65
+ export interface IFeatureDoor extends IFeature {
66
+ orientation: string;
67
+ openingDirection: string;
61
68
  }
62
- export interface IFeatureHydrated extends IFeature {
69
+ interface IFeatureHydratedShared {
63
70
  line: ICoordinatesLine;
64
71
  }
65
- export interface IFeaturesShared<T> {
72
+ export interface IFeatureHydrated extends IFeature, IFeatureHydratedShared {
73
+ }
74
+ export interface IFeatureDoorHydrated extends IFeatureDoor, IFeatureHydratedShared {
75
+ }
76
+ export interface IFeaturesShared<T, D> {
66
77
  [IElements.WINDOW]?: Array<T>;
67
- [IElements.DOOR]?: Array<T>;
78
+ [IElements.DOOR]?: Array<D>;
68
79
  [IElements.OPENING]?: Array<T>;
69
80
  }
70
- export interface IFeatures extends IFeaturesShared<IFeature> {
81
+ export interface IFeatures extends IFeaturesShared<IFeature, IFeatureDoor> {
71
82
  }
72
- export interface IFeaturesHydrated extends IFeaturesShared<IFeatureHydrated> {
83
+ export interface IFeaturesHydrated extends IFeaturesShared<IFeatureHydrated, IFeatureDoorHydrated> {
73
84
  }
74
85
  export declare enum IElementStyleModes {
75
86
  HIGHLIGHT = "highlight",
@@ -156,6 +167,10 @@ export interface ISpacesThemePartial {
156
167
  vertex: Partial<IStylesVertex>;
157
168
  feature: Partial<IStylesFeature>;
158
169
  }
170
+ export interface IWallsValidationConfig {
171
+ minLength: number;
172
+ padding: number;
173
+ }
159
174
  export declare enum SNAPPING_TYPES {
160
175
  ANGLE = "angle"
161
176
  }
@@ -228,6 +243,7 @@ export interface ISpacesConfigUser extends ISpacesConfigShared<Partial<ISpacesSt
228
243
  zoomDisabled: boolean;
229
244
  translateDisabled: boolean;
230
245
  zoomSensitivity: number;
246
+ reverseZoom: boolean;
231
247
  }
232
248
  export interface ISpacesAttributes {
233
249
  [IElements.WALL]: string;
@@ -236,7 +252,6 @@ export interface ISpacesAttributes {
236
252
  [IElements.OPENING]: string;
237
253
  featurePositionX: string;
238
254
  featurePositionY: string;
239
- featurePositionZ: string;
240
255
  featureConnectedTo: string;
241
256
  featureHeight: string;
242
257
  featureLength: string;
@@ -247,6 +262,8 @@ export interface ISpacesAttributes {
247
262
  wallEndY: string;
248
263
  wallEndZ: string;
249
264
  wallConnections: string;
265
+ doorOrientation: string;
266
+ doorOpeningDirection: string;
250
267
  }
251
268
  interface ISpacesPropsShared<T, U> {
252
269
  config: T;
@@ -1,4 +1,4 @@
1
- import { IWall, IFeatures, IElementAddress, IWalls, IErrorElement, IFeature, INewWall, ICoordinate2D, IVertex, ISnapPoint } from './types';
1
+ import { IWall, IFeatures, IElementAddress, IWalls, IErrorElement, IFeature, INewWall, ICoordinate2D, IVertex, ISnapPoint, IWallsValidationConfig } from './types';
2
2
  export interface IFeatureValidatorInput {
3
3
  updatedFeature: Pick<IFeature, 'length' | 'offset'> & {
4
4
  address: IElementAddress;
@@ -20,17 +20,17 @@ export interface IMoveVertexValidatorInput {
20
20
  vertex: IVertex;
21
21
  features: IFeatures;
22
22
  }
23
- declare type IValidatorFunction<T> = (input: T) => false | IErrorElement;
24
- export declare function isWallTooShort(input: IAddWallValidatorInput): false | IErrorElement;
23
+ declare type IValidatorFunction<T> = (input: T, validationConfig: IWallsValidationConfig) => false | IErrorElement;
24
+ export declare function isWallTooShort(input: IAddWallValidatorInput, validationConfig: IWallsValidationConfig): false | IErrorElement;
25
25
  export declare function isWallIntersectingFeature(input: IAddWallValidatorInput): false | IErrorElement;
26
26
  export declare function isWallOverlappingExisitingWalls(input: IAddWallValidatorInput): false | IErrorElement;
27
27
  export declare function isWallEndingOnFeature(input: IAddWallValidatorInput): false | IErrorElement;
28
- export declare function isFeatureOutsideWallBounds(input: IFeatureValidatorInput): false | IErrorElement;
28
+ export declare function isFeatureOutsideWallBounds(input: IFeatureValidatorInput, validationConfig: IWallsValidationConfig): false | IErrorElement;
29
29
  export declare function isFeatureCollidingWithExistingFeature(input: IFeatureValidatorInput): false | IErrorElement;
30
- export declare function areWallsTooShort(input: IMoveVertexValidatorInput): false | IErrorElement;
30
+ export declare function areWallsTooShort(input: IMoveVertexValidatorInput, validationConfig: IWallsValidationConfig): false | IErrorElement;
31
31
  export declare function areWallsIntersecting(input: IMoveVertexValidatorInput): false | IErrorElement;
32
- export declare function areWallsOrphaningFeatures(input: IMoveVertexValidatorInput): false | IErrorElement;
32
+ export declare function areWallsOrphaningFeatures(input: IMoveVertexValidatorInput, validationConfig: IWallsValidationConfig): false | IErrorElement;
33
33
  export declare function areWallsDuplicated(input: IMoveVertexValidatorInput): false | IErrorElement;
34
34
  export declare function isVertexLandingOnFeature(input: IMoveVertexValidatorInput): false | IErrorElement;
35
- export declare function runValidators<T>(validators: Array<IValidatorFunction<T>>, input: T): IErrorElement[] | null;
35
+ export declare function runValidators<T>(validators: Array<IValidatorFunction<T>>, input: T, validationConfig: IWallsValidationConfig): IErrorElement[] | null;
36
36
  export {};
@@ -13,9 +13,8 @@ exports.runValidators = exports.isVertexLandingOnFeature = exports.areWallsDupli
13
13
  var types_1 = require("./types");
14
14
  var geometry_1 = require("./geometry");
15
15
  var messaging_1 = require("./messaging");
16
- var constants_1 = require("./constants");
17
- function isLineTooShort(wallOrLine) {
18
- var minLength = constants_1.MIN_WALL_LENGTH;
16
+ function isLineTooShort(wallOrLine, validationConfig) {
17
+ var minLength = validationConfig.minLength;
19
18
  var line = Array.isArray(wallOrLine) ? wallOrLine : wallOrLine.line;
20
19
  var tooClose = geometry_1.arePointsWithinProximity.apply(void 0, __spreadArray(__spreadArray([], line, false), [minLength], false));
21
20
  if (tooClose)
@@ -25,8 +24,8 @@ function isLineTooShort(wallOrLine) {
25
24
  };
26
25
  return false;
27
26
  }
28
- function isWallTooShort(input) {
29
- return isLineTooShort(input.newWall.line);
27
+ function isWallTooShort(input, validationConfig) {
28
+ return isLineTooShort(input.newWall.line, validationConfig);
30
29
  }
31
30
  exports.isWallTooShort = isWallTooShort;
32
31
  function isWallIntersectingFeature(input) {
@@ -127,9 +126,9 @@ function isWallEndingOnFeature(input) {
127
126
  return false;
128
127
  }
129
128
  exports.isWallEndingOnFeature = isWallEndingOnFeature;
130
- function isFeatureOutsideWallBounds(input) {
129
+ function isFeatureOutsideWallBounds(input, validationConfig) {
131
130
  var wall = input.wall, updatedFeature = input.updatedFeature;
132
- var padding = constants_1.WALL_PADDING_FOR_FEATURE;
131
+ var padding = validationConfig.padding;
133
132
  var wallLength = (0, geometry_1.getLengthOfLineSegment)(wall.line);
134
133
  if (updatedFeature.offset < padding ||
135
134
  updatedFeature.offset + updatedFeature.length > wallLength - padding)
@@ -166,7 +165,7 @@ function isFeatureCollidingWithExistingFeature(input) {
166
165
  return false;
167
166
  }
168
167
  exports.isFeatureCollidingWithExistingFeature = isFeatureCollidingWithExistingFeature;
169
- function areWallsTooShort(input) {
168
+ function areWallsTooShort(input, validationConfig) {
170
169
  var walls = input.walls, vertex = input.vertex, updatedPosition = input.updatedPosition;
171
170
  var _a = vertex.connections.reduce(function (output, connection) {
172
171
  var _a;
@@ -184,7 +183,7 @@ function areWallsTooShort(input) {
184
183
  var index = wallIndexes_1[_i];
185
184
  var line = walls[index].line;
186
185
  line[updatedVerticesMap[index]] = updatedPosition.point;
187
- if (isLineTooShort(line))
186
+ if (isLineTooShort(line, validationConfig))
188
187
  return {
189
188
  address: { type: types_1.IElements.WALL, index: index },
190
189
  message: messaging_1.errorMessages.wallTooShort(),
@@ -230,9 +229,10 @@ function areWallsIntersecting(input) {
230
229
  return false;
231
230
  }
232
231
  exports.areWallsIntersecting = areWallsIntersecting;
233
- function areWallsOrphaningFeatures(input) {
232
+ function areWallsOrphaningFeatures(input, validationConfig) {
234
233
  var _a;
235
234
  var walls = input.walls, vertex = input.vertex, features = input.features, updatedPosition = input.updatedPosition;
235
+ var padding = validationConfig.padding;
236
236
  var _b = vertex.connections.reduce(function (output, connection) {
237
237
  var _a;
238
238
  var wallIndex = connection[0], vertexIndex = connection[1];
@@ -266,10 +266,9 @@ function areWallsOrphaningFeatures(input) {
266
266
  type: types_1.IErrorTypes.HARD,
267
267
  };
268
268
  if (updatedVerticesMap[wallIdx] === 0 &&
269
- feat.offset - wallLengthDelta < constants_1.WALL_PADDING_FOR_FEATURE)
269
+ feat.offset - wallLengthDelta < padding)
270
270
  return error;
271
- else if (feat.offset + feat.length >
272
- updatedWallLength - constants_1.WALL_PADDING_FOR_FEATURE) {
271
+ else if (feat.offset + feat.length > updatedWallLength - padding) {
273
272
  return error;
274
273
  }
275
274
  }
@@ -348,9 +347,9 @@ function isVertexLandingOnFeature(input) {
348
347
  return false;
349
348
  }
350
349
  exports.isVertexLandingOnFeature = isVertexLandingOnFeature;
351
- function runValidators(validators, input) {
350
+ function runValidators(validators, input, validationConfig) {
352
351
  var errors = validators.reduce(function (output, validate) {
353
- var error = validate(input);
352
+ var error = validate(input, validationConfig);
354
353
  if (error)
355
354
  output.push(error);
356
355
  return output;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threekit-tools/treble",
3
- "version": "0.0.90-next-05",
3
+ "version": "0.0.90-next-07",
4
4
  "author": "Amaan Saeed",
5
5
  "license": "MIT",
6
6
  "files": [