提交 a4eae2da 编写于 作者: M Mr.doob

Some more tweaks on OBJLoader. Hopefully it can now serve as a good reference.

上级 49c34190
......@@ -4,8 +4,12 @@
THREE.OBJLoader = function () {};
THREE.OBJLoader.prototype = new THREE.Loader();
THREE.OBJLoader.prototype.constructor = THREE.OBJLoader;
THREE.OBJLoader.prototype.load = function ( url, callback ) {
var that = this;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
......@@ -14,7 +18,9 @@ THREE.OBJLoader.prototype.load = function ( url, callback ) {
if ( xhr.status == 200 || xhr.status == 0 ) {
callback( THREE.OBJLoader.prototype.parse( xhr.responseText ) );
callback( that.parse( xhr.responseText ) );
that.onLoadComplete();
} else {
......@@ -29,14 +35,14 @@ THREE.OBJLoader.prototype.load = function ( url, callback ) {
xhr.open( "GET", url, true );
xhr.send( null );
that.onLoadStart();
};
THREE.OBJLoader.prototype.parse = function ( data ) {
var geometry = new THREE.Geometry();
console.time( 'THREE.OBJLoader.parse()' );
function vertex( a, b, c ) {
return new THREE.Vector3( parseFloat( a ), parseFloat( b ), parseFloat( c ) );
......@@ -128,8 +134,6 @@ THREE.OBJLoader.prototype.parse = function ( data ) {
}
console.timeEnd( 'THREE.OBJLoader.parse()' );
geometry.computeCentroids();
return geometry;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册