使用 Three.js 从一侧看不到人脸 [英] Faces invisible from one side using Three.js

查看:34
本文介绍了使用 Three.js 从一侧看不到人脸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将一个带有 JPG 纹理的 OBJ 文件加载到页面中 - 从一侧可以看到面部,但从另一侧看它们是不可见的.

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.

我尝试添加 model.doubleSided = true; 但这似乎没有改变任何东西.

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

推荐答案

在材质上添加双面标志.假设你有类似的东西:

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

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

添加:

material.side = THREE.DoubleSide;

或者当你创建材料时:

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

对于返回 Object3D 的 OBJMTL 加载器,我们需要遍历对象以设置适当的标志:

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;
    });
}

这篇关于使用 Three.js 从一侧看不到人脸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