Skip to content

Instantly share code, notes, and snippets.

@ZacBrownBand
Created April 26, 2016 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZacBrownBand/11c0baa90a8b4e3aa5d7db581734bfe0 to your computer and use it in GitHub Desktop.
Save ZacBrownBand/11c0baa90a8b4e3aa5d7db581734bfe0 to your computer and use it in GitHub Desktop.
Cesium Sandcastle Pixel Picker
<style>
@import url(../templates/bucket.css);
.point {
border: 1px solid red;
width: 5px;
height: 5px;
position: absolute;
top: 197px;
left: 197px;
}
</style>
<div id="cesiumContainer" class="fullSize"></div>
<div id="toolbar"></div>
<div class="point"></div>
var viewer = new Cesium.Viewer('cesiumContainer');
var pixels = new Uint8Array(4);
function getColor(x, y) {
var gl = viewer.canvas.getContext('webgl');
gl.readPixels(x, y, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
console.log(pixels);
}
Sandcastle.addToolbarButton('Get Color at 200, 200', getColor.bind(null, 200, 200));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment