[Help] CameraController.options not working after toggleControls

Previously the team helped me around with the speckle waypoint navigation and also with the linear angle dampener…
Here’s a live example

I now wanted to enable zoom and set a min fov and max fov… I wasn’t able to set enable zoom mechanism despite setting it to true…

Hi @Ahmed_Jamil

Well, before any of that happens I say you need a way in which you can correlate “zooming” inside an image with “zooming” inside 3D space.

From what you are saying, by “zooming” you mean varying the camera’s fov. That’s currently not being handled by any of our camera controllers. So setting zoom: true will not give you access to varying the camera’s fov. That option is restricted to the orbit controls (which you are not using)

Cheers

1 Like

Got it, earlier we had the ability to use the enableZoom key and set minFov and maxFov that would restrict the zoom fov…

The orbit controls does allow for purely setting the fov and also clamping it between the given min and max. If that’s all you need this functionality can be easily translated to the fly controls.

I’ll show you a live example as soon as I get the chance to make it

1 Like

Thanks again @alex , that would be really helpful

So I had a look and setting the fov is controls independent. As in you use CameraController’s filedOfView property to set it directly.

Now if you want it clamped to a min/max you don’t necessarily need the viewer to do that for you since it’s trivial.

Given the above, I’m not sure how to further help

Got it, I was still unable to trigger the zoom in and zoom out ability in speckle viewer with waypoint navigation mode…
By zoom in and zoom out I meant, the ability to scroll and zoom to change the fov…

You are already doing it at line 52 in your example

cameraController.fieldOfView = 120;

1 Like

I commented out the line at 52, I was using it to set the default fov on initial load.

I’m not able to use the “pinch to zoom” or “scroll” to change my fov, that’s what I meant, I even have the enableZoom turned on so that the behaviour takes place..

There is a misconception here. enableZoom does not allow you to change the camera fov on mouse wheel or pinch zoom. It’s an option that targets the orbit controls and the “zoom” is the camera moving towards it’s target in 3d space, as you would naturally have it.

Like I said before, you already have the means to change the camera fov via the controller’s fieldOfView. This means that you can listen to input events in your application and act on the fov accordingly. Something along the lines of

viewer.getContainer().addEventListener('wheel', (event: WheelEvent) => {
  camerControls.fileOfView += event.deltaY // Or whatever step you define
})

The viewer-library is a library. The idea behind it, is not to cover all the possible use cases that can exist, but rather to give users the means to develop applications that can span across as many uses cases as possible.

Yours is a very cool use case with the 360 image in sync with a 3D view. The default camera functionality that the viewer-library ships with, was not originally intended to be used as such, however it can be more or less configured to behave the way you need it to. For basic navigation it may be enough, but if you want to further develop the idea with more complex features, you can also look into implementing your own WaypointControls which can extend the stock FlyControls. Approaching it this way, you’ll have a better, reusable and modular implementation

Cheers

1 Like

Thanks again for this @alex , the idea of zooming and fov is confusing.
Your explanation cleared out to me how it works…

:raising_hands:

1 Like

I tried to add a listener for onWheel, and here’s what I found. Changing the fov using cameraControls.fieldOfView was causing nothing, but if I did it while panning, it would show me the change.

Here’s an example

Here’s a video better explaining my case

In the video it didn’t show my console logs, but if you scroll using mousewheel, it shows that the field of view is changing, but on screen nothing happens.

If you tried to pan and use mouse acceleration ( smoothing out animation of the panning ) , and during that time if you scrolled, it would show on screen also that the fov is changing.

Here is an updated example that works as you expect it to.

You were not telling the viewer to re-render by calling requestRender.

For your “waypoint” controller nothing else was needed. However I’ve also added two extra lines for the orbit controller, which you don’t use nor need but I’ve added them nonetheless for consistency.

1 Like

I wanted to say thanks again for this @alex, I wasn’t even aware of the update flags. Amazing thing.

I wish I could add two solutions to this topic …

2 Likes