Back to the Shapespark home page

Navigating the nodes in a scene

I am looking for a way to parse all the nodes in a scene.
I am aware that you can interact with a node through the viewer object but I am not aware about how can I get all the nodes present in a scene. Any help would be greatly appreciated.

Thanks!

It’s not possible to get the node hierarchy through the API. However, you can get the list of node types in the scene (there can be multiple nodes of a given node type in the scene) with:

ViewerApi.getEditableNodeTypes()

The list contains only editable node types, that is node types for which

ViewerApi.setNodeTypeEditable(nodeType)

has been called before the scene starts to load. Nodes of editable node types are guaranteed not to be merged with other nodes as a part of scene optimizations. The nodeType argument can be a string or a regular expression.

Would it help for your use case?

I am not sure whether the mentioned API would help me.

Let me explain to you the use case. I am creating a sample flat walkthrough which my user would be able to interact with. In the walkthrough they are allowed to customise certain elements, for eg: the user could click on a wall and apply a wallpaper or they can choose the floor type. The choices for all the elements are provided by us. We want to save the choices that the user has made. So, when the next time they login using their IDs, the wallpaper or the floor they would have chosen in the previous session gets applied automatically in the scene.

We were aiming to solve this by keeping a track of nodes(meshes) they have clicked & the last texture they have applied to it. And when the scene gets loaded the next time we go through this data and apply the respective textures to respective nodes.

I hope I was able to clarify the use case. Please let me know how should we go about solving this.

Thanks!