Faces invisible from one side using Three.js

我怕爱的太早我们不能终老 提交于 2019-12-20 03:30:07

问题


I have an OBJ file with JPG texture loaded into a page - from one side the faces are visible, but from the other they are invisible.

Faces visible (a little dark - sorry!)

Other side - faces not visible.

I tried adding model.doubleSided = true; but that doesn't seem to change anything.


回答1:


Add the double sided flag on the material. Assuming you have something like:

material = new THREE.MeshLambertMaterial ({ color: 0xFF00FF });

add:

material.side = THREE.DoubleSide;

or when you create the material do:

material = new THREE.MeshLambertMaterial ({ color: 0xFF00FF, side: THREE.DoubleSide });

EDIT: For the OBJMTL loader that returns an Object3D we would then need to traverse the object to set the appropriate flag:

if (object instanceof THREE.Object3D)
{
    object.traverse (function (mesh)
    {
        if (! (mesh instanceof THREE.Mesh)) return;

        mesh.material.side = THREE.DoubleSide;
    });
}



回答2:


Try adding renderer.setFaceCulling( THREE.CullFaceNone );



来源:https://stackoverflow.com/questions/23640056/faces-invisible-from-one-side-using-three-js

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