提交 7168bc24 编写于 作者: A alteredq

Added more random functions to THREE.Math

上级 655b1efb
......@@ -25,7 +25,7 @@ e,g,f)&&(n={distance:a.distanceTo(k),point:k.clone(),face:n,object:m},s.push(n))
THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,f,k,o){h=!1;b=g;c=f;d=k;e=o;a()};this.addPoint=function(g,f){h?(h=!1,b=g,c=f,d=g,e=f):(b=b<g?b:g,c=c<f?c:f,d=d>g?d:g,e=e>f?e:f);a()};this.add3Points=
function(g,f,k,o,p,m){h?(h=!1,b=g<k?g<p?g:p:k<p?k:p,c=f<o?f<m?f:m:o<m?o:m,d=g>k?g>p?g:p:k>p?k:p,e=f>o?f>m?f:m:o>m?o:m):(b=g<k?g<p?g<b?g:b:p<b?p:b:k<p?k<b?k:b:p<b?p:b,c=f<o?f<m?f<c?f:c:m<c?m:c:o<m?o<c?o:c:m<c?m:c,d=g>k?g>p?g>d?g:d:p>d?p:d:k>p?k>d?k:d:p>d?p:d,e=f>o?f>m?f>e?f:e:m>e?m:e:o>m?o>e?o:e:m>e?m:e);a()};this.addRectangle=function(g){h?(h=!1,b=g.getLeft(),c=g.getTop(),d=g.getRight(),e=g.getBottom()):(b=b<g.getLeft()?b:g.getLeft(),c=c<g.getTop()?c:g.getTop(),d=d>g.getRight()?d:g.getRight(),e=e>
g.getBottom()?e:g.getBottom());a()};this.inflate=function(g){b-=g;c-=g;d+=g;e+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d<g.getRight()?d:g.getRight();e=e<g.getBottom()?e:g.getBottom();a()};this.intersects=function(a){return Math.min(d,a.getRight())-Math.max(b,a.getLeft())>=0&&Math.min(e,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};
THREE.Math={clamp:function(a,b,c){return a<b?b:a>c?c:a},clampBottom:function(a,b){return a<b?b:a},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},random16:function(){return(65280*Math.random()+255*Math.random())/65535}};THREE.Matrix3=function(){this.m=[]};
THREE.Math={clamp:function(a,b,c){return a<b?b:a>c?c:a},clampBottom:function(a,b){return a<b?b:a},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(0.5-Math.random())}};THREE.Matrix3=function(){this.m=[]};
THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
THREE.Matrix4=function(a,b,c,d,e,g,f,h,i,j,k,o,p,m,s,n){this.set(a!==void 0?a:1,b||0,c||0,d||0,e||0,g!==void 0?g:1,f||0,h||0,i||0,j||0,k!==void 0?k:1,o||0,p||0,m||0,s||0,n!==void 0?n:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,g,f,h,i,j,k,o,p,m,s,n){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=f;this.n24=h;this.n31=i;this.n32=j;this.n33=k;this.n34=o;this.n41=p;this.n42=m;this.n43=s;this.n44=n;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
......
......@@ -24,7 +24,7 @@ e,f,g)&&(h={distance:a.distanceTo(l),point:l.clone(),face:h,object:i},o.push(h))
THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,j=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,l,h){j=!1;b=f;c=g;d=l;e=h;a()};this.addPoint=function(f,g){j?(j=!1,b=f,c=g,d=f,e=g):(b=b<f?b:f,c=c<g?c:g,d=d>f?d:f,e=e>g?e:g);a()};this.add3Points=
function(f,g,l,h,m,o){j?(j=!1,b=f<l?f<m?f:m:l<m?l:m,c=g<h?g<o?g:o:h<o?h:o,d=f>l?f>m?f:m:l>m?l:m,e=g>h?g>o?g:o:h>o?h:o):(b=f<l?f<m?f<b?f:b:m<b?m:b:l<m?l<b?l:b:m<b?m:b,c=g<h?g<o?g<c?g:c:o<c?o:c:h<o?h<c?h:c:o<c?o:c,d=f>l?f>m?f>d?f:d:m>d?m:d:l>m?l>d?l:d:m>d?m:d,e=g>h?g>o?g>e?g:e:o>e?o:e:h>o?h>e?h:e:o>e?o:e);a()};this.addRectangle=function(f){j?(j=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),d=d>f.getRight()?d:f.getRight(),e=e>
f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d<f.getRight()?d:f.getRight();e=e<f.getBottom()?e:f.getBottom();a()};this.intersects=function(a){return Math.min(d,a.getRight())-Math.max(b,a.getLeft())>=0&&Math.min(e,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){j=!0;e=d=c=b=0;a()};this.isEmpty=function(){return j}};
THREE.Math={clamp:function(a,b,c){return a<b?b:a>c?c:a},clampBottom:function(a,b){return a<b?b:a},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},random16:function(){return(65280*Math.random()+255*Math.random())/65535}};THREE.Matrix3=function(){this.m=[]};
THREE.Math={clamp:function(a,b,c){return a<b?b:a>c?c:a},clampBottom:function(a,b){return a<b?b:a},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(0.5-Math.random())}};THREE.Matrix3=function(){this.m=[]};
THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
THREE.Matrix4=function(a,b,c,d,e,f,g,j,n,k,l,h,m,o,p,i){this.set(a!==void 0?a:1,b||0,c||0,d||0,e||0,f!==void 0?f:1,g||0,j||0,n||0,k||0,l!==void 0?l:1,h||0,m||0,o||0,p||0,i!==void 0?i:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,j,n,k,l,h,m,o,p,i){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=j;this.n31=n;this.n32=k;this.n33=l;this.n34=h;this.n41=m;this.n42=o;this.n43=p;this.n44=i;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
......
......@@ -24,7 +24,7 @@ e,f,g)&&(m={distance:a.distanceTo(j),point:j.clone(),face:m,object:k},n.push(m))
THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,j,k){h=!1;b=f;c=g;d=j;e=k;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=b<f?b:f,c=c<g?c:g,d=d>f?d:f,e=e>g?e:g);a()};this.add3Points=
function(f,g,j,k,m,n){h?(h=!1,b=f<j?f<m?f:m:j<m?j:m,c=g<k?g<n?g:n:k<n?k:n,d=f>j?f>m?f:m:j>m?j:m,e=g>k?g>n?g:n:k>n?k:n):(b=f<j?f<m?f<b?f:b:m<b?m:b:j<m?j<b?j:b:m<b?m:b,c=g<k?g<n?g<c?g:c:n<c?n:c:k<n?k<c?k:c:n<c?n:c,d=f>j?f>m?f>d?f:d:m>d?m:d:j>m?j>d?j:d:m>d?m:d,e=g>k?g>n?g>e?g:e:n>e?n:e:k>n?k>e?k:e:n>e?n:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),d=d>f.getRight()?d:f.getRight(),e=e>
f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d<f.getRight()?d:f.getRight();e=e<f.getBottom()?e:f.getBottom();a()};this.intersects=function(a){return Math.min(d,a.getRight())-Math.max(b,a.getLeft())>=0&&Math.min(e,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};
THREE.Math={clamp:function(a,b,c){return a<b?b:a>c?c:a},clampBottom:function(a,b){return a<b?b:a},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},random16:function(){return(65280*Math.random()+255*Math.random())/65535}};THREE.Matrix3=function(){this.m=[]};
THREE.Math={clamp:function(a,b,c){return a<b?b:a>c?c:a},clampBottom:function(a,b){return a<b?b:a},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(0.5-Math.random())}};THREE.Matrix3=function(){this.m=[]};
THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
THREE.Matrix4=function(a,b,c,d,e,f,g,h,l,i,j,k,m,n,p,o){this.set(a!==void 0?a:1,b||0,c||0,d||0,e||0,f!==void 0?f:1,g||0,h||0,l||0,i||0,j!==void 0?j:1,k||0,m||0,n||0,p||0,o!==void 0?o:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,l,i,j,k,m,n,p,o){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=h;this.n31=l;this.n32=i;this.n33=j;this.n34=k;this.n41=m;this.n42=n;this.n43=p;this.n44=o;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
......
......@@ -24,7 +24,7 @@ e,f,g)&&(m={distance:a.distanceTo(k),point:k.clone(),face:m,object:j},n.push(m))
THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,k,j){h=!1;b=f;c=g;d=k;e=j;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=b<f?b:f,c=c<g?c:g,d=d>f?d:f,e=e>g?e:g);a()};this.add3Points=
function(f,g,k,j,n,m){h?(h=!1,b=f<k?f<n?f:n:k<n?k:n,c=g<j?g<m?g:m:j<m?j:m,d=f>k?f>n?f:n:k>n?k:n,e=g>j?g>m?g:m:j>m?j:m):(b=f<k?f<n?f<b?f:b:n<b?n:b:k<n?k<b?k:b:n<b?n:b,c=g<j?g<m?g<c?g:c:m<c?m:c:j<m?j<c?j:c:m<c?m:c,d=f>k?f>n?f>d?f:d:n>d?n:d:k>n?k>d?k:d:n>d?n:d,e=g>j?g>m?g>e?g:e:m>e?m:e:j>m?j>e?j:e:m>e?m:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),d=d>f.getRight()?d:f.getRight(),e=e>
f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d<f.getRight()?d:f.getRight();e=e<f.getBottom()?e:f.getBottom();a()};this.intersects=function(a){return Math.min(d,a.getRight())-Math.max(b,a.getLeft())>=0&&Math.min(e,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};
THREE.Math={clamp:function(a,b,c){return a<b?b:a>c?c:a},clampBottom:function(a,b){return a<b?b:a},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},random16:function(){return(65280*Math.random()+255*Math.random())/65535}};THREE.Matrix3=function(){this.m=[]};
THREE.Math={clamp:function(a,b,c){return a<b?b:a>c?c:a},clampBottom:function(a,b){return a<b?b:a},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(0.5-Math.random())}};THREE.Matrix3=function(){this.m=[]};
THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
THREE.Matrix4=function(a,b,c,d,e,f,g,h,l,i,k,j,n,m,o,p){this.set(a!==void 0?a:1,b||0,c||0,d||0,e||0,f!==void 0?f:1,g||0,h||0,l||0,i||0,k!==void 0?k:1,j||0,n||0,m||0,o||0,p!==void 0?p:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,l,i,k,j,n,m,o,p){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=h;this.n31=l;this.n32=i;this.n33=k;this.n34=j;this.n41=n;this.n42=m;this.n43=o;this.n44=p;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
......
......@@ -24,7 +24,7 @@ f,g,h)&&(w={distance:a.distanceTo(j),point:j.clone(),face:w,object:n},p.push(w))
THREE.Rectangle=function(){function a(){g=c-b;h=f-d}var b,d,c,f,g,h,i=!0;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return c};this.getBottom=function(){return f};this.set=function(g,h,j,p){i=!1;b=g;d=h;c=j;f=p;a()};this.addPoint=function(g,h){i?(i=!1,b=g,d=h,c=g,f=h):(b=b<g?b:g,d=d<h?d:h,c=c>g?c:g,f=f>h?f:h);a()};this.add3Points=
function(g,h,j,p,s,w){i?(i=!1,b=g<j?g<s?g:s:j<s?j:s,d=h<p?h<w?h:w:p<w?p:w,c=g>j?g>s?g:s:j>s?j:s,f=h>p?h>w?h:w:p>w?p:w):(b=g<j?g<s?g<b?g:b:s<b?s:b:j<s?j<b?j:b:s<b?s:b,d=h<p?h<w?h<d?h:d:w<d?w:d:p<w?p<d?p:d:w<d?w:d,c=g>j?g>s?g>c?g:c:s>c?s:c:j>s?j>c?j:c:s>c?s:c,f=h>p?h>w?h>f?h:f:w>f?w:f:p>w?p>f?p:f:w>f?w:f);a()};this.addRectangle=function(g){i?(i=!1,b=g.getLeft(),d=g.getTop(),c=g.getRight(),f=g.getBottom()):(b=b<g.getLeft()?b:g.getLeft(),d=d<g.getTop()?d:g.getTop(),c=c>g.getRight()?c:g.getRight(),f=f>
g.getBottom()?f:g.getBottom());a()};this.inflate=function(g){b-=g;d-=g;c+=g;f+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();d=d>g.getTop()?d:g.getTop();c=c<g.getRight()?c:g.getRight();f=f<g.getBottom()?f:g.getBottom();a()};this.intersects=function(a){return Math.min(c,a.getRight())-Math.max(b,a.getLeft())>=0&&Math.min(f,a.getBottom())-Math.max(d,a.getTop())>=0};this.empty=function(){i=!0;f=c=d=b=0;a()};this.isEmpty=function(){return i}};
THREE.Math={clamp:function(a,b,d){return a<b?b:a>d?d:a},clampBottom:function(a,b){return a<b?b:a},mapLinear:function(a,b,d,c,f){return c+(a-b)*(f-c)/(d-b)},random16:function(){return(65280*Math.random()+255*Math.random())/65535}};THREE.Matrix3=function(){this.m=[]};
THREE.Math={clamp:function(a,b,d){return a<b?b:a>d?d:a},clampBottom:function(a,b){return a<b?b:a},mapLinear:function(a,b,d,c,f){return c+(a-b)*(f-c)/(d-b)},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(0.5-Math.random())}};THREE.Matrix3=function(){this.m=[]};
THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
THREE.Matrix4=function(a,b,d,c,f,g,h,i,l,k,j,p,s,w,n,E){this.set(a!==void 0?a:1,b||0,d||0,c||0,f||0,g!==void 0?g:1,h||0,i||0,l||0,k||0,j!==void 0?j:1,p||0,s||0,w||0,n||0,E!==void 0?E:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,d,c,f,g,h,i,l,k,j,p,s,w,n,E){this.n11=a;this.n12=b;this.n13=d;this.n14=c;this.n21=f;this.n22=g;this.n23=h;this.n24=i;this.n31=l;this.n32=k;this.n33=j;this.n34=p;this.n41=s;this.n42=w;this.n43=n;this.n44=E;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
......
......@@ -4,31 +4,61 @@
THREE.Math = {
// Clamp value to range <a, b>
clamp: function ( x, a, b ) {
return ( x < a ) ? a : ( ( x > b ) ? b : x );
},
// Clamp value to range <a, inf)
clampBottom: function ( x, a ) {
return x < a ? a : x;
},
mapLinear: function( x, a1, a2, b1, b2 ) {
// Linear mapping from range <a1, a2> to range <b1, b2>
mapLinear: function ( x, a1, a2, b1, b2 ) {
return b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 );
},
// Get 16 bits of randomness
// Random float from <0, 1> with 16 bits of randomness
// (standard Math.random() creates repetitive patterns when applied over larger space)
random16: function() {
random16: function () {
return ( 65280 * Math.random() + 255 * Math.random() ) / 65535;
},
// Random integer from <low, high> interval
randInt: function ( low, high ) {
return low + Math.floor( Math.random() * ( high - low + 1 ) );
},
// Random float from <low, high> interval
randFloat: function ( low, high ) {
return low + Math.random() * ( high - low );
},
// Random float from <-range/2, range/2> interval
randFloatSpread: function ( range ) {
return range * ( 0.5 - Math.random() );
}
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册