Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marker Rotation is set to zero when updating marker position #1292

Closed
Rai-Rai opened this issue Apr 17, 2024 · 3 comments
Closed

Marker Rotation is set to zero when updating marker position #1292

Rai-Rai opened this issue Apr 17, 2024 · 3 comments
Labels
Milestone

Comments

@Rai-Rai
Copy link

Rai-Rai commented Apr 17, 2024

Describe the bug

I'm updating the position of a marker (In reality via Drag'nDrop but I've changed this to the select-marker event for this bug report). The rotation of the marker is lost if the position is updated. This happens also if the tooltip is updated. (Not tested with other attributes)

Generate Marker:

createMarker() {
    const newMarker: MarkerConfig = {
      id: guid(),
      position: this.viewer.getPosition(),
      image: 'https://fonts.gstatic.com/s/i/materialiconsoutlined/arrow_circle_right/v2/24px.svg',
      size: {width: 90, height: 90},
      rotation: '90deg',
      anchor: 'center center',
      tooltip: 'Generated pin Generated pin Generated pin Generated pin Generated pin Generated pin Generated pin Generated pin Generated pin ',
      data: {
        generated: true,
      },
    }
    this.addMarker(newMarker);
  }

private addMarker(marker: MarkerConfig) {
    this.markersPlugin.addMarker(marker);
  }

changing the position by click on the marker

this.markersPlugin.addEventListener('select-marker', ({marker, doubleClick, rightClick}) => {

      const intersect = this.viewer.dataHelper.viewerCoordsToVector3({x: 100, y: 100})
      const newMarkerPosition = this.viewer.dataHelper.vector3ToSphericalCoords(intersect);

      //rotation before update
      console.log("rotation before updating Marker: ", this.markersPlugin.getMarker(marker.id).config.rotation);

      //rotation is lost
      this.markersPlugin.updateMarker({id: marker.id, position: newMarkerPosition});
      // this.markersPlugin.updateMarker({id: marker.id, tooltip: 'hello'});

      //this would (of course) keep the rotation
      // this.markersPlugin.updateMarker({id: marker.id, position: newMarkerPosition, rotation: marker.config.rotation});

      //rotation after update
      console.log("rotation after updating Marker: ", this.markersPlugin.getMarker(marker.id).config.rotation);

}

console output:

rotation before updating Marker:  1.5707963267948966
rotation after updating Marker:  0

I assume that the problem is caused here after merging the two configs:

since I don't see the warning of the try-catch block in my console it's likely already ending on L164 with the IF

The whole thing is done with:

Online demo URL

https://codesandbox.io/p/devbox/optimistic-https-gqs3n6?file=%2Fsrc%2Fapp%2Fapp.component.ts

Photo Sphere Viewer version

5.7.2

Plugins loaded

Markers Plugin

OS & browser

Win/Chrome

Additional context

No response

@Rai-Rai Rai-Rai added the bug label Apr 17, 2024
@mistic100
Copy link
Owner

thank you for the complete analysis :)

@mistic100 mistic100 added this to the 5.7.3 milestone Apr 22, 2024
Copy link

This feature/bug fix has been released in version 5.7.3.

@Rai-Rai
Copy link
Author

Rai-Rai commented Apr 23, 2024

Thank you, works great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants