Relative Content

Tag Archive for three.jsgltf

How to rotate make a rotate a group backed on camaras orientation?

I am making a game where you have a sword that you can swing, the sword is in a group with an offset so it is positioned right. I am trying to make it so that when I press Z the sword swings down and then back up via rotation. how do I get the sword to swing in the direction I face? Currently, I have if (keys.z) group.rotation.x -= Math.PI/100;, but that only works for the x-axis. The model copes the camera position with group.position.copy(camera.position);, and quaternion with if(!keys.z)group.quaternion.copy(camera.quaternion);.
One way I thought do do it was to change the sword’s rotation offset but I don’t know how to do that, would that even work? Anyways please help I love coding and want to make this game!