Three.js smoke animation with transparent background

五迷三道 提交于 2019-12-25 00:27:03

问题


I'm completely new to three.js, I'd like the smoke canvas to on top of the image to have a transparent background. the canvas sits behind the image at the moment, that's why I have this css below.

canvas{ 
    position: absolute;
    z-index: 2;
    top:0px;
    left: 0;
}

I don't understand how to remove or to make the black background of the canvas transparent. Please have a look at my demo below

https://codepen.io/davide77/pen/GxZgZB?editors=1010


回答1:


If you need a transparent background you can pass in the alpha parameter to the WebGLRenderer constructor.

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

https://threejs.org/docs/#api/renderers/WebGLRenderer




回答2:


You can use scene.background for this. There is no need to work with an additional HTML element. Just do:

scene.background = texture;

https://codepen.io/anon/pen/OvNVmy



来源:https://stackoverflow.com/questions/49279899/three-js-smoke-animation-with-transparent-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!