Replies: 1 comment 1 reply
-
If you do it like this suspense makes no sense, it does nothing. But it's almost correct, useMemo should be a useEffect. function MmdModel({ url }) {
const [nodes, set] = useState()
useEffect(() => void new MMDLoader().load(url, set), [url])
return nodes ? <primitive object={nodes} dispose={null} /> : null
}
<Canvas>
<MmdModel url="PATH_TO_PMX_FILE"/>
</Canvas> Not that this solves your issue, it's probably a wrong path or the file is broken. the path either has to be "/file.pmx" if it's located in /public, or, if it's withing /src you have to I would suggest suspense + useLoader, function MmdModel({ url }) {
const nodes = useLoader(MMDLoader, url)
return <primitive object={nodes} dispose={null} />
}
<Canvas>
<Suspense fallback={null}>
<MmdModel url="PATH_TO_PMX_FILE"/>
</Suspense>
</Canvas> but as I said, your problem is something else. btw, it looks like you are creating component functions inside a component: function App() {
function LoadModel({url}) { ... }
const MmdModel = () => ...
return ( this is an anti pattern: https://twitter.com/0xca0a/status/1269562072725098501 if that's the case it could even be the reason why you run into issues, because that pattern unmounts/remounts the components on every single render. unmount in r3f disposes objects (as in, it destroys geometries and materials, hence the |
Beta Was this translation helpful? Give feedback.
-
How can I render MMD Model?
I'm trying to render MMD Model like this
But this is not working
・error message
THREE.WebGLProgram: shader error: 1281 35715 false gl.getProgramInfoLog invalid shaders THREE.WebGLShader: gl.getShaderInfoLog() vertex
Beta Was this translation helpful? Give feedback.
All reactions