I seem to be having problems with Three.ObjectLoader. I export the scene in 4.3 JSON format. This scene includes geometry, materials and lighting. The scene opens in the Three.js editor just fine, without errors.
I am working on firefox with the Three.js r70 wizard. Here is the link to the generated json: https://gist.github.com/fraguada/d86637f7987096b361ea
In the viewer I'm trying to write, I use the following code to load:
var manager = new THREE.LoadingManager(); manager.onProgress = function ( item, loaded, total ) { console.log( item, loaded, total ); }; // instantiate a loader var loader = new THREE.ObjectLoader(manager); loader.load( // resource URL coming from other file Name, // Function when resource is loaded function ( result ) { scene.add( result.scene ); }, // Function called when download progresses function ( xhr ) { console.log( (xhr.loaded / xhr.total * 100) + '% loaded' ); }, // Function called when download errors function ( xhr ) { console.log( 'An error happened' ); } );
In the console, I see the following:
THREE.WebGLRenderer 70 three.min.js (line 513) 100% loaded content.js (line 117) THREE.Object3D.add: undefined is not an instance of THREE.Object3D. three.min.js (line 164) js/Test83.js 1 1 content.js (line 86)
The error also appears in unminified three.js on line 7674
This problem also occurs if I create geometry and other objects in the Three.js editor and export it as a scene.
The problem seems to be here: scene.add( result.scene ); Are you suggesting that THREE.ObjectLoader can use JSON from the file? In the code I send, if I delete scene.add( result.scene ); , it seems that the file is loading at least (data is being loaded, but the geometry is not visualized), since no errors occur. If I have scenes with many grids, the progress will be displayed on the console (10% loaded, loaded at 20%, etc.).
Any ideas would be greatly appreciated.