Reach each buldings in one gbl file

hi people

I build a project where I have a gbl 3d model map of university buildings and I should implement this map in next.js, but the problem is how I can reach each building to make onclick functions.

you should consider that buildings are in one GBL file

You can either use glb.scene.getObjectByName

Or scene.traverse( e=> console.log(e) )

To print all the nodes in the scene.

Alternatively, since you’re already bound to react by next - you can convert the GLB into a JSX component using gltf-jsx and bind the events directly.

the command is

npx gltfjsx yourmodel.glb --transform

and the problem is solved. this wouldn’t be straight forward otherwise and you would have to create a lot of boilercode for hover and clicks. in react your models are declarative, you can just add event handlers.