I copied a 3d model of cartoon girl capsulated in a glb file from github. It had a facemesh, in which many shape keys had been defined, such as Face.M_F00_000_00_Fcl_EYE_Close_R.
My purpose was to play an animation that blinks right eye. So I set three key frames:
- initial status, time:0, frame:0, value=0 (value 0/1 represents eye opening/closing)
- eye closed, time: 0.2s, frame: 0.2 * 60=12, value=1 (60 is the framerate)
- eye opened, time: 0.2s, frame: 0.4 * 60 = 24, value=0
Then I tried to play the anim, the codes were below:
var anim = new BABYLON.Animation(
name,
"influence",
framesPerSecond,
Animation.ANIMATIONTYPE_FLOAT
);
anim.setKeys(keyFrames);
rightEye.animations = [anim];
scene.beginAnimation(rightEye, 0, 24, false, 1, endCallback);
But the right eye didn’t blink at all. What could be the reasons?
I use javascript, not typescript. Here is the loading sequence of script files, in which anim.js contains the above codes.
<script src="https://cdn.babylonjs.com/babylon.js"></script>
<script src="https://cdn.babylonjs.com/loaders/babylonjs.loaders.min.js"></script>
<script src="js/anim.js"></script>
And I have debugged many times. All the parameters during the running time seemed to be normal, at least they were all not undefined