gltfLoader and objLoader not working

i’m getting errors.
for the gltfLoader
code

    const gltfLoader = new GLTFLoader();
    const url = '/public/assets/phone.gltf';
    gltfLoader.load(url, (gltf) => {
      const object = gltf.scene;
      scene.add(object);
    });

error
for the objLoader
code

    objLoader = new OBJLoader()
    objLoader.setPath('/public/assets/')
    objLoader.load('phone.obj', function(object) {
        console.log(object)
        object.position.y -= 60
        scene.add(object)
    })

error1

i have found no working solutions on these.

Hi, it looks like you are using a project created with Create React App.

You should remove “/public” from the beginning of your URLs. The public folder content will be served at the server root.

2 Likes

gotchu. if i remove public it doesn’t find my assets folder. i put my assets folder in public.
test

I would try visiting http://localhost:3000/assets/phone.gltf (or whatever port you’re running this on) and see what you get back. If they file is there you probably also have another issue.

1 Like

the file downloaded. so it is there. this is beyond me man. i read a solution that i didn’t really understand… someone had to go into the actual gltfloader module and change a few lines of code. but it wasn’t clear what he changed. he just said he did, lol.

another statement i found was

web server does not serve a glb but HTML content.

but had nothing else to say about it.

that’s not random, that’s the arraybuffers (meshes, vertices, …).

the correct path should be const url = ‘/assets/phone.gltf’

1 Like

you’re getting a 404 back, this is what the error messages mean. it’s trying to parse the 404 html page as gltf, so pretty certain your only issue is the path. there is nothing wrong with base64 inside gtlf’s.

1 Like

wow okay. so it was the path…? but i tried multiple different paths. so that’s annoying. but thank you to both of you for the help.

i’m guessing what i did was i tried different path so many times and maybe forgot to try it again when i put my assets into public folder. idk.