How to match name to index in nodemap?

(Wakyak) #1


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!


(Paul Sketch) #2

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.

(Wakyak) #3

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