PolylineVolume extruded shape cannot be drawn below the reference positions
- Dominant language
- JavaScript
- Stars
- 15.7k
- Forks
- 3.9k
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 34
Description
Brought up on the forum: https://groups.google.com/forum/#!topic/cesium-dev/rfu43TpF0h0
> The shape I'm providing "surrounds" the z-axis, but the extrusion is always being drawn "above" the reference positions.
```
var viewer = new Cesium.Viewer('cesiumContainer');
//Use STK World Terrain
viewer.terrainProvider = new Cesium.CesiumTerrainProvider({
url: 'https://assets.agi.com/stk-terrain/v1/tilesets/world/tiles',
requestVertexNormals: true
});
//Set the random number seed for consistent results.
Cesium.Math.setRandomNumberSeed(3);
var start = Cesium.JulianDate.fromDate(new Date());
var stop = Cesium.JulianDate.addSeconds(start, 360, new Cesium.JulianDate());
function computeFlightPath(lon, lat, radius, outPos) {
var sampledPos = new Cesium.SampledPositionProperty();
var count = 0;
for (var i = 0; i <= 270; i += 15) {
var radians = Cesium.Math.toRadians(i);
var time = Cesium.JulianDate.addSeconds(start, i, new Cesium.JulianDate());
var position = Cesium.Cartesian3.fromDegrees(
lon + (radius * 1.5 * Math.cos(radians)),
lat + (radius * Math.sin(radians)),
Cesium.Math.nextRandomNumber() * 500 + 1750);
sampledPos.addSample(time, position);
outPos[count++] = position;
}
return sampledPos;
}
function computeFinalFlightPath(a, b, outPos) {
var sampledPos = new Cesium.SampledPositionProperty();
for (var i = 0; i < a.length; i++) {
var radians = Cesium.Math.toRadians(i * 15);
var time = Cesium.JulianDate.addSeconds(start, i, new Cesium.JulianDate());
var position = Cesium.Cartesian3.fromElements(
((a[i].x + b[i].x) * 0.5),
((a[i].y + b[i].y) * 0.5),
((a[i].z + b[i].z) * 0.5));
sampledPos.addSample(time, position);
outPos[i] = position;
}
return sampledPos;
}
function createFlightGraphics(sampledPos, pos, color) {
for (var p = 0; p < pos.length; p++) {
viewer.entities.add({
position: pos[p],
point: {
pixelSize : 8,
color: Cesium.Color.TRANSPARENT,
outlineColor: color,
outlineWidth: 3
}
});
}
viewer.entities.add({
availability: new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({
start: start,
stop: stop
})]),
// Use our computed positions
position: sampledPos,
// Automatically compute orientation based on position movement.
orientation : new Cesium.VelocityOrientationProperty(sampledPos),
path: {
resolution: 1,
material: new Cesium.PolylineGlowMaterialProperty({
glowPower : 0.1,
color : color
}),
width : 10
}
});
}
//Compute the position
var uav1Pos = [];
var uav1SampledPos = computeFlightPath(-83.60986232757568,41.653258658953995, 0.03, uav1Pos);
var uav2Pos = [];
var uav2SampledPos = computeFlightPath(-83.60986232757570,41.653258658953998, 0.033, uav2Pos);
var uav3Pos = [];
var uav3SampledPos = computeFinalFlightPath(uav1Pos, uav2Pos, uav3Pos);
// Create graphics
//createFlightGraphics(uav1SampledPos, uav1Pos, Cesium.Color.YELLOW);
//createFlightGraphics(uav2SampledPos, uav2Pos, Cesium.Color.RED);
createFlightGraphics(uav3SampledPos, uav3Pos, Cesium.Color.CYAN);
viewer.entities.add({
polylineVolume: {
positions: uav3Pos,
shape: [
new Cesium.Cartesian2(-500.0, -200.0),
new Cesium.Cartesian2( 500.0, -200.0),
new Cesium.Cartesian2( 500.0, 200.0),
new Cesium.Cartesian2(-500.0, 200.0)
],
material: Cesium.Color.BLUE.withAlpha(0.5),
outline: true,
outlineColor: Cesium.Color.BLACK
}
});
viewer.zoomTo(viewer.entities);
```
Contributor guide
Research direction
Start by running the supplied Cesium Viewer reproduction with the polylineVolume entity and its surrounding shape. Inspect the polylineVolume implementation and related geometry behavior to determine why the shape is drawn only above the reference positions. Done means the same example can render the volume below those positions when the shape surrounds the z-axis.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100