(updated on 3/17/2023)
This fairly straightforward class essentially creates six cutting planes from the bounding box of a list of nodeids. The result is that only elements inside the bounding box will be visible. While it is of course possible to turn off visibilities of individual elements in HOOPS Communicator this approach allows for quickly “focusing in” on a precise area within a model. This can be particularly useful to limit the view to a “Space” in an IFC model where the individual items within that space are not children of the item in the tree hierarchy and might extend past the defined space.
Usage:
let myClippingBox = new ClippingBox(hwv);
Creates a new ClippingBox object.
myClippingBox.createFromNodes([hwv.selectionManager.getLast().getNodeId()]);
Activates and displays the clipping box from the bounding box of a list of nodeids (in this case the current selection is used)
myClippingBox.deactivate();
Hides the clipping box
myClippingBox.getActive();
If true clipping box is currently visible
myClippingBox.refresh();
Refreshes the clipping box. This function has to be called after a loadSubtree call which in some cases can remove custom cutting planes.
myClippingBox.setOpacity(opacity);
Sets the opacity level of the clip box geometry. (Default: 0.1)
myClippingBox.setEnableOnTop(onoff);
If true clipping box will be rendered on top of the model (Default: True)
myClippingBox.setEnableCutting(onoff);
If true the model will be clipped. (Default: True)
myClippingBox.getEnableCutting();
Returns if cutting planes are active
myClippingBox.calculateEntitiesInVolume(select = true, config = null)
Calculates all entities within the clipping box volume. If select
is set to true, the found entities will be selected. In addition you can provide an optional IncrementalPickConfig object to control how the selection will be performed.
The function will return an array of nodeids which includes all entities found within the volume. This includes entities that are only partially within the volume.
myClippingBox.showMovementHandles();
Adds the standard handles to the clipping box.
The class works well with the new handles operators to interactively change the size and orientation of the clipping box. If you intend to utilize the new handles use the code below to register the ClippingBox class with those handles:
mySHandleManager.registerEventReceiver(function (nodeids) {
myClippingBox.scaleEvent(nodeids[0]);
});
For a live demo of this class you can go here:
https://3dsandbox.techsoft3d.com/?snippet=3lV14CGX266sYaLINLR0sW&fullscreen=true&autorun=true
Below is the code for the ClippingBox class. It has no external dependencies except for the relevant HOOPS Web Viewer libraries. Simply include the JS file into your project.
It is important to note that this code is not production-ready and provided “as-is”. It is really meant as a starting point for your own development and as an example for some of the functionality and concepts used in HOOPS Communicator.
If you have any questions or comments please don’t hesitate to post them here in the forum.
ClippingBox.js (13.4 KB)