Orientation of entity changing even if the position is changed

Copy and paste the following code in sandcastle.

After few (2/4) seconds you will notice the model orientation is changing for few moment and going back to actual.

Is this expected?

Or there is bug in the following code/Cesium.VelocityOrientationProperty?

Please help me on this.

`var viewer = new Cesium.Viewer(“cesiumContainer”);
Cesium.Math.setRandomNumberSeed(3);

//Set bounds of our simulation time
var start = Cesium.JulianDate.fromDate(new Date(2020, 2, 25, 16));
var stop = Cesium.JulianDate.addSeconds(
start,
30,
new Cesium.JulianDate()
);

//Make sure viewer is at the desired time.
viewer.clock.startTime = start.clone();
viewer.clock.stopTime = stop.clone();
viewer.clock.currentTime = start.clone();
viewer.clock.clockRange = Cesium.ClockRange.UNBOUNDED; //Loop at the end
viewer.clock.multiplier = 0.12;
viewer.clock.shouldAnimate = true;

//Set timeline to simulation bounds
viewer.timeline.zoomTo(start, stop);

var pos1 = Cesium.Cartesian3.fromDegrees(
-75.15787310614596,
39.97862668312678
);
/var pos2 = Cesium.Cartesian3.fromDegrees(
-75.1633691390455,
39.95355089912078
);
/
var position = new Cesium.SampledPositionProperty();

position.addSample(start, pos1);
//position.addSample(stop, pos1);

var entity = viewer.entities.add({
//position: Cesium.Cartesian3.fromDegrees(55.06947837489445, 24.994953965832412, 50),
model: {
uri: “…/SampleData/models/CesiumMilkTruck/CesiumMilkTruck.glb”,
minimumPixelSize: 64,
},
viewFrom: new Cesium.Cartesian3(-100.0, 0.0, 100.0),
position: position,
orientation: new Cesium.VelocityOrientationProperty(position),
});

viewer.trackedEntity = entity;

setInterval(function(){
var stop1 = Cesium.JulianDate.addSeconds(
viewer.clock.currentTime,
2.1,
new Cesium.JulianDate()
);
position.addSample(stop1, pos1);

}, 2000);
`

Can you share your Sandcastle example with the “Share” button? See: How to share custom Sandcastle examples. Or using code-blocks. It’s hard to copy-paste this into Sandcastle without manually fixing characters like the quotes.

I think I can guess what the issue is though - if there are no samples for the VelocityOrientationProperty to sample, it’ll snap to a default. I posted a link here that explains this issue and has some discussion about how this may be fixed: Orientation problem at the end path VelocityOrientationProperty.

1 Like

Yeah it’s same question posted of the following link: