Simplified Flight Model

Here are a couple of programs that demonstrate a simplified vector-based flight model that takes into account the basic forces affecting flight - lift, drag, thrust and gravity.
Basic Demo
Flight Demo with Sopwith Pup
This is a work-in-process, so feedback is appreciated.


Looking really good! The controls felt a bit sensitive at first, but once you get used to things the planes fly great (I only used my laptop touch pad though)

I’d highly recommend creating a demo with terrain or floating objects so we can get a better sense of speed and how the plane handles :slight_smile:

1 Like

Yes, I definitely plan to create a little “sandbox” for the aircraft - someplace where you can land, take off, chase enemies, etc.
I’m glad the touchpad works. That is a control I hadn’t tried

Check out the new and improved version of the Sopwith Pup demo
Sopwith Pup
I modified the AC.rote.js library to include taildragger take-off routines and to better incorporate the effects of gravity while turning (previously, the aircraft was “floating up” in turns). I modified the demo program to include more landscape features.

What I’m missing is some kind of control state representation. I move the mouse, press buttons, but I have no idea how the aircraft is interpreting it. Because there is a delay between input and aircraft behavior - it’s hard to control.

I’m a complete 0 when it comes to flight-based simulations/games, so this comes from a noob in the field. Maybe for more experienced people there is no such issue.

For most of the game-related usecases, i think that “realistic” flight is not necessary, so a stable control state being the default would be an advantage.

Basiclly, if I let go of the controls - I would like for the aircraft to just fly in the straight line towards the center of the screen. Just my point of view

1 Like

What frame rate are you getting? I tried it on my ancient MS Surface yesterday and was getting only 20 fps, which made it almost unflyable - certainly not fun. If frame rate is a problem I can change the program to take differing frame rates into account. The simulation is currently set up for 60 fps, which is what I get on my PC.

But if you are getting a decent frame rate, your primary flight control is the mouse.

  • To take off - move the mouse wheel until the power setting is “1”. When the aircraft reaches flying speed (around 60 mph), move the mouse back gently. This will cause the aircraft to pitch up and leave the ground.
  • Move the mouse gently from side to side to make the aircraft bank (and turn) left or right.
  • Move the mouse forward to pitch down and backwards to pitch up.
    Once you get used to it, the mouse control works surprisingly well. But the required mouse movements are generally fairly small. Sometimes when you try and do a roll, you will accidentally push forward or back which will cause a weird maneuver.

There are keyboard alternatives:

  • The -/= keys control the throttle.
  • The up/down arrow keys control pitch.
  • The left/right arrow keys control bank.

Once you have gotten into pretty much straight and level flight, you can try a few things to show how the control system works.

  • Bank slightly to the left or right. You will notice that the plane starts turning. This is because some of the lift that you are using to stay in the air is being deflected to the side. If you pull back on the mouse by the right amount, you will stay level for the entire turn.
  • Pull back on the mouse. This will put you into a vertical loop. You can keep doing this for several repetitions if you like.
  • Try to fly through the hangars. I would suggest starting a long way back so you can line up. Make gentle banks to turn left or right. As you are diving down, you will have to push forward more because the increased airspeed creates more lift. (You can also reduce the thrust a bit, should cause the aircraft to pitch forward without increasing airspeed.)

Finally, if you hold down the left mouse button, you can move the mouse to pan around the aircraft.

I hope this helps. Let me know if it does not.

As you suggest, one of my primary goals is to make it “user friendly”.


1 Like

Hey Phil, thanks for the explanation.

I have a fairly good desktop PC, so framerate is not a problem. My mouse sensitivity is very high, so small movements of the mouse cover large distance of the cursor. That would explain the control feeling really bizarre.

From perspective of user-friendliness, i think having some kind of control target display would help. Like displaying a target cross in the middle of the screen, and change its rotation based on the target bank (roll), but do that immediately, and have some other indicator for pitch.

