Browse Source

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

Fordy 10 years ago
parent
commit
423c07d52b
51 changed files with 311 additions and 214 deletions
  1. 16 4
      build/three.js
  2. 7 7
      build/three.min.js
  3. 7 3
      docs/api/materials/MeshPhongMaterial.html
  4. 9 0
      docs/api/objects/Bone.html
  5. 8 0
      docs/api/objects/LOD.html
  6. 8 0
      docs/api/objects/LensFlare.html
  7. 8 0
      docs/api/objects/Line.html
  8. 9 0
      docs/api/objects/LineSegments.html
  9. 8 0
      docs/api/objects/Mesh.html
  10. 8 0
      docs/api/objects/MorphAnimMesh.html
  11. 7 0
      docs/api/objects/PointCloud.html
  12. 4 0
      docs/api/objects/Skeleton.html
  13. 8 0
      docs/api/objects/SkinnedMesh.html
  14. 8 1
      docs/api/objects/Sprite.html
  15. 1 3
      examples/js/cameras/CombinedCamera.js
  16. 8 8
      examples/js/loaders/ColladaLoader.js
  17. 15 74
      examples/js/shaders/NormalDisplacementShader.js
  18. 44 47
      examples/webgl_materials_normaldisplacementmap.html
  19. 1 2
      src/cameras/OrthographicCamera.js
  20. 2 3
      src/cameras/PerspectiveCamera.js
  21. 27 4
      src/core/BufferGeometry.js
  22. 2 2
      src/core/Geometry.js
  23. 2 2
      src/extras/core/Curve.js
  24. 2 2
      src/extras/core/CurvePath.js
  25. 7 8
      src/extras/core/Path.js
  26. 4 4
      src/extras/core/Shape.js
  27. 7 7
      src/extras/geometries/ExtrudeGeometry.js
  28. 2 2
      src/extras/geometries/TubeGeometry.js
  29. 1 1
      src/extras/helpers/EdgesHelper.js
  30. 1 1
      src/loaders/JSONLoader.js
  31. 1 1
      src/loaders/ObjectLoader.js
  32. 1 1
      src/materials/Material.js
  33. 6 0
      src/materials/MeshPhongMaterial.js
  34. 1 1
      src/math/Box3.js
  35. 3 3
      src/math/Triangle.js
  36. 1 1
      src/objects/LensFlare.js
  37. 1 1
      src/objects/SkinnedMesh.js
  38. 8 0
      src/renderers/WebGLRenderer.js
  39. 9 0
      src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl
  40. 5 0
      src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl
  41. 2 2
      src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl
  42. 1 1
      src/renderers/shaders/ShaderChunk/map_fragment.glsl
  43. 1 1
      src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl
  44. 1 1
      src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl
  45. 1 1
      src/renderers/shaders/ShaderChunk/uv_vertex.glsl
  46. 14 13
      src/renderers/shaders/ShaderLib.js
  47. 6 0
      src/renderers/shaders/UniformsLib.js
  48. 4 0
      src/renderers/webgl/WebGLProgram.js
  49. 1 1
      src/renderers/webgl/WebGLShadowMap.js
  50. 1 1
      src/renderers/webgl/plugins/LensFlarePlugin.js
  51. 2 0
      utils/build/includes/common.json

File diff suppressed because it is too large
+ 16 - 4
build/three.js


File diff suppressed because it is too large
+ 7 - 7
build/three.min.js


+ 7 - 3
docs/api/materials/MeshPhongMaterial.html

@@ -27,6 +27,7 @@
 		map — Set texture map. Default is null <br />
 		lightMap — Set light map. Default is null.<br />
 		aoMap — Set ao map. Default is null.<br />
+		emissiveMap — Set emissive map. Default is null.<br />
 		specularMap — Set specular map. Default is null.<br />
 		alphaMap — Set alpha map. Default is null.<br />
 		envMap — Set env map. Default is null.<br />
@@ -76,13 +77,16 @@
 		</div> 
 
 		<h3>[property:Texture map]</h3>
-		<div>Set color texture map. Default is null.</div>
+		<div>Set color texture map. Default is null. The texture map color is modulated by the diffuse color.</div>
 
 		<h3>[property:Texture lightMap]</h3>
-		<div>Set light map. Default is null.</div>
+		<div>Set light map. Default is null. The lightMap requires a second set of UVs.</div>
 
 		<h3>[property:Texture aoMap]</h3>
-		<div>Set ambient occlusion map. Default is null.</div>
+		<div>Set ambient occlusion map. Default is null. The aoMap requires a second set of UVs.</div>
+
+		<h3>[property:Texture emissiveMap]</h3>
+		<div>Set emisssive (glow) map. Default is null. The emissive map color is modulated by the emissive color. If you have an emissive map, be sure to set the emissive color to something other than black.</div>
 
 		<h3>[property:Texture bumpMap]</h3>
 		<div>

+ 9 - 0
docs/api/objects/Bone.html

@@ -41,6 +41,15 @@
 		An optional reference to the [page:SkinnedMesh].
 		</div>
 
+		<h2>Methods</h2>
+
+		<h3>[method:Object3D clone]([page:Object3D object])</h3>
+		<div>
+		object -- (optional) Object3D which needs to be cloned. If undefined, clone method will create a new cloned Bone Object.
+		</div>
+		<div>
+		Clone a Bone Object.
+		</div>
 
 		<h2>Source</h2>
 

+ 8 - 0
docs/api/objects/LOD.html

@@ -75,6 +75,14 @@
 		<div>
 		Update the visiblility of the level of detail based on the distance from the camera.
 		</div>
+		
+		<h3>[method:Object3D clone]([page:Object3D object])</h3>
+		<div>
+		object -- (optional) Object3D which needs to be cloned. If undefined, clone method will create a new cloned LOD Object.
+		</div>
+		<div>
+		Clone a LOD Object.
+		</div>
 
 		<h2>Source</h2>
 

+ 8 - 0
docs/api/objects/LensFlare.html

@@ -65,6 +65,14 @@
 		Updates the lens flare based on the [page:LensFlare.positionScreen positionScreen] property.
 		</div>
 
+		<h3>[method:Object3D clone]([page:Object3D object])</h3>
+		<div>
+		object -- (optional) Object3D which needs to be cloned. If undefined, clone method will create a new cloned LensFlare Object.
+		</div>
+		<div>
+		Clone a LensFlare Object.
+		</div>
+
 		<h2>Source</h2>
 
 		[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]

+ 8 - 0
docs/api/objects/Line.html

@@ -63,6 +63,14 @@
 		<div>
 		Get intersections between a casted ray and this Line. [page:Raycaster.intersectObject] will call this method.
 		</div>
+		
+		<h3>[method:Object3D clone]([page:Object3D object])</h3>
+		<div>
+		object -- (optional) Object3D which needs to be cloned. If undefined, clone method will create a new cloned Line Object.
+		</div>
+		<div>
+		Clone a Line Object.
+		</div>
 
 		<h2>Source</h2>
 

+ 9 - 0
docs/api/objects/LineSegments.html

@@ -45,6 +45,15 @@
 		<div>
 		Get intersections between a casted ray and this Line. [page:Raycaster.intersectObject] will call this method.
 		</div>
+		
+		<h3>[method:Object3D clone]([page:Object3D object])</h3>
+		<div>
+		object -- (optional) Object3D which needs to be cloned. If undefined, clone method will create a new cloned LineSegments Object.
+		</div>
+		<div>
+		Clone a LineSegments Object.
+		</div>
+
 
 		<h2>Source</h2>
 

