In my latest project, I decided to create a "camera controller" that handles the movement and rotation of the camera by utilizing an Object3D as its parent. The Y-axis rotations are applied to the Object3D, while the X-axis rotation is directly applied to the camera itself. Here's a snippet of the code:
function cameraController(cam, scene){
// Implementation details here...
}
Despite successfully implementing the camera controller, I encountered an issue where raycasting fails to detect meshes when the camera and its parent object are being moved simultaneously.
Here's the relevant raycasting function:
document.addEventListener('click', function(event) {
// Raycasting logic here...
}, false);
I've attempted using methods like "cam.updateMatrix()" and "cam.updateProjectionMatrix", but unfortunately, they didn't resolve the issue. Even after making the camera a child of the Object3D, the initial positions remain unchanged (0, 10, -4). If anyone has insights on why raycasting isn't functioning properly when using this controller to move the camera, I'd greatly appreciate your input.