Hiding unwanted toolbar items in the Forge viewer

Here’s a quick one to wrap up the week. Some time ago we decided that Dasher 360 didn’t need to provide the option for users to do an unconstrained orbit: the default mode of turntable orbit would be perfectly adequate, especially as we deal mainly with building models.

So it was that I created a simple extension to hide that particular toolbar button. It worked well enough, but after a while I saw the icon creep back into the UI. It turns out that the application resize event – which is called for lots of different reasons – was re-enabling the UI. Attaching our own event handler made it possible for us to re-hide the icon once re-enabled.

Here’s the TypeScript implementation:

/// <reference path=’../../../../../typings/lmv-client/lmv-client.d.ts’ />

 

export default class HideOrbitExtension extends Autodesk.Viewing.Extension {

 

  private _toolbarName = ‘toolbar-orbitTools’;

 

  constructor(viewer: Autodesk.Viewing.Private.GuiViewer3D, options: any) {

    Read more