depthFailMaterial for dynamic polylines
See original GitHub issueThe new depthFailMaterial property currently only works for static polyline entities. This is because the PolylineGeometryUpdater uses a PolylineGeometry for static polylines and a PolylineCollection for dynamic ones. We’ll need to add depth fail material support to the PolylineCollection
var viewer = new Cesium.Viewer('cesiumContainer');
var cesiumTerrainProviderMeshes = new Cesium.CesiumTerrainProvider({
url : 'https://assets.agi.com/stk-terrain/v1/tilesets/world/tiles',
requestWaterMask : true,
requestVertexNormals : true
});
viewer.terrainProvider = cesiumTerrainProviderMeshes;
viewer.scene.globe.depthTestAgainstTerrain = true;
var length = 1000;
var startLon = Cesium.Math.toRadians(86.953793);
var endLon = Cesium.Math.toRadians(86.896497);
var lat = Cesium.Math.toRadians(27.988257);
var terrainSamplePositions = [];
for (var i = 0; i < length; ++i) {
var lon = Cesium.Math.lerp(endLon, startLon, i / (length - 1));
var position = new Cesium.Cartographic(lon, lat);
terrainSamplePositions.push(position);
}
var positions = [];
function getPositions() {
return positions;
}
viewer.entities.add({
polyline : {
positions : new Cesium.CallbackProperty(getPositions, false),
followSurface : false,
width : 5,
material : new Cesium.PolylineOutlineMaterialProperty({
color : Cesium.Color.ORANGE,
outlineWidth : 2,
outlineColor : Cesium.Color.BLACK
}),
depthFailMaterial : new Cesium.PolylineOutlineMaterialProperty({
color : Cesium.Color.RED,
outlineWidth : 2,
outlineColor : Cesium.Color.BLACK
})
}
});
Cesium.when(Cesium.sampleTerrainMostDetailed(viewer.terrainProvider, terrainSamplePositions), function(samples) {
var offset = 10.0;
for (var i = 0; i < samples.length; ++i) {
samples[i].height += offset;
}
positions = Cesium.Ellipsoid.WGS84.cartographicArrayToCartesianArray(samples);
var target = new Cesium.Cartesian3(300770.50872389384, 5634912.131394585, 2978152.2865545116);
offset = new Cesium.Cartesian3(6344.974098678562, -793.3419798081741, 2499.9508860763162);
viewer.camera.lookAt(target, offset);
viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
});
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (10 by maintainers)
Top Results From Across the Web
depthFailMaterial for dynamic polylines · Issue #5333 - GitHub
The new depthFailMaterial property currently only works for static polyline entities. This is because the PolylineGeometryUpdater uses a ...
Read more >Disable Depth Test For Polylines and Polygons
Hi Omar,. Unfortunately we are using dynamic polylines which depthFailMaterial does not support. I can see an open issue on GitHub #5333 so...
Read more >How to make polylines always visible - Cesium Community
Im drawing a polyline and it's not visible through building or terrain, is there a way to force it to always show no...
Read more >cesium/CHANGES.md - UNPKG
666, - Fixed a bug where dynamic polylines did not use the given arcType. ... for polyline entities with a dynamic color for...
Read more >Best and most performant implementation of dynamic shapes ...
I also tried using primitives. It worked great for polylines, I would simply remove the old one and add a new one with...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I was also trapped by this. Finally worked around by using primitive with depthTest (sub attribute of renderState) set to false. Example:
Then the update process is a remove-if-exists-then-add process:
If you want to update this primitive immediately (which happens to be my case), you should also set asynchronous to false.
Hi @WilliamLiu-1997, there aren’t any plans to work on this presently. But we’d be happy to review a pull request if you’d be interested in adding the feature yourself!