I'm working on developing a basic airplane flying game. The goal is to allow users to control the plane using arrow keys, rotating it within a 360-degree area. When using the up and down arrow keys, I want the plane to move along a Y-axis relative to its horizontal position. Meanwhile, the left and right arrow keys should only rotate the plane around its z-axis, adjusting its Y-axis position accordingly. My main question is how can I achieve this kind of rotation where the Y-axis remains relative to the current horizontal position?
So far, I've created a group named 'airplane' and have experimented with commands like airplane.rotation.z (for left and right movement) and airplane.rotation.x (for up and down movement). However, the x-axis doesn't align with the new horizontal plane as desired. Additionally, I tried accessing the model/mesh within the group using airplane.children[1].matrix.rotation.x in hopes of changing the relative Y-axis, but encountered the same issue. How can I determine the relative Y-axis based on the plane's current horizontal orientation?
If you'd like to see my code, you can view it on jsfiddle here
Any assistance or advice on this matter would be highly appreciated.