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

Height affecting ground primitive polygon rendering #11883

Open
r-edwards opened this issue Mar 15, 2024 · 2 comments
Open

Height affecting ground primitive polygon rendering #11883

r-edwards opened this issue Mar 15, 2024 · 2 comments

Comments

@r-edwards
Copy link

r-edwards commented Mar 15, 2024

What happened?

I'm currently creating a GroundPolylinePrimitive using GroundPolylineGeometry, as well as a GroundPrimitive that uses a PolygonGeometry to "fill" the polyline. I'm giving both the GroundPolylineGeometry and GroundPrimitive the same positions, however the polygon shape does not seem to match the polyline. See the attached screenshot:

Screenshot 2024-03-15 at 2 24 12 pm

I've previously worked from a fork of cesium at version 1.99.0 in which the positions of the polygon do correctly "fill" the polyline. For example here is a screenshot running locally of the same scenario as the linked sandbox but with cesium version 1.99:

Screenshot 2024-03-15 at 3 16 59 pm

Here's the code for this example running at cesium v1.99.0:

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

const cartographics = [
    {
      "longitude": -1.8402495415863134,
      "latitude": 0.7033934337801941,
      "height": 2177.974000000284
    },
    {
      "longitude": -1.8402506824369915,
      "latitude": 0.7033901872332414,
      "height": 2177.9740000000156
    },
    {
      "longitude": -1.840249836934684,
      "latitude": 0.703388112597783,
      "height": 2177.9739999988838
    },
    {
      "longitude": -1.8402478059109948,
      "latitude": 0.7033903665805613,
      "height": 2177.9739999987028
    },
    {
      "longitude": -1.840246112964614,
      "latitude": 0.7033920799454119,
      "height": 2177.9739999996555
    },
    {
      "longitude": -1.8402467855800173,
      "latitude": 0.7033933442953648,
      "height": 2177.9740000006414
    },
    {
      "longitude": -1.8402495415863134,
      "latitude": 0.7033934337801941,
      "height": 2177.974000000284
    }
  ];

const { WGS84 } = Cesium.Ellipsoid;

const positions = WGS84.cartographicArrayToCartesianArray(cartographics);

const c = Cesium.Color.fromCssColorString('#ffe566');

const polygonGeometryInstance = new Cesium.GeometryInstance({
    geometry: new Cesium.PolygonGeometry({
        polygonHierarchy: {
            positions,
        },
    }),    
    attributes: {
        color: new Cesium.ColorGeometryInstanceAttribute(
            c.red,
            c.green,
            c.blue,
        ),
    },
});

const polygonPrimitive = new Cesium.GroundPrimitive({
    geometryInstances: polygonGeometryInstance,
    appearance: new Cesium.PerInstanceColorAppearance({
        closed: true,
        translucent: true,
    }),
});

const lineGeometryInstance = new Cesium.GeometryInstance({
    geometry: new Cesium.GroundPolylineGeometry({
        positions,
        loop: false,
        width: 3.0,
    }),
});

const linePrimitive = new Cesium.GroundPolylinePrimitive({
    geometryInstances: [lineGeometryInstance],
    appearance: new Cesium.PolylineMaterialAppearance({
        material: Cesium.Material.fromType('Color', {
            color: c,
        }),
    }),
});

viewer.scene.primitives.add(polygonPrimitive);
viewer.scene.primitives.add(linePrimitive);

viewer.scene.camera.flyTo({destination: positions[0]});

Interestingly when using cartographics with zeroed height they seem to match up (note this sandbox).

How is height intended to affect a ground primitive? Is this a regression, or expected behaviour?

Reproduction steps

  1. Create a ground primitive using polygon geometry, and a ground polyline primitive using ground polyline geometry using the same positions in example sandbox/code snippet
  2. Note that they don't quite match up

...

Sandcastle example

https://sandcastle.cesium.com/#c=tVZbb5tIFP4ryPsQLLljYLgMrhNtZK26lbpqpVS7D3EeJjC2Rx0zaGZI5Eb+73vAYANx7FhqeYE55zuH71whkZk21hNnz0xZ11bGnq0Z07xYo38rmT0fJNV5JjNDecbUfDD8OM/mWVJZJlQZuVQ0X/FEg4P7eWbB9bK7WdZ8IGS25KZI2XwwsT64iPiO58eB7wYkxC72Ry0oNXukgyIH4xj7GEfEcWPfbQFXjC9XpoR5bhShOPKd6vKIvwNtR+/iETgh8XwcxrEbnObhuCTyMPZ8138HD8cNwouI+DEBFtgPyel8EOK6XhBHEcGnaOC4vAghmFxGA1IdxK4Txz45kw8chgGAQ/c9RCKozGVEQogzDuF2pj88JwKy0E1ufJ5HHAZBcCGPiAQQp+NG+EyjYt/34gCHncy91SAh9NGFDfK7J6a8PbQm+8X679Md8a0tTHW9Ev4Sguda8rQFy6XmhsMjwCoD1F4Jt0rRzXc5AxG4oFl1tjtL47BNpGBIyKW9d9lZNAcaMymkQgsl1zOtq8OdUTxb2ld/LBYsCMOrYYeg2Cxl9onJNTNq8xlkNEtYd9n1tXZdjmUtn7TB37oe7X3prOZlf3OmqEpWYNdS7gB1bKODvGmB7XBUFas6UAMxPRaQto6PpAy3w6ZKQJ//bWNtd1+fIMXSUV+2VIxlr6SPomAt4XB0aNjtkQR/U3wNoT31M6tkkaV7ZT+xDWGI8o1C1a+lec6oKgXdWjDVAKtE3O5h7bIkQmqWTiyjOiEZAGpRJCwzHd122I9RwJfvF3ZQnRQIuO2420iv+0RImU+sBRW6HcQzT81qYmHknGR/ujw1k/eU6f5YLh7OVKn2/w81THEqjldpXWsnjVkDr2b9+yZn9lVV5KtRf6zqsUjaUzU8ko/djw7SUHKG8iZajWia2v0+Li1O4TsJe73FOqYJXcNGOMJhp0ALAVvSfkmZNjyjZeEnhxa4dx5q+oPRYKrNRrCbJs4/+TqXyliFEjZCY8PWOXwTmB4/FskPZlCiqy1aQqfjtuk05U8WT6+P/N/BuFCtQbMohLjjP+HrcjMdA/6VqZA0hcX79YkpQTclbOXefNkJEULTMRyPWxopxSNVPc//Aw

Environment

Browser: Chrome 121.0.6167.160
CesiumJS Version: 1.115
Operating System: Mac OS 13.5

@ggetz
Copy link
Contributor

ggetz commented Mar 20, 2024

Hi @r-edwards, thanks for reporting this issue!

The 1.110 release included some significant changes to how we handle polygon rendering. This does appear to be a regression.

@n0rdlicht
Copy link

n0rdlicht commented May 28, 2024

@r-edwards thanks for reporting, I can second the behaviour change as we are seeing the same regression when we tested upgrading from 1.105 to 1.113 recently. In our testing it seems at least until 1.116 polygons behave as reported.

@ggetz is there an update on if this will be addressed or a possible workaround in the meantime? Many thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants