Hide and isolate
Hide objects, show only a set, show a storey on its own, fit the view to a selection and bring everything back; what the H key, the middle button and F do.
Visibility is a state of the ObjectStateManager: the visible set. Hiding removes objects from it, isolating replaces it, and every viewer connected to the manager draws exactly that set.
Before you start#
You have a viewer with a model loaded and its objectStateManager. Objects are identified by Qid or selected with a BQL query.
Hide#
await objectStateManager.removeFromVisibleSet("GET WHERE type = IFCSPACE");
await objectStateManager.removeFromVisibleSet(objectStateManager.getSelectedQids()); // what H does
await objectStateManager.addToVisibleSet([qid]); // show againHidden objects are also deselected before the viewers are told, so the selection never contains an invisible object.
Isolate#
setVisibleSet replaces the visible set: whatever is not in the argument disappears.
// Only the selection
await objectStateManager.setVisibleSet(objectStateManager.getSelectedQids());
// Only one storey, without its openings; the storey Qids come from a query or the ModelManager
await objectStateManager.setBuildingStoreysVisibleExclusive([storeyQid], true);
// Everything back: original visibility, colours and selection
await objectStateManager.resetAll();resetAll restores the first-load state, in which IFCOPENINGELEMENT, IFCPROJECT, IFCBUILDING, IFCBUILDINGSTOREY and IFCZONE stay hidden. To show literally every object, add modelManager.getAllQids() to the visible set instead.
Fit the view#
await objectStateManager.viewFit(objectStateManager.getSelectedQids(), {margin: 5, animate: true, updatePivot: true});
await objectStateManager.viewFit(objectStateManager.getVisibleQids(), {animate: true}); // what F does with nothing selected
await viewer.viewFitModels([versionUuid]);updatePivot moves the orbit pivot to the centre of the fitted objects, which is what users expect after a focus.
The interactive shortcuts#
- H hides the selected objects through
removeFromVisibleSet, as above. - Middle click hides the object under the pointer when
hideObjectOnMiddleClickis on, which it is by default (reference/viewer3d#hideobjectonmiddleclick). This one is applied by the viewer directly: the ObjectStateManager's visible set is not updated, sogetInvisibleQids()does not list the object and other viewers do not follow.resetAll()brings it back. - F fits the selection, or everything visible when nothing is selected.
A different way to see inside a building without hiding anything is the proximity fade: put the walls, roofs and slabs in the soft-occluder set with objectStateManager.addToSoftOccluderSet("GET WHERE type = IFCWALL"), and they fade out and become pick-through as the camera comes close (viewer.setProximityFadeConfig tunes the distances).
Check#
After setVisibleSet on one storey, objectStateManager.getInvisibleQids().size is the number of objects of all the other storeys, and resetAll() brings them back.