我很难在Three.js中使用aoMap。
我有一个glb资产,红色通道上有aoMap或其他内容。当我将其带入巴比伦查看器时,我可以看到ao很好,但是它不会显示在three.js查看器或我的项目中。我认为这与第二组uvs有关,但是我找不到在使用gltf加载程序的基础上进行此操作的资源……我真的不知道该怎么做。任何回应将不胜感激!
这是我的代码(我使用的是html画布作为纹理)
然后我获得了模型的几何形状和所需的漫反射纹理(全白色),但是异常显示未显示...
working application with shadows included in diffuse
not working, diffuse is just white, and aoMap is not showing
答案 0 :(得分:2)
您需要第二组UV是正确的。其背后的原因是经常重复出现漫反射纹理(例如砖墙或方格T恤)。但是,AO阴影在几何图形的每个部分更可能是唯一的,因此几乎永远不会重复。由于通常需要使用其他UV贴图方法,因此默认设置是使用第二组UV。
您可以做两件事:
// Get existing `uv` data array
const uv1Array = mesh.geometry.getAttribute("uv").array;
// Use this array to create new attribute named `uv2`
mesh.geometry.setAttribute( 'uv2', new THREE.BufferAttribute( uv1Array, 2 ) );
.getAttribute
和.setAttribute
是BufferGeometry
的方法,如果您想进一步了解它们的话。