About control the camera view

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.

Like this. Anybody answer my doubts?

在 2017年5月4日星期四 UTC+8上午9:14:43,xuncanzhe写道:

Hi there,

Have you looked into viewer.trackedEntity (http://cesiumjs.org/Cesium/Build/Documentation/Viewer.html?classFilter=view#trackedEntity)? Would that method cover your desired behavior?

Hope that helps,

  • Rachel

Hi Rachel,

Thank you for your answer, The TrackedEntity does not apply to this situation. In fact, I want the model and the camera to be relatively stationary, position and direction.

  • xuncanzhe

在 2017年5月9日星期二 UTC+8下午9:13:07,Rachel Hwang写道:

Hi Xuncanzhe,

Here’s a code example that seems similar to what you want, if I understand you correctly. Check out this thread – seems relevant.

https://groups.google.com/forum/#!msg/cesium-dev/-mDNh2qlTZQ/WOIPQHVNAgAJ

Hope that helps,

  • Rachel

Hi Rachel,

Thank you for so much, It solved my problem perfectly. Although I do not know why I directly control the camera’s direction and location can not achieve this effect.

  • xuncanzhe

在 2017年5月12日星期五 UTC+8上午5:01:49,Rachel Hwang写道: