Skip to content

Instantly share code, notes, and snippets.

@nkint
Created April 29, 2017 23:08
Show Gist options
  • Save nkint/fd0fbf30fc1844ebb12ad181c010ed7c to your computer and use it in GitHub Desktop.
Save nkint/fd0fbf30fc1844ebb12ad181c010ed7c to your computer and use it in GitHub Desktop.
load image from url into a regl.texture object
const emptyTextureDimension = {
width: 512,
height: 512,
channels: 3,
}
function loadImageIntoTexture(url, texture) {
const image = new Image()
image.crossOrigin = 'anonymous'
image.src = url
image.onload = function () {
texture({ data: image })
}
}
const satelliteTexture = regl.texture(emptyTextureDimension)
const satelliteUrl = getTextureUrl(tile) // here is something
loadImageIntoTexture(satelliteUrl, satellite)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment