通过 dbId 放置自定义标记而不在查看器上显示标记
Placing custom markup by dbId not showing the markups on viewer
所以我想重现this教程。我有 IconMarkupExtension.js 的完全相同的代码。但是我没有在查看器上看到标记,但是自定义扩展被添加到带有图标的工具栏中。我想知道这是否与我使用的模型有关但不确定。
我的查看器代码
if (viewer != null) {
var thisviewer= viewer;
if (thisviewer) {
thisviewer.tearDown();
thisviewer.finish();
thisviewer= null;
$("#forgeViewer").empty();
}
}
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;
}
Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
});
加载扩展
viewer.loadExtension('IconMarkupExtension', {
button: {
icon: 'fa-thermometer-half',
tooltip: 'Show The Temperature'
},
icons: [
{ dbId: 69, label: '300°C', css: 'temperatureHigh fas fa-thermometer-full'},
{ dbId: 70, label: '300°C', css: 'temperatureHigh fas fa-thermometer-full'},
{ dbId: 71, label: '300°C', css: 'temperatureHigh fas fa-thermometer-full'}
],
onClick: (id) => {
console.log(' ======================= IconMarkupExtension onClick id: ' + id);
viewer.select(id);
viewer.utilities.fitToView();
switch (id){
case 69:
alert('Sensor offline');
}
}
})
这是我正在使用的 the 型号。
我使用的是查看器版本 V7*
谢谢
编辑:
我设法获取了图标,但所有图标都居中显示。正如你在下面看到的
即使我选择了一个特定的对象也是一样的。
标签和值根据我添加的模型 ID 正确显示。
是不是和我的机型有关?
所以我想重现this教程。我有 IconMarkupExtension.js 的完全相同的代码。但是我没有在查看器上看到标记,但是自定义扩展被添加到带有图标的工具栏中。我想知道这是否与我使用的模型有关但不确定。
我的查看器代码
if (viewer != null) {
var thisviewer= viewer;
if (thisviewer) {
thisviewer.tearDown();
thisviewer.finish();
thisviewer= null;
$("#forgeViewer").empty();
}
}
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;
}
Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
});
加载扩展
viewer.loadExtension('IconMarkupExtension', {
button: {
icon: 'fa-thermometer-half',
tooltip: 'Show The Temperature'
},
icons: [
{ dbId: 69, label: '300°C', css: 'temperatureHigh fas fa-thermometer-full'},
{ dbId: 70, label: '300°C', css: 'temperatureHigh fas fa-thermometer-full'},
{ dbId: 71, label: '300°C', css: 'temperatureHigh fas fa-thermometer-full'}
],
onClick: (id) => {
console.log(' ======================= IconMarkupExtension onClick id: ' + id);
viewer.select(id);
viewer.utilities.fitToView();
switch (id){
case 69:
alert('Sensor offline');
}
}
})
这是我正在使用的 the 型号。
我使用的是查看器版本 V7*
谢谢
编辑:
我设法获取了图标,但所有图标都居中显示。正如你在下面看到的
即使我选择了一个特定的对象也是一样的。
标签和值根据我添加的模型 ID 正确显示。
是不是和我的机型有关?