Browse Source

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

Ben Houston 12 years ago
parent
commit
e47032d0f7
37 changed files with 520 additions and 1252 deletions
  1. 0 631
      build/three.js
  2. 157 152
      build/three.min.js
  3. 11 14
      docs/api/extras/core/Curve.html
  4. 2 2
      docs/api/extras/geometries/ExtrudeGeometry.html
  5. 1 1
      docs/api/extras/geometries/IcosahedronGeometry.html
  6. 1 1
      docs/api/extras/geometries/LatheGeometry.html
  7. 1 1
      docs/api/extras/geometries/OctahedronGeometry.html
  8. 1 1
      docs/api/extras/geometries/PlaneGeometry.html
  9. 1 1
      docs/api/extras/geometries/PolyhedronGeometry.html
  10. 1 1
      docs/api/extras/geometries/TetrahedronGeometry.html
  11. 1 1
      docs/api/extras/geometries/TextGeometry.html
  12. 1 1
      docs/api/extras/geometries/TorusGeometry.html
  13. 1 1
      docs/api/extras/geometries/TorusKnotGeometry.html
  14. 5 4
      docs/api/extras/modifiers/SubdivisionModifier.html
  15. 1 1
      docs/api/extras/objects/LensFlare.html
  16. 4 2
      docs/api/materials/ShaderMaterial.html
  17. 1 1
      docs/api/textures/DataTexture.html
  18. 1 1
      docs/api/textures/Texture.html
  19. 36 4
      docs/index.html
  20. 5 1
      editor/js/ui/Viewport.js
  21. 97 174
      examples/js/ShaderDeferred.js
  22. 7 7
      examples/js/renderers/CSS3DRenderer.js
  23. 1 1
      examples/js/renderers/DOMRenderer.js
  24. 79 119
      examples/js/renderers/WebGLDeferredRenderer.js
  25. 2 2
      examples/webgl_lights_deferred_morphs.html
  26. 5 5
      examples/webgl_lights_deferred_pointlights.html
  27. 10 9
      src/core/BufferGeometry.js
  28. 21 8
      src/core/Geometry.js
  29. 4 5
      src/core/Object3D.js
  30. 25 40
      src/extras/FontUtils.js
  31. 10 22
      src/extras/core/Curve.js
  32. 6 0
      src/loaders/Loader.js
  33. 4 5
      src/materials/Material.js
  34. 7 8
      src/math/Math.js
  35. 2 13
      src/math/Sphere.js
  36. 4 7
      src/renderers/WebGLShaders.js
  37. 4 5
      src/textures/Texture.js

File diff suppressed because it is too large
+ 0 - 631
build/three.js


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


+ 11 - 14
docs/api/extras/core/Curve.html

@@ -9,7 +9,7 @@
 	<body>
 	<body>
 		<h1>[name]</h1>
 		<h1>[name]</h1>
 
 
-		<div class="desc">todo</div>
+		<div class="desc">An extensible curve object which contains methods for interpolation</div>
 
 
 
 
 		<h2>Constructor</h2>
 		<h2>Constructor</h2>
@@ -25,37 +25,34 @@
 		<h2>Methods</h2>
 		<h2>Methods</h2>
 
 
 		<h3>.getPoint ( t )</h3>
 		<h3>.getPoint ( t )</h3>
-		<div>todo</div>
+		<div>Returns a vector for point t of the curve where t is between 0 and 1</div>
 
 
 		<h3>.getPointAt ( u )</h3>
 		<h3>.getPointAt ( u )</h3>
-		<div>todo</div>
+		<div>Returns a vector for point at relative position in curve according to arc length</div>
 
 
 		<h3>.getPoints ( divisions )</h3>
 		<h3>.getPoints ( divisions )</h3>
-		<div>todo</div>
+		<div>Get sequence of points using getPoint( t ) </div>
 
 
 		<h3>.getSpacedPoints ( divisions )</h3>
 		<h3>.getSpacedPoints ( divisions )</h3>
-		<div>todo</div>
+		<div>Get sequence of equi-spaced points using getPointAt( u )</div>
 
 
 		<h3>.getLength ()</h3>
 		<h3>.getLength ()</h3>
-		<div>todo</div>
+		<div>Get total curve arc length</div>
 
 
 		<h3>.getLengths ( divisions )</h3>
 		<h3>.getLengths ( divisions )</h3>
-		<div>todo</div>
+		<div>Get list of cumulative segment lengths</div>
 
 
 		<h3>.updateArcLengths ()</h3>
 		<h3>.updateArcLengths ()</h3>
-		<div>todo</div>
+		<div>Update the cumlative segment distance cache</div>
 
 
 		<h3>.getUtoTmapping ( u, distance )</h3>
 		<h3>.getUtoTmapping ( u, distance )</h3>
-		<div>todo</div>
-
-		<h3>.getNormalVector ( t )</h3>
-		<div>todo</div>
+		<div>Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equi distance</div>
 
 
 		<h3>.getTangent ( t )</h3>
 		<h3>.getTangent ( t )</h3>
-		<div>todo</div>
+		<div>Returns a unit vector tangent at t. If the subclassed curve do not implement its tangent derivation, 2 points a small delta apart will be used to find its gradient which seems to give a reasonable approximation</div>
 
 
 		<h3>.getTangentAt ( u )</h3>
 		<h3>.getTangentAt ( u )</h3>
-		<div>todo</div>
+		<div>Returns tangent at equidistance point u on the curve</div>
 
 
 
 
 		<h2>Source</h2>
 		<h2>Source</h2>

+ 2 - 2
docs/api/extras/geometries/ExtrudeGeometry.html

@@ -9,12 +9,12 @@
 	<body>
 	<body>
 		<h1>[name]</h1>
 		<h1>[name]</h1>
 
 
-		<div class="desc">todo</div>
+		<div class="desc">Creates extruded geometry from a path shape</div>
 
 
 
 
 		<h2>Constructor</h2>
 		<h2>Constructor</h2>
 
 
-		<h3>[name]()</h3>
+		<h3>[name]( shapes, options )</h3>
 
 
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>

+ 1 - 1
docs/api/extras/geometries/IcosahedronGeometry.html

@@ -14,7 +14,7 @@
 
 
 		<h2>Constructor</h2>
 		<h2>Constructor</h2>
 
 
-		<h3>[name]()</h3>
+		<h3>[name]( radius, detail )</h3>
 
 
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>

+ 1 - 1
docs/api/extras/geometries/LatheGeometry.html

@@ -14,7 +14,7 @@
 
 
 		<h2>Constructor</h2>
 		<h2>Constructor</h2>
 
 
-		<h3>[name]()</h3>
+		<h3>[name]( points, steps, angle )</h3>
 
 
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>

+ 1 - 1
docs/api/extras/geometries/OctahedronGeometry.html

@@ -14,7 +14,7 @@
 
 
 		<h2>Constructor</h2>
 		<h2>Constructor</h2>
 
 
-		<h3>[name]()</h3>
+		<h3>[name]( radius, detail )</h3>
 
 
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>

+ 1 - 1
docs/api/extras/geometries/PlaneGeometry.html

@@ -14,7 +14,7 @@
 
 
 		<h2>Constructor</h2>
 		<h2>Constructor</h2>
 
 
-		<h3>[name]()</h3>
+		<h3>[name]( width, height, widthSegments, heightSegments )</h3>
 
 
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>

+ 1 - 1
docs/api/extras/geometries/PolyhedronGeometry.html

@@ -14,7 +14,7 @@
 
 
 		<h2>Constructor</h2>
 		<h2>Constructor</h2>
 
 
-		<h3>[name]()</h3>
+		<h3>[name]( vertices, faces, radius, detail )</h3>
 
 
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>

+ 1 - 1
docs/api/extras/geometries/TetrahedronGeometry.html

@@ -14,7 +14,7 @@
 
 
 		<h2>Constructor</h2>
 		<h2>Constructor</h2>
 
 
-		<h3>[name]()</h3>
+		<h3>[name]( radius, detail )</h3>
 
 
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>

+ 1 - 1
docs/api/extras/geometries/TextGeometry.html

@@ -14,7 +14,7 @@
 
 
 		<h2>Constructor</h2>
 		<h2>Constructor</h2>
 
 
-		<h3>[name]()</h3>
+		<h3>[name]( text, parameters )</h3>
 
 
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>

+ 1 - 1
docs/api/extras/geometries/TorusGeometry.html

@@ -14,7 +14,7 @@
 
 
 		<h2>Constructor</h2>
 		<h2>Constructor</h2>
 
 
-		<h3>[name]()</h3>
+		<h3>[name]( radius, tube, radialSegments, tubularSegments, arc )</h3>
 
 
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>

+ 1 - 1
docs/api/extras/geometries/TorusKnotGeometry.html

@@ -14,7 +14,7 @@
 
 
 		<h2>Constructor</h2>
 		<h2>Constructor</h2>
 
 
-		<h3>[name]()</h3>
+		<h3>[name]( radius, tube, radialSegments, tubularSegments, arc )</h3>
 
 
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>

+ 5 - 4
docs/api/extras/modifiers/SubdivisionModifier.html

@@ -9,17 +9,18 @@
 	<body>
 	<body>
 		<h1>[name]</h1>
 		<h1>[name]</h1>
 
 
-		<div class="desc">todo</div>
+		<div class="desc">Applies Catmull-Clark Subdivision Surfaces for creating smooth geometry meshes</div>
 
 
 
 
 		<h2>Constructor</h2>
 		<h2>Constructor</h2>
 
 
-		<h3>[name]()</h3>
+		<h3>[name]( subdivisions )</h3>
 
 
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>
 
 
 		<h3>.subdivisions</h3>
 		<h3>.subdivisions</h3>
+		<div>Number of time subdivision will be applied</div>
 
 
 		<h3>.useOldVertexColors</h3>
 		<h3>.useOldVertexColors</h3>
 
 
@@ -30,10 +31,10 @@
 		<h2>Methods</h2>
 		<h2>Methods</h2>
 
 
 		<h3>.modify ( geometry )</h3>
 		<h3>.modify ( geometry )</h3>
-		<div>todo</div>
+		<div>Modifies the geometry by running subdivision surfaces. This calls .smooth() internally</div>
 
 
 		<h3>.smooth ( oldGeometry )</h3>
 		<h3>.smooth ( oldGeometry )</h3>
-		<div>todo</div>
+		<div>Performs an iteration of Catmull-Clark Subdivision</div>
 
 
 
 
 
 

+ 1 - 1
docs/api/extras/objects/LensFlare.html

@@ -14,7 +14,7 @@
 
 
 		<h2>Constructor</h2>
 		<h2>Constructor</h2>
 
 
-		<h3>[name]()</h3>
+		<h3>[name]( texture, size, distance, blending, color )</h3>
 
 
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>

+ 4 - 2
docs/api/materials/ShaderMaterial.html

@@ -11,12 +11,14 @@
 
 
 		<h1>[name]</h1>
 		<h1>[name]</h1>
 
 
-		<div class="desc">todo</div>
+		<div class="desc">Material rendered with custom shaders</div>
 
 
 
 
 		<h2>Constructor</h2>
 		<h2>Constructor</h2>
 
 
-		<h3>[name]()</h3>
+		<h3>[name]( parameters )
+
+</h3>
 
 
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>

+ 1 - 1
docs/api/textures/DataTexture.html

@@ -14,7 +14,7 @@
 
 
 		<h2>Constructor</h2>
 		<h2>Constructor</h2>
 
 
-		<h3>[name]()</h3>
+		<h3>[name]( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy )</h3>
 
 
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>

+ 1 - 1
docs/api/textures/Texture.html

@@ -14,7 +14,7 @@
 
 
 		<h2>Constructor</h2>
 		<h2>Constructor</h2>
 
 
-		<h3>[name]()</h3>
+		<h3>[name]( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy )</h3>
 
 
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>

+ 36 - 4
docs/index.html

@@ -104,6 +104,9 @@
 
 
 			var html = '<h1><a href="http://threejs.org">three.js</a><span style="font-size: 50%; vertical-align: super;"> r' + REVISION + '</span></h1>';
 			var html = '<h1><a href="http://threejs.org">three.js</a><span style="font-size: 50%; vertical-align: super;"> r' + REVISION + '</span></h1>';
 
 
+			var DELIMITER = '/';
+			var nameCategoryMap = {};
+
 			for ( var section in list ) {
 			for ( var section in list ) {
 
 
 				html += '<h2>' + section + '</h2>';
 				html += '<h2>' + section + '</h2>';
@@ -122,6 +125,12 @@
 
 
 						html += '<li><a href="javascript:goTo(\'' + section + '\', \'' + category + '\', \'' + page[ 0 ] + '\')">' + page[ 0 ] + '</a></li>';
 						html += '<li><a href="javascript:goTo(\'' + section + '\', \'' + category + '\', \'' + page[ 0 ] + '\')">' + page[ 0 ] + '</a></li>';
 
 
+						nameCategoryMap[page[0]] = {
+							section: section,
+							category: category,
+							name: page[0]
+						};
+
 					}
 					}
 
 
 					html += '</ul>';
 					html += '</ul>';
@@ -134,13 +143,36 @@
 
 
 			panel.innerHTML += html;
 			panel.innerHTML += html;
 
 
+			function encodeUrl( path ) {
+
+				return path.replace(/\ \/\ /g, '.').replace(/\ /g, '_');
+
+			}
+
+			function decodeUrl( path ) {
+
+				return path.replace(/_/g, ' ').replace(/\./g, ' / ');
+
+			}
+
 			// Page loading
 			// Page loading
 
 
 			function goTo( section, category, name ) {
 			function goTo( section, category, name ) {
 
 
-				window.document.title = 'three.js - documentation - ' + section + ' - ' + name;
+				// Fully resolve links that only provide a name
+				if(arguments.length == 1) {
+					var location = nameCategoryMap[section];
+					section = location.section;
+					category = location.category;
+					name = location.name;
+				}
+
+				var title = 'three.js - documentation - ' + section + ' - ' + name;
+				var url = encodeUrl(section) + DELIMITER + encodeUrl( category ) + DELIMITER + encodeUrl(name);
+
+				window.location.hash = url;
+				window.document.title = title;
 
 
-				window.location.hash = section + '/' + category + '/' + name.replace(/\ /g, '-');
 
 
 				viewer.src = pages[ section ][ category ][ name ] + '.html';
 				viewer.src = pages[ section ][ category ][ name ] + '.html';
 
 
@@ -148,8 +180,8 @@
 
 
 			function goToHash() {
 			function goToHash() {
 
 
-				var hash = window.location.hash.substring( 1 ).split('/');
-				goTo( hash[0], hash[1], hash[2].replace(/\-/g, ' ') );
+				var hash = window.location.hash.substring( 1 ).split(DELIMITER);
+				goTo( decodeUrl(hash[0]), decodeUrl(hash[1]), decodeUrl(hash[2]) );
 
 
 			}
 			}
 
 

+ 5 - 1
editor/js/ui/Viewport.js

@@ -714,7 +714,7 @@ var Viewport = function ( signals ) {
 		defaultScene.add( defaultCamera );
 		defaultScene.add( defaultCamera );
 
 
 		signals.sceneAdded.dispatch( defaultScene, defaultCamera, defaultBgColor );
 		signals.sceneAdded.dispatch( defaultScene, defaultCamera, defaultBgColor );
-		signals.objectSelected.dispatch( defaultScene.properties.defaultSelection );
+		signals.objectSelected.dispatch( defaultCamera );
 
 
 	} );
 	} );
 
 
@@ -872,6 +872,8 @@ var Viewport = function ( signals ) {
 
 
 		var scene = new THREE.Scene();
 		var scene = new THREE.Scene();
 
 
+		/*
+
 		// create lights
 		// create lights
 
 
 		var light1 = new THREE.DirectionalLight( 0xffffff, 0.8 );
 		var light1 = new THREE.DirectionalLight( 0xffffff, 0.8 );
@@ -925,6 +927,8 @@ var Viewport = function ( signals ) {
 		scene.add( light4 );
 		scene.add( light4 );
 		scene.add( mesh );
 		scene.add( mesh );
 
 
+		*/
+
 		return scene;
 		return scene;
 
 
 	}
 	}

+ 97 - 174
examples/js/ShaderDeferred.js

@@ -17,9 +17,11 @@ THREE.ShaderDeferred = {
 			THREE.UniformsLib[ "shadowmap" ],
 			THREE.UniformsLib[ "shadowmap" ],
 
 
 			{
 			{
-				"emissive" : { type: "c", value: new THREE.Color( 0x000000 ) },
-				"specular" : { type: "c", value: new THREE.Color( 0x111111 ) },
-				"shininess": { type: "f", value: 30 }
+				"emissive" :  { type: "c", value: new THREE.Color( 0x000000 ) },
+				"specular" :  { type: "c", value: new THREE.Color( 0x111111 ) },
+				"shininess":  { type: "f", value: 30 },
+				"wrapAround": 		{ type: "f", value: 1 },
+				"additiveSpecular": { type: "f", value: 1 }
 			}
 			}
 
 
 		] ),
 		] ),
