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

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.
@@ -57,7 +57,8 @@ var useNestedConfigurator = function (address) {
57
57
  return;
58
58
  if (playerLoading)
59
59
  return;
60
- configurator.current = window.threekit.configurator.getNestedConfigurator([address].flat());
60
+ configurator.current =
61
+ window.threekit.treble.getNestedConfigurator(address);
61
62
  if (!configurator.current)
62
63
  return;
63
64
  var updatedAttrs = configurator.current.getDisplayAttributes();
@@ -10,32 +10,16 @@ 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;
18
13
  private _state;
19
14
  constructor(config: IRoomBuilderStateProps);
20
15
  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
- }[];
29
16
  set walls(walls: IWalls);
30
17
  get wallCount(): number;
31
18
  get wallLines(): ICoordinatesLine[];
32
19
  get vertices(): IVerticesState;
33
- get verticesToDraw(): IVerticesState;
34
20
  set vertices(vertices: IVerticesState);
35
21
  get verticesList(): Array<IVertex>;
36
- get verticesListToDraw(): Array<IVertex>;
37
22
  get features(): IFeatures;
38
- get featuresToDraw(): Record<string, IFeature[]>;
39
23
  set features(features: IFeatures);
40
24
  get getHydratedFeatures(): undefined | IFeaturesHydrated;
41
25
  get featureCount(): number;
@@ -46,27 +30,7 @@ export declare class RoomBuilderState {
46
30
  set showDimensions(val: boolean);
47
31
  get angleSnappingEnabled(): boolean;
48
32
  set angleSnappingEnabled(val: boolean);
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;
33
+ get enclosedSpaces(): Array<IEnclosedSpace>;
70
34
  private getWall;
71
35
  private addWall;
72
36
  private addWalls;
@@ -75,7 +39,7 @@ export declare class RoomBuilderState {
75
39
  private getWallConnectionsHydrated;
76
40
  private getWallDimensions;
77
41
  private getWallDetailedDimensions;
78
- private getAllWallDimensionsToDraw;
42
+ private getAllWallDimensions;
79
43
  private shiftAllFeaturesOnWall;
80
44
  private addFeatureToWall;
81
45
  private removeFeatureFromWall;
@@ -106,24 +70,23 @@ export declare class RoomBuilderState {
106
70
  private snapVertexToAbsoluteAngle;
107
71
  private getFeatureAtPoint;
108
72
  private getElementAtPoint;
109
- getClickedElement(cursorPoint: ICoordinate2D): undefined | IElementUi;
73
+ getClickedElement(point: ICoordinate2D): undefined | IElementUi;
110
74
  private getPointProximity;
111
75
  private reevaluateFeatureConnections;
112
76
  private pushStateToConfigurator;
113
77
  setAttributesToState(attributes?: Record<string, IHydratedAttribute>): void;
114
78
  deleteAll(): void;
115
79
  private resetInternalState;
116
- highlightElementIfInProximity(canvas: HTMLCanvasElement, cursorPoint: ICoordinate2D): void;
80
+ highlightElementIfInProximity(canvas: HTMLCanvasElement, point: ICoordinate2D): void;
117
81
  startDrawNewWall(startPoint: ICoordinate2D): void;
118
82
  drawNewWall(canvas: HTMLCanvasElement, endPoint: ICoordinate2D): void;
119
83
  cancelDrawNewWall(canvas: HTMLCanvasElement): void;
120
84
  finishDrawNewWall(canvas: HTMLCanvasElement, assetId: string): Promise<void>;
121
- drawNewWallGuides(canvas: HTMLCanvasElement, cursorPoint: ICoordinate2D): void;
122
85
  private moveActiveVertex;
123
86
  private finishMoveActiveVertex;
124
87
  private moveActiveFeature;
125
88
  private finishMoveActiveFeature;
126
- selectElementIfInProximity(canvas: HTMLCanvasElement, cursorPoint: ICoordinate2D): void;
89
+ selectElementIfInProximity(canvas: HTMLCanvasElement, point: ICoordinate2D): void;
127
90
  moveActiveElement(canvas: HTMLCanvasElement, moveToPoint: ICoordinate2D): void;
128
91
  finishMoveActiveElement(canvas: HTMLCanvasElement): void;
129
92
  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, _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);
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);
113
113
  break;
114
114
  }
115
115
  };
@@ -191,11 +191,6 @@ 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];
199
194
  }
200
195
  Object.defineProperty(RoomBuilderState.prototype, "walls", {
201
196
  get: function () {
@@ -207,14 +202,6 @@ var RoomBuilderState = (function () {
207
202
  enumerable: false,
208
203
  configurable: true
209
204
  });
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
- });
218
205
  Object.defineProperty(RoomBuilderState.prototype, "wallCount", {
219
206
  get: function () {
220
207
  return this.walls.length;
@@ -242,13 +229,6 @@ var RoomBuilderState = (function () {
242
229
  enumerable: false,
243
230
  configurable: true
244
231
  });
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
- });
252
232
  Object.defineProperty(RoomBuilderState.prototype, "verticesList", {
253
233
  get: function () {
254
234
  return Object.entries(this.vertices).map(function (_a) {
@@ -262,14 +242,6 @@ var RoomBuilderState = (function () {
262
242
  enumerable: false,
263
243
  configurable: true
264
244
  });
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
- });
273
245
  Object.defineProperty(RoomBuilderState.prototype, "features", {
274
246
  get: function () {
275
247
  return this._state[types_2.IElements.FEATURE];
@@ -280,20 +252,6 @@ var RoomBuilderState = (function () {
280
252
  enumerable: false,
281
253
  configurable: true
282
254
  });
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
- });
297
255
  Object.defineProperty(RoomBuilderState.prototype, "getHydratedFeatures", {
298
256
  get: function () {
299
257
  var _this = this;
@@ -358,7 +316,7 @@ var RoomBuilderState = (function () {
358
316
  enumerable: false,
359
317
  configurable: true
360
318
  });
361
- Object.defineProperty(RoomBuilderState.prototype, "enclosedSpacesToDraw", {
319
+ Object.defineProperty(RoomBuilderState.prototype, "enclosedSpaces", {
362
320
  get: function () {
363
321
  var _this = this;
364
322
  var loops = (0, findLoops_1.findLoops)(this.wallLines).inner;
@@ -367,7 +325,7 @@ var RoomBuilderState = (function () {
367
325
  var area = screenSpaceArea * Math.pow(_this._config.config.scale, 2);
368
326
  var convertedArea = (0, dataHandlers_1.convertAreaUnit)(area, types_1.IUnits.METER, _this._config.config.unit);
369
327
  var enclosedSpace = {
370
- loop: loop.map(function (point) { return _this.transformPointToCanvas(point); }),
328
+ loop: loop,
371
329
  area: (0, dataHandlers_1.prepAreaForUser)(convertedArea, _this._config.config.unit),
372
330
  center: loop.reduce(function (centerPoint, point) {
373
331
  centerPoint[0] += point[0] / loop.length;
@@ -375,7 +333,6 @@ var RoomBuilderState = (function () {
375
333
  return centerPoint;
376
334
  }, [0, 0]),
377
335
  };
378
- enclosedSpace.center = _this.transformPointToCanvas(enclosedSpace.center);
379
336
  output.push(enclosedSpace);
380
337
  return output;
381
338
  }, []);
@@ -383,145 +340,6 @@ var RoomBuilderState = (function () {
383
340
  enumerable: false,
384
341
  configurable: true
385
342
  });
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
- };
525
343
  RoomBuilderState.prototype.getWall = function (index) {
526
344
  return this.walls[index];
527
345
  };
@@ -624,11 +442,11 @@ var RoomBuilderState = (function () {
624
442
  }, []);
625
443
  return lines;
626
444
  };
627
- RoomBuilderState.prototype.getAllWallDimensionsToDraw = function (detailedWallsIndexes) {
445
+ RoomBuilderState.prototype.getAllWallDimensions = function (detailedWallsIndexes) {
628
446
  var _this = this;
629
447
  if (detailedWallsIndexes === void 0) { detailedWallsIndexes = []; }
630
448
  var indexes = new Set([detailedWallsIndexes].flat());
631
- var dimensionsList = this.walls.reduce(function (output, _, i) {
449
+ return this.walls.reduce(function (output, _, i) {
632
450
  var dimensions = indexes.has(i)
633
451
  ? _this.getWallDetailedDimensions(i)
634
452
  : _this.getWallDimensions(i);
@@ -640,7 +458,6 @@ var RoomBuilderState = (function () {
640
458
  output.push(dimensions);
641
459
  return output;
642
460
  }, []);
643
- return dimensionsList.map(function (dimension) { return (__assign(__assign({}, dimension), { line: _this.transformLineToCanvas(dimension.line) })); });
644
461
  };
645
462
  RoomBuilderState.prototype.shiftAllFeaturesOnWall = function (index, shift) {
646
463
  var _this = this;
@@ -805,8 +622,7 @@ var RoomBuilderState = (function () {
805
622
  if (!wall)
806
623
  return undefined;
807
624
  var line = (0, geometry_1.getParallelLineSegmentAtDistance)(wall.line, constants_1.UI_ANCHOR_DISTANCE);
808
- var point = (0, geometry_1.getMidpointOfLineSegment)(line);
809
- return this.transformPointToCanvas(point);
625
+ return (0, geometry_1.getMidpointOfLineSegment)(line);
810
626
  };
811
627
  RoomBuilderState.prototype.getVertex = function (index) {
812
628
  return this.verticesList[index];
@@ -878,7 +694,6 @@ var RoomBuilderState = (function () {
878
694
  });
879
695
  };
880
696
  RoomBuilderState.prototype.addFeature = function (type, feature, addToWallIndex) {
881
- var _a;
882
697
  var offset = undefined;
883
698
  var index = undefined;
884
699
  if (addToWallIndex !== undefined && feature.offset !== undefined) {
@@ -906,13 +721,13 @@ var RoomBuilderState = (function () {
906
721
  return;
907
722
  var newFeature = __assign(__assign({}, feature), { offset: offset, connectedTo: [types_2.IElements.WALL, index] });
908
723
  var newFeatureIndex;
909
- if ((_a = this._state[types_2.IElements.FEATURE][type]) === null || _a === void 0 ? void 0 : _a.length) {
910
- newFeatureIndex = this._state[types_2.IElements.FEATURE][type].length;
724
+ if (this._state[types_2.IElements.FEATURE][type]) {
911
725
  this._state[types_2.IElements.FEATURE][type].push(newFeature);
726
+ newFeatureIndex = this._state[types_2.IElements.FEATURE][type].length;
912
727
  }
913
728
  else {
914
729
  this._state[types_2.IElements.FEATURE][type] = [newFeature];
915
- newFeatureIndex = 0;
730
+ newFeatureIndex = 1;
916
731
  }
917
732
  this.addFeatureToWall(index, [type, newFeatureIndex]);
918
733
  this.pushStateToConfigurator();
@@ -946,8 +761,7 @@ var RoomBuilderState = (function () {
946
761
  if (!feature)
947
762
  return;
948
763
  var line = (0, geometry_1.getParallelLineSegmentAtDistance)(feature.line, constants_1.UI_ANCHOR_DISTANCE);
949
- var point = (0, geometry_1.getMidpointOfLineSegment)(line);
950
- return this.transformPointToCanvas(point);
764
+ return (0, geometry_1.getMidpointOfLineSegment)(line);
951
765
  };
952
766
  RoomBuilderState.prototype.deleteElement = function (type, index) {
953
767
  if (type === types_2.IElements.VERTEX)
@@ -958,11 +772,11 @@ var RoomBuilderState = (function () {
958
772
  this.deleteFeature(type, index);
959
773
  };
960
774
  RoomBuilderState.prototype.getVertexInProximity = function (point) {
775
+ var _this = this;
961
776
  if (!point)
962
777
  return undefined;
963
- var snapProximity = this.transformLengthFromCanvas(this._config.config.snapProximity);
964
778
  var index = this.verticesList.findIndex(function (vertex) {
965
- return (0, geometry_1.arePointsWithinProximity)(vertex.point, point, snapProximity);
779
+ return (0, geometry_1.arePointsWithinProximity)(vertex.point, point, _this._config.config.snapProximity);
966
780
  });
967
781
  if (index === -1)
968
782
  return undefined;
@@ -1020,17 +834,17 @@ var RoomBuilderState = (function () {
1020
834
  return __assign({ type: types_2.IElements.WALL, index: index }, intersection);
1021
835
  };
1022
836
  RoomBuilderState.prototype.snapPointToAbsoluteAngle = function (point, anchorPoint, angle) {
1023
- if (angle === void 0) { angle = 30; }
1024
- var snapProximity = this.transformLengthFromCanvas(this._config.config.snapProximity);
837
+ if (angle === void 0) { angle = 15; }
838
+ var snapProximity = this._config.config.snapProximity;
1025
839
  if (Math.abs(point[0] - anchorPoint[0]) < snapProximity) {
1026
840
  return {
1027
- type: types_1.SNAPPING_TYPES.ANGLE,
841
+ type: 'Angle',
1028
842
  point: [anchorPoint[0], point[1]],
1029
843
  };
1030
844
  }
1031
845
  else if (Math.abs(point[1] - anchorPoint[1]) < snapProximity) {
1032
846
  return {
1033
- type: types_1.SNAPPING_TYPES.ANGLE,
847
+ type: 'Angle',
1034
848
  point: [point[0], anchorPoint[1]],
1035
849
  };
1036
850
  }
@@ -1040,7 +854,7 @@ var RoomBuilderState = (function () {
1040
854
  var radians = degrees * (Math.PI / 180);
1041
855
  if ((0, geometry_1.getDistanceToLine)(anchorPoint, radians, point) < snapProximity)
1042
856
  return {
1043
- type: types_1.SNAPPING_TYPES.ANGLE,
857
+ type: 'Angle',
1044
858
  point: (0, geometry_1.closestPointOnLine)(anchorPoint, radians, point),
1045
859
  };
1046
860
  }
@@ -1051,7 +865,6 @@ var RoomBuilderState = (function () {
1051
865
  var vertex = this.getVertex(vertexIndex);
1052
866
  if (!vertex)
1053
867
  return undefined;
1054
- var snapProximity = this.transformLengthFromCanvas(this._config.config.snapProximity);
1055
868
  var point = vertex.connections.reduce(function (output, connection) {
1056
869
  var _a;
1057
870
  var line = (_a = _this.getWall(connection[0])) === null || _a === void 0 ? void 0 : _a.line;
@@ -1059,16 +872,16 @@ var RoomBuilderState = (function () {
1059
872
  return output;
1060
873
  var _b = output || updatedPoint, x = _b[0], y = _b[1];
1061
874
  var _c = line[connection[1] === 0 ? 1 : 0], xAnchor = _c[0], yAnchor = _c[1];
1062
- if (Math.abs(x - xAnchor) < snapProximity)
875
+ if (Math.abs(x - xAnchor) < _this._config.config.snapProximity)
1063
876
  return [xAnchor, y];
1064
- else if (Math.abs(y - yAnchor) < snapProximity)
877
+ else if (Math.abs(y - yAnchor) < _this._config.config.snapProximity)
1065
878
  return [x, yAnchor];
1066
879
  return output;
1067
880
  }, undefined);
1068
881
  if (!point)
1069
882
  return point;
1070
883
  return {
1071
- type: types_1.SNAPPING_TYPES.ANGLE,
884
+ type: 'Angle',
1072
885
  point: point,
1073
886
  };
1074
887
  };
@@ -1114,8 +927,7 @@ var RoomBuilderState = (function () {
1114
927
  return { type: types_2.IElements.WALL, index: wallInProximity };
1115
928
  return undefined;
1116
929
  };
1117
- RoomBuilderState.prototype.getClickedElement = function (cursorPoint) {
1118
- var point = this.transformPointFromCanvas(cursorPoint);
930
+ RoomBuilderState.prototype.getClickedElement = function (point) {
1119
931
  var element = this.getElementAtPoint(point);
1120
932
  if (!element)
1121
933
  return;
@@ -1162,6 +974,8 @@ var RoomBuilderState = (function () {
1162
974
  RoomBuilderState.prototype.setAttributesToState = function (attributes) {
1163
975
  if (!attributes)
1164
976
  return;
977
+ if (!attributes[this._config.attributes[types_2.IElements.WALL]])
978
+ return;
1165
979
  this._attributesState = attributes;
1166
980
  var data = (0, dataHandlers_1.prepAttributesIncoming)(attributes, this._config);
1167
981
  this.walls = data[types_2.IElements.WALL];
@@ -1182,9 +996,8 @@ var RoomBuilderState = (function () {
1182
996
  if (this._attributesState)
1183
997
  this.setAttributesToState(this._attributesState);
1184
998
  };
1185
- RoomBuilderState.prototype.highlightElementIfInProximity = function (canvas, cursorPoint) {
999
+ RoomBuilderState.prototype.highlightElementIfInProximity = function (canvas, point) {
1186
1000
  var _a, _b;
1187
- var point = this.transformPointFromCanvas(cursorPoint);
1188
1001
  var elementAtPoint = this.getElementAtPoint(point);
1189
1002
  if ((!elementAtPoint && !this._highlightedElement) ||
1190
1003
  Array.isArray(this._highlightedElement))
@@ -1200,14 +1013,13 @@ var RoomBuilderState = (function () {
1200
1013
  };
1201
1014
  RoomBuilderState.prototype.startDrawNewWall = function (startPoint) {
1202
1015
  var _a;
1203
- var point = this.transformPointFromCanvas(startPoint);
1204
- var snapPoint = this.getPointProximity(point);
1016
+ var snapPoint = this.getPointProximity(startPoint);
1205
1017
  if ((snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.type) === types_2.IElements.WINDOW ||
1206
1018
  (snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.type) === types_2.IElements.OPENING ||
1207
1019
  (snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.type) === types_2.IElements.DOOR)
1208
1020
  return;
1209
1021
  this._newWall = {
1210
- start: (_a = snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.point) !== null && _a !== void 0 ? _a : point,
1022
+ start: (_a = snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.point) !== null && _a !== void 0 ? _a : startPoint,
1211
1023
  snapStartTo: snapPoint,
1212
1024
  };
1213
1025
  };
@@ -1215,13 +1027,12 @@ var RoomBuilderState = (function () {
1215
1027
  var _a, _b, _c, _d, _e;
1216
1028
  if (!this._newWall)
1217
1029
  return;
1218
- var point = this.transformPointFromCanvas(endPoint);
1219
- var snapPoint = this.getPointProximity(point);
1030
+ var snapPoint = this.getPointProximity(endPoint);
1220
1031
  if (!snapPoint && this._angleSnappingEnabled)
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);
1032
+ 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);
1222
1033
  var wallLine = [
1223
1034
  this._newWall.start,
1224
- (_c = snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.point) !== null && _c !== void 0 ? _c : point,
1035
+ (_c = snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.point) !== null && _c !== void 0 ? _c : endPoint,
1225
1036
  ];
1226
1037
  var validationData = {
1227
1038
  walls: this.walls,
@@ -1246,7 +1057,7 @@ var RoomBuilderState = (function () {
1246
1057
  case types_1.IErrorTypes.WARN:
1247
1058
  case null:
1248
1059
  default:
1249
- this._newWall.end = (_e = snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.point) !== null && _e !== void 0 ? _e : point;
1060
+ this._newWall.end = (_e = snapPoint === null || snapPoint === void 0 ? void 0 : snapPoint.point) !== null && _e !== void 0 ? _e : endPoint;
1250
1061
  this._newWall.snapEndTo = snapPoint;
1251
1062
  this.drawRoom(canvas);
1252
1063
  break;
@@ -1307,6 +1118,8 @@ var RoomBuilderState = (function () {
1307
1118
  this.addWalls(newWallLines.map(function (line) { return ({
1308
1119
  assetId: assetId,
1309
1120
  line: line,
1121
+ height: 1,
1122
+ thickness: 0.6,
1310
1123
  connections: [],
1311
1124
  }); }));
1312
1125
  this._newWall = null;
@@ -1317,13 +1130,7 @@ var RoomBuilderState = (function () {
1317
1130
  });
1318
1131
  });
1319
1132
  };
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
+ RoomBuilderState.prototype.selectElementIfInProximity = function (canvas, point) {
1327
1134
  var elementAtPoint = this.getElementAtPoint(point);
1328
1135
  if (!elementAtPoint || elementAtPoint.type === types_2.IElements.WALL)
1329
1136
  return;
@@ -1342,14 +1149,13 @@ var RoomBuilderState = (function () {
1342
1149
  return;
1343
1150
  if (!this._activeElement)
1344
1151
  return;
1345
- var point = this.transformPointFromCanvas(moveToPoint);
1346
1152
  var type = this._activeElement.type;
1347
1153
  if (type === types_2.IElements.VERTEX)
1348
- this.moveActiveVertex(canvas, point);
1154
+ this.moveActiveVertex(canvas, moveToPoint);
1349
1155
  else if (type === types_2.IElements.WINDOW ||
1350
1156
  type === types_2.IElements.DOOR ||
1351
1157
  type === types_2.IElements.OPENING)
1352
- this.moveActiveFeature(canvas, point);
1158
+ this.moveActiveFeature(canvas, moveToPoint);
1353
1159
  };
1354
1160
  RoomBuilderState.prototype.finishMoveActiveElement = function (canvas) {
1355
1161
  if (!this._activeElement)
@@ -1418,11 +1224,11 @@ var RoomBuilderState = (function () {
1418
1224
  ((_c = this._activeElement) === null || _c === void 0 ? void 0 : _c.type) === types_2.IElements.DOOR ||
1419
1225
  ((_d = this._activeElement) === null || _d === void 0 ? void 0 : _d.type) === types_2.IElements.OPENING))
1420
1226
  activeWallIndex = (_e = this.getFeature(this._activeElement.type, this._activeElement.index)) === null || _e === void 0 ? void 0 : _e.connectedTo[1];
1421
- (0, draw_1.drawRoom)(canvas, this.enclosedSpacesToDraw, this.wallsToDraw, this.verticesListToDraw, this.featuresToDraw, this._showDimensions
1422
- ? this.getAllWallDimensionsToDraw(activeWallIndex)
1227
+ (0, draw_1.drawRoom)(canvas, this.enclosedSpaces, this.walls, this.verticesList, this.features, this._showDimensions
1228
+ ? this.getAllWallDimensions(activeWallIndex)
1423
1229
  : undefined, selection, this._config.config);
1424
1230
  if (((_f = this._newWall) === null || _f === void 0 ? void 0 : _f.start) && ((_g = this._newWall) === null || _g === void 0 ? void 0 : _g.end)) {
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
+ (0, draw_1.drawNewWall)(canvas, [this._newWall.start, this._newWall.end], this._config.config.styles, this._errorElement ? types_1.IElementStyleModes.ERROR : undefined);
1426
1232
  }
1427
1233
  };
1428
1234
  return RoomBuilderState;
@@ -1,37 +1,22 @@
1
- import { ICoordinate2D } from './types';
2
- export declare enum IRoomBuilderAttributes {
3
- WALLS = "_tkSpace_walls",
4
- WINDOWS = "_tkSpace_windows",
5
- DOORS = "_tkSpace_doors",
6
- OPENINGS = "_tkSpace_openings"
7
- }
8
1
  export declare enum IWallAttributes {
9
- START_X = "_tkSpace_startX",
10
- START_Y = "_tkSpace_startY",
11
- START_Z = "_tkSpace_startZ",
12
- END_X = "_tkSpace_endX",
13
- END_Y = "_tkSpace_endY",
14
- END_Z = "_tkSpace_endZ",
15
- CONNECTIONS = "_tkSpace_connections",
16
- WALL_HEIGHT = "_tkSpace_wallHeight",
17
- WALL_THICKNESS = "_tkSpace_wallThickness"
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"
18
9
  }
19
10
  export declare enum IFeatureAttribute {
20
- POSITION_X = "_tkSpace_offsetX",
21
- POSITION_Y = "_tkSpace_offsetY",
22
- POSITION_Z = "_tkSpace_offsetZ",
23
- CONNECTED_TO = "_tkSpace_connectedTo",
24
- FEATURE_HEIGHT = "_tkSpace_featureHeight",
25
- FEATURE_LENGTH = "_tkSpace_featureWidth"
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"
26
17
  }
27
18
  export declare const SCALE = 0.02;
28
- export declare const SNAP_PROXIMITY = 16;
29
- export declare const ZOOM_MAX = 100;
30
- export declare const ZOOM_MIN = 20;
31
- export declare const ZOOM_DEFAULT = 40;
32
- export declare const TRANSLATE_MAX: ICoordinate2D;
33
- export declare const TRANSLATE_MIN: ICoordinate2D;
34
- export declare const TRANSLATE_DEFAULT: ICoordinate2D;
19
+ export declare const SNAP_PROXIMITY = 10;
35
20
  export declare const MIN_WALL_LENGTH = 50;
36
21
  export declare const WALL_PADDING_FOR_FEATURE = 20;
37
22
  export declare const UNIT_LABELS: {