DistanceDisplayConditionGeometryInstanceAttribute with Polyline Primitive

Hello!

1. A concise explanation of the problem you’re experiencing.

I’m trying to get DistanceDisplayConditionGeometryInstanceAttribute to work with polyline arrow primitives to render a big amount of polyline arrows. This is not working as Cesium will throw a RuntimeError. I haven’t found any examples on how to do this and therefore I’m not sure if I’m using it wrong, it’s not supported, a bug etc.

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

The Sandcastle code below will throw some vertex shader compile error (“RuntimeError: Vertex shader failed to compile. Compile log: ERROR: 0:166: ‘assign’ : cannot convert from ‘highp 2-component vector of float’ to ‘Position highp 4-component vector of float’”):

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var arrowMaterialAppearance = new Cesium.PolylineMaterialAppearance(
{
material: Cesium.Material.fromType(
Cesium.Material.PolylineArrowType,
{
color: Cesium.Color.RED
}
),
translucent: false
}
);

var startPosition = Cesium.Cartesian3.fromDegrees(16, 46, 500);

var endPosition = Cesium.Cartesian3.fromDegrees(16.1, 46.1, 500);

var geometryInstance = new Cesium.GeometryInstance({
geometry: new Cesium.PolylineGeometry({
positions: [startPosition, endPosition],
width: 5
}),
attributes: {
show: new Cesium.DistanceDisplayConditionGeometryInstanceAttribute(
100.0,
10000.0
)
}
});

var primitive = viewer.scene.primitives.add(
new Cesium.Primitive({
geometryInstances: [geometryInstance],
appearance: arrowMaterialAppearance
})
);

var rectangle = Cesium.Rectangle.fromDegrees(15.9, 46.2, 16.2, 45.9);
viewer.camera.flyTo({
destination: rectangle
});

``

It’s caused by by these lines:

show: new Cesium.DistanceDisplayConditionGeometryInstanceAttribute(

100.0,

10000.0

)

If this is removed the polyline is rendered correct.

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

There are a lot of arrows to be rendered and not all should be shown at once - only when a user zooms into an area. I’m able to achieve this behavior by showing the polyline primitives based on the camera altitude. However, this is not optimal, e.g. when viewing at a flat angle arrows in the distance are also rendered.

4. The Cesium version you’re using, your operating system and browser.

Cesium 1.49.0

OS: macOS 10.13.6

Browsers: Chrome 69 / Safari 11.1.2

Looks like this is an error in our docs! The show attribute has to be called distanceDisplayCondition instead. That should resolve it.

I opened a PR to fix this in the docs (https://github.com/AnalyticalGraphicsInc/cesium/pull/7038). Thanks for pointing this out!

Thanks! This solves it.