How to get mouse wheel value

Hey I am new to BABYLON. I am trying to get the mouse wheel input value but i can’t find the correct observer for that. I searched onPointerObserver but its not in there. i want to use the mouse wheel input to scale my mesh.

Thank you

Hi and welcome to BJS!
It could be depending on the type of camera you are using. Actually, there are different methods, but I guess the easier is to capture the value from the camera. i.e. Say you would be using an arcRotateCamera, you can capture the value of ‘radius’. What type of camera are you using?

hey, i am using universal camera. but how can i capture value from camera

Well, that’s precisely depending on the type of camera. Look at this PG of a universal camera, click on ‘the inspector’ (3rd icon in the top menu) and in the inspector ‘nodes’ click on the camera.

Notice how your camera changes ‘positions’, ‘rotations’ AND 'target. It is changing target precisely because it’s ‘a universal camera’. So you can retrieve any of the values from camera.position, camera.rotation and, however in your case you said

By saying this, ‘my mesh’ needs to be recognized (as a target/targeted mesh), which is not the case by default using a universal camera. May be you should consider using another type of camera or may be this is what you want, however in this case, we would need to determine how the mesh is defined as ‘targeted’ (and will make things a bit more complex :wink:

hey thank you for your response, but can’t i just get the mouse wheel value, like how mush my wheel has been rotated.

Well, I’m afraid that will not help you. A mouse wheel can have different sensitivity inputs. Already by default, it can scale 1, 3, 5, 10 rows. In the end, speaking about a 3d env, it’s your camera that will determine how close you are looking at a mesh (not the rotation on your mouse wheel). So, to get accurate result, you need to determine the position of your camera looking at your mesh/target.

hey how can i stop mouse rotation and only keep the mouse wheel scroll

line 39: You can lock the camera on a target. Only the mousewheel zoom input will remain.

Edit: using a free or universal camera, the KB input for ‘camera move’ will still be active. They can be disabled as well.

and how can i limit the mouse wheel input

Again, I believe you are just not using the right camera for this behavior. Note that you can still switch camera depending on context. But for this context/behavior you seem to ask for, best would be to use an arcRotateCamera, such as this:

Hope this helps,

Yeah this could work, Thank you! :blush: