Comments (8)
@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.
Thanks for your report.
I couldn't reproduce the problem.
Do you mind attaching an animation Gif or video?
from camera-controls.
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.
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.
from camera-controls.
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.
@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.
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)
- How to set the mousewheel rotation direction? HOT 4
- How to update cameracontrols after the camera is manually changed? HOT 5
- Disable Pan/Truck on the right mouse HOT 5
- How to rotate azimuth to face an object? HOT 3
- How to continue camera-controls based on the current camera position and perspective when enabled is set to true again, instead of returning to the position when enabled is set to false HOT 1
- enablePan HOT 1
- How to control 'enablePan'、'enableZoom' like OrbitControls? HOT 1
- Add the ability to hold children HOT 4
- Give `setLookAt` a linear option HOT 2
- If pointer is held down without any movement "updated" keeps firing HOT 3
- Changing camera up vector significantly causes weird behavior HOT 4
- Camera Controls - Scrolling HOT 1
- Infinity Dolly not working HOT 5
- Add back modifier keys to pointer events HOT 1
- setLookAt doesn't trigger an update of the viewport attributes HOT 4
- Slow pinch-zoom when using orthographic camera HOT 7
- problem HOT 1
- Bug with setting interactiveArea top position. HOT 1
- Dolly behavior in first person mode is different when scrolling up and down HOT 1
- How to use CameraControls in react native HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from camera-controls.