I am currently working on a project to develop a simple game that involves shooting projectiles out of a gun barrel. At the moment, I have a basic setup where a cube and a cylinder are combined as the barrel. When I rotate the group containing these elements, the barrel moves accordingly in different directions without any issues.
However, my main challenge lies in determining the exact direction in which the gun barrel is pointing. I need to accurately identify the face of the cube to which the barrel is attached, as well as its orientation in relation to the 3D space - whether it's facing X+, Y+, Z+, X-, Y-, or Z-. Apologies for any misuse of technical terms in my description. Unfortunately, none of my attempted solutions have been successful so far, hence why I haven't included them here.
If you'd like to see an example of what I'm trying to achieve, please visit this CodePen link.
Additionally, here is some code snippet related to my project just to provide more context:
var geometry = new THREE.BoxGeometry( 50, 50, 50 );
var material = new THREE.MeshNormalMaterial();
var cube = new THREE.Mesh( geometry, material );
var cylgeo = new THREE.CylinderGeometry( 10, 5, 100, 32 );
var cylmesh = new THREE.Mesh( cylgeo, material );
cylmesh.rotateZ(Math.PI/2);
cylmesh.translateY(35);
var group = new THREE.Group();
group.add( cube );
group.add( cylmesh );
scene.add(group);