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

Implemented real spotlights.

This adds 2 extra parameters to SpotLight:

- "angle" for controlling light cone width
- "exponent" for controlling sideways light attenuation (from light->target axis towards edges of light cone)

Warning: this changes appearance of everything that used old fake SpotLight. To get approximately similar look use these parameter values:

```
spotLight.angle = Math.PI;
spotLight.exponent = 1;
```

Todo:

- implement spotlights in normal map and skin shaders
- check what's going on with vertex colors and ambient term in unlit parts
- check shadowmap darkening vs unlit parts darkening
- maybe some better formula for light cone attenuation, current one varies too wildly with cone angle
alteredq 13 жил өмнө
parent
commit
1087cf8cda

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


+ 30 - 30
build/custom/ThreeCanvas.js

@@ -1,6 +1,6 @@
 // ThreeCanvas.js - http://github.com/mrdoob/three.js
 'use strict';var THREE=THREE||{REVISION:"49dev"};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;
-(function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c<b.length&&!window.requestAnimationFrame;++c)window.requestAnimationFrame=window[b[c]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[b[c]+"CancelAnimationFrame"]||window[b[c]+"CancelRequestAnimationFrame"];if(!window.requestAnimationFrame)window.requestAnimationFrame=function(b){var c=(new Date).getTime(),f=Math.max(0,16-(c-a)),g=window.setTimeout(function(){b(c+f)},f);a=c+f;return g};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=
+(function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c<b.length&&!window.requestAnimationFrame;++c)window.requestAnimationFrame=window[b[c]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[b[c]+"CancelAnimationFrame"]||window[b[c]+"CancelRequestAnimationFrame"];if(!window.requestAnimationFrame)window.requestAnimationFrame=function(b){var c=Date.now(),f=Math.max(0,16-(c-a)),g=window.setTimeout(function(){b(c+f)},f);a=c+f;return g};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=
 function(a){clearTimeout(a)}})();THREE.Color=function(a){void 0!==a&&this.setHex(a);return this};
 THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a){this.r=a.r*a.r;this.g=a.g*a.g;this.b=a.b*a.b;return this},copyLinearToGamma:function(a){this.r=Math.sqrt(a.r);this.g=Math.sqrt(a.g);this.b=Math.sqrt(a.b);return this},convertGammaToLinear:function(){var a=this.r,b=this.g,c=this.b;this.r=a*a;this.g=b*b;this.b=c*c;return this},convertLinearToGamma:function(){this.r=Math.sqrt(this.r);this.g=Math.sqrt(this.g);
 this.b=Math.sqrt(this.b);return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,e,f;if(0===c)this.r=this.g=this.b=0;else switch(d=Math.floor(6*a),e=6*a-d,a=c*(1-b),f=c*(1-b*e),b=c*(1-b*(1-e)),d){case 1:this.r=f;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=f;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=c;this.g=a;this.b=f;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=
@@ -80,7 +80,7 @@ this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRo
 this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-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);0===a?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},multiply:function(a,
 b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,i=a.z,a=a.w;this.x=b*a+e*f+c*i-d*g;this.y=c*a+e*g+d*f-b*i;this.z=d*a+e*i+b*g-c*f;this.w=e*a-b*f-c*g-d*i;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,i=this.z,j=this.w,h=j*c+g*e-i*d,l=j*d+i*c-f*e,o=j*e+f*
 d-g*c,c=-f*c-g*d-i*e;b.x=h*j+c*-f+l*-i-o*-g;b.y=l*j+c*-g+o*-f-h*-i;b.z=o*j+c*-i+h*-g-l*-f;return b},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(0.001>Math.abs(e))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;b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(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;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(0.0010>Math.abs(e))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;b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Vertex.prototype={constructor:THREE.Vertex,clone:function(){return new THREE.Vertex(this.position.clone())}};THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};
 THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;for(b=0,c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();for(b=0,c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();for(b=0,c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
 return a}};THREE.Face4=function(a,b,c,d,e,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};
@@ -144,34 +144,34 @@ THREE.SpriteAlignment.topLeft=new THREE.Vector2(1,-1);THREE.SpriteAlignment.topC
 THREE.SpriteAlignment.bottomRight=new THREE.Vector2(-1,1);THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=null;this.matrixAutoUpdate=!1;this.__objects=[];this.__lights=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;
 THREE.Scene.prototype.__addObject=function(a){if(a instanceof THREE.Light)-1===this.__lights.indexOf(a)&&this.__lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&-1===this.__objects.indexOf(a)){this.__objects.push(a);this.__objectsAdded.push(a);var b=this.__objectsRemoved.indexOf(a);-1!==b&&this.__objectsRemoved.splice(b,1)}for(b=0;b<a.children.length;b++)this.__addObject(a.children[b])};
 THREE.Scene.prototype.__removeObject=function(a){if(a instanceof THREE.Light){var b=this.__lights.indexOf(a);-1!==b&&this.__lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.__objects.indexOf(a),-1!==b&&(this.__objects.splice(b,1),this.__objectsRemoved.push(a),b=this.__objectsAdded.indexOf(a),-1!==b&&this.__objectsAdded.splice(b,1)));for(b=0;b<a.children.length;b++)this.__removeObject(a.children[b])};
-THREE.CanvasRenderer=function(a){function b(a){if(D!=a)k.globalAlpha=D=a}function c(a){if(L!=a){switch(a){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}L=a}}function d(a){if(G!=a)k.strokeStyle=G=a}function e(a){if(t!=a)k.fillStyle=t=a}var a=a||{},f=this,g,i,j,h=new THREE.Projector,l=void 0!==a.canvas?a.canvas:document.createElement("canvas"),
-o,m,n,p,k=l.getContext("2d"),u=new THREE.Color(0),H=0,D=1,L=0,G=null,t=null,E=null,A=null,F=null,r,v,y,K,$=new THREE.RenderableVertex,da=new THREE.RenderableVertex,O,I,T,Q,U,C,J,R,B,P,N,V,s=new THREE.Color,x=new THREE.Color,w=new THREE.Color,z=new THREE.Color,M=new THREE.Color,la=[],fa=[],ga,ha,ea,aa,Ba,Ca,Da,Ea,Fa,Ga,ma=new THREE.Rectangle,Z=new THREE.Rectangle,Y=new THREE.Rectangle,ya=!1,X=new THREE.Color,na=new THREE.Color,oa=new THREE.Color,S=new THREE.Vector3,sa,ta,za,ba,ua,va,a=16;sa=document.createElement("canvas");
-sa.width=sa.height=2;ta=sa.getContext("2d");ta.fillStyle="rgba(0,0,0,1)";ta.fillRect(0,0,2,2);za=ta.getImageData(0,0,2,2);ba=za.data;ua=document.createElement("canvas");ua.width=ua.height=a;va=ua.getContext("2d");va.translate(-a/2,-a/2);va.scale(a,a);a--;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){o=a;m=b;n=Math.floor(o/2);p=Math.floor(m/2);l.width=o;l.height=m;ma.set(-n,-p,n,p);Z.set(-n,-p,n,p);D=1;L=0;
-F=A=E=t=G=null};this.setClearColor=function(a,b){u.copy(a);H=void 0!==b?b:1;Z.set(-n,-p,n,p)};this.setClearColorHex=function(a,b){u.setHex(a);H=void 0!==b?b:1;Z.set(-n,-p,n,p)};this.clear=function(){k.setTransform(1,0,0,-1,n,p);Z.isEmpty()||(Z.minSelf(ma),Z.inflate(2),1>H&&k.clearRect(Math.floor(Z.getX()),Math.floor(Z.getY()),Math.floor(Z.getWidth()),Math.floor(Z.getHeight())),0<H&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(255*u.r)+","+Math.floor(255*u.g)+","+Math.floor(255*u.b)+","+H+")"),
-k.fillRect(Math.floor(Z.getX()),Math.floor(Z.getY()),Math.floor(Z.getWidth()),Math.floor(Z.getHeight()))),Z.empty())};this.render=function(a,l){function o(a){var b,c,d,e;X.setRGB(0,0,0);na.setRGB(0,0,0);oa.setRGB(0,0,0);for(b=0,c=a.length;b<c;b++)d=a[b],e=d.color,d instanceof THREE.AmbientLight?(X.r+=e.r,X.g+=e.g,X.b+=e.b):d instanceof THREE.DirectionalLight?(na.r+=e.r,na.g+=e.g,na.b+=e.b):d instanceof THREE.PointLight&&(oa.r+=e.r,oa.g+=e.g,oa.b+=e.b)}function m(a,b,c,d){var e,f,g,h,i,j;for(e=0,f=
-a.length;e<f;e++)g=a[e],h=g.color,g instanceof THREE.DirectionalLight?(i=g.matrixWorld.getPosition(),j=c.dot(i),0>=j||(j*=g.intensity,d.r+=h.r*j,d.g+=h.g*j,d.b+=h.b*j)):g instanceof THREE.PointLight&&(i=g.matrixWorld.getPosition(),j=c.dot(S.sub(i,b).normalize()),0>=j||(j*=0==g.distance?1:1-Math.min(b.distanceTo(i)/g.distance,1),0!=j&&(j*=g.intensity,d.r+=h.r*j,d.g+=h.g*j,d.b+=h.b*j)))}function t(a,f,g){b(g.opacity);c(g.blending);var h,i,j,l,q,o;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)l=
-g.map.image,q=l.width>>1,o=l.height>>1,g=f.scale.x*n,j=f.scale.y*p,h=g*q,i=j*o,Y.set(a.x-h,a.y-i,a.x+h,a.y+i),ma.intersects(Y)&&(k.save(),k.translate(a.x,a.y),k.rotate(-f.rotation),k.scale(g,-j),k.translate(-q,-o),k.drawImage(l,0,0),k.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=f.scale.x*n,i=f.scale.y*p,Y.set(a.x-h,a.y-i,a.x+h,a.y+i),ma.intersects(Y)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),k.save(),k.translate(a.x,a.y),k.rotate(-f.rotation),k.scale(h,i),g.program(k),
-k.restore()))}function u(a,e,f,g){b(g.opacity);c(g.blending);k.beginPath();k.moveTo(a.positionScreen.x,a.positionScreen.y);k.lineTo(e.positionScreen.x,e.positionScreen.y);k.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(E!=a)k.lineWidth=E=a;a=g.linecap;if(A!=a)k.lineCap=A=a;a=g.linejoin;if(F!=a)k.lineJoin=F=a;d(g.color.getContextStyle());k.stroke();Y.inflate(2*g.linewidth)}}function D(a,d,e,g,h,i,k,q){f.info.render.vertices+=3;f.info.render.faces++;b(q.opacity);c(q.blending);
-O=a.positionScreen.x;I=a.positionScreen.y;T=d.positionScreen.x;Q=d.positionScreen.y;U=e.positionScreen.x;C=e.positionScreen.y;G(O,I,T,Q,U,C);if(q instanceof THREE.MeshBasicMaterial)if(q.map)q.map.mapping instanceof THREE.UVMapping&&(aa=k.uvs[0],Aa(O,I,T,Q,U,C,aa[g].u,aa[g].v,aa[h].u,aa[h].v,aa[i].u,aa[i].v,q.map));else if(q.envMap){if(q.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,S.copy(k.vertexNormalsWorld[g]),Ba=0.5*(S.x*a.n11+S.y*a.n12+S.z*a.n13)+0.5,Ca=0.5*
--(S.x*a.n21+S.y*a.n22+S.z*a.n23)+0.5,S.copy(k.vertexNormalsWorld[h]),Da=0.5*(S.x*a.n11+S.y*a.n12+S.z*a.n13)+0.5,Ea=0.5*-(S.x*a.n21+S.y*a.n22+S.z*a.n23)+0.5,S.copy(k.vertexNormalsWorld[i]),Fa=0.5*(S.x*a.n11+S.y*a.n12+S.z*a.n13)+0.5,Ga=0.5*-(S.x*a.n21+S.y*a.n22+S.z*a.n23)+0.5,Aa(O,I,T,Q,U,C,Ba,Ca,Da,Ea,Fa,Ga,q.envMap)}else q.wireframe?ja(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(q.color);else if(q instanceof THREE.MeshLambertMaterial)q.map&&!q.wireframe&&(q.map.mapping instanceof
-THREE.UVMapping&&(aa=k.uvs[0],Aa(O,I,T,Q,U,C,aa[g].u,aa[g].v,aa[h].u,aa[h].v,aa[i].u,aa[i].v,q.map)),c(THREE.SubtractiveBlending)),ya?!q.wireframe&&q.shading==THREE.SmoothShading&&3==k.vertexNormalsWorld.length?(x.r=w.r=z.r=X.r,x.g=w.g=z.g=X.g,x.b=w.b=z.b=X.b,m(j,k.v1.positionWorld,k.vertexNormalsWorld[0],x),m(j,k.v2.positionWorld,k.vertexNormalsWorld[1],w),m(j,k.v3.positionWorld,k.vertexNormalsWorld[2],z),x.r=Math.max(0,Math.min(q.color.r*x.r,1)),x.g=Math.max(0,Math.min(q.color.g*x.g,1)),x.b=Math.max(0,
-Math.min(q.color.b*x.b,1)),w.r=Math.max(0,Math.min(q.color.r*w.r,1)),w.g=Math.max(0,Math.min(q.color.g*w.g,1)),w.b=Math.max(0,Math.min(q.color.b*w.b,1)),z.r=Math.max(0,Math.min(q.color.r*z.r,1)),z.g=Math.max(0,Math.min(q.color.g*z.g,1)),z.b=Math.max(0,Math.min(q.color.b*z.b,1)),M.r=0.5*(w.r+z.r),M.g=0.5*(w.g+z.g),M.b=0.5*(w.b+z.b),ea=wa(x,w,z,M),qa(O,I,T,Q,U,C,0,0,1,0,0,1,ea)):(s.r=X.r,s.g=X.g,s.b=X.b,m(j,k.centroidWorld,k.normalWorld,s),s.r=Math.max(0,Math.min(q.color.r*s.r,1)),s.g=Math.max(0,Math.min(q.color.g*
-s.g,1)),s.b=Math.max(0,Math.min(q.color.b*s.b,1)),q.wireframe?ja(s,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(s)):q.wireframe?ja(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(q.color);else if(q instanceof THREE.MeshDepthMaterial)ga=l.near,ha=l.far,x.r=x.g=x.b=1-pa(a.positionScreen.z,ga,ha),w.r=w.g=w.b=1-pa(d.positionScreen.z,ga,ha),z.r=z.g=z.b=1-pa(e.positionScreen.z,ga,ha),M.r=0.5*(w.r+z.r),M.g=0.5*(w.g+z.g),M.b=0.5*(w.b+z.b),ea=wa(x,w,z,M),qa(O,I,T,
-Q,U,C,0,0,1,0,0,1,ea);else if(q instanceof THREE.MeshNormalMaterial)s.r=ra(k.normalWorld.x),s.g=ra(k.normalWorld.y),s.b=ra(k.normalWorld.z),q.wireframe?ja(s,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(s)}function L(a,d,e,g,h,i,k,q,o){f.info.render.vertices+=4;f.info.render.faces++;b(q.opacity);c(q.blending);if(q.map||q.envMap)D(a,d,g,0,1,3,k,q,o),D(h,e,i,1,2,3,k,q,o);else if(O=a.positionScreen.x,I=a.positionScreen.y,T=d.positionScreen.x,Q=d.positionScreen.y,U=e.positionScreen.x,
-C=e.positionScreen.y,J=g.positionScreen.x,R=g.positionScreen.y,B=h.positionScreen.x,P=h.positionScreen.y,N=i.positionScreen.x,V=i.positionScreen.y,q instanceof THREE.MeshBasicMaterial)H(O,I,T,Q,U,C,J,R),q.wireframe?ja(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(q.color);else if(q instanceof THREE.MeshLambertMaterial)ya?!q.wireframe&&q.shading==THREE.SmoothShading&&4==k.vertexNormalsWorld.length?(x.r=w.r=z.r=M.r=X.r,x.g=w.g=z.g=M.g=X.g,x.b=w.b=z.b=M.b=X.b,m(j,k.v1.positionWorld,
-k.vertexNormalsWorld[0],x),m(j,k.v2.positionWorld,k.vertexNormalsWorld[1],w),m(j,k.v4.positionWorld,k.vertexNormalsWorld[3],z),m(j,k.v3.positionWorld,k.vertexNormalsWorld[2],M),x.r=Math.max(0,Math.min(q.color.r*x.r,1)),x.g=Math.max(0,Math.min(q.color.g*x.g,1)),x.b=Math.max(0,Math.min(q.color.b*x.b,1)),w.r=Math.max(0,Math.min(q.color.r*w.r,1)),w.g=Math.max(0,Math.min(q.color.g*w.g,1)),w.b=Math.max(0,Math.min(q.color.b*w.b,1)),z.r=Math.max(0,Math.min(q.color.r*z.r,1)),z.g=Math.max(0,Math.min(q.color.g*
-z.g,1)),z.b=Math.max(0,Math.min(q.color.b*z.b,1)),M.r=Math.max(0,Math.min(q.color.r*M.r,1)),M.g=Math.max(0,Math.min(q.color.g*M.g,1)),M.b=Math.max(0,Math.min(q.color.b*M.b,1)),ea=wa(x,w,z,M),G(O,I,T,Q,J,R),qa(O,I,T,Q,J,R,0,0,1,0,0,1,ea),G(B,P,U,C,N,V),qa(B,P,U,C,N,V,1,0,1,1,0,1,ea)):(s.r=X.r,s.g=X.g,s.b=X.b,m(j,k.centroidWorld,k.normalWorld,s),s.r=Math.max(0,Math.min(q.color.r*s.r,1)),s.g=Math.max(0,Math.min(q.color.g*s.g,1)),s.b=Math.max(0,Math.min(q.color.b*s.b,1)),H(O,I,T,Q,U,C,J,R),q.wireframe?
-ja(s,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(s)):(H(O,I,T,Q,U,C,J,R),q.wireframe?ja(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(q.color));else if(q instanceof THREE.MeshNormalMaterial)s.r=ra(k.normalWorld.x),s.g=ra(k.normalWorld.y),s.b=ra(k.normalWorld.z),H(O,I,T,Q,U,C,J,R),q.wireframe?ja(s,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(s);else if(q instanceof THREE.MeshDepthMaterial)ga=l.near,ha=l.far,x.r=x.g=x.b=1-pa(a.positionScreen.z,
-ga,ha),w.r=w.g=w.b=1-pa(d.positionScreen.z,ga,ha),z.r=z.g=z.b=1-pa(g.positionScreen.z,ga,ha),M.r=M.g=M.b=1-pa(e.positionScreen.z,ga,ha),ea=wa(x,w,z,M),G(O,I,T,Q,J,R),qa(O,I,T,Q,J,R,0,0,1,0,0,1,ea),G(B,P,U,C,N,V),qa(B,P,U,C,N,V,1,0,1,1,0,1,ea)}function G(a,b,c,d,e,f){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(a,b);k.closePath()}function H(a,b,c,d,e,f,g,h){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(g,h);k.lineTo(a,b);k.closePath()}function ja(a,b,c,e){if(E!=
-b)k.lineWidth=E=b;if(A!=c)k.lineCap=A=c;if(F!=e)k.lineJoin=F=e;d(a.getContextStyle());k.stroke();Y.inflate(2*b)}function ia(a){e(a.getContextStyle());k.fill()}function Aa(a,b,c,d,f,g,h,i,j,l,o,n,m){if(0!=m.image.width){if(!0==m.needsUpdate||void 0==la[m.id]){var p=m.wrapS==THREE.RepeatWrapping,r=m.wrapT==THREE.RepeatWrapping;la[m.id]=k.createPattern(m.image,p&&r?"repeat":p&&!r?"repeat-x":!p&&r?"repeat-y":"no-repeat");m.needsUpdate=!1}e(la[m.id]);var p=m.offset.x/m.repeat.x,r=m.offset.y/m.repeat.y,
-t=m.image.width*m.repeat.x,u=m.image.height*m.repeat.y,h=(h+p)*t,i=(i+r)*u,c=c-a,d=d-b,f=f-a,g=g-b,j=(j+p)*t-h,l=(l+r)*u-i,o=(o+p)*t-h,n=(n+r)*u-i,p=j*n-o*l;if(0==p){if(void 0===fa[m.id])b=document.createElement("canvas"),b.width=m.image.width,b.height=m.image.height,b=b.getContext("2d"),b.drawImage(m.image,0,0),fa[m.id]=b.getImageData(0,0,m.image.width,m.image.height).data;b=fa[m.id];h=4*(Math.floor(h)+Math.floor(i)*m.image.width);s.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255);ia(s)}else p=1/p,m=(n*c-
-l*f)*p,l=(n*d-l*g)*p,c=(j*f-o*c)*p,d=(j*g-o*d)*p,a=a-m*h-c*i,h=b-l*h-d*i,k.save(),k.transform(m,l,c,d,a,h),k.fill(),k.restore()}}function qa(a,b,c,d,e,f,g,h,i,j,l,m,o){var n,p;n=o.width-1;p=o.height-1;g*=n;h*=p;c-=a;d-=b;e-=a;f-=b;i=i*n-g;j=j*p-h;l=l*n-g;m=m*p-h;p=1/(i*m-l*j);n=(m*c-j*e)*p;j=(m*d-j*f)*p;c=(i*e-l*c)*p;d=(i*f-l*d)*p;a=a-n*g-c*h;b=b-j*g-d*h;k.save();k.transform(n,j,c,d,a,b);k.clip();k.drawImage(o,0,0);k.restore()}function wa(a,b,c,d){var e=~~(255*a.r),f=~~(255*a.g),a=~~(255*a.b),g=~~(255*
-b.r),h=~~(255*b.g),b=~~(255*b.b),i=~~(255*c.r),j=~~(255*c.g),c=~~(255*c.b),k=~~(255*d.r),l=~~(255*d.g),d=~~(255*d.b);ba[0]=0>e?0:255<e?255:e;ba[1]=0>f?0:255<f?255:f;ba[2]=0>a?0:255<a?255:a;ba[4]=0>g?0:255<g?255:g;ba[5]=0>h?0:255<h?255:h;ba[6]=0>b?0:255<b?255:b;ba[8]=0>i?0:255<i?255:i;ba[9]=0>j?0:255<j?255:j;ba[10]=0>c?0:255<c?255:c;ba[12]=0>k?0:255<k?255:k;ba[13]=0>l?0:255<l?255:l;ba[14]=0>d?0:255<d?255:d;ta.putImageData(za,0,0);va.drawImage(sa,0,0);return ua}function pa(a,b,c){a=(a-b)/(c-b);return a*
-a*(3-2*a)}function ra(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}function ka(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;0!=e&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var xa,Ha,W,ca;this.autoClear?this.clear():k.setTransform(1,0,0,-1,n,p);f.info.render.vertices=0;f.info.render.faces=0;g=h.projectScene(a,l,this.sortElements);i=g.elements;j=g.lights;(ya=0<j.length)&&o(j);for(xa=0,Ha=i.length;xa<Ha;xa++)if(W=i[xa],ca=W.material,ca=ca instanceof THREE.MeshFaceMaterial?W.faceMaterial:ca,!(null==ca||
-0==ca.opacity)){Y.empty();if(W instanceof THREE.RenderableParticle)r=W,r.x*=n,r.y*=p,t(r,W,ca,a);else if(W instanceof THREE.RenderableLine)r=W.v1,v=W.v2,r.positionScreen.x*=n,r.positionScreen.y*=p,v.positionScreen.x*=n,v.positionScreen.y*=p,Y.addPoint(r.positionScreen.x,r.positionScreen.y),Y.addPoint(v.positionScreen.x,v.positionScreen.y),ma.intersects(Y)&&u(r,v,W,ca,a);else if(W instanceof THREE.RenderableFace3)r=W.v1,v=W.v2,y=W.v3,r.positionScreen.x*=n,r.positionScreen.y*=p,v.positionScreen.x*=
-n,v.positionScreen.y*=p,y.positionScreen.x*=n,y.positionScreen.y*=p,ca.overdraw&&(ka(r.positionScreen,v.positionScreen),ka(v.positionScreen,y.positionScreen),ka(y.positionScreen,r.positionScreen)),Y.add3Points(r.positionScreen.x,r.positionScreen.y,v.positionScreen.x,v.positionScreen.y,y.positionScreen.x,y.positionScreen.y),ma.intersects(Y)&&D(r,v,y,0,1,2,W,ca,a);else if(W instanceof THREE.RenderableFace4)r=W.v1,v=W.v2,y=W.v3,K=W.v4,r.positionScreen.x*=n,r.positionScreen.y*=p,v.positionScreen.x*=n,
-v.positionScreen.y*=p,y.positionScreen.x*=n,y.positionScreen.y*=p,K.positionScreen.x*=n,K.positionScreen.y*=p,$.positionScreen.copy(v.positionScreen),da.positionScreen.copy(K.positionScreen),ca.overdraw&&(ka(r.positionScreen,v.positionScreen),ka(v.positionScreen,K.positionScreen),ka(K.positionScreen,r.positionScreen),ka(y.positionScreen,$.positionScreen),ka(y.positionScreen,da.positionScreen)),Y.addPoint(r.positionScreen.x,r.positionScreen.y),Y.addPoint(v.positionScreen.x,v.positionScreen.y),Y.addPoint(y.positionScreen.x,
-y.positionScreen.y),Y.addPoint(K.positionScreen.x,K.positionScreen.y),ma.intersects(Y)&&L(r,v,y,K,$,da,W,ca,a);Z.addRectangle(Y)}k.setTransform(1,0,0,1,0,0)}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
+THREE.CanvasRenderer=function(a){function b(a){if(D!=a)k.globalAlpha=D=a}function c(a){if(L!=a){switch(a){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}L=a}}function d(a){if(G!=a)k.strokeStyle=G=a}function e(a){if(t!=a)k.fillStyle=t=a}console.log("THREE.CanvasRenderer",THREE.REVISION);var a=a||{},f=this,g,i,j,h=new THREE.Projector,l=void 0!==
+a.canvas?a.canvas:document.createElement("canvas"),o,m,n,p,k=l.getContext("2d"),u=new THREE.Color(0),H=0,D=1,L=0,G=null,t=null,E=null,A=null,F=null,r,v,y,K,$=new THREE.RenderableVertex,da=new THREE.RenderableVertex,O,I,T,Q,U,C,J,R,B,P,N,V,s=new THREE.Color,x=new THREE.Color,w=new THREE.Color,z=new THREE.Color,M=new THREE.Color,la=[],fa=[],ga,ha,ea,aa,Ba,Ca,Da,Ea,Fa,Ga,ma=new THREE.Rectangle,Z=new THREE.Rectangle,Y=new THREE.Rectangle,ya=!1,X=new THREE.Color,na=new THREE.Color,oa=new THREE.Color,S=
+new THREE.Vector3,sa,ta,za,ba,ua,va,a=16;sa=document.createElement("canvas");sa.width=sa.height=2;ta=sa.getContext("2d");ta.fillStyle="rgba(0,0,0,1)";ta.fillRect(0,0,2,2);za=ta.getImageData(0,0,2,2);ba=za.data;ua=document.createElement("canvas");ua.width=ua.height=a;va=ua.getContext("2d");va.translate(-a/2,-a/2);va.scale(a,a);a--;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){o=a;m=b;n=Math.floor(o/2);p=Math.floor(m/
+2);l.width=o;l.height=m;ma.set(-n,-p,n,p);Z.set(-n,-p,n,p);D=1;L=0;F=A=E=t=G=null};this.setClearColor=function(a,b){u.copy(a);H=void 0!==b?b:1;Z.set(-n,-p,n,p)};this.setClearColorHex=function(a,b){u.setHex(a);H=void 0!==b?b:1;Z.set(-n,-p,n,p)};this.clear=function(){k.setTransform(1,0,0,-1,n,p);Z.isEmpty()||(Z.minSelf(ma),Z.inflate(2),1>H&&k.clearRect(Math.floor(Z.getX()),Math.floor(Z.getY()),Math.floor(Z.getWidth()),Math.floor(Z.getHeight())),0<H&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(255*
+u.r)+","+Math.floor(255*u.g)+","+Math.floor(255*u.b)+","+H+")"),k.fillRect(Math.floor(Z.getX()),Math.floor(Z.getY()),Math.floor(Z.getWidth()),Math.floor(Z.getHeight()))),Z.empty())};this.render=function(a,l){function o(a){var b,c,d,e;X.setRGB(0,0,0);na.setRGB(0,0,0);oa.setRGB(0,0,0);for(b=0,c=a.length;b<c;b++)d=a[b],e=d.color,d instanceof THREE.AmbientLight?(X.r+=e.r,X.g+=e.g,X.b+=e.b):d instanceof THREE.DirectionalLight?(na.r+=e.r,na.g+=e.g,na.b+=e.b):d instanceof THREE.PointLight&&(oa.r+=e.r,oa.g+=
+e.g,oa.b+=e.b)}function m(a,b,c,d){var e,f,g,h,i,j;for(e=0,f=a.length;e<f;e++)g=a[e],h=g.color,g instanceof THREE.DirectionalLight?(i=g.matrixWorld.getPosition(),j=c.dot(i),0>=j||(j*=g.intensity,d.r+=h.r*j,d.g+=h.g*j,d.b+=h.b*j)):g instanceof THREE.PointLight&&(i=g.matrixWorld.getPosition(),j=c.dot(S.sub(i,b).normalize()),0>=j||(j*=0==g.distance?1:1-Math.min(b.distanceTo(i)/g.distance,1),0!=j&&(j*=g.intensity,d.r+=h.r*j,d.g+=h.g*j,d.b+=h.b*j)))}function t(a,f,g){b(g.opacity);c(g.blending);var h,i,
+j,l,q,o;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)l=g.map.image,q=l.width>>1,o=l.height>>1,g=f.scale.x*n,j=f.scale.y*p,h=g*q,i=j*o,Y.set(a.x-h,a.y-i,a.x+h,a.y+i),ma.intersects(Y)&&(k.save(),k.translate(a.x,a.y),k.rotate(-f.rotation),k.scale(g,-j),k.translate(-q,-o),k.drawImage(l,0,0),k.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=f.scale.x*n,i=f.scale.y*p,Y.set(a.x-h,a.y-i,a.x+h,a.y+i),ma.intersects(Y)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),k.save(),
+k.translate(a.x,a.y),k.rotate(-f.rotation),k.scale(h,i),g.program(k),k.restore()))}function u(a,e,f,g){b(g.opacity);c(g.blending);k.beginPath();k.moveTo(a.positionScreen.x,a.positionScreen.y);k.lineTo(e.positionScreen.x,e.positionScreen.y);k.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(E!=a)k.lineWidth=E=a;a=g.linecap;if(A!=a)k.lineCap=A=a;a=g.linejoin;if(F!=a)k.lineJoin=F=a;d(g.color.getContextStyle());k.stroke();Y.inflate(2*g.linewidth)}}function D(a,d,e,g,h,i,k,q){f.info.render.vertices+=
+3;f.info.render.faces++;b(q.opacity);c(q.blending);O=a.positionScreen.x;I=a.positionScreen.y;T=d.positionScreen.x;Q=d.positionScreen.y;U=e.positionScreen.x;C=e.positionScreen.y;G(O,I,T,Q,U,C);if(q instanceof THREE.MeshBasicMaterial)if(q.map)q.map.mapping instanceof THREE.UVMapping&&(aa=k.uvs[0],Aa(O,I,T,Q,U,C,aa[g].u,aa[g].v,aa[h].u,aa[h].v,aa[i].u,aa[i].v,q.map));else if(q.envMap){if(q.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,S.copy(k.vertexNormalsWorld[g]),
+Ba=0.5*(S.x*a.n11+S.y*a.n12+S.z*a.n13)+0.5,Ca=0.5*-(S.x*a.n21+S.y*a.n22+S.z*a.n23)+0.5,S.copy(k.vertexNormalsWorld[h]),Da=0.5*(S.x*a.n11+S.y*a.n12+S.z*a.n13)+0.5,Ea=0.5*-(S.x*a.n21+S.y*a.n22+S.z*a.n23)+0.5,S.copy(k.vertexNormalsWorld[i]),Fa=0.5*(S.x*a.n11+S.y*a.n12+S.z*a.n13)+0.5,Ga=0.5*-(S.x*a.n21+S.y*a.n22+S.z*a.n23)+0.5,Aa(O,I,T,Q,U,C,Ba,Ca,Da,Ea,Fa,Ga,q.envMap)}else q.wireframe?ja(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(q.color);else if(q instanceof THREE.MeshLambertMaterial)q.map&&
+!q.wireframe&&(q.map.mapping instanceof THREE.UVMapping&&(aa=k.uvs[0],Aa(O,I,T,Q,U,C,aa[g].u,aa[g].v,aa[h].u,aa[h].v,aa[i].u,aa[i].v,q.map)),c(THREE.SubtractiveBlending)),ya?!q.wireframe&&q.shading==THREE.SmoothShading&&3==k.vertexNormalsWorld.length?(x.r=w.r=z.r=X.r,x.g=w.g=z.g=X.g,x.b=w.b=z.b=X.b,m(j,k.v1.positionWorld,k.vertexNormalsWorld[0],x),m(j,k.v2.positionWorld,k.vertexNormalsWorld[1],w),m(j,k.v3.positionWorld,k.vertexNormalsWorld[2],z),x.r=Math.max(0,Math.min(q.color.r*x.r,1)),x.g=Math.max(0,
+Math.min(q.color.g*x.g,1)),x.b=Math.max(0,Math.min(q.color.b*x.b,1)),w.r=Math.max(0,Math.min(q.color.r*w.r,1)),w.g=Math.max(0,Math.min(q.color.g*w.g,1)),w.b=Math.max(0,Math.min(q.color.b*w.b,1)),z.r=Math.max(0,Math.min(q.color.r*z.r,1)),z.g=Math.max(0,Math.min(q.color.g*z.g,1)),z.b=Math.max(0,Math.min(q.color.b*z.b,1)),M.r=0.5*(w.r+z.r),M.g=0.5*(w.g+z.g),M.b=0.5*(w.b+z.b),ea=wa(x,w,z,M),qa(O,I,T,Q,U,C,0,0,1,0,0,1,ea)):(s.r=X.r,s.g=X.g,s.b=X.b,m(j,k.centroidWorld,k.normalWorld,s),s.r=Math.max(0,Math.min(q.color.r*
+s.r,1)),s.g=Math.max(0,Math.min(q.color.g*s.g,1)),s.b=Math.max(0,Math.min(q.color.b*s.b,1)),q.wireframe?ja(s,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(s)):q.wireframe?ja(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(q.color);else if(q instanceof THREE.MeshDepthMaterial)ga=l.near,ha=l.far,x.r=x.g=x.b=1-pa(a.positionScreen.z,ga,ha),w.r=w.g=w.b=1-pa(d.positionScreen.z,ga,ha),z.r=z.g=z.b=1-pa(e.positionScreen.z,ga,ha),M.r=0.5*(w.r+z.r),M.g=0.5*(w.g+z.g),
+M.b=0.5*(w.b+z.b),ea=wa(x,w,z,M),qa(O,I,T,Q,U,C,0,0,1,0,0,1,ea);else if(q instanceof THREE.MeshNormalMaterial)s.r=ra(k.normalWorld.x),s.g=ra(k.normalWorld.y),s.b=ra(k.normalWorld.z),q.wireframe?ja(s,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(s)}function L(a,d,e,g,h,i,k,q,o){f.info.render.vertices+=4;f.info.render.faces++;b(q.opacity);c(q.blending);if(q.map||q.envMap)D(a,d,g,0,1,3,k,q,o),D(h,e,i,1,2,3,k,q,o);else if(O=a.positionScreen.x,I=a.positionScreen.y,T=d.positionScreen.x,
+Q=d.positionScreen.y,U=e.positionScreen.x,C=e.positionScreen.y,J=g.positionScreen.x,R=g.positionScreen.y,B=h.positionScreen.x,P=h.positionScreen.y,N=i.positionScreen.x,V=i.positionScreen.y,q instanceof THREE.MeshBasicMaterial)H(O,I,T,Q,U,C,J,R),q.wireframe?ja(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(q.color);else if(q instanceof THREE.MeshLambertMaterial)ya?!q.wireframe&&q.shading==THREE.SmoothShading&&4==k.vertexNormalsWorld.length?(x.r=w.r=z.r=M.r=X.r,x.g=w.g=z.g=
+M.g=X.g,x.b=w.b=z.b=M.b=X.b,m(j,k.v1.positionWorld,k.vertexNormalsWorld[0],x),m(j,k.v2.positionWorld,k.vertexNormalsWorld[1],w),m(j,k.v4.positionWorld,k.vertexNormalsWorld[3],z),m(j,k.v3.positionWorld,k.vertexNormalsWorld[2],M),x.r=Math.max(0,Math.min(q.color.r*x.r,1)),x.g=Math.max(0,Math.min(q.color.g*x.g,1)),x.b=Math.max(0,Math.min(q.color.b*x.b,1)),w.r=Math.max(0,Math.min(q.color.r*w.r,1)),w.g=Math.max(0,Math.min(q.color.g*w.g,1)),w.b=Math.max(0,Math.min(q.color.b*w.b,1)),z.r=Math.max(0,Math.min(q.color.r*
+z.r,1)),z.g=Math.max(0,Math.min(q.color.g*z.g,1)),z.b=Math.max(0,Math.min(q.color.b*z.b,1)),M.r=Math.max(0,Math.min(q.color.r*M.r,1)),M.g=Math.max(0,Math.min(q.color.g*M.g,1)),M.b=Math.max(0,Math.min(q.color.b*M.b,1)),ea=wa(x,w,z,M),G(O,I,T,Q,J,R),qa(O,I,T,Q,J,R,0,0,1,0,0,1,ea),G(B,P,U,C,N,V),qa(B,P,U,C,N,V,1,0,1,1,0,1,ea)):(s.r=X.r,s.g=X.g,s.b=X.b,m(j,k.centroidWorld,k.normalWorld,s),s.r=Math.max(0,Math.min(q.color.r*s.r,1)),s.g=Math.max(0,Math.min(q.color.g*s.g,1)),s.b=Math.max(0,Math.min(q.color.b*
+s.b,1)),H(O,I,T,Q,U,C,J,R),q.wireframe?ja(s,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(s)):(H(O,I,T,Q,U,C,J,R),q.wireframe?ja(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(q.color));else if(q instanceof THREE.MeshNormalMaterial)s.r=ra(k.normalWorld.x),s.g=ra(k.normalWorld.y),s.b=ra(k.normalWorld.z),H(O,I,T,Q,U,C,J,R),q.wireframe?ja(s,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(s);else if(q instanceof THREE.MeshDepthMaterial)ga=l.near,
+ha=l.far,x.r=x.g=x.b=1-pa(a.positionScreen.z,ga,ha),w.r=w.g=w.b=1-pa(d.positionScreen.z,ga,ha),z.r=z.g=z.b=1-pa(g.positionScreen.z,ga,ha),M.r=M.g=M.b=1-pa(e.positionScreen.z,ga,ha),ea=wa(x,w,z,M),G(O,I,T,Q,J,R),qa(O,I,T,Q,J,R,0,0,1,0,0,1,ea),G(B,P,U,C,N,V),qa(B,P,U,C,N,V,1,0,1,1,0,1,ea)}function G(a,b,c,d,e,f){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(a,b);k.closePath()}function H(a,b,c,d,e,f,g,h){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(g,h);k.lineTo(a,
+b);k.closePath()}function ja(a,b,c,e){if(E!=b)k.lineWidth=E=b;if(A!=c)k.lineCap=A=c;if(F!=e)k.lineJoin=F=e;d(a.getContextStyle());k.stroke();Y.inflate(2*b)}function ia(a){e(a.getContextStyle());k.fill()}function Aa(a,b,c,d,f,g,h,i,j,l,o,n,m){if(0!=m.image.width){if(!0==m.needsUpdate||void 0==la[m.id]){var p=m.wrapS==THREE.RepeatWrapping,r=m.wrapT==THREE.RepeatWrapping;la[m.id]=k.createPattern(m.image,p&&r?"repeat":p&&!r?"repeat-x":!p&&r?"repeat-y":"no-repeat");m.needsUpdate=!1}e(la[m.id]);var p=m.offset.x/
+m.repeat.x,r=m.offset.y/m.repeat.y,t=m.image.width*m.repeat.x,u=m.image.height*m.repeat.y,h=(h+p)*t,i=(i+r)*u,c=c-a,d=d-b,f=f-a,g=g-b,j=(j+p)*t-h,l=(l+r)*u-i,o=(o+p)*t-h,n=(n+r)*u-i,p=j*n-o*l;if(0==p){if(void 0===fa[m.id])b=document.createElement("canvas"),b.width=m.image.width,b.height=m.image.height,b=b.getContext("2d"),b.drawImage(m.image,0,0),fa[m.id]=b.getImageData(0,0,m.image.width,m.image.height).data;b=fa[m.id];h=4*(Math.floor(h)+Math.floor(i)*m.image.width);s.setRGB(b[h]/255,b[h+1]/255,b[h+
+2]/255);ia(s)}else p=1/p,m=(n*c-l*f)*p,l=(n*d-l*g)*p,c=(j*f-o*c)*p,d=(j*g-o*d)*p,a=a-m*h-c*i,h=b-l*h-d*i,k.save(),k.transform(m,l,c,d,a,h),k.fill(),k.restore()}}function qa(a,b,c,d,e,f,g,h,i,j,l,m,o){var n,p;n=o.width-1;p=o.height-1;g*=n;h*=p;c-=a;d-=b;e-=a;f-=b;i=i*n-g;j=j*p-h;l=l*n-g;m=m*p-h;p=1/(i*m-l*j);n=(m*c-j*e)*p;j=(m*d-j*f)*p;c=(i*e-l*c)*p;d=(i*f-l*d)*p;a=a-n*g-c*h;b=b-j*g-d*h;k.save();k.transform(n,j,c,d,a,b);k.clip();k.drawImage(o,0,0);k.restore()}function wa(a,b,c,d){var e=~~(255*a.r),
+f=~~(255*a.g),a=~~(255*a.b),g=~~(255*b.r),h=~~(255*b.g),b=~~(255*b.b),i=~~(255*c.r),j=~~(255*c.g),c=~~(255*c.b),k=~~(255*d.r),l=~~(255*d.g),d=~~(255*d.b);ba[0]=0>e?0:255<e?255:e;ba[1]=0>f?0:255<f?255:f;ba[2]=0>a?0:255<a?255:a;ba[4]=0>g?0:255<g?255:g;ba[5]=0>h?0:255<h?255:h;ba[6]=0>b?0:255<b?255:b;ba[8]=0>i?0:255<i?255:i;ba[9]=0>j?0:255<j?255:j;ba[10]=0>c?0:255<c?255:c;ba[12]=0>k?0:255<k?255:k;ba[13]=0>l?0:255<l?255:l;ba[14]=0>d?0:255<d?255:d;ta.putImageData(za,0,0);va.drawImage(sa,0,0);return ua}
+function pa(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function ra(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}function ka(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;0!=e&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var xa,Ha,W,ca;this.autoClear?this.clear():k.setTransform(1,0,0,-1,n,p);f.info.render.vertices=0;f.info.render.faces=0;g=h.projectScene(a,l,this.sortElements);i=g.elements;j=g.lights;(ya=0<j.length)&&o(j);for(xa=0,Ha=i.length;xa<Ha;xa++)if(W=i[xa],ca=W.material,ca=ca instanceof THREE.MeshFaceMaterial?
+W.faceMaterial:ca,!(null==ca||0==ca.opacity)){Y.empty();if(W instanceof THREE.RenderableParticle)r=W,r.x*=n,r.y*=p,t(r,W,ca,a);else if(W instanceof THREE.RenderableLine)r=W.v1,v=W.v2,r.positionScreen.x*=n,r.positionScreen.y*=p,v.positionScreen.x*=n,v.positionScreen.y*=p,Y.addPoint(r.positionScreen.x,r.positionScreen.y),Y.addPoint(v.positionScreen.x,v.positionScreen.y),ma.intersects(Y)&&u(r,v,W,ca,a);else if(W instanceof THREE.RenderableFace3)r=W.v1,v=W.v2,y=W.v3,r.positionScreen.x*=n,r.positionScreen.y*=
+p,v.positionScreen.x*=n,v.positionScreen.y*=p,y.positionScreen.x*=n,y.positionScreen.y*=p,ca.overdraw&&(ka(r.positionScreen,v.positionScreen),ka(v.positionScreen,y.positionScreen),ka(y.positionScreen,r.positionScreen)),Y.add3Points(r.positionScreen.x,r.positionScreen.y,v.positionScreen.x,v.positionScreen.y,y.positionScreen.x,y.positionScreen.y),ma.intersects(Y)&&D(r,v,y,0,1,2,W,ca,a);else if(W instanceof THREE.RenderableFace4)r=W.v1,v=W.v2,y=W.v3,K=W.v4,r.positionScreen.x*=n,r.positionScreen.y*=p,
+v.positionScreen.x*=n,v.positionScreen.y*=p,y.positionScreen.x*=n,y.positionScreen.y*=p,K.positionScreen.x*=n,K.positionScreen.y*=p,$.positionScreen.copy(v.positionScreen),da.positionScreen.copy(K.positionScreen),ca.overdraw&&(ka(r.positionScreen,v.positionScreen),ka(v.positionScreen,K.positionScreen),ka(K.positionScreen,r.positionScreen),ka(y.positionScreen,$.positionScreen),ka(y.positionScreen,da.positionScreen)),Y.addPoint(r.positionScreen.x,r.positionScreen.y),Y.addPoint(v.positionScreen.x,v.positionScreen.y),
+Y.addPoint(y.positionScreen.x,y.positionScreen.y),Y.addPoint(K.positionScreen.x,K.positionScreen.y),ma.intersects(Y)&&L(r,v,y,K,$,da,W,ca,a);Z.addRectangle(Y)}k.setTransform(1,0,0,1,0,0)}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
 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.faceMaterial=this.material=null;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.faceMaterial=this.material=null;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.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null};

+ 4 - 4
build/custom/ThreeDOM.js

@@ -1,6 +1,6 @@
 // ThreeDOM.js - http://github.com/mrdoob/three.js
 'use strict';var THREE=THREE||{REVISION:"49dev"};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;
-(function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c<b.length&&!window.requestAnimationFrame;++c)window.requestAnimationFrame=window[b[c]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[b[c]+"CancelAnimationFrame"]||window[b[c]+"CancelRequestAnimationFrame"];if(!window.requestAnimationFrame)window.requestAnimationFrame=function(b){var c=(new Date).getTime(),f=Math.max(0,16-(c-a)),g=window.setTimeout(function(){b(c+f)},f);a=c+f;return g};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=
+(function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c<b.length&&!window.requestAnimationFrame;++c)window.requestAnimationFrame=window[b[c]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[b[c]+"CancelAnimationFrame"]||window[b[c]+"CancelRequestAnimationFrame"];if(!window.requestAnimationFrame)window.requestAnimationFrame=function(b){var c=Date.now(),f=Math.max(0,16-(c-a)),g=window.setTimeout(function(){b(c+f)},f);a=c+f;return g};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=
 function(a){clearTimeout(a)}})();THREE.Color=function(a){void 0!==a&&this.setHex(a);return this};
 THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a){this.r=a.r*a.r;this.g=a.g*a.g;this.b=a.b*a.b;return this},copyLinearToGamma:function(a){this.r=Math.sqrt(a.r);this.g=Math.sqrt(a.g);this.b=Math.sqrt(a.b);return this},convertGammaToLinear:function(){var a=this.r,b=this.g,c=this.b;this.r=a*a;this.g=b*b;this.b=c*c;return this},convertLinearToGamma:function(){this.r=Math.sqrt(this.r);this.g=Math.sqrt(this.g);
 this.b=Math.sqrt(this.b);return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,e,f;if(0===c)this.r=this.g=this.b=0;else switch(d=Math.floor(6*a),e=6*a-d,a=c*(1-b),f=c*(1-b*e),b=c*(1-b*(1-e)),d){case 1:this.r=f;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=f;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=c;this.g=a;this.b=f;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=
@@ -80,7 +80,7 @@ this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRo
 this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-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);0===a?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},multiply:function(a,
 b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,i=a.z,a=a.w;this.x=b*a+e*f+c*i-d*g;this.y=c*a+e*g+d*f-b*i;this.z=d*a+e*i+b*g-c*f;this.w=e*a-b*f-c*g-d*i;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,i=this.z,k=this.w,h=k*c+g*e-i*d,j=k*d+i*c-f*e,l=k*e+f*
 d-g*c,c=-f*c-g*d-i*e;b.x=h*k+c*-f+j*-i-l*-g;b.y=j*k+c*-g+l*-f-h*-i;b.z=l*k+c*-i+h*-g-j*-f;return b},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(0.001>Math.abs(e))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;b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(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;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(0.0010>Math.abs(e))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;b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Vertex.prototype={constructor:THREE.Vertex,clone:function(){return new THREE.Vertex(this.position.clone())}};THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};
 THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;for(b=0,c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();for(b=0,c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();for(b=0,c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
 return a}};THREE.Face4=function(a,b,c,d,e,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};
@@ -117,8 +117,8 @@ THREE.SpriteAlignment.topLeft=new THREE.Vector2(1,-1);THREE.SpriteAlignment.topC
 THREE.SpriteAlignment.bottomRight=new THREE.Vector2(-1,1);THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=null;this.matrixAutoUpdate=!1;this.__objects=[];this.__lights=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;
 THREE.Scene.prototype.__addObject=function(a){if(a instanceof THREE.Light)-1===this.__lights.indexOf(a)&&this.__lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&-1===this.__objects.indexOf(a)){this.__objects.push(a);this.__objectsAdded.push(a);var b=this.__objectsRemoved.indexOf(a);-1!==b&&this.__objectsRemoved.splice(b,1)}for(b=0;b<a.children.length;b++)this.__addObject(a.children[b])};
 THREE.Scene.prototype.__removeObject=function(a){if(a instanceof THREE.Light){var b=this.__lights.indexOf(a);-1!==b&&this.__lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.__objects.indexOf(a),-1!==b&&(this.__objects.splice(b,1),this.__objectsRemoved.push(a),b=this.__objectsAdded.indexOf(a),-1!==b&&this.__objectsAdded.splice(b,1)));for(b=0;b<a.children.length;b++)this.__removeObject(a.children[b])};
-THREE.DOMRenderer=function(){var a,b,c,d,e,f,g,i=new THREE.Projector;g=function(a){for(var b=document.documentElement,c=0;c<a.length;c++)if("string"===typeof b.style[a[c]])return a[c];return null}(["transform","MozTransform","WebkitTransform","msTransform","OTransform"]);this.domElement=document.createElement("div");this.setSize=function(a,b){c=a;d=b;e=c/2;f=d/2};this.render=function(c,d){var j,l,n,m,p,o;a=i.projectScene(c,d);b=a.elements;for(j=0,l=b.length;j<l;j++)if(n=b[j],n instanceof THREE.RenderableParticle&&
-n.material instanceof THREE.ParticleDOMMaterial)m=n.material.domElement,p=n.x*e+e-(m.offsetWidth>>1),o=n.y*f+f-(m.offsetHeight>>1),m.style.left=p+"px",m.style.top=o+"px",m.style.zIndex=Math.abs(Math.floor((1-n.z)*d.far/d.near)),g&&(m.style[g]="scale("+n.scale.x*e+","+n.scale.y*f+")")}};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};
+THREE.DOMRenderer=function(){console.log("THREE.DOMRenderer",THREE.REVISION);var a,b,c,d,e,f,g,i=new THREE.Projector;g=function(a){for(var b=document.documentElement,c=0;c<a.length;c++)if("string"===typeof b.style[a[c]])return a[c];return null}(["transform","MozTransform","WebkitTransform","msTransform","OTransform"]);this.domElement=document.createElement("div");this.setSize=function(a,b){c=a;d=b;e=c/2;f=d/2};this.render=function(c,d){var j,l,n,m,p,o;a=i.projectScene(c,d);b=a.elements;for(j=0,l=
+b.length;j<l;j++)if(n=b[j],n instanceof THREE.RenderableParticle&&n.material instanceof THREE.ParticleDOMMaterial)m=n.material.domElement,p=n.x*e+e-(m.offsetWidth>>1),o=n.y*f+f-(m.offsetHeight>>1),m.style.left=p+"px",m.style.top=o+"px",m.style.zIndex=Math.abs(Math.floor((1-n.z)*d.far/d.near)),g&&(m.style[g]="scale("+n.scale.x*e+","+n.scale.y*f+")")}};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};
 THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
 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.faceMaterial=this.material=null;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.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};THREE.RenderableObject=function(){this.z=this.object=null};

+ 6 - 6
build/custom/ThreeExtras.js

@@ -108,7 +108,7 @@ c)THREE.Quaternion.slerp(f,e,a.quaternion,d);else if("scl"===c)c=a.scale,c.x=f[0
 THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],d=[],f,e,g,h,j,i;f=(a.length-1)*b;e=Math.floor(f);f-=e;c[0]=0===e?e:e-1;c[1]=e;c[2]=e>a.length-2?e:e+1;c[3]=e>a.length-3?e:e+2;e=a[c[0]];h=a[c[1]];j=a[c[2]];i=a[c[3]];c=f*f;g=f*c;d[0]=this.interpolate(e[0],h[0],j[0],i[0],f,c,g);d[1]=this.interpolate(e[1],h[1],j[1],i[1],f,c,g);d[2]=this.interpolate(e[2],h[2],j[2],i[2],f,c,g);return d};
 THREE.Animation.prototype.interpolate=function(a,b,c,d,f,e,g){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*e+a*f+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c<d.length-1?c:d.length-1:c%d.length;c<d.length;c++)if(void 0!==d[c][a])return d[c];return this.data.hierarchy[b].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?0<c?c:0:0<=c?c:c+d.length;0<=c;c--)if(void 0!==d[c][a])return d[c];return this.data.hierarchy[b].keys[d.length-1]};
-THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.001;this.isPlaying=!1;this.loop=this.isPaused=!0;this.JITCompile=void 0!==c?c:!0;a=0;for(b=this.hierarchy.length;a<b;a++){var c=this.data.hierarchy[a].sids,d=this.hierarchy[a];if(this.data.hierarchy[a].keys.length&&c){for(var f=0;f<c.length;f++){var e=c[f],g=this.getNextKeyWith(e,a,0);g&&g.apply(e)}d.matrixAutoUpdate=!1;this.data.hierarchy[a].node.updateMatrix();
+THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.0010;this.isPlaying=!1;this.loop=this.isPaused=!0;this.JITCompile=void 0!==c?c:!0;a=0;for(b=this.hierarchy.length;a<b;a++){var c=this.data.hierarchy[a].sids,d=this.hierarchy[a];if(this.data.hierarchy[a].keys.length&&c){for(var f=0;f<c.length;f++){var e=c[f],g=this.getNextKeyWith(e,a,0);g&&g.apply(e)}d.matrixAutoUpdate=!1;this.data.hierarchy[a].node.updateMatrix();
 d.matrixWorldNeedsUpdate=!0}}};
 THREE.KeyFrameAnimation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=void 0!==a?a:!0;this.currentTime=void 0!==b?b:0;this.startTimeMs=b;this.startTime=1E7;this.endTime=-this.startTime;var c,d=this.hierarchy.length,f,e;for(c=0;c<d;c++){f=this.hierarchy[c];e=this.data.hierarchy[c];f.useQuaternion=!0;if(void 0===e.animationCache)e.animationCache={},e.animationCache.prevKey=null,e.animationCache.nextKey=null,e.animationCache.originalMatrix=f instanceof THREE.Bone?f.skinMatrix:
 f.matrix;f=this.data.hierarchy[c].keys;if(f.length)e.animationCache.prevKey=f[0],e.animationCache.nextKey=f[1],this.startTime=Math.min(f[0].time,this.startTime),this.endTime=Math.max(f[f.length-1].time,this.endTime)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};THREE.KeyFrameAnimation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
@@ -127,7 +127,7 @@ THREE.CombinedCamera.prototype.setSize=function(a,b){this.cameraP.aspect=a/b;thi
 THREE.CombinedCamera.prototype.setLens=function(a,b){var c=2*Math.atan((void 0!==b?b:24)/(2*a))*(180/Math.PI);this.setFov(c);return c};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};
 THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};
 THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};
-THREE.FirstPersonControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=void 0!==b?b:document;this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=
+THREE.FirstPersonControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=void 0!==b?b:document;this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=
 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=
@@ -137,14 +137,14 @@ this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b)
 this.object.lookAt(b)}};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){return 1>(a*=2)?0.5*a*a:-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function f(a,b,c,d){var f={name:c,fps:0.6,length:d,hierarchy:[]},e,g=b.getControlPointsArray(),h=b.getLength(),q=g.length,t=0;e=q-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[e]={time:d,pos:g[e],rot:[0,0,0,1],scl:[1,1,1]};for(e=1;e<q-1;e++)t=d*h.chunks[e]/h.total,b.keys[e]={time:t,pos:g[e]};f.hierarchy[0]=b;THREE.AnimationHandler.add(f);
 return new THREE.Animation(a,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function e(a,b){var c,d,e=new THREE.Geometry;for(c=0;c<a.points.length*b;c++)d=c/(a.points.length*b),d=a.getPoint(d),e.vertices[c]=new THREE.Vertex(new THREE.Vector3(d.x,d.y,d.z));return e}this.object=a;this.domElement=void 0!==b?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.005;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/
+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=2*Math.PI,h=Math.PI/180;this.update=function(a){var b;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed*a);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed*a);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)*h;this.theta=this.lon*h;a=this.phi%g;this.phi=0<=a?a:a+g;b=this.verticalAngleMap.srcRange;a=this.verticalAngleMap.dstRange;
 b=THREE.Math.mapLinear(this.phi,b[0],b[1],a[0],a[1]);var d=a[1]-a[0];this.phi=c((b-a[0])/d)*d+a[0];b=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;b=THREE.Math.mapLinear(this.theta,b[0],b[1],a[0],a[1]);d=a[1]-a[0];this.theta=c((b-a[0])/d)*d+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.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}),b=new THREE.MeshLambertMaterial({color:65280}),
 c=new THREE.CubeGeometry(10,10,20),g=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(g,b);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,b=this.spline,g=e(b,10),c=e(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),g=new THREE.Line(g,h),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));g.scale.set(1,1,1);a.add(g);c.scale.set(1,1,1);a.add(c);for(var g=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),n=0;n<b.points.length;n++)c=new THREE.Mesh(g,h),c.position.copy(b.points[n]),a.add(c)}this.domElement.addEventListener("mousemove",d(this,this.onMouseMove),
 !1)}};THREE.PathControlsIdCounter=0;
