After importing the obj file into the editor and exporting the geometry to a js file, I encountered an error in Firefox debug saying "Type Error: t1 is undefined". Interestingly, when I changed the model to the .js file exported by MaxExporter with both "Export UVs" and "Export Normals" selected, everything worked perfectly. However, switching to a file exported by MaxExporter with only "Export UVs" selected resulted in the same error "Type Error: t1 is undefined". I'm not sure if this is a bug or an issue with my code. How can I resolve this?
Below is the code I'm using:
var ambient = 0xffffff, diffuse = 0xffffff, specular = 0x000000, shininess = 100;
var shader = THREE.ShaderLib["normalmap"];
var uniforms = THREE.UniformsUtils.clone(shader.uniforms);
uniforms["tNormal"].value = THREE.ImageUtils.loadTexture("md/normals.jpg");
uniforms["uNormalScale"].value.set(1.5, 1.5);
uniforms["tDiffuse"].value = THREE.ImageUtils.loadTexture("md/diff.jpg");
uniforms["enableDiffuse"].value = true;
uniforms["uDiffuseColor"].value.setHex(diffuse);
uniforms["uSpecularColor"].value.setHex(specular);
uniforms["uAmbientColor"].value.setHex(ambient);
uniforms["uShininess"].value = shininess;
var parameters = {
fragmentShader: shader.fragmentShader,
vertexShader: shader.vertexShader,
uniforms: uniforms,
lights: true
};
var material = new THREE.ShaderMaterial(parameters);
loader = new THREE.JSONLoader(true);
loader.load("md/model.js", function (geometry) {
createScene(geometry, 100, material)
});
container.appendChild(renderer.domElement);
window.addEventListener('resize', onWindowResize, false);
}
function createScene(geometry, scale, material) {
geometry.computeTangents();
geometry.computeVertexNormals();
mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
mesh.position.y = -0;
mesh.scale.x = mesh.scale.y = mesh.scale.z = scale;
scene.add(mesh);
}