Help Needed with Three.ObjectLoader. I am exporting a scene in JSON Format 4.3, containing geometries, materials, and lights. The scene opens error-free in the Three.js Editor.
Working on firefox with Three.js r70 master. View the generated json here: https://gist.github.com/fraguada/d86637f7987096b361ea
In my viewer project, the loading code snippet is as follows:
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' ); }
);
Console output shows:
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)
Error also seen in unminified three.js at line 7674
The issue persists even if creating geometry and objects in the Three.js editor for export as a scene.
The problem seems to be related to this line of code: scene.add(result.scene);
Am I wrong in assuming that THREE.ObjectLoader can process JSON from a file? When I remove scene.add(result.scene);
no errors occur, but no visualized geometry. With scenes having multiple meshes, progress logs in the console (10% loaded, 20% loaded, etc).
Any insights would be greatly appreciated.