I am attempting to import an external JSON model into the scene and assign its value to a variable called head, and then add it to the scene.
This is what I have done:
var loader = new THREE.JSONLoader();
this.head = loader.load( "eagle2.js", function( geometry ) {
var material = new THREE.MeshPhongMaterial(), head;
head = new THREE.Mesh( geometry, material );
head.scale.set( 200, 200, 200 );
head.position.y = 0;
return head;
} );
this.mesh.add(this.head);
My goal is to load the JSON model and assign all the meshes to the head variable within the current function. However, when I execute the code above, it shows a type error in the console. The model loads successfully, but the error message is:
TypeError: a is undefined Three.js Line 55
How can I fix this error?