How to match name to index in nodemap?


I’m looking for a way to find the index (and subsequently the InstanceID) of a given name in the node map.

The viewer API documentation states that nodes is a “flattened array of node objects”. I’ve tried indexOf to no avail and my hunch is that nodes is more complex than a standard array.

Shaderbytes excellent utility is out of the question I’m afraid since I’m planning on using both animation and hover events which afaik aren’t supported.

Any help would be mighty appreciated!


InstanceID is what index the flattened array “nodemap”, or you can find it in the nodegraph.
its an immutable node property you can use to direclty access a node in the nodemap.
you would only need names for debug session once you get the node instance ID

Anyway here’s a sample that creates NodesByName using either nodegraph or nodemap.

1 Like

Many thanks Paul!

Exactly what I was looking for. I’ll be studying the code and soaking up all the goodness.

I see your point about InstanceIDs, but as long as the performance hit isn’t to bad, I’d rather use names since my project will be going through numerous iterations a week when live, and seeing as Sketchfab seems to jumble the IDs every time i re-upload that seems like the safer bet.

Cheers /Erik

It seems this example doesn’t work anymore? I am at a loss regardign finding the node instance IDs.

In the model inspector the graph displays totally different numbers and I don’t know how to find them otherwise.

the sample still works here
Be sure to check browser devtools console logs to find the list of nodes
(can be listeed as an “> Object” where clicking on the > unfold the list)

( Labs Model inspector use old viewer api code so it’s not the same ID as now, so it cannot be used for this )