function loadModel(file:any) {
return new Promise((res, rej) => {
const loader = new GLTFLoader();
loader.load(file, function (gltf) {
res(gltf.scene);
}, undefined, function (error) {
rej(error);
});
});
}
this.glasses = await loadModel(`/${glassUrl}`);
This code was working fine days ago and today I open it and I suddenly get this error. I even switched to the previous versions of my applications in the repo where I validated that it was working correctly and pushed and in those versions too suddenly I got this error.
Not enough info… can you reproduce it in a fiddle, and/or post the model itself?
1 Like
async function loadGlasses() {
const glasses = await loadModel(`/3d/glasses/scene.gltf`);
const bbox = new THREE.Box3().setFromObject(glasses);
const size = bbox.getSize(new THREE.Vector3());
}
function loadModel(file:any) {
return new Promise((res, rej) => {
const loader = new GLTFLoader();
loader.load(file, function (gltf) {
res(gltf.scene);
}, undefined, function (error) {
rej(error);
});
});
}
useEffect(()=>{
loadGlasses();
},[])
scene.gltf (1.8 MB)
This is the simple code.
The model is actually accessible like the route is not wrong. I have attached the model too.
async function loadGlasses() {
const loader = new GLTFLoader()
const glb = await loader.loadAsync(`./3d/glasses/scene.gltf`);
const glasses = glb.scene;
const bbox = new THREE.Box3().setFromObject(glasses.scene);
const size = bbox.getSize(new THREE.Vector3());
}
I shortened your loading code ^
I don’t see where you actually add the “glasses” to the scene, so not surprising that you’re not seeing anything?
You’re close!
( I dragged your gltf file onto here: https://gltf-viewer.donmccurdy.com/ ) and it rendered ok so, you’re reaal close.)