Possible bug with camera inputs?

The following code works fine in my project:

scene.activeCamera.inputs.attached.pointers.buttons = [0];
// 0 for left mouse button - 1 for scroll wheel press - 2 for right click

However setting the button ID to 2, which should let it be controlled by right-clicking - Does nothing, 0 and 1 work as intended.

I’m unfortunately unable to create a playground on this particular problem as it doesn’t work at all there:

I think this is a misunderstanding as to what the buttons array does.

The button array define which buttons are read and used as input, but not their action. It is an arry of accepted buttons. So if you want the left click to stop working and doing what it is intended to do, you remove 0 from the array. if you don’t want tight click to ever work, remove the 2 from the array. but it does not mean that when removing 0, 2 will take its place.

would be wonderful to have a playground. the reason the playground complains in the generic way the inputs were implemented. try either casting to the right class (the PointerInput class of the camer you are using) or cast to any, just for the sake of making it work. This will be easier for us :slight_smile:

1 Like

Ahh, I had figured I was using it correctly as passing in [1] made it so that the camera only reacted to click the scroll wheel. I’ll try to get a PG working.

@RaananW

https://www.babylonjs-playground.com/#HDQ3H4#2

if you comment/uncomment the different lines you’ll see what I mean.
I’m unsure if I’m doing this wrong :frowning:

Either way, my main goal here is to rotate the camera when I right click & drag rather than the left click default :stuck_out_tongue: Any help towards that goal would be greatly appreciated <3

Thanks :slight_smile:

How is that - https://www.babylonjs-playground.com/#HDQ3H4#3

What actually being done here is moving the panning functionality to the left click, keeping the right click free to just run regular pointer events. See the attach function

1 Like

PERFECT. I hate how simple the solution usually is. lol. Thanks a ton!

1 Like

@RaananW just out of curiosity, how does this work?
attachControl() seems to only take:

camera.attachControl(canvas, true);

According to the docs Here

I guess my question here is what do the second true, and 0 do in
camera.attachControl(canvas, true, true, 0)
In regards to switching the mouse functions

That’s because I checked the specific camera’s API (in your case the arc rotate). some cameras have extra variables. This trick will not work on a different camera, but other things will :blush:

1 Like

Found it thank you! I appreciate your help here :sparkling_heart::sparkling_heart:

2 Likes