Created
April 26, 2016 15:00
-
-
Save ZacBrownBand/11c0baa90a8b4e3aa5d7db581734bfe0 to your computer and use it in GitHub Desktop.
Cesium Sandcastle Pixel Picker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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