21 Mar 2018

Event monitor for the Viewer

In order to understand what is going on inside the Viewer it can be useful to see the events that are firing at certain points.

Philippe already has a nice and polished solution for this implemented inside an Extension. However, I thought the below quick and dirty solution could be useful as well since it could be even used with the Viewer on the various Autodesk storage websites like A360 as described in this article - see above image.

function subscribeToAllEvents (viewer) {
    for (var key in Autodesk.Viewing) {
        if (key.endsWith("_EVENT")) {
            (function(eventName) {
               viewer.addEventListener(
                    Autodesk.Viewing[eventName],
                    function (event) {
                        console.log(eventName, event);
                    }
                ); 
            })(key);
        }
    }
}

 

Related Article