# \[Question\]about disableDepthTestDistance of PointPrimitive

**URL:** <https://community.cesium.com/t/question-about-disabledepthtestdistance-of-pointprimitive/15071>\
**Category:** CesiumJS\
**Created:** [August 31, 2021, 8:17am UTC](https://community.cesium.com/t/question-about-disabledepthtestdistance-of-pointprimitive/15071 "2021-08-31T08:17:42Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![zouyaoji](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/zouyaoji/32/2246_2.png) [@zouyaoji](https://community.cesium.com/u/zouyaoji)\
**Post date:** [August 31, 2021, 8:17am UTC](https://community.cesium.com/t/question-about-disabledepthtestdistance-of-pointprimitive/15071/1 "2021-08-31T08:17:42Z")

</div>

In my case,disableDepthTestDistance of PointPrimitive has been set to POSITIVE\_INFINITY, but it is still not at the top.It is still overwhelmed by CircleGeometry, which makes it impossible to pick up.

I want to keep PointPrimitive at the top level, even if the appearance.renderState.depthTest of the Primitive loaded CircleGeometry is false, what should I do?

See [Test DEMO](https://sandcastle.cesium.com/#c=lVbdkto2FH4VDVdmhgiD+TMhOyUsSZhkFybQ7XR2mYywBaixJY8k2NAdbprnyX171Zdpp6/RgzFgC9NNuULSOd85+s53jrwmEq0ZfaQSvUKcPqIeVWwV4rt4z3ooePG6J7gmjFP5UCi+fOAo+e09sUdCKgkOhPjc1dbpGKURe0Rq+Ee4k7FA6EWlWalX3Tp2a06t0azbrXopa1FzXQeMsGs7ddduNF3j3Kk3Gg2ngStOzW7UKrbdTJ8XSxcyekeJz/hixLS3/Ej4ghqJJWY3RC+xFh/BmHBlVW1sF0vfY/nCqZ+bQnYAkMnvtHiO24kE3LmQoXWKKNmXGh5c928ng8nPGQAobSQU00xwBdW9Twe9z2M9h+gcbqclVC6jv37/9vefX//57Y9z1Jrt4KrbaLlNx3WaCarr4kq1WW3ZdjVBrdca2HXtWt1ptKq1aYqnKdzCuIdkIVxkTXsiCKi3u1JWr6NzAyuHTeVRTvERTWHi+1YOePE8A8G4Hj2bxgWrTC7HomAoZZ94S2u+4nsw63BWRE9pYi9Fj/N/yipMLcVjG2m5oob0Dtjt85bEcynCrpRkc8rA9GZfaDBmv9I2amHbOPREIOQJd7eKIV9vIIBVrYO2qru6n7WDWOkA5kovx//1h27vfb75T8zXyzaqnOXhM0VmAb2mkV5OqNLXTGnCPcj5dhXOQACj4XgwGdz1Pw1u3wxuoWMyANt0mbZZEXhQMI0ATupRQhHU/nuYVPf2NA28R6Lc/984lWleTk/Ip3NgxS+hnb9YSBItmYe2R9wcJ49JL6BZ9fbivbdUhFTLTVZX0DiaQokyBGTIkzD2Vqq9m3ClZ1g8dtyFJs6GJlFEidyXMWUNs49KRoLu8djshDCxaJsuMbmTTQQTvxCLDZ41Q0lz4tE3Qj4S6ec2k4T6UTnWgNhGRlzQ4UGAOWcISr8TKeDOSaBMYKDM2NkaGs0sF0m1BnyvdJXh6K1xajJ08G4nevivSERtuLeUgotdlc3UjTpHF2bVcT8zEC8ZX5h659M5nusgpvSYN57CJeF+YH7mjD1JKR9HUOz+GhT+bm9k7d8Jj/A1UelMExCsqB7waKW7++l+mt+hWNMQgIz5Hb8gzPtM/eHsF7gEZJE8RbB5dMKpmZCOihCbo8OTn/S6lYYrFk2Z7fpMBBS+GxZZywzsNlW/0iVOdn2Cb4Y/jvufboZ3/eLLQqnQUXoT0KuD+w8sjITUaCUDC+OypmEUQGOo8mwFoTX21JHFTjnt2vHZGjH/Vc53JvICohSczFdB/O48FK46ZbA/cw1E/B03XFMZkM3ObFm5+rDfxBh3yrDM99RCBDMiDeR/AQ)

---

<div class="post-metadata">

**Author:** ![sam.rothstein](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/sam.rothstein/32/6584_2.png) [@sam.rothstein](https://community.cesium.com/u/sam.rothstein)\
**Post date:** [August 31, 2021, 6:43pm UTC](https://community.cesium.com/t/question-about-disabledepthtestdistance-of-pointprimitive/15071/2 "2021-08-31T18:43:58Z")

</div>

@zouyaoji

Thank you very much for the detailed community forum post! I would love to know more about your application. For instance, what are you trying to achieve with your `PointPrimative` objects? More information on your project goal would help me provide you with more tailored support. In the meantime, have you checked out the following community forum threads?

> [@Disable Depth Test For Polylines and Polygons](https://community.cesium.com/t/disable-depth-test-for-polylines-and-polygons/7312):
>
> 1. A concise explanation of the problem you're experiencing. Hi! I'm looking for an equivalent to disableDepthTestDistance in [https://cesiumjs.org/Cesium/Build/Documentation/PointGraphics.html](https://cesiumjs.org/Cesium/Build/Documentation/PointGraphics.html) for polylines and polygons. Even if the solution is less than elegant for the time being, I'll take it. Here are the current restrictions I'm working under: -All polylines and polygons must display on top of the globe and other entities. -Feature picking needs to still operate on these polylines and pol…

> [@Disabling depth test for some entities](https://community.cesium.com/t/disabling-depth-test-for-some-entities/5077):
>
> Hello, I'd like to disable the depth test for certain entities with absolute positioning (not attached to the ground). Ideally, I would like to do something like: polygonEntity = cesiumViewer.entities.add({ &nbsp;&nbsp;&nbsp;&nbsp;polygon: { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hierarchy: cesiumCartesian, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;perPositionHeight: true, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;material: Cesium.Color.GREEN.withAlpha(0.5), &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;renderState: { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;depthTest: {enabled: false} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;} }); Can anyone tell me what…

> [@Globe depth test disable](https://community.cesium.com/t/globe-depth-test-disable/12620):
>
> Hello! I’m trying to put transparent imagery with street names over 3d tileset There are some artifacts when globe geometry intersects with tileset How could I disable depth test for the globe to make my imagery rendered always on top of tileset? Thank you

These threads discuss a lot of the topics that you are mentioning here. Among other things, these resources discuss best practices for disabling depth tests for a variety of entities. I am curious to hear your thoughts!

-Sam

---

<div class="post-metadata">

**Author:** ![zouyaoji](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/zouyaoji/32/2246_2.png) [@zouyaoji](https://community.cesium.com/u/zouyaoji)\
**Post date:** [September 1, 2021, 1:41am UTC](https://community.cesium.com/t/question-about-disabledepthtestdistance-of-pointprimitive/15071/3 "2021-09-01T01:41:21Z")

</div>

Thank you so much [sam.rothstein](https://community.cesium.com/u/sam.rothstein)!

I want to keep my PointPrimative at the top level. I have set its disableDepthTestDistance property to Number.POSITIVE\_INFINITY. But it doesn’t seem to take effect. For details, you can see the Test Demo above.

The effect I want is:

 ![HA$JTWNL~~IT~BQWL29RN](https://global.discourse-cdn.com/cesium/original/2X/6/698560b9d91fe18bab34f2d7052712743ca154f6.jpeg)

The actual effect is:

 ![{7X70{FV%R%BY_Y_S}{7P](https://global.discourse-cdn.com/cesium/original/2X/8/8716dfe3e0e1bfbb0000e410ad80dc322f1fed3e.jpeg)

The PointPrimitive in the middle seems to be overwhelmed by the CircleGeometry, which prevents me from picking it up.

And the reason why I want Disable Depth Test For the CircleGeometry is because I want CircleGeometry to maintain its integrity and not be overwhelmed by other objects, such as 3dtiles.  
As shown below (Enable Depth Test):

 ![image](https://global.discourse-cdn.com/cesium/original/2X/1/1dfcf2e284fb536432012539e81829991614bf7a.jpeg)

For the CircleGeometry, the effect I want is as follows(Disable Depth Test):

 ![image](https://global.discourse-cdn.com/cesium/original/2X/e/e8481dbf03b6ae188a533ae5b91a08c789869861.jpeg)

But there is still a problem with the above effect. PointPrimitive is overwhelmed by CircleGeometry, even if the disableDepthTestDistance property of PointPrimitive has been set to Number.POSITIVE\_INFINITY.

So, my real demand is, Disable Depth Test For CircleGeometry, and keep PointPrimitive at the top.

I don’t know if I have described my problem clearly. I look forward to your reply.  
@sam.rothstein

---

<div class="post-metadata">

**Author:** ![IKangXu](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/ikangxu/32/6169_2.png) [@IKangXu](https://community.cesium.com/u/IKangXu)\
**Post date:** [September 1, 2021, 2:46am UTC](https://community.cesium.com/t/question-about-disabledepthtestdistance-of-pointprimitive/15071/4 "2021-09-01T02:46:34Z")

</div>

```auto
class VertexPrimitive{
    constructor() {
        this._vertexs = new Cesium.PointPrimitiveCollection({
            blendOption: Cesium.BlendOption.TRANSLUCENT
        })
    }

    add(vertex) {
        this._vertexs.add(vertex)
    }

    update(frameState) {
        if (this._vertexs.length > 0) {
            let originalLength = frameState.commandList.length
            this._vertexs.update(frameState)
            let endLength = frameState.commandList.length
            for (let i = originalLength; i < endLength; ++i) {
                frameState.commandList[i].pass = Cesium.Pass.TRANSLUCENT
                frameState.commandList[i].renderState = Cesium.RenderState.fromCache({
                    depthTest: {
                        enabled: false
                    },
                    depthMask: false
                })
            }
        }
    }

    ……
}

```

It can be solved in this way.

@zouyaoji

---

<div class="post-metadata">

**Author:** ![zouyaoji](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/zouyaoji/32/2246_2.png) [@zouyaoji](https://community.cesium.com/u/zouyaoji)\
**Post date:** [September 1, 2021, 5:31am UTC](https://community.cesium.com/t/question-about-disabledepthtestdistance-of-pointprimitive/15071/5 "2021-09-01T05:31:45Z")

</div>

@IKangXu  
Thank you for your reply. I tried the solution you gave, but it didn’t seem to work. I don’t know if I didn’t write it correctly.

[sandcastle](https://sandcastle.cesium.com/#c=nVfdcuI2FH4VDVd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ng5gjZTNqcpvt8P7r7RIVLlVyn8wpGjKIQopQDUs6TsCAsg3a4C5Te8OJhNh0Zd+mnie9TIrdhTHDDlkAlI7x3IOuV4O442rpI5NzJ2ofdqBAlGyyAWibNiE0/CvlMpJNbTIk2ltOGXm9R6daU6UF6V9poOZo6znfRGnrbTA9SPvqkUXUP7aXbu3x47SUSrD17IYUnwijrqmtx9o/0qsN9siCOMh/petmdIdqAIJmSC5G2NC5gBnH9g2BsS0q9sQ/BHqwgwz9vmYztRmUTb0WCpKY7EBxQNfT8pept96C4f7tiRV0A0vp3tGsx+4k6o8cfwQjQYre0weVBCCd6Qnq+sBnaL8e7WjeScMXMLA/rTHAKG/Y8zZmCTQytTemYT8I6wZej2/Hg6+XoblDsFEqFbqDWnJ7uxb9jri+kQkvJDYzLiro+h8IIyo9LeFphOzh4sVtOinYdtkLM+ZDzRYZsDmsGUGZLHs2dh8Jptwz8GVEuoi+e0YpKTtYh26JyerG9xBh3y3DMl1RC8EciNeR/AA)

---

<div class="post-metadata">

**Author:** ![IKangXu](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/ikangxu/32/6169_2.png) [@IKangXu](https://community.cesium.com/u/IKangXu)\
**Post date:** [September 1, 2021, 7:48am UTC](https://community.cesium.com/t/question-about-disabledepthtestdistance-of-pointprimitive/15071/6 "2021-09-01T07:48:02Z")

</div>

@zouyaoji switch to entity to load the circle.

```auto
const circle = new Cesium.CircleGeometry({
  center: startPosition,
  radius: 100,
});

const primitive = new Cesium.Primitive({
  appearance: new Cesium.MaterialAppearance({
	material: Cesium.Material.fromType("Color"),
	faceForward: true,
	renderState: {
	  depthTest: {
		enabled: false,
	  },
	},
  }),
  geometryInstances: new Cesium.GeometryInstance({
	geometry: circle,
  }),
  asynchronous: false,
});

primitiveCollection.add(primitive);

```

to

```auto
function computeCirclePoints(center, radius) {
    let pnts = [];
    let cep = Cesium.EllipseGeometryLibrary.computeEllipsePositions({
            center: center,
            semiMajorAxis: radius,
            semiMinorAxis: radius,
            rotation: 0,
            granularity: 0.005
        },
        false,
        true
    );
    if (cep && cep.outerPositions) {
        pnts = Cesium.Cartesian3.unpackArray(cep.outerPositions);
    }
    return pnts;
}

var pnts = computeCirclePoints(startPosition, 100);
pnts.push(pnts[0]);

var entity = new Cesium.Entity({
    polygon: {
        material: Cesium.Color.YELLOW.withAlpha(0.6),
        fill: true,
        hierarchy: {
            positions: pnts
        }
    }
});

viewer.entities.add(entity);

```

---

<div class="post-metadata">

**Author:** ![sam.rothstein](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/sam.rothstein/32/6584_2.png) [@sam.rothstein](https://community.cesium.com/u/sam.rothstein)\
**Post date:** [September 1, 2021, 2:06pm UTC](https://community.cesium.com/t/question-about-disabledepthtestdistance-of-pointprimitive/15071/7 "2021-09-01T14:06:08Z")

</div>

@IKangXu

Thank you for jumping in and helping out @zouyaoji 🚀 😃 Your engagement means a lot to the community!

-Sam

---

<div class="post-metadata">

**Author:** ![zouyaoji](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/zouyaoji/32/2246_2.png) [@zouyaoji](https://community.cesium.com/u/zouyaoji)\
**Post date:** [September 1, 2021, 4:37pm UTC](https://community.cesium.com/t/question-about-disabledepthtestdistance-of-pointprimitive/15071/8 "2021-09-01T16:37:31Z")

</div>

Thanks to @IKangXu , but the problem is still not solved.

Do you have a solution? @sam.rothstein

I want to use Primitive API instead of Entity API.

In my case, how can I pick up the PointPrimitive covered by CircleGeometry. Or how to make PointPrimitive at the top. When I set disableDepthTestDistance of PointPrimitive to Number.POSITIVE\_INFINITY, PointPrimitive is still not at the top level. Can this be considered a BUG?

---

<div class="post-metadata">

**Author:** ![IKangXu](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/ikangxu/32/6169_2.png) [@IKangXu](https://community.cesium.com/u/IKangXu)\
**Post date:** [September 2, 2021, 6:55am UTC](https://community.cesium.com/t/question-about-disabledepthtestdistance-of-pointprimitive/15071/9 "2021-09-02T06:55:40Z")

</div>

@zouyaoji

The method of using primitive has been solved.

The method is as follows:

Set the draw primitive object  
`pass = Cesium.Pass.OPAQUE` and `blending: Cesium.BlendingState.ALPHA_BLEND`

In fact, it is to adjust the order of Primitive rendering to before PointPrimitive

```auto
const primitive = new Cesium.Primitive({
  appearance: new Cesium.MaterialAppearance({
	material: Cesium.Material.fromType("Color"),
	faceForward: true,
	renderState: {
	  depthTest: {
		enabled: false,
	  },
	},
  }),
  geometryInstances: new Cesium.GeometryInstance({
	geometry: circle,
  }),
  asynchronous: false,
});

primitiveCollection.add(primitive);

const primitive = new Cesium.Primitive({
  appearance: new Cesium.MaterialAppearance({
	material: Cesium.Material.fromType("Color"),
	faceForward: true,
	renderState: {
	  depthTest: {
		enabled: false,
	  },
	},
  }),
  geometryInstances: new Cesium.GeometryInstance({
	geometry: circle,
  }),
  asynchronous: false,
});

primitiveCollection.add(primitive);

var originalPrimitiveUpdate = primitive.update;
        
primitive.update = function (frameState) {
  const originalLength = frameState.commandList.length;
  originalPrimitiveUpdate.call(this, frameState);
  const endLength = frameState.commandList.length;
  for (let i = originalLength; i < endLength; ++i) {
	 frameState.commandList[i].pass = Cesium.Pass.OPAQUE;
		frameState.commandList[i].renderState = Cesium.RenderState.fromCache({
			depthTest: {
				enabled: false
			},
			depthMask: false,
			blending: Cesium.BlendingState.ALPHA_BLEND
		});
	}
};

```

---

<div class="post-metadata">

**Author:** ![zouyaoji](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/zouyaoji/32/2246_2.png) [@zouyaoji](https://community.cesium.com/u/zouyaoji)\
**Post date:** [September 2, 2021, 7:08am UTC](https://community.cesium.com/t/question-about-disabledepthtestdistance-of-pointprimitive/15071/10 "2021-09-02T07:08:21Z")

</div>

@IKangXu  
It’s solved perfectly. Thank you for your contribution and sharing.

---

<div class="post-metadata">

**Author:** ![sam.rothstein](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/sam.rothstein/32/6584_2.png) [@sam.rothstein](https://community.cesium.com/u/sam.rothstein)\
**Post date:** [September 2, 2021, 3:06pm UTC](https://community.cesium.com/t/question-about-disabledepthtestdistance-of-pointprimitive/15071/11 "2021-09-02T15:06:34Z")

</div>

@IKangXu

Thank you very much for your input 🚀 😀

-Sam

---

<div class="post-metadata">

**Author:** ![IKangXu](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/ikangxu/32/6169_2.png) [@IKangXu](https://community.cesium.com/u/IKangXu)\
**Post date:** [September 3, 2021, 1:21am UTC](https://community.cesium.com/t/question-about-disabledepthtestdistance-of-pointprimitive/15071/12 "2021-09-03T01:21:43Z")

</div>

If you use GroundPrimitive, The following effects occur

![image](https://global.discourse-cdn.com/cesium/original/2X/d/d3c6707af241a49c8166a4aa0432de83cee662d2.jpeg)

The reason for this phenomenon is GroundPrimitive  
the order of rendering itself takes precedence over `Cesium.Pass.TRANSLUCENT`

Therefore, there is no need to adjust the rendering order accordingly.

```auto
primitive.update = function (frameState) {
	const originalLength = frameState.commandList.length;
	originalPrimitiveUpdate.call(this, frameState);
	const endLength = frameState.commandList.length;
	for (let i = originalLength; i < endLength; ++i) {
		if(frameState.commandList[i].pass !== Cesium.Pass.TRANSLUCENT) {
			continue;
		}
		frameState.commandList[i].pass = Cesium.Pass.OPAQUE;
		frameState.commandList[i].renderState = Cesium.RenderState.fromCache({
			depthTest: {
				enabled: false
			},
			depthMask: false,
			blending: Cesium.BlendingState.ALPHA_BLEND
		});
	}
};

```
