I have a path using SampledPositionProperty
, which I would like to have a model to follow.
The model is 180 degrees rotated and moves “backwards” along the path.
Inspired by this thread, I added the CallbackProperty
on the orientation, calling VelocityOrientationProperty
for each timestep.
I can then get the quaternion at a certain point in time. But I lack the skills, to add an additional heading rotation in a local reference system by 180 degrees.
Here is the code snippet. Some help in that orientation CallbackProperty
would be highly appreciated.
var position = new Cesium.SampledPositionProperty();
for (var i = 0; i < points.length; i ++) {
var time = Cesium.JulianDate.addSeconds(start, points[i].time - points[0].time, new Cesium.JulianDate());
var pos = Cesium.Cartesian3.fromDegrees(points[i].lon, points[i].lat, points[i].alt);
position.addSample(time, pos);
}
var path = this.viewer.entities.add({
position : position,
orientation: new Cesium.CallbackProperty(function(time, result){
var rwx = new Cesium.VelocityOrientationProperty(position).getValue(time);
var rwx1 = new Cesium.HeadingPitchRoll.fromQuaternion(rwx);
rwx1.heading += Math.PI;
var orientation = Cesium.Quaternion.fromHeadingPitchRoll(rwx1);
return orientation;
},false),
path : {
leadTime: 0,
trailTime: 20 * 60,
resolution : 5,
material: new Cesium.PolylineGlowMaterialProperty({
glowPower: 0.5,
taperPower: 0.3,
color: Cesium.Color.LIGHTSTEELBLUE,
}),
width : 5
},
model: {
uri: "./myModel.glb",
maximumScale:10000,
minimumPixelSize: 128
},
});