Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
Swapping pre-loaded GLTF objects on button click

What I am trying to achieve is have a button that says "Change Models" and then the rendered model disappears and is replaced by one of the other models.

What I have in VS Code Currently

Any help is appreciated and truly means and helps a lot.

The errors that follow

         const Scene = () => {
      const model1 = useGLTF("/assets/Models/City/scene.gltf", true)
    
      const model2 = useGLTF("/assets/Models/Skate/scene.gltf", true)
    
    
      const model3 = useGLTF("/assets/Models/London/scene.gltf", true)
    
    
      const options = [model1,model2,model3]
    
      const [scene, setScene] = useState(city)
      
    
      const onChange = ((e) => {
        setScene => {(
          options[Math.floor(Math.random() * options.length)]
        )
    
        }
    
      })    
      return (
        <primitive object={{scene}.scene} dispose={null} scale={10}  />
      )      
    }
    export default class Home extends React.Component {
        render(){
    
          return(
              <Canvas>
                <Suspense fallback={null}>
                  <Scene />
                </Suspense>
              </Canvas>
          )
        }
    
        
    
    
    
    }

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!