hart-estate-widget 0.0.28 → 0.0.31

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.
@@ -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: !config.panoramaImages[0],
85
- image: config.panoramaImages[0],
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
@@ -13,6 +13,8 @@ require("core-js/modules/web.dom-collections.iterator.js");
13
13
 
14
14
  var _react = _interopRequireWildcard(require("react"));
15
15
 
16
+ var _store = _interopRequireDefault(require("../store"));
17
+
16
18
  var THREE = _interopRequireWildcard(require("three"));
17
19
 
18
20
  var PANOLENS = _interopRequireWildcard(require("panolens"));
@@ -58,7 +60,13 @@ const getPanoramas = (json, images, setLoadingState) => {
58
60
  if (!image) return acc;
59
61
  const panorama = createPanorama(image, index, setLoadingState);
60
62
  panorama['room_id'] = jsonRoom.ID;
61
- acc.push(panorama);
63
+
64
+ if (panorama['room_id'] === _store.default.hallRoomId) {
65
+ acc.unshift(panorama);
66
+ } else {
67
+ acc.push(panorama);
68
+ }
69
+
62
70
  return acc;
63
71
  }, []);
64
72
  };
@@ -206,12 +214,30 @@ const PanoramaTab = _ref3 => {
206
214
  };
207
215
 
208
216
  (0, _react.useEffect)(() => {
217
+ const container = document.querySelector('.widget-tab__panorama-overlay');
209
218
  const newViewer = new PANOLENS.Viewer({
210
- container: document.querySelector('.widget-tab__panorama-overlay'),
219
+ container,
211
220
  autoHideInfospot: false,
212
221
  controlButtons: [],
213
222
  cameraFov: 90
214
223
  });
224
+ container.addEventListener('mousewheel', e => {
225
+ e.preventDefault();
226
+ e.stopPropagation();
227
+ const scope = newViewer.getControl();
228
+ const fovStep = 2;
229
+
230
+ if (e.deltaY > 0) {
231
+ const newFov = scope.object.fov + fovStep;
232
+ scope.object.fov = newFov < scope.maxFov ? newFov : scope.maxFov;
233
+ scope.object.updateProjectionMatrix();
234
+ return;
235
+ }
236
+
237
+ const newFov = scope.object.fov - fovStep;
238
+ scope.object.fov = newFov > scope.minFov ? newFov : scope.minFov;
239
+ scope.object.updateProjectionMatrix();
240
+ });
215
241
  panoramas.forEach(panorama => {
216
242
  if (!panorama.panorama_id) return;
217
243
  panorama.addEventListener('enter', _ref4 => {
@@ -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: panoramaImages[0],
48
+ img: _store.default.hallRoomImage,
50
49
  icon: null
51
50
  },
52
51
  'rotation': {
@@ -638,7 +638,7 @@ class HouseStore {
638
638
  const modelPath = "".concat(this.apiStore.API_URL, "/storage/furniture/").concat(mesh);
639
639
  const {
640
640
  Location,
641
- WEB_Rotation,
641
+ Rotation,
642
642
  Model: ModelName
643
643
  } = furniture;
644
644
  const {
@@ -727,7 +727,7 @@ class HouseStore {
727
727
  const model = originalModel.clone();
728
728
  model.scale.set(this.sceneScale, this.sceneScale, this.sceneScale);
729
729
  model.position.set(X * this.sceneScale, Y * this.sceneScale, Z * this.sceneScale);
730
- model.rotation.set(Math.PI / 2, THREE.Math.degToRad(WEB_Rotation.Yaw), 0);
730
+ model.rotation.set(Math.PI / 2, THREE.Math.degToRad(Rotation.Yaw), 0);
731
731
  const loadedTextures = this.loadedTextures[ModelName];
732
732
 
733
733
  if (loadedTextures) {
@@ -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,37 @@ 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
+ return door.Walls.some(doorWallId => json.Floors[0].ExteriorWalls.some(exteriorWallId => exteriorWallId === doorWallId));
44
+ });
45
+ const wallWithExteriorDoor = exteriorDoor.Walls.find(wallId => wallId !== exteriorWallWithDoor);
46
+ const room = json.Floors[0].Units[0].Rooms.find(_ref => {
47
+ let {
48
+ Walls
49
+ } = _ref;
50
+ return Walls.some(wallId => wallId === wallWithExteriorDoor);
51
+ });
52
+ return room.ID;
53
+ }
54
+
55
+ get hallRoomImage() {
56
+ const {
57
+ json,
58
+ panoramaImages
59
+ } = this.config;
60
+ const roomIndex = json.Floors[0].Units[0].Rooms.findIndex(room => room.ID === this.hallRoomId);
61
+ const image = panoramaImages.find(url => url.includes("".concat(roomIndex, ".png")));
62
+ return image || panoramaImages[0];
63
+ }
64
+
32
65
  setConfig(config) {
33
66
  this.config = config;
34
67
  }
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.28",
6
+ "version": "0.0.31",
7
7
  "private": false,
8
8
  "main": "build/index.js",
9
9
  "module": "build/index.js",