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

Z-Ordering of entity collection #4108

Open
tfili opened this issue Jul 12, 2016 · 47 comments
Open

Z-Ordering of entity collection #4108

tfili opened this issue Jul 12, 2016 · 47 comments

Comments

@tfili
Copy link
Contributor

tfili commented Jul 12, 2016

It would be nice to be able to change the render order of entities. Right now we have to tweak the eyeOffset which needs to change based on camera distance.

@hpinkos
Copy link
Contributor

hpinkos commented Dec 7, 2016

This is probably one of the most frequently requested things on the forum.
Also requested in #53

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 2, 2017

CC #3647

@shunter
Copy link
Contributor

shunter commented Jan 2, 2017

@hpinkos
Copy link
Contributor

hpinkos commented Jan 18, 2017

Related: #4878 #4695

@hpinkos
Copy link
Contributor

hpinkos commented Feb 8, 2017

@smills2929
Copy link

+1. I'd love to see this!

@hpinkos
Copy link
Contributor

hpinkos commented Mar 16, 2017

@hpinkos hpinkos mentioned this issue Apr 11, 2017
@emackey
Copy link
Contributor

emackey commented May 4, 2017

Thinking about a possible implementation for billboards: https://groups.google.com/d/msg/cesium-dev/7CHDGRyJvwc/S55fUJ8XCAAJ

@schitzN
Copy link

schitzN commented Jan 9, 2018

push

Seems like this is still an issue. We have the same problem with labels drawn underneath polylines.

@hpinkos
Copy link
Contributor

hpinkos commented Jan 9, 2018

Hi @schitzN, this hasn't been addressed yet. But stay tuned! We're starting work on this in the next month

@ggetz
Copy link
Contributor

ggetz commented May 2, 2018

@hpinkos Will these changes also apply to billboard/lablel/polyline collections?

See on the forum: https://groups.google.com/forum/#!topic/cesium-dev/ywyFR5GSi_c

@hpinkos
Copy link
Contributor

hpinkos commented May 4, 2018

@ggetz the changes I'm working on this round are specifically to address z-ordering in 3D, so I won't be making changes to billboards/labels because they are ordered spatially by their 3D position. We will have support for ordering polylines on the earth surface.

@erezy
Copy link

erezy commented May 6, 2018

@ggetz Thanks!
@hpinkos changing the order of the primitives collections in 2D worked in the past (V 1.21)
I don't know why it stopped working.
Do you know when the issue will be resolved?

@hpinkos
Copy link
Contributor

hpinkos commented May 7, 2018

Thanks @erezy, I didn't realize this was a regression. I've opened a separate issue so we can look into fixing it: #6569

@eatjhuapl
Copy link

Will these changes also apply to rendering GeoJsonDataSource ?

@hpinkos
Copy link
Contributor

hpinkos commented Jun 18, 2018

@eatapl we haven't hooked this up to GeoJson because I couldn't find anything in the GeoJSON spec that can be used to specify polygon ordering. Does GeoJSON have a property used for ordering that I missed? Thanks!

@killroy42
Copy link

Is there a workaround currently for at least drawing polylines below billboards? I'm implementing my own z-ordering where I can, but I don't know how to interact with the render pipeline for the parts of a single entity.

@hpinkos
Copy link
Contributor

hpinkos commented Mar 29, 2019

@ladislavhorky Could you put together a Sandcastle example to reproduce that?

@ladislavhorky
Copy link

@hpinkos here it is. You only need to turn it a bit to get some label in the town square to cross transparent polyline.

@hpinkos
Copy link
Contributor

hpinkos commented Mar 29, 2019

@ladislavhorky The lines are drawing on top of the labels because you set a depthFailMaterial. That is working as designed. The depthFailMaterial colors the line when it fails the depth test, so it will always draw on top of the label when the label is in front of the line spatially. The lines look like they are rendering below the labels if I remove depthFailMaterial

@ladislavhorky
Copy link

@hpinkos I see, that makes sense. But then, is there some way to make the polylines visible through the terrain/3D tiles without setting depthFailMaterial and thus interfering with labels? Like maybe splitting labels and lines into separate datasources? The intended behavior is to make both labels and lines visible through the mesh with correct z-ordering much like in Zpeugh's example.

My best workaround so far is to use distanceDisplayCondition for labels to minimize the crosses and some transparency for polylines to make the crosses less visible.

@hpinkos
Copy link
Contributor

hpinkos commented Apr 1, 2019

I'm sorry @ladislavhorky, I don't have any workaround at this time

@ladislavhorky
Copy link

@hpinkos Thanks for your time anyway. I'll do with the transparency for now.

@Maarondesigns
Copy link

Was there ever a resolution found for this issue? I am getting different behavior depending on the alpha channel of polygon material as well. If the material has any transparency, the labels appear behind. If alpha is 1.0, label appears in front, but always behind polylines (GeoJsonDataSource stroke). See image on the left, green color has 1.0 alpha while other colors have less.

Also, in an unrelated issue, the individual letters of label text appear wonky/not-aligned if the text is smaller than about 17px (right image)

