Hello there, i am trying to animate a gltf model exported from blender using gltf-Blender-Exporter. The animation works in blender and some online model viewers too but i have failed to play it in cesium. Following is my code:
var viewer = new Cesium.Viewer(‘cesiumContainer’, {
infoBox : false,
selectionIndicator : false,
shadows : true,
shouldAnimate : true
});
var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
Cesium.Cartesian3.fromDegrees(101.70333333333,3.1527777777778,600));
var model = viewer.scene.primitives.add(Cesium.Model.fromGltf({
url : Cesium.buildModuleUrl(‘Assets/Textures/flame/gltf_file.gltf’),
modelMatrix : modelMatrix,
scale: 5000
}));
Cesium.when(model.readyPromise).then(function(model) {
model.activeAnimations.addAll({
loop : Cesium.ModelAnimationLoop.REPEAT
});
})
``
Can anyone help me finding the issue here? I have attached the gltf file for reference.
-Thanks!
Cesium version: 1.48
flame.gltf (22.5 KB)
I can see the animation names in model.activeAnimations which means they are being added to the model but for some reason they don’t work. I have tried another model which only had simple scale animation and that didn’t work too. Its strange.
Cesium doesn’t yet support the CUBICSPLINE animation type.
In the Blender glTF exporter, look for the export options panel, “Animation” tab (during export). Try putting a checkmark on “Always Sample Animations.” That should convert everything to LINEAR. Let us know if it works!
–Ed.
Hello Ed,
I tried the “Always sample animation” option in blender gltf exporter but the animation is still not working. I have attached the newly exported file.
flame.gltf (37.1 KB)
The .gltf file by itself won’t work without the .bin and textures. Can you attach a .glb file instead? The .glb form has the whole bundle. Thanks,
–Ed.
Hello Ed,
Thanks for quick response, i appreciate your time. I have placed the .bin and texture file in the same folder the .gltf is placed and I think its working because I can see the texture on the model in cesium. I am not using .glb because sometimes it gives strange output i.e. objects are not placed at right positions and the scale is not right. I have attached a rar files which contains .glb, .gltf, .bin, texture, and my export settings screenshot. Both .glb and .gltf are exported with “Always sample animation” option now.
-Thanks
Flame.zip (4.19 MB)
Well. Looks like the sampled animations are using STEP, not LINEAR. My general thoughts on this are (a) Cesium should add support for STEP animation, and (b) I’m disappointed the Blender exporter is producing STEP instead of LINEAR as an approximation for sampled spline curves, that seems incorrect.
Not sure what to tell you from here. Either Cesium or the Blender exporter (or both) will need to change.
The only workaround you have left is to go into Blender’s Graph Editor pane, select some keyframes and manually change the “interpolation type” to “linear”. This will remove all the curvature, so you’ll need additional linear keyframes to break up the straight lines and make them look a little more as if they were curves. I’m sorry I don’t have anything better to tell you about this, but it would seem that some issues need to be filed.
–Ed.
Thanks alot Ed! for pointing me in the right direction. I will experiment with graph editor and post my results here and I will also file an issue on git repo.
I exported the model to gltf using “Always Sample Animations” option. Then I opened .gltf file in text editor and replaced STEP with LINEAR manually. The animations are now working. However, animations are behaving slightly different than original ones.
A fix was submitted to the Blender exporter in https://github.com/KhronosGroup/glTF-Blender-IO/pull/417. I think it should have made it into last night’s build of 2.80.
–Ed.