Skip to content

Instantly share code, notes, and snippets.

@balataca
Created September 6, 2019 21:54
Show Gist options
  • Save balataca/d20d8b9323c146dd1c6cd5373a43f43d to your computer and use it in GitHub Desktop.
Save balataca/d20d8b9323c146dd1c6cd5373a43f43d to your computer and use it in GitHub Desktop.
AFRAME alpha channel video shader
AFRAME.registerShader('videoAlpha', {
schema: {
src: { type: 'map' },
transparent: { default: true, is: 'uniform' }
},
init (data) {
const videoTexture = new THREE.VideoTexture(data.src)
videoTexture.minFilter = THREE.LinearFilter
videoTexture.format = THREE.RGBAFormat
this.material = new THREE.MeshLambertMaterial({
map: videoTexture
})
},
update (data) {
this.material.src = data.src
this.material.transparent = data.transparent
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment