We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Changing Camera Controls Corrupts Mouse Wheel

Home Forums Programming Changing Camera Controls Corrupts Mouse Wheel

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #52699
    wishful97
    Participant

    Hello all,

    Question in short:
    Why mouse wheel zooming gets corrupted after changing controls?

    Longer Description:
    I have a simple scene (which I attached to this post) with orbit controls at the beginning and mouse wheel scroll works fine for zooming.
    I also have a red button on top left that on click, toggles the camera controls between FirstPerson and Orbit. When I click it once and switch to FirstPerson, the mouse wheel does not zoom correctly (but the w button works fine for zooming) and it jitters and jumps as you can see in the attached video. After that even if I click on the red button to change the controls back to Orbit, mouse wheel does not work correctly.

    video

    #52740
    kdv
    Participant

    see below…

    Puzzles and JS. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of meaning at all.

    #52741
    kdv
    Participant
    function runCode(app) {
        // add your code here, e.g. console.log('Hello, World!');
    
        var isFP = false;
        var prevControls = app.controls; //save OrbitControls with all parameters
    
        $("#change_control").click( function() {
            console.log("controls changed");
    
            if (isFP) {
                app.controls = prevControls;
                app.controls.enabled = true; //enable OrbitControls
            }
            else {
                app.controls.enabled = false; //disable OrbitControls
                app.controls = new v3d.FirstPersonControls(app.camera, app.renderer.domElement);
                //app.controls.zoomSpeed = 0; //disable wheel zoom
            }
            isFP = !isFP;
        })
    }

    When I click it once and switch to FirstPerson, the mouse wheel does not zoom correctly

    that’s because Orbit and FirstPerson controls were both active )))

    Puzzles and JS. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of meaning at all.

    #52767
    wishful97
    Participant

    Thank you very much for your time and help!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.