Offset position of trackedEntity?

Is there a way to have a tracked entity be not in the vertical center, but maybe just 1/3 up from the bottom? similar to how GPS have “direction up” mode where your own position is lower than center?

Hi @poncho524 ,
You can change entity position by adding offsets as given below:

let position = entity.position; //cartesian3
let offsetz = 100;
entity.position = Cesium.Matrix4.multiplyByPoint(Cesium.Transforms.eastNorthUpToFixedFrame(position),
                new Cesium.Cartesian3(0, 0, offsetz), new Cesium.Cartesian3());

Please elaborate, if it doesn’t solve your issue.

  • Regards,

I’m not interested in moving the “trackedEntity” but in moving the camera position.

Currently if you set “trackedEntity” to an entity, then the camera will snap to having that entity in the horizontal and vertical center of the window. I’d like to have to remain in the horizontal center, but have the camera pitched up just a bit to look further ahead, but still bound to the entity, ie still have the entity be the pivot point of tilting.

Here’s a link to an older thread on this topic, I’d start there to see if that has some of the answers;

Cheers,

Alex

I’m not sure that answers my Q.

I modified the “interpolation” sandcastle to demo what i mean.
sandcastle demo

In this demo you’ll see the entity is set as the “tracked entity” so the camera is fixed on that position. I added rotating the camera based on the heading of the entity to so it follows the heading of the entity.

my question is this: the tracked entity is fixed at horizontal and vertical center of screen. is there a way to offset where on the screen the “tracked entity” is fixed?

like this… top is default… would like to move tracked entity to lower portion of screen and still remain the fixed pivot point.

1 Like

Ah, so you’re saying you want to follow the object, but not have the object in the center of the screen? I don’t think that is possible with parameters out of the box, but I would solve this by creating an invisible dot (or something) that share your models coordinates but with the right offset, and then follow that invisible dot. (You’d use a change-controlled callback for the position that simply readys the coord from the model at intervals or real-time, and do the offset)

Does that make sense? The only aber with this is of course that you need to control the camera a bit yourself to handle if the user moves the camera around manually and then you have to restrict it back to where you want the camera. Maybe you could try to draw a screenshot that shows what you’d like to achieve?

Cheers,

Alex

Hi, did you find the solution ? I would like to move tracked/target entity to bottom of the screen (same as Google Map app in navigation mode). I am using this code for chasing model.

          var matrix3Scratch = new Cesium.Matrix3();
          var positionScratch = new Cesium.Cartesian3();
          var orientationScratch = new Cesium.Quaternion();
          function getModelMatrix(entity, time, result) {
              var position = Cesium.Property.getValueOrUndefined(entity.position, time, positionScratch);
              if (!Cesium.defined(position)) {
                  return undefined;
              }
              var orientation = Cesium.Property.getValueOrUndefined(entity.orientation, time, orientationScratch);
              if (!Cesium.defined(orientation)) {
                  result = Cesium.Transforms.eastNorthUpToFixedFrame(position, undefined, result);
              } else {
                  result = Cesium.Matrix4.fromRotationTranslation(Cesium.Matrix3.fromQuaternion(orientation, matrix3Scratch), position, result);
              }
              return result;
          }
          viewer.scene.preRender.addEventListener(function(){
              getModelMatrix(currentPositionEntity, viewer.clock.currentTime, scratch);
              viewer.scene.camera.lookAtTransform(scratch, new Cesium.Cartesian3(0.0, 300.0, 700));
          });