Good day everyone, I have a question, is there a ready-made solution for tracking the collision of the camera with the objects used by orbitcontrol. I have an urgent need to prevent the camera from moving outside the wall area inside the room, I tried this option
https://threejs.org/examples/?q=controls#misc_controls_pointerlock
but with orbitcontrol it does not work, in principle I can create a small transparent cube and use it to determine the collision of the camera, but I would like to hear the opinion of experts on how to do it better.
Iām not aware of a ready-to-use solution.
Here is an example,
See lines 26-35
I create a ray from the controls target, to the camera position and if any object is intersected between, then I update the camera to the intersects point.
Thanks a lot tomorrow I will try.
This solution does not always work correctly, probably as I thought it would be better to create a virtual cube and use it as an obstacle by moving it.
Damn, this is a very difficult moment in debugging, here problems begin when the camera is boiled, if you rotate the camera quickly through an obstacle, then it may not catch the moment.
Thank you very much, I understood the meaning of how to do it better and why you wrote it this way, everything works fine after some minor changes.