Search code examples
javascriptautodesk-forgeautodesk-viewerforge

Forge viewer call focus method


In forge viewer I want to call the focus method from my script to focus on selected elements.

like this image

I cannot find method like

viewer.focuse(viewer.getSelection());

Solution

  • This is quite simple, just call Viewer3D#fitToView()~

    var selection = viewer.getSelection();
    viewer.fitToView( selection );
    

    See here for the documentation: https://developer.autodesk.com/en/docs/viewer/v2/reference/javascript/viewer3d/