CesiumGS / CesiumGS/cesium

Primitive outline z-fighting issue

Open
#2,333 1 comment 0 reactions 0 assignees View on GitHub
category - graphics type - bug
Dominant language
JavaScript
Stars
15.7k
Forks
3.9k
Avg merge
4d 6h
Merged PRs (30d)
34

Description

There's some sort of z-fighting translucency issues going on with Primitives that I can easily reproduce but have no idea what the problem is. Using the `entity-corridor` branch, paste the below code into Sandcastle. Zoom in slightly and middle mouse rotate so you can look at Texas from the south-west side. You'll hit a zone where the outline seems to disappear, but if you look closely it's still being drawn but seemingly overwritten by the geometry. I've confirmed with the inspector that this is not a bounding sphere or culling issue.

```
var viewer = new Cesium.Viewer('cesiumContainer');
Cesium.viewerEntityMixin(viewer);
Cesium.viewerCesiumInspectorMixin(viewer);

//Seed the random number generator for repeatable results.
Cesium.Math.setRandomNumberSeed(0);

//Create a new GeoJSON data source and add it to the list.
var dataSource = new Cesium.GeoJsonDataSource();
viewer.dataSources.add(dataSource);

//Load the document into the data source and then set custom graphics
dataSource.loadUrl('../../SampleData/ne_10m_us_states.topojson').then(function() {
//Get the array of entities
var entities = dataSource.entities.entities;

var colorHash = {};
for (var i = 0; i < entities.length; i++) {
//For each entity, create a random color based on the state name.
//Some states have multiple entities, so we store the color in a
//hash so that we use the same color for the entire state.
var entity = entities[i];
var name = entity.name;
var color = colorHash[name];
if (!color) {
color = Cesium.Color.fromRandom({
alpha : 0.9
});
colorHash[name] = color;
}

//Extrude the polygon based on the state's population. Each entity
//stores the properties for the GeoJSON feature it was created from
//Since the population is a huge number, we divide by 50.
entity.corridor = new Cesium.CorridorGraphics();
entity.corridor.positions = entity.polygon.positions;
entity.corridor.outline = new Cesium.ConstantProperty(true);
entity.corridor.outlineColor = new Cesium.ConstantProperty(Cesium.Color.BLACK);
entity.corridor.material = Cesium.ColorMaterialProperty.fromColor(color);
entity.corridor.width = new Cesium.ConstantProperty(50000);
entity.corridor.fill = new Cesium.ConstantProperty(true);
entity.corridor.extrudedHeight = new Cesium.ConstantProperty(entity.properties.Population / 50.0);

entity.polygon = undefined;
}
});

//Set the camera to a US centered tilted view.
var camera = viewer.scene.camera;
camera.lookAt(Cesium.Cartesian3.fromDegrees(-98, 15.0, 5000000),
Cesium.Cartesian3.fromDegrees(-98, 40.0, 0), Cesium.Cartesian3.UNIT_Z);
```

![image](https://cloud.githubusercontent.com/assets/1495196/5495813/0413e68e-86cf-11e4-95fa-768eb44408ac.png)

![image](https://cloud.githubusercontent.com/assets/1495196/5495819/146acbe2-86cf-11e4-8ad1-cf819f7fb383.png)

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue in Sandcastle using the entity-corridor branch and the supplied CorridorGraphics example, then inspect the scene with the Cesium inspector. Focus on the translucent primitive outline while rotating into the south-west Texas view. Done means the outline remains visible instead of appearing overwritten by the geometry.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.