mistic100 / Photo-Sphere-Viewer

A JavaScript library to display 360° sphere panoramas.
https://photo-sphere-viewer.js.org
MIT License
1.89k stars 681 forks source link

Marker: Replacing orientation with rotation doesn't work as expected #1339

Closed Rai-Rai closed 3 months ago

Rai-Rai commented 3 months ago

Describe your problem

As discussed in the other Bug Report I'm replacing the deprecated orientation with rotation.

At the moment I assume that it's a misunderstanding on my end, hence a Support request. I've attached an online demo.

The aim is to have the orientation=horizontal effect by using rotation.

If you comment rotation in line 45 and enable orientation in line 46 it works perfectly as always. (Just to prove that the marker works).

//rotation: { pitch: rotationTest },
orientation: 'horizontal', // No problem if orientation is used instead of rotation

If you use rotation.pitch with the static value of 1 (Line 38) then the marker is visible (but of course a bit strange) const rotationTest = currentViewPosition.pitch < 0 ? -1 : 1;

If you use the rotation.pitch with the Pi/2 value (Line 35) then the marker is not visible at all. const rotationTest = currentViewPosition.pitch < 0 ? -Math.PI / 2 : Math.PI / 2;

I don't understand the problem based on the Deprecation notice and the old code, hope you can point me in the right direction. https://github.com/mistic100/Photo-Sphere-Viewer/blob/c03c92a09f7a4fb4a646b0a777577bc56a92d736/packages/markers-plugin/src/markers/Marker3D.ts#L124

Online demo URL

https://codesandbox.io/p/sandbox/trusting-turing-c3wppz

Photo Sphere Viewer version

5.8.1

Plugins loaded

MarkerPlugin

Additional context

No response

shyxn commented 3 months ago

Maybe it's because of the signed value

This should help : const rotationTest = currentViewPosition.pitch < 0 ? Math.PI / 2 : -Math.PI / 2;

When using rotation config instead of orientation, the signed values are reversed : https://github.com/mistic100/Photo-Sphere-Viewer/blob/c03c92a09f7a4fb4a646b0a777577bc56a92d736/packages/markers-plugin/src/markers/Marker3D.ts#L134-L138

I don't know much about it, but it's probably a ThreeJS constraint.

Rai-Rai commented 3 months ago

Oh damn, I've missed this difference between the if and else. Solved. I'll create a PR for the docu later