Browse files

Refactored ImmediateRenderObject flags (thanks to @mrdoob).

As per suggestion in alteredq@5d5f92d
  • Loading branch information...
1 parent aac7221 commit 763fcf796e6ccd2d175aebf390f8935cc078bd1a @alteredq alteredq committed May 1, 2012
Showing with 26 additions and 26 deletions.
  1. +4 −4 build/Three.js
  2. +1 −1 build/custom/ThreeExtras.js
  3. +3 −3 build/custom/ThreeWebGL.js
  4. +12 −12 examples/js/MarchingCubes.js
  5. +6 −6 src/renderers/WebGLRenderer.js
View
8 build/Three.js
@@ -326,9 +326,9 @@ THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGrou
j.deleteBuffer(c.__webglLineBuffer);var d=void 0,e=void 0;if(c.numMorphTargets){d=0;for(e=c.numMorphTargets;d<e;d++)j.deleteBuffer(c.__webglMorphTargetsBuffers[d])}if(c.numMorphNormals){d=0;for(e=c.numMorphNormals;d<e;d++)j.deleteBuffer(c.__webglMorphNormalsBuffers[d])}if(c.__webglCustomAttributesList){d=void 0;for(d in c.__webglCustomAttributesList)j.deleteBuffer(c.__webglCustomAttributesList[d].buffer)}C.info.memory.geometries--}else if(a instanceof THREE.Ribbon){a=a.geometry;j.deleteBuffer(a.__webglVertexBuffer);
j.deleteBuffer(a.__webglColorBuffer);C.info.memory.geometries--}else if(a instanceof THREE.Line){a=a.geometry;j.deleteBuffer(a.__webglVertexBuffer);j.deleteBuffer(a.__webglColorBuffer);C.info.memory.geometries--}else if(a instanceof THREE.ParticleSystem){a=a.geometry;j.deleteBuffer(a.__webglVertexBuffer);j.deleteBuffer(a.__webglColorBuffer);C.info.memory.geometries--}}};this.deallocateTexture=function(a){if(a.__webglInit){a.__webglInit=false;j.deleteTexture(a.__webglTexture);C.info.memory.textures--}};
this.deallocateRenderTarget=function(a){if(a&&a.__webglTexture){j.deleteTexture(a.__webglTexture);if(a instanceof THREE.WebGLRenderTargetCube)for(var b=0;b<6;b++){j.deleteFramebuffer(a.__webglFramebuffer[b]);j.deleteRenderbuffer(a.__webglRenderbuffer[b])}else{j.deleteFramebuffer(a.__webglFramebuffer);j.deleteRenderbuffer(a.__webglRenderbuffer)}}};this.deallocateMaterial=function(a){var b=a.program;if(b){a.program=void 0;var c,d,e=false,a=0;for(c=P.length;a<c;a++){d=P[a];if(d.program===b){d.usedTimes--;
-d.usedTimes===0&&(e=true);break}}if(e){e=[];a=0;for(c=P.length;a<c;a++){d=P[a];d.program!==b&&e.push(d)}P=e;j.deleteProgram(b);C.info.memory.programs--}}};this.updateShadowMap=function(a,b){T=null;M=ca=oa=Oa=Z=-1;la=true;$=S=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=function(a,b,c){if(a.hasPos&&!a.__webglVertexBuffer)a.__webglVertexBuffer=j.createBuffer();if(a.hasNormal&&!a.__webglNormalBuffer)a.__webglNormalBuffer=j.createBuffer();if(a.hasUv&&!a.__webglUvBuffer)a.__webglUvBuffer=
-j.createBuffer();if(a.hasPos){j.bindBuffer(j.ARRAY_BUFFER,a.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,a.positionArray,j.DYNAMIC_DRAW);j.enableVertexAttribArray(b.attributes.position);j.vertexAttribPointer(b.attributes.position,3,j.FLOAT,false,0,0)}if(a.hasNormal){j.bindBuffer(j.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,e,f,g,h,i,k,l,m,n,o=a.count*3;for(n=0;n<o;n=n+9){c=a.normalArray;d=c[n];e=c[n+1];f=c[n+2];g=c[n+3];i=c[n+4];l=c[n+5];h=c[n+6];k=c[n+7];m=c[n+8];d=(d+
-g+h)/3;e=(e+i+k)/3;f=(f+l+m)/3;c[n]=d;c[n+1]=e;c[n+2]=f;c[n+3]=d;c[n+4]=e;c[n+5]=f;c[n+6]=d;c[n+7]=e;c[n+8]=f}}j.bufferData(j.ARRAY_BUFFER,a.normalArray,j.DYNAMIC_DRAW);j.enableVertexAttribArray(b.attributes.normal);j.vertexAttribPointer(b.attributes.normal,3,j.FLOAT,false,0,0)}if(a.hasUv){j.bindBuffer(j.ARRAY_BUFFER,a.__webglUvBuffer);j.bufferData(j.ARRAY_BUFFER,a.uvArray,j.DYNAMIC_DRAW);j.enableVertexAttribArray(b.attributes.uv);j.vertexAttribPointer(b.attributes.uv,2,j.FLOAT,false,0,0)}j.drawArrays(j.TRIANGLES,
+d.usedTimes===0&&(e=true);break}}if(e){e=[];a=0;for(c=P.length;a<c;a++){d=P[a];d.program!==b&&e.push(d)}P=e;j.deleteProgram(b);C.info.memory.programs--}}};this.updateShadowMap=function(a,b){T=null;M=ca=oa=Oa=Z=-1;la=true;$=S=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=function(a,b,c){if(a.hasPositions&&!a.__webglVertexBuffer)a.__webglVertexBuffer=j.createBuffer();if(a.hasNormals&&!a.__webglNormalBuffer)a.__webglNormalBuffer=j.createBuffer();if(a.hasUvs&&!a.__webglUvBuffer)a.__webglUvBuffer=
+j.createBuffer();if(a.hasPositions){j.bindBuffer(j.ARRAY_BUFFER,a.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,a.positionArray,j.DYNAMIC_DRAW);j.enableVertexAttribArray(b.attributes.position);j.vertexAttribPointer(b.attributes.position,3,j.FLOAT,false,0,0)}if(a.hasNormals){j.bindBuffer(j.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,e,f,g,h,i,k,l,m,n,o=a.count*3;for(n=0;n<o;n=n+9){c=a.normalArray;d=c[n];e=c[n+1];f=c[n+2];g=c[n+3];i=c[n+4];l=c[n+5];h=c[n+6];k=c[n+7];m=c[n+
+8];d=(d+g+h)/3;e=(e+i+k)/3;f=(f+l+m)/3;c[n]=d;c[n+1]=e;c[n+2]=f;c[n+3]=d;c[n+4]=e;c[n+5]=f;c[n+6]=d;c[n+7]=e;c[n+8]=f}}j.bufferData(j.ARRAY_BUFFER,a.normalArray,j.DYNAMIC_DRAW);j.enableVertexAttribArray(b.attributes.normal);j.vertexAttribPointer(b.attributes.normal,3,j.FLOAT,false,0,0)}if(a.hasUvs){j.bindBuffer(j.ARRAY_BUFFER,a.__webglUvBuffer);j.bufferData(j.ARRAY_BUFFER,a.uvArray,j.DYNAMIC_DRAW);j.enableVertexAttribArray(b.attributes.uv);j.vertexAttribPointer(b.attributes.uv,2,j.FLOAT,false,0,0)}j.drawArrays(j.TRIANGLES,
0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,e,f){if(d.visible!==false){c=r(a,b,c,d,f);a=c.attributes;b=false;d=e.id*16777215+c.id*2+(d.wireframe?1:0);if(d!==ca){ca=d;b=true}if(f instanceof THREE.Mesh){f=e.offsets;d=0;for(c=f.length;d<c;++d){if(b){j.bindBuffer(j.ARRAY_BUFFER,e.vertexPositionBuffer);j.vertexAttribPointer(a.position,e.vertexPositionBuffer.itemSize,j.FLOAT,false,0,f[d].index*12);if(a.normal>=0&&e.vertexNormalBuffer){j.bindBuffer(j.ARRAY_BUFFER,e.vertexNormalBuffer);
j.vertexAttribPointer(a.normal,e.vertexNormalBuffer.itemSize,j.FLOAT,false,0,f[d].index*12)}if(a.uv>=0&&e.vertexUvBuffer)if(e.vertexUvBuffer){j.bindBuffer(j.ARRAY_BUFFER,e.vertexUvBuffer);j.vertexAttribPointer(a.uv,e.vertexUvBuffer.itemSize,j.FLOAT,false,0,f[d].index*8);j.enableVertexAttribArray(a.uv)}else j.disableVertexAttribArray(a.uv);if(a.color>=0&&e.vertexColorBuffer){j.bindBuffer(j.ARRAY_BUFFER,e.vertexColorBuffer);j.vertexAttribPointer(a.color,e.vertexColorBuffer.itemSize,j.FLOAT,false,0,
f[d].index*16)}j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.vertexIndexBuffer)}j.drawElements(j.TRIANGLES,f[d].count,j.UNSIGNED_SHORT,f[d].start*2);C.info.render.calls++;C.info.render.vertices=C.info.render.vertices+f[d].count;C.info.render.faces=C.info.render.faces+f[d].count/3}}}};this.renderBuffer=function(a,b,c,d,e,f){if(d.visible!==false){var g,i,c=r(a,b,c,d,f),b=c.attributes,a=false,c=e.id*16777215+c.id*2+(d.wireframe?1:0);if(c!==ca){ca=c;a=true}if(!d.morphTargets&&b.position>=0){if(a){j.bindBuffer(j.ARRAY_BUFFER,
@@ -446,7 +446,7 @@ x;a.faceVertexUvs=H}};THREE.GeometryUtils.random=THREE.Math.random16;THREE.Geome
THREE.ImageUtils={crossOrigin:"anonymous",loadTexture:function(a,b,c){var d=new Image,e=new THREE.Texture(d,b);d.onload=function(){e.needsUpdate=true;c&&c(this)};d.crossOrigin=this.crossOrigin;d.src=a;return e},loadTextureCube:function(a,b,c){var d,e=[],f=new THREE.Texture(e,b),b=e.loadCount=0;for(d=a.length;b<d;++b){e[b]=new Image;e[b].onload=function(){e.loadCount=e.loadCount+1;if(e.loadCount===6)f.needsUpdate=true;c&&c(this)};e[b].crossOrigin=this.crossOrigin;e[b].src=a[b]}return f},getNormalMap:function(a,
b){var c=function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},b=b|1,d=a.width,e=a.height,f=document.createElement("canvas");f.width=d;f.height=e;var g=f.getContext("2d");g.drawImage(a,0,0);for(var h=g.getImageData(0,0,d,e).data,i=g.createImageData(d,e),k=i.data,l=0;l<d;l++)for(var o=0;o<e;o++){var m=o-1<0?0:o-1,p=o+1>e-1?e-1:o+1,q=l-1<0?0:l-1,n=l+1>d-1?d-1:l+1,r=[],u=[0,0,h[(o*d+l)*4]/255*b];r.push([-1,0,h[(o*d+q)*4]/255*b]);r.push([-1,-1,h[(m*d+q)*4]/255*b]);r.push([0,
-1,h[(m*d+l)*4]/255*b]);r.push([1,-1,h[(m*d+n)*4]/255*b]);r.push([1,0,h[(o*d+n)*4]/255*b]);r.push([1,1,h[(p*d+n)*4]/255*b]);r.push([0,1,h[(p*d+l)*4]/255*b]);r.push([-1,1,h[(p*d+q)*4]/255*b]);m=[];q=r.length;for(p=0;p<q;p++){var n=r[p],t=r[(p+1)%q],n=[n[0]-u[0],n[1]-u[1],n[2]-u[2]],t=[t[0]-u[0],t[1]-u[1],t[2]-u[2]];m.push(c([n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]))}r=[0,0,0];for(p=0;p<m.length;p++){r[0]=r[0]+m[p][0];r[1]=r[1]+m[p][1];r[2]=r[2]+m[p][2]}r[0]=r[0]/m.length;r[1]=
-r[1]/m.length;r[2]=r[2]/m.length;u=(o*d+l)*4;k[u]=(r[0]+1)/2*255|0;k[u+1]=(r[1]+0.5)*255|0;k[u+2]=r[2]*255|0;k[u+3]=255}g.putImageData(i,0,0);return f},generateDataTexture:function(a,b,c){for(var d=a*b,e=new Uint8Array(3*d),f=Math.floor(c.r*255),g=Math.floor(c.g*255),c=Math.floor(c.b*255),h=0;h<d;h++){e[h*3]=f;e[h*3+1]=g;e[h*3+2]=c}a=new THREE.DataTexture(e,a,b,THREE.RGBFormat);a.needsUpdate=true;return a}};
+r[1]/m.length;r[2]=r[2]/m.length;u=(o*d+l)*4;k[u]=(r[0]+1)/2*255|0;k[u+1]=(r[1]+1)/2*255|0;k[u+2]=r[2]*255|0;k[u+3]=255}g.putImageData(i,0,0);return f},generateDataTexture:function(a,b,c){for(var d=a*b,e=new Uint8Array(3*d),f=Math.floor(c.r*255),g=Math.floor(c.g*255),c=Math.floor(c.b*255),h=0;h<d;h++){e[h*3]=f;e[h*3+1]=g;e[h*3+2]=c}a=new THREE.DataTexture(e,a,b,THREE.RGBFormat);a.needsUpdate=true;return a}};
THREE.SceneUtils={showHierarchy:function(a,b){THREE.SceneUtils.traverseHierarchy(a,function(a){a.visible=b})},traverseHierarchy:function(a,b){var c,d,e=a.children.length;for(d=0;d<e;d++){c=a.children[d];b(c);THREE.SceneUtils.traverseHierarchy(c,b)}},createMultiMaterialObject:function(a,b){var c,d=b.length,e=new THREE.Object3D;for(c=0;c<d;c++){var f=new THREE.Mesh(a,b[c]);e.add(f)}return e},cloneObject:function(a){var b;if(a instanceof THREE.MorphAnimMesh){b=new THREE.MorphAnimMesh(a.geometry,a.material);
b.duration=a.duration;b.mirroredLoop=a.mirroredLoop;b.time=a.time;b.lastKeyframe=a.lastKeyframe;b.currentKeyframe=a.currentKeyframe;b.direction=a.direction;b.directionBackwards=a.directionBackwards}else if(a instanceof THREE.SkinnedMesh)b=new THREE.SkinnedMesh(a.geometry,a.material);else if(a instanceof THREE.Mesh)b=new THREE.Mesh(a.geometry,a.material);else if(a instanceof THREE.Line)b=new THREE.Line(a.geometry,a.material,a.type);else if(a instanceof THREE.Ribbon)b=new THREE.Ribbon(a.geometry,a.material);
else if(a instanceof THREE.ParticleSystem){b=new THREE.ParticleSystem(a.geometry,a.material);b.sortParticles=a.sortParticles}else if(a instanceof THREE.Particle)b=new THREE.Particle(a.material);else if(a instanceof THREE.Sprite){b=new THREE.Sprite({});b.color.copy(a.color);b.map=a.map;b.blending=a.blending;b.useScreenCoordinates=a.useScreenCoordinates;b.mergeWith3D=a.mergeWith3D;b.affectedByDistance=a.affectedByDistance;b.scaleByViewport=a.scaleByViewport;b.alignment=a.alignment;b.rotation3d.copy(a.rotation3d);
View
2 build/custom/ThreeExtras.js
@@ -24,7 +24,7 @@ o.vertexNormals[0].copy(g),o.vertexNormals[1].copy(f)),4===e.vertexColors.length
THREE.ImageUtils={crossOrigin:"anonymous",loadTexture:function(b,a,c){var d=new Image,e=new THREE.Texture(d,a);d.onload=function(){e.needsUpdate=!0;c&&c(this)};d.crossOrigin=this.crossOrigin;d.src=b;return e},loadTextureCube:function(b,a,c){var d,e=[],f=new THREE.Texture(e,a),a=e.loadCount=0;for(d=b.length;a<d;++a)e[a]=new Image,e[a].onload=function(){e.loadCount+=1;6===e.loadCount&&(f.needsUpdate=!0);c&&c(this)},e[a].crossOrigin=this.crossOrigin,e[a].src=b[a];return f},getNormalMap:function(b,a){var c=
function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},a=a|1,d=b.width,e=b.height,f=document.createElement("canvas");f.width=d;f.height=e;var g=f.getContext("2d");g.drawImage(b,0,0);for(var h=g.getImageData(0,0,d,e).data,i=g.createImageData(d,e),j=i.data,l=0;l<d;l++)for(var n=0;n<e;n++){var k=0>n-1?0:n-1,m=n+1>e-1?e-1:n+1,p=0>l-1?0:l-1,q=l+1>d-1?d-1:l+1,r=[],t=[0,0,h[4*(n*d+l)]/255*a];r.push([-1,0,h[4*(n*d+p)]/255*a]);r.push([-1,-1,h[4*(k*d+p)]/255*a]);r.push([0,
-1,h[4*(k*d+l)]/255*a]);r.push([1,-1,h[4*(k*d+q)]/255*a]);r.push([1,0,h[4*(n*d+q)]/255*a]);r.push([1,1,h[4*(m*d+q)]/255*a]);r.push([0,1,h[4*(m*d+l)]/255*a]);r.push([-1,1,h[4*(m*d+p)]/255*a]);k=[];p=r.length;for(m=0;m<p;m++){var q=r[m],s=r[(m+1)%p],q=[q[0]-t[0],q[1]-t[1],q[2]-t[2]],s=[s[0]-t[0],s[1]-t[1],s[2]-t[2]];k.push(c([q[1]*s[2]-q[2]*s[1],q[2]*s[0]-q[0]*s[2],q[0]*s[1]-q[1]*s[0]]))}r=[0,0,0];for(m=0;m<k.length;m++)r[0]+=k[m][0],r[1]+=k[m][1],r[2]+=k[m][2];r[0]/=k.length;r[1]/=k.length;r[2]/=k.length;
-t=4*(n*d+l);j[t]=255*((r[0]+1)/2)|0;j[t+1]=255*(r[1]+0.5)|0;j[t+2]=255*r[2]|0;j[t+3]=255}g.putImageData(i,0,0);return f},generateDataTexture:function(b,a,c){for(var d=b*a,e=new Uint8Array(3*d),f=Math.floor(255*c.r),g=Math.floor(255*c.g),c=Math.floor(255*c.b),h=0;h<d;h++)e[3*h]=f,e[3*h+1]=g,e[3*h+2]=c;b=new THREE.DataTexture(e,b,a,THREE.RGBFormat);b.needsUpdate=!0;return b}};
+t=4*(n*d+l);j[t]=255*((r[0]+1)/2)|0;j[t+1]=255*((r[1]+1)/2)|0;j[t+2]=255*r[2]|0;j[t+3]=255}g.putImageData(i,0,0);return f},generateDataTexture:function(b,a,c){for(var d=b*a,e=new Uint8Array(3*d),f=Math.floor(255*c.r),g=Math.floor(255*c.g),c=Math.floor(255*c.b),h=0;h<d;h++)e[3*h]=f,e[3*h+1]=g,e[3*h+2]=c;b=new THREE.DataTexture(e,b,a,THREE.RGBFormat);b.needsUpdate=!0;return b}};
THREE.SceneUtils={showHierarchy:function(b,a){THREE.SceneUtils.traverseHierarchy(b,function(b){b.visible=a})},traverseHierarchy:function(b,a){var c,d,e=b.children.length;for(d=0;d<e;d++)c=b.children[d],a(c),THREE.SceneUtils.traverseHierarchy(c,a)},createMultiMaterialObject:function(b,a){var c,d=a.length,e=new THREE.Object3D;for(c=0;c<d;c++){var f=new THREE.Mesh(b,a[c]);e.add(f)}return e},cloneObject:function(b){var a;b instanceof THREE.MorphAnimMesh?(a=new THREE.MorphAnimMesh(b.geometry,b.material),
a.duration=b.duration,a.mirroredLoop=b.mirroredLoop,a.time=b.time,a.lastKeyframe=b.lastKeyframe,a.currentKeyframe=b.currentKeyframe,a.direction=b.direction,a.directionBackwards=b.directionBackwards):b instanceof THREE.SkinnedMesh?a=new THREE.SkinnedMesh(b.geometry,b.material):b instanceof THREE.Mesh?a=new THREE.Mesh(b.geometry,b.material):b instanceof THREE.Line?a=new THREE.Line(b.geometry,b.material,b.type):b instanceof THREE.Ribbon?a=new THREE.Ribbon(b.geometry,b.material):b instanceof THREE.ParticleSystem?
(a=new THREE.ParticleSystem(b.geometry,b.material),a.sortParticles=b.sortParticles):b instanceof THREE.Particle?a=new THREE.Particle(b.material):b instanceof THREE.Sprite?(a=new THREE.Sprite({}),a.color.copy(b.color),a.map=b.map,a.blending=b.blending,a.useScreenCoordinates=b.useScreenCoordinates,a.mergeWith3D=b.mergeWith3D,a.affectedByDistance=b.affectedByDistance,a.scaleByViewport=b.scaleByViewport,a.alignment=b.alignment,a.rotation3d.copy(b.rotation3d),a.rotation=b.rotation,a.opacity=b.opacity,
View
6 build/custom/ThreeWebGL.js
@@ -290,9 +290,9 @@ if(a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geome
f.deleteBuffer(c.__webglLineBuffer);var d=void 0,e=void 0;if(c.numMorphTargets){d=0;for(e=c.numMorphTargets;d<e;d++)f.deleteBuffer(c.__webglMorphTargetsBuffers[d])}if(c.numMorphNormals){d=0;for(e=c.numMorphNormals;d<e;d++)f.deleteBuffer(c.__webglMorphNormalsBuffers[d])}if(c.__webglCustomAttributesList){d=void 0;for(d in c.__webglCustomAttributesList)f.deleteBuffer(c.__webglCustomAttributesList[d].buffer)}E.info.memory.geometries--}else if(a instanceof THREE.Ribbon){a=a.geometry;f.deleteBuffer(a.__webglVertexBuffer);
f.deleteBuffer(a.__webglColorBuffer);E.info.memory.geometries--}else if(a instanceof THREE.Line){a=a.geometry;f.deleteBuffer(a.__webglVertexBuffer);f.deleteBuffer(a.__webglColorBuffer);E.info.memory.geometries--}else if(a instanceof THREE.ParticleSystem){a=a.geometry;f.deleteBuffer(a.__webglVertexBuffer);f.deleteBuffer(a.__webglColorBuffer);E.info.memory.geometries--}}};this.deallocateTexture=function(a){if(a.__webglInit){a.__webglInit=false;f.deleteTexture(a.__webglTexture);E.info.memory.textures--}};
this.deallocateRenderTarget=function(a){if(a&&a.__webglTexture){f.deleteTexture(a.__webglTexture);if(a instanceof THREE.WebGLRenderTargetCube)for(var b=0;b<6;b++){f.deleteFramebuffer(a.__webglFramebuffer[b]);f.deleteRenderbuffer(a.__webglRenderbuffer[b])}else{f.deleteFramebuffer(a.__webglFramebuffer);f.deleteRenderbuffer(a.__webglRenderbuffer)}}};this.deallocateMaterial=function(a){var b=a.program;if(b){a.program=void 0;var c,d,e=false,a=0;for(c=W.length;a<c;a++){d=W[a];if(d.program===b){d.usedTimes--;
-d.usedTimes===0&&(e=true);break}}if(e){e=[];a=0;for(c=W.length;a<c;a++){d=W[a];d.program!==b&&e.push(d)}W=e;f.deleteProgram(b);E.info.memory.programs--}}};this.updateShadowMap=function(a,b){za=null;na=ca=nb=Xa=Ia=-1;ob=true;Ha=Ba=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=function(a,b,c){if(a.hasPos&&!a.__webglVertexBuffer)a.__webglVertexBuffer=f.createBuffer();if(a.hasNormal&&!a.__webglNormalBuffer)a.__webglNormalBuffer=f.createBuffer();if(a.hasUv&&!a.__webglUvBuffer)a.__webglUvBuffer=
-f.createBuffer();if(a.hasPos){f.bindBuffer(f.ARRAY_BUFFER,a.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,a.positionArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(b.attributes.position);f.vertexAttribPointer(b.attributes.position,3,f.FLOAT,false,0,0)}if(a.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,e,g,h,i,k,j,l,m,n,p=a.count*3;for(n=0;n<p;n=n+9){c=a.normalArray;d=c[n];e=c[n+1];g=c[n+2];h=c[n+3];k=c[n+4];l=c[n+5];i=c[n+6];j=c[n+7];m=c[n+8];d=(d+
-h+i)/3;e=(e+k+j)/3;g=(g+l+m)/3;c[n]=d;c[n+1]=e;c[n+2]=g;c[n+3]=d;c[n+4]=e;c[n+5]=g;c[n+6]=d;c[n+7]=e;c[n+8]=g}}f.bufferData(f.ARRAY_BUFFER,a.normalArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(b.attributes.normal);f.vertexAttribPointer(b.attributes.normal,3,f.FLOAT,false,0,0)}if(a.hasUv){f.bindBuffer(f.ARRAY_BUFFER,a.__webglUvBuffer);f.bufferData(f.ARRAY_BUFFER,a.uvArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(b.attributes.uv);f.vertexAttribPointer(b.attributes.uv,2,f.FLOAT,false,0,0)}f.drawArrays(f.TRIANGLES,
+d.usedTimes===0&&(e=true);break}}if(e){e=[];a=0;for(c=W.length;a<c;a++){d=W[a];d.program!==b&&e.push(d)}W=e;f.deleteProgram(b);E.info.memory.programs--}}};this.updateShadowMap=function(a,b){za=null;na=ca=nb=Xa=Ia=-1;ob=true;Ha=Ba=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=function(a,b,c){if(a.hasPositions&&!a.__webglVertexBuffer)a.__webglVertexBuffer=f.createBuffer();if(a.hasNormals&&!a.__webglNormalBuffer)a.__webglNormalBuffer=f.createBuffer();if(a.hasUvs&&!a.__webglUvBuffer)a.__webglUvBuffer=
+f.createBuffer();if(a.hasPositions){f.bindBuffer(f.ARRAY_BUFFER,a.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,a.positionArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(b.attributes.position);f.vertexAttribPointer(b.attributes.position,3,f.FLOAT,false,0,0)}if(a.hasNormals){f.bindBuffer(f.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,e,g,h,i,k,j,l,m,n,p=a.count*3;for(n=0;n<p;n=n+9){c=a.normalArray;d=c[n];e=c[n+1];g=c[n+2];h=c[n+3];k=c[n+4];l=c[n+5];i=c[n+6];j=c[n+7];m=c[n+
+8];d=(d+h+i)/3;e=(e+k+j)/3;g=(g+l+m)/3;c[n]=d;c[n+1]=e;c[n+2]=g;c[n+3]=d;c[n+4]=e;c[n+5]=g;c[n+6]=d;c[n+7]=e;c[n+8]=g}}f.bufferData(f.ARRAY_BUFFER,a.normalArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(b.attributes.normal);f.vertexAttribPointer(b.attributes.normal,3,f.FLOAT,false,0,0)}if(a.hasUvs){f.bindBuffer(f.ARRAY_BUFFER,a.__webglUvBuffer);f.bufferData(f.ARRAY_BUFFER,a.uvArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(b.attributes.uv);f.vertexAttribPointer(b.attributes.uv,2,f.FLOAT,false,0,0)}f.drawArrays(f.TRIANGLES,
0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,e,g){if(d.visible!==false){c=r(a,b,c,d,g);a=c.attributes;b=false;d=e.id*16777215+c.id*2+(d.wireframe?1:0);if(d!==ca){ca=d;b=true}if(g instanceof THREE.Mesh){g=e.offsets;d=0;for(c=g.length;d<c;++d){if(b){f.bindBuffer(f.ARRAY_BUFFER,e.vertexPositionBuffer);f.vertexAttribPointer(a.position,e.vertexPositionBuffer.itemSize,f.FLOAT,false,0,g[d].index*12);if(a.normal>=0&&e.vertexNormalBuffer){f.bindBuffer(f.ARRAY_BUFFER,e.vertexNormalBuffer);
f.vertexAttribPointer(a.normal,e.vertexNormalBuffer.itemSize,f.FLOAT,false,0,g[d].index*12)}if(a.uv>=0&&e.vertexUvBuffer)if(e.vertexUvBuffer){f.bindBuffer(f.ARRAY_BUFFER,e.vertexUvBuffer);f.vertexAttribPointer(a.uv,e.vertexUvBuffer.itemSize,f.FLOAT,false,0,g[d].index*8);f.enableVertexAttribArray(a.uv)}else f.disableVertexAttribArray(a.uv);if(a.color>=0&&e.vertexColorBuffer){f.bindBuffer(f.ARRAY_BUFFER,e.vertexColorBuffer);f.vertexAttribPointer(a.color,e.vertexColorBuffer.itemSize,f.FLOAT,false,0,
g[d].index*16)}f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,e.vertexIndexBuffer)}f.drawElements(f.TRIANGLES,g[d].count,f.UNSIGNED_SHORT,g[d].start*2);E.info.render.calls++;E.info.render.vertices=E.info.render.vertices+g[d].count;E.info.render.faces=E.info.render.faces+g[d].count/3}}}};this.renderBuffer=function(a,b,c,d,e,g){if(d.visible!==false){var h,i,c=r(a,b,c,d,g),b=c.attributes,a=false,c=e.id*16777215+c.id*2+(d.wireframe?1:0);if(c!==ca){ca=c;a=true}if(!d.morphTargets&&b.position>=0){if(a){f.bindBuffer(f.ARRAY_BUFFER,
View
24 examples/js/MarchingCubes.js
@@ -53,9 +53,9 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs ) {
this.maxCount = 4096; // TODO: find the fastest size for this buffer
this.count = 0;
- this.hasPos = false;
- this.hasNormal = false;
- this.hasUv = false;
+ this.hasPositions = false;
+ this.hasNormals = false;
+ this.hasUvs = false;
this.positionArray = new Float32Array( this.maxCount * 3 );
this.normalArray = new Float32Array( this.maxCount * 3 );
@@ -362,12 +362,12 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs ) {
if ( this.count >= this.maxCount - 3 ) {
- this.hasPos = true;
- this.hasNormal = true;
+ this.hasPositions = true;
+ this.hasNormals = true;
if ( this.enableUvs ) {
- this.hasUv = true;
+ this.hasUvs = true;
}
@@ -381,9 +381,9 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs ) {
this.count = 0;
- this.hasPos = false;
- this.hasNormal = false;
- this.hasUv = false;
+ this.hasPositions = false;
+ this.hasNormals = false;
+ this.hasUvs = false;
};
@@ -395,12 +395,12 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs ) {
for ( var i = this.count * 3; i < this.positionArray.length; i ++ )
this.positionArray[ i ] = 0.0;
- this.hasPos = true;
- this.hasNormal = true;
+ this.hasPositions = true;
+ this.hasNormals = true;
if ( this.enableUvs ) {
- this.hasUv = true;
+ this.hasUvs = true;
}
View
12 src/renderers/WebGLRenderer.js
@@ -2882,11 +2882,11 @@ THREE.WebGLRenderer = function ( parameters ) {
this.renderBufferImmediate = function ( object, program, shading ) {
- if ( object.hasPos && ! object.__webglVertexBuffer ) object.__webglVertexBuffer = _gl.createBuffer();
- if ( object.hasNormal && ! object.__webglNormalBuffer ) object.__webglNormalBuffer = _gl.createBuffer();
- if ( object.hasUv && ! object.__webglUvBuffer ) object.__webglUvBuffer = _gl.createBuffer();
+ if ( object.hasPositions && ! object.__webglVertexBuffer ) object.__webglVertexBuffer = _gl.createBuffer();
+ if ( object.hasNormals && ! object.__webglNormalBuffer ) object.__webglNormalBuffer = _gl.createBuffer();
+ if ( object.hasUvs && ! object.__webglUvBuffer ) object.__webglUvBuffer = _gl.createBuffer();
- if ( object.hasPos ) {
+ if ( object.hasPositions ) {
_gl.bindBuffer( _gl.ARRAY_BUFFER, object.__webglVertexBuffer );
_gl.bufferData( _gl.ARRAY_BUFFER, object.positionArray, _gl.DYNAMIC_DRAW );
@@ -2895,7 +2895,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
- if ( object.hasNormal ) {
+ if ( object.hasNormals ) {
_gl.bindBuffer( _gl.ARRAY_BUFFER, object.__webglNormalBuffer );
@@ -2948,7 +2948,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
- if ( object.hasUv ) {
+ if ( object.hasUvs ) {
_gl.bindBuffer( _gl.ARRAY_BUFFER, object.__webglUvBuffer );
_gl.bufferData( _gl.ARRAY_BUFFER, object.uvArray, _gl.DYNAMIC_DRAW );

0 comments on commit 763fcf7

Please sign in to comment.