Here's the issue I'm facing:
I created a scene in Blender and exported it using the io_three addon.
The resulting JSON file contains all objects when the scene option is selected during export.
If I do not select this option, only the currently selected object is exported.
The Problem:
I am unable to display the entire scene using Three.js. When I load the file, I only see the background and not the actual scene.
Here is how my loader looks:
var loader = new THREE.JSONLoader();
loader.load('test.json', function(geometry, material){
var materials = new THREE.MeshFaceMaterial(material);
mesh = new THREE.Mesh(geometry, materials);
scene.add(mesh);
});
An error I encounter:
Uncaught TypeError: Cannot read property 'length' of undefined(anonymous function) @ three.min.js:268THREE.JSONLoader.parse @ three.min.js:271f.onreadystatechange @ three.min.js:266
The JSON file generated (which includes 2 basic cubes with textures):
{
"textures": [{
"image": "E30E1CC2-2152-3E22-8467-D5845ECA8529",
"anisotropy": 1,
"repeat": [1,1],
"magFilter": "LinearFilter",
"mapping": "UVMapping",
"uuid": "F7F25B99-8709-3776-8D32-B0774203CF6B",
"type": "Geometry",
"name": "Tex",
"wrap": ["RepeatWrapping","RepeatWrapping"],
"minFilter": "LinearMipMapLinearFilter"
}],
// Additional JSON data goes here
}
I have tried using 'test.js', OBJLoader, OBJMTLLoader, and searched for similar issues online but haven't found a solution yet. Could someone please point out what I might be doing wrong or provide a simple example where loading and displaying multiple objects works correctly in Three.js? It seems to work fine when working with a single cube without using the scene option, but I'm struggling to figure out how to load and display a complete scene comprising multiple objects from a JSON file.