Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corridor renders from Primitive API but not Entity API #4829

Open
hpinkos opened this issue Jan 9, 2017 · 7 comments
Open

Corridor renders from Primitive API but not Entity API #4829

hpinkos opened this issue Jan 9, 2017 · 7 comments
Labels

Comments

@hpinkos
Copy link
Contributor

hpinkos commented Jan 9, 2017

From #4326

This corridor renders:

var viewer = new Cesium.Viewer('cesiumContainer');
var scene = viewer.scene;

var redCorridorInstance = new Cesium.GeometryInstance({
    geometry: new Cesium.CorridorGeometry({
        positions : Cesium.Cartesian3.fromDegreesArray([
            -16.41549000000001,28.44423000000001,
            -16.41549000000001,28.44423000000001,
            -16.41505000000001,28.44430000000001,
            -16.41507000000001,28.44430000000001,
            -16.41473000000001,28.44460000000001,
            -16.41429000000001,28.44452000000001,
            -16.41430000000001,28.44453000000001,
            -16.41428000000001,28.44452000000001,
            -16.41416000000001,28.44434000000001,
            -16.41415000000001,28.44434000000001,
            -16.41397000000001,28.44408000000001
        ]),
        width : 1,
        vertexFormat : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT
    }),
    attributes : {
        color : Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 0.0, 0.0, 0.5))
    }
});

var primitive = scene.groundPrimitives.add(new Cesium.GroundPrimitive({
    geometryInstances: [redCorridorInstance],
    appearance: new Cesium.PerInstanceColorAppearance({
        closed: true
    })
}));

scene.camera.setView({
    destination: Cesium.Cartesian3.fromDegrees(-16.41549000000001, 28.44423000000001, 100)
});

But this one doesn't

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

var redCorridor = viewer.entities.add({
    name : 'Red corridor on surface with rounded corners and outline',
    corridor : {
        positions : Cesium.Cartesian3.fromDegreesArray([
            -16.41549000000001,28.44423000000001,
            -16.41549000000001,28.44423000000001,
            -16.41505000000001,28.44430000000001,
            -16.41507000000001,28.44430000000001,
            -16.41473000000001,28.44460000000001,
            -16.41429000000001,28.44452000000001,
            -16.41430000000001,28.44453000000001,
            -16.41428000000001,28.44452000000001,
            -16.41416000000001,28.44434000000001,
            -16.41415000000001,28.44434000000001,
            -16.41397000000001,28.44408000000001
        ]),
        width : 1,
        material : Cesium.Color.RED.withAlpha(0.5),
        outline : true,
        outlineColor : Cesium.Color.RED
    }
});

viewer.zoomTo(viewer.entities);
@hpinkos
Copy link
Contributor Author

hpinkos commented Jan 9, 2017

Related forum posts:
https://groups.google.com/forum/?hl=en#!topic/cesium-dev/9wvnNNQcLTA
https://groups.google.com/forum/?hl=en#!topic/cesium-dev/7h3W_ICb4wM

Another example:

positions : Cesium.Cartesian3.fromDegreesArray([
    43.0298791905732,30.3249511347621,
    43.0535143723772,30.3254863499896,
    43.0531351413855,30.217161279318,
    43.0300902644761,30.2171721034287,
    43.0298791905732,30.3249511347621
]),

@hpinkos
Copy link
Contributor Author

hpinkos commented Jan 9, 2017

From @mramato

If someone wants to look at this, the geometry for the Corridor is created in CorridorGeometryUpdater.createFillGeometryInstance and then it's used in StaticGroundGeometryColorBrach in the createPrimitive block around line 86. There's probably an unrelated bug specific to CorridorGeometry in the Entity API.

@pjcozzi pjcozzi added good first issue An opportunity for first time contributors category - entity labels Jun 14, 2017
@CHBaker
Copy link

CHBaker commented Dec 20, 2017

I think I am having the same issue, but with polylines. I get the z-fighting you referenced in the related issue. Is there a fix for this yet?

I have an example on the sandcastle running this code:

var viewer = new Cesium.Viewer('cesiumContainer', { infoBox : false });
var entities = viewer.entities;

entities.add({
     polyline : {
        positions : Cesium.Cartesian3.fromDegreesArray([-111.0, 40.0,
                                                        -95.0, 40.0]),
        width : 3,
        material : Cesium.Color.RED,
        heightReference : Cesium.HeightReference.CLAMP_TO_GROUND
    }
    });
viewer.zoomTo(viewer.entities);

@hpinkos
Copy link
Contributor Author

hpinkos commented Dec 21, 2017

Hi @CHBaker. Polylines don't have a heightReference property and do not support being clamped to terrain. They will curve to fit the ellipsoid automatically though.

@CHBaker
Copy link

CHBaker commented Dec 21, 2017

@hpinkos hmmm. I saw some posts about adding this feature in 2015, guess it never got added. The problem I have is two polylines crossing at a perfetc '+' sign, but when you zoom in one is floating above the other, so when you ctrl + click to move perspective the lines move a lot and do not lay directly on top of each other.

This only occurs once you zoom in very close, they lay directly on top of each other, but once cesium renders as close as you can get, they don't appear on top of each other

@hpinkos
Copy link
Contributor Author

hpinkos commented Dec 21, 2017

@CHBaker try changing the value of the granularity attribute. This is a value in radians that specifies the distance at which the line should be subdivided and pushed to the ellipsoid surface. Here's an illustration to show what I'm talking about:
image

For a really large number, the line will just cut through the ellipsoid. A smaller value will break the line up to better fit the curvature.

By default, it subdivides the line each degree (Math.PI/180 radians). A smaller value might work better for your case.

@CHBaker
Copy link

CHBaker commented Dec 21, 2017

Alright, I think that did it, thanks!

@ggetz ggetz removed their assignment Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants