Next (Exporting To Babylon.js) Previous (Exporting)

Exporting To Three.js

Clara.io exports two different Three.JS formats: JSONLoader format if you export a single object, and Scene and Object formats that are loaded via the THREE.ObjectLoader if you have none or multiple nodes selected.

Unfortunately, all both different formats have the same extension, which makes it a bit tricky. What format is exported from Clara.io depends on whether you have a single mesh selected (JSONLoader) or not (ObjectLoader.)

Loading a JSONLoader ThreeJS file

If you export a single object, using the export selection command, use the the JSONLoader.load() function:

var loader = new THREE.JSONLoader();
loader.load( 'monster.json', function ( geometry, materials ) {
    var mesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) );
    scene.add( mesh );
});

Loading an Object and Scene ThreeJS file

If you exported the whole scene or multiple objects, use the ObjectLoader.load() function:

var loader = new THREE.ObjectLoader();
loader.load("zebra.json",function ( obj ) {
     scene.add( obj );
});

Alternatively, use the ObjectLoader.parse() to load the data from an already in-memory JSON object.


Next (Exporting To Babylon.js) Previous (Exporting)