pmndrs / gltfjsx

🎮 Turns GLTFs into JSX components
https://gltf.pmnd.rs
MIT License
4.4k stars 289 forks source link

How to rewrite gltfjsx generated jsx file to separate geometry and material #257

Open shunmian opened 2 months ago

shunmian commented 2 months ago

I have generated jsx file by gltfjsx with following result

export function Model(props) {
  const { nodes, materials } = useGLTF('./models/Common/Model.glb')
  return (
    <group {...props} dispose={null}>
      <mesh castShadow geometry={nodes.001.geometry} material={materials.001} />
    </group>
  )
}

Is it possible to rewrite above jsx into something like below?

export function Model(props) {
  const { nodes, materials } = useGLTF('./models/Common/Model.glb')
  return (
    <group {...props} dispose={null}>
      <mesh>
        <SomeGeometry buffer={nodes.001.geometry} />
        <SomeMaterial buffer={materials.001}
      </mesh>
    </group>
  )
}

Anyone can help?

jo-chemla commented 2 months ago

The ability to explode meshes geometry and materials in the component tree has been requested in this thread