Is there any observable for mouse wheel input?

Hi! So I want to make a functionality that involves resizing a mesh by scrolling the mouse wheel, I’ve been searching through and documentation about this but it seems that the mouse wheel is reserved for camera control on Babylon.

So is there any observable built in on Babylon that doesn’t involve the camera controls and that modifies something in the scene or should I try to do it with JavaScript events?

You have this as observable on the pointer

scene.onPointerObservable.add((kbInfo) => {
        if (kbInfo.type == 8) //scroll
        {
            
        }
    });
2 Likes

You may also remove (and add it later again) mouse wheel from camera controls.

camera.inputs.remove(camera.inputs.attached.mousewheel);
1 Like

Here is simple PG example - https://playground.babylonjs.com/#7ZAQD0#1

2 Likes

Thanks for the PG and the recommendations just one thing, is there a way to detect when is a scroll up or scroll down with this method? I’ll put the PG as answer because it was the thing I was looking for but I would be glad to get this answered to.

Look in the console.log for anything that might be useful to you.

For example, there is kbInfo.event.deltaY who could help you with this

scene.onPointerObservable.add((kbInfo) => {
        if (kbInfo.type == 8) //scroll
        {
            if (kbInfo.event.deltaY > 0)
            {

            }
            if (kbInfo.event.deltaY < 0) 
            {
                
            }
        }
    });
3 Likes