Hide/show nodes

api

(Rowdysign) #1

Greetings,

I'm currently into the Sketchfab API and I want to hide (or show) certain 3d-objects in my uploaded Sketchfab scene.

I got all the API correctly set-up. I can see the Sketchfab scene in the iframe I'm running locally. The API also tells me in the browser console some statistics like download speed, etc. I also use the getNodeMap() function which tells me that there are 2 objects in the scene (Object {49: Object, 50: Object}). So far, so good I guess.

The Sketchfab scene consists of 3 simple meshes. I want to hide one or more of them. But when I want to hide object 50, the API hides all 3 meshes. When I hide object 49, nothing happens.

I'm aware that it can be possible to hide/show models because I saw the source code of https://forum.sketchfab.com/t/searching-for-a-good-example-of-viewer-api-use-hide-show-objects/5459
I noticed that the getNodeMap() function returns a lot of objects with the scene from the link (including object 49 and 50, but also a lot more). Tried to upload different filetypes (like .blend, .obj) some with multiple 3d meshes and also tried completely different Sketchfab scenes but could not get all the nodes logged, just only "object 49 and object 50".

What am I doing wrong? How can I get getNodeMap() function logging more nodes?


(Klaasnienhuis) #2

Hi @rowdysign,

The nodemap includes a lot of extras besides the actual objects you want to work with. I'm not sure where these come from exactly but I think they are partly generated by sketchfab as well. If you hide the wrong object you might be hiding the entire scene by accident for instance. I've found that if you check the type of the object you want to show/hide you can avoid this. The type should be MatrixTransform.
I've taken the liberty to demonstrate this with one of your public scenes: https://dl.dropboxusercontent.com/u/378324/rowdysign_test.html


Hiding one node, hides the whole model
#3

The secret Inspector tool is a great way to quickly visualize your scene graph:
http://sketchfab.github.io/experiments/model-inspector/index.html?urlid=756477cbf2b74661a9376ec50fcde32c

Clicking a node will hide/show it, and the console will output its nodeID (although, that's not especially helpful because they aren't constant when you re-load the model).


(Rowdysign) #4

Thank you both very much, both examples clarify greatly. I will try to create my own implementation of it shortly. I will let you know if it works. Thanks again.


(Klaasnienhuis) #5

Yes, that's why I always use the object names. You can control these and as long as you make them unique you're all set.


#6

Yep, it's pretty easy to traverse the nodes and test for name and type to define each object


(Jon Russell) #7

Can someone let me know why I cant seem to hide/show this vertex group? I am pretty sure I did this before and it worked, but now it doesnt. I have attached two images. I am using code to hide/show ‘Half’ or e.g. ‘Half1’.

lqeWVpitvolxRsalnH6E_height640Tb90TaowYmlIyqBzAisE_height640


#8

I’m taking a look at the model using our old Inspector experiment. As far as I can tell, there’s one object / node called Cylinder.000 that is a lot of those parts combined.

https://labs.sketchfab.com/experiments/model-inspector/index.html?urlid={{ MODEL_ID }}


(Shaderbytes) #9

because vertex groups are not separate entities in sketchfab you can target with hide/show. Select those group of vertices and separate them and then give that object a unique name. you probably had your object names the same as the vertex group name before hence you thinking the vertex grouyp name matters… it doesnt. Object names matter.


(Jon Russell) #10

Thanks for this. I will have a look into it now.