简体   繁体   English

将three.js背景更改为不透明度.5

[英]Changing three.js background to opacity .5

Ok So I am trying to make the background of the canvas/three.js to something that will be like opacity:.5 I can make it completely transparent with new THREE.WebGLRenderer( { alpha: true } ); 好的,所以我试图将canvas / three.js的背景设置为opacity:.5我可以使用new THREE.WebGLRenderer( { alpha: true } );使其完全透明new THREE.WebGLRenderer( { alpha: true } );

but this isn't what I am looking for I want to be able to see behind the render(canvas background) so I can see the body/html of the page below but keep the objects in the render opacity:1 . 但这不是我想要的,我希望能够在render(canvas background)后面看到,所以我可以看到下面页面的body / html,但将对象保持在render opacity:1

Any idea's? 有任何想法吗? Thanks! 谢谢!

You can try to set the clear color and alpha value of the renderer like the following in order to have more control about how the background is rendered: 您可以尝试设置渲染器的透明颜色和Alpha值,如下所示,以便更好地控制渲染背景的方式:

const renderer = new THREE.WebGLRenderer( { alpha: true } );
renderer.setClearColor( color );
renderer.setClearAlpha( 0.5 );

https://jsfiddle.net/vr648d3z/1/ https://jsfiddle.net/vr648d3z/1/

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

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