Browse Source

Merge branch 'master' into dev

alteredq 14 years ago
parent
commit
f1e4f59afc

File diff suppressed because it is too large
+ 35 - 36
build/Three.js


+ 1 - 1
build/custom/ThreeCanvas.js

@@ -53,7 +53,7 @@ THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;thi
 d;this.z=a.z*d;this.w=Math.cos(c);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*=-1;this.y*=-1;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);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},
 multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,f=this.w,g=a.x,e=a.y,h=a.z,a=a.w;this.x=b*a+f*g+c*h-d*e;this.y=c*a+f*e+d*g-b*h;this.z=d*a+f*h+b*e-c*g;this.w=f*a-b*g-c*e-d*h;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},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,g=this.x,e=this.y,h=this.z,i=this.w,l=i*c+e*f-h*d,m=
 i*d+h*c-g*f,j=i*f+g*d-e*c,c=-g*c-e*d-h*f;b.x=l*i+c*-g+m*-h-j*-e;b.y=m*i+c*-e+j*-g-l*-h;b.z=j*i+c*-h+l*-e-m*-g;return b}};
-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(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.001)return 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),c;f=Math.sin((1-d)*g)/e;d=Math.sin(d*g)/e;c.w=a.w*f+b.w*d;c.x=a.x*f+b.x*d;c.y=a.y*f+b.y*d;c.z=a.z*f+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+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(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.0010)return 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),c;f=Math.sin((1-d)*g)/e;d=Math.sin(d*g)/e;c.w=a.w*f+b.w*d;c.x=a.x*f+b.x*d;c.y=a.y*f+b.y*d;c.z=a.z*f+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 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.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,f,g,e){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.materials=e instanceof Array?e:[e];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};

+ 1 - 1
build/custom/ThreeDOM.js

@@ -53,7 +53,7 @@ THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;thi
 d;this.z=a.z*d;this.w=Math.cos(c);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*=-1;this.y*=-1;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);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},
 multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,h=a.z,a=a.w;this.x=b*a+e*g+c*h-d*f;this.y=c*a+e*f+d*g-b*h;this.z=d*a+e*h+b*f-c*g;this.w=e*a-b*g-c*f-d*h;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},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,h=this.z,j=this.w,i=j*c+f*e-h*d,k=
 j*d+h*c-g*e,l=j*e+g*d-f*c,c=-g*c-f*d-h*e;b.x=i*j+c*-g+k*-h-l*-f;b.y=k*j+c*-f+l*-g-i*-h;b.z=l*j+c*-h+i*-f-k*-g;return b}};
-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(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.001)return 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),c;e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+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(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.0010)return 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),c;e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,e,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=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,g,f){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=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;

File diff suppressed because it is too large
+ 0 - 1
build/custom/ThreeExtras.js


+ 1 - 1
build/custom/ThreeSVG.js

@@ -53,7 +53,7 @@ THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;thi
 d;this.z=a.z*d;this.w=Math.cos(c);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*=-1;this.y*=-1;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);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},
 multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,h=a.z,a=a.w;this.x=b*a+e*g+c*h-d*f;this.y=c*a+e*f+d*g-b*h;this.z=d*a+e*h+b*f-c*g;this.w=e*a-b*g-c*f-d*h;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},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,h=this.z,k=this.w,l=k*c+f*e-h*d,i=
 k*d+h*c-g*e,j=k*e+g*d-f*c,c=-g*c-f*d-h*e;b.x=l*k+c*-g+i*-h-j*-f;b.y=i*k+c*-f+j*-g-l*-h;b.z=j*k+c*-h+l*-f-i*-g;return b}};
-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(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.001)return 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),c;e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+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(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.0010)return 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),c;e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,e,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=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,g,f){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=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};

+ 18 - 18
build/custom/ThreeWebGL.js

@@ -53,7 +53,7 @@ THREE.Quaternion.prototype={set:function(b,d,e,f){this.x=b;this.y=d;this.z=e;thi
 f;this.z=b.z*f;this.w=Math.cos(e);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*=-1;this.y*=-1;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 b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);b==0?this.w=this.z=this.y=this.x=0:(b=1/b,this.x*=b,this.y*=b,this.z*=b,this.w*=b);return this},
 multiplySelf:function(b){var d=this.x,e=this.y,f=this.z,g=this.w,i=b.x,h=b.y,j=b.z,b=b.w;this.x=d*b+g*i+e*j-f*h;this.y=e*b+g*h+f*i-d*j;this.z=f*b+g*j+d*h-e*i;this.w=g*b-d*i-e*h-f*j;return this},multiply:function(b,d){this.x=b.x*d.w+b.y*d.z-b.z*d.y+b.w*d.x;this.y=-b.x*d.z+b.y*d.w+b.z*d.x+b.w*d.y;this.z=b.x*d.y-b.y*d.x+b.z*d.w+b.w*d.z;this.w=-b.x*d.x-b.y*d.y-b.z*d.z+b.w*d.w;return this},multiplyVector3:function(b,d){d||(d=b);var e=b.x,f=b.y,g=b.z,i=this.x,h=this.y,j=this.z,k=this.w,o=k*e+h*g-j*f,q=
 k*f+j*e-i*g,n=k*g+i*f-h*e,e=-i*e-h*f-j*g;d.x=o*k+e*-i+q*-j-n*-h;d.y=q*k+e*-h+n*-i-o*-j;d.z=n*k+e*-j+o*-h-q*-i;return d}};
