Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

194
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda