In my work with Blender, I am utilizing io_three for exporting an entire scene including a Torus, a Sphere, Suzanne (also known as the Money Head), a Camera, and a Point of Light (Lamp). When I receive the JSON file from this export, it contains these elements nested as children:
"object":{
"type":"Scene",
"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
"uuid":"3FF28BA1-D2C4-4191-B85E-6CF740855E1C",
"children":[{
"name":"Camera",
"uuid":"B7190F03-3E64-4CE9-80C4-4C4830CDE149",
...
}]
}
Now, in order to import the complete scene using the Object Loader so that I have everything together rather than separate objects:
var Sphere;
var Monkey;
var BlenderCam;
var loader = new THREE.ObjectLoader();
// load a resource
loader.load(
// resource URL
'models/suzane/scene.json',
// Function when resource is loaded
function ( loadedScene ) {
...
loop();
}
);
I can handle meshes like the Torus, Suzanne, and Sphere successfully. However, I am facing difficulty in handling the Camera or Lamp objects.
I attempted to locate each child object using:
BlenderCam = loadedScene.children[ 0 ];
Even after trying various indexes from 0 to 4 (there are 5 children), only three of them are recognized by Three.js, ignoring the Camera and Lamp objects. Moving the Lamp's position in the JSON file didn't change this behavior, where only children[0], children[1], and children[2] are accessed, with children[0] representing the Sphere instead of the Camera. Hence, the Camera is seemingly being overlooked.
My questions are:
- Is there a method to utilize the Camera defined in the JSON file?
- Can the Lamp object from the JSON file be utilized?
Essentially, I aim to design everything in Blender and then seamlessly import the whole scene including objects, camera, and light to Three.js. Any guidance on this matter would be highly appreciated. Thank you in advance for your assistance!