Explorar o código

Updated builds.

Mr.doob %!s(int64=11) %!d(string=hai) anos
pai
achega
e695691a1b
Modificáronse 2 ficheiros con 20 adicións e 24 borrados
  1. 14 18
      build/three.js
  2. 6 6
      build/three.min.js

+ 14 - 18
build/three.js

@@ -8243,28 +8243,24 @@ THREE.Projector = function () {
 
 		};
 
-		var checkVerticesVisibility = function ( v1, v2, v3 ) {
-
-			return v1.visible === true && v2.visible === true && v3.visible === true;
-
-		};
-
 		var checkTriangleVisibility = function ( v1, v2, v3 ) {
 
+			if ( v1.visible === true || v2.visible === true || v3.visible === true ) return true;
+
 			_points3[ 0 ] = v1.positionScreen;
 			_points3[ 1 ] = v2.positionScreen;
 			_points3[ 2 ] = v3.positionScreen;
 
-			if ( _clipBox.isIntersectionBox( _boundingBox.setFromPoints( _points3 ) ) ) {
+			return _clipBox.isIntersectionBox( _boundingBox.setFromPoints( _points3 ) );
 
-				return ( ( v3.positionScreen.x - v1.positionScreen.x ) *
-					    ( v2.positionScreen.y - v1.positionScreen.y ) -
-					    ( v3.positionScreen.y - v1.positionScreen.y ) *
-					    ( v2.positionScreen.x - v1.positionScreen.x ) ) < 0;
+		};
 
-			}
+		var checkBackfaceCulling = function ( v1, v2, v3 ) {
 
-			return false;
+			return ( ( v3.positionScreen.x - v1.positionScreen.x ) *
+				    ( v2.positionScreen.y - v1.positionScreen.y ) -
+				    ( v3.positionScreen.y - v1.positionScreen.y ) *
+				    ( v2.positionScreen.x - v1.positionScreen.x ) ) < 0;
 
 		};
 