Perhaps have a model in place that translates roll to yaw, so that the aircraft would always stabilize the roll to 0 over-time. That way if you let go of the controls the aircraft would always right itself with respect to roll (bank). Flying upside down is a really weird experience unless you’re already used to it, it is quite disorienting.

1 Like

Yes, it turns out that the mouse sensitivity is really high. I doubt I move my mouse more than an inch in any direction during flight. I guess I have flown it so many times trying to work out the kinks that I have gotten used to it. (From what I have heard, the sidestick on the F-16 is equally sensitive - so it not totally unrealistic.)

Nevertheless, I will see if I can loosen the controls a bit - or at least add a slider so you can adjust to suit.

I had previously posted a mouse-targeting demo where you use the mouse to move a target to the place in the sky where you want to go and the plane tries to go there. It sounds like that is similar to what you are suggesting. It used a combination of pitch, roll and yaw (for small changes). However, I was not able to make it work perfectly, so I did not use it here.

Flying upside down is weird in real life too. It is best done where there is some positive g-force, as in a loop or barrel roll. (I have done both.) But simply flying upside down means that you are hanging upside down in your straps. Pilots generally don’t like that sensation.

That’s quite interesting. As I said, I have very little experience with flight, none in real life and very little in games and simulators. I have read a bit on the subject thought, and I’ve seen similar statements from other people on the subject of flight controls beyond that in a horizontal plane feel quite unnatural.

I think that given time, your neuroplasticity can kick in and let you adapt to flying upside down etc. But for a newbie “flying” a plane would feel nice only if it’s basically like driving a car.

I guess limiting roll might help, like having it on a “rubber band”, so you can only bank your craft so much and it would always right itself.

About the “target”, I think the key here is mental model, allowing the user to predict the result of their inputs. Maybe a ghost model of the craft being rendered on screen, but projected 1-2 seconds ahead in time. You could adjust inputs and see what would happen, basically.

It’s a fascinating duality, on one hand it’s awesome to see realistic flight controls, on the other hand - it feels like riding a unicycle while rubbing your belling and being slapped with a tuna, for an uninitiated that is.

1 Like

Here are some things I have learned over the years, from flying both real aircraft and simulations:

  • If you want to turn, bank first then pitch up (or down) to maintain the desired altitude. If you try both at the same time, you risk over-controlling. (I can see if there is some way to reduce “cross-feeding” - e.g. by increasing the movement required for pitch so that you can more easily bank without changing pitch.)
  • If you want to make a small lateral adjustment, bank slightly.
  • If you are trying to arrive at a point in space (like a gate), bank first, so that you will intercept the point when you pitch up.
  • Pitch down is rarely used. It is very uncomfortable since all the blood rushes to your head and you can’t pitch down as fast as you can pitch up. So rather than pitch down, pilots would prefer to make a 180 degrees bank and then pitch up.
  • Similarly, flying upside down is not something that pilots do for an extended period. It is generally something you do only when you are transitioning to something else: e.g., lining up your bank or getting ready to pitch up.

You are correct in wanting the aircraft to stabilize. Most aircraft are designed to be inherently stable in flight.

With regard to banking, most general aviation and commercial aircraft have some dihedral in their wings so that the bank will tend to return to vertical. Aerobatic and combat aircraft have little or no dihedral because they want to bank quickly. The Sopwith Pup appears to have had dihedral, so I can add that option.

Obtaining pitch stability is more difficult since there is no natural tendency for an aircraft to fly level. Here the trim control is the pilot’s friend (which the Sopwith Pup didn’t have). But the mouse control actually does a good job of acting as a trim control because you can set it to a position and leave it.


I never thought that pilots would prefer to bank in order to reduce altitude instead of pitching down due to comfort. Quite interesting. I think that in a simulation without this kind of physical feedback it will be the other way around, since your orientation will be more “natural” when pitching.

If you can have a model that levels the aircraft’s bank/roll to 0 over time, it would make the model easier to control for the inexperienced and still allow various maneuvers that an experienced user may wish to perform, with some resistance from the model.

