@threekit-tools/treble 0.0.88 → 0.0.89-next-002
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.
- package/dist/components/AttributeValue/index.js +2 -0
- package/dist/components/Wishlist/index.d.ts +1 -1
- package/dist/components/Zoom/index.d.ts +1 -1
- package/dist/components/containers/formInputContainer.d.ts +1 -1
- package/dist/connection.d.ts +4 -0
- package/dist/connection.js +3 -0
- package/dist/hooks/useProductCache/index.d.ts +1 -1
- package/dist/hooks/useRoomBuilder/RoomBuilderState.d.ts +95 -0
- package/dist/hooks/useRoomBuilder/RoomBuilderState.js +1237 -0
- package/dist/hooks/useRoomBuilder/constants.d.ts +41 -0
- package/dist/hooks/useRoomBuilder/constants.js +48 -0
- package/dist/hooks/useRoomBuilder/dataHandlers.d.ts +18 -0
- package/dist/hooks/useRoomBuilder/dataHandlers.js +187 -0
- package/dist/hooks/useRoomBuilder/draw.d.ts +55 -0
- package/dist/hooks/useRoomBuilder/draw.js +573 -0
- package/dist/hooks/useRoomBuilder/findLoops.d.ts +5 -0
- package/dist/hooks/useRoomBuilder/findLoops.js +99 -0
- package/dist/hooks/useRoomBuilder/geometry.d.ts +33 -0
- package/dist/hooks/useRoomBuilder/geometry.js +325 -0
- package/dist/hooks/useRoomBuilder/index.d.ts +40 -0
- package/dist/hooks/useRoomBuilder/index.js +303 -0
- package/dist/hooks/useRoomBuilder/messaging.d.ts +8 -0
- package/dist/hooks/useRoomBuilder/messaging.js +18 -0
- package/dist/hooks/useRoomBuilder/themes.d.ts +12 -0
- package/dist/hooks/useRoomBuilder/themes.js +273 -0
- package/dist/hooks/useRoomBuilder/types.d.ts +238 -0
- package/dist/hooks/useRoomBuilder/types.js +36 -0
- package/dist/hooks/useRoomBuilder/validators.d.ts +36 -0
- package/dist/hooks/useRoomBuilder/validators.js +362 -0
- package/dist/http/request.js +4 -1
- package/dist/icons/Add.d.ts +1 -1
- package/dist/icons/Add.js +3 -3
- package/dist/icons/Angle.d.ts +3 -0
- package/dist/icons/Angle.js +21 -0
- package/dist/icons/ArrowLeft.d.ts +1 -1
- package/dist/icons/ArrowLeft.js +3 -3
- package/dist/icons/ArrowRight.d.ts +1 -1
- package/dist/icons/ArrowRight.js +3 -3
- package/dist/icons/Camera.d.ts +1 -1
- package/dist/icons/Camera.js +3 -3
- package/dist/icons/CaretDown.d.ts +1 -1
- package/dist/icons/CaretDown.js +3 -3
- package/dist/icons/CaretLeft.d.ts +1 -1
- package/dist/icons/CaretLeft.js +3 -3
- package/dist/icons/CaretRight.d.ts +1 -1
- package/dist/icons/CaretRight.js +3 -3
- package/dist/icons/CaretUp.d.ts +1 -1
- package/dist/icons/CaretUp.js +3 -3
- package/dist/icons/Cart.d.ts +1 -1
- package/dist/icons/Cart.js +3 -3
- package/dist/icons/Checkmate.d.ts +1 -1
- package/dist/icons/Checkmate.js +3 -3
- package/dist/icons/Clipboard.d.ts +1 -1
- package/dist/icons/Clipboard.js +3 -3
- package/dist/icons/ColorPicker.d.ts +1 -1
- package/dist/icons/ColorPicker.js +3 -3
- package/dist/icons/Copy.d.ts +1 -1
- package/dist/icons/Copy.js +3 -3
- package/dist/icons/Cursor.d.ts +3 -0
- package/dist/icons/Cursor.js +21 -0
- package/dist/icons/Delete.d.ts +1 -1
- package/dist/icons/Delete.js +3 -3
- package/dist/icons/Door.d.ts +3 -0
- package/dist/icons/Door.js +22 -0
- package/dist/icons/DoubleCaretLeft.d.ts +1 -1
- package/dist/icons/DoubleCaretLeft.js +3 -3
- package/dist/icons/DoubleCaretRight.d.ts +1 -1
- package/dist/icons/DoubleCaretRight.js +3 -3
- package/dist/icons/Download.d.ts +1 -1
- package/dist/icons/Download.js +3 -3
- package/dist/icons/Drag.d.ts +1 -1
- package/dist/icons/Drag.js +3 -3
- package/dist/icons/Draggable.d.ts +1 -1
- package/dist/icons/Draggable.js +3 -3
- package/dist/icons/Draw.d.ts +3 -0
- package/dist/icons/Draw.js +21 -0
- package/dist/icons/Edit.d.ts +1 -1
- package/dist/icons/Edit.js +3 -3
- package/dist/icons/Heart.d.ts +1 -1
- package/dist/icons/Heart.js +3 -3
- package/dist/icons/Image.d.ts +1 -1
- package/dist/icons/Image.js +3 -3
- package/dist/icons/Info.d.ts +1 -1
- package/dist/icons/Info.js +3 -3
- package/dist/icons/Layout.d.ts +3 -0
- package/dist/icons/Layout.js +21 -0
- package/dist/icons/Mail.d.ts +1 -1
- package/dist/icons/Mail.js +3 -3
- package/dist/icons/Menu.d.ts +1 -1
- package/dist/icons/Menu.js +3 -3
- package/dist/icons/More.d.ts +1 -1
- package/dist/icons/More.js +3 -3
- package/dist/icons/NewWindow.d.ts +1 -1
- package/dist/icons/NewWindow.js +3 -3
- package/dist/icons/Opening.d.ts +3 -0
- package/dist/icons/Opening.js +21 -0
- package/dist/icons/Pause.d.ts +1 -1
- package/dist/icons/Pause.js +3 -3
- package/dist/icons/Play.d.ts +1 -1
- package/dist/icons/Play.js +3 -3
- package/dist/icons/Redo.d.ts +1 -1
- package/dist/icons/Redo.js +3 -3
- package/dist/icons/Remove.d.ts +1 -1
- package/dist/icons/Remove.js +3 -3
- package/dist/icons/Ruler.d.ts +1 -1
- package/dist/icons/Ruler.js +3 -3
- package/dist/icons/Search.d.ts +1 -1
- package/dist/icons/Search.js +3 -3
- package/dist/icons/Settings.d.ts +1 -1
- package/dist/icons/Settings.js +3 -3
- package/dist/icons/Share.d.ts +1 -1
- package/dist/icons/Share.js +3 -3
- package/dist/icons/Switch.d.ts +1 -1
- package/dist/icons/Switch.js +3 -3
- package/dist/icons/Tag.d.ts +1 -1
- package/dist/icons/Tag.js +3 -3
- package/dist/icons/TrashCan.d.ts +3 -0
- package/dist/icons/TrashCan.js +21 -0
- package/dist/icons/TrashCanAlt.d.ts +3 -0
- package/dist/icons/TrashCanAlt.js +21 -0
- package/dist/icons/Undo.d.ts +1 -1
- package/dist/icons/Undo.js +3 -3
- package/dist/icons/Wall.d.ts +3 -0
- package/dist/icons/Wall.js +21 -0
- package/dist/icons/Window.d.ts +3 -0
- package/dist/icons/Window.js +22 -0
- package/dist/icons/Wishlist.d.ts +1 -1
- package/dist/icons/Wishlist.js +3 -3
- package/dist/icons/ZoomIn.d.ts +1 -1
- package/dist/icons/ZoomIn.js +3 -3
- package/dist/icons/ZoomOut.d.ts +1 -1
- package/dist/icons/ZoomOut.js +3 -3
- package/dist/icons/index.d.ts +2 -6
- package/dist/icons/index.js +20 -0
- package/dist/icons/types.d.ts +7 -0
- package/dist/icons/types.js +2 -0
- package/dist/index.d.ts +12 -1
- package/dist/index.js +25 -2
- package/dist/store/index.d.ts +8 -29
- package/dist/store/product.d.ts +1 -1
- package/dist/store/product.js +6 -7
- package/dist/store/treble.js +6 -1
- package/dist/types.d.ts +47 -7
- package/dist/types.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare enum IWallAttributes {
|
|
2
|
+
START_X = "Start X",
|
|
3
|
+
START_Z = "Start Z",
|
|
4
|
+
END_X = "End X",
|
|
5
|
+
END_Z = "End Z",
|
|
6
|
+
HEIGHT = "Height",
|
|
7
|
+
THICKNESS = "Thickness",
|
|
8
|
+
CONNECTIONS = "Connections"
|
|
9
|
+
}
|
|
10
|
+
export declare enum IFeatureAttribute {
|
|
11
|
+
POSITION_X = "Start X",
|
|
12
|
+
POSITION_Y = "Start Y",
|
|
13
|
+
POSITION_Z = "Start Z",
|
|
14
|
+
HEIGHT = "Height",
|
|
15
|
+
LENGTH = "Length",
|
|
16
|
+
CONNECTED_TO = "Connected To"
|
|
17
|
+
}
|
|
18
|
+
export declare const SCALE = 0.02;
|
|
19
|
+
export declare const SNAP_PROXIMITY = 10;
|
|
20
|
+
export declare const MIN_WALL_LENGTH = 50;
|
|
21
|
+
export declare const WALL_PADDING_FOR_FEATURE = 20;
|
|
22
|
+
export declare const UNIT_LABELS: {
|
|
23
|
+
feet: string;
|
|
24
|
+
meter: string;
|
|
25
|
+
inch: string;
|
|
26
|
+
cm: string;
|
|
27
|
+
};
|
|
28
|
+
export declare const UNIT_FACTORS: {
|
|
29
|
+
cm: number;
|
|
30
|
+
meter: number;
|
|
31
|
+
feet: number;
|
|
32
|
+
inch: number;
|
|
33
|
+
};
|
|
34
|
+
export declare const FEATURE_LABELS: {
|
|
35
|
+
windows: string;
|
|
36
|
+
doors: string;
|
|
37
|
+
openings: string;
|
|
38
|
+
};
|
|
39
|
+
export declare const FEATURE_LENGTH = 120;
|
|
40
|
+
export declare const UI_ANCHOR_DISTANCE = -60;
|
|
41
|
+
export declare const WALL_SNAP_DISTANCE = 12;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a, _b, _c;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.WALL_SNAP_DISTANCE = exports.UI_ANCHOR_DISTANCE = exports.FEATURE_LENGTH = exports.FEATURE_LABELS = exports.UNIT_FACTORS = exports.UNIT_LABELS = exports.WALL_PADDING_FOR_FEATURE = exports.MIN_WALL_LENGTH = exports.SNAP_PROXIMITY = exports.SCALE = exports.IFeatureAttribute = exports.IWallAttributes = void 0;
|
|
5
|
+
var types_1 = require("./types");
|
|
6
|
+
var IWallAttributes;
|
|
7
|
+
(function (IWallAttributes) {
|
|
8
|
+
IWallAttributes["START_X"] = "Start X";
|
|
9
|
+
IWallAttributes["START_Z"] = "Start Z";
|
|
10
|
+
IWallAttributes["END_X"] = "End X";
|
|
11
|
+
IWallAttributes["END_Z"] = "End Z";
|
|
12
|
+
IWallAttributes["HEIGHT"] = "Height";
|
|
13
|
+
IWallAttributes["THICKNESS"] = "Thickness";
|
|
14
|
+
IWallAttributes["CONNECTIONS"] = "Connections";
|
|
15
|
+
})(IWallAttributes = exports.IWallAttributes || (exports.IWallAttributes = {}));
|
|
16
|
+
var IFeatureAttribute;
|
|
17
|
+
(function (IFeatureAttribute) {
|
|
18
|
+
IFeatureAttribute["POSITION_X"] = "Start X";
|
|
19
|
+
IFeatureAttribute["POSITION_Y"] = "Start Y";
|
|
20
|
+
IFeatureAttribute["POSITION_Z"] = "Start Z";
|
|
21
|
+
IFeatureAttribute["HEIGHT"] = "Height";
|
|
22
|
+
IFeatureAttribute["LENGTH"] = "Length";
|
|
23
|
+
IFeatureAttribute["CONNECTED_TO"] = "Connected To";
|
|
24
|
+
})(IFeatureAttribute = exports.IFeatureAttribute || (exports.IFeatureAttribute = {}));
|
|
25
|
+
exports.SCALE = 0.02;
|
|
26
|
+
exports.SNAP_PROXIMITY = 10;
|
|
27
|
+
exports.MIN_WALL_LENGTH = 50;
|
|
28
|
+
exports.WALL_PADDING_FOR_FEATURE = 20;
|
|
29
|
+
exports.UNIT_LABELS = (_a = {},
|
|
30
|
+
_a[types_1.IUnits.FEET] = 'ft',
|
|
31
|
+
_a[types_1.IUnits.METER] = 'm',
|
|
32
|
+
_a[types_1.IUnits.INCH] = 'in',
|
|
33
|
+
_a[types_1.IUnits.CM] = 'cm',
|
|
34
|
+
_a);
|
|
35
|
+
exports.UNIT_FACTORS = (_b = {},
|
|
36
|
+
_b[types_1.IUnits.CM] = 100,
|
|
37
|
+
_b[types_1.IUnits.METER] = 1,
|
|
38
|
+
_b[types_1.IUnits.FEET] = 3.28084,
|
|
39
|
+
_b[types_1.IUnits.INCH] = 39.37,
|
|
40
|
+
_b);
|
|
41
|
+
exports.FEATURE_LABELS = (_c = {},
|
|
42
|
+
_c[types_1.IElements.WINDOW] = 'Window',
|
|
43
|
+
_c[types_1.IElements.DOOR] = 'Door',
|
|
44
|
+
_c[types_1.IElements.OPENING] = 'Opening',
|
|
45
|
+
_c);
|
|
46
|
+
exports.FEATURE_LENGTH = 120;
|
|
47
|
+
exports.UI_ANCHOR_DISTANCE = -60;
|
|
48
|
+
exports.WALL_SNAP_DISTANCE = 12;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IWalls, IRoomBuilderStateProps, IVerticesState, IFeatures } from './types';
|
|
2
|
+
import { IUnits } from './types';
|
|
3
|
+
import type { IConfiguration, IHydratedAttribute } from '../../types';
|
|
4
|
+
export declare function prepAttributesIncoming(attributes: Record<string, IHydratedAttribute>, config: IRoomBuilderStateProps): {
|
|
5
|
+
features: IFeatures;
|
|
6
|
+
walls: IWalls;
|
|
7
|
+
vertex: IVerticesState;
|
|
8
|
+
};
|
|
9
|
+
export declare function prepAttributesOutgoing(walls: IWalls, features: IFeatures, config: IRoomBuilderStateProps): {
|
|
10
|
+
[x: string]: import("../../types").IConfigurationAttribute | {
|
|
11
|
+
assetId: string;
|
|
12
|
+
configuration: IConfiguration;
|
|
13
|
+
}[];
|
|
14
|
+
};
|
|
15
|
+
export declare function convertLengthUnit(value: number, from: IUnits, to: IUnits): number;
|
|
16
|
+
export declare function convertAreaUnit(value: number, from: IUnits, to: IUnits): number;
|
|
17
|
+
export declare function prepLengthForUser(value: number, unit: IUnits): string;
|
|
18
|
+
export declare function prepAreaForUser(value: number, unit: IUnits): string;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.prepAreaForUser = exports.prepLengthForUser = exports.convertAreaUnit = exports.convertLengthUnit = exports.prepAttributesOutgoing = exports.prepAttributesIncoming = void 0;
|
|
15
|
+
var types_1 = require("./types");
|
|
16
|
+
var constants_1 = require("./constants");
|
|
17
|
+
var geometry_1 = require("./geometry");
|
|
18
|
+
function prepConnectionOutgoing(connection) {
|
|
19
|
+
return "".concat(connection[0], ".").concat(connection[1]);
|
|
20
|
+
}
|
|
21
|
+
function prepConnectionIncoming(connection) {
|
|
22
|
+
var _a = connection.split('.'), attributeName = _a[0], indexStr = _a[1];
|
|
23
|
+
return [attributeName, parseInt(indexStr)];
|
|
24
|
+
}
|
|
25
|
+
function prepWallsAndVerticesIncoming(wallsAttribute, config) {
|
|
26
|
+
var _a;
|
|
27
|
+
var walls = [];
|
|
28
|
+
var vertices = {};
|
|
29
|
+
((wallsAttribute === null || wallsAttribute === void 0 ? void 0 : wallsAttribute.value) || []).forEach(function (_a, i) {
|
|
30
|
+
var assetId = _a.assetId, configuration = _a.configuration;
|
|
31
|
+
var point1 = [
|
|
32
|
+
(configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IWallAttributes.START_X]) / config.config.scale,
|
|
33
|
+
(configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IWallAttributes.START_Z]) / config.config.scale,
|
|
34
|
+
];
|
|
35
|
+
var point2 = [
|
|
36
|
+
(configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IWallAttributes.END_X]) / config.config.scale,
|
|
37
|
+
(configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IWallAttributes.END_Z]) / config.config.scale,
|
|
38
|
+
];
|
|
39
|
+
var point1Str = JSON.stringify(point1);
|
|
40
|
+
var point2Str = JSON.stringify(point2);
|
|
41
|
+
if (vertices[point1Str])
|
|
42
|
+
vertices[point1Str].push([i, 0]);
|
|
43
|
+
else
|
|
44
|
+
vertices[point1Str] = [[i, 0]];
|
|
45
|
+
if (vertices[point2Str])
|
|
46
|
+
vertices[point2Str].push([i, 1]);
|
|
47
|
+
else
|
|
48
|
+
vertices[point2Str] = [[i, 1]];
|
|
49
|
+
var connections = [];
|
|
50
|
+
walls.push({
|
|
51
|
+
assetId: assetId,
|
|
52
|
+
line: [point1, point2],
|
|
53
|
+
path: (0, geometry_1.addThicknessToLine)([point1, point2], config.config.styles.wall.thickness),
|
|
54
|
+
height: configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IWallAttributes.HEIGHT],
|
|
55
|
+
thickness: configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IWallAttributes.THICKNESS],
|
|
56
|
+
connections: connections,
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
return _a = {}, _a[types_1.IElements.WALL] = walls, _a[types_1.IElements.VERTEX] = vertices, _a;
|
|
60
|
+
}
|
|
61
|
+
function prepFeatureIncoming(walls, featureAttribute, config) {
|
|
62
|
+
var _a;
|
|
63
|
+
var feature = [];
|
|
64
|
+
(_a = featureAttribute === null || featureAttribute === void 0 ? void 0 : featureAttribute.value) === null || _a === void 0 ? void 0 : _a.forEach(function (_a) {
|
|
65
|
+
var assetId = _a.assetId, configuration = _a.configuration;
|
|
66
|
+
var offset = (configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IFeatureAttribute.POSITION_X]) / config.config.scale;
|
|
67
|
+
var length = (configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IFeatureAttribute.LENGTH]) / config.config.scale ||
|
|
68
|
+
constants_1.FEATURE_LENGTH;
|
|
69
|
+
var connectedTo = (configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.IFeatureAttribute.CONNECTED_TO]) || '';
|
|
70
|
+
var wallIndex = prepConnectionIncoming(connectedTo)[1];
|
|
71
|
+
var featureLine = (0, geometry_1.getLineAtOffsetOnLineSegment)(walls[wallIndex].line, offset, length);
|
|
72
|
+
var path = (0, geometry_1.addThicknessToLine)(featureLine, config.config.styles.feature.thickness);
|
|
73
|
+
feature.push({
|
|
74
|
+
assetId: assetId,
|
|
75
|
+
offset: offset,
|
|
76
|
+
length: length,
|
|
77
|
+
path: path,
|
|
78
|
+
connectedTo: [types_1.IElements.WALL, wallIndex],
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
return feature;
|
|
82
|
+
}
|
|
83
|
+
function prepAttributesIncoming(attributes, config) {
|
|
84
|
+
var _a;
|
|
85
|
+
var featuresList = [types_1.IElements.WINDOW, types_1.IElements.DOOR, types_1.IElements.OPENING];
|
|
86
|
+
var wallsAndVertices = prepWallsAndVerticesIncoming(attributes[config.attributes[types_1.IElements.WALL]], config);
|
|
87
|
+
var featuresData = featuresList.reduce(function (output, type) {
|
|
88
|
+
output[type] = prepFeatureIncoming(wallsAndVertices[types_1.IElements.WALL], attributes[config.attributes[type]], config);
|
|
89
|
+
return output;
|
|
90
|
+
}, {});
|
|
91
|
+
return __assign(__assign({}, wallsAndVertices), (_a = {}, _a[types_1.IElements.FEATURE] = featuresData, _a));
|
|
92
|
+
}
|
|
93
|
+
exports.prepAttributesIncoming = prepAttributesIncoming;
|
|
94
|
+
function prepFeaturesOutgoing(features, config) {
|
|
95
|
+
return features.map(function (feature) {
|
|
96
|
+
var _a, _b;
|
|
97
|
+
var assetId = feature.assetId, offset = feature.offset, length = feature.length;
|
|
98
|
+
var connectedTo = prepConnectionOutgoing([
|
|
99
|
+
config.attributes[feature.connectedTo[0]],
|
|
100
|
+
feature.connectedTo[1],
|
|
101
|
+
]);
|
|
102
|
+
var configuration = Object.entries((_a = {},
|
|
103
|
+
_a[constants_1.IFeatureAttribute.LENGTH] = length,
|
|
104
|
+
_a[constants_1.IFeatureAttribute.POSITION_X] = offset,
|
|
105
|
+
_a)).reduce(function (output, _a) {
|
|
106
|
+
var _b;
|
|
107
|
+
var key = _a[0], value = _a[1];
|
|
108
|
+
return Object.assign(output, (_b = {},
|
|
109
|
+
_b[key] = value ? value * config.config.scale : value,
|
|
110
|
+
_b));
|
|
111
|
+
}, (_b = {},
|
|
112
|
+
_b[constants_1.IFeatureAttribute.CONNECTED_TO] = connectedTo,
|
|
113
|
+
_b));
|
|
114
|
+
return {
|
|
115
|
+
assetId: assetId,
|
|
116
|
+
configuration: configuration,
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function prepWallsOutgoing(walls, config) {
|
|
121
|
+
return walls.map(function (wall) {
|
|
122
|
+
var _a, _b;
|
|
123
|
+
var line = wall.line, height = wall.height, thickness = wall.thickness;
|
|
124
|
+
var connections = wall.connections.map(function (connection) {
|
|
125
|
+
var attributeName = config.attributes[connection[0]];
|
|
126
|
+
if (!attributeName)
|
|
127
|
+
return;
|
|
128
|
+
return prepConnectionOutgoing([attributeName, connection[1]]);
|
|
129
|
+
});
|
|
130
|
+
var _c = line.flat(), x1 = _c[0], y1 = _c[1], x2 = _c[2], y2 = _c[3];
|
|
131
|
+
var configuration = Object.entries((_a = {},
|
|
132
|
+
_a[constants_1.IWallAttributes.START_X] = x1,
|
|
133
|
+
_a[constants_1.IWallAttributes.START_Z] = y1,
|
|
134
|
+
_a[constants_1.IWallAttributes.END_X] = x2,
|
|
135
|
+
_a[constants_1.IWallAttributes.END_Z] = y2,
|
|
136
|
+
_a[constants_1.IWallAttributes.HEIGHT] = height,
|
|
137
|
+
_a[constants_1.IWallAttributes.THICKNESS] = thickness,
|
|
138
|
+
_a)).reduce(function (output, _a) {
|
|
139
|
+
var _b;
|
|
140
|
+
var key = _a[0], value = _a[1];
|
|
141
|
+
return Object.assign(output, (_b = {},
|
|
142
|
+
_b[key] = value ? value * config.config.scale : value,
|
|
143
|
+
_b));
|
|
144
|
+
}, (_b = {},
|
|
145
|
+
_b[constants_1.IWallAttributes.CONNECTIONS] = JSON.stringify(connections),
|
|
146
|
+
_b));
|
|
147
|
+
return {
|
|
148
|
+
assetId: wall.assetId,
|
|
149
|
+
configuration: configuration,
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function prepAttributesOutgoing(walls, features, config) {
|
|
154
|
+
var _a;
|
|
155
|
+
var wallsAttribute = prepWallsOutgoing(walls, config);
|
|
156
|
+
var featuresAttributes = Object.entries(features).reduce(function (output, _a) {
|
|
157
|
+
var type = _a[0], features = _a[1];
|
|
158
|
+
var attributeName = config.attributes[type];
|
|
159
|
+
if (!attributeName)
|
|
160
|
+
return output;
|
|
161
|
+
output[attributeName] = prepFeaturesOutgoing(features, config);
|
|
162
|
+
return output;
|
|
163
|
+
}, {});
|
|
164
|
+
return __assign(__assign({}, featuresAttributes), (_a = {}, _a[config.attributes[types_1.IElements.WALL]] = wallsAttribute, _a));
|
|
165
|
+
}
|
|
166
|
+
exports.prepAttributesOutgoing = prepAttributesOutgoing;
|
|
167
|
+
function convertLengthUnit(value, from, to) {
|
|
168
|
+
return (value / constants_1.UNIT_FACTORS[from]) * constants_1.UNIT_FACTORS[to];
|
|
169
|
+
}
|
|
170
|
+
exports.convertLengthUnit = convertLengthUnit;
|
|
171
|
+
function convertAreaUnit(value, from, to) {
|
|
172
|
+
return (value / constants_1.UNIT_FACTORS[from]) * Math.pow(constants_1.UNIT_FACTORS[to], 2);
|
|
173
|
+
}
|
|
174
|
+
exports.convertAreaUnit = convertAreaUnit;
|
|
175
|
+
function prepLengthForUser(value, unit) {
|
|
176
|
+
if (unit === types_1.IUnits.FEET) {
|
|
177
|
+
var feet = Math.floor(value);
|
|
178
|
+
var inches = 1.2 * (value % 1);
|
|
179
|
+
return "".concat(feet).concat(constants_1.UNIT_LABELS[types_1.IUnits.FEET], " ").concat(inches.toFixed(2)).concat(constants_1.UNIT_LABELS[types_1.IUnits.INCH]);
|
|
180
|
+
}
|
|
181
|
+
return "".concat(value.toFixed(2), " ").concat(constants_1.UNIT_LABELS[unit]);
|
|
182
|
+
}
|
|
183
|
+
exports.prepLengthForUser = prepLengthForUser;
|
|
184
|
+
function prepAreaForUser(value, unit) {
|
|
185
|
+
return "".concat(value.toFixed(2), " sq-").concat(constants_1.UNIT_LABELS[unit]);
|
|
186
|
+
}
|
|
187
|
+
exports.prepAreaForUser = prepAreaForUser;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { IWall, ICoordinate2D, ICoordinatesLine, IFeatures, IFeature, IElementAddress, IRoomBuilderStyles, IRoomBuilderConfigInternal, IStylesGrid, IStylesWall, IStylesVertex, ILineDimensions, IVertex, IElementStyleModes, IStylesFloor, IEnclosedSpace } from './types';
|
|
2
|
+
interface IWallToDraw extends Omit<IWall, 'assetId' | 'connections'> {
|
|
3
|
+
}
|
|
4
|
+
interface IWallsToDraw extends Array<IWallToDraw> {
|
|
5
|
+
}
|
|
6
|
+
export declare function clearCanvas(canvas: HTMLCanvasElement): void;
|
|
7
|
+
export declare function drawBackground(canvas: HTMLCanvasElement, color?: string): void;
|
|
8
|
+
export declare function drawGrid(canvas: HTMLCanvasElement, styles: IStylesGrid): void;
|
|
9
|
+
export declare function drawFloor(canvas: HTMLCanvasElement, enclosedSpaces: Array<IEnclosedSpace>, styles: IStylesFloor): void;
|
|
10
|
+
export declare function drawVertex(canvas: HTMLCanvasElement, point: ICoordinate2D, style: IStylesVertex, mode?: IElementStyleModes): void;
|
|
11
|
+
export declare function drawNewWall(canvas: HTMLCanvasElement, line: ICoordinatesLine, styles: IRoomBuilderStyles, mode?: IElementStyleModes.ERROR): void;
|
|
12
|
+
export declare function drawWalls(canvas: HTMLCanvasElement, walls: IWallsToDraw, selections: {
|
|
13
|
+
active: Array<number>;
|
|
14
|
+
highlighted: Array<number>;
|
|
15
|
+
error: Array<number>;
|
|
16
|
+
hidden: Array<number>;
|
|
17
|
+
}, styles: IStylesWall): void;
|
|
18
|
+
export declare function drawVertices(canvas: HTMLCanvasElement, vertices: Array<IVertex>, selections: {
|
|
19
|
+
active: Array<number>;
|
|
20
|
+
highlighted: Array<number>;
|
|
21
|
+
error: Array<number>;
|
|
22
|
+
hidden: Array<number>;
|
|
23
|
+
}, styles: IStylesVertex): void;
|
|
24
|
+
export declare function drawDimensions(canvas: HTMLCanvasElement, dimensions: Array<ILineDimensions>, config: IRoomBuilderConfigInternal): void;
|
|
25
|
+
export declare function drawWindows(canvas: HTMLCanvasElement, walls: IWallsToDraw, windows: Array<IFeature>, selections: {
|
|
26
|
+
active: Array<number>;
|
|
27
|
+
highlighted: Array<number>;
|
|
28
|
+
error: Array<number>;
|
|
29
|
+
hidden: Array<number>;
|
|
30
|
+
}, styles: IRoomBuilderStyles): void;
|
|
31
|
+
export declare function drawDoors(canvas: HTMLCanvasElement, walls: IWallsToDraw, doors: Array<IFeature>, selections: {
|
|
32
|
+
active: Array<number>;
|
|
33
|
+
highlighted: Array<number>;
|
|
34
|
+
error: Array<number>;
|
|
35
|
+
hidden: Array<number>;
|
|
36
|
+
}, styles: IRoomBuilderStyles): void;
|
|
37
|
+
export declare function drawOpenings(canvas: HTMLCanvasElement, walls: IWallsToDraw, openings: Array<IFeature>, selections: {
|
|
38
|
+
active: Array<number>;
|
|
39
|
+
highlighted: Array<number>;
|
|
40
|
+
error: Array<number>;
|
|
41
|
+
hidden: Array<number>;
|
|
42
|
+
}, styles: IRoomBuilderStyles): void;
|
|
43
|
+
export declare function drawElements(canvas: HTMLCanvasElement, walls: IWallsToDraw, vertices: Array<IVertex>, features: IFeatures, selections: {
|
|
44
|
+
active: Array<IElementAddress>;
|
|
45
|
+
highlighted: Array<IElementAddress>;
|
|
46
|
+
hidden: Array<IElementAddress>;
|
|
47
|
+
error: Array<IElementAddress>;
|
|
48
|
+
}, styles: IRoomBuilderStyles): void;
|
|
49
|
+
export declare function drawRoom(canvas: HTMLCanvasElement, enclosedSpaces: Array<IEnclosedSpace>, walls: IWallsToDraw, vertices: Array<IVertex>, features: IFeatures, dimensions: Array<ILineDimensions> | undefined, selections: {
|
|
50
|
+
active?: Array<IElementAddress> | IElementAddress;
|
|
51
|
+
highlighted?: Array<IElementAddress> | IElementAddress;
|
|
52
|
+
hidden?: Array<IElementAddress> | IElementAddress;
|
|
53
|
+
error?: Array<IElementAddress> | IElementAddress;
|
|
54
|
+
}, config: IRoomBuilderConfigInternal): void;
|
|
55
|
+
export {};
|