How to play blend shape animations or morph animations exported from blender in Vision Pro apps using Reality Kit

So I am exporting a .usdc file from blender that already has some morph animations. The animations play well in blender but when I export I cannot seem to play them in RealityKit or RCP.

Entity.availableAnimations is an empty array. Not of the child objects in the entity hierarchy has an animation library component with it.

Maybe I am exporting it wrong but I tried multiple combinations but doesn't seem to work.

Here are my export settings in blender

The original file I purchased is an FBX file that has the animation but when I try to directly get it in RealityConverter it doesn't seem to play animations.

Answered by Vision Pro Engineer in 845629022

Hi @doomdave

Have you tried adding a BlendShapeWeightsComponent to the entity you wish to animate with blend shapes?

You can create a BlendShapeWeightsComponent and add it to an entity with a model component as follows:

func addBlendShapeWeightsComponent(to entity: Entity) {
    guard let modelComponent = entity.modelComponent else {
        return
    }
    let meshResource = modelComponent.mesh
    let blendShapeWeightsMapping = BlendShapeWeightsMapping(meshResource: meshResource)
    var blendComponent = BlendShapeWeightsComponent(weightsMapping: blendShapeWeightsMapping)
    entity.components.set(blendComponent)
}

I'd also highly recommend checking out the BOT-anist sample code for a concrete example of how to animate a mesh with blend shapes.

Let me know if you have any further questions!

Accepted Answer

Hi @doomdave

Have you tried adding a BlendShapeWeightsComponent to the entity you wish to animate with blend shapes?

You can create a BlendShapeWeightsComponent and add it to an entity with a model component as follows:

func addBlendShapeWeightsComponent(to entity: Entity) {
    guard let modelComponent = entity.modelComponent else {
        return
    }
    let meshResource = modelComponent.mesh
    let blendShapeWeightsMapping = BlendShapeWeightsMapping(meshResource: meshResource)
    var blendComponent = BlendShapeWeightsComponent(weightsMapping: blendShapeWeightsMapping)
    entity.components.set(blendComponent)
}

I'd also highly recommend checking out the BOT-anist sample code for a concrete example of how to animate a mesh with blend shapes.

Let me know if you have any further questions!

Thanks a lot! this is very helpful!

How to play blend shape animations or morph animations exported from blender in Vision Pro apps using Reality Kit
 
 
Q