Implementing Morph Target Based Facial Animations with GLB Models in SwiftUI: Insights from Babylon.js Experts?

,

Hey there!

I’m currently working on a SwiftUI project where I aim to integrate animated, talking head features similar to a project I discovered on GitHub, which uses readyplayer.me models in GLB format for creating talking heads by applying predefined sets of morph targets for facial expressions (e.g., for a smiling emoji). Here’s an example of the morph target application in the original JavaScript project:

code:

:grinning:’: { dt: [300,2000], vs: { browInnerUp: [0.6], jawOpen: [0.1], mouthDimpleLeft: [0.2], mouthDimpleRight: [0.2], mouthOpen: [0.3], mouthPressLeft: [0.3], mouthPressRight: [0.3], mouthRollLower: [0.4], mouthShrugUpper: [0.4], mouthSmile: [0.7], mouthUpperUpLeft: [0.3], mouthUpperUpRight: [0.3], noseSneerLeft: [0.4], noseSneerRight: [0.4] }}

While exploring the model (e.g., this model), I could not find explicit references to these morph targets within the model itself, particularly after converting the GLB model to USDZ for use in my project. This raised a couple of questions for me:

  1. Are these specific morph targets (e.g., browInnerUp, mouthShrugUpper) inherently available in the readyplayer.me GLB models, and if so, how can they be accessed and utilized?
  2. If these morph targets are not directly part of the GLB model, how are they applied in the JavaScript project to animate the models? I’m interested in understanding if there’s an approach to defining or applying these morph targets to create similar facial animations.

I realize this question might not directly pertain to Babylon.js, given its primary focus on SwiftUI and Three.js usage in the original project. However, after nearly reaching a dead end in my search for answers and understanding the overlap in knowledge within the JavaScript and 3D modeling communities, I believe the expertise here could shed light on my query. Your insights into Three.js, WebGL, and general 3D modeling principles could be incredibly valuable.

Thank you for your guidance and insights!

Drop your GLB into Sandbox, choose Wolf3D_Head mesh with Inspector and play with morph targets as you like.

It may depend on how you download them. ReadyPlayer API lets to choose morph targets to download. More info here - GET - 3D avatar - Ready Player Me

How to use - see docs: https://doc.babylonjs.com/features/featuresDeepDive/mesh/morphTargets

1 Like

Thank you so much for the guidance and for pointing me towards the Sandbox tool—it’s truly fantastic for visualizing the morph targets!

I’m currently facing a challenge specific to my SwiftUI project, where I cannot work directly with GLB files and need to convert them into USDZ format. Unfortunately, all my attempts to convert from GLB to USDZ, including using Blender, have resulted in the loss of the morph targets, which are crucial for the facial animations in my project.

Do you have any suggestions or know of any tools/methods that could help export GLB files to USDZ without losing the morph targets?

Any advice or directions on this would be immensely appreciated!

1 Like

cc @bghgary who might know a good converter ?

I don’t know much about this, but I did quick searches. If the intention is to use the USDZ on iOS, I’m not sure it will work. It seems like iOS doesn’t have support for blend shapes (i.e. morph targets). See RealityKit Blendshapes | Apple Developer Forums and usd_from_gltf/convert/converter.cc at 6d288cce8b68744494a226574ae1d7ba6a9c46eb · google/usd_from_gltf (github.com)

Hey @bghgary,

Thanks for jumping in and doing that quick search! Regarding the blend shapes support on iOS, it’s a bit nuanced. While you’re right about the USDZ and RealityKit limitations, it seems like SceneKit actually does support blend shapes (aka morph targets). Apple’s own documentation hints at this under the SceneKit section, not just ARKit. Here’s a bit more info on that: Validating feature support for USD files | Apple Developer Documentation.

On a related note, I managed to convert the GLB file into DAE, and Blender happily showed all the morph keys in this DAE file. However, when I pop it open in Xcode’s scene editor, it’s like a ghost town in the morph targets section – totally empty, even though there’s a designated space for them. This makes me think that there’s some level of support for morph targets in DAE files, at least. Here’s what it looks like in Xcode: https://i.stack.imgur.com/oti2f.jpg, and here’s the Blender view for comparison: https://i.stack.imgur.com/ndJrv.jpg.

Bit of a head-scratcher, right? I’m thinking it might be something specific about how these files are being interpreted or maybe something’s getting lost in translation from DAE to whatever Xcode expects.

Cheers!

DAE (i.e., COLLADA) support is almost always spotty because it’s a massive specification.

Hey @pilsen,

I am trying to do the exact same thing did you have any luck with this?