yomotsu / camera-controls

A camera control for three.js, similar to THREE.OrbitControls yet supports smooth transitions and more features.
https://yomotsu.github.io/camera-controls/
MIT License
1.99k stars 253 forks source link

Dolly to cursor reaches limit #497

Open sguimmara opened 5 months ago

sguimmara commented 5 months ago

Describe the bug

Hi, not sure if a bug, or I am missing something in the configuration.

Even when infinityDolly = true, I cannot dolly past a certain point without updating the orbit point.

Is there something in the configuration to allow that ?

To Reproduce

In the video below:

dolly_to_cursor.webm

Code

this._orbitControls.dollyToCursor = true;
this._orbitControls.verticalDragToForward = true;
this._orbitControls.minDistance = 2;
this._orbitControls.maxDistance = Infinity;
this._orbitControls.dollySpeed = 1;

Live example

No response

Expected behavior

I would like to be able to dolly to cursor without being limited by the distance.

Screenshots or Video

No response

Device

No response

OS

No response

Browser

No response

yomotsu commented 5 months ago

Would you mind providing a simplified working example on CodeSandbox or a similar platform to reproduce the problem?

FYI: you must set minDistance to not a small value if you wish to enable infinityDolly

tmuguet commented 5 months ago

Hi @yomotsu ,

I'm working with @sguimmara. I reproduced this issue with an example derived from the infinity-dolly example: https://codepen.io/tmuguet/pen/poBXyyd . In this example, if you try to dolly-in in the top-left or top-right corner, you end up getting stuck, whether infinite dolly is enabled or not actually.

yomotsu commented 5 months ago

Thank you for providing the demo.

I believe the minDistance value is too small relative to the scene's scale. For instance, a value of 100 is nearly insignificant when considering camera positions such as camera.position.set(59861, -543453, 600000) and other similar settings.

Could you try using a larger number for the minDistance value?

tmuguet commented 4 months ago

Thanks for your prompt answer!

Setting a larger number (like 10000) fixes this issue, but it comes with some side-effects:

We've tried using setBoundary to bound the target, but it also introduces some other side-effects.

I believe there's no "one value fits all uses-cases". I'll try to have an adaptative minDistance then.