You could make the model’s automatic bank adjustment relate to current state bank-altering inputs, so if the user is trying to bank - let them, if they are not - level out at some rate.

It could be a parameter, like “strength of roll-leveling assistance”. You could set that to some reasonable value for a newbie and let the user change it later on if they desire. Same can be done to pitch.

For the sake of lateral controls, it would result in user just banking, and the model leveling them out automatically, no need to really understand what just happened, it just feels like driving from perspective of controls when making small adjustments. You could even pitch up slightly when recovering from a bank to regain altitude, it would probably feel very “gamy” to a real pilot, but would feel quite nice to a newbie.

Depending on your goals, having some kind of control assistance like this could be optional, to accommodate both users experienced with “real” flight controls, and those who are not.

1 Like

I must have misspoke. You don’t bank to reduce altitude, although that will happen it you don’t increase lift enough to make up for the downward lift you are losing. Actually, on a precision approach, you use power to control altitude and pitch to control airspeed. But on a flight simulator, most people (including myself) don’t have patience for a 10 minute approach. Instead, we will wait until the last possible moment and then aim for the runway, cut power, drop flaps and gear and hope that everything works out.

Yes, I can easily model dihedral, which will tend to return the back to zero. In my demo, I tried to assist by making the horizon line clearly visible, so that you know what is level. Also, because of limitations in the program, your external view always has a level horizon.

1 Like

Here is an updated version of the Flight Demo with Sopwith Pup

This version includes:

  • Moving control surfaces (thanks to wassfila for showing me how to do this).
  • Enemy aircraft with Positional Audio.
  • Firing guns with (nonlethal) tracer bullets.

Changes to controls:

  • Mouse buttons now control yaw.
  • Hold shift key and move mouse to pan around aircraft

Future modifications:

  • Different input schemes
  • Dihedral to re-center bank

This demonstration program now includes just about “one of everything” to show what can be done while still keeping frame rate at 60fps.

Future versions could include:

  • A variable frame rate version.
  • A “no texture” version (for better frame rate)

I could improve the demo create by adding features like rolling hills and more gaming elements (which I may eventually do just for fun). But the purpose of this demo is mostly just to show what can you can do with the AC.rote.js program.

As always, feedback is appreciated.


A couple of small fixes:

  • The sun was too high.
  • The axle on my aircraft too high.

Hit reload on your browser to see changes.

great work… :grinning:

1 Like

Here is the latest version of the Flight Demo with Sopwith Pup

This includes several enhancements. The most interesting change is that we have added a “pitch” animation to the model so that you can change aircraft pitch independent of the flight path. This allows you to do things like “flare” to a landing.

This Flight Demo is intended to show how you can use our helper program ACflyt.js to create your own flight simulation.

We have now created a separate webpage which discusses ACflyt and the Demo programs. You can also download a zip file that includes that latest version of ACflyt.js and the Demo that you can try using it in your own project.

Land on a Carrier!

The experimental version of the demo has now evolved into a naval version in which you can land on a carrier.

The flight demo is ACflytModelDemoXP.

Instructions for landing on the carrier are on the ACflyt webpage.

I added a pseudo shadow so you can better gauge your height in the last few feet.

The next step will be to get the carrier moving and to “lock” the landed plane to the carrier deck so that the carrier does not sail away without taking the plane.

The original “land” version of the demo has also been upgraded to include these features.

1 Like

The carrier is now moving! Also the aircraft has been upgraded to a WWII FM2 Wildcat with retractable landing gear and extendable flaps - both of which work. As you will see, there is a great deal of difference between landing a slow biplane and a WWII fighter. In fact, it was impossible to land the FM2 on the carrier until I got it moving.

After much trial and effort, I have created a version of one of my aircraft demos where you can bank along with the aircraft:

Sopwith Pup Over the Ocean

I had to replace the default SkyBox with a cube that I could rotate. Essentially, I stopped the aircraft from rotating and plugged the aircraft xyz rotation values into the cube.

Repositioning the sun was more complex. I ended up having to use the following equations to position it properly:

// Heading (Longitude)
var Yrad = ACHead * DegRad;
var X1 = LightX * Math.cos(-Yrad) - LightZ * Math.sin(-Yrad);
var Z1 = LightX * Math.sin(-Yrad) + LightZ * Math.cos(-Yrad);
// Pitch (Latitude)
var Xrad = Mod360(-ACPtch) * DegRad;
var Y1 = LightY * Math.cos(Xrad) - Z1 * Math.sin(Xrad);
var ZF = LightY * Math.sin(Xrad) + Z1 * Math.cos(Xrad);
// Bank
var Zrad = ACBank * DegRad;
var XF = X1 * Math.cos(Zrad) - Y1 * Math.sin(Zrad);
var YF = X1 * Math.sin(Zrad) + Y1 * Math.cos(Zrad);
// Set

Unfortunately, this is a complication that will prevent the use of this method in an open world flight simulation since you would have to use the same equations to reposition every object, in addition to rotating the object. (The light did not have to be rotated.)

A few questions:

  1. Can I replace the above equations with a single quaternion calculation? I know nothing about quaternions, but am willing to learn.

  2. Is there a way to brighten the aircraft? I had to use a brightly-colored Skybox to increase visibility - which is why the poor pilot is in the middle of the ocean. Since this is a glb model, I included the following in my program:
    renderer.gammaFactor = 2.2;
    renderer.outputEncoding = THREE.sRGBEncoding;

EDIT: I brightened the aircraft by adding Ambient lighting with an intensity of 0.25.

With the default SkyBox, I could use reflection to brighten the aircraft. However, if my understanding is correct, implementing reflection with a custom Cube will require some special programming - a four camera setup?

  1. I assume that the default three.js camera calculates positions of all objects and rotates them. So what I am doing is probably a partial duplication of what the camera is doing. Is there any way to have the camera make these kinds of calculations? Or is that simply impractical?


Here is the FM2 which has more animated parts:
FM2 over Ocean

I forgot to add that this modification will allow me to create “in-cockpit” views of aircraft, such as the FM2.

You should also be able to create a simple “in cockpit” space combat simulation since there would not be a lot of external objects for which calculations are required. But I would need to figure out how to rotate the objects - which I haven’t done yet.

For reference, the webpage with links to all my demos is at:
Phil Crowther’s Aviation Webpage

Here are a couple of versions of the flight simulation where the camera banks with the plane. I replaced the standard SkyBox with a SkyCube that pitches and banks. I had to reposition all the objects. But it still runs at 60fps. Perhaps that is because I am giving up some of the benefits of the standard Skybox, such as reflective mapping. The advantage of using this method is that I can finally switch to a cockpit view.

Here is the external view:
FM2 - external view
Here is the cockpit view:
FM2 - cockpit view

I still have several fixes and improvements to make, including adding some lag to the controls and camera… Eventually, I will combine the two so that you can switch from cockpit view to external view and back.

1 Like

Since this last post, I have updated the FM2 Demo with a version that allows you to switch between internal and external views “on the fly”. I discovered that I could rotate the horizon using the default setup, as long as I did not use the “LookAt” command. So this version uses the default skybox.
FM2 Demo

Also, just for fun, I have added a simplified helicopter simulation to my collection of programs.
Helicopter Demo

Use the mouse wheel (or Q/W keys) to take off or descend.
Use the mouse (or Arrow keys) to fly forward, back or sideways.
Use the mouse buttons (or Z/X keys) to rotate laterally.
(Don’t forget to press the “S” key to hear the helicopter sound.)

Because helicopters are supposed to fly mostly “flat”, this uses an environment where the horizon stays flat.

To simplify operations, your altitude will not change as result of your pitching or banking. Essentially, the mouse wheel controls your altitude and mouse movement (pitch and bank) controls your direction and speed.

As always, feel free to appropriate my programs for your own nefarious purposes.


1 Like