Posted By

Philippe Leefsma
I write JavaScript for the future 3D World Wide Web, A.K.A Forge Platform
29 May 2017
This week post illustrates how you can control the selectability of any components in the Forge Viewer. There may be scenarii where you want to enforce or restrict user selection to a specific group of components, that either match a given property, based on their parent component or a set of predefined dbIds...
There are three interaction paths you need to control to achieve that:
The SelectionFilter extension is an example of such implementation. It generates a treeview that represents the model structure, allowing to specify exactly which components can be selected or not. An active switch means the component is selectable. There is also some internal logic in the tree that will disable all child components if a parent is disabled. Internally the extension maintains a table of all dbIds set to a boolean value to indicate if each component is selectable or not.
Another remarkable aspect of this extension is that it supports multiple models loaded in the same scene. This is possible with not much more complexity because it is using my base class MultiModelExtensionBase, exposed in a previous post: Preparing your viewing application for multi-model workflows.
You can have a play with the live version of the SelectionFilter there and refer to the full source code on github. Use the Model Loader to add an extra model to the scene and control selectability of various components in each model.