Currently, I am working with the Three.js library and trying to implement a Subdivision Modifier on a model. I have been successful in loading a model and applying a subdivision modifier to a CubeGeometry. The code functions properly when the specific line is removed; however, this results in no "subdivisions" being applied. Without these changes, an error occurs in the JavaScript console stating "Uncaught TypeError: Cannot read property 'u' of null". My assumption is that the clone() method was not fully completed before the modify() function was called.
Does anyone have any suggestions on how to resolve this issue?
var loader = new THREE.JSONLoader();
loader.load( "models/parrot.js", function( geometry )
{
var material = new THREE.MeshFaceMaterial();
var mesh = new THREE.Mesh( geometry, material );
mesh.position.set(-50,25,0);
scene.add( mesh );
var smooth = THREE.GeometryUtils.clone( geometry );
smooth.mergeVertices();
var divisions = 2;
var modifier = new THREE.SubdivisionModifier( divisions );
modifier.modify( smooth ); // This is the line causing the error
var mesh2 = new THREE.Mesh( smooth, material );
mesh2.position.set(50,25,0);
scene.add( mesh2 );
});