提交 07d57df5 编写于 作者: A alteredq

Transplanted Geometry.computeBoundingSphere optimization to BufferGeometry.computeBoundingSphere.

上级 a85e59ed
...@@ -519,7 +519,7 @@ G=void 0,A=void 0,w=void 0,C=void 0,u=n[s[p]].x,t=n[s[p]].y,z=n[s[r]].x,D=n[s[r] ...@@ -519,7 +519,7 @@ G=void 0,A=void 0,w=void 0,C=void 0,u=n[s[p]].x,t=n[s[p]].y,z=n[s[r]].x,D=n[s[r]
a[g[i]],a[g[m]]]);h.push([g[j],g[i],g[m]]);j=i;for(m=i+1;m<e;j++,m++)g[j]=g[m];e--;l=2*e}}return d?h:f};a.Triangulate.area=b;return a})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};THREE.BufferGeometry=function(){this.id=THREE.GeometryCount++;this.attributes={};this.dynamic=false;this.boundingSphere=this.boundingBox=null;this.hasTangents=false;this.morphTargets=[]}; a[g[i]],a[g[m]]]);h.push([g[j],g[i],g[m]]);j=i;for(m=i+1;m<e;j++,m++)g[j]=g[m];e--;l=2*e}}return d?h:f};a.Triangulate.area=b;return a})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};THREE.BufferGeometry=function(){this.id=THREE.GeometryCount++;this.attributes={};this.dynamic=false;this.boundingSphere=this.boundingBox=null;this.hasTangents=false;this.morphTargets=[]};
THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,applyMatrix:function(a){var b,c;if(this.attributes.position)b=this.attributes.position.array;if(this.attributes.normal)c=this.attributes.normal.array;if(b!==void 0){a.multiplyVector3Array(b);this.verticesNeedUpdate=true}if(c!==void 0){b=new THREE.Matrix4;b.extractRotation(a);b.multiplyVector3Array(c);this.normalsNeedUpdate=true}},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3(Infinity,Infinity, THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,applyMatrix:function(a){var b,c;if(this.attributes.position)b=this.attributes.position.array;if(this.attributes.normal)c=this.attributes.normal.array;if(b!==void 0){a.multiplyVector3Array(b);this.verticesNeedUpdate=true}if(c!==void 0){b=new THREE.Matrix4;b.extractRotation(a);b.multiplyVector3Array(c);this.normalsNeedUpdate=true}},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3(Infinity,Infinity,
Infinity),max:new THREE.Vector3(-Infinity,-Infinity,-Infinity)};var a=this.attributes.position.array;if(a)for(var b=this.boundingBox,c,d,e,f=0,g=a.length;f<g;f=f+3){c=a[f];d=a[f+1];e=a[f+2];if(c<b.min.x)b.min.x=c;else if(c>b.max.x)b.max.x=c;if(d<b.min.y)b.min.y=d;else if(d>b.max.y)b.max.y=d;if(e<b.min.z)b.min.z=e;else if(e>b.max.z)b.max.z=e}if(a===void 0||a.length===0){this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere= Infinity),max:new THREE.Vector3(-Infinity,-Infinity,-Infinity)};var a=this.attributes.position.array;if(a)for(var b=this.boundingBox,c,d,e,f=0,g=a.length;f<g;f=f+3){c=a[f];d=a[f+1];e=a[f+2];if(c<b.min.x)b.min.x=c;else if(c>b.max.x)b.max.x=c;if(d<b.min.y)b.min.y=d;else if(d>b.max.y)b.max.y=d;if(e<b.min.z)b.min.z=e;else if(e>b.max.z)b.max.z=e}if(a===void 0||a.length===0){this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere=
{radius:0};var a=this.attributes.position.array;if(a){for(var b,c=0,d,e,f=0,g=a.length;f<g;f=f+3){b=a[f];d=a[f+1];e=a[f+2];b=Math.sqrt(b*b+d*d+e*e);b>c&&(c=b)}this.boundingSphere.radius=c}},computeVertexNormals:function(){if(this.attributes.position&&this.attributes.index){var a,b,c,d;a=this.attributes.position.array.length;if(this.attributes.normal===void 0)this.attributes.normal={itemSize:3,array:new Float32Array(a),numItems:a};else{a=0;for(b=this.attributes.normal.array.length;a<b;a++)this.attributes.normal.array[a]= {radius:0};var a=this.attributes.position.array;if(a){for(var b,c=0,d,e,f=0,g=a.length;f<g;f=f+3){b=a[f];d=a[f+1];e=a[f+2];b=b*b+d*d+e*e;b>c&&(c=b)}this.boundingSphere.radius=Math.sqrt(c)}},computeVertexNormals:function(){if(this.attributes.position&&this.attributes.index){var a,b,c,d;a=this.attributes.position.array.length;if(this.attributes.normal===void 0)this.attributes.normal={itemSize:3,array:new Float32Array(a),numItems:a};else{a=0;for(b=this.attributes.normal.array.length;a<b;a++)this.attributes.normal.array[a]=
0}var e=this.offsets,f=this.attributes.index.array,g=this.attributes.position.array,h=this.attributes.normal.array,j,i,m,l,n,p,r=new THREE.Vector3,o=new THREE.Vector3,q=new THREE.Vector3,s=new THREE.Vector3,x=new THREE.Vector3;c=0;for(d=e.length;c<d;++c){b=e[c].start;j=e[c].count;var u=e[c].index;a=b;for(b=b+j;a<b;a=a+3){j=u+f[a];i=u+f[a+1];m=u+f[a+2];l=g[j*3];n=g[j*3+1];p=g[j*3+2];r.set(l,n,p);l=g[i*3];n=g[i*3+1];p=g[i*3+2];o.set(l,n,p);l=g[m*3];n=g[m*3+1];p=g[m*3+2];q.set(l,n,p);s.sub(q,o);x.sub(r, 0}var e=this.offsets,f=this.attributes.index.array,g=this.attributes.position.array,h=this.attributes.normal.array,j,i,m,l,n,p,r=new THREE.Vector3,o=new THREE.Vector3,q=new THREE.Vector3,s=new THREE.Vector3,x=new THREE.Vector3;c=0;for(d=e.length;c<d;++c){b=e[c].start;j=e[c].count;var u=e[c].index;a=b;for(b=b+j;a<b;a=a+3){j=u+f[a];i=u+f[a+1];m=u+f[a+2];l=g[j*3];n=g[j*3+1];p=g[j*3+2];r.set(l,n,p);l=g[i*3];n=g[i*3+1];p=g[i*3+2];o.set(l,n,p);l=g[m*3];n=g[m*3+1];p=g[m*3+2];q.set(l,n,p);s.sub(q,o);x.sub(r,
o);s.crossSelf(x);h[j*3]=h[j*3]+s.x;h[j*3+1]=h[j*3+1]+s.y;h[j*3+2]=h[j*3+2]+s.z;h[i*3]=h[i*3]+s.x;h[i*3+1]=h[i*3+1]+s.y;h[i*3+2]=h[i*3+2]+s.z;h[m*3]=h[m*3]+s.x;h[m*3+1]=h[m*3+1]+s.y;h[m*3+2]=h[m*3+2]+s.z}}a=0;for(b=h.length;a<b;a=a+3){l=h[a];n=h[a+1];p=h[a+2];c=1/Math.sqrt(l*l+n*n+p*p);h[a]=h[a]*c;h[a+1]=h[a+1]*c;h[a+2]=h[a+2]*c}this.normalsNeedUpdate=true}},computeTangents:function(){function a(a,b,c){l=d[a*3];n=d[a*3+1];p=d[a*3+2];r=d[b*3];o=d[b*3+1];q=d[b*3+2];s=d[c*3];x=d[c*3+1];u=d[c*3+2];t= o);s.crossSelf(x);h[j*3]=h[j*3]+s.x;h[j*3+1]=h[j*3+1]+s.y;h[j*3+2]=h[j*3+2]+s.z;h[i*3]=h[i*3]+s.x;h[i*3+1]=h[i*3+1]+s.y;h[i*3+2]=h[i*3+2]+s.z;h[m*3]=h[m*3]+s.x;h[m*3+1]=h[m*3+1]+s.y;h[m*3+2]=h[m*3+2]+s.z}}a=0;for(b=h.length;a<b;a=a+3){l=h[a];n=h[a+1];p=h[a+2];c=1/Math.sqrt(l*l+n*n+p*p);h[a]=h[a]*c;h[a+1]=h[a+1]*c;h[a+2]=h[a+2]*c}this.normalsNeedUpdate=true}},computeTangents:function(){function a(a,b,c){l=d[a*3];n=d[a*3+1];p=d[a*3+2];r=d[b*3];o=d[b*3+1];q=d[b*3+2];s=d[c*3];x=d[c*3+1];u=d[c*3+2];t=
f[a*2];z=f[a*2+1];D=f[b*2];G=f[b*2+1];A=f[c*2];w=f[c*2+1];C=r-l;H=s-l;O=o-n;N=x-n;$=q-p;E=u-p;F=D-t;Q=A-t;L=G-z;K=w-z;V=1/(F*K-Q*L);P.set((K*C-L*H)*V,(K*O-L*N)*V,(K*$-L*E)*V);aa.set((F*H-Q*C)*V,(F*N-Q*O)*V,(F*E-Q*$)*V);i[a].addSelf(P);i[b].addSelf(P);i[c].addSelf(P);m[a].addSelf(aa);m[b].addSelf(aa);m[c].addSelf(aa)}function b(a){Fa.x=e[a*3];Fa.y=e[a*3+1];Fa.z=e[a*3+2];na.copy(Fa);ea=i[a];Z.copy(ea);Z.subSelf(Fa.multiplyScalar(Fa.dot(ea))).normalize();ja.cross(na,ea);Ia=ja.dot(m[a]);Aa=Ia<0?-1:1; f[a*2];z=f[a*2+1];D=f[b*2];G=f[b*2+1];A=f[c*2];w=f[c*2+1];C=r-l;H=s-l;O=o-n;N=x-n;$=q-p;E=u-p;F=D-t;Q=A-t;L=G-z;K=w-z;V=1/(F*K-Q*L);P.set((K*C-L*H)*V,(K*O-L*N)*V,(K*$-L*E)*V);aa.set((F*H-Q*C)*V,(F*N-Q*O)*V,(F*E-Q*$)*V);i[a].addSelf(P);i[b].addSelf(P);i[c].addSelf(P);m[a].addSelf(aa);m[b].addSelf(aa);m[c].addSelf(aa)}function b(a){Fa.x=e[a*3];Fa.y=e[a*3+1];Fa.z=e[a*3+2];na.copy(Fa);ea=i[a];Z.copy(ea);Z.subSelf(Fa.multiplyScalar(Fa.dot(ea))).normalize();ja.cross(na,ea);Ia=ja.dot(m[a]);Aa=Ia<0?-1:1;
......
...@@ -50,7 +50,7 @@ A=void 0,x=void 0,w=void 0,C=void 0,t=n[s[k]].x,r=n[s[k]].y,v=n[s[o]].x,z=n[s[o] ...@@ -50,7 +50,7 @@ A=void 0,x=void 0,w=void 0,C=void 0,t=n[s[k]].x,r=n[s[k]].y,v=n[s[o]].x,z=n[s[o]
b[g[j]],b[g[l]]]);h.push([g[i],g[j],g[l]]);i=j;for(l=j+1;l<e;i++,l++)g[i]=g[l];e--;m=2*e}}return d?h:f};b.Triangulate.area=a;return b})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};THREE.BufferGeometry=function(){this.id=THREE.GeometryCount++;this.attributes={};this.dynamic=false;this.boundingSphere=this.boundingBox=null;this.hasTangents=false;this.morphTargets=[]}; b[g[j]],b[g[l]]]);h.push([g[i],g[j],g[l]]);i=j;for(l=j+1;l<e;i++,l++)g[i]=g[l];e--;m=2*e}}return d?h:f};b.Triangulate.area=a;return b})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};THREE.BufferGeometry=function(){this.id=THREE.GeometryCount++;this.attributes={};this.dynamic=false;this.boundingSphere=this.boundingBox=null;this.hasTangents=false;this.morphTargets=[]};
THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,applyMatrix:function(b){var a,c;if(this.attributes.position)a=this.attributes.position.array;if(this.attributes.normal)c=this.attributes.normal.array;if(a!==void 0){b.multiplyVector3Array(a);this.verticesNeedUpdate=true}if(c!==void 0){a=new THREE.Matrix4;a.extractRotation(b);a.multiplyVector3Array(c);this.normalsNeedUpdate=true}},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3(Infinity,Infinity, THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,applyMatrix:function(b){var a,c;if(this.attributes.position)a=this.attributes.position.array;if(this.attributes.normal)c=this.attributes.normal.array;if(a!==void 0){b.multiplyVector3Array(a);this.verticesNeedUpdate=true}if(c!==void 0){a=new THREE.Matrix4;a.extractRotation(b);a.multiplyVector3Array(c);this.normalsNeedUpdate=true}},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3(Infinity,Infinity,
Infinity),max:new THREE.Vector3(-Infinity,-Infinity,-Infinity)};var b=this.attributes.position.array;if(b)for(var a=this.boundingBox,c,d,e,f=0,g=b.length;f<g;f=f+3){c=b[f];d=b[f+1];e=b[f+2];if(c<a.min.x)a.min.x=c;else if(c>a.max.x)a.max.x=c;if(d<a.min.y)a.min.y=d;else if(d>a.max.y)a.max.y=d;if(e<a.min.z)a.min.z=e;else if(e>a.max.z)a.max.z=e}if(b===void 0||b.length===0){this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere= Infinity),max:new THREE.Vector3(-Infinity,-Infinity,-Infinity)};var b=this.attributes.position.array;if(b)for(var a=this.boundingBox,c,d,e,f=0,g=b.length;f<g;f=f+3){c=b[f];d=b[f+1];e=b[f+2];if(c<a.min.x)a.min.x=c;else if(c>a.max.x)a.max.x=c;if(d<a.min.y)a.min.y=d;else if(d>a.max.y)a.max.y=d;if(e<a.min.z)a.min.z=e;else if(e>a.max.z)a.max.z=e}if(b===void 0||b.length===0){this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere=
{radius:0};var b=this.attributes.position.array;if(b){for(var a,c=0,d,e,f=0,g=b.length;f<g;f=f+3){a=b[f];d=b[f+1];e=b[f+2];a=Math.sqrt(a*a+d*d+e*e);a>c&&(c=a)}this.boundingSphere.radius=c}},computeVertexNormals:function(){if(this.attributes.position&&this.attributes.index){var b,a,c,d;b=this.attributes.position.array.length;if(this.attributes.normal===void 0)this.attributes.normal={itemSize:3,array:new Float32Array(b),numItems:b};else{b=0;for(a=this.attributes.normal.array.length;b<a;b++)this.attributes.normal.array[b]= {radius:0};var b=this.attributes.position.array;if(b){for(var a,c=0,d,e,f=0,g=b.length;f<g;f=f+3){a=b[f];d=b[f+1];e=b[f+2];a=a*a+d*d+e*e;a>c&&(c=a)}this.boundingSphere.radius=Math.sqrt(c)}},computeVertexNormals:function(){if(this.attributes.position&&this.attributes.index){var b,a,c,d;b=this.attributes.position.array.length;if(this.attributes.normal===void 0)this.attributes.normal={itemSize:3,array:new Float32Array(b),numItems:b};else{b=0;for(a=this.attributes.normal.array.length;b<a;b++)this.attributes.normal.array[b]=
0}var e=this.offsets,f=this.attributes.index.array,g=this.attributes.position.array,h=this.attributes.normal.array,i,j,l,m,n,k,o=new THREE.Vector3,q=new THREE.Vector3,p=new THREE.Vector3,s=new THREE.Vector3,u=new THREE.Vector3;c=0;for(d=e.length;c<d;++c){a=e[c].start;i=e[c].count;var t=e[c].index;b=a;for(a=a+i;b<a;b=b+3){i=t+f[b];j=t+f[b+1];l=t+f[b+2];m=g[i*3];n=g[i*3+1];k=g[i*3+2];o.set(m,n,k);m=g[j*3];n=g[j*3+1];k=g[j*3+2];q.set(m,n,k);m=g[l*3];n=g[l*3+1];k=g[l*3+2];p.set(m,n,k);s.sub(p,q);u.sub(o, 0}var e=this.offsets,f=this.attributes.index.array,g=this.attributes.position.array,h=this.attributes.normal.array,i,j,l,m,n,k,o=new THREE.Vector3,q=new THREE.Vector3,p=new THREE.Vector3,s=new THREE.Vector3,u=new THREE.Vector3;c=0;for(d=e.length;c<d;++c){a=e[c].start;i=e[c].count;var t=e[c].index;b=a;for(a=a+i;b<a;b=b+3){i=t+f[b];j=t+f[b+1];l=t+f[b+2];m=g[i*3];n=g[i*3+1];k=g[i*3+2];o.set(m,n,k);m=g[j*3];n=g[j*3+1];k=g[j*3+2];q.set(m,n,k);m=g[l*3];n=g[l*3+1];k=g[l*3+2];p.set(m,n,k);s.sub(p,q);u.sub(o,
q);s.crossSelf(u);h[i*3]=h[i*3]+s.x;h[i*3+1]=h[i*3+1]+s.y;h[i*3+2]=h[i*3+2]+s.z;h[j*3]=h[j*3]+s.x;h[j*3+1]=h[j*3+1]+s.y;h[j*3+2]=h[j*3+2]+s.z;h[l*3]=h[l*3]+s.x;h[l*3+1]=h[l*3+1]+s.y;h[l*3+2]=h[l*3+2]+s.z}}b=0;for(a=h.length;b<a;b=b+3){m=h[b];n=h[b+1];k=h[b+2];c=1/Math.sqrt(m*m+n*n+k*k);h[b]=h[b]*c;h[b+1]=h[b+1]*c;h[b+2]=h[b+2]*c}this.normalsNeedUpdate=true}},computeTangents:function(){function b(a,b,c){m=d[a*3];n=d[a*3+1];k=d[a*3+2];o=d[b*3];q=d[b*3+1];p=d[b*3+2];s=d[c*3];u=d[c*3+1];t=d[c*3+2];r= q);s.crossSelf(u);h[i*3]=h[i*3]+s.x;h[i*3+1]=h[i*3+1]+s.y;h[i*3+2]=h[i*3+2]+s.z;h[j*3]=h[j*3]+s.x;h[j*3+1]=h[j*3+1]+s.y;h[j*3+2]=h[j*3+2]+s.z;h[l*3]=h[l*3]+s.x;h[l*3+1]=h[l*3+1]+s.y;h[l*3+2]=h[l*3+2]+s.z}}b=0;for(a=h.length;b<a;b=b+3){m=h[b];n=h[b+1];k=h[b+2];c=1/Math.sqrt(m*m+n*n+k*k);h[b]=h[b]*c;h[b+1]=h[b+1]*c;h[b+2]=h[b+2]*c}this.normalsNeedUpdate=true}},computeTangents:function(){function b(a,b,c){m=d[a*3];n=d[a*3+1];k=d[a*3+2];o=d[b*3];q=d[b*3+1];p=d[b*3+2];s=d[c*3];u=d[c*3+1];t=d[c*3+2];r=
f[a*2];v=f[a*2+1];z=f[b*2];A=f[b*2+1];x=f[c*2];w=f[c*2+1];C=o-m;B=s-m;E=q-n;G=u-n;L=p-k;H=t-k;D=z-r;K=x-r;F=A-v;O=w-v;I=1/(D*O-K*F);M.set((O*C-F*B)*I,(O*E-F*G)*I,(O*L-F*H)*I);J.set((D*B-K*C)*I,(D*G-K*E)*I,(D*H-K*L)*I);j[a].addSelf(M);j[b].addSelf(M);j[c].addSelf(M);l[a].addSelf(J);l[b].addSelf(J);l[c].addSelf(J)}function a(a){U.x=e[a*3];U.y=e[a*3+1];U.z=e[a*3+2];X.copy(U);W=j[a];V.copy(W);V.subSelf(U.multiplyScalar(U.dot(W))).normalize();Y.cross(X,W);Z=Y.dot(l[a]);$=Z<0?-1:1;i[a*4]=V.x;i[a*4+1]=V.y; f[a*2];v=f[a*2+1];z=f[b*2];A=f[b*2+1];x=f[c*2];w=f[c*2+1];C=o-m;B=s-m;E=q-n;G=u-n;L=p-k;H=t-k;D=z-r;K=x-r;F=A-v;O=w-v;I=1/(D*O-K*F);M.set((O*C-F*B)*I,(O*E-F*G)*I,(O*L-F*H)*I);J.set((D*B-K*C)*I,(D*G-K*E)*I,(D*H-K*L)*I);j[a].addSelf(M);j[b].addSelf(M);j[c].addSelf(M);l[a].addSelf(J);l[b].addSelf(J);l[c].addSelf(J)}function a(a){U.x=e[a*3];U.y=e[a*3+1];U.z=e[a*3+2];X.copy(U);W=j[a];V.copy(W);V.subSelf(U.multiplyScalar(U.dot(W))).normalize();Y.cross(X,W);Z=Y.dot(l[a]);$=Z<0?-1:1;i[a*4]=V.x;i[a*4+1]=V.y;
......
...@@ -431,7 +431,7 @@ THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new ...@@ -431,7 +431,7 @@ THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new
THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=this.object=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null};THREE.BufferGeometry=function(){this.id=THREE.GeometryCount++;this.attributes={};this.dynamic=false;this.boundingSphere=this.boundingBox=null;this.hasTangents=false;this.morphTargets=[]}; THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=this.object=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null};THREE.BufferGeometry=function(){this.id=THREE.GeometryCount++;this.attributes={};this.dynamic=false;this.boundingSphere=this.boundingBox=null;this.hasTangents=false;this.morphTargets=[]};
THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,applyMatrix:function(a){var b,c;if(this.attributes.position)b=this.attributes.position.array;if(this.attributes.normal)c=this.attributes.normal.array;if(b!==void 0){a.multiplyVector3Array(b);this.verticesNeedUpdate=true}if(c!==void 0){b=new THREE.Matrix4;b.extractRotation(a);b.multiplyVector3Array(c);this.normalsNeedUpdate=true}},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3(Infinity,Infinity, THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,applyMatrix:function(a){var b,c;if(this.attributes.position)b=this.attributes.position.array;if(this.attributes.normal)c=this.attributes.normal.array;if(b!==void 0){a.multiplyVector3Array(b);this.verticesNeedUpdate=true}if(c!==void 0){b=new THREE.Matrix4;b.extractRotation(a);b.multiplyVector3Array(c);this.normalsNeedUpdate=true}},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3(Infinity,Infinity,
Infinity),max:new THREE.Vector3(-Infinity,-Infinity,-Infinity)};var a=this.attributes.position.array;if(a)for(var b=this.boundingBox,c,d,e,f=0,h=a.length;f<h;f=f+3){c=a[f];d=a[f+1];e=a[f+2];if(c<b.min.x)b.min.x=c;else if(c>b.max.x)b.max.x=c;if(d<b.min.y)b.min.y=d;else if(d>b.max.y)b.max.y=d;if(e<b.min.z)b.min.z=e;else if(e>b.max.z)b.max.z=e}if(a===void 0||a.length===0){this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere= Infinity),max:new THREE.Vector3(-Infinity,-Infinity,-Infinity)};var a=this.attributes.position.array;if(a)for(var b=this.boundingBox,c,d,e,f=0,h=a.length;f<h;f=f+3){c=a[f];d=a[f+1];e=a[f+2];if(c<b.min.x)b.min.x=c;else if(c>b.max.x)b.max.x=c;if(d<b.min.y)b.min.y=d;else if(d>b.max.y)b.max.y=d;if(e<b.min.z)b.min.z=e;else if(e>b.max.z)b.max.z=e}if(a===void 0||a.length===0){this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere=
{radius:0};var a=this.attributes.position.array;if(a){for(var b,c=0,d,e,f=0,h=a.length;f<h;f=f+3){b=a[f];d=a[f+1];e=a[f+2];b=Math.sqrt(b*b+d*d+e*e);b>c&&(c=b)}this.boundingSphere.radius=c}},computeVertexNormals:function(){if(this.attributes.position&&this.attributes.index){var a,b,c,d;a=this.attributes.position.array.length;if(this.attributes.normal===void 0)this.attributes.normal={itemSize:3,array:new Float32Array(a),numItems:a};else{a=0;for(b=this.attributes.normal.array.length;a<b;a++)this.attributes.normal.array[a]= {radius:0};var a=this.attributes.position.array;if(a){for(var b,c=0,d,e,f=0,h=a.length;f<h;f=f+3){b=a[f];d=a[f+1];e=a[f+2];b=b*b+d*d+e*e;b>c&&(c=b)}this.boundingSphere.radius=Math.sqrt(c)}},computeVertexNormals:function(){if(this.attributes.position&&this.attributes.index){var a,b,c,d;a=this.attributes.position.array.length;if(this.attributes.normal===void 0)this.attributes.normal={itemSize:3,array:new Float32Array(a),numItems:a};else{a=0;for(b=this.attributes.normal.array.length;a<b;a++)this.attributes.normal.array[a]=
0}var e=this.offsets,f=this.attributes.index.array,h=this.attributes.position.array,i=this.attributes.normal.array,l,k,j,o,m,p,u=new THREE.Vector3,n=new THREE.Vector3,q=new THREE.Vector3,r=new THREE.Vector3,w=new THREE.Vector3;c=0;for(d=e.length;c<d;++c){b=e[c].start;l=e[c].count;var v=e[c].index;a=b;for(b=b+l;a<b;a=a+3){l=v+f[a];k=v+f[a+1];j=v+f[a+2];o=h[l*3];m=h[l*3+1];p=h[l*3+2];u.set(o,m,p);o=h[k*3];m=h[k*3+1];p=h[k*3+2];n.set(o,m,p);o=h[j*3];m=h[j*3+1];p=h[j*3+2];q.set(o,m,p);r.sub(q,n);w.sub(u, 0}var e=this.offsets,f=this.attributes.index.array,h=this.attributes.position.array,i=this.attributes.normal.array,l,k,j,o,m,p,u=new THREE.Vector3,n=new THREE.Vector3,q=new THREE.Vector3,r=new THREE.Vector3,w=new THREE.Vector3;c=0;for(d=e.length;c<d;++c){b=e[c].start;l=e[c].count;var v=e[c].index;a=b;for(b=b+l;a<b;a=a+3){l=v+f[a];k=v+f[a+1];j=v+f[a+2];o=h[l*3];m=h[l*3+1];p=h[l*3+2];u.set(o,m,p);o=h[k*3];m=h[k*3+1];p=h[k*3+2];n.set(o,m,p);o=h[j*3];m=h[j*3+1];p=h[j*3+2];q.set(o,m,p);r.sub(q,n);w.sub(u,
n);r.crossSelf(w);i[l*3]=i[l*3]+r.x;i[l*3+1]=i[l*3+1]+r.y;i[l*3+2]=i[l*3+2]+r.z;i[k*3]=i[k*3]+r.x;i[k*3+1]=i[k*3+1]+r.y;i[k*3+2]=i[k*3+2]+r.z;i[j*3]=i[j*3]+r.x;i[j*3+1]=i[j*3+1]+r.y;i[j*3+2]=i[j*3+2]+r.z}}a=0;for(b=i.length;a<b;a=a+3){o=i[a];m=i[a+1];p=i[a+2];c=1/Math.sqrt(o*o+m*m+p*p);i[a]=i[a]*c;i[a+1]=i[a+1]*c;i[a+2]=i[a+2]*c}this.normalsNeedUpdate=true}},computeTangents:function(){function a(a,b,c){o=d[a*3];m=d[a*3+1];p=d[a*3+2];u=d[b*3];n=d[b*3+1];q=d[b*3+2];r=d[c*3];w=d[c*3+1];v=d[c*3+2];H= n);r.crossSelf(w);i[l*3]=i[l*3]+r.x;i[l*3+1]=i[l*3+1]+r.y;i[l*3+2]=i[l*3+2]+r.z;i[k*3]=i[k*3]+r.x;i[k*3+1]=i[k*3+1]+r.y;i[k*3+2]=i[k*3+2]+r.z;i[j*3]=i[j*3]+r.x;i[j*3+1]=i[j*3+1]+r.y;i[j*3+2]=i[j*3+2]+r.z}}a=0;for(b=i.length;a<b;a=a+3){o=i[a];m=i[a+1];p=i[a+2];c=1/Math.sqrt(o*o+m*m+p*p);i[a]=i[a]*c;i[a+1]=i[a+1]*c;i[a+2]=i[a+2]*c}this.normalsNeedUpdate=true}},computeTangents:function(){function a(a,b,c){o=d[a*3];m=d[a*3+1];p=d[a*3+2];u=d[b*3];n=d[b*3+1];q=d[b*3+2];r=d[c*3];w=d[c*3+1];v=d[c*3+2];H=
f[a*2];x=f[a*2+1];D=f[b*2];E=f[b*2+1];O=f[c*2];B=f[c*2+1];Q=u-o;F=r-o;W=n-m;V=w-m;T=q-p;A=v-p;M=D-H;G=O-H;ea=E-x;I=B-x;aa=1/(M*I-G*ea);P.set((I*Q-ea*F)*aa,(I*W-ea*V)*aa,(I*T-ea*A)*aa);Aa.set((M*F-G*Q)*aa,(M*V-G*W)*aa,(M*A-G*T)*aa);k[a].addSelf(P);k[b].addSelf(P);k[c].addSelf(P);j[a].addSelf(Aa);j[b].addSelf(Aa);j[c].addSelf(Aa)}function b(a){Ga.x=e[a*3];Ga.y=e[a*3+1];Ga.z=e[a*3+2];la.copy(Ga);ua=k[a];fa.copy(ua);fa.subSelf(Ga.multiplyScalar(Ga.dot(ua))).normalize();Ja.cross(la,ua);Xa=Ja.dot(j[a]); f[a*2];x=f[a*2+1];D=f[b*2];E=f[b*2+1];O=f[c*2];B=f[c*2+1];Q=u-o;F=r-o;W=n-m;V=w-m;T=q-p;A=v-p;M=D-H;G=O-H;ea=E-x;I=B-x;aa=1/(M*I-G*ea);P.set((I*Q-ea*F)*aa,(I*W-ea*V)*aa,(I*T-ea*A)*aa);Aa.set((M*F-G*Q)*aa,(M*V-G*W)*aa,(M*A-G*T)*aa);k[a].addSelf(P);k[b].addSelf(P);k[c].addSelf(P);j[a].addSelf(Aa);j[b].addSelf(Aa);j[c].addSelf(Aa)}function b(a){Ga.x=e[a*3];Ga.y=e[a*3+1];Ga.z=e[a*3+2];la.copy(Ga);ua=k[a];fa.copy(ua);fa.subSelf(Ga.multiplyScalar(Ga.dot(ua))).normalize();Ja.cross(la,ua);Xa=Ja.dot(j[a]);
......
...@@ -137,7 +137,7 @@ THREE.BufferGeometry.prototype = { ...@@ -137,7 +137,7 @@ THREE.BufferGeometry.prototype = {
if ( positions ) { if ( positions ) {
var radius, maxRadius = 0; var radiusSq, maxRadiusSq = 0;
var x, y, z; var x, y, z;
for ( var i = 0, il = positions.length; i < il; i += 3 ) { for ( var i = 0, il = positions.length; i < il; i += 3 ) {
...@@ -146,12 +146,12 @@ THREE.BufferGeometry.prototype = { ...@@ -146,12 +146,12 @@ THREE.BufferGeometry.prototype = {
y = positions[ i + 1 ]; y = positions[ i + 1 ];
z = positions[ i + 2 ]; z = positions[ i + 2 ];
radius = Math.sqrt( x * x + y * y + z * z ); radiusSq = x * x + y * y + z * z;
if ( radius > maxRadius ) maxRadius = radius; if ( radiusSq > maxRadiusSq ) maxRadiusSq = radiusSq;
} }
this.boundingSphere.radius = maxRadius; this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册