Hi, I’ve been looking through previous posts discussing this issue, and I was under the impression that keyed morph / blend shapes animations in imported FBXs are now supported.
I have a simple FBX with a blend shape animation, but I can’t get it to play. In the viewer I can see the morph targets and can manipulate them in scripts, but the animation settings are greyed out ( see grab attached ).
I’m probably doing something wrong, or misunderstood whether these baked animations are actually possible. Could anyone kindly give me a steer or confirm that it’s not supported at the moment?
Cheers!
I just imported this glb from here : Blendshapes / morph targets - #8 by will
It works in the PC model viewer ( I can see the square morphing ) but I’m not able to add this glb as a model to an entity in the scene. It’s marked up as a ‘binary’ rather than a model, like the other glbs in the scene. PlayCanvas glTF Viewer
Am I missing part of the puzzle - something do with gltf importing?!
OK I think I’m getting closer: Loading glTF GLBs | Learn PlayCanvas
Is this implementation the best option at this time?
If you are loading GLBs that have been exported outside of PlayCanvas then yes, currently that’s the way you have to go.
It’s certainly possibly to make a glb with animated morph targets. I have an example fbx which has bone animation as well as morphing, all playing well inside the viewer. I’m not sure how this was created, I’m not proficient with the modelling software to this degree, but perhaps you can inspect the fbx file to see how this can be set up?
BlendShapeTest.zip (24.7 KB)
Thanks for your help guys.
@yaustar I can now load the glb using the loadGlbContainerFromAsset method from the example project. This returns an asset object, which I listen for the ready event when loaded. The glb is displayed in the scene, but does not play its animation.
Do I need to somehow get a reference to the animation and start it? The resource property of the loaded asset is an ArrayBuffer object ( see grab ) and I’m unsure how to access the model or animation. Do I need to tweak the asset import settings?
@mvaligursky I can load the fbx you sent in the model viewer, but it does not animate, the glb does though. Do you have a sample project where the glb is loaded into a scene and is animating?
Thanks again!
You will need to add the animation component to the entity and add the animation asset from the GLB container asset to the component
Example: Merging animation glb to its source glb - #14 by yaustar
The viewer which plays the glb is here:
And here’s its source code, so you can see how the animation is set up to play: playcanvas-viewer/viewer.ts at master · playcanvas/playcanvas-viewer · GitHub
Thanks guys, finally got it working! Really appreciate your help.
For anyone interested, here’s the code I added to the load callback to init the animations ( from this project Loading glTF GLBs | Learn PlayCanvas ):
// 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) {
self.entity.model.asset = asset.resource.model;
self.entity.addComponent("animation", {
activate: false,
assets: asset.resource.animations
});
self.entity.animation.play('AnimatedMorphCube.glb', 0);
});
};
Hi, i have same issues with playing morphtargets. I imported fbx from blender with key animation and shape keys. I can see the morphtargets but i cant see the key animation. I add the new anim compenent to template and select the animation. Wen i launch it i see the key animation but not morphtarget animation.In your project you use one single glb file and add the animation with the script but i export the as fbx and playcanvas convert it to glb files. How can i now add the morphtargets to my entity. Do you have any idea? Thank you
Trying out this code now but can’t seem to get this to work. Is it correct as written?