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

Using Material with PolygonOutlineGeometry #2052

Closed
aramk opened this issue Aug 12, 2014 · 3 comments
Closed

Using Material with PolygonOutlineGeometry #2052

aramk opened this issue Aug 12, 2014 · 3 comments
Assignees

Comments

@aramk
Copy link

aramk commented Aug 12, 2014

In order to modify the color of polygon outlines, you can use the approach in the sandcastle which uses PerInstanceColorAppearance and then use:

var geometryAtts = primitive.getGeometryInstanceAttributes(geometry.id);
geometryAtts.color = ColorGeometryInstanceAttribute.toValue(fillColor);

The problem is that this needs Primitive#update() to be called before use, which I cannot guarantee. Using Material works fine for PolygonGeometry and you modify the color by setting it on appearance.material.uniforms.color. The same does not work for PolygonOutlineGeometry and I'm not sure why. Here is my construction code:

var outlineGeometry = new GeometryInstance({
  geometry: new PolygonOutlineGeometry({
    polygonHierarchy: polygonHierarchy,
    height: elevation,
    extrudedHeight: elevation + height,
    vertexFormat: VertexFormat.POSITION_AND_ST
  })
});

var outlineAppearance = new EllipsoidSurfaceAppearance({
  material: new Material({
    fabric: {
      type: 'Color',
      uniforms: {
        color: borderColor
      }
    },
    translucent: false
  })
});

var outlinePrimitive = new Primitive({
  geometryInstances: outlineGeometry,
  appearance: outlineAppearance
});

I get the following error:

DeveloperError: Appearance/Geometry mismatch. The appearance requires vertex shader attribute input 'st', which was not computed as part of the Geometry. Use the appearance's vertexFormat property when constructing the geometry.

I am setting the correct VertexFormat, so I'm not sure why it's failing.

@mramato
Copy link
Contributor

mramato commented Aug 12, 2014

Unfortunately, the only appearance supported by all outlined geometry is PerInstanceColorAppearance. I believe @bagnell looked into supporting other types at some point, but there were issues with making it look good (Polyline materials are incredibly complex, see the blog post about it here). He can keep me honest here and chime in with his thoughts

To work around the Primitve.update before use issue; you can wait for Primitive.ready to be true before executing your code. I thought we also added an event that gets fired; but that does not appear to be the case. I'll look into adding one for the next release.

@aramk
Copy link
Author

aramk commented Aug 12, 2014

Thanks for that clarification. I can probably use a wrapper method which waits on update with a while loop and maybe even uses a promise, and maybe a timeout of 5 seconds or so.

@pjcozzi pjcozzi self-assigned this Oct 6, 2014
@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 2, 2017

Duplicate with #2174. @aramk please reopen if there is another issue.

@pjcozzi pjcozzi closed this as completed Jan 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants