@vijay_krishna, here is the working version of your playground. There were a few differences between your asset and the one that was loaded in the previous example I shared, so let me go through the process you would need for a more complex model like this one.
Animation keys
The values in the keys you pass will be the exact animation curves you want to play, so you will need to modify the animation keys as you need for the animation you wish to play on your morphs.
Mesh array
In the original example, there were three meshes that all needed the same operations done to them so I created an array of the meshes to apply the same actions to each. In your case, unless you can group different meshes that have similar naming conventions, you likely won’t need an array to iterate through. It may be more readable to just hold each mesh that has morphs that need to be animated in a constant rather than needing to iterate an array.
Mesh Target
You will need to create an array to hold like targets, in this case the left and right eye blink. However, you will have to plan out how you are grouping your targets as there may be actions where you need to assign the same animation to several targets like blinking or raising eyebrows. There will be others like a wink where you will want to have isolated targets, so I would think carefully about what actions your character will go through to help organize your targets. In this example, since we were only making the character blink, I just used a quick array to hold them.
Animation Group
Whenever you need to be playing animations at the same time that need to sync, like blinking, you will want to put the animations into an animation group. Then you can call play, pause, stop, etc on the group and all morphs will be affected at once and always be in sync.
Getting the targets for the morphs
Here you will want to iterate through the mesh.morphTargetManager._targets
and look for the targets by name. In our case, the ones we wanted have “Blink” as a part of their name. But you may need to be more prescriptive in searching for the correct target. Once we find the targets that match the strings we are looking for, we use mesh.morphTargetManager.getTarget(index)
to assign the targets to our array.
Play Animation
We just need to create an animation per target at this point. We pass each target we found in the previous step to a new animation with the “influence” property as the animation target. We also pass the animation group that will hold both eye blink animations. Once we have all of the animations in the group, we call animationGroup.start()
on the group which will synchronize the animations for both eyes.
I commented heavily on the PG, so you should be able to follow what is going on. However, if you have more questions, please feel free to reach out.