最新版本的伪造查看器(6.6.0)在我的控制台中引发“意外令牌”错误,并且我的某些$(button).on('click')事件将不再绑定到我的自定义面板中(尽管有错误,请求的模型仍会加载)
我将查看器恢复到6.5.0版,并且我的代码可以正常工作,我还删除了除初始化逻辑之外的所有代码,并且仍然收到控制台错误。
我还尝试了各种绑定事件的方法,但在最新的查看器版本(row.names
,a <- data.frame(d = 1, cont = T); rownames(a) <- "bbb"
b <- data.frame(d = 3, cont = T); rownames(b) <- "ggg"
x <- data.frame(d = 3:5, cont = c(F, F, F)); rownames(x) <- paste0("xx",1:3)
y <- data.frame(d = 1:3, cont = c(F, F, F)); rownames(y) <- paste0("yy",1:3)
j <- list(Study1 = a, Study2 = b)
k <- list(Study1 = x, Study2 = y)
,$(document).on('click', 'myButton', this.onMyButtonClick)
,$('#myButton).click(this.onMyButtonClick)
)中都无效
$('myButton').bind('click', this.onMyButtonClick)
$('myButton').on('click', this.onMyButtonClick)
<link rel="stylesheet" href="https://developer.api.autodesk.com/modelderivative/v2/viewers/6.*/style.min.css" type="text/css">
<script src="https://developer.api.autodesk.com/modelderivative/v2/viewers/6.*/viewer3D.min.js"></script>
const options = {
env: `AutodeskProduction`,
getAccessToken: getForgeToken
};
const documentId = `urn:${urn[`urn_string`]}`;
Autodesk.Viewing.Initializer(options, function onInitialized() {
Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
});
function onDocumentLoadSuccess(doc) {
$(`.navbar-div`).css(`margin-bottom`,`10px`);
const viewable = Autodesk.Viewing.Document.getSubItemsWithProperties(doc.getRootItem(), {
'type': `geometry`,
'role': `2d`
}, true);
if (viewable.length === 0) {
return;
}
const initialViewable = viewable[0];
const svfUrl = doc.getViewablePath(initialViewable);
const modelOptions = {
sharedPropertyDbPath: doc.getPropertyDbPath()
};
const viewerDiv = document.getElementById(`viewer`);
viewer = new Autodesk.Viewing.Private.GuiViewer3D(viewerDiv);
viewer.start(svfUrl, modelOptions, onLoadModelSuccess, onLoadModelError);
}
class MyExtension extends Autodesk.Viewing.Extension {
constructor(viewer) {
super();
Autodesk.Viewing.Extension.call(this, viewer);
}
createPanel() {
const Panel = new Autodesk.Viewing.UI.DockingPanel(NOP_VIEWER.container, `myPanel`, `Title`);
$(Panel.container).append(*some html*);
Panel.setVisible(true);
$(`#myPanel`).find(`.docking-panel-close`).remove();
$(`#myPanel`).find(`.docking-panel-title`).append(myButton);
$(`#myButton`).click(this.onMyButtonClick.bind(this));
}
onMyButtonClick() {
alert('here');
}
}
Autodesk.Viewing.theExtensionManager.registerExtension(`myExtension`, MyExtension);
答案 0 :(得分:1)
编辑: 现在通过标题面板中的按钮在主要浏览器上进行了测试和工作-实时示例here。会让Engineering知道这正在改变变革,但我怀疑他们不鼓励在此处放置控件
class MyExtension extends Autodesk.Viewing.Extension {
constructor(viewer) {
super(viewer);
this.createPanel()
}
createPanel() {
const Panel = new Autodesk.Viewing.UI.DockingPanel(NOP_VIEWER.container, `myPanel`, `Title`);
Panel.setVisible(true);
$(`#myPanel`).height('100').offset({ top: 10, left: 30 }).find(`.docking-panel-close`).remove();
$(`#myPanel`).append($('<button/>').text('Test').mousedown(this.onMyButtonClick.bind(this)))
}
onMyButtonClick(e) {
e.stopPropagation();
alert('here')
}
}