Autodesk-Forge / viewer-react-express-headless

Headless viewer: Creates a custom Viewer GUI using react-express
https://viewer-rocks.autodesk.io/
MIT License
103 stars 48 forks source link

used custom code implementation for model browser functionality. is there any way to get data of model browser. #21

Open sannysoni123 opened 6 years ago

sannysoni123 commented 6 years ago

i used headless functionality for viewer in angular 5. Common attributes like zoom, rotation, pan - custom usage of setActiveNavigationTool() inbuilt function. so is there any way to get model browser data functionality like door / wall / kitchen attributes Please let me know the way ...

julianobrasil commented 4 years ago

This would be cool. I've found very limited access to what happens in the model browser (some example of how to switch the event a click on the model browser leaves would fire, for example). But it would be much nicer if you had a way to get a reference to the instance to, for example, change the handler function that responds to the mouse clicks.

julianobrasil commented 4 years ago

In fact, based on this post and after some console.log's, I've found out what you have to override to have a little bit of control. In the current version of Viewer I'm using (v7), a click on an item in the Viewer Model Browser fires an internal function that isolates the clicked element. This internal function is called isolate. Without having to mess with everything, you can override it:

(Autodesk.Viewing.Extensions as any).ViewerModelStructurePanel.prototype.isolate = function isolate(
    dbId: number,
    model: Autodesk.Viewing.Model
  ) {
    // here you can do whatever you want to
    if (model) {
      const event = {
        type: 'MY_CUSTOM_EVENT',
        dbId,
        model,
      };
      this.viewer.dispatchEvent(event);
    }
  };