Jump to content

ArcRotateCamera attachControls() misbehaving


IIerpos
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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();
            });
        }

 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...