I am trying to load a workshop (glTF file) in my scene but all I get is the error message
Uncaught (in promise) TypeError: Cannot read property 'geometry' of undefined at GLTFLoader.js:2572
I tried opening the file in Three.js
editor and in glTF Viewer and it worked, I also checked the file with glTF Validator and it said the file was valid but I can't figure out why it doesn't with me. I also tried to open another glTF model found on the Internet with my code and it worked just fine.
new Promise(function(resolve, reject) {
const manager = new THREE.LoadingManager();
const gltfloader = new THREE.GLTFLoader(manager);
gltfloader.setCrossOrigin('anonymous');
gltfloader.setDRACOLoader(new THREE.DRACOLoader());
gltfloader.load("data/gltf/salleTP/salleTP.gltf", function (gltf) {
const content = gltf.scene || gltf.scenes[0];
scene.add(content);
}, undefined, reject);
});
It seems you are using three.js R102
and the respective GLTFLoader
version. When loading your glTF
asset, a known error in GLTFLoader
occurs that was fixed with R103
(see https://github.com/mrdoob/three.js/pull/15881). After upgrading your code base to the latest three.js
version, your asset loads fine.
three.js R104