Error in OBJLoader of THREE.JS lilbrary

早过忘川 提交于 2019-12-23 04:38:11

问题


I'm trying to follow the examples in that book in order to learn the Three.js library "Learning Three.js: The JavaScript 3D Library for WebGL" and I also have the example sets downloaded from that github link https://github.com/josdirksen/learning-threejs. Most of the examples are runing fine but some of them raises an error especially the one which loads Wavefront objects with OBJLoader.js file. It raises the following error in run time

Uncaught TypeError: undefined is not a function VM12649 OBJLoader.js:66

Corresponding portion of OBJLoader.js is

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;

        }

回答1:


You have downloaded the latest version of the three.js library (probably r68) but the examples are written against version r63 so somethings have changed.

As you can see at https://github.com/mrdoob/three.js/releases in r67 the method computeCentroids was removed from the Geometry.



来源:https://stackoverflow.com/questions/26322640/error-in-objloader-of-three-js-lilbrary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!