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

190
Views
Load GLTF/GLB Model into NextJS App via HTML input tag with React Three Fiber

I want to provide HTML input to upload own 3d model using GLTF/GLB format from local using React three fiber, react three drei, and three-stdlib within NextJs App, but I received error with the message is

Unhandled Runtime Error TypeError: url.lastIndexOf is not a function

The following is my snippet code, I still don't know which line of code caused error

  1. HTML input for upload

if (e.target.files[0].name?.includes('glb') || e.target.files[0].name?.includes('gltf')) {
    const reader = new FileReader()
    reader.readAsDataURL(e.target.files[0])
    reader.onload = (_url) => {
      setThreeDUrl(_url)
      setThreeDFile(e.target.files[0])
      setShowAudioThumbnailModal(true)
    }
}
return(
  <Canvas>
    <Model1 threeDUrl={threeDUrl} threeDFile={threeDFile} />
  </Canvas>
)

  1. 3D Component

import React from 'react'
import { useLoader } from '@react-three/fiber'
import { GLTFLoader } from 'three-stdlib'
import { OrbitControls } from '@react-three/drei'

const ThreeDModel2 = ({ threeDUrl }) => {
    const loadedGltf = useLoader(GLTFLoader, threeDUrl)

    return (
        <>
            <primitive object={loadedGltf.scene}></primitive>
            <OrbitControls />
            <ambientLight />
        </>
    )
}

export default ThreeDModel2

Is there any suggestion to solve this problem? is my code still haven't worked fine yet? Your help is very thankful for me

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!