浏览代码

Merged with @mrdoob's dev branch.

alteredq 12 年之前
父节点
当前提交
654adb5fd7
共有 3 个文件被更改,包括 16 次插入1 次删除
  1. 7 0
      build/three.js
  2. 2 1
      build/three.min.js
  3. 7 0
      src/core/BufferGeometry.js

+ 7 - 0
build/three.js

@@ -6039,6 +6039,13 @@ THREE.BufferGeometry.prototype = {
 		this.hasTangents = true;
 		this.tangentsNeedUpdate = true;
 
+	},
+
+	deallocate: function () {
+
+		var index = THREE.GeometryLibrary.indexOf( this );
+		if ( index !== -1 ) THREE.GeometryLibrary.splice( index, 1 );
+
 	}
 
 };

+ 2 - 1
build/three.min.js

@@ -127,7 +127,8 @@ g=this.attributes.position.array,h=this.attributes.normal.array,i,j,m,n,l,p,o=ne
 2]+=r.z,h[3*j]+=r.x,h[3*j+1]+=r.y,h[3*j+2]+=r.z,h[3*m]+=r.x,h[3*m+1]+=r.y,h[3*m+2]+=r.z}a=0;for(b=h.length;a<b;a+=3)n=h[a],l=h[a+1],p=h[a+2],c=1/Math.sqrt(n*n+l*l+p*p),h[a]*=c,h[a+1]*=c,h[a+2]*=c;this.normalsNeedUpdate=!0}},computeTangents:function(){function a(a){aa.x=d[3*a];aa.y=d[3*a+1];aa.z=d[3*a+2];P.copy(aa);Q=i[a];M.copy(Q);M.subSelf(aa.multiplyScalar(aa.dot(Q))).normalize();R.cross(P,Q);U=R.dot(j[a]);O=0>U?-1:1;h[4*a]=M.x;h[4*a+1]=M.y;h[4*a+2]=M.z;h[4*a+3]=O}if(void 0===this.attributes.index||
 void 0===this.attributes.position||void 0===this.attributes.normal||void 0===this.attributes.uv)console.warn("Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");else{var b=this.attributes.index.array,c=this.attributes.position.array,d=this.attributes.normal.array,e=this.attributes.uv.array,f=c.length/3;if(void 0===this.attributes.tangent){var g=4*f;this.attributes.tangent={itemSize:4,array:new Float32Array(g),numItems:g}}for(var h=this.attributes.tangent.array,
 i=[],j=[],g=0;g<f;g++)i[g]=new THREE.Vector3,j[g]=new THREE.Vector3;var m,n,l,p,o,q,s,r,A,u,t,F,z,w,v,f=new THREE.Vector3,g=new THREE.Vector3,C,D,I,L,B,K,H,G=this.offsets;I=0;for(L=G.length;I<L;++I){D=G[I].start;B=G[I].count;var N=G[I].index;C=D;for(D+=B;C<D;C+=3)B=N+b[C],K=N+b[C+1],H=N+b[C+2],m=c[3*B],n=c[3*B+1],l=c[3*B+2],p=c[3*K],o=c[3*K+1],q=c[3*K+2],s=c[3*H],r=c[3*H+1],A=c[3*H+2],u=e[2*B],t=e[2*B+1],F=e[2*K],z=e[2*K+1],w=e[2*H],v=e[2*H+1],p-=m,m=s-m,o-=n,n=r-n,q-=l,l=A-l,F-=u,u=w-u,z-=t,t=v-
-t,v=1/(F*t-u*z),f.set((t*p-z*m)*v,(t*o-z*n)*v,(t*q-z*l)*v),g.set((F*m-u*p)*v,(F*n-u*o)*v,(F*l-u*q)*v),i[B].addSelf(f),i[K].addSelf(f),i[H].addSelf(f),j[B].addSelf(g),j[K].addSelf(g),j[H].addSelf(g)}var M=new THREE.Vector3,R=new THREE.Vector3,aa=new THREE.Vector3,P=new THREE.Vector3,O,Q,U;I=0;for(L=G.length;I<L;++I){D=G[I].start;B=G[I].count;N=G[I].index;C=D;for(D+=B;C<D;C+=3)B=N+b[C],K=N+b[C+1],H=N+b[C+2],a(B),a(K),a(H)}this.tangentsNeedUpdate=this.hasTangents=!0}}};
+t,v=1/(F*t-u*z),f.set((t*p-z*m)*v,(t*o-z*n)*v,(t*q-z*l)*v),g.set((F*m-u*p)*v,(F*n-u*o)*v,(F*l-u*q)*v),i[B].addSelf(f),i[K].addSelf(f),i[H].addSelf(f),j[B].addSelf(g),j[K].addSelf(g),j[H].addSelf(g)}var M=new THREE.Vector3,R=new THREE.Vector3,aa=new THREE.Vector3,P=new THREE.Vector3,O,Q,U;I=0;for(L=G.length;I<L;++I){D=G[I].start;B=G[I].count;N=G[I].index;C=D;for(D+=B;C<D;C+=3)B=N+b[C],K=N+b[C+1],H=N+b[C+2],a(B),a(K),a(H)}this.tangentsNeedUpdate=this.hasTangents=!0}},deallocate:function(){var a=THREE.GeometryLibrary.indexOf(this);
+-1!==a&&THREE.GeometryLibrary.splice(a,1)}};
 THREE.Spline=function(a){function b(a,b,c,d,e,f,g){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,f,g,h,i,j,m,n,l;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){e=(this.points.length-1)*a;f=Math.floor(e);g=e-f;c[0]=0===f?f:f-1;c[1]=f;c[2]=f>this.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1:
 f+2;j=this.points[c[0]];m=this.points[c[1]];n=this.points[c[2]];l=this.points[c[3]];h=g*g;i=g*h;d.x=b(j.x,m.x,n.x,l.x,g,h,i);d.y=b(j.y,m.y,n.y,l.y,g,h,i);d.z=b(j.z,m.z,n.z,l.z,g,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d};this.getLength=function(a){var b,c,d,e=b=b=0,f=new THREE.Vector3,g=new THREE.Vector3,h=[],i=0;h[0]=0;a||(a=100);c=this.points.length*a;f.copy(this.points[0]);for(a=1;a<c;a++)b=
 a/c,d=this.getPoint(b),g.copy(d),i+=g.distanceTo(f),f.copy(d),b*=this.points.length-1,b=Math.floor(b),b!=e&&(h[b]=i,e=b);h[h.length]=i;return{chunks:h,total:i}};this.reparametrizeByArcLength=function(a){var b,c,d,e,f,g,h=[],i=new THREE.Vector3,j=this.getLength();h.push(i.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=j.chunks[b]-j.chunks[b-1];g=Math.ceil(a*c/j.total);e=(b-1)/(this.points.length-1);f=b/(this.points.length-1);for(c=1;c<g-1;c++)d=e+c*(1/g)*(f-e),d=this.getPoint(d),

+ 7 - 0
src/core/BufferGeometry.js

@@ -476,6 +476,13 @@ THREE.BufferGeometry.prototype = {
 		this.hasTangents = true;
 		this.tangentsNeedUpdate = true;
 
+	},
+
+	deallocate: function () {
+
+		var index = THREE.GeometryLibrary.indexOf( this );
+		if ( index !== -1 ) THREE.GeometryLibrary.splice( index, 1 );
+
 	}
 
 };