Change Pan direction in speckle viewer

Panned surface in Viewer is not following the cursor rather it is going the opposite direction.
How to change its behaviour such that it follows the cursor when panned.

Is there an option for this, i couldn’t find in the documentation.

Thanks,

Hi @Muhammad_Adnan

From the video I see that the effective action that you want to flip direction in the viewer is the orbiting action,even though in a 360 viewer it would be called “panning”. Flipping orbiting direction is easy, and can be done via CameraController’s options

cameraController.options = { orbitSensitivity: -1 };

For better clarity we will add explicit options for flipping action axes in a future release

I’ve updated the live example I made for you a while ago that simulates a 360 viewer to have the orbiting flipped.

Cheers

Thanks Alex, this is perfect.

1 Like

Hey Alex, another question. i want to keep both views in sync
So when i pan around on image i get a yaw pitch value,then i use yawpitch to cartesian converter, it returns target value
i am passing this target value and original(calculated at initialisation of the viewer) position of the camera in
fromPositionAndTarget

there seems to be a shakiness when transitioning. attached video for reference.

i am thinking its because i am setting both the position and target everytime. can you suggest something for this.

Hi @Muhammad_Adnan

I suggest you try setCameraView from the CameraController extension by passing it a PolarView where you can directly use your pitch and yaw values. Do note that both azimuth and polar are expected to be deltas and not absolute values.

Using fromPositionAndTarget should also work, but in your particular case position stays the same, and only the direction changes, as you are rotating in place. I could help you more if you made a live example where the problem can be observed. You can use stackblitz like I did with the previous live examples I shared with you

Cheers

Hey Alex, spent some time on making an example.
i’ve tried using polar coordinates. its kinda working but it always pans to the right even if i pan left

Example

updateCameraPosition function is where i use setCameraView.
view has the current position(yaw,pitch) from SingleViewer.

Hi @Muhammad_Adnan

I’ve made a few small changes to your live example:

  • First one, like I previously mentioned, when passing a PolarView, it is treated as a delta, not absolute values. I changed this and now deltas are computed for pitch and yaw
  • PolarView expects it’s azimuth and polar values in radians, that’;s why I’m multiplying the values with 1/Math.PI
  • Finally, you are using wrapped values for pitch and yaw : [-180, 180] and [-90,90] which is fine, however this trips us the delta computations. What’s left for you to do, is to provide uniform delta values

Cheers

1 Like