简体   繁体   English

Three.js 透明背景

[英]Three.js Transparent Background

I know this might sound repeated, I googled it and found answers here about the background color such as this link ( Transparent background with three.js ), But that solution and some others did not work for my case.我知道这听起来可能是重复的,我用谷歌搜索并在这里找到了关于背景颜色的答案,例如这个链接( 透明背景与 three.js ),但那个解决方案和其他一些解决方案不适用于我的情况。

I forked a codepen creation from someone else, and tried to adapt it to use it dynamically but I'm unable to remove the background even when setting alpha: true , setClearColor and scene.background = null into Scene instance.我从其他人那里创建了一个 codepen,并尝试对其进行调整以动态使用它,但即使将alpha: truesetClearColorscene.background = null为 Scene 实例,我也无法删除背景。

I'm new in Three.js and I could not find the actual solution to my problem I've decided to post.我是 Three.js 的新手,我找不到我决定发布的问题的实际解决方案。

I tried debugging the camera angles thinking that might be the issue?我尝试调试摄像机角度,认为这可能是问题所在? - Still unsuccesful. - 仍然不成功。

Here's a Codepen link so you can check it out (it starts at Line 141)这是一个 Codepen 链接,您可以查看它(从第 141 行开始)

https://codepen.io/ig10/pen/JjLJNyX https://codepen.io/ig10/pen/JjLJNyX

Thank you谢谢

It should be just this:应该是这样的:

const renderer = new THREE.WebGLRenderer( { alpha: true } );

As this comment suggests, the issue is with the composer.正如这个评论所暗示的,问题出在作曲家身上。 When I switch the composer.render() with renderer.render(scene, camera) I see the red background当我用renderer.render(scene, camera)切换composer.render() ) 我看到红色背景

So this is probably the correct duplicate: How do I stop EffectComposer from destroying my transparent background?所以这可能是正确的副本:如何阻止 EffectComposer 破坏我的透明背景?

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

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