Jump to content

how to zoom in/out on FreeCamera


gwmaze
 Share

Recommended Posts

Hey Babylon Community,

I'm quite new to Babylon. I worked with ThreeJS and Unity so I'm not an absolute beginner when it comes to 3D programming ...
I have searched the web like crazy but did not find something that helped me out.

I simply want to zoom in and out with mouse wheel and pinch gesture like the ArcCamera does but on a normal FreeCamera or UniversalCamera.
I managed to get the wheel events and the mouse wheel delta but i can not find out which property i have to manipulate to zoom.

I tried camera.fov since in Unity camera.fieldOfView does exactly what i need - but in babylon the view gets extremely distorted.

Can please someone give me a hint about the specific properties i have to change?

Thanks and all the best

 

 

Link to comment
Share on other sites

Hi G, welcome to the forum. 

http://playground.babylonjs.com/#6FHKHC#12

That playround demo shows a freeCamera mouseWheeler... lines 18-37 do the work.

I think there is also a method... that uses a camera's .inputs... but I haven't researched that very much.

Also, I have no experience with touch gestures, except maybe the non-computer type (ahem) :D

https://github.com/BabylonJS/Babylon.js/tree/master/src/Cameras/Inputs

That is a list of currently-available camera.inputs.  babylon.freeCameraTouchInput.ts IS in the list, but an in-code search of all playgrounds... for 'freeCameraTouchInput' is returning no hits, unfortunately.  I think the freeCamera is already touchEnabled.

console.log(camera.inputs.attached.mouse);   // that says it is.

I hope I have been helpful.  Stay tuned for more comments/ideas.

Link to comment
Share on other sites

Hey Wingnut,

wow - that was quick ?


Thanks for your reply and yep - it was helpful because i now finally see how to use the BABYLON Framework to work with the mouse wheel!

But in my case repositioning the camera is not really what i want.
I have a first-person-like scene where the user can navigate via clicking waypoints on the floor.
The camera is always at the same hight (about a normal person eye hight) and can be turned in any direction.
The user should be able to zoom in and out to have a more detailed look at the Objects in the scene but the camera should always stay in place.
I built a prototype in Unity but unfortunately, Unity does not support mobile devices so I now try babylon.


In Unity camera.fieldOfView does exactly what i want - zooming without changing the camera position and without distortion.
There has to be an equivalent solution in babylon ... I hope ?

Here you can see the current demo state of my project.

http://projekte.gameworker.de/mytheresa/valentino3d/public/

- the gray boxes on the floor are prototypes of waypoints - you can click them
- the mouse control is inverted (because the customer wanted me to ? )

Thanks again and all the best

Link to comment
Share on other sites

Hi G.... interesting challenge, and a beautiful scene.

I decided to make a FOV mousewheeler, with standard camera.fovmode = BABYLON.Camera.fovmode_VERTICAL_FIXED;

http://playground.babylonjs.com/#6FHKHC#14

Just goofin' around.  I want to somehow "see" the fov-caused distortion you mentioned.

Would you know how to adjust this playground (and save another version) where we could more-easily see the distortion you speak-of?

I can't see it here, but I don't have the best eyes anymore... I'm an old geez.  (60)  :)

Link to comment
Share on other sites

Hey, Wingnut and all other readers,

actually camera.fov does the trick - i simply passed in way to extreme values.
If i treat fov gentle it works as expected - rooky mistake - sorry!

But as i said - your reply was helpfull anyway, so ...
Thanks again!

Now i'm working on pinch zoom - let's see how that turns out ? 

maze

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...