CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
13.03k stars 3.51k forks source link

Support glTF animations in 3D Tiles payloads #8962

Closed bertt closed 4 years ago

bertt commented 4 years ago

Hi, is there somewhere a sample/documention of playing glTF animation from b3dm tile(s) in Cesium? Is it supported? I see my tiles are rendered in Cesium but the animation is not playing :-(

mramato commented 4 years ago

This has come up before but I don't believe we have an issue so thanks for writing one up. I'll update the issue title to make it clear this is a general feature request.

The 3D Tiles implementation does not currently activate and/or update animations contained within individual payloads. I'm not sure of how difficult this would be to expose as an option to the end-user API. I would imagine it would be similar to how Model works and then the tileset would have to cycle through all visible tiles each frame and updating the model animations. Depending on the number of animations, scalability could be an issue, both because of additional draw calls and also because of the time it takes to animate each tile.

When he has time, perhaps @lilleyse can chime in with his thoughts.

lilleyse commented 4 years ago

First thing I would check is if the glTF animates by itself. b3dm contains a Model instance which has a ModelAnimationCollection that uses frameState.time. I would expect animation to work out of the box. @bertt are you able to share your tileset ?

bertt commented 4 years ago

yes sure,

live demo: https://bertt.github.io/cesium_3dtiles_samples/samples/animations/

code: https://github.com/bertt/cesium_3dtiles_samples/tree/master/samples/animations

I've unpacked the 1.b3dm to 1.glb and gltf: https://github.com/bertt/cesium_3dtiles_samples/blob/master/samples/animations/tiles/1.gltf

When inspecting the glb in Gestaltor it displays an animation with name 'track1':

animation

it also animates something when playing in Gestaltor.

lilleyse commented 4 years ago

Thanks @bertt, can confirm that animations don't play for the 3D Tiles on my end either.

Looks like the thing that's missing from the 3D Tiles code is a call to add the animations, like what ModelVisualizer does for glTF's in CZML:

model.activeAnimations.addAll({
    loop: ModelAnimationLoop.REPEAT
});

This could be added pretty easily to Batched3DModel3DTileContent and Instanced3DModel3DTileContent.