Coder Social home page Coder Social logo

Comments (12)

sraimund avatar sraimund commented on May 16, 2024 2

I landed on this issue coming from outlineWidth property of the PolygonGraphics docs. Based on the suggested workaround of @thw0rted, here the code for converting polygons into polylines with outline:

const dataSource = await Cesium.GeoJsonDataSource.load("polygons.geojson");

for (const entity of dataSource.entities.values) {
    entity.polyline = new Cesium.PolylineGraphics();
    entity.polyline.positions = entity.polygon.hierarchy.getValue().positions;
    entity.polygon = undefined;
    
    entity.polyline.width = 3;
    entity.polyline.material = new Cesium.PolylineOutlineMaterialProperty({
        color: Cesium.Color.WHITE,
        outlineWidth: 2,
        outlineColor: Cesium.Color.BLACK
    });
}

viewer.dataSources.add(dataSource); 

An exemplary use case would be to style borders of administrative units (given as polygons).

from cesium.

s3xysteak avatar s3xysteak commented on May 16, 2024 2

Now I have a possibly good way before an official solution emerges, here is the code:

// Assuming the existence of a DataSource which is a geojson about polygon
const entities = dataSource.entities.values
entities.forEach(entity => {
  entity.polygon.width = 4
  entity.polygon.material = Cesium.Color.fromCssColorString('#FF5500')

  entity.polyline = new Cesium.PolylineGraphics({
    positions: entity.polygon.hierarchy.getValue().positions,
    width: 2,
    material: Cesium.Color.BLACK
  })
  
})

That looks like a outline of the polygon.

from cesium.

kristiancalhoun avatar kristiancalhoun commented on May 16, 2024

Hi Jonah,

Are you running Chrome with ANGLE enabled? You can check http://analyticalgraphicsinc.github.com/webglreport/ to find out. If so, then the maximum aliased line width is 1 and the polyline outline will not show up. You can disable ANGLE in Chrome using the --use-gl=desktop flag. The Sandbox example you mention displays correctly for me in Chrome without ANGLE and in Firefox 12.0.

If the width is still not changing, make sure you're using a valid value. Within Cesium, you can use the Context.getMinimumAliasedLineWidth and Context.getMaximumAliasedLineWidth functions to find the range.

Hope this helps,

-Kristian

from cesium.

mramato avatar mramato commented on May 16, 2024

Kristian hit the nail on the head, but in case you're unfamiliar with ANGLE, you can read more about it here: http://code.google.com/p/angleproject/

Both Chrome and Firefox use ANGLE by default on Windows and render with DirectX under-the-hood. There is actually a bug opened for ANGLE with this particular issue: http://code.google.com/p/angleproject/issues/detail?id=119

from cesium.

djone010 avatar djone010 commented on May 16, 2024

Thanks for all the information and quick response. When I turn off angle though, I get this browser does not support WebGL.

from cesium.

mramato avatar mramato commented on May 16, 2024

There's a good reason they use ANGLE, OpenGL is not supported very well on a wide variety of video cards. One thing you can try is to upgrade your video card drivers. Some drivers are explicitly black-listed by Firefox and Chrome. If that doesn't fix it, then it's likely you need ANGLE in order for WebGL to work on your particular machine. Hopefully ANGLE will fix the line width issues in a future release.

from cesium.

MarchChadwick avatar MarchChadwick commented on May 16, 2024

Would love to change the outlineWidth property. No luck as yet.

from cesium.

GatorScott avatar GatorScott commented on May 16, 2024

The ANGLE project declared in 2014 that they would not be implementing wide lines. Having said that, wide outlines are working for me on Windows 10 in

  • Chrome 62.0.3202.62, ANGLE (NVIDIA Quadro M1000M Direct3D11 vs_5_0 ps_5_0)
  • Firefox 56.0, ANGLE (NVIDIA Quadro M1000M Direct3D11 vs_5_0 ps_5_0)
  • Edge 40.15063.674.0, Intel(R) HD Graphics 530
  • Internet Explorer 11.674.15063.0, NVIDIA Quadro M100M

What configuration is failing for you? I used webglreport.com to obtain the Unmasked Renderer shown above.

from cesium.

MarchChadwick avatar MarchChadwick commented on May 16, 2024

Hello GatorScott and thank you for response. I am using Chrome with a Macbook pro. Following PolylineOutlineMaterialProperty https://cesiumjs.org/Cesium/Build/Documentation/PolylineOutlineMaterialProperty.html in the Cesium sandbox https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Polygon.html&label=undefined produces no change in outline thickness for me.

from cesium.

hpinkos avatar hpinkos commented on May 16, 2024

@MarchChadwick support for outlineWidth is dependent on your OS and your graphics card. If the value of scene.maximumAliasedLineWidth is 1, then your machine only supports 1px width geometry outlines. See more information here: https://stackoverflow.com/questions/25394677/how-do-you-change-the-width-on-an-ellipseoutlinegeometry-in-cesium-map/25405483#25405483

In the future, please ask questions like this on the forum: https://groups.google.com/forum/?hl=en#!forum/cesium-dev
We use GitHub exclusively for bug tracking and planning new features, and we might miss your question if you comment on a closed issue like this. Thanks!

from cesium.

thw0rted avatar thw0rted commented on May 16, 2024

Since the docs are now going to link to this issue, I'll make a suggestion here for future readers. If you're trying to make a filled shape with a thick outline, and can easily express that outline as an array of points (say, a PolygonGraphics or EllipseGraphics), it's pretty simple to add a PolylineGraphics to your entity instead of using the built-in outline property on your 2D shape. Hopefully at some point in the future this won't be necessary, but for now this ensures a consistent appearance on any platform.

from cesium.

mzlan avatar mzlan commented on May 16, 2024

Hi,I set the browser angel default as opengl and box outlineWidth working。

var outlineOnly = viewer.entities.add({
name: "Yellow box outline",
position: Cesium.Cartesian3.fromDegrees(-100.0, 40.0, 300000.0),
box: {
dimensions: new Cesium.Cartesian3(400000.0, 300000.0, 500000.0),
fill: false,
outline: true,
outlineColor: Cesium.Color.YELLOW,
outlineWidth:2,
},
});

from cesium.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.