Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jitter when clamping to ground #4049

Open
mramato opened this issue Jun 27, 2016 · 4 comments
Open

Jitter when clamping to ground #4049

mramato opened this issue Jun 27, 2016 · 4 comments

Comments

@mramato
Copy link
Contributor

mramato commented Jun 27, 2016

Noticed while reviewing #3903. Here's a sandcastle example which creates a circular flight with altitude of 0 and then clamps to terrain. There is really jerky camera or entity motion as it animates.

var viewer = new Cesium.Viewer('cesiumContainer', {
    shouldAnimate: true,
    terrainProviderViewModels : [], //Disable terrain changing
    infoBox : false //Disable InfoBox widget
});

//Enable lighting based on sun/moon positions
viewer.terrainProvider = Cesium.createWorldTerrain();

//Use STK World Terrain
viewer.terrainProvider = new Cesium.CesiumTerrainProvider({
    url : 'https://assets.agi.com/stk-terrain/world',
    requestWaterMask : true,
    requestVertexNormals : true
});

//Enable depth testing so things behind the terrain disappear.
viewer.scene.globe.depthTestAgainstTerrain = true;

//Set the random number seed for consistent results.
Cesium.Math.setRandomNumberSeed(3);

//Set bounds of our simulation time
var start = Cesium.JulianDate.fromDate(new Date(2015, 2, 25, 16));
var stop = Cesium.JulianDate.addSeconds(start, 360, new Cesium.JulianDate());

//Make sure viewer is at the desired time.
viewer.clock.startTime = start.clone();
viewer.clock.stopTime = stop.clone();
viewer.clock.currentTime = start.clone();
viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP; //Loop at the end
viewer.clock.multiplier = 1;

//Set timeline to simulation bounds
viewer.timeline.zoomTo(start, stop);

//Generate a random circular pattern with varying heights.
function computeCirclularFlight(lon, lat, radius) {
    var property = new Cesium.SampledPositionProperty();
    for (var i = 0; i <= 360; i += 45) {
        var radians = Cesium.Math.toRadians(i);
        var time = Cesium.JulianDate.addSeconds(start, i, new Cesium.JulianDate());
        var position = Cesium.Cartesian3.fromDegrees(lon + (radius * 1.5 * Math.cos(radians)), lat + (radius * Math.sin(radians)), 0);
        property.addSample(time, position);

        //Also create a point for each sample we generate.
        viewer.entities.add({
            position : position,
            point : {
                pixelSize : 8,
                color : Cesium.Color.TRANSPARENT,
                outlineColor : Cesium.Color.YELLOW,
                outlineWidth : 3
            }
        });
    }
    return property;
}

//Compute the entity position property.
var position = computeCirclularFlight(-112.110693, 36.0994841, 0.03);

//Actually create the entity
var entity = viewer.entities.add({

    //Set the entity availability to the same interval as the simulation time.
    availability : new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({
        start : start,
        stop : stop
    })]),

    //Use our computed positions
    position : position,

    //Automatically compute orientation based on position movement.
    orientation : new Cesium.VelocityOrientationProperty(position),

    //Load the Cesium plane model to represent the entity
    model : {
        uri : '../../SampleData/models/CesiumAir/Cesium_Air.gltf',
        minimumPixelSize : 64,
        heightReference: Cesium.HeightReference.CLAMP_TO_GROUND
    }
});

viewer.trackedEntity = entity;
@pjcozzi
Copy link
Contributor

pjcozzi commented Jun 28, 2016

Looks like this happens on the first terrain height request of a new tile. To see it more clearly:

  • Zoom out a bit so lower LOD tiles are loaded
  • Make the animation speed something like 0.5x
  • Use the Cesium inspector to turn on Terrain -> Show tile coordinates
viewer.extend(Cesium.viewerCesiumInspectorMixin);

@srcejon
Copy link
Contributor

srcejon commented Jan 24, 2022

It seems there can be a lot of jitter even if we don't have any terrain loaded.

Sandcastle example

@srcejon
Copy link
Contributor

srcejon commented Jan 24, 2022

There's also jitter if RELATIVE_TO_GROUND is used:

Sandcastle example

@srcejon
Copy link
Contributor

srcejon commented Jan 25, 2022

Looks like this happens on the first terrain height request of a new tile. To see it more clearly:

  • Zoom out a bit so lower LOD tiles are loaded
  • Make the animation speed something like 0.5x
  • Use the Cesium inspector to turn on Terrain -> Show tile coordinates
viewer.extend(Cesium.viewerCesiumInspectorMixin);

The amount of jitter seems to be reduced if "Suspend LOD update" is checked. However, there's still some larger jitter at the end of this clip:

jitter

It looks like it's the camera that jitters rather than the model, as the motion appears smooth when the camera isn't tracking the entity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants