From fd1618881fa4db09196e739aa541aad692d0f753 Mon Sep 17 00:00:00 2001 From: Chandler Prall Date: Fri, 15 Jul 2011 19:33:59 -0700 Subject: [PATCH 1/2] Making the variable user-customizable --- src/renderers/WebGLRenderer.js | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index e0a77bbb..a1518913 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -7,18 +7,9 @@ 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, _gl, _programs = [], @@ -78,6 +69,7 @@ THREE.WebGLRenderer = function ( parameters ) { _antialias = parameters.antialias !== undefined ? parameters.antialias : false, _clearColor = parameters.clearColor !== undefined ? new THREE.Color( parameters.clearColor ) : new THREE.Color( 0x000000 ), _clearAlpha = parameters.clearAlpha !== undefined ? parameters.clearAlpha : 0; + _maxLights = parameters.maxLights !== undefined ? parameters.maxLights : 4; this.data = { @@ -2310,7 +2302,7 @@ THREE.WebGLRenderer = function ( parameters ) { // heuristics to create shader parameters according to lights in the scene // (not to blow over maxLights budget) - maxLightCount = allocateLights( lights, 4 ); + maxLightCount = allocateLights( lights ); maxBones = allocateBones( object ); @@ -5329,7 +5321,7 @@ THREE.WebGLRenderer = function ( parameters ) { }; - function allocateLights( lights, maxLights ) { + function allocateLights( lights ) { var l, ll, light, dirLights, pointLights, maxDirLights, maxPointLights; dirLights = pointLights = maxDirLights = maxPointLights = 0; @@ -5343,15 +5335,15 @@ THREE.WebGLRenderer = function ( parameters ) { } - if ( ( pointLights + dirLights ) <= maxLights ) { + if ( ( pointLights + dirLights ) <= _maxLights ) { maxDirLights = dirLights; maxPointLights = pointLights; } else { - maxDirLights = Math.ceil( maxLights * dirLights / ( pointLights + dirLights ) ); - maxPointLights = maxLights - maxDirLights; + maxDirLights = Math.ceil( _maxLights * dirLights / ( pointLights + dirLights ) ); + maxPointLights = _maxLights - maxDirLights; } From 5ce5f942cf079de416318d5600ec24fe0bc09ea9 Mon Sep 17 00:00:00 2001 From: hayfield Date: Wed, 17 Aug 2011 15:09:20 +0100 Subject: [PATCH 2/2] Add arc parameter to TorusGeometry, so it can be used to build half-tori and quarter-tori (e.g. for 90-degree pipe bends). --- src/extras/geometries/TorusGeometry.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/extras/geometries/TorusGeometry.js b/src/extras/geometries/TorusGeometry.js index b9f3b0bf..3314fdd0 100644 --- a/src/extras/geometries/TorusGeometry.js +++ b/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 */ -THREE.TorusGeometry = function ( radius, tube, segmentsR, segmentsT ) { +THREE.TorusGeometry = function ( radius, tube, segmentsR, segmentsT, arc ) { THREE.Geometry.call( this ); @@ -13,14 +13,15 @@ THREE.TorusGeometry = function ( radius, tube, segmentsR, segmentsT ) { this.tube = tube || 40; this.segmentsR = segmentsR || 8; this.segmentsT = segmentsT || 6; + this.arc = arc || (2 * Math.PI); var temp_uv = []; for ( var j = 0; j <= this.segmentsR; ++j ) { 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 x = (this.radius + this.tube*Math.cos(v))*Math.cos(u); var y = (this.radius + this.tube*Math.cos(v))*Math.sin(u);