Browse Source

Fixed Sprites to use "object.visible"

alteredq 14 years ago
parent
commit
d2a3122be1
4 changed files with 20 additions and 15 deletions
  1. 3 3
      build/Three.js
  2. 6 6
      build/custom/ThreeWebGL.js
  3. 4 4
      examples/webgl_sprites.html
  4. 7 2
      src/renderers/WebGLRenderer.js

+ 3 - 3
build/Three.js

@@ -256,9 +256,9 @@ t(o,h):t(n,h))}else(h=e)&&(h.transparent?t(o,h):t(n,h))}function z(b,e){return e
 ja[w]||(ja[w]=new THREE.Matrix4);u=V.shadowMap[w];x=ja[w];ha.position.copy(t.position);ha.target.position.copy(t.target.position);ha.update(void 0,!0);b.update(void 0,!1,ha);x.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);x.multiplySelf(ha.projectionMatrix);x.multiplySelf(ha.matrixWorldInverse);ha.matrixWorldInverse.flattenToArray(sa);ha.projectionMatrix.flattenToArray(ua);qa.multiply(ha.projectionMatrix,ha.matrixWorldInverse);p(qa);V.initWebGLObjects(b);X(u);o.clearColor(1,1,1,1);V.clear();o.clearColor(ia.r,
 ia.g,ia.b,W);x=b.__webglObjects.length;t=b.__webglObjectsImmediate.length;for(u=0;u<x;u++)L=b.__webglObjects[u],z=L.object,z.visible&&z.castShadow?!(z instanceof THREE.Mesh)||!z.frustumCulled||v(z)?(z.matrixWorld.flattenToArray(z._objectMatrixArray),E(z,ha,!1),L.render=!0):L.render=!1:L.render=!1;k(!0);K(THREE.NormalBlending);for(u=0;u<x;u++)if(L=b.__webglObjects[u],L.render)z=L.object,buffer=L.buffer,m(z),L=z.customDepthMaterial?z.customDepthMaterial:z.geometry.morphTargets.length?oa:ya,f(ha,y,null,
 L,buffer,z);for(u=0;u<t;u++)L=b.__webglObjectsImmediate[u],z=L.object,z.visible&&z.castShadow&&(z.matrixAutoUpdate&&z.matrixWorld.flattenToArray(z._objectMatrixArray),E(z,ha,!1),m(z),program=e(ha,y,null,ya,z),z.render(function(b){h(b,program,ya.shading)}));w++}}function A(b,e){var c,f,h;c=ca.attributes;var k=ca.uniforms,m=J/va,n,p=[],t=va*0.5,u=J*0.5,w=!0;o.useProgram(ca.program);S=ca.program;ma=ka=-1;Aa||(o.enableVertexAttribArray(ca.attributes.position),o.enableVertexAttribArray(ca.attributes.uv),
-Aa=!0);o.disable(o.CULL_FACE);o.enable(o.BLEND);o.depthMask(!0);o.bindBuffer(o.ARRAY_BUFFER,ca.vertexBuffer);o.vertexAttribPointer(c.position,2,o.FLOAT,!1,16,0);o.vertexAttribPointer(c.uv,2,o.FLOAT,!1,16,8);o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,ca.elementBuffer);o.uniformMatrix4fv(k.projectionMatrix,!1,ua);o.activeTexture(o.TEXTURE0);o.uniform1i(k.map,0);c=0;for(f=b.__webglSprites.length;c<f;c++)h=b.__webglSprites[c],h.useScreenCoordinates?h.z=-h.position.z:(h._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,
-h.matrixWorld,h._modelViewMatrixArray),h.z=-h._modelViewMatrix.n34);b.__webglSprites.sort(z);c=0;for(f=b.__webglSprites.length;c<f;c++)h=b.__webglSprites[c],h.map&&h.map.image&&h.map.image.width&&(h.useScreenCoordinates?(o.uniform1i(k.useScreenCoordinates,1),o.uniform3f(k.screenPosition,(h.position.x-t)/t,(u-h.position.y)/u,Math.max(0,Math.min(1,h.position.z)))):(o.uniform1i(k.useScreenCoordinates,0),o.uniform1i(k.affectedByDistance,h.affectedByDistance?1:0),o.uniformMatrix4fv(k.modelViewMatrix,!1,
-h._modelViewMatrixArray)),n=h.map.image.width/(h.scaleByViewport?J:1),p[0]=n*m*h.scale.x,p[1]=n*h.scale.y,o.uniform2f(k.uvScale,h.uvScale.x,h.uvScale.y),o.uniform2f(k.uvOffset,h.uvOffset.x,h.uvOffset.y),o.uniform2f(k.alignment,h.alignment.x,h.alignment.y),o.uniform1f(k.opacity,h.opacity),o.uniform3f(k.color,h.color.r,h.color.g,h.color.b),o.uniform1f(k.rotation,h.rotation),o.uniform2fv(k.scale,p),h.mergeWith3D&&!w?(o.enable(o.DEPTH_TEST),w=!0):!h.mergeWith3D&&w&&(o.disable(o.DEPTH_TEST),w=!1),K(h.blending),
+Aa=!0);o.disable(o.CULL_FACE);o.enable(o.BLEND);o.depthMask(!0);o.bindBuffer(o.ARRAY_BUFFER,ca.vertexBuffer);o.vertexAttribPointer(c.position,2,o.FLOAT,!1,16,0);o.vertexAttribPointer(c.uv,2,o.FLOAT,!1,16,8);o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,ca.elementBuffer);o.uniformMatrix4fv(k.projectionMatrix,!1,ua);o.activeTexture(o.TEXTURE0);o.uniform1i(k.map,0);c=0;for(f=b.__webglSprites.length;c<f;c++)if(h=b.__webglSprites[c],h.visible)h.useScreenCoordinates?h.z=-h.position.z:(h._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,
+h.matrixWorld,h._modelViewMatrixArray),h.z=-h._modelViewMatrix.n34);b.__webglSprites.sort(z);c=0;for(f=b.__webglSprites.length;c<f;c++)h=b.__webglSprites[c],h.visible&&h.map&&h.map.image&&h.map.image.width&&(h.useScreenCoordinates?(o.uniform1i(k.useScreenCoordinates,1),o.uniform3f(k.screenPosition,(h.position.x-t)/t,(u-h.position.y)/u,Math.max(0,Math.min(1,h.position.z)))):(o.uniform1i(k.useScreenCoordinates,0),o.uniform1i(k.affectedByDistance,h.affectedByDistance?1:0),o.uniformMatrix4fv(k.modelViewMatrix,
+!1,h._modelViewMatrixArray)),n=h.map.image.width/(h.scaleByViewport?J:1),p[0]=n*m*h.scale.x,p[1]=n*h.scale.y,o.uniform2f(k.uvScale,h.uvScale.x,h.uvScale.y),o.uniform2f(k.uvOffset,h.uvOffset.x,h.uvOffset.y),o.uniform2f(k.alignment,h.alignment.x,h.alignment.y),o.uniform1f(k.opacity,h.opacity),o.uniform3f(k.color,h.color.r,h.color.g,h.color.b),o.uniform1f(k.rotation,h.rotation),o.uniform2fv(k.scale,p),h.mergeWith3D&&!w?(o.enable(o.DEPTH_TEST),w=!0):!h.mergeWith3D&&w&&(o.disable(o.DEPTH_TEST),w=!1),K(h.blending),
 M(h.map,0),o.drawElements(o.TRIANGLES,6,o.UNSIGNED_SHORT,0));o.enable(o.CULL_FACE);o.enable(o.DEPTH_TEST);o.depthMask(ea)}function E(b,e,c){b._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);c&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function D(b){var e,c,f,h;h=b.__materials;b=0;for(c=h.length;b<c;b++)if(f=h[b],f.attributes)for(e in f.attributes)if(f.attributes[e].needsUpdate)return!0;return!1}function F(b){var e,
 c,f,h;h=b.__materials;b=0;for(c=h.length;b<c;b++)if(f=h[b],f.attributes)for(e in f.attributes)f.attributes[e].needsUpdate=!1}function G(b,e){var c;for(c=b.length-1;c>=0;c--)b[c].object==e&&b.splice(c,1)}function N(b){function e(b){var h=[];c=0;for(f=b.length;c<f;c++)b[c]==void 0?h.push("undefined"):h.push(b[c].id);return h.join("_")}var c,f,h,k,m,n,o,p,t={},w=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};h=0;for(k=b.faces.length;h<k;h++)m=b.faces[h],n=m.materials,o=e(n),t[o]==
 void 0&&(t[o]={hash:o,counter:0}),p=t[o].hash+"_"+t[o].counter,b.geometryGroups[p]==void 0&&(b.geometryGroups[p]={faces:[],materials:n,vertices:0,numMorphTargets:w}),m=m instanceof THREE.Face3?3:4,b.geometryGroups[p].vertices+m>65535&&(t[o].counter+=1,p=t[o].hash+"_"+t[o].counter,b.geometryGroups[p]==void 0&&(b.geometryGroups[p]={faces:[],materials:n,vertices:0,numMorphTargets:w})),b.geometryGroups[p].faces.push(h),b.geometryGroups[p].vertices+=m;b.geometryGroupsList=[];for(var u in b.geometryGroups)b.geometryGroupsList.push(b.geometryGroups[u])}

