Izzimach / react-three-legacy

React bindings to create and control a 3D scene using three.js
Other
1.52k stars 128 forks source link

Performance with pointer events if a lot of objects are on the scene #100

Open macrozone opened 7 years ago

macrozone commented 7 years ago

The function projectPointerEvent raycasts on every child, no matter if a certain child needs pointer events.

It would probably better to filter out children that not have defined onClick3D or similar.

Also it would probably good to be able to assign additional event listeners to the <Scene>-Component (e.g. as mentioned here https://github.com/Izzimach/react-three/issues/87)

Izzimach commented 7 years ago

I don't really want to proscribe a specific baked-in strategy to handle many objects, since it can depend on how the scene is specifically set up.

Maybe allow the user to provide a custom raycast handler, with the fallback/default being what it is now, just iterating over all children?