@threekit-tools/treble 0.0.91 → 0.0.92
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 +1 -1
- package/dist/Treble/snapshot.d.ts +22 -0
- package/dist/Treble/snapshot.js +247 -0
- package/dist/Treble/snapshots.d.ts +1 -1
- package/dist/components/ThreekitProvider/index.js +3 -2
- package/dist/connection.d.ts +4 -1
- package/dist/connection.js +16 -53
- package/dist/hooks/useAttribute/index.js +1 -5
- package/dist/hooks/useSnapshot/index.d.ts +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 +164 -0
- package/dist/hooks/useSpaces/SpacesState.js +1751 -0
- package/dist/hooks/useSpaces/constants.d.ts +64 -0
- package/dist/hooks/useSpaces/constants.js +109 -0
- package/dist/hooks/useSpaces/dataHandlers.d.ts +20 -0
- package/dist/hooks/useSpaces/dataHandlers.js +254 -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 +33 -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 +10 -0
- package/dist/hooks/useSpaces/draw/drawWalls.js +88 -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/useSpaces/geometry/findLoops.js +117 -0
- 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 +82 -0
- package/dist/hooks/useSpaces/index.js +482 -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/useSpaces/themes/index.d.ts +11 -0
- 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 +339 -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/useSpaces/validators/messaging.d.ts +8 -0
- package/dist/hooks/useSpaces/validators/messaging.js +18 -0
- package/dist/icons/Player3D.d.ts +3 -0
- package/dist/icons/Player3D.js +21 -0
- package/dist/icons/Ruler copy.d.ts +3 -0
- package/dist/icons/Ruler copy.js +22 -0
- package/dist/icons/RulerBlank.d.ts +3 -0
- package/dist/icons/RulerBlank.js +25 -0
- package/dist/icons/RulerDetailed copy.d.ts +3 -0
- package/dist/icons/RulerDetailed copy.js +27 -0
- package/dist/icons/RulerDetailed.d.ts +3 -0
- package/dist/icons/RulerDetailed.js +27 -0
- package/dist/icons/types.d.ts +1 -1
- package/dist/store/attributes.d.ts +1 -1
- package/dist/store/index.d.ts +10 -31
- package/dist/store/spaces.d.ts +47 -0
- package/dist/store/spaces.js +197 -0
- package/dist/store/treble.d.ts +3 -1
- package/dist/store/treble.js +45 -30
- package/dist/store/wishlist.d.ts +20 -2
- package/dist/types.d.ts +12 -3
- package/package.json +2 -1
- package/dist/hooks/useSpaces/Canvas.d.ts +0 -37
- package/dist/hooks/useSpaces/Canvas.js +0 -199
package/dist/Treble/Treble.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ declare class Treble {
|
|
|
22
22
|
_player: IThreekitPrivatePlayer;
|
|
23
23
|
wishlist: IWishlist;
|
|
24
24
|
private _snapshots;
|
|
25
|
-
takeSnapshots: typeof snapshots['takeSnapshots'];
|
|
25
|
+
takeSnapshots: (typeof snapshots)['takeSnapshots'];
|
|
26
26
|
_debugMode: boolean;
|
|
27
27
|
constructor({ player, orgId }: ITreble);
|
|
28
28
|
createOrder: (order?: IOrder) => Promise<import("../http/orders").IOrderResponse>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type ISnapshotsCameras = undefined | string | Array<string | undefined>;
|
|
2
|
+
interface SnapshotSize {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
}
|
|
6
|
+
export interface ITakeSnapshotsConfig {
|
|
7
|
+
attributeName?: string;
|
|
8
|
+
output?: string;
|
|
9
|
+
format?: string;
|
|
10
|
+
size?: SnapshotSize;
|
|
11
|
+
filename?: string;
|
|
12
|
+
useStage?: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface IGetSnapshot {
|
|
15
|
+
size: SnapshotSize;
|
|
16
|
+
format: string;
|
|
17
|
+
}
|
|
18
|
+
declare const _default: {
|
|
19
|
+
getSnapshot: ({ size, format }: IGetSnapshot) => Promise<string>;
|
|
20
|
+
takeSnapshots: (camerasList: ISnapshotsCameras, snapshotsConfig: ITakeSnapshotsConfig) => Promise<void | string[] | Blob[] | File[] | null>;
|
|
21
|
+
};
|
|
22
|
+
export default _default;
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var api_1 = __importDefault(require("../api"));
|
|
43
|
+
var constants_1 = require("../constants");
|
|
44
|
+
var types_1 = require("../types");
|
|
45
|
+
var utils_1 = require("../utils");
|
|
46
|
+
var DEFAULT_CAMERA_CONFIG = {
|
|
47
|
+
filename: "snapshot",
|
|
48
|
+
size: { width: 1920, height: 1080 },
|
|
49
|
+
format: types_1.SNAPSHOT_FORMATS.PNG,
|
|
50
|
+
attributeName: constants_1.ATTRIBUTES_RESERVED.camera,
|
|
51
|
+
output: types_1.SNAPSHOT_OUTPUTS.BLOB,
|
|
52
|
+
useStage: false,
|
|
53
|
+
};
|
|
54
|
+
var cameraValues;
|
|
55
|
+
var getCameraValue = function (configurator, cameraAttrName) {
|
|
56
|
+
if (cameraAttrName === void 0) { cameraAttrName = constants_1.ATTRIBUTES_RESERVED.camera; }
|
|
57
|
+
var attribute = configurator
|
|
58
|
+
.getDisplayAttributes()
|
|
59
|
+
.find(function (el) { return el.name === cameraAttrName; });
|
|
60
|
+
if (!attribute)
|
|
61
|
+
return undefined;
|
|
62
|
+
return attribute.value;
|
|
63
|
+
};
|
|
64
|
+
var getCamerasMap = function (configurator, cameraAttrName) {
|
|
65
|
+
if (cameraAttrName === void 0) { cameraAttrName = constants_1.ATTRIBUTES_RESERVED.camera; }
|
|
66
|
+
if (cameraValues)
|
|
67
|
+
return cameraValues;
|
|
68
|
+
var attribute = configurator
|
|
69
|
+
.getDisplayAttributes()
|
|
70
|
+
.find(function (el) { return el.name === cameraAttrName; });
|
|
71
|
+
if (!attribute) {
|
|
72
|
+
cameraValues = {};
|
|
73
|
+
return cameraValues;
|
|
74
|
+
}
|
|
75
|
+
var cameraAttribute = attribute;
|
|
76
|
+
cameraAttribute.values.forEach(function (el) {
|
|
77
|
+
var _a;
|
|
78
|
+
var value = cameraAttribute.type === types_1.ATTRIBUTE_TYPES.ASSET
|
|
79
|
+
? { assetId: el.assetId }
|
|
80
|
+
: el.value;
|
|
81
|
+
cameraValues = Object.assign(cameraValues || {}, (_a = {},
|
|
82
|
+
_a[el.label] = value,
|
|
83
|
+
_a));
|
|
84
|
+
}, {});
|
|
85
|
+
return cameraValues;
|
|
86
|
+
};
|
|
87
|
+
var getSnapshot = function (_a) {
|
|
88
|
+
var size = _a.size, format = _a.format;
|
|
89
|
+
return window.threekit.player.snapshotAsync({
|
|
90
|
+
size: size,
|
|
91
|
+
mimeType: "image/".concat(types_1.SNAPSHOT_FORMATS[format]),
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
var getSnapshots = function (cameras, snapshotConfig) { return __awaiter(void 0, void 0, void 0, function () {
|
|
95
|
+
var attributeName, size, format, configurator, _a, camerasMap, snapshots;
|
|
96
|
+
return __generator(this, function (_b) {
|
|
97
|
+
switch (_b.label) {
|
|
98
|
+
case 0:
|
|
99
|
+
attributeName = snapshotConfig.attributeName || DEFAULT_CAMERA_CONFIG.attributeName;
|
|
100
|
+
size = snapshotConfig.size || DEFAULT_CAMERA_CONFIG.size;
|
|
101
|
+
format = snapshotConfig.format || DEFAULT_CAMERA_CONFIG.format;
|
|
102
|
+
if (!(snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.useStage)) return [3, 2];
|
|
103
|
+
return [4, window.threekit.player.getStageConfigurator()];
|
|
104
|
+
case 1:
|
|
105
|
+
_a = _b.sent();
|
|
106
|
+
return [3, 3];
|
|
107
|
+
case 2:
|
|
108
|
+
_a = window.threekit.configurator;
|
|
109
|
+
_b.label = 3;
|
|
110
|
+
case 3:
|
|
111
|
+
configurator = _a;
|
|
112
|
+
camerasMap = getCamerasMap(configurator, attributeName);
|
|
113
|
+
if (!camerasMap)
|
|
114
|
+
return [2, Promise.resolve([])];
|
|
115
|
+
snapshots = [];
|
|
116
|
+
return [2, cameras.reduce(function (snapshotPromise, camera) {
|
|
117
|
+
return snapshotPromise.then(function () {
|
|
118
|
+
return new Promise(function (resolve) { return __awaiter(void 0, void 0, void 0, function () {
|
|
119
|
+
var snapshotStr;
|
|
120
|
+
var _a;
|
|
121
|
+
return __generator(this, function (_b) {
|
|
122
|
+
switch (_b.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
if (!camera) return [3, 2];
|
|
125
|
+
return [4, configurator.setConfiguration((_a = {},
|
|
126
|
+
_a[attributeName] = camerasMap[camera],
|
|
127
|
+
_a))];
|
|
128
|
+
case 1:
|
|
129
|
+
_b.sent();
|
|
130
|
+
_b.label = 2;
|
|
131
|
+
case 2: return [4, getSnapshot({ size: size, format: format })];
|
|
132
|
+
case 3:
|
|
133
|
+
snapshotStr = _b.sent();
|
|
134
|
+
snapshots.push(snapshotStr);
|
|
135
|
+
resolve(snapshots);
|
|
136
|
+
return [2];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}); });
|
|
140
|
+
});
|
|
141
|
+
}, Promise.resolve(snapshots))];
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}); };
|
|
145
|
+
var takeSnapshots = function (camerasList, snapshotsConfig) { return __awaiter(void 0, void 0, void 0, function () {
|
|
146
|
+
var filename, size, format, attributeName, output, configurator, _a, cameras, snapshotsRaw, snapshotData, camerasMap_1, currentCamera, cameraPosition, _b, attachments, response, urlsArray, snapshotBlobs, snapshotFiles;
|
|
147
|
+
var _c;
|
|
148
|
+
return __generator(this, function (_d) {
|
|
149
|
+
switch (_d.label) {
|
|
150
|
+
case 0:
|
|
151
|
+
filename = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.filename) || DEFAULT_CAMERA_CONFIG.filename;
|
|
152
|
+
size = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.size) || DEFAULT_CAMERA_CONFIG.size;
|
|
153
|
+
format = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.format) || DEFAULT_CAMERA_CONFIG.format;
|
|
154
|
+
attributeName = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.attributeName) || DEFAULT_CAMERA_CONFIG.attributeName;
|
|
155
|
+
output = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.output) || DEFAULT_CAMERA_CONFIG.output;
|
|
156
|
+
if (!(snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.useStage)) return [3, 2];
|
|
157
|
+
return [4, window.threekit.player.getStageConfigurator()];
|
|
158
|
+
case 1:
|
|
159
|
+
_a = _d.sent();
|
|
160
|
+
return [3, 3];
|
|
161
|
+
case 2:
|
|
162
|
+
_a = window.threekit.configurator;
|
|
163
|
+
_d.label = 3;
|
|
164
|
+
case 3:
|
|
165
|
+
configurator = _a;
|
|
166
|
+
cameras = Array.isArray(camerasList) ? camerasList : [camerasList];
|
|
167
|
+
if (!(cameras.length === 1 && cameras[0] === undefined)) return [3, 5];
|
|
168
|
+
return [4, getSnapshot({ size: size, format: format })];
|
|
169
|
+
case 4:
|
|
170
|
+
snapshotData = _d.sent();
|
|
171
|
+
snapshotsRaw = [snapshotData];
|
|
172
|
+
return [3, 8];
|
|
173
|
+
case 5:
|
|
174
|
+
camerasMap_1 = getCamerasMap(configurator, attributeName);
|
|
175
|
+
if (!camerasMap_1)
|
|
176
|
+
return [2, null];
|
|
177
|
+
cameras = cameras.filter(function (el) { return el === undefined || Object.keys(camerasMap_1).includes(el); });
|
|
178
|
+
currentCamera = getCameraValue(configurator, attributeName);
|
|
179
|
+
cameraPosition = (0, utils_1.getCameraPosition)(window.threekit.player.camera);
|
|
180
|
+
return [4, getSnapshots(cameras, snapshotsConfig)];
|
|
181
|
+
case 6:
|
|
182
|
+
snapshotsRaw = _d.sent();
|
|
183
|
+
return [4, configurator.setConfiguration((_c = {},
|
|
184
|
+
_c[attributeName] = currentCamera,
|
|
185
|
+
_c))];
|
|
186
|
+
case 7:
|
|
187
|
+
_d.sent();
|
|
188
|
+
(0, utils_1.setCameraPosition)(window.threekit.player.camera, cameraPosition);
|
|
189
|
+
_d.label = 8;
|
|
190
|
+
case 8:
|
|
191
|
+
_b = output;
|
|
192
|
+
switch (_b) {
|
|
193
|
+
case types_1.SNAPSHOT_OUTPUTS.URL: return [3, 9];
|
|
194
|
+
case types_1.SNAPSHOT_OUTPUTS.DOWNLOAD: return [3, 11];
|
|
195
|
+
case types_1.SNAPSHOT_OUTPUTS.BLOB: return [3, 12];
|
|
196
|
+
case types_1.SNAPSHOT_OUTPUTS.FILE: return [3, 13];
|
|
197
|
+
case types_1.SNAPSHOT_OUTPUTS.DATA_URL: return [3, 14];
|
|
198
|
+
}
|
|
199
|
+
return [3, 14];
|
|
200
|
+
case 9:
|
|
201
|
+
attachments = snapshotsRaw.reduce(function (output, el, idx) {
|
|
202
|
+
var _a;
|
|
203
|
+
var cameraName = (camerasList === null || camerasList === void 0 ? void 0 : camerasList[idx])
|
|
204
|
+
? (0, utils_1.regularToKebabCase)(camerasList[idx] || 'default')
|
|
205
|
+
: filename;
|
|
206
|
+
var preppedFilename = cameraName === filename
|
|
207
|
+
? "".concat(filename, ".").concat(format)
|
|
208
|
+
: "".concat(filename, "-").concat(cameraName, ".").concat(format);
|
|
209
|
+
var file = (0, utils_1.dataURItoFile)(el, preppedFilename);
|
|
210
|
+
return Object.assign(output, (_a = {}, _a[cameraName] = file, _a));
|
|
211
|
+
}, {});
|
|
212
|
+
return [4, api_1.default.configurations.save({
|
|
213
|
+
assetId: window.threekit.player.assetId,
|
|
214
|
+
configuration: window.threekit.configurator.getConfiguration(),
|
|
215
|
+
attachments: attachments,
|
|
216
|
+
})];
|
|
217
|
+
case 10:
|
|
218
|
+
response = _d.sent();
|
|
219
|
+
urlsArray = Object.values(response.data.attachments);
|
|
220
|
+
return [2, Promise.resolve(urlsArray)];
|
|
221
|
+
case 11:
|
|
222
|
+
snapshotsRaw.forEach(function (snapshotBlob, idx) {
|
|
223
|
+
var cameraName = (camerasList === null || camerasList === void 0 ? void 0 : camerasList[idx])
|
|
224
|
+
? "-".concat((0, utils_1.regularToKebabCase)(camerasList[idx] || 'default'))
|
|
225
|
+
: '';
|
|
226
|
+
(0, utils_1.downloadSnapshot)(snapshotBlob, "".concat(filename).concat(cameraName, ".").concat(format));
|
|
227
|
+
});
|
|
228
|
+
return [2, Promise.resolve()];
|
|
229
|
+
case 12:
|
|
230
|
+
snapshotBlobs = snapshotsRaw.map(function (el) { return (0, utils_1.dataURItoBlob)(el); });
|
|
231
|
+
return [2, Promise.resolve(snapshotBlobs)];
|
|
232
|
+
case 13:
|
|
233
|
+
snapshotFiles = snapshotsRaw.map(function (el, idx) {
|
|
234
|
+
var cameraName = (camerasList === null || camerasList === void 0 ? void 0 : camerasList[idx])
|
|
235
|
+
? "-".concat((0, utils_1.regularToKebabCase)(camerasList[idx] || 'default'))
|
|
236
|
+
: '';
|
|
237
|
+
return (0, utils_1.dataURItoFile)(el, "".concat(filename).concat(cameraName, ".").concat(format));
|
|
238
|
+
});
|
|
239
|
+
return [2, Promise.resolve(snapshotFiles)];
|
|
240
|
+
case 14: return [2, Promise.resolve(snapshotsRaw)];
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}); };
|
|
244
|
+
exports.default = {
|
|
245
|
+
getSnapshot: getSnapshot,
|
|
246
|
+
takeSnapshots: takeSnapshots,
|
|
247
|
+
};
|
|
@@ -17,6 +17,6 @@ interface IGetSnapshot {
|
|
|
17
17
|
}
|
|
18
18
|
declare const _default: {
|
|
19
19
|
getSnapshot: ({ size, format }: IGetSnapshot) => Promise<string>;
|
|
20
|
-
takeSnapshots: (camerasList: ISnapshotsCameras, snapshotsConfig: ITakeSnapshotsConfig) => Promise<void | string[] |
|
|
20
|
+
takeSnapshots: (camerasList: ISnapshotsCameras, snapshotsConfig: ITakeSnapshotsConfig) => Promise<void | string[] | Blob[] | File[] | null>;
|
|
21
21
|
};
|
|
22
22
|
export default _default;
|
|
@@ -37,13 +37,14 @@ var GlobalStyles_styles_1 = __importDefault(require("./GlobalStyles.styles"));
|
|
|
37
37
|
var DevTools_1 = __importDefault(require("../DevTools"));
|
|
38
38
|
var App = function (props) {
|
|
39
39
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
40
|
-
var playerConfig = props.playerConfig, assetId = props.assetId, productId = props.productId, project = props.project, locale = props.locale, threekitEnv = props.threekitEnv, eventHandlers = props.eventHandlers;
|
|
40
|
+
var playerConfig = props.playerConfig, assetId = props.assetId, customId = props.customId, productId = props.productId, project = props.project, locale = props.locale, threekitEnv = props.threekitEnv, eventHandlers = props.eventHandlers;
|
|
41
41
|
(0, react_1.useEffect)(function () {
|
|
42
42
|
var init = function () {
|
|
43
43
|
dispatch((0, treble_1.launch)({
|
|
44
44
|
playerConfig: playerConfig,
|
|
45
45
|
productId: productId,
|
|
46
46
|
assetId: assetId,
|
|
47
|
+
customId: customId,
|
|
47
48
|
project: project,
|
|
48
49
|
locale: locale,
|
|
49
50
|
threekitEnv: threekitEnv,
|
|
@@ -59,7 +60,7 @@ var ThreekitProvider = function (props) {
|
|
|
59
60
|
return (react_1.default.createElement(react_redux_1.Provider, { store: (0, store_1.default)(props.reducer) },
|
|
60
61
|
react_1.default.createElement(styled_components_1.ThemeProvider, { theme: theme_1.default },
|
|
61
62
|
react_1.default.createElement(GlobalStyles_styles_1.default, null),
|
|
62
|
-
react_1.default.createElement(App, { locale: props.locale, assetId: props.assetId, productId: props.productId, project: props.project, playerConfig: props.playerConfig, threekitEnv: props.threekitEnv, eventHandlers: props.eventHandlers }, props.children),
|
|
63
|
+
react_1.default.createElement(App, { locale: props.locale, assetId: props.assetId, customId: props.customId, productId: props.productId, project: props.project, playerConfig: props.playerConfig, threekitEnv: props.threekitEnv, eventHandlers: props.eventHandlers }, props.children),
|
|
63
64
|
constants_1.TREBLE_DEBUG ? null : react_1.default.createElement(DevTools_1.default, null))));
|
|
64
65
|
};
|
|
65
66
|
exports.default = ThreekitProvider;
|
package/dist/connection.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export interface IConnectionConfig {
|
|
|
3
3
|
authToken?: string;
|
|
4
4
|
orgId?: string;
|
|
5
5
|
assetId?: string;
|
|
6
|
+
customId?: string;
|
|
6
7
|
threekitDomain?: string;
|
|
7
8
|
serverUrl?: string;
|
|
8
9
|
cacheParameters?: ICacheParameters;
|
|
@@ -11,15 +12,17 @@ export declare class ThreekitConnection {
|
|
|
11
12
|
_authToken: string;
|
|
12
13
|
_orgId: string;
|
|
13
14
|
_assetId: string;
|
|
15
|
+
_customId: string;
|
|
14
16
|
_threekitDomain: string;
|
|
15
17
|
_serverUrl: string;
|
|
16
18
|
_cacheParameters?: ICacheParameters;
|
|
17
19
|
constructor();
|
|
18
|
-
connect(config: IConnectionConfig):
|
|
20
|
+
connect(config: IConnectionConfig): void;
|
|
19
21
|
getConnection(): {
|
|
20
22
|
authToken: string;
|
|
21
23
|
orgId: string;
|
|
22
24
|
assetId: string;
|
|
25
|
+
customId: string;
|
|
23
26
|
threekitDomain: string;
|
|
24
27
|
serverUrl: string;
|
|
25
28
|
cacheParameters: ICacheParameters | undefined;
|
package/dist/connection.js
CHANGED
|
@@ -1,40 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.ThreekitConnection = void 0;
|
|
40
4
|
var ThreekitConnection = (function () {
|
|
@@ -42,27 +6,25 @@ var ThreekitConnection = (function () {
|
|
|
42
6
|
this._authToken = '';
|
|
43
7
|
this._orgId = '';
|
|
44
8
|
this._assetId = '';
|
|
9
|
+
this._customId = '';
|
|
45
10
|
this._serverUrl = '';
|
|
46
11
|
this._threekitDomain = 'https://admin-fts.threekit.com';
|
|
47
12
|
}
|
|
48
13
|
ThreekitConnection.prototype.connect = function (config) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return [2];
|
|
64
|
-
});
|
|
65
|
-
});
|
|
14
|
+
if (config.authToken)
|
|
15
|
+
this._authToken = config.authToken;
|
|
16
|
+
if (config.orgId)
|
|
17
|
+
this._orgId = config.orgId;
|
|
18
|
+
if (config.assetId)
|
|
19
|
+
this._assetId = config.assetId;
|
|
20
|
+
if (config.customId)
|
|
21
|
+
this._customId = config.customId;
|
|
22
|
+
if (config.serverUrl)
|
|
23
|
+
this._serverUrl = config.serverUrl;
|
|
24
|
+
if (config.threekitDomain)
|
|
25
|
+
this._threekitDomain = "https://".concat(config.threekitDomain);
|
|
26
|
+
if (config.cacheParameters)
|
|
27
|
+
this._cacheParameters = config.cacheParameters;
|
|
66
28
|
};
|
|
67
29
|
ThreekitConnection.prototype.getConnection = function () {
|
|
68
30
|
var _a;
|
|
@@ -72,6 +34,7 @@ var ThreekitConnection = (function () {
|
|
|
72
34
|
authToken: this._authToken,
|
|
73
35
|
orgId: this._orgId,
|
|
74
36
|
assetId: this._assetId,
|
|
37
|
+
customId: this._customId,
|
|
75
38
|
threekitDomain: this._threekitDomain,
|
|
76
39
|
serverUrl: this._serverUrl,
|
|
77
40
|
cacheParameters: this._cacheParameters,
|
|
@@ -35,14 +35,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
39
|
var store_1 = require("../../store");
|
|
43
40
|
var attributes_1 = require("../../store/attributes");
|
|
44
41
|
var utils_1 = require("../../utils");
|
|
45
|
-
var api_1 = __importDefault(require("../../api"));
|
|
46
42
|
var utils_2 = require("../../utils");
|
|
47
43
|
var useAttribute = function (attributeName) {
|
|
48
44
|
var _a;
|
|
@@ -66,7 +62,7 @@ var useAttribute = function (attributeName) {
|
|
|
66
62
|
if (!!value) return [3, 1];
|
|
67
63
|
preppedValue = (0, utils_1.selectionToConfiguration)('', attribute.type);
|
|
68
64
|
return [3, 3];
|
|
69
|
-
case 1: return [4,
|
|
65
|
+
case 1: return [4, window.threekit.player.uploadImage(value)];
|
|
70
66
|
case 2:
|
|
71
67
|
assetId = _b.sent();
|
|
72
68
|
if (assetId)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ISnapshotsCameras, ITakeSnapshotsConfig } from '../../Treble';
|
|
2
|
-
declare const useSnapshot: (cameras: ISnapshotsCameras, config: ITakeSnapshotsConfig) => (() => Promise<void | string[] |
|
|
2
|
+
declare const useSnapshot: (cameras: ISnapshotsCameras, config: ITakeSnapshotsConfig) => (() => Promise<void | string[] | Blob[] | File[] | null>) | undefined;
|
|
3
3
|
export default useSnapshot;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ICoordinate2D } from './types';
|
|
3
|
+
interface ISpacesLayout {
|
|
4
|
+
loops?: Array<ICoordinate2D[]>;
|
|
5
|
+
size?: number;
|
|
6
|
+
color?: string;
|
|
7
|
+
padding?: number;
|
|
8
|
+
strokeWidth?: number;
|
|
9
|
+
}
|
|
10
|
+
export default function SpacesLayout(props: ISpacesLayout): JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var react_1 = __importDefault(require("react"));
|
|
18
|
+
function SpacesLayout(props) {
|
|
19
|
+
var loops = props.loops;
|
|
20
|
+
var size = props.size || 20;
|
|
21
|
+
var padding = props.padding || 2;
|
|
22
|
+
var strokeWidth = props.strokeWidth || 2;
|
|
23
|
+
if (!(loops === null || loops === void 0 ? void 0 : loops.length))
|
|
24
|
+
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
25
|
+
var _a = loops.reduce(function (output, loop, i) {
|
|
26
|
+
loop.forEach(function (_a, j) {
|
|
27
|
+
var x = _a[0], y = _a[1];
|
|
28
|
+
if (!i && !j) {
|
|
29
|
+
output = {
|
|
30
|
+
xMin: x,
|
|
31
|
+
yMin: y,
|
|
32
|
+
xMax: x,
|
|
33
|
+
yMax: y,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
if (x < output.xMin)
|
|
38
|
+
output.xMin = x;
|
|
39
|
+
else if (x > output.xMax)
|
|
40
|
+
output.xMax = x;
|
|
41
|
+
if (y < output.yMin)
|
|
42
|
+
output.yMin = y;
|
|
43
|
+
else if (y > output.yMax)
|
|
44
|
+
output.yMax = y;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return output;
|
|
48
|
+
}, {
|
|
49
|
+
xMin: 0,
|
|
50
|
+
yMin: 0,
|
|
51
|
+
xMax: 0,
|
|
52
|
+
yMax: 0,
|
|
53
|
+
}), xMin = _a.xMin, yMin = _a.yMin, xMax = _a.xMax, yMax = _a.yMax;
|
|
54
|
+
var xSpan = xMax - xMin;
|
|
55
|
+
var ySpan = yMax - yMin;
|
|
56
|
+
var xCenter = xMin + xSpan / 2;
|
|
57
|
+
var yCenter = yMin + ySpan / 2;
|
|
58
|
+
var scaleFactor = (size - 2 * padding) / Math.max(xSpan, ySpan);
|
|
59
|
+
var translate = [
|
|
60
|
+
xCenter * scaleFactor - size / 2,
|
|
61
|
+
yCenter * scaleFactor - size / 2,
|
|
62
|
+
];
|
|
63
|
+
return (react_1.default.createElement("svg", __assign({ width: size, height: size, fill: "none", xmlns: "http://www.w3.org/2000/svg" }, props), loops.map(function (loop, i) {
|
|
64
|
+
var path = loop
|
|
65
|
+
.map(function (point, i) {
|
|
66
|
+
var x = point[0] * scaleFactor - translate[0];
|
|
67
|
+
var y = point[1] * scaleFactor - translate[1];
|
|
68
|
+
return (!i ? 'M ' : 'L ') + x + ' ' + y;
|
|
69
|
+
})
|
|
70
|
+
.join(' ') + ' Z';
|
|
71
|
+
return (react_1.default.createElement("path", { key: "path-".concat(i), d: path, stroke: props.color, strokeWidth: strokeWidth }));
|
|
72
|
+
})));
|
|
73
|
+
}
|
|
74
|
+
exports.default = SpacesLayout;
|