‌Best way of traverse (high performance in large models)

Hi
Imagine I have a large model of 300MB with a lot of objects.
I have 10 groups in My object.
What is the best way to filter, find, and select my Groups?
I think traversing all objects can cause low performance

Traverse is fast but not something you want to do every frame. (Unless your scene is simple in which case it’s fine)

When you call renderer.render the first thing it does internally is a traverse.
Like. Even for the most complex scene with 1 million objects… Just traversing it should only take a few milliseconds.

There are methods like “getobjectbyname” and similar but they all use something like .traverse internally anyway.

If you have a poorly performing scene… it’s usually not traverse that is the “bottleneck” but rather what you are doing inside your traverse.

What is giving you the impression that traversing is slow?

Perhaps you can combine some of your operations into a single traverse instead of doing repeated traverses?

for instance… finding multiple named groups could be done like:

let groupNames={
   "joe":true,
   "bob":true,
  "steve":true
}
let results=[]
scene.traverse(e=>{if(groupNames[e])results.push(e)})

1 Like