Browse Source

Merge remote branch 'upstream/master'

timk 14 years ago
parent
commit
781dc18eb0
3 changed files with 15 additions and 22 deletions
  1. 2 2
      examples/js/Tween.js
  2. 4 3
      src/extras/geometries/TorusGeometry.js
  3. 9 17
      src/renderers/WebGLRenderer.js

+ 2 - 2
examples/js/Tween.js

@@ -1,5 +1,5 @@
-// tween.js r1 - http://github.com/sole/tween.js
-var TWEEN=TWEEN||function(){var a,e,c,d,f=[];return{start:function(g){c=setInterval(this.update,1E3/(g||60))},stop:function(){clearInterval(c)},add:function(g){f.push(g)},remove:function(g){a=f.indexOf(g);a!==-1&&f.splice(a,1)},update:function(){a=0;e=f.length;for(d=(new Date).getTime();a<e;)if(f[a].update(d))a++;else{f.splice(a,1);e--}}}}();
+// tween.js r2 - http://github.com/sole/tween.js
+var TWEEN=TWEEN||function(){var a,e,c,d,f=[];return{start:function(g){c=setInterval(this.update,1E3/(g||60))},stop:function(){clearInterval(c)},add:function(g){f.push(g)},getAll:function(){return f},removeAll:function(){f=[]},remove:function(g){a=f.indexOf(g);a!==-1&&f.splice(a,1)},update:function(){a=0;e=f.length;for(d=(new Date).getTime();a<e;)if(f[a].update(d))a++;else{f.splice(a,1);e--}}}}();
 TWEEN.Tween=function(a){var e={},c={},d={},f=1E3,g=0,j=null,n=TWEEN.Easing.Linear.EaseNone,k=null,l=null,m=null;this.to=function(b,h){if(h!==null)f=h;for(var i in b)if(a[i]!==null)d[i]=b[i];return this};this.start=function(){TWEEN.add(this);j=(new Date).getTime()+g;for(var b in d)if(a[b]!==null){e[b]=a[b];c[b]=d[b]-a[b]}return this};this.stop=function(){TWEEN.remove(this);return this};this.delay=function(b){g=b;return this};this.easing=function(b){n=b;return this};this.chain=function(b){k=b};this.onUpdate=
 TWEEN.Tween=function(a){var e={},c={},d={},f=1E3,g=0,j=null,n=TWEEN.Easing.Linear.EaseNone,k=null,l=null,m=null;this.to=function(b,h){if(h!==null)f=h;for(var i in b)if(a[i]!==null)d[i]=b[i];return this};this.start=function(){TWEEN.add(this);j=(new Date).getTime()+g;for(var b in d)if(a[b]!==null){e[b]=a[b];c[b]=d[b]-a[b]}return this};this.stop=function(){TWEEN.remove(this);return this};this.delay=function(b){g=b;return this};this.easing=function(b){n=b;return this};this.chain=function(b){k=b};this.onUpdate=
 function(b){l=b;return this};this.onComplete=function(b){m=b;return this};this.update=function(b){var h,i;if(b<j)return true;b=(b-j)/f;b=b>1?1:b;i=n(b);for(h in c)a[h]=e[h]+c[h]*i;l!==null&&l.call(a,i);if(b==1){m!==null&&m.call(a);k!==null&&k.start();return false}return true}};TWEEN.Easing={Linear:{},Quadratic:{},Cubic:{},Quartic:{},Quintic:{},Sinusoidal:{},Exponential:{},Circular:{},Elastic:{},Back:{},Bounce:{}};TWEEN.Easing.Linear.EaseNone=function(a){return a};
 function(b){l=b;return this};this.onComplete=function(b){m=b;return this};this.update=function(b){var h,i;if(b<j)return true;b=(b-j)/f;b=b>1?1:b;i=n(b);for(h in c)a[h]=e[h]+c[h]*i;l!==null&&l.call(a,i);if(b==1){m!==null&&m.call(a);k!==null&&k.start();return false}return true}};TWEEN.Easing={Linear:{},Quadratic:{},Cubic:{},Quartic:{},Quintic:{},Sinusoidal:{},Exponential:{},Circular:{},Elastic:{},Back:{},Bounce:{}};TWEEN.Easing.Linear.EaseNone=function(a){return a};
 TWEEN.Easing.Quadratic.EaseIn=function(a){return a*a};TWEEN.Easing.Quadratic.EaseOut=function(a){return-a*(a-2)};TWEEN.Easing.Quadratic.EaseInOut=function(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)};TWEEN.Easing.Cubic.EaseIn=function(a){return a*a*a};TWEEN.Easing.Cubic.EaseOut=function(a){return--a*a*a+1};TWEEN.Easing.Cubic.EaseInOut=function(a){if((a*=2)<1)return 0.5*a*a*a;return 0.5*((a-=2)*a*a+2)};TWEEN.Easing.Quartic.EaseIn=function(a){return a*a*a*a};
 TWEEN.Easing.Quadratic.EaseIn=function(a){return a*a};TWEEN.Easing.Quadratic.EaseOut=function(a){return-a*(a-2)};TWEEN.Easing.Quadratic.EaseInOut=function(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)};TWEEN.Easing.Cubic.EaseIn=function(a){return a*a*a};TWEEN.Easing.Cubic.EaseOut=function(a){return--a*a*a+1};TWEEN.Easing.Cubic.EaseInOut=function(a){if((a*=2)<1)return 0.5*a*a*a;return 0.5*((a-=2)*a*a+2)};TWEEN.Easing.Quartic.EaseIn=function(a){return a*a*a*a};

+ 4 - 3
src/extras/geometries/TorusGeometry.js

@@ -3,7 +3,7 @@
  * based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3DLite/src/away3dlite/primitives/Torus.as?r=2888
  * based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3DLite/src/away3dlite/primitives/Torus.as?r=2888
  */
  */
 
 
-THREE.TorusGeometry = function ( radius, tube, segmentsR, segmentsT ) {
+THREE.TorusGeometry = function ( radius, tube, segmentsR, segmentsT, arc ) {
 
 
 	THREE.Geometry.call( this );
 	THREE.Geometry.call( this );
 
 
@@ -13,14 +13,15 @@ THREE.TorusGeometry = function ( radius, tube, segmentsR, segmentsT ) {
 	this.tube = tube || 40;
 	this.tube = tube || 40;
 	this.segmentsR = segmentsR || 8;
 	this.segmentsR = segmentsR || 8;
 	this.segmentsT = segmentsT || 6;
 	this.segmentsT = segmentsT || 6;
+	this.arc = arc || (2 * Math.PI);
 
 
 	var temp_uv = [];
 	var temp_uv = [];
 
 
 	for ( var j = 0; j <= this.segmentsR; ++j ) {
 	for ( var j = 0; j <= this.segmentsR; ++j ) {
 
 
 		for ( var i = 0; i <= this.segmentsT; ++i ) {
 		for ( var i = 0; i <= this.segmentsT; ++i ) {
-
-			var u = i / this.segmentsT * 2 * Math.PI;
+		
+			var u = i / this.segmentsT * this.arc;
 			var v = j / this.segmentsR * 2 * Math.PI;
 			var v = j / this.segmentsR * 2 * Math.PI;
 			var x = (this.radius + this.tube*Math.cos(v))*Math.cos(u);
 			var x = (this.radius + this.tube*Math.cos(v))*Math.cos(u);
 			var y = (this.radius + this.tube*Math.cos(v))*Math.sin(u);
 			var y = (this.radius + this.tube*Math.cos(v))*Math.sin(u);

+ 9 - 17
src/renderers/WebGLRenderer.js

@@ -7,18 +7,9 @@
 
 
 THREE.WebGLRenderer = function ( parameters ) {
 THREE.WebGLRenderer = function ( parameters ) {
 
 
-	// Currently you can use just up to 4 directional / point lights total.
-	// Chrome barfs on shader linking when there are more than 4 lights :(
-
-	// The problem comes from shader using too many varying vectors.
-
-	// This is not GPU limitation as the same shader works ok in Firefox
-	// and Chrome with "--use-gl=desktop" flag.
-
-	// Difference comes from Chrome on Windows using by default ANGLE,
-	// thus going DirectX9 route (while FF uses OpenGL).
-
-	// See http://code.google.com/p/chromium/issues/detail?id=63491
+	// By default you can use just up to 4 directional / point lights total.
+	// ANGLE implementation (Chrome/Firefox on Windows) is bound to
+	// 10 varying vectors due to DirectX9 limitation.
 
 
 	var _this = this,
 	var _this = this,
 	_gl, _programs = [],
 	_gl, _programs = [],
@@ -79,6 +70,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 	_antialias = parameters.antialias !== undefined ? parameters.antialias : false,
 	_antialias = parameters.antialias !== undefined ? parameters.antialias : false,
 	_clearColor = parameters.clearColor !== undefined ? new THREE.Color( parameters.clearColor ) : new THREE.Color( 0x000000 ),
 	_clearColor = parameters.clearColor !== undefined ? new THREE.Color( parameters.clearColor ) : new THREE.Color( 0x000000 ),
 	_clearAlpha = parameters.clearAlpha !== undefined ? parameters.clearAlpha : 0;
 	_clearAlpha = parameters.clearAlpha !== undefined ? parameters.clearAlpha : 0;
+	_maxLights = parameters.maxLights !== undefined ? parameters.maxLights : 4;
 
 
 	this.data = {
 	this.data = {
 
 
@@ -2480,7 +2472,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		// heuristics to create shader parameters according to lights in the scene
 		// heuristics to create shader parameters according to lights in the scene
 		// (not to blow over maxLights budget)
 		// (not to blow over maxLights budget)
 
 
-		maxLightCount = allocateLights( lights, 4 );
+		maxLightCount = allocateLights( lights );
 
 
 		maxShadows = allocateShadows( lights );
 		maxShadows = allocateShadows( lights );
 
 
@@ -5345,7 +5337,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	};
 	};
 
 
-	function allocateLights( lights, maxLights ) {
+	function allocateLights( lights ) {
 
 
 		var l, ll, light, dirLights, pointLights, maxDirLights, maxPointLights;
 		var l, ll, light, dirLights, pointLights, maxDirLights, maxPointLights;
 		dirLights = pointLights = maxDirLights = maxPointLights = 0;
 		dirLights = pointLights = maxDirLights = maxPointLights = 0;
@@ -5360,15 +5352,15 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		}
 		}
 
 
-		if ( ( pointLights + dirLights ) <= maxLights ) {
+		if ( ( pointLights + dirLights ) <= _maxLights ) {
 
 
 			maxDirLights = dirLights;
 			maxDirLights = dirLights;
 			maxPointLights = pointLights;
 			maxPointLights = pointLights;
 
 
 		} else {
 		} else {
 
 
-			maxDirLights = Math.ceil( maxLights * dirLights / ( pointLights + dirLights ) );
-			maxPointLights = maxLights - maxDirLights;
+			maxDirLights = Math.ceil( _maxLights * dirLights / ( pointLights + dirLights ) );
+			maxPointLights = _maxLights - maxDirLights;
 
 
 		}
 		}