Skip to content

Instantly share code, notes, and snippets.

@rlittlefield
Created August 21, 2014 16:35
Show Gist options
  • Save rlittlefield/e7ee65ccf3f103fcc78d to your computer and use it in GitHub Desktop.
Save rlittlefield/e7ee65ccf3f103fcc78d to your computer and use it in GitHub Desktop.
Cesium JS - geometry age determines visibility behind low-opacity billboards
var viewer = new Cesium.Viewer('cesiumContainer');
var scene = viewer.scene;
var primitives = scene.primitives;
var old_col = new Cesium.PolylineCollection();
scene.primitives.add(old_col);
var billboards = primitives.add(new Cesium.BillboardCollection());
billboards.add({
image : '../images/Cesium_Logo_overlay.png',
position : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883, 1110000)
});
var new_col = new Cesium.PolylineCollection();
scene.primitives.add(new_col);
Sandcastle.addToolbarMenu([
{
text : 'Choose an item below',
onselect : function() {
}
},
{
text : 'Add polyline to old collection',
onselect : function() {
var start_pos = Cesium.Cartesian3.fromDegrees(-43.679, 70.269, 1000000);
var end_pos = Cesium.Cartesian3.fromDegrees(-81.62, 28.0, 1000000);
if (window.new_polyline) {
console.log('removing new polyline');
scene.primitives.remove(window.new_polyline);
}
window.old_polyline = old_col.add({
positions : [start_pos, end_pos],
material : Cesium.Material.fromType('Color', {
color : new Cesium.Color(193, 193, 193, 1.0)
}),
width : 1.0
});
}
}, {
text : 'Add polyline to new collection',
onselect : function() {
if (window.old_polyline) {
console.log('removing old polyline');
scene.primitives.remove(window.old_polyline);
}
var start_pos = Cesium.Cartesian3.fromDegrees(-40.179, 70.269, 1000000);
var end_pos = Cesium.Cartesian3.fromDegrees(-77.12, 28.0, 1000000);
window.new_polyline = new_col.add({
positions : [start_pos, end_pos],
material : Cesium.Material.fromType('Color', {
color : new Cesium.Color(193, 193, 193, 1.0)
}),
width : 1.0
});
}
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment