Overriding the the model pitch/roll/yaw when using SampledPositionPropertys on a timeline

I have a model of a helicopter and a set of points starting at ground level, rising vertically and then flying more or less horizontally to a destination.
When I run the flightpath using the timeline widget, the model flies the first vertical section of the flight path with the helicopter nose pointing straight up which is a problem.
I tried specifying a modelMatrix with a transform to the entity I added to the viewer trackedEntity but that had no effect.

Is there a way to override the roll,pitch and yaw of my model at each of the SamplePositionProperty points of the flightpath, or to get an event callback per frame to set the orientation override?

Advice or sample code would be much appreciated.

Alec.

Hello Alec,

Usually this means that your model is oriented incorrectly. Usually the easiest solution for this is to re-orient it in a model editing tool and then re-convert it to glTF for use in Cesium. The model should be pointed forward along the X axis.

I don’t know of a good way to override this when using a sampled position property to orient the model.

Best,

Hannah

Hi Hanna,

Thanks for the response.
The model is oriented correctly when flying forwards on its flight path, but a helicopter can also rise upwards along it's Z axis so there is no way to make a flight path look correct for a helicopter without overriding its orientation.

Hi Alec,

You can specify an entity’s orientation in the same way you specify its position:

https://cesiumjs.org/Cesium/Build/Documentation/Entity.html#orientation

The orientations must be Quaternions, but you can construct those from heading/pitch/roll, matrices, etc:

https://cesiumjs.org/Cesium/Build/Documentation/Quaternion.html?classFilter=quate#.fromHeadingPitchRoll

Note that this is the rotation from the Earth Fixed axes (positive Z up through the North pole). If you want to express your rotation relative to the earth-north-up axes, use Transforms to compute it and then use Quaternion.fromRotationMatrix and Quaternion.multiply.

Kevin

Thanks Kevin, I’ll look into this approach.
Alec.