-
Notifications
You must be signed in to change notification settings - Fork 3
/
aframe-transparent-video-shader.umd.js
2 lines (2 loc) · 1.36 KB
/
aframe-transparent-video-shader.umd.js
1
2
!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){AFRAME.registerShader("transparent-video",{schema:{src:{type:"map"}},applyWebmShader:function(e){var a=new THREE.VideoTexture(e);a.format=THREE.RGBAFormat,this.material=new THREE.MeshBasicMaterial({map:a,transparent:!0})},applyHEVCShader:function(e){var a=new THREE.VideoTexture(e),r=new THREE.VideoTexture(e);a.format=THREE.RGBAFormat,r.format=THREE.AlphaFormat,this.material=new THREE.ShaderMaterial({vertexShader:"\n varying vec2 vUv;\n \n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n varying vec2 vUv;\n uniform sampler2D videoTexture;\n uniform sampler2D alphaTexture;\n\n void main() {\n vec4 videoColor = texture2D(videoTexture, vUv);\n vec4 alphaColor = texture2D(alphaTexture, vUv);\n\n gl_FragColor = vec4(videoColor.rgb, alphaColor.a);\n }\n ",uniforms:{videoTexture:{type:"t",value:a},alphaTexture:{type:"t",value:r}},transparent:!0})},init:function(e){var a,r=e.src,n=new URL(r.currentSrc).pathname.split("."),t=null==(a=n[n.length-1])?void 0:a.toLowerCase();e.transparent=!0,"webm"===t?this.applyWebmShader(r):this.applyHEVCShader(r)}})});
//# sourceMappingURL=aframe-transparent-video-shader.umd.js.map