three.min.js 382.6 KB
Newer Older
M
Mr.doob 已提交
1
// three.js - http://github.com/mrdoob/three.js
A
alteredq 已提交
2 3 4 5
'use strict';var THREE=THREE||{REVISION:"53dev"};self.console=self.console||{info:function(){},log:function(){},debug:function(){},warn:function(){},error:function(){}};self.Int32Array=self.Int32Array||Array;self.Float32Array=self.Float32Array||Array;String.prototype.startsWith=String.prototype.startsWith||function(a){return this.slice(0,a.length)===a};String.prototype.endsWith=String.prototype.endsWith||function(a){var a=String(a),b=this.lastIndexOf(a);return(-1<b&&b)===this.length-a.length};
String.prototype.trim=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")};
(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"];void 0===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});window.cancelAnimationFrame=window.cancelAnimationFrame||
function(a){window.clearTimeout(a)}})();THREE.FrontSide=0;THREE.BackSide=1;THREE.DoubleSide=2;THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NoBlending=0;THREE.NormalBlending=1;THREE.AdditiveBlending=2;THREE.SubtractiveBlending=3;THREE.MultiplyBlending=4;THREE.CustomBlending=5;THREE.AddEquation=100;THREE.SubtractEquation=101;THREE.ReverseSubtractEquation=102;THREE.ZeroFactor=200;THREE.OneFactor=201;THREE.SrcColorFactor=202;
6
THREE.OneMinusSrcColorFactor=203;THREE.SrcAlphaFactor=204;THREE.OneMinusSrcAlphaFactor=205;THREE.DstAlphaFactor=206;THREE.OneMinusDstAlphaFactor=207;THREE.DstColorFactor=208;THREE.OneMinusDstColorFactor=209;THREE.SrcAlphaSaturateFactor=210;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.AddOperation=2;THREE.UVMapping=function(){};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};
A
alteredq 已提交
7 8 9 10 11 12
THREE.RepeatWrapping=1E3;THREE.ClampToEdgeWrapping=1001;THREE.MirroredRepeatWrapping=1002;THREE.NearestFilter=1003;THREE.NearestMipMapNearestFilter=1004;THREE.NearestMipMapLinearFilter=1005;THREE.LinearFilter=1006;THREE.LinearMipMapNearestFilter=1007;THREE.LinearMipMapLinearFilter=1008;THREE.UnsignedByteType=1009;THREE.ByteType=1010;THREE.ShortType=1011;THREE.UnsignedShortType=1012;THREE.IntType=1013;THREE.UnsignedIntType=1014;THREE.FloatType=1015;THREE.UnsignedShort4444Type=1016;
THREE.UnsignedShort5551Type=1017;THREE.UnsignedShort565Type=1018;THREE.AlphaFormat=1019;THREE.RGBFormat=1020;THREE.RGBAFormat=1021;THREE.LuminanceFormat=1022;THREE.LuminanceAlphaFormat=1023;THREE.RGB_S3TC_DXT1_Format=2001;THREE.RGBA_S3TC_DXT1_Format=2002;THREE.RGBA_S3TC_DXT3_Format=2003;THREE.RGBA_S3TC_DXT5_Format=2004;THREE.Clock=function(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1};
THREE.Clock.prototype.start=function(){this.oldTime=this.startTime=Date.now();this.running=!0};THREE.Clock.prototype.stop=function(){this.getElapsedTime();this.running=!1};THREE.Clock.prototype.getElapsedTime=function(){return this.elapsedTime+=this.getDelta()};THREE.Clock.prototype.getDelta=function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var b=Date.now(),a=0.001*(b-this.oldTime);this.oldTime=b;this.elapsedTime+=a}return 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;0===c?this.r=this.g=this.b=0:(d=Math.floor(6*a),e=6*a-d,a=c*(1-b),f=c*(1-b*e),b=c*(1-b*(1-e)),0===d?(this.r=c,this.g=b,this.b=a):1===d?(this.r=f,this.g=c,this.b=a):2===d?(this.r=a,this.g=c,this.b=b):3===d?(this.r=a,this.g=f,this.b=c):4===d?(this.r=b,this.g=a,this.b=c):5===d&&(this.r=c,this.g=a,this.b=f));return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&
13 14
255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},lerpSelf:function(a,b){this.r+=(a.r-this.r)*b;this.g+=(a.g-this.g)*b;this.b+=(a.b-this.b)*b;return this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getContextStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},getHSV:function(a){var b=this.r,c=this.g,d=this.b,e=Math.max(Math.max(b,c),d),f=Math.min(Math.min(b,
c),d);if(f===e)f=b=0;else{var g=e-f,f=g/e,b=(b===e?(c-d)/g:c===e?2+(d-b)/g:4+(b-c)/g)/6;0>b&&(b+=1);1<b&&(b-=1)}void 0===a&&(a={h:0,s:0,v:0});a.h=b;a.s=f;a.v=e;return a},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
A
alteredq 已提交
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a):this.set(0,
0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,a=this.y-a.y;return b*b+a*a},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,
b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;return this},equals:function(a){return a.x===this.x&&a.y===this.y},isZero:function(a){return this.lengthSq()<(void 0!==a?a:1E-4)},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0};
THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},
sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a):
this.z=this.y=this.x=0;return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=
(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},angleTo:function(a){return Math.acos(this.dot(a)/this.length()/a.length())},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){return(new THREE.Vector3).sub(this,
a).lengthSq()},getPositionFromMatrix:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setEulerFromRotationMatrix:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.elements,e=d[0],f=d[4],g=d[8],h=d[1],i=d[5],j=d[9],m=d[2],n=d[6],d=d[10];void 0===b||"XYZ"===b?(this.y=Math.asin(c(g)),0.99999>Math.abs(g)?(this.x=Math.atan2(-j,d),this.z=Math.atan2(-f,e)):(this.x=Math.atan2(n,i),this.z=0)):"YXZ"===b?(this.x=Math.asin(-c(j)),0.99999>Math.abs(j)?
(this.y=Math.atan2(g,d),this.z=Math.atan2(h,i)):(this.y=Math.atan2(-m,e),this.z=0)):"ZXY"===b?(this.x=Math.asin(c(n)),0.99999>Math.abs(n)?(this.y=Math.atan2(-m,d),this.z=Math.atan2(-f,i)):(this.y=0,this.z=Math.atan2(h,e))):"ZYX"===b?(this.y=Math.asin(-c(m)),0.99999>Math.abs(m)?(this.x=Math.atan2(n,d),this.z=Math.atan2(h,e)):(this.x=0,this.z=Math.atan2(-f,i))):"YZX"===b?(this.z=Math.asin(c(h)),0.99999>Math.abs(h)?(this.x=Math.atan2(-j,i),this.y=Math.atan2(-m,e)):(this.x=0,this.y=Math.atan2(g,d))):
"XZY"===b&&(this.z=Math.asin(-c(f)),0.99999>Math.abs(f)?(this.x=Math.atan2(n,i),this.y=Math.atan2(g,e)):(this.x=Math.atan2(-j,d),this.y=0));return this},setEulerFromQuaternion:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.x*a.x,e=a.y*a.y,f=a.z*a.z,g=a.w*a.w;void 0===b||"XYZ"===b?(this.x=Math.atan2(2*(a.x*a.w-a.y*a.z),g-d-e+f),this.y=Math.asin(c(2*(a.x*a.z+a.y*a.w))),this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),g+d-e-f)):"YXZ"===b?(this.x=Math.asin(c(2*(a.x*a.w-a.y*a.z))),this.y=Math.atan2(2*
(a.x*a.z+a.y*a.w),g-d-e+f),this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),g-d+e-f)):"ZXY"===b?(this.x=Math.asin(c(2*(a.x*a.w+a.y*a.z))),this.y=Math.atan2(2*(a.y*a.w-a.z*a.x),g-d-e+f),this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),g-d+e-f)):"ZYX"===b?(this.x=Math.atan2(2*(a.x*a.w+a.z*a.y),g-d-e+f),this.y=Math.asin(c(2*(a.y*a.w-a.x*a.z))),this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),g+d-e-f)):"YZX"===b?(this.x=Math.atan2(2*(a.x*a.w-a.z*a.y),g-d+e-f),this.y=Math.atan2(2*(a.y*a.w-a.x*a.z),g+d-e-f),this.z=Math.asin(c(2*(a.x*a.y+
a.z*a.w)))):"XZY"===b&&(this.x=Math.atan2(2*(a.x*a.w+a.y*a.z),g-d+e-f),this.y=Math.atan2(2*(a.x*a.z+a.y*a.w),g+d-e-f),this.z=Math.asin(c(2*(a.z*a.w-a.x*a.y))));return this},getScaleFromMatrix:function(a){var b=this.set(a.elements[0],a.elements[1],a.elements[2]).length(),c=this.set(a.elements[4],a.elements[5],a.elements[6]).length(),a=this.set(a.elements[8],a.elements[9],a.elements[10]).length();this.x=b;this.y=c;this.z=a;return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},
isZero:function(a){return this.lengthSq()<(void 0!==a?a:1E-4)},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1};
THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=
a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return Math.abs(this.x)+
Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);1E-4>b?(this.x=1,this.z=this.y=0):
(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d,a=a.elements,e=a[0];d=a[4];var f=a[8],g=a[1],h=a[5],i=a[9];c=a[2];b=a[6];var j=a[10];if(0.01>Math.abs(d-g)&&0.01>Math.abs(f-c)&&0.01>Math.abs(i-b)){if(0.1>Math.abs(d+g)&&0.1>Math.abs(f+c)&&0.1>Math.abs(i+b)&&0.1>Math.abs(e+h+j-3))return this.set(1,0,0,0),this;a=Math.PI;e=(e+1)/2;h=(h+1)/2;j=(j+1)/2;d=(d+g)/4;f=(f+c)/4;i=(i+b)/4;e>h&&e>j?0.01>e?(b=0,d=c=0.707106781):(b=Math.sqrt(e),c=d/b,d=f/
b):h>j?0.01>h?(b=0.707106781,c=0,d=0.707106781):(c=Math.sqrt(h),b=d/c,d=i/c):0.01>j?(c=b=0.707106781,d=0):(d=Math.sqrt(j),b=f/d,c=i/d);this.set(b,c,d,a);return this}a=Math.sqrt((b-i)*(b-i)+(f-c)*(f-c)+(g-d)*(g-d));0.001>Math.abs(a)&&(a=1);this.x=(b-i)/a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=Math.acos((e+h+j-1)/2);return this}};THREE.Matrix3=function(){this.elements=new Float32Array(9)};
THREE.Matrix3.prototype={constructor:THREE.Matrix3,getInverse:function(a){var b=a.elements,a=b[10]*b[5]-b[6]*b[9],c=-b[10]*b[1]+b[2]*b[9],d=b[6]*b[1]-b[2]*b[5],e=-b[10]*b[4]+b[6]*b[8],f=b[10]*b[0]-b[2]*b[8],g=-b[6]*b[0]+b[2]*b[4],h=b[9]*b[4]-b[5]*b[8],i=-b[9]*b[0]+b[1]*b[8],j=b[5]*b[0]-b[1]*b[4],b=b[0]*a+b[1]*e+b[2]*h;0===b&&console.warn("Matrix3.getInverse(): determinant == 0");var b=1/b,m=this.elements;m[0]=b*a;m[1]=b*c;m[2]=b*d;m[3]=b*e;m[4]=b*f;m[5]=b*g;m[6]=b*h;m[7]=b*i;m[8]=b*j;return this},
transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,e,f,g,h,i,j,m,n,l,p,o,q){this.elements=new Float32Array(16);this.set(void 0!==a?a:1,b||0,c||0,d||0,e||0,void 0!==f?f:1,g||0,h||0,i||0,j||0,void 0!==m?m:1,n||0,l||0,p||0,o||0,void 0!==q?q:1)};
35 36
THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,i,j,m,n,l,p,o,q){var s=this.elements;s[0]=a;s[4]=b;s[8]=c;s[12]=d;s[1]=e;s[5]=f;s[9]=g;s[13]=h;s[2]=i;s[6]=j;s[10]=m;s[14]=n;s[3]=l;s[7]=p;s[11]=o;s[15]=q;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]);return this},lookAt:function(a,b,c){var d=this.elements,
e=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();0===g.length()&&(g.z=1);e.cross(c,g).normalize();0===e.length()&&(g.x+=1E-4,e.cross(c,g).normalize());f.cross(g,e);d[0]=e.x;d[4]=f.x;d[8]=g.x;d[1]=e.y;d[5]=f.y;d[9]=g.y;d[2]=e.z;d[6]=f.z;d[10]=g.z;return this},multiply:function(a,b){var c=a.elements,d=b.elements,e=this.elements,f=c[0],g=c[4],h=c[8],i=c[12],j=c[1],m=c[5],n=c[9],l=c[13],p=c[2],o=c[6],q=c[10],s=c[14],r=c[3],A=c[7],u=c[11],c=c[15],t=d[0],F=d[4],z=d[8],
37
w=d[12],v=d[1],C=d[5],D=d[9],I=d[13],L=d[2],B=d[6],K=d[10],H=d[14],G=d[3],M=d[7],N=d[11],d=d[15];e[0]=f*t+g*v+h*L+i*G;e[4]=f*F+g*C+h*B+i*M;e[8]=f*z+g*D+h*K+i*N;e[12]=f*w+g*I+h*H+i*d;e[1]=j*t+m*v+n*L+l*G;e[5]=j*F+m*C+n*B+l*M;e[9]=j*z+m*D+n*K+l*N;e[13]=j*w+m*I+n*H+l*d;e[2]=p*t+o*v+q*L+s*G;e[6]=p*F+o*C+q*B+s*M;e[10]=p*z+o*D+q*K+s*N;e[14]=p*w+o*I+q*H+s*d;e[3]=r*t+A*v+u*L+c*G;e[7]=r*F+A*C+u*B+c*M;e[11]=r*z+A*D+u*K+c*N;e[15]=r*w+A*I+u*H+c*d;return this},multiplySelf:function(a){return this.multiply(this,
A
alteredq 已提交
38 39 40 41 42 43
a)},multiplyToArray:function(a,b,c){var d=this.elements;this.multiply(a,b);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12];c[13]=d[13];c[14]=d[14];c[15]=d[15];return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[4]*=a;b[8]*=a;b[12]*=a;b[1]*=a;b[5]*=a;b[9]*=a;b[13]*=a;b[2]*=a;b[6]*=a;b[10]*=a;b[14]*=a;b[3]*=a;b[7]*=a;b[11]*=a;b[15]*=a;return this},multiplyVector3:function(a){var b=this.elements,
c=a.x,d=a.y,e=a.z,f=1/(b[3]*c+b[7]*d+b[11]*e+b[15]);a.x=(b[0]*c+b[4]*d+b[8]*e+b[12])*f;a.y=(b[1]*c+b[5]*d+b[9]*e+b[13])*f;a.z=(b[2]*c+b[6]*d+b[10]*e+b[14])*f;return a},multiplyVector4:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=a.w;a.x=b[0]*c+b[4]*d+b[8]*e+b[12]*f;a.y=b[1]*c+b[5]*d+b[9]*e+b[13]*f;a.z=b[2]*c+b[6]*d+b[10]*e+b[14]*f;a.w=b[3]*c+b[7]*d+b[11]*e+b[15]*f;return a},multiplyVector3Array:function(a){for(var b=THREE.Matrix4.__v1,c=0,d=a.length;c<d;c+=3)b.x=a[c],b.y=a[c+1],b.z=a[c+2],
this.multiplyVector3(b),a[c]=b.x,a[c+1]=b.y,a[c+2]=b.z;return a},rotateAxis:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z;a.x=c*b[0]+d*b[4]+e*b[8];a.y=c*b[1]+d*b[5]+e*b[9];a.z=c*b[2]+d*b[6]+e*b[10];a.normalize();return a},crossVector:function(a){var b=this.elements,c=new THREE.Vector4;c.x=b[0]*a.x+b[4]*a.y+b[8]*a.z+b[12]*a.w;c.y=b[1]*a.x+b[5]*a.y+b[9]*a.z+b[13]*a.w;c.z=b[2]*a.x+b[6]*a.y+b[10]*a.z+b[14]*a.w;c.w=a.w?b[3]*a.x+b[7]*a.y+b[11]*a.z+b[15]*a.w:1;return c},determinant:function(){var a=
this.elements,b=a[0],c=a[4],d=a[8],e=a[12],f=a[1],g=a[5],h=a[9],i=a[13],j=a[2],m=a[6],n=a[10],l=a[14],p=a[3],o=a[7],q=a[11],a=a[15];return e*h*m*p-d*i*m*p-e*g*n*p+c*i*n*p+d*g*l*p-c*h*l*p-e*h*j*o+d*i*j*o+e*f*n*o-b*i*n*o-d*f*l*o+b*h*l*o+e*g*j*q-c*i*j*q-e*f*m*q+b*i*m*q+c*f*l*q-b*g*l*q-d*g*j*a+c*h*j*a+d*f*m*a-b*h*m*a-c*f*n*a+b*g*n*a},transpose:function(){var a=this.elements,b;b=a[1];a[1]=a[4];a[4]=b;b=a[2];a[2]=a[8];a[8]=b;b=a[6];a[6]=a[9];a[9]=b;b=a[3];a[3]=a[12];a[12]=b;b=a[7];a[7]=a[13];a[13]=b;b=
a[11];a[11]=a[14];a[14]=b;return this},flattenToArray:function(a){var b=this.elements;a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3];a[4]=b[4];a[5]=b[5];a[6]=b[6];a[7]=b[7];a[8]=b[8];a[9]=b[9];a[10]=b[10];a[11]=b[11];a[12]=b[12];a[13]=b[13];a[14]=b[14];a[15]=b[15];return a},flattenToArrayOffset:function(a,b){var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];a[b+9]=c[9];a[b+10]=c[10];a[b+11]=c[11];a[b+12]=c[12];a[b+13]=c[13];a[b+
14]=c[14];a[b+15]=c[15];return a},getPosition:function(){var a=this.elements;return THREE.Matrix4.__v1.set(a[12],a[13],a[14])},setPosition:function(a){var b=this.elements;b[12]=a.x;b[13]=a.y;b[14]=a.z;return this},getColumnX:function(){var a=this.elements;return THREE.Matrix4.__v1.set(a[0],a[1],a[2])},getColumnY:function(){var a=this.elements;return THREE.Matrix4.__v1.set(a[4],a[5],a[6])},getColumnZ:function(){var a=this.elements;return THREE.Matrix4.__v1.set(a[8],a[9],a[10])},getInverse:function(a){var b=
44 45
this.elements,c=a.elements,d=c[0],e=c[4],f=c[8],g=c[12],h=c[1],i=c[5],j=c[9],m=c[13],n=c[2],l=c[6],p=c[10],o=c[14],q=c[3],s=c[7],r=c[11],c=c[15];b[0]=j*o*s-m*p*s+m*l*r-i*o*r-j*l*c+i*p*c;b[4]=g*p*s-f*o*s-g*l*r+e*o*r+f*l*c-e*p*c;b[8]=f*m*s-g*j*s+g*i*r-e*m*r-f*i*c+e*j*c;b[12]=g*j*l-f*m*l-g*i*p+e*m*p+f*i*o-e*j*o;b[1]=m*p*q-j*o*q-m*n*r+h*o*r+j*n*c-h*p*c;b[5]=f*o*q-g*p*q+g*n*r-d*o*r-f*n*c+d*p*c;b[9]=g*j*q-f*m*q-g*h*r+d*m*r+f*h*c-d*j*c;b[13]=f*m*n-g*j*n+g*h*p-d*m*p-f*h*o+d*j*o;b[2]=i*o*q-m*l*q+m*n*s-h*o*
s-i*n*c+h*l*c;b[6]=g*l*q-e*o*q-g*n*s+d*o*s+e*n*c-d*l*c;b[10]=e*m*q-g*i*q+g*h*s-d*m*s-e*h*c+d*i*c;b[14]=g*i*n-e*m*n-g*h*l+d*m*l+e*h*o-d*i*o;b[3]=j*l*q-i*p*q-j*n*s+h*p*s+i*n*r-h*l*r;b[7]=e*p*q-f*l*q+f*n*s-d*p*s-e*n*r+d*l*r;b[11]=f*i*q-e*j*q-f*h*s+d*j*s+e*h*r-d*i*r;b[15]=e*j*n-f*i*n+f*h*l-d*j*l-e*h*p+d*i*p;this.multiplyScalar(1/a.determinant());return this},setRotationFromEuler:function(a,b){var c=this.elements,d=a.x,e=a.y,f=a.z,g=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e),i=Math.cos(f),f=
A
alteredq 已提交
46 47 48 49 50 51 52
Math.sin(f);if(void 0===b||"XYZ"===b){var j=g*i,m=g*f,n=d*i,l=d*f;c[0]=h*i;c[4]=-h*f;c[8]=e;c[1]=m+n*e;c[5]=j-l*e;c[9]=-d*h;c[2]=l-j*e;c[6]=n+m*e;c[10]=g*h}else"YXZ"===b?(j=h*i,m=h*f,n=e*i,l=e*f,c[0]=j+l*d,c[4]=n*d-m,c[8]=g*e,c[1]=g*f,c[5]=g*i,c[9]=-d,c[2]=m*d-n,c[6]=l+j*d,c[10]=g*h):"ZXY"===b?(j=h*i,m=h*f,n=e*i,l=e*f,c[0]=j-l*d,c[4]=-g*f,c[8]=n+m*d,c[1]=m+n*d,c[5]=g*i,c[9]=l-j*d,c[2]=-g*e,c[6]=d,c[10]=g*h):"ZYX"===b?(j=g*i,m=g*f,n=d*i,l=d*f,c[0]=h*i,c[4]=n*e-m,c[8]=j*e+l,c[1]=h*f,c[5]=l*e+j,c[9]=
m*e-n,c[2]=-e,c[6]=d*h,c[10]=g*h):"YZX"===b?(j=g*h,m=g*e,n=d*h,l=d*e,c[0]=h*i,c[4]=l-j*f,c[8]=n*f+m,c[1]=f,c[5]=g*i,c[9]=-d*i,c[2]=-e*i,c[6]=m*f+n,c[10]=j-l*f):"XZY"===b&&(j=g*h,m=g*e,n=d*h,l=d*e,c[0]=h*i,c[4]=-f,c[8]=e*i,c[1]=j*f+l,c[5]=g*i,c[9]=m*f-n,c[2]=n*f-m,c[6]=d*i,c[10]=l*f+j);return this},setRotationFromQuaternion:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=a.w,g=c+c,h=d+d,i=e+e,a=c*g,j=c*h,c=c*i,m=d*h,d=d*i,e=e*i,g=f*g,h=f*h,f=f*i;b[0]=1-(m+e);b[4]=j-f;b[8]=c+h;b[1]=j+f;b[5]=1-(a+
e);b[9]=d-g;b[2]=c-h;b[6]=d+g;b[10]=1-(a+m);return this},compose:function(a,b,c){var d=this.elements,e=THREE.Matrix4.__m1,f=THREE.Matrix4.__m2;e.identity();e.setRotationFromQuaternion(b);f.makeScale(c.x,c.y,c.z);this.multiply(e,f);d[12]=a.x;d[13]=a.y;d[14]=a.z;return this},decompose:function(a,b,c){var d=this.elements,e=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;e.set(d[0],d[1],d[2]);f.set(d[4],d[5],d[6]);g.set(d[8],d[9],d[10]);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=
b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=e.length();c.y=f.length();c.z=g.length();a.x=d[12];a.y=d[13];a.z=d[14];d=THREE.Matrix4.__m1;d.copy(this);d.elements[0]/=c.x;d.elements[1]/=c.x;d.elements[2]/=c.x;d.elements[4]/=c.y;d.elements[5]/=c.y;d.elements[6]/=c.y;d.elements[8]/=c.z;d.elements[9]/=c.z;d.elements[10]/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){var b=this.elements,a=a.elements;b[12]=a[12];b[13]=
a[13];b[14]=a[14];return this},extractRotation:function(a){var b=this.elements,a=a.elements,c=THREE.Matrix4.__v1,d=1/c.set(a[0],a[1],a[2]).length(),e=1/c.set(a[4],a[5],a[6]).length(),c=1/c.set(a[8],a[9],a[10]).length();b[0]=a[0]*d;b[1]=a[1]*d;b[2]=a[2]*d;b[4]=a[4]*e;b[5]=a[5]*e;b[6]=a[6]*e;b[8]=a[8]*c;b[9]=a[9]*c;b[10]=a[10]*c;return this},translate:function(a){var b=this.elements,c=a.x,d=a.y,a=a.z;b[12]=b[0]*c+b[4]*d+b[8]*a+b[12];b[13]=b[1]*c+b[5]*d+b[9]*a+b[13];b[14]=b[2]*c+b[6]*d+b[10]*a+b[14];
b[15]=b[3]*c+b[7]*d+b[11]*a+b[15];return this},rotateX:function(a){var b=this.elements,c=b[4],d=b[5],e=b[6],f=b[7],g=b[8],h=b[9],i=b[10],j=b[11],m=Math.cos(a),a=Math.sin(a);b[4]=m*c+a*g;b[5]=m*d+a*h;b[6]=m*e+a*i;b[7]=m*f+a*j;b[8]=m*g-a*c;b[9]=m*h-a*d;b[10]=m*i-a*e;b[11]=m*j-a*f;return this},rotateY:function(a){var b=this.elements,c=b[0],d=b[1],e=b[2],f=b[3],g=b[8],h=b[9],i=b[10],j=b[11],m=Math.cos(a),a=Math.sin(a);b[0]=m*c-a*g;b[1]=m*d-a*h;b[2]=m*e-a*i;b[3]=m*f-a*j;b[8]=m*g+a*c;b[9]=m*h+a*d;b[10]=
m*i+a*e;b[11]=m*j+a*f;return this},rotateZ:function(a){var b=this.elements,c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],m=Math.cos(a),a=Math.sin(a);b[0]=m*c+a*g;b[1]=m*d+a*h;b[2]=m*e+a*i;b[3]=m*f+a*j;b[4]=m*g-a*c;b[5]=m*h-a*d;b[6]=m*i-a*e;b[7]=m*j-a*f;return this},rotateByAxis:function(a,b){var c=this.elements;if(1===a.x&&0===a.y&&0===a.z)return this.rotateX(b);if(0===a.x&&1===a.y&&0===a.z)return this.rotateY(b);if(0===a.x&&0===a.y&&1===a.z)return this.rotateZ(b);var d=a.x,e=a.y,f=a.z,
53
g=Math.sqrt(d*d+e*e+f*f),d=d/g,e=e/g,f=f/g,g=d*d,h=e*e,i=f*f,j=Math.cos(b),m=Math.sin(b),n=1-j,l=d*e*n,p=d*f*n,n=e*f*n,d=d*m,o=e*m,m=f*m,f=g+(1-g)*j,g=l+m,e=p-o,l=l-m,h=h+(1-h)*j,m=n+d,p=p+o,n=n-d,i=i+(1-i)*j,j=c[0],d=c[1],o=c[2],q=c[3],s=c[4],r=c[5],A=c[6],u=c[7],t=c[8],F=c[9],z=c[10],w=c[11];c[0]=f*j+g*s+e*t;c[1]=f*d+g*r+e*F;c[2]=f*o+g*A+e*z;c[3]=f*q+g*u+e*w;c[4]=l*j+h*s+m*t;c[5]=l*d+h*r+m*F;c[6]=l*o+h*A+m*z;c[7]=l*q+h*u+m*w;c[8]=p*j+n*s+i*t;c[9]=p*d+n*r+i*F;c[10]=p*o+n*A+i*z;c[11]=p*q+n*u+i*w;
A
alteredq 已提交
54 55 56 57 58
return this},scale:function(a){var b=this.elements,c=a.x,d=a.y,a=a.z;b[0]*=c;b[4]*=d;b[8]*=a;b[1]*=c;b[5]*=d;b[9]*=a;b[2]*=c;b[6]*=d;b[10]*=a;b[3]*=c;b[7]*=d;b[11]*=a;return this},getMaxScaleOnAxis:function(){var a=this.elements;return Math.sqrt(Math.max(a[0]*a[0]+a[1]*a[1]+a[2]*a[2],Math.max(a[4]*a[4]+a[5]*a[5]+a[6]*a[6],a[8]*a[8]+a[9]*a[9]+a[10]*a[10])))},makeTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},makeRotationX:function(a){var b=Math.cos(a),a=Math.sin(a);
this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},makeRotationY:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},makeRotationZ:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},makeRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,h=a.z,i=e*f,j=e*g;this.set(i*f+c,i*g-d*h,i*h+d*g,0,i*g+d*h,j*g+c,j*h-d*f,0,i*h-d*g,j*h+d*f,e*h*h+c,0,0,0,0,1);return this},makeScale:function(a,
b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},makeFrustum:function(a,b,c,d,e,f){var g=this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(d-c);g[9]=(d+c)/(d-c);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makePerspective:function(a,b,c,d){var a=c*Math.tan(a*Math.PI/360),e=-a;return this.makeFrustum(e*b,a*b,e,a,c,d)},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,h=b-a,i=c-d,j=f-e;g[0]=2/
h;g[4]=0;g[8]=0;g[12]=-((b+a)/h);g[1]=0;g[5]=2/i;g[9]=0;g[13]=-((c+d)/i);g[2]=0;g[6]=0;g[10]=-2/j;g[14]=-((f+e)/j);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},clone:function(){var a=this.elements;return new THREE.Matrix4(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15])}};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
THREE.EventTarget=function(){var a={};this.addEventListener=function(b,c){void 0===a[b]&&(a[b]=[]);-1===a[b].indexOf(c)&&a[b].push(c)};this.dispatchEvent=function(b){for(var c in a[b.type])a[b.type][c](b)};this.removeEventListener=function(b,c){var d=a[b].indexOf(c);-1!==d&&a[b].splice(d,1)}};THREE.Frustum=function(){this.planes=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4]};
59
THREE.Frustum.prototype.setFromMatrix=function(a){var b=this.planes,c=a.elements,a=c[0],d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],i=c[6],j=c[7],m=c[8],n=c[9],l=c[10],p=c[11],o=c[12],q=c[13],s=c[14],c=c[15];b[0].set(f-a,j-g,p-m,c-o);b[1].set(f+a,j+g,p+m,c+o);b[2].set(f+d,j+h,p+n,c+q);b[3].set(f-d,j-h,p-n,c-q);b[4].set(f-e,j-i,p-l,c-s);b[5].set(f+e,j+i,p+l,c+s);for(d=0;6>d;d++)a=b[d],a.divideScalar(Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z))};
A
alteredq 已提交
60 61
THREE.Frustum.prototype.contains=function(a){for(var b=0,c=this.planes,b=a.matrixWorld,d=b.elements,a=-a.geometry.boundingSphere.radius*b.getMaxScaleOnAxis(),e=0;6>e;e++)if(b=c[e].x*d[12]+c[e].y*d[13]+c[e].z*d[14]+c[e].w,b<=a)return!1;return!0};THREE.Frustum.__v1=new THREE.Vector3;
(function(a){a.Ray=function(b,c,d,e){this.origin=b||new a.Vector3;this.direction=c||new a.Vector3;this.near=d||0;this.far=e||Infinity};var b=new a.Vector3,c=new a.Vector3,d=new a.Vector3,e=new a.Vector3,f=new a.Vector3,g=new a.Vector3,h=new a.Matrix4,i=function(a,b){return a.distance-b.distance},j=new a.Vector3,m=new a.Vector3,n=new a.Vector3,l=function(a,b,c){j.sub(c,a);var d=j.dot(b),a=m.add(a,n.copy(b).multiplyScalar(d));return c.distanceTo(a)},p=function(a,b,c,d){j.sub(d,b);m.sub(c,b);n.sub(a,
62 63 64
b);var a=j.dot(j),b=j.dot(m),c=j.dot(n),e=m.dot(m),d=m.dot(n),f=1/(a*e-b*b),e=(e*c-b*d)*f,a=(a*d-b*c)*f;return 0<=e&&0<=a&&1>e+a},o=function(i,j,m){var n,o;if(i instanceof a.Particle){n=l(j.origin,j.direction,i.matrixWorld.getPosition());if(n>i.scale.x)return m;o={distance:n,point:i.position,face:null,object:i};m.push(o)}else if(i instanceof a.Mesh){var q=i.geometry.boundingSphere.radius*i.matrixWorld.getMaxScaleOnAxis();n=l(j.origin,j.direction,i.matrixWorld.getPosition());if(n>q)return m;var z,
w,v=i.geometry,C=v.vertices,D,I,L;D=i.geometry.materials;I=i.material instanceof a.MeshFaceMaterial;var B,K=j.precision;i.matrixRotationWorld.extractRotation(i.matrixWorld);b.copy(j.origin);h.getInverse(i.matrixWorld);c.copy(b);h.multiplyVector3(c);d.copy(j.direction);h.rotateAxis(d).normalize();q=0;for(z=v.faces.length;q<z;q++)if(o=v.faces[q],n=!0===I?D[o.materialIndex]:i.material,void 0!==n&&(L=n.side,e.sub(o.centroid,c),f=o.normal,n=d.dot(f),!(Math.abs(n)<K)&&(w=f.dot(e)/n,!(0>w)&&(L===a.DoubleSide||
(L===a.FrontSide?0>n:0<n)))))if(g.add(c,d.multiplyScalar(w)),o instanceof a.Face3)n=C[o.a],w=C[o.b],L=C[o.c],p(g,n,w,L)&&(w=i.matrixWorld.multiplyVector3(g.clone()),n=b.distanceTo(w),n<j.near||n>j.far||(o={distance:n,point:w,face:o,faceIndex:q,object:i},m.push(o)));else if(o instanceof a.Face4&&(n=C[o.a],w=C[o.b],L=C[o.c],B=C[o.d],p(g,n,w,B)||p(g,w,L,B)))w=i.matrixWorld.multiplyVector3(g.clone()),n=b.distanceTo(w),n<j.near||n>j.far||(o={distance:n,point:w,face:o,faceIndex:q,object:i},m.push(o))}},
A
alteredq 已提交
65 66 67 68 69 70 71 72
q=function(a,b,c){for(var a=a.getDescendants(),d=0,e=a.length;d<e;d++)o(a[d],b,c)};a.Ray.prototype.precision=1E-4;a.Ray.prototype.set=function(a,b){this.origin=a;this.direction=b};a.Ray.prototype.intersectObject=function(a,b){var c=[];!0===b&&q(a,this,c);o(a,this,c);c.sort(i);return c};a.Ray.prototype.intersectObjects=function(a,b){for(var c=[],d=0,e=a.length;d<e;d++)o(a[d],this,c),!0===b&&q(a[d],this,c);c.sort(i);return c}})(THREE);
THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b=0,c=0,d=0,e=0,f=0,g=0,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,m,n){h=!1;b=f;c=g;d=m;e=n;a()};this.addPoint=function(f,g){!0===h?(h=!1,b=f,c=g,d=f,e=g):(b=b<f?b:f,c=c<g?c:g,d=d>f?d:f,e=e>
g?e:g);a()};this.add3Points=function(f,g,m,n,l,p){!0===h?(h=!1,b=f<m?f<l?f:l:m<l?m:l,c=g<n?g<p?g:p:n<p?n:p,d=f>m?f>l?f:l:m>l?m:l,e=g>n?g>p?g:p:n>p?n:p):(b=f<m?f<l?f<b?f:b:l<b?l:b:m<l?m<b?m:b:l<b?l:b,c=g<n?g<p?g<c?g:c:p<c?p:c:n<p?n<c?n:c:p<c?p:c,d=f>m?f>l?f>d?f:d:l>d?l:d:m>l?m>d?m:d:l>d?l:d,e=g>n?g>p?g>e?g:e:p>e?p:e:n>p?n>e?n:e:p>e?p:e);a()};this.addRectangle=function(f){!0===h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),
d=d>f.getRight()?d:f.getRight(),e=e>f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d<f.getRight()?d:f.getRight();e=e<f.getBottom()?e:f.getBottom();a()};this.intersects=function(a){return d<a.getLeft()||b>a.getRight()||e<a.getTop()||c>a.getBottom()?!1:!0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};
THREE.Math={clamp:function(a,b,c){return a<b?b:a>c?c:a},clampBottom:function(a,b){return a<b?b:a},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(0.5-Math.random())},sign:function(a){return 0>a?-1:0<a?1:0}};
THREE.Object3D=function(){THREE.Object3DLibrary.push(this);this.id=THREE.Object3DIdCount++;this.name="";this.properties={};this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder=THREE.Object3D.defaultEulerOrder;this.scale=new THREE.Vector3(1,1,1);this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=
this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this._vector=new THREE.Vector3};
THREE.Object3D.prototype={constructor:THREE.Object3D,applyMatrix:function(a){this.matrix.multiply(a,this.matrix);this.scale.getScaleFromMatrix(this.matrix);a=(new THREE.Matrix4).extractRotation(this.matrix);this.rotation.setEulerFromRotationMatrix(a,this.eulerOrder);this.position.getPositionFromMatrix(this.matrix)},translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,
M
Mr.doob 已提交
73 74 75 76 77 78 79
this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},localToWorld:function(a){return this.matrixWorld.multiplyVector3(a)},worldToLocal:function(a){return THREE.Object3D.__m1.getInverse(this.matrixWorld).multiplyVector3(a)},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&(!1===this.useQuaternion?this.rotation.setEulerFromRotationMatrix(this.matrix,this.eulerOrder):this.quaternion.copy(this.matrix.decompose()[1]))},add:function(a){if(a===
this)console.warn("THREE.Object3D.add: An object can't be added as a child of itself.");else if(a instanceof THREE.Object3D){void 0!==a.parent&&a.parent.remove(a);a.parent=this;this.children.push(a);for(var b=this;void 0!==b.parent;)b=b.parent;void 0!==b&&b instanceof THREE.Scene&&b.__addObject(a)}},remove:function(a){var b=this.children.indexOf(a);if(-1!==b){a.parent=void 0;this.children.splice(b,1);for(b=this;void 0!==b.parent;)b=b.parent;void 0!==b&&b instanceof THREE.Scene&&b.__removeObject(a)}},
traverse:function(a){a(this);for(var b=0,c=this.children.length;b<c;b++)this.children[b].traverse(a)},getChildByName:function(a,b){for(var c=0,d=this.children.length;c<d;c++){var e=this.children[c];if(e.name===a||!0===b&&(e=e.getChildByName(a,b),void 0!==e))return e}},getDescendants:function(a){void 0===a&&(a=[]);Array.prototype.push.apply(a,this.children);for(var b=0,c=this.children.length;b<c;b++)this.children[b].getDescendants(a);return a},updateMatrix:function(){this.matrix.setPosition(this.position);
!1===this.useQuaternion?this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder):this.matrix.setRotationFromQuaternion(this.quaternion);if(1!==this.scale.x||1!==this.scale.y||1!==this.scale.z)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(a){!0===this.matrixAutoUpdate&&this.updateMatrix();if(!0===this.matrixWorldNeedsUpdate||!0===a)void 0===this.parent?this.matrixWorld.copy(this.matrix):
this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)},clone:function(a){void 0===a&&(a=new THREE.Object3D);a.name=this.name;a.up.copy(this.up);a.position.copy(this.position);a.rotation instanceof THREE.Vector3&&a.rotation.copy(this.rotation);a.eulerOrder=this.eulerOrder;a.scale.copy(this.scale);a.renderDepth=this.renderDepth;a.rotationAutoUpdate=this.rotationAutoUpdate;a.matrix.copy(this.matrix);
a.matrixWorld.copy(this.matrixWorld);a.matrixRotationWorld.copy(this.matrixRotationWorld);a.matrixAutoUpdate=this.matrixAutoUpdate;a.matrixWorldNeedsUpdate=this.matrixWorldNeedsUpdate;a.quaternion.copy(this.quaternion);a.useQuaternion=this.useQuaternion;a.boundRadius=this.boundRadius;a.boundRadiusScale=this.boundRadiusScale;a.visible=this.visible;a.castShadow=this.castShadow;a.receiveShadow=this.receiveShadow;a.frustumCulled=this.frustumCulled;for(var b=0;b<this.children.length;b++)a.add(this.children[b].clone());
return a},deallocate:function(){var a=THREE.Object3DLibrary.indexOf(this);-1!==a&&THREE.Object3DLibrary.splice(a,1)}};THREE.Object3D.__m1=new THREE.Matrix4;THREE.Object3D.defaultEulerOrder="XYZ";THREE.Object3DIdCount=0;THREE.Object3DLibrary=[];
A
alteredq 已提交
80
THREE.Projector=function(){function a(){if(f===h){var a=new THREE.RenderableObject;g.push(a);h++;f++;return a}return g[f++]}function b(){if(j===n){var a=new THREE.RenderableVertex;m.push(a);n++;j++;return a}return m[j++]}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;if(0<=e&&0<=f&&0<=g&&0<=h)return!0;if(0>e&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(d<
81 82
c)return!1;a.lerpSelf(b,c);b.lerpSelf(a,1-d);return!0}var e,f,g=[],h=0,i,j,m=[],n=0,l,p,o=[],q=0,s,r=[],A=0,u,t,F=[],z=0,w,v,C=[],D=0,I={objects:[],sprites:[],lights:[],elements:[]},L=new THREE.Vector3,B=new THREE.Vector4,K=new THREE.Matrix4,H=new THREE.Matrix4,G=new THREE.Frustum,M=new THREE.Vector4,N=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);K.multiply(b.projectionMatrix,b.matrixWorldInverse);K.multiplyVector3(a);return a};this.unprojectVector=
function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);K.multiply(b.matrixWorld,b.projectionMatrixInverse);K.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectScene=function(g,h,n,O){var Q=h.near,U=h.far,J=!1,qa,S,ha,Y,ba,ia,Z,da,Na,Aa,Ja,Ta,ta,db,xb,Ua;v=t=s=p=0;I.elements.length=0;g.updateMatrixWorld();void 0===h.parent&&
83 84
h.updateMatrixWorld();h.matrixWorldInverse.getInverse(h.matrixWorld);K.multiply(h.projectionMatrix,h.matrixWorldInverse);G.setFromMatrix(K);f=0;I.objects.length=0;I.sprites.length=0;I.lights.length=0;var gb=function(b){for(var c=0,d=b.children.length;c<d;c++){var f=b.children[c];if(!1!==f.visible){if(f instanceof THREE.Light)I.lights.push(f);else if(f instanceof THREE.Mesh||f instanceof THREE.Line){if(!1===f.frustumCulled||!0===G.contains(f))e=a(),e.object=f,null!==f.renderDepth?e.z=f.renderDepth:
(L.copy(f.matrixWorld.getPosition()),K.multiplyVector3(L),e.z=L.z),I.objects.push(e)}else f instanceof THREE.Sprite||f instanceof THREE.Particle?(e=a(),e.object=f,null!==f.renderDepth?e.z=f.renderDepth:(L.copy(f.matrixWorld.getPosition()),K.multiplyVector3(L),e.z=L.z),I.sprites.push(e)):(e=a(),e.object=f,null!==f.renderDepth?e.z=f.renderDepth:(L.copy(f.matrixWorld.getPosition()),K.multiplyVector3(L),e.z=L.z),I.objects.push(e));gb(f)}}};gb(g);!0===n&&I.objects.sort(c);g=0;for(n=I.objects.length;g<
85 86
n;g++)if(da=I.objects[g].object,Na=da.matrixWorld,j=0,da instanceof THREE.Mesh){Aa=da.geometry;Ja=da.geometry.materials;ha=Aa.vertices;Ta=Aa.faces;db=Aa.faceVertexUvs;Aa=da.matrixRotationWorld.extractRotation(Na);xb=da.material instanceof THREE.MeshFaceMaterial;qa=0;for(S=ha.length;qa<S;qa++)i=b(),i.positionWorld.copy(ha[qa]),Na.multiplyVector3(i.positionWorld),i.positionScreen.copy(i.positionWorld),K.multiplyVector4(i.positionScreen),i.positionScreen.x/=i.positionScreen.w,i.positionScreen.y/=i.positionScreen.w,
i.visible=i.positionScreen.z>Q&&i.positionScreen.z<U;ha=0;for(qa=Ta.length;ha<qa;ha++)if(S=Ta[ha],Ua=!0===xb?Ja[S.materialIndex]:da.material,void 0!==Ua){ia=Ua.side;if(S instanceof THREE.Face3)if(Y=m[S.a],ba=m[S.b],Z=m[S.c],!0===Y.visible&&!0===ba.visible&&!0===Z.visible)if(J=0>(Z.positionScreen.x-Y.positionScreen.x)*(ba.positionScreen.y-Y.positionScreen.y)-(Z.positionScreen.y-Y.positionScreen.y)*(ba.positionScreen.x-Y.positionScreen.x),ia===THREE.DoubleSide||J===(ia===THREE.FrontSide))p===q?(ta=
87 88 89
new THREE.RenderableFace3,o.push(ta),q++,p++,l=ta):l=o[p++],l.v1.copy(Y),l.v2.copy(ba),l.v3.copy(Z);else continue;else continue;else if(S instanceof THREE.Face4)if(Y=m[S.a],ba=m[S.b],Z=m[S.c],ta=m[S.d],!0===Y.visible&&!0===ba.visible&&!0===Z.visible&&!0===ta.visible)if(J=0>(ta.positionScreen.x-Y.positionScreen.x)*(ba.positionScreen.y-Y.positionScreen.y)-(ta.positionScreen.y-Y.positionScreen.y)*(ba.positionScreen.x-Y.positionScreen.x)||0>(ba.positionScreen.x-Z.positionScreen.x)*(ta.positionScreen.y-
Z.positionScreen.y)-(ba.positionScreen.y-Z.positionScreen.y)*(ta.positionScreen.x-Z.positionScreen.x),ia===THREE.DoubleSide||J===(ia===THREE.FrontSide)){if(s===A){var lb=new THREE.RenderableFace4;r.push(lb);A++;s++;l=lb}else l=r[s++];l.v1.copy(Y);l.v2.copy(ba);l.v3.copy(Z);l.v4.copy(ta)}else continue;else continue;l.normalWorld.copy(S.normal);!1===J&&(ia===THREE.BackSide||ia===THREE.DoubleSide)&&l.normalWorld.negate();Aa.multiplyVector3(l.normalWorld);l.centroidWorld.copy(S.centroid);Na.multiplyVector3(l.centroidWorld);
l.centroidScreen.copy(l.centroidWorld);K.multiplyVector3(l.centroidScreen);Z=S.vertexNormals;Y=0;for(ba=Z.length;Y<ba;Y++)ta=l.vertexNormalsWorld[Y],ta.copy(Z[Y]),!1===J&&(ia===THREE.BackSide||ia===THREE.DoubleSide)&&ta.negate(),Aa.multiplyVector3(ta);l.vertexNormalsLength=Z.length;Y=0;for(ba=db.length;Y<ba;Y++)if(ta=db[Y][ha],void 0!==ta){ia=0;for(Z=ta.length;ia<Z;ia++)l.uvs[Y][ia]=ta[ia]}l.color=S.color;l.material=Ua;l.z=l.centroidScreen.z;I.elements.push(l)}}else if(da instanceof THREE.Line){H.multiply(K,
90 91
Na);ha=da.geometry.vertices;Y=b();Y.positionScreen.copy(ha[0]);H.multiplyVector4(Y.positionScreen);Na=da.type===THREE.LinePieces?2:1;qa=1;for(S=ha.length;qa<S;qa++)Y=b(),Y.positionScreen.copy(ha[qa]),H.multiplyVector4(Y.positionScreen),0<(qa+1)%Na||(ba=m[j-2],M.copy(Y.positionScreen),N.copy(ba.positionScreen),!0===d(M,N)&&(M.multiplyScalar(1/M.w),N.multiplyScalar(1/N.w),t===z?(Ja=new THREE.RenderableLine,F.push(Ja),z++,t++,u=Ja):u=F[t++],u.v1.positionScreen.copy(M),u.v2.positionScreen.copy(N),u.z=
Math.max(M.z,N.z),u.material=da.material,I.elements.push(u)))}g=0;for(n=I.sprites.length;g<n;g++)da=I.sprites[g].object,Na=da.matrixWorld,da instanceof THREE.Particle&&(B.set(Na.elements[12],Na.elements[13],Na.elements[14],1),K.multiplyVector4(B),B.z/=B.w,0<B.z&&1>B.z&&(v===D?(Q=new THREE.RenderableParticle,C.push(Q),D++,v++,w=Q):w=C[v++],w.object=da,w.x=B.x/B.w,w.y=B.y/B.w,w.z=B.z,w.rotation=da.rotation.z,w.scale.x=da.scale.x*Math.abs(w.x-(B.x+h.projectionMatrix.elements[0])/(B.w+h.projectionMatrix.elements[12])),
92
w.scale.y=da.scale.y*Math.abs(w.y-(B.y+h.projectionMatrix.elements[5])/(B.w+h.projectionMatrix.elements[13])),w.material=da.material,I.elements.push(w)));!0===O&&I.elements.sort(c);return I}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1};
A
alteredq 已提交
93 94 95 96 97 98 99 100 101 102 103 104 105
THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a,b){var c=Math.cos(a.x/2),d=Math.cos(a.y/2),e=Math.cos(a.z/2),f=Math.sin(a.x/2),g=Math.sin(a.y/2),h=Math.sin(a.z/2);void 0===b||"XYZ"===b?(this.x=f*d*e+c*g*h,this.y=c*g*e-f*d*h,this.z=c*d*h+f*g*e,this.w=c*d*e-f*g*h):"YXZ"===b?(this.x=f*d*e+c*g*h,this.y=c*g*e-f*d*h,this.z=c*d*
h-f*g*e,this.w=c*d*e+f*g*h):"ZXY"===b?(this.x=f*d*e-c*g*h,this.y=c*g*e+f*d*h,this.z=c*d*h+f*g*e,this.w=c*d*e-f*g*h):"ZYX"===b?(this.x=f*d*e-c*g*h,this.y=c*g*e+f*d*h,this.z=c*d*h-f*g*e,this.w=c*d*e+f*g*h):"YZX"===b?(this.x=f*d*e+c*g*h,this.y=c*g*e+f*d*h,this.z=c*d*h-f*g*e,this.w=c*d*e-f*g*h):"XZY"===b&&(this.x=f*d*e-c*g*h,this.y=c*g*e-f*d*h,this.z=c*d*h+f*g*e,this.w=c*d*e+f*g*h);return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);
return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0],a=b[4],d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],i=b[6],b=b[10],j=c+f+b;0<j?(c=0.5/Math.sqrt(j+1),this.w=0.25/c,this.x=(i-g)*c,this.y=(d-h)*c,this.z=(e-a)*c):c>f&&c>b?(c=2*Math.sqrt(1+c-f-b),this.w=(i-g)/c,this.x=0.25*c,this.y=(a+e)/c,this.z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this.w=(d-h)/c,this.x=(a+e)/c,this.y=0.25*c,this.z=(g+i)/c):(c=2*Math.sqrt(1+b-c-f),this.w=(e-a)/c,this.x=(d+h)/c,this.y=(g+i)/c,this.z=0.25*c);return this},calculateW:function(){this.w=
-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);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){var c=a.x,d=a.y,e=a.z,f=a.w,g=b.x,h=b.y,i=b.z,j=b.w;
this.x=c*j+d*i-e*h+f*g;this.y=-c*i+d*j+e*g+f*h;this.z=c*h-d*g+e*j+f*i;this.w=-c*g-d*h-e*i+f*j;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-d*h;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,h=this.z,i=this.w,j=i*c+g*e-h*d,m=i*d+h*c-f*e,n=i*e+f*d-g*c,c=-f*c-g*d-h*e;b.x=j*i+c*-f+m*-h-n*-g;b.y=m*i+c*-g+n*-f-j*-h;
b.z=n*i+c*-h+j*-g-m*-f;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,e=this.z,f=this.w,g=f*a.w+c*a.x+d*a.y+e*a.z;0>g?(this.w=-a.w,this.x=-a.x,this.y=-a.y,this.z=-a.z,g=-g):this.copy(a);if(1<=g)return this.w=f,this.x=c,this.y=d,this.z=e,this;var h=Math.acos(g),i=Math.sqrt(1-g*g);if(0.001>Math.abs(i))return this.w=0.5*(f+this.w),this.x=0.5*(c+this.x),this.y=0.5*(d+this.y),this.z=0.5*(e+this.z),this;g=Math.sin((1-b)*h)/i;h=Math.sin(b*h)/i;this.w=f*g+this.w*h;this.x=c*g+this.x*h;this.y=d*g+
this.y*h;this.z=e*g+this.z*h;return this},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 b=Math.acos(e),f=Math.sqrt(1-e*e);if(0.001>Math.abs(f))return c.w=0.5*(a.w+c.w),c.x=0.5*(a.x+c.x),c.y=0.5*(a.y+c.y),c.z=0.5*(a.z+c.z),c;e=Math.sin((1-d)*b)/f;d=Math.sin(d*b)/f;c.w=a.w*e+c.w*d;c.x=a.x*e+c.x*d;c.y=a.y*e+c.y*d;c.z=a.z*e+c.z*d;return c};
THREE.Vertex=function(a){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.");return a};THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};
THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;b=0;for(c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();b=0;for(c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();b=0;for(c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
return a}};THREE.Face4=function(a,b,c,d,e,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};
THREE.Face4.prototype={constructor:THREE.Face4,clone:function(){var a=new THREE.Face4(this.a,this.b,this.c,this.d);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;b=0;for(c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();b=0;for(c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();b=0;for(c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
return a}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},lerpSelf:function(a,b){this.u+=(a.u-this.u)*b;this.v+=(a.v-this.v)*b;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
106 107
THREE.Geometry=function(){THREE.GeometryLibrary.push(this);this.id=THREE.GeometryIdCount++;this.name="";this.vertices=[];this.colors=[];this.normals=[];this.materials=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.morphNormals=[];this.skinWeights=[];this.skinIndices=[];this.lineDistances=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1;this.dynamic=!0;this.buffersNeedUpdate=this.lineDistancesNeedUpdate=this.colorsNeedUpdate=
this.tangentsNeedUpdate=this.normalsNeedUpdate=this.uvsNeedUpdate=this.elementsNeedUpdate=this.verticesNeedUpdate=!1};
A
alteredq 已提交
108 109 110 111 112 113 114
THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){var b=new THREE.Matrix4;b.extractRotation(a);for(var c=0,d=this.vertices.length;c<d;c++)a.multiplyVector3(this.vertices[c]);c=0;for(d=this.faces.length;c<d;c++){var e=this.faces[c];b.multiplyVector3(e.normal);for(var f=0,g=e.vertexNormals.length;f<g;f++)b.multiplyVector3(e.vertexNormals[f]);a.multiplyVector3(e.centroid)}},computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c.centroid.set(0,
0,0),c instanceof THREE.Face3?(c.centroid.addSelf(this.vertices[c.a]),c.centroid.addSelf(this.vertices[c.b]),c.centroid.addSelf(this.vertices[c.c]),c.centroid.divideScalar(3)):c instanceof THREE.Face4&&(c.centroid.addSelf(this.vertices[c.a]),c.centroid.addSelf(this.vertices[c.b]),c.centroid.addSelf(this.vertices[c.c]),c.centroid.addSelf(this.vertices[c.d]),c.centroid.divideScalar(4))},computeFaceNormals:function(){var a,b,c,d,e,f,g=new THREE.Vector3,h=new THREE.Vector3;a=0;for(b=this.faces.length;a<
b;a++)c=this.faces[a],d=this.vertices[c.a],e=this.vertices[c.b],f=this.vertices[c.c],g.sub(f,e),h.sub(d,e),g.crossSelf(h),g.isZero()||g.normalize(),c.normal.copy(g)},computeVertexNormals:function(){var a,b,c,d;if(void 0===this.__tmpVertices){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]:
c instanceof THREE.Face4&&(c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3])}else{d=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal)):c instanceof THREE.Face4&&(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));a=0;for(b=this.vertices.length;a<
b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c])):c instanceof THREE.Face4&&(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeMorphNormals:function(){var a,b,c,d,e;c=0;for(d=this.faces.length;c<d;c++){e=this.faces[c];e.__originalFaceNormal?e.__originalFaceNormal.copy(e.normal):
e.__originalFaceNormal=e.normal.clone();e.__originalVertexNormals||(e.__originalVertexNormals=[]);a=0;for(b=e.vertexNormals.length;a<b;a++)e.__originalVertexNormals[a]?e.__originalVertexNormals[a].copy(e.vertexNormals[a]):e.__originalVertexNormals[a]=e.vertexNormals[a].clone()}var f=new THREE.Geometry;f.faces=this.faces;a=0;for(b=this.morphTargets.length;a<b;a++){if(!this.morphNormals[a]){this.morphNormals[a]={};this.morphNormals[a].faceNormals=[];this.morphNormals[a].vertexNormals=[];var g=this.morphNormals[a].faceNormals,
h=this.morphNormals[a].vertexNormals,i,j;c=0;for(d=this.faces.length;c<d;c++)e=this.faces[c],i=new THREE.Vector3,j=e instanceof THREE.Face3?{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3}:{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3,d:new THREE.Vector3},g.push(i),h.push(j)}g=this.morphNormals[a];f.vertices=this.morphTargets[a].vertices;f.computeFaceNormals();f.computeVertexNormals();c=0;for(d=this.faces.length;c<d;c++)e=this.faces[c],i=g.faceNormals[c],j=g.vertexNormals[c],
115
i.copy(e.normal),e instanceof THREE.Face3?(j.a.copy(e.vertexNormals[0]),j.b.copy(e.vertexNormals[1]),j.c.copy(e.vertexNormals[2])):(j.a.copy(e.vertexNormals[0]),j.b.copy(e.vertexNormals[1]),j.c.copy(e.vertexNormals[2]),j.d.copy(e.vertexNormals[3]))}c=0;for(d=this.faces.length;c<d;c++)e=this.faces[c],e.normal=e.__originalFaceNormal,e.vertexNormals=e.__originalVertexNormals},computeTangents:function(){function a(a,b,c,d,e,f,v){h=a.vertices[b];i=a.vertices[c];j=a.vertices[d];m=g[e];n=g[f];l=g[v];p=i.x-
116 117
h.x;o=j.x-h.x;q=i.y-h.y;s=j.y-h.y;r=i.z-h.z;A=j.z-h.z;u=n.u-m.u;t=l.u-m.u;F=n.v-m.v;z=l.v-m.v;w=1/(u*z-t*F);I.set((z*p-F*o)*w,(z*q-F*s)*w,(z*r-F*A)*w);L.set((u*o-t*p)*w,(u*s-t*q)*w,(u*A-t*r)*w);C[b].addSelf(I);C[c].addSelf(I);C[d].addSelf(I);D[b].addSelf(L);D[c].addSelf(L);D[d].addSelf(L)}var b,c,d,e,f,g,h,i,j,m,n,l,p,o,q,s,r,A,u,t,F,z,w,v,C=[],D=[],I=new THREE.Vector3,L=new THREE.Vector3,B=new THREE.Vector3,K=new THREE.Vector3,H=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)C[b]=new THREE.Vector3,
D[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)f=this.faces[b],g=this.faceVertexUvs[0][b],f instanceof THREE.Face3?a(this,f.a,f.b,f.c,0,1,2):f instanceof THREE.Face4&&(a(this,f.a,f.b,f.d,0,1,3),a(this,f.b,f.c,f.d,1,2,3));var G=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];for(d=0;d<f.vertexNormals.length;d++)H.copy(f.vertexNormals[d]),e=f[G[d]],v=C[e],B.copy(v),B.subSelf(H.multiplyScalar(H.dot(v))).normalize(),K.cross(f.vertexNormals[d],v),e=K.dot(D[e]),e=0>e?
118 119 120 121
-1:1,f.vertexTangents[d]=new THREE.Vector4(B.x,B.y,B.z,e)}this.hasTangents=!0},computeLineDistances:function(){for(var a=0,b=this.vertices,c=0,d=b.length;c<d;c++)0<c&&(a+=b[c].distanceTo(b[c-1])),this.lineDistances[c]=a},computeBoundingBox:function(){this.boundingBox||(this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3});if(0<this.vertices.length){var a;a=this.vertices[0];this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,
e=this.vertices.length;d<e;d++)(a=this.vertices[d],a.x<b.x?b.x=a.x:a.x>c.x&&(c.x=a.x),a.y<b.y?b.y=a.y:a.y>c.y&&(c.y=a.y),a.z<b.z)?b.z=a.z:a.z>c.z&&(c.z=a.z)}else this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){var a=0;null===this.boundingSphere&&(this.boundingSphere={radius:0});for(var b=0,c=this.vertices.length;b<c;b++){var d=this.vertices[b].lengthSq();d>a&&(a=d)}this.boundingSphere.radius=Math.sqrt(a)},mergeVertices:function(){var a={},b=[],c=[],
d,e=Math.pow(10,4),f,g,h,i;f=0;for(g=this.vertices.length;f<g;f++)d=this.vertices[f],d=[Math.round(d.x*e),Math.round(d.y*e),Math.round(d.z*e)].join("_"),void 0===a[d]?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];f=0;for(g=this.faces.length;f<g;f++)if(a=this.faces[f],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4){a.a=c[a.a];a.b=c[a.b];a.c=c[a.c];a.d=c[a.d];d=[a.a,a.b,a.c,a.d];for(e=3;0<e;e--)if(d.indexOf(a["abcd"[e]])!==e){d.splice(e,1);
this.faces[f]=new THREE.Face3(d[0],d[1],d[2],a.normal,a.color,a.materialIndex);d=0;for(h=this.faceVertexUvs.length;d<h;d++)(i=this.faceVertexUvs[d][f])&&i.splice(e,1);this.faces[f].vertexColors=a.vertexColors;break}}c=this.vertices.length-b.length;this.vertices=b;return c},clone:function(){},deallocate:function(){var a=THREE.GeometryLibrary.indexOf(this);-1!==a&&THREE.GeometryLibrary.splice(a,1)}};THREE.GeometryIdCount=0;THREE.GeometryLibrary=[];
A
alteredq 已提交
122 123 124 125
THREE.BufferGeometry=function(){THREE.GeometryLibrary.push(this);this.id=THREE.GeometryIdCount++;this.attributes={};this.dynamic=!1;this.boundingSphere=this.boundingBox=null;this.hasTangents=!1;this.morphTargets=[]};
THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,applyMatrix:function(a){var b,c;this.attributes.position&&(b=this.attributes.position.array);this.attributes.normal&&(c=this.attributes.normal.array);void 0!==b&&(a.multiplyVector3Array(b),this.verticesNeedUpdate=!0);void 0!==c&&(b=new THREE.Matrix4,b.extractRotation(a),b.multiplyVector3Array(c),this.normalsNeedUpdate=!0)},computeBoundingBox:function(){this.boundingBox||(this.boundingBox={min:new THREE.Vector3(Infinity,Infinity,Infinity),
max:new THREE.Vector3(-Infinity,-Infinity,-Infinity)});var a=this.attributes.position.array;if(a)for(var b=this.boundingBox,c,d,e,f=0,g=a.length;f<g;f+=3)(c=a[f],d=a[f+1],e=a[f+2],c<b.min.x?b.min.x=c:c>b.max.x&&(b.max.x=c),d<b.min.y?b.min.y=d:d>b.max.y&&(b.max.y=d),e<b.min.z)?b.min.z=e:e>b.max.z&&(b.max.z=e);if(void 0===a||0===a.length)this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){this.boundingSphere||(this.boundingSphere={radius:0});var a=this.attributes.position.array;
if(a){for(var b,c=0,d,e,f=0,g=a.length;f<g;f+=3)b=a[f],d=a[f+1],e=a[f+2],b=b*b+d*d+e*e,b>c&&(c=b);this.boundingSphere.radius=Math.sqrt(c)}},computeVertexNormals:function(){if(this.attributes.position&&this.attributes.index){var a,b,c,d;a=this.attributes.position.array.length;if(void 0===this.attributes.normal)this.attributes.normal={itemSize:3,array:new Float32Array(a),numItems:a};else{a=0;for(b=this.attributes.normal.array.length;a<b;a++)this.attributes.normal.array[a]=0}var e=this.offsets,f=this.attributes.index.array,
126
g=this.attributes.position.array,h=this.attributes.normal.array,i,j,m,n,l,p,o=new THREE.Vector3,q=new THREE.Vector3,s=new THREE.Vector3,r=new THREE.Vector3,A=new THREE.Vector3;c=0;for(d=e.length;c<d;++c){b=e[c].start;i=e[c].count;var u=e[c].index;a=b;for(b+=i;a<b;a+=3)i=u+f[a],j=u+f[a+1],m=u+f[a+2],n=g[3*i],l=g[3*i+1],p=g[3*i+2],o.set(n,l,p),n=g[3*j],l=g[3*j+1],p=g[3*j+2],q.set(n,l,p),n=g[3*m],l=g[3*m+1],p=g[3*m+2],s.set(n,l,p),r.sub(s,q),A.sub(o,q),r.crossSelf(A),h[3*i]+=r.x,h[3*i+1]+=r.y,h[3*i+
127
2]+=r.z,h[3*j]+=r.x,h[3*j+1]+=r.y,h[3*j+2]+=r.z,h[3*m]+=r.x,h[3*m+1]+=r.y,h[3*m+2]+=r.z}a=0;for(b=h.length;a<b;a+=3)n=h[a],l=h[a+1],p=h[a+2],c=1/Math.sqrt(n*n+l*l+p*p),h[a]*=c,h[a+1]*=c,h[a+2]*=c;this.normalsNeedUpdate=!0}},computeTangents:function(){function a(a){aa.x=d[3*a];aa.y=d[3*a+1];aa.z=d[3*a+2];P.copy(aa);Q=i[a];N.copy(Q);N.subSelf(aa.multiplyScalar(aa.dot(Q))).normalize();R.cross(P,Q);U=R.dot(j[a]);O=0>U?-1:1;h[4*a]=N.x;h[4*a+1]=N.y;h[4*a+2]=N.z;h[4*a+3]=O}if(void 0===this.attributes.index||
A
alteredq 已提交
128
void 0===this.attributes.position||void 0===this.attributes.normal||void 0===this.attributes.uv)console.warn("Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");else{var b=this.attributes.index.array,c=this.attributes.position.array,d=this.attributes.normal.array,e=this.attributes.uv.array,f=c.length/3;if(void 0===this.attributes.tangent){var g=4*f;this.attributes.tangent={itemSize:4,array:new Float32Array(g),numItems:g}}for(var h=this.attributes.tangent.array,
129 130
i=[],j=[],g=0;g<f;g++)i[g]=new THREE.Vector3,j[g]=new THREE.Vector3;var m,n,l,p,o,q,s,r,A,u,t,F,z,w,v,f=new THREE.Vector3,g=new THREE.Vector3,C,D,I,L,B,K,H,G=this.offsets;I=0;for(L=G.length;I<L;++I){D=G[I].start;B=G[I].count;var M=G[I].index;C=D;for(D+=B;C<D;C+=3)B=M+b[C],K=M+b[C+1],H=M+b[C+2],m=c[3*B],n=c[3*B+1],l=c[3*B+2],p=c[3*K],o=c[3*K+1],q=c[3*K+2],s=c[3*H],r=c[3*H+1],A=c[3*H+2],u=e[2*B],t=e[2*B+1],F=e[2*K],z=e[2*K+1],w=e[2*H],v=e[2*H+1],p-=m,m=s-m,o-=n,n=r-n,q-=l,l=A-l,F-=u,u=w-u,z-=t,t=v-
t,v=1/(F*t-u*z),f.set((t*p-z*m)*v,(t*o-z*n)*v,(t*q-z*l)*v),g.set((F*m-u*p)*v,(F*n-u*o)*v,(F*l-u*q)*v),i[B].addSelf(f),i[K].addSelf(f),i[H].addSelf(f),j[B].addSelf(g),j[K].addSelf(g),j[H].addSelf(g)}var N=new THREE.Vector3,R=new THREE.Vector3,aa=new THREE.Vector3,P=new THREE.Vector3,O,Q,U;I=0;for(L=G.length;I<L;++I){D=G[I].start;B=G[I].count;M=G[I].index;C=D;for(D+=B;C<D;C+=3)B=M+b[C],K=M+b[C+1],H=M+b[C+2],a(B),a(K),a(H)}this.tangentsNeedUpdate=this.hasTangents=!0}},deallocate:function(){var a=THREE.GeometryLibrary.indexOf(this);
M
Mr.doob 已提交
131
-1!==a&&THREE.GeometryLibrary.splice(a,1)}};
A
alteredq 已提交
132 133 134
THREE.Spline=function(a){function b(a,b,c,d,e,f,g){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,f,g,h,i,j,m,n,l;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){e=(this.points.length-1)*a;f=Math.floor(e);g=e-f;c[0]=0===f?f:f-1;c[1]=f;c[2]=f>this.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1:
f+2;j=this.points[c[0]];m=this.points[c[1]];n=this.points[c[2]];l=this.points[c[3]];h=g*g;i=g*h;d.x=b(j.x,m.x,n.x,l.x,g,h,i);d.y=b(j.y,m.y,n.y,l.y,g,h,i);d.z=b(j.z,m.z,n.z,l.z,g,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d};this.getLength=function(a){var b,c,d,e=b=b=0,f=new THREE.Vector3,g=new THREE.Vector3,h=[],i=0;h[0]=0;a||(a=100);c=this.points.length*a;f.copy(this.points[0]);for(a=1;a<c;a++)b=
a/c,d=this.getPoint(b),g.copy(d),i+=g.distanceTo(f),f.copy(d),b*=this.points.length-1,b=Math.floor(b),b!=e&&(h[b]=i,e=b);h[h.length]=i;return{chunks:h,total:i}};this.reparametrizeByArcLength=function(a){var b,c,d,e,f,g,h=[],i=new THREE.Vector3,j=this.getLength();h.push(i.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=j.chunks[b]-j.chunks[b-1];g=Math.ceil(a*c/j.total);e=(b-1)/(this.points.length-1);f=b/(this.points.length-1);for(c=1;c<g-1;c++)d=e+c*(1/g)*(f-e),d=this.getPoint(d),
M
Mr.doob 已提交
135 136 137 138
h.push(i.copy(d).clone());h.push(i.copy(this.points[b]).clone())}this.points=h}};THREE.Camera=function(){THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};THREE.Camera.prototype=Object.create(THREE.Object3D.prototype);
THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);!0===this.rotationAutoUpdate&&(!1===this.useQuaternion?this.rotation.setEulerFromRotationMatrix(this.matrix,this.eulerOrder):this.quaternion.copy(this.matrix.decompose()[1]))};THREE.OrthographicCamera=function(a,b,c,d,e,f){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=void 0!==e?e:0.1;this.far=void 0!==f?f:2E3;this.updateProjectionMatrix()};
THREE.OrthographicCamera.prototype=Object.create(THREE.Camera.prototype);THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix.makeOrthographic(this.left,this.right,this.top,this.bottom,this.near,this.far)};THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=void 0!==a?a:50;this.aspect=void 0!==b?b:1;this.near=void 0!==c?c:0.1;this.far=void 0!==d?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=Object.create(THREE.Camera.prototype);
THREE.PerspectiveCamera.prototype.setLens=function(a,b){void 0===b&&(b=24);this.fov=2*Math.atan(b/(2*a))*(180/Math.PI);this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=f;this.updateProjectionMatrix()};
A
alteredq 已提交
139 140 141 142 143 144 145 146 147
THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix.makePerspective(this.fov,this.aspect,this.near,this.far)};
THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=Object.create(THREE.Object3D.prototype);THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=Object.create(THREE.Light.prototype);
THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0;this.onlyShadow=this.castShadow=!1;this.shadowCameraNear=50;this.shadowCameraFar=5E3;this.shadowCameraLeft=-500;this.shadowCameraTop=this.shadowCameraRight=500;this.shadowCameraBottom=-500;this.shadowCameraVisible=!1;this.shadowBias=0;this.shadowDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCascade=
!1;this.shadowCascadeOffset=new THREE.Vector3(0,0,-1E3);this.shadowCascadeCount=2;this.shadowCascadeBias=[0,0,0];this.shadowCascadeWidth=[512,512,512];this.shadowCascadeHeight=[512,512,512];this.shadowCascadeNearZ=[-1,0.99,0.998];this.shadowCascadeFarZ=[0.99,0.998,1];this.shadowCascadeArray=[];this.shadowMatrix=this.shadowCamera=this.shadowMapSize=this.shadowMap=null};THREE.DirectionalLight.prototype=Object.create(THREE.Light.prototype);
THREE.HemisphereLight=function(a,b,c){THREE.Light.call(this,a);this.groundColor=new THREE.Color(b);this.position=new THREE.Vector3(0,100,0);this.intensity=void 0!==c?c:1};THREE.HemisphereLight.prototype=Object.create(THREE.Light.prototype);THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0};THREE.PointLight.prototype=Object.create(THREE.Light.prototype);
THREE.SpotLight=function(a,b,c,d,e){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0;this.angle=void 0!==d?d:Math.PI/2;this.exponent=void 0!==e?e:10;this.onlyShadow=this.castShadow=!1;this.shadowCameraNear=50;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowCameraVisible=!1;this.shadowBias=0;this.shadowDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowMatrix=this.shadowCamera=
this.shadowMapSize=this.shadowMap=null};THREE.SpotLight.prototype=Object.create(THREE.Light.prototype);THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
THREE.Loader.prototype={constructor:THREE.Loader,crossOrigin:"anonymous",addStatusElement:function(){var a=document.createElement("div");a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="rgba(0,0,0,0.25)";a.style.color="#fff";a.style.width="120px";a.style.padding="0.5em 0.5em 0.5em 0.5em";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ",b=a.total?b+((100*a.loaded/
a.total).toFixed(0)+"%"):b+((a.loaded/1E3).toFixed(2)+" KB");this.statusDomElement.innerHTML=b},extractUrlBase:function(a){a=a.split("/");a.pop();return(1>a.length?".":a.join("/"))+"/"},initMaterials:function(a,b,c){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=THREE.Loader.prototype.createMaterial(b[d],c)},hasNormals:function(a){var b,c,d=a.materials.length;for(c=0;c<d;c++)if(b=a.materials[c],b instanceof THREE.ShaderMaterial)return!0;return!1},createMaterial:function(a,b){function c(a){a=
148 149
Math.log(a)/Math.LN2;return Math.floor(a)==a}function d(a){a=Math.log(a)/Math.LN2;return Math.pow(2,Math.round(a))}function e(a,e,f,h,i,j,s){var r=f.toLowerCase().endsWith(".dds"),A=b+"/"+f;if(r){var u=THREE.ImageUtils.loadCompressedTexture(A);a[e]=u}else u=document.createElement("canvas"),a[e]=new THREE.Texture(u);a[e].sourceFile=f;if(h&&(a[e].repeat.set(h[0],h[1]),1!==h[0]&&(a[e].wrapS=THREE.RepeatWrapping),1!==h[1]))a[e].wrapT=THREE.RepeatWrapping;i&&a[e].offset.set(i[0],i[1]);if(j&&(f={repeat:THREE.RepeatWrapping,
mirror:THREE.MirroredRepeatWrapping},void 0!==f[j[0]]&&(a[e].wrapS=f[j[0]]),void 0!==f[j[1]]))a[e].wrapT=f[j[1]];s&&(a[e].anisotropy=s);if(!r){var t=a[e],a=new Image;a.onload=function(){if(!c(this.width)||!c(this.height)){var a=d(this.width),b=d(this.height);t.image.width=a;t.image.height=b;t.image.getContext("2d").drawImage(this,0,0,a,b)}else t.image=this;t.needsUpdate=true};a.crossOrigin=g.crossOrigin;a.src=A}}function f(a){return(255*a[0]<<16)+(255*a[1]<<8)+255*a[2]}var g=this,h="MeshLambertMaterial",
A
alteredq 已提交
150 151 152 153 154 155 156 157 158
i={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,bumpMap:null,wireframe:!1};if(a.shading){var j=a.shading.toLowerCase();"phong"===j?h="MeshPhongMaterial":"basic"===j&&(h="MeshBasicMaterial")}void 0!==a.blending&&void 0!==THREE[a.blending]&&(i.blending=THREE[a.blending]);if(void 0!==a.transparent||1>a.opacity)i.transparent=a.transparent;void 0!==a.depthTest&&(i.depthTest=a.depthTest);void 0!==a.depthWrite&&(i.depthWrite=a.depthWrite);void 0!==a.visible&&(i.visible=a.visible);void 0!==
a.flipSided&&(i.side=THREE.BackSide);void 0!==a.doubleSided&&(i.side=THREE.DoubleSide);void 0!==a.wireframe&&(i.wireframe=a.wireframe);void 0!==a.vertexColors&&("face"===a.vertexColors?i.vertexColors=THREE.FaceColors:a.vertexColors&&(i.vertexColors=THREE.VertexColors));a.colorDiffuse?i.color=f(a.colorDiffuse):a.DbgColor&&(i.color=a.DbgColor);a.colorSpecular&&(i.specular=f(a.colorSpecular));a.colorAmbient&&(i.ambient=f(a.colorAmbient));a.transparency&&(i.opacity=a.transparency);a.specularCoef&&(i.shininess=
a.specularCoef);a.mapDiffuse&&b&&e(i,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap,a.mapDiffuseAnisotropy);a.mapLight&&b&&e(i,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap,a.mapLightAnisotropy);a.mapBump&&b&&e(i,"bumpMap",a.mapBump,a.mapBumpRepeat,a.mapBumpOffset,a.mapBumpWrap,a.mapBumpAnisotropy);a.mapNormal&&b&&e(i,"normalMap",a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap,a.mapNormalAnisotropy);a.mapSpecular&&b&&e(i,"specularMap",
a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap,a.mapSpecularAnisotropy);a.mapBumpScale&&(i.bumpScale=a.mapBumpScale);a.mapNormal?(h=THREE.ShaderUtils.lib.normal,j=THREE.UniformsUtils.clone(h.uniforms),j.tNormal.value=i.normalMap,a.mapNormalFactor&&j.uNormalScale.value.set(a.mapNormalFactor,a.mapNormalFactor),i.map&&(j.tDiffuse.value=i.map,j.enableDiffuse.value=!0),i.specularMap&&(j.tSpecular.value=i.specularMap,j.enableSpecular.value=!0),i.lightMap&&(j.tAO.value=i.lightMap,
j.enableAO.value=!0),j.uDiffuseColor.value.setHex(i.color),j.uSpecularColor.value.setHex(i.specular),j.uAmbientColor.value.setHex(i.ambient),j.uShininess.value=i.shininess,void 0!==i.opacity&&(j.uOpacity.value=i.opacity),i=new THREE.ShaderMaterial({fragmentShader:h.fragmentShader,vertexShader:h.vertexShader,uniforms:j,lights:!0,fog:!0})):i=new THREE[h](i);void 0!==a.DbgName&&(i.name=a.DbgName);return i}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=Object.create(THREE.Loader.prototype);
THREE.BinaryLoader.prototype.load=function(a,b,c,d){var c=c?c:this.extractUrlBase(a),d=d?d:this.extractUrlBase(a),e=this.showProgress?THREE.Loader.prototype.updateProgress:null;this.onLoadStart();this.loadAjaxJSON(this,a,b,c,d,e)};
THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,b,c,d,e,f){var g=new XMLHttpRequest;g.onreadystatechange=function(){if(4==g.readyState)if(200==g.status||0==g.status){var h=JSON.parse(g.responseText);a.loadAjaxBuffers(h,c,e,d,f)}else console.error("THREE.BinaryLoader: Couldn't load ["+b+"] ["+g.status+"]")};g.open("GET",b,!0);g.send(null)};
THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,b,c,d,e){var f=new XMLHttpRequest,g=c+"/"+a.buffers,h=0;f.onreadystatechange=function(){if(4==f.readyState)if(200==f.status||0==f.status){var c=f.response;void 0===c&&(c=(new Uint8Array(f.responseBody)).buffer);THREE.BinaryLoader.prototype.createBinModel(c,b,d,a.materials)}else console.error("THREE.BinaryLoader: Couldn't load ["+g+"] ["+f.status+"]");else 3==f.readyState?e&&(0==h&&(h=f.getResponseHeader("Content-Length")),e({total:h,loaded:f.responseText.length})):
2==f.readyState&&(h=f.getResponseHeader("Content-Length"))};f.open("GET",g,!0);f.responseType="arraybuffer";f.send(null)};
159 160
THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var e=function(b){var c,e,i,j,m,n,l,p,o,q,s,r,A,u,t;function F(a){return a%4?4-a%4:0}function z(a,b){return(new Uint8Array(a,b,1))[0]}function w(a,b){return(new Uint32Array(a,b,1))[0]}function v(b,c){var d,e,f,g,h,i,j,l,m=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){e=m[3*d];f=m[3*d+1];g=m[3*d+2];h=M[2*e];e=M[2*e+1];i=M[2*f];j=M[2*f+1];f=M[2*g];l=M[2*g+1];g=K.faceVertexUvs[0];var n=[];n.push(new THREE.UV(h,e));n.push(new THREE.UV(i,j));n.push(new THREE.UV(f,
l));g.push(n)}}function C(b,c){var d,e,f,g,h,i,j,l,m,n,o=new Uint32Array(a,c,4*b);for(d=0;d<b;d++){e=o[4*d];f=o[4*d+1];g=o[4*d+2];h=o[4*d+3];i=M[2*e];e=M[2*e+1];j=M[2*f];m=M[2*f+1];l=M[2*g];n=M[2*g+1];g=M[2*h];f=M[2*h+1];h=K.faceVertexUvs[0];var p=[];p.push(new THREE.UV(i,e));p.push(new THREE.UV(j,m));p.push(new THREE.UV(l,n));p.push(new THREE.UV(g,f));h.push(p)}}function D(b,c,d){for(var e,f,g,h,c=new Uint32Array(a,c,3*b),i=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[3*d],f=c[3*d+1],g=c[3*d+2],h=i[d],
161 162
K.faces.push(new THREE.Face3(e,f,g,null,null,h))}function I(b,c,d){for(var e,f,g,h,i,c=new Uint32Array(a,c,4*b),j=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[4*d],f=c[4*d+1],g=c[4*d+2],h=c[4*d+3],i=j[d],K.faces.push(new THREE.Face4(e,f,g,h,null,null,i))}function L(b,c,d,e){for(var f,g,h,i,j,l,m,c=new Uint32Array(a,c,3*b),d=new Uint32Array(a,d,3*b),n=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[3*e];g=c[3*e+1];h=c[3*e+2];j=d[3*e];l=d[3*e+1];m=d[3*e+2];i=n[e];var o=G[3*l],p=G[3*l+1];l=G[3*l+2];var q=G[3*m],r=
G[3*m+1];m=G[3*m+2];K.faces.push(new THREE.Face3(f,g,h,[new THREE.Vector3(G[3*j],G[3*j+1],G[3*j+2]),new THREE.Vector3(o,p,l),new THREE.Vector3(q,r,m)],null,i))}}function B(b,c,d,e){for(var f,g,h,i,j,l,m,n,o,c=new Uint32Array(a,c,4*b),d=new Uint32Array(a,d,4*b),p=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[4*e];g=c[4*e+1];h=c[4*e+2];i=c[4*e+3];l=d[4*e];m=d[4*e+1];n=d[4*e+2];o=d[4*e+3];j=p[e];var q=G[3*m],r=G[3*m+1];m=G[3*m+2];var s=G[3*n],t=G[3*n+1];n=G[3*n+2];var u=G[3*o],v=G[3*o+1];o=G[3*o+2];K.faces.push(new THREE.Face4(f,
163 164 165 166
g,h,i,[new THREE.Vector3(G[3*l],G[3*l+1],G[3*l+2]),new THREE.Vector3(q,r,m),new THREE.Vector3(s,t,n),new THREE.Vector3(u,v,o)],null,j))}}var K=this,H=0,G=[],M=[],N,R,aa;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(K,d,b);t=a;R=H;b=new Uint8Array(t,R,12);q="";for(A=0;12>A;A++)q+=String.fromCharCode(b[R+A]);c=z(t,R+12);z(t,R+13);z(t,R+14);z(t,R+15);e=z(t,R+16);i=z(t,R+17);j=z(t,R+18);m=z(t,R+19);n=w(t,R+20);l=w(t,R+20+4);p=w(t,R+20+8);o=w(t,R+20+12);q=w(t,R+20+16);s=w(t,R+20+20);r=
w(t,R+20+24);A=w(t,R+20+28);b=w(t,R+20+32);u=w(t,R+20+36);t=w(t,R+20+40);H+=c;R=3*e+m;aa=4*e+m;N=o*R;c=q*(R+3*i);e=s*(R+3*j);m=r*(R+3*i+3*j);R=A*aa;i=b*(aa+4*i);j=u*(aa+4*j);aa=H;var H=new Float32Array(a,H,3*n),P,O,Q,U;for(P=0;P<n;P++)O=H[3*P],Q=H[3*P+1],U=H[3*P+2],K.vertices.push(new THREE.Vector3(O,Q,U));n=H=aa+3*n*Float32Array.BYTES_PER_ELEMENT;if(l){H=new Int8Array(a,H,3*l);for(aa=0;aa<l;aa++)P=H[3*aa],O=H[3*aa+1],Q=H[3*aa+2],G.push(P/127,O/127,Q/127)}H=n+3*l*Int8Array.BYTES_PER_ELEMENT;l=H+=
F(3*l);if(p){H=new Float32Array(a,H,2*p);for(n=0;n<p;n++)aa=H[2*n],P=H[2*n+1],M.push(aa,P)}p=H=l+2*p*Float32Array.BYTES_PER_ELEMENT;N=p+N+F(2*o);l=N+c+F(2*q);c=l+e+F(2*s);e=c+m+F(2*r);R=e+R+F(2*A);m=R+i+F(2*b);i=m+j+F(2*u);s&&(j=l+3*s*Uint32Array.BYTES_PER_ELEMENT,D(s,l,j+3*s*Uint32Array.BYTES_PER_ELEMENT),v(s,j));r&&(s=c+3*r*Uint32Array.BYTES_PER_ELEMENT,j=s+3*r*Uint32Array.BYTES_PER_ELEMENT,L(r,c,s,j+3*r*Uint32Array.BYTES_PER_ELEMENT),v(r,j));u&&(r=m+4*u*Uint32Array.BYTES_PER_ELEMENT,I(u,m,r+4*
u*Uint32Array.BYTES_PER_ELEMENT),C(u,r));t&&(u=i+4*t*Uint32Array.BYTES_PER_ELEMENT,r=u+4*t*Uint32Array.BYTES_PER_ELEMENT,B(t,i,u,r+4*t*Uint32Array.BYTES_PER_ELEMENT),C(t,r));o&&D(o,p,p+3*o*Uint32Array.BYTES_PER_ELEMENT);q&&(o=N+3*q*Uint32Array.BYTES_PER_ELEMENT,L(q,N,o,o+3*q*Uint32Array.BYTES_PER_ELEMENT));A&&I(A,e,e+4*A*Uint32Array.BYTES_PER_ELEMENT);b&&(q=R+4*b*Uint32Array.BYTES_PER_ELEMENT,B(b,R,q,q+4*b*Uint32Array.BYTES_PER_ELEMENT));this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&
A
alteredq 已提交
167 168 169 170 171
this.computeTangents()};e.prototype=Object.create(THREE.Geometry.prototype);b(new e(c))};THREE.ImageLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null};
THREE.ImageLoader.prototype={constructor:THREE.ImageLoader,load:function(a,b){var c=this;void 0===b&&(b=new Image);b.addEventListener("load",function(){c.dispatchEvent({type:"load",content:b})},!1);b.addEventListener("error",function(){c.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},!1);c.crossOrigin&&(b.crossOrigin=c.crossOrigin);b.src=a}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a);this.withCredentials=!1};THREE.JSONLoader.prototype=Object.create(THREE.Loader.prototype);
THREE.JSONLoader.prototype.load=function(a,b,c){c=c?c:this.extractUrlBase(a);this.onLoadStart();this.loadAjaxJSON(this,a,b,c)};
THREE.JSONLoader.prototype.loadAjaxJSON=function(a,b,c,d,e){var f=new XMLHttpRequest,g=0;f.withCredentials=this.withCredentials;f.onreadystatechange=function(){if(f.readyState===f.DONE)if(200===f.status||0===f.status){if(f.responseText){var h=JSON.parse(f.responseText);a.createModel(h,c,d)}else console.warn("THREE.JSONLoader: ["+b+"] seems to be unreachable or file there is empty");a.onLoadComplete()}else console.error("THREE.JSONLoader: Couldn't load ["+b+"] ["+f.status+"]");else f.readyState===
f.LOADING?e&&(0===g&&(g=f.getResponseHeader("Content-Length")),e({total:g,loaded:f.responseText.length})):f.readyState===f.HEADERS_RECEIVED&&(g=f.getResponseHeader("Content-Length"))};f.open("GET",b,!0);f.send(null)};
172 173
THREE.JSONLoader.prototype.createModel=function(a,b,c){var d=new THREE.Geometry,e=void 0!==a.scale?1/a.scale:1;this.initMaterials(d,a.materials,c);var f,g,h,i,j,m,n,l,p,o,q,s,r,A,u=a.faces;p=a.vertices;var t=a.normals,F=a.colors,z=0;for(f=0;f<a.uvs.length;f++)a.uvs[f].length&&z++;for(f=0;f<z;f++)d.faceUvs[f]=[],d.faceVertexUvs[f]=[];c=0;for(i=p.length;c<i;)j=new THREE.Vector3,j.x=p[c++]*e,j.y=p[c++]*e,j.z=p[c++]*e,d.vertices.push(j);c=0;for(i=u.length;c<i;){p=u[c++];j=p&1;h=p&2;f=p&4;g=p&8;n=p&16;
m=p&32;o=p&64;p&=128;j?(q=new THREE.Face4,q.a=u[c++],q.b=u[c++],q.c=u[c++],q.d=u[c++],j=4):(q=new THREE.Face3,q.a=u[c++],q.b=u[c++],q.c=u[c++],j=3);h&&(h=u[c++],q.materialIndex=h);h=d.faces.length;if(f)for(f=0;f<z;f++)s=a.uvs[f],l=u[c++],A=s[2*l],l=s[2*l+1],d.faceUvs[f][h]=new THREE.UV(A,l);if(g)for(f=0;f<z;f++){s=a.uvs[f];r=[];for(g=0;g<j;g++)l=u[c++],A=s[2*l],l=s[2*l+1],r[g]=new THREE.UV(A,l);d.faceVertexUvs[f][h]=r}n&&(n=3*u[c++],g=new THREE.Vector3,g.x=t[n++],g.y=t[n++],g.z=t[n],q.normal=g);if(m)for(f=
174
0;f<j;f++)n=3*u[c++],g=new THREE.Vector3,g.x=t[n++],g.y=t[n++],g.z=t[n],q.vertexNormals.push(g);o&&(m=u[c++],m=new THREE.Color(F[m]),q.color=m);if(p)for(f=0;f<j;f++)m=u[c++],m=new THREE.Color(F[m]),q.vertexColors.push(m);d.faces.push(q)}if(a.skinWeights){c=0;for(i=a.skinWeights.length;c<i;c+=2)u=a.skinWeights[c],t=a.skinWeights[c+1],d.skinWeights.push(new THREE.Vector4(u,t,0,0))}if(a.skinIndices){c=0;for(i=a.skinIndices.length;c<i;c+=2)u=a.skinIndices[c],t=a.skinIndices[c+1],d.skinIndices.push(new THREE.Vector4(u,
175 176
t,0,0))}d.bones=a.bones;d.animation=a.animation;if(void 0!==a.morphTargets){c=0;for(i=a.morphTargets.length;c<i;c++){d.morphTargets[c]={};d.morphTargets[c].name=a.morphTargets[c].name;d.morphTargets[c].vertices=[];F=d.morphTargets[c].vertices;z=a.morphTargets[c].vertices;u=0;for(t=z.length;u<t;u+=3)p=new THREE.Vector3,p.x=z[u]*e,p.y=z[u+1]*e,p.z=z[u+2]*e,F.push(p)}}if(void 0!==a.morphColors){c=0;for(i=a.morphColors.length;c<i;c++){d.morphColors[c]={};d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=
[];t=d.morphColors[c].colors;F=a.morphColors[c].colors;e=0;for(u=F.length;e<u;e+=3)z=new THREE.Color(16755200),z.setRGB(F[e],F[e+1],F[e+2]),t.push(z)}}d.computeCentroids();d.computeFaceNormals();this.hasNormals(d)&&d.computeTangents();b(d)};THREE.LoadingMonitor=function(){THREE.EventTarget.call(this);var a=this,b=0,c=0,d=function(){b++;a.dispatchEvent({type:"progress",loaded:b,total:c});b===c&&a.dispatchEvent({type:"load"})};this.add=function(a){c++;a.addEventListener("load",d,!1)}};
A
alteredq 已提交
177 178 179 180 181 182 183 184 185
THREE.GeometryLoader=function(){THREE.EventTarget.call(this);this.path=this.crossOrigin=null};
THREE.GeometryLoader.prototype={constructor:THREE.GeometryLoader,load:function(a){var b=this,c=null;if(null===b.path){var d=a.split("/");d.pop();b.path=1>d.length?".":d.join("/")}d=new XMLHttpRequest;d.addEventListener("load",function(d){d.target.responseText?c=b.parse(JSON.parse(d.target.responseText),e):b.dispatchEvent({type:"error",message:"Invalid file ["+a+"]"})},!1);d.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},!1);d.open("GET",a,
!0);d.send(null);var e=new THREE.LoadingMonitor;e.addEventListener("load",function(){b.dispatchEvent({type:"load",content:c})});e.add(d)},parse:function(a,b){var c=this,d=new THREE.Geometry,e=void 0!==a.scale?1/a.scale:1;if(a.materials){d.materials=[];for(var f=0;f<a.materials.length;++f){var g=a.materials[f],h=function(a){a=Math.log(a)/Math.LN2;return Math.floor(a)==a},i=function(a){a=Math.log(a)/Math.LN2;return Math.pow(2,Math.round(a))},j=function(a,d,e,f,g,j){a[d]=new THREE.Texture;a[d].sourceFile=
e;if(f&&(a[d].repeat.set(f[0],f[1]),1!==f[0]&&(a[d].wrapS=THREE.RepeatWrapping),1!==f[1]))a[d].wrapT=THREE.RepeatWrapping;g&&a[d].offset.set(g[0],g[1]);if(j&&(f={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping},void 0!==f[j[0]]&&(a[d].wrapS=f[j[0]]),void 0!==f[j[1]]))a[d].wrapT=f[j[1]];var l=a[d],a=new THREE.ImageLoader;a.addEventListener("load",function(a){a=a.content;if(!h(a.width)||!h(a.height)){var b=i(a.width),c=i(a.height);l.image=document.createElement("canvas");l.image.width=
b;l.image.height=c;l.image.getContext("2d").drawImage(a,0,0,b,c)}else l.image=a;l.needsUpdate=!0});a.crossOrigin=c.crossOrigin;a.load(c.path+"/"+e);b&&b.add(a)},m=function(a){return(255*a[0]<<16)+(255*a[1]<<8)+255*a[2]},n="MeshLambertMaterial",l={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,bumpMap:null,wireframe:!1};if(g.shading){var p=g.shading.toLowerCase();"phong"===p?n="MeshPhongMaterial":"basic"===p&&(n="MeshBasicMaterial")}void 0!==g.blending&&void 0!==THREE[g.blending]&&
(l.blending=THREE[g.blending]);if(void 0!==g.transparent||1>g.opacity)l.transparent=g.transparent;void 0!==g.depthTest&&(l.depthTest=g.depthTest);void 0!==g.depthWrite&&(l.depthWrite=g.depthWrite);void 0!==g.vertexColors&&("face"==g.vertexColors?l.vertexColors=THREE.FaceColors:g.vertexColors&&(l.vertexColors=THREE.VertexColors));g.colorDiffuse?l.color=m(g.colorDiffuse):g.DbgColor&&(l.color=g.DbgColor);g.colorSpecular&&(l.specular=m(g.colorSpecular));g.colorAmbient&&(l.ambient=m(g.colorAmbient));g.transparency&&
(l.opacity=g.transparency);g.specularCoef&&(l.shininess=g.specularCoef);void 0!==g.visible&&(l.visible=g.visible);void 0!==g.flipSided&&(l.side=THREE.BackSide);void 0!==g.doubleSided&&(l.side=THREE.DoubleSide);void 0!==g.wireframe&&(l.wireframe=g.wireframe);g.mapDiffuse&&j(l,"map",g.mapDiffuse,g.mapDiffuseRepeat,g.mapDiffuseOffset,g.mapDiffuseWrap);g.mapLight&&j(l,"lightMap",g.mapLight,g.mapLightRepeat,g.mapLightOffset,g.mapLightWrap);g.mapBump&&j(l,"bumpMap",g.mapBump,g.mapBumpRepeat,g.mapBumpOffset,
g.mapBumpWrap);g.mapNormal&&j(l,"normalMap",g.mapNormal,g.mapNormalRepeat,g.mapNormalOffset,g.mapNormalWrap);g.mapSpecular&&j(l,"specularMap",g.mapSpecular,g.mapSpecularRepeat,g.mapSpecularOffset,g.mapSpecularWrap);g.mapNormal?(j=THREE.ShaderUtils.lib.normal,m=THREE.UniformsUtils.clone(j.uniforms),m.tNormal.value=l.normalMap,g.mapNormalFactor&&m.uNormalScale.value.set(g.mapNormalFactor,g.mapNormalFactor),l.map&&(m.tDiffuse.value=l.map,m.enableDiffuse.value=!0),l.specularMap&&(m.tSpecular.value=l.specularMap,
m.enableSpecular.value=!0),l.lightMap&&(m.tAO.value=l.lightMap,m.enableAO.value=!0),m.uDiffuseColor.value.setHex(l.color),m.uSpecularColor.value.setHex(l.specular),m.uAmbientColor.value.setHex(l.ambient),m.uShininess.value=l.shininess,void 0!==l.opacity&&(m.uOpacity.value=l.opacity),l=new THREE.ShaderMaterial({fragmentShader:j.fragmentShader,vertexShader:j.vertexShader,uniforms:m,lights:!0,fog:!0})):l=new THREE[n](l);void 0!==g.DbgName&&(l.name=g.DbgName);d.materials[f]=l}}var g=a.faces,o=a.vertices,
186 187 188 189
l=a.normals,j=a.colors,m=0;if(a.uvs)for(f=0;f<a.uvs.length;f++)a.uvs[f].length&&m++;for(f=0;f<m;f++)d.faceUvs[f]=[],d.faceVertexUvs[f]=[];n=0;for(p=o.length;n<p;){var q=new THREE.Vector3;q.x=o[n++]*e;q.y=o[n++]*e;q.z=o[n++]*e;d.vertices.push(q)}n=0;for(p=g.length;n<p;){var s=g[n++],r=s&2,f=s&4,A=s&8,u=s&16,o=s&32,t=s&64,q=s&128;if(s&1){s=new THREE.Face4;s.a=g[n++];s.b=g[n++];s.c=g[n++];s.d=g[n++];var F=4}else s=new THREE.Face3,s.a=g[n++],s.b=g[n++],s.c=g[n++],F=3;r&&(r=g[n++],s.materialIndex=r);var z=
d.faces.length;if(f)for(f=0;f<m;f++){var w=a.uvs[f],r=g[n++],v=w[2*r],r=w[2*r+1];d.faceUvs[f][z]=new THREE.UV(v,r)}if(A)for(f=0;f<m;f++){for(var w=a.uvs[f],A=[],C=0;C<F;C++)r=g[n++],v=w[2*r],r=w[2*r+1],A[C]=new THREE.UV(v,r);d.faceVertexUvs[f][z]=A}u&&(u=3*g[n++],r=new THREE.Vector3,r.x=l[u++],r.y=l[u++],r.z=l[u],s.normal=r);if(o)for(f=0;f<F;f++)u=3*g[n++],r=new THREE.Vector3,r.x=l[u++],r.y=l[u++],r.z=l[u],s.vertexNormals.push(r);t&&(o=g[n++],s.color=new THREE.Color(j[o]));if(q)for(f=0;f<F;f++)o=
g[n++],s.vertexColors.push(new THREE.Color(j[o]));d.faces.push(s)}if(a.skinWeights){f=0;for(g=a.skinWeights.length;f<g;f+=2)d.skinWeights.push(new THREE.Vector4(a.skinWeights[f],a.skinWeights[f+1],0,0))}if(a.skinIndices){f=0;for(g=a.skinIndices.length;f<g;f+=2)l=0,d.skinIndices.push(new THREE.Vector4(a.skinIndices[f],a.skinIndices[f+1],l,0))}d.bones=a.bones;d.animation=a.animation;if(a.morphTargets){f=0;for(g=a.morphTargets.length;f<g;f++){d.morphTargets[f]={};d.morphTargets[f].name=a.morphTargets[f].name;
d.morphTargets[f].vertices=[];l=d.morphTargets[f].vertices;j=a.morphTargets[f].vertices;r=0;for(m=j.length;r<m;r+=3)q=new THREE.Vector3,q.x=j[r]*e,q.y=j[r+1]*e,q.z=j[r+2]*e,l.push(q)}}if(a.morphColors){f=0;for(g=a.morphColors.length;f<g;f++){d.morphColors[f]={};d.morphColors[f].name=a.morphColors[f].name;d.morphColors[f].colors=[];e=d.morphColors[f].colors;j=a.morphColors[f].colors;l=0;for(m=j.length;l<m;l+=3)n=new THREE.Color(16755200),n.setRGB(j[l],j[l+1],j[l+2]),e.push(n)}}d.computeCentroids();
A
alteredq 已提交
190 191 192
d.computeFaceNormals();return d}};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){};this.geometryHandlerMap={};this.hierarchyHandlerMap={};this.addGeometryHandler("ascii",THREE.JSONLoader);this.addGeometryHandler("binary",THREE.BinaryLoader)};THREE.SceneLoader.prototype.constructor=THREE.SceneLoader;
THREE.SceneLoader.prototype.load=function(a,b){var c=this,d=new XMLHttpRequest;d.onreadystatechange=function(){if(4===d.readyState)if(200===d.status||0===d.status){var e=JSON.parse(d.responseText);c.parse(e,b,a)}else console.error("THREE.SceneLoader: Couldn't load ["+a+"] ["+d.status+"]")};d.open("GET",a,!0);d.send(null)};THREE.SceneLoader.prototype.addGeometryHandler=function(a,b){this.geometryHandlerMap[a]={loaderClass:b}};
THREE.SceneLoader.prototype.addHierarchyHandler=function(a,b){this.hierarchyHandlerMap[a]={loaderClass:b}};
193 194 195 196 197
THREE.SceneLoader.prototype.parse=function(a,b,c){function d(a,b){return"relativeToHTML"==b?a:n+"/"+a}function e(){f(P.scene,Q.objects)}function f(a,b){for(var c in b)if(void 0===P.objects[c]){var e=b[c],g=null;if(e.type&&e.type in m.hierarchyHandlerMap&&void 0===e.loading){var i={},j;for(j in s)"type"!==j&&"url"!==j&&(i[j]=s[j]);D=P.materials[e.materials[0]];e.loading=!0;var l=m.hierarchyHandlerMap[e.type].loaderObject;l.addEventListener?(l.addEventListener("load",h(c,a,D,e)),l.load(d(e.url,Q.urlBaseType))):
l.options?l.load(d(e.url,Q.urlBaseType),h(c,a,D,e)):l.load(d(e.url,Q.urlBaseType),h(c,a,D,e),i)}else if(void 0!==e.geometry){if(C=P.geometries[e.geometry])g=!1,D=P.materials[e.materials[0]],(g=D instanceof THREE.ShaderMaterial)&&C.computeTangents(),u=e.position,t=e.rotation,F=e.quaternion,z=e.scale,r=e.matrix,F=0,0===e.materials.length&&(D=new THREE.MeshFaceMaterial),1<e.materials.length&&(D=new THREE.MeshFaceMaterial),e.skin?g=new THREE.SkinnedMesh(C,D):e.morph?(g=new THREE.MorphAnimMesh(C,D),void 0!==
e.duration&&(g.duration=e.duration),void 0!==e.time&&(g.time=e.time),void 0!==e.mirroredLoop&&(g.mirroredLoop=e.mirroredLoop),D.morphNormals&&C.computeMorphNormals()):g=new THREE.Mesh(C,D),g.name=c,r?(g.matrixAutoUpdate=!1,g.matrix.set(r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8],r[9],r[10],r[11],r[12],r[13],r[14],r[15])):(g.position.set(u[0],u[1],u[2]),F?(g.quaternion.set(F[0],F[1],F[2],F[3]),g.useQuaternion=!0):g.rotation.set(t[0],t[1],t[2]),g.scale.set(z[0],z[1],z[2])),g.visible=e.visible,g.castShadow=
e.castShadow,g.receiveShadow=e.receiveShadow,a.add(g),P.objects[c]=g}else"DirectionalLight"===e.type||"PointLight"===e.type||"AmbientLight"===e.type?(H=void 0!==e.color?e.color:16777215,G=void 0!==e.intensity?e.intensity:1,"DirectionalLight"===e.type?(u=e.direction,K=new THREE.DirectionalLight(H,G),K.position.set(u[0],u[1],u[2]),e.target&&(O.push({object:K,targetName:e.target}),K.target=null)):"PointLight"===e.type?(u=e.position,A=e.distance,K=new THREE.PointLight(H,G,A),K.position.set(u[0],u[1],
u[2])):"AmbientLight"===e.type&&(K=new THREE.AmbientLight(H)),a.add(K),K.name=c,P.lights[c]=K,P.objects[c]=K):"PerspectiveCamera"===e.type||"OrthographicCamera"===e.type?("PerspectiveCamera"===e.type?I=new THREE.PerspectiveCamera(e.fov,e.aspect,e.near,e.far):"OrthographicCamera"===e.type&&(I=new THREE.OrthographicCamera(w.left,w.right,w.top,w.bottom,w.near,w.far)),u=e.position,I.position.set(u[0],u[1],u[2]),a.add(I),I.name=c,P.cameras[c]=I,P.objects[c]=I):(u=e.position,t=e.rotation,F=e.quaternion,
198 199 200 201 202
z=e.scale,F=0,g=new THREE.Object3D,g.name=c,g.position.set(u[0],u[1],u[2]),F?(g.quaternion.set(F[0],F[1],F[2],F[3]),g.useQuaternion=!0):g.rotation.set(t[0],t[1],t[2]),g.scale.set(z[0],z[1],z[2]),g.visible=void 0!==e.visible?e.visible:!1,a.add(g),P.objects[c]=g,P.empties[c]=g);if(g){if(void 0!==e.properties)for(var n in e.properties)g.properties[n]=e.properties[n];void 0!==e.children&&f(g,e.children)}}}function g(a){return function(b){P.geometries[a]=b;e();M-=1;m.onLoadComplete();j()}}function h(a,
b,c,d){return function(f){var f=f.content?f.content:f.dae?f.scene:f,g=d.position,h=d.rotation,i=d.quaternion,l=d.scale;f.position.set(g[0],g[1],g[2]);i?(f.quaternion.set(i[0],i[1],i[2],i[3]),f.useQuaternion=!0):f.rotation.set(h[0],h[1],h[2]);f.scale.set(l[0],l[1],l[2]);c&&f.traverse(function(a){a.material=c});b.add(f);P.objects[a]=f;e();M-=1;m.onLoadComplete();j()}}function i(a){return function(b){P.geometries[a]=b}}function j(){m.callbackProgress({totalModels:R,totalTextures:aa,loadedModels:R-M,
loadedTextures:aa-N},P);m.onLoadProgress();if(0===M&&0===N){for(var a=0;a<O.length;a++){var c=O[a],d=P.objects[c.targetName];d?c.object.target=d:(c.object.target=new THREE.Object3D,P.scene.add(c.object.target));c.object.target.properties.targetInverse=c.object}b(P)}}var m=this,n=THREE.Loader.prototype.extractUrlBase(c),l,p,o,q,s,r,A,u,t,F,z,w,v,C,D,I,L,B,K,H,G,M,N,R,aa,P,O=[],Q=a,U;for(U in this.geometryHandlerMap)a=this.geometryHandlerMap[U].loaderClass,this.geometryHandlerMap[U].loaderObject=new a;
for(U in this.hierarchyHandlerMap)a=this.hierarchyHandlerMap[U].loaderClass,this.hierarchyHandlerMap[U].loaderObject=new a;N=M=0;P={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},empties:{}};if(Q.transform&&(U=Q.transform.position,a=Q.transform.rotation,c=Q.transform.scale,U&&P.scene.position.set(U[0],U[1],U[2]),a&&P.scene.rotation.set(a[0],a[1],a[2]),c&&P.scene.scale.set(c[0],c[1],c[2]),U||a||c))P.scene.updateMatrix(),P.scene.updateMatrixWorld();
U=function(a){return function(){N-=a;j();m.onLoadComplete()}};for(o in Q.fogs)a=Q.fogs[o],"linear"===a.type?L=new THREE.Fog(0,a.near,a.far):"exp2"===a.type&&(L=new THREE.FogExp2(0,a.density)),w=a.color,L.color.setRGB(w[0],w[1],w[2]),P.fogs[o]=L;for(l in Q.geometries)s=Q.geometries[l],s.type in this.geometryHandlerMap&&(M+=1,m.onLoadStart());for(var J in Q.objects)o=Q.objects[J],o.type&&o.type in this.hierarchyHandlerMap&&(M+=1,m.onLoadStart());R=M;for(l in Q.geometries)if(s=Q.geometries[l],"cube"===
203 204
s.type)C=new THREE.CubeGeometry(s.width,s.height,s.depth,s.widthSegments,s.heightSegments,s.depthSegments,null,s.flipped,s.sides),P.geometries[l]=C;else if("plane"===s.type)C=new THREE.PlaneGeometry(s.width,s.height,s.widthSegments,s.heightSegments),P.geometries[l]=C;else if("sphere"===s.type)C=new THREE.SphereGeometry(s.radius,s.widthSegments,s.heightSegments),P.geometries[l]=C;else if("cylinder"===s.type)C=new THREE.CylinderGeometry(s.topRad,s.botRad,s.height,s.radSegs,s.heightSegs),P.geometries[l]=
C;else if("torus"===s.type)C=new THREE.TorusGeometry(s.radius,s.tube,s.segmentsR,s.segmentsT),P.geometries[l]=C;else if("icosahedron"===s.type)C=new THREE.IcosahedronGeometry(s.radius,s.subdivisions),P.geometries[l]=C;else if(s.type in this.geometryHandlerMap){J={};for(B in s)"type"!==B&&"url"!==B&&(J[B]=s[B]);this.geometryHandlerMap[s.type].loaderObject.load(d(s.url,Q.urlBaseType),g(l),J)}else"embedded"===s.type&&(J=Q.embeds[s.id],J.metadata=Q.metadata,J&&this.geometryHandlerMap.ascii.loaderObject.createModel(J,
205
i(l),""));for(q in Q.textures)if(l=Q.textures[q],l.url instanceof Array){N+=l.url.length;for(B=0;B<l.url.length;B++)m.onLoadStart()}else N+=1,m.onLoadStart();aa=N;for(q in Q.textures){l=Q.textures[q];void 0!==l.mapping&&void 0!==THREE[l.mapping]&&(l.mapping=new THREE[l.mapping]);if(l.url instanceof Array){J=l.url.length;o=[];for(B=0;B<J;B++)o[B]=d(l.url[B],Q.urlBaseType);B=(B=o[0].endsWith(".dds"))?THREE.ImageUtils.loadCompressedTextureCube(o,l.mapping,U(J)):THREE.ImageUtils.loadTextureCube(o,l.mapping,
206 207 208 209 210 211 212
U(J))}else{B=l.url.toLowerCase().endsWith(".dds");J=d(l.url,Q.urlBaseType);o=U(1);B=B?THREE.ImageUtils.loadCompressedTexture(J,l.mapping,o):THREE.ImageUtils.loadTexture(J,l.mapping,o);void 0!==THREE[l.minFilter]&&(B.minFilter=THREE[l.minFilter]);void 0!==THREE[l.magFilter]&&(B.magFilter=THREE[l.magFilter]);l.anisotropy&&(B.anisotropy=l.anisotropy);if(l.repeat&&(B.repeat.set(l.repeat[0],l.repeat[1]),1!==l.repeat[0]&&(B.wrapS=THREE.RepeatWrapping),1!==l.repeat[1]))B.wrapT=THREE.RepeatWrapping;l.offset&&
B.offset.set(l.offset[0],l.offset[1]);if(l.wrap&&(J={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping},void 0!==J[l.wrap[0]]&&(B.wrapS=J[l.wrap[0]]),void 0!==J[l.wrap[1]]))B.wrapT=J[l.wrap[1]]}P.textures[q]=B}for(p in Q.materials){r=Q.materials[p];for(v in r.parameters)"envMap"===v||"map"===v||"lightMap"===v||"bumpMap"===v?r.parameters[v]=P.textures[r.parameters[v]]:"shading"===v?r.parameters[v]="flat"===r.parameters[v]?THREE.FlatShading:THREE.SmoothShading:"side"===v?r.parameters[v]=
"double"==r.parameters[v]?THREE.DoubleSide:"back"==r.parameters[v]?THREE.BackSide:THREE.FrontSide:"blending"===v?r.parameters[v]=r.parameters[v]in THREE?THREE[r.parameters[v]]:THREE.NormalBlending:"combine"===v?r.parameters[v]="MixOperation"==r.parameters[v]?THREE.MixOperation:THREE.MultiplyOperation:"vertexColors"===v?"face"==r.parameters[v]?r.parameters[v]=THREE.FaceColors:r.parameters[v]&&(r.parameters[v]=THREE.VertexColors):"wrapRGB"===v&&(q=r.parameters[v],r.parameters[v]=new THREE.Vector3(q[0],
q[1],q[2]));void 0!==r.parameters.opacity&&1>r.parameters.opacity&&(r.parameters.transparent=!0);r.parameters.normalMap?(q=THREE.ShaderUtils.lib.normal,U=THREE.UniformsUtils.clone(q.uniforms),l=r.parameters.color,B=r.parameters.specular,J=r.parameters.ambient,o=r.parameters.shininess,U.tNormal.value=P.textures[r.parameters.normalMap],r.parameters.normalScale&&U.uNormalScale.value.set(r.parameters.normalScale[0],r.parameters.normalScale[1]),r.parameters.map&&(U.tDiffuse.value=r.parameters.map,U.enableDiffuse.value=
!0),r.parameters.envMap&&(U.tCube.value=r.parameters.envMap,U.enableReflection.value=!0,U.uReflectivity.value=r.parameters.reflectivity),r.parameters.lightMap&&(U.tAO.value=r.parameters.lightMap,U.enableAO.value=!0),r.parameters.specularMap&&(U.tSpecular.value=P.textures[r.parameters.specularMap],U.enableSpecular.value=!0),r.parameters.displacementMap&&(U.tDisplacement.value=P.textures[r.parameters.displacementMap],U.enableDisplacement.value=!0,U.uDisplacementBias.value=r.parameters.displacementBias,
U.uDisplacementScale.value=r.parameters.displacementScale),U.uDiffuseColor.value.setHex(l),U.uSpecularColor.value.setHex(B),U.uAmbientColor.value.setHex(J),U.uShininess.value=o,r.parameters.opacity&&(U.uOpacity.value=r.parameters.opacity),D=new THREE.ShaderMaterial({fragmentShader:q.fragmentShader,vertexShader:q.vertexShader,uniforms:U,lights:!0,fog:!0})):D=new THREE[r.type](r.parameters);P.materials[p]=D}e();P.cameras&&Q.defaults.camera&&(P.currentCamera=P.cameras[Q.defaults.camera]);P.fogs&&Q.defaults.fog&&
(P.scene.fog=P.fogs[Q.defaults.fog]);w=Q.defaults.bgcolor;P.bgColor=new THREE.Color;P.bgColor.setRGB(w[0],w[1],w[2]);P.bgColorAlpha=Q.defaults.bgalpha;m.callbackSync(P);j()};THREE.TextureLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null};
213
THREE.TextureLoader.prototype={constructor:THREE.TextureLoader,load:function(a){var b=this,c=new Image;c.addEventListener("load",function(){var a=new THREE.Texture(c);a.needsUpdate=!0;b.dispatchEvent({type:"load",content:a})},!1);c.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},!1);b.crossOrigin&&(c.crossOrigin=b.crossOrigin);c.src=a}};
A
alteredq 已提交
214 215 216 217
THREE.Material=function(){THREE.MaterialLibrary.push(this);this.id=THREE.MaterialIdCount++;this.name="";this.side=THREE.FrontSide;this.opacity=1;this.transparent=!1;this.blending=THREE.NormalBlending;this.blendSrc=THREE.SrcAlphaFactor;this.blendDst=THREE.OneMinusSrcAlphaFactor;this.blendEquation=THREE.AddEquation;this.depthWrite=this.depthTest=!0;this.polygonOffset=!1;this.alphaTest=this.polygonOffsetUnits=this.polygonOffsetFactor=0;this.overdraw=!1;this.needsUpdate=this.visible=!0};
THREE.Material.prototype.setValues=function(a){if(void 0!==a)for(var b in a){var c=a[b];if(void 0===c)console.warn("THREE.Material: '"+b+"' parameter is undefined.");else if(b in this){var d=this[b];d instanceof THREE.Color&&c instanceof THREE.Color?d.copy(c):d instanceof THREE.Color&&"number"===typeof c?d.setHex(c):d instanceof THREE.Vector3&&c instanceof THREE.Vector3?d.copy(c):this[b]=c}}};
THREE.Material.prototype.clone=function(a){void 0===a&&(a=new THREE.Material);a.name=this.name;a.side=this.side;a.opacity=this.opacity;a.transparent=this.transparent;a.blending=this.blending;a.blendSrc=this.blendSrc;a.blendDst=this.blendDst;a.blendEquation=this.blendEquation;a.depthTest=this.depthTest;a.depthWrite=this.depthWrite;a.polygonOffset=this.polygonOffset;a.polygonOffsetFactor=this.polygonOffsetFactor;a.polygonOffsetUnits=this.polygonOffsetUnits;a.alphaTest=this.alphaTest;a.overdraw=this.overdraw;
a.visible=this.visible;return a};THREE.Material.prototype.deallocate=function(){var a=THREE.MaterialLibrary.indexOf(this);-1!==a&&THREE.MaterialLibrary.splice(a,1)};THREE.MaterialIdCount=0;THREE.MaterialLibrary=[];THREE.LineBasicMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=!1;this.fog=!0;this.setValues(a)};THREE.LineBasicMaterial.prototype=Object.create(THREE.Material.prototype);
218 219
THREE.LineBasicMaterial.prototype.clone=function(){var a=new THREE.LineBasicMaterial;THREE.Material.prototype.clone.call(this,a);a.color.copy(this.color);a.linewidth=this.linewidth;a.linecap=this.linecap;a.linejoin=this.linejoin;a.vertexColors=this.vertexColors;a.fog=this.fog;return a};THREE.LineDashedMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.scale=this.linewidth=1;this.dashSize=3;this.gapSize=1;this.vertexColors=!1;this.fog=!0;this.setValues(a)};
THREE.LineDashedMaterial.prototype=Object.create(THREE.Material.prototype);THREE.LineDashedMaterial.prototype.clone=function(){var a=new THREE.LineDashedMaterial;THREE.Material.prototype.clone.call(this,a);a.color.copy(this.color);a.linewidth=this.linewidth;a.scale=this.scale;a.dashSize=this.dashSize;a.gapSize=this.gapSize;a.vertexColors=this.vertexColors;a.fog=this.fog;return a};
A
alteredq 已提交
220 221 222 223 224 225 226 227
THREE.MeshBasicMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.envMap=this.specularMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=THREE.NoColors;this.morphTargets=this.skinning=!1;this.setValues(a)};
THREE.MeshBasicMaterial.prototype=Object.create(THREE.Material.prototype);
THREE.MeshBasicMaterial.prototype.clone=function(){var a=new THREE.MeshBasicMaterial;THREE.Material.prototype.clone.call(this,a);a.color.copy(this.color);a.map=this.map;a.lightMap=this.lightMap;a.specularMap=this.specularMap;a.envMap=this.envMap;a.combine=this.combine;a.reflectivity=this.reflectivity;a.refractionRatio=this.refractionRatio;a.fog=this.fog;a.shading=this.shading;a.wireframe=this.wireframe;a.wireframeLinewidth=this.wireframeLinewidth;a.wireframeLinecap=this.wireframeLinecap;a.wireframeLinejoin=
this.wireframeLinejoin;a.vertexColors=this.vertexColors;a.skinning=this.skinning;a.morphTargets=this.morphTargets;return a};
THREE.MeshLambertMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(16777215);this.emissive=new THREE.Color(0);this.wrapAround=!1;this.wrapRGB=new THREE.Vector3(1,1,1);this.envMap=this.specularMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap=
"round";this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)};THREE.MeshLambertMaterial.prototype=Object.create(THREE.Material.prototype);
THREE.MeshLambertMaterial.prototype.clone=function(){var a=new THREE.MeshLambertMaterial;THREE.Material.prototype.clone.call(this,a);a.color.copy(this.color);a.ambient.copy(this.ambient);a.emissive.copy(this.emissive);a.wrapAround=this.wrapAround;a.wrapRGB.copy(this.wrapRGB);a.map=this.map;a.lightMap=this.lightMap;a.specularMap=this.specularMap;a.envMap=this.envMap;a.combine=this.combine;a.reflectivity=this.reflectivity;a.refractionRatio=this.refractionRatio;a.fog=this.fog;a.shading=this.shading;
a.wireframe=this.wireframe;a.wireframeLinewidth=this.wireframeLinewidth;a.wireframeLinecap=this.wireframeLinecap;a.wireframeLinejoin=this.wireframeLinejoin;a.vertexColors=this.vertexColors;a.skinning=this.skinning;a.morphTargets=this.morphTargets;a.morphNormals=this.morphNormals;return a};
228 229
THREE.MeshPhongMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(16777215);this.emissive=new THREE.Color(0);this.specular=new THREE.Color(1118481);this.shininess=30;this.metal=!1;this.perPixel=!0;this.wrapAround=!1;this.wrapRGB=new THREE.Vector3(1,1,1);this.bumpMap=this.lightMap=this.map=null;this.bumpScale=1;this.normalMap=null;this.normalScale=new THREE.Vector2(1,1);this.envMap=this.specularMap=null;this.combine=THREE.MultiplyOperation;
this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)};THREE.MeshPhongMaterial.prototype=Object.create(THREE.Material.prototype);
A
alteredq 已提交
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
THREE.MeshPhongMaterial.prototype.clone=function(){var a=new THREE.MeshPhongMaterial;THREE.Material.prototype.clone.call(this,a);a.color.copy(this.color);a.ambient.copy(this.ambient);a.emissive.copy(this.emissive);a.specular.copy(this.specular);a.shininess=this.shininess;a.metal=this.metal;a.perPixel=this.perPixel;a.wrapAround=this.wrapAround;a.wrapRGB.copy(this.wrapRGB);a.map=this.map;a.lightMap=this.lightMap;a.bumpMap=this.bumpMap;a.bumpScale=this.bumpScale;a.normalMap=this.normalMap;a.normalScale.copy(this.normalScale);
a.specularMap=this.specularMap;a.envMap=this.envMap;a.combine=this.combine;a.reflectivity=this.reflectivity;a.refractionRatio=this.refractionRatio;a.fog=this.fog;a.shading=this.shading;a.wireframe=this.wireframe;a.wireframeLinewidth=this.wireframeLinewidth;a.wireframeLinecap=this.wireframeLinecap;a.wireframeLinejoin=this.wireframeLinejoin;a.vertexColors=this.vertexColors;a.skinning=this.skinning;a.morphTargets=this.morphTargets;a.morphNormals=this.morphNormals;return a};
THREE.MeshDepthMaterial=function(a){THREE.Material.call(this);this.wireframe=!1;this.wireframeLinewidth=1;this.setValues(a)};THREE.MeshDepthMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshDepthMaterial.prototype.clone=function(){var a=new THREE.LineBasicMaterial;THREE.Material.prototype.clone.call(this,a);a.wireframe=this.wireframe;a.wireframeLinewidth=this.wireframeLinewidth;return a};
THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);this.shading=THREE.FlatShading;this.wireframe=!1;this.wireframeLinewidth=1;this.setValues(a)};THREE.MeshNormalMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshNormalMaterial.prototype.clone=function(){var a=new THREE.MeshNormalMaterial;THREE.Material.prototype.clone.call(this,a);a.shading=this.shading;a.wireframe=this.wireframe;a.wireframeLinewidth=this.wireframeLinewidth;return a};THREE.MeshFaceMaterial=function(){};
THREE.MeshFaceMaterial.prototype.clone=function(){return new THREE.MeshFaceMaterial};THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.map=null;this.size=1;this.sizeAttenuation=!0;this.vertexColors=!1;this.fog=!0;this.setValues(a)};THREE.ParticleBasicMaterial.prototype=Object.create(THREE.Material.prototype);
THREE.ParticleBasicMaterial.prototype.clone=function(){var a=new THREE.ParticleBasicMaterial;THREE.Material.prototype.clone.call(this,a);a.color.copy(this.color);a.map=this.map;a.size=this.size;a.sizeAttenuation=this.sizeAttenuation;a.vertexColors=this.vertexColors;a.fog=this.fog;return a};THREE.ParticleCanvasMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.program=function(){};this.setValues(a)};THREE.ParticleCanvasMaterial.prototype=Object.create(THREE.Material.prototype);
THREE.ParticleCanvasMaterial.prototype.clone=function(){var a=new THREE.ParticleCanvasMaterial;THREE.Material.prototype.clone.call(this,a);a.color.copy(this.color);a.program=this.program;return a};THREE.ParticleDOMMaterial=function(a){this.element=a};THREE.ParticleDOMMaterial.prototype.clone=function(){return new THREE.ParticleDOMMaterial(this.element)};
THREE.ShaderMaterial=function(a){THREE.Material.call(this);this.vertexShader=this.fragmentShader="void main() {}";this.uniforms={};this.defines={};this.attributes=null;this.shading=THREE.SmoothShading;this.wireframe=!1;this.wireframeLinewidth=1;this.lights=this.fog=!1;this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)};THREE.ShaderMaterial.prototype=Object.create(THREE.Material.prototype);
THREE.ShaderMaterial.prototype.clone=function(){var a=new THREE.ShaderMaterial;THREE.Material.prototype.clone.call(this,a);a.fragmentShader=this.fragmentShader;a.vertexShader=this.vertexShader;a.uniforms=THREE.UniformsUtils.clone(this.uniforms);a.attributes=this.attributes;a.defines=this.defines;a.shading=this.shading;a.wireframe=this.wireframe;a.wireframeLinewidth=this.wireframeLinewidth;a.fog=this.fog;a.lights=this.lights;a.vertexColors=this.vertexColors;a.skinning=this.skinning;a.morphTargets=
this.morphTargets;a.morphNormals=this.morphNormals;return a};
THREE.Texture=function(a,b,c,d,e,f,g,h,i){THREE.TextureLibrary.push(this);this.id=THREE.TextureIdCount++;this.name="";this.image=a;this.mapping=void 0!==b?b:new THREE.UVMapping;this.wrapS=void 0!==c?c:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==d?d:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==e?e:THREE.LinearFilter;this.minFilter=void 0!==f?f:THREE.LinearMipMapLinearFilter;this.anisotropy=void 0!==i?i:1;this.format=void 0!==g?g:THREE.RGBAFormat;this.type=void 0!==h?h:THREE.UnsignedByteType;
this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.generateMipmaps=!0;this.premultiplyAlpha=!1;this.flipY=!0;this.needsUpdate=!1;this.onUpdate=null};
THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture;a.image=this.image;a.mapping=this.mapping;a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.anisotropy=this.anisotropy;a.format=this.format;a.type=this.type;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.generateMipmaps=this.generateMipmaps;a.premultiplyAlpha=this.premultiplyAlpha;a.flipY=this.flipY;return a},deallocate:function(){var a=THREE.TextureLibrary.indexOf(this);
-1!==a&&THREE.TextureLibrary.splice(a,1)}};THREE.TextureIdCount=0;THREE.TextureLibrary=[];THREE.CompressedTexture=function(a,b,c,d,e,f,g,h,i,j){THREE.Texture.call(this,null,f,g,h,i,j,d,e);this.image={width:b,height:c};this.mipmaps=a};THREE.CompressedTexture.prototype=Object.create(THREE.Texture.prototype);
THREE.CompressedTexture.prototype.clone=function(){var a=new THREE.CompressedTexture;a.image=this.image;a.mipmaps=this.mipmaps;a.format=this.format;a.type=this.type;a.mapping=this.mapping;a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.anisotropy=this.anisotropy;a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};THREE.DataTexture=function(a,b,c,d,e,f,g,h,i,j){THREE.Texture.call(this,null,f,g,h,i,j,d,e);this.image={data:a,width:b,height:c}};
THREE.DataTexture.prototype=Object.create(THREE.Texture.prototype);THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.image.data,this.image.width,this.image.height,this.format,this.type,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a};THREE.Particle.prototype=Object.create(THREE.Object3D.prototype);
THREE.Particle.prototype.clone=function(a){void 0===a&&(a=new THREE.Particle(this.material));THREE.Object3D.prototype.clone.call(this,a);return a};THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=void 0!==b?b:new THREE.ParticleBasicMaterial({color:16777215*Math.random()});this.sortParticles=!1;this.geometry&&(null===this.geometry.boundingSphere&&this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius);this.frustumCulled=!1};
THREE.ParticleSystem.prototype=Object.create(THREE.Object3D.prototype);THREE.ParticleSystem.prototype.clone=function(a){void 0===a&&(a=new THREE.ParticleSystem(this.geometry,this.material));a.sortParticles=this.sortParticles;THREE.Object3D.prototype.clone.call(this,a);return a};
THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.material=void 0!==b?b:new THREE.LineBasicMaterial({color:16777215*Math.random()});this.type=void 0!==c?c:THREE.LineStrip;this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere())};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=Object.create(THREE.Object3D.prototype);
THREE.Line.prototype.clone=function(a){void 0===a&&(a=new THREE.Line(this.geometry,this.material,this.type));THREE.Object3D.prototype.clone.call(this,a);return a};
THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=void 0!==b?b:new THREE.MeshBasicMaterial({color:16777215*Math.random(),wireframe:!0});if(this.geometry&&(null===this.geometry.boundingSphere&&this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var c=0;c<this.geometry.morphTargets.length;c++)this.morphTargetInfluences.push(0),
this.morphTargetDictionary[this.geometry.morphTargets[c].name]=c}};THREE.Mesh.prototype=Object.create(THREE.Object3D.prototype);THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(void 0!==this.morphTargetDictionary[a])return this.morphTargetDictionary[a];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0};
THREE.Mesh.prototype.clone=function(a){void 0===a&&(a=new THREE.Mesh(this.geometry,this.material));THREE.Object3D.prototype.clone.call(this,a);return a};THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4};THREE.Bone.prototype=Object.create(THREE.Object3D.prototype);
THREE.Bone.prototype.update=function(a,b){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate)a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0;var c,d=this.children.length;for(c=0;c<d;c++)this.children[c].update(this.skinMatrix,b)};
THREE.SkinnedMesh=function(a,b,c){THREE.Mesh.call(this,a,b);this.useVertexTexture=void 0!==c?c:!0;this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var d,e,f;if(void 0!==this.geometry.bones){for(a=0;a<this.geometry.bones.length;a++)c=this.geometry.bones[a],d=c.pos,e=c.rotq,f=c.scl,b=this.addBone(),b.name=c.name,b.position.set(d[0],d[1],d[2]),b.quaternion.set(e[0],e[1],e[2],e[3]),b.useQuaternion=!0,void 0!==f?b.scale.set(f[0],f[1],f[2]):b.scale.set(1,1,1);for(a=0;a<this.bones.length;a++)c=
this.geometry.bones[a],b=this.bones[a],-1===c.parent?this.add(b):this.bones[c.parent].add(b);a=this.bones.length;this.useVertexTexture?(this.boneTextureHeight=this.boneTextureWidth=a=256<a?64:64<a?32:16<a?16:8,this.boneMatrices=new Float32Array(4*this.boneTextureWidth*this.boneTextureHeight),this.boneTexture=new THREE.DataTexture(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,THREE.RGBAFormat,THREE.FloatType),this.boneTexture.minFilter=THREE.NearestFilter,this.boneTexture.magFilter=
THREE.NearestFilter,this.boneTexture.generateMipmaps=!1,this.boneTexture.flipY=!1):this.boneMatrices=new Float32Array(16*a);this.pose()}};THREE.SkinnedMesh.prototype=Object.create(THREE.Mesh.prototype);THREE.SkinnedMesh.prototype.addBone=function(a){void 0===a&&(a=new THREE.Bone(this));this.bones.push(a);return a};
THREE.SkinnedMesh.prototype.updateMatrixWorld=function(a){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1;for(var a=0,b=this.children.length;a<b;a++){var c=this.children[a];c instanceof THREE.Bone?c.update(this.identityMatrix,!1):c.updateMatrixWorld(!0)}if(void 0==this.boneInverses){this.boneInverses=[];a=0;for(b=this.bones.length;a<
b;a++)c=new THREE.Matrix4,c.getInverse(this.bones[a].skinMatrix),this.boneInverses.push(c)}a=0;for(b=this.bones.length;a<b;a++)THREE.SkinnedMesh.offsetMatrix.multiply(this.bones[a].skinMatrix,this.boneInverses[a]),THREE.SkinnedMesh.offsetMatrix.flattenToArrayOffset(this.boneMatrices,16*a);this.useVertexTexture&&(this.boneTexture.needsUpdate=!0)};
THREE.SkinnedMesh.prototype.pose=function(){this.updateMatrixWorld(!0);for(var a=0;a<this.geometry.skinIndices.length;a++){var b=this.geometry.skinWeights[a],c=1/b.lengthManhattan();Infinity!==c?b.multiplyScalar(c):b.set(1)}};THREE.SkinnedMesh.prototype.clone=function(a){void 0===a&&(a=new THREE.SkinnedMesh(this.geometry,this.material,this.useVertexTexture));THREE.Mesh.prototype.clone.call(this,a);return a};THREE.SkinnedMesh.offsetMatrix=new THREE.Matrix4;
THREE.MorphAnimMesh=function(a,b){THREE.Mesh.call(this,a,b);this.duration=1E3;this.mirroredLoop=!1;this.currentKeyframe=this.lastKeyframe=this.time=0;this.direction=1;this.directionBackwards=!1;this.setFrameRange(0,this.geometry.morphTargets.length-1)};THREE.MorphAnimMesh.prototype=Object.create(THREE.Mesh.prototype);THREE.MorphAnimMesh.prototype.setFrameRange=function(a,b){this.startKeyframe=a;this.endKeyframe=b;this.length=this.endKeyframe-this.startKeyframe+1};
THREE.MorphAnimMesh.prototype.setDirectionForward=function(){this.direction=1;this.directionBackwards=!1};THREE.MorphAnimMesh.prototype.setDirectionBackward=function(){this.direction=-1;this.directionBackwards=!0};
THREE.MorphAnimMesh.prototype.parseAnimations=function(){var a=this.geometry;a.animations||(a.animations={});for(var b,c=a.animations,d=/([a-z]+)(\d+)/,e=0,f=a.morphTargets.length;e<f;e++){var g=a.morphTargets[e].name.match(d);if(g&&1<g.length){g=g[1];c[g]||(c[g]={start:Infinity,end:-Infinity});var h=c[g];e<h.start&&(h.start=e);e>h.end&&(h.end=e);b||(b=g)}}a.firstAnimation=b};
THREE.MorphAnimMesh.prototype.setAnimationLabel=function(a,b,c){this.geometry.animations||(this.geometry.animations={});this.geometry.animations[a]={start:b,end:c}};THREE.MorphAnimMesh.prototype.playAnimation=function(a,b){var c=this.geometry.animations[a];c?(this.setFrameRange(c.start,c.end),this.duration=1E3*((c.end-c.start)/b),this.time=0):console.warn("animation["+a+"] undefined")};
THREE.MorphAnimMesh.prototype.updateAnimation=function(a){var b=this.duration/this.length;this.time+=this.direction*a;if(this.mirroredLoop){if(this.time>this.duration||0>this.time)if(this.direction*=-1,this.time>this.duration&&(this.time=this.duration,this.directionBackwards=!0),0>this.time)this.time=0,this.directionBackwards=!1}else this.time%=this.duration,0>this.time&&(this.time+=this.duration);a=this.startKeyframe+THREE.Math.clamp(Math.floor(this.time/b),0,this.length-1);a!==this.currentKeyframe&&
(this.morphTargetInfluences[this.lastKeyframe]=0,this.morphTargetInfluences[this.currentKeyframe]=1,this.morphTargetInfluences[a]=0,this.lastKeyframe=this.currentKeyframe,this.currentKeyframe=a);b=this.time%b/b;this.directionBackwards&&(b=1-b);this.morphTargetInfluences[this.currentKeyframe]=b;this.morphTargetInfluences[this.lastKeyframe]=1-b};
THREE.MorphAnimMesh.prototype.clone=function(a){void 0===a&&(a=new THREE.MorphAnimMesh(this.geometry,this.material));a.duration=this.duration;a.mirroredLoop=this.mirroredLoop;a.time=this.time;a.lastKeyframe=this.lastKeyframe;a.currentKeyframe=this.currentKeyframe;a.direction=this.direction;a.directionBackwards=this.directionBackwards;THREE.Mesh.prototype.clone.call(this,a);return a};THREE.Ribbon=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b};THREE.Ribbon.prototype=Object.create(THREE.Object3D.prototype);
THREE.Ribbon.prototype.clone=function(a){void 0===a&&(a=new THREE.Ribbon(this.geometry,this.material));THREE.Object3D.prototype.clone.call(this,a);return a};THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=Object.create(THREE.Object3D.prototype);THREE.LOD.prototype.addLevel=function(a,b){void 0===b&&(b=0);for(var b=Math.abs(b),c=0;c<this.LODs.length&&!(b<this.LODs[c].visibleAtDistance);c++);this.LODs.splice(c,0,{visibleAtDistance:b,object3D:a});this.add(a)};
THREE.LOD.prototype.update=function(a){if(1<this.LODs.length){a.matrixWorldInverse.getInverse(a.matrixWorld);a=a.matrixWorldInverse;a=-(a.elements[2]*this.matrixWorld.elements[12]+a.elements[6]*this.matrixWorld.elements[13]+a.elements[10]*this.matrixWorld.elements[14]+a.elements[14]);this.LODs[0].object3D.visible=!0;for(var b=1;b<this.LODs.length;b++)if(a>=this.LODs[b].visibleAtDistance)this.LODs[b-1].object3D.visible=!1,this.LODs[b].object3D.visible=!0;else break;for(;b<this.LODs.length;b++)this.LODs[b].object3D.visible=
!1}};THREE.LOD.prototype.clone=function(){};
270 271 272
THREE.Sprite=function(a){THREE.Object3D.call(this);a=a||{};this.color=void 0!==a.color?new THREE.Color(a.color):new THREE.Color(16777215);this.map=void 0!==a.map?a.map:new THREE.Texture;this.blending=void 0!==a.blending?a.blending:THREE.NormalBlending;this.blendSrc=void 0!==a.blendSrc?a.blendSrc:THREE.SrcAlphaFactor;this.blendDst=void 0!==a.blendDst?a.blendDst:THREE.OneMinusSrcAlphaFactor;this.blendEquation=void 0!==a.blendEquation?a.blendEquation:THREE.AddEquation;this.useScreenCoordinates=void 0!==
a.useScreenCoordinates?a.useScreenCoordinates:!0;this.mergeWith3D=void 0!==a.mergeWith3D?a.mergeWith3D:!this.useScreenCoordinates;this.affectedByDistance=void 0!==a.affectedByDistance?a.affectedByDistance:!this.useScreenCoordinates;this.scaleByViewport=void 0!==a.scaleByViewport?a.scaleByViewport:!this.affectedByDistance;this.alignment=a.alignment instanceof THREE.Vector2?a.alignment:THREE.SpriteAlignment.center.clone();this.fog=void 0!==a.fog?a.fog:!1;this.rotation3d=this.rotation;this.rotation=
0;this.opacity=1;this.uvOffset=new THREE.Vector2(0,0);this.uvScale=new THREE.Vector2(1,1)};THREE.Sprite.prototype=Object.create(THREE.Object3D.prototype);THREE.Sprite.prototype.updateMatrix=function(){this.matrix.setPosition(this.position);this.rotation3d.set(0,0,this.rotation);this.matrix.setRotationFromEuler(this.rotation3d);if(1!==this.scale.x||1!==this.scale.y)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,this.scale.y);this.matrixWorldNeedsUpdate=!0};
A
alteredq 已提交
273 274 275 276 277
THREE.Sprite.prototype.clone=function(a){void 0===a&&(a=new THREE.Sprite({}));a.color.copy(this.color);a.map=this.map;a.blending=this.blending;a.useScreenCoordinates=this.useScreenCoordinates;a.mergeWith3D=this.mergeWith3D;a.affectedByDistance=this.affectedByDistance;a.scaleByViewport=this.scaleByViewport;a.alignment=this.alignment;a.fog=this.fog;a.rotation3d.copy(this.rotation3d);a.rotation=this.rotation;a.opacity=this.opacity;a.uvOffset.copy(this.uvOffset);a.uvScale.copy(this.uvScale);THREE.Object3D.prototype.clone.call(this,
a);return a};THREE.SpriteAlignment={};THREE.SpriteAlignment.topLeft=new THREE.Vector2(1,-1);THREE.SpriteAlignment.topCenter=new THREE.Vector2(0,-1);THREE.SpriteAlignment.topRight=new THREE.Vector2(-1,-1);THREE.SpriteAlignment.centerLeft=new THREE.Vector2(1,0);THREE.SpriteAlignment.center=new THREE.Vector2(0,0);THREE.SpriteAlignment.centerRight=new THREE.Vector2(-1,0);THREE.SpriteAlignment.bottomLeft=new THREE.Vector2(1,1);THREE.SpriteAlignment.bottomCenter=new THREE.Vector2(0,1);
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=Object.create(THREE.Object3D.prototype);
THREE.Scene.prototype.__addObject=function(a){if(a instanceof THREE.Light)-1===this.__lights.indexOf(a)&&this.__lights.push(a),a.target&&void 0===a.target.parent&&this.add(a.target);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])};
A
alteredq 已提交
278
THREE.Fog=function(a,b,c){this.name="";this.color=new THREE.Color(a);this.near=void 0!==b?b:1;this.far=void 0!==c?c:1E3};THREE.Fog.prototype.clone=function(){return new THREE.Fog(this.color.getHex(),this.near,this.far)};THREE.FogExp2=function(a,b){this.name="";this.color=new THREE.Color(a);this.density=void 0!==b?b:2.5E-4};THREE.FogExp2.prototype.clone=function(){return new THREE.FogExp2(this.color.getHex(),this.density)};
279
THREE.CanvasRenderer=function(a){function b(a){A!==a&&(A=q.globalAlpha=a)}function c(a){u!==a&&(a===THREE.NormalBlending?q.globalCompositeOperation="source-over":a===THREE.AdditiveBlending?q.globalCompositeOperation="lighter":a===THREE.SubtractiveBlending&&(q.globalCompositeOperation="darker"),u=a)}function d(a){t!==a&&(t=q.strokeStyle=a)}function e(a){F!==a&&(F=q.fillStyle=a)}console.log("THREE.CanvasRenderer",THREE.REVISION);var a=a||{},f=this,g,h,i,j=new THREE.Projector,m=void 0!==a.canvas?a.canvas:
280
document.createElement("canvas"),n,l,p,o,q=m.getContext("2d"),s=new THREE.Color(0),r=0,A=1,u=0,t=null,F=null,z=null,w=null,v=null,C,D,I,L,B=new THREE.RenderableVertex,K=new THREE.RenderableVertex,H,G,M,N,R,aa,P,O,Q,U,J,qa,S=new THREE.Color,ha=new THREE.Color,Y=new THREE.Color,ba=new THREE.Color,ia=new THREE.Color,Z=new THREE.Color,da=new THREE.Color,Na={},Aa={},Ja,Ta,ta,db,xb,Ua,gb,lb,Ab,Bb,fb=new THREE.Rectangle,va=new THREE.Rectangle,Ha=new THREE.Rectangle,mb=!1,La=new THREE.Color,Za=new THREE.Color,
281 282 283
eb=new THREE.Color,ua=new THREE.Vector3,$a,ab,nb,ja,hb,qb,a=16;$a=document.createElement("canvas");$a.width=$a.height=2;ab=$a.getContext("2d");ab.fillStyle="rgba(0,0,0,1)";ab.fillRect(0,0,2,2);nb=ab.getImageData(0,0,2,2);ja=nb.data;hb=document.createElement("canvas");hb.width=hb.height=a;qb=hb.getContext("2d");qb.translate(-a/2,-a/2);qb.scale(a,a);a--;this.domElement=m;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){n=a;l=b;p=
Math.floor(n/2);o=Math.floor(l/2);m.width=n;m.height=l;fb.set(-p,-o,p,o);va.set(-p,-o,p,o);A=1;u=0;v=w=z=F=t=null};this.setClearColor=function(a,b){s.copy(a);r=void 0!==b?b:1;va.set(-p,-o,p,o)};this.setClearColorHex=function(a,b){s.setHex(a);r=void 0!==b?b:1;va.set(-p,-o,p,o)};this.getMaxAnisotropy=function(){return 0};this.clear=function(){q.setTransform(1,0,0,-1,p,o);!1===va.isEmpty()&&(va.minSelf(fb),va.inflate(2),1>r&&q.clearRect(Math.floor(va.getX()),Math.floor(va.getY()),Math.floor(va.getWidth()),
Math.floor(va.getHeight())),0<r&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(255*s.r)+","+Math.floor(255*s.g)+","+Math.floor(255*s.b)+","+r+")"),q.fillRect(Math.floor(va.getX()),Math.floor(va.getY()),Math.floor(va.getWidth()),Math.floor(va.getHeight()))),va.empty())};this.render=function(a,l){function m(a,b,c){for(var d=0,e=i.length;d<e;d++){var f=i[d],g=f.color;if(f instanceof THREE.DirectionalLight){var h=f.matrixWorld.getPosition().normalize(),k=b.dot(h);0>=k||(k*=f.intensity,c.r+=g.r*k,
284
c.g+=g.g*k,c.b+=g.b*k)}else f instanceof THREE.PointLight&&(h=f.matrixWorld.getPosition(),k=b.dot(ua.sub(h,a).normalize()),0>=k||(k*=0==f.distance?1:1-Math.min(a.distanceTo(h)/f.distance,1),0!=k&&(k*=f.intensity,c.r+=g.r*k,c.g+=g.g*k,c.b+=g.b*k)))}}function n(a,d,e,g,h,k,i,j){f.info.render.vertices+=3;f.info.render.faces++;b(j.opacity);c(j.blending);H=a.positionScreen.x;G=a.positionScreen.y;M=d.positionScreen.x;N=d.positionScreen.y;R=e.positionScreen.x;aa=e.positionScreen.y;r(H,G,M,N,R,aa);(j instanceof
285
THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial)&&null===j.map&&null===j.map?(Z.copy(j.color),da.copy(j.emissive),j.vertexColors===THREE.FaceColors&&(Z.r*=i.color.r,Z.g*=i.color.g,Z.b*=i.color.b),!0===mb)?!1===j.wireframe&&j.shading==THREE.SmoothShading&&3==i.vertexNormalsLength?(ha.r=Y.r=ba.r=La.r,ha.g=Y.g=ba.g=La.g,ha.b=Y.b=ba.b=La.b,m(i.v1.positionWorld,i.vertexNormalsWorld[0],ha),m(i.v2.positionWorld,i.vertexNormalsWorld[1],Y),m(i.v3.positionWorld,i.vertexNormalsWorld[2],ba),ha.r=
286 287 288 289
ha.r*Z.r+da.r,ha.g=ha.g*Z.g+da.g,ha.b=ha.b*Z.b+da.b,Y.r=Y.r*Z.r+da.r,Y.g=Y.g*Z.g+da.g,Y.b=Y.b*Z.b+da.b,ba.r=ba.r*Z.r+da.r,ba.g=ba.g*Z.g+da.g,ba.b=ba.b*Z.b+da.b,ia.r=0.5*(Y.r+ba.r),ia.g=0.5*(Y.g+ba.g),ia.b=0.5*(Y.b+ba.b),ta=wc(ha,Y,ba,ia),la(H,G,M,N,R,aa,0,0,1,0,0,1,ta)):(S.r=La.r,S.g=La.g,S.b=La.b,m(i.centroidWorld,i.normalWorld,S),S.r=S.r*Z.r+da.r,S.g=S.g*Z.g+da.g,S.b=S.b*Z.b+da.b,!0===j.wireframe?t(S,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):u(S)):!0===j.wireframe?t(j.color,j.wireframeLinewidth,
j.wireframeLinecap,j.wireframeLinejoin):u(j.color):j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial?null!==j.map?j.map.mapping instanceof THREE.UVMapping&&(db=i.uvs[0],A(H,G,M,N,R,aa,db[g].u,db[g].v,db[h].u,db[h].v,db[k].u,db[k].v,j.map)):null!==j.envMap?j.envMap.mapping instanceof THREE.SphericalReflectionMapping&&(a=l.matrixWorldInverse,ua.copy(i.vertexNormalsWorld[g]),xb=0.5*(ua.x*a.elements[0]+ua.y*a.elements[4]+ua.z*a.elements[8])+
0.5,Ua=0.5*(ua.x*a.elements[1]+ua.y*a.elements[5]+ua.z*a.elements[9])+0.5,ua.copy(i.vertexNormalsWorld[h]),gb=0.5*(ua.x*a.elements[0]+ua.y*a.elements[4]+ua.z*a.elements[8])+0.5,lb=0.5*(ua.x*a.elements[1]+ua.y*a.elements[5]+ua.z*a.elements[9])+0.5,ua.copy(i.vertexNormalsWorld[k]),Ab=0.5*(ua.x*a.elements[0]+ua.y*a.elements[4]+ua.z*a.elements[8])+0.5,Bb=0.5*(ua.x*a.elements[1]+ua.y*a.elements[5]+ua.z*a.elements[9])+0.5,A(H,G,M,N,R,aa,xb,Ua,gb,lb,Ab,Bb,j.envMap)):(S.copy(j.color),j.vertexColors===THREE.FaceColors&&
(S.r*=i.color.r,S.g*=i.color.g,S.b*=i.color.b),!0===j.wireframe?t(S,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):u(S)):j instanceof THREE.MeshDepthMaterial?(Ja=l.near,Ta=l.far,ha.r=ha.g=ha.b=1-Cb(a.positionScreen.z,Ja,Ta),Y.r=Y.g=Y.b=1-Cb(d.positionScreen.z,Ja,Ta),ba.r=ba.g=ba.b=1-Cb(e.positionScreen.z,Ja,Ta),ia.r=0.5*(Y.r+ba.r),ia.g=0.5*(Y.g+ba.g),ia.b=0.5*(Y.b+ba.b),ta=wc(ha,Y,ba,ia),la(H,G,M,N,R,aa,0,0,1,0,0,1,ta)):j instanceof THREE.MeshNormalMaterial&&(S.r=gc(i.normalWorld.x),
290
S.g=gc(i.normalWorld.y),S.b=gc(i.normalWorld.z),!0===j.wireframe?t(S,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):u(S))}function r(a,b,c,d,e,f){q.beginPath();q.moveTo(a,b);q.lineTo(c,d);q.lineTo(e,f);q.closePath()}function s(a,b,c,d,e,f,g,h){q.beginPath();q.moveTo(a,b);q.lineTo(c,d);q.lineTo(e,f);q.lineTo(g,h);q.closePath()}function t(a,b,c,e){z!==b&&(z=q.lineWidth=b);w!==c&&(w=q.lineCap=c);v!==e&&(v=q.lineJoin=e);d(a.getContextStyle());q.stroke();Ha.inflate(2*b)}function u(a){e(a.getContextStyle());
291 292 293 294 295 296 297 298
q.fill()}function A(a,b,c,d,f,g,h,k,i,j,l,m,la){if(!(la instanceof THREE.DataTexture||void 0===la.image||0==la.image.width)){if(!0===la.needsUpdate){var n=la.wrapS==THREE.RepeatWrapping,o=la.wrapT==THREE.RepeatWrapping;Na[la.id]=q.createPattern(la.image,!0===n&&!0===o?"repeat":!0===n&&!1===o?"repeat-x":!1===n&&!0===o?"repeat-y":"no-repeat");la.needsUpdate=!1}void 0===Na[la.id]?e("rgba(0,0,0,1)"):e(Na[la.id]);var n=la.offset.x/la.repeat.x,o=la.offset.y/la.repeat.y,p=la.image.width*la.repeat.x,Cb=la.image.height*
la.repeat.y,h=(h+n)*p,k=(1-k+o)*Cb,c=c-a,d=d-b,f=f-a,g=g-b,i=(i+n)*p-h,j=(1-j+o)*Cb-k,l=(l+n)*p-h,m=(1-m+o)*Cb-k,n=i*m-l*j;0===n?(void 0===Aa[la.id]&&(b=document.createElement("canvas"),b.width=la.image.width,b.height=la.image.height,b=b.getContext("2d"),b.drawImage(la.image,0,0),Aa[la.id]=b.getImageData(0,0,la.image.width,la.image.height).data),b=Aa[la.id],h=4*(Math.floor(h)+Math.floor(k)*la.image.width),S.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255),u(S)):(n=1/n,la=(m*c-j*f)*n,j=(m*d-j*g)*n,c=(i*f-l*
c)*n,d=(i*g-l*d)*n,a=a-la*h-c*k,h=b-j*h-d*k,q.save(),q.transform(la,j,c,d,a,h),q.fill(),q.restore())}}function la(a,b,c,d,e,f,g,h,k,i,j,l,m){var la,n;la=m.width-1;n=m.height-1;g*=la;h*=n;c-=a;d-=b;e-=a;f-=b;k=k*la-g;i=i*n-h;j=j*la-g;l=l*n-h;n=1/(k*l-j*i);la=(l*c-i*e)*n;i=(l*d-i*f)*n;c=(k*e-j*c)*n;d=(k*f-j*d)*n;a=a-la*g-c*h;b=b-i*g-d*h;q.save();q.transform(la,i,c,d,a,b);q.clip();q.drawImage(m,0,0);q.restore()}function wc(a,b,c,d){ja[0]=255*a.r|0;ja[1]=255*a.g|0;ja[2]=255*a.b|0;ja[4]=255*b.r|0;ja[5]=
255*b.g|0;ja[6]=255*b.b|0;ja[8]=255*c.r|0;ja[9]=255*c.g|0;ja[10]=255*c.b|0;ja[12]=255*d.r|0;ja[13]=255*d.g|0;ja[14]=255*d.b|0;ab.putImageData(nb,0,0);qb.drawImage($a,0,0);return hb}function Cb(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function gc(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}function Xb(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)}if(!1===l instanceof THREE.Camera)console.error("THREE.CanvasRenderer.render: camera is not an instance of THREE.Camera.");
else{var Yb,xc,ma,ca;!0===this.autoClear?this.clear():q.setTransform(1,0,0,-1,p,o);f.info.render.vertices=0;f.info.render.faces=0;g=j.projectScene(a,l,this.sortObjects,this.sortElements);h=g.elements;i=g.lights;mb=0<i.length;if(!0===mb){La.setRGB(0,0,0);Za.setRGB(0,0,0);eb.setRGB(0,0,0);Yb=0;for(xc=i.length;Yb<xc;Yb++){ca=i[Yb];var na=ca.color;ca instanceof THREE.AmbientLight?(La.r+=na.r,La.g+=na.g,La.b+=na.b):ca instanceof THREE.DirectionalLight?(Za.r+=na.r,Za.g+=na.g,Za.b+=na.b):ca instanceof THREE.PointLight&&
(eb.r+=na.r,eb.g+=na.g,eb.b+=na.b)}}Yb=0;for(xc=h.length;Yb<xc;Yb++)if(ma=h[Yb],ca=ma.material,!(void 0===ca||!1===ca.visible)){Ha.empty();if(ma instanceof THREE.RenderableParticle){C=ma;C.x*=p;C.y*=o;var na=C,bb=ma;b(ca.opacity);c(ca.blending);var F=void 0,zb=void 0,rb=void 0,sb=void 0,hc=ma=void 0,Pc=void 0;ca instanceof THREE.ParticleBasicMaterial?null===ca.map?(rb=bb.object.scale.x,sb=bb.object.scale.y,rb*=bb.scale.x*p,sb*=bb.scale.y*o,Ha.set(na.x-rb,na.y-sb,na.x+rb,na.y+sb),!1!==fb.intersects(Ha)&&
(e(ca.color.getContextStyle()),q.save(),q.translate(na.x,na.y),q.rotate(-bb.rotation),q.scale(rb,sb),q.fillRect(-1,-1,2,2),q.restore())):(ma=ca.map.image,hc=ma.width>>1,Pc=ma.height>>1,rb=bb.scale.x*p,sb=bb.scale.y*o,F=rb*hc,zb=sb*Pc,Ha.set(na.x-F,na.y-zb,na.x+F,na.y+zb),!1!==fb.intersects(Ha)&&(q.save(),q.translate(na.x,na.y),q.rotate(-bb.rotation),q.scale(rb,-sb),q.translate(-hc,-Pc),q.drawImage(ma,0,0),q.restore())):ca instanceof THREE.ParticleCanvasMaterial&&(F=bb.scale.x*p,zb=bb.scale.y*o,Ha.set(na.x-
F,na.y-zb,na.x+F,na.y+zb),!1!==fb.intersects(Ha)&&(d(ca.color.getContextStyle()),e(ca.color.getContextStyle()),q.save(),q.translate(na.x,na.y),q.rotate(-bb.rotation),q.scale(F,zb),ca.program(q),q.restore()))}else if(ma instanceof THREE.RenderableLine){if(C=ma.v1,D=ma.v2,C.positionScreen.x*=p,C.positionScreen.y*=o,D.positionScreen.x*=p,D.positionScreen.y*=o,Ha.addPoint(C.positionScreen.x,C.positionScreen.y),Ha.addPoint(D.positionScreen.x,D.positionScreen.y),!0===fb.intersects(Ha)&&(na=C,bb=D,b(ca.opacity),
299 300 301
c(ca.blending),q.beginPath(),q.moveTo(na.positionScreen.x,na.positionScreen.y),q.lineTo(bb.positionScreen.x,bb.positionScreen.y),ca instanceof THREE.LineBasicMaterial))na=ca.linewidth,z!==na&&(z=q.lineWidth=na),na=ca.linecap,w!==na&&(w=q.lineCap=na),na=ca.linejoin,v!==na&&(v=q.lineJoin=na),d(ca.color.getContextStyle()),q.stroke(),Ha.inflate(2*ca.linewidth)}else if(ma instanceof THREE.RenderableFace3)C=ma.v1,D=ma.v2,I=ma.v3,C.positionScreen.x*=p,C.positionScreen.y*=o,D.positionScreen.x*=p,D.positionScreen.y*=
o,I.positionScreen.x*=p,I.positionScreen.y*=o,!0===ca.overdraw&&(Xb(C.positionScreen,D.positionScreen),Xb(D.positionScreen,I.positionScreen),Xb(I.positionScreen,C.positionScreen)),Ha.add3Points(C.positionScreen.x,C.positionScreen.y,D.positionScreen.x,D.positionScreen.y,I.positionScreen.x,I.positionScreen.y),!0===fb.intersects(Ha)&&n(C,D,I,0,1,2,ma,ca,a);else if(ma instanceof THREE.RenderableFace4&&(C=ma.v1,D=ma.v2,I=ma.v3,L=ma.v4,C.positionScreen.x*=p,C.positionScreen.y*=o,D.positionScreen.x*=p,D.positionScreen.y*=
o,I.positionScreen.x*=p,I.positionScreen.y*=o,L.positionScreen.x*=p,L.positionScreen.y*=o,B.positionScreen.copy(D.positionScreen),K.positionScreen.copy(L.positionScreen),!0===ca.overdraw&&(Xb(C.positionScreen,D.positionScreen),Xb(D.positionScreen,L.positionScreen),Xb(L.positionScreen,C.positionScreen),Xb(I.positionScreen,B.positionScreen),Xb(I.positionScreen,K.positionScreen)),Ha.addPoint(C.positionScreen.x,C.positionScreen.y),Ha.addPoint(D.positionScreen.x,D.positionScreen.y),Ha.addPoint(I.positionScreen.x,
302
I.positionScreen.y),Ha.addPoint(L.positionScreen.x,L.positionScreen.y),!0===fb.intersects(Ha)))(na=C,bb=D,F=I,zb=L,rb=B,sb=K,hc=a,f.info.render.vertices+=4,f.info.render.faces++,b(ca.opacity),c(ca.blending),void 0!==ca.map&&null!==ca.map||void 0!==ca.envMap&&null!==ca.envMap)?(n(na,bb,zb,0,1,3,ma,ca,hc),n(rb,F,sb,1,2,3,ma,ca,hc)):(H=na.positionScreen.x,G=na.positionScreen.y,M=bb.positionScreen.x,N=bb.positionScreen.y,R=F.positionScreen.x,aa=F.positionScreen.y,P=zb.positionScreen.x,O=zb.positionScreen.y,
303
Q=rb.positionScreen.x,U=rb.positionScreen.y,J=sb.positionScreen.x,qa=sb.positionScreen.y,ca instanceof THREE.MeshLambertMaterial||ca instanceof THREE.MeshPhongMaterial)?(Z.copy(ca.color),da.copy(ca.emissive),ca.vertexColors===THREE.FaceColors&&(Z.r*=ma.color.r,Z.g*=ma.color.g,Z.b*=ma.color.b),!0===mb)?!1===ca.wireframe&&ca.shading==THREE.SmoothShading&&4==ma.vertexNormalsLength?(ha.r=Y.r=ba.r=ia.r=La.r,ha.g=Y.g=ba.g=ia.g=La.g,ha.b=Y.b=ba.b=ia.b=La.b,m(ma.v1.positionWorld,ma.vertexNormalsWorld[0],
304 305 306 307
ha),m(ma.v2.positionWorld,ma.vertexNormalsWorld[1],Y),m(ma.v4.positionWorld,ma.vertexNormalsWorld[3],ba),m(ma.v3.positionWorld,ma.vertexNormalsWorld[2],ia),ha.r=ha.r*Z.r+da.r,ha.g=ha.g*Z.g+da.g,ha.b=ha.b*Z.b+da.b,Y.r=Y.r*Z.r+da.r,Y.g=Y.g*Z.g+da.g,Y.b=Y.b*Z.b+da.b,ba.r=ba.r*Z.r+da.r,ba.g=ba.g*Z.g+da.g,ba.b=ba.b*Z.b+da.b,ia.r=ia.r*Z.r+da.r,ia.g=ia.g*Z.g+da.g,ia.b=ia.b*Z.b+da.b,ta=wc(ha,Y,ba,ia),r(H,G,M,N,P,O),la(H,G,M,N,P,O,0,0,1,0,0,1,ta),r(Q,U,R,aa,J,qa),la(Q,U,R,aa,J,qa,1,0,1,1,0,1,ta)):(S.r=La.r,
S.g=La.g,S.b=La.b,m(ma.centroidWorld,ma.normalWorld,S),S.r=S.r*Z.r+da.r,S.g=S.g*Z.g+da.g,S.b=S.b*Z.b+da.b,s(H,G,M,N,R,aa,P,O),!0===ca.wireframe?t(S,ca.wireframeLinewidth,ca.wireframeLinecap,ca.wireframeLinejoin):u(S)):(S.r=Z.r+da.r,S.g=Z.g+da.g,S.b=Z.b+da.b,s(H,G,M,N,R,aa,P,O),!0===ca.wireframe?t(S,ca.wireframeLinewidth,ca.wireframeLinecap,ca.wireframeLinejoin):u(S)):ca instanceof THREE.MeshBasicMaterial?(S.copy(ca.color),ca.vertexColors===THREE.FaceColors&&(S.r*=ma.color.r,S.g*=ma.color.g,S.b*=ma.color.b),
s(H,G,M,N,R,aa,P,O),!0===ca.wireframe?t(S,ca.wireframeLinewidth,ca.wireframeLinecap,ca.wireframeLinejoin):u(S)):ca instanceof THREE.MeshNormalMaterial?(S.r=gc(ma.normalWorld.x),S.g=gc(ma.normalWorld.y),S.b=gc(ma.normalWorld.z),s(H,G,M,N,R,aa,P,O),!0===ca.wireframe?t(S,ca.wireframeLinewidth,ca.wireframeLinecap,ca.wireframeLinejoin):u(S)):ca instanceof THREE.MeshDepthMaterial&&(Ja=l.near,Ta=l.far,ha.r=ha.g=ha.b=1-Cb(na.positionScreen.z,Ja,Ta),Y.r=Y.g=Y.b=1-Cb(bb.positionScreen.z,Ja,Ta),ba.r=ba.g=ba.b=
1-Cb(zb.positionScreen.z,Ja,Ta),ia.r=ia.g=ia.b=1-Cb(F.positionScreen.z,Ja,Ta),ta=wc(ha,Y,ba,ia),r(H,G,M,N,P,O),la(H,G,M,N,P,O,0,0,1,0,0,1,ta),r(Q,U,R,aa,J,qa),la(Q,U,R,aa,J,qa,1,0,1,1,0,1,ta));va.addRectangle(Ha)}q.setTransform(1,0,0,1,0,0)}}};
A
alteredq 已提交
308
THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform float flipEnvMap;\nuniform int combine;\n#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\nuniform bool useRefract;\nuniform float refractionRatio;\n#else\nvarying vec3 vReflect;\n#endif\n#endif",
309
envmap_fragment:"#ifdef USE_ENVMAP\nvec3 reflectVec;\n#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\nvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\nif ( useRefract ) {\nreflectVec = refract( cameraToVertex, normal, refractionRatio );\n} else { \nreflectVec = reflect( cameraToVertex, normal );\n}\n#else\nreflectVec = vReflect;\n#endif\n#ifdef DOUBLE_SIDED\nfloat flipNormal = ( -1.0 + 2.0 * float( gl_FrontFacing ) );\nvec4 cubeColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n#else\nvec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n#endif\n#ifdef GAMMA_INPUT\ncubeColor.xyz *= cubeColor.xyz;\n#endif\nif ( combine == 1 ) {\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularStrength * reflectivity );\n} else if ( combine == 2 ) {\ngl_FragColor.xyz += cubeColor.xyz * specularStrength * reflectivity;\n} else {\ngl_FragColor.xyz = mix( gl_FragColor.xyz, gl_FragColor.xyz * cubeColor.xyz, specularStrength * reflectivity );\n}\n#endif",
A
alteredq 已提交
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
envmap_pars_vertex:"#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP )\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n#ifdef USE_SKINNING\nvec4 mPosition = modelMatrix * skinned;\n#endif\n#if defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )\nvec4 mPosition = modelMatrix * vec4( morphed, 1.0 );\n#endif\n#if ! defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )\nvec4 mPosition = modelMatrix * vec4( position, 1.0 );\n#endif\n#endif",
envmap_vertex:"#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP )\nvec3 nWorld = mat3( modelMatrix[ 0 ].xyz, modelMatrix[ 1 ].xyz, modelMatrix[ 2 ].xyz ) * objectNormal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) );\n#endif",map_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )\nvarying vec2 vUv;\nuniform vec4 offsetRepeat;\n#endif",map_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )\nvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
map_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )\nvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",map_fragment:"#ifdef USE_MAP\n#ifdef GAMMA_INPUT\nvec4 texelColor = texture2D( map, vUv );\ntexelColor.xyz *= texelColor.xyz;\ngl_FragColor = gl_FragColor * texelColor;\n#else\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",
lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\nuniform sampler2D bumpMap;\nuniform float bumpScale;\nvec2 dHdxy_fwd() {\nvec2 dSTdx = dFdx( vUv );\nvec2 dSTdy = dFdy( vUv );\nfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\nfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\nfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\nreturn vec2( dBx, dBy );\n}\nvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\nvec3 vSigmaX = dFdx( surf_pos );\nvec3 vSigmaY = dFdy( surf_pos );\nvec3 vN = surf_norm;\nvec3 R1 = cross( vSigmaY, vN );\nvec3 R2 = cross( vN, vSigmaX );\nfloat fDet = dot( vSigmaX, R1 );\nvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\nreturn normalize( abs( fDet ) * surf_norm - vGrad );\n}\n#endif",
normalmap_pars_fragment:"#ifdef USE_NORMALMAP\nuniform sampler2D normalMap;\nuniform vec2 normalScale;\nvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\nvec3 q0 = dFdx( eye_pos.xyz );\nvec3 q1 = dFdy( eye_pos.xyz );\nvec2 st0 = dFdx( vUv.st );\nvec2 st1 = dFdy( vUv.st );\nvec3 S = normalize(  q0 * st1.t - q1 * st0.t );\nvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\nvec3 N = normalize( surf_norm );\nvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\nmapN.xy = normalScale * mapN.xy;\nmat3 tsn = mat3( S, T, N );\nreturn normalize( tsn * mapN );\n}\n#endif",
specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\nuniform sampler2D specularMap;\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\nvec4 texelSpecular = texture2D( specularMap, vUv );\nspecularStrength = texelSpecular.r;\n#else\nspecularStrength = 1.0;\n#endif",lights_lambert_pars_vertex:"uniform vec3 ambient;\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_HEMI_LIGHTS > 0\nuniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\nuniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\nuniform vec3 hemisphereLightPosition[ MAX_HEMI_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#endif\n#if MAX_SPOT_LIGHTS > 0\nuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\nuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\nuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\nuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\nuniform float spotLightAngle[ MAX_SPOT_LIGHTS ];\nuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif",
lights_lambert_vertex:"vLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\nvLightBack = vec3( 0.0 );\n#endif\ntransformedNormal = normalize( transformedNormal );\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nfloat dotProduct = dot( transformedNormal, dirVector );\nvec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );\n#ifdef DOUBLE_SIDED\nvec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n#ifdef WRAP_AROUND\nvec3 directionalLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n#endif\n#endif\n#ifdef WRAP_AROUND\nvec3 directionalLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\ndirectionalLightWeighting = mix( directionalLightWeighting, directionalLightWeightingHalf, wrapRGB );\n#ifdef DOUBLE_SIDED\ndirectionalLightWeightingBack = mix( directionalLightWeightingBack, directionalLightWeightingHalfBack, wrapRGB );\n#endif\n#endif\nvLightFront += directionalLightColor[ i ] * directionalLightWeighting;\n#ifdef DOUBLE_SIDED\nvLightBack += directionalLightColor[ i ] * directionalLightWeightingBack;\n#endif\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nfloat dotProduct = dot( transformedNormal, lVector );\nvec3 pointLightWeighting = vec3( max( dotProduct, 0.0 ) );\n#ifdef DOUBLE_SIDED\nvec3 pointLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n#ifdef WRAP_AROUND\nvec3 pointLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n#endif\n#endif\n#ifdef WRAP_AROUND\nvec3 pointLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\npointLightWeighting = mix( pointLightWeighting, pointLightWeightingHalf, wrapRGB );\n#ifdef DOUBLE_SIDED\npointLightWeightingBack = mix( pointLightWeightingBack, pointLightWeightingHalfBack, wrapRGB );\n#endif\n#endif\nvLightFront += pointLightColor[ i ] * pointLightWeighting * lDistance;\n#ifdef DOUBLE_SIDED\nvLightBack += pointLightColor[ i ] * pointLightWeightingBack * lDistance;\n#endif\n}\n#endif\n#if MAX_SPOT_LIGHTS > 0\nfor( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nlVector = normalize( lVector );\nfloat spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - mPosition.xyz ) );\nif ( spotEffect > spotLightAngle[ i ] ) {\nspotEffect = pow( spotEffect, spotLightExponent[ i ] );\nfloat lDistance = 1.0;\nif ( spotLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );\nfloat dotProduct = dot( transformedNormal, lVector );\nvec3 spotLightWeighting = vec3( max( dotProduct, 0.0 ) );\n#ifdef DOUBLE_SIDED\nvec3 spotLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n#ifdef WRAP_AROUND\nvec3 spotLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n#endif\n#endif\n#ifdef WRAP_AROUND\nvec3 spotLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\nspotLightWeighting = mix( spotLightWeighting, spotLightWeightingHalf, wrapRGB );\n#ifdef DOUBLE_SIDED\nspotLightWeightingBack = mix( spotLightWeightingBack, spotLightWeightingHalfBack, wrapRGB );\n#endif\n#endif\nvLightFront += spotLightColor[ i ] * spotLightWeighting * lDistance * spotEffect;\n#ifdef DOUBLE_SIDED\nvLightBack += spotLightColor[ i ] * spotLightWeightingBack * lDistance * spotEffect;\n#endif\n}\n}\n#endif\n#if MAX_HEMI_LIGHTS > 0\nfor( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( hemisphereLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nlVector = normalize( lVector );\nfloat dotProduct = dot( transformedNormal, lVector );\nfloat hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\nfloat hemiDiffuseWeightBack = -0.5 * dotProduct + 0.5;\nvLightFront += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\n#ifdef DOUBLE_SIDED\nvLightBack += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeightBack );\n#endif\n}\n#endif\nvLightFront = vLightFront * diffuse + ambient * ambientLightColor + emissive;\n#ifdef DOUBLE_SIDED\nvLightBack = vLightBack * diffuse + ambient * ambientLightColor + emissive;\n#endif",
lights_phong_pars_vertex:"#ifndef PHONG_PER_PIXEL\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#if MAX_SPOT_LIGHTS > 0\nuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\nuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\nvarying vec4 vSpotLight[ MAX_SPOT_LIGHTS ];\n#endif\n#endif\n#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP )\nvarying vec3 vWorldPosition;\n#endif",
lights_phong_vertex:"#ifndef PHONG_PER_PIXEL\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#if MAX_SPOT_LIGHTS > 0\nfor( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( spotLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );\nvSpotLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#endif\n#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP )\nvWorldPosition = mPosition.xyz;\n#endif",
lights_phong_pars_fragment:"uniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_HEMI_LIGHTS > 0\nuniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\nuniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\nuniform vec3 hemisphereLightPosition[ MAX_HEMI_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\n#ifdef PHONG_PER_PIXEL\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#else\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#endif\n#if MAX_SPOT_LIGHTS > 0\nuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\nuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\nuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\nuniform float spotLightAngle[ MAX_SPOT_LIGHTS ];\nuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\n#ifdef PHONG_PER_PIXEL\nuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\n#else\nvarying vec4 vSpotLight[ MAX_SPOT_LIGHTS ];\n#endif\n#endif\n#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP )\nvarying vec3 vWorldPosition;\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",
lights_phong_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#ifdef DOUBLE_SIDED\nnormal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n#endif\n#ifdef USE_NORMALMAP\nnormal = perturbNormal2Arb( -viewPosition, normal );\n#elif defined( USE_BUMPMAP )\nnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse  = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n#ifdef PHONG_PER_PIXEL\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz + vViewPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\n#else\nvec3 lVector = normalize( vPointLight[ i ].xyz );\nfloat lDistance = vPointLight[ i ].w;\n#endif\nfloat dotProduct = dot( normal, lVector );\n#ifdef WRAP_AROUND\nfloat pointDiffuseWeightFull = max( dotProduct, 0.0 );\nfloat pointDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\nvec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n#else\nfloat pointDiffuseWeight = max( dotProduct, 0.0 );\n#endif\npointDiffuse  += diffuse * pointLightColor[ i ] * pointDiffuseWeight * lDistance;\nvec3 pointHalfVector = normalize( lVector + viewPosition );\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointSpecularWeight = specularStrength * max( pow( pointDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, pointHalfVector ), 5.0 );\npointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance * specularNormalization;\n#else\npointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;\n#endif\n}\n#endif\n#if MAX_SPOT_LIGHTS > 0\nvec3 spotDiffuse  = vec3( 0.0 );\nvec3 spotSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\n#ifdef PHONG_PER_PIXEL\nvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz + vViewPosition.xyz;\nfloat lDistance = 1.0;\nif ( spotLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\n#else\nvec3 lVector = normalize( vSpotLight[ i ].xyz );\nfloat lDistance = vSpotLight[ i ].w;\n#endif\nfloat spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );\nif ( spotEffect > spotLightAngle[ i ] ) {\nspotEffect = pow( spotEffect, spotLightExponent[ i ] );\nfloat dotProduct = dot( normal, lVector );\n#ifdef WRAP_AROUND\nfloat spotDiffuseWeightFull = max( dotProduct, 0.0 );\nfloat spotDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\nvec3 spotDiffuseWeight = mix( vec3 ( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );\n#else\nfloat spotDiffuseWeight = max( dotProduct, 0.0 );\n#endif\nspotDiffuse += diffuse * spotLightColor[ i ] * spotDiffuseWeight * lDistance * spotEffect;\nvec3 spotHalfVector = normalize( lVector + viewPosition );\nfloat spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );\nfloat spotSpecularWeight = specularStrength * max( pow( spotDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, spotHalfVector ), 5.0 );\nspotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * lDistance * specularNormalization * spotEffect;\n#else\nspotSpecular += specular * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * lDistance * spotEffect;\n#endif\n}\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse  = vec3( 0.0 );\nvec3 dirSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nfloat dotProduct = dot( normal, dirVector );\n#ifdef WRAP_AROUND\nfloat dirDiffuseWeightFull = max( dotProduct, 0.0 );\nfloat dirDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\nvec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );\n#else\nfloat dirDiffuseWeight = max( dotProduct, 0.0 );\n#endif\ndirDiffuse  += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;\nvec3 dirHalfVector = normalize( dirVector + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirSpecularWeight = specularStrength * max( pow( dirDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( dirVector, dirHalfVector ), 5.0 );\ndirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;\n#else\ndirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n#endif\n}\n#endif\n#if MAX_HEMI_LIGHTS > 0\nvec3 hemiDiffuse  = vec3( 0.0 );\nvec3 hemiSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( hemisphereLightPosition[ i ], 1.0 );\nvec3 lVector = normalize( lPosition.xyz + vViewPosition.xyz );\nfloat dotProduct = dot( normal, lVector );\nfloat hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\nvec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\nhemiDiffuse += diffuse * hemiColor;\nvec3 hemiHalfVectorSky = normalize( lVector + viewPosition );\nfloat hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;\nfloat hemiSpecularWeightSky = specularStrength * max( pow( hemiDotNormalHalfSky, shininess ), 0.0 );\nvec3 lVectorGround = normalize( -lPosition.xyz + vViewPosition.xyz );\nvec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );\nfloat hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;\nfloat hemiSpecularWeightGround = specularStrength * max( pow( hemiDotNormalHalfGround, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat dotProductGround = dot( normal, lVectorGround );\nfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\nvec3 schlickSky = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, hemiHalfVectorSky ), 5.0 );\nvec3 schlickGround = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 5.0 );\nhemiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );\n#else\nhemiSpecular += specular * hemiColor * ( hemiSpecularWeightSky + hemiSpecularWeightGround ) * hemiDiffuseWeight;\n#endif\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_HEMI_LIGHTS > 0\ntotalDiffuse += hemiDiffuse;\ntotalSpecular += hemiSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\n#if MAX_SPOT_LIGHTS > 0\ntotalDiffuse += spotDiffuse;\ntotalSpecular += spotSpecular;\n#endif\n#ifdef METAL\ngl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient + totalSpecular );\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient ) + totalSpecular;\n#endif",
color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n#ifdef GAMMA_INPUT\nvColor = color * color;\n#else\nvColor = color;\n#endif\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n#ifdef BONE_TEXTURE\nuniform sampler2D boneTexture;\nmat4 getBoneMatrix( const in float i ) {\nfloat j = i * 4.0;\nfloat x = mod( j, N_BONE_PIXEL_X );\nfloat y = floor( j / N_BONE_PIXEL_X );\nconst float dx = 1.0 / N_BONE_PIXEL_X;\nconst float dy = 1.0 / N_BONE_PIXEL_Y;\ny = dy * ( y + 0.5 );\nvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\nvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\nvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\nvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\nmat4 bone = mat4( v1, v2, v3, v4 );\nreturn bone;\n}\n#else\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\nmat4 getBoneMatrix( const in float i ) {\nmat4 bone = boneGlobalMatrices[ int(i) ];\nreturn bone;\n}\n#endif\n#endif",
skinbase_vertex:"#ifdef USE_SKINNING\nmat4 boneMatX = getBoneMatrix( skinIndex.x );\nmat4 boneMatY = getBoneMatrix( skinIndex.y );\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n#ifdef USE_MORPHTARGETS\nvec4 skinVertex = vec4( morphed, 1.0 );\n#else\nvec4 skinVertex = vec4( position, 1.0 );\n#endif\nvec4 skinned  = boneMatX * skinVertex * skinWeight.x;\nskinned \t  += boneMatY * skinVertex * skinWeight.y;\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n#ifndef USE_MORPHNORMALS\nuniform float morphTargetInfluences[ 8 ];\n#else\nuniform float morphTargetInfluences[ 4 ];\n#endif\n#endif",
morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n#ifndef USE_MORPHNORMALS\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n#endif\nmorphed += position;\n#endif",
default_vertex:"vec4 mvPosition;\n#ifdef USE_SKINNING\nmvPosition = modelViewMatrix * skinned;\n#endif\n#if !defined( USE_SKINNING ) && defined( USE_MORPHTARGETS )\nmvPosition = modelViewMatrix * vec4( morphed, 1.0 );\n#endif\n#if !defined( USE_SKINNING ) && ! defined( USE_MORPHTARGETS )\nmvPosition = modelViewMatrix * vec4( position, 1.0 );\n#endif\ngl_Position = projectionMatrix * mvPosition;",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\nvec3 morphedNormal = vec3( 0.0 );\nmorphedNormal +=  ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\nmorphedNormal +=  ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\nmorphedNormal +=  ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\nmorphedNormal +=  ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\nmorphedNormal += normal;\n#endif",
skinnormal_vertex:"#ifdef USE_SKINNING\nmat4 skinMatrix = skinWeight.x * boneMatX;\nskinMatrix \t+= skinWeight.y * boneMatY;\n#ifdef USE_MORPHNORMALS\nvec4 skinnedNormal = skinMatrix * vec4( morphedNormal, 0.0 );\n#else\nvec4 skinnedNormal = skinMatrix * vec4( normal, 0.0 );\n#endif\n#endif",defaultnormal_vertex:"vec3 objectNormal;\n#ifdef USE_SKINNING\nobjectNormal = skinnedNormal.xyz;\n#endif\n#if !defined( USE_SKINNING ) && defined( USE_MORPHNORMALS )\nobjectNormal = morphedNormal;\n#endif\n#if !defined( USE_SKINNING ) && ! defined( USE_MORPHNORMALS )\nobjectNormal = normal;\n#endif\n#ifdef FLIP_SIDED\nobjectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;",
shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\nuniform sampler2D shadowMap[ MAX_SHADOWS ];\nuniform vec2 shadowMapSize[ MAX_SHADOWS ];\nuniform float shadowDarkness[ MAX_SHADOWS ];\nuniform float shadowBias[ MAX_SHADOWS ];\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nfloat unpackDepth( const in vec4 rgba_depth ) {\nconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\nfloat depth = dot( rgba_depth, bit_shift );\nreturn depth;\n}\n#endif",shadowmap_fragment:"#ifdef USE_SHADOWMAP\n#ifdef SHADOWMAP_DEBUG\nvec3 frustumColors[3];\nfrustumColors[0] = vec3( 1.0, 0.5, 0.0 );\nfrustumColors[1] = vec3( 0.0, 1.0, 0.8 );\nfrustumColors[2] = vec3( 0.0, 0.5, 1.0 );\n#endif\n#ifdef SHADOWMAP_CASCADE\nint inFrustumCount = 0;\n#endif\nfloat fDepth;\nvec3 shadowColor = vec3( 1.0 );\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\nbool inFrustum = all( inFrustumVec );\n#ifdef SHADOWMAP_CASCADE\ninFrustumCount += int( inFrustum );\nbvec3 frustumTestVec = bvec3( inFrustum, inFrustumCount == 1, shadowCoord.z <= 1.0 );\n#else\nbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n#endif\nbool frustumTest = all( frustumTestVec );\nif ( frustumTest ) {\nshadowCoord.z += shadowBias[ i ];\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nconst float shadowDelta = 1.0 / 9.0;\nfloat xPixelOffset = 1.0 / shadowMapSize[ i ].x;\nfloat yPixelOffset = 1.0 / shadowMapSize[ i ].y;\nfloat dx0 = -1.25 * xPixelOffset;\nfloat dy0 = -1.25 * yPixelOffset;\nfloat dx1 = 1.25 * xPixelOffset;\nfloat dy1 = 1.25 * yPixelOffset;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );\n#endif\n}\n#ifdef SHADOWMAP_DEBUG\n#ifdef SHADOWMAP_CASCADE\nif ( inFrustum && inFrustumCount == 1 ) gl_FragColor.xyz *= frustumColors[ i ];\n#else\nif ( inFrustum ) gl_FragColor.xyz *= frustumColors[ i ];\n#endif\n#endif\n}\n#ifdef GAMMA_OUTPUT\nshadowColor *= shadowColor;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n#endif",
shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * mPosition;\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif",linear_to_gamma_fragment:"#ifdef GAMMA_OUTPUT\ngl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n#endif"};
THREE.UniformsUtils={merge:function(a){var b,c,d,e={};for(b=0;b<a.length;b++)for(c in d=this.clone(a[b]),d)e[c]=d[c];return e},clone:function(a){var b,c,d,e={};for(b in a)for(c in e[b]={},a[b])d=a[b][c],e[b][c]=d instanceof THREE.Color||d instanceof THREE.Vector2||d instanceof THREE.Vector3||d instanceof THREE.Vector4||d instanceof THREE.Matrix4||d instanceof THREE.Texture?d.clone():d instanceof Array?d.slice():d;return e}};
THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:null},offsetRepeat:{type:"v4",value:new THREE.Vector4(0,0,1,1)},lightMap:{type:"t",value:null},specularMap:{type:"t",value:null},envMap:{type:"t",value:null},flipEnvMap:{type:"f",value:-1},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},morphTargetInfluences:{type:"f",value:0}},bump:{bumpMap:{type:"t",
value:null},bumpScale:{type:"f",value:1}},normalmap:{normalMap:{type:"t",value:null},normalScale:{type:"v2",value:new THREE.Vector2(1,1)}},fog:{fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},hemisphereLightPosition:{type:"fv",value:[]},hemisphereLightSkyColor:{type:"fv",
value:[]},hemisphereLightGroundColor:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",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:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",
value:1},scale:{type:"f",value:1},map:{type:"t",value:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},shadowmap:{shadowMap:{type:"tv",value:[]},shadowMapSize:{type:"v2v",value:[]},shadowBias:{type:"fv1",value:[]},shadowDarkness:{type:"fv1",value:[]},shadowMatrix:{type:"m4v",value:[]}}};
THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}"},normal:{uniforms:{opacity:{type:"f",
value:1}},vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalMatrix * normal;\ngl_Position = projectionMatrix * mvPosition;\n}",fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}"},basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.shadowmap]),vertexShader:[THREE.ShaderChunk.map_pars_vertex,
THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.color_vertex,"#ifdef USE_ENVMAP",THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,
"#endif",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,
THREE.ShaderChunk.specularmap_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.specularmap_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,
THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(16777215)},emissive:{type:"c",value:new THREE.Color(0)},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),vertexShader:["#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;\n#endif",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_lambert_pars_vertex,THREE.ShaderChunk.color_pars_vertex,
THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.worldpos_vertex,
THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.lights_lambert_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;\n#endif",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.specularmap_pars_fragment,
"void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.specularmap_fragment,"#ifdef DOUBLE_SIDED\nif ( gl_FrontFacing )\ngl_FragColor.xyz *= vLightFront;\nelse\ngl_FragColor.xyz *= vLightBack;\n#else\ngl_FragColor.xyz *= vLightFront;\n#endif",THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,
THREE.ShaderChunk.fog_fragment,"}"].join("\n")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.bump,THREE.UniformsLib.normalmap,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(16777215)},emissive:{type:"c",value:new THREE.Color(0)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),vertexShader:["#define PHONG\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",
THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_phong_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,
THREE.ShaderChunk.defaultnormal_vertex,"vNormal = transformedNormal;",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.default_vertex,"vViewPosition = -mvPosition.xyz;",THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.lights_phong_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;",
THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_phong_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.bumpmap_pars_fragment,THREE.ShaderChunk.normalmap_pars_fragment,THREE.ShaderChunk.specularmap_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,
THREE.ShaderChunk.specularmap_fragment,THREE.ShaderChunk.lights_phong_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.particle,THREE.UniformsLib.shadowmap]),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,
THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;",THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,
349 350 351 352
THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},dashed:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,{scale:{type:"f",value:1},dashSize:{type:"f",
value:1},totalSize:{type:"f",value:2}}]),vertexShader:["uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;",THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vLineDistance = scale * lineDistance;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;",
THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\nif ( mod( vLineDistance, totalSize ) > dashSize ) {\ndiscard;\n}\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {",THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,
THREE.ShaderChunk.default_vertex,"}"].join("\n"),fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask  = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}"}};
A
alteredq 已提交
353 354 355 356 357 358
THREE.WebGLRenderer=function(a){function b(a){if(a.__webglCustomAttributesList)for(var b in a.__webglCustomAttributesList)k.deleteBuffer(a.__webglCustomAttributesList[b].buffer)}function c(a,b){var c=a.vertices.length,d=b.material;if(d.attributes){void 0===a.__webglCustomAttributesList&&(a.__webglCustomAttributesList=[]);for(var e in d.attributes){var f=d.attributes[e];if(!f.__webglInitialized||f.createUniqueBuffers){f.__webglInitialized=!0;var g=1;"v2"===f.type?g=2:"v3"===f.type?g=3:"v4"===f.type?
g=4:"c"===f.type&&(g=3);f.size=g;f.array=new Float32Array(c*g);f.buffer=k.createBuffer();f.buffer.belongsToAttribute=e;f.needsUpdate=!0}a.__webglCustomAttributesList.push(f)}}}function d(a,b){var c=b.geometry,d=a.faces3,h=a.faces4,i=3*d.length+4*h.length,j=1*d.length+2*h.length,h=3*d.length+4*h.length,d=e(b,a),l=g(d),m=f(d),n=d.vertexColors?d.vertexColors:!1;a.__vertexArray=new Float32Array(3*i);m&&(a.__normalArray=new Float32Array(3*i));c.hasTangents&&(a.__tangentArray=new Float32Array(4*i));n&&
(a.__colorArray=new Float32Array(3*i));if(l){if(0<c.faceUvs.length||0<c.faceVertexUvs.length)a.__uvArray=new Float32Array(2*i);if(1<c.faceUvs.length||1<c.faceVertexUvs.length)a.__uv2Array=new Float32Array(2*i)}b.geometry.skinWeights.length&&b.geometry.skinIndices.length&&(a.__skinIndexArray=new Float32Array(4*i),a.__skinWeightArray=new Float32Array(4*i));a.__faceArray=new Uint16Array(3*j);a.__lineArray=new Uint16Array(2*h);if(a.numMorphTargets){a.__morphTargetsArrays=[];c=0;for(l=a.numMorphTargets;c<
l;c++)a.__morphTargetsArrays.push(new Float32Array(3*i))}if(a.numMorphNormals){a.__morphNormalsArrays=[];c=0;for(l=a.numMorphNormals;c<l;c++)a.__morphNormalsArrays.push(new Float32Array(3*i))}a.__webglFaceCount=3*j;a.__webglLineCount=2*h;if(d.attributes){void 0===a.__webglCustomAttributesList&&(a.__webglCustomAttributesList=[]);for(var o in d.attributes){var j=d.attributes[o],c={},p;for(p in j)c[p]=j[p];if(!c.__webglInitialized||c.createUniqueBuffers)c.__webglInitialized=!0,h=1,"v2"===c.type?h=2:
"v3"===c.type?h=3:"v4"===c.type?h=4:"c"===c.type&&(h=3),c.size=h,c.array=new Float32Array(i*h),c.buffer=k.createBuffer(),c.buffer.belongsToAttribute=o,j.needsUpdate=!0,c.__original=j;a.__webglCustomAttributesList.push(c)}}a.__inittedArrays=!0}function e(a,b){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;if(0<=b.materialIndex)return a.geometry.materials[b.materialIndex]}function f(a){return a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial?
!1:a&&void 0!==a.shading&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function g(a){return a.map||a.lightMap||a.bumpMap||a.normalMap||a.specularMap||a instanceof THREE.ShaderMaterial?!0:!1}function h(a){var b,c,d;for(b in a.attributes)d="index"===b?k.ELEMENT_ARRAY_BUFFER:k.ARRAY_BUFFER,c=a.attributes[b],c.buffer=k.createBuffer(),k.bindBuffer(d,c.buffer),k.bufferData(d,c.array,k.STATIC_DRAW)}function i(a,b,c){var d,e,f,g,h=a.vertices;g=h.length;var i=a.colors,j=i.length,l=
359
a.__vertexArray,m=a.__colorArray,n=a.__sortArray,o=a.verticesNeedUpdate,p=a.colorsNeedUpdate,q=a.__webglCustomAttributesList;if(c.sortParticles){ab.copy($a);ab.multiplySelf(c.matrixWorld);for(d=0;d<g;d++)e=h[d],nb.copy(e),ab.multiplyVector3(nb),n[d]=[nb.z,d];n.sort(function(a,b){return b[0]-a[0]});for(d=0;d<g;d++)e=h[n[d][1]],f=3*d,l[f]=e.x,l[f+1]=e.y,l[f+2]=e.z;for(d=0;d<j;d++)f=3*d,e=i[n[d][1]],m[f]=e.r,m[f+1]=e.g,m[f+2]=e.b;if(q){i=0;for(j=q.length;i<j;i++)if(h=q[i],void 0===h.boundTo||"vertices"===
A
alteredq 已提交
360 361 362 363
h.boundTo)if(f=0,e=h.value.length,1===h.size)for(d=0;d<e;d++)g=n[d][1],h.array[d]=h.value[g];else if(2===h.size)for(d=0;d<e;d++)g=n[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,f+=2;else if(3===h.size)if("c"===h.type)for(d=0;d<e;d++)g=n[d][1],g=h.value[g],h.array[f]=g.r,h.array[f+1]=g.g,h.array[f+2]=g.b,f+=3;else for(d=0;d<e;d++)g=n[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,f+=3;else if(4===h.size)for(d=0;d<e;d++)g=n[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,
h.array[f+2]=g.z,h.array[f+3]=g.w,f+=4}}else{if(o)for(d=0;d<g;d++)e=h[d],f=3*d,l[f]=e.x,l[f+1]=e.y,l[f+2]=e.z;if(p)for(d=0;d<j;d++)e=i[d],f=3*d,m[f]=e.r,m[f+1]=e.g,m[f+2]=e.b;if(q){i=0;for(j=q.length;i<j;i++)if(h=q[i],h.needsUpdate&&(void 0===h.boundTo||"vertices"===h.boundTo))if(e=h.value.length,f=0,1===h.size)for(d=0;d<e;d++)h.array[d]=h.value[d];else if(2===h.size)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,f+=2;else if(3===h.size)if("c"===h.type)for(d=0;d<e;d++)g=h.value[d],h.array[f]=
g.r,h.array[f+1]=g.g,h.array[f+2]=g.b,f+=3;else for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,f+=3;else if(4===h.size)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,h.array[f+3]=g.w,f+=4}}if(o||c.sortParticles)k.bindBuffer(k.ARRAY_BUFFER,a.__webglVertexBuffer),k.bufferData(k.ARRAY_BUFFER,l,b);if(p||c.sortParticles)k.bindBuffer(k.ARRAY_BUFFER,a.__webglColorBuffer),k.bufferData(k.ARRAY_BUFFER,m,b);if(q){i=0;for(j=q.length;i<j;i++)if(h=q[i],
h.needsUpdate||c.sortParticles)k.bindBuffer(k.ARRAY_BUFFER,h.buffer),k.bufferData(k.ARRAY_BUFFER,h.array,b)}}function j(a,b,c){var d=a.attributes,e=d.index,f=d.position,g=d.normal,h=d.uv,i=d.color,d=d.tangent;a.elementsNeedUpdate&&void 0!==e&&(k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,e.buffer),k.bufferData(k.ELEMENT_ARRAY_BUFFER,e.array,b));a.verticesNeedUpdate&&void 0!==f&&(k.bindBuffer(k.ARRAY_BUFFER,f.buffer),k.bufferData(k.ARRAY_BUFFER,f.array,b));a.normalsNeedUpdate&&void 0!==g&&(k.bindBuffer(k.ARRAY_BUFFER,
364
g.buffer),k.bufferData(k.ARRAY_BUFFER,g.array,b));a.uvsNeedUpdate&&void 0!==h&&(k.bindBuffer(k.ARRAY_BUFFER,h.buffer),k.bufferData(k.ARRAY_BUFFER,h.array,b));a.colorsNeedUpdate&&void 0!==i&&(k.bindBuffer(k.ARRAY_BUFFER,i.buffer),k.bufferData(k.ARRAY_BUFFER,i.array,b));a.tangentsNeedUpdate&&void 0!==d&&(k.bindBuffer(k.ARRAY_BUFFER,d.buffer),k.bufferData(k.ARRAY_BUFFER,d.array,b));if(c)for(var j in a.attributes)delete a.attributes[j].array}function m(a,b){return a.z!==b.z?b.z-a.z:b.id-a.id}function n(a,
365 366 367 368 369
b){return b[1]-a[1]}function l(a,b,c){if(a.length)for(var d=0,e=a.length;d<e;d++)Z=ha=null,ba=ia=Ja=Aa=gb=Ua=Ta=-1,hb=!0,a[d].render(b,c,Za,eb),Z=ha=null,ba=ia=Ja=Aa=gb=Ua=Ta=-1,hb=!0}function p(a,b,c,d,e,f,g,h){var k,i,j,l;b?(i=a.length-1,l=b=-1):(i=0,b=a.length,l=1);for(var m=i;m!==b;m+=l)if(k=a[m],k.render){i=k.object;j=k.buffer;if(h)k=h;else{k=k[c];if(!k)continue;g&&J.setBlending(k.blending,k.blendEquation,k.blendSrc,k.blendDst);J.setDepthTest(k.depthTest);J.setDepthWrite(k.depthWrite);C(k.polygonOffset,
k.polygonOffsetFactor,k.polygonOffsetUnits)}J.setMaterialFaces(k);j instanceof THREE.BufferGeometry?J.renderBufferDirect(d,e,f,k,j,i):J.renderBuffer(d,e,f,k,j,i)}}function o(a,b,c,d,e,f,g){for(var h,k,i=0,j=a.length;i<j;i++)if(h=a[i],k=h.object,k.visible){if(g)h=g;else{h=h[b];if(!h)continue;f&&J.setBlending(h.blending,h.blendEquation,h.blendSrc,h.blendDst);J.setDepthTest(h.depthTest);J.setDepthWrite(h.depthWrite);C(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}J.renderImmediateObject(c,
d,e,h,k)}}function q(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function s(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function r(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function A(a,b){for(var c=a.length-1;0<=c;c--)a[c].object===b&&a.splice(c,1)}function u(a,b){for(var c=a.length-1;0<=c;c--)a[c]===b&&a.splice(c,1)}function t(a,b,c,d,e){Na=0;d.needsUpdate&&(d.program&&J.deallocateMaterial(d),J.initMaterial(d,b,c,e),d.needsUpdate=
!1);d.morphTargets&&!e.__webglMorphTargetInfluences&&(e.__webglMorphTargetInfluences=new Float32Array(J.maxMorphTargets));var f=!1,g=d.program,h=g.uniforms,i=d.uniforms;g!==ha&&(k.useProgram(g),ha=g,f=!0);d.id!==ba&&(ba=d.id,f=!0);if(f||a!==Z)k.uniformMatrix4fv(h.projectionMatrix,!1,a._projectionMatrixArray),a!==Z&&(Z=a);if(d.skinning)if(fc&&e.useVertexTexture){if(null!==h.boneTexture){var j=F();k.uniform1i(h.boneTexture,j);J.setTexture(e.boneTexture,j)}}else null!==h.boneGlobalMatrices&&k.uniformMatrix4fv(h.boneGlobalMatrices,
!1,e.boneMatrices);if(f){c&&d.fog&&(i.fogColor.value=c.color,c instanceof THREE.Fog?(i.fogNear.value=c.near,i.fogFar.value=c.far):c instanceof THREE.FogExp2&&(i.fogDensity.value=c.density));if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(hb){for(var l=0,m=0,n=0,o,p,q,r,s=qb,t=s.directional.colors,u=s.directional.positions,z=s.point.colors,A=s.point.positions,C=s.point.distances,D=s.spot.colors,B=s.spot.positions,I=s.spot.distances,S=s.spot.directions,
370 371 372
K=s.spot.angles,O=s.spot.exponents,Y=s.hemi.skyColors,Q=s.hemi.groundColors,N=s.hemi.positions,M=0,P=0,da=0,R=0,c=o=q=q=p=0,f=b.length;c<f;c++)j=b[c],!j.onlyShadow&&j.visible&&(o=j.color,r=j.intensity,p=j.distance,j instanceof THREE.AmbientLight?J.gammaInput?(l+=o.r*o.r,m+=o.g*o.g,n+=o.b*o.b):(l+=o.r,m+=o.g,n+=o.b):j instanceof THREE.DirectionalLight?(p=3*M,J.gammaInput?w(t,p,o,r*r):v(t,p,o,r),ja.copy(j.matrixWorld.getPosition()),ja.subSelf(j.target.matrixWorld.getPosition()),ja.normalize(),u[p]=
ja.x,u[p+1]=ja.y,u[p+2]=ja.z,M+=1):j instanceof THREE.PointLight?(q=3*P,J.gammaInput?w(z,q,o,r*r):v(z,q,o,r),r=j.matrixWorld.getPosition(),A[q]=r.x,A[q+1]=r.y,A[q+2]=r.z,C[P]=p,P+=1):j instanceof THREE.SpotLight?(q=3*da,J.gammaInput?w(D,q,o,r*r):v(D,q,o,r),r=j.matrixWorld.getPosition(),B[q]=r.x,B[q+1]=r.y,B[q+2]=r.z,I[da]=p,ja.copy(r),ja.subSelf(j.target.matrixWorld.getPosition()),ja.normalize(),S[q]=ja.x,S[q+1]=ja.y,S[q+2]=ja.z,K[da]=Math.cos(j.angle),O[da]=j.exponent,da+=1):j instanceof THREE.HemisphereLight&&
(p=j.color,q=j.groundColor,o=3*R,J.gammaInput?(r*=r,w(Y,o,p,r),w(Q,o,q,r)):(v(Y,o,p,r),v(Q,o,q,r)),r=j.matrixWorld.getPosition(),N[o]=r.x,N[o+1]=r.y,N[o+2]=r.z,R+=1));c=3*M;for(f=t.length;c<f;c++)t[c]=0;c=3*P;for(f=z.length;c<f;c++)z[c]=0;c=3*da;for(f=D.length;c<f;c++)D[c]=0;c=3*R;for(f=Y.length;c<f;c++)Y[c]=0;c=3*R;for(f=Q.length;c<f;c++)Q[c]=0;s.directional.length=M;s.point.length=P;s.spot.length=da;s.hemi.length=R;s.ambient[0]=l;s.ambient[1]=m;s.ambient[2]=n;hb=!1}c=qb;i.ambientLightColor.value=
A
alteredq 已提交
373
c.ambient;i.directionalLightColor.value=c.directional.colors;i.directionalLightDirection.value=c.directional.positions;i.pointLightColor.value=c.point.colors;i.pointLightPosition.value=c.point.positions;i.pointLightDistance.value=c.point.distances;i.spotLightColor.value=c.spot.colors;i.spotLightPosition.value=c.spot.positions;i.spotLightDistance.value=c.spot.distances;i.spotLightDirection.value=c.spot.directions;i.spotLightAngle.value=c.spot.angles;i.spotLightExponent.value=c.spot.exponents;i.hemisphereLightSkyColor.value=
374 375
c.hemi.skyColors;i.hemisphereLightGroundColor.value=c.hemi.groundColors;i.hemisphereLightPosition.value=c.hemi.positions}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial){i.opacity.value=d.opacity;J.gammaInput?i.diffuse.value.copyGammaToLinear(d.color):i.diffuse.value=d.color;i.map.value=d.map;i.lightMap.value=d.lightMap;i.specularMap.value=d.specularMap;d.bumpMap&&(i.bumpMap.value=d.bumpMap,i.bumpScale.value=d.bumpScale);d.normalMap&&
(i.normalMap.value=d.normalMap,i.normalScale.value.copy(d.normalScale));var U;d.map?U=d.map:d.specularMap?U=d.specularMap:d.normalMap?U=d.normalMap:d.bumpMap&&(U=d.bumpMap);void 0!==U&&(c=U.offset,U=U.repeat,i.offsetRepeat.value.set(c.x,c.y,U.x,U.y));i.envMap.value=d.envMap;i.flipEnvMap.value=d.envMap instanceof THREE.WebGLRenderTargetCube?1:-1;i.reflectivity.value=d.reflectivity;i.refractionRatio.value=d.refractionRatio;i.combine.value=d.combine;i.useRefract.value=d.envMap&&d.envMap.mapping instanceof
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
THREE.CubeRefractionMapping}d instanceof THREE.LineBasicMaterial?(i.diffuse.value=d.color,i.opacity.value=d.opacity):d instanceof THREE.LineDashedMaterial?(i.diffuse.value=d.color,i.opacity.value=d.opacity,i.dashSize.value=d.dashSize,i.totalSize.value=d.dashSize+d.gapSize,i.scale.value=d.scale):d instanceof THREE.ParticleBasicMaterial?(i.psColor.value=d.color,i.opacity.value=d.opacity,i.size.value=d.size,i.scale.value=G.height/2,i.map.value=d.map):d instanceof THREE.MeshPhongMaterial?(i.shininess.value=
d.shininess,J.gammaInput?(i.ambient.value.copyGammaToLinear(d.ambient),i.emissive.value.copyGammaToLinear(d.emissive),i.specular.value.copyGammaToLinear(d.specular)):(i.ambient.value=d.ambient,i.emissive.value=d.emissive,i.specular.value=d.specular),d.wrapAround&&i.wrapRGB.value.copy(d.wrapRGB)):d instanceof THREE.MeshLambertMaterial?(J.gammaInput?(i.ambient.value.copyGammaToLinear(d.ambient),i.emissive.value.copyGammaToLinear(d.emissive)):(i.ambient.value=d.ambient,i.emissive.value=d.emissive),d.wrapAround&&
i.wrapRGB.value.copy(d.wrapRGB)):d instanceof THREE.MeshDepthMaterial?(i.mNear.value=a.near,i.mFar.value=a.far,i.opacity.value=d.opacity):d instanceof THREE.MeshNormalMaterial&&(i.opacity.value=d.opacity);if(e.receiveShadow&&!d._shadowPass&&i.shadowMatrix){c=U=0;for(f=b.length;c<f;c++)if(j=b[c],j.castShadow&&(j instanceof THREE.SpotLight||j instanceof THREE.DirectionalLight&&!j.shadowCascade))i.shadowMap.value[U]=j.shadowMap,i.shadowMapSize.value[U]=j.shadowMapSize,i.shadowMatrix.value[U]=j.shadowMatrix,
i.shadowDarkness.value[U]=j.shadowDarkness,i.shadowBias.value[U]=j.shadowBias,U++}b=d.uniformsList;i=0;for(U=b.length;i<U;i++)if(f=g.uniforms[b[i][1]])if(c=b[i][0],l=c.type,j=c.value,"i"===l)k.uniform1i(f,j);else if("f"===l)k.uniform1f(f,j);else if("v2"===l)k.uniform2f(f,j.x,j.y);else if("v3"===l)k.uniform3f(f,j.x,j.y,j.z);else if("v4"===l)k.uniform4f(f,j.x,j.y,j.z,j.w);else if("c"===l)k.uniform3f(f,j.r,j.g,j.b);else if("iv1"===l)k.uniform1iv(f,j);else if("iv"===l)k.uniform3iv(f,j);else if("fv1"===
l)k.uniform1fv(f,j);else if("fv"===l)k.uniform3fv(f,j);else if("v2v"===l){void 0===c._array&&(c._array=new Float32Array(2*j.length));l=0;for(m=j.length;l<m;l++)n=2*l,c._array[n]=j[l].x,c._array[n+1]=j[l].y;k.uniform2fv(f,c._array)}else if("v3v"===l){void 0===c._array&&(c._array=new Float32Array(3*j.length));l=0;for(m=j.length;l<m;l++)n=3*l,c._array[n]=j[l].x,c._array[n+1]=j[l].y,c._array[n+2]=j[l].z;k.uniform3fv(f,c._array)}else if("v4v"===l){void 0===c._array&&(c._array=new Float32Array(4*j.length));
l=0;for(m=j.length;l<m;l++)n=4*l,c._array[n]=j[l].x,c._array[n+1]=j[l].y,c._array[n+2]=j[l].z,c._array[n+3]=j[l].w;k.uniform4fv(f,c._array)}else if("m4"===l)void 0===c._array&&(c._array=new Float32Array(16)),j.flattenToArray(c._array),k.uniformMatrix4fv(f,!1,c._array);else if("m4v"===l){void 0===c._array&&(c._array=new Float32Array(16*j.length));l=0;for(m=j.length;l<m;l++)j[l].flattenToArrayOffset(c._array,16*l);k.uniformMatrix4fv(f,!1,c._array)}else if("t"===l){if(n=j,j=F(),k.uniform1i(f,j),n)if(n.image instanceof
Array&&6===n.image.length){if(c=n,f=j,6===c.image.length)if(c.needsUpdate){c.image.__webglTextureCube||(c.image.__webglTextureCube=k.createTexture());k.activeTexture(k.TEXTURE0+f);k.bindTexture(k.TEXTURE_CUBE_MAP,c.image.__webglTextureCube);k.pixelStorei(k.UNPACK_FLIP_Y_WEBGL,c.flipY);f=c instanceof THREE.CompressedTexture;j=[];for(l=0;6>l;l++)J.autoScaleCubemaps&&!f?(m=j,n=l,s=c.image[l],u=Oc,s.width<=u&&s.height<=u||(z=Math.max(s.width,s.height),t=Math.floor(s.width*u/z),u=Math.floor(s.height*u/
z),z=document.createElement("canvas"),z.width=t,z.height=u,z.getContext("2d").drawImage(s,0,0,s.width,s.height,0,0,t,u),s=z),m[n]=s):j[l]=c.image[l];l=j[0];m=0===(l.width&l.width-1)&&0===(l.height&l.height-1);n=H(c.format);s=H(c.type);L(k.TEXTURE_CUBE_MAP,c,m);for(l=0;6>l;l++)if(f){u=j[l].mipmaps;z=0;for(A=u.length;z<A;z++)t=u[z],k.compressedTexImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+l,z,n,t.width,t.height,0,t.data)}else k.texImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+l,0,n,n,s,j[l]);c.generateMipmaps&&
m&&k.generateMipmap(k.TEXTURE_CUBE_MAP);c.needsUpdate=!1;if(c.onUpdate)c.onUpdate()}else k.activeTexture(k.TEXTURE0+f),k.bindTexture(k.TEXTURE_CUBE_MAP,c.image.__webglTextureCube)}else n instanceof THREE.WebGLRenderTargetCube?(c=n,k.activeTexture(k.TEXTURE0+j),k.bindTexture(k.TEXTURE_CUBE_MAP,c.__webglTexture)):J.setTexture(n,j)}else if("tv"===l){void 0===c._array&&(c._array=[]);l=0;for(m=c.value.length;l<m;l++)c._array[l]=F();k.uniform1iv(f,c._array);l=0;for(m=c.value.length;l<m;l++)n=c.value[l],
j=c._array[l],n&&J.setTexture(n,j)}if((d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&null!==h.cameraPosition)b=a.matrixWorld.getPosition(),k.uniform3f(h.cameraPosition,b.x,b.y,b.z);(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&null!==h.viewMatrix&&k.uniformMatrix4fv(h.viewMatrix,!1,a._viewMatrixArray)}k.uniformMatrix4fv(h.modelViewMatrix,!1,e._modelViewMatrix.elements);h.normalMatrix&&
k.uniformMatrix3fv(h.normalMatrix,!1,e._normalMatrix.elements);null!==h.modelMatrix&&k.uniformMatrix4fv(h.modelMatrix,!1,e.matrixWorld.elements);return g}function F(){var a=Na;a>=vc&&console.warn("Trying to use "+a+" texture units while this GPU supports only "+vc);Na+=1;return a}function z(a,b){a._modelViewMatrix.multiply(b.matrixWorldInverse,a.matrixWorld);a._normalMatrix.getInverse(a._modelViewMatrix);a._normalMatrix.transpose()}function w(a,b,c,d){a[b]=c.r*c.r*d;a[b+1]=c.g*c.g*d;a[b+2]=c.b*c.b*
d}function v(a,b,c,d){a[b]=c.r*d;a[b+1]=c.g*d;a[b+2]=c.b*d}function C(a,b,c){lb!==a&&(a?k.enable(k.POLYGON_OFFSET_FILL):k.disable(k.POLYGON_OFFSET_FILL),lb=a);if(a&&(Ab!==b||Bb!==c))k.polygonOffset(b,c),Ab=b,Bb=c}function D(a){for(var a=a.split("\n"),b=0,c=a.length;b<c;b++)a[b]=b+1+": "+a[b];return a.join("\n")}function I(a,b){var c;"fragment"===a?c=k.createShader(k.FRAGMENT_SHADER):"vertex"===a&&(c=k.createShader(k.VERTEX_SHADER));k.shaderSource(c,b);k.compileShader(c);return!k.getShaderParameter(c,
k.COMPILE_STATUS)?(console.error(k.getShaderInfoLog(c)),console.error(D(b)),null):c}function L(a,b,c){c?(k.texParameteri(a,k.TEXTURE_WRAP_S,H(b.wrapS)),k.texParameteri(a,k.TEXTURE_WRAP_T,H(b.wrapT)),k.texParameteri(a,k.TEXTURE_MAG_FILTER,H(b.magFilter)),k.texParameteri(a,k.TEXTURE_MIN_FILTER,H(b.minFilter))):(k.texParameteri(a,k.TEXTURE_WRAP_S,k.CLAMP_TO_EDGE),k.texParameteri(a,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE),k.texParameteri(a,k.TEXTURE_MAG_FILTER,K(b.magFilter)),k.texParameteri(a,k.TEXTURE_MIN_FILTER,
K(b.minFilter)));if(yb&&b.type!==THREE.FloatType&&(1<b.anisotropy||b.__oldAnisotropy))k.texParameterf(a,yb.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,mc)),b.__oldAnisotropy=b.anisotropy}function B(a,b){k.bindRenderbuffer(k.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(k.renderbufferStorage(k.RENDERBUFFER,k.DEPTH_COMPONENT16,b.width,b.height),k.framebufferRenderbuffer(k.FRAMEBUFFER,k.DEPTH_ATTACHMENT,k.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(k.renderbufferStorage(k.RENDERBUFFER,k.DEPTH_STENCIL,
b.width,b.height),k.framebufferRenderbuffer(k.FRAMEBUFFER,k.DEPTH_STENCIL_ATTACHMENT,k.RENDERBUFFER,a)):k.renderbufferStorage(k.RENDERBUFFER,k.RGBA4,b.width,b.height)}function K(a){return a===THREE.NearestFilter||a===THREE.NearestMipMapNearestFilter||a===THREE.NearestMipMapLinearFilter?k.NEAREST:k.LINEAR}function H(a){if(a===THREE.RepeatWrapping)return k.REPEAT;if(a===THREE.ClampToEdgeWrapping)return k.CLAMP_TO_EDGE;if(a===THREE.MirroredRepeatWrapping)return k.MIRRORED_REPEAT;if(a===THREE.NearestFilter)return k.NEAREST;
if(a===THREE.NearestMipMapNearestFilter)return k.NEAREST_MIPMAP_NEAREST;if(a===THREE.NearestMipMapLinearFilter)return k.NEAREST_MIPMAP_LINEAR;if(a===THREE.LinearFilter)return k.LINEAR;if(a===THREE.LinearMipMapNearestFilter)return k.LINEAR_MIPMAP_NEAREST;if(a===THREE.LinearMipMapLinearFilter)return k.LINEAR_MIPMAP_LINEAR;if(a===THREE.UnsignedByteType)return k.UNSIGNED_BYTE;if(a===THREE.UnsignedShort4444Type)return k.UNSIGNED_SHORT_4_4_4_4;if(a===THREE.UnsignedShort5551Type)return k.UNSIGNED_SHORT_5_5_5_1;
if(a===THREE.UnsignedShort565Type)return k.UNSIGNED_SHORT_5_6_5;if(a===THREE.ByteType)return k.BYTE;if(a===THREE.ShortType)return k.SHORT;if(a===THREE.UnsignedShortType)return k.UNSIGNED_SHORT;if(a===THREE.IntType)return k.INT;if(a===THREE.UnsignedIntType)return k.UNSIGNED_INT;if(a===THREE.FloatType)return k.FLOAT;if(a===THREE.AlphaFormat)return k.ALPHA;if(a===THREE.RGBFormat)return k.RGB;if(a===THREE.RGBAFormat)return k.RGBA;if(a===THREE.LuminanceFormat)return k.LUMINANCE;if(a===THREE.LuminanceAlphaFormat)return k.LUMINANCE_ALPHA;
if(a===THREE.AddEquation)return k.FUNC_ADD;if(a===THREE.SubtractEquation)return k.FUNC_SUBTRACT;if(a===THREE.ReverseSubtractEquation)return k.FUNC_REVERSE_SUBTRACT;if(a===THREE.ZeroFactor)return k.ZERO;if(a===THREE.OneFactor)return k.ONE;if(a===THREE.SrcColorFactor)return k.SRC_COLOR;if(a===THREE.OneMinusSrcColorFactor)return k.ONE_MINUS_SRC_COLOR;if(a===THREE.SrcAlphaFactor)return k.SRC_ALPHA;if(a===THREE.OneMinusSrcAlphaFactor)return k.ONE_MINUS_SRC_ALPHA;if(a===THREE.DstAlphaFactor)return k.DST_ALPHA;
if(a===THREE.OneMinusDstAlphaFactor)return k.ONE_MINUS_DST_ALPHA;if(a===THREE.DstColorFactor)return k.DST_COLOR;if(a===THREE.OneMinusDstColorFactor)return k.ONE_MINUS_DST_COLOR;if(a===THREE.SrcAlphaSaturateFactor)return k.SRC_ALPHA_SATURATE;if(void 0!==pb){if(a===THREE.RGB_S3TC_DXT1_Format)return pb.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===THREE.RGBA_S3TC_DXT1_Format)return pb.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===THREE.RGBA_S3TC_DXT3_Format)return pb.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===THREE.RGBA_S3TC_DXT5_Format)return pb.COMPRESSED_RGBA_S3TC_DXT5_EXT}return 0}
console.log("THREE.WebGLRenderer",THREE.REVISION);var a=a||{},G=void 0!==a.canvas?a.canvas:document.createElement("canvas"),M=void 0!==a.precision?a.precision:"highp",N=void 0!==a.alpha?a.alpha:!0,R=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,aa=void 0!==a.antialias?a.antialias:!1,P=void 0!==a.stencil?a.stencil:!0,O=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,Q=void 0!==a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0),U=void 0!==a.clearAlpha?a.clearAlpha:0;this.domElement=
G;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.shadowMapEnabled=this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapCullFrontFaces=this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.shadowMapCascade=this.shadowMapDebug=!1;this.maxMorphTargets=8;this.maxMorphNormals=4;this.autoScaleCubemaps=!0;this.renderPluginsPre=[];this.renderPluginsPost=[];this.info=
{memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var J=this,qa=[],S=0,ha=null,Y=null,ba=-1,ia=null,Z=null,da=0,Na=0,Aa=-1,Ja=-1,Ta=-1,ta=-1,db=-1,xb=-1,Ua=-1,gb=-1,lb=null,Ab=null,Bb=null,fb=null,va=0,Ha=0,mb=0,La=0,Za=0,eb=0,ua=new THREE.Frustum,$a=new THREE.Matrix4,ab=new THREE.Matrix4,nb=new THREE.Vector4,ja=new THREE.Vector3,hb=!0,qb={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]},spot:{length:0,
colors:[],positions:[],distances:[],directions:[],angles:[],exponents:[]},hemi:{length:0,skyColors:[],groundColors:[],positions:[]}},k,yb,pb;try{if(!(k=G.getContext("experimental-webgl",{alpha:N,premultipliedAlpha:R,antialias:aa,stencil:P,preserveDrawingBuffer:O})))throw"Error creating WebGL context.";}catch(Nc){console.error(Nc)}a=k.getExtension("OES_texture_float");N=k.getExtension("OES_standard_derivatives");yb=k.getExtension("EXT_texture_filter_anisotropic")||k.getExtension("MOZ_EXT_texture_filter_anisotropic")||
k.getExtension("WEBKIT_EXT_texture_filter_anisotropic");pb=k.getExtension("WEBGL_compressed_texture_s3tc")||k.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||k.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");a||console.log("THREE.WebGLRenderer: Float textures not supported.");N||console.log("THREE.WebGLRenderer: Standard derivatives not supported.");yb||console.log("THREE.WebGLRenderer: Anisotropic texture filtering not supported.");pb||console.log("THREE.WebGLRenderer: S3TC compressed textures not supported.");
k.clearColor(0,0,0,1);k.clearDepth(1);k.clearStencil(0);k.enable(k.DEPTH_TEST);k.depthFunc(k.LEQUAL);k.frontFace(k.CCW);k.cullFace(k.BACK);k.enable(k.CULL_FACE);k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA);k.clearColor(Q.r,Q.g,Q.b,U);this.context=k;var vc=k.getParameter(k.MAX_TEXTURE_IMAGE_UNITS),N=k.getParameter(k.MAX_VERTEX_TEXTURE_IMAGE_UNITS);k.getParameter(k.MAX_TEXTURE_SIZE);var Oc=k.getParameter(k.MAX_CUBE_MAP_TEXTURE_SIZE),mc=yb?k.getParameter(yb.MAX_TEXTURE_MAX_ANISOTROPY_EXT):
0,ec=0<N,fc=ec&&a;pb&&k.getParameter(k.COMPRESSED_TEXTURE_FORMATS);this.getContext=function(){return k};this.supportsVertexTextures=function(){return ec};this.getMaxAnisotropy=function(){return mc};this.setSize=function(a,b){G.width=a;G.height=b;this.setViewport(0,0,G.width,G.height)};this.setViewport=function(a,b,c,d){va=void 0!==a?a:0;Ha=void 0!==b?b:0;mb=void 0!==c?c:G.width;La=void 0!==d?d:G.height;k.viewport(va,Ha,mb,La)};this.setScissor=function(a,b,c,d){k.scissor(a,b,c,d)};this.enableScissorTest=
function(a){a?k.enable(k.SCISSOR_TEST):k.disable(k.SCISSOR_TEST)};this.setClearColorHex=function(a,b){Q.setHex(a);U=b;k.clearColor(Q.r,Q.g,Q.b,U)};this.setClearColor=function(a,b){Q.copy(a);U=b;k.clearColor(Q.r,Q.g,Q.b,U)};this.getClearColor=function(){return Q};this.getClearAlpha=function(){return U};this.clear=function(a,b,c){var d=0;if(void 0===a||a)d|=k.COLOR_BUFFER_BIT;if(void 0===b||b)d|=k.DEPTH_BUFFER_BIT;if(void 0===c||c)d|=k.STENCIL_BUFFER_BIT;k.clear(d)};this.clearTarget=function(a,b,c,
d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=!1,delete a._modelViewMatrix,delete a._normalMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._modelMatrixArray,a instanceof THREE.Mesh)for(var c in a.geometry.geometryGroups){var d=a.geometry.geometryGroups[c];
k.deleteBuffer(d.__webglVertexBuffer);k.deleteBuffer(d.__webglNormalBuffer);k.deleteBuffer(d.__webglTangentBuffer);k.deleteBuffer(d.__webglColorBuffer);k.deleteBuffer(d.__webglUVBuffer);k.deleteBuffer(d.__webglUV2Buffer);k.deleteBuffer(d.__webglSkinIndicesBuffer);k.deleteBuffer(d.__webglSkinWeightsBuffer);k.deleteBuffer(d.__webglFaceBuffer);k.deleteBuffer(d.__webglLineBuffer);var e=void 0,f=void 0;if(d.numMorphTargets){e=0;for(f=d.numMorphTargets;e<f;e++)k.deleteBuffer(d.__webglMorphTargetsBuffers[e])}if(d.numMorphNormals){e=
0;for(f=d.numMorphNormals;e<f;e++)k.deleteBuffer(d.__webglMorphNormalsBuffers[e])}b(d);J.info.memory.geometries--}else a instanceof THREE.Ribbon?(a=a.geometry,k.deleteBuffer(a.__webglVertexBuffer),k.deleteBuffer(a.__webglColorBuffer),k.deleteBuffer(a.__webglNormalBuffer),b(a),J.info.memory.geometries--):a instanceof THREE.Line?(a=a.geometry,k.deleteBuffer(a.__webglVertexBuffer),k.deleteBuffer(a.__webglColorBuffer),k.deleteBuffer(a.__webglLineDistanceBuffer),b(a),J.info.memory.geometries--):a instanceof
THREE.ParticleSystem&&(a=a.geometry,k.deleteBuffer(a.__webglVertexBuffer),k.deleteBuffer(a.__webglColorBuffer),b(a),J.info.memory.geometries--)};this.deallocateTexture=function(a){a.__webglInit&&(a.__webglInit=!1,k.deleteTexture(a.__webglTexture),J.info.memory.textures--)};this.deallocateRenderTarget=function(a){if(a&&a.__webglTexture)if(k.deleteTexture(a.__webglTexture),a instanceof THREE.WebGLRenderTargetCube)for(var b=0;6>b;b++)k.deleteFramebuffer(a.__webglFramebuffer[b]),k.deleteRenderbuffer(a.__webglRenderbuffer[b]);
else k.deleteFramebuffer(a.__webglFramebuffer),k.deleteRenderbuffer(a.__webglRenderbuffer)};this.deallocateMaterial=function(a){var b=a.program;if(b){a.program=void 0;var c,d,e=!1,a=0;for(c=qa.length;a<c;a++)if(d=qa[a],d.program===b){d.usedTimes--;0===d.usedTimes&&(e=!0);break}if(e){e=[];a=0;for(c=qa.length;a<c;a++)d=qa[a],d.program!==b&&e.push(d);qa=e;k.deleteProgram(b);J.info.memory.programs--}}};this.updateShadowMap=function(a,b){ha=null;ba=ia=gb=Ua=Ta=-1;hb=!0;Ja=Aa=-1;this.shadowMapPlugin.update(a,
b)};this.renderBufferImmediate=function(a,b,c){a.hasPositions&&!a.__webglVertexBuffer&&(a.__webglVertexBuffer=k.createBuffer());a.hasNormals&&!a.__webglNormalBuffer&&(a.__webglNormalBuffer=k.createBuffer());a.hasUvs&&!a.__webglUvBuffer&&(a.__webglUvBuffer=k.createBuffer());a.hasColors&&!a.__webglColorBuffer&&(a.__webglColorBuffer=k.createBuffer());a.hasPositions&&(k.bindBuffer(k.ARRAY_BUFFER,a.__webglVertexBuffer),k.bufferData(k.ARRAY_BUFFER,a.positionArray,k.DYNAMIC_DRAW),k.enableVertexAttribArray(b.attributes.position),
k.vertexAttribPointer(b.attributes.position,3,k.FLOAT,!1,0,0));if(a.hasNormals){k.bindBuffer(k.ARRAY_BUFFER,a.__webglNormalBuffer);if(c.shading===THREE.FlatShading){var d,e,f,g,h,i,j,l,m,n,o,p=3*a.count;for(o=0;o<p;o+=9)n=a.normalArray,d=n[o],e=n[o+1],f=n[o+2],g=n[o+3],i=n[o+4],l=n[o+5],h=n[o+6],j=n[o+7],m=n[o+8],d=(d+g+h)/3,e=(e+i+j)/3,f=(f+l+m)/3,n[o]=d,n[o+1]=e,n[o+2]=f,n[o+3]=d,n[o+4]=e,n[o+5]=f,n[o+6]=d,n[o+7]=e,n[o+8]=f}k.bufferData(k.ARRAY_BUFFER,a.normalArray,k.DYNAMIC_DRAW);k.enableVertexAttribArray(b.attributes.normal);
k.vertexAttribPointer(b.attributes.normal,3,k.FLOAT,!1,0,0)}a.hasUvs&&c.map&&(k.bindBuffer(k.ARRAY_BUFFER,a.__webglUvBuffer),k.bufferData(k.ARRAY_BUFFER,a.uvArray,k.DYNAMIC_DRAW),k.enableVertexAttribArray(b.attributes.uv),k.vertexAttribPointer(b.attributes.uv,2,k.FLOAT,!1,0,0));a.hasColors&&c.vertexColors!==THREE.NoColors&&(k.bindBuffer(k.ARRAY_BUFFER,a.__webglColorBuffer),k.bufferData(k.ARRAY_BUFFER,a.colorArray,k.DYNAMIC_DRAW),k.enableVertexAttribArray(b.attributes.color),k.vertexAttribPointer(b.attributes.color,
3,k.FLOAT,!1,0,0));k.drawArrays(k.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,e,f){if(!1!==d.visible)if(c=t(a,b,c,d,f),a=c.attributes,b=!1,d=16777215*e.id+2*c.id+(d.wireframe?1:0),d!==ia&&(ia=d,b=!0),f instanceof THREE.Mesh){f=e.offsets;1<f.length&&(b=!0);d=0;for(c=f.length;d<c;++d){var g=f[d].index;if(b){var h=e.attributes.position,i=h.itemSize;k.bindBuffer(k.ARRAY_BUFFER,h.buffer);k.vertexAttribPointer(a.position,i,k.FLOAT,!1,0,4*g*i);h=e.attributes.normal;0<=a.normal&&
h&&(i=h.itemSize,k.bindBuffer(k.ARRAY_BUFFER,h.buffer),k.vertexAttribPointer(a.normal,i,k.FLOAT,!1,0,4*g*i));h=e.attributes.uv;0<=a.uv&&h&&(h.buffer?(i=h.itemSize,k.bindBuffer(k.ARRAY_BUFFER,h.buffer),k.vertexAttribPointer(a.uv,i,k.FLOAT,!1,0,4*g*i),k.enableVertexAttribArray(a.uv)):k.disableVertexAttribArray(a.uv));i=e.attributes.color;if(0<=a.color&&i){var j=i.itemSize;k.bindBuffer(k.ARRAY_BUFFER,i.buffer);k.vertexAttribPointer(a.color,j,k.FLOAT,!1,0,4*g*j)}h=e.attributes.tangent;0<=a.tangent&&h&&
(i=h.itemSize,k.bindBuffer(k.ARRAY_BUFFER,h.buffer),k.vertexAttribPointer(a.tangent,i,k.FLOAT,!1,0,4*g*i));k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,e.attributes.index.buffer)}k.drawElements(k.TRIANGLES,f[d].count,k.UNSIGNED_SHORT,2*f[d].start);J.info.render.calls++;J.info.render.vertices+=f[d].count;J.info.render.faces+=f[d].count/3}}else f instanceof THREE.ParticleSystem&&b&&(h=e.attributes.position,i=h.itemSize,k.bindBuffer(k.ARRAY_BUFFER,h.buffer),k.vertexAttribPointer(a.position,i,k.FLOAT,!1,0,0),
i=e.attributes.color,0<=a.color&&i&&(j=i.itemSize,k.bindBuffer(k.ARRAY_BUFFER,i.buffer),k.vertexAttribPointer(a.color,j,k.FLOAT,!1,0,0)),k.drawArrays(k.POINTS,0,h.numItems/3),J.info.render.calls++,J.info.render.points+=h.numItems/3)};this.renderBuffer=function(a,b,c,d,e,f){if(!1!==d.visible){var g,h,c=t(a,b,c,d,f),b=c.attributes,a=!1,c=16777215*e.id+2*c.id+(d.wireframe?1:0);c!==ia&&(ia=c,a=!0);if(!d.morphTargets&&0<=b.position)a&&(k.bindBuffer(k.ARRAY_BUFFER,e.__webglVertexBuffer),k.vertexAttribPointer(b.position,
3,k.FLOAT,!1,0,0));else if(f.morphTargetBase){c=d.program.attributes;-1!==f.morphTargetBase?(k.bindBuffer(k.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]),k.vertexAttribPointer(c.position,3,k.FLOAT,!1,0,0)):0<=c.position&&(k.bindBuffer(k.ARRAY_BUFFER,e.__webglVertexBuffer),k.vertexAttribPointer(c.position,3,k.FLOAT,!1,0,0));if(f.morphTargetForcedOrder.length){var i=0;h=f.morphTargetForcedOrder;for(g=f.morphTargetInfluences;i<d.numSupportedMorphTargets&&i<h.length;)k.bindBuffer(k.ARRAY_BUFFER,
e.__webglMorphTargetsBuffers[h[i]]),k.vertexAttribPointer(c["morphTarget"+i],3,k.FLOAT,!1,0,0),d.morphNormals&&(k.bindBuffer(k.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[h[i]]),k.vertexAttribPointer(c["morphNormal"+i],3,k.FLOAT,!1,0,0)),f.__webglMorphTargetInfluences[i]=g[h[i]],i++}else{h=[];g=f.morphTargetInfluences;var j,l=g.length;for(j=0;j<l;j++)i=g[j],0<i&&h.push([j,i]);h.length>d.numSupportedMorphTargets?(h.sort(n),h.length=d.numSupportedMorphTargets):h.length>d.numSupportedMorphNormals?h.sort(n):
0===h.length&&h.push([0,0]);for(i=0;i<d.numSupportedMorphTargets;)h[i]?(j=h[i][0],k.bindBuffer(k.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[j]),k.vertexAttribPointer(c["morphTarget"+i],3,k.FLOAT,!1,0,0),d.morphNormals&&(k.bindBuffer(k.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[j]),k.vertexAttribPointer(c["morphNormal"+i],3,k.FLOAT,!1,0,0)),f.__webglMorphTargetInfluences[i]=g[j]):(k.vertexAttribPointer(c["morphTarget"+i],3,k.FLOAT,!1,0,0),d.morphNormals&&k.vertexAttribPointer(c["morphNormal"+i],3,k.FLOAT,
!1,0,0),f.__webglMorphTargetInfluences[i]=0),i++}null!==d.program.uniforms.morphTargetInfluences&&k.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){g=0;for(h=e.__webglCustomAttributesList.length;g<h;g++)c=e.__webglCustomAttributesList[g],0<=b[c.buffer.belongsToAttribute]&&(k.bindBuffer(k.ARRAY_BUFFER,c.buffer),k.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,k.FLOAT,!1,0,0))}0<=b.color&&(k.bindBuffer(k.ARRAY_BUFFER,
e.__webglColorBuffer),k.vertexAttribPointer(b.color,3,k.FLOAT,!1,0,0));0<=b.normal&&(k.bindBuffer(k.ARRAY_BUFFER,e.__webglNormalBuffer),k.vertexAttribPointer(b.normal,3,k.FLOAT,!1,0,0));0<=b.tangent&&(k.bindBuffer(k.ARRAY_BUFFER,e.__webglTangentBuffer),k.vertexAttribPointer(b.tangent,4,k.FLOAT,!1,0,0));0<=b.uv&&(e.__webglUVBuffer?(k.bindBuffer(k.ARRAY_BUFFER,e.__webglUVBuffer),k.vertexAttribPointer(b.uv,2,k.FLOAT,!1,0,0),k.enableVertexAttribArray(b.uv)):k.disableVertexAttribArray(b.uv));0<=b.uv2&&
(e.__webglUV2Buffer?(k.bindBuffer(k.ARRAY_BUFFER,e.__webglUV2Buffer),k.vertexAttribPointer(b.uv2,2,k.FLOAT,!1,0,0),k.enableVertexAttribArray(b.uv2)):k.disableVertexAttribArray(b.uv2));d.skinning&&(0<=b.skinIndex&&0<=b.skinWeight)&&(k.bindBuffer(k.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),k.vertexAttribPointer(b.skinIndex,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),k.vertexAttribPointer(b.skinWeight,4,k.FLOAT,!1,0,0));0<=b.lineDistance&&(k.bindBuffer(k.ARRAY_BUFFER,e.__webglLineDistanceBuffer),
k.vertexAttribPointer(b.lineDistance,1,k.FLOAT,!1,0,0))}f instanceof THREE.Mesh?(d.wireframe?(d=d.wireframeLinewidth,d!==fb&&(k.lineWidth(d),fb=d),a&&k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),k.drawElements(k.LINES,e.__webglLineCount,k.UNSIGNED_SHORT,0)):(a&&k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),k.drawElements(k.TRIANGLES,e.__webglFaceCount,k.UNSIGNED_SHORT,0)),J.info.render.calls++,J.info.render.vertices+=e.__webglFaceCount,J.info.render.faces+=e.__webglFaceCount/
3):f instanceof THREE.Line?(f=f.type===THREE.LineStrip?k.LINE_STRIP:k.LINES,d=d.linewidth,d!==fb&&(k.lineWidth(d),fb=d),k.drawArrays(f,0,e.__webglLineCount),J.info.render.calls++):f instanceof THREE.ParticleSystem?(k.drawArrays(k.POINTS,0,e.__webglParticleCount),J.info.render.calls++,J.info.render.points+=e.__webglParticleCount):f instanceof THREE.Ribbon&&(k.drawArrays(k.TRIANGLE_STRIP,0,e.__webglVertexCount),J.info.render.calls++)}};this.render=function(a,b,c,d){if(!1===b instanceof THREE.Camera)console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");
else{var e,f,g,h,i=a.__lights,j=a.fog;ba=-1;hb=!0;this.autoUpdateScene&&a.updateMatrixWorld();void 0===b.parent&&b.updateMatrixWorld();b._viewMatrixArray||(b._viewMatrixArray=new Float32Array(16));b._projectionMatrixArray||(b._projectionMatrixArray=new Float32Array(16));b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);$a.multiply(b.projectionMatrix,b.matrixWorldInverse);ua.setFromMatrix($a);
this.autoUpdateObjects&&this.initWebGLObjects(a);l(this.renderPluginsPre,a,b);J.info.render.calls=0;J.info.render.vertices=0;J.info.render.faces=0;J.info.render.points=0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);h=a.__webglObjects;d=0;for(e=h.length;d<e;d++)if(f=h[d],g=f.object,f.render=!1,g.visible&&(!(g instanceof THREE.Mesh||g instanceof THREE.ParticleSystem)||!g.frustumCulled||ua.contains(g))){z(g,b);var n=f,q=n.object,
r=n.buffer,s=void 0,s=s=void 0,s=q.material;s instanceof THREE.MeshFaceMaterial?(s=r.materialIndex,0<=s&&(s=q.geometry.materials[s],s.transparent?(n.transparent=s,n.opaque=null):(n.opaque=s,n.transparent=null))):s&&(s.transparent?(n.transparent=s,n.opaque=null):(n.opaque=s,n.transparent=null));f.render=!0;!0===this.sortObjects&&(null!==g.renderDepth?f.z=g.renderDepth:(nb.copy(g.matrixWorld.getPosition()),$a.multiplyVector3(nb),f.z=nb.z),f.id=g.id)}this.sortObjects&&h.sort(m);h=a.__webglObjectsImmediate;
d=0;for(e=h.length;d<e;d++)f=h[d],g=f.object,g.visible&&(z(g,b),g=f.object.material,g.transparent?(f.transparent=g,f.opaque=null):(f.opaque=g,f.transparent=null));a.overrideMaterial?(d=a.overrideMaterial,this.setBlending(d.blending,d.blendEquation,d.blendSrc,d.blendDst),this.setDepthTest(d.depthTest),this.setDepthWrite(d.depthWrite),C(d.polygonOffset,d.polygonOffsetFactor,d.polygonOffsetUnits),p(a.__webglObjects,!1,"",b,i,j,!0,d),o(a.__webglObjectsImmediate,"",b,i,j,!1,d)):(this.setBlending(THREE.NormalBlending),
p(a.__webglObjects,!0,"opaque",b,i,j,!1),o(a.__webglObjectsImmediate,"opaque",b,i,j,!1),p(a.__webglObjects,!1,"transparent",b,i,j,!0),o(a.__webglObjectsImmediate,"transparent",b,i,j,!0));l(this.renderPluginsPost,a,b);c&&(c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter)&&(c instanceof THREE.WebGLRenderTargetCube?(k.bindTexture(k.TEXTURE_CUBE_MAP,c.__webglTexture),k.generateMipmap(k.TEXTURE_CUBE_MAP),k.bindTexture(k.TEXTURE_CUBE_MAP,null)):(k.bindTexture(k.TEXTURE_2D,
c.__webglTexture),k.generateMipmap(k.TEXTURE_2D),k.bindTexture(k.TEXTURE_2D,null)));this.setDepthTest(!0);this.setDepthWrite(!0)}};this.renderImmediateObject=function(a,b,c,d,e){var f=t(a,b,c,d,e);ia=-1;J.setMaterialFaces(d);e.immediateRenderCallback?e.immediateRenderCallback(f,k,ua):e.render(function(a){J.renderBufferImmediate(a,f,d)})};this.initWebGLObjects=function(a){a.__webglObjects||(a.__webglObjects=[],a.__webglObjectsImmediate=[],a.__webglSprites=[],a.__webglFlares=[]);for(;a.__objectsAdded.length;){var b=
a.__objectsAdded[0],l=a,n=void 0,m=void 0,o=void 0;if(!b.__webglInit)if(b.__webglInit=!0,b._modelViewMatrix=new THREE.Matrix4,b._normalMatrix=new THREE.Matrix3,b instanceof THREE.Mesh)if(m=b.geometry,m instanceof THREE.Geometry){if(void 0===m.geometryGroups){var p=m,t=void 0,v=void 0,w=void 0,z=void 0,C=void 0,D=void 0,F=void 0,B={},H=p.morphTargets.length,I=p.morphNormals.length;p.geometryGroups={};t=0;for(v=p.faces.length;t<v;t++)w=p.faces[t],z=w.materialIndex,D=void 0!==z?z:-1,void 0===B[D]&&(B[D]=
{hash:D,counter:0}),F=B[D].hash+"_"+B[D].counter,void 0===p.geometryGroups[F]&&(p.geometryGroups[F]={faces3:[],faces4:[],materialIndex:z,vertices:0,numMorphTargets:H,numMorphNormals:I}),C=w instanceof THREE.Face3?3:4,65535<p.geometryGroups[F].vertices+C&&(B[D].counter+=1,F=B[D].hash+"_"+B[D].counter,void 0===p.geometryGroups[F]&&(p.geometryGroups[F]={faces3:[],faces4:[],materialIndex:z,vertices:0,numMorphTargets:H,numMorphNormals:I})),w instanceof THREE.Face3?p.geometryGroups[F].faces3.push(t):p.geometryGroups[F].faces4.push(t),
p.geometryGroups[F].vertices+=C;p.geometryGroupsList=[];var S=void 0;for(S in p.geometryGroups)p.geometryGroups[S].id=da++,p.geometryGroupsList.push(p.geometryGroups[S])}for(n in m.geometryGroups)if(o=m.geometryGroups[n],!o.__webglVertexBuffer){var G=o;G.__webglVertexBuffer=k.createBuffer();G.__webglNormalBuffer=k.createBuffer();G.__webglTangentBuffer=k.createBuffer();G.__webglColorBuffer=k.createBuffer();G.__webglUVBuffer=k.createBuffer();G.__webglUV2Buffer=k.createBuffer();G.__webglSkinIndicesBuffer=
k.createBuffer();G.__webglSkinWeightsBuffer=k.createBuffer();G.__webglFaceBuffer=k.createBuffer();G.__webglLineBuffer=k.createBuffer();var K=void 0,Y=void 0;if(G.numMorphTargets){G.__webglMorphTargetsBuffers=[];K=0;for(Y=G.numMorphTargets;K<Y;K++)G.__webglMorphTargetsBuffers.push(k.createBuffer())}if(G.numMorphNormals){G.__webglMorphNormalsBuffers=[];K=0;for(Y=G.numMorphNormals;K<Y;K++)G.__webglMorphNormalsBuffers.push(k.createBuffer())}J.info.memory.geometries++;d(o,b);m.verticesNeedUpdate=!0;m.morphTargetsNeedUpdate=
!0;m.elementsNeedUpdate=!0;m.uvsNeedUpdate=!0;m.normalsNeedUpdate=!0;m.tangentsNeedUpdate=!0;m.colorsNeedUpdate=!0}}else m instanceof THREE.BufferGeometry&&h(m);else if(b instanceof THREE.Ribbon){if(m=b.geometry,!m.__webglVertexBuffer){var O=m;O.__webglVertexBuffer=k.createBuffer();O.__webglColorBuffer=k.createBuffer();O.__webglNormalBuffer=k.createBuffer();J.info.memory.geometries++;var L=m,Q=b,N=L.vertices.length;L.__vertexArray=new Float32Array(3*N);L.__colorArray=new Float32Array(3*N);L.__normalArray=
new Float32Array(3*N);L.__webglVertexCount=N;c(L,Q);m.verticesNeedUpdate=!0;m.colorsNeedUpdate=!0;m.normalsNeedUpdate=!0}}else if(b instanceof THREE.Line){if(m=b.geometry,!m.__webglVertexBuffer){var ba=m;ba.__webglVertexBuffer=k.createBuffer();ba.__webglColorBuffer=k.createBuffer();ba.__webglLineDistanceBuffer=k.createBuffer();J.info.memory.geometries++;var M=m,U=b,P=M.vertices.length;M.__vertexArray=new Float32Array(3*P);M.__colorArray=new Float32Array(3*P);M.__lineDistanceArray=new Float32Array(1*
P);M.__webglLineCount=P;c(M,U);m.verticesNeedUpdate=!0;m.colorsNeedUpdate=!0;m.lineDistancesNeedUpdate=!0}}else if(b instanceof THREE.ParticleSystem&&(m=b.geometry,!m.__webglVertexBuffer))if(m instanceof THREE.Geometry){var R=m;R.__webglVertexBuffer=k.createBuffer();R.__webglColorBuffer=k.createBuffer();J.info.memory.geometries++;var Z=m,ha=b,ia=Z.vertices.length;Z.__vertexArray=new Float32Array(3*ia);Z.__colorArray=new Float32Array(3*ia);Z.__sortArray=[];Z.__webglParticleCount=ia;c(Z,ha);m.verticesNeedUpdate=
!0;m.colorsNeedUpdate=!0}else m instanceof THREE.BufferGeometry&&h(m);if(!b.__webglActive){if(b instanceof THREE.Mesh)if(m=b.geometry,m instanceof THREE.BufferGeometry)q(l.__webglObjects,m,b);else for(n in m.geometryGroups)o=m.geometryGroups[n],q(l.__webglObjects,o,b);else b instanceof THREE.Ribbon||b instanceof THREE.Line||b instanceof THREE.ParticleSystem?(m=b.geometry,q(l.__webglObjects,m,b)):b instanceof THREE.ImmediateRenderObject||b.immediateRenderCallback?l.__webglObjectsImmediate.push({object:b,
opaque:null,transparent:null}):b instanceof THREE.Sprite?l.__webglSprites.push(b):b instanceof THREE.LensFlare&&l.__webglFlares.push(b);b.__webglActive=!0}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;){var aa=a.__objectsRemoved[0],qa=a;aa instanceof THREE.Mesh||aa instanceof THREE.ParticleSystem||aa instanceof THREE.Ribbon||aa instanceof THREE.Line?A(qa.__webglObjects,aa):aa instanceof THREE.Sprite?u(qa.__webglSprites,aa):aa instanceof THREE.LensFlare?u(qa.__webglFlares,aa):(aa instanceof
THREE.ImmediateRenderObject||aa.immediateRenderCallback)&&A(qa.__webglObjectsImmediate,aa);aa.__webglActive=!1;a.__objectsRemoved.splice(0,1)}for(var Na=0,ta=a.__webglObjects.length;Na<ta;Na++){var Aa=a.__webglObjects[Na].object,fa=Aa.geometry,Ja=void 0,ua=void 0,ja=void 0;if(Aa instanceof THREE.Mesh)if(fa instanceof THREE.BufferGeometry)(fa.verticesNeedUpdate||fa.elementsNeedUpdate||fa.uvsNeedUpdate||fa.normalsNeedUpdate||fa.colorsNeedUpdate||fa.tangentsNeedUpdate)&&j(fa,k.DYNAMIC_DRAW,!fa.dynamic),
fa.verticesNeedUpdate=!1,fa.elementsNeedUpdate=!1,fa.uvsNeedUpdate=!1,fa.normalsNeedUpdate=!1,fa.colorsNeedUpdate=!1,fa.tangentsNeedUpdate=!1;else{for(var Ha=0,La=fa.geometryGroupsList.length;Ha<La;Ha++)if(Ja=fa.geometryGroupsList[Ha],ja=e(Aa,Ja),fa.buffersNeedUpdate&&d(Ja,Aa),ua=ja.attributes&&s(ja),fa.verticesNeedUpdate||fa.morphTargetsNeedUpdate||fa.elementsNeedUpdate||fa.uvsNeedUpdate||fa.normalsNeedUpdate||fa.colorsNeedUpdate||fa.tangentsNeedUpdate||ua){var pa=Ja,Ta=Aa,va=k.DYNAMIC_DRAW,db=!fa.dynamic,
Ua=ja;if(pa.__inittedArrays){var fb=f(Ua),hb=Ua.vertexColors?Ua.vertexColors:!1,xb=g(Ua),gb=fb===THREE.SmoothShading,E=void 0,$=void 0,Za=void 0,T=void 0,eb=void 0,$a=void 0,Db=void 0,nb=void 0,ab=void 0,lb=void 0,mb=void 0,V=void 0,W=void 0,X=void 0,oa=void 0,Eb=void 0,Fb=void 0,Gb=void 0,pb=void 0,Hb=void 0,Ib=void 0,Jb=void 0,qb=void 0,Kb=void 0,Lb=void 0,Mb=void 0,yb=void 0,Nb=void 0,Ob=void 0,Pb=void 0,Ab=void 0,Qb=void 0,Rb=void 0,Sb=void 0,Bb=void 0,wa=void 0,ec=void 0,Zb=void 0,ic=void 0,
jc=void 0,Qa=void 0,fc=void 0,Oa=void 0,Pa=void 0,$b=void 0,Ub=void 0,Ia=0,Ma=0,Vb=0,Wb=0,tb=0,Xa=0,za=0,cb=0,Ka=0,ga=0,ka=0,y=0,xa=void 0,Ra=pa.__vertexArray,nc=pa.__uvArray,oc=pa.__uv2Array,ub=pa.__normalArray,Da=pa.__tangentArray,Sa=pa.__colorArray,Ea=pa.__skinIndexArray,Fa=pa.__skinWeightArray,Qc=pa.__morphTargetsArrays,Rc=pa.__morphNormalsArrays,Sc=pa.__webglCustomAttributesList,x=void 0,Tb=pa.__faceArray,ob=pa.__lineArray,ib=Ta.geometry,vc=ib.elementsNeedUpdate,mc=ib.uvsNeedUpdate,Nc=ib.normalsNeedUpdate,
Oc=ib.tangentsNeedUpdate,fd=ib.colorsNeedUpdate,gd=ib.morphTargetsNeedUpdate,cc=ib.vertices,ra=pa.faces3,sa=pa.faces4,Ya=ib.faces,Tc=ib.faceVertexUvs[0],Uc=ib.faceVertexUvs[1],dc=ib.skinIndices,ac=ib.skinWeights,bc=ib.morphTargets,yc=ib.morphNormals;if(ib.verticesNeedUpdate){E=0;for($=ra.length;E<$;E++)T=Ya[ra[E]],V=cc[T.a],W=cc[T.b],X=cc[T.c],Ra[Ma]=V.x,Ra[Ma+1]=V.y,Ra[Ma+2]=V.z,Ra[Ma+3]=W.x,Ra[Ma+4]=W.y,Ra[Ma+5]=W.z,Ra[Ma+6]=X.x,Ra[Ma+7]=X.y,Ra[Ma+8]=X.z,Ma+=9;E=0;for($=sa.length;E<$;E++)T=Ya[sa[E]],
V=cc[T.a],W=cc[T.b],X=cc[T.c],oa=cc[T.d],Ra[Ma]=V.x,Ra[Ma+1]=V.y,Ra[Ma+2]=V.z,Ra[Ma+3]=W.x,Ra[Ma+4]=W.y,Ra[Ma+5]=W.z,Ra[Ma+6]=X.x,Ra[Ma+7]=X.y,Ra[Ma+8]=X.z,Ra[Ma+9]=oa.x,Ra[Ma+10]=oa.y,Ra[Ma+11]=oa.z,Ma+=12;k.bindBuffer(k.ARRAY_BUFFER,pa.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,Ra,va)}if(gd){Qa=0;for(fc=bc.length;Qa<fc;Qa++){E=ka=0;for($=ra.length;E<$;E++)$b=ra[E],T=Ya[$b],V=bc[Qa].vertices[T.a],W=bc[Qa].vertices[T.b],X=bc[Qa].vertices[T.c],Oa=Qc[Qa],Oa[ka]=V.x,Oa[ka+1]=V.y,Oa[ka+2]=V.z,Oa[ka+
3]=W.x,Oa[ka+4]=W.y,Oa[ka+5]=W.z,Oa[ka+6]=X.x,Oa[ka+7]=X.y,Oa[ka+8]=X.z,Ua.morphNormals&&(gb?(Ub=yc[Qa].vertexNormals[$b],Hb=Ub.a,Ib=Ub.b,Jb=Ub.c):Jb=Ib=Hb=yc[Qa].faceNormals[$b],Pa=Rc[Qa],Pa[ka]=Hb.x,Pa[ka+1]=Hb.y,Pa[ka+2]=Hb.z,Pa[ka+3]=Ib.x,Pa[ka+4]=Ib.y,Pa[ka+5]=Ib.z,Pa[ka+6]=Jb.x,Pa[ka+7]=Jb.y,Pa[ka+8]=Jb.z),ka+=9;E=0;for($=sa.length;E<$;E++)$b=sa[E],T=Ya[$b],V=bc[Qa].vertices[T.a],W=bc[Qa].vertices[T.b],X=bc[Qa].vertices[T.c],oa=bc[Qa].vertices[T.d],Oa=Qc[Qa],Oa[ka]=V.x,Oa[ka+1]=V.y,Oa[ka+2]=
V.z,Oa[ka+3]=W.x,Oa[ka+4]=W.y,Oa[ka+5]=W.z,Oa[ka+6]=X.x,Oa[ka+7]=X.y,Oa[ka+8]=X.z,Oa[ka+9]=oa.x,Oa[ka+10]=oa.y,Oa[ka+11]=oa.z,Ua.morphNormals&&(gb?(Ub=yc[Qa].vertexNormals[$b],Hb=Ub.a,Ib=Ub.b,Jb=Ub.c,qb=Ub.d):qb=Jb=Ib=Hb=yc[Qa].faceNormals[$b],Pa=Rc[Qa],Pa[ka]=Hb.x,Pa[ka+1]=Hb.y,Pa[ka+2]=Hb.z,Pa[ka+3]=Ib.x,Pa[ka+4]=Ib.y,Pa[ka+5]=Ib.z,Pa[ka+6]=Jb.x,Pa[ka+7]=Jb.y,Pa[ka+8]=Jb.z,Pa[ka+9]=qb.x,Pa[ka+10]=qb.y,Pa[ka+11]=qb.z),ka+=12;k.bindBuffer(k.ARRAY_BUFFER,pa.__webglMorphTargetsBuffers[Qa]);k.bufferData(k.ARRAY_BUFFER,
Qc[Qa],va);Ua.morphNormals&&(k.bindBuffer(k.ARRAY_BUFFER,pa.__webglMorphNormalsBuffers[Qa]),k.bufferData(k.ARRAY_BUFFER,Rc[Qa],va))}}if(ac.length){E=0;for($=ra.length;E<$;E++)T=Ya[ra[E]],Nb=ac[T.a],Ob=ac[T.b],Pb=ac[T.c],Fa[ga]=Nb.x,Fa[ga+1]=Nb.y,Fa[ga+2]=Nb.z,Fa[ga+3]=Nb.w,Fa[ga+4]=Ob.x,Fa[ga+5]=Ob.y,Fa[ga+6]=Ob.z,Fa[ga+7]=Ob.w,Fa[ga+8]=Pb.x,Fa[ga+9]=Pb.y,Fa[ga+10]=Pb.z,Fa[ga+11]=Pb.w,Qb=dc[T.a],Rb=dc[T.b],Sb=dc[T.c],Ea[ga]=Qb.x,Ea[ga+1]=Qb.y,Ea[ga+2]=Qb.z,Ea[ga+3]=Qb.w,Ea[ga+4]=Rb.x,Ea[ga+5]=Rb.y,
Ea[ga+6]=Rb.z,Ea[ga+7]=Rb.w,Ea[ga+8]=Sb.x,Ea[ga+9]=Sb.y,Ea[ga+10]=Sb.z,Ea[ga+11]=Sb.w,ga+=12;E=0;for($=sa.length;E<$;E++)T=Ya[sa[E]],Nb=ac[T.a],Ob=ac[T.b],Pb=ac[T.c],Ab=ac[T.d],Fa[ga]=Nb.x,Fa[ga+1]=Nb.y,Fa[ga+2]=Nb.z,Fa[ga+3]=Nb.w,Fa[ga+4]=Ob.x,Fa[ga+5]=Ob.y,Fa[ga+6]=Ob.z,Fa[ga+7]=Ob.w,Fa[ga+8]=Pb.x,Fa[ga+9]=Pb.y,Fa[ga+10]=Pb.z,Fa[ga+11]=Pb.w,Fa[ga+12]=Ab.x,Fa[ga+13]=Ab.y,Fa[ga+14]=Ab.z,Fa[ga+15]=Ab.w,Qb=dc[T.a],Rb=dc[T.b],Sb=dc[T.c],Bb=dc[T.d],Ea[ga]=Qb.x,Ea[ga+1]=Qb.y,Ea[ga+2]=Qb.z,Ea[ga+3]=Qb.w,
Ea[ga+4]=Rb.x,Ea[ga+5]=Rb.y,Ea[ga+6]=Rb.z,Ea[ga+7]=Rb.w,Ea[ga+8]=Sb.x,Ea[ga+9]=Sb.y,Ea[ga+10]=Sb.z,Ea[ga+11]=Sb.w,Ea[ga+12]=Bb.x,Ea[ga+13]=Bb.y,Ea[ga+14]=Bb.z,Ea[ga+15]=Bb.w,ga+=16;0<ga&&(k.bindBuffer(k.ARRAY_BUFFER,pa.__webglSkinIndicesBuffer),k.bufferData(k.ARRAY_BUFFER,Ea,va),k.bindBuffer(k.ARRAY_BUFFER,pa.__webglSkinWeightsBuffer),k.bufferData(k.ARRAY_BUFFER,Fa,va))}if(fd&&hb){E=0;for($=ra.length;E<$;E++)T=Ya[ra[E]],Db=T.vertexColors,nb=T.color,3===Db.length&&hb===THREE.VertexColors?(Kb=Db[0],
Lb=Db[1],Mb=Db[2]):Mb=Lb=Kb=nb,Sa[Ka]=Kb.r,Sa[Ka+1]=Kb.g,Sa[Ka+2]=Kb.b,Sa[Ka+3]=Lb.r,Sa[Ka+4]=Lb.g,Sa[Ka+5]=Lb.b,Sa[Ka+6]=Mb.r,Sa[Ka+7]=Mb.g,Sa[Ka+8]=Mb.b,Ka+=9;E=0;for($=sa.length;E<$;E++)T=Ya[sa[E]],Db=T.vertexColors,nb=T.color,4===Db.length&&hb===THREE.VertexColors?(Kb=Db[0],Lb=Db[1],Mb=Db[2],yb=Db[3]):yb=Mb=Lb=Kb=nb,Sa[Ka]=Kb.r,Sa[Ka+1]=Kb.g,Sa[Ka+2]=Kb.b,Sa[Ka+3]=Lb.r,Sa[Ka+4]=Lb.g,Sa[Ka+5]=Lb.b,Sa[Ka+6]=Mb.r,Sa[Ka+7]=Mb.g,Sa[Ka+8]=Mb.b,Sa[Ka+9]=yb.r,Sa[Ka+10]=yb.g,Sa[Ka+11]=yb.b,Ka+=12;0<Ka&&
(k.bindBuffer(k.ARRAY_BUFFER,pa.__webglColorBuffer),k.bufferData(k.ARRAY_BUFFER,Sa,va))}if(Oc&&ib.hasTangents){E=0;for($=ra.length;E<$;E++)T=Ya[ra[E]],ab=T.vertexTangents,Eb=ab[0],Fb=ab[1],Gb=ab[2],Da[za]=Eb.x,Da[za+1]=Eb.y,Da[za+2]=Eb.z,Da[za+3]=Eb.w,Da[za+4]=Fb.x,Da[za+5]=Fb.y,Da[za+6]=Fb.z,Da[za+7]=Fb.w,Da[za+8]=Gb.x,Da[za+9]=Gb.y,Da[za+10]=Gb.z,Da[za+11]=Gb.w,za+=12;E=0;for($=sa.length;E<$;E++)T=Ya[sa[E]],ab=T.vertexTangents,Eb=ab[0],Fb=ab[1],Gb=ab[2],pb=ab[3],Da[za]=Eb.x,Da[za+1]=Eb.y,Da[za+
2]=Eb.z,Da[za+3]=Eb.w,Da[za+4]=Fb.x,Da[za+5]=Fb.y,Da[za+6]=Fb.z,Da[za+7]=Fb.w,Da[za+8]=Gb.x,Da[za+9]=Gb.y,Da[za+10]=Gb.z,Da[za+11]=Gb.w,Da[za+12]=pb.x,Da[za+13]=pb.y,Da[za+14]=pb.z,Da[za+15]=pb.w,za+=16;k.bindBuffer(k.ARRAY_BUFFER,pa.__webglTangentBuffer);k.bufferData(k.ARRAY_BUFFER,Da,va)}if(Nc&&fb){E=0;for($=ra.length;E<$;E++)if(T=Ya[ra[E]],eb=T.vertexNormals,$a=T.normal,3===eb.length&&gb)for(wa=0;3>wa;wa++)Zb=eb[wa],ub[Xa]=Zb.x,ub[Xa+1]=Zb.y,ub[Xa+2]=Zb.z,Xa+=3;else for(wa=0;3>wa;wa++)ub[Xa]=$a.x,
ub[Xa+1]=$a.y,ub[Xa+2]=$a.z,Xa+=3;E=0;for($=sa.length;E<$;E++)if(T=Ya[sa[E]],eb=T.vertexNormals,$a=T.normal,4===eb.length&&gb)for(wa=0;4>wa;wa++)Zb=eb[wa],ub[Xa]=Zb.x,ub[Xa+1]=Zb.y,ub[Xa+2]=Zb.z,Xa+=3;else for(wa=0;4>wa;wa++)ub[Xa]=$a.x,ub[Xa+1]=$a.y,ub[Xa+2]=$a.z,Xa+=3;k.bindBuffer(k.ARRAY_BUFFER,pa.__webglNormalBuffer);k.bufferData(k.ARRAY_BUFFER,ub,va)}if(mc&&Tc&&xb){E=0;for($=ra.length;E<$;E++)if(Za=ra[E],lb=Tc[Za],void 0!==lb)for(wa=0;3>wa;wa++)ic=lb[wa],nc[Vb]=ic.u,nc[Vb+1]=ic.v,Vb+=2;E=0;for($=
sa.length;E<$;E++)if(Za=sa[E],lb=Tc[Za],void 0!==lb)for(wa=0;4>wa;wa++)ic=lb[wa],nc[Vb]=ic.u,nc[Vb+1]=ic.v,Vb+=2;0<Vb&&(k.bindBuffer(k.ARRAY_BUFFER,pa.__webglUVBuffer),k.bufferData(k.ARRAY_BUFFER,nc,va))}if(mc&&Uc&&xb){E=0;for($=ra.length;E<$;E++)if(Za=ra[E],mb=Uc[Za],void 0!==mb)for(wa=0;3>wa;wa++)jc=mb[wa],oc[Wb]=jc.u,oc[Wb+1]=jc.v,Wb+=2;E=0;for($=sa.length;E<$;E++)if(Za=sa[E],mb=Uc[Za],void 0!==mb)for(wa=0;4>wa;wa++)jc=mb[wa],oc[Wb]=jc.u,oc[Wb+1]=jc.v,Wb+=2;0<Wb&&(k.bindBuffer(k.ARRAY_BUFFER,pa.__webglUV2Buffer),
k.bufferData(k.ARRAY_BUFFER,oc,va))}if(vc){E=0;for($=ra.length;E<$;E++)Tb[tb]=Ia,Tb[tb+1]=Ia+1,Tb[tb+2]=Ia+2,tb+=3,ob[cb]=Ia,ob[cb+1]=Ia+1,ob[cb+2]=Ia,ob[cb+3]=Ia+2,ob[cb+4]=Ia+1,ob[cb+5]=Ia+2,cb+=6,Ia+=3;E=0;for($=sa.length;E<$;E++)Tb[tb]=Ia,Tb[tb+1]=Ia+1,Tb[tb+2]=Ia+3,Tb[tb+3]=Ia+1,Tb[tb+4]=Ia+2,Tb[tb+5]=Ia+3,tb+=6,ob[cb]=Ia,ob[cb+1]=Ia+1,ob[cb+2]=Ia,ob[cb+3]=Ia+3,ob[cb+4]=Ia+1,ob[cb+5]=Ia+2,ob[cb+6]=Ia+2,ob[cb+7]=Ia+3,cb+=8,Ia+=4;k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,pa.__webglFaceBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,
Tb,va);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,pa.__webglLineBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,ob,va)}if(Sc){wa=0;for(ec=Sc.length;wa<ec;wa++)if(x=Sc[wa],x.__original.needsUpdate){y=0;if(1===x.size)if(void 0===x.boundTo||"vertices"===x.boundTo){E=0;for($=ra.length;E<$;E++)T=Ya[ra[E]],x.array[y]=x.value[T.a],x.array[y+1]=x.value[T.b],x.array[y+2]=x.value[T.c],y+=3;E=0;for($=sa.length;E<$;E++)T=Ya[sa[E]],x.array[y]=x.value[T.a],x.array[y+1]=x.value[T.b],x.array[y+2]=x.value[T.c],x.array[y+3]=
x.value[T.d],y+=4}else{if("faces"===x.boundTo){E=0;for($=ra.length;E<$;E++)xa=x.value[ra[E]],x.array[y]=xa,x.array[y+1]=xa,x.array[y+2]=xa,y+=3;E=0;for($=sa.length;E<$;E++)xa=x.value[sa[E]],x.array[y]=xa,x.array[y+1]=xa,x.array[y+2]=xa,x.array[y+3]=xa,y+=4}}else if(2===x.size)if(void 0===x.boundTo||"vertices"===x.boundTo){E=0;for($=ra.length;E<$;E++)T=Ya[ra[E]],V=x.value[T.a],W=x.value[T.b],X=x.value[T.c],x.array[y]=V.x,x.array[y+1]=V.y,x.array[y+2]=W.x,x.array[y+3]=W.y,x.array[y+4]=X.x,x.array[y+
5]=X.y,y+=6;E=0;for($=sa.length;E<$;E++)T=Ya[sa[E]],V=x.value[T.a],W=x.value[T.b],X=x.value[T.c],oa=x.value[T.d],x.array[y]=V.x,x.array[y+1]=V.y,x.array[y+2]=W.x,x.array[y+3]=W.y,x.array[y+4]=X.x,x.array[y+5]=X.y,x.array[y+6]=oa.x,x.array[y+7]=oa.y,y+=8}else{if("faces"===x.boundTo){E=0;for($=ra.length;E<$;E++)X=W=V=xa=x.value[ra[E]],x.array[y]=V.x,x.array[y+1]=V.y,x.array[y+2]=W.x,x.array[y+3]=W.y,x.array[y+4]=X.x,x.array[y+5]=X.y,y+=6;E=0;for($=sa.length;E<$;E++)oa=X=W=V=xa=x.value[sa[E]],x.array[y]=
V.x,x.array[y+1]=V.y,x.array[y+2]=W.x,x.array[y+3]=W.y,x.array[y+4]=X.x,x.array[y+5]=X.y,x.array[y+6]=oa.x,x.array[y+7]=oa.y,y+=8}}else if(3===x.size){var ea;ea="c"===x.type?["r","g","b"]:["x","y","z"];if(void 0===x.boundTo||"vertices"===x.boundTo){E=0;for($=ra.length;E<$;E++)T=Ya[ra[E]],V=x.value[T.a],W=x.value[T.b],X=x.value[T.c],x.array[y]=V[ea[0]],x.array[y+1]=V[ea[1]],x.array[y+2]=V[ea[2]],x.array[y+3]=W[ea[0]],x.array[y+4]=W[ea[1]],x.array[y+5]=W[ea[2]],x.array[y+6]=X[ea[0]],x.array[y+7]=X[ea[1]],
x.array[y+8]=X[ea[2]],y+=9;E=0;for($=sa.length;E<$;E++)T=Ya[sa[E]],V=x.value[T.a],W=x.value[T.b],X=x.value[T.c],oa=x.value[T.d],x.array[y]=V[ea[0]],x.array[y+1]=V[ea[1]],x.array[y+2]=V[ea[2]],x.array[y+3]=W[ea[0]],x.array[y+4]=W[ea[1]],x.array[y+5]=W[ea[2]],x.array[y+6]=X[ea[0]],x.array[y+7]=X[ea[1]],x.array[y+8]=X[ea[2]],x.array[y+9]=oa[ea[0]],x.array[y+10]=oa[ea[1]],x.array[y+11]=oa[ea[2]],y+=12}else if("faces"===x.boundTo){E=0;for($=ra.length;E<$;E++)X=W=V=xa=x.value[ra[E]],x.array[y]=V[ea[0]],
x.array[y+1]=V[ea[1]],x.array[y+2]=V[ea[2]],x.array[y+3]=W[ea[0]],x.array[y+4]=W[ea[1]],x.array[y+5]=W[ea[2]],x.array[y+6]=X[ea[0]],x.array[y+7]=X[ea[1]],x.array[y+8]=X[ea[2]],y+=9;E=0;for($=sa.length;E<$;E++)oa=X=W=V=xa=x.value[sa[E]],x.array[y]=V[ea[0]],x.array[y+1]=V[ea[1]],x.array[y+2]=V[ea[2]],x.array[y+3]=W[ea[0]],x.array[y+4]=W[ea[1]],x.array[y+5]=W[ea[2]],x.array[y+6]=X[ea[0]],x.array[y+7]=X[ea[1]],x.array[y+8]=X[ea[2]],x.array[y+9]=oa[ea[0]],x.array[y+10]=oa[ea[1]],x.array[y+11]=oa[ea[2]],
y+=12}else if("faceVertices"===x.boundTo){E=0;for($=ra.length;E<$;E++)xa=x.value[ra[E]],V=xa[0],W=xa[1],X=xa[2],x.array[y]=V[ea[0]],x.array[y+1]=V[ea[1]],x.array[y+2]=V[ea[2]],x.array[y+3]=W[ea[0]],x.array[y+4]=W[ea[1]],x.array[y+5]=W[ea[2]],x.array[y+6]=X[ea[0]],x.array[y+7]=X[ea[1]],x.array[y+8]=X[ea[2]],y+=9;E=0;for($=sa.length;E<$;E++)xa=x.value[sa[E]],V=xa[0],W=xa[1],X=xa[2],oa=xa[3],x.array[y]=V[ea[0]],x.array[y+1]=V[ea[1]],x.array[y+2]=V[ea[2]],x.array[y+3]=W[ea[0]],x.array[y+4]=W[ea[1]],x.array[y+
5]=W[ea[2]],x.array[y+6]=X[ea[0]],x.array[y+7]=X[ea[1]],x.array[y+8]=X[ea[2]],x.array[y+9]=oa[ea[0]],x.array[y+10]=oa[ea[1]],x.array[y+11]=oa[ea[2]],y+=12}}else if(4===x.size)if(void 0===x.boundTo||"vertices"===x.boundTo){E=0;for($=ra.length;E<$;E++)T=Ya[ra[E]],V=x.value[T.a],W=x.value[T.b],X=x.value[T.c],x.array[y]=V.x,x.array[y+1]=V.y,x.array[y+2]=V.z,x.array[y+3]=V.w,x.array[y+4]=W.x,x.array[y+5]=W.y,x.array[y+6]=W.z,x.array[y+7]=W.w,x.array[y+8]=X.x,x.array[y+9]=X.y,x.array[y+10]=X.z,x.array[y+
11]=X.w,y+=12;E=0;for($=sa.length;E<$;E++)T=Ya[sa[E]],V=x.value[T.a],W=x.value[T.b],X=x.value[T.c],oa=x.value[T.d],x.array[y]=V.x,x.array[y+1]=V.y,x.array[y+2]=V.z,x.array[y+3]=V.w,x.array[y+4]=W.x,x.array[y+5]=W.y,x.array[y+6]=W.z,x.array[y+7]=W.w,x.array[y+8]=X.x,x.array[y+9]=X.y,x.array[y+10]=X.z,x.array[y+11]=X.w,x.array[y+12]=oa.x,x.array[y+13]=oa.y,x.array[y+14]=oa.z,x.array[y+15]=oa.w,y+=16}else if("faces"===x.boundTo){E=0;for($=ra.length;E<$;E++)X=W=V=xa=x.value[ra[E]],x.array[y]=V.x,x.array[y+
1]=V.y,x.array[y+2]=V.z,x.array[y+3]=V.w,x.array[y+4]=W.x,x.array[y+5]=W.y,x.array[y+6]=W.z,x.array[y+7]=W.w,x.array[y+8]=X.x,x.array[y+9]=X.y,x.array[y+10]=X.z,x.array[y+11]=X.w,y+=12;E=0;for($=sa.length;E<$;E++)oa=X=W=V=xa=x.value[sa[E]],x.array[y]=V.x,x.array[y+1]=V.y,x.array[y+2]=V.z,x.array[y+3]=V.w,x.array[y+4]=W.x,x.array[y+5]=W.y,x.array[y+6]=W.z,x.array[y+7]=W.w,x.array[y+8]=X.x,x.array[y+9]=X.y,x.array[y+10]=X.z,x.array[y+11]=X.w,x.array[y+12]=oa.x,x.array[y+13]=oa.y,x.array[y+14]=oa.z,
x.array[y+15]=oa.w,y+=16}else if("faceVertices"===x.boundTo){E=0;for($=ra.length;E<$;E++)xa=x.value[ra[E]],V=xa[0],W=xa[1],X=xa[2],x.array[y]=V.x,x.array[y+1]=V.y,x.array[y+2]=V.z,x.array[y+3]=V.w,x.array[y+4]=W.x,x.array[y+5]=W.y,x.array[y+6]=W.z,x.array[y+7]=W.w,x.array[y+8]=X.x,x.array[y+9]=X.y,x.array[y+10]=X.z,x.array[y+11]=X.w,y+=12;E=0;for($=sa.length;E<$;E++)xa=x.value[sa[E]],V=xa[0],W=xa[1],X=xa[2],oa=xa[3],x.array[y]=V.x,x.array[y+1]=V.y,x.array[y+2]=V.z,x.array[y+3]=V.w,x.array[y+4]=W.x,
x.array[y+5]=W.y,x.array[y+6]=W.z,x.array[y+7]=W.w,x.array[y+8]=X.x,x.array[y+9]=X.y,x.array[y+10]=X.z,x.array[y+11]=X.w,x.array[y+12]=oa.x,x.array[y+13]=oa.y,x.array[y+14]=oa.z,x.array[y+15]=oa.w,y+=16}k.bindBuffer(k.ARRAY_BUFFER,x.buffer);k.bufferData(k.ARRAY_BUFFER,x.array,va)}}db&&(delete pa.__inittedArrays,delete pa.__colorArray,delete pa.__normalArray,delete pa.__tangentArray,delete pa.__uvArray,delete pa.__uv2Array,delete pa.__faceArray,delete pa.__vertexArray,delete pa.__lineArray,delete pa.__skinIndexArray,
delete pa.__skinWeightArray)}}fa.verticesNeedUpdate=!1;fa.morphTargetsNeedUpdate=!1;fa.elementsNeedUpdate=!1;fa.uvsNeedUpdate=!1;fa.normalsNeedUpdate=!1;fa.colorsNeedUpdate=!1;fa.tangentsNeedUpdate=!1;fa.buffersNeedUpdate=!1;ja.attributes&&r(ja)}else if(Aa instanceof THREE.Ribbon){ja=e(Aa,fa);ua=ja.attributes&&s(ja);if(fa.verticesNeedUpdate||fa.colorsNeedUpdate||fa.normalsNeedUpdate||ua){var vb=fa,zc=k.DYNAMIC_DRAW,pc=void 0,qc=void 0,rc=void 0,Ac=void 0,ya=void 0,Bc=void 0,Cc=void 0,Dc=void 0,Xc=
void 0,Va=void 0,kc=void 0,Ba=void 0,jb=void 0,Yc=vb.vertices,Zc=vb.colors,$c=vb.normals,hd=Yc.length,id=Zc.length,jd=$c.length,Ec=vb.__vertexArray,Fc=vb.__colorArray,Gc=vb.__normalArray,kd=vb.colorsNeedUpdate,ld=vb.normalsNeedUpdate,Vc=vb.__webglCustomAttributesList;if(vb.verticesNeedUpdate){for(pc=0;pc<hd;pc++)Ac=Yc[pc],ya=3*pc,Ec[ya]=Ac.x,Ec[ya+1]=Ac.y,Ec[ya+2]=Ac.z;k.bindBuffer(k.ARRAY_BUFFER,vb.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,Ec,zc)}if(kd){for(qc=0;qc<id;qc++)Bc=Zc[qc],ya=3*
qc,Fc[ya]=Bc.r,Fc[ya+1]=Bc.g,Fc[ya+2]=Bc.b;k.bindBuffer(k.ARRAY_BUFFER,vb.__webglColorBuffer);k.bufferData(k.ARRAY_BUFFER,Fc,zc)}if(ld){for(rc=0;rc<jd;rc++)Cc=$c[rc],ya=3*rc,Gc[ya]=Cc.x,Gc[ya+1]=Cc.y,Gc[ya+2]=Cc.z;k.bindBuffer(k.ARRAY_BUFFER,vb.__webglNormalBuffer);k.bufferData(k.ARRAY_BUFFER,Gc,zc)}if(Vc){Dc=0;for(Xc=Vc.length;Dc<Xc;Dc++)if(Ba=Vc[Dc],Ba.needsUpdate&&(void 0===Ba.boundTo||"vertices"===Ba.boundTo)){ya=0;kc=Ba.value.length;if(1===Ba.size)for(Va=0;Va<kc;Va++)Ba.array[Va]=Ba.value[Va];
else if(2===Ba.size)for(Va=0;Va<kc;Va++)jb=Ba.value[Va],Ba.array[ya]=jb.x,Ba.array[ya+1]=jb.y,ya+=2;else if(3===Ba.size)if("c"===Ba.type)for(Va=0;Va<kc;Va++)jb=Ba.value[Va],Ba.array[ya]=jb.r,Ba.array[ya+1]=jb.g,Ba.array[ya+2]=jb.b,ya+=3;else for(Va=0;Va<kc;Va++)jb=Ba.value[Va],Ba.array[ya]=jb.x,Ba.array[ya+1]=jb.y,Ba.array[ya+2]=jb.z,ya+=3;else if(4===Ba.size)for(Va=0;Va<kc;Va++)jb=Ba.value[Va],Ba.array[ya]=jb.x,Ba.array[ya+1]=jb.y,Ba.array[ya+2]=jb.z,Ba.array[ya+3]=jb.w,ya+=4;k.bindBuffer(k.ARRAY_BUFFER,
Ba.buffer);k.bufferData(k.ARRAY_BUFFER,Ba.array,zc)}}}fa.verticesNeedUpdate=!1;fa.colorsNeedUpdate=!1;fa.normalsNeedUpdate=!1;ja.attributes&&r(ja)}else if(Aa instanceof THREE.Line){ja=e(Aa,fa);ua=ja.attributes&&s(ja);if(fa.verticesNeedUpdate||fa.colorsNeedUpdate||fa.lineDistancesNeedUpdate||ua){var wb=fa,Hc=k.DYNAMIC_DRAW,sc=void 0,tc=void 0,uc=void 0,Ic=void 0,Ga=void 0,Jc=void 0,ad=wb.vertices,bd=wb.colors,cd=wb.lineDistances,md=ad.length,nd=bd.length,od=cd.length,Kc=wb.__vertexArray,Lc=wb.__colorArray,
dd=wb.__lineDistanceArray,pd=wb.colorsNeedUpdate,qd=wb.lineDistancesNeedUpdate,Wc=wb.__webglCustomAttributesList,Mc=void 0,ed=void 0,Wa=void 0,lc=void 0,kb=void 0,Ca=void 0;if(wb.verticesNeedUpdate){for(sc=0;sc<md;sc++)Ic=ad[sc],Ga=3*sc,Kc[Ga]=Ic.x,Kc[Ga+1]=Ic.y,Kc[Ga+2]=Ic.z;k.bindBuffer(k.ARRAY_BUFFER,wb.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,Kc,Hc)}if(pd){for(tc=0;tc<nd;tc++)Jc=bd[tc],Ga=3*tc,Lc[Ga]=Jc.r,Lc[Ga+1]=Jc.g,Lc[Ga+2]=Jc.b;k.bindBuffer(k.ARRAY_BUFFER,wb.__webglColorBuffer);k.bufferData(k.ARRAY_BUFFER,
Lc,Hc)}if(qd){for(uc=0;uc<od;uc++)dd[uc]=cd[uc];k.bindBuffer(k.ARRAY_BUFFER,wb.__webglLineDistanceBuffer);k.bufferData(k.ARRAY_BUFFER,dd,Hc)}if(Wc){Mc=0;for(ed=Wc.length;Mc<ed;Mc++)if(Ca=Wc[Mc],Ca.needsUpdate&&(void 0===Ca.boundTo||"vertices"===Ca.boundTo)){Ga=0;lc=Ca.value.length;if(1===Ca.size)for(Wa=0;Wa<lc;Wa++)Ca.array[Wa]=Ca.value[Wa];else if(2===Ca.size)for(Wa=0;Wa<lc;Wa++)kb=Ca.value[Wa],Ca.array[Ga]=kb.x,Ca.array[Ga+1]=kb.y,Ga+=2;else if(3===Ca.size)if("c"===Ca.type)for(Wa=0;Wa<lc;Wa++)kb=
Ca.value[Wa],Ca.array[Ga]=kb.r,Ca.array[Ga+1]=kb.g,Ca.array[Ga+2]=kb.b,Ga+=3;else for(Wa=0;Wa<lc;Wa++)kb=Ca.value[Wa],Ca.array[Ga]=kb.x,Ca.array[Ga+1]=kb.y,Ca.array[Ga+2]=kb.z,Ga+=3;else if(4===Ca.size)for(Wa=0;Wa<lc;Wa++)kb=Ca.value[Wa],Ca.array[Ga]=kb.x,Ca.array[Ga+1]=kb.y,Ca.array[Ga+2]=kb.z,Ca.array[Ga+3]=kb.w,Ga+=4;k.bindBuffer(k.ARRAY_BUFFER,Ca.buffer);k.bufferData(k.ARRAY_BUFFER,Ca.array,Hc)}}}fa.verticesNeedUpdate=!1;fa.colorsNeedUpdate=!1;fa.lineDistancesNeedUpdate=!1;ja.attributes&&r(ja)}else Aa instanceof
THREE.ParticleSystem&&(fa instanceof THREE.BufferGeometry?((fa.verticesNeedUpdate||fa.colorsNeedUpdate)&&j(fa,k.DYNAMIC_DRAW,!fa.dynamic),fa.verticesNeedUpdate=!1,fa.colorsNeedUpdate=!1):(ja=e(Aa,fa),ua=ja.attributes&&s(ja),(fa.verticesNeedUpdate||fa.colorsNeedUpdate||Aa.sortParticles||ua)&&i(fa,k.DYNAMIC_DRAW,Aa),fa.verticesNeedUpdate=!1,fa.colorsNeedUpdate=!1,ja.attributes&&r(ja)))}};this.initMaterial=function(a,b,c,d){var e,f,g,h,i,j,l,m,n;a instanceof THREE.MeshDepthMaterial?n="depth":a instanceof
THREE.MeshNormalMaterial?n="normal":a instanceof THREE.MeshBasicMaterial?n="basic":a instanceof THREE.MeshLambertMaterial?n="lambert":a instanceof THREE.MeshPhongMaterial?n="phong":a instanceof THREE.LineBasicMaterial?n="basic":a instanceof THREE.LineDashedMaterial?n="dashed":a instanceof THREE.ParticleBasicMaterial&&(n="particle_basic");if(n){var o=THREE.ShaderLib[n];a.uniforms=THREE.UniformsUtils.clone(o.uniforms);a.vertexShader=o.vertexShader;a.fragmentShader=o.fragmentShader}var p,q,r;e=p=q=r=
o=0;for(f=b.length;e<f;e++)g=b[e],g.onlyShadow||(g instanceof THREE.DirectionalLight&&p++,g instanceof THREE.PointLight&&q++,g instanceof THREE.SpotLight&&r++,g instanceof THREE.HemisphereLight&&o++);e=p;f=q;g=r;h=o;o=p=0;for(r=b.length;o<r;o++)q=b[o],q.castShadow&&(q instanceof THREE.SpotLight&&p++,q instanceof THREE.DirectionalLight&&!q.shadowCascade&&p++);m=p;fc&&d&&d.useVertexTexture?l=1024:(b=k.getParameter(k.MAX_VERTEX_UNIFORM_VECTORS),b=Math.floor((b-20)/4),void 0!==d&&d instanceof THREE.SkinnedMesh&&
(b=Math.min(d.bones.length,b),b<d.bones.length&&console.warn("WebGLRenderer: too many bones - "+d.bones.length+", this GPU supports just "+b+" (try OpenGL instead of ANGLE)")),l=b);var s;a:{q=a.fragmentShader;r=a.vertexShader;o=a.uniforms;b=a.attributes;p=a.defines;var c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,bumpMap:!!a.bumpMap,normalMap:!!a.normalMap,specularMap:!!a.specularMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,fogExp:c instanceof THREE.FogExp2,sizeAttenuation:a.sizeAttenuation,
skinning:a.skinning,maxBones:l,useVertexTexture:fc&&d&&d.useVertexTexture,boneTextureWidth:d&&d.boneTextureWidth,boneTextureHeight:d&&d.boneTextureHeight,morphTargets:a.morphTargets,morphNormals:a.morphNormals,maxMorphTargets:this.maxMorphTargets,maxMorphNormals:this.maxMorphNormals,maxDirLights:e,maxPointLights:f,maxSpotLights:g,maxHemiLights:h,maxShadows:m,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapDebug:this.shadowMapDebug,shadowMapCascade:this.shadowMapCascade,
alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround,doubleSided:a.side===THREE.DoubleSide,flipSided:a.side===THREE.BackSide},t,u,v,d=[];n?d.push(n):(d.push(q),d.push(r));for(u in p)d.push(u),d.push(p[u]);for(t in c)d.push(t),d.push(c[t]);n=d.join();t=0;for(u=qa.length;t<u;t++)if(d=qa[t],d.code===n){d.usedTimes++;s=d.program;break a}t=[];for(v in p)u=p[v],!1!==u&&(u="#define "+v+" "+u,t.push(u));u=t.join("\n");v=k.createProgram();t=["precision "+M+" float;",u,ec?"#define VERTEX_TEXTURES":
"",J.gammaInput?"#define GAMMA_INPUT":"",J.gammaOutput?"#define GAMMA_OUTPUT":"",J.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_HEMI_LIGHTS "+c.maxHemiLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.bumpMap?"#define USE_BUMPMAP":
"",c.normalMap?"#define USE_NORMALMAP":"",c.specularMap?"#define USE_SPECULARMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.useVertexTexture?"#define BONE_TEXTURE":"",c.boneTextureWidth?"#define N_BONE_PIXEL_X "+c.boneTextureWidth.toFixed(1):"",c.boneTextureHeight?"#define N_BONE_PIXEL_Y "+c.boneTextureHeight.toFixed(1):"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?
"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.flipSided?"#define FLIP_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
u=["precision "+M+" float;",c.bumpMap||c.normalMap?"#extension GL_OES_standard_derivatives : enable":"",u,"#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_HEMI_LIGHTS "+c.maxHemiLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",J.gammaInput?"#define GAMMA_INPUT":"",J.gammaOutput?"#define GAMMA_OUTPUT":"",J.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",
485
c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fogExp?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.bumpMap?"#define USE_BUMPMAP":"",c.normalMap?"#define USE_NORMALMAP":"",c.specularMap?"#define USE_SPECULARMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.flipSided?"#define FLIP_SIDED":
486
"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");u=I("fragment",u+q);t=I("vertex",t+r);k.attachShader(v,t);k.attachShader(v,u);k.linkProgram(v);k.getProgramParameter(v,k.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+k.getProgramParameter(v,k.VALIDATE_STATUS)+
487 488 489 490 491 492 493 494 495 496 497 498
", gl error ["+k.getError()+"]");k.deleteShader(u);k.deleteShader(t);v.uniforms={};v.attributes={};var w;t="viewMatrix modelViewMatrix projectionMatrix normalMatrix modelMatrix cameraPosition morphTargetInfluences".split(" ");c.useVertexTexture?t.push("boneTexture"):t.push("boneGlobalMatrices");for(w in o)t.push(w);w=t;t=0;for(u=w.length;t<u;t++)d=w[t],v.uniforms[d]=k.getUniformLocation(v,d);t="position normal uv uv2 tangent color skinIndex skinWeight lineDistance".split(" ");for(w=0;w<c.maxMorphTargets;w++)t.push("morphTarget"+
w);for(w=0;w<c.maxMorphNormals;w++)t.push("morphNormal"+w);for(s in b)t.push(s);s=t;w=0;for(b=s.length;w<b;w++)t=s[w],v.attributes[t]=k.getAttribLocation(v,t);v.id=S++;qa.push({program:v,code:n,usedTimes:1});J.info.memory.programs=qa.length;s=v}a.program=s;s=a.program.attributes;0<=s.position&&k.enableVertexAttribArray(s.position);0<=s.color&&k.enableVertexAttribArray(s.color);0<=s.normal&&k.enableVertexAttribArray(s.normal);0<=s.tangent&&k.enableVertexAttribArray(s.tangent);0<=s.lineDistance&&k.enableVertexAttribArray(s.lineDistance);
a.skinning&&(0<=s.skinIndex&&0<=s.skinWeight)&&(k.enableVertexAttribArray(s.skinIndex),k.enableVertexAttribArray(s.skinWeight));if(a.attributes)for(j in a.attributes)void 0!==s[j]&&0<=s[j]&&k.enableVertexAttribArray(s[j]);if(a.morphTargets){a.numSupportedMorphTargets=0;v="morphTarget";for(j=0;j<this.maxMorphTargets;j++)w=v+j,0<=s[w]&&(k.enableVertexAttribArray(s[w]),a.numSupportedMorphTargets++)}if(a.morphNormals){a.numSupportedMorphNormals=0;v="morphNormal";for(j=0;j<this.maxMorphNormals;j++)w=v+
j,0<=s[w]&&(k.enableVertexAttribArray(s[w]),a.numSupportedMorphNormals++)}a.uniformsList=[];for(i in a.uniforms)a.uniformsList.push([a.uniforms[i],i])};this.setFaceCulling=function(a,b){a?(!b||"ccw"===b?k.frontFace(k.CCW):k.frontFace(k.CW),"back"===a?k.cullFace(k.BACK):"front"===a?k.cullFace(k.FRONT):k.cullFace(k.FRONT_AND_BACK),k.enable(k.CULL_FACE)):k.disable(k.CULL_FACE)};this.setMaterialFaces=function(a){var b=a.side===THREE.DoubleSide,a=a.side===THREE.BackSide;Aa!==b&&(b?k.disable(k.CULL_FACE):
k.enable(k.CULL_FACE),Aa=b);Ja!==a&&(a?k.frontFace(k.CW):k.frontFace(k.CCW),Ja=a)};this.setDepthTest=function(a){Ua!==a&&(a?k.enable(k.DEPTH_TEST):k.disable(k.DEPTH_TEST),Ua=a)};this.setDepthWrite=function(a){gb!==a&&(k.depthMask(a),gb=a)};this.setBlending=function(a,b,c,d){a!==Ta&&(a===THREE.NoBlending?k.disable(k.BLEND):a===THREE.AdditiveBlending?(k.enable(k.BLEND),k.blendEquation(k.FUNC_ADD),k.blendFunc(k.SRC_ALPHA,k.ONE)):a===THREE.SubtractiveBlending?(k.enable(k.BLEND),k.blendEquation(k.FUNC_ADD),
k.blendFunc(k.ZERO,k.ONE_MINUS_SRC_COLOR)):a===THREE.MultiplyBlending?(k.enable(k.BLEND),k.blendEquation(k.FUNC_ADD),k.blendFunc(k.ZERO,k.SRC_COLOR)):a===THREE.CustomBlending?k.enable(k.BLEND):(k.enable(k.BLEND),k.blendEquationSeparate(k.FUNC_ADD,k.FUNC_ADD),k.blendFuncSeparate(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA,k.ONE,k.ONE_MINUS_SRC_ALPHA)),Ta=a);if(a===THREE.CustomBlending){if(b!==ta&&(k.blendEquation(H(b)),ta=b),c!==db||d!==xb)k.blendFunc(H(c),H(d)),db=c,xb=d}else xb=db=ta=null};this.setTexture=
function(a,b){if(a.needsUpdate){a.__webglInit||(a.__webglInit=!0,a.__webglTexture=k.createTexture(),J.info.memory.textures++);k.activeTexture(k.TEXTURE0+b);k.bindTexture(k.TEXTURE_2D,a.__webglTexture);k.pixelStorei(k.UNPACK_FLIP_Y_WEBGL,a.flipY);k.pixelStorei(k.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha);var c=a.image,d=0===(c.width&c.width-1)&&0===(c.height&c.height-1),e=H(a.format),f=H(a.type);L(k.TEXTURE_2D,a,d);if(a instanceof THREE.CompressedTexture)for(var f=a.mipmaps,g=0,h=f.length;g<
h;g++)c=f[g],k.compressedTexImage2D(k.TEXTURE_2D,g,e,c.width,c.height,0,c.data);else a instanceof THREE.DataTexture?k.texImage2D(k.TEXTURE_2D,0,e,c.width,c.height,0,e,f,c.data):k.texImage2D(k.TEXTURE_2D,0,e,e,f,a.image);a.generateMipmaps&&d&&k.generateMipmap(k.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdate)a.onUpdate()}else k.activeTexture(k.TEXTURE0+b),k.bindTexture(k.TEXTURE_2D,a.__webglTexture)};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){void 0===
a.depthBuffer&&(a.depthBuffer=!0);void 0===a.stencilBuffer&&(a.stencilBuffer=!0);a.__webglTexture=k.createTexture();var c=0===(a.width&a.width-1)&&0===(a.height&a.height-1),d=H(a.format),e=H(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];k.bindTexture(k.TEXTURE_CUBE_MAP,a.__webglTexture);L(k.TEXTURE_CUBE_MAP,a,c);for(var f=0;6>f;f++){a.__webglFramebuffer[f]=k.createFramebuffer();a.__webglRenderbuffer[f]=k.createRenderbuffer();k.texImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,d,a.width,
a.height,0,d,e,null);var g=a,h=k.TEXTURE_CUBE_MAP_POSITIVE_X+f;k.bindFramebuffer(k.FRAMEBUFFER,a.__webglFramebuffer[f]);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,h,g.__webglTexture,0);B(a.__webglRenderbuffer[f],a)}c&&k.generateMipmap(k.TEXTURE_CUBE_MAP)}else a.__webglFramebuffer=k.createFramebuffer(),a.__webglRenderbuffer=k.createRenderbuffer(),k.bindTexture(k.TEXTURE_2D,a.__webglTexture),L(k.TEXTURE_2D,a,c),k.texImage2D(k.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=k.TEXTURE_2D,
k.bindFramebuffer(k.FRAMEBUFFER,a.__webglFramebuffer),k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,d,a.__webglTexture,0),B(a.__webglRenderbuffer,a),c&&k.generateMipmap(k.TEXTURE_2D);b?k.bindTexture(k.TEXTURE_CUBE_MAP,null):k.bindTexture(k.TEXTURE_2D,null);k.bindRenderbuffer(k.RENDERBUFFER,null);k.bindFramebuffer(k.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,e=d=0):(b=null,c=mb,a=La,d=va,e=Ha);b!==Y&&(k.bindFramebuffer(k.FRAMEBUFFER,
b),k.viewport(d,e,c,a),Y=b);Za=c;eb=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)};
A
alteredq 已提交
499 500 501 502 503 504 505
THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=void 0!==c.wrapS?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==c.wrapT?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==c.magFilter?c.magFilter:THREE.LinearFilter;this.minFilter=void 0!==c.minFilter?c.minFilter:THREE.LinearMipMapLinearFilter;this.anisotropy=void 0!==c.anisotropy?c.anisotropy:1;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=void 0!==c.format?c.format:
THREE.RGBAFormat;this.type=void 0!==c.type?c.type:THREE.UnsignedByteType;this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.generateMipmaps=!0};
THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.anisotropy=this.anisotropy;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;a.generateMipmaps=this.generateMipmaps;return a};
THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0};THREE.WebGLRenderTargetCube.prototype=Object.create(THREE.WebGLRenderTarget.prototype);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.vertexNormalsLength=0;this.material=this.color=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.vertexNormalsLength=0;this.material=this.color=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=this.object=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};
506
THREE.ColorUtils={adjustHSV:function(a,b,c,d){var e=THREE.ColorUtils.__hsv;a.getHSV(e);e.h=THREE.Math.clamp(e.h+b,0,1);e.s=THREE.Math.clamp(e.s+c,0,1);e.v=THREE.Math.clamp(e.v+d,0,1);a.setHSV(e.h,e.s,e.v)}};THREE.ColorUtils.__hsv={h:0,s:0,v:0};
A
alteredq 已提交
507
THREE.GeometryUtils={merge:function(a,b){for(var c,d,e=a.vertices.length,f=b instanceof THREE.Mesh?b.geometry:b,g=a.vertices,h=f.vertices,i=a.faces,j=f.faces,m=a.faceVertexUvs[0],n=f.faceVertexUvs[0],l={},p=0;p<a.materials.length;p++)l[a.materials[p].id]=p;b instanceof THREE.Mesh&&(b.matrixAutoUpdate&&b.updateMatrix(),c=b.matrix,d=new THREE.Matrix4,d.extractRotation(c,b.scale));for(var p=0,o=h.length;p<o;p++){var q=h[p].clone();c&&c.multiplyVector3(q);g.push(q)}p=0;for(o=j.length;p<o;p++){var g=j[p],
508 509
s,r,A=g.vertexNormals,u=g.vertexColors;g instanceof THREE.Face3?s=new THREE.Face3(g.a+e,g.b+e,g.c+e):g instanceof THREE.Face4&&(s=new THREE.Face4(g.a+e,g.b+e,g.c+e,g.d+e));s.normal.copy(g.normal);d&&d.multiplyVector3(s.normal);h=0;for(q=A.length;h<q;h++)r=A[h].clone(),d&&d.multiplyVector3(r),s.vertexNormals.push(r);s.color.copy(g.color);h=0;for(q=u.length;h<q;h++)r=u[h],s.vertexColors.push(r.clone());void 0!==g.materialIndex&&(h=f.materials[g.materialIndex],q=h.id,u=l[q],void 0===u&&(u=a.materials.length,
l[q]=u,a.materials.push(h)),s.materialIndex=u);s.centroid.copy(g.centroid);c&&c.multiplyVector3(s.centroid);i.push(s)}p=0;for(o=n.length;p<o;p++){c=n[p];d=[];h=0;for(q=c.length;h<q;h++)d.push(new THREE.UV(c[h].u,c[h].v));m.push(d)}},clone:function(a){var b=new THREE.Geometry,c,d=a.vertices,e=a.faces,f=a.faceVertexUvs[0];a.materials&&(b.materials=a.materials.slice());a=0;for(c=d.length;a<c;a++)b.vertices.push(d[a].clone());a=0;for(c=e.length;a<c;a++)b.faces.push(e[a].clone());a=0;for(c=f.length;a<
A
alteredq 已提交
510 511 512 513 514 515 516 517
c;a++){for(var d=f[a],e=[],g=0,h=d.length;g<h;g++)e.push(new THREE.UV(d[g].u,d[g].v));b.faceVertexUvs[0].push(e)}return b},randomPointInTriangle:function(a,b,c){var d,e,f,g=new THREE.Vector3,h=THREE.GeometryUtils.__v1;d=THREE.GeometryUtils.random();e=THREE.GeometryUtils.random();1<d+e&&(d=1-d,e=1-e);f=1-d-e;g.copy(a);g.multiplyScalar(d);h.copy(b);h.multiplyScalar(e);g.addSelf(h);h.copy(c);h.multiplyScalar(f);g.addSelf(h);return g},randomPointInFace:function(a,b,c){var d,e,f;if(a instanceof THREE.Face3)return d=
b.vertices[a.a],e=b.vertices[a.b],f=b.vertices[a.c],THREE.GeometryUtils.randomPointInTriangle(d,e,f);if(a instanceof THREE.Face4){d=b.vertices[a.a];e=b.vertices[a.b];f=b.vertices[a.c];var b=b.vertices[a.d],g;c?a._area1&&a._area2?(c=a._area1,g=a._area2):(c=THREE.GeometryUtils.triangleArea(d,e,b),g=THREE.GeometryUtils.triangleArea(e,f,b),a._area1=c,a._area2=g):(c=THREE.GeometryUtils.triangleArea(d,e,b),g=THREE.GeometryUtils.triangleArea(e,f,b));return THREE.GeometryUtils.random()*(c+g)<c?THREE.GeometryUtils.randomPointInTriangle(d,
e,b):THREE.GeometryUtils.randomPointInTriangle(e,f,b)}},randomPointsInGeometry:function(a,b){function c(a){function b(c,d){if(d<c)return c;var e=c+Math.floor((d-c)/2);return j[e]>a?b(c,e-1):j[e]<a?b(e+1,d):e}return b(0,j.length-1)}var d,e,f=a.faces,g=a.vertices,h=f.length,i=0,j=[],m,n,l,p;for(e=0;e<h;e++)d=f[e],d instanceof THREE.Face3?(m=g[d.a],n=g[d.b],l=g[d.c],d._area=THREE.GeometryUtils.triangleArea(m,n,l)):d instanceof THREE.Face4&&(m=g[d.a],n=g[d.b],l=g[d.c],p=g[d.d],d._area1=THREE.GeometryUtils.triangleArea(m,
n,p),d._area2=THREE.GeometryUtils.triangleArea(n,l,p),d._area=d._area1+d._area2),i+=d._area,j[e]=i;d=[];for(e=0;e<b;e++)g=THREE.GeometryUtils.random()*i,g=c(g),d[e]=THREE.GeometryUtils.randomPointInFace(f[g],a,!0);return d},triangleArea:function(a,b,c){var d,e=THREE.GeometryUtils.__v1;e.sub(a,b);d=e.length();e.sub(a,c);a=e.length();e.sub(b,c);c=e.length();b=0.5*(d+a+c);return Math.sqrt(b*(b-d)*(b-a)*(b-c))},center:function(a){a.computeBoundingBox();var b=a.boundingBox,c=new THREE.Vector3;c.add(b.min,
b.max);c.multiplyScalar(-0.5);a.applyMatrix((new THREE.Matrix4).makeTranslation(c.x,c.y,c.z));a.computeBoundingBox();return c},normalizeUVs:function(a){for(var a=a.faceVertexUvs[0],b=0,c=a.length;b<c;b++)for(var d=a[b],e=0,f=d.length;e<f;e++)if(1!==d[e].u&&(d[e].u-=Math.floor(d[e].u)),1!==d[e].v)d[e].v-=Math.floor(d[e].v)},triangulateQuads:function(a){var b,c,d,e,f=[],g=[],h=[];b=0;for(c=a.faceUvs.length;b<c;b++)g[b]=[];b=0;for(c=a.faceVertexUvs.length;b<c;b++)h[b]=[];b=0;for(c=a.faces.length;b<c;b++)if(d=
a.faces[b],d instanceof THREE.Face4){e=d.a;var i=d.b,j=d.c,m=d.d,n=new THREE.Face3,l=new THREE.Face3;n.color.copy(d.color);l.color.copy(d.color);n.materialIndex=d.materialIndex;l.materialIndex=d.materialIndex;n.a=e;n.b=i;n.c=m;l.a=i;l.b=j;l.c=m;4===d.vertexColors.length&&(n.vertexColors[0]=d.vertexColors[0].clone(),n.vertexColors[1]=d.vertexColors[1].clone(),n.vertexColors[2]=d.vertexColors[3].clone(),l.vertexColors[0]=d.vertexColors[1].clone(),l.vertexColors[1]=d.vertexColors[2].clone(),l.vertexColors[2]=
d.vertexColors[3].clone());f.push(n,l);d=0;for(e=a.faceVertexUvs.length;d<e;d++)a.faceVertexUvs[d].length&&(n=a.faceVertexUvs[d][b],i=n[1],j=n[2],m=n[3],n=[n[0].clone(),i.clone(),m.clone()],i=[i.clone(),j.clone(),m.clone()],h[d].push(n,i));d=0;for(e=a.faceUvs.length;d<e;d++)a.faceUvs[d].length&&(i=a.faceUvs[d][b],g[d].push(i,i))}else{f.push(d);d=0;for(e=a.faceUvs.length;d<e;d++)g[d].push(a.faceUvs[d][b]);d=0;for(e=a.faceVertexUvs.length;d<e;d++)h[d].push(a.faceVertexUvs[d][b])}a.faces=f;a.faceUvs=
g;a.faceVertexUvs=h;a.computeCentroids();a.computeFaceNormals();a.computeVertexNormals();a.hasTangents&&a.computeTangents()},explode:function(a){for(var b=[],c=0,d=a.faces.length;c<d;c++){var e=b.length,f=a.faces[c];if(f instanceof THREE.Face4){var g=f.a,h=f.b,i=f.c,g=a.vertices[g],h=a.vertices[h],i=a.vertices[i],j=a.vertices[f.d];b.push(g.clone());b.push(h.clone());b.push(i.clone());b.push(j.clone());f.a=e;f.b=e+1;f.c=e+2;f.d=e+3}else g=f.a,h=f.b,i=f.c,g=a.vertices[g],h=a.vertices[h],i=a.vertices[i],
518
b.push(g.clone()),b.push(h.clone()),b.push(i.clone()),f.a=e,f.b=e+1,f.c=e+2}a.vertices=b;delete a.__tmpVertices},tessellate:function(a,b){var c,d,e,f,g,h,i,j,m,n,l,p,o,q,s,r,A,u,t,F=[],z=[];c=0;for(d=a.faceVertexUvs.length;c<d;c++)z[c]=[];c=0;for(d=a.faces.length;c<d;c++)if(e=a.faces[c],e instanceof THREE.Face3)if(f=e.a,g=e.b,h=e.c,j=a.vertices[f],m=a.vertices[g],n=a.vertices[h],p=j.distanceTo(m),o=m.distanceTo(n),l=j.distanceTo(n),p>b||o>b||l>b){i=a.vertices.length;u=e.clone();t=e.clone();p>=o&&
A
alteredq 已提交
519 520
p>=l?(j=j.clone(),j.lerpSelf(m,0.5),u.a=f,u.b=i,u.c=h,t.a=i,t.b=g,t.c=h,3===e.vertexNormals.length&&(f=e.vertexNormals[0].clone(),f.lerpSelf(e.vertexNormals[1],0.5),u.vertexNormals[1].copy(f),t.vertexNormals[0].copy(f)),3===e.vertexColors.length&&(f=e.vertexColors[0].clone(),f.lerpSelf(e.vertexColors[1],0.5),u.vertexColors[1].copy(f),t.vertexColors[0].copy(f)),e=0):o>=p&&o>=l?(j=m.clone(),j.lerpSelf(n,0.5),u.a=f,u.b=g,u.c=i,t.a=i,t.b=h,t.c=f,3===e.vertexNormals.length&&(f=e.vertexNormals[1].clone(),
f.lerpSelf(e.vertexNormals[2],0.5),u.vertexNormals[2].copy(f),t.vertexNormals[0].copy(f),t.vertexNormals[1].copy(e.vertexNormals[2]),t.vertexNormals[2].copy(e.vertexNormals[0])),3===e.vertexColors.length&&(f=e.vertexColors[1].clone(),f.lerpSelf(e.vertexColors[2],0.5),u.vertexColors[2].copy(f),t.vertexColors[0].copy(f),t.vertexColors[1].copy(e.vertexColors[2]),t.vertexColors[2].copy(e.vertexColors[0])),e=1):(j=j.clone(),j.lerpSelf(n,0.5),u.a=f,u.b=g,u.c=i,t.a=i,t.b=g,t.c=h,3===e.vertexNormals.length&&
521
(f=e.vertexNormals[0].clone(),f.lerpSelf(e.vertexNormals[2],0.5),u.vertexNormals[2].copy(f),t.vertexNormals[0].copy(f)),3===e.vertexColors.length&&(f=e.vertexColors[0].clone(),f.lerpSelf(e.vertexColors[2],0.5),u.vertexColors[2].copy(f),t.vertexColors[0].copy(f)),e=2);F.push(u,t);a.vertices.push(j);f=0;for(g=a.faceVertexUvs.length;f<g;f++)a.faceVertexUvs[f].length&&(j=a.faceVertexUvs[f][c],t=j[0],h=j[1],u=j[2],0===e?(m=t.clone(),m.lerpSelf(h,0.5),j=[t.clone(),m.clone(),u.clone()],h=[m.clone(),h.clone(),
522 523 524
u.clone()]):1===e?(m=h.clone(),m.lerpSelf(u,0.5),j=[t.clone(),h.clone(),m.clone()],h=[m.clone(),u.clone(),t.clone()]):(m=t.clone(),m.lerpSelf(u,0.5),j=[t.clone(),h.clone(),m.clone()],h=[m.clone(),h.clone(),u.clone()]),z[f].push(j,h))}else{F.push(e);f=0;for(g=a.faceVertexUvs.length;f<g;f++)z[f].push(a.faceVertexUvs[f][c])}else if(f=e.a,g=e.b,h=e.c,i=e.d,j=a.vertices[f],m=a.vertices[g],n=a.vertices[h],l=a.vertices[i],p=j.distanceTo(m),o=m.distanceTo(n),q=n.distanceTo(l),s=j.distanceTo(l),p>b||o>b||
q>b||s>b){r=a.vertices.length;A=a.vertices.length+1;u=e.clone();t=e.clone();p>=o&&p>=q&&p>=s||q>=o&&q>=p&&q>=s?(p=j.clone(),p.lerpSelf(m,0.5),m=n.clone(),m.lerpSelf(l,0.5),u.a=f,u.b=r,u.c=A,u.d=i,t.a=r,t.b=g,t.c=h,t.d=A,4===e.vertexNormals.length&&(f=e.vertexNormals[0].clone(),f.lerpSelf(e.vertexNormals[1],0.5),g=e.vertexNormals[2].clone(),g.lerpSelf(e.vertexNormals[3],0.5),u.vertexNormals[1].copy(f),u.vertexNormals[2].copy(g),t.vertexNormals[0].copy(f),t.vertexNormals[3].copy(g)),4===e.vertexColors.length&&
(f=e.vertexColors[0].clone(),f.lerpSelf(e.vertexColors[1],0.5),g=e.vertexColors[2].clone(),g.lerpSelf(e.vertexColors[3],0.5),u.vertexColors[1].copy(f),u.vertexColors[2].copy(g),t.vertexColors[0].copy(f),t.vertexColors[3].copy(g)),e=0):(p=m.clone(),p.lerpSelf(n,0.5),m=l.clone(),m.lerpSelf(j,0.5),u.a=f,u.b=g,u.c=r,u.d=A,t.a=A,t.b=r,t.c=h,t.d=i,4===e.vertexNormals.length&&(f=e.vertexNormals[1].clone(),f.lerpSelf(e.vertexNormals[2],0.5),g=e.vertexNormals[3].clone(),g.lerpSelf(e.vertexNormals[0],0.5),
525
u.vertexNormals[2].copy(f),u.vertexNormals[3].copy(g),t.vertexNormals[0].copy(g),t.vertexNormals[1].copy(f)),4===e.vertexColors.length&&(f=e.vertexColors[1].clone(),f.lerpSelf(e.vertexColors[2],0.5),g=e.vertexColors[3].clone(),g.lerpSelf(e.vertexColors[0],0.5),u.vertexColors[2].copy(f),u.vertexColors[3].copy(g),t.vertexColors[0].copy(g),t.vertexColors[1].copy(f)),e=1);F.push(u,t);a.vertices.push(p,m);f=0;for(g=a.faceVertexUvs.length;f<g;f++)a.faceVertexUvs[f].length&&(j=a.faceVertexUvs[f][c],t=j[0],
526
h=j[1],u=j[2],j=j[3],0===e?(m=t.clone(),m.lerpSelf(h,0.5),n=u.clone(),n.lerpSelf(j,0.5),t=[t.clone(),m.clone(),n.clone(),j.clone()],h=[m.clone(),h.clone(),u.clone(),n.clone()]):(m=h.clone(),m.lerpSelf(u,0.5),n=j.clone(),n.lerpSelf(t,0.5),t=[t.clone(),h.clone(),m.clone(),n.clone()],h=[n.clone(),m.clone(),u.clone(),j.clone()]),z[f].push(t,h))}else{F.push(e);f=0;for(g=a.faceVertexUvs.length;f<g;f++)z[f].push(a.faceVertexUvs[f][c])}a.faces=F;a.faceVertexUvs=z}};THREE.GeometryUtils.random=THREE.Math.random16;
A
alteredq 已提交
527 528 529 530 531 532 533
THREE.GeometryUtils.__v1=new THREE.Vector3;
THREE.ImageUtils={crossOrigin:"anonymous",loadTexture:function(a,b,c,d){var e=new Image,f=new THREE.Texture(e,b),b=new THREE.ImageLoader;b.addEventListener("load",function(a){f.image=a.content;f.needsUpdate=!0;c&&c(f)});b.addEventListener("error",function(a){d&&d(a.message)});b.crossOrigin=this.crossOrigin;b.load(a,e);f.sourceFile=a;return f},loadCompressedTexture:function(a,b,c,d){var e=new THREE.CompressedTexture;e.mapping=b;var f=new XMLHttpRequest;f.onload=function(){var a=THREE.ImageUtils.parseDDS(f.response,
!0);e.format=a.format;e.mipmaps=a.mipmaps;e.image.width=a.width;e.image.height=a.height;e.generateMipmaps=!1;e.needsUpdate=!0;c&&c(e)};f.onerror=d;f.open("GET",a,!0);f.responseType="arraybuffer";f.send(null);return e},loadTextureCube:function(a,b,c,d){var e=[];e.loadCount=0;var f=new THREE.Texture;f.image=e;void 0!==b&&(f.mapping=b);f.flipY=!1;for(var b=0,g=a.length;b<g;++b){var h=new Image;e[b]=h;h.onload=function(){e.loadCount=e.loadCount+1;if(e.loadCount===6){f.needsUpdate=true;c&&c()}};h.onerror=
d;h.crossOrigin=this.crossOrigin;h.src=a[b]}return f},loadCompressedTextureCube:function(a,b,c,d){var e=[];e.loadCount=0;var f=new THREE.CompressedTexture;f.image=e;void 0!==b&&(f.mapping=b);f.flipY=!1;f.generateMipmaps=!1;for(var b=function(a,b){return function(){var d=THREE.ImageUtils.parseDDS(a.response,true);b.format=d.format;b.mipmaps=d.mipmaps;b.width=d.width;b.height=d.height;e.loadCount=e.loadCount+1;if(e.loadCount===6){f.format=d.format;f.needsUpdate=true;c&&c()}}},g=0,h=a.length;g<h;++g){var i=
{};e[g]=i;var j=new XMLHttpRequest;j.onload=b(j,i);j.onerror=d;j.open("GET",a[g],!0);j.responseType="arraybuffer";j.send(null)}return f},parseDDS:function(a,b){function c(a){return a.charCodeAt(0)+(a.charCodeAt(1)<<8)+(a.charCodeAt(2)<<16)+(a.charCodeAt(3)<<24)}var d={mipmaps:[],width:0,height:0,format:null,mipmapCount:1},e=c("DXT1"),f=c("DXT3"),g=c("DXT5"),h=new Int32Array(a,0,31);if(542327876!==h[0])return console.error("ImageUtils.parseDDS(): Invalid magic number in DDS header"),d;if(!h[20]&4)return console.error("ImageUtils.parseDDS(): Unsupported format, must contain a FourCC code"),
d;var i=h[21];switch(i){case e:e=8;d.format=THREE.RGB_S3TC_DXT1_Format;break;case f:e=16;d.format=THREE.RGBA_S3TC_DXT3_Format;break;case g:e=16;d.format=THREE.RGBA_S3TC_DXT5_Format;break;default:return console.error("ImageUtils.parseDDS(): Unsupported FourCC code: ",String.fromCharCode(i&255,i>>8&255,i>>16&255,i>>24&255)),d}d.mipmapCount=1;h[2]&131072&&!1!==b&&(d.mipmapCount=Math.max(1,h[7]));d.width=h[4];d.height=h[3];h=h[1]+4;f=d.width;g=d.height;for(i=0;i<d.mipmapCount;i++){var j=Math.max(4,f)/
4*Math.max(4,g)/4*e,m={data:new Uint8Array(a,h,j),width:f,height:g};d.mipmaps.push(m);h+=j;f=Math.max(0.5*f,1);g=Math.max(0.5*g,1)}return d},getNormalMap:function(a,b){var c=function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},b=b|1,d=a.width,e=a.height,f=document.createElement("canvas");f.width=d;f.height=e;var g=f.getContext("2d");g.drawImage(a,0,0);for(var h=g.getImageData(0,0,d,e).data,i=g.createImageData(d,e),j=i.data,m=0;m<d;m++)for(var n=0;n<e;n++){var l=
534 535
0>n-1?0:n-1,p=n+1>e-1?e-1:n+1,o=0>m-1?0:m-1,q=m+1>d-1?d-1:m+1,s=[],r=[0,0,h[4*(n*d+m)]/255*b];s.push([-1,0,h[4*(n*d+o)]/255*b]);s.push([-1,-1,h[4*(l*d+o)]/255*b]);s.push([0,-1,h[4*(l*d+m)]/255*b]);s.push([1,-1,h[4*(l*d+q)]/255*b]);s.push([1,0,h[4*(n*d+q)]/255*b]);s.push([1,1,h[4*(p*d+q)]/255*b]);s.push([0,1,h[4*(p*d+m)]/255*b]);s.push([-1,1,h[4*(p*d+o)]/255*b]);l=[];o=s.length;for(p=0;p<o;p++){var q=s[p],A=s[(p+1)%o],q=[q[0]-r[0],q[1]-r[1],q[2]-r[2]],A=[A[0]-r[0],A[1]-r[1],A[2]-r[2]];l.push(c([q[1]*
A[2]-q[2]*A[1],q[2]*A[0]-q[0]*A[2],q[0]*A[1]-q[1]*A[0]]))}s=[0,0,0];for(p=0;p<l.length;p++)s[0]+=l[p][0],s[1]+=l[p][1],s[2]+=l[p][2];s[0]/=l.length;s[1]/=l.length;s[2]/=l.length;r=4*(n*d+m);j[r]=255*((s[0]+1)/2)|0;j[r+1]=255*((s[1]+1)/2)|0;j[r+2]=255*s[2]|0;j[r+3]=255}g.putImageData(i,0,0);return f},generateDataTexture:function(a,b,c){for(var d=a*b,e=new Uint8Array(3*d),f=Math.floor(255*c.r),g=Math.floor(255*c.g),c=Math.floor(255*c.b),h=0;h<d;h++)e[3*h]=f,e[3*h+1]=g,e[3*h+2]=c;a=new THREE.DataTexture(e,
A
alteredq 已提交
536 537 538 539 540 541 542 543 544 545 546
a,b,THREE.RGBFormat);a.needsUpdate=!0;return a}};THREE.SceneUtils={createMultiMaterialObject:function(a,b){for(var c=new THREE.Object3D,d=0,e=b.length;d<e;d++)c.add(new THREE.Mesh(a,b[d]));return c},detach:function(a,b,c){a.applyMatrix(b.matrixWorld);b.remove(a);c.add(a)},attach:function(a,b,c){var d=new THREE.Matrix4;d.getInverse(c.matrixWorld);a.applyMatrix(d);b.remove(a);c.add(a)}};
THREE.WebGLRenderer&&(THREE.ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:null}},fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
vertexShader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = modelMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
normal:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},enableReflection:{type:"i",value:0},enableDisplacement:{type:"i",value:0},tDisplacement:{type:"t",value:null},tDiffuse:{type:"t",value:null},tCube:{type:"t",value:null},tNormal:{type:"t",value:null},tSpecular:{type:"t",value:null},tAO:{type:"t",value:null},uNormalScale:{type:"v2",value:new THREE.Vector2(1,
1)},uDisplacementBias:{type:"f",value:0},uDisplacementScale:{type:"f",value:1},uDiffuseColor:{type:"c",value:new THREE.Color(16777215)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(16777215)},uShininess:{type:"f",value:30},uOpacity:{type:"f",value:1},useRefract:{type:"i",value:0},uRefractionRatio:{type:"f",value:0.98},uReflectivity:{type:"f",value:0.5},uOffset:{type:"v2",value:new THREE.Vector2(0,0)},uRepeat:{type:"v2",value:new THREE.Vector2(1,
1)},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),fragmentShader:["uniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform float uOpacity;\nuniform bool enableDiffuse;\nuniform bool enableSpecular;\nuniform bool enableAO;\nuniform bool enableReflection;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tSpecular;\nuniform sampler2D tAO;\nuniform samplerCube tCube;\nuniform vec2 uNormalScale;\nuniform bool useRefract;\nuniform float uRefractionRatio;\nuniform float uReflectivity;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_HEMI_LIGHTS > 0\nuniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\nuniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\nuniform vec3 hemisphereLightPosition[ MAX_HEMI_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#endif\n#if MAX_SPOT_LIGHTS > 0\nuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\nuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\nuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\nuniform float spotLightAngle[ MAX_SPOT_LIGHTS ];\nuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\nuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif\nvarying vec3 vWorldPosition;\nvarying vec3 vViewPosition;",
THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3( 1.0 ), uOpacity );\nvec3 specularTex = vec3( 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse ) {\n#ifdef GAMMA_INPUT\nvec4 texelColor = texture2D( tDiffuse, vUv );\ntexelColor.xyz *= texelColor.xyz;\ngl_FragColor = gl_FragColor * texelColor;\n#else\ngl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );\n#endif\n}\nif( enableAO ) {\n#ifdef GAMMA_INPUT\nvec4 aoColor = texture2D( tAO, vUv );\naoColor.xyz *= aoColor.xyz;\ngl_FragColor.xyz = gl_FragColor.xyz * aoColor.xyz;\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * texture2D( tAO, vUv ).xyz;\n#endif\n}\nif( enableSpecular )\nspecularTex = texture2D( tSpecular, vUv ).xyz;\nmat3 tsb = mat3( normalize( vTangent ), normalize( vBinormal ), normalize( vNormal ) );\nvec3 finalNormal = tsb * normalTex;\n#ifdef FLIP_SIDED\nfinalNormal = -finalNormal;\n#endif\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointVector = lPosition.xyz + vViewPosition.xyz;\nfloat pointDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\npointDistance = 1.0 - min( ( length( pointVector ) / pointLightDistance[ i ] ), 1.0 );\npointVector = normalize( pointVector );\n#ifdef WRAP_AROUND\nfloat pointDiffuseWeightFull = max( dot( normal, pointVector ), 0.0 );\nfloat pointDiffuseWeightHalf = max( 0.5 * dot( normal, pointVector ) + 0.5, 0.0 );\nvec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n#else\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\n#endif\npointDiffuse += pointDistance * pointLightColor[ i ] * uDiffuseColor * pointDiffuseWeight;\nvec3 pointHalfVector = normalize( pointVector + viewPosition );\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointSpecularWeight = specularTex.r * max( pow( pointDotNormalHalf, uShininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( uShininess + 2.0001 ) / 8.0;\nvec3 schlick = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( pointVector, pointHalfVector ), 5.0 );\npointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance * specularNormalization;\n#else\npointSpecular += pointDistance * pointLightColor[ i ] * uSpecularColor * pointSpecularWeight * pointDiffuseWeight;\n#endif\n}\n#endif\n#if MAX_SPOT_LIGHTS > 0\nvec3 spotDiffuse = vec3( 0.0 );\nvec3 spotSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\nvec3 spotVector = lPosition.xyz + vViewPosition.xyz;\nfloat spotDistance = 1.0;\nif ( spotLightDistance[ i ] > 0.0 )\nspotDistance = 1.0 - min( ( length( spotVector ) / spotLightDistance[ i ] ), 1.0 );\nspotVector = normalize( spotVector );\nfloat spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );\nif ( spotEffect > spotLightAngle[ i ] ) {\nspotEffect = pow( spotEffect, spotLightExponent[ i ] );\n#ifdef WRAP_AROUND\nfloat spotDiffuseWeightFull = max( dot( normal, spotVector ), 0.0 );\nfloat spotDiffuseWeightHalf = max( 0.5 * dot( normal, spotVector ) + 0.5, 0.0 );\nvec3 spotDiffuseWeight = mix( vec3 ( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );\n#else\nfloat spotDiffuseWeight = max( dot( normal, spotVector ), 0.0 );\n#endif\nspotDiffuse += spotDistance * spotLightColor[ i ] * uDiffuseColor * spotDiffuseWeight * spotEffect;\nvec3 spotHalfVector = normalize( spotVector + viewPosition );\nfloat spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );\nfloat spotSpecularWeight = specularTex.r * max( pow( spotDotNormalHalf, uShininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( uShininess + 2.0001 ) / 8.0;\nvec3 schlick = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( spotVector, spotHalfVector ), 5.0 );\nspotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * spotDistance * specularNormalization * spotEffect;\n#else\nspotSpecular += spotDistance * spotLightColor[ i ] * uSpecularColor * spotSpecularWeight * spotDiffuseWeight * spotEffect;\n#endif\n}\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse = vec3( 0.0 );\nvec3 dirSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\n#ifdef WRAP_AROUND\nfloat directionalLightWeightingFull = max( dot( normal, dirVector ), 0.0 );\nfloat directionalLightWeightingHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );\nvec3 dirDiffuseWeight = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );\n#else\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\n#endif\ndirDiffuse += directionalLightColor[ i ] * uDiffuseColor * dirDiffuseWeight;\nvec3 dirHalfVector = normalize( dirVector + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirSpecularWeight = specularTex.r * max( pow( dirDotNormalHalf, uShininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat specularNormalization = ( uShininess + 2.0001 ) / 8.0;\nvec3 schlick = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( dirVector, dirHalfVector ), 5.0 );\ndirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;\n#else\ndirSpecular += directionalLightColor[ i ] * uSpecularColor * dirSpecularWeight * dirDiffuseWeight;\n#endif\n}\n#endif\n#if MAX_HEMI_LIGHTS > 0\nvec3 hemiDiffuse  = vec3( 0.0 );\nvec3 hemiSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( hemisphereLightPosition[ i ], 1.0 );\nvec3 lVector = normalize( lPosition.xyz + vViewPosition.xyz );\nfloat dotProduct = dot( normal, lVector );\nfloat hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\nvec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\nhemiDiffuse += uDiffuseColor * hemiColor;\nvec3 hemiHalfVectorSky = normalize( lVector + viewPosition );\nfloat hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;\nfloat hemiSpecularWeightSky = specularTex.r * max( pow( hemiDotNormalHalfSky, uShininess ), 0.0 );\nvec3 lVectorGround = normalize( -lPosition.xyz + vViewPosition.xyz );\nvec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );\nfloat hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;\nfloat hemiSpecularWeightGround = specularTex.r * max( pow( hemiDotNormalHalfGround, uShininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nfloat dotProductGround = dot( normal, lVectorGround );\nfloat specularNormalization = ( uShininess + 2.0001 ) / 8.0;\nvec3 schlickSky = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( lVector, hemiHalfVectorSky ), 5.0 );\nvec3 schlickGround = uSpecularColor + vec3( 1.0 - uSpecularColor ) * pow( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 5.0 );\nhemiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );\n#else\nhemiSpecular += uSpecularColor * hemiColor * ( hemiSpecularWeightSky + hemiSpecularWeightGround ) * hemiDiffuseWeight;\n#endif\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_HEMI_LIGHTS > 0\ntotalDiffuse += hemiDiffuse;\ntotalSpecular += hemiSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\n#if MAX_SPOT_LIGHTS > 0\ntotalDiffuse += spotDiffuse;\ntotalSpecular += spotSpecular;\n#endif\n#ifdef METAL\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * uAmbientColor + totalSpecular );\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * uAmbientColor ) + totalSpecular;\n#endif\nif ( enableReflection ) {\nvec3 vReflect;\nvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\nif ( useRefract ) {\nvReflect = refract( cameraToVertex, normal, uRefractionRatio );\n} else {\nvReflect = reflect( cameraToVertex, normal );\n}\nvec4 cubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n#ifdef GAMMA_INPUT\ncubeColor.xyz *= cubeColor.xyz;\n#endif\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularTex.r * uReflectivity );\n}",
THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["attribute vec4 tangent;\nuniform vec2 uOffset;\nuniform vec2 uRepeat;\nuniform bool enableDisplacement;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vWorldPosition;\nvarying vec3 vViewPosition;",
THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,"#ifdef USE_SKINNING\nvNormal = normalMatrix * skinnedNormal.xyz;\nvec4 skinnedTangent = skinMatrix * vec4( tangent.xyz, 0.0 );\nvTangent = normalMatrix * skinnedTangent.xyz;\n#else\nvNormal = normalMatrix * normal;\nvTangent = normalMatrix * tangent.xyz;\n#endif\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvUv = uv * uRepeat + uOffset;\nvec3 displacedPosition;\n#ifdef VERTEX_TEXTURES\nif ( enableDisplacement ) {\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\ndisplacedPosition = position + normalize( normal ) * df;\n} else {\n#ifdef USE_SKINNING\nvec4 skinVertex = vec4( position, 1.0 );\nvec4 skinned  = boneMatX * skinVertex * skinWeight.x;\nskinned \t  += boneMatY * skinVertex * skinWeight.y;\ndisplacedPosition  = skinned.xyz;\n#else\ndisplacedPosition = position;\n#endif\n}\n#else\n#ifdef USE_SKINNING\nvec4 skinVertex = vec4( position, 1.0 );\nvec4 skinned  = boneMatX * skinVertex * skinWeight.x;\nskinned \t  += boneMatY * skinVertex * skinWeight.y;\ndisplacedPosition  = skinned.xyz;\n#else\ndisplacedPosition = position;\n#endif\n#endif\nvec4 mvPosition = modelViewMatrix * vec4( displacedPosition, 1.0 );\nvec4 mPosition = modelMatrix * vec4( displacedPosition, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\nvWorldPosition = mPosition.xyz;\nvViewPosition = -mvPosition.xyz;\n#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * mPosition;\n}\n#endif\n}"].join("\n")},
cube:{uniforms:{tCube:{type:"t",value:null},tFlip:{type:"f",value:-1}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = modelMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( tFlip * wPos.x, wPos.yz ) );\n}"}}});
THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},loadFace:function(a){var b=a.familyName.toLowerCase();this.faces[b]=this.faces[b]||{};this.faces[b][a.cssFontWeight]=this.faces[b][a.cssFontWeight]||{};this.faces[b][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[b][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){for(var b=this.getFace(),c=this.size/b.resolution,d=
547 548
0,e=String(a).split(""),f=e.length,g=[],a=0;a<f;a++){var h=new THREE.Path,h=this.extractGlyphPoints(e[a],b,c,d,h),d=d+h.offset;g.push(h.path)}return{paths:g,offset:d/2}},extractGlyphPoints:function(a,b,c,d,e){var f=[],g,h,i,j,m,n,l,p,o,q,s,r=b.glyphs[a]||b.glyphs["?"];if(r){if(r.o){b=r._cachedOutline||(r._cachedOutline=r.o.split(" "));j=b.length;for(a=0;a<j;){i=b[a++];switch(i){case "m":i=b[a++]*c+d;m=b[a++]*c;e.moveTo(i,m);break;case "l":i=b[a++]*c+d;m=b[a++]*c;e.lineTo(i,m);break;case "q":i=b[a++]*
c+d;m=b[a++]*c;p=b[a++]*c+d;o=b[a++]*c;e.quadraticCurveTo(p,o,i,m);if(g=f[f.length-1]){n=g.x;l=g.y;g=1;for(h=this.divisions;g<=h;g++){var A=g/h;THREE.Shape.Utils.b2(A,n,p,i);THREE.Shape.Utils.b2(A,l,o,m)}}break;case "b":i=b[a++]*c+d;m=b[a++]*c;p=b[a++]*c+d;o=b[a++]*-c;q=b[a++]*c+d;s=b[a++]*-c;e.bezierCurveTo(i,m,p,o,q,s);if(g=f[f.length-1]){n=g.x;l=g.y;g=1;for(h=this.divisions;g<=h;g++){A=g/h;THREE.Shape.Utils.b3(A,n,p,q,i);THREE.Shape.Utils.b3(A,l,o,s,m)}}}}}return{offset:r.ha*c,path:e}}}};
A
alteredq 已提交
549
THREE.FontUtils.generateShapes=function(a,b){var b=b||{},c=b.curveSegments!==void 0?b.curveSegments:4,d=b.font!==void 0?b.font:"helvetiker",e=b.weight!==void 0?b.weight:"normal",f=b.style!==void 0?b.style:"normal";THREE.FontUtils.size=b.size!==void 0?b.size:100;THREE.FontUtils.divisions=c;THREE.FontUtils.face=d;THREE.FontUtils.weight=e;THREE.FontUtils.style=f;c=THREE.FontUtils.drawText(a).paths;d=[];e=0;for(f=c.length;e<f;e++)Array.prototype.push.apply(d,c[e].toShapes());return d};
550
(function(a){var b=function(a){for(var b=a.length,e=0,f=b-1,g=0;g<b;f=g++)e=e+(a[f].x*a[g].y-a[g].x*a[f].y);return e*0.5};a.Triangulate=function(a,d){var e=a.length;if(e<3)return null;var f=[],g=[],h=[],i,j,m;if(b(a)>0)for(j=0;j<e;j++)g[j]=j;else for(j=0;j<e;j++)g[j]=e-1-j;var n=2*e;for(j=e-1;e>2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");break}i=j;e<=i&&(i=0);j=i+1;e<=j&&(j=0);m=j+1;e<=m&&(m=0);var l;a:{l=a;var p=i,o=j,q=m,s=e,r=g,A=void 0,u=void 0,t=void 0,F=void 0,z=void 0,
551
w=void 0,v=void 0,C=void 0,D=void 0,u=l[r[p]].x,t=l[r[p]].y,F=l[r[o]].x,z=l[r[o]].y,w=l[r[q]].x,v=l[r[q]].y;if(1E-10>(F-u)*(v-t)-(z-t)*(w-u))l=false;else{for(A=0;A<s;A++)if(!(A==p||A==o||A==q)){var C=l[r[A]].x,D=l[r[A]].y,I=void 0,L=void 0,B=void 0,K=void 0,H=void 0,G=void 0,M=void 0,N=void 0,R=void 0,aa=void 0,P=void 0,O=void 0,I=B=H=void 0,I=w-F,L=v-z,B=u-w,K=t-v,H=F-u,G=z-t,M=C-u,N=D-t,R=C-F,aa=D-z,P=C-w,O=D-v,I=I*aa-L*R,H=H*N-G*M,B=B*O-K*P;if(I>=0&&B>=0&&H>=0){l=false;break a}}l=true}}if(l){f.push([a[g[i]],
A
alteredq 已提交
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
a[g[j]],a[g[m]]]);h.push([g[i],g[j],g[m]]);i=j;for(m=j+1;m<e;i++,m++)g[i]=g[m];e--;n=2*e}}return d?h:f};a.Triangulate.area=b;return a})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(a){a=this.getUtoTmapping(a);return this.getPoint(a)};
THREE.Curve.prototype.getPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPoint(b/a));return c};THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPointAt(b/a));return c};THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]};
THREE.Curve.prototype.getLengths=function(a){a||(a=this.__arcLengthDivisions?this.__arcLengthDivisions:200);if(this.cacheArcLengths&&this.cacheArcLengths.length==a+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=false;var b=[],c,d=this.getPoint(0),e,f=0;b.push(0);for(e=1;e<=a;e++){c=this.getPoint(e/a);f=f+c.distanceTo(d);b.push(f);d=c}return this.cacheArcLengths=b};THREE.Curve.prototype.updateArcLengths=function(){this.needsUpdate=true;this.getLengths()};
THREE.Curve.prototype.getUtoTmapping=function(a,b){var c=this.getLengths(),d=0,e=c.length,f;f=b?b:a*c[e-1];for(var g=0,h=e-1,i;g<=h;){d=Math.floor(g+(h-g)/2);i=c[d]-f;if(i<0)g=d+1;else if(i>0)h=d-1;else{h=d;break}}d=h;if(c[d]==f)return d/(e-1);g=c[d];return c=(d+(f-g)/(c[d+1]-g))/(e-1)};THREE.Curve.prototype.getNormalVector=function(a){a=this.getTangent(a);return new THREE.Vector2(-a.y,a.x)};
THREE.Curve.prototype.getTangent=function(a){var b=a-1E-4,a=a+1E-4;b<0&&(b=0);a>1&&(a=1);b=this.getPoint(b);return this.getPoint(a).clone().subSelf(b).normalize()};THREE.Curve.prototype.getTangentAt=function(a){a=this.getUtoTmapping(a);return this.getTangent(a)};THREE.LineCurve=function(a,b){this.v1=a;this.v2=b};THREE.LineCurve.prototype=Object.create(THREE.Curve.prototype);THREE.LineCurve.prototype.getPoint=function(a){var b=this.v2.clone().subSelf(this.v1);b.multiplyScalar(a).addSelf(this.v1);return b};
THREE.LineCurve.prototype.getPointAt=function(a){return this.getPoint(a)};THREE.LineCurve.prototype.getTangent=function(){return this.v2.clone().subSelf(this.v1).normalize()};THREE.QuadraticBezierCurve=function(a,b,c){this.v0=a;this.v1=b;this.v2=c};THREE.QuadraticBezierCurve.prototype=Object.create(THREE.Curve.prototype);
THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var b;b=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);return new THREE.Vector2(b,a)};THREE.QuadraticBezierCurve.prototype.getTangent=function(a){var b;b=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.y,this.v1.y,this.v2.y);b=new THREE.Vector2(b,a);b.normalize();return b};
THREE.CubicBezierCurve=function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d};THREE.CubicBezierCurve.prototype=Object.create(THREE.Curve.prototype);THREE.CubicBezierCurve.prototype.getPoint=function(a){var b;b=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);return new THREE.Vector2(b,a)};
THREE.CubicBezierCurve.prototype.getTangent=function(a){var b;b=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);b=new THREE.Vector2(b,a);b.normalize();return b};THREE.SplineCurve=function(a){this.points=a==void 0?[]:a};THREE.SplineCurve.prototype=Object.create(THREE.Curve.prototype);
THREE.SplineCurve.prototype.getPoint=function(a){var b=new THREE.Vector2,c=[],d=this.points,e;e=(d.length-1)*a;a=Math.floor(e);e=e-a;c[0]=a==0?a:a-1;c[1]=a;c[2]=a>d.length-2?d.length-1:a+1;c[3]=a>d.length-3?d.length-1:a+2;b.x=THREE.Curve.Utils.interpolate(d[c[0]].x,d[c[1]].x,d[c[2]].x,d[c[3]].x,e);b.y=THREE.Curve.Utils.interpolate(d[c[0]].y,d[c[1]].y,d[c[2]].y,d[c[3]].y,e);return b};
THREE.EllipseCurve=function(a,b,c,d,e,f,g){this.aX=a;this.aY=b;this.xRadius=c;this.yRadius=d;this.aStartAngle=e;this.aEndAngle=f;this.aClockwise=g};THREE.EllipseCurve.prototype=Object.create(THREE.Curve.prototype);THREE.EllipseCurve.prototype.getPoint=function(a){var b=this.aEndAngle-this.aStartAngle;this.aClockwise||(a=1-a);b=this.aStartAngle+a*b;a=this.aX+this.xRadius*Math.cos(b);b=this.aY+this.yRadius*Math.sin(b);return new THREE.Vector2(a,b)};
THREE.ArcCurve=function(a,b,c,d,e,f){THREE.EllipseCurve.call(this,a,b,c,c,d,e,f)};THREE.ArcCurve.prototype=Object.create(THREE.EllipseCurve.prototype);
THREE.Curve.Utils={tangentQuadraticBezier:function(a,b,c,d){return 2*(1-a)*(c-b)+2*a*(d-c)},tangentCubicBezier:function(a,b,c,d,e){return-3*b*(1-a)*(1-a)+3*c*(1-a)*(1-a)-6*a*c*(1-a)+6*a*d*(1-a)-3*a*a*d+3*a*a*e},tangentSpline:function(a){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*a-2*a)},interpolate:function(a,b,c,d,e){var a=(c-a)*0.5,d=(d-b)*0.5,f=e*e;return(2*b-2*c+a+d)*e*f+(-3*b+3*c-2*a-d)*f+a*e+b}};
THREE.Curve.create=function(a,b){a.prototype=Object.create(THREE.Curve.prototype);a.prototype.getPoint=b;return a};THREE.LineCurve3=THREE.Curve.create(function(a,b){this.v1=a;this.v2=b},function(a){var b=new THREE.Vector3;b.sub(this.v2,this.v1);b.multiplyScalar(a);b.addSelf(this.v1);return b});
THREE.QuadraticBezierCurve3=THREE.Curve.create(function(a,b,c){this.v0=a;this.v1=b;this.v2=c},function(a){var b,c;b=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);c=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);a=THREE.Shape.Utils.b2(a,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(b,c,a)});
THREE.CubicBezierCurve3=THREE.Curve.create(function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d},function(a){var b,c;b=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);c=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);a=THREE.Shape.Utils.b3(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z);return new THREE.Vector3(b,c,a)});
THREE.SplineCurve3=THREE.Curve.create(function(a){this.points=a==void 0?[]:a},function(a){var b=new THREE.Vector3,c=[],d=this.points,e,a=(d.length-1)*a;e=Math.floor(a);a=a-e;c[0]=e==0?e:e-1;c[1]=e;c[2]=e>d.length-2?d.length-1:e+1;c[3]=e>d.length-3?d.length-1:e+2;e=d[c[0]];var f=d[c[1]],g=d[c[2]],c=d[c[3]];b.x=THREE.Curve.Utils.interpolate(e.x,f.x,g.x,c.x,a);b.y=THREE.Curve.Utils.interpolate(e.y,f.y,g.y,c.y,a);b.z=THREE.Curve.Utils.interpolate(e.z,f.z,g.z,c.z,a);return b});
THREE.ClosedSplineCurve3=THREE.Curve.create(function(a){this.points=a==void 0?[]:a},function(a){var b=new THREE.Vector3,c=[],d=this.points,e;e=(d.length-0)*a;a=Math.floor(e);e=e-a;a=a+(a>0?0:(Math.floor(Math.abs(a)/d.length)+1)*d.length);c[0]=(a-1)%d.length;c[1]=a%d.length;c[2]=(a+1)%d.length;c[3]=(a+2)%d.length;b.x=THREE.Curve.Utils.interpolate(d[c[0]].x,d[c[1]].x,d[c[2]].x,d[c[3]].x,e);b.y=THREE.Curve.Utils.interpolate(d[c[0]].y,d[c[1]].y,d[c[2]].y,d[c[3]].y,e);b.z=THREE.Curve.Utils.interpolate(d[c[0]].z,
d[c[1]].z,d[c[2]].z,d[c[3]].z,e);return b});THREE.CurvePath=function(){this.curves=[];this.bends=[];this.autoClose=false};THREE.CurvePath.prototype=Object.create(THREE.Curve.prototype);THREE.CurvePath.prototype.add=function(a){this.curves.push(a)};THREE.CurvePath.prototype.checkConnection=function(){};THREE.CurvePath.prototype.closePath=function(){var a=this.curves[0].getPoint(0),b=this.curves[this.curves.length-1].getPoint(1);a.equals(b)||this.curves.push(new THREE.LineCurve(b,a))};
THREE.CurvePath.prototype.getPoint=function(a){for(var b=a*this.getLength(),c=this.getCurveLengths(),a=0;a<c.length;){if(c[a]>=b){b=c[a]-b;a=this.curves[a];b=1-b/a.getLength();return a.getPointAt(b)}a++}return null};THREE.CurvePath.prototype.getLength=function(){var a=this.getCurveLengths();return a[a.length-1]};
THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var a=[],b=0,c,d=this.curves.length;for(c=0;c<d;c++){b=b+this.curves[c].getLength();a.push(b)}return this.cacheLengths=a};
THREE.CurvePath.prototype.getBoundingBox=function(){var a=this.getPoints(),b,c,d,e,f,g;b=c=Number.NEGATIVE_INFINITY;e=f=Number.POSITIVE_INFINITY;var h,i,j,m,n=a[0]instanceof THREE.Vector3;m=n?new THREE.Vector3:new THREE.Vector2;i=0;for(j=a.length;i<j;i++){h=a[i];if(h.x>b)b=h.x;else if(h.x<e)e=h.x;if(h.y>c)c=h.y;else if(h.y<f)f=h.y;if(n)if(h.z>d)d=h.z;else if(h.z<g)g=h.z;m.addSelf(h)}a={minX:e,minY:f,maxX:b,maxY:c,centroid:m.divideScalar(j)};if(n){a.maxZ=d;a.minZ=g}return a};
THREE.CurvePath.prototype.createPointsGeometry=function(a){a=this.getPoints(a,true);return this.createGeometry(a)};THREE.CurvePath.prototype.createSpacedPointsGeometry=function(a){a=this.getSpacedPoints(a,true);return this.createGeometry(a)};THREE.CurvePath.prototype.createGeometry=function(a){for(var b=new THREE.Geometry,c=0;c<a.length;c++)b.vertices.push(new THREE.Vector3(a[c].x,a[c].y,a[c].z||0));return b};THREE.CurvePath.prototype.addWrapPath=function(a){this.bends.push(a)};
THREE.CurvePath.prototype.getTransformedPoints=function(a,b){var c=this.getPoints(a),d,e;if(!b)b=this.bends;d=0;for(e=b.length;d<e;d++)c=this.getWrapPoints(c,b[d]);return c};THREE.CurvePath.prototype.getTransformedSpacedPoints=function(a,b){var c=this.getSpacedPoints(a),d,e;if(!b)b=this.bends;d=0;for(e=b.length;d<e;d++)c=this.getWrapPoints(c,b[d]);return c};
THREE.CurvePath.prototype.getWrapPoints=function(a,b){var c=this.getBoundingBox(),d,e,f,g,h,i;d=0;for(e=a.length;d<e;d++){f=a[d];g=f.x;h=f.y;i=g/c.maxX;i=b.getUtoTmapping(i,g);g=b.getPoint(i);h=b.getNormalVector(i).multiplyScalar(h);f.x=g.x+h.x;f.y=g.y+h.y}return a};THREE.Gyroscope=function(){THREE.Object3D.call(this)};THREE.Gyroscope.prototype=Object.create(THREE.Object3D.prototype);
THREE.Gyroscope.prototype.updateMatrixWorld=function(a){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||a){if(this.parent){this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix);this.matrixWorld.decompose(this.translationWorld,this.rotationWorld,this.scaleWorld);this.matrix.decompose(this.translationObject,this.rotationObject,this.scaleObject);this.matrixWorld.compose(this.translationWorld,this.rotationObject,this.scaleWorld)}else this.matrixWorld.copy(this.matrix);
this.matrixWorldNeedsUpdate=false;a=true}for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)};THREE.Gyroscope.prototype.translationWorld=new THREE.Vector3;THREE.Gyroscope.prototype.translationObject=new THREE.Vector3;THREE.Gyroscope.prototype.rotationWorld=new THREE.Quaternion;THREE.Gyroscope.prototype.rotationObject=new THREE.Quaternion;THREE.Gyroscope.prototype.scaleWorld=new THREE.Vector3;THREE.Gyroscope.prototype.scaleObject=new THREE.Vector3;
THREE.Path=function(a){THREE.CurvePath.call(this);this.actions=[];a&&this.fromPoints(a)};THREE.Path.prototype=Object.create(THREE.CurvePath.prototype);THREE.PathActions={MOVE_TO:"moveTo",LINE_TO:"lineTo",QUADRATIC_CURVE_TO:"quadraticCurveTo",BEZIER_CURVE_TO:"bezierCurveTo",CSPLINE_THRU:"splineThru",ARC:"arc",ELLIPSE:"ellipse"};THREE.Path.prototype.fromPoints=function(a){this.moveTo(a[0].x,a[0].y);for(var b=1,c=a.length;b<c;b++)this.lineTo(a[b].x,a[b].y)};
THREE.Path.prototype.moveTo=function(a,b){var c=Array.prototype.slice.call(arguments);this.actions.push({action:THREE.PathActions.MOVE_TO,args:c})};THREE.Path.prototype.lineTo=function(a,b){var c=Array.prototype.slice.call(arguments),d=this.actions[this.actions.length-1].args,d=new THREE.LineCurve(new THREE.Vector2(d[d.length-2],d[d.length-1]),new THREE.Vector2(a,b));this.curves.push(d);this.actions.push({action:THREE.PathActions.LINE_TO,args:c})};
THREE.Path.prototype.quadraticCurveTo=function(a,b,c,d){var e=Array.prototype.slice.call(arguments),f=this.actions[this.actions.length-1].args,f=new THREE.QuadraticBezierCurve(new THREE.Vector2(f[f.length-2],f[f.length-1]),new THREE.Vector2(a,b),new THREE.Vector2(c,d));this.curves.push(f);this.actions.push({action:THREE.PathActions.QUADRATIC_CURVE_TO,args:e})};
THREE.Path.prototype.bezierCurveTo=function(a,b,c,d,e,f){var g=Array.prototype.slice.call(arguments),h=this.actions[this.actions.length-1].args,h=new THREE.CubicBezierCurve(new THREE.Vector2(h[h.length-2],h[h.length-1]),new THREE.Vector2(a,b),new THREE.Vector2(c,d),new THREE.Vector2(e,f));this.curves.push(h);this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:g})};
THREE.Path.prototype.splineThru=function(a){var b=Array.prototype.slice.call(arguments),c=this.actions[this.actions.length-1].args,c=[new THREE.Vector2(c[c.length-2],c[c.length-1])];Array.prototype.push.apply(c,a);c=new THREE.SplineCurve(c);this.curves.push(c);this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:b})};THREE.Path.prototype.arc=function(a,b,c,d,e,f){var g=this.actions[this.actions.length-1].args;this.absarc(a+g[g.length-2],b+g[g.length-1],c,d,e,f)};
THREE.Path.prototype.absarc=function(a,b,c,d,e,f){this.absellipse(a,b,c,c,d,e,f)};THREE.Path.prototype.ellipse=function(a,b,c,d,e,f,g){var h=this.actions[this.actions.length-1].args;this.absellipse(a+h[h.length-2],b+h[h.length-1],c,d,e,f,g)};THREE.Path.prototype.absellipse=function(a,b,c,d,e,f,g){var h=Array.prototype.slice.call(arguments),i=new THREE.EllipseCurve(a,b,c,d,e,f,g);this.curves.push(i);i=i.getPoint(g?1:0);h.push(i.x);h.push(i.y);this.actions.push({action:THREE.PathActions.ELLIPSE,args:h})};
THREE.Path.prototype.getSpacedPoints=function(a){a||(a=40);for(var b=[],c=0;c<a;c++)b.push(this.getPoint(c/a));return b};
THREE.Path.prototype.getPoints=function(a,b){if(this.useSpacedPoints){console.log("tata");return this.getSpacedPoints(a,b)}var a=a||12,c=[],d,e,f,g,h,i,j,m,n,l,p,o,q;d=0;for(e=this.actions.length;d<e;d++){f=this.actions[d];g=f.action;f=f.args;switch(g){case THREE.PathActions.MOVE_TO:c.push(new THREE.Vector2(f[0],f[1]));break;case THREE.PathActions.LINE_TO:c.push(new THREE.Vector2(f[0],f[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:h=f[2];i=f[3];n=f[0];l=f[1];if(c.length>0){g=c[c.length-1];
p=g.x;o=g.y}else{g=this.actions[d-1].args;p=g[g.length-2];o=g[g.length-1]}for(f=1;f<=a;f++){q=f/a;g=THREE.Shape.Utils.b2(q,p,n,h);q=THREE.Shape.Utils.b2(q,o,l,i);c.push(new THREE.Vector2(g,q))}break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];i=f[5];n=f[0];l=f[1];j=f[2];m=f[3];if(c.length>0){g=c[c.length-1];p=g.x;o=g.y}else{g=this.actions[d-1].args;p=g[g.length-2];o=g[g.length-1]}for(f=1;f<=a;f++){q=f/a;g=THREE.Shape.Utils.b3(q,p,n,j,h);q=THREE.Shape.Utils.b3(q,o,l,m,i);c.push(new THREE.Vector2(g,
q))}break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[d-1].args;q=[new THREE.Vector2(g[g.length-2],g[g.length-1])];g=a*f[0].length;q=q.concat(f[0]);q=new THREE.SplineCurve(q);for(f=1;f<=g;f++)c.push(q.getPointAt(f/g));break;case THREE.PathActions.ARC:h=f[0];i=f[1];l=f[2];j=f[3];g=f[4];n=!!f[5];p=g-j;o=a*2;for(f=1;f<=o;f++){q=f/o;n||(q=1-q);q=j+q*p;g=h+l*Math.cos(q);q=i+l*Math.sin(q);c.push(new THREE.Vector2(g,q))}break;case THREE.PathActions.ELLIPSE:h=f[0];i=f[1];l=f[2];m=f[3];j=f[4];g=f[5];
n=!!f[6];p=g-j;o=a*2;for(f=1;f<=o;f++){q=f/o;n||(q=1-q);q=j+q*p;g=h+l*Math.cos(q);q=i+m*Math.sin(q);c.push(new THREE.Vector2(g,q))}}}d=c[c.length-1];Math.abs(d.x-c[0].x)<1E-10&&Math.abs(d.y-c[0].y)<1E-10&&c.splice(c.length-1,1);b&&c.push(c[0]);return c};
THREE.Path.prototype.toShapes=function(){var a,b,c,d,e=[],f=new THREE.Path;a=0;for(b=this.actions.length;a<b;a++){c=this.actions[a];d=c.args;c=c.action;if(c==THREE.PathActions.MOVE_TO&&f.actions.length!=0){e.push(f);f=new THREE.Path}f[c].apply(f,d)}f.actions.length!=0&&e.push(f);if(e.length==0)return[];var g;d=[];a=!THREE.Shape.Utils.isClockWise(e[0].getPoints());if(e.length==1){f=e[0];g=new THREE.Shape;g.actions=f.actions;g.curves=f.curves;d.push(g);return d}if(a){g=new THREE.Shape;a=0;for(b=e.length;a<
b;a++){f=e[a];if(THREE.Shape.Utils.isClockWise(f.getPoints())){g.actions=f.actions;g.curves=f.curves;d.push(g);g=new THREE.Shape}else g.holes.push(f)}}else{a=0;for(b=e.length;a<b;a++){f=e[a];if(THREE.Shape.Utils.isClockWise(f.getPoints())){g&&d.push(g);g=new THREE.Shape;g.actions=f.actions;g.curves=f.curves}else g.holes.push(f)}d.push(g)}return d};THREE.Shape=function(){THREE.Path.apply(this,arguments);this.holes=[]};THREE.Shape.prototype=Object.create(THREE.Path.prototype);
THREE.Shape.prototype.extrude=function(a){return new THREE.ExtrudeGeometry(this,a)};THREE.Shape.prototype.makeGeometry=function(a){return new THREE.ShapeGeometry(this,a)};THREE.Shape.prototype.getPointsHoles=function(a){var b,c=this.holes.length,d=[];for(b=0;b<c;b++)d[b]=this.holes[b].getTransformedPoints(a,this.bends);return d};THREE.Shape.prototype.getSpacedPointsHoles=function(a){var b,c=this.holes.length,d=[];for(b=0;b<c;b++)d[b]=this.holes[b].getTransformedSpacedPoints(a,this.bends);return d};
THREE.Shape.prototype.extractAllPoints=function(a){return{shape:this.getTransformedPoints(a),holes:this.getPointsHoles(a)}};THREE.Shape.prototype.extractPoints=function(a){return this.useSpacedPoints?this.extractAllSpacedPoints(a):this.extractAllPoints(a)};THREE.Shape.prototype.extractAllSpacedPoints=function(a){return{shape:this.getTransformedSpacedPoints(a),holes:this.getSpacedPointsHoles(a)}};
594 595
THREE.Shape.Utils={removeHoles:function(a,b){var c=a.concat(),d=c.concat(),e,f,g,h,i,j,m,n,l,p,o=[];for(i=0;i<b.length;i++){j=b[i];Array.prototype.push.apply(d,j);f=Number.POSITIVE_INFINITY;for(e=0;e<j.length;e++){l=j[e];p=[];for(n=0;n<c.length;n++){m=c[n];m=l.distanceToSquared(m);p.push(m);if(m<f){f=m;g=e;h=n}}}e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1;var q=[j[g],c[h],c[e]];n=THREE.FontUtils.Triangulate.area(q);var s=[j[g],j[f],c[h]];l=THREE.FontUtils.Triangulate.area(s);p=h;m=g;h=h+1;g=g+
-1;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+j.length);g=g%j.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1;q=[j[g],c[h],c[e]];q=THREE.FontUtils.Triangulate.area(q);s=[j[g],j[f],c[h]];s=THREE.FontUtils.Triangulate.area(s);if(n+l>q+s){h=p;g=m;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+j.length);g=g%j.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1}n=c.slice(0,h);l=c.slice(h);p=j.slice(g);m=j.slice(0,g);f=[j[g],j[f],c[h]];o.push([j[g],c[h],c[e]]);o.push(f);c=n.concat(p).concat(m).concat(l)}return{shape:c,
A
alteredq 已提交
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634
isolatedPts:o,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,e=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,false),f,g,h,i,j={};f=0;for(g=d.length;f<g;f++){i=d[f].x+":"+d[f].y;j[i]!==void 0&&console.log("Duplicate point",i);j[i]=f}f=0;for(g=c.length;f<g;f++){h=c[f];for(d=0;d<3;d++){i=h[d].x+":"+h[d].y;i=j[i];i!==void 0&&(h[d]=i)}}f=0;for(g=e.length;f<g;f++){h=e[f];for(d=0;d<3;d++){i=h[d].x+":"+h[d].y;i=j[i];i!==void 0&&(h[d]=i)}}return c.concat(e)},
isClockWise:function(a){return THREE.FontUtils.Triangulate.area(a)<0},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,d){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,d)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a,b){return a*a*a*b},b3:function(a,b,c,d,e){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,d)+
this.b3p3(a,e)}};
THREE.AnimationHandler=function(){var a=[],b={},c={update:function(b){for(var c=0;c<a.length;c++)a[c].update(b)},addToUpdate:function(b){a.indexOf(b)===-1&&a.push(b)},removeFromUpdate:function(b){b=a.indexOf(b);b!==-1&&a.splice(b,1)},add:function(a){b[a.name]!==void 0&&console.log("THREE.AnimationHandler.add: Warning! "+a.name+" already exists in library. Overwriting.");b[a.name]=a;if(a.initialized!==true){for(var c=0;c<a.hierarchy.length;c++){for(var d=0;d<a.hierarchy[c].keys.length;d++){if(a.hierarchy[c].keys[d].time<0)a.hierarchy[c].keys[d].time=
0;if(a.hierarchy[c].keys[d].rot!==void 0&&!(a.hierarchy[c].keys[d].rot instanceof THREE.Quaternion)){var h=a.hierarchy[c].keys[d].rot;a.hierarchy[c].keys[d].rot=new THREE.Quaternion(h[0],h[1],h[2],h[3])}}if(a.hierarchy[c].keys.length&&a.hierarchy[c].keys[0].morphTargets!==void 0){h={};for(d=0;d<a.hierarchy[c].keys.length;d++)for(var i=0;i<a.hierarchy[c].keys[d].morphTargets.length;i++){var j=a.hierarchy[c].keys[d].morphTargets[i];h[j]=-1}a.hierarchy[c].usedMorphTargets=h;for(d=0;d<a.hierarchy[c].keys.length;d++){var m=
{};for(j in h){for(i=0;i<a.hierarchy[c].keys[d].morphTargets.length;i++)if(a.hierarchy[c].keys[d].morphTargets[i]===j){m[j]=a.hierarchy[c].keys[d].morphTargetsInfluences[i];break}i===a.hierarchy[c].keys[d].morphTargets.length&&(m[j]=0)}a.hierarchy[c].keys[d].morphTargetsInfluences=m}}for(d=1;d<a.hierarchy[c].keys.length;d++)if(a.hierarchy[c].keys[d].time===a.hierarchy[c].keys[d-1].time){a.hierarchy[c].keys.splice(d,1);d--}for(d=0;d<a.hierarchy[c].keys.length;d++)a.hierarchy[c].keys[d].index=d}d=parseInt(a.length*
a.fps,10);a.JIT={};a.JIT.hierarchy=[];for(c=0;c<a.hierarchy.length;c++)a.JIT.hierarchy.push(Array(d));a.initialized=true}},get:function(a){if(typeof a==="string"){if(b[a])return b[a];console.log("THREE.AnimationHandler.get: Couldn't find animation "+a);return null}},parse:function(a){var b=[];if(a instanceof THREE.SkinnedMesh)for(var c=0;c<a.bones.length;c++)b.push(a.bones[c]);else d(a,b);return b}},d=function(a,b){b.push(a);for(var c=0;c<a.children.length;c++)d(a.children[c],b)};c.LINEAR=0;c.CATMULLROM=
1;c.CATMULLROM_FORWARD=2;return c}();THREE.Animation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=false;this.loop=this.isPaused=true;this.interpolationType=c!==void 0?c:THREE.AnimationHandler.LINEAR;this.points=[];this.target=new THREE.Vector3};
THREE.Animation.prototype.play=function(a,b){if(this.isPlaying===false){this.isPlaying=true;this.loop=a!==void 0?a:true;this.currentTime=b!==void 0?b:0;var c,d=this.hierarchy.length,e;for(c=0;c<d;c++){e=this.hierarchy[c];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)e.useQuaternion=true;e.matrixAutoUpdate=true;if(e.animationCache===void 0){e.animationCache={};e.animationCache.prevKey={pos:0,rot:0,scl:0};e.animationCache.nextKey={pos:0,rot:0,scl:0};e.animationCache.originalMatrix=
e instanceof THREE.Bone?e.skinMatrix:e.matrix}var f=e.animationCache.prevKey;e=e.animationCache.nextKey;f.pos=this.data.hierarchy[c].keys[0];f.rot=this.data.hierarchy[c].keys[0];f.scl=this.data.hierarchy[c].keys[0];e.pos=this.getNextKeyWith("pos",c,1);e.rot=this.getNextKeyWith("rot",c,1);e.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=false;THREE.AnimationHandler.addToUpdate(this)};
THREE.Animation.prototype.pause=function(){this.isPaused===true?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};THREE.Animation.prototype.stop=function(){this.isPaused=this.isPlaying=false;THREE.AnimationHandler.removeFromUpdate(this)};
THREE.Animation.prototype.update=function(a){if(this.isPlaying!==false){var b=["pos","rot","scl"],c,d,e,f,g,h,i,j,m;m=this.currentTime=this.currentTime+a*this.timeScale;j=this.currentTime=this.currentTime%this.data.length;parseInt(Math.min(j*this.data.fps,this.data.length*this.data.fps),10);for(var n=0,l=this.hierarchy.length;n<l;n++){a=this.hierarchy[n];i=a.animationCache;for(var p=0;p<3;p++){c=b[p];g=i.prevKey[c];h=i.nextKey[c];if(h.time<=m){if(j<m)if(this.loop){g=this.data.hierarchy[n].keys[0];
for(h=this.getNextKeyWith(c,n,1);h.time<j;){g=h;h=this.getNextKeyWith(c,n,h.index+1)}}else{this.stop();return}else{do{g=h;h=this.getNextKeyWith(c,n,h.index+1)}while(h.time<j)}i.prevKey[c]=g;i.nextKey[c]=h}a.matrixAutoUpdate=true;a.matrixWorldNeedsUpdate=true;d=(j-g.time)/(h.time-g.time);e=g[c];f=h[c];if(d<0||d>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+n);d=d<0?0:1}if(c==="pos"){c=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=e[0]+
(f[0]-e[0])*d;c.y=e[1]+(f[1]-e[1])*d;c.z=e[2]+(f[2]-e[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=this.getPrevKeyWith("pos",n,g.index-1).pos;this.points[1]=e;this.points[2]=f;this.points[3]=this.getNextKeyWith("pos",n,h.index+1).pos;d=d*0.33+0.33;e=this.interpolateCatmullRom(this.points,d);c.x=e[0];c.y=e[1];c.z=e[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){d=
this.interpolateCatmullRom(this.points,d*1.01);this.target.set(d[0],d[1],d[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();d=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,d,0)}}}else if(c==="rot")THREE.Quaternion.slerp(e,f,a.quaternion,d);else if(c==="scl"){c=a.scale;c.x=e[0]+(f[0]-e[0])*d;c.y=e[1]+(f[1]-e[1])*d;c.z=e[2]+(f[2]-e[2])*d}}}}};
THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],d=[],e,f,g,h,i,j;e=(a.length-1)*b;f=Math.floor(e);e=e-f;c[0]=f===0?f:f-1;c[1]=f;c[2]=f>a.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];h=a[c[1]];i=a[c[2]];j=a[c[3]];c=e*e;g=e*c;d[0]=this.interpolate(f[0],h[0],i[0],j[0],e,c,g);d[1]=this.interpolate(f[1],h[1],i[1],j[1],e,c,g);d[2]=this.interpolate(f[2],h[2],i[2],j[2],e,c,g);return d};
THREE.Animation.prototype.interpolate=function(a,b,c,d,e,f,g){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+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(d[c][a]!==void 0)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?c>0?c:0:c>=0?c:c+d.length;c>=0;c--)if(d[c][a]!==void 0)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=false;this.loop=this.isPaused=true;this.JITCompile=c!==void 0?c:true;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 e=0;e<c.length;e++){var f=c[e],g=this.getNextKeyWith(f,a,0);g&&g.apply(f)}d.matrixAutoUpdate=
false;this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=true}}};
THREE.KeyFrameAnimation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=true;this.loop=a!==void 0?a:true;this.currentTime=b!==void 0?b:0;this.startTimeMs=b;this.startTime=1E7;this.endTime=-this.startTime;var c,d=this.hierarchy.length,e,f;for(c=0;c<d;c++){e=this.hierarchy[c];f=this.data.hierarchy[c];e.useQuaternion=true;if(f.animationCache===void 0){f.animationCache={};f.animationCache.prevKey=null;f.animationCache.nextKey=null;f.animationCache.originalMatrix=e instanceof THREE.Bone?
e.skinMatrix:e.matrix}e=this.data.hierarchy[c].keys;if(e.length){f.animationCache.prevKey=e[0];f.animationCache.nextKey=e[1];this.startTime=Math.min(e[0].time,this.startTime);this.endTime=Math.max(e[e.length-1].time,this.endTime)}}this.update(0)}this.isPaused=false;THREE.AnimationHandler.addToUpdate(this)};THREE.KeyFrameAnimation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
THREE.KeyFrameAnimation.prototype.stop=function(){this.isPaused=this.isPlaying=false;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.data.hierarchy.length;a++){var b=this.hierarchy[a],c=this.data.hierarchy[a];if(c.animationCache!==void 0){var d=c.animationCache.originalMatrix;if(b instanceof THREE.Bone){d.copy(b.skinMatrix);b.skinMatrix=d}else{d.copy(b.matrix);b.matrix=d}delete c.animationCache}}};
THREE.KeyFrameAnimation.prototype.update=function(a){if(this.isPlaying){var b,c,d,e,f=this.data.JIT.hierarchy,g,h,i;h=this.currentTime=this.currentTime+a*this.timeScale;g=this.currentTime=this.currentTime%this.data.length;if(g<this.startTimeMs)g=this.currentTime=this.startTimeMs+g;e=parseInt(Math.min(g*this.data.fps,this.data.length*this.data.fps),10);if((i=g<h)&&!this.loop){for(var a=0,j=this.hierarchy.length;a<j;a++){var m=this.data.hierarchy[a].keys,f=this.data.hierarchy[a].sids;d=m.length-1;e=
this.hierarchy[a];if(m.length){for(m=0;m<f.length;m++){g=f[m];(h=this.getPrevKeyWith(g,a,d))&&h.apply(g)}this.data.hierarchy[a].node.updateMatrix();e.matrixWorldNeedsUpdate=true}}this.stop()}else if(!(g<this.startTime)){a=0;for(j=this.hierarchy.length;a<j;a++){d=this.hierarchy[a];b=this.data.hierarchy[a];var m=b.keys,n=b.animationCache;if(this.JITCompile&&f[a][e]!==void 0)if(d instanceof THREE.Bone){d.skinMatrix=f[a][e];d.matrixWorldNeedsUpdate=false}else{d.matrix=f[a][e];d.matrixWorldNeedsUpdate=
true}else if(m.length){if(this.JITCompile&&n)d instanceof THREE.Bone?d.skinMatrix=n.originalMatrix:d.matrix=n.originalMatrix;b=n.prevKey;c=n.nextKey;if(b&&c){if(c.time<=h){if(i&&this.loop){b=m[0];for(c=m[1];c.time<g;){b=c;c=m[b.index+1]}}else if(!i)for(var l=m.length-1;c.time<g&&c.index!==l;){b=c;c=m[b.index+1]}n.prevKey=b;n.nextKey=c}c.time>=g?b.interpolate(c,g):b.interpolate(c,c.time)}this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=true}}if(this.JITCompile&&f[0][e]===void 0){this.hierarchy[0].updateMatrixWorld(true);
for(a=0;a<this.hierarchy.length;a++)f[a][e]=this.hierarchy[a]instanceof THREE.Bone?this.hierarchy[a].skinMatrix.clone():this.hierarchy[a].matrix.clone()}}}};THREE.KeyFrameAnimation.prototype.getNextKeyWith=function(a,b,c){b=this.data.hierarchy[b].keys;for(c=c%b.length;c<b.length;c++)if(b[c].hasTarget(a))return b[c];return b[0]};
THREE.KeyFrameAnimation.prototype.getPrevKeyWith=function(a,b,c){b=this.data.hierarchy[b].keys;for(c=c>=0?c:c+b.length;c>=0;c--)if(b[c].hasTarget(a))return b[c];return b[b.length-1]};
THREE.CubeCamera=function(a,b,c){THREE.Object3D.call(this);var d=new THREE.PerspectiveCamera(90,1,a,b);d.up.set(0,-1,0);d.lookAt(new THREE.Vector3(1,0,0));this.add(d);var e=new THREE.PerspectiveCamera(90,1,a,b);e.up.set(0,-1,0);e.lookAt(new THREE.Vector3(-1,0,0));this.add(e);var f=new THREE.PerspectiveCamera(90,1,a,b);f.up.set(0,0,1);f.lookAt(new THREE.Vector3(0,1,0));this.add(f);var g=new THREE.PerspectiveCamera(90,1,a,b);g.up.set(0,0,-1);g.lookAt(new THREE.Vector3(0,-1,0));this.add(g);var h=new THREE.PerspectiveCamera(90,
1,a,b);h.up.set(0,-1,0);h.lookAt(new THREE.Vector3(0,0,1));this.add(h);var i=new THREE.PerspectiveCamera(90,1,a,b);i.up.set(0,-1,0);i.lookAt(new THREE.Vector3(0,0,-1));this.add(i);this.renderTarget=new THREE.WebGLRenderTargetCube(c,c,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updateCubeMap=function(a,b){var c=this.renderTarget,l=c.generateMipmaps;c.generateMipmaps=false;c.activeCubeFace=0;a.render(b,d,c);c.activeCubeFace=1;a.render(b,e,c);c.activeCubeFace=
2;a.render(b,f,c);c.activeCubeFace=3;a.render(b,g,c);c.activeCubeFace=4;a.render(b,h,c);c.generateMipmaps=l;c.activeCubeFace=5;a.render(b,i,c)}};THREE.CubeCamera.prototype=Object.create(THREE.Object3D.prototype);THREE.CombinedCamera=function(a,b,c,d,e,f,g){THREE.Camera.call(this);this.fov=c;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2;this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,b/2,b/-2,f,g);this.cameraP=new THREE.PerspectiveCamera(c,a/b,d,e);this.zoom=1;this.toPerspective()};
THREE.CombinedCamera.prototype=Object.create(THREE.Camera.prototype);THREE.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near;this.far=this.cameraP.far;this.cameraP.fov=this.fov/this.zoom;this.cameraP.updateProjectionMatrix();this.projectionMatrix=this.cameraP.projectionMatrix;this.inPerspectiveMode=true;this.inOrthographicMode=false};
THREE.CombinedCamera.prototype.toOrthographic=function(){var a=this.cameraP.aspect,b=(this.cameraP.near+this.cameraP.far)/2,b=Math.tan(this.fov/2)*b,a=2*b*a/2,b=b/this.zoom,a=a/this.zoom;this.cameraO.left=-a;this.cameraO.right=a;this.cameraO.top=b;this.cameraO.bottom=-b;this.cameraO.updateProjectionMatrix();this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix;this.inPerspectiveMode=false;this.inOrthographicMode=true};
THREE.CombinedCamera.prototype.setSize=function(a,b){this.cameraP.aspect=a/b;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2};THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPerspectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.updateProjectionMatrix=function(){if(this.inPerspectiveMode)this.toPerspective();else{this.toPerspective();this.toOrthographic()}};
THREE.CombinedCamera.prototype.setLens=function(a,b){b===void 0&&(b=24);var c=2*Math.atan(b/(a*2))*(180/Math.PI);this.setFov(c);return c};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPerspectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=false};
THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=false};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=false};THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=false};
THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=false};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=false};
THREE.CircleGeometry=function(a,b,c,d){THREE.Geometry.call(this);var a=a||50,c=c!==void 0?c:0,d=d!==void 0?d:Math.PI*2,b=b!==void 0?Math.max(3,b):8,e,f=[];e=new THREE.Vector3;var g=new THREE.UV(0.5,0.5);this.vertices.push(e);f.push(g);for(e=0;e<=b;e++){var h=new THREE.Vector3;h.x=a*Math.cos(c+e/b*d);h.y=a*Math.sin(c+e/b*d);this.vertices.push(h);f.push(new THREE.UV((h.x/a+1)/2,-(h.y/a+1)/2+1))}c=new THREE.Vector3(0,0,-1);for(e=1;e<=b;e++){this.faces.push(new THREE.Face3(e,e+1,0,[c,c,c]));this.faceVertexUvs[0].push([f[e],
f[e+1],g])}this.computeCentroids();this.computeFaceNormals();this.boundingSphere={radius:a}};THREE.CircleGeometry.prototype=Object.create(THREE.Geometry.prototype);
635
THREE.CubeGeometry=function(a,b,c,d,e,f,g,h){function i(a,b,c,d,e,f,g,h){var i,l=j.widthSegments,m=j.heightSegments,n=e/2,o=f/2,p=j.vertices.length;if(a==="x"&&b==="y"||a==="y"&&b==="x")i="z";else if(a==="x"&&b==="z"||a==="z"&&b==="x"){i="y";m=j.depthSegments}else if(a==="z"&&b==="y"||a==="y"&&b==="z"){i="x";l=j.depthSegments}var q=l+1,s=m+1,M=e/l,N=f/m,R=new THREE.Vector3;R[i]=g>0?1:-1;for(e=0;e<s;e++)for(f=0;f<q;f++){var aa=new THREE.Vector3;aa[a]=(f*M-n)*c;aa[b]=(e*N-o)*d;aa[i]=g;j.vertices.push(aa)}for(e=
636 637
0;e<m;e++)for(f=0;f<l;f++){a=new THREE.Face4(f+q*e+p,f+q*(e+1)+p,f+1+q*(e+1)+p,f+1+q*e+p);a.normal.copy(R);a.vertexNormals.push(R.clone(),R.clone(),R.clone(),R.clone());a.materialIndex=h;j.faces.push(a);j.faceVertexUvs[0].push([new THREE.UV(f/l,1-e/m),new THREE.UV(f/l,1-(e+1)/m),new THREE.UV((f+1)/l,1-(e+1)/m),new THREE.UV((f+1)/l,1-e/m)])}}THREE.Geometry.call(this);var j=this;this.width=a;this.height=b;this.depth=c;this.widthSegments=d||1;this.heightSegments=e||1;this.depthSegments=f||1;var a=this.width/
2,b=this.height/2,c=this.depth/2,m,n,l,p,o,q;if(g!==void 0){if(g instanceof Array)this.materials=g;else{this.materials=[];for(m=0;m<6;m++)this.materials.push(g)}m=0;p=1;n=2;o=3;l=4;q=5}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(h!=void 0)for(var s in h)this.sides[s]!==void 0&&(this.sides[s]=h[s]);this.sides.px&&i("z","y",-1,-1,this.depth,this.height,a,m);this.sides.nx&&i("z","y",1,-1,this.depth,this.height,-a,p);this.sides.py&&i("x","z",1,1,this.width,this.depth,
A
alteredq 已提交
638
b,n);this.sides.ny&&i("x","z",1,-1,this.width,this.depth,-b,o);this.sides.pz&&i("x","y",1,-1,this.width,this.height,c,l);this.sides.nz&&i("x","y",-1,-1,this.width,this.height,-c,q);this.computeCentroids();this.mergeVertices()};THREE.CubeGeometry.prototype=Object.create(THREE.Geometry.prototype);
639 640 641 642
THREE.CylinderGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);var a=a!==void 0?a:20,b=b!==void 0?b:20,c=c!==void 0?c:100,g=c/2,d=d||8,e=e||1,h,i,j=[],m=[];for(i=0;i<=e;i++){var n=[],l=[],p=i/e,o=p*(b-a)+a;for(h=0;h<=d;h++){var q=h/d,s=new THREE.Vector3;s.x=o*Math.sin(q*Math.PI*2);s.y=-p*c+g;s.z=o*Math.cos(q*Math.PI*2);this.vertices.push(s);n.push(this.vertices.length-1);l.push(new THREE.UV(q,1-p))}j.push(n);m.push(l)}c=(b-a)/c;for(h=0;h<d;h++){if(a!==0){n=this.vertices[j[0][h]].clone();l=
this.vertices[j[0][h+1]].clone()}else{n=this.vertices[j[1][h]].clone();l=this.vertices[j[1][h+1]].clone()}n.setY(Math.sqrt(n.x*n.x+n.z*n.z)*c).normalize();l.setY(Math.sqrt(l.x*l.x+l.z*l.z)*c).normalize();for(i=0;i<e;i++){var p=j[i][h],o=j[i+1][h],q=j[i+1][h+1],s=j[i][h+1],r=n.clone(),A=n.clone(),u=l.clone(),t=l.clone(),F=m[i][h].clone(),z=m[i+1][h].clone(),w=m[i+1][h+1].clone(),v=m[i][h+1].clone();this.faces.push(new THREE.Face4(p,o,q,s,[r,A,u,t]));this.faceVertexUvs[0].push([F,z,w,v])}}if(!f&&a>
0){this.vertices.push(new THREE.Vector3(0,g,0));for(h=0;h<d;h++){p=j[0][h];o=j[0][h+1];q=this.vertices.length-1;r=new THREE.Vector3(0,1,0);A=new THREE.Vector3(0,1,0);u=new THREE.Vector3(0,1,0);F=m[0][h].clone();z=m[0][h+1].clone();w=new THREE.UV(z.u,0);this.faces.push(new THREE.Face3(p,o,q,[r,A,u]));this.faceVertexUvs[0].push([F,z,w])}}if(!f&&b>0){this.vertices.push(new THREE.Vector3(0,-g,0));for(h=0;h<d;h++){p=j[i][h+1];o=j[i][h];q=this.vertices.length-1;r=new THREE.Vector3(0,-1,0);A=new THREE.Vector3(0,
-1,0);u=new THREE.Vector3(0,-1,0);F=m[i][h+1].clone();z=m[i][h].clone();w=new THREE.UV(z.u,1);this.faces.push(new THREE.Face3(p,o,q,[r,A,u]));this.faceVertexUvs[0].push([F,z,w])}}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=Object.create(THREE.Geometry.prototype);
A
alteredq 已提交
643 644
THREE.ExtrudeGeometry=function(a,b){if(typeof a!=="undefined"){THREE.Geometry.call(this);a=a instanceof Array?a:[a];this.shapebb=a[a.length-1].getBoundingBox();this.addShapeList(a,b);this.computeCentroids();this.computeFaceNormals()}};THREE.ExtrudeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ExtrudeGeometry.prototype.addShapeList=function(a,b){for(var c=a.length,d=0;d<c;d++)this.addShape(a[d],b)};
THREE.ExtrudeGeometry.prototype.addShape=function(a,b){function c(a,b,c){b||console.log("die");return b.clone().multiplyScalar(c).addSelf(a)}function d(a,b,c){var d=THREE.ExtrudeGeometry.__v1,e=THREE.ExtrudeGeometry.__v2,f=THREE.ExtrudeGeometry.__v3,g=THREE.ExtrudeGeometry.__v4,h=THREE.ExtrudeGeometry.__v5,i=THREE.ExtrudeGeometry.__v6;d.set(a.x-b.x,a.y-b.y);e.set(a.x-c.x,a.y-c.y);d=d.normalize();e=e.normalize();f.set(-d.y,d.x);g.set(e.y,-e.x);h.copy(a).addSelf(f);i.copy(a).addSelf(g);if(h.equals(i))return g.clone();
645 646 647
h.copy(b).addSelf(f);i.copy(c).addSelf(g);f=d.dot(g);g=i.subSelf(h).dot(g);if(f===0){console.log("Either infinite or no solutions!");g===0?console.log("Its finite solutions."):console.log("Too bad, no solutions.")}g=g/f;if(g<0){b=Math.atan2(b.y-a.y,b.x-a.x);a=Math.atan2(c.y-a.y,c.x-a.x);b>a&&(a=a+Math.PI*2);c=(b+a)/2;a=-Math.cos(c);c=-Math.sin(c);return new THREE.Vector2(a,c)}return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function e(c,d){var e,f;for(O=c.length;--O>=0;){e=O;f=O-1;f<0&&(f=
c.length-1);for(var g=0,h=l+m*2,g=0;g<h;g++){var i=R*g,j=R*(g+1),n=d+e+i,i=d+f+i,o=d+f+j,j=d+e+j,p=c,q=g,s=h,t=e,u=f,n=n+I,i=i+I,o=o+I,j=j+I;D.faces.push(new THREE.Face4(n,i,o,j,null,null,r));n=A.generateSideWallUV(D,a,p,b,n,i,o,j,q,s,t,u);D.faceVertexUvs[0].push(n)}}}function f(a,b,c){D.vertices.push(new THREE.Vector3(a,b,c))}function g(c,d,e,f){c=c+I;d=d+I;e=e+I;D.faces.push(new THREE.Face3(c,d,e,null,null,s));c=f?A.generateBottomUV(D,a,b,c,d,e):A.generateTopUV(D,a,b,c,d,e);D.faceVertexUvs[0].push(c)}
var h=b.amount!==void 0?b.amount:100,i=b.bevelThickness!==void 0?b.bevelThickness:6,j=b.bevelSize!==void 0?b.bevelSize:i-2,m=b.bevelSegments!==void 0?b.bevelSegments:3,n=b.bevelEnabled!==void 0?b.bevelEnabled:true,l=b.steps!==void 0?b.steps:1,p=b.extrudePath,o,q=false,s=b.material,r=b.extrudeMaterial,A=b.UVGenerator!==void 0?b.UVGenerator:THREE.ExtrudeGeometry.WorldUVGenerator,u,t,F,z;if(p){o=p.getSpacedPoints(l);q=true;n=false;u=b.frames!==void 0?b.frames:new THREE.TubeGeometry.FrenetFrames(p,l,
648 649 650 651
false);t=new THREE.Vector3;F=new THREE.Vector3;z=new THREE.Vector3}if(!n)j=i=m=0;var w,v,C,D=this,I=this.vertices.length,p=a.extractPoints(),L=p.shape,p=p.holes,B=!THREE.Shape.Utils.isClockWise(L);if(B){L=L.reverse();v=0;for(C=p.length;v<C;v++){w=p[v];THREE.Shape.Utils.isClockWise(w)&&(p[v]=w.reverse())}B=false}var K=THREE.Shape.Utils.triangulateShape(L,p),B=L;v=0;for(C=p.length;v<C;v++){w=p[v];L=L.concat(w)}var H,G,M,N,R=L.length,aa=K.length,P=[],O=0,Q=B.length;H=Q-1;for(G=O+1;O<Q;O++,H++,G++){H===
Q&&(H=0);G===Q&&(G=0);P[O]=d(B[O],B[H],B[G])}var U=[],J,qa=P.concat();v=0;for(C=p.length;v<C;v++){w=p[v];J=[];O=0;Q=w.length;H=Q-1;for(G=O+1;O<Q;O++,H++,G++){H===Q&&(H=0);G===Q&&(G=0);J[O]=d(w[O],w[H],w[G])}U.push(J);qa=qa.concat(J)}for(H=0;H<m;H++){w=H/m;M=i*(1-w);G=j*Math.sin(w*Math.PI/2);O=0;for(Q=B.length;O<Q;O++){N=c(B[O],P[O],G);f(N.x,N.y,-M)}v=0;for(C=p.length;v<C;v++){w=p[v];J=U[v];O=0;for(Q=w.length;O<Q;O++){N=c(w[O],J[O],G);f(N.x,N.y,-M)}}}G=j;for(O=0;O<R;O++){N=n?c(L[O],qa[O],G):L[O];if(q){F.copy(u.normals[0]).multiplyScalar(N.x);
t.copy(u.binormals[0]).multiplyScalar(N.y);z.copy(o[0]).addSelf(F).addSelf(t);f(z.x,z.y,z.z)}else f(N.x,N.y,0)}for(w=1;w<=l;w++)for(O=0;O<R;O++){N=n?c(L[O],qa[O],G):L[O];if(q){F.copy(u.normals[w]).multiplyScalar(N.x);t.copy(u.binormals[w]).multiplyScalar(N.y);z.copy(o[w]).addSelf(F).addSelf(t);f(z.x,z.y,z.z)}else f(N.x,N.y,h/l*w)}for(H=m-1;H>=0;H--){w=H/m;M=i*(1-w);G=j*Math.sin(w*Math.PI/2);O=0;for(Q=B.length;O<Q;O++){N=c(B[O],P[O],G);f(N.x,N.y,h+M)}v=0;for(C=p.length;v<C;v++){w=p[v];J=U[v];O=0;for(Q=
w.length;O<Q;O++){N=c(w[O],J[O],G);q?f(N.x,N.y+o[l-1].y,o[l-1].x+M):f(N.x,N.y,h+M)}}}if(n){i=R*0;for(O=0;O<aa;O++){h=K[O];g(h[2]+i,h[1]+i,h[0]+i,true)}i=R*(l+m*2);for(O=0;O<aa;O++){h=K[O];g(h[0]+i,h[1]+i,h[2]+i,false)}}else{for(O=0;O<aa;O++){h=K[O];g(h[2],h[1],h[0],true)}for(O=0;O<aa;O++){h=K[O];g(h[0]+R*l,h[1]+R*l,h[2]+R*l,false)}}h=0;e(B,h);h=h+B.length;v=0;for(C=p.length;v<C;v++){w=p[v];e(w,h);h=h+w.length}};
A
alteredq 已提交
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696
THREE.ExtrudeGeometry.WorldUVGenerator={generateTopUV:function(a,b,c,d,e,f){b=a.vertices[e].x;e=a.vertices[e].y;c=a.vertices[f].x;f=a.vertices[f].y;return[new THREE.UV(a.vertices[d].x,a.vertices[d].y),new THREE.UV(b,e),new THREE.UV(c,f)]},generateBottomUV:function(a,b,c,d,e,f){return this.generateTopUV(a,b,c,d,e,f)},generateSideWallUV:function(a,b,c,d,e,f,g,h){var b=a.vertices[e].x,c=a.vertices[e].y,e=a.vertices[e].z,d=a.vertices[f].x,i=a.vertices[f].y,f=a.vertices[f].z,j=a.vertices[g].x,m=a.vertices[g].y,
g=a.vertices[g].z,n=a.vertices[h].x,l=a.vertices[h].y,a=a.vertices[h].z;return Math.abs(c-i)<0.01?[new THREE.UV(b,1-e),new THREE.UV(d,1-f),new THREE.UV(j,1-g),new THREE.UV(n,1-a)]:[new THREE.UV(c,1-e),new THREE.UV(i,1-f),new THREE.UV(m,1-g),new THREE.UV(l,1-a)]}};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2;THREE.ExtrudeGeometry.__v5=new THREE.Vector2;
THREE.ExtrudeGeometry.__v6=new THREE.Vector2;THREE.ShapeGeometry=function(a,b){THREE.Geometry.call(this);a instanceof Array===false&&(a=[a]);this.shapebb=a[a.length-1].getBoundingBox();this.addShapeList(a,b);this.computeCentroids();this.computeFaceNormals()};THREE.ShapeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ShapeGeometry.prototype.addShapeList=function(a,b){for(var c=0,d=a.length;c<d;c++)this.addShape(a[c],b);return this};
THREE.ShapeGeometry.prototype.addShape=function(a,b){b===void 0&&(b={});var c=b.material,d=b.UVGenerator===void 0?THREE.ExtrudeGeometry.WorldUVGenerator:b.UVGenerator,e,f,g,h=this.vertices.length;e=a.extractPoints();var i=e.shape,j=e.holes;if(!THREE.Shape.Utils.isClockWise(i)){i=i.reverse();e=0;for(f=j.length;e<f;e++){g=j[e];THREE.Shape.Utils.isClockWise(g)&&(j[e]=g.reverse())}}var m=THREE.Shape.Utils.triangulateShape(i,j);e=0;for(f=j.length;e<f;e++){g=j[e];i=i.concat(g)}j=i.length;f=m.length;for(e=
0;e<j;e++){g=i[e];this.vertices.push(new THREE.Vector3(g.x,g.y,0))}for(e=0;e<f;e++){j=m[e];i=j[0]+h;g=j[1]+h;j=j[2]+h;this.faces.push(new THREE.Face3(i,g,j,null,null,c));this.faceVertexUvs[0].push(d.generateBottomUV(this,a,b,i,g,j))}};
THREE.LatheGeometry=function(a,b,c){THREE.Geometry.call(this);for(var b=b||12,c=c||2*Math.PI,d=[],e=(new THREE.Matrix4).makeRotationZ(c/b),f=0;f<a.length;f++){d[f]=a[f].clone();this.vertices.push(d[f])}for(var g=b+1,c=0;c<g;c++)for(f=0;f<d.length;f++){d[f]=e.multiplyVector3(d[f].clone());this.vertices.push(d[f])}for(c=0;c<b;c++){d=0;for(e=a.length;d<e-1;d++){this.faces.push(new THREE.Face4(c*e+d,(c+1)%g*e+d,(c+1)%g*e+(d+1)%e,c*e+(d+1)%e));this.faceVertexUvs[0].push([new THREE.UV(1-c/b,d/e),new THREE.UV(1-
(c+1)/b,d/e),new THREE.UV(1-(c+1)/b,(d+1)/e),new THREE.UV(1-c/b,(d+1)/e)])}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=Object.create(THREE.Geometry.prototype);
THREE.PlaneGeometry=function(a,b,c,d){THREE.Geometry.call(this);this.width=a;this.height=b;this.widthSegments=c||1;this.heightSegments=d||1;for(var c=a/2,e=b/2,d=this.widthSegments,f=this.heightSegments,g=d+1,h=f+1,i=this.width/d,j=this.height/f,m=new THREE.Vector3(0,0,1),a=0;a<h;a++)for(b=0;b<g;b++)this.vertices.push(new THREE.Vector3(b*i-c,-(a*j-e),0));for(a=0;a<f;a++)for(b=0;b<d;b++){c=new THREE.Face4(b+g*a,b+g*(a+1),b+1+g*(a+1),b+1+g*a);c.normal.copy(m);c.vertexNormals.push(m.clone(),m.clone(),
m.clone(),m.clone());this.faces.push(c);this.faceVertexUvs[0].push([new THREE.UV(b/d,1-a/f),new THREE.UV(b/d,1-(a+1)/f),new THREE.UV((b+1)/d,1-(a+1)/f),new THREE.UV((b+1)/d,1-a/f)])}this.computeCentroids()};THREE.PlaneGeometry.prototype=Object.create(THREE.Geometry.prototype);
THREE.SphereGeometry=function(a,b,c,d,e,f,g){THREE.Geometry.call(this);this.radius=a||50;this.widthSegments=Math.max(3,Math.floor(b)||8);this.heightSegments=Math.max(2,Math.floor(c)||6);for(var d=d!==void 0?d:0,e=e!==void 0?e:Math.PI*2,f=f!==void 0?f:0,g=g!==void 0?g:Math.PI,c=[],h=[],b=0;b<=this.heightSegments;b++){for(var i=[],j=[],a=0;a<=this.widthSegments;a++){var m=a/this.widthSegments,n=b/this.heightSegments,l=new THREE.Vector3;l.x=-this.radius*Math.cos(d+m*e)*Math.sin(f+n*g);l.y=this.radius*
Math.cos(f+n*g);l.z=this.radius*Math.sin(d+m*e)*Math.sin(f+n*g);this.vertices.push(l);i.push(this.vertices.length-1);j.push(new THREE.UV(m,1-n))}c.push(i);h.push(j)}for(b=0;b<this.heightSegments;b++)for(a=0;a<this.widthSegments;a++){var d=c[b][a+1],e=c[b][a],f=c[b+1][a],g=c[b+1][a+1],i=this.vertices[d].clone().normalize(),j=this.vertices[e].clone().normalize(),m=this.vertices[f].clone().normalize(),n=this.vertices[g].clone().normalize(),l=h[b][a+1].clone(),p=h[b][a].clone(),o=h[b+1][a].clone(),q=
h[b+1][a+1].clone();if(Math.abs(this.vertices[d].y)===this.radius){this.faces.push(new THREE.Face3(d,f,g,[i,m,n]));this.faceVertexUvs[0].push([l,o,q])}else if(Math.abs(this.vertices[f].y)===this.radius){this.faces.push(new THREE.Face3(d,e,f,[i,j,m]));this.faceVertexUvs[0].push([l,p,o])}else{this.faces.push(new THREE.Face4(d,e,f,g,[i,j,m,n]));this.faceVertexUvs[0].push([l,p,o,q])}}this.computeCentroids();this.computeFaceNormals();this.boundingSphere={radius:this.radius}};
THREE.SphereGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.TextGeometry=function(a,b){var c=THREE.FontUtils.generateShapes(a,b);b.amount=b.height!==void 0?b.height:50;if(b.bevelThickness===void 0)b.bevelThickness=10;if(b.bevelSize===void 0)b.bevelSize=8;if(b.bevelEnabled===void 0)b.bevelEnabled=false;THREE.ExtrudeGeometry.call(this,c,b)};THREE.TextGeometry.prototype=Object.create(THREE.ExtrudeGeometry.prototype);
THREE.TorusGeometry=function(a,b,c,d,e){THREE.Geometry.call(this);this.radius=a||100;this.tube=b||40;this.radialSegments=c||8;this.tubularSegments=d||6;this.arc=e||Math.PI*2;e=new THREE.Vector3;a=[];b=[];for(c=0;c<=this.radialSegments;c++)for(d=0;d<=this.tubularSegments;d++){var f=d/this.tubularSegments*this.arc,g=c/this.radialSegments*Math.PI*2;e.x=this.radius*Math.cos(f);e.y=this.radius*Math.sin(f);var h=new THREE.Vector3;h.x=(this.radius+this.tube*Math.cos(g))*Math.cos(f);h.y=(this.radius+this.tube*
Math.cos(g))*Math.sin(f);h.z=this.tube*Math.sin(g);this.vertices.push(h);a.push(new THREE.UV(d/this.tubularSegments,c/this.radialSegments));b.push(h.clone().subSelf(e).normalize())}for(c=1;c<=this.radialSegments;c++)for(d=1;d<=this.tubularSegments;d++){var e=(this.tubularSegments+1)*c+d-1,f=(this.tubularSegments+1)*(c-1)+d-1,g=(this.tubularSegments+1)*(c-1)+d,h=(this.tubularSegments+1)*c+d,i=new THREE.Face4(e,f,g,h,[b[e],b[f],b[g],b[h]]);i.normal.addSelf(b[e]);i.normal.addSelf(b[f]);i.normal.addSelf(b[g]);
i.normal.addSelf(b[h]);i.normal.normalize();this.faces.push(i);this.faceVertexUvs[0].push([a[e].clone(),a[f].clone(),a[g].clone(),a[h].clone()])}this.computeCentroids()};THREE.TorusGeometry.prototype=Object.create(THREE.Geometry.prototype);
THREE.TorusKnotGeometry=function(a,b,c,d,e,f,g){function h(a,b,c,d,e,f){var g=Math.cos(a);Math.cos(b);b=Math.sin(a);a=c/d*a;c=Math.cos(a);g=e*(2+c)*0.5*g;b=e*(2+c)*b*0.5;e=f*e*Math.sin(a)*0.5;return new THREE.Vector3(g,b,e)}THREE.Geometry.call(this);this.radius=a||200;this.tube=b||40;this.radialSegments=c||64;this.tubularSegments=d||8;this.p=e||2;this.q=f||3;this.heightScale=g||1;this.grid=Array(this.radialSegments);c=new THREE.Vector3;d=new THREE.Vector3;e=new THREE.Vector3;for(a=0;a<this.radialSegments;++a){this.grid[a]=
Array(this.tubularSegments);for(b=0;b<this.tubularSegments;++b){var i=a/this.radialSegments*2*this.p*Math.PI,g=b/this.tubularSegments*2*Math.PI,f=h(i,g,this.q,this.p,this.radius,this.heightScale),i=h(i+0.01,g,this.q,this.p,this.radius,this.heightScale);c.sub(i,f);d.add(i,f);e.cross(c,d);d.cross(e,c);e.normalize();d.normalize();i=-this.tube*Math.cos(g);g=this.tube*Math.sin(g);f.x=f.x+(i*d.x+g*e.x);f.y=f.y+(i*d.y+g*e.y);f.z=f.z+(i*d.z+g*e.z);this.grid[a][b]=this.vertices.push(new THREE.Vector3(f.x,
f.y,f.z))-1}}for(a=0;a<this.radialSegments;++a)for(b=0;b<this.tubularSegments;++b){var e=(a+1)%this.radialSegments,f=(b+1)%this.tubularSegments,c=this.grid[a][b],d=this.grid[e][b],e=this.grid[e][f],f=this.grid[a][f],g=new THREE.UV(a/this.radialSegments,b/this.tubularSegments),i=new THREE.UV((a+1)/this.radialSegments,b/this.tubularSegments),j=new THREE.UV((a+1)/this.radialSegments,(b+1)/this.tubularSegments),m=new THREE.UV(a/this.radialSegments,(b+1)/this.tubularSegments);this.faces.push(new THREE.Face4(c,
d,e,f));this.faceVertexUvs[0].push([g,i,j,m])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=Object.create(THREE.Geometry.prototype);
THREE.TubeGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);this.path=a;this.segments=b||64;this.radius=c||1;this.radiusSegments=d||8;this.closed=e||false;if(f)this.debug=new THREE.Object3D;this.grid=[];var g,h,f=this.segments+1,i,j,m,n=new THREE.Vector3,l,p,o,b=new THREE.TubeGeometry.FrenetFrames(a,b,e);l=b.tangents;p=b.normals;o=b.binormals;this.tangents=l;this.normals=p;this.binormals=o;for(b=0;b<f;b++){this.grid[b]=[];d=b/(f-1);m=a.getPointAt(d);d=l[b];g=p[b];h=o[b];if(this.debug){this.debug.add(new THREE.ArrowHelper(d,
m,c,255));this.debug.add(new THREE.ArrowHelper(g,m,c,16711680));this.debug.add(new THREE.ArrowHelper(h,m,c,65280))}for(d=0;d<this.radiusSegments;d++){i=d/this.radiusSegments*2*Math.PI;j=-this.radius*Math.cos(i);i=this.radius*Math.sin(i);n.copy(m);n.x=n.x+(j*g.x+i*h.x);n.y=n.y+(j*g.y+i*h.y);n.z=n.z+(j*g.z+i*h.z);this.grid[b][d]=this.vertices.push(new THREE.Vector3(n.x,n.y,n.z))-1}}for(b=0;b<this.segments;b++)for(d=0;d<this.radiusSegments;d++){f=e?(b+1)%this.segments:b+1;n=(d+1)%this.radiusSegments;
a=this.grid[b][d];c=this.grid[f][d];f=this.grid[f][n];n=this.grid[b][n];l=new THREE.UV(b/this.segments,d/this.radiusSegments);p=new THREE.UV((b+1)/this.segments,d/this.radiusSegments);o=new THREE.UV((b+1)/this.segments,(d+1)/this.radiusSegments);g=new THREE.UV(b/this.segments,(d+1)/this.radiusSegments);this.faces.push(new THREE.Face4(a,c,f,n));this.faceVertexUvs[0].push([l,p,o,g])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.TubeGeometry.prototype=Object.create(THREE.Geometry.prototype);
THREE.TubeGeometry.FrenetFrames=function(a,b,c){new THREE.Vector3;var d=new THREE.Vector3;new THREE.Vector3;var e=[],f=[],g=[],h=new THREE.Vector3,i=new THREE.Matrix4,b=b+1,j,m,n;this.tangents=e;this.normals=f;this.binormals=g;for(j=0;j<b;j++){m=j/(b-1);e[j]=a.getTangentAt(m);e[j].normalize()}f[0]=new THREE.Vector3;g[0]=new THREE.Vector3;a=Number.MAX_VALUE;j=Math.abs(e[0].x);m=Math.abs(e[0].y);n=Math.abs(e[0].z);if(j<=a){a=j;d.set(1,0,0)}if(m<=a){a=m;d.set(0,1,0)}n<=a&&d.set(0,0,1);h.cross(e[0],d).normalize();
f[0].cross(e[0],h);g[0].cross(e[0],f[0]);for(j=1;j<b;j++){f[j]=f[j-1].clone();g[j]=g[j-1].clone();h.cross(e[j-1],e[j]);if(h.length()>1E-4){h.normalize();d=Math.acos(e[j-1].dot(e[j]));i.makeRotationAxis(h,d).multiplyVector3(f[j])}g[j].cross(e[j],f[j])}if(c){d=Math.acos(f[0].dot(f[b-1]));d=d/(b-1);e[0].dot(h.cross(f[0],f[b-1]))>0&&(d=-d);for(j=1;j<b;j++){i.makeRotationAxis(e[j],d*j).multiplyVector3(f[j]);g[j].cross(e[j],f[j])}}};
THREE.PolyhedronGeometry=function(a,b,c,d){function e(a){var b=a.normalize().clone();b.index=i.vertices.push(b)-1;var c=Math.atan2(a.z,-a.x)/2/Math.PI+0.5,a=Math.atan2(-a.y,Math.sqrt(a.x*a.x+a.z*a.z))/Math.PI+0.5;b.uv=new THREE.UV(c,1-a);return b}function f(a,b,c,d){if(d<1){d=new THREE.Face3(a.index,b.index,c.index,[a.clone(),b.clone(),c.clone()]);d.centroid.addSelf(a).addSelf(b).addSelf(c).divideScalar(3);d.normal=d.centroid.clone().normalize();i.faces.push(d);d=Math.atan2(d.centroid.z,-d.centroid.x);
i.faceVertexUvs[0].push([h(a.uv,a,d),h(b.uv,b,d),h(c.uv,c,d)])}else{d=d-1;f(a,g(a,b),g(a,c),d);f(g(a,b),b,g(b,c),d);f(g(a,c),g(b,c),c,d);f(g(a,b),g(b,c),g(a,c),d)}}function g(a,b){n[a.index]||(n[a.index]=[]);n[b.index]||(n[b.index]=[]);var c=n[a.index][b.index];c===void 0&&(n[a.index][b.index]=n[b.index][a.index]=c=e((new THREE.Vector3).add(a,b).divideScalar(2)));return c}function h(a,b,c){c<0&&a.u===1&&(a=new THREE.UV(a.u-1,a.v));b.x===0&&b.z===0&&(a=new THREE.UV(c/2/Math.PI+0.5,a.v));return a}THREE.Geometry.call(this);
for(var c=c||1,d=d||0,i=this,j=0,m=a.length;j<m;j++)e(new THREE.Vector3(a[j][0],a[j][1],a[j][2]));for(var n=[],a=this.vertices,j=0,m=b.length;j<m;j++)f(a[b[j][0]],a[b[j][1]],a[b[j][2]],d);this.mergeVertices();j=0;for(m=this.vertices.length;j<m;j++)this.vertices[j].multiplyScalar(c);this.computeCentroids();this.boundingSphere={radius:c}};THREE.PolyhedronGeometry.prototype=Object.create(THREE.Geometry.prototype);
THREE.IcosahedronGeometry=function(a,b){var c=(1+Math.sqrt(5))/2;THREE.PolyhedronGeometry.call(this,[[-1,c,0],[1,c,0],[-1,-c,0],[1,-c,0],[0,-1,c],[0,1,c],[0,-1,-c],[0,1,-c],[c,0,-1],[c,0,1],[-c,0,-1],[-c,0,1]],[[0,11,5],[0,5,1],[0,1,7],[0,7,10],[0,10,11],[1,5,9],[5,11,4],[11,10,2],[10,7,6],[7,1,8],[3,9,4],[3,4,2],[3,2,6],[3,6,8],[3,8,9],[4,9,5],[2,4,11],[6,2,10],[8,6,7],[9,8,1]],a,b)};THREE.IcosahedronGeometry.prototype=Object.create(THREE.Geometry.prototype);
THREE.OctahedronGeometry=function(a,b){THREE.PolyhedronGeometry.call(this,[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]],[[0,2,4],[0,4,3],[0,3,5],[0,5,2],[1,2,5],[1,5,3],[1,3,4],[1,4,2]],a,b)};THREE.OctahedronGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.TetrahedronGeometry=function(a,b){THREE.PolyhedronGeometry.call(this,[[1,1,1],[-1,-1,1],[-1,1,-1],[1,-1,-1]],[[2,1,0],[0,3,2],[1,3,0],[2,3,1]],a,b)};THREE.TetrahedronGeometry.prototype=Object.create(THREE.Geometry.prototype);
THREE.ParametricGeometry=function(a,b,c,d){THREE.Geometry.call(this);var e=this.vertices,f=this.faces,g=this.faceVertexUvs[0],d=d===void 0?false:d,h,i,j,m,n=b+1;for(h=0;h<=c;h++){m=h/c;for(i=0;i<=b;i++){j=i/b;j=a(j,m);e.push(j)}}var l,p,o,q;for(h=0;h<c;h++)for(i=0;i<b;i++){a=h*n+i;e=h*n+i+1;m=(h+1)*n+i;j=(h+1)*n+i+1;l=new THREE.UV(i/b,h/c);p=new THREE.UV((i+1)/b,h/c);o=new THREE.UV(i/b,(h+1)/c);q=new THREE.UV((i+1)/b,(h+1)/c);if(d){f.push(new THREE.Face3(a,e,m));f.push(new THREE.Face3(e,j,m));g.push([l,
p,o]);g.push([p,q,o])}else{f.push(new THREE.Face4(a,e,j,m));g.push([l,p,q,o])}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.ParametricGeometry.prototype=Object.create(THREE.Geometry.prototype);
THREE.ConvexGeometry=function(a){function b(a){var b=a.length();return new THREE.UV(a.x/b,a.y/b)}THREE.Geometry.call(this);for(var c=[[0,1,2],[0,2,1]],d=3;d<a.length;d++){var e=d,f=a[e].clone(),g=f.length();f.x=f.x+g*(Math.random()-0.5)*2E-6;f.y=f.y+g*(Math.random()-0.5)*2E-6;f.z=f.z+g*(Math.random()-0.5)*2E-6;for(var g=[],h=0;h<c.length;){var i=c[h],j=f,m=a[i[0]],n;n=m;var l=a[i[1]],p=a[i[2]],o=new THREE.Vector3,q=new THREE.Vector3;o.sub(p,l);q.sub(n,l);o.crossSelf(q);o.isZero()||o.normalize();n=
o;m=n.dot(m);if(n.dot(j)>=m){for(j=0;j<3;j++){m=[i[j],i[(j+1)%3]];n=true;for(l=0;l<g.length;l++)if(g[l][0]===m[1]&&g[l][1]===m[0]){g[l]=g[g.length-1];g.pop();n=false;break}n&&g.push(m)}c[h]=c[c.length-1];c.pop()}else h++}for(l=0;l<g.length;l++)c.push([g[l][0],g[l][1],e])}e=0;f=Array(a.length);for(d=0;d<c.length;d++){g=c[d];for(h=0;h<3;h++){if(f[g[h]]===void 0){f[g[h]]=e++;this.vertices.push(a[g[h]])}g[h]=f[g[h]]}}for(d=0;d<c.length;d++)this.faces.push(new THREE.Face3(c[d][0],c[d][1],c[d][2]));for(d=
0;d<this.faces.length;d++){g=this.faces[d];this.faceVertexUvs[0].push([b(this.vertices[g.a]),b(this.vertices[g.b]),b(this.vertices[g.c])])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.ConvexGeometry.prototype=Object.create(THREE.Geometry.prototype);
THREE.AxisHelper=function(a){var b=new THREE.Geometry;b.vertices.push(new THREE.Vector3,new THREE.Vector3(a||1,0,0),new THREE.Vector3,new THREE.Vector3(0,a||1,0),new THREE.Vector3,new THREE.Vector3(0,0,a||1));b.colors.push(new THREE.Color(16711680),new THREE.Color(16755200),new THREE.Color(65280),new THREE.Color(11206400),new THREE.Color(255),new THREE.Color(43775));a=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors});THREE.Line.call(this,b,a,THREE.LinePieces)};
THREE.AxisHelper.prototype=Object.create(THREE.Line.prototype);
THREE.ArrowHelper=function(a,b,c,d){THREE.Object3D.call(this);d===void 0&&(d=16776960);c===void 0&&(c=20);var e=new THREE.Geometry;e.vertices.push(new THREE.Vector3(0,0,0));e.vertices.push(new THREE.Vector3(0,1,0));this.line=new THREE.Line(e,new THREE.LineBasicMaterial({color:d}));this.add(this.line);e=new THREE.CylinderGeometry(0,0.05,0.25,5,1);this.cone=new THREE.Mesh(e,new THREE.MeshBasicMaterial({color:d}));this.cone.position.set(0,1,0);this.add(this.cone);if(b instanceof THREE.Vector3)this.position=
b;this.setDirection(a);this.setLength(c)};THREE.ArrowHelper.prototype=Object.create(THREE.Object3D.prototype);THREE.ArrowHelper.prototype.setDirection=function(a){var b=(new THREE.Vector3(0,1,0)).crossSelf(a),a=Math.acos((new THREE.Vector3(0,1,0)).dot(a.clone().normalize()));this.matrix=(new THREE.Matrix4).makeRotationAxis(b.normalize(),a);this.rotation.setEulerFromRotationMatrix(this.matrix,this.eulerOrder)};THREE.ArrowHelper.prototype.setLength=function(a){this.scale.set(a,a,a)};
THREE.ArrowHelper.prototype.setColor=function(a){this.line.material.color.setHex(a);this.cone.material.color.setHex(a)};
THREE.CameraHelper=function(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){d.geometry.vertices.push(new THREE.Vector3);d.geometry.colors.push(new THREE.Color(b));d.pointMap[a]===void 0&&(d.pointMap[a]=[]);d.pointMap[a].push(d.geometry.vertices.length-1)}THREE.Line.call(this);var d=this;this.geometry=new THREE.Geometry;this.material=new THREE.LineBasicMaterial({color:16777215,vertexColors:THREE.FaceColors});this.type=THREE.LinePieces;this.matrixWorld=a.matrixWorld;this.matrixAutoUpdate=false;this.pointMap=
{};b("n1","n2",16755200);b("n2","n4",16755200);b("n4","n3",16755200);b("n3","n1",16755200);b("f1","f2",16755200);b("f2","f4",16755200);b("f4","f3",16755200);b("f3","f1",16755200);b("n1","f1",16755200);b("n2","f2",16755200);b("n3","f3",16755200);b("n4","f4",16755200);b("p","n1",16711680);b("p","n2",16711680);b("p","n3",16711680);b("p","n4",16711680);b("u1","u2",43775);b("u2","u3",43775);b("u3","u1",43775);b("c","t",16777215);b("p","c",3355443);b("cn1","cn2",3355443);b("cn3","cn4",3355443);b("cf1",
"cf2",3355443);b("cf3","cf4",3355443);this.camera=a;this.update(a)};THREE.CameraHelper.prototype=Object.create(THREE.Line.prototype);
THREE.CameraHelper.prototype.update=function(){function a(a,d,e,f){THREE.CameraHelper.__v.set(d,e,f);THREE.CameraHelper.__projector.unprojectVector(THREE.CameraHelper.__v,THREE.CameraHelper.__c);a=b.pointMap[a];if(a!==void 0){d=0;for(e=a.length;d<e;d++)b.geometry.vertices[a[d]].copy(THREE.CameraHelper.__v)}}var b=this;THREE.CameraHelper.__c.projectionMatrix.copy(this.camera.projectionMatrix);a("c",0,0,-1);a("t",0,0,1);a("n1",-1,-1,-1);a("n2",1,-1,-1);a("n3",-1,1,-1);a("n4",1,1,-1);a("f1",-1,-1,1);
a("f2",1,-1,1);a("f3",-1,1,1);a("f4",1,1,1);a("u1",0.7,1.1,-1);a("u2",-0.7,1.1,-1);a("u3",0,2,-1);a("cf1",-1,0,1);a("cf2",1,0,1);a("cf3",0,-1,1);a("cf4",0,1,1);a("cn1",-1,0,-1);a("cn2",1,0,-1);a("cn3",0,-1,-1);a("cn4",0,1,-1);this.geometry.verticesNeedUpdate=true};THREE.CameraHelper.__projector=new THREE.Projector;THREE.CameraHelper.__v=new THREE.Vector3;THREE.CameraHelper.__c=new THREE.Camera;
A
alteredq 已提交
697 698 699 700
THREE.DirectionalLightHelper=function(a,b,c){THREE.Object3D.call(this);this.light=a;this.position=a.position;this.properties.isGizmo=true;this.color=a.color.clone();this.color.r=this.color.r*a.intensity;this.color.g=this.color.g*a.intensity;this.color.b=this.color.b*a.intensity;var d=this.color.getHex();this.direction=new THREE.Vector3;this.direction.sub(a.target.position,a.position);var e=new THREE.SphereGeometry(b,8,4),b=new THREE.SphereGeometry(b,16,8),f=new THREE.MeshBasicMaterial({color:d,fog:false});
this.lightArrow=new THREE.ArrowHelper(this.direction,null,c,d);this.lightSphere=new THREE.Mesh(b,f);this.lightArrow.cone.material.fog=false;this.lightArrow.line.material.fog=false;this.add(this.lightArrow);this.add(this.lightSphere);this.targetSphere=null;if(a.target.properties.targetInverse){c=new THREE.MeshBasicMaterial({color:d,wireframe:true,fog:false});this.targetSphere=new THREE.Mesh(e,c);this.targetSphere.position=a.target.position;this.targetSphere.properties.isGizmo=true;this.targetSphere.properties.gizmoSubject=
a.target;this.targetSphere.properties.gizmoRoot=this.targetSphere;d=new THREE.LineDashedMaterial({color:d,dashSize:4,gapSize:4,opacity:0.75,transparent:true,fog:false});e=new THREE.Geometry;e.vertices.push(this.position.clone());e.vertices.push(this.targetSphere.position.clone());e.computeLineDistances();this.targetLine=new THREE.Line(e,d);this.targetLine.properties.isGizmo=true}this.lightSphere.properties.isGizmo=true;this.lightSphere.properties.gizmoSubject=a;this.lightSphere.properties.gizmoRoot=
this};THREE.DirectionalLightHelper.prototype=Object.create(THREE.Object3D.prototype);
701
THREE.DirectionalLightHelper.prototype.update=function(){this.direction.sub(this.light.target.position,this.light.position);this.lightArrow.setDirection(this.direction);this.color.copy(this.light.color);var a=THREE.Math.clamp(this.light.intensity,0,1);this.color.r=this.color.r*a;this.color.g=this.color.g*a;this.color.b=this.color.b*a;this.lightArrow.setColor(this.color.getHex());this.lightSphere.material.color.copy(this.color);this.targetSphere.material.color.copy(this.color);this.targetLine.material.color.copy(this.color);
A
alteredq 已提交
702 703 704 705 706 707
this.targetLine.geometry.vertices[0].copy(this.light.position);this.targetLine.geometry.vertices[1].copy(this.light.target.position);this.targetLine.geometry.computeLineDistances();this.targetLine.geometry.verticesNeedUpdate=true};
THREE.PointLightHelper=function(a,b){THREE.Object3D.call(this);this.light=a;this.position=a.position;this.properties.isGizmo=true;this.color=a.color.clone();this.color.r=this.color.r*a.intensity;this.color.g=this.color.g*a.intensity;this.color.b=this.color.b*a.intensity;var c=this.color.getHex(),d=new THREE.SphereGeometry(b,16,8),e=new THREE.MeshBasicMaterial({color:c,fog:false});this.lightSphere=new THREE.Mesh(d,e);this.add(this.lightSphere);this.lightSphere.properties.isGizmo=true;this.lightSphere.properties.gizmoSubject=
a;this.lightSphere.properties.gizmoRoot=this;for(var c=new THREE.LineBasicMaterial({color:c,fog:false}),d=new THREE.Geometry,e=b*1.25,f=b*2.25,g=0.707*e,h=0.707*f,e=[[e,0,0],[f,0,0],[-e,0,0],[-f,0,0],[0,e,0],[0,f,0],[0,-e,0],[0,-f,0],[0,0,e],[0,0,f],[0,0,-e],[0,0,-f],[g,g,0],[h,h,0],[-g,-g,0],[-h,-h,0],[g,-g,0],[h,-h,0],[-g,g,0],[-h,h,0],[g,0,g],[h,0,h],[-g,0,-g],[-h,0,-h],[g,0,-g],[h,0,-h],[-g,0,g],[-h,0,h],[0,g,g],[0,h,h],[0,-g,-g],[0,-h,-h],[0,g,-g],[0,h,-h],[0,-g,g],[0,-h,h]],f=0,g=e.length;f<
g;f++)d.vertices.push(new THREE.Vector3(e[f][0],e[f][1],e[f][2]));this.lightLine=new THREE.Line(d,c,THREE.LinePieces);this.add(this.lightLine)};THREE.PointLightHelper.prototype=Object.create(THREE.Object3D.prototype);THREE.PointLightHelper.prototype.update=function(){this.color.copy(this.light.color);var a=THREE.Math.clamp(this.light.intensity,0,1);this.color.r=this.color.r*a;this.color.g=this.color.g*a;this.color.b=this.color.b*a;this.lightSphere.material.color.copy(this.color);this.lightLine.material.color.copy(this.color)};
THREE.SubdivisionModifier=function(a){this.subdivisions=a===void 0?1:a;this.useOldVertexColors=false;this.supportUVs=true;this.debug=false};THREE.SubdivisionModifier.prototype.modify=function(a){for(var b=this.subdivisions;b-- >0;)this.smooth(a)};THREE.GeometryUtils.orderedKey=function(a,b){return Math.min(a,b)+"_"+Math.max(a,b)};
THREE.GeometryUtils.computeEdgeFaces=function(a){function b(a,b){g[a]===void 0&&(g[a]=[]);g[a].push(b)}var c,d,e,f,g={},h=THREE.GeometryUtils.orderedKey;c=0;for(d=a.faces.length;c<d;c++){e=a.faces[c];if(e instanceof THREE.Face3){f=h(e.a,e.b);b(f,c);f=h(e.b,e.c);b(f,c);f=h(e.c,e.a);b(f,c)}else if(e instanceof THREE.Face4){f=h(e.a,e.b);b(f,c);f=h(e.b,e.c);b(f,c);f=h(e.c,e.d);b(f,c);f=h(e.d,e.a);b(f,c)}}return g};
708 709 710 711 712
THREE.SubdivisionModifier.prototype.smooth=function(a){function b(){m.debug&&(console&&console.assert)&&console.assert.apply(console,arguments)}function c(){m.debug&&console.log.apply(console,arguments)}function d(){console&&console.log.apply(console,arguments)}function e(a,b,d,e,g,h,l){var n=new THREE.Face4(a,b,d,e,null,g.color,g.materialIndex);if(m.useOldVertexColors){n.vertexColors=[];for(var o,p,q,s=0;s<4;s++){q=h[s];o=new THREE.Color;o.setRGB(0,0,0);for(var r=0;r<q.length;r++){p=g.vertexColors[q[r]-
1];o.r=o.r+p.r;o.g=o.g+p.g;o.b=o.b+p.b}o.r=o.r/q.length;o.g=o.g/q.length;o.b=o.b/q.length;n.vertexColors[s]=o}}i.push(n);if(m.supportUVs){g=[f(a,""),f(b,l),f(d,l),f(e,l)];g[0]?g[1]?g[2]?g[3]?j.push(g):c("d :( ",e+":"+l):c("c :( ",d+":"+l):c("b :( ",b+":"+l):c("a :( ",a+":"+l)}}function f(a,b){var e=a+":"+b,f=u[e];if(!f){a>=q&&a<q+o.length?c("face pt"):c("edge pt");d("warning, UV not found for",e);return null}return f}function g(a,b,c){var e=a+":"+b;e in u?d("dup vertexNo",a,"oldFaceNo",b,"value",
c,"key",e,u[e]):u[e]=c}var h=[],i=[],j=[],m=this,n=THREE.GeometryUtils.orderedKey,l=THREE.GeometryUtils.computeEdgeFaces,p=a.vertices,o=a.faces,q=p.length,h=p.concat(),s=[],r={},A={},u={},t,F,z,w,v,C=a.faceVertexUvs[0],D;c("originalFaces, uvs, originalVerticesLength",o.length,C.length,q);if(m.supportUVs){t=0;for(F=C.length;t<F;t++){z=0;for(w=C[t].length;z<w;z++){D=o[t]["abcd".charAt(z)];g(D,t,C[t][z])}}}if(C.length==0)m.supportUVs=false;t=0;for(var I in u)t++;if(!t){m.supportUVs=false;c("no uvs")}t=
0;for(F=o.length;t<F;t++){v=o[t];s.push(v.centroid);h.push(v.centroid);if(m.supportUVs){w=new THREE.UV;if(v instanceof THREE.Face3){w.u=f(v.a,t).u+f(v.b,t).u+f(v.c,t).u;w.v=f(v.a,t).v+f(v.b,t).v+f(v.c,t).v;w.u=w.u/3;w.v=w.v/3}else if(v instanceof THREE.Face4){w.u=f(v.a,t).u+f(v.b,t).u+f(v.c,t).u+f(v.d,t).u;w.v=f(v.a,t).v+f(v.b,t).v+f(v.c,t).v+f(v.d,t).v;w.u=w.u/4;w.v=w.v/4}g(q+t,"",w)}}var l=l(a),L;F=0;var B,K;I={};C={};for(t in l){D=l[t];B=t.split("_");K=B[0];B=B[1];z=K;v=[K,B];I[z]===void 0&&(I[z]=
[]);I[z].push(v);z=B;v=[K,B];I[z]===void 0&&(I[z]=[]);I[z].push(v);z=0;for(w=D.length;z<w;z++){v=D[z];L=K;var H=v,G=t;C[L]===void 0&&(C[L]={});C[L][H]=G;L=B;H=t;C[L]===void 0&&(C[L]={});C[L][v]=H}D.length<2&&(A[t]=true)}for(t in l){D=l[t];v=D[0];L=D[1];B=t.split("_");K=B[0];B=B[1];w=new THREE.Vector3;b(D.length>0,"an edge without faces?!");if(D.length==1){w.addSelf(p[K]);w.addSelf(p[B]);w.multiplyScalar(0.5)}else{w.addSelf(s[v]);w.addSelf(s[L]);w.addSelf(p[K]);w.addSelf(p[B]);w.multiplyScalar(0.25)}r[t]=
713 714
q+o.length+F;h.push(w);F++;if(m.supportUVs){w=new THREE.UV;w.u=f(K,v).u+f(B,v).u;w.v=f(K,v).v+f(B,v).v;w.u=w.u/2;w.v=w.v/2;g(r[t],v,w);if(D.length>=2){b(D.length==2,"did we plan for more than 2 edges?");w=new THREE.UV;w.u=f(K,L).u+f(B,L).u;w.v=f(K,L).v+f(B,L).v;w.u=w.u/2;w.v=w.v/2;g(r[t],L,w)}}}c("-- Step 2 done");var M,N;w=["123","12","2","23"];L=["123","23","3","31"];var H=["123","31","1","12"],G=["1234","12","2","23"],R=["1234","23","3","34"],aa=["1234","34","4","41"],P=["1234","41","1","12"];
t=0;for(F=s.length;t<F;t++){v=o[t];D=q+t;if(v instanceof THREE.Face3){K=n(v.a,v.b);B=n(v.b,v.c);M=n(v.c,v.a);e(D,r[K],v.b,r[B],v,w,t);e(D,r[B],v.c,r[M],v,L,t);e(D,r[M],v.a,r[K],v,H,t)}else if(v instanceof THREE.Face4){K=n(v.a,v.b);B=n(v.b,v.c);M=n(v.c,v.d);N=n(v.d,v.a);e(D,r[K],v.b,r[B],v,G,t);e(D,r[B],v.c,r[M],v,R,t);e(D,r[M],v.d,r[N],v,aa,t);e(D,r[N],v.a,r[K],v,P,t)}else c("face should be a face!",v)}r=new THREE.Vector3;v=new THREE.Vector3;t=0;for(F=p.length;t<F;t++)if(I[t]!==void 0){r.set(0,0,
715 716
0);v.set(0,0,0);B=new THREE.Vector3(0,0,0);D=0;for(z in C[t]){r.addSelf(s[z]);D++}L=0;K=I[t].length;w=D!=K;for(z=0;z<K;z++)A[n(I[t][z][0],I[t][z][1])]&&L++;r.divideScalar(D);L=0;if(w){for(z=0;z<K;z++){D=I[t][z];if(H=l[n(D[0],D[1])].length==1){D=p[D[0]].clone().addSelf(p[D[1]]).divideScalar(2);v.addSelf(D);L++}}v.divideScalar(4);b(L==2,"should have only 2 boundary edges")}else{for(z=0;z<K;z++){D=I[t][z];D=p[D[0]].clone().addSelf(p[D[1]]).divideScalar(2);v.addSelf(D)}v.divideScalar(K)}B.addSelf(p[t]);
if(w){B.divideScalar(2);B.addSelf(v)}else{B.multiplyScalar(K-3);B.addSelf(r);B.addSelf(v.multiplyScalar(2));B.divideScalar(K)}h[t]=B}a.vertices=h;a.faces=i;a.faceVertexUvs[0]=j;delete a.__tmpVertices;a.computeCentroids();a.computeFaceNormals();a.computeVertexNormals()};THREE.ImmediateRenderObject=function(){THREE.Object3D.call(this);this.render=function(){}};THREE.ImmediateRenderObject.prototype=Object.create(THREE.Object3D.prototype);
A
alteredq 已提交
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731
THREE.LensFlare=function(a,b,c,d,e){THREE.Object3D.call(this);this.lensFlares=[];this.positionScreen=new THREE.Vector3;this.customUpdateCallback=void 0;a!==void 0&&this.add(a,b,c,d,e)};THREE.LensFlare.prototype=Object.create(THREE.Object3D.prototype);
THREE.LensFlare.prototype.add=function(a,b,c,d,e,f){b===void 0&&(b=-1);c===void 0&&(c=0);f===void 0&&(f=1);e===void 0&&(e=new THREE.Color(16777215));if(d===void 0)d=THREE.NormalBlending;c=Math.min(c,Math.max(0,c));this.lensFlares.push({texture:a,size:b,distance:c,x:0,y:0,z:0,scale:1,rotation:1,opacity:f,color:e,blending:d})};
THREE.LensFlare.prototype.updateLensFlares=function(){var a,b=this.lensFlares.length,c,d=-this.positionScreen.x*2,e=-this.positionScreen.y*2;for(a=0;a<b;a++){c=this.lensFlares[a];c.x=this.positionScreen.x+d*c.distance;c.y=this.positionScreen.y+e*c.distance;c.wantedRotation=c.x*Math.PI*0.25;c.rotation=c.rotation+(c.wantedRotation-c.rotation)*0.25}};
THREE.MorphBlendMesh=function(a,b){THREE.Mesh.call(this,a,b);this.animationsMap={};this.animationsList=[];var c=this.geometry.morphTargets.length;this.createAnimation("__default",0,c-1,c/1);this.setAnimationWeight("__default",1)};THREE.MorphBlendMesh.prototype=Object.create(THREE.Mesh.prototype);
THREE.MorphBlendMesh.prototype.createAnimation=function(a,b,c,d){b={startFrame:b,endFrame:c,length:c-b+1,fps:d,duration:(c-b)/d,lastFrame:0,currentFrame:0,active:false,time:0,direction:1,weight:1,directionBackwards:false,mirroredLoop:false};this.animationsMap[a]=b;this.animationsList.push(b)};
THREE.MorphBlendMesh.prototype.autoCreateAnimations=function(a){for(var b=/([a-z]+)(\d+)/,c,d={},e=this.geometry,f=0,g=e.morphTargets.length;f<g;f++){var h=e.morphTargets[f].name.match(b);if(h&&h.length>1){var i=h[1];d[i]||(d[i]={start:Infinity,end:-Infinity});h=d[i];if(f<h.start)h.start=f;if(f>h.end)h.end=f;c||(c=i)}}for(i in d){h=d[i];this.createAnimation(i,h.start,h.end,a)}this.firstAnimation=c};
THREE.MorphBlendMesh.prototype.setAnimationDirectionForward=function(a){if(a=this.animationsMap[a]){a.direction=1;a.directionBackwards=false}};THREE.MorphBlendMesh.prototype.setAnimationDirectionBackward=function(a){if(a=this.animationsMap[a]){a.direction=-1;a.directionBackwards=true}};THREE.MorphBlendMesh.prototype.setAnimationFPS=function(a,b){var c=this.animationsMap[a];if(c){c.fps=b;c.duration=(c.end-c.start)/c.fps}};
THREE.MorphBlendMesh.prototype.setAnimationDuration=function(a,b){var c=this.animationsMap[a];if(c){c.duration=b;c.fps=(c.end-c.start)/c.duration}};THREE.MorphBlendMesh.prototype.setAnimationWeight=function(a,b){var c=this.animationsMap[a];if(c)c.weight=b};THREE.MorphBlendMesh.prototype.setAnimationTime=function(a,b){var c=this.animationsMap[a];if(c)c.time=b};THREE.MorphBlendMesh.prototype.getAnimationTime=function(a){var b=0;if(a=this.animationsMap[a])b=a.time;return b};
THREE.MorphBlendMesh.prototype.getAnimationDuration=function(a){var b=-1;if(a=this.animationsMap[a])b=a.duration;return b};THREE.MorphBlendMesh.prototype.playAnimation=function(a){var b=this.animationsMap[a];if(b){b.time=0;b.active=true}else console.warn("animation["+a+"] undefined")};THREE.MorphBlendMesh.prototype.stopAnimation=function(a){if(a=this.animationsMap[a])a.active=false};
THREE.MorphBlendMesh.prototype.update=function(a){for(var b=0,c=this.animationsList.length;b<c;b++){var d=this.animationsList[b];if(d.active){var e=d.duration/d.length;d.time=d.time+d.direction*a;if(d.mirroredLoop){if(d.time>d.duration||d.time<0){d.direction=d.direction*-1;if(d.time>d.duration){d.time=d.duration;d.directionBackwards=true}if(d.time<0){d.time=0;d.directionBackwards=false}}}else{d.time=d.time%d.duration;if(d.time<0)d.time=d.time+d.duration}var f=d.startFrame+THREE.Math.clamp(Math.floor(d.time/
e),0,d.length-1),g=d.weight;if(f!==d.currentFrame){this.morphTargetInfluences[d.lastFrame]=0;this.morphTargetInfluences[d.currentFrame]=1*g;this.morphTargetInfluences[f]=0;d.lastFrame=d.currentFrame;d.currentFrame=f}e=d.time%e/e;d.directionBackwards&&(e=1-e);this.morphTargetInfluences[d.currentFrame]=e*g;this.morphTargetInfluences[d.lastFrame]=(1-e)*g}}};
THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.createShader(b.FRAGMENT_SHADER),e=b.createShader(b.VERTEX_SHADER);b.shaderSource(d,a.fragmentShader);b.shaderSource(e,a.vertexShader);b.compileShader(d);b.compileShader(e);b.attachShader(c,d);b.attachShader(c,e);b.linkProgram(c);return c}var b,c,d,e,f,g,h,i,j,m,n,l,p;this.init=function(o){b=o.context;c=o;d=new Float32Array(16);e=new Uint16Array(6);o=0;d[o++]=-1;d[o++]=-1;d[o++]=0;d[o++]=0;d[o++]=1;d[o++]=-1;d[o++]=1;d[o++]=
0;d[o++]=1;d[o++]=1;d[o++]=1;d[o++]=1;d[o++]=-1;d[o++]=1;d[o++]=0;d[o++]=1;o=0;e[o++]=0;e[o++]=1;e[o++]=2;e[o++]=0;e[o++]=2;e[o++]=3;f=b.createBuffer();g=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,f);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,b.STATIC_DRAW);h=b.createTexture();i=b.createTexture();b.bindTexture(b.TEXTURE_2D,h);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16,0,b.RGB,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,
b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);b.bindTexture(b.TEXTURE_2D,i);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,16,16,0,b.RGBA,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);
b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);if(b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){j=false;m=a(THREE.ShaderFlares.lensFlare)}else{j=true;m=a(THREE.ShaderFlares.lensFlareVertexTexture)}n={};l={};n.vertex=b.getAttribLocation(m,"position");n.uv=b.getAttribLocation(m,"uv");l.renderType=b.getUniformLocation(m,"renderType");l.map=b.getUniformLocation(m,"map");l.occlusionMap=b.getUniformLocation(m,"occlusionMap");l.opacity=b.getUniformLocation(m,"opacity");l.color=b.getUniformLocation(m,
732 733 734 735
"color");l.scale=b.getUniformLocation(m,"scale");l.rotation=b.getUniformLocation(m,"rotation");l.screenPosition=b.getUniformLocation(m,"screenPosition");p=false};this.render=function(a,d,e,r){var a=a.__webglFlares,A=a.length;if(A){var u=new THREE.Vector3,t=r/e,F=e*0.5,z=r*0.5,w=16/r,v=new THREE.Vector2(w*t,w),C=new THREE.Vector3(1,1,0),D=new THREE.Vector2(1,1),I=l,w=n;b.useProgram(m);if(!p){b.enableVertexAttribArray(n.vertex);b.enableVertexAttribArray(n.uv);p=true}b.uniform1i(I.occlusionMap,0);b.uniform1i(I.map,
1);b.bindBuffer(b.ARRAY_BUFFER,f);b.vertexAttribPointer(w.vertex,2,b.FLOAT,false,16,0);b.vertexAttribPointer(w.uv,2,b.FLOAT,false,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.disable(b.CULL_FACE);b.depthMask(false);var L,B,K,H,G;for(L=0;L<A;L++){w=16/r;v.set(w*t,w);H=a[L];u.set(H.matrixWorld.elements[12],H.matrixWorld.elements[13],H.matrixWorld.elements[14]);d.matrixWorldInverse.multiplyVector3(u);d.projectionMatrix.multiplyVector3(u);C.copy(u);D.x=C.x*F+F;D.y=C.y*z+z;if(j||D.x>0&&D.x<e&&D.y>0&&
D.y<r){b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,h);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,D.x-8,D.y-8,16,16,0);b.uniform1i(I.renderType,0);b.uniform2f(I.scale,v.x,v.y);b.uniform3f(I.screenPosition,C.x,C.y,C.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,i);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,D.x-8,D.y-8,16,16,0);b.uniform1i(I.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);H.positionScreen.copy(C);H.customUpdateCallback?H.customUpdateCallback(H):H.updateLensFlares();b.uniform1i(I.renderType,2);b.enable(b.BLEND);B=0;for(K=H.lensFlares.length;B<K;B++){G=H.lensFlares[B];if(G.opacity>0.001&&G.scale>0.001){C.x=G.x;C.y=G.y;C.z=G.z;w=G.size*G.scale/r;v.x=w*t;v.y=w;b.uniform3f(I.screenPosition,C.x,C.y,C.z);b.uniform2f(I.scale,v.x,v.y);b.uniform1f(I.rotation,G.rotation);b.uniform1f(I.opacity,G.opacity);
736
b.uniform3f(I.color,G.color.r,G.color.g,G.color.b);c.setBlending(G.blending,G.blendEquation,G.blendSrc,G.blendDst);c.setTexture(G.texture,1);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}}}}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(true)}}};
A
alteredq 已提交
737
THREE.ShadowMapPlugin=function(){var a,b,c,d,e,f,g=new THREE.Frustum,h=new THREE.Matrix4,i=new THREE.Vector3,j=new THREE.Vector3;this.init=function(g){a=g.context;b=g;var g=THREE.ShaderLib.depthRGBA,h=THREE.UniformsUtils.clone(g.uniforms);c=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h});d=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h,morphTargets:true});e=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,
738 739 740 741 742
vertexShader:g.vertexShader,uniforms:h,skinning:true});f=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h,morphTargets:true,skinning:true});c._shadowPass=true;d._shadowPass=true;e._shadowPass=true;f._shadowPass=true};this.render=function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(m,n){var l,p,o,q,s,r,A,u,t,F=[];q=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);a.enable(a.CULL_FACE);a.frontFace(a.CCW);b.shadowMapCullFrontFaces?
a.cullFace(a.FRONT):a.cullFace(a.BACK);b.setDepthTest(true);l=0;for(p=m.__lights.length;l<p;l++){o=m.__lights[l];if(o.castShadow)if(o instanceof THREE.DirectionalLight&&o.shadowCascade)for(s=0;s<o.shadowCascadeCount;s++){var z;if(o.shadowCascadeArray[s])z=o.shadowCascadeArray[s];else{t=o;A=s;z=new THREE.DirectionalLight;z.isVirtual=true;z.onlyShadow=true;z.castShadow=true;z.shadowCameraNear=t.shadowCameraNear;z.shadowCameraFar=t.shadowCameraFar;z.shadowCameraLeft=t.shadowCameraLeft;z.shadowCameraRight=
t.shadowCameraRight;z.shadowCameraBottom=t.shadowCameraBottom;z.shadowCameraTop=t.shadowCameraTop;z.shadowCameraVisible=t.shadowCameraVisible;z.shadowDarkness=t.shadowDarkness;z.shadowBias=t.shadowCascadeBias[A];z.shadowMapWidth=t.shadowCascadeWidth[A];z.shadowMapHeight=t.shadowCascadeHeight[A];z.pointsWorld=[];z.pointsFrustum=[];u=z.pointsWorld;r=z.pointsFrustum;for(var w=0;w<8;w++){u[w]=new THREE.Vector3;r[w]=new THREE.Vector3}u=t.shadowCascadeNearZ[A];t=t.shadowCascadeFarZ[A];r[0].set(-1,-1,u);
r[1].set(1,-1,u);r[2].set(-1,1,u);r[3].set(1,1,u);r[4].set(-1,-1,t);r[5].set(1,-1,t);r[6].set(-1,1,t);r[7].set(1,1,t);z.originalCamera=n;r=new THREE.Gyroscope;r.position=o.shadowCascadeOffset;r.add(z);r.add(z.target);n.add(r);o.shadowCascadeArray[s]=z;console.log("Created virtualLight",z)}A=o;u=s;t=A.shadowCascadeArray[u];t.position.copy(A.position);t.target.position.copy(A.target.position);t.lookAt(t.target);t.shadowCameraVisible=A.shadowCameraVisible;t.shadowDarkness=A.shadowDarkness;t.shadowBias=
A.shadowCascadeBias[u];r=A.shadowCascadeNearZ[u];A=A.shadowCascadeFarZ[u];t=t.pointsFrustum;t[0].z=r;t[1].z=r;t[2].z=r;t[3].z=r;t[4].z=A;t[5].z=A;t[6].z=A;t[7].z=A;F[q]=z;q++}else{F[q]=o;q++}}l=0;for(p=F.length;l<p;l++){o=F[l];if(!o.shadowMap){o.shadowMap=new THREE.WebGLRenderTarget(o.shadowMapWidth,o.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat});o.shadowMapSize=new THREE.Vector2(o.shadowMapWidth,o.shadowMapHeight);o.shadowMatrix=new THREE.Matrix4}if(!o.shadowCamera){if(o instanceof
A
alteredq 已提交
743
THREE.SpotLight)o.shadowCamera=new THREE.PerspectiveCamera(o.shadowCameraFov,o.shadowMapWidth/o.shadowMapHeight,o.shadowCameraNear,o.shadowCameraFar);else if(o instanceof THREE.DirectionalLight)o.shadowCamera=new THREE.OrthographicCamera(o.shadowCameraLeft,o.shadowCameraRight,o.shadowCameraTop,o.shadowCameraBottom,o.shadowCameraNear,o.shadowCameraFar);else{console.error("Unsupported light type for shadow");continue}m.add(o.shadowCamera);b.autoUpdateScene&&m.updateMatrixWorld()}if(o.shadowCameraVisible&&
744 745 746 747 748
!o.cameraHelper){o.cameraHelper=new THREE.CameraHelper(o.shadowCamera);o.shadowCamera.add(o.cameraHelper)}if(o.isVirtual&&z.originalCamera==n){s=n;q=o.shadowCamera;r=o.pointsFrustum;t=o.pointsWorld;i.set(Infinity,Infinity,Infinity);j.set(-Infinity,-Infinity,-Infinity);for(A=0;A<8;A++){u=t[A];u.copy(r[A]);THREE.ShadowMapPlugin.__projector.unprojectVector(u,s);q.matrixWorldInverse.multiplyVector3(u);if(u.x<i.x)i.x=u.x;if(u.x>j.x)j.x=u.x;if(u.y<i.y)i.y=u.y;if(u.y>j.y)j.y=u.y;if(u.z<i.z)i.z=u.z;if(u.z>
j.z)j.z=u.z}q.left=i.x;q.right=j.x;q.top=j.y;q.bottom=i.y;q.updateProjectionMatrix()}q=o.shadowMap;r=o.shadowMatrix;s=o.shadowCamera;s.position.copy(o.matrixWorld.getPosition());s.lookAt(o.target.matrixWorld.getPosition());s.updateMatrixWorld();s.matrixWorldInverse.getInverse(s.matrixWorld);if(o.cameraHelper)o.cameraHelper.visible=o.shadowCameraVisible;o.shadowCameraVisible&&o.cameraHelper.update();r.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);r.multiplySelf(s.projectionMatrix);r.multiplySelf(s.matrixWorldInverse);
if(!s._viewMatrixArray)s._viewMatrixArray=new Float32Array(16);if(!s._projectionMatrixArray)s._projectionMatrixArray=new Float32Array(16);s.matrixWorldInverse.flattenToArray(s._viewMatrixArray);s.projectionMatrix.flattenToArray(s._projectionMatrixArray);h.multiply(s.projectionMatrix,s.matrixWorldInverse);g.setFromMatrix(h);b.setRenderTarget(q);b.clear();t=m.__webglObjects;o=0;for(q=t.length;o<q;o++){A=t[o];r=A.object;A.render=false;if(r.visible&&r.castShadow&&(!(r instanceof THREE.Mesh)||!r.frustumCulled||
g.contains(r))){r._modelViewMatrix.multiply(s.matrixWorldInverse,r.matrixWorld);A.render=true}}o=0;for(q=t.length;o<q;o++){A=t[o];if(A.render){r=A.object;A=A.buffer;w=r.material instanceof THREE.MeshFaceMaterial?r.geometry.materials[0]:r.material;u=r.geometry.morphTargets.length>0&&w.morphTargets;w=r instanceof THREE.SkinnedMesh&&w.skinning;u=r.customDepthMaterial?r.customDepthMaterial:w?u?f:e:u?d:c;A instanceof THREE.BufferGeometry?b.renderBufferDirect(s,m.__lights,null,u,A,r):b.renderBuffer(s,m.__lights,
null,u,A,r)}}t=m.__webglObjectsImmediate;o=0;for(q=t.length;o<q;o++){A=t[o];r=A.object;if(r.visible&&r.castShadow){r._modelViewMatrix.multiply(s.matrixWorldInverse,r.matrixWorld);b.renderImmediateObject(s,m.__lights,null,c,r)}}}l=b.getClearColor();p=b.getClearAlpha();a.clearColor(l.r,l.g,l.b,p);a.enable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.BACK)}};THREE.ShadowMapPlugin.__projector=new THREE.Projector;
A
alteredq 已提交
749 750 751
THREE.SpritePlugin=function(){function a(a,b){return a.z!==b.z?b.z-a.z:b.id-a.id}var b,c,d,e,f,g,h,i,j,m;this.init=function(a){b=a.context;c=a;d=new Float32Array(16);e=new Uint16Array(6);a=0;d[a++]=-1;d[a++]=-1;d[a++]=0;d[a++]=0;d[a++]=1;d[a++]=-1;d[a++]=1;d[a++]=0;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=-1;d[a++]=1;d[a++]=0;d[a++]=1;a=0;e[a++]=0;e[a++]=1;e[a++]=2;e[a++]=0;e[a++]=2;e[a++]=3;f=b.createBuffer();g=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,f);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);
b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,l=b.createProgram(),p=b.createShader(b.FRAGMENT_SHADER),o=b.createShader(b.VERTEX_SHADER);b.shaderSource(p,a.fragmentShader);b.shaderSource(o,a.vertexShader);b.compileShader(p);b.compileShader(o);b.attachShader(l,p);b.attachShader(l,o);b.linkProgram(l);h=l;i={};j={};i.position=b.getAttribLocation(h,"position");i.uv=b.getAttribLocation(h,"uv");j.uvOffset=b.getUniformLocation(h,
"uvOffset");j.uvScale=b.getUniformLocation(h,"uvScale");j.rotation=b.getUniformLocation(h,"rotation");j.scale=b.getUniformLocation(h,"scale");j.alignment=b.getUniformLocation(h,"alignment");j.color=b.getUniformLocation(h,"color");j.map=b.getUniformLocation(h,"map");j.opacity=b.getUniformLocation(h,"opacity");j.useScreenCoordinates=b.getUniformLocation(h,"useScreenCoordinates");j.affectedByDistance=b.getUniformLocation(h,"affectedByDistance");j.screenPosition=b.getUniformLocation(h,"screenPosition");
752 753 754 755 756
j.modelViewMatrix=b.getUniformLocation(h,"modelViewMatrix");j.projectionMatrix=b.getUniformLocation(h,"projectionMatrix");j.fogType=b.getUniformLocation(h,"fogType");j.fogDensity=b.getUniformLocation(h,"fogDensity");j.fogNear=b.getUniformLocation(h,"fogNear");j.fogFar=b.getUniformLocation(h,"fogFar");j.fogColor=b.getUniformLocation(h,"fogColor");m=false};this.render=function(d,e,p,o){var q=d.__webglSprites,s=q.length;if(s){var r=i,A=j,u=o/p,p=p*0.5,t=o*0.5,F=true;b.useProgram(h);if(!m){b.enableVertexAttribArray(r.position);
b.enableVertexAttribArray(r.uv);m=true}b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(true);b.bindBuffer(b.ARRAY_BUFFER,f);b.vertexAttribPointer(r.position,2,b.FLOAT,false,16,0);b.vertexAttribPointer(r.uv,2,b.FLOAT,false,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.uniformMatrix4fv(A.projectionMatrix,false,e._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(A.map,0);var z=r=0,w=d.fog;if(w){b.uniform3f(A.fogColor,w.color.r,w.color.g,w.color.b);if(w instanceof THREE.Fog){b.uniform1f(A.fogNear,
w.near);b.uniform1f(A.fogFar,w.far);b.uniform1i(A.fogType,1);z=r=1}else if(w instanceof THREE.FogExp2){b.uniform1f(A.fogDensity,w.density);b.uniform1i(A.fogType,2);z=r=2}}else{b.uniform1i(A.fogType,0);z=r=0}for(var v,C=[],w=0;w<s;w++){v=q[w];if(v.visible&&v.opacity!==0)if(v.useScreenCoordinates)v.z=-v.position.z;else{v._modelViewMatrix.multiply(e.matrixWorldInverse,v.matrixWorld);v.z=-v._modelViewMatrix.elements[14]}}q.sort(a);for(w=0;w<s;w++){v=q[w];if(v.visible&&v.opacity!==0&&v.map&&v.map.image&&
v.map.image.width){if(v.useScreenCoordinates){b.uniform1i(A.useScreenCoordinates,1);b.uniform3f(A.screenPosition,(v.position.x-p)/p,(t-v.position.y)/t,Math.max(0,Math.min(1,v.position.z)))}else{b.uniform1i(A.useScreenCoordinates,0);b.uniform1i(A.affectedByDistance,v.affectedByDistance?1:0);b.uniformMatrix4fv(A.modelViewMatrix,false,v._modelViewMatrix.elements)}e=d.fog&&v.fog?z:0;if(r!==e){b.uniform1i(A.fogType,e);r=e}e=1/(v.scaleByViewport?o:1);C[0]=e*u*v.scale.x;C[1]=e*v.scale.y;b.uniform2f(A.uvScale,
v.uvScale.x,v.uvScale.y);b.uniform2f(A.uvOffset,v.uvOffset.x,v.uvOffset.y);b.uniform2f(A.alignment,v.alignment.x,v.alignment.y);b.uniform1f(A.opacity,v.opacity);b.uniform3f(A.color,v.color.r,v.color.g,v.color.b);b.uniform1f(A.rotation,v.rotation);b.uniform2fv(A.scale,C);if(v.mergeWith3D&&!F){b.enable(b.DEPTH_TEST);F=true}else if(!v.mergeWith3D&&F){b.disable(b.DEPTH_TEST);F=false}c.setBlending(v.blending,v.blendEquation,v.blendSrc,v.blendDst);c.setTexture(v.map,0);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,
A
alteredq 已提交
757
0)}}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(true)}}};
A
alteredq 已提交
758 759 760 761 762 763 764 765
THREE.DepthPassPlugin=function(){this.enabled=false;this.renderTarget=null;var a,b,c,d,e=new THREE.Frustum,f=new THREE.Matrix4;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:true});c._shadowPass=true;d._shadowPass=true};this.render=
function(a,b){this.enabled&&this.update(a,b)};this.update=function(g,h){var i,j,m,n,l,p;a.clearColor(1,1,1,1);a.disable(a.BLEND);b.setDepthTest(true);b.autoUpdateScene&&g.updateMatrixWorld();if(!h._viewMatrixArray)h._viewMatrixArray=new Float32Array(16);if(!h._projectionMatrixArray)h._projectionMatrixArray=new Float32Array(16);h.matrixWorldInverse.getInverse(h.matrixWorld);h.matrixWorldInverse.flattenToArray(h._viewMatrixArray);h.projectionMatrix.flattenToArray(h._projectionMatrixArray);f.multiply(h.projectionMatrix,
h.matrixWorldInverse);e.setFromMatrix(f);b.setRenderTarget(this.renderTarget);b.clear();p=g.__webglObjects;i=0;for(j=p.length;i<j;i++){m=p[i];l=m.object;m.render=false;if(l.visible&&(!(l instanceof THREE.Mesh)||!l.frustumCulled||e.contains(l))){l._modelViewMatrix.multiply(h.matrixWorldInverse,l.matrixWorld);m.render=true}}i=0;for(j=p.length;i<j;i++){m=p[i];if(m.render){l=m.object;m=m.buffer;l.material&&b.setMaterialFaces(l.material);n=l.customDepthMaterial?l.customDepthMaterial:l.geometry.morphTargets.length?
d:c;m instanceof THREE.BufferGeometry?b.renderBufferDirect(h,g.__lights,null,n,m,l):b.renderBuffer(h,g.__lights,null,n,m,l)}}p=g.__webglObjectsImmediate;i=0;for(j=p.length;i<j;i++){m=p[i];l=m.object;if(l.visible&&l.castShadow){l._modelViewMatrix.multiply(h.matrixWorldInverse,l.matrixWorld);b.renderImmediateObject(h,g.__lights,null,c,l)}}i=b.getClearColor();j=b.getClearAlpha();a.clearColor(i.r,i.g,i.b,j);a.enable(a.BLEND)}};
THREE.ShaderFlares={lensFlareVertexTexture:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nuniform sampler2D occlusionMap;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif( renderType == 2 ) {\nvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.5 ) );\nvVisibility = (       visibility.r / 9.0 ) *\n( 1.0 - visibility.g / 9.0 ) *\n(       visibility.b / 9.0 ) *\n( 1.0 - visibility.a / 9.0 );\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"precision mediump float;\nuniform sampler2D map;\nuniform float opacity;\nuniform int renderType;\nuniform vec3 color;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * vVisibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"},
lensFlare:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif( renderType == 2 ) {\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"precision mediump float;\nuniform sampler2D map;\nuniform sampler2D occlusionMap;\nuniform float opacity;\nuniform int renderType;\nuniform vec3 color;\nvarying vec2 vUV;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( texture2D( map, vUV ).rgb, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nfloat visibility = texture2D( occlusionMap, vec2( 0.5, 0.1 ) ).a +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 ) ).a +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 ) ).a +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 ) ).a;\nvisibility = ( 1.0 - visibility / 4.0 );\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * visibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"}};
THREE.ShaderSprite={sprite:{vertexShader:"uniform int useScreenCoordinates;\nuniform int affectedByDistance;\nuniform vec3 screenPosition;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 alignment;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position + alignment;\nvec2 rotatedPosition;\nrotatedPosition.x = ( cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y ) * scale.x;\nrotatedPosition.y = ( sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y ) * scale.y;\nvec4 finalPosition;\nif( useScreenCoordinates != 0 ) {\nfinalPosition = vec4( screenPosition.xy + rotatedPosition, screenPosition.z, 1.0 );\n} else {\nfinalPosition = projectionMatrix * modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition * ( affectedByDistance == 1 ? 1.0 : finalPosition.z );\n}\ngl_Position = finalPosition;\n}",
fragmentShader:"precision mediump float;\nuniform vec3 color;\nuniform sampler2D map;\nuniform float opacity;\nuniform int fogType;\nuniform vec3 fogColor;\nuniform float fogDensity;\nuniform float fogNear;\nuniform float fogFar;\nvarying vec2 vUV;\nvoid main() {\nvec4 texture = texture2D( map, vUV );\ngl_FragColor = vec4( color * texture.xyz, texture.a * opacity );\nif ( fogType > 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"}};