Should Cesium.ExtrapolationType.HOLD consider last known orientation?

I’m using a SampledPositionProperty for position, VelocityOrientationProperty for orientation, and a forwardExtrapolationType of Cesium.ExtrapolationType.HOLD to model the movement of a 3D entity. Once the time advances past the window of sample data, I would expect the HOLD to maintain not only position, but also last known orientation (with zero velocity and acceleration). It seems to only hold the last position, while returning orientation to default.

In my case, I’m calculating waypoints on the fly (which takes <1 second), but there is sometimes a gap where my entities reach the last sample before I can add a new future sample. This results in the entity pausing at the last sample and waiting for the next sample to arrive (which is what I would expect), but the reset of orientation to default causes the motion to look less smooth as the entity briefly faces in the default heading.

Am I doing this incorrectly? Or is there a way to specify that the HOLD applies not only to position but also last know orientation?

Welcome to the Cesium community @zouyaoji! As Matt mentioned here you should be able to do this by setting the same interpolation properties on your orientation property.

If that’s not working, can you reproduce the issue you’re seeing in a Sandcastle ? You can put your example there, press “Share” and paste the link here.

Hi, omar, thank you for your support, but I didn’t use SampledProperty to defined orientation, I used VelocityOrientationProperty do defined orientation. This is my demo:

Test

Oh yes, I remember this issue now. The velocity orientation property does not do any interpolation of its own. It just takes the last two positions in time. If those two positions are the same, then there’s no valid orientation that can be discerned.

There’s some discussion here about how you can work around this: The orientation of vehicles has problem when waiting in front of traffic light - #2 by omar by using a CompositePositionProperty that defines how to handle this case in your app.

Hi Omar,
Thanks a lot for your answer!

I have read those discussions on this issue. In my case, assuming that the data is pushed every two seconds, how should I get the time interval when the aircraft is moving and the time interval when it stops?

I don’t know at what time the aircraft will be in a waiting state within a two-second interval. Is there an example for reference?

I may find a relatively simple way to solve this issue, by using CallbackProperty. But I’m not sure if there will be other problems. It is still good to use it. It is recommended that you take a look, if possible, and hope to help others who encounter similar problems.

var viewer = new Cesium.Viewer(“cesiumContainer”, {
infoBox: false,
selectionIndicator: false,
shadows: true,
shouldAnimate: true
});
viewer.camera.setView({
destination: Cesium.Cartesian3.fromDegrees(105, 30, 15000000)
});

var position = new Cesium.SampledPositionProperty();
position.forwardExtrapolationType =
    Cesium.ExtrapolationType.HOLD;

var lastOri = undefined;
var orientation = new Cesium.VelocityOrientationProperty(
    position
);
var lastAxis = undefined;
var alignedAxis = new Cesium.VelocityVectorProperty(position);

viewer.entities.removeAll();

var entity = viewer.entities.add({
    name: "../../SampleData/models/CesiumAir/Cesium_Air.glb",
    position: position,
    orientation: new Cesium.CallbackProperty(function(time, result) {
      var ori = orientation.getValue(time)
      if (ori) {
        lastOri = ori
      } else {
        return lastOri
      }
      return ori
    }, false),
    model: {
        uri: "../../SampleData/models/CesiumAir/Cesium_Air.glb",
        minimumPixelSize: 128,
        maximumScale: 20000
    },
    billboard: {
        image: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABQklEQVR42u1VOwrCQBSMYOEF7EQE7yBW1t5BEKxt0ljbaOMRxMIbWFp6AiutRQ1opeAB9DkPXjDoJuazu4JkYEh2eTszbLJvHScFiIhZBvdCfnesAoYbemFr05jZpE80re0CjGaKADObu3BQBDjYDKBEHiAP8N8BfH08axSOWrBWtzH3+wV9B9eUtQWBSAmcUnLwmlJW8zFlxziNsQveSR9Yy43znTvgjcyBtTsf/wcGLfCYQOgRcy4M7NX6eq4FHrgEJ2AXrEfU1qVmImu8KOH3AGtwDg7ANliJ+FShgqqjx1qiORCPNQXECr/qhGm888vID3BR+F9tBlgpAqxsmfOldFIEOPuXkEnzRowm0zBl3kvQ6Xqm//zdW+s+ypy5EyEXyRCsyrgf8OvLXFVqbrrNC4q5YiBAUVuXSxhsxMyi8QTgFyrjcMz6hwAAAABJRU5ErkJggg==',
        alignedAxis: new Cesium.CallbackProperty(function(time, result) {
          var axis = alignedAxis.getValue(time)
          if (axis) {
            lastAxis = axis
          } else {
            return lastAxis
          }
          return axis
        }, false),
        pixelOffset: new Cesium.Cartesian2(100, 100)
    }
});

var positions = [
    {
        lng: 132.399,
        lat: 51.478
    },
    {
        lng: 136.607,
        lat: 49.992
    },
    {
        lng: 136.69,
        lat: 47.022
    },
    {
        lng: 135.287,
        lat: 43.969
    },
    {
        lng: 134.621,
        lat: 42.52
    },
    {
        lng: 132.317,
        lat: 41.906
    },
    {
        lng: 130.666,
        lat: 39.844
    },
    {
        lng: 129.056,
        lat: 37.831
    }
];
var i = 0;
setInterval(function() {
    position.addSample(
        Cesium.JulianDate.addSeconds(
            Cesium.JulianDate.now(),
            1,
            new Cesium.JulianDate()
        ),
        Cesium.Cartesian3.fromDegrees(positions[i].lng, positions[i].lat, 20000)
    );
    i++;
    if (i > 7) {
        i = 0;
    }
}, 2000);

Sancastle: Link

Hello, after I set trackedEntity, I feel not right. will you take another look?

Sancastle Link

It feels very different from this example.

I think this is the same issue that is described here: https://github.com/CesiumGS/cesium/issues/8350

What I haven’t figured out a solution to yet.

Okay, I have tried using the viewFrom parameter on the entity, but it has not improved. let me check again. If you find a solution, please share it, thank you very much.

I don’t have an answer for the viewFrom problem yet, but I opened a GitHub issue for improving the behavior of VelocityOrientationProperty here: https://github.com/CesiumGS/cesium/issues/8900