hart-estate-widget 0.0.32 → 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.
Binary file
|
Binary file
|
@@ -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");
|
@@ -27,6 +31,10 @@ var _panoramaHelpers = require("../utils/panoramaHelpers");
|
|
27
31
|
|
28
32
|
var _geometric = require("geometric");
|
29
33
|
|
34
|
+
var _spotIcon = _interopRequireDefault(require("../assets/img/spot-icon.png"));
|
35
|
+
|
36
|
+
var _doorIcon = _interopRequireDefault(require("../assets/img/door-icon.png"));
|
37
|
+
|
30
38
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
31
39
|
|
32
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); }
|
@@ -38,6 +46,19 @@ const {
|
|
38
46
|
ORBIT
|
39
47
|
} = PANOLENS.CONTROLS;
|
40
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
|
+
};
|
41
62
|
|
42
63
|
const createPanorama = (image, index, setLoadingState) => {
|
43
64
|
const panorama = new PANOLENS.ImagePanorama(image);
|
@@ -56,17 +77,19 @@ const createPanorama = (image, index, setLoadingState) => {
|
|
56
77
|
const getPanoramas = (json, images, setLoadingState) => {
|
57
78
|
if (!json) return images.map((image, index) => createPanorama(image, index, setLoadingState));
|
58
79
|
return json.Floors[0].Units[0].Rooms.reduce((acc, jsonRoom, index) => {
|
59
|
-
const
|
60
|
-
if (!
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
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
|
+
});
|
70
93
|
return acc;
|
71
94
|
}, []);
|
72
95
|
};
|
@@ -83,9 +106,18 @@ const getPanoramaRooms = (json, panoramas) => {
|
|
83
106
|
top: 0
|
84
107
|
};
|
85
108
|
const currentRoom = json.Floors[0].Units[0].Rooms.find(room => room.ID === panorama['room_id']);
|
86
|
-
|
109
|
+
let [left, top] = (0, _geometric.polygonMean)((0, _panoramaHelpers.getRoomCoordinates)(currentRoom, json.Floors[0].Walls, json.Vertices));
|
87
110
|
|
88
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
|
+
|
89
121
|
setPanoramaLinks(json, currentRoom, [left, top], panorama, panoramas);
|
90
122
|
}
|
91
123
|
|
@@ -100,11 +132,22 @@ const getPanoramaRooms = (json, panoramas) => {
|
|
100
132
|
};
|
101
133
|
|
102
134
|
const setPanoramaLinks = (json, currentRoom, center, panorama, panoramas) => {
|
103
|
-
|
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 => {
|
104
147
|
let {
|
105
148
|
Location,
|
106
149
|
Walls
|
107
|
-
} =
|
150
|
+
} = _ref3;
|
108
151
|
if (!Walls.some(doorWallId => currentRoom.Walls.some(roomWallId => roomWallId === doorWallId))) return;
|
109
152
|
const connectedRoom = json.Floors[0].Units[0].Rooms.find(room => {
|
110
153
|
const roomHasSameWall = room.Walls.some(roomWallId => Walls.some(doorWallId => roomWallId === doorWallId));
|
@@ -112,26 +155,33 @@ const setPanoramaLinks = (json, currentRoom, center, panorama, panoramas) => {
|
|
112
155
|
return roomHasSameWall && !isSameRoom;
|
113
156
|
});
|
114
157
|
if (!connectedRoom) return;
|
115
|
-
const connectedPanorama = panoramas.find(
|
158
|
+
const connectedPanorama = panoramas.find(_ref4 => {
|
116
159
|
let {
|
117
160
|
room_id
|
118
|
-
} =
|
161
|
+
} = _ref4;
|
119
162
|
return room_id === connectedRoom.ID;
|
120
163
|
});
|
121
164
|
if (!connectedPanorama) return;
|
122
|
-
|
123
|
-
const locationY = Location.X - center[0];
|
124
|
-
const defaultScale = 20;
|
125
|
-
const maxScale = 50;
|
126
|
-
const defaultLength = 120;
|
127
|
-
const length = (0, _geometric.lineLength)([[0, 0], [locationX, locationY]]);
|
128
|
-
const scale = length / defaultLength * defaultScale;
|
129
|
-
const finalScale = scale > maxScale ? maxScale : scale;
|
130
|
-
const position = new THREE.Vector3(locationX, -10, locationY);
|
131
|
-
panorama.link(connectedPanorama, position, finalScale);
|
165
|
+
connectPanorama(panorama, connectedPanorama, Location, center, true);
|
132
166
|
});
|
133
167
|
};
|
134
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
|
+
|
135
185
|
const initPanorama = () => {
|
136
186
|
let camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 1100);
|
137
187
|
let controls = new _threeDeviceOrientation.default(camera);
|
@@ -157,12 +207,12 @@ const initPanorama = () => {
|
|
157
207
|
};
|
158
208
|
};
|
159
209
|
|
160
|
-
const PanoramaTab =
|
210
|
+
const PanoramaTab = _ref5 => {
|
161
211
|
let {
|
162
212
|
json,
|
163
213
|
planImage,
|
164
214
|
images
|
165
|
-
} =
|
215
|
+
} = _ref5;
|
166
216
|
const [menuState, setMenuState] = (0, _react.useState)(false);
|
167
217
|
const [loadingState, setLoadingState] = (0, _react.useState)(true);
|
168
218
|
const [isMapActive, setMapState] = (0, _react.useState)(false);
|
@@ -240,10 +290,10 @@ const PanoramaTab = _ref3 => {
|
|
240
290
|
});
|
241
291
|
panoramas.forEach(panorama => {
|
242
292
|
if (!panorama.panorama_id) return;
|
243
|
-
panorama.addEventListener('enter',
|
293
|
+
panorama.addEventListener('enter', _ref6 => {
|
244
294
|
let {
|
245
295
|
target
|
246
|
-
} =
|
296
|
+
} = _ref6;
|
247
297
|
return setCurrentRoomIndex(target['panorama_index']);
|
248
298
|
});
|
249
299
|
newViewer.add(panorama);
|
@@ -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;
|