Hi all,
we are trying to implement a POV view for a tracking test.
The goal is to have an entity visualized by a model and the camera following a short distance behind, like a third person view where the model is still visble.
We have everything working, the path, the model moving smoothly along the path, but when trying to see what the model sees we encounter some ugly jumps and ~180 deg turns of the camera.
// The entity
var entity = this.cesium.viewer.entities.add({
availability: new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({
start: startTime,
stop: stopTime
})]),
position: new Cesium.SampledPositionProperty(),
show: true,
orientation: new Cesium.VelocityOrientationProperty(entity.position), // this is reset each time the position of the entity is updated
model: {
uri: ‘/model.gltf’,
minimumPixelSize: 64
},
path: {
resolution: 5,
material: new Cesium.PolylineOutlineMaterialProperty({
color: cesiumColor
}),
width: 5,
leadTime: 0,
trailTime: settings.trailTime,
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND
}
});
// --------------------------------------------------------
// This is running each camera tick
var direction = entity.orientation.getValue(time);
var angle = Cesium.Quaternion.computeAngle(direction);
// bad way to turn camera by 180 deg
angle = Cesium.Math.toRadians(Cesium.Math.toDegrees(angle) + 180);
camera.lookAt(position, new Cesium.HeadingPitchRange(angle, cesium.viewer.camera.pitch, 10));
``
I looked at the orientation value for the time when the jumps occur and the Quaternions “w” value (which is used to calculate the angle) is jumping there from e.g. 0.4xxxx to -0.xxxx,
so most probably the problem is in the entities orientation - still I’m wondering why the model then moves smoothly.
I uploaded a small video showcasing what I’m talking about: https://youtu.be/F6RiGhSY5ws
Jumps happen at ~12sec and ~28sec.
Somewhere I heard it’s too possible to take the models matrix and move the camera with that information, but I’m not familiar enough how that would work.
Side question: How would i get the pitch of the model/path? That would be our next step after fixing this issue.
Would appreciate any help, thank you in advance.