+ 8 - 0
docs/api/objects/Mesh.html

@@ -96,6 +96,14 @@
 		<div>
 		Get intersections between a casted ray and this mesh. [page:Raycaster.intersectObject] will call this method.
 		</div>
+		
+		<h3>[method:Object3D clone]([page:Object3D object])</h3>
+		<div>
+		object -- (optional) Object3D which needs to be cloned. If undefined, clone method will create a new cloned Mesh Object.
+		</div>
+		<div>
+		Clone a Mesh Object.
+		</div>
 
 
 		<h2>Source</h2>

+ 8 - 0
docs/api/objects/MorphAnimMesh.html

@@ -165,6 +165,14 @@
 		Defines an animation. Sets the geometry.animations[label] to be an object with the start and end properties.
 		</div>
 
+		<h3>[method:Object3D clone]([page:Object3D object])</h3>
+		<div>
+		object -- (optional) Object3D which needs to be cloned. If undefined, clone method will create a new cloned MorphAnimMesh Object.
+		</div>
+		<div>
+		Clone a MorphAnimMesh Object.
+		</div>
+		
 		<h2>Source</h2>
 
 		[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]

+ 7 - 0
docs/api/objects/PointCloud.html

@@ -47,6 +47,13 @@
 		Get intersections between a casted ray and this PointCloud. [page:Raycaster.intersectObject] will call this method.
 		</div>
 
+		<h3>[method:Object3D clone]([page:Object3D object])</h3>
+		<div>
+		object -- (optional) Object3D which needs to be cloned. If undefined, clone method will create a new cloned PointCloud Object.
+		</div>
+		<div>
+		Clone a PointCloud Object.
+		</div>
 
 		<h2>Source</h2>
 

+ 4 - 0
docs/api/objects/Skeleton.html

@@ -120,6 +120,10 @@
 		This is called automatically by the [page:WebGLRenderer] if the skeleton is used with a [page:SkinnedMesh].
 		</div>
 		
+		<h3>[method:Skeleton clone]()</h3>
+		<div>
+		Clone a Skeleton Object.
+		</div>
 		
 		<h2>Source</h2>
 

+ 8 - 0
docs/api/objects/SkinnedMesh.html

@@ -131,6 +131,14 @@
 		This method adds the bone to the skinned mesh when it is provided. It creates a new bone and adds that when no bone is given.
 		</div>
 
+		<h3>[method:Object3D clone]([page:Object3D object])</h3>
+		<div>
+		object -- (optional) Object3D which needs to be cloned. If undefined, clone method will create a new cloned SkinnedMesh Object.
+		</div>
+		<div>
+		Clone a SkinnedMesh Object.
+		</div>
+		
 		<h2>Source</h2>
 
 		[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]

+ 8 - 1
docs/api/objects/Sprite.html

@@ -47,7 +47,14 @@
                 <div>
                 This creates a new clone of the sprite.
                 </div>
-
+		
+		<h3>[method:Object3D clone]([page:Object3D object])</h3>
+		<div>
+		object -- (optional) Object3D which needs to be cloned. If undefined, clone method will create a new cloned Sprite Object.
+		</div>
+		<div>
+		Clone a Sprite Object.
+		</div>
 
 		<h2>Source</h2>
 

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

@@ -29,8 +29,6 @@ THREE.CombinedCamera = function ( width, height, fov, near, far, orthoNear, orth
 
 	this.toPerspective();
 
-	var aspect = width / height;
-
 };
 
 THREE.CombinedCamera.prototype = Object.create( THREE.Camera.prototype );
@@ -129,7 +127,7 @@ THREE.CombinedCamera.prototype.setFov = function( fov ) {
 
 };
 
