question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Entity position doesn't apply to polygons

See original GitHub issue

This seems like such a fundamental thing that it must be an intended behavior, but I’m bringing it up here because I feel like it’s confusing and I haven’t found any issues discussing it.

Let’s say you have a polygon entity:

var redPolygon = viewer.entities.add({
    polygon : {
        hierarchy : Cesium.Cartesian3.fromDegreesArray([-115.0, 37.0,
                                                        -115.0, 32.0,
                                                        -107.0, 33.0,
                                                        -102.0, 31.0,
                                                        -102.0, 35.0]),
        material : Cesium.Color.RED
    }
});

Looks great. Let’s say you wanted to move it just slightly, so you define a position offset:

var redPolygon = viewer.entities.add({
    position : new Cesium.Cartesian3(100, 0, 0),
    polygon : {
        hierarchy : Cesium.Cartesian3.fromDegreesArray([-115.0, 37.0,
                                                        -115.0, 32.0,
                                                        -107.0, 33.0,
                                                        -102.0, 31.0,
                                                        -102.0, 35.0]),
        material : Cesium.Color.RED
    }
});

This has no effect. This is confusing because the docs imply that this is the position of the entity, so the fact that it doesn’t change anything is strange. This seems to be the case with other geometry types but not with models.

Of course it’s possible to just offset every positions in polygon.hierarchy, but this seems like an inconsistent API. Why is position a property of the entity if it only applies to model ?

The fact that entities don’t have a model matrix makes it so that there’s no easy way to apply offsets like this. This came up while I was trying to show that classification entities can be dynamic, and with invert classification you could do a cool thing where you can have a moving mask over your tileset. So it would have been nice to be able to just specify a position and move that rectangle anywhere.

I know this would be kind of a big API change, but at the very least something in the docs should say that entity.position doesn’t apply to all geometry types.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
hpinkoscommented, Oct 23, 2018

@OmarShehata position applies to certain entity types like labels, billboards, models, ellipses, pretty much any entity type that has a singular position. It does not apply to geometry types with multiple positions like polygons, polylines and walls. I think we should just clarify the documentation, I don’t think this is a change we would want to make in the near future. Applying a modelMatrix to a geometry type that is intended to curve to the surface of the globe does not have good results. The best way to move the polygon would be to make the hierarchy a dynamic property and recalculate the position values.

0reactions
ezriYerushalmicommented, Nov 6, 2018

Works great thank you all! @OmarShehata @hpinkos

Read more comments on GitHub >

github_iconTop Results From Across the Web

Entity position doesn't apply to polygons · Issue #7180 - GitHub
It does not apply to geometry types with multiple positions like polygons, polylines and walls. I think we should just clarify the documentation ......
Read more >
Polygon shape callback property error (outerpositions ...
Hi, I'm currently just trying to get a polygon to update after being drawn by ... The example here Entity position doesn't apply...
Read more >
Why are my polygons being drawn in the wrong location?
Using ActualWidth or ActualHeight instead of simply Height or Width causes it to not draw anything. I assumed it would be because my...
Read more >
Polygon anchor point(center point) - Google Groups
Hello. I am working with geojson data and load data with using. Cesium.GeoJsonDataSource(). I access entities and they are Polygon.
Read more >
Bing map polygons are not returned properly for ISO country ...
var geoDataRequestOptions = {entityType: type,getAllPolygons: true, ... Location(dataBounds.center.latitude, dataBounds.center.longitude);
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found