2

How do i update the view using setViewCube in v7? I was using the following code in v6, but it doesn't work in v7.

viewer.setViewCube('[top/front]');

In the migration guide v6 to v7 it says, I should call it through the extension:

extension.setViewCube(display);

How do I get the extension object from where to call it from?

Joni Turunen
  • 137
  • 1
  • 13

1 Answers1

3

As the migration document mentions: The ViewCube apis have been moved out of Viewer3D instance and into the Autodesk.ViewCubeUi extension. So you will need to get the extension by

viewcuiext = viewer.getExtension('Autodesk.ViewCubeUi')
viewcuiext.setViewCube(display);

this assumes the extension has been loaded, otherwise, call

   viewer.loadExtension('Autodesk.ViewCubeUi')
          .then(res=>console.log('the extension has been loaded: ' + res))

loadExtension is a promise call, so ensure it has been loaded successfully.

Please let us know if there is any question.

Xiaodong Liang
  • 2,051
  • 2
  • 9
  • 14
  • 1
    Thanks @Xiaodong, just for those who see this solution, what the Promise return is a reference to the extension, so you can simply do : viewer.loadExtension('Autodesk.ViewCubeUi') .then(ext=>ext.setViewCube('back')) – Alaa Abuiteiwi Jan 17 '23 at 13:15