image

@jony89
Copy link
Contributor

jony89 commented Dec 5, 2019

@hpinkos , what is the roadmap regard this feature?

it is extremely needed, and it seems there is no workaround at the moment?

@OmarShehata
Copy link
Contributor

@Maarondesigns thanks for pointing these out. These are potentially separate issues. The small font issue seems to have been working as of CesiumJS 1.62. I opened an issue for this here: #8474

For the outline ordering issue, I'm unable to reproduce this. Here's the Sandcastle I tried. You can toggle the material alpha = 1 vs alpha = 0.8 with the buttons. It seems that the stroke is always on top regardless. Are you able to share a Sandcastle example that reproduces it?

@jony89 there may be a workaround depending on what exactly you're trying to achieve. Feel free to open a Cesium forum discussion thread describing your use case.

@Maarondesigns
Copy link

I've circled back to this issue on a separate project. It seems like polylines render randomly above or below polygons and corridors with alpha less than 1.0. I am creating everything using the Primitive API. The project is my own version of the game RISK if you're interested: github

//country fill
let polygonPrimitive = new Cesium.Primitive({
        show: dontShow ? false : true,
        releaseGeometryInstances: false,
        geometryInstances: new Cesium.GeometryInstance({
          id: id + "_polygon",
          geometry: Cesium.PolygonGeometry.createGeometry(
            new Cesium.PolygonGeometry({
              polygonHierarchy: cartesian,
              height
            })
          )
        }),
        appearance: new Cesium.MaterialAppearance({
          material: new Cesium.Material.fromType("Color", {
            color: new Cesium.Color(
              fillColor[0],
              fillColor[1],
              fillColor[2],
              fillOpacity
            )
          })
        }),
        asynchronous: false
      });
//country border
let corridorPrimitive = new Cesium.Primitive({
          show: dontShow ? false : true,
          releaseGeometryInstances: false,
          geometryInstances: new Cesium.GeometryInstance({
            id: cid,
            geometry: Cesium.CorridorGeometry.createGeometry(
              new Cesium.CorridorGeometry({
                positions: p,
                width: 8000,
                extrudedHeight: height + 10000
              })
            )
          }),
          appearance: new Cesium.MaterialAppearance({
            material: new Cesium.Material.fromType("Color", {
              color: new Cesium.Color(
                strokeColor[0],
                strokeColor[1],
                strokeColor[2],
                strokeOpacity
              )
            })
          }),
          asynchronous: false
        });
//path
let path = new Cesium.Primitive({
      releaseGeometryInstances: false,
      geometryInstances: new Cesium.GeometryInstance({
        id: id?id:"path",
        geometry: Cesium.PolylineGeometry.createGeometry(
          new Cesium.PolylineGeometry({
            positions,
            width
          })
        )
      }),
      appearance: new Cesium.PolylineMaterialAppearance({
        material: new Cesium.Material.fromType("PolylineDash", {
          color
        })
      }),
      asynchronous: false
    });

Changing the camera angle makes the dashed polyline pop in front of or behind the countries. Same behavior when corridor alpha<1.0. In image below corridor alpha is 1.0.
image

@Maarondesigns
Copy link

Maarondesigns commented Mar 4, 2020

@Maarondesigns thanks for pointing these out. These are potentially separate issues. The small font issue seems to have been working as of CesiumJS 1.62. I opened an issue for this here: #8474

For the outline ordering issue, I'm unable to reproduce this. Here's the Sandcastle I tried. You can toggle the material alpha = 1 vs alpha = 0.8 with the buttons. It seems that the stroke is always on top regardless. Are you able to share a Sandcastle example that reproduces it?

@jony89 there may be a workaround depending on what exactly you're trying to achieve. Feel free to open a Cesium forum discussion thread describing your use case.

I was able to reproduce in your sandcastle...This issue occurs when the polygon has extrudedHeight and then eyeOffset is used on the label to appear in front of it. SandCastle

It also occurs when you use a billboard with image: [ html canvas ], which I started doing to fix the alignment issue of the letters.

@dzungpng
Copy link
Contributor

dzungpng commented Nov 4, 2020

@aldenpoole
Copy link

aldenpoole commented Jul 29, 2022

Is there still no good fix for this? Even setting an eyeOffset z value is a subpar solution. I am having such trouble getting my label entities to appear over my arcs. The arcs vary in height, and some of them get very high.

I should say - the labels are for other entities on the map and not related to the arcs at all.

Can there not be a flag to treat these label entities as such so that they are just rendered above everything else, regardless of height?

@ggetz
Copy link
Contributor

ggetz commented Oct 19, 2022

Requested in #10861

@ggetz
Copy link
Contributor

ggetz commented Feb 21, 2023

Also reported in #11097 and #11074.

@ggetz ggetz closed this as completed Feb 21, 2023
@ggetz ggetz reopened this Feb 21, 2023
@ggetz
Copy link
Contributor

ggetz commented Apr 11, 2024

Also reported in #11925.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Notable backlog items
Development

No branches or pull requests