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

fitToBox on a plane: how to prevent plane to get perpendicular to view? #496

Open AmauryHamon opened 2 months ago

AmauryHamon commented 2 months ago

Describe the bug

Hi all, just discovering cameraControls. I made a scene with planes positioned and rotated randomly When clicking on a plane, I want to fit the plane intersected to fit only on its front or back side.

If the plane is rotated close to being perpendicular to the view, then it choose 'invisible sides'

Is there anything to prevent that?

To Reproduce

Steps to reproduce the behavior:

  1. Create a scene with a plane
  2. add mouse raycaster and click event to call the fitToBox on the intersected plane
  3. Move camera so plane is rotated close to being perpendicular to camera
  4. See error

Code

No response

Live example

Live example

Expected behavior

If mesh is a plane, only fit to front side (or back if double side is activated)

Screenshots or Video

No response

Device

Desktop

OS

MacOS

Browser

Chrome

yomotsu commented 2 months ago

Did you already check https://yomotsu.github.io/camera-controls/examples/fit-to-rect.html ?