Coder Social home page Coder Social logo

Comments (8)

yomotsu avatar yomotsu commented on May 20, 2024 1

@looeee Oh yeah! That's right!
Thanks for providing the great update and it saves other situations like this.

Let me close this issue.
Although, this is still kind of workaround but could solve

from camera-controls.

yomotsu avatar yomotsu commented on May 20, 2024

Thanks for your report.

I couldn't reproduce the problem.
Do you mind attaching an animation Gif or video?

from camera-controls.

leoncvlt avatar leoncvlt commented on May 20, 2024

Interesting! I have uploaded a video of the issue on imgur: https://imgur.com/a/9yrUGqF

The first time I didn't click the mouse button during the animation and the camera tweens at the intended speed. Then I hold my mouse button during the transition to show the camera speeding up, the third time I click intermittently. You can see when I'm holding the mouse button down as a little icon appears above the cursor in the screen recording.

I'm seeing this issue on both latest chrome (79.0.3945.117) and firefox (72.0.1) on desktop, haven't tried on mobile. Thanks!

from camera-controls.

yomotsu avatar yomotsu commented on May 20, 2024

Ah, I see. here is the problem.

dampingFactor is changed by mouse dragging.
You can disable user input while zooming.

cameraControls.fitTo( object, true );
cameraControls.enabled = false;

However, there is no camera-move-end event to re-enable it for now.
(I should add the event)

Here is an workaround.

cameraControls.fitTo( object, true );
cameraControls.enabled = false;
setTimeout( () => {
  cameraControls.enabled = true;
}, 1000 );

from camera-controls.

yomotsu avatar yomotsu commented on May 20, 2024

5

from camera-controls.

leoncvlt avatar leoncvlt commented on May 20, 2024

Thanks! I had the feeling it was something going on on update. Weirdly enough, setting controls.enabled = false was one of the first thing I tried, but wasn't working as expected.

I looked into it a bit more, and found it that I am calling controls.fitTo (and also disabling the controls) in response to a click event on a raycasted 3D object - since the click event propagates (does not when clicking a html button), then endDragging events never fires and the controls are stuck in a "mouse is held down" state when being disabled.

This actually resulted in another bug I had where re-enabling the controls afterwards would cause the camera to rotate even without clicking the mouse button, because it was still in the "stuck" state.

I managed to fix this with a workaround, by calling controls._state = 0 when disabling the controls to force it back to an ACTION.NONE state. It works, not sure if you can think of a least hacky way to do this :)

from camera-controls.

looeee avatar looeee commented on May 20, 2024

@yomotsu I guess now you can use the rest event?

cameraControls.fitTo( object, true );
cameraControls.enabled = false;

setTimeout( () => {
  cameraControls.enabled = true;
}, 1000 );

Would become

cameraControls.fitTo( object, true );
cameraControls.enabled = false;

cameraControls.addEventListener('rest', () => {
    cameraControls.enabled = true;
});

Or even

cameraControls.enabled = false;
await cameraControls.fitTo( object, true );
cameraControls.enabled = true;

from camera-controls.

leoncvlt avatar leoncvlt commented on May 20, 2024

Another workaround in case you still want to rotate the camera around during the zoom:

    const _prevDraggingDampingFactor = cameraControls.draggingDampingFactor;
    cameraControls.draggingDampingFactor = cameraControls.dampingFactor;
    await cameraControls.fitTo( object, true );
    cameraControls.draggingDampingFactor = _prevDraggingDampingFactor;

from camera-controls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.