-// For mantaining similar API with PerspectiveCamera
+// For maintaining similar API with PerspectiveCamera
 
 THREE.CombinedCamera.prototype.updateProjectionMatrix = function() {
 

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

@@ -635,7 +635,7 @@ THREE.ColladaLoader = function () {
 		var bones = [];
 		setupSkeleton( skeleton, bones, -1 );
 		setupSkinningMatrices( bones, skinController.skin );
-		v = new THREE.Vector3();
+		var v = new THREE.Vector3();
 		var skinned = [];
 
 		for (var i = 0; i < geometry.vertices.length; i ++) {
@@ -648,14 +648,14 @@ THREE.ColladaLoader = function () {
 
 			if ( bones[ i ].type != 'JOINT' ) continue;
 
-			for ( j = 0; j < bones[ i ].weights.length; j ++ ) {
+			for ( var j = 0; j < bones[ i ].weights.length; j ++ ) {
 
-				w = bones[ i ].weights[ j ];
-				vidx = w.index;
-				weight = w.weight;
+				var w = bones[ i ].weights[ j ];
+				var vidx = w.index;
+				var weight = w.weight;
 
-				o = geometry.vertices[vidx];
-				s = skinned[vidx];
+				var o = geometry.vertices[vidx];
+				var s = skinned[vidx];
 
 				v.x = o.x;
 				v.y = o.y;
@@ -5188,7 +5188,7 @@ THREE.ColladaLoader = function () {
 
 	function loadTextureImage ( texture, url ) {
 
-		loader = new THREE.ImageLoader();
+		var loader = new THREE.ImageLoader();
 
 		loader.load( url, function ( image ) {
 

+ 15 - 74
examples/js/shaders/NormalDisplacementShader.js

@@ -46,8 +46,6 @@ THREE.NormalDisplacementShader = {
 		"uOffset" : { type: "v2", value: new THREE.Vector2( 0, 0 ) },
 		"uRepeat" : { type: "v2", value: new THREE.Vector2( 1, 1 ) },
 
-		"wrapRGB" : { type: "v3", value: new THREE.Vector3( 1, 1, 1 ) }
-
 		}
 
 	] ),
@@ -117,12 +115,6 @@ THREE.NormalDisplacementShader = {
 
 		"#endif",
 
-		"#ifdef WRAP_AROUND",
-
-		"	uniform vec3 wrapRGB;",
-
-		"#endif",
-
 		"varying vec3 vWorldPosition;",
 		"varying vec3 vViewPosition;",
 
@@ -132,9 +124,11 @@ THREE.NormalDisplacementShader = {
 		THREE.ShaderChunk[ "logdepthbuf_pars_fragment" ],
 
 		"void main() {",
+
 			THREE.ShaderChunk[ "logdepthbuf_fragment" ],
 
-		"	vec3 outgoingLight = vec3( 0.0 );",	// outgoing light does not have an alpha, the surface does
+		"	vec3 outgoingLight = vec3( 0.0 );",
+
 		"	vec4 diffuseColor = vec4( diffuse, opacity );",
 
 		"	vec3 specularTex = vec3( 1.0 );",
@@ -162,22 +156,11 @@ THREE.NormalDisplacementShader = {
 
 		"	if( enableAO ) {",
 
-		"		#ifdef GAMMA_INPUT",
-
-		"			vec4 aoColor = texture2D( tAO, vUv );",
-		"			aoColor.xyz *= aoColor.xyz;",
-
-		"			diffuseColor.rgb *= aoColor.xyz;",
-
-		"		#else",
-
-		"			diffuseColor.rgb *= texture2D( tAO, vUv ).xyz;",
-
-		"		#endif",
-
+		"		diffuseColor.rgb *= texture2D( tAO, vUv ).xyz;", // actually, the AOmap should be modulating ambient light sources only,
+																 // and should use the second set of UVs, as is done elsewhere in the library
 		"	}",
 
-		THREE.ShaderChunk[ "alphatest_fragment" ],
+			THREE.ShaderChunk[ "alphatest_fragment" ],
 
 		"	if( enableSpecular )",
 		"		specularTex = texture2D( tSpecular, vUv ).xyz;",
@@ -187,7 +170,7 @@ THREE.NormalDisplacementShader = {
 
 		"	#ifdef FLIP_SIDED",
 
-		"		finalNormal = -finalNormal;",
+		"		finalNormal = - finalNormal;",
 
 		"	#endif",
 
@@ -214,18 +197,7 @@ THREE.NormalDisplacementShader = {
 
 					// diffuse
 
-		"			#ifdef WRAP_AROUND",
-
-		"				float pointDiffuseWeightFull = max( dot( normal, pointVector ), 0.0 );",
-		"				float pointDiffuseWeightHalf = max( 0.5 * dot( normal, pointVector ) + 0.5, 0.0 );",
-
-		"				vec3 pointDiffuseWeight = mix( vec3( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );",
-
-		"			#else",
-
-		"				float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );",
-
-		"			#endif",
+		"			float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );",
 
 		"			totalDiffuseLight += pointDistance * pointLightColor[ i ] * pointDiffuseWeight;",
 
@@ -267,18 +239,8 @@ THREE.NormalDisplacementShader = {
 
 						// diffuse
 
-		"				#ifdef WRAP_AROUND",
-
-		"					float spotDiffuseWeightFull = max( dot( normal, spotVector ), 0.0 );",
-		"					float spotDiffuseWeightHalf = max( 0.5 * dot( normal, spotVector ) + 0.5, 0.0 );",
 
-		"					vec3 spotDiffuseWeight = mix( vec3( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );",
-
-		"				#else",
-
-		"					float spotDiffuseWeight = max( dot( normal, spotVector ), 0.0 );",
-
-		"				#endif",
+		"				float spotDiffuseWeight = max( dot( normal, spotVector ), 0.0 );",
 
 		"				totalDiffuseLight += spotDistance * spotLightColor[ i ] * spotDiffuseWeight * spotEffect;",
 
@@ -303,25 +265,14 @@ THREE.NormalDisplacementShader = {
 
 		"	#if MAX_DIR_LIGHTS > 0",
 
-		"		for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {",
+		"		for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {",
 
 		"			vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );",
 		"			vec3 dirVector = normalize( lDirection.xyz );",
 
 					// diffuse
 
-		"			#ifdef WRAP_AROUND",
-
-		"				float directionalLightWeightingFull = max( dot( normal, dirVector ), 0.0 );",
-		"				float directionalLightWeightingHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );",
-
-		"				vec3 dirDiffuseWeight = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );",
-
-		"			#else",
-
-		"				float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );",
-
-		"			#endif",
+		"			float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );",
 
 		"			totalDiffuseLight += directionalLightColor[ i ] * dirDiffuseWeight;",
 
@@ -360,26 +311,16 @@ THREE.NormalDisplacementShader = {
 
 					// specular (sky light)
 
-
 		"			vec3 hemiHalfVectorSky = normalize( lVector + viewPosition );",
 		"			float hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;",
 		"			float hemiSpecularWeightSky = specularTex.r * max( pow( max( hemiDotNormalHalfSky, 0.0 ), shininess ), 0.0 );",
 
-					// specular (ground light)
-
-		"			vec3 lVectorGround = -lVector;",
-
-		"			vec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );",
-		"			float hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;",
-		"			float hemiSpecularWeightGround = specularTex.r * max( pow( max( hemiDotNormalHalfGround, 0.0 ), shininess ), 0.0 );",
-
-		"			float dotProductGround = dot( normal, lVectorGround );",
+					//
 
 		"			float specularNormalization = ( shininess + 2.0 ) / 8.0;",
 
 		"			vec3 schlickSky = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, hemiHalfVectorSky ), 0.0 ), 5.0 );",
-		"			vec3 schlickGround = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 0.0 ), 5.0 );",
-		"			totalSpecularLight += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );",
+		"			totalSpecularLight += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) );",
 
 		"		}",
 
@@ -427,7 +368,7 @@ THREE.NormalDisplacementShader = {
 			THREE.ShaderChunk[ "linear_to_gamma_fragment" ],
 			THREE.ShaderChunk[ "fog_fragment" ],
 
-		"	gl_FragColor = vec4( outgoingLight, diffuseColor.a );",	// TODO, this should be pre-multiplied to allow for bright highlights on very transparent objects
+		"	gl_FragColor = vec4( outgoingLight, diffuseColor.a );",
 
 		"}"
 
@@ -557,7 +498,7 @@ THREE.NormalDisplacementShader = {
 			//
 
 		"	vWorldPosition = worldPosition.xyz;",
-		"	vViewPosition = -mvPosition.xyz;",
+		"	vViewPosition = - mvPosition.xyz;",
 
 			// shadows
 

+ 44 - 47
examples/webgl_materials_normaldisplacementmap.html

@@ -58,16 +58,13 @@
 
 			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
 
-			var statsEnabled = true;
-
-			var container, stats, loader;
+			var stats, loader;
 
 			var camera, scene, renderer;
 
-			var mesh, zmesh, geometry;
 			var mesh1, mesh2;
 
-			var spotLight, pointLight, ambientLight;
+			var pointLight;
 
 			var mouseX = 0;
 			var mouseY = 0;
@@ -84,17 +81,19 @@
 
 			function init() {
 
-				container = document.createElement( 'div' );
+				var container = document.createElement( 'div' );
 				document.body.appendChild( container );
 
-				camera = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, -10000, 10000 );
-				camera.position.z = 1500;
-
 				scene = new THREE.Scene();
 
+				var width = 500;
+				var aspect = window.innerWidth / window.innerHeight;
+				camera = new THREE.OrthographicCamera( - width * aspect, width * aspect, width, - width, 1, 10000 );
+				camera.position.z = 1500;
+
 				// LIGHTS
 
-				ambientLight = new THREE.AmbientLight( 0x111111 );
+				var ambientLight = new THREE.AmbientLight( 0x111111 );
 				scene.add( ambientLight );
 
 				pointLight = new THREE.PointLight( 0xff0000 );
@@ -102,39 +101,27 @@
 				pointLight.distance = 4000;
 				scene.add( pointLight );
 
-				pointLight2 = new THREE.PointLight( 0xff5500 );
+				var pointLight2 = new THREE.PointLight( 0xff5500 );
 				pointLight2.position.z = 1000;
-				pointLight2.distance = 2000;
 				scene.add( pointLight2 );
 
-				pointLight3 = new THREE.PointLight( 0x0000ff );
+				var pointLight3 = new THREE.PointLight( 0x0000ff );
 				pointLight3.position.x = -1000;
 				pointLight3.position.z = 1000;
-				pointLight3.distance = 2000;
 				scene.add( pointLight3 );
 
-				spotLight = new THREE.SpotLight( 0xaaaaaa );
+				var spotLight = new THREE.SpotLight( 0xaaaaaa );
 				spotLight.position.set( 1000, 500, 1000 );
 				spotLight.castShadow = true;
 				spotLight.shadowCameraNear = 500;
 				spotLight.shadowCameraFov = 70;
-				spotLight.shadowBias = 0.001;
+				spotLight.shadowBias = - 0.001;
 				spotLight.shadowMapWidth = 1024;
 				spotLight.shadowMapHeight = 1024;
+				spotLight.shadowDarkness = 0.5;
 				scene.add( spotLight );
 
-				directionalLight2 = new THREE.DirectionalLight( 0xaaff33, 0 );
-				directionalLight2.position.set( -1, 1, 0.5 ).normalize();
-				//scene.add( directionalLight2 );
-
-				directionalLight3 = new THREE.DirectionalLight( 0xaaff33 );
-				directionalLight3.position.set( -1, 1, 0.5 ).normalize();
-				//scene.add( directionalLight3 );
-
-
-				// light representation
-
-				var sphere = new THREE.SphereGeometry( 100, 16, 8 );
+				// env map
 
 				var path = "textures/cube/SwedishRoyalCastle/";
 				var format = '.jpg';
@@ -144,7 +131,7 @@
 						path + 'pz' + format, path + 'nz' + format
 					];
 
-				var reflectionCube = THREE.ImageUtils.loadTextureCube( urls );
+				var reflectionCube = THREE.ImageUtils.loadTextureCube( urls, THREE.CubeReflectionMapping );
 
 				// common material parameters
 
@@ -168,7 +155,7 @@
 				uniforms[ "uDisplacementBias" ].value = - 0.428408;
 				uniforms[ "uDisplacementScale" ].value = 2.436143;
 
-				uniforms[ "uNormalScale" ].value.y = -1;
+				uniforms[ "uNormalScale" ].value.y = - 1;
 
 				uniforms[ "diffuse" ].value.setHex( diffuse );
 				uniforms[ "specular" ].value.setHex( specular );
@@ -176,13 +163,21 @@
 				uniforms[ "shininess" ].value = shininess;
 
 				uniforms[ "tCube" ].value = reflectionCube;
-				uniforms[ "reflectivity" ].value = 0.1;
+				uniforms[ "reflectivity" ].value = 0.2;
 
-				var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights: true, fog: false };
-				var material1 = new THREE.ShaderMaterial( parameters );
+				var defines = {};
+				defines[ "ENVMAP_MODE_REFLECTION" ] = "";
+
+				var parameters = {
+					defines: defines,
+					uniforms: uniforms,
+					vertexShader: shader.vertexShader,
+					fragmentShader: shader.fragmentShader,
+					lights: true,
+					fog: false
+				};
 
-				// Ensure that ENVMAP_MODE_REFLECTION is defined in shader
-				material1.envMap = reflectionCube;
+				var material1 = new THREE.ShaderMaterial( parameters );
 
 				var material2 = new THREE.MeshPhongMaterial( {
 					color: diffuse,
@@ -190,9 +185,11 @@
 					shininess: shininess,
 					normalMap: uniforms[ "tNormal" ].value,
 					normalScale: uniforms[ "uNormalScale" ].value,
+					aoMap: uniforms[ "tAO" ].value,
+					aoMapIntensity: 1,
 					envMap: reflectionCube,
 					combine: THREE.MixOperation,
-					reflectivity: 0.1
+					reflectivity: 0.2
 				} );
 
 				//
@@ -219,22 +216,19 @@
 				renderer.shadowMap.enabled = true;
 				renderer.shadowMap.type = THREE.PCFShadowMap;
 
-
 				//
 
 				var description = "normal + ao" + ( renderer.supportsVertexTextures() ? " + displacement + environment + shadow" : " + <strike>displacement</strike>" );
 				document.getElementById( "description" ).innerHTML = description;
 				document.getElementById( "vt" ).style.display = renderer.supportsVertexTextures() ? "none" : "block";
 
-				if ( statsEnabled ) {
-
-					stats = new Stats();
-					stats.domElement.style.position = 'absolute';
-					stats.domElement.style.top = '0px';
-					stats.domElement.style.zIndex = 100;
-					container.appendChild( stats.domElement );
+				//
 
-				}
+				stats = new Stats();
+				stats.domElement.style.position = 'absolute';
+				stats.domElement.style.top = '0px';
+				stats.domElement.style.zIndex = 100;
+				container.appendChild( stats.domElement );
 
 				//
 
@@ -260,7 +254,9 @@
 
 			function createScene( geometry, scale, material1, material2 ) {
 
-				geometry.computeTangents();
+				geometry.computeTangents(); // attribute tangents are required for NormalDisplacementShader
+
+				geometry.faceVertexUvs[ 1 ] = geometry.faceVertexUvs[ 0 ]; // 2nd set of UVs required for aoMap with MeshPhongMaterial
 
 				mesh1 = new THREE.Mesh( geometry, material1 );
 				mesh1.position.x = - scale * 12;
@@ -294,7 +290,8 @@
 				requestAnimationFrame( animate );
 
 				render();
-				if ( statsEnabled ) stats.update();
+
+				stats.update();
 
 			}
 

+ 1 - 2
src/cameras/OrthographicCamera.js

@@ -52,8 +52,6 @@ THREE.OrthographicCamera.prototype.clone = function () {
 	camera.near = this.near;
 	camera.far = this.far;
 
-	camera.projectionMatrix.copy( this.projectionMatrix );
-
 	return camera;
 };
 
@@ -61,6 +59,7 @@ THREE.OrthographicCamera.prototype.toJSON = function ( meta ) {
 
 	var data = THREE.Object3D.prototype.toJSON.call( this, meta );
 
+	data.object.zoom = this.zoom;
 	data.object.left = this.left;
 	data.object.right = this.right;
 	data.object.top = this.top;

+ 2 - 3
src/cameras/PerspectiveCamera.js

@@ -27,7 +27,7 @@ THREE.PerspectiveCamera.prototype.constructor = THREE.PerspectiveCamera;
 
 /**
  * Uses Focal Length (in mm) to estimate and set FOV
- * 35mm (fullframe) camera is used if frame size is not specified;
+ * 35mm (full-frame) camera is used if frame size is not specified;
  * Formula based on http://www.bobatkins.com/photography/technical/field_of_view.html
  */
 
@@ -135,8 +135,6 @@ THREE.PerspectiveCamera.prototype.clone = function () {
 	camera.near = this.near;
 	camera.far = this.far;
 
-	camera.projectionMatrix.copy( this.projectionMatrix );
-
 	return camera;
 
 };
@@ -145,6 +143,7 @@ THREE.PerspectiveCamera.prototype.toJSON = function ( meta ) {
 
 	var data = THREE.Object3D.prototype.toJSON.call( this, meta );
 
+	data.object.zoom = this.zoom;
 	data.object.fov = this.fov;
 	data.object.aspect = this.aspect;
 	data.object.near = this.near;

+ 27 - 4
src/core/BufferGeometry.js

@@ -156,6 +156,14 @@ THREE.BufferGeometry.prototype = {
 			this.addAttribute( 'position', positions.copyVector3sArray( geometry.vertices ) );
 			this.addAttribute( 'color', colors.copyColorsArray( geometry.colors ) );
 
+			if ( geometry.lineDistances && geometry.lineDistances.length === geometry.vertices.length ) {
+
+				var lineDistances = new THREE.Float32Attribute( geometry.lineDistances.length, 1 );
+
+				this.addAttribute( 'lineDistance',  lineDistances.copyArray( geometry.lineDistances ) );
+
+			}
+
 			if ( geometry.boundingSphere !== null ) {
 
 				this.boundingSphere = geometry.boundingSphere.clone();
@@ -266,6 +274,21 @@ THREE.BufferGeometry.prototype = {
 
 		}
 
+		if ( geometry.lineDistancesNeedUpdate ) {
+
+			var attribute = this.attributes.lineDistance;
+
+			if ( attribute !== undefined ) {
+
+				attribute.copyArray( geometry.lineDistances );
+				attribute.needsUpdate = true;
+
+			}
+
+			geometry.lineDistancesNeedUpdate = false;
+
+		}
+
 		return this;
 
 	},
@@ -839,7 +862,7 @@ THREE.BufferGeometry.prototype = {
 			for ( var vo = 0; vo < 3; vo ++ ) {
 				var vid = indices[ findex * 3 + vo ];
 				if ( vertexMap[ vid ] === - 1 ) {
-					//Unmapped vertice
+					//Unmapped vertex
 					faceVertices[ vo * 2 ] = vid;
 					faceVertices[ vo * 2 + 1 ] = - 1;
 					newVerticeMaps ++;
@@ -849,7 +872,7 @@ THREE.BufferGeometry.prototype = {
 					faceVertices[ vo * 2 + 1 ] = - 1;
 					duplicatedVertices ++;
 				} else {
-					//Reused vertice in the current block
+					//Reused vertex in the current block
 					faceVertices[ vo * 2 ] = vid;
 					faceVertices[ vo * 2 + 1 ] = vertexMap[ vid ];
 				}
@@ -884,7 +907,7 @@ THREE.BufferGeometry.prototype = {
 			}
 		}
 
-		/* Move all attribute values to map to the new computed indices , also expand the vertice stack to match our new vertexPtr. */
+		/* Move all attribute values to map to the new computed indices , also expand the vertex stack to match our new vertexPtr. */
 		this.reorderBuffers( sortedIndices, revVertexMap, vertexPtr );
 		this.offsets = offsets; // TODO: Deprecate
 		this.drawcalls = offsets;
@@ -965,7 +988,7 @@ THREE.BufferGeometry.prototype = {
 		Reorder attributes based on a new indexBuffer and indexMap.
 		indexBuffer - Uint16Array of the new ordered indices.
 		indexMap - Int32Array where the position is the new vertex ID and the value the old vertex ID for each vertex.
-		vertexCount - Amount of total vertices considered in this reordering (in case you want to grow the vertice stack).
+		vertexCount - Amount of total vertices considered in this reordering (in case you want to grow the vertex stack).
 	*/
 	reorderBuffers: function ( indexBuffer, indexMap, vertexCount ) {
 

+ 2 - 2
src/core/Geometry.js

@@ -773,11 +773,11 @@ THREE.Geometry.prototype = {
 
 	mergeVertices: function () {
 
-		var verticesMap = {}; // Hashmap for looking up vertice by position coordinates (and making sure they are unique)
+		var verticesMap = {}; // Hashmap for looking up vertices by position coordinates (and making sure they are unique)
 		var unique = [], changes = [];
 
 		var v, key;
-		var precisionPoints = 4; // number of decimal points, eg. 4 for epsilon of 0.0001
+		var precisionPoints = 4; // number of decimal points, e.g. 4 for epsilon of 0.0001
 		var precision = Math.pow( 10, precisionPoints );
 		var i, il, face;
 		var indices, j, jl;

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

@@ -147,7 +147,7 @@ THREE.Curve.prototype.updateArcLengths = function() {
 	this.getLengths();
 };
 
-// Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equi distance
+// Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant
 
 THREE.Curve.prototype.getUtoTmapping = function ( u, distance ) {
 
@@ -209,7 +209,7 @@ THREE.Curve.prototype.getUtoTmapping = function ( u, distance ) {
 
 	}
 
-	// we could get finer grain at lengths, or use simple interpolatation between two points
+	// we could get finer grain at lengths, or use simple interpolation between two points
 
 	var lengthBefore = arcLengths[ i ];
 	var lengthAfter = arcLengths[ i + 1 ];

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

@@ -113,7 +113,7 @@ THREE.CurvePath.prototype.getCurveLengths = function() {
 
 	}
 
-	// Get length of subsurve
+	// Get length of sub-curve
 	// Push sums into cached array
 
 	var lengths = [], sums = 0;
@@ -206,7 +206,7 @@ THREE.CurvePath.prototype.createPointsGeometry = function( divisions ) {
 
 };
 
-// Generate geometry from equidistance sampling along the path
+// Generate geometry from equidistant sampling along the path
 
 THREE.CurvePath.prototype.createSpacedPointsGeometry = function( divisions ) {
 

+ 7 - 8
src/extras/core/Path.js

@@ -27,7 +27,7 @@ THREE.PathActions = {
 	LINE_TO: 'lineTo',
 	QUADRATIC_CURVE_TO: 'quadraticCurveTo', // Bezier quadratic curve
 	BEZIER_CURVE_TO: 'bezierCurveTo', 		// Bezier cubic curve
-	CSPLINE_THRU: 'splineThru',				// Catmull-rom spline
+	CSPLINE_THRU: 'splineThru',				// Catmull-Rom spline
 	ARC: 'arc',								// Circle
 	ELLIPSE: 'ellipse'
 };
@@ -208,7 +208,6 @@ THREE.Path.prototype.getSpacedPoints = function ( divisions, closedPath ) {
 THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
 
 	if (this.useSpacedPoints) {
-		console.log('tata');
 		return this.getSpacedPoints( divisions, closedPath );
 	}
 
@@ -543,9 +542,9 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) {
 					if ( perpEdge < 0 ) 				continue;
 					inside = ! inside;		// true intersection left of inPt
 				}
-			} else {		// parallel or colinear
+			} else {		// parallel or collinear
 				if ( inPt.y !== edgeLowPt.y ) 		continue;			// parallel
-				// egde lies on the same horizontal line as inPt
+				// edge lies on the same horizontal line as inPt
 				if ( ( ( edgeHighPt.x <= inPt.x ) && ( inPt.x <= edgeLowPt.x ) ) ||
 					 ( ( edgeLowPt.x <= inPt.x ) && ( inPt.x <= edgeHighPt.x ) ) )		return	true;	// inPt: Point on contour !
 				// continue;
@@ -626,7 +625,7 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) {
 
 
 	if ( newShapes.length > 1 ) {
-		var ambigious = false;
+		var ambiguous = false;
 		var toChange = [];
 
 		for (var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) {
@@ -644,17 +643,17 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) {
 							hole_unassigned = false;
 							betterShapeHoles[s2Idx].push( ho );
 						} else {
-							ambigious = true;
+							ambiguous = true;
 						}
 					}
 				}
 				if ( hole_unassigned ) { betterShapeHoles[sIdx].push( ho ); }
 			}
 		}
-		// console.log("ambigious: ", ambigious);
+		// console.log("ambiguous: ", ambiguous);
 		if ( toChange.length > 0 ) {
 			// console.log("to change: ", toChange);
-			if (! ambigious)	newShapeHoles = betterShapeHoles;
+			if (! ambiguous)	newShapeHoles = betterShapeHoles;
 		}
 	}
 

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

@@ -127,7 +127,7 @@ THREE.Shape.Utils = {
 	triangulateShape: function ( contour, holes ) {
 
 		function point_in_segment_2D_colin( inSegPt1, inSegPt2, inOtherPt ) {
-			// inOtherPt needs to be colinear to the inSegment
+			// inOtherPt needs to be collinear to the inSegment
 			if ( inSegPt1.x !== inSegPt2.x ) {
 				if ( inSegPt1.x < inSegPt2.x ) {
 					return	( ( inSegPt1.x <= inOtherPt.x ) && ( inOtherPt.x <= inSegPt2.x ) );
@@ -189,13 +189,13 @@ THREE.Shape.Utils = {
 				return	[ { x: inSeg1Pt1.x + factorSeg1 * seg1dx,
 							y: inSeg1Pt1.y + factorSeg1 * seg1dy } ];
 
-			} else {		// parallel or colinear
+			} else {		// parallel or collinear
 				if ( ( perpSeg1 !== 0 ) ||
 					 ( seg2dy * seg1seg2dx !== seg2dx * seg1seg2dy ) ) 			return [];
 
 				// they are collinear or degenerate
-				var seg1Pt = ( (seg1dx === 0) && (seg1dy === 0) );	// segment1 ist just a point?
-				var seg2Pt = ( (seg2dx === 0) && (seg2dy === 0) );	// segment2 ist just a point?
+				var seg1Pt = ( (seg1dx === 0) && (seg1dy === 0) );	// segment1 is just a point?
+				var seg2Pt = ( (seg2dx === 0) && (seg2dy === 0) );	// segment2 is just a point?
 				// both segments are points
 				if ( seg1Pt && seg2Pt ) {
 					if ( (inSeg1Pt1.x !== inSeg2Pt1.x) ||

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

@@ -6,7 +6,7 @@
  * parameters = {
  *
  *  curveSegments: <int>, // number of points on the curves
- *  steps: <int>, // number of points for z-side extrusions / used for subdividing segements of extrude spline too
+ *  steps: <int>, // number of points for z-side extrusions / used for subdividing segments of extrude spline too
  *  amount: <int>, // Depth to extrude the shape
  *
  *  bevelEnabled: <bool>, // turn on bevel
@@ -114,7 +114,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 
 	}
 
-	// Variables initalization
+	// Variables initialization 
 
 	var ahole, h, hl; // looping of holes
 	var scope = this;
@@ -187,7 +187,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 		var EPSILON = 0.0000000001;
 
 		// computes for inPt the corresponding point inPt' on a new contour
-		//   shiftet by 1 unit (length of normalized vector) to the left
+		//   shifted by 1 unit (length of normalized vector) to the left
 		// if we walk along contour clockwise, this new contour is outside the old one
 		//
 		// inPt' is the intersection of the two lines parallel to the two
@@ -203,10 +203,10 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 
 		var v_prev_lensq = ( v_prev_x * v_prev_x + v_prev_y * v_prev_y );
 
-		// check for colinear edges
-		var colinear0 = ( v_prev_x * v_next_y - v_prev_y * v_next_x );
+		// check for collinear edges
+		var collinear0 = ( v_prev_x * v_next_y - v_prev_y * v_next_x );
 
-		if ( Math.abs( colinear0 ) > EPSILON ) {		// not colinear
+		if ( Math.abs( collinear0 ) > EPSILON ) {		// not collinear
 
 			// length of vectors for normalizing
 
@@ -241,7 +241,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 				shrink_by = Math.sqrt( v_trans_lensq / 2 );
 			}
 
-		} else {		// handle special case of colinear edges
+		} else {		// handle special case of collinear edges
 
 			var direction_eq = false;		// assumes: opposite
 			if ( v_prev_x > EPSILON ) {

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

@@ -67,7 +67,7 @@ THREE.TubeGeometry = function ( path, segments, radius, radialSegments, closed,
 
 	}
 
-	// consruct the grid
+	// construct the grid
 
 	for ( i = 0; i < numpoints; i ++ ) {
 
@@ -213,7 +213,7 @@ THREE.TubeGeometry.FrenetFrames = function ( path, segments, closed ) {
 	*/
 
 	function initialNormal3() {
-		// select an initial normal vector perpenicular to the first tangent vector,
+		// select an initial normal vector perpendicular to the first tangent vector,
 		// and in the direction of the smallest tangent xyz component
 
 		normals[ 0 ] = new THREE.Vector3();

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

@@ -2,7 +2,7 @@
  * @author WestLangley / http://github.com/WestLangley
  * @param object THREE.Mesh whose geometry will be used
  * @param hex line color
- * @param thresholdAngle the minimim angle (in degrees),
+ * @param thresholdAngle the minimum angle (in degrees),
  * between the face normals of adjacent faces,
  * that is required to render an edge. A value of 10 means
  * an edge is only rendered if the angle is at least 10 degrees.

+ 1 - 1
src/loaders/JSONLoader.js

@@ -16,7 +16,7 @@ THREE.JSONLoader.prototype.constructor = THREE.JSONLoader;
 
 THREE.JSONLoader.prototype.load = function ( url, callback, texturePath ) {
 
-	// todo: unify load API to for easier SceneLoader use
+	// TODO: unify load API to for easier SceneLoader use
 
 	texturePath = texturePath && ( typeof texturePath === 'string' ) ? texturePath : this.extractUrlBase( url );
 

+ 1 - 1
src/loaders/ObjectLoader.js

@@ -352,7 +352,7 @@ THREE.ObjectLoader.prototype = {
 
 				if ( data.image === undefined ) {
 
-					console.warn( 'THREE.ObjectLoader: No "image" speficied for', data.uuid );
+					console.warn( 'THREE.ObjectLoader: No "image" specified for', data.uuid );
 
 				}
 

+ 1 - 1
src/materials/Material.js

@@ -93,7 +93,7 @@ THREE.Material.prototype = {
 
 				} else if ( key === 'overdraw' ) {
 
-					// ensure overdraw is backwards-compatable with legacy boolean type
+					// ensure overdraw is backwards-compatible with legacy boolean type
 					this[ key ] = Number( newValue );
 
 				} else {

+ 6 - 0
src/materials/MeshPhongMaterial.js

@@ -17,6 +17,8 @@
  *  aoMap: new THREE.Texture( <Image> ),
  *  aoMapIntensity: <float>
  *
+ *  emissiveMap: new THREE.Texture( <Image> ),
+ *
  *  bumpMap: new THREE.Texture( <Image> ),
  *  bumpScale: <float>,
  *
@@ -71,6 +73,8 @@ THREE.MeshPhongMaterial = function ( parameters ) {
 	this.aoMap = null;
 	this.aoMapIntensity = 1.0;
 
+	this.emissiveMap = null;
+
 	this.bumpMap = null;
 	this.bumpScale = 1;
 
@@ -129,6 +133,8 @@ THREE.MeshPhongMaterial.prototype.clone = function () {
 	material.aoMap = this.aoMap;
 	material.aoMapIntensity = this.aoMapIntensity;
 
+	material.emissiveMap = this.emissiveMap;
+
 	material.bumpMap = this.bumpMap;
 	material.bumpScale = this.bumpScale;
 

+ 1 - 1
src/math/Box3.js

@@ -57,7 +57,7 @@ THREE.Box3.prototype = {
 	setFromObject: function () {
 
 		// Computes the world-axis-aligned bounding box of an object (including its children),
-		// accounting for both the object's, and childrens', world transforms
+		// accounting for both the object's, and children's, world transforms
 
 		var v1 = new THREE.Vector3();
 

+ 3 - 3
src/math/Triangle.js

@@ -36,7 +36,7 @@ THREE.Triangle.normal = function () {
 
 }();
 
-// static/instance method to calculate barycoordinates
+// static/instance method to calculate barycentric coordinates
 // based on: http://www.blackpawn.com/texts/pointinpoly/default.html
 THREE.Triangle.barycoordFromPoint = function () {
 
@@ -60,7 +60,7 @@ THREE.Triangle.barycoordFromPoint = function () {
 
 		var result = optionalTarget || new THREE.Vector3();
 
-		// colinear or singular triangle
+		// collinear or singular triangle
 		if ( denom === 0 ) {
 			// arbitrary location outside of triangle?
 			// not sure if this is the best idea, maybe should be returning undefined
@@ -71,7 +71,7 @@ THREE.Triangle.barycoordFromPoint = function () {
 		var u = ( dot11 * dot02 - dot01 * dot12 ) * invDenom;
 		var v = ( dot00 * dot12 - dot01 * dot02 ) * invDenom;
 
-		// barycoordinates must always sum to 1
+		// barycentric coordinates must always sum to 1
 		return result.set( 1 - u - v, v, u );
 
 	};

+ 1 - 1
src/objects/LensFlare.js

@@ -42,7 +42,7 @@ THREE.LensFlare.prototype.add = function ( texture, size, distance, blending, co
 		texture: texture, 			// THREE.Texture
 		size: size, 				// size in pixels (-1 = use texture.width)
 		distance: distance, 		// distance (0-1) from light source (0=at light source)
-		x: 0, y: 0, z: 0,			// screen position (-1 => 1) z = 0 is ontop z = 1 is back
+		x: 0, y: 0, z: 0,			// screen position (-1 => 1) z = 0 is in front z = 1 is back
 		scale: 1, 					// scale
 		rotation: 1, 				// rotation
 		opacity: opacity,			// opacity

+ 1 - 1
src/objects/SkinnedMesh.js

@@ -148,7 +148,7 @@ THREE.SkinnedMesh.prototype.updateMatrixWorld = function( force ) {
 
 	} else {
 
-		console.warn( 'THREE.SkinnedMesh unreckognized bindMode: ' + this.bindMode );
+		console.warn( 'THREE.SkinnedMesh unrecognized bindMode: ' + this.bindMode );
 
 	}
 

+ 8 - 0
src/renderers/WebGLRenderer.js

@@ -1853,6 +1853,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			envMapMode: material.envMap && material.envMap.mapping,
 			lightMap: !! material.lightMap,
 			aoMap: !! material.aoMap,
+			emissiveMap: !! material.emissiveMap,
 			bumpMap: !! material.bumpMap,
 			normalMap: !! material.normalMap,
 			specularMap: !! material.specularMap,
@@ -2364,6 +2365,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		// 3. normal map
 		// 4. bump map
 		// 5. alpha map
+		// 6. emissive map
 
 		var uvScaleMap;
 
@@ -2387,6 +2389,10 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			uvScaleMap = material.alphaMap;
 
+		} else if ( material.emissiveMap ) {
+
+			uvScaleMap = material.emissiveMap;
+
 		}
 
 		if ( uvScaleMap !== undefined ) {
@@ -2471,6 +2477,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 		uniforms.aoMap.value = material.aoMap;
 		uniforms.aoMapIntensity.value = material.aoMapIntensity;
 
+		uniforms.emissiveMap.value = material.emissiveMap;
+
 	}
 
 	function refreshUniformsLambert ( uniforms, material ) {

+ 9 - 0
src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl

@@ -0,0 +1,9 @@
+#ifdef USE_EMISSIVEMAP
+
+	vec4 emissiveColor = texture2D( emissiveMap, vUv );
+
+	emissiveColor.rgb = inputToLinear( emissiveColor.rgb );
+
+	totalEmissiveLight *= emissiveColor.rgb;
+
+#endif

+ 5 - 0
src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl

@@ -0,0 +1,5 @@
+#ifdef USE_EMISSIVEMAP
+
+	uniform sampler2D emissiveMap;
+
+#endif

+ 2 - 2
src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl

@@ -156,10 +156,10 @@ vec3 totalSpecularLight = vec3( 0.0 );
 
 #ifdef METAL
 
-	outgoingLight += diffuseColor.rgb * ( totalDiffuseLight + totalAmbientLight ) * specular + totalSpecularLight + emissive;
+	outgoingLight += diffuseColor.rgb * ( totalDiffuseLight + totalAmbientLight ) * specular + totalSpecularLight + totalEmissiveLight;
 
 #else
 
-	outgoingLight += diffuseColor.rgb * ( totalDiffuseLight + totalAmbientLight ) + totalSpecularLight + emissive;
+	outgoingLight += diffuseColor.rgb * ( totalDiffuseLight + totalAmbientLight ) + totalSpecularLight + totalEmissiveLight;
 
 #endif

+ 1 - 1
src/renderers/shaders/ShaderChunk/map_fragment.glsl

@@ -6,4 +6,4 @@
 
 	diffuseColor *= texelColor;
 
-#endif
+#endif

+ 1 - 1
src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl

@@ -1,4 +1,4 @@
-#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP )
+#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP )
 
 	varying vec2 vUv;
 

+ 1 - 1
src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl

@@ -1,4 +1,4 @@
-#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP )
+#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP )
 
 	varying vec2 vUv;
 	uniform vec4 offsetRepeat;

+ 1 - 1
src/renderers/shaders/ShaderChunk/uv_vertex.glsl

@@ -1,4 +1,4 @@
-#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP )
+#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP )
 
 	vUv = uv * offsetRepeat.zw + offsetRepeat.xy;
 

+ 14 - 13
src/renderers/shaders/ShaderLib.js

@@ -101,7 +101,7 @@ THREE.ShaderLib = {
 
 				THREE.ShaderChunk[ "fog_fragment" ],
 
-			"	gl_FragColor = vec4( outgoingLight, diffuseColor.a );",	// TODO, this should be pre-multiplied to allow for bright highlights on very transparent objects
+			"	gl_FragColor = vec4( outgoingLight, diffuseColor.a );",
 
 			"}"
 
@@ -212,9 +212,6 @@ THREE.ShaderLib = {
 
 			"	#ifdef DOUBLE_SIDED",
 
-					//"float isFront = float( gl_FrontFacing );",
-					//"gl_FragColor.xyz *= isFront * vLightFront + ( 1.0 - isFront ) * vLightBack;",
-
 			"		if ( gl_FrontFacing )",
 			"			outgoingLight += diffuseColor.rgb * vLightFront + emissive;",
 			"		else",
@@ -233,7 +230,7 @@ THREE.ShaderLib = {
 
 				THREE.ShaderChunk[ "fog_fragment" ],
 
-			"	gl_FragColor = vec4( outgoingLight, diffuseColor.a );",	// TODO, this should be pre-multiplied to allow for bright highlights on very transparent objects
+			"	gl_FragColor = vec4( outgoingLight, diffuseColor.a );",
 
 			"}"
 
@@ -248,6 +245,7 @@ THREE.ShaderLib = {
 			THREE.UniformsLib[ "common" ],
 			THREE.UniformsLib[ "aomap" ],
 			THREE.UniformsLib[ "lightmap" ],
+			THREE.UniformsLib[ "emissivemap" ],
 			THREE.UniformsLib[ "bump" ],
 			THREE.UniformsLib[ "normalmap" ],
 			THREE.UniformsLib[ "fog" ],
@@ -307,7 +305,7 @@ THREE.ShaderLib = {
 				THREE.ShaderChunk[ "default_vertex" ],
 				THREE.ShaderChunk[ "logdepthbuf_vertex" ],
 
-			"	vViewPosition = -mvPosition.xyz;",
+			"	vViewPosition = - mvPosition.xyz;",
 
 				THREE.ShaderChunk[ "worldpos_vertex" ],
 				THREE.ShaderChunk[ "envmap_vertex" ],
@@ -336,6 +334,7 @@ THREE.ShaderLib = {
 			THREE.ShaderChunk[ "alphamap_pars_fragment" ],
 			THREE.ShaderChunk[ "aomap_pars_fragment" ],
 			THREE.ShaderChunk[ "lightmap_pars_fragment" ],
+			THREE.ShaderChunk[ "emissivemap_pars_fragment" ],
 			THREE.ShaderChunk[ "envmap_pars_fragment" ],
 			THREE.ShaderChunk[ "fog_pars_fragment" ],
 			THREE.ShaderChunk[ "lights_phong_pars_fragment" ],
@@ -347,9 +346,10 @@ THREE.ShaderLib = {
 
 			"void main() {",
 
-			"	vec3 outgoingLight = vec3( 0.0 );",	// outgoing light does not have an alpha, the surface does
+			"	vec3 outgoingLight = vec3( 0.0 );",
 			"	vec4 diffuseColor = vec4( diffuse, opacity );",
 			"	vec3 totalAmbientLight = ambientLightColor;",
+			"	vec3 totalEmissiveLight = emissive;",
 
 				THREE.ShaderChunk[ "logdepthbuf_fragment" ],
 				THREE.ShaderChunk[ "map_fragment" ],
@@ -359,6 +359,7 @@ THREE.ShaderLib = {
 				THREE.ShaderChunk[ "specularmap_fragment" ],
 				THREE.ShaderChunk[ "lightmap_fragment" ],
 				THREE.ShaderChunk[ "aomap_fragment" ],
+				THREE.ShaderChunk[ "emissivemap_fragment" ],
 
 				THREE.ShaderChunk[ "lights_phong_fragment" ],
 
@@ -369,7 +370,7 @@ THREE.ShaderLib = {
 
 				THREE.ShaderChunk[ "fog_fragment" ],
 
-			"	gl_FragColor = vec4( outgoingLight, diffuseColor.a );",	// TODO, this should be pre-multiplied to allow for bright highlights on very transparent objects
+			"	gl_FragColor = vec4( outgoingLight, diffuseColor.a );",
 
 			"}"
 
@@ -432,7 +433,7 @@ THREE.ShaderLib = {
 
 			"void main() {",
 
-			"	vec3 outgoingLight = vec3( 0.0 );",	// outgoing light does not have an alpha, the surface does
+			"	vec3 outgoingLight = vec3( 0.0 );",
 			"	vec4 diffuseColor = vec4( psColor, opacity );",
 
 				THREE.ShaderChunk[ "logdepthbuf_fragment" ],
@@ -445,7 +446,7 @@ THREE.ShaderLib = {
 				THREE.ShaderChunk[ "shadowmap_fragment" ],
 				THREE.ShaderChunk[ "fog_fragment" ],
 
-			"	gl_FragColor = vec4( outgoingLight, diffuseColor.a );",	// TODO, this should be pre-multiplied to allow for bright highlights on very transparent objects
+			"	gl_FragColor = vec4( outgoingLight, diffuseColor.a );",
 
 			"}"
 
@@ -517,7 +518,7 @@ THREE.ShaderLib = {
 
 			"	}",
 
-			"	vec3 outgoingLight = vec3( 0.0 );",	// outgoing light does not have an alpha, the surface does
+			"	vec3 outgoingLight = vec3( 0.0 );",
 			"	vec4 diffuseColor = vec4( diffuse, opacity );",
 
 				THREE.ShaderChunk[ "logdepthbuf_fragment" ],
@@ -527,7 +528,7 @@ THREE.ShaderLib = {
 
 				THREE.ShaderChunk[ "fog_fragment" ],
 
-			"	gl_FragColor = vec4( outgoingLight, diffuseColor.a );",	// TODO, this should be pre-multiplied to allow for bright highlights on very transparent objects
+			"	gl_FragColor = vec4( outgoingLight, diffuseColor.a );",
 
 			"}"
 
@@ -585,7 +586,7 @@ THREE.ShaderLib = {
 			"	#endif",
 
 			"	float color = 1.0 - smoothstep( mNear, mFar, depth );",
-			"	gl_FragColor = vec4( vec3( color ), opacity );",   // TODO, this should be pre-multiplied to allow for bright highlights on very transparent objects
+			"	gl_FragColor = vec4( vec3( color ), opacity );",
 
 			"}"
 

+ 6 - 0
src/renderers/shaders/UniformsLib.js

@@ -36,6 +36,12 @@ THREE.UniformsLib = {
 
 	},
 
+	emissivemap: {
+
+		"emissiveMap" : { type: "t", value: null },
+
+	},
+
 	bump: {
 
 		"bumpMap" : { type: "t", value: null },

+ 4 - 0
src/renderers/webgl/WebGLProgram.js

@@ -213,6 +213,7 @@ THREE.WebGLProgram = ( function () {
 				parameters.envMap ? '#define ' + envMapModeDefine : '',
 				parameters.lightMap ? '#define USE_LIGHTMAP' : '',
 				parameters.aoMap ? '#define USE_AOMAP' : '',
+				parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',
 				parameters.bumpMap ? '#define USE_BUMPMAP' : '',
 				parameters.normalMap ? '#define USE_NORMALMAP' : '',
 				parameters.specularMap ? '#define USE_SPECULARMAP' : '',
@@ -300,6 +301,8 @@ THREE.WebGLProgram = ( function () {
 				'precision ' + parameters.precision + ' float;',
 				'precision ' + parameters.precision + ' int;',
 
+				'#define SHADER_NAME ' + material.__webglShader.name,
+
 				customDefines,
 
 				'#define MAX_DIR_LIGHTS ' + parameters.maxDirLights,
@@ -325,6 +328,7 @@ THREE.WebGLProgram = ( function () {
 				parameters.envMap ? '#define ' + envMapBlendingDefine : '',
 				parameters.lightMap ? '#define USE_LIGHTMAP' : '',
 				parameters.aoMap ? '#define USE_AOMAP' : '',
+				parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',
 				parameters.bumpMap ? '#define USE_BUMPMAP' : '',
 				parameters.normalMap ? '#define USE_NORMALMAP' : '',
 				parameters.specularMap ? '#define USE_SPECULARMAP' : '',

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

@@ -275,7 +275,7 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 
 				object = webglObject.object;
 
-				// culling is overriden globally for all objects
+				// culling is overridden globally for all objects
 				// while rendering depth map
 
 				// need to deal with MeshFaceMaterial somehow

+ 1 - 1
src/renderers/webgl/plugins/LensFlarePlugin.js

@@ -302,7 +302,7 @@ THREE.LensFlarePlugin = function ( renderer, flares ) {
 		state.disableUnusedAttributes();
 
 		// loop through all lens flares to update their occlusion and positions
-		// setup gl and common used attribs/unforms
+		// setup gl and common used attribs/uniforms
 
 		gl.uniform1i( uniforms.occlusionMap, 0 );
 		gl.uniform1i( uniforms.map, 1 );

+ 2 - 0
utils/build/includes/common.json

@@ -104,6 +104,8 @@
 	"src/renderers/shaders/ShaderChunk/common.glsl",
 	"src/renderers/shaders/ShaderChunk/default_vertex.glsl",
 	"src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl",
+	"src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl",
+	"src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl",
 	"src/renderers/shaders/ShaderChunk/envmap_fragment.glsl",
 	"src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl",
 	"src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl",

Some files were not shown because too many files changed in this diff