@@ -8292,9 +8288,9 @@ THREE.Projector = function () {
 			var v2 = _vertexPool[ b ];
 			var v3 = _vertexPool[ c ];
 
-			if ( checkVerticesVisibility( v1, v2, v3 ) === false ) return;
+			if ( checkTriangleVisibility( v1, v2, v3 ) === false ) return;
 
-			if ( material.side === THREE.DoubleSide || checkTriangleVisibility( v1, v2, v3 ) === true ) {
+			if ( material.side === THREE.DoubleSide || checkBackfaceCulling( v1, v2, v3 ) === true ) {
 
 				_face = getNextFaceInPool();
 
@@ -8327,8 +8323,8 @@ THREE.Projector = function () {
 		return {
 			setObject: setObject,
 			projectVertex: projectVertex,
-			checkVerticesVisibility: checkVerticesVisibility,
 			checkTriangleVisibility: checkTriangleVisibility,
+			checkBackfaceCulling: checkBackfaceCulling,
 			pushVertex: pushVertex,
 			pushNormal: pushNormal,
 			pushLine: pushLine,
@@ -8518,9 +8514,9 @@ THREE.Projector = function () {
 
 						}
 
-						if ( renderList.checkVerticesVisibility( v1, v2, v3 ) === false ) continue;
+						if ( renderList.checkTriangleVisibility( v1, v2, v3 ) === false ) continue;
 
-						var visible = renderList.checkTriangleVisibility( v1, v2, v3 );
+						var visible = renderList.checkBackfaceCulling( v1, v2, v3 );
 
 						if ( side !== THREE.DoubleSide ) {
 							if ( side === THREE.FrontSide && visible === false ) continue;

+ 6 - 6
build/three.min.js

@@ -168,14 +168,14 @@ if(!0===b)for(var c=0;c<this.children.length;c++)a.add(this.children[c].clone())
 0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(d<c)return!1;a.lerp(b,c);b.lerp(a,1-d);return!0}var f,g,h=[],k=0,l,n,q=[],p=0,r,u,s=[],v=0,w,t,x=[],G=0,F,P,H=[],E=0,K={objects:[],lights:[],elements:[]},z=new THREE.Vector3,y=new THREE.Vector3,I=new THREE.Vector3,C=new THREE.Vector3,N=new THREE.Vector4,A=new THREE.Box3(new THREE.Vector3(-1,-1,-1),new THREE.Vector3(1,1,1)),M=new THREE.Box3,D=Array(3),J=new THREE.Matrix4,Y=
 new THREE.Matrix4,R,ka=new THREE.Matrix4,ca=new THREE.Matrix3,X=new THREE.Frustum,O=new THREE.Vector4,S=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);Y.multiplyMatrices(b.projectionMatrix,b.matrixWorldInverse);return a.applyProjection(Y)};this.unprojectVector=function(){var a=new THREE.Matrix4;return function(b,c){a.getInverse(c.projectionMatrix);Y.multiplyMatrices(c.matrixWorld,a);return b.applyProjection(Y)}}();this.pickingRay=function(a,b){a.z=
 -1;var c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.sub(a).normalize();return new THREE.Raycaster(a,c)};var ea=function(a){if(!1!==a.visible){if(a instanceof THREE.Light)K.lights.push(a);else if(a instanceof THREE.Mesh||a instanceof THREE.Line||a instanceof THREE.Sprite)if(!1===a.frustumCulled||!0===X.intersectsObject(a)){if(g===k){var b=new THREE.RenderableObject;h.push(b);k++;g++;f=b}else f=h[g++];f.id=a.id;f.object=a;null!==a.renderDepth?f.z=a.renderDepth:
-(C.setFromMatrixPosition(a.matrixWorld),C.applyProjection(Y),f.z=C.z);K.objects.push(f)}for(var b=0,c=a.children.length;b<c;b++)ea(a.children[b])}},B=new function(){var d=[],e=null,f=null,g=new THREE.Matrix3,h=function(a){var b=a.positionWorld,c=a.positionScreen;b.copy(a.position).applyMatrix4(R);c.copy(b).applyMatrix4(Y);b=1/c.w;c.x*=b;c.y*=b;c.z*=b;a.visible=-1<=c.x&&1>=c.x&&-1<=c.y&&1>=c.y&&-1<=c.z&&1>=c.z},k=function(a,b,c){return!0===a.visible&&!0===b.visible&&!0===c.visible},n=function(a,b,
-c){D[0]=a.positionScreen;D[1]=b.positionScreen;D[2]=c.positionScreen;return A.isIntersectionBox(M.setFromPoints(D))?0>(c.positionScreen.x-a.positionScreen.x)*(b.positionScreen.y-a.positionScreen.y)-(c.positionScreen.y-a.positionScreen.y)*(b.positionScreen.x-a.positionScreen.x):!1};return{setObject:function(a){e=a;f=e.material;g.getNormalMatrix(e.matrixWorld);d.length=0},projectVertex:h,checkVerticesVisibility:k,checkTriangleVisibility:n,pushVertex:function(b,c,d){l=a();l.position.set(b,c,d);h(l)},
-pushNormal:function(a,b,c){d.push(a,b,c)},pushLine:function(a,b){var d=q[a],f=q[b];w=c();w.id=e.id;w.v1.copy(d);w.v2.copy(f);w.z=(d.positionScreen.z+f.positionScreen.z)/2;w.material=e.material;K.elements.push(w)},pushTriangle:function(a,c,h){var l=q[a],s=q[c],p=q[h];if(!1!==k(l,s,p)&&(f.side===THREE.DoubleSide||!0===n(l,s,p))){r=b();r.id=e.id;r.v1.copy(l);r.v2.copy(s);r.v3.copy(p);r.z=(l.positionScreen.z+s.positionScreen.z+p.positionScreen.z)/3;for(l=0;3>l;l++)s=3*arguments[l],p=r.vertexNormalsModel[l],
-p.set(d[s+0],d[s+1],d[s+2]),p.applyMatrix3(g).normalize();r.vertexNormalsLength=3;r.material=e.material;K.elements.push(r)}}}};this.projectScene=function(f,h,k,l){var s,p,v,x,G,C,A,D,M;P=t=u=0;K.elements.length=0;!0===f.autoUpdate&&f.updateMatrixWorld();void 0===h.parent&&h.updateMatrixWorld();J.copy(h.matrixWorldInverse.getInverse(h.matrixWorld));Y.multiplyMatrices(h.projectionMatrix,J);X.setFromMatrix(Y);g=0;K.objects.length=0;K.lights.length=0;ea(f);!0===k&&K.objects.sort(d);f=0;for(k=K.objects.length;f<
-k;f++)if(s=K.objects[f].object,p=s.geometry,B.setObject(s),R=s.matrixWorld,n=0,s instanceof THREE.Mesh)if(p instanceof THREE.BufferGeometry){if(C=p.attributes,s=p.offsets,void 0!==C.position){D=C.position.array;p=0;for(x=D.length;p<x;p+=3)B.pushVertex(D[p],D[p+1],D[p+2]);if(void 0!==C.normal)for(M=C.normal.array,p=0,x=M.length;p<x;p+=3)B.pushNormal(M[p],M[p+1],M[p+2]);if(void 0!==C.index)if(C=C.index.array,0<s.length)for(f=0;f<s.length;f++)for(x=s[f],D=x.index,p=x.start,x=x.start+x.count;p<x;p+=3)B.pushTriangle(C[p]+
+(C.setFromMatrixPosition(a.matrixWorld),C.applyProjection(Y),f.z=C.z);K.objects.push(f)}for(var b=0,c=a.children.length;b<c;b++)ea(a.children[b])}},B=new function(){var d=[],e=null,f=null,g=new THREE.Matrix3,h=function(a){var b=a.positionWorld,c=a.positionScreen;b.copy(a.position).applyMatrix4(R);c.copy(b).applyMatrix4(Y);b=1/c.w;c.x*=b;c.y*=b;c.z*=b;a.visible=-1<=c.x&&1>=c.x&&-1<=c.y&&1>=c.y&&-1<=c.z&&1>=c.z},k=function(a,b,c){if(!0===a.visible||!0===b.visible||!0===c.visible)return!0;D[0]=a.positionScreen;
+D[1]=b.positionScreen;D[2]=c.positionScreen;return A.isIntersectionBox(M.setFromPoints(D))},n=function(a,b,c){return 0>(c.positionScreen.x-a.positionScreen.x)*(b.positionScreen.y-a.positionScreen.y)-(c.positionScreen.y-a.positionScreen.y)*(b.positionScreen.x-a.positionScreen.x)};return{setObject:function(a){e=a;f=e.material;g.getNormalMatrix(e.matrixWorld);d.length=0},projectVertex:h,checkTriangleVisibility:k,checkBackfaceCulling:n,pushVertex:function(b,c,d){l=a();l.position.set(b,c,d);h(l)},pushNormal:function(a,
+b,c){d.push(a,b,c)},pushLine:function(a,b){var d=q[a],f=q[b];w=c();w.id=e.id;w.v1.copy(d);w.v2.copy(f);w.z=(d.positionScreen.z+f.positionScreen.z)/2;w.material=e.material;K.elements.push(w)},pushTriangle:function(a,c,h){var l=q[a],s=q[c],p=q[h];if(!1!==k(l,s,p)&&(f.side===THREE.DoubleSide||!0===n(l,s,p))){r=b();r.id=e.id;r.v1.copy(l);r.v2.copy(s);r.v3.copy(p);r.z=(l.positionScreen.z+s.positionScreen.z+p.positionScreen.z)/3;for(l=0;3>l;l++)s=3*arguments[l],p=r.vertexNormalsModel[l],p.set(d[s+0],d[s+
+1],d[s+2]),p.applyMatrix3(g).normalize();r.vertexNormalsLength=3;r.material=e.material;K.elements.push(r)}}}};this.projectScene=function(f,h,k,l){var s,p,v,x,G,C,A,D,M;P=t=u=0;K.elements.length=0;!0===f.autoUpdate&&f.updateMatrixWorld();void 0===h.parent&&h.updateMatrixWorld();J.copy(h.matrixWorldInverse.getInverse(h.matrixWorld));Y.multiplyMatrices(h.projectionMatrix,J);X.setFromMatrix(Y);g=0;K.objects.length=0;K.lights.length=0;ea(f);!0===k&&K.objects.sort(d);f=0;for(k=K.objects.length;f<k;f++)if(s=
+K.objects[f].object,p=s.geometry,B.setObject(s),R=s.matrixWorld,n=0,s instanceof THREE.Mesh)if(p instanceof THREE.BufferGeometry){if(C=p.attributes,s=p.offsets,void 0!==C.position){D=C.position.array;p=0;for(x=D.length;p<x;p+=3)B.pushVertex(D[p],D[p+1],D[p+2]);if(void 0!==C.normal)for(M=C.normal.array,p=0,x=M.length;p<x;p+=3)B.pushNormal(M[p],M[p+1],M[p+2]);if(void 0!==C.index)if(C=C.index.array,0<s.length)for(f=0;f<s.length;f++)for(x=s[f],D=x.index,p=x.start,x=x.start+x.count;p<x;p+=3)B.pushTriangle(C[p]+
 D,C[p+1]+D,C[p+2]+D);else for(p=0,x=C.length;p<x;p+=3)B.pushTriangle(C[p],C[p+1],C[p+2]);else for(p=0,x=D.length/3;p<x;p+=3)B.pushTriangle(p,p+1,p+2)}}else{if(p instanceof THREE.Geometry){v=p.vertices;x=p.faces;C=p.faceVertexUvs;ca.getNormalMatrix(R);D=s.material instanceof THREE.MeshFaceMaterial;M=!0===D?s.material:null;for(var ia=0,za=v.length;ia<za;ia++){var la=v[ia];B.pushVertex(la.x,la.y,la.z)}ia=0;for(za=x.length;ia<za;ia++){v=x[ia];var va=!0===D?M.materials[v.materialIndex]:s.material;if(void 0!==
 va){A=va.side;var la=q[v.a],V=q[v.b],ra=q[v.c];if(!0===va.morphTargets){G=p.morphTargets;var Aa=s.morphTargetInfluences,wa=la.position,ma=V.position,Ea=ra.position;z.set(0,0,0);y.set(0,0,0);I.set(0,0,0);for(var Ka=0,ga=G.length;Ka<ga;Ka++){var na=Aa[Ka];if(0!==na){var Ia=G[Ka].vertices;z.x+=(Ia[v.a].x-wa.x)*na;z.y+=(Ia[v.a].y-wa.y)*na;z.z+=(Ia[v.a].z-wa.z)*na;y.x+=(Ia[v.b].x-ma.x)*na;y.y+=(Ia[v.b].y-ma.y)*na;y.z+=(Ia[v.b].z-ma.z)*na;I.x+=(Ia[v.c].x-Ea.x)*na;I.y+=(Ia[v.c].y-Ea.y)*na;I.z+=(Ia[v.c].z-
-Ea.z)*na}}la.position.add(z);V.position.add(y);ra.position.add(I);B.projectVertex(la);B.projectVertex(V);B.projectVertex(ra)}if(!1!==B.checkVerticesVisibility(la,V,ra)){Aa=B.checkTriangleVisibility(la,V,ra);if(A!==THREE.DoubleSide){if(A===THREE.FrontSide&&!1===Aa)continue;if(A===THREE.BackSide&&!0===Aa)continue}r=b();r.id=s.id;r.v1.copy(la);r.v2.copy(V);r.v3.copy(ra);r.normalModel.copy(v.normal);!1!==Aa||A!==THREE.BackSide&&A!==THREE.DoubleSide||r.normalModel.negate();r.normalModel.applyMatrix3(ca).normalize();
+Ea.z)*na}}la.position.add(z);V.position.add(y);ra.position.add(I);B.projectVertex(la);B.projectVertex(V);B.projectVertex(ra)}if(!1!==B.checkTriangleVisibility(la,V,ra)){Aa=B.checkBackfaceCulling(la,V,ra);if(A!==THREE.DoubleSide){if(A===THREE.FrontSide&&!1===Aa)continue;if(A===THREE.BackSide&&!0===Aa)continue}r=b();r.id=s.id;r.v1.copy(la);r.v2.copy(V);r.v3.copy(ra);r.normalModel.copy(v.normal);!1!==Aa||A!==THREE.BackSide&&A!==THREE.DoubleSide||r.normalModel.negate();r.normalModel.applyMatrix3(ca).normalize();
 G=v.vertexNormals;wa=0;for(ma=Math.min(G.length,3);wa<ma;wa++)Ea=r.vertexNormalsModel[wa],Ea.copy(G[wa]),!1!==Aa||A!==THREE.BackSide&&A!==THREE.DoubleSide||Ea.negate(),Ea.applyMatrix3(ca).normalize();r.vertexNormalsLength=G.length;G=0;for(Aa=Math.min(C.length,3);G<Aa;G++)if(A=C[G][ia],void 0!==A)for(wa=0,ma=A.length;wa<ma;wa++)r.uvs[G][wa]=A[wa];r.color=v.color;r.material=va;r.z=(la.positionScreen.z+V.positionScreen.z+ra.positionScreen.z)/3;K.elements.push(r)}}}}}else if(s instanceof THREE.Line)if(p instanceof
 THREE.BufferGeometry){if(C=p.attributes,void 0!==C.position){D=C.position.array;p=0;for(x=D.length;p<x;p+=3)B.pushVertex(D[p],D[p+1],D[p+2]);if(void 0!==C.index)for(C=C.index.array,p=0,x=C.length;p<x;p+=2)B.pushLine(C[p],C[p+1]);else for(p=0,x=D.length/3-1;p<x;p++)B.pushLine(p,p+1)}}else{if(p instanceof THREE.Geometry&&(ka.multiplyMatrices(Y,R),v=s.geometry.vertices,0!==v.length))for(la=a(),la.positionScreen.copy(v[0]).applyMatrix4(ka),p=s.type===THREE.LinePieces?2:1,ia=1,za=v.length;ia<za;ia++)la=
 a(),la.positionScreen.copy(v[ia]).applyMatrix4(ka),0<(ia+1)%p||(V=q[n-2],O.copy(la.positionScreen),S.copy(V.positionScreen),!0===e(O,S)&&(O.multiplyScalar(1/O.w),S.multiplyScalar(1/S.w),w=c(),w.id=s.id,w.v1.positionScreen.copy(O),w.v2.positionScreen.copy(S),w.z=Math.max(O.z,S.z),w.material=s.material,s.material.vertexColors===THREE.VertexColors&&(w.vertexColors[0].copy(s.geometry.colors[ia]),w.vertexColors[1].copy(s.geometry.colors[ia-1])),K.elements.push(w)))}else s instanceof THREE.Sprite&&(N.set(R.elements[12],