GLTF Object loading but not showing up

1k views Asked by At

I'm using three.js and have the scene and everything set up but when I try to load a 3d object (.gltf from here sketchfab 3d object). But the object seems to load fully and then doesn't show up for some reason. The file is being imported correctly.

import laptop from './laptop/scene.gltf'

var objloader = new GLTFLoader();               
    objloader.load(laptop, function (gltf) {
        gltf.scene.scale.set(2, 2, 2);
        gltf.scene.position.set(220, 10, 400)

        scene.add(gltf.scene);
    });  

This error is showing up in the console which doesn't make sense because it should be placed correctly.

RangeError: attempting to construct out-of-bounds TypedArray on ArrayBuffer
1

There are 1 answers

0
Papi On

I have fixed this problem by converting the gltf to glb. The gltf folder had textures folder inside as well as a binary file. Perhaps React was not taking those extra files into account. Because glb is the entire 3d object inside one file with no dependencies.