提交 cb3efd23 编写于 作者: A alteredq

Merge remote-tracking branch 'remotes/mrdoob/dev' into dev

因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -79,7 +79,7 @@ this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRo
Math.abs(this.x);this.y=a.elements[8]-a.elements[2]<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.elements[1]-a.elements[4]<0?-Math.abs(this.z):Math.abs(this.z);this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x=this.x*-1;this.y=this.y*-1;this.z=this.z*-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=
Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a===0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x=this.x*a;this.y=this.y*a;this.z=this.z*a;this.w=this.w*a}return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,k=a.z,a=a.w;this.x=b*a+e*f+c*k-d*g;this.y=
c*a+e*g+d*f-b*k;this.z=d*a+e*k+b*g-c*f;this.w=e*a-b*f-c*g-d*k;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,k=this.z,m=this.w,i=m*c+g*e-k*d,h=m*d+k*c-f*e,j=m*e+f*d-g*c,c=-f*c-g*d-k*e;b.x=i*m+c*-f+h*-k-j*-g;b.y=h*m+c*-g+j*-f-i*-k;b.z=j*m+c*-k+i*-g-h*-f;return b},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}};
THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(e<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;e=-e}else c.copy(b);if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(e),e=Math.sqrt(1-e*e);if(Math.abs(e)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.")};
THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(e<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;e=-e}else c.copy(b);if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(e),e=Math.sqrt(1-e*e);if(Math.abs(e)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.")};
THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};
THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;b=0;for(c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();b=0;for(c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();b=0;for(c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
return a}};THREE.Face4=function(a,b,c,d,e,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};
......@@ -97,12 +97,12 @@ m=g.faceNormals[c];i=g.vertexNormals[c];m.copy(e.normal);if(e instanceof THREE.F
i=a.vertices[d];h=g[f];j=g[e];o=g[M];n=m.x-k.x;p=i.x-k.x;l=m.y-k.y;q=i.y-k.y;u=m.z-k.z;s=i.z-k.z;z=j.u-h.u;A=o.u-h.u;v=j.v-h.v;D=o.v-h.v;x=1/(z*D-A*v);C.set((D*n-v*p)*x,(D*l-v*q)*x,(D*u-v*s)*x);L.set((z*p-A*n)*x,(z*q-A*l)*x,(z*s-A*u)*x);t[b].addSelf(C);t[c].addSelf(C);t[d].addSelf(C);y[b].addSelf(L);y[c].addSelf(L);y[d].addSelf(L)}var b,c,d,e,f,g,k,m,i,h,j,o,n,p,l,q,u,s,z,A,v,D,x,G,t=[],y=[],C=new THREE.Vector3,L=new THREE.Vector3,Q=new THREE.Vector3,N=new THREE.Vector3,r=new THREE.Vector3;b=0;for(c=
this.vertices.length;b<c;b++){t[b]=new THREE.Vector3;y[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];g=this.faceVertexUvs[0][b];if(f instanceof THREE.Face3)a(this,f.a,f.b,f.c,0,1,2);else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.d,0,1,3);a(this,f.b,f.c,f.d,1,2,3)}}var E=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];for(d=0;d<f.vertexNormals.length;d++){r.copy(f.vertexNormals[d]);e=f[E[d]];G=t[e];Q.copy(G);Q.subSelf(r.multiplyScalar(r.dot(G))).normalize();
N.cross(f.vertexNormals[d],G);e=N.dot(y[e]);e=e<0?-1:1;f.vertexTangents[d]=new THREE.Vector4(Q.x,Q.y,Q.z,e)}}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,e=this.vertices.length;d<e;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(){if(!this.boundingSphere)this.boundingSphere={radius:0};for(var a,b=0,c=0,d=this.vertices.length;c<d;c++){a=this.vertices[c].length();a>b&&(b=a)}this.boundingSphere.radius=b},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;f=0;for(g=this.vertices.length;f<g;f++){d=this.vertices[f];d=[Math.round(d.x*
e),Math.round(d.y*e),Math.round(d.z*e)].join("_");if(a[d]===void 0){a[d]=f;b.push(this.vertices[f]);c[f]=b.length-1}else c[f]=c[a[d]]}f=0;for(g=this.faces.length;f<g;f++){a=this.faces[f];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];e=[a.a,a.b,a.c,a.d];for(d=3;d>0;d--)if(e.indexOf(a["abcd"[d]])!=d){e.splice(d,1);this.faces[f]=new THREE.Face3(e[0],e[1],e[2]);this.faceVertexUvs[0][f].splice(d,1)}}}this.vertices=
b}};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=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.getRotationFromMatrix(this.matrix)};
THREE.OrthographicCamera=function(a,b,c,d,e,f){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=e!==void 0?e:0.1;this.far=f!==void 0?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;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=new THREE.Camera;THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;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,e,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=f;this.updateProjectionMatrix()};
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(){if(!this.boundingSphere)this.boundingSphere={radius:0};for(var a,b=0,c=0,d=this.vertices.length;c<d;c++){a=this.vertices[c].length();a>b&&(b=a)}this.boundingSphere.radius=b},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g,k;f=0;for(g=this.vertices.length;f<g;f++){d=this.vertices[f];d=[Math.round(d.x*
e),Math.round(d.y*e),Math.round(d.z*e)].join("_");if(a[d]===void 0){a[d]=f;b.push(this.vertices[f]);c[f]=b.length-1}else c[f]=c[a[d]]}f=0;for(g=this.faces.length;f<g;f++){e=this.faces[f];if(e instanceof THREE.Face3){e.a=c[e.a];e.b=c[e.b];e.c=c[e.c]}else if(e instanceof THREE.Face4){e.a=c[e.a];e.b=c[e.b];e.c=c[e.c];e.d=c[e.d];d=[e.a,e.b,e.c,e.d];for(a=3;a>0;a--)if(d.indexOf(e["abcd"[a]])!=a){d.splice(a,1);this.faces[f]=new THREE.Face3(d[0],d[1],d[2]);e=0;for(d=this.faceVertexUvs.length;e<d;e++)(k=
this.faceVertexUvs[e][f])&&k.splice(a,1);break}}}c=this.vertices.length-b.length;this.vertices=b;return c}};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=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.getRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,d,e,f){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=e!==void 0?e:0.1;this.far=f!==void 0?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;
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=new THREE.Camera;THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;
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,e,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=f;this.updateProjectionMatrix()};
THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix.makePerspective(this.fov,this.aspect,this.near,this.far)};
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;
THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0;this.onlyShadow=this.castShadow=false;this.shadowCameraNear=50;this.shadowCameraFar=5E3;this.shadowCameraLeft=-500;this.shadowCameraTop=this.shadowCameraRight=500;this.shadowCameraBottom=-500;this.shadowCameraVisible=false;this.shadowBias=0;this.shadowDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;
......
......@@ -79,7 +79,7 @@ this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRo
Math.abs(this.x);this.y=a.elements[8]-a.elements[2]<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.elements[1]-a.elements[4]<0?-Math.abs(this.z):Math.abs(this.z);this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x=this.x*-1;this.y=this.y*-1;this.z=this.z*-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=
Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a===0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x=this.x*a;this.y=this.y*a;this.z=this.z*a;this.w=this.w*a}return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,i=a.z,a=a.w;this.x=b*a+e*f+c*i-d*g;this.y=
c*a+e*g+d*f-b*i;this.z=d*a+e*i+b*g-c*f;this.w=e*a-b*f-c*g-d*i;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,i=this.z,j=this.w,k=j*c+g*e-i*d,h=j*d+i*c-f*e,m=j*e+f*d-g*c,c=-f*c-g*d-i*e;b.x=k*j+c*-f+h*-i-m*-g;b.y=h*j+c*-g+m*-f-k*-i;b.z=m*j+c*-i+k*-g-h*-f;return b},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}};
THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(e<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;e=-e}else c.copy(b);if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(e),e=Math.sqrt(1-e*e);if(Math.abs(e)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.")};
THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(e<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;e=-e}else c.copy(b);if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(e),e=Math.sqrt(1-e*e);if(Math.abs(e)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.")};
THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};
THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;b=0;for(c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();b=0;for(c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();b=0;for(c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
return a}};THREE.Face4=function(a,b,c,d,e,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};
......
此差异已折叠。
此差异已折叠。
......@@ -79,7 +79,7 @@ this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRo
Math.abs(this.x);this.y=a.elements[8]-a.elements[2]<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.elements[1]-a.elements[4]<0?-Math.abs(this.z):Math.abs(this.z);this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x=this.x*-1;this.y=this.y*-1;this.z=this.z*-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=
Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a===0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x=this.x*a;this.y=this.y*a;this.z=this.z*a;this.w=this.w*a}return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,f=this.w,g=a.x,h=a.y,l=a.z,a=a.w;this.x=b*a+f*g+c*l-d*h;this.y=
c*a+f*h+d*g-b*l;this.z=d*a+f*l+b*h-c*g;this.w=f*a-b*g-c*h-d*l;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,g=this.x,h=this.y,l=this.z,m=this.w,j=m*c+h*f-l*d,i=m*d+l*c-g*f,o=m*f+g*d-h*c,c=-g*c-h*d-l*f;b.x=j*m+c*-g+i*-l-o*-h;b.y=i*m+c*-h+o*-g-j*-l;b.z=o*m+c*-l+j*-h-i*-g;return b},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}};
THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(f<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;f=-f}else c.copy(b);if(Math.abs(f)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(f),f=Math.sqrt(1-f*f);if(Math.abs(f)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}b=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.")};
THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(f<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;f=-f}else c.copy(b);if(Math.abs(f)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(f),f=Math.sqrt(1-f*f);if(Math.abs(f)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}b=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.")};
THREE.Face3=function(a,b,c,d,f,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};
THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;b=0;for(c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();b=0;for(c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();b=0;for(c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
return a}};THREE.Face4=function(a,b,c,d,f,g,h){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=h;this.centroid=new THREE.Vector3};
......@@ -97,9 +97,9 @@ m=h.faceNormals[c];j=h.vertexNormals[c];m.copy(f.normal);if(f instanceof THREE.F
j=a.vertices[d];i=h[f];o=h[g];k=h[S];u=m.x-l.x;r=j.x-l.x;n=m.y-l.y;p=j.y-l.y;w=m.z-l.z;q=j.z-l.z;I=o.u-i.u;B=k.u-i.u;s=o.v-i.v;J=k.v-i.v;C=1/(I*J-B*s);Q.set((J*u-s*r)*C,(J*n-s*p)*C,(J*w-s*q)*C);T.set((I*r-B*u)*C,(I*p-B*n)*C,(I*q-B*w)*C);F[b].addSelf(Q);F[c].addSelf(Q);F[d].addSelf(Q);P[b].addSelf(T);P[c].addSelf(T);P[d].addSelf(T)}var b,c,d,f,g,h,l,m,j,i,o,k,u,r,n,p,w,q,I,B,s,J,C,G,F=[],P=[],Q=new THREE.Vector3,T=new THREE.Vector3,Z=new THREE.Vector3,R=new THREE.Vector3,z=new THREE.Vector3;b=0;for(c=
this.vertices.length;b<c;b++){F[b]=new THREE.Vector3;P[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){g=this.faces[b];h=this.faceVertexUvs[0][b];if(g instanceof THREE.Face3)a(this,g.a,g.b,g.c,0,1,2);else if(g instanceof THREE.Face4){a(this,g.a,g.b,g.d,0,1,3);a(this,g.b,g.c,g.d,1,2,3)}}var H=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){g=this.faces[b];for(d=0;d<g.vertexNormals.length;d++){z.copy(g.vertexNormals[d]);f=g[H[d]];G=F[f];Z.copy(G);Z.subSelf(z.multiplyScalar(z.dot(G))).normalize();
R.cross(g.vertexNormals[d],G);f=R.dot(P[f]);f=f<0?-1:1;g.vertexTangents[d]=new THREE.Vector4(Z.x,Z.y,Z.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(){if(!this.boundingSphere)this.boundingSphere={radius:0};for(var a,b=0,c=0,d=this.vertices.length;c<d;c++){a=this.vertices[c].length();a>b&&(b=a)}this.boundingSphere.radius=b},mergeVertices:function(){var a={},b=[],c=[],d,f=Math.pow(10,4),g,h;g=0;for(h=this.vertices.length;g<h;g++){d=this.vertices[g];d=[Math.round(d.x*
f),Math.round(d.y*f),Math.round(d.z*f)].join("_");if(a[d]===void 0){a[d]=g;b.push(this.vertices[g]);c[g]=b.length-1}else c[g]=c[a[d]]}g=0;for(h=this.faces.length;g<h;g++){a=this.faces[g];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];f=[a.a,a.b,a.c,a.d];for(d=3;d>0;d--)if(f.indexOf(a["abcd"[d]])!=d){f.splice(d,1);this.faces[g]=new THREE.Face3(f[0],f[1],f[2]);this.faceVertexUvs[0][g].splice(d,1)}}}this.vertices=
b}};THREE.GeometryCount=0;
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(){if(!this.boundingSphere)this.boundingSphere={radius:0};for(var a,b=0,c=0,d=this.vertices.length;c<d;c++){a=this.vertices[c].length();a>b&&(b=a)}this.boundingSphere.radius=b},mergeVertices:function(){var a={},b=[],c=[],d,f=Math.pow(10,4),g,h,l;g=0;for(h=this.vertices.length;g<h;g++){d=this.vertices[g];d=[Math.round(d.x*
f),Math.round(d.y*f),Math.round(d.z*f)].join("_");if(a[d]===void 0){a[d]=g;b.push(this.vertices[g]);c[g]=b.length-1}else c[g]=c[a[d]]}g=0;for(h=this.faces.length;g<h;g++){f=this.faces[g];if(f instanceof THREE.Face3){f.a=c[f.a];f.b=c[f.b];f.c=c[f.c]}else if(f instanceof THREE.Face4){f.a=c[f.a];f.b=c[f.b];f.c=c[f.c];f.d=c[f.d];d=[f.a,f.b,f.c,f.d];for(a=3;a>0;a--)if(d.indexOf(f["abcd"[a]])!=a){d.splice(a,1);this.faces[g]=new THREE.Face3(d[0],d[1],d[2]);f=0;for(d=this.faceVertexUvs.length;f<d;f++)(l=
this.faceVertexUvs[f][g])&&l.splice(a,1);break}}}c=this.vertices.length-b.length;this.vertices=b;return c}};THREE.GeometryCount=0;
THREE.Spline=function(a){function b(a,b,c,d,f,g,h){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*h+(-3*(b-c)-2*a-d)*g+a*f+b}this.points=a;var c=[],d={x:0,y:0,z:0},f,g,h,l,m,j,i,o,k;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){f=(this.points.length-1)*a;g=Math.floor(f);h=f-g;c[0]=g===0?g:g-1;c[1]=g;c[2]=g>this.points.length-2?this.points.length-1:g+1;c[3]=g>this.points.length-3?this.points.length-1:
g+2;j=this.points[c[0]];i=this.points[c[1]];o=this.points[c[2]];k=this.points[c[3]];l=h*h;m=h*l;d.x=b(j.x,i.x,o.x,k.x,h,l,m);d.y=b(j.y,i.y,o.y,k.y,h,l,m);d.z=b(j.z,i.z,o.z,k.z,h,l,m);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,f=b=b=0,g=new THREE.Vector3,h=new THREE.Vector3,i=[],l=0;i[0]=0;a||(a=100);c=this.points.length*a;g.copy(this.points[0]);for(a=1;a<c;a++){b=
a/c;d=this.getPoint(b);h.copy(d);l=l+h.distanceTo(g);g.copy(d);b=(this.points.length-1)*b;b=Math.floor(b);if(b!=f){i[b]=l;f=b}}i[i.length]=l;return{chunks:i,total:l}};this.reparametrizeByArcLength=function(a){var b,c,d,f,g,h,i=[],l=new THREE.Vector3,k=this.getLength();i.push(l.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=k.chunks[b]-k.chunks[b-1];h=Math.ceil(a*c/k.total);f=(b-1)/(this.points.length-1);g=b/(this.points.length-1);for(c=1;c<h-1;c++){d=f+c*(1/h)*(g-f);d=this.getPoint(d);
......@@ -400,7 +400,7 @@ b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);if(b.getParameter(b
"color");k.scale=b.getUniformLocation(i,"scale");k.rotation=b.getUniformLocation(i,"rotation");k.screenPosition=b.getUniformLocation(i,"screenPosition");u=false};this.render=function(a,d,f,w){var a=a.__webglFlares,q=a.length;if(q){var I=new THREE.Vector3,B=w/f,s=f*0.5,J=w*0.5,C=16/w,G=new THREE.Vector2(C*B,C),F=new THREE.Vector3(1,1,0),P=new THREE.Vector2(1,1),Q=k,C=o;b.useProgram(i);if(!u){b.enableVertexAttribArray(o.vertex);b.enableVertexAttribArray(o.uv);u=true}b.uniform1i(Q.occlusionMap,0);b.uniform1i(Q.map,
1);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(C.vertex,2,b.FLOAT,false,16,0);b.vertexAttribPointer(C.uv,2,b.FLOAT,false,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.disable(b.CULL_FACE);b.depthMask(false);var T,Z,R,z,H;for(T=0;T<q;T++){C=16/w;G.set(C*B,C);z=a[T];I.set(z.matrixWorld.elements[12],z.matrixWorld.elements[13],z.matrixWorld.elements[14]);d.matrixWorldInverse.multiplyVector3(I);d.projectionMatrix.multiplyVector3(I);F.copy(I);P.x=F.x*s+s;P.y=F.y*J+J;if(j||P.x>0&&P.x<f&&P.y>0&&
P.y<w){b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,l);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,P.x-8,P.y-8,16,16,0);b.uniform1i(Q.renderType,0);b.uniform2f(Q.scale,G.x,G.y);b.uniform3f(Q.screenPosition,F.x,F.y,F.z);b.disable(b.BLEND);b.enable(b.DEPTH_TEST);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,m);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,P.x-8,P.y-8,16,16,0);b.uniform1i(Q.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);
b.bindTexture(b.TEXTURE_2D,l);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);z.positionScreen.copy(F);z.customUpdateCallback?z.customUpdateCallback(z):z.updateLensFlares();b.uniform1i(Q.renderType,2);b.enable(b.BLEND);Z=0;for(R=z.lensFlares.length;Z<R;Z++){H=z.lensFlares[Z];if(H.opacity>0.0010&&H.scale>0.0010){F.x=H.x;F.y=H.y;F.z=H.z;C=H.size*H.scale/w;G.x=C*B;G.y=C;b.uniform3f(Q.screenPosition,F.x,F.y,F.z);b.uniform2f(Q.scale,G.x,G.y);b.uniform1f(Q.rotation,H.rotation);b.uniform1f(Q.opacity,H.opacity);
b.bindTexture(b.TEXTURE_2D,l);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);z.positionScreen.copy(F);z.customUpdateCallback?z.customUpdateCallback(z):z.updateLensFlares();b.uniform1i(Q.renderType,2);b.enable(b.BLEND);Z=0;for(R=z.lensFlares.length;Z<R;Z++){H=z.lensFlares[Z];if(H.opacity>0.001&&H.scale>0.001){F.x=H.x;F.y=H.y;F.z=H.z;C=H.size*H.scale/w;G.x=C*B;G.y=C;b.uniform3f(Q.screenPosition,F.x,F.y,F.z);b.uniform2f(Q.scale,G.x,G.y);b.uniform1f(Q.rotation,H.rotation);b.uniform1f(Q.opacity,H.opacity);
b.uniform3f(Q.color,H.color.r,H.color.g,H.color.b);c.setBlending(H.blending,H.blendEquation,H.blendSrc,H.blendDst);c.setTexture(H.texture,1);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}}}}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(true)}}};
THREE.ShadowMapPlugin=function(){var a,b,c,d,f=new THREE.Frustum,g=new THREE.Matrix4,h=new THREE.Vector3,l=new THREE.Vector3;this.init=function(f){a=f.context;b=f;var f=THREE.ShaderLib.depthRGBA,g=THREE.UniformsUtils.clone(f.uniforms);c=new THREE.ShaderMaterial({fragmentShader:f.fragmentShader,vertexShader:f.vertexShader,uniforms:g});d=new THREE.ShaderMaterial({fragmentShader:f.fragmentShader,vertexShader:f.vertexShader,uniforms:g,morphTargets:true});c._shadowPass=true;d._shadowPass=true};this.render=
function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(m,j){var i,o,k,u,r,n,p,w,q,I=[];u=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);a.enable(a.CULL_FACE);b.shadowMapCullFrontFaces?a.cullFace(a.FRONT):a.cullFace(a.BACK);b.setDepthTest(true);i=0;for(o=m.__lights.length;i<o;i++){k=m.__lights[i];if(k.castShadow)if(k instanceof THREE.DirectionalLight&&k.shadowCascade)for(r=0;r<k.shadowCascadeCount;r++){var B;if(k.shadowCascadeArray[r])B=k.shadowCascadeArray[r];
......
......@@ -69,13 +69,13 @@
var q = 3;
var radius = 150, tube = 10, segmentsR = 50, segmentsT = 20;
// var GrannyKnot = new THREE.Curves.GrannyKnot();
var GrannyKnot = new THREE.Curves.GrannyKnot();
// var torus = new THREE.TorusKnotGeometry( radius, tube, segmentsR, segmentsT, p , q, heightScale );
// var torus2 = new THREE.TorusKnotGeometry2( radius, tube, segmentsR, segmentsT, p , q, heightScale );
var torus2 = new THREE.TorusKnotGeometry2( radius, tube, segmentsR, segmentsT, p , q, heightScale );
// var sphere = new THREE.SphereGeometry( 75, 20, 10 );
// var sphere2 = new THREE.SphereGeometry2( 75, 20, 10 );
var sphere2 = new THREE.SphereGeometry2( 75, 20, 10 );
// var tube = new THREE.TubeGeometry(GrannyKnot, 150, 2, 8, true, false);
// var tube2 = new THREE.TubeGeometry2(GrannyKnot, 150, 2, 8, true, false);
var tube2 = new THREE.TubeGeometry2(GrannyKnot, 150, 2, 8, true, false);
// var benchmarkCopies = 1000;
......@@ -88,26 +88,37 @@
// }
console.log(THREE.ParametricGeometries);
var geo = new THREE.ParametricGeometry(20, 20, THREE.ParametricGeometries.klein);
var geo;
// Klein Bottle
geo = new THREE.ParametricGeometry(THREE.ParametricGeometries.klein, 20, 20);
object = THREE.SceneUtils.createMultiMaterialObject( geo, materials );
object.children[ 0 ].doubleSided = true;
object.position.set( 0, 0, 0 );
object.scale.multiplyScalar(10);
scene.add( object );
// var geo = new THREE.ParametricGeometry(10, 10, THREE.ParametricGeometries.plane(200, 200));
THREE.UVsDebug( geo );
document.body.appendChild( THREE.UVsDebug( geo ));
// Mobius Strip
geo = new THREE.ParametricGeometry(THREE.ParametricGeometries.mobius, 20, 20);
object = THREE.SceneUtils.createMultiMaterialObject( geo, materials );
// object.children[ 0 ].doubleSided = true;
object.position.set( 10, 0, 0 );
object.scale.multiplyScalar(100);
scene.add( object );
// var geo = new THREE.ParametricGeometry(THREE.ParametricGeometries.plane(200, 200), 10, 10);
// THREE.UVsDebug( geo );
// document.body.appendChild( THREE.UVsDebug( geo ));
// object = THREE.SceneUtils.createMultiMaterialObject( geo, materials );
// object = THREE.SceneUtils.createMultiMaterialObject( torus, materials );
// object.position.set( 0, 0, 0 );
// scene.add( object );
// object = THREE.SceneUtils.createMultiMaterialObject( torus2, materials );
// object.position.set( 0, 100, 0 );
// scene.add( object );
object = THREE.SceneUtils.createMultiMaterialObject( torus2, materials );
object.position.set( 0, 100, 0 );
scene.add( object );
......@@ -116,21 +127,18 @@
// object.position.set( 500, 0, 0 );
// scene.add( object );
// object = THREE.SceneUtils.createMultiMaterialObject( sphere2, materials );
// object.position.set( 200, 0, 0 );
// scene.add( object );
object = THREE.SceneUtils.createMultiMaterialObject( sphere2, materials );
object.position.set( 200, 0, 0 );
scene.add( object );
// object = THREE.SceneUtils.createMultiMaterialObject( tube, materials );
// object.position.set( 0, 0, 0 );
// scene.add( object );
// object = THREE.SceneUtils.createMultiMaterialObject( tube2, materials );
// object.position.set( 100, 0, 0 );
// scene.add( object );
object = THREE.SceneUtils.createMultiMaterialObject( tube2, materials );
object.position.set( 100, 0, 0 );
scene.add( object );
// object = THREE.SceneUtils.createMultiMaterialObject( new THREE.ParametricGeometry(10, 10, klein) , materials );
// object.position.set( 100, 0, 0 );
// scene.add( object );
// object = THREE.SceneUtils.createMultiMaterialObject( new THREE.PlaneGeometry( 400, 400, 4, 4 ), materials );
// // object.children[ 0 ].doubleSided = true;
......
......@@ -5,69 +5,69 @@
*/
THREE.TubeGeometry2 = function(path, segments, radius, segmentsRadius, closed, debug) {
this.path = path;
this.segments = segments || 64;
this.radius = radius || 1;
this.segmentsRadius = segmentsRadius || 8;
this.closed = closed || false;
if (debug) this.debug = new THREE.Object3D();
this.path = path;
this.segments = segments || 64;
this.radius = radius || 1;
this.segmentsRadius = segmentsRadius || 8;
this.closed = closed || false;
if (debug) this.debug = new THREE.Object3D();
var scope = this,
var scope = this,
tangent, normal, binormal,
tangent, normal, binormal,
numpoints = this.segments + 1,
numpoints = this.segments + 1,
x, y, z, tx, ty, tz, u, v,
x, y, z, tx, ty, tz, u, v,
cx, cy, pos, pos2 = new THREE.Vector3(),
i, j, ip, jp, a, b, c, d, uva, uvb, uvc, uvd;
cx, cy, pos, pos2 = new THREE.Vector3(),
i, j, ip, jp, a, b, c, d, uva, uvb, uvc, uvd;
var frames = new THREE.TubeGeometry.FrenetFrames(path, segments, closed),
tangents = frames.tangents,
normals = frames.normals,
binormals = frames.binormals;
var frames = new THREE.TubeGeometry.FrenetFrames(path, segments, closed),
tangents = frames.tangents,
normals = frames.normals,
binormals = frames.binormals;
// proxy internals
this.tangents = tangents;
this.normals = normals;
this.binormals = binormals;
// proxy internals
this.tangents = tangents;
this.normals = normals;
this.binormals = binormals;
var ParametricTube = function(u, v) {
v *= 2 * pi;
i = u * (numpoints - 1);
i = Math.floor(i);
var ParametricTube = function(u, v) {
v *= 2 * pi;
i = u * (numpoints - 1);
i = Math.floor(i);
pos = path.getPointAt(u);
pos = path.getPointAt(u);
tangent = tangents[i];
normal = normals[i];
binormal = binormals[i];
tangent = tangents[i];
normal = normals[i];
binormal = binormals[i];
if (scope.debug) {
if (scope.debug) {
scope.debug.add(new THREE.ArrowHelper(tangent, pos, radius, 0x0000ff));
scope.debug.add(new THREE.ArrowHelper(normal, pos, radius, 0xff0000));
scope.debug.add(new THREE.ArrowHelper(binormal, pos, radius, 0x00ff00));
scope.debug.add(new THREE.ArrowHelper(tangent, pos, radius, 0x0000ff));
scope.debug.add(new THREE.ArrowHelper(normal, pos, radius, 0xff0000));
scope.debug.add(new THREE.ArrowHelper(binormal, pos, radius, 0x00ff00));
}
cx = -scope.radius * Math.cos(v); // TODO: Hack: Negating it so it faces outside.
cy = scope.radius * Math.sin(v);
}
cx = -scope.radius * Math.cos(v); // TODO: Hack: Negating it so it faces outside.
cy = scope.radius * Math.sin(v);
pos2.copy(pos);
pos2.x += cx * normal.x + cy * binormal.x;
pos2.y += cx * normal.y + cy * binormal.y;
pos2.z += cx * normal.z + cy * binormal.z;
pos2.copy(pos);
pos2.x += cx * normal.x + cy * binormal.x;
pos2.y += cx * normal.y + cy * binormal.y;
pos2.z += cx * normal.z + cy * binormal.z;
return pos2.clone();
};
return pos2.clone();
};
THREE.ParametricGeometry.call(this, segments, segmentsRadius, ParametricTube);
THREE.ParametricGeometry.call(this, ParametricTube, segments, segmentsRadius);
};
......@@ -89,31 +89,31 @@ THREE.TubeGeometry2.prototype.constructor = THREE.TubeGeometry2;
this.heightScale = heightScale || 1;
var TorusKnotCurve = THREE.Curve.create(
var TorusKnotCurve = THREE.Curve.create(
function() {
},
function() {
},
function(t) {
function(t) {
t *= Math.PI * 2;
t *= Math.PI * 2;
var r = 0.5;
var tx = (1 + r * Math.cos(q * t)) * Math.cos(p * t),
ty = (1 + r * Math.cos(q * t)) * Math.sin(p * t),
tz = r * Math.sin(q * t);
var r = 0.5;
var tx = (1 + r * Math.cos(q * t)) * Math.cos(p * t),
ty = (1 + r * Math.cos(q * t)) * Math.sin(p * t),
tz = r * Math.sin(q * t);
return new THREE.Vector3(tx, ty * heightScale, tz).multiplyScalar(radius);
return new THREE.Vector3(tx, ty * heightScale, tz).multiplyScalar(radius);
}
}
);
var segments = segmentsR;
var radiusSegments = segmentsT;
var extrudePath = new TorusKnotCurve();
);
var segments = segmentsR;
var radiusSegments = segmentsT;
var extrudePath = new TorusKnotCurve();
THREE.TubeGeometry2.call( this, extrudePath, segments, tube, radiusSegments, true, false );
THREE.TubeGeometry2.call( this, extrudePath, segments, tube, radiusSegments, true, false );
};
......@@ -124,54 +124,85 @@ THREE.TorusKnotGeometry2.prototype.constructor = THREE.TorusKnotGeometry2;
var sin = Math.sin, cos = Math.cos, pi = Math.PI;
THREE.ParametricGeometries = {
klein: function (v, u) {
u *= pi;
v *= 2 * pi;
u = u * 2;
var x, y, z;
if (u < pi) {
x = 3 * cos(u) * (1 + sin(u)) + (2 * (1 - cos(u) / 2)) * cos(u) * cos(v);
z = -8 * sin(u) - 2 * (1 - cos(u) / 2) * sin(u) * cos(v);
} else {
x = 3 * cos(u) * (1 + sin(u)) + (2 * (1 - cos(u) / 2)) * cos(v + pi);
z = -8 * sin(u);
}
y = -2 * (1 - cos(u) / 2) * sin(v);
return new THREE.Vector3(x, y, z);
},
plane: function (width, height) {
return function(u, v) {
var x = u * width;
var y = 0;
var z = v * height;
console.log(x, y, z);
return new THREE.Vector3(x, y, z);
};
}
klein: function (v, u) {
u *= pi;
v *= 2 * pi;
u = u * 2;
var x, y, z;
if (u < pi) {
x = 3 * cos(u) * (1 + sin(u)) + (2 * (1 - cos(u) / 2)) * cos(u) * cos(v);
z = -8 * sin(u) - 2 * (1 - cos(u) / 2) * sin(u) * cos(v);
} else {
x = 3 * cos(u) * (1 + sin(u)) + (2 * (1 - cos(u) / 2)) * cos(v + pi);
z = -8 * sin(u);
}
y = -2 * (1 - cos(u) / 2) * sin(v);
return new THREE.Vector3(x, y, z);
},
plane: function (width, height) {
return function(u, v) {
var x = u * width;
var y = 0;
var z = v * height;
console.log(x, y, z);
return new THREE.Vector3(x, y, z);
};
},
mobius: function(u, t) {
// flat mobius strip
// http://www.wolframalpha.com/input/?i=M%C3%B6bius+strip+parametric+equations&lk=1&a=ClashPrefs_*Surface.MoebiusStrip.SurfaceProperty.ParametricEquations-
// u = u - 0.5;
// var v = 2 * pi * t;
// var x, y, z;
// var a = 2;
// x = cos(v) * (a + u * cos(v/2));
// y = sin(v) * (a + u * cos(v/2));
// z = u * sin(v/2);
// return new THREE.Vector3(x, y, z);
// volumetric mobius strip
u *= pi;
t *= 2 * pi;
u = u * 2
var phi = u / 2
var major = 2.25, a = 0.125, b = 0.65;
var x, y, z;
x = a * cos(t) * cos(phi) - b * sin(t) * sin(phi);
z = a * cos(t) * sin(phi) + b * sin(t) * cos(phi);
y = (major + x) * sin(u);
x = (major + x) * cos(u);
return new THREE.Vector3(x, y, z);
}
};
THREE.SphereGeometry2 = function(size, x, y) {
function sphere(u, v) {
u *= pi;
v *= 2 * pi;
var x = sin(u) * cos(v);
var y = cos(u);
var z = -sin(u) * sin(v);
function sphere(u, v) {
u *= pi;
v *= 2 * pi;
var x = sin(u) * cos(v);
var y = cos(u);
var z = -sin(u) * sin(v);
return new THREE.Vector3(x, y, z).multiplyScalar(size);
}
return new THREE.Vector3(x, y, z).multiplyScalar(size);
}
THREE.ParametricGeometry.call(this, y, x, sphere);
THREE.ParametricGeometry.call(this, sphere, y, x);
};
......@@ -181,16 +212,16 @@ THREE.SphereGeometry2.prototype.constructor = THREE.SphereGeometry2;
THREE.PlaneGeometry2 = function(width, depth, segmentsWidth, segmentsDepth) {
function plane(u, v) {
var x = u * width;
var y = 0;
var z = v * depth;
function plane(u, v) {
var x = u * width;
var y = 0;
var z = v * depth;
return new THREE.Vector3(x, y, z);
}
return new THREE.Vector3(x, y, z);
}
THREE.ParametricGeometry.call(this, segmentsWidth, segmentsDepth, plane);
THREE.ParametricGeometry.call(this, plane, segmentsWidth, segmentsDepth);
};
......
......@@ -4,7 +4,7 @@
* based on the brilliant article by @prideout http://prideout.net/blog/?p=44
*/
THREE.ParametricGeometry = function ( slices, stacks, func ) {
THREE.ParametricGeometry = function ( func, slices, stacks, face4 ) {
THREE.Geometry.call( this );
......@@ -12,7 +12,7 @@ THREE.ParametricGeometry = function ( slices, stacks, func ) {
var faces = this.faces;
var uvs = this.faceVertexUvs[ 0 ];
var face3 = true;
var useFace3 = (face4 === undefined) ? true : !face4;
var i, il, j, p;
var u, v;
......@@ -40,30 +40,40 @@ THREE.ParametricGeometry = function ( slices, stacks, func ) {
for ( i = 0; i < stacks; i ++ ) {
for ( j = 0; j < slices; j ++ ) {
a = i * stackCount + j;
b = i * stackCount + j + 1;
c = (i + 1) * stackCount + j;
d = (i + 1) * stackCount + j + 1;
a = i * sliceCount + j;
b = i * sliceCount + j + 1;
c = (i + 1) * sliceCount + j;
d = (i + 1) * sliceCount + j + 1;
uva = new THREE.UV( i / slices, j / stacks );
uvb = new THREE.UV( i / slices, ( j + 1 ) / stacks );
uvc = new THREE.UV( ( i + 1 ) / slices, j / stacks );
uvd = new THREE.UV( ( i + 1 ) / slices, ( j + 1 ) / stacks );
faces.push( new THREE.Face3( a, b, c ) );
faces.push( new THREE.Face3( b, d, c ) );
if ( useFace3 ) {
faces.push( new THREE.Face3( a, b, c ) );
faces.push( new THREE.Face3( b, d, c ) );
uvs.push( [ uva, uvb, uvc ] );
uvs.push( [ uvb, uvd, uvc ] );
} else {
faces.push( new THREE.Face4( a, b, d, c ) );
uvs.push( [ uva, uvb, uvc, uvd ] );
}
uvs.push( [ uva, uvb, uvc ] );
uvs.push( [ uvb, uvd, uvc ] );
}
}
console.log(this);
// console.log(this);
// magic bullet
var diff = this.mergeVertices();
console.log('removed ', diff, ' vertices by merging')
console.log('removed ', diff, ' vertices by merging');
this.computeCentroids();
this.computeFaceNormals();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册