MaterialConverterPrism Extension是为Autodesk Forge Viewer创建的一个扩展,其主要作用是将特定格式的材质转换为可以在Viewer中渲染的格式。它主要通过解析不支持在Forge Viewer中渲染的材质属性,创建一种等效的材质。以下是一个使用MaterialConverterPrism Extension的代码示例:
const viewer = new Autodesk.Viewing.GuiViewer3D(container);
const options = {
env: 'AutodeskProduction',
api: 'derivativeV2',
accessToken: 'ACCESS_TOKEN_HERE'
};
Autodesk.Viewing.Initializer(options, () => {
viewer.start();
const documentId = 'URN_HERE';
Autodesk.Viewing.Document.load(documentId, (doc) => {
const viewables = doc.getRoot().getDefaultGeometry();
viewer.setDocument(doc, viewables);
viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, () => {
const materialConverter = viewer.impl.matman()._materialCache._materialsByModelId.default.Extension.MaterialConverter;
const convertedMaterial = materialConverter.convert({
type: 'StdMaterial',
diffuse: 16777215,
specular: 16777215,
opacity: 0.5
});
console.log(convertedMaterial); // outputs the converted material
});
});
});
上一篇:AutodeskForgeViewer的DWF加载出错-在处理SVF时出现错误。
下一篇:AutodeskForgeViewerDiffToolExentionCountisnotmatchingwithBIM360CompareToolcount