THREE.JS lilbrary的OBJLoader出错 [英] Error in OBJLoader of THREE.JS lilbrary

查看:382
本文介绍了THREE.JS lilbrary的OBJLoader出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按照该书中的示例来学习Three.js库学习Three.js:用于WebGL的JavaScript 3D库,我还有从该github链接下载的示例集 https://github.com/josdirksen/learning-threejs 。大多数示例运行正常,但其中一些会引发错误,尤其是使用OBJLoader.js文件加载Wavefront对象的错误。它在运行时引发以下错误

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

未捕获TypeError:undefined不是函数VM12649 OBJLoader.js:66

OBJLoader.js的对应部分是

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;

        }


推荐答案

你有下载了最新版本的three.js库(可能是r68)但是这些例子是针对r63版本编写的,所以有些事情已经改变了。

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.

正如您在 https:/ r67中的/github.com/mrdoob/three.js/releases 方法 computeCentroids 已从 Geometry

这篇关于THREE.JS lilbrary的OBJLoader出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