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.89k stars 241 forks source link

Invert Colliders #521

Open CosyStudios opened 2 weeks ago

CosyStudios commented 2 weeks ago

Is your feature request related to a problem? Please describe.

I'm trying to use the colliders array in a particular scenario where the camera is inside a collider. (Specifically a generative planet model that has its height map displaced inward) & I'm trying to avoid the camera going a)outside of the containing sphere as well as avoid the "mountains" etc that extrude inward.

For simplicity, I created a collider mesh with radius equal to the planet radius minus the tallest peak of the displacement with the view this would stop the camera going any closer to the interior surface than the heighest displaced point.

Evidently the colliders function with the camera assumed to be outside of the collider.. When the camera is moved outside / between the collider and the real mesh, I cant re-enter the collider so its obviously doing its job, but the wrong way round to what i desire.

Describe the solution you'd like

Is there any way the collider detection can be inverted so that it stays inside the collider mesh rather than avoids the outside?

Describe alternatives you've considered

No response

Additional context

No response

yomotsu commented 2 weeks ago

So, I think you can simply reverse the sphere face direction.

CosyStudios commented 2 weeks ago

Appreciate the speedy reply Yomotsu as in set side: BackSide on the material?

doesn't seem to affect the outcome...

CosyStudios commented 2 weeks ago

unless you mean id have to construct my own custom sphere buffergeometry and somehow do it in the constuction of that?

yomotsu commented 2 weeks ago

What about this? https://discourse.threejs.org/t/how-to-flip-normal-in-buffergeometry/35206

Also, to better understand your case, would you mind providing a simplified example in JSFiddle, CodeSandbox, or any other similar platform? This would greatly assist me.