-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Entity ease of use #2315
Entity ease of use #2315
Conversation
FYI, I just noticed the "unknown" commits; switched to a new system and apparently git wasn't fully configured when I committed. I'll fix it in the morning. |
Excellent! Is code like this possible? var viewer = new Cesium.Viewer('cesiumContainer');
var entity = viewer.entities.add(new Cesium.Entity({
name: 'example',
description : '<b>HTML description!</b>',
position : Cesium.Cartesian3.fromDegrees(3, -4, 50000),
label : {
text : 'A label!',
verticalOrigin : Cesium.VerticalOrigin.BOTTOM
},
point : {
pixelSize : 15,
color : Cesium.Color.RED
},
polygon : {
material : Cesium.Color.BLUE,
extrudedHeight : 50000,
outline: true,
outlineColor : Cesium.Color.BLACK,
positions : Cartesian3.fromDegreesArray([-2, -2, 3, -4, 2, -2, 2, 2, -2, 2])
},
viewFrom : new Cesium.Cartesian3(100000, 0, 100000)
}));
viewer.trackedEntity = entity; This:
More questions:
|
To simplify code for constant values (and to make it easier for beginners to learn), DataSource properties were modified to take raw values as input (and turn them into a corresponding property instance). For example, ``` var foo = new PolygonGraphics foo.positions = new ConstantProperty([...]); foo.material = new ConstantProperty('./src.png'); foo.extrudedHeight = new ConstantProperty(10000); ``` becomes ``` var foo = new PolygonGraphics foo.positions = [...]; foo.material = './src.png'; foo.extrudedHeight = 10000; ``` Reading the property back will return a Property instance in each of the above cases. Most values become ConstantProperty instances, materials because either a `ColorMaterialProperty` or a `ImageMaterialProperty` depending on type. Position becomes a `ConstantPositionProperty`. Also added an options argument to most DataSource graphics objects and Entity that enables their properties to be set at construction time. Added a CustomDataSource to easily add entities programmatically. Also sort requires. Deprecated id argument to Entity contructor. Deprecated `ColorMaterialProperty.fromColor`.
d5b5c07
to
b43eaf4
Compare
FYI, I did a force push in order to get rid of the unknown commits (turns out git-gui was pointing to a different .gitconfig than my command line because of home directory issues). |
Another question: how good is batching under the hood, e.g., are we going to run into a lot of cases where it slows down adding new entities or modifying them? What is the strategy? |
Since the original CesiumWidget (I'm talking dojo, pre-knockout) suffered from kitchen-sink syndrome; we were paranoid about putting too much stuff directly into the Viewer widget. Now that we have a better handle on where Cesium is going, we've talked about deprecating
It should be easy to do and would be no different than how the other "raw" properties work. i.e. if you do
The last line would have no affect (because
👍 Had I remembered it existed, I would have done the same.
It would be possible to automatically turn a hex string into a
You just do a normal pick and the
It depends on the type of primitive being mapped. For example, static Geometry with constant visibility and color has basically zero overhead once the primitive is created. It will only be looked at again if something changes. For non-geometryr primitives, (Point/Billboard/Label/Path/Model), we loop over each entity once per frame and there is currently overhead even if the data is static. However, we already have infrastructure in place to allow us to remove that overhead; I just haven't had time to refactor the visualizers to take advantage of it. In the long run, performance overhead should be fairly negligible but right now it's definitely there for large data-sets (for non-geometry).
We can, but it's going to show what I describe above. I personally wouldn't worry about it until we are prepared to spend time addressing any discrepancies; particularly because I think the overhead is small enough not to matter for a majority of our users.
There's a good possibility that we might need a way to express some of these things through the Entity interface as well (particularly because of KML and people's desire to add imagery via CZML). @kring started looking into this at one point, but we still need to nail down the semantics of how things would work. If people are writing code, then they would want to use the Cesium API directly, but external Data Sources will likely always be going through the entity system. None of this is set in stone though; we'll know more once we get further along in KML.
In the long run, maybe; but I would say it's too early to try and do it now. In my opinion, we need time for the API to mature and for us to understand how people use it before we start taking stuff out.
I agree, non-issue. I would go as far to call it a feature of AMD. Like my answer above; I think a year or two from now we can take a step back at the mature API and decide if we want to collapse modules or move stuff around.
I assumed that was the plan; but we should probably flesh out how and when we want to do that. It will definitely expose the need for other changes to make sure we have feature parity at the entity level.
I assume you are talking about geometry, since adding/modifying Point/Billboard/Label/Path/Model shouldn't be a problem. Geometry is currently batched per data-source into as few primitives as possible as per the rules of the batching system (i.e. things like translucency, appearance, open/closed, outline, etc.. affect what can be batched). Time-dynamic geometry is not batched at all (since it has to change every frame anyway). I'm sure how we treat dynamic geometry will change once we have dynamic buffers. One drawback here is that if we define 10,000 similar geometries (say opaque colored static boxes); that gets batched into a single primitive. If later on we add a new colored static box, we would end up rebatching that into a single primitive with 10,001 geometries. However, this isn't as bad as it sounds and I'm not sure how common of a use case it is. If some use cases end up slow; we have a lot of ways to improve things behind the scenes with non-breaking changes. We can easily add new heuristics for batching as needed. Also keep in mind that if you want to express data in a time-dynamic faction, you would not do it by setting the above example to new values every frame. That would have a large adverse affect on performance. Instead you would use the built-in Property types we already expose, such as Finally, one known issue we'll have to deal with is dynamic but non-simulation time driven changes. For example, interactive polygon drawing. This is a case where all of the data is static, but changes constantly as the user moves the mouse. My current best strategy for this is to simply have the user tell us up front that the data is going to be changing frequently; though we could get fancy and try and auto-detect it if we want to.
I saved this for last because I have mixed feelings about it. Since Cesium is an SDK, doing this without weirding up the API presents it's own challenges. I could add That's a wrap. This definitely sets the record for longest GitHub response I've ever written. Hopefully I didn't miss anything. |
Agreed on most accounts.
Not now, but I think we should revisit the whole procedural pick paradigm compared to events. It might make sense from our implementation perspective, but I imagine it is atypical of most JavaScript APIs.
I suspect looping over a lot of static billboards is going to hurt, which is why the billboard collection is designed the way it is. Even if we're not able to improve performance now, it would be good to know what we are getting into. Perhaps it's only a few percent. Perhaps it is more.
I'd still like a quick discussion here as it seems like there is at least three places.
I would say ASAP if we are going to promote this as the Cesium API to use for most developers.
I think we will need them for the add/remove case (even the billboard and label collections need work here), but we could see what users really need first.
Do you have some code examples here? I get it, but how natural is this to users compared to, for example, how they use labels and billboards today?
I don't know all the implementation details here, but, if it helps, we treat the globe as a special case in |
`EntityCollection.add` now takes either an `Entity` instance or an options object. The options themselves can either be `xxxGraphics` instances or options objects themselves.
@pjcozzi I made some of the changes you asked for, namely the ability to not have to instantiate the |
Conflicts: Source/DataSources/PolygonGraphics.js
Conflicts: Source/Widgets/Viewer/viewerEntityMixin.js
Conflicts: Source/DataSources/PolygonGraphics.js
Conflicts: Source/DataSources/Entity.js
Conflicts: Source/DataSources/BoxGraphics.js
Viewer.zoomTo and Viewer.flyTo
Conflicts: CHANGES.md
EntityView 2D rotation
Change parameger name for `Viewer.zoomTo` and `flyTo` Allow InfoBox default sanitizer to be set to undefined to disable it.
Same for CompositeEntityCollection.entities. Since EntityCollection is normally exposed itself as an `entities` property, the naming was creating lots of awkward places where we had `foo.entities.entities`, `foo.entities.values` makes this more readable and less error prone.
Port Sandcastle examples to entity layer
Unless anyone has any other comments, this is ready to be merged up to master. |
@kring and @chris-cooper, since I know you were interested in it before, this change also introduces a dev-only Sandcastle folder of examples that get filtered automatically in the release. Just be sure it has the |
I'm pretty sure coverage is the same (if not a little better) than master. I agree it needs to be improved, but this branch isn't the cause. Either way, I'll add improved coverage to the roadmap issue. |
This isn't ready yet, but I'm opening it up for early review.
The goal here is to further enhance the
DataSource
layer so that it can be easier to use for beginners and also become the primary high-level API for Cesium. This would eliminate the need for the "mid-level" api we've considered adding, such as the currentPolygon
primitive (which would eventually be made obsolete). While the overall goal is still a long way off, this PR gets it a lot closer.This change looks bigger/scarier than it is, but it mainly does 4 things:
ConstantProperty
,ConstantPositionProperty
,ColorMaterialProperty
, orImageMaterialProperty
. We create a new property on the fly if needed, mirroring the behavior of C#implicit
types.createPropertyDescriptor
has been deleted and replaced with severalPropertyHelper
functions to achieve this goal.Entity
and the variousxxxGraphics
objects now take anoptions
argument which mirrors their public properties.CustomDataSource
object, which makes easy to add Entities to a viewer instances in very little code. This is in lieu of simply having anentities
property onViewer
. It fits a little better in the existing architecture.viewer.entities
isn't off the table, but I think it would require more rework for not a lot of benefit. I've also thought about renaming the existingDataSource
interface to something else (DataSourceInterface
?) and renamingCustomDatasource
toDataSource
. This would be a non-breaking change that only affects documentation.EntityCollection.add
now takes either anEntity
instance or an options object. The options themselves can either bexxxGraphics
instances or options objects themselves.Here's a complete Sandcastle example that puts the above changes to use.
TODO
PropertyHelper
Checkerboard
material property.PolylineVolumeGeometry
support to entityTODO post-merge (will write issues when ready)
EllipsoidSurfaceAppearance
BoundingSphere.fromBoundingSpheres
does not always produce a good sphere for view.