Morph target object upload as an FBX won't morph

There’s morph target support now.
We have some issues with importing morph normals from fbx it seems … but positions work well.

aha, weird. we’re trying two paths here

  1. Import the asset as FBX. No animations ever came in. would you have an example file with an fbx with morph targets? Perhaps morph targets could still be there without any animation present?
  2. Second path would be to import a GLB file, and I tried the Loader code from this project: Loading glTF GLBs | Learn PlayCanvas

However I’m having some problems starting the animation. Not sure how to go about to do that from there. File loads fine though.

One more strange thing: The GLB we exported loads fine and plays with morph target in this viever: https://playcanvas.github.io/playcanvas-gltf/viewer/ But not in this one: PlayCanvas glTF Viewer where it gives an error:

image

What’s the difference?

MorphTwist.zip (116.4 KB)
I believe this fbx when imported imports morph targets. I think I then downloaded the converted glb into PlayCanvas glTF Viewer and that worked - the fbx does not have animation, but you get a slider for morph target and it works.

This viewer is old one based on older tech and not being up to date with the current engine: PlayCanvas glTF Viewer

This is the new one. PlayCanvas glTF Viewer
Are you able to shader the glb file that gives you the error in the new viewer?

1 Like

Hi, thanks for looking into this.

I added the fbx in your zip to playcanvas, and the following assets are generated:

Where is this morph target slider you’re mentioning? component on the entity when added to hiearky? On the asset inspector? I can’t see it anywhere.

The slider was mentioned in the viewer section … that’s where you find it. You can either download the glb file (model, not animation). Or you can click on Open in Viewer in the inspector of test.glb. Slider is in the viewer on the left bottom.

maybe also look here [SOLVED] Morph / shape blend animation not playing - #5 by mvaligursky

Great, seems both the Cube twist and my model does show morph target slider when I click “open in viever”.

Now to the final question then, How do I start this “animation”?

With your model FBX, does it have an animation? If so, it should be a case of adding an anim component and playing the animation.

If you don’t want to add the complexity of a state graph, you can use this script in the project to make it a bit easier: Animation without State Graph | Learn PlayCanvas

That’s what I was hoping for too. But it seems there is no animation. However, there is morph target. The target should be animated in Blender according to the animator, but perhaps it’s not translating properly.

When I import the twist cube in the Editor, it generates one glb with the model, and one with the animation. But I’m not sure the animation effects the morph weight.
But I believe the fbx I linked from another thread animates both the meshes as well as morph.

The animation of the Twist is not connecting in the viewer at least. If I try to import the fbx you mention from the other thread (online_ex.fbx) it will give these assets:

However, if I choose the glb and press open in viewer to have look I get this error:

Yep we’ve notice this issue as well … it used to work … we’ll investigate. It seems the generated glb in some cases is not valid. Perhaps try this to convert fbx->Glb, I had good susccess with this.

https://github.com/facebookincubator/FBX2glTF (manual: https://developers.facebook.com/docs/sharing/3d-posts/glb-tutorials/#convert-from-fbx)

@slimbuck seems to suggest the generated glb is only invalid if hierarchy import is enabled … try to disable it and test the glb that generates. We’ll investigate the problem.

I created an issue to track this https://github.com/playcanvas/editor/issues/596

ok. Perhaps separate bug then but this is where we are now:

  1. Morph targets are animated in blender (4 of them) . The values are keyframed.
  2. We have the option to export as GLB or FBX. The glb option does not work because of the bug above? So we choose FBX.
  3. We import the FBX and it get’s converted to GLB. That glb has indeed 4 morph targets, which I can confirm by using the GLTF viewever in playcanvas.
  4. However, there is no animation imported and thus we can’t utilize the file as intended.

Is this another bug?

I can import the same FBX in Cinema4D for example and confirm the animation has indeed been exported from Blender, but Playcanvas does not seem to pick it up.

These are the files generated when importing the FBX, so no Animation component.

image

Am I missing something?

I have a fix for your glb loading issue: https://github.com/playcanvas/engine/pull/3677

The issue was that we didn’t handle a scene without a node in it.

As a workaround till we release the fix in the engine, you can either:

  • build local engine with my fix
  • remove the empty scene from the glb when you export it (called stinger)

Screenshot 2021-11-09 at 13.51.21

1 Like

Regarding the import of the morph animation from the fbx, perhaps @slimbuck knows if that should be supported?

Great find, thanks!

@slimbuck confirmed we don’t currently seem to support import of morph animations from fbx … we’ll try to add it in the not too distant future.

1 Like

So, finally now that we can load the GLB without errors. I settled for this script workaround to start the animation from there instead. Given the current lack of editor support for the GLB assets.

Entity in scene:

load-glb.js code to load the GLB and also play the animation within (first one)

var LoadGlb = pc.createScript('loadGlb');
LoadGlb.attributes.add('glbAsset', { type: 'asset', assetType: 'binary'});

// initialize code called once per entity
LoadGlb.prototype.initialize = function() {
    
    var self = this;
    
    utils.loadGlbContainerFromAsset(this.glbAsset, null, this.glbAsset.name, function (err, asset) {
        var renderRootEntity = asset.resource.instantiateRenderEntity();
        
        self.entity.addChild(renderRootEntity);
        
        var animationAsset = asset.resource.animations[0].resource;
    
        // Create state with animation asset from glb.
        self.entity.anim.assignAnimation('Run', animationAsset);
        
        //Transition to state in Stategraph
        self.entity.anim.baseLayer.transition('Run', 0.2);   

    });
    
   
};
1 Like