Entity position doesn't apply to polygons
See original GitHub issueThis 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:
- Created 5 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top GitHub Comments
@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 amodelMatrix
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.Works great thank you all! @OmarShehata @hpinkos