News for hackers. Stuff that matters.
Re:React Renderer for Three.js by tills13 on Sunday August 15, 2021 @03:43PM (#28191847)
Oops, I guess it's not undefined, but it'll attempt to render a ref object.

const mesh = useRef()

<mesh />

The underlying JavaScript (i.e. not JSX) on the first render , is React.createElement(mesh /* { current: undefined } */, { ref: mesh } )

In fact, I don't even think it matters which render you're talking about. It's still rendering a ref (again, { current: <undefined or a Three.MESH, I guess> }). That doesn't seem right to me.

Re:React Renderer for Three.js by petrbela on Sunday August 15, 2021 @08:03PM (#28193713)
Actually, the compiled JS is `React.createElement('mesh', { ref: mesh } )`. JSX compiler converts all lower-case names to strings. Only upper-case name (and composites like `rn.View`) are converted to variables.

The reason r3f uses lower-case names for built-in components is to distinguish them from your own components; from the documentation: "It merely expresses Three.js in JSX: <mesh /> becomes new THREE.Mesh(), and that happens dynamically." So whenever you see <mesh /> or anything else lower-case it is just an JSX alias for a Three.js core component. Note that they're not HTML tags in the resulting output; since they're rendered inside <Canvas />, they're transformed to Three.js automatically.

Re:React Renderer for Three.js by tills13 on Monday August 16, 2021 @12:06AM (#28194839)
Ah, right. It's very obvious in hindsight. Thank you for clarifying.
Re:React Renderer for Three.js by afloatboat on Sunday August 15, 2021 @05:54PM (#28192899)
Ah, right. But the mesh useRef is not wat is being rendered, the `mesh` component is more like rendering a div. If you open the sandbox and remove the useRef mesh and references it will still work.

Pretty confusing though, would have been better to call it `meshRef`. I also expected these components to be capitalised, but it probably makes sense in the way that in the dom renderer default components are lowercase as well.

Re:React Renderer for Three.js by tills13 on Monday August 16, 2021 @12:07AM (#28194841)
yeah imo simply changing the variable name of the ref would go a long way, here.