2
0
Эх сурвалжийг харах

Merge branch 'addFunctionDefintions' of https://github.com/gero3/three.js into dev

Conflicts:
	examples/js/wip/TypedGeometry.js
	src/objects/Mesh.js
Mr.doob 10 жил өмнө
parent
commit
22cad1ab86

+ 4 - 4
examples/js/controls/OrthographicTrackballControls.js

@@ -123,7 +123,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
 
 		var vector = new THREE.Vector2();
 
-		return function ( pageX, pageY ) {
+		return function getMouseOnScreen( pageX, pageY ) {
 
 			vector.set(
 				( pageX - _this.screen.left ) / _this.screen.width,
@@ -142,7 +142,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
 		var objectUp = new THREE.Vector3();
 		var mouseOnBall = new THREE.Vector3();
 
-		return function ( pageX, pageY ) {
+		return function getMouseProjectionOnBall( pageX, pageY ) {
 
 			mouseOnBall.set(
 				( pageX - _this.screen.width * 0.5 - _this.screen.left ) / _this.radius,
@@ -192,7 +192,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
 			quaternion = new THREE.Quaternion();
 
 
-		return function () {
+		return function rotateCamera() {
 
 			var angle = Math.acos( _rotateStart.dot( _rotateEnd ) / _rotateStart.length() / _rotateEnd.length() );
 
@@ -270,7 +270,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
 			objectUp = new THREE.Vector3(),
 			pan = new THREE.Vector3();
 
-		return function () {
+		return function panCamera() {
 
 			mouseChange.copy( _panEnd ).sub( _panStart );
 

+ 5 - 7
examples/js/controls/TrackballControls.js

@@ -115,7 +115,7 @@ THREE.TrackballControls = function ( object, domElement ) {
 
 		var vector = new THREE.Vector2();
 
-		return function ( pageX, pageY ) {
+		return function getMouseOnScreen( pageX, pageY ) {
 
 			vector.set(
 				( pageX - _this.screen.left ) / _this.screen.width,
@@ -132,7 +132,7 @@ THREE.TrackballControls = function ( object, domElement ) {
 
 		var vector = new THREE.Vector2();
 
-		return function ( pageX, pageY ) {
+		return function getMouseOnCircle( pageX, pageY ) {
 
 			vector.set(
 				( ( pageX - _this.screen.width * 0.5 - _this.screen.left ) / ( _this.screen.width * 0.5 ) ),
@@ -154,7 +154,7 @@ THREE.TrackballControls = function ( object, domElement ) {
 			moveDirection = new THREE.Vector3(),
 			angle;
 
-		return function () {
+		return function rotateCamera() {
 
 			moveDirection.set( _moveCurr.x - _movePrev.x, _moveCurr.y - _movePrev.y, 0 );
 			angle = moveDirection.length();
@@ -183,9 +183,7 @@ THREE.TrackballControls = function ( object, domElement ) {
 				_lastAxis.copy( axis );
 				_lastAngle = angle;
 
-			}
-
-			else if ( !_this.staticMoving && _lastAngle ) {
+			} else if ( !_this.staticMoving && _lastAngle ) {
 
 				_lastAngle *= Math.sqrt( 1.0 - _this.dynamicDampingFactor );
 				_eye.copy( _this.object.position ).sub( _this.target );
@@ -242,7 +240,7 @@ THREE.TrackballControls = function ( object, domElement ) {
 			objectUp = new THREE.Vector3(),
 			pan = new THREE.Vector3();
 
-		return function () {
+		return function panCamera() {
 
 			mouseChange.copy( _panEnd ).sub( _panStart );
 

+ 5 - 5
examples/js/exporters/STLBinaryExporter.js

@@ -3,7 +3,7 @@
  * @author mrdoob / http://mrdoob.com/
  * @author mudcube / http://mudcu.be/
  */
- 
+
 THREE.STLBinaryExporter = function () {};
 
 THREE.STLBinaryExporter.prototype = {
@@ -15,7 +15,7 @@ THREE.STLBinaryExporter.prototype = {
 		var vector = new THREE.Vector3();
 		var normalMatrixWorld = new THREE.Matrix3();
 
-		return function ( scene ) {
+		return function parse( scene ) {
 
 			var triangles = 0;
 			scene.traverse( function ( object ) {
@@ -64,16 +64,16 @@ THREE.STLBinaryExporter.prototype = {
 
 					}
 
-					output.setUint16(offset, 0, true); offset += 2; // attribute byte count					
+					output.setUint16(offset, 0, true); offset += 2; // attribute byte count
 
 				}
 
 			} );
-			
+
 			return output;
 
 		};
 
 	}() )
 
-};
+};

+ 3 - 3
examples/js/exporters/STLExporter.js

@@ -2,7 +2,7 @@
  * @author kovacsv / http://kovacsv.hu/
  * @author mrdoob / http://mrdoob.com/
  */
- 
+
 THREE.STLExporter = function () {};
 
 THREE.STLExporter.prototype = {
@@ -14,7 +14,7 @@ THREE.STLExporter.prototype = {
 		var vector = new THREE.Vector3();
 		var normalMatrixWorld = new THREE.Matrix3();
 
-		return function ( scene ) {
+		return function parse( scene ) {
 
 			var output = '';
 
@@ -72,4 +72,4 @@ THREE.STLExporter.prototype = {
 
 	}() )
 
-};
+};

+ 3 - 3
examples/js/renderers/RaytracingRenderer.js

@@ -103,7 +103,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
 
 		}
 
-		return function ( rayOrigin, rayDirection, outputColor, recursionDepth ) {
+		return function spawnRay( rayOrigin, rayDirection, outputColor, recursionDepth ) {
 
 			var ray = raycaster.ray;
 
@@ -355,7 +355,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
 		var tmpVec2 = new THREE.Vector3();
 		var tmpVec3 = new THREE.Vector3();
 
-		return function ( outputVector, point, shading, face, vertices ) {
+		return function computePixelNormal( outputVector, point, shading, face, vertices ) {
 
 			var faceNormal = face.normal;
 			var vertexNormals = face.vertexNormals;
@@ -424,7 +424,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
 
 		var pixelColor = new THREE.Color();
 
-		return function ( blockX, blockY ) {
+		return function renderBlock( blockX, blockY ) {
 
 			var index = 0;
 

+ 1 - 1
examples/webgl_geometry_text2.html

@@ -77,7 +77,7 @@
 		<script>
 			THREE.Shape.Utils.triangulateShape = ( function () {
 				var pnlTriangulator = new PNLTRI.Triangulator();
-				return function ( contour, holes ) {
+				return function triangulateShape( contour, holes ) {
 					// console.log("new Triangulation: PnlTri.js " + PNLTRI.REVISION );
 					return pnlTriangulator.triangulate_polygon( [ contour ].concat(holes) );
 				};

+ 1 - 1
src/extras/audio/Audio.js

@@ -123,7 +123,7 @@ THREE.Audio.prototype.updateMatrixWorld = ( function () {
 
 	var position = new THREE.Vector3();
 
-	return function ( force ) {
+	return function updateMatrixWorld( force ) {
 
 		THREE.Object3D.prototype.updateMatrixWorld.call( this, force );
 

+ 1 - 1
src/extras/audio/AudioListener.js

@@ -23,7 +23,7 @@ THREE.AudioListener.prototype.updateMatrixWorld = ( function () {
 
 	var orientation = new THREE.Vector3();
 
-	return function ( force ) {
+	return function updateMatrixWorld( force ) {
 
 		THREE.Object3D.prototype.updateMatrixWorld.call( this, force );
 

+ 64 - 64
src/extras/core/Gyroscope.js

@@ -1,65 +1,65 @@
-/**
- * @author alteredq / http://alteredqualia.com/
- */
-
-THREE.Gyroscope = function () {
-
-	THREE.Object3D.call( this );
-
-};
-
-THREE.Gyroscope.prototype = Object.create( THREE.Object3D.prototype );
+/**
+ * @author alteredq / http://alteredqualia.com/
+ */
+
+THREE.Gyroscope = function () {
+
+	THREE.Object3D.call( this );
+
+};
+
+THREE.Gyroscope.prototype = Object.create( THREE.Object3D.prototype );
 THREE.Gyroscope.prototype.constructor = THREE.Gyroscope;
-
-THREE.Gyroscope.prototype.updateMatrixWorld = ( function () {
-
-	var translationObject = new THREE.Vector3();
-	var quaternionObject = new THREE.Quaternion();
-	var scaleObject = new THREE.Vector3();
-
-	var translationWorld = new THREE.Vector3();
-	var quaternionWorld = new THREE.Quaternion();
-	var scaleWorld = new THREE.Vector3();
-
-	return function ( force ) {
-
-		this.matrixAutoUpdate && this.updateMatrix();
-
-		// update matrixWorld
-
-		if ( this.matrixWorldNeedsUpdate || force ) {
-
-			if ( this.parent ) {
-
-				this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
-
-				this.matrixWorld.decompose( translationWorld, quaternionWorld, scaleWorld );
-				this.matrix.decompose( translationObject, quaternionObject, scaleObject );
-
-				this.matrixWorld.compose( translationWorld, quaternionObject, scaleWorld );
-
-
-			} else {
-
-				this.matrixWorld.copy( this.matrix );
-
-			}
-
-
-			this.matrixWorldNeedsUpdate = false;
-
-			force = true;
-
-		}
-
-		// update children
-
-		for ( var i = 0, l = this.children.length; i < l; i ++ ) {
-
-			this.children[ i ].updateMatrixWorld( force );
-
-		}
-
-	};
-	
-}() );
+
+THREE.Gyroscope.prototype.updateMatrixWorld = ( function () {
+
+	var translationObject = new THREE.Vector3();
+	var quaternionObject = new THREE.Quaternion();
+	var scaleObject = new THREE.Vector3();
+
+	var translationWorld = new THREE.Vector3();
+	var quaternionWorld = new THREE.Quaternion();
+	var scaleWorld = new THREE.Vector3();
+
+	return function updateMatrixWorld( force ) {
+
+		this.matrixAutoUpdate && this.updateMatrix();
+
+		// update matrixWorld
+
+		if ( this.matrixWorldNeedsUpdate || force ) {
+
+			if ( this.parent ) {
+
+				this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
+
+				this.matrixWorld.decompose( translationWorld, quaternionWorld, scaleWorld );
+				this.matrix.decompose( translationObject, quaternionObject, scaleObject );
+
+				this.matrixWorld.compose( translationWorld, quaternionObject, scaleWorld );
+
+
+			} else {
+
+				this.matrixWorld.copy( this.matrix );
+
+			}
+
+
+			this.matrixWorldNeedsUpdate = false;
+
+			force = true;
+
+		}
+
+		// update children
+
+		for ( var i = 0, l = this.children.length; i < l; i ++ ) {
+
+			this.children[ i ].updateMatrixWorld( force );
+
+		}
+
+	};
+
+}() );

+ 2 - 2
src/extras/helpers/ArrowHelper.js

@@ -22,7 +22,7 @@ THREE.ArrowHelper = ( function () {
 	var coneGeometry = new THREE.CylinderGeometry( 0, 0.5, 1, 5, 1 );
 	coneGeometry.applyMatrix( new THREE.Matrix4().makeTranslation( 0, - 0.5, 0 ) );
 
-	return function ( dir, origin, length, color, headLength, headWidth ) {
+	return function ArrowHelper( dir, origin, length, color, headLength, headWidth ) {
 
 		// dir is assumed to be normalized
 
@@ -58,7 +58,7 @@ THREE.ArrowHelper.prototype.setDirection = ( function () {
 	var axis = new THREE.Vector3();
 	var radians;
 
-	return function ( dir ) {
+	return function setDirection( dir ) {
 
 		// dir is assumed to be normalized
 

+ 1 - 1
src/extras/helpers/FaceNormalsHelper.js

@@ -59,7 +59,7 @@ THREE.FaceNormalsHelper.prototype.update = ( function () {
 	var v1 = new THREE.Vector3();
 	var v2 = new THREE.Vector3();
 
-	return function() {
+	return function update() {
 
 		this.object.updateMatrixWorld( true );
 

+ 1 - 1
src/extras/helpers/VertexNormalsHelper.js

@@ -57,7 +57,7 @@ THREE.VertexNormalsHelper.prototype.update = ( function () {
 	var v1 = new THREE.Vector3();
 	var v2 = new THREE.Vector3();
 
-	return function() {
+	return function update() {
 
 		var keys = [ 'a', 'b', 'c' ];
 

+ 398 - 398
src/loaders/Loader.js

@@ -1,398 +1,398 @@
-/**
- * @author alteredq / http://alteredqualia.com/
- */
-
-THREE.Loader = function () {
-
-	this.onLoadStart = function () {};
-	this.onLoadProgress = function () {};
-	this.onLoadComplete = function () {};
-
-};
-
-THREE.Loader.prototype = {
-
-	constructor: THREE.Loader,
-
-	crossOrigin: undefined,
-
-	extractUrlBase: function ( url ) {
-
-		var parts = url.split( '/' );
-
-		if ( parts.length === 1 ) return './';
-
-		parts.pop();
-
-		return parts.join( '/' ) + '/';
-
-	},
-
-	initMaterials: function ( materials, texturePath, crossOrigin ) {
-
-		var array = [];
-
-		for ( var i = 0; i < materials.length; ++ i ) {
-
-			array[ i ] = this.createMaterial( materials[ i ], texturePath, crossOrigin );
-
-		}
-
-		return array;
-
-	},
-
-	needsTangents: function ( materials ) {
-
-		for ( var i = 0, il = materials.length; i < il; i ++ ) {
-
-			var m = materials[ i ];
-
-			if ( m instanceof THREE.ShaderMaterial ) return true;
-
-		}
-
-		return false;
-
-	},
-
-	createMaterial: ( function () {
-
-		var imageLoader;
-
-		return function ( m, texturePath, crossOrigin ) {
-
-			var scope = this;
-
-			if ( crossOrigin === undefined && scope.crossOrigin !== undefined ) crossOrigin = scope.crossOrigin;
-
-			if ( imageLoader === undefined ) imageLoader = new THREE.ImageLoader();
-
-			function nearest_pow2( n ) {
-
-				var l = Math.log( n ) / Math.LN2;
-				return Math.pow( 2, Math.round(  l ) );
-
-			}
-
-			function create_texture( where, name, sourceFile, repeat, offset, wrap, anisotropy ) {
-
-				var fullPath = texturePath + sourceFile;
-
-				var texture;
-
-				var loader = THREE.Loader.Handlers.get( fullPath );
-
-				if ( loader !== null ) {
-
-					texture = loader.load( fullPath );
-
-				} else {
-
-					texture = new THREE.Texture();
-
-					loader = imageLoader;
-					loader.setCrossOrigin( crossOrigin );
-					loader.load( fullPath, function ( image ) {
-
-					if ( THREE.Math.isPowerOfTwo( image.width ) === false ||
-						 THREE.Math.isPowerOfTwo( image.height ) === false ) {
-
-							var width = nearest_pow2( image.width );
-							var height = nearest_pow2( image.height );
-
-							var canvas = document.createElement( 'canvas' );
-							canvas.width = width;
-							canvas.height = height;
-
-							var context = canvas.getContext( '2d' );
-							context.drawImage( image, 0, 0, width, height );
-
-							texture.image = canvas;
-
-						} else {
-
-							texture.image = image;
-
-						}
-
-						texture.needsUpdate = true;
-
-					} );
-
-				}
-
-				texture.sourceFile = sourceFile;
-
-				if ( repeat ) {
-
-					texture.repeat.set( repeat[ 0 ], repeat[ 1 ] );
-
-					if ( repeat[ 0 ] !== 1 ) texture.wrapS = THREE.RepeatWrapping;
-					if ( repeat[ 1 ] !== 1 ) texture.wrapT = THREE.RepeatWrapping;
-
-				}
-
-				if ( offset ) {
-
-					texture.offset.set( offset[ 0 ], offset[ 1 ] );
-
-				}
-
-				if ( wrap ) {
-
-					var wrapMap = {
-						'repeat': THREE.RepeatWrapping,
-						'mirror': THREE.MirroredRepeatWrapping
-					};
-
-					if ( wrapMap[ wrap[ 0 ] ] !== undefined ) texture.wrapS = wrapMap[ wrap[ 0 ] ];
-					if ( wrapMap[ wrap[ 1 ] ] !== undefined ) texture.wrapT = wrapMap[ wrap[ 1 ] ];
-
-				}
-
-				if ( anisotropy ) {
-
-					texture.anisotropy = anisotropy;
-
-				}
-
-				where[ name ] = texture;
-
-			}
-
-			function rgb2hex( rgb ) {
-
-				return ( rgb[ 0 ] * 255 << 16 ) + ( rgb[ 1 ] * 255 << 8 ) + rgb[ 2 ] * 255;
-
-			}
-
-			// defaults
-
-			var mtype = 'MeshLambertMaterial';
-			var mpars = { color: 0xeeeeee, opacity: 1.0, map: null, lightMap: null, normalMap: null, bumpMap: null, wireframe: false };
-
-			// parameters from model file
-
-			if ( m.shading ) {
-
-				var shading = m.shading.toLowerCase();
-
-				if ( shading === 'phong' ) mtype = 'MeshPhongMaterial';
-				else if ( shading === 'basic' ) mtype = 'MeshBasicMaterial';
-
-			}
-
-			if ( m.blending !== undefined && THREE[ m.blending ] !== undefined ) {
-
-				mpars.blending = THREE[ m.blending ];
-
-			}
-
-			if ( m.transparent !== undefined ) {
-
-				mpars.transparent = m.transparent;
-
-			}
-
-			if ( m.opacity !== undefined && m.opacity < 1.0 ) {
-
-				mpars.transparent = true;
-
-			}
-
-			if ( m.depthTest !== undefined ) {
-
-				mpars.depthTest = m.depthTest;
-
-			}
-
-			if ( m.depthWrite !== undefined ) {
-
-				mpars.depthWrite = m.depthWrite;
-
-			}
-
-			if ( m.visible !== undefined ) {
-
-				mpars.visible = m.visible;
-
-			}
-
-			if ( m.flipSided !== undefined ) {
-
-				mpars.side = THREE.BackSide;
-
-			}
-
-			if ( m.doubleSided !== undefined ) {
-
-				mpars.side = THREE.DoubleSide;
-
-			}
-
-			if ( m.wireframe !== undefined ) {
-
-				mpars.wireframe = m.wireframe;
-
-			}
-
-			if ( m.vertexColors !== undefined ) {
-
-				if ( m.vertexColors === 'face' ) {
-
-					mpars.vertexColors = THREE.FaceColors;
-
-				} else if ( m.vertexColors ) {
-
-					mpars.vertexColors = THREE.VertexColors;
-
-				}
-
-			}
-
-			// colors
-
-			if ( m.colorDiffuse ) {
-
-				mpars.color = rgb2hex( m.colorDiffuse );
-
-			} else if ( m.DbgColor ) {
-
-				mpars.color = m.DbgColor;
-
-			}
-
-			if ( m.colorSpecular ) {
-
-				mpars.specular = rgb2hex( m.colorSpecular );
-
-			}
-
-			if ( m.colorEmissive ) {
-
-				mpars.emissive = rgb2hex( m.colorEmissive );
-
-			}
-
-			// modifiers
-
-			if ( m.transparency !== undefined ) {
-
-				console.warn( 'THREE.Loader: transparency has been renamed to opacity' );
-				m.opacity = m.transparency;
-
-			}
-
-			if ( m.opacity !== undefined ) {
-
-				mpars.opacity = m.opacity;
-
-			}
-
-			if ( m.specularCoef ) {
-
-				mpars.shininess = m.specularCoef;
-
-			}
-
-			// textures
-
-			if ( m.mapDiffuse && texturePath ) {
-
-				create_texture( mpars, 'map', m.mapDiffuse, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy );
-
-			}
-
-			if ( m.mapLight && texturePath ) {
-
-				create_texture( mpars, 'lightMap', m.mapLight, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy );
-
-			}
-
-			if ( m.mapAO && texturePath ) {
-
-				create_texture( mpars, 'aoMap', m.mapAO, m.mapAORepeat, m.mapAOOffset, m.mapAOWrap, m.mapAOAnisotropy );
-
-			}
-
-			if ( m.mapBump && texturePath ) {
-
-				create_texture( mpars, 'bumpMap', m.mapBump, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy );
-
-			}
-
-			if ( m.mapNormal && texturePath ) {
-
-				create_texture( mpars, 'normalMap', m.mapNormal, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy );
-
-			}
-
-			if ( m.mapSpecular && texturePath ) {
-
-				create_texture( mpars, 'specularMap', m.mapSpecular, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy );
-
-			}
-
-			if ( m.mapAlpha && texturePath ) {
-
-				create_texture( mpars, 'alphaMap', m.mapAlpha, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy );
-
-			}
-
-			//
-
-			if ( m.mapBumpScale ) {
-
-				mpars.bumpScale = m.mapBumpScale;
-
-			}
-
-			if ( m.mapNormalFactor ) {
-
-				mpars.normalScale = new THREE.Vector2( m.mapNormalFactor, m.mapNormalFactor );
-
-			}
-
-			var material = new THREE[ mtype ]( mpars );
-
-			if ( m.DbgName !== undefined ) material.name = m.DbgName;
-
-			return material;
-
-		};
-
-	} )()
-
-};
-
-THREE.Loader.Handlers = {
-
-	handlers: [],
-
-	add: function ( regex, loader ) {
-
-		this.handlers.push( regex, loader );
-
-	},
-
-	get: function ( file ) {
-
-		for ( var i = 0, l = this.handlers.length; i < l; i += 2 ) {
-
-			var regex = this.handlers[ i ];
-			var loader  = this.handlers[ i + 1 ];
-
-			if ( regex.test( file ) ) {
-
-				return loader;
-
-			}
-
-		}
-
-		return null;
-
-	}
-
-};
+/**
+ * @author alteredq / http://alteredqualia.com/
+ */
+
+THREE.Loader = function () {
+
+	this.onLoadStart = function () {};
+	this.onLoadProgress = function () {};
+	this.onLoadComplete = function () {};
+
+};
+
+THREE.Loader.prototype = {
+
+	constructor: THREE.Loader,
+
+	crossOrigin: undefined,
+
+	extractUrlBase: function ( url ) {
+
+		var parts = url.split( '/' );
+
+		if ( parts.length === 1 ) return './';
+
+		parts.pop();
+
+		return parts.join( '/' ) + '/';
+
+	},
+
+	initMaterials: function ( materials, texturePath, crossOrigin ) {
+
+		var array = [];
+
+		for ( var i = 0; i < materials.length; ++ i ) {
+
+			array[ i ] = this.createMaterial( materials[ i ], texturePath, crossOrigin );
+
+		}
+
+		return array;
+
+	},
+
+	needsTangents: function ( materials ) {
+
+		for ( var i = 0, il = materials.length; i < il; i ++ ) {
+
+			var m = materials[ i ];
+
+			if ( m instanceof THREE.ShaderMaterial ) return true;
+
+		}
+
+		return false;
+
+	},
+
+	createMaterial: ( function () {
+
+		var imageLoader;
+
+		return function createMaterial( m, texturePath, crossOrigin ) {
+
+			var scope = this;
+
+			if ( crossOrigin === undefined && scope.crossOrigin !== undefined ) crossOrigin = scope.crossOrigin;
+
+			if ( imageLoader === undefined ) imageLoader = new THREE.ImageLoader();
+
+			function nearest_pow2( n ) {
+
+				var l = Math.log( n ) / Math.LN2;
+				return Math.pow( 2, Math.round(  l ) );
+
+			}
+
+			function create_texture( where, name, sourceFile, repeat, offset, wrap, anisotropy ) {
+
+				var fullPath = texturePath + sourceFile;
+
+				var texture;
+
+				var loader = THREE.Loader.Handlers.get( fullPath );
+
+				if ( loader !== null ) {
+
+					texture = loader.load( fullPath );
+
+				} else {
+
+					texture = new THREE.Texture();
+
+					loader = imageLoader;
+					loader.setCrossOrigin( crossOrigin );
+					loader.load( fullPath, function ( image ) {
+
+					if ( THREE.Math.isPowerOfTwo( image.width ) === false ||
+						 THREE.Math.isPowerOfTwo( image.height ) === false ) {
+
+							var width = nearest_pow2( image.width );
+							var height = nearest_pow2( image.height );
+
+							var canvas = document.createElement( 'canvas' );
+							canvas.width = width;
+							canvas.height = height;
+
+							var context = canvas.getContext( '2d' );
+							context.drawImage( image, 0, 0, width, height );
+
+							texture.image = canvas;
+
+						} else {
+
+							texture.image = image;
+
+						}
+
+						texture.needsUpdate = true;
+
+					} );
+
+				}
+
+				texture.sourceFile = sourceFile;
+
+				if ( repeat ) {
+
+					texture.repeat.set( repeat[ 0 ], repeat[ 1 ] );
+
+					if ( repeat[ 0 ] !== 1 ) texture.wrapS = THREE.RepeatWrapping;
+					if ( repeat[ 1 ] !== 1 ) texture.wrapT = THREE.RepeatWrapping;
+
+				}
+
+				if ( offset ) {
+
+					texture.offset.set( offset[ 0 ], offset[ 1 ] );
+
+				}
+
+				if ( wrap ) {
+
+					var wrapMap = {
+						'repeat': THREE.RepeatWrapping,
+						'mirror': THREE.MirroredRepeatWrapping
+					};
+
+					if ( wrapMap[ wrap[ 0 ] ] !== undefined ) texture.wrapS = wrapMap[ wrap[ 0 ] ];
+					if ( wrapMap[ wrap[ 1 ] ] !== undefined ) texture.wrapT = wrapMap[ wrap[ 1 ] ];
+
+				}
+
+				if ( anisotropy ) {
+
+					texture.anisotropy = anisotropy;
+
+				}
+
+				where[ name ] = texture;
+
+			}
+
+			function rgb2hex( rgb ) {
+
+				return ( rgb[ 0 ] * 255 << 16 ) + ( rgb[ 1 ] * 255 << 8 ) + rgb[ 2 ] * 255;
+
+			}
+
+			// defaults
+
+			var mtype = 'MeshLambertMaterial';
+			var mpars = { color: 0xeeeeee, opacity: 1.0, map: null, lightMap: null, normalMap: null, bumpMap: null, wireframe: false };
+
+			// parameters from model file
+
+			if ( m.shading ) {
+
+				var shading = m.shading.toLowerCase();
+
+				if ( shading === 'phong' ) mtype = 'MeshPhongMaterial';
+				else if ( shading === 'basic' ) mtype = 'MeshBasicMaterial';
+
+			}
+
+			if ( m.blending !== undefined && THREE[ m.blending ] !== undefined ) {
+
+				mpars.blending = THREE[ m.blending ];
+
+			}
+
+			if ( m.transparent !== undefined ) {
+
+				mpars.transparent = m.transparent;
+
+			}
+
+			if ( m.opacity !== undefined && m.opacity < 1.0 ) {
+
+				mpars.transparent = true;
+
+			}
+
+			if ( m.depthTest !== undefined ) {
+
+				mpars.depthTest = m.depthTest;
+
+			}
+
+			if ( m.depthWrite !== undefined ) {
+
+				mpars.depthWrite = m.depthWrite;
+
+			}
+
+			if ( m.visible !== undefined ) {
+
+				mpars.visible = m.visible;
+
+			}
+
+			if ( m.flipSided !== undefined ) {
+
+				mpars.side = THREE.BackSide;
+
+			}
+
+			if ( m.doubleSided !== undefined ) {
+
+				mpars.side = THREE.DoubleSide;
+
+			}
+
+			if ( m.wireframe !== undefined ) {
+
+				mpars.wireframe = m.wireframe;
+
+			}
+
+			if ( m.vertexColors !== undefined ) {
+
+				if ( m.vertexColors === 'face' ) {
+
+					mpars.vertexColors = THREE.FaceColors;
+
+				} else if ( m.vertexColors ) {
+
+					mpars.vertexColors = THREE.VertexColors;
+
+				}
+
+			}
+
+			// colors
+
+			if ( m.colorDiffuse ) {
+
+				mpars.color = rgb2hex( m.colorDiffuse );
+
+			} else if ( m.DbgColor ) {
+
+				mpars.color = m.DbgColor;
+
+			}
+
+			if ( m.colorSpecular ) {
+
+				mpars.specular = rgb2hex( m.colorSpecular );
+
+			}
+
+			if ( m.colorEmissive ) {
+
+				mpars.emissive = rgb2hex( m.colorEmissive );
+
+			}
+
+			// modifiers
+
+			if ( m.transparency !== undefined ) {
+
+				console.warn( 'THREE.Loader: transparency has been renamed to opacity' );
+				m.opacity = m.transparency;
+
+			}
+
+			if ( m.opacity !== undefined ) {
+
+				mpars.opacity = m.opacity;
+
+			}
+
+			if ( m.specularCoef ) {
+
+				mpars.shininess = m.specularCoef;
+
+			}
+
+			// textures
+
+			if ( m.mapDiffuse && texturePath ) {
+
+				create_texture( mpars, 'map', m.mapDiffuse, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy );
+
+			}
+
+			if ( m.mapLight && texturePath ) {
+
+				create_texture( mpars, 'lightMap', m.mapLight, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy );
+
+			}
+
+			if ( m.mapAO && texturePath ) {
+
+				create_texture( mpars, 'aoMap', m.mapAO, m.mapAORepeat, m.mapAOOffset, m.mapAOWrap, m.mapAOAnisotropy );
+
+			}
+
+			if ( m.mapBump && texturePath ) {
+
+				create_texture( mpars, 'bumpMap', m.mapBump, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy );
+
+			}
+
+			if ( m.mapNormal && texturePath ) {
+
+				create_texture( mpars, 'normalMap', m.mapNormal, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy );
+
+			}
+
+			if ( m.mapSpecular && texturePath ) {
+
+				create_texture( mpars, 'specularMap', m.mapSpecular, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy );
+
+			}
+
+			if ( m.mapAlpha && texturePath ) {
+
+				create_texture( mpars, 'alphaMap', m.mapAlpha, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy );
+
+			}
+
+			//
+
+			if ( m.mapBumpScale ) {
+
+				mpars.bumpScale = m.mapBumpScale;
+
+			}
+
+			if ( m.mapNormalFactor ) {
+
+				mpars.normalScale = new THREE.Vector2( m.mapNormalFactor, m.mapNormalFactor );
+
+			}
+
+			var material = new THREE[ mtype ]( mpars );
+
+			if ( m.DbgName !== undefined ) material.name = m.DbgName;
+
+			return material;
+
+		};
+
+	} )()
+
+};
+
+THREE.Loader.Handlers = {
+
+	handlers: [],
+
+	add: function ( regex, loader ) {
+
+		this.handlers.push( regex, loader );
+
+	},
+
+	get: function ( file ) {
+
+		for ( var i = 0, l = this.handlers.length; i < l; i += 2 ) {
+
+			var regex = this.handlers[ i ];
+			var loader  = this.handlers[ i + 1 ];
+
+			if ( regex.test( file ) ) {
+
+				return loader;
+
+			}
+
+		}
+
+		return null;
+
+	}
+
+};

+ 4 - 4
src/math/Vector2.js

@@ -107,7 +107,7 @@ THREE.Vector2.prototype = {
 		return this;
 
 	},
-	
+
 	addScaledVector: function ( v, s ) {
 
         this.x += v.x * s;
@@ -261,11 +261,11 @@ THREE.Vector2.prototype = {
 		return this;
 	},
 
-	clampScalar: ( function () {
+	clampScalar: function () {
 
 		var min, max;
 
-		return function ( minVal, maxVal ) {
+		return function clampScalar( minVal, maxVal ) {
 
 			if ( min === undefined ) {
 
@@ -281,7 +281,7 @@ THREE.Vector2.prototype = {
 
 		};
 
-	} )(),
+	}(),
 
 	floor: function () {
 

+ 13 - 13
src/math/Vector3.js

@@ -125,7 +125,7 @@ THREE.Vector3.prototype = {
 		return this;
 
 	},
-	
+
 	addScaledVector: function ( v, s ) {
 
         this.x += v.x * s;
@@ -152,7 +152,7 @@ THREE.Vector3.prototype = {
 		return this;
 
 	},
-	
+
 	subScalar: function ( s ) {
 
 		this.x -= s;
@@ -214,7 +214,7 @@ THREE.Vector3.prototype = {
 
 		var quaternion;
 
-		return function ( euler ) {
+		return function applyEuler( euler ) {
 
 			if ( euler instanceof THREE.Euler === false ) {
 
@@ -236,7 +236,7 @@ THREE.Vector3.prototype = {
 
 		var quaternion;
 
-		return function ( axis, angle ) {
+		return function applyAxisAngle( axis, angle ) {
 
 			if ( quaternion === undefined ) quaternion = new THREE.Quaternion();
 
@@ -329,7 +329,7 @@ THREE.Vector3.prototype = {
 
 		var matrix;
 
-		return function ( camera ) {
+		return function project( camera ) {
 
 			if ( matrix === undefined ) matrix = new THREE.Matrix4();
 
@@ -344,7 +344,7 @@ THREE.Vector3.prototype = {
 
 		var matrix;
 
-		return function ( camera ) {
+		return function unproject( camera ) {
 
 			if ( matrix === undefined ) matrix = new THREE.Matrix4();
 
@@ -492,11 +492,11 @@ THREE.Vector3.prototype = {
 
 	},
 
-	clampScalar: ( function () {
+	clampScalar: function () {
 
 		var min, max;
 
-		return function ( minVal, maxVal ) {
+		return function clampScalar( minVal, maxVal ) {
 
 			if ( min === undefined ) {
 
@@ -512,7 +512,7 @@ THREE.Vector3.prototype = {
 
 		};
 
-	} )(),
+	}(),
 
 	floor: function () {
 
@@ -661,7 +661,7 @@ THREE.Vector3.prototype = {
 
 		var v1, dot;
 
-		return function ( vector ) {
+		return function projectOnVector( vector ) {
 
 			if ( v1 === undefined ) v1 = new THREE.Vector3();
 
@@ -679,7 +679,7 @@ THREE.Vector3.prototype = {
 
 		var v1;
 
-		return function ( planeNormal ) {
+		return function projectOnPlane( planeNormal ) {
 
 			if ( v1 === undefined ) v1 = new THREE.Vector3();
 
@@ -698,7 +698,7 @@ THREE.Vector3.prototype = {
 
 		var v1;
 
-		return function ( normal ) {
+		return function reflect( normal ) {
 
 			if ( v1 === undefined ) v1 = new THREE.Vector3();
 
@@ -793,7 +793,7 @@ THREE.Vector3.prototype = {
 	},
 
 	setFromMatrixColumn: function ( index, matrix ) {
-		
+
 		var offset = index * 4;
 
 		var me = matrix.elements;

+ 4 - 4
src/math/Vector4.js

@@ -140,7 +140,7 @@ THREE.Vector4.prototype = {
 		return this;
 
 	},
-	
+
 	addScaledVector: function ( v, s ) {
 
         this.x += v.x * s;
@@ -505,11 +505,11 @@ THREE.Vector4.prototype = {
 
 	},
 
-	clampScalar: ( function () {
+	clampScalar: function () {
 
 		var min, max;
 
-		return function ( minVal, maxVal ) {
+		return function clampScalar( minVal, maxVal ) {
 
 			if ( min === undefined ) {
 
@@ -525,7 +525,7 @@ THREE.Vector4.prototype = {
 
 		};
 
-	} )(),
+	}(),
 
   floor: function () {
 

+ 2 - 2
src/objects/LOD.js

@@ -73,7 +73,7 @@ THREE.LOD.prototype.raycast = ( function () {
 
 	var matrixPosition = new THREE.Vector3();
 
-	return function ( raycaster, intersects ) {
+	return function raycast( raycaster, intersects ) {
 
 		matrixPosition.setFromMatrixPosition( this.matrixWorld );
 
@@ -90,7 +90,7 @@ THREE.LOD.prototype.update = function () {
 	var v1 = new THREE.Vector3();
 	var v2 = new THREE.Vector3();
 
-	return function ( camera ) {
+	return function update( camera ) {
 
 		var levels = this.levels;
 

+ 1 - 1
src/objects/Line.js

@@ -28,7 +28,7 @@ THREE.Line.prototype.raycast = ( function () {
 	var ray = new THREE.Ray();
 	var sphere = new THREE.Sphere();
 
-	return function ( raycaster, intersects ) {
+	return function raycast( raycaster, intersects ) {
 
 		var precision = raycaster.linePrecision;
 		var precisionSq = precision * precision;

+ 1 - 1
src/objects/Mesh.js

@@ -70,7 +70,7 @@ THREE.Mesh.prototype.raycast = ( function () {
 	var tempB = new THREE.Vector3();
 	var tempC = new THREE.Vector3();
 
-	return function ( raycaster, intersects ) {
+	return function raycast( raycaster, intersects ) {
 
 		var geometry = this.geometry;
 		var material = this.material;

+ 1 - 1
src/objects/PointCloud.js

@@ -21,7 +21,7 @@ THREE.PointCloud.prototype.raycast = ( function () {
 	var inverseMatrix = new THREE.Matrix4();
 	var ray = new THREE.Ray();
 
-	return function ( raycaster, intersects ) {
+	return function raycast( raycaster, intersects ) {
 
 		var object = this;
 		var geometry = object.geometry;

+ 1 - 1
src/objects/Skeleton.js

@@ -145,7 +145,7 @@ THREE.Skeleton.prototype.update = ( function () {
 
 	var offsetMatrix = new THREE.Matrix4();
 
-	return function () {
+	return function update() {
 
 		// flatten bone matrices to array
 

+ 3 - 3
src/objects/Sprite.js

@@ -14,7 +14,7 @@ THREE.Sprite = ( function () {
 	geometry.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
 	geometry.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ) );
 
-	return function ( material ) {
+	return function Sprite( material ) {
 
 		THREE.Object3D.call( this );
 
@@ -34,13 +34,13 @@ THREE.Sprite.prototype.raycast = ( function () {
 
 	var matrixPosition = new THREE.Vector3();
 
-	return function ( raycaster, intersects ) {
+	return function raycast( raycaster, intersects ) {
 
 		matrixPosition.setFromMatrixPosition( this.matrixWorld );
 
 		var distanceSq = raycaster.ray.distanceSqToPoint( matrixPosition );
 		var guessSizeSq = this.scale.x * this.scale.y;
-		
+
 		if ( distanceSq > guessSizeSq ) {
 
 			return;

+ 2 - 2
src/renderers/WebGLRenderer.js

@@ -312,7 +312,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		var array;
 
-		return function () {
+		return function getCompressedTextureFormats() {
 
 			if ( array !== undefined ) {
 
@@ -439,7 +439,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		var value;
 
-		return function () {
+		return function getMaxAnisotropy() {
 
 			if ( value !== undefined ) return value;
 

+ 1 - 1
src/renderers/webgl/WebGLProgram.js

@@ -76,7 +76,7 @@ THREE.WebGLProgram = ( function () {
 
 	}
 
-	return function ( renderer, code, material, parameters ) {
+	return function WebGLProgram( renderer, code, material, parameters ) {
 
 		var gl = renderer.context;
 

+ 1 - 1
src/renderers/webgl/WebGLShader.js

@@ -14,7 +14,7 @@ THREE.WebGLShader = ( function () {
 
 	};
 
-	return function ( gl, type, string ) {
+	return function WebGLShader( gl, type, string ) {
 
 		var shader = gl.createShader( type );