Browse Source

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

Conflicts:
	examples/js/loaders/ColladaLoader.js
Mr.doob 10 năm trước cách đây
mục cha
commit
e57b5d1ef3
100 tập tin đã thay đổi với 3645 bổ sung3634 xóa
  1. 5 5
      editor/js/Sidebar.Material.js
  2. 1 1
      editor/js/Sidebar.Object3D.js
  3. 1 1
      editor/js/Storage.js
  4. 1 1
      examples/js/AudioObject.js
  5. 9 9
      examples/js/BlendCharacter.js
  6. 3 3
      examples/js/Car.js
  7. 26 26
      examples/js/Cloth.js
  8. 9 9
      examples/js/CurveExtras.js
  9. 1 1
      examples/js/Detector.js
  10. 10 10
      examples/js/ImprovedNoise.js
  11. 1 1
      examples/js/MD2Character.js
  12. 3 3
      examples/js/MD2CharacterComplex.js
  13. 23 23
      examples/js/MarchingCubes.js
  14. 6 6
      examples/js/Ocean.js
  15. 43 43
      examples/js/Octree.js
  16. 6 6
      examples/js/ParametricGeometries.js
  17. 1 1
      examples/js/ShaderTerrain.js
  18. 233 233
      examples/js/SimplexNoise.js
  19. 2 2
      examples/js/SimulationRenderer.js
  20. 154 154
      examples/js/Sparks.js
  21. 5 5
      examples/js/TypedArrayUtils.js
  22. 1 1
      examples/js/cameras/CombinedCamera.js
  23. 3 3
      examples/js/controls/EditorControls.js
  24. 2 2
      examples/js/controls/FirstPersonControls.js
  25. 1 1
      examples/js/controls/FlyControls.js
  26. 25 25
      examples/js/controls/MouseControls.js
  27. 2 2
      examples/js/controls/OrbitControls.js
  28. 5 5
      examples/js/controls/OrthographicTrackballControls.js
  29. 7 7
      examples/js/controls/TrackballControls.js
  30. 38 38
      examples/js/controls/TransformControls.js
  31. 6 6
      examples/js/crossfade/scenes.js
  32. 12 12
      examples/js/crossfade/transition.js
  33. 1 1
      examples/js/curves/NURBSCurve.js
  34. 2 2
      examples/js/curves/NURBSSurface.js
  35. 29 29
      examples/js/curves/NURBSUtils.js
  36. 13 13
      examples/js/effects/AsciiEffect.js
  37. 20 20
      examples/js/effects/VREffect.js
  38. 1 1
      examples/js/exporters/SceneExporter.js
  39. 14 14
      examples/js/geometries/ConvexGeometry.js
  40. 23 23
      examples/js/geometries/DecalGeometry.js
  41. 1 1
      examples/js/geometries/hilbert2D.js
  42. 1 1
      examples/js/geometries/hilbert3D.js
  43. 348 348
      examples/js/loaders/AWDLoader.js
  44. 27 27
      examples/js/loaders/AssimpJSONLoader.js
  45. 56 56
      examples/js/loaders/BinaryLoader.js
  46. 111 98
      examples/js/loaders/ColladaLoader.js
  47. 13 13
      examples/js/loaders/DDSLoader.js
  48. 3 3
      examples/js/loaders/MTLLoader.js
  49. 1 3
      examples/js/loaders/PDBLoader.js
  50. 10 10
      examples/js/loaders/PLYLoader.js
  51. 24 24
      examples/js/loaders/PVRLoader.js
  52. 33 33
      examples/js/loaders/RGBELoader.js
  53. 17 17
      examples/js/loaders/STLLoader.js
  54. 18 18
      examples/js/loaders/TGALoader.js
  55. 302 302
      examples/js/loaders/UTF8Loader.js
  56. 19 19
      examples/js/loaders/VRMLLoader.js
  57. 1 1
      examples/js/loaders/ctm/CTMLoader.js
  58. 412 412
      examples/js/loaders/ctm/ctm.js
  59. 399 399
      examples/js/loaders/ctm/lzma.js
  60. 2 2
      examples/js/loaders/deprecated/SceneLoader.js
  61. 168 168
      examples/js/loaders/gltf/glTF-parser.js
  62. 5 5
      examples/js/loaders/gltf/glTFAnimation.js
  63. 522 522
      examples/js/loaders/gltf/glTFLoader.js
  64. 103 103
      examples/js/loaders/gltf/glTFLoaderUtils.js
  65. 10 10
      examples/js/math/Lut.js
  66. 8 8
      examples/js/modifiers/SubdivisionModifier.js
  67. 2 2
      examples/js/postprocessing/AdaptiveToneMappingPass.js
  68. 32 32
      examples/js/postprocessing/GlitchPass.js
  69. 3 3
      examples/js/renderers/SVGRenderer.js
  70. 63 63
      examples/js/renderers/SoftwareRenderer.js
  71. 4 4
      examples/js/renderers/plugins/DepthPassPlugin.js
  72. 1 1
      examples/js/shaders/BokehShader2.js
  73. 2 2
      examples/js/shaders/ConvolutionShader.js
  74. 1 1
      examples/js/shaders/FXAAShader.js
  75. 1 1
      examples/js/shaders/NormalDisplacementShader.js
  76. 1 1
      examples/js/shaders/TriangleBlurShader.js
  77. 55 55
      examples/js/utils/UVsDebug.js
  78. 22 22
      examples/js/wip/ProxyGeometry.js
  79. 2 2
      examples/js/wip/benchmark/BoxGeometry2.js
  80. 25 25
      examples/js/wip/benchmark/Geometry4.js
  81. 1 1
      examples/js/wip/proxies/MultiColor.js
  82. 1 1
      examples/js/wip/proxies/MultiVector3.js
  83. 2 2
      src/core/Object3D.js
  84. 5 5
      src/extras/FontUtils.js
  85. 1 1
      src/extras/ImageUtils.js
  86. 2 2
      src/extras/animation/Animation.js
  87. 7 7
      src/extras/core/Curve.js
  88. 1 1
      src/extras/core/CurvePath.js
  89. 4 4
      src/extras/core/Path.js
  90. 12 12
      src/extras/core/Shape.js
  91. 2 2
      src/extras/curves/SplineCurve.js
  92. 14 14
      src/extras/geometries/ExtrudeGeometry.js
  93. 6 6
      src/extras/geometries/TubeGeometry.js
  94. 1 1
      src/lights/DirectionalLight.js
  95. 1 1
      src/loaders/BinaryTextureLoader.js
  96. 1 1
      src/loaders/CompressedTextureLoader.js
  97. 1 1
      src/loaders/JSONLoader.js
  98. 4 4
      src/math/Matrix4.js
  99. 1 1
      src/math/Ray.js
  100. 2 2
      src/math/Sphere.js

+ 5 - 5
editor/js/Sidebar.Material.js

