Three.js MeshBasicMaterial doesn't work as expected

回眸只為那壹抹淺笑 提交于 2020-01-05 10:07:11

问题


I am trying to create a texture with Three.js.

My source of texture_f1 is a .png file witch means you can see the background through it.

The problem is that if i try to set background color: 0xffffff it doesn't work in combination with map:.

If i set only the color:0xffffff , it return a white, but when use with map: like this var material_f1 = new THREE.MeshBasicMaterial({ map: texture_f1, color: 0xffffff}); i can see the background through the .png black .


回答1:


If you have a transparent texture, you must set material.transparent to true.

var material = new THREE.MeshBasicMaterial( {
    color: 0xffffff,
    map: texture,
    transparent: true
} )

Note that the material color does not "show through" the transparent texture -- it tints the texture.

If you want the material color to "show through" the transparent texture, then you need to use ShaderMaterial, instead, and create a custom shader.

There is an example of doing that in this stackoverflow answer.

three.js r.71



来源:https://stackoverflow.com/questions/31738809/three-js-meshbasicmaterial-doesnt-work-as-expected

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