Преглед изворни кода

Merge branch 'dev' of https://github.com/mrdoob/three.js into FBXLoader_rotation_order_warning

Lewy Blue пре 7 година
родитељ
комит
780f98dcfb
82 измењених фајлова са 5723 додато и 1248 уклоњено
  1. 214 77
      build/three.js
  2. 336 336
      build/three.min.js
  3. 214 77
      build/three.module.js
  4. 3 0
      docs/api/core/BufferGeometry.html
  5. 3 0
      docs/api/core/Geometry.html
  6. 0 23
      docs/api/extras/core/CurvePath.html
  7. 2 2
      docs/api/extras/curves/CatmullRomCurve3.html
  8. 6 6
      docs/api/extras/curves/CubicBezierCurve.html
  9. 2 2
      docs/api/extras/curves/CubicBezierCurve3.html
  10. 3 2
      docs/api/extras/curves/EllipseCurve.html
  11. 2 2
      docs/api/extras/curves/QuadraticBezierCurve.html
  12. 2 2
      docs/api/extras/curves/QuadraticBezierCurve3.html
  13. 2 2
      docs/api/extras/curves/SplineCurve.html
  14. 2 2
      docs/api/geometries/CircleGeometry.html
  15. 4 4
      docs/api/geometries/CylinderGeometry.html
  16. 3 3
      docs/api/geometries/RingGeometry.html
  17. 2 2
      docs/api/geometries/SphereGeometry.html
  18. 3 3
      docs/api/geometries/TorusGeometry.html
  19. 3 3
      docs/api/geometries/TorusKnotGeometry.html
  20. 78 78
      docs/api/helpers/VertexNormalsHelper.html
  21. 8 0
      docs/api/renderers/WebGLRenderer.html
  22. 3 2
      docs/examples/exporters/GLTFExporter.html
  23. 2 2
      docs/index.html
  24. 2 2
      docs/page.js
  25. 0 32
      editor/js/libs/tern-threejs/threejs.js
  26. 2 2
      examples/canvas_geometry_shapes.html
  27. 23 23
      examples/js/CurveExtras.js
  28. 4 3
      examples/js/Octree.js
  29. 2 2
      examples/js/animation/MMDPhysics.js
  30. 95 7
      examples/js/exporters/GLTFExporter.js
  31. 32 13
      examples/js/loaders/ColladaLoader.js
  32. 145 122
      examples/js/loaders/FBXLoader.js
  33. 46 55
      examples/js/loaders/GLTFLoader.js
  34. 2215 0
      examples/js/loaders/deprecated/LegacyGLTFLoader.js
  35. 23 6
      examples/misc_exporter_gltf.html
  36. 1 1
      examples/webgl_clipping_advanced.html
  37. 10 6
      examples/webgl_geometry_shapes.html
  38. 5 4
      examples/webgl_geometry_text_shapes.html
  39. 1 1
      examples/webgl_octree.html
  40. 12 2
      examples/webgl_shadowmap_pcss.html
  41. 6 3
      package.json
  42. 46 0
      src/Three.Legacy.js
  43. 17 0
      src/core/BufferGeometry.js
  44. 15 0
      src/core/Geometry.js
  45. 7 7
      src/core/Object3D.js
  46. 0 39
      src/extras/core/CurvePath.js
  47. 1 1
      src/geometries/CircleGeometry.js
  48. 3 3
      src/geometries/CylinderGeometry.js
  49. 2 2
      src/geometries/RingGeometry.js
  50. 1 1
      src/geometries/SphereGeometry.js
  51. 2 2
      src/geometries/TorusGeometry.js
  52. 2 2
      src/geometries/TorusKnotGeometry.js
  53. 69 9
      src/loaders/FileLoader.js
  54. 3 3
      src/renderers/WebGLRenderer.js
  55. 43 14
      test/unit/qunit-utils.js
  56. 0 6
      test/unit/src/extras/curves/ArcCurve.js
  57. 192 0
      test/unit/src/extras/curves/CatmullRomCurve3.js
  58. 189 3
      test/unit/src/extras/curves/CubicBezierCurve.js
  59. 227 3
      test/unit/src/extras/curves/CubicBezierCurve3.js
  60. 170 3
      test/unit/src/extras/curves/EllipseCurve.js
  61. 149 3
      test/unit/src/extras/curves/LineCurve.js
  62. 178 3
      test/unit/src/extras/curves/LineCurve3.js
  63. 188 3
      test/unit/src/extras/curves/QuadraticBezierCurve.js
  64. 226 3
      test/unit/src/extras/curves/QuadraticBezierCurve3.js
  65. 149 3
      test/unit/src/extras/curves/SplineCurve.js
  66. 21 0
      test/unit/src/lights/AmbientLight.js
  67. 0 27
      test/unit/src/lights/AmbientLight.tests.js
  68. 21 0
      test/unit/src/lights/DirectionalLight.js
  69. 0 28
      test/unit/src/lights/DirectionalLight.tests.js
  70. 40 5
      test/unit/src/lights/DirectionalLightShadow.js
  71. 25 0
      test/unit/src/lights/HemisphereLight.js
  72. 0 35
      test/unit/src/lights/HemisphereLight.tests.js
  73. 18 3
      test/unit/src/lights/Light.js
  74. 23 5
      test/unit/src/lights/LightShadow.js
  75. 45 0
      test/unit/src/lights/PointLight.js
  76. 0 27
      test/unit/src/lights/PointLight.tests.js
  77. 29 0
      test/unit/src/lights/RectAreaLight.js
  78. 0 38
      test/unit/src/lights/RectAreaLight.tests.js
  79. 55 0
      test/unit/src/lights/SpotLight.js
  80. 0 41
      test/unit/src/lights/SpotLight.tests.js
  81. 40 5
      test/unit/src/lights/SpotLightShadow.js
  82. 6 7
      test/unit/unittests_sources.html

+ 214 - 77
build/three.js

@@ -838,7 +838,7 @@
 
 		},
 
-		lengthManhattan: function () {
+		manhattanLength: function () {
 
 			return Math.abs( this.x ) + Math.abs( this.y );
 
@@ -875,7 +875,7 @@
 
 		},
 
-		distanceToManhattan: function ( v ) {
+		manhattanDistanceTo: function ( v ) {
 
 			return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y );
 
@@ -2984,7 +2984,7 @@
 
 		},
 
-		lengthManhattan: function () {
+		manhattanLength: function () {
 
 			return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );
 
@@ -3111,7 +3111,7 @@
 
 		},
 
-		distanceToManhattan: function ( v ) {
+		manhattanDistanceTo: function ( v ) {
 
 			return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z );
 
@@ -4458,7 +4458,7 @@
 
 		},
 
-		lengthManhattan: function () {
+		manhattanLength: function () {
 
 			return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w );
 
@@ -10361,23 +10361,23 @@
 		}(),
 
 		rotateOnWorldAxis: function () {
-			
+
 			// rotate object on axis in world space
 			// axis is assumed to be normalized
 			// method assumes no rotated parent
 
 			var q1 = new Quaternion();
-			
+
 			return function rotateOnWorldAxis( axis, angle ) {
-			
+
 				q1.setFromAxisAngle( axis, angle );
-			
+
 				this.quaternion.premultiply( q1 );
-			
+
 				return this;
-			
+
 			};
-			
+
 		}(),
 
 		rotateX: function () {
@@ -12162,6 +12162,21 @@
 
 		},
 
+		setFromPoints: function ( points ) {
+
+			this.vertices = [];
+
+			for ( var i = 0, l = points.length; i < l; i ++ ) {
+
+				var point = points[ i ];
+				this.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );
+
+			}
+
+			return this;
+
+		},
+
 		sortFacesByMaterialIndex: function () {
 
 			var faces = this.faces;
@@ -13704,6 +13719,23 @@
 
 		},
 
+		setFromPoints: function ( points ) {
+
+			var position = [];
+
+			for ( var i = 0, l = points.length; i < l; i ++ ) {
+
+				var point = points[ i ];
+				position.push( point.x, point.y, point.z || 0 );
+
+			}
+
+			this.addAttribute( 'position', new Float32BufferAttribute( position, 3 ) );
+
+			return this;
+
+		},
+
 		updateFromObject: function ( object ) {
 
 			var geometry = object.geometry;
@@ -14519,6 +14551,10 @@
 
 		var scope = this;
 
+		width = width || 1;
+		height = height || 1;
+		depth = depth || 1;
+
 		// segments
 
 		widthSegments = Math.floor( widthSegments ) || 1;
@@ -14705,6 +14741,9 @@
 			heightSegments: heightSegments
 		};
 
+		width = width || 1;
+		height = height || 1;
+
 		var width_half = width / 2;
 		var height_half = height / 2;
 
@@ -21545,7 +21584,7 @@
 
 		// Clearing
 
-		this.getClearColor = function() {
+		this.getClearColor = function () {
 
 			return background.getClearColor();
 
@@ -21557,13 +21596,13 @@
 
 		};
 
-		this.getClearAlpha = function() {
+		this.getClearAlpha = function () {
 
 			return background.getClearAlpha();
 
 		};
 
-		this.setClearAlpha = function() {
+		this.setClearAlpha = function () {
 
 			background.setClearAlpha.apply( background, arguments );
 
@@ -24434,7 +24473,7 @@
 
 					var sw = this.geometry.skinWeights[ i ];
 
-					scale = 1.0 / sw.lengthManhattan();
+					scale = 1.0 / sw.manhattanLength();
 
 					if ( scale !== Infinity ) {
 
@@ -24461,7 +24500,7 @@
 					vec.z = skinWeight.getZ( i );
 					vec.w = skinWeight.getW( i );
 
-					scale = 1.0 / vec.lengthManhattan();
+					scale = 1.0 / vec.manhattanLength();
 
 					if ( scale !== Infinity ) {
 
@@ -26257,8 +26296,8 @@
 			q: q
 		};
 
-		radius = radius || 100;
-		tube = tube || 40;
+		radius = radius || 1;
+		tube = tube || 0.4;
 		tubularSegments = Math.floor( tubularSegments ) || 64;
 		radialSegments = Math.floor( radialSegments ) || 8;
 		p = p || 2;
@@ -26439,8 +26478,8 @@
 			arc: arc
 		};
 
-		radius = radius || 100;
-		tube = tube || 40;
+		radius = radius || 1;
+		tube = tube || 0.4;
 		radialSegments = Math.floor( radialSegments ) || 8;
 		tubularSegments = Math.floor( tubularSegments ) || 6;
 		arc = arc || Math.PI * 2;
@@ -28151,7 +28190,7 @@
 			thetaLength: thetaLength
 		};
 
-		radius = radius || 50;
+		radius = radius || 1;
 
 		widthSegments = Math.max( 3, Math.floor( widthSegments ) || 8 );
 		heightSegments = Math.max( 2, Math.floor( heightSegments ) || 6 );
@@ -28293,8 +28332,8 @@
 			thetaLength: thetaLength
 		};
 
-		innerRadius = innerRadius || 20;
-		outerRadius = outerRadius || 50;
+		innerRadius = innerRadius || 0.5;
+		outerRadius = outerRadius || 1;
 
 		thetaStart = thetaStart !== undefined ? thetaStart : 0;
 		thetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;
@@ -28896,9 +28935,9 @@
 
 		var scope = this;
 
-		radiusTop = radiusTop !== undefined ? radiusTop : 20;
-		radiusBottom = radiusBottom !== undefined ? radiusBottom : 20;
-		height = height !== undefined ? height : 100;
+		radiusTop = radiusTop !== undefined ? radiusTop : 1;
+		radiusBottom = radiusBottom !== undefined ? radiusBottom : 1;
+		height = height || 1;
 
 		radialSegments = Math.floor( radialSegments ) || 8;
 		heightSegments = Math.floor( heightSegments ) || 1;
@@ -29245,7 +29284,7 @@
 			thetaLength: thetaLength
 		};
 
-		radius = radius || 50;
+		radius = radius || 1;
 		segments = segments !== undefined ? Math.max( 3, segments ) : 8;
 
 		thetaStart = thetaStart !== undefined ? thetaStart : 0;
@@ -30219,6 +30258,8 @@
 	 * @author mrdoob / http://mrdoob.com/
 	 */
 
+	var loading = {};
+
 	function FileLoader( manager ) {
 
 		this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
@@ -30253,6 +30294,22 @@
 
 			}
 
+			// Check if request is duplicate
+
+			if ( loading[ url ] !== undefined ) {
+
+				loading[ url ].push( {
+
+					onLoad: onLoad,
+					onProgress: onProgress,
+					onError: onError
+
+				} );
+
+				return;
+
+			}
+
 			// Check for data: URI
 			var dataUriRegex = /^data:(.*?)(;base64)?,(.*)$/;
 			var dataUriRegexResult = url.match( dataUriRegex );
@@ -30344,7 +30401,20 @@
 
 			} else {
 
+				// Initialise array for duplicate requests
+
+				loading[ url ] = [];
+
+				loading[ url ].push( {
+
+					onLoad: onLoad,
+					onProgress: onProgress,
+					onError: onError
+
+				} );
+
 				var request = new XMLHttpRequest();
+
 				request.open( 'GET', url, true );
 
 				request.addEventListener( 'load', function ( event ) {
@@ -30353,9 +30423,18 @@
 
 					Cache.add( url, response );
 
+					var callbacks = loading[ url ];
+
+					delete loading[ url ];
+
 					if ( this.status === 200 ) {
 
-						if ( onLoad ) onLoad( response );
+						for ( var i = 0, il = callbacks.length; i < il; i ++ ) {
+
+							var callback = callbacks[ i ];
+							if ( callback.onLoad ) callback.onLoad( response );
+
+						}
 
 						scope.manager.itemEnd( url );
 
@@ -30366,13 +30445,23 @@
 
 						console.warn( 'THREE.FileLoader: HTTP Status 0 received.' );
 
-						if ( onLoad ) onLoad( response );
+						for ( var i = 0, il = callbacks.length; i < il; i ++ ) {
+
+							var callback = callbacks[ i ];
+							if ( callback.onLoad ) callback.onLoad( response );
+
+						}
 
 						scope.manager.itemEnd( url );
 
 					} else {
 
-						if ( onError ) onError( event );
+						for ( var i = 0, il = callbacks.length; i < il; i ++ ) {
+
+							var callback = callbacks[ i ];
+							if ( callback.onError ) callback.onError( event );
+
+						}
 
 						scope.manager.itemEnd( url );
 						scope.manager.itemError( url );
@@ -30381,19 +30470,29 @@
 
 				}, false );
 
-				if ( onProgress !== undefined ) {
+				request.addEventListener( 'progress', function ( event ) {
 
-					request.addEventListener( 'progress', function ( event ) {
+					var callbacks = loading[ url ];
 
-						onProgress( event );
+					for ( var i = 0, il = callbacks.length; i < il; i ++ ) {
 
-					}, false );
+						var callback = callbacks[ i ];
+						if ( callback.onProgress ) callback.onProgress( event );
 
-				}
+					}
+
+				}, false );
 
 				request.addEventListener( 'error', function ( event ) {
 
-					if ( onError ) onError( event );
+					var callbacks = loading[ url ];
+
+					for ( var i = 0, il = callbacks.length; i < il; i ++ ) {
+
+						var callback = callbacks[ i ];
+						if ( callback.onError ) callback.onError( event );
+
+					}
 
 					scope.manager.itemEnd( url );
 					scope.manager.itemError( url );
@@ -35727,43 +35826,6 @@
 
 			return points;
 
-		},
-
-		/**************************************************************
-		 *	Create Geometries Helpers
-		 **************************************************************/
-
-		/// Generate geometry from path points (for Line or Points objects)
-
-		createPointsGeometry: function ( divisions ) {
-
-			var pts = this.getPoints( divisions );
-			return this.createGeometry( pts );
-
-		},
-
-		// Generate geometry from equidistant sampling along the path
-
-		createSpacedPointsGeometry: function ( divisions ) {
-
-			var pts = this.getSpacedPoints( divisions );
-			return this.createGeometry( pts );
-
-		},
-
-		createGeometry: function ( points ) {
-
-			var geometry = new Geometry();
-
-			for ( var i = 0, l = points.length; i < l; i ++ ) {
-
-				var point = points[ i ];
-				geometry.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );
-
-			}
-
-			return geometry;
-
 		}
 
 	} );
@@ -42899,6 +42961,51 @@
 
 	//
 
+	Object.assign( CurvePath.prototype, {
+
+		createPointsGeometry: function ( divisions ) {
+
+			console.warn( 'THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.' );
+
+			// generate geometry from path points (for Line or Points objects)
+
+			var pts = this.getPoints( divisions );
+			return this.createGeometry( pts );
+
+		},
+
+		createSpacedPointsGeometry: function ( divisions ) {
+
+			console.warn( 'THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.' );
+
+			// generate geometry from equidistant sampling along the path
+
+			var pts = this.getSpacedPoints( divisions );
+			return this.createGeometry( pts );
+
+		},
+
+		createGeometry: function ( points ) {
+
+			console.warn( 'THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.' );
+
+			var geometry = new Geometry();
+
+			for ( var i = 0, l = points.length; i < l; i ++ ) {
+
+				var point = points[ i ];
+				geometry.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );
+
+			}
+
+			return geometry;
+
+		}
+
+	} );
+
+	//
+
 	function ClosedSplineCurve3( points ) {
 
 		console.warn( 'THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.' );
@@ -43314,9 +43421,21 @@
 
 		fromAttribute: function ( attribute, index, offset ) {
 
-			console.error( 'THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute().' );
+			console.warn( 'THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute().' );
 			return this.fromBufferAttribute( attribute, index, offset );
 
+		},
+		distanceToManhattan: function ( v ) {
+
+			console.warn( 'THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo().' );
+			return this.manhattanDistanceTo( v );
+
+		},
+		lengthManhattan: function () {
+
+			console.warn( 'THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength().' );
+			return this.manhattanLength();
+
 		}
 
 	} );
@@ -43359,9 +43478,21 @@
 		},
 		fromAttribute: function ( attribute, index, offset ) {
 
-			console.error( 'THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute().' );
+			console.warn( 'THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute().' );
 			return this.fromBufferAttribute( attribute, index, offset );
 
+		},
+		distanceToManhattan: function ( v ) {
+
+			console.warn( 'THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo().' );
+			return this.manhattanDistanceTo( v );
+
+		},
+		lengthManhattan: function () {
+
+			console.warn( 'THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength().' );
+			return this.manhattanLength();
+
 		}
 
 	} );
@@ -43370,9 +43501,15 @@
 
 		fromAttribute: function ( attribute, index, offset ) {
 
-			console.error( 'THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute().' );
+			console.warn( 'THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute().' );
 			return this.fromBufferAttribute( attribute, index, offset );
 
+		},
+		lengthManhattan: function () {
+
+			console.warn( 'THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength().' );
+			return this.manhattanLength();
+
 		}
 
 	} );

Разлика између датотеке није приказан због своје велике величине
+ 336 - 336
build/three.min.js


+ 214 - 77
build/three.module.js

@@ -832,7 +832,7 @@ Object.assign( Vector2.prototype, {
 
 	},
 
-	lengthManhattan: function () {
+	manhattanLength: function () {
 
 		return Math.abs( this.x ) + Math.abs( this.y );
 
@@ -869,7 +869,7 @@ Object.assign( Vector2.prototype, {
 
 	},
 
-	distanceToManhattan: function ( v ) {
+	manhattanDistanceTo: function ( v ) {
 
 		return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y );
 
@@ -2978,7 +2978,7 @@ Object.assign( Vector3.prototype, {
 
 	},
 
-	lengthManhattan: function () {
+	manhattanLength: function () {
 
 		return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );
 
@@ -3105,7 +3105,7 @@ Object.assign( Vector3.prototype, {
 
 	},
 
-	distanceToManhattan: function ( v ) {
+	manhattanDistanceTo: function ( v ) {
 
 		return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z );
 
@@ -4452,7 +4452,7 @@ Object.assign( Vector4.prototype, {
 
 	},
 
-	lengthManhattan: function () {
+	manhattanLength: function () {
 
 		return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w );
 
@@ -10355,23 +10355,23 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, {
 	}(),
 
 	rotateOnWorldAxis: function () {
-		
+
 		// rotate object on axis in world space
 		// axis is assumed to be normalized
 		// method assumes no rotated parent
 
 		var q1 = new Quaternion();
-		
+
 		return function rotateOnWorldAxis( axis, angle ) {
-		
+
 			q1.setFromAxisAngle( axis, angle );
-		
+
 			this.quaternion.premultiply( q1 );
-		
+
 			return this;
-		
+
 		};
-		
+
 	}(),
 
 	rotateX: function () {
@@ -12156,6 +12156,21 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, {
 
 	},
 
+	setFromPoints: function ( points ) {
+
+		this.vertices = [];
+
+		for ( var i = 0, l = points.length; i < l; i ++ ) {
+
+			var point = points[ i ];
+			this.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );
+
+		}
+
+		return this;
+
+	},
+
 	sortFacesByMaterialIndex: function () {
 
 		var faces = this.faces;
@@ -13698,6 +13713,23 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
 
 	},
 
+	setFromPoints: function ( points ) {
+
+		var position = [];
+
+		for ( var i = 0, l = points.length; i < l; i ++ ) {
+
+			var point = points[ i ];
+			position.push( point.x, point.y, point.z || 0 );
+
+		}
+
+		this.addAttribute( 'position', new Float32BufferAttribute( position, 3 ) );
+
+		return this;
+
+	},
+
 	updateFromObject: function ( object ) {
 
 		var geometry = object.geometry;
@@ -14513,6 +14545,10 @@ function BoxBufferGeometry( width, height, depth, widthSegments, heightSegments,
 
 	var scope = this;
 
+	width = width || 1;
+	height = height || 1;
+	depth = depth || 1;
+
 	// segments
 
 	widthSegments = Math.floor( widthSegments ) || 1;
@@ -14699,6 +14735,9 @@ function PlaneBufferGeometry( width, height, widthSegments, heightSegments ) {
 		heightSegments: heightSegments
 	};
 
+	width = width || 1;
+	height = height || 1;
+
 	var width_half = width / 2;
 	var height_half = height / 2;
 
@@ -21539,7 +21578,7 @@ function WebGLRenderer( parameters ) {
 
 	// Clearing
 
-	this.getClearColor = function() {
+	this.getClearColor = function () {
 
 		return background.getClearColor();
 
@@ -21551,13 +21590,13 @@ function WebGLRenderer( parameters ) {
 
 	};
 
-	this.getClearAlpha = function() {
+	this.getClearAlpha = function () {
 
 		return background.getClearAlpha();
 
 	};
 
-	this.setClearAlpha = function() {
+	this.setClearAlpha = function () {
 
 		background.setClearAlpha.apply( background, arguments );
 
@@ -24428,7 +24467,7 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
 
 				var sw = this.geometry.skinWeights[ i ];
 
-				scale = 1.0 / sw.lengthManhattan();
+				scale = 1.0 / sw.manhattanLength();
 
 				if ( scale !== Infinity ) {
 
@@ -24455,7 +24494,7 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
 				vec.z = skinWeight.getZ( i );
 				vec.w = skinWeight.getW( i );
 
-				scale = 1.0 / vec.lengthManhattan();
+				scale = 1.0 / vec.manhattanLength();
 
 				if ( scale !== Infinity ) {
 
@@ -26251,8 +26290,8 @@ function TorusKnotBufferGeometry( radius, tube, tubularSegments, radialSegments,
 		q: q
 	};
 
-	radius = radius || 100;
-	tube = tube || 40;
+	radius = radius || 1;
+	tube = tube || 0.4;
 	tubularSegments = Math.floor( tubularSegments ) || 64;
 	radialSegments = Math.floor( radialSegments ) || 8;
 	p = p || 2;
@@ -26433,8 +26472,8 @@ function TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc
 		arc: arc
 	};
 
-	radius = radius || 100;
-	tube = tube || 40;
+	radius = radius || 1;
+	tube = tube || 0.4;
 	radialSegments = Math.floor( radialSegments ) || 8;
 	tubularSegments = Math.floor( tubularSegments ) || 6;
 	arc = arc || Math.PI * 2;
@@ -28145,7 +28184,7 @@ function SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart,
 		thetaLength: thetaLength
 	};
 
-	radius = radius || 50;
+	radius = radius || 1;
 
 	widthSegments = Math.max( 3, Math.floor( widthSegments ) || 8 );
 	heightSegments = Math.max( 2, Math.floor( heightSegments ) || 6 );
@@ -28287,8 +28326,8 @@ function RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegment
 		thetaLength: thetaLength
 	};
 
-	innerRadius = innerRadius || 20;
-	outerRadius = outerRadius || 50;
+	innerRadius = innerRadius || 0.5;
+	outerRadius = outerRadius || 1;
 
 	thetaStart = thetaStart !== undefined ? thetaStart : 0;
 	thetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;
@@ -28890,9 +28929,9 @@ function CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments
 
 	var scope = this;
 
-	radiusTop = radiusTop !== undefined ? radiusTop : 20;
-	radiusBottom = radiusBottom !== undefined ? radiusBottom : 20;
-	height = height !== undefined ? height : 100;
+	radiusTop = radiusTop !== undefined ? radiusTop : 1;
+	radiusBottom = radiusBottom !== undefined ? radiusBottom : 1;
+	height = height || 1;
 
 	radialSegments = Math.floor( radialSegments ) || 8;
 	heightSegments = Math.floor( heightSegments ) || 1;
@@ -29239,7 +29278,7 @@ function CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) {
 		thetaLength: thetaLength
 	};
 
-	radius = radius || 50;
+	radius = radius || 1;
 	segments = segments !== undefined ? Math.max( 3, segments ) : 8;
 
 	thetaStart = thetaStart !== undefined ? thetaStart : 0;
@@ -30213,6 +30252,8 @@ var DefaultLoadingManager = new LoadingManager();
  * @author mrdoob / http://mrdoob.com/
  */
 
+var loading = {};
+
 function FileLoader( manager ) {
 
 	this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
@@ -30247,6 +30288,22 @@ Object.assign( FileLoader.prototype, {
 
 		}
 
+		// Check if request is duplicate
+
+		if ( loading[ url ] !== undefined ) {
+
+			loading[ url ].push( {
+
+				onLoad: onLoad,
+				onProgress: onProgress,
+				onError: onError
+
+			} );
+
+			return;
+
+		}
+
 		// Check for data: URI
 		var dataUriRegex = /^data:(.*?)(;base64)?,(.*)$/;
 		var dataUriRegexResult = url.match( dataUriRegex );
@@ -30338,7 +30395,20 @@ Object.assign( FileLoader.prototype, {
 
 		} else {
 
+			// Initialise array for duplicate requests
+
+			loading[ url ] = [];
+
+			loading[ url ].push( {
+
+				onLoad: onLoad,
+				onProgress: onProgress,
+				onError: onError
+
+			} );
+
 			var request = new XMLHttpRequest();
+
 			request.open( 'GET', url, true );
 
 			request.addEventListener( 'load', function ( event ) {
@@ -30347,9 +30417,18 @@ Object.assign( FileLoader.prototype, {
 
 				Cache.add( url, response );
 
+				var callbacks = loading[ url ];
+
+				delete loading[ url ];
+
 				if ( this.status === 200 ) {
 
-					if ( onLoad ) onLoad( response );
+					for ( var i = 0, il = callbacks.length; i < il; i ++ ) {
+
+						var callback = callbacks[ i ];
+						if ( callback.onLoad ) callback.onLoad( response );
+
+					}
 
 					scope.manager.itemEnd( url );
 
@@ -30360,13 +30439,23 @@ Object.assign( FileLoader.prototype, {
 
 					console.warn( 'THREE.FileLoader: HTTP Status 0 received.' );
 
-					if ( onLoad ) onLoad( response );
+					for ( var i = 0, il = callbacks.length; i < il; i ++ ) {
+
+						var callback = callbacks[ i ];
+						if ( callback.onLoad ) callback.onLoad( response );
+
+					}
 
 					scope.manager.itemEnd( url );
 
 				} else {
 
-					if ( onError ) onError( event );
+					for ( var i = 0, il = callbacks.length; i < il; i ++ ) {
+
+						var callback = callbacks[ i ];
+						if ( callback.onError ) callback.onError( event );
+
+					}
 
 					scope.manager.itemEnd( url );
 					scope.manager.itemError( url );
@@ -30375,19 +30464,29 @@ Object.assign( FileLoader.prototype, {
 
 			}, false );
 
-			if ( onProgress !== undefined ) {
+			request.addEventListener( 'progress', function ( event ) {
 
-				request.addEventListener( 'progress', function ( event ) {
+				var callbacks = loading[ url ];
 
-					onProgress( event );
+				for ( var i = 0, il = callbacks.length; i < il; i ++ ) {
 
-				}, false );
+					var callback = callbacks[ i ];
+					if ( callback.onProgress ) callback.onProgress( event );
 
-			}
+				}
+
+			}, false );
 
 			request.addEventListener( 'error', function ( event ) {
 
-				if ( onError ) onError( event );
+				var callbacks = loading[ url ];
+
+				for ( var i = 0, il = callbacks.length; i < il; i ++ ) {
+
+					var callback = callbacks[ i ];
+					if ( callback.onError ) callback.onError( event );
+
+				}
 
 				scope.manager.itemEnd( url );
 				scope.manager.itemError( url );
@@ -35721,43 +35820,6 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), {
 
 		return points;
 
-	},
-
-	/**************************************************************
-	 *	Create Geometries Helpers
-	 **************************************************************/
-
-	/// Generate geometry from path points (for Line or Points objects)
-
-	createPointsGeometry: function ( divisions ) {
-
-		var pts = this.getPoints( divisions );
-		return this.createGeometry( pts );
-
-	},
-
-	// Generate geometry from equidistant sampling along the path
-
-	createSpacedPointsGeometry: function ( divisions ) {
-
-		var pts = this.getSpacedPoints( divisions );
-		return this.createGeometry( pts );
-
-	},
-
-	createGeometry: function ( points ) {
-
-		var geometry = new Geometry();
-
-		for ( var i = 0, l = points.length; i < l; i ++ ) {
-
-			var point = points[ i ];
-			geometry.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );
-
-		}
-
-		return geometry;
-
 	}
 
 } );
@@ -42893,6 +42955,51 @@ Curve.create = function ( construct, getPoint ) {
 
 //
 
+Object.assign( CurvePath.prototype, {
+
+	createPointsGeometry: function ( divisions ) {
+
+		console.warn( 'THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.' );
+
+		// generate geometry from path points (for Line or Points objects)
+
+		var pts = this.getPoints( divisions );
+		return this.createGeometry( pts );
+
+	},
+
+	createSpacedPointsGeometry: function ( divisions ) {
+
+		console.warn( 'THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.' );
+
+		// generate geometry from equidistant sampling along the path
+
+		var pts = this.getSpacedPoints( divisions );
+		return this.createGeometry( pts );
+
+	},
+
+	createGeometry: function ( points ) {
+
+		console.warn( 'THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.' );
+
+		var geometry = new Geometry();
+
+		for ( var i = 0, l = points.length; i < l; i ++ ) {
+
+			var point = points[ i ];
+			geometry.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );
+
+		}
+
+		return geometry;
+
+	}
+
+} );
+
+//
+
 function ClosedSplineCurve3( points ) {
 
 	console.warn( 'THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.' );
@@ -43308,9 +43415,21 @@ Object.assign( Vector2.prototype, {
 
 	fromAttribute: function ( attribute, index, offset ) {
 
-		console.error( 'THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute().' );
+		console.warn( 'THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute().' );
 		return this.fromBufferAttribute( attribute, index, offset );
 
+	},
+	distanceToManhattan: function ( v ) {
+
+		console.warn( 'THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo().' );
+		return this.manhattanDistanceTo( v );
+
+	},
+	lengthManhattan: function () {
+
+		console.warn( 'THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength().' );
+		return this.manhattanLength();
+
 	}
 
 } );
@@ -43353,9 +43472,21 @@ Object.assign( Vector3.prototype, {
 	},
 	fromAttribute: function ( attribute, index, offset ) {
 
-		console.error( 'THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute().' );
+		console.warn( 'THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute().' );
 		return this.fromBufferAttribute( attribute, index, offset );
 
+	},
+	distanceToManhattan: function ( v ) {
+
+		console.warn( 'THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo().' );
+		return this.manhattanDistanceTo( v );
+
+	},
+	lengthManhattan: function () {
+
+		console.warn( 'THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength().' );
+		return this.manhattanLength();
+
 	}
 
 } );
@@ -43364,9 +43495,15 @@ Object.assign( Vector4.prototype, {
 
 	fromAttribute: function ( attribute, index, offset ) {
 
-		console.error( 'THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute().' );
+		console.warn( 'THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute().' );
 		return this.fromBufferAttribute( attribute, index, offset );
 
+	},
+	lengthManhattan: function () {
+
+		console.warn( 'THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength().' );
+		return this.manhattanLength();
+
 	}
 
 } );

+ 3 - 0
docs/api/core/BufferGeometry.html

@@ -316,6 +316,9 @@
 		<h3>[method:BufferGeometry setFromObject] ( [page:Object3D object] )</h3>
 		<div>Sets the attributes for this BufferGeometry from an [page:Object3D].</div>
 
+		<h3>[method:BufferGeometry setFromPoints] ( [page:Array points] )</h3>
+		<div>Sets the attributes for this BufferGeometry from an array of points.</div>
+
 		<h3>[method:Object toJSON]()</h3>
 		<div>Returns a JSON object representation of the BufferGeometry.</div>
 

+ 3 - 0
docs/api/core/Geometry.html

@@ -315,6 +315,9 @@
 	        Use [page:Object3D.rotation] for typical real-time mesh rotation.
 		</div>
 
+		<h3>[method:Geometry setFromPoints] ( [page:Array points] )</h3>
+		<div>Sets the vertices for this Geometry from an array of points.</div>
+
 		<h3>[method:null sortFacesByMaterialIndex] (  )</h3>
 		<div>
 		Sorts the faces array according to material index. For complex geometries with several materials,

+ 0 - 23
docs/api/extras/core/CurvePath.html

@@ -49,29 +49,6 @@
 		<h3>[method:null closePath]()</h3>
 		<div>Adds a [page:LineCurve lineCurve] to close the path.</div>
 
-		<h3>[method:Geometry createGeometry]( [page:Vector3 points] )</h3>
-		<div>
-		points -- An array of [page:Vector3 Vector3s]<br /><br />
-
-		Creates a geometry from points
-		</div>
-
-		<h3>[method:Geometry createPointsGeometry]( [page:Integer divisions] )</h3>
-		<div>
-		divisions -- How many segments to create. Defaults to *12*.<br /><br />
-
-		Creates a [page:Geometry] object comprised of [page:Vector3 Vector3s], for example
-		to be used with [page:Line] or [page:Points]. Uses [page:Curve.getPoints]() for the division.
-		</div>
-
-		<h3>[method:Geometry createSpacedPointsGeometry]( [page:Integer divisions] )</h3>
-		<div>
-		divisions -- How many segments to create. Defaults to *12*.<br /><br />
-
-		Creates a [page:Geometry] object comprised of [page:Vector3]s that are equidistant, for example
-		to be used with [page:Line] or [page:Points].	Uses [page:Curve.getSpacedPoints]() for the division.
-		</div>
-
 		<h3>[method:Float getCurveLengths]()</h3>
 		<div>Adds together the lengths of the curves in the [page:.curves] array.</div>
 

+ 2 - 2
docs/api/extras/curves/CatmullRomCurve3.html

@@ -27,8 +27,8 @@ var curve = new THREE.CatmullRomCurve3( [
 	new THREE.Vector3( 10, 0, 10 )
 ] );
 
-var geometry = new THREE.Geometry();
-geometry.vertices = curve.getPoints( 50 );
+var points = curve.getPoints( 50 );
+var geometry = new THREE.BufferGeometry().setFromPoints( points );
 
 var material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
 

+ 6 - 6
docs/api/extras/curves/CubicBezierCurve.html

@@ -22,15 +22,15 @@
 
 <code>
 var curve = new THREE.CubicBezierCurve(
-	new THREE.Vector2( -10, 0, 0 ),
-	new THREE.Vector2( -5, 15, 0 ),
-	new THREE.Vector2( 20, 15, 0 ),
-	new THREE.Vector2( 10, 0, 0 )
+	new THREE.Vector2( -10, 0 ),
+	new THREE.Vector2( -5, 15 ),
+	new THREE.Vector2( 20, 15 ),
+	new THREE.Vector2( 10, 0 )
 );
 
-var path = new THREE.Path( curve.getPoints( 50 ) );
+var points = curve.getPoints( 50 );
+var geometry = new THREE.BufferGeometry().setFromPoints( points );
 
-var geometry = path.createPointsGeometry( 50 );
 var material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
 
 // Create the final object to add to the scene

+ 2 - 2
docs/api/extras/curves/CubicBezierCurve3.html

@@ -28,8 +28,8 @@ var curve = new THREE.CubicBezierCurve3(
 	new THREE.Vector3( 10, 0, 0 )
 );
 
-var geometry = new THREE.Geometry();
-geometry.vertices = curve.getPoints( 50 );
+var points = curve.getPoints( 50 );
+var geometry = new THREE.BufferGeometry().setFromPoints( points );
 
 var material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
 

+ 3 - 2
docs/api/extras/curves/EllipseCurve.html

@@ -28,8 +28,9 @@ var curve = new THREE.EllipseCurve(
 	0                 // aRotation
 );
 
-var path = new THREE.Path( curve.getPoints( 50 ) );
-var geometry = path.createPointsGeometry( 50 );
+var points = curve.getPoints( 50 );
+var geometry = new THREE.BufferGeometry().setFromPoints( points );
+
 var material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
 
 // Create the final object to add to the scene

+ 2 - 2
docs/api/extras/curves/QuadraticBezierCurve.html

@@ -27,9 +27,9 @@ var curve = new THREE.QuadraticBezierCurve(
 	new THREE.Vector2( 10, 0 )
 );
 
-var path = new THREE.Path( curve.getPoints( 50 ) );
+var points = curve.getPoints( 50 );
+var geometry = new THREE.BufferGeometry().setFromPoints( points );
 
-var geometry = path.createPointsGeometry( 50 );
 var material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
 
 //Create the final object to add to the scene

+ 2 - 2
docs/api/extras/curves/QuadraticBezierCurve3.html

@@ -27,8 +27,8 @@ var curve = new THREE.QuadraticBezierCurve3(
 	new THREE.Vector3( 10, 0, 0 )
 );
 
-var geometry = new THREE.Geometry();
-geometry.vertices = curve.getPoints( 50 );
+var points = curve.getPoints( 50 );
+var geometry = new THREE.BufferGeometry().setFromPoints( points );
 
 var material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
 

+ 2 - 2
docs/api/extras/curves/SplineCurve.html

@@ -29,9 +29,9 @@ var curve = new THREE.SplineCurve( [
 	new THREE.Vector2( 10, 0 )
 ] );
 
-var path = new THREE.Path( curve.getPoints( 50 ) );
+var points = curve.getPoints( 50 );
+var geometry = new THREE.BufferGeometry().setFromPoints( points );
 
-var geometry = path.createPointsGeometry( 50 );
 var material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
 
 // Create the final object to add to the scene

+ 2 - 2
docs/api/geometries/CircleGeometry.html

@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html lang="en">
 	<head>
-		<meta charset="utf-8" />
+		<meta charset="utf-8" />
 		<base href="../../" />
 		<script src="list.js"></script>
 		<script src="page.js"></script>
@@ -46,7 +46,7 @@
 
 		<h3>[name]([page:Float radius], [page:Integer segments], [page:Float thetaStart], [page:Float thetaLength])</h3>
 		<div>
-		radius — Radius of the circle, default = 50.<br />
+		radius — Radius of the circle, default = 1.<br />
 		segments — Number of segments (triangles), minimum = 3, default = 8.<br />
 		thetaStart — Start angle for first segment, default = 0 (three o'clock position).<br />
 		thetaLength — The central angle, often called theta, of the circular sector. The default is 2*Pi, which makes for a complete circle.

+ 4 - 4
docs/api/geometries/CylinderGeometry.html

@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html lang="en">
 	<head>
-		<meta charset="utf-8" />
+		<meta charset="utf-8" />
 		<base href="../../" />
 		<script src="list.js"></script>
 		<script src="page.js"></script>
@@ -44,9 +44,9 @@
 
 		<h3>[name]([page:Float radiusTop], [page:Float radiusBottom], [page:Float height], [page:Integer radiusSegments], [page:Integer heightSegments], [page:Boolean openEnded], [page:Float thetaStart], [page:Float thetaLength])</h3>
 		<div>
-		radiusTop — Radius of the cylinder at the top. Default is 20.<br />
-		radiusBottom — Radius of the cylinder at the bottom. Default is 20.<br />
-		height — Height of the cylinder. Default is 100.<br />
+		radiusTop — Radius of the cylinder at the top. Default is 1.<br />
+		radiusBottom — Radius of the cylinder at the bottom. Default is 1.<br />
+		height — Height of the cylinder. Default is 1.<br />
 		radiusSegments — Number of segmented faces around the circumference of the cylinder. Default is 8<br />
 		heightSegments — Number of rows of faces along the height of the cylinder. Default is 1.<br />
 		openEnded — A Boolean indicating whether the ends of the cylinder are open or capped. Default is false, meaning capped.<br />

+ 3 - 3
docs/api/geometries/RingGeometry.html

@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html lang="en">
 	<head>
-		<meta charset="utf-8" />
+		<meta charset="utf-8" />
 		<base href="../../" />
 		<script src="list.js"></script>
 		<script src="page.js"></script>
@@ -44,8 +44,8 @@
 
 		<h3>[name]([page:Float innerRadius], [page:Float outerRadius], [page:Integer thetaSegments], [page:Integer phiSegments], [page:Float thetaStart], [page:Float thetaLength])</h3>
 		<div>
-		innerRadius — Default is 20. <br />
-		outerRadius — Default is 50. <br />
+		innerRadius — Default is 0.5. <br />
+		outerRadius — Default is 1. <br />
 		thetaSegments — Number of segments.  A higher number means the ring will be more round.  Minimum is 3.  Default is 8. <br />
 		phiSegments — Minimum is 1.  Default is 8.<br />
 		thetaStart — Starting angle. Default is 0. <br />

+ 2 - 2
docs/api/geometries/SphereGeometry.html

@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html lang="en">
 	<head>
-		<meta charset="utf-8" />
+		<meta charset="utf-8" />
 		<base href="../../" />
 		<script src="list.js"></script>
 		<script src="page.js"></script>
@@ -45,7 +45,7 @@
 		<h3>[name]([page:Float radius], [page:Integer widthSegments], [page:Integer heightSegments], [page:Float phiStart], [page:Float phiLength], [page:Float thetaStart], [page:Float thetaLength])</h3>
 
 		<div>
-		radius — sphere radius. Default is 50.<br />
+		radius — sphere radius. Default is 1.<br />
 		widthSegments — number of horizontal segments. Minimum value is 3, and the default is 8.<br />
 		heightSegments — number of vertical segments. Minimum value is 2, and the default is 6.<br />
 		phiStart — specify horizontal starting angle. Default is 0.<br />

+ 3 - 3
docs/api/geometries/TorusGeometry.html

@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html lang="en">
 	<head>
-		<meta charset="utf-8" />
+		<meta charset="utf-8" />
 		<base href="../../" />
 		<script src="list.js"></script>
 		<script src="page.js"></script>
@@ -44,8 +44,8 @@
 
 		<h3>[name]([page:Float radius], [page:Float tube], [page:Integer radialSegments], [page:Integer tubularSegments], [page:Float arc])</h3>
 		<div>
-		radius — Default is 100. <br />
-		tube — Diameter of the tube.  Default is 40. <br />
+		radius — Default is 1. <br />
+		tube — Diameter of the tube.  Default is 0.4. <br />
 		radialSegments — Default is 8 <br />
 		tubularSegments — Default is 6. <br />
 		arc — Central angle.  Default is Math.PI * 2.

+ 3 - 3
docs/api/geometries/TorusKnotGeometry.html

@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html lang="en">
 	<head>
-		<meta charset="utf-8" />
+		<meta charset="utf-8" />
 		<base href="../../" />
 		<script src="list.js"></script>
 		<script src="page.js"></script>
@@ -45,8 +45,8 @@
 		<h3>[name]([page:Float radius], [page:Float tube], [page:Integer tubularSegments], [page:Integer radialSegments], [page:Integer p], [page:Integer q])</h3>
 		<div>
 			<ul>
-				<li>radius — Default is 100.</li>
-				<li>tube — Diameter of the tube. Default is 40.</li>
+				<li>radius — Default is 1.</li>
+				<li>tube — Diameter of the tube. Default is 0.4.</li>
 				<li>tubularSegments — Default is 64.</li>
 				<li>radialSegments — Default is 8.</li>
 				<li>p — This value determines, how many times the geometry winds around its axis of rotational symmetry. Default is 2.</li>

+ 78 - 78
docs/api/helpers/VertexNormalsHelper.html

@@ -1,79 +1,79 @@
-<!DOCTYPE html>
-<html lang="en">
-	<head>
+<!DOCTYPE html>
+<html lang="en">
+	<head>
 		<meta charset="utf-8" />
-		<base href="../../" />
-		<script src="list.js"></script>
-		<script src="page.js"></script>
-		<link type="text/css" rel="stylesheet" href="page.css" />
-	</head>
-	<body>
-		[page:Line] &rarr;
-
-		<h1>[name]</h1>
-
-		<div class="desc">
-			Renders [page:ArrowHelper arrows] to visualize an object's vertex normal vectors.
-			Requires that normals have been specified in a [page:BufferAttribute custom attribute] or
-			have been calculated using [page:Geometry.computeVertexNormals computeVertexNormals].<br /><br />
-
-			Unline [page:FaceNormalsHelper], this works with [page:BufferGeometry].
-		</div>
-
-		<h2>Example</h2>
-
-		[example:webgl_helpers WebGL / helpers]
-
-		<code>
-		var geometry = new THREE.BoxGeometry( 10, 10, 10, 2, 2, 2 );
-		var material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
-		var box = new THREE.Mesh( geometry, material );
-
-		var helper = new THREE.VertexNormalsHelper( box, 2, 0x00ff00, 1 );
-
-		scene.add( box );
-		scene.add( helper );
-		</code>
-
-
-		<h2>Constructor</h2>
-
-
-		<h3>[name]( [page:Object3D object], [page:Number size], [page:Hex color], [page:Number linewidth] )</h3>
-		<div>
-			[page:Object3D object] -- object for which to render vertex normals.<br />
-			[page:Number size] -- (optional) length of the arrows. Default is 1.<br />
-			[page:Hex color] -- hex color of the arrows. Default is 0xff0000.<br />
-			[page:Number linewidth] -- (optional) width of the arrow lines. Default is 1.
-		</div>
-
-
-		<h2>Properties</h2>
-		<div>See the base [page:LineSegments] class for common properties.</div>
-
-		<h3>[property:object matrixAutoUpdate]</h3>
-		<div>
-			See [page:Object3D.matrixAutoUpdate]. Set to *false* here as the helper is using the
-			objects's [page:Object3D.matrixWorld matrixWorld].
-		</div>
-
-		<h3>[property:Object3D object]</h3>
-		<div>The object for which the vertex normals are being visualized.</div>
-
-		<h3>[property:Number size]</h3>
-		<div>Length of the arrows. Default is *1*.</div>
-
-
-		<h2>Methods</h2>
-		<div>See the base [page:LineSegments] class for common methods.</div>
-
-
-		<h3>[method:null update]()</h3>
-		<div>Updates the vertex normal preview based on movement of the object.</div>
-
-
-		<h2>Source</h2>
-
-		[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
-	</body>
-</html>
+		<base href="../../" />
+		<script src="list.js"></script>
+		<script src="page.js"></script>
+		<link type="text/css" rel="stylesheet" href="page.css" />
+	</head>
+	<body>
+		[page:Line] &rarr;
+
+		<h1>[name]</h1>
+
+		<div class="desc">
+			Renders [page:ArrowHelper arrows] to visualize an object's vertex normal vectors.
+			Requires that normals have been specified in a [page:BufferAttribute custom attribute] or
+			have been calculated using [page:Geometry.computeVertexNormals computeVertexNormals].<br /><br />
+
+			Unlike [page:FaceNormalsHelper], this works with [page:BufferGeometry].
+		</div>
+
+		<h2>Example</h2>
+
+		[example:webgl_helpers WebGL / helpers]
+
+		<code>
+		var geometry = new THREE.BoxGeometry( 10, 10, 10, 2, 2, 2 );
+		var material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
+		var box = new THREE.Mesh( geometry, material );
+
+		var helper = new THREE.VertexNormalsHelper( box, 2, 0x00ff00, 1 );
+
+		scene.add( box );
+		scene.add( helper );
+		</code>
+
+
+		<h2>Constructor</h2>
+
+
+		<h3>[name]( [page:Object3D object], [page:Number size], [page:Hex color], [page:Number linewidth] )</h3>
+		<div>
+			[page:Object3D object] -- object for which to render vertex normals.<br />
+			[page:Number size] -- (optional) length of the arrows. Default is 1.<br />
+			[page:Hex color] -- hex color of the arrows. Default is 0xff0000.<br />
+			[page:Number linewidth] -- (optional) width of the arrow lines. Default is 1.
+		</div>
+
+
+		<h2>Properties</h2>
+		<div>See the base [page:LineSegments] class for common properties.</div>
+
+		<h3>[property:object matrixAutoUpdate]</h3>
+		<div>
+			See [page:Object3D.matrixAutoUpdate]. Set to *false* here as the helper is using the
+			objects's [page:Object3D.matrixWorld matrixWorld].
+		</div>
+
+		<h3>[property:Object3D object]</h3>
+		<div>The object for which the vertex normals are being visualized.</div>
+
+		<h3>[property:Number size]</h3>
+		<div>Length of the arrows. Default is *1*.</div>
+
+
+		<h2>Methods</h2>
+		<div>See the base [page:LineSegments] class for common methods.</div>
+
+
+		<h3>[method:null update]()</h3>
+		<div>Updates the vertex normal preview based on movement of the object.</div>
+
+
+		<h2>Source</h2>
+
+		[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+	</body>
+</html>

+ 8 - 0
docs/api/renderers/WebGLRenderer.html

@@ -225,6 +225,14 @@
 		<h3>[property:Boolean shadowMap.enabled]</h3>
 		<div>If set, use shadow maps in the scene. Default is *false*.</div>
 
+		<h3>[property:Boolean shadowMap.autoUpdate]</h3>
+		<div>Enables automatic updates to the shadows in the scene. Default is *true*.</div>
+		<div>If you do not require dynamic lighting / shadows, you may set this to *false* when the renderer is instantiated.</div>
+
+		<h3>[property:Boolean shadowMap.needsUpdate]</h3>
+		<div>When set to *true*, shadow maps in the scene will be updated in the next *render* call. Default is *false*. </div>
+		<div>If you have disabled automatic updates to shadow maps (*shadowMap.autoUpdate = false*), you will need to set this to *true* and then make a render call to update the shadows in your scene.</div>
+
 		<h3>[property:Integer shadowMap.type]</h3>
 		<div>Defines shadow map type (unfiltered, percentage close filtering, percentage close filtering with bilinear filtering in shader)</div>
 		<div>Options are THREE.BasicShadowMap, THREE.PCFShadowMap (default), THREE.PCFSoftShadowMap. See [page:WebGLRenderer WebGLRenderer constants] for details.</div>

+ 3 - 2
docs/examples/exporters/GLTFExporter.html

@@ -72,16 +72,17 @@ exporter.parse( [ scene1, object1, object2, scene2 ], ...)
 			</code>
 		</ul>
 
-		[page:Function onCompleted] — Will be called when the export completes. The argument will be the generated glTF JSON.<br />
+		[page:Function onCompleted] — Will be called when the export completes. The argument will be the generated glTF JSON or binary ArrayBuffer.<br />
 		[page:Options options] - Export options<br />
 		<ul>
 			<li>trs - bool. Export position, rotation and scale instead of matrix per node. Default is false</li>
 			<li>onlyVisible - bool. Export only visible objects. Default is true.</li>
 			<li>truncateDrawRange - bool. Export just the attributes within the drawRange, if defined, instead of exporting the whole array. Default is true.</li>
+			<li>binary - bool. Export in binary (.glb) format, returning an ArrayBuffer. Default is false.</li>
 		</ul>
 		</div>
 		<div>
-		Generates a glTF output (JSON) with from the input (Scene or Objects)
+		Generates a .gltf (JSON) or .glb (binary) output from the input (Scene or Objects)
 		</div>
 
 		<h2>Source</h2>

+ 2 - 2
docs/index.html

@@ -307,7 +307,7 @@
 				if(hash) {
 
 					iframe.src = splitHash[ 0 ] + '.html' + splitHash[ 1 ];
-					subtitle = ' - ' + titles[ splitHash[ 0 ] ] + splitHash[ 1 ];
+					subtitle = titles[ splitHash[ 0 ] ] + splitHash[ 1 ] + ' - ';
 
 				} else {
 
@@ -317,7 +317,7 @@
 				}
 
 				document.body.replaceChild( iframe, oldIframe );
-				document.title = 'three.js docs' + subtitle;
+				document.title = subtitle + 'three.js docs';
 
 			}
 

+ 2 - 2
docs/page.js

@@ -24,7 +24,7 @@ if ( !window.frameElement && window.location.protocol !== 'file:' ) {
 }
 
 
-var onDocumentLoad = function ( event ) {
+function onDocumentLoad( event ) {
 
 	var path;
 	var pathname = window.location.pathname;
@@ -69,7 +69,7 @@ var onDocumentLoad = function ( event ) {
 	text = text.replace( /\[example:([\w\_]+)\]/gi, "[example:$1 $1]" ); // [example:name] to [example:name title]
 	text = text.replace( /\[example:([\w\_]+) ([\w\:\/\.\-\_ \s]+)\]/gi, "<a href=\"../examples/#$1\"  target=\"_blank\">$2</a>" ); // [example:name title]
 
-	
+
 	document.body.innerHTML = text;
 
 	// handle code snippets formatting

+ 0 - 32
editor/js/libs/tern-threejs/threejs.js

@@ -924,34 +924,10 @@
           "!type": "boolean",
           "!doc": "todo"
         },
-        "getWrapPoints": {
-          "!type": "fn(oldPts: todo, path: todo) -> todo",
-          "!doc": "todo"
-        },
-        "createPointsGeometry": {
-          "!type": "fn(divisions: todo) -> todo",
-          "!doc": "todo"
-        },
-        "addWrapPath": {
-          "!type": "fn(bendpath: todo) -> todo",
-          "!doc": "todo"
-        },
-        "createGeometry": {
-          "!type": "fn(points: todo) -> todo",
-          "!doc": "todo"
-        },
         "add": {
           "!type": "fn(curve: todo) -> todo",
           "!doc": "todo"
         },
-        "getTransformedSpacedPoints": {
-          "!type": "fn(segments: todo, bends: todo) -> todo",
-          "!doc": "todo"
-        },
-        "createSpacedPointsGeometry": {
-          "!type": "fn(divisions: todo) -> todo",
-          "!doc": "todo"
-        },
         "closePath": {
           "!type": "fn() -> todo",
           "!doc": "todo"
@@ -963,14 +939,6 @@
         "getCurveLengths": {
           "!type": "fn() -> todo",
           "!doc": "todo"
-        },
-        "getTransformedPoints": {
-          "!type": "fn(segments: todo, bends: todo) -> todo",
-          "!doc": "todo"
-        },
-        "checkConnection": {
-          "!type": "fn() -> todo",
-          "!doc": "todo"
         }
       },
       "!doc": "todo",

+ 2 - 2
examples/canvas_geometry_shapes.html

@@ -82,8 +82,8 @@
 
 					// line
 
-					var geometry = shape.createPointsGeometry();
-					geometry.vertices.push( geometry.vertices[ 0 ].clone() );
+					var points = shape.getPoints();
+					var geometry = new THREE.Geometry().setFromPoints( points );
 
 					var material = new THREE.LineBasicMaterial( { linewidth: 10, color: 0x333333, transparent: true } );
 

+ 23 - 23
examples/js/CurveExtras.js

@@ -40,11 +40,11 @@
 
 	// HeartCurve
 
-	function HeartCurve( s ) {
+	function HeartCurve( scale ) {
 
 		THREE.Curve.call( this );
 
-		this.scale = ( s === undefined ) ? 5 : s;
+		this.scale = ( scale === undefined ) ? 5 : scale;
 
 	}
 
@@ -67,11 +67,11 @@
 
 	// Viviani's Curve
 
-	function VivianiCurve( radius ) {
+	function VivianiCurve( scale ) {
 
 		THREE.Curve.call( this );
 
-		this.radius = radius;
+		this.scale = ( scale === undefined ) ? 70 : scale;
 
 	}
 
@@ -83,7 +83,7 @@
 		var point = optionalTarget || new THREE.Vector3();
 
 		t = t * 4 * Math.PI; // normalized to 0..1
-		var a = this.radius / 2;
+		var a = this.scale / 2;
 
 		var x = a * ( 1 + Math.cos( t ) );
 		var y = a * Math.sin( t );
@@ -151,11 +151,11 @@
 
 	// TrefoilKnot
 
-	function TrefoilKnot( s ) {
+	function TrefoilKnot( scale ) {
 
 		THREE.Curve.call( this );
 
-		this.scale = ( s === undefined ) ? 10 : s;
+		this.scale = ( scale === undefined ) ? 10 : scale;
 
 	}
 
@@ -178,11 +178,11 @@
 
 	// TorusKnot
 
-	function TorusKnot( s ) {
+	function TorusKnot( scale ) {
 
 		THREE.Curve.call( this );
 
-		this.scale = ( s === undefined ) ? 10 : s;
+		this.scale = ( scale === undefined ) ? 10 : scale;
 
 	}
 
@@ -208,11 +208,11 @@
 
 	// CinquefoilKnot
 
-	function CinquefoilKnot( s ) {
+	function CinquefoilKnot( scale ) {
 
 		THREE.Curve.call( this );
 
-		this.scale = ( s === undefined ) ? 10 : s;
+		this.scale = ( scale === undefined ) ? 10 : scale;
 
 	}
 
@@ -238,11 +238,11 @@
 
 	// TrefoilPolynomialKnot
 
-	function TrefoilPolynomialKnot( s ) {
+	function TrefoilPolynomialKnot( scale ) {
 
 		THREE.Curve.call( this );
 
-		this.scale = ( s === undefined ) ? 10 : s;
+		this.scale = ( scale === undefined ) ? 10 : scale;
 
 	}
 
@@ -272,11 +272,11 @@
 
 	// FigureEightPolynomialKnot
 
-	function FigureEightPolynomialKnot( s ) {
+	function FigureEightPolynomialKnot( scale ) {
 
 		THREE.Curve.call( this );
 
-		this.scale = ( s === undefined ) ? 1 : s;
+		this.scale = ( scale === undefined ) ? 1 : scale;
 
 	}
 
@@ -299,11 +299,11 @@
 
 	// DecoratedTorusKnot4a
 
-	function DecoratedTorusKnot4a( s ) {
+	function DecoratedTorusKnot4a( scale ) {
 
 		THREE.Curve.call( this );
 
-		this.scale = ( s === undefined ) ? 40 : s;
+		this.scale = ( scale === undefined ) ? 40 : scale;
 
 	}
 
@@ -326,11 +326,11 @@
 
 	// DecoratedTorusKnot4b
 
-	function DecoratedTorusKnot4b( s ) {
+	function DecoratedTorusKnot4b( scale ) {
 
 		THREE.Curve.call( this );
 
-		this.scale = ( s === undefined ) ? 40 : s;
+		this.scale = ( scale === undefined ) ? 40 : scale;
 
 	}
 
@@ -353,11 +353,11 @@
 
 	// DecoratedTorusKnot5a
 
-	function DecoratedTorusKnot5a( s ) {
+	function DecoratedTorusKnot5a( scale ) {
 
 		THREE.Curve.call( this );
 
-		this.scale = ( s === undefined ) ? 40 : s;
+		this.scale = ( scale === undefined ) ? 40 : scale;
 
 	}
 
@@ -380,11 +380,11 @@
 
 	// DecoratedTorusKnot5c
 
-	function DecoratedTorusKnot5c( s ) {
+	function DecoratedTorusKnot5c( scale ) {
 
 		THREE.Curve.call( this );
 
-		this.scale = ( s === undefined ) ? 40 : s;
+		this.scale = ( scale === undefined ) ? 40 : scale;
 
 	}
 

+ 4 - 3
examples/js/Octree.js

@@ -119,8 +119,9 @@
 		
 		if ( this.scene ) {
 			
-			this.visualGeometry = new THREE.BoxGeometry( 1, 1, 1 );
-			this.visualMaterial = new THREE.MeshBasicMaterial( { color: 0xFF0066, wireframe: true, wireframeLinewidth: 1 } );
+			var helper = new THREE.BoxHelper( new THREE.Mesh( new THREE.BoxGeometry( 1, 1, 1 ) ), 0xff0066 );
+			this.visualGeometry = helper.geometry;
+			this.visualMaterial = helper.material;
 			
 		}
 		
@@ -773,7 +774,7 @@
 		
 		if ( this.tree.scene ) {
 			
-			this.visual = new THREE.Mesh( this.tree.visualGeometry, this.tree.visualMaterial );
+			this.visual = new THREE.LineSegments( this.tree.visualGeometry, this.tree.visualMaterial );
 			this.visual.scale.set( this.radiusOverlap * 2, this.radiusOverlap * 2, this.radiusOverlap * 2 );
 			this.visual.position.copy( this.position );
 			this.tree.scene.add( this.visual );

+ 2 - 2
examples/js/animation/MMDPhysics.js

@@ -59,7 +59,7 @@ THREE.MMDPhysics.prototype = {
 
 		var helper = this.helper;
 		var currentPosition = helper.allocThreeVector3();
-		var currentRotation = helper.allocThreeVector3();
+		var currentRotation = helper.allocThreeEuler();
 		var currentScale = helper.allocThreeVector3();
 
 		currentPosition.copy( mesh.position );
@@ -91,7 +91,7 @@ THREE.MMDPhysics.prototype = {
 		this.reset();
 
 		helper.freeThreeVector3( currentPosition );
-		helper.freeThreeVector3( currentRotation );
+		helper.freeThreeEuler( currentRotation );
 		helper.freeThreeVector3( currentScale );
 
 	},

+ 95 - 7
examples/js/exporters/GLTFExporter.js

@@ -54,6 +54,7 @@ THREE.GLTFExporter.prototype = {
 	 * @param  {Function} onDone  Callback on completed
 	 * @param  {Object} options options
 	 *                          trs: Exports position, rotation and scale instead of matrix
+	 *                          binary: Exports `.glb` as ArrayBuffer, instead of `.gltf` as JSON
 	 */
 	parse: function ( input, onDone, options ) {
 
@@ -104,6 +105,33 @@ THREE.GLTFExporter.prototype = {
 
 		}
 
+		/**
+		 * Converts a string to an ArrayBuffer.
+		 * @param  {string} text
+		 * @return {ArrayBuffer}
+		 */
+		function stringToArrayBuffer( text ) {
+
+			if ( window.TextEncoder !== undefined ) {
+
+				return new TextEncoder().encode( text ).buffer;
+
+			}
+
+			var buffer = new ArrayBuffer( text.length * 2 ); // 2 bytes per character.
+
+			var bufferView = new Uint16Array( buffer );
+
+			for ( var i = 0; i < text.length; ++ i ) {
+
+				bufferView[ i ] = text.charCodeAt( i );
+
+			}
+
+			return buffer;
+
+		}
+
 		/**
 		 * Get the min and he max vectors from the given attribute
 		 * @param  {THREE.WebGLAttribute} attribute Attribute to find the min/max
@@ -1002,17 +1030,77 @@ THREE.GLTFExporter.prototype = {
 		if ( outputJSON.buffers && outputJSON.buffers.length > 0 ) {
 
 			outputJSON.buffers[ 0 ].byteLength = blob.size;
-			var objectURL = URL.createObjectURL( blob );
 
 			var reader = new window.FileReader();
-			reader.readAsDataURL( blob );
-			reader.onloadend = function () {
 
-				var base64data = reader.result;
-				outputJSON.buffers[ 0 ].uri = base64data;
-				onDone( outputJSON );
+			if ( options.binary === true ) {
+
+				// https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#glb-file-format-specification
+
+				var GLB_HEADER_BYTES = 12;
+				var GLB_HEADER_MAGIC = 0x46546C67;
+				var GLB_VERSION = 2;
+
+				var GLB_CHUNK_PREFIX_BYTES = 8;
+				var GLB_CHUNK_TYPE_JSON = 0x4E4F534A;
+				var GLB_CHUNK_TYPE_BIN = 0x004E4942;
+
+				reader.readAsArrayBuffer( blob );
+				reader.onloadend = function () {
+
+					// Binary chunk.
+					var binaryChunk = reader.result;
+					var binaryChunkPrefix = new DataView( new ArrayBuffer( GLB_CHUNK_PREFIX_BYTES ) );
+					binaryChunkPrefix.setUint32( 0, binaryChunk.byteLength, true );
+					binaryChunkPrefix.setUint32( 4, GLB_CHUNK_TYPE_BIN, true );
+
+					// JSON chunk.
+					delete outputJSON.buffers[ 0 ].uri; // Omitted URI indicates use of binary chunk.
+					var jsonChunk = stringToArrayBuffer( JSON.stringify( outputJSON ) );
+					var jsonChunkPrefix = new DataView( new ArrayBuffer( GLB_CHUNK_PREFIX_BYTES ) );
+					jsonChunkPrefix.setUint32( 0, jsonChunk.byteLength, true );
+					jsonChunkPrefix.setUint32( 4, GLB_CHUNK_TYPE_JSON, true );
+
+					// GLB header.
+					var header = new ArrayBuffer( GLB_HEADER_BYTES );
+					var headerView = new DataView( header );
+					headerView.setUint32( 0, GLB_HEADER_MAGIC, true );
+					headerView.setUint32( 4, GLB_VERSION, true );
+					var totalByteLength = GLB_HEADER_BYTES
+						+ jsonChunkPrefix.byteLength + jsonChunk.byteLength
+						+ binaryChunkPrefix.byteLength + binaryChunk.byteLength;
+					headerView.setUint32( 8, totalByteLength, true );
+
+					var glbBlob = new Blob( [
+						header,
+						jsonChunkPrefix,
+						jsonChunk,
+						binaryChunkPrefix,
+						binaryChunk
+					], { type: 'application/octet-stream' } );
+
+					var glbReader = new window.FileReader();
+					glbReader.readAsArrayBuffer( glbBlob );
+					glbReader.onloadend = function () {
+
+						onDone( glbReader.result );
 
-			};
+					};
+
+				};
+
+			} else {
+
+				reader.readAsDataURL( blob );
+				reader.onloadend = function () {
+
+					var base64data = reader.result;
+					outputJSON.buffers[ 0 ].uri = base64data;
+					onDone( outputJSON );
+
+				};
+
+			}
 
 		} else {
 

+ 32 - 13
examples/js/loaders/ColladaLoader.js

@@ -128,6 +128,12 @@ THREE.ColladaLoader.prototype = {
 
 		}
 
+		function generateId() {
+
+			return 'three_default_' + ( count ++ );
+
+		}
+
 		function isEmpty( object ) {
 
 			return Object.keys( object ).length === 0;
@@ -2719,6 +2725,26 @@ THREE.ColladaLoader.prototype = {
 
 		// nodes
 
+		function prepareNodes( xml ) {
+
+			var elements = xml.getElementsByTagName( 'node' );
+
+			// ensure all node elements have id attributes
+
+			for ( var i = 0; i < elements.length; i ++ ) {
+
+				var element = elements[ i ];
+
+				if ( element.hasAttribute( 'id' ) === false ) {
+
+					element.setAttribute( 'id', generateId() );
+
+				}
+
+			}
+
+		}
+
 		var matrix = new THREE.Matrix4();
 		var vector = new THREE.Vector3();
 
@@ -2748,14 +2774,8 @@ THREE.ColladaLoader.prototype = {
 				switch ( child.nodeName ) {
 
 					case 'node':
-
-						if ( child.hasAttribute( 'id' ) ) {
-
-							data.nodes.push( child.getAttribute( 'id' ) );
-							parseNode( child );
-
-						}
-
+						data.nodes.push( child.getAttribute( 'id' ) );
+						parseNode( child );
 						break;
 
 					case 'instance_camera':
@@ -2814,11 +2834,7 @@ THREE.ColladaLoader.prototype = {
 
 			}
 
-			if ( xml.hasAttribute( 'id' ) ) {
-
-				library.nodes[ xml.getAttribute( 'id' ) ] = data;
-
-			}
+			library.nodes[ data.id ] = data;
 
 			return data;
 
@@ -3220,6 +3236,8 @@ THREE.ColladaLoader.prototype = {
 				children: []
 			};
 
+			prepareNodes( xml );
+
 			var elements = getElementsByTagName( xml, 'node' );
 
 			for ( var i = 0; i < elements.length; i ++ ) {
@@ -3345,6 +3363,7 @@ THREE.ColladaLoader.prototype = {
 
 		var animations = [];
 		var kinematics = {};
+		var count = 0;
 
 		//
 

+ 145 - 122
examples/js/loaders/FBXLoader.js

@@ -238,6 +238,7 @@
 				break;
 
 			case 'jpg':
+			case 'jpeg':
 
 				type = 'image/jpeg';
 				break;
@@ -261,14 +262,6 @@
 
 		if ( typeof content === 'string' ) {
 
-			// ASCII format sometimes an extra ',' gets added to the end of the content string
-			// TODO: Investigate why the parser is adding this character
-			if ( content.slice( - 1 ) === ',' ) {
-
-				content = content.slice( 0, - 1 );
-
-			}
-
 			return 'data:' + type + ';base64,' + content;
 
 		} else {
@@ -386,6 +379,15 @@
 		texture.wrapS = valueU === 0 ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping;
 		texture.wrapT = valueV === 0 ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping;
 
+		if ( 'Scaling' in textureNode.properties ) {
+
+			var values = textureNode.properties.Scaling.value;
+
+			texture.repeat.x = values[ 0 ];
+			texture.repeat.y = values[ 1 ];
+
+		}
+
 		loader.setPath( currentPath );
 
 		return texture;
@@ -489,7 +491,7 @@
 
 		if ( properties.BumpFactor ) {
 
-			parameters.bumpScale = parseFloat( properties.BumpFactor.value );
+			parameters.bumpScale = properties.BumpFactor.value;
 
 		}
 		if ( properties.Diffuse ) {
@@ -499,12 +501,12 @@
 		}
 		if ( properties.DisplacementFactor ) {
 
-			parameters.displacementScale = parseFloat( properties.DisplacementFactor.value );
+			parameters.displacementScale = properties.DisplacementFactor.value;
 
 		}
 		if ( properties.ReflectionFactor ) {
 
-			parameters.reflectivity = parseFloat( properties.ReflectionFactor.value );
+			parameters.reflectivity = properties.ReflectionFactor.value;
 
 		}
 		if ( properties.Specular ) {
@@ -514,7 +516,7 @@
 		}
 		if ( properties.Shininess ) {
 
-			parameters.shininess = parseFloat( properties.Shininess.value );
+			parameters.shininess = properties.Shininess.value;
 
 		}
 		if ( properties.Emissive ) {
@@ -547,56 +549,44 @@
 			switch ( type ) {
 
 				case 'Bump':
-				case ' "Bump':
 					parameters.bumpMap = textureMap.get( relationship.ID );
 					break;
 
 				case 'DiffuseColor':
-				case ' "DiffuseColor':
 					parameters.map = textureMap.get( relationship.ID );
 					break;
 
 				case 'DisplacementColor':
-				case ' "DisplacementColor':
 					parameters.displacementMap = textureMap.get( relationship.ID );
 					break;
 
 
 				case 'EmissiveColor':
-				case ' "EmissiveColor':
 					parameters.emissiveMap = textureMap.get( relationship.ID );
 					break;
 
 				case 'NormalMap':
-				case ' "NormalMap':
 					parameters.normalMap = textureMap.get( relationship.ID );
 					break;
 
 				case 'ReflectionColor':
-				case ' "ReflectionColor':
 					parameters.envMap = textureMap.get( relationship.ID );
 					parameters.envMap.mapping = THREE.EquirectangularReflectionMapping;
 					break;
 
 				case 'SpecularColor':
-				case ' "SpecularColor':
 					parameters.specularMap = textureMap.get( relationship.ID );
 					break;
 
 				case 'TransparentColor':
-				case ' "TransparentColor':
 					parameters.alphaMap = textureMap.get( relationship.ID );
 					parameters.transparent = true;
 					break;
 
 				case 'AmbientColor':
-				case ' "AmbientColor':
 				case 'ShininessExponent': // AKA glossiness map
-				case ' "ShininessExponent':
 				case 'SpecularFactor': // AKA specularLevel
-				case ' "SpecularFactor':
 				case 'VectorDisplacementColor': // NOTE: Seems to be a copy of DisplacementColor
-				case ' "VectorDisplacementColor':
 				default:
 					console.warn( 'THREE.FBXLoader: %s map is not supported in three.js, skipping texture.', type );
 					break;
@@ -935,10 +925,9 @@
 
 			if ( uvInfo ) {
 
-				var uvTemp = new THREE.Vector2();
-
 				for ( var i = 0; i < uvInfo.length; i ++ ) {
 
+					var uvTemp = new THREE.Vector2();
 					vertex.uv.push( uvTemp.fromArray( getData( polygonVertexIndex, polygonIndex, vertexIndex, uvInfo[ i ] ) ) );
 
 				}
@@ -1047,6 +1036,27 @@
 
 		}
 
+		// the loop above doesn't add the last group, do that here.
+		if ( geo.groups.length > 0 ) {
+
+			var lastGroup = geo.groups[ geo.groups.length - 1 ];
+			var lastIndex = lastGroup.start + lastGroup.count;
+
+			if ( lastIndex !== materialIndexBuffer.length ) {
+
+				geo.addGroup( lastIndex, materialIndexBuffer.length - lastIndex, prevMaterialIndex );
+
+			}
+
+		}
+
+		// catch case where the whole geometry has a single non-zero index
+		if ( geo.groups.length === 0 && materialIndexBuffer[ 0 ] !== 0 ) {
+
+			geo.addGroup( 0, materialIndexBuffer.length, materialIndexBuffer[ 0 ] );
+
+		}
+
 		return geo;
 
 	}
@@ -1486,7 +1496,7 @@
 						} else {
 
 							var type = 0;
-							if ( cameraAttribute.CameraProjectionType !== undefined && ( cameraAttribute.CameraProjectionType.value === '1' || cameraAttribute.CameraProjectionType.value === 1 ) ) {
+							if ( cameraAttribute.CameraProjectionType !== undefined && cameraAttribute.CameraProjectionType.value === 1 ) {
 
 								type = 1;
 
@@ -1512,8 +1522,8 @@
 
 							if ( cameraAttribute.AspectWidth !== undefined && cameraAttribute.AspectHeight !== undefined ) {
 
-								width = parseFloat( cameraAttribute.AspectWidth.value );
-								height = parseFloat( cameraAttribute.AspectHeight.value );
+								width = cameraAttribute.AspectWidth.value;
+								height = cameraAttribute.AspectHeight.value;
 
 							}
 
@@ -1522,19 +1532,17 @@
 							var fov = 45;
 							if ( cameraAttribute.FieldOfView !== undefined ) {
 
-								fov = parseFloat( cameraAttribute.FieldOfView.value );
+								fov = cameraAttribute.FieldOfView.value;
 
 							}
 
 							switch ( type ) {
 
-								case '0': // Perspective
-								case 0:
+								case 0: // Perspective
 									model = new THREE.PerspectiveCamera( fov, aspect, nearClippingPlane, farClippingPlane );
 									break;
 
-								case '1': // Orthographic
-								case 1:
+								case 1: // Orthographic
 									model = new THREE.OrthographicCamera( - width / 2, width / 2, height / 2, - height / 2, nearClippingPlane, farClippingPlane );
 									break;
 
@@ -1596,20 +1604,14 @@
 
 							if ( lightAttribute.Color !== undefined ) {
 
-								var temp = lightAttribute.Color.value.split( ',' );
-
-								var r = parseFloat( temp[ 0 ] );
-								var g = parseFloat( temp[ 1 ] );
-								var b = parseFloat( temp[ 1 ] );
-
-								color = new THREE.Color( r, g, b );
+								color = parseColor( lightAttribute.Color.value );
 
 							}
 
 							var intensity = ( lightAttribute.Intensity === undefined ) ? 1 : lightAttribute.Intensity.value / 100;
 
 							// light disabled
-							if ( lightAttribute.CastLightOnObject !== undefined && ( lightAttribute.CastLightOnObject.value === '0' || lightAttribute.CastLightOnObject.value === 0 ) ) {
+							if ( lightAttribute.CastLightOnObject !== undefined && lightAttribute.CastLightOnObject.value === 0 ) {
 
 								intensity = 0;
 
@@ -1618,7 +1620,7 @@
 							var distance = 0;
 							if ( lightAttribute.FarAttenuationEnd !== undefined ) {
 
-								if ( lightAttribute.EnableFarAttenuation !== undefined && ( lightAttribute.EnableFarAttenuation.value === '0' || lightAttribute.EnableFarAttenuation.value === 0 ) ) {
+								if ( lightAttribute.EnableFarAttenuation !== undefined && lightAttribute.EnableFarAttenuation.value === 0 ) {
 
 									distance = 0;
 
@@ -1636,18 +1638,15 @@
 
 							switch ( type ) {
 
-								case '0': // Point
-								case 0:
+								case 0: // Point
 									model = new THREE.PointLight( color, intensity, distance, decay );
 									break;
 
-								case '1': // Directional
-								case 1:
+								case 1: // Directional
 									model = new THREE.DirectionalLight( color, intensity );
 									break;
 
-								case '2': // Spot
-								case 2:
+								case 2: // Spot
 									var angle = Math.PI / 3;
 
 									if ( lightAttribute.InnerAngle !== undefined ) {
@@ -1677,7 +1676,7 @@
 
 							}
 
-							if ( lightAttribute.CastShadows !== undefined && ( lightAttribute.CastShadows.value === '1' || lightAttribute.CastShadows.value === 1 ) ) {
+							if ( lightAttribute.CastShadows !== undefined && lightAttribute.CastShadows.value === 1 ) {
 
 								model.castShadow = true;
 
@@ -1730,7 +1729,7 @@
 
 						} else {
 
-							material = new THREE.MeshStandardMaterial( { color: 0x3300ff } );
+							material = new THREE.MeshPhongMaterial( { color: 0xcccccc } );
 							materials.push( material );
 
 						}
@@ -1833,13 +1832,13 @@
 
 			if ( 'Lcl_Translation' in node.properties ) {
 
-				model.position.fromArray( parseFloatArray( node.properties.Lcl_Translation.value ) );
+				model.position.fromArray( node.properties.Lcl_Translation.value );
 
 			}
 
 			if ( 'Lcl_Rotation' in node.properties ) {
 
-				var rotation = parseFloatArray( node.properties.Lcl_Rotation.value ).map( degreeToRadian );
+				var rotation = node.properties.Lcl_Rotation.value.map( degreeToRadian );
 				rotation.push( 'ZYX' );
 				model.rotation.fromArray( rotation );
 
@@ -1847,7 +1846,7 @@
 
 			if ( 'Lcl_Scaling' in node.properties ) {
 
-				model.scale.fromArray( parseFloatArray( node.properties.Lcl_Scaling.value ) );
+				model.scale.fromArray( node.properties.Lcl_Scaling.value );
 
 			}
 
@@ -1886,17 +1885,13 @@
 
 					var child = conns.children[ childrenIndex ];
 
-					if ( child.relationship === 'LookAtProperty' || child.relationship === ' "LookAtProperty' ) {
+					if ( child.relationship === 'LookAtProperty' ) {
 
 						var lookAtTarget = FBXTree.Objects.subNodes.Model[ child.ID ];
 
 						if ( 'Lcl_Translation' in lookAtTarget.properties ) {
 
-							var pos = lookAtTarget.properties.Lcl_Translation.value.split( ',' ).map( function ( val ) {
-
-								return parseFloat( val );
-
-							} );
+							var pos = lookAtTarget.properties.Lcl_Translation.value;
 
 							// DirectionalLight, SpotLight
 							if ( model.target !== undefined ) {
@@ -1947,22 +1942,24 @@
 		// Now with the bones created, we can update the skeletons and bind them to the skinned meshes.
 		sceneGraph.updateMatrixWorld( true );
 
+		var worldMatrices = new Map();
+
 		// Put skeleton into bind pose.
-		var BindPoseNode = FBXTree.Objects.subNodes.Pose;
-		for ( var nodeID in BindPoseNode ) {
+		if ( 'Pose' in FBXTree.Objects.subNodes ) {
 
-			if ( BindPoseNode[ nodeID ].attrType === 'BindPose' ) {
+			var BindPoseNode = FBXTree.Objects.subNodes.Pose;
+			for ( var nodeID in BindPoseNode ) {
 
-				BindPoseNode = BindPoseNode[ nodeID ];
-				break;
+				if ( BindPoseNode[ nodeID ].attrType === 'BindPose' ) {
 
-			}
+					BindPoseNode = BindPoseNode[ nodeID ];
+					break;
 
-		}
-		if ( BindPoseNode ) {
+				}
+
+			}
 
 			var PoseNode = BindPoseNode.subNodes.PoseNode;
-			var worldMatrices = new Map();
 
 			for ( var PoseNodeIndex = 0, PoseNodeLength = PoseNode.length; PoseNodeIndex < PoseNodeLength; ++ PoseNodeIndex ) {
 
@@ -2118,7 +2115,7 @@
 
 				if ( 'CustomFrameRate' in FBXTree.GlobalSettings.properties ) {
 
-					fps = parseFloat( FBXTree.GlobalSettings.properties.CustomFrameRate.value );
+					fps = FBXTree.GlobalSettings.properties.CustomFrameRate.value;
 
 					fps = ( fps === - 1 ) ? 30 : fps;
 
@@ -3733,6 +3730,8 @@
 
 		if ( animationNode === undefined ) return key;
 
+		euler.setFromQuaternion( bone.quaternion, 'ZYX', false );
+
 		try {
 
 			if ( hasCurve( animationNode, 'T' ) && hasKeyOnFrame( animationNode.T, frame ) ) {
@@ -3743,11 +3742,26 @@
 
 			if ( hasCurve( animationNode, 'R' ) && hasKeyOnFrame( animationNode.R, frame ) ) {
 
-				var rotationX = animationNode.R.curves.x.values[ frame ];
-				var rotationY = animationNode.R.curves.y.values[ frame ];
-				var rotationZ = animationNode.R.curves.z.values[ frame ];
+				// Only update the euler's values if rotation is defined for the axis on this frame
+				if ( animationNode.R.curves.x.values[ frame ] ) {
+
+					euler.x = animationNode.R.curves.x.values[ frame ];
+
+				}
 
-				quaternion.setFromEuler( euler.set( rotationX, rotationY, rotationZ, 'ZYX' ) );
+				if ( animationNode.R.curves.y.values[ frame ] ) {
+
+					euler.y = animationNode.R.curves.y.values[ frame ];
+
+				}
+
+				if ( animationNode.R.curves.z.values[ frame ] ) {
+
+					euler.z = animationNode.R.curves.z.values[ frame ];
+
+				}
+
+				quaternion.setFromEuler( euler );
 				key.rot = quaternion.toArray();
 
 			}
@@ -4159,7 +4173,7 @@
 					//	 "iVB..."
 					if ( propName === 'Content' && propValue === ',' ) {
 
-						propValue = split[ ++ lineNum ].replace( /"/g, '' ).trim();
+						propValue = split[ ++ lineNum ].replace( /"/g, '' ).replace( /,$/, '' ).trim();
 
 					}
 
@@ -4201,7 +4215,6 @@
 
 		parseNodeBegin: function ( line, nodeName, nodeAttrs ) {
 
-			// var nodeName = match[1];
 			var node = { 'name': nodeName, properties: {}, 'subNodes': {} };
 			var attrs = this.parseNodeAttr( nodeAttrs );
 			var currentNode = this.getCurrentNode();
@@ -4211,11 +4224,9 @@
 
 				this.allNodes.add( nodeName, node );
 
-			} else {
-
-				// a subnode
+			} else { // a subnode
 
-				// already exists subnode, then append it
+				// if the subnode already exists, append it
 				if ( nodeName in currentNode.subNodes ) {
 
 					var tmp = currentNode.subNodes[ nodeName ];
@@ -4261,6 +4272,7 @@
 
 			}
 
+
 			// for this		  ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
 			// NodeAttribute: 1001463072, "NodeAttribute::", "LimbNode" {
 			if ( nodeAttrs ) {
@@ -4310,8 +4322,8 @@
 			var currentNode = this.getCurrentNode();
 			var parentName = currentNode.name;
 
-			// special case parent node's is like "Properties70"
-			// these children nodes must treat with careful
+			// special case where the parent node is something like "Properties70"
+			// these children nodes must treated carefully
 			if ( parentName !== undefined ) {
 
 				var propMatch = parentName.match( /Properties(\d)+/ );
@@ -4324,7 +4336,7 @@
 
 			}
 
-			// special case Connections
+			// Connections
 			if ( propName === 'C' ) {
 
 				var connProps = propValue.split( ',' ).slice( 1 );
@@ -4333,6 +4345,12 @@
 
 				var rest = propValue.split( ',' ).slice( 3 );
 
+				rest = rest.map( function ( elem ) {
+
+					return elem.trim().replace( /^"/, '' );
+
+				} );
+
 				propName = 'connections';
 				propValue = [ from, to ];
 				append( propValue, rest );
@@ -4345,7 +4363,7 @@
 
 			}
 
-			// special case Connections
+			// Node
 			if ( propName === 'Node' ) {
 
 				var id = parseInt( propValue );
@@ -4370,7 +4388,6 @@
 
 			} else {
 
-				// console.log( propName + ":  " + propValue );
 				if ( Array.isArray( currentNode.properties[ propName ] ) ) {
 
 					currentNode.properties[ propName ].push( propValue );
@@ -4420,19 +4437,27 @@
 			}
 			*/
 
-			// cast value in its type
+			// cast value to its type
 			switch ( innerPropType1 ) {
 
 				case 'int':
+				case 'enum':
+				case 'bool':
+				case 'ULongLong':
 					innerPropValue = parseInt( innerPropValue );
 					break;
 
 				case 'double':
+				case 'Number':
+				case 'FieldOfView':
 					innerPropValue = parseFloat( innerPropValue );
 					break;
 
 				case 'ColorRGB':
 				case 'Vector3D':
+				case 'Lcl_Translation':
+				case 'Lcl_Rotation':
+				case 'Lcl_Scaling':
 					innerPropValue = parseFloatArray( innerPropValue );
 					break;
 
@@ -4684,12 +4709,6 @@
 
 					}
 
-					if ( innerPropType1.indexOf( 'Lcl_' ) === 0 ) {
-
-						innerPropValue = innerPropValue.toString();
-
-					}
-
 					// this will be copied to parent. see above.
 					properties[ innerPropName ] = {
 
@@ -4778,29 +4797,38 @@
 
 			switch ( type ) {
 
-				case 'F':
-					return reader.getFloat32();
+				case 'C':
+					return reader.getBoolean();
 
 				case 'D':
 					return reader.getFloat64();
 
-				case 'L':
-					return reader.getInt64();
+				case 'F':
+					return reader.getFloat32();
 
 				case 'I':
 					return reader.getInt32();
 
+				case 'L':
+					return reader.getInt64();
+
+				case 'R':
+					var length = reader.getUint32();
+					return reader.getArrayBuffer( length );
+
+				case 'S':
+					var length = reader.getUint32();
+					return reader.getString( length );
+
 				case 'Y':
 					return reader.getInt16();
 
-				case 'C':
-					return reader.getBoolean();
-
-				case 'f':
+				case 'b':
+				case 'c':
 				case 'd':
-				case 'l':
+				case 'f':
 				case 'i':
-				case 'b':
+				case 'l':
 
 					var arrayLength = reader.getUint32();
 					var encoding = reader.getUint32(); // 0: non-compressed, 1: compressed
@@ -4810,20 +4838,21 @@
 
 						switch ( type ) {
 
-							case 'f':
-								return reader.getFloat32Array( arrayLength );
+							case 'b':
+							case 'c':
+								return reader.getBooleanArray( arrayLength );
 
 							case 'd':
 								return reader.getFloat64Array( arrayLength );
 
-							case 'l':
-								return reader.getInt64Array( arrayLength );
+							case 'f':
+								return reader.getFloat32Array( arrayLength );
 
 							case 'i':
 								return reader.getInt32Array( arrayLength );
 
-							case 'b':
-								return reader.getBooleanArray( arrayLength );
+							case 'l':
+								return reader.getInt64Array( arrayLength );
 
 						}
 
@@ -4840,31 +4869,25 @@
 
 					switch ( type ) {
 
-						case 'f':
-							return reader2.getFloat32Array( arrayLength );
+
+						case 'b':
+						case 'c':
+							return reader2.getBooleanArray( arrayLength );
 
 						case 'd':
 							return reader2.getFloat64Array( arrayLength );
 
-						case 'l':
-							return reader2.getInt64Array( arrayLength );
+						case 'f':
+							return reader2.getFloat32Array( arrayLength );
 
 						case 'i':
 							return reader2.getInt32Array( arrayLength );
 
-						case 'b':
-							return reader2.getBooleanArray( arrayLength );
+						case 'l':
+							return reader2.getInt64Array( arrayLength );
 
 					}
 
-				case 'S':
-					var length = reader.getUint32();
-					return reader.getString( length );
-
-				case 'R':
-					var length = reader.getUint32();
-					return reader.getArrayBuffer( length );
-
 				default:
 					throw new Error( 'THREE.FBXLoader: Unknown property type ' + type );
 

+ 46 - 55
examples/js/loaders/GLTFLoader.js

@@ -1333,6 +1333,7 @@ THREE.GLTFLoader = ( function () {
 	GLTFParser.prototype.parse = function ( onLoad, onError ) {
 
 		var json = this.json;
+		var parser = this;
 
 		// Clear the loader cache
 		this.cache.removeAll();
@@ -1341,43 +1342,19 @@ THREE.GLTFLoader = ( function () {
 		this._withDependencies( [
 
 			'scenes',
-			'cameras',
 			'animations'
 
 		] ).then( function ( dependencies ) {
 
-			var scenes = [];
-
-			for ( var i = 0; i < dependencies.scenes.length; i ++ ) {
-
-				scenes.push( dependencies.scenes[ i ] );
-
-			}
-
-			var scene = json.scene !== undefined ? dependencies.scenes[ json.scene ] : scenes[ 0 ];
-
-			var cameras = [];
-
-			dependencies.cameras = dependencies.cameras || [];
+			var scenes = dependencies.scenes || [];
+			var scene = scenes[ json.scene || 0 ];
+			var animations = dependencies.animations || [];
 
-			for ( var i = 0; i < dependencies.cameras.length; i ++ ) {
+			parser.getDependencies( 'camera' ).then( function ( cameras ) {
 
-				var camera = dependencies.cameras[ i ];
-				cameras.push( camera );
-
-			}
+				onLoad( scene, scenes, cameras, animations );
 
-			var animations = [];
-
-			dependencies.animations = dependencies.animations || [];
-
-			for ( var i = 0; i < dependencies.animations.length; i ++ ) {
-
-				animations.push( dependencies.animations[ i ] );
-
-			}
-
-			onLoad( scene, scenes, cameras, animations );
+			} ).catch( onError );
 
 		} ).catch( onError );
 
@@ -1406,6 +1383,24 @@ THREE.GLTFLoader = ( function () {
 
 	};
 
+	/**
+	 * Requests all dependencies of the specified type asynchronously, with caching.
+	 * @param {string} type
+	 * @return {Promise<Array<Object>>}
+	 */
+	GLTFParser.prototype.getDependencies = function ( type ) {
+
+		var parser = this;
+		var defs = this.json[ type + 's' ] || [];
+
+		return Promise.all( defs.map( function ( def, index ) {
+
+			return parser.getDependency( type, index );
+
+		} ) );
+
+	};
+
 	/**
 	 * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
 	 * @param {number} bufferIndex
@@ -2028,43 +2023,39 @@ THREE.GLTFLoader = ( function () {
 
 	/**
 	 * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
+	 * @param {number} cameraIndex
+	 * @return {Promise<THREE.Camera>}
 	 */
-	GLTFParser.prototype.loadCameras = function () {
-
-		var json = this.json;
+	GLTFParser.prototype.loadCamera = function ( cameraIndex ) {
 
-		return _each( json.cameras, function ( camera ) {
+		var camera;
+		var cameraDef = this.json.cameras[ cameraIndex ];
+		var params = cameraDef[ cameraDef.type ];
 
-			var _camera;
+		if ( ! params ) {
 
-			var params = camera[ camera.type ];
+			console.warn( 'THREE.GLTFLoader: Missing camera parameters.' );
+			return;
 
-			if ( ! params ) {
-
-				console.warn( 'THREE.GLTFLoader: Missing camera parameters.' );
-				return;
-
-			}
-
-			if ( camera.type === 'perspective' ) {
+		}
 
-				var aspectRatio = params.aspectRatio || 1;
-				var xfov = params.yfov * aspectRatio;
+		if ( cameraDef.type === 'perspective' ) {
 
-				_camera = new THREE.PerspectiveCamera( THREE.Math.radToDeg( xfov ), aspectRatio, params.znear || 1, params.zfar || 2e6 );
+			var aspectRatio = params.aspectRatio || 1;
+			var xfov = params.yfov * aspectRatio;
 
-			} else if ( camera.type === 'orthographic' ) {
+			camera = new THREE.PerspectiveCamera( THREE.Math.radToDeg( xfov ), aspectRatio, params.znear || 1, params.zfar || 2e6 );
 
-				_camera = new THREE.OrthographicCamera( params.xmag / - 2, params.xmag / 2, params.ymag / 2, params.ymag / - 2, params.znear, params.zfar );
+		} else if ( cameraDef.type === 'orthographic' ) {
 
-			}
+			camera = new THREE.OrthographicCamera( params.xmag / -2, params.xmag / 2, params.ymag / 2, params.ymag / -2, params.znear, params.zfar );
 
-			if ( camera.name !== undefined ) _camera.name = camera.name;
-			if ( camera.extras ) _camera.userData = camera.extras;
+		}
 
-			return _camera;
+		if ( cameraDef.name !== undefined ) camera.name = cameraDef.name;
+		if ( cameraDef.extras ) camera.userData = cameraDef.extras;
 
-		} );
+		return Promise.resolve( camera );
 
 	};
 
@@ -2295,7 +2286,7 @@ THREE.GLTFLoader = ( function () {
 
 				} else if ( nodeDef.camera !== undefined ) {
 
-					return dependencies.cameras[ nodeDef.camera ];
+					return scope.getDependency( 'camera', nodeDef.camera );
 
 				} else if ( nodeDef.extensions
 								 && nodeDef.extensions[ EXTENSIONS.KHR_LIGHTS ]

+ 2215 - 0
examples/js/loaders/deprecated/LegacyGLTFLoader.js

@@ -0,0 +1,2215 @@
+/**
+ * @author Rich Tibbett / https://github.com/richtr
+ * @author mrdoob / http://mrdoob.com/
+ * @author Tony Parisi / http://www.tonyparisi.com/
+ * @author Takahiro / https://github.com/takahirox
+ */
+
+THREE.LegacyGLTFLoader = ( function () {
+
+	function LegacyGLTFLoader( manager ) {
+
+		this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
+
+	}
+
+	LegacyGLTFLoader.prototype = {
+
+		constructor: LegacyGLTFLoader,
+
+		crossOrigin: 'Anonymous',
+
+		load: function ( url, onLoad, onProgress, onError ) {
+
+			var scope = this;
+
+			var path = this.path && ( typeof this.path === "string" ) ? this.path : THREE.Loader.prototype.extractUrlBase( url );
+
+			var loader = new THREE.FileLoader( scope.manager );
+
+			loader.setResponseType( 'arraybuffer' );
+
+			loader.load( url, function ( data ) {
+
+				scope.parse( data, onLoad, path );
+
+			}, onProgress, onError );
+
+		},
+
+		setCrossOrigin: function ( value ) {
+
+			this.crossOrigin = value;
+
+		},
+
+		setPath: function ( value ) {
+
+			this.path = value;
+
+		},
+
+		parse: function ( data, callback, path ) {
+
+			var content;
+			var extensions = {};
+
+			var magic = convertUint8ArrayToString( new Uint8Array( data, 0, 4 ) );
+
+			if ( magic === BINARY_EXTENSION_HEADER_DEFAULTS.magic ) {
+
+				extensions[ EXTENSIONS.KHR_BINARY_GLTF ] = new GLTFBinaryExtension( data );
+				content = extensions[ EXTENSIONS.KHR_BINARY_GLTF ].content;
+
+			} else {
+
+				content = convertUint8ArrayToString( new Uint8Array( data ) );
+
+			}
+
+			var json = JSON.parse( content );
+
+			if ( json.extensionsUsed && json.extensionsUsed.indexOf( EXTENSIONS.KHR_MATERIALS_COMMON ) >= 0 ) {
+
+				extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ] = new GLTFMaterialsCommonExtension( json );
+
+			}
+
+			console.time( 'LegacyGLTFLoader' );
+
+			var parser = new GLTFParser( json, extensions, {
+
+				path: path || this.path,
+				crossOrigin: this.crossOrigin
+
+			} );
+
+			parser.parse( function ( scene, scenes, cameras, animations ) {
+
+				console.timeEnd( 'LegacyGLTFLoader' );
+
+				var glTF = {
+					"scene": scene,
+					"scenes": scenes,
+					"cameras": cameras,
+					"animations": animations
+				};
+
+				callback( glTF );
+
+			} );
+
+		}
+
+	};
+
+	/* GLTFREGISTRY */
+
+	function GLTFRegistry() {
+
+		var objects = {};
+
+		return	{
+
+			get: function ( key ) {
+
+				return objects[ key ];
+
+			},
+
+			add: function ( key, object ) {
+
+				objects[ key ] = object;
+
+			},
+
+			remove: function ( key ) {
+
+				delete objects[ key ];
+
+			},
+
+			removeAll: function () {
+
+				objects = {};
+
+			},
+
+			update: function ( scene, camera ) {
+
+				for ( var name in objects ) {
+
+					var object = objects[ name ];
+
+					if ( object.update ) {
+
+						object.update( scene, camera );
+
+					}
+
+				}
+
+			}
+
+		};
+
+	}
+
+	/* GLTFSHADERS */
+
+	LegacyGLTFLoader.Shaders = {
+
+		update: function () {
+
+			console.warn( 'THREE.LegacyGLTFLoader.Shaders has been deprecated, and now updates automatically.' );
+
+		}
+
+	};
+
+	/* GLTFSHADER */
+
+	function GLTFShader( targetNode, allNodes ) {
+
+		var boundUniforms = {};
+
+		// bind each uniform to its source node
+
+		var uniforms = targetNode.material.uniforms;
+
+		for ( var uniformId in uniforms ) {
+
+			var uniform = uniforms[ uniformId ];
+
+			if ( uniform.semantic ) {
+
+				var sourceNodeRef = uniform.node;
+
+				var sourceNode = targetNode;
+
+				if ( sourceNodeRef ) {
+
+					sourceNode = allNodes[ sourceNodeRef ];
+
+				}
+
+				boundUniforms[ uniformId ] = {
+					semantic: uniform.semantic,
+					sourceNode: sourceNode,
+					targetNode: targetNode,
+					uniform: uniform
+				};
+
+			}
+
+		}
+
+		this.boundUniforms = boundUniforms;
+		this._m4 = new THREE.Matrix4();
+
+	}
+
+	// Update - update all the uniform values
+	GLTFShader.prototype.update = function ( scene, camera ) {
+
+		var boundUniforms = this.boundUniforms;
+
+		for ( var name in boundUniforms ) {
+
+			var boundUniform = boundUniforms[ name ];
+
+			switch ( boundUniform.semantic ) {
+
+				case "MODELVIEW":
+
+					var m4 = boundUniform.uniform.value;
+					m4.multiplyMatrices( camera.matrixWorldInverse, boundUniform.sourceNode.matrixWorld );
+					break;
+
+				case "MODELVIEWINVERSETRANSPOSE":
+
+					var m3 = boundUniform.uniform.value;
+					this._m4.multiplyMatrices( camera.matrixWorldInverse, boundUniform.sourceNode.matrixWorld );
+					m3.getNormalMatrix( this._m4 );
+					break;
+
+				case "PROJECTION":
+
+					var m4 = boundUniform.uniform.value;
+					m4.copy( camera.projectionMatrix );
+					break;
+
+				case "JOINTMATRIX":
+
+					var m4v = boundUniform.uniform.value;
+
+					for ( var mi = 0; mi < m4v.length; mi ++ ) {
+
+						// So it goes like this:
+						// SkinnedMesh world matrix is already baked into MODELVIEW;
+						// transform joints to local space,
+						// then transform using joint's inverse
+						m4v[ mi ]
+							.getInverse( boundUniform.sourceNode.matrixWorld )
+							.multiply( boundUniform.targetNode.skeleton.bones[ mi ].matrixWorld )
+							.multiply( boundUniform.targetNode.skeleton.boneInverses[ mi ] )
+							.multiply( boundUniform.targetNode.bindMatrix );
+
+					}
+
+					break;
+
+				default :
+
+					console.warn( "Unhandled shader semantic: " + boundUniform.semantic );
+					break;
+
+			}
+
+		}
+
+	};
+
+
+	/* ANIMATION */
+
+	LegacyGLTFLoader.Animations = {
+
+		update: function () {
+
+			console.warn( 'THREE.LegacyGLTFLoader.Animation has been deprecated. Use THREE.AnimationMixer instead.' );
+
+		}
+
+	};
+
+	/*********************************/
+	/********** EXTENSIONS ***********/
+	/*********************************/
+
+	var EXTENSIONS = {
+		KHR_BINARY_GLTF: 'KHR_binary_glTF',
+		KHR_MATERIALS_COMMON: 'KHR_materials_common'
+	};
+
+	/* MATERIALS COMMON EXTENSION */
+
+	function GLTFMaterialsCommonExtension( json ) {
+
+		this.name = EXTENSIONS.KHR_MATERIALS_COMMON;
+
+		this.lights = {};
+
+		var extension = ( json.extensions && json.extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ] ) || {};
+		var lights = extension.lights || {};
+
+		for ( var lightId in lights ) {
+
+			var light = lights[ lightId ];
+			var lightNode;
+
+			var lightParams = light[ light.type ];
+			var color = new THREE.Color().fromArray( lightParams.color );
+
+			switch ( light.type ) {
+
+				case "directional":
+					lightNode = new THREE.DirectionalLight( color );
+					lightNode.position.set( 0, 0, 1 );
+					break;
+
+				case "point":
+					lightNode = new THREE.PointLight( color );
+					break;
+
+				case "spot":
+					lightNode = new THREE.SpotLight( color );
+					lightNode.position.set( 0, 0, 1 );
+					break;
+
+				case "ambient":
+					lightNode = new THREE.AmbientLight( color );
+					break;
+
+			}
+
+			if ( lightNode ) {
+
+				this.lights[ lightId ] = lightNode;
+
+			}
+
+		}
+
+	}
+
+	/* BINARY EXTENSION */
+
+	var BINARY_EXTENSION_BUFFER_NAME = 'binary_glTF';
+
+	var BINARY_EXTENSION_HEADER_DEFAULTS = { magic: 'glTF', version: 1, contentFormat: 0 };
+
+	var BINARY_EXTENSION_HEADER_LENGTH = 20;
+
+	function GLTFBinaryExtension( data ) {
+
+		this.name = EXTENSIONS.KHR_BINARY_GLTF;
+
+		var headerView = new DataView( data, 0, BINARY_EXTENSION_HEADER_LENGTH );
+
+		var header = {
+			magic: convertUint8ArrayToString( new Uint8Array( data.slice( 0, 4 ) ) ),
+			version: headerView.getUint32( 4, true ),
+			length: headerView.getUint32( 8, true ),
+			contentLength: headerView.getUint32( 12, true ),
+			contentFormat: headerView.getUint32( 16, true )
+		};
+
+		for ( var key in BINARY_EXTENSION_HEADER_DEFAULTS ) {
+
+			var value = BINARY_EXTENSION_HEADER_DEFAULTS[ key ];
+
+			if ( header[ key ] !== value ) {
+
+				throw new Error( 'Unsupported glTF-Binary header: Expected "%s" to be "%s".', key, value );
+
+			}
+
+		}
+
+		var contentArray = new Uint8Array( data, BINARY_EXTENSION_HEADER_LENGTH, header.contentLength );
+
+		this.header = header;
+		this.content = convertUint8ArrayToString( contentArray );
+		this.body = data.slice( BINARY_EXTENSION_HEADER_LENGTH + header.contentLength, header.length );
+
+	}
+
+	GLTFBinaryExtension.prototype.loadShader = function ( shader, bufferViews ) {
+
+		var bufferView = bufferViews[ shader.extensions[ EXTENSIONS.KHR_BINARY_GLTF ].bufferView ];
+		var array = new Uint8Array( bufferView );
+
+		return convertUint8ArrayToString( array );
+
+	};
+
+	GLTFBinaryExtension.prototype.loadTextureSourceUri = function ( source, bufferViews ) {
+
+		var metadata = source.extensions[ EXTENSIONS.KHR_BINARY_GLTF ];
+		var bufferView = bufferViews[ metadata.bufferView ];
+		var stringData = convertUint8ArrayToString( new Uint8Array( bufferView ) );
+
+		return 'data:' + metadata.mimeType + ';base64,' + btoa( stringData );
+
+	};
+
+	/*********************************/
+	/********** INTERNALS ************/
+	/*********************************/
+
+	/* CONSTANTS */
+
+	var WEBGL_CONSTANTS = {
+		FLOAT: 5126,
+		//FLOAT_MAT2: 35674,
+		FLOAT_MAT3: 35675,
+		FLOAT_MAT4: 35676,
+		FLOAT_VEC2: 35664,
+		FLOAT_VEC3: 35665,
+		FLOAT_VEC4: 35666,
+		LINEAR: 9729,
+		REPEAT: 10497,
+		SAMPLER_2D: 35678,
+		TRIANGLES: 4,
+		LINES: 1,
+		UNSIGNED_BYTE: 5121,
+		UNSIGNED_SHORT: 5123,
+
+		VERTEX_SHADER: 35633,
+		FRAGMENT_SHADER: 35632
+	};
+
+	var WEBGL_TYPE = {
+		5126: Number,
+		//35674: THREE.Matrix2,
+		35675: THREE.Matrix3,
+		35676: THREE.Matrix4,
+		35664: THREE.Vector2,
+		35665: THREE.Vector3,
+		35666: THREE.Vector4,
+		35678: THREE.Texture
+	};
+
+	var WEBGL_COMPONENT_TYPES = {
+		5120: Int8Array,
+		5121: Uint8Array,
+		5122: Int16Array,
+		5123: Uint16Array,
+		5125: Uint32Array,
+		5126: Float32Array
+	};
+
+	var WEBGL_FILTERS = {
+		9728: THREE.NearestFilter,
+		9729: THREE.LinearFilter,
+		9984: THREE.NearestMipMapNearestFilter,
+		9985: THREE.LinearMipMapNearestFilter,
+		9986: THREE.NearestMipMapLinearFilter,
+		9987: THREE.LinearMipMapLinearFilter
+	};
+
+	var WEBGL_WRAPPINGS = {
+		33071: THREE.ClampToEdgeWrapping,
+		33648: THREE.MirroredRepeatWrapping,
+		10497: THREE.RepeatWrapping
+	};
+
+	var WEBGL_TEXTURE_FORMATS = {
+		6406: THREE.AlphaFormat,
+		6407: THREE.RGBFormat,
+		6408: THREE.RGBAFormat,
+		6409: THREE.LuminanceFormat,
+		6410: THREE.LuminanceAlphaFormat
+	};
+
+	var WEBGL_TEXTURE_DATATYPES = {
+		5121: THREE.UnsignedByteType,
+		32819: THREE.UnsignedShort4444Type,
+		32820: THREE.UnsignedShort5551Type,
+		33635: THREE.UnsignedShort565Type
+	};
+
+	var WEBGL_SIDES = {
+		1028: THREE.BackSide,  // Culling front
+		1029: THREE.FrontSide  // Culling back
+		//1032: THREE.NoSide   // Culling front and back, what to do?
+	};
+
+	var WEBGL_DEPTH_FUNCS = {
+		512: THREE.NeverDepth,
+		513: THREE.LessDepth,
+		514: THREE.EqualDepth,
+		515: THREE.LessEqualDepth,
+		516: THREE.GreaterEqualDepth,
+		517: THREE.NotEqualDepth,
+		518: THREE.GreaterEqualDepth,
+		519: THREE.AlwaysDepth
+	};
+
+	var WEBGL_BLEND_EQUATIONS = {
+		32774: THREE.AddEquation,
+		32778: THREE.SubtractEquation,
+		32779: THREE.ReverseSubtractEquation
+	};
+
+	var WEBGL_BLEND_FUNCS = {
+		0: THREE.ZeroFactor,
+		1: THREE.OneFactor,
+		768: THREE.SrcColorFactor,
+		769: THREE.OneMinusSrcColorFactor,
+		770: THREE.SrcAlphaFactor,
+		771: THREE.OneMinusSrcAlphaFactor,
+		772: THREE.DstAlphaFactor,
+		773: THREE.OneMinusDstAlphaFactor,
+		774: THREE.DstColorFactor,
+		775: THREE.OneMinusDstColorFactor,
+		776: THREE.SrcAlphaSaturateFactor
+		// The followings are not supported by Three.js yet
+		//32769: CONSTANT_COLOR,
+		//32770: ONE_MINUS_CONSTANT_COLOR,
+		//32771: CONSTANT_ALPHA,
+		//32772: ONE_MINUS_CONSTANT_COLOR
+	};
+
+	var WEBGL_TYPE_SIZES = {
+		'SCALAR': 1,
+		'VEC2': 2,
+		'VEC3': 3,
+		'VEC4': 4,
+		'MAT2': 4,
+		'MAT3': 9,
+		'MAT4': 16
+	};
+
+	var PATH_PROPERTIES = {
+		scale: 'scale',
+		translation: 'position',
+		rotation: 'quaternion'
+	};
+
+	var INTERPOLATION = {
+		LINEAR: THREE.InterpolateLinear,
+		STEP: THREE.InterpolateDiscrete
+	};
+
+	var STATES_ENABLES = {
+		2884: 'CULL_FACE',
+		2929: 'DEPTH_TEST',
+		3042: 'BLEND',
+		3089: 'SCISSOR_TEST',
+		32823: 'POLYGON_OFFSET_FILL',
+		32926: 'SAMPLE_ALPHA_TO_COVERAGE'
+	};
+
+	/* UTILITY FUNCTIONS */
+
+	function _each( object, callback, thisObj ) {
+
+		if ( !object ) {
+			return Promise.resolve();
+		}
+
+		var results;
+		var fns = [];
+
+		if ( Object.prototype.toString.call( object ) === '[object Array]' ) {
+
+			results = [];
+
+			var length = object.length;
+
+			for ( var idx = 0; idx < length; idx ++ ) {
+
+				var value = callback.call( thisObj || this, object[ idx ], idx );
+
+				if ( value ) {
+
+					fns.push( value );
+
+					if ( value instanceof Promise ) {
+
+						value.then( function( key, value ) {
+
+							results[ key ] = value;
+
+						}.bind( this, idx ));
+
+					} else {
+
+						results[ idx ] = value;
+
+					}
+
+				}
+
+			}
+
+		} else {
+
+			results = {};
+
+			for ( var key in object ) {
+
+				if ( object.hasOwnProperty( key ) ) {
+
+					var value = callback.call( thisObj || this, object[ key ], key );
+
+					if ( value ) {
+
+						fns.push( value );
+
+						if ( value instanceof Promise ) {
+
+							value.then( function( key, value ) {
+
+								results[ key ] = value;
+
+							}.bind( this, key ));
+
+						} else {
+
+							results[ key ] = value;
+
+						}
+
+					}
+
+				}
+
+			}
+
+		}
+
+		return Promise.all( fns ).then( function() {
+
+			return results;
+
+		});
+
+	}
+
+	function resolveURL( url, path ) {
+
+		// Invalid URL
+		if ( typeof url !== 'string' || url === '' )
+			return '';
+
+		// Absolute URL http://,https://,//
+		if ( /^(https?:)?\/\//i.test( url ) ) {
+
+			return url;
+
+		}
+
+		// Data URI
+		if ( /^data:.*,.*$/i.test( url ) ) {
+
+			return url;
+
+		}
+
+		// Relative URL
+		return ( path || '' ) + url;
+
+	}
+
+	function convertUint8ArrayToString( array ) {
+
+		if ( window.TextDecoder !== undefined ) {
+
+			return new TextDecoder().decode( array );
+
+		}
+
+		// Avoid the String.fromCharCode.apply(null, array) shortcut, which
+		// throws a "maximum call stack size exceeded" error for large arrays.
+
+		var s = '';
+
+		for ( var i = 0, il = array.length; i < il; i ++ ) {
+
+			s += String.fromCharCode( array[ i ] );
+
+		}
+
+		return s;
+
+	}
+
+	// Three.js seems too dependent on attribute names so globally
+	// replace those in the shader code
+	function replaceTHREEShaderAttributes( shaderText, technique ) {
+
+		// Expected technique attributes
+		var attributes = {};
+
+		for ( var attributeId in technique.attributes ) {
+
+			var pname = technique.attributes[ attributeId ];
+
+			var param = technique.parameters[ pname ];
+			var atype = param.type;
+			var semantic = param.semantic;
+
+			attributes[ attributeId ] = {
+				type: atype,
+				semantic: semantic
+			};
+
+		}
+
+		// Figure out which attributes to change in technique
+
+		var shaderParams = technique.parameters;
+		var shaderAttributes = technique.attributes;
+		var params = {};
+
+		for ( var attributeId in attributes ) {
+
+			var pname = shaderAttributes[ attributeId ];
+			var shaderParam = shaderParams[ pname ];
+			var semantic = shaderParam.semantic;
+			if ( semantic ) {
+
+				params[ attributeId ] = shaderParam;
+
+			}
+
+		}
+
+		for ( var pname in params ) {
+
+			var param = params[ pname ];
+			var semantic = param.semantic;
+
+			var regEx = new RegExp( "\\b" + pname + "\\b", "g" );
+
+			switch ( semantic ) {
+
+				case "POSITION":
+
+					shaderText = shaderText.replace( regEx, 'position' );
+					break;
+
+				case "NORMAL":
+
+					shaderText = shaderText.replace( regEx, 'normal' );
+					break;
+
+				case 'TEXCOORD_0':
+				case 'TEXCOORD0':
+				case 'TEXCOORD':
+
+					shaderText = shaderText.replace( regEx, 'uv' );
+					break;
+
+				case 'TEXCOORD_1':
+
+					shaderText = shaderText.replace( regEx, 'uv2' );
+					break;
+
+				case 'COLOR_0':
+				case 'COLOR0':
+				case 'COLOR':
+
+					shaderText = shaderText.replace( regEx, 'color' );
+					break;
+
+				case "WEIGHT":
+
+					shaderText = shaderText.replace( regEx, 'skinWeight' );
+					break;
+
+				case "JOINT":
+
+					shaderText = shaderText.replace( regEx, 'skinIndex' );
+					break;
+
+			}
+
+		}
+
+		return shaderText;
+
+	}
+
+	function createDefaultMaterial() {
+
+		return new THREE.MeshPhongMaterial( {
+			color: 0x00000,
+			emissive: 0x888888,
+			specular: 0x000000,
+			shininess: 0,
+			transparent: false,
+			depthTest: true,
+			side: THREE.FrontSide
+		} );
+
+	}
+
+	// Deferred constructor for RawShaderMaterial types
+	function DeferredShaderMaterial( params ) {
+
+		this.isDeferredShaderMaterial = true;
+
+		this.params = params;
+
+	}
+
+	DeferredShaderMaterial.prototype.create = function () {
+
+		var uniforms = THREE.UniformsUtils.clone( this.params.uniforms );
+
+		for ( var uniformId in this.params.uniforms ) {
+
+			var originalUniform = this.params.uniforms[ uniformId ];
+
+			if ( originalUniform.value instanceof THREE.Texture ) {
+
+				uniforms[ uniformId ].value = originalUniform.value;
+				uniforms[ uniformId ].value.needsUpdate = true;
+
+			}
+
+			uniforms[ uniformId ].semantic = originalUniform.semantic;
+			uniforms[ uniformId ].node = originalUniform.node;
+
+		}
+
+		this.params.uniforms = uniforms;
+
+		return new THREE.RawShaderMaterial( this.params );
+
+	};
+
+	/* GLTF PARSER */
+
+	function GLTFParser( json, extensions, options ) {
+
+		this.json = json || {};
+		this.extensions = extensions || {};
+		this.options = options || {};
+
+		// loader object cache
+		this.cache = new GLTFRegistry();
+
+	}
+
+	GLTFParser.prototype._withDependencies = function ( dependencies ) {
+
+		var _dependencies = {};
+
+		for ( var i = 0; i < dependencies.length; i ++ ) {
+
+			var dependency = dependencies[ i ];
+			var fnName = "load" + dependency.charAt( 0 ).toUpperCase() + dependency.slice( 1 );
+
+			var cached = this.cache.get( dependency );
+
+			if ( cached !== undefined ) {
+
+				_dependencies[ dependency ] = cached;
+
+			} else if ( this[ fnName ] ) {
+
+				var fn = this[ fnName ]();
+				this.cache.add( dependency, fn );
+
+				_dependencies[ dependency ] = fn;
+
+			}
+
+		}
+
+		return _each( _dependencies, function ( dependency ) {
+
+			return dependency;
+
+		} );
+
+	};
+
+	GLTFParser.prototype.parse = function ( callback ) {
+
+		var json = this.json;
+
+		// Clear the loader cache
+		this.cache.removeAll();
+
+		// Fire the callback on complete
+		this._withDependencies( [
+
+			"scenes",
+			"cameras",
+			"animations"
+
+		] ).then( function ( dependencies ) {
+
+			var scenes = [];
+
+			for ( var name in dependencies.scenes ) {
+
+				scenes.push( dependencies.scenes[ name ] );
+
+			}
+
+			var scene = json.scene !== undefined ? dependencies.scenes[ json.scene ] : scenes[ 0 ];
+
+			var cameras = [];
+
+			for ( var name in dependencies.cameras ) {
+
+				var camera = dependencies.cameras[ name ];
+				cameras.push( camera );
+
+			}
+
+			var animations = [];
+
+			for ( var name in dependencies.animations ) {
+
+				animations.push( dependencies.animations[ name ] );
+
+			}
+
+			callback( scene, scenes, cameras, animations );
+
+		} );
+
+	};
+
+	GLTFParser.prototype.loadShaders = function () {
+
+		var json = this.json;
+		var extensions = this.extensions;
+		var options = this.options;
+
+		return this._withDependencies( [
+
+			"bufferViews"
+
+		] ).then( function ( dependencies ) {
+
+			return _each( json.shaders, function ( shader ) {
+
+				if ( shader.extensions && shader.extensions[ EXTENSIONS.KHR_BINARY_GLTF ] ) {
+
+					return extensions[ EXTENSIONS.KHR_BINARY_GLTF ].loadShader( shader, dependencies.bufferViews );
+
+				}
+
+				return new Promise( function ( resolve ) {
+
+					var loader = new THREE.FileLoader();
+					loader.setResponseType( 'text' );
+					loader.load( resolveURL( shader.uri, options.path ), function ( shaderText ) {
+
+						resolve( shaderText );
+
+					} );
+
+				} );
+
+			} );
+
+		} );
+
+	};
+
+	GLTFParser.prototype.loadBuffers = function () {
+
+		var json = this.json;
+		var extensions = this.extensions;
+		var options = this.options;
+
+		return _each( json.buffers, function ( buffer, name ) {
+
+			if ( name === BINARY_EXTENSION_BUFFER_NAME ) {
+
+				return extensions[ EXTENSIONS.KHR_BINARY_GLTF ].body;
+
+			}
+
+			if ( buffer.type === 'arraybuffer' || buffer.type === undefined ) {
+
+				return new Promise( function ( resolve ) {
+
+					var loader = new THREE.FileLoader();
+					loader.setResponseType( 'arraybuffer' );
+					loader.load( resolveURL( buffer.uri, options.path ), function ( buffer ) {
+
+						resolve( buffer );
+
+					} );
+
+				} );
+
+			} else {
+
+				console.warn( 'THREE.LegacyGLTFLoader: ' + buffer.type + ' buffer type is not supported' );
+
+			}
+
+		} );
+
+	};
+
+	GLTFParser.prototype.loadBufferViews = function () {
+
+		var json = this.json;
+
+		return this._withDependencies( [
+
+			"buffers"
+
+		] ).then( function ( dependencies ) {
+
+			return _each( json.bufferViews, function ( bufferView ) {
+
+				var arraybuffer = dependencies.buffers[ bufferView.buffer ];
+
+				var byteLength = bufferView.byteLength !== undefined ? bufferView.byteLength : 0;
+
+				return arraybuffer.slice( bufferView.byteOffset, bufferView.byteOffset + byteLength );
+
+			} );
+
+		} );
+
+	};
+
+	GLTFParser.prototype.loadAccessors = function () {
+
+		var json = this.json;
+
+		return this._withDependencies( [
+
+			"bufferViews"
+
+		] ).then( function ( dependencies ) {
+
+			return _each( json.accessors, function ( accessor ) {
+
+				var arraybuffer = dependencies.bufferViews[ accessor.bufferView ];
+				var itemSize = WEBGL_TYPE_SIZES[ accessor.type ];
+				var TypedArray = WEBGL_COMPONENT_TYPES[ accessor.componentType ];
+
+				// For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12.
+				var elementBytes = TypedArray.BYTES_PER_ELEMENT;
+				var itemBytes = elementBytes * itemSize;
+
+				// The buffer is not interleaved if the stride is the item size in bytes.
+				if ( accessor.byteStride && accessor.byteStride !== itemBytes ) {
+
+					// Use the full buffer if it's interleaved.
+					var array = new TypedArray( arraybuffer );
+
+					// Integer parameters to IB/IBA are in array elements, not bytes.
+					var ib = new THREE.InterleavedBuffer( array, accessor.byteStride / elementBytes );
+
+					return new THREE.InterleavedBufferAttribute( ib, itemSize, accessor.byteOffset / elementBytes );
+
+				} else {
+
+					array = new TypedArray( arraybuffer, accessor.byteOffset, accessor.count * itemSize );
+
+					return new THREE.BufferAttribute( array, itemSize );
+
+				}
+
+			} );
+
+		} );
+
+	};
+
+	GLTFParser.prototype.loadTextures = function () {
+
+		var json = this.json;
+		var extensions = this.extensions;
+		var options = this.options;
+
+		return this._withDependencies( [
+
+			"bufferViews"
+
+		] ).then( function ( dependencies ) {
+
+			return _each( json.textures, function ( texture ) {
+
+				if ( texture.source ) {
+
+					return new Promise( function ( resolve ) {
+
+						var source = json.images[ texture.source ];
+						var sourceUri = source.uri;
+
+						if ( source.extensions && source.extensions[ EXTENSIONS.KHR_BINARY_GLTF ] ) {
+
+							sourceUri = extensions[ EXTENSIONS.KHR_BINARY_GLTF ].loadTextureSourceUri( source, dependencies.bufferViews );
+
+						}
+
+						var textureLoader = THREE.Loader.Handlers.get( sourceUri );
+
+						if ( textureLoader === null ) {
+
+							textureLoader = new THREE.TextureLoader();
+
+						}
+
+						textureLoader.setCrossOrigin( options.crossOrigin );
+
+						textureLoader.load( resolveURL( sourceUri, options.path ), function ( _texture ) {
+
+							_texture.flipY = false;
+
+							if ( texture.name !== undefined ) _texture.name = texture.name;
+
+							_texture.format = texture.format !== undefined ? WEBGL_TEXTURE_FORMATS[ texture.format ] : THREE.RGBAFormat;
+
+							if ( texture.internalFormat !== undefined && _texture.format !== WEBGL_TEXTURE_FORMATS[ texture.internalFormat ] ) {
+
+								console.warn( 'THREE.LegacyGLTFLoader: Three.js doesn\'t support texture internalFormat which is different from texture format. ' +
+															'internalFormat will be forced to be the same value as format.' );
+
+							}
+
+							_texture.type = texture.type !== undefined ? WEBGL_TEXTURE_DATATYPES[ texture.type ] : THREE.UnsignedByteType;
+
+							if ( texture.sampler ) {
+
+								var sampler = json.samplers[ texture.sampler ];
+
+								_texture.magFilter = WEBGL_FILTERS[ sampler.magFilter ] || THREE.LinearFilter;
+								_texture.minFilter = WEBGL_FILTERS[ sampler.minFilter ] || THREE.NearestMipMapLinearFilter;
+								_texture.wrapS = WEBGL_WRAPPINGS[ sampler.wrapS ] || THREE.RepeatWrapping;
+								_texture.wrapT = WEBGL_WRAPPINGS[ sampler.wrapT ] || THREE.RepeatWrapping;
+
+							}
+
+							resolve( _texture );
+
+						}, undefined, function () {
+
+							resolve();
+
+						} );
+
+					} );
+
+				}
+
+			} );
+
+		} );
+
+	};
+
+	GLTFParser.prototype.loadMaterials = function () {
+
+		var json = this.json;
+
+		return this._withDependencies( [
+
+			"shaders",
+			"textures"
+
+		] ).then( function ( dependencies ) {
+
+			return _each( json.materials, function ( material ) {
+
+				var materialType;
+				var materialValues = {};
+				var materialParams = {};
+
+				var khr_material;
+
+				if ( material.extensions && material.extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ] ) {
+
+					khr_material = material.extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ];
+
+				}
+
+				if ( khr_material ) {
+
+					// don't copy over unused values to avoid material warning spam
+					var keys = [ 'ambient', 'emission', 'transparent', 'transparency', 'doubleSided' ];
+
+					switch ( khr_material.technique ) {
+
+						case 'BLINN' :
+						case 'PHONG' :
+							materialType = THREE.MeshPhongMaterial;
+							keys.push( 'diffuse', 'specular', 'shininess' );
+							break;
+
+						case 'LAMBERT' :
+							materialType = THREE.MeshLambertMaterial;
+							keys.push( 'diffuse' );
+							break;
+
+						case 'CONSTANT' :
+						default :
+							materialType = THREE.MeshBasicMaterial;
+							break;
+
+					}
+
+					keys.forEach( function( v ) {
+
+						if ( khr_material.values[ v ] !== undefined ) materialValues[ v ] = khr_material.values[ v ];
+
+					} );
+
+					if ( khr_material.doubleSided || materialValues.doubleSided ) {
+
+						materialParams.side = THREE.DoubleSide;
+
+					}
+
+					if ( khr_material.transparent || materialValues.transparent ) {
+
+						materialParams.transparent = true;
+						materialParams.opacity = ( materialValues.transparency !== undefined ) ? materialValues.transparency : 1;
+
+					}
+
+				} else if ( material.technique === undefined ) {
+
+					materialType = THREE.MeshPhongMaterial;
+
+					Object.assign( materialValues, material.values );
+
+				} else {
+
+					materialType = DeferredShaderMaterial;
+
+					var technique = json.techniques[ material.technique ];
+
+					materialParams.uniforms = {};
+
+					var program = json.programs[ technique.program ];
+
+					if ( program ) {
+
+						materialParams.fragmentShader = dependencies.shaders[ program.fragmentShader ];
+
+						if ( ! materialParams.fragmentShader ) {
+
+							console.warn( "ERROR: Missing fragment shader definition:", program.fragmentShader );
+							materialType = THREE.MeshPhongMaterial;
+
+						}
+
+						var vertexShader = dependencies.shaders[ program.vertexShader ];
+
+						if ( ! vertexShader ) {
+
+							console.warn( "ERROR: Missing vertex shader definition:", program.vertexShader );
+							materialType = THREE.MeshPhongMaterial;
+
+						}
+
+						// IMPORTANT: FIX VERTEX SHADER ATTRIBUTE DEFINITIONS
+						materialParams.vertexShader = replaceTHREEShaderAttributes( vertexShader, technique );
+
+						var uniforms = technique.uniforms;
+
+						for ( var uniformId in uniforms ) {
+
+							var pname = uniforms[ uniformId ];
+							var shaderParam = technique.parameters[ pname ];
+
+							var ptype = shaderParam.type;
+
+							if ( WEBGL_TYPE[ ptype ] ) {
+
+								var pcount = shaderParam.count;
+								var value;
+
+								if ( material.values !== undefined ) value = material.values[ pname ];
+
+								var uvalue = new WEBGL_TYPE[ ptype ]();
+								var usemantic = shaderParam.semantic;
+								var unode = shaderParam.node;
+
+								switch ( ptype ) {
+
+									case WEBGL_CONSTANTS.FLOAT:
+
+										uvalue = shaderParam.value;
+
+										if ( pname == "transparency" ) {
+
+											materialParams.transparent = true;
+
+										}
+
+										if ( value !== undefined ) {
+
+											uvalue = value;
+
+										}
+
+										break;
+
+									case WEBGL_CONSTANTS.FLOAT_VEC2:
+									case WEBGL_CONSTANTS.FLOAT_VEC3:
+									case WEBGL_CONSTANTS.FLOAT_VEC4:
+									case WEBGL_CONSTANTS.FLOAT_MAT3:
+
+										if ( shaderParam && shaderParam.value ) {
+
+											uvalue.fromArray( shaderParam.value );
+
+										}
+
+										if ( value ) {
+
+											uvalue.fromArray( value );
+
+										}
+
+										break;
+
+									case WEBGL_CONSTANTS.FLOAT_MAT2:
+
+										// what to do?
+										console.warn( "FLOAT_MAT2 is not a supported uniform type" );
+										break;
+
+									case WEBGL_CONSTANTS.FLOAT_MAT4:
+
+										if ( pcount ) {
+
+											uvalue = new Array( pcount );
+
+											for ( var mi = 0; mi < pcount; mi ++ ) {
+
+												uvalue[ mi ] = new WEBGL_TYPE[ ptype ]();
+
+											}
+
+											if ( shaderParam && shaderParam.value ) {
+
+												var m4v = shaderParam.value;
+												uvalue.fromArray( m4v );
+
+											}
+
+											if ( value ) {
+
+												uvalue.fromArray( value );
+
+											}
+
+										} else {
+
+											if ( shaderParam && shaderParam.value ) {
+
+												var m4 = shaderParam.value;
+												uvalue.fromArray( m4 );
+
+											}
+
+											if ( value ) {
+
+												uvalue.fromArray( value );
+
+											}
+
+										}
+
+										break;
+
+									case WEBGL_CONSTANTS.SAMPLER_2D:
+
+										if ( value !== undefined ) {
+
+											uvalue = dependencies.textures[ value ];
+
+										} else if ( shaderParam.value !== undefined ) {
+
+											uvalue = dependencies.textures[ shaderParam.value ];
+
+										} else {
+
+											uvalue = null;
+
+										}
+
+										break;
+
+								}
+
+								materialParams.uniforms[ uniformId ] = {
+									value: uvalue,
+									semantic: usemantic,
+									node: unode
+								};
+
+							} else {
+
+								throw new Error( "Unknown shader uniform param type: " + ptype );
+
+							}
+
+						}
+
+						var states = technique.states || {};
+						var enables = states.enable || [];
+						var functions = states.functions || {};
+
+						var enableCullFace = false;
+						var enableDepthTest = false;
+						var enableBlend = false;
+
+						for ( var i = 0, il = enables.length; i < il; i ++ ) {
+
+							var enable = enables[ i ];
+
+							switch ( STATES_ENABLES[ enable ] ) {
+
+								case 'CULL_FACE':
+
+									enableCullFace = true;
+
+									break;
+
+								case 'DEPTH_TEST':
+
+									enableDepthTest = true;
+
+									break;
+
+								case 'BLEND':
+
+									enableBlend = true;
+
+									break;
+
+								// TODO: implement
+								case 'SCISSOR_TEST':
+								case 'POLYGON_OFFSET_FILL':
+								case 'SAMPLE_ALPHA_TO_COVERAGE':
+
+									break;
+
+								default:
+
+									throw new Error( "Unknown technique.states.enable: " + enable );
+
+							}
+
+						}
+
+						if ( enableCullFace ) {
+
+							materialParams.side = functions.cullFace !== undefined ? WEBGL_SIDES[ functions.cullFace ] : THREE.FrontSide;
+
+						} else {
+
+							materialParams.side = THREE.DoubleSide;
+
+						}
+
+						materialParams.depthTest = enableDepthTest;
+						materialParams.depthFunc = functions.depthFunc !== undefined ? WEBGL_DEPTH_FUNCS[ functions.depthFunc ] : THREE.LessDepth;
+						materialParams.depthWrite = functions.depthMask !== undefined ? functions.depthMask[ 0 ] : true;
+
+						materialParams.blending = enableBlend ? THREE.CustomBlending : THREE.NoBlending;
+						materialParams.transparent = enableBlend;
+
+						var blendEquationSeparate = functions.blendEquationSeparate;
+
+						if ( blendEquationSeparate !== undefined ) {
+
+							materialParams.blendEquation = WEBGL_BLEND_EQUATIONS[ blendEquationSeparate[ 0 ] ];
+							materialParams.blendEquationAlpha = WEBGL_BLEND_EQUATIONS[ blendEquationSeparate[ 1 ] ];
+
+						} else {
+
+							materialParams.blendEquation = THREE.AddEquation;
+							materialParams.blendEquationAlpha = THREE.AddEquation;
+
+						}
+
+						var blendFuncSeparate = functions.blendFuncSeparate;
+
+						if ( blendFuncSeparate !== undefined ) {
+
+							materialParams.blendSrc = WEBGL_BLEND_FUNCS[ blendFuncSeparate[ 0 ] ];
+							materialParams.blendDst = WEBGL_BLEND_FUNCS[ blendFuncSeparate[ 1 ] ];
+							materialParams.blendSrcAlpha = WEBGL_BLEND_FUNCS[ blendFuncSeparate[ 2 ] ];
+							materialParams.blendDstAlpha = WEBGL_BLEND_FUNCS[ blendFuncSeparate[ 3 ] ];
+
+						} else {
+
+							materialParams.blendSrc = THREE.OneFactor;
+							materialParams.blendDst = THREE.ZeroFactor;
+							materialParams.blendSrcAlpha = THREE.OneFactor;
+							materialParams.blendDstAlpha = THREE.ZeroFactor;
+
+						}
+
+					}
+
+				}
+
+				if ( Array.isArray( materialValues.diffuse ) ) {
+
+					materialParams.color = new THREE.Color().fromArray( materialValues.diffuse );
+
+				} else if ( typeof( materialValues.diffuse ) === 'string' ) {
+
+					materialParams.map = dependencies.textures[ materialValues.diffuse ];
+
+				}
+
+				delete materialParams.diffuse;
+
+				if ( typeof( materialValues.reflective ) === 'string' ) {
+
+					materialParams.envMap = dependencies.textures[ materialValues.reflective ];
+
+				}
+
+				if ( typeof( materialValues.bump ) === 'string' ) {
+
+					materialParams.bumpMap = dependencies.textures[ materialValues.bump ];
+
+				}
+
+				if ( Array.isArray( materialValues.emission ) ) {
+
+					if ( materialType === THREE.MeshBasicMaterial ) {
+
+						materialParams.color = new THREE.Color().fromArray( materialValues.emission );
+
+					} else {
+
+						materialParams.emissive = new THREE.Color().fromArray( materialValues.emission );
+
+					}
+
+				} else if ( typeof( materialValues.emission ) === 'string' ) {
+
+					if ( materialType === THREE.MeshBasicMaterial ) {
+
+						materialParams.map = dependencies.textures[ materialValues.emission ];
+
+					} else {
+
+						materialParams.emissiveMap = dependencies.textures[ materialValues.emission ];
+
+					}
+
+				}
+
+				if ( Array.isArray( materialValues.specular ) ) {
+
+					materialParams.specular = new THREE.Color().fromArray( materialValues.specular );
+
+				} else if ( typeof( materialValues.specular ) === 'string' ) {
+
+					materialParams.specularMap = dependencies.textures[ materialValues.specular ];
+
+				}
+
+				if ( materialValues.shininess !== undefined ) {
+
+					materialParams.shininess = materialValues.shininess;
+
+				}
+
+				var _material = new materialType( materialParams );
+				if ( material.name !== undefined ) _material.name = material.name;
+
+				return _material;
+
+			} );
+
+		} );
+
+	};
+
+	GLTFParser.prototype.loadMeshes = function () {
+
+		var json = this.json;
+
+		return this._withDependencies( [
+
+			"accessors",
+			"materials"
+
+		] ).then( function ( dependencies ) {
+
+			return _each( json.meshes, function ( mesh ) {
+
+				var group = new THREE.Group();
+				if ( mesh.name !== undefined ) group.name = mesh.name;
+
+				if ( mesh.extras ) group.userData = mesh.extras;
+
+				var primitives = mesh.primitives || [];
+
+				for ( var name in primitives ) {
+
+					var primitive = primitives[ name ];
+
+					if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLES || primitive.mode === undefined ) {
+
+						var geometry = new THREE.BufferGeometry();
+
+						var attributes = primitive.attributes;
+
+						for ( var attributeId in attributes ) {
+
+							var attributeEntry = attributes[ attributeId ];
+
+							if ( ! attributeEntry ) return;
+
+							var bufferAttribute = dependencies.accessors[ attributeEntry ];
+
+							switch ( attributeId ) {
+
+								case 'POSITION':
+									geometry.addAttribute( 'position', bufferAttribute );
+									break;
+
+								case 'NORMAL':
+									geometry.addAttribute( 'normal', bufferAttribute );
+									break;
+
+								case 'TEXCOORD_0':
+								case 'TEXCOORD0':
+								case 'TEXCOORD':
+									geometry.addAttribute( 'uv', bufferAttribute );
+									break;
+
+								case 'TEXCOORD_1':
+									geometry.addAttribute( 'uv2', bufferAttribute );
+									break;
+
+								case 'COLOR_0':
+								case 'COLOR0':
+								case 'COLOR':
+									geometry.addAttribute( 'color', bufferAttribute );
+									break;
+
+								case 'WEIGHT':
+									geometry.addAttribute( 'skinWeight', bufferAttribute );
+									break;
+
+								case 'JOINT':
+									geometry.addAttribute( 'skinIndex', bufferAttribute );
+									break;
+
+							}
+
+						}
+
+						if ( primitive.indices ) {
+
+							geometry.setIndex( dependencies.accessors[ primitive.indices ] );
+
+						}
+
+						var material = dependencies.materials !== undefined ? dependencies.materials[ primitive.material ] : createDefaultMaterial();
+
+						var meshNode = new THREE.Mesh( geometry, material );
+						meshNode.castShadow = true;
+						meshNode.name = ( name === "0" ? group.name : group.name + name );
+
+						if ( primitive.extras ) meshNode.userData = primitive.extras;
+
+						group.add( meshNode );
+
+					} else if ( primitive.mode === WEBGL_CONSTANTS.LINES ) {
+
+						var geometry = new THREE.BufferGeometry();
+
+						var attributes = primitive.attributes;
+
+						for ( var attributeId in attributes ) {
+
+							var attributeEntry = attributes[ attributeId ];
+
+							if ( ! attributeEntry ) return;
+
+							var bufferAttribute = dependencies.accessors[ attributeEntry ];
+
+							switch ( attributeId ) {
+
+								case 'POSITION':
+									geometry.addAttribute( 'position', bufferAttribute );
+									break;
+
+								case 'COLOR_0':
+								case 'COLOR0':
+								case 'COLOR':
+									geometry.addAttribute( 'color', bufferAttribute );
+									break;
+
+							}
+
+						}
+
+						var material = dependencies.materials[ primitive.material ];
+
+						var meshNode;
+
+						if ( primitive.indices ) {
+
+							geometry.setIndex( dependencies.accessors[ primitive.indices ] );
+
+							meshNode = new THREE.LineSegments( geometry, material );
+
+						} else {
+
+							meshNode = new THREE.Line( geometry, material );
+
+						}
+
+						meshNode.name = ( name === "0" ? group.name : group.name + name );
+
+						if ( primitive.extras ) meshNode.userData = primitive.extras;
+
+						group.add( meshNode );
+
+					} else {
+
+						console.warn( "Only triangular and line primitives are supported" );
+
+					}
+
+				}
+
+				return group;
+
+			} );
+
+		} );
+
+	};
+
+	GLTFParser.prototype.loadCameras = function () {
+
+		var json = this.json;
+
+		return _each( json.cameras, function ( camera ) {
+
+			if ( camera.type == "perspective" && camera.perspective ) {
+
+				var yfov = camera.perspective.yfov;
+				var aspectRatio = camera.perspective.aspectRatio !== undefined ? camera.perspective.aspectRatio : 1;
+
+				// According to COLLADA spec...
+				// aspectRatio = xfov / yfov
+				var xfov = yfov * aspectRatio;
+
+				var _camera = new THREE.PerspectiveCamera( THREE.Math.radToDeg( xfov ), aspectRatio, camera.perspective.znear || 1, camera.perspective.zfar || 2e6 );
+				if ( camera.name !== undefined ) _camera.name = camera.name;
+
+				if ( camera.extras ) _camera.userData = camera.extras;
+
+				return _camera;
+
+			} else if ( camera.type == "orthographic" && camera.orthographic ) {
+
+				var _camera = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, camera.orthographic.znear, camera.orthographic.zfar );
+				if ( camera.name !== undefined ) _camera.name = camera.name;
+
+				if ( camera.extras ) _camera.userData = camera.extras;
+
+				return _camera;
+
+			}
+
+		} );
+
+	};
+
+	GLTFParser.prototype.loadSkins = function () {
+
+		var json = this.json;
+
+		return this._withDependencies( [
+
+			"accessors"
+
+		] ).then( function ( dependencies ) {
+
+			return _each( json.skins, function ( skin ) {
+
+				var bindShapeMatrix = new THREE.Matrix4();
+
+				if ( skin.bindShapeMatrix !== undefined ) bindShapeMatrix.fromArray( skin.bindShapeMatrix );
+
+				var _skin = {
+					bindShapeMatrix: bindShapeMatrix,
+					jointNames: skin.jointNames,
+					inverseBindMatrices: dependencies.accessors[ skin.inverseBindMatrices ]
+				};
+
+				return _skin;
+
+			} );
+
+		} );
+
+	};
+
+	GLTFParser.prototype.loadAnimations = function () {
+
+		var json = this.json;
+
+		return this._withDependencies( [
+
+			"accessors",
+			"nodes"
+
+		] ).then( function ( dependencies ) {
+
+			return _each( json.animations, function ( animation, animationId ) {
+
+				var tracks = [];
+
+				for ( var channelId in animation.channels ) {
+
+					var channel = animation.channels[ channelId ];
+					var sampler = animation.samplers[ channel.sampler ];
+
+					if ( sampler ) {
+
+						var target = channel.target;
+						var name = target.id;
+						var input = animation.parameters !== undefined ? animation.parameters[ sampler.input ] : sampler.input;
+						var output = animation.parameters !== undefined ? animation.parameters[ sampler.output ] : sampler.output;
+
+						var inputAccessor = dependencies.accessors[ input ];
+						var outputAccessor = dependencies.accessors[ output ];
+
+						var node = dependencies.nodes[ name ];
+
+						if ( node ) {
+
+							node.updateMatrix();
+							node.matrixAutoUpdate = true;
+
+							var TypedKeyframeTrack = PATH_PROPERTIES[ target.path ] === PATH_PROPERTIES.rotation
+								? THREE.QuaternionKeyframeTrack
+								: THREE.VectorKeyframeTrack;
+
+							var targetName = node.name ? node.name : node.uuid;
+							var interpolation = sampler.interpolation !== undefined ? INTERPOLATION[ sampler.interpolation ] : THREE.InterpolateLinear;
+
+							// KeyframeTrack.optimize() will modify given 'times' and 'values'
+							// buffers before creating a truncated copy to keep. Because buffers may
+							// be reused by other tracks, make copies here.
+							tracks.push( new TypedKeyframeTrack(
+								targetName + '.' + PATH_PROPERTIES[ target.path ],
+								THREE.AnimationUtils.arraySlice( inputAccessor.array, 0 ),
+								THREE.AnimationUtils.arraySlice( outputAccessor.array, 0 ),
+								interpolation
+							) );
+
+						}
+
+					}
+
+				}
+
+				var name = animation.name !== undefined ? animation.name : "animation_" + animationId;
+
+				return new THREE.AnimationClip( name, undefined, tracks );
+
+			} );
+
+		} );
+
+	};
+
+	GLTFParser.prototype.loadNodes = function () {
+
+		var json = this.json;
+		var extensions = this.extensions;
+		var scope = this;
+
+		return _each( json.nodes, function ( node ) {
+
+			var matrix = new THREE.Matrix4();
+
+			var _node;
+
+			if ( node.jointName ) {
+
+				_node = new THREE.Bone();
+				_node.name = node.name !== undefined ? node.name : node.jointName;
+				_node.jointName = node.jointName;
+
+			} else {
+
+				_node = new THREE.Object3D();
+				if ( node.name !== undefined ) _node.name = node.name;
+
+			}
+
+			if ( node.extras ) _node.userData = node.extras;
+
+			if ( node.matrix !== undefined ) {
+
+				matrix.fromArray( node.matrix );
+				_node.applyMatrix( matrix );
+
+			} else {
+
+				if ( node.translation !== undefined ) {
+
+					_node.position.fromArray( node.translation );
+
+				}
+
+				if ( node.rotation !== undefined ) {
+
+					_node.quaternion.fromArray( node.rotation );
+
+				}
+
+				if ( node.scale !== undefined ) {
+
+					_node.scale.fromArray( node.scale );
+
+				}
+
+			}
+
+			return _node;
+
+		} ).then( function ( __nodes ) {
+
+			return scope._withDependencies( [
+
+				"meshes",
+				"skins",
+				"cameras"
+
+			] ).then( function ( dependencies ) {
+
+				return _each( __nodes, function ( _node, nodeId ) {
+
+					var node = json.nodes[ nodeId ];
+
+					if ( node.meshes !== undefined ) {
+
+						for ( var meshId in node.meshes ) {
+
+							var mesh = node.meshes[ meshId ];
+							var group = dependencies.meshes[ mesh ];
+
+							if ( group === undefined ) {
+
+								console.warn( 'LegacyGLTFLoader: Couldn\'t find node "' + mesh + '".' );
+								continue;
+
+							}
+
+							for ( var childrenId in group.children ) {
+
+								var child = group.children[ childrenId ];
+
+								// clone Mesh to add to _node
+
+								var originalMaterial = child.material;
+								var originalGeometry = child.geometry;
+								var originalUserData = child.userData;
+								var originalName = child.name;
+
+								var material;
+
+								if ( originalMaterial.isDeferredShaderMaterial ) {
+
+									originalMaterial = material = originalMaterial.create();
+
+								} else {
+
+									material = originalMaterial;
+
+								}
+
+								switch ( child.type ) {
+
+									case 'LineSegments':
+										child = new THREE.LineSegments( originalGeometry, material );
+										break;
+
+									case 'LineLoop':
+										child = new THREE.LineLoop( originalGeometry, material );
+										break;
+
+									case 'Line':
+										child = new THREE.Line( originalGeometry, material );
+										break;
+
+									default:
+										child = new THREE.Mesh( originalGeometry, material );
+
+								}
+
+								child.castShadow = true;
+								child.userData = originalUserData;
+								child.name = originalName;
+
+								var skinEntry;
+
+								if ( node.skin ) {
+
+									skinEntry = dependencies.skins[ node.skin ];
+
+								}
+
+								// Replace Mesh with SkinnedMesh in library
+								if ( skinEntry ) {
+
+									var getJointNode = function ( jointId ) {
+
+										var keys = Object.keys( __nodes );
+
+										for ( var i = 0, il = keys.length; i < il; i ++ ) {
+
+											var n = __nodes[ keys[ i ] ];
+
+											if ( n.jointName === jointId ) return n;
+
+										}
+
+										return null;
+
+									};
+
+									var geometry = originalGeometry;
+									var material = originalMaterial;
+									material.skinning = true;
+
+									child = new THREE.SkinnedMesh( geometry, material );
+									child.castShadow = true;
+									child.userData = originalUserData;
+									child.name = originalName;
+
+									var bones = [];
+									var boneInverses = [];
+
+									for ( var i = 0, l = skinEntry.jointNames.length; i < l; i ++ ) {
+
+										var jointId = skinEntry.jointNames[ i ];
+										var jointNode = getJointNode( jointId );
+
+										if ( jointNode ) {
+
+											bones.push( jointNode );
+
+											var m = skinEntry.inverseBindMatrices.array;
+											var mat = new THREE.Matrix4().fromArray( m, i * 16 );
+											boneInverses.push( mat );
+
+										} else {
+
+											console.warn( "WARNING: joint: '" + jointId + "' could not be found" );
+
+										}
+
+									}
+
+									child.bind( new THREE.Skeleton( bones, boneInverses ), skinEntry.bindShapeMatrix );
+
+									var buildBoneGraph = function ( parentJson, parentObject, property ) {
+
+										var children = parentJson[ property ];
+
+										if ( children === undefined ) return;
+
+										for ( var i = 0, il = children.length; i < il; i ++ ) {
+
+											var nodeId = children[ i ];
+											var bone = __nodes[ nodeId ];
+											var boneJson = json.nodes[ nodeId ];
+
+											if ( bone !== undefined && bone.isBone === true && boneJson !== undefined ) {
+
+												parentObject.add( bone );
+												buildBoneGraph( boneJson, bone, 'children' );
+
+											}
+
+										}
+
+									};
+
+									buildBoneGraph( node, child, 'skeletons' );
+
+								}
+
+								_node.add( child );
+
+							}
+
+						}
+
+					}
+
+					if ( node.camera !== undefined ) {
+
+						var camera = dependencies.cameras[ node.camera ];
+
+						_node.add( camera );
+
+					}
+
+					if ( node.extensions
+							 && node.extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ]
+							 && node.extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ].light ) {
+
+						var extensionLights = extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ].lights;
+						var light = extensionLights[ node.extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ].light ];
+
+						_node.add( light );
+
+					}
+
+					return _node;
+
+				} );
+
+			} );
+
+		} );
+
+	};
+
+	GLTFParser.prototype.loadScenes = function () {
+
+		var json = this.json;
+
+		// scene node hierachy builder
+
+		function buildNodeHierachy( nodeId, parentObject, allNodes ) {
+
+			var _node = allNodes[ nodeId ];
+			parentObject.add( _node );
+
+			var node = json.nodes[ nodeId ];
+
+			if ( node.children ) {
+
+				var children = node.children;
+
+				for ( var i = 0, l = children.length; i < l; i ++ ) {
+
+					var child = children[ i ];
+					buildNodeHierachy( child, _node, allNodes );
+
+				}
+
+			}
+
+		}
+
+		return this._withDependencies( [
+
+			"nodes"
+
+		] ).then( function ( dependencies ) {
+
+			return _each( json.scenes, function ( scene ) {
+
+				var _scene = new THREE.Scene();
+				if ( scene.name !== undefined ) _scene.name = scene.name;
+
+				if ( scene.extras ) _scene.userData = scene.extras;
+
+				var nodes = scene.nodes || [];
+
+				for ( var i = 0, l = nodes.length; i < l; i ++ ) {
+
+					var nodeId = nodes[ i ];
+					buildNodeHierachy( nodeId, _scene, dependencies.nodes );
+
+				}
+
+				_scene.traverse( function ( child ) {
+
+					// Register raw material meshes with LegacyGLTFLoader.Shaders
+					if ( child.material && child.material.isRawShaderMaterial ) {
+
+						child.gltfShader = new GLTFShader( child, dependencies.nodes );
+						child.onBeforeRender = function(renderer, scene, camera){
+							this.gltfShader.update(scene, camera);
+						};
+
+					}
+
+				} );
+
+				return _scene;
+
+			} );
+
+		} );
+
+	};
+
+	return LegacyGLTFLoader;
+
+} )();

+ 23 - 6
examples/misc_exporter_gltf.html

@@ -32,6 +32,7 @@
 			<label><input id="option_trs" name="trs" type="checkbox"/>TRS</label>
 			<label><input id="option_visible" name="visible" type="checkbox" checked="checked"/>Only Visible</label>
 			<label><input id="option_drawrange" name="visible" type="checkbox" checked="checked"/>Truncate drawRange</label>
+			<label><input id="option_binary" name="visible" type="checkbox">Binary (<code>.glb</code>)</label>
 		</div>
 
 		<script src="../build/three.js"></script>
@@ -48,13 +49,22 @@
 				var options = {
 					trs: document.getElementById('option_trs').checked,
 					onlyVisible: document.getElementById('option_visible').checked,
-					truncateDrawRange: document.getElementById('option_drawrange').checked
-				}
+					truncateDrawRange: document.getElementById('option_drawrange').checked,
+					binary: document.getElementById('option_binary').checked
+				};
 				gltfExporter.parse( input, function( result ) {
 
-					var output = JSON.stringify( result, null, 2 );
-					console.log( output );
-					saveString( output, 'scene.gltf' );
+					if ( result instanceof ArrayBuffer ) {
+
+						saveArrayBuffer( result, 'scene.glb' );
+
+					} else {
+
+						var output = JSON.stringify( result, null, 2 );
+						console.log( output );
+						saveString( output, 'scene.gltf' );
+
+					}
 
 				}, options );
 
@@ -98,7 +108,7 @@
 			function save( blob, filename ) {
 
 				link.href = URL.createObjectURL( blob );
-				link.download = filename || 'data.json';
+				link.download = filename;
 				link.click();
 
 				// URL.revokeObjectURL( url ); breaks Firefox...
@@ -111,6 +121,13 @@
 
 			}
 
+
+			function saveArrayBuffer( buffer, filename ) {
+
+				save( new Blob( [ buffer ], { type: 'application/octet-stream' } ), filename );
+
+			}
+
 			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
 
 			var container;

+ 1 - 1
examples/webgl_clipping_advanced.html

@@ -117,7 +117,7 @@
 						xAxis.x, yAxis.x, zAxis.x, trans.x,
 						xAxis.y, yAxis.y, zAxis.y, trans.y,
 						xAxis.z, yAxis.z, zAxis.z, trans.z,
-							0,		0,		0,			1 );
+						0,	 0,	  0,	   1 );
 
 				};
 

+ 10 - 6
examples/webgl_geometry_shapes.html

@@ -114,12 +114,16 @@
 					// lines
 
 					shape.autoClose = true;
-					var points = shape.createPointsGeometry();
-					var spacedPoints = shape.createSpacedPointsGeometry( 50 );
+
+					var points = shape.getPoints();
+					var spacedPoints = shape.getSpacedPoints( 50 );
+
+					var geometryPoints = new THREE.BufferGeometry().setFromPoints( points );
+					var geometrySpacedPoints = new THREE.BufferGeometry().setFromPoints( spacedPoints );
 
 					// solid line
 
-					var line = new THREE.Line( points, new THREE.LineBasicMaterial( { color: color, linewidth: 3 } ) );
+					var line = new THREE.Line( geometryPoints, new THREE.LineBasicMaterial( { color: color, linewidth: 3 } ) );
 					line.position.set( x, y, z - 25 );
 					line.rotation.set( rx, ry, rz );
 					line.scale.set( s, s, s );
@@ -127,7 +131,7 @@
 
 					// line from equidistance sampled points
 
-					var line = new THREE.Line( spacedPoints, new THREE.LineBasicMaterial( { color: color, linewidth: 3 } ) );
+					var line = new THREE.Line( geometrySpacedPoints, new THREE.LineBasicMaterial( { color: color, linewidth: 3 } ) );
 					line.position.set( x, y, z + 25 );
 					line.rotation.set( rx, ry, rz );
 					line.scale.set( s, s, s );
@@ -135,7 +139,7 @@
 
 					// vertices from real points
 
-					var particles = new THREE.Points( points, new THREE.PointsMaterial( { color: color, size: 4 } ) );
+					var particles = new THREE.Points( geometryPoints, new THREE.PointsMaterial( { color: color, size: 4 } ) );
 					particles.position.set( x, y, z + 75 );
 					particles.rotation.set( rx, ry, rz );
 					particles.scale.set( s, s, s );
@@ -143,7 +147,7 @@
 
 					// equidistance sampled points
 
-					var particles = new THREE.Points( spacedPoints, new THREE.PointsMaterial( { color: color, size: 4 } ) );
+					var particles = new THREE.Points( geometrySpacedPoints, new THREE.PointsMaterial( { color: color, size: 4 } ) );
 					particles.position.set( x, y, z + 125 );
 					particles.rotation.set( rx, ry, rz );
 					particles.scale.set( s, s, s );

+ 5 - 4
examples/webgl_geometry_text_shapes.html

@@ -116,11 +116,12 @@
 
 						var shape = shapes[ i ];
 
-						var lineGeometry = shape.createPointsGeometry();
+						var points = shape.getPoints();
+						var geometry = new THREE.BufferGeometry().setFromPoints( points );
+						
+						geometry.translate( xMid, 0, 0 );
 
-						lineGeometry.translate( xMid, 0, 0 );
-
-						var lineMesh = new THREE.Line( lineGeometry, matDark );
+						var lineMesh = new THREE.Line( geometry, matDark );
 						lineText.add( lineMesh );
 
 					}

+ 1 - 1
examples/webgl_octree.html

@@ -28,7 +28,7 @@
 				mesh,
 				meshes = [],
 				meshesSearch = [],
-				meshCountMax = 1000,
+				meshCountMax = 100,
 				radius = 500,
 				radiusMax = radius * 10,
 				radiusMaxHalf = radiusMax * 0.5,

+ 12 - 2
examples/webgl_shadowmap_pcss.html

@@ -190,8 +190,10 @@
 					var material = new THREE.MeshPhongMaterial( { color: Math.random() * 0xffffff } );
 
 					var sphere = new THREE.Mesh( geometry, material );
-					sphere.position.x = Math.random() * 6 - 3;
-					sphere.position.z = Math.random() * 6 - 3;
+					sphere.position.x = Math.random() - 0.5;
+					sphere.position.z = Math.random() - 0.5;
+					sphere.position.normalize();
+					sphere.position.multiplyScalar( Math.random() * 2 + 1 );
 					sphere.castShadow = true;
 					sphere.receiveShadow = true;
 					sphere.userData.phase = Math.random() * Math.PI;
@@ -208,6 +210,14 @@
 				mesh.receiveShadow = true;
 				scene.add( mesh );
 
+				// column
+
+				var mesh = new THREE.Mesh( new THREE.BoxBufferGeometry( 1, 4, 1 ), groundMaterial );
+				mesh.position.y = 2;
+				mesh.castShadow = true;
+				mesh.receiveShadow = true;
+				scene.add( mesh );
+
 				// overwrite shadowmap code
 
 				var shader = THREE.ShaderChunk.shadowmap_pars_fragment;

+ 6 - 3
package.json

@@ -31,7 +31,8 @@
     "build-test": "rollup -c test/rollup.unit.config.js",
     "build-uglify": "rollup -c && uglifyjs build/three.js -cm --preamble \"// threejs.org/license\" > build/three.min.js",
     "build-closure": "rollup -c && java -jar node_modules/google-closure-compiler/compiler.jar --warning_level=VERBOSE --jscomp_off=globalThis --jscomp_off=checkTypes --externs utils/build/externs.js --language_in=ECMASCRIPT5_STRICT --js build/three.js --js_output_file build/three.min.js",
-    "dev": "rollup -c -w -m inline",
+    "dev": "concurrently --names \"ROLLUP,HTTP\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c -w -m inline\" \"serve --port 8080\"",
+    "start": "npm run dev",
     "lint": "eslint src",
     "test": "rollup -c test/rollup.unit.config.js -w",
     "editor": "electron ./editor/main.js"
@@ -49,13 +50,15 @@
   },
   "homepage": "http://threejs.org/",
   "devDependencies": {
+    "concurrently": "^3.5.0",
+    "electron": "1.7.8",
     "eslint": "^4.1.1",
     "eslint-config-mdcs": "^4.2.2",
     "google-closure-compiler": "^20170521.0.0",
     "qunitjs": "^2.1.1",
     "rollup": "^0.43.0",
     "rollup-watch": "^4.0.0",
-    "uglify-js": "^3.0.23",
-    "electron": "1.7.8"
+    "serve": "^6.3.1",
+    "uglify-js": "^3.0.23"
   }
 }

+ 46 - 0
src/Three.Legacy.js

@@ -24,6 +24,7 @@ import { Geometry } from './core/Geometry.js';
 import { Object3D } from './core/Object3D.js';
 import { Uniform } from './core/Uniform.js';
 import { Curve } from './extras/core/Curve.js';
+import { CurvePath } from './extras/core/CurvePath.js';
 import { CatmullRomCurve3 } from './extras/curves/CatmullRomCurve3.js';
 import { AxesHelper } from './helpers/AxesHelper.js';
 import { BoxHelper } from './helpers/BoxHelper.js';
@@ -242,6 +243,51 @@ Curve.create = function ( construct, getPoint ) {
 
 //
 
+Object.assign( CurvePath.prototype, {
+
+	createPointsGeometry: function ( divisions ) {
+
+		console.warn( 'THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.' );
+
+		// generate geometry from path points (for Line or Points objects)
+
+		var pts = this.getPoints( divisions );
+		return this.createGeometry( pts );
+
+	},
+
+	createSpacedPointsGeometry: function ( divisions ) {
+
+		console.warn( 'THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.' );
+
+		// generate geometry from equidistant sampling along the path
+
+		var pts = this.getSpacedPoints( divisions );
+		return this.createGeometry( pts );
+
+	},
+
+	createGeometry: function ( points ) {
+
+		console.warn( 'THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.' );
+
+		var geometry = new Geometry();
+
+		for ( var i = 0, l = points.length; i < l; i ++ ) {
+
+			var point = points[ i ];
+			geometry.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );
+
+		}
+
+		return geometry;
+
+	}
+
+} );
+
+//
+
 export function ClosedSplineCurve3( points ) {
 
 	console.warn( 'THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.' );

+ 17 - 0
src/core/BufferGeometry.js

@@ -334,6 +334,23 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
 
 	},
 
+	setFromPoints: function ( points ) {
+
+		var position = [];
+
+		for ( var i = 0, l = points.length; i < l; i ++ ) {
+
+			var point = points[ i ];
+			position.push( point.x, point.y, point.z || 0 );
+
+		}
+
+		this.addAttribute( 'position', new Float32BufferAttribute( position, 3 ) );
+
+		return this;
+
+	},
+
 	updateFromObject: function ( object ) {
 
 		var geometry = object.geometry;

+ 15 - 0
src/core/Geometry.js

@@ -921,6 +921,21 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, {
 
 	},
 
+	setFromPoints: function ( points ) {
+
+		this.vertices = [];
+
+		for ( var i = 0, l = points.length; i < l; i ++ ) {
+
+			var point = points[ i ];
+			this.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );
+
+		}
+
+		return this;
+
+	},
+
 	sortFacesByMaterialIndex: function () {
 
 		var faces = this.faces;

+ 7 - 7
src/core/Object3D.js

@@ -171,23 +171,23 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, {
 	}(),
 
 	rotateOnWorldAxis: function () {
-		
+
 		// rotate object on axis in world space
 		// axis is assumed to be normalized
 		// method assumes no rotated parent
 
 		var q1 = new Quaternion();
-		
+
 		return function rotateOnWorldAxis( axis, angle ) {
-		
+
 			q1.setFromAxisAngle( axis, angle );
-		
+
 			this.quaternion.premultiply( q1 );
-		
+
 			return this;
-		
+
 		};
-		
+
 	}(),
 
 	rotateX: function () {

+ 0 - 39
src/extras/core/CurvePath.js

@@ -1,6 +1,4 @@
 import { Curve } from './Curve.js';
-import { Vector3 } from '../../math/Vector3.js';
-import { Geometry } from '../../core/Geometry.js';
 import { LineCurve } from '../curves/LineCurve.js';
 
 /**
@@ -198,43 +196,6 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), {
 
 		return points;
 
-	},
-
-	/**************************************************************
-	 *	Create Geometries Helpers
-	 **************************************************************/
-
-	/// Generate geometry from path points (for Line or Points objects)
-
-	createPointsGeometry: function ( divisions ) {
-
-		var pts = this.getPoints( divisions );
-		return this.createGeometry( pts );
-
-	},
-
-	// Generate geometry from equidistant sampling along the path
-
-	createSpacedPointsGeometry: function ( divisions ) {
-
-		var pts = this.getSpacedPoints( divisions );
-		return this.createGeometry( pts );
-
-	},
-
-	createGeometry: function ( points ) {
-
-		var geometry = new Geometry();
-
-		for ( var i = 0, l = points.length; i < l; i ++ ) {
-
-			var point = points[ i ];
-			geometry.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );
-
-		}
-
-		return geometry;
-
 	}
 
 } );

+ 1 - 1
src/geometries/CircleGeometry.js

@@ -48,7 +48,7 @@ function CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) {
 		thetaLength: thetaLength
 	};
 
-	radius = radius || 50;
+	radius = radius || 1;
 	segments = segments !== undefined ? Math.max( 3, segments ) : 8;
 
 	thetaStart = thetaStart !== undefined ? thetaStart : 0;

+ 3 - 3
src/geometries/CylinderGeometry.js

@@ -57,9 +57,9 @@ function CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments
 
 	var scope = this;
 
-	radiusTop = radiusTop !== undefined ? radiusTop : 20;
-	radiusBottom = radiusBottom !== undefined ? radiusBottom : 20;
-	height = height !== undefined ? height : 100;
+	radiusTop = radiusTop !== undefined ? radiusTop : 1;
+	radiusBottom = radiusBottom !== undefined ? radiusBottom : 1;
+	height = height || 1;
 
 	radialSegments = Math.floor( radialSegments ) || 8;
 	heightSegments = Math.floor( heightSegments ) || 1;

+ 2 - 2
src/geometries/RingGeometry.js

@@ -51,8 +51,8 @@ function RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegment
 		thetaLength: thetaLength
 	};
 
-	innerRadius = innerRadius || 20;
-	outerRadius = outerRadius || 50;
+	innerRadius = innerRadius || 0.5;
+	outerRadius = outerRadius || 1;
 
 	thetaStart = thetaStart !== undefined ? thetaStart : 0;
 	thetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;

+ 1 - 1
src/geometries/SphereGeometry.js

@@ -53,7 +53,7 @@ function SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart,
 		thetaLength: thetaLength
 	};
 
-	radius = radius || 50;
+	radius = radius || 1;
 
 	widthSegments = Math.max( 3, Math.floor( widthSegments ) || 8 );
 	heightSegments = Math.max( 2, Math.floor( heightSegments ) || 6 );

+ 2 - 2
src/geometries/TorusGeometry.js

@@ -49,8 +49,8 @@ function TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc
 		arc: arc
 	};
 
-	radius = radius || 100;
-	tube = tube || 40;
+	radius = radius || 1;
+	tube = tube || 0.4;
 	radialSegments = Math.floor( radialSegments ) || 8;
 	tubularSegments = Math.floor( tubularSegments ) || 6;
 	arc = arc || Math.PI * 2;

+ 2 - 2
src/geometries/TorusKnotGeometry.js

@@ -54,8 +54,8 @@ function TorusKnotBufferGeometry( radius, tube, tubularSegments, radialSegments,
 		q: q
 	};
 
-	radius = radius || 100;
-	tube = tube || 40;
+	radius = radius || 1;
+	tube = tube || 0.4;
 	tubularSegments = Math.floor( tubularSegments ) || 64;
 	radialSegments = Math.floor( radialSegments ) || 8;
 	p = p || 2;

+ 69 - 9
src/loaders/FileLoader.js

@@ -5,6 +5,8 @@
 import { Cache } from './Cache.js';
 import { DefaultLoadingManager } from './LoadingManager.js';
 
+var loading = {};
+
 function FileLoader( manager ) {
 
 	this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
@@ -39,6 +41,22 @@ Object.assign( FileLoader.prototype, {
 
 		}
 
+		// Check if request is duplicate
+
+		if ( loading[ url ] !== undefined ) {
+
+			loading[ url ].push( {
+
+				onLoad: onLoad,
+				onProgress: onProgress,
+				onError: onError
+
+			} );
+
+			return;
+
+		}
+
 		// Check for data: URI
 		var dataUriRegex = /^data:(.*?)(;base64)?,(.*)$/;
 		var dataUriRegexResult = url.match( dataUriRegex );
@@ -130,7 +148,20 @@ Object.assign( FileLoader.prototype, {
 
 		} else {
 
+			// Initialise array for duplicate requests
+
+			loading[ url ] = [];
+
+			loading[ url ].push( {
+
+				onLoad: onLoad,
+				onProgress: onProgress,
+				onError: onError
+
+			} );
+
 			var request = new XMLHttpRequest();
+
 			request.open( 'GET', url, true );
 
 			request.addEventListener( 'load', function ( event ) {
@@ -139,9 +170,18 @@ Object.assign( FileLoader.prototype, {
 
 				Cache.add( url, response );
 
+				var callbacks = loading[ url ];
+
+				delete loading[ url ];
+
 				if ( this.status === 200 ) {
 
-					if ( onLoad ) onLoad( response );
+					for ( var i = 0, il = callbacks.length; i < il; i ++ ) {
+
+						var callback = callbacks[ i ];
+						if ( callback.onLoad ) callback.onLoad( response );
+
+					}
 
 					scope.manager.itemEnd( url );
 
@@ -152,13 +192,23 @@ Object.assign( FileLoader.prototype, {
 
 					console.warn( 'THREE.FileLoader: HTTP Status 0 received.' );
 
-					if ( onLoad ) onLoad( response );
+					for ( var i = 0, il = callbacks.length; i < il; i ++ ) {
+
+						var callback = callbacks[ i ];
+						if ( callback.onLoad ) callback.onLoad( response );
+
+					}
 
 					scope.manager.itemEnd( url );
 
 				} else {
 
-					if ( onError ) onError( event );
+					for ( var i = 0, il = callbacks.length; i < il; i ++ ) {
+
+						var callback = callbacks[ i ];
+						if ( callback.onError ) callback.onError( event );
+
+					}
 
 					scope.manager.itemEnd( url );
 					scope.manager.itemError( url );
@@ -167,19 +217,29 @@ Object.assign( FileLoader.prototype, {
 
 			}, false );
 
-			if ( onProgress !== undefined ) {
+			request.addEventListener( 'progress', function ( event ) {
 
-				request.addEventListener( 'progress', function ( event ) {
+				var callbacks = loading[ url ];
 
-					onProgress( event );
+				for ( var i = 0, il = callbacks.length; i < il; i ++ ) {
 
-				}, false );
+					var callback = callbacks[ i ];
+					if ( callback.onProgress ) callback.onProgress( event );
 
-			}
+				}
+
+			}, false );
 
 			request.addEventListener( 'error', function ( event ) {
 
-				if ( onError ) onError( event );
+				var callbacks = loading[ url ];
+
+				for ( var i = 0, il = callbacks.length; i < il; i ++ ) {
+
+					var callback = callbacks[ i ];
+					if ( callback.onError ) callback.onError( event );
+
+				}
 
 				scope.manager.itemEnd( url );
 				scope.manager.itemError( url );

+ 3 - 3
src/renderers/WebGLRenderer.js

@@ -437,7 +437,7 @@ function WebGLRenderer( parameters ) {
 
 	// Clearing
 
-	this.getClearColor = function() {
+	this.getClearColor = function () {
 
 		return background.getClearColor();
 
@@ -449,13 +449,13 @@ function WebGLRenderer( parameters ) {
 
 	};
 
-	this.getClearAlpha = function() {
+	this.getClearAlpha = function () {
 
 		return background.getClearAlpha();
 
 	};
 
-	this.setClearAlpha = function() {
+	this.setClearAlpha = function () {
 
 		background.setClearAlpha.apply( background, arguments );
 

+ 43 - 14
test/unit/qunit-utils.js

@@ -243,33 +243,62 @@ function runStdGeometryTests( assert, geometries ) {
 //
 
 // Run common light tests.
-function runStdLightTests( assert, lights ) {
+function runStdLightTests( lights ) {
 
-	for ( var i = 0, l = lights.length; i < l; i++ ) {
+	for ( var i = 0, l = lights.length; i < l; i ++ ) {
 
-		var light = lights[i];
+		var light = lights[ i ];
 
-		// Clone
-		checkLightClone( light );
+		// copy and clone
+		checkLightCopyClone( light );
+
+		// THREE.Light doesn't get parsed by ObjectLoader as it's only
+		// used as an abstract base class - so we skip the JSON tests
+		if ( light.type !== "Light" ) {
+
+			// json round trip
+			checkLightJsonRoundtrip( light );
+
+		}
 
-		// json round trip
-		checkLightJsonRoundtrip( light );
 	}
 
 }
 
+function checkLightCopyClone( light ) {
 
-function checkLightClone( light ) {
+	// copy
+	var newLight = new light.constructor( 0xc0ffee );
+	newLight.copy( light );
+
+	QUnit.assert.notEqual( newLight.uuid, light.uuid, "Copied light's UUID differs from original" );
+	QUnit.assert.notEqual( newLight.id, light.id, "Copied light's id differs from original" );
+	QUnit.assert.smartEqual( newLight, light, "Copied light is equal to original" );
+
+	// real copy?
+	newLight.color.setHex( 0xc0ffee );
+	QUnit.assert.notStrictEqual(
+		newLight.color.getHex(), light.color.getHex(), "Copied light is independent from original"
+	);
 
 	// Clone
-	var copy = light.clone();
-	QUnit.assert.notEqual( copy.uuid, light.uuid, "clone uuid should differ from original" );
-	QUnit.assert.notEqual( copy.id, light.id, "clone id should differ from original" );
-	QUnit.assert.smartEqual( copy, light, "clone is equal to original" );
+	var clone = light.clone(); // better get a new var
+	QUnit.assert.notEqual( clone.uuid, light.uuid, "Cloned light's UUID differs from original" );
+	QUnit.assert.notEqual( clone.id, light.id, "Clone light's id differs from original" );
+	QUnit.assert.smartEqual( clone, light, "Clone light is equal to original" );
 
+	// real clone?
+	clone.color.setHex( 0xc0ffee );
+	QUnit.assert.notStrictEqual(
+		clone.color.getHex(), light.color.getHex(), "Clone light is independent from original"
+	);
 
-	// json round trip with clone
-	checkLightJsonRoundtrip( copy );
+	if ( light.type !== "Light" ) {
+
+		// json round trip with clone
+		checkLightJsonRoundtrip( clone );
+
+	}
 
 }
 

+ 0 - 6
test/unit/src/extras/curves/ArcCurve.js

@@ -1,6 +0,0 @@
-/**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
- */
-
-//Todo
-console.warn("Todo: Unit tests of ArcCurve")

+ 192 - 0
test/unit/src/extras/curves/CatmullRomCurve3.js

@@ -147,3 +147,195 @@ QUnit.test( "closed catmullrom basic check", function( assert ) {
 	} );
 
 } );
+
+
+//
+// curve.type = 'catmullrom'; only from here on
+//
+QUnit.test( "getLength/getLengths", function ( assert ) {
+
+	var curve = new THREE.CatmullRomCurve3( positions );
+	curve.type = 'catmullrom';
+
+	var length = curve.getLength();
+	var expectedLength = 551.549686276872;
+
+	assert.numEqual( length, expectedLength, "Correct length of curve" );
+
+	var expectedLengths = [
+		0,
+		120,
+		220,
+		416.9771560359221,
+		536.9771560359221
+	];
+	var lengths = curve.getLengths( expectedLengths.length - 1 );
+
+	assert.strictEqual( lengths.length, expectedLengths.length, "Correct number of segments" );
+
+	lengths.forEach( function ( segment, i ) {
+
+		assert.numEqual( segment, expectedLengths[ i ], "segment[" + i + "] correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getPointAt", function ( assert ) {
+
+	var curve = new THREE.CatmullRomCurve3( positions );
+	curve.type = 'catmullrom';
+
+	var expectedPoints = [
+		new THREE.Vector3( - 60, - 100, 60 ),
+		new THREE.Vector3( - 64.84177333183106, 64.86956465359813, 64.84177333183106 ),
+		new THREE.Vector3( - 28.288507045700854, 104.83101184518996, 28.288507045700854 ),
+		new THREE.Vector3( 60, - 100, - 60 )
+	];
+
+	var points = [
+		curve.getPointAt( 0 ),
+		curve.getPointAt( 0.3 ),
+		curve.getPointAt( 0.5 ),
+		curve.getPointAt( 1 )
+	];
+
+	assert.deepEqual( points, expectedPoints, "Correct points" );
+
+} );
+
+QUnit.test( "getTangent/getTangentAt", function ( assert ) {
+
+	var curve = new THREE.CatmullRomCurve3( positions );
+	curve.type = 'catmullrom';
+
+	var expectedTangents = [
+		new THREE.Vector3( 0, 1, 0 ),
+		new THREE.Vector3( - 0.0001090274561657922, 0.9999999881130137, 0.0001090274561657922 ),
+		new THREE.Vector3( 0.7071067811865475, - 2.0930381713877622e-13, - 0.7071067811865475 ),
+		new THREE.Vector3( 0.43189437062802816, - 0.7917919583070032, - 0.43189437062802816 ),
+		new THREE.Vector3( - 0.00019991333100812723, - 0.9999999600346592, 0.00019991333100812723 )
+	];
+
+	var tangents = [
+		curve.getTangent( 0 ),
+		curve.getTangent( 0.25 ),
+		curve.getTangent( 0.5 ),
+		curve.getTangent( 0.75 ),
+		curve.getTangent( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangent #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangent #" + i + ": y correct" );
+
+	} );
+
+	//
+
+	expectedTangents = [
+		new THREE.Vector3( 0, 1, 0 ),
+		new THREE.Vector3( - 0.10709018822205997, 0.9884651653817284, 0.10709018822205997 ),
+		new THREE.Vector3( 0.6396363672964268, - 0.4262987629159402, - 0.6396363672964268 ),
+		new THREE.Vector3( 0.5077298411616501, - 0.6960034603275557, - 0.5077298411616501 ),
+		new THREE.Vector3( - 0.00019991333100812723, - 0.9999999600346592, 0.00019991333100812723 )
+	];
+
+	tangents = [
+		curve.getTangentAt( 0 ),
+		curve.getTangentAt( 0.25 ),
+		curve.getTangentAt( 0.5 ),
+		curve.getTangentAt( 0.75 ),
+		curve.getTangentAt( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangentAt #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangentAt #" + i + ": y correct" );
+
+	} );
+
+} );
+
+QUnit.test( "computeFrenetFrames", function ( assert ) {
+
+	var curve = new THREE.CatmullRomCurve3( positions );
+	curve.type = 'catmullrom';
+
+	var expected = {
+		binormals: [
+			new THREE.Vector3( - 1, 0, 0 ),
+			new THREE.Vector3( - 0.28685061854203, 0.6396363672964267, - 0.7131493814579701 ),
+			new THREE.Vector3( - 1.9982670528160395e-8, - 0.0001999133310081272, - 0.9999999800173295 )
+		],
+		normals: [
+			new THREE.Vector3( 0, 0, - 1 ),
+			new THREE.Vector3( - 0.7131493814579699, - 0.6396363672964268, - 0.2868506185420297 ),
+			new THREE.Vector3( - 0.9999999800173294, 0.00019991333100810582, - 1.99826701852146e-8 )
+		],
+		tangents: [
+			new THREE.Vector3( 0, 1, 0 ),
+			new THREE.Vector3( 0.6396363672964269, - 0.4262987629159403, - 0.6396363672964269 ),
+			new THREE.Vector3( - 0.0001999133310081273, - 0.9999999600346594, 0.0001999133310081273 )
+		]
+	};
+
+	var frames = curve.computeFrenetFrames( 2, false );
+
+	Object.keys( expected ).forEach( function ( group, i ) {
+
+		expected[ group ].forEach( function ( vec, j ) {
+
+			assert.numEqual( frames[ group ][ j ].x, vec.x, "Frenet frames [" + i + ", " + j + "].x correct" );
+			assert.numEqual( frames[ group ][ j ].y, vec.y, "Frenet frames [" + i + ", " + j + "].y correct" );
+			assert.numEqual( frames[ group ][ j ].z, vec.z, "Frenet frames [" + i + ", " + j + "].z correct" );
+
+		} );
+
+	} );
+
+} );
+
+QUnit.test( "getUtoTmapping", function ( assert ) {
+
+	var curve = new THREE.CatmullRomCurve3( positions );
+	curve.type = 'catmullrom';
+
+	var start = curve.getUtoTmapping( 0, 0 );
+	var end = curve.getUtoTmapping( 0, curve.getLength() );
+	var somewhere = curve.getUtoTmapping( 0.5, 500 );
+
+	var expectedSomewhere = 0.8964116382083199;
+
+	assert.strictEqual( start, 0, "getUtoTmapping( 0, 0 ) is the starting point" );
+	assert.strictEqual( end, 1, "getUtoTmapping( 0, length ) is the ending point" );
+	assert.numEqual( somewhere, expectedSomewhere, "getUtoTmapping( 0.5, 500 ) is correct" );
+
+} );
+
+QUnit.test( "getSpacedPoints", function ( assert ) {
+
+	var curve = new THREE.CatmullRomCurve3( positions );
+	curve.type = 'catmullrom';
+
+	var expectedPoints = [
+		new THREE.Vector3( - 60, - 100, 60 ),
+		new THREE.Vector3( - 60, 10.311489426555056, 60 ),
+		new THREE.Vector3( - 65.05889864636504, 117.99691802595966, 65.05889864636504 ),
+		new THREE.Vector3( 6.054276900088592, 78.7153118386369, - 6.054276900088592 ),
+		new THREE.Vector3( 64.9991491385602, 8.386980812799566, - 64.9991491385602 ),
+		new THREE.Vector3( 60, - 100, - 60 )
+	];
+
+	var points = curve.getSpacedPoints();
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+} );

+ 189 - 3
test/unit/src/extras/curves/CubicBezierCurve.js

@@ -1,6 +1,192 @@
 /**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
+ * @author moraxy / https://github.com/moraxy
  */
 
-//Todo
-console.warn("Todo: Unit tests of CubicBezierCurve")
+QUnit.module( "CubicBezierCurve", {
+
+	before: function () {
+
+		// from the docs
+		this.curve = new THREE.CubicBezierCurve(
+			new THREE.Vector2( - 10, 0 ),
+			new THREE.Vector2( - 5, 15 ),
+			new THREE.Vector2( 20, 15 ),
+			new THREE.Vector2( 10, 0 )
+		);
+
+	}
+
+} );
+
+QUnit.test( "Simple curve", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( - 10, 0 ),
+		new THREE.Vector2( - 3.359375, 8.4375 ),
+		new THREE.Vector2( 5.625, 11.25 ),
+		new THREE.Vector2( 11.796875, 8.4375 ),
+		new THREE.Vector2( 10, 0 )
+	];
+
+	var points = curve.getPoints( expectedPoints.length - 1 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+	// symmetry
+	var curveRev = new THREE.CubicBezierCurve(
+		curve.v3, curve.v2, curve.v1, curve.v0
+	);
+
+	points = curveRev.getPoints( expectedPoints.length - 1 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Reversed: Correct number of points" );
+	assert.deepEqual( points, expectedPoints.reverse(), "Reversed: Correct points curve" );
+
+} );
+
+QUnit.test( "getLength/getLengths", function ( assert ) {
+
+	var curve = this.curve;
+
+	var length = curve.getLength();
+	var expectedLength = 36.64630888504102;
+
+	assert.numEqual( length, expectedLength, "Correct length of curve" );
+
+	var expectedLengths = [
+		0,
+		10.737285813492393,
+		20.15159143794633,
+		26.93408340370825,
+		35.56079575637337
+	];
+	var lengths = curve.getLengths( expectedLengths.length - 1 );
+
+	assert.strictEqual( lengths.length, expectedLengths.length, "Correct number of segments" );
+
+	lengths.forEach( function ( segment, i ) {
+
+		assert.numEqual( segment, expectedLengths[ i ], "segment[" + i + "] correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getPointAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( - 10, 0 ),
+		new THREE.Vector2( - 3.3188282598022596, 8.463722639089221 ),
+		new THREE.Vector2( 3.4718554735926617, 11.07899406116314 ),
+		new THREE.Vector2( 10, 0 )
+	];
+
+	var points = [
+		curve.getPointAt( 0 ),
+		curve.getPointAt( 0.3 ),
+		curve.getPointAt( 0.5 ),
+		curve.getPointAt( 1 )
+	];
+
+	assert.deepEqual( points, expectedPoints, "Correct points" );
+
+} );
+
+QUnit.test( "getTangent/getTangentAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedTangents = [
+		new THREE.Vector2( 0.316370061632252, 0.9486358543207215 ),
+		new THREE.Vector2( 0.838961283088303, 0.5441911111721949 ),
+		new THREE.Vector2( 1, 0 ),
+		new THREE.Vector2( 0.47628313192245453, - 0.8792919755383518 ),
+		new THREE.Vector2( - 0.5546041767829665, - 0.8321142992972107 )
+	];
+
+	var tangents = [
+		curve.getTangent( 0 ),
+		curve.getTangent( 0.25 ),
+		curve.getTangent( 0.5 ),
+		curve.getTangent( 0.75 ),
+		curve.getTangent( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangent #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangent #" + i + ": y correct" );
+
+	} );
+
+	//
+
+	expectedTangents = [
+		new THREE.Vector2( 0.316370061632252, 0.9486358543207215 ),
+		new THREE.Vector2( 0.7794223085548987, 0.6264988945935596 ),
+		new THREE.Vector2( 0.988266153082452, 0.15274164681452052 ),
+		new THREE.Vector2( 0.5004110404199416, - 0.8657879593906534 ),
+		new THREE.Vector2( - 0.5546041767829665, - 0.8321142992972107 )
+	];
+
+	tangents = [
+		curve.getTangentAt( 0 ),
+		curve.getTangentAt( 0.25 ),
+		curve.getTangentAt( 0.5 ),
+		curve.getTangentAt( 0.75 ),
+		curve.getTangentAt( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangentAt #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangentAt #" + i + ": y correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getUtoTmapping", function ( assert ) {
+
+	var curve = this.curve;
+
+	var start = curve.getUtoTmapping( 0, 0 );
+	var end = curve.getUtoTmapping( 0, curve.getLength() );
+	var somewhere = curve.getUtoTmapping( 0.5, 1 );
+
+	var expectedSomewhere = 0.02130029182257093;
+
+	assert.strictEqual( start, 0, "getUtoTmapping( 0, 0 ) is the starting point" );
+	assert.strictEqual( end, 1, "getUtoTmapping( 0, length ) is the ending point" );
+	assert.numEqual( somewhere, expectedSomewhere, "getUtoTmapping( 0.5, 1 ) is correct" );
+
+} );
+
+QUnit.test( "getSpacedPoints", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( - 10, 0 ),
+		new THREE.Vector2( - 6.16826457740703, 6.17025727295411 ),
+		new THREE.Vector2( - 0.058874033259857184, 10.1240558653185 ),
+		new THREE.Vector2( 7.123523032625162, 11.154913869041575 ),
+		new THREE.Vector2( 12.301846885754463, 6.808865855469985 ),
+		new THREE.Vector2( 10, 0 )
+	];
+
+	var points = curve.getSpacedPoints();
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+} );

+ 227 - 3
test/unit/src/extras/curves/CubicBezierCurve3.js

@@ -1,6 +1,230 @@
 /**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
+ * @author moraxy / https://github.com/moraxy
  */
 
-//Todo
-console.warn("Todo: Unit tests of CubicBezierCurve3")
+QUnit.module( "CubicBezierCurve3", {
+
+	before: function () {
+
+		// modified from the docs
+		this.curve = new THREE.CubicBezierCurve3(
+			new THREE.Vector3( - 10, 0, 2 ),
+			new THREE.Vector3( - 5, 15, 4 ),
+			new THREE.Vector3( 20, 15, - 5 ),
+			new THREE.Vector3( 10, 0, 10 )
+		);
+
+	}
+
+} );
+
+QUnit.test( "Simple curve", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector3( - 10, 0, 2 ),
+		new THREE.Vector3( - 3.359375, 8.4375, 1.984375 ),
+		new THREE.Vector3( 5.625, 11.25, 1.125 ),
+		new THREE.Vector3( 11.796875, 8.4375, 2.703125 ),
+		new THREE.Vector3( 10, 0, 10 )
+	];
+
+	var points = curve.getPoints( expectedPoints.length - 1 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+	// symmetry
+	var curveRev = new THREE.CubicBezierCurve3(
+		curve.v3, curve.v2, curve.v1, curve.v0
+	);
+
+	points = curveRev.getPoints( expectedPoints.length - 1 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Reversed: Correct number of points" );
+	assert.deepEqual( points, expectedPoints.reverse(), "Reversed: Correct points curve" );
+
+} );
+
+QUnit.test( "getLength/getLengths", function ( assert ) {
+
+	var curve = this.curve;
+
+	var length = curve.getLength();
+	var expectedLength = 39.58103024989427;
+
+	assert.numEqual( length, expectedLength, "Correct length of curve" );
+
+	var expectedLengths = [
+		0,
+		10.73729718231036,
+		20.19074500737662,
+		27.154413277853756,
+		38.453287150114214
+	];
+	var lengths = curve.getLengths( expectedLengths.length - 1 );
+
+	assert.strictEqual( lengths.length, expectedLengths.length, "Correct number of segments" );
+
+	lengths.forEach( function ( segment, i ) {
+
+		assert.numEqual( segment, expectedLengths[ i ], "segment[" + i + "] correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getPointAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector3( - 10, 0, 2 ),
+		new THREE.Vector3( - 2.591880240484318, 8.908333501170798, 1.8953420625251136 ),
+		new THREE.Vector3( 4.866251460832755, 11.22787914038507, 1.150832855206874 ),
+		new THREE.Vector3( 10, 0, 10 )
+	];
+
+	var points = [
+		curve.getPointAt( 0 ),
+		curve.getPointAt( 0.3 ),
+		curve.getPointAt( 0.5 ),
+		curve.getPointAt( 1 )
+	];
+
+	assert.deepEqual( points, expectedPoints, "Correct points" );
+
+} );
+
+QUnit.test( "getTangent/getTangentAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedTangents = [
+		new THREE.Vector3( 0.3138715439944244, 0.9411440474105875, 0.12542940601858074 ),
+		new THREE.Vector3( 0.8351825262580098, 0.54174002562179, - 0.09480449605683638 ),
+		new THREE.Vector3( 0.9997531780538501, 0, - 0.02221672728433752 ),
+		new THREE.Vector3( 0.40693407933981185, - 0.7512629496079668, 0.5196235518317053 ),
+		new THREE.Vector3( - 0.42632467075185815, - 0.6396469221230213, 0.6396085444448543 )
+	];
+
+	var tangents = [
+		curve.getTangent( 0 ),
+		curve.getTangent( 0.25 ),
+		curve.getTangent( 0.5 ),
+		curve.getTangent( 0.75 ),
+		curve.getTangent( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangent #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangent #" + i + ": y correct" );
+
+	} );
+
+	//
+
+	expectedTangents = [
+		new THREE.Vector3( 0.3138715439944244, 0.9411440474105875, 0.12542940601858074 ),
+		new THREE.Vector3( 0.8016539573770751, 0.5918626760037707, - 0.08396133262002324 ),
+		new THREE.Vector3( 0.997337559412928, 0.05740742907719314, - 0.044968652092444425 ),
+		new THREE.Vector3( 0.1389373097746809, - 0.7882209938358005, 0.5995032016837588 ),
+		new THREE.Vector3( - 0.42632467075185815, - 0.6396469221230213, 0.6396085444448543 )
+	];
+
+	tangents = [
+		curve.getTangentAt( 0 ),
+		curve.getTangentAt( 0.25 ),
+		curve.getTangentAt( 0.5 ),
+		curve.getTangentAt( 0.75 ),
+		curve.getTangentAt( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangentAt #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangentAt #" + i + ": y correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getUtoTmapping", function ( assert ) {
+
+	var curve = this.curve;
+
+	var start = curve.getUtoTmapping( 0, 0 );
+	var end = curve.getUtoTmapping( 0, curve.getLength() );
+	var somewhere = curve.getUtoTmapping( 0.5, 1 );
+
+	var expectedSomewhere = 0.021163245321323316;
+
+	assert.strictEqual( start, 0, "getUtoTmapping( 0, 0 ) is the starting point" );
+	assert.strictEqual( end, 1, "getUtoTmapping( 0, length ) is the ending point" );
+	assert.numEqual( somewhere, expectedSomewhere, "getUtoTmapping( 0.5, 1 ) is correct" );
+
+} );
+
+QUnit.test( "getSpacedPoints", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector3( - 10, 0, 2 ),
+		new THREE.Vector3( - 5.756524515061918, 6.568020242700483, 2.22116711170301 ),
+		new THREE.Vector3( 1.0003511895116906, 10.49656064587831, 1.4727101010850698 ),
+		new THREE.Vector3( 8.767656412295171, 10.784286845278622, 1.2873599519775174 ),
+		new THREE.Vector3( 12.306772513558396, 5.545103788071547, 4.909948454535794 ),
+		new THREE.Vector3( 10, 0, 10 )
+	];
+
+	var points = curve.getSpacedPoints();
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+} );
+
+QUnit.test( "computeFrenetFrames", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expected = {
+		binormals: [
+			new THREE.Vector3( - 0.9486358543207215, 0.316370061632252, - 6.938893903907228e-18 ),
+			new THREE.Vector3( - 0.05491430765311864, 0.9969838307670049, 0.054842137122173326 ),
+			new THREE.Vector3( 0.5944656510461876, 0.334836503700931, 0.7310917216844742 )
+		],
+		normals: [
+			new THREE.Vector3( 0.03968210891259515, 0.11898683173537697, - 0.9921025471723304 ),
+			new THREE.Vector3( - 0.047981365124836806, 0.05222670079466692, - 0.9974819097732357 ),
+			new THREE.Vector3( 0.6818048583242511, - 0.6919077473246573, - 0.23749906180354932 )
+		],
+		tangents: [
+			new THREE.Vector3( 0.3138715439944244, 0.9411440474105875, 0.12542940601858074 ),
+			new THREE.Vector3( 0.9973375594129282, 0.05740742907719315, - 0.04496865209244443 ),
+			new THREE.Vector3( - 0.42632467075185815, - 0.6396469221230213, 0.6396085444448543 )
+		]
+	};
+
+	var frames = curve.computeFrenetFrames( 2, false );
+
+	Object.keys( expected ).forEach( function ( group, i ) {
+
+		expected[ group ].forEach( function ( vec, j ) {
+
+			assert.numEqual( frames[ group ][ j ].x, vec.x, "Frenet frames [" + i + ", " + j + "].x correct" );
+			assert.numEqual( frames[ group ][ j ].y, vec.y, "Frenet frames [" + i + ", " + j + "].y correct" );
+			assert.numEqual( frames[ group ][ j ].z, vec.z, "Frenet frames [" + i + ", " + j + "].z correct" );
+
+		} );
+
+	} );
+
+} );

+ 170 - 3
test/unit/src/extras/curves/EllipseCurve.js

@@ -1,6 +1,173 @@
 /**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
+ * @author moraxy / https://github.com/moraxy
  */
 
-//Todo
-console.warn("Todo: Unit tests of EllipseCurve")
+QUnit.module( "EllipseCurve", {
+
+	before: function () {
+
+		// from the docs
+		this.curve = new THREE.EllipseCurve(
+			0, 0, // ax, aY
+			10, 10, // xRadius, yRadius
+			0, 2 * Math.PI, // aStartAngle, aEndAngle
+			false, // aClockwise
+			0 // aRotation
+		);
+
+	}
+
+} );
+
+QUnit.test( "Simple curve", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( 10, 0 ),
+		new THREE.Vector2( 0, 10 ),
+		new THREE.Vector2( - 10, 0 ),
+		new THREE.Vector2( 0, - 10 ),
+		new THREE.Vector2( 10, 0 )
+	];
+
+	var points = curve.getPoints( expectedPoints.length - 1 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+
+	points.forEach( function ( point, i ) {
+
+		assert.numEqual( point.x, expectedPoints[ i ].x, "point[" + i + "].x correct" );
+		assert.numEqual( point.y, expectedPoints[ i ].y, "point[" + i + "].y correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getLength/getLengths", function ( assert ) {
+
+	var curve = this.curve;
+
+	var length = curve.getLength();
+	var expectedLength = 62.829269247282795;
+
+	assert.numEqual( length, expectedLength, "Correct length of curve" );
+
+	var lengths = curve.getLengths( 5 );
+	var expectedLengths = [
+		0,
+		11.755705045849462,
+		23.51141009169892,
+		35.26711513754839,
+		47.02282018339785,
+		58.77852522924731
+	];
+
+	assert.strictEqual( lengths.length, expectedLengths.length, "Correct number of segments" );
+
+	lengths.forEach( function ( segment, i ) {
+
+		assert.numEqual( segment, expectedLengths[ i ], "segment[" + i + "] correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getPoint/getPointAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var testValues = [ 0, 0.3, 0.5, 0.7, 1 ];
+
+	testValues.forEach( function ( val, i ) {
+
+		var expectedX = Math.cos( val * Math.PI * 2 ) * 10;
+		var expectedY = Math.sin( val * Math.PI * 2 ) * 10;
+
+		var p = curve.getPoint( val );
+		var a = curve.getPointAt( val );
+
+		assert.numEqual( p.x, expectedX, "getPoint(" + val + ").x correct" );
+		assert.numEqual( p.y, expectedY, "getPoint(" + val + ").y correct" );
+
+		assert.numEqual( a.x, expectedX, "getPointAt(" + val + ").x correct" );
+		assert.numEqual( a.y, expectedY, "getPointAt(" + val + ").y correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getTangent", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedTangents = [
+		new THREE.Vector2( - 0.000314159260186071, 0.9999999506519786 ),
+		new THREE.Vector2( - 1, 0 ),
+		new THREE.Vector2( 0, - 1 ),
+		new THREE.Vector2( 1, 0 ),
+		new THREE.Vector2( 0.00031415926018600165, 0.9999999506519784 )
+	];
+
+	var tangents = [
+		curve.getTangent( 0 ),
+		curve.getTangent( 0.25 ),
+		curve.getTangent( 0.5 ),
+		curve.getTangent( 0.75 ),
+		curve.getTangent( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangent #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangent #" + i + ": y correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getUtoTmapping", function ( assert ) {
+
+	var curve = this.curve;
+
+	var start = curve.getUtoTmapping( 0, 0 );
+	var end = curve.getUtoTmapping( 0, curve.getLength() );
+	var somewhere = curve.getUtoTmapping( 0.7, 1 );
+
+	var expectedSomewhere = 0.01591614882650014;
+
+	assert.strictEqual( start, 0, "getUtoTmapping( 0, 0 ) is the starting point" );
+	assert.strictEqual( end, 1, "getUtoTmapping( 0, length ) is the ending point" );
+	assert.numEqual( somewhere, expectedSomewhere, "getUtoTmapping( 0.7, 1 ) is correct" );
+
+} );
+
+QUnit.test( "getSpacedPoints", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( 10, 0 ),
+		new THREE.Vector2( 3.0901699437494603, 9.51056516295154 ),
+		new THREE.Vector2( - 8.090169943749492, 5.877852522924707 ),
+		new THREE.Vector2( - 8.090169943749459, - 5.877852522924751 ),
+		new THREE.Vector2( 3.0901699437494807, - 9.510565162951533 ),
+		new THREE.Vector2( 10, - 2.4492935982947065e-15 )
+	];
+
+	var points = curve.getSpacedPoints();
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+
+	expectedPoints.forEach( function ( exp, i ) {
+
+		var point = points[ i ];
+
+		assert.numEqual( point.x, exp.x, "Point #" + i + ": x correct" );
+		assert.numEqual( point.y, exp.y, "Point #" + i + ": y correct" );
+
+	} );
+
+} );

+ 149 - 3
test/unit/src/extras/curves/LineCurve.js

@@ -1,6 +1,152 @@
 /**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
+ * @author moraxy / https://github.com/moraxy
  */
 
-//Todo
-console.warn("Todo: Unit tests of LineCurve")
+QUnit.module( "LineCurve", {
+
+	before: function () {
+
+		this.points = [
+			new THREE.Vector2( 0, 0 ),
+			new THREE.Vector2( 10, 10 ),
+			new THREE.Vector2( - 10, 10 ),
+			new THREE.Vector2( - 8, 5 )
+		];
+
+		this.curve = new THREE.LineCurve( this.points[ 0 ], this.points[ 1 ] );
+
+	}
+
+} );
+
+QUnit.test( "Simple curve", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( 0, 0 ),
+		new THREE.Vector2( 2, 2 ),
+		new THREE.Vector2( 4, 4 ),
+		new THREE.Vector2( 6, 6 ),
+		new THREE.Vector2( 8, 8 ),
+		new THREE.Vector2( 10, 10 )
+	];
+
+	var points = curve.getPoints();
+
+	assert.deepEqual( points, expectedPoints, "Correct points for first curve" );
+
+	//
+
+	curve = new THREE.LineCurve( this.points[ 1 ], this.points[ 2 ] );
+
+	expectedPoints = [
+		new THREE.Vector2( 10, 10 ),
+		new THREE.Vector2( 6, 10 ),
+		new THREE.Vector2( 2, 10 ),
+		new THREE.Vector2( - 2, 10 ),
+		new THREE.Vector2( - 6, 10 ),
+		new THREE.Vector2( - 10, 10 )
+	];
+
+	points = curve.getPoints();
+
+	assert.deepEqual( points, expectedPoints, "Correct points for second curve" );
+
+} );
+
+QUnit.test( "getLength/getLengths", function ( assert ) {
+
+	var curve = this.curve;
+
+	var length = curve.getLength();
+	var expectedLength = Math.sqrt( 200 );
+
+	assert.numEqual( length, expectedLength, "Correct length of curve" );
+
+	var lengths = curve.getLengths( 5 );
+	var expectedLengths = [
+		0.0,
+		Math.sqrt( 8 ),
+		Math.sqrt( 32 ),
+		Math.sqrt( 72 ),
+		Math.sqrt( 128 ),
+		Math.sqrt( 200 )
+	];
+
+	assert.strictEqual( lengths.length, expectedLengths.length, "Correct number of segments" );
+
+	lengths.forEach( function ( segment, i ) {
+
+		assert.numEqual( segment, expectedLengths[ i ], "segment[" + i + "] correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getPointAt", function ( assert ) {
+
+	var curve = new THREE.LineCurve( this.points[ 0 ], this.points[ 3 ] );
+
+	var expectedPoints = [
+		new THREE.Vector2( 0, 0 ),
+		new THREE.Vector2( - 2.4, 1.5 ),
+		new THREE.Vector2( - 4, 2.5 ),
+		new THREE.Vector2( - 8, 5 )
+	];
+
+	var points = [
+		curve.getPointAt( 0 ),
+		curve.getPointAt( 0.3 ),
+		curve.getPointAt( 0.5 ),
+		curve.getPointAt( 1 )
+	];
+
+	assert.deepEqual( points, expectedPoints, "Correct points" );
+
+} );
+
+QUnit.test( "getTangent", function ( assert ) {
+
+	var curve = this.curve;
+
+	var tangent = curve.getTangent( 0 );
+	var expectedTangent = Math.sqrt( 0.5 );
+
+	assert.numEqual( tangent.x, expectedTangent, "tangent.x correct" );
+	assert.numEqual( tangent.y, expectedTangent, "tangent.y correct" );
+
+} );
+
+QUnit.test( "getUtoTmapping", function ( assert ) {
+
+	var curve = this.curve;
+
+	var start = curve.getUtoTmapping( 0, 0 );
+	var end = curve.getUtoTmapping( 0, curve.getLength() );
+	var somewhere = curve.getUtoTmapping( 0.3, 0 );
+
+	assert.strictEqual( start, 0, "getUtoTmapping( 0, 0 ) is the starting point" );
+	assert.strictEqual( end, 1, "getUtoTmapping( 0, length ) is the ending point" );
+	assert.numEqual( somewhere, 0.3, "getUtoTmapping( 0.3, 0 ) is correct" );
+
+} );
+
+QUnit.test( "getSpacedPoints", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( 0, 0 ),
+		new THREE.Vector2( 2.5, 2.5 ),
+		new THREE.Vector2( 5, 5 ),
+		new THREE.Vector2( 7.5, 7.5 ),
+		new THREE.Vector2( 10, 10 )
+	];
+
+	var points = curve.getSpacedPoints( 4 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+} );

+ 178 - 3
test/unit/src/extras/curves/LineCurve3.js

@@ -1,6 +1,181 @@
 /**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
+ * @author moraxy / https://github.com/moraxy
  */
 
-//Todo
-console.warn("Todo: Unit tests of LineCurve3")
+QUnit.module( "LineCurve3", {
+
+	before: function () {
+
+		this.points = [
+			new THREE.Vector3( 0, 0, 0 ),
+			new THREE.Vector3( 10, 10, 10 ),
+			new THREE.Vector3( - 10, 10, - 10 ),
+			new THREE.Vector3( - 8, 5, - 7 )
+		];
+
+		this.curve = new THREE.LineCurve3( this.points[ 0 ], this.points[ 1 ] );
+
+	}
+
+} );
+
+QUnit.test( "Simple curve", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector3( 0, 0, 0 ),
+		new THREE.Vector3( 2, 2, 2 ),
+		new THREE.Vector3( 4, 4, 4 ),
+		new THREE.Vector3( 6, 6, 6 ),
+		new THREE.Vector3( 8, 8, 8 ),
+		new THREE.Vector3( 10, 10, 10 )
+	];
+
+	var points = curve.getPoints();
+
+	assert.deepEqual( points, expectedPoints, "Correct points for first curve" );
+
+	//
+
+	curve = new THREE.LineCurve3( this.points[ 1 ], this.points[ 2 ] );
+
+	expectedPoints = [
+		new THREE.Vector3( 10, 10, 10 ),
+		new THREE.Vector3( 6, 10, 6 ),
+		new THREE.Vector3( 2, 10, 2 ),
+		new THREE.Vector3( - 2, 10, - 2 ),
+		new THREE.Vector3( - 6, 10, - 6 ),
+		new THREE.Vector3( - 10, 10, - 10 )
+	];
+
+	points = curve.getPoints();
+
+	assert.deepEqual( points, expectedPoints, "Correct points for second curve" );
+
+} );
+
+QUnit.test( "getLength/getLengths", function ( assert ) {
+
+	var curve = this.curve;
+
+	var length = curve.getLength();
+	var expectedLength = Math.sqrt( 300 );
+
+	assert.numEqual( length, expectedLength, "Correct length of curve" );
+
+	var lengths = curve.getLengths( 5 );
+	var expectedLengths = [
+		0.0,
+		Math.sqrt( 12 ),
+		Math.sqrt( 48 ),
+		Math.sqrt( 108 ),
+		Math.sqrt( 192 ),
+		Math.sqrt( 300 )
+	];
+
+	assert.strictEqual( lengths.length, expectedLengths.length, "Correct number of segments" );
+
+	lengths.forEach( function ( segment, i ) {
+
+		assert.numEqual( segment, expectedLengths[ i ], "segment[" + i + "] correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getPointAt", function ( assert ) {
+
+	var curve = new THREE.LineCurve3( this.points[ 0 ], this.points[ 3 ] );
+
+	var expectedPoints = [
+		new THREE.Vector3( 0, 0, 0 ),
+		new THREE.Vector3( - 2.4, 1.5, - 2.1 ),
+		new THREE.Vector3( - 4, 2.5, - 3.5 ),
+		new THREE.Vector3( - 8, 5, - 7 )
+	];
+
+	var points = [
+		curve.getPointAt( 0 ),
+		curve.getPointAt( 0.3 ),
+		curve.getPointAt( 0.5 ),
+		curve.getPointAt( 1 )
+	];
+
+	assert.deepEqual( points, expectedPoints, "Correct getPointAt points" );
+
+} );
+
+QUnit.test( "getTangent/getTangentAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var tangent = curve.getTangent( 0.5 );
+	var expectedTangent = Math.sqrt( 1 / 3 );
+
+	assert.numEqual( tangent.x, expectedTangent, "tangent.x correct" );
+	assert.numEqual( tangent.y, expectedTangent, "tangent.y correct" );
+	assert.numEqual( tangent.z, expectedTangent, "tangent.z correct" );
+
+	tangent = curve.getTangentAt( 0.5 );
+
+	assert.numEqual( tangent.x, expectedTangent, "tangentAt.x correct" );
+	assert.numEqual( tangent.y, expectedTangent, "tangentAt.y correct" );
+	assert.numEqual( tangent.z, expectedTangent, "tangentAt.z correct" );
+
+} );
+
+QUnit.test( "computeFrenetFrames", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expected = {
+		binormals: new THREE.Vector3( - 0.5 * Math.sqrt( 2 ), 0.5 * Math.sqrt( 2 ), 0 ),
+		normals: new THREE.Vector3( Math.sqrt( 1 / 6 ), Math.sqrt( 1 / 6 ), - Math.sqrt( 2 / 3 ) ),
+		tangents: new THREE.Vector3( Math.sqrt( 1 / 3 ), Math.sqrt( 1 / 3 ), Math.sqrt( 1 / 3 ) )
+	};
+
+	var frames = curve.computeFrenetFrames( 1, false );
+
+	for ( var val in expected ) {
+
+		assert.numEqual( frames[ val ][ 0 ].x, expected[ val ].x, "Frenet frames " + val + ".x correct" );
+		assert.numEqual( frames[ val ][ 0 ].y, expected[ val ].y, "Frenet frames " + val + ".y correct" );
+		assert.numEqual( frames[ val ][ 0 ].z, expected[ val ].z, "Frenet frames " + val + ".z correct" );
+
+	}
+
+} );
+
+QUnit.test( "getUtoTmapping", function ( assert ) {
+
+	var curve = this.curve;
+
+	var start = curve.getUtoTmapping( 0, 0 );
+	var end = curve.getUtoTmapping( 0, curve.getLength() );
+	var somewhere = curve.getUtoTmapping( 0.7, 0 );
+
+	assert.strictEqual( start, 0, "getUtoTmapping( 0, 0 ) is the starting point" );
+	assert.strictEqual( end, 1, "getUtoTmapping( 0, length ) is the ending point" );
+	assert.numEqual( somewhere, 0.7, "getUtoTmapping( 0.7, 0 ) is correct" );
+
+} );
+
+QUnit.test( "getSpacedPoints", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector3( 0, 0, 0 ),
+		new THREE.Vector3( 2.5, 2.5, 2.5 ),
+		new THREE.Vector3( 5, 5, 5 ),
+		new THREE.Vector3( 7.5, 7.5, 7.5 ),
+		new THREE.Vector3( 10, 10, 10 )
+	];
+
+	var points = curve.getSpacedPoints( 4 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+} );

+ 188 - 3
test/unit/src/extras/curves/QuadraticBezierCurve.js

@@ -1,6 +1,191 @@
 /**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
+ * @author moraxy / https://github.com/moraxy
  */
 
-//Todo
-console.warn("Todo: Unit tests of QuadraticBezierCurve")
+QUnit.module( "QuadraticBezierCurve", {
+
+	before: function () {
+
+		// from the docs
+		this.curve = new THREE.QuadraticBezierCurve(
+			new THREE.Vector2( - 10, 0 ),
+			new THREE.Vector2( 20, 15 ),
+			new THREE.Vector2( 10, 0 )
+		);
+
+	}
+
+} );
+
+QUnit.test( "Simple curve", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( - 10, 0 ),
+		new THREE.Vector2( 2.5, 5.625 ),
+		new THREE.Vector2( 10, 7.5 ),
+		new THREE.Vector2( 12.5, 5.625 ),
+		new THREE.Vector2( 10, 0 )
+	];
+
+	var points = curve.getPoints( expectedPoints.length - 1 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+	// symmetry
+	var curveRev = new THREE.QuadraticBezierCurve(
+		curve.v2, curve.v1, curve.v0
+	);
+
+	points = curveRev.getPoints( expectedPoints.length - 1 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Reversed: Correct number of points" );
+	assert.deepEqual( points, expectedPoints.reverse(), "Reversed: Correct points curve" );
+
+} );
+
+QUnit.test( "getLength/getLengths", function ( assert ) {
+
+	var curve = this.curve;
+
+	var length = curve.getLength();
+	var expectedLength = 31.269026549416683;
+
+	assert.numEqual( length, expectedLength, "Correct length of curve" );
+
+	var expectedLengths = [
+		0,
+		13.707320124663317,
+		21.43814317269643,
+		24.56314317269643,
+		30.718679298818998
+	];
+	var lengths = curve.getLengths( expectedLengths.length - 1 );
+
+	assert.strictEqual( lengths.length, expectedLengths.length, "Correct number of segments" );
+
+	lengths.forEach( function ( segment, i ) {
+
+		assert.numEqual( segment, expectedLengths[ i ], "segment[" + i + "] correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getPointAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( - 10, 0 ),
+		new THREE.Vector2( - 1.5127849599387615, 3.993582003773624 ),
+		new THREE.Vector2( 4.310076165722796, 6.269921971403917 ),
+		new THREE.Vector2( 10, 0 )
+	];
+
+	var points = [
+		curve.getPointAt( 0 ),
+		curve.getPointAt( 0.3 ),
+		curve.getPointAt( 0.5 ),
+		curve.getPointAt( 1 )
+	];
+
+	assert.deepEqual( points, expectedPoints, "Correct points" );
+
+} );
+
+QUnit.test( "getTangent/getTangentAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedTangents = [
+		new THREE.Vector2( 0.89443315420562, 0.44720166888975904 ),
+		new THREE.Vector2( 0.936329177569021, 0.3511234415884543 ),
+		new THREE.Vector2( 1, 0 ),
+		new THREE.Vector2( - 5.921189464667277e-13, - 1 ),
+		new THREE.Vector2( - 0.5546617882904897, - 0.8320758983472577 )
+	];
+
+	var tangents = [
+		curve.getTangent( 0 ),
+		curve.getTangent( 0.25 ),
+		curve.getTangent( 0.5 ),
+		curve.getTangent( 0.75 ),
+		curve.getTangent( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangent #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangent #" + i + ": y correct" );
+
+	} );
+
+	//
+
+	expectedTangents = [
+		new THREE.Vector2( 0.89443315420562, 0.44720166888975904 ),
+		new THREE.Vector2( 0.9125211423360805, 0.40902954024086674 ),
+		new THREE.Vector2( 0.9480289098765387, 0.3181842014278863 ),
+		new THREE.Vector2( 0.7969127189169473, - 0.6040944615111106 ),
+		new THREE.Vector2( - 0.5546617882904897, - 0.8320758983472577 )
+	];
+
+	tangents = [
+		curve.getTangentAt( 0 ),
+		curve.getTangentAt( 0.25 ),
+		curve.getTangentAt( 0.5 ),
+		curve.getTangentAt( 0.75 ),
+		curve.getTangentAt( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangentAt #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangentAt #" + i + ": y correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getUtoTmapping", function ( assert ) {
+
+	var curve = this.curve;
+
+	var start = curve.getUtoTmapping( 0, 0 );
+	var end = curve.getUtoTmapping( 0, curve.getLength() );
+	var somewhere = curve.getUtoTmapping( 0.5, 1 );
+
+	var expectedSomewhere = 0.015073978276116116;
+
+	assert.strictEqual( start, 0, "getUtoTmapping( 0, 0 ) is the starting point" );
+	assert.strictEqual( end, 1, "getUtoTmapping( 0, length ) is the ending point" );
+	assert.numEqual( somewhere, expectedSomewhere, "getUtoTmapping( 0.5, 1 ) is correct" );
+
+} );
+
+QUnit.test( "getSpacedPoints", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( - 10, 0 ),
+		new THREE.Vector2( - 4.366603655406173, 2.715408933540383 ),
+		new THREE.Vector2( 1.3752241477827831, 5.191972084404416 ),
+		new THREE.Vector2( 7.312990279153634, 7.136310044848586 ),
+		new THREE.Vector2( 12.499856644824826, 5.653289188715387 ),
+		new THREE.Vector2( 10, 0 )
+	];
+
+	var points = curve.getSpacedPoints();
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+} );

+ 226 - 3
test/unit/src/extras/curves/QuadraticBezierCurve3.js

@@ -1,6 +1,229 @@
 /**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
+ * @author moraxy / https://github.com/moraxy
  */
 
-//Todo
-console.warn("Todo: Unit tests of QuadraticBezierCurve")
+QUnit.module( "QuadraticBezierCurve3", {
+
+	before: function () {
+
+		// modified from the docs
+		this.curve = new THREE.QuadraticBezierCurve3(
+			new THREE.Vector3( - 10, 0, 2 ),
+			new THREE.Vector3( 20, 15, - 5 ),
+			new THREE.Vector3( 10, 0, 10 )
+		);
+
+	}
+
+} );
+
+QUnit.test( "Simple curve", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector3( - 10, 0, 2 ),
+		new THREE.Vector3( 2.5, 5.625, - 0.125 ),
+		new THREE.Vector3( 10, 7.5, 0.5 ),
+		new THREE.Vector3( 12.5, 5.625, 3.875 ),
+		new THREE.Vector3( 10, 0, 10 )
+	];
+
+	var points = curve.getPoints( expectedPoints.length - 1 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+	// symmetry
+	var curveRev = new THREE.QuadraticBezierCurve3(
+		curve.v2, curve.v1, curve.v0
+	);
+
+	points = curveRev.getPoints( expectedPoints.length - 1 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Reversed: Correct number of points" );
+	assert.deepEqual( points, expectedPoints.reverse(), "Reversed: Correct points curve" );
+
+} );
+
+QUnit.test( "getLength/getLengths", function ( assert ) {
+
+	var curve = this.curve;
+
+	var length = curve.getLength();
+	var expectedLength = 35.47294274967861;
+
+	assert.numEqual( length, expectedLength, "Correct length of curve" );
+
+	var expectedLengths = [
+		0,
+		13.871057998581074,
+		21.62710402732536,
+		26.226696400568883,
+		34.91037361704809
+	];
+	var lengths = curve.getLengths( expectedLengths.length - 1 );
+
+	assert.strictEqual( lengths.length, expectedLengths.length, "Correct number of segments" );
+
+	lengths.forEach( function ( segment, i ) {
+
+		assert.numEqual( segment, expectedLengths[ i ], "segment[" + i + "] correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getPointAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector3( - 10, 0, 2 ),
+		new THREE.Vector3( - 0.4981634504454243, 4.427089043881476, 0.19308849757196012 ),
+		new THREE.Vector3( 6.149415812887238, 6.838853310980195, - 0.20278120208668637 ),
+		new THREE.Vector3( 10, 0, 10 )
+	];
+
+	var points = [
+		curve.getPointAt( 0 ),
+		curve.getPointAt( 0.3 ),
+		curve.getPointAt( 0.5 ),
+		curve.getPointAt( 1 )
+	];
+
+	assert.deepEqual( points, expectedPoints, "Correct points" );
+
+} );
+
+QUnit.test( "getTangent/getTangentAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedTangents = [
+		new THREE.Vector3( 0.8755715084258769, 0.4377711603816079, - 0.2042815331129452 ),
+		new THREE.Vector3( 0.9340289249885844, 0.3502608468707904, - 0.07005216937416067 ),
+		new THREE.Vector3( 0.9284766908853163, 0, 0.37139067635396156 ),
+		new THREE.Vector3( - 3.669031233375946e-13, - 0.6196442885791218, 0.7848827655333463 ),
+		new THREE.Vector3( - 0.4263618889888853, - 0.6396068005601663, 0.6396238584473043 )
+	];
+
+	var tangents = [
+		curve.getTangent( 0 ),
+		curve.getTangent( 0.25 ),
+		curve.getTangent( 0.5 ),
+		curve.getTangent( 0.75 ),
+		curve.getTangent( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangent #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangent #" + i + ": y correct" );
+
+	} );
+
+	//
+
+	expectedTangents = [
+		new THREE.Vector3( 0.8755715084258769, 0.4377711603816079, - 0.2042815331129452 ),
+		new THREE.Vector3( 0.9060725703490549, 0.3984742932857448, - 0.14230507668907377 ),
+		new THREE.Vector3( 0.9621604167456882, 0.2688562845452628, 0.044312872940942424 ),
+		new THREE.Vector3( 0.016586454041780826, - 0.6163270940470614, 0.7873155674098058 ),
+		new THREE.Vector3( - 0.4263618889888853, - 0.6396068005601663, 0.6396238584473043 )
+	];
+
+	tangents = [
+		curve.getTangentAt( 0 ),
+		curve.getTangentAt( 0.25 ),
+		curve.getTangentAt( 0.5 ),
+		curve.getTangentAt( 0.75 ),
+		curve.getTangentAt( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangentAt #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangentAt #" + i + ": y correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getUtoTmapping", function ( assert ) {
+
+	var curve = this.curve;
+
+	var start = curve.getUtoTmapping( 0, 0 );
+	var end = curve.getUtoTmapping( 0, curve.getLength() );
+	var somewhere = curve.getUtoTmapping( 0.5, 1 );
+
+	var expectedSomewhere = 0.014760890927167196;
+
+	assert.strictEqual( start, 0, "getUtoTmapping( 0, 0 ) is the starting point" );
+	assert.strictEqual( end, 1, "getUtoTmapping( 0, length ) is the ending point" );
+	assert.numEqual( somewhere, expectedSomewhere, "getUtoTmapping( 0.5, 1 ) is correct" );
+
+} );
+
+QUnit.test( "getSpacedPoints", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector3( - 10, 0, 2 ),
+		new THREE.Vector3( - 3.712652983516992, 3.015179001762753, 0.6957120710270492 ),
+		new THREE.Vector3( 2.7830973773262975, 5.730399338061483, - 0.1452668772806931 ),
+		new THREE.Vector3( 9.575825284074465, 7.48754187603603, 0.3461104039841496 ),
+		new THREE.Vector3( 12.345199937734154, 4.575759904730531, 5.142117429101656 ),
+		new THREE.Vector3( 10, 0, 10 )
+	];
+
+	var points = curve.getSpacedPoints();
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+} );
+
+QUnit.test( "computeFrenetFrames", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expected = {
+		binormals: [
+			new THREE.Vector3( - 0.447201668889759, 0.8944331542056199, 0 ),
+			new THREE.Vector3( - 0.2684231751110917, 0.9631753839815436, - 0.01556209353802903 ),
+			new THREE.Vector3( 0.3459273556592433, 0.53807011680075, 0.7686447905324219 )
+		],
+		normals: [
+			new THREE.Vector3( - 0.18271617600817133, - 0.09135504253146765, - 0.9789121795283909 ),
+			new THREE.Vector3( 0.046865035058597876, - 0.003078628350883253, - 0.9988964863970807 ),
+			new THREE.Vector3( 0.8357929194629689, - 0.5489842348221077, 0.008155102228190641 )
+		],
+		tangents: [
+			new THREE.Vector3( 0.8755715084258767, 0.4377711603816078, - 0.20428153311294514 ),
+			new THREE.Vector3( 0.9621604167456884, 0.26885628454526284, 0.04431287294094243 ),
+			new THREE.Vector3( - 0.4263618889888853, - 0.6396068005601663, 0.6396238584473043 )
+		]
+	};
+
+	var frames = curve.computeFrenetFrames( 2, false );
+
+	Object.keys( expected ).forEach( function ( group, i ) {
+
+		expected[ group ].forEach( function ( vec, j ) {
+
+			assert.numEqual( frames[ group ][ j ].x, vec.x, "Frenet frames [" + i + ", " + j + "].x correct" );
+			assert.numEqual( frames[ group ][ j ].y, vec.y, "Frenet frames [" + i + ", " + j + "].y correct" );
+			assert.numEqual( frames[ group ][ j ].z, vec.z, "Frenet frames [" + i + ", " + j + "].z correct" );
+
+		} );
+
+	} );
+
+} );

+ 149 - 3
test/unit/src/extras/curves/SplineCurve.js

@@ -1,6 +1,152 @@
 /**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
+ * @author moraxy / https://github.com/moraxy
  */
 
-//Todo
-console.warn("Todo: Unit tests of SplineCurve")
+QUnit.module( "SplineCurve", {
+
+	before: function () {
+
+		// Create a sine-like wave
+		this.curve = new THREE.SplineCurve( [
+			new THREE.Vector2( - 10, 0 ),
+			new THREE.Vector2( - 5, 5 ),
+			new THREE.Vector2( 0, 0 ),
+			new THREE.Vector2( 5, - 5 ),
+			new THREE.Vector2( 10, 0 )
+		] );
+
+	}
+
+} );
+
+QUnit.test( "Simple curve", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( - 10, 0 ),
+		new THREE.Vector2( - 6.08, 4.56 ),
+		new THREE.Vector2( - 2, 2.48 ),
+		new THREE.Vector2( 2, - 2.48 ),
+		new THREE.Vector2( 6.08, - 4.56 ),
+		new THREE.Vector2( 10, 0 )
+	];
+
+	var points = curve.getPoints( 5 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "1st: Correct number of points" );
+
+	points.forEach( function ( point, i ) {
+
+		assert.numEqual( point.x, expectedPoints[ i ].x, "points[" + i + "].x" );
+		assert.numEqual( point.y, expectedPoints[ i ].y, "points[" + i + "].y" );
+
+	} );
+
+	//
+
+	points = curve.getPoints( 4 );
+
+	assert.deepEqual( points, curve.points, "2nd: Returned points are identical to control points" );
+
+} );
+
+QUnit.test( "getLength/getLengths", function ( assert ) {
+
+	var curve = this.curve;
+
+	var length = curve.getLength();
+	var expectedLength = 28.876950901868135;
+
+	assert.numEqual( length, expectedLength, "Correct length of curve" );
+
+	var expectedLengths = [
+		0.0,
+		Math.sqrt( 50 ),
+		Math.sqrt( 200 ),
+		Math.sqrt( 450 ),
+		Math.sqrt( 800 )
+	];
+
+	var lengths = curve.getLengths( 4 );
+
+	assert.deepEqual( lengths, expectedLengths, "Correct segment lengths" );
+
+} );
+
+QUnit.test( "getPointAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	assert.ok( curve.getPointAt( 0 ).equals( curve.points[ 0 ] ), "PointAt 0.0 correct" );
+	assert.ok( curve.getPointAt( 1 ).equals( curve.points[ 4 ] ), "PointAt 1.0 correct" );
+
+	var pointAt = curve.getPointAt( 0.5 );
+	assert.numEqual( pointAt.x, 0.0, "PointAt 0.5 x correct" );
+	assert.numEqual( pointAt.y, 0.0, "PointAt 0.5 y correct" );
+
+} );
+
+QUnit.test( "getTangent", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedTangent = [
+		new THREE.Vector2( 0.7068243340243188, 0.7073891155729485 ), // 0
+		new THREE.Vector2( 0.7069654305325396, - 0.7072481035902046 ), // 0.5
+		new THREE.Vector2( 0.7068243340245123, 0.7073891155727552 ) // 1
+	];
+
+	var tangents = [
+		curve.getTangent( 0 ),
+		curve.getTangent( 0.5 ),
+		curve.getTangent( 1 )
+	];
+
+	tangents.forEach( function ( tangent, i ) {
+
+		assert.numEqual( tangent.x, expectedTangent[ i ].x, "tangent[" + i + "].x" );
+		assert.numEqual( tangent.y, expectedTangent[ i ].y, "tangent[" + i + "].y" );
+
+	} );
+
+} );
+
+QUnit.test( "getUtoTmapping", function ( assert ) {
+
+	var curve = this.curve;
+
+	var start = curve.getUtoTmapping( 0, 0 );
+	var end = curve.getUtoTmapping( 0, curve.getLength() );
+	var middle = curve.getUtoTmapping( 0.5, 0 );
+
+	assert.strictEqual( start, 0, "getUtoTmapping( 0, 0 ) is the starting point" );
+	assert.strictEqual( end, 1, "getUtoTmapping( 0, length ) is the ending point" );
+	assert.numEqual( middle, 0.5, "getUtoTmapping( 0.5, 0 ) is the middle" );
+
+} );
+
+QUnit.test( "getSpacedPoints", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( - 10, 0 ),
+		new THREE.Vector2( - 4.996509634683014, 4.999995128640857 ),
+		new THREE.Vector2( 0, 0 ),
+		new THREE.Vector2( 4.996509634683006, - 4.999995128640857 ),
+		new THREE.Vector2( 10, 0 )
+	];
+
+	var points = curve.getSpacedPoints( 4 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+
+	points.forEach( function ( point, i ) {
+
+		assert.numEqual( point.x, expectedPoints[ i ].x, "points[" + i + "].x" );
+		assert.numEqual( point.y, expectedPoints[ i ].y, "points[" + i + "].y" );
+
+	} );
+
+} );

+ 21 - 0
test/unit/src/lights/AmbientLight.js

@@ -0,0 +1,21 @@
+/**
+ * @author moraxy / https://github.com/moraxy
+ */
+
+QUnit.module( "AmbientLight" );
+
+QUnit.test( "Standard Light tests", function ( assert ) {
+
+	var parameters = {
+		color: 0xaaaaaa,
+		intensity: 0.5
+	};
+
+	var lights = [
+		new THREE.AmbientLight( parameters.color ),
+		new THREE.AmbientLight( parameters.color, parameters.intensity )
+	];
+
+	runStdLightTests( lights );
+
+} );

+ 0 - 27
test/unit/src/lights/AmbientLight.tests.js

@@ -1,27 +0,0 @@
-(function () {
-
-	'use strict';
-
-	var lights;
-
-	QUnit.module( "Lights - AmbientLight", {
-
-		beforeEach: function() {
-
-			lights = [
-
-				new THREE.AmbientLight( 0xaaaaaa ),
-
-			];
-
-		}
-
-	});
-
-	QUnit.test( "standard light tests", function( assert ) {
-
-		runStdLightTests( assert, lights );
-
-	});
-
-})();

+ 21 - 0
test/unit/src/lights/DirectionalLight.js

@@ -0,0 +1,21 @@
+/**
+ * @author moraxy / https://github.com/moraxy
+ */
+
+QUnit.module( "DirectionalLight" );
+
+QUnit.test( "Standard Light tests", function ( assert ) {
+
+	var parameters = {
+		color: 0xaaaaaa,
+		intensity: 0.5
+	};
+
+	var lights = [
+		new THREE.DirectionalLight( parameters.color ),
+		new THREE.DirectionalLight( parameters.color, parameters.intensity )
+	];
+
+	runStdLightTests( lights );
+
+} );

+ 0 - 28
test/unit/src/lights/DirectionalLight.tests.js

@@ -1,28 +0,0 @@
-(function () {
-
-	'use strict';
-
-	var lights;
-
-	QUnit.module( "Lights - DirectionalLight", {
-
-		beforeEach: function() {
-
-			lights = [
-
-				new THREE.DirectionalLight( 0xaaaaaa ),
-				new THREE.DirectionalLight( 0xaaaaaa, 0.8 ),
-
-			];
-
-		}
-
-	});
-
-	QUnit.test( "standard light tests", function( assert ) {
-
-		runStdLightTests( assert, lights );
-
-	});
-
-})();

+ 40 - 5
test/unit/src/lights/DirectionalLightShadow.js

@@ -1,6 +1,41 @@
-/**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
- */
 
-//Todo
-console.warn("Todo: Unit tests of DirectionalLightShadow")
+QUnit.module( "DirectionalLightShadow" );
+
+QUnit.test( "clone/copy", function ( assert ) {
+
+	var a = new THREE.DirectionalLightShadow();
+	var b = new THREE.DirectionalLightShadow();
+	var c;
+
+	assert.notDeepEqual( a, b, "Newly instanced shadows are not equal" );
+
+	c = a.clone();
+	assert.smartEqual( a, c, "Shadows are identical after clone()" );
+
+	c.mapSize.set( 1024, 1024 );
+	assert.notDeepEqual( a, c, "Shadows are different again after change" );
+
+	b.copy( a );
+	assert.smartEqual( a, b, "Shadows are identical after copy()" );
+
+	b.mapSize.set( 512, 512 );
+	assert.notDeepEqual( a, b, "Shadows are different again after change" );
+
+} );
+
+QUnit.test( "toJSON", function ( assert ) {
+
+	var light = new THREE.DirectionalLight();
+	var shadow = new THREE.DirectionalLightShadow();
+
+	shadow.bias = 10;
+	shadow.radius = 5;
+	shadow.mapSize.set( 1024, 1024 );
+	light.shadow = shadow;
+
+	var json = light.toJSON();
+	var newLight = new THREE.ObjectLoader().parse( json );
+
+	assert.smartEqual( newLight.shadow, light.shadow, "Reloaded shadow is identical to the original one" );
+
+} );

+ 25 - 0
test/unit/src/lights/HemisphereLight.js

@@ -0,0 +1,25 @@
+/**
+ * @author moraxy / https://github.com/moraxy
+ */
+
+QUnit.module( "HemisphereLight" );
+
+QUnit.test( "Standard Light tests", function ( assert ) {
+
+	var parameters = {
+		skyColor: 0x123456,
+		groundColor: 0xabc012,
+		intensity: 0.6
+	};
+
+	var lights = [
+		new THREE.HemisphereLight( parameters.skyColor ),
+		new THREE.HemisphereLight( parameters.skyColor, parameters.groundColor ),
+		new THREE.HemisphereLight(
+			parameters.skyColor, parameters.groundColor, parameters.intensity
+		)
+	];
+
+	runStdLightTests( lights );
+
+} );

+ 0 - 35
test/unit/src/lights/HemisphereLight.tests.js

@@ -1,35 +0,0 @@
-(function () {
-
-	'use strict';
-
-	var parameters = {
-		skyColor: 0x123456,
-		groundColor: 0xabc012,
-		intensity: 0.6
-	};
-
-	var lights;
-
-	QUnit.module( "Lights - HemisphereLight", {
-
-		beforeEach: function() {
-
-			lights = [
-
-				new THREE.HemisphereLight( parameters.skyColor ),
-				new THREE.HemisphereLight( parameters.skyColor, parameters.groundColor ),
-				new THREE.HemisphereLight( parameters.skyColor, parameters.groundColor, parameters.intensity ),
-
-			];
-
-		}
-
-	});
-
-	QUnit.test( "standard light tests", function( assert ) {
-
-		runStdLightTests( assert, lights );
-
-	});
-
-})();

+ 18 - 3
test/unit/src/lights/Light.js

@@ -1,6 +1,21 @@
 /**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
+ * @author moraxy / https://github.com/moraxy
  */
 
-//Todo
-console.warn("Todo: Unit tests of Light")
+QUnit.module( "Light" );
+
+QUnit.test( "Standard Light tests", function ( assert ) {
+
+	var parameters = {
+		color: 0xaaaaaa,
+		intensity: 0.5
+	};
+
+	var lights = [
+		new THREE.Light( parameters.color ),
+		new THREE.Light( parameters.color, parameters.intensity )
+	];
+
+	runStdLightTests( lights, true );
+
+} );

+ 23 - 5
test/unit/src/lights/LightShadow.js

@@ -1,6 +1,24 @@
-/**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
- */
 
-//Todo
-console.warn("Todo: Unit tests of LightShadow")
+QUnit.module( "LightShadow" );
+
+QUnit.test( "clone/copy", function ( assert ) {
+
+	var a = new THREE.LightShadow( new THREE.OrthographicCamera( - 5, 5, 5, - 5, 0.5, 500 ) );
+	var b = new THREE.LightShadow( new THREE.OrthographicCamera( - 3, 3, 3, - 3, 0.3, 300 ) );
+	var c;
+
+	assert.notDeepEqual( a, b, "Newly instanced shadows are not equal" );
+
+	c = a.clone();
+	assert.smartEqual( a, c, "Shadows are identical after clone()" );
+
+	c.mapSize.set( 256, 256 );
+	assert.notDeepEqual( a, c, "Shadows are different again after change" );
+
+	b.copy( a );
+	assert.smartEqual( a, b, "Shadows are identical after copy()" );
+
+	b.mapSize.set( 512, 512 );
+	assert.notDeepEqual( a, b, "Shadows are different again after change" );
+
+} );

+ 45 - 0
test/unit/src/lights/PointLight.js

@@ -0,0 +1,45 @@
+/**
+ * @author moraxy / https://github.com/moraxy
+ */
+
+QUnit.module( "PointLight" );
+
+QUnit.test( "Standard Light tests", function ( assert ) {
+
+	var parameters = {
+		color: 0xaaaaaa,
+		intensity: 0.5,
+		distance: 100,
+		decay: 2
+	};
+
+	var lights = [
+		new THREE.PointLight( parameters.color ),
+		new THREE.PointLight( parameters.color, parameters.intensity ),
+		new THREE.PointLight(
+			parameters.color, parameters.intensity, parameters.distance
+		),
+		new THREE.PointLight(
+			parameters.color, parameters.intensity, parameters.distance,
+			parameters.decay
+		)
+	];
+
+	runStdLightTests( lights );
+
+} );
+
+QUnit.test( "power", function ( assert ) {
+
+	var a = new THREE.PointLight( 0xaaaaaa );
+
+	a.intensity = 100;
+	assert.numEqual( a.power, 100 * Math.PI * 4, "Correct power for an intensity of 100" );
+
+	a.intensity = 40;
+	assert.numEqual( a.power, 40 * Math.PI * 4, "Correct power for an intensity of 40" );
+
+	a.power = 100;
+	assert.numEqual( a.intensity, 100 / ( 4 * Math.PI ), "Correct intensity for a power of 100" );
+
+} );

+ 0 - 27
test/unit/src/lights/PointLight.tests.js

@@ -1,27 +0,0 @@
-(function () {
-
-	'use strict';
-
-	var lights;
-
-	QUnit.module( "Lights - PointLight", {
-
-		beforeEach: function() {
-
-			lights = [
-
-				new THREE.PointLight( 0xaaaaaa ),
-
-			];
-
-		}
-
-	});
-
-	QUnit.test( "standard light tests", function( assert ) {
-
-		runStdLightTests( assert, lights );
-
-	});
-
-})();

+ 29 - 0
test/unit/src/lights/RectAreaLight.js

@@ -0,0 +1,29 @@
+/**
+ * @author moraxy / https://github.com/moraxy
+ */
+
+QUnit.module( "RectAreaLight" );
+
+QUnit.test( "Standard Light tests", function ( assert ) {
+
+	var parameters = {
+		color: 0xaaaaaa,
+		intensity: 0.5,
+		width: 100,
+		height: 50
+	};
+
+	var lights = [
+		new THREE.RectAreaLight( parameters.color ),
+		new THREE.RectAreaLight( parameters.color, parameters.intensity ),
+		new THREE.RectAreaLight(
+			parameters.color, parameters.intensity, parameters.width
+		),
+		new THREE.RectAreaLight(
+			parameters.color, parameters.intensity, parameters.width, parameters.height
+		)
+	];
+
+	runStdLightTests( lights );
+
+} );

+ 0 - 38
test/unit/src/lights/RectAreaLight.tests.js

@@ -1,38 +0,0 @@
-(function () {
-
-	'use strict';
-
-	var parameters = {
-		color: 0xaaaaaa,
-		intensity: 0.5,
-	};
-
-	var lights;
-
-	// TODO (abelnation): verify this works
-
-	QUnit.module( "Lights - RectAreaLight", {
-
-		beforeEach: function() {
-
-			lights = [
-
-				new THREE.RectAreaLight( parameters.color ),
-				new THREE.RectAreaLight( parameters.color, parameters.intensity ),
-				new THREE.RectAreaLight( parameters.color, parameters.intensity, 5.0 ),
-				new THREE.RectAreaLight( parameters.color, parameters.intensity, 5.0, 20.0 ),
-				new THREE.RectAreaLight( parameters.color, parameters.intensity, undefined, 20.0 ),
-
-			];
-
-		}
-
-	});
-
-	QUnit.test( "standard light tests", function( assert ) {
-
-		runStdLightTests( assert, lights );
-
-	});
-
-})();

+ 55 - 0
test/unit/src/lights/SpotLight.js

@@ -0,0 +1,55 @@
+/**
+ * @author moraxy / https://github.com/moraxy
+ */
+
+QUnit.module( "SpotLight" );
+
+QUnit.test( "Standard Light tests", function ( assert ) {
+
+	var parameters = {
+		color: 0xaaaaaa,
+		intensity: 0.5,
+		distance: 100,
+		angle: 0.8,
+		penumbra: 8,
+		decay: 2
+	};
+
+	var lights = [
+		new THREE.SpotLight( parameters.color ),
+		new THREE.SpotLight( parameters.color, parameters.intensity ),
+		new THREE.SpotLight(
+			parameters.color, parameters.intensity, parameters.distance
+		),
+		new THREE.SpotLight(
+			parameters.color, parameters.intensity, parameters.distance,
+			parameters.angle
+		),
+		new THREE.SpotLight(
+			parameters.color, parameters.intensity, parameters.distance,
+			parameters.angle, parameters.penumbra
+		),
+		new THREE.SpotLight(
+			parameters.color, parameters.intensity, parameters.distance,
+			parameters.angle, parameters.penumbra, parameters.decay
+		)
+	];
+
+	runStdLightTests( lights );
+
+} );
+
+QUnit.test( "power", function ( assert ) {
+
+	var a = new THREE.SpotLight( 0xaaaaaa );
+
+	a.intensity = 100;
+	assert.numEqual( a.power, 100 * Math.PI, "Correct power for an intensity of 100" );
+
+	a.intensity = 40;
+	assert.numEqual( a.power, 40 * Math.PI, "Correct power for an intensity of 40" );
+
+	a.power = 100;
+	assert.numEqual( a.intensity, 100 / Math.PI, "Correct intensity for a power of 100" );
+
+} );

+ 0 - 41
test/unit/src/lights/SpotLight.tests.js

@@ -1,41 +0,0 @@
-(function () {
-
-	'use strict';
-
-	var parameters = {
-		color: 0xaaaaaa,
-		intensity: 0.5,
-		distance: 100,
-		angle: 0.8,
-		exponent: 8,
-		decay: 2
-	};
-
-	var lights;
-
-	QUnit.module( "Lights - SpotLight", {
-
-		beforeEach: function() {
-
-			lights = [
-
-				new THREE.SpotLight( parameters.color ),
-				new THREE.SpotLight( parameters.color, parameters.intensity ),
-				new THREE.SpotLight( parameters.color, parameters.intensity, parameters.distance ),
-				new THREE.SpotLight( parameters.color, parameters.intensity, parameters.distance, parameters.angle ),
-				new THREE.SpotLight( parameters.color, parameters.intensity, parameters.distance, parameters.angle, parameters.exponent ),
-				new THREE.SpotLight( parameters.color, parameters.intensity, parameters.distance, parameters.angle, parameters.exponent, parameters.decay ),
-
-			];
-
-		}
-
-	});
-
-	QUnit.test( "standard light tests", function( assert ) {
-
-		runStdLightTests( assert, lights );
-
-	});
-
-})();

+ 40 - 5
test/unit/src/lights/SpotLightShadow.js

@@ -1,6 +1,41 @@
-/**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
- */
 
-//Todo
-console.warn("Todo: Unit tests of SpotLightShadow")
+QUnit.module( "SpotLightShadow" );
+
+QUnit.test( "clone/copy", function ( assert ) {
+
+	var a = new THREE.SpotLightShadow();
+	var b = new THREE.SpotLightShadow();
+	var c;
+
+	assert.notDeepEqual( a, b, "Newly instanced shadows are not equal" );
+
+	c = a.clone();
+	assert.smartEqual( a, c, "Shadows are identical after clone()" );
+
+	c.mapSize.set( 256, 256 );
+	assert.notDeepEqual( a, c, "Shadows are different again after change" );
+
+	b.copy( a );
+	assert.smartEqual( a, b, "Shadows are identical after copy()" );
+
+	b.mapSize.set( 512, 512 );
+	assert.notDeepEqual( a, b, "Shadows are different again after change" );
+
+} );
+
+QUnit.test( "toJSON", function ( assert ) {
+
+	var light = new THREE.SpotLight();
+	var shadow = new THREE.SpotLightShadow();
+
+	shadow.bias = 10;
+	shadow.radius = 5;
+	shadow.mapSize.set( 128, 128 );
+	light.shadow = shadow;
+
+	var json = light.toJSON();
+	var newLight = new THREE.ObjectLoader().parse( json );
+
+	assert.smartEqual( newLight.shadow, light.shadow, "Reloaded shadow is equal to the original one" );
+
+} );

+ 6 - 7
test/unit/unittests_sources.html

@@ -97,7 +97,6 @@
   <script src="src/extras/core/ShapePath.js"></script>
 
   <!-- /src/extras/curves -->
-  <script src="src/extras/curves/ArcCurve.js"></script>
   <script src="src/extras/curves/CatmullRomCurve3.js"></script>
   <script src="src/extras/curves/CubicBezierCurve.js"></script>
   <script src="src/extras/curves/CubicBezierCurve3.js"></script>
@@ -157,15 +156,15 @@
 
 
   <!-- /src/lights -->
-  <script src="src/lights/AmbientLight.tests.js"></script>
-  <script src="src/lights/DirectionalLight.tests.js"></script>
+  <script src="src/lights/AmbientLight.js"></script>
+  <script src="src/lights/DirectionalLight.js"></script>
   <script src="src/lights/DirectionalLightShadow.js"></script>
-  <script src="src/lights/HemisphereLight.tests.js"></script>
+  <script src="src/lights/HemisphereLight.js"></script>
   <script src="src/lights/Light.js"></script>
   <script src="src/lights/LightShadow.js"></script>
-  <script src="src/lights/PointLight.tests.js"></script>
-  <script src="src/lights/RectAreaLight.tests.js"></script>
-  <script src="src/lights/SpotLight.tests.js"></script>
+  <script src="src/lights/PointLight.js"></script>
+  <script src="src/lights/RectAreaLight.js"></script>
+  <script src="src/lights/SpotLight.js"></script>
   <script src="src/lights/SpotLightShadow.js"></script>
 
 

Неке датотеке нису приказане због велике количине промена