Viewer API Utility Updates 2

(Shaderbytes) #1

Hey there devs

I have added and changed some things to make life easier for us all again.

The main focus was to abstract and enhance the current click event for the viewer. I discovered that the current sketchfab event returns instance ID's , and also detects them on the geometry node types.

Since my tool gives preference to imported node names, and the node names on geometry nodes are generated derivatives of the object names we want to use, I altered the initialization of the Utility to now cycle the geometry nodes as well , but maps them via instanceID to their relevant parent MatrixTransform node. ( the ones with the names we care about )

I then changed getNodeObject function to be able to accept either an object name (MatrixTransform) or an instanceID (MatrixTransform or Geometry) and it will always return the relevant matrix transform object.

Not to worry you dont even have to call this yourself - in my abstraction of the click event I perform this for you and then write an additional variable onto the event named "node"

If this all sound confusing here is a quick explanation. If you create a 3d scene of a car and it has 3 objects in the scene named body , windows and tyres and use my Utility's click event wrapper then you can simply deal with clicking on those objects and test for those names , simple.

a code example :

function onSketchfabUtilityReady() {

    sketchfabAPIUtility.addEventListener('click', onSketchfabClick);


function onSketchfabClick(e) {

    if ( == "Body") {
        // do something


(Draconius) #2

This is really cool!! Makes selections so much easier. Do you think there's any possibility of applying the same principle to material IDs? Would make scene breakdowns much more understandable. But this in itself is pretty intuitive. Thanks for sharing!

(Shaderbytes) #3

can you explain? My Utility already uses material names as keys for all material related functionality.

eg :

 sketchfabAPIUtility.setColor("ThumbSticks", sketchfabAPIUtility.AlbedoPBR, data.colorHex);
 sketchfabAPIUtility.setFactor("D-Pad", sketchfabAPIUtility.MetalnessPBR, 1);