@@ -30,6 +32,8 @@ THREE.ShaderDeferred = {
 			"uniform vec3 specular;",
 			"uniform vec3 specular;",
 			"uniform vec3 emissive;",
 			"uniform vec3 emissive;",
 			"uniform float shininess;",
 			"uniform float shininess;",
+			"uniform float wrapAround;",
+			"uniform float additiveSpecular;",
 
 
 			THREE.ShaderChunk[ "color_pars_fragment" ],
 			THREE.ShaderChunk[ "color_pars_fragment" ],
 			THREE.ShaderChunk[ "map_pars_fragment" ],
 			THREE.ShaderChunk[ "map_pars_fragment" ],
@@ -66,21 +70,33 @@ THREE.ShaderDeferred = {
 
 
 				THREE.ShaderChunk[ "fog_fragment" ],
 				THREE.ShaderChunk[ "fog_fragment" ],
 
 
+				//
+
+				"const float compressionScale = 0.999;",
+
 				// diffuse color
 				// diffuse color
 
 
-				"gl_FragColor.x = vec3_to_float( 0.999 * gl_FragColor.xyz );",
+				"gl_FragColor.x = vec3_to_float( compressionScale * gl_FragColor.xyz );",
 
 
 				// specular color
 				// specular color
 
 
-				"gl_FragColor.y = vec3_to_float( 0.999 * specular );",
+				"gl_FragColor.y = additiveSpecular * vec3_to_float( compressionScale * specular );",
 
 
 				// shininess
 				// shininess
 
 
-				"gl_FragColor.z = shininess;",
+				"gl_FragColor.z = wrapAround * shininess;",
 
 
 				// emissive color
 				// emissive color
 
 
-				"gl_FragColor.w = vec3_to_float( 0.999 * emissive );",
+				"#ifdef USE_MAP",
+
+					"gl_FragColor.w = vec3_to_float( compressionScale * emissive * texelColor.xyz );",
+
+				"#else",
+
+					"gl_FragColor.w = vec3_to_float( compressionScale * emissive );",
+
+				"#endif",
 
 
 			"}"
 			"}"
 
 
@@ -125,60 +141,62 @@ THREE.ShaderDeferred = {
 
 
 	},
 	},
 
 
-	"clipDepth" : {
+	"normalDepth" : {
 
 
-		uniforms: { },
+		uniforms: {
 
 
-		fragmentShader : [
+			bumpMap: 	  { type: "t", value: null },
+			bumpScale:	  { type: "f", value: 1 },
+			offsetRepeat: { type: "v4", value: new THREE.Vector4( 0, 0, 1, 1 ) }
 
 
-			"varying vec4 clipPos;",
+		},
 
 
-			"void main() {",
+		fragmentShader : [
 
 
-				"gl_FragColor = vec4( clipPos.z / clipPos.w, 1.0, 1.0, 1.0 );",
+			"#ifdef USE_BUMPMAP",
 
 
-			"}"
+				"#extension GL_OES_standard_derivatives : enable\n",
 
 
-		].join("\n"),
+				"varying vec2 vUv;",
+				"varying vec3 vViewPosition;",
 
 
-		vertexShader : [
+				THREE.ShaderChunk[ "bumpmap_pars_fragment" ],
 
 
-			"varying vec4 clipPos;",
+			"#endif",
 
 
-			THREE.ShaderChunk[ "morphtarget_pars_vertex" ],
+			"varying vec3 normalView;",
+			"varying vec4 clipPos;",
 
 
 			"void main() {",
 			"void main() {",
 
 
-				THREE.ShaderChunk[ "morphtarget_vertex" ],
-				THREE.ShaderChunk[ "default_vertex" ],
+				"vec3 normal = normalize( normalView );",
 
 
-				"clipPos = gl_Position;",
+				"#ifdef USE_BUMPMAP",
 
 
-			"}"
+					"normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );",
 
 
-		].join("\n")
+				"#endif",
 
 
-	},
+				"gl_FragColor.xyz = normal * 0.5 + 0.5;",
+				"gl_FragColor.w = clipPos.z / clipPos.w;",
 
 
-	"normals" : {
+			"}"
 
 
-		uniforms: { },
+		].join("\n"),
 
 
-		fragmentShader : [
+		vertexShader : [
 
 
 			"varying vec3 normalView;",
 			"varying vec3 normalView;",
+			"varying vec4 clipPos;",
 
 
-			"void main() {",
-
-				"gl_FragColor = vec4( vec3( normalView * 0.5 + 0.5 ), 1.0 );",
+			"#ifdef USE_BUMPMAP",
 
 
-			"}"
+				"varying vec2 vUv;",
+				"varying vec3 vViewPosition;",
 
 
-		].join("\n"),
+				"uniform vec4 offsetRepeat;",
 
 
-		vertexShader : [
-
-			"varying vec3 normalView;",
+			"#endif",
 
 
 			THREE.ShaderChunk[ "morphtarget_pars_vertex" ],
 			THREE.ShaderChunk[ "morphtarget_pars_vertex" ],
 
 
@@ -204,105 +222,13 @@ THREE.ShaderDeferred = {
 
 
 				"normalView = normalize( normalMatrix * objectNormal );",
 				"normalView = normalize( normalMatrix * objectNormal );",
 
 
-			"}"
-
-		].join("\n")
-
-	},
-
-	"bump" : {
-
-		uniforms: {
-
-			bumpMap: 	  { type: "t", value: null },
-			bumpScale:	  { type: "f", value: 1 },
-			offsetRepeat: { type: "v4", value: new THREE.Vector4( 0, 0, 1, 1 ) }
-
-		},
-
-		fragmentShader : [
-
-			"#extension GL_OES_standard_derivatives : enable\n",
-
-			"varying vec3 normalView;",
-			"varying vec2 vUv;",
-			"varying vec3 vViewPosition;",
-
-			THREE.ShaderChunk[ "bumpmap_pars_fragment" ],
+				"#ifdef USE_BUMPMAP",
 
 
-			"void main() {",
-
-				"vec3 normal = normalize( normalView );",
-				"normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );",
-				"gl_FragColor = vec4( vec3( normal * 0.5 + 0.5 ), 1.0 );",
-
-			"}"
-
-		].join("\n"),
-
-		vertexShader : [
+					"vUv = uv * offsetRepeat.zw + offsetRepeat.xy;",
+					"vViewPosition = -mvPosition.xyz;",
 
 
-			"varying vec3 normalView;",
-			"varying vec2 vUv;",
-			"varying vec3 vViewPosition;",
-
-			"uniform vec4 offsetRepeat;",
-
-			"void main() {",
-
-				"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
-				"gl_Position = projectionMatrix * mvPosition;",
-				"normalView = normalize( normalMatrix * normal );",
-				"vUv = uv * offsetRepeat.zw + offsetRepeat.xy;",
-				"vViewPosition = -mvPosition.xyz;",
-
-			"}"
-
-		].join("\n")
-
-	},
-
-	"unlit" : {
-
-		uniforms: {
-
-			samplerDepth: { type: "t", value: null },
-			viewWidth:    { type: "f", value: 800 },
-			viewHeight:   { type: "f", value: 600 },
-			lightColor:   { type: "c", value: new THREE.Color( 0x000000 ) }
-
-		},
-
-		fragmentShader : [
-
-			"varying vec4 clipPos;",
-			"uniform sampler2D samplerDepth;",
-
-			"uniform float viewHeight;",
-			"uniform float viewWidth;",
-
-			"uniform vec3 lightColor;",
-
-			"void main() {",
-
-				"vec2 texCoord = gl_FragCoord.xy / vec2( viewWidth, viewHeight );",
-				"float z = texture2D( samplerDepth, texCoord ).x;",
-				"vec4 color = vec4( lightColor, 1.0 );",
-				"float depth = clipPos.z / clipPos.w;",
-				"if( depth > z && z > 0.0 ) color.w = 0.0;",
-				"gl_FragColor = color;",
-
-			"}"
-
-		].join("\n"),
-
-		vertexShader : [
-
-			"varying vec4 clipPos;",
-
-			"void main() {",
+				"#endif",
 
 
-				"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
 				"clipPos = gl_Position;",
 				"clipPos = gl_Position;",
 
 
 			"}"
 			"}"
@@ -316,7 +242,7 @@ THREE.ShaderDeferred = {
 		uniforms: {
 		uniforms: {
 
 
 			samplerLight: 	{ type: "t", value: null },
 			samplerLight: 	{ type: "t", value: null },
-			multiply:		{ type: "f", value: 1 }
+			brightness:		{ type: "f", value: 1 }
 
 
 		},
 		},
 
 
@@ -324,12 +250,12 @@ THREE.ShaderDeferred = {
 
 
 			"varying vec2 texCoord;",
 			"varying vec2 texCoord;",
 			"uniform sampler2D samplerLight;",
 			"uniform sampler2D samplerLight;",
-			"uniform float multiply;",
+			"uniform float brightness;",
 
 
 			"void main() {",
 			"void main() {",
 
 
 				"vec3 color = texture2D( samplerLight, texCoord ).xyz;",
 				"vec3 color = texture2D( samplerLight, texCoord ).xyz;",
-				"gl_FragColor = vec4( multiply * sqrt( color ), 1.0 );",
+				"gl_FragColor = vec4( brightness * sqrt( color ), 1.0 );",
 
 
 			"}"
 			"}"
 
 
@@ -355,9 +281,8 @@ THREE.ShaderDeferred = {
 
 
 		uniforms: {
 		uniforms: {
 
 
-			samplerNormals: { type: "t", value: null },
-			samplerDepth: 	{ type: "t", value: null },
-			samplerColor: 	{ type: "t", value: null },
+			samplerNormalDepth: { type: "t", value: null },
+			samplerColor: 		{ type: "t", value: null },
 			matView: 		{ type: "m4", value: new THREE.Matrix4() },
 			matView: 		{ type: "m4", value: new THREE.Matrix4() },
 			matProjInverse: { type: "m4", value: new THREE.Matrix4() },
 			matProjInverse: { type: "m4", value: new THREE.Matrix4() },
 			viewWidth: 		{ type: "f", value: 800 },
 			viewWidth: 		{ type: "f", value: 800 },
@@ -375,8 +300,7 @@ THREE.ShaderDeferred = {
 			"varying vec4 clipPos;",
 			"varying vec4 clipPos;",
 
 
 			"uniform sampler2D samplerColor;",
 			"uniform sampler2D samplerColor;",
-			"uniform sampler2D samplerDepth;",
-			"uniform sampler2D samplerNormals;",
+			"uniform sampler2D samplerNormalDepth;",
 
 
 			"uniform float lightRadius;",
 			"uniform float lightRadius;",
 			"uniform float lightIntensity;",
 			"uniform float lightIntensity;",
@@ -402,17 +326,10 @@ THREE.ShaderDeferred = {
 
 
 				"vec2 texCoord = gl_FragCoord.xy / vec2( viewWidth, viewHeight );",
 				"vec2 texCoord = gl_FragCoord.xy / vec2( viewWidth, viewHeight );",
 
 
-				"float z = texture2D( samplerDepth, texCoord ).x;",
-				"float lightZ = clipPos.z / clipPos.w;",
-
-				/*
-				"if ( z == 0.0 ) {",
-
-					"gl_FragColor = vec4( vec3( 0.0 ), 1.0 );",
-					"return;",
+				"vec4 normalDepth = texture2D( samplerNormalDepth, texCoord );",
 
 
-				"}",
-				*/
+				"float z = normalDepth.w;",
+				"float lightZ = clipPos.z / clipPos.w;",
 
 
 				"if ( z == 0.0 || lightZ > z ) discard;",
 				"if ( z == 0.0 || lightZ > z ) discard;",
 
 
@@ -441,7 +358,7 @@ THREE.ShaderDeferred = {
 
 
 				// normal
 				// normal
 
 
-				"vec3 normal = texture2D( samplerNormals, texCoord ).xyz * 2.0 - 1.0;",
+				"vec3 normal = normalDepth.xyz * 2.0 - 1.0;",
 
 
 				// color
 				// color
 
 
@@ -449,20 +366,31 @@ THREE.ShaderDeferred = {
 
 
 				"vec3 albedo = float_to_vec3( abs( colorMap.x ) );",
 				"vec3 albedo = float_to_vec3( abs( colorMap.x ) );",
 				"vec3 specularColor = float_to_vec3( abs( colorMap.y ) );",
 				"vec3 specularColor = float_to_vec3( abs( colorMap.y ) );",
-				"float shininess = colorMap.z;",
+				"float shininess = abs( colorMap.z );",
+				"float wrapAround = sign( colorMap.z );",
 
 
-				// wrap around lighting
+				// light
+
+				"vec3 diffuse;",
 
 
 				"float diffuseFull = max( dot( normal, lightDir ), 0.0 );",
 				"float diffuseFull = max( dot( normal, lightDir ), 0.0 );",
-				"float diffuseHalf = max( 0.5 + 0.5 * dot( normal, lightDir ), 0.0 );",
 
 
-				"const vec3 wrapRGB = vec3( 0.6, 0.2, 0.2 );",
-				"vec3 diffuse = mix( vec3 ( diffuseFull ), vec3( diffuseHalf ), wrapRGB );",
+				"if ( wrapAround < 0.0 ) {",
 
 
-				// simple lighting
+					// wrap around lighting
 
 
-				//"float diffuseFull = max( dot( normal, lightDir ), 0.0 );",
-				//"vec3 diffuse = vec3 ( diffuseFull );",
+					"float diffuseHalf = max( 0.5 + 0.5 * dot( normal, lightDir ), 0.0 );",
+
+					"const vec3 wrapRGB = vec3( 0.6, 0.2, 0.2 );",
+					"diffuse = mix( vec3( diffuseFull ), vec3( diffuseHalf ), wrapRGB );",
+
+				"} else {",
+
+					// simple lighting
+
+					"diffuse = vec3( diffuseFull );",
+
+				"}",
 
 
 				// specular
 				// specular
 
 
@@ -484,15 +412,17 @@ THREE.ShaderDeferred = {
 
 
 				"vec3 light = lightIntensity * lightColor;",
 				"vec3 light = lightIntensity * lightColor;",
 
 
-				"#ifdef ADDITIVE_SPECULAR",
+				"float additiveSpecular = sign( colorMap.y );",
+
+				"if ( additiveSpecular < 0.0 ) {",
 
 
 					"gl_FragColor = vec4( albedo * light * diffuse, attenuation ) + vec4( light * specular, attenuation );",
 					"gl_FragColor = vec4( albedo * light * diffuse, attenuation ) + vec4( light * specular, attenuation );",
 
 
-				"#else",
+				"} else {",
 
 
 					"gl_FragColor = vec4( albedo * light * ( diffuse + specular ), attenuation );",
 					"gl_FragColor = vec4( albedo * light * ( diffuse + specular ), attenuation );",
 
 
-				"#endif",
+				"}",
 
 
 			"}"
 			"}"
 
 
@@ -522,9 +452,8 @@ THREE.ShaderDeferred = {
 
 
 		uniforms: {
 		uniforms: {
 
 
-			samplerNormals: { type: "t", value: null },
-			samplerDepth: 	{ type: "t", value: null },
-			samplerColor: 	{ type: "t", value: null },
+			samplerNormalDepth: { type: "t", value: null },
+			samplerColor: 		{ type: "t", value: null },
 			matView: 		{ type: "m4", value: new THREE.Matrix4() },
 			matView: 		{ type: "m4", value: new THREE.Matrix4() },
 			matProjInverse: { type: "m4", value: new THREE.Matrix4() },
 			matProjInverse: { type: "m4", value: new THREE.Matrix4() },
 			viewWidth: 		{ type: "f", value: 800 },
 			viewWidth: 		{ type: "f", value: 800 },
@@ -541,8 +470,7 @@ THREE.ShaderDeferred = {
 			"varying vec4 clipPos;",
 			"varying vec4 clipPos;",
 
 
 			"uniform sampler2D samplerColor;",
 			"uniform sampler2D samplerColor;",
-			"uniform sampler2D samplerDepth;",
-			"uniform sampler2D samplerNormals;",
+			"uniform sampler2D samplerNormalDepth;",
 
 
 			"uniform float lightRadius;",
 			"uniform float lightRadius;",
 			"uniform float lightIntensity;",
 			"uniform float lightIntensity;",
@@ -568,7 +496,8 @@ THREE.ShaderDeferred = {
 
 
 				"vec2 texCoord = gl_FragCoord.xy / vec2( viewWidth, viewHeight );",
 				"vec2 texCoord = gl_FragCoord.xy / vec2( viewWidth, viewHeight );",
 
 
-				"float z = texture2D( samplerDepth, texCoord ).x;",
+				"vec4 normalDepth = texture2D( samplerNormalDepth, texCoord );",
+				"float z = normalDepth.w;",
 
 
 				"if ( z == 0.0 ) discard;",
 				"if ( z == 0.0 ) discard;",
 
 
@@ -585,7 +514,7 @@ THREE.ShaderDeferred = {
 
 
 				// normal
 				// normal
 
 
-				"vec3 normal = texture2D( samplerNormals, texCoord ).xyz * 2.0 - 1.0;",
+				"vec3 normal = normalDepth.xyz * 2.0 - 1.0;",
 
 
 				// color
 				// color
 
 
@@ -665,7 +594,6 @@ THREE.ShaderDeferred = {
 
 
 		uniforms: {
 		uniforms: {
 
 
-			samplerDepth: 	{ type: "t", value: null },
 			samplerColor: 	{ type: "t", value: null },
 			samplerColor: 	{ type: "t", value: null },
 			viewWidth: 		{ type: "f", value: 800 },
 			viewWidth: 		{ type: "f", value: 800 },
 			viewHeight: 	{ type: "f", value: 600 },
 			viewHeight: 	{ type: "f", value: 600 },
@@ -674,7 +602,6 @@ THREE.ShaderDeferred = {
 
 
 		fragmentShader : [
 		fragmentShader : [
 
 
-			"uniform sampler2D samplerDepth;",
 			"uniform sampler2D samplerColor;",
 			"uniform sampler2D samplerColor;",
 
 
 			"uniform float viewHeight;",
 			"uniform float viewHeight;",
@@ -695,10 +622,6 @@ THREE.ShaderDeferred = {
 
 
 				"vec2 texCoord = gl_FragCoord.xy / vec2( viewWidth, viewHeight );",
 				"vec2 texCoord = gl_FragCoord.xy / vec2( viewWidth, viewHeight );",
 
 
-				"float z = texture2D( samplerDepth, texCoord ).x;",
-
-				"if ( z == 0.0 ) discard;",
-
 				"vec4 colorMap = texture2D( samplerColor, texCoord );",
 				"vec4 colorMap = texture2D( samplerColor, texCoord );",
 				"vec3 emissiveColor = float_to_vec3( abs( colorMap.w ) );",
 				"vec3 emissiveColor = float_to_vec3( abs( colorMap.w ) );",
 
 

+ 7 - 7
examples/js/renderers/CSS3DRenderer.js

@@ -121,10 +121,10 @@ THREE.CSS3DRenderer = function () {
 			epsilon( elements[ 1 ] ) + ',' +
 			epsilon( elements[ 1 ] ) + ',' +
 			epsilon( elements[ 2 ] ) + ',' +
 			epsilon( elements[ 2 ] ) + ',' +
 			epsilon( elements[ 3 ] ) + ',' +
 			epsilon( elements[ 3 ] ) + ',' +
-			epsilon( elements[ 4 ] ) + ',' +
-			epsilon( elements[ 5 ] ) + ',' +
-			epsilon( elements[ 6 ] ) + ',' +
-			epsilon( elements[ 7 ] ) + ',' +
+			epsilon( - elements[ 4 ] ) + ',' +
+			epsilon( - elements[ 5 ] ) + ',' +
+			epsilon( - elements[ 6 ] ) + ',' +
+			epsilon( - elements[ 7 ] ) + ',' +
 			epsilon( elements[ 8 ] ) + ',' +
 			epsilon( elements[ 8 ] ) + ',' +
 			epsilon( elements[ 9 ] ) + ',' +
 			epsilon( elements[ 9 ] ) + ',' +
 			epsilon( elements[ 10 ] ) + ',' +
 			epsilon( elements[ 10 ] ) + ',' +
@@ -133,7 +133,7 @@ THREE.CSS3DRenderer = function () {
 			epsilon( elements[ 13 ] ) + ',' +
 			epsilon( elements[ 13 ] ) + ',' +
 			epsilon( elements[ 14 ] ) + ',' +
 			epsilon( elements[ 14 ] ) + ',' +
 			epsilon( elements[ 15 ] ) +
 			epsilon( elements[ 15 ] ) +
-		') scale3d(1,-1,1)';
+		')';
 
 
 	}
 	}
 
 
@@ -146,6 +146,8 @@ THREE.CSS3DRenderer = function () {
 		this.domElement.style.oPerspective = fov + "px";
 		this.domElement.style.oPerspective = fov + "px";
 		this.domElement.style.perspective = fov + "px";
 		this.domElement.style.perspective = fov + "px";
 
 
+		var objects = _projector.projectScene( scene, camera, false ).objects;
+		
 		var style = "translate3d(0,0," + fov + "px)" + getCameraCSSMatrix( camera.matrixWorldInverse ) + " translate3d(" + _widthHalf + "px," + _heightHalf + "px, 0)";
 		var style = "translate3d(0,0," + fov + "px)" + getCameraCSSMatrix( camera.matrixWorldInverse ) + " translate3d(" + _widthHalf + "px," + _heightHalf + "px, 0)";
 
 
 		this.cameraElement.style.WebkitTransform = style;
 		this.cameraElement.style.WebkitTransform = style;
@@ -153,8 +155,6 @@ THREE.CSS3DRenderer = function () {
 		this.cameraElement.style.oTransform = style;
 		this.cameraElement.style.oTransform = style;
 		this.cameraElement.style.transform = style;
 		this.cameraElement.style.transform = style;
 
 
-		var objects = _projector.projectScene( scene, camera, false ).objects;
-
 		for ( var i = 0, il = objects.length; i < il; i ++ ) {
 		for ( var i = 0, il = objects.length; i < il; i ++ ) {
 
 
 			var object = objects[ i ].object;
 			var object = objects[ i ].object;

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

@@ -55,7 +55,7 @@ THREE.DOMRenderer = function () {
 
 
 			if ( element instanceof THREE.RenderableParticle && element.material instanceof THREE.ParticleDOMMaterial ) {
 			if ( element instanceof THREE.RenderableParticle && element.material instanceof THREE.ParticleDOMMaterial ) {
 
 
-				dom = element.material.domElement;
+				dom = element.material.element;
 
 
 				v1x = element.x * _widthHalf + _widthHalf - ( dom.offsetWidth >> 1 );
 				v1x = element.x * _widthHalf + _widthHalf - ( dom.offsetWidth >> 1 );
 				v1y = element.y * _heightHalf + _heightHalf - ( dom.offsetHeight >> 1 );
 				v1y = element.y * _heightHalf + _heightHalf - ( dom.offsetHeight >> 1 );

+ 79 - 119
examples/js/renderers/WebGLDeferredRenderer.js

@@ -14,8 +14,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 	var scaledWidth = Math.floor( scale * width );
 	var scaledWidth = Math.floor( scale * width );
 	var scaledHeight = Math.floor( scale * height );
 	var scaledHeight = Math.floor( scale * height );
 
 
-	var additiveSpecular = parameters.additiveSpecular;
-	var multiply = parameters.multiply;
+	var brightness = parameters.brightness;
 
 
 	this.renderer = parameters.renderer;
 	this.renderer = parameters.renderer;
 
 
@@ -23,7 +22,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 
 
 		this.renderer = new THREE.WebGLRenderer( { alpha: false } );
 		this.renderer = new THREE.WebGLRenderer( { alpha: false } );
 		this.renderer.setSize( width, height );
 		this.renderer.setSize( width, height );
-		this.renderer.setClearColorHex( 0x000000, 1 );
+		this.renderer.setClearColorHex( 0x000000, 0 );
 
 
 		this.renderer.autoClear = false;
 		this.renderer.autoClear = false;
 
 
@@ -39,9 +38,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 	var black = new THREE.Color( 0x000000 );
 	var black = new THREE.Color( 0x000000 );
 
 
 	var colorShader = THREE.ShaderDeferred[ "color" ];
 	var colorShader = THREE.ShaderDeferred[ "color" ];
-	var normalShader = THREE.ShaderDeferred[ "normals" ];
-	var bumpShader = THREE.ShaderDeferred[ "bump" ];
-	var clipDepthShader = THREE.ShaderDeferred[ "clipDepth" ];
+	var normalDepthShader = THREE.ShaderDeferred[ "normalDepth" ];
 
 
 	//
 	//
 
 
@@ -65,19 +62,11 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 
 
 	//
 	//
 
 
-	var defaultNormalMaterial = new THREE.ShaderMaterial( {
+	var defaultNormalDepthMaterial = new THREE.ShaderMaterial( {
 
 
-		uniforms:       THREE.UniformsUtils.clone( normalShader.uniforms ),
-		vertexShader:   normalShader.vertexShader,
-		fragmentShader: normalShader.fragmentShader
-
-	} );
-
-	var defaultDepthMaterial = new THREE.ShaderMaterial( {
-
-		uniforms:       THREE.UniformsUtils.clone( clipDepthShader.uniforms ),
-		vertexShader:   clipDepthShader.vertexShader,
-		fragmentShader: clipDepthShader.fragmentShader
+		uniforms:       THREE.UniformsUtils.clone( normalDepthShader.uniforms ),
+		vertexShader:   normalDepthShader.vertexShader,
+		fragmentShader: normalDepthShader.fragmentShader
 
 
 	} );
 	} );
 
 
@@ -88,8 +77,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 		if ( object.material instanceof THREE.MeshFaceMaterial ) {
 		if ( object.material instanceof THREE.MeshFaceMaterial ) {
 
 
 			var colorMaterials = [];
 			var colorMaterials = [];
-			var depthMaterials = [];
-			var normalMaterials = [];
+			var normalDepthMaterials = [];
 
 
 			var materials = object.material.materials;
 			var materials = object.material.materials;
 
 
@@ -98,22 +86,19 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 				var deferredMaterials = createDeferredMaterials( materials[ i ] );
 				var deferredMaterials = createDeferredMaterials( materials[ i ] );
 
 
 				colorMaterials.push( deferredMaterials.colorMaterial );
 				colorMaterials.push( deferredMaterials.colorMaterial );
-				depthMaterials.push( deferredMaterials.depthMaterial );
-				normalMaterials.push( deferredMaterials.normalMaterial );
+				normalDepthMaterials.push( deferredMaterials.normalDepthMaterial );
 
 
 			}
 			}
 
 
 			object.properties.colorMaterial = new THREE.MeshFaceMaterial( colorMaterials );
 			object.properties.colorMaterial = new THREE.MeshFaceMaterial( colorMaterials );
-			object.properties.depthMaterial = new THREE.MeshFaceMaterial( depthMaterials );
-			object.properties.normalMaterial = new THREE.MeshFaceMaterial( normalMaterials );
+			object.properties.normalDepthMaterial = new THREE.MeshFaceMaterial( normalDepthMaterials );
 
 
 		} else {
 		} else {
 
 
 			var deferredMaterials = createDeferredMaterials( object.material );
 			var deferredMaterials = createDeferredMaterials( object.material );
 
 
 			object.properties.colorMaterial = deferredMaterials.colorMaterial;
 			object.properties.colorMaterial = deferredMaterials.colorMaterial;
-			object.properties.depthMaterial = deferredMaterials.depthMaterial;
-			object.properties.normalMaterial = deferredMaterials.normalMaterial;
+			object.properties.normalDepthMaterial = deferredMaterials.normalDepthMaterial;
 
 
 		}
 		}
 
 
@@ -161,11 +146,15 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 
 
 		var specular = originalMaterial.specular !== undefined ? originalMaterial.specular : black;
 		var specular = originalMaterial.specular !== undefined ? originalMaterial.specular : black;
 		var shininess = originalMaterial.shininess !== undefined ? originalMaterial.shininess : 1;
 		var shininess = originalMaterial.shininess !== undefined ? originalMaterial.shininess : 1;
+		var wrapAround = originalMaterial.wrapAround !== undefined ? ( originalMaterial.wrapAround ? -1 : 1 ) : 1;
+		var additiveSpecular = originalMaterial.metal !== undefined ? ( originalMaterial.metal ? 1 : -1 ) : -1;
 
 
 		uniforms.emissive.value.copy( emissive );
 		uniforms.emissive.value.copy( emissive );
 		uniforms.diffuse.value.copy( diffuse );
 		uniforms.diffuse.value.copy( diffuse );
 		uniforms.specular.value.copy( specular );
 		uniforms.specular.value.copy( specular );
 		uniforms.shininess.value = shininess;
 		uniforms.shininess.value = shininess;
+		uniforms.wrapAround.value = wrapAround;
+		uniforms.additiveSpecular.value = additiveSpecular;
 
 
 		uniforms.map.value = originalMaterial.map;
 		uniforms.map.value = originalMaterial.map;
 
 
@@ -186,77 +175,54 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 
 
 		deferredMaterials.colorMaterial = material;
 		deferredMaterials.colorMaterial = material;
 
 
-		// normal material
+		// normal + depth material
 		// -----------------
 		// -----------------
 		//	vertex normals
 		//	vertex normals
 		//	morph normals
 		//	morph normals
 		//	bump map
 		//	bump map
 		//	bump scale
 		//	bump scale
+		//  clip depth
 
 
-		if ( originalMaterial.bumpMap ) {
+		if ( originalMaterial.morphTargets || originalMaterial.bumpMap ) {
 
 
-			var uniforms = THREE.UniformsUtils.clone( bumpShader.uniforms );
+			var uniforms = THREE.UniformsUtils.clone( normalDepthShader.uniforms );
+			var defines = { "USE_BUMPMAP": !!originalMaterial.bumpMap };
 
 
-			var normalMaterial = new THREE.ShaderMaterial( {
+			var normalDepthMaterial = new THREE.ShaderMaterial( {
 
 
-				uniforms: 		uniforms,
-				vertexShader: 	bumpShader.vertexShader,
-				fragmentShader: bumpShader.fragmentShader,
-				defines:		{ "USE_BUMPMAP": true }
+				uniforms:       uniforms,
+				vertexShader:   normalDepthShader.vertexShader,
+				fragmentShader: normalDepthShader.fragmentShader,
+				shading:		originalMaterial.shading,
+				defines:		defines,
+				blending:		THREE.NoBlending
 
 
 			} );
 			} );
 
 
-			uniforms.bumpMap.value = originalMaterial.bumpMap;
-			uniforms.bumpScale.value = originalMaterial.bumpScale;
-
-			var offset = originalMaterial.bumpMap.offset;
-			var repeat = originalMaterial.bumpMap.repeat;
-
-			uniforms.offsetRepeat.value.set( offset.x, offset.y, repeat.x, repeat.y );
+			if ( originalMaterial.morphTargets ) {
 
 
-			deferredMaterials.normalMaterial = normalMaterial;
-
-		} else if ( originalMaterial.morphTargets ) {
-
-			var normalMaterial = new THREE.ShaderMaterial( {
-
-				uniforms:       THREE.UniformsUtils.clone( normalShader.uniforms ),
-				vertexShader:   normalShader.vertexShader,
-				fragmentShader: normalShader.fragmentShader,
-				shading:		originalMaterial.shading
-
-			} );
-
-			normalMaterial.morphTargets = originalMaterial.morphTargets;
-			normalMaterial.morphNormals = originalMaterial.morphNormals;
-
-			deferredMaterials.normalMaterial = normalMaterial;
-
-		} else {
+				normalDepthMaterial.morphTargets = originalMaterial.morphTargets;
+				normalDepthMaterial.morphNormals = originalMaterial.morphNormals;
 
 
-			deferredMaterials.normalMaterial = defaultNormalMaterial;
-
-		}
-
-		// depth material
+			}
 
 
-		if ( originalMaterial.morphTargets ) {
+			if ( originalMaterial.bumpMap ) {
 
 
-			var depthMaterial = new THREE.ShaderMaterial( {
+				uniforms.bumpMap.value = originalMaterial.bumpMap;
+				uniforms.bumpScale.value = originalMaterial.bumpScale;
 
 
-				uniforms:       THREE.UniformsUtils.clone( clipDepthShader.uniforms ),
-				vertexShader:   clipDepthShader.vertexShader,
-				fragmentShader: clipDepthShader.fragmentShader
+				var offset = originalMaterial.bumpMap.offset;
+				var repeat = originalMaterial.bumpMap.repeat;
 
 
-			} );
+				uniforms.offsetRepeat.value.set( offset.x, offset.y, repeat.x, repeat.y );
 
 
-			depthMaterial.morphTargets = originalMaterial.morphTargets;
+			}
 
 
-			deferredMaterials.depthMaterial = depthMaterial;
+			deferredMaterials.normalDepthMaterial = normalDepthMaterial;
 
 
 		} else {
 		} else {
 
 
-			deferredMaterials.depthMaterial = defaultDepthMaterial;
+			deferredMaterials.normalDepthMaterial = defaultNormalDepthMaterial;
 
 
 		}
 		}
 
 
@@ -273,7 +239,6 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 			uniforms:       THREE.UniformsUtils.clone( pointLightShader.uniforms ),
 			uniforms:       THREE.UniformsUtils.clone( pointLightShader.uniforms ),
 			vertexShader:   pointLightShader.vertexShader,
 			vertexShader:   pointLightShader.vertexShader,
 			fragmentShader: pointLightShader.fragmentShader,
 			fragmentShader: pointLightShader.fragmentShader,
-			defines:		{ "ADDITIVE_SPECULAR": additiveSpecular },
 
 
 			blending:		THREE.AdditiveBlending,
 			blending:		THREE.AdditiveBlending,
 			depthWrite:		false,
 			depthWrite:		false,
@@ -290,8 +255,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 		materialLight.uniforms[ "viewHeight" ].value = scaledHeight;
 		materialLight.uniforms[ "viewHeight" ].value = scaledHeight;
 
 
 		materialLight.uniforms[ 'samplerColor' ].value = compColor.renderTarget2;
 		materialLight.uniforms[ 'samplerColor' ].value = compColor.renderTarget2;
-		materialLight.uniforms[ 'samplerNormals' ].value = compNormal.renderTarget2;
-		materialLight.uniforms[ 'samplerDepth' ].value = compDepth.renderTarget2;
+		materialLight.uniforms[ 'samplerNormalDepth' ].value = compNormalDepth.renderTarget2;
 
 
 		// create light proxy mesh
 		// create light proxy mesh
 
 
@@ -316,7 +280,6 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 			uniforms:       THREE.UniformsUtils.clone( directionalLightShader.uniforms ),
 			uniforms:       THREE.UniformsUtils.clone( directionalLightShader.uniforms ),
 			vertexShader:   directionalLightShader.vertexShader,
 			vertexShader:   directionalLightShader.vertexShader,
 			fragmentShader: directionalLightShader.fragmentShader,
 			fragmentShader: directionalLightShader.fragmentShader,
-			defines:		{ "ADDITIVE_SPECULAR": additiveSpecular },
 
 
 			blending:		THREE.AdditiveBlending,
 			blending:		THREE.AdditiveBlending,
 			depthWrite:		false,
 			depthWrite:		false,
@@ -332,8 +295,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 		materialLight.uniforms[ "viewHeight" ].value = scaledHeight;
 		materialLight.uniforms[ "viewHeight" ].value = scaledHeight;
 
 
 		materialLight.uniforms[ 'samplerColor' ].value = compColor.renderTarget2;
 		materialLight.uniforms[ 'samplerColor' ].value = compColor.renderTarget2;
-		materialLight.uniforms[ 'samplerDepth' ].value = compDepth.renderTarget2;
-		materialLight.uniforms[ 'samplerNormals' ].value = compNormal.renderTarget2;
+		materialLight.uniforms[ 'samplerNormalDepth' ].value = compNormalDepth.renderTarget2;
 
 
 		// create light proxy mesh
 		// create light proxy mesh
 
 
@@ -358,7 +320,8 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 			vertexShader:   emissiveLightShader.vertexShader,
 			vertexShader:   emissiveLightShader.vertexShader,
 			fragmentShader: emissiveLightShader.fragmentShader,
 			fragmentShader: emissiveLightShader.fragmentShader,
 			depthTest:		false,
 			depthTest:		false,
-			depthWrite:		false
+			depthWrite:		false,
+			blending:		THREE.NoBlending
 
 
 		} );
 		} );
 
 
@@ -367,7 +330,6 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 		materialLight.uniforms[ "viewHeight" ].value = scaledHeight;
 		materialLight.uniforms[ "viewHeight" ].value = scaledHeight;
 
 
 		materialLight.uniforms[ 'samplerColor' ].value = compColor.renderTarget2;
 		materialLight.uniforms[ 'samplerColor' ].value = compColor.renderTarget2;
-		materialLight.uniforms[ 'samplerDepth' ].value = compDepth.renderTarget2;
 
 
 		// create light proxy mesh
 		// create light proxy mesh
 
 
@@ -412,15 +374,9 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 
 
 	};
 	};
 
 
-	var setMaterialDepth = function ( object ) {
-
-		if ( object.material ) object.material = object.properties.depthMaterial;
-
-	};
-
-	var setMaterialNormal = function ( object ) {
+	var setMaterialNormalDepth = function ( object ) {
 
 
-		if ( object.material ) object.material = object.properties.normalMaterial;
+		if ( object.material ) object.material = object.properties.normalDepthMaterial;
 
 
 	};
 	};
 
 
@@ -434,8 +390,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 		scaledHeight = Math.floor( scale * height );
 		scaledHeight = Math.floor( scale * height );
 
 
 		compColor.setSize( scaledWidth, scaledHeight );
 		compColor.setSize( scaledWidth, scaledHeight );
-		compNormal.setSize( scaledWidth, scaledHeight );
-		compDepth.setSize( scaledWidth, scaledHeight );
+		compNormalDepth.setSize( scaledWidth, scaledHeight );
 		compLight.setSize( scaledWidth, scaledHeight );
 		compLight.setSize( scaledWidth, scaledHeight );
 		compFinal.setSize( scaledWidth, scaledHeight );
 		compFinal.setSize( scaledWidth, scaledHeight );
 
 
@@ -447,11 +402,10 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 			uniforms[ "viewHeight" ].value = scaledHeight;
 			uniforms[ "viewHeight" ].value = scaledHeight;
 
 
 			uniforms[ 'samplerColor' ].value = compColor.renderTarget2;
 			uniforms[ 'samplerColor' ].value = compColor.renderTarget2;
-			uniforms[ 'samplerDepth' ].value = compDepth.renderTarget2;
 
 
-			if ( uniforms[ 'samplerNormals' ] ) {
+			if ( uniforms[ 'samplerNormalDepth' ] ) {
 
 
-				uniforms[ 'samplerNormals' ].value = compNormal.renderTarget2;
+				uniforms[ 'samplerNormalDepth' ].value = compNormalDepth.renderTarget2;
 
 
 			}
 			}
 
 
@@ -483,33 +437,33 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 		lightSceneFullscreen = scene.properties.lightSceneFullscreen;
 		lightSceneFullscreen = scene.properties.lightSceneFullscreen;
 
 
 		passColor.camera = camera;
 		passColor.camera = camera;
-		passNormal.camera = camera;
-		passDepth.camera = camera;
+		passNormalDepth.camera = camera;
 		passLightProxy.camera = camera;
 		passLightProxy.camera = camera;
 		passLightFullscreen.camera = THREE.EffectComposer.camera;
 		passLightFullscreen.camera = THREE.EffectComposer.camera;
 
 
 		passColor.scene = scene;
 		passColor.scene = scene;
-		passNormal.scene = scene;
-		passDepth.scene = scene;
+		passNormalDepth.scene = scene;
 		passLightFullscreen.scene = lightSceneFullscreen;
 		passLightFullscreen.scene = lightSceneFullscreen;
 		passLightProxy.scene = lightSceneProxy;
 		passLightProxy.scene = lightSceneProxy;
 
 
 		scene.traverse( initDeferredProperties );
 		scene.traverse( initDeferredProperties );
 
 
+		// update scene graph only once per frame
+
+		this.renderer.autoUpdateScene = false;
+		scene.updateMatrixWorld();
+
 		// g-buffer color
 		// g-buffer color
 
 
 		scene.traverse( setMaterialColor );
 		scene.traverse( setMaterialColor );
 		compColor.render();
 		compColor.render();
 
 
-		// g-buffer depth
-
-		scene.traverse( setMaterialDepth );
-		compDepth.render();
+		// g-buffer normals + depth
 
 
-		// g-buffer normals
+		scene.traverse( setMaterialNormalDepth );
+		compNormalDepth.render();
 
 
-		scene.traverse( setMaterialNormal );
-		compNormal.render();
+		this.renderer.autoUpdateScene = true;
 
 
 		// light pass
 		// light pass
 
 
@@ -554,32 +508,36 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 		// g-buffers
 		// g-buffers
 
 
 		var rtColor   = new THREE.WebGLRenderTarget( scaledWidth, scaledHeight, rtParamsFloatNearest );
 		var rtColor   = new THREE.WebGLRenderTarget( scaledWidth, scaledHeight, rtParamsFloatNearest );
-		var rtNormal  = new THREE.WebGLRenderTarget( scaledWidth, scaledHeight, rtParamsFloatLinear );
-		var rtDepth   = new THREE.WebGLRenderTarget( scaledWidth, scaledHeight, rtParamsFloatLinear );
+		var rtNormalDepth = new THREE.WebGLRenderTarget( scaledWidth, scaledHeight, rtParamsFloatLinear );
 		var rtLight   = new THREE.WebGLRenderTarget( scaledWidth, scaledHeight, rtParamsFloatLinear );
 		var rtLight   = new THREE.WebGLRenderTarget( scaledWidth, scaledHeight, rtParamsFloatLinear );
 		var rtFinal   = new THREE.WebGLRenderTarget( scaledWidth, scaledHeight, rtParamsUByte );
 		var rtFinal   = new THREE.WebGLRenderTarget( scaledWidth, scaledHeight, rtParamsUByte );
 
 
 		rtColor.generateMipmaps = false;
 		rtColor.generateMipmaps = false;
-		rtNormal.generateMipmaps = false;
-		rtDepth.generateMipmaps = false;
+		rtNormalDepth.generateMipmaps = false;
 		rtLight.generateMipmaps = false;
 		rtLight.generateMipmaps = false;
 		rtFinal.generateMipmaps = false;
 		rtFinal.generateMipmaps = false;
 
 
-		// composers
+		// color composer
 
 
 		passColor = new THREE.RenderPass();
 		passColor = new THREE.RenderPass();
+		passColor.clear = true;
+
 		compColor = new THREE.EffectComposer( _this.renderer, rtColor );
 		compColor = new THREE.EffectComposer( _this.renderer, rtColor );
 		compColor.addPass( passColor );
 		compColor.addPass( passColor );
 
 
-		passNormal = new THREE.RenderPass();
-		compNormal = new THREE.EffectComposer( _this.renderer, rtNormal );
-		compNormal.addPass( passNormal );
+		// normal + depth composer
+
+		passNormalDepth = new THREE.RenderPass();
+		passNormalDepth.clear = true;
 
 
-		passDepth = new THREE.RenderPass();
-		compDepth = new THREE.EffectComposer( _this.renderer, rtDepth );
-		compDepth.addPass( passDepth );
+		compNormalDepth = new THREE.EffectComposer( _this.renderer, rtNormalDepth );
+		compNormalDepth.addPass( passNormalDepth );
+
+		// light composer
 
 
 		passLightFullscreen = new THREE.RenderPass();
 		passLightFullscreen = new THREE.RenderPass();
+		passLightFullscreen.clear = true;
+
 		passLightProxy = new THREE.RenderPass();
 		passLightProxy = new THREE.RenderPass();
 		passLightProxy.clear = false;
 		passLightProxy.clear = false;
 
 
@@ -587,11 +545,13 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 		compLight.addPass( passLightFullscreen );
 		compLight.addPass( passLightFullscreen );
 		compLight.addPass( passLightProxy );
 		compLight.addPass( passLightProxy );
 
 
-		// composite
+		// final composer
 
 
 		compositePass = new THREE.ShaderPass( compositeShader );
 		compositePass = new THREE.ShaderPass( compositeShader );
 		compositePass.uniforms[ 'samplerLight' ].value = compLight.renderTarget2;
 		compositePass.uniforms[ 'samplerLight' ].value = compLight.renderTarget2;
-		compositePass.uniforms[ 'multiply' ].value = multiply;
+		compositePass.uniforms[ 'brightness' ].value = brightness;
+		compositePass.material.blending = THREE.NoBlending;
+		compositePass.clear = true;
 
 
 		// FXAA
 		// FXAA
 
 

+ 2 - 2
examples/webgl_lights_deferred_morphs.html

@@ -111,7 +111,7 @@
 
 
 				// renderer
 				// renderer
 
 
-				renderer = new THREE.WebGLDeferredRenderer( { width: WIDTH, height: HEIGHT, scale: SCALE, multiply: 2, additiveSpecular: true } );
+				renderer = new THREE.WebGLDeferredRenderer( { width: WIDTH, height: HEIGHT, scale: SCALE, brightness: 2 } );
 
 
 				renderer.domElement.style.position = "absolute";
 				renderer.domElement.style.position = "absolute";
 				renderer.domElement.style.top = MARGIN + "px";
 				renderer.domElement.style.top = MARGIN + "px";
@@ -215,7 +215,7 @@
 
 
 					geometry.computeMorphNormals();
 					geometry.computeMorphNormals();
 
 
-					var material = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x333333, shininess: 20, morphTargets: true, morphNormals: true, vertexColors: THREE.NoColors, shading: THREE.FlatShading } );
+					var material = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x333333, shininess: 20, wrapAround: true, morphTargets: true, morphNormals: true, vertexColors: THREE.NoColors, shading: THREE.FlatShading } );
 					var meshAnim = new THREE.MorphAnimMesh( geometry, material );
 					var meshAnim = new THREE.MorphAnimMesh( geometry, material );
 
 
 					meshAnim.duration = 3000;
 					meshAnim.duration = 3000;

+ 5 - 5
examples/webgl_lights_deferred_pointlights.html

@@ -111,7 +111,7 @@
 
 
 				// renderer
 				// renderer
 
 
-				renderer = new THREE.WebGLDeferredRenderer( { width: WIDTH, height: HEIGHT, scale: SCALE, additiveSpecular: false, multiply: 2 } );
+				renderer = new THREE.WebGLDeferredRenderer( { width: WIDTH, height: HEIGHT, scale: SCALE, brightness: 2 } );
 
 
 				renderer.domElement.style.position = "absolute";
 				renderer.domElement.style.position = "absolute";
 				renderer.domElement.style.top = MARGIN + "px";
 				renderer.domElement.style.top = MARGIN + "px";
@@ -242,7 +242,7 @@
 					mapHeight.anisotropy = 4;
 					mapHeight.anisotropy = 4;
 					mapHeight.format = THREE.RGBFormat;
 					mapHeight.format = THREE.RGBFormat;
 
 
-					var material = new THREE.MeshPhongMaterial( { map: mapColor, bumpMap: mapHeight, bumpScale: 2.5, shininess: 75, specular: 0x090909 } );
+					var material = new THREE.MeshPhongMaterial( { map: mapColor, bumpMap: mapHeight, bumpScale: 2.5, shininess: 75, specular: 0x090909, wrapAround: true, metal: true } );
 
 
 					var object = new THREE.Mesh( geometry, material );
 					var object = new THREE.Mesh( geometry, material );
 					object.scale.multiplyScalar( 8 );
 					object.scale.multiplyScalar( 8 );
@@ -254,7 +254,7 @@
 				var loader = new THREE.BinaryLoader();
 				var loader = new THREE.BinaryLoader();
 				loader.load( "obj/female02/Female02_bin.js", function( geometry, materials ) {
 				loader.load( "obj/female02/Female02_bin.js", function( geometry, materials ) {
 
 
-					var material = new THREE.MeshPhongMaterial( { shininess: 175, specular: 0x999999 } );
+					for ( var i = 0; i < materials.length; i ++ ) materials[ i ].wrapAround = true;
 
 
 					var object = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) );
 					var object = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) );
 					object.position.x = -50;
 					object.position.x = -50;
@@ -266,7 +266,7 @@
 
 
 				loader.load( "obj/male02/Male02_bin.js", function( geometry, materials ) {
 				loader.load( "obj/male02/Male02_bin.js", function( geometry, materials ) {
 
 
-					var material = new THREE.MeshPhongMaterial( { shininess: 175, specular: 0x999999 } );
+					for ( var i = 0; i < materials.length; i ++ ) materials[ i ].wrapAround = true;
 
 
 					var object = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) );
 					var object = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) );
 					object.position.x = 50;
 					object.position.x = 50;
@@ -306,7 +306,7 @@
 
 
 				var matPlane  = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x111111, shininess:  50, bumpMap: mapHeight2, bumpScale: 0.5 } );
 				var matPlane  = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x111111, shininess:  50, bumpMap: mapHeight2, bumpScale: 0.5 } );
 				var matPlane2 = new THREE.MeshPhongMaterial( { color: 0x331919, specular: 0x111111, shininess:  50, bumpMap: mapHeight2, bumpScale: 1 } );
 				var matPlane2 = new THREE.MeshPhongMaterial( { color: 0x331919, specular: 0x111111, shininess:  50, bumpMap: mapHeight2, bumpScale: 1 } );
-				var matPlane3 = new THREE.MeshPhongMaterial( { color: 0x00aaff, specular: 0xffffff, shininess: 200, bumpMap: mapHeight3, bumpScale: 1.2 } );
+				var matPlane3 = new THREE.MeshPhongMaterial( { color: 0x00aaff, specular: 0xffffff, shininess: 200, bumpMap: mapHeight3, bumpScale: 1.2, wrapAround: true } );
 				var matPlane4 = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x111111, shininess:  50, bumpMap: mapHeight3, bumpScale: 1 } );
 				var matPlane4 = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x111111, shininess:  50, bumpMap: mapHeight3, bumpScale: 1 } );
 
 
 				// bottom
 				// bottom

+ 10 - 9
src/core/BufferGeometry.js

@@ -4,8 +4,6 @@
 
 
 THREE.BufferGeometry = function () {
 THREE.BufferGeometry = function () {
 
 
-	THREE.GeometryLibrary.push( this );
-
 	this.id = THREE.GeometryIdCount ++;
 	this.id = THREE.GeometryIdCount ++;
 
 
 	// attributes
 	// attributes
@@ -31,6 +29,8 @@ THREE.BufferGeometry = function () {
 
 
 	this.morphTargets = [];
 	this.morphTargets = [];
 
 
+	THREE.GeometryLibrary[ this.id ] = this;
+
 };
 };
 
 
 THREE.BufferGeometry.prototype = {
 THREE.BufferGeometry.prototype = {
@@ -69,7 +69,7 @@ THREE.BufferGeometry.prototype = {
 
 
 	computeBoundingBox: function () {
 	computeBoundingBox: function () {
 
 
-		if ( ! this.boundingBox ) {
+		if ( this.boundingBox === null ) {
 
 
 			this.boundingBox = new THREE.Box3();
 			this.boundingBox = new THREE.Box3();
 
 
@@ -141,8 +141,10 @@ THREE.BufferGeometry.prototype = {
 
 
 	computeBoundingSphere: function () {
 	computeBoundingSphere: function () {
 
 
-		if ( ! this.boundingSphere ) {
+		if ( this.boundingSphere === null ) {
+
 			this.boundingSphere = new THREE.Sphere();
 			this.boundingSphere = new THREE.Sphere();
+
 		}
 		}
 
 
 		var positions = this.attributes[ "position" ].array;
 		var positions = this.attributes[ "position" ].array;
@@ -251,15 +253,15 @@ THREE.BufferGeometry.prototype = {
 						ab.sub( pA, pB );
 						ab.sub( pA, pB );
 						cb.crossSelf( ab );
 						cb.crossSelf( ab );
 
 
-						normals[ vA * 3 ] 	  += cb.x;
+						normals[ vA * 3 ]     += cb.x;
 						normals[ vA * 3 + 1 ] += cb.y;
 						normals[ vA * 3 + 1 ] += cb.y;
 						normals[ vA * 3 + 2 ] += cb.z;
 						normals[ vA * 3 + 2 ] += cb.z;
 
 
-						normals[ vB * 3 ] 	  += cb.x;
+						normals[ vB * 3 ]     += cb.x;
 						normals[ vB * 3 + 1 ] += cb.y;
 						normals[ vB * 3 + 1 ] += cb.y;
 						normals[ vB * 3 + 2 ] += cb.z;
 						normals[ vB * 3 + 2 ] += cb.z;
 
 
-						normals[ vC * 3 ] 	  += cb.x;
+						normals[ vC * 3 ]     += cb.x;
 						normals[ vC * 3 + 1 ] += cb.y;
 						normals[ vC * 3 + 1 ] += cb.y;
 						normals[ vC * 3 + 2 ] += cb.z;
 						normals[ vC * 3 + 2 ] += cb.z;
 
 
@@ -544,8 +546,7 @@ THREE.BufferGeometry.prototype = {
 
 
 	deallocate: function () {
 	deallocate: function () {
 
 
-		var index = THREE.GeometryLibrary.indexOf( this );
-		if ( index !== -1 ) THREE.GeometryLibrary.splice( index, 1 );
+		delete THREE.GeometryLibrary[ this.id ];
 
 
 	}
 	}
 
 

+ 21 - 8
src/core/Geometry.js

@@ -9,8 +9,6 @@
 
 
 THREE.Geometry = function () {
 THREE.Geometry = function () {
 
 
-	THREE.GeometryLibrary.push( this );
-
 	this.id = THREE.GeometryIdCount ++;
 	this.id = THREE.GeometryIdCount ++;
 
 
 	this.name = '';
 	this.name = '';
@@ -52,11 +50,13 @@ THREE.Geometry = function () {
 
 
 	this.buffersNeedUpdate = false;
 	this.buffersNeedUpdate = false;
 
 
+	THREE.GeometryLibrary[ this.id ] = this;
+
 };
 };
 
 
 THREE.Geometry.prototype = {
 THREE.Geometry.prototype = {
 
 
-	constructor : THREE.Geometry,
+	constructor: THREE.Geometry,
 
 
 	applyMatrix: function ( matrix ) {
 	applyMatrix: function ( matrix ) {
 
 
@@ -577,12 +577,26 @@ THREE.Geometry.prototype = {
 
 
 	computeBoundingBox: function () {
 	computeBoundingBox: function () {
 
 
-		this.boundingBox = new THREE.Box3().setFromPoints( this.vertices );
+		if ( this.boundingBox === null ) {
+
+			this.boundingBox = new THREE.Box3();
+
+		}
+
+		this.boundingBox.setFromPoints( this.vertices );
+
 	},
 	},
 
 
 	computeBoundingSphere: function () {
 	computeBoundingSphere: function () {
 
 
-		this.boundingSphere = new THREE.Sphere().setFromCenterAndPoints( new THREE.Vector3(), this.vertices );
+		if ( this.boundingSphere === null ) {
+
+			this.boundingSphere = new THREE.Sphere();
+
+		}
+
+		this.boundingSphere.setFromCenterAndPoints( this.boundingSphere.center, this.vertices );
+
 	},
 	},
 
 
 	/*
 	/*
@@ -724,12 +738,11 @@ THREE.Geometry.prototype = {
 
 
 	deallocate: function () {
 	deallocate: function () {
 
 
-		var index = THREE.GeometryLibrary.indexOf( this );
-		if ( index !== -1 ) THREE.GeometryLibrary.splice( index, 1 );
+		delete THREE.GeometryLibrary[ this.id ];
 
 
 	}
 	}
 
 
 };
 };
 
 
 THREE.GeometryIdCount = 0;
 THREE.GeometryIdCount = 0;
-THREE.GeometryLibrary = [];
+THREE.GeometryLibrary = {};

+ 4 - 5
src/core/Object3D.js

@@ -6,8 +6,6 @@
 
 
 THREE.Object3D = function () {
 THREE.Object3D = function () {
 
 
-	THREE.Object3DLibrary.push( this );
-
 	this.id = THREE.Object3DIdCount ++;
 	this.id = THREE.Object3DIdCount ++;
 
 
 	this.name = '';
 	this.name = '';
@@ -49,6 +47,8 @@ THREE.Object3D = function () {
 
 
 	this._vector = new THREE.Vector3();
 	this._vector = new THREE.Vector3();
 
 
+	THREE.Object3DLibrary[ this.id ] = this;
+
 };
 };
 
 
 
 
@@ -362,8 +362,7 @@ THREE.Object3D.prototype = {
 
 
 	deallocate: function () {
 	deallocate: function () {
 
 
-		var index = THREE.Object3DLibrary.indexOf( this );
-		if ( index !== -1 ) THREE.Object3DLibrary.splice( index, 1 );
+		delete THREE.Object3DLibrary[ this.id ];
 
 
 	}
 	}
 
 
@@ -373,4 +372,4 @@ THREE.Object3D.__m1 = new THREE.Matrix4();
 THREE.Object3D.defaultEulerOrder = 'XYZ',
 THREE.Object3D.defaultEulerOrder = 'XYZ',
 
 
 THREE.Object3DIdCount = 0;
 THREE.Object3DIdCount = 0;
-THREE.Object3DLibrary = [];
+THREE.Object3DLibrary = {};

+ 25 - 40
src/extras/FontUtils.js

@@ -350,11 +350,6 @@ THREE.FontUtils.generateShapes = function( text, parameters ) {
 
 
 				/* output Triangle */
 				/* output Triangle */
 
 
-				/*
-				result.push( contour[ a ] );
-				result.push( contour[ b ] );
-				result.push( contour[ c ] );
-				*/
 				result.push( [ contour[ a ],
 				result.push( [ contour[ a ],
 					contour[ b ],
 					contour[ b ],
 					contour[ c ] ] );
 					contour[ c ] ] );
@@ -402,34 +397,6 @@ THREE.FontUtils.generateShapes = function( text, parameters ) {
 
 
 	};
 	};
 
 
-	// see if p is inside triangle abc
-
-	var insideTriangle = function( ax, ay,
-								   bx, by,
-								   cx, cy,
-								   px, py ) {
-
-		  var aX, aY, bX, bY;
-		  var cX, cY, apx, apy;
-		  var bpx, bpy, cpx, cpy;
-		  var cCROSSap, bCROSScp, aCROSSbp;
-
-		  aX = cx - bx;  aY = cy - by;
-		  bX = ax - cx;  bY = ay - cy;
-		  cX = bx - ax;  cY = by - ay;
-		  apx= px  -ax;  apy= py - ay;
-		  bpx= px - bx;  bpy= py - by;
-		  cpx= px - cx;  cpy= py - cy;
-
-		  aCROSSbp = aX*bpy - aY*bpx;
-		  cCROSSap = cX*apy - cY*apx;
-		  bCROSScp = bX*cpy - bY*cpx;
-
-		  return ( (aCROSSbp >= 0.0) && (bCROSScp >= 0.0) && (cCROSSap >= 0.0) );
-
-	};
-
-
 	var snip = function ( contour, u, v, w, n, verts ) {
 	var snip = function ( contour, u, v, w, n, verts ) {
 
 
 		var p;
 		var p;
@@ -447,18 +414,36 @@ THREE.FontUtils.generateShapes = function( text, parameters ) {
 
 
 		if ( EPSILON > (((bx-ax)*(cy-ay)) - ((by-ay)*(cx-ax))) ) return false;
 		if ( EPSILON > (((bx-ax)*(cy-ay)) - ((by-ay)*(cx-ax))) ) return false;
 
 
-			for ( p = 0; p < n; p++ ) {
+		var aX, aY, bX, bY, cX, cY;
+		var apx, apy, bpx, bpy, cpx, cpy;
+		var cCROSSap, bCROSScp, aCROSSbp;
+
+		aX = cx - bx;  aY = cy - by;
+		bX = ax - cx;  bY = ay - cy;
+		cX = bx - ax;  cY = by - ay;
+
+		for ( p = 0; p < n; p++ ) {
+
+			if( (p === u) || (p === v) || (p === w) ) continue;
 
 
-				if( (p == u) || (p == v) || (p == w) ) continue;
+			px = contour[ verts[ p ] ].x
+			py = contour[ verts[ p ] ].y
 
 
-				px = contour[ verts[ p ] ].x
-				py = contour[ verts[ p ] ].y
+			apx = px - ax;  apy = py - ay;
+			bpx = px - bx;  bpy = py - by;
+			cpx = px - cx;  cpy = py - cy;
 
 
-				if ( insideTriangle( ax, ay, bx, by, cx, cy, px, py ) ) return false;
+			// see if p is inside triangle abc
 
 
-		  }
+			aCROSSbp = aX*bpy - aY*bpx;
+			cCROSSap = cX*apy - cY*apx;
+			bCROSScp = bX*cpy - bY*cpx;
+
+			if ( (aCROSSbp >= 0.0) && (bCROSScp >= 0.0) && (cCROSSap >= 0.0) ) return false;
+
+		}
 
 
-		  return true;
+		return true;
 
 
 	};
 	};
 
 

+ 10 - 22
src/extras/core/Curve.js

@@ -1,7 +1,7 @@
 /**
 /**
  * @author zz85 / http://www.lab4games.net/zz85/blog
  * @author zz85 / http://www.lab4games.net/zz85/blog
  * Extensible curve object
  * Extensible curve object
- * 
+ *
  * Some common of Curve methods
  * Some common of Curve methods
  * .getPoint(t), getTangent(t)
  * .getPoint(t), getTangent(t)
  * .getPointAt(u), getTagentAt(u)
  * .getPointAt(u), getTagentAt(u)
@@ -110,8 +110,8 @@ 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 ) 
+	if ( this.cacheArcLengths
+		&& ( this.cacheArcLengths.length == divisions + 1 )
 		&& !this.needsUpdate) {
 		&& !this.needsUpdate) {
 
 
 		//console.log( "cached", this.cacheArcLengths );
 		//console.log( "cached", this.cacheArcLengths );
@@ -231,22 +231,10 @@ THREE.Curve.prototype.getUtoTmapping = function ( u, distance ) {
 
 
 };
 };
 
 
-
-// In 2D space, there are actually 2 normal vectors,
-// and in 3D space, infinte
-// TODO this should be depreciated.
-THREE.Curve.prototype.getNormalVector = function( t ) {
-
-	var vec = this.getTangent( t );
-
-	return new THREE.Vector2( -vec.y , vec.x );
-
-};
-
 // Returns a unit vector tangent at t
 // Returns a unit vector tangent at t
-// In case any sub curve does not implement its tangent / normal finding,
-// we get 2 points with a small delta and find a gradient of the 2 points
-// which seems to make a reasonable approximation
+// In case any sub curve does not implement its tangent derivation,
+// 2 points a small delta apart will be used to find its gradient
+// which seems to give a reasonable approximation
 
 
 THREE.Curve.prototype.getTangent = function( t ) {
 THREE.Curve.prototype.getTangent = function( t ) {
 
 
@@ -261,7 +249,7 @@ THREE.Curve.prototype.getTangent = function( t ) {
 
 
 	var pt1 = this.getPoint( t1 );
 	var pt1 = this.getPoint( t1 );
 	var pt2 = this.getPoint( t2 );
 	var pt2 = this.getPoint( t2 );
-	
+
 	var vec = pt2.clone().subSelf(pt1);
 	var vec = pt2.clone().subSelf(pt1);
 	return vec.normalize();
 	return vec.normalize();
 
 
@@ -715,7 +703,7 @@ THREE.SplineCurve3 = THREE.Curve.create(
 // 	v.z = THREE.Curve.Utils.tangentSpline( t, pt0.z, pt1.z, pt2.z, pt3.z );
 // 	v.z = THREE.Curve.Utils.tangentSpline( t, pt0.z, pt1.z, pt2.z, pt3.z );
 
 
 // 	return v;
 // 	return v;
-		
+
 // }
 // }
 
 
 /**************************************************************
 /**************************************************************
@@ -741,7 +729,7 @@ THREE.ClosedSplineCurve3 = THREE.Curve.create(
 
 
         intPoint = Math.floor( point );
         intPoint = Math.floor( point );
         weight = point - intPoint;
         weight = point - intPoint;
-            
+
         intPoint += intPoint > 0 ? 0 : ( Math.floor( Math.abs( intPoint ) / points.length ) + 1 ) * points.length;
         intPoint += intPoint > 0 ? 0 : ( Math.floor( Math.abs( intPoint ) / points.length ) + 1 ) * points.length;
         c[ 0 ] = ( intPoint - 1 ) % points.length;
         c[ 0 ] = ( intPoint - 1 ) % points.length;
         c[ 1 ] = ( intPoint ) % points.length;
         c[ 1 ] = ( intPoint ) % points.length;
@@ -751,7 +739,7 @@ THREE.ClosedSplineCurve3 = THREE.Curve.create(
         v.x = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].x, points[ c[ 1 ] ].x, points[ c[ 2 ] ].x, points[ c[ 3 ] ].x, weight );
         v.x = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].x, points[ c[ 1 ] ].x, points[ c[ 2 ] ].x, points[ c[ 3 ] ].x, weight );
         v.y = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].y, points[ c[ 1 ] ].y, points[ c[ 2 ] ].y, points[ c[ 3 ] ].y, weight );
         v.y = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].y, points[ c[ 1 ] ].y, points[ c[ 2 ] ].y, points[ c[ 3 ] ].y, weight );
         v.z = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].z, points[ c[ 1 ] ].z, points[ c[ 2 ] ].z, points[ c[ 3 ] ].z, weight );
         v.z = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].z, points[ c[ 1 ] ].z, points[ c[ 2 ] ].z, points[ c[ 3 ] ].z, weight );
-        
+
         return v;
         return v;
 
 
     }
     }

+ 6 - 0
src/loaders/Loader.js

@@ -420,6 +420,12 @@ THREE.Loader.prototype = {
 			var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights: true, fog: true };
 			var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights: true, fog: true };
 			var material = new THREE.ShaderMaterial( parameters );
 			var material = new THREE.ShaderMaterial( parameters );
 
 
+			if ( mpars.transparent ) {
+
+				material.transparent = true;
+
+			}
+
 		} else {
 		} else {
 
 
 			var material = new THREE[ mtype ]( mpars );
 			var material = new THREE[ mtype ]( mpars );

+ 4 - 5
src/materials/Material.js

@@ -5,8 +5,6 @@
 
 
 THREE.Material = function () {
 THREE.Material = function () {
 
 
-	THREE.MaterialLibrary.push( this );
-
 	this.id = THREE.MaterialIdCount ++;
 	this.id = THREE.MaterialIdCount ++;
 
 
 	this.name = '';
 	this.name = '';
@@ -37,6 +35,8 @@ THREE.Material = function () {
 
 
 	this.needsUpdate = true;
 	this.needsUpdate = true;
 
 
+	THREE.MaterialLibrary[ this.id ] = this;
+
 };
 };
 
 
 THREE.Material.prototype.setValues = function ( values ) {
 THREE.Material.prototype.setValues = function ( values ) {
@@ -118,10 +118,9 @@ THREE.Material.prototype.clone = function ( material ) {
 
 
 THREE.Material.prototype.deallocate = function () {
 THREE.Material.prototype.deallocate = function () {
 
 
-	var index = THREE.MaterialLibrary.indexOf( this );
-	if ( index !== -1 ) THREE.MaterialLibrary.splice( index, 1 );
+	delete THREE.MaterialLibrary[ this.id ];
 
 
 };
 };
 
 
 THREE.MaterialIdCount = 0;
 THREE.MaterialIdCount = 0;
-THREE.MaterialLibrary = [];
+THREE.MaterialLibrary = {};

+ 7 - 8
src/math/Math.js

@@ -65,20 +65,19 @@ THREE.Math = {
 
 
 		return ( x < 0 ) ? -1 : ( ( x > 0 ) ? 1 : 0 );
 		return ( x < 0 ) ? -1 : ( ( x > 0 ) ? 1 : 0 );
 
 
-	}
-
-	degreesToRadians: function( degrees ) {
+	},
 
 
-	  return degrees * THREE.Math.__d2r;
+	degreesToRadians: function ( degrees ) {
 
 
-	};
+		return degrees * THREE.Math.__d2r;
 
 
-	radiansToDegrees: function( radians ) {
+	},
 
 
-	  return radians * THREE.Math.__r2d;
+	radiansToDegrees: function ( radians ) {
 
 
-	};
+		return radians * THREE.Math.__r2d;
 
 
+	}
 
 
 };
 };
 
 

+ 2 - 13
src/math/Sphere.js

@@ -4,19 +4,9 @@
 
 
 THREE.Sphere = function ( center, radius ) {
 THREE.Sphere = function ( center, radius ) {
 
 
+	this.center = center === undefined ? new THREE.Vector3() : center.clone();
+	this.radius = radius === undefined ? 0 : radius;
 
 
-	if ( center === undefined && radius === undefined ) {
-
-		this.center = new THREE.Vector3();
-		this.radius = 0;
-
-	} else {
-
-		this.center = center.clone();
-		this.radius = radius || 0;
-
-	}
-	
 };
 };
 
 
 THREE.Sphere.prototype = {
 THREE.Sphere.prototype = {
@@ -29,7 +19,6 @@ THREE.Sphere.prototype = {
 		this.radius = radius;
 		this.radius = radius;
 
 
 		return this;
 		return this;
-
 	},
 	},
 
 
 	setFromCenterAndPoints: function ( center, points ) {
 	setFromCenterAndPoints: function ( center, points ) {

+ 4 - 7
src/renderers/WebGLShaders.js

@@ -268,19 +268,16 @@ THREE.ShaderChunk = {
 
 
 		"#ifdef USE_MAP",
 		"#ifdef USE_MAP",
 
 
+			"vec4 texelColor = texture2D( map, vUv );",
+
 			"#ifdef GAMMA_INPUT",
 			"#ifdef GAMMA_INPUT",
 
 
-				"vec4 texelColor = texture2D( map, vUv );",
 				"texelColor.xyz *= texelColor.xyz;",
 				"texelColor.xyz *= texelColor.xyz;",
 
 
-				"gl_FragColor = gl_FragColor * texelColor;",
-
-			"#else",
-
-				"gl_FragColor = gl_FragColor * texture2D( map, vUv );",
-
 			"#endif",
 			"#endif",
 
 
+			"gl_FragColor = gl_FragColor * texelColor;",
+
 		"#endif"
 		"#endif"
 
 
 	].join("\n"),
 	].join("\n"),

+ 4 - 5
src/textures/Texture.js

@@ -6,8 +6,6 @@
 
 
 THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
 THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
 
 
-	THREE.TextureLibrary.push( this );
-
 	this.id = THREE.TextureIdCount ++;
 	this.id = THREE.TextureIdCount ++;
 
 
 	this.name = '';
 	this.name = '';
@@ -39,6 +37,8 @@ THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter, f
 	this.needsUpdate = false;
 	this.needsUpdate = false;
 	this.onUpdate = null;
 	this.onUpdate = null;
 
 
+	THREE.TextureLibrary[ this.id ] = this;
+
 };
 };
 
 
 THREE.Texture.prototype = {
 THREE.Texture.prototype = {
@@ -79,12 +79,11 @@ THREE.Texture.prototype = {
 
 
 	deallocate: function () {
 	deallocate: function () {
 
 
-		var index = THREE.TextureLibrary.indexOf( this );
-		if ( index !== -1 ) THREE.TextureLibrary.splice( index, 1 );
+		delete THREE.TextureLibrary[ this.id ];
 
 
 	}
 	}
 
 
 };
 };
 
 
 THREE.TextureIdCount = 0;
 THREE.TextureIdCount = 0;
-THREE.TextureLibrary = [];
+THREE.TextureLibrary = {};

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