简体   繁体   English

THREE.JS库的OBJLoader错误

[英]Error in OBJLoader of THREE.JS lilbrary

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 . 我正在尝试遵循该书中的示例,以学习Three.js库“学习Three.js:WebGL的JavaScript 3D库”,并且我还从该github链接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. 大多数示例运行良好,但其中一些引发了错误,尤其是使用OBJLoader.js文件加载Wavefront对象的示例。 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 OBJLoader.js的对应部分是

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;

        }

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. 您已经下载了Three.js库的最新版本(可能是r68),但是这些示例是针对r63版本编写的,因此发生了一些变化。

As you can see at https://github.com/mrdoob/three.js/releases in r67 the method computeCentroids was removed from the Geometry . 正如您在r67中的https://github.com/mrdoob/three.js/releases上看到的那样,已从Geometry中删除了computeCentroids方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM