Attempting to load an object model with the code snippet below:
var loader = new THREE.JSONLoader();
loader.load('js/spacecraft.js', modelLoadedCallback);
function modelLoadedCallback(geometry) {
spacecraft = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial(geometry.materials));
spacecraft.position.x = 0;
spacecraft.position.y = 0;
spacecraft.position.z = 0;
mesh.add(spacecraft);
scene.add( mesh );
}
However, each time renderer.render(..) is called, I encounter this error message:
Uncaught TypeError: Cannot read property 'visible' of undefined
Despite both mesh and spacecraft objects appearing to be loaded correctly when checked in the console, I am puzzled by this error. Any suggestions on what might be wrong with the JSONLoader?