0
votes

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
Are you using the latest version of three.js? Also make sure not to use a GLTFLoader from a third-party npm package. - Mugen87
Version 121 and I'm importing it from the examples import {GLTFLoader} from '../../../../node_modules/three/examples/jsm/loaders/GLTFLoader'; - Stasys Meclazcke

1 Answers

1
votes

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.