Skip to content

Instantly share code, notes, and snippets.

@brunosimon
Last active November 13, 2019 18:00
Show Gist options
  • Save brunosimon/389129c84e8488e30bf8ed0d5e9fc12b to your computer and use it in GitHub Desktop.
Save brunosimon/389129c84e8488e30bf8ed0d5e9fc12b to your computer and use it in GitHub Desktop.
Folio 2019 - Medium article - Floor
const topLeft = new THREE.Color(0x00ffff)
const topRight = new THREE.Color(0xffffff)
const bottomRight = new THREE.Color(0xff00ff)
const bottomLeft = new THREE.Color(0x0000ff)
const data = new Uint8Array([
Math.round(bottomLeft.r * 255), Math.round(bottomLeft.g * 255), Math.round(bottomLeft.b * 255),
Math.round(bottomRight.r * 255), Math.round(bottomRight.g * 255), Math.round(bottomRight.b * 255),
Math.round(topLeft.r * 255), Math.round(topLeft.g * 255), Math.round(topLeft.b * 255),
Math.round(topRight.r * 255), Math.round(topRight.g * 255), Math.round(topRight.b * 255)
])
const backgroundTexture = new THREE.DataTexture(data, 2, 2, THREE.RGBFormat)
backgroundTexture.magFilter = THREE.LinearFilter
backgroundTexture.needsUpdate = true
material.uniforms.tBackground.value = backgroundTexture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment