viewer api spotlight header image

Using the Viewer API to Show or Hide Model Parts

Back to overview


As one of the 3D Generalist’s on the iExcel visualization team at UNMC we create, in some cases, highly detailed anatomy models that we host on Sketchfab for educational and training purposes.  While it’s great to rotate and visualize models directly on Sketchfab, we also needed the ability to show and hide parts of our models, show the name given to each object from our content creation tools such as Maya and Blender. We also wanted the ability to collapse the objects into treeview relationships to help avoid clutter on the extremely large models. The primary goal is to have subject matter experts be able to reference our models and show and hide various parts for a lecture or training session.   As an example, only seeing the outside of a heart is not as useful as being able to hide aspects of the model.

We wanted this solution to work dynamically so that it “just works” for all our models without, if possible, using any external libraries or having to rely on any special naming conventions of our 3D assets.

Working with the Viewer API

I decided to create a simple HTML page that utilizes the Sketchfab Viewer API that we host internally and generate a treeview based on the naming and relationships of the uploaded model. (Side effect: this reveals all of our poor object naming conventions, as you can see in the screenshot below, pointed at one of my personal projects.)  Utilizing the Sketchfab Viewer API, I was able to process the Matrix Transforms recursively and maintain the parent/child relationships of the nodes utilizing arrays and a hash table.  Now that we know the Instance ID’s for each node in the tree we can easily show and hide any part of the model that we want.

viewer api app example

I’m happy to share the generic version of this functionality so you may find a use for it or even help me improve it.

You can see an example of how the app works here.

You can check out your own model or any model for that matter simply by replacing the “id” in the query string with the guid from the URL of any model you want to show and hide parts of.

Also, feel free to fork the code from GitHub and hit me up if you do something cool with it or have improvements!

About the author

Nathanial Ryan

I’m a long-time Blender user currently working as a 3D generalist on the iExcel visualization team at UNMC. I post lots of Blender projects and renders on my twitter account @FullyCroisened if you are interested in all things Blender and XR.


  • Igor says:

    Damn it,, it’s so easy to implement … now I’m afraid that my models will easily be stolen from the site in such ways …

  • Igor says:

    Note that the plugin works fine on my model. It is strange that such a function was not implemented in the server of the skechfab.

    There is also a cool rendering straight from the web

    Lchino used this function today to render models for the Asset store

  • James Green says:

    Hi Igor,

    I’m not sure what you mean by “stolen from the site”. Using the Viewer API to interact with the viewer is not much different than simply looking at models in the “regular” viewer.

  • James Green says:

    Hmm. I’m still not sure I understand the issue. Anyone who knows the URL of a model can view it, embed it, and capture screenshots of it.

  • Igor says:

    James, I meant the download model from the SkethFab browser. It was through the API that access was so easily obtained. Why not copy the mesh, texture and save the same way. (I’m certainly not an expert, that’s why I panic).

    In the second post, I just said that the author of the article had made a useful tool that, surprisingly, would not be implemented into the site like the one for rendering from the screen (link 2)

  • Alexandr says:

    Hi Igor,

    I’m not an expert, but as far as I know there is no realtime rendering capability on your computer unless you load the model and textures directly into your computer’s memory, unless it’s streaming like these game streaming services. So yes, if you have reasons to fear that your model will be copied or your texturing secret sauce will be traced, it is better not to load it into sketchfab, marmoset viewer or anything else, but images/video of render. But for my taste, there is no reason to lose head too much, you can always complain to the administration of any service or someone else, and I am sure it will be banned, and AAA studios will not steal your models anyway, so you will not suffer terrible losses. However as you wish. Generally I understand your fear but skill and knowledge is still yours and it can’t be just downloaded…at least for now)

    Regarding the article, it’s always impressive how people do such things, and it also quite be useful, so it’s cool, nice work, gonna save this link!)

    And I hope I won’t ruin anyone’s mood, but you can find it all in the section:
    It less visual friendly but yeah:

Leave a Reply

Your email address will not be published.

Related articles