How does the cesium car keep the direction of the last frame after it stops( (code attached)

Test code: use the parameter static constant cell.extrapolationtype.hold—it explains When the sample data is out of range, the first or last value will be used. But in fact, we always keep the first value, or the east direction, and we can’t keep the direction of the last frame. After testing, the following code will turn to the east when it stops while i wonder it keeps the direction of the last frame. The following code can be copied directly into the online example of cesium _–Cesium Sandcastle

Please ! thank you very much!

var viewer = new Cesium.Viewer(“cesiumContainer”, {

shouldAnimate: true,

});

let czml = [{

“id”: “document”,

                "version": "1.0",

                "clock": {

                    "currentTime": "2020-12-20T16:00:03Z",

                    "multiplier": 1

                }

            }, {

                "id": "line1",

                "name": "XX路线1",

                "availability": "2020-12-20T16:00:00Z/2020-12-20T16:05:00Z",

                "model": {

                    "gltf": "../SampleData/models/GroundVehicle/GroundVehicle.glb",

                    "scale": 1

                },

                "orientation": {

                    "velocityReference": "#position"

                },

                "viewFrom": {

                    "cartesian": [80, 80, 80]

                },

                "path": {

                    "material": {

                        "solidColor": {

                            "color": {

                                "interval": "2020-12-20T16:00:00Z/2020-12-20T16:05:00Z",

                                "rgba": [255, 0, 0, 255]

                            }

                        }

                    },

                    "width": [{

                        "interval": "2020-12-20T16:00:00Z/2020-12-20T16:05:00Z",

                        "number": 0.0

                    }]

                },

                "position": {

                    "interpolationAlgorithm": "LAGRANGE",

                    "forwardExtrapolationType": 'HOLD',

                    "interpolationDegree": 1,

                    "epoch": "2020-12-20T16:00:00Z",

                    "cartographicDegrees": [

                        0.00,108.328947792453,22.7469164044214,0.0,

                        3.071,108.329388241433,22.7470366141948,0.0,

                        5.540,108.32928156764,22.7474785429229,0.0,

                        9.540,108.329014032717,22.7474785429229,0.0

                    ]

                }

            }]

            var dataSourcePromise = new Cesium.CzmlDataSource.load(czml);
         
            viewer.dataSources.add(dataSourcePromise);

            viewer.zoomTo(dataSourcePromise);

Hi @metyoo – can I confirm with you that this is the Sandcastle that you are using to test this?

It does appear that once the car reaches the end of its track, it completely flips its direction. I just want to make sure I understand what you’re asking – do you want help with a fix for this?

1 Like

Thanks for you reply, so sorry that i just saw it so late. Yes ,your test is exactly reproduce my problem . “It does appear that once the car reaches the end of its track, it completely flips its direction” ——i don’t want it flips its direction, i just want it remain its direction when the car reaches the end, no flips,no flips.

thank you

Thanks for you reply, so sorry that i just saw it so late. Yes ,your test is exactly reproduce my problem . “It does appear that once the car reaches the end of its track, it completely flips its direction” ——i don’t want it flips its direction, i just want it remain its direction when the car reaches the end, no flips,no flips.

thank you

There isn’t an easy fix here because of how the orientation is computed from speed (since when the entity is not moving, the orientation is undefined). See this issue for more details and some suggested workarounds: Make VelocityOrientationProperty better handle case where entity stops · Issue #8900 · CesiumGS/cesium · GitHub