@@ -463,7 +463,7 @@ Sidebar.Material = function ( editor ) {
 
 				var mapEnabled = materialMapEnabled.getValue() === true;
 
-				if ( objectHasUvs )  {
+				if ( objectHasUvs ) {
 
 					material.map = mapEnabled ? materialMap.getValue() : null;
 					material.needsUpdate = true;
@@ -480,7 +480,7 @@ Sidebar.Material = function ( editor ) {
 
 				var mapEnabled = materialAlphaMapEnabled.getValue() === true;
 
-				if ( objectHasUvs )  {
+				if ( objectHasUvs ) {
 
 					material.alphaMap = mapEnabled ? materialAlphaMap.getValue() : null;
 					material.needsUpdate = true;
@@ -516,7 +516,7 @@ Sidebar.Material = function ( editor ) {
 
 				var bumpMapEnabled = materialBumpMapEnabled.getValue() === true;
 
-				if ( objectHasUvs )  {
+				if ( objectHasUvs ) {
 
 					material.bumpMap = bumpMapEnabled ? materialBumpMap.getValue() : null;
 					material.bumpScale = materialBumpScale.getValue();
@@ -534,7 +534,7 @@ Sidebar.Material = function ( editor ) {
 
 				var normalMapEnabled = materialNormalMapEnabled.getValue() === true;
 
-				if ( objectHasUvs )  {
+				if ( objectHasUvs ) {
 
 					material.normalMap = normalMapEnabled ? materialNormalMap.getValue() : null;
 					material.needsUpdate = true;
@@ -551,7 +551,7 @@ Sidebar.Material = function ( editor ) {
 
 				var specularMapEnabled = materialSpecularMapEnabled.getValue() === true;
 
-				if ( objectHasUvs )  {
+				if ( objectHasUvs ) {
 
 					material.specularMap = specularMapEnabled ? materialSpecularMap.getValue() : null;
 					material.needsUpdate = true;

+ 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() );
 
 	} );
 

+ 1 - 1
editor/js/Storage.js

@@ -8,7 +8,7 @@ var Storage = function () {
 
 	if ( indexedDB === undefined  ) {
 		console.warn( 'Storage: IndexedDB not available.' );
-		return { init: function (){}, get: function (){}, set: function (){}, clear: function (){} };
+		return { init: function () {}, get: function () {}, set: function () {}, clear: function () {} };
 	}
 
 	var name = 'threejs-editor';

+ 1 - 1
examples/js/AudioObject.js

@@ -40,7 +40,7 @@ THREE.AudioObject = function ( url, volume, playbackRate, loop ) {
 
 			THREE.AudioObject.prototype.context = new webkitAudioContext();
 
-		} catch( error ) {
+		} catch ( error ) {
 
 			console.warn( "THREE.AudioObject: webkitAudioContext not found" );
 			return this;

+ 9 - 9
examples/js/BlendCharacter.js

@@ -22,7 +22,7 @@ THREE.BlendCharacter = function () {
 
 			// Create the animations
 
-			for ( var i = 0; i < geometry.animations.length; ++i ) {
+			for ( var i = 0; i < geometry.animations.length; ++ i ) {
 
 				var animName = geometry.animations[ i ].name;
 				scope.animations[ animName ] = new THREE.Animation( scope, geometry.animations[ i ] );
@@ -46,7 +46,7 @@ THREE.BlendCharacter = function () {
 
 	this.update = function( dt ) {
 
-		for ( var i = this.weightSchedule.length - 1; i >= 0; --i ) {
+		for ( var i = this.weightSchedule.length - 1; i >= 0; -- i ) {
 
 			var data = this.weightSchedule[ i ];
 			data.timeElapsed += dt;
@@ -87,7 +87,7 @@ THREE.BlendCharacter = function () {
 		// lengths match. This is useful for smoothing out transitions that get out of
 		// phase such as between a walk and run cycle
 
-		for ( var i = this.warpSchedule.length - 1; i >= 0; --i ) {
+		for ( var i = this.warpSchedule.length - 1; i >= 0; -- i ) {
 
 			var data = this.warpSchedule[ i ];
 			data.timeElapsed += dt;
@@ -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() {

+ 3 - 3
examples/js/Car.js

@@ -195,7 +195,7 @@ THREE.Car = function () {
 
 		var forwardDelta = this.speed * delta;
 
-		this.carOrientation += ( forwardDelta * this.STEERING_RADIUS_RATIO )* this.wheelOrientation;
+		this.carOrientation += ( forwardDelta * this.STEERING_RADIUS_RATIO ) * this.wheelOrientation;
 
 		// displacement
 
@@ -363,8 +363,8 @@ THREE.Car = function () {
 	};
 
 	function quadraticEaseOut( k ) { return - k * ( k - 2 ); }
-	function cubicEaseOut( k ) { return --k * k * k + 1; }
-	function circularEaseOut( k ) { return Math.sqrt( 1 - --k * k ); }
+	function cubicEaseOut( k ) { return -- k * k * k + 1; }
+	function circularEaseOut( k ) { return Math.sqrt( 1 - -- k * k ); }
 	function sinusoidalEaseOut( k ) { return Math.sin( k * Math.PI / 2 ); }
 	function exponentialEaseOut( k ) { return k === 1 ? 1 : - Math.pow( 2, - 10 * k ) + 1; }
 

+ 26 - 26
examples/js/Cloth.js

@@ -48,8 +48,8 @@ var lastTime;
 function plane(width, height) {
 
 	return function(u, v) {
-		var x = (u-0.5) * width;
-		var y = (v+0.5) * height;
+		var x = (u - 0.5) * width;
+		var y = (v + 0.5) * height;
 		var z = 0;
 
 		return new THREE.Vector3(x, y, z);
@@ -94,8 +94,8 @@ var diff = new THREE.Vector3();
 function satisifyConstrains(p1, p2, distance) {
 	diff.subVectors(p2.position, p1.position);
 	var currentDist = diff.length();
-	if (currentDist==0) return; // prevents division by 0
-	var correction = diff.multiplyScalar(1 - distance/currentDist);
+	if (currentDist == 0) return; // prevents division by 0
+	var correction = diff.multiplyScalar(1 - distance / currentDist);
 	var correctionHalf = correction.multiplyScalar(0.5);
 	p1.position.add(correctionHalf);
 	p2.position.sub(correctionHalf);
@@ -114,47 +114,47 @@ function Cloth(w, h) {
 	var u, v;
 
 	// Create particles
-	for (v=0;v<=h;v++) {
-		for (u=0;u<=w;u++) {
+	for (v = 0; v <= h; v ++) {
+		for (u = 0; u <= w; u ++) {
 			particles.push(
-				new Particle(u/w, v/h, 0, MASS)
+				new Particle(u / w, v / h, 0, MASS)
 			);
 		}
 	}
 
 	// Structural
 
-	for (v=0;v<h;v++) {
-		for (u=0;u<w;u++) {
+	for (v = 0; v < h; v ++) {
+		for (u = 0; u < w; u ++) {
 
 			constrains.push([
 				particles[index(u, v)],
-				particles[index(u, v+1)],
+				particles[index(u, v + 1)],
 				restDistance
 			]);
 
 			constrains.push([
 				particles[index(u, v)],
-				particles[index(u+1, v)],
+				particles[index(u + 1, v)],
 				restDistance
 			]);
 
 		}
 	}
 
-	for (u=w, v=0;v<h;v++) {
+	for (u = w, v = 0; v < h; v ++) {
 		constrains.push([
 			particles[index(u, v)],
-			particles[index(u, v+1)],
+			particles[index(u, v + 1)],
 			restDistance
 
 		]);
 	}
 
-	for (v=h, u=0;u<w;u++) {
+	for (v = h, u = 0; u < w; u ++) {
 		constrains.push([
 			particles[index(u, v)],
-			particles[index(u+1, v)],
+			particles[index(u + 1, v)],
 			restDistance
 		]);
 	}
@@ -211,7 +211,7 @@ function simulate(time) {
 
 		particles = cloth.particles;
 
-		for (i=0,il=faces.length;i<il;i++) {
+		for (i = 0,il = faces.length; i < il; i ++) {
 			face = faces[i];
 			normal = face.normal;
 
@@ -222,8 +222,8 @@ function simulate(time) {
 		}
 	}
 	
-	for (particles = cloth.particles, i=0, il = particles.length
-			;i<il;i++) {
+	for (particles = cloth.particles, i = 0, il = particles.length
+			; i < il; i ++) {
 		particle = particles[i];
 		particle.addForce(gravity);
 
@@ -234,7 +234,7 @@ function simulate(time) {
 
 	constrains = cloth.constrains,
 	il = constrains.length;
-	for (i=0;i<il;i++) {
+	for (i = 0; i < il; i ++) {
 		constrain = constrains[i];
 		satisifyConstrains(constrain[0], constrain[1], constrain[2]);
 	}
@@ -242,12 +242,12 @@ function simulate(time) {
 	// Ball Constrains
 
 
-	ballPosition.z = -Math.sin(Date.now()/600) * 90 ; //+ 40;
-	ballPosition.x = Math.cos(Date.now()/400) * 70
+	ballPosition.z = -Math.sin(Date.now() / 600) * 90 ; //+ 40;
+	ballPosition.x = Math.cos(Date.now() / 400) * 70
 
 	if (sphere.visible)
-	for (particles = cloth.particles, i=0, il = particles.length
-			;i<il;i++) {
+	for (particles = cloth.particles, i = 0, il = particles.length
+			; i < il; i ++) {
 		particle = particles[i];
 		pos = particle.position;
 		diff.subVectors(pos, ballPosition);
@@ -259,8 +259,8 @@ function simulate(time) {
 	}
 
 	// Floor Constains
-	for (particles = cloth.particles, i=0, il = particles.length
-			;i<il;i++) {
+	for (particles = cloth.particles, i = 0, il = particles.length
+			; i < il; i ++) {
 		particle = particles[i];
 		pos = particle.position;
 		if (pos.y < -250) {
@@ -269,7 +269,7 @@ function simulate(time) {
 	}
 
 	// Pin Constrains
-	for (i=0, il=pins.length;i<il;i++) {
+	for (i = 0, il = pins.length; i < il; i ++) {
 		var xy = pins[i];
 		var p = particles[xy];
 		p.position.copy(p.original);

+ 9 - 9
examples/js/CurveExtras.js

@@ -15,15 +15,15 @@
 THREE.Curves = {};
 
 
- THREE.Curves.GrannyKnot = THREE.Curve.create( function(){},
+ 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(
 

+ 1 - 1
examples/js/Detector.js

@@ -6,7 +6,7 @@
 var Detector = {
 
 	canvas: !! window.CanvasRenderingContext2D,
-	webgl: ( function () { try { var canvas = document.createElement( 'canvas' ); return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) ); } catch( e ) { return false; } } )(),
+	webgl: ( function () { try { var canvas = document.createElement( 'canvas' ); return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) ); } catch ( e ) { return false; } } )(),
 	workers: !! window.Worker,
 	fileapi: window.File && window.FileReader && window.FileList && window.Blob,
 

+ 10 - 10
examples/js/ImprovedNoise.js

@@ -2,7 +2,7 @@
 
 var ImprovedNoise = function () {
 
-	var p = [151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,
+	var p = [ 151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,
 		 23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,
 		 174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,
 		 133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,
@@ -11,11 +11,11 @@ var ImprovedNoise = function () {
 		 248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,
 		 178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,
 		 14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,
-		 93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180];
+		 93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180 ];
 
-	for (var i=0; i < 256 ; i++) {
+	for (var i = 0; i < 256 ; i ++) {
 
-		p[256+i] = p[i];
+		p[256 + i] = p[i];
 
 	}
 
@@ -51,20 +51,20 @@ var ImprovedNoise = function () {
 			y -= floorY;
 			z -= floorZ;
 
-			var xMinus1 = x -1, yMinus1 = y - 1, zMinus1 = z - 1;
+			var xMinus1 = x - 1, yMinus1 = y - 1, zMinus1 = z - 1;
 
 			var u = fade(x), v = fade(y), w = fade(z);
 
-			var A = p[X]+Y, AA = p[A]+Z, AB = p[A+1]+Z, B = p[X+1]+Y, BA = p[B]+Z, BB = p[B+1]+Z;
+			var A = p[X] + Y, AA = p[A] + Z, AB = p[A + 1] + Z, B = p[X + 1] + Y, BA = p[B] + Z, BB = p[B + 1] + Z;
 
 			return lerp(w, lerp(v, lerp(u, grad(p[AA], x, y, z), 
 							grad(p[BA], xMinus1, y, z)),
 						lerp(u, grad(p[AB], x, yMinus1, z),
 							grad(p[BB], xMinus1, yMinus1, z))),
-					lerp(v, lerp(u, grad(p[AA+1], x, y, zMinus1),
-							grad(p[BA+1], xMinus1, y, z-1)),
-						lerp(u, grad(p[AB+1], x, yMinus1, zMinus1),
-							grad(p[BB+1], xMinus1, yMinus1, zMinus1))));
+					lerp(v, lerp(u, grad(p[AA + 1], x, y, zMinus1),
+							grad(p[BA + 1], xMinus1, y, z - 1)),
+						lerp(u, grad(p[AB + 1], x, yMinus1, zMinus1),
+							grad(p[BB + 1], xMinus1, yMinus1, zMinus1))));
 
 		}
 	}

+ 1 - 1
examples/js/MD2Character.js

@@ -210,7 +210,7 @@ THREE.MD2Character = function () {
 		//
 
 		var mesh = new THREE.MorphAnimMesh( geometry, materialTexture );
-		mesh.rotation.y = -Math.PI/2;
+		mesh.rotation.y = -Math.PI / 2;
 
 		mesh.castShadow = true;
 		mesh.receiveShadow = true;

+ 3 - 3
examples/js/MD2CharacterComplex.js

@@ -402,7 +402,7 @@ THREE.MD2CharacterComplex = function () {
 
 		if ( controls.moveForward ) {
 
-			if ( this.meshBody )   {
+			if ( this.meshBody ) {
 
 				this.meshBody.setAnimationDirectionForward( this.activeAnimation );
 				this.meshBody.setAnimationDirectionForward( this.oldAnimation );
@@ -445,7 +445,7 @@ THREE.MD2CharacterComplex = function () {
 		// speed based on controls
 
 		if ( controls.crouch ) 	this.maxSpeed = this.crouchSpeed;
-		else  					this.maxSpeed = this.walkSpeed;
+		else this.maxSpeed = this.walkSpeed;
 
 		this.maxReverseSpeed = -this.maxSpeed;
 
@@ -533,7 +533,7 @@ THREE.MD2CharacterComplex = function () {
 		//
 
 		var mesh = new THREE.MorphBlendMesh( geometry, materialTexture );
-		mesh.rotation.y = -Math.PI/2;
+		mesh.rotation.y = -Math.PI / 2;
 
 		//
 

+ 23 - 23
examples/js/MarchingCubes.js

@@ -224,7 +224,7 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs, enableColors )
 
 		// bottom of the cube
 
-		if ( bits & 16 )  {
+		if ( bits & 16 ) {
 
 			this.compNorm( qz );
 			this.compNorm( q1z );
@@ -232,7 +232,7 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs, enableColors )
 
 		};
 
-		if ( bits & 32 )  {
+		if ( bits & 32 ) {
 
 			this.compNorm( q1z );
 			this.compNorm( q1yz );
@@ -485,22 +485,22 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs, enableColors )
 
 		var x, y, z, y_offset, z_offset, fx, fy, fz, fz2, fy2, val;
 
-		for ( z = min_z; z < max_z; z++ ) {
+		for ( z = min_z; z < max_z; z ++ ) {
 
 			z_offset = this.size2 * z,
 			fz = z / this.size - ballz,
 			fz2 = fz * fz;
 
-			for ( y = min_y; y < max_y; y++ ) {
+			for ( y = min_y; y < max_y; y ++ ) {
 
 				y_offset = z_offset + this.size * y;
 				fy = y / this.size - bally;
 				fy2 = fy * fy;
 
-				for ( x = min_x; x < max_x; x++ ) {
+				for ( x = min_x; x < max_x; x ++ ) {
 
 					fx = x / this.size - ballx;
-					val = strength / ( 0.000001 + fx*fx + fy2 + fz2 ) - subtract;
+					val = strength / ( 0.000001 + fx * fx + fy2 + fz2 ) - subtract;
 					if ( val > 0.0 ) this.field[ y_offset + x ] += val;
 
 				}
@@ -763,38 +763,38 @@ THREE.MarchingCubes.prototype.constructor = THREE.MarchingCubes;
 // who in turn got them from Cory Gene Bloyd.
 
 THREE.edgeTable = new Int32Array([
-0x0  , 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
+0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
-0x190, 0x99 , 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,
+0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,
 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,
-0x230, 0x339, 0x33 , 0x13a, 0x636, 0x73f, 0x435, 0x53c,
+0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c,
 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,
-0x3a0, 0x2a9, 0x1a3, 0xaa , 0x7a6, 0x6af, 0x5a5, 0x4ac,
+0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac,
 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,
-0x460, 0x569, 0x663, 0x76a, 0x66 , 0x16f, 0x265, 0x36c,
+0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c,
 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,
-0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff , 0x3f5, 0x2fc,
+0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc,
 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,
-0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55 , 0x15c,
+0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c,
 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,
-0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc ,
+0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc,
 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,
 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,
-0xcc , 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
+0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,
-0x15c, 0x55 , 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
+0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,
-0x2fc, 0x3f5, 0xff , 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
+0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,
-0x36c, 0x265, 0x16f, 0x66 , 0x76a, 0x663, 0x569, 0x460,
+0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460,
 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,
-0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa , 0x1a3, 0x2a9, 0x3a0,
+0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0,
 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,
-0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33 , 0x339, 0x230,
+0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230,
 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,
-0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99 , 0x190,
+0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190,
 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,
-0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0])
+0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0 ])
 
 THREE.triTable = new Int32Array([
 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
@@ -1052,4 +1052,4 @@ THREE.triTable = new Int32Array([
 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
--1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]);
+-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ]);

+ 6 - 6
examples/js/Ocean.js

@@ -20,8 +20,8 @@
 		return value !== undefined ? value : defaultValue;
 	};
 	options = options || {};
-	this.clearColor = optionalParameter(options.CLEAR_COLOR, [1.0, 1.0, 1.0, 0.0]);
-	this.geometryOrigin = optionalParameter(options.GEOMETRY_ORIGIN, [-1000.0, -1000.0]);
+	this.clearColor = optionalParameter(options.CLEAR_COLOR, [ 1.0, 1.0, 1.0, 0.0 ]);
+	this.geometryOrigin = optionalParameter(options.GEOMETRY_ORIGIN, [ -1000.0, -1000.0 ]);
 	this.sunDirectionX = optionalParameter(options.SUN_DIRECTION[0], -1.0);
 	this.sunDirectionY = optionalParameter(options.SUN_DIRECTION[1], 1.0);
 	this.sunDirectionZ = optionalParameter(options.SUN_DIRECTION[2], 1.0);
@@ -228,8 +228,8 @@ THREE.Ocean.prototype.generateSeedPhaseTexture = function() {
 	// Setup the seed texture
 	this.pingPhase = true;
 	var phaseArray = new window.Float32Array(this.resolution * this.resolution * 4);
-	for (var i = 0; i < this.resolution; i++) {
-		for (var j = 0; j < this.resolution; j++) {
+	for (var i = 0; i < this.resolution; i ++) {
+		for (var j = 0; j < this.resolution; j ++) {
 			phaseArray[i * this.resolution * 4 + j * 4] =  Math.random() * 2.0 * Math.PI;
 			phaseArray[i * this.resolution * 4 + j * 4 + 1] = 0.0;
 			phaseArray[i * this.resolution * 4 + j * 4 + 2] = 0.0;
@@ -283,7 +283,7 @@ THREE.Ocean.prototype.renderSpectrumFFT = function() {
 	
 	this.scene.overrideMaterial = this.materialOceanHorizontal;
 
-	for (var i = 0; i < iterations; i++) {
+	for (var i = 0; i < iterations; i ++) {
 		if (i === 0) {
 			this.materialOceanHorizontal.uniforms.u_input.value = this.spectrumFramebuffer;
 			this.materialOceanHorizontal.uniforms.u_subtransformSize.value = Math.pow(2, (i % (iterations)) + 1);
@@ -301,7 +301,7 @@ THREE.Ocean.prototype.renderSpectrumFFT = function() {
 		}
 	}
 	this.scene.overrideMaterial = this.materialOceanVertical;
-	for (var i = iterations; i < iterations*2; i++) {
+	for (var i = iterations; i < iterations * 2; i ++) {
 		if (i === iterations * 2 - 1) {
 			this.materialOceanVertical.uniforms.u_input.value = (iterations % 2 === 0) ? this.pingTransformFramebuffer : this.pongTransformFramebuffer;
 			this.materialOceanVertical.uniforms.u_subtransformSize.value = Math.pow(2, (i % (iterations)) + 1);

+ 43 - 43
examples/js/Octree.js

@@ -29,7 +29,7 @@
 	
 	function indexOfValue( array, value ) {
 		
-		for ( var i = 0, il = array.length; i < il; i++ ) {
+		for ( var i = 0, il = array.length; i < il; i ++ ) {
 			
 			if ( array[ i ] === value ) {
 				
@@ -45,7 +45,7 @@
 	
 	function indexOfPropertyWithValue( array, property, value ) {
 		
-		for ( var i = 0, il = array.length; i < il; i++ ) {
+		for ( var i = 0, il = array.length; i < il; i ++ ) {
 			
 			if ( array[ i ][ property ] === value ) {
 				
@@ -140,7 +140,7 @@
 			
 			if ( this.objectsDeferred.length > 0 ) {
 				
-				for ( var i = 0, il = this.objectsDeferred.length; i < il; i++ ) {
+				for ( var i = 0, il = this.objectsDeferred.length; i < il; i ++ ) {
 					
 					var deferred = this.objectsDeferred[ i ];
 					
@@ -221,7 +221,7 @@
 					geometry = object.geometry;
 					vertices = geometry.vertices;
 					
-					for ( i = 0, l = vertices.length; i < l; i++ ) {
+					for ( i = 0, l = vertices.length; i < l; i ++ ) {
 						
 						this.addObjectData( object, vertices[ i ] );
 						
@@ -232,7 +232,7 @@
 					geometry = object.geometry;
 					faces = geometry.faces;
 					
-					for ( i = 0, l = faces.length; i < l; i++ ) {
+					for ( i = 0, l = faces.length; i < l; i ++ ) {
 						
 						this.addObjectData( object, faces[ i ] );
 						
@@ -297,7 +297,7 @@
 					
 					// remove from objects data list
 					
-					for ( i = 0, l = objectsDataRemoved.length; i < l; i++ ) {
+					for ( i = 0, l = objectsDataRemoved.length; i < l; i ++ ) {
 						
 						objectData = objectsDataRemoved[ i ];
 						
@@ -341,7 +341,7 @@
 				
 				objectsData = octree.objectsData;
 				
-				for ( i = 0, l = objectsData.length; i < l; i++ ) {
+				for ( i = 0, l = objectsData.length; i < l; i ++ ) {
 					
 					objectData = objectsData[ i ];
 					
@@ -366,7 +366,7 @@
 			// check all object data for changes in position
 			// assumes all object matrices are up to date
 			
-			for ( i = 0, l = this.objectsData.length; i < l; i++ ) {
+			for ( i = 0, l = this.objectsData.length; i < l; i ++ ) {
 				
 				objectData = this.objectsData[ i ];
 				
@@ -402,7 +402,7 @@
 			
 			// update changed objects
 			
-			for ( i = 0, l = objectsUpdate.length; i < l; i++ ) {
+			for ( i = 0, l = objectsUpdate.length; i < l; i ++ ) {
 				
 				objectData = objectsUpdate[ i ];
 				
@@ -429,14 +429,14 @@
 			
 			parent = object.parent;
 			
-			while( parent ) {
+			while ( parent ) {
 				
 				parentCascade.push( parent );
 				parent = parent.parent;
 				
 			}
 			
-			for ( i = 0, l = parentCascade.length; i < l; i++ ) {
+			for ( i = 0, l = parentCascade.length; i < l; i ++ ) {
 				
 				parent = parentCascade[ i ];
 				
@@ -494,7 +494,7 @@
 			
 			// search each node of root
 			
-			for ( i = 0, l = this.root.nodesIndices.length; i < l; i++ ) {
+			for ( i = 0, l = this.root.nodesIndices.length; i < l; i ++ ) {
 				
 				node = this.root.nodesByIndex[ this.root.nodesIndices[ i ] ];
 				
@@ -511,7 +511,7 @@
 				
 				// for each object data found
 				
-				for ( i = 0, l = objects.length; i < l; i++ ) {
+				for ( i = 0, l = objects.length; i < l; i ++ ) {
 					
 					objectData = objects[ i ];
 					object = objectData.object;
@@ -739,7 +739,7 @@
 		
 		// basic properties
 		
-		this.id = this.tree.nodeCount++;
+		this.id = this.tree.nodeCount ++;
 		this.position = parameters.position instanceof THREE.Vector3 ? parameters.position : new THREE.Vector3();
 		this.radius = parameters.radius > 0 ? parameters.radius : 1;
 		this.indexOctant = parameters.indexOctant;
@@ -811,7 +811,7 @@
 			
 			// cascade
 			
-			for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
+			for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
 				
 				this.nodesByIndex[ this.nodesIndices[ i ] ].updateProperties();
 				
@@ -832,7 +832,7 @@
 			
 			// unset parent in nodes
 			
-			for ( i = 0, l = nodesIndices.length; i < l; i++ ) {
+			for ( i = 0, l = nodesIndices.length; i < l; i ++ ) {
 				
 				node = nodesByIndex[ nodesIndices[ i ] ];
 				
@@ -949,7 +949,7 @@
 			var i, l,
 				object;
 
-			for ( i = 0, l = objects.length; i < l; i++ ) {
+			for ( i = 0, l = objects.length; i < l; i ++ ) {
 				
 				object = objects[ i ];
 				
@@ -977,7 +977,7 @@
 			
 			if ( nodesRemovedFrom.length > 0 ) {
 				
-				for ( i = 0, l = nodesRemovedFrom.length; i < l; i++ ) {
+				for ( i = 0, l = nodesRemovedFrom.length; i < l; i ++ ) {
 					
 					nodesRemovedFrom[ i ].shrink();
 					
@@ -1021,7 +1021,7 @@
 			
 				// search each object data for object and remove (slow)
 				
-				for ( i = this.objects.length - 1; i >= 0; i-- ) {
+				for ( i = this.objects.length - 1; i >= 0; i -- ) {
 					
 					objectData = this.objects[ i ];
 					
@@ -1059,7 +1059,7 @@
 			
 			if ( removeData.searchComplete !== true ) {
 				
-				for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
+				for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
 					
 					node = this.nodesByIndex[ this.nodesIndices[ i ] ];
 					
@@ -1106,7 +1106,7 @@
 			
 			// for each object
 			
-			for ( i = 0, l = this.objects.length; i < l; i++ ) {
+			for ( i = 0, l = this.objects.length; i < l; i ++ ) {
 				
 				object = this.objects[ i ];
 				
@@ -1183,7 +1183,7 @@
 				
 				// for each object
 				
-				for ( i = 0, l = objects.length; i < l; i++ ) {
+				for ( i = 0, l = objects.length; i < l; i ++ ) {
 					
 					object = objects[ i ];
 					
@@ -1314,7 +1314,7 @@
 				
 				// reset counts
 				
-				for ( i = 0, l = iom.length; i < l; i++ ) {
+				for ( i = 0, l = iom.length; i < l; i ++ ) {
 					
 					iom[ i ].count = 0;
 					
@@ -1322,7 +1322,7 @@
 				
 				// for all outside objects, find outside octants containing most objects
 				
-				for ( i = 0, l = objects.length; i < l; i++ ) {
+				for ( i = 0, l = objects.length; i < l; i ++ ) {
 					
 					object = objects[ i ];
 					
@@ -1344,11 +1344,11 @@
 						
 						if ( flagsOutside & this.tree.FLAG_POS_X ) {
 							
-							iom[ this.tree.INDEX_OUTSIDE_POS_X ].count++;
+							iom[ this.tree.INDEX_OUTSIDE_POS_X ].count ++;
 							
 						} else if ( flagsOutside & this.tree.FLAG_NEG_X ) {
 							
-							iom[ this.tree.INDEX_OUTSIDE_NEG_X ].count++;
+							iom[ this.tree.INDEX_OUTSIDE_NEG_X ].count ++;
 							
 						}
 						
@@ -1356,11 +1356,11 @@
 						
 						if ( flagsOutside & this.tree.FLAG_POS_Y ) {
 							
-							iom[ this.tree.INDEX_OUTSIDE_POS_Y ].count++;
+							iom[ this.tree.INDEX_OUTSIDE_POS_Y ].count ++;
 							
 						} else if ( flagsOutside & this.tree.FLAG_NEG_Y ) {
 							
-							iom[ this.tree.INDEX_OUTSIDE_NEG_Y ].count++;
+							iom[ this.tree.INDEX_OUTSIDE_NEG_Y ].count ++;
 							
 						}
 						
@@ -1368,11 +1368,11 @@
 						
 						if ( flagsOutside & this.tree.FLAG_POS_Z ) {
 							
-							iom[ this.tree.INDEX_OUTSIDE_POS_Z ].count++;
+							iom[ this.tree.INDEX_OUTSIDE_POS_Z ].count ++;
 							
 						} else if ( flagsOutside & this.tree.FLAG_NEG_Z ) {
 							
-							iom[ this.tree.INDEX_OUTSIDE_NEG_Z ].count++;
+							iom[ this.tree.INDEX_OUTSIDE_NEG_Z ].count ++;
 							
 						}
 						
@@ -1474,7 +1474,7 @@
 					
 					// add all expand objects to parent
 					
-					for ( i = 0, l = objectsExpand.length; i < l; i++ ) {
+					for ( i = 0, l = objectsExpand.length; i < l; i ++ ) {
 						
 						this.tree.root.addObject( objectsExpand[ i ] );
 						
@@ -1546,7 +1546,7 @@
 			
 			nodes = toArray( nodes );
 			
-			for ( i = 0, l = nodes.length; i < l; i++ ) {
+			for ( i = 0, l = nodes.length; i < l; i ++ ) {
 				
 				node = nodes[ i ];
 				
@@ -1586,7 +1586,7 @@
 				nodeHeaviestObjectsCount = 0;
 				outsideHeaviestObjectsCount = this.objects.length;
 				
-				for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
+				for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
 					
 					node = this.nodesByIndex[ this.nodesIndices[ i ] ];
 					
@@ -1625,7 +1625,7 @@
 			
 			// handle all nodes
 			
-			for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
+			for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
 				
 				node = this.nodesByIndex[ this.nodesIndices[ i ] ];
 				
@@ -1848,7 +1848,7 @@
 				
 				// search subtree
 				
-				for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
+				for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
 					
 					node = this.nodesByIndex[ this.nodesIndices[ i ] ];
 					
@@ -1917,7 +1917,7 @@
 			tmin = Math.max( Math.max( Math.min( t1, t2), Math.min( t3, t4)), Math.min( t5, t6));
 			
 			// if tmin > tmax or tmin > ray distance, ray doesn't intersect AABB
-			if( tmin > tmax || tmin > distance ) {
+			if ( tmin > tmax || tmin > distance ) {
 				return false;
 			}
 			
@@ -1932,7 +1932,7 @@
 
 			if ( this.nodesIndices.length > 0 ) {
 				
-				for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
+				for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
 
 					node = this.nodesByIndex[ this.nodesIndices[ i ] ];
 
@@ -1961,7 +1961,7 @@
 			var i, l,
 				count = this.nodesIndices.length;
 			
-			for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
+			for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
 				
 				count += this.nodesByIndex[ this.nodesIndices[ i ] ].getNodeCountRecursive();
 				
@@ -1978,7 +1978,7 @@
 			
 			objects = ( objects || [] ).concat( this.objects );
 			
-			for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
+			for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
 				
 				node = this.nodesByIndex[ this.nodesIndices[ i ] ];
 				
@@ -1995,7 +1995,7 @@
 			var i, l,
 				count = this.objects.length;
 			
-			for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
+			for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
 				
 				count += this.nodesByIndex[ this.nodesIndices[ i ] ].getObjectCountEnd();
 				
@@ -2010,7 +2010,7 @@
 			var count = this.objects.length,
 				parent = this.parent;
 			
-			while( parent instanceof THREE.OctreeNode ) {
+			while ( parent instanceof THREE.OctreeNode ) {
 				
 				count += parent.objects.length;
 				parent = parent.parent;
@@ -2033,7 +2033,7 @@
 			console.log( ( this.parent ? space + ' ' : ' ' ), '+ objects ( ', this.objects.length, ' ) ', this.objects );
 			console.log( ( this.parent ? space + ' ' : ' ' ), '+ children ( ', this.nodesIndices.length, ' )', this.nodesIndices, this.nodesByIndex );
 			
-			for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
+			for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
 				
 				node = this.nodesByIndex[ this.nodesIndices[ i ] ];
 				
@@ -2101,7 +2101,7 @@
 		var i, il,
 			intersects = [];
 		
-		for ( i = 0, il = objects.length; i < il; i++ ) {
+		for ( i = 0, il = objects.length; i < il; i ++ ) {
 			
 			intersects = intersects.concat( this.intersectOctreeObject( objects[ i ], recursive ) );
 		

+ 6 - 6
examples/js/ParametricGeometries.js

@@ -48,9 +48,9 @@ THREE.ParametricGeometries = {
 		var x, y, z;
 
 		var a = 2;
-		x = Math.cos(v) * (a + u * Math.cos(v/2));
-		y = Math.sin(v) * (a + u * Math.cos(v/2));
-		z = u * Math.sin(v/2);
+		x = Math.cos(v) * (a + u * Math.cos(v / 2));
+		y = Math.sin(v) * (a + u * Math.cos(v / 2));
+		z = u * Math.sin(v / 2);
 		return new THREE.Vector3(x, y, z);
 
 	},
@@ -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;
 
 
 

+ 1 - 1
examples/js/ShaderTerrain.js

@@ -217,7 +217,7 @@ THREE.ShaderTerrain = {
 				"#if MAX_HEMI_LIGHTS > 0",
 
 					"vec3 hemiDiffuse  = vec3( 0.0 );",
-					"vec3 hemiSpecular = vec3( 0.0 );" ,
+					"vec3 hemiSpecular = vec3( 0.0 );",
 
 					"for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {",
 

+ 233 - 233
examples/js/SimplexNoise.js

@@ -13,190 +13,190 @@
  */
 var SimplexNoise = function(r) {
 	if (r == undefined) r = Math;
-  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.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],
-	     [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],
-	     [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,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.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 ],
+	     [ 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,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[i]=this.p[i & 255];
+	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 = [ 
-    [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], 
-    [1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0], 
-    [1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,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], 
-    [2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0], 
-    [2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]; 
+	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 ], 
+    [ 1,2,0,3 ],[ 0,0,0,0 ],[ 1,3,0,2 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 2,3,0,1 ],[ 2,3,1,0 ], 
+    [ 1,0,2,3 ],[ 1,0,3,2 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 2,0,3,1 ],[ 0,0,0,0 ],[ 2,1,3,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 ], 
+    [ 2,0,1,3 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 3,0,1,2 ],[ 3,0,2,1 ],[ 0,0,0,0 ],[ 3,1,2,0 ], 
+    [ 2,1,0,3 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 0,0,0,0 ],[ 3,1,0,2 ],[ 0,0,0,0 ],[ 3,2,0,1 ],[ 3,2,1,0 ]]; 
 };
 
 SimplexNoise.prototype.dot = function(g, x, y) { 
-	return g[0]*x + g[1]*y;
+	return g[0] * x + g[1] * 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) 
-      { 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 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 
-  } 
+	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 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 
+	} 
   // 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);
 };

+ 2 - 2
examples/js/SimulationRenderer.js

@@ -19,12 +19,12 @@ function SimulationRenderer(WIDTH, renderer) {
 	// Init RTT stuff
 	gl = renderer.getContext();
 
-	if( !gl.getExtension( "OES_texture_float" )) {
+	if ( !gl.getExtension( "OES_texture_float" )) {
 		alert( "No OES_texture_float support for float textures!" );
 		return;
 	}
 
-	if( gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS) == 0) {
+	if ( gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS) == 0) {
 		alert( "No support for vertex shader textures!" );
 		return;
 	}

+ 154 - 154
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 = {};
 };
 
 
@@ -77,14 +77,14 @@ SPARKS.Emitter.prototype = {
 				elapsed = maxBlock;
 			}
 
-			while(elapsed >= emitter._TIMESTEP) {
+			while (elapsed >= emitter._TIMESTEP) {
 				emitter.update(emitter._TIMESTEP / 1000);
 				elapsed -= emitter._TIMESTEP;
 			}
 			emitter._lastTime = time - elapsed;
 
 		} else {
-			emitter.update(elapsed/1000);
+			emitter.update(elapsed / 1000);
 			emitter._lastTime = time;
 		}
 
@@ -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,32 +277,32 @@ 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._oldvelocity = SPARKS.VectorPool.get().set(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
      // faceAxis 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;
@@ -595,17 +595,17 @@ SPARKS.CubeZone.prototype.contains = function(position) {
 	var y = this.y; // depth
 	var z = this.z; // height
 
-	if (x<0) {
+	if (x < 0) {
 		startX += x;
 		x = Math.abs(x);
 	}
 
-	if (y<0) {
+	if (y < 0) {
 		startY += y;
 		y = Math.abs(y);
 	}
 
-	if (z<0) {
+	if (z < 0) {
 		startZ += z;
 		z = Math.abs(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;
+	}
 
 };
 
@@ -769,7 +769,7 @@ SPARKS.VectorPool = {
 
 	// Get a new Vector
 	get: function() {
-		if (this.__pools.length>0) {
+		if (this.__pools.length > 0) {
 			return this.__pools.pop();
 		}
 
@@ -786,7 +786,7 @@ SPARKS.VectorPool = {
 	_addToPool: function() {
 		//console.log("creating some pools");
 
-		for (var i=0, size = 100; i < size; i++) {
+		for (var i = 0, size = 100; i < size; i ++) {
 			this.__pools.push(new THREE.Vector3());
 		}
 
@@ -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,
@@ -821,7 +821,7 @@ SPARKS.Utils = {
 
 	getPerpendicular: function( v )
 	{
-		if( v.x == 0 )
+		if ( v.x == 0 )
 		{
 			return new THREE.Vector3D( 1, 0, 0 );
 		}

+ 5 - 5
examples/js/TypedArrayUtils.js

@@ -33,8 +33,8 @@ THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
 		for ( y = 0; y < eleSize; y ++ ) {
 
 			tmp = arr[ a + y ];
-			arr[ a + y ]=arr[ b + y ];
-			arr[ b + y ]=tmp;
+			arr[ a + y ] = arr[ b + y ];
+			arr[ b + y ] = tmp;
 
 		}
 
@@ -46,7 +46,7 @@ THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
 
 		if ( right - left <= 25 ) {
 
-			for ( j= left + 1; j <= right; j ++ ) {
+			for ( j = left + 1; j <= right; j ++ ) {
 
 				for ( x = 0; x < eleSize; x ++ ) {
 			
@@ -214,7 +214,7 @@ THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
 		
 		median = Math.floor( plength / 2 );
 		
-		node = new self.Node( getPointSet( points, median ) , depth, parent, median + pos );
+		node = new self.Node( getPointSet( points, median ), depth, parent, median + pos );
 		node.left = buildTree( points.subarray( 0, median * eleSize), depth + 1, node, pos );
 		node.right = buildTree( points.subarray( ( median + 1 ) * eleSize, points.length ), depth + 1, node, pos + median + 1 );
 
@@ -226,7 +226,7 @@ THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
 		
 	this.getMaxDepth = function () { return maxDepth; };
 	
-	this.nearest = function ( point, maxNodes , maxDistance ) {
+	this.nearest = function ( point, maxNodes, maxDistance ) {
 	
 		 /* point: array of size eleSize 
 			maxNodes: max amount of nodes to return 

+ 1 - 1
examples/js/cameras/CombinedCamera.js

@@ -29,7 +29,7 @@ THREE.CombinedCamera = function ( width, height, fov, near, far, orthoNear, orth
 
 	this.toPerspective();
 
-	var aspect = width/height;
+	var aspect = width / height;
 
 };
 

+ 3 - 3
examples/js/controls/EditorControls.js

@@ -262,7 +262,7 @@ THREE.EditorControls = function ( object, domElement ) {
 			case 1:
 				touches[ 0 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
 				touches[ 1 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
-				scope.rotate( touches[ 0 ].sub( getClosest( touches[ 0 ] ,prevTouches ) ).multiplyScalar( - 0.005 ) );
+				scope.rotate( touches[ 0 ].sub( getClosest( touches[ 0 ], prevTouches ) ).multiplyScalar( - 0.005 ) );
 				break;
 
 			case 2:
@@ -273,8 +273,8 @@ THREE.EditorControls = function ( object, domElement ) {
 				prevDistance = distance;
 
 
-				var offset0 = touches[ 0 ].clone().sub( getClosest( touches[ 0 ] ,prevTouches ) );
-				var offset1 = touches[ 1 ].clone().sub( getClosest( touches[ 1 ] ,prevTouches ) );
+				var offset0 = touches[ 0 ].clone().sub( getClosest( touches[ 0 ], prevTouches ) );
+				var offset1 = touches[ 1 ].clone().sub( getClosest( touches[ 1 ], prevTouches ) );
 				offset0.x = -offset0.x;
 				offset1.x = -offset1.x;
 

+ 2 - 2
examples/js/controls/FirstPersonControls.js

@@ -163,7 +163,7 @@ THREE.FirstPersonControls = function ( object, domElement ) {
 
 	this.onKeyUp = function ( event ) {
 
-		switch( event.keyCode ) {
+		switch ( event.keyCode ) {
 
 			case 38: /*up*/
 			case 87: /*W*/ this.moveForward = false; break;
@@ -229,7 +229,7 @@ THREE.FirstPersonControls = function ( object, domElement ) {
 		}
 
 		this.lon += this.mouseX * actualLookSpeed;
-		if( this.lookVertical ) this.lat -= this.mouseY * actualLookSpeed * verticalLookRatio;
+		if ( this.lookVertical ) this.lat -= this.mouseY * actualLookSpeed * verticalLookRatio;
 
 		this.lat = Math.max( - 85, Math.min( 85, this.lat ) );
 		this.phi = THREE.Math.degToRad( 90 - this.lat );

+ 1 - 1
examples/js/controls/FlyControls.js

@@ -80,7 +80,7 @@ THREE.FlyControls = function ( object, domElement ) {
 
 	this.keyup = function( event ) {
 
-		switch( event.keyCode ) {
+		switch ( event.keyCode ) {
 
 			case 16: /* shift */ this.movementSpeedMultiplier = 1; break;
 

+ 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 );
 
 };

+ 2 - 2
examples/js/controls/OrbitControls.js

@@ -121,8 +121,8 @@ THREE.OrbitControls = function ( object, domElement ) {
 	// events
 
 	var changeEvent = { type: 'change' };
-	var startEvent = { type: 'start'};
-	var endEvent = { type: 'end'};
+	var startEvent = { type: 'start' };
+	var endEvent = { type: 'end' };
 
 	this.rotateLeft = function ( angle ) {
 

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

@@ -73,8 +73,8 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
 	// events
 
 	var changeEvent = { type: 'change' };
-	var startEvent = { type: 'start'};
-	var endEvent = { type: 'end'};
+	var startEvent = { type: 'start' };
+	var endEvent = { type: 'end' };
 
 
 	// methods
@@ -156,7 +156,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
 
 				if ( length < Math.SQRT1_2 ) {
 
-					mouseOnBall.z = Math.sqrt( 1.0 - length*length );
+					mouseOnBall.z = Math.sqrt( 1.0 - length * length );
 
 				} else {
 
@@ -186,7 +186,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
 
 	}() );
 
-	this.rotateCamera = (function(){
+	this.rotateCamera = (function() {
 
 		var axis = new THREE.Vector3(),
 			quaternion = new THREE.Quaternion();
@@ -264,7 +264,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
 
 	};
 
-	this.panCamera = (function(){
+	this.panCamera = (function() {
 
 		var mouseChange = new THREE.Vector2(),
 			objectUp = new THREE.Vector3(),

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

@@ -68,8 +68,8 @@ THREE.TrackballControls = function ( object, domElement ) {
 	// events
 
 	var changeEvent = { type: 'change' };
-	var startEvent = { type: 'start'};
-	var endEvent = { type: 'end'};
+	var startEvent = { type: 'start' };
+	var endEvent = { type: 'end' };
 
 
 	// methods
@@ -133,8 +133,8 @@ THREE.TrackballControls = function ( object, domElement ) {
 		return function ( pageX, pageY ) {
 
 			mouseOnBall.set(
-				( pageX - _this.screen.width * 0.5 - _this.screen.left ) / (_this.screen.width*.5),
-				( _this.screen.height * 0.5 + _this.screen.top - pageY ) / (_this.screen.height*.5),
+				( pageX - _this.screen.width * 0.5 - _this.screen.left ) / (_this.screen.width * .5),
+				( _this.screen.height * 0.5 + _this.screen.top - pageY ) / (_this.screen.height * .5),
 				0.0
 			);
 
@@ -144,7 +144,7 @@ THREE.TrackballControls = function ( object, domElement ) {
 
 				if ( length < Math.SQRT1_2 ) {
 
-					mouseOnBall.z = Math.sqrt( 1.0 - length*length );
+					mouseOnBall.z = Math.sqrt( 1.0 - length * length );
 
 				} else {
 
@@ -174,7 +174,7 @@ THREE.TrackballControls = function ( object, domElement ) {
 
 	}() );
 
-	this.rotateCamera = (function(){
+	this.rotateCamera = (function() {
 
 		var axis = new THREE.Vector3(),
 			quaternion = new THREE.Quaternion();
@@ -245,7 +245,7 @@ THREE.TrackballControls = function ( object, domElement ) {
 
 	};
 
-	this.panCamera = (function(){
+	this.panCamera = (function() {
 
 		var mouseChange = new THREE.Vector2(),
 			objectUp = new THREE.Vector3(),

+ 38 - 38
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;
 
 			}
 
@@ -110,8 +110,8 @@
 
 			this.activePlane = planes["XYZE"];
 
-			planes["YZ"].rotation.set( 0, Math.PI/2, 0 );
-			planes["XZ"].rotation.set( -Math.PI/2, 0, 0 );
+			planes["YZ"].rotation.set( 0, Math.PI / 2, 0 );
+			planes["XZ"].rotation.set( -Math.PI / 2, 0, 0 );
 
 			for (var i in planes) {
 				planes[i].name = i;
@@ -126,7 +126,7 @@
 
 				for ( var name in gizmoMap ) {
 
-					for ( i = gizmoMap[name].length; i--;) {
+					for ( i = gizmoMap[name].length; i --;) {
 
 						var object = gizmoMap[name][i][0];
 						var position = gizmoMap[name][i][1];
@@ -183,7 +183,7 @@
 
 		this.highlight = function ( axis ) {
 			this.traverse(function( child ) {
-				if ( child.material && child.material.highlight ){
+				if ( child.material && child.material.highlight ) {
 					if ( child.name == axis ) {
 						child.material.highlight( true );
 					} else {
@@ -236,7 +236,7 @@
 
 		this.handleGizmos = {
 			X: [
-				[ new THREE.Mesh( arrowGeometry, new GizmoMaterial( { color: 0xff0000 } ) ), [ 0.5, 0, 0 ], [ 0, 0, -Math.PI/2 ] ],
+				[ new THREE.Mesh( arrowGeometry, new GizmoMaterial( { color: 0xff0000 } ) ), [ 0.5, 0, 0 ], [ 0, 0, -Math.PI / 2 ] ],
 				[ new THREE.Line( lineXGeometry, new GizmoLineMaterial( { color: 0xff0000 } ) ) ]
 			],
 			Y: [
@@ -244,7 +244,7 @@
 				[	new THREE.Line( lineYGeometry, new GizmoLineMaterial( { color: 0x00ff00 } ) ) ]
 			],
 			Z: [
-				[ new THREE.Mesh( arrowGeometry, new GizmoMaterial( { color: 0x0000ff } ) ), [ 0, 0, 0.5 ], [ Math.PI/2, 0, 0 ] ],
+				[ new THREE.Mesh( arrowGeometry, new GizmoMaterial( { color: 0x0000ff } ) ), [ 0, 0, 0.5 ], [ Math.PI / 2, 0, 0 ] ],
 				[ new THREE.Line( lineZGeometry, new GizmoLineMaterial( { color: 0x0000ff } ) ) ]
 			],
 			XYZ: [
@@ -254,22 +254,22 @@
 				[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.29, 0.29 ), new GizmoMaterial( { color: 0xffff00, opacity: 0.25 } ) ), [ 0.15, 0.15, 0 ] ]
 			],
 			YZ: [
-				[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.29, 0.29 ), new GizmoMaterial( { color: 0x00ffff, opacity: 0.25 } ) ), [ 0, 0.15, 0.15 ], [ 0, Math.PI/2, 0 ] ]
+				[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.29, 0.29 ), new GizmoMaterial( { color: 0x00ffff, opacity: 0.25 } ) ), [ 0, 0.15, 0.15 ], [ 0, Math.PI / 2, 0 ] ]
 			],
 			XZ: [
-				[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.29, 0.29 ), new GizmoMaterial( { color: 0xff00ff, opacity: 0.25 } ) ), [ 0.15, 0, 0.15 ], [ -Math.PI/2, 0, 0 ] ]
+				[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.29, 0.29 ), new GizmoMaterial( { color: 0xff00ff, opacity: 0.25 } ) ), [ 0.15, 0, 0.15 ], [ -Math.PI / 2, 0, 0 ] ]
 			]
 		};
 
 		this.pickerGizmos = {
 			X: [
-				[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0xff0000, opacity: 0.25 } ) ), [ 0.6, 0, 0 ], [ 0, 0, -Math.PI/2 ] ]
+				[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0xff0000, opacity: 0.25 } ) ), [ 0.6, 0, 0 ], [ 0, 0, -Math.PI / 2 ] ]
 			],
 			Y: [
 				[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0x00ff00, opacity: 0.25 } ) ), [ 0, 0.6, 0 ] ]
 			],
 			Z: [
-				[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0x0000ff, opacity: 0.25 } ) ), [ 0, 0, 0.6 ], [ Math.PI/2, 0, 0 ] ]
+				[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0x0000ff, opacity: 0.25 } ) ), [ 0, 0, 0.6 ], [ Math.PI / 2, 0, 0 ] ]
 			],
 			XYZ: [
 				[ new THREE.Mesh( new THREE.OctahedronGeometry( 0.2, 0 ), new GizmoMaterial( { color: 0xffffff, opacity: 0.25 } ) ) ]
@@ -278,10 +278,10 @@
 				[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.4, 0.4 ), new GizmoMaterial( { color: 0xffff00, opacity: 0.25 } ) ), [ 0.2, 0.2, 0 ] ]
 			],
 			YZ: [
-				[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.4, 0.4 ), new GizmoMaterial( { color: 0x00ffff, opacity: 0.25 } ) ), [ 0, 0.2, 0.2 ], [ 0, Math.PI/2, 0 ] ]
+				[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.4, 0.4 ), new GizmoMaterial( { color: 0x00ffff, opacity: 0.25 } ) ), [ 0, 0.2, 0.2 ], [ 0, Math.PI / 2, 0 ] ]
 			],
 			XZ: [
-				[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.4, 0.4 ), new GizmoMaterial( { color: 0xff00ff, opacity: 0.25 } ) ), [ 0.2, 0, 0.2 ], [ -Math.PI/2, 0, 0 ] ]
+				[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.4, 0.4 ), new GizmoMaterial( { color: 0xff00ff, opacity: 0.25 } ) ), [ 0.2, 0, 0.2 ], [ -Math.PI / 2, 0, 0 ] ]
 			]
 		};
 
@@ -295,12 +295,12 @@
 				if ( Math.abs(eye.y) > Math.abs(eye.z) ) this.activePlane = this.planes[ "XZ" ];
 			}
 
-			if ( axis == "Y" ){
+			if ( axis == "Y" ) {
 				this.activePlane = this.planes[ "XY" ];
 				if ( Math.abs(eye.x) > Math.abs(eye.z) ) this.activePlane = this.planes[ "YZ" ];
 			}
 
-			if ( axis == "Z" ){
+			if ( axis == "Z" ) {
 				this.activePlane = this.planes[ "XZ" ];
 				if ( Math.abs(eye.x) > Math.abs(eye.y) ) this.activePlane = this.planes[ "YZ" ];
 			}
@@ -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 = {
@@ -362,13 +362,13 @@
 
 		this.pickerGizmos = {
 			X: [
-				[ new THREE.Mesh( new THREE.TorusGeometry( 1, 0.12, 4, 12, Math.PI ), new GizmoMaterial( { color: 0xff0000, opacity: 0.25 } ) ), [ 0, 0, 0 ], [ 0, -Math.PI/2, -Math.PI/2 ] ]
+				[ new THREE.Mesh( new THREE.TorusGeometry( 1, 0.12, 4, 12, Math.PI ), new GizmoMaterial( { color: 0xff0000, opacity: 0.25 } ) ), [ 0, 0, 0 ], [ 0, -Math.PI / 2, -Math.PI / 2 ] ]
 			],
 			Y: [
-				[ new THREE.Mesh( new THREE.TorusGeometry( 1, 0.12, 4, 12, Math.PI ), new GizmoMaterial( { color: 0x00ff00, opacity: 0.25 } ) ), [ 0, 0, 0 ], [ Math.PI/2, 0, 0 ] ]
+				[ new THREE.Mesh( new THREE.TorusGeometry( 1, 0.12, 4, 12, Math.PI ), new GizmoMaterial( { color: 0x00ff00, opacity: 0.25 } ) ), [ 0, 0, 0 ], [ Math.PI / 2, 0, 0 ] ]
 			],
 			Z: [
-				[ new THREE.Mesh( new THREE.TorusGeometry( 1, 0.12, 4, 12, Math.PI ), new GizmoMaterial( { color: 0x0000ff, opacity: 0.25 } ) ), [ 0, 0, 0 ], [ 0, 0, -Math.PI/2 ] ]
+				[ new THREE.Mesh( new THREE.TorusGeometry( 1, 0.12, 4, 12, Math.PI ), new GizmoMaterial( { color: 0x0000ff, opacity: 0.25 } ) ), [ 0, 0, 0 ], [ 0, 0, -Math.PI / 2 ] ]
 			],
 			E: [
 				[ new THREE.Mesh( new THREE.TorusGeometry( 1.25, 0.12, 2, 24 ), new GizmoMaterial( { color: 0xffff00, opacity: 0.25 } ) ) ]
@@ -474,7 +474,7 @@
 
 		this.handleGizmos = {
 			X: [
-				[ new THREE.Mesh( arrowGeometry, new GizmoMaterial( { color: 0xff0000 } ) ), [ 0.5, 0, 0 ], [ 0, 0, -Math.PI/2 ] ],
+				[ new THREE.Mesh( arrowGeometry, new GizmoMaterial( { color: 0xff0000 } ) ), [ 0.5, 0, 0 ], [ 0, 0, -Math.PI / 2 ] ],
 				[ new THREE.Line( lineXGeometry, new GizmoLineMaterial( { color: 0xff0000 } ) ) ]
 			],
 			Y: [
@@ -482,7 +482,7 @@
 				[ new THREE.Line( lineYGeometry, new GizmoLineMaterial( { color: 0x00ff00 } ) ) ]
 			],
 			Z: [
-				[ new THREE.Mesh( arrowGeometry, new GizmoMaterial( { color: 0x0000ff } ) ), [ 0, 0, 0.5 ], [ Math.PI/2, 0, 0 ] ],
+				[ new THREE.Mesh( arrowGeometry, new GizmoMaterial( { color: 0x0000ff } ) ), [ 0, 0, 0.5 ], [ Math.PI / 2, 0, 0 ] ],
 				[ new THREE.Line( lineZGeometry, new GizmoLineMaterial( { color: 0x0000ff } ) ) ]
 			],
 			XYZ: [
@@ -492,13 +492,13 @@
 
 		this.pickerGizmos = {
 			X: [
-				[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0xff0000, opacity: 0.25 } ) ), [ 0.6, 0, 0 ], [ 0, 0, -Math.PI/2 ] ]
+				[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0xff0000, opacity: 0.25 } ) ), [ 0.6, 0, 0 ], [ 0, 0, -Math.PI / 2 ] ]
 			],
 			Y: [
 				[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0x00ff00, opacity: 0.25 } ) ), [ 0, 0.6, 0 ] ]
 			],
 			Z: [
-				[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0x0000ff, opacity: 0.25 } ) ), [ 0, 0, 0.6 ], [ Math.PI/2, 0, 0 ] ]
+				[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0x0000ff, opacity: 0.25 } ) ), [ 0, 0, 0.6 ], [ Math.PI / 2, 0, 0 ] ]
 			],
 			XYZ: [
 				[ new THREE.Mesh( new THREE.BoxGeometry( 0.4, 0.4, 0.4 ), new GizmoMaterial( { color: 0xffffff, opacity: 0.25 } ) ) ]
@@ -515,12 +515,12 @@
 				if ( Math.abs(eye.y) > Math.abs(eye.z) ) this.activePlane = this.planes[ "XZ" ];
 			}
 
-			if ( axis == "Y" ){
+			if ( axis == "Y" ) {
 				this.activePlane = this.planes[ "XY" ];
 				if ( Math.abs(eye.x) > Math.abs(eye.z) ) this.activePlane = this.planes[ "YZ" ];
 			}
 
-			if ( axis == "Z" ){
+			if ( axis == "Z" ) {
 				this.activePlane = this.planes[ "XZ" ];
 				if ( Math.abs(eye.x) > Math.abs(eye.y) ) this.activePlane = this.planes[ "YZ" ];
 			}
@@ -775,7 +775,7 @@
 
 					scope.gizmo[_mode].setActivePlane( scope.axis, eye );
 
-					var planeIntersect = intersectObjects( pointer, [scope.gizmo[_mode].activePlane] );
+					var planeIntersect = intersectObjects( pointer, [ scope.gizmo[_mode].activePlane ] );
 
 					oldPosition.copy( scope.object.position );
 					oldScale.copy( scope.object.scale );
@@ -803,9 +803,9 @@
 			event.preventDefault();
 			event.stopPropagation();
 
-			var pointer = event.changedTouches? event.changedTouches[0] : event;
+			var pointer = event.changedTouches ? event.changedTouches[0] : event;
 
-			var planeIntersect = intersectObjects( pointer, [scope.gizmo[_mode].activePlane] );
+			var planeIntersect = intersectObjects( pointer, [ scope.gizmo[_mode].activePlane ] );
 
 			point.copy( planeIntersect.point );
 

+ 6 - 6
examples/js/crossfade/scenes.js

@@ -8,7 +8,7 @@ function generateGeometry(objectType, numObjects) {
 
 			var n = ( f instanceof THREE.Face3 ) ? 3 : 4;
 
-			for( var j = 0; j < n; j ++ ) {
+			for ( var j = 0; j < n; j ++ ) {
 
 				f.vertexColors[ j ] = c;
 
@@ -43,13 +43,13 @@ function generateGeometry(objectType, numObjects) {
 			geom = new THREE.BoxGeometry( 1, 1, 1 );
 			scale.y = Math.random() * 200 + 100;
 			scale.z = Math.random() * 200 + 100;
-			color.setRGB( 0, 0, Math.random()+0.1 );
+			color.setRGB( 0, 0, Math.random() + 0.1 );
 		}
 		else if ( objectType == "sphere" )
 		{
 			geom = new THREE.IcosahedronGeometry( 1, 1 )
 			scale.y = scale.z = scale.x;
-			color.setRGB( Math.random()+0.1, 0, 0 );
+			color.setRGB( Math.random() + 0.1, 0, 0 );
 		}
 
 		// give the geom's vertices a random color, to be displayed
@@ -94,9 +94,9 @@ function Scene ( type, numObjects, cameraZ, fov, rotationSpeed, clearColor ) {
 
 	this.render = function( delta, rtt ) {
 
-		this.mesh.rotation.x += delta*this.rotationSpeed.x;
-		this.mesh.rotation.y += delta*this.rotationSpeed.y;
-		this.mesh.rotation.z += delta*this.rotationSpeed.z;
+		this.mesh.rotation.x += delta * this.rotationSpeed.x;
+		this.mesh.rotation.y += delta * this.rotationSpeed.y;
+		this.mesh.rotation.z += delta * this.rotationSpeed.z;
 
 		renderer.setClearColor( this.clearColor );
 

+ 12 - 12
examples/js/crossfade/transition.js

@@ -5,8 +5,8 @@ function Transition ( sceneA, sceneB ) {
 	this.cameraOrtho = new THREE.OrthographicCamera(window.innerWidth / -2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / -2, -10, 10);
 
 	this.textures = [];
-	for (var i=0;i<6;i++)
-		this.textures[i]=new THREE.ImageUtils.loadTexture('textures/transition/transition'+(i+1)+'.png');
+	for (var i = 0; i < 6; i ++)
+		this.textures[i] = new THREE.ImageUtils.loadTexture('textures/transition/transition' + (i + 1) + '.png');
 				
 	this.quadmaterial = new THREE.ShaderMaterial({
 
@@ -101,13 +101,13 @@ function Transition ( sceneA, sceneB ) {
 	
 	this.setTextureThreshold = function ( value ) {
 	
-		this.quadmaterial.uniforms.threshold.value=value;
+		this.quadmaterial.uniforms.threshold.value = value;
 
 	}
 	
 	this.useTexture = function ( value ) {
 	
-		this.quadmaterial.uniforms.useTexture.value = value?1:0;
+		this.quadmaterial.uniforms.useTexture.value = value ? 1 : 0;
 
 	}
 	
@@ -122,32 +122,32 @@ function Transition ( sceneA, sceneB ) {
 		// Transition animation
 		if (transitionParams.animateTransition)
 		{
-			var t=(1+Math.sin(transitionParams.transitionSpeed*clock.getElapsedTime()/Math.PI))/2;
-			transitionParams.transition=THREE.Math.smoothstep(t,0.3,0.7);
+			var t = (1 + Math.sin(transitionParams.transitionSpeed * clock.getElapsedTime() / Math.PI)) / 2;
+			transitionParams.transition = THREE.Math.smoothstep(t, 0.3, 0.7);
 			
 			// Change the current alpha texture after each transition
-			if (transitionParams.loopTexture && (transitionParams.transition==0 || transitionParams.transition==1))
+			if (transitionParams.loopTexture && (transitionParams.transition == 0 || transitionParams.transition == 1))
 			{
 				if (this.needChange)
 				{
-					transitionParams.texture=(transitionParams.texture+1)%this.textures.length;
+					transitionParams.texture = (transitionParams.texture + 1)%this.textures.length;
 					this.quadmaterial.uniforms.tMixTexture.value = this.textures[transitionParams.texture];
-					this.needChange=false;
+					this.needChange = false;
 				}
 			}	
 			else
-				this.needChange=true;
+				this.needChange = true;
 				
 		}
 		
 		this.quadmaterial.uniforms.mixRatio.value = transitionParams.transition;
 
 		// Prevent render both scenes when it's not necessary
-		if (transitionParams.transition==0) {
+		if (transitionParams.transition == 0) {
 			
 			this.sceneB.render( delta, false );
 		
-		} else if (transitionParams.transition==1) {
+		} else if (transitionParams.transition == 1) {
 		
 			this.sceneA.render( delta, false );
 			

+ 1 - 1
examples/js/curves/NURBSCurve.js

@@ -18,7 +18,7 @@ THREE.NURBSCurve = function ( degree, knots /* array of reals */, controlPoints
 	this.degree = degree;
 	this.knots = knots;
 	this.controlPoints = [];
-	for (var i = 0; i < controlPoints.length; ++i) { // ensure Vector4 for control points
+	for (var i = 0; i < controlPoints.length; ++ i) { // ensure Vector4 for control points
 		var point = controlPoints[i];
 		this.controlPoints[i] = new THREE.Vector4(point.x, point.y, point.z, point.w);
 	}

+ 2 - 2
examples/js/curves/NURBSSurface.js

@@ -23,9 +23,9 @@ THREE.NURBSSurface = function ( degree1, degree2, knots1, knots2 /* arrays of re
 	var len2 = knots2.length - degree2 - 1;
 
 	// ensure Vector4 for control points
-	for (var i = 0; i < len1; ++i) {
+	for (var i = 0; i < len1; ++ i) {
 		this.controlPoints[i] = []
-		for (var j = 0; j < len2; ++j) {
+		for (var j = 0; j < len2; ++ j) {
 			var point = controlPoints[i][j];
 			this.controlPoints[i][j] = new THREE.Vector4(point.x, point.y, point.z, point.w);
 		}

+ 29 - 29
examples/js/curves/NURBSUtils.js

@@ -68,14 +68,14 @@ THREE.NURBSUtils = {
 		var right = [];
 		N[0] = 1.0;
 
-		for (var j = 1; j <= p; ++j) {
+		for (var j = 1; j <= p; ++ j) {
 	   
 			left[j] = u - U[span + 1 - j];
 			right[j] = U[span + j] - u;
 
 			var saved = 0.0;
 
-			for (var r = 0; r < j; ++r) {
+			for (var r = 0; r < j; ++ r) {
 
 				var rv = right[r + 1];
 				var lv = left[j - r];
@@ -106,7 +106,7 @@ THREE.NURBSUtils = {
 		var N = this.calcBasisFunctions(span, u, p, U);
 		var C = new THREE.Vector4(0, 0, 0, 0);
 
-		for (var j = 0; j <= p; ++j) {
+		for (var j = 0; j <= p; ++ j) {
 			var point = P[span - p + j];
 			var Nj = N[j];
 			var wNj = point.w * Nj;
@@ -134,15 +134,15 @@ THREE.NURBSUtils = {
 	calcBasisFunctionDerivatives: function( span,  u,  p,  n,  U ) {
 
 		var zeroArr = [];
-		for (var i = 0; i <= p; ++i)
+		for (var i = 0; i <= p; ++ i)
 			zeroArr[i] = 0.0;
 
 		var ders = [];
-		for (var i = 0; i <= n; ++i)
+		for (var i = 0; i <= n; ++ i)
 			ders[i] = zeroArr.slice(0);
 
 		var ndu = [];
-		for (var i = 0; i <= p; ++i)
+		for (var i = 0; i <= p; ++ i)
 			ndu[i] = zeroArr.slice(0);
 
 		ndu[0][0] = 1.0;
@@ -150,13 +150,13 @@ THREE.NURBSUtils = {
 		var left = zeroArr.slice(0);
 		var right = zeroArr.slice(0);
 
-		for (var j = 1; j <= p; ++j) {
+		for (var j = 1; j <= p; ++ j) {
 			left[j] = u - U[span + 1 - j];
 			right[j] = U[span + j] - u;
 
 			var saved = 0.0;
 
-			for (var r = 0; r < j; ++r) {
+			for (var r = 0; r < j; ++ r) {
 				var rv = right[r + 1];
 				var lv = left[j - r];
 				ndu[j][r] = rv + lv;
@@ -169,21 +169,21 @@ THREE.NURBSUtils = {
 			ndu[j][j] = saved;
 		}
 
-		for (var j = 0; j <= p; ++j) {
+		for (var j = 0; j <= p; ++ j) {
 			ders[0][j] = ndu[j][p];
 		}
 
-		for (var r = 0; r <= p; ++r) {
+		for (var r = 0; r <= p; ++ r) {
 			var s1 = 0;
 			var s2 = 1;
 
 			var a = [];
-			for (var i = 0; i <= p; ++i) {
+			for (var i = 0; i <= p; ++ i) {
 				a[i] = zeroArr.slice(0);
 			}
 			a[0][0] = 1.0;
 
-			for (var k = 1; k <= n; ++k) {
+			for (var k = 1; k <= n; ++ k) {
 				var d = 0.0;
 				var rk = r - k;
 				var pk = p - k;
@@ -196,7 +196,7 @@ THREE.NURBSUtils = {
 				var j1 = (rk >= -1) ? 1 : -rk;
 				var j2 = (r - 1 <= pk) ? k - 1 :  p - r;
 
-				for (var j = j1; j <= j2; ++j) {
+				for (var j = j1; j <= j2; ++ j) {
 					a[s2][j] = (a[s1][j] - a[s1][j - 1]) / ndu[pk + 1][rk + j];
 					d += a[s2][j] * ndu[rk + j][pk];
 				}
@@ -216,8 +216,8 @@ THREE.NURBSUtils = {
 
 		var r = p;
 
-		for (var k = 1; k <= n; ++k) {
-			for (var j = 0; j <= p; ++j) {
+		for (var k = 1; k <= n; ++ k) {
+			for (var j = 0; j <= p; ++ j) {
 				ders[k][j] *= r;
 			}
 			r *= p - k;
@@ -245,7 +245,7 @@ THREE.NURBSUtils = {
 		var nders = this.calcBasisFunctionDerivatives(span, u, p, du, U);
 		var Pw = [];
 
-		for (var i = 0; i < P.length; ++i) {
+		for (var i = 0; i < P.length; ++ i) {
 			var point = P[i].clone();
 			var w = point.w;
 
@@ -255,17 +255,17 @@ THREE.NURBSUtils = {
 
 			Pw[i] = point;
 		}
-		for (var k = 0; k <= du; ++k) {
+		for (var k = 0; k <= du; ++ k) {
 			var point = Pw[span - p].clone().multiplyScalar(nders[k][0]);
 
-			for (var j = 1; j <= p; ++j) {
+			for (var j = 1; j <= p; ++ j) {
 				point.add(Pw[span - p + j].clone().multiplyScalar(nders[k][j]));
 			}
 
 			CK[k] = point;
 		}
 
-		for (var k = du + 1; k <= nd + 1; ++k) {
+		for (var k = du + 1; k <= nd + 1; ++ k) {
 			CK[k] = new THREE.Vector4(0, 0, 0);
 		}
 
@@ -281,17 +281,17 @@ THREE.NURBSUtils = {
 	calcKoverI: function( k, i ) {
 		var nom = 1;
 
-		for (var j = 2; j <= k; ++j) {
+		for (var j = 2; j <= k; ++ j) {
 			nom *= j;
 		}
 
 		var denom = 1;
 
-		for (var j = 2; j <= i; ++j) {
+		for (var j = 2; j <= i; ++ j) {
 			denom *= j;
 		}
 
-		for (var j = 2; j <= k - i; ++j) {
+		for (var j = 2; j <= k - i; ++ j) {
 			denom *= j;
 		}
 
@@ -311,7 +311,7 @@ THREE.NURBSUtils = {
 		var Aders = [];
 		var wders = [];
 
-		for (var i = 0; i < nd; ++i) {
+		for (var i = 0; i < nd; ++ i) {
 			var point = Pders[i];
 			Aders[i] = new THREE.Vector3(point.x, point.y, point.z);
 			wders[i] = point.w;
@@ -319,11 +319,11 @@ THREE.NURBSUtils = {
 
 		var CK = [];
 
-		for (var k = 0; k < nd; ++k) {
+		for (var k = 0; k < nd; ++ k) {
 			var v = Aders[k].clone();
 
-			for (var i = 1; i <= k; ++i) {
-				v.sub(CK[k - i].clone().multiplyScalar(this.calcKoverI(k,i) * wders[i]));
+			for (var i = 1; i <= k; ++ i) {
+				v.sub(CK[k - i].clone().multiplyScalar(this.calcKoverI(k, i) * wders[i]));
 			}
 
 			CK[k] = v.divideScalar(wders[0]);
@@ -367,9 +367,9 @@ THREE.NURBSUtils = {
 		var Nv = this.calcBasisFunctions(vspan, v, q, V);
 		var temp = [];
 
-		for (var l = 0; l <= q; ++l) {
+		for (var l = 0; l <= q; ++ l) {
 			temp[l] = new THREE.Vector4(0, 0, 0, 0);
-			for (var k = 0; k <= p; ++k) {
+			for (var k = 0; k <= p; ++ k) {
 				var point = P[uspan - p + k][vspan - q + l].clone();
 				var w = point.w;
 				point.x *= w;
@@ -380,7 +380,7 @@ THREE.NURBSUtils = {
 		}
 
 		var Sw = new THREE.Vector4(0, 0, 0, 0);
-		for (var l = 0; l <= q; ++l) {
+		for (var l = 0; l <= q; ++ l) {
 			Sw.add(temp[l].multiplyScalar(Nv[l]));
 		}
 

+ 13 - 13
examples/js/effects/AsciiEffect.js

@@ -96,8 +96,8 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
 
 		var oStyle = oAscii.style;
 		oStyle.display = "inline";
-		oStyle.width = Math.round(iWidth/fResolution*iScale) + "px";
-		oStyle.height = Math.round(iHeight/fResolution*iScale) + "px";
+		oStyle.width = Math.round(iWidth / fResolution * iScale) + "px";
+		oStyle.height = Math.round(iHeight / fResolution * iScale) + "px";
 		oStyle.whiteSpace = "pre";
 		oStyle.margin = "0px";
 		oStyle.padding = "0px";
@@ -144,8 +144,8 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
 
 	// Setup dom
 
-	var fFontSize = (2/fResolution)*iScale;
-	var fLineHeight = (2/fResolution)*iScale;
+	var fFontSize = (2 / fResolution) * iScale;
+	var fLineHeight = (2 / fResolution) * iScale;
 
 	// adjust letter-spacing for all combinations of scale and resolution to get it to fit the image width.
 
@@ -204,9 +204,9 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
 
 		// console.time('rendering');
 
-		for (var y=0;y<iHeight;y+=2) {
-			for (var x=0;x<iWidth;x++) {
-				var iOffset = (y*iWidth + x) * 4;
+		for (var y = 0; y < iHeight; y+=2) {
+			for (var x = 0; x < iWidth; x ++) {
+				var iOffset = (y * iWidth + x) * 4;
 
 				var iRed = oImgData[iOffset];
 				var iGreen = oImgData[iOffset + 1];
@@ -216,7 +216,7 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
 
 				var fBrightness;
 
-				fBrightness = (0.3*iRed + 0.59*iGreen + 0.11*iBlue) / 255;
+				fBrightness = (0.3 * iRed + 0.59 * iGreen + 0.11 * iBlue) / 255;
 				// fBrightness = (0.3*iRed + 0.5*iGreen + 0.3*iBlue) / 255;
 
 				if (iAlpha == 0) {
@@ -226,7 +226,7 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
 
 				}
 
-				iCharIdx = Math.floor((1-fBrightness) * (aCharList.length-1));
+				iCharIdx = Math.floor((1 - fBrightness) * (aCharList.length - 1));
 
 				if (bInvert) {
 					iCharIdx = aCharList.length - iCharIdx - 1;
@@ -238,14 +238,14 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
 
 				var strThisChar = aCharList[iCharIdx];
 
-				if (strThisChar===undefined || strThisChar == " ")
+				if (strThisChar === undefined || strThisChar == " ")
 					strThisChar = "&nbsp;";
 
 				if (bColor) {
 					strChars += "<span style='"
-						+ "color:rgb("+iRed+","+iGreen+","+iBlue+");"
-						+ (bBlock ? "background-color:rgb("+iRed+","+iGreen+","+iBlue+");" : "")
-						+ (bAlpha ? "opacity:" + (iAlpha/255) + ";" : "")
+						+ "color:rgb(" + iRed + "," + iGreen + "," + iBlue + ");"
+						+ (bBlock ? "background-color:rgb(" + iRed + "," + iGreen + "," + iBlue + ");" : "")
+						+ (bAlpha ? "opacity:" + (iAlpha / 255) + ";" : "")
 						+ "'>" + strThisChar + "</span>";
 				} else {
 					strChars += strThisChar;

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

@@ -43,7 +43,7 @@ THREE.VREffect = function ( renderer, done ) {
 		function gotVRDevices( devices ) {
 			var vrHMD;
 			var error;
-			for ( var i = 0; i < devices.length; ++i ) {
+			for ( var i = 0; i < devices.length; ++ i ) {
 				if ( devices[i] instanceof HMDVRDevice ) {
 					vrHMD = devices[i];
 					self._vrHMD = vrHMD;
@@ -56,7 +56,7 @@ THREE.VREffect = function ( renderer, done ) {
 			}
 			if ( done ) {
 				if ( !vrHMD ) {
-				 error = 'HMD not available';
+					error = 'HMD not available';
 				}
 				done( error );
 			}
@@ -155,7 +155,7 @@ THREE.VREffect = function ( renderer, done ) {
 		var vrHMD = this._vrHMD;
 		var canvas = renderer.domElement;
 		var fullScreenChange =
-			canvas.mozRequestFullScreen? 'mozfullscreenchange' : 'webkitfullscreenchange';
+			canvas.mozRequestFullScreen ? 'mozfullscreenchange' : 'webkitfullscreenchange';
 
 		document.addEventListener( fullScreenChange, onFullScreenChanged, false );
 		function onFullScreenChanged() {
@@ -175,7 +175,7 @@ THREE.VREffect = function ( renderer, done ) {
 		var pxoffset = (fov.leftTan - fov.rightTan) * pxscale * 0.5;
 		var pyscale = 2.0 / (fov.upTan + fov.downTan);
 		var pyoffset = (fov.upTan - fov.downTan) * pyscale * 0.5;
-		return { scale: [pxscale, pyscale], offset: [pxoffset, pyoffset] };
+		return { scale: [ pxscale, pyscale ], offset: [ pxoffset, pyoffset ] };
 	};
 
 	this.FovPortToProjection = function( fov, rightHanded /* = true */, zNear /* = 0.01 */, zFar /* = 10000.0 */ )
@@ -194,30 +194,30 @@ THREE.VREffect = function ( renderer, done ) {
 		var scaleAndOffset = this.FovToNDCScaleOffset(fov);
 
 		// X result, map clip edges to [-w,+w]
-		m[0*4+0] = scaleAndOffset.scale[0];
-		m[0*4+1] = 0.0;
-		m[0*4+2] = scaleAndOffset.offset[0] * handednessScale;
-		m[0*4+3] = 0.0;
+		m[0 * 4 + 0] = scaleAndOffset.scale[0];
+		m[0 * 4 + 1] = 0.0;
+		m[0 * 4 + 2] = scaleAndOffset.offset[0] * handednessScale;
+		m[0 * 4 + 3] = 0.0;
 
 		// Y result, map clip edges to [-w,+w]
 		// Y offset is negated because this proj matrix transforms from world coords with Y=up,
 		// but the NDC scaling has Y=down (thanks D3D?)
-		m[1*4+0] = 0.0;
-		m[1*4+1] = scaleAndOffset.scale[1];
-		m[1*4+2] = -scaleAndOffset.offset[1] * handednessScale;
-		m[1*4+3] = 0.0;
+		m[1 * 4 + 0] = 0.0;
+		m[1 * 4 + 1] = scaleAndOffset.scale[1];
+		m[1 * 4 + 2] = -scaleAndOffset.offset[1] * handednessScale;
+		m[1 * 4 + 3] = 0.0;
 
 		// Z result (up to the app)
-		m[2*4+0] = 0.0;
-		m[2*4+1] = 0.0;
-		m[2*4+2] = zFar / (zNear - zFar) * -handednessScale;
-		m[2*4+3] = (zFar * zNear) / (zNear - zFar);
+		m[2 * 4 + 0] = 0.0;
+		m[2 * 4 + 1] = 0.0;
+		m[2 * 4 + 2] = zFar / (zNear - zFar) * -handednessScale;
+		m[2 * 4 + 3] = (zFar * zNear) / (zNear - zFar);
 
 		// W result (= Z in)
-		m[3*4+0] = 0.0;
-		m[3*4+1] = 0.0;
-		m[3*4+2] = handednessScale;
-		m[3*4+3] = 0.0;
+		m[3 * 4 + 0] = 0.0;
+		m[3 * 4 + 1] = 0.0;
+		m[3 * 4 + 2] = handednessScale;
+		m[3 * 4 + 3] = 0.0;
 
 		mobj.transpose();
 

+ 1 - 1
examples/js/exporters/SceneExporter.js

@@ -182,7 +182,7 @@ THREE.SceneExporter.prototype = {
 
 		function NumConstantString( c ) {
 
-			var constants = [ "NearestFilter", "NearestMipMapNearestFilter" , "NearestMipMapLinearFilter",
+			var constants = [ "NearestFilter", "NearestMipMapNearestFilter", "NearestMipMapLinearFilter",
 							  "LinearFilter", "LinearMipMapNearestFilter", "LinearMipMapLinearFilter" ];
 
 			for ( var i = 0; i < constants.length; i ++ ) {

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

@@ -23,7 +23,7 @@ THREE.ConvexGeometry = function( vertices ) {
 
 	var faces = [ [ 0, 1, 2 ], [ 0, 2, 1 ] ]; 
 
-	for ( var i = 3; i < vertices.length; i++ ) {
+	for ( var i = 3; i < vertices.length; i ++ ) {
 
 		addPoint( i );
 
@@ -49,13 +49,13 @@ THREE.ConvexGeometry = function( vertices ) {
 			// then we try to add the face's edges into the hole.
 			if ( visible( face, vertex ) ) {
 
-				for ( var e = 0; e < 3; e++ ) {
+				for ( var e = 0; e < 3; e ++ ) {
 
 					var edge = [ face[ e ], face[ ( e + 1 ) % 3 ] ];
 					var boundary = true;
 
 					// remove duplicated edges.
-					for ( var h = 0; h < hole.length; h++ ) {
+					for ( var h = 0; h < hole.length; h ++ ) {
 
 						if ( equalEdge( hole[ h ], edge ) ) {
 
@@ -82,13 +82,13 @@ THREE.ConvexGeometry = function( vertices ) {
 
 			} else { // not visible
 
-				f++;
+				f ++;
 
 			}
 		}
 
 		// construct the new faces formed by the edges of the hole and the vertex
-		for ( var h = 0; h < hole.length; h++ ) {
+		for ( var h = 0; h < hole.length; h ++ ) {
 
 			faces.push( [ 
 				hole[ h ][ 0 ],
@@ -170,27 +170,27 @@ THREE.ConvexGeometry = function( vertices ) {
 	var id = 0;
 	var newId = new Array( vertices.length ); // map from old vertex id to new id
 
-	for ( var i = 0; i < faces.length; i++ ) {
+	for ( var i = 0; i < faces.length; i ++ ) {
 
 		 var face = faces[ i ];
 
-		 for ( var j = 0; j < 3; j++ ) {
+		 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 ] ];
 
 		 }
 
 	}
 
 	// Convert faces into instances of THREE.Face3
-	for ( var i = 0; i < faces.length; i++ ) {
+	for ( var i = 0; i < faces.length; i ++ ) {
 
 		this.faces.push( new THREE.Face3( 
 				faces[ i ][ 0 ],
@@ -201,7 +201,7 @@ THREE.ConvexGeometry = function( vertices ) {
 	}
 
 	// Compute UVs
-	for ( var i = 0; i < this.faces.length; i++ ) {
+	for ( var i = 0; i < this.faces.length; i ++ ) {
 
 		var face = this.faces[ i ];
 

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

@@ -15,7 +15,7 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
 
 	THREE.Geometry.call( this );
 
-	if( check === undefined ) check = null;
+	if ( check === undefined ) check = null;
 	check = check || new THREE.Vector3( 1, 1, 1 );
 
 	this.uvs = [];
@@ -60,10 +60,10 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
 
 		}
 
-		if( inVertices.length === 0 ) return [];
+		if ( inVertices.length === 0 ) return [];
 		var outVertices = [];
 
-		for( var j = 0; j < inVertices.length; j += 3 ) {
+		for ( var j = 0; j < inVertices.length; j += 3 ) {
 
 			var v1Out, v2Out, v3Out, total = 0;
 
@@ -75,24 +75,24 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
 			v2Out = d2 > 0;
 			v3Out = d3 > 0;
 
-			total = ( v1Out?1:0 ) + ( v2Out?1:0 ) + ( v3Out?1:0 );
+			total = ( v1Out ? 1 : 0 ) + ( v2Out ? 1 : 0 ) + ( v3Out ? 1 : 0 );
 
-			switch( total ) {
-				case 0:{
+			switch ( total ) {
+				case 0: {
 					outVertices.push( inVertices[ j ] );
 					outVertices.push( inVertices[ j + 1 ] );
 					outVertices.push( inVertices[ j + 2 ] );
 					break;
 				}
-				case 1:{
+				case 1: {
 					var nV1, nV2, nV3;
-					if( v1Out ) {
+					if ( v1Out ) {
 						nV1 = inVertices[ j + 1 ]; 
 						nV2 = inVertices[ j + 2 ];
 						nV3 = clip( inVertices[ j ], nV1, plane );
 						nV4 = clip( inVertices[ j ], nV2, plane );
 					}
-					if( v2Out ) { 
+					if ( v2Out ) { 
 						nV1 = inVertices[ j ]; 
 						nV2 = inVertices[ j + 2 ];
 						nV3 = clip( inVertices[ j + 1 ], nV1, plane );
@@ -107,7 +107,7 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
 						outVertices.push( nV4 );
 						break;
 					}
-					if( v3Out ) { 
+					if ( v3Out ) { 
 						nV1 = inVertices[ j ]; 
 						nV2 = inVertices[ j + 1 ];
 						nV3 = clip( inVertices[ j + 2 ], nV1, plane );
@@ -126,7 +126,7 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
 				}
 				case 2: {
 					var nV1, nV2, nV3;
-					if( !v1Out ) { 
+					if ( !v1Out ) { 
 						nV1 = inVertices[ j ].clone();
 						nV2 = clip( nV1, inVertices[ j + 1 ], plane );
 						nV3 = clip( nV1, inVertices[ j + 2 ], plane ); 
@@ -134,7 +134,7 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
 						outVertices.push( nV2 );
 						outVertices.push( nV3 );
 					}
-					if( !v2Out ) { 
+					if ( !v2Out ) { 
 						nV1 = inVertices[ j + 1 ].clone();
 						nV2 = clip( nV1, inVertices[ j + 2 ], plane );
 						nV3 = clip( nV1, inVertices[ j ], plane );
@@ -142,7 +142,7 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
 						outVertices.push( nV2 );
 						outVertices.push( nV3 );
 					}
-					if( !v3Out ) {
+					if ( !v3Out ) {
 						nV1 = inVertices[ j + 2 ].clone();
 						nV2 = clip( nV1, inVertices[ j ], plane );
 						nV3 = clip( nV1, inVertices[ j + 1 ], plane );
@@ -164,7 +164,7 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
 
 	}
 
-	this.pushVertex = function( vertices, id, n ){
+	this.pushVertex = function( vertices, id, n ) {
 
 		var v = mesh.geometry.vertices[ id ].clone();
 		v.applyMatrix4( mesh.matrix );
@@ -177,7 +177,7 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
 
 		var finalVertices = [];
 
-		for( var i = 0; i < mesh.geometry.faces.length; i++ ) {
+		for ( var i = 0; i < mesh.geometry.faces.length; i ++ ) {
 
 			var f = mesh.geometry.faces[ i ];
 			var vertices = [];
@@ -186,20 +186,20 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
 			this.pushVertex( vertices, f[ this.faceIndices[ 1 ] ], f.vertexNormals[ 1 ] );
 			this.pushVertex( vertices, f[ this.faceIndices[ 2 ] ], f.vertexNormals[ 2 ] );
 
-			if( check.x ) {
+			if ( check.x ) {
 				vertices = this.clipFace( vertices, new THREE.Vector3( 1, 0, 0 ) );
 				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 ) );
+			if ( check.y ) {
+				vertices = this.clipFace( vertices, new THREE.Vector3( 0, 1, 0 ) );
+				vertices = this.clipFace( vertices, new THREE.Vector3( 0, -1, 0 ) );
 			}
-			if( check.z ) {
+			if ( check.z ) {
 				vertices = this.clipFace( vertices, new THREE.Vector3( 0, 0, 1 ) );
 				vertices = this.clipFace( vertices, new THREE.Vector3( 0, 0, -1 ) );
 			}
 
-			for( var j = 0; j < vertices.length; j++ ) {
+			for ( var j = 0; j < vertices.length; j ++ ) {
 
 				var v = vertices[ j ];
 
@@ -212,13 +212,13 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
 
 			}
 
-			if( vertices.length === 0 ) continue;
+			if ( vertices.length === 0 ) continue;
 
 			finalVertices = finalVertices.concat( vertices );
 
 		}
 
-		for( var k = 0; k < finalVertices.length; k += 3 ) {
+		for ( var k = 0; k < finalVertices.length; k += 3 ) {
 			
 			this.vertices.push(
 				finalVertices[ k ].vertex,

+ 1 - 1
examples/js/geometries/hilbert2D.js

@@ -42,7 +42,7 @@ function hilbert2D (center, size, iterations, v0, v1, v2, v3) {
 	];
 
 	// Recurse iterations
-	if (0 <= --iterations) {
+	if (0 <= -- iterations) {
 		var tmp = [];
 
 		Array.prototype.push.apply( tmp, hilbert2D ( vec[ 0 ], half, iterations, v0, v3, v2, v1 ) );

+ 1 - 1
examples/js/geometries/hilbert3D.js

@@ -63,7 +63,7 @@ function hilbert3D(center, size, iterations, v0, v1, v2, v3, v4, v5, v6, v7) {
 	];
 
 	// Recurse iterations
-	if( --iterations >= 0 ) {
+	if ( -- iterations >= 0 ) {
 		var tmp = [];
 
 		Array.prototype.push.apply( tmp, hilbert3D ( vec[ 0 ], half, iterations, v0, v3, v4, v7, v6, v5, v2, v1 ) );

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 348 - 348
examples/js/loaders/AWDLoader.js


+ 27 - 27
examples/js/loaders/AssimpJSONLoader.js

@@ -74,7 +74,7 @@ THREE.AssimpJSONLoader.prototype = {
 
 	parseList : function(json, handler) {
 		var meshes = new Array(json.length);
-		for(var i = 0; i < json.length; ++i) {
+		for (var i = 0; i < json.length; ++ i) {
 			meshes[i] = handler.call(this, json[i]);
 		}
 		return meshes;
@@ -87,13 +87,13 @@ THREE.AssimpJSONLoader.prototype = {
 		geometry = new THREE.Geometry();
 
 		// read vertex positions
-		for(in_data = json.vertices, i = 0, e = in_data.length; i < e; ) {
-			geometry.vertices.push( new THREE.Vector3( in_data[ i++ ], in_data[ i++ ], in_data[ i++ ] ) );
+		for (in_data = json.vertices, i = 0, e = in_data.length; i < e; ) {
+			geometry.vertices.push( new THREE.Vector3( in_data[ i ++ ], in_data[ i ++ ], in_data[ i ++ ] ) );
 		}
 
 		// read faces
 		var cnt = 0;
-		for(in_data = json.faces, i = 0, e = in_data.length; i < e; ++i) {
+		for (in_data = json.faces, i = 0, e = in_data.length; i < e; ++ i) {
 			face = new THREE.Face3();
 			src = in_data[i];
 			face.a = src[0];
@@ -106,12 +106,12 @@ THREE.AssimpJSONLoader.prototype = {
 
 		// read texture coordinates - three.js attaches them to its faces
 		json.texturecoords = json.texturecoords || [];
-		for(i = 0, e = json.texturecoords.length; i < e; ++i) {
+		for (i = 0, e = json.texturecoords.length; i < e; ++ i) {
 
 			function convertTextureCoords(in_uv, out_faces, out_vertex_uvs) {
 				var i, e, face, a, b, c;
 
-				for(i = 0, e = out_faces.length; i < e; ++i) {
+				for (i = 0, e = out_faces.length; i < e; ++ i) {
 					face = out_faces[i];
 					a = face.a * 2;
 					b = face.b * 2;
@@ -128,12 +128,12 @@ THREE.AssimpJSONLoader.prototype = {
 		}
 
 		// read normals - three.js also attaches them to its faces
-		if(json.normals) {
+		if (json.normals) {
 
 			function convertNormals(in_nor, out_faces) {
 				var i, e, face, a, b, c;
 
-				for(i = 0, e = out_faces.length; i < e; ++i) {
+				for (i = 0, e = out_faces.length; i < e; ++ i) {
 					face = out_faces[i];
 					a = face.a * 3;
 					b = face.b * 3;
@@ -150,7 +150,7 @@ THREE.AssimpJSONLoader.prototype = {
 		}
 
 		// read vertex colors - three.js also attaches them to its faces
-		if(json.colors && json.colors[0]) {
+		if (json.colors && json.colors[0]) {
 
 			function convertColors(in_color, out_faces) {
 				var i, e, face, a, b, c;
@@ -162,7 +162,7 @@ THREE.AssimpJSONLoader.prototype = {
 					return col;
 				}
 
-				for(i = 0, e = out_faces.length; i < e; ++i) {
+				for (i = 0, e = out_faces.length; i < e; ++ i) {
 					face = out_faces[i];
 					a = face.a * 4;
 					b = face.b * 4;
@@ -198,7 +198,7 @@ THREE.AssimpJSONLoader.prototype = {
 
 		function toColor(value_arr) {
 			var col = new THREE.Color();
-			col.setRGB(value_arr[0],value_arr[1],value_arr[2]);
+			col.setRGB(value_arr[0], value_arr[1], value_arr[2]);
 			return col;
 		}
 
@@ -212,28 +212,28 @@ THREE.AssimpJSONLoader.prototype = {
 		for (var i in json.properties) {
 			prop = json.properties[i];
 
-			if(prop.key === '$tex.file') {
+			if (prop.key === '$tex.file') {
 				// prop.semantic gives the type of the texture
 				// 1: diffuse
 				// 2: specular mao
 				// 5: height map (bumps)
 				// 6: normal map
 				// more values (i.e. emissive, environment) are known by assimp and may be relevant
-				if(prop.semantic === 1 || prop.semantic === 5 || prop.semantic === 6 || prop.semantic === 2) {
+				if (prop.semantic === 1 || prop.semantic === 5 || prop.semantic === 6 || prop.semantic === 2) {
 					(function(semantic) {
 						var loader = new THREE.TextureLoader(scope.manager),
 						keyname;
 
-						if(semantic === 1) {
+						if (semantic === 1) {
 							keyname = 'map';
 						}
-						else if(semantic === 5) {
+						else if (semantic === 5) {
 							keyname = 'bumpMap';
 						}
-						else if(semantic === 6) {
+						else if (semantic === 6) {
 							keyname = 'normalMap';
 						}
-						else if(semantic === 2) {
+						else if (semantic === 2) {
 							keyname = 'specularMap';
 						}
 
@@ -243,7 +243,7 @@ THREE.AssimpJSONLoader.prototype = {
 						var material_url = scope.texturePath + '/' + prop.value
 						material_url = material_url.replace(/\\/g, '/');
 						loader.load(material_url, function(tex) {
-							if(tex) {
+							if (tex) {
 								// TODO: read texture settings from assimp.
 								// Wrapping is the default, though.
 								tex.wrapS = tex.wrapT = THREE.RepeatWrapping;
@@ -255,19 +255,19 @@ THREE.AssimpJSONLoader.prototype = {
 					})(prop.semantic);
 				}
 			}
-			else if(prop.key === '?mat.name') {
+			else if (prop.key === '?mat.name') {
 				init_props.name = prop.value;
 			}
-			else if(prop.key === '$clr.diffuse') {
+			else if (prop.key === '$clr.diffuse') {
 				init_props.color = toColor(prop.value);
 			}
-			else if(prop.key === '$clr.specular') {
+			else if (prop.key === '$clr.specular') {
 				init_props.specular = toColor(prop.value);
 			}
-			else if(prop.key === '$clr.emissive') {
+			else if (prop.key === '$clr.emissive') {
 				init_props.emissive = toColor(prop.value);
 			}
-			else if(prop.key === '$mat.shadingm') {
+			else if (prop.key === '$mat.shadingm') {
 				// aiShadingMode_Flat
 				if (prop.value === 1) {
 					init_props.shading = THREE.FlatShading;
@@ -281,8 +281,8 @@ THREE.AssimpJSONLoader.prototype = {
 		// note: three.js does not like it when a texture is added after the geometry
 		// has been rendered once, see http://stackoverflow.com/questions/16531759/.
 		// for this reason we fill all slots upfront with default textures
-		if(has_textures.length) {
-			for(i = has_textures.length-1; i >= 0; --i) {
+		if (has_textures.length) {
+			for (i = has_textures.length - 1; i >= 0; -- i) {
 				init_props[has_textures[i]] = defaultTexture();
 			}
 		}
@@ -301,12 +301,12 @@ THREE.AssimpJSONLoader.prototype = {
 		obj.matrix = new THREE.Matrix4().fromArray(node.transformation).transpose();
 		obj.matrix.decompose( obj.position, obj.quaternion, obj.scale );
 
-		for(i = 0; node.meshes && i < node.meshes.length; ++i) {
+		for (i = 0; node.meshes && i < node.meshes.length; ++ i) {
 			idx = node.meshes[i];
 			obj.add(new THREE.Mesh( meshes[idx], materials[json.meshes[idx].materialindex] ));
 		}
 
-		for(i = 0; node.children && i < node.children.length; ++i) {
+		for (i = 0; node.children && i < node.children.length; ++ i) {
 			obj.add(this.parseObject(json, node.children[i], meshes, materials));
 		}
 

+ 56 - 56
examples/js/loaders/BinaryLoader.js

@@ -192,7 +192,7 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
 		start_quad_flat     = start_tri_smooth_uv + len_tri_smooth_uv  + handlePadding( md.ntri_smooth_uv * 2 );
 		start_quad_smooth   = start_quad_flat     + len_quad_flat	   + handlePadding( md.nquad_flat * 2 );
 		start_quad_flat_uv  = start_quad_smooth   + len_quad_smooth    + handlePadding( md.nquad_smooth * 2 );
-		start_quad_smooth_uv= start_quad_flat_uv  + len_quad_flat_uv   + handlePadding( md.nquad_flat_uv * 2 );
+		start_quad_smooth_uv = start_quad_flat_uv  + len_quad_flat_uv   + handlePadding( md.nquad_flat_uv * 2 );
 
 		// have to first process faces with uvs
 		// so that face and uv indices match
@@ -236,18 +236,18 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
 				'material_index_bytes'    :parseUChar8( data, offset + 19 ),
 
 				'nvertices'    :parseUInt32( data, offset + 20 ),
-				'nnormals'     :parseUInt32( data, offset + 20 + 4*1 ),
-				'nuvs'         :parseUInt32( data, offset + 20 + 4*2 ),
+				'nnormals'     :parseUInt32( data, offset + 20 + 4 * 1 ),
+				'nuvs'         :parseUInt32( data, offset + 20 + 4 * 2 ),
 
-				'ntri_flat'      :parseUInt32( data, offset + 20 + 4*3 ),
-				'ntri_smooth'    :parseUInt32( data, offset + 20 + 4*4 ),
-				'ntri_flat_uv'   :parseUInt32( data, offset + 20 + 4*5 ),
-				'ntri_smooth_uv' :parseUInt32( data, offset + 20 + 4*6 ),
+				'ntri_flat'      :parseUInt32( data, offset + 20 + 4 * 3 ),
+				'ntri_smooth'    :parseUInt32( data, offset + 20 + 4 * 4 ),
+				'ntri_flat_uv'   :parseUInt32( data, offset + 20 + 4 * 5 ),
+				'ntri_smooth_uv' :parseUInt32( data, offset + 20 + 4 * 6 ),
 
-				'nquad_flat'      :parseUInt32( data, offset + 20 + 4*7 ),
-				'nquad_smooth'    :parseUInt32( data, offset + 20 + 4*8 ),
-				'nquad_flat_uv'   :parseUInt32( data, offset + 20 + 4*9 ),
-				'nquad_smooth_uv' :parseUInt32( data, offset + 20 + 4*10 )
+				'nquad_flat'      :parseUInt32( data, offset + 20 + 4 * 7 ),
+				'nquad_smooth'    :parseUInt32( data, offset + 20 + 4 * 8 ),
+				'nquad_flat_uv'   :parseUInt32( data, offset + 20 + 4 * 9 ),
+				'nquad_smooth_uv' :parseUInt32( data, offset + 20 + 4 * 10 )
 
 			};
 /*
@@ -336,7 +336,7 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
 
 			var i, x, y, z;
 
-			for( i = 0; i < nElements; i ++ ) {
+			for ( i = 0; i < nElements; i ++ ) {
 
 				x = coordArray[ i * 3 ];
 				y = coordArray[ i * 3 + 1 ];
@@ -360,13 +360,13 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
 
 				var i, x, y, z;
 
-				for( i = 0; i < nElements; i ++ ) {
+				for ( i = 0; i < nElements; i ++ ) {
 
 					x = normalArray[ i * 3 ];
 					y = normalArray[ i * 3 + 1 ];
 					z = normalArray[ i * 3 + 2 ];
 
-					normals.push( x/127, y/127, z/127 );
+					normals.push( x / 127, y / 127, z / 127 );
 
 				}
 
@@ -386,7 +386,7 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
 
 				var i, u, v;
 
-				for( i = 0; i < nElements; i ++ ) {
+				for ( i = 0; i < nElements; i ++ ) {
 
 					u = uvArray[ i * 2 ];
 					v = uvArray[ i * 2 + 1 ];
@@ -407,20 +407,20 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
 
 			var uvIndexBuffer = new Uint32Array( data, offset, 3 * nElements );
 
-			for( i = 0; i < nElements; i ++ ) {
+			for ( i = 0; i < nElements; i ++ ) {
 
 				uva = uvIndexBuffer[ i * 3 ];
 				uvb = uvIndexBuffer[ i * 3 + 1 ];
 				uvc = uvIndexBuffer[ i * 3 + 2 ];
 
-				u1 = uvs[ uva*2 ];
-				v1 = uvs[ uva*2 + 1 ];
+				u1 = uvs[ uva * 2 ];
+				v1 = uvs[ uva * 2 + 1 ];
 
-				u2 = uvs[ uvb*2 ];
-				v2 = uvs[ uvb*2 + 1 ];
+				u2 = uvs[ uvb * 2 ];
+				v2 = uvs[ uvb * 2 + 1 ];
 
-				u3 = uvs[ uvc*2 ];
-				v3 = uvs[ uvc*2 + 1 ];
+				u3 = uvs[ uvc * 2 ];
+				v3 = uvs[ uvc * 2 + 1 ];
 
 				scope.faceVertexUvs[ 0 ].push( [
 					new THREE.Vector2( u1, v1 ),
@@ -438,24 +438,24 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
 
 			var uvIndexBuffer = new Uint32Array( data, offset, 4 * nElements );
 
-			for( i = 0; i < nElements; i ++ ) {
+			for ( i = 0; i < nElements; i ++ ) {
 
 				uva = uvIndexBuffer[ i * 4 ];
 				uvb = uvIndexBuffer[ i * 4 + 1 ];
 				uvc = uvIndexBuffer[ i * 4 + 2 ];
 				uvd = uvIndexBuffer[ i * 4 + 3 ];
 
-				u1 = uvs[ uva*2 ];
-				v1 = uvs[ uva*2 + 1 ];
+				u1 = uvs[ uva * 2 ];
+				v1 = uvs[ uva * 2 + 1 ];
 
-				u2 = uvs[ uvb*2 ];
-				v2 = uvs[ uvb*2 + 1 ];
+				u2 = uvs[ uvb * 2 ];
+				v2 = uvs[ uvb * 2 + 1 ];
 
-				u3 = uvs[ uvc*2 ];
-				v3 = uvs[ uvc*2 + 1 ];
+				u3 = uvs[ uvc * 2 ];
+				v3 = uvs[ uvc * 2 + 1 ];
 
-				u4 = uvs[ uvd*2 ];
-				v4 = uvs[ uvd*2 + 1 ];
+				u4 = uvs[ uvd * 2 ];
+				v4 = uvs[ uvd * 2 + 1 ];
 
 				scope.faceVertexUvs[ 0 ].push( [
 					new THREE.Vector2( u1, v1 ),
@@ -480,7 +480,7 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
 			var vertexIndexBuffer = new Uint32Array( data, offsetVertices, 3 * nElements );
 			var materialIndexBuffer = new Uint16Array( data, offsetMaterials, nElements );
 
-			for( i = 0; i < nElements; i ++ ) {
+			for ( i = 0; i < nElements; i ++ ) {
 
 				a = vertexIndexBuffer[ i * 3 ];
 				b = vertexIndexBuffer[ i * 3 + 1 ];
@@ -501,7 +501,7 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
 			var vertexIndexBuffer = new Uint32Array( data, offsetVertices, 4 * nElements );
 			var materialIndexBuffer = new Uint16Array( data, offsetMaterials, nElements );
 
-			for( i = 0; i < nElements; i ++ ) {
+			for ( i = 0; i < nElements; i ++ ) {
 
 				a = vertexIndexBuffer[ i * 4 ];
 				b = vertexIndexBuffer[ i * 4 + 1 ];
@@ -526,7 +526,7 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
 			var normalIndexBuffer = new Uint32Array( data, offsetNormals, 3 * nElements );
 			var materialIndexBuffer = new Uint16Array( data, offsetMaterials, nElements );
 
-			for( i = 0; i < nElements; i ++ ) {
+			for ( i = 0; i < nElements; i ++ ) {
 
 				a = vertexIndexBuffer[ i * 3 ];
 				b = vertexIndexBuffer[ i * 3 + 1 ];
@@ -538,17 +538,17 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
 
 				m = materialIndexBuffer[ i ];
 
-				var nax = normals[ na*3     ],
-					nay = normals[ na*3 + 1 ],
-					naz = normals[ na*3 + 2 ],
+				var nax = normals[ na * 3     ],
+					nay = normals[ na * 3 + 1 ],
+					naz = normals[ na * 3 + 2 ],
 
-					nbx = normals[ nb*3     ],
-					nby = normals[ nb*3 + 1 ],
-					nbz = normals[ nb*3 + 2 ],
+					nbx = normals[ nb * 3     ],
+					nby = normals[ nb * 3 + 1 ],
+					nbz = normals[ nb * 3 + 2 ],
 
-					ncx = normals[ nc*3     ],
-					ncy = normals[ nc*3 + 1 ],
-					ncz = normals[ nc*3 + 2 ];
+					ncx = normals[ nc * 3     ],
+					ncy = normals[ nc * 3 + 1 ],
+					ncz = normals[ nc * 3 + 2 ];
 
 				scope.faces.push( new THREE.Face3( a, b, c, [
 					new THREE.Vector3( nax, nay, naz ),
@@ -569,7 +569,7 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
 			var normalIndexBuffer = new Uint32Array( data, offsetNormals, 4 * nElements );
 			var materialIndexBuffer = new Uint16Array( data, offsetMaterials, nElements );
 
-			for( i = 0; i < nElements; i ++ ) {
+			for ( i = 0; i < nElements; i ++ ) {
 
 				a = vertexIndexBuffer[ i * 4 ];
 				b = vertexIndexBuffer[ i * 4 + 1 ];
@@ -583,21 +583,21 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
 
 				m = materialIndexBuffer[ i ];
 
-				var nax = normals[ na*3     ],
-					nay = normals[ na*3 + 1 ],
-					naz = normals[ na*3 + 2 ],
+				var nax = normals[ na * 3     ],
+					nay = normals[ na * 3 + 1 ],
+					naz = normals[ na * 3 + 2 ],
 
-					nbx = normals[ nb*3     ],
-					nby = normals[ nb*3 + 1 ],
-					nbz = normals[ nb*3 + 2 ],
+					nbx = normals[ nb * 3     ],
+					nby = normals[ nb * 3 + 1 ],
+					nbz = normals[ nb * 3 + 2 ],
 
-					ncx = normals[ nc*3     ],
-					ncy = normals[ nc*3 + 1 ],
-					ncz = normals[ nc*3 + 2 ],
+					ncx = normals[ nc * 3     ],
+					ncy = normals[ nc * 3 + 1 ],
+					ncz = normals[ nc * 3 + 2 ],
 
-					ndx = normals[ nd*3     ],
-					ndy = normals[ nd*3 + 1 ],
-					ndz = normals[ nd*3 + 2 ];
+					ndx = normals[ nd * 3     ],
+					ndy = normals[ nd * 3 + 1 ],
+					ndz = normals[ nd * 3 + 2 ];
 
 				scope.faces.push( new THREE.Face3( a, b, d, [
 					new THREE.Vector3( nax, nay, naz ),

+ 111 - 98
examples/js/loaders/ColladaLoader.js

@@ -66,9 +66,9 @@ THREE.ColladaLoader = function () {
 
 			request.onreadystatechange = function() {
 
-				if( request.readyState === 4 ) {
+				if ( request.readyState === 4 ) {
 
-					if( request.status === 0 || request.status === 200 ) {
+					if ( request.status === 0 || request.status === 200 ) {
 
 
 						if ( request.responseXML ) {
@@ -342,7 +342,7 @@ THREE.ColladaLoader = function () {
 
 			animData.push(newData);
 
-			for ( var i = 0, il = n.keys.length; i < il; i++ ) {
+			for ( var i = 0, il = n.keys.length; i < il; i ++ ) {
 
 				newData.length = Math.max( newData.length, n.keys[i].time );
 
@@ -359,7 +359,7 @@ THREE.ColladaLoader = function () {
 
 		}
 
-		for ( var i = 0, il = node.children.length; i < il; i++ ) {
+		for ( var i = 0, il = node.children.length; i < il; i ++ ) {
 
 			var d = recurseHierarchy( node.children[i] );
 
@@ -513,7 +513,7 @@ THREE.ColladaLoader = function () {
 
 				node.world.copy( m );
 				node.localworld.copy(m);
-				if(frame === 0)
+				if (frame === 0)
 					node.matrix.copy(m);
 			}
 
@@ -607,24 +607,24 @@ THREE.ColladaLoader = function () {
 			bone.name = node.sid;
 			bone.parent = parentid;
 			bone.matrix = node.matrix;
-			var data = [new THREE.Vector3(),new THREE.Quaternion(),new THREE.Vector3()];
-			bone.matrix.decompose(data[0],data[1],data[2]);
+			var data = [ new THREE.Vector3(),new THREE.Quaternion(),new THREE.Vector3() ];
+			bone.matrix.decompose(data[0], data[1], data[2]);
 
-			bone.pos = [data[0].x,data[0].y,data[0].z];
+			bone.pos = [ data[0].x,data[0].y,data[0].z ];
 
-			bone.scl = [data[2].x,data[2].y,data[2].z];
-			bone.rotq = [data[1].x,data[1].y,data[1].z,data[1].w];
+			bone.scl = [ data[2].x,data[2].y,data[2].z ];
+			bone.rotq = [ data[1].x,data[1].y,data[1].z,data[1].w ];
 			list.push(bone);
 
-			for(var i in node.nodes) {
+			for (var i in node.nodes) {
 
-				walk(node.sid,node.nodes[i],list);
+				walk(node.sid, node.nodes[i], list);
 
 			}
 
 		};
 
-		walk(-1,skeleton,list);
+		walk(-1, skeleton, list);
 		return list;
 
 	}
@@ -638,7 +638,7 @@ THREE.ColladaLoader = function () {
 		v = new THREE.Vector3();
 		var skinned = [];
 
-		for(var i =0; i < geometry.vertices.length; i++) {
+		for (var i = 0; i < geometry.vertices.length; i ++) {
 
 			skinned.push(new THREE.Vector3());
 
@@ -670,7 +670,7 @@ THREE.ColladaLoader = function () {
 
 		}
 
-		for(var i =0; i < geometry.vertices.length; i++) {
+		for (var i = 0; i < geometry.vertices.length; i ++) {
 
 			geometry.vertices[i] = skinned[i];
 
@@ -707,11 +707,11 @@ THREE.ColladaLoader = function () {
 
 		//sort that list so that the order reflects the order in the joint list
 		var sortedbones = [];
-		for(var i = 0; i < joints.length; i++) {
+		for (var i = 0; i < joints.length; i ++) {
 
-			for(var j =0; j < bonelist.length; j++) {
+			for (var j = 0; j < bonelist.length; j ++) {
 
-				if(bonelist[j].name === joints[i]) {
+				if (bonelist[j].name === joints[i]) {
 
 					sortedbones[i] = bonelist[j];
 
@@ -722,11 +722,11 @@ THREE.ColladaLoader = function () {
 		}
 
 		//hook up the parents by index instead of name
-		for(var i = 0; i < sortedbones.length; i++) {
+		for (var i = 0; i < sortedbones.length; i ++) {
 
-			for(var j =0; j < sortedbones.length; j++) {
+			for (var j = 0; j < sortedbones.length; j ++) {
 
-				if(sortedbones[i].parent === sortedbones[j].name) {
+				if (sortedbones[i].parent === sortedbones[j].name) {
 
 					sortedbones[i].parent = j;
 
@@ -742,7 +742,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 = [];
@@ -751,10 +751,10 @@ THREE.ColladaLoader = function () {
 
 		// hook up the skin weights
 		// TODO - this might be a good place to choose greatest 4 weights
-		for(var i =0; i < weights.length; i++) {
+		for ( var i =0; i < weights.length; i ++ ) {
 
-			var indicies = new THREE.Vector4(weights[i][0]?weights[i][0].joint:0,weights[i][1]?weights[i][1].joint:0,weights[i][2]?weights[i][2].joint:0,weights[i][3]?weights[i][3].joint:0);
-			var weight = new THREE.Vector4(weights[i][0]?weights[i][0].weight:0,weights[i][1]?weights[i][1].weight:0,weights[i][2]?weights[i][2].weight:0,weights[i][3]?weights[i][3].weight:0);
+			var indicies = new THREE.Vector4(weights[i][0] ? weights[i][0].joint : 0,weights[i][1] ? weights[i][1].joint : 0,weights[i][2] ? weights[i][2].joint : 0,weights[i][3] ? weights[i][3].joint : 0);
+			var weight = new THREE.Vector4(weights[i][0] ? weights[i][0].weight : 0,weights[i][1] ? weights[i][1].weight : 0,weights[i][2] ? weights[i][2].weight : 0,weights[i][3] ? weights[i][3].weight : 0);
 
 			skinIndices.push(indicies);
 			skinWeights.push(weight);
@@ -768,11 +768,11 @@ THREE.ColladaLoader = function () {
 
 		//create an animation for the animated bones
 		//NOTE: this has no effect when using morphtargets
-		var animationdata = {"name":animationBounds.ID,"fps":30,"length":animationBounds.frames/30,"hierarchy":[]};
+		var animationdata = { "name":animationBounds.ID,"fps":30,"length":animationBounds.frames / 30,"hierarchy":[] };
 
-		for(var j =0; j < sortedbones.length; j++) {
+		for (var j = 0; j < sortedbones.length; j ++) {
 
-			animationdata.hierarchy.push({parent:sortedbones[j].parent, name:sortedbones[j].name, keys:[]});
+			animationdata.hierarchy.push({ parent:sortedbones[j].parent, name:sortedbones[j].name, keys:[] });
 
 		}
 
@@ -780,7 +780,7 @@ THREE.ColladaLoader = function () {
 
 
 
-		skinToBindPose(geometry,skeleton,skinController);
+		skinToBindPose(geometry, skeleton, skinController);
 
 
 		for ( frame = 0; frame < animationBounds.frames; frame ++ ) {
@@ -793,25 +793,25 @@ THREE.ColladaLoader = function () {
 			setupSkeleton( skeleton, bones, frame );
 			setupSkinningMatrices( bones, skinController.skin );
 
-			for(var i = 0; i < bones.length; i ++) {
+			for (var i = 0; i < bones.length; i ++) {
 
-				for(var j = 0; j < animationdata.hierarchy.length; j ++) {
+				for (var j = 0; j < animationdata.hierarchy.length; j ++) {
 
-					if(animationdata.hierarchy[j].name === bones[i].sid) {
+					if (animationdata.hierarchy[j].name === bones[i].sid) {
 
 						var key = {};
-						key.time = (frame/30);
+						key.time = (frame / 30);
 						key.matrix = bones[i].animatrix;
 
-						if(frame === 0)
+						if (frame === 0)
 							bones[i].matrix = key.matrix;
 
-						var data = [new THREE.Vector3(),new THREE.Quaternion(),new THREE.Vector3()];
-						key.matrix.decompose(data[0],data[1],data[2]);
+						var data = [ new THREE.Vector3(),new THREE.Quaternion(),new THREE.Vector3() ];
+						key.matrix.decompose(data[0], data[1], data[2]);
 
-						key.pos = [data[0].x,data[0].y,data[0].z];
+						key.pos = [ data[0].x,data[0].y,data[0].z ];
 
-						key.scl = [data[2].x,data[2].y,data[2].z];
+						key.scl = [ data[2].x,data[2].y,data[2].z ];
 						key.rot = data[1];
 
 						animationdata.hierarchy[j].keys.push(key);
@@ -904,7 +904,7 @@ THREE.ColladaLoader = function () {
 
 						var matrix = new THREE.Matrix4();
 
-						for (i = 0; i < transforms.length; i++ ) {
+						for (i = 0; i < transforms.length; i ++ ) {
 
 							var transform = transforms[ i ];
 
@@ -1352,6 +1352,7 @@ THREE.ColladaLoader = function () {
 
 		var nodes = COLLADA.querySelectorAll('library_nodes node');
 
+<<<<<<< HEAD
 		for ( var i = 0; i < nodes.length; i++ ) {
 
 			var attObj = nodes[i].attributes.getNamedItem('id');
@@ -1362,6 +1363,14 @@ THREE.ColladaLoader = function () {
 
 			}
 
+=======
+		for ( var i = 0; i < nodes.length; i ++ ) {
+
+			var attObj = nodes[i].attributes.getNamedItem('id');
+			if ( attObj && attObj.value === id ) {
+				return nodes[i];
+			}
+>>>>>>> 4501d5a51d49e2e709930188a02af8d3dec5da61
 		}
 
 		return undefined;
@@ -1506,7 +1515,7 @@ THREE.ColladaLoader = function () {
 			var keys = [],
 				sids = [];
 
-			for ( var i = 0, il = node.channels.length; i < il; i++ ) {
+			for ( var i = 0, il = node.channels.length; i < il; i ++ ) {
 
 				var channel = node.channels[i],
 					fullSid = channel.fullSid,
@@ -1519,7 +1528,7 @@ THREE.ColladaLoader = function () {
 
 					member = [];
 
-					for ( var j = 0, jl = channel.arrIndices.length; j < jl; j++ ) {
+					for ( var j = 0, jl = channel.arrIndices.length; j < jl; j ++ ) {
 
 						member[ j ] = getConvertedIndex( channel.arrIndices[ j ] );
 
@@ -1539,7 +1548,7 @@ THREE.ColladaLoader = function () {
 
 					}
 
-					for ( var j = 0, jl = input.length; j < jl; j++ ) {
+					for ( var j = 0, jl = input.length; j < jl; j ++ ) {
 
 						var time = input[j],
 							data = sampler.getData( transform.type, j, member ),
@@ -1566,11 +1575,11 @@ THREE.ColladaLoader = function () {
 			}
 
 			// post process
-			for ( var i = 0; i < sids.length; i++ ) {
+			for ( var i = 0; i < sids.length; i ++ ) {
 
 				var sid = sids[ i ];
 
-				for ( var j = 0; j < keys.length; j++ ) {
+				for ( var j = 0; j < keys.length; j ++ ) {
 
 					var key = keys[ j ];
 
@@ -1595,7 +1604,7 @@ THREE.ColladaLoader = function () {
 
 		var retVal = null;
 
-		for ( var i = 0, il = keys.length; i < il && retVal === null; i++ ) {
+		for ( var i = 0, il = keys.length; i < il && retVal === null; i ++ ) {
 
 			var key = keys[i];
 
@@ -1619,7 +1628,7 @@ THREE.ColladaLoader = function () {
 
 		var ndx = -1;
 
-		for ( var i = 0, il = keys.length; i < il && ndx === -1; i++ ) {
+		for ( var i = 0, il = keys.length; i < il && ndx === -1; i ++ ) {
 
 			var key = keys[i];
 
@@ -1637,8 +1646,8 @@ THREE.ColladaLoader = function () {
 
 	function interpolateKeys ( keys, key, ndx, fullSid ) {
 
-		var prevKey = getPrevKeyWith( keys, fullSid, ndx ? ndx-1 : 0 ),
-			nextKey = getNextKeyWith( keys, fullSid, ndx+1 );
+		var prevKey = getPrevKeyWith( keys, fullSid, ndx ? ndx - 1 : 0 ),
+			nextKey = getNextKeyWith( keys, fullSid, ndx + 1 );
 
 		if ( prevKey && nextKey ) {
 
@@ -1656,7 +1665,7 @@ THREE.ColladaLoader = function () {
 
 				data = [];
 
-				for ( var i = 0; i < prevData.length; ++i ) {
+				for ( var i = 0; i < prevData.length; ++ i ) {
 
 					data[ i ] = prevData[ i ] + ( nextData[ i ] - prevData[ i ] ) * scale;
 
@@ -1678,7 +1687,7 @@ THREE.ColladaLoader = function () {
 
 	function getNextKeyWith( keys, fullSid, ndx ) {
 
-		for ( ; ndx < keys.length; ndx++ ) {
+		for ( ; ndx < keys.length; ndx ++ ) {
 
 			var key = keys[ ndx ];
 
@@ -1700,7 +1709,7 @@ THREE.ColladaLoader = function () {
 
 		ndx = ndx >= 0 ? ndx : ndx + keys.length;
 
-		for ( ; ndx >= 0; ndx-- ) {
+		for ( ; ndx >= 0; ndx -- ) {
 
 			var key = keys[ ndx ];
 
@@ -1759,7 +1768,7 @@ THREE.ColladaLoader = function () {
 		this.name = element.getAttribute('name');
 		this.type = "none";
 
-		for ( var i = 0; i < element.childNodes.length; i++ ) {
+		for ( var i = 0; i < element.childNodes.length; i ++ ) {
 
 			var child = element.childNodes[ i ];
 
@@ -2022,7 +2031,7 @@ THREE.ColladaLoader = function () {
 			var numBones = vcount[i];
 			var vertex_weights = [];
 
-			for ( var j = 0; j < numBones; j++ ) {
+			for ( var j = 0; j < numBones; j ++ ) {
 
 				var influence = {};
 
@@ -2644,7 +2653,7 @@ THREE.ColladaLoader = function () {
 
 					var instances = child.querySelectorAll('instance_material');
 
-					for ( var j = 0; j < instances.length; j ++ ){
+					for ( var j = 0; j < instances.length; j ++ ) {
 
 						var instance = instances[j];
 						this.instance_material.push( (new InstanceMaterial()).parse(instance) );
@@ -2873,7 +2882,7 @@ THREE.ColladaLoader = function () {
 			input = inputs[ j ];
 
 			var offset = input.offset + 1;
-			maxOffset = (maxOffset < offset)? offset : maxOffset;
+			maxOffset = (maxOffset < offset) ? offset : maxOffset;
 
 			switch ( input.semantic ) {
 
@@ -2885,7 +2894,7 @@ THREE.ColladaLoader = function () {
 
 		}
 
-		for ( var pCount = 0; pCount < pList.length; ++pCount ) {
+		for ( var pCount = 0; pCount < pList.length; ++ pCount ) {
 
 			var p = pList[ pCount ], i = 0;
 
@@ -2967,7 +2976,7 @@ THREE.ColladaLoader = function () {
 						source = sources[ input.source ];
 						numParams = source.accessor.params.length;
 
-						for ( var ndx = 0, len = vs.length; ndx < len; ndx++ ) {
+						for ( var ndx = 0, len = vs.length; ndx < len; ndx ++ ) {
 
 							ns.push( getConvertedVec3( source.data, vs[ ndx ] * numParams ) );
 
@@ -2993,7 +3002,7 @@ THREE.ColladaLoader = function () {
 						source = sources[ input.source ];
 						numParams = source.accessor.params.length;
 
-						for ( var ndx = 0, len = vs.length; ndx < len; ndx++ ) {
+						for ( var ndx = 0, len = vs.length; ndx < len; ndx ++ ) {
 
 							idx32 = vs[ ndx ] * numParams;
 							if ( ts[ input.set ] === undefined ) ts[ input.set ] = [ ];
@@ -3016,7 +3025,7 @@ THREE.ColladaLoader = function () {
 						source = sources[ input.source ];
 						numParams = source.accessor.params.length;
 
-						for ( var ndx = 0, len = vs.length; ndx < len; ndx++ ) {
+						for ( var ndx = 0, len = vs.length; ndx < len; ndx ++ ) {
 
 							idx32 = vs[ ndx ] * numParams;
 							cs.push( new THREE.Color().setRGB( source.data[ idx32 ], source.data[ idx32 + 1 ], source.data[ idx32 + 2 ] ) );
@@ -3035,9 +3044,9 @@ THREE.ColladaLoader = function () {
 
 				} else if ( vcount === 4 ) {
 
-					faces.push( new THREE.Face3( vs[0], vs[1], vs[3], [ns[0], ns[1], ns[3]], cs.length ? [cs[0], cs[1], cs[3]] : new THREE.Color() ) );
+					faces.push( new THREE.Face3( vs[0], vs[1], vs[3], [ ns[0], ns[1], ns[3]], cs.length ? [ cs[0], cs[1], cs[3]] : new THREE.Color() ) );
 
-					faces.push( new THREE.Face3( vs[1], vs[2], vs[3], [ns[1], ns[2], ns[3]], cs.length ? [cs[1], cs[2], cs[3]] : new THREE.Color() ) );
+					faces.push( new THREE.Face3( vs[1], vs[2], vs[3], [ ns[1], ns[2], ns[3]], cs.length ? [ cs[1], cs[2], cs[3]] : new THREE.Color() ) );
 
 				} else if ( vcount > 4 && options.subdivideFaces ) {
 
@@ -3050,7 +3059,11 @@ THREE.ColladaLoader = function () {
 
 						// FIXME: normals don't seem to be quite right
 
+<<<<<<< HEAD
 						faces.push( new THREE.Face3( vs[0], vs[k], vs[k+1], [ ns[0], ns[k++], ns[k] ], clr ) );
+=======
+						faces.push( new THREE.Face3( vs[0], vs[k], vs[k + 1], [ ns[0], ns[k ++], ns[k] ],  clr ) );
+>>>>>>> 4501d5a51d49e2e709930188a02af8d3dec5da61
 
 					}
 
@@ -3064,14 +3077,14 @@ THREE.ColladaLoader = function () {
 						face.daeMaterial = primitive.material;
 						geom.faces.push( face );
 
-						for ( k = 0; k < texture_sets.length; k++ ) {
+						for ( k = 0; k < texture_sets.length; k ++ ) {
 
 							uv = ts[ texture_sets[k] ];
 
 							if ( vcount > 4 ) {
 
 								// Grab the right UVs for the vertices in this face
-								uvArr = [ uv[0], uv[ndx+1], uv[ndx+2] ];
+								uvArr = [ uv[0], uv[ndx + 1], uv[ndx + 2] ];
 
 							} else if ( vcount === 4 ) {
 
@@ -3376,35 +3389,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;
 
-			}
+		}
 
 		//}
 
@@ -3671,7 +3684,7 @@ THREE.ColladaLoader = function () {
 
 		var keys = {
 			'diffuse':'map',
-			'ambient':'lightMap' ,
+			'ambient':'lightMap',
 			'specular':'specularMap',
 			'emission':'emissionMap',
 			'bump':'bumpMap',
@@ -3768,7 +3781,7 @@ THREE.ColladaLoader = function () {
 				case 'reflectivity':
 
 					props[ prop ] = this[ prop ];
-					if( props[ prop ] > 0.0 ) props['envMap'] = options.defaultEnvMap;
+					if ( props[ prop ] > 0.0 ) props['envMap'] = options.defaultEnvMap;
 					props['combine'] = THREE.MixOperation;	//mix regular shading with reflective component
 					break;
 
@@ -4061,7 +4074,7 @@ THREE.ColladaLoader = function () {
 
 	};
 
-	Effect.prototype.parseTechnique= function ( element ) {
+	Effect.prototype.parseTechnique = function ( element ) {
 
 		for ( var i = 0; i < element.childNodes.length; i ++ ) {
 
@@ -4110,7 +4123,7 @@ THREE.ColladaLoader = function () {
 
 	};
 
-	Effect.prototype.parseExtraTechnique= function ( element ) {
+	Effect.prototype.parseExtraTechnique = function ( element ) {
 
 		for ( var i = 0; i < element.childNodes.length; i ++ ) {
 
@@ -4394,7 +4407,7 @@ THREE.ColladaLoader = function () {
 			data = [];
 			ndx *= this.strideOut;
 
-			for ( var i = 0; i < this.strideOut; ++i ) {
+			for ( var i = 0; i < this.strideOut; ++ i ) {
 
 				data[ i ] = this.output[ ndx + i ];
 
@@ -4457,7 +4470,7 @@ THREE.ColladaLoader = function () {
 
 	Key.prototype.apply = function ( opt_sid ) {
 
-		for ( var i = 0; i < this.targets.length; ++i ) {
+		for ( var i = 0; i < this.targets.length; ++ i ) {
 
 			var target = this.targets[ i ];
 
@@ -4473,7 +4486,7 @@ THREE.ColladaLoader = function () {
 
 	Key.prototype.getTarget = function ( fullSid ) {
 
-		for ( var i = 0; i < this.targets.length; ++i ) {
+		for ( var i = 0; i < this.targets.length; ++ i ) {
 
 			if ( this.targets[ i ].sid === fullSid ) {
 
@@ -4489,7 +4502,7 @@ THREE.ColladaLoader = function () {
 
 	Key.prototype.hasTarget = function ( fullSid ) {
 
-		for ( var i = 0; i < this.targets.length; ++i ) {
+		for ( var i = 0; i < this.targets.length; ++ i ) {
 
 			if ( this.targets[ i ].sid === fullSid ) {
 
@@ -4525,7 +4538,7 @@ THREE.ColladaLoader = function () {
 
 					data = [];
 
-					for ( var j = 0; j < prevData.length; ++j ) {
+					for ( var j = 0; j < prevData.length; ++ j ) {
 
 						data[ j ] = prevData[ j ] + ( nextData[ j ] - prevData[ j ] ) * scale;
 
@@ -4763,7 +4776,7 @@ THREE.ColladaLoader = function () {
 
 							case 'quadratic_attenuation':
 								var f = parseFloat( child.textContent );
-								this.distance = f ? Math.sqrt( 1/f ) : 0;
+								this.distance = f ? Math.sqrt( 1 / f ) : 0;
 						}
 
 					}
@@ -4829,7 +4842,7 @@ THREE.ColladaLoader = function () {
 		this.joints = [];
 		this.links = [];
 
-		for (var i = 0; i < element.childNodes.length; i++ ) {
+		for (var i = 0; i < element.childNodes.length; i ++ ) {
 
 			var child = element.childNodes[ i ];
 			if ( child.nodeType != 1 ) continue;
@@ -4854,7 +4867,7 @@ THREE.ColladaLoader = function () {
 
 	KinematicsModel.prototype.parseCommon = function( element ) {
 
-		for (var i = 0; i < element.childNodes.length; i++ ) {
+		for (var i = 0; i < element.childNodes.length; i ++ ) {
 
 			var child = element.childNodes[ i ];
 			if ( child.nodeType != 1 ) continue;
@@ -4922,8 +4935,8 @@ THREE.ColladaLoader = function () {
 			max: max
 		};
 
-		var jointTypes = ['prismatic', 'revolute'];
-		for (var i = 0; i < jointTypes.length; i++ ) {
+		var jointTypes = [ 'prismatic', 'revolute' ];
+		for (var i = 0; i < jointTypes.length; i ++ ) {
 
 			var type = jointTypes[ i ];
 
@@ -4965,7 +4978,7 @@ THREE.ColladaLoader = function () {
 		this.transforms = [];
 		this.attachments = [];
 
-		for (var i = 0; i < element.childNodes.length; i++ ) {
+		for (var i = 0; i < element.childNodes.length; i ++ ) {
 
 			var child = element.childNodes[ i ];
 			if ( child.nodeType != 1 ) continue;
@@ -5008,7 +5021,7 @@ THREE.ColladaLoader = function () {
 		this.joint = element.getAttribute('joint').split('/').pop();
 		this.links = [];
 
-		for (var i = 0; i < element.childNodes.length; i++ ) {
+		for (var i = 0; i < element.childNodes.length; i ++ ) {
 
 			var child = element.childNodes[ i ];
 			if ( child.nodeType != 1 ) continue;
@@ -5185,7 +5198,7 @@ THREE.ColladaLoader = function () {
 		var parts = f.toString().split( '.' );
 		parts[ 1 ] = parts.length > 1 ? parts[ 1 ].substr( 0, num ) : "0";
 
-		while( parts[ 1 ].length < num ) {
+		while ( parts[ 1 ].length < num ) {
 
 			parts[ 1 ] += '0';
 
@@ -5411,7 +5424,7 @@ THREE.ColladaLoader = function () {
 
 		if ( index > -1 && index < 3 ) {
 
-			var members = ['X', 'Y', 'Z'],
+			var members = [ 'X', 'Y', 'Z' ],
 				indices = { X: 0, Y: 1, Z: 2 };
 
 			index = getConvertedMember( members[ index ] );

+ 13 - 13
examples/js/loaders/DDSLoader.js

@@ -70,21 +70,21 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) {
 	}
 
 	function loadARGBMip( buffer, dataOffset, width, height ) {
-		var dataLength = width*height*4;
+		var dataLength = width * height * 4;
 		var srcBuffer = new Uint8Array( buffer, dataOffset, dataLength );
 		var byteArray = new Uint8Array( dataLength );
 		var dst = 0;
 		var src = 0;
-		for ( var y = 0; y < height; y++ ) {
-			for ( var x = 0; x < width; x++ ) {
-				var b = srcBuffer[src]; src++;
-				var g = srcBuffer[src]; src++;
-				var r = srcBuffer[src]; src++;
-				var a = srcBuffer[src]; src++;
-				byteArray[dst] = r; dst++;	//r
-				byteArray[dst] = g; dst++;	//g
-				byteArray[dst] = b; dst++;	//b
-				byteArray[dst] = a; dst++;	//a
+		for ( var y = 0; y < height; y ++ ) {
+			for ( var x = 0; x < width; x ++ ) {
+				var b = srcBuffer[src]; src ++;
+				var g = srcBuffer[src]; src ++;
+				var r = srcBuffer[src]; src ++;
+				var a = srcBuffer[src]; src ++;
+				byteArray[dst] = r; dst ++;	//r
+				byteArray[dst] = g; dst ++;	//g
+				byteArray[dst] = b; dst ++;	//b
+				byteArray[dst] = a; dst ++;	//a
 			}
 		}
 		return byteArray;
@@ -166,7 +166,7 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) {
 
 		default:
 
-			if( header[off_RGBBitCount] ==32 
+			if ( header[off_RGBBitCount] == 32 
 				&& header[off_RBitMask]&0xff0000
 				&& header[off_GBitMask]&0xff00 
 				&& header[off_BBitMask]&0xff
@@ -208,7 +208,7 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) {
 
 		for ( var i = 0; i < dds.mipmapCount; i ++ ) {
 
-			if( isRGBAUncompressed ) {
+			if ( isRGBAUncompressed ) {
 				var byteArray = loadARGBMip( buffer, dataOffset, width, height );
 				var dataLength = byteArray.length;
 			} else {

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

@@ -121,8 +121,8 @@ THREE.MTLLoader.MaterialCreator = function( baseUrl, options ) {
 	this.materialsArray = [];
 	this.nameLookup = {};
 
-	this.side = ( this.options && this.options.side )? this.options.side: THREE.FrontSide;
-	this.wrap = ( this.options && this.options.wrap )? this.options.wrap: THREE.RepeatWrapping;
+	this.side = ( this.options && this.options.side ) ? this.options.side : THREE.FrontSide;
+	this.wrap = ( this.options && this.options.wrap ) ? this.options.wrap : THREE.RepeatWrapping;
 
 };
 
@@ -426,7 +426,7 @@ THREE.MTLLoader.ensurePowerOfTwo_ = function ( image ) {
 
 THREE.MTLLoader.nextHighestPowerOfTwo_ = function( x ) {
 
-	--x;
+	-- x;
 
 	for ( var i = 1; i < 32; i <<= 1 ) {
 

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 3
examples/js/loaders/PDBLoader.js


+ 10 - 10
examples/js/loaders/PLYLoader.js

@@ -80,7 +80,7 @@ THREE.PLYLoader.prototype = {
 
 		var array_buffer = new Uint8Array(buf);
 		var str = '';
-		for(var i = 0; i < buf.byteLength; i++) {
+		for (var i = 0; i < buf.byteLength; i ++) {
 			str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian
 		}
 
@@ -88,7 +88,7 @@ THREE.PLYLoader.prototype = {
 
 	},
 
-	isASCII: function( data ){
+	isASCII: function( data ) {
 
 		var header = this.parseHeader( this.bin2str( data ) );
 
@@ -167,7 +167,7 @@ THREE.PLYLoader.prototype = {
 			lineType = lineValues.shift()
 			line = lineValues.join(" ")
 
-			switch( lineType ) {
+			switch ( lineType ) {
 
 			case "format":
 
@@ -224,7 +224,7 @@ THREE.PLYLoader.prototype = {
 
 	parseASCIINumber: function ( n, type ) {
 
-		switch( type ) {
+		switch ( type ) {
 
 		case 'char': case 'uchar': case 'short': case 'ushort': case 'int': case 'uint':
 		case 'int8': case 'uint8': case 'int16': case 'uint16': case 'int32': case 'uint32':
@@ -301,7 +301,7 @@ THREE.PLYLoader.prototype = {
 
 			if ( currentElementCount >= header.elements[currentElement].count ) {
 
-				currentElement++;
+				currentElement ++;
 				currentElementCount = 0;
 
 			}
@@ -310,7 +310,7 @@ THREE.PLYLoader.prototype = {
 
 			this.handleElement( geometry, header.elements[currentElement].name, element );
 
-			currentElementCount++;
+			currentElementCount ++;
 
 		}
 
@@ -385,7 +385,7 @@ THREE.PLYLoader.prototype = {
 
 	binaryRead: function ( dataview, at, type, little_endian ) {
 
-		switch( type ) {
+		switch ( type ) {
 
 			// corespondences for non-specific length types here match rply:
 		case 'int8':		case 'char':	 return [ dataview.getInt8( at ), 1 ];
@@ -419,13 +419,13 @@ THREE.PLYLoader.prototype = {
 
 				var list = [];
 
-				result = this.binaryRead( dataview, at+read, properties[i].countType, little_endian );
+				result = this.binaryRead( dataview, at + read, properties[i].countType, little_endian );
 				var n = result[0];
 				read += result[1];
 
 				for ( j = 0; j < n; j ++ ) {
 
-					result = this.binaryRead( dataview, at+read, properties[i].itemType, little_endian );
+					result = this.binaryRead( dataview, at + read, properties[i].itemType, little_endian );
 					list.push( result[0] );
 					read += result[1];
 
@@ -435,7 +435,7 @@ THREE.PLYLoader.prototype = {
 
 			} else {
 
-				result = this.binaryRead( dataview, at+read, properties[i].type, little_endian );
+				result = this.binaryRead( dataview, at + read, properties[i].type, little_endian );
 				element[ properties[i].name ] = result[0];
 				read += result[1];
 

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

@@ -28,11 +28,11 @@ THREE.PVRLoader.parse = function ( buffer, loadMipmaps ) {
 	};
 
 	// PVR v3
-	if( header[0] === 0x03525650 ) {
+	if ( header[0] === 0x03525650 ) {
 		return THREE.PVRLoader._parseV3( pvrDatas );
 	} 
 	// PVR v2
-	else if( header[11] === 0x21525650) {
+	else if ( header[11] === 0x21525650) {
 		return THREE.PVRLoader._parseV2( pvrDatas );
 
 	} else {
@@ -55,7 +55,7 @@ THREE.PVRLoader._parseV3 = function ( pvrDatas ) {
 		numFaces      =  header[10],
 		numMipmaps    =  header[11];
 
-	switch( pixelFormat ) {
+	switch ( pixelFormat ) {
 		case 0 : // PVRTC 2bpp RGB
 			bpp = 2;
 			format = THREE.RGB_PVRTC_2BPPV1_Format;
@@ -73,20 +73,20 @@ THREE.PVRLoader._parseV3 = function ( pvrDatas ) {
 			format = THREE.RGBA_PVRTC_4BPPV1_Format;
 			break;
 		default :
-			throw new Error( "pvrtc - unsupported PVR format "+pixelFormat);
+			throw new Error( "pvrtc - unsupported PVR format " + pixelFormat);
 	}
 
 	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 ) {
@@ -123,28 +123,28 @@ THREE.PVRLoader._parseV2 = function ( pvrDatas ) {
 		format = _hasAlpha ? THREE.RGBA_PVRTC_4BPPV1_Format : THREE.RGB_PVRTC_4BPPV1_Format;
 		bpp = 4;
 	}
-	else if( formatFlags === PVRTC_2) {
+	else if ( formatFlags === PVRTC_2) {
 		format = _hasAlpha ? THREE.RGBA_PVRTC_2BPPV1_Format : THREE.RGB_PVRTC_2BPPV1_Format;
 		bpp = 2;
 	}
 	else
-		throw new Error( "pvrtc - unknown format "+formatFlags);
+		throw new Error( "pvrtc - unknown format " + formatFlags);
 	
 
 
 	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 );
 
 };
 
@@ -195,7 +195,7 @@ THREE.PVRLoader._extract = function ( pvrDatas ) {
 
 
 
-	if( bpp === 2 ){
+	if ( bpp === 2 ) {
 		blockWidth = 8;
 		blockHeight = 4;
 	} else {
@@ -243,7 +243,7 @@ THREE.PVRLoader._extract = function ( pvrDatas ) {
 
 		}
 
-		mipLevel++;
+		mipLevel ++;
 
 	}
 

+ 33 - 33
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||''));
 			}
@@ -60,13 +60,13 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
 			lineLimit = !lineLimit ? 1024 : lineLimit;
 			var p = buffer.pos,
 				i = -1, len = 0, s = '', chunkSize = 128,
-				chunk = String.fromCharCode.apply(null, new Uint16Array( buffer.subarray( p, p+chunkSize ) ) )
+				chunk = String.fromCharCode.apply(null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) )
 			;
-			while ( (0 > (i=chunk.indexOf( NEWLINE ))) && (len < lineLimit) && (p < buffer.byteLength) ) {
+			while ( (0 > (i = chunk.indexOf( NEWLINE ))) && (len < lineLimit) && (p < buffer.byteLength) ) {
 
 				s += chunk; len += chunk.length;
 				p += chunkSize;
-				chunk += String.fromCharCode.apply(null, new Uint16Array( buffer.subarray( p, p+chunkSize ) ) );
+				chunk += String.fromCharCode.apply(null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) );
 
 			}
 
@@ -78,7 +78,7 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
 					else if (byteCode > 0x7ff && byteCode <= 0xffff) byteLen += 2;
 					if (byteCode >= 0xDC00 && byteCode <= 0xDFFF) i--; //trail surrogate
 				}*/
-				if ( false !== consume ) buffer.pos += len+i+1;
+				if ( false !== consume ) buffer.pos += len + i + 1;
 				return s + chunk.slice(0, i);
 
 			}
@@ -122,11 +122,11 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
 				}
 			;
 
-			if ( buffer.pos >= buffer.byteLength || !( line=fgets( buffer ) ) ) {
+			if ( buffer.pos >= buffer.byteLength || !( line = fgets( buffer ) ) ) {
 				return rgbe_error( rgbe_read_error, "no header found" );
 			}
 			/* if you want to require the magic token then uncomment the next line */
-			if ( !(match=line.match(magic_token_re)) ) {
+			if ( !(match = line.match(magic_token_re)) ) {
 				return rgbe_error( rgbe_format_error, "bad initial token" );
 			}
 			header.valid |= RGBE_VALID_PROGRAMTYPE;
@@ -144,17 +144,17 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
 					continue; // comment line
 				}
 
-				if ( match=line.match(gamma_re) ) {
+				if ( match = line.match(gamma_re) ) {
 					header.gamma = parseFloat(match[1], 10);
 				}
-				if ( match=line.match(exposure_re) ) {
+				if ( match = line.match(exposure_re) ) {
 					header.exposure = parseFloat(match[1], 10);
 				}
-				if ( match=line.match(format_re) ) {
+				if ( match = line.match(format_re) ) {
 					header.valid |= RGBE_VALID_FORMAT;
 					header.format = match[1];//'32-bit_rle_rgbe';
 				}
-				if ( match=line.match(dimensions_re) ) {
+				if ( match = line.match(dimensions_re) ) {
 					header.valid |= RGBE_VALID_DIMENSIONS;
 					header.height = parseInt(match[1], 10);
 					header.width = parseInt(match[2], 10);
@@ -193,29 +193,29 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
 				return rgbe_error(rgbe_format_error, "wrong scanline width");
 			}
 
-			data_rgba = new Uint8Array( 4*w*h );
+			data_rgba = new Uint8Array( 4 * w * h );
 
 			if ( !data_rgba || !data_rgba.length ) {
 				return rgbe_error(rgbe_memory_error, "unable to allocate buffer space");
 			}
 
-			offset = 0; pos = 0; ptr_end = 4*scanline_width;
+			offset = 0; pos = 0; ptr_end = 4 * scanline_width;
 			rgbeStart = new Uint8Array( 4 );
 			scanline_buffer = new Uint8Array( ptr_end );
 
 			// read in each successive scanline
-			while( (num_scanlines > 0) && (pos < buffer.byteLength) ) {
+			while ( (num_scanlines > 0) && (pos < buffer.byteLength) ) {
 
-				if ( pos+4 > buffer.byteLength ) {
+				if ( pos + 4 > buffer.byteLength ) {
 
 					return rgbe_error( rgbe_read_error );
 
 				}
 
-				rgbeStart[0] = buffer[pos++];
-				rgbeStart[1] = buffer[pos++];
-				rgbeStart[2] = buffer[pos++];
-				rgbeStart[3] = buffer[pos++];
+				rgbeStart[0] = buffer[pos ++];
+				rgbeStart[1] = buffer[pos ++];
+				rgbeStart[2] = buffer[pos ++];
+				rgbeStart[3] = buffer[pos ++];
 
 				if ( (2 != rgbeStart[0]) || (2 != rgbeStart[1]) || (((rgbeStart[2]<<8) | rgbeStart[3]) != scanline_width) ) {
 
@@ -228,11 +228,11 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
 				ptr = 0;
 				while ( (ptr < ptr_end) && (pos < buffer.byteLength) ) {
 
-					count = buffer[ pos++ ];
+					count = buffer[ pos ++ ];
 					isEncodedRun = count > 128;
 					if ( isEncodedRun ) count -= 128;
 
-					if ( (0 === count) || (ptr+count > ptr_end) ) {
+					if ( (0 === count) || (ptr + count > ptr_end) ) {
 
 						return rgbe_error(rgbe_format_error, "bad scanline data");
 
@@ -240,15 +240,15 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
 
 					if ( isEncodedRun ) {
 						// a (encoded) run of the same value
-						byteValue = buffer[ pos++ ];
-						for (i=0; i<count; i++) {
-							scanline_buffer[ ptr++ ] = byteValue;
+						byteValue = buffer[ pos ++ ];
+						for (i = 0; i < count; i ++) {
+							scanline_buffer[ ptr ++ ] = byteValue;
 						}
 						//ptr += count;
 
 					} else {
 						// a literal-run
-						scanline_buffer.set( buffer.subarray(pos, pos+count), ptr );
+						scanline_buffer.set( buffer.subarray(pos, pos + count), ptr );
 						ptr += count; pos += count;
 					}
 				}
@@ -257,19 +257,19 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
 				// now convert data from buffer into rgba
 				// first red, then green, then blue, then exponent (alpha)
 				l = scanline_width; //scanline_buffer.byteLength;
-				for (i=0; i<l; i++) {
+				for (i = 0; i < l; i ++) {
 					off = 0;
-					data_rgba[offset] = scanline_buffer[i+off];
+					data_rgba[offset] = scanline_buffer[i + off];
 					off += scanline_width; //1;
-					data_rgba[offset+1] = scanline_buffer[i+off];
+					data_rgba[offset + 1] = scanline_buffer[i + off];
 					off += scanline_width; //1;
-					data_rgba[offset+2] = scanline_buffer[i+off];
+					data_rgba[offset + 2] = scanline_buffer[i + off];
 					off += scanline_width; //1;
-					data_rgba[offset+3] = scanline_buffer[i+off];
+					data_rgba[offset + 3] = scanline_buffer[i + off];
 					offset += 4;
 				}
 
-				num_scanlines--;
+				num_scanlines --;
 			}
 
 			return data_rgba;

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

@@ -59,7 +59,7 @@ THREE.STLLoader.prototype = {
 			var expect, face_size, n_faces, reader;
 			reader = new DataView( binData );
 			face_size = (32 / 8 * 3) + ((32 / 8 * 3) * 3) + (16 / 8);
-			n_faces = reader.getUint32(80,true);
+			n_faces = reader.getUint32(80, true);
 			expect = 80 + (32 / 8) + (n_faces * face_size);
 			
 			if ( expect === reader.byteLength ) {
@@ -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;
@@ -231,10 +231,10 @@ THREE.STLLoader.prototype = {
 
 	ensureString: function ( buf ) {
 
-		if (typeof buf !== "string"){
+		if (typeof buf !== "string") {
 			var array_buffer = new Uint8Array(buf);
 			var str = '';
-			for(var i = 0; i < buf.byteLength; i++) {
+			for (var i = 0; i < buf.byteLength; i ++) {
 				str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian
 			}
 			return str;
@@ -246,9 +246,9 @@ THREE.STLLoader.prototype = {
 
 	ensureBinary: function ( buf ) {
 
-		if (typeof buf === "string"){
+		if (typeof buf === "string") {
 			var array_buffer = new Uint8Array(buf.length);
-			for(var i = 0; i < buf.length; i++) {
+			for (var i = 0; i < buf.length; i ++) {
 				array_buffer[i] = buf.charCodeAt(i) & 0xff; // implicitly assumes little-endian
 			}
 			return array_buffer.buffer || array_buffer;
@@ -260,9 +260,9 @@ THREE.STLLoader.prototype = {
 
 };
 
-if ( typeof DataView === 'undefined'){
+if ( typeof DataView === 'undefined') {
 
-	DataView = function(buffer, byteOffset, byteLength){
+	DataView = function(buffer, byteOffset, byteLength) {
 
 		this.buffer = buffer;
 		this.byteOffset = byteOffset || 0;
@@ -273,12 +273,12 @@ if ( typeof DataView === 'undefined'){
 
 	DataView.prototype = {
 
-		_getCharCodes:function(buffer,start,length){
+		_getCharCodes:function(buffer,start,length) {
 			start = start || 0;
 			length = length || buffer.length;
 			var end = start + length;
 			var codes = [];
-			for (var i = start; i < end; i++) {
+			for (var i = start; i < end; i ++) {
 				codes.push(buffer.charCodeAt(i) & 0xff);
 			}
 			return codes;
@@ -325,7 +325,7 @@ if ( typeof DataView === 'undefined'){
 
 			}
 
-			if (this.isString){
+			if (this.isString) {
 
 				result = this._getCharCodes(this.buffer, byteOffset, byteOffset + length);
 

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

@@ -57,7 +57,7 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
 
 	function tgaCheckHeader( header ) {
 
-		switch( header.image_type ) {
+		switch ( header.image_type ) {
 
 			// Check indexed type
 			case TGA_TYPE_INDEXED:
@@ -83,12 +83,12 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
 
 			// Invalid type ?
 			default:
-				console.error('THREE.TGALoader.parse.tgaCheckHeader: Invalid type " '+ header.image_type + '"');
+				console.error('THREE.TGALoader.parse.tgaCheckHeader: Invalid type " ' + header.image_type + '"');
 
 		}
 
 		// Check image width and height
-		if ( header.width <= 0 || header.height <=0 ) {
+		if ( header.width <= 0 || header.height <= 0 ) {
 			console.error( 'THREE.TGALoader.parse.tgaCheckHeader: Invalid image size' );
 		}
 
@@ -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 ) {
@@ -171,19 +171,19 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
 			var pixels = new Uint8Array(pixel_size);
 
 			while (shift < pixel_total) {
-				c     = data[offset++];
+				c     = data[offset ++];
 				count = (c & 0x7f) + 1;
 
 				// RLE pixels.
 				if (c & 0x80) {
 					// Bind pixel tmp array
-					for (i = 0; i < pixel_size; ++i) {
-							pixels[i] = data[offset++];
+					for (i = 0; i < pixel_size; ++ i) {
+						pixels[i] = data[offset ++];
 					}
 
 					// Copy pixel array
-					for (i = 0; i < count; ++i) {
-							pixel_data.set(pixels, shift + i * pixel_size);
+					for (i = 0; i < count; ++ i) {
+						pixel_data.set(pixels, shift + i * pixel_size);
 					}
 
 					shift += pixel_size * count;
@@ -191,8 +191,8 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
 				} else {
 					// Raw pixels.
 					count *= pixel_size;
-					for (i = 0; i < count; ++i) {
-							pixel_data[shift + i] = data[offset++];
+					for (i = 0; i < count; ++ i) {
+						pixel_data[shift + i] = data[offset ++];
 					}
 					shift += count;
 				}
@@ -214,10 +214,10 @@ 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++) {
+			for (x = x_start; x !== x_end; x += x_step, i ++) {
 				color = image[i];
 				imageData[(x + width * y) * 4 + 3] = 255;
 				imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
@@ -291,7 +291,7 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
 		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++) {
+			for (x = x_start; x !== x_end; x += x_step, i ++) {
 				color = image[i];
 				imageData[(x + width * y) * 4 + 0] = color;
 				imageData[(x + width * y) * 4 + 1] = color;
@@ -332,7 +332,7 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
 			y_end,
 			data = new Uint8Array(width * height * 4);
 
-		switch( (header.flags & TGA_ORIGIN_MASK) >> TGA_ORIGIN_SHIFT ) {
+		switch ( (header.flags & TGA_ORIGIN_MASK) >> TGA_ORIGIN_SHIFT ) {
 			default:
 			case TGA_ORIGIN_UL:
 				x_start = 0;
@@ -374,7 +374,7 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
 
 		if ( use_grey ) {
 
-			switch( header.pixel_size ) {
+			switch ( header.pixel_size ) {
 				case 8:
 					tgaGetImageDataGrey8bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image );
 					break;
@@ -388,7 +388,7 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
 
 		} else {
 
-			switch( header.pixel_size ) {
+			switch ( header.pixel_size ) {
 				case 8:
 					tgaGetImageData8bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image, palette );
 					break;

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

@@ -50,15 +50,15 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray
 	j = 0;
 	offset = 0;
 
-	for( i = offset; i < end; i += stride ) {
+	for ( i = offset; i < end; i += stride ) {
 
 		x = attribArray[ i ];
 		y = attribArray[ i + 1 ];
 		z = attribArray[ i + 2 ];
 
-		positions[ j++ ] = x;
-		positions[ j++ ] = y;
-		positions[ j++ ] = z;
+		positions[ j ++ ] = x;
+		positions[ j ++ ] = y;
+		positions[ j ++ ] = z;
 
 	}
 
@@ -67,13 +67,13 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray
 	j = 0;
 	offset = 3;
 
-	for( i = offset; i < end; i += stride ) {
+	for ( i = offset; i < end; i += stride ) {
 
 		u = attribArray[ i ];
 		v = attribArray[ i + 1 ];
 
-		uvs[ j++ ] = u;
-		uvs[ j++ ] = v;
+		uvs[ j ++ ] = u;
+		uvs[ j ++ ] = v;
 
 	}
 
@@ -82,24 +82,24 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray
 	j = 0;
 	offset = 5;
 
-	for( i = offset; i < end; i += stride ) {
+	for ( i = offset; i < end; i += stride ) {
 
 		x = attribArray[ i ];
 		y = attribArray[ i + 1 ];
 		z = attribArray[ i + 2 ];
 
-		normals[ j++ ] = x;
-		normals[ j++ ] = y;
-		normals[ j++ ] = z;
+		normals[ j ++ ] = x;
+		normals[ j ++ ] = y;
+		normals[ j ++ ] = z;
 
 	}
 
-    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();
 
@@ -133,8 +133,8 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray
 
 var DEFAULT_DECODE_PARAMS = {
 
-    decodeOffsets: [-4095, -4095, -4095, 0, 0, -511, -511, -511],
-    decodeScales: [1/8191, 1/8191, 1/8191, 1/1023, 1/1023, 1/1023, 1/1023, 1/1023]
+    decodeOffsets: [ -4095, -4095, -4095, 0, 0, -511, -511, -511 ],
+    decodeScales: [ 1 / 8191, 1 / 8191, 1 / 8191, 1 / 1023, 1 / 1023, 1 / 1023, 1 / 1023, 1 / 1023 ]
 
     // TODO: normal decoding? (see walt.js)
     // needs to know: input, output (from vertex format!)
@@ -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))) +
-                        attribsOutFixed[stride*i0 + j] +
-                        attribsOutFixed[stride*i1 + j] -
-                        attribsOutFixed[stride*i2 + j];
+					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 ] );
 
-    }
+	}
 }

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

@@ -123,7 +123,7 @@ THREE.VRMLLoader.prototype = {
 
 				var coord = [ ], aColor, bColor, t = 1, A = {}, B = {}, applyColor = false, colorIndex;
 
-				for ( var k = 0; k < angles.length; k++ ) {
+				for ( var k = 0; k < angles.length; k ++ ) {
 
 					var vec = { };
 
@@ -137,19 +137,19 @@ THREE.VRMLLoader.prototype = {
 				}
 
 				// painting the colors on the faces
-				for ( var i = 0; i < geometry.faces.length ; i++ ) {
+				for ( var i = 0; i < geometry.faces.length ; i ++ ) {
 
 					f  = geometry.faces[ i ];
 
 					n = ( f instanceof THREE.Face3 ) ? 3 : 4;
 
-					for ( var j = 0; j < n; j++ ) {
+					for ( var j = 0; j < n; j ++ ) {
 
 						vertexIndex = f[ faceIndices[ j ] ];
 
 						p = geometry.vertices[ vertexIndex ];
 
-						for ( var index = 0; index < colors.length; index++ ) {
+						for ( var index = 0; index < colors.length; index ++ ) {
 
 							// linear interpolation between aColor and bColor, calculate proportion
 							// A is previous point (angle)
@@ -160,8 +160,8 @@ THREE.VRMLLoader.prototype = {
 
 							} else {
 
-								A.x = coord[ index-1 ].x;
-								A.y = coord[ index-1 ].y;
+								A.x = coord[ index - 1 ].x;
+								A.y = coord[ index - 1 ].y;
 
 							}
 
@@ -188,7 +188,7 @@ THREE.VRMLLoader.prototype = {
 								}
 
 							} else if ( undefined === f.vertexColors[ j ] ) {
-								colorIndex = directionIsDown ? colors.length -1 : 0;
+								colorIndex = directionIsDown ? colors.length - 1 : 0;
 								f.vertexColors[ j ] = colors[ colorIndex ];
 
 							}
@@ -250,7 +250,7 @@ THREE.VRMLLoader.prototype = {
 					if (parts.length > 0) {
 						index = [];
 
-						for (var ind = 0;ind < parts.length; ind++) {
+						for (var ind = 0; ind < parts.length; ind ++) {
 
 							// the part should either be positive integer or -1
 							if (!/(-?\d+)/.test( parts[ind]) ) {
@@ -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
@@ -301,7 +301,7 @@ THREE.VRMLLoader.prototype = {
 					// the parts hold the angles as strings
 					if ( parts.length > 0 ) {
 
-						for ( var ind = 0;ind < parts.length; ind++ ) {
+						for ( var ind = 0; ind < parts.length; ind ++ ) {
 
 							// the part should be a float
 							if ( ! float_pattern.test( parts[ind] ) ) {
@@ -321,7 +321,7 @@ THREE.VRMLLoader.prototype = {
 
 				} else if (this.isRecordingColors) {
 
-					while( null !== ( parts = float3_pattern.exec(line) ) ) {
+					while ( null !== ( parts = float3_pattern.exec(line) ) ) {
 
 						color = {
 							r: parseFloat(parts[1]),
@@ -339,7 +339,7 @@ THREE.VRMLLoader.prototype = {
 						node[this.recordingFieldname] = this.colors;
 					}
 
-				} else if ( parts[parts.length -1] !== 'NULL' && fieldName !== 'children') {
+				} else if ( parts[parts.length - 1] !== 'NULL' && fieldName !== 'children') {
 
 					switch (fieldName) {
 
@@ -466,7 +466,7 @@ THREE.VRMLLoader.prototype = {
 
 					if ( matches = /([^\s]*){1}\s?{/.exec( line ) ) { // first subpattern should match the Node name
 
-						var block = { 'nodeType' : matches[1], 'string': line, 'parent': current, 'children': [],'comment' : comment};
+						var block = { 'nodeType' : matches[1], 'string': line, 'parent': current, 'children': [],'comment' : comment };
 						current.children.push( block );
 						current = block;
 
@@ -528,7 +528,7 @@ THREE.VRMLLoader.prototype = {
 									parent.material.side = THREE.DoubleSide;
 								}
 
-							} else if (defineKey){
+							} else if (defineKey) {
 
 								var object = defines[ defineKey ].clone();
 								parent.add( object );
@@ -660,7 +660,7 @@ THREE.VRMLLoader.prototype = {
 
 						var indexes;
 
-						for ( var i = 0, j = data.children.length; i < j; i++ ) {
+						for ( var i = 0, j = data.children.length; i < j; i ++ ) {
 
 							var child = data.children[ i ];
 
@@ -668,7 +668,7 @@ THREE.VRMLLoader.prototype = {
 
 							if ( 'Coordinate' === child.nodeType ) {
 
-								for ( var k = 0, l = child.points.length; k < l; k++ ) {
+								for ( var k = 0, l = child.points.length; k < l; k ++ ) {
 
 									var point = child.points[ k ];
 
@@ -684,7 +684,7 @@ THREE.VRMLLoader.prototype = {
 						var skip = 0;
 
 						// read this: http://math.hws.edu/eck/cs424/notes2013/16_Threejs_Advanced.html
-						for ( var i = 0, j = data.coordIndex.length; i < j; i++ ) {
+						for ( var i = 0, j = data.coordIndex.length; i < j; i ++ ) {
 
 							indexes = data.coordIndex[i];
 
@@ -694,7 +694,7 @@ THREE.VRMLLoader.prototype = {
 							// todo: this is the time to check if the faces are ordered ccw or not (cw)
 
 							// Face3 only works with triangles, but IndexedFaceSet allows shapes with more then three vertices, build them of triangles
-							while ( indexes.length >= 3 && skip < ( indexes.length -2 ) ) {
+							while ( indexes.length >= 3 && skip < ( indexes.length - 2 ) ) {
 
 								var face = new THREE.Face3(
 									indexes[0],
@@ -704,7 +704,7 @@ THREE.VRMLLoader.prototype = {
 									// todo: pass in the color, if a color index is present
 								);
 
-								skip++;
+								skip ++;
 
 								geometry.faces.push( face );
 

+ 1 - 1
examples/js/loaders/ctm/CTMLoader.js

@@ -126,7 +126,7 @@ THREE.CTMLoader.prototype.load = function( url, callback, parameters ) {
 							scope.createModel( ctmFile, callback );
 
 							var e = Date.now();
-							console.log( "model load time [worker]: " + (e-e1) + " ms, total: " + (e-s));
+							console.log( "model load time [worker]: " + (e - e1) + " ms, total: " + (e - s));
 
 						}
 

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

@@ -45,617 +45,617 @@ CTM.Flags = {
   NORMALS: 0x00000001
 };
 
-CTM.File = function(stream){
-  this.load(stream);
+CTM.File = function(stream) {
+	this.load(stream);
 };
 
-CTM.File.prototype.load = function(stream){
-  this.header = new CTM.FileHeader(stream);
+CTM.File.prototype.load = function(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;
+CTM.File.prototype.getReader = function() {
+	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();
+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();
 };
 
-CTM.FileHeader.prototype.hasNormals = function(){
-  return this.flags & CTM.Flags.NORMALS;
+CTM.FileHeader.prototype.hasNormals = function() {
+	return this.flags & CTM.Flags.NORMALS;
 };
 
-CTM.FileBody = function(header){
-  var i = header.triangleCount * 3,
+CTM.FileBody = function(header) {
+	var i = header.triangleCount * 3,
       v = header.vertexCount * 3,
-      n = header.hasNormals()? header.vertexCount * 3: 0,
+      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();
+		}
+	}
+};
+
+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();
   
-  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 = function() {
 };
 
-CTM.ReaderRAW.prototype.read = function(stream, body){
-  this.readIndices(stream, body.indices);
-  this.readVertices(stream, body.vertices);
+CTM.ReaderRAW.prototype.read = function(stream, body) {
+	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);
+CTM.ReaderRAW.prototype.readIndices = function(stream, indices) {
+	stream.readInt32(); //magic "INDX"
+	stream.readArrayInt32(indices);
 };
 
-CTM.ReaderRAW.prototype.readVertices = function(stream, vertices){
-  stream.readInt32(); //magic "VERT"
-  stream.readArrayFloat32(vertices);
+CTM.ReaderRAW.prototype.readVertices = function(stream, vertices) {
+	stream.readInt32(); //magic "VERT"
+	stream.readArrayFloat32(vertices);
 };
 
-CTM.ReaderRAW.prototype.readNormals = function(stream, normals){
-  stream.readInt32(); //magic "NORM"
-  stream.readArrayFloat32(normals);
+CTM.ReaderRAW.prototype.readNormals = function(stream, 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"
+CTM.ReaderRAW.prototype.readUVMaps = function(stream, uvMaps) {
+	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"
+CTM.ReaderRAW.prototype.readAttrMaps = function(stream, attrMaps) {
+	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 = function() {
 };
 
-CTM.ReaderMG1.prototype.read = function(stream, body){
-  this.readIndices(stream, body.indices);
-  this.readVertices(stream, body.vertices);
+CTM.ReaderMG1.prototype.read = function(stream, body) {
+	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);
-  }
-};
-
-CTM.ReaderMG1.prototype.readIndices = function(stream, indices){
-  stream.readInt32(); //magic "INDX"
-  stream.readInt32(); //packed size
+	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
   
-  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
+CTM.ReaderMG1.prototype.readVertices = function(stream, vertices) {
+	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
+CTM.ReaderMG1.prototype.readNormals = function(stream, normals) {
+	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"
+CTM.ReaderMG1.prototype.readUVMaps = function(stream, uvMaps) {
+	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"
+CTM.ReaderMG1.prototype.readAttrMaps = function(stream, attrMaps) {
+	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 = function() {
 };
 
-CTM.ReaderMG2.prototype.read = function(stream, body){
-  this.MG2Header = new CTM.FileMG2Header(stream);
+CTM.ReaderMG2.prototype.read = function(stream, body) {
+	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);
-  }
-};
-
-CTM.ReaderMG2.prototype.readVertices = function(stream, vertices){
-  stream.readInt32(); //magic "VERT"
-  stream.readInt32(); //packed size
-
-  var interleaved = new CTM.InterleavedStream(vertices, 3);
-  LZMA.decompress(stream, stream, interleaved, interleaved.data.length);
+	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
+
+	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
+CTM.ReaderMG2.prototype.readGridIndices = function(stream, vertices) {
+	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
+CTM.ReaderMG2.prototype.readIndices = function(stream, indices) {
+	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
+CTM.ReaderMG2.prototype.readNormals = function(stream, body) {
+	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"
+CTM.ReaderMG2.prototype.readUVMaps = function(stream, uvMaps) {
+	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"
+CTM.ReaderMG2.prototype.readAttrMaps = function(stream, attrMaps) {
+	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.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];
+		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];
     
-    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];
-  }
+CTM.restoreGridIndices = function(gridIndices, len) {
+	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,
+CTM.restoreVertices = function(vertices, grid, gridIndices, precision) {
+	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,
+CTM.restoreNormals = function(normals, smooth, precision) {
+	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,
+CTM.restoreMap = function(map, count, precision) {
+	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),
+CTM.calcSmoothNormals = function(indices, vertices) {
+	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),
+CTM.isLittleEndian = (function() {
+	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;
+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;
 };
 
-CTM.InterleavedStream.prototype.writeByte = function(value){
-  this.data[this.offset] = value;
+CTM.InterleavedStream.prototype.writeByte = function(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;
+CTM.Stream = function(data) {
+	this.data = data;
+	this.offset = 0;
 };
 
 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;
+CTM.Stream.prototype.readByte = function() {
+	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);
+CTM.Stream.prototype.readInt32 = function() {
+	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;
+CTM.Stream.prototype.readFloat32 = function() {
+	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();
+CTM.Stream.prototype.readString = function() {
+	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;
+CTM.Stream.prototype.readArrayInt32 = function(array) {
+	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;
+CTM.Stream.prototype.readArrayFloat32 = function(array) {
+	var i = 0, len = array.length;
 
-  while(i < len){
-    array[i ++] = this.readFloat32();
-  }
+	while (i < len) {
+		array[i ++] = this.readFloat32();
+	}
 
-  return array;
+	return array;
 };

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

@@ -8,510 +8,510 @@ if ( typeof module === 'object' ) {
 
 }
 
-LZMA.OutWindow = function(){
-  this._windowSize = 0;
+LZMA.OutWindow = function() {
+	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;
+LZMA.OutWindow.prototype.create = function(windowSize) {
+	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;
-  }
+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;
+	}
 };
 
-LZMA.OutWindow.prototype.releaseStream = function(){
-  this.flush();
-  this._stream = null;
+LZMA.OutWindow.prototype.releaseStream = function() {
+	this.flush();
+	this._stream = null;
 };
 
-LZMA.OutWindow.prototype.setStream = function(stream){
-  this.releaseStream();
-  this._stream = stream;
+LZMA.OutWindow.prototype.setStream = function(stream) {
+	this.releaseStream();
+	this._stream = stream;
 };
 
-LZMA.OutWindow.prototype.init = function(solid){
-  if (!solid){
-    this._streamPos = 0;
-    this._pos = 0;
-  }
+LZMA.OutWindow.prototype.init = function(solid) {
+	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();
-    }
-  }
+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();
+		}
+	}
 };
 
-LZMA.OutWindow.prototype.putByte = function(b){
-  this._buffer[this._pos ++] = b;
-  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();
+	}
 };
 
-LZMA.OutWindow.prototype.getByte = function(distance){
-  var pos = this._pos - distance - 1;
-  if (pos < 0){
-    pos += this._windowSize;
-  }
-  return this._buffer[pos];
+LZMA.OutWindow.prototype.getByte = function(distance) {
+	var pos = this._pos - distance - 1;
+	if (pos < 0) {
+		pos += this._windowSize;
+	}
+	return this._buffer[pos];
 };
 
-LZMA.RangeDecoder = function(){
+LZMA.RangeDecoder = function() {
 };
 
-LZMA.RangeDecoder.prototype.setStream = function(stream){
-  this._stream = stream;
+LZMA.RangeDecoder.prototype.setStream = function(stream) {
+	this._stream = stream;
 };
 
-LZMA.RangeDecoder.prototype.releaseStream = function(){
-  this._stream = null;
+LZMA.RangeDecoder.prototype.releaseStream = function() {
+	this._stream = null;
 };
 
-LZMA.RangeDecoder.prototype.init = function(){
-  var i = 5;
+LZMA.RangeDecoder.prototype.init = function() {
+	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;
+LZMA.RangeDecoder.prototype.decodeDirectBits = function(numTotalBits) {
+	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],
+LZMA.RangeDecoder.prototype.decodeBit = function(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;
-  }
+	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;
+	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;
-  }
+LZMA.initBitModels = function(probs, len) {
+	while (len --) {
+		probs[len] = 1024;
+	}
 };
 
-LZMA.BitTreeDecoder = function(numBitLevels){
-  this._models = [];
-  this._numBitLevels = numBitLevels;
+LZMA.BitTreeDecoder = function(numBitLevels) {
+	this._models = [];
+	this._numBitLevels = numBitLevels;
 };
 
-LZMA.BitTreeDecoder.prototype.init = function(){
-  LZMA.initBitModels(this._models, 1 << this._numBitLevels);
+LZMA.BitTreeDecoder.prototype.init = function() {
+	LZMA.initBitModels(this._models, 1 << this._numBitLevels);
 };
 
-LZMA.BitTreeDecoder.prototype.decode = function(rangeDecoder){
-  var m = 1, i = this._numBitLevels;
+LZMA.BitTreeDecoder.prototype.decode = function(rangeDecoder) {
+	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;
+LZMA.BitTreeDecoder.prototype.reverseDecode = function(rangeDecoder) {
+	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;
+LZMA.reverseDecode2 = function(models, startIndex, rangeDecoder, numBitLevels) {
+	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;
+LZMA.LenDecoder = function() {
+	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);
-  }
+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);
+	}
 };
 
-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();
+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();
 };
 
-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);
+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);
 };
 
-LZMA.Decoder2 = function(){
-  this._decoders = [];
+LZMA.Decoder2 = function() {
+	this._decoders = [];
 };
 
-LZMA.Decoder2.prototype.init = function(){
-  LZMA.initBitModels(this._decoders, 0x300);
+LZMA.Decoder2.prototype.init = function() {
+	LZMA.initBitModels(this._decoders, 0x300);
 };
 
-LZMA.Decoder2.prototype.decodeNormal = function(rangeDecoder){
-  var symbol = 1;
+LZMA.Decoder2.prototype.decodeNormal = function(rangeDecoder) {
+	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;
+LZMA.Decoder2.prototype.decodeWithMatchByte = function(rangeDecoder, matchByte) {
+	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 = function() {
 };
 
-LZMA.LiteralDecoder.prototype.create = function(numPosBits, numPrevBits){
-  var i;
+LZMA.LiteralDecoder.prototype.create = function(numPosBits, numPrevBits) {
+	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;
+    && (this._numPosBits === numPosBits) ) {
+		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();
-  }
+LZMA.LiteralDecoder.prototype.init = function() {
+	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)
+LZMA.LiteralDecoder.prototype.getDecoder = function(pos, prevByte) {
+	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;
+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._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;
+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;
 };
 
-LZMA.Decoder.prototype.setLcLpPb = function(lc, lp, pb){
-  var numPosStates = 1 << pb;
+LZMA.Decoder.prototype.setLcLpPb = function(lc, lp, 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;
+LZMA.Decoder.prototype.init = function() {
+	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,
+LZMA.Decoder.prototype.decode = function(inStream, outStream, outSize) {
+	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;
-};
-
-LZMA.Decoder.prototype.setDecoderProperties = function(properties){
-  var value, lc, lp, pb, dictionarySize;
-
-  if (properties.size < 5){
-    return false;
-  }
-
-  value = properties.readByte();
-  lc = value % 9;
-  value = ~~(value / 9);
-  lp = value % 5;
-  pb = ~~(value / 5);
-
-  if ( !this.setLcLpPb(lc, lp, pb) ){
-    return false;
-  }
-
-  dictionarySize = properties.readByte();
-  dictionarySize |= properties.readByte() << 8;
-  dictionarySize |= properties.readByte() << 16;
-  dictionarySize += properties.readByte() * 16777216;
-
-  return this.setDictionarySize(dictionarySize);
-};
-
-LZMA.decompress = function(properties, inStream, outStream, outSize){
-  var decoder = new LZMA.Decoder();
-
-  if ( !decoder.setDecoderProperties(properties) ){
-    throw "Incorrect stream properties";
-  }
-
-  if ( !decoder.decode(inStream, outStream, outSize) ){
-    throw "Error in data stream";
-  }
-
-  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;
+
+	if (properties.size < 5) {
+		return false;
+	}
+
+	value = properties.readByte();
+	lc = value % 9;
+	value = ~~(value / 9);
+	lp = value % 5;
+	pb = ~~(value / 5);
+
+	if ( !this.setLcLpPb(lc, lp, pb) ) {
+		return false;
+	}
+
+	dictionarySize = properties.readByte();
+	dictionarySize |= properties.readByte() << 8;
+	dictionarySize |= properties.readByte() << 16;
+	dictionarySize += properties.readByte() * 16777216;
+
+	return this.setDictionarySize(dictionarySize);
+};
+
+LZMA.decompress = function(properties, inStream, outStream, outSize) {
+	var decoder = new LZMA.Decoder();
+
+	if ( !decoder.setDecoderProperties(properties) ) {
+		throw "Incorrect stream properties";
+	}
+
+	if ( !decoder.decode(inStream, outStream, outSize) ) {
+		throw "Error in data stream";
+	}
+
+	return true;
 };

+ 2 - 2
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 ) );
 
 						}
 
@@ -891,7 +891,7 @@ THREE.SceneLoader.prototype = {
 
 				counter_textures += textureJSON.url.length;
 
-				for( var n = 0; n < textureJSON.url.length; n ++ ) {
+				for ( var n = 0; n < textureJSON.url.length; n ++ ) {
 
 					scope.onLoadStart();
 

+ 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;
 
 }));

+ 5 - 5
examples/js/loaders/gltf/glTFAnimation.js

@@ -24,7 +24,7 @@ THREE.glTFAnimator = ( function () {
 
 		update : function()
 		{
-			for (i = 0; i < animators.length; i++)
+			for (i = 0; i < animators.length; i ++)
 			{
 				animators[i].update();
 			}
@@ -50,7 +50,7 @@ THREE.glTFAnimation = function(interps)
 THREE.glTFAnimation.prototype.createInterpolators = function(interps)
 {
 	var i, len = interps.length;
-	for (i = 0; i < len; i++)
+	for (i = 0; i < len; i ++)
 	{
 		var interp = new THREE.glTFInterpolator(interps[i]);
 		this.interps.push(interp);
@@ -90,7 +90,7 @@ THREE.glTFAnimation.prototype.update = function()
 	{
 		this.running = false;
 		var i, len = this.interps.length;
-		for (i = 0; i < len; i++)
+		for (i = 0; i < len; i ++)
 		{
 			this.interps[i].interp(this.duration);
 		}
@@ -100,7 +100,7 @@ THREE.glTFAnimation.prototype.update = function()
 	else
 	{
 		var i, len = this.interps.length;
-		for (i = 0; i < len; i++)
+		for (i = 0; i < len; i ++)
 		{
 			this.interps[i].interp(t);
 		}
@@ -202,7 +202,7 @@ THREE.glTFInterpolator.prototype.interp = function(t)
 	}
 	else
 	{
-		for (i = 0; i < this.count - 1; i++)
+		for (i = 0; i < this.count - 1; i ++)
 		{
 			var key1 = this.keys[i];
 			var key2 = this.keys[i + 1];

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 522 - 522
examples/js/loaders/gltf/glTFLoader.js


+ 103 - 103
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],
+                "range" : [ 0 ],
                 "type" : "text",
                 "delegate" : delegate,
                 "ctx" : ctx }, null);
     	
-            return null;
-	    }
+	return null;
+}
 	},    
 });

+ 10 - 10
examples/js/math/Lut.js

@@ -42,7 +42,7 @@ THREE.Lut.prototype = {
 
 	constructor: THREE.Lut,
 
-	lut: [], map: [], mapname: 'rainbow' , n: 256, minV: 0, maxV: 1, legend: null,
+	lut: [], map: [], mapname: 'rainbow', n: 256, minV: 0, maxV: 1, legend: null,
 
 	set: function ( value ) {
 
@@ -167,7 +167,7 @@ THREE.Lut.prototype = {
 
 		for ( var i = 1; i >= 0; i-=step ) {
 
-			for ( var j = this.map.length - 1; j >= 0; j-- ) {
+			for ( var j = this.map.length - 1; j >= 0; j -- ) {
 
 				if ( i < this.map[ j ][ 0 ] && i >= this.map[ j - 1 ][ 0 ]  ) {
 
@@ -194,7 +194,7 @@ THREE.Lut.prototype = {
 		this.legend.ctx.putImageData( imageData, 0, 0 );
 		this.legend.texture.needsUpdate = true;
 
-		this.legend.legendGeometry = new THREE.PlaneBufferGeometry( this.legend.dimensions.width , this.legend.dimensions.height );
+		this.legend.legendGeometry = new THREE.PlaneBufferGeometry( this.legend.dimensions.width, this.legend.dimensions.height );
 		this.legend.legendMaterial = new THREE.MeshBasicMaterial( { map : this.legend.texture, side : THREE.DoubleSide } );
 
 		this.legend.mesh = new THREE.Mesh( this.legend.legendGeometry, this.legend.legendMaterial );
@@ -269,7 +269,7 @@ THREE.Lut.prototype = {
 
 		this.legend.labels.title = parameters.hasOwnProperty( 'title' ) ? parameters[ 'title' ] : '';
 
-		this.legend.labels.um = parameters.hasOwnProperty( 'um' ) ? ' [ '+ parameters[ 'um' ] + ' ]': '';
+		this.legend.labels.um = parameters.hasOwnProperty( 'um' ) ? ' [ ' + parameters[ 'um' ] + ' ]' : '';
 
 		this.legend.labels.ticks = parameters.hasOwnProperty( 'ticks' ) ? parameters[ 'ticks' ] : 0;
 
@@ -340,7 +340,7 @@ THREE.Lut.prototype = {
 
 			}
 
-			for ( var i = 0; i < this.legend.labels.ticks; i++ ) {
+			for ( var i = 0; i < this.legend.labels.ticks; i ++ ) {
 
 				var value = ( this.maxV - this.minV ) / ( this.legend.labels.ticks - 1  ) * i ;
 
@@ -429,7 +429,7 @@ THREE.Lut.prototype = {
 
 					var linePosition = ( this.legend.position.y - ( this.legend.dimensions.height * 0.5 ) + 0.01 ) + ( this.legend.dimensions.height ) * ( value / ( this.maxV - this.minV ) * 0.99 );
 
-					geometry.vertices.push( new THREE.Vector3( this.legend.position.x + this.legend.dimensions.width * 0.55, linePosition , this.legend.position.z  ) );
+					geometry.vertices.push( new THREE.Vector3( this.legend.position.x + this.legend.dimensions.width * 0.55, linePosition, this.legend.position.z  ) );
 
 					geometry.vertices.push( new THREE.Vector3( this.legend.position.x + this.legend.dimensions.width * 0.7, linePosition, this.legend.position.z  ) );
 
@@ -463,9 +463,9 @@ THREE.Lut.prototype = {
 
 THREE.ColorMapKeywords = {
 
-  "rainbow":    [ [ 0.0, '0x0000FF' ], [ 0.2, '0x00FFFF' ], [ 0.5, '0x00FF00' ], [ 0.8, '0xFFFF00'],  [1.0, '0xFF0000' ] ],
-  "cooltowarm": [ [ 0.0, '0x3C4EC2' ], [ 0.2, '0x9BBCFF' ], [ 0.5, '0xDCDCDC' ], [ 0.8, '0xF6A385'],  [1.0, '0xB40426' ] ],
-  "blackbody" : [ [ 0.0, '0x000000' ], [ 0.2, '0x780000' ], [ 0.5, '0xE63200' ], [ 0.8, '0xFFFF00'],  [1.0, '0xFFFFFF' ] ],
-  "grayscale" : [ [ 0.0, '0x000000' ], [ 0.2, '0x404040' ], [ 0.5, '0x7F7F80' ], [ 0.8, '0xBFBFBF'],  [1.0, '0xFFFFFF' ] ]
+  "rainbow":    [ [ 0.0, '0x0000FF' ], [ 0.2, '0x00FFFF' ], [ 0.5, '0x00FF00' ], [ 0.8, '0xFFFF00' ],  [ 1.0, '0xFF0000' ] ],
+  "cooltowarm": [ [ 0.0, '0x3C4EC2' ], [ 0.2, '0x9BBCFF' ], [ 0.5, '0xDCDCDC' ], [ 0.8, '0xF6A385' ],  [ 1.0, '0xB40426' ] ],
+  "blackbody" : [ [ 0.0, '0x000000' ], [ 0.2, '0x780000' ], [ 0.5, '0xE63200' ], [ 0.8, '0xFFFF00' ],  [ 1.0, '0xFFFFFF' ] ],
+  "grayscale" : [ [ 0.0, '0x000000' ], [ 0.2, '0x404040' ], [ 0.5, '0x7F7F80' ], [ 0.8, '0xBFBFBF' ],  [ 1.0, '0xFFFFFF' ] ]
 
 };

+ 8 - 8
examples/js/modifiers/SubdivisionModifier.js

@@ -26,7 +26,7 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
 
 	var repeats = this.subdivisions;
 
-	while ( repeats-- > 0 ) {
+	while ( repeats -- > 0 ) {
 		this.smooth( geometry );
 	}
 
@@ -101,11 +101,11 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
 
 		var i, il, face, edge;
 
-		for ( i = 0, il = vertices.length; i < il; i++ ) {
+		for ( i = 0, il = vertices.length; i < il; i ++ ) {
 			metaVertices[ i ] = { edges: [] };
 		}
 		
-		for ( i = 0, il = faces.length; i < il; i++ ) {
+		for ( i = 0, il = faces.length; i < il; i ++ ) {
 			face = faces[ i ];
 
 			processEdge( face.a, face.b, vertices, edges, face, metaVertices );
@@ -194,11 +194,11 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
 
 			tmp.set( 0, 0, 0 );
 
-			for ( j = 0; j < connectedFaces; j++ ) {
+			for ( j = 0; j < connectedFaces; j ++ ) {
 
 				face = currentEdge.faces[ j ];
 				
-				for ( k = 0; k < 3; k++ ) {
+				for ( k = 0; k < 3; k ++ ) {
 
 					other = oldVertices[ face[ ABC[k] ] ];
 					if (other !== currentEdge.a && other !== currentEdge.b ) break;
@@ -229,7 +229,7 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
 		var connectingEdge, connectingEdges, oldVertex, newSourceVertex;
 		newSourceVertices = [];
 
-		for ( i = 0, il = oldVertices.length; i < il; i++ ) {
+		for ( i = 0, il = oldVertices.length; i < il; i ++ ) {
 
 			oldVertex = oldVertices[ i ];
 
@@ -284,7 +284,7 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
 
 			tmp.set( 0, 0, 0 );
 
-			for ( j=0; j < n; j++ ) {
+			for ( j = 0; j < n; j ++ ) {
 
 				connectingEdge = connectingEdges[ j ];
 				other = connectingEdge.a !== oldVertex ? connectingEdge.a : connectingEdge.b;
@@ -312,7 +312,7 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
 		var sl = newSourceVertices.length, edge1, edge2, edge3;
 		newFaces = [];
 
-		for ( i = 0, il = oldFaces.length; i < il; i++ ) {
+		for ( i = 0, il = oldFaces.length; i < il; i ++ ) {
 
 			face = oldFaces[ i ];
 

+ 2 - 2
examples/js/postprocessing/AdaptiveToneMappingPass.js

@@ -11,7 +11,7 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) {
 
 	this.resolution = ( resolution !== undefined ) ? resolution : 256;
 	this.needsInit = true;
-	this.adaptive = adaptive !== undefined? !!adaptive : true;
+	this.adaptive = adaptive !== undefined ? !!adaptive : true;
 
 	this.luminanceRT = null;
 	this.previousLuminanceRT = null;
@@ -190,7 +190,7 @@ THREE.AdaptiveToneMappingPass.prototype = {
 			this.materialToneMap.uniforms.luminanceMap.value = this.luminanceRT;
 		}
 		//Put something in the adaptive luminance texture so that the scene can render initially
-		this.quad.material = new THREE.MeshBasicMaterial( {color: 0x777777 });
+		this.quad.material = new THREE.MeshBasicMaterial( { color: 0x777777 });
 		this.materialLuminance.needsUpdate = true;
 		this.materialAdaptiveLum.needsUpdate = true;
 		this.materialToneMap.needsUpdate = true;

+ 32 - 32
examples/js/postprocessing/GlitchPass.js

@@ -9,10 +9,10 @@ THREE.GlitchPass = function ( dt_size ) {
 	var shader = THREE.DigitalGlitch;
 	this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
 
-	if(dt_size==undefined) dt_size=64;
+	if (dt_size == undefined) dt_size = 64;
 	
 	
-	this.uniforms[ "tDisp"].value=this.generateHeightmap(dt_size);
+	this.uniforms[ "tDisp"].value = this.generateHeightmap(dt_size);
 	
 
 	this.material = new THREE.ShaderMaterial({
@@ -34,8 +34,8 @@ THREE.GlitchPass = function ( dt_size ) {
 	this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
 	this.scene.add( this.quad );
 	
-	this.goWild=false;
-	this.curF=0;
+	this.goWild = false;
+	this.curF = 0;
 	this.generateTrigger();
 	
 };
@@ -45,34 +45,34 @@ THREE.GlitchPass.prototype = {
 	render: function ( renderer, writeBuffer, readBuffer, delta ) 
 	{
 		this.uniforms[ "tDiffuse" ].value = readBuffer;
-		this.uniforms[ 'seed' ].value=Math.random();//default seeding
-		this.uniforms[ 'byp' ].value=0;
+		this.uniforms[ 'seed' ].value = Math.random();//default seeding
+		this.uniforms[ 'byp' ].value = 0;
 		
-		if(this.curF % this.randX ==0 || this.goWild==true)
+		if (this.curF % this.randX == 0 || this.goWild == true)
 		{
-			this.uniforms[ 'amount' ].value=Math.random()/30;
-			this.uniforms[ 'angle' ].value=THREE.Math.randFloat(-Math.PI,Math.PI);
-			this.uniforms[ 'seed_x' ].value=THREE.Math.randFloat(-1,1);
-			this.uniforms[ 'seed_y' ].value=THREE.Math.randFloat(-1,1);
-			this.uniforms[ 'distortion_x' ].value=THREE.Math.randFloat(0,1);
-			this.uniforms[ 'distortion_y' ].value=THREE.Math.randFloat(0,1);
-			this.curF=0;
+			this.uniforms[ 'amount' ].value = Math.random() / 30;
+			this.uniforms[ 'angle' ].value = THREE.Math.randFloat(-Math.PI, Math.PI);
+			this.uniforms[ 'seed_x' ].value = THREE.Math.randFloat(-1, 1);
+			this.uniforms[ 'seed_y' ].value = THREE.Math.randFloat(-1, 1);
+			this.uniforms[ 'distortion_x' ].value = THREE.Math.randFloat(0, 1);
+			this.uniforms[ 'distortion_y' ].value = THREE.Math.randFloat(0, 1);
+			this.curF = 0;
 			this.generateTrigger();
 		}
-		else if(this.curF % this.randX <this.randX/5)
+		else if (this.curF % this.randX < this.randX / 5)
 		{
-			this.uniforms[ 'amount' ].value=Math.random()/90;
-			this.uniforms[ 'angle' ].value=THREE.Math.randFloat(-Math.PI,Math.PI);
-			this.uniforms[ 'distortion_x' ].value=THREE.Math.randFloat(0,1);
-			this.uniforms[ 'distortion_y' ].value=THREE.Math.randFloat(0,1);
-			this.uniforms[ 'seed_x' ].value=THREE.Math.randFloat(-0.3,0.3);
-			this.uniforms[ 'seed_y' ].value=THREE.Math.randFloat(-0.3,0.3);
+			this.uniforms[ 'amount' ].value = Math.random() / 90;
+			this.uniforms[ 'angle' ].value = THREE.Math.randFloat(-Math.PI, Math.PI);
+			this.uniforms[ 'distortion_x' ].value = THREE.Math.randFloat(0, 1);
+			this.uniforms[ 'distortion_y' ].value = THREE.Math.randFloat(0, 1);
+			this.uniforms[ 'seed_x' ].value = THREE.Math.randFloat(-0.3, 0.3);
+			this.uniforms[ 'seed_y' ].value = THREE.Math.randFloat(-0.3, 0.3);
 		}
-		else if(this.goWild==false)
+		else if (this.goWild == false)
 		{
-			this.uniforms[ 'byp' ].value=1;
+			this.uniforms[ 'byp' ].value = 1;
 		}
-		this.curF++;
+		this.curF ++;
 		
 		this.quad.material = this.material;
 		if ( this.renderToScreen ) 
@@ -86,20 +86,20 @@ THREE.GlitchPass.prototype = {
 	},
 	generateTrigger:function()
 	{
-		this.randX=THREE.Math.randInt(120,240);
+		this.randX = THREE.Math.randInt(120, 240);
 	},
 	generateHeightmap:function(dt_size)
 	{
-		var data_arr = new Float32Array( dt_size*dt_size * 3 );
+		var data_arr = new Float32Array( dt_size * dt_size * 3 );
 		console.log(dt_size);
-		var length=dt_size*dt_size;
+		var length = dt_size * dt_size;
 		
-		for ( var i = 0; i < length; i++) 
+		for ( var i = 0; i < length; i ++) 
 		{
-			var val=THREE.Math.randFloat(0,1);
-			data_arr[ i*3 + 0 ] = val;
-			data_arr[ i*3 + 1 ] = val;
-			data_arr[ i*3 + 2 ] = val;
+			var val = THREE.Math.randFloat(0, 1);
+			data_arr[ i * 3 + 0 ] = val;
+			data_arr[ i * 3 + 1 ] = val;
+			data_arr[ i * 3 + 2 ] = val;
 		}
 		
 		var texture = new THREE.DataTexture( data_arr, dt_size, dt_size, THREE.RGBFormat, THREE.FloatType );

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

@@ -68,7 +68,7 @@ THREE.SVGRenderer = function () {
 
 	this.setQuality = function( quality ) {
 
-		switch(quality) {
+		switch (quality) {
 
 			case "high": _quality = 1; break;
 			case "low": _quality = 0; break;
@@ -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 );
@@ -232,7 +232,7 @@ THREE.SVGRenderer = function () {
 		_directionalLights.setRGB( 0, 0, 0 );
 		_pointLights.setRGB( 0, 0, 0 );
 
-		for ( var l = 0, ll = lights.length; l < ll; l++ ) {
+		for ( var l = 0, ll = lights.length; l < ll; l ++ ) {
 
 			var light = lights[ l ];
 			var lightColor = light.color;

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

@@ -292,9 +292,9 @@ THREE.SoftwareRenderer = function ( parameters ) {
 		for ( var i = 0; i < size; i+=4 ) {
 
 			data[ i ] = clearColor.r * 255 | 0;
-			data[ i+1 ] = clearColor.g * 255 | 0;
-			data[ i+2 ] = clearColor.b * 255 | 0;
-			data[ i+3 ] = 255;
+			data[ i + 1 ] = clearColor.g * 255 | 0;
+			data[ i + 2 ] = clearColor.b * 255 | 0;
+			data[ i + 3 ] = 255;
 		}
 
 		context.fillStyle = clearColor.getStyle();
@@ -306,31 +306,31 @@ THREE.SoftwareRenderer = function ( parameters ) {
 		var diffuseR = material.color.r * 255;
 		var diffuseG = material.color.g * 255;
 		var diffuseB = material.color.b * 255;
-		var palette = new Uint8Array(256*3);
+		var palette = new Uint8Array(256 * 3);
 
 		if ( bSimulateSpecular ) {
 
-			while(i < 204) {
-				palette[j++] = Math.min( i * diffuseR / 204, 255 );
-				palette[j++] = Math.min( i * diffuseG / 204, 255 );
-				palette[j++] = Math.min( i * diffuseB / 204, 255 );
-				++i;
+			while (i < 204) {
+				palette[j ++] = Math.min( i * diffuseR / 204, 255 );
+				palette[j ++] = Math.min( i * diffuseG / 204, 255 );
+				palette[j ++] = Math.min( i * diffuseB / 204, 255 );
+				++ i;
 			}
 
-			while(i < 256) { // plus specular highlight
-				palette[j++] = Math.min( diffuseR + (i - 204) * (255 - diffuseR) / 82, 255 );
-				palette[j++] = Math.min( diffuseG + (i - 204) * (255 - diffuseG) / 82, 255 );
-				palette[j++] = Math.min( diffuseB + (i - 204) * (255 - diffuseB) / 82, 255 );
-				++i;
+			while (i < 256) { // plus specular highlight
+				palette[j ++] = Math.min( diffuseR + (i - 204) * (255 - diffuseR) / 82, 255 );
+				palette[j ++] = Math.min( diffuseG + (i - 204) * (255 - diffuseG) / 82, 255 );
+				palette[j ++] = Math.min( diffuseB + (i - 204) * (255 - diffuseB) / 82, 255 );
+				++ i;
 			}
 
 		} else {
 
-			while(i < 256) {
-				palette[j++] = Math.min( i * diffuseR / 255, 255 );
-				palette[j++] = Math.min( i * diffuseG / 255, 255 );
-				palette[j++] = Math.min( i * diffuseB / 255, 255 );
-				++i;
+			while (i < 256) {
+				palette[j ++] = Math.min( i * diffuseR / 255, 255 );
+				palette[j ++] = Math.min( i * diffuseG / 255, 255 );
+				palette[j ++] = Math.min( i * diffuseB / 255, 255 );
+				++ i;
 			}
 
 		}
@@ -355,17 +355,17 @@ THREE.SoftwareRenderer = function ( parameters ) {
 
 		if ( !isTransparent ) {
 			buffer[ colorOffset ] = tdata[tIndex];
-			buffer[ colorOffset + 1 ] = tdata[tIndex+1];
-			buffer[ colorOffset + 2 ] = tdata[tIndex+2];
+			buffer[ colorOffset + 1 ] = tdata[tIndex + 1];
+			buffer[ colorOffset + 2 ] = tdata[tIndex + 2];
 			buffer[ colorOffset + 3 ] = material.opacity * 255;
 			depthBuf[ offset ] = depth;
 		}
 		else {
-			var opaci = tdata[tIndex+3] * material.opacity;
-			var texel = (tdata[tIndex] << 16) + (tdata[tIndex+1] << 8) + tdata[tIndex+2];
-			if(opaci < 250) {
+			var opaci = tdata[tIndex + 3] * material.opacity;
+			var texel = (tdata[tIndex] << 16) + (tdata[tIndex + 1] << 8) + tdata[tIndex + 2];
+			if (opaci < 250) {
 				var backColor = (buffer[colorOffset] << 16) + (buffer[colorOffset + 1] << 8) + buffer[colorOffset + 2];
-				texel = texel * opaci + backColor * (1-opaci);
+				texel = texel * opaci + backColor * (1 - opaci);
 			}
 
 			buffer[ colorOffset ] = (texel & 0xff0000) >> 16;
@@ -393,19 +393,19 @@ THREE.SoftwareRenderer = function ( parameters ) {
 
 		if ( !isTransparent ) {
 			buffer[ colorOffset ] = (material.palette[cIndex] * tdata[tIndex]) >> 8;
-			buffer[ colorOffset + 1 ] = (material.palette[cIndex+1] * tdata[tIndex+1]) >> 8;
-			buffer[ colorOffset + 2 ] = (material.palette[cIndex+2] * tdata[tIndex+2]) >> 8;
+			buffer[ colorOffset + 1 ] = (material.palette[cIndex + 1] * tdata[tIndex + 1]) >> 8;
+			buffer[ colorOffset + 2 ] = (material.palette[cIndex + 2] * tdata[tIndex + 2]) >> 8;
 			buffer[ colorOffset + 3 ] = material.opacity * 255;
 			depthBuf[ offset ] = depth;
 		} else {
-			var opaci = tdata[tIndex+3] * material.opacity;
+			var opaci = tdata[tIndex + 3] * material.opacity;
 			var foreColor = ((material.palette[cIndex] * tdata[tIndex]) << 16)
-							+ ((material.palette[cIndex+1] * tdata[tIndex+1]) << 8 )
-							+ (material.palette[cIndex+2] * tdata[tIndex+2]);
+							+ ((material.palette[cIndex + 1] * tdata[tIndex + 1]) << 8 )
+							+ (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);
+			if (opaci < 250) {
+				var backColor = buffer[ colorOffset ] << 24 + buffer[ colorOffset + 1 ] << 16 + buffer[ colorOffset + 2 ] << 8;
+				foreColor = foreColor * opaci + backColor * (1 - opaci);
 			}
 
 			buffer[ colorOffset ] = (foreColor & 0xff0000) >> 16;
@@ -587,11 +587,11 @@ THREE.SoftwareRenderer = function ( parameters ) {
 			bHasUV = true;
 
 			tu1 = uv1.x;
-			tv1 = 1-uv1.y;
+			tv1 = 1 - uv1.y;
 			tu2 = uv2.x;
-			tv2 = 1-uv2.y;
+			tv2 = 1 - uv2.y;
 			tu3 = uv3.x;
-			tv3 = 1-uv3.y;
+			tv3 = 1 - uv3.y;
 		}
 
 		// Normal values
@@ -660,9 +660,9 @@ THREE.SoftwareRenderer = function ( parameters ) {
 		// Z interpolation setup
 
 		var dz12 = z1 - z2, dz31 = z3 - z1;
-		var invDet = 1.0 / (dx12*dy31 - dx31*dy12);
-		var dzdx = (invDet * (dz12*dy31 - dz31*dy12)); // dz per one subpixel step in x
-		var dzdy = (invDet * (dz12*dx31 - dx12*dz31)); // dz per one subpixel step in y
+		var invDet = 1.0 / (dx12 * dy31 - dx31 * dy12);
+		var dzdx = (invDet * (dz12 * dy31 - dz31 * dy12)); // dz per one subpixel step in x
+		var dzdy = (invDet * (dz12 * dx31 - dx12 * dz31)); // dz per one subpixel step in y
 
 		// Z at top/left corner of rast area
 
@@ -678,11 +678,11 @@ THREE.SoftwareRenderer = function ( parameters ) {
 		if ( bHasUV ) {
 			// UV interpolation setup
 			var dtu12 = tu1 - tu2, dtu31 = tu3 - tu1;
-			var dtudx = (invDet * (dtu12*dy31 - dtu31*dy12)); // dtu per one subpixel step in x
-			var dtudy = (invDet * (dtu12*dx31 - dx12*dtu31)); // dtu per one subpixel step in y
+			var dtudx = (invDet * (dtu12 * dy31 - dtu31 * dy12)); // dtu per one subpixel step in x
+			var dtudy = (invDet * (dtu12 * dx31 - dx12 * dtu31)); // dtu per one subpixel step in y
 			var dtv12 = tv1 - tv2, dtv31 = tv3 - tv1;
-			dtvdx = (invDet * (dtv12*dy31 - dtv31*dy12)); // dtv per one subpixel step in x
-			dtvdy = (invDet * (dtv12*dx31 - dx12*dtv31)); // dtv per one subpixel step in y
+			dtvdx = (invDet * (dtv12 * dy31 - dtv31 * dy12)); // dtv per one subpixel step in x
+			dtvdy = (invDet * (dtv12 * dx31 - dx12 * dtv31)); // dtv per one subpixel step in y
 
 			// UV at top/left corner of rast area
 			cbtu = ( tu1 + (minXfixscale - x1) * dtudx + (minYfixscale - y1) * dtudy );
@@ -699,8 +699,8 @@ THREE.SoftwareRenderer = function ( parameters ) {
 		if ( bHasNormal ) {
 			 // Normal interpolation setup
 			var dnz12 = nz1 - nz2, dnz31 = nz3 - nz1;
-			var dnzdx = (invDet * (dnz12*dy31 - dnz31*dy12)); // dnz per one subpixel step in x
-			var dnzdy = (invDet * (dnz12*dx31 - dx12*dnz31)); // dnz per one subpixel step in y
+			var dnzdx = (invDet * (dnz12 * dy31 - dnz31 * dy12)); // dnz per one subpixel step in x
+			var dnzdy = (invDet * (dnz12 * dx31 - dx12 * dnz31)); // dnz per one subpixel step in y
 
 			// Normal at top/left corner of rast area
 			cbnz = ( nz1 + (minXfixscale - x1) * dnzdx + (minYfixscale - y1) * dnzdy );
@@ -716,14 +716,14 @@ THREE.SoftwareRenderer = function ( parameters ) {
 		var nmin2 = 0, nmax2 = 0;
 		var nmin3 = 0, nmax3 = 0;
 		var nminz = 0, nmaxz = 0;
-		if (dx12 >= 0) nmax1 -= qm1*dx12; else nmin1 -= qm1*dx12;
-		if (dy12 >= 0) nmax1 -= qm1*dy12; else nmin1 -= qm1*dy12;
-		if (dx23 >= 0) nmax2 -= qm1*dx23; else nmin2 -= qm1*dx23;
-		if (dy23 >= 0) nmax2 -= qm1*dy23; else nmin2 -= qm1*dy23;
-		if (dx31 >= 0) nmax3 -= qm1*dx31; else nmin3 -= qm1*dx31;
-		if (dy31 >= 0) nmax3 -= qm1*dy31; else nmin3 -= qm1*dy31;
-		if (dzdx >= 0) nmaxz += qm1*dzdx; else nminz += qm1*dzdx;
-		if (dzdy >= 0) nmaxz += qm1*dzdy; else nminz += qm1*dzdy;
+		if (dx12 >= 0) nmax1 -= qm1 * dx12; else nmin1 -= qm1 * dx12;
+		if (dy12 >= 0) nmax1 -= qm1 * dy12; else nmin1 -= qm1 * dy12;
+		if (dx23 >= 0) nmax2 -= qm1 * dx23; else nmin2 -= qm1 * dx23;
+		if (dy23 >= 0) nmax2 -= qm1 * dy23; else nmin2 -= qm1 * dy23;
+		if (dx31 >= 0) nmax3 -= qm1 * dx31; else nmin3 -= qm1 * dx31;
+		if (dy31 >= 0) nmax3 -= qm1 * dy31; else nmin3 -= qm1 * dy31;
+		if (dzdx >= 0) nmaxz += qm1 * dzdx; else nminz += qm1 * dzdx;
+		if (dzdy >= 0) nmaxz += qm1 * dzdy; else nminz += qm1 * dzdy;
 
 		// Loop through blocks
 		var linestep = canvasWidth - q;
@@ -894,7 +894,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
 								cxnz += dnzdx;
 							}
 
-							offset++;
+							offset ++;
 
 						}
 
@@ -978,7 +978,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
 								cxnz += dnzdx;
 							}
 
-							offset++;
+							offset ++;
 
 						}
 
@@ -1005,18 +1005,18 @@ THREE.SoftwareRenderer = function ( parameters ) {
 			}
 
 			// Advance to next row of blocks
-			cb1 += q*dx12;
-			cb2 += q*dx23;
-			cb3 += q*dx31;
-			cbz += q*dzdy;
+			cb1 += q * dx12;
+			cb2 += q * dx23;
+			cb3 += q * dx31;
+			cbz += q * dzdy;
 
 			if ( bHasUV ) {
-				cbtu += q*dtudy;
-				cbtv += q*dtvdy;
+				cbtu += q * dtudy;
+				cbtv += q * dtvdy;
 			}
 
 			if ( bHasNormal ) {
-				cbnz += q*dnzdy;
+				cbnz += q * dnzdy;
 			}
 
 		}
@@ -1081,7 +1081,7 @@ THREE.SoftwareRenderer.Texture = function() {
 
 	this.fromImage = function( image ) {
 
-		if( !image || image.width <= 0 || image.height <= 0 )
+		if ( !image || image.width <= 0 || image.height <= 0 )
 			return;
 
 		if ( canvas === undefined ) {

+ 4 - 4
examples/js/renderers/plugins/DepthPassPlugin.js

@@ -107,7 +107,7 @@ THREE.DepthPassPlugin = function () {
 		// set object matrices & frustum culling
 		
 		_renderList.length = 0;
-		projectObject(scene,scene,camera);
+		projectObject(scene, scene, camera);
 
 		// render regular objects
 
@@ -189,7 +189,7 @@ THREE.DepthPassPlugin = function () {
 
 	};
 	
-	function projectObject(scene, object,camera){
+	function projectObject(scene, object,camera) {
 		
 		if ( object.visible ) {
 	
@@ -198,7 +198,7 @@ THREE.DepthPassPlugin = function () {
 			if (webglObjects && (object.frustumCulled === false || _frustum.intersectsObject( object ) === true) ) {
 		
 		
-				for (var i = 0, l = webglObjects.length; i < l; i++){
+				for (var i = 0, l = webglObjects.length; i < l; i ++) {
 			
 					var webglObject = webglObjects[i];
 					
@@ -208,7 +208,7 @@ THREE.DepthPassPlugin = function () {
 				}
 			}
 	
-			for(var i = 0, l = object.children.length; i < l; i++) {
+			for (var i = 0, l = object.children.length; i < l; i ++) {
 				
 				projectObject(scene, object.children[i], camera);
 			}

+ 1 - 1
examples/js/shaders/BokehShader2.js

@@ -44,7 +44,7 @@ THREE.BokehShader = {
 		"pentagon": { type: "i", value: 0 },
 
 		"shaderFocus":  { type: "i", value: 1 },
-		"focusCoords":  { type: "v2", value: new THREE.Vector2()},
+		"focusCoords":  { type: "v2", value: new THREE.Vector2() },
 
 
 	},

+ 2 - 2
examples/js/shaders/ConvolutionShader.js

@@ -83,7 +83,7 @@ THREE.ConvolutionShader = {
 
 		values = new Array( kernelSize );
 		sum = 0.0;
-		for ( i = 0; i < kernelSize; ++i ) {
+		for ( i = 0; i < kernelSize; ++ i ) {
 
 			values[ i ] = gauss( i - halfWidth, sigma );
 			sum += values[ i ];
@@ -92,7 +92,7 @@ THREE.ConvolutionShader = {
 
 		// normalize the kernel
 
-		for ( i = 0; i < kernelSize; ++i ) values[ i ] /= sum;
+		for ( i = 0; i < kernelSize; ++ i ) values[ i ] /= sum;
 
 		return values;
 

+ 1 - 1
examples/js/shaders/FXAAShader.js

@@ -13,7 +13,7 @@ THREE.FXAAShader = {
 	uniforms: {
 
 		"tDiffuse":   { type: "t", value: null },
-		"resolution": { type: "v2", value: new THREE.Vector2( 1 / 1024, 1 / 512 )  }
+		"resolution": { type: "v2", value: new THREE.Vector2( 1 / 1024, 1 / 512 ) }
 
 	},
 

+ 1 - 1
examples/js/shaders/NormalDisplacementShader.js

@@ -350,7 +350,7 @@ THREE.NormalDisplacementShader = {
 		"	#if MAX_HEMI_LIGHTS > 0",
 
 		"		vec3 hemiDiffuse = vec3( 0.0 );",
-		"		vec3 hemiSpecular = vec3( 0.0 );" ,
+		"		vec3 hemiSpecular = vec3( 0.0 );",
 
 		"		for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {",
 

+ 1 - 1
examples/js/shaders/TriangleBlurShader.js

@@ -15,7 +15,7 @@ THREE.TriangleBlurShader = {
 	uniforms : {
 
 		"texture": { type: "t", value: null },
-		"delta":   { type: "v2", value:new THREE.Vector2( 1, 1 )  }
+		"delta":   { type: "v2", value:new THREE.Vector2( 1, 1 ) }
 
 	},
 

+ 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;
 
 }
 

+ 22 - 22
examples/js/wip/ProxyGeometry.js

@@ -56,17 +56,17 @@ Object.defineProperties(THREE.ProxyGeometry.prototype, {
 
 	verticesNeedUpdate: {
 		enumerable: true,	
-		get: function() { if (this.attributes[ 'position' ]) return this.attributes[ 'position' ].needsUpdate; } ,
+		get: function() { if (this.attributes[ 'position' ]) return this.attributes[ 'position' ].needsUpdate; },
 		set: function(v) { if (this.attributes[ 'position' ]) this.attributes[ 'position' ].needsUpdate = v; } 
 	},
 	colorsNeedUpdate: {
 		enumerable: true,	
-		get: function() { if (this.attributes[ 'color' ]) return this.attributes[ 'color' ].needsUpdate; } ,
+		get: function() { if (this.attributes[ 'color' ]) return this.attributes[ 'color' ].needsUpdate; },
 		set: function(v) { if (this.attributes[ 'color' ]) this.attributes[ 'color' ].needsUpdate = v; } 
 	},
 	normalsNeedUpdate: {
 		enumerable: true,	
-		get: function() { if (this.attributes[ 'normal' ]) return this.attributes[ 'normal' ].needsUpdate; } ,
+		get: function() { if (this.attributes[ 'normal' ]) return this.attributes[ 'normal' ].needsUpdate; },
 		set: function(v) { if (this.attributes[ 'normal' ]) this.attributes[ 'normal' ].needsUpdate = v; } 
 	},
 });
@@ -95,7 +95,7 @@ THREE.ProxyGeometry.prototype.createVertexProxies = function(values) {
 
 	if (values) {
 
-		for (var i = 0; i < values.length; i++) {
+		for (var i = 0; i < values.length; i ++) {
 
 			this.vertices[i].copy(values[i]);
 
@@ -166,7 +166,7 @@ THREE.ProxyGeometry.prototype.createFaceProxies = function(values) {
 		for ( var i = 0, l = positionarray.length / 3; i < l; i += 3 ) {
 
 			var o = i * 3;
-			var v1 = i, v2 = i+1, v3 = i+2;
+			var v1 = i, v2 = i + 1, v3 = i + 2;
 
 			var face = new THREE.ProxyFace3( v1, v2, v3 );
 			faces.push(face);
@@ -179,7 +179,7 @@ THREE.ProxyGeometry.prototype.createFaceProxies = function(values) {
 
 	if (values) {
 
-		for (var i = 0, l = values.length; i < l; i++) {
+		for (var i = 0, l = values.length; i < l; i ++) {
 
 			var f = faces[i],
 			    v = values[i];
@@ -222,7 +222,7 @@ THREE.ProxyGeometry.prototype.createFaceVertexNormalProxies = function(values) {
 
 		var normalarray = this.attributes[ 'normal' ].array;
 
-		for (var i = 0, l = this.faces.length; i < l; i++) {
+		for (var i = 0, l = this.faces.length; i < l; i ++) {
 
 			var f = this.faces[i];
 
@@ -240,14 +240,14 @@ THREE.ProxyGeometry.prototype.createFaceVertexNormalProxies = function(values) {
 
 	if (values) {
 
-		for (var i = 0, l = values.length; i < l; i++) {
+		for (var i = 0, l = values.length; i < l; i ++) {
 
 			var f = this.faces[i],
 			    v = values[i];
 
 			if (v.vertexNormals.length > 0) {
 
-				for (var j = 0, l2 = f.vertexNormals.length; j < l2; j++) {
+				for (var j = 0, l2 = f.vertexNormals.length; j < l2; j ++) {
 
 					f.vertexNormals[j].copy(v.vertexNormals[j]);
 
@@ -271,7 +271,7 @@ THREE.ProxyGeometry.prototype.createFaceVertexColorProxies = function(values) {
 
 		var colorarray = this.attributes[ 'color' ].array;
 
-		for (var i = 0, l = this.faces.length; i < l; i++) {
+		for (var i = 0, l = this.faces.length; i < l; i ++) {
 			var f = this.faces[i];
 
 			if ( this.attributes[ 'index' ] ) {
@@ -298,12 +298,12 @@ THREE.ProxyGeometry.prototype.createFaceVertexColorProxies = function(values) {
 
 	if (values) {
 
-		for (var i = 0, l = values.length; i < l; i++) {
+		for (var i = 0, l = values.length; i < l; i ++) {
 
 			var f = this.faces[i],
 			    v = values[i];
 
-			for (var j = 0, l2 = f.vertexColors.length; j < l2; j++) {
+			for (var j = 0, l2 = f.vertexColors.length; j < l2; j ++) {
 
 				if (v.vertexColors.length > 0) {
 
@@ -329,7 +329,7 @@ THREE.ProxyGeometry.prototype.createFaceVertexTangentProxies = function(values)
 
 		var tangentarray = this.attributes[ 'tangent' ].array;
 
-		for (var i = 0, l = this.faces.length; i < l; i++) {
+		for (var i = 0, l = this.faces.length; i < l; i ++) {
 
 			var f = this.faces[i];
 
@@ -346,14 +346,14 @@ THREE.ProxyGeometry.prototype.createFaceVertexTangentProxies = function(values)
 
 	if (values) {
 
-		for (var i = 0, l = values.length; i < l; i++) {
+		for (var i = 0, l = values.length; i < l; i ++) {
 
 			var f = this.faces[i],
 			    v = values[i];
 
 			if (v.vertexTangents.length > 0) {
 
-				for (var j = 0, l2 = f.vertexTangents.length; j < l2; j++) {
+				for (var j = 0, l2 = f.vertexTangents.length; j < l2; j ++) {
 
 					f.vertexTangents[j].copy(v.vertexTangents[j]);
 
@@ -384,7 +384,7 @@ THREE.ProxyGeometry.prototype.createUvProxies = function(values) {
 		var faces = this.faces;
 		var uvarray = this.attributes[ 'uv' ].array;
 
-		for (var i = 0, l = faces.length; i < l; i++) {
+		for (var i = 0, l = faces.length; i < l; i ++) {
 			var f = faces[i];
 
 			this.faceVertexUvs[0][i] = [];
@@ -408,9 +408,9 @@ THREE.ProxyGeometry.prototype.createUvProxies = function(values) {
 
 	if (values) {
 
-		for (var i = 0, l = values.length; i < l; i++) {
+		for (var i = 0, l = values.length; i < l; i ++) {
 
-			for (var j = 0, l2 = values[i].length; j < l2; j++) {
+			for (var j = 0, l2 = values[i].length; j < l2; j ++) {
 
 				var uv = values[i][j];
 				this.faceVertexUvs[0][i][j].copy(uv);
@@ -445,7 +445,7 @@ THREE.ProxyGeometry.prototype.createSkinIndexProxies = function(values) {
 
 	if (values) {
 
-		for (var i = 0; i < values.length; i++) {
+		for (var i = 0; i < values.length; i ++) {
 
 			this.skinIndices[i].copy(values[i]);
 
@@ -477,7 +477,7 @@ THREE.ProxyGeometry.prototype.createSkinWeightProxies = function(values) {
 
 	if (values) {
 
-		for (var i = 0; i < values.length; i++) {
+		for (var i = 0; i < values.length; i ++) {
 
 			this.skinWeights[i].copy(values[i]);
 
@@ -509,7 +509,7 @@ THREE.ProxyGeometry.prototype.createColorProxies = function(values) {
 
 	if (values) {
 
-		for (var i = 0; i < values.length; i++) {
+		for (var i = 0; i < values.length; i ++) {
 
 			this.colors[i].copy(values[i]);
 
@@ -585,7 +585,7 @@ THREE.ProxyGeometry.prototype.mergeVertices = function () {
 	// have to remove them from the geometry.
 	var faceIndicesToRemove = [];
 
-	for( i = 0, il = this.faces.length; i < il; i ++ ) {
+	for ( i = 0, il = this.faces.length; i < il; i ++ ) {
 
 		face = this.faces[ i ];
 

+ 2 - 2
examples/js/wip/benchmark/BoxGeometry2.js

@@ -86,9 +86,9 @@ THREE.BoxGeometry2 = function ( width, height, depth, widthSegments, heightSegme
 
 		}
 
-		for ( iy = 0; iy < gridY; iy++ ) {
+		for ( iy = 0; iy < gridY; iy ++ ) {
 
-			for ( ix = 0; ix < gridX; ix++ ) {
+			for ( ix = 0; ix < gridX; ix ++ ) {
 
 				var a = ix + gridX1 * iy;
 				var b = ix + gridX1 * ( iy + 1 );

+ 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 );

+ 1 - 1
examples/js/wip/proxies/MultiColor.js

@@ -12,7 +12,7 @@ THREE.MultiColor.prototype.constructor = THREE.MultiColor;
 
 THREE.MultiColor.prototype.setAll = function(axis, value) {
 
-	for (var i = 0, l = this.links.length; i < l; i++) {
+	for (var i = 0, l = this.links.length; i < l; i ++) {
 
 		this.links[i][axis] = value;
 

+ 1 - 1
examples/js/wip/proxies/MultiVector3.js

@@ -12,7 +12,7 @@ THREE.MultiVector3.prototype.constructor = THREE.MultiVector3;
 
 THREE.MultiVector3.prototype.setAll = function(axis, value) {
 
-	for (var i = 0, l = this.links.length; i < l; i++) {
+	for (var i = 0, l = this.links.length; i < l; i ++) {
 
 		this.links[i][axis] = value;
 

+ 2 - 2
src/core/Object3D.js

@@ -302,7 +302,7 @@ THREE.Object3D.prototype = {
 
 		if ( arguments.length > 1 ) {
 
-			for ( var i = 0; i < arguments.length; i++ ) {
+			for ( var i = 0; i < arguments.length; i ++ ) {
 
 				this.add( arguments[ i ] );
 
@@ -346,7 +346,7 @@ THREE.Object3D.prototype = {
 
 		if ( arguments.length > 1 ) {
 
-			for ( var i = 0; i < arguments.length; i++ ) {
+			for ( var i = 0; i < arguments.length; i ++ ) {
 
 				this.remove( arguments[ i ] );
 

+ 5 - 5
src/extras/FontUtils.js

@@ -156,7 +156,7 @@ THREE.FontUtils = {
 
 					x = outline[ i ++ ] * scaleX + offset;
 					y = outline[ i ++ ] * scaleY;
-					path.lineTo( x,y );
+					path.lineTo( x, y );
 					break;
 
 				case 'q':
@@ -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':
 
@@ -367,7 +367,7 @@ THREE.FontUtils.generateShapes = function ( text, parameters ) {
 
 				/* remove v from the remaining polygon */
 
-				for ( s = v, t = v + 1; t < nv; s++, t++ ) {
+				for ( s = v, t = v + 1; t < nv; s ++, t ++ ) {
 
 					verts[ s ] = verts[ t ];
 

+ 1 - 1
src/extras/ImageUtils.js

@@ -144,7 +144,7 @@ THREE.ImageUtils = {
 				points.push( [ - 1, 0, data[ ( y * width + lx ) * 4 ] / 255 * depth ] );
 				points.push( [ - 1, - 1, data[ ( ly * width + lx ) * 4 ] / 255 * depth ] );
 				points.push( [ 0, - 1, data[ ( ly * width + x ) * 4 ] / 255 * depth ] );
-				points.push( [  1, - 1, data[ ( ly * width + ux ) * 4 ] / 255 * depth ] );
+				points.push( [ 1, - 1, data[ ( ly * width + ux ) * 4 ] / 255 * depth ] );
 				points.push( [ 1, 0, data[ ( y * width + ux ) * 4 ] / 255 * depth ] );
 				points.push( [ 1, 1, data[ ( uy * width + ux ) * 4 ] / 255 * depth ] );
 				points.push( [ 0, 1, data[ ( uy * width + x ) * 4 ] / 255 * depth ] );

+ 2 - 2
src/extras/animation/Animation.js

@@ -28,7 +28,7 @@ THREE.Animation.prototype.keyTypes = [ "pos", "rot", "scl" ];
 THREE.Animation.prototype.play = function ( startTime, weight ) {
 
 	this.currentTime = startTime !== undefined ? startTime : 0;
-	this.weight = weight !== undefined ? weight: 1;
+	this.weight = weight !== undefined ? weight : 1;
 
 	this.isPlaying = true;
 
@@ -119,7 +119,7 @@ THREE.Animation.prototype.resetBlendWeights = function () {
 
 };
 
-THREE.Animation.prototype.update = (function(){
+THREE.Animation.prototype.update = (function() {
 
 	var points = [];
 	var target = new THREE.Vector3();

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

@@ -107,7 +107,7 @@ THREE.Curve.prototype.getLength = function () {
 
 THREE.Curve.prototype.getLengths = function ( divisions ) {
 
-	if ( ! divisions ) divisions = (this.__arcLengthDivisions) ? (this.__arcLengthDivisions): 200;
+	if ( ! divisions ) divisions = (this.__arcLengthDivisions) ? (this.__arcLengthDivisions) : 200;
 
 	if ( this.cacheArcLengths
 		&& ( this.cacheArcLengths.length == divisions + 1 )
@@ -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;
 
@@ -281,8 +281,8 @@ THREE.Curve.Utils = {
 	tangentCubicBezier: function (t, p0, p1, p2, p3 ) {
 
 		return - 3 * p0 * (1 - t) * (1 - t)  +
-			3 * p1 * (1 - t) * (1-t) - 6 *t *p1 * (1-t) +
-			6 * t *  p2 * (1-t) - 3 * t * t * p2 +
+			3 * p1 * (1 - t) * (1 - t) - 6 * t * p1 * (1 - t) +
+			6 * t *  p2 * (1 - t) - 3 * t * t * p2 +
 			3 * t * t * p3;
 
 	},

+ 1 - 1
src/extras/core/CurvePath.js

@@ -36,7 +36,7 @@ THREE.CurvePath.prototype.closePath = function() {
 	// and verify for vector3 (needs to implement equals)
 	// Add a line curve if start and end of lines are not connected
 	var startPoint = this.curves[0].getPoint(0);
-	var endPoint = this.curves[this.curves.length-1].getPoint(1);
+	var endPoint = this.curves[this.curves.length - 1].getPoint(1);
 	
 	if (! startPoint.equals(endPoint)) {
 		this.curves.push( new THREE.LineCurve(endPoint, startPoint) );

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

@@ -228,7 +228,7 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
 		action = item.action;
 		args = item.args;
 
-		switch( action ) {
+		switch ( action ) {
 
 		case THREE.PathActions.MOVE_TO:
 
@@ -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
 
@@ -520,7 +520,7 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) {
 		//  with the horizontal line through inPt, left of inPt
 		//  not counting lowerY endpoints of edges and whole edges on that line
 		var inside = false;
-		for( var p = polyLen - 1, q = 0; q < polyLen; p = q ++ ) {
+		for ( var p = polyLen - 1, q = 0; q < polyLen; p = q ++ ) {
 			var edgeLowPt  = inPolygon[ p ];
 			var edgeHighPt = inPolygon[ q ];
 

+ 12 - 12
src/extras/core/Shape.js

@@ -173,16 +173,16 @@ THREE.Shape.Utils = {
 				if ( perpSeg2 == 0 ) {
 					if ( ( inExcludeAdjacentSegs ) &&
 						 ( ( perpSeg1 == 0 ) || ( perpSeg1 == limit ) ) )		return [];
-					return  [ inSeg1Pt1 ];
+					return [ inSeg1Pt1 ];
 				}
 				if ( perpSeg2 == limit ) {
 					if ( ( inExcludeAdjacentSegs ) &&
 						 ( ( perpSeg1 == 0 ) || ( perpSeg1 == limit ) ) )		return [];
-					return  [ inSeg1Pt2 ];
+					return [ inSeg1Pt2 ];
 				}
 				// intersection at endpoint of segment#2?
-				if ( perpSeg1 == 0 )		return  [ inSeg2Pt1 ];
-				if ( perpSeg1 == limit )	return  [ inSeg2Pt2 ];
+				if ( perpSeg1 == 0 )		return [ inSeg2Pt1 ];
+				if ( perpSeg1 == limit )	return [ inSeg2Pt2 ];
 
 				// return real intersection point
 				var factorSeg1 = perpSeg2 / limit;
@@ -200,17 +200,17 @@ THREE.Shape.Utils = {
 				if ( seg1Pt && seg2Pt ) {
 					if ( (inSeg1Pt1.x != inSeg2Pt1.x) ||
 						 (inSeg1Pt1.y != inSeg2Pt1.y) )		return [];   	// they are distinct  points
-					return  [ inSeg1Pt1 ];                 					// they are the same point
+					return [ inSeg1Pt1 ];                 					// they are the same point
 				}
 				// segment#1  is a single point
 				if ( seg1Pt ) {
 					if (! point_in_segment_2D_colin( inSeg2Pt1, inSeg2Pt2, inSeg1Pt1 ) )		return [];		// but not in segment#2
-					return  [ inSeg1Pt1 ];
+					return [ inSeg1Pt1 ];
 				}
 				// segment#2  is a single point
 				if ( seg2Pt ) {
 					if (! point_in_segment_2D_colin( inSeg1Pt1, inSeg1Pt2, inSeg2Pt1 ) )		return [];		// but not in segment#1
-					return  [ inSeg2Pt1 ];
+					return [ inSeg2Pt1 ];
 				}
 
 				// they are collinear segments, which might overlap
@@ -341,7 +341,7 @@ THREE.Shape.Utils = {
 				// checks for intersections with shape edges
 				var sIdx, nextIdx, intersection;
 				for ( sIdx = 0; sIdx < shape.length; sIdx ++ ) {
-					nextIdx = sIdx+1; nextIdx %= shape.length;
+					nextIdx = sIdx + 1; nextIdx %= shape.length;
 					intersection = intersect_segments_2D( inShapePt, inHolePt, shape[sIdx], shape[nextIdx], true );
 					if ( intersection.length > 0 )		return	true;
 				}
@@ -358,7 +358,7 @@ THREE.Shape.Utils = {
 				for ( ihIdx = 0; ihIdx < indepHoles.length; ihIdx ++ ) {
 					chkHole = holes[indepHoles[ihIdx]];
 					for ( hIdx = 0; hIdx < chkHole.length; hIdx ++ ) {
-						nextIdx = hIdx+1; nextIdx %= chkHole.length;
+						nextIdx = hIdx + 1; nextIdx %= chkHole.length;
 						intersection = intersect_segments_2D( inShapePt, inHolePt, chkHole[hIdx], chkHole[nextIdx], true );
 						if ( intersection.length > 0 )		return	true;
 					}
@@ -410,12 +410,12 @@ THREE.Shape.Utils = {
 							if ( intersectsHoleEdge( shapePt, holePt ) )		continue;
 
 							holeIndex = h2;
-							indepHoles.splice(h,1);
+							indepHoles.splice(h, 1);
 
-							tmpShape1 = shape.slice( 0, shapeIndex+1 );
+							tmpShape1 = shape.slice( 0, shapeIndex + 1 );
 							tmpShape2 = shape.slice( shapeIndex );
 							tmpHole1 = hole.slice( holeIndex );
-							tmpHole2 = hole.slice( 0, holeIndex+1 );
+							tmpHole2 = hole.slice( 0, holeIndex + 1 );
 
 							shape = tmpShape1.concat( tmpHole1 ).concat( tmpHole2 ).concat( tmpShape2 );
 

+ 2 - 2
src/extras/curves/SplineCurve.js

@@ -21,8 +21,8 @@ THREE.SplineCurve.prototype.getPoint = function ( t ) {
 
 	var point0 = points[ intPoint == 0 ? intPoint : intPoint - 1 ]
 	var point1 = points[ intPoint ]
-	var point2 = points[ intPoint > points.length - 2 ? points.length -1 : intPoint + 1 ]
-	var point3 = points[ intPoint > points.length - 3 ? points.length -1 : intPoint + 2 ]
+	var point2 = points[ intPoint > points.length - 2 ? points.length - 1 : intPoint + 1 ]
+	var point3 = points[ intPoint > points.length - 3 ? points.length - 1 : intPoint + 2 ]
 
 	var vector = new THREE.Vector2();
 

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

@@ -163,7 +163,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 
 	var contour = vertices; // vertices has all points but contour has only points of circumference
 
-	for ( h = 0, hl = holes.length;  h < hl; h ++ ) {
+	for ( h = 0, hl = holes.length; h < hl; h ++ ) {
 
 		ahole = holes[ h ];
 
@@ -296,7 +296,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 		var pt_j = contour[ j ];
 		var pt_k = contour[ k ];
 
-		contourMovements[ i ]= getBevelVec( contour[ i ], contour[ j ], contour[ k ] );
+		contourMovements[ i ] = getBevelVec( contour[ i ], contour[ j ], contour[ k ] );
 
 	}
 
@@ -314,7 +314,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 			if ( k === il ) k = 0;
 
 			//  (j)---(i)---(k)
-			oneHoleMovements[ i ]= getBevelVec( ahole[ i ], ahole[ j ], ahole[ k ] );
+			oneHoleMovements[ i ] = getBevelVec( ahole[ i ], ahole[ j ], ahole[ k ] );
 
 		}
 
@@ -333,7 +333,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 		z = bevelThickness * ( 1 - t );
 
 		//z = bevelThickness * t;
-		bs = bevelSize * ( Math.sin ( t * Math.PI/2 ) ) ; // curved
+		bs = bevelSize * ( Math.sin ( t * Math.PI / 2 ) ) ; // curved
 		//bs = bevelSize * t ; // linear
 
 		// contract shape
@@ -433,7 +433,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 		t = b / bevelSegments;
 		z = bevelThickness * ( 1 - t );
 		//bs = bevelSize * ( 1-Math.sin ( ( 1 - t ) * Math.PI/2 ) );
-		bs = bevelSize * Math.sin ( t * Math.PI/2 ) ;
+		bs = bevelSize * Math.sin ( t * Math.PI / 2 ) ;
 
 		// contract shape
 
@@ -496,7 +496,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 			for ( i = 0; i < flen; i ++ ) {
 
 				face = faces[ i ];
-				f3( face[ 2 ]+ offset, face[ 1 ]+ offset, face[ 0 ] + offset );
+				f3( face[ 2 ] + offset, face[ 1 ] + offset, face[ 0 ] + offset );
 
 			}
 
@@ -543,7 +543,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 		sidewalls( contour, layeroffset );
 		layeroffset += contour.length;
 
-		for ( h = 0, hl = holes.length;  h < hl; h ++ ) {
+		for ( h = 0, hl = holes.length; h < hl; h ++ ) {
 
 			ahole = holes[ h ];
 			sidewalls( ahole, layeroffset );
@@ -560,7 +560,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 		var j, k;
 		i = contour.length;
 
-		while ( --i >= 0 ) {
+		while ( -- i >= 0 ) {
 
 			j = i;
 			k = i - 1;
@@ -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 ] ] );
 
 	}
 

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

@@ -252,17 +252,17 @@ THREE.TubeGeometry.FrenetFrames = function ( path, segments, closed ) {
 
 	for ( i = 1; i < numpoints; i ++ ) {
 
-		normals[ i ] = normals[ i-1 ].clone();
+		normals[ i ] = normals[ i - 1 ].clone();
 
-		binormals[ i ] = binormals[ i-1 ].clone();
+		binormals[ i ] = binormals[ i - 1 ].clone();
 
-		vec.crossVectors( tangents[ i-1 ], tangents[ i ] );
+		vec.crossVectors( tangents[ i - 1 ], tangents[ i ] );
 
 		if ( vec.length() > epsilon ) {
 
 			vec.normalize();
 
-			theta = Math.acos( THREE.Math.clamp( tangents[ i-1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors
+			theta = Math.acos( THREE.Math.clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors
 
 			normals[ i ].applyMatrix4( mat.makeRotationAxis( vec, theta ) );
 
@@ -277,10 +277,10 @@ THREE.TubeGeometry.FrenetFrames = function ( path, segments, closed ) {
 
 	if ( closed ) {
 
-		theta = Math.acos( THREE.Math.clamp( normals[ 0 ].dot( normals[ numpoints-1 ] ), - 1, 1 ) );
+		theta = Math.acos( THREE.Math.clamp( normals[ 0 ].dot( normals[ numpoints - 1 ] ), - 1, 1 ) );
 		theta /= ( numpoints - 1 );
 
-		if ( tangents[ 0 ].dot( vec.crossVectors( normals[ 0 ], normals[ numpoints-1 ] ) ) > 0 ) {
+		if ( tangents[ 0 ].dot( vec.crossVectors( normals[ 0 ], normals[ numpoints - 1 ] ) ) > 0 ) {
 
 			theta = - theta;
 

+ 1 - 1
src/lights/DirectionalLight.js

@@ -47,7 +47,7 @@ THREE.DirectionalLight = function ( color, intensity ) {
 	this.shadowCascadeHeight = [ 512, 512, 512 ];
 
 	this.shadowCascadeNearZ = [ - 1.000, 0.990, 0.998 ];
-	this.shadowCascadeFarZ  = [  0.990, 0.998, 1.000 ];
+	this.shadowCascadeFarZ  = [ 0.990, 0.998, 1.000 ];
 
 	this.shadowCascadeArray = [];
 

+ 1 - 1
src/loaders/BinaryTextureLoader.js

@@ -34,7 +34,7 @@ THREE.BinaryTextureLoader.prototype = {
 
 				texture.image = texData.image;
 
-			} else if ( undefined !== texData.data ){
+			} else if ( undefined !== texData.data ) {
 
 				texture.image.width = texData.width;
 				texture.image.height = texData.height;

+ 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/Ray.js

@@ -345,7 +345,7 @@ THREE.Ray.prototype = {
 
 	}(),
 
-	intersectBox: function ( box , optionalTarget ) {
+	intersectBox: function ( box, optionalTarget ) {
 
 		// http://www.scratchapixel.com/lessons/3d-basic-lessons/lesson-7-intersecting-simple-shapes/ray-box-intersection/
 

+ 2 - 2
src/math/Sphere.js

@@ -26,7 +26,7 @@ THREE.Sphere.prototype = {
 
 		var box = new THREE.Box3();
 
-		return function ( points, optionalCenter )  {
+		return function ( points, optionalCenter ) {
 
 			var center = this.center;
 
@@ -52,7 +52,7 @@ THREE.Sphere.prototype = {
 
 			return this;
 
- 		};
+		};
 
 	}(),
 

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác