IIerpos Posted August 8, 2017 Share Posted August 8, 2017 The arguments in the attachControl() method for ArcRotateCamera do not seem to behave as described in the documentation. I am unable to achieve what I could before 3.0. Prevent default seems to be affected by whether "useCtrlForPanning" is true. I can't get the RMB to pan at all, as I could the previous version. please toy with the booleans and see what I mean. http://www.babylonjs-playground.com/index.html#6QH6SN Ideally, I would have the RMB and ctrl+LMB both panning, with no menu showing up on RMB click. At the very least, I would like to be able to disable the right click menu while having panning enabled. Thanks! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 8, 2017 Share Posted August 8, 2017 Works as expected: https://www.babylonjs-playground.com/index.html#6QH6SN#1 Doc: http://doc.babylonjs.com/classes/3.0/arcrotatecamera#attachcontrol-element-nopreventdefault-usectrlforpanning-panningmousebutton-rarr-void Code which could be clearer: https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/babylon.arcRotateCamera.ts#L284 Quote Link to comment Share on other sites More sharing options...
IIerpos Posted August 9, 2017 Author Share Posted August 9, 2017 OK. Sorry about that. The looking at the code did clear that up, mostly. For readers: 1. The noPreventDefault option in ArcRotateCamera.attachControl() does not stop a right click menu if the ctrl-LMB panning is enabled. 2. (I should have seen this) The panningMouseButton option is a NUMBER - the number of the button that you want to pan with. 0 - LMB, 1 - MMB, 2 - RMB. That being said, I have a strange bug in my implementation of BABYLON where everything loads, unless I attach the camera controls. When I do, it throws an error: TypeError: element.addEventListener is not a function babylon.custom.js:33275:13 In another implementation of mine, the page loads, and the controls attach, but the panning will not work. In both cases the camera is an arcRotateCamera and line that causes or has issues is simply scene.activeCamera.attachControl(canvas, false, false); If you have any ideas, I'd be most grateful. Here is a file where, for me, the panning will not work. Drop the two files in a folder with a copy of babylon.custom.js and it should demonstrate the issue. tmmWeb3D.js.htm a.babylon Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 9, 2017 Share Posted August 9, 2017 Can you reproduce your issue in the Playground? Quote Link to comment Share on other sites More sharing options...
IIerpos Posted August 16, 2017 Author Share Posted August 16, 2017 It's taken me ages to really get back to this, but my problem has not gone away. Unfortunately, I can't reproduce this without loading a .babylon file exported from Blender. Please open the given test file. If I build the scene manually using a createScene(), the panning works just fine, whereas if I use loadFile(), it is broken. In both cases, the controls are attached by the same code, so I surmise that the problem is in the my loader or the .babylon file. panningProblemDemo.zip Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 16, 2017 Share Posted August 16, 2017 Ok I know where the issue is the initial camera is replaced by the one loaded in the .babylon file Just change your show function to this one: function show() { var camera = new BABYLON.ArcRotateCamera('camera1', 0, 0, 0, null, scene); camera.setPosition(new BABYLON.Vector3(0, 0, -10)); camera.setTarget(BABYLON.Vector3.Zero()); camera.panningSensibility = 300; scene.activeCamera = camera; scene.activeCamera.attachControl(canvas, false, true); engine.runRenderLoop(function() { scene.render(); }); } Quote Link to comment Share on other sites More sharing options...
IIerpos Posted August 16, 2017 Author Share Posted August 16, 2017 I am sorry - I was very unclear about the lines at the end of the script (86, 87). They were meant to be run one or the other as a comparison between createScene() vs. loadFile(). Both contain entire scenes which include cameras. When I load a .babylon scene file, can I not successfully attach the controls of the camera which is contained in the file to the canvas? In the setup as I intended it to run, there should not be a camera to replace. The one loaded in the .babylon file should be the only existing camera. So if I replace the camera which is in the scene already with a new BABYLON.ArcRotateCamera(...), I may get the results I want, but I still don't understand what is going wrong. Thank you, by the way! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 16, 2017 Share Posted August 16, 2017 Then you just have to setup your camera with the same panningSensibility (and make sure it is an ArcRotateCamera) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.