Skip to content

Instantly share code, notes, and snippets.

@ZacBrownBand
Created May 5, 2016 13:16
Show Gist options
  • Save ZacBrownBand/f42c1540b14dec49da876350cbec1f6f to your computer and use it in GitHub Desktop.
Save ZacBrownBand/f42c1540b14dec49da876350cbec1f6f to your computer and use it in GitHub Desktop.
Picks the color of a pixel from a cesium viewer canvas.
var viewer = new Cesium.Viewer('cesiumContainer');
var scene = viewer.scene;
var context = scene.context;
var readColor = false;
scene.postRender.addEventListener(function() {
if (readColor) {
readColor = false;
var pixels = context.readPixels({
x : 0,
y : 0,
width : 1,
height : 1
});
console.log(pixels);
}
});
Sandcastle.addToolbarButton('Get Color', function() {
readColor = true;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment