Convert ThreeJS to React-three-fiber #1986
Replies: 1 comment
-
i would recommend not going to crazy with things that are inherently imperative. it probably can be done but i wouldnt want to loose sleep over it, there are things in threejs that need to be driven by function calls and that's fine because react has hooks for that: function Foo() {
const ref = useRef()
useLayoutEffect(() => {
...
ref.current.setIndex(whatever)
}, [])
return <foo ref={ref} /> useLayoutEffect fires after the jsx has rendered, so the objects exist, but before it is committed and rendered out by threejs, so there's no flash of unstyled content or anything like that. attach is geoing to be much easier btw #1912 v8 will be released in a few days (when react 18 comes out). but again, there may be cases where you call functions, and that's always a side effect (-> layout effect). |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I'm trying to convert the following code to react-three-fiber, however, it doesn't work.
Here is the code I have in ThreeJS, this is working fine.
Then I try to use this in React and decided to use react-three-fiber.
After the conversion, I cannot make it to work.
The data source is exactly the same. I'm so confused right now.
I was suspected that my
attach="index"
is not correct but I can't find much document about it.This is the error that appear on my console.
[.WebGL-0x7fdb8a8ada00]GL ERROR :GL_INVALID_ENUM : glDrawElements: type was GL_FLOAT
Beta Was this translation helpful? Give feedback.
All reactions