Clamping to ground PointPrimitiveCollection

Dear Cesium users and team!

How to clamp to ground PointPrimitiveCollection?

I have tried this code in sandcastle, but it is not working :frowning:

var viewer = new Cesium.Viewer(‘cesiumContainer’, {

terrainProvider: Cesium.createWorldTerrain()

});

viewer.scene.globe.depthTestAgainstTerrain = true;

var points = viewer.scene.primitives.add(new Cesium.PointPrimitiveCollection({

heightReference : Cesium.HeightReference.CLAMP_TO_GROUND

}));

for (var longitude = -180; longitude < 180; longitude++) {

var color = Cesium.Color.PINK;

if ((longitude % 2) === 0) {

color = Cesium.Color.CYAN;

}

for (var latitude = -90; latitude < 90; latitude++) {

points.add({

position : Cesium.Cartesian3.fromDegrees(longitude, latitude),

color : color,

heightReference : Cesium.HeightReference.RELATIVE_TO_GROUND

});

}

}

Any help would be greatly appreciated.

Sincerely,

Ru