CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.92k stars 3.48k forks source link

CLAMP_TO_GROUND for Billboards incorrect positions #4776

Open Joebh opened 7 years ago

Joebh commented 7 years ago

When using a terrain provider that uses a heightmap terrain format, the CLAMP_TO_GROUND property produces incorrect positions for billboards. It is easier to see when there are more billboards placed. I can get it to happen every time when there are 10 billboards on the globe.

I've tested with the terrain provider at https://cesiumjs.org/smallTerrain. This is not an issue when the terrain provider provides a quantized mesh format.

I'm using the current 3d-tiles branch at revision 31cf664a04881bc618f468043370f8fcd254859b.

hpinkos commented 7 years ago

Thanks @Joebh, I was able to reproduce this.
It doesn't happen every time, but occasionally some of the points doesn't get clamped to the terrain. Here is a code example:

var viewer = new Cesium.Viewer('cesiumContainer');

viewer.terrainProvider = new Cesium.VRTheWorldTerrainProvider({
    url : 'http://www.vr-theworld.com/vr-theworld/tiles1.0.0/73/',
    credit : 'Terrain data courtesy VT MÄK'
});

var lon = -122.1957;
var lat = 46.1914;

for (var i = 0; i < 5; i++) {
    for (var j = 0; j < 5; j++) {
        viewer.entities.add({
            position : Cesium.Cartesian3.fromDegrees(lon + i*0.0001, lat + j*0.0001),
            point : {
                color : Cesium.Color.RED,
                pixelSize : 10,
                heightReference : Cesium.HeightReference.CLAMP_TO_GROUND
            }
        });
    }
}
pjcozzi commented 7 years ago

Is this the same issue as #4598?

hpinkos commented 7 years ago

I could still reproduce it with the fix in #4622, so I don't think it's the same issue

duvifn commented 7 years ago

Is this the same issue as #4598?

Issue #4598 is a position offset of clamped billboards and here the problem is, actually, that the billboards don't get clamped to the current level of terrain (as @hpinkos wrote).

It's caused by the fact that billboards don't get updated in some conditions (points 2,3,4 in #4686, and maybe additional problems).

It occasionally happens also with STK Terrain. I was able to reproduce this by removing the cache and putting the camera close, before the loading start (to increase the chance of using upsampled tiles).

ggetz commented 7 years ago

Came on the forum: https://groups.google.com/forum/#!topic/cesium-dev/NroeiSFxKFw

ggetz commented 6 years ago

Cam up again on the forum: https://groups.google.com/forum/#!topic/cesium-dev/kQiuFbnTpSQ

smills2929 commented 6 years ago

I can confirm I am having the same issue.

ihpled commented 2 years ago

I, don't know if it is related to the same bug but billboards doesn't clamp to ground at all when terrain provider is ArcGISTiledElevationTerrainProvider. They behave correctly when provider is of type returned by Cesium.createWorldTerrain(). Is it a known issue?