浏览代码

Moved "extras/MathUtils" to "core/Math" (thanks to @mrdoob).

alteredq 14 年之前
父节点
当前提交
89bddf3827

+ 8 - 8
build/Three.js

@@ -20,8 +20,8 @@ this.direction,b.matrixWorld.getPosition());if(k==null||k>b.geometry.boundingSph
 w=f instanceof THREE.Face4?w.multiplyVector3(y[f.d].position.clone()):null,u=b.matrixRotationWorld.multiplyVector3(f.normal.clone()),x=A.dot(u),b.doubleSided||(b.flipSided?x>0:x<0)))if(x=u.dot((new THREE.Vector3).sub(n,v))/x,v=v.addSelf(A.multiplyScalar(x)),f instanceof THREE.Face3)e(v,n,p,t)&&(f={distance:this.origin.distanceTo(v),point:v,face:f,object:b},h.push(f));else if(f instanceof THREE.Face4&&(e(v,n,p,w)||e(v,p,t,w)))f={distance:this.origin.distanceTo(v),point:v,face:f,object:b},h.push(f)}return h}};
 THREE.Rectangle=function(){function b(){k=f-c;m=h-e}var c,e,f,h,k,m,n=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return k};this.getHeight=function(){return m};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(k,m,w,u){n=!1;c=k;e=m;f=w;h=u;b()};this.addPoint=function(k,m){n?(n=!1,c=k,e=m,f=k,h=m):(c=c<k?c:k,e=e<m?e:m,f=f>k?f:k,h=h>m?h:m);b()};this.add3Points=
 function(k,m,w,u,x,v){n?(n=!1,c=k<w?k<x?k:x:w<x?w:x,e=m<u?m<v?m:v:u<v?u:v,f=k>w?k>x?k:x:w>x?w:x,h=m>u?m>v?m:v:u>v?u:v):(c=k<w?k<x?k<c?k:c:x<c?x:c:w<x?w<c?w:c:x<c?x:c,e=m<u?m<v?m<e?m:e:v<e?v:e:u<v?u<e?u:e:v<e?v:e,f=k>w?k>x?k>f?k:f:x>f?x:f:w>x?w>f?w:f:x>f?x:f,h=m>u?m>v?m>h?m:h:v>h?v:h:u>v?u>h?u:h:v>h?v:h);b()};this.addRectangle=function(k){n?(n=!1,c=k.getLeft(),e=k.getTop(),f=k.getRight(),h=k.getBottom()):(c=c<k.getLeft()?c:k.getLeft(),e=e<k.getTop()?e:k.getTop(),f=f>k.getRight()?f:k.getRight(),h=h>
-k.getBottom()?h:k.getBottom());b()};this.inflate=function(k){c-=k;e-=k;f+=k;h+=k;b()};this.minSelf=function(k){c=c>k.getLeft()?c:k.getLeft();e=e>k.getTop()?e:k.getTop();f=f<k.getRight()?f:k.getRight();h=h<k.getBottom()?h:k.getBottom();b()};this.intersects=function(b){return Math.min(f,b.getRight())-Math.max(c,b.getLeft())>=0&&Math.min(h,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){n=!0;h=f=e=c=0;b()};this.isEmpty=function(){return n}};THREE.Matrix3=function(){this.m=[]};
-THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}};
+k.getBottom()?h:k.getBottom());b()};this.inflate=function(k){c-=k;e-=k;f+=k;h+=k;b()};this.minSelf=function(k){c=c>k.getLeft()?c:k.getLeft();e=e>k.getTop()?e:k.getTop();f=f<k.getRight()?f:k.getRight();h=h<k.getBottom()?h:k.getBottom();b()};this.intersects=function(b){return Math.min(f,b.getRight())-Math.max(c,b.getLeft())>=0&&Math.min(h,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){n=!0;h=f=e=c=0;b()};this.isEmpty=function(){return n}};
+THREE.Math={clamp:function(b,c,e){return b<c?c:b>e?e:b},clampBottom:function(b,c){return b<c?c:b},mapLinear:function(b,c,e,f,h){return f+(b-c)*(h-f)/(e-c)}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}};
 THREE.Matrix4=function(b,c,e,f,h,k,m,n,p,t,w,u,x,v,A,z){this.set(b!==void 0?b:1,c||0,e||0,f||0,h||0,k!==void 0?k:1,m||0,n||0,p||0,t||0,w!==void 0?w:1,u||0,x||0,v||0,A||0,z!==void 0?z:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
 THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,e,f,h,k,m,n,p,t,w,u,x,v,A,z){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=h;this.n22=k;this.n23=m;this.n24=n;this.n31=p;this.n32=t;this.n33=w;this.n34=u;this.n41=x;this.n42=v;this.n43=A;this.n44=z;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(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,
 c,e){var f=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,k=THREE.Matrix4.__v3;k.sub(b,c).normalize();if(k.length()===0)k.z=1;f.cross(e,k).normalize();f.length()===0&&(k.x+=1.0E-4,f.cross(e,k).normalize());h.cross(k,f).normalize();this.n11=f.x;this.n12=h.x;this.n13=k.x;this.n21=f.y;this.n22=h.y;this.n23=k.y;this.n31=f.z;this.n32=h.z;this.n33=k.z;return this},multiplyVector3:function(b){var c=b.x,e=b.y,f=b.z,h=1/(this.n41*c+this.n42*e+this.n43*f+this.n44);b.x=(this.n11*c+this.n12*e+this.n13*f+this.n14)*h;
@@ -136,7 +136,7 @@ c*16)}};THREE.SkinnedMesh.prototype.addBone=function(b){b===void 0&&(b=new THREE
 THREE.SkinnedMesh.prototype.pose=function(){this.update(void 0,!0);for(var b,c=[],e=0;e<this.bones.length;e++)b=this.bones[e],c.push(THREE.Matrix4.makeInvert(b.skinMatrix)),b.skinMatrix.flattenToArrayOffset(this.boneMatrices,e*16);if(this.geometry.skinVerticesA===void 0){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var f;for(b=0;b<this.geometry.skinIndices.length;b++){var e=this.geometry.vertices[b].position,h=this.geometry.skinIndices[b].x,k=this.geometry.skinIndices[b].y;f=new THREE.Vector3(e.x,
 e.y,e.z);this.geometry.skinVerticesA.push(c[h].multiplyVector3(f));f=new THREE.Vector3(e.x,e.y,e.z);this.geometry.skinVerticesB.push(c[k].multiplyVector3(f));this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y!==1&&(e=(1-(this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y))*0.5,this.geometry.skinWeights[b].x+=e,this.geometry.skinWeights[b].y+=e)}}};
 THREE.MorphAnimMesh=function(b,c){THREE.Mesh.call(this,b,c);this.duration=1E3;this.mirroredLoop=!1;this.currentKeyframe=this.lastKeyframe=this.time=0;this.direction=1;this.directionBackwards=!1};THREE.MorphAnimMesh.prototype=new THREE.Mesh;THREE.MorphAnimMesh.prototype.constructor=THREE.MorphAnimMesh;
-THREE.MorphAnimMesh.prototype.updateAnimation=function(b){var c=this.duration/(this.geometry.morphTargets.length-1);this.time+=this.direction*b;if(this.mirroredLoop){if(this.time>this.duration||this.time<0){this.direction*=-1;if(this.time>this.duration)this.time=this.duration,this.directionBackwards=!0;if(this.time<0)this.time=0,this.directionBackwards=!1}}else this.time%=this.duration;b=THREE.MathUtils.clamp(Math.floor(this.time/c),0,this.geometry.morphTargets.length-1);if(b!=this.currentKeyframe)this.morphTargetInfluences[this.lastKeyframe]=
+THREE.MorphAnimMesh.prototype.updateAnimation=function(b){var c=this.duration/(this.geometry.morphTargets.length-1);this.time+=this.direction*b;if(this.mirroredLoop){if(this.time>this.duration||this.time<0){this.direction*=-1;if(this.time>this.duration)this.time=this.duration,this.directionBackwards=!0;if(this.time<0)this.time=0,this.directionBackwards=!1}}else this.time%=this.duration;b=THREE.Math.clamp(Math.floor(this.time/c),0,this.geometry.morphTargets.length-1);if(b!=this.currentKeyframe)this.morphTargetInfluences[this.lastKeyframe]=
 0,this.morphTargetInfluences[this.currentKeyframe]=1,this.morphTargetInfluences[b]=0,this.lastKeyframe=this.currentKeyframe,this.currentKeyframe=b;c=this.time%c/c;this.directionBackwards&&(c=1-c);this.morphTargetInfluences[this.currentKeyframe]=c;this.morphTargetInfluences[this.lastKeyframe]=1-c};THREE.Ribbon=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c]};THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;
 THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.addLevel=function(b,c){c===void 0&&(c=0);for(var c=Math.abs(c),e=0;e<this.LODs.length;e++)if(c<this.LODs[e].visibleAtDistance)break;this.LODs.splice(e,0,{visibleAtDistance:c,object3D:b});this.add(b)};
 THREE.LOD.prototype.update=function(b,c,e){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;if(this.LODs.length>1){b=e.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var f=1;f<this.LODs.length;f++)if(b>=this.LODs[f].visibleAtDistance)this.LODs[f-1].object3D.visible=!1,
@@ -350,7 +350,7 @@ THREE.WebGLRenderTargetCube.prototype=new THREE.WebGLRenderTarget;THREE.WebGLRen
 THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.materials=null};
-THREE.ColorUtils={adjustHSV:function(b,c,e,f){var h=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(b,h);h.h=THREE.MathUtils.clamp(h.h+c,0,1);h.s=THREE.MathUtils.clamp(h.s+e,0,1);h.v=THREE.MathUtils.clamp(h.v+f,0,1);b.setHSV(h.h,h.s,h.v)},rgbToHsv:function(b,c){var e=b.r,f=b.g,h=b.b,k=Math.max(Math.max(e,f),h),m=Math.min(Math.min(e,f),h);if(m==k)m=e=0;else{var n=k-m,m=n/k,e=e==k?(f-h)/n:f==k?2+(h-e)/n:4+(e-f)/n;e/=6;e<0&&(e+=1);e>1&&(e-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=e;c.s=m;c.v=k;return c}};
+THREE.ColorUtils={adjustHSV:function(b,c,e,f){var h=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(b,h);h.h=THREE.Math.clamp(h.h+c,0,1);h.s=THREE.Math.clamp(h.s+e,0,1);h.v=THREE.Math.clamp(h.v+f,0,1);b.setHSV(h.h,h.s,h.v)},rgbToHsv:function(b,c){var e=b.r,f=b.g,h=b.b,k=Math.max(Math.max(e,f),h),m=Math.min(Math.min(e,f),h);if(m==k)m=e=0;else{var n=k-m,m=n/k,e=e==k?(f-h)/n:f==k?2+(h-e)/n:4+(e-f)/n;e/=6;e<0&&(e+=1);e>1&&(e-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=e;c.s=m;c.v=k;return c}};
 THREE.ColorUtils.__hsv={h:0,s:0,v:0};
 THREE.GeometryUtils={merge:function(b,c){var e,f,h=b.vertices.length,k=c instanceof THREE.Mesh?c.geometry:c,m=b.vertices,n=k.vertices,p=b.faces,t=k.faces,w=b.faceVertexUvs[0],k=k.faceVertexUvs[0];if(c instanceof THREE.Mesh)c.matrixAutoUpdate&&c.updateMatrix(),e=c.matrix,f=new THREE.Matrix4,f.extractRotation(e,c.scale);for(var u=0,x=n.length;u<x;u++){var v=new THREE.Vertex(n[u].position.clone());e&&e.multiplyVector3(v.position);m.push(v)}u=0;for(x=t.length;u<x;u++){var v=t[u],A,z,y=v.vertexNormals,
 E=v.vertexColors;v instanceof THREE.Face3?A=new THREE.Face3(v.a+h,v.b+h,v.c+h):v instanceof THREE.Face4&&(A=new THREE.Face4(v.a+h,v.b+h,v.c+h,v.d+h));A.normal.copy(v.normal);f&&f.multiplyVector3(A.normal);m=0;for(n=y.length;m<n;m++)z=y[m].clone(),f&&f.multiplyVector3(z),A.vertexNormals.push(z);A.color.copy(v.color);m=0;for(n=E.length;m<n;m++)z=E[m],A.vertexColors.push(z.clone());A.materials=v.materials.slice();A.centroid.copy(v.centroid);e&&e.multiplyVector3(A.centroid);p.push(A)}u=0;for(x=k.length;u<
@@ -364,7 +364,7 @@ t[h]=p}f=[];m={};for(h=0;h<c;h++)n=THREE.GeometryUtils.random()*p,n=e(n),f[h]=TH
 THREE.ImageUtils={loadTexture:function(b,c,e){var f=new Image,h=new THREE.Texture(f,c);f.onload=function(){h.needsUpdate=!0;e&&e(this)};f.crossOrigin="";f.src=b;return h},loadTextureCube:function(b,c,e){var f,h=[],k=new THREE.Texture(h,c),c=h.loadCount=0;for(f=b.length;c<f;++c)h[c]=new Image,h[c].onload=function(){h.loadCount+=1;if(h.loadCount==6)k.needsUpdate=!0;e&&e(this)},h[c].crossOrigin="",h[c].src=b[c];return k},getNormalMap:function(b,c){var e=function(b){var c=Math.sqrt(b[0]*b[0]+b[1]*b[1]+
 b[2]*b[2]);return[b[0]/c,b[1]/c,b[2]/c]};c|=1;var f=b.width,h=b.height,k=document.createElement("canvas");k.width=f;k.height=h;var m=k.getContext("2d");m.drawImage(b,0,0);for(var n=m.getImageData(0,0,f,h).data,p=m.createImageData(f,h),t=p.data,w=0;w<f;w++)for(var u=1;u<h;u++){var x=u-1<0?h-1:u-1,v=(u+1)%h,A=w-1<0?f-1:w-1,z=(w+1)%f,y=[],E=[0,0,n[(u*f+w)*4]/255*c];y.push([-1,0,n[(u*f+A)*4]/255*c]);y.push([-1,-1,n[(x*f+A)*4]/255*c]);y.push([0,-1,n[(x*f+w)*4]/255*c]);y.push([1,-1,n[(x*f+z)*4]/255*c]);
 y.push([1,0,n[(u*f+z)*4]/255*c]);y.push([1,1,n[(v*f+z)*4]/255*c]);y.push([0,1,n[(v*f+w)*4]/255*c]);y.push([-1,1,n[(v*f+A)*4]/255*c]);x=[];A=y.length;for(v=0;v<A;v++){var z=y[v],F=y[(v+1)%A],z=[z[0]-E[0],z[1]-E[1],z[2]-E[2]],F=[F[0]-E[0],F[1]-E[1],F[2]-E[2]];x.push(e([z[1]*F[2]-z[2]*F[1],z[2]*F[0]-z[0]*F[2],z[0]*F[1]-z[1]*F[0]]))}y=[0,0,0];for(v=0;v<x.length;v++)y[0]+=x[v][0],y[1]+=x[v][1],y[2]+=x[v][2];y[0]/=x.length;y[1]/=x.length;y[2]/=x.length;E=(u*f+w)*4;t[E]=(y[0]+1)/2*255|0;t[E+1]=(y[1]+0.5)*
-255|0;t[E+2]=y[2]*255|0;t[E+3]=255}m.putImageData(p,0,0);return k}};THREE.MathUtils={clamp:function(b,c,e){return b<c?c:b>e?e:b},clampBottom:function(b,c){return b<c?c:b},mapLinear:function(b,c,e,f,h){return f+(b-c)*(h-f)/(e-c)}};THREE.SceneUtils={showHierarchy:function(b,c){THREE.SceneUtils.traverseHierarchy(b,function(b){b.visible=c})},traverseHierarchy:function(b,c){var e,f,h=b.children.length;for(f=0;f<h;f++)e=b.children[f],c(e),THREE.SceneUtils.traverseHierarchy(e,c)}};
+255|0;t[E+2]=y[2]*255|0;t[E+3]=255}m.putImageData(p,0,0);return k}};THREE.SceneUtils={showHierarchy:function(b,c){THREE.SceneUtils.traverseHierarchy(b,function(b){b.visible=c})},traverseHierarchy:function(b,c){var e,f,h=b.children.length;for(f=0;f<h;f++)e=b.children[f],c(e),THREE.SceneUtils.traverseHierarchy(e,c)}};
 if(THREE.WebGLRenderer)THREE.ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
 vertexShader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
 normal:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},enableReflection:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tCube:{type:"t",value:1,texture:null},tNormal:{type:"t",value:2,texture:null},tSpecular:{type:"t",value:3,texture:null},tAO:{type:"t",value:4,texture:null},tDisplacement:{type:"t",value:5,texture:null},uNormalScale:{type:"f",
@@ -448,16 +448,16 @@ THREE.FirstPersonControls=function(b,c){function e(b,e){return function(){e.appl
 this.mouseY=this.mouseX=this.autoSpeedFactor=this.tdiff=0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));this.onMouseDown=function(b){this.domElement!==document&&this.domElement.focus();b.preventDefault();b.stopPropagation();
 if(this.activeLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(b){this.domElement===document?(this.mouseX=b.pageX-this.viewHalfX,this.mouseY=b.pageY-this.viewHalfY):(this.mouseX=b.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=
 b.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=
-!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp=!1;break;case 70:this.moveDown=!1}};this.update=function(){var b=(new Date).getTime();this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;if(!this.freeze){this.autoSpeedFactor=this.heightSpeed?this.tdiff*(THREE.MathUtils.clamp(this.object.position.y,this.heightMin,this.heightMax)-this.heightMin)*this.heightCoef:0;var e=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.object.translateZ(-(e+
+!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp=!1;break;case 70:this.moveDown=!1}};this.update=function(){var b=(new Date).getTime();this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;if(!this.freeze){this.autoSpeedFactor=this.heightSpeed?this.tdiff*(THREE.Math.clamp(this.object.position.y,this.heightMin,this.heightMax)-this.heightMin)*this.heightCoef:0;var e=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.object.translateZ(-(e+
 this.autoSpeedFactor));this.moveBackward&&this.object.translateZ(e);this.moveLeft&&this.object.translateX(-e);this.moveRight&&this.object.translateX(e);this.moveUp&&this.object.translateY(e);this.moveDown&&this.object.translateY(-e);e=this.tdiff*this.lookSpeed;this.activeLook||(e=0);this.lon+=this.mouseX*e;this.lookVertical&&(this.lat-=this.mouseY*e);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=this.target,c=this.object.position;
-b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta)}b=1;this.constrainVertical&&(b=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*e;this.lookVertical&&(this.lat-=this.mouseY*e*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.MathUtils.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);
+b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta)}b=1;this.constrainVertical&&(b=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*e;this.lookVertical&&(this.lat-=this.mouseY*e*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);
 b=this.target;c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(b)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",e(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",e(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",e(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",
 e(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",e(this,this.onKeyUp),!1)};
 THREE.PathControls=function(b,c){function e(b){if((b*=2)<1)return 0.5*b*b;return-0.5*(--b*(b-2)-1)}function f(b,e){return function(){e.apply(b,arguments)}}function h(b,e,c,f){var k={name:c,fps:0.6,length:f,hierarchy:[]},h,m=e.getControlPointsArray(),n=e.getLength(),y=m.length,E=0;h=y-1;e={parent:-1,keys:[]};e.keys[0]={time:0,pos:m[0],rot:[0,0,0,1],scl:[1,1,1]};e.keys[h]={time:f,pos:m[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h<y-1;h++)E=f*n.chunks[h]/n.total,e.keys[h]={time:E,pos:m[h]};k.hierarchy[0]=
 e;THREE.AnimationHandler.add(k);return new THREE.Animation(b,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function k(b,e){var c,f,k=new THREE.Geometry;for(c=0;c<b.points.length*e;c++)f=c/(b.points.length*e),f=b.getPoint(f),k.vertices[c]=new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z));return k}this.object=b;this.domElement=c!==void 0?c:document;this.id="PathControls"+THREE.PathControlsIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=
 new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookHorizontal=this.lookVertical=!0;this.verticalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.horizontalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.target=new THREE.Object3D;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=
 this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));var m=Math.PI*2,n=Math.PI/180;this.update=function(){var b,c;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*n;this.theta=this.lon*n;c=this.phi%m;this.phi=c>=0?c:c+m;b=this.verticalAngleMap.srcRange;
-c=this.verticalAngleMap.dstRange;b=THREE.MathUtils.mapLinear(this.phi,b[0],b[1],c[0],c[1]);var f=c[1]-c[0];this.phi=e((b-c[0])/f)*f+c[0];b=this.horizontalAngleMap.srcRange;c=this.horizontalAngleMap.dstRange;b=THREE.MathUtils.mapLinear(this.theta,b[0],b[1],c[0],c[1]);f=c[1]-c[0];this.theta=e((b-c[0])/f)*f+c[0];c=this.target.position;c.x=100*Math.sin(this.phi)*Math.cos(this.theta);c.y=100*Math.cos(this.phi);c.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=
+c=this.verticalAngleMap.dstRange;b=THREE.Math.mapLinear(this.phi,b[0],b[1],c[0],c[1]);var f=c[1]-c[0];this.phi=e((b-c[0])/f)*f+c[0];b=this.horizontalAngleMap.srcRange;c=this.horizontalAngleMap.dstRange;b=THREE.Math.mapLinear(this.theta,b[0],b[1],c[0],c[1]);f=c[1]-c[0];this.theta=e((b-c[0])/f)*f+c[0];c=this.target.position;c.x=100*Math.sin(this.phi)*Math.cos(this.theta);c.y=100*Math.cos(this.phi);c.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=
 function(b){this.domElement===document?(this.mouseX=b.pageX-this.viewHalfX,this.mouseY=b.pageY-this.viewHalfY):(this.mouseX=b.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=b.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var b=new THREE.MeshLambertMaterial({color:30719}),c=new THREE.MeshLambertMaterial({color:65280}),
 e=new THREE.CubeGeometry(10,10,20),m=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(e,b);b=new THREE.Mesh(m,c);b.position.set(0,10,0);this.animation=h(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(b)}else this.animation=h(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var b=
 this.debugPath,c=this.spline,e=k(c,10),m=k(c,10),n=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(e,n);particleObj=new THREE.ParticleSystem(m,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);b.add(lineObj);particleObj.scale.set(1,1,1);b.add(particleObj);m=new THREE.SphereGeometry(1,16,8);n=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<c.points.length;i++)e=new THREE.Mesh(m,n),e.position.copy(c.points[i]),b.add(e)}this.domElement.addEventListener("mousemove",

+ 7 - 7
build/custom/ThreeExtras.js

@@ -1,5 +1,5 @@
 // ThreeExtras.js r46dev - http://github.com/mrdoob/three.js
-THREE.ColorUtils={adjustHSV:function(a,b,c,e){var f=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,f);f.h=THREE.MathUtils.clamp(f.h+b,0,1);f.s=THREE.MathUtils.clamp(f.s+c,0,1);f.v=THREE.MathUtils.clamp(f.v+e,0,1);a.setHSV(f.h,f.s,f.v)},rgbToHsv:function(a,b){var c=a.r,e=a.g,f=a.b,h=Math.max(Math.max(c,e),f),g=Math.min(Math.min(c,e),f);if(g==h)g=c=0;else{var k=h-g,g=k/h,c=c==h?(e-f)/k:e==h?2+(f-c)/k:4+(c-e)/k;c/=6;c<0&&(c+=1);c>1&&(c-=1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=g;b.v=h;return b}};
+THREE.ColorUtils={adjustHSV:function(a,b,c,e){var f=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,f);f.h=THREE.Math.clamp(f.h+b,0,1);f.s=THREE.Math.clamp(f.s+c,0,1);f.v=THREE.Math.clamp(f.v+e,0,1);a.setHSV(f.h,f.s,f.v)},rgbToHsv:function(a,b){var c=a.r,e=a.g,f=a.b,h=Math.max(Math.max(c,e),f),g=Math.min(Math.min(c,e),f);if(g==h)g=c=0;else{var k=h-g,g=k/h,c=c==h?(e-f)/k:e==h?2+(f-c)/k:4+(c-e)/k;c/=6;c<0&&(c+=1);c>1&&(c-=1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=g;b.v=h;return b}};
 THREE.ColorUtils.__hsv={h:0,s:0,v:0};
 THREE.GeometryUtils={merge:function(a,b){var c,e,f=a.vertices.length,h=b instanceof THREE.Mesh?b.geometry:b,g=a.vertices,k=h.vertices,l=a.faces,m=h.faces,n=a.faceVertexUvs[0],h=h.faceVertexUvs[0];if(b instanceof THREE.Mesh)b.matrixAutoUpdate&&b.updateMatrix(),c=b.matrix,e=new THREE.Matrix4,e.extractRotation(c,b.scale);for(var o=0,t=k.length;o<t;o++){var u=new THREE.Vertex(k[o].position.clone());c&&c.multiplyVector3(u.position);g.push(u)}o=0;for(t=m.length;o<t;o++){var u=m[o],v,y,p=u.vertexNormals,
 z=u.vertexColors;u instanceof THREE.Face3?v=new THREE.Face3(u.a+f,u.b+f,u.c+f):u instanceof THREE.Face4&&(v=new THREE.Face4(u.a+f,u.b+f,u.c+f,u.d+f));v.normal.copy(u.normal);e&&e.multiplyVector3(v.normal);g=0;for(k=p.length;g<k;g++)y=p[g].clone(),e&&e.multiplyVector3(y),v.vertexNormals.push(y);v.color.copy(u.color);g=0;for(k=z.length;g<k;g++)y=z[g],v.vertexColors.push(y.clone());v.materials=u.materials.slice();v.centroid.copy(u.centroid);c&&c.multiplyVector3(v.centroid);l.push(v)}o=0;for(t=h.length;o<
@@ -13,7 +13,7 @@ m[f]=l}e=[];g={};for(f=0;f<b;f++)k=THREE.GeometryUtils.random()*l,k=c(k),e[f]=TH
 THREE.ImageUtils={loadTexture:function(a,b,c){var e=new Image,f=new THREE.Texture(e,b);e.onload=function(){f.needsUpdate=!0;c&&c(this)};e.crossOrigin="";e.src=a;return f},loadTextureCube:function(a,b,c){var e,f=[],h=new THREE.Texture(f,b),b=f.loadCount=0;for(e=a.length;b<e;++b)f[b]=new Image,f[b].onload=function(){f.loadCount+=1;if(f.loadCount==6)h.needsUpdate=!0;c&&c(this)},f[b].crossOrigin="",f[b].src=a[b];return h},getNormalMap:function(a,b){var c=function(a){var c=Math.sqrt(a[0]*a[0]+a[1]*a[1]+
 a[2]*a[2]);return[a[0]/c,a[1]/c,a[2]/c]};b|=1;var e=a.width,f=a.height,h=document.createElement("canvas");h.width=e;h.height=f;var g=h.getContext("2d");g.drawImage(a,0,0);for(var k=g.getImageData(0,0,e,f).data,l=g.createImageData(e,f),m=l.data,n=0;n<e;n++)for(var o=1;o<f;o++){var t=o-1<0?f-1:o-1,u=(o+1)%f,v=n-1<0?e-1:n-1,y=(n+1)%e,p=[],z=[0,0,k[(o*e+n)*4]/255*b];p.push([-1,0,k[(o*e+v)*4]/255*b]);p.push([-1,-1,k[(t*e+v)*4]/255*b]);p.push([0,-1,k[(t*e+n)*4]/255*b]);p.push([1,-1,k[(t*e+y)*4]/255*b]);
 p.push([1,0,k[(o*e+y)*4]/255*b]);p.push([1,1,k[(u*e+y)*4]/255*b]);p.push([0,1,k[(u*e+n)*4]/255*b]);p.push([-1,1,k[(u*e+v)*4]/255*b]);t=[];v=p.length;for(u=0;u<v;u++){var y=p[u],x=p[(u+1)%v],y=[y[0]-z[0],y[1]-z[1],y[2]-z[2]],x=[x[0]-z[0],x[1]-z[1],x[2]-z[2]];t.push(c([y[1]*x[2]-y[2]*x[1],y[2]*x[0]-y[0]*x[2],y[0]*x[1]-y[1]*x[0]]))}p=[0,0,0];for(u=0;u<t.length;u++)p[0]+=t[u][0],p[1]+=t[u][1],p[2]+=t[u][2];p[0]/=t.length;p[1]/=t.length;p[2]/=t.length;z=(o*e+n)*4;m[z]=(p[0]+1)/2*255|0;m[z+1]=(p[1]+0.5)*
-255|0;m[z+2]=p[2]*255|0;m[z+3]=255}g.putImageData(l,0,0);return h}};THREE.MathUtils={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,e,f){return e+(a-b)*(f-e)/(c-b)}};THREE.SceneUtils={showHierarchy:function(a,b){THREE.SceneUtils.traverseHierarchy(a,function(a){a.visible=b})},traverseHierarchy:function(a,b){var c,e,f=a.children.length;for(e=0;e<f;e++)c=a.children[e],b(c),THREE.SceneUtils.traverseHierarchy(c,b)}};
+255|0;m[z+2]=p[2]*255|0;m[z+3]=255}g.putImageData(l,0,0);return h}};THREE.SceneUtils={showHierarchy:function(a,b){THREE.SceneUtils.traverseHierarchy(a,function(a){a.visible=b})},traverseHierarchy:function(a,b){var c,e,f=a.children.length;for(e=0;e<f;e++)c=a.children[e],b(c),THREE.SceneUtils.traverseHierarchy(c,b)}};
 if(THREE.WebGLRenderer)THREE.ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
 vertexShader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
 normal:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},enableReflection:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tCube:{type:"t",value:1,texture:null},tNormal:{type:"t",value:2,texture:null},tSpecular:{type:"t",value:3,texture:null},tAO:{type:"t",value:4,texture:null},tDisplacement:{type:"t",value:5,texture:null},uNormalScale:{type:"f",
@@ -97,16 +97,16 @@ THREE.FirstPersonControls=function(a,b){function c(a,c){return function(){c.appl
 this.mouseY=this.mouseX=this.autoSpeedFactor=this.tdiff=0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));this.onMouseDown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();
 if(this.activeLook)switch(a.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=
 a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=
-!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp=!1;break;case 70:this.moveDown=!1}};this.update=function(){var a=(new Date).getTime();this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;if(!this.freeze){this.autoSpeedFactor=this.heightSpeed?this.tdiff*(THREE.MathUtils.clamp(this.object.position.y,this.heightMin,this.heightMax)-this.heightMin)*this.heightCoef:0;var c=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.object.translateZ(-(c+
+!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp=!1;break;case 70:this.moveDown=!1}};this.update=function(){var a=(new Date).getTime();this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;if(!this.freeze){this.autoSpeedFactor=this.heightSpeed?this.tdiff*(THREE.Math.clamp(this.object.position.y,this.heightMin,this.heightMax)-this.heightMin)*this.heightCoef:0;var c=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.object.translateZ(-(c+
 this.autoSpeedFactor));this.moveBackward&&this.object.translateZ(c);this.moveLeft&&this.object.translateX(-c);this.moveRight&&this.object.translateX(c);this.moveUp&&this.object.translateY(c);this.moveDown&&this.object.translateY(-c);c=this.tdiff*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var a=this.target,b=this.object.position;
-a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)*Math.sin(this.theta)}a=1;this.constrainVertical&&(a=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c*a);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.MathUtils.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);
+a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)*Math.sin(this.theta)}a=1;this.constrainVertical&&(a=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c*a);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);
 a=this.target;b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(a)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",
 c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};
 THREE.PathControls=function(a,b){function c(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)}function e(a,c){return function(){c.apply(a,arguments)}}function f(a,c,b,e){var g={name:b,fps:0.6,length:e,hierarchy:[]},h,f=c.getControlPointsArray(),k=c.getLength(),p=f.length,z=0;h=p-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:f[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[h]={time:e,pos:f[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h<p-1;h++)z=e*k.chunks[h]/k.total,c.keys[h]={time:z,pos:f[h]};g.hierarchy[0]=
 c;THREE.AnimationHandler.add(g);return new THREE.Animation(a,b,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function h(a,c){var b,e,g=new THREE.Geometry;for(b=0;b<a.points.length*c;b++)e=b/(a.points.length*c),e=a.getPoint(e),g.vertices[b]=new THREE.Vertex(new THREE.Vector3(e.x,e.y,e.z));return g}this.object=a;this.domElement=b!==void 0?b:document;this.id="PathControls"+THREE.PathControlsIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=
 new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookHorizontal=this.lookVertical=!0;this.verticalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.horizontalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.target=new THREE.Object3D;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=
 this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));var g=Math.PI*2,k=Math.PI/180;this.update=function(){var a,b;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*k;this.theta=this.lon*k;b=this.phi%g;this.phi=b>=0?b:b+g;a=this.verticalAngleMap.srcRange;
-b=this.verticalAngleMap.dstRange;a=THREE.MathUtils.mapLinear(this.phi,a[0],a[1],b[0],b[1]);var e=b[1]-b[0];this.phi=c((a-b[0])/e)*e+b[0];a=this.horizontalAngleMap.srcRange;b=this.horizontalAngleMap.dstRange;a=THREE.MathUtils.mapLinear(this.theta,a[0],a[1],b[0],b[1]);e=b[1]-b[0];this.theta=c((a-b[0])/e)*e+b[0];b=this.target.position;b.x=100*Math.sin(this.phi)*Math.cos(this.theta);b.y=100*Math.cos(this.phi);b.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=
+b=this.verticalAngleMap.dstRange;a=THREE.Math.mapLinear(this.phi,a[0],a[1],b[0],b[1]);var e=b[1]-b[0];this.phi=c((a-b[0])/e)*e+b[0];a=this.horizontalAngleMap.srcRange;b=this.horizontalAngleMap.dstRange;a=THREE.Math.mapLinear(this.theta,a[0],a[1],b[0],b[1]);e=b[1]-b[0];this.theta=c((a-b[0])/e)*e+b[0];b=this.target.position;b.x=100*Math.sin(this.phi)*Math.cos(this.theta);b.y=100*Math.cos(this.phi);b.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=
 function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),c=new THREE.MeshLambertMaterial({color:65280}),
 b=new THREE.CubeGeometry(10,10,20),g=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(b,a);a=new THREE.Mesh(g,c);a.position.set(0,10,0);this.animation=f(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=f(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a=
 this.debugPath,c=this.spline,b=h(c,10),g=h(c,10),k=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(b,k);particleObj=new THREE.ParticleSystem(g,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);a.add(lineObj);particleObj.scale.set(1,1,1);a.add(particleObj);g=new THREE.SphereGeometry(1,16,8);k=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<c.points.length;i++)b=new THREE.Mesh(g,k),b.position.copy(c.points[i]),a.add(b)}this.domElement.addEventListener("mousemove",
@@ -212,8 +212,8 @@ m))}function y(c){var b,e,g,h;b=f(a,c);e=f(a,c+P);g=f(a,c+T);c=D[b*2];h=D[b*2+1]
 g));p.push(new THREE.UV(n,h));o.push(p)}var z=this,x=0,w,A=[],D=[],B,E,I,G,K,C,F,J,M,N,L,O,H,Q,P,T,X,R,S,W,U,Z,Y,$,V;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(z,e,c);w={signature:a.substr(x,8),header_bytes:n(a,x+8),vertex_coordinate_bytes:n(a,x+9),normal_coordinate_bytes:n(a,x+10),uv_coordinate_bytes:n(a,x+11),vertex_index_bytes:n(a,x+12),normal_index_bytes:n(a,x+13),uv_index_bytes:n(a,x+14),material_index_bytes:n(a,x+15),nvertices:f(a,x+16),nnormals:f(a,x+16+4),nuvs:f(a,x+16+
 8),ntri_flat:f(a,x+16+12),ntri_smooth:f(a,x+16+16),ntri_flat_uv:f(a,x+16+20),ntri_smooth_uv:f(a,x+16+24),nquad_flat:f(a,x+16+28),nquad_smooth:f(a,x+16+32),nquad_flat_uv:f(a,x+16+36),nquad_smooth_uv:f(a,x+16+40)};x+=w.header_bytes;B=w.vertex_index_bytes;E=w.vertex_index_bytes*2;I=w.vertex_index_bytes*3;G=w.vertex_index_bytes*3+w.material_index_bytes;K=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes;C=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes*2;F=w.vertex_index_bytes;
 J=w.vertex_index_bytes*2;M=w.vertex_index_bytes*3;N=w.vertex_index_bytes*4;L=w.vertex_index_bytes*4+w.material_index_bytes;O=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes;H=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*2;Q=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*3;P=w.uv_index_bytes;T=w.uv_index_bytes*2;X=w.uv_index_bytes;R=w.uv_index_bytes*2;S=w.uv_index_bytes*3;c=w.vertex_index_bytes*3+w.material_index_bytes;V=w.vertex_index_bytes*
-4+w.material_index_bytes;W=w.ntri_flat*c;U=w.ntri_smooth*(c+w.normal_index_bytes*3);Z=w.ntri_flat_uv*(c+w.uv_index_bytes*3);Y=w.ntri_smooth_uv*(c+w.normal_index_bytes*3+w.uv_index_bytes*3);$=w.nquad_flat*V;c=w.nquad_smooth*(V+w.normal_index_bytes*4);V=w.nquad_flat_uv*(V+w.uv_index_bytes*4);x+=function(c){for(var e,f,h,k=w.vertex_coordinate_bytes*3,l=c+w.nvertices*k;c<l;c+=k)e=b(a,c),f=b(a,c+w.vertex_coordinate_bytes),h=b(a,c+w.vertex_coordinate_bytes*2),z.vertices.push(new THREE.Vertex(new THREE.Vector3(e,
-f,h)));return w.nvertices*k}(x);x+=function(c){for(var b,e,g,f=w.normal_coordinate_bytes*3,h=c+w.nnormals*f;c<h;c+=f)b=m(a,c),e=m(a,c+w.normal_coordinate_bytes),g=m(a,c+w.normal_coordinate_bytes*2),A.push(b/127,e/127,g/127);return w.nnormals*f}(x);x+=function(c){for(var e,f,h=w.uv_coordinate_bytes*2,k=c+w.nuvs*h;c<k;c+=h)e=b(a,c),f=b(a,c+w.uv_coordinate_bytes),D.push(e,f);return w.nuvs*h}(x);W=x+W;U=W+U;Z=U+Z;Y=Z+Y;$=Y+$;c=$+c;V=c+V;(function(a){var c,b=w.vertex_index_bytes*3+w.material_index_bytes,
+4+w.material_index_bytes;W=w.ntri_flat*c;U=w.ntri_smooth*(c+w.normal_index_bytes*3);Z=w.ntri_flat_uv*(c+w.uv_index_bytes*3);Y=w.ntri_smooth_uv*(c+w.normal_index_bytes*3+w.uv_index_bytes*3);$=w.nquad_flat*V;c=w.nquad_smooth*(V+w.normal_index_bytes*4);V=w.nquad_flat_uv*(V+w.uv_index_bytes*4);x+=function(c){for(var e,h,f,k=w.vertex_coordinate_bytes*3,l=c+w.nvertices*k;c<l;c+=k)e=b(a,c),h=b(a,c+w.vertex_coordinate_bytes),f=b(a,c+w.vertex_coordinate_bytes*2),z.vertices.push(new THREE.Vertex(new THREE.Vector3(e,
+h,f)));return w.nvertices*k}(x);x+=function(c){for(var b,e,g,h=w.normal_coordinate_bytes*3,f=c+w.nnormals*h;c<f;c+=h)b=m(a,c),e=m(a,c+w.normal_coordinate_bytes),g=m(a,c+w.normal_coordinate_bytes*2),A.push(b/127,e/127,g/127);return w.nnormals*h}(x);x+=function(c){for(var e,h,f=w.uv_coordinate_bytes*2,k=c+w.nuvs*f;c<k;c+=f)e=b(a,c),h=b(a,c+w.uv_coordinate_bytes),D.push(e,h);return w.nuvs*f}(x);W=x+W;U=W+U;Z=U+Z;Y=Z+Y;$=Y+$;c=$+c;V=c+V;(function(a){var c,b=w.vertex_index_bytes*3+w.material_index_bytes,
 e=b+w.uv_index_bytes*3,g=a+w.ntri_flat_uv*e;for(c=a;c<g;c+=e)o(c),y(c+b);return g-a})(U);(function(a){var c,b=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes*3,e=b+w.uv_index_bytes*3,g=a+w.ntri_smooth_uv*e;for(c=a;c<g;c+=e)t(c),y(c+b);return g-a})(Z);(function(a){var c,b=w.vertex_index_bytes*4+w.material_index_bytes,e=b+w.uv_index_bytes*4,g=a+w.nquad_flat_uv*e;for(c=a;c<g;c+=e)u(c),p(c+b);return g-a})(c);(function(a){var c,b=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*
 4,e=b+w.uv_index_bytes*4,g=a+w.nquad_smooth_uv*e;for(c=a;c<g;c+=e)v(c),p(c+b);return g-a})(V);(function(a){var c,b=w.vertex_index_bytes*3+w.material_index_bytes,e=a+w.ntri_flat*b;for(c=a;c<e;c+=b)o(c);return e-a})(x);(function(a){var c,b=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes*3,e=a+w.ntri_smooth*b;for(c=a;c<e;c+=b)t(c);return e-a})(W);(function(a){var c,b=w.vertex_index_bytes*4+w.material_index_bytes,e=a+w.nquad_flat*b;for(c=a;c<e;c+=b)u(c);return e-a})(Y);(function(a){var c,
 b=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*4,e=a+w.nquad_smooth*b;for(c=a;c<e;c+=b)v(c);return e-a})($);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(c))};

+ 12 - 12
examples/js/Car.js

@@ -126,28 +126,28 @@ THREE.Car = function () {
 
 		if ( controls.moveForward ) {
 
-			this.speed = THREE.MathUtils.clamp( this.speed + delta * this.FRONT_ACCELERATION, this.MAX_REVERSE_SPEED, this.MAX_SPEED );
-			this.acceleration = THREE.MathUtils.clamp( this.acceleration + delta, -1, 1 );
+			this.speed = THREE.Math.clamp( this.speed + delta * this.FRONT_ACCELERATION, this.MAX_REVERSE_SPEED, this.MAX_SPEED );
+			this.acceleration = THREE.Math.clamp( this.acceleration + delta, -1, 1 );
 
 		}
 
 		if ( controls.moveBackward ) {
 
 
-			this.speed = THREE.MathUtils.clamp( this.speed - delta * this.BACK_ACCELERATION, this.MAX_REVERSE_SPEED, this.MAX_SPEED );
-			this.acceleration = THREE.MathUtils.clamp( this.acceleration - delta, -1, 1 );
+			this.speed = THREE.Math.clamp( this.speed - delta * this.BACK_ACCELERATION, this.MAX_REVERSE_SPEED, this.MAX_SPEED );
+			this.acceleration = THREE.Math.clamp( this.acceleration - delta, -1, 1 );
 
 		}
 
 		if ( controls.moveLeft ) {
 
-			this.wheelOrientation = THREE.MathUtils.clamp( this.wheelOrientation + delta * this.WHEEL_ANGULAR_ACCELERATION, - this.MAX_WHEEL_ROTATION, this.MAX_WHEEL_ROTATION );
+			this.wheelOrientation = THREE.Math.clamp( this.wheelOrientation + delta * this.WHEEL_ANGULAR_ACCELERATION, - this.MAX_WHEEL_ROTATION, this.MAX_WHEEL_ROTATION );
 
 		}
 
 		if ( controls.moveRight ) {
 
-			this.wheelOrientation = THREE.MathUtils.clamp( this.wheelOrientation - delta * this.WHEEL_ANGULAR_ACCELERATION, - this.MAX_WHEEL_ROTATION, this.MAX_WHEEL_ROTATION );
+			this.wheelOrientation = THREE.Math.clamp( this.wheelOrientation - delta * this.WHEEL_ANGULAR_ACCELERATION, - this.MAX_WHEEL_ROTATION, this.MAX_WHEEL_ROTATION );
 
 		}
 
@@ -159,15 +159,15 @@ THREE.Car = function () {
 
 				var k = exponentialEaseOut( this.speed / this.MAX_SPEED );
 
-				this.speed = THREE.MathUtils.clamp( this.speed - k * delta * this.FRONT_DECCELERATION, 0, this.MAX_SPEED );
-				this.acceleration = THREE.MathUtils.clamp( this.acceleration - k * delta, 0, 1 );
+				this.speed = THREE.Math.clamp( this.speed - k * delta * this.FRONT_DECCELERATION, 0, this.MAX_SPEED );
+				this.acceleration = THREE.Math.clamp( this.acceleration - k * delta, 0, 1 );
 
 			} else {
 
 				var k = exponentialEaseOut( this.speed / this.MAX_REVERSE_SPEED );
 
-				this.speed = THREE.MathUtils.clamp( this.speed + k * delta * this.BACK_ACCELERATION, this.MAX_REVERSE_SPEED, 0 );
-				this.acceleration = THREE.MathUtils.clamp( this.acceleration + k * delta, -1, 0 );
+				this.speed = THREE.Math.clamp( this.speed + k * delta * this.BACK_ACCELERATION, this.MAX_REVERSE_SPEED, 0 );
+				this.acceleration = THREE.Math.clamp( this.acceleration + k * delta, -1, 0 );
 
 			}
 
@@ -180,11 +180,11 @@ THREE.Car = function () {
 
 			if ( this.wheelOrientation > 0 ) {
 
-				this.wheelOrientation = THREE.MathUtils.clamp( this.wheelOrientation - delta * this.WHEEL_ANGULAR_DECCELERATION, 0, this.MAX_WHEEL_ROTATION );
+				this.wheelOrientation = THREE.Math.clamp( this.wheelOrientation - delta * this.WHEEL_ANGULAR_DECCELERATION, 0, this.MAX_WHEEL_ROTATION );
 
 			} else {
 
-				this.wheelOrientation = THREE.MathUtils.clamp( this.wheelOrientation + delta * this.WHEEL_ANGULAR_DECCELERATION, - this.MAX_WHEEL_ROTATION, 0 );
+				this.wheelOrientation = THREE.Math.clamp( this.wheelOrientation + delta * this.WHEEL_ANGULAR_DECCELERATION, - this.MAX_WHEEL_ROTATION, 0 );
 
 			}
 

+ 4 - 4
examples/webgl_materials_cubemap_dynamic.html

@@ -881,7 +881,7 @@
 
 				// day / night
 
-				v = THREE.MathUtils.clamp( v + 0.5 * delta * vdir, 0.1, 0.9 );
+				v = THREE.Math.clamp( v + 0.5 * delta * vdir, 0.1, 0.9 );
 				scene.fog.color.setHSV( 0.51, 0.5, v );
 
 				renderer.setClearColor( scene.fog.color, 1 );
@@ -934,10 +934,10 @@
 
 				}
 
-				effectBloom.screenUniforms[ "opacity" ].value = THREE.MathUtils.mapLinear( vnorm, 0, 1, 1, 0.75 );
+				effectBloom.screenUniforms[ "opacity" ].value = THREE.Math.mapLinear( vnorm, 0, 1, 1, 0.75 );
 
-				ambientLight.color.setHSV( 0, 0, THREE.MathUtils.mapLinear( vnorm, 0, 1, 0.07, 0.33 ) );
-				groundBasic.color.setHSV( 0.1, 0.45, THREE.MathUtils.mapLinear( vnorm, 0, 1, 0.725, 0.995 ) );
+				ambientLight.color.setHSV( 0, 0, THREE.Math.mapLinear( vnorm, 0, 1, 0.07, 0.33 ) );
+				groundBasic.color.setHSV( 0.1, 0.45, THREE.Math.mapLinear( vnorm, 0, 1, 0.725, 0.995 ) );
 
 				// blur
 

+ 5 - 5
examples/webgl_shading_physical.html

@@ -47,6 +47,7 @@
 		<script type="text/javascript" src="../src/core/Vector4.js"></script>
 		<script type="text/javascript" src="../src/core/Ray.js"></script>
 		<script type="text/javascript" src="../src/core/Rectangle.js"></script>
+		<script type="text/javascript" src="../src/core/Math.js"></script>
 		<script type="text/javascript" src="../src/core/Matrix3.js"></script>
 		<script type="text/javascript" src="../src/core/Matrix4.js"></script>
 		<script type="text/javascript" src="../src/core/Object3D.js"></script>
@@ -111,7 +112,6 @@
 		<script type="text/javascript" src="../src/extras/ColorUtils.js"></script>
 		<script type="text/javascript" src="../src/extras/GeometryUtils.js"></script>
 		<script type="text/javascript" src="../src/extras/ImageUtils.js"></script>
-		<script type="text/javascript" src="../src/extras/MathUtils.js"></script>
 		<script type="text/javascript" src="../src/extras/SceneUtils.js"></script>
 		<script type="text/javascript" src="../src/extras/ShaderUtils.js"></script>
 		<script type="text/javascript" src="../src/extras/core/Curve.js"></script>
@@ -603,13 +603,13 @@
 
 				if ( morph ) morph.updateAnimation( delta );
 
-				scene.fog.color.setHSV( 0.13, 0.25, THREE.MathUtils.mapLinear( parameters.control, 0, 100, 0.1, 0.99 ) );
+				scene.fog.color.setHSV( 0.13, 0.25, THREE.Math.mapLinear( parameters.control, 0, 100, 0.1, 0.99 ) );
 				renderer.setClearColor( scene.fog.color, 1 );
 
-				sunLight.intensity = THREE.MathUtils.mapLinear( parameters.control, 0, 100, 0.3, 1 );
-				pointLight.intensity = THREE.MathUtils.mapLinear( parameters.control, 0, 100, 1, 0.5 );
+				sunLight.intensity = THREE.Math.mapLinear( parameters.control, 0, 100, 0.3, 1 );
+				pointLight.intensity = THREE.Math.mapLinear( parameters.control, 0, 100, 1, 0.5 );
 
-				pointLight.color.setHSV( 0.1, THREE.MathUtils.mapLinear( parameters.control, 0, 100, 0.99, 0 ), 0.9 );
+				pointLight.color.setHSV( 0.1, THREE.Math.mapLinear( parameters.control, 0, 100, 0.99, 0 ), 0.9 );
 
 				renderer.shadowMapDarkness = 0.5 * sunLight.intensity;
 

+ 1 - 1
src/extras/MathUtils.js → src/core/Math.js

@@ -2,7 +2,7 @@
  * @author alteredq / http://alteredqualia.com/
  */
 
-THREE.MathUtils = {
+THREE.Math = {
 
 	clamp: function ( x, a, b ) {
 

+ 3 - 3
src/extras/ColorUtils.js

@@ -10,9 +10,9 @@ THREE.ColorUtils = {
 
 		THREE.ColorUtils.rgbToHsv( color, hsv );
 
-		hsv.h = THREE.MathUtils.clamp( hsv.h + h, 0, 1 );
-		hsv.s = THREE.MathUtils.clamp( hsv.s + s, 0, 1 );
-		hsv.v = THREE.MathUtils.clamp( hsv.v + v, 0, 1 );
+		hsv.h = THREE.Math.clamp( hsv.h + h, 0, 1 );
+		hsv.s = THREE.Math.clamp( hsv.s + s, 0, 1 );
+		hsv.v = THREE.Math.clamp( hsv.v + v, 0, 1 );
 
 		color.setHSV( hsv.h, hsv.s, hsv.v );
 

+ 2 - 2
src/extras/controls/FirstPersonControls.js

@@ -183,7 +183,7 @@ THREE.FirstPersonControls = function ( object, domElement ) {
 
 			if ( this.heightSpeed ) {
 
-				var y = THREE.MathUtils.clamp( this.object.position.y, this.heightMin, this.heightMax );
+				var y = THREE.Math.clamp( this.object.position.y, this.heightMin, this.heightMax );
 				var delta = y - this.heightMin;
 
 				this.autoSpeedFactor = this.tdiff * ( delta * this.heightCoef );
@@ -247,7 +247,7 @@ THREE.FirstPersonControls = function ( object, domElement ) {
 
 		if ( this.constrainVertical ) {
 
-			this.phi = THREE.MathUtils.mapLinear( this.phi, 0, Math.PI, this.verticalMin, this.verticalMax );
+			this.phi = THREE.Math.mapLinear( this.phi, 0, Math.PI, this.verticalMin, this.verticalMax );
 
 		}
 

+ 2 - 2
src/extras/controls/PathControls.js

@@ -79,7 +79,7 @@ THREE.PathControls = function ( object, domElement ) {
 		srcRange = this.verticalAngleMap.srcRange;
 		dstRange = this.verticalAngleMap.dstRange;
 
-		var tmpPhi = THREE.MathUtils.mapLinear( this.phi, srcRange[ 0 ], srcRange[ 1 ], dstRange[ 0 ], dstRange[ 1 ] );
+		var tmpPhi = THREE.Math.mapLinear( this.phi, srcRange[ 0 ], srcRange[ 1 ], dstRange[ 0 ], dstRange[ 1 ] );
 		var tmpPhiFullRange = dstRange[ 1 ] - dstRange[ 0 ];
 		var tmpPhiNormalized = ( tmpPhi - dstRange[ 0 ] ) / tmpPhiFullRange;
 
@@ -90,7 +90,7 @@ THREE.PathControls = function ( object, domElement ) {
 		srcRange = this.horizontalAngleMap.srcRange;
 		dstRange = this.horizontalAngleMap.dstRange;
 
-		var tmpTheta = THREE.MathUtils.mapLinear( this.theta, srcRange[ 0 ], srcRange[ 1 ], dstRange[ 0 ], dstRange[ 1 ] );
+		var tmpTheta = THREE.Math.mapLinear( this.theta, srcRange[ 0 ], srcRange[ 1 ], dstRange[ 0 ], dstRange[ 1 ] );
 		var tmpThetaFullRange = dstRange[ 1 ] - dstRange[ 0 ];
 		var tmpThetaNormalized = ( tmpTheta - dstRange[ 0 ] ) / tmpThetaFullRange;
 

+ 1 - 1
src/objects/MorphAnimMesh.js

@@ -59,7 +59,7 @@ THREE.MorphAnimMesh.prototype.updateAnimation = function ( delta ) {
 
 	}
 
-	var keyframe = THREE.MathUtils.clamp( Math.floor( this.time / frameTime ), 0, this.geometry.morphTargets.length - 1 );
+	var keyframe = THREE.Math.clamp( Math.floor( this.time / frameTime ), 0, this.geometry.morphTargets.length - 1 );
 
 	if ( keyframe != this.currentKeyframe ) {
 

+ 1 - 1
utils/build.py

@@ -19,6 +19,7 @@ COMMON_FILES = [
 'core/Vector4.js',
 'core/Ray.js',
 'core/Rectangle.js',
+'core/Math.js',
 'core/Matrix3.js',
 'core/Matrix4.js',
 'core/Object3D.js',
@@ -86,7 +87,6 @@ EXTRAS_FILES = [
 'extras/ColorUtils.js',
 'extras/GeometryUtils.js',
 'extras/ImageUtils.js',
-'extras/MathUtils.js',
 'extras/SceneUtils.js',
 'extras/ShaderUtils.js',
 'extras/core/Curve.js',