You can see the results at:
Press the arrow keys to see the elevator and rudder move.
For the record, here are the changes I made:
At the beginning of the program, I inserted the following global variables:
var mixer1 = 0;
var mixer2 = 0;
In the function(gltf) section of the file loader, I inserted the following lines:
// The elevator animation
var clip1 = gltf.animations;
mixer1 = new THREE.AnimationMixer(object);
var action1 = mixer1.clipAction(clip1);
// The rudder animation
var clip2 = gltf.animations;
mixer2 = new THREE.AnimationMixer(object);
var action2 = mixer2.clipAction(clip2);
In the main program, I inserted the following commands:
if (mixer1) mixer1.setTime(elvatr/anmfps);
if (mixer2) mixer2.setTime(rudder/anmfps);
where elvatr and rudder have values of between 1 and 59 (since the animation has 60 steps) and anmfps = 24 (which is the default fps for Blender animations).
You need a separate mixer for the animation associated with each part because you will be using the mixer.setTime(t) command to set the position for each part.
I just need to test this in my flight simulator demo to make sure that the parts do not “detach” (I don’t see why they would) and that there is no huge frame rate hit.
Thanks for all your help and encouragement!
EDIT: I tested it out on the program and it works great! I only changed the movement of the elevator because it is relatively straightforward. The rudder movement will be more complex. And I need to add animations for 2 to 4 ailerons. And now that I know how to add animations, I can add all sorts of eye candy to the simulation, such as waving flags and people.