-THREE.FlyControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=void 0!==b?b:document;b&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.005;this.autoForward=this.dragToLook=!1;this.object.useQuaternion=!0;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,
+THREE.FlyControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=void 0!==b?b:document;b&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.object.useQuaternion=!0;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,
 0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.handleEvent=function(a){if("function"==typeof this[a.type])this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.keyCode){case 16:this.movementSpeedMultiplier=0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=
 1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};this.keyup=function(a){switch(a.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=
 0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.object.moveForward=
@@ -381,8 +381,8 @@ b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);0>=b.getParameter(b
 "color");l.scale=b.getUniformLocation(k,"scale");l.rotation=b.getUniformLocation(k,"rotation");l.screenPosition=b.getUniformLocation(k,"screenPosition");n=!1};this.render=function(a,d,f,t){var a=a.__webglFlares,s=a.length;if(s){var v=new THREE.Vector3,o=t/f,x=0.5*f,y=0.5*t,z=16/t,u=new THREE.Vector2(z*o,z),w=new THREE.Vector3(1,1,0),E=new THREE.Vector2(1,1),H=l,z=p;b.useProgram(k);n||(b.enableVertexAttribArray(p.vertex),b.enableVertexAttribArray(p.uv),n=!0);b.uniform1i(H.occlusionMap,0);b.uniform1i(H.map,
 1);b.bindBuffer(b.ARRAY_BUFFER,e);b.vertexAttribPointer(z.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(z.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.disable(b.CULL_FACE);b.depthMask(!1);var I,J,C,A,B;for(I=0;I<s;I++)if(z=16/t,u.set(z*o,z),A=a[I],v.set(A.matrixWorld.n14,A.matrixWorld.n24,A.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(v),d.projectionMatrix.multiplyVector3(v),w.copy(v),E.x=w.x*x+x,E.y=w.y*y+y,i||0<E.x&&E.x<f&&0<E.y&&E.y<t){b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,
 h);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,E.x-8,E.y-8,16,16,0);b.uniform1i(H.renderType,0);b.uniform2f(H.scale,u.x,u.y);b.uniform3f(H.screenPosition,w.x,w.y,w.z);b.disable(b.BLEND);b.enable(b.DEPTH_TEST);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,j);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,E.x-8,E.y-8,16,16,0);b.uniform1i(H.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,h);b.drawElements(b.TRIANGLES,
-6,b.UNSIGNED_SHORT,0);A.positionScreen.copy(w);A.customUpdateCallback?A.customUpdateCallback(A):A.updateLensFlares();b.uniform1i(H.renderType,2);b.enable(b.BLEND);for(J=0,C=A.lensFlares.length;J<C;J++)if(B=A.lensFlares[J],0.001<B.opacity&&0.001<B.scale)w.x=B.x,w.y=B.y,w.z=B.z,z=B.size*B.scale/t,u.x=z*o,u.y=z,b.uniform3f(H.screenPosition,w.x,w.y,w.z),b.uniform2f(H.scale,u.x,u.y),b.uniform1f(H.rotation,B.rotation),b.uniform1f(H.opacity,B.opacity),b.uniform3f(H.color,B.color.r,B.color.g,B.color.b),c.setBlending(B.blending,
-B.blendEquation,B.blendSrc,B.blendDst),c.setTexture(B.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
+6,b.UNSIGNED_SHORT,0);A.positionScreen.copy(w);A.customUpdateCallback?A.customUpdateCallback(A):A.updateLensFlares();b.uniform1i(H.renderType,2);b.enable(b.BLEND);for(J=0,C=A.lensFlares.length;J<C;J++)if(B=A.lensFlares[J],0.0010<B.opacity&&0.0010<B.scale)w.x=B.x,w.y=B.y,w.z=B.z,z=B.size*B.scale/t,u.x=z*o,u.y=z,b.uniform3f(H.screenPosition,w.x,w.y,w.z),b.uniform2f(H.scale,u.x,u.y),b.uniform1f(H.rotation,B.rotation),b.uniform1f(H.opacity,B.opacity),b.uniform3f(H.color,B.color.r,B.color.g,B.color.b),
+c.setBlending(B.blending,B.blendEquation,B.blendSrc,B.blendDst),c.setTexture(B.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
 THREE.ShadowMapPlugin=function(){var a,b,c,d,f=new THREE.Frustum,e=new THREE.Matrix4,g=new THREE.Vector3,h=new THREE.Vector3;this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f,morphTargets:!0});c._shadowPass=!0;d._shadowPass=!0};this.render=function(a,
 c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(j,i){var k,p,l,n,r,m,q,t,s,v=[];n=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.FRONT);b.setDepthTest(!0);for(k=0,p=j.__lights.length;k<p;k++)if(l=j.__lights[k],l.castShadow)if(l instanceof THREE.DirectionalLight&&l.shadowCascade)for(r=0;r<l.shadowCascadeCount;r++){var o;if(l.shadowCascadeArray[r])o=l.shadowCascadeArray[r];else{s=l;q=r;o=new THREE.DirectionalLight;o.isVirtual=
 !0;o.onlyShadow=!0;o.castShadow=!0;o.shadowCameraNear=s.shadowCameraNear;o.shadowCameraFar=s.shadowCameraFar;o.shadowCameraLeft=s.shadowCameraLeft;o.shadowCameraRight=s.shadowCameraRight;o.shadowCameraBottom=s.shadowCameraBottom;o.shadowCameraTop=s.shadowCameraTop;o.shadowCameraVisible=s.shadowCameraVisible;o.shadowDarkness=s.shadowDarkness;o.shadowBias=s.shadowCascadeBias[q];o.shadowMapWidth=s.shadowCascadeWidth[q];o.shadowMapHeight=s.shadowCascadeHeight[q];o.pointsWorld=[];o.pointsFrustum=[];t=

+ 12 - 12
build/custom/ThreeSVG.js

@@ -1,6 +1,6 @@
 // ThreeSVG.js - http://github.com/mrdoob/three.js
 'use strict';var THREE=THREE||{REVISION:"49dev"};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;
-(function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c<b.length&&!window.requestAnimationFrame;++c)window.requestAnimationFrame=window[b[c]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[b[c]+"CancelAnimationFrame"]||window[b[c]+"CancelRequestAnimationFrame"];if(!window.requestAnimationFrame)window.requestAnimationFrame=function(b){var c=(new Date).getTime(),f=Math.max(0,16-(c-a)),g=window.setTimeout(function(){b(c+f)},f);a=c+f;return g};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=
+(function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c<b.length&&!window.requestAnimationFrame;++c)window.requestAnimationFrame=window[b[c]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[b[c]+"CancelAnimationFrame"]||window[b[c]+"CancelRequestAnimationFrame"];if(!window.requestAnimationFrame)window.requestAnimationFrame=function(b){var c=Date.now(),f=Math.max(0,16-(c-a)),g=window.setTimeout(function(){b(c+f)},f);a=c+f;return g};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=
 function(a){clearTimeout(a)}})();THREE.Color=function(a){void 0!==a&&this.setHex(a);return this};
 THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a){this.r=a.r*a.r;this.g=a.g*a.g;this.b=a.b*a.b;return this},copyLinearToGamma:function(a){this.r=Math.sqrt(a.r);this.g=Math.sqrt(a.g);this.b=Math.sqrt(a.b);return this},convertGammaToLinear:function(){var a=this.r,b=this.g,c=this.b;this.r=a*a;this.g=b*b;this.b=c*c;return this},convertLinearToGamma:function(){this.r=Math.sqrt(this.r);this.g=Math.sqrt(this.g);
 this.b=Math.sqrt(this.b);return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,e,f;if(0===c)this.r=this.g=this.b=0;else switch(d=Math.floor(6*a),e=6*a-d,a=c*(1-b),f=c*(1-b*e),b=c*(1-b*(1-e)),d){case 1:this.r=f;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=f;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=c;this.g=a;this.b=f;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=
@@ -80,7 +80,7 @@ this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRo
 this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-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);0===a?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},multiply:function(a,
 b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,i=a.z,a=a.w;this.x=b*a+e*f+c*i-d*g;this.y=c*a+e*g+d*f-b*i;this.z=d*a+e*i+b*g-c*f;this.w=e*a-b*f-c*g-d*i;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,i=this.z,j=this.w,h=j*c+g*e-i*d,k=j*d+i*c-f*e,m=j*e+f*
 d-g*c,c=-f*c-g*d-i*e;b.x=h*j+c*-f+k*-i-m*-g;b.y=k*j+c*-g+m*-f-h*-i;b.z=m*j+c*-i+h*-g-k*-f;return b},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(0.001>Math.abs(e))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;b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(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;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(0.0010>Math.abs(e))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;b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Vertex.prototype={constructor:THREE.Vertex,clone:function(){return new THREE.Vertex(this.position.clone())}};THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};
 THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;for(b=0,c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();for(b=0,c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();for(b=0,c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
 return a}};THREE.Face4=function(a,b,c,d,e,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};
@@ -144,17 +144,17 @@ THREE.SpriteAlignment.bottomRight=new THREE.Vector2(-1,1);THREE.Scene=function()
 THREE.Scene.prototype.__addObject=function(a){if(a instanceof THREE.Light)-1===this.__lights.indexOf(a)&&this.__lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&-1===this.__objects.indexOf(a)){this.__objects.push(a);this.__objectsAdded.push(a);var b=this.__objectsRemoved.indexOf(a);-1!==b&&this.__objectsRemoved.splice(b,1)}for(b=0;b<a.children.length;b++)this.__addObject(a.children[b])};
 THREE.Scene.prototype.__removeObject=function(a){if(a instanceof THREE.Light){var b=this.__lights.indexOf(a);-1!==b&&this.__lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.__objects.indexOf(a),-1!==b&&(this.__objects.splice(b,1),this.__objectsRemoved.push(a),b=this.__objectsAdded.indexOf(a),-1!==b&&this.__objectsAdded.splice(b,1)));for(b=0;b<a.children.length;b++)this.__removeObject(a.children[b])};
 THREE.SVGRenderer=function(){function a(a,b,c,d){var e,f,g,h,i,j;for(e=0,f=a.length;e<f;e++)g=a[e],h=g.color,g instanceof THREE.DirectionalLight?(i=g.matrixWorld.getPosition(),j=c.dot(i),0>=j||(j*=g.intensity,d.r+=h.r*j,d.g+=h.g*j,d.b+=h.b*j)):g instanceof THREE.PointLight&&(i=g.matrixWorld.getPosition(),j=c.dot(E.sub(i,b).normalize()),0>=j||(j*=0==g.distance?1:1-Math.min(b.distanceTo(i)/g.distance,1),0!=j&&(j*=g.intensity,d.r+=h.r*j,d.g+=h.g*j,d.b+=h.b*j)))}function b(a){null==B[a]&&(B[a]=document.createElementNS("http://www.w3.org/2000/svg",
-"path"),0==M&&B[a].setAttribute("shape-rendering","crispEdges"));return B[a]}function c(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}var d=this,e,f,g,i=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),h,k,m,n,l,o,p,u,H=new THREE.Rectangle,w=new THREE.Rectangle,D=!1,s=new THREE.Color,t=new THREE.Color,y=new THREE.Color,x=new THREE.Color,z,E=new THREE.Vector3,B=[],F=[],A,L,P,M=1;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,
-faces:0}};this.setQuality=function(a){switch(a){case "high":M=1;break;case "low":M=0}};this.setSize=function(a,b){h=a;k=b;m=h/2;n=k/2;j.setAttribute("viewBox",-m+" "+-n+" "+h+" "+k);j.setAttribute("width",h);j.setAttribute("height",k);H.set(-m,-n,m,n)};this.clear=function(){for(;0<j.childNodes.length;)j.removeChild(j.childNodes[0])};this.render=function(h,k){var B,E,r,q;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=i.projectScene(h,k,this.sortElements);f=e.elements;
-g=e.lights;P=L=0;if(D=0<g.length){t.setRGB(0,0,0);y.setRGB(0,0,0);x.setRGB(0,0,0);for(B=0,E=g.length;B<E;B++)q=g[B],r=q.color,q instanceof THREE.AmbientLight?(t.r+=r.r,t.g+=r.g,t.b+=r.b):q instanceof THREE.DirectionalLight?(y.r+=r.r,y.g+=r.g,y.b+=r.b):q instanceof THREE.PointLight&&(x.r+=r.r,x.g+=r.g,x.b+=r.b)}for(B=0,E=f.length;B<E;B++)if(r=f[B],q=r.material,q=q instanceof THREE.MeshFaceMaterial?r.faceMaterial:q,!(null==q||0==q.opacity))if(w.empty(),r instanceof THREE.RenderableParticle)l=r,l.x*=
-m,l.y*=-n;else if(r instanceof THREE.RenderableLine){if(l=r.v1,o=r.v2,l.positionScreen.x*=m,l.positionScreen.y*=-n,o.positionScreen.x*=m,o.positionScreen.y*=-n,w.addPoint(l.positionScreen.x,l.positionScreen.y),w.addPoint(o.positionScreen.x,o.positionScreen.y),H.intersects(w)){r=l;var J=o,v=P++;null==F[v]&&(F[v]=document.createElementNS("http://www.w3.org/2000/svg","line"),0==M&&F[v].setAttribute("shape-rendering","crispEdges"));A=F[v];A.setAttribute("x1",r.positionScreen.x);A.setAttribute("y1",r.positionScreen.y);
-A.setAttribute("x2",J.positionScreen.x);A.setAttribute("y2",J.positionScreen.y);q instanceof THREE.LineBasicMaterial&&(A.setAttribute("style","fill: none; stroke: "+q.color.getContextStyle()+"; stroke-width: "+q.linewidth+"; stroke-opacity: "+q.opacity+"; stroke-linecap: "+q.linecap+"; stroke-linejoin: "+q.linejoin),j.appendChild(A))}}else if(r instanceof THREE.RenderableFace3){if(l=r.v1,o=r.v2,p=r.v3,l.positionScreen.x*=m,l.positionScreen.y*=-n,o.positionScreen.x*=m,o.positionScreen.y*=-n,p.positionScreen.x*=
-m,p.positionScreen.y*=-n,w.addPoint(l.positionScreen.x,l.positionScreen.y),w.addPoint(o.positionScreen.x,o.positionScreen.y),w.addPoint(p.positionScreen.x,p.positionScreen.y),H.intersects(w)){var J=l,v=o,G=p;d.info.render.vertices+=3;d.info.render.faces++;A=b(L++);A.setAttribute("d","M "+J.positionScreen.x+" "+J.positionScreen.y+" L "+v.positionScreen.x+" "+v.positionScreen.y+" L "+G.positionScreen.x+","+G.positionScreen.y+"z");q instanceof THREE.MeshBasicMaterial?s.copy(q.color):q instanceof THREE.MeshLambertMaterial?
-D?(s.r=t.r,s.g=t.g,s.b=t.b,a(g,r.centroidWorld,r.normalWorld,s),s.r=Math.max(0,Math.min(q.color.r*s.r,1)),s.g=Math.max(0,Math.min(q.color.g*s.g,1)),s.b=Math.max(0,Math.min(q.color.b*s.b,1))):s.copy(q.color):q instanceof THREE.MeshDepthMaterial?(z=1-q.__2near/(q.__farPlusNear-r.z*q.__farMinusNear),s.setRGB(z,z,z)):q instanceof THREE.MeshNormalMaterial&&s.setRGB(c(r.normalWorld.x),c(r.normalWorld.y),c(r.normalWorld.z));q.wireframe?A.setAttribute("style","fill: none; stroke: "+s.getContextStyle()+"; stroke-width: "+
-q.wireframeLinewidth+"; stroke-opacity: "+q.opacity+"; stroke-linecap: "+q.wireframeLinecap+"; stroke-linejoin: "+q.wireframeLinejoin):A.setAttribute("style","fill: "+s.getContextStyle()+"; fill-opacity: "+q.opacity);j.appendChild(A)}}else if(r instanceof THREE.RenderableFace4&&(l=r.v1,o=r.v2,p=r.v3,u=r.v4,l.positionScreen.x*=m,l.positionScreen.y*=-n,o.positionScreen.x*=m,o.positionScreen.y*=-n,p.positionScreen.x*=m,p.positionScreen.y*=-n,u.positionScreen.x*=m,u.positionScreen.y*=-n,w.addPoint(l.positionScreen.x,
-l.positionScreen.y),w.addPoint(o.positionScreen.x,o.positionScreen.y),w.addPoint(p.positionScreen.x,p.positionScreen.y),w.addPoint(u.positionScreen.x,u.positionScreen.y),H.intersects(w))){var J=l,v=o,G=p,I=u;d.info.render.vertices+=4;d.info.render.faces++;A=b(L++);A.setAttribute("d","M "+J.positionScreen.x+" "+J.positionScreen.y+" L "+v.positionScreen.x+" "+v.positionScreen.y+" L "+G.positionScreen.x+","+G.positionScreen.y+" L "+I.positionScreen.x+","+I.positionScreen.y+"z");q instanceof THREE.MeshBasicMaterial?
+"path"),0==M&&B[a].setAttribute("shape-rendering","crispEdges"));return B[a]}function c(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}console.log("THREE.SVGRenderer",THREE.REVISION);var d=this,e,f,g,i=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),h,k,m,n,l,o,p,u,H=new THREE.Rectangle,w=new THREE.Rectangle,D=!1,s=new THREE.Color,t=new THREE.Color,y=new THREE.Color,x=new THREE.Color,z,E=new THREE.Vector3,B=[],F=[],A,L,P,M=1;this.domElement=j;this.sortElements=this.sortObjects=
+this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setQuality=function(a){switch(a){case "high":M=1;break;case "low":M=0}};this.setSize=function(a,b){h=a;k=b;m=h/2;n=k/2;j.setAttribute("viewBox",-m+" "+-n+" "+h+" "+k);j.setAttribute("width",h);j.setAttribute("height",k);H.set(-m,-n,m,n)};this.clear=function(){for(;0<j.childNodes.length;)j.removeChild(j.childNodes[0])};this.render=function(h,k){var B,E,r,q;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=i.projectScene(h,
+k,this.sortElements);f=e.elements;g=e.lights;P=L=0;if(D=0<g.length){t.setRGB(0,0,0);y.setRGB(0,0,0);x.setRGB(0,0,0);for(B=0,E=g.length;B<E;B++)q=g[B],r=q.color,q instanceof THREE.AmbientLight?(t.r+=r.r,t.g+=r.g,t.b+=r.b):q instanceof THREE.DirectionalLight?(y.r+=r.r,y.g+=r.g,y.b+=r.b):q instanceof THREE.PointLight&&(x.r+=r.r,x.g+=r.g,x.b+=r.b)}for(B=0,E=f.length;B<E;B++)if(r=f[B],q=r.material,q=q instanceof THREE.MeshFaceMaterial?r.faceMaterial:q,!(null==q||0==q.opacity))if(w.empty(),r instanceof
+THREE.RenderableParticle)l=r,l.x*=m,l.y*=-n;else if(r instanceof THREE.RenderableLine){if(l=r.v1,o=r.v2,l.positionScreen.x*=m,l.positionScreen.y*=-n,o.positionScreen.x*=m,o.positionScreen.y*=-n,w.addPoint(l.positionScreen.x,l.positionScreen.y),w.addPoint(o.positionScreen.x,o.positionScreen.y),H.intersects(w)){r=l;var J=o,v=P++;null==F[v]&&(F[v]=document.createElementNS("http://www.w3.org/2000/svg","line"),0==M&&F[v].setAttribute("shape-rendering","crispEdges"));A=F[v];A.setAttribute("x1",r.positionScreen.x);
+A.setAttribute("y1",r.positionScreen.y);A.setAttribute("x2",J.positionScreen.x);A.setAttribute("y2",J.positionScreen.y);q instanceof THREE.LineBasicMaterial&&(A.setAttribute("style","fill: none; stroke: "+q.color.getContextStyle()+"; stroke-width: "+q.linewidth+"; stroke-opacity: "+q.opacity+"; stroke-linecap: "+q.linecap+"; stroke-linejoin: "+q.linejoin),j.appendChild(A))}}else if(r instanceof THREE.RenderableFace3){if(l=r.v1,o=r.v2,p=r.v3,l.positionScreen.x*=m,l.positionScreen.y*=-n,o.positionScreen.x*=
+m,o.positionScreen.y*=-n,p.positionScreen.x*=m,p.positionScreen.y*=-n,w.addPoint(l.positionScreen.x,l.positionScreen.y),w.addPoint(o.positionScreen.x,o.positionScreen.y),w.addPoint(p.positionScreen.x,p.positionScreen.y),H.intersects(w)){var J=l,v=o,G=p;d.info.render.vertices+=3;d.info.render.faces++;A=b(L++);A.setAttribute("d","M "+J.positionScreen.x+" "+J.positionScreen.y+" L "+v.positionScreen.x+" "+v.positionScreen.y+" L "+G.positionScreen.x+","+G.positionScreen.y+"z");q instanceof THREE.MeshBasicMaterial?
 s.copy(q.color):q instanceof THREE.MeshLambertMaterial?D?(s.r=t.r,s.g=t.g,s.b=t.b,a(g,r.centroidWorld,r.normalWorld,s),s.r=Math.max(0,Math.min(q.color.r*s.r,1)),s.g=Math.max(0,Math.min(q.color.g*s.g,1)),s.b=Math.max(0,Math.min(q.color.b*s.b,1))):s.copy(q.color):q instanceof THREE.MeshDepthMaterial?(z=1-q.__2near/(q.__farPlusNear-r.z*q.__farMinusNear),s.setRGB(z,z,z)):q instanceof THREE.MeshNormalMaterial&&s.setRGB(c(r.normalWorld.x),c(r.normalWorld.y),c(r.normalWorld.z));q.wireframe?A.setAttribute("style",
-"fill: none; stroke: "+s.getContextStyle()+"; stroke-width: "+q.wireframeLinewidth+"; stroke-opacity: "+q.opacity+"; stroke-linecap: "+q.wireframeLinecap+"; stroke-linejoin: "+q.wireframeLinejoin):A.setAttribute("style","fill: "+s.getContextStyle()+"; fill-opacity: "+q.opacity);j.appendChild(A)}}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};
+"fill: none; stroke: "+s.getContextStyle()+"; stroke-width: "+q.wireframeLinewidth+"; stroke-opacity: "+q.opacity+"; stroke-linecap: "+q.wireframeLinecap+"; stroke-linejoin: "+q.wireframeLinejoin):A.setAttribute("style","fill: "+s.getContextStyle()+"; fill-opacity: "+q.opacity);j.appendChild(A)}}else if(r instanceof THREE.RenderableFace4&&(l=r.v1,o=r.v2,p=r.v3,u=r.v4,l.positionScreen.x*=m,l.positionScreen.y*=-n,o.positionScreen.x*=m,o.positionScreen.y*=-n,p.positionScreen.x*=m,p.positionScreen.y*=
+-n,u.positionScreen.x*=m,u.positionScreen.y*=-n,w.addPoint(l.positionScreen.x,l.positionScreen.y),w.addPoint(o.positionScreen.x,o.positionScreen.y),w.addPoint(p.positionScreen.x,p.positionScreen.y),w.addPoint(u.positionScreen.x,u.positionScreen.y),H.intersects(w))){var J=l,v=o,G=p,I=u;d.info.render.vertices+=4;d.info.render.faces++;A=b(L++);A.setAttribute("d","M "+J.positionScreen.x+" "+J.positionScreen.y+" L "+v.positionScreen.x+" "+v.positionScreen.y+" L "+G.positionScreen.x+","+G.positionScreen.y+
+" L "+I.positionScreen.x+","+I.positionScreen.y+"z");q instanceof THREE.MeshBasicMaterial?s.copy(q.color):q instanceof THREE.MeshLambertMaterial?D?(s.r=t.r,s.g=t.g,s.b=t.b,a(g,r.centroidWorld,r.normalWorld,s),s.r=Math.max(0,Math.min(q.color.r*s.r,1)),s.g=Math.max(0,Math.min(q.color.g*s.g,1)),s.b=Math.max(0,Math.min(q.color.b*s.b,1))):s.copy(q.color):q instanceof THREE.MeshDepthMaterial?(z=1-q.__2near/(q.__farPlusNear-r.z*q.__farMinusNear),s.setRGB(z,z,z)):q instanceof THREE.MeshNormalMaterial&&s.setRGB(c(r.normalWorld.x),
+c(r.normalWorld.y),c(r.normalWorld.z));q.wireframe?A.setAttribute("style","fill: none; stroke: "+s.getContextStyle()+"; stroke-width: "+q.wireframeLinewidth+"; stroke-opacity: "+q.opacity+"; stroke-linecap: "+q.wireframeLinecap+"; stroke-linejoin: "+q.wireframeLinejoin):A.setAttribute("style","fill: "+s.getContextStyle()+"; fill-opacity: "+q.opacity);j.appendChild(A)}}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};
 THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
 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.faceMaterial=this.material=null;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.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};THREE.RenderableObject=function(){this.z=this.object=null};

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


