three.js - ThreeJS GLTFExporter 不导出 PBR 材质贴图
问题描述
我有一个带有 PBR 材质的简单立方体。使用的贴图是颜色、金属度、粗糙度、凹凸。当我通过此代码导出场景时,导出的 glb 缺少除颜色之外的所有地图。这是 ThreeJS 中的错误吗?
e = new THREE.GLTFExporter();
e.parse(STAGE.scene.mesh, (glb) => {
let blob = new Blob([glb], { type: "application/octet-stream" });
let d = document.createElement('a');
d.href = window.URL.createObjectURL(blob);
d.download = "orbis.glb"
document.body.appendChild(d);
d.click();
document.body.removeChild(d);
}, {binary: true});
解决方案
你应该使用不同的纹理。原因是 gltf 规范:
- gltf 使用 normalMap 而不是凹凸贴图,因此凹凸贴图不会被导出
- metalnessMap 和 roughnessMap 仅在它们是相同纹理时才被导出,因为 gltf 对两者都使用一个纹理(参见https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#metallic-roughness-material和https: //github.com/mrdoob/three.js/issues/14940用于在导出器中合并这些纹理的功能请求)
推荐阅读
- azure - 创建 3 个 VNET,其中所有流量都通过一个 VNET(中心辐射型)路由
- javascript - Mongo 并不总是返回正确的结果
- google-sheets - 谷歌表格 VLOOKUP 返回多个值
- android - 如何启动多个 FlutterActivity?
- unity3d - 如何从 Blender 中导出 .dae 动画?
- ios - 创建类似于 iOS 联系人的 UI 编辑 UI
- python - 如何创建一组 tkinter 小部件(for 循环)并单独引用它们中的每一个?
- netlogo - 协助 Netlogo 中的节点/链接导航
- tensorflow - 自定义层输出 Keras 的尺寸
- jenkins - 如何在 Jenkins Job DSL 插件的上下文中使用共享/常见的 groovy 方法