-THREE.Quaternion.slerp=function(b,d,e,f){var g=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(g)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var i=Math.acos(g),h=Math.sqrt(1-g*g);if(Math.abs(h)<0.001)return e.w=0.5*(b.w+d.w),e.x=0.5*(b.x+d.x),e.y=0.5*(b.y+d.y),e.z=0.5*(b.z+d.z),e;g=Math.sin((1-f)*i)/h;f=Math.sin(f*i)/h;e.w=b.w*g+d.w*f;e.x=b.x*g+d.x*f;e.y=b.y*g+d.y*f;e.z=b.z*g+d.z*f;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
+THREE.Quaternion.slerp=function(b,d,e,f){var g=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(g)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var i=Math.acos(g),h=Math.sqrt(1-g*g);if(Math.abs(h)<0.0010)return e.w=0.5*(b.w+d.w),e.x=0.5*(b.x+d.x),e.y=0.5*(b.y+d.y),e.z=0.5*(b.z+d.z),e;g=Math.sin((1-f)*i)/h;f=Math.sin(f*i)/h;e.w=b.w*g+d.w*f;e.x=b.x*g+d.x*f;e.y=b.y*g+d.y*f;e.z=b.z*g+d.z*f;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
 THREE.Face3=function(b,d,e,f,g,i){this.a=b;this.b=d;this.c=e;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.materials=i instanceof Array?i:[i];this.centroid=new THREE.Vector3};
 THREE.Face4=function(b,d,e,f,g,i,h){this.a=b;this.b=d;this.c=e;this.d=f;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=i instanceof THREE.Color?i:new THREE.Color;this.vertexColors=i instanceof Array?i:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)};
 THREE.UV.prototype={set:function(b,d){this.u=b;this.v=d;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
@@ -157,26 +157,26 @@ lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirec
 color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position  = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position  = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#endif",
 morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInfluences[ 8 ];\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0, 0.0, 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif",
 default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"};THREE.UniformsUtils={merge:function(b){var d,e,f,g={};for(d=0;d<b.length;d++)for(e in f=this.clone(b[d]),f)g[e]=f[e];return g},clone:function(b){var d,e,f,g={};for(d in b)for(e in g[d]={},b[d])f=b[d][e],g[d][e]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f;return g}};
-THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},offsetRepeat:{type:"v4",value:new THREE.Vector4(0,0,1,1)},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",
-value:new THREE.Color(16777215)},morphTargetInfluences:{type:"f",value:0}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightDistance:{type:"fv1",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",value:1},
-map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
+THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},offsetRepeat:{type:"v4",value:new THREE.Vector4(0,0,1,1)},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},morphTargetInfluences:{type:"f",value:0}},fog:{fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",
+value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightDistance:{type:"fv1",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",
+value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
 THREE.ShaderLib={lensFlareVertexTexture:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nuniform sampler2D occlusionMap;\nattribute vec2 position;\nattribute vec2 UV;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nvUV = UV;\nvec2 pos = position;\nif( renderType == 2 ) {\nvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.5 ) );\nvVisibility = (       visibility.r / 9.0 ) *\n( 1.0 - visibility.g / 9.0 ) *\n(       visibility.b / 9.0 ) *\n( 1.0 - visibility.a / 9.0 );\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D map;\nuniform float opacity;\nuniform int renderType;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nvec4 color = texture2D( map, vUV );\ncolor.a *= opacity * vVisibility;\ngl_FragColor = color;\n}\n}"},
 lensFlare:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nattribute vec2 position;\nattribute vec2 UV;\nvarying vec2 vUV;\nvoid main() {\nvUV = UV;\nvec2 pos = position;\nif( renderType == 2 ) {\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D map;\nuniform sampler2D occlusionMap;\nuniform float opacity;\nuniform int renderType;\nvarying vec2 vUV;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( texture2D( map, vUV ).rgb, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nfloat visibility = texture2D( occlusionMap, vec2( 0.5, 0.1 ) ).a +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 ) ).a +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 ) ).a +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 ) ).a;\nvisibility = ( 1.0 - visibility / 4.0 );\nvec4 color = texture2D( map, vUV );\ncolor.a *= opacity * visibility;\ngl_FragColor = color;\n}\n}"},
 sprite:{vertexShader:"uniform int useScreenCoordinates;\nuniform int affectedByDistance;\nuniform vec3 screenPosition;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 alignment;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position + alignment;\nvec2 rotatedPosition;\nrotatedPosition.x = ( cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y ) * scale.x;\nrotatedPosition.y = ( sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y ) * scale.y;\nvec4 finalPosition;\nif( useScreenCoordinates != 0 ) {\nfinalPosition = vec4( screenPosition.xy + rotatedPosition, screenPosition.z, 1.0 );\n} else {\nfinalPosition = projectionMatrix * modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition * ( affectedByDistance == 1 ? 1.0 : finalPosition.z );\n}\ngl_Position = finalPosition;\n}",
 fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D map;\nuniform float opacity;\nvarying vec2 vUV;\nvoid main() {\nvec4 color = texture2D( map, vUV );\ncolor.a *= opacity;\ngl_FragColor = color;\n}"},shadowPost:{vertexShader:"uniform \tmat4 \tprojectionMatrix;\nattribute \tvec3 \tposition;\nvoid main() {\ngl_Position = projectionMatrix * vec4( position, 1.0 );\n}",fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform \tfloat \tdarkness;\nvoid main() {\ngl_FragColor = vec4( 0, 0, 0, darkness );\n}"},
 shadowVolumeDynamic:{uniforms:{directionalLightDirection:{type:"fv",value:[]}},vertexShader:"uniform \tvec3 \tdirectionalLightDirection;\nvoid main() {\nvec4 pos      = objectMatrix * vec4( position, 1.0 );\nvec3 norm     = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 extruded = vec4( directionalLightDirection * 5000.0 * step( 0.0, dot( directionalLightDirection, norm ) ), 0.0 );\ngl_Position   = projectionMatrix * viewMatrix * ( pos + extruded );\n}",fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0 );\n}"},
 depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},fragmentShader:"uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}",vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f",value:1}},
-fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,
-THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:[THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex,
-THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),
-fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,
-THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["varying vec3 vLightWeighting;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
-THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),
-fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.lights_fragment,THREE.ShaderChunk.map_fragment,
-THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,
-"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,
-THREE.ShaderChunk.default_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",
-THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};
+fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",
+THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:[THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,
+THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,
+THREE.UniformsLib.fog,THREE.UniformsLib.lights]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,
+THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["varying vec3 vLightWeighting;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,
+THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},
+shininess:{type:"f",value:30}}]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.lights_fragment,
+THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,
+THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_vertex,
+THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,
+"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};
 THREE.WebGLRenderer=function(b){function d(b,d,e){var f,g,h,i=b.vertices,j=i.length,k=b.colors,o=k.length,p=b.__vertexArray,O=b.__colorArray,q=b.__sortArray,n=b.__dirtyVertices,t=b.__dirtyColors;if(e.sortParticles){ia.multiplySelf(e.matrixWorld);for(f=0;f<j;f++)g=i[f].position,Da.copy(g),ia.multiplyVector3(Da),q[f]=[Da.z,f];q.sort(function(b,c){return c[0]-b[0]});for(f=0;f<j;f++)g=i[q[f][1]].position,h=f*3,p[h]=g.x,p[h+1]=g.y,p[h+2]=g.z;for(f=0;f<o;f++)h=f*3,color=k[q[f][1]],O[h]=color.r,O[h+1]=color.g,
 O[h+2]=color.b}else{if(n)for(f=0;f<j;f++)g=i[f].position,h=f*3,p[h]=g.x,p[h+1]=g.y,p[h+2]=g.z;if(t)for(f=0;f<o;f++)color=k[f],h=f*3,O[h]=color.r,O[h+1]=color.g,O[h+2]=color.b}if(n||e.sortParticles)c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer),c.bufferData(c.ARRAY_BUFFER,p,d);if(t||e.sortParticles)c.bindBuffer(c.ARRAY_BUFFER,b.__webglColorBuffer),c.bufferData(c.ARRAY_BUFFER,O,d)}function e(b,d,e,f,g){f.program||L.initMaterial(f,d,e,g);var h=f.program,i=h.uniforms,j=f.uniforms;h!=la&&(c.useProgram(h),
 la=h);c.uniformMatrix4fv(i.projectionMatrix,!1,ta);if(e&&(f instanceof THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshPhongMaterial||f instanceof THREE.LineBasicMaterial||f instanceof THREE.ParticleBasicMaterial||f.fog))if(j.fogColor.value=e.color,e instanceof THREE.Fog)j.fogNear.value=e.near,j.fogFar.value=e.far;else if(e instanceof THREE.FogExp2)j.fogDensity.value=e.density;if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||
@@ -211,9 +211,9 @@ h.uvScale.y),c.uniform2f(g.uvOffset,h.uvOffset.x,h.uvOffset.y),c.uniform2f(g.ali
 k=new THREE.Vector3,o=qa/va,p=va*0.5,n=qa*0.5,q=16/qa,t=[q*o,q],u=[1,1,0],r=[1,1],z=v.uniforms;d=v.attributes;c.useProgram(v.program);la=v.program;F=-1;Ia||(c.enableVertexAttribArray(v.attributes.vertex),c.enableVertexAttribArray(v.attributes.uv),Ia=!0);c.uniform1i(z.occlusionMap,0);c.uniform1i(z.map,1);c.bindBuffer(c.ARRAY_BUFFER,v.vertexBuffer);c.vertexAttribPointer(d.vertex,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(d.uv,2,c.FLOAT,!1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.elementBuffer);c.disable(c.CULL_FACE);
 c.depthMask(!1);c.activeTexture(c.TEXTURE0);c.bindTexture(c.TEXTURE_2D,v.occlusionTexture);c.activeTexture(c.TEXTURE1);for(f=0;f<h;f++)if(d=b.__webglLensFlares[f].object,k.set(d.matrixWorld.n14,d.matrixWorld.n24,d.matrixWorld.n34),e.matrixWorldInverse.multiplyVector3(k),e.projectionMatrix.multiplyVector3(k),u[0]=k.x,u[1]=k.y,u[2]=k.z,r[0]=u[0]*p+p,r[1]=u[1]*n+n,v.hasVertexTexture||r[0]>0&&r[0]<va&&r[1]>0&&r[1]<qa){c.bindTexture(c.TEXTURE_2D,v.tempTexture);c.copyTexImage2D(c.TEXTURE_2D,0,c.RGB,r[0]-
 8,r[1]-8,16,16,0);c.uniform1i(z.renderType,0);c.uniform2fv(z.scale,t);c.uniform3fv(z.screenPosition,u);c.disable(c.BLEND);c.enable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.bindTexture(c.TEXTURE_2D,v.occlusionTexture);c.copyTexImage2D(c.TEXTURE_2D,0,c.RGBA,r[0]-8,r[1]-8,16,16,0);c.uniform1i(z.renderType,1);c.disable(c.DEPTH_TEST);c.bindTexture(c.TEXTURE_2D,v.tempTexture);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);d.positionScreen.x=u[0];d.positionScreen.y=u[1];d.positionScreen.z=
-u[2];d.customUpdateCallback?d.customUpdateCallback(d):d.updateLensFlares();c.uniform1i(z.renderType,2);c.enable(c.BLEND);g=0;for(i=d.lensFlares.length;g<i;g++)if(j=d.lensFlares[g],j.opacity>0.001&&j.scale>0.001)u[0]=j.x,u[1]=j.y,u[2]=j.z,q=j.size*j.scale/qa,t[0]=q*o,t[1]=q,c.uniform3fv(z.screenPosition,u),c.uniform2fv(z.scale,t),c.uniform1f(z.rotation,j.rotation),c.uniform1f(z.opacity,j.opacity),y(j.blending),P(j.texture,1),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);
-c.depthMask(ma)}function C(b,c){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function N(b){var e,f,h,g;if(b instanceof THREE.Mesh){f=b.geometry;for(e in f.geometryGroups){h=f.geometryGroups[e];a:{for(var i=g=void 0,j=void 0,k=void 0,o=void 0,o=h.__materials,i=0,j=o.length;i<j;i++)if(k=o[i],k.attributes)for(g in k.attributes)if(k.attributes[g].needsUpdate){g=!0;
-break a}g=!1}if(f.__dirtyVertices||f.__dirtyMorphTargets||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents||g)if(g=h,i=b,j=c.DYNAMIC_DRAW,g.__inittedArrays){var n=o=k=void 0,p=void 0,q=n=void 0,t=void 0,u=void 0,r=void 0,y=void 0,v=void 0,z=void 0,C=void 0,D=void 0,x=void 0,J=void 0,I=void 0,E=void 0,s=p=r=p=u=t=void 0,A=void 0,m=A=s=t=void 0,F=void 0,H=m=A=s=n=n=q=r=p=m=A=s=F=m=A=s=F=m=A=s=void 0,B=0,G=0,P=0,T=0,L=0,K=0,U=0,M=0,ca=0,w=0,da=0,A=s=0,fa=g.__vertexArray,
+u[2];d.customUpdateCallback?d.customUpdateCallback(d):d.updateLensFlares();c.uniform1i(z.renderType,2);c.enable(c.BLEND);g=0;for(i=d.lensFlares.length;g<i;g++)if(j=d.lensFlares[g],j.opacity>0.0010&&j.scale>0.0010)u[0]=j.x,u[1]=j.y,u[2]=j.z,q=j.size*j.scale/qa,t[0]=q*o,t[1]=q,c.uniform3fv(z.screenPosition,u),c.uniform2fv(z.scale,t),c.uniform1f(z.rotation,j.rotation),c.uniform1f(z.opacity,j.opacity),y(j.blending),P(j.texture,1),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}c.enable(c.CULL_FACE);
+c.enable(c.DEPTH_TEST);c.depthMask(ma)}function C(b,c){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function N(b){var e,f,h,g;if(b instanceof THREE.Mesh){f=b.geometry;for(e in f.geometryGroups){h=f.geometryGroups[e];a:{for(var i=g=void 0,j=void 0,k=void 0,o=void 0,o=h.__materials,i=0,j=o.length;i<j;i++)if(k=o[i],k.attributes)for(g in k.attributes)if(k.attributes[g].needsUpdate){g=
+!0;break a}g=!1}if(f.__dirtyVertices||f.__dirtyMorphTargets||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents||g)if(g=h,i=b,j=c.DYNAMIC_DRAW,g.__inittedArrays){var n=o=k=void 0,p=void 0,q=n=void 0,t=void 0,u=void 0,r=void 0,y=void 0,v=void 0,z=void 0,C=void 0,D=void 0,x=void 0,J=void 0,I=void 0,E=void 0,s=p=r=p=u=t=void 0,A=void 0,m=A=s=t=void 0,F=void 0,H=m=A=s=n=n=q=r=p=m=A=s=F=m=A=s=F=m=A=s=void 0,B=0,G=0,P=0,T=0,L=0,K=0,U=0,M=0,ca=0,w=0,da=0,A=s=0,fa=g.__vertexArray,
 $=g.__uvArray,aa=g.__uv2Array,Q=g.__normalArray,V=g.__tangentArray,ga=g.__colorArray,W=g.__skinVertexAArray,X=g.__skinVertexBArray,Y=g.__skinIndexArray,Z=g.__skinWeightArray,ea=g.__morphTargetsArrays,S=g.__webglCustomAttributes,m=void 0,N=g.__faceArray,R=g.__lineArray,la=g.__needsSmoothNormals,v=g.__vertexColorType,y=g.__uvType,z=g.__normalType,ja=i.geometry,ma=ja.__dirtyVertices,na=ja.__dirtyElements,ha=ja.__dirtyUvs,pa=ja.__dirtyNormals,qa=ja.__dirtyTangents,ra=ja.__dirtyColors,sa=ja.__dirtyMorphTargets,
 ia=ja.vertices,ua=g.faces,xa=ja.faces,va=ja.faceVertexUvs[0],ya=ja.faceVertexUvs[1],oa=ja.skinVerticesA,ta=ja.skinVerticesB,wa=ja.skinIndices,Ba=ja.skinWeights,Ca=i instanceof THREE.ShadowVolume?ja.edgeFaces:void 0,Aa=ja.morphTargets;if(S)for(H in S)S[H].offset=0,S[H].offsetSrc=0;k=0;for(o=ua.length;k<o;k++)if(n=ua[k],p=xa[n],va&&(C=va[n]),ya&&(D=ya[n]),n=p.vertexNormals,q=p.normal,t=p.vertexColors,u=p.color,r=p.vertexTangents,p instanceof THREE.Face3){if(ma)x=ia[p.a].position,J=ia[p.b].position,
 I=ia[p.c].position,fa[G]=x.x,fa[G+1]=x.y,fa[G+2]=x.z,fa[G+3]=J.x,fa[G+4]=J.y,fa[G+5]=J.z,fa[G+6]=I.x,fa[G+7]=I.y,fa[G+8]=I.z,G+=9;if(S)for(H in S)if(m=S[H],m.__original.needsUpdate)s=m.offset,A=m.offsetSrc,m.size===1?(m.boundTo===void 0||m.boundTo==="vertices"?(m.array[s+0]=m.value[p.a],m.array[s+1]=m.value[p.b],m.array[s+2]=m.value[p.c]):m.boundTo==="faces"?(m.array[s+0]=m.value[A],m.array[s+1]=m.value[A],m.array[s+2]=m.value[A],m.offsetSrc++):m.boundTo==="faceVertices"&&(m.array[s+0]=m.value[A+

+ 5 - 0
src/extras/ShaderUtils.js

@@ -95,6 +95,7 @@ THREE.ShaderUtils = {
 
 			uniforms: THREE.UniformsUtils.merge( [
 
+				THREE.UniformsLib[ "fog" ],
 				THREE.UniformsLib[ "lights" ],
 
 				{
@@ -162,6 +163,8 @@ THREE.ShaderUtils = {
 
 				"varying vec3 vViewPosition;",
 
+				THREE.ShaderChunk[ "fog_pars_fragment" ],
+
 				"void main() {",
 
 					"gl_FragColor = vec4( 1.0 );",
@@ -255,6 +258,8 @@ THREE.ShaderUtils = {
 
 					"gl_FragColor = gl_FragColor * totalLight;",
 
+					THREE.ShaderChunk[ "fog_fragment" ],
+
 				"}"
 
 			].join("\n"),

+ 21 - 4
src/extras/io/Loader.js

@@ -293,6 +293,12 @@ THREE.Loader.prototype = {
 
 		}
 
+		if ( m.mapSpecular && texture_path ) {
+
+			create_texture( mpars, "specularMap", m.mapSpecular, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap );
+
+		}
+
 		// special case for normal mapped material
 
 		if ( m.mapNormal ) {
@@ -320,10 +326,21 @@ THREE.Loader.prototype = {
 
 			}
 
-			// for the moment don't handle specular, AO and displacement textures
+			if ( mpars.specularMap ) {
+
+				uniforms[ "tSpecular" ].texture = mpars.specularMap;
+				uniforms[ "enableSpecular" ].value = true;
+
+			}
+
+			if ( mpars.lightMap ) {
+
+				uniforms[ "tAO" ].texture = mpars.lightMap;
+				uniforms[ "enableAO" ].value = true;
+
+			}
 
-			uniforms[ "enableAO" ].value = false;
-			uniforms[ "enableSpecular" ].value = false;
+			// for the moment don't handle displacement texture
 
 			uniforms[ "uDiffuseColor" ].value.setHex( diffuse );
 			uniforms[ "uSpecularColor" ].value.setHex( specular );
@@ -337,7 +354,7 @@ THREE.Loader.prototype = {
 
 			}
 
-			var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights: true };
+			var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights: true, fog: true };
 
 			material = new THREE.MeshShaderMaterial( parameters );
 

+ 15 - 4
src/extras/io/SceneLoader.js

@@ -535,7 +535,7 @@ THREE.SceneLoader.prototype = {
 					if ( modelJson ) {
 
 						jsonLoader.createModel( modelJson, create_callback_embed( dg ), texture_path );
-						
+
 					}
 
 				}
@@ -713,8 +713,19 @@ THREE.SceneLoader.prototype = {
 
 					}
 
-					uniforms[ "enableAO" ].value = false;
-					uniforms[ "enableSpecular" ].value = false;
+					if ( m.parameters.lightMap ) {
+
+						uniforms[ "tAO" ].texture = m.parameters.lightMap;
+						uniforms[ "enableAO" ].value = true;
+
+					}
+
+					if ( m.parameters.specularMap ) {
+
+						uniforms[ "tSpecular" ].texture = result.textures[ m.parameters.specularMap ];
+						uniforms[ "enableSpecular" ].value = true;
+
+					}
 
 					uniforms[ "uDiffuseColor" ].value.setHex( diffuse );
 					uniforms[ "uSpecularColor" ].value.setHex( specular );
@@ -728,7 +739,7 @@ THREE.SceneLoader.prototype = {
 
 					}
 
-					var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights: true };
+					var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights: true, fog: true };
 
 					material = new THREE.MeshShaderMaterial( parameters );
 

+ 23 - 6
src/renderers/WebGLShaders.js

@@ -588,12 +588,16 @@ THREE.UniformsLib = {
 		"refractionRatio" : { type: "f", value: 0.98 },
 		"combine" : { type: "i", value: 0 },
 
+		"morphTargetInfluences" : { type: "f", value: 0 }
+
+	},
+
+	fog : {
+
 		"fogDensity" : { type: "f", value: 0.00025 },
 		"fogNear" : { type: "f", value: 1 },
 		"fogFar" : { type: "f", value: 2000 },
-		"fogColor" : { type: "c", value: new THREE.Color( 0xffffff ) },
-
-		"morphTargetInfluences" : { type: "f", value: 0 }
+		"fogColor" : { type: "c", value: new THREE.Color( 0xffffff ) }
 
 	},
 
@@ -664,7 +668,7 @@ THREE.ShaderLib = {
 
 					"vVisibility = (       visibility.r / 9.0 ) *",
 								  "( 1.0 - visibility.g / 9.0 ) *",
-								  "(       visibility.b / 9.0 ) *", 
+								  "(       visibility.b / 9.0 ) *",
 								  "( 1.0 - visibility.a / 9.0 );",
 
 					"pos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;",
@@ -1016,7 +1020,12 @@ THREE.ShaderLib = {
 
 	'basic': {
 
-		uniforms: THREE.UniformsLib[ "common" ],
+		uniforms: THREE.UniformsUtils.merge( [
+
+			THREE.UniformsLib[ "common" ],
+			THREE.UniformsLib[ "fog" ]
+
+		] ),
 
 		fragmentShader: [
 
@@ -1072,7 +1081,13 @@ THREE.ShaderLib = {
 
 	'lambert': {
 
-		uniforms: THREE.UniformsUtils.merge( [ THREE.UniformsLib[ "common" ], THREE.UniformsLib[ "lights" ] ] ),
+		uniforms: THREE.UniformsUtils.merge( [
+
+			THREE.UniformsLib[ "common" ],
+			THREE.UniformsLib[ "fog" ],
+			THREE.UniformsLib[ "lights" ]
+
+		] ),
 
 		fragmentShader: [
 
@@ -1141,7 +1156,9 @@ THREE.ShaderLib = {
 		uniforms: THREE.UniformsUtils.merge( [
 
 			THREE.UniformsLib[ "common" ],
+			THREE.UniformsLib[ "fog" ],
 			THREE.UniformsLib[ "lights" ],
+
 			{
 				"ambient"  : { type: "c", value: new THREE.Color( 0x050505 ) },
 				"specular" : { type: "c", value: new THREE.Color( 0x111111 ) },

+ 32 - 5
utils/exporters/blender/2.58/scripts/addons/io_mesh_threejs/export_threejs.py

@@ -761,6 +761,7 @@ def extract_materials(mesh, scene, option_colors, option_copy_textures, filepath
             handle_texture('diffuse', textures, material, filepath, option_copy_textures)
             handle_texture('light', textures, material, filepath, option_copy_textures)
             handle_texture('normal', textures, material, filepath, option_copy_textures)
+            handle_texture('specular', textures, material, filepath, option_copy_textures)
 
             material["vertexColors"] = m.THREE_useVertexColors and option_colors
 
@@ -771,7 +772,10 @@ def extract_materials(mesh, scene, option_colors, option_copy_textures, filepath
             #else:
             #    material['shading'] = "Lambert"
 
-            material['shading'] = m.THREE_materialType
+            if textures['normal']:
+                material['shading'] = "Phong"
+            else:
+                material['shading'] = m.THREE_materialType
 
     return materials
 
@@ -1324,6 +1328,7 @@ def extract_material_data(m, option_colors):
 
     material['mapDiffuse'] = ""
     material['mapLight'] = ""
+    material['mapSpecular'] = ""
     material['mapNormal'] = ""
     material['mapNormalFactor'] = 1.0
 
@@ -1335,6 +1340,9 @@ def extract_material_data(m, option_colors):
     if textures['light']:
         material['mapLight'] = textures['light']['texture'].image.name
 
+    if textures['specular']:
+        material['mapSpecular'] = textures['specular']['texture'].image.name
+
     if textures['normal']:
         material['mapNormal'] = textures['normal']['texture'].image.name
         if textures['normal']['slot'].use_map_normal:
@@ -1348,7 +1356,8 @@ def guess_material_textures(material):
     textures = {
         'diffuse' : None,
         'light'   : None,
-        'normal'  : None
+        'normal'  : None,
+        'specular': None
     }
 
     # just take first textures of each, for the moment three.js materials can't handle more
@@ -1363,6 +1372,9 @@ def guess_material_textures(material):
                 if texture.use_normal_map:
                     textures['normal'] = { "texture": texture, "slot": slot }
 
+                elif slot.use_map_specular or slot.use_map_hardness:
+                    textures['specular'] = { "texture": texture, "slot": slot }
+
                 else:
                     if not textures['diffuse']:
                         textures['diffuse'] = { "texture": texture, "slot": slot }
@@ -1370,19 +1382,30 @@ def guess_material_textures(material):
                     else:
                         textures['light'] = { "texture": texture, "slot": slot }
 
-                if textures['diffuse'] and textures['normal'] and textures['light']:
+                if textures['diffuse'] and textures['normal'] and textures['light'] and textures['specular']:
                     break
 
     return textures
 
 def generate_material_string(material):
+
+    material_id = material["name"]
+
+    # default to Lambert
+
+    shading = material.get("shading", "Lambert")
+
+    # normal mapped materials must use Phong
+    # to get all required parameters for normal shader
+
+    if material['mapNormal']:
+        shading = "Phong"
+
     type_map = {
     "Lambert"   : "MeshLambertMaterial",
     "Phong"     : "MeshPhongMaterial"
     }
 
-    material_id = material["name"]
-    shading = material.get("shading", "Lambert")
     material_type = type_map.get(shading, "MeshBasicMaterial")
 
     parameters = '"color": %d' % rgb2int(material["colorDiffuse"])
@@ -1395,6 +1418,7 @@ def generate_material_string(material):
 
     colorMap = material['mapDiffuse']
     lightMap = material['mapLight']
+    specularMap = material['mapSpecular']
     normalMap = material['mapNormal']
     normalMapFactor = material['mapNormalFactor']
 
@@ -1402,8 +1426,11 @@ def generate_material_string(material):
         parameters += ', "map": %s' % generate_string(colorMap)
     if lightMap:
         parameters += ', "lightMap": %s' % generate_string(lightMap)
+    if specularMap:
+        parameters += ', "specularMap": %s' % generate_string(specularMap)
     if normalMap:
         parameters += ', "normalMap": %s' % generate_string(normalMap)
+
     if normalMapFactor != 1.0:
         parameters += ', "normalMapFactor": %f' % normalMapFactor
 

+ 109 - 109
utils/exporters/blender/2.58/scripts/addons/io_mesh_threejs/import_threejs.py

@@ -27,7 +27,7 @@ import json
 import bpy
 import mathutils
 from mathutils.geometry import tesselate_polygon
-from io_utils import load_image, unpack_list, unpack_face_list
+from bpy_extras.image_utils import load_image
 
 # #####################################################
 # Generators
@@ -40,43 +40,43 @@ def setColor(c, t):
 def create_texture(filename, modelpath):
     name = filename
     texture = bpy.data.textures.new(name, type='IMAGE')
-    
+
     image = load_image(filename, modelpath)
     has_data = False
 
     if image:
         texture.image = image
         has_data = image.has_data
-    
+
     return texture
-    
+
 def create_materials(data, modelpath):
     materials = []
     materials_data = data.get("materials", [])
-    
+
     for i, m in enumerate(materials_data):
 
         name = m.get("DbgName", "material_%d" % i)
-        
+
         colorAmbient = m.get("colorAmbient", None)
         colorDiffuse = m.get("colorDiffuse", None)
         colorSpecular = m.get("colorSpecular", None)
         alpha = m.get("transparency", 1.0)
         specular_hardness = m.get("specularCoef", 0)
-        
+
         mapDiffuse = m.get("mapDiffuse", None)
         mapLightmap = m.get("mapLightmap", None)
-        
+
         vertexColorsType = m.get("vertexColors", False)
-        
+
         useVertexColors = False
         if vertexColorsType:
             useVertexColors = True
-        
+
         material = bpy.data.materials.new(name)
-        
+
         material.THREE_useVertexColors = useVertexColors
-        
+
         if colorDiffuse:
             setColor(material.diffuse_color, colorDiffuse)
             material.diffuse_intensity = 1.0
@@ -84,14 +84,14 @@ def create_materials(data, modelpath):
         if colorSpecular:
             setColor(material.specular_color, colorSpecular)
             material.specular_intensity = 1.0
-            
+
         if alpha < 1.0:
             material.alpha = alpha
             material.use_transparency = True
-            
+
         if specular_hardness:
             material.specular_hardness = specular_hardness
-            
+
         if mapDiffuse:
             texture = create_texture(mapDiffuse, modelpath)
             mtex = material.texture_slots.add()
@@ -99,13 +99,13 @@ def create_materials(data, modelpath):
             mtex.texture_coords = 'UV'
             mtex.use = True
             mtex.use_map_color_diffuse = True
-            
+
             material.active_texture = texture
 
         materials.append(material)
-        
+
     return materials
-    
+
 def create_mesh_object(name, vertices, materials, face_data, flipYZ, recalculate_normals):
 
     faces         = face_data["faces"]
@@ -114,23 +114,23 @@ def create_mesh_object(name, vertices, materials, face_data, flipYZ, recalculate
     vertexUVs     = face_data["vertexUVs"]
     faceMaterials = face_data["materials"]
     faceColors    = face_data["faceColors"]
-    
+
     edges = []
-    
+
     # Create a new mesh
-    
+
     me = bpy.data.meshes.new(name)
     me.from_pydata(vertices, edges, faces)
-    
+
     # Handle normals
-    
+
     if not recalculate_normals:
         me.update(calc_edges = True)
-    
+
     if face_data["hasVertexNormals"]:
-        
+
         print("setting vertex normals")
-        
+
         for fi in range(len(faces)):
 
             if vertexNormals[fi]:
@@ -139,24 +139,24 @@ def create_mesh_object(name, vertices, materials, face_data, flipYZ, recalculate
 
                 # if me.update() is called after setting vertex normals
                 # setting face.use_smooth overrides these normals
-                #  - this fixes weird shading artefacts (seems to come from sharing 
+                #  - this fixes weird shading artefacts (seems to come from sharing
                 #    of vertices between faces, didn't find a way how to set vertex normals
-                #    per face use of vertex as opposed to per vertex), 
+                #    per face use of vertex as opposed to per vertex),
                 #  - probably this just overrides all custom vertex normals
                 #  - to preserve vertex normals from the original data
                 #    call me.update() before setting them
-                
+
                 me.faces[fi].use_smooth = True
-                
+
                 if not recalculate_normals:
                     for j in range(len(vertexNormals[fi])):
-                        
+
                         vertexNormal = vertexNormals[fi][j]
-                    
+
                         x = vertexNormal[0]
                         y = vertexNormal[1]
                         z = vertexNormal[2]
-                        
+
                         if flipYZ:
                             tmp = y
                             y = -z
@@ -169,45 +169,45 @@ def create_mesh_object(name, vertices, materials, face_data, flipYZ, recalculate
                             #z = -z
 
                         vi = me.faces[fi].vertices[j]
-                        
+
                         me.vertices[vi].normal.x = x
                         me.vertices[vi].normal.y = y
                         me.vertices[vi].normal.z = z
-      
+
     if recalculate_normals:
         me.update(calc_edges = True)
 
     # Handle colors
-    
+
     if face_data["hasVertexColors"]:
 
         print("setting vertex colors")
 
         me.vertex_colors.new("vertex_color_layer_0")
-        
+
         for fi in range(len(faces)):
 
             if vertexColors[fi]:
-                
+
                 face_colors = me.vertex_colors[0].data[fi]
                 face_colors = face_colors.color1, face_colors.color2, face_colors.color3, face_colors.color4
-                
+
                 for vi in range(len(vertexColors[fi])):
-                    
+
                     r = vertexColors[fi][vi][0]
                     g = vertexColors[fi][vi][1]
                     b = vertexColors[fi][vi][2]
-                
+
                     face_colors[vi].r = r
                     face_colors[vi].g = g
                     face_colors[vi].b = b
-                    
+
     elif face_data["hasFaceColors"]:
 
         print("setting vertex colors from face colors")
 
         me.vertex_colors.new("vertex_color_layer_0")
-        
+
         for fi in range(len(faces)):
 
             if faceColors[fi]:
@@ -218,19 +218,19 @@ def create_mesh_object(name, vertices, materials, face_data, flipYZ, recalculate
 
                 face_colors = me.vertex_colors[0].data[fi]
                 face_colors = face_colors.color1, face_colors.color2, face_colors.color3, face_colors.color4
-                
+
                 for vi in range(len(faces[fi])):
-                
+
                     face_colors[vi].r = r
                     face_colors[vi].g = g
                     face_colors[vi].b = b
 
     # Handle uvs
-    
+
     if face_data["hasVertexUVs"]:
 
         print("setting vertex uvs")
-        
+
         for li, layer in enumerate(vertexUVs):
 
             me.uv_textures.new("uv_layer_%d" % li)
@@ -238,47 +238,47 @@ def create_mesh_object(name, vertices, materials, face_data, flipYZ, recalculate
             for fi in range(len(faces)):
 
                 if layer[fi]:
-                    
+
                     uv_face = me.uv_textures[li].data[fi]
                     face_uvs = uv_face.uv1, uv_face.uv2, uv_face.uv3, uv_face.uv4
-                    
+
                     for vi in range(len(layer[fi])):
-                        
+
                         u = layer[fi][vi][0]
                         v = layer[fi][vi][1]
-                    
+
                         face_uvs[vi].x = u
                         face_uvs[vi].y = 1.0 - v
-                        
+
                     active_texture = materials[faceMaterials[fi]].active_texture
-                    
+
                     if active_texture:
                         uv_face.use_image = True
                         uv_face.image = active_texture.image
 
 
     # Handle materials # 1
-    
+
     if face_data["hasMaterials"]:
-        
+
 
         print("setting materials (mesh)")
-    
+
         for m in materials:
-            
+
             me.materials.append(m)
 
-        print("setting materials (faces)")    
+        print("setting materials (faces)")
 
         for fi in range(len(faces)):
-            
+
             if faceMaterials[fi] >= 0:
-                
+
                 me.faces[fi].material_index = faceMaterials[fi]
 
     # Create a new object
-    
-    ob = bpy.data.objects.new(name, me) 
+
+    ob = bpy.data.objects.new(name, me)
     ob.data = me                                # link the mesh data to the object
 
 
@@ -286,14 +286,14 @@ def create_mesh_object(name, vertices, materials, face_data, flipYZ, recalculate
     scene.objects.link(ob)                      # link the object into the scene
 
     ob.location = scene.cursor_location         # position object at 3d-cursor
-    
-    
+
+
 # #####################################################
 # Faces
 # #####################################################
 
 def extract_faces(data):
-    
+
     result = {
     "faces"         : [],
     "materials"     : [],
@@ -303,14 +303,14 @@ def extract_faces(data):
     "vertexNormals" : [],
     "faceColors"    : [],
     "vertexColors"  : [],
-    
+
     "hasVertexNormals"  : False,
     "hasVertexUVs"      : False,
     "hasVertexColors"   : False,
     "hasFaceColors"     : False,
     "hasMaterials"      : False
     }
-    
+
     faces = data.get("faces", [])
     normals = data.get("normals", [])
     colors = data.get("colors", [])
@@ -351,23 +351,23 @@ def extract_faces(data):
         result["hasVertexColors"] = result["hasVertexColors"] or hasFaceVertexColor
         result["hasFaceColors"] = result["hasFaceColors"] or hasFaceColor
         result["hasMaterials"] = result["hasMaterials"] or hasMaterial
-        
+
         # vertices
-        
+
         if isQuad:
 
             a = faces[ offset ]
             offset += 1
-            
+
             b = faces[ offset ]
             offset += 1
-            
+
             c = faces[ offset ]
             offset += 1
-            
+
             d = faces[ offset ]
             offset += 1
-            
+
             face = [a, b, c, d]
 
             nVertices = 4
@@ -376,26 +376,26 @@ def extract_faces(data):
 
             a = faces[ offset ]
             offset += 1
-            
+
             b = faces[ offset ]
             offset += 1
-            
+
             c = faces[ offset ]
             offset += 1
 
             face = [a, b, c]
-            
+
             nVertices = 3
 
         result["faces"].append(face)
 
         # material
-        
+
         if hasMaterial:
 
             materialIndex = faces[ offset ]
             offset += 1
-        
+
         else:
 
             materialIndex = -1
@@ -407,9 +407,9 @@ def extract_faces(data):
         for i in range(nUvLayers):
 
             faceUv = None
-            
+
             if hasFaceUv:
-                
+
                 uvLayer = data["uvs"][ i ]
 
                 uvIndex = faces[ offset ]
@@ -419,7 +419,7 @@ def extract_faces(data):
                 v = uvLayer[ uvIndex * 2 + 1 ]
 
                 faceUv = [u, v]
-                
+
             result["faceUVs"][i].append(faceUv)
 
 
@@ -452,18 +452,18 @@ def extract_faces(data):
             z = normals[ normalIndex + 2 ]
 
             faceNormal = [x, y, z]
-            
+
         else:
 
             faceNormal = None
-        
+
         result["faceNormals"].append(faceNormal)
 
 
         if hasFaceVertexNormal:
 
             vertexNormals = []
-            
+
             for j in range(nVertices):
 
                 normalIndex = faces[ offset ] * 3
@@ -472,14 +472,14 @@ def extract_faces(data):
                 x = normals[ normalIndex ]
                 y = normals[ normalIndex + 1 ]
                 z = normals[ normalIndex + 2 ]
-                
+
                 vertexNormals.append( [x, y, z] )
 
 
         else:
 
             vertexNormals = None
-        
+
         result["vertexNormals"].append(vertexNormals)
 
 
@@ -487,11 +487,11 @@ def extract_faces(data):
 
             colorIndex = faces[ offset ]
             offset += 1
-            
+
             faceColor = hexToTuple( colors[ colorIndex ] )
 
         else:
-            
+
             faceColor = None
 
         result["faceColors"].append(faceColor)
@@ -510,14 +510,14 @@ def extract_faces(data):
                 vertexColors.append( color )
 
         else:
-            
+
             vertexColors = None
-            
+
         result["vertexColors"].append(vertexColors)
 
 
     return result
-    
+
 # #####################################################
 # Utils
 # #####################################################
@@ -527,10 +527,10 @@ def hexToTuple( hexColor ):
     g = (( hexColor >> 8 ) & 0xff) / 255.0
     b = ( hexColor & 0xff) / 255.0
     return (r, g, b)
-    
+
 def isBitSet(value, position):
     return value & ( 1 << position )
-    
+
 def splitArray(data, chunkSize):
     result = []
     chunk = []
@@ -546,7 +546,7 @@ def splitArray(data, chunkSize):
 def extract_json_string(text):
     marker_begin = "var model ="
     marker_end = "postMessage"
-    
+
     start = text.find(marker_begin) + len(marker_begin)
     end = text.find(marker_end)
     end = text.rfind("}", start, end)
@@ -563,13 +563,13 @@ def get_path(filepath):
 # #####################################################
 
 def load(operator, context, filepath, option_flip_yz = True, recalculate_normals = True):
-    
+
     print('\nimporting %r' % filepath)
 
     time_main = time.time()
 
     print("\tparsing JSON file...")
-    
+
     time_sub = time.time()
 
     file = open(filepath, 'rU')
@@ -578,24 +578,24 @@ def load(operator, context, filepath, option_flip_yz = True, recalculate_normals
 
     json_string = extract_json_string(rawcontent)
     data = json.loads( json_string )
-    
+
     time_new = time.time()
 
     print('parsing %.4f sec' % (time_new - time_sub))
-    
+
     time_sub = time_new
 
     # flip YZ
-    
+
     vertices = splitArray(data["vertices"], 3)
-    
+
     if option_flip_yz:
-        vertices[:] = [(v[0], -v[2], v[1]) for v in vertices]        
+        vertices[:] = [(v[0], -v[2], v[1]) for v in vertices]
 
     # extract faces
-    
+
     face_data = extract_faces(data)
-    
+
     # deselect all
 
     bpy.ops.object.select_all(action='DESELECT')
@@ -606,19 +606,19 @@ def load(operator, context, filepath, option_flip_yz = True, recalculate_normals
     ncolors = len(data.get("colors", [])) / 3
     nuvs = len(data.get("uvs", [])) / 2
     nmaterials = len(data.get("materials", []))
-    
-    print('\tbuilding geometry...\n\tfaces:%i, vertices:%i, vertex normals: %i, vertex uvs: %i, vertex colors: %i, materials: %i ...' % ( 
+
+    print('\tbuilding geometry...\n\tfaces:%i, vertices:%i, vertex normals: %i, vertex uvs: %i, vertex colors: %i, materials: %i ...' % (
         nfaces, nvertices, nnormals, nuvs, ncolors, nmaterials ))
 
     # Create materials
-    
+
     materials = create_materials(data, get_path(filepath))
-    
+
     # Create new obj
-    
+
     create_mesh_object(get_name(filepath), vertices, materials, face_data, option_flip_yz, recalculate_normals)
 
-    scene = bpy.context.scene 
+    scene = bpy.context.scene
     scene.update()
 
     time_new = time.time()

Some files were not shown because too many files changed in this diff