I am using the raycaster to get the Object3D I am clicking on. The first object is the closest Object3D where I clicked. If I look in the intersection data, I see there is a “face” key and a “faceIndex” key. The question is, how would I be able to get the quaternion for the face I am clicking on? I can get the quaternion of the Box Object3D and I figure I could probably do some fancy Vector3 add/multiplication or something like that based on the faceIndex, but is there another way to quickly get the quaternion of the face I’m clicking on? The final goal is to basically orientate my camera in front and at the same angle as the face in question. If this can work for any kind of geometry (not just a Box), even better.
I got the answer earlier for the position of the point on the face being clicked by using the point and normal data. I’m just missing the face’s quaternion piece.
This is not an answer of the question, I’m just curious.
If
then why do you need the quaternion? Here is a demo of orienting the camera to face the clicked point. It uses only the position and the normal of the point of itersection.
hmmm…interesting. I will look at that example more in details. Regarding the quaternion, I use it in case the face in question has been rotated and my camera needs to follow that rotation. That means that the camera will not always be “horizontal” to the world space and will rotate along with the face, giving the illusion that the face in question is not moving, but from the outside, the camera and the face are rotating (x, y & z). As of right now, I was only able to place the camera in front of an Object3D and match the Object3D’s quaternion.
Here is a video of the current system that positions the camera in front of each Object3D (rounded plane).
It will detect if it should position the camera in front or at the back of each Object3D based on which is in view.
I would like to make this system be able to instead of looking at just the front or back, but all the faces an Object3D has and pick the one that is in view and also the closest. For now, getting the position and quaternion (ie: rotation) of the face that is intersecting (point) from the raycaster is the immediate goal.