I've been delving into the teachings of the Three.js library through the book "Learning Three.js: The JavaScript 3D Library for WebGL" and I've also downloaded the example sets from the corresponding GitHub repository https://github.com/josdirksen/learning-threejs. While most of the examples work smoothly, I've encountered some errors, particularly with the one that involves loading Wavefront objects using the OBJLoader.js file. During runtime, it throws the following error:
Uncaught TypeError: undefined is not a function VM12649 OBJLoader.js:66
The problematic section of the OBJLoader.js file is as follows:
function meshN( meshName, materialName ) {
if ( geometry.vertices.length > 0 ) {
geometry.mergeVertices();
geometry.computeCentroids(); //EXCEPTION RASED HERE !!!!!
geometry.computeFaceNormals();
geometry.computeBoundingSphere();
object.add( mesh );
geometry = new THREE.Geometry();
mesh = new THREE.Mesh( geometry, material );
verticesCount = 0;
}