【发布时间】:2021-10-10 09:31:04
【问题描述】:
我一直在 V6* 中使用以下 .impl 方法
viewerApp.getCurrentViewer().impl.invalidate viewerApp.getCurrentViewer().impl.matman()._materials
如何继续使用 V7*
谢谢
编辑:
var options = {
env: 'AutodeskProduction',
api: 'derivativeV2',
getAccessToken: function(onTokenReady) {
var token = accessToken;
var timeInSeconds = 3600;
onTokenReady(token, timeInSeconds);
}
};
var documentId = "urn:" + urn;
Autodesk.Viewing.Initializer(options, function() {
var htmlDiv = document.getElementById('forgeViewer');
viewer = new Autodesk.Viewing.GuiViewer3D(htmlDiv);
var startedCode = viewer.start();
if (startedCode > 0) {
console.error('Failed to create a Viewer: WebGL not supported.');
return;
}
console.log('Initialization complete, loading a model next...');
Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
});
...
然后我使用 impl 方法如下..
var mats = viewer.impl.matman()._materials;
但我仍然得到错误
无法读取 null 的属性“impl”
不知道为什么,但可能是我的全局 viewer 变量为 null ,不知道为什么会发生这种情况或我做错了什么。
【问题讨论】:
-
这可能是时间问题 - 也许您正尝试在全局查看器变量初始化之前访问它。尝试在初始化
viewer变量的行上放置一个断点,看看它是否被及时调用。
标签: autodesk-forge autodesk-viewer autodesk