+ 1 - 1
examples/webgl_materials_cubemap_dynamic.html

@@ -161,7 +161,7 @@
 				ambientLight = new THREE.AmbientLight( 0x555555 );
 				scene.add( ambientLight );
 
-				spotLight = new THREE.SpotLight( 0xffffff );
+				spotLight = new THREE.SpotLight( 0xffffff, 1, 0, Math.PI, 1 );
 				spotLight.position.set( 0, 1800, 1500 );
 				spotLight.target.position.set( 0, 0, 0 );
 				spotLight.castShadow = true;

+ 1 - 1
examples/webgl_shading_physical.html

@@ -329,7 +329,7 @@
 				pointLight.position.set( 0, 0, 0 );
 				scene.add( pointLight );
 
-				sunLight = new THREE.SpotLight( 0xffffff, sunIntensity );
+				sunLight = new THREE.SpotLight( 0xffffff, sunIntensity, 0, Math.PI, 1 );
 				sunLight.position.set( 1000, 2000, 1000 );
 
 				sunLight.castShadow = true;

+ 1 - 1
examples/webgl_shadowmap.html

@@ -103,7 +103,7 @@
 				var ambient = new THREE.AmbientLight( 0x444444 );
 				scene.add( ambient );
 
-				light = new THREE.SpotLight( 0xffffff );
+				light = new THREE.SpotLight( 0xffffff, 1, 0, Math.PI, 1 );
 				light.position.set( 0, 1500, 1000 );
 				light.target.position.set( 0, 0, 0 );
 

