0

I'm using a sandcastle example to animate an entity by using SampledProperty and clampToGround methods. I want to add height distance between entity and the path on which it is moving.

I have tried the solution given on this link But not getting any change on entity position. Here is the sandcastle link

Jacky
  • 47
  • 5
  • I'm not certain, but I think `clampToGround` likely isn't compatible with adding a height. You may have to fetch the heights from the terrain and include them in the SampledPositionProperty. – emackey Jan 07 '22 at 14:47
  • I think I got failed to explain the requirement properly. I wanted to move object with clampToGround position but at given height. – Jacky Jan 07 '22 at 15:55

1 Answers1

0

Solved it by modify code as below:

function start() {
  clock.shouldAnimate = true;
  var objectsToExclude = [entity];
  scene.postRender.addEventListener(function () {
    var position = positionProperty.getValue(clock.currentTime);
    var clampPos = scene.clampToHeight(position, objectsToExclude);
    clampPos = Cesium.Matrix4.multiplyByPoint(Cesium.Transforms.eastNorthUpToFixedFrame(clampPos),new Cesium.Cartesian3(0, 0, 2), new Cesium.Cartesian3());
    entity.position = clampPos;
  });
}

Sandcastle link

Jacky
  • 47
  • 5