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 behaviour with updateMarker() #1335

Closed
shyxn opened this issue Jun 24, 2024 · 4 comments
Closed

Marker rotation behaviour with updateMarker() #1335

shyxn opened this issue Jun 24, 2024 · 4 comments
Labels
Milestone

Comments

@shyxn
Copy link

shyxn commented Jun 24, 2024

Describe the bug

Hello!


(I think it was a very wise decision to abandon "orientation" in favor of 
"rotation" in 5.8, so thank you!)



Here’s my beautiful little ImageLayer marker :

image 19(1)

If you apply a rotation using updateMarker() (or directly in the initial marker config in addMarker()) :
updateMarker({id: "yid7gnnhtsb", rotation: {roll: 1.2}}, true)

image 20

This works fine, but if you then update another marker config property, for example opacity :
updateMarker({id: "yid7gnnhtsb", opacity: 0.6}, true)

image 22

The modification was successful but the marker rotated another 1.2 on roll.

This bug also occurs with yaw and pitch.

I think updateMarker renders again the rotation values contained in marker’s config : 


Frame 9(1)

(However, I think it’s not the case with MarkersPlugin.renderMarkers() method.)

The workaround I'm using for now is to call updateMarker a second time
after a rotation update call, to reset directly the marker's rotation properties to 0, as it will not replace the visual rotation aspect.

I think it would be nice to have a property or method on MarkerConfig so that we can get the real current "cumulative" rotation values of a marker (in order to reuse them once with addMarker(), for example), as is the case with other MarkerConfig properties (position, size, etc.).

Here if you have any other questions.

Thank you very much!



Online demo URL

No response

Photo Sphere Viewer version

5.8.0

Plugins loaded

No response

OS & browser

Windows, Chrome 126

Additional context

No response

@shyxn shyxn added the bug label Jun 24, 2024
@mistic100 mistic100 added this to the 5.8.1 milestone Jun 24, 2024
@Rai-Rai
Copy link

Rai-Rai commented Jun 24, 2024

Hi,
I've also migrated from orientation to rotation today and observed the following:

  1. If I create an imageLayer marker with rotation yaw/pitch = 0 --> Every button click creates a marker ✔️
    If I create an imageLayer marker with rotation yaw=0 pitch = 1.25 --> Every button click creates a marker ✔️
    If I create an imageLayer marker with rotation yaw=0 pitch = Math.Pi --> Marker is created but invisible ✖️
    Clicking on my Size +/- buttons to increase/decrease the size leads to an interesting effect:
    1st click: marker becomes visible
    2nd click: marker becoms invisible
    3rd click: marker becoms visible
    ....

The aim was to reproduce the orientation=horizontal effect, according to the docu:
horizontal → rotation.pitch: (+/-) Math.PI (the sign depends on the marker position.pitch)
Positive/negative makes no difference.

I can't guarantee at the moment that it isn't a problem on my end since I did a major refactoring. But suspicious is that it only happens if I set pitch to Math.Pi.

I'll likely need 1-2 days if you need an online demo or further investigation from my end.

@mistic100
Copy link
Owner

@Rai-Rai sorry, it's an error in the migration doc, it must be +/- Pi / 2

group.rotateX(this.state.position.pitch < 0 ? -Math.PI / 2 : Math.PI / 2);

pitch = PI of course rotates your marker completely on its axis, so it is invisible

@Rai-Rai
Copy link

Rai-Rai commented Jun 25, 2024

Thank you, I'll change it accordingly.
BTW, I think you could simplify the statement by using Math.sign().
So it could be: group.rotateX(Math.sign(this.state.position.pitch) * Math.PI / 2);

Copy link

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

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

3 participants