@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.
@@ -1,44 +1,29 @@
1
1
  "use strict";
2
2
  var _a, _b, _c;
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_DEFAULT = exports.ZOOM_MIN = exports.ZOOM_MAX = exports.SNAP_PROXIMITY = exports.SCALE = exports.IFeatureAttribute = exports.IWallAttributes = exports.IRoomBuilderAttributes = void 0;
4
+ exports.WALL_SNAP_DISTANCE = exports.UI_ANCHOR_DISTANCE = exports.FEATURE_LENGTH = exports.FEATURE_LABELS = exports.UNIT_FACTORS = exports.UNIT_LABELS = exports.WALL_PADDING_FOR_FEATURE = exports.MIN_WALL_LENGTH = exports.SNAP_PROXIMITY = exports.SCALE = exports.IFeatureAttribute = exports.IWallAttributes = void 0;
5
5
  var types_1 = require("./types");
6
- var IRoomBuilderAttributes;
7
- (function (IRoomBuilderAttributes) {
8
- IRoomBuilderAttributes["WALLS"] = "_tkSpace_walls";
9
- IRoomBuilderAttributes["WINDOWS"] = "_tkSpace_windows";
10
- IRoomBuilderAttributes["DOORS"] = "_tkSpace_doors";
11
- IRoomBuilderAttributes["OPENINGS"] = "_tkSpace_openings";
12
- })(IRoomBuilderAttributes = exports.IRoomBuilderAttributes || (exports.IRoomBuilderAttributes = {}));
13
6
  var IWallAttributes;
14
7
  (function (IWallAttributes) {
15
- IWallAttributes["START_X"] = "_tkSpace_startX";
16
- IWallAttributes["START_Y"] = "_tkSpace_startY";
17
- IWallAttributes["START_Z"] = "_tkSpace_startZ";
18
- IWallAttributes["END_X"] = "_tkSpace_endX";
19
- IWallAttributes["END_Y"] = "_tkSpace_endY";
20
- IWallAttributes["END_Z"] = "_tkSpace_endZ";
21
- IWallAttributes["CONNECTIONS"] = "_tkSpace_connections";
22
- IWallAttributes["WALL_HEIGHT"] = "_tkSpace_wallHeight";
23
- IWallAttributes["WALL_THICKNESS"] = "_tkSpace_wallThickness";
8
+ IWallAttributes["START_X"] = "Start X";
9
+ IWallAttributes["START_Z"] = "Start Z";
10
+ IWallAttributes["END_X"] = "End X";
11
+ IWallAttributes["END_Z"] = "End Z";
12
+ IWallAttributes["HEIGHT"] = "Height";
13
+ IWallAttributes["THICKNESS"] = "Thickness";
14
+ IWallAttributes["CONNECTIONS"] = "Connections";
24
15
  })(IWallAttributes = exports.IWallAttributes || (exports.IWallAttributes = {}));
25
16
  var IFeatureAttribute;
26
17
  (function (IFeatureAttribute) {
27
- IFeatureAttribute["POSITION_X"] = "_tkSpace_offsetX";
28
- IFeatureAttribute["POSITION_Y"] = "_tkSpace_offsetY";
29
- IFeatureAttribute["POSITION_Z"] = "_tkSpace_offsetZ";
30
- IFeatureAttribute["CONNECTED_TO"] = "_tkSpace_connectedTo";
31
- IFeatureAttribute["FEATURE_HEIGHT"] = "_tkSpace_featureHeight";
32
- IFeatureAttribute["FEATURE_LENGTH"] = "_tkSpace_featureWidth";
18
+ IFeatureAttribute["POSITION_X"] = "Start X";
19
+ IFeatureAttribute["POSITION_Y"] = "Start Y";
20
+ IFeatureAttribute["POSITION_Z"] = "Start Z";
21
+ IFeatureAttribute["HEIGHT"] = "Height";
22
+ IFeatureAttribute["LENGTH"] = "Length";
23
+ IFeatureAttribute["CONNECTED_TO"] = "Connected To";
33
24
  })(IFeatureAttribute = exports.IFeatureAttribute || (exports.IFeatureAttribute = {}));
34
25
  exports.SCALE = 0.02;
35
- exports.SNAP_PROXIMITY = 16;
36
- exports.ZOOM_MAX = 100;
37
- exports.ZOOM_MIN = 20;
38
- exports.ZOOM_DEFAULT = 40;
39
- exports.TRANSLATE_MAX = [-400, -400];
40
- exports.TRANSLATE_MIN = [400, 400];
41
- exports.TRANSLATE_DEFAULT = [-200, -200];
26
+ exports.SNAP_PROXIMITY = 10;
42
27
  exports.MIN_WALL_LENGTH = 50;
43
28
  exports.WALL_PADDING_FOR_FEATURE = 20;
44
29
  exports.UNIT_LABELS = (_a = {},
@@ -51,8 +51,8 @@ function prepWallsAndVerticesIncoming(wallsAttribute, config) {
51
51
  assetId: assetId,
52
52
  line: [point1, point2],
53
53
  path: (0, geometry_1.addThicknessToLine)([point1, point2], config.config.styles.wall.thickness),
54
- height: configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IWallAttributes.WALL_HEIGHT],
55
- thickness: configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IWallAttributes.WALL_THICKNESS],
54
+ height: configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IWallAttributes.HEIGHT],
55
+ thickness: configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IWallAttributes.THICKNESS],
56
56
  connections: connections,
57
57
  });
58
58
  });
@@ -64,7 +64,7 @@ function prepFeatureIncoming(walls, featureAttribute, config) {
64
64
  (_a = featureAttribute === null || featureAttribute === void 0 ? void 0 : featureAttribute.value) === null || _a === void 0 ? void 0 : _a.forEach(function (_a) {
65
65
  var assetId = _a.assetId, configuration = _a.configuration;
66
66
  var offset = (configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IFeatureAttribute.POSITION_X]) / config.config.scale;
67
- var length = (configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IFeatureAttribute.FEATURE_LENGTH]) / config.config.scale ||
67
+ var length = (configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IFeatureAttribute.LENGTH]) / config.config.scale ||
68
68
  constants_1.FEATURE_LENGTH;
