hart-estate-widget 0.0.8 → 0.0.9
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/README.md +67 -13
- package/build/assets/sass/components/loader.sass +51 -0
- package/build/assets/sass/components/panorama.sass +98 -0
- package/build/assets/sass/index.sass +2 -0
- package/build/components/Application.js +7 -1
- package/build/components/Loader.js +22 -0
- package/build/components/PanoramaTab.js +213 -0
- package/build/config/defaultConfig.js +4 -1
- package/build/config/defaultJSON.js +2432 -0
- package/build/index.js +16 -8
- package/build/utils/helpers.js +79 -0
- package/package.json +6 -2
package/build/index.js
CHANGED
@@ -6,25 +6,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
Object.defineProperty(exports, "ImageTab", {
|
7
7
|
enumerable: true,
|
8
8
|
get: function get() {
|
9
|
-
return _ImageTab.
|
9
|
+
return _ImageTab.default;
|
10
10
|
}
|
11
11
|
});
|
12
12
|
Object.defineProperty(exports, "Instructions", {
|
13
13
|
enumerable: true,
|
14
14
|
get: function get() {
|
15
|
-
return _Instructions.
|
15
|
+
return _Instructions.default;
|
16
|
+
}
|
17
|
+
});
|
18
|
+
Object.defineProperty(exports, "PanoramaTab", {
|
19
|
+
enumerable: true,
|
20
|
+
get: function get() {
|
21
|
+
return _PanoramaTab.default;
|
16
22
|
}
|
17
23
|
});
|
18
24
|
Object.defineProperty(exports, "RotationTab", {
|
19
25
|
enumerable: true,
|
20
26
|
get: function get() {
|
21
|
-
return _RotationTab.
|
27
|
+
return _RotationTab.default;
|
22
28
|
}
|
23
29
|
});
|
24
30
|
Object.defineProperty(exports, "TabWrapper", {
|
25
31
|
enumerable: true,
|
26
32
|
get: function get() {
|
27
|
-
return _TabWrapper.
|
33
|
+
return _TabWrapper.default;
|
28
34
|
}
|
29
35
|
});
|
30
36
|
Object.defineProperty(exports, "Widget", {
|
@@ -38,12 +44,14 @@ var _react = _interopRequireDefault(require("react"));
|
|
38
44
|
|
39
45
|
var _Widget = _interopRequireDefault(require("./components/Widget"));
|
40
46
|
|
41
|
-
var _ImageTab = require("./components/ImageTab");
|
47
|
+
var _ImageTab = _interopRequireDefault(require("./components/ImageTab"));
|
48
|
+
|
49
|
+
var _Instructions = _interopRequireDefault(require("./components/Instructions"));
|
42
50
|
|
43
|
-
var
|
51
|
+
var _RotationTab = _interopRequireDefault(require("./components/RotationTab"));
|
44
52
|
|
45
|
-
var
|
53
|
+
var _PanoramaTab = _interopRequireDefault(require("./components/PanoramaTab"));
|
46
54
|
|
47
|
-
var _TabWrapper = require("./components/TabWrapper");
|
55
|
+
var _TabWrapper = _interopRequireDefault(require("./components/TabWrapper"));
|
48
56
|
|
49
57
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -0,0 +1,79 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getVerticesLocations = exports.getScale = exports.findWallVertices = exports.findRoomCenter = exports.findMinMaxCoordinates = void 0;
|
7
|
+
|
8
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
9
|
+
|
10
|
+
const findWallVertices = (walls, wall, vertices) => {
|
11
|
+
const currentWall = walls.find(el => el.ID === wall);
|
12
|
+
return currentWall.Vertices.map(vertex => vertices.find(el => el.ID === vertex));
|
13
|
+
};
|
14
|
+
|
15
|
+
exports.findWallVertices = findWallVertices;
|
16
|
+
|
17
|
+
const getVerticesLocations = vertices => vertices.map(vertex => vertex.Location);
|
18
|
+
|
19
|
+
exports.getVerticesLocations = getVerticesLocations;
|
20
|
+
|
21
|
+
const findMinMaxCoordinates = (room, walls, vertices) => {
|
22
|
+
let maxX = 0;
|
23
|
+
let minX = Infinity;
|
24
|
+
let maxY = 0;
|
25
|
+
let minY = Infinity;
|
26
|
+
room.Walls.forEach(wall => {
|
27
|
+
const [coord1, coord2] = getVerticesLocations(findWallVertices(walls, wall, vertices)); // CALCULATE MAX COORDS
|
28
|
+
|
29
|
+
if (coord1.X > maxX) maxX = coord1.X;
|
30
|
+
if (coord1.X > maxX) maxX = coord1.X;
|
31
|
+
if (coord2.Y > maxY) maxY = coord2.Y;
|
32
|
+
if (coord2.Y > maxY) maxY = coord2.Y; // CALCULATE MIN COORDS
|
33
|
+
|
34
|
+
if (coord1.X < minX) minX = coord1.X;
|
35
|
+
if (coord1.X < minX) minX = coord1.X;
|
36
|
+
if (coord2.Y < minY) minY = coord2.Y;
|
37
|
+
if (coord2.Y < minY) minY = coord2.Y;
|
38
|
+
});
|
39
|
+
return {
|
40
|
+
maxX,
|
41
|
+
minX,
|
42
|
+
maxY,
|
43
|
+
minY
|
44
|
+
};
|
45
|
+
};
|
46
|
+
|
47
|
+
exports.findMinMaxCoordinates = findMinMaxCoordinates;
|
48
|
+
|
49
|
+
const findRoomCenter = (room, walls, vertices) => {
|
50
|
+
const {
|
51
|
+
maxX,
|
52
|
+
minX,
|
53
|
+
maxY,
|
54
|
+
minY
|
55
|
+
} = findMinMaxCoordinates(room, walls, vertices);
|
56
|
+
const left = (maxX + minX) / 2;
|
57
|
+
const top = (maxY + minY) / 2;
|
58
|
+
return {
|
59
|
+
left,
|
60
|
+
top
|
61
|
+
};
|
62
|
+
};
|
63
|
+
|
64
|
+
exports.findRoomCenter = findRoomCenter;
|
65
|
+
|
66
|
+
const getScale = (image, json) => {
|
67
|
+
const imageWidth = image.width;
|
68
|
+
const imageHeight = image.height;
|
69
|
+
const baseImageWidth = 1024;
|
70
|
+
const baseImageHeight = imageHeight * (baseImageWidth / imageWidth);
|
71
|
+
const deltaX = imageWidth / baseImageWidth / json.Scale.X;
|
72
|
+
const deltaY = imageHeight / baseImageHeight / json.Scale.X;
|
73
|
+
return {
|
74
|
+
X: deltaX,
|
75
|
+
Y: deltaY
|
76
|
+
};
|
77
|
+
};
|
78
|
+
|
79
|
+
exports.getScale = getScale;
|
package/package.json
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
"description": "HART Estate widget",
|
4
4
|
"author": "HART",
|
5
5
|
"keywords": [],
|
6
|
-
"version": "0.0.
|
6
|
+
"version": "0.0.9",
|
7
7
|
"private": false,
|
8
8
|
"main": "build/index.js",
|
9
9
|
"module": "build/index.js",
|
@@ -17,16 +17,20 @@
|
|
17
17
|
},
|
18
18
|
"scripts": {
|
19
19
|
"start": "babel src --watch --out-dir build --copy-files",
|
20
|
+
"start-example": "cd ./example && npm run start",
|
20
21
|
"build": "rm -rf build && NODE_ENV=production babel src --out-dir build --copy-files && npm run build:sass",
|
21
22
|
"build:sass": "sass src/assets/sass/index.sass:build/index.css --style compressed"
|
22
23
|
},
|
23
24
|
"dependencies": {
|
25
|
+
"core-js": "^3.21.0",
|
24
26
|
"mobx": "^6.3.13",
|
25
27
|
"mobx-react-lite": "^3.2.3",
|
28
|
+
"panolens": "^0.12.1",
|
26
29
|
"panzoom": "^9.4.2",
|
27
30
|
"react": "^17.0.2",
|
28
31
|
"react-dom": "^17.0.2",
|
29
|
-
"
|
32
|
+
"three": "^0.137.5",
|
33
|
+
"three-device-orientation": "^1.0.3"
|
30
34
|
},
|
31
35
|
"devDependencies": {
|
32
36
|
"@babel/cli": "^7.17.0",
|