Panning is not happening for first time

Please do not forget to add a link to a Playground to get a faster answer:

Hi all,
I am new to this forum, I am trying out the 3D renderingof obj and flb files I am trying to pan using shift+left click instead of default panning.
I am using the below code but for the first time when click on shift +left the panning is not happening .
Anyone please help me out with this
Camera.attachcontrol(canvas,true,false,-1);
scene.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnKeyDownTrigger, function (evt) {
if(evt.sourceEvent.keyCode === 16) {
camera._panningMouseButton = 0;
}
}));
scene.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnKeyUpTrigger, function (evt) {
if(evt.sourceEvent.keyCode === 16) {
camera._panningMouseButton = -1;
}
}));

1 Like

Hey there, welcome to the forum. :slight_smile: So the the first click on the canvas gives the canvas the focus, which allows it to receive keyboard events. For example you could try calling canvas.focus(), then your shift-click behavior should work on the fist click like below. An alternative could be to add event listeners on the window to keep track of the shift key.

3 Likes