Morph target object upload as an FBX won't morph

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