Thanks to http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Interpolation.html&label=Showcases
I want to control the camer view based on the real-time location and direction of the model.
object.cesiumData.then(function(datasource){
var temp_entity = datasource.entities.values[datasource.entities.values.length-1];
temp_entity.position.setInterpolationOptions({
interpolationDegree : 15,
interpolationAlgorithm : Cesium.LagrangePolynomialApproximation
});
temp_entity.orientation = new Cesium.VelocityOrientationProperty(temp_entity.position);
fly_callback = globalSetting.viewer.clock.onTick.addEventListener(function(clock) {
var camera = globalSetting.viewer.camera;
camera.position = temp_entity.position.`getValueInReferenceFrame`(clock.currentTime, Cesium.ReferenceFrame.FIXED);
var tempCartoP = Cesium.Cartographic.clone(camera.positionCartographic);
tempCartoP.height += 5.5;
camera.position = Cesium.Cartesian3.fromRadians(tempCartoP.longitude, tempCartoP.latitude, tempCartoP.height);
var tempMatrix3 = new Cesium.Matrix3.fromQuaternion(temp_entity.orientation.getValue(clock.currentTime));
var testDirection = new Cesium.Cartesian3(1, 0.0, 0.0);
Cesium.Matrix3.multiplyByVector(tempMatrix3, testDirection, testDirection);
var testUp = new Cesium.Cartesian3(0.0 , 0.0, 1);
Cesium.Matrix3.multiplyByVector(tempMatrix3, testUp , testUp );
Cesium.Cartesian3.normalize(testDirection, testDirection);
Cesium.Cartesian3.normalize(testUp , testUp );
camera.direction = testDirection.clone();
camera.up = testUp.clone();
});
});
I think this model should be stationary relative to the camera. But the actual effect of this model is floating. Has been swaying around.
What did I ignore?
Cesium version:1.31.0
firefox 49.