Opening a PR to indicate that this is "stable" enough to preview and for preliminary review, but there's still a decent amount of work to be done.
Features:
- support for
PolylineMaterialAppearance
- mitered polylines
- batching multiple instances with per-instance show and line width
Implementation notes:
More details in https://github.com/AnalyticalGraphicsInc/cesium/issues/2172#issuecomment-385685782.
We're using a single-pass, globe-depth-based algorithm.
~For each line segment in the polyline we generate a geometry instance volume that has several planes encoded in the batch table. For each fragment on the volume, we look up the globe depth to compute a terrain position in eyespace and clip this position based on the planes from the batch table.
The planes are also used to compute the position's distance from the center and ends of the line for material support.~
~Due to the batch table dependence and mapping of attributes from multiple instances to a single pick ID, this PR introduces a new Primitive
type, GroundPolylinePrimitive
.
There's also a new user-facing geometry, GroundPolylineGeometry
, that doesn't actually have a createGeometry
function but rather gets decomposed into individual volumes that are then used to generate vertex buffers and attributes.~
~This is a little troublesome for asynchronous geometry since GroundPolylineGeometry
's computation currently happens on the main thread, with the worker threads mostly just converting chunks of this into the combined vertex buffer. In practice this doesn't seem to be a huge problem, but it's something we should talk about.~
For each line segment in the polyline we generate a volume with vertex attributes that describe the line segment using a series of planes. For each fragment on the volume, we look up the globe depth to compute a terrain position in eyespace and clip this position based on the planes from the vertex attributes.
The planes are also used to compute the position's distance from the center and ends of the line for material support.
The planes differ between 2D and 3D, and I haven't figured out yet how to interpolate them for morphing, so there's a new Primitive
type that issues draw commands with different shaders for 2D and morph. When morphing we actually just draw the volumes themselves with materials, which seems acceptable because the camera goes so far away during the morph anyway.
- [x] I should also do load and runtime comparisons with a hack that attempts to simulate polylines using corridors or something.
TODO:
- [x] Integrate with changes in https://github.com/AnalyticalGraphicsInc/cesium/pull/6434 for better geometry heights
- [x] batch per-instance colors
- [x] doc and specs, compatibility checks
- [x] spruce up Sandcastle example
- more geometry cases
- selection indicator?
- volume debug toggle
- Z ordering/Z ordering with
GroundPrimitives
Couple Post-PR roadmap items:
- Entity API integration (priority)
- Investigate smear reduction with something like screen-space partial derivatives
- terrain height and volume length improvements
- Evaluate whether dashed lines should "swim" or stay put
- Investigate fixes for floating point problems with very long arrow lines