简体   繁体   English

有没有办法在 Three.js 中拥有透明的视频背景?

[英]Is there a way to have transparent video background in Three.js?

I have a greenscreen HTML5 video and want to display it on a plane with a video texture using Three.js.我有一个绿屏 HTML5 视频,想使用 Three.js 在带有视频纹理的平面上显示它。

I tried to use two different video textures ( the video and the alpha channel ) but they are not perfectly synchronized in time and based on what I read it's very hard to sync two HTML5 videos.我尝试使用两种不同的视频纹理(视频和 alpha 通道),但它们在时间上并不完全同步,根据我阅读的内容,同步两个 HTML5 视频非常困难。

I think using .webm video is the way to go but I can't manage to get the alpha channel working with Three.js.我认为使用 .webm 视频是可行的方法,但我无法让 alpha 通道与 Three.js 一起工作。 Is it possible or is there another way to do it ?有可能还是有其他方法可以做到? Thanks !谢谢 !

var material = new THREE.MeshBasicMaterial( { map: videoTexture, transparent: true } );

You have to specify the format in order to have the transparency :您必须指定格式才能获得透明度:

texture.format = THREE.RGBAFormat;

Thanks everyone谢谢大家

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM