gero3 10 лет назад
Родитель
Сommit
4501d5a51d
41 измененных файлов с 2779 добавлено и 2779 удалено
  1. 1 1
      editor/js/Sidebar.Object3D.js
  2. 6 6
      examples/js/BlendCharacter.js
  3. 8 8
      examples/js/CurveExtras.js
  4. 3 3
      examples/js/ParametricGeometries.js
  5. 211 211
      examples/js/SimplexNoise.js
  6. 145 145
      examples/js/Sparks.js
  7. 25 25
      examples/js/controls/MouseControls.js
  8. 12 12
      examples/js/controls/TransformControls.js
  9. 1 1
      examples/js/effects/VREffect.js
  10. 5 5
      examples/js/geometries/ConvexGeometry.js
  11. 2 2
      examples/js/geometries/DecalGeometry.js
  12. 345 345
      examples/js/loaders/AWDLoader.js
  13. 26 26
      examples/js/loaders/ColladaLoader.js
  14. 16 16
      examples/js/loaders/PVRLoader.js
  15. 3 3
      examples/js/loaders/RGBELoader.js
  16. 7 7
      examples/js/loaders/STLLoader.js
  17. 6 6
      examples/js/loaders/TGALoader.js
  18. 286 286
      examples/js/loaders/UTF8Loader.js
  19. 1 1
      examples/js/loaders/VRMLLoader.js
  20. 357 357
      examples/js/loaders/ctm/ctm.js
  21. 348 348
      examples/js/loaders/ctm/lzma.js
  22. 1 1
      examples/js/loaders/deprecated/SceneLoader.js
  23. 168 168
      examples/js/loaders/gltf/glTF-parser.js
  24. 522 522
      examples/js/loaders/gltf/glTFLoader.js
  25. 102 102
      examples/js/loaders/gltf/glTFLoaderUtils.js
  26. 1 1
      examples/js/renderers/SVGRenderer.js
  27. 2 2
      examples/js/renderers/SoftwareRenderer.js
  28. 55 55
      examples/js/utils/UVsDebug.js
  29. 25 25
      examples/js/wip/benchmark/Geometry4.js
  30. 3 3
      src/extras/FontUtils.js
  31. 4 4
      src/extras/core/Curve.js
  32. 2 2
      src/extras/core/Path.js
  33. 6 6
      src/extras/geometries/ExtrudeGeometry.js
  34. 1 1
      src/loaders/CompressedTextureLoader.js
  35. 1 1
      src/loaders/JSONLoader.js
  36. 4 4
      src/math/Matrix4.js
  37. 1 1
      src/math/Sphere.js
  38. 7 7
      src/math/Vector2.js
  39. 8 8
      src/math/Vector3.js
  40. 29 29
      src/math/Vector4.js
  41. 23 23
      src/renderers/WebGLRenderer.js

+ 1 - 1
editor/js/Sidebar.Object3D.js

@@ -84,7 +84,7 @@ Sidebar.Object3D = function ( editor ) {
 	var objectNameRow = new UI.Panel();
 	var objectName = new UI.Input().setWidth( '150px' ).setFontSize( '12px' ).onChange( function () {
 
-			editor.nameObject( editor.selected, objectName.getValue() );
+		editor.nameObject( editor.selected, objectName.getValue() );
 
 	} );
 

+ 6 - 6
examples/js/BlendCharacter.js

@@ -203,17 +203,17 @@ THREE.BlendCharacter = function () {
 
 	this.unPauseAll = function() {
 
-	for ( var a in this.animations ) {
+		for ( var a in this.animations ) {
 
-	  if ( this.animations[ a ].isPlaying && this.animations[ a ].isPaused ) {
+			if ( this.animations[ a ].isPlaying && this.animations[ a ].isPaused ) {
 
-		this.animations[ a ].pause();
+				this.animations[ a ].pause();
 
-	  }
+			}
 
-	}
+		}
 
-  };
+	};
 
 
 	this.stopAll = function() {

+ 8 - 8
examples/js/CurveExtras.js

@@ -18,12 +18,12 @@ THREE.Curves = {};
  THREE.Curves.GrannyKnot = THREE.Curve.create( function() {},
 
 	 function(t) {
-	    t = 2 * Math.PI * t;
+		t = 2 * Math.PI * t;
 
-	    var x = -0.22 * Math.cos(t) - 1.28 * Math.sin(t) - 0.44 * Math.cos(3 * t) - 0.78 * Math.sin(3 * t);
-	    var y = -0.1 * Math.cos(2 * t) - 0.27 * Math.sin(2 * t) + 0.38 * Math.cos(4 * t) + 0.46 * Math.sin(4 * t);
-	    var z = 0.7 * Math.cos(3 * t) - 0.4 * Math.sin(3 * t);
-	    return new THREE.Vector3(x, y, z).multiplyScalar(20);
+		var x = -0.22 * Math.cos(t) - 1.28 * Math.sin(t) - 0.44 * Math.cos(3 * t) - 0.78 * Math.sin(3 * t);
+		var y = -0.1 * Math.cos(2 * t) - 0.27 * Math.sin(2 * t) + 0.38 * Math.cos(4 * t) + 0.46 * Math.sin(4 * t);
+		var z = 0.7 * Math.cos(3 * t) - 0.4 * Math.sin(3 * t);
+		return new THREE.Vector3(x, y, z).multiplyScalar(20);
 	}
 );
 
@@ -214,10 +214,10 @@ THREE.Curves.TrefoilPolynomialKnot = THREE.Curve.create(
 // }
 var scaleTo = function(x, y, t) {
 
-		var r = y - x;
-		return t * r + x;
+	var r = y - x;
+	return t * r + x;
 
-	}
+}
 
 THREE.Curves.FigureEightPolynomialKnot = THREE.Curve.create(
 

+ 3 - 3
examples/js/ParametricGeometries.js

@@ -108,9 +108,9 @@ THREE.ParametricGeometries.TubeGeometry = function(path, segments, radius, segme
 		binormals = frames.binormals;
 
 		// proxy internals
-		this.tangents = tangents;
-		this.normals = normals;
-		this.binormals = binormals;
+	this.tangents = tangents;
+	this.normals = normals;
+	this.binormals = binormals;
 
 
 

+ 211 - 211
examples/js/SimplexNoise.js

@@ -13,11 +13,11 @@
  */
 var SimplexNoise = function(r) {
 	if (r == undefined) r = Math;
-  this.grad3 = [[ 1,1,0 ],[ -1,1,0 ],[ 1,-1,0 ],[ -1,-1,0 ], 
+	this.grad3 = [[ 1,1,0 ],[ -1,1,0 ],[ 1,-1,0 ],[ -1,-1,0 ], 
                                  [ 1,0,1 ],[ -1,0,1 ],[ 1,0,-1 ],[ -1,0,-1 ], 
                                  [ 0,1,1 ],[ 0,-1,1 ],[ 0,1,-1 ],[ 0,-1,-1 ]]; 
 
-  this.grad4 = [[ 0,1,1,1 ], [ 0,1,1,-1 ], [ 0,1,-1,1 ], [ 0,1,-1,-1 ],
+	this.grad4 = [[ 0,1,1,1 ], [ 0,1,1,-1 ], [ 0,1,-1,1 ], [ 0,1,-1,-1 ],
 	     [ 0,-1,1,1 ], [ 0,-1,1,-1 ], [ 0,-1,-1,1 ], [ 0,-1,-1,-1 ],
 	     [ 1,0,1,1 ], [ 1,0,1,-1 ], [ 1,0,-1,1 ], [ 1,0,-1,-1 ],
 	     [ -1,0,1,1 ], [ -1,0,1,-1 ], [ -1,0,-1,1 ], [ -1,0,-1,-1 ],
@@ -26,19 +26,19 @@ var SimplexNoise = function(r) {
 	     [ 1,1,1,0 ], [ 1,1,-1,0 ], [ 1,-1,1,0 ], [ 1,-1,-1,0 ],
 	     [ -1,1,1,0 ], [ -1,1,-1,0 ], [ -1,-1,1,0 ], [ -1,-1,-1,0 ]];
 
-  this.p = [];
-  for (var i = 0; i < 256; i ++) {
-	  this.p[i] = Math.floor(r.random() * 256);
-  }
+	this.p = [];
+	for (var i = 0; i < 256; i ++) {
+		this.p[i] = Math.floor(r.random() * 256);
+	}
   // To remove the need for index wrapping, double the permutation table length 
-  this.perm = []; 
-  for (var i = 0; i < 512; i ++) {
+	this.perm = []; 
+	for (var i = 0; i < 512; i ++) {
 		this.perm[i] = this.p[i & 255];
 	} 
 
   // A lookup table to traverse the simplex around a given point in 4D. 
   // Details can be found where this table is used, in the 4D noise method. 
-  this.simplex = [ 
+	this.simplex = [ 
     [ 0,1,2,3 ],[ 0,1,3,2 ],[ 0,0,0,0 ],[ 0,2,3,1 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 1,2,3,0 ], 
     [ 0,2,1,3 ],[ 0,0,0,0 ],[ 0,3,1,2 ],[ 0,3,2,1 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 1,3,2,0 ], 
     [ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ], 
@@ -54,149 +54,149 @@ SimplexNoise.prototype.dot = function(g, x, y) {
 };
 
 SimplexNoise.prototype.dot3 = function(g, x, y, z) {
-  return g[0] * x + g[1] * y + g[2] * z; 
+	return g[0] * x + g[1] * y + g[2] * z; 
 }
 
 SimplexNoise.prototype.dot4 = function(g, x, y, z, w) {
-  return g[0] * x + g[1] * y + g[2] * z + g[3] * w;
+	return g[0] * x + g[1] * y + g[2] * z + g[3] * w;
 };
 
 SimplexNoise.prototype.noise = function(xin, yin) { 
-  var n0, n1, n2; // Noise contributions from the three corners 
+	var n0, n1, n2; // Noise contributions from the three corners 
   // Skew the input space to determine which simplex cell we're in 
-  var F2 = 0.5 * (Math.sqrt(3.0) - 1.0); 
-  var s = (xin + yin) * F2; // Hairy factor for 2D 
-  var i = Math.floor(xin + s); 
-  var j = Math.floor(yin + s); 
-  var G2 = (3.0 - Math.sqrt(3.0)) / 6.0; 
-  var t = (i + j) * G2; 
-  var X0 = i - t; // Unskew the cell origin back to (x,y) space 
-  var Y0 = j - t; 
-  var x0 = xin - X0; // The x,y distances from the cell origin 
-  var y0 = yin - Y0; 
+	var F2 = 0.5 * (Math.sqrt(3.0) - 1.0); 
+	var s = (xin + yin) * F2; // Hairy factor for 2D 
+	var i = Math.floor(xin + s); 
+	var j = Math.floor(yin + s); 
+	var G2 = (3.0 - Math.sqrt(3.0)) / 6.0; 
+	var t = (i + j) * G2; 
+	var X0 = i - t; // Unskew the cell origin back to (x,y) space 
+	var Y0 = j - t; 
+	var x0 = xin - X0; // The x,y distances from the cell origin 
+	var y0 = yin - Y0; 
   // For the 2D case, the simplex shape is an equilateral triangle. 
   // Determine which simplex we are in. 
-  var i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords 
-  if (x0 > y0) {i1 = 1; j1 = 0;} // lower triangle, XY order: (0,0)->(1,0)->(1,1) 
-  else {i1 = 0; j1 = 1;}      // upper triangle, YX order: (0,0)->(0,1)->(1,1) 
+	var i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords 
+	if (x0 > y0) {i1 = 1; j1 = 0;} // lower triangle, XY order: (0,0)->(1,0)->(1,1) 
+	else {i1 = 0; j1 = 1;}      // upper triangle, YX order: (0,0)->(0,1)->(1,1) 
   // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and 
   // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where 
   // c = (3-sqrt(3))/6 
-  var x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords 
-  var y1 = y0 - j1 + G2; 
-  var x2 = x0 - 1.0 + 2.0 * G2; // Offsets for last corner in (x,y) unskewed coords 
-  var y2 = y0 - 1.0 + 2.0 * G2; 
+	var x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords 
+	var y1 = y0 - j1 + G2; 
+	var x2 = x0 - 1.0 + 2.0 * G2; // Offsets for last corner in (x,y) unskewed coords 
+	var y2 = y0 - 1.0 + 2.0 * G2; 
   // Work out the hashed gradient indices of the three simplex corners 
-  var ii = i & 255; 
-  var jj = j & 255; 
-  var gi0 = this.perm[ii + this.perm[jj]] % 12; 
-  var gi1 = this.perm[ii + i1 + this.perm[jj + j1]] % 12; 
-  var gi2 = this.perm[ii + 1 + this.perm[jj + 1]] % 12; 
+	var ii = i & 255; 
+	var jj = j & 255; 
+	var gi0 = this.perm[ii + this.perm[jj]] % 12; 
+	var gi1 = this.perm[ii + i1 + this.perm[jj + j1]] % 12; 
+	var gi2 = this.perm[ii + 1 + this.perm[jj + 1]] % 12; 
   // Calculate the contribution from the three corners 
-  var t0 = 0.5 - x0 * x0 - y0 * y0; 
-  if (t0 < 0) n0 = 0.0; 
-  else { 
-    t0 *= t0; 
-    n0 = t0 * t0 * this.dot(this.grad3[gi0], x0, y0);  // (x,y) of grad3 used for 2D gradient 
-  } 
-  var t1 = 0.5 - x1 * x1 - y1 * y1; 
-  if (t1 < 0) n1 = 0.0; 
-  else { 
-    t1 *= t1; 
-    n1 = t1 * t1 * this.dot(this.grad3[gi1], x1, y1); 
-  }
-  var t2 = 0.5 - x2 * x2 - y2 * y2; 
-  if (t2 < 0) n2 = 0.0; 
-  else { 
-    t2 *= t2; 
-    n2 = t2 * t2 * this.dot(this.grad3[gi2], x2, y2); 
-  } 
+	var t0 = 0.5 - x0 * x0 - y0 * y0; 
+	if (t0 < 0) n0 = 0.0; 
+	else { 
+		t0 *= t0; 
+		n0 = t0 * t0 * this.dot(this.grad3[gi0], x0, y0);  // (x,y) of grad3 used for 2D gradient 
+	} 
+	var t1 = 0.5 - x1 * x1 - y1 * y1; 
+	if (t1 < 0) n1 = 0.0; 
+	else { 
+		t1 *= t1; 
+		n1 = t1 * t1 * this.dot(this.grad3[gi1], x1, y1); 
+	}
+	var t2 = 0.5 - x2 * x2 - y2 * y2; 
+	if (t2 < 0) n2 = 0.0; 
+	else { 
+		t2 *= t2; 
+		n2 = t2 * t2 * this.dot(this.grad3[gi2], x2, y2); 
+	} 
   // Add contributions from each corner to get the final noise value. 
   // The result is scaled to return values in the interval [-1,1]. 
-  return 70.0 * (n0 + n1 + n2); 
+	return 70.0 * (n0 + n1 + n2); 
 };
 
 // 3D simplex noise 
 SimplexNoise.prototype.noise3d = function(xin, yin, zin) { 
-  var n0, n1, n2, n3; // Noise contributions from the four corners 
+	var n0, n1, n2, n3; // Noise contributions from the four corners 
   // Skew the input space to determine which simplex cell we're in 
-  var F3 = 1.0 / 3.0; 
-  var s = (xin + yin + zin) * F3; // Very nice and simple skew factor for 3D 
-  var i = Math.floor(xin + s); 
-  var j = Math.floor(yin + s); 
-  var k = Math.floor(zin + s); 
-  var G3 = 1.0 / 6.0; // Very nice and simple unskew factor, too 
-  var t = (i + j + k) * G3; 
-  var X0 = i - t; // Unskew the cell origin back to (x,y,z) space 
-  var Y0 = j - t; 
-  var Z0 = k - t; 
-  var x0 = xin - X0; // The x,y,z distances from the cell origin 
-  var y0 = yin - Y0; 
-  var z0 = zin - Z0; 
+	var F3 = 1.0 / 3.0; 
+	var s = (xin + yin + zin) * F3; // Very nice and simple skew factor for 3D 
+	var i = Math.floor(xin + s); 
+	var j = Math.floor(yin + s); 
+	var k = Math.floor(zin + s); 
+	var G3 = 1.0 / 6.0; // Very nice and simple unskew factor, too 
+	var t = (i + j + k) * G3; 
+	var X0 = i - t; // Unskew the cell origin back to (x,y,z) space 
+	var Y0 = j - t; 
+	var Z0 = k - t; 
+	var x0 = xin - X0; // The x,y,z distances from the cell origin 
+	var y0 = yin - Y0; 
+	var z0 = zin - Z0; 
   // For the 3D case, the simplex shape is a slightly irregular tetrahedron. 
   // Determine which simplex we are in. 
-  var i1, j1, k1; // Offsets for second corner of simplex in (i,j,k) coords 
-  var i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords 
-  if (x0 >= y0) { 
-    if (y0 >= z0) 
+	var i1, j1, k1; // Offsets for second corner of simplex in (i,j,k) coords 
+	var i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords 
+	if (x0 >= y0) { 
+		if (y0 >= z0) 
       { i1 = 1; j1 = 0; k1 = 0; i2 = 1; j2 = 1; k2 = 0; } // X Y Z order 
       else if (x0 >= z0) { i1 = 1; j1 = 0; k1 = 0; i2 = 1; j2 = 0; k2 = 1; } // X Z Y order 
-      else { i1 = 0; j1 = 0; k1 = 1; i2 = 1; j2 = 0; k2 = 1; } // Z X Y order 
-    } 
-  else { // x0<y0 
-    if (y0 < z0) { i1 = 0; j1 = 0; k1 = 1; i2 = 0; j2 = 1; k2 = 1; } // Z Y X order 
+		else { i1 = 0; j1 = 0; k1 = 1; i2 = 1; j2 = 0; k2 = 1; } // Z X Y order 
+	} 
+	else { // x0<y0 
+		if (y0 < z0) { i1 = 0; j1 = 0; k1 = 1; i2 = 0; j2 = 1; k2 = 1; } // Z Y X order 
     else if (x0 < z0) { i1 = 0; j1 = 1; k1 = 0; i2 = 0; j2 = 1; k2 = 1; } // Y Z X order 
-    else { i1 = 0; j1 = 1; k1 = 0; i2 = 1; j2 = 1; k2 = 0; } // Y X Z order 
-  } 
+		else { i1 = 0; j1 = 1; k1 = 0; i2 = 1; j2 = 1; k2 = 0; } // Y X Z order 
+	} 
   // A step of (1,0,0) in (i,j,k) means a step of (1-c,-c,-c) in (x,y,z), 
   // a step of (0,1,0) in (i,j,k) means a step of (-c,1-c,-c) in (x,y,z), and 
   // a step of (0,0,1) in (i,j,k) means a step of (-c,-c,1-c) in (x,y,z), where 
   // c = 1/6.
-  var x1 = x0 - i1 + G3; // Offsets for second corner in (x,y,z) coords 
-  var y1 = y0 - j1 + G3; 
-  var z1 = z0 - k1 + G3; 
-  var x2 = x0 - i2 + 2.0 * G3; // Offsets for third corner in (x,y,z) coords 
-  var y2 = y0 - j2 + 2.0 * G3; 
-  var z2 = z0 - k2 + 2.0 * G3; 
-  var x3 = x0 - 1.0 + 3.0 * G3; // Offsets for last corner in (x,y,z) coords 
-  var y3 = y0 - 1.0 + 3.0 * G3; 
-  var z3 = z0 - 1.0 + 3.0 * G3; 
+	var x1 = x0 - i1 + G3; // Offsets for second corner in (x,y,z) coords 
+	var y1 = y0 - j1 + G3; 
+	var z1 = z0 - k1 + G3; 
+	var x2 = x0 - i2 + 2.0 * G3; // Offsets for third corner in (x,y,z) coords 
+	var y2 = y0 - j2 + 2.0 * G3; 
+	var z2 = z0 - k2 + 2.0 * G3; 
+	var x3 = x0 - 1.0 + 3.0 * G3; // Offsets for last corner in (x,y,z) coords 
+	var y3 = y0 - 1.0 + 3.0 * G3; 
+	var z3 = z0 - 1.0 + 3.0 * G3; 
   // Work out the hashed gradient indices of the four simplex corners 
-  var ii = i & 255; 
-  var jj = j & 255; 
-  var kk = k & 255; 
-  var gi0 = this.perm[ii + this.perm[jj + this.perm[kk]]] % 12; 
-  var gi1 = this.perm[ii + i1 + this.perm[jj + j1 + this.perm[kk + k1]]] % 12; 
-  var gi2 = this.perm[ii + i2 + this.perm[jj + j2 + this.perm[kk + k2]]] % 12; 
-  var gi3 = this.perm[ii + 1 + this.perm[jj + 1 + this.perm[kk + 1]]] % 12; 
+	var ii = i & 255; 
+	var jj = j & 255; 
+	var kk = k & 255; 
+	var gi0 = this.perm[ii + this.perm[jj + this.perm[kk]]] % 12; 
+	var gi1 = this.perm[ii + i1 + this.perm[jj + j1 + this.perm[kk + k1]]] % 12; 
+	var gi2 = this.perm[ii + i2 + this.perm[jj + j2 + this.perm[kk + k2]]] % 12; 
+	var gi3 = this.perm[ii + 1 + this.perm[jj + 1 + this.perm[kk + 1]]] % 12; 
   // Calculate the contribution from the four corners 
-  var t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0; 
-  if (t0 < 0) n0 = 0.0; 
-  else { 
-    t0 *= t0; 
-    n0 = t0 * t0 * this.dot3(this.grad3[gi0], x0, y0, z0); 
-  }
-  var t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1; 
-  if (t1 < 0) n1 = 0.0; 
-  else { 
-    t1 *= t1; 
-    n1 = t1 * t1 * this.dot3(this.grad3[gi1], x1, y1, z1); 
-  } 
-  var t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2; 
-  if (t2 < 0) n2 = 0.0; 
-  else { 
-    t2 *= t2; 
-    n2 = t2 * t2 * this.dot3(this.grad3[gi2], x2, y2, z2); 
-  } 
-  var t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3; 
-  if (t3 < 0) n3 = 0.0; 
-  else { 
-    t3 *= t3; 
-    n3 = t3 * t3 * this.dot3(this.grad3[gi3], x3, y3, z3); 
-  } 
+	var t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0; 
+	if (t0 < 0) n0 = 0.0; 
+	else { 
+		t0 *= t0; 
+		n0 = t0 * t0 * this.dot3(this.grad3[gi0], x0, y0, z0); 
+	}
+	var t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1; 
+	if (t1 < 0) n1 = 0.0; 
+	else { 
+		t1 *= t1; 
+		n1 = t1 * t1 * this.dot3(this.grad3[gi1], x1, y1, z1); 
+	} 
+	var t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2; 
+	if (t2 < 0) n2 = 0.0; 
+	else { 
+		t2 *= t2; 
+		n2 = t2 * t2 * this.dot3(this.grad3[gi2], x2, y2, z2); 
+	} 
+	var t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3; 
+	if (t3 < 0) n3 = 0.0; 
+	else { 
+		t3 *= t3; 
+		n3 = t3 * t3 * this.dot3(this.grad3[gi3], x3, y3, z3); 
+	} 
   // Add contributions from each corner to get the final noise value. 
   // The result is scaled to stay just inside [-1,1] 
-  return 32.0 * (n0 + n1 + n2 + n3); 
+	return 32.0 * (n0 + n1 + n2 + n3); 
 };
 
 // 4D simplex noise
@@ -207,24 +207,24 @@ SimplexNoise.prototype.noise4d = function( x, y, z, w ) {
 	var perm = this.perm;
 	
    // The skewing and unskewing factors are hairy again for the 4D case
-   var F4 = (Math.sqrt(5.0) - 1.0) / 4.0;
-   var G4 = (5.0 - Math.sqrt(5.0)) / 20.0;
-   var n0, n1, n2, n3, n4; // Noise contributions from the five corners
+	var F4 = (Math.sqrt(5.0) - 1.0) / 4.0;
+	var G4 = (5.0 - Math.sqrt(5.0)) / 20.0;
+	var n0, n1, n2, n3, n4; // Noise contributions from the five corners
    // Skew the (x,y,z,w) space to determine which cell of 24 simplices we're in
-   var s = (x + y + z + w) * F4; // Factor for 4D skewing
-   var i = Math.floor(x + s);
-   var j = Math.floor(y + s);
-   var k = Math.floor(z + s);
-   var l = Math.floor(w + s);
-   var t = (i + j + k + l) * G4; // Factor for 4D unskewing
-   var X0 = i - t; // Unskew the cell origin back to (x,y,z,w) space
-   var Y0 = j - t;
-   var Z0 = k - t;
-   var W0 = l - t;
-   var x0 = x - X0;  // The x,y,z,w distances from the cell origin
-   var y0 = y - Y0;
-   var z0 = z - Z0;
-   var w0 = w - W0;
+	var s = (x + y + z + w) * F4; // Factor for 4D skewing
+	var i = Math.floor(x + s);
+	var j = Math.floor(y + s);
+	var k = Math.floor(z + s);
+	var l = Math.floor(w + s);
+	var t = (i + j + k + l) * G4; // Factor for 4D unskewing
+	var X0 = i - t; // Unskew the cell origin back to (x,y,z,w) space
+	var Y0 = j - t;
+	var Z0 = k - t;
+	var W0 = l - t;
+	var x0 = x - X0;  // The x,y,z,w distances from the cell origin
+	var y0 = y - Y0;
+	var z0 = z - Z0;
+	var w0 = w - W0;
 
    // For the 4D case, the simplex is a 4D shape I won't even try to describe.
    // To find out which of the 24 possible simplices we're in, we need to
@@ -234,91 +234,91 @@ SimplexNoise.prototype.noise4d = function( x, y, z, w ) {
    // First, six pair-wise comparisons are performed between each possible pair
    // of the four coordinates, and the results are used to add up binary bits
    // for an integer index.
-   var c1 = (x0 > y0) ? 32 : 0;
-   var c2 = (x0 > z0) ? 16 : 0;
-   var c3 = (y0 > z0) ? 8 : 0;
-   var c4 = (x0 > w0) ? 4 : 0;
-   var c5 = (y0 > w0) ? 2 : 0;
-   var c6 = (z0 > w0) ? 1 : 0;
-   var c = c1 + c2 + c3 + c4 + c5 + c6;
-   var i1, j1, k1, l1; // The integer offsets for the second simplex corner
-   var i2, j2, k2, l2; // The integer offsets for the third simplex corner
-   var i3, j3, k3, l3; // The integer offsets for the fourth simplex corner
+	var c1 = (x0 > y0) ? 32 : 0;
+	var c2 = (x0 > z0) ? 16 : 0;
+	var c3 = (y0 > z0) ? 8 : 0;
+	var c4 = (x0 > w0) ? 4 : 0;
+	var c5 = (y0 > w0) ? 2 : 0;
+	var c6 = (z0 > w0) ? 1 : 0;
+	var c = c1 + c2 + c3 + c4 + c5 + c6;
+	var i1, j1, k1, l1; // The integer offsets for the second simplex corner
+	var i2, j2, k2, l2; // The integer offsets for the third simplex corner
+	var i3, j3, k3, l3; // The integer offsets for the fourth simplex corner
    // simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some order.
    // Many values of c will never occur, since e.g. x>y>z>w makes x<z, y<w and x<w
    // impossible. Only the 24 indices which have non-zero entries make any sense.
    // We use a thresholding to set the coordinates in turn from the largest magnitude.
    // The number 3 in the "simplex" array is at the position of the largest coordinate.
-   i1 = simplex[c][0] >= 3 ? 1 : 0;
-   j1 = simplex[c][1] >= 3 ? 1 : 0;
-   k1 = simplex[c][2] >= 3 ? 1 : 0;
-   l1 = simplex[c][3] >= 3 ? 1 : 0;
+	i1 = simplex[c][0] >= 3 ? 1 : 0;
+	j1 = simplex[c][1] >= 3 ? 1 : 0;
+	k1 = simplex[c][2] >= 3 ? 1 : 0;
+	l1 = simplex[c][3] >= 3 ? 1 : 0;
    // The number 2 in the "simplex" array is at the second largest coordinate.
-   i2 = simplex[c][0] >= 2 ? 1 : 0;
-   j2 = simplex[c][1] >= 2 ? 1 : 0;    k2 = simplex[c][2] >= 2 ? 1 : 0;
-   l2 = simplex[c][3] >= 2 ? 1 : 0;
+	i2 = simplex[c][0] >= 2 ? 1 : 0;
+	j2 = simplex[c][1] >= 2 ? 1 : 0;    k2 = simplex[c][2] >= 2 ? 1 : 0;
+	l2 = simplex[c][3] >= 2 ? 1 : 0;
    // The number 1 in the "simplex" array is at the second smallest coordinate.
-   i3 = simplex[c][0] >= 1 ? 1 : 0;
-   j3 = simplex[c][1] >= 1 ? 1 : 0;
-   k3 = simplex[c][2] >= 1 ? 1 : 0;
-   l3 = simplex[c][3] >= 1 ? 1 : 0;
+	i3 = simplex[c][0] >= 1 ? 1 : 0;
+	j3 = simplex[c][1] >= 1 ? 1 : 0;
+	k3 = simplex[c][2] >= 1 ? 1 : 0;
+	l3 = simplex[c][3] >= 1 ? 1 : 0;
    // The fifth corner has all coordinate offsets = 1, so no need to look that up.
-   var x1 = x0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords
-   var y1 = y0 - j1 + G4;
-   var z1 = z0 - k1 + G4;
-   var w1 = w0 - l1 + G4;
-   var x2 = x0 - i2 + 2.0 * G4; // Offsets for third corner in (x,y,z,w) coords
-   var y2 = y0 - j2 + 2.0 * G4;
-   var z2 = z0 - k2 + 2.0 * G4;
-   var w2 = w0 - l2 + 2.0 * G4;
-   var x3 = x0 - i3 + 3.0 * G4; // Offsets for fourth corner in (x,y,z,w) coords
-   var y3 = y0 - j3 + 3.0 * G4;
-   var z3 = z0 - k3 + 3.0 * G4;
-   var w3 = w0 - l3 + 3.0 * G4;
-   var x4 = x0 - 1.0 + 4.0 * G4; // Offsets for last corner in (x,y,z,w) coords
-   var y4 = y0 - 1.0 + 4.0 * G4;
-   var z4 = z0 - 1.0 + 4.0 * G4;
-   var w4 = w0 - 1.0 + 4.0 * G4;
+	var x1 = x0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords
+	var y1 = y0 - j1 + G4;
+	var z1 = z0 - k1 + G4;
+	var w1 = w0 - l1 + G4;
+	var x2 = x0 - i2 + 2.0 * G4; // Offsets for third corner in (x,y,z,w) coords
+	var y2 = y0 - j2 + 2.0 * G4;
+	var z2 = z0 - k2 + 2.0 * G4;
+	var w2 = w0 - l2 + 2.0 * G4;
+	var x3 = x0 - i3 + 3.0 * G4; // Offsets for fourth corner in (x,y,z,w) coords
+	var y3 = y0 - j3 + 3.0 * G4;
+	var z3 = z0 - k3 + 3.0 * G4;
+	var w3 = w0 - l3 + 3.0 * G4;
+	var x4 = x0 - 1.0 + 4.0 * G4; // Offsets for last corner in (x,y,z,w) coords
+	var y4 = y0 - 1.0 + 4.0 * G4;
+	var z4 = z0 - 1.0 + 4.0 * G4;
+	var w4 = w0 - 1.0 + 4.0 * G4;
    // Work out the hashed gradient indices of the five simplex corners
-   var ii = i & 255;
-   var jj = j & 255;
-   var kk = k & 255;
-   var ll = l & 255;
-   var gi0 = perm[ii + perm[jj + perm[kk + perm[ll]]]] % 32;
-   var gi1 = perm[ii + i1 + perm[jj + j1 + perm[kk + k1 + perm[ll + l1]]]] % 32;
-   var gi2 = perm[ii + i2 + perm[jj + j2 + perm[kk + k2 + perm[ll + l2]]]] % 32;
-   var gi3 = perm[ii + i3 + perm[jj + j3 + perm[kk + k3 + perm[ll + l3]]]] % 32;
-   var gi4 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] % 32;
+	var ii = i & 255;
+	var jj = j & 255;
+	var kk = k & 255;
+	var ll = l & 255;
+	var gi0 = perm[ii + perm[jj + perm[kk + perm[ll]]]] % 32;
+	var gi1 = perm[ii + i1 + perm[jj + j1 + perm[kk + k1 + perm[ll + l1]]]] % 32;
+	var gi2 = perm[ii + i2 + perm[jj + j2 + perm[kk + k2 + perm[ll + l2]]]] % 32;
+	var gi3 = perm[ii + i3 + perm[jj + j3 + perm[kk + k3 + perm[ll + l3]]]] % 32;
+	var gi4 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] % 32;
    // Calculate the contribution from the five corners
-   var t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0;
-   if (t0 < 0) n0 = 0.0;
-   else {
-     t0 *= t0;
-     n0 = t0 * t0 * this.dot4(grad4[gi0], x0, y0, z0, w0);
-   }
-  var t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1;
-   if (t1 < 0) n1 = 0.0;
-   else {
-     t1 *= t1;
-     n1 = t1 * t1 * this.dot4(grad4[gi1], x1, y1, z1, w1);
-   }
-  var t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2;
-   if (t2 < 0) n2 = 0.0;
-   else {
-     t2 *= t2;
-     n2 = t2 * t2 * this.dot4(grad4[gi2], x2, y2, z2, w2);
-   }   var t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3;
-   if (t3 < 0) n3 = 0.0;
-   else {
-     t3 *= t3;
-     n3 = t3 * t3 * this.dot4(grad4[gi3], x3, y3, z3, w3);
-   }
-  var t4 = 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4;
-   if (t4 < 0) n4 = 0.0;
-   else {
-     t4 *= t4;
-     n4 = t4 * t4 * this.dot4(grad4[gi4], x4, y4, z4, w4);
-   }
+	var t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0;
+	if (t0 < 0) n0 = 0.0;
+	else {
+		t0 *= t0;
+		n0 = t0 * t0 * this.dot4(grad4[gi0], x0, y0, z0, w0);
+	}
+	var t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1;
+	if (t1 < 0) n1 = 0.0;
+	else {
+		t1 *= t1;
+		n1 = t1 * t1 * this.dot4(grad4[gi1], x1, y1, z1, w1);
+	}
+	var t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2;
+	if (t2 < 0) n2 = 0.0;
+	else {
+		t2 *= t2;
+		n2 = t2 * t2 * this.dot4(grad4[gi2], x2, y2, z2, w2);
+	}   var t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3;
+	if (t3 < 0) n3 = 0.0;
+	else {
+		t3 *= t3;
+		n3 = t3 * t3 * this.dot4(grad4[gi3], x3, y3, z3, w3);
+	}
+	var t4 = 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4;
+	if (t4 < 0) n4 = 0.0;
+	else {
+		t4 *= t4;
+		n4 = t4 * t4 * this.dot4(grad4[gi4], x4, y4, z4, w4);
+	}
    // Sum up and scale the result to cover the range [-1,1]
-   return 27.0 * (n0 + n1 + n2 + n3 + n4);
+	return 27.0 * (n0 + n1 + n2 + n3 + n4);
 };

+ 145 - 145
examples/js/Sparks.js

@@ -19,18 +19,18 @@ var SPARKS = {};
 
 SPARKS.Emitter = function (counter) {
 
-    this._counter = counter ? counter : new SPARKS.SteadyCounter(10); // provides number of particles to produce
+	this._counter = counter ? counter : new SPARKS.SteadyCounter(10); // provides number of particles to produce
 
-    this._particles = [];
+	this._particles = [];
 
 
-    this._initializers = []; // use for creation of particles
-    this._actions = [];     // uses action to update particles
-    this._activities = [];  //  not supported yet
+	this._initializers = []; // use for creation of particles
+	this._actions = [];     // uses action to update particles
+	this._activities = [];  //  not supported yet
 
-    this._handlers = [];
+	this._handlers = [];
 
-    this.callbacks = {};
+	this.callbacks = {};
 };
 
 
@@ -99,108 +99,108 @@ SPARKS.Emitter.prototype = {
 	// Update particle engine in seconds, not milliseconds
     update: function(time) {
 
-		var i, j;
-        var len = this._counter.updateEmitter( this, time );
+	var i, j;
+	var len = this._counter.updateEmitter( this, time );
 
         // Create particles
-        for ( i = 0; i < len; i ++ ) {
-            this.createParticle();
-        }
+	for ( i = 0; i < len; i ++ ) {
+		this.createParticle();
+	}
 
         // Update activities
-        len = this._activities.length;
-        for ( i = 0; i < len; i ++ )
+	len = this._activities.length;
+	for ( i = 0; i < len; i ++ )
         {
-            this._activities[i].update( this, time );
-        }
+		this._activities[i].update( this, time );
+	}
 
 
-        len = this._actions.length;
+	len = this._actions.length;
 
-		var particle;
-		var action;
-        var len2 = this._particles.length;
+	var particle;
+	var action;
+	var len2 = this._particles.length;
 
-        for ( j = 0; j < len; j ++ )
+	for ( j = 0; j < len; j ++ )
         {
-            action = this._actions[j];
-            for ( i = 0; i < len2; ++ i )
+		action = this._actions[j];
+		for ( i = 0; i < len2; ++ i )
             {
-                particle = this._particles[i];
-                action.update( this, particle, time );
-            }
-        }
+			particle = this._particles[i];
+			action.update( this, particle, time );
+		}
+	}
 
 
         // remove dead particles
-        for ( i = len2; i --; )
+	for ( i = len2; i --; )
         {
-            particle = this._particles[i];
-            if ( particle.isDead )
+		particle = this._particles[i];
+		if ( particle.isDead )
             {
                 //particle =
-				this._particles.splice( i, 1 );
-                this.dispatchEvent("dead", particle);
-				SPARKS.VectorPool.release(particle.position); //
-				SPARKS.VectorPool.release(particle.velocity);
+			this._particles.splice( i, 1 );
+			this.dispatchEvent("dead", particle);
+			SPARKS.VectorPool.release(particle.position); //
+			SPARKS.VectorPool.release(particle.velocity);
 
-            } else {
-                this.dispatchEvent("updated", particle);
-            }
-        }
+		} else {
+			this.dispatchEvent("updated", particle);
+		}
+	}
 
-		this.dispatchEvent("loopUpdated");
+	this.dispatchEvent("loopUpdated");
 
     },
 
     createParticle: function() {
-        var particle = new SPARKS.Particle();
+	var particle = new SPARKS.Particle();
         // In future, use a Particle Factory
-        var len = this._initializers.length, i;
+	var len = this._initializers.length, i;
 
-        for ( i = 0; i < len; i ++ ) {
-            this._initializers[i].initialize( this, particle );
-        }
+	for ( i = 0; i < len; i ++ ) {
+		this._initializers[i].initialize( this, particle );
+	}
 
-        this._particles.push( particle );
+	this._particles.push( particle );
 
-        this.dispatchEvent("created", particle); // ParticleCreated
+	this.dispatchEvent("created", particle); // ParticleCreated
 
-        return particle;
+	return particle;
     },
 
     addInitializer: function (initializer) {
-        this._initializers.push(initializer);
+	this._initializers.push(initializer);
     },
 
     addAction: function (action) {
-        this._actions.push(action);
+	this._actions.push(action);
     },
 
     removeInitializer: function (initializer) {
-		var index = this._initializers.indexOf(initializer);
-		if (index > -1) {
-			this._initializers.splice( index, 1 );
-		}
+	var index = this._initializers.indexOf(initializer);
+	if (index > -1) {
+		this._initializers.splice( index, 1 );
+	}
     },
 
     removeAction: function (action) {
-		var index = this._actions.indexOf(action);
-		if (index > -1) {
-			this._actions.splice( index, 1 );
-		}
+	var index = this._actions.indexOf(action);
+	if (index > -1) {
+		this._actions.splice( index, 1 );
+	}
 		//console.log('removeAction', index, this._actions);
     },
 
     addCallback: function(name, callback) {
-        this.callbacks[name] = callback;
+	this.callbacks[name] = callback;
     },
 
     dispatchEvent: function(name, args) {
-        var callback = this.callbacks[name];
-        if (callback) {
-            callback(args);
-        }
+	var callback = this.callbacks[name];
+	if (callback) {
+		callback(args);
+	}
 
     }
 
@@ -227,7 +227,7 @@ SPARKS.EVENT_LOOP_UPDATED = "loopUpdated";
 
 // Number of particles per seconds
 SPARKS.SteadyCounter = function(rate) {
-    this.rate = rate;
+	this.rate = rate;
 
 	// we use a shortfall counter to make up for slow emitters
 	this.leftover = 0;
@@ -277,31 +277,31 @@ SPARKS.Particle = function() {
     /**
      * The lifetime of the particle, in seconds.
      */
-    this.lifetime = 0;
+	this.lifetime = 0;
 
     /**
      * The age of the particle, in seconds.
      */
-    this.age = 0;
+	this.age = 0;
 
     /**
      * The energy of the particle.
      */
-    this.energy = 1;
+	this.energy = 1;
 
     /**
      * Whether the particle is dead and should be removed from the stage.
      */
-    this.isDead = false;
+	this.isDead = false;
 
-    this.target = null; // tag
+	this.target = null; // tag
 
     /**
      * For 3D
      */
 
-     this.position = SPARKS.VectorPool.get().set(0, 0, 0); //new THREE.Vector3( 0, 0, 0 );
-     this.velocity = SPARKS.VectorPool.get().set(0, 0, 0); //new THREE.Vector3( 0, 0, 0 );
+	this.position = SPARKS.VectorPool.get().set(0, 0, 0); //new THREE.Vector3( 0, 0, 0 );
+	this.velocity = SPARKS.VectorPool.get().set(0, 0, 0); //new THREE.Vector3( 0, 0, 0 );
 	this._oldvelocity = SPARKS.VectorPool.get().set(0, 0, 0);
      // rotation vec3
      // angVelocity vec3
@@ -317,26 +317,26 @@ SPARKS.Particle = function() {
 *   update function
 *********************************/
 SPARKS.Action = function() {
-    this._priority = 0;
+	this._priority = 0;
 };
 
 
 SPARKS.Age = function(easing) {
-    this._easing = (easing == null) ? TWEEN.Easing.Linear.None : easing;
+	this._easing = (easing == null) ? TWEEN.Easing.Linear.None : easing;
 };
 
 SPARKS.Age.prototype.update = function (emitter, particle, time) {
-    particle.age += time;
-    if ( particle.age >= particle.lifetime )
+	particle.age += time;
+	if ( particle.age >= particle.lifetime )
     {
-        particle.energy = 0;
-        particle.isDead = true;
-    }
+		particle.energy = 0;
+		particle.isDead = true;
+	}
     else
-    {
-        var t = this._easing(particle.age / particle.lifetime);
-        particle.energy = -1 * t + 1;
-    }
+	{
+		var t = this._easing(particle.age / particle.lifetime);
+		particle.energy = -1 * t + 1;
+	}
 };
 
 /*
@@ -360,9 +360,9 @@ SPARKS.Move = function() {
 
 SPARKS.Move.prototype.update = function(emitter, particle, time) {
     // attempt verlet velocity updating.
-    var p = particle.position;
+	var p = particle.position;
 	var v = particle.velocity;
-    var old = particle._oldvelocity;
+	var old = particle._oldvelocity;
 
 	if (this._velocityVerlet) {
 		p.x += (v.x + old.x) * 0.5 * time;
@@ -384,12 +384,12 @@ SPARKS.Move.prototype.update = function(emitter, particle, time) {
 
 /* Marks particles found in specified zone dead */
 SPARKS.DeathZone = function(zone) {
-    this.zone = zone;
+	this.zone = zone;
 };
 
 SPARKS.DeathZone.prototype.update = function(emitter, particle, time) {
 
-    if (this.zone.contains(particle.position)) {
+	if (this.zone.contains(particle.position)) {
 		particle.isDead = true;
 	}
 
@@ -400,12 +400,12 @@ SPARKS.DeathZone.prototype.update = function(emitter, particle, time) {
  */
 SPARKS.ActionZone = function(action, zone) {
 	this.action = action;
-    this.zone = zone;
+	this.zone = zone;
 };
 
 SPARKS.ActionZone.prototype.update = function(emitter, particle, time) {
 
-    if (this.zone.contains(particle.position)) {
+	if (this.zone.contains(particle.position)) {
 		this.action.update( emitter, particle, time );
 	}
 
@@ -421,20 +421,20 @@ SPARKS.Accelerate = function(x,y,z) {
 		return;
 	}
 
-    this.acceleration = new THREE.Vector3(x,y,z);
+	this.acceleration = new THREE.Vector3(x,y,z);
 
 };
 
 SPARKS.Accelerate.prototype.update = function(emitter, particle, time) {
-    var acc = this.acceleration;
+	var acc = this.acceleration;
 
-    var v = particle.velocity;
+	var v = particle.velocity;
 
 	particle._oldvelocity.set(v.x, v.y, v.z);
 
-    v.x += acc.x * time;
-    v.y += acc.y * time;
-    v.z += acc.z * time;
+	v.x += acc.x * time;
+	v.y += acc.y * time;
+	v.z += acc.z * time;
 
 };
 
@@ -442,16 +442,16 @@ SPARKS.Accelerate.prototype.update = function(emitter, particle, time) {
  * Accelerate Factor accelerate based on a factor of particle's velocity.
  */
 SPARKS.AccelerateFactor = function(factor) {
-    this.factor = factor;
+	this.factor = factor;
 };
 
 SPARKS.AccelerateFactor.prototype.update = function(emitter, particle, time) {
-    var factor = this.factor;
+	var factor = this.factor;
 
-    var v = particle.velocity;
+	var v = particle.velocity;
 	var len = v.length();
 	var adjFactor;
-    if (len > 0) {
+	if (len > 0) {
 
 		adjFactor = factor * time / len;
 		adjFactor += 1;
@@ -475,14 +475,14 @@ SPARKS.AccelerateVelocity = function(factor) {
 };
 
 SPARKS.AccelerateVelocity.prototype.update = function(emitter, particle, time) {
-    var factor = this.factor;
+	var factor = this.factor;
 
-    var v = particle.velocity;
+	var v = particle.velocity;
 
 
-    v.z += - v.x * factor;
-    v.y += v.z * factor;
-    v.x +=  v.y * factor;
+	v.z += - v.x * factor;
+	v.y += v.z * factor;
+	v.x +=  v.y * factor;
 
 };
 
@@ -494,18 +494,18 @@ SPARKS.RandomDrift = function(x,y,z) {
 		return;
 	}
 
-    this.drift = new THREE.Vector3(x,y,z);
+	this.drift = new THREE.Vector3(x,y,z);
 }
 
 
 SPARKS.RandomDrift.prototype.update = function(emitter, particle, time) {
-    var drift = this.drift;
+	var drift = this.drift;
 
-    var v = particle.velocity;
+	var v = particle.velocity;
 
-    v.x += ( Math.random() - 0.5 ) * drift.x * time;
-    v.y += ( Math.random() - 0.5 ) * drift.y * time;
-    v.z += ( Math.random() - 0.5 ) * drift.z * time;
+	v.x += ( Math.random() - 0.5 ) * drift.x * time;
+	v.y += ( Math.random() - 0.5 ) * drift.y * time;
+	v.z += ( Math.random() - 0.5 ) * drift.z * time;
 
 };
 
@@ -521,29 +521,29 @@ SPARKS.Zone = function() {
 // TODO, contains() for Zone
 
 SPARKS.PointZone = function(pos) {
-    this.pos = pos;
+	this.pos = pos;
 };
 
 SPARKS.PointZone.prototype.getLocation = function() {
-    return this.pos;
+	return this.pos;
 };
 
 SPARKS.PointZone = function(pos) {
-    this.pos = pos;
+	this.pos = pos;
 };
 
 SPARKS.PointZone.prototype.getLocation = function() {
-    return this.pos;
+	return this.pos;
 };
 
 SPARKS.LineZone = function(start, end) {
-    this.start = start;
+	this.start = start;
 	this.end = end;
 	this._length = end.clone().sub( start );
 };
 
 SPARKS.LineZone.prototype.getLocation = function() {
-    var len = this._length.clone();
+	var len = this._length.clone();
 
 	len.multiplyScalar( Math.random() );
 	return len.add( this.start );
@@ -552,7 +552,7 @@ SPARKS.LineZone.prototype.getLocation = function() {
 
 // Basically a RectangleZone
 SPARKS.ParallelogramZone = function(corner, side1, side2) {
-    this.corner = corner;
+	this.corner = corner;
 	this.side1 = side1;
 	this.side2 = side2;
 };
@@ -567,7 +567,7 @@ SPARKS.ParallelogramZone.prototype.getLocation = function() {
 };
 
 SPARKS.CubeZone = function(position, x, y, z) {
-    this.position = position;
+	this.position = position;
 	this.x = x;
 	this.y = y;
 	this.z = z;
@@ -674,29 +674,29 @@ SPARKS.DiscZone.prototype.getLocation = function() {
 */
 
 SPARKS.SphereCapZone = function(x, y, z, minr, maxr, angle) {
-    this.x = x;
-    this.y = y;
-    this.z = z;
-    this.minr = minr;
-    this.maxr = maxr;
-    this.angle = angle;
+	this.x = x;
+	this.y = y;
+	this.z = z;
+	this.minr = minr;
+	this.maxr = maxr;
+	this.angle = angle;
 };
 
 SPARKS.SphereCapZone.prototype.getLocation = function() {
-    var theta = Math.PI * 2  * SPARKS.Utils.random();
-    var r = SPARKS.Utils.random();
+	var theta = Math.PI * 2  * SPARKS.Utils.random();
+	var r = SPARKS.Utils.random();
 
     //new THREE.Vector3
-    var v =  SPARKS.VectorPool.get().set(r * Math.cos(theta), -1 / Math.tan(this.angle * SPARKS.Utils.DEGREE_TO_RADIAN), r * Math.sin(theta));
+	var v =  SPARKS.VectorPool.get().set(r * Math.cos(theta), -1 / Math.tan(this.angle * SPARKS.Utils.DEGREE_TO_RADIAN), r * Math.sin(theta));
 
     //v.length = StardustMath.interpolate(0, _minRadius, 1, _maxRadius, Math.random());
 
-    var i = this.minr - ((this.minr - this.maxr) *  Math.random() );
-    v.multiplyScalar(i);
+	var i = this.minr - ((this.minr - this.maxr) *  Math.random() );
+	v.multiplyScalar(i);
 
 	v.__markedForReleased = true;
 
-    return v;
+	return v;
 };
 
 
@@ -709,33 +709,33 @@ SPARKS.SphereCapZone.prototype.getLocation = function() {
 
 // Specifies random life between max and min
 SPARKS.Lifetime = function(min, max) {
-    this._min = min;
+	this._min = min;
 
-    this._max = max ? max : min;
+	this._max = max ? max : min;
 
 };
 
 SPARKS.Lifetime.prototype.initialize = function( emitter/*Emitter*/, particle/*Particle*/ ) {
-    particle.lifetime = this._min + SPARKS.Utils.random() * ( this._max - this._min );
+	particle.lifetime = this._min + SPARKS.Utils.random() * ( this._max - this._min );
 };
 
 
 SPARKS.Position = function(zone) {
-    this.zone = zone;
+	this.zone = zone;
 };
 
 SPARKS.Position.prototype.initialize = function( emitter/*Emitter*/, particle/*Particle*/ ) {
-    var pos = this.zone.getLocation();
-    particle.position.set(pos.x, pos.y, pos.z);
+	var pos = this.zone.getLocation();
+	particle.position.set(pos.x, pos.y, pos.z);
 };
 
 SPARKS.Velocity = function(zone) {
-    this.zone = zone;
+	this.zone = zone;
 };
 
 SPARKS.Velocity.prototype.initialize = function( emitter/*Emitter*/, particle/*Particle*/ ) {
-    var pos = this.zone.getLocation();
-    particle.velocity.set(pos.x, pos.y, pos.z);
+	var pos = this.zone.getLocation();
+	particle.velocity.set(pos.x, pos.y, pos.z);
 	if (pos.__markedForReleased) {
 		//console.log("release");
 		SPARKS.VectorPool.release(pos);
@@ -744,17 +744,17 @@ SPARKS.Velocity.prototype.initialize = function( emitter/*Emitter*/, particle/*P
 };
 
 SPARKS.Target = function(target, callback) {
-    this.target = target;
-    this.callback = callback;
+	this.target = target;
+	this.callback = callback;
 };
 
 SPARKS.Target.prototype.initialize = function( emitter, particle ) {
 
-    if (this.callback) {
-        particle.target = this.callback();
-    } else {
-        particle.target = this.target;
-    }
+	if (this.callback) {
+		particle.target = this.callback();
+	} else {
+		particle.target = this.target;
+	}
 
 };
 
@@ -807,7 +807,7 @@ SPARKS.VectorPool = {
 *********************************/
 SPARKS.Utils = {
     random: function() {
-        return Math.random();
+	return Math.random();
     },
     DEGREE_TO_RADIAN: Math.PI / 180,
 	TWOPI: Math.PI * 2,

+ 25 - 25
examples/js/controls/MouseControls.js

@@ -6,50 +6,50 @@
 
 THREE.MouseControls = function ( object ) {
 
-  var scope = this;
-  var PI_2 = Math.PI / 2;
-  var mouseQuat = {
+	var scope = this;
+	var PI_2 = Math.PI / 2;
+	var mouseQuat = {
     x: new THREE.Quaternion(),
     y: new THREE.Quaternion()
   };
-  var object = object;
-  var xVector = new THREE.Vector3( 1, 0, 0 );
-  var yVector = new THREE.Vector3( 0, 1, 0 );
+	var object = object;
+	var xVector = new THREE.Vector3( 1, 0, 0 );
+	var yVector = new THREE.Vector3( 0, 1, 0 );
 
-  var onMouseMove = function ( event ) {
+	var onMouseMove = function ( event ) {
 
-    if ( scope.enabled === false ) return;
+		if ( scope.enabled === false ) return;
 
-    var orientation = scope.orientation;
+		var orientation = scope.orientation;
 
-    var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
-    var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
+		var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
+		var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
 
-    orientation.y += movementX * 0.0025;
-    orientation.x += movementY * 0.0025;
+		orientation.y += movementX * 0.0025;
+		orientation.x += movementY * 0.0025;
 
-    orientation.x = Math.max( - PI_2, Math.min( PI_2, orientation.x ) );
+		orientation.x = Math.max( - PI_2, Math.min( PI_2, orientation.x ) );
 
-  };
+	};
 
-  this.enabled = true;
+	this.enabled = true;
 
-  this.orientation = {
+	this.orientation = {
     x: 0,
     y: 0,
   };
 
-  this.update = function() {
+	this.update = function() {
 
-    if ( this.enabled === false ) return;
+		if ( this.enabled === false ) return;
 
-    mouseQuat.x.setFromAxisAngle( xVector, this.orientation.x );
-    mouseQuat.y.setFromAxisAngle( yVector, this.orientation.y );
-    object.quaternion.copy(mouseQuat.y).multiply(mouseQuat.x)
-    return;
+		mouseQuat.x.setFromAxisAngle( xVector, this.orientation.x );
+		mouseQuat.y.setFromAxisAngle( yVector, this.orientation.y );
+		object.quaternion.copy(mouseQuat.y).multiply(mouseQuat.x)
+		return;
 
-  };
+	};
 
-  document.addEventListener( 'mousemove', onMouseMove, false );
+	document.addEventListener( 'mousemove', onMouseMove, false );
 
 };

+ 12 - 12
examples/js/controls/TransformControls.js

@@ -30,8 +30,8 @@
 
 			} else {
 
-					this.color.copy( this.oldColor );
-					this.opacity = this.oldOpacity;
+				this.color.copy( this.oldColor );
+				this.opacity = this.oldOpacity;
 
 			}
 
@@ -65,8 +65,8 @@
 
 			} else {
 
-					this.color.copy( this.oldColor );
-					this.opacity = this.oldOpacity;
+				this.color.copy( this.oldColor );
+				this.opacity = this.oldOpacity;
 
 			}
 
@@ -331,15 +331,15 @@
 
 		var CircleGeometry = function ( radius, facing, arc ) {
 
-				var geometry = new THREE.Geometry();
-				arc = arc ? arc : 1;
-				for ( var i = 0; i <= 64 * arc; ++ i ) {
-					if ( facing == 'x' ) geometry.vertices.push( new THREE.Vector3( 0, Math.cos( i / 32 * Math.PI ), Math.sin( i / 32 * Math.PI ) ).multiplyScalar(radius) );
-					if ( facing == 'y' ) geometry.vertices.push( new THREE.Vector3( Math.cos( i / 32 * Math.PI ), 0, Math.sin( i / 32 * Math.PI ) ).multiplyScalar(radius) );
-					if ( facing == 'z' ) geometry.vertices.push( new THREE.Vector3( Math.sin( i / 32 * Math.PI ), Math.cos( i / 32 * Math.PI ), 0 ).multiplyScalar(radius) );
-				}
+			var geometry = new THREE.Geometry();
+			arc = arc ? arc : 1;
+			for ( var i = 0; i <= 64 * arc; ++ i ) {
+				if ( facing == 'x' ) geometry.vertices.push( new THREE.Vector3( 0, Math.cos( i / 32 * Math.PI ), Math.sin( i / 32 * Math.PI ) ).multiplyScalar(radius) );
+				if ( facing == 'y' ) geometry.vertices.push( new THREE.Vector3( Math.cos( i / 32 * Math.PI ), 0, Math.sin( i / 32 * Math.PI ) ).multiplyScalar(radius) );
+				if ( facing == 'z' ) geometry.vertices.push( new THREE.Vector3( Math.sin( i / 32 * Math.PI ), Math.cos( i / 32 * Math.PI ), 0 ).multiplyScalar(radius) );
+			}
 
-				return geometry;
+			return geometry;
 		};
 
 		this.handleGizmos = {

+ 1 - 1
examples/js/effects/VREffect.js

@@ -56,7 +56,7 @@ THREE.VREffect = function ( renderer, done ) {
 			}
 			if ( done ) {
 				if ( !vrHMD ) {
-				 error = 'HMD not available';
+					error = 'HMD not available';
 				}
 				done( error );
 			}

+ 5 - 5
examples/js/geometries/ConvexGeometry.js

@@ -176,14 +176,14 @@ THREE.ConvexGeometry = function( vertices ) {
 
 		 for ( var j = 0; j < 3; j ++ ) {
 
-				if ( newId[ face[ j ] ] === undefined ) {
+			if ( newId[ face[ j ] ] === undefined ) {
 
-						newId[ face[ j ] ] = id ++;
-						this.vertices.push( vertices[ face[ j ] ] );
+				newId[ face[ j ] ] = id ++;
+				this.vertices.push( vertices[ face[ j ] ] );
 
-				}
+			}
 
-				face[ j ] = newId[ face[ j ] ];
+			face[ j ] = newId[ face[ j ] ];
 
 		 }
 

+ 2 - 2
examples/js/geometries/DecalGeometry.js

@@ -191,8 +191,8 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
 				vertices = this.clipFace( vertices, new THREE.Vector3( -1, 0, 0 ) );
 			}
 			if ( check.y ) {
-			   	vertices = this.clipFace( vertices, new THREE.Vector3( 0, 1, 0 ) );
-			   	vertices = this.clipFace( vertices, new THREE.Vector3( 0, -1, 0 ) );
+				vertices = this.clipFace( vertices, new THREE.Vector3( 0, 1, 0 ) );
+				vertices = this.clipFace( vertices, new THREE.Vector3( 0, -1, 0 ) );
 			}
 			if ( check.z ) {
 				vertices = this.clipFace( vertices, new THREE.Vector3( 0, 0, 1 ) );

Разница между файлами не показана из-за своего большого размера
+ 345 - 345
examples/js/loaders/AWDLoader.js


+ 26 - 26
examples/js/loaders/ColladaLoader.js

@@ -735,7 +735,7 @@ THREE.ColladaLoader = function () {
 
 		// move vertices to bind shape
 		for ( i = 0; i < geometry.vertices.length; i ++ ) {
-					geometry.vertices[i].applyMatrix4( skinController.skin.bindShapeMatrix );
+			geometry.vertices[i].applyMatrix4( skinController.skin.bindShapeMatrix );
 		}
 
 		var skinIndices = [];
@@ -1343,17 +1343,17 @@ THREE.ColladaLoader = function () {
 
 	function getLibraryNode( id ) {
 
-        var nodes = COLLADA.querySelectorAll('library_nodes node');
+		var nodes = COLLADA.querySelectorAll('library_nodes node');
 
-        for ( var i = 0; i < nodes.length; i ++ ) {
+		for ( var i = 0; i < nodes.length; i ++ ) {
 
-            var attObj = nodes[i].attributes.getNamedItem('id');
-            if ( attObj && attObj.value === id ) {
-                return nodes[i];
-        }
-        }
+			var attObj = nodes[i].attributes.getNamedItem('id');
+			if ( attObj && attObj.value === id ) {
+				return nodes[i];
+			}
+		}
 
-        return undefined;
+		return undefined;
 
 	};
 
@@ -3365,35 +3365,35 @@ THREE.ColladaLoader = function () {
 
 		//for (var i = 0; i < this.accessor.params.length; i++) {
 
-			var param = this.accessor.params[ 0 ];
+		var param = this.accessor.params[ 0 ];
 
 			//console.log(param.name + " " + param.type);
 
-			switch ( param.type ) {
+		switch ( param.type ) {
 
-				case 'IDREF':
-				case 'Name': case 'name':
-				case 'float':
+			case 'IDREF':
+			case 'Name': case 'name':
+			case 'float':
 
-					return this.data;
+				return this.data;
 
-				case 'float4x4':
+			case 'float4x4':
 
-					for ( var j = 0; j < this.data.length; j += 16 ) {
+				for ( var j = 0; j < this.data.length; j += 16 ) {
 
-						var s = this.data.slice( j, j + 16 );
-						var m = getConvertedMat4( s );
-						result.push( m );
-					}
+					var s = this.data.slice( j, j + 16 );
+					var m = getConvertedMat4( s );
+					result.push( m );
+				}
 
-					break;
+				break;
 
-				default:
+			default:
 
-					console.log( 'ColladaLoader: Source: Read dont know how to read ' + param.type + '.' );
-					break;
+				console.log( 'ColladaLoader: Source: Read dont know how to read ' + param.type + '.' );
+				break;
 
-			}
+		}
 
 		//}
 

+ 16 - 16
examples/js/loaders/PVRLoader.js

@@ -77,16 +77,16 @@ THREE.PVRLoader._parseV3 = function ( pvrDatas ) {
 	}
 
 	pvrDatas.dataPtr 	 = 52 + metaLen;
-  	pvrDatas.bpp 		 = bpp;
-  	pvrDatas.format 	 = format;
-  	pvrDatas.width 		 = width;
-  	pvrDatas.height 	 = height;
-  	pvrDatas.numSurfaces = numFaces;
-  	pvrDatas.numMipmaps  = numMipmaps;
+	pvrDatas.bpp 		 = bpp;
+	pvrDatas.format 	 = format;
+	pvrDatas.width 		 = width;
+	pvrDatas.height 	 = height;
+	pvrDatas.numSurfaces = numFaces;
+	pvrDatas.numMipmaps  = numMipmaps;
 
-  	pvrDatas.isCubemap 	= (numFaces === 6);
+	pvrDatas.isCubemap 	= (numFaces === 6);
 
-  	return THREE.PVRLoader._extract( pvrDatas );
+	return THREE.PVRLoader._extract( pvrDatas );
 };
 
 THREE.PVRLoader._parseV2 = function ( pvrDatas ) {
@@ -133,18 +133,18 @@ THREE.PVRLoader._parseV2 = function ( pvrDatas ) {
 
 
 	pvrDatas.dataPtr 	 = headerLength;
-  	pvrDatas.bpp 		 = bpp;
-  	pvrDatas.format 	 = format;
-  	pvrDatas.width 		 = width;
-  	pvrDatas.height 	 = height;
-  	pvrDatas.numSurfaces = numSurfs;
-  	pvrDatas.numMipmaps  = numMipmaps + 1;
+	pvrDatas.bpp 		 = bpp;
+	pvrDatas.format 	 = format;
+	pvrDatas.width 		 = width;
+	pvrDatas.height 	 = height;
+	pvrDatas.numSurfaces = numSurfs;
+	pvrDatas.numMipmaps  = numMipmaps + 1;
 
   	// guess cubemap type seems tricky in v2
   	// it juste a pvr containing 6 surface (no explicit cubemap type)
-  	pvrDatas.isCubemap 	= (numSurfs === 6);
+	pvrDatas.isCubemap 	= (numSurfs === 6);
 
-  	return THREE.PVRLoader._extract( pvrDatas );
+	return THREE.PVRLoader._extract( pvrDatas );
 
 };
 

+ 3 - 3
examples/js/loaders/RGBELoader.js

@@ -30,11 +30,11 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
 		rgbe_error = function(rgbe_error_code, msg) {
 			switch (rgbe_error_code) {
 				case rgbe_read_error: console.error("THREE.RGBELoader Read Error: " + (msg||''));
-				break;
+					break;
 				case rgbe_write_error: console.error("THREE.RGBELoader Write Error: " + (msg||''));
-				break;
+					break;
 				case rgbe_format_error:  console.error("THREE.RGBELoader Bad File Format: " + (msg||''));
-				break;
+					break;
 				default:
 				case rgbe_memory_error:  console.error("THREE.RGBELoader: Error: " + (msg||''));
 			}

+ 7 - 7
examples/js/loaders/STLLoader.js

@@ -110,15 +110,15 @@ THREE.STLLoader.prototype = {
 				(reader.getUint8(index + 4) == 0x52 /*'R'*/) &&
 				(reader.getUint8(index + 5) == 0x3D /*'='*/)) {
 
-					hasColors = true;
-					colors = new Float32Array( faces * 3 * 3);
+				hasColors = true;
+				colors = new Float32Array( faces * 3 * 3);
 
-					defaultR = reader.getUint8(index + 6) / 255;
-					defaultG = reader.getUint8(index + 7) / 255;
-					defaultB = reader.getUint8(index + 8) / 255;
-					alpha = reader.getUint8(index + 9) / 255;
-				}
+				defaultR = reader.getUint8(index + 6) / 255;
+				defaultG = reader.getUint8(index + 7) / 255;
+				defaultB = reader.getUint8(index + 8) / 255;
+				alpha = reader.getUint8(index + 9) / 255;
 			}
+		}
 
 		var dataOffset = 84;
 		var faceLength = 12 * 4 + 2;

+ 6 - 6
examples/js/loaders/TGALoader.js

@@ -154,8 +154,8 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
 			pixel_total,
 			palettes;
 
-			pixel_size = header.pixel_size >> 3;
-			pixel_total = header.width * header.height * pixel_size;
+		pixel_size = header.pixel_size >> 3;
+		pixel_total = header.width * header.height * pixel_size;
 
 		 // Read palettes
 		 if ( use_pal ) {
@@ -178,12 +178,12 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
 				if (c & 0x80) {
 					// Bind pixel tmp array
 					for (i = 0; i < pixel_size; ++ i) {
-							pixels[i] = data[offset ++];
+						pixels[i] = data[offset ++];
 					}
 
 					// Copy pixel array
 					for (i = 0; i < count; ++ i) {
-							pixel_data.set(pixels, shift + i * pixel_size);
+						pixel_data.set(pixels, shift + i * pixel_size);
 					}
 
 					shift += pixel_size * count;
@@ -192,7 +192,7 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
 					// Raw pixels.
 					count *= pixel_size;
 					for (i = 0; i < count; ++ i) {
-							pixel_data[shift + i] = data[offset ++];
+						pixel_data[shift + i] = data[offset ++];
 					}
 					shift += count;
 				}
@@ -214,7 +214,7 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
 
 		var colormap = palettes;
 		var color, i = 0, x, y;
-				var width = header.width;
+		var width = header.width;
 
 		for (y = y_start; y !== y_end; y += y_step) {
 			for (x = x_start; x !== x_end; x += x_step, i ++) {

+ 286 - 286
examples/js/loaders/UTF8Loader.js

@@ -94,12 +94,12 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray
 
 	}
 
-    geometry.addAttribute( 'index', new THREE.BufferAttribute( indices, 1 ) );
-    geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
-    geometry.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
-    geometry.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ) );
+	geometry.addAttribute( 'index', new THREE.BufferAttribute( indices, 1 ) );
+	geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
+	geometry.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
+	geometry.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ) );
 
-    geometry.offsets.push( { start: 0, count: indices.length, index: 0 } );
+	geometry.offsets.push( { start: 0, count: indices.length, index: 0 } );
 
 	geometry.computeBoundingSphere();
 
@@ -158,17 +158,17 @@ THREE.UTF8Loader.prototype.decompressAttribsInner_ = function ( str, inputStart,
                                                                   output, outputStart, stride,
                                                                   decodeOffset, decodeScale ) {
 
-    var prev = 0;
+	var prev = 0;
 
-    for ( var j = inputStart; j < inputEnd; j ++ ) {
+	for ( var j = inputStart; j < inputEnd; j ++ ) {
 
-        var code = str.charCodeAt( j );
-        prev += ( code >> 1 ) ^ ( -( code & 1 ) );
+		var code = str.charCodeAt( j );
+		prev += ( code >> 1 ) ^ ( -( code & 1 ) );
 
-        output[ outputStart ] = decodeScale * ( prev + decodeOffset );
-        outputStart += stride;
+		output[ outputStart ] = decodeScale * ( prev + decodeOffset );
+		outputStart += stride;
 
-    }
+	}
 
 };
 
@@ -177,52 +177,52 @@ THREE.UTF8Loader.prototype.decompressIndices_ = function( str, inputStart, numIn
 
 	var highest = 0;
 
-    for ( var i = 0; i < numIndices; i ++ ) {
+	for ( var i = 0; i < numIndices; i ++ ) {
 
-        var code = str.charCodeAt( inputStart ++ );
+		var code = str.charCodeAt( inputStart ++ );
 
-        output[ outputStart ++ ] = highest - code;
+		output[ outputStart ++ ] = highest - code;
 
-        if ( code === 0 ) {
+		if ( code === 0 ) {
 
-            highest ++;
+			highest ++;
 
-        }
+		}
 
-    }
+	}
 
 };
 
 THREE.UTF8Loader.prototype.decompressAABBs_ = function ( str, inputStart, numBBoxen,
                                                            decodeOffsets, decodeScales ) {
-    var numFloats = 6 * numBBoxen;
+	var numFloats = 6 * numBBoxen;
 
-    var inputEnd = inputStart + numFloats;
-    var outputStart = 0;
+	var inputEnd = inputStart + numFloats;
+	var outputStart = 0;
 
-    var bboxen = new Float32Array( numFloats );
+	var bboxen = new Float32Array( numFloats );
 
-    for ( var i = inputStart; i < inputEnd; i += 6 ) {
+	for ( var i = inputStart; i < inputEnd; i += 6 ) {
 
-        var minX = str.charCodeAt(i + 0) + decodeOffsets[0];
-        var minY = str.charCodeAt(i + 1) + decodeOffsets[1];
-        var minZ = str.charCodeAt(i + 2) + decodeOffsets[2];
+		var minX = str.charCodeAt(i + 0) + decodeOffsets[0];
+		var minY = str.charCodeAt(i + 1) + decodeOffsets[1];
+		var minZ = str.charCodeAt(i + 2) + decodeOffsets[2];
 
-        var radiusX = (str.charCodeAt(i + 3) + 1) >> 1;
-        var radiusY = (str.charCodeAt(i + 4) + 1) >> 1;
-        var radiusZ = (str.charCodeAt(i + 5) + 1) >> 1;
+		var radiusX = (str.charCodeAt(i + 3) + 1) >> 1;
+		var radiusY = (str.charCodeAt(i + 4) + 1) >> 1;
+		var radiusZ = (str.charCodeAt(i + 5) + 1) >> 1;
 
-        bboxen[ outputStart ++ ] = decodeScales[0] * (minX + radiusX);
-        bboxen[ outputStart ++ ] = decodeScales[1] * (minY + radiusY);
-        bboxen[ outputStart ++ ] = decodeScales[2] * (minZ + radiusZ);
+		bboxen[ outputStart ++ ] = decodeScales[0] * (minX + radiusX);
+		bboxen[ outputStart ++ ] = decodeScales[1] * (minY + radiusY);
+		bboxen[ outputStart ++ ] = decodeScales[2] * (minZ + radiusZ);
 
-        bboxen[ outputStart ++ ] = decodeScales[0] * radiusX;
-        bboxen[ outputStart ++ ] = decodeScales[1] * radiusY;
-        bboxen[ outputStart ++ ] = decodeScales[2] * radiusZ;
+		bboxen[ outputStart ++ ] = decodeScales[0] * radiusX;
+		bboxen[ outputStart ++ ] = decodeScales[1] * radiusY;
+		bboxen[ outputStart ++ ] = decodeScales[2] * radiusZ;
 
-    }
+	}
 
-    return bboxen;
+	return bboxen;
 
 };
 
@@ -230,67 +230,67 @@ THREE.UTF8Loader.prototype.decompressMesh =  function ( str, meshParams, decodeP
 
     // Extract conversion parameters from attribArrays.
 
-    var stride = decodeParams.decodeScales.length;
+	var stride = decodeParams.decodeScales.length;
 
-    var decodeOffsets = decodeParams.decodeOffsets;
-    var decodeScales = decodeParams.decodeScales;
+	var decodeOffsets = decodeParams.decodeOffsets;
+	var decodeScales = decodeParams.decodeScales;
 
-    var attribStart = meshParams.attribRange[0];
-    var numVerts = meshParams.attribRange[1];
+	var attribStart = meshParams.attribRange[0];
+	var numVerts = meshParams.attribRange[1];
 
     // Decode attributes.
 
-    var inputOffset = attribStart;
-    var attribsOut = new Float32Array( stride * numVerts );
+	var inputOffset = attribStart;
+	var attribsOut = new Float32Array( stride * numVerts );
 
-    for (var j = 0; j < stride; j ++ ) {
+	for (var j = 0; j < stride; j ++ ) {
 
-        var end = inputOffset + numVerts;
+		var end = inputOffset + numVerts;
 
 		var decodeScale = decodeScales[j];
 
-        if ( decodeScale ) {
+		if ( decodeScale ) {
 
             // Assume if decodeScale is never set, simply ignore the
             // attribute.
 
-            this.decompressAttribsInner_( str, inputOffset, end,
+			this.decompressAttribsInner_( str, inputOffset, end,
                 attribsOut, j, stride,
                 decodeOffsets[j], decodeScale );
-        }
+		}
 
-        inputOffset = end;
+		inputOffset = end;
 
-    }
+	}
 
-    var indexStart = meshParams.indexRange[ 0 ];
-    var numIndices = 3 * meshParams.indexRange[ 1 ];
+	var indexStart = meshParams.indexRange[ 0 ];
+	var numIndices = 3 * meshParams.indexRange[ 1 ];
 
-    var indicesOut = new Uint16Array( numIndices );
+	var indicesOut = new Uint16Array( numIndices );
 
-    this.decompressIndices_( str, inputOffset, numIndices, indicesOut, 0 );
+	this.decompressIndices_( str, inputOffset, numIndices, indicesOut, 0 );
 
     // Decode bboxen.
 
-    var bboxen = undefined;
-    var bboxOffset = meshParams.bboxes;
+	var bboxen = undefined;
+	var bboxOffset = meshParams.bboxes;
 
-    if ( bboxOffset ) {
+	if ( bboxOffset ) {
 
-        bboxen = this.decompressAABBs_( str, bboxOffset, meshParams.names.length, decodeOffsets, decodeScales );
-    }
+		bboxen = this.decompressAABBs_( str, bboxOffset, meshParams.names.length, decodeOffsets, decodeScales );
+	}
 
-    callback( name, idx, attribsOut, indicesOut, bboxen, meshParams );
+	callback( name, idx, attribsOut, indicesOut, bboxen, meshParams );
 
 };
 
 THREE.UTF8Loader.prototype.copyAttrib = function ( stride, attribsOutFixed, lastAttrib, index ) {
 
-    for ( var j = 0; j < stride; j ++ ) {
+	for ( var j = 0; j < stride; j ++ ) {
 
-        lastAttrib[ j ] = attribsOutFixed[ stride * index + j ];
+		lastAttrib[ j ] = attribsOutFixed[ stride * index + j ];
 
-    }
+	}
 
 };
 
@@ -298,343 +298,343 @@ THREE.UTF8Loader.prototype.decodeAttrib2 = function ( str, stride, decodeOffsets
                                                         numVerts, attribsOut, attribsOutFixed, lastAttrib,
                                                         index ) {
 
-    for ( var j = 0; j < 5; j ++ ) {
+	for ( var j = 0; j < 5; j ++ ) {
 
-        var code = str.charCodeAt( deltaStart + numVerts * j + index );
-        var delta = ( code >> 1) ^ (-(code & 1));
+		var code = str.charCodeAt( deltaStart + numVerts * j + index );
+		var delta = ( code >> 1) ^ (-(code & 1));
 
-        lastAttrib[ j ] += delta;
-        attribsOutFixed[ stride * index + j ] = lastAttrib[ j ];
-        attribsOut[ stride * index + j ] = decodeScales[ j ] * ( lastAttrib[ j ] + decodeOffsets[ j ] );
-    }
+		lastAttrib[ j ] += delta;
+		attribsOutFixed[ stride * index + j ] = lastAttrib[ j ];
+		attribsOut[ stride * index + j ] = decodeScales[ j ] * ( lastAttrib[ j ] + decodeOffsets[ j ] );
+	}
 
 };
 
 THREE.UTF8Loader.prototype.accumulateNormal = function ( i0, i1, i2, attribsOutFixed, crosses ) {
 
-    var p0x = attribsOutFixed[ 8 * i0 ];
-    var p0y = attribsOutFixed[ 8 * i0 + 1 ];
-    var p0z = attribsOutFixed[ 8 * i0 + 2 ];
+	var p0x = attribsOutFixed[ 8 * i0 ];
+	var p0y = attribsOutFixed[ 8 * i0 + 1 ];
+	var p0z = attribsOutFixed[ 8 * i0 + 2 ];
 
-    var p1x = attribsOutFixed[ 8 * i1 ];
-    var p1y = attribsOutFixed[ 8 * i1 + 1 ];
-    var p1z = attribsOutFixed[ 8 * i1 + 2 ];
+	var p1x = attribsOutFixed[ 8 * i1 ];
+	var p1y = attribsOutFixed[ 8 * i1 + 1 ];
+	var p1z = attribsOutFixed[ 8 * i1 + 2 ];
 
-    var p2x = attribsOutFixed[ 8 * i2 ];
-    var p2y = attribsOutFixed[ 8 * i2 + 1 ];
-    var p2z = attribsOutFixed[ 8 * i2 + 2 ];
+	var p2x = attribsOutFixed[ 8 * i2 ];
+	var p2y = attribsOutFixed[ 8 * i2 + 1 ];
+	var p2z = attribsOutFixed[ 8 * i2 + 2 ];
 
-    p1x -= p0x;
-    p1y -= p0y;
-    p1z -= p0z;
+	p1x -= p0x;
+	p1y -= p0y;
+	p1z -= p0z;
 
-    p2x -= p0x;
-    p2y -= p0y;
-    p2z -= p0z;
+	p2x -= p0x;
+	p2y -= p0y;
+	p2z -= p0z;
 
-    p0x = p1y * p2z - p1z * p2y;
-    p0y = p1z * p2x - p1x * p2z;
-    p0z = p1x * p2y - p1y * p2x;
+	p0x = p1y * p2z - p1z * p2y;
+	p0y = p1z * p2x - p1x * p2z;
+	p0z = p1x * p2y - p1y * p2x;
 
-    crosses[ 3 * i0 ]     += p0x;
-    crosses[ 3 * i0 + 1 ] += p0y;
-    crosses[ 3 * i0 + 2 ] += p0z;
+	crosses[ 3 * i0 ]     += p0x;
+	crosses[ 3 * i0 + 1 ] += p0y;
+	crosses[ 3 * i0 + 2 ] += p0z;
 
-    crosses[ 3 * i1 ]     += p0x;
-    crosses[ 3 * i1 + 1 ] += p0y;
-    crosses[ 3 * i1 + 2 ] += p0z;
+	crosses[ 3 * i1 ]     += p0x;
+	crosses[ 3 * i1 + 1 ] += p0y;
+	crosses[ 3 * i1 + 2 ] += p0z;
 
-    crosses[ 3 * i2 ]     += p0x;
-    crosses[ 3 * i2 + 1 ] += p0y;
-    crosses[ 3 * i2 + 2 ] += p0z;
+	crosses[ 3 * i2 ]     += p0x;
+	crosses[ 3 * i2 + 1 ] += p0y;
+	crosses[ 3 * i2 + 2 ] += p0z;
 
 };
 
 THREE.UTF8Loader.prototype.decompressMesh2 = function( str, meshParams, decodeParams, name, idx, callback ) {
 
-    var MAX_BACKREF = 96;
+	var MAX_BACKREF = 96;
 
     // Extract conversion parameters from attribArrays.
 
-    var stride = decodeParams.decodeScales.length;
+	var stride = decodeParams.decodeScales.length;
 
 	var decodeOffsets = decodeParams.decodeOffsets;
-    var decodeScales = decodeParams.decodeScales;
+	var decodeScales = decodeParams.decodeScales;
 
-    var deltaStart = meshParams.attribRange[ 0 ];
-    var numVerts = meshParams.attribRange[ 1 ];
+	var deltaStart = meshParams.attribRange[ 0 ];
+	var numVerts = meshParams.attribRange[ 1 ];
 
-    var codeStart = meshParams.codeRange[ 0 ];
-    var codeLength = meshParams.codeRange[ 1 ];
+	var codeStart = meshParams.codeRange[ 0 ];
+	var codeLength = meshParams.codeRange[ 1 ];
 
-    var numIndices = 3 * meshParams.codeRange[ 2 ];
+	var numIndices = 3 * meshParams.codeRange[ 2 ];
 
-    var indicesOut = new Uint16Array( numIndices );
+	var indicesOut = new Uint16Array( numIndices );
 
-    var crosses = new Int32Array( 3 * numVerts );
+	var crosses = new Int32Array( 3 * numVerts );
 
-    var lastAttrib = new Uint16Array( stride );
+	var lastAttrib = new Uint16Array( stride );
 
-    var attribsOutFixed = new Uint16Array( stride * numVerts );
-    var attribsOut = new Float32Array( stride * numVerts );
+	var attribsOutFixed = new Uint16Array( stride * numVerts );
+	var attribsOut = new Float32Array( stride * numVerts );
 
-    var highest = 0;
-    var outputStart = 0;
+	var highest = 0;
+	var outputStart = 0;
 
-    for ( var i = 0; i < numIndices; i += 3 ) {
+	for ( var i = 0; i < numIndices; i += 3 ) {
 
-        var code = str.charCodeAt( codeStart ++ );
+		var code = str.charCodeAt( codeStart ++ );
 
-        var max_backref = Math.min( i, MAX_BACKREF );
+		var max_backref = Math.min( i, MAX_BACKREF );
 
-        if ( code < max_backref ) {
+		if ( code < max_backref ) {
 
             // Parallelogram
 
-            var winding = code % 3;
-            var backref = i - ( code - winding );
-            var i0, i1, i2;
+			var winding = code % 3;
+			var backref = i - ( code - winding );
+			var i0, i1, i2;
 
-            switch ( winding ) {
+			switch ( winding ) {
 
-                case 0:
+				case 0:
 
-                    i0 = indicesOut[ backref + 2 ];
-                    i1 = indicesOut[ backref + 1 ];
-                    i2 = indicesOut[ backref + 0 ];
-                    break;
+					i0 = indicesOut[ backref + 2 ];
+					i1 = indicesOut[ backref + 1 ];
+					i2 = indicesOut[ backref + 0 ];
+					break;
 
-                case 1:
+				case 1:
 
-                    i0 = indicesOut[ backref + 0 ];
-                    i1 = indicesOut[ backref + 2 ];
-                    i2 = indicesOut[ backref + 1 ];
-                    break;
+					i0 = indicesOut[ backref + 0 ];
+					i1 = indicesOut[ backref + 2 ];
+					i2 = indicesOut[ backref + 1 ];
+					break;
 
-                case 2:
+				case 2:
 
-                    i0 = indicesOut[ backref + 1 ];
-                    i1 = indicesOut[ backref + 0 ];
-                    i2 = indicesOut[ backref + 2 ];
-                    break;
+					i0 = indicesOut[ backref + 1 ];
+					i1 = indicesOut[ backref + 0 ];
+					i2 = indicesOut[ backref + 2 ];
+					break;
 
-            }
+			}
 
-            indicesOut[ outputStart ++ ] = i0;
-            indicesOut[ outputStart ++ ] = i1;
+			indicesOut[ outputStart ++ ] = i0;
+			indicesOut[ outputStart ++ ] = i1;
 
-            code = str.charCodeAt( codeStart ++ );
+			code = str.charCodeAt( codeStart ++ );
 
-            var index = highest - code;
-            indicesOut[ outputStart ++ ] = index;
+			var index = highest - code;
+			indicesOut[ outputStart ++ ] = index;
 
-            if ( code === 0 ) {
+			if ( code === 0 ) {
 
-                for (var j = 0; j < 5; j ++ ) {
+				for (var j = 0; j < 5; j ++ ) {
 
-                    var deltaCode = str.charCodeAt( deltaStart + numVerts * j + highest );
+					var deltaCode = str.charCodeAt( deltaStart + numVerts * j + highest );
 
-                    var prediction = ((deltaCode >> 1) ^ (-(deltaCode & 1))) +
+					var prediction = ((deltaCode >> 1) ^ (-(deltaCode & 1))) +
                         attribsOutFixed[stride * i0 + j] +
                         attribsOutFixed[stride * i1 + j] -
                         attribsOutFixed[stride * i2 + j];
 
-                    lastAttrib[j] = prediction;
+					lastAttrib[j] = prediction;
 
-                    attribsOutFixed[ stride * highest + j ] = prediction;
-                    attribsOut[ stride * highest + j ] = decodeScales[ j ] * ( prediction + decodeOffsets[ j ] );
+					attribsOutFixed[ stride * highest + j ] = prediction;
+					attribsOut[ stride * highest + j ] = decodeScales[ j ] * ( prediction + decodeOffsets[ j ] );
 
-                }
+				}
 
-                highest ++;
+				highest ++;
 
-            } else {
+			} else {
 
-                this.copyAttrib( stride, attribsOutFixed, lastAttrib, index );
+				this.copyAttrib( stride, attribsOutFixed, lastAttrib, index );
 
-            }
+			}
 
-            this.accumulateNormal( i0, i1, index, attribsOutFixed, crosses );
+			this.accumulateNormal( i0, i1, index, attribsOutFixed, crosses );
 
-        } else {
+		} else {
 
             // Simple
 
-            var index0 = highest - ( code - max_backref );
+			var index0 = highest - ( code - max_backref );
 
-            indicesOut[ outputStart ++ ] = index0;
+			indicesOut[ outputStart ++ ] = index0;
 
-            if ( code === max_backref ) {
+			if ( code === max_backref ) {
 
-                this.decodeAttrib2( str, stride, decodeOffsets, decodeScales, deltaStart,
+				this.decodeAttrib2( str, stride, decodeOffsets, decodeScales, deltaStart,
                     numVerts, attribsOut, attribsOutFixed, lastAttrib,
                     highest ++ );
 
-            } else {
+			} else {
 
-                this.copyAttrib(stride, attribsOutFixed, lastAttrib, index0);
+				this.copyAttrib(stride, attribsOutFixed, lastAttrib, index0);
 
-            }
+			}
 
-            code = str.charCodeAt( codeStart ++ );
+			code = str.charCodeAt( codeStart ++ );
 
-            var index1 = highest - code;
-            indicesOut[ outputStart ++ ] = index1;
+			var index1 = highest - code;
+			indicesOut[ outputStart ++ ] = index1;
 
-            if ( code === 0 ) {
+			if ( code === 0 ) {
 
-                this.decodeAttrib2( str, stride, decodeOffsets, decodeScales, deltaStart,
+				this.decodeAttrib2( str, stride, decodeOffsets, decodeScales, deltaStart,
                     numVerts, attribsOut, attribsOutFixed, lastAttrib,
                     highest ++ );
 
-            } else {
+			} else {
 
-                this.copyAttrib( stride, attribsOutFixed, lastAttrib, index1 );
+				this.copyAttrib( stride, attribsOutFixed, lastAttrib, index1 );
 
-            }
+			}
 
-            code = str.charCodeAt( codeStart ++ );
+			code = str.charCodeAt( codeStart ++ );
 
-            var index2 = highest - code;
-            indicesOut[ outputStart ++ ] = index2;
+			var index2 = highest - code;
+			indicesOut[ outputStart ++ ] = index2;
 
-            if ( code === 0 ) {
+			if ( code === 0 ) {
 
-                for ( var j = 0; j < 5; j ++ ) {
+				for ( var j = 0; j < 5; j ++ ) {
 
-                    lastAttrib[ j ] = ( attribsOutFixed[ stride * index0 + j ] + attribsOutFixed[ stride * index1 + j ] ) / 2;
+					lastAttrib[ j ] = ( attribsOutFixed[ stride * index0 + j ] + attribsOutFixed[ stride * index1 + j ] ) / 2;
 
-                }
+				}
 
-                this.decodeAttrib2( str, stride, decodeOffsets, decodeScales, deltaStart,
+				this.decodeAttrib2( str, stride, decodeOffsets, decodeScales, deltaStart,
                     numVerts, attribsOut, attribsOutFixed, lastAttrib,
                     highest ++ );
 
-            } else {
+			} else {
 
-                this.copyAttrib( stride, attribsOutFixed, lastAttrib, index2 );
+				this.copyAttrib( stride, attribsOutFixed, lastAttrib, index2 );
 
-            }
+			}
 
-            this.accumulateNormal( index0, index1, index2, attribsOutFixed, crosses );
+			this.accumulateNormal( index0, index1, index2, attribsOutFixed, crosses );
 
-        }
+		}
 
-    }
+	}
 
-    for ( var i = 0; i < numVerts; i ++ ) {
+	for ( var i = 0; i < numVerts; i ++ ) {
 
-        var nx = crosses[ 3 * i ];
-        var ny = crosses[ 3 * i + 1 ];
-        var nz = crosses[ 3 * i + 2 ];
+		var nx = crosses[ 3 * i ];
+		var ny = crosses[ 3 * i + 1 ];
+		var nz = crosses[ 3 * i + 2 ];
 
-        var norm = 511.0 / Math.sqrt( nx * nx + ny * ny + nz * nz );
+		var norm = 511.0 / Math.sqrt( nx * nx + ny * ny + nz * nz );
 
-        var cx = str.charCodeAt( deltaStart + 5 * numVerts + i );
-        var cy = str.charCodeAt( deltaStart + 6 * numVerts + i );
-        var cz = str.charCodeAt( deltaStart + 7 * numVerts + i );
+		var cx = str.charCodeAt( deltaStart + 5 * numVerts + i );
+		var cy = str.charCodeAt( deltaStart + 6 * numVerts + i );
+		var cz = str.charCodeAt( deltaStart + 7 * numVerts + i );
 
-        attribsOut[ stride * i + 5 ] = norm * nx + ((cx >> 1) ^ (-(cx & 1)));
-        attribsOut[ stride * i + 6 ] = norm * ny + ((cy >> 1) ^ (-(cy & 1)));
-        attribsOut[ stride * i + 7 ] = norm * nz + ((cz >> 1) ^ (-(cz & 1)));
-    }
+		attribsOut[ stride * i + 5 ] = norm * nx + ((cx >> 1) ^ (-(cx & 1)));
+		attribsOut[ stride * i + 6 ] = norm * ny + ((cy >> 1) ^ (-(cy & 1)));
+		attribsOut[ stride * i + 7 ] = norm * nz + ((cz >> 1) ^ (-(cz & 1)));
+	}
 
-    callback( name, idx, attribsOut, indicesOut, undefined, meshParams );
+	callback( name, idx, attribsOut, indicesOut, undefined, meshParams );
 
 };
 
 THREE.UTF8Loader.prototype.downloadMesh = function ( path, name, meshEntry, decodeParams, callback ) {
 
-    var loader = this;
-    var idx = 0;
+	var loader = this;
+	var idx = 0;
 
-    function onprogress( req, e ) {
+	function onprogress( req, e ) {
 
-        while ( idx < meshEntry.length ) {
+		while ( idx < meshEntry.length ) {
 
-            var meshParams = meshEntry[ idx ];
-            var indexRange = meshParams.indexRange;
+			var meshParams = meshEntry[ idx ];
+			var indexRange = meshParams.indexRange;
 
-            if ( indexRange ) {
+			if ( indexRange ) {
 
-                var meshEnd = indexRange[ 0 ] + 3 * indexRange[ 1 ];
+				var meshEnd = indexRange[ 0 ] + 3 * indexRange[ 1 ];
 
-                if ( req.responseText.length < meshEnd ) break;
+				if ( req.responseText.length < meshEnd ) break;
 
-                loader.decompressMesh( req.responseText, meshParams, decodeParams, name, idx, callback );
+				loader.decompressMesh( req.responseText, meshParams, decodeParams, name, idx, callback );
 
-            } else {
+			} else {
 
-                var codeRange = meshParams.codeRange;
-                var meshEnd = codeRange[ 0 ] + codeRange[ 1 ];
+				var codeRange = meshParams.codeRange;
+				var meshEnd = codeRange[ 0 ] + codeRange[ 1 ];
 
-                if ( req.responseText.length < meshEnd ) break;
+				if ( req.responseText.length < meshEnd ) break;
 
-                loader.decompressMesh2( req.responseText, meshParams, decodeParams, name, idx, callback );
-            }
+				loader.decompressMesh2( req.responseText, meshParams, decodeParams, name, idx, callback );
+			}
 
-            ++ idx;
+			++ idx;
 
-        }
+		}
 
-    };
+	};
 
-    getHttpRequest( path, function( req, e ) {
+	getHttpRequest( path, function( req, e ) {
 
-        if ( req.status === 200 || req.status === 0 ) {
+		if ( req.status === 200 || req.status === 0 ) {
 
-            onprogress( req, e );
+			onprogress( req, e );
 
-        }
+		}
 
         // TODO: handle errors.
 
-    }, onprogress );
+	}, onprogress );
 
 };
 
 THREE.UTF8Loader.prototype.downloadMeshes = function ( path, meshUrlMap, decodeParams, callback ) {
 
-    for ( var url in meshUrlMap ) {
+	for ( var url in meshUrlMap ) {
 
-        var meshEntry = meshUrlMap[url];
-        this.downloadMesh( path + url, url, meshEntry, decodeParams, callback );
+		var meshEntry = meshUrlMap[url];
+		this.downloadMesh( path + url, url, meshEntry, decodeParams, callback );
 
-    }
+	}
 
 };
 
 THREE.UTF8Loader.prototype.createMeshCallback = function( materialBaseUrl, loadModelInfo, allDoneCallback ) {
 
 	var nCompletedUrls = 0;
-    var nExpectedUrls = 0;
+	var nExpectedUrls = 0;
 
-    var expectedMeshesPerUrl = {};
-    var decodedMeshesPerUrl = {};
+	var expectedMeshesPerUrl = {};
+	var decodedMeshesPerUrl = {};
 
 	var modelParts = {};
 
 	var meshUrlMap = loadModelInfo.urls;
 
-    for ( var url in meshUrlMap ) {
+	for ( var url in meshUrlMap ) {
 
-        expectedMeshesPerUrl[ url ] = meshUrlMap[ url ].length;
-        decodedMeshesPerUrl[ url ] = 0;
+		expectedMeshesPerUrl[ url ] = meshUrlMap[ url ].length;
+		decodedMeshesPerUrl[ url ] = 0;
 
 		nExpectedUrls ++;
 
-        modelParts[ url ] = new THREE.Object3D();
+		modelParts[ url ] = new THREE.Object3D();
 
-    }
+	}
 
-    var model = new THREE.Object3D();
+	var model = new THREE.Object3D();
 
     // Prepare materials first...
 
-    var materialCreator = new THREE.MTLLoader.MaterialCreator( materialBaseUrl, loadModelInfo.options );
-    materialCreator.setMaterials( loadModelInfo.materials );
+	var materialCreator = new THREE.MTLLoader.MaterialCreator( materialBaseUrl, loadModelInfo.options );
+	materialCreator.setMaterials( loadModelInfo.materials );
 
-    materialCreator.preload();
+	materialCreator.preload();
 
 	// Create callback for creating mesh parts
 
@@ -652,32 +652,32 @@ THREE.UTF8Loader.prototype.createMeshCallback = function( materialBaseUrl, loadM
         // meshParams contains the material info
 
 		var geometry = bufferGeometryCreator.create( attribArray, indexArray );
-        var material = materialCreator.create( meshParams.material );
+		var material = materialCreator.create( meshParams.material );
 
 		var mesh = new THREE.Mesh( geometry, material );
-        modelParts[ name ].add( mesh );
+		modelParts[ name ].add( mesh );
 
         //model.add(new THREE.Mesh(geometry, material));
 
-        decodedMeshesPerUrl[ name ] ++;
+		decodedMeshesPerUrl[ name ] ++;
 
-        if ( decodedMeshesPerUrl[ name ] === expectedMeshesPerUrl[ name ] ) {
+		if ( decodedMeshesPerUrl[ name ] === expectedMeshesPerUrl[ name ] ) {
 
-            nCompletedUrls ++;
+			nCompletedUrls ++;
 
-            model.add( modelParts[ name ] );
+			model.add( modelParts[ name ] );
 
-            if ( nCompletedUrls === nExpectedUrls ) {
+			if ( nCompletedUrls === nExpectedUrls ) {
 
                 // ALL DONE!!!
 
-                allDoneCallback( model );
+				allDoneCallback( model );
 
-            }
+			}
 
-        }
+		}
 
-    };
+	};
 
 	return meshCallback;
 
@@ -685,61 +685,61 @@ THREE.UTF8Loader.prototype.createMeshCallback = function( materialBaseUrl, loadM
 
 THREE.UTF8Loader.prototype.downloadModel = function ( geometryBase, materialBase, model, callback ) {
 
-    var meshCallback = this.createMeshCallback( materialBase, model, callback );
-    this.downloadMeshes( geometryBase, model.urls, model.decodeParams, meshCallback );
+	var meshCallback = this.createMeshCallback( materialBase, model, callback );
+	this.downloadMeshes( geometryBase, model.urls, model.decodeParams, meshCallback );
 
 };
 
 THREE.UTF8Loader.prototype.downloadModelJson = function ( jsonUrl, callback, options ) {
 
-    getJsonRequest( jsonUrl, function( loaded ) {
+	getJsonRequest( jsonUrl, function( loaded ) {
 
-        if ( ! loaded.decodeParams ) {
+		if ( ! loaded.decodeParams ) {
 
-            if ( options && options.decodeParams ) {
+			if ( options && options.decodeParams ) {
 
-                loaded.decodeParams = options.decodeParams;
+				loaded.decodeParams = options.decodeParams;
 
-            } else {
+			} else {
 
-                loaded.decodeParams = DEFAULT_DECODE_PARAMS;
+				loaded.decodeParams = DEFAULT_DECODE_PARAMS;
 
-            }
+			}
 
-        }
+		}
 
-        loaded.options = options;
+		loaded.options = options;
 
-        var geometryBase = jsonUrl.substr( 0, jsonUrl.lastIndexOf( "/" ) + 1 );
-        var materialBase = geometryBase;
+		var geometryBase = jsonUrl.substr( 0, jsonUrl.lastIndexOf( "/" ) + 1 );
+		var materialBase = geometryBase;
 
-        if ( options && options.geometryBase ) {
+		if ( options && options.geometryBase ) {
 
-            geometryBase = options.geometryBase;
+			geometryBase = options.geometryBase;
 
-            if ( geometryBase.charAt( geometryBase.length - 1 ) !== "/" ) {
+			if ( geometryBase.charAt( geometryBase.length - 1 ) !== "/" ) {
 
-                geometryBase = geometryBase + "/";
+				geometryBase = geometryBase + "/";
 
-            }
+			}
 
-        }
+		}
 
-        if ( options && options.materialBase ) {
+		if ( options && options.materialBase ) {
 
-            materialBase = options.materialBase;
+			materialBase = options.materialBase;
 
-            if ( materialBase.charAt( materialBase.length - 1 ) !== "/" ) {
+			if ( materialBase.charAt( materialBase.length - 1 ) !== "/" ) {
 
-                materialBase = materialBase  + "/";
+				materialBase = materialBase  + "/";
 
-            }
+			}
 
-        }
+		}
 
-        this.downloadModel( geometryBase, materialBase, loaded, callback );
+		this.downloadModel( geometryBase, materialBase, loaded, callback );
 
-    }.bind( this ) );
+	}.bind( this ) );
 
 };
 
@@ -747,23 +747,23 @@ THREE.UTF8Loader.prototype.downloadModelJson = function ( jsonUrl, callback, opt
 
 function getHttpRequest( url, onload, opt_onprogress ) {
 
-    var LISTENERS = {
+	var LISTENERS = {
 
         load: function( e ) { onload( req, e ); },
         progress: function( e ) { opt_onprogress( req, e ); }
 
     };
 
-    var req = new XMLHttpRequest();
-    addListeners( req, LISTENERS );
+	var req = new XMLHttpRequest();
+	addListeners( req, LISTENERS );
 
-    req.open( 'GET', url, true );
-    req.send( null );
+	req.open( 'GET', url, true );
+	req.send( null );
 }
 
 function getJsonRequest( url, onjson ) {
 
-    getHttpRequest( url,
+	getHttpRequest( url,
         function( e ) { onjson( JSON.parse( e.responseText ) ); },
         function() {} );
 
@@ -773,9 +773,9 @@ function addListeners( dom, listeners ) {
 
     // TODO: handle event capture, object binding.
 
-    for ( var key in listeners ) {
+	for ( var key in listeners ) {
 
-        dom.addEventListener( key, listeners[ key ] );
+		dom.addEventListener( key, listeners[ key ] );
 
-    }
+	}
 }

+ 1 - 1
examples/js/loaders/VRMLLoader.js

@@ -260,7 +260,7 @@ THREE.VRMLLoader.prototype = {
 							// end of current face
 							if (parts[ind] === "-1") {
 								if (index.length > 0) {
-								   this.indexes.push(index);
+									this.indexes.push(index);
 								}
 
 								// start new one

+ 357 - 357
examples/js/loaders/ctm/ctm.js

@@ -46,552 +46,552 @@ CTM.Flags = {
 };
 
 CTM.File = function(stream) {
-  this.load(stream);
+	this.load(stream);
 };
 
 CTM.File.prototype.load = function(stream) {
-  this.header = new CTM.FileHeader(stream);
+	this.header = new CTM.FileHeader(stream);
 
-  this.body = new CTM.FileBody(this.header);
+	this.body = new CTM.FileBody(this.header);
   
-  this.getReader().read(stream, this.body);
+	this.getReader().read(stream, this.body);
 };
 
 CTM.File.prototype.getReader = function() {
-  var reader;
+	var reader;
 
-  switch (this.header.compressionMethod){
-    case CTM.CompressionMethod.RAW:
-      reader = new CTM.ReaderRAW();
-      break;
-    case CTM.CompressionMethod.MG1:
-      reader = new CTM.ReaderMG1();
-      break;
-    case CTM.CompressionMethod.MG2:
-      reader = new CTM.ReaderMG2();
-      break;
-  }
+	switch (this.header.compressionMethod){
+		case CTM.CompressionMethod.RAW:
+			reader = new CTM.ReaderRAW();
+			break;
+		case CTM.CompressionMethod.MG1:
+			reader = new CTM.ReaderMG1();
+			break;
+		case CTM.CompressionMethod.MG2:
+			reader = new CTM.ReaderMG2();
+			break;
+	}
 
-  return reader;
+	return reader;
 };
 
 CTM.FileHeader = function(stream) {
-  stream.readInt32(); //magic "OCTM"
-  this.fileFormat = stream.readInt32();
-  this.compressionMethod = stream.readInt32();
-  this.vertexCount = stream.readInt32();
-  this.triangleCount = stream.readInt32();
-  this.uvMapCount = stream.readInt32();
-  this.attrMapCount = stream.readInt32();
-  this.flags = stream.readInt32();
-  this.comment = stream.readString();
+	stream.readInt32(); //magic "OCTM"
+	this.fileFormat = stream.readInt32();
+	this.compressionMethod = stream.readInt32();
+	this.vertexCount = stream.readInt32();
+	this.triangleCount = stream.readInt32();
+	this.uvMapCount = stream.readInt32();
+	this.attrMapCount = stream.readInt32();
+	this.flags = stream.readInt32();
+	this.comment = stream.readString();
 };
 
 CTM.FileHeader.prototype.hasNormals = function() {
-  return this.flags & CTM.Flags.NORMALS;
+	return this.flags & CTM.Flags.NORMALS;
 };
 
 CTM.FileBody = function(header) {
-  var i = header.triangleCount * 3,
+	var i = header.triangleCount * 3,
       v = header.vertexCount * 3,
       n = header.hasNormals() ? header.vertexCount * 3 : 0,
       u = header.vertexCount * 2,
       a = header.vertexCount * 4,
       j = 0;
 
-  var data = new ArrayBuffer(
+	var data = new ArrayBuffer(
     (i + v + n + (u * header.uvMapCount) + (a * header.attrMapCount) ) * 4);
 
-  this.indices = new Uint32Array(data, 0, i);
+	this.indices = new Uint32Array(data, 0, i);
 
-  this.vertices = new Float32Array(data, i * 4, v);
+	this.vertices = new Float32Array(data, i * 4, v);
 
-  if ( header.hasNormals() ) {
-    this.normals = new Float32Array(data, (i + v) * 4, n);
-  }
+	if ( header.hasNormals() ) {
+		this.normals = new Float32Array(data, (i + v) * 4, n);
+	}
   
-  if (header.uvMapCount) {
-    this.uvMaps = [];
-    for (j = 0; j < header.uvMapCount; ++ j) {
-      this.uvMaps[j] = { uv: new Float32Array(data,
+	if (header.uvMapCount) {
+		this.uvMaps = [];
+		for (j = 0; j < header.uvMapCount; ++ j) {
+			this.uvMaps[j] = { uv: new Float32Array(data,
         (i + v + n + (j * u) ) * 4, u) };
-    }
-  }
+		}
+	}
   
-  if (header.attrMapCount) {
-    this.attrMaps = [];
-    for (j = 0; j < header.attrMapCount; ++ j) {
-      this.attrMaps[j] = { attr: new Float32Array(data,
+	if (header.attrMapCount) {
+		this.attrMaps = [];
+		for (j = 0; j < header.attrMapCount; ++ j) {
+			this.attrMaps[j] = { attr: new Float32Array(data,
         (i + v + n + (u * header.uvMapCount) + (j * a) ) * 4, a) };
-    }
-  }
+		}
+	}
 };
 
 CTM.FileMG2Header = function(stream) {
-  stream.readInt32(); //magic "MG2H"
-  this.vertexPrecision = stream.readFloat32();
-  this.normalPrecision = stream.readFloat32();
-  this.lowerBoundx = stream.readFloat32();
-  this.lowerBoundy = stream.readFloat32();
-  this.lowerBoundz = stream.readFloat32();
-  this.higherBoundx = stream.readFloat32();
-  this.higherBoundy = stream.readFloat32();
-  this.higherBoundz = stream.readFloat32();
-  this.divx = stream.readInt32();
-  this.divy = stream.readInt32();
-  this.divz = stream.readInt32();
+	stream.readInt32(); //magic "MG2H"
+	this.vertexPrecision = stream.readFloat32();
+	this.normalPrecision = stream.readFloat32();
+	this.lowerBoundx = stream.readFloat32();
+	this.lowerBoundy = stream.readFloat32();
+	this.lowerBoundz = stream.readFloat32();
+	this.higherBoundx = stream.readFloat32();
+	this.higherBoundy = stream.readFloat32();
+	this.higherBoundz = stream.readFloat32();
+	this.divx = stream.readInt32();
+	this.divy = stream.readInt32();
+	this.divz = stream.readInt32();
   
-  this.sizex = (this.higherBoundx - this.lowerBoundx) / this.divx;
-  this.sizey = (this.higherBoundy - this.lowerBoundy) / this.divy;
-  this.sizez = (this.higherBoundz - this.lowerBoundz) / this.divz;
+	this.sizex = (this.higherBoundx - this.lowerBoundx) / this.divx;
+	this.sizey = (this.higherBoundy - this.lowerBoundy) / this.divy;
+	this.sizez = (this.higherBoundz - this.lowerBoundz) / this.divz;
 };
 
 CTM.ReaderRAW = function() {
 };
 
 CTM.ReaderRAW.prototype.read = function(stream, body) {
-  this.readIndices(stream, body.indices);
-  this.readVertices(stream, body.vertices);
+	this.readIndices(stream, body.indices);
+	this.readVertices(stream, body.vertices);
   
-  if (body.normals) {
-    this.readNormals(stream, body.normals);
-  }
-  if (body.uvMaps) {
-    this.readUVMaps(stream, body.uvMaps);
-  }
-  if (body.attrMaps) {
-    this.readAttrMaps(stream, body.attrMaps);
-  }
+	if (body.normals) {
+		this.readNormals(stream, body.normals);
+	}
+	if (body.uvMaps) {
+		this.readUVMaps(stream, body.uvMaps);
+	}
+	if (body.attrMaps) {
+		this.readAttrMaps(stream, body.attrMaps);
+	}
 };
 
 CTM.ReaderRAW.prototype.readIndices = function(stream, indices) {
-  stream.readInt32(); //magic "INDX"
-  stream.readArrayInt32(indices);
+	stream.readInt32(); //magic "INDX"
+	stream.readArrayInt32(indices);
 };
 
 CTM.ReaderRAW.prototype.readVertices = function(stream, vertices) {
-  stream.readInt32(); //magic "VERT"
-  stream.readArrayFloat32(vertices);
+	stream.readInt32(); //magic "VERT"
+	stream.readArrayFloat32(vertices);
 };
 
 CTM.ReaderRAW.prototype.readNormals = function(stream, normals) {
-  stream.readInt32(); //magic "NORM"
-  stream.readArrayFloat32(normals);
+	stream.readInt32(); //magic "NORM"
+	stream.readArrayFloat32(normals);
 };
 
 CTM.ReaderRAW.prototype.readUVMaps = function(stream, uvMaps) {
-  var i = 0;
-  for (; i < uvMaps.length; ++ i) {
-    stream.readInt32(); //magic "TEXC"
+	var i = 0;
+	for (; i < uvMaps.length; ++ i) {
+		stream.readInt32(); //magic "TEXC"
 
-    uvMaps[i].name = stream.readString();
-    uvMaps[i].filename = stream.readString();
-    stream.readArrayFloat32(uvMaps[i].uv);
-  }
+		uvMaps[i].name = stream.readString();
+		uvMaps[i].filename = stream.readString();
+		stream.readArrayFloat32(uvMaps[i].uv);
+	}
 };
 
 CTM.ReaderRAW.prototype.readAttrMaps = function(stream, attrMaps) {
-  var i = 0;
-  for (; i < attrMaps.length; ++ i) {
-    stream.readInt32(); //magic "ATTR"
+	var i = 0;
+	for (; i < attrMaps.length; ++ i) {
+		stream.readInt32(); //magic "ATTR"
 
-    attrMaps[i].name = stream.readString();
-    stream.readArrayFloat32(attrMaps[i].attr);
-  }
+		attrMaps[i].name = stream.readString();
+		stream.readArrayFloat32(attrMaps[i].attr);
+	}
 };
 
 CTM.ReaderMG1 = function() {
 };
 
 CTM.ReaderMG1.prototype.read = function(stream, body) {
-  this.readIndices(stream, body.indices);
-  this.readVertices(stream, body.vertices);
+	this.readIndices(stream, body.indices);
+	this.readVertices(stream, body.vertices);
   
-  if (body.normals) {
-    this.readNormals(stream, body.normals);
-  }
-  if (body.uvMaps) {
-    this.readUVMaps(stream, body.uvMaps);
-  }
-  if (body.attrMaps) {
-    this.readAttrMaps(stream, body.attrMaps);
-  }
+	if (body.normals) {
+		this.readNormals(stream, body.normals);
+	}
+	if (body.uvMaps) {
+		this.readUVMaps(stream, body.uvMaps);
+	}
+	if (body.attrMaps) {
+		this.readAttrMaps(stream, body.attrMaps);
+	}
 };
 
 CTM.ReaderMG1.prototype.readIndices = function(stream, indices) {
-  stream.readInt32(); //magic "INDX"
-  stream.readInt32(); //packed size
+	stream.readInt32(); //magic "INDX"
+	stream.readInt32(); //packed size
   
-  var interleaved = new CTM.InterleavedStream(indices, 3);
-  LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
+	var interleaved = new CTM.InterleavedStream(indices, 3);
+	LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
 
-  CTM.restoreIndices(indices, indices.length);
+	CTM.restoreIndices(indices, indices.length);
 };
 
 CTM.ReaderMG1.prototype.readVertices = function(stream, vertices) {
-  stream.readInt32(); //magic "VERT"
-  stream.readInt32(); //packed size
+	stream.readInt32(); //magic "VERT"
+	stream.readInt32(); //packed size
   
-  var interleaved = new CTM.InterleavedStream(vertices, 1);
-  LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
+	var interleaved = new CTM.InterleavedStream(vertices, 1);
+	LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
 };
 
 CTM.ReaderMG1.prototype.readNormals = function(stream, normals) {
-  stream.readInt32(); //magic "NORM"
-  stream.readInt32(); //packed size
+	stream.readInt32(); //magic "NORM"
+	stream.readInt32(); //packed size
 
-  var interleaved = new CTM.InterleavedStream(normals, 3);
-  LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
+	var interleaved = new CTM.InterleavedStream(normals, 3);
+	LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
 };
 
 CTM.ReaderMG1.prototype.readUVMaps = function(stream, uvMaps) {
-  var i = 0;
-  for (; i < uvMaps.length; ++ i) {
-    stream.readInt32(); //magic "TEXC"
+	var i = 0;
+	for (; i < uvMaps.length; ++ i) {
+		stream.readInt32(); //magic "TEXC"
 
-    uvMaps[i].name = stream.readString();
-    uvMaps[i].filename = stream.readString();
+		uvMaps[i].name = stream.readString();
+		uvMaps[i].filename = stream.readString();
     
-    stream.readInt32(); //packed size
+		stream.readInt32(); //packed size
 
-    var interleaved = new CTM.InterleavedStream(uvMaps[i].uv, 2);
-    LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
-  }
+		var interleaved = new CTM.InterleavedStream(uvMaps[i].uv, 2);
+		LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
+	}
 };
 
 CTM.ReaderMG1.prototype.readAttrMaps = function(stream, attrMaps) {
-  var i = 0;
-  for (; i < attrMaps.length; ++ i) {
-    stream.readInt32(); //magic "ATTR"
+	var i = 0;
+	for (; i < attrMaps.length; ++ i) {
+		stream.readInt32(); //magic "ATTR"
 
-    attrMaps[i].name = stream.readString();
+		attrMaps[i].name = stream.readString();
     
-    stream.readInt32(); //packed size
+		stream.readInt32(); //packed size
 
-    var interleaved = new CTM.InterleavedStream(attrMaps[i].attr, 4);
-    LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
-  }
+		var interleaved = new CTM.InterleavedStream(attrMaps[i].attr, 4);
+		LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
+	}
 };
 
 CTM.ReaderMG2 = function() {
 };
 
 CTM.ReaderMG2.prototype.read = function(stream, body) {
-  this.MG2Header = new CTM.FileMG2Header(stream);
+	this.MG2Header = new CTM.FileMG2Header(stream);
   
-  this.readVertices(stream, body.vertices);
-  this.readIndices(stream, body.indices);
+	this.readVertices(stream, body.vertices);
+	this.readIndices(stream, body.indices);
   
-  if (body.normals) {
-    this.readNormals(stream, body);
-  }
-  if (body.uvMaps) {
-    this.readUVMaps(stream, body.uvMaps);
-  }
-  if (body.attrMaps) {
-    this.readAttrMaps(stream, body.attrMaps);
-  }
+	if (body.normals) {
+		this.readNormals(stream, body);
+	}
+	if (body.uvMaps) {
+		this.readUVMaps(stream, body.uvMaps);
+	}
+	if (body.attrMaps) {
+		this.readAttrMaps(stream, body.attrMaps);
+	}
 };
 
 CTM.ReaderMG2.prototype.readVertices = function(stream, vertices) {
-  stream.readInt32(); //magic "VERT"
-  stream.readInt32(); //packed size
+	stream.readInt32(); //magic "VERT"
+	stream.readInt32(); //packed size
 
-  var interleaved = new CTM.InterleavedStream(vertices, 3);
-  LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
+	var interleaved = new CTM.InterleavedStream(vertices, 3);
+	LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
   
-  var gridIndices = this.readGridIndices(stream, vertices);
+	var gridIndices = this.readGridIndices(stream, vertices);
   
-  CTM.restoreVertices(vertices, this.MG2Header, gridIndices, this.MG2Header.vertexPrecision);
+	CTM.restoreVertices(vertices, this.MG2Header, gridIndices, this.MG2Header.vertexPrecision);
 };
 
 CTM.ReaderMG2.prototype.readGridIndices = function(stream, vertices) {
-  stream.readInt32(); //magic "GIDX"
-  stream.readInt32(); //packed size
+	stream.readInt32(); //magic "GIDX"
+	stream.readInt32(); //packed size
   
-  var gridIndices = new Uint32Array(vertices.length / 3);
+	var gridIndices = new Uint32Array(vertices.length / 3);
   
-  var interleaved = new CTM.InterleavedStream(gridIndices, 1);
-  LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
+	var interleaved = new CTM.InterleavedStream(gridIndices, 1);
+	LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
   
-  CTM.restoreGridIndices(gridIndices, gridIndices.length);
+	CTM.restoreGridIndices(gridIndices, gridIndices.length);
   
-  return gridIndices;
+	return gridIndices;
 };
 
 CTM.ReaderMG2.prototype.readIndices = function(stream, indices) {
-  stream.readInt32(); //magic "INDX"
-  stream.readInt32(); //packed size
+	stream.readInt32(); //magic "INDX"
+	stream.readInt32(); //packed size
 
-  var interleaved = new CTM.InterleavedStream(indices, 3);
-  LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
+	var interleaved = new CTM.InterleavedStream(indices, 3);
+	LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
 
-  CTM.restoreIndices(indices, indices.length);
+	CTM.restoreIndices(indices, indices.length);
 };
 
 CTM.ReaderMG2.prototype.readNormals = function(stream, body) {
-  stream.readInt32(); //magic "NORM"
-  stream.readInt32(); //packed size
+	stream.readInt32(); //magic "NORM"
+	stream.readInt32(); //packed size
 
-  var interleaved = new CTM.InterleavedStream(body.normals, 3);
-  LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
+	var interleaved = new CTM.InterleavedStream(body.normals, 3);
+	LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
 
-  var smooth = CTM.calcSmoothNormals(body.indices, body.vertices);
+	var smooth = CTM.calcSmoothNormals(body.indices, body.vertices);
 
-  CTM.restoreNormals(body.normals, smooth, this.MG2Header.normalPrecision);
+	CTM.restoreNormals(body.normals, smooth, this.MG2Header.normalPrecision);
 };
 
 CTM.ReaderMG2.prototype.readUVMaps = function(stream, uvMaps) {
-  var i = 0;
-  for (; i < uvMaps.length; ++ i) {
-    stream.readInt32(); //magic "TEXC"
+	var i = 0;
+	for (; i < uvMaps.length; ++ i) {
+		stream.readInt32(); //magic "TEXC"
 
-    uvMaps[i].name = stream.readString();
-    uvMaps[i].filename = stream.readString();
+		uvMaps[i].name = stream.readString();
+		uvMaps[i].filename = stream.readString();
     
-    var precision = stream.readFloat32();
+		var precision = stream.readFloat32();
     
-    stream.readInt32(); //packed size
+		stream.readInt32(); //packed size
 
-    var interleaved = new CTM.InterleavedStream(uvMaps[i].uv, 2);
-    LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
+		var interleaved = new CTM.InterleavedStream(uvMaps[i].uv, 2);
+		LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
     
-    CTM.restoreMap(uvMaps[i].uv, 2, precision);
-  }
+		CTM.restoreMap(uvMaps[i].uv, 2, precision);
+	}
 };
 
 CTM.ReaderMG2.prototype.readAttrMaps = function(stream, attrMaps) {
-  var i = 0;
-  for (; i < attrMaps.length; ++ i) {
-    stream.readInt32(); //magic "ATTR"
+	var i = 0;
+	for (; i < attrMaps.length; ++ i) {
+		stream.readInt32(); //magic "ATTR"
 
-    attrMaps[i].name = stream.readString();
+		attrMaps[i].name = stream.readString();
     
-    var precision = stream.readFloat32();
+		var precision = stream.readFloat32();
     
-    stream.readInt32(); //packed size
+		stream.readInt32(); //packed size
 
-    var interleaved = new CTM.InterleavedStream(attrMaps[i].attr, 4);
-    LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
+		var interleaved = new CTM.InterleavedStream(attrMaps[i].attr, 4);
+		LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
     
-    CTM.restoreMap(attrMaps[i].attr, 4, precision);
-  }
+		CTM.restoreMap(attrMaps[i].attr, 4, precision);
+	}
 };
 
 CTM.restoreIndices = function(indices, len) {
-  var i = 3;
-  if (len > 0) {
-    indices[2] += indices[0];
-    indices[1] += indices[0];
-  }
-  for (; i < len; i += 3) {
-    indices[i] += indices[i - 3];
+	var i = 3;
+	if (len > 0) {
+		indices[2] += indices[0];
+		indices[1] += indices[0];
+	}
+	for (; i < len; i += 3) {
+		indices[i] += indices[i - 3];
     
-    if (indices[i] === indices[i - 3]) {
-      indices[i + 1] += indices[i - 2];
-    }else {
-      indices[i + 1] += indices[i];
-    }
+		if (indices[i] === indices[i - 3]) {
+			indices[i + 1] += indices[i - 2];
+		}else {
+			indices[i + 1] += indices[i];
+		}
 
-    indices[i + 2] += indices[i];
-  }
+		indices[i + 2] += indices[i];
+	}
 };
 
 CTM.restoreGridIndices = function(gridIndices, len) {
-  var i = 1;
-  for (; i < len; ++ i) {
-    gridIndices[i] += gridIndices[i - 1];
-  }
+	var i = 1;
+	for (; i < len; ++ i) {
+		gridIndices[i] += gridIndices[i - 1];
+	}
 };
 
 CTM.restoreVertices = function(vertices, grid, gridIndices, precision) {
-  var gridIdx, delta, x, y, z,
+	var gridIdx, delta, x, y, z,
       intVertices = new Uint32Array(vertices.buffer, vertices.byteOffset, vertices.length),
       ydiv = grid.divx, zdiv = ydiv * grid.divy,
       prevGridIdx = 0x7fffffff, prevDelta = 0,
       i = 0, j = 0, len = gridIndices.length;
 
-  for (; i < len; j += 3) {
-    x = gridIdx = gridIndices[i ++];
+	for (; i < len; j += 3) {
+		x = gridIdx = gridIndices[i ++];
     
-    z = ~~(x / zdiv);
-    x -= ~~(z * zdiv);
-    y = ~~(x / ydiv);
-    x -= ~~(y * ydiv);
+		z = ~~(x / zdiv);
+		x -= ~~(z * zdiv);
+		y = ~~(x / ydiv);
+		x -= ~~(y * ydiv);
 
-    delta = intVertices[j];
-    if (gridIdx === prevGridIdx) {
-      delta += prevDelta;
-    }
+		delta = intVertices[j];
+		if (gridIdx === prevGridIdx) {
+			delta += prevDelta;
+		}
 
-    vertices[j]     = grid.lowerBoundx +
+		vertices[j]     = grid.lowerBoundx +
       x * grid.sizex + precision * delta;
-    vertices[j + 1] = grid.lowerBoundy +
+		vertices[j + 1] = grid.lowerBoundy +
       y * grid.sizey + precision * intVertices[j + 1];
-    vertices[j + 2] = grid.lowerBoundz +
+		vertices[j + 2] = grid.lowerBoundz +
       z * grid.sizez + precision * intVertices[j + 2];
 
-    prevGridIdx = gridIdx;
-    prevDelta = delta;
-  }
+		prevGridIdx = gridIdx;
+		prevDelta = delta;
+	}
 };
 
 CTM.restoreNormals = function(normals, smooth, precision) {
-  var ro, phi, theta, sinPhi,
+	var ro, phi, theta, sinPhi,
       nx, ny, nz, by, bz, len,
       intNormals = new Uint32Array(normals.buffer, normals.byteOffset, normals.length),
       i = 0, k = normals.length,
       PI_DIV_2 = 3.141592653589793238462643 * 0.5;
 
-  for (; i < k; i += 3) {
-    ro = intNormals[i] * precision;
-    phi = intNormals[i + 1];
+	for (; i < k; i += 3) {
+		ro = intNormals[i] * precision;
+		phi = intNormals[i + 1];
 
-    if (phi === 0) {
-      normals[i]     = smooth[i]     * ro;
-      normals[i + 1] = smooth[i + 1] * ro;
-      normals[i + 2] = smooth[i + 2] * ro;
-    }else {
+		if (phi === 0) {
+			normals[i]     = smooth[i]     * ro;
+			normals[i + 1] = smooth[i + 1] * ro;
+			normals[i + 2] = smooth[i + 2] * ro;
+		}else {
       
-      if (phi <= 4) {
-        theta = (intNormals[i + 2] - 2) * PI_DIV_2;
-      }else {
-        theta = ( (intNormals[i + 2] * 4 / phi) - 2) * PI_DIV_2;
-      }
+			if (phi <= 4) {
+				theta = (intNormals[i + 2] - 2) * PI_DIV_2;
+			}else {
+				theta = ( (intNormals[i + 2] * 4 / phi) - 2) * PI_DIV_2;
+			}
       
-      phi *= precision * PI_DIV_2;
-      sinPhi = ro * Math.sin(phi);
+			phi *= precision * PI_DIV_2;
+			sinPhi = ro * Math.sin(phi);
 
-      nx = sinPhi * Math.cos(theta);
-      ny = sinPhi * Math.sin(theta);
-      nz = ro * Math.cos(phi);
+			nx = sinPhi * Math.cos(theta);
+			ny = sinPhi * Math.sin(theta);
+			nz = ro * Math.cos(phi);
 
-      bz = smooth[i + 1];
-      by = smooth[i] - smooth[i + 2];
+			bz = smooth[i + 1];
+			by = smooth[i] - smooth[i + 2];
 
-      len = Math.sqrt(2 * bz * bz + by * by);
-      if (len > 1e-20) {
-        by /= len;
-        bz /= len;
-      }
+			len = Math.sqrt(2 * bz * bz + by * by);
+			if (len > 1e-20) {
+				by /= len;
+				bz /= len;
+			}
 
-      normals[i]     = smooth[i]     * nz +
+			normals[i]     = smooth[i]     * nz +
         (smooth[i + 1] * bz - smooth[i + 2] * by) * ny - bz * nx;
-      normals[i + 1] = smooth[i + 1] * nz -
+			normals[i + 1] = smooth[i + 1] * nz -
         (smooth[i + 2]      + smooth[i]   ) * bz  * ny + by * nx;
-      normals[i + 2] = smooth[i + 2] * nz +
+			normals[i + 2] = smooth[i + 2] * nz +
         (smooth[i]     * by + smooth[i + 1] * bz) * ny + bz * nx;
-    }
-  }
+		}
+	}
 };
 
 CTM.restoreMap = function(map, count, precision) {
-  var delta, value,
+	var delta, value,
       intMap = new Uint32Array(map.buffer, map.byteOffset, map.length),
       i = 0, j, len = map.length;
 
-  for (; i < count; ++ i) {
-    delta = 0;
+	for (; i < count; ++ i) {
+		delta = 0;
 
-    for (j = i; j < len; j += count) {
-      value = intMap[j];
+		for (j = i; j < len; j += count) {
+			value = intMap[j];
       
-      delta += value & 1 ? -( (value + 1) >> 1) : value >> 1;
+			delta += value & 1 ? -( (value + 1) >> 1) : value >> 1;
       
-      map[j] = delta * precision;
-    }
-  }
+			map[j] = delta * precision;
+		}
+	}
 };
 
 CTM.calcSmoothNormals = function(indices, vertices) {
-  var smooth = new Float32Array(vertices.length),
+	var smooth = new Float32Array(vertices.length),
       indx, indy, indz, nx, ny, nz,
       v1x, v1y, v1z, v2x, v2y, v2z, len,
       i, k;
 
-  for (i = 0, k = indices.length; i < k;) {
-    indx = indices[i ++] * 3;
-    indy = indices[i ++] * 3;
-    indz = indices[i ++] * 3;
-
-    v1x = vertices[indy]     - vertices[indx];
-    v2x = vertices[indz]     - vertices[indx];
-    v1y = vertices[indy + 1] - vertices[indx + 1];
-    v2y = vertices[indz + 1] - vertices[indx + 1];
-    v1z = vertices[indy + 2] - vertices[indx + 2];
-    v2z = vertices[indz + 2] - vertices[indx + 2];
+	for (i = 0, k = indices.length; i < k;) {
+		indx = indices[i ++] * 3;
+		indy = indices[i ++] * 3;
+		indz = indices[i ++] * 3;
+
+		v1x = vertices[indy]     - vertices[indx];
+		v2x = vertices[indz]     - vertices[indx];
+		v1y = vertices[indy + 1] - vertices[indx + 1];
+		v2y = vertices[indz + 1] - vertices[indx + 1];
+		v1z = vertices[indy + 2] - vertices[indx + 2];
+		v2z = vertices[indz + 2] - vertices[indx + 2];
     
-    nx = v1y * v2z - v1z * v2y;
-    ny = v1z * v2x - v1x * v2z;
-    nz = v1x * v2y - v1y * v2x;
+		nx = v1y * v2z - v1z * v2y;
+		ny = v1z * v2x - v1x * v2z;
+		nz = v1x * v2y - v1y * v2x;
     
-    len = Math.sqrt(nx * nx + ny * ny + nz * nz);
-    if (len > 1e-10) {
-      nx /= len;
-      ny /= len;
-      nz /= len;
-    }
+		len = Math.sqrt(nx * nx + ny * ny + nz * nz);
+		if (len > 1e-10) {
+			nx /= len;
+			ny /= len;
+			nz /= len;
+		}
     
-    smooth[indx]     += nx;
-    smooth[indx + 1] += ny;
-    smooth[indx + 2] += nz;
-    smooth[indy]     += nx;
-    smooth[indy + 1] += ny;
-    smooth[indy + 2] += nz;
-    smooth[indz]     += nx;
-    smooth[indz + 1] += ny;
-    smooth[indz + 2] += nz;
-  }
-
-  for (i = 0, k = smooth.length; i < k; i += 3) {
-    len = Math.sqrt(smooth[i] * smooth[i] + 
+		smooth[indx]     += nx;
+		smooth[indx + 1] += ny;
+		smooth[indx + 2] += nz;
+		smooth[indy]     += nx;
+		smooth[indy + 1] += ny;
+		smooth[indy + 2] += nz;
+		smooth[indz]     += nx;
+		smooth[indz + 1] += ny;
+		smooth[indz + 2] += nz;
+	}
+
+	for (i = 0, k = smooth.length; i < k; i += 3) {
+		len = Math.sqrt(smooth[i] * smooth[i] + 
       smooth[i + 1] * smooth[i + 1] +
       smooth[i + 2] * smooth[i + 2]);
 
-    if (len > 1e-10) {
-      smooth[i]     /= len;
-      smooth[i + 1] /= len;
-      smooth[i + 2] /= len;
-    }
-  }
+		if (len > 1e-10) {
+			smooth[i]     /= len;
+			smooth[i + 1] /= len;
+			smooth[i + 2] /= len;
+		}
+	}
 
-  return smooth;
+	return smooth;
 };
 
 CTM.isLittleEndian = (function() {
-  var buffer = new ArrayBuffer(2),
+	var buffer = new ArrayBuffer(2),
       bytes = new Uint8Array(buffer),
       ints = new Uint16Array(buffer);
 
-  bytes[0] = 1;
+	bytes[0] = 1;
 
-  return ints[0] === 1;
+	return ints[0] === 1;
 }());
 
 CTM.InterleavedStream = function(data, count) {
-  this.data = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
-  this.offset = CTM.isLittleEndian ? 3 : 0;
-  this.count = count * 4;
-  this.len = this.data.length;
+	this.data = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
+	this.offset = CTM.isLittleEndian ? 3 : 0;
+	this.count = count * 4;
+	this.len = this.data.length;
 };
 
 CTM.InterleavedStream.prototype.writeByte = function(value) {
-  this.data[this.offset] = value;
+	this.data[this.offset] = value;
   
-  this.offset += this.count;
-  if (this.offset >= this.len) {
+	this.offset += this.count;
+	if (this.offset >= this.len) {
   
-    this.offset -= this.len - 4;
-    if (this.offset >= this.count) {
+		this.offset -= this.len - 4;
+		if (this.offset >= this.count) {
     
-      this.offset -= this.count + (CTM.isLittleEndian ? 1 : -1);
-    }
-  }
+			this.offset -= this.count + (CTM.isLittleEndian ? 1 : -1);
+		}
+	}
 };
 
 CTM.Stream = function(data) {
-  this.data = data;
-  this.offset = 0;
+	this.data = data;
+	this.offset = 0;
 };
 
 CTM.Stream.prototype.TWO_POW_MINUS23 = Math.pow(2, -23);
@@ -599,63 +599,63 @@ CTM.Stream.prototype.TWO_POW_MINUS23 = Math.pow(2, -23);
 CTM.Stream.prototype.TWO_POW_MINUS126 = Math.pow(2, -126);
 
 CTM.Stream.prototype.readByte = function() {
-  return this.data[this.offset ++] & 0xff;
+	return this.data[this.offset ++] & 0xff;
 };
 
 CTM.Stream.prototype.readInt32 = function() {
-  var i = this.readByte();
-  i |= this.readByte() << 8;
-  i |= this.readByte() << 16;
-  return i | (this.readByte() << 24);
+	var i = this.readByte();
+	i |= this.readByte() << 8;
+	i |= this.readByte() << 16;
+	return i | (this.readByte() << 24);
 };
 
 CTM.Stream.prototype.readFloat32 = function() {
-  var m = this.readByte();
-  m += this.readByte() << 8;
+	var m = this.readByte();
+	m += this.readByte() << 8;
 
-  var b1 = this.readByte();
-  var b2 = this.readByte();
+	var b1 = this.readByte();
+	var b2 = this.readByte();
 
-  m += (b1 & 0x7f) << 16; 
-  var e = ( (b2 & 0x7f) << 1) | ( (b1 & 0x80) >>> 7);
-  var s = b2 & 0x80 ? -1 : 1;
+	m += (b1 & 0x7f) << 16; 
+	var e = ( (b2 & 0x7f) << 1) | ( (b1 & 0x80) >>> 7);
+	var s = b2 & 0x80 ? -1 : 1;
 
-  if (e === 255) {
-    return m !== 0 ? NaN : s * Infinity;
-  }
-  if (e > 0) {
-    return s * (1 + (m * this.TWO_POW_MINUS23) ) * Math.pow(2, e - 127);
-  }
-  if (m !== 0) {
-    return s * m * this.TWO_POW_MINUS126;
-  }
-  return s * 0;
+	if (e === 255) {
+		return m !== 0 ? NaN : s * Infinity;
+	}
+	if (e > 0) {
+		return s * (1 + (m * this.TWO_POW_MINUS23) ) * Math.pow(2, e - 127);
+	}
+	if (m !== 0) {
+		return s * m * this.TWO_POW_MINUS126;
+	}
+	return s * 0;
 };
 
 CTM.Stream.prototype.readString = function() {
-  var len = this.readInt32();
+	var len = this.readInt32();
 
-  this.offset += len;
+	this.offset += len;
 
-  return String.fromCharCode.apply(null, this.data.subarray(this.offset - len, this.offset));
+	return String.fromCharCode.apply(null, this.data.subarray(this.offset - len, this.offset));
 };
 
 CTM.Stream.prototype.readArrayInt32 = function(array) {
-  var i = 0, len = array.length;
+	var i = 0, len = array.length;
   
-  while (i < len) {
-    array[i ++] = this.readInt32();
-  }
+	while (i < len) {
+		array[i ++] = this.readInt32();
+	}
 
-  return array;
+	return array;
 };
 
 CTM.Stream.prototype.readArrayFloat32 = function(array) {
-  var i = 0, len = array.length;
+	var i = 0, len = array.length;
 
-  while (i < len) {
-    array[i ++] = this.readFloat32();
-  }
+	while (i < len) {
+		array[i ++] = this.readFloat32();
+	}
 
-  return array;
+	return array;
 };

+ 348 - 348
examples/js/loaders/ctm/lzma.js

@@ -9,509 +9,509 @@ if ( typeof module === 'object' ) {
 }
 
 LZMA.OutWindow = function() {
-  this._windowSize = 0;
+	this._windowSize = 0;
 };
 
 LZMA.OutWindow.prototype.create = function(windowSize) {
-  if ( (!this._buffer) || (this._windowSize !== windowSize) ) {
-    this._buffer = [];
-  }
-  this._windowSize = windowSize;
-  this._pos = 0;
-  this._streamPos = 0;
+	if ( (!this._buffer) || (this._windowSize !== windowSize) ) {
+		this._buffer = [];
+	}
+	this._windowSize = windowSize;
+	this._pos = 0;
+	this._streamPos = 0;
 };
 
 LZMA.OutWindow.prototype.flush = function() {
-  var size = this._pos - this._streamPos;
-  if (size !== 0) {
-    while (size --) {
-      this._stream.writeByte(this._buffer[this._streamPos ++]);
-    }
-    if (this._pos >= this._windowSize) {
-      this._pos = 0;
-    }
-    this._streamPos = this._pos;
-  }
+	var size = this._pos - this._streamPos;
+	if (size !== 0) {
+		while (size --) {
+			this._stream.writeByte(this._buffer[this._streamPos ++]);
+		}
+		if (this._pos >= this._windowSize) {
+			this._pos = 0;
+		}
+		this._streamPos = this._pos;
+	}
 };
 
 LZMA.OutWindow.prototype.releaseStream = function() {
-  this.flush();
-  this._stream = null;
+	this.flush();
+	this._stream = null;
 };
 
 LZMA.OutWindow.prototype.setStream = function(stream) {
-  this.releaseStream();
-  this._stream = stream;
+	this.releaseStream();
+	this._stream = stream;
 };
 
 LZMA.OutWindow.prototype.init = function(solid) {
-  if (!solid) {
-    this._streamPos = 0;
-    this._pos = 0;
-  }
+	if (!solid) {
+		this._streamPos = 0;
+		this._pos = 0;
+	}
 };
 
 LZMA.OutWindow.prototype.copyBlock = function(distance, len) {
-  var pos = this._pos - distance - 1;
-  if (pos < 0) {
-    pos += this._windowSize;
-  }
-  while (len --) {
-    if (pos >= this._windowSize) {
-      pos = 0;
-    }
-    this._buffer[this._pos ++] = this._buffer[pos ++];
-    if (this._pos >= this._windowSize) {
-      this.flush();
-    }
-  }
+	var pos = this._pos - distance - 1;
+	if (pos < 0) {
+		pos += this._windowSize;
+	}
+	while (len --) {
+		if (pos >= this._windowSize) {
+			pos = 0;
+		}
+		this._buffer[this._pos ++] = this._buffer[pos ++];
+		if (this._pos >= this._windowSize) {
+			this.flush();
+		}
+	}
 };
 
 LZMA.OutWindow.prototype.putByte = function(b) {
-  this._buffer[this._pos ++] = b;
-  if (this._pos >= this._windowSize) {
-    this.flush();
-  }
+	this._buffer[this._pos ++] = b;
+	if (this._pos >= this._windowSize) {
+		this.flush();
+	}
 };
 
 LZMA.OutWindow.prototype.getByte = function(distance) {
-  var pos = this._pos - distance - 1;
-  if (pos < 0) {
-    pos += this._windowSize;
-  }
-  return this._buffer[pos];
+	var pos = this._pos - distance - 1;
+	if (pos < 0) {
+		pos += this._windowSize;
+	}
+	return this._buffer[pos];
 };
 
 LZMA.RangeDecoder = function() {
 };
 
 LZMA.RangeDecoder.prototype.setStream = function(stream) {
-  this._stream = stream;
+	this._stream = stream;
 };
 
 LZMA.RangeDecoder.prototype.releaseStream = function() {
-  this._stream = null;
+	this._stream = null;
 };
 
 LZMA.RangeDecoder.prototype.init = function() {
-  var i = 5;
+	var i = 5;
 
-  this._code = 0;
-  this._range = -1;
+	this._code = 0;
+	this._range = -1;
   
-  while (i --) {
-    this._code = (this._code << 8) | this._stream.readByte();
-  }
+	while (i --) {
+		this._code = (this._code << 8) | this._stream.readByte();
+	}
 };
 
 LZMA.RangeDecoder.prototype.decodeDirectBits = function(numTotalBits) {
-  var result = 0, i = numTotalBits, t;
+	var result = 0, i = numTotalBits, t;
 
-  while (i --) {
-    this._range >>>= 1;
-    t = (this._code - this._range) >>> 31;
-    this._code -= this._range & (t - 1);
-    result = (result << 1) | (1 - t);
+	while (i --) {
+		this._range >>>= 1;
+		t = (this._code - this._range) >>> 31;
+		this._code -= this._range & (t - 1);
+		result = (result << 1) | (1 - t);
 
-    if ( (this._range & 0xff000000) === 0) {
-      this._code = (this._code << 8) | this._stream.readByte();
-      this._range <<= 8;
-    }
-  }
+		if ( (this._range & 0xff000000) === 0) {
+			this._code = (this._code << 8) | this._stream.readByte();
+			this._range <<= 8;
+		}
+	}
 
-  return result;
+	return result;
 };
 
 LZMA.RangeDecoder.prototype.decodeBit = function(probs, index) {
-  var prob = probs[index],
+	var prob = probs[index],
       newBound = (this._range >>> 11) * prob;
 
-  if ( (this._code ^ 0x80000000) < (newBound ^ 0x80000000) ) {
-    this._range = newBound;
-    probs[index] += (2048 - prob) >>> 5;
-    if ( (this._range & 0xff000000) === 0) {
-      this._code = (this._code << 8) | this._stream.readByte();
-      this._range <<= 8;
-    }
-    return 0;
-  }
-
-  this._range -= newBound;
-  this._code -= newBound;
-  probs[index] -= prob >>> 5;
-  if ( (this._range & 0xff000000) === 0) {
-    this._code = (this._code << 8) | this._stream.readByte();
-    this._range <<= 8;
-  }
-  return 1;
+	if ( (this._code ^ 0x80000000) < (newBound ^ 0x80000000) ) {
+		this._range = newBound;
+		probs[index] += (2048 - prob) >>> 5;
+		if ( (this._range & 0xff000000) === 0) {
+			this._code = (this._code << 8) | this._stream.readByte();
+			this._range <<= 8;
+		}
+		return 0;
+	}
+
+	this._range -= newBound;
+	this._code -= newBound;
+	probs[index] -= prob >>> 5;
+	if ( (this._range & 0xff000000) === 0) {
+		this._code = (this._code << 8) | this._stream.readByte();
+		this._range <<= 8;
+	}
+	return 1;
 };
 
 LZMA.initBitModels = function(probs, len) {
-  while (len --) {
-    probs[len] = 1024;
-  }
+	while (len --) {
+		probs[len] = 1024;
+	}
 };
 
 LZMA.BitTreeDecoder = function(numBitLevels) {
-  this._models = [];
-  this._numBitLevels = numBitLevels;
+	this._models = [];
+	this._numBitLevels = numBitLevels;
 };
 
 LZMA.BitTreeDecoder.prototype.init = function() {
-  LZMA.initBitModels(this._models, 1 << this._numBitLevels);
+	LZMA.initBitModels(this._models, 1 << this._numBitLevels);
 };
 
 LZMA.BitTreeDecoder.prototype.decode = function(rangeDecoder) {
-  var m = 1, i = this._numBitLevels;
+	var m = 1, i = this._numBitLevels;
 
-  while (i --) {
-    m = (m << 1) | rangeDecoder.decodeBit(this._models, m);
-  }
-  return m - (1 << this._numBitLevels);
+	while (i --) {
+		m = (m << 1) | rangeDecoder.decodeBit(this._models, m);
+	}
+	return m - (1 << this._numBitLevels);
 };
 
 LZMA.BitTreeDecoder.prototype.reverseDecode = function(rangeDecoder) {
-  var m = 1, symbol = 0, i = 0, bit;
+	var m = 1, symbol = 0, i = 0, bit;
 
-  for (; i < this._numBitLevels; ++ i) {
-    bit = rangeDecoder.decodeBit(this._models, m);
-    m = (m << 1) | bit;
-    symbol |= bit << i;
-  }
-  return symbol;
+	for (; i < this._numBitLevels; ++ i) {
+		bit = rangeDecoder.decodeBit(this._models, m);
+		m = (m << 1) | bit;
+		symbol |= bit << i;
+	}
+	return symbol;
 };
 
 LZMA.reverseDecode2 = function(models, startIndex, rangeDecoder, numBitLevels) {
-  var m = 1, symbol = 0, i = 0, bit;
+	var m = 1, symbol = 0, i = 0, bit;
 
-  for (; i < numBitLevels; ++ i) {
-    bit = rangeDecoder.decodeBit(models, startIndex + m);
-    m = (m << 1) | bit;
-    symbol |= bit << i;
-  }
-  return symbol;
+	for (; i < numBitLevels; ++ i) {
+		bit = rangeDecoder.decodeBit(models, startIndex + m);
+		m = (m << 1) | bit;
+		symbol |= bit << i;
+	}
+	return symbol;
 };
 
 LZMA.LenDecoder = function() {
-  this._choice = [];
-  this._lowCoder = [];
-  this._midCoder = [];
-  this._highCoder = new LZMA.BitTreeDecoder(8);
-  this._numPosStates = 0;
+	this._choice = [];
+	this._lowCoder = [];
+	this._midCoder = [];
+	this._highCoder = new LZMA.BitTreeDecoder(8);
+	this._numPosStates = 0;
 };
 
 LZMA.LenDecoder.prototype.create = function(numPosStates) {
-  for (; this._numPosStates < numPosStates; ++ this._numPosStates) {
-    this._lowCoder[this._numPosStates] = new LZMA.BitTreeDecoder(3);
-    this._midCoder[this._numPosStates] = new LZMA.BitTreeDecoder(3);
-  }
+	for (; this._numPosStates < numPosStates; ++ this._numPosStates) {
+		this._lowCoder[this._numPosStates] = new LZMA.BitTreeDecoder(3);
+		this._midCoder[this._numPosStates] = new LZMA.BitTreeDecoder(3);
+	}
 };
 
 LZMA.LenDecoder.prototype.init = function() {
-  var i = this._numPosStates;
-  LZMA.initBitModels(this._choice, 2);
-  while (i --) {
-    this._lowCoder[i].init();
-    this._midCoder[i].init();
-  }
-  this._highCoder.init();
+	var i = this._numPosStates;
+	LZMA.initBitModels(this._choice, 2);
+	while (i --) {
+		this._lowCoder[i].init();
+		this._midCoder[i].init();
+	}
+	this._highCoder.init();
 };
 
 LZMA.LenDecoder.prototype.decode = function(rangeDecoder, posState) {
-  if (rangeDecoder.decodeBit(this._choice, 0) === 0) {
-    return this._lowCoder[posState].decode(rangeDecoder);
-  }
-  if (rangeDecoder.decodeBit(this._choice, 1) === 0) {
-    return 8 + this._midCoder[posState].decode(rangeDecoder);
-  }
-  return 16 + this._highCoder.decode(rangeDecoder);
+	if (rangeDecoder.decodeBit(this._choice, 0) === 0) {
+		return this._lowCoder[posState].decode(rangeDecoder);
+	}
+	if (rangeDecoder.decodeBit(this._choice, 1) === 0) {
+		return 8 + this._midCoder[posState].decode(rangeDecoder);
+	}
+	return 16 + this._highCoder.decode(rangeDecoder);
 };
 
 LZMA.Decoder2 = function() {
-  this._decoders = [];
+	this._decoders = [];
 };
 
 LZMA.Decoder2.prototype.init = function() {
-  LZMA.initBitModels(this._decoders, 0x300);
+	LZMA.initBitModels(this._decoders, 0x300);
 };
 
 LZMA.Decoder2.prototype.decodeNormal = function(rangeDecoder) {
-  var symbol = 1;
+	var symbol = 1;
 
-  do {
-    symbol = (symbol << 1) | rangeDecoder.decodeBit(this._decoders, symbol);
-  }while (symbol < 0x100);
+	do {
+		symbol = (symbol << 1) | rangeDecoder.decodeBit(this._decoders, symbol);
+	}while (symbol < 0x100);
 
-  return symbol & 0xff;
+	return symbol & 0xff;
 };
 
 LZMA.Decoder2.prototype.decodeWithMatchByte = function(rangeDecoder, matchByte) {
-  var symbol = 1, matchBit, bit;
+	var symbol = 1, matchBit, bit;
 
-  do {
-    matchBit = (matchByte >> 7) & 1;
-    matchByte <<= 1;
-    bit = rangeDecoder.decodeBit(this._decoders, ( (1 + matchBit) << 8) + symbol);
-    symbol = (symbol << 1) | bit;
-    if (matchBit !== bit) {
-      while (symbol < 0x100) {
-        symbol = (symbol << 1) | rangeDecoder.decodeBit(this._decoders, symbol);
-      }
-      break;
-    }
-  }while (symbol < 0x100);
+	do {
+		matchBit = (matchByte >> 7) & 1;
+		matchByte <<= 1;
+		bit = rangeDecoder.decodeBit(this._decoders, ( (1 + matchBit) << 8) + symbol);
+		symbol = (symbol << 1) | bit;
+		if (matchBit !== bit) {
+			while (symbol < 0x100) {
+				symbol = (symbol << 1) | rangeDecoder.decodeBit(this._decoders, symbol);
+			}
+			break;
+		}
+	}while (symbol < 0x100);
 
-  return symbol & 0xff;
+	return symbol & 0xff;
 };
 
 LZMA.LiteralDecoder = function() {
 };
 
 LZMA.LiteralDecoder.prototype.create = function(numPosBits, numPrevBits) {
-  var i;
+	var i;
 
-  if (this._coders
+	if (this._coders
     && (this._numPrevBits === numPrevBits)
     && (this._numPosBits === numPosBits) ) {
-    return;
-  }
-  this._numPosBits = numPosBits;
-  this._posMask = (1 << numPosBits) - 1;
-  this._numPrevBits = numPrevBits;
+		return;
+	}
+	this._numPosBits = numPosBits;
+	this._posMask = (1 << numPosBits) - 1;
+	this._numPrevBits = numPrevBits;
 
-  this._coders = [];
+	this._coders = [];
 
-  i = 1 << (this._numPrevBits + this._numPosBits);
-  while (i --) {
-    this._coders[i] = new LZMA.Decoder2();
-  }
+	i = 1 << (this._numPrevBits + this._numPosBits);
+	while (i --) {
+		this._coders[i] = new LZMA.Decoder2();
+	}
 };
 
 LZMA.LiteralDecoder.prototype.init = function() {
-  var i = 1 << (this._numPrevBits + this._numPosBits);
-  while (i --) {
-    this._coders[i].init();
-  }
+	var i = 1 << (this._numPrevBits + this._numPosBits);
+	while (i --) {
+		this._coders[i].init();
+	}
 };
 
 LZMA.LiteralDecoder.prototype.getDecoder = function(pos, prevByte) {
-  return this._coders[( (pos & this._posMask) << this._numPrevBits)
+	return this._coders[( (pos & this._posMask) << this._numPrevBits)
     + ( (prevByte & 0xff) >>> (8 - this._numPrevBits) )];
 };
 
 LZMA.Decoder = function() {
-  this._outWindow = new LZMA.OutWindow();
-  this._rangeDecoder = new LZMA.RangeDecoder();
-  this._isMatchDecoders = [];
-  this._isRepDecoders = [];
-  this._isRepG0Decoders = [];
-  this._isRepG1Decoders = [];
-  this._isRepG2Decoders = [];
-  this._isRep0LongDecoders = [];
-  this._posSlotDecoder = [];
-  this._posDecoders = [];
-  this._posAlignDecoder = new LZMA.BitTreeDecoder(4);
-  this._lenDecoder = new LZMA.LenDecoder();
-  this._repLenDecoder = new LZMA.LenDecoder();
-  this._literalDecoder = new LZMA.LiteralDecoder();
-  this._dictionarySize = -1;
-  this._dictionarySizeCheck = -1;
-
-  this._posSlotDecoder[0] = new LZMA.BitTreeDecoder(6);
-  this._posSlotDecoder[1] = new LZMA.BitTreeDecoder(6);
-  this._posSlotDecoder[2] = new LZMA.BitTreeDecoder(6);
-  this._posSlotDecoder[3] = new LZMA.BitTreeDecoder(6);
+	this._outWindow = new LZMA.OutWindow();
+	this._rangeDecoder = new LZMA.RangeDecoder();
+	this._isMatchDecoders = [];
+	this._isRepDecoders = [];
+	this._isRepG0Decoders = [];
+	this._isRepG1Decoders = [];
+	this._isRepG2Decoders = [];
+	this._isRep0LongDecoders = [];
+	this._posSlotDecoder = [];
+	this._posDecoders = [];
+	this._posAlignDecoder = new LZMA.BitTreeDecoder(4);
+	this._lenDecoder = new LZMA.LenDecoder();
+	this._repLenDecoder = new LZMA.LenDecoder();
+	this._literalDecoder = new LZMA.LiteralDecoder();
+	this._dictionarySize = -1;
+	this._dictionarySizeCheck = -1;
+
+	this._posSlotDecoder[0] = new LZMA.BitTreeDecoder(6);
+	this._posSlotDecoder[1] = new LZMA.BitTreeDecoder(6);
+	this._posSlotDecoder[2] = new LZMA.BitTreeDecoder(6);
+	this._posSlotDecoder[3] = new LZMA.BitTreeDecoder(6);
 };
 
 LZMA.Decoder.prototype.setDictionarySize = function(dictionarySize) {
-  if (dictionarySize < 0) {
-    return false;
-  }
-  if (this._dictionarySize !== dictionarySize) {
-    this._dictionarySize = dictionarySize;
-    this._dictionarySizeCheck = Math.max(this._dictionarySize, 1);
-    this._outWindow.create( Math.max(this._dictionarySizeCheck, 4096) );
-  }
-  return true;
+	if (dictionarySize < 0) {
+		return false;
+	}
+	if (this._dictionarySize !== dictionarySize) {
+		this._dictionarySize = dictionarySize;
+		this._dictionarySizeCheck = Math.max(this._dictionarySize, 1);
+		this._outWindow.create( Math.max(this._dictionarySizeCheck, 4096) );
+	}
+	return true;
 };
 
 LZMA.Decoder.prototype.setLcLpPb = function(lc, lp, pb) {
-  var numPosStates = 1 << pb;
+	var numPosStates = 1 << pb;
 
-  if (lc > 8 || lp > 4 || pb > 4) {
-    return false;
-  }
+	if (lc > 8 || lp > 4 || pb > 4) {
+		return false;
+	}
 
-  this._literalDecoder.create(lp, lc);
+	this._literalDecoder.create(lp, lc);
 
-  this._lenDecoder.create(numPosStates);
-  this._repLenDecoder.create(numPosStates);
-  this._posStateMask = numPosStates - 1;
+	this._lenDecoder.create(numPosStates);
+	this._repLenDecoder.create(numPosStates);
+	this._posStateMask = numPosStates - 1;
 
-  return true;
+	return true;
 };
 
 LZMA.Decoder.prototype.init = function() {
-  var i = 4;
+	var i = 4;
 
-  this._outWindow.init(false);
+	this._outWindow.init(false);
 
-  LZMA.initBitModels(this._isMatchDecoders, 192);
-  LZMA.initBitModels(this._isRep0LongDecoders, 192);
-  LZMA.initBitModels(this._isRepDecoders, 12);
-  LZMA.initBitModels(this._isRepG0Decoders, 12);
-  LZMA.initBitModels(this._isRepG1Decoders, 12);
-  LZMA.initBitModels(this._isRepG2Decoders, 12);
-  LZMA.initBitModels(this._posDecoders, 114);
+	LZMA.initBitModels(this._isMatchDecoders, 192);
+	LZMA.initBitModels(this._isRep0LongDecoders, 192);
+	LZMA.initBitModels(this._isRepDecoders, 12);
+	LZMA.initBitModels(this._isRepG0Decoders, 12);
+	LZMA.initBitModels(this._isRepG1Decoders, 12);
+	LZMA.initBitModels(this._isRepG2Decoders, 12);
+	LZMA.initBitModels(this._posDecoders, 114);
 
-  this._literalDecoder.init();
+	this._literalDecoder.init();
 
-  while (i --) {
-    this._posSlotDecoder[i].init();
-  }
+	while (i --) {
+		this._posSlotDecoder[i].init();
+	}
 
-  this._lenDecoder.init();
-  this._repLenDecoder.init();
-  this._posAlignDecoder.init();
-  this._rangeDecoder.init();
+	this._lenDecoder.init();
+	this._repLenDecoder.init();
+	this._posAlignDecoder.init();
+	this._rangeDecoder.init();
 };
 
 LZMA.Decoder.prototype.decode = function(inStream, outStream, outSize) {
-  var state = 0, rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0, nowPos64 = 0, prevByte = 0,
+	var state = 0, rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0, nowPos64 = 0, prevByte = 0,
       posState, decoder2, len, distance, posSlot, numDirectBits;
 
-  this._rangeDecoder.setStream(inStream);
-  this._outWindow.setStream(outStream);
-
-  this.init();
-
-  while (outSize < 0 || nowPos64 < outSize) {
-    posState = nowPos64 & this._posStateMask;
-
-    if (this._rangeDecoder.decodeBit(this._isMatchDecoders, (state << 4) + posState) === 0) {
-      decoder2 = this._literalDecoder.getDecoder(nowPos64 ++, prevByte);
-
-      if (state >= 7) {
-        prevByte = decoder2.decodeWithMatchByte(this._rangeDecoder, this._outWindow.getByte(rep0) );
-      }else {
-        prevByte = decoder2.decodeNormal(this._rangeDecoder);
-      }
-      this._outWindow.putByte(prevByte);
-
-      state = state < 4 ? 0 : state - (state < 10 ? 3 : 6);
-
-    }else {
-
-      if (this._rangeDecoder.decodeBit(this._isRepDecoders, state) === 1) {
-        len = 0;
-        if (this._rangeDecoder.decodeBit(this._isRepG0Decoders, state) === 0) {
-          if (this._rangeDecoder.decodeBit(this._isRep0LongDecoders, (state << 4) + posState) === 0) {
-            state = state < 7 ? 9 : 11;
-            len = 1;
-          }
-        }else {
-          if (this._rangeDecoder.decodeBit(this._isRepG1Decoders, state) === 0) {
-            distance = rep1;
-          }else {
-            if (this._rangeDecoder.decodeBit(this._isRepG2Decoders, state) === 0) {
-              distance = rep2;
-            }else {
-              distance = rep3;
-              rep3 = rep2;
-            }
-            rep2 = rep1;
-          }
-          rep1 = rep0;
-          rep0 = distance;
-        }
-        if (len === 0) {
-          len = 2 + this._repLenDecoder.decode(this._rangeDecoder, posState);
-          state = state < 7 ? 8 : 11;
-        }
-      }else {
-        rep3 = rep2;
-        rep2 = rep1;
-        rep1 = rep0;
-
-        len = 2 + this._lenDecoder.decode(this._rangeDecoder, posState);
-        state = state < 7 ? 7 : 10;
-
-        posSlot = this._posSlotDecoder[len <= 5 ? len - 2 : 3].decode(this._rangeDecoder);
-        if (posSlot >= 4) {
-
-          numDirectBits = (posSlot >> 1) - 1;
-          rep0 = (2 | (posSlot & 1) ) << numDirectBits;
-
-          if (posSlot < 14) {
-            rep0 += LZMA.reverseDecode2(this._posDecoders,
+	this._rangeDecoder.setStream(inStream);
+	this._outWindow.setStream(outStream);
+
+	this.init();
+
+	while (outSize < 0 || nowPos64 < outSize) {
+		posState = nowPos64 & this._posStateMask;
+
+		if (this._rangeDecoder.decodeBit(this._isMatchDecoders, (state << 4) + posState) === 0) {
+			decoder2 = this._literalDecoder.getDecoder(nowPos64 ++, prevByte);
+
+			if (state >= 7) {
+				prevByte = decoder2.decodeWithMatchByte(this._rangeDecoder, this._outWindow.getByte(rep0) );
+			}else {
+				prevByte = decoder2.decodeNormal(this._rangeDecoder);
+			}
+			this._outWindow.putByte(prevByte);
+
+			state = state < 4 ? 0 : state - (state < 10 ? 3 : 6);
+
+		}else {
+
+			if (this._rangeDecoder.decodeBit(this._isRepDecoders, state) === 1) {
+				len = 0;
+				if (this._rangeDecoder.decodeBit(this._isRepG0Decoders, state) === 0) {
+					if (this._rangeDecoder.decodeBit(this._isRep0LongDecoders, (state << 4) + posState) === 0) {
+						state = state < 7 ? 9 : 11;
+						len = 1;
+					}
+				}else {
+					if (this._rangeDecoder.decodeBit(this._isRepG1Decoders, state) === 0) {
+						distance = rep1;
+					}else {
+						if (this._rangeDecoder.decodeBit(this._isRepG2Decoders, state) === 0) {
+							distance = rep2;
+						}else {
+							distance = rep3;
+							rep3 = rep2;
+						}
+						rep2 = rep1;
+					}
+					rep1 = rep0;
+					rep0 = distance;
+				}
+				if (len === 0) {
+					len = 2 + this._repLenDecoder.decode(this._rangeDecoder, posState);
+					state = state < 7 ? 8 : 11;
+				}
+			}else {
+				rep3 = rep2;
+				rep2 = rep1;
+				rep1 = rep0;
+
+				len = 2 + this._lenDecoder.decode(this._rangeDecoder, posState);
+				state = state < 7 ? 7 : 10;
+
+				posSlot = this._posSlotDecoder[len <= 5 ? len - 2 : 3].decode(this._rangeDecoder);
+				if (posSlot >= 4) {
+
+					numDirectBits = (posSlot >> 1) - 1;
+					rep0 = (2 | (posSlot & 1) ) << numDirectBits;
+
+					if (posSlot < 14) {
+						rep0 += LZMA.reverseDecode2(this._posDecoders,
                 rep0 - posSlot - 1, this._rangeDecoder, numDirectBits);
-          }else {
-            rep0 += this._rangeDecoder.decodeDirectBits(numDirectBits - 4) << 4;
-            rep0 += this._posAlignDecoder.reverseDecode(this._rangeDecoder);
-            if (rep0 < 0) {
-              if (rep0 === -1) {
-                break;
-              }
-              return false;
-            }
-          }
-        }else {
-          rep0 = posSlot;
-        }
-      }
-
-      if (rep0 >= nowPos64 || rep0 >= this._dictionarySizeCheck) {
-        return false;
-      }
-
-      this._outWindow.copyBlock(rep0, len);
-      nowPos64 += len;
-      prevByte = this._outWindow.getByte(0);
-    }
-  }
-
-  this._outWindow.flush();
-  this._outWindow.releaseStream();
-  this._rangeDecoder.releaseStream();
-
-  return true;
+					}else {
+						rep0 += this._rangeDecoder.decodeDirectBits(numDirectBits - 4) << 4;
+						rep0 += this._posAlignDecoder.reverseDecode(this._rangeDecoder);
+						if (rep0 < 0) {
+							if (rep0 === -1) {
+								break;
+							}
+							return false;
+						}
+					}
+				}else {
+					rep0 = posSlot;
+				}
+			}
+
+			if (rep0 >= nowPos64 || rep0 >= this._dictionarySizeCheck) {
+				return false;
+			}
+
+			this._outWindow.copyBlock(rep0, len);
+			nowPos64 += len;
+			prevByte = this._outWindow.getByte(0);
+		}
+	}
+
+	this._outWindow.flush();
+	this._outWindow.releaseStream();
+	this._rangeDecoder.releaseStream();
+
+	return true;
 };
 
 LZMA.Decoder.prototype.setDecoderProperties = function(properties) {
-  var value, lc, lp, pb, dictionarySize;
+	var value, lc, lp, pb, dictionarySize;
 
-  if (properties.size < 5) {
-    return false;
-  }
+	if (properties.size < 5) {
+		return false;
+	}
 
-  value = properties.readByte();
-  lc = value % 9;
-  value = ~~(value / 9);
-  lp = value % 5;
-  pb = ~~(value / 5);
+	value = properties.readByte();
+	lc = value % 9;
+	value = ~~(value / 9);
+	lp = value % 5;
+	pb = ~~(value / 5);
 
-  if ( !this.setLcLpPb(lc, lp, pb) ) {
-    return false;
-  }
+	if ( !this.setLcLpPb(lc, lp, pb) ) {
+		return false;
+	}
 
-  dictionarySize = properties.readByte();
-  dictionarySize |= properties.readByte() << 8;
-  dictionarySize |= properties.readByte() << 16;
-  dictionarySize += properties.readByte() * 16777216;
+	dictionarySize = properties.readByte();
+	dictionarySize |= properties.readByte() << 8;
+	dictionarySize |= properties.readByte() << 16;
+	dictionarySize += properties.readByte() * 16777216;
 
-  return this.setDictionarySize(dictionarySize);
+	return this.setDictionarySize(dictionarySize);
 };
 
 LZMA.decompress = function(properties, inStream, outStream, outSize) {
-  var decoder = new LZMA.Decoder();
+	var decoder = new LZMA.Decoder();
 
-  if ( !decoder.setDecoderProperties(properties) ) {
-    throw "Incorrect stream properties";
-  }
+	if ( !decoder.setDecoderProperties(properties) ) {
+		throw "Incorrect stream properties";
+	}
 
-  if ( !decoder.decode(inStream, outStream, outSize) ) {
-    throw "Error in data stream";
-  }
+	if ( !decoder.decode(inStream, outStream, outSize) ) {
+		throw "Error in data stream";
+	}
 
-  return true;
+	return true;
 };

+ 1 - 1
examples/js/loaders/deprecated/SceneLoader.js

@@ -430,7 +430,7 @@ THREE.SceneLoader.prototype = {
 
 						} else if ( objJSON.target ) {
 
-						    camera.lookAt( new THREE.Vector3().fromArray( objJSON.target ) );
+							camera.lookAt( new THREE.Vector3().fromArray( objJSON.target ) );
 
 						}
 

+ 168 - 168
examples/js/loaders/gltf/glTF-parser.js

@@ -49,35 +49,35 @@
 */
 var global = window;
 (function (root, factory) {
-    if (typeof exports === 'object') {
+	if (typeof exports === 'object') {
         // Node. Does not work with strict CommonJS, but
         // only CommonJS-like enviroments that support module.exports,
         // like Node.
-        factory(module.exports);
-    } else if (typeof define === 'function' && define.amd) {
+		factory(module.exports);
+	} else if (typeof define === 'function' && define.amd) {
         // AMD. Register as an anonymous module.
-        define([], function () {
-            return factory(root);
-        });
-    } else {
+		define([], function () {
+			return factory(root);
+		});
+	} else {
         // Browser globals
-        factory(root);
-    }
+		factory(root);
+	}
 }(this, function (root) {
-    "use strict";
+	"use strict";
 
-    var categoriesDepsOrder = [ "buffers", "bufferViews", "images",  "videos", "samplers", "textures", "shaders", "programs", "techniques", "materials", "accessors", "meshes", "cameras", "lights", "skins", "nodes", "scenes", "animations" ];
+	var categoriesDepsOrder = [ "buffers", "bufferViews", "images",  "videos", "samplers", "textures", "shaders", "programs", "techniques", "materials", "accessors", "meshes", "cameras", "lights", "skins", "nodes", "scenes", "animations" ];
 
-    var glTFParser = Object.create(Object.prototype, {
+	var glTFParser = Object.create(Object.prototype, {
 
         _rootDescription: { value: null, writable: true },
 
         rootDescription: {
             set: function(value) {
-                this._rootDescription = value;
+	this._rootDescription = value;
             },
             get: function() {
-                return this._rootDescription;
+	return this._rootDescription;
             }
         },
 
@@ -86,34 +86,34 @@ var global = window;
         //detect absolute path following the same protocol than window.location
         _isAbsolutePath: {
             value: function(path) {
-                var isAbsolutePathRegExp = new RegExp("^" + window.location.protocol, "i");
+	var isAbsolutePathRegExp = new RegExp("^" + window.location.protocol, "i");
 
-                return path.match(isAbsolutePathRegExp) ? true : false;
+	return path.match(isAbsolutePathRegExp) ? true : false;
             }
         },
 
         resolvePathIfNeeded: {
             value: function(path) {
-                if (this._isAbsolutePath(path)) {
-                    return path;
-                }
+	if (this._isAbsolutePath(path)) {
+		return path;
+	}
 
-                return this.baseURL + path;
+	return this.baseURL + path;
             }
         },
 
         _resolvePathsForCategories: {
             value: function(categories) {
-                categories.forEach( function(category) {
-                    var descriptions = this.json[category];
-                    if (descriptions) {
-                        var descriptionKeys = Object.keys(descriptions);
-                        descriptionKeys.forEach( function(descriptionKey) {
-                            var description = descriptions[descriptionKey];
-                            description.path = this.resolvePathIfNeeded(description.path);
-                        }, this);
-                    }
-                }, this);
+	categories.forEach( function(category) {
+		var descriptions = this.json[category];
+		if (descriptions) {
+			var descriptionKeys = Object.keys(descriptions);
+			descriptionKeys.forEach( function(descriptionKey) {
+				var description = descriptions[descriptionKey];
+				description.path = this.resolvePathIfNeeded(description.path);
+			}, this);
+		}
+	}, this);
             }
         },
 
@@ -125,13 +125,13 @@ var global = window;
         json: {
             enumerable: true,
             get: function() {
-                return this._json;
+	return this._json;
             },
             set: function(value) {
-                if (this._json !== value) {
-                    this._json = value;
-                    this._resolvePathsForCategories([ "buffers", "shaders", "images", "videos" ]);
-                }
+	if (this._json !== value) {
+		this._json = value;
+		this._resolvePathsForCategories([ "buffers", "shaders", "images", "videos" ]);
+	}
             }
         },
 
@@ -142,60 +142,60 @@ var global = window;
 
         getEntryDescription: {
             value: function (entryID, entryType) {
-                var entries = null;
+	var entries = null;
 
-                var category = entryType;
-                entries = this.rootDescription[category];
-                if (!entries) {
-                    console.log("ERROR:CANNOT find expected category named:" + category);
-                    return null;
-                }
+	var category = entryType;
+	entries = this.rootDescription[category];
+	if (!entries) {
+		console.log("ERROR:CANNOT find expected category named:" + category);
+		return null;
+	}
 
-                return entries ? entries[entryID] : null;
+	return entries ? entries[entryID] : null;
             }
         },
 
         _stepToNextCategory: {
             value: function() {
-                this._state.categoryIndex = this.getNextCategoryIndex(this._state.categoryIndex + 1);
-                if (this._state.categoryIndex !== -1) {
-                    this._state.categoryState.index = 0;
-                    return true;
-                }
+	this._state.categoryIndex = this.getNextCategoryIndex(this._state.categoryIndex + 1);
+	if (this._state.categoryIndex !== -1) {
+		this._state.categoryState.index = 0;
+		return true;
+	}
 
-                return false;
+	return false;
             }
         },
 
         _stepToNextDescription: {
             enumerable: false,
             value: function() {
-                var categoryState = this._state.categoryState;
-                var keys = categoryState.keys;
-                if (!keys) {
-                    console.log("INCONSISTENCY ERROR");
-                    return false;
-                }
-
-                categoryState.index ++;
-                categoryState.keys = null;
-                if (categoryState.index >= keys.length) {
-                    return this._stepToNextCategory();
-                }
-                return false;
+	var categoryState = this._state.categoryState;
+	var keys = categoryState.keys;
+	if (!keys) {
+		console.log("INCONSISTENCY ERROR");
+		return false;
+	}
+
+	categoryState.index ++;
+	categoryState.keys = null;
+	if (categoryState.index >= keys.length) {
+		return this._stepToNextCategory();
+	}
+	return false;
             }
         },
 
         hasCategory: {
             value: function(category) {
-                return this.rootDescription[category] ? true : false;
+	return this.rootDescription[category] ? true : false;
             }
         },
 
         _handleState: {
             value: function() {
 
-                var methodForType = {
+	var methodForType = {
                     "buffers" : this.handleBuffer,
                     "bufferViews" : this.handleBufferView,
                     "shaders" : this.handleShader,
@@ -217,46 +217,46 @@ var global = window;
 
                 };
 
-                var success = true;
-                while (this._state.categoryIndex !== -1) {
-                    var category = categoriesDepsOrder[this._state.categoryIndex];
-                    var categoryState = this._state.categoryState;
-                    var keys = categoryState.keys;
-                    if (!keys) {
-                        categoryState.keys = keys = Object.keys(this.rootDescription[category]);
-                        if (keys) {
-                            if (keys.length == 0) {
-                                this._stepToNextDescription();
-                                continue;
-                            }
-                        }
-                    }
-
-                    var type = category;
-                    var entryID = keys[categoryState.index];
-                    var description = this.getEntryDescription(entryID, type);
-                    if (!description) {
-                        if (this.handleError) {
-                            this.handleError("INCONSISTENCY ERROR: no description found for entry " + entryID);
-                            success = false;
-                            break;
-                        }
-                    } else {
-
-                        if (methodForType[type]) {
-                            if (methodForType[type].call(this, entryID, description, this._state.userInfo) === false) {
-                                success = false;
-                                break;
-                            }
-                        }
-
-                        this._stepToNextDescription();
-                    }
-                }
-
-                if (this.handleLoadCompleted) {
-                    this.handleLoadCompleted(success);
-                }
+	var success = true;
+	while (this._state.categoryIndex !== -1) {
+		var category = categoriesDepsOrder[this._state.categoryIndex];
+		var categoryState = this._state.categoryState;
+		var keys = categoryState.keys;
+		if (!keys) {
+			categoryState.keys = keys = Object.keys(this.rootDescription[category]);
+			if (keys) {
+				if (keys.length == 0) {
+					this._stepToNextDescription();
+					continue;
+				}
+			}
+		}
+
+		var type = category;
+		var entryID = keys[categoryState.index];
+		var description = this.getEntryDescription(entryID, type);
+		if (!description) {
+			if (this.handleError) {
+				this.handleError("INCONSISTENCY ERROR: no description found for entry " + entryID);
+				success = false;
+				break;
+			}
+		} else {
+
+			if (methodForType[type]) {
+				if (methodForType[type].call(this, entryID, description, this._state.userInfo) === false) {
+					success = false;
+					break;
+				}
+			}
+
+			this._stepToNextDescription();
+		}
+	}
+
+	if (this.handleLoadCompleted) {
+		this.handleLoadCompleted(success);
+	}
 
             }
         },
@@ -264,40 +264,40 @@ var global = window;
         _loadJSONIfNeeded: {
             enumerable: true,
             value: function(callback) {
-                var self = this;
+	var self = this;
                 //FIXME: handle error
-                if (!this._json) {
-                    var jsonPath = this._path;
-                    var i = jsonPath.lastIndexOf("/");
-                    this.baseURL = (i !== 0) ? jsonPath.substring(0, i + 1) : '';
-                    var jsonfile = new XMLHttpRequest();
-                    jsonfile.open("GET", jsonPath, true);
-                    jsonfile.addEventListener( 'load', function ( event ) {
-                        self.json = JSON.parse(jsonfile.responseText);
-                        if (callback) {
-                            callback(self.json);
-                        }
-                    }, false );
-                    jsonfile.send(null);
-               } else {
-                    if (callback) {
-                        callback(this.json);
-                    }
-                }
+	if (!this._json) {
+		var jsonPath = this._path;
+		var i = jsonPath.lastIndexOf("/");
+		this.baseURL = (i !== 0) ? jsonPath.substring(0, i + 1) : '';
+		var jsonfile = new XMLHttpRequest();
+		jsonfile.open("GET", jsonPath, true);
+		jsonfile.addEventListener( 'load', function ( event ) {
+			self.json = JSON.parse(jsonfile.responseText);
+			if (callback) {
+				callback(self.json);
+			}
+		}, false );
+		jsonfile.send(null);
+	} else {
+		if (callback) {
+			callback(this.json);
+		}
+	}
             }
         },
 
         /* load JSON and assign it as description to the reader */
         _buildLoader: {
             value: function(callback) {
-                var self = this;
-                function JSONReady(json) {
-                    self.rootDescription = json;
-                    if (callback)
+	var self = this;
+	function JSONReady(json) {
+		self.rootDescription = json;
+		if (callback)
                         callback(this);
-                }
+	}
 
-                this._loadJSONIfNeeded(JSONReady);
+	this._loadJSONIfNeeded(JSONReady);
             }
         },
 
@@ -305,51 +305,51 @@ var global = window;
 
         _getEntryType: {
             value: function(entryID) {
-                var rootKeys = categoriesDepsOrder;
-                for (var i = 0 ; i < rootKeys.length ; i ++) {
-                    var rootValues = this.rootDescription[rootKeys[i]];
-                    if (rootValues) {
-                        return rootKeys[i];
-                    }
-                }
-                return null;
+	var rootKeys = categoriesDepsOrder;
+	for (var i = 0 ; i < rootKeys.length ; i ++) {
+		var rootValues = this.rootDescription[rootKeys[i]];
+		if (rootValues) {
+			return rootKeys[i];
+		}
+	}
+	return null;
             }
         },
 
         getNextCategoryIndex: {
             value: function(currentIndex) {
-                for (var i = currentIndex ; i < categoriesDepsOrder.length ; i ++) {
-                    if (this.hasCategory(categoriesDepsOrder[i])) {
-                        return i;
-                    }
-                }
+	for (var i = currentIndex ; i < categoriesDepsOrder.length ; i ++) {
+		if (this.hasCategory(categoriesDepsOrder[i])) {
+			return i;
+		}
+	}
 
-                return -1;
+	return -1;
             }
         },
 
         load: {
             enumerable: true,
             value: function(userInfo, options) {
-                var self = this;
-                this._buildLoader(function loaderReady(reader) {
-                    var startCategory = self.getNextCategoryIndex.call(self, 0);
-                    if (startCategory !== -1) {
-                        self._state = { "userInfo" : userInfo,
+	var self = this;
+	this._buildLoader(function loaderReady(reader) {
+		var startCategory = self.getNextCategoryIndex.call(self, 0);
+		if (startCategory !== -1) {
+			self._state = { "userInfo" : userInfo,
                                         "options" : options,
                                         "categoryIndex" : startCategory,
                                         "categoryState" : { "index" : "0" } };
-                        self._handleState();
-                    }
-                });
+			self._handleState();
+		}
+	});
             }
         },
 
         initWithPath: {
             value: function(path) {
-                this._path = path;
-                this._json = null;
-                return this;
+	this._path = path;
+	this._json = null;
+	return this;
             }
         },
 
@@ -359,30 +359,30 @@ var global = window;
         //to be invoked by subclass, so that ids can be ensured to not overlap
         loaderContext: {
             value: function() {
-                if (typeof this._knownURLs[this._path] === "undefined") {
-                    this._knownURLs[this._path] = Object.keys(this._knownURLs).length;
-                }
-                return "__" + this._knownURLs[this._path];
+	if (typeof this._knownURLs[this._path] === "undefined") {
+		this._knownURLs[this._path] = Object.keys(this._knownURLs).length;
+	}
+	return "__" + this._knownURLs[this._path];
             }
         },
 
         initWithJSON: {
             value: function(json, baseURL) {
-                this.json = json;
-                this.baseURL = baseURL;
-                if (!baseURL) {
-                    console.log("WARNING: no base URL passed to Reader:initWithJSON");
-                }
-                return this;
+	this.json = json;
+	this.baseURL = baseURL;
+	if (!baseURL) {
+		console.log("WARNING: no base URL passed to Reader:initWithJSON");
+	}
+	return this;
             }
         }
 
     });
 
-    if (root) {
-        root.glTFParser = glTFParser;
-    }
+	if (root) {
+		root.glTFParser = glTFParser;
+	}
 
-    return glTFParser;
+	return glTFParser;
 
 }));

Разница между файлами не показана из-за своего большого размера
+ 522 - 522
examples/js/loaders/gltf/glTFLoader.js


+ 102 - 102
examples/js/loaders/gltf/glTFLoaderUtils.js

@@ -26,8 +26,8 @@ THREE.GLTFLoaderUtils = Object.create(Object, {
         value: function() {
 	        this._streams = {};
 	        this._streamsStatus = {};
-            this._resources = {};
-            this._resourcesStatus = {};
+	this._resources = {};
+	this._resourcesStatus = {};
         }
     },
 
@@ -35,60 +35,60 @@ THREE.GLTFLoaderUtils = Object.create(Object, {
     _containsResource: {
         enumerable: false,
         value: function(resourceID) {
-            return this._resources[resourceID] ? true : false;
+	return this._resources[resourceID] ? true : false;
         }
     },
 
     _storeResource: {
         enumerable: false,
         value: function(resourceID, resource) {
-            if (!resourceID) {
-                console.log("ERROR: entry does not contain id, cannot store");
-                return;
-            }
+	if (!resourceID) {
+		console.log("ERROR: entry does not contain id, cannot store");
+		return;
+	}
 
-            if (this._containsResource[resourceID]) {
-                console.log("WARNING: resource:" + resourceID + " is already stored, overriding");
-            }
+	if (this._containsResource[resourceID]) {
+		console.log("WARNING: resource:" + resourceID + " is already stored, overriding");
+	}
 
-           this._resources[resourceID] = resource;
+	this._resources[resourceID] = resource;
         }
     },
 
     _getResource: {
         enumerable: false,
         value: function(resourceID) {
-            return this._resources[resourceID];
+	return this._resources[resourceID];
         }
     },
 
     _loadStream: {
         value: function(path, type, delegate) {
-            var self = this;
+	var self = this;
 
-            if (!type) {
-                delegate.handleError(THREE.GLTFLoaderUtils.INVALID_TYPE, null);
-                return;
-            }
+	if (!type) {
+		delegate.handleError(THREE.GLTFLoaderUtils.INVALID_TYPE, null);
+		return;
+	}
 
-            if (!path) {
-                delegate.handleError(THREE.GLTFLoaderUtils.INVALID_PATH);
-                return;
-            }
+	if (!path) {
+		delegate.handleError(THREE.GLTFLoaderUtils.INVALID_PATH);
+		return;
+	}
 
-            var xhr = new XMLHttpRequest();
-            xhr.open('GET', path, true);
-            xhr.responseType = (type === this.ARRAY_BUFFER) ? "arraybuffer" : "text";
+	var xhr = new XMLHttpRequest();
+	xhr.open('GET', path, true);
+	xhr.responseType = (type === this.ARRAY_BUFFER) ? "arraybuffer" : "text";
 
             //if this is not specified, 1 "big blob" scenes fails to load.
-            xhr.setRequestHeader("If-Modified-Since", "Sat, 01 Jan 1970 00:00:00 GMT");
-            xhr.addEventListener( 'load', function ( event ) {
-                delegate.streamAvailable(path, xhr.response);
-            }, false );
-            xhr.addEventListener( 'error', function ( event ) {
-                delegate.handleError(THREE.GLTFLoaderUtils.XMLHTTPREQUEST_STATUS_ERROR, xhr.status);
-            }, false );
-            xhr.send(null);
+	xhr.setRequestHeader("If-Modified-Since", "Sat, 01 Jan 1970 00:00:00 GMT");
+	xhr.addEventListener( 'load', function ( event ) {
+		delegate.streamAvailable(path, xhr.response);
+	}, false );
+	xhr.addEventListener( 'error', function ( event ) {
+		delegate.handleError(THREE.GLTFLoaderUtils.XMLHTTPREQUEST_STATUS_ERROR, xhr.status);
+	}, false );
+	xhr.send(null);
         }
     },
 
@@ -97,86 +97,86 @@ THREE.GLTFLoaderUtils = Object.create(Object, {
 
     _handleRequest: {
         value: function(request) {
-            var resourceStatus = this._resourcesStatus[request.id];
-            if (resourceStatus)
+	var resourceStatus = this._resourcesStatus[request.id];
+	if (resourceStatus)
             {
-            	this._resourcesStatus[request.id] ++;
-            }
+		this._resourcesStatus[request.id] ++;
+	}
             else
-            {
-            	this._resourcesStatus[request.id] = 1;
-            }
+	{
+		this._resourcesStatus[request.id] = 1;
+	}
             
-            var streamStatus = this._streamsStatus[request.path];
-            if (streamStatus && streamStatus.status === "loading" )
+	var streamStatus = this._streamsStatus[request.path];
+	if (streamStatus && streamStatus.status === "loading" )
             {
-            	streamStatus.requests.push(request);
-                return;
-            }
+		streamStatus.requests.push(request);
+		return;
+	}
             
-            this._streamsStatus[request.path] = { status : "loading", requests : [ request ] };
+	this._streamsStatus[request.path] = { status : "loading", requests : [ request ] };
     		
-            var self = this;
-            var processResourceDelegate = {};
-
-            processResourceDelegate.streamAvailable = function(path, res_) {
-            	var streamStatus = self._streamsStatus[path];
-            	var requests = streamStatus.requests;
-                requests.forEach( function(req_) {
-                    var subArray = res_.slice(req_.range[0], req_.range[1]);
-                    var convertedResource = req_.delegate.convert(subArray, req_.ctx);
-                    self._storeResource(req_.id, convertedResource);
-                    req_.delegate.resourceAvailable(convertedResource, req_.ctx);
-                    -- self._resourcesStatus[req_.id];
-
-                }, this);
+	var self = this;
+	var processResourceDelegate = {};
+
+	processResourceDelegate.streamAvailable = function(path, res_) {
+		var streamStatus = self._streamsStatus[path];
+		var requests = streamStatus.requests;
+		requests.forEach( function(req_) {
+			var subArray = res_.slice(req_.range[0], req_.range[1]);
+			var convertedResource = req_.delegate.convert(subArray, req_.ctx);
+			self._storeResource(req_.id, convertedResource);
+			req_.delegate.resourceAvailable(convertedResource, req_.ctx);
+			-- self._resourcesStatus[req_.id];
+
+		}, this);
             	
-                delete self._streamsStatus[path];
+		delete self._streamsStatus[path];
 
-            };
+	};
 
-            processResourceDelegate.handleError = function(errorCode, info) {
-                request.delegate.handleError(errorCode, info);
-            }
+	processResourceDelegate.handleError = function(errorCode, info) {
+		request.delegate.handleError(errorCode, info);
+	}
 
-            this._loadStream(request.path, request.type, processResourceDelegate);
+	this._loadStream(request.path, request.type, processResourceDelegate);
         }
     },
 
 
     _elementSizeForGLType: {
         value: function(glType) {
-            switch (glType) {
-                case WebGLRenderingContext.FLOAT :
-                    return Float32Array.BYTES_PER_ELEMENT;
-                case WebGLRenderingContext.UNSIGNED_BYTE :
-                    return Uint8Array.BYTES_PER_ELEMENT;
-                case WebGLRenderingContext.UNSIGNED_SHORT :
-                    return Uint16Array.BYTES_PER_ELEMENT;
-                case WebGLRenderingContext.FLOAT_VEC2 :
-                    return Float32Array.BYTES_PER_ELEMENT * 2;
-                case WebGLRenderingContext.FLOAT_VEC3 :
-                    return Float32Array.BYTES_PER_ELEMENT * 3;
-                case WebGLRenderingContext.FLOAT_VEC4 :
-                    return Float32Array.BYTES_PER_ELEMENT * 4;
-                case WebGLRenderingContext.FLOAT_MAT3 :
-                    return Float32Array.BYTES_PER_ELEMENT * 9;
-                case WebGLRenderingContext.FLOAT_MAT4 :
-                    return Float32Array.BYTES_PER_ELEMENT * 16;
-                default:
-                    return null;
-            }
+	switch (glType) {
+		case WebGLRenderingContext.FLOAT :
+			return Float32Array.BYTES_PER_ELEMENT;
+		case WebGLRenderingContext.UNSIGNED_BYTE :
+			return Uint8Array.BYTES_PER_ELEMENT;
+		case WebGLRenderingContext.UNSIGNED_SHORT :
+			return Uint16Array.BYTES_PER_ELEMENT;
+		case WebGLRenderingContext.FLOAT_VEC2 :
+			return Float32Array.BYTES_PER_ELEMENT * 2;
+		case WebGLRenderingContext.FLOAT_VEC3 :
+			return Float32Array.BYTES_PER_ELEMENT * 3;
+		case WebGLRenderingContext.FLOAT_VEC4 :
+			return Float32Array.BYTES_PER_ELEMENT * 4;
+		case WebGLRenderingContext.FLOAT_MAT3 :
+			return Float32Array.BYTES_PER_ELEMENT * 9;
+		case WebGLRenderingContext.FLOAT_MAT4 :
+			return Float32Array.BYTES_PER_ELEMENT * 16;
+		default:
+			return null;
+	}
         }
     },
 
     _handleWrappedBufferViewResourceLoading: {
         value: function(wrappedBufferView, delegate, ctx) {
-            var bufferView = wrappedBufferView.bufferView;
-            var buffer = bufferView.buffer;
-            var byteOffset = wrappedBufferView.byteOffset + bufferView.description.byteOffset;
-            var range = [ byteOffset, (this._elementSizeForGLType(wrappedBufferView.type) * wrappedBufferView.count) + byteOffset ];
+	var bufferView = wrappedBufferView.bufferView;
+	var buffer = bufferView.buffer;
+	var byteOffset = wrappedBufferView.byteOffset + bufferView.description.byteOffset;
+	var range = [ byteOffset, (this._elementSizeForGLType(wrappedBufferView.type) * wrappedBufferView.count) + byteOffset ];
 
-            this._handleRequest({ "id" : wrappedBufferView.id,
+	this._handleRequest({ "id" : wrappedBufferView.id,
                                     "range" : range,
                                     "type" : buffer.description.type,
                                     "path" : buffer.description.path,
@@ -189,14 +189,14 @@ THREE.GLTFLoaderUtils = Object.create(Object, {
     	
             value: function(wrappedBufferView, delegate, ctx) {
 
-            var savedBuffer = this._getResource(wrappedBufferView.id);
-            if (savedBuffer) {
-                return savedBuffer;
-            } else {
-                this._handleWrappedBufferViewResourceLoading(wrappedBufferView, delegate, ctx);
-            }
+	var savedBuffer = this._getResource(wrappedBufferView.id);
+	if (savedBuffer) {
+		return savedBuffer;
+	} else {
+		this._handleWrappedBufferViewResourceLoading(wrappedBufferView, delegate, ctx);
+	}
 
-            return null;
+	return null;
         }
     },
 
@@ -204,17 +204,17 @@ THREE.GLTFLoaderUtils = Object.create(Object, {
     	
         value: function(request, delegate, ctx) {
 
-    		request.delegate = delegate;
-    		request.ctx = ctx;
+	request.delegate = delegate;
+	request.ctx = ctx;
 
-            this._handleRequest({ "id" : request.id,
+	this._handleRequest({ "id" : request.id,
                 "path" : request.path,
                 "range" : [ 0 ],
                 "type" : "text",
                 "delegate" : delegate,
                 "ctx" : ctx }, null);
     	
-            return null;
-	    }
+	return null;
+}
 	},    
 });

+ 1 - 1
examples/js/renderers/SVGRenderer.js

@@ -215,7 +215,7 @@ THREE.SVGRenderer = function () {
 				var x =   _vector3.x * _svgWidthHalf;
 				var y = - _vector3.y * _svgHeightHalf;
 
-			 	var node = object.node;
+				var node = object.node;
 				node.setAttribute( 'transform', 'translate(' + x + ',' + y + ')' );
 
 				_svg.appendChild( node );

+ 2 - 2
examples/js/renderers/SoftwareRenderer.js

@@ -404,8 +404,8 @@ THREE.SoftwareRenderer = function ( parameters ) {
 							+ (material.palette[cIndex + 2] * tdata[tIndex + 2]);
 
 			if (opaci < 250) {
-			var backColor = buffer[ colorOffset ] << 24 + buffer[ colorOffset + 1 ] << 16 + buffer[ colorOffset + 2 ] << 8;
-			foreColor = foreColor * opaci + backColor * (1 - opaci);
+				var backColor = buffer[ colorOffset ] << 24 + buffer[ colorOffset + 1 ] << 16 + buffer[ colorOffset + 2 ] << 8;
+				foreColor = foreColor * opaci + backColor * (1 - opaci);
 			}
 
 			buffer[ colorOffset ] = (foreColor & 0xff0000) >> 16;

+ 55 - 55
examples/js/utils/UVsDebug.js

@@ -16,104 +16,104 @@ THREE.UVsDebug = function( geometry, size ) {
 
     // handles wrapping of uv.x > 1 only
     
-    var abc = 'abcd';
+	var abc = 'abcd';
 
-    var uv, u, ax, ay;
-    var i, il, j, jl;
-    var vnum;
+	var uv, u, ax, ay;
+	var i, il, j, jl;
+	var vnum;
 
-    var a = new THREE.Vector2();
-    var b = new THREE.Vector2();
+	var a = new THREE.Vector2();
+	var b = new THREE.Vector2();
 
-    var faces = geometry.faces;
-    var uvs = geometry.faceVertexUvs[ 0 ];
+	var faces = geometry.faces;
+	var uvs = geometry.faceVertexUvs[ 0 ];
 
-    var canvas = document.createElement( 'canvas' );
-    var width = size || 1024;   // power of 2 required for wrapping
-    var height = size || 1024;
-    canvas.width = width;
-    canvas.height = height;
+	var canvas = document.createElement( 'canvas' );
+	var width = size || 1024;   // power of 2 required for wrapping
+	var height = size || 1024;
+	canvas.width = width;
+	canvas.height = height;
 
-    var ctx = canvas.getContext( '2d' );
-    ctx.lineWidth = 2;
-    ctx.strokeStyle = 'rgba( 0, 0, 0, 1.0 )';
-    ctx.textAlign = 'center';
+	var ctx = canvas.getContext( '2d' );
+	ctx.lineWidth = 2;
+	ctx.strokeStyle = 'rgba( 0, 0, 0, 1.0 )';
+	ctx.textAlign = 'center';
 
     // paint background white
 
-    ctx.fillStyle = 'rgba( 255, 255, 255, 1.0 )';
-    ctx.fillRect( 0, 0, width, height );
+	ctx.fillStyle = 'rgba( 255, 255, 255, 1.0 )';
+	ctx.fillRect( 0, 0, width, height );
 
-    for ( i = 0, il = uvs.length; i < il; i ++ ) {
+	for ( i = 0, il = uvs.length; i < il; i ++ ) {
 
-        uv = uvs[ i ];
+		uv = uvs[ i ];
 
         // draw lines
 
-        ctx.beginPath();
+		ctx.beginPath();
 
-        a.set( 0, 0 );
+		a.set( 0, 0 );
 
-        for ( j = 0, jl = uv.length; j < jl; j ++ ) {
+		for ( j = 0, jl = uv.length; j < jl; j ++ ) {
 
-            u = uv[ j ];
+			u = uv[ j ];
 
-            a.x += u.x;
-            a.y += u.y;
+			a.x += u.x;
+			a.y += u.y;
 
-            if ( j == 0 ) {
+			if ( j == 0 ) {
 
-                ctx.moveTo( u.x * width, ( 1 - u.y ) * height );
+				ctx.moveTo( u.x * width, ( 1 - u.y ) * height );
 
-            } else {
+			} else {
 
-                ctx.lineTo( u.x * width, ( 1 - u.y ) * height );
+				ctx.lineTo( u.x * width, ( 1 - u.y ) * height );
 
-            }
+			}
 
-        }
+		}
 
-        ctx.closePath();
-        ctx.stroke();
+		ctx.closePath();
+		ctx.stroke();
 
-        a.divideScalar( jl );
+		a.divideScalar( jl );
 
         // label the face number
 
-        ctx.font = "12pt Arial bold";
-        ctx.fillStyle = 'rgba( 0, 0, 0, 1.0 )';
-        ctx.fillText( i, a.x * width, ( 1 - a.y ) * height );
+		ctx.font = "12pt Arial bold";
+		ctx.fillStyle = 'rgba( 0, 0, 0, 1.0 )';
+		ctx.fillText( i, a.x * width, ( 1 - a.y ) * height );
 
-        if ( a.x > 0.95 ) { // wrap x // 0.95 is arbitrary
+		if ( a.x > 0.95 ) { // wrap x // 0.95 is arbitrary
 
-            ctx.fillText( i, ( a.x % 1 ) * width, ( 1 - a.y ) * height );
+			ctx.fillText( i, ( a.x % 1 ) * width, ( 1 - a.y ) * height );
 
-        }
+		}
 
-        ctx.font = "8pt Arial bold";
-        ctx.fillStyle = 'rgba( 0, 0, 0, 1.0 )';
+		ctx.font = "8pt Arial bold";
+		ctx.fillStyle = 'rgba( 0, 0, 0, 1.0 )';
 
         // label uv edge orders
 
-        for ( j = 0, jl = uv.length; j < jl; j ++ ) {
+		for ( j = 0, jl = uv.length; j < jl; j ++ ) {
 
-            u = uv[ j ];
-            b.addVectors( a, u ).divideScalar( 2 );
+			u = uv[ j ];
+			b.addVectors( a, u ).divideScalar( 2 );
 
-            vnum = faces[ i ][ abc[ j ] ];
-            ctx.fillText( abc[ j ] + vnum, b.x * width, ( 1 - b.y ) * height );
+			vnum = faces[ i ][ abc[ j ] ];
+			ctx.fillText( abc[ j ] + vnum, b.x * width, ( 1 - b.y ) * height );
 
-            if ( b.x > 0.95 ) {  // wrap x
+			if ( b.x > 0.95 ) {  // wrap x
 
-                ctx.fillText( abc[ j ] + vnum, ( b.x % 1 ) * width, ( 1 - b.y ) * height );
+				ctx.fillText( abc[ j ] + vnum, ( b.x % 1 ) * width, ( 1 - b.y ) * height );
 
-            }
+			}
 
-        }
+		}
 
-    }
+	}
 
-    return canvas;
+	return canvas;
 
 }
 

+ 25 - 25
examples/js/wip/benchmark/Geometry4.js

@@ -1,18 +1,18 @@
 THREE.Geometry4 = function ( size ) {
 
-        THREE.BufferGeometry.call( this );
+	THREE.BufferGeometry.call( this );
 
-        var verticesBuffer = new ArrayBuffer( size * 3 * 4 );
-        var normalsBuffer = new ArrayBuffer( size * 3 * 4 );
-        var uvsBuffer = new ArrayBuffer( size * 2 * 4 );
+	var verticesBuffer = new ArrayBuffer( size * 3 * 4 );
+	var normalsBuffer = new ArrayBuffer( size * 3 * 4 );
+	var uvsBuffer = new ArrayBuffer( size * 2 * 4 );
 
-        this.attributes[ 'position' ] = { array: new Float32Array( verticesBuffer, 0, size * 3 ), itemSize: 3 };
-        this.attributes[ 'normal' ] = { array: new Float32Array( normalsBuffer, 0, size * 3 ), itemSize: 3 };
-        this.attributes[ 'uv' ] = { array: new Float32Array( uvsBuffer, 0, size * 2 ), itemSize: 2 };
+	this.attributes[ 'position' ] = { array: new Float32Array( verticesBuffer, 0, size * 3 ), itemSize: 3 };
+	this.attributes[ 'normal' ] = { array: new Float32Array( normalsBuffer, 0, size * 3 ), itemSize: 3 };
+	this.attributes[ 'uv' ] = { array: new Float32Array( uvsBuffer, 0, size * 2 ), itemSize: 2 };
 
-        this.vertices = new THREE.VectorArrayProxy( this.attributes[ 'position' ] );
-        this.normals = new THREE.VectorArrayProxy( this.attributes[ 'normal' ] );
-        this.uvs = new THREE.VectorArrayProxy( this.attributes[ 'uv' ] );
+	this.vertices = new THREE.VectorArrayProxy( this.attributes[ 'position' ] );
+	this.normals = new THREE.VectorArrayProxy( this.attributes[ 'normal' ] );
+	this.uvs = new THREE.VectorArrayProxy( this.attributes[ 'uv' ] );
 
 };
 THREE.Geometry4.prototype = Object.create( THREE.BufferGeometry.prototype );
@@ -22,16 +22,16 @@ THREE.VectorArrayProxy = function(attribute) {
 
         // Acts as a proxy for an array of vectors, by setting up accessors which return THREE.Vector*Proxy objects
 
-        this.attribute = attribute;
+	this.attribute = attribute;
 
-        for (var i = 0, l = this.attribute.array.length / this.attribute.itemSize; i < l; i ++) {
+	for (var i = 0, l = this.attribute.array.length / this.attribute.itemSize; i < l; i ++) {
 
-                Object.defineProperty(this, i, {
+		Object.defineProperty(this, i, {
                         get: (function(i) { return function() { return this.getValue(i); }})(i),
                         set: (function(i) { return function(v) { return this.setValue(i, v); }})(i),
                 });
 
-        }
+	}
 
 }
 
@@ -39,23 +39,23 @@ THREE.VectorArrayProxy.prototype.getValue = function(i) {
 
         // Allocates a new THREE.Vector2Proxy or THREE.Vector3Proxy depending on the itemSize of our attribute
 
-        var subarray = this.attribute.array.subarray(i * this.attribute.itemSize, (i + 1) * this.attribute.itemSize);
+	var subarray = this.attribute.array.subarray(i * this.attribute.itemSize, (i + 1) * this.attribute.itemSize);
 
-        switch (this.attribute.itemSize) {
+	switch (this.attribute.itemSize) {
 
-                case 2:
-                        return new THREE.Vector2Proxy(subarray);
+		case 2:
+			return new THREE.Vector2Proxy(subarray);
 
-                case 3:
-                        return new THREE.Vector3Proxy(subarray);
+		case 3:
+			return new THREE.Vector3Proxy(subarray);
 
-        }
+	}
 
 }
 THREE.VectorArrayProxy.prototype.setValue = function(i, v) {
 
-        var vec = this[i];
-        vec.copy(v);
+	var vec = this[i];
+	vec.copy(v);
 
 }
 
@@ -63,7 +63,7 @@ THREE.VectorArrayProxy.prototype.setValue = function(i, v) {
 
 THREE.Vector2Proxy = function(subarray) {
 
-        this.subarray = subarray;
+	this.subarray = subarray;
 
 }
 THREE.Vector2Proxy.prototype = Object.create( THREE.Vector2.prototype );
@@ -74,7 +74,7 @@ Object.defineProperty(THREE.Vector2Proxy.prototype, 'y', { get: function() { ret
 
 THREE.Vector3Proxy = function(subarray) {
 
-        this.subarray = subarray;
+	this.subarray = subarray;
 
 }
 THREE.Vector3Proxy.prototype = Object.create( THREE.Vector3.prototype );

+ 3 - 3
src/extras/FontUtils.js

@@ -182,11 +182,11 @@ THREE.FontUtils = {
 							var t = i2 / divisions;
 							var tx = THREE.Shape.Utils.b2( t, cpx0, cpx1, cpx );
 							var ty = THREE.Shape.Utils.b2( t, cpy0, cpy1, cpy );
-					  }
+						}
 
-				  }
+					}
 
-				  break;
+					break;
 
 				case 'b':
 

+ 4 - 4
src/extras/core/Curve.js

@@ -212,17 +212,17 @@ THREE.Curve.prototype.getUtoTmapping = function ( u, distance ) {
 	// we could get finer grain at lengths, or use simple interpolatation between two points
 
 	var lengthBefore = arcLengths[ i ];
-    var lengthAfter = arcLengths[ i + 1 ];
+	var lengthAfter = arcLengths[ i + 1 ];
 
-    var segmentLength = lengthAfter - lengthBefore;
+	var segmentLength = lengthAfter - lengthBefore;
 
     // determine where we are between the 'before' and 'after' points
 
-    var segmentFraction = ( targetArcLength - lengthBefore ) / segmentLength;
+	var segmentFraction = ( targetArcLength - lengthBefore ) / segmentLength;
 
     // add that fractional amount to t
 
-    var t = ( i + segmentFraction ) / ( il - 1 );
+	var t = ( i + segmentFraction ) / ( il - 1 );
 
 	return t;
 

+ 2 - 2
src/extras/core/Path.js

@@ -375,7 +375,7 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
 
 			//console.log(points);
 
-		  break;
+			break;
 		  
 		case THREE.PathActions.ELLIPSE:
 
@@ -413,7 +413,7 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
 
 			//console.log(points);
 
-		  break;
+			break;
 
 		} // end switch
 

+ 6 - 6
src/extras/geometries/ExtrudeGeometry.js

@@ -605,7 +605,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 
 		var uvs = uvgen.generateTopUV( scope, a, b, c );
 
- 		scope.faceVertexUvs[ 0 ].push( uvs );
+		scope.faceVertexUvs[ 0 ].push( uvs );
 
 	}
 
@@ -616,13 +616,13 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 		c += shapesOffset;
 		d += shapesOffset;
 
- 		scope.faces.push( new THREE.Face3( a, b, d, null, null, extrudeMaterial ) );
- 		scope.faces.push( new THREE.Face3( b, c, d, null, null, extrudeMaterial ) );
+		scope.faces.push( new THREE.Face3( a, b, d, null, null, extrudeMaterial ) );
+		scope.faces.push( new THREE.Face3( b, c, d, null, null, extrudeMaterial ) );
 
- 		var uvs = uvgen.generateSideWallUV( scope, a, b, c, d );
+		var uvs = uvgen.generateSideWallUV( scope, a, b, c, d );
 
- 		scope.faceVertexUvs[ 0 ].push( [ uvs[ 0 ], uvs[ 1 ], uvs[ 3 ] ] );
- 		scope.faceVertexUvs[ 0 ].push( [ uvs[ 1 ], uvs[ 2 ], uvs[ 3 ] ] );
+		scope.faceVertexUvs[ 0 ].push( [ uvs[ 0 ], uvs[ 1 ], uvs[ 3 ] ] );
+		scope.faceVertexUvs[ 0 ].push( [ uvs[ 1 ], uvs[ 2 ], uvs[ 3 ] ] );
 
 	}
 

+ 1 - 1
src/loaders/CompressedTextureLoader.js

@@ -49,7 +49,7 @@ THREE.CompressedTextureLoader.prototype = {
 
 					if ( loaded === 6 ) {
 
- 						if (texDatas.mipmapCount == 1)
+						if (texDatas.mipmapCount == 1)
  							texture.minFilter = THREE.LinearFilter;
 
 						texture.format = texDatas.format;

+ 1 - 1
src/loaders/JSONLoader.js

@@ -461,7 +461,7 @@ THREE.JSONLoader.prototype.parse = function ( json, texturePath ) {
 
 		if ( geometry.bones && geometry.bones.length > 0 && ( geometry.skinWeights.length !== geometry.skinIndices.length || geometry.skinIndices.length !== geometry.vertices.length ) ) {
 
-				THREE.warn( 'THREE.JSONLoader: When skinning, number of vertices (' + geometry.vertices.length + '), skinIndices (' +
+			THREE.warn( 'THREE.JSONLoader: When skinning, number of vertices (' + geometry.vertices.length + '), skinIndices (' +
 					geometry.skinIndices.length + '), and skinWeights (' + geometry.skinWeights.length + ') should match.' );
 
 		}

+ 4 - 4
src/math/Matrix4.js

@@ -92,15 +92,15 @@ THREE.Matrix4.prototype = {
 
 	extractBasis: function ( xAxis, yAxis, zAxis ) {
  
- 		var te = this.elements;
+		var te = this.elements;
  
 		xAxis.set( te[ 0 ], te[ 1 ], te[ 2 ] );
 		yAxis.set( te[ 4 ], te[ 5 ], te[ 6 ] );
 		zAxis.set( te[ 8 ], te[ 9 ], te[ 10 ] );
  
- 		return this;
+		return this;
  		
- 	},
+	},
  
 	makeBasis: function ( xAxis, yAxis, zAxis ) {
 
@@ -111,7 +111,7 @@ THREE.Matrix4.prototype = {
 			0,       0,       0,       1
 		);
 
-	    return this;
+		return this;
 
 	},
 

+ 1 - 1
src/math/Sphere.js

@@ -52,7 +52,7 @@ THREE.Sphere.prototype = {
 
 			return this;
 
- 		};
+		};
 
 	}(),
 

+ 7 - 7
src/math/Vector2.js

@@ -371,9 +371,9 @@ THREE.Vector2.prototype = {
 
 	lerpVectors: function ( v1, v2, alpha ) {
 
-	    this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
+		this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
 
-	    return this;
+		return this;
 
 	},
 
@@ -408,14 +408,14 @@ THREE.Vector2.prototype = {
 
 	fromAttribute: function ( attribute, index, offset ) {
 
-	    if ( offset === undefined ) offset = 0;
+		if ( offset === undefined ) offset = 0;
 
-	    index = index * attribute.itemSize + offset;
+		index = index * attribute.itemSize + offset;
 
-	    this.x = attribute.array[ index ];
-	    this.y = attribute.array[ index + 1 ];
+		this.x = attribute.array[ index ];
+		this.y = attribute.array[ index + 1 ];
 
-	    return this;
+		return this;
 
 	},
 

+ 8 - 8
src/math/Vector3.js

@@ -599,9 +599,9 @@ THREE.Vector3.prototype = {
 
 	lerpVectors: function ( v1, v2, alpha ) {
 
-	    this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
+		this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
 
-	    return this;
+		return this;
 
 	},
 
@@ -819,15 +819,15 @@ THREE.Vector3.prototype = {
 
 	fromAttribute: function ( attribute, index, offset ) {
 
-	    if ( offset === undefined ) offset = 0;
+		if ( offset === undefined ) offset = 0;
 
-	    index = index * attribute.itemSize + offset;
+		index = index * attribute.itemSize + offset;
 
-	    this.x = attribute.array[ index ];
-	    this.y = attribute.array[ index + 1 ];
-	    this.z = attribute.array[ index + 2 ];
+		this.x = attribute.array[ index ];
+		this.y = attribute.array[ index + 1 ];
+		this.z = attribute.array[ index + 2 ];
 
-	    return this;
+		return this;
 
 	},
 

+ 29 - 29
src/math/Vector4.js

@@ -507,45 +507,45 @@ THREE.Vector4.prototype = {
 
     floor: function () {
 
-        this.x = Math.floor( this.x );
-        this.y = Math.floor( this.y );
-        this.z = Math.floor( this.z );
-        this.w = Math.floor( this.w );
+	this.x = Math.floor( this.x );
+	this.y = Math.floor( this.y );
+	this.z = Math.floor( this.z );
+	this.w = Math.floor( this.w );
 
-        return this;
+	return this;
 
     },
 
     ceil: function () {
 
-        this.x = Math.ceil( this.x );
-        this.y = Math.ceil( this.y );
-        this.z = Math.ceil( this.z );
-        this.w = Math.ceil( this.w );
+	this.x = Math.ceil( this.x );
+	this.y = Math.ceil( this.y );
+	this.z = Math.ceil( this.z );
+	this.w = Math.ceil( this.w );
 
-        return this;
+	return this;
 
     },
 
     round: function () {
 
-        this.x = Math.round( this.x );
-        this.y = Math.round( this.y );
-        this.z = Math.round( this.z );
-        this.w = Math.round( this.w );
+	this.x = Math.round( this.x );
+	this.y = Math.round( this.y );
+	this.z = Math.round( this.z );
+	this.w = Math.round( this.w );
 
-        return this;
+	return this;
 
     },
 
     roundToZero: function () {
 
-        this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
-        this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
-        this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
-        this.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w );
+	this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
+	this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
+	this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
+	this.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w );
 
-        return this;
+	return this;
 
     },
 
@@ -617,9 +617,9 @@ THREE.Vector4.prototype = {
 
 	lerpVectors: function ( v1, v2, alpha ) {
 
-	    this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
+		this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
 
-	    return this;
+		return this;
 
 	},
 
@@ -658,16 +658,16 @@ THREE.Vector4.prototype = {
 
 	fromAttribute: function ( attribute, index, offset ) {
 
-	    if ( offset === undefined ) offset = 0;
+		if ( offset === undefined ) offset = 0;
 
-	    index = index * attribute.itemSize + offset;
+		index = index * attribute.itemSize + offset;
 
-	    this.x = attribute.array[ index ];
-	    this.y = attribute.array[ index + 1 ];
-	    this.z = attribute.array[ index + 2 ];
-	    this.w = attribute.array[ index + 3 ];
+		this.x = attribute.array[ index ];
+		this.y = attribute.array[ index + 1 ];
+		this.z = attribute.array[ index + 2 ];
+		this.w = attribute.array[ index + 3 ];
 
-	    return this;
+		return this;
 
 	},
 

+ 23 - 23
src/renderers/WebGLRenderer.js

@@ -6155,49 +6155,49 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	this.readRenderTargetPixels = function( renderTarget, x, y, width, height, buffer ) {
 
-	    if ( ! ( renderTarget instanceof THREE.WebGLRenderTarget ) ) {
+		if ( ! ( renderTarget instanceof THREE.WebGLRenderTarget ) ) {
 
-	        console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );
-	        return;
+			console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );
+			return;
 
-	    }
+		}
 
-	    if ( renderTarget.__webglFramebuffer ) {
+		if ( renderTarget.__webglFramebuffer ) {
 
-	        if ( renderTarget.format !== THREE.RGBAFormat ) {
+			if ( renderTarget.format !== THREE.RGBAFormat ) {
 
-	            console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA format. readPixels can read only RGBA format.' );
-	            return;
+				console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA format. readPixels can read only RGBA format.' );
+				return;
 
-	        }
+			}
 
-	        var restore = false;
+			var restore = false;
 
-	        if ( renderTarget.__webglFramebuffer !== _currentFramebuffer ) {
+			if ( renderTarget.__webglFramebuffer !== _currentFramebuffer ) {
 
-	            _gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTarget.__webglFramebuffer );
+				_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTarget.__webglFramebuffer );
 
-	            restore = true;
+				restore = true;
 
-	        }
+			}
 
-	        if ( _gl.checkFramebufferStatus( _gl.FRAMEBUFFER ) === _gl.FRAMEBUFFER_COMPLETE ) {
+			if ( _gl.checkFramebufferStatus( _gl.FRAMEBUFFER ) === _gl.FRAMEBUFFER_COMPLETE ) {
 
-	            _gl.readPixels( x, y, width, height, _gl.RGBA, _gl.UNSIGNED_BYTE, buffer );
+				_gl.readPixels( x, y, width, height, _gl.RGBA, _gl.UNSIGNED_BYTE, buffer );
 
-	        } else {
+			} else {
 
-	            console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.' );
+				console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.' );
 
-	        }
+			}
 
-	        if ( restore ) {
+			if ( restore ) {
 
-	            _gl.bindFramebuffer( _gl.FRAMEBUFFER, _currentFramebuffer );
+				_gl.bindFramebuffer( _gl.FRAMEBUFFER, _currentFramebuffer );
 
-	        }
+			}
 
-	    }
+		}
 
 	};
 

Некоторые файлы не были показаны из-за большого количества измененных файлов