Reputation: 53
I want to use the ModelStructurePanel in my Forge Viewer to show the user a list of models and they can choose which model is to be loaded or unloaded, but (even after they are unloaded) i need the models to still show up in the model browser. Basically i want the usual behavior of the ModelStructurePanel when multiple models are loaded, but i want to override it in a way i can use it to display multiple models before loading them through user input. Once a model is loaded, all the functionalities of the ModelStructurePanel should work the same. Is this possible to implement?
Upvotes: 0
Views: 120
Reputation: 4375
Your approach seems a bit convoluted, I see 2 ways you could get job done:
1/ You can have a custom control (treeview or list for instance) that only displays your models, so user can pick one and it gets loaded by the viewer, then it loads model structure in the built-in panel
2/ You create a custom instanceTree which represent your models (but it has to mimic the Forge instanceTree) and you pass it to the built-in modelstructure so it shows your models hierarchy, then user can pick one and it will load in viewer, at which point you load the current model tree inside the panel. Loading data in the modelstructure can be done with:
viewer.modelstructure.setModel(instanceTree);
Personally I would go with approach 1/, as you could customize better your own control rather than fiddling around with the modelstructure which is not designed for that purpose
Upvotes: 1