@panoramax/web-viewer 4.0.3-develop-d8c835a2 → 4.0.3-develop-b8d837b4
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/CHANGELOG.md +1 -0
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/docs/03_URL_settings.md +21 -0
- package/package.json +1 -1
- package/src/utils/InitParameters.js +33 -1
- package/src/utils/URLHandler.js +1 -1
package/docs/03_URL_settings.md
CHANGED
|
@@ -75,6 +75,27 @@ Example:
|
|
|
75
75
|
xyz=10/25/50
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
### :material-tag-arrow-right: `xywh`: picture position (annotation format)
|
|
79
|
+
|
|
80
|
+
The position to show on picture at first load, in common annotation format.
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
x,y,w,h
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
With:
|
|
87
|
+
|
|
88
|
+
- `x`: the horizontal offset compared to original picture left border (in pixels)
|
|
89
|
+
- `y`: the vertical offset compared to original picture top border (in pixels)
|
|
90
|
+
- `w`: the area width (in pixels)
|
|
91
|
+
- `h`: the area height (in pixels)
|
|
92
|
+
|
|
93
|
+
Example:
|
|
94
|
+
|
|
95
|
+
```urlencoded
|
|
96
|
+
xywh=3520,1264,96,112
|
|
97
|
+
```
|
|
98
|
+
|
|
78
99
|
## :map: Map settings
|
|
79
100
|
|
|
80
101
|
### :fontawesome-solid-location-dot: `map`: map position and visibility
|
package/package.json
CHANGED
|
@@ -89,6 +89,7 @@ export default class InitParameters { // eslint-disable-line import/no-unused-mo
|
|
|
89
89
|
let map_pic_type = urlParams.pic_type;
|
|
90
90
|
let map_camera = urlParams.camera;
|
|
91
91
|
let map_pic_score = urlParams.pic_score;
|
|
92
|
+
let psv_xywh = urlParams.xywh;
|
|
92
93
|
|
|
93
94
|
// Check coherence
|
|
94
95
|
if(!["map", "pic"].includes(focus)) {
|
|
@@ -121,7 +122,7 @@ export default class InitParameters { // eslint-disable-line import/no-unused-mo
|
|
|
121
122
|
transitionDuration: psv_speed,
|
|
122
123
|
picturesNavigation: psv_nav,
|
|
123
124
|
};
|
|
124
|
-
this._psvPostInit = { xyz: psv_xyz };
|
|
125
|
+
this._psvPostInit = { xyz: psv_xyz, xywh: psv_xywh };
|
|
125
126
|
|
|
126
127
|
this._mapInit = {
|
|
127
128
|
raster: map_raster,
|
|
@@ -280,6 +281,28 @@ export function xyzParamToPSVPosition(str) {
|
|
|
280
281
|
else { return null; }
|
|
281
282
|
}
|
|
282
283
|
|
|
284
|
+
/**
|
|
285
|
+
* Extracts from string xywh position
|
|
286
|
+
* @param {string} str The xywh position as hash string
|
|
287
|
+
* @param {object} [picmeta] The current picture metadata, used to compute zoom based on image size
|
|
288
|
+
* @returns {object} { textureX, textureY, z }
|
|
289
|
+
* @private
|
|
290
|
+
*/
|
|
291
|
+
function xywhParamToPSVPosition(str, picmeta) {
|
|
292
|
+
const loc = (str || "").split(",");
|
|
293
|
+
if (loc.length === 4 && !loc.some(v => isNaN(v))) {
|
|
294
|
+
const size = picmeta?.properties?.["pers:interior_orientation"]?.sensor_array_dimensions;
|
|
295
|
+
const res = {
|
|
296
|
+
textureX: +loc[0] + loc[2] / 2,
|
|
297
|
+
textureY: +loc[1] + loc[3] / 2,
|
|
298
|
+
z: size && size.length == 2 ? (1 - (((loc[2] / size[0]) + (loc[3] / size[1])) / 2)) * 75 : null,
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
return res;
|
|
302
|
+
}
|
|
303
|
+
else { return null; }
|
|
304
|
+
}
|
|
305
|
+
|
|
283
306
|
/**
|
|
284
307
|
* Extracts from hash parsed keys all map filters values
|
|
285
308
|
* @param {*} vals Hash keys
|
|
@@ -315,6 +338,15 @@ export function alterPSVState(psv, params) {
|
|
|
315
338
|
}, {once: true});
|
|
316
339
|
}
|
|
317
340
|
|
|
341
|
+
// Change xywh position
|
|
342
|
+
if(params.xywh) {
|
|
343
|
+
psv.addEventListener("picture-loaded", () => {
|
|
344
|
+
const coords = xywhParamToPSVPosition(params.xywh, psv.getPictureMetadata());
|
|
345
|
+
psv.rotate(coords);
|
|
346
|
+
psv.zoom(coords.z);
|
|
347
|
+
}, {once: true});
|
|
348
|
+
}
|
|
349
|
+
|
|
318
350
|
// Change transitionDuration
|
|
319
351
|
let td = params.transitionDuration || params.speed;
|
|
320
352
|
if(td !== undefined) {
|
package/src/utils/URLHandler.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
// List of supported parameters
|
|
6
6
|
const MANAGED_PARAMETERS = [
|
|
7
7
|
"speed", "nav", "focus", "pic", "xyz", "map",
|
|
8
|
-
"background", "users", "pic_score", "s"
|
|
8
|
+
"background", "users", "pic_score", "s", "xywh",
|
|
9
9
|
].concat(Object.values(MAP_FILTERS_JS2URL));
|
|
10
10
|
|
|
11
11
|
// Events to listen on parent and PSV
|