Hello.
I’m trying to update an old script (rev. 69) which uses the JSON loader. I’ve been able to implement LegacyJSONLoader
and it works fine (although the rest of the script has many issues).
But I’d rather implement the GLTF loader. The first difference I notice is that, while the JSON loader returns one geometry and an array of materials, the GLTF loader doesn’t. And the script requires that single geometry.
So, I’m trying this:
new THREE.GLTFLoader().load(url, function(data) {
var json=data.scene.toJSON(),
geo=new THREE.Geometry();
for(var i=0;i<json.geometries.length;i++) geo.merge(json.geometries[i]);
//...continue with the old method using geo and json.materials
});
But, although it doesn’t fail, the model isn’t loaded or it’s created empty.
I could traverse data.scene
to extract the mesh and then use its geometry, but a GLTF file can contain multiple meshes. That’s why I tried to merge them all.
Is there any simple way to make the two loaders compatible? Without rewriting the whole script.
Thank you.