Whether i can make mutilpolygon as one entity,such as building, so that i can highlight it as a whole.
such as
i want pick it and highlight as a whole, so how can i achieve the goal?
Whether i can make mutilpolygon as one entity,such as building, so that i can highlight it as a whole.
such as
i want pick it and highlight as a whole, so how can i achieve the goal?
The Entity API doesn’t have multipolygon support (while we might add it in the future it’s not on a near-term roadmap). If you are trying to create a tube similar to your image, you might want to try Polyline Volumes http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Polyline%20Volume.html&label=Geometries
In the soonish term, I would like to be able to add the ability to specify multiple entities that represent a single entity, but I don’t have an exact timeframe for that yet.
Hello Matt, is there a way to get the set of child entities from a parent entity? I need to do this same thing, though mine is a little weirder so I can't use something like polyline volumes. What I tried to do was create a parent entity, then add all of the other entities that make up my overall object, and set the parent entity on all of them. When I click on one of the entities, I then check if it has a parent, and if so, I grab that and use that for further processing. The thing is, I couldn't find a way to then get all of the other children from that parent entity. There are of course workarounds for that, such as creating a map data structure to associate the parent entity's id to a list of the child entities, etc, but is there a prettier way using Cesium directly?
Funny… I’m in need of this as well but not multipolygon, but multibillboards in one entities. =) lol
Looking forward to the future. Cesium, you guys are all doing a SUPERB job. Keep it up.
I use Primitive to get all the GeometryInstances. Each Geometry is a polygon. Code:
EntityPick.pickAndHighlight = function(viewer) {
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function(movement) {
var pickedObject = viewer.scene.pick(movement.position);
if (Cesium.defined(pickedObject)) {
var objs = pickedObject.primitive._pickIds;
for(var i=0;i<objs.length; i++){
var attributes = pickedObject.primitive.getGeometryInstanceAttributes(objs[i].object["id"]);
attributes.color = Cesium.ColorGeometryInstanceAttribute.toValue(Cesium.Color.YELLOW);
attributes.show = Cesium.ShowGeometryInstanceAttribute.toValue(true);
}
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
};
But after this, i has other problem, the primitive do not has the property(id), i can not set a unique id for the primitive, so i can not find primitive with a property, do you have solutions?
在 2015年4月16日星期四 UTC+8下午1:53:55,DB写道:
the primitive can combine multiple geometries。
在 2015年4月17日星期五 UTC+8上午1:21:26,Katone Vi写道:
you can use entity._children (a hiden property) to get all the children。
在 2015年4月16日星期四 UTC+8下午1:53:55,DB写道:
In general, you should not access _children
or any other property that starts with an underscore. They are private for a reason and your code will break in the future when we change those properties. We may expose the children in the near future, but I need to explore potential issues with it first.
So to answer your initial question, there’s no official way to start with the parent entity and get it’s children (other than iterating), but there might be soon.
We may also add an explicit multi-polygon ability for Entities, but it gets tricky fast. Another option I’m exploring is having a a “pickEntity” property on a given entity, which would indicate another entity to be the one that gets picked when the given entity is picked. This could allow for multiple entities to act as a single entity from an end users point of view. Long term we might have both solutions.