// Button 1
var button1 = new Autodesk.Viewing.UI.Button('my-view-front-button')
button1.icon.style.backgroundImage = 'url(../img/frontview.png)'
button1.onClick = function (e) {
_viewer.setViewCube('front')
}
button1.addClass('my-view-front-button')
button1.setToolTip('View front')
// Button 2
var button2 = new Autodesk.Viewing.UI.Button('my-view-back-button')
button2.icon.style.backgroundImage = 'url(../img/backview.png)'
button2.onClick = function (e) {
_viewer.setViewCube('back')
}
button2.addClass('my-view-back-button')
button2.setToolTip('View Back')
// SubToolbar
this.subToolbar = new Autodesk.Viewing.UI.ControlGroup('my-custom-view-toolbar')
this.subToolbar.addControl(button1)
this.subToolbar.addControl(button2)
// Add subToolbar to main toolbar
_viewer.toolbar.addControl(this.subToolbar)
2. 删除控件:
// remove settings button from toolbar
var group = _viewer.toolbar.getControl('settingsTools')
group.removeControl('toolbar-settingsTool')
3. 调整控件位置:
// reposition the default control
var op = {
index : 0
}
var fullscreenBtn = group.getControl('toolbar-fullscreenTool')
group.removeControl('toolbar-fullscreenTool')
group.addControl( fullscreenBtn, op)
1. 新增控件或控件组,可以参考如下代码:
2. 删除控件:
3. 调整控件位置: