three-mesh-ui icon indicating copy to clipboard operation
three-mesh-ui copied to clipboard

args as an object doesn't work with @react-three/fiber reconciler

Open saitonakamura opened this issue 4 years ago • 2 comments

Repro: press click in the sandbox

It has to do with the this piece of code in fiber reconciler. If the component is not a r3f instance (instance.__r3f.instance flag indicates it), then r3f assumes that args will be an array (because three js constructors usually have multiple arguments). Obviously it fails with an object.

What I don't understand is whether three-ui-component should be an instance or not. Instance components examples are OrbitControls, mesh, PerspectiveCamera. Non-instance are materials, ambientLight

saitonakamura avatar Aug 09 '21 10:08 saitonakamura

What is interesting is that createInstance (branch when instance.__r3f.instance is true) respects non-array args. Maybe it should be fixed in r3f?

saitonakamura avatar Aug 09 '21 10:08 saitonakamura

Hi @saitonakamura, I'm afraid I won't be able to help with this one, as I don't use r3f at all myself, and the lib is primarily intended for native three.js. If you find a solution involving updating three-mesh-ui, I'm happy to look into your PR.

felixmariotto avatar Aug 09 '21 10:08 felixmariotto