hart-estate-widget 0.0.30 → 0.0.33
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/build/assets/img/door-icon.png +0 -0
- package/build/assets/img/spot-icon.png +0 -0
- package/build/components/Application.js +2 -2
- package/build/components/PanoramaTab.js +82 -24
- package/build/components/TabPanes.js +1 -2
- package/build/store/index.js +35 -0
- package/build/utils/panoramaHelpers.js +19 -2
- package/package.json +1 -1
Binary file
|
Binary file
|
@@ -81,8 +81,8 @@ const Application = (0, _mobxReactLite.observer)(_ref => {
|
|
81
81
|
})),
|
82
82
|
'panorama': /*#__PURE__*/_react.default.createElement(_TabWrapper.default, {
|
83
83
|
isActive: !isTabPanesVisible,
|
84
|
-
disabled: !
|
85
|
-
image:
|
84
|
+
disabled: !_store.default.hallRoomImage,
|
85
|
+
image: _store.default.hallRoomImage,
|
86
86
|
title: "Panoramic tour",
|
87
87
|
text: ['Use mouse to rotate', 'To move through the rooms, click on the layout thumbnail'],
|
88
88
|
onStart: hideTabPanes
|
@@ -5,6 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
7
|
|
8
|
+
require("core-js/modules/es.regexp.exec.js");
|
9
|
+
|
10
|
+
require("core-js/modules/es.string.match.js");
|
11
|
+
|
8
12
|
require("core-js/modules/es.array.reduce.js");
|
9
13
|
|
10
14
|
require("core-js/modules/es.string.includes.js");
|
@@ -13,6 +17,8 @@ require("core-js/modules/web.dom-collections.iterator.js");
|
|
13
17
|
|
14
18
|
var _react = _interopRequireWildcard(require("react"));
|
15
19
|
|
20
|
+
var _store = _interopRequireDefault(require("../store"));
|
21
|
+
|
16
22
|
var THREE = _interopRequireWildcard(require("three"));
|
17
23
|
|
18
24
|
var PANOLENS = _interopRequireWildcard(require("panolens"));
|
@@ -25,6 +31,10 @@ var _panoramaHelpers = require("../utils/panoramaHelpers");
|
|
25
31
|
|
26
32
|
var _geometric = require("geometric");
|
27
33
|
|
34
|
+
var _spotIcon = _interopRequireDefault(require("../assets/img/spot-icon.png"));
|
35
|
+
|
36
|
+
var _doorIcon = _interopRequireDefault(require("../assets/img/door-icon.png"));
|
37
|
+
|
28
38
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
29
39
|
|
30
40
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
@@ -36,6 +46,19 @@ const {
|
|
36
46
|
ORBIT
|
37
47
|
} = PANOLENS.CONTROLS;
|
38
48
|
const pathName = 'Panorama_0_0_';
|
49
|
+
(0, _panoramaHelpers.imageToUri)(_spotIcon.default, img => PANOLENS.DataImage.Spot = img);
|
50
|
+
(0, _panoramaHelpers.imageToUri)(_doorIcon.default, img => PANOLENS.DataImage.Door = img);
|
51
|
+
|
52
|
+
const getCameraFromSrc = (json, src) => {
|
53
|
+
const cameraIdTimestamp = src.match(/(?<=CameraId)[\s\S]*?(?=\.png)/);
|
54
|
+
const cameraId = "CameraId".concat(cameraIdTimestamp);
|
55
|
+
return json.Floors[0].CameraPoints.find(_ref => {
|
56
|
+
let {
|
57
|
+
ID
|
58
|
+
} = _ref;
|
59
|
+
return ID === cameraId;
|
60
|
+
});
|
61
|
+
};
|
39
62
|
|
40
63
|
const createPanorama = (image, index, setLoadingState) => {
|
41
64
|
const panorama = new PANOLENS.ImagePanorama(image);
|
@@ -54,11 +77,19 @@ const createPanorama = (image, index, setLoadingState) => {
|
|
54
77
|
const getPanoramas = (json, images, setLoadingState) => {
|
55
78
|
if (!json) return images.map((image, index) => createPanorama(image, index, setLoadingState));
|
56
79
|
return json.Floors[0].Units[0].Rooms.reduce((acc, jsonRoom, index) => {
|
57
|
-
const
|
58
|
-
if (!
|
59
|
-
|
60
|
-
|
61
|
-
|
80
|
+
const roomImages = images.filter(img => img.includes(pathName + index));
|
81
|
+
if (!roomImages.length) return acc;
|
82
|
+
roomImages.forEach(image => {
|
83
|
+
const panorama = createPanorama(image, index, setLoadingState);
|
84
|
+
panorama['room_images'] = roomImages;
|
85
|
+
panorama['room_id'] = jsonRoom.ID;
|
86
|
+
|
87
|
+
if (panorama['room_id'] === _store.default.hallRoomId) {
|
88
|
+
acc.unshift(panorama);
|
89
|
+
} else {
|
90
|
+
acc.push(panorama);
|
91
|
+
}
|
92
|
+
});
|
62
93
|
return acc;
|
63
94
|
}, []);
|
64
95
|
};
|
@@ -75,9 +106,18 @@ const getPanoramaRooms = (json, panoramas) => {
|
|
75
106
|
top: 0
|
76
107
|
};
|
77
108
|
const currentRoom = json.Floors[0].Units[0].Rooms.find(room => room.ID === panorama['room_id']);
|
78
|
-
|
109
|
+
let [left, top] = (0, _geometric.polygonMean)((0, _panoramaHelpers.getRoomCoordinates)(currentRoom, json.Floors[0].Walls, json.Vertices));
|
79
110
|
|
80
111
|
if (!panorama.linkedSpots.length) {
|
112
|
+
if (panorama.src.includes('_CameraId')) {
|
113
|
+
const currentCamera = getCameraFromSrc(json, panorama.src);
|
114
|
+
const {
|
115
|
+
Location
|
116
|
+
} = currentCamera;
|
117
|
+
left = Location.X;
|
118
|
+
top = Location.Y;
|
119
|
+
}
|
120
|
+
|
81
121
|
setPanoramaLinks(json, currentRoom, [left, top], panorama, panoramas);
|
82
122
|
}
|
83
123
|
|
@@ -92,11 +132,22 @@ const getPanoramaRooms = (json, panoramas) => {
|
|
92
132
|
};
|
93
133
|
|
94
134
|
const setPanoramaLinks = (json, currentRoom, center, panorama, panoramas) => {
|
95
|
-
|
135
|
+
panorama['room_images'].forEach(image => {
|
136
|
+
if (image === panorama.src) return;
|
137
|
+
const connectedPanorama = panoramas.find(_ref2 => {
|
138
|
+
let {
|
139
|
+
src
|
140
|
+
} = _ref2;
|
141
|
+
return src === image;
|
142
|
+
});
|
143
|
+
const currentCamera = getCameraFromSrc(json, connectedPanorama.src);
|
144
|
+
connectPanorama(panorama, connectedPanorama, currentCamera.Location, center, false);
|
145
|
+
});
|
146
|
+
json.Floors[0].Doors.forEach(_ref3 => {
|
96
147
|
let {
|
97
148
|
Location,
|
98
149
|
Walls
|
99
|
-
} =
|
150
|
+
} = _ref3;
|
100
151
|
if (!Walls.some(doorWallId => currentRoom.Walls.some(roomWallId => roomWallId === doorWallId))) return;
|
101
152
|
const connectedRoom = json.Floors[0].Units[0].Rooms.find(room => {
|
102
153
|
const roomHasSameWall = room.Walls.some(roomWallId => Walls.some(doorWallId => roomWallId === doorWallId));
|
@@ -104,26 +155,33 @@ const setPanoramaLinks = (json, currentRoom, center, panorama, panoramas) => {
|
|
104
155
|
return roomHasSameWall && !isSameRoom;
|
105
156
|
});
|
106
157
|
if (!connectedRoom) return;
|
107
|
-
const connectedPanorama = panoramas.find(
|
158
|
+
const connectedPanorama = panoramas.find(_ref4 => {
|
108
159
|
let {
|
109
160
|
room_id
|
110
|
-
} =
|
161
|
+
} = _ref4;
|
111
162
|
return room_id === connectedRoom.ID;
|
112
163
|
});
|
113
164
|
if (!connectedPanorama) return;
|
114
|
-
|
115
|
-
const locationY = Location.X - center[0];
|
116
|
-
const defaultScale = 20;
|
117
|
-
const maxScale = 50;
|
118
|
-
const defaultLength = 120;
|
119
|
-
const length = (0, _geometric.lineLength)([[0, 0], [locationX, locationY]]);
|
120
|
-
const scale = length / defaultLength * defaultScale;
|
121
|
-
const finalScale = scale > maxScale ? maxScale : scale;
|
122
|
-
const position = new THREE.Vector3(locationX, -10, locationY);
|
123
|
-
panorama.link(connectedPanorama, position, finalScale);
|
165
|
+
connectPanorama(panorama, connectedPanorama, Location, center, true);
|
124
166
|
});
|
125
167
|
};
|
126
168
|
|
169
|
+
const connectPanorama = function connectPanorama(panorama, connectedPanorama, location, center) {
|
170
|
+
let isDoorLink = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
171
|
+
const locationX = location.Y - center[1];
|
172
|
+
const locationY = location.X - center[0];
|
173
|
+
const locationZ = isDoorLink ? -10 : -50;
|
174
|
+
const icon = isDoorLink ? PANOLENS.DataImage.Door : PANOLENS.DataImage.Spot;
|
175
|
+
const defaultScale = 20;
|
176
|
+
const maxScale = 50;
|
177
|
+
const defaultLength = 120;
|
178
|
+
const length = (0, _geometric.lineLength)([[0, 0], [locationX, locationY]]);
|
179
|
+
const scale = length / defaultLength * defaultScale;
|
180
|
+
const finalScale = scale > maxScale ? maxScale : scale;
|
181
|
+
const position = new THREE.Vector3(locationX, locationZ, locationY);
|
182
|
+
panorama.link(connectedPanorama, position, finalScale, icon);
|
183
|
+
};
|
184
|
+
|
127
185
|
const initPanorama = () => {
|
128
186
|
let camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 1100);
|
129
187
|
let controls = new _threeDeviceOrientation.default(camera);
|
@@ -149,12 +207,12 @@ const initPanorama = () => {
|
|
149
207
|
};
|
150
208
|
};
|
151
209
|
|
152
|
-
const PanoramaTab =
|
210
|
+
const PanoramaTab = _ref5 => {
|
153
211
|
let {
|
154
212
|
json,
|
155
213
|
planImage,
|
156
214
|
images
|
157
|
-
} =
|
215
|
+
} = _ref5;
|
158
216
|
const [menuState, setMenuState] = (0, _react.useState)(false);
|
159
217
|
const [loadingState, setLoadingState] = (0, _react.useState)(true);
|
160
218
|
const [isMapActive, setMapState] = (0, _react.useState)(false);
|
@@ -232,10 +290,10 @@ const PanoramaTab = _ref3 => {
|
|
232
290
|
});
|
233
291
|
panoramas.forEach(panorama => {
|
234
292
|
if (!panorama.panorama_id) return;
|
235
|
-
panorama.addEventListener('enter',
|
293
|
+
panorama.addEventListener('enter', _ref6 => {
|
236
294
|
let {
|
237
295
|
target
|
238
|
-
} =
|
296
|
+
} = _ref6;
|
239
297
|
return setCurrentRoomIndex(target['panorama_index']);
|
240
298
|
});
|
241
299
|
newViewer.add(panorama);
|
@@ -28,7 +28,6 @@ const TabPanes = (0, _mobxReactLite.observer)(_ref => {
|
|
28
28
|
planImage,
|
29
29
|
topView,
|
30
30
|
topDownView,
|
31
|
-
panoramaImages,
|
32
31
|
rotationImages,
|
33
32
|
tabs
|
34
33
|
} = _store.default.config;
|
@@ -46,7 +45,7 @@ const TabPanes = (0, _mobxReactLite.observer)(_ref => {
|
|
46
45
|
icon: null
|
47
46
|
},
|
48
47
|
'panorama': {
|
49
|
-
img:
|
48
|
+
img: _store.default.hallRoomImage,
|
50
49
|
icon: null
|
51
50
|
},
|
52
51
|
'rotation': {
|
package/build/store/index.js
CHANGED
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
7
|
|
8
|
+
require("core-js/modules/es.string.includes.js");
|
9
|
+
|
8
10
|
var _react = _interopRequireDefault(require("react"));
|
9
11
|
|
10
12
|
var _mobx = require("mobx");
|
@@ -29,6 +31,39 @@ class Store {
|
|
29
31
|
(0, _mobx.makeAutoObservable)(this);
|
30
32
|
}
|
31
33
|
|
34
|
+
get hallRoomId() {
|
35
|
+
const {
|
36
|
+
json
|
37
|
+
} = this.config;
|
38
|
+
if (!json) return 0;
|
39
|
+
const exteriorWallWithDoor = json.Floors[0].ExteriorWalls.find(wallId => {
|
40
|
+
return json.Floors[0].Doors.some(door => door.Walls.some(doorWallId => doorWallId === wallId));
|
41
|
+
});
|
42
|
+
const exteriorDoor = json.Floors[0].Doors.find(door => {
|
43
|
+
const isSameDoor = door.Walls.some(doorWallId => doorWallId === exteriorWallWithDoor);
|
44
|
+
const isExterior = door.Walls.some(doorWallId => json.Floors[0].ExteriorWalls.some(exteriorWallId => exteriorWallId === doorWallId));
|
45
|
+
return isSameDoor && isExterior;
|
46
|
+
});
|
47
|
+
const wallWithExteriorDoor = exteriorDoor.Walls.find(wallId => wallId !== exteriorWallWithDoor);
|
48
|
+
const room = json.Floors[0].Units[0].Rooms.find(_ref => {
|
49
|
+
let {
|
50
|
+
Walls
|
51
|
+
} = _ref;
|
52
|
+
return Walls.some(wallId => wallId === wallWithExteriorDoor);
|
53
|
+
});
|
54
|
+
return room.ID;
|
55
|
+
}
|
56
|
+
|
57
|
+
get hallRoomImage() {
|
58
|
+
const {
|
59
|
+
json,
|
60
|
+
panoramaImages
|
61
|
+
} = this.config;
|
62
|
+
const roomIndex = json.Floors[0].Units[0].Rooms.findIndex(room => room.ID === this.hallRoomId);
|
63
|
+
const image = panoramaImages.find(url => url.includes("".concat(roomIndex, ".png")));
|
64
|
+
return image || panoramaImages[0];
|
65
|
+
}
|
66
|
+
|
32
67
|
setConfig(config) {
|
33
68
|
this.config = config;
|
34
69
|
}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.getScale = exports.getRoomCoordinates = exports.findWallVertices = void 0;
|
6
|
+
exports.imageToUri = exports.getScale = exports.getRoomCoordinates = exports.findWallVertices = void 0;
|
7
7
|
|
8
8
|
require("core-js/modules/es.array.reduce.js");
|
9
9
|
|
@@ -49,4 +49,21 @@ const getScale = (image, json) => {
|
|
49
49
|
};
|
50
50
|
};
|
51
51
|
|
52
|
-
exports.getScale = getScale;
|
52
|
+
exports.getScale = getScale;
|
53
|
+
|
54
|
+
const imageToUri = (url, callback) => {
|
55
|
+
const canvas = document.createElement('canvas');
|
56
|
+
const ctx = canvas.getContext('2d');
|
57
|
+
const image = new Image();
|
58
|
+
image.src = url;
|
59
|
+
|
60
|
+
image.onload = () => {
|
61
|
+
canvas.width = image.width;
|
62
|
+
canvas.height = image.height;
|
63
|
+
ctx.drawImage(image, 0, 0);
|
64
|
+
callback(canvas.toDataURL('image/png'));
|
65
|
+
canvas.remove();
|
66
|
+
};
|
67
|
+
};
|
68
|
+
|
69
|
+
exports.imageToUri = imageToUri;
|