+ 3 - 1
src/lights/SpotLight.js

@@ -2,7 +2,7 @@
  * @author alteredq / http://alteredqualia.com/
  */
 
-THREE.SpotLight = function ( hex, intensity, distance ) {
+THREE.SpotLight = function ( hex, intensity, distance, angle, exponent ) {
 
 	THREE.Light.call( this, hex );
 
@@ -11,6 +11,8 @@ THREE.SpotLight = function ( hex, intensity, distance ) {
 
 	this.intensity = ( intensity !== undefined ) ? intensity : 1;
 	this.distance = ( distance !== undefined ) ? distance : 0;
+	this.angle = ( angle !== undefined ) ? angle : Math.PI / 2;
+	this.exponent = ( exponent !== undefined ) ? exponent : 10;
 
 	this.castShadow = false;
 	this.onlyShadow = false;

+ 91 - 15
src/renderers/WebGLRenderer.js

@@ -160,7 +160,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		ambient: [ 0, 0, 0 ],
 		directional: { length: 0, colors: new Array(), positions: new Array() },
-		point: { length: 0, colors: new Array(), positions: new Array(), distances: new Array() }
+		point: { length: 0, colors: new Array(), positions: new Array(), distances: new Array() },
+		spot: { length: 0, colors: new Array(), positions: new Array(), distances: new Array(), directions: new Array(), angles: new Array(), exponents: new Array() }
 
 	};
 
@@ -4237,22 +4238,35 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		parameters = {
 
-			map: !!material.map, envMap: !!material.envMap, lightMap: !!material.lightMap,
+			map: !!material.map,
+			envMap: !!material.envMap,
+			lightMap: !!material.lightMap,
+
 			vertexColors: material.vertexColors,
-			fog: fog, useFog: material.fog,
+
+			fog: fog,
+			useFog: material.fog,
+
 			sizeAttenuation: material.sizeAttenuation,
+
 			skinning: material.skinning,
+			maxBones: maxBones,
+
 			morphTargets: material.morphTargets,
 			morphNormals: material.morphNormals,
 			maxMorphTargets: this.maxMorphTargets,
 			maxMorphNormals: this.maxMorphNormals,
-			maxDirLights: maxLightCount.directional, maxPointLights: maxLightCount.point,
-			maxBones: maxBones,
+
+			maxDirLights: maxLightCount.directional,
+			maxPointLights: maxLightCount.point,
+			maxSpotLights: maxLightCount.spot,
+
+			maxShadows: maxShadows,
 			shadowMapEnabled: this.shadowMapEnabled && object.receiveShadow,
 			shadowMapSoft: this.shadowMapSoft,
 			shadowMapDebug: this.shadowMapDebug,
 			shadowMapCascade: this.shadowMapCascade,
-			maxShadows: maxShadows,
+
 			alphaTest: material.alphaTest,
 			metal: material.metal,
 			perPixel: material.perPixel,
@@ -4669,6 +4683,13 @@ THREE.WebGLRenderer = function ( parameters ) {
 		uniforms.pointLightPosition.value = lights.point.positions;
 		uniforms.pointLightDistance.value = lights.point.distances;
 
+		uniforms.spotLightColor.value = lights.spot.colors;
+		uniforms.spotLightPosition.value = lights.spot.positions;
+		uniforms.spotLightDistance.value = lights.spot.distances;
+		uniforms.spotLightDirection.value = lights.spot.directions;
+		uniforms.spotLightAngle.value = lights.spot.angles;
+		uniforms.spotLightExponent.value = lights.spot.exponents;
+
 	};
 
 	function refreshUniformsShadow ( uniforms, lights ) {
@@ -4959,11 +4980,20 @@ THREE.WebGLRenderer = function ( parameters ) {
 		ppositions = zlights.point.positions,
 		pdistances = zlights.point.distances,
 
+		scolors = zlights.spot.colors,
+		spositions = zlights.spot.positions,
+		sdistances = zlights.spot.distances,
+		sdirections = zlights.spot.directions,
+		sangles = zlights.spot.angles,
+		sexponents = zlights.spot.exponents,
+
 		dlength = 0,
 		plength = 0,
+		slength = 0,
 
 		doffset = 0,
-		poffset = 0;
+		poffset = 0,
+		soffset = 0;
 
 		for ( l = 0, ll = lights.length; l < ll; l ++ ) {
 
@@ -5019,7 +5049,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				dlength += 1;
 
-			} else if( light instanceof THREE.PointLight || light instanceof THREE.SpotLight ) {
+			} else if( light instanceof THREE.PointLight ) {
 
 				poffset = plength * 3;
 
@@ -5047,6 +5077,45 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				plength += 1;
 
+			} else if( light instanceof THREE.SpotLight ) {
+
+				soffset = slength * 3;
+
+				if ( _this.gammaInput ) {
+
+					scolors[ soffset ]     = color.r * color.r * intensity * intensity;
+					scolors[ soffset + 1 ] = color.g * color.g * intensity * intensity;
+					scolors[ soffset + 2 ] = color.b * color.b * intensity * intensity;
+
+				} else {
+
+					scolors[ soffset ]     = color.r * intensity;
+					scolors[ soffset + 1 ] = color.g * intensity;
+					scolors[ soffset + 2 ] = color.b * intensity;
+
+				}
+
+				position = light.matrixWorld.getPosition();
+
+				spositions[ soffset ]     = position.x;
+				spositions[ soffset + 1 ] = position.y;
+				spositions[ soffset + 2 ] = position.z;
+
+				sdistances[ slength ] = distance;
+
+				_direction.copy( position );
+				_direction.subSelf( light.target.matrixWorld.getPosition() );
+				_direction.normalize();
+
+				sdirections[ soffset ]     = _direction.x;
+				sdirections[ soffset + 1 ] = _direction.y;
+				sdirections[ soffset + 2 ] = _direction.z;
+
+				sangles[ slength ] = Math.cos( light.angle );
+				sexponents[ slength ] = light.exponent;
+
+				slength += 1;
+
 			}
 
 		}
@@ -5056,9 +5125,11 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		for ( l = dlength * 3, ll = dcolors.length; l < ll; l ++ ) dcolors[ l ] = 0.0;
 		for ( l = plength * 3, ll = pcolors.length; l < ll; l ++ ) pcolors[ l ] = 0.0;
+		for ( l = slength * 3, ll = scolors.length; l < ll; l ++ ) scolors[ l ] = 0.0;
 
-		zlights.point.length = plength;
 		zlights.directional.length = dlength;
+		zlights.point.length = plength;
+		zlights.spot.length = slength;
 
 		zlights.ambient[ 0 ] = r;
 		zlights.ambient[ 1 ] = g;
@@ -5362,6 +5433,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			"#define MAX_DIR_LIGHTS " + parameters.maxDirLights,
 			"#define MAX_POINT_LIGHTS " + parameters.maxPointLights,
+			"#define MAX_SPOT_LIGHTS " + parameters.maxSpotLights,
 
 			"#define MAX_SHADOWS " + parameters.maxShadows,
 
@@ -5447,6 +5519,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			"#define MAX_DIR_LIGHTS " + parameters.maxDirLights,
 			"#define MAX_POINT_LIGHTS " + parameters.maxPointLights,
+			"#define MAX_SPOT_LIGHTS " + parameters.maxSpotLights,
 
 			"#define MAX_SHADOWS " + parameters.maxShadows,
 
@@ -6063,10 +6136,11 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	function allocateLights ( lights ) {
 
-		var l, ll, light, dirLights, pointLights, maxDirLights, maxPointLights;
-		dirLights = pointLights = maxDirLights = maxPointLights = 0;
+		var l, ll, light, dirLights, pointLights, spotLights, maxDirLights, maxPointLights, maxSpotLights;
 
-		for ( l = 0, ll = lights.length; l < ll; l++ ) {
+		dirLights = pointLights = spotLights = maxDirLights = maxPointLights = maxSpotLights = 0;
+
+		for ( l = 0, ll = lights.length; l < ll; l ++ ) {
 
 			light = lights[ l ];
 
@@ -6074,23 +6148,25 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			if ( light instanceof THREE.DirectionalLight ) dirLights ++;
 			if ( light instanceof THREE.PointLight ) pointLights ++;
-			if ( light instanceof THREE.SpotLight ) pointLights ++;
+			if ( light instanceof THREE.SpotLight ) spotLights ++;
 
 		}
 
-		if ( ( pointLights + dirLights ) <= _maxLights ) {
+		if ( ( pointLights + spotLights + dirLights ) <= _maxLights ) {
 
 			maxDirLights = dirLights;
 			maxPointLights = pointLights;
+			maxSpotLights = spotLights;
 
 		} else {
 
 			maxDirLights = Math.ceil( _maxLights * dirLights / ( pointLights + dirLights ) );
 			maxPointLights = _maxLights - maxDirLights;
+			maxSpotLights = maxPointLights; // this is not really correct
 
 		}
 
-		return { 'directional' : maxDirLights, 'point' : maxPointLights };
+		return { 'directional' : maxDirLights, 'point' : maxPointLights, 'spot': maxSpotLights };
 
 	};
 

+ 240 - 5
src/renderers/WebGLShaders.js

@@ -285,11 +285,22 @@ THREE.ShaderChunk = {
 
 		"#endif",
 
+		"#if MAX_SPOT_LIGHTS > 0",
+
+			"uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];",
+			"uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];",
+			"uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];",
+			"uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];",
+			"uniform float spotLightAngle[ MAX_SPOT_LIGHTS ];",
+			"uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];",
+
+		"#endif",
+
 		"#ifdef WRAP_AROUND",
 
 			"uniform vec3 wrapRGB;",
 
-		"#endif",
+		"#endif"
 
 	].join("\n"),
 
@@ -405,13 +416,74 @@ THREE.ShaderChunk = {
 
 		"#endif",
 
+		"#if MAX_SPOT_LIGHTS > 0",
+
+			"for( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {",
+
+				"vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );",
+				"vec3 lVector = lPosition.xyz - mvPosition.xyz;",
+
+				"lVector = normalize( lVector );",
+
+				"float spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - mPosition.xyz ) );",
+
+				"if ( spotEffect > spotLightAngle[ i ] ) {",
+
+					"spotEffect = pow( spotEffect, spotLightExponent[ i ] );",
+
+					"float lDistance = 1.0;",
+					"if ( spotLightDistance[ i ] > 0.0 )",
+						"lDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );",
+
+					"float dotProduct = dot( transformedNormal, lVector );",
+					"vec3 spotLightWeighting = vec3( max( dotProduct, 0.0 ) );",
+
+					"#ifdef DOUBLE_SIDED",
+
+						"vec3 spotLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );",
+
+						"#ifdef WRAP_AROUND",
+
+							"vec3 spotLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );",
+
+						"#endif",
+
+					"#endif",
+
+					"#ifdef WRAP_AROUND",
+
+						"vec3 spotLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );",
+						"spotLightWeighting = mix( spotLightWeighting, spotLightWeightingHalf, wrapRGB );",
+
+						"#ifdef DOUBLE_SIDED",
+
+							"spotLightWeightingBack = mix( spotLightWeightingBack, spotLightWeightingHalfBack, wrapRGB );",
+
+						"#endif",
+
+					"#endif",
+
+					"vLightFront += spotLightColor[ i ] * spotLightWeighting * lDistance * spotEffect;",
+
+					"#ifdef DOUBLE_SIDED",
+
+						"vLightBack += spotLightColor[ i ] * spotLightWeightingBack * lDistance * spotEffect;",
+
+					"#endif",
+
+				"}",
+
+			"}",
+
+		"#endif",
+
 		"vLightFront = vLightFront * diffuse + ambient * ambientLightColor + emissive;",
 
 		"#ifdef DOUBLE_SIDED",
 
 			"vLightBack = vLightBack * diffuse + ambient * ambientLightColor + emissive;",
 
-		"#endif",
+		"#endif"
 
 	].join("\n"),
 
@@ -419,15 +491,32 @@ THREE.ShaderChunk = {
 
 	lights_phong_pars_vertex: [
 
-		"#if MAX_POINT_LIGHTS > 0",
 		"#ifndef PHONG_PER_PIXEL",
 
+		"#if MAX_POINT_LIGHTS > 0",
+
 			"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];",
 			"uniform float pointLightDistance[ MAX_POINT_LIGHTS ];",
 
 			"varying vec4 vPointLight[ MAX_POINT_LIGHTS ];",
 
 		"#endif",
+
+		"#if MAX_SPOT_LIGHTS > 0",
+
+			"uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];",
+			"uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];",
+
+			"varying vec4 vSpotLight[ MAX_SPOT_LIGHTS ];",
+
+		"#endif",
+
+		"#endif",
+
+		"#if MAX_SPOT_LIGHTS > 0",
+
+			"varying vec3 vWorldPosition;",
+
 		"#endif"
 
 	].join("\n"),
@@ -435,9 +524,10 @@ THREE.ShaderChunk = {
 
 	lights_phong_vertex: [
 
-		"#if MAX_POINT_LIGHTS > 0",
 		"#ifndef PHONG_PER_PIXEL",
 
+		"#if MAX_POINT_LIGHTS > 0",
+
 			"for( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {",
 
 				"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );",
@@ -452,6 +542,30 @@ THREE.ShaderChunk = {
 			"}",
 
 		"#endif",
+
+		"#if MAX_SPOT_LIGHTS > 0",
+
+			"for( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {",
+
+				"vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );",
+				"vec3 lVector = lPosition.xyz - mvPosition.xyz;",
+
+				"float lDistance = 1.0;",
+				"if ( spotLightDistance[ i ] > 0.0 )",
+					"lDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );",
+
+				"vSpotLight[ i ] = vec4( lVector, lDistance );",
+
+			"}",
+
+		"#endif",
+
+		"#endif",
+
+		"#if MAX_SPOT_LIGHTS > 0",
+
+			"vWorldPosition = mPosition.xyz;",
+
 		"#endif"
 
 	].join("\n"),
@@ -484,6 +598,28 @@ THREE.ShaderChunk = {
 
 		"#endif",
 
+		"#if MAX_SPOT_LIGHTS > 0",
+
+			"uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];",
+			"uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];",
+			"uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];",
+			"uniform float spotLightAngle[ MAX_SPOT_LIGHTS ];",
+			"uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];",
+
+			"#ifdef PHONG_PER_PIXEL",
+
+				"uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];",
+
+			"#else",
+
+				"varying vec4 vSpotLight[ MAX_SPOT_LIGHTS ];",
+
+			"#endif",
+
+			"varying vec3 vWorldPosition;",
+
+		"#endif",
+
 		"#ifdef WRAP_AROUND",
 
 			"uniform vec3 wrapRGB;",
@@ -575,6 +711,83 @@ THREE.ShaderChunk = {
 
 		"#endif",
 
+		"#if MAX_SPOT_LIGHTS > 0",
+
+			"vec3 spotDiffuse  = vec3( 0.0 );",
+			"vec3 spotSpecular = vec3( 0.0 );",
+
+			"for ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {",
+
+				"#ifdef PHONG_PER_PIXEL",
+
+					"vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );",
+					"vec3 lVector = lPosition.xyz + vViewPosition.xyz;",
+
+					"float lDistance = 1.0;",
+					"if ( spotLightDistance[ i ] > 0.0 )",
+						"lDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );",
+
+					"lVector = normalize( lVector );",
+
+				"#else",
+
+					"vec3 lVector = normalize( vSpotLight[ i ].xyz );",
+					"float lDistance = vSpotLight[ i ].w;",
+
+				"#endif",
+
+				"float spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );",
+
+				"if ( spotEffect > spotLightAngle[ i ] ) {",
+
+					"spotEffect = pow( spotEffect, spotLightExponent[ i ] );",
+
+					// diffuse
+
+					"float dotProduct = dot( normal, lVector );",
+
+					"#ifdef WRAP_AROUND",
+
+						"float spotDiffuseWeightFull = max( dotProduct, 0.0 );",
+						"float spotDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );",
+
+						"vec3 spotDiffuseWeight = mix( vec3 ( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );",
+
+					"#else",
+
+						"float spotDiffuseWeight = max( dotProduct, 0.0 );",
+
+					"#endif",
+
+					"spotDiffuse += diffuse * spotLightColor[ i ] * spotDiffuseWeight * lDistance * spotEffect;",
+
+					// specular
+
+					"vec3 spotHalfVector = normalize( lVector + viewPosition );",
+					"float spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );",
+					"float spotSpecularWeight = max( pow( spotDotNormalHalf, shininess ), 0.0 );",
+
+					"#ifdef PHYSICALLY_BASED_SHADING",
+
+						// 2.0 => 2.0001 is hack to work around ANGLE bug
+
+						"float specularNormalization = ( shininess + 2.0001 ) / 8.0;",
+
+						"vec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, spotHalfVector ), 5.0 );",
+						"spotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * lDistance * specularNormalization * spotEffect;",
+
+					"#else",
+
+						"spotSpecular += specular * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * lDistance * spotEffect;",
+
+					"#endif",
+
+				"}",
+
+			"}",
+
+		"#endif",
+
 		"#if MAX_DIR_LIGHTS > 0",
 
 			"vec3 dirDiffuse  = vec3( 0.0 );",
@@ -667,6 +880,13 @@ THREE.ShaderChunk = {
 
 		"#endif",
 
+		"#if MAX_SPOT_LIGHTS > 0",
+
+			"totalDiffuse += spotDiffuse;",
+			"totalSpecular += spotSpecular;",
+
+		"#endif",
+
 		"#ifdef METAL",
 
 			"gl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient + totalSpecular );",
@@ -1197,11 +1417,20 @@ THREE.UniformsLib = {
 	lights: {
 
 		"ambientLightColor" : { type: "fv", value: [] },
+
 		"directionalLightDirection" : { type: "fv", value: [] },
 		"directionalLightColor" : { type: "fv", value: [] },
+
 		"pointLightColor" : { type: "fv", value: [] },
 		"pointLightPosition" : { type: "fv", value: [] },
-		"pointLightDistance" : { type: "fv1", value: [] }
+		"pointLightDistance" : { type: "fv1", value: [] },
+
+		"spotLightColor" : { type: "fv", value: [] },
+		"spotLightPosition" : { type: "fv", value: [] },
+		"spotLightDirection" : { type: "fv", value: [] },
+		"spotLightDistance" : { type: "fv1", value: [] },
+		"spotLightAngle" : { type: "fv1", value: [] },
+		"spotLightExponent" : { type: "fv1", value: [] }
 
 	},
 
@@ -1429,6 +1658,12 @@ THREE.ShaderLib = {
 
 				THREE.ShaderChunk[ "morphnormal_vertex" ],
 
+				"#ifndef USE_ENVMAP",
+
+					"vec4 mPosition = objectMatrix * vec4( position, 1.0 );",
+
+				"#endif",
+
 				THREE.ShaderChunk[ "lights_lambert_vertex" ],
 				THREE.ShaderChunk[ "skinning_vertex" ],
 				THREE.ShaderChunk[ "morphtarget_vertex" ],

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