Good to hear! I’ve edited the code slightly, adding in a check for undefined values.
You could also have the camera pitch down as well, rotating mydir and myup before setting the rot mat to the camera.
Might want to check out some smoothing options (Hermite Polynomial seems to work well)
It’ll handle alot of what you’ve coded for. Can get orientation real time as you’re traveling along the track.
There’s a caveat with interpolation: If there’s a large gap between 2 points and you want to travel between the 2 points in a straight line, but you enter and exit this line at a sharp degree, it’ll travel along a far out curve. I’ve witnessed this trying out the non-linear interpolations. A solution would be providing some more points between large gaps.
I’ve edited the code again (check above post) to add a pitch down. It makes use of a rotate function:
var CC3 = Cesium.Cartesian3;var rotated=new CC3();
var dotS = CC3.dot(rotatee,rotater);
var base = CC3.multiplyByScalar(rotater,dotS,new CC3());
var vpa = CC3.subtract(rotatee,base,new CC3());
var cx = CC3.multiplyByScalar(vpa,Math.cos(angleRad),new CC3());
var vppa = CC3.cross(rotater,vpa,new CC3());
var cy = CC3.multiplyByScalar(vppa,Math.sin(angleRad),new CC3());
var temp = CC3.add(base,cx,new CC3());
var rotated = CC3.add(temp,cy,new CC3());
Oh ya, if you want to see what I mean by curving around large gap, put this at the end of the addpointentity function: