@panoramax/web-viewer 5.0.0-develop-c36ee660 → 5.0.0-develop-1f5f0b87

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.
@@ -9,7 +9,7 @@ import BasicStyles from "./Basic.css" with { type: "css" };
9
9
  document.adoptedStyleSheets.push(AtkinsonStyles);
10
10
  document.adoptedStyleSheets.push(BasicStyles);
11
11
 
12
- const __COMMIT_HASH__ = "c36ee66";
12
+ const __COMMIT_HASH__ = "1f5f0b8";
13
13
  const __PACKAGE_VERSION__ = "5.0.0";
14
14
  const __PACKAGE_ISSUES_URL__ = "https://gitlab.com/panoramax/clients/web-viewer/-/work_items";
15
15
 
@@ -1370,28 +1370,21 @@ export default class Photo extends PSViewer {
1370
1370
  // Send valid rectangle through event
1371
1371
  if(sendRectEvent) {
1372
1372
  // Get texture coordinates (corresponding to a full 360° sphere)
1373
- const minxy = this.dataHelper.sphericalCoordsToTextureCoords(this._drawingAnnotation[0]);
1374
- const maxxy = this.dataHelper.sphericalCoordsToTextureCoords(this._drawingAnnotation[1]);
1375
- let shape = [
1376
- minxy.textureX,
1377
- minxy.textureY,
1378
- maxxy.textureX,
1379
- maxxy.textureY
1380
- ];
1373
+ let shape = this._myMarkers.markers[DRAW_ANNOT_RECT].config.polygon
1374
+ .map(c => {
1375
+ const t = this.dataHelper.sphericalCoordsToTextureCoords(c);
1376
+ return [t.textureX, t.textureY];
1377
+ });
1381
1378
 
1382
1379
  // Re-compute original texture coordinates (flat or cropped images)
1383
1380
  const crop = this.getPictureMetadata()?.panorama?.cropData;
1384
1381
  if(crop) {
1385
- shape[0] -= crop.croppedX;
1386
- shape[1] -= crop.croppedY;
1387
- shape[2] -= crop.croppedX;
1388
- shape[3] -= crop.croppedY;
1382
+ shape = shape.map(([x,y]) => [x - crop.croppedX, y - crop.croppedY]);
1389
1383
 
1390
1384
  // Check if annotations doesn't go outside of picture
1391
- if(shape[0] < 0 || shape[0] > crop.croppedWidth) { shape = null; }
1392
- else if(shape[1] < 0 || shape[1] > crop.croppedHeight) { shape = null; }
1393
- else if(shape[2] < 0 || shape[2] > crop.croppedWidth) { shape = null; }
1394
- else if(shape[3] < 0 || shape[3] > crop.croppedHeight) { shape = null; }
1385
+ if(shape.find(([x,y]) => x < 0 || x > crop.croppedWidth || y < 0 || y > crop.croppedHeight)) {
1386
+ shape = null;
1387
+ }
1395
1388
 
1396
1389
  // Alert user if shape is invalid
1397
1390
  if(!shape) {
@@ -1401,13 +1394,9 @@ export default class Photo extends PSViewer {
1401
1394
  }
1402
1395
  }
1403
1396
 
1404
- // Check coordinates order
1405
- if(shape && shape[0] >= shape[2] && shape[1] >= shape[3]) {
1406
- let maxx = shape[0];
1407
- let minx = shape[2];
1408
- let maxy = shape[1];
1409
- let miny = shape[3];
1410
- shape = [minx, miny, maxx, maxy];
1397
+ // Add back last coordinate
1398
+ if(shape[0][0] !== shape[shape.length-1][0] || shape[0][1] !== shape[shape.length-1][1]) {
1399
+ shape.push(shape[0]);
1411
1400
  }
1412
1401
 
1413
1402
  /**
@@ -1415,7 +1404,7 @@ export default class Photo extends PSViewer {
1415
1404
  *
1416
1405
  * @event Panoramax.components.ui.Photo#annotation-drawn
1417
1406
  * @type {CustomEvent}
1418
- * @property {string} detail.shape The annotation geometry, or null if latest draw is invalid
1407
+ * @property {number[][]} detail.shape The annotation geometry, or null if latest draw is invalid
1419
1408
  */
1420
1409
  const event = new CustomEvent("annotation-drawn", {
1421
1410
  detail: { shape }
@@ -0,0 +1 @@
1
+ {}
@@ -741,16 +741,10 @@ export default class API extends EventTarget {
741
741
  */
742
742
  createPictureAnnotation(picMeta, shape, semanticsDiff) {
743
743
  // Fake send version
744
- // Return Promise.resolve({
744
+ // return Promise.resolve({
745
745
  // "id": "fe298d59-a9c6-4680-8e76-6efe82d97f48",
746
746
  // "semantics": semanticsDiff,
747
- // "shape": { "type": "Polygon", "coordinates": [[
748
- // [shape[0], shape[1]],
749
- // [shape[0], shape[3]],
750
- // [shape[2], shape[3]],
751
- // [shape[2], shape[1]],
752
- // [shape[0], shape[1]],
753
- // ]] }
747
+ // "shape": { "type": "Polygon", "coordinates": [shape] }
754
748
  // });
755
749
 
756
750
  if(!this.isReady()) { throw new Error("API is not ready to use"); }
@@ -767,7 +761,7 @@ export default class API extends EventTarget {
767
761
  method: "POST",
768
762
  body: JSON.stringify({
769
763
  semantics: semanticsDiff,
770
- shape: shape
764
+ shape: { type: "Polygon", coordinates: [shape] }
771
765
  }),
772
766
  headers: { "Content-Type": "application/json" },
773
767
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panoramax/web-viewer",
3
- "version": "5.0.0-develop-c36ee660",
3
+ "version": "5.0.0-develop-1f5f0b87",
4
4
  "description": "Panoramax web viewer for geolocated pictures",
5
5
  "main": "./build/cjs/index.js",
6
6
  "module": "./build/esm/index.js",