Manage animations of an entity model

1. A concise explanation of the problem you’re experiencing.

Hi, I’m doing a sort of flight simulation with flight data, so far i’ve done pretty good, I have the plane moving and rotating as it did in real life, with a polyline showing its route,

but I’d like to trigger animations of my model when certain events occur, the thing is that my plane is an entity and therefore needs a “Cesium.ModelGraphics” object as the model. I’ve seen in the documentation that “Cesium.Model” contains “activeAnimations” where you can add or remove your animations and trigger them depending on the time which is exactly what I need !But i’m working with an entity which it’s a higher level object that was advised to work with when you want to animate position and rotation I can’t seem to have acces to “Cesium.Model” or at least that’s where i’m stuck.

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

What i’m currently doing:

mymodel = new Cesium.ModelGraphics({

uri : ‘./3D_model/atr_complete.gltf’,

scale : 2.3,

minimumPixelSize : 2,

maximumScale : 600

});

planeEntity = cesiumViewer.entities.add({

availability: new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({

start: start,

stop: stop

})]),

name: 'ATR ’ + plane.model,

//Use our computed positions

position: posProperty,

orientation: orientationProperty,

//Load the Cesium plane model to represent the plane

model: mymodel,

});

Thank you very much for your help

Hey, it’s me, again.

So I dug into the Source code and i’ve seen that “ModelVisualizer” takes the entity and more specifically the “ModelGraphics” and then transforms it into a “Model” to render it, so i’m thinking maybe I could intervene in the process and do so that the ModelGraphics does the same as the Model.

My plan right now is to try to add the methods belonging to “Model” to “ModelGraphics” and then change the “Cesium.js” source code to take into account the animations times and parameters that I’ll need.

Do you think it’s feasible? If you have another solution i’d also be down for it :>

Honestly seems weird that no one ever ran into this issue.

As always, Thank you for your help and also just your amazing work on Cesium :slight_smile:

Hi there,

It does seem weird that no one has run into this issue! I did a quick search on the forum and couldn’t find a similar question already asked.

ModelGraphics does have a property runAnimations which determines if the animations should be run or not. The value of runAnimations is a Property, which means the value doesn’t have to be constant. I think you’ll want to use a CallbackProperty for your purposes, and update the value returned based on what’s happening in your app.

Thanks,

Gabby

Hi Gabby,

Thank you for your answer !

Correct me if i’m wrong but I believe the property runAnimations runs all the animations at once, so even if I can put false or true overtime I won’t be able to do just one animation if I want to because there are like 5 distinct animations within my gltf model.

However, if I would be working with a simple model, I would have access to the Cesium.ModelAnimationCollection() and could add just the animation I want.

Thanks,

Quentin

Is there any reason why there isn’t a “modelAnimationCollection” Member to the "Cesium.ModelGraphics" Object ?
I don’t see the purpose of having a “runAnimations” property that’s gonna run either all the animations or none, because in the “Cesium.ModelVisualizer” that transforms a ModelGraphics into a Model, You have the “activeAnimations” member anyway and you just addAll or add nothing depending on the “runAnimations” property.

So I’m wondering why not having a modelAnimationCollection member to the ModelGraphics and just give it to the Model inside the ModelVisualizer?

Quentin

One way to do data-driven animations is to use the existing nodeTransformations system:

https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/?src=CZML%20Model%20-%20Node%20Transformations.html

Essentially these are more powerful than canned animations because the transformation values (translate/rotate/scale) for any number of nodes can be computed based on simulation time. You could imagine opening payload bay doors at a certain mission time, then closing them later, by describing the transformations to apply to various nodes in the model, with automatic interpolation between data points.