diff --git a/build/Three.js b/build/Three.js index 9a5493e4..8bfa7ba3 100755 --- a/build/Three.js +++ b/build/Three.js @@ -1,7 +1,7 @@ // Three.js r32 - http://github.com/mrdoob/three.js -var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=!0;this.setHex(a)}; -THREE.Color.prototype={setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,d){var e,g,i,l,n,k;if(d==0)e=g=i=0;else{l=Math.floor(a*6);n=a*6-l;a=d*(1-b);k=d*(1-b*n);b=d*(1-b*(1-n));switch(l){case 1:e=k;g=d;i=a;break;case 2:e=a;g=d;i=b;break;case 3:e=a;g=k;i=d;break;case 4:e=b;g=a;i=d;break;case 5:e=d;g=a;i=k;break;case 6:case 0:e=d;g=b;i=a}}this.r=e;this.g=g;this.b=i;if(this.autoUpdate){this.updateHex();this.updateStyleString()}}, -setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+ +var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)}; +THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,d){var e,g,i,l,n,k;if(d==0)e=g=i=0;else{l=Math.floor(a*6);n=a*6-l;a=d*(1-b);k=d*(1-b*n);b=d*(1-b*(1-n));switch(l){case 1:e=k;g=d;i=a;break;case 2:e=a;g=d;i=b;break;case 3:e=a;g=k;i=d;break;case 4:e=b;g=a;i=d;break;case 5:e=d;g=a;i=k;break;case 6:case 0:e=d;g=b;i=a}}this.r=e;this.g=g;this.b=i;if(this.autoUpdate){this.updateHex(); +this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+ this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0}; THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x* this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,d){this.x=a||0;this.y=b||0;this.z=d||0}; @@ -67,19 +67,19 @@ z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,d=this. this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,d=this.vertices.length;b65535){o[n].counter+=1;k=o[n].hash+"_"+o[n].counter;this.geometryChunks[k]==undefined&&(this.geometryChunks[k]={faces:[],materials:l,vertices:0})}this.geometryChunks[k].faces.push(e);this.geometryChunks[k].vertices+=i}},toString:function(){return"THREE.Geometry ( vertices: "+ this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0; -THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.visible=!0;this.autoUpdateMatrix=!0;this.matrixNeedsToUpdate=!0;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale=1;this.rotationMatrix= -new THREE.Matrix4};THREE.Object3D.prototype.update=function(a,b,d){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}var e=this.children.length;for(a=0;athis.data.length){for(;k>this.data.length;)k-=this.data.length;this.startTime=(new Date).getTime()*0.001-k;k=(new Date).getTime()*0.001-this.startTime}l=Math.min(parseInt(k*this.data.fps),parseInt(this.data.length*this.data.fps));for(var s=0,w=this.hierarchy.length;s1){console.log("Scale out of bounds:"+b);b=b<0?0:1}THREE.Quaternion.slerp(e,g,i.quaternion,b)}else{d=d==="pos"?i.position:i.scale;d.x=e[0]+(g[0]-e[0])*b;d.y=e[1]+(g[1]-e[1])*b;d.z=e[2]+(g[2]-e[2])*b}}}if(n[0][l]===undefined){this.hierarchy[0].update(undefined,!0);for(s=0;s-this.zNear)return!1;if(l+i<-this.zFar)return!1;l-=i;var n=this.projectionMatrix,k=1/(n.n43*l),o=k*this.screenCenterX,s=(g.n11*b+g.n12*d+g.n13*e+g.n14)*n.n11*o;i=n.n11*i*o;if(s+i<-this.screenCenterX)return!1;if(s-i>this.screenCenterX)return!1;b=(g.n21*b+g.n22*d+g.n23*e+g.n24)*n.n22*k*this.screenCenterY; if(b+i<-this.screenCenterY)return!1;if(b-i>this.screenCenterY)return!1;a.screenPosition.set(s,b,l,i);return!0};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight; @@ -144,8 +144,8 @@ THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(a,b,d){this.color=new THREE.Color(a);this.near=b||1;this.far=d||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4}; THREE.Projector=function(){function a(T,O){return O.z-T.z}function b(T,O){var ca=0,S=1,ba=T.z+T.w,V=O.z+O.w,D=-T.z+T.w,J=-O.z+O.w;if(ba>=0&&V>=0&&D>=0&&J>=0)return!0;else if(ba<0&&V<0||D<0&&J<0)return!1;else{if(ba<0)ca=Math.max(ca,ba/(ba-V));else V<0&&(S=Math.min(S,ba/(ba-V)));if(D<0)ca=Math.max(ca,D/(D-J));else J<0&&(S=Math.min(S,D/(D-J)));if(Sba&&Q.z=0&&c.enableVertexAttribArray(j.color);j.normal>=0&&c.enableVertexAttribArray(j.normal);j.tangent>=0&&c.enableVertexAttribArray(j.tangent);if(f.skinning&&j.skinVertexA>=0&&j.skinVertexB>= -0&&j.skinIndex>=0&&j.skinWeight>=0){c.enableVertexAttribArray(j.skinVertexA);c.enableVertexAttribArray(j.skinVertexB);c.enableVertexAttribArray(j.skinIndex);c.enableVertexAttribArray(j.skinWeight)}};this.render=function(f,m,p,j){var h,q,t,A,W,G,M,C,aa=f.lights,da=f.fog;m.autoUpdateMatrix&&m.update();m.globalMatrix.flattenToArray(ja);m.projectionMatrix.flattenToArray(la);m.inverseMatrix.flattenToArray(Q);J.multiply(m.projectionMatrix,m.globalMatrix);k(J);THREE.AnimationHandler&&THREE.AnimationHandler.update(); +0&&j.skinIndex>=0&&j.skinWeight>=0){c.enableVertexAttribArray(j.skinVertexA);c.enableVertexAttribArray(j.skinVertexB);c.enableVertexAttribArray(j.skinIndex);c.enableVertexAttribArray(j.skinWeight)}};this.render=function(f,m,p,j){var h,q,t,A,W,G,M,C,aa=f.lights,da=f.fog;m.matrixAutoUpdate&&m.update();m.globalMatrix.flattenToArray(ja);m.projectionMatrix.flattenToArray(la);m.inverseMatrix.flattenToArray(Q);J.multiply(m.projectionMatrix,m.globalMatrix);k(J);THREE.AnimationHandler&&THREE.AnimationHandler.update(); f.update(undefined,!1,m);this.initWebGLObjects(f,m);r(p,j!==undefined?j:!0);this.autoClear&&this.clear();W=f.__webGLObjects.length;for(j=0;j>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+ +var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)}; +THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var d,f,g,h,k,j;if(c==0)d=f=g=0;else{h=Math.floor(a*6);k=a*6-h;a=c*(1-b);j=c*(1-b*k);b=c*(1-b*(1-k));switch(h){case 1:d=j;f=c;g=a;break;case 2:d=a;f=c;g=b;break;case 3:d=a;f=j;g=c;break;case 4:d=b;f=a;g=c;break;case 5:d=c;f=a;g=j;break;case 6:case 0:d=c;f=b;g=a}}this.r=d;this.g=f;this.b=g;if(this.autoUpdate){this.updateHex(); +this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+ this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0}; THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x* this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0}; @@ -67,19 +67,19 @@ z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this. this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b65535){m[k].counter+=1;j=m[k].hash+"_"+m[k].counter;this.geometryChunks[j]==undefined&&(this.geometryChunks[j]={faces:[],materials:h,vertices:0})}this.geometryChunks[j].faces.push(d);this.geometryChunks[j].vertices+=g}},toString:function(){return"THREE.Geometry ( vertices: "+ this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0; -THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.visible=!0;this.autoUpdateMatrix=!0;this.matrixNeedsToUpdate=!0;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale=1;this.rotationMatrix= -new THREE.Matrix4};THREE.Object3D.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}var d=this.children.length;for(a=0;athis.data.length){for(;j>this.data.length;)j-=this.data.length;this.startTime=(new Date).getTime()*0.001-j;j=(new Date).getTime()*0.001-this.startTime}h=Math.min(parseInt(j*this.data.fps),parseInt(this.data.length*this.data.fps));for(var o=0,w=this.hierarchy.length;o1){console.log("Scale out of bounds:"+b);b=b<0?0:1}THREE.Quaternion.slerp(d,f,g.quaternion,b)}else{c=c==="pos"?g.position:g.scale;c.x=d[0]+(f[0]-d[0])*b;c.y=d[1]+(f[1]-d[1])*b;c.z=d[2]+(f[2]-d[2])*b}}}if(k[0][h]===undefined){this.hierarchy[0].update(undefined,!0);for(o=0;o-this.zNear)return!1;if(h+g<-this.zFar)return!1;h-=g;var k=this.projectionMatrix,j=1/(k.n43*h),m=j*this.screenCenterX,o=(f.n11*b+f.n12*c+f.n13*d+f.n14)*k.n11*m;g=k.n11*g*m;if(o+g<-this.screenCenterX)return!1;if(o-g>this.screenCenterX)return!1;b=(f.n21*b+f.n22*c+f.n23*d+f.n24)*k.n22*j*this.screenCenterY; if(b+g<-this.screenCenterY)return!1;if(b-g>this.screenCenterY)return!1;a.screenPosition.set(o,b,h,g);return!0};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight; @@ -144,8 +144,8 @@ THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b||1;this.far=c||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4}; THREE.Projector=function(){function a(L,M){return M.z-L.z}function b(L,M){var V=0,S=1,Y=L.z+L.w,Z=M.z+M.w,G=-L.z+L.w,U=-M.z+M.w;if(Y>=0&&Z>=0&&G>=0&&U>=0)return!0;else if(Y<0&&Z<0||G<0&&U<0)return!1;else{if(Y<0)V=Math.max(V,Y/(Y-Z));else Z<0&&(S=Math.min(S,Y/(Y-Z)));if(G<0)V=Math.max(V,G/(G-U));else U<0&&(S=Math.min(S,G/(G-U)));if(SY&&W.z=0&&e.enableVertexAttribArray(p.color);p.normal>=0&&e.enableVertexAttribArray(p.normal);p.tangent>=0&&e.enableVertexAttribArray(p.tangent);if(l.skinning&&p.skinVertexA>=0&&p.skinVertexB>= -0&&p.skinIndex>=0&&p.skinWeight>=0){e.enableVertexAttribArray(p.skinVertexA);e.enableVertexAttribArray(p.skinVertexB);e.enableVertexAttribArray(p.skinIndex);e.enableVertexAttribArray(p.skinWeight)}};this.render=function(l,z,C,p){var n,B,H,N,ca,y,E,D,P=l.lights,T=l.fog;z.autoUpdateMatrix&&z.update();z.globalMatrix.flattenToArray(ka);z.projectionMatrix.flattenToArray(na);z.inverseMatrix.flattenToArray(W);U.multiply(z.projectionMatrix,z.globalMatrix);j(U);THREE.AnimationHandler&&THREE.AnimationHandler.update(); +0&&p.skinIndex>=0&&p.skinWeight>=0){e.enableVertexAttribArray(p.skinVertexA);e.enableVertexAttribArray(p.skinVertexB);e.enableVertexAttribArray(p.skinIndex);e.enableVertexAttribArray(p.skinWeight)}};this.render=function(l,z,C,p){var n,B,H,N,ca,y,E,D,P=l.lights,T=l.fog;z.matrixAutoUpdate&&z.update();z.globalMatrix.flattenToArray(ka);z.projectionMatrix.flattenToArray(na);z.inverseMatrix.flattenToArray(W);U.multiply(z.projectionMatrix,z.globalMatrix);j(U);THREE.AnimationHandler&&THREE.AnimationHandler.update(); l.update(undefined,!1,z);this.initWebGLObjects(l,z);v(C,p!==undefined?p:!0);this.autoClear&&this.clear();ca=l.__webGLObjects.length;for(p=0;pWebGL
\n
\nPlease try in\nChrome 9+ /\nFirefox 4+ /\nSafari OSX 10.6+';d.id= c;c=d.style;c.fontFamily="monospace";c.fontSize="13px";c.textAlign="center";c.background="#eee";c.color="#000";c.padding="1em";c.width="475px";c.margin="5em auto 0";a.appendChild(d);b.appendChild(a);return d}}; -var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,d=a.vertices.length,f=c?b.geometry:b,g=a.vertices,h=f.vertices,k=a.faces,j=f.faces,m=a.uvs;f=f.uvs;c&&b.autoUpdateMatrix&&b.updateMatrix();for(var o=0,w=h.length;o + + } + - + - +
three.js - webgl ribbons example
- + @@ -155,7 +155,7 @@ diff --git a/src/animation/Animation.js b/src/animation/Animation.js index 031bc76c..4104249d 100644 --- a/src/animation/Animation.js +++ b/src/animation/Animation.js @@ -54,7 +54,7 @@ THREE.Animation.prototype.play = function( loop ) { for( var h = 0; h < this.hierarchy.length; h++ ) { this.hierarchy[ h ].useQuaternion = true; - this.hierarchy[ h ].autoUpdateMatrix = true; + this.hierarchy[ h ].matrixAutoUpdate = true; if( this.hierarchy[ h ].prevKey === undefined ) { @@ -159,8 +159,8 @@ THREE.Animation.prototype.update = function( time ) { if( JIThierarchy[ h ][ frame ] !== undefined ) { object.skinMatrix = JIThierarchy[ h ][ frame ]; - object.autoUpdateMatrix = false; - object.matrixNeedsToUpdate = false; + object.matrixAutoUpdate = false; + object.matrixNeedsUpdate = false; //object.skinMatrix.flattenToArray( this.root.boneMatrices[ h ] ); object.skinMatrix.flattenToArrayOffset( this.root.boneMatrices, h * 16 ); @@ -214,8 +214,8 @@ THREE.Animation.prototype.update = function( time ) { // interpolate rot (quaternion slerp) - object.autoUpdateMatrix = true; - object.matrixNeedsToUpdate = true; + object.matrixAutoUpdate = true; + object.matrixNeedsUpdate = true; scale = ( currentTime - prevKey.time ) / ( nextKey.time - prevKey.time ); prevXYZ = prevKey[ type ]; diff --git a/src/cameras/Camera.js b/src/cameras/Camera.js index 48ca243f..cc3c6046 100644 --- a/src/cameras/Camera.js +++ b/src/cameras/Camera.js @@ -98,17 +98,17 @@ THREE.Camera.prototype.update = function( parentGlobalMatrix, forceUpdate, camer } else { - if( this.autoUpdateMatrix ) + if( this.matrixAutoUpdate ) forceUpdate |= this.updateMatrix(); - if( forceUpdate || this.matrixNeedsToUpdate ) { + if( forceUpdate || this.matrixNeedsUpdate ) { if( parentGlobalMatrix ) this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix ); else this.globalMatrix.copy( this.localMatrix ); - this.matrixNeedsToUpdate = false; + this.matrixNeedsUpdate = false; forceUpdate = true; THREE.Matrix4.makeInvert( this.globalMatrix, this.inverseMatrix ); diff --git a/src/core/Color.js b/src/core/Color.js index 6f1bf9c8..1559f6a4 100644 --- a/src/core/Color.js +++ b/src/core/Color.js @@ -4,13 +4,14 @@ THREE.Color = function ( hex ) { - this.autoUpdate = true; this.setHex( hex ); }; THREE.Color.prototype = { + autoUpdate: true, + setRGB: function ( r, g, b ) { this.r = r; @@ -26,27 +27,27 @@ THREE.Color.prototype = { }, - // based on MochiKit implementation by Bob Ippolito - // h,s,v ranges are < 0.0 - 1.0 > - setHSV: function ( h, s, v ) { + // based on MochiKit implementation by Bob Ippolito + // h,s,v ranges are < 0.0 - 1.0 > + var red, green, blue, i, f, p, q, t; - + if ( v == 0.0 ) { - + red = green = blue = 0; - + } else { - + i = Math.floor( h * 6 ); f = ( h * 6 ) - i; p = v * ( 1 - s ); q = v * ( 1 - ( s * f ) ); t = v * ( 1 - ( s * ( 1 - f ) ) ); - + switch ( i ) { - + case 1: red = q; green = v; blue = p; break; case 2: red = p; green = v; blue = t; break; case 3: red = p; green = q; blue = v; break; @@ -54,11 +55,11 @@ THREE.Color.prototype = { case 5: red = v; green = p; blue = q; break; case 6: // fall through case 0: red = v; green = t; blue = p; break; - + } - + } - + this.r = red; this.g = green; this.b = blue; @@ -69,9 +70,9 @@ THREE.Color.prototype = { this.updateStyleString(); } - + }, - + setHex: function ( hex ) { this.hex = ( ~~ hex ) & 0xffffff; @@ -111,7 +112,6 @@ THREE.Color.prototype = { }, - toString: function () { return 'THREE.Color ( r: ' + this.r + ', g: ' + this.g + ', b: ' + this.b + ', hex: ' + this.hex + ' )'; diff --git a/src/extras/GeometryUtils.js b/src/extras/GeometryUtils.js index 4638c187..aacc9b20 100644 --- a/src/extras/GeometryUtils.js +++ b/src/extras/GeometryUtils.js @@ -14,7 +14,7 @@ var GeometryUtils = { uvs1 = geometry1.uvs, uvs2 = geometry2.uvs; - isMesh && object2.autoUpdateMatrix && object2.updateMatrix(); + isMesh && object2.matrixAutoUpdate && object2.updateMatrix(); for ( var i = 0, il = vertices2.length; i < il; i ++ ) { diff --git a/src/objects/Bone.js b/src/objects/Bone.js index e61ec2ef..cb60fcc9 100644 --- a/src/objects/Bone.js +++ b/src/objects/Bone.js @@ -25,21 +25,21 @@ THREE.Bone.prototype.update = function( parentSkinMatrix, forceUpdate, camera ) // update local - if( this.autoUpdateMatrix ) + if( this.matrixAutoUpdate ) forceUpdate |= this.updateMatrix(); // update skin matrix - if( forceUpdate || this.matrixNeedsToUpdate ) { + if( forceUpdate || this.matrixNeedsUpdate ) { if( parentSkinMatrix ) this.skinMatrix.multiply( parentSkinMatrix, this.localMatrix ); else this.skinMatrix.copy( this.localMatrix ); - this.matrixNeedsToUpdate = false; - forceUpdate = true; + this.matrixNeedsUpdate = false; + forceUpdate = true; } @@ -96,4 +96,4 @@ THREE.Bone.prototype.addChild = function( child ) { /* * Todo: Remove Children: see if any remaining are none-Bone - */ \ No newline at end of file + */ diff --git a/src/objects/LOD.js b/src/objects/LOD.js index 32ad47ab..a4612803 100644 --- a/src/objects/LOD.js +++ b/src/objects/LOD.js @@ -43,20 +43,20 @@ THREE.LOD.prototype.update = function( parentGlobalMatrix, forceUpdate, camera ) // update local - if( this.autoUpdateMatrix ) + if( this.matrixAutoUpdate ) forceUpdate |= this.updateMatrix(); // update global - if( forceUpdate || this.matrixNeedsToUpdate ) { + if( forceUpdate || this.matrixNeedsUpdate ) { if( parentGlobalMatrix ) this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix ); else this.globalMatrix.copy( this.localMatrix ); - this.matrixNeedsToUpdate = false; + this.matrixNeedsUpdate = false; forceUpdate = true; } diff --git a/src/objects/Mesh.js b/src/objects/Mesh.js index 5a135734..3924592d 100644 --- a/src/objects/Mesh.js +++ b/src/objects/Mesh.js @@ -45,20 +45,20 @@ THREE.Mesh.prototype.update = function( parentGlobalMatrix, forceUpdate, camera // update local - if( this.autoUpdateMatrix ) + if( this.matrixAutoUpdate ) forceUpdate |= this.updateMatrix(); // update global - if( forceUpdate || this.matrixNeedsToUpdate ) { + if( forceUpdate || this.matrixNeedsUpdate ) { if( parentGlobalMatrix ) this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix ); else this.globalMatrix.copy( this.localMatrix ); - this.matrixNeedsToUpdate = false; + this.matrixNeedsUpdate = false; forceUpdate = true; } diff --git a/src/objects/Object3D.js b/src/objects/Object3D.js index 3ab0ca62..14223ab1 100644 --- a/src/objects/Object3D.js +++ b/src/objects/Object3D.js @@ -9,8 +9,8 @@ THREE.Object3D = function() { this.id = THREE.Object3DCounter.value ++; this.visible = true; - this.autoUpdateMatrix = true; - this.matrixNeedsToUpdate = true; + this.matrixAutoUpdate = true; + this.matrixNeedsUpdate = true; this.parent = undefined; this.children = []; @@ -44,20 +44,20 @@ THREE.Object3D.prototype.update = function( parentGlobalMatrix, forceUpdate, cam // update local - if( this.autoUpdateMatrix ) + if( this.matrixAutoUpdate ) forceUpdate |= this.updateMatrix(); // update global - if( forceUpdate || this.matrixNeedsToUpdate ) { + if( forceUpdate || this.matrixNeedsUpdate ) { if( parentGlobalMatrix ) this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix ); else this.globalMatrix.copy( this.localMatrix ); - this.matrixNeedsToUpdate = false; + this.matrixNeedsUpdate = false; forceUpdate = true; } diff --git a/src/objects/Particle.js b/src/objects/Particle.js index a81885e9..2c439bff 100644 --- a/src/objects/Particle.js +++ b/src/objects/Particle.js @@ -8,7 +8,7 @@ THREE.Particle = function ( materials ) { this.materials = materials instanceof Array ? materials : [ materials ]; - this.autoUpdateMatrix = false; + this.matrixAutoUpdate = false; }; diff --git a/src/objects/SkinnedMesh.js b/src/objects/SkinnedMesh.js index df46ef20..c57442e5 100644 --- a/src/objects/SkinnedMesh.js +++ b/src/objects/SkinnedMesh.js @@ -83,20 +83,20 @@ THREE.SkinnedMesh.prototype.update = function( parentGlobalMatrix, forceUpdate, // update local - if( this.autoUpdateMatrix ) + if( this.matrixAutoUpdate ) forceUpdate |= this.updateMatrix(); // update global - if( forceUpdate || this.matrixNeedsToUpdate ) { + if( forceUpdate || this.matrixNeedsUpdate ) { if( parentGlobalMatrix ) this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix ); else this.globalMatrix.copy( this.localMatrix ); - this.matrixNeedsToUpdate = false; + this.matrixNeedsUpdate = false; forceUpdate = true; } diff --git a/src/renderers/Projector.js b/src/renderers/Projector.js index 0bc99e7b..a4e19844 100644 --- a/src/renderers/Projector.js +++ b/src/renderers/Projector.js @@ -72,7 +72,7 @@ THREE.Projector = function() { _face3Count = _lineCount = _particleCount = 0; - camera.autoUpdateMatrix && camera.update(); + camera.matrixAutoUpdate && camera.update(); _projScreenMatrix.multiply( camera.projectionMatrix, camera.globalMatrix ); computeFrustum( _projScreenMatrix ); @@ -87,7 +87,7 @@ THREE.Projector = function() { if ( !object.visible ) continue; - object.autoUpdateMatrix && object.updateMatrix(); + object.matrixAutoUpdate && object.updateMatrix(); objectMatrix = object.globalMatrix; objectMatrix.extractRotationMatrix( object.rotationMatrix ); diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 90c8e6f2..9b01ee2d 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -22,20 +22,20 @@ THREE.WebGLRenderer = function ( parameters ) { var _canvas = document.createElement( 'canvas' ), _gl, _oldProgram = null, - _oldFramebuffer = null, + _oldFramebuffer = null, _this = this, - + // gl state cache - + _oldDoubleSided = null, _oldFlipSided = null, _oldBlending = null, _oldDepth = null, - + // camera matrices caches - - _frustum = [ + + _frustum = [ new THREE.Vector4(), new THREE.Vector4(), new THREE.Vector4(), @@ -47,11 +47,11 @@ THREE.WebGLRenderer = function ( parameters ) { _projScreenMatrix = new THREE.Matrix4(), _projectionMatrixArray = new Float32Array( 16 ), _cameraInverseMatrixArray = new Float32Array( 16 ), - - _viewMatrixArray = new Float32Array( 16 ), + + _viewMatrixArray = new Float32Array( 16 ), _vector3 = new THREE.Vector4(), - + // parameters defaults antialias = true, @@ -127,7 +127,7 @@ THREE.WebGLRenderer = function ( parameters ) { dlength = 0, plength = 0, - + doffset = 0, poffset = 0; @@ -147,7 +147,7 @@ THREE.WebGLRenderer = function ( parameters ) { } else if ( light instanceof THREE.DirectionalLight ) { doffset = dlength * 3; - + dcolors[ doffset ] = color.r * intensity; dcolors[ doffset + 1 ] = color.g * intensity; dcolors[ doffset + 2 ] = color.b * intensity; @@ -161,7 +161,7 @@ THREE.WebGLRenderer = function ( parameters ) { } else if( light instanceof THREE.PointLight ) { poffset = plength * 3; - + pcolors[ poffset ] = color.r * intensity; pcolors[ poffset + 1 ] = color.g * intensity; pcolors[ poffset + 2 ] = color.b * intensity; @@ -175,10 +175,10 @@ THREE.WebGLRenderer = function ( parameters ) { } } - + // null eventual remains from removed lights // (this is to avoid if in shader) - + for( l = dlength * 3; l < dcolors.length; l++ ) dcolors[ l ] = 0.0; for( l = plength * 3; l < pcolors.length; l++ ) pcolors[ l ] = 0.0; @@ -220,17 +220,17 @@ THREE.WebGLRenderer = function ( parameters ) { geometryChunk.__webGLColorBuffer = _gl.createBuffer(); geometryChunk.__webGLUVBuffer = _gl.createBuffer(); geometryChunk.__webGLUV2Buffer = _gl.createBuffer(); - + geometryChunk.__webGLSkinVertexABuffer = _gl.createBuffer(); geometryChunk.__webGLSkinVertexBBuffer = _gl.createBuffer(); geometryChunk.__webGLSkinIndicesBuffer = _gl.createBuffer(); geometryChunk.__webGLSkinWeightsBuffer = _gl.createBuffer(); - + geometryChunk.__webGLFaceBuffer = _gl.createBuffer(); geometryChunk.__webGLLineBuffer = _gl.createBuffer(); }; - + function initLineBuffers ( geometry ) { var nvertices = geometry.vertices.length; @@ -252,14 +252,14 @@ THREE.WebGLRenderer = function ( parameters ) { geometry.__webGLVertexCount = nvertices; }; - + function initParticleBuffers ( geometry ) { var nvertices = geometry.vertices.length; geometry.__vertexArray = new Float32Array( nvertices * 3 ); geometry.__colorArray = new Float32Array( nvertices * 3 ); - + geometry.__sortArray = []; geometry.__webGLParticleCount = nvertices; @@ -306,7 +306,7 @@ THREE.WebGLRenderer = function ( parameters ) { geometryChunk.__skinVertexBArray = new Float32Array( nvertices * 4 ); geometryChunk.__skinIndexArray = new Float32Array( nvertices * 4 ); geometryChunk.__skinWeightArray = new Float32Array( nvertices * 4 ); - + geometryChunk.__faceArray = new Uint16Array( ntris * 3 ); geometryChunk.__lineArray = new Uint16Array( nlines * 2 ); @@ -319,8 +319,8 @@ THREE.WebGLRenderer = function ( parameters ) { function setMeshBuffers ( geometryChunk, object, hint ) { - var f, fl, fi, face, vertexNormals, faceNormal, normal, - uv, uv2, v1, v2, v3, v4, t1, t2, t3, t4, + var f, fl, fi, face, vertexNormals, faceNormal, normal, + uv, uv2, v1, v2, v3, v4, t1, t2, t3, t4, c1, c2, c3, c4, sw1, sw2, sw3, sw4, si1, si2, si3, si4, @@ -347,7 +347,7 @@ THREE.WebGLRenderer = function ( parameters ) { normalArray = geometryChunk.__normalArray, tangentArray = geometryChunk.__tangentArray, colorArray = geometryChunk.__colorArray, - + skinVertexAArray = geometryChunk.__skinVertexAArray, skinVertexBArray = geometryChunk.__skinVertexBArray, skinIndexArray = geometryChunk.__skinIndexArray, @@ -357,13 +357,13 @@ THREE.WebGLRenderer = function ( parameters ) { lineArray = geometryChunk.__lineArray, needsSmoothNormals = geometryChunk.__needsSmoothNormals, - + geometry = object.geometry, // this is shared for all chunks - + dirtyVertices = geometry.__dirtyVertices, - dirtyElements = geometry.__dirtyElements, - dirtyUvs = geometry.__dirtyUvs, - dirtyNormals = geometry.__dirtyNormals, + dirtyElements = geometry.__dirtyElements, + dirtyUvs = geometry.__dirtyUvs, + dirtyNormals = geometry.__dirtyNormals, dirtyTangents = geometry.__dirtyTangents, dirtyColors = geometry.__dirtyColors, @@ -373,12 +373,12 @@ THREE.WebGLRenderer = function ( parameters ) { obj_uvs = geometry.uvs, obj_uvs2 = geometry.uvs2, obj_colors = geometry.colors, - + obj_skinVerticesA = geometry.skinVerticesA, obj_skinVerticesB = geometry.skinVerticesB, obj_skinIndices = geometry.skinIndices, obj_skinWeights = geometry.skinWeights; - + for ( f = 0, fl = chunk_faces.length; f < fl; f++ ) { fi = chunk_faces[ f ]; @@ -412,15 +412,15 @@ THREE.WebGLRenderer = function ( parameters ) { offset += 9; } - + if ( obj_skinWeights.length ) { // weights - + sw1 = obj_skinWeights[ face.a ]; sw2 = obj_skinWeights[ face.b ]; sw3 = obj_skinWeights[ face.c ]; - + skinWeightArray[ offset_skin ] = sw1.x; skinWeightArray[ offset_skin + 1 ] = sw1.y; skinWeightArray[ offset_skin + 2 ] = sw1.z; @@ -437,7 +437,7 @@ THREE.WebGLRenderer = function ( parameters ) { skinWeightArray[ offset_skin + 11 ] = sw3.w; // indices - + si1 = obj_skinIndices[ face.a ]; si2 = obj_skinIndices[ face.b ]; si3 = obj_skinIndices[ face.c ]; @@ -458,7 +458,7 @@ THREE.WebGLRenderer = function ( parameters ) { skinIndexArray[ offset_skin + 11 ] = si3.w; // vertices A - + sa1 = obj_skinVerticesA[ face.a ]; sa2 = obj_skinVerticesA[ face.b ]; sa3 = obj_skinVerticesA[ face.c ]; @@ -479,7 +479,7 @@ THREE.WebGLRenderer = function ( parameters ) { skinVertexAArray[ offset_skin + 11 ] = 1; // vertices B - + sb1 = obj_skinVerticesB[ face.a ]; sb2 = obj_skinVerticesB[ face.b ]; sb3 = obj_skinVerticesB[ face.c ]; @@ -500,11 +500,11 @@ THREE.WebGLRenderer = function ( parameters ) { skinVertexBArray[ offset_skin + 11 ] = 1; offset_skin += 12; - + } if ( dirtyColors && obj_colors.length ) { - + c1 = obj_colors[ face.a ]; c2 = obj_colors[ face.b ]; c3 = obj_colors[ face.c ]; @@ -520,7 +520,7 @@ THREE.WebGLRenderer = function ( parameters ) { colorArray[ offset_color + 6 ] = c3.r; colorArray[ offset_color + 7 ] = c3.g; colorArray[ offset_color + 8 ] = c3.b; - + offset_color += 9; } @@ -664,16 +664,16 @@ THREE.WebGLRenderer = function ( parameters ) { offset += 12; } - + if ( obj_skinWeights.length ) { // weights - + sw1 = obj_skinWeights[ face.a ]; sw2 = obj_skinWeights[ face.b ]; sw3 = obj_skinWeights[ face.c ]; sw4 = obj_skinWeights[ face.d ]; - + skinWeightArray[ offset_skin ] = sw1.x; skinWeightArray[ offset_skin + 1 ] = sw1.y; skinWeightArray[ offset_skin + 2 ] = sw1.z; @@ -695,7 +695,7 @@ THREE.WebGLRenderer = function ( parameters ) { skinWeightArray[ offset_skin + 15 ] = sw4.w; // indices - + si1 = obj_skinIndices[ face.a ]; si2 = obj_skinIndices[ face.b ]; si3 = obj_skinIndices[ face.c ]; @@ -722,7 +722,7 @@ THREE.WebGLRenderer = function ( parameters ) { skinIndexArray[ offset_skin + 15 ] = si4.w; // vertices A - + sa1 = obj_skinVerticesA[ face.a ]; sa2 = obj_skinVerticesA[ face.b ]; sa3 = obj_skinVerticesA[ face.c ]; @@ -749,7 +749,7 @@ THREE.WebGLRenderer = function ( parameters ) { skinVertexAArray[ offset_skin + 15 ] = 1; // vertices B - + sb1 = obj_skinVerticesB[ face.a ]; sb2 = obj_skinVerticesB[ face.b ]; sb3 = obj_skinVerticesB[ face.c ]; @@ -775,10 +775,10 @@ THREE.WebGLRenderer = function ( parameters ) { skinVertexBArray[ offset_skin + 14 ] = sb4.z; skinVertexBArray[ offset_skin + 15 ] = 1; - offset_skin += 16; - + offset_skin += 16; + } - + if ( dirtyColors && obj_colors.length ) { c1 = obj_colors[ face.a ]; @@ -801,11 +801,11 @@ THREE.WebGLRenderer = function ( parameters ) { colorArray[ offset_color + 9 ] = c4.r; colorArray[ offset_color + 10 ] = c4.g; colorArray[ offset_color + 11 ] = c4.b; - + offset_color += 12; - } - + } + if ( dirtyTangents && geometry.hasTangents ) { t1 = vertices[ face.a ].tangent; @@ -883,7 +883,7 @@ THREE.WebGLRenderer = function ( parameters ) { } } - + if ( dirtyUvs && uv2 ) { for ( i = 0; i < 4; i ++ ) { @@ -946,7 +946,7 @@ THREE.WebGLRenderer = function ( parameters ) { _gl.bufferData( _gl.ARRAY_BUFFER, colorArray, hint ); } - + if ( dirtyNormals ) { _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLNormalBuffer ); @@ -984,9 +984,9 @@ THREE.WebGLRenderer = function ( parameters ) { _gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, lineArray, hint ); } - + if( offset_skin > 0 ) { - + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLSkinVertexABuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, skinVertexAArray, hint ); @@ -998,7 +998,7 @@ THREE.WebGLRenderer = function ( parameters ) { _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLSkinWeightsBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, skinWeightArray, hint ); - + } }; @@ -1013,8 +1013,8 @@ THREE.WebGLRenderer = function ( parameters ) { vertexArray = geometry.__vertexArray, colorArray = geometry.__colorArray, - - dirtyVertices = geometry.__dirtyVertices, + + dirtyVertices = geometry.__dirtyVertices, dirtyColors = geometry.__dirtyColors; if ( dirtyVertices ) { @@ -1067,8 +1067,8 @@ THREE.WebGLRenderer = function ( parameters ) { vertexArray = geometry.__vertexArray, colorArray = geometry.__colorArray, - - dirtyVertices = geometry.__dirtyVertices, + + dirtyVertices = geometry.__dirtyVertices, dirtyColors = geometry.__dirtyColors; if ( dirtyVertices ) { @@ -1110,7 +1110,7 @@ THREE.WebGLRenderer = function ( parameters ) { } }; - + function setParticleBuffers ( geometry, hint, object, camera ) { var v, c, vertex, offset, @@ -1119,60 +1119,60 @@ THREE.WebGLRenderer = function ( parameters ) { colors = geometry.colors, cl = colors.length, - + vertexArray = geometry.__vertexArray, colorArray = geometry.__colorArray, - + sortArray = geometry.__sortArray, - + dirtyVertices = geometry.__dirtyVertices, dirtyElements = geometry.__dirtyElements, dirtyColors = geometry.__dirtyColors; if ( object.sortParticles ) { - + _projScreenMatrix.multiplySelf( object.globalMatrix ); - + for ( v = 0; v < vl; v++ ) { vertex = vertices[ v ].position; - + _vector3.copy( vertex ); _projScreenMatrix.multiplyVector3( _vector3 ); - + sortArray[ v ] = [ _vector3.z, v ]; - + } - + sortArray.sort( function(a,b) { return b[0] - a[0]; } ); - + for ( v = 0; v < vl; v++ ) { - + vertex = vertices[ sortArray[v][1] ].position; - + offset = v * 3; - + vertexArray[ offset ] = vertex.x; vertexArray[ offset + 1 ] = vertex.y; vertexArray[ offset + 2 ] = vertex.z; - + } - + for ( c = 0; c < cl; c++ ) { - + offset = c * 3; - + color = colors[ sortArray[c][1] ]; colorArray[ offset ] = color.r; colorArray[ offset + 1 ] = color.g; colorArray[ offset + 2 ] = color.b; - + } - - + + } else { - + if ( dirtyVertices ) { for ( v = 0; v < vl; v++ ) { @@ -1188,9 +1188,9 @@ THREE.WebGLRenderer = function ( parameters ) { } } - + if ( dirtyColors ) { - + for ( c = 0; c < cl; c++ ) { color = colors[ c ]; @@ -1202,25 +1202,25 @@ THREE.WebGLRenderer = function ( parameters ) { colorArray[ offset + 2 ] = color.b; } - + } } - + if ( dirtyVertices || object.sortParticles ) { - + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webGLVertexBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, vertexArray, hint ); - + } - + if ( dirtyColors || object.sortParticles ) { - + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webGLColorBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, colorArray, hint ); - + } - + }; function setMaterialShaders( material, shaders ) { @@ -1241,7 +1241,7 @@ THREE.WebGLRenderer = function ( parameters ) { uniforms.opacity.value = material.opacity; uniforms.map.texture = material.map; - + uniforms.light_map.texture = material.light_map; uniforms.env_map.texture = material.env_map; @@ -1267,9 +1267,9 @@ THREE.WebGLRenderer = function ( parameters ) { uniforms.map.texture = material.map; }; - + function refreshUniformsFog( uniforms, fog ) { - + uniforms.fogColor.value.setHex( fog.color.hex ); if ( fog instanceof THREE.Fog ) { @@ -1282,7 +1282,7 @@ THREE.WebGLRenderer = function ( parameters ) { uniforms.fogDensity.value = fog.density; } - + }; function refreshUniformsPhong( uniforms, material ) { @@ -1310,7 +1310,7 @@ THREE.WebGLRenderer = function ( parameters ) { this.initMaterial = function( material, lights, fog ) { var u, identifiers, parameters, maxLightCount; - + if ( material instanceof THREE.MeshDepthMaterial ) { setMaterialShaders( material, THREE.ShaderLib[ 'depth' ] ); @@ -1336,9 +1336,9 @@ THREE.WebGLRenderer = function ( parameters ) { setMaterialShaders( material, THREE.ShaderLib[ 'basic' ] ); } else if ( material instanceof THREE.ParticleBasicMaterial ) { - + setMaterialShaders( material, THREE.ShaderLib[ 'particle_basic' ] ); - + } // heuristics to create shader parameters according to lights in the scene @@ -1349,10 +1349,10 @@ THREE.WebGLRenderer = function ( parameters ) { parameters = { fog: fog, map: material.map, env_map: material.env_map, light_map: material.light_map, vertex_colors: material.vertex_colors, skinning: material.skinning, maxDirLights: maxLightCount.directional, maxPointLights: maxLightCount.point }; - + material.program = buildProgram( material.fragment_shader, material.vertex_shader, parameters ); - identifiers = [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition', + identifiers = [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition', 'cameraInverseMatrix', 'uBoneGlobalMatrices' ]; for( u in material.uniforms ) { @@ -1362,35 +1362,35 @@ THREE.WebGLRenderer = function ( parameters ) { } cacheUniformLocations( material.program, identifiers ); - cacheAttributeLocations( material.program, [ "position", "normal", "uv", "uv2", "tangent", "color", + cacheAttributeLocations( material.program, [ "position", "normal", "uv", "uv2", "tangent", "color", "skinVertexA", "skinVertexB", "skinIndex", "skinWeight" ] ); - + var attributes = material.program.attributes; - + _gl.enableVertexAttribArray( attributes.position ); - + if ( attributes.color >= 0 ) _gl.enableVertexAttribArray( attributes.color ); - if ( attributes.normal >= 0 ) _gl.enableVertexAttribArray( attributes.normal ); + if ( attributes.normal >= 0 ) _gl.enableVertexAttribArray( attributes.normal ); if ( attributes.tangent >= 0 ) _gl.enableVertexAttribArray( attributes.tangent ); - - if ( material.skinning && - attributes.skinVertexA >=0 && attributes.skinVertexB >= 0 && + + if ( material.skinning && + attributes.skinVertexA >=0 && attributes.skinVertexB >= 0 && attributes.skinIndex >= 0 && attributes.skinWeight >= 0 ) { - + _gl.enableVertexAttribArray( attributes.skinVertexA ); _gl.enableVertexAttribArray( attributes.skinVertexB ); _gl.enableVertexAttribArray( attributes.skinIndex ); _gl.enableVertexAttribArray( attributes.skinWeight ); - + } }; - + function setProgram ( camera, lights, fog, material, object ) { - + if ( !material.program ) _this.initMaterial( material, lights, fog ); - var program = material.program, + var program = material.program, p_uniforms = program.uniforms, m_uniforms = material.uniforms; @@ -1398,24 +1398,24 @@ THREE.WebGLRenderer = function ( parameters ) { _gl.useProgram( program ); _oldProgram = program; - + _gl.uniformMatrix4fv( p_uniforms.projectionMatrix, false, _projectionMatrixArray ); } - + // refresh uniforms common to several materials - - if ( fog && ( + + if ( fog && ( material instanceof THREE.MeshBasicMaterial || material instanceof THREE.MeshLambertMaterial || material instanceof THREE.MeshPhongMaterial || material instanceof THREE.LineBasicMaterial || material instanceof THREE.ParticleBasicMaterial ) ) { - + refreshUniformsFog( m_uniforms, fog ); - - } + + } if ( material instanceof THREE.MeshPhongMaterial || material instanceof THREE.MeshLambertMaterial ) { @@ -1434,15 +1434,15 @@ THREE.WebGLRenderer = function ( parameters ) { } // refresh single material specific uniforms - + if ( material instanceof THREE.LineBasicMaterial ) { refreshUniformsLine( m_uniforms, material ); - + } else if ( material instanceof THREE.ParticleBasicMaterial ) { refreshUniformsParticle( m_uniforms, material ); - + } else if ( material instanceof THREE.MeshPhongMaterial ) { refreshUniformsPhong( m_uniforms, material ); @@ -1452,35 +1452,35 @@ THREE.WebGLRenderer = function ( parameters ) { m_uniforms.mNear.value = camera.zNear; m_uniforms.mFar.value = camera.zFar; m_uniforms.opacity.value = material.opacity; - + } else if ( material instanceof THREE.MeshNormalMaterial ) { m_uniforms.opacity.value = material.opacity; - + } - + // load common uniforms - + loadUniformsGeneric( program, m_uniforms ); loadUniformsMatrices( p_uniforms, object ); // load material specific uniforms // (shader material also gets them for the sake of genericity) - + if ( material instanceof THREE.MeshShaderMaterial || material instanceof THREE.MeshPhongMaterial || material.env_map ) { - + _gl.uniform3f( p_uniforms.cameraPosition, camera.position.x, camera.position.y, camera.position.z ); - + } - + if ( material instanceof THREE.MeshShaderMaterial || material.env_map || material.skinning ) { - + _gl.uniformMatrix4fv( p_uniforms.objectMatrix, false, object._objectMatrixArray ); - + } if ( material instanceof THREE.MeshPhongMaterial || @@ -1489,25 +1489,25 @@ THREE.WebGLRenderer = function ( parameters ) { material.skinning ) { _gl.uniformMatrix4fv( p_uniforms.viewMatrix, false, _viewMatrixArray ); - + } - + if ( material.skinning ) { - + loadUniformsSkinning( p_uniforms, object ); - + } - + return program; - + }; - + function renderBuffer( camera, lights, fog, material, geometryChunk, object ) { var program, attributes, linewidth, primitives; program = setProgram( camera, lights, fog, material, object ); - + attributes = program.attributes; // vertices @@ -1520,7 +1520,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( attributes.color >= 0 ) { _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLColorBuffer ); - _gl.vertexAttribPointer( attributes.color, 3, _gl.FLOAT, false, 0, 0 ); + _gl.vertexAttribPointer( attributes.color, 3, _gl.FLOAT, false, 0, 0 ); } @@ -1529,7 +1529,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( attributes.normal >= 0 ) { _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLNormalBuffer ); - _gl.vertexAttribPointer( attributes.normal, 3, _gl.FLOAT, false, 0, 0 ); + _gl.vertexAttribPointer( attributes.normal, 3, _gl.FLOAT, false, 0, 0 ); } @@ -1578,10 +1578,10 @@ THREE.WebGLRenderer = function ( parameters ) { } - if ( material.skinning && - attributes.skinVertexA >=0 && attributes.skinVertexB >= 0 && + if ( material.skinning && + attributes.skinVertexA >=0 && attributes.skinVertexB >= 0 && attributes.skinIndex >= 0 && attributes.skinWeight >= 0 ) { - + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLSkinVertexABuffer ); _gl.vertexAttribPointer( attributes.skinVertexA, 4, _gl.FLOAT, false, 0, 0 ); @@ -1593,104 +1593,104 @@ THREE.WebGLRenderer = function ( parameters ) { _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLSkinWeightsBuffer ); _gl.vertexAttribPointer( attributes.skinWeight, 4, _gl.FLOAT, false, 0, 0 ); - + } - + // render mesh if ( object instanceof THREE.Mesh ) { // wireframe - + if ( material.wireframe ) { _gl.lineWidth( material.wireframe_linewidth ); _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLLineBuffer ); _gl.drawElements( _gl.LINES, geometryChunk.__webGLLineCount, _gl.UNSIGNED_SHORT, 0 ); - + // triangles - + } else { - + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLFaceBuffer ); _gl.drawElements( _gl.TRIANGLES, geometryChunk.__webGLFaceCount, _gl.UNSIGNED_SHORT, 0 ); - + } - + // render lines - + } else if ( object instanceof THREE.Line ) { - + primitives = ( object.type == THREE.LineStrip ) ? _gl.LINE_STRIP : _gl.LINES; _gl.lineWidth( material.linewidth ); _gl.drawArrays( primitives, 0, geometryChunk.__webGLLineCount ); - + // render particles - + } else if ( object instanceof THREE.ParticleSystem ) { - + _gl.drawArrays( _gl.POINTS, 0, geometryChunk.__webGLParticleCount ); - + // render ribbon - + } else if ( object instanceof THREE.Ribbon ) { - + _gl.drawArrays( _gl.TRIANGLE_STRIP, 0, geometryChunk.__webGLVertexCount ); - + } }; function renderBufferImmediate( object, program ) { - + if ( ! object.__webGLVertexBuffer ) object.__webGLVertexBuffer = _gl.createBuffer(); if ( ! object.__webGLNormalBuffer ) object.__webGLNormalBuffer = _gl.createBuffer(); - + if ( object.hasPos ) { - + _gl.bindBuffer( _gl.ARRAY_BUFFER, object.__webGLVertexBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, object.positionArray, _gl.DYNAMIC_DRAW ); _gl.enableVertexAttribArray( program.attributes.position ); _gl.vertexAttribPointer( program.attributes.position, 3, _gl.FLOAT, false, 0, 0 ); - + } - + if ( object.hasNormal ) { - + _gl.bindBuffer( _gl.ARRAY_BUFFER, object.__webGLNormalBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, object.normalArray, _gl.DYNAMIC_DRAW ); _gl.enableVertexAttribArray( program.attributes.normal ); _gl.vertexAttribPointer( program.attributes.normal, 3, _gl.FLOAT, false, 0, 0 ); - + } - + _gl.drawArrays( _gl.TRIANGLES, 0, object.count ); - + object.count = 0; - + }; - + function setObjectFaces( object ) { - + if ( _oldDoubleSided != object.doubleSided ) { - + if( object.doubleSided ) { - + _gl.disable( _gl.CULL_FACE ); } else { _gl.enable( _gl.CULL_FACE ); - + } - + _oldDoubleSided = object.doubleSided; - + } - + if ( _oldFlipSided != object.flipSided ) { - + if( object.flipSided ) { _gl.frontFace( _gl.CW ); @@ -1700,33 +1700,33 @@ THREE.WebGLRenderer = function ( parameters ) { _gl.frontFace( _gl.CCW ); } - + _oldFlipSided = object.flipSided; } - + }; - + function setDepthTest( test ) { - + if ( _oldDepth != test ) { if( test ) { - + _gl.enable( _gl.DEPTH_TEST ); - + } else { - + _gl.disable( _gl.DEPTH_TEST ); - + } - + _oldDepth = test; } - + }; - + function computeFrustum( m ) { _frustum[ 0 ].set( m.n41 - m.n11, m.n42 - m.n12, m.n43 - m.n13, m.n44 - m.n14 ); @@ -1737,7 +1737,7 @@ THREE.WebGLRenderer = function ( parameters ) { _frustum[ 5 ].set( m.n41 + m.n31, m.n42 + m.n32, m.n43 + m.n33, m.n44 + m.n34 ); var i, plane; - + for ( i = 0; i < 5; i ++ ) { plane = _frustum[ i ]; @@ -1746,7 +1746,7 @@ THREE.WebGLRenderer = function ( parameters ) { } }; - + function isInFrustum( object ) { var distance, matrix = object.globalMatrix, @@ -1764,14 +1764,14 @@ THREE.WebGLRenderer = function ( parameters ) { }; function addToFixedArray( where, what ) { - + where.list[ where.count ] = what; where.count += 1; - + }; - + function unrollImmediateBufferMaterials( globject ) { - + var i, l, m, ml, material, object = globject.object, opaque = globject.opaque, @@ -1779,22 +1779,22 @@ THREE.WebGLRenderer = function ( parameters ) { transparent.count = 0; opaque.count = 0; - + for ( m = 0, ml = object.materials.length; m < ml; m++ ) { material = object.materials[ m ]; - + if ( ( material.opacity && material.opacity < 1.0 ) || material.blending != THREE.NormalBlending ) addToFixedArray( transparent, material ); else addToFixedArray( opaque, material ); - + } - + }; - + function unrollBufferMaterials( globject ) { - + var i, l, m, ml, material, meshMaterial, object = globject.object, buffer = globject.buffer, @@ -1803,7 +1803,7 @@ THREE.WebGLRenderer = function ( parameters ) { transparent.count = 0; opaque.count = 0; - + for ( m = 0, ml = object.materials.length; m < ml; m++ ) { meshMaterial = object.materials[ m ]; @@ -1813,14 +1813,14 @@ THREE.WebGLRenderer = function ( parameters ) { for ( i = 0, l = buffer.materials.length; i < l; i++ ) { material = buffer.materials[ i ]; - + if ( material ) { - + if ( ( material.opacity && material.opacity < 1.0 ) || material.blending != THREE.NormalBlending ) addToFixedArray( transparent, material ); else addToFixedArray( opaque, material ); - + } } @@ -1828,7 +1828,7 @@ THREE.WebGLRenderer = function ( parameters ) { } else { material = meshMaterial; - + if ( ( material.opacity && material.opacity < 1.0 ) || material.blending != THREE.NormalBlending ) addToFixedArray( transparent, material ); else @@ -1837,37 +1837,37 @@ THREE.WebGLRenderer = function ( parameters ) { } } - + }; - - + + function painterSort( a, b ) { return b.z - a.z; }; - + this.render = function( scene, camera, renderTarget, clear ) { - + var i, program, opaque, transparent, material, o, ol, oil, webGLObject, object, buffer, lights = scene.lights, fog = scene.fog, ol; - - camera.autoUpdateMatrix && camera.update(); - + + camera.matrixAutoUpdate && camera.update(); + camera.globalMatrix.flattenToArray( _viewMatrixArray ); camera.projectionMatrix.flattenToArray( _projectionMatrixArray ); camera.inverseMatrix.flattenToArray( _cameraInverseMatrixArray ); _projScreenMatrix.multiply( camera.projectionMatrix, camera.globalMatrix ); computeFrustum( _projScreenMatrix ); - + if( THREE.AnimationHandler ) THREE.AnimationHandler.update(); - + scene.update( undefined, false, camera ); - + this.initWebGLObjects( scene, camera ); setRenderTarget( renderTarget, clear !== undefined ? clear : true ); @@ -1879,101 +1879,101 @@ THREE.WebGLRenderer = function ( parameters ) { } // set matrices - + ol = scene.__webGLObjects.length; - + for ( o = 0; o < ol; o++ ) { webGLObject = scene.__webGLObjects[ o ]; object = webGLObject.object; - if ( object.visible ) { + if ( object.visible ) { if ( ! ( object instanceof THREE.Mesh ) || isInFrustum( object ) ) { - + object.globalMatrix.flattenToArray( object._objectMatrixArray ); - + setupMatrices( object, camera ); - + unrollBufferMaterials( webGLObject ); - + webGLObject.render = true; - + if ( this.sortObjects ) { - + _vector3.copy( object.position ); _projScreenMatrix.multiplyVector3( _vector3 ); webGLObject.z = _vector3.z; - + } - + } else { - + webGLObject.render = false; - + } - + } else { - + webGLObject.render = false; } - + } - + if ( this.sortObjects ) { - + scene.__webGLObjects.sort( painterSort ); - + } - + oil = scene.__webGLObjectsImmediate.length; - + for ( o = 0; o < oil; o++ ) { - + webGLObject = scene.__webGLObjectsImmediate[ o ]; object = webGLObject.object; - + if ( object.visible ) { - - if( object.autoUpdateMatrix ) { - + + if( object.matrixAutoUpdate ) { + object.globalMatrix.flattenToArray( object._objectMatrixArray ); - + } - + setupMatrices( object, camera ); - + unrollImmediateBufferMaterials( webGLObject ); - + } - + } // opaque pass setBlending( THREE.NormalBlending ); - + for ( o = 0; o < ol; o++ ) { webGLObject = scene.__webGLObjects[ o ]; if ( webGLObject.render ) { - + object = webGLObject.object; buffer = webGLObject.buffer; opaque = webGLObject.opaque; - + setObjectFaces( object ); - + for( i = 0; i < opaque.count; i++ ) { - + material = opaque.list[ i ]; - + setDepthTest( material.depth_test ); renderBuffer( camera, lights, fog, material, buffer, object ); - + } } @@ -1981,31 +1981,31 @@ THREE.WebGLRenderer = function ( parameters ) { } // opaque pass (immediate simulator) - + for ( o = 0; o < oil; o++ ) { - + webGLObject = scene.__webGLObjectsImmediate[ o ]; object = webGLObject.object; - + if ( object.visible ) { - + opaque = webGLObject.opaque; - + setObjectFaces( object ); - + for( i = 0; i < opaque.count; i++ ) { - + material = opaque.list[ i ]; - + setDepthTest( material.depth_test ); - + program = setProgram( camera, lights, fog, material, object ); object.render( function( object ) { renderBufferImmediate( object, program ); } ); - + } - + } - + } // transparent pass @@ -2015,22 +2015,22 @@ THREE.WebGLRenderer = function ( parameters ) { webGLObject = scene.__webGLObjects[ o ]; if ( webGLObject.render ) { - + object = webGLObject.object; buffer = webGLObject.buffer; transparent = webGLObject.transparent; - + setObjectFaces( object ); - + for( i = 0; i < transparent.count; i++ ) { - + material = transparent.list[ i ]; - + setBlending( material.blending ); setDepthTest( material.depth_test ); - + renderBuffer( camera, lights, fog, material, buffer, object ); - + } } @@ -2038,34 +2038,34 @@ THREE.WebGLRenderer = function ( parameters ) { } // transparent pass (immediate simulator) - + for ( o = 0; o < oil; o++ ) { - + webGLObject = scene.__webGLObjectsImmediate[ o ]; object = webGLObject.object; - + if ( object.visible ) { - + transparent = webGLObject.transparent; - + setObjectFaces( object ); - + for( i = 0; i < transparent.count; i++ ) { - + material = transparent.list[ i ]; - + setBlending( material.blending ); setDepthTest( material.depth_test ); - + program = setProgram( camera, lights, fog, material, object ); object.render( function( object ) { renderBufferImmediate( object, program ); } ); - + } - + } - + } - + // Generate mipmap if we're using any kind of mipmap filtering if ( renderTarget && renderTarget.min_filter !== THREE.NearestFilter && renderTarget.min_filter !== THREE.LinearFilter ) { @@ -2077,21 +2077,21 @@ THREE.WebGLRenderer = function ( parameters ) { }; function addObject( scene, object ) { - + var g, geometry, geometryChunk, objmap; - + geometry = object.geometry; - + if ( scene.__webGLObjectsMap[ object.id ] == undefined ) { scene.__webGLObjectsMap[ object.id ] = {}; - + object._modelViewMatrix = new THREE.Matrix4(); - + object._normalMatrixArray = new Float32Array( 9 ); object._modelViewMatrixArray = new Float32Array( 16 ); object._objectMatrixArray = new Float32Array( 16 ); - + object.globalMatrix.flattenToArray( object._objectMatrixArray ); } @@ -2123,8 +2123,8 @@ THREE.WebGLRenderer = function ( parameters ) { } - if( geometry.__dirtyVertices || geometry.__dirtyElements || - geometry.__dirtyUvs || geometry.__dirtyNormals || + if( geometry.__dirtyVertices || geometry.__dirtyElements || + geometry.__dirtyUvs || geometry.__dirtyNormals || geometry.__dirtyColors || geometry.__dirtyTangents ) { setMeshBuffers( geometryChunk, object, _gl.DYNAMIC_DRAW ); @@ -2166,7 +2166,7 @@ THREE.WebGLRenderer = function ( parameters ) { geometry.__dirtyVertices = false; geometry.__dirtyColors = false; - + } else if ( object instanceof THREE.Line ) { if( ! geometry.__webGLVertexBuffer ) { @@ -2199,7 +2199,7 @@ THREE.WebGLRenderer = function ( parameters ) { geometry.__dirtyVertices = true; geometry.__dirtyColors = true; - + } if( geometry.__dirtyVertices || geometry.__dirtyColors || object.sortParticles ) { @@ -2214,24 +2214,24 @@ THREE.WebGLRenderer = function ( parameters ) { geometry.__dirtyColors = false; } else if ( object instanceof THREE.MarchingCubes ) { - + add_buffer_immediate( scene.__webGLObjectsImmediate, objmap, 0, object ); - + }/*else if ( object instanceof THREE.Particle ) { }*/ - + }; function add_buffer( objlist, objmap, id, buffer, object ) { if ( objmap[ id ] == undefined ) { - objlist.push( { buffer: buffer, object: object, - opaque: { list: [], count: 0 }, + objlist.push( { buffer: buffer, object: object, + opaque: { list: [], count: 0 }, transparent: { list: [], count: 0 } } ); - + objmap[ id ] = 1; } @@ -2242,17 +2242,17 @@ THREE.WebGLRenderer = function ( parameters ) { if ( objmap[ id ] == undefined ) { - objlist.push( { object: object, - opaque: { list: [], count: 0 }, + objlist.push( { object: object, + opaque: { list: [], count: 0 }, transparent: { list: [], count: 0 } } ); - + objmap[ id ] = 1; } }; - + this.initWebGLObjects = function( scene, camera ) { var o, ol, object; @@ -2265,13 +2265,13 @@ THREE.WebGLRenderer = function ( parameters ) { scene.__webGLObjectsImmediate = []; } - + for ( o = 0, ol = scene.objects.length; o < ol; o++ ) { object = scene.objects[ o ]; addObject( scene, object ); - + } }; @@ -2293,7 +2293,7 @@ THREE.WebGLRenderer = function ( parameters ) { } }; - + function setupMatrices ( object, camera ) { object._modelViewMatrix.multiplyToArray( camera.globalMatrix, object.globalMatrix, object._modelViewMatrixArray ); @@ -2379,7 +2379,7 @@ THREE.WebGLRenderer = function ( parameters ) { _gl.enable( _gl.BLEND ); _gl.blendFunc( _gl.ONE, _gl.ONE_MINUS_SRC_ALPHA ); _gl.clearColor( clearColor.r, clearColor.g, clearColor.b, clearAlpha ); - + _cullEnabled = true; }; @@ -2435,7 +2435,7 @@ THREE.WebGLRenderer = function ( parameters ) { "attribute vec3 color;", "attribute vec2 uv;", "attribute vec2 uv2;", - + "attribute vec4 skinVertexA;", "attribute vec4 skinVertexB;", "attribute vec4 skinIndex;", @@ -2457,7 +2457,7 @@ THREE.WebGLRenderer = function ( parameters ) { //console.log( prefix_vertex + vertex_shader ); } - + //console.log( prefix_fragment + fragment_shader ); //console.log( prefix_vertex + vertex_shader ); @@ -2469,30 +2469,30 @@ THREE.WebGLRenderer = function ( parameters ) { }; function loadUniformsSkinning( uniforms, object ) { - + _gl.uniformMatrix4fv( uniforms.cameraInverseMatrix, false, _cameraInverseMatrixArray ); - + /* var i, l = object.boneMatrices.length; - + for( i = 0; i < l; i++ ) { - + //_gl.uniformMatrix4fv( uniforms[ "uBoneGlobalMatrices[" + i + "]" ], false, object.boneMatrices[ i ]() ); _gl.uniformMatrix4fv( uniforms[ "uBoneGlobalMatrices[" + i + "]" ], false, object.boneMatrices[ i ] ); - + } */ _gl.uniformMatrix4fv( uniforms[ "uBoneGlobalMatrices" ], false, object.boneMatrices ); - + }; - + function loadUniformsMatrices( uniforms, object ) { - + _gl.uniformMatrix4fv( uniforms.modelViewMatrix, false, object._modelViewMatrixArray ); _gl.uniformMatrix3fv( uniforms.normalMatrix, false, object._normalMatrixArray ); }; - + function loadUniformsGeneric( program, uniforms ) { var u, uniform, value, type, location, texture; @@ -2562,7 +2562,7 @@ THREE.WebGLRenderer = function ( parameters ) { function setBlending( blending ) { if ( blending != _oldBlending ) { - + switch ( blending ) { case THREE.AdditiveBlending: @@ -2592,15 +2592,15 @@ THREE.WebGLRenderer = function ( parameters ) { _gl.blendFunc( _gl.ONE, _gl.ONE_MINUS_SRC_ALPHA ); break; - + } - + _oldBlending = blending; - + } }; - + function setCubeTexture( texture, slot ) { if ( texture.image.length == 6 ) { @@ -2942,7 +2942,7 @@ THREE.WebGLRenderer = function ( parameters ) { THREE.Snippets = { // FOG - + fog_pars_fragment: [ "#ifdef USE_FOG", @@ -2981,7 +2981,7 @@ THREE.Snippets = { ].join("\n"), // ENVIRONMENT MAP - + envmap_pars_fragment: [ "#ifdef USE_ENVMAP", @@ -3048,7 +3048,7 @@ THREE.Snippets = { "#endif" ].join("\n"), - + // COLOR MAP (particles) map_particle_pars_fragment: [ @@ -3116,7 +3116,7 @@ THREE.Snippets = { ].join("\n"), // LIGHT MAP - + lightmap_pars_fragment: [ "#ifdef USE_LIGHTMAP", @@ -3127,7 +3127,7 @@ THREE.Snippets = { "#endif" ].join("\n"), - + lightmap_pars_vertex: [ "#ifdef USE_LIGHTMAP", @@ -3137,7 +3137,7 @@ THREE.Snippets = { "#endif" ].join("\n"), - + lightmap_fragment: [ "#ifdef USE_LIGHTMAP", @@ -3147,7 +3147,7 @@ THREE.Snippets = { "#endif" ].join("\n"), - + lightmap_vertex: [ "#ifdef USE_LIGHTMAP", @@ -3184,7 +3184,7 @@ THREE.Snippets = { ].join("\n"), // LIGHTS - + lights_vertex: [ "if ( !enableLighting ) {", @@ -3247,7 +3247,7 @@ THREE.Snippets = { "vec3 normal = normalize( vNormal );", "vec3 viewPosition = normalize( vViewPosition );", - + "vec4 mColor = vec4( diffuse, opacity );", "vec4 mSpecular = vec4( specular, opacity );", @@ -3311,11 +3311,11 @@ THREE.Snippets = { "#if MAX_POINT_LIGHTS > 0", "totalLight += pointDiffuse + pointSpecular;", "#endif", - + "gl_FragColor = gl_FragColor * totalLight;" ].join("\n"), - + // VERTEX COLORS color_pars_fragment: [ @@ -3338,7 +3338,7 @@ THREE.Snippets = { "#endif" ].join("\n"), - + color_pars_vertex: [ "#ifdef USE_COLOR", @@ -3359,37 +3359,37 @@ THREE.Snippets = { "#endif" ].join("\n"), - + // skinning - + skinning_pars_vertex: [ - + "#ifdef USE_SKINNING", - + "uniform mat4 uBoneGlobalMatrices[20];", - + "#endif" - + ].join("\n"), - + skinning_vertex: [ - + "#ifdef USE_SKINNING", "gl_Position = ( uBoneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;", "gl_Position += ( uBoneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;", - + // this doesn't work, no idea why //"gl_Position = projectionMatrix * cameraInverseMatrix * objectMatrix * gl_Position;", - + "gl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;", - + "#else", - + "gl_Position = projectionMatrix * mvPosition;", - + "#endif" - + ].join("\n") }; @@ -3439,9 +3439,9 @@ THREE.UniformsLib = { "fogNear" : { type: "f", value: 1 }, "fogFar" : { type: "f", value: 2000 }, "fogColor" : { type: "c", value: new THREE.Color( 0xffffff ) } - + } - + }; THREE.ShaderLib = { @@ -3533,7 +3533,7 @@ THREE.ShaderLib = { "void main() {", "gl_FragColor = vec4( diffuse, opacity );", - + THREE.Snippets[ "map_fragment" ], THREE.Snippets[ "lightmap_fragment" ], THREE.Snippets[ "color_fragment" ], @@ -3578,7 +3578,7 @@ THREE.ShaderLib = { "uniform vec3 diffuse;", "uniform float opacity;", - "varying vec3 vLightWeighting;", + "varying vec3 vLightWeighting;", THREE.Snippets[ "color_pars_fragment" ], THREE.Snippets[ "map_pars_fragment" ], @@ -3718,7 +3718,7 @@ THREE.ShaderLib = { ].join("\n") }, - + 'particle_basic': { uniforms: THREE.UniformsLib[ "particle" ], @@ -3747,13 +3747,13 @@ THREE.ShaderLib = { vertex_shader: [ "uniform float size;", - + THREE.Snippets[ "color_pars_vertex" ], - + "void main() {", THREE.Snippets[ "color_vertex" ], - + "vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );", "gl_Position = projectionMatrix * mvPosition;", @@ -3765,6 +3765,6 @@ THREE.ShaderLib = { ].join("\n") } - -}; \ No newline at end of file + +}; diff --git a/src/renderers/WebGLRenderer2.js b/src/renderers/WebGLRenderer2.js index ed2eeb52..60b357d3 100644 --- a/src/renderers/WebGLRenderer2.js +++ b/src/renderers/WebGLRenderer2.js @@ -97,7 +97,7 @@ THREE.WebGLRenderer2 = function ( antialias ) { this.autoClear && this.clear(); - camera.autoUpdateMatrix && camera.updateMatrix(); + camera.matrixAutoUpdate && camera.updateMatrix(); // Setup camera matrices @@ -127,7 +127,7 @@ THREE.WebGLRenderer2 = function ( antialias ) { var geometry, material, m, ml, program, uniforms, attributes; - object.autoUpdateMatrix && object.updateMatrix(); + object.matrixAutoUpdate && object.updateMatrix(); // Setup object matrices