69
69
  var connectedTo = (configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IFeatureAttribute.CONNECTED_TO]) || '';
70
70
  var wallIndex = prepConnectionIncoming(connectedTo)[1];
@@ -100,7 +100,7 @@ function prepFeaturesOutgoing(features, config) {
100
100
  feature.connectedTo[1],
101
101
  ]);
102
102
  var configuration = Object.entries((_a = {},
103
- _a[constants_1.IFeatureAttribute.FEATURE_LENGTH] = length,
103
+ _a[constants_1.IFeatureAttribute.LENGTH] = length,
104
104
  _a[constants_1.IFeatureAttribute.POSITION_X] = offset,
105
105
  _a)).reduce(function (output, _a) {
106
106
  var _b;
@@ -133,8 +133,8 @@ function prepWallsOutgoing(walls, config) {
133
133
  _a[constants_1.IWallAttributes.START_Z] = y1,
134
134
  _a[constants_1.IWallAttributes.END_X] = x2,
135
135
  _a[constants_1.IWallAttributes.END_Z] = y2,
136
- _a[constants_1.IWallAttributes.WALL_HEIGHT] = height,
137
- _a[constants_1.IWallAttributes.WALL_THICKNESS] = thickness,
136
+ _a[constants_1.IWallAttributes.HEIGHT] = height,
137
+ _a[constants_1.IWallAttributes.THICKNESS] = thickness,
138
138
  _a)).reduce(function (output, _a) {
139
139
  var _b;
140
140
  var key = _a[0], value = _a[1];
@@ -36,8 +36,8 @@ function drawGrid(canvas, styles) {
36
36
  if (!ctx)
37
37
  return;
38
38
  ctx.strokeStyle = styles.lineColor;
39
- var numHorizontalLines = Math.ceil(canvas.height / styles.gridStepGap);
40
- var numVerticalLines = Math.ceil(canvas.width / styles.gridStepGap);
39
+ var numHorizontalLines = Math.ceil(canvas.width / styles.gridStepGap);
40
+ var numVerticalLines = Math.ceil(canvas.height / styles.gridStepGap);
41
41
  for (var i = 0; i < numHorizontalLines; i++) {
42
42
  var y = i * styles.gridStepGap;
43
43
  ctx.lineWidth =
@@ -1,11 +1,9 @@
1
1
  import React from 'react';
2
2
  import type { IHydratedAttributeArray } from '../../types';
3
- import type { ICoordinate2D, IElementName, IElementPublic, IRoomBuilderHookProps } from './types';
3
+ import type { IElementName, IElementPublic, IRoomBuilderHookProps } from './types';
4
4
  import { IModes, IUnits, IElements } from './types';
5
5
  import { IThemes } from './themes';
6
- import RoomBuilderLayout from './RoomBuilderLayout';
7
6
  interface IUseRoomBuilder {
8
- drawRoom: () => void;
9
7
  canvasRef: React.RefObject<HTMLCanvasElement>;
10
8
  [IElements.WALL]?: IHydratedAttributeArray;
11
9
  [IElements.WINDOW]?: IHydratedAttributeArray;
@@ -22,15 +20,6 @@ interface IUseRoomBuilder {
22
20
  enabled: boolean;
23
21
  handleToggle: (val?: boolean) => void;
24
22
  };
25
- zoom: {
26
- min: number;
27
- max: number;
28
- value: number;
29
- handleChange: (value: number) => void;
30
- };
31
- translate: {
32
- handleChange: (delta: ICoordinate2D) => void;
33
- };
34
23
  mode: {
35
24
  value: IModes;
36
25
  options: Array<{
@@ -41,17 +30,11 @@ interface IUseRoomBuilder {
41
30
  }>;
42
31
  handleChange: (mode: IModes) => void;
43
32
  };
44
- layouts: Array<{
45
- label: string;
46
- loops: Array<ICoordinate2D[]>;
47
- handleSelect: () => void;
48
- }>;
49
33
  }
50
34
  declare const useRoomBuilder: {
51
35
  (props: IRoomBuilderHookProps): IUseRoomBuilder;
52
36
  themes: typeof IThemes;
53
37
  units: typeof IUnits;
54
38
  modes: typeof IModes;
55
- LayoutIcon: typeof RoomBuilderLayout;
56
39
  };
57
40
  export default useRoomBuilder;
@@ -43,82 +43,46 @@ var useConfigurator_1 = __importDefault(require("../useConfigurator"));
43
43
  var RoomBuilderState_1 = __importDefault(require("./RoomBuilderState"));
44
44
  var constants_1 = require("./constants");
45
45
  var themes_1 = __importStar(require("./themes"));
46
- var RoomBuilderLayout_1 = __importDefault(require("./RoomBuilderLayout"));
47
- var store_1 = require("../../store");
48
- var roomBuilder_1 = require("../../store/roomBuilder");
49
- var useThreekitInitStatus_1 = __importDefault(require("../useThreekitInitStatus"));
50
46
  var useRoomBuilder = function (props) {
51
47
  var _a;
52
- var _b;
53
48
  var attributesState = (0, useConfigurator_1.default)()[0];
54
- var hasLoaded = (0, useThreekitInitStatus_1.default)();
55
- var dispatch = (0, store_1.useThreekitDispatch)();
56
- var layouts = (0, store_1.useThreekitSelector)(roomBuilder_1.getLayouts);
57
- var zoom = (0, store_1.useThreekitSelector)(roomBuilder_1.getZoom);
58
- var translation = (0, store_1.useThreekitSelector)(roomBuilder_1.getTranslation);
59
- var modeValue = (0, store_1.useThreekitSelector)(roomBuilder_1.getMode);
60
- var showDimensions = (0, store_1.useThreekitSelector)(roomBuilder_1.getShowDimensions);
61
- var angleSnappingEnabled = (0, store_1.useThreekitSelector)(roomBuilder_1.getAngleSnappingEnabled);
62
- var _c = (0, react_1.useState)(null), selectedElement = _c[0], setSelectedElement = _c[1];
63
- var _d = (0, react_1.useState)(null), selectedWallAsset = _d[0], setSelectedWallAsset = _d[1];
49
+ var _b = (0, react_1.useState)(types_1.IModes.DRAW), modeValue = _b[0], setMode = _b[1];
50
+ var _c = (0, react_1.useState)(true), showDimensions = _c[0], setShowDimensions = _c[1];
51
+ var _d = (0, react_1.useState)(true), angleSnappingEnabled = _d[0], setAngleSnappingEnabled = _d[1];
52
+ var _e = (0, react_1.useState)(null), selectedElement = _e[0], setSelectedElement = _e[1];
53
+ var _f = (0, react_1.useState)(null), selectedWallAsset = _f[0], setSelectedWallAsset = _f[1];
64
54
  var canvasRef = (0, react_1.useRef)(null);
65
55
  var selectElementPending = (0, react_1.useRef)(null);
66
- var translationAnchorRef = (0, react_1.useRef)(null);
67
56
  var preppedConfig = Object.assign({
68
57
  scale: constants_1.SCALE,
69
58
  unit: types_1.IUnits.FEET,
70
59
  snapProximity: constants_1.SNAP_PROXIMITY,
71
- zoomDefault: zoom || constants_1.ZOOM_DEFAULT,
72
- translateDefault: translation || constants_1.TRANSLATE_DEFAULT,
73
- styles: ((_b = props.config) === null || _b === void 0 ? void 0 : _b.theme) && themes_1.default[props.config.theme]
60
+ styles: ((_a = props.config) === null || _a === void 0 ? void 0 : _a.theme) && themes_1.default[props.config.theme]
74
61
  ? themes_1.default[props.config.theme]
75
62
  : themes_1.default[themes_1.IThemes.DEFAULT],
76
63
  }, props.config);
77
- var attributeNames = Object.assign((_a = {},
78
- _a[types_1.IElements.WALL] = constants_1.IRoomBuilderAttributes.WALLS,
79
- _a[types_1.IElements.WINDOW] = constants_1.IRoomBuilderAttributes.WINDOWS,
80
- _a[types_1.IElements.OPENING] = constants_1.IRoomBuilderAttributes.OPENINGS,
81
- _a[types_1.IElements.DOOR] = constants_1.IRoomBuilderAttributes.DOORS,
82
- _a), props.attributes);
83
- var roomBuilderRef = (0, react_1.useRef)(new RoomBuilderState_1.default(__assign(__assign({}, props), { config: preppedConfig, attributes: attributeNames })));
64
+ var roomBuilderRef = (0, react_1.useRef)(new RoomBuilderState_1.default(__assign(__assign({}, props), { config: preppedConfig })));
84
65
  var drawRoom = function () { return roomBuilderRef.current.drawRoom(canvasRef.current); };
85
66
  (0, react_1.useEffect)(function () {
86
67
  var _a;
87
- if (!selectedWallAsset && (attributesState === null || attributesState === void 0 ? void 0 : attributesState[attributeNames[types_1.IElements.WALL]]))
88
- setSelectedWallAsset(((_a = attributesState === null || attributesState === void 0 ? void 0 : attributesState[attributeNames[types_1.IElements.WALL]]) === null || _a === void 0 ? void 0 : _a.values[0].assetId) || null);
68
+ if (!selectedWallAsset &&
69
+ (attributesState === null || attributesState === void 0 ? void 0 : attributesState[props.attributes[types_1.IElements.WALL]]))
70
+ setSelectedWallAsset(((_a = attributesState === null || attributesState === void 0 ? void 0 : attributesState[props.attributes[types_1.IElements.WALL]]) === null || _a === void 0 ? void 0 : _a.values[0].assetId) || null);
89
71
  var attributesDelinked = JSON.parse(JSON.stringify(attributesState));
90
72
  roomBuilderRef.current.setAttributesToState(attributesDelinked);
91
73
  drawRoom();
92
74
  }, [attributesState]);
93
75
  (0, react_1.useEffect)(function () {
94
- var _a;
95
- if (zoom &&
96
- ((_a = props.config) === null || _a === void 0 ? void 0 : _a.zoomDefault) &&
97
- props.config.zoomDefault >= roomBuilderRef.current.zoomMin &&
98
- roomBuilderRef.current.zoomMax >= props.config.zoomDefault)
99
- updateZoom(props.config.zoomDefault);
100
- }, []);
101
- (0, react_1.useEffect)(function () {
102
- var _a, _b;
103
76
  if (canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current) {
104
- roomBuilderRef.current.canvasDimensions = [
105
- canvasRef.current.width,
106
- canvasRef.current.height,
107
- ];
108
77
  canvasRef.current.addEventListener('mousedown', handleDrawWallStart);
109
78
  canvasRef.current.addEventListener('mousemove', handleDrawWallMouseMove);
110
79
  document.addEventListener('mouseup', handleDrawWallFinish);
111
80
  canvasRef.current.addEventListener('mousemove', handleSelectModeHover);
112
81
  canvasRef.current.addEventListener('mousedown', handleSelectElement);
113
82
  canvasRef.current.addEventListener('mousemove', handleMoveSelectedElement);
114
- if (!((_a = props.config) === null || _a === void 0 ? void 0 : _a.translateDisabled))
115
- canvasRef.current.addEventListener('mousemove', handleMoveCanvas);
116
83
  document.addEventListener('mouseup', handleSetSelectedElement);
117
- if (!((_b = props.config) === null || _b === void 0 ? void 0 : _b.zoomDisabled))
118
- canvasRef.current.addEventListener('wheel', handleScrollToZoom);
119
84
  }
120
85
  return function () {
121
- var _a, _b;
122
86
  if (canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current) {
123
87
  canvasRef.current.removeEventListener('mousedown', handleDrawWallStart);
124
88
  canvasRef.current.removeEventListener('mousemove', handleDrawWallMouseMove);
@@ -126,11 +90,7 @@ var useRoomBuilder = function (props) {
126
90
  canvasRef.current.removeEventListener('mousemove', handleSelectModeHover);
127
91
  canvasRef.current.removeEventListener('mousedown', handleSelectElement);
128
92
  canvasRef.current.removeEventListener('mousemove', handleMoveSelectedElement);
129
- if (!((_a = props.config) === null || _a === void 0 ? void 0 : _a.translateDisabled))
130
- canvasRef.current.removeEventListener('mousemove', handleMoveCanvas);
131
93
  document.removeEventListener('mouseup', handleSetSelectedElement);
132
- if (!((_b = props.config) === null || _b === void 0 ? void 0 : _b.zoomDisabled))
133
- canvasRef.current.removeEventListener('wheel', handleScrollToZoom);
134
94
  }
135
95
  };
136
96
  });
@@ -145,30 +105,6 @@ var useRoomBuilder = function (props) {
145
105
  : null;
146
106
  drawRoom();
147
107
  }, [selectedElement, showDimensions, angleSnappingEnabled]);
148
- (0, react_1.useEffect)(function () {
149
- if (!hasLoaded)
150
- return;
151
- var layoutIds = props.layouts || [];
152
- dispatch((0, roomBuilder_1.hydrateLayouts)(layoutIds, {
153
- walls: attributeNames[types_1.IElements.WALL],
154
- startX: constants_1.IWallAttributes.START_X,
155
- startZ: constants_1.IWallAttributes.START_Z,
156
- endX: constants_1.IWallAttributes.END_X,
157
- endZ: constants_1.IWallAttributes.END_Z,
158
- }));
159
- }, [hasLoaded, JSON.stringify(props.layouts)]);
160
- var updateZoom = function (value) {
161
- var newZoom = roomBuilderRef.current.setZoom(value);
162
- if (!newZoom)
163
- return;
164
- dispatch((0, roomBuilder_1.setZoom)(newZoom));
165
- drawRoom();
166
- };
167
- var handleScrollToZoom = function (e) {
168
- if (!canvasRef.current)
169
- return;
170
- updateZoom(e.deltaY);
171
- };
172
108
  var handleSelectModeHover = function (e) {
173
109
  if (!canvasRef.current)
174
110
  return;
@@ -176,22 +112,16 @@ var useRoomBuilder = function (props) {
176
112
  return;
177
113
  if (roomBuilderRef.current.activeElement !== null)
178
114
  return;
179
- if (translationAnchorRef.current)
180
- return;
181
115
  var cursorPoint = [e.offsetX, e.offsetY];
182
116
  roomBuilderRef.current.highlightElementIfInProximity(canvasRef.current, cursorPoint);
183
117
  };
184
118
  var handleSelectElement = function (e) {
185
- var _a;
186
119
  if (!canvasRef.current)
187
120
  return;
188
121
  if (modeValue !== types_1.IModes.SELECT)
189
122
  return;
190
123
  var cursorPoint = [e.offsetX, e.offsetY];
191
124
  roomBuilderRef.current.selectElementIfInProximity(canvasRef.current, cursorPoint);
192
- if (!((_a = props.config) === null || _a === void 0 ? void 0 : _a.translateDisabled) &&
193
- !roomBuilderRef.current.activeElement)
194
- translationAnchorRef.current = cursorPoint;
195
125
  var element = roomBuilderRef.current.getClickedElement(cursorPoint);
196
126
  if (!element) {
197
127
  if (selectedElement !== null)
@@ -213,20 +143,6 @@ var useRoomBuilder = function (props) {
213
143
  roomBuilderRef.current.moveActiveElement(canvasRef.current, point);
214
144
  selectElementPending.current = null;
215
145
  };
216
- var handleMoveCanvas = function (e) {
217
- if (modeValue !== types_1.IModes.SELECT)
218
- return;
219
- if (!canvasRef.current)
220
- return;
221
- if (roomBuilderRef.current.selectedElement || !translationAnchorRef.current)
222
- return;
223
- var delta = [
224
- e.offsetX - translationAnchorRef.current[0],
225
- e.offsetY - translationAnchorRef.current[1],
226
- ];
227
- handleChangeTranslate(delta);
228
- translationAnchorRef.current = [e.offsetX, e.offsetY];
229
- };
230
146
  var handleSetSelectedElement = function (e) {
231
147
  var _a;
232
148
  if (modeValue !== types_1.IModes.SELECT)
@@ -241,10 +157,7 @@ var useRoomBuilder = function (props) {
241
157
  if (selectElementPending.current) {
242
158
  setSelectedElement(selectElementPending.current);
243
159
  selectElementPending.current = null;
244
- return;
245
160
  }
246
- if (translationAnchorRef.current)
247
- translationAnchorRef.current = null;
248
161
  };
249
162
  var handleDrawWallStart = function (e) {
250
163
  if (modeValue !== types_1.IModes.DRAW)
@@ -258,8 +171,7 @@ var useRoomBuilder = function (props) {
258
171
  if (!canvasRef.current)
259
172
  return;
260
173
  var cursorPoint = [e.offsetX, e.offsetY];
261
- if (roomBuilderRef.current.isDrawWallActive)
262
- roomBuilderRef.current.drawNewWall(canvasRef.current, cursorPoint);
174
+ roomBuilderRef.current.drawNewWall(canvasRef.current, cursorPoint);
263
175
  };
264
176
  var handleDrawWallFinish = function (e) {
265
177
  var _a;
@@ -292,14 +204,14 @@ var useRoomBuilder = function (props) {
292
204
  if (!attribute)
293
205
  return undefined;
294
206
  var values = attribute.values.map(function (val) { return (__assign(__assign({}, val), { selected: val.assetId === selectedWallAsset, selectToDraw: function () {
295
- dispatch((0, roomBuilder_1.setMode)(types_1.IModes.DRAW));
207
+ setMode(types_1.IModes.DRAW);
296
208
  setSelectedWallAsset(val.assetId);
297
209
  } })); });
298
210
  var value = attribute.value.map(function (val, i) { return (__assign(__assign({}, val), { delete: function () { var _a; return (_a = roomBuilderRef.current) === null || _a === void 0 ? void 0 : _a.deleteWall(i); } })); });
299
211
  return __assign(__assign({}, attribute), { values: values, value: value });
300
212
  };
301
213
  var getElementFromAttributeName = function (attributeName) {
302
- var elementAttr = Object.entries(attributeNames).find(function (_a) {
214
+ var elementAttr = Object.entries(props.attributes).find(function (_a) {
303
215
  var _ = _a[0], attrName = _a[1];
304
216
  return attrName === attributeName;
305
217
  });
@@ -311,7 +223,7 @@ var useRoomBuilder = function (props) {
311
223
  if (mode === modeValue)
312
224
  return;
313
225
  drawRoom();
314
- dispatch((0, roomBuilder_1.setMode)(mode));
226
+ setMode(mode);
315
227
  setSelectedElement(null);
316
228
  };
317
229
  var handleReset = function () {
@@ -322,7 +234,7 @@ var useRoomBuilder = function (props) {
322
234
  var handleDeleteElement = function (type, index) {
323
235
  var _a;
324
236
  var elementType = type;
325
- if (Object.values(attributeNames).includes(type)) {
237
+ if (Object.values(props.attributes).includes(type)) {
326
238
  var updatedType = getElementFromAttributeName(type);
327
239
  if (!updatedType)
328
240
  return;
@@ -333,38 +245,29 @@ var useRoomBuilder = function (props) {
333
245
  };
334
246
  var handleToggleDimensions = function (val) {
335
247
  if (val === undefined)
336
- dispatch((0, roomBuilder_1.setShowDimensions)(!showDimensions));
248
+ setShowDimensions(!showDimensions);
337
249
  else
338
- dispatch((0, roomBuilder_1.setShowDimensions)(val));
250
+ setShowDimensions(val);
339
251
  setSelectedElement(null);
340
252
  };
341
253
  var handleToggleAngleSnapping = function (val) {
342
254
  if (val === undefined)
343
- dispatch((0, roomBuilder_1.setAngleSnappingEnabled)(!angleSnappingEnabled));
255
+ setAngleSnappingEnabled(!angleSnappingEnabled);
344
256
  else
345
- dispatch((0, roomBuilder_1.setAngleSnappingEnabled)(val));
257
+ setAngleSnappingEnabled(val);
346
258
  setSelectedElement(null);
347
259
  };
348
- var handleChangeTranslate = function (delta) {
349
- roomBuilderRef.current.translate = [
350
- roomBuilderRef.current.translate[0] + delta[0],
351
- roomBuilderRef.current.translate[1] + delta[1],
352
- ];
353
- dispatch((0, roomBuilder_1.setTranslation)(roomBuilderRef.current.translate));
354
- drawRoom();
355
- };
356
260
  return {
357
- drawRoom: drawRoom,
358
261
  canvasRef: canvasRef,
359
262
  selectedElement: selectedElement === null
360
263
  ? selectedElement
361
264
  : __assign(__assign({}, selectedElement), { path: [
362
- attributeNames[selectedElement.path[0]],
265
+ props.attributes[selectedElement.path[0]],
363
266
  selectedElement.path[1],
364
- ], type: selectedElement.path[0] }),
267
+ ] }),
365
268
  mode: {
366
269
  value: modeValue,
367
- options: [types_1.IModes.SELECT, types_1.IModes.DRAW].map(function (el) { return ({
270
+ options: [types_1.IModes.DRAW, types_1.IModes.SELECT].map(function (el) { return ({
368
271
  value: el,
369
272
  label: el,
370
273
  selected: modeValue === el,
@@ -380,32 +283,21 @@ var useRoomBuilder = function (props) {
380
283
  enabled: angleSnappingEnabled,
381
284
  handleToggle: handleToggleAngleSnapping,
382
285
  },
383
- zoom: {
384
- min: roomBuilderRef.current.zoomMin,
385
- max: roomBuilderRef.current.zoomMax,
386
- value: zoom || constants_1.ZOOM_DEFAULT,
387
- handleChange: updateZoom,
388
- },
389
- translate: {
390
- handleChange: handleChangeTranslate,
391
- },
392
286
  reset: handleReset,
393
287
  deleteElement: handleDeleteElement,
394
- layouts: layouts.map(function (layout) { return ({
395
- label: layout.label,
396
- loops: layout.loop,
397
- handleSelect: function () {
398
- return window.threekit.configurator.setFullConfiguration(layout.configuration);
399
- },
400
- }); }),
401
- walls: prepWallAttributeForOutput(attributesState === null || attributesState === void 0 ? void 0 : attributesState[attributeNames[types_1.IElements.WALL]]),
402
- windows: prepFeatureAttributeForOutput(types_1.IElements.WINDOW, attributesState === null || attributesState === void 0 ? void 0 : attributesState[attributeNames[types_1.IElements.WINDOW]]),
403
- doors: prepFeatureAttributeForOutput(types_1.IElements.DOOR, attributesState === null || attributesState === void 0 ? void 0 : attributesState[attributeNames[types_1.IElements.DOOR]]),
404
- openings: prepFeatureAttributeForOutput(types_1.IElements.OPENING, attributesState === null || attributesState === void 0 ? void 0 : attributesState[attributeNames[types_1.IElements.OPENING]]),
288
+ walls: prepWallAttributeForOutput(attributesState === null || attributesState === void 0 ? void 0 : attributesState[props.attributes[types_1.IElements.WALL]]),
289
+ windows: props.attributes[types_1.IElements.WINDOW]
290
+ ? prepFeatureAttributeForOutput(types_1.IElements.WINDOW, attributesState === null || attributesState === void 0 ? void 0 : attributesState[props.attributes[types_1.IElements.WINDOW]])
291
+ : undefined,
292
+ doors: props.attributes[types_1.IElements.DOOR]
293
+ ? prepFeatureAttributeForOutput(types_1.IElements.DOOR, attributesState === null || attributesState === void 0 ? void 0 : attributesState[props.attributes[types_1.IElements.DOOR]])
294
+ : undefined,
295
+ openings: props.attributes[types_1.IElements.OPENING]
296
+ ? prepFeatureAttributeForOutput(types_1.IElements.OPENING, attributesState === null || attributesState === void 0 ? void 0 : attributesState[props.attributes[types_1.IElements.OPENING]])
297
+ : undefined,
405
298
  };
406
299
  };
407
300
  useRoomBuilder.themes = themes_1.IThemes;
408
301
  useRoomBuilder.units = types_1.IUnits;
409
302
  useRoomBuilder.modes = types_1.IModes;
410
- useRoomBuilder.LayoutIcon = RoomBuilderLayout_1.default;
411
303
  exports.default = useRoomBuilder;
@@ -157,9 +157,6 @@ export interface IRoomBuilderThemePartial {
157
157
  vertex: Partial<IStylesVertex>;
158
158
  feature: Partial<IStylesFeature>;
159
159
  }
160
- export declare enum SNAPPING_TYPES {
161
- ANGLE = "angle"
162
- }
163
160
  export interface IElementAddress {
164
161
  type: IElementName;
165
162
  index: number;
@@ -180,7 +177,7 @@ export interface ISnapPointWall extends ISnapPointShared<IElements.WALL> {
180
177
  }
181
178
  export interface ISnapPointFeature extends ISnapPointShared<IFeatureName> {
182
179
  }
183
- export interface ISnapPointAngle extends Omit<ISnapPointShared<SNAPPING_TYPES.ANGLE>, 'index'> {
180
+ export interface ISnapPointAngle extends Omit<ISnapPointShared<'Angle'>, 'index'> {
184
181
  }
185
182
  export declare type ISnapPoint = ISnapPointVertex | ISnapPointWall | ISnapPointFeature | ISnapPointAngle;
186
183
  export interface IActiveElement extends IElementAddress {
@@ -202,7 +199,6 @@ export interface IElementUi {
202
199
  }
203
200
  export interface IElementPublic extends Pick<IElementUi, 'uiAnchor'> {
204
201
  path: [attribute: string, index: number];
205
- type: IFeatureName | IElements.WALL;
206
202
  }
207
203
  export declare enum IModes {
208
204
  SELECT = "select",
@@ -219,15 +215,11 @@ export interface IRoomBuilderConfigShared<T> {
219
215
  unit: IUnits;
220
216
  snapProximity: number;
221
217
  styles: T;
222
- zoomDefault: number;
223
- translateDefault: ICoordinate2D;
224
218
  }
225
219
  export interface IRoomBuilderConfigInternal extends IRoomBuilderConfigShared<IRoomBuilderStyles> {
226
220
  }
227
221
  export interface IRoomBuilderConfigUser extends IRoomBuilderConfigShared<Partial<IRoomBuilderStyles>> {
228
- theme: string;
229
- zoomDisabled: boolean;
230
- translateDisabled: boolean;
222
+ theme?: string;
231
223
  }
232
224
  export interface IRoomBuilderAttributes {
233
225
  [IElements.WALL]: string;
@@ -238,7 +230,6 @@ export interface IRoomBuilderAttributes {
238
230
  interface IRoomBuilderPropsShared<T> {
239
231
  config: T;
240
232
  attributes: IRoomBuilderAttributes;
241
- layouts?: Array<string>;
242
233
  }
243
234
  export interface IRoomBuilderHookProps extends IRoomBuilderPropsShared<undefined | Partial<IRoomBuilderConfigUser>> {
244
235
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IUnits = exports.IModes = exports.IErrorTypes = exports.SNAPPING_TYPES = exports.IElementStyleModes = exports.IElements = void 0;
3
+ exports.IUnits = exports.IModes = exports.IErrorTypes = exports.IElementStyleModes = exports.IElements = void 0;
4
4
  var IElements;
5
5
  (function (IElements) {
6
6
  IElements["WALL"] = "walls";
@@ -16,10 +16,6 @@ var IElementStyleModes;
16
16
  IElementStyleModes["ACTIVE"] = "active";
17
17
  IElementStyleModes["ERROR"] = "error";
18
18
  })(IElementStyleModes = exports.IElementStyleModes || (exports.IElementStyleModes = {}));
19
- var SNAPPING_TYPES;
20
- (function (SNAPPING_TYPES) {
21
- SNAPPING_TYPES["ANGLE"] = "angle";
22
- })(SNAPPING_TYPES = exports.SNAPPING_TYPES || (exports.SNAPPING_TYPES = {}));
23
19
  var IErrorTypes;
24
20
  (function (IErrorTypes) {
25
21
  IErrorTypes["HARD"] = "hard";
@@ -10,10 +10,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.Draw = void 0;
11
11
  var react_1 = __importDefault(require("react"));
12
12
  var styled_components_1 = __importDefault(require("styled-components"));
13
- var Path = styled_components_1.default.path(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n fill: ", ";\n"], ["\n fill: ", ";\n"])), function (props) { return props.color || props.theme.textColor; });
13
+ var SVG = styled_components_1.default.svg(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n .tk-icon {\n fill: ", ";\n }\n"], ["\n .tk-icon {\n fill: ", ";\n }\n"])), function (props) { return props.color || props.theme.textColor; });
14
14
  var Draw = function (props) {
15
- return (react_1.default.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
16
- react_1.default.createElement(Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M3.74417 0.637287C4.59388 -0.212428 5.97154 -0.21243 6.82126 0.637287L19.3627 13.1787C19.7708 13.5868 20 14.1402 20 14.7173V20H14.7173C14.1402 20 13.5868 19.7708 13.1787 19.3627L0.637287 6.82126C-0.21243 5.97154 -0.21243 4.59388 0.637286 3.74417L3.74417 0.637287ZM5.50251 1.95604C5.38112 1.83465 5.18431 1.83465 5.06292 1.95604L1.95604 5.06292C1.83465 5.18431 1.83465 5.38112 1.95604 5.50251L4.20155 7.74802L7.74802 4.20155L5.50251 1.95604ZM9.06677 5.52031L18.044 14.4975C18.1023 14.5558 18.135 14.6348 18.135 14.7173V18.135H14.7173C14.6348 18.135 14.5558 18.1023 14.4975 18.044L5.52031 9.06677L9.06677 5.52031Z", color: props.color })));
15
+ return (react_1.default.createElement(SVG, { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", color: props.color },
16
+ react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M3.74417 0.637287C4.59388 -0.212428 5.97154 -0.21243 6.82126 0.637287L19.3627 13.1787C19.7708 13.5868 20 14.1402 20 14.7173V20H14.7173C14.1402 20 13.5868 19.7708 13.1787 19.3627L0.637287 6.82126C-0.21243 5.97154 -0.21243 4.59388 0.637286 3.74417L3.74417 0.637287ZM5.50251 1.95604C5.38112 1.83465 5.18431 1.83465 5.06292 1.95604L1.95604 5.06292C1.83465 5.18431 1.83465 5.38112 1.95604 5.50251L4.20155 7.74802L7.74802 4.20155L5.50251 1.95604ZM9.06677 5.52031L18.044 14.4975C18.1023 14.5558 18.135 14.6348 18.135 14.7173V18.135H14.7173C14.6348 18.135 14.5558 18.1023 14.4975 18.044L5.52031 9.06677L9.06677 5.52031Z", className: "tk-icon" })));
17
17
  };
18
18
  exports.Draw = Draw;
19
19
  exports.Draw.iconName = 'draw';
@@ -10,11 +10,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.Window = void 0;
11
11
  var react_1 = __importDefault(require("react"));
12
12
  var styled_components_1 = __importDefault(require("styled-components"));
13
- var Path = styled_components_1.default.path(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n fill: ", ";\n"], ["\n fill: ", ";\n"])), function (props) { return props.color || props.theme.textColor; });
13
+ var SVG = styled_components_1.default.svg(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n .tk-icon {\n fill: ", ";\n }\n"], ["\n .tk-icon {\n fill: ", ";\n }\n"])), function (props) { return props.color || props.theme.textColor; });
14
14
  var Window = function (props) {
15
- return (react_1.default.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
16
- react_1.default.createElement(Path, { fillRule: "evenodd", clipRule: "evenodd", color: props.color, d: "M2.28571 15.4286V4.42858H17.7603V15.4286H2.28571ZM10.4891 10.3947V14.5714H16.9031V10.3947H10.4891ZM16.9031 9.46248V5.28572H10.4891V9.46248H16.9031ZM9.55688 5.28572H3.14286V9.46248H9.55688V5.28572ZM3.14286 14.5714V10.3947H9.55688V14.5714H3.14286Z" }),
17
- react_1.default.createElement(Path, { fillRule: "evenodd", clipRule: "evenodd", color: props.color, d: "M0.285714 2.71429C0.127919 2.71429 0 2.84221 0 3.00001V17C0 17.1578 0.127918 17.2857 0.285714 17.2857H19.7143C19.8721 17.2857 20 17.1578 20 17V3.00001C20 2.84221 19.8721 2.71429 19.7143 2.71429H0.285714ZM0.857143 3.57144V16.4286H19.1429V3.57144H0.857143Z" })));
15
+ return (react_1.default.createElement(SVG, { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", color: props.color },
16
+ react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M2.28571 15.4286V4.42858H17.7603V15.4286H2.28571ZM10.4891 10.3947V14.5714H16.9031V10.3947H10.4891ZM16.9031 9.46248V5.28572H10.4891V9.46248H16.9031ZM9.55688 5.28572H3.14286V9.46248H9.55688V5.28572ZM3.14286 14.5714V10.3947H9.55688V14.5714H3.14286Z", className: "tk-icon" }),
17
+ react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M0.285714 2.71429C0.127919 2.71429 0 2.84221 0 3.00001V17C0 17.1578 0.127918 17.2857 0.285714 17.2857H19.7143C19.8721 17.2857 20 17.1578 20 17V3.00001C20 2.84221 19.8721 2.71429 19.7143 2.71429H0.285714ZM0.857143 3.57144V16.4286H19.1429V3.57144H0.857143Z", className: "tk-icon" })));
18
18
  };
19
19
  exports.Window = Window;
20
20
  exports.Window.iconName = 'window';
@@ -33,7 +33,6 @@ var More_1 = __importDefault(require("./More"));
33
33
  var NewWindow_1 = __importDefault(require("./NewWindow"));
34
34
  var Pause_1 = __importDefault(require("./Pause"));
35
35
  var Play_1 = __importDefault(require("./Play"));
36
- var Player3D_1 = __importDefault(require("./Player3D"));
37
36
  var Redo_1 = __importDefault(require("./Redo"));
38
37
  var Remove_1 = __importDefault(require("./Remove"));
39
38
  var Ruler_1 = __importDefault(require("./Ruler"));
@@ -87,7 +86,6 @@ exports.default = (_a = {},
87
86
  _a[NewWindow_1.default.iconName] = NewWindow_1.default,
88
87
  _a[Pause_1.default.iconName] = Pause_1.default,
89
88
  _a[Play_1.default.iconName] = Play_1.default,
90
- _a[Player3D_1.default.iconName] = Player3D_1.default,
91
89
  _a[Redo_1.default.iconName] = Redo_1.default,
92
90
  _a[Remove_1.default.iconName] = Remove_1.default,
93
91
  _a[Ruler_1.default.iconName] = Ruler_1.default,
package/dist/index.d.ts CHANGED
@@ -55,7 +55,6 @@ import PlayerLoadingSpinner from './components/PlayerLoadingSpinner';
55
55
  import DraggableHint from './components/DraggableHint';
56
56
  import TurntableAnimation from './components/TurntableAnimation';
57
57
  import BreatheAnimation from './components/BreatheAnimation';
58
- import RoomBuilderLayoutIcon from './hooks/useRoomBuilder/RoomBuilderLayout';
59
58
  import AddIcon from './icons/Add';
60
59
  import ArrowLeftIcon from './icons/ArrowLeft';
61
60
  import ArrowRightIcon from './icons/ArrowRight';
@@ -85,7 +84,6 @@ import MoreIcon from './icons/More';
85
84
  import NewWindowIcon from './icons/NewWindow';
86
85
  import PauseIcon from './icons/Pause';
87
86
  import PlayIcon from './icons/Play';
88
- import Player3DIcon from './icons/Player3D';
89
87
  import RedoIcon from './icons/Redo';
90
88
  import RemoveIcon from './icons/Remove';
91
89
  import RulerIcon from './icons/Ruler';
@@ -109,4 +107,4 @@ import DoorIcon from './icons/Door';
109
107
  import OpeningIcon from './icons/Opening';
110
108
  import WallIcon from './icons/Wall';
111
109
  import LayoutIcon from './icons/Layout';
112
- export { useAttribute, useConfigurator, useConfigurationLoader, useFirstPlayerInteraction, useMetadata, useName, usePlayerLoadingStatus, usePrice, useThreekitInitStatus, useZoom, useSnapshot, useWishlist, useShare, usePlayerPortal, useProductCache, useNestedConfigurator, useLoadingProgress, usePlayer, useRoomBuilder, ThreekitProvider, Player, Button, Cards, Dropdown, Strips, Swatch, TextInput, Tiles, TilesGroup, Upload, Switch, ProductName, ProductDescription, AttributeTitle, AttributeValue, TotalPrice, Skeleton, message, Modal, Drawer, Accordion, Tabs, PortalToArOverlay, PortalToElement, AwaitThreekitLoad, FlatForm, Zoom, Snapshots, Wishlist, Share, TrebleApp, ProductLayout, PlayerLoadingCircular, PlayerLoadingSpinner, DraggableHint, TurntableAnimation, BreatheAnimation, RoomBuilderLayoutIcon, AddIcon, ArrowLeftIcon, ArrowRightIcon, CameraIcon, CaretDownIcon, CaretUpIcon, CaretLeftIcon, CaretRightIcon, CartIcon, CheckmateIcon, ClipboardIcon, ColorPickerIcon, CopyIcon, DeleteIcon, DoubleCaretLeftIcon, DoubleCaretRightIcon, DownloadIcon, DraggableIcon, DragIcon, EditIcon, HeartIcon, ImageIcon, InfoIcon, MailIcon, MenuIcon, MoreIcon, NewWindowIcon, PauseIcon, PlayIcon, Player3DIcon, RedoIcon, RemoveIcon, RulerIcon, SearchIcon, SettingsIcon, ShareIcon, SwitchIcon, TagIcon, UndoIcon, WishlistIcon, ZoomInIcon, ZoomOutIcon, SpinnerIcon, AngleIcon, TrashCanIcon, TrashCanAltIcon, CursorIcon, WindowIcon, DrawIcon, DoorIcon, OpeningIcon, WallIcon, LayoutIcon, };
110
+ export { useAttribute, useConfigurator, useConfigurationLoader, useFirstPlayerInteraction, useMetadata, useName, usePlayerLoadingStatus, usePrice, useThreekitInitStatus, useZoom, useSnapshot, useWishlist, useShare, usePlayerPortal, useProductCache, useNestedConfigurator, useLoadingProgress, usePlayer, useRoomBuilder, ThreekitProvider, Player, Button, Cards, Dropdown, Strips, Swatch, TextInput, Tiles, TilesGroup, Upload, Switch, ProductName, ProductDescription, AttributeTitle, AttributeValue, TotalPrice, Skeleton, message, Modal, Drawer, Accordion, Tabs, PortalToArOverlay, PortalToElement, AwaitThreekitLoad, FlatForm, Zoom, Snapshots, Wishlist, Share, TrebleApp, ProductLayout, PlayerLoadingCircular, PlayerLoadingSpinner, DraggableHint, TurntableAnimation, BreatheAnimation, AddIcon, ArrowLeftIcon, ArrowRightIcon, CameraIcon, CaretDownIcon, CaretUpIcon, CaretLeftIcon, CaretRightIcon, CartIcon, CheckmateIcon, ClipboardIcon, ColorPickerIcon, CopyIcon, DeleteIcon, DoubleCaretLeftIcon, DoubleCaretRightIcon, DownloadIcon, DraggableIcon, DragIcon, EditIcon, HeartIcon, ImageIcon, InfoIcon, MailIcon, MenuIcon, MoreIcon, NewWindowIcon, PauseIcon, PlayIcon, RedoIcon, RemoveIcon, RulerIcon, SearchIcon, SettingsIcon, ShareIcon, SwitchIcon, TagIcon, UndoIcon, WishlistIcon, ZoomInIcon, ZoomOutIcon, SpinnerIcon, AngleIcon, TrashCanIcon, TrashCanAltIcon, CursorIcon, WindowIcon, DrawIcon, DoorIcon, OpeningIcon, WallIcon, LayoutIcon, };