@threekit-tools/treble 0.0.89-next-004 → 0.0.89-next-006

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.
@@ -26,7 +26,7 @@ declare class Treble {
26
26
  _debugMode: boolean;
27
27
  constructor({ player, orgId }: ITreble);
28
28
  createOrder: (order?: IOrder) => Promise<import("../http/orders").IOrderResponse>;
29
- saveConfiguration: (config?: Partial<Omit<ISaveConfiguration, 'configuration'>>) => Promise<{
29
+ saveConfiguration: (config?: Partial<ISaveConfiguration>) => Promise<{
30
30
  resumableUrl: string;
31
31
  } & import("../http/configurations").IConfigurationResponse & {
32
32
  thumbnail: string;
@@ -80,18 +80,18 @@ var Treble = (function () {
80
80
  });
81
81
  }); };
82
82
  this.saveConfiguration = function (config) { return __awaiter(_this, void 0, void 0, function () {
83
- var threekitDomain, _a, customerId, metadata, productVersion, attachments, player, response, params, url;
83
+ var threekitDomain, _a, customerId, metadata, configuration, productVersion, attachments, player, response, params, url;
84
84
  var _b;
85
85
  var _c;
86
86
  return __generator(this, function (_d) {
87
87
  switch (_d.label) {
88
88
  case 0:
89
89
  threekitDomain = connection_1.default.getConnection().threekitDomain;
90
- _a = Object.assign({}, config), customerId = _a.customerId, metadata = _a.metadata, productVersion = _a.productVersion, attachments = _a.attachments;
90
+ _a = Object.assign({}, config), customerId = _a.customerId, metadata = _a.metadata, configuration = _a.configuration, productVersion = _a.productVersion, attachments = _a.attachments;
91
91
  player = window.threekit.player.enableApi(types_1.PRIVATE_APIS.PLAYER);
92
92
  return [4, api_1.default.configurations.save({
93
93
  assetId: window.threekit.player.assetId,
94
- configuration: player.getConfigurator().getFullConfiguration(),
94
+ configuration: configuration || player.getConfigurator().getFullConfiguration(),
95
95
  customerId: customerId,
96
96
  metadata: metadata,
97
97
  productVersion: productVersion,
@@ -57,8 +57,7 @@ var useNestedConfigurator = function (address) {
57
57
  return;
58
58
  if (playerLoading)
59
59
  return;
60
- configurator.current =
61
- window.threekit.treble.getNestedConfigurator(address);
60
+ configurator.current = window.threekit.configurator.getNestedConfigurator([address].flat());
62
61
  if (!configurator.current)
63
62
  return;
64
63
  var updatedAttrs = configurator.current.getDisplayAttributes();
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import type { ICoordinate2D } from './types';
3
+ interface IRoomBuilderLayout {
4
+ loops?: Array<ICoordinate2D[]>;
5
+ size?: number;
6
+ }
7
+ export default function RoomBuilderLayout(props: IRoomBuilderLayout): JSX.Element;
8
+ export {};
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var react_1 = __importDefault(require("react"));
7
+ function RoomBuilderLayout(props) {
8
+ var loops = props.loops;
9
+ var size = props.size || 20;
10
+ if (!(loops === null || loops === void 0 ? void 0 : loops.length))
11
+ return react_1.default.createElement(react_1.default.Fragment, null);
12
+ var paths = loops.map(function (loop) {
13
+ return loop
14
+ .map(function (_a, i) {
15
+ var x = _a[0], y = _a[1];
16
+ return (i === 0 ? 'M ' : 'L ') + x + ' ' + y;
17
+ })
18
+ .join(' ') + ' Z';
19
+ });
20
+ return (react_1.default.createElement("svg", { width: size, height: size, viewBox: "0 0 ".concat(size, " ").concat(size), fill: "none", xmlns: "http://www.w3.org/2000/svg" }, paths.map(function (path, i) { return (react_1.default.createElement("path", { key: "path-".concat(i), d: path, stroke: "white", strokeWidth: 1 })); })));
21
+ }
22
+ exports.default = RoomBuilderLayout;
@@ -10,16 +10,32 @@ export declare class RoomBuilderState {
10
10
  private _errorElement;
11
11
  private _showDimensions;
12
12
  private _angleSnappingEnabled;
13
+ private _canvasDimensions;
14
+ private _zoom;
15
+ private _zoomLimits;
16
+ private _translate;
17
+ private _translateLimits;
13
18
  private _state;
14
19
  constructor(config: IRoomBuilderStateProps);
15
20
  get walls(): IWalls;
21
+ get wallsToDraw(): {
22
+ line: ICoordinatesLine;
23
+ path: undefined;
24
+ assetId: string;
25
+ height?: number | undefined;
26
+ thickness?: number | undefined;
27
+ connections: [elementType: IFeatureName, index: number][];
28
+ }[];
16
29
  set walls(walls: IWalls);
17
30
  get wallCount(): number;
18
31
  get wallLines(): ICoordinatesLine[];
19
32
  get vertices(): IVerticesState;
33
+ get verticesToDraw(): IVerticesState;
20
34
  set vertices(vertices: IVerticesState);
21
35
  get verticesList(): Array<IVertex>;
36
+ get verticesListToDraw(): Array<IVertex>;
22
37
  get features(): IFeatures;
38
+ get featuresToDraw(): Record<string, IFeature[]>;
23
39
  set features(features: IFeatures);
24
40
  get getHydratedFeatures(): undefined | IFeaturesHydrated;
25
41
  get featureCount(): number;
@@ -30,7 +46,27 @@ export declare class RoomBuilderState {
30
46
  set showDimensions(val: boolean);
31
47
  get angleSnappingEnabled(): boolean;
32
48
  set angleSnappingEnabled(val: boolean);
33
- get enclosedSpaces(): Array<IEnclosedSpace>;
49
+ get enclosedSpacesToDraw(): Array<IEnclosedSpace>;
50
+ get canvasDimensions(): ICoordinate2D;
51
+ get canvasWidth(): number;
52
+ get canvasHeight(): number;
53
+ set canvasDimensions(dimensions: ICoordinate2D);
54
+ get zoom(): number;
55
+ get zoomFactor(): number;
56
+ get zoomMin(): number;
57
+ get zoomMax(): number;
58
+ setZoom(delta: number): number | undefined;
59
+ get translate(): ICoordinate2D;
60
+ get translateMin(): ICoordinate2D;
61
+ get translateMax(): ICoordinate2D;
62
+ set translate(position: ICoordinate2D);
63
+ get isDrawWallActive(): boolean;
64
+ transformLengthFromCanvas(length: number): number;
65
+ transformLengthToCanvas(length: number): number;
66
+ transformPointToCanvas(point: ICoordinate2D): ICoordinate2D;
67
+ transformPointFromCanvas(point: ICoordinate2D): ICoordinate2D;
68
+ transformLineToCanvas(line: ICoordinatesLine): ICoordinatesLine;
69
+ transformLineFromCanvas(line: ICoordinatesLine): ICoordinatesLine;
34
70
  private getWall;
35
71
  private addWall;
36
72
  private addWalls;
@@ -39,7 +75,7 @@ export declare class RoomBuilderState {
39
75
  private getWallConnectionsHydrated;
40
76
  private getWallDimensions;
41
77
  private getWallDetailedDimensions;
42
- private getAllWallDimensions;
78
+ private getAllWallDimensionsToDraw;
43
79
  private shiftAllFeaturesOnWall;
44
80
  private addFeatureToWall;
45
81
  private removeFeatureFromWall;
@@ -70,23 +106,24 @@ export declare class RoomBuilderState {
70
106
  private snapVertexToAbsoluteAngle;
71
107
  private getFeatureAtPoint;
72
108
  private getElementAtPoint;
73
- getClickedElement(point: ICoordinate2D): undefined | IElementUi;
109
+ getClickedElement(cursorPoint: ICoordinate2D): undefined | IElementUi;
74
110
  private getPointProximity;
75
111
  private reevaluateFeatureConnections;
76
112
  private pushStateToConfigurator;
77
113
  setAttributesToState(attributes?: Record<string, IHydratedAttribute>): void;
78
114
  deleteAll(): void;
79
115
  private resetInternalState;
80
- highlightElementIfInProximity(canvas: HTMLCanvasElement, point: ICoordinate2D): void;
116
+ highlightElementIfInProximity(canvas: HTMLCanvasElement, cursorPoint: ICoordinate2D): void;
81
117
  startDrawNewWall(startPoint: ICoordinate2D): void;
82
118
  drawNewWall(canvas: HTMLCanvasElement, endPoint: ICoordinate2D): void;
83
119
  cancelDrawNewWall(canvas: HTMLCanvasElement): void;
84
120
  finishDrawNewWall(canvas: HTMLCanvasElement, assetId: string): Promise<void>;
121
+ drawNewWallGuides(canvas: HTMLCanvasElement, cursorPoint: ICoordinate2D): void;
85
122
  private moveActiveVertex;
86
123
  private finishMoveActiveVertex;
87
124
  private moveActiveFeature;
88
125
  private finishMoveActiveFeature;
89
- selectElementIfInProximity(canvas: HTMLCanvasElement, point: ICoordinate2D): void;
126
+ selectElementIfInProximity(canvas: HTMLCanvasElement, cursorPoint: ICoordinate2D): void;
90
127
  moveActiveElement(canvas: HTMLCanvasElement, moveToPoint: ICoordinate2D): void;
91
128
  finishMoveActiveElement(canvas: HTMLCanvasElement): void;
92
129
  cancelMoveActiveElement(canvas: HTMLCanvasElement): void;
@@ -109,7 +109,7 @@ var RoomBuilderState = (function () {
109
109
  _this._activeElement.snapPoint = snapPoint;
110
110
  _this.repositionVertex(_this._activeElement.index, (_c = snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.point) !== null && _c !== void 0 ? _c : point);
111
111
  _this.drawRoom(canvas);
112
- (0, draw_1.drawVertex)(canvas, (_d = snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.point) !== null && _d !== void 0 ? _d : point, _this._config.config.styles.vertex, types_1.IElementStyleModes.HIGHLIGHT);
112
+ (0, draw_1.drawVertex)(canvas, _this.transformPointToCanvas((_d = snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.point) !== null && _d !== void 0 ? _d : point), _this._config.config.styles.vertex, types_1.IElementStyleModes.HIGHLIGHT);
113
113
  break;
114
114
  }
115
115
  };
@@ -191,6 +191,11 @@ var RoomBuilderState = (function () {
191
191
  this._showDimensions = true;
192
192
  this._angleSnappingEnabled = true;
193
193
  this._attributesState = null;
194
+ this._canvasDimensions = [0, 0];
195
+ this._zoom = config.config.zoomDefault;
196
+ this._zoomLimits = [constants_1.ZOOM_MIN, constants_1.ZOOM_MAX];
197
+ this._translate = config.config.translateDefault;
198
+ this._translateLimits = [constants_1.TRANSLATE_MIN, constants_1.TRANSLATE_MAX];
194
199
  }
195
200
  Object.defineProperty(RoomBuilderState.prototype, "walls", {
196
201
  get: function () {
@@ -202,6 +207,14 @@ var RoomBuilderState = (function () {
202
207
  enumerable: false,
203
208
  configurable: true
204
209
  });
210
+ Object.defineProperty(RoomBuilderState.prototype, "wallsToDraw", {
211
+ get: function () {
212
+ var _this = this;
213
+ return this._state[types_2.IElements.WALL].map(function (wall) { return (__assign(__assign({}, wall), { line: _this.transformLineToCanvas(wall.line), path: undefined })); });
214
+ },
215
+ enumerable: false,
216
+ configurable: true
217
+ });
205
218
  Object.defineProperty(RoomBuilderState.prototype, "wallCount", {
206
219
  get: function () {
207
220
  return this.walls.length;
@@ -229,6 +242,13 @@ var RoomBuilderState = (function () {
229
242
  enumerable: false,
230
243
  configurable: true
231
244
  });
245
+ Object.defineProperty(RoomBuilderState.prototype, "verticesToDraw", {
246
+ get: function () {
247
+ return this._state[types_2.IElements.VERTEX];
248
+ },
249
+ enumerable: false,
250
+ configurable: true
251
+ });
232
252
  Object.defineProperty(RoomBuilderState.prototype, "verticesList", {
233
253
  get: function () {
234
254
  return Object.entries(this.vertices).map(function (_a) {
@@ -242,6 +262,14 @@ var RoomBuilderState = (function () {
242
262
  enumerable: false,
243
263
  configurable: true
244
264
  });
265
+ Object.defineProperty(RoomBuilderState.prototype, "verticesListToDraw", {
266
+ get: function () {
267
+ var _this = this;
268
+ return this.verticesList.map(function (vertex) { return (__assign(__assign({}, vertex), { point: _this.transformPointToCanvas(vertex.point) })); });
269
+ },
270
+ enumerable: false,
271
+ configurable: true
272
+ });
245
273
  Object.defineProperty(RoomBuilderState.prototype, "features", {
246
274
  get: function () {
247
275
  return this._state[types_2.IElements.FEATURE];
@@ -252,6 +280,20 @@ var RoomBuilderState = (function () {
252
280
  enumerable: false,
253
281
  configurable: true
254
282
  });
283
+ Object.defineProperty(RoomBuilderState.prototype, "featuresToDraw", {
284
+ get: function () {
285
+ var _this = this;
286
+ return Object.entries(this.features).reduce(function (output, _a) {
287
+ var _b;
288
+ var type = _a[0], featureArr = _a[1];
289
+ return Object.assign(output, (_b = {},
290
+ _b[type] = featureArr.map(function (feature) { return (__assign(__assign({}, feature), { path: undefined, offset: _this.transformLengthToCanvas(feature.offset), length: _this.transformLengthToCanvas(feature.length) })); }),
291
+ _b));
292
+ }, {});
293
+ },
294
+ enumerable: false,
295
+ configurable: true
296
+ });
255
297
  Object.defineProperty(RoomBuilderState.prototype, "getHydratedFeatures", {
256
298
  get: function () {
257
299
  var _this = this;
@@ -316,7 +358,7 @@ var RoomBuilderState = (function () {
316
358
  enumerable: false,
317
359
  configurable: true
318
360
  });
319
- Object.defineProperty(RoomBuilderState.prototype, "enclosedSpaces", {
361
+ Object.defineProperty(RoomBuilderState.prototype, "enclosedSpacesToDraw", {
320
362
  get: function () {
321
363
  var _this = this;
322
364
  var loops = (0, findLoops_1.findLoops)(this.wallLines).inner;
@@ -325,7 +367,7 @@ var RoomBuilderState = (function () {
325
367
  var area = screenSpaceArea * Math.pow(_this._config.config.scale, 2);
326
368
  var convertedArea = (0, dataHandlers_1.convertAreaUnit)(area, types_1.IUnits.METER, _this._config.config.unit);
327
369
  var enclosedSpace = {
328
- loop: loop,
370
+ loop: loop.map(function (point) { return _this.transformPointToCanvas(point); }),
329
371
  area: (0, dataHandlers_1.prepAreaForUser)(convertedArea, _this._config.config.unit),
330
372
  center: loop.reduce(function (centerPoint, point) {
331
373
  centerPoint[0] += point[0] / loop.length;
@@ -333,6 +375,7 @@ var RoomBuilderState = (function () {
333
375
  return centerPoint;
334
376
  }, [0, 0]),
335
377
  };
378
+ enclosedSpace.center = _this.transformPointToCanvas(enclosedSpace.center);
336
379
  output.push(enclosedSpace);
337
380
  return output;
338
381
  }, []);
@@ -340,6 +383,145 @@ var RoomBuilderState = (function () {
340
383
  enumerable: false,
341
384
  configurable: true
342
385
  });
386
+ Object.defineProperty(RoomBuilderState.prototype, "canvasDimensions", {
387
+ get: function () {
388
+ return this._canvasDimensions;
389
+ },
390
+ set: function (dimensions) {
391
+ this._canvasDimensions = dimensions;
392
+ },
393
+ enumerable: false,
394
+ configurable: true
395
+ });
396
+ Object.defineProperty(RoomBuilderState.prototype, "canvasWidth", {
397
+ get: function () {
398
+ return this.canvasDimensions[0];
399
+ },
400
+ enumerable: false,
401
+ configurable: true
402
+ });
403
+ Object.defineProperty(RoomBuilderState.prototype, "canvasHeight", {
404
+ get: function () {
405
+ return this.canvasDimensions[1];
406
+ },
407
+ enumerable: false,
408
+ configurable: true
409
+ });
410
+ Object.defineProperty(RoomBuilderState.prototype, "zoom", {
411
+ get: function () {
412
+ return this._zoom;
413
+ },
414
+ enumerable: false,
415
+ configurable: true
416
+ });
417
+ Object.defineProperty(RoomBuilderState.prototype, "zoomFactor", {
418
+ get: function () {
419
+ return this._zoom / this.zoomMin;
420
+ },
421
+ enumerable: false,
422
+ configurable: true
423
+ });
424
+ Object.defineProperty(RoomBuilderState.prototype, "zoomMin", {
425
+ get: function () {
426
+ return this._zoomLimits[0];
427
+ },
428
+ enumerable: false,
429
+ configurable: true
430
+ });
431
+ Object.defineProperty(RoomBuilderState.prototype, "zoomMax", {
432
+ get: function () {
433
+ return this._zoomLimits[1];
434
+ },
435
+ enumerable: false,
436
+ configurable: true
437
+ });
438
+ RoomBuilderState.prototype.setZoom = function (delta) {
439
+ var newZoom = this.zoom + delta;
440
+ var preppedZoom = newZoom < this.zoomMin
441
+ ? this.zoomMin
442
+ : newZoom > this.zoomMax
443
+ ? this.zoomMax
444
+ : newZoom;
445
+ if (preppedZoom === this.zoom)
446
+ return;
447
+ this._zoom = preppedZoom;
448
+ return this.zoom;
449
+ };
450
+ Object.defineProperty(RoomBuilderState.prototype, "translate", {
451
+ get: function () {
452
+ return this._translate;
453
+ },
454
+ set: function (position) {
455
+ var zoomFactor = this._zoom / this.zoomMin;
456
+ var delta = [
457
+ (position[0] - this._translate[0]) / zoomFactor,
458
+ (position[1] - this._translate[1]) / zoomFactor,
459
+ ];
460
+ this._translate = [
461
+ this._translate[0] + delta[0],
462
+ this._translate[1] + delta[1],
463
+ ];
464
+ },
465
+ enumerable: false,
466
+ configurable: true
467
+ });
468
+ Object.defineProperty(RoomBuilderState.prototype, "translateMin", {
469
+ get: function () {
470
+ return this._translateLimits[0];
471
+ },
472
+ enumerable: false,
473
+ configurable: true
474
+ });
475
+ Object.defineProperty(RoomBuilderState.prototype, "translateMax", {
476
+ get: function () {
477
+ return this._translateLimits[1];
478
+ },
479
+ enumerable: false,
480
+ configurable: true
481
+ });
482
+ Object.defineProperty(RoomBuilderState.prototype, "isDrawWallActive", {
483
+ get: function () {
484
+ return !!this._newWall;
485
+ },
486
+ enumerable: false,
487
+ configurable: true
488
+ });
489
+ RoomBuilderState.prototype.transformLengthFromCanvas = function (length) {
490
+ return length / this.zoomFactor;
491
+ };
492
+ RoomBuilderState.prototype.transformLengthToCanvas = function (length) {
493
+ return length * this.zoomFactor;
494
+ };
495
+ RoomBuilderState.prototype.transformPointToCanvas = function (point) {
496
+ var widthOffset = this.canvasWidth / 2;
497
+ var heightOffset = this.canvasHeight / 2;
498
+ return [
499
+ this.transformLengthToCanvas(point[0] + this.translate[0]) -
500
+ widthOffset * (this.zoomFactor - 1),
501
+ this.transformLengthToCanvas(point[1] + this.translate[1]) -
502
+ heightOffset * (this.zoomFactor - 1),
503
+ ];
504
+ };
505
+ RoomBuilderState.prototype.transformPointFromCanvas = function (point) {
506
+ var widthOffset = this.canvasWidth / 2;
507
+ var heightOffset = this.canvasHeight / 2;
508
+ return [
509
+ this.transformLengthFromCanvas(point[0] + widthOffset * (this.zoomFactor - 1)) - this.translate[0],
510
+ this.transformLengthFromCanvas(point[1] + heightOffset * (this.zoomFactor - 1)) - this.translate[1],
511
+ ];
512
+ };
513
+ RoomBuilderState.prototype.transformLineToCanvas = function (line) {
514
+ return [
515
+ this.transformPointToCanvas(line[0]),
516
+ this.transformPointToCanvas(line[1]),
517
+ ];
518
+ };
519
+ RoomBuilderState.prototype.transformLineFromCanvas = function (line) {
520
+ return [
521
+ this.transformPointFromCanvas(line[0]),
522
+ this.transformPointFromCanvas(line[1]),
523
+ ];
524
+ };
343
525
  RoomBuilderState.prototype.getWall = function (index) {
344
526
  return this.walls[index];
345
527
  };
@@ -442,11 +624,11 @@ var RoomBuilderState = (function () {
442
624
  }, []);
443
625
  return lines;
444
626
  };
445
- RoomBuilderState.prototype.getAllWallDimensions = function (detailedWallsIndexes) {
627
+ RoomBuilderState.prototype.getAllWallDimensionsToDraw = function (detailedWallsIndexes) {
446
628
  var _this = this;
447
629
  if (detailedWallsIndexes === void 0) { detailedWallsIndexes = []; }
448
630
  var indexes = new Set([detailedWallsIndexes].flat());
449
- return this.walls.reduce(function (output, _, i) {
631
+ var dimensionsList = this.walls.reduce(function (output, _, i) {
450
632
  var dimensions = indexes.has(i)
451
633
  ? _this.getWallDetailedDimensions(i)
452
634
  : _this.getWallDimensions(i);
@@ -458,6 +640,7 @@ var RoomBuilderState = (function () {
458
640
  output.push(dimensions);
459
641
  return output;
460
642
  }, []);
643
+ return dimensionsList.map(function (dimension) { return (__assign(__assign({}, dimension), { line: _this.transformLineToCanvas(dimension.line) })); });
461
644
  };
462
645
  RoomBuilderState.prototype.shiftAllFeaturesOnWall = function (index, shift) {
463
646
  var _this = this;
@@ -622,7 +805,8 @@ var RoomBuilderState = (function () {
622
805
  if (!wall)
623
806
  return undefined;
624
807
  var line = (0, geometry_1.getParallelLineSegmentAtDistance)(wall.line, constants_1.UI_ANCHOR_DISTANCE);
625
- return (0, geometry_1.getMidpointOfLineSegment)(line);
808
+ var point = (0, geometry_1.getMidpointOfLineSegment)(line);
809
+ return this.transformPointToCanvas(point);
626
810
  };
627
811
  RoomBuilderState.prototype.getVertex = function (index) {
628
812
  return this.verticesList[index];
@@ -762,7 +946,8 @@ var RoomBuilderState = (function () {
762
946
  if (!feature)
763
947
  return;
764
948
  var line = (0, geometry_1.getParallelLineSegmentAtDistance)(feature.line, constants_1.UI_ANCHOR_DISTANCE);
765
- return (0, geometry_1.getMidpointOfLineSegment)(line);
949
+ var point = (0, geometry_1.getMidpointOfLineSegment)(line);
950
+ return this.transformPointToCanvas(point);
766
951
  };
767
952
  RoomBuilderState.prototype.deleteElement = function (type, index) {
768
953
  if (type === types_2.IElements.VERTEX)
@@ -773,11 +958,11 @@ var RoomBuilderState = (function () {
773
958
  this.deleteFeature(type, index);
774
959
  };
775
960
  RoomBuilderState.prototype.getVertexInProximity = function (point) {
776
- var _this = this;
777
961
  if (!point)
778
962
  return undefined;
963
+ var snapProximity = this.transformLengthFromCanvas(this._config.config.snapProximity);
779
964
  var index = this.verticesList.findIndex(function (vertex) {
780
- return (0, geometry_1.arePointsWithinProximity)(vertex.point, point, _this._config.config.snapProximity);
965
+ return (0, geometry_1.arePointsWithinProximity)(vertex.point, point, snapProximity);
781
966
  });
782
967
  if (index === -1)
783
968
  return undefined;
@@ -835,17 +1020,17 @@ var RoomBuilderState = (function () {
835
1020
  return __assign({ type: types_2.IElements.WALL, index: index }, intersection);
836
1021
  };
837
1022
  RoomBuilderState.prototype.snapPointToAbsoluteAngle = function (point, anchorPoint, angle) {
838
- if (angle === void 0) { angle = 15; }
839
- var snapProximity = this._config.config.snapProximity;
1023
+ if (angle === void 0) { angle = 30; }
1024
+ var snapProximity = this.transformLengthFromCanvas(this._config.config.snapProximity);
840
1025
  if (Math.abs(point[0] - anchorPoint[0]) < snapProximity) {
841
1026
  return {
842
- type: 'Angle',
1027
+ type: types_1.SNAPPING_TYPES.ANGLE,
843
1028
  point: [anchorPoint[0], point[1]],
844
1029
  };
845
1030
  }
846
1031
  else if (Math.abs(point[1] - anchorPoint[1]) < snapProximity) {
847
1032
  return {
848
- type: 'Angle',
1033
+ type: types_1.SNAPPING_TYPES.ANGLE,
849
1034
  point: [point[0], anchorPoint[1]],
850
1035
  };
851
1036
  }
@@ -855,7 +1040,7 @@ var RoomBuilderState = (function () {
855
1040
  var radians = degrees * (Math.PI / 180);
856
1041
  if ((0, geometry_1.getDistanceToLine)(anchorPoint, radians, point) < snapProximity)
857
1042
  return {
858
- type: 'Angle',
1043
+ type: types_1.SNAPPING_TYPES.ANGLE,
859
1044
  point: (0, geometry_1.closestPointOnLine)(anchorPoint, radians, point),
860
1045
  };
861
1046
  }
@@ -866,6 +1051,7 @@ var RoomBuilderState = (function () {
866
1051
  var vertex = this.getVertex(vertexIndex);
867
1052
  if (!vertex)
868
1053
  return undefined;
1054
+ var snapProximity = this.transformLengthFromCanvas(this._config.config.snapProximity);
869
1055
  var point = vertex.connections.reduce(function (output, connection) {
870
1056
  var _a;
871
1057
  var line = (_a = _this.getWall(connection[0])) === null || _a === void 0 ? void 0 : _a.line;
@@ -873,16 +1059,16 @@ var RoomBuilderState = (function () {
873
1059
  return output;
874
1060
  var _b = output || updatedPoint, x = _b[0], y = _b[1];
875
1061
  var _c = line[connection[1] === 0 ? 1 : 0], xAnchor = _c[0], yAnchor = _c[1];
876
- if (Math.abs(x - xAnchor) < _this._config.config.snapProximity)
1062
+ if (Math.abs(x - xAnchor) < snapProximity)
877
1063
  return [xAnchor, y];
878
- else if (Math.abs(y - yAnchor) < _this._config.config.snapProximity)
1064
+ else if (Math.abs(y - yAnchor) < snapProximity)
879
1065
  return [x, yAnchor];
880
1066
  return output;
881
1067
  }, undefined);
882
1068
  if (!point)
883
1069
  return point;
884
1070
  return {
885
- type: 'Angle',
1071
+ type: types_1.SNAPPING_TYPES.ANGLE,
886
1072
  point: point,
887
1073
  };
888
1074
  };
@@ -928,7 +1114,8 @@ var RoomBuilderState = (function () {
928
1114
  return { type: types_2.IElements.WALL, index: wallInProximity };
929
1115
  return undefined;
930
1116
  };
931
- RoomBuilderState.prototype.getClickedElement = function (point) {
1117
+ RoomBuilderState.prototype.getClickedElement = function (cursorPoint) {
1118
+ var point = this.transformPointFromCanvas(cursorPoint);
932
1119
  var element = this.getElementAtPoint(point);
933
1120
  if (!element)
934
1121
  return;
@@ -975,8 +1162,6 @@ var RoomBuilderState = (function () {
975
1162
  RoomBuilderState.prototype.setAttributesToState = function (attributes) {
976
1163
  if (!attributes)
977
1164
  return;
978
- if (!attributes[this._config.attributes[types_2.IElements.WALL]])
979
- return;
980
1165
  this._attributesState = attributes;
981
1166
  var data = (0, dataHandlers_1.prepAttributesIncoming)(attributes, this._config);
982
1167
  this.walls = data[types_2.IElements.WALL];
@@ -997,8 +1182,9 @@ var RoomBuilderState = (function () {
997
1182
  if (this._attributesState)
998
1183
  this.setAttributesToState(this._attributesState);
999
1184
  };
1000
- RoomBuilderState.prototype.highlightElementIfInProximity = function (canvas, point) {
1185
+ RoomBuilderState.prototype.highlightElementIfInProximity = function (canvas, cursorPoint) {
1001
1186
  var _a, _b;
1187
+ var point = this.transformPointFromCanvas(cursorPoint);
1002
1188
  var elementAtPoint = this.getElementAtPoint(point);
1003
1189
  if ((!elementAtPoint && !this._highlightedElement) ||
1004
1190
  Array.isArray(this._highlightedElement))
@@ -1014,13 +1200,14 @@ var RoomBuilderState = (function () {
1014
1200
  };
1015
1201
  RoomBuilderState.prototype.startDrawNewWall = function (startPoint) {
1016
1202
  var _a;
1017
- var snapPoint = this.getPointProximity(startPoint);
1203
+ var point = this.transformPointFromCanvas(startPoint);
1204
+ var snapPoint = this.getPointProximity(point);
1018
1205
  if ((snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.type) === types_2.IElements.WINDOW ||
1019
1206
  (snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.type) === types_2.IElements.OPENING ||
1020
1207
  (snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.type) === types_2.IElements.DOOR)
1021
1208
  return;
1022
1209
  this._newWall = {
1023
- start: (_a = snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.point) !== null && _a !== void 0 ? _a : startPoint,
1210
+ start: (_a = snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.point) !== null && _a !== void 0 ? _a : point,
1024
1211
  snapStartTo: snapPoint,
1025
1212
  };
1026
1213
  };
@@ -1028,12 +1215,13 @@ var RoomBuilderState = (function () {
1028
1215
  var _a, _b, _c, _d, _e;
1029
1216
  if (!this._newWall)
1030
1217
  return;
1031
- var snapPoint = this.getPointProximity(endPoint);
1218
+ var point = this.transformPointFromCanvas(endPoint);
1219
+ var snapPoint = this.getPointProximity(point);
1032
1220
  if (!snapPoint && this._angleSnappingEnabled)
1033
- snapPoint = this.snapPointToAbsoluteAngle(endPoint, (_b = (_a = this._newWall.snapStartTo) === null || _a === void 0 ? void 0 : _a.point) !== null && _b !== void 0 ? _b : this._newWall.start);
1221
+ snapPoint = this.snapPointToAbsoluteAngle(point, (_b = (_a = this._newWall.snapStartTo) === null || _a === void 0 ? void 0 : _a.point) !== null && _b !== void 0 ? _b : this._newWall.start);
1034
1222
  var wallLine = [
1035
1223
  this._newWall.start,
1036
- (_c = snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.point) !== null && _c !== void 0 ? _c : endPoint,
1224
+ (_c = snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.point) !== null && _c !== void 0 ? _c : point,
1037
1225
  ];
1038
1226
  var validationData = {
1039
1227
  walls: this.walls,
@@ -1058,7 +1246,7 @@ var RoomBuilderState = (function () {
1058
1246
  case types_1.IErrorTypes.WARN:
1059
1247
  case null:
1060
1248
  default:
1061
- this._newWall.end = (_e = snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.point) !== null && _e !== void 0 ? _e : endPoint;
1249
+ this._newWall.end = (_e = snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.point) !== null && _e !== void 0 ? _e : point;
1062
1250
  this._newWall.snapEndTo = snapPoint;
1063
1251
  this.drawRoom(canvas);
1064
1252
  break;
@@ -1129,7 +1317,13 @@ var RoomBuilderState = (function () {
1129
1317
  });
1130
1318
  });
1131
1319
  };
1132
- RoomBuilderState.prototype.selectElementIfInProximity = function (canvas, point) {
1320
+ RoomBuilderState.prototype.drawNewWallGuides = function (canvas, cursorPoint) {
1321
+ var point = this.transformPointFromCanvas(cursorPoint);
1322
+ if (canvas)
1323
+ console.log(point);
1324
+ };
1325
+ RoomBuilderState.prototype.selectElementIfInProximity = function (canvas, cursorPoint) {
1326
+ var point = this.transformPointFromCanvas(cursorPoint);
1133
1327
  var elementAtPoint = this.getElementAtPoint(point);
1134
1328
  if (!elementAtPoint || elementAtPoint.type === types_2.IElements.WALL)
1135
1329
  return;
@@ -1148,13 +1342,14 @@ var RoomBuilderState = (function () {
1148
1342
  return;
1149
1343
  if (!this._activeElement)
1150
1344
  return;
1345
+ var point = this.transformPointFromCanvas(moveToPoint);
1151
1346
  var type = this._activeElement.type;
1152
1347
  if (type === types_2.IElements.VERTEX)
1153
- this.moveActiveVertex(canvas, moveToPoint);
1348
+ this.moveActiveVertex(canvas, point);
1154
1349
  else if (type === types_2.IElements.WINDOW ||
1155
1350
  type === types_2.IElements.DOOR ||
1156
1351
  type === types_2.IElements.OPENING)
1157
- this.moveActiveFeature(canvas, moveToPoint);
1352
+ this.moveActiveFeature(canvas, point);
1158
1353
  };
1159
1354
  RoomBuilderState.prototype.finishMoveActiveElement = function (canvas) {
1160
1355
  if (!this._activeElement)
@@ -1223,11 +1418,11 @@ var RoomBuilderState = (function () {
1223
1418
  ((_c = this._activeElement) === null || _c === void 0 ? void 0 : _c.type) === types_2.IElements.DOOR ||
1224
1419
  ((_d = this._activeElement) === null || _d === void 0 ? void 0 : _d.type) === types_2.IElements.OPENING))
1225
1420
  activeWallIndex = (_e = this.getFeature(this._activeElement.type, this._activeElement.index)) === null || _e === void 0 ? void 0 : _e.connectedTo[1];
1226
- (0, draw_1.drawRoom)(canvas, this.enclosedSpaces, this.walls, this.verticesList, this.features, this._showDimensions
1227
- ? this.getAllWallDimensions(activeWallIndex)
1421
+ (0, draw_1.drawRoom)(canvas, this.enclosedSpacesToDraw, this.wallsToDraw, this.verticesListToDraw, this.featuresToDraw, this._showDimensions
1422
+ ? this.getAllWallDimensionsToDraw(activeWallIndex)
1228
1423
  : undefined, selection, this._config.config);
1229
1424
  if (((_f = this._newWall) === null || _f === void 0 ? void 0 : _f.start) && ((_g = this._newWall) === null || _g === void 0 ? void 0 : _g.end)) {
1230
- (0, draw_1.drawNewWall)(canvas, [this._newWall.start, this._newWall.end], this._config.config.styles, this._errorElement ? types_1.IElementStyleModes.ERROR : undefined);
1425
+ (0, draw_1.drawNewWall)(canvas, this.transformLineToCanvas([this._newWall.start, this._newWall.end]), this._config.config.styles, this._errorElement ? types_1.IElementStyleModes.ERROR : undefined);
1231
1426
  }
1232
1427
  };
1233
1428
  return RoomBuilderState;