2
0
Эх сурвалжийг харах

Reverted computeBoundingSphere sketchy optimisation. But left the neat one.

Mr.doob 13 жил өмнө
parent
commit
a85e59ede8

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 136 - 136
build/Three.js


+ 3 - 3
build/custom/ThreeCanvas.js

@@ -111,9 +111,9 @@ m=g.faceNormals[c];k=g.vertexNormals[c];m.copy(f.normal);if(f instanceof THREE.F
 k=a.vertices[d];h=g[e];n=g[f];l=g[t];o=m.x-j.x;q=k.x-j.x;i=m.y-j.y;p=k.y-j.y;r=m.z-j.z;u=k.z-j.z;v=n.u-h.u;B=l.u-h.u;x=n.v-h.v;A=l.v-h.v;y=1/(v*A-B*x);C.set((A*o-x*q)*y,(A*i-x*p)*y,(A*r-x*u)*y);K.set((v*q-B*o)*y,(v*p-B*i)*y,(v*u-B*r)*y);s[b].addSelf(C);s[c].addSelf(C);s[d].addSelf(C);w[b].addSelf(K);w[c].addSelf(K);w[d].addSelf(K)}var b,c,d,f,e,g,j,m,k,h,n,l,o,q,i,p,r,u,v,B,x,A,y,E,s=[],w=[],C=new THREE.Vector3,K=new THREE.Vector3,M=new THREE.Vector3,N=new THREE.Vector3,t=new THREE.Vector3;b=0;for(c=
 this.vertices.length;b<c;b++){s[b]=new THREE.Vector3;w[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){e=this.faces[b];g=this.faceVertexUvs[0][b];if(e instanceof THREE.Face3)a(this,e.a,e.b,e.c,0,1,2);else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.d,0,1,3);a(this,e.b,e.c,e.d,1,2,3)}}var G=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){e=this.faces[b];for(d=0;d<e.vertexNormals.length;d++){t.copy(e.vertexNormals[d]);f=e[G[d]];E=s[f];M.copy(E);M.subSelf(t.multiplyScalar(t.dot(E))).normalize();
 N.cross(e.vertexNormals[d],E);f=N.dot(w[f]);f=f<0?-1:1;e.vertexTangents[d]=new THREE.Vector4(M.x,M.y,M.z,f)}}this.hasTangents=true},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(this.vertices.length>0){var a;a=this.vertices[0];this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,f=this.vertices.length;d<f;d++){a=this.vertices[d];if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=
-a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}else{this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(a){if(this.boundingSphere===null)this.boundingSphere={radius:0};a===void 0&&(a=1);for(var b=0,c=0,d=this.vertices.length;c<d;c=c+a){var f=this.vertices[c].lengthSq();f>b&&(b=f)}this.boundingSphere.radius=Math.sqrt(b)},mergeVertices:function(){var a={},b=[],c=[],d,f=Math.pow(10,4),e,g,j,m;e=0;for(g=this.vertices.length;e<
-g;e++){d=this.vertices[e];d=[Math.round(d.x*f),Math.round(d.y*f),Math.round(d.z*f)].join("_");if(a[d]===void 0){a[d]=e;b.push(this.vertices[e]);c[e]=b.length-1}else c[e]=c[a[d]]}e=0;for(g=this.faces.length;e<g;e++){a=this.faces[e];if(a instanceof THREE.Face3){a.a=c[a.a];a.b=c[a.b];a.c=c[a.c]}else if(a instanceof THREE.Face4){a.a=c[a.a];a.b=c[a.b];a.c=c[a.c];a.d=c[a.d];d=[a.a,a.b,a.c,a.d];for(f=3;f>0;f--)if(d.indexOf(a["abcd"[f]])!==f){d.splice(f,1);this.faces[e]=new THREE.Face3(d[0],d[1],d[2],a.normal,
-a.color,a.materialIndex);d=0;for(j=this.faceVertexUvs.length;d<j;d++)(m=this.faceVertexUvs[d][e])&&m.splice(f,1);this.faces[e].vertexColors=a.vertexColors;break}}}c=this.vertices.length-b.length;this.vertices=b;return c},clone:function(){}};THREE.GeometryCount=0;THREE.Camera=function(){THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};THREE.Camera.prototype=Object.create(THREE.Object3D.prototype);
+a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}else{this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){var a=0;if(this.boundingSphere===null)this.boundingSphere={radius:0};for(var b=0,c=this.vertices.length;b<c;b++){var d=this.vertices[b].lengthSq();d>a&&(a=d)}this.boundingSphere.radius=Math.sqrt(a)},mergeVertices:function(){var a={},b=[],c=[],d,f=Math.pow(10,4),e,g,j,m;e=0;for(g=this.vertices.length;e<g;e++){d=
+this.vertices[e];d=[Math.round(d.x*f),Math.round(d.y*f),Math.round(d.z*f)].join("_");if(a[d]===void 0){a[d]=e;b.push(this.vertices[e]);c[e]=b.length-1}else c[e]=c[a[d]]}e=0;for(g=this.faces.length;e<g;e++){a=this.faces[e];if(a instanceof THREE.Face3){a.a=c[a.a];a.b=c[a.b];a.c=c[a.c]}else if(a instanceof THREE.Face4){a.a=c[a.a];a.b=c[a.b];a.c=c[a.c];a.d=c[a.d];d=[a.a,a.b,a.c,a.d];for(f=3;f>0;f--)if(d.indexOf(a["abcd"[f]])!==f){d.splice(f,1);this.faces[e]=new THREE.Face3(d[0],d[1],d[2],a.normal,a.color,
+a.materialIndex);d=0;for(j=this.faceVertexUvs.length;d<j;d++)(m=this.faceVertexUvs[d][e])&&m.splice(f,1);this.faces[e].vertexColors=a.vertexColors;break}}}c=this.vertices.length-b.length;this.vertices=b;return c},clone:function(){}};THREE.GeometryCount=0;THREE.Camera=function(){THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};THREE.Camera.prototype=Object.create(THREE.Object3D.prototype);
 THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate===true&&this.rotation.setEulerFromRotationMatrix(this.matrix,this.eulerOrder)};THREE.OrthographicCamera=function(a,b,c,d,f,e){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=f!==void 0?f:0.1;this.far=e!==void 0?e:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=Object.create(THREE.Camera.prototype);
 THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix.makeOrthographic(this.left,this.right,this.top,this.bottom,this.near,this.far)};THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=Object.create(THREE.Camera.prototype);
 THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((b!==void 0?b:24)/(a*2))*(180/Math.PI);this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,f,e){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=f;this.height=e;this.updateProjectionMatrix()};

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 118 - 118
build/custom/ThreeWebGL.js


+ 4 - 6
src/core/Geometry.js

@@ -544,15 +544,13 @@ THREE.Geometry.prototype = {
 
 	},
 
-	computeBoundingSphere: function ( step ) {
-
-		if ( this.boundingSphere === null ) this.boundingSphere = { radius: 0 };
-
-		if ( step === undefined ) step = 1;
+	computeBoundingSphere: function () {
 
 		var maxRadiusSq = 0;
 
-		for ( var i = 0, l = this.vertices.length; i < l; i += step ) {
+		if ( this.boundingSphere === null ) this.boundingSphere = { radius: 0 };
+
+		for ( var i = 0, l = this.vertices.length; i < l; i ++ ) {
 
 			var radiusSq = this.vertices[ i ].lengthSq();
 			if ( radiusSq > maxRadiusSq ) maxRadiusSq = radiusSq;

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно