@threekit-tools/treble 0.0.94 → 0.0.95-next-01
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/Treble/Treble.d.ts +2 -2
- package/dist/Treble/Treble.js +3 -3
- package/dist/Treble/index.d.ts +1 -1
- package/dist/Treble/index.js +1 -1
- package/dist/Treble/{snapshots.d.ts → snapshot.d.ts} +1 -1
- package/dist/Treble/{snapshots.js → snapshot.js} +1 -1
- package/dist/Treble/wishlist.d.ts +1 -1
- package/dist/Treble/wishlist.js +1 -1
- package/dist/api/assets.js +1 -1
- package/dist/api/catalog.js +1 -1
- package/dist/api/configurations.js +1 -1
- package/dist/api/datatables.js +1 -1
- package/dist/api/orders.js +1 -1
- package/dist/api/price.js +1 -1
- package/dist/components/AttributeTitle/index.d.ts +2 -2
- package/dist/components/AttributeValue/index.d.ts +2 -2
- package/dist/components/BreatheAnimation/index.js +1 -1
- package/dist/components/Button/index.d.ts +3 -3
- package/dist/components/Cards/index.d.ts +3 -3
- package/dist/components/DevTools/index.d.ts +2 -2
- package/dist/components/DraggableHint/draggableIndicator.styles.d.ts +1 -1
- package/dist/components/DraggableHint/index.d.ts +2 -2
- package/dist/components/Dropdown/index.d.ts +3 -3
- package/dist/components/FlatForm/index.d.ts +2 -2
- package/dist/components/FormComponentDescription/index.d.ts +1 -1
- package/dist/components/FormComponentTitle/index.d.ts +1 -1
- package/dist/components/Player/index.d.ts +9 -9
- package/dist/components/PlayerLoadingCircular/index.d.ts +2 -2
- package/dist/components/PlayerLoadingSpinner/index.d.ts +2 -2
- package/dist/components/PlayerLoadingSpinner/playerLoadingSpinner.styles.d.ts +1 -1
- package/dist/components/ProductDescription/index.d.ts +3 -3
- package/dist/components/ProductName/index.d.ts +3 -3
- package/dist/components/Share/index.d.ts +2 -2
- package/dist/components/Share/index.js +1 -1
- package/dist/components/Share/share.styles.d.ts +1 -1
- package/dist/components/Snapshots/index.d.ts +2 -2
- package/dist/components/Strips/index.d.ts +3 -3
- package/dist/components/Swatch/index.d.ts +3 -3
- package/dist/components/Switch/index.d.ts +3 -3
- package/dist/components/TextInput/index.d.ts +3 -3
- package/dist/components/ThreekitProvider/index.d.ts +1 -1
- package/dist/components/Tiles/index.d.ts +3 -3
- package/dist/components/TilesGroup/index.d.ts +3 -3
- package/dist/components/TotalPrice/index.d.ts +3 -3
- package/dist/components/TrebleApp/index.d.ts +3 -3
- package/dist/components/TurntableAnimation/index.js +1 -1
- package/dist/components/Upload/index.d.ts +3 -3
- package/dist/components/Upload/index.js +1 -1
- package/dist/components/UploadArea/index.d.ts +3 -3
- package/dist/components/UploadArea/index.js +1 -1
- package/dist/components/Wishlist/WishlistItem.d.ts +2 -2
- package/dist/components/Wishlist/index.d.ts +4 -4
- package/dist/components/Wishlist/index.js +1 -1
- package/dist/components/Zoom/index.d.ts +6 -6
- package/dist/components/containers/formInputContainer.d.ts +2 -2
- package/dist/components/formComponents.d.ts +6 -6
- package/dist/components/message/index.d.ts +1 -1
- package/dist/constants.d.ts +6 -6
- package/dist/hooks/useAttribute/index.d.ts +4 -4
- package/dist/hooks/useAttribute/index.js +1 -1
- package/dist/hooks/useConfigurationLoader/index.js +1 -1
- package/dist/hooks/useConfigurator/index.d.ts +3 -3
- package/dist/hooks/useDevTools/index.d.ts +1 -1
- package/dist/hooks/useNestedConfigurator/index.d.ts +2 -2
- package/dist/hooks/useNestedConfigurator/index.js +3 -4
- package/dist/hooks/usePlayer/index.d.ts +1 -1
- package/dist/hooks/usePlayerPortal/index.d.ts +1 -1
- package/dist/hooks/useProductCache/index.js +1 -1
- package/dist/hooks/useResetProduct/index.d.ts +1 -1
- package/dist/hooks/useResetProduct/index.js +1 -1
- package/dist/hooks/useShare/index.d.ts +1 -1
- package/dist/hooks/useShare/index.js +1 -1
- package/dist/hooks/useSingleAnimation/index.js +1 -1
- package/dist/hooks/useSpaces/SpacesLayout.d.ts +11 -0
- package/dist/hooks/useSpaces/SpacesLayout.js +74 -0
- package/dist/hooks/useSpaces/SpacesState.d.ts +177 -0
- package/dist/hooks/useSpaces/SpacesState.js +1816 -0
- package/dist/hooks/useSpaces/constants.d.ts +79 -0
- package/dist/hooks/useSpaces/constants.js +130 -0
- package/dist/hooks/useSpaces/dataHandlers.d.ts +38 -0
- package/dist/hooks/useSpaces/dataHandlers.js +411 -0
- package/dist/hooks/useSpaces/draw/clearCanvas.d.ts +2 -0
- package/dist/hooks/useSpaces/draw/clearCanvas.js +9 -0
- package/dist/hooks/useSpaces/draw/drawBackground.d.ts +2 -0
- package/dist/hooks/useSpaces/draw/drawBackground.js +12 -0
- package/dist/hooks/useSpaces/draw/drawDimensions.d.ts +3 -0
- package/dist/hooks/useSpaces/draw/drawDimensions.js +53 -0
- package/dist/hooks/useSpaces/draw/drawDoors.d.ts +9 -0
- package/dist/hooks/useSpaces/draw/drawDoors.js +99 -0
- package/dist/hooks/useSpaces/draw/drawFloor.d.ts +3 -0
- package/dist/hooks/useSpaces/draw/drawFloor.js +36 -0
- package/dist/hooks/useSpaces/draw/drawGrid.d.ts +3 -0
- package/dist/hooks/useSpaces/draw/drawGrid.js +36 -0
- package/dist/hooks/useSpaces/draw/drawGuides.d.ts +3 -0
- package/dist/hooks/useSpaces/draw/drawGuides.js +23 -0
- package/dist/hooks/useSpaces/draw/drawOpenings.d.ts +9 -0
- package/dist/hooks/useSpaces/draw/drawOpenings.js +72 -0
- package/dist/hooks/useSpaces/draw/drawVertices.d.ts +8 -0
- package/dist/hooks/useSpaces/draw/drawVertices.js +61 -0
- package/dist/hooks/useSpaces/draw/drawWalls.d.ts +11 -0
- package/dist/hooks/useSpaces/draw/drawWalls.js +90 -0
- package/dist/hooks/useSpaces/draw/drawWindows.d.ts +9 -0
- package/dist/hooks/useSpaces/draw/drawWindows.js +82 -0
- package/dist/hooks/useSpaces/draw/index.d.ts +11 -0
- package/dist/hooks/useSpaces/draw/index.js +129 -0
- package/dist/hooks/useSpaces/geometry/addThicknessToLine.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/addThicknessToLine.js +13 -0
- package/dist/hooks/useSpaces/geometry/areLinesEqual.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/areLinesEqual.js +17 -0
- package/dist/hooks/useSpaces/geometry/arePointsEqual.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/arePointsEqual.js +8 -0
- package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.js +11 -0
- package/dist/hooks/useSpaces/geometry/closestPointOnLine.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/closestPointOnLine.js +13 -0
- package/dist/hooks/useSpaces/geometry/doLinesOverlap.d.ts +2 -0
- package/dist/hooks/useSpaces/geometry/doLinesOverlap.js +16 -0
- package/dist/hooks/useSpaces/geometry/euclideanMod.d.ts +2 -0
- package/dist/hooks/useSpaces/geometry/euclideanMod.js +6 -0
- package/dist/hooks/useSpaces/geometry/findLoops.d.ts +6 -0
- package/dist/hooks/{useRoomBuilder → useSpaces/geometry}/findLoops.js +31 -13
- package/dist/hooks/useSpaces/geometry/getAllLineIntersections.d.ts +6 -0
- package/dist/hooks/useSpaces/geometry/getAllLineIntersections.js +23 -0
- package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.js +7 -0
- package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.js +17 -0
- package/dist/hooks/useSpaces/geometry/getDistanceToLine.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getDistanceToLine.js +10 -0
- package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.js +7 -0
- package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.js +17 -0
- package/dist/hooks/useSpaces/geometry/getLineOtherPoint.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getLineOtherPoint.js +11 -0
- package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.js +43 -0
- package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.js +9 -0
- package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.js +20 -0
- package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.js +11 -0
- package/dist/hooks/useSpaces/geometry/getPolygonArea.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getPolygonArea.js +15 -0
- package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.js +16 -0
- package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.d.ts +6 -0
- package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.js +17 -0
- package/dist/hooks/useSpaces/geometry/getTriangleArea.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getTriangleArea.js +9 -0
- package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.js +12 -0
- package/dist/hooks/useSpaces/geometry/index.d.ts +30 -0
- package/dist/hooks/useSpaces/geometry/index.js +64 -0
- package/dist/hooks/useSpaces/geometry/isPointInPolygon.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/isPointInPolygon.js +21 -0
- package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.js +25 -0
- package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.js +11 -0
- package/dist/hooks/useSpaces/geometry/splitLineAtOffset.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/splitLineAtOffset.js +12 -0
- package/dist/hooks/useSpaces/geometry/splitLineAtPoint.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/splitLineAtPoint.js +9 -0
- package/dist/hooks/useSpaces/geometry/splitLineAtPoints.d.ts +3 -0
- package/dist/hooks/useSpaces/geometry/splitLineAtPoints.js +28 -0
- package/dist/hooks/useSpaces/index.d.ts +95 -0
- package/dist/hooks/useSpaces/index.js +625 -0
- package/dist/hooks/useSpaces/themes/blueprint.d.ts +3 -0
- package/dist/hooks/useSpaces/themes/blueprint.js +96 -0
- package/dist/hooks/useSpaces/themes/default.d.ts +3 -0
- package/dist/hooks/useSpaces/themes/default.js +96 -0
- package/dist/hooks/{useRoomBuilder/themes.d.ts → useSpaces/themes/index.d.ts} +3 -4
- package/dist/hooks/useSpaces/themes/index.js +21 -0
- package/dist/hooks/useSpaces/themes/light.d.ts +3 -0
- package/dist/hooks/useSpaces/themes/light.js +96 -0
- package/dist/hooks/useSpaces/types.d.ts +378 -0
- package/dist/hooks/useSpaces/types.js +54 -0
- package/dist/hooks/useSpaces/validators/areWallsDuplicated.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/areWallsDuplicated.js +61 -0
- package/dist/hooks/useSpaces/validators/areWallsIntersecting.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/areWallsIntersecting.js +42 -0
- package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.js +52 -0
- package/dist/hooks/useSpaces/validators/areWallsTooShort.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/areWallsTooShort.js +37 -0
- package/dist/hooks/useSpaces/validators/index.d.ts +15 -0
- package/dist/hooks/useSpaces/validators/index.js +40 -0
- package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.js +31 -0
- package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.js +19 -0
- package/dist/hooks/useSpaces/validators/isLineTooShort.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isLineTooShort.js +26 -0
- package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.d.ts +4 -0
- package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.js +19 -0
- package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.js +19 -0
- package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.js +41 -0
- package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.js +54 -0
- package/dist/hooks/useSpaces/validators/isWallTooShort.d.ts +3 -0
- package/dist/hooks/useSpaces/validators/isWallTooShort.js +10 -0
- package/dist/hooks/{useRoomBuilder → useSpaces/validators}/messaging.js +1 -1
- package/dist/hooks/useWishlist/index.d.ts +1 -1
- package/dist/hooks/useZoom/index.d.ts +1 -1
- package/dist/http/assets.d.ts +1 -1
- package/dist/http/orders.d.ts +1 -1
- package/dist/icons/AngleSnapping.d.ts +3 -0
- package/dist/icons/AngleSnapping.js +28 -0
- package/dist/icons/Boundary.d.ts +3 -0
- package/dist/icons/Boundary.js +21 -0
- package/dist/icons/Center.d.ts +3 -0
- package/dist/icons/Center.js +24 -0
- package/dist/icons/Draw.js +3 -3
- package/dist/icons/GridSnapping.d.ts +3 -0
- package/dist/icons/GridSnapping.js +28 -0
- package/dist/icons/LayoutAlt.d.ts +3 -0
- package/dist/icons/LayoutAlt.js +21 -0
- package/dist/icons/Magnet.d.ts +3 -0
- package/dist/icons/Magnet.js +27 -0
- package/dist/icons/Player3D.d.ts +3 -0
- package/dist/icons/Player3D.js +21 -0
- package/dist/icons/RulerBlank.d.ts +3 -0
- package/dist/icons/RulerBlank.js +25 -0
- package/dist/icons/RulerDetailed.d.ts +3 -0
- package/dist/icons/RulerDetailed.js +27 -0
- package/dist/icons/Save.d.ts +3 -0
- package/dist/icons/Save.js +21 -0
- package/dist/icons/Spinner.d.ts +2 -2
- package/dist/icons/UnitCm.d.ts +3 -0
- package/dist/icons/UnitCm.js +22 -0
- package/dist/icons/UnitFeet.d.ts +3 -0
- package/dist/icons/UnitFeet.js +22 -0
- package/dist/icons/UnitInch.d.ts +3 -0
- package/dist/icons/UnitInch.js +22 -0
- package/dist/icons/UnitMeter.d.ts +3 -0
- package/dist/icons/UnitMeter.js +21 -0
- package/dist/icons/Window.js +4 -4
- package/dist/icons/index.js +28 -0
- package/dist/index.d.ts +17 -2
- package/dist/index.js +35 -5
- package/dist/store/attributes.d.ts +4 -3
- package/dist/store/attributes.js +1 -1
- package/dist/store/index.d.ts +43 -12
- package/dist/store/index.js +3 -1
- package/dist/store/price.d.ts +1 -1
- package/dist/store/price.js +1 -1
- package/dist/store/product.d.ts +2 -2
- package/dist/store/product.js +5 -8
- package/dist/store/spaces.d.ts +74 -0
- package/dist/store/spaces.js +354 -0
- package/dist/store/translations.d.ts +1 -1
- package/dist/store/translations.js +1 -1
- package/dist/store/treble.d.ts +2 -2
- package/dist/store/treble.js +15 -22
- package/dist/store/wishlist.d.ts +4 -22
- package/dist/store/wishlist.js +1 -1
- package/dist/types.d.ts +20 -18
- package/dist/types.js +9 -9
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +3 -3
- package/package.json +1 -1
- package/dist/hooks/useRoomBuilder/RoomBuilderState.d.ts +0 -95
- package/dist/hooks/useRoomBuilder/RoomBuilderState.js +0 -1237
- package/dist/hooks/useRoomBuilder/constants.d.ts +0 -41
- package/dist/hooks/useRoomBuilder/constants.js +0 -48
- package/dist/hooks/useRoomBuilder/dataHandlers.d.ts +0 -18
- package/dist/hooks/useRoomBuilder/dataHandlers.js +0 -187
- package/dist/hooks/useRoomBuilder/draw.d.ts +0 -55
- package/dist/hooks/useRoomBuilder/draw.js +0 -573
- package/dist/hooks/useRoomBuilder/findLoops.d.ts +0 -5
- package/dist/hooks/useRoomBuilder/geometry.d.ts +0 -33
- package/dist/hooks/useRoomBuilder/geometry.js +0 -325
- package/dist/hooks/useRoomBuilder/index.d.ts +0 -40
- package/dist/hooks/useRoomBuilder/index.js +0 -303
- package/dist/hooks/useRoomBuilder/themes.js +0 -273
- package/dist/hooks/useRoomBuilder/types.d.ts +0 -238
- package/dist/hooks/useRoomBuilder/types.js +0 -36
- package/dist/hooks/useRoomBuilder/validators.d.ts +0 -36
- package/dist/hooks/useRoomBuilder/validators.js +0 -362
- /package/dist/hooks/{useRoomBuilder → useSpaces/validators}/messaging.d.ts +0 -0
|
@@ -0,0 +1,625 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var react_1 = require("react");
|
|
54
|
+
var types_1 = require("./types");
|
|
55
|
+
var types_2 = require("./types");
|
|
56
|
+
var useConfigurator_1 = __importDefault(require("../useConfigurator"));
|
|
57
|
+
var constants_1 = require("./constants");
|
|
58
|
+
var themes_1 = require("./themes");
|
|
59
|
+
var SpacesLayout_1 = __importDefault(require("./SpacesLayout"));
|
|
60
|
+
var store_1 = require("../../store");
|
|
61
|
+
var spaces_1 = require("../../store/spaces");
|
|
62
|
+
var useThreekitInitStatus_1 = __importDefault(require("../useThreekitInitStatus"));
|
|
63
|
+
var getLocalTouchPoint = function (touch, rect) {
|
|
64
|
+
if (touch.clientY < rect.top ||
|
|
65
|
+
rect.bottom < touch.clientY ||
|
|
66
|
+
touch.clientX < rect.left ||
|
|
67
|
+
rect.right < touch.clientX)
|
|
68
|
+
return undefined;
|
|
69
|
+
return [touch.clientX - rect.left, touch.clientY - rect.top];
|
|
70
|
+
};
|
|
71
|
+
var useSpaces = function (props) {
|
|
72
|
+
var _a, _b, _c, _d, _e;
|
|
73
|
+
var attributesState = (0, useConfigurator_1.default)()[0];
|
|
74
|
+
var hasLoaded = (0, useThreekitInitStatus_1.default)();
|
|
75
|
+
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
76
|
+
var layouts = (0, store_1.useThreekitSelector)(spaces_1.getLayouts);
|
|
77
|
+
var hasInitialized = (0, store_1.useThreekitSelector)(spaces_1.getInitialized);
|
|
78
|
+
var zoom = (0, store_1.useThreekitSelector)(spaces_1.getZoom);
|
|
79
|
+
var unit = (0, store_1.useThreekitSelector)(spaces_1.getUnit);
|
|
80
|
+
var translation = (0, store_1.useThreekitSelector)(spaces_1.getTranslation);
|
|
81
|
+
var modeValue = (0, store_1.useThreekitSelector)(spaces_1.getMode);
|
|
82
|
+
var showDimensions = (0, store_1.useThreekitSelector)(spaces_1.getShowDimensions);
|
|
83
|
+
var angleSnappingEnabled = (0, store_1.useThreekitSelector)(spaces_1.getAngleSnappingEnabled);
|
|
84
|
+
var guideSnappingEnabled = (0, store_1.useThreekitSelector)(spaces_1.getGuideSnappingEnabled);
|
|
85
|
+
var gridSnappingEnabled = (0, store_1.useThreekitSelector)(spaces_1.getGridSnappingEnabled);
|
|
86
|
+
var wallMode = (0, store_1.useThreekitSelector)(spaces_1.getWallMode);
|
|
87
|
+
var _f = (0, react_1.useState)(null), selectedElement = _f[0], setSelectedElement = _f[1];
|
|
88
|
+
var _g = (0, react_1.useState)(false), pendingStatus = _g[0], setPendingStatus = _g[1];
|
|
89
|
+
var canvasRef = (0, react_1.useRef)(null);
|
|
90
|
+
var selectElementPending = (0, react_1.useRef)(null);
|
|
91
|
+
var translationAnchorRef = (0, react_1.useRef)(null);
|
|
92
|
+
var prevStateRef = (0, react_1.useRef)('');
|
|
93
|
+
var attributeNames = Object.assign(constants_1.ATTRIBUTE_NAME_DEFAULTS, props.attributes);
|
|
94
|
+
var spacesRef = (0, react_1.useRef)(null);
|
|
95
|
+
var drawSpaces = function () { var _a; return (_a = spacesRef.current) === null || _a === void 0 ? void 0 : _a.drawSpaces(canvasRef.current); };
|
|
96
|
+
(0, react_1.useEffect)(function () {
|
|
97
|
+
if (!hasLoaded)
|
|
98
|
+
return;
|
|
99
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
100
|
+
var parameters, _a;
|
|
101
|
+
var _b;
|
|
102
|
+
return __generator(this, function (_c) {
|
|
103
|
+
switch (_c.label) {
|
|
104
|
+
case 0:
|
|
105
|
+
parameters = props.config
|
|
106
|
+
? Object.assign({}, props.config.unit ? { unit: props.config.unit } : undefined, props.config.showDimensions
|
|
107
|
+
? { showDimensions: props.config.showDimensions }
|
|
108
|
+
: undefined, 'zoomDefault' in props.config
|
|
109
|
+
? { zoomDefault: props.config.zoomDefault }
|
|
110
|
+
: undefined, props.config.translateDefault
|
|
111
|
+
? { translateDefault: props.config.translateDefault }
|
|
112
|
+
: undefined, 'enableAngleSnapping' in props.config
|
|
113
|
+
? { enableAngleSnapping: props.config.enableAngleSnapping }
|
|
114
|
+
: undefined, 'enableGridSnapping' in props.config
|
|
115
|
+
? { enableGridSnapping: props.config.enableGridSnapping }
|
|
116
|
+
: undefined, 'enableGuideSnapping' in props.config
|
|
117
|
+
? { enableGridSnapping: props.config.enableGuideSnapping }
|
|
118
|
+
: undefined)
|
|
119
|
+
: {};
|
|
120
|
+
_a = spacesRef;
|
|
121
|
+
return [4, dispatch((0, spaces_1.initSpaces)({
|
|
122
|
+
parameters: __assign(__assign({}, parameters), { theme: (_b = props.config) === null || _b === void 0 ? void 0 : _b.theme }),
|
|
123
|
+
layoutIds: props.layouts || [],
|
|
124
|
+
attributeNames: attributeNames,
|
|
125
|
+
canvasDimensions: canvasRef.current
|
|
126
|
+
? [canvasRef.current.width, canvasRef.current.height]
|
|
127
|
+
: undefined,
|
|
128
|
+
setPendingStatus: setPendingStatus,
|
|
129
|
+
}))];
|
|
130
|
+
case 1:
|
|
131
|
+
_a.current = _c.sent();
|
|
132
|
+
drawSpaces();
|
|
133
|
+
return [2];
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}); })();
|
|
137
|
+
}, [hasLoaded]);
|
|
138
|
+
if (spacesRef.current) {
|
|
139
|
+
var attributesDelinked = void 0;
|
|
140
|
+
if (JSON.stringify(attributesState) !== prevStateRef.current) {
|
|
141
|
+
prevStateRef.current = JSON.stringify(attributesState);
|
|
142
|
+
attributesDelinked = JSON.parse(JSON.stringify(attributesState));
|
|
143
|
+
}
|
|
144
|
+
(_a = spacesRef.current) === null || _a === void 0 ? void 0 : _a.sync({
|
|
145
|
+
attributesState: attributesDelinked,
|
|
146
|
+
canvasDimensions: canvasRef.current
|
|
147
|
+
? [canvasRef.current.width, canvasRef.current.height]
|
|
148
|
+
: undefined,
|
|
149
|
+
angleSnappingEnabled: angleSnappingEnabled,
|
|
150
|
+
gridSnappingEnabled: gridSnappingEnabled,
|
|
151
|
+
guideSnappingEnabled: guideSnappingEnabled,
|
|
152
|
+
showDimensions: showDimensions,
|
|
153
|
+
unit: unit,
|
|
154
|
+
zoom: spacesRef.current.zoom !== zoom ? zoom : undefined,
|
|
155
|
+
translate: translation,
|
|
156
|
+
wallMode: {
|
|
157
|
+
value: wallMode.value,
|
|
158
|
+
assetId: wallMode.assetId,
|
|
159
|
+
},
|
|
160
|
+
selectedElement: selectedElement
|
|
161
|
+
? {
|
|
162
|
+
type: selectedElement.path[0],
|
|
163
|
+
index: selectedElement.path[1],
|
|
164
|
+
}
|
|
165
|
+
: null,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
(0, react_1.useEffect)(function () {
|
|
169
|
+
if (!canvasRef.current)
|
|
170
|
+
return;
|
|
171
|
+
if (pendingStatus)
|
|
172
|
+
canvasRef.current.style.cursor = 'progress';
|
|
173
|
+
else
|
|
174
|
+
canvasRef.current.style.cursor = 'default';
|
|
175
|
+
}, [pendingStatus, canvasRef.current]);
|
|
176
|
+
(0, react_1.useEffect)(function () {
|
|
177
|
+
var _a, _b;
|
|
178
|
+
if (pendingStatus)
|
|
179
|
+
return;
|
|
180
|
+
if (canvasRef.current) {
|
|
181
|
+
canvasRef.current.addEventListener('mousedown', handleDrawWallStart);
|
|
182
|
+
canvasRef.current.addEventListener('touchstart', handleDrawWallStart);
|
|
183
|
+
canvasRef.current.addEventListener('mousemove', handleDrawWallMouseMove);
|
|
184
|
+
canvasRef.current.addEventListener('touchmove', handleDrawWallMouseMove);
|
|
185
|
+
document.addEventListener('mouseup', handleDrawWallFinish);
|
|
186
|
+
document.addEventListener('touchend', handleDrawWallFinish);
|
|
187
|
+
canvasRef.current.addEventListener('mousemove', handleHover);
|
|
188
|
+
canvasRef.current.addEventListener('mousedown', handleSelectElement);
|
|
189
|
+
canvasRef.current.addEventListener('touchstart', handleSelectElement);
|
|
190
|
+
canvasRef.current.addEventListener('mousemove', handleMoveSelectedElement);
|
|
191
|
+
canvasRef.current.addEventListener('touchmove', handleMoveSelectedElement);
|
|
192
|
+
if (!((_a = props.config) === null || _a === void 0 ? void 0 : _a.translateDisabled)) {
|
|
193
|
+
canvasRef.current.addEventListener('mousemove', handleMoveCanvas);
|
|
194
|
+
canvasRef.current.addEventListener('touchmove', handleMoveCanvas);
|
|
195
|
+
}
|
|
196
|
+
document.addEventListener('mouseup', handleFinishMove);
|
|
197
|
+
document.addEventListener('touchend', handleFinishMove);
|
|
198
|
+
if (!((_b = props.config) === null || _b === void 0 ? void 0 : _b.zoomDisabled))
|
|
199
|
+
canvasRef.current.addEventListener('wheel', handleScrollToZoom);
|
|
200
|
+
}
|
|
201
|
+
return function () {
|
|
202
|
+
var _a, _b;
|
|
203
|
+
if (canvasRef.current) {
|
|
204
|
+
canvasRef.current.removeEventListener('mousedown', handleDrawWallStart);
|
|
205
|
+
canvasRef.current.removeEventListener('touchstart', handleDrawWallStart);
|
|
206
|
+
canvasRef.current.removeEventListener('mousemove', handleDrawWallMouseMove);
|
|
207
|
+
canvasRef.current.removeEventListener('touchmove', handleDrawWallMouseMove);
|
|
208
|
+
document.removeEventListener('mouseup', handleDrawWallFinish);
|
|
209
|
+
document.removeEventListener('touchend', handleDrawWallFinish);
|
|
210
|
+
canvasRef.current.removeEventListener('mousemove', handleHover);
|
|
211
|
+
canvasRef.current.removeEventListener('mousedown', handleSelectElement);
|
|
212
|
+
canvasRef.current.removeEventListener('touchstart', handleSelectElement);
|
|
213
|
+
canvasRef.current.removeEventListener('mousemove', handleMoveSelectedElement);
|
|
214
|
+
canvasRef.current.removeEventListener('touchmove', handleMoveSelectedElement);
|
|
215
|
+
if (!((_a = props.config) === null || _a === void 0 ? void 0 : _a.translateDisabled)) {
|
|
216
|
+
canvasRef.current.removeEventListener('mousemove', handleMoveCanvas);
|
|
217
|
+
canvasRef.current.removeEventListener('touchmove', handleMoveCanvas);
|
|
218
|
+
}
|
|
219
|
+
document.removeEventListener('mouseup', handleFinishMove);
|
|
220
|
+
document.removeEventListener('touchend', handleFinishMove);
|
|
221
|
+
if (!((_b = props.config) === null || _b === void 0 ? void 0 : _b.zoomDisabled))
|
|
222
|
+
canvasRef.current.removeEventListener('wheel', handleScrollToZoom);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
});
|
|
226
|
+
(0, react_1.useEffect)(function () {
|
|
227
|
+
if (hasInitialized)
|
|
228
|
+
drawSpaces();
|
|
229
|
+
});
|
|
230
|
+
var updateZoom = function (value) {
|
|
231
|
+
if (!spacesRef.current)
|
|
232
|
+
return;
|
|
233
|
+
var prevZoom = spacesRef.current.zoom;
|
|
234
|
+
spacesRef.current.zoom = value;
|
|
235
|
+
if (prevZoom === spacesRef.current.zoom)
|
|
236
|
+
return;
|
|
237
|
+
dispatch((0, spaces_1.setZoom)(spacesRef.current.zoom));
|
|
238
|
+
drawSpaces();
|
|
239
|
+
};
|
|
240
|
+
var updateUnit = function (unit) {
|
|
241
|
+
if (!spacesRef.current)
|
|
242
|
+
return;
|
|
243
|
+
spacesRef.current.unit = unit;
|
|
244
|
+
dispatch((0, spaces_1.setUnit)(spacesRef.current.unit));
|
|
245
|
+
};
|
|
246
|
+
var handleRecenter = function (zoomToFit) {
|
|
247
|
+
if (!spacesRef.current)
|
|
248
|
+
return;
|
|
249
|
+
spacesRef.current.centerSpace(canvasRef.current, zoomToFit);
|
|
250
|
+
dispatch((0, spaces_1.setZoom)(spacesRef.current.zoom));
|
|
251
|
+
dispatch((0, spaces_1.setTranslation)(spacesRef.current.translate));
|
|
252
|
+
};
|
|
253
|
+
var handleSelectModeHover = function (canvas, cursorPoint) {
|
|
254
|
+
if (!spacesRef.current)
|
|
255
|
+
return;
|
|
256
|
+
if (spacesRef.current.activeElement !== null)
|
|
257
|
+
return;
|
|
258
|
+
if (translationAnchorRef.current)
|
|
259
|
+
return;
|
|
260
|
+
spacesRef.current.highlightElementIfInProximity(canvas, cursorPoint);
|
|
261
|
+
};
|
|
262
|
+
var handleSelectElement = function (e) {
|
|
263
|
+
var _a;
|
|
264
|
+
if (!spacesRef.current)
|
|
265
|
+
return;
|
|
266
|
+
if (!canvasRef.current)
|
|
267
|
+
return;
|
|
268
|
+
if (modeValue !== types_2.IModes.SELECT)
|
|
269
|
+
return;
|
|
270
|
+
var cursorPoint;
|
|
271
|
+
if ('offsetX' in e && 'offsetY' in e)
|
|
272
|
+
cursorPoint = [e.offsetX, e.offsetY];
|
|
273
|
+
else {
|
|
274
|
+
var localTouchPoint = getLocalTouchPoint(e.touches[0], canvasRef.current.getBoundingClientRect());
|
|
275
|
+
if (!localTouchPoint)
|
|
276
|
+
return;
|
|
277
|
+
cursorPoint = localTouchPoint;
|
|
278
|
+
}
|
|
279
|
+
spacesRef.current.selectElementIfInProximity(canvasRef.current, cursorPoint);
|
|
280
|
+
var element = spacesRef.current.getElementUiAtPoint(cursorPoint);
|
|
281
|
+
if (!element) {
|
|
282
|
+
if (selectedElement !== null)
|
|
283
|
+
setSelectedElement(null);
|
|
284
|
+
if (!((_a = props.config) === null || _a === void 0 ? void 0 : _a.translateDisabled) && !spacesRef.current.activeElement)
|
|
285
|
+
translationAnchorRef.current = cursorPoint;
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
if (spacesRef.current.activeElement ||
|
|
289
|
+
(selectedElement &&
|
|
290
|
+
JSON.stringify(element.path) !== JSON.stringify(selectedElement.path)))
|
|
291
|
+
setSelectedElement(null);
|
|
292
|
+
selectElementPending.current = element;
|
|
293
|
+
};
|
|
294
|
+
var handleMoveSelectedElement = function (e) {
|
|
295
|
+
if (!spacesRef.current)
|
|
296
|
+
return;
|
|
297
|
+
if (modeValue !== types_2.IModes.SELECT)
|
|
298
|
+
return;
|
|
299
|
+
if (!canvasRef.current)
|
|
300
|
+
return;
|
|
301
|
+
var point;
|
|
302
|
+
if ('offsetX' in e && 'offsetY' in e)
|
|
303
|
+
point = [e.offsetX, e.offsetY];
|
|
304
|
+
else {
|
|
305
|
+
var localTouchPoint = getLocalTouchPoint(e.touches[0], canvasRef.current.getBoundingClientRect());
|
|
306
|
+
if (!localTouchPoint)
|
|
307
|
+
return;
|
|
308
|
+
point = localTouchPoint;
|
|
309
|
+
}
|
|
310
|
+
spacesRef.current.moveActiveElement(canvasRef.current, point);
|
|
311
|
+
selectElementPending.current = null;
|
|
312
|
+
};
|
|
313
|
+
var handleMoveCanvas = function (e) {
|
|
314
|
+
if (!spacesRef.current)
|
|
315
|
+
return;
|
|
316
|
+
if (modeValue !== types_2.IModes.SELECT)
|
|
317
|
+
return;
|
|
318
|
+
if (!canvasRef.current)
|
|
319
|
+
return;
|
|
320
|
+
if (spacesRef.current.selectedElement || !translationAnchorRef.current)
|
|
321
|
+
return;
|
|
322
|
+
var point;
|
|
323
|
+
if ('offsetX' in e && 'offsetY' in e)
|
|
324
|
+
point = [e.offsetX, e.offsetY];
|
|
325
|
+
else {
|
|
326
|
+
var localTouchPoint = getLocalTouchPoint(e.touches[0], canvasRef.current.getBoundingClientRect());
|
|
327
|
+
if (!localTouchPoint)
|
|
328
|
+
return;
|
|
329
|
+
point = localTouchPoint;
|
|
330
|
+
}
|
|
331
|
+
spacesRef.current.translate = [
|
|
332
|
+
spacesRef.current.translate[0] +
|
|
333
|
+
point[0] -
|
|
334
|
+
translationAnchorRef.current[0],
|
|
335
|
+
spacesRef.current.translate[1] +
|
|
336
|
+
point[1] -
|
|
337
|
+
translationAnchorRef.current[1],
|
|
338
|
+
];
|
|
339
|
+
translationAnchorRef.current = point;
|
|
340
|
+
drawSpaces();
|
|
341
|
+
};
|
|
342
|
+
var handleFinishMove = function (e) {
|
|
343
|
+
var _a;
|
|
344
|
+
if (!spacesRef.current)
|
|
345
|
+
return;
|
|
346
|
+
if (modeValue !== types_2.IModes.SELECT)
|
|
347
|
+
return;
|
|
348
|
+
if (!canvasRef.current)
|
|
349
|
+
return;
|
|
350
|
+
if (!((_a = canvasRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
|
|
351
|
+
spacesRef.current.cancelMoveActiveElement(canvasRef.current);
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
spacesRef.current.finishMoveActiveElement(canvasRef.current);
|
|
355
|
+
if (selectElementPending.current) {
|
|
356
|
+
setSelectedElement(selectElementPending.current);
|
|
357
|
+
selectElementPending.current = null;
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
if (translationAnchorRef.current) {
|
|
361
|
+
translationAnchorRef.current = null;
|
|
362
|
+
dispatch((0, spaces_1.setTranslation)(spacesRef.current.translate));
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
var handleDrawModeHover = function (canvas, cursorPoint) {
|
|
366
|
+
if (!spacesRef.current)
|
|
367
|
+
return;
|
|
368
|
+
if (spacesRef.current.isDrawWallActive)
|
|
369
|
+
return;
|
|
370
|
+
spacesRef.current.showGuideAtPoint(canvas, cursorPoint);
|
|
371
|
+
};
|
|
372
|
+
var handleDrawWallStart = function (e) {
|
|
373
|
+
if (!spacesRef.current || !canvasRef.current)
|
|
374
|
+
return;
|
|
375
|
+
if (modeValue !== types_2.IModes.DRAW)
|
|
376
|
+
return;
|
|
377
|
+
var startPoint;
|
|
378
|
+
if ('offsetX' in e && 'offsetY' in e)
|
|
379
|
+
startPoint = [e.offsetX, e.offsetY];
|
|
380
|
+
else {
|
|
381
|
+
var localTouchPoint = getLocalTouchPoint(e.touches[0], canvasRef.current.getBoundingClientRect());
|
|
382
|
+
if (!localTouchPoint)
|
|
383
|
+
return;
|
|
384
|
+
startPoint = localTouchPoint;
|
|
385
|
+
}
|
|
386
|
+
spacesRef.current.startDrawNewWall(startPoint);
|
|
387
|
+
};
|
|
388
|
+
var handleDrawWallMouseMove = function (e) {
|
|
389
|
+
if (!spacesRef.current || !canvasRef.current)
|
|
390
|
+
return;
|
|
391
|
+
if (modeValue !== types_2.IModes.DRAW)
|
|
392
|
+
return;
|
|
393
|
+
if (!spacesRef.current.isDrawWallActive)
|
|
394
|
+
return;
|
|
395
|
+
var point;
|
|
396
|
+
if ('offsetX' in e && 'offsetY' in e)
|
|
397
|
+
point = [e.offsetX, e.offsetY];
|
|
398
|
+
else {
|
|
399
|
+
var localTouchPoint = getLocalTouchPoint(e.touches[0], canvasRef.current.getBoundingClientRect());
|
|
400
|
+
if (!localTouchPoint)
|
|
401
|
+
return;
|
|
402
|
+
point = localTouchPoint;
|
|
403
|
+
}
|
|
404
|
+
spacesRef.current.drawNewWall(canvasRef.current, point);
|
|
405
|
+
};
|
|
406
|
+
var handleDrawWallFinish = function (e) {
|
|
407
|
+
var _a;
|
|
408
|
+
if (!spacesRef.current || !canvasRef.current)
|
|
409
|
+
return;
|
|
410
|
+
if (modeValue !== types_2.IModes.DRAW)
|
|
411
|
+
return;
|
|
412
|
+
if (!((_a = canvasRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
|
|
413
|
+
spacesRef.current.cancelDrawNewWall(canvasRef.current);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
spacesRef.current.finishDrawNewWall(canvasRef.current);
|
|
417
|
+
};
|
|
418
|
+
var handleScrollToZoom = function (e) {
|
|
419
|
+
var _a;
|
|
420
|
+
if (!canvasRef.current)
|
|
421
|
+
return;
|
|
422
|
+
var zoomSensitivity = ((_a = props.config) === null || _a === void 0 ? void 0 : _a.zoomSensitivity) || constants_1.ZOOM_SENSITIVITY;
|
|
423
|
+
updateZoom(-1 * e.deltaY * zoomSensitivity);
|
|
424
|
+
e.preventDefault();
|
|
425
|
+
};
|
|
426
|
+
var handleHover = function (e) {
|
|
427
|
+
if (!canvasRef.current)
|
|
428
|
+
return;
|
|
429
|
+
var cursorPoint = [e.offsetX, e.offsetY];
|
|
430
|
+
if (modeValue === types_2.IModes.DRAW)
|
|
431
|
+
handleDrawModeHover(canvasRef.current, cursorPoint);
|
|
432
|
+
else if (modeValue === types_2.IModes.SELECT)
|
|
433
|
+
handleSelectModeHover(canvasRef.current, cursorPoint);
|
|
434
|
+
};
|
|
435
|
+
var prepFeatureAttributeForOutput = function (type, attribute) {
|
|
436
|
+
if (!attribute)
|
|
437
|
+
return undefined;
|
|
438
|
+
var values = attribute.values.map(function (val) { return (__assign(__assign({}, val), { add: function (addToWallIndex, feature) {
|
|
439
|
+
var _a;
|
|
440
|
+
return (_a = spacesRef.current) === null || _a === void 0 ? void 0 : _a.addFeature(type, addToWallIndex, __assign({ assetId: val.assetId }, (feature || {})));
|
|
441
|
+
} })); });
|
|
442
|
+
var value = attribute.value.map(function (val, i) { return (__assign(__assign({}, val), { delete: function () { var _a; return (_a = spacesRef.current) === null || _a === void 0 ? void 0 : _a.deleteFeature(type, i); } })); });
|
|
443
|
+
return __assign(__assign({}, attribute), { values: values, value: value });
|
|
444
|
+
};
|
|
445
|
+
var prepWallAttributeForOutput = function (attribute) {
|
|
446
|
+
if (!attribute)
|
|
447
|
+
return undefined;
|
|
448
|
+
var values = attribute.values.map(function (val) { return (__assign({}, val)); });
|
|
449
|
+
var value = attribute.value.map(function (val, i) { return (__assign(__assign({}, val), { delete: function () { var _a; return (_a = spacesRef.current) === null || _a === void 0 ? void 0 : _a.deleteWall(i); }, splitWall: function (offset) { var _a; return (_a = spacesRef.current) === null || _a === void 0 ? void 0 : _a.splitWallAtOffset(i, offset); } })); });
|
|
450
|
+
return __assign(__assign({}, attribute), { values: values, value: value });
|
|
451
|
+
};
|
|
452
|
+
var getElementFromAttributeName = function (attributeName) {
|
|
453
|
+
var elementAttr = Object.entries(attributeNames).find(function (_a) {
|
|
454
|
+
var _ = _a[0], attrName = _a[1];
|
|
455
|
+
return attrName === attributeName;
|
|
456
|
+
});
|
|
457
|
+
if (!elementAttr)
|
|
458
|
+
return;
|
|
459
|
+
return elementAttr[0];
|
|
460
|
+
};
|
|
461
|
+
var handleSetMode = function (mode) {
|
|
462
|
+
if (mode === modeValue)
|
|
463
|
+
return;
|
|
464
|
+
dispatch((0, spaces_1.setMode)(mode));
|
|
465
|
+
setSelectedElement(null);
|
|
466
|
+
};
|
|
467
|
+
var handleReset = function () {
|
|
468
|
+
var _a;
|
|
469
|
+
(_a = spacesRef.current) === null || _a === void 0 ? void 0 : _a.deleteAll();
|
|
470
|
+
setSelectedElement(null);
|
|
471
|
+
};
|
|
472
|
+
var handleDeleteElement = function (type, index) {
|
|
473
|
+
var _a;
|
|
474
|
+
var elementType = type;
|
|
475
|
+
if (Object.values(attributeNames).includes(type)) {
|
|
476
|
+
var updatedType = getElementFromAttributeName(type);
|
|
477
|
+
if (!updatedType)
|
|
478
|
+
return;
|
|
479
|
+
elementType = updatedType;
|
|
480
|
+
}
|
|
481
|
+
(_a = spacesRef.current) === null || _a === void 0 ? void 0 : _a.deleteElement(elementType, index);
|
|
482
|
+
setSelectedElement(null);
|
|
483
|
+
};
|
|
484
|
+
var handleSetShowDimensions = function (val) {
|
|
485
|
+
dispatch((0, spaces_1.setShowDimensions)(val));
|
|
486
|
+
};
|
|
487
|
+
var handleToggleAngleSnapping = function (val) {
|
|
488
|
+
if (val === undefined)
|
|
489
|
+
dispatch((0, spaces_1.setAngleSnappingEnabled)(!angleSnappingEnabled));
|
|
490
|
+
else
|
|
491
|
+
dispatch((0, spaces_1.setAngleSnappingEnabled)(val));
|
|
492
|
+
setSelectedElement(null);
|
|
493
|
+
};
|
|
494
|
+
var handleToggleGuideSnapping = function (val) {
|
|
495
|
+
if (val === undefined)
|
|
496
|
+
dispatch((0, spaces_1.setGuideSnappingEnabled)(!guideSnappingEnabled));
|
|
497
|
+
else
|
|
498
|
+
dispatch((0, spaces_1.setGuideSnappingEnabled)(val));
|
|
499
|
+
setSelectedElement(null);
|
|
500
|
+
};
|
|
501
|
+
var handleToggleGridSnapping = function (val) {
|
|
502
|
+
if (val === undefined)
|
|
503
|
+
dispatch((0, spaces_1.setGridSnappingEnabled)(!gridSnappingEnabled));
|
|
504
|
+
else
|
|
505
|
+
dispatch((0, spaces_1.setGridSnappingEnabled)(val));
|
|
506
|
+
setSelectedElement(null);
|
|
507
|
+
};
|
|
508
|
+
var handleChangeTranslate = function (delta) {
|
|
509
|
+
if (!spacesRef.current)
|
|
510
|
+
return;
|
|
511
|
+
spacesRef.current.translate = [
|
|
512
|
+
spacesRef.current.translate[0] + delta[0],
|
|
513
|
+
spacesRef.current.translate[1] + delta[1],
|
|
514
|
+
];
|
|
515
|
+
dispatch((0, spaces_1.setTranslation)(spacesRef.current.translate));
|
|
516
|
+
};
|
|
517
|
+
return {
|
|
518
|
+
hasLoaded: hasInitialized,
|
|
519
|
+
draw: drawSpaces,
|
|
520
|
+
canvasRef: canvasRef,
|
|
521
|
+
selectedElement: selectedElement === null
|
|
522
|
+
? selectedElement
|
|
523
|
+
: __assign(__assign({}, selectedElement), { path: [
|
|
524
|
+
attributeNames[selectedElement.path[0]],
|
|
525
|
+
selectedElement.path[1],
|
|
526
|
+
], type: selectedElement.path[0], deleteElement: function () { return handleDeleteElement.apply(void 0, selectedElement.path); }, splitWall: selectedElement.path[0] !== types_2.IElements.WALL
|
|
527
|
+
? undefined
|
|
528
|
+
: function (offset) {
|
|
529
|
+
var _a;
|
|
530
|
+
return (_a = spacesRef.current) === null || _a === void 0 ? void 0 : _a.splitWallAtOffset(selectedElement.path[1], offset);
|
|
531
|
+
}, addFeature: selectedElement.path[0] !== types_2.IElements.WALL
|
|
532
|
+
? undefined
|
|
533
|
+
: function (type, feature) {
|
|
534
|
+
var _a;
|
|
535
|
+
return (_a = spacesRef.current) === null || _a === void 0 ? void 0 : _a.addFeature(type, selectedElement.path[1], feature);
|
|
536
|
+
} }),
|
|
537
|
+
mode: {
|
|
538
|
+
value: modeValue,
|
|
539
|
+
options: [types_2.IModes.SELECT, types_2.IModes.DRAW].map(function (el) { return ({
|
|
540
|
+
value: el,
|
|
541
|
+
label: el,
|
|
542
|
+
selected: modeValue === el,
|
|
543
|
+
handleSelect: function () { return handleSetMode(el); },
|
|
544
|
+
}); }),
|
|
545
|
+
handleChange: handleSetMode,
|
|
546
|
+
},
|
|
547
|
+
dimensions: {
|
|
548
|
+
value: showDimensions,
|
|
549
|
+
options: [
|
|
550
|
+
types_1.IDimensionOptions.NONE,
|
|
551
|
+
types_1.IDimensionOptions.DEFAULT,
|
|
552
|
+
types_1.IDimensionOptions.DETAILED,
|
|
553
|
+
].map(function (el) { return ({
|
|
554
|
+
value: el,
|
|
555
|
+
label: el,
|
|
556
|
+
selected: showDimensions === el,
|
|
557
|
+
handleSelect: function () { return handleSetShowDimensions(el); },
|
|
558
|
+
}); }),
|
|
559
|
+
handleChange: handleSetShowDimensions,
|
|
560
|
+
},
|
|
561
|
+
angleSnapping: {
|
|
562
|
+
enabled: angleSnappingEnabled,
|
|
563
|
+
handleToggle: handleToggleAngleSnapping,
|
|
564
|
+
},
|
|
565
|
+
guideSnapping: {
|
|
566
|
+
enabled: guideSnappingEnabled,
|
|
567
|
+
handleToggle: handleToggleGuideSnapping,
|
|
568
|
+
},
|
|
569
|
+
gridSnapping: {
|
|
570
|
+
enabled: gridSnappingEnabled,
|
|
571
|
+
handleToggle: handleToggleGridSnapping,
|
|
572
|
+
},
|
|
573
|
+
zoom: {
|
|
574
|
+
min: (_c = (_b = spacesRef.current) === null || _b === void 0 ? void 0 : _b.zoomMin) !== null && _c !== void 0 ? _c : constants_1.ZOOM_MIN,
|
|
575
|
+
max: (_e = (_d = spacesRef.current) === null || _d === void 0 ? void 0 : _d.zoomMax) !== null && _e !== void 0 ? _e : constants_1.ZOOM_MAX,
|
|
576
|
+
value: zoom,
|
|
577
|
+
handleChange: updateZoom,
|
|
578
|
+
},
|
|
579
|
+
unit: {
|
|
580
|
+
value: unit,
|
|
581
|
+
options: [types_2.IUnits.FEET, types_2.IUnits.METER, types_2.IUnits.INCH, types_2.IUnits.CM].map(function (el) { return ({
|
|
582
|
+
value: el,
|
|
583
|
+
label: el,
|
|
584
|
+
selected: unit === el,
|
|
585
|
+
handleSelect: function () { return updateUnit(el); },
|
|
586
|
+
}); }),
|
|
587
|
+
handleChange: updateUnit,
|
|
588
|
+
},
|
|
589
|
+
wallMode: {
|
|
590
|
+
value: wallMode.value,
|
|
591
|
+
options: wallMode.options.map(function (mode) { return ({
|
|
592
|
+
value: mode,
|
|
593
|
+
label: constants_1.wallModeLabels[mode],
|
|
594
|
+
selected: mode === wallMode.value,
|
|
595
|
+
handleSelect: function () { return dispatch((0, spaces_1.setWallModeValue)(mode)); },
|
|
596
|
+
}); }),
|
|
597
|
+
handleChange: function (wallMode) {
|
|
598
|
+
return dispatch((0, spaces_1.setWallModeValue)(wallMode));
|
|
599
|
+
},
|
|
600
|
+
},
|
|
601
|
+
translate: {
|
|
602
|
+
handleChange: handleChangeTranslate,
|
|
603
|
+
},
|
|
604
|
+
reset: handleReset,
|
|
605
|
+
recenter: handleRecenter,
|
|
606
|
+
deleteElement: handleDeleteElement,
|
|
607
|
+
layouts: layouts.map(function (layout) { return ({
|
|
608
|
+
label: layout.label,
|
|
609
|
+
loops: layout.loop,
|
|
610
|
+
handleSelect: function () {
|
|
611
|
+
return window.threekit.configurator.setFullConfiguration(layout.configuration);
|
|
612
|
+
},
|
|
613
|
+
}); }),
|
|
614
|
+
walls: prepWallAttributeForOutput(attributesState === null || attributesState === void 0 ? void 0 : attributesState[attributeNames[types_2.IElements.WALL]]),
|
|
615
|
+
windows: prepFeatureAttributeForOutput(types_2.IElements.WINDOW, attributesState === null || attributesState === void 0 ? void 0 : attributesState[attributeNames[types_2.IElements.WINDOW]]),
|
|
616
|
+
doors: prepFeatureAttributeForOutput(types_2.IElements.DOOR, attributesState === null || attributesState === void 0 ? void 0 : attributesState[attributeNames[types_2.IElements.DOOR]]),
|
|
617
|
+
openings: prepFeatureAttributeForOutput(types_2.IElements.OPENING, attributesState === null || attributesState === void 0 ? void 0 : attributesState[attributeNames[types_2.IElements.OPENING]]),
|
|
618
|
+
};
|
|
619
|
+
};
|
|
620
|
+
useSpaces.themes = themes_1.IThemes;
|
|
621
|
+
useSpaces.units = types_2.IUnits;
|
|
622
|
+
useSpaces.modes = types_2.IModes;
|
|
623
|
+
useSpaces.wallModes = constants_1.WallModes;
|
|
624
|
+
useSpaces.LayoutIcon = SpacesLayout_1.default;
|
|
625
|
+
exports.default = useSpaces;
|