Scale Handles Operator

HOOPS Communicator currently does not include the ability to interactively scale geometry as part of its default handle types. The operator below implements that functionality by allowing the user to scale the content of a node along each major axis separately or uniformly along all axis.

The implementation is fairly straightforward and just like the standard handles in HOOPS Communicator utilizes the overlay functionality to quickly draw the handles on top of other geometry and to filter selection. One difference from the standard handles is that it will take the rotation of the node the handles are attaching to into account when placing the handles.


To activate the operator simply add the code below:

myScaleHandles = new ScaleHandles(hwv);
let scaleHandlesId = hwv.operatorManager.registerCustomOperator(myScaleHandles);
hwv.operatorManager.push(scaleHandlesId);

This will add the new operator to the top of the operator stack.

myScaleHandles.show(hwv.selectionManager.getLast().getNodeId());

The show function activates the handles for a given nodeid. Only one set of handles can be active at a given time and handles can only be attached to a single node.

myScaleHandles.hide()

Hides the currently active handles.

myScaleHandles.registerEventReceiver(function (nodeid) {
       //do something               
    });

It is possible to register one or more callback functions that get executed whenever the matrix of the target node is changed by the scale handles.


Below is the main code for the ScaleHandles class. It has no external dependencies except for the relevant HOOPS Web Viewer libraries and the also attached ViewerUtility class. Simply include the js 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.

ViewerUtility.js (5.6 KB)
ScaleHandles.js (10.7 KB)