pmndrs / gltfjsx

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

How can I add a new scene in gltfjsx? #79

Closed sourabpramanik closed 3 years ago

sourabpramanik commented 3 years ago

Screenshot from 2021-05-06 17-34-53 @drcmda I was watching a video https://www.youtube.com/watch?v=2pUzJOfekVE&t=1025s by Yuri Artyukh and in place of using a simple sphere I wanted to use a gltf model of earth like you can see in my repo https://github.com/sourabpramanik/fff, but I don't know how to setup the line from Three like Yuri did to connect the coordinates in my gltfjsx can you help me. Here is the javascript https://github.com/sourabpramanik/fff/blob/main/src/component/Planet.js also if you have any model to demonstrate it will be easy.

drcmda commented 3 years ago

gltfjsx is good when you need to make changes to the models contents, you can have that planet in two lines otherwise:

function Planet(props) {
  const { scene } = useGLTF(url)
  return <primitive object={scene} {...props} />
}

<Planet position={[1, 2, 3]} />

it would best best to study r3f at least a little https://docs.pmnd.rs/ that would make things easier. also has lots of examples there.

sourabpramanik commented 3 years ago

Actually I am new to this three.js so can you please take some time out and show that to me how it will happen.