在 Autodesk Forge Viewer 中使用 THREE.MeshLambertMaterial 不起作用

问题描述 投票:0回答:0

我正在尝试将

THREE.MeshLambertMaterial
应用于 Autodesk Forge Viewer 中的模型。一旦我调用
fragList.setMaterial(fragId, lambertMaterial)
,模型就会消失,并出现以下控制台警告:

[.WebGL-00004F14008E4F00] GL_INVALID_OPERATION: Active draw buffers with missing fragment shader outputs.

使用

THREE.MeshBasicMaterial
没有错误,但我想利用 Lambert 材质的着色能力。理想情况下,我会使用
THREE.MeshPhongMaterial
,但 Forge Viewer 似乎使用了
THREE.MeshPhongMaterial
的修改版本,因此通常适用于 Phong 的效果不再有效(例如,
material.envMap
的行为与使用正常的三种材料,以及影响 envMap 混合的
material.combine
属性无法更改)。

我已经创建了一个 Github 存储库和测试页面来演示这个问题。

存储库:https://github.com/throw-away-97743/ForgeViewerTests

现场演示:https://throw-away-97743.github.io/ForgeViewerTests/basic-lambert-test.html

相关JavaScript代码:

// please refer to the live demo and repository
// for a more interactive example
const fragList = model.getFragmentList();
const matMan = Viewer.impl.matman();
const fragIds = Object.keys(fragList.fragments.fragId2dbId);
const lambertMaterial = new THREE.MeshLambertMaterial();
lambertMaterial.color = new THREE.Color(0xff0000);
matMan.addNonHDRMaterial("lambertMaterial", lambertMaterial);
lambertMaterial.envMap = null;
lambertMaterial.needsUpdate = true;
fragIds.forEach(fragId => fragList.setMaterial(fragId, lambertMaterial));
Viewer.impl.invalidate(true);
three.js webgl autodesk-forge autodesk-viewer autodesk-model-derivative
© www.soinside.com 2019 - 2024. All rights reserved.