Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions examples/js/loaders/OBJMTLLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
* @author angelxuanchang
*/

THREE.OBJMTLLoader = function () {};
THREE.OBJMTLLoader = function ( manager ) {

this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;

};

THREE.OBJMTLLoader.prototype = {

Expand Down Expand Up @@ -147,7 +151,7 @@ THREE.OBJMTLLoader.prototype = {
}

}

function add_uvs( a, b, c ) {

geometry.faceVertexUvs[ 0 ].push( [
Expand All @@ -157,19 +161,19 @@ THREE.OBJMTLLoader.prototype = {
] );

}

function handle_face_line(faces, uvs, normals_inds) {

if ( faces[ 3 ] === undefined ) {

add_face( faces[ 0 ], faces[ 1 ], faces[ 2 ], normals_inds );

if (!(uvs === undefined) && uvs.length > 0) {
add_uvs( uvs[ 0 ], uvs[ 1 ], uvs[ 2 ] );
}

} else {

if (!(normals_inds === undefined) && normals_inds.length > 0) {

add_face( faces[ 0 ], faces[ 1 ], faces[ 3 ], [ normals_inds[ 0 ], normals_inds[ 1 ], normals_inds[ 3 ] ]);
Expand All @@ -181,7 +185,7 @@ THREE.OBJMTLLoader.prototype = {
add_face( faces[ 1 ], faces[ 2 ], faces[ 3 ]);

}

if (!(uvs === undefined) && uvs.length > 0) {

add_uvs( uvs[ 0 ], uvs[ 1 ], uvs[ 3 ] );
Expand All @@ -190,7 +194,7 @@ THREE.OBJMTLLoader.prototype = {
}

}

}


Expand Down Expand Up @@ -218,7 +222,7 @@ THREE.OBJMTLLoader.prototype = {

var face_pattern3 = /f( +(\d+)\/(\d+)\/(\d+))( +(\d+)\/(\d+)\/(\d+))( +(\d+)\/(\d+)\/(\d+))( +(\d+)\/(\d+)\/(\d+))?/;

// f vertex//normal vertex//normal vertex//normal ...
// f vertex//normal vertex//normal vertex//normal ...

var face_pattern4 = /f( +(\d+)\/\/(\d+))( +(\d+)\/\/(\d+))( +(\d+)\/\/(\d+))( +(\d+)\/\/(\d+))?/

Expand Down Expand Up @@ -275,7 +279,7 @@ THREE.OBJMTLLoader.prototype = {
} else if ( ( result = face_pattern2.exec( line ) ) !== null ) {

// ["f 1/1 2/2 3/3", " 1/1", "1", "1", " 2/2", "2", "2", " 3/3", "3", "3", undefined, undefined, undefined]

handle_face_line(
[ result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ] ], //faces
[ result[ 3 ], result[ 6 ], result[ 9 ], result[ 12 ] ] //uv
Expand Down Expand Up @@ -304,7 +308,7 @@ THREE.OBJMTLLoader.prototype = {
} else if ( /^o /.test( line ) ) {

// object

meshN();
face_offset = face_offset + vertices.length;
vertices = [];
Expand Down Expand Up @@ -350,7 +354,7 @@ THREE.OBJMTLLoader.prototype = {

//Add last object
meshN(undefined, undefined);

return group;

}
Expand Down
12 changes: 7 additions & 5 deletions examples/js/loaders/SceneLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @author alteredq / http://alteredqualia.com/
*/

THREE.SceneLoader = function () {
THREE.SceneLoader = function ( manager ) {

this.onLoadStart = function () {};
this.onLoadProgress = function() {};
Expand All @@ -16,6 +16,8 @@ THREE.SceneLoader = function () {

this.addGeometryHandler( "ascii", THREE.JSONLoader );

this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;

};

THREE.SceneLoader.prototype = {
Expand Down Expand Up @@ -449,7 +451,7 @@ THREE.SceneLoader.prototype = {

camera.lookAt( new THREE.Vector3().fromArray( objJSON.target ) );

}
}

parent.add( camera );

Expand Down Expand Up @@ -989,7 +991,7 @@ THREE.SceneLoader.prototype = {

texture = new THREE.Texture();
loader = new THREE.ImageLoader();

( function ( texture ) {

loader.load( fullUrl, function ( image ) {
Expand All @@ -1000,9 +1002,9 @@ THREE.SceneLoader.prototype = {
textureCallback();

} );

} )( texture )


}

Expand Down
Loading