Created
September 6, 2019 21:54
-
-
Save balataca/d20d8b9323c146dd1c6cd5373a43f43d to your computer and use it in GitHub Desktop.
AFRAME alpha channel video shader
This file contains hidden or 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
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