+ 6 - 6
build/custom/ThreeWebGL.js

@@ -213,12 +213,12 @@ c)&&(f.transparent?q(k,f):q(j,f))}function y(b,c){return c.z-b.z}function x(b){v
 (Sa[La]=new THREE.Matrix4);q=L.shadowMap[La];r=Sa[La];pa.position.copy(p.position);pa.target.position.copy(p.target.position);pa.update(void 0,!0);b.update(void 0,!1,pa);r.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);r.multiplySelf(pa.projectionMatrix);r.multiplySelf(pa.matrixWorldInverse);pa.matrixWorldInverse.flattenToArray(Ta);pa.projectionMatrix.flattenToArray(Ca);za.multiply(pa.projectionMatrix,pa.matrixWorldInverse);n(za);L.initWebGLObjects(b);O(q);e.clearColor(1,1,1,1);L.clear();e.clearColor(ea.r,
 ea.g,ea.b,Ga);r=b.__webglObjects.length;p=b.__webglObjectsImmediate.length;for(q=0;q<r;q++)m=b.__webglObjects[q],B=m.object,B.visible&&B.castShadow?!(B instanceof THREE.Mesh)||!B.frustumCulled||t(B)?(B.matrixWorld.flattenToArray(B._objectMatrixArray),F(B,pa,!1),m.render=!0):m.render=!1:m.render=!1;j(!0);E(THREE.NormalBlending);for(q=0;q<r;q++)if(m=b.__webglObjects[q],m.render)B=m.object,buffer=m.buffer,h(B),m=B.customDepthMaterial?B.customDepthMaterial:B.geometry.morphTargets.length?Ya:Ua,f(pa,u,
 null,m,buffer,B);for(q=0;q<p;q++)m=b.__webglObjectsImmediate[q],B=m.object,B.visible&&B.castShadow&&(B.matrixAutoUpdate&&B.matrixWorld.flattenToArray(B._objectMatrixArray),F(B,pa,!1),h(B),program=d(pa,u,null,Ua,B),B.render(function(b){i(b,program,Ua.shading)}));La++}}function D(b,c){var d,f,h;d=m.attributes;var i=m.uniforms,j=Da/ya,k,n=[],p=ya*0.5,q=Da*0.5,r=!0;e.useProgram(m.program);Va=m.program;V=H=-1;Za||(e.enableVertexAttribArray(m.attributes.position),e.enableVertexAttribArray(m.attributes.uv),
-Za=!0);e.disable(e.CULL_FACE);e.enable(e.BLEND);e.depthMask(!0);e.bindBuffer(e.ARRAY_BUFFER,m.vertexBuffer);e.vertexAttribPointer(d.position,2,e.FLOAT,!1,16,0);e.vertexAttribPointer(d.uv,2,e.FLOAT,!1,16,8);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,m.elementBuffer);e.uniformMatrix4fv(i.projectionMatrix,!1,Ca);e.activeTexture(e.TEXTURE0);e.uniform1i(i.map,0);d=0;for(f=b.__webglSprites.length;d<f;d++)h=b.__webglSprites[d],h.useScreenCoordinates?h.z=-h.position.z:(h._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,
-h.matrixWorld,h._modelViewMatrixArray),h.z=-h._modelViewMatrix.n34);b.__webglSprites.sort(y);d=0;for(f=b.__webglSprites.length;d<f;d++)h=b.__webglSprites[d],h.map&&h.map.image&&h.map.image.width&&(h.useScreenCoordinates?(e.uniform1i(i.useScreenCoordinates,1),e.uniform3f(i.screenPosition,(h.position.x-p)/p,(q-h.position.y)/q,Math.max(0,Math.min(1,h.position.z)))):(e.uniform1i(i.useScreenCoordinates,0),e.uniform1i(i.affectedByDistance,h.affectedByDistance?1:0),e.uniformMatrix4fv(i.modelViewMatrix,!1,
-h._modelViewMatrixArray)),k=h.map.image.width/(h.scaleByViewport?Da:1),n[0]=k*j*h.scale.x,n[1]=k*h.scale.y,e.uniform2f(i.uvScale,h.uvScale.x,h.uvScale.y),e.uniform2f(i.uvOffset,h.uvOffset.x,h.uvOffset.y),e.uniform2f(i.alignment,h.alignment.x,h.alignment.y),e.uniform1f(i.opacity,h.opacity),e.uniform3f(i.color,h.color.r,h.color.g,h.color.b),e.uniform1f(i.rotation,h.rotation),e.uniform2fv(i.scale,n),h.mergeWith3D&&!r?(e.enable(e.DEPTH_TEST),r=!0):!h.mergeWith3D&&r&&(e.disable(e.DEPTH_TEST),r=!1),E(h.blending),
-ha(h.map,0),e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0));e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(R)}function F(b,c,d){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);d&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function wa(b){var c,d,e,f;f=b.__materials;b=0;for(d=f.length;b<d;b++)if(e=f[b],e.attributes)for(c in e.attributes)if(e.attributes[c].needsUpdate)return!0;return!1}function xa(b){var c,
-d,e,f;f=b.__materials;b=0;for(d=f.length;b<d;b++)if(e=f[b],e.attributes)for(c in e.attributes)e.attributes[c].needsUpdate=!1}function oa(b,c){var d;for(d=b.length-1;d>=0;d--)b[d].object==c&&b.splice(d,1)}function qa(b){function c(b){var f=[];d=0;for(e=b.length;d<e;d++)b[d]==void 0?f.push("undefined"):f.push(b[d].id);return f.join("_")}var d,e,f,h,i,j,k,n,p={},q=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};f=0;for(h=b.faces.length;f<h;f++)i=b.faces[f],j=i.materials,k=c(j),p[k]==
-void 0&&(p[k]={hash:k,counter:0}),n=p[k].hash+"_"+p[k].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[],materials:j,vertices:0,numMorphTargets:q}),i=i instanceof THREE.Face3?3:4,b.geometryGroups[n].vertices+i>65535&&(p[k].counter+=1,n=p[k].hash+"_"+p[k].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[],materials:j,vertices:0,numMorphTargets:q})),b.geometryGroups[n].faces.push(f),b.geometryGroups[n].vertices+=i;b.geometryGroupsList=[];for(var r in b.geometryGroups)b.geometryGroupsList.push(b.geometryGroups[r])}
+Za=!0);e.disable(e.CULL_FACE);e.enable(e.BLEND);e.depthMask(!0);e.bindBuffer(e.ARRAY_BUFFER,m.vertexBuffer);e.vertexAttribPointer(d.position,2,e.FLOAT,!1,16,0);e.vertexAttribPointer(d.uv,2,e.FLOAT,!1,16,8);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,m.elementBuffer);e.uniformMatrix4fv(i.projectionMatrix,!1,Ca);e.activeTexture(e.TEXTURE0);e.uniform1i(i.map,0);d=0;for(f=b.__webglSprites.length;d<f;d++)if(h=b.__webglSprites[d],h.visible)h.useScreenCoordinates?h.z=-h.position.z:(h._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,
+h.matrixWorld,h._modelViewMatrixArray),h.z=-h._modelViewMatrix.n34);b.__webglSprites.sort(y);d=0;for(f=b.__webglSprites.length;d<f;d++)h=b.__webglSprites[d],h.visible&&h.map&&h.map.image&&h.map.image.width&&(h.useScreenCoordinates?(e.uniform1i(i.useScreenCoordinates,1),e.uniform3f(i.screenPosition,(h.position.x-p)/p,(q-h.position.y)/q,Math.max(0,Math.min(1,h.position.z)))):(e.uniform1i(i.useScreenCoordinates,0),e.uniform1i(i.affectedByDistance,h.affectedByDistance?1:0),e.uniformMatrix4fv(i.modelViewMatrix,
+!1,h._modelViewMatrixArray)),k=h.map.image.width/(h.scaleByViewport?Da:1),n[0]=k*j*h.scale.x,n[1]=k*h.scale.y,e.uniform2f(i.uvScale,h.uvScale.x,h.uvScale.y),e.uniform2f(i.uvOffset,h.uvOffset.x,h.uvOffset.y),e.uniform2f(i.alignment,h.alignment.x,h.alignment.y),e.uniform1f(i.opacity,h.opacity),e.uniform3f(i.color,h.color.r,h.color.g,h.color.b),e.uniform1f(i.rotation,h.rotation),e.uniform2fv(i.scale,n),h.mergeWith3D&&!r?(e.enable(e.DEPTH_TEST),r=!0):!h.mergeWith3D&&r&&(e.disable(e.DEPTH_TEST),r=!1),
+E(h.blending),ha(h.map,0),e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0));e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(R)}function F(b,c,d){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);d&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function wa(b){var c,d,e,f;f=b.__materials;b=0;for(d=f.length;b<d;b++)if(e=f[b],e.attributes)for(c in e.attributes)if(e.attributes[c].needsUpdate)return!0;return!1}
+function xa(b){var c,d,e,f;f=b.__materials;b=0;for(d=f.length;b<d;b++)if(e=f[b],e.attributes)for(c in e.attributes)e.attributes[c].needsUpdate=!1}function oa(b,c){var d;for(d=b.length-1;d>=0;d--)b[d].object==c&&b.splice(d,1)}function qa(b){function c(b){var f=[];d=0;for(e=b.length;d<e;d++)b[d]==void 0?f.push("undefined"):f.push(b[d].id);return f.join("_")}var d,e,f,h,i,j,k,n,p={},q=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};f=0;for(h=b.faces.length;f<h;f++)i=b.faces[f],j=
+i.materials,k=c(j),p[k]==void 0&&(p[k]={hash:k,counter:0}),n=p[k].hash+"_"+p[k].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[],materials:j,vertices:0,numMorphTargets:q}),i=i instanceof THREE.Face3?3:4,b.geometryGroups[n].vertices+i>65535&&(p[k].counter+=1,n=p[k].hash+"_"+p[k].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[],materials:j,vertices:0,numMorphTargets:q})),b.geometryGroups[n].faces.push(f),b.geometryGroups[n].vertices+=i;b.geometryGroupsList=[];for(var r in b.geometryGroups)b.geometryGroupsList.push(b.geometryGroups[r])}
 function ga(b,c,d){b.push({buffer:c,object:d,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function E(b){if(b!=H){switch(b){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.SRC_ALPHA,
 e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}H=b}}function v(b,c,d){(d.width&d.width-1)==0&&(d.height&d.height-1)==0?(e.texParameteri(b,e.TEXTURE_WRAP_S,P(c.wrapS)),e.texParameteri(b,e.TEXTURE_WRAP_T,P(c.wrapT)),e.texParameteri(b,e.TEXTURE_MAG_FILTER,P(c.magFilter)),e.texParameteri(b,e.TEXTURE_MIN_FILTER,P(c.minFilter)),e.generateMipmap(b)):(e.texParameteri(b,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(b,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(b,e.TEXTURE_MAG_FILTER,ta(c.magFilter)),
 e.texParameteri(b,e.TEXTURE_MIN_FILTER,ta(c.minFilter)))}function ha(b,c){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=e.createTexture(),L.info.memory.textures++;e.activeTexture(e.TEXTURE0+c);e.bindTexture(e.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture?e.texImage2D(e.TEXTURE_2D,0,P(b.format),b.image.width,b.image.height,0,P(b.format),e.UNSIGNED_BYTE,b.image.data):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,b.image);v(e.TEXTURE_2D,b,b.image);b.needsUpdate=

+ 4 - 4
examples/webgl_sprites.html

@@ -43,7 +43,7 @@
 				container = document.createElement( 'div' );
 				document.body.appendChild( container );
 
-				camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 10000 );
+				camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 5000 );
 				camera.position.z = 1500;
 
 				scene = new THREE.Scene();
@@ -89,17 +89,17 @@
 
 				// add 2d-sprites
 
-				sprite = new THREE.Sprite( { map: mapA, alignment:THREE.SpriteAlignment.topLeft } );
+				sprite = new THREE.Sprite( { map: mapA, alignment: THREE.SpriteAlignment.topLeft } );
 				sprite.position.set( 100, 100, 0 );
 				sprite.opacity = 0.25;
 				scene.add( sprite );
 
-				sprite = new THREE.Sprite( { map: mapA, alignment:THREE.SpriteAlignment.topLeft } );
+				sprite = new THREE.Sprite( { map: mapA, alignment: THREE.SpriteAlignment.topLeft } );
 				sprite.position.set( 150, 150, 2 );
 				sprite.opacity = 0.5;
 				scene.add( sprite );
 
-				sprite = new THREE.Sprite( { map: mapA, alignment:THREE.SpriteAlignment.topLeft } );
+				sprite = new THREE.Sprite( { map: mapA, alignment: THREE.SpriteAlignment.topLeft } );
 				sprite.position.set( 200, 200, 3 );
 				sprite.opacity = 1;
 				scene.add( sprite );

+ 7 - 2
src/renderers/WebGLRenderer.js

@@ -3973,6 +3973,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			object = scene.__webglSprites[ o ];
 
+			if ( !object.visible ) continue;
+
 			if( !object.useScreenCoordinates ) {
 
 				object._modelViewMatrix.multiplyToArray( camera.matrixWorldInverse, object.matrixWorld, object._modelViewMatrixArray );
@@ -3988,13 +3990,13 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		scene.__webglSprites.sort( painterSort );
 
-		// render all non-custom shader sprites
+		// render all sprites
 
 		for ( o = 0, ol = scene.__webglSprites.length; o < ol; o ++ ) {
 
 			object = scene.__webglSprites[ o ];
 
-			if ( object.map && object.map.image && object.map.image.width ) {
+			if ( object.visible && object.map && object.map.image && object.map.image.width ) {
 
 				if ( object.useScreenCoordinates ) {
 
@@ -4012,14 +4014,17 @@ THREE.WebGLRenderer = function ( parameters ) {
 				}
 
 				size = object.map.image.width / ( object.scaleByViewport ? _viewportHeight : 1 );
+
 				scale[ 0 ] = size * invAspect * object.scale.x;
 				scale[ 1 ] = size * object.scale.y;
 
 				_gl.uniform2f( uniforms.uvScale, object.uvScale.x, object.uvScale.y );
 				_gl.uniform2f( uniforms.uvOffset, object.uvOffset.x, object.uvOffset.y );
 				_gl.uniform2f( uniforms.alignment, object.alignment.x, object.alignment.y );
+
 				_gl.uniform1f( uniforms.opacity, object.opacity );
 				_gl.uniform3f( uniforms.color, object.color.r, object.color.g, object.color.b );
+
 				_gl.uniform1f( uniforms.rotation, object.rotation );
 				_gl.uniform2fv( uniforms.scale, scale );