@thiagopnts/kaleidoscope
Version:
360º video/image viewer
2 lines • 262 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Kaleidoscope=t.Kaleidoscope||{})}(this,function(t){"use strict";function e(t,e){return e={exports:{}},t(e,e.exports),e.exports}var i={isiPhone:function(){return/iphone.*(7|8|9)_[0-9]/i.test(navigator.userAgent)},isIE:function(){return/Trident/i.test(navigator.userAgent)}},r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},n=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=function(){function t(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,i,r){return i&&t(e.prototype,i),r&&t(e,r),e}}(),o=function t(e,i,r){null===e&&(e=Function.prototype);var n=Object.getOwnPropertyDescriptor(e,i);if(void 0===n){var a=Object.getPrototypeOf(e);return null===a?void 0:t(a,i,r)}if("value"in n)return n.value;var o=n.get;if(void 0!==o)return o.call(r)},s=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},h=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},u=e(function(t,e){var i={REVISION:"75"};"function"==typeof define&&define.amd?define("three",i):"undefined"!=typeof e&&"undefined"!=typeof t&&(t.exports=i),void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Math.sign&&(Math.sign=function(t){return t<0?-1:t>0?1:+t}),void 0===Function.prototype.name&&void 0!==Object.defineProperty&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]}}),void 0===Object.assign&&Object.defineProperty(Object,"assign",{writable:!0,configurable:!0,value:function(t){if(void 0===t||null===t)throw new TypeError("Cannot convert first argument to object");for(var e=Object(t),i=1,r=arguments.length;i!==r;++i){var n=arguments[i];if(void 0!==n&&null!==n){n=Object(n);for(var a=Object.keys(n),o=0,s=a.length;o!==s;++o){var h=a[o],u=Object.getOwnPropertyDescriptor(n,h);void 0!==u&&u.enumerable&&(e[h]=n[h])}}}return e}}),i.MOUSE={LEFT:0,MIDDLE:1,RIGHT:2},i.CullFaceNone=0,i.CullFaceBack=1,i.CullFaceFront=2,i.CullFaceFrontBack=3,i.FrontFaceDirectionCW=0,i.FrontFaceDirectionCCW=1,i.BasicShadowMap=0,i.PCFShadowMap=1,i.PCFSoftShadowMap=2,i.FrontSide=0,i.BackSide=1,i.DoubleSide=2,i.FlatShading=1,i.SmoothShading=2,i.NoColors=0,i.FaceColors=1,i.VertexColors=2,i.NoBlending=0,i.NormalBlending=1,i.AdditiveBlending=2,i.SubtractiveBlending=3,i.MultiplyBlending=4,i.CustomBlending=5,i.AddEquation=100,i.SubtractEquation=101,i.ReverseSubtractEquation=102,i.MinEquation=103,i.MaxEquation=104,i.ZeroFactor=200,i.OneFactor=201,i.SrcColorFactor=202,i.OneMinusSrcColorFactor=203,i.SrcAlphaFactor=204,i.OneMinusSrcAlphaFactor=205,i.DstAlphaFactor=206,i.OneMinusDstAlphaFactor=207,i.DstColorFactor=208,i.OneMinusDstColorFactor=209,i.SrcAlphaSaturateFactor=210,i.NeverDepth=0,i.AlwaysDepth=1,i.LessDepth=2,i.LessEqualDepth=3,i.EqualDepth=4,i.GreaterEqualDepth=5,i.GreaterDepth=6,i.NotEqualDepth=7,i.MultiplyOperation=0,i.MixOperation=1,i.AddOperation=2,i.NoToneMapping=0,i.LinearToneMapping=1,i.ReinhardToneMapping=2,i.Uncharted2ToneMapping=3,i.CineonToneMapping=4,i.UVMapping=300,i.CubeReflectionMapping=301,i.CubeRefractionMapping=302,i.EquirectangularReflectionMapping=303,i.EquirectangularRefractionMapping=304,i.SphericalReflectionMapping=305,i.CubeUVReflectionMapping=306,i.CubeUVRefractionMapping=307,i.RepeatWrapping=1e3,i.ClampToEdgeWrapping=1001,i.MirroredRepeatWrapping=1002,i.NearestFilter=1003,i.NearestMipMapNearestFilter=1004,i.NearestMipMapLinearFilter=1005,i.LinearFilter=1006,i.LinearMipMapNearestFilter=1007,i.LinearMipMapLinearFilter=1008,i.UnsignedByteType=1009,i.ByteType=1010,i.ShortType=1011,i.UnsignedShortType=1012,i.IntType=1013,i.UnsignedIntType=1014,i.FloatType=1015,i.HalfFloatType=1025,i.UnsignedShort4444Type=1016,i.UnsignedShort5551Type=1017,i.UnsignedShort565Type=1018,i.AlphaFormat=1019,i.RGBFormat=1020,i.RGBAFormat=1021,i.LuminanceFormat=1022,i.LuminanceAlphaFormat=1023,i.RGBEFormat=i.RGBAFormat,i.RGB_S3TC_DXT1_Format=2001,i.RGBA_S3TC_DXT1_Format=2002,i.RGBA_S3TC_DXT3_Format=2003,i.RGBA_S3TC_DXT5_Format=2004,i.RGB_PVRTC_4BPPV1_Format=2100,i.RGB_PVRTC_2BPPV1_Format=2101,i.RGBA_PVRTC_4BPPV1_Format=2102,i.RGBA_PVRTC_2BPPV1_Format=2103,i.RGB_ETC1_Format=2151,i.LoopOnce=2200,i.LoopRepeat=2201,i.LoopPingPong=2202,i.InterpolateDiscrete=2300,i.InterpolateLinear=2301,i.InterpolateSmooth=2302,i.ZeroCurvatureEnding=2400,i.ZeroSlopeEnding=2401,i.WrapAroundEnding=2402,i.TrianglesDrawMode=0,i.TriangleStripDrawMode=1,i.TriangleFanDrawMode=2,i.LinearEncoding=3e3,i.sRGBEncoding=3001,i.GammaEncoding=3007,i.RGBEEncoding=3002,i.LogLuvEncoding=3003,i.RGBM7Encoding=3004,i.RGBM16Encoding=3005,i.RGBDEncoding=3006,i.Math={generateUUID:function(){var t,e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=new Array(36),r=0;return function(){for(var n=0;n<36;n++)8===n||13===n||18===n||23===n?i[n]="-":14===n?i[n]="4":(r<=2&&(r=33554432+16777216*Math.random()|0),t=15&r,r>>=4,i[n]=e[19===n?3&t|8:t]);return i.join("")}}(),clamp:function(t,e,i){return Math.max(e,Math.min(i,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,i,r,n){return r+(t-e)*(n-r)/(i-e)},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e),t*t*(3-2*t))},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e),t*t*t*(t*(6*t-15)+10))},random16:function(){return Math.random()},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(){var t=Math.PI/180;return function(e){return e*t}}(),radToDeg:function(){var t=180/Math.PI;return function(e){return e*t}}(),isPowerOfTwo:function(t){return 0===(t&t-1)&&0!==t},nearestPowerOfTwo:function(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))},nextPowerOfTwo:function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t}},i.Color=function(t){return 3===arguments.length?this.fromArray(arguments):this.set(t)},i.Color.prototype={constructor:i.Color,r:1,g:1,b:1,set:function(t){return t instanceof i.Color?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this},setScalar:function(t){this.r=t,this.g=t,this.b=t},setHex:function(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,i){return this.r=t,this.g=e,this.b=i,this},setHSL:function(){function t(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}return function(e,r,n){if(e=i.Math.euclideanModulo(e,1),r=i.Math.clamp(r,0,1),n=i.Math.clamp(n,0,1),0===r)this.r=this.g=this.b=n;else{var a=n<=.5?n*(1+r):n+r-n*r,o=2*n-a;this.r=t(o,a,e+1/3),this.g=t(o,a,e),this.b=t(o,a,e-1/3)}return this}}(),setStyle:function(t){function e(t){void 0!==t&&parseFloat(t)<1}var r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var n,a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(n=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(n[1],10))/255,this.g=Math.min(255,parseInt(n[2],10))/255,this.b=Math.min(255,parseInt(n[3],10))/255,e(n[5]),this;if(n=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(n[1],10))/100,this.g=Math.min(100,parseInt(n[2],10))/100,this.b=Math.min(100,parseInt(n[3],10))/100,e(n[5]),this;break;case"hsl":case"hsla":if(n=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var s=parseFloat(n[1])/360,h=parseInt(n[2],10)/100,u=parseInt(n[3],10)/100;return e(n[5]),this.setHSL(s,h,u)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(t)){var l=r[1],c=l.length;if(3===c)return this.r=parseInt(l.charAt(0)+l.charAt(0),16)/255,this.g=parseInt(l.charAt(1)+l.charAt(1),16)/255,this.b=parseInt(l.charAt(2)+l.charAt(2),16)/255,this;if(6===c)return this.r=parseInt(l.charAt(0)+l.charAt(1),16)/255,this.g=parseInt(l.charAt(2)+l.charAt(3),16)/255,this.b=parseInt(l.charAt(4)+l.charAt(5),16)/255,this}if(t&&t.length>0){var l=i.ColorKeywords[t];void 0!==l&&this.setHex(l)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var i=e>0?1/e:1;return this.r=Math.pow(t.r,i),this.g=Math.pow(t.g,i),this.b=Math.pow(t.b,i),this},convertGammaToLinear:function(){var t=this.r,e=this.g,i=this.b;return this.r=t*t,this.g=e*e,this.b=i*i,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),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)},getHSL:function(t){var e,i,r=t||{h:0,s:0,l:0},n=this.r,a=this.g,o=this.b,s=Math.max(n,a,o),h=Math.min(n,a,o),u=(h+s)/2;if(h===s)e=0,i=0;else{var l=s-h;switch(i=u<=.5?l/(s+h):l/(2-s-h),s){case n:e=(a-o)/l+(a<o?6:0);break;case a:e=(o-n)/l+2;break;case o:e=(n-a)/l+4}e/=6}return r.h=e,r.s=i,r.l=u,r},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(t,e,i){var r=this.getHSL();return r.h+=t,r.s+=e,r.l+=i,this.setHSL(r.h,r.s,r.l),this},add:function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this},addColors:function(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this},addScalar:function(t){return this.r+=t,this.g+=t,this.b+=t,this},multiply:function(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this},multiplyScalar:function(t){return this.r*=t,this.g*=t,this.b*=t,this},lerp:function(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this},equals:function(t){return t.r===this.r&&t.g===this.g&&t.b===this.b},fromArray:function(t,e){return void 0===e&&(e=0),this.r=t[e],this.g=t[e+1],this.b=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}},i.ColorKeywords={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},i.Vector2=function(t,e){this.x=t||0,this.y=e||0},i.Vector2.prototype={constructor:i.Vector2,get width(){return this.x},set width(t){this.x=t},get height(){return this.y},set height(t){this.y=t},set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return isFinite(t)?(this.x*=t,this.y*=t):(this.x=0,this.y=0),this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:function(){var t,e;return function(r,n){return void 0===t&&(t=new i.Vector2,e=new i.Vector2),t.set(r,r),e.set(n,n),this.clamp(t,e)}}(),clampLength:function(t,e){var i=this.length();return this.multiplyScalar(Math.max(t,Math.min(e,i))/i),this},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length())},angle:function t(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i},setLength:function(t){return this.multiplyScalar(t/this.length())},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,i){return this.subVectors(e,t).multiplyScalar(i).add(t),this},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromAttribute:function(t,e,i){return void 0===i&&(i=0),e=e*t.itemSize+i,this.x=t.array[e],this.y=t.array[e+1],this},rotateAround:function(t,e){var i=Math.cos(e),r=Math.sin(e),n=this.x-t.x,a=this.y-t.y;return this.x=n*i-a*r+t.x,this.y=n*r+a*i+t.y,this}},i.Vector3=function(t,e,i){this.x=t||0,this.y=e||0,this.z=i||0},i.Vector3.prototype={constructor:i.Vector3,set:function(t,e,i){return this.x=t,this.y=e,this.z=i,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?this.multiplyVectors(t,e):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t):(this.x=0,this.y=0,this.z=0),this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:function(){var t;return function(e){return e instanceof i.Euler==!1,void 0===t&&(t=new i.Quaternion),this.applyQuaternion(t.setFromEuler(e)),this}}(),applyAxisAngle:function(){var t;return function(e,r){return void 0===t&&(t=new i.Quaternion),this.applyQuaternion(t.setFromAxisAngle(e,r)),this}}(),applyMatrix3:function(t){var e=this.x,i=this.y,r=this.z,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6]*r,this.y=n[1]*e+n[4]*i+n[7]*r,this.z=n[2]*e+n[5]*i+n[8]*r,this},applyMatrix4:function(t){var e=this.x,i=this.y,r=this.z,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*r+n[12],this.y=n[1]*e+n[5]*i+n[9]*r+n[13],this.z=n[2]*e+n[6]*i+n[10]*r+n[14],this},applyProjection:function(t){var e=this.x,i=this.y,r=this.z,n=t.elements,a=1/(n[3]*e+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*e+n[4]*i+n[8]*r+n[12])*a,this.y=(n[1]*e+n[5]*i+n[9]*r+n[13])*a,this.z=(n[2]*e+n[6]*i+n[10]*r+n[14])*a,this},applyQuaternion:function(t){var e=this.x,i=this.y,r=this.z,n=t.x,a=t.y,o=t.z,s=t.w,h=s*e+a*r-o*i,u=s*i+o*e-n*r,l=s*r+n*i-a*e,c=-n*e-a*i-o*r;return this.x=h*s+c*-n+u*-o-l*-a,this.y=u*s+c*-a+l*-n-h*-o,this.z=l*s+c*-o+h*-a-u*-n,this},project:function(){var t;return function(e){return void 0===t&&(t=new i.Matrix4),t.multiplyMatrices(e.projectionMatrix,t.getInverse(e.matrixWorld)),this.applyProjection(t)}}(),unproject:function(){var t;return function(e){return void 0===t&&(t=new i.Matrix4),t.multiplyMatrices(e.matrixWorld,t.getInverse(e.projectionMatrix)),this.applyProjection(t)}}(),transformDirection:function(t){var e=this.x,i=this.y,r=this.z,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*r,this.y=n[1]*e+n[5]*i+n[9]*r,this.z=n[2]*e+n[6]*i+n[10]*r,this.normalize(),this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(){var t,e;return function(r,n){return void 0===t&&(t=new i.Vector3,e=new i.Vector3),t.set(r,r,r),e.set(n,n,n),this.clamp(t,e)}}(),clampLength:function(t,e){var i=this.length();return this.multiplyScalar(Math.max(t,Math.min(e,i))/i),this},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(t){return this.multiplyScalar(t/this.length())},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,i){return this.subVectors(e,t).multiplyScalar(i).add(t),this},cross:function(t,e){if(void 0!==e)return this.crossVectors(t,e);var i=this.x,r=this.y,n=this.z;return this.x=r*t.z-n*t.y,this.y=n*t.x-i*t.z,this.z=i*t.y-r*t.x,this},crossVectors:function(t,e){var i=t.x,r=t.y,n=t.z,a=e.x,o=e.y,s=e.z;return this.x=r*s-n*o,this.y=n*a-i*s,this.z=i*o-r*a,this},projectOnVector:function(){var t,e;return function(r){return void 0===t&&(t=new i.Vector3),t.copy(r).normalize(),e=this.dot(t),this.copy(t).multiplyScalar(e)}}(),projectOnPlane:function(){var t;return function(e){return void 0===t&&(t=new i.Vector3),t.copy(this).projectOnVector(e),this.sub(t)}}(),reflect:function(){var t;return function(e){return void 0===t&&(t=new i.Vector3),this.sub(t.copy(e).multiplyScalar(2*this.dot(e)))}}(),angleTo:function(t){var e=this.dot(t)/Math.sqrt(this.lengthSq()*t.lengthSq());return Math.acos(i.Math.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,i=this.y-t.y,r=this.z-t.z;return e*e+i*i+r*r},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromMatrixPosition:function(t){return this.setFromMatrixColumn(t,3)},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=r,this},setFromMatrixColumn:function(t,e){return"number"==typeof t&&(t=arguments[1],e=arguments[0]),this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromAttribute:function(t,e,i){return void 0===i&&(i=0),e=e*t.itemSize+i,this.x=t.array[e],this.y=t.array[e+1],this.z=t.array[e+2],this}},i.Vector4=function(t,e,i,r){this.x=t||0,this.y=e||0,this.z=i||0,this.w=void 0!==r?r:1},i.Vector4.prototype={constructor:i.Vector4,set:function(t,e,i,r){return this.x=t,this.y=e,this.z=i,this.w=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t,this.w*=t):(this.x=0,this.y=0,this.z=0,this.w=0),this},applyMatrix4:function(t){var e=this.x,i=this.y,r=this.z,n=this.w,a=t.elements;return this.x=a[0]*e+a[4]*i+a[8]*r+a[12]*n,this.y=a[1]*e+a[5]*i+a[9]*r+a[13]*n,this.z=a[2]*e+a[6]*i+a[10]*r+a[14]*n,this.w=a[3]*e+a[7]*i+a[11]*r+a[15]*n,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,i,r,n,a=.01,o=.1,s=t.elements,h=s[0],u=s[4],l=s[8],c=s[1],p=s[5],f=s[9],d=s[2],m=s[6],v=s[10];if(Math.abs(u-c)<a&&Math.abs(l-d)<a&&Math.abs(f-m)<a){if(Math.abs(u+c)<o&&Math.abs(l+d)<o&&Math.abs(f+m)<o&&Math.abs(h+p+v-3)<o)return this.set(1,0,0,0),this;e=Math.PI;var g=(h+1)/2,y=(p+1)/2,x=(v+1)/2,M=(u+c)/4,b=(l+d)/4,_=(f+m)/4;return g>y&&g>x?g<a?(i=0,r=.707106781,n=.707106781):(i=Math.sqrt(g),r=M/i,n=b/i):y>x?y<a?(i=.707106781,r=0,n=.707106781):(r=Math.sqrt(y),i=M/r,n=_/r):x<a?(i=.707106781,r=.707106781,n=0):(n=Math.sqrt(x),i=b/n,r=_/n),this.set(i,r,n,e),this}var S=Math.sqrt((m-f)*(m-f)+(l-d)*(l-d)+(c-u)*(c-u));return Math.abs(S)<.001&&(S=1),this.x=(m-f)/S,this.y=(l-d)/S,this.z=(c-u)/S,this.w=Math.acos((h+p+v-1)/2),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},clampScalar:function(){var t,e;return function(r,n){return void 0===t&&(t=new i.Vector4,e=new i.Vector4),t.set(r,r,r,r),e.set(n,n,n,n),this.clamp(t,e)}}(),floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},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(t){return this.multiplyScalar(t/this.length())},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},lerpVectors:function(t,e,i){return this.subVectors(e,t).multiplyScalar(i).add(t),this},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},fromAttribute:function(t,e,i){return void 0===i&&(i=0),e=e*t.itemSize+i,this.x=t.array[e],this.y=t.array[e+1],this.z=t.array[e+2],this.w=t.array[e+3],this}},i.Matrix3=function(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1]),arguments.length>0},i.Matrix3.prototype={constructor:i.Matrix3,set:function(t,e,i,r,n,a,o,s,h){var u=this.elements;return u[0]=t,u[1]=r,u[2]=o,u[3]=e,u[4]=n,u[5]=s,u[6]=i,u[7]=a,u[8]=h,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var e=t.elements;return this.set(e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8]),this},setFromMatrix4:function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},applyToVector3Array:function(){var t;return function(e,r,n){void 0===t&&(t=new i.Vector3),void 0===r&&(r=0),void 0===n&&(n=e.length);for(var a=0,o=r;a<n;a+=3,o+=3)t.fromArray(e,o),t.applyMatrix3(this),t.toArray(e,o);return e}}(),applyToBuffer:function(){var t;return function(e,r,n){void 0===t&&(t=new i.Vector3),void 0===r&&(r=0),void 0===n&&(n=e.length/e.itemSize);for(var a=0,o=r;a<n;a++,o++)t.x=e.getX(o),t.y=e.getY(o),t.z=e.getZ(o),t.applyMatrix3(this),e.setXYZ(t.x,t.y,t.z);return e}}(),multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this},determinant:function(){var t=this.elements,e=t[0],i=t[1],r=t[2],n=t[3],a=t[4],o=t[5],s=t[6],h=t[7],u=t[8];return e*a*u-e*o*h-i*n*u+i*o*s+r*n*h-r*a*s},getInverse:function(t,e){t instanceof i.Matrix4;var r=t.elements,n=this.elements,a=r[0],o=r[1],s=r[2],h=r[3],u=r[4],l=r[5],c=r[6],p=r[7],f=r[8],d=f*u-l*p,m=l*c-f*h,v=p*h-u*c,g=a*d+o*m+s*v;if(0===g){return this.identity()}return n[0]=d,n[1]=s*p-f*o,n[2]=l*o-s*u,n[3]=m,n[4]=f*a-s*c,n[5]=s*h-l*a,n[6]=v,n[7]=o*c-p*a,n[8]=u*a-o*h,this.multiplyScalar(1/g)},transpose:function(){var t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this},flattenToArrayOffset:function(t,e){var i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],
t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t},getNormalMatrix:function(t){return this.setFromMatrix4(t).getInverse(this).transpose()},transposeIntoArray:function(t){var e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this},fromArray:function(t){return this.elements.set(t),this},toArray:function(){var t=this.elements;return[t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8]]}},i.Matrix4=function(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),arguments.length>0},i.Matrix4.prototype={constructor:i.Matrix4,set:function(t,e,i,r,n,a,o,s,h,u,l,c,p,f,d,m){var v=this.elements;return v[0]=t,v[4]=e,v[8]=i,v[12]=r,v[1]=n,v[5]=a,v[9]=o,v[13]=s,v[2]=h,v[6]=u,v[10]=l,v[14]=c,v[3]=p,v[7]=f,v[11]=d,v[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new i.Matrix4).fromArray(this.elements)},copy:function(t){return this.elements.set(t.elements),this},copyPosition:function(t){var e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this},extractBasis:function(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this},extractRotation:function(){var t;return function(e){void 0===t&&(t=new i.Vector3);var r=this.elements,n=e.elements,a=1/t.setFromMatrixColumn(e,0).length(),o=1/t.setFromMatrixColumn(e,1).length(),s=1/t.setFromMatrixColumn(e,2).length();return r[0]=n[0]*a,r[1]=n[1]*a,r[2]=n[2]*a,r[4]=n[4]*o,r[5]=n[5]*o,r[6]=n[6]*o,r[8]=n[8]*s,r[9]=n[9]*s,r[10]=n[10]*s,this}}(),makeRotationFromEuler:function(t){t instanceof i.Euler==!1;var e=this.elements,r=t.x,n=t.y,a=t.z,o=Math.cos(r),s=Math.sin(r),h=Math.cos(n),u=Math.sin(n),l=Math.cos(a),c=Math.sin(a);if("XYZ"===t.order){var p=o*l,f=o*c,d=s*l,m=s*c;e[0]=h*l,e[4]=-h*c,e[8]=u,e[1]=f+d*u,e[5]=p-m*u,e[9]=-s*h,e[2]=m-p*u,e[6]=d+f*u,e[10]=o*h}else if("YXZ"===t.order){var v=h*l,g=h*c,y=u*l,x=u*c;e[0]=v+x*s,e[4]=y*s-g,e[8]=o*u,e[1]=o*c,e[5]=o*l,e[9]=-s,e[2]=g*s-y,e[6]=x+v*s,e[10]=o*h}else if("ZXY"===t.order){var v=h*l,g=h*c,y=u*l,x=u*c;e[0]=v-x*s,e[4]=-o*c,e[8]=y+g*s,e[1]=g+y*s,e[5]=o*l,e[9]=x-v*s,e[2]=-o*u,e[6]=s,e[10]=o*h}else if("ZYX"===t.order){var p=o*l,f=o*c,d=s*l,m=s*c;e[0]=h*l,e[4]=d*u-f,e[8]=p*u+m,e[1]=h*c,e[5]=m*u+p,e[9]=f*u-d,e[2]=-u,e[6]=s*h,e[10]=o*h}else if("YZX"===t.order){var M=o*h,b=o*u,_=s*h,S=s*u;e[0]=h*l,e[4]=S-M*c,e[8]=_*c+b,e[1]=c,e[5]=o*l,e[9]=-s*l,e[2]=-u*l,e[6]=b*c+_,e[10]=M-S*c}else if("XZY"===t.order){var M=o*h,b=o*u,_=s*h,S=s*u;e[0]=h*l,e[4]=-c,e[8]=u*l,e[1]=M*c+S,e[5]=o*l,e[9]=b*c-_,e[2]=_*c-b,e[6]=s*l,e[10]=S*c+M}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){var e=this.elements,i=t.x,r=t.y,n=t.z,a=t.w,o=i+i,s=r+r,h=n+n,u=i*o,l=i*s,c=i*h,p=r*s,f=r*h,d=n*h,m=a*o,v=a*s,g=a*h;return e[0]=1-(p+d),e[4]=l-g,e[8]=c+v,e[1]=l+g,e[5]=1-(u+d),e[9]=f-m,e[2]=c-v,e[6]=f+m,e[10]=1-(u+p),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:function(){var t,e,r;return function(n,a,o){void 0===t&&(t=new i.Vector3),void 0===e&&(e=new i.Vector3),void 0===r&&(r=new i.Vector3);var s=this.elements;return r.subVectors(n,a).normalize(),0===r.lengthSq()&&(r.z=1),t.crossVectors(o,r).normalize(),0===t.lengthSq()&&(r.x+=1e-4,t.crossVectors(o,r).normalize()),e.crossVectors(r,t),s[0]=t.x,s[4]=e.x,s[8]=r.x,s[1]=t.y,s[5]=e.y,s[9]=r.y,s[2]=t.z,s[6]=e.z,s[10]=r.z,this}}(),multiply:function(t,e){return void 0!==e?this.multiplyMatrices(t,e):this.multiplyMatrices(this,t)},multiplyMatrices:function(t,e){var i=t.elements,r=e.elements,n=this.elements,a=i[0],o=i[4],s=i[8],h=i[12],u=i[1],l=i[5],c=i[9],p=i[13],f=i[2],d=i[6],m=i[10],v=i[14],g=i[3],y=i[7],x=i[11],M=i[15],b=r[0],_=r[4],S=r[8],w=r[12],E=r[1],T=r[5],A=r[9],L=r[13],C=r[2],R=r[6],U=r[10],F=r[14],P=r[3],N=r[7],D=r[11],B=r[15];return n[0]=a*b+o*E+s*C+h*P,n[4]=a*_+o*T+s*R+h*N,n[8]=a*S+o*A+s*U+h*D,n[12]=a*w+o*L+s*F+h*B,n[1]=u*b+l*E+c*C+p*P,n[5]=u*_+l*T+c*R+p*N,n[9]=u*S+l*A+c*U+p*D,n[13]=u*w+l*L+c*F+p*B,n[2]=f*b+d*E+m*C+v*P,n[6]=f*_+d*T+m*R+v*N,n[10]=f*S+d*A+m*U+v*D,n[14]=f*w+d*L+m*F+v*B,n[3]=g*b+y*E+x*C+M*P,n[7]=g*_+y*T+x*R+M*N,n[11]=g*S+y*A+x*U+M*D,n[15]=g*w+y*L+x*F+M*B,this},multiplyToArray:function(t,e,i){var r=this.elements;return this.multiplyMatrices(t,e),i[0]=r[0],i[1]=r[1],i[2]=r[2],i[3]=r[3],i[4]=r[4],i[5]=r[5],i[6]=r[6],i[7]=r[7],i[8]=r[8],i[9]=r[9],i[10]=r[10],i[11]=r[11],i[12]=r[12],i[13]=r[13],i[14]=r[14],i[15]=r[15],this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToVector3Array:function(){var t;return function(e,r,n){void 0===t&&(t=new i.Vector3),void 0===r&&(r=0),void 0===n&&(n=e.length);for(var a=0,o=r;a<n;a+=3,o+=3)t.fromArray(e,o),t.applyMatrix4(this),t.toArray(e,o);return e}}(),applyToBuffer:function(){var t;return function(e,r,n){void 0===t&&(t=new i.Vector3),void 0===r&&(r=0),void 0===n&&(n=e.length/e.itemSize);for(var a=0,o=r;a<n;a++,o++)t.x=e.getX(o),t.y=e.getY(o),t.z=e.getZ(o),t.applyMatrix4(this),e.setXYZ(t.x,t.y,t.z);return e}}(),determinant:function(){var t=this.elements,e=t[0],i=t[4],r=t[8],n=t[12],a=t[1],o=t[5],s=t[9],h=t[13],u=t[2],l=t[6],c=t[10],p=t[14],f=t[3],d=t[7],m=t[11],v=t[15];return f*(+n*s*l-r*h*l-n*o*c+i*h*c+r*o*p-i*s*p)+d*(+e*s*p-e*h*c+n*a*c-r*a*p+r*h*u-n*s*u)+m*(+e*h*l-e*o*p-n*a*l+i*a*p+n*o*u-i*h*u)+v*(-r*o*u-e*s*l+e*o*c+r*a*l-i*a*c+i*s*u)},transpose:function(){var t,e=this.elements;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},flattenToArrayOffset:function(t,e){var i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t},getPosition:function(){var t;return function(){return void 0===t&&(t=new i.Vector3),t.setFromMatrixColumn(this,3)}}(),setPosition:function(t){var e=this.elements;return e[12]=t.x,e[13]=t.y,e[14]=t.z,this},getInverse:function(t,e){var i=this.elements,r=t.elements,n=r[0],a=r[1],o=r[2],s=r[3],h=r[4],u=r[5],l=r[6],c=r[7],p=r[8],f=r[9],d=r[10],m=r[11],v=r[12],g=r[13],y=r[14],x=r[15],M=f*y*c-g*d*c+g*l*m-u*y*m-f*l*x+u*d*x,b=v*d*c-p*y*c-v*l*m+h*y*m+p*l*x-h*d*x,_=p*g*c-v*f*c+v*u*m-h*g*m-p*u*x+h*f*x,S=v*f*l-p*g*l-v*u*d+h*g*d+p*u*y-h*f*y,w=n*M+a*b+o*_+s*S;if(0===w){return this.identity()}return i[0]=M,i[1]=g*d*s-f*y*s-g*o*m+a*y*m+f*o*x-a*d*x,i[2]=u*y*s-g*l*s+g*o*c-a*y*c-u*o*x+a*l*x,i[3]=f*l*s-u*d*s-f*o*c+a*d*c+u*o*m-a*l*m,i[4]=b,i[5]=p*y*s-v*d*s+v*o*m-n*y*m-p*o*x+n*d*x,i[6]=v*l*s-h*y*s-v*o*c+n*y*c+h*o*x-n*l*x,i[7]=h*d*s-p*l*s+p*o*c-n*d*c-h*o*m+n*l*m,i[8]=_,i[9]=v*f*s-p*g*s-v*a*m+n*g*m+p*a*x-n*f*x,i[10]=h*g*s-v*u*s+v*a*c-n*g*c-h*a*x+n*u*x,i[11]=p*u*s-h*f*s-p*a*c+n*f*c+h*a*m-n*u*m,i[12]=S,i[13]=p*g*o-v*f*o+v*a*d-n*g*d-p*a*y+n*f*y,i[14]=v*u*o-h*g*o-v*a*l+n*g*l+h*a*y-n*u*y,i[15]=h*f*o-p*u*o+p*a*l-n*f*l-h*a*d+n*u*d,this.multiplyScalar(1/w)},scale:function(t){var e=this.elements,i=t.x,r=t.y,n=t.z;return e[0]*=i,e[4]*=r,e[8]*=n,e[1]*=i,e[5]*=r,e[9]*=n,e[2]*=i,e[6]*=r,e[10]*=n,e[3]*=i,e[7]*=r,e[11]*=n,this},getMaxScaleOnAxis:function(){var t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,r))},makeTranslation:function(t,e,i){return this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this},makeRotationX:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this},makeRotationY:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this},makeRotationZ:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(t,e){var i=Math.cos(e),r=Math.sin(e),n=1-i,a=t.x,o=t.y,s=t.z,h=n*a,u=n*o;return this.set(h*a+i,h*o-r*s,h*s+r*o,0,h*o+r*s,u*o+i,u*s-r*a,0,h*s-r*o,u*s+r*a,n*s*s+i,0,0,0,0,1),this},makeScale:function(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this},compose:function(t,e,i){return this.makeRotationFromQuaternion(e),this.scale(i),this.setPosition(t),this},decompose:function(){var t,e;return function(r,n,a){void 0===t&&(t=new i.Vector3),void 0===e&&(e=new i.Matrix4);var o=this.elements,s=t.set(o[0],o[1],o[2]).length(),h=t.set(o[4],o[5],o[6]).length(),u=t.set(o[8],o[9],o[10]).length(),l=this.determinant();l<0&&(s=-s),r.x=o[12],r.y=o[13],r.z=o[14],e.elements.set(this.elements);var c=1/s,p=1/h,f=1/u;return e.elements[0]*=c,e.elements[1]*=c,e.elements[2]*=c,e.elements[4]*=p,e.elements[5]*=p,e.elements[6]*=p,e.elements[8]*=f,e.elements[9]*=f,e.elements[10]*=f,n.setFromRotationMatrix(e),a.x=s,a.y=h,a.z=u,this}}(),makeFrustum:function(t,e,i,r,n,a){var o=this.elements,s=2*n/(e-t),h=2*n/(r-i),u=(e+t)/(e-t),l=(r+i)/(r-i),c=-(a+n)/(a-n),p=-2*a*n/(a-n);return o[0]=s,o[4]=0,o[8]=u,o[12]=0,o[1]=0,o[5]=h,o[9]=l,o[13]=0,o[2]=0,o[6]=0,o[10]=c,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this},makePerspective:function(t,e,r,n){var a=r*Math.tan(i.Math.degToRad(.5*t)),o=-a,s=o*e,h=a*e;return this.makeFrustum(s,h,o,a,r,n)},makeOrthographic:function(t,e,i,r,n,a){var o=this.elements,s=1/(e-t),h=1/(i-r),u=1/(a-n),l=(e+t)*s,c=(i+r)*h,p=(a+n)*u;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-l,o[1]=0,o[5]=2*h,o[9]=0,o[13]=-c,o[2]=0,o[6]=0,o[10]=-2*u,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this},equals:function(t){for(var e=this.elements,i=t.elements,r=0;r<16;r++)if(e[r]!==i[r])return!1;return!0},fromArray:function(t){return this.elements.set(t),this},toArray:function(){var t=this.elements;return[t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15]]}},i.Plane=function(t,e){this.normal=void 0!==t?t:new i.Vector3(1,0,0),this.constant=void 0!==e?e:0},i.Plane.prototype={constructor:i.Plane,set:function(t,e){return this.normal.copy(t),this.constant=e,this},setComponents:function(t,e,i,r){return this.normal.set(t,e,i),this.constant=r,this},setFromNormalAndCoplanarPoint:function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},setFromCoplanarPoints:function(){var t=new i.Vector3,e=new i.Vector3;return function(i,r,n){var a=t.subVectors(n,r).cross(e.subVectors(i,r)).normalize();return this.setFromNormalAndCoplanarPoint(a,i),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},normalize:function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(t){return this.normal.dot(t)+this.constant},distanceToSphere:function(t){return this.distanceToPoint(t.center)-t.radius},projectPoint:function(t,e){return this.orthoPoint(t,e).sub(t).negate()},orthoPoint:function(t,e){var r=this.distanceToPoint(t),n=e||new i.Vector3;return n.copy(this.normal).multiplyScalar(r)},intersectLine:function(){var t=new i.Vector3;return function(e,r){var n=r||new i.Vector3,a=e.delta(t),o=this.normal.dot(a);if(0!==o){var s=-(e.start.dot(this.normal)+this.constant)/o;if(!(s<0||s>1))return n.copy(a).multiplyScalar(s).add(e.start)}else if(0===this.distanceToPoint(e.start))return n.copy(e.start)}}(),intersectsLine:function(t){var e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){var e=t||new i.Vector3;return e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var t=new i.Vector3,e=new i.Vector3,r=new i.Matrix3;return function(i,n){var a=n||r.getNormalMatrix(i),o=t.copy(this.normal).applyMatrix3(a),s=this.coplanarPoint(e);return s.applyMatrix4(i),this.setFromNormalAndCoplanarPoint(o,s),this}}(),translate:function(t){return this.constant=this.constant-t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}},i.Quaternion=function(t,e,i,r){this._x=t||0,this._y=e||0,this._z=i||0,this._w=void 0!==r?r:1},i.Quaternion.prototype={constructor:i.Quaternion,get x(){return this._x},set x(t){this._x=t,this.onChangeCallback()},get y(){return this._y},set y(t){this._y=t,this.onChangeCallback()},get z(){return this._z},set z(t){this._z=t,this.onChangeCallback()},get w(){return this._w},set w(t){this._w=t,this.onChangeCallback()},set:function(t,e,i,r){return this._x=t,this._y=e,this._z=i,this._w=r,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this.onChangeCallback(),this},setFromEuler:function(t,e){if(t instanceof i.Euler==!1)throw new Error("THREE.Quaternion: .setFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var r=Math.cos(t._x/2),n=Math.cos(t._y/2),a=Math.cos(t._z/2),o=Math.sin(t._x/2),s=Math.sin(t._y/2),h=Math.sin(t._z/2),u=t.order;return"XYZ"===u?(this._x=o*n*a+r*s*h,this._y=r*s*a-o*n*h,this._z=r*n*h+o*s*a,this._w=r*n*a-o*s*h):"YXZ"===u?(this._x=o*n*a+r*s*h,this._y=r*s*a-o*n*h,this._z=r*n*h-o*s*a,this._w=r*n*a+o*s*h):"ZXY"===u?(this._x=o*n*a-r*s*h,this._y=r*s*a+o*n*h,this._z=r*n*h+o*s*a,this._w=r*n*a-o*s*h):"ZYX"===u?(this._x=o*n*a-r*s*h,this._y=r*s*a+o*n*h,this._z=r*n*h-o*s*a,this._w=r*n*a+o*s*h):"YZX"===u?(this._x=o*n*a+r*s*h,this._y=r*s*a+o*n*h,this._z=r*n*h-o*s*a,this._w=r*n*a-o*s*h):"XZY"===u&&(this._x=o*n*a-r*s*h,this._y=r*s*a-o*n*h,this._z=r*n*h+o*s*a,this._w=r*n*a+o*s*h),e!==!1&&this.onChangeCallback(),this},setFromAxisAngle:function(t,e){var i=e/2,r=Math.sin(i);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(i),this.onChangeCallback(),this},setFromRotationMatrix:function(t){var e,i=t.elements,r=i[0],n=i[4],a=i[8],o=i[1],s=i[5],h=i[9],u=i[2],l=i[6],c=i[10],p=r+s+c;return p>0?(e=.5/Math.sqrt(p+1),this._w=.25/e,this._x=(l-h)*e,this._y=(a-u)*e,this._z=(o-n)*e):r>s&&r>c?(e=2*Math.sqrt(1+r-s-c),this._w=(l-h)/e,this._x=.25*e,this._y=(n+o)/e,this._z=(a+u)/e):s>c?(e=2*Math.sqrt(1+s-r-c),this._w=(a-u)/e,this._x=(n+o)/e,this._y=.25*e,this._z=(h+l)/e):(e=2*Math.sqrt(1+c-r-s),this._w=(o-n)/e,this._x=(a+u)/e,this._y=(h+l)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:function(){var t,e,r=1e-6;return function(n,a){return void 0===t&&(t=new i.Vector3),e=n.dot(a)+1,e<r?(e=0,Math.abs(n.x)>Math.abs(n.z)?t.set(-n.y,n.x,0):t.set(0,-n.z,n.y)):t.crossVectors(n,a),this._x=t.x,this._y=t.y,this._z=t.z,this._w=e,this.normalize(),this}}(),inverse:function(){return this.conjugate().normalize(),this},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},multiply:function(t,e){return void 0!==e?this.multiplyQuaternions(t,e):this.multiplyQuaternions(this,t)},multiplyQuaternions:function(t,e){var i=t._x,r=t._y,n=t._z,a=t._w,o=e._x,s=e._y,h=e._z,u=e._w;return this._x=i*u+a*o+r*h-n*s,this._y=r*u+a*s+n*o-i*h,this._z=n*u+a*h+i*s-r*o,this._w=a*u-i*o-r*s-n*h,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var i=this._x,r=this._y,n=this._z,a=this._w,o=a*t._w+i*t._x+r*t._y+n*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=i,this._y=r,this._z=n,this;var s=Math.sqrt(1-o*o);if(Math.abs(s)<.001)return this._w=.5*(a+this._w),this._x=.5*(i+this._x),this._y=.5*(r+this._y),this._z=.5*(n+this._z),this;var h=Math.atan2(s,o),u=Math.sin((1-e)*h)/s,l=Math.sin(e*h)/s;return this._w=a*u+this._w*l,this._x=i*u+this._x*l,this._y=r*u+this._y*l,this._z=n*u+this._z*l,this.onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}},Object.assign(i.Quaternion,{slerp:function(t,e,i,r){return i.copy(t).slerp(e,r)},slerpFlat:function(t,e,i,r,n,a,o){var s=i[r+0],h=i[r+1],u=i[r+2],l=i[r+3],c=n[a+0],p=n[a+1],f=n[a+2],d=n[a+3];if(l!==d||s!==c||h!==p||u!==f){var m=1-o,v=s*c+h*p+u*f+l*d,g=v>=0?1:-1,y=1-v*v;if(y>Number.EPSILON){var x=Math.sqrt(y),M=Math.atan2(x,v*g);m=Math.sin(m*M)/x,o=Math.sin(o*M)/x}var b=o*g;if(s=s*m+c*b,h=h*m+p*b,u=u*m+f*b,l=l*m+d*b,m===1-o){var _=1/Math.sqrt(s*s+h*h+u*u+l*l);s*=_,h*=_,u*=_,l*=_}}t[e]=s,t[e+1]=h,t[e+2]=u,t[e+3]=l}}),i.Triangle=function(t,e,r){this.a=void 0!==t?t:new i.Vector3,this.b=void 0!==e?e:new i.Vector3,this.c=void 0!==r?r:new i.Vector3},i.Triangle.normal=function(){var t=new i.Vector3;return function(e,r,n,a){var o=a||new i.Vector3;o.subVectors(n,r),t.subVectors(e,r),o.cross(t);var s=o.lengthSq();return s>0?o.multiplyScalar(1/Math.sqrt(s)):o.set(0,0,0)}}(),i.Triangle.barycoordFromPoint=function(){var t=new i.Vector3,e=new i.Vector3,r=new i.Vector3;return function(n,a,o,s,h){t.subVectors(s,a),e.subVectors(o,a),r.subVectors(n,a);var u=t.dot(t),l=t.dot(e),c=t.dot(r),p=e.dot(e),f=e.dot(r),d=u*p-l*l,m=h||new i.Vector3;if(0===d)return m.set(-2,-1,-1);var v=1/d,g=(p*c-l*f)*v,y=