Clamping to ground PointPrimitiveCollection is not working!

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++) {


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

        color : color,

        heightReference : Cesium.HeightReference.RELATIVE_TO_GROUND




Any help would be greatly appreciated.



A PointPrimitiveCollection does not take a height reference, see:

Have you tried using the Entity API to add your points, like here:

I have many many points ([x,y,z,value] data). I would like to use “point cloud” technology, but I don’t know how to make point cloud from these data simply, not using .las files and similar exotic compexities. I thought using PointPrimitiveCollection I will gain better performance then separately adding points.

Where do your XYZ values come from? What format are you using to gather/generate these?

They are generated programmatically using multiagent library MASON

Java array of double arrays.

If you want to get a custom point cloud like that in CesiumJS the easiest way may be to generate a LAS file. I’ve found tools like LASPy useful for this: It should be straightforward if you can export your XYZ values from Java as a CSV file, and have a few lines of Python code turn that into an LAS that you can upload to Cesium ion.

That still doesn’t solve the clamp to ground issue though - as far as I’m aware most use cases for point clouds need to maintain the position of each point, so you’d lose that information if you clamp to ground. But if you did need to do this with primitives you’d have to look at how the Entity API does it (which queries the terrain height at each point) and moves the position accordingly (but at that point you might as well use the Entity API).

1 Like