I’m trying to upload a GLTF
object into Three.js
and it will give me an error. I tried to follow this tutorial and he doesn’t get any errors while I have errors. I downloaded the model from sketchhfab and is this model. Trying to load the model with this code but I don’t know why I have errors.
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
const chestObject = new URL('../../assets/treasure_chest/scene.gltf', import.meta.url)
const gltfLoader = new GLTFLoader();
gltfLoader.load(chestObject.href, function(gltf){
const model = gltf.scene;
scene.add(model);
model.position.set(-7, 4, 10)
}, undefined, function(error){
console.error(error);
})