hart-estate-widget 0.0.49 → 0.0.52
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/css/app.css +1 -1
- package/build/assets/css/app.css.map +1 -1
- package/build/assets/sass/components/panorama.sass +38 -33
- package/build/assets/sass/components/tabs.sass +7 -6
- package/build/assets/sass/index.sass +2 -2
- package/build/components/Application.js +42 -25
- package/build/components/Buttons/FullScreenButton.js +7 -3
- package/build/components/Buttons/TabButton.js +4 -6
- package/build/components/ImageTab.js +3 -5
- package/build/components/Instructions.js +15 -13
- package/build/components/Loader.js +4 -5
- package/build/components/ModelTab.js +89 -54
- package/build/components/PanoramaTab.js +332 -207
- package/build/components/RotationTab.js +75 -33
- package/build/components/Widget.js +44 -28
- package/build/config/defaultConfig.js +2 -4
- package/build/enums/deviceOrientationStatuses.js +11 -0
- package/build/enums/deviceWidth.js +11 -0
- package/build/enums/imageExtentions.js +6 -11
- package/build/index.js +0 -2
- package/build/store/apiStore.js +177 -40
- package/build/store/fullScreenStore.js +90 -20
- package/build/store/houseStore.js +792 -693
- package/build/store/index.js +70 -44
- package/build/store/modelStore.js +194 -141
- package/build/threesixty/events.js +94 -71
- package/build/threesixty/index.js +138 -112
- package/build/utils/csg/csg-lib.js +383 -298
- package/build/utils/csg/csg-worker.js +23 -33
- package/build/utils/csg/three-csg.js +103 -106
- package/build/utils/helpers.js +12 -0
- package/build/utils/modelHelpers.js +46 -40
- package/build/utils/panoramaHelpers.js +48 -32
- package/package.json +7 -14
- package/build/enums/deviceOrientationStatus.js +0 -11
@@ -1,26 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
4
|
+
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
4
6
|
value: true
|
5
7
|
});
|
6
8
|
exports.default = void 0;
|
7
9
|
|
8
|
-
require("core-js/modules/es.array.reduce.js");
|
9
|
-
|
10
|
-
require("core-js/modules/es.regexp.exec.js");
|
11
|
-
|
12
|
-
require("core-js/modules/es.string.split.js");
|
13
|
-
|
14
|
-
require("core-js/modules/es.string.includes.js");
|
15
|
-
|
16
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
17
|
-
|
18
|
-
require("core-js/modules/es.regexp.to-string.js");
|
19
|
-
|
20
|
-
require("core-js/modules/es.array.flat.js");
|
21
|
-
|
22
|
-
require("core-js/modules/es.array.unscopables.flat.js");
|
23
|
-
|
24
10
|
var _react = _interopRequireWildcard(require("react"));
|
25
11
|
|
26
12
|
var _store = _interopRequireDefault(require("../store"));
|
@@ -33,10 +19,14 @@ var _threeDeviceOrientation = _interopRequireDefault(require("three-device-orien
|
|
33
19
|
|
34
20
|
var _geometric = require("geometric");
|
35
21
|
|
36
|
-
var
|
22
|
+
var _deviceOrientationStatuses = require("../enums/deviceOrientationStatuses");
|
23
|
+
|
24
|
+
var _deviceWidth = require("../enums/deviceWidth");
|
37
25
|
|
38
26
|
var _imageExtentions = require("../enums/imageExtentions");
|
39
27
|
|
28
|
+
var _helpers = require("../utils/helpers");
|
29
|
+
|
40
30
|
var _panoramaHelpers = require("../utils/panoramaHelpers");
|
41
31
|
|
42
32
|
var _Loader = _interopRequireDefault(require("./Loader"));
|
@@ -63,88 +53,107 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
63
53
|
|
64
54
|
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); }
|
65
55
|
|
66
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
56
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
57
|
+
|
58
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
59
|
+
|
60
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
61
|
+
|
62
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
63
|
+
|
64
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
65
|
+
|
66
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
67
|
+
|
68
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
67
69
|
|
68
|
-
|
70
|
+
var instructionSteps = [{
|
69
71
|
icon: _handMove.default,
|
70
72
|
text: 'Вращать планировку'
|
71
73
|
}, {
|
72
74
|
icon: _handResearch.default,
|
73
75
|
text: 'Исследовать планировку'
|
74
76
|
}];
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
const cameraFovValues = {
|
77
|
+
var _PANOLENS$CONTROLS = PANOLENS.CONTROLS,
|
78
|
+
DEVICEORIENTATION = _PANOLENS$CONTROLS.DEVICEORIENTATION,
|
79
|
+
ORBIT = _PANOLENS$CONTROLS.ORBIT;
|
80
|
+
var pathName = 'Panorama_0_0_';
|
81
|
+
var cameraFovValues = {
|
81
82
|
x1: 90,
|
82
83
|
x2: 60
|
83
84
|
};
|
84
85
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
var getDefaultUserData = function getDefaultUserData() {
|
87
|
+
return {
|
88
|
+
left: 0,
|
89
|
+
top: 0,
|
90
|
+
points: []
|
91
|
+
};
|
92
|
+
};
|
90
93
|
|
91
|
-
|
92
|
-
|
94
|
+
var createPanorama = function createPanorama(image, index, setLoadingState) {
|
95
|
+
var panorama = new PANOLENS.ImagePanorama(image);
|
93
96
|
panorama.userData = getDefaultUserData();
|
94
97
|
panorama['panorama_id'] = index + 1;
|
95
|
-
panorama.addEventListener('progress', event
|
98
|
+
panorama.addEventListener('progress', function (event) {
|
96
99
|
setLoadingState(true);
|
97
100
|
|
98
101
|
if (event.progress.loaded / event.progress.total * 100 === 100) {
|
99
102
|
setLoadingState(false);
|
100
103
|
}
|
101
104
|
});
|
102
|
-
panorama.addEventListener('enter', ()
|
105
|
+
panorama.addEventListener('enter', function () {
|
106
|
+
return setLoadingState(false);
|
107
|
+
});
|
103
108
|
return panorama;
|
104
109
|
};
|
105
110
|
|
106
|
-
|
107
|
-
if (!json) return images.map((image, index)
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
+
var getPanoramas = function getPanoramas(json, images, setLoadingState) {
|
112
|
+
if (!json) return images.map(function (image, index) {
|
113
|
+
return createPanorama(image, index, setLoadingState);
|
114
|
+
});
|
115
|
+
var panoramas = json.Floors[0].Units[0].Rooms.reduce(function (acc, jsonRoom, index) {
|
116
|
+
var roomImages = images.filter(function (img) {
|
117
|
+
var panoramaIdIndex = img.indexOf(pathName) + pathName.length;
|
111
118
|
if (panoramaIdIndex < pathName.length) return false;
|
112
|
-
|
113
|
-
|
119
|
+
var indexAsString = String(index);
|
120
|
+
var panoramaId = String((0, _imageExtentions.removeExtention)(img.substring(panoramaIdIndex))).split('.')[0];
|
114
121
|
|
115
|
-
if (panoramaId.includes(_panoramaHelpers.cameraIdBeginning)) {
|
116
|
-
|
122
|
+
if (panoramaId.toLowerCase().includes(_panoramaHelpers.cameraIdBeginning)) {
|
123
|
+
var cameraIdIndex = panoramaId.toLowerCase().indexOf(_panoramaHelpers.cameraIdBeginning) - 1;
|
117
124
|
panoramaId = panoramaId.slice(0, cameraIdIndex);
|
118
125
|
}
|
119
126
|
|
120
|
-
|
121
|
-
|
127
|
+
var maxIndexLength = Math.max(indexAsString.length, panoramaId.length);
|
128
|
+
var imageInRoom = (0, _panoramaHelpers.getArrayFromNumber)(maxIndexLength).every(function (i) {
|
122
129
|
return panoramaId[i] === indexAsString[i];
|
123
130
|
});
|
124
131
|
return imageInRoom;
|
125
132
|
});
|
126
133
|
if (!roomImages.length) return acc;
|
127
|
-
roomImages.forEach(image
|
128
|
-
|
134
|
+
roomImages.forEach(function (image) {
|
135
|
+
var panorama = createPanorama(image, index, setLoadingState);
|
129
136
|
panorama['room_images'] = roomImages;
|
130
137
|
panorama['room_id'] = jsonRoom.ID;
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
left,
|
143
|
-
top,
|
144
|
-
points: roomPoints
|
145
|
-
};
|
138
|
+
var roomPoints = (0, _panoramaHelpers.getRoomCoordinates)(jsonRoom, json.Floors[0].Walls, json.Vertices);
|
139
|
+
|
140
|
+
var _polygonMean = (0, _geometric.polygonMean)(roomPoints),
|
141
|
+
_polygonMean2 = _slicedToArray(_polygonMean, 2),
|
142
|
+
left = _polygonMean2[0],
|
143
|
+
top = _polygonMean2[1];
|
144
|
+
|
145
|
+
if (panorama.src.toLowerCase().includes(_panoramaHelpers.cameraIdBeginning)) {
|
146
|
+
var currentCamera = (0, _panoramaHelpers.getCameraFromSrc)(json, panorama.src);
|
147
|
+
left = currentCamera.Location.X;
|
148
|
+
top = currentCamera.Location.Y;
|
146
149
|
}
|
147
150
|
|
151
|
+
panorama.userData = {
|
152
|
+
left: left,
|
153
|
+
top: top,
|
154
|
+
points: roomPoints
|
155
|
+
};
|
156
|
+
|
148
157
|
if (panorama['room_id'] === _store.default.initialPanoramaRoomId) {
|
149
158
|
acc.unshift(panorama);
|
150
159
|
} else {
|
@@ -153,9 +162,11 @@ const getPanoramas = (json, images, setLoadingState) => {
|
|
153
162
|
});
|
154
163
|
return acc;
|
155
164
|
}, []);
|
156
|
-
return panoramas.map((panorama, index)
|
165
|
+
return panoramas.map(function (panorama, index) {
|
157
166
|
panorama['panorama_index'] = index;
|
158
|
-
|
167
|
+
var currentRoom = json.Floors[0].Units[0].Rooms.find(function (room) {
|
168
|
+
return room.ID === panorama['room_id'];
|
169
|
+
});
|
159
170
|
|
160
171
|
if (!panorama.linkedSpots.length) {
|
161
172
|
return setPanoramaLinks(json, currentRoom, panorama, panoramas);
|
@@ -165,128 +176,202 @@ const getPanoramas = (json, images, setLoadingState) => {
|
|
165
176
|
});
|
166
177
|
};
|
167
178
|
|
168
|
-
|
169
|
-
|
170
|
-
panorama['room_images'].forEach(image
|
179
|
+
var setPanoramaLinks = function setPanoramaLinks(json, currentRoom, panorama, panoramas) {
|
180
|
+
var center = [panorama.userData.left, panorama.userData.top];
|
181
|
+
panorama['room_images'].forEach(function (image) {
|
171
182
|
if (image === panorama.src) return;
|
172
|
-
|
173
|
-
|
174
|
-
src
|
175
|
-
} = _ref;
|
183
|
+
var connectedPanorama = panoramas.find(function (_ref) {
|
184
|
+
var src = _ref.src;
|
176
185
|
return src === image;
|
177
186
|
});
|
178
|
-
|
187
|
+
var currentCamera = (0, _panoramaHelpers.getCameraFromSrc)(json, connectedPanorama.src);
|
179
188
|
if (!currentCamera) return;
|
180
189
|
connectPanorama(panorama, connectedPanorama, currentCamera.Location, center, false);
|
181
190
|
});
|
182
|
-
json.Floors[0].Doors.forEach(_ref2
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
+
json.Floors[0].Doors.forEach(function (_ref2) {
|
192
|
+
var Location = _ref2.Location,
|
193
|
+
Walls = _ref2.Walls;
|
194
|
+
if (!Walls.some(function (doorWallId) {
|
195
|
+
return currentRoom.Walls.some(function (roomWallId) {
|
196
|
+
return roomWallId === doorWallId;
|
197
|
+
});
|
198
|
+
})) return;
|
199
|
+
var connectedRoom = json.Floors[0].Units[0].Rooms.find(function (room) {
|
200
|
+
var roomHasSameWall = room.Walls.some(function (roomWallId) {
|
201
|
+
return Walls.some(function (doorWallId) {
|
202
|
+
return roomWallId === doorWallId;
|
203
|
+
});
|
204
|
+
});
|
205
|
+
var isSameRoom = room.ID === currentRoom.ID;
|
191
206
|
return roomHasSameWall && !isSameRoom;
|
192
207
|
});
|
193
208
|
if (!connectedRoom) return;
|
194
|
-
|
195
|
-
|
196
|
-
room_id
|
197
|
-
} = _ref3;
|
209
|
+
var availablePanoramas = panoramas.filter(function (_ref3) {
|
210
|
+
var room_id = _ref3.room_id;
|
198
211
|
return room_id === connectedRoom.ID;
|
199
212
|
});
|
200
|
-
|
201
|
-
|
202
|
-
|
213
|
+
|
214
|
+
var _getClosestPanorama = (0, _panoramaHelpers.getClosestPanorama)([Location.X, Location.Y], availablePanoramas),
|
215
|
+
connectedPanorama = _getClosestPanorama.panorama;
|
216
|
+
|
203
217
|
if (!connectedPanorama) return;
|
204
218
|
connectPanorama(panorama, connectedPanorama, Location, center, true);
|
205
219
|
});
|
206
220
|
return panorama;
|
207
221
|
};
|
208
222
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
223
|
+
var connectPanorama = function connectPanorama(panorama, connectedPanorama, location, center) {
|
224
|
+
var isDoorLink = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
225
|
+
var locationX = location.Y - center[1];
|
226
|
+
var locationY = location.X - center[0];
|
227
|
+
var locationZ = isDoorLink ? -10 : -100;
|
228
|
+
var icon = isDoorLink ? _doorIcon.default : _spotIcon.default;
|
229
|
+
var iconUrl = "".concat(icon, "?id=").concat(panorama['panorama_index'], "-").concat(panorama['panorama_id'], "-").concat(Math.random());
|
230
|
+
var defaultScale = 20;
|
231
|
+
var maxScale = 50;
|
232
|
+
var defaultLength = 120;
|
233
|
+
var length = (0, _geometric.lineLength)([[0, 0], [locationX, locationY]]);
|
234
|
+
var scale = length / defaultLength * defaultScale;
|
235
|
+
var finalScale = scale > maxScale ? maxScale : scale;
|
236
|
+
var resultScale = isDoorLink ? finalScale : finalScale - 15;
|
237
|
+
var position = new THREE.Vector3(locationX, locationZ, locationY);
|
224
238
|
panorama.link(connectedPanorama, position, resultScale, iconUrl);
|
225
239
|
};
|
226
240
|
|
227
|
-
|
241
|
+
var PanoramaTab = function PanoramaTab(_ref4) {
|
228
242
|
var _panoramas$currentRoo;
|
229
243
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
244
|
+
var json = _ref4.json,
|
245
|
+
planImage = _ref4.planImage,
|
246
|
+
images = _ref4.images,
|
247
|
+
disabled = _ref4.disabled;
|
248
|
+
|
249
|
+
var _useState = (0, _react.useState)(_deviceOrientationStatuses.deviceOrientationStatuses.DENIED),
|
250
|
+
_useState2 = _slicedToArray(_useState, 2),
|
251
|
+
deviceOrientationStatus = _useState2[0],
|
252
|
+
setDeviceOrientationStatus = _useState2[1];
|
253
|
+
|
254
|
+
var _useState3 = (0, _react.useState)(true),
|
255
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
256
|
+
showInstructions = _useState4[0],
|
257
|
+
setInstructionsState = _useState4[1];
|
258
|
+
|
259
|
+
var _useState5 = (0, _react.useState)(true),
|
260
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
261
|
+
loadingState = _useState6[0],
|
262
|
+
setLoadingState = _useState6[1];
|
263
|
+
|
264
|
+
var _useState7 = (0, _react.useState)({
|
265
|
+
width: 0,
|
266
|
+
height: 0
|
267
|
+
}),
|
268
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
269
|
+
windowSize = _useState8[0],
|
270
|
+
setWindowSize = _useState8[1];
|
271
|
+
|
272
|
+
var _useState9 = (0, _react.useState)({
|
273
|
+
width: '195px',
|
274
|
+
height: 'auto'
|
275
|
+
}),
|
276
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
277
|
+
mapSize = _useState10[0],
|
278
|
+
setMapSize = _useState10[1];
|
279
|
+
|
280
|
+
var _useState11 = (0, _react.useState)({
|
241
281
|
X: 1,
|
242
282
|
Y: 1
|
243
|
-
})
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
283
|
+
}),
|
284
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
285
|
+
planScale = _useState12[0],
|
286
|
+
setPlanScale = _useState12[1];
|
287
|
+
|
288
|
+
var _useState13 = (0, _react.useState)(true),
|
289
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
290
|
+
isMapDisabled = _useState14[0],
|
291
|
+
setMapDisabledState = _useState14[1];
|
292
|
+
|
293
|
+
var _useState15 = (0, _react.useState)(false),
|
294
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
295
|
+
autoplayEnabled = _useState16[0],
|
296
|
+
setAutoplayState = _useState16[1];
|
297
|
+
|
298
|
+
var _useState17 = (0, _react.useState)(cameraFovValues.x1),
|
299
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
300
|
+
cameraFov = _useState18[0],
|
301
|
+
setCameraFov = _useState18[1];
|
302
|
+
|
303
|
+
var _useState19 = (0, _react.useState)(0),
|
304
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
305
|
+
currentRoomIndex = _useState20[0],
|
306
|
+
setCurrentRoomIndex = _useState20[1];
|
307
|
+
|
308
|
+
var _useState21 = (0, _react.useState)([]),
|
309
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
310
|
+
panoramas = _useState22[0],
|
311
|
+
setPanoramas = _useState22[1];
|
312
|
+
|
313
|
+
var _useState23 = (0, _react.useState)(null),
|
314
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
315
|
+
viewer = _useState24[0],
|
316
|
+
setViewer = _useState24[1];
|
317
|
+
|
318
|
+
var changePanorama = function changePanorama(panorama) {
|
251
319
|
setCurrentRoomIndex(panorama['panorama_index']);
|
252
320
|
viewer.setPanorama(panorama);
|
253
321
|
};
|
254
322
|
|
255
|
-
|
256
|
-
|
257
|
-
|
323
|
+
var setScale = function setScale() {
|
324
|
+
if (!viewer) return;
|
325
|
+
var image = document.querySelector('.widget-tab__panorama-map img');
|
326
|
+
var _viewer$container = viewer.container,
|
327
|
+
clientWidth = _viewer$container.clientWidth,
|
328
|
+
clientHeight = _viewer$container.clientHeight;
|
329
|
+
var imageWidth = image.naturalWidth;
|
330
|
+
var imageHeight = image.naturalHeight;
|
331
|
+
var imageDelta = imageWidth / imageHeight;
|
332
|
+
var maxWidth = 195;
|
333
|
+
var maxHeight = clientHeight - 200;
|
334
|
+
var width = maxWidth;
|
335
|
+
var height = width / imageDelta;
|
336
|
+
|
337
|
+
if (height >= maxHeight) {
|
338
|
+
height = maxHeight;
|
339
|
+
width = height * imageDelta;
|
340
|
+
}
|
341
|
+
|
342
|
+
setMapSize({
|
343
|
+
width: "".concat(width, "px"),
|
344
|
+
height: "".concat(height, "px")
|
345
|
+
});
|
346
|
+
setPlanScale((0, _panoramaHelpers.getScale)({
|
347
|
+
width: width,
|
348
|
+
height: height
|
349
|
+
}, json));
|
350
|
+
viewer.onWindowResize(clientWidth, clientHeight);
|
258
351
|
};
|
259
352
|
|
260
|
-
|
353
|
+
var onImageLoaded = function onImageLoaded() {
|
261
354
|
setScale();
|
262
355
|
setMapDisabledState(!json);
|
263
356
|
};
|
264
357
|
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
return className;
|
269
|
-
};
|
270
|
-
|
271
|
-
const getDotPosition = _ref5 => {
|
272
|
-
let {
|
273
|
-
left,
|
274
|
-
top
|
275
|
-
} = _ref5;
|
358
|
+
var getDotPosition = function getDotPosition(_ref5) {
|
359
|
+
var left = _ref5.left,
|
360
|
+
top = _ref5.top;
|
276
361
|
return {
|
277
362
|
left: "".concat(left * planScale.X, "px"),
|
278
363
|
top: "".concat(top * planScale.Y, "px")
|
279
364
|
};
|
280
365
|
};
|
281
366
|
|
282
|
-
|
367
|
+
var updateCameraFov = function updateCameraFov(fov) {
|
283
368
|
setCameraFov(fov);
|
284
369
|
viewer.camera.fov = fov;
|
285
370
|
viewer.camera.currentFov = fov;
|
286
371
|
viewer.camera.updateProjectionMatrix();
|
287
372
|
};
|
288
373
|
|
289
|
-
|
374
|
+
var toggleFov = function toggleFov() {
|
290
375
|
if (viewer.camera.fov === cameraFovValues.x1) {
|
291
376
|
updateCameraFov(cameraFovValues.x2);
|
292
377
|
return;
|
@@ -295,38 +380,58 @@ const PanoramaTab = _ref4 => {
|
|
295
380
|
updateCameraFov(cameraFovValues.x1);
|
296
381
|
};
|
297
382
|
|
298
|
-
|
383
|
+
var toggleAutoplay = function toggleAutoplay() {
|
299
384
|
setAutoplayState(!autoplayEnabled);
|
300
385
|
|
301
386
|
if (autoplayEnabled) {
|
302
387
|
viewer.disableAutoRate();
|
388
|
+
|
389
|
+
if (deviceOrientationStatus === _deviceOrientationStatuses.deviceOrientationStatuses.GRANTED) {
|
390
|
+
viewer.enableControl(DEVICEORIENTATION);
|
391
|
+
}
|
392
|
+
|
303
393
|
return;
|
304
394
|
}
|
305
395
|
|
396
|
+
if (viewer.getControlId() !== 'orbit') {
|
397
|
+
viewer.enableControl(ORBIT);
|
398
|
+
}
|
399
|
+
|
306
400
|
viewer.enableAutoRate();
|
307
401
|
};
|
308
402
|
|
309
|
-
|
403
|
+
var updateWindowWidth = function updateWindowWidth() {
|
404
|
+
return setWindowSize({
|
405
|
+
width: window.innerWidth,
|
406
|
+
height: window.innerHeight
|
407
|
+
});
|
408
|
+
};
|
409
|
+
|
410
|
+
var rescaleMap = function rescaleMap() {
|
411
|
+
var map = document.querySelector('.widget-tab__panorama-map');
|
412
|
+
if (!map) return;
|
413
|
+
map.classList.remove('widget-tab__panorama-map--scaled');
|
414
|
+
};
|
310
415
|
|
311
|
-
(0, _react.useEffect)(()
|
416
|
+
(0, _react.useEffect)(function () {
|
312
417
|
window.addEventListener('resize', updateWindowWidth);
|
418
|
+
updateWindowWidth();
|
313
419
|
return function cleanup() {
|
314
420
|
window.removeEventListener('resize', updateWindowWidth);
|
315
421
|
};
|
316
422
|
}, []);
|
317
|
-
(0, _react.useEffect)(()
|
423
|
+
(0, _react.useEffect)(function () {
|
318
424
|
if (!panoramas.length) return;
|
319
|
-
|
320
|
-
|
321
|
-
autoRotateActivationDuration:
|
425
|
+
var container = document.querySelector('.widget-tab__panorama-overlay');
|
426
|
+
var newViewer = new PANOLENS.Viewer({
|
427
|
+
autoRotateActivationDuration: 1000,
|
428
|
+
cameraFov: cameraFovValues.x1,
|
322
429
|
autoHideInfospot: false,
|
323
430
|
controlButtons: [],
|
324
|
-
|
325
|
-
cameraFov: cameraFovValues.x1,
|
326
|
-
container
|
431
|
+
container: container
|
327
432
|
});
|
328
433
|
|
329
|
-
|
434
|
+
var preventCameraFovChange = function preventCameraFovChange(e) {
|
330
435
|
e.preventDefault();
|
331
436
|
e.stopPropagation();
|
332
437
|
newViewer.camera.fov = newViewer.camera.currentFov;
|
@@ -335,12 +440,10 @@ const PanoramaTab = _ref4 => {
|
|
335
440
|
|
336
441
|
container.addEventListener('mousewheel', preventCameraFovChange);
|
337
442
|
container.addEventListener('touchmove', preventCameraFovChange);
|
338
|
-
panoramas.forEach(panorama
|
443
|
+
panoramas.forEach(function (panorama) {
|
339
444
|
if (!panorama.panorama_id) return;
|
340
|
-
panorama.addEventListener('enter', _ref6
|
341
|
-
|
342
|
-
target
|
343
|
-
} = _ref6;
|
445
|
+
panorama.addEventListener('enter', function (_ref6) {
|
446
|
+
var target = _ref6.target;
|
344
447
|
return setCurrentRoomIndex(target['panorama_index']);
|
345
448
|
});
|
346
449
|
newViewer.add(panorama);
|
@@ -348,68 +451,94 @@ const PanoramaTab = _ref4 => {
|
|
348
451
|
newViewer.scene.rotation.y = Math.PI / 2;
|
349
452
|
newViewer.camera.currentFov = cameraFovValues.x1;
|
350
453
|
setViewer(newViewer);
|
351
|
-
|
352
|
-
|
454
|
+
var camera = new THREE.PerspectiveCamera(75, container.clientWidth / container.clientHeight, 1, 1000);
|
455
|
+
var orientationControls = new _threeDeviceOrientation.default(camera);
|
456
|
+
|
457
|
+
var getAngle = function getAngle(control) {
|
458
|
+
if (control.alpha) {
|
459
|
+
return control.alpha - THREE.MathUtils.degToRad(control.screenOrientation);
|
460
|
+
}
|
461
|
+
|
462
|
+
return control.getAzimuthalAngle();
|
463
|
+
};
|
353
464
|
|
354
|
-
|
465
|
+
var animate = function animate() {
|
355
466
|
window.requestAnimationFrame(animate);
|
356
|
-
camera.aspect = window.innerWidth / window.innerHeight;
|
357
|
-
camera.updateProjectionMatrix();
|
358
467
|
orientationControls.update();
|
359
|
-
|
468
|
+
var fovElement = document.querySelector('.widget-tab__panorama-map__fov');
|
360
469
|
if (!fovElement) return;
|
361
|
-
|
362
|
-
const angle = -(control.alpha || control.getAzimuthalAngle());
|
470
|
+
var angle = -getAngle(newViewer.getControl());
|
363
471
|
fovElement.style.transform = "translate(-50%, -50%) rotate(".concat(angle, "rad)");
|
364
472
|
};
|
365
473
|
|
366
474
|
animate();
|
367
475
|
}, [panoramas]);
|
368
|
-
(0, _react.useEffect)(setScale, [json,
|
369
|
-
(0, _react.useEffect)(
|
476
|
+
(0, _react.useEffect)(setScale, [json, windowSize, viewer]);
|
477
|
+
(0, _react.useEffect)(function () {
|
478
|
+
return setPanoramas(getPanoramas(json, images, setLoadingState));
|
479
|
+
}, [json, images]);
|
480
|
+
|
481
|
+
var requestDeviceOrientation = function requestDeviceOrientation() {
|
482
|
+
return DeviceOrientationEvent.requestPermission().then(function (status) {
|
483
|
+
setDeviceOrientationStatus(status);
|
484
|
+
|
485
|
+
if (status !== _deviceOrientationStatuses.deviceOrientationStatuses.GRANTED) {
|
486
|
+
viewer.enableControl(ORBIT);
|
487
|
+
return;
|
488
|
+
}
|
370
489
|
|
371
|
-
|
490
|
+
viewer.enableControl(DEVICEORIENTATION);
|
491
|
+
});
|
492
|
+
};
|
493
|
+
|
494
|
+
var onStart = function onStart() {
|
372
495
|
setInstructionsState(false);
|
373
496
|
|
374
497
|
try {
|
375
498
|
if (!DeviceOrientationEvent.requestPermission) return;
|
376
|
-
return
|
377
|
-
if (status !== _deviceOrientationStatus.deviceOrientationStatus.GRANTED) {
|
378
|
-
setTimeout(() => viewer.enableControl(ORBIT), 100);
|
379
|
-
return;
|
380
|
-
}
|
381
|
-
|
382
|
-
setTimeout(() => viewer.enableControl(DEVICEORIENTATION), 100);
|
383
|
-
});
|
499
|
+
return requestDeviceOrientation();
|
384
500
|
} catch (error) {
|
385
501
|
console.error(error.message);
|
386
502
|
}
|
387
503
|
};
|
388
504
|
|
389
|
-
|
390
|
-
return points.map(_ref7
|
391
|
-
|
505
|
+
var getRoomPointsAsString = function getRoomPointsAsString(points) {
|
506
|
+
return points.map(function (_ref7) {
|
507
|
+
var _ref8 = _slicedToArray(_ref7, 2),
|
508
|
+
x = _ref8[0],
|
509
|
+
y = _ref8[1];
|
510
|
+
|
392
511
|
return [x * planScale.X, y * planScale.Y];
|
393
|
-
}).flat().filter(
|
512
|
+
}).flat().filter(function (num) {
|
513
|
+
return !isNaN(num);
|
514
|
+
}).toString();
|
394
515
|
};
|
395
516
|
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
517
|
+
var onMapClick = function onMapClick(event) {
|
518
|
+
if (loadingState) return;
|
519
|
+
var map = document.querySelector('.widget-tab__panorama-map');
|
520
|
+
|
521
|
+
if (windowSize.width <= _deviceWidth.deviceWidth.tablet) {
|
522
|
+
if (!map.classList.contains('widget-tab__panorama-map--scaled')) {
|
523
|
+
map.classList.add('widget-tab__panorama-map--scaled');
|
524
|
+
return;
|
525
|
+
}
|
526
|
+
}
|
527
|
+
|
528
|
+
rescaleMap();
|
529
|
+
var image = document.querySelector('.widget-tab__panorama-map img');
|
530
|
+
var clientX = event.clientX,
|
531
|
+
clientY = event.clientY;
|
532
|
+
var x = (clientX - image.x) / planScale.X;
|
533
|
+
var y = (clientY - image.y) / planScale.Y;
|
534
|
+
var availablePanoramas = panoramas.filter(function (_ref9) {
|
535
|
+
var userData = _ref9.userData;
|
408
536
|
return (0, _geometric.pointInPolygon)([x, y], userData.points);
|
409
537
|
});
|
410
|
-
|
411
|
-
|
412
|
-
|
538
|
+
|
539
|
+
var _getClosestPanorama2 = (0, _panoramaHelpers.getClosestPanorama)([x, y], availablePanoramas),
|
540
|
+
panorama = _getClosestPanorama2.panorama;
|
541
|
+
|
413
542
|
if (!panorama) return;
|
414
543
|
changePanorama(panorama);
|
415
544
|
};
|
@@ -417,30 +546,26 @@ const PanoramaTab = _ref4 => {
|
|
417
546
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
418
547
|
className: "widget-tab__panorama"
|
419
548
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
420
|
-
className: "widget-tab__panorama-overlay"
|
549
|
+
className: "widget-tab__panorama-overlay",
|
550
|
+
onContextMenu: _helpers.preventRightClick
|
421
551
|
}), loadingState && /*#__PURE__*/_react.default.createElement(_Loader.default, {
|
422
552
|
absolute: true
|
423
553
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
424
554
|
className: "widget-tab__panorama-map ".concat(isMapDisabled ? 'widget-tab__panorama-map--hidden' : '')
|
425
555
|
}, /*#__PURE__*/_react.default.createElement("img", {
|
426
556
|
src: planImage,
|
427
|
-
|
428
|
-
alt: "plan"
|
429
|
-
|
430
|
-
|
431
|
-
className: getDotClassName(index),
|
432
|
-
style: getDotPosition(panorama.userData),
|
433
|
-
onClick: () => changePanorama(panorama)
|
434
|
-
})), /*#__PURE__*/_react.default.createElement("div", {
|
557
|
+
style: mapSize,
|
558
|
+
alt: "plan",
|
559
|
+
onLoad: onImageLoaded
|
560
|
+
}), !isMapDisabled && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
435
561
|
className: "widget-tab__panorama-map__fov",
|
436
562
|
style: getDotPosition(((_panoramas$currentRoo = panoramas[currentRoomIndex]) === null || _panoramas$currentRoo === void 0 ? void 0 : _panoramas$currentRoo.userData) || getDefaultUserData())
|
437
563
|
}), /*#__PURE__*/_react.default.createElement("svg", {
|
564
|
+
width: mapSize.width,
|
438
565
|
key: "X-".concat(planScale.X, "-Y-").concat(planScale.Y),
|
439
566
|
onClick: onMapClick
|
440
|
-
}, panoramas.map((
|
441
|
-
|
442
|
-
userData
|
443
|
-
} = _ref9;
|
567
|
+
}, panoramas.map(function (_ref10, index) {
|
568
|
+
var userData = _ref10.userData;
|
444
569
|
return /*#__PURE__*/_react.default.createElement("polygon", {
|
445
570
|
key: index,
|
446
571
|
points: getRoomPointsAsString(userData.points)
|