将绘制的模型从 Blender 导出到 Three.js

发布于 2025-01-14 10:40:59 字数 1088 浏览 4 评论 0原文

我尝试将 GLTF 模型从 Blender 导出到 Three.js。有用。但我在 Three.js 上有一些带有照明和绘画的工件。我在 Three.js 中有线条和正方形,但我不知道为什么。

输入图片这里的描述

我只使用 Blender 中的 Principled BSDF 节点来绘制我的模型。如果我在 Three.js (MeshPhongMaterial) 中设置材质,它就可以正常工作。但对于来自 Blender 的 Principled BSDF 节点则不然。有什么想法吗?

输入图片这里的描述

我试图让物体投射阴影并对灯光做出反应。这与 MeshPhongMaterial 和 Principled BSDF 配合良好。但在第二种选择中,我不喜欢这些黑色条纹。

const INITIAL_MTL = new THREE.MeshPhongMaterial( { color: 0x575757, shininess: 10 } );
...
let theModel = gltf.scene;

        theModel.traverse((o) => {
            if (o.isMesh) {
                if (o.name == 'Foundation') {
                    o.material = INITIAL_MTL //Left part on screenshot with MeshPhongMaterial
                }
                o.castShadow = true;
                o.receiveShadow = true;
            }
        })

I tried to export GLTF model from Blender to Three.js. It works. But I have some artifacts on Three.js with lighting and painting. I have lines and squares in Three.js and I don't know why.

enter image description here

I used only Principled BSDF node in Blender to painting my model. If I set material in Three.js (MeshPhongMaterial) it works fine. But not with Principled BSDF node from Blender. Any ideas?

enter image description here

I'm trying to make the object cast a shadow and react to the lighting. This works well with MeshPhongMaterial and with Principled BSDF. But in the second option, I don't like these black stripes.

const INITIAL_MTL = new THREE.MeshPhongMaterial( { color: 0x575757, shininess: 10 } );
...
let theModel = gltf.scene;

        theModel.traverse((o) => {
            if (o.isMesh) {
                if (o.name == 'Foundation') {
                    o.material = INITIAL_MTL //Left part on screenshot with MeshPhongMaterial
                }
                o.castShadow = true;
                o.receiveShadow = true;
            }
        })

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生死何惧 2025-01-21 10:40:59

减轻自阴影伪影的常用方法是调制阴影投射光的 bias 属性。尝试一下:

light.shadow.bias = - 0.002;

The usual approach to mitigate self-shadowing artifacts is to modulate the bias property of your shadow-casting light. Try it with:

light.shadow.bias = - 0.002;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文