Browse Source

Added handling of "light.visible" to WebGLRenderer.

Fixes #1945.
alteredq 13 years ago
parent
commit
2751c2c76d
3 changed files with 9 additions and 9 deletions
  1. 1 1
      build/Three.js
  2. 7 7
      build/custom/ThreeWebGL.js
  3. 1 1
      src/renderers/WebGLRenderer.js

+ 1 - 1
build/Three.js

@@ -302,7 +302,7 @@ a[m];if(k.render){i=k.object;j=k.buffer;if(h)k=h;else{k=k[c];if(!k)continue;g&&C
 f&&C.setBlending(h.blending,h.blendEquation,h.blendSrc,h.blendDst);C.setDepthTest(h.depthTest);C.setDepthWrite(h.depthWrite);t(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}C.renderImmediateObject(c,d,e,h,k)}}}function o(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function m(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return true;return false}function p(a){for(var b in a.attributes)a.attributes[b].needsUpdate=false}function r(a,b){for(var c=a.length-
 1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function n(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function q(a,b,c,d,e){if(d.needsUpdate){d.program&&C.deallocateMaterial(d);C.initMaterial(d,b,c,e);d.needsUpdate=false}if(d.morphTargets&&!e.__webglMorphTargetInfluences)e.__webglMorphTargetInfluences=new Float32Array(C.maxMorphTargets);var f=false,g=d.program,h=g.uniforms,i=d.uniforms;if(g!==S){k.useProgram(g);S=g;f=true}if(d.id!==K){K=d.id;f=true}if(f||a!==ga){k.uniformMatrix4fv(h.projectionMatrix,
 false,a._projectionMatrixArray);a!==ga&&(ga=a)}if(f){if(c&&d.fog){i.fogColor.value=c.color;if(c instanceof THREE.Fog){i.fogNear.value=c.near;i.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)i.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(ma){for(var j,l=0,m=0,n=0,o,p,r,q=ob,t=q.directional.colors,u=q.directional.positions,v=q.point.colors,y=q.point.positions,x=q.point.distances,G=q.spot.colors,B=q.spot.positions,H=q.spot.distances,
-Z=q.spot.directions,I=q.spot.angles,F=q.spot.exponents,N=0,M=0,Y=0,O=r=0,c=O=0,f=b.length;c<f;c++){j=b[c];if(!j.onlyShadow){o=j.color;p=j.intensity;r=j.distance;if(j instanceof THREE.AmbientLight)if(C.gammaInput){l=l+o.r*o.r;m=m+o.g*o.g;n=n+o.b*o.b}else{l=l+o.r;m=m+o.g;n=n+o.b}else if(j instanceof THREE.DirectionalLight){r=N*3;if(C.gammaInput){t[r]=o.r*o.r*p*p;t[r+1]=o.g*o.g*p*p;t[r+2]=o.b*o.b*p*p}else{t[r]=o.r*p;t[r+1]=o.g*p;t[r+2]=o.b*p}Ea.copy(j.matrixWorld.getPosition());Ea.subSelf(j.target.matrixWorld.getPosition());
+Z=q.spot.directions,I=q.spot.angles,F=q.spot.exponents,N=0,M=0,Y=0,O=r=0,c=O=0,f=b.length;c<f;c++){j=b[c];if(!j.onlyShadow&&j.visible){o=j.color;p=j.intensity;r=j.distance;if(j instanceof THREE.AmbientLight)if(C.gammaInput){l=l+o.r*o.r;m=m+o.g*o.g;n=n+o.b*o.b}else{l=l+o.r;m=m+o.g;n=n+o.b}else if(j instanceof THREE.DirectionalLight){r=N*3;if(C.gammaInput){t[r]=o.r*o.r*p*p;t[r+1]=o.g*o.g*p*p;t[r+2]=o.b*o.b*p*p}else{t[r]=o.r*p;t[r+1]=o.g*p;t[r+2]=o.b*p}Ea.copy(j.matrixWorld.getPosition());Ea.subSelf(j.target.matrixWorld.getPosition());
 Ea.normalize();u[r]=Ea.x;u[r+1]=Ea.y;u[r+2]=Ea.z;N=N+1}else if(j instanceof THREE.PointLight){O=M*3;if(C.gammaInput){v[O]=o.r*o.r*p*p;v[O+1]=o.g*o.g*p*p;v[O+2]=o.b*o.b*p*p}else{v[O]=o.r*p;v[O+1]=o.g*p;v[O+2]=o.b*p}o=j.matrixWorld.getPosition();y[O]=o.x;y[O+1]=o.y;y[O+2]=o.z;x[M]=r;M=M+1}else if(j instanceof THREE.SpotLight){O=Y*3;if(C.gammaInput){G[O]=o.r*o.r*p*p;G[O+1]=o.g*o.g*p*p;G[O+2]=o.b*o.b*p*p}else{G[O]=o.r*p;G[O+1]=o.g*p;G[O+2]=o.b*p}o=j.matrixWorld.getPosition();B[O]=o.x;B[O+1]=o.y;B[O+2]=
 o.z;H[Y]=r;Ea.copy(o);Ea.subSelf(j.target.matrixWorld.getPosition());Ea.normalize();Z[O]=Ea.x;Z[O+1]=Ea.y;Z[O+2]=Ea.z;I[Y]=Math.cos(j.angle);F[Y]=j.exponent;Y=Y+1}}}c=N*3;for(f=t.length;c<f;c++)t[c]=0;c=M*3;for(f=v.length;c<f;c++)v[c]=0;c=Y*3;for(f=G.length;c<f;c++)G[c]=0;q.directional.length=N;q.point.length=M;q.spot.length=Y;q.ambient[0]=l;q.ambient[1]=m;q.ambient[2]=n;ma=false}c=ob;i.ambientLightColor.value=c.ambient;i.directionalLightColor.value=c.directional.colors;i.directionalLightDirection.value=
 c.directional.positions;i.pointLightColor.value=c.point.colors;i.pointLightPosition.value=c.point.positions;i.pointLightDistance.value=c.point.distances;i.spotLightColor.value=c.spot.colors;i.spotLightPosition.value=c.spot.positions;i.spotLightDistance.value=c.spot.distances;i.spotLightDirection.value=c.spot.directions;i.spotLightAngle.value=c.spot.angles;i.spotLightExponent.value=c.spot.exponents}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial){i.opacity.value=

+ 7 - 7
build/custom/ThreeWebGL.js

@@ -266,7 +266,7 @@ b;m=m+l){i=a[m];if(i.render){j=i.object;k=i.buffer;if(h)i=h;else{i=i[c];if(!i)co
 h[b];if(!h)continue;e&&F.setBlending(h.blending,h.blendEquation,h.blendSrc,h.blendDst);F.setDepthTest(h.depthTest);F.setDepthWrite(h.depthWrite);p(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}F.renderImmediateObject(c,d,g,h,i)}}}function o(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function m(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return true;return false}function v(a){for(var b in a.attributes)a.attributes[b].needsUpdate=false}function r(a,
 b){for(var c=a.length-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function n(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function q(a,b,c,d,e){if(d.needsUpdate){d.program&&F.deallocateMaterial(d);F.initMaterial(d,b,c,e);d.needsUpdate=false}if(d.morphTargets&&!e.__webglMorphTargetInfluences)e.__webglMorphTargetInfluences=new Float32Array(F.maxMorphTargets);var f=false,h=d.program,i=h.uniforms,j=d.uniforms;if(h!==za){g.useProgram(h);za=h;f=true}if(d.id!==na){na=d.id;f=true}if(f||a!==ga){g.uniformMatrix4fv(i.projectionMatrix,
 false,a._projectionMatrixArray);a!==ga&&(ga=a)}if(f){if(c&&d.fog){j.fogColor.value=c.color;if(c instanceof THREE.Fog){j.fogNear.value=c.near;j.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)j.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(ob){for(var k,l=0,m=0,n=0,o,q,r,p=bc,v=p.directional.colors,w=p.directional.positions,t=p.point.colors,z=p.point.positions,D=p.point.distances,E=p.spot.colors,I=p.spot.positions,L=p.spot.distances,
-K=p.spot.directions,M=p.spot.angles,Q=p.spot.exponents,S=0,R=0,T=0,H=r=0,c=H=0,f=b.length;c<f;c++){k=b[c];if(!k.onlyShadow){o=k.color;q=k.intensity;r=k.distance;if(k instanceof THREE.AmbientLight)if(F.gammaInput){l=l+o.r*o.r;m=m+o.g*o.g;n=n+o.b*o.b}else{l=l+o.r;m=m+o.g;n=n+o.b}else if(k instanceof THREE.DirectionalLight){r=S*3;if(F.gammaInput){v[r]=o.r*o.r*q*q;v[r+1]=o.g*o.g*q*q;v[r+2]=o.b*o.b*q*q}else{v[r]=o.r*q;v[r+1]=o.g*q;v[r+2]=o.b*q}Ca.copy(k.matrixWorld.getPosition());Ca.subSelf(k.target.matrixWorld.getPosition());
+K=p.spot.directions,M=p.spot.angles,Q=p.spot.exponents,S=0,R=0,T=0,H=r=0,c=H=0,f=b.length;c<f;c++){k=b[c];if(!k.onlyShadow&&k.visible){o=k.color;q=k.intensity;r=k.distance;if(k instanceof THREE.AmbientLight)if(F.gammaInput){l=l+o.r*o.r;m=m+o.g*o.g;n=n+o.b*o.b}else{l=l+o.r;m=m+o.g;n=n+o.b}else if(k instanceof THREE.DirectionalLight){r=S*3;if(F.gammaInput){v[r]=o.r*o.r*q*q;v[r+1]=o.g*o.g*q*q;v[r+2]=o.b*o.b*q*q}else{v[r]=o.r*q;v[r+1]=o.g*q;v[r+2]=o.b*q}Ca.copy(k.matrixWorld.getPosition());Ca.subSelf(k.target.matrixWorld.getPosition());
 Ca.normalize();w[r]=Ca.x;w[r+1]=Ca.y;w[r+2]=Ca.z;S=S+1}else if(k instanceof THREE.PointLight){H=R*3;if(F.gammaInput){t[H]=o.r*o.r*q*q;t[H+1]=o.g*o.g*q*q;t[H+2]=o.b*o.b*q*q}else{t[H]=o.r*q;t[H+1]=o.g*q;t[H+2]=o.b*q}o=k.matrixWorld.getPosition();z[H]=o.x;z[H+1]=o.y;z[H+2]=o.z;D[R]=r;R=R+1}else if(k instanceof THREE.SpotLight){H=T*3;if(F.gammaInput){E[H]=o.r*o.r*q*q;E[H+1]=o.g*o.g*q*q;E[H+2]=o.b*o.b*q*q}else{E[H]=o.r*q;E[H+1]=o.g*q;E[H+2]=o.b*q}o=k.matrixWorld.getPosition();I[H]=o.x;I[H+1]=o.y;I[H+2]=
 o.z;L[T]=r;Ca.copy(o);Ca.subSelf(k.target.matrixWorld.getPosition());Ca.normalize();K[H]=Ca.x;K[H+1]=Ca.y;K[H+2]=Ca.z;M[T]=Math.cos(k.angle);Q[T]=k.exponent;T=T+1}}}c=S*3;for(f=v.length;c<f;c++)v[c]=0;c=R*3;for(f=t.length;c<f;c++)t[c]=0;c=T*3;for(f=E.length;c<f;c++)E[c]=0;p.directional.length=S;p.point.length=R;p.spot.length=T;p.ambient[0]=l;p.ambient[1]=m;p.ambient[2]=n;ob=false}c=bc;j.ambientLightColor.value=c.ambient;j.directionalLightColor.value=c.directional.colors;j.directionalLightDirection.value=
 c.directional.positions;j.pointLightColor.value=c.point.colors;j.pointLightPosition.value=c.point.positions;j.pointLightDistance.value=c.point.distances;j.spotLightColor.value=c.spot.colors;j.spotLightPosition.value=c.spot.positions;j.spotLightDistance.value=c.spot.distances;j.spotLightDirection.value=c.spot.directions;j.spotLightAngle.value=c.spot.angles;j.spotLightExponent.value=c.spot.exponents}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial){j.opacity.value=
@@ -366,15 +366,15 @@ Fb.__webglColorBuffer);g.bufferData(g.ARRAY_BUFFER,Ec,Vc)}}Y.verticesNeedUpdate=
 fa=void 0;if(tb.verticesNeedUpdate){for(qc=0;qc<hd;qc++){Fc=Yc[qc];ma=qc*3;Hc[ma]=Fc.x;Hc[ma+1]=Fc.y;Hc[ma+2]=Fc.z}g.bindBuffer(g.ARRAY_BUFFER,tb.__webglVertexBuffer);g.bufferData(g.ARRAY_BUFFER,Hc,Sc)}if(jd){for(rc=0;rc<id;rc++){Gc=Zc[rc];ma=rc*3;Ic[ma]=Gc.r;Ic[ma+1]=Gc.g;Ic[ma+2]=Gc.b}g.bindBuffer(g.ARRAY_BUFFER,tb.__webglColorBuffer);g.bufferData(g.ARRAY_BUFFER,Ic,Sc)}if(Tc){Jc=0;for($c=Tc.length;Jc<$c;Jc++){fa=Tc[Jc];if(fa.needsUpdate&&(fa.boundTo===void 0||fa.boundTo==="vertices")){ma=0;Zb=fa.value.length;
 if(fa.size===1)for(ya=0;ya<Zb;ya++)fa.array[ya]=fa.value[ya];else if(fa.size===2)for(ya=0;ya<Zb;ya++){Ga=fa.value[ya];fa.array[ma]=Ga.x;fa.array[ma+1]=Ga.y;ma=ma+2}else if(fa.size===3)if(fa.type==="c")for(ya=0;ya<Zb;ya++){Ga=fa.value[ya];fa.array[ma]=Ga.r;fa.array[ma+1]=Ga.g;fa.array[ma+2]=Ga.b;ma=ma+3}else for(ya=0;ya<Zb;ya++){Ga=fa.value[ya];fa.array[ma]=Ga.x;fa.array[ma+1]=Ga.y;fa.array[ma+2]=Ga.z;ma=ma+3}else if(fa.size===4)for(ya=0;ya<Zb;ya++){Ga=fa.value[ya];fa.array[ma]=Ga.x;fa.array[ma+1]=
 Ga.y;fa.array[ma+2]=Ga.z;fa.array[ma+3]=Ga.w;ma=ma+4}g.bindBuffer(g.ARRAY_BUFFER,fa.buffer);g.bufferData(g.ARRAY_BUFFER,fa.array,Sc)}}}}Y.verticesNeedUpdate=false;Y.colorsNeedUpdate=false;Fa.attributes&&v(Fa)}else if(Va instanceof THREE.ParticleSystem){Fa=c(Va,gc);Tb=Fa.attributes&&m(Fa);(Y.verticesNeedUpdate||Y.colorsNeedUpdate||Va.sortParticles||Tb)&&f(Y,g.DYNAMIC_DRAW,Va);Y.verticesNeedUpdate=false;Y.colorsNeedUpdate=false;Fa.attributes&&v(Fa)}}};this.initMaterial=function(a,b,c,d){var e,f,h;a instanceof
-THREE.MeshDepthMaterial?h="depth":a instanceof THREE.MeshNormalMaterial?h="normal":a instanceof THREE.MeshBasicMaterial?h="basic":a instanceof THREE.MeshLambertMaterial?h="lambert":a instanceof THREE.MeshPhongMaterial?h="phong":a instanceof THREE.LineBasicMaterial?h="basic":a instanceof THREE.ParticleBasicMaterial&&(h="particle_basic");if(h){var i=THREE.ShaderLib[h];a.uniforms=THREE.UniformsUtils.clone(i.uniforms);a.vertexShader=i.vertexShader;a.fragmentShader=i.fragmentShader}var j,k,l,m,o;j=m=o=
-i=0;for(k=b.length;j<k;j++){l=b[j];if(!l.onlyShadow){l instanceof THREE.DirectionalLight&&m++;l instanceof THREE.PointLight&&o++;l instanceof THREE.SpotLight&&i++}}if(o+i+m<=Z){k=m;l=o;m=i}else{k=Math.ceil(Z*m/(o+m));m=l=Z-k}var n=0,i=0;for(o=b.length;i<o;i++){j=b[i];if(j.castShadow){j instanceof THREE.SpotLight&&n++;j instanceof THREE.DirectionalLight&&!j.shadowCascade&&n++}}var q=50;if(d!==void 0&&d instanceof THREE.SkinnedMesh)q=d.bones.length;var p;a:{j=a.fragmentShader;o=a.vertexShader;var i=
-a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,maxBones:q,morphTargets:a.morphTargets,morphNormals:a.morphNormals,maxMorphTargets:this.maxMorphTargets,maxMorphNormals:this.maxMorphNormals,maxDirLights:k,maxPointLights:l,maxSpotLights:m,maxShadows:n,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapDebug:this.shadowMapDebug,
-shadowMapCascade:this.shadowMapCascade,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround,doubleSided:d&&d.doubleSided},r,d=[];if(h)d.push(h);else{d.push(j);d.push(o)}for(r in c){d.push(r);d.push(c[r])}h=d.join();r=0;for(d=W.length;r<d;r++){k=W[r];if(k.code===h){k.usedTimes++;p=k.program;break a}}r=g.createProgram();d=["precision "+E+" float;",ec>0?"#define VERTEX_TEXTURES":"",F.gammaInput?"#define GAMMA_INPUT":"",F.gammaOutput?"#define GAMMA_OUTPUT":"",F.physicallyBasedShading?
+THREE.MeshDepthMaterial?h="depth":a instanceof THREE.MeshNormalMaterial?h="normal":a instanceof THREE.MeshBasicMaterial?h="basic":a instanceof THREE.MeshLambertMaterial?h="lambert":a instanceof THREE.MeshPhongMaterial?h="phong":a instanceof THREE.LineBasicMaterial?h="basic":a instanceof THREE.ParticleBasicMaterial&&(h="particle_basic");if(h){var i=THREE.ShaderLib[h];a.uniforms=THREE.UniformsUtils.clone(i.uniforms);a.vertexShader=i.vertexShader;a.fragmentShader=i.fragmentShader}var k,j,l,m,o;k=m=o=
+i=0;for(j=b.length;k<j;k++){l=b[k];if(!l.onlyShadow){l instanceof THREE.DirectionalLight&&m++;l instanceof THREE.PointLight&&o++;l instanceof THREE.SpotLight&&i++}}if(o+i+m<=Z){j=m;l=o;m=i}else{j=Math.ceil(Z*m/(o+m));m=l=Z-j}var n=0,i=0;for(o=b.length;i<o;i++){k=b[i];if(k.castShadow){k instanceof THREE.SpotLight&&n++;k instanceof THREE.DirectionalLight&&!k.shadowCascade&&n++}}var q=50;if(d!==void 0&&d instanceof THREE.SkinnedMesh)q=d.bones.length;var p;a:{k=a.fragmentShader;o=a.vertexShader;var i=
+a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,maxBones:q,morphTargets:a.morphTargets,morphNormals:a.morphNormals,maxMorphTargets:this.maxMorphTargets,maxMorphNormals:this.maxMorphNormals,maxDirLights:j,maxPointLights:l,maxSpotLights:m,maxShadows:n,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapDebug:this.shadowMapDebug,
+shadowMapCascade:this.shadowMapCascade,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround,doubleSided:d&&d.doubleSided},r,d=[];if(h)d.push(h);else{d.push(k);d.push(o)}for(r in c){d.push(r);d.push(c[r])}h=d.join();r=0;for(d=W.length;r<d;r++){j=W[r];if(j.code===h){j.usedTimes++;p=j.program;break a}}r=g.createProgram();d=["precision "+E+" float;",ec>0?"#define VERTEX_TEXTURES":"",F.gammaInput?"#define GAMMA_INPUT":"",F.gammaOutput?"#define GAMMA_OUTPUT":"",F.physicallyBasedShading?
 "#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?
 "#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
-k=["precision "+E+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",F.gammaInput?"#define GAMMA_INPUT":"",F.gammaOutput?"#define GAMMA_OUTPUT":"",F.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":
+j=["precision "+E+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",F.gammaInput?"#define GAMMA_INPUT":"",F.gammaOutput?"#define GAMMA_OUTPUT":"",F.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":
 "",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");
-j=D("fragment",k+j);d=D("vertex",d+o);g.attachShader(r,d);g.attachShader(r,j);g.linkProgram(r);g.getProgramParameter(r,g.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+g.getProgramParameter(r,g.VALIDATE_STATUS)+", gl error ["+g.getError()+"]");g.deleteShader(j);g.deleteShader(d);r.uniforms={};r.attributes={};var t,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","boneGlobalMatrices","morphTargetInfluences"];for(t in i)d.push(t);
+k=D("fragment",j+k);d=D("vertex",d+o);g.attachShader(r,d);g.attachShader(r,k);g.linkProgram(r);g.getProgramParameter(r,g.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+g.getProgramParameter(r,g.VALIDATE_STATUS)+", gl error ["+g.getError()+"]");g.deleteShader(k);g.deleteShader(d);r.uniforms={};r.attributes={};var t,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","boneGlobalMatrices","morphTargetInfluences"];for(t in i)d.push(t);
 t=d;d=0;for(i=t.length;d<i;d++){o=t[d];r.uniforms[o]=g.getUniformLocation(r,o)}d=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(t=0;t<c.maxMorphTargets;t++)d.push("morphTarget"+t);for(t=0;t<c.maxMorphNormals;t++)d.push("morphNormal"+t);for(p in b)d.push(p);p=d;t=0;for(b=p.length;t<b;t++){c=p[t];r.attributes[c]=g.getAttribLocation(r,c)}r.id=I++;W.push({program:r,code:h,usedTimes:1});F.info.memory.programs=W.length;p=r}a.program=p;p=a.program.attributes;
 p.position>=0&&g.enableVertexAttribArray(p.position);p.color>=0&&g.enableVertexAttribArray(p.color);p.normal>=0&&g.enableVertexAttribArray(p.normal);p.tangent>=0&&g.enableVertexAttribArray(p.tangent);if(a.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0){g.enableVertexAttribArray(p.skinVertexA);g.enableVertexAttribArray(p.skinVertexB);g.enableVertexAttribArray(p.skinIndex);g.enableVertexAttribArray(p.skinWeight)}if(a.attributes)for(f in a.attributes)p[f]!==void 0&&p[f]>=
 0&&g.enableVertexAttribArray(p[f]);if(a.morphTargets){a.numSupportedMorphTargets=0;b="morphTarget";for(f=0;f<this.maxMorphTargets;f++){t=b+f;if(p[t]>=0){g.enableVertexAttribArray(p[t]);a.numSupportedMorphTargets++}}}if(a.morphNormals){a.numSupportedMorphNormals=0;b="morphNormal";for(f=0;f<this.maxMorphNormals;f++){t=b+f;if(p[t]>=0){g.enableVertexAttribArray(p[t]);a.numSupportedMorphNormals++}}}a.uniformsList=[];for(e in a.uniforms)a.uniformsList.push([a.uniforms[e],e])};this.setFaceCulling=function(a,

+ 1 - 1
src/renderers/WebGLRenderer.js

@@ -5137,7 +5137,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			light = lights[ l ];
 
-			if ( light.onlyShadow ) continue;
+			if ( light.onlyShadow || ! light.visible ) continue;
 
 			color = light.color;
 			intensity = light.intensity;