Difference between revisions of "Template:Humboldt Berlin"

(Prototype team template page)
 
Line 805: Line 805:
  
 
</div>
 
</div>
 +
 +
 +
<!-- CUSTOM SCRIPT -->
 +
<script>
 +
!function(e){var t=function(){function e(e){var t=this;this.canvas=e,this.engine=new BABYLON.Engine(e,!0,{preserveDrawingBuffer:!0}),this.engine.runRenderLoop(function(){t.scene&&t.scene.render()}),this.bindedResize=this.resize.bind(this),window.addEventListener("resize",this.bindedResize)}return e.prototype.resize=function(){this.engine.resize()},e.prototype.exportScreenshot=function(){return this.canvas.toDataURL("image/png")},e.prototype.dispose=function(){this.engine.dispose(),window.removeEventListener("resize",this.bindedResize)},e.prototype.sphereMaterial=function(e,t,i){this.viewmode&&this.viewmode.sphereMaterial(this,e,t,i)},e.prototype.cylinderMaterial=function(e,t,i){this.viewmode&&this.viewmode.cylinderMaterial(this,e,t,i)},e.prototype.createScene=function(){this.scene&&this.scene.dispose(),console.log("create babylon scene");var e=new BABYLON.Scene(this.engine);this.scene=e,this.viewmode&&this.viewmode.createScene(this)},e}();e.BabylonContext=t}(Molvwr||(Molvwr={})),function(e){!function(e){e.defaultConfig=function(){return{allowLOD:!1,renderers:["Sphere"],atomScaleFactor:3,cylinderScale:.6,sphereSegments:16}},e.spheres=function(){return{allowLOD:!0,renderers:["Sphere"],atomScaleFactor:3,cylinderScale:.6,sphereSegments:16,sphereLOD:[{depth:0,segments:32,effects:!0},{depth:5,segments:24,effects:!0},{depth:10,segments:16,effects:!0},{depth:20,segments:12,effects:!0},{depth:40,segments:6,effects:!0},{depth:60,segments:6},{depth:80,segments:4}]}},e.sticks=function(){return{allowLOD:!0,renderers:["Sticks"],atomScaleFactor:1.3,cylinderScale:1.4,sphereSegments:16,cylinderSegments:16,cylinderLOD:[{depth:0,segments:64,effects:!0},{depth:10,segments:32,effects:!0},{depth:20,segments:24,effects:!0},{depth:40,segments:16,effects:!0},{depth:60,segments:12},{depth:80,segments:8}]}},e.ballsAndSticks=function(){return{allowLOD:!0,renderers:["BondsCylinder","Sphere"],atomScaleFactor:1.3,cylinderScale:.6,sphereSegments:16,cylinderSegments:8,cylinderLOD:[{depth:0,segments:64,effects:!0},{depth:5,segments:32,effects:!0},{depth:20,segments:24,effects:!0},{depth:60,segments:12}],sphereLOD:[{depth:0,segments:64,effects:!0},{depth:5,segments:32,effects:!0},{depth:10,segments:24,effects:!0},{depth:20,segments:16,effects:!0},{depth:40,segments:12,effects:!0},{depth:60,segments:6},{depth:80,segments:4}]}}}(e.Config||(e.Config={}))}(Molvwr||(Molvwr={}));var __global=this;!function(e){e.process=function(){if(__global.BABYLON)for(var i,r=0,n=(i=arguments[0]?arguments[0].length?arguments[0]:[arguments[0]]:document.querySelectorAll("*[data-molvwr]")).length;r<n;r++){var o=i[r];if(o&&o.style){o.molvwr&&o.molvwr.dispose();var s=o.getAttribute("data-molvwr"),a=o.getAttribute("data-molvwr-format"),h=o.getAttribute("data-molvwr-view");if(a||(a=t.getMoleculeFileFormat(s)),!s)return void console.error("please specify a molecule url by adding a data-molvwr attribute");if(!a)return void console.error("molecule file format not found or not specified for "+s);var c=null;"spheres"==h?c=e.Config.spheres():"ballsandsticks"==h?c=e.Config.ballsAndSticks():"sticks"==h&&(c=e.Config.sticks()),s&&a&&new t(o,c).loadContentFromUrl(s,a)}}else console.error("Babylon.js is not available, please add a reference to Babylon.js script")};var t=function(){function t(t,i,r){if(!__global.BABYLON)throw new Error("Babylon.js is not available, please add a reference to Babylon.js script");if(!t)throw new Error("you must provide an element to host the viewer");this.config=i||e.Config.defaultConfig(),this.element=t,this.element.molvwr=this,this.canvas=document.createElement("CANVAS"),this.canvas.setAttribute("touch-action","manipulation");const n=window.innerHeight-200;this.canvas.setAttribute("width","1440px"),this.canvas.setAttribute("height",n+"px"),this.canvas.style.width="100%",this.canvas.style.height="100%",this.element.appendChild(this.canvas),this.context=new e.BabylonContext(this.canvas),this.viewmode=r,this.viewmode||(this.viewmode=new e.ViewModes.Standard)}return t.prototype.dispose=function(){this.context.dispose(),this.context=null,this.element=null,this.canvas=null,this.element.innerHTML=""},t.prototype._loadContentFromString=function(t,i,r){var n=this;return new e.Utils.Promise(function(r,o){var s=e.Parser[i];if(s){console.time("parsing "+i);var a=s.parse(t);console.timeEnd("parsing "+i),a?n._postProcessMolecule(a).then(function(){return n._renderMolecule(a)}).then(function(){return a}).then(r,o):(console.warn("no molecule from parser "+i),r())}else console.warn("no parser for "+i),r()})},t.prototype._renderMolecule=function(t){var i=this;return this.molecule=t,this._createContext(),new e.Utils.Promise(function(r,n){if(console.time("rendering..."),i.config.renderers){i.config.renderers.length;var o=[];i.config.renderers.forEach(function(t){var r=e.Renderer[t];if(r){var n=new r(i,i.context,i.config);o.push(n.render(i.molecule))}}),e.Utils.Promise.all(o).then(function(){console.timeEnd("rendering...")}).then(r,n)}else r(t)})},t.prototype.setOptions=function(e,t){this.config=e,this.refresh(t)},t.prototype.setViewMode=function(t,i){this.viewmode=t,this.viewmode||(this.viewmode=new e.ViewModes.Standard),this.refresh(i)},t.prototype.refresh=function(e){this.molecule?this._renderMolecule(this.molecule).then(e,e):e&&e()},t.prototype._createContext=function(){this.context&&this.context.dispose(),this.context=new e.BabylonContext(this.canvas),this.context.viewmode=this.viewmode,this.context.createScene()},t.prototype.exportScreenshot=function(){return this.context.exportScreenshot()},t.endsWith=function(e,t){return-1!==e.indexOf(t,e.length-t.length)},t.getMoleculeFileFormat=function(e){return t.endsWith(e,".pdb")?"pdb":t.endsWith(e,".mol")||t.endsWith(e,".sdf")?"mol":t.endsWith(e,".xyz")?"xyz":null},t.prototype.loadContentFromString=function(e,t,i,r){this._createContext(),this._loadContentFromString(e,t,i).then(r,r)},t.prototype.loadContentFromUrl=function(e,i,r,n){var o=this;i||(i=t.getMoleculeFileFormat(e)),i||console.error("molecule file format not found or not specified"),this._createContext();try{var s=new XMLHttpRequest;s.onreadystatechange=function(){4==s.readyState&&(200==s.status?o._loadContentFromString(s.responseText,i,r).then(n,n):(console.warn("cannot get content from "+e+" "+s.status+" "+s.statusText),n()))},s.open("GET",e,!0),s.send(null)}catch(e){console.error(e),n()}},t.prototype._postProcessMolecule=function(e){var t=this;return console.time("post process"),e.kinds=e.kinds||{},e.bondkinds=e.bondkinds||{},e.batchSize=Math.min(120,e.atoms.length/4>>0),e.batchSize=Math.max(40,e.batchSize),this._center(e).then(function(){return t._calculateAtomsBondsAsync(e)}).then(function(){console.timeEnd("post process")})},t.prototype._calculateAtomsBondsAsync=function(t){console.time("check bounds");var i=[],r=t.atoms.length;return e.Utils.runBatch(0,300,t.atoms,function(e,n,o){t.kinds[e.kind.symbol]?t.kinds[e.kind.symbol].count++:t.kinds[e.kind.symbol]={kind:e.kind,count:1};for(var s=o+1;s<r;s++){var a=t.atoms[s],h=new BABYLON.Vector3(e.x,e.y,e.z),c=new BABYLON.Vector3(a.x,a.y,a.z),l=BABYLON.Vector3.Distance(h,c);l<1.3*(e.kind.radius+a.kind.radius)&&(t.bondkinds[e.kind.symbol+"#"+a.kind.symbol]?t.bondkinds[e.kind.symbol+"#"+a.kind.symbol].count++:t.bondkinds[e.kind.symbol+"#"+a.kind.symbol]={d:l,key:e.kind.symbol+"#"+a.kind.symbol,kindA:e.kind,kindB:a.kind,count:1},i.push({d:l,atomA:e,atomB:a,cutoff:l/(e.kind.radius+a.kind.radius)}))}},"checkbounds").then(function(){t.bonds=i,console.timeEnd("check bounds"),console.log("found "+i.length+" bonds")})},t.prototype._getCentroid=function(e){var t=1/0,i=-1/0,r=1/0,n=-1/0,o=1/0,s=-1/0;return e.atoms.forEach(function(e){e.x>i&&(i=e.x),e.x<t&&(t=e.x),e.y>n&&(n=e.y),e.y<r&&(r=e.y),e.z>s&&(s=e.z),e.z<o&&(o=e.z)}),{x:(t+i)/2,y:(r+n)/2,z:(o+s)/2}},t.prototype._center=function(t){console.time("recenter atoms");var i=this._getCentroid(t);return t.atoms.forEach(function(e){e.x-=i.x,e.y-=i.y,e.z-=i.z}),console.timeEnd("recenter atoms"),e.Utils.Promise.resolve()},t}();e.Viewer=t}(Molvwr||(Molvwr={})),function(e){!function(e){e.elements=[{symbol:"Xx",name:"unknown",mass:1,radius:1,color:[1,.078,.576],number:0},{symbol:"H",name:"hydrogen",mass:1.00794,radius:.31,color:[1,1,1],number:1},{symbol:"He",name:"helium",mass:4.002602,radius:.28,color:[.851,1,1],number:2},{symbol:"Li",name:"lithium",mass:6.941,radius:1.28,color:[.8,.502,1],number:3},{symbol:"Be",name:"beryllium",mass:9.012182,radius:.96,color:[.761,1,0],number:4},{symbol:"B",name:"boron",mass:10.811,radius:.84,color:[1,.71,.71],number:5},{symbol:"C",name:"carbon",mass:12.0107,radius:.73,color:[.565,.565,.565],number:6},{symbol:"N",name:"nitrogen",mass:14.0067,radius:.71,color:[.188,.314,.973],number:7},{symbol:"O",name:"oxygen",mass:15.9994,radius:.66,color:[1,.051,.051],number:8},{symbol:"F",name:"fluorine",mass:18.9984032,radius:.57,color:[.565,.878,.314],number:9},{symbol:"Ne",name:"neon",mass:20.1797,radius:.58,color:[.702,.89,.961],number:10},{symbol:"Na",name:"sodium",mass:22.98976928,radius:1.66,color:[.671,.361,.949],number:11},{symbol:"Mg",name:"magnesium",mass:24.305,radius:1.41,color:[.541,1,0],number:12},{symbol:"Al",name:"aluminum",mass:26.9815386,radius:1.21,color:[.749,.651,.651],number:13},{symbol:"Si",name:"silicon",mass:28.0855,radius:1.11,color:[.941,.784,.627],number:14},{symbol:"P",name:"phosphorus",mass:30.973762,radius:1.07,color:[1,.502,0],number:15},{symbol:"S",name:"sulfur",mass:32.065,radius:1.05,color:[1,1,.188],number:16},{symbol:"Cl",name:"chlorine",mass:35.453,radius:1.02,color:[.122,.941,.122],number:17},{symbol:"Ar",name:"argon",mass:39.948,radius:1.06,color:[.502,.82,.89],number:18},{symbol:"K",name:"potassium",mass:39.0983,radius:2.03,color:[.561,.251,.831],number:19},{symbol:"Ca",name:"calcium",mass:40.078,radius:1.76,color:[.239,1,0],number:20},{symbol:"Sc",name:"scandium",mass:44.955912,radius:1.7,color:[.902,.902,.902],number:21},{symbol:"Ti",name:"titanium",mass:47.867,radius:1.6,color:[.749,.761,.78],number:22},{symbol:"V",name:"vanadium",mass:50.9415,radius:1.53,color:[.651,.651,.671],number:23},{symbol:"Cr",name:"chromium",mass:51.9961,radius:1.39,color:[.541,.6,.78],number:24},{symbol:"Mn",name:"manganese",mass:54.938045,radius:1.39,color:[.611,.478,.78],number:25},{symbol:"Fe",name:"iron",mass:55.845,radius:1.32,color:[.878,.4,.2],number:26},{symbol:"Co",name:"cobalt",mass:58.6934,radius:1.26,color:[.941,.565,.627],number:27},{symbol:"Ni",name:"nickel",mass:58.933195,radius:1.24,color:[.314,.816,.314],number:28},{symbol:"Cu",name:"copper",mass:63.546,radius:1.32,color:[.784,.502,.2],number:29},{symbol:"Zn",name:"zinc",mass:65.38,radius:1.22,color:[.49,.502,.69],number:30},{symbol:"Ga",name:"gallium",mass:69.723,radius:1.22,color:[.761,.561,.561],number:31},{symbol:"Ge",name:"germanium",mass:72.64,radius:1.2,color:[.4,.561,.561],number:32},{symbol:"As",name:"arsenic",mass:74.9216,radius:1.19,color:[.741,.502,.89],number:33},{symbol:"Se",name:"selenium",mass:78.96,radius:1.2,color:[1,.631,0],number:34},{symbol:"Br",name:"bromine",mass:79.904,radius:1.2,color:[.651,.161,.161],number:35},{symbol:"Kr",name:"krypton",mass:83.798,radius:1.16,color:[.361,.722,.82],number:36},{symbol:"Rb",name:"rubidium",mass:85.4678,radius:2.2,color:[.439,.18,.69],number:37},{symbol:"Sr",name:"strontium",mass:87.62,radius:1.95,color:[0,1,0],number:38},{symbol:"Y",name:"yttrium",mass:88.90585,radius:1.9,color:[.58,1,1],number:39},{symbol:"Zr",name:"zirconium",mass:91.224,radius:1.75,color:[.58,.878,.878],number:40},{symbol:"Nb",name:"niobium",mass:92.90638,radius:1.64,color:[.451,.761,.788],number:41},{symbol:"Mo",name:"molybdenum",mass:95.96,radius:1.54,color:[.329,.71,.71],number:42},{symbol:"Tc",name:"technetium",mass:98,radius:1.47,color:[.231,.62,.62],number:43},{symbol:"Ru",name:"ruthenium",mass:101.07,radius:1.46,color:[.141,.561,.561],number:44},{symbol:"Rh",name:"rhodium",mass:102.9055,radius:1.42,color:[.039,.49,.549],number:45},{symbol:"Pd",name:"palladium",mass:106.42,radius:1.39,color:[0,.412,.522],number:46},{symbol:"Ag",name:"silver",mass:107.8682,radius:1.45,color:[.753,.753,.753],number:47},{symbol:"Cd",name:"cadmium",mass:112.411,radius:1.44,color:[1,.851,.561],number:48},{symbol:"In",name:"indium",mass:114.818,radius:1.42,color:[.651,.459,.451],number:49},{symbol:"Sn",name:"tin",mass:118.71,radius:1.39,color:[.4,.502,.502],number:50},{symbol:"Sb",name:"antimony",mass:121.76,radius:1.39,color:[.62,.388,.71],number:51},{symbol:"Te",name:"tellurium",mass:127.6,radius:1.38,color:[.831,.478,0],number:52},{symbol:"I",name:"iodine",mass:126.9047,radius:1.39,color:[.58,0,.58],number:53},{symbol:"Xe",name:"xenon",mass:131.293,radius:1.4,color:[.259,.62,.69],number:54},{symbol:"Cs",name:"cesium",mass:132.9054519,radius:2.44,color:[.341,.09,.561],number:55},{symbol:"Ba",name:"barium",mass:137.327,radius:2.15,color:[0,.788,0],number:56},{symbol:"La",name:"lanthanum",mass:138.90547,radius:2.07,color:[.439,.831,1],number:57},{symbol:"Ce",name:"cerium",mass:140.116,radius:2.04,color:[1,1,.78],number:58},{symbol:"Pr",name:"praseodymium",mass:140.90765,radius:2.03,color:[.851,1,.78],number:59},{symbol:"Nd",name:"neodymium",mass:144.242,radius:2.01,color:[.78,1,.78],number:60},{symbol:"Pm",name:"promethium",mass:145,radius:1.99,color:[.639,1,.78],number:61},{symbol:"Sm",name:"samarium",mass:150.36,radius:1.98,color:[.561,1,.78],number:62},{symbol:"Eu",name:"europium",mass:151.964,radius:1.98,color:[.38,1,.78],number:63},{symbol:"Gd",name:"gadolinium",mass:157.25,radius:1.96,color:[.271,1,.78],number:64},{symbol:"Tb",name:"terbium",mass:158.92535,radius:1.94,color:[.189,1,.78],number:65},{symbol:"Dy",name:"dysprosium",mass:162.5,radius:1.92,color:[.122,1,.78],number:66},{symbol:"Ho",name:"holmium",mass:164.93032,radius:1.92,color:[0,1,.612],number:67},{symbol:"Er",name:"erbium",mass:167.259,radius:1.89,color:[0,.902,.459],number:68},{symbol:"Tm",name:"thulium",mass:168.93421,radius:1.9,color:[0,.831,.322],number:69},{symbol:"Yb",name:"ytterbium",mass:173.054,radius:1.87,color:[0,.749,.22],number:70},{symbol:"Lu",name:"lutetium",mass:174.9668,radius:1.87,color:[0,.671,.141],number:71},{symbol:"Hf",name:"hafnium",mass:178.49,radius:1.75,color:[.302,.761,1],number:72},{symbol:"Ta",name:"tantalum",mass:180.94788,radius:1.7,color:[.302,.651,1],number:73},{symbol:"W",name:"tungsten",mass:183.84,radius:1.62,color:[.129,.58,.839],number:74},{symbol:"Re",name:"rhenium",mass:186.207,radius:1.51,color:[.149,.49,.671],number:75},{symbol:"Os",name:"osmium",mass:190.23,radius:1.44,color:[.149,.4,.588],number:76},{symbol:"Ir",name:"iridium",mass:192.217,radius:1.41,color:[.09,.329,.529],number:77},{symbol:"Pt",name:"platinum",mass:195.084,radius:1.36,color:[.816,.816,.878],number:78},{symbol:"Au",name:"gold",mass:196.966569,radius:1.36,color:[1,.82,.137],number:79},{symbol:"Hg",name:"mercury",mass:200.59,radius:1.32,color:[.722,.722,.816],number:80},{symbol:"Tl",name:"thallium",mass:204.3833,radius:1.45,color:[.651,.329,.302],number:81},{symbol:"Pb",name:"lead",mass:207.2,radius:1.46,color:[.341,.349,.38],number:82},{symbol:"Bi",name:"bismuth",mass:208.9804,radius:1.48,color:[.62,.31,.71],number:83},{symbol:"Po",name:"polonium",mass:210,radius:1.4,color:[.671,.361,0],number:84},{symbol:"At",name:"astatine",mass:210,radius:1.5,color:[.459,.31,.271],number:85},{symbol:"Rn",name:"radon",mass:220,radius:1.5,color:[.259,.51,.588],number:86},{symbol:"Fr",name:"francium",mass:223,radius:2.6,color:[.259,0,.4],number:87},{symbol:"Ra",name:"radium",mass:226,radius:2.21,color:[0,.49,0],number:88},{symbol:"Ac",name:"actinium",mass:227,radius:2.15,color:[.439,.671,.98],number:89},{symbol:"Th",name:"thorium",mass:231.03588,radius:2.06,color:[0,.729,1],number:90},{symbol:"Pa",name:"protactinium",mass:232.03806,radius:2,color:[0,.631,1],number:91},{symbol:"U",name:"uranium",mass:237,radius:1.96,color:[0,.561,1],number:92},{symbol:"Np",name:"neptunium",mass:238.02891,radius:1.9,color:[0,.502,1],number:93},{symbol:"Pu",name:"plutonium",mass:243,radius:1.87,color:[0,.42,1],number:94},{symbol:"Am",name:"americium",mass:244,radius:1.8,color:[.329,.361,.949],number:95},{symbol:"Cm",name:"curium",mass:247,radius:1.69,color:[.471,.361,.89],number:96},{symbol:"Bk",name:"berkelium",mass:247,radius:1.66,color:[.541,.31,.89],number:97},{symbol:"Cf",name:"californium",mass:251,radius:1.68,color:[.631,.212,.831],number:98},{symbol:"Es",name:"einsteinium",mass:252,radius:1.65,color:[.702,.122,.831],number:99},{symbol:"Fm",name:"fermium",mass:257,radius:1.67,color:[.702,.122,.729],number:100},{symbol:"Md",name:"mendelevium",mass:258,radius:1.73,color:[.702,.051,.651],number:101},{symbol:"No",name:"nobelium",mass:259,radius:1.76,color:[.741,.051,.529],number:102},{symbol:"Lr",name:"lawrencium",mass:262,radius:1.61,color:[.78,0,.4],number:103},{symbol:"Rf",name:"rutherfordium",mass:261,radius:1.57,color:[.8,0,.349],number:104},{symbol:"Db",name:"dubnium",mass:262,radius:1.49,color:[.82,0,.31],number:105},{symbol:"Sg",name:"seaborgium",mass:266,radius:1.43,color:[.851,0,.271],number:106},{symbol:"Bh",name:"bohrium",mass:264,radius:1.41,color:[.878,0,.22],number:107},{symbol:"Hs",name:"hassium",mass:277,radius:1.34,color:[.902,0,.18],number:108},{symbol:"Mt",name:"meitnerium",mass:268,radius:1.29,color:[.922,0,.149],number:10},{symbol:"Ds",name:"Ds",mass:271,radius:1.28,color:[.922,0,.149],number:110},{symbol:"Uuu",name:"Uuu",mass:272,radius:1.21,color:[.922,0,.149],number:11},{symbol:"Uub",name:"Uub",mass:285,radius:1.22,color:[.922,0,.149],number:112},{symbol:"Uut",name:"Uut",mass:284,radius:1.36,color:[.922,0,.149],number:113},{symbol:"Uuq",name:"Uuq",mass:289,radius:1.43,color:[.922,0,.149],number:114},{symbol:"Uup",name:"Uup",mass:288,radius:1.62,color:[.922,0,.149],number:115},{symbol:"Uuh",name:"Uuh",mass:292,radius:1.75,color:[.922,0,.149],number:116},{symbol:"Uus",name:"Uus",mass:294,radius:1.65,color:[.922,0,.149],number:117},{symbol:"Uuo",name:"Uuo",mass:296,radius:1.57,color:[.922,0,.149],number:118}],e.elementsBySymbol={},e.elements.forEach(function(t){e.elementsBySymbol[t.symbol.toUpperCase()]=t}),e.elementsByNumber={},e.elements.forEach(function(t){e.elementsByNumber[t.number]=t}),e.MIN_ATOM_RADIUS=1/0,e.MAX_ATOM_RADIUS=-1/0,e.elements.forEach(function(t){e.MIN_ATOM_RADIUS=Math.min(e.MIN_ATOM_RADIUS,t.radius),e.MAX_ATOM_RADIUS=Math.max(e.MAX_ATOM_RADIUS,t.radius)})}(e.Elements||(e.Elements={}))}(Molvwr||(Molvwr={})),function(e){!function(t){function i(e){return e?parseFloat(e.trim()):0}t.mol={parse:function(t){console.log("parsing mol content");var r={atoms:[],title:null},n=t.split("\n");r.title=n[1];for(var o=0,s=n.length;o<s;o++)if(0==n[o].indexOf("  ")){var a=n[o].split(" ").filter(function(e){var t=e.trim();return!(!t||!t.length)});if(a.length&&a.length>=4){var h=a[3].trim(),c=i(a[0]),l=i(a[1]),u=i(a[2]),d=e.Elements.elementsBySymbol[h.toUpperCase()];d?r.atoms.push({kind:d,x:c,y:l,z:u,bonds:[]}):console.warn("atom not found "+h)}}return console.log("found "+r.atoms.length),r}}}(e.Parser||(e.Parser={}))}(Molvwr||(Molvwr={})),function(e){!function(t){t.pdb={parse:function(e){console.log("parsing pdb content");for(var t={atoms:[],title:null},i=e.split("\n"),r=0,n=i.length;r<n;r++){var o=i[r];0!=o.indexOf("HETATM")&&0!=o.indexOf("ATOM")||this.parseHETATM(t,o)}return console.log("found "+t.title+" "+t.atoms.length),t},parseHETATM:function(t,i){var r=i.substr(12,2).trim();!1===isNaN(r[0])&&(r=r.substr(1));var n=e.Elements.elementsBySymbol[r.toUpperCase()];if(n){var o=parseFloat(i.substr(30,8).trim()),s=parseFloat(i.substr(38,8).trim()),a=parseFloat(i.substr(46,8).trim());t.atoms.push({kind:n,x:o,y:s,z:a,bonds:[]})}else console.warn("atom not found "+r)}}}(e.Parser||(e.Parser={}))}(Molvwr||(Molvwr={})),function(e){!function(t){function i(e){return e?parseFloat(e.trim()):0}t.xyz={parse:function(t){console.log("parsing xyz content");var r={atoms:[],title:null},n=t.split("\n");r.title=n[1];for(var o=2,s=n.length;o<s;o++){var a=n[o].split(" ").filter(function(e){var t=e.trim();return!(!t||!t.length)});if(a.length&&a.length>=4){var h=a[0].trim(),c=i(a[1]),l=i(a[2]),u=i(a[3]),d=e.Elements.elementsBySymbol[h.toUpperCase()];d?r.atoms.push({kind:d,x:c,y:l,z:u,bonds:[]}):console.warn("atom not found "+h)}}return console.log("found "+r.title+" "+r.atoms.length),r}}}(e.Parser||(e.Parser={}))}(Molvwr||(Molvwr={}));var Molvwr;__global=this;!function(e){!function(e){var t="function"==typeof setImmediate&&setImmediate||function(e){setTimeout(e,1)},i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};e.runBatch=function e(i,n,o,s,a){return a&&console.log(a+" "+i+"/"+o.length),new r(function(r,h){t(function(){var t=o.slice(i,i+n);t.forEach(function(e,t){s(e,t,t+i)}),t.length<n?r():e(i+n,n,o,s,a).then(r,h)})})};var r=function(){function e(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],a(e,function e(t){try{if(t===this)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)){var i=t.then;if("function"==typeof i)return void a(i.bind(t),e.bind(this),o.bind(this))}this._state=!0,this._value=t,s.call(this)}catch(e){console.error(e),o.call(this,e)}}.bind(this),o.bind(this))}return e.prototype.catch=function(e){return this.then(null,e)},e.prototype.then=function(t,i){var r=this;return new e(function(e,o){n.call(r,new function(e,t,i,r){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=i,this.reject=r}(t,i,e,o))})},e.timeout=function(t){return new e(function(e,i){setTimeout(function(){e()},t)})},e.all=function(t){var r=Array.prototype.slice.call(1===arguments.length&&i(arguments[0])?arguments[0]:arguments);return new e(function(e,t){if(0===r.length)return e([]);var i=r.length;function n(o,s){try{if(s&&("object"==typeof s||"function"==typeof s)){var a=s.then;if("function"==typeof a)return void a.call(s,function(e){n(o,e)},t)}r[o]=s,0==--i&&e(r)}catch(e){console.error(e),t(e)}}for(var o=0;o<r.length;o++)n(o,r[o])})},e.resolve=function(t){return t&&"object"==typeof t&&t.constructor===e?t:new e(function(e){e(t)})},e.reject=function(t){return new e(function(e,i){i(t)})},e.race=function(t){return new e(function(e,i){for(var r=0,n=t.length;r<n;r++)t[r].then(e,i)})},e._setImmediateFn=function(e){t=e},e}();function n(e){var i=this;null!==this._state?t(function(){var t=i._state?e.onFulfilled:e.onRejected;if(null!==t){var r;try{r=t(i._value)}catch(t){return console.error(t),void e.reject(t)}e.resolve(r)}else(i._state?e.resolve:e.reject)(i._value)}):this._deferreds.push(e)}function o(e){this._state=!1,this._value=e,s.call(this)}function s(){for(var e=0,t=this._deferreds.length;e<t;e++)n.call(this,this._deferreds[e]);this._deferreds=null}function a(e,t,i){var r=!1;try{e(function(e){r||(r=!0,t(e))},function(e){r||(r=!0,i(e))})}catch(e){if(console.error(e),r)return;r=!0,i(e)}}e.Promise=r}(e.Utils||(e.Utils={}))}(Molvwr||(Molvwr={})),function(e){!function(t){var i=function(){function t(e,t,i){this.meshes={},this.ctx=t,this.config=i,this.viewer=e}return t.prototype.render=function(t){var i=this,r=(this.config,e.Elements.MIN_ATOM_RADIUS*this.config.cylinderScale*this.config.atomScaleFactor);t.bonds.length;return this.prepareBonds(t,r).then(function(){return console.time("cylinder rendering"),e.Utils.runBatch(0,t.batchSize,t.bonds,function(e,t){var r=e.atomA.kind.symbol+"#"+e.atomB.kind.symbol,n=i.meshes[r].createInstance("bond"+t);i.alignCylinderToBinding(e.atomA,e.atomB,e.d,n)},"cylinder rendering").then(function(){console.timeEnd("cylinder rendering")})})},t.prototype.prepareBonds=function(t,i){var r=this;console.time("prepare bonds as cylinder");var n=[];for(var o in t.bondkinds)n.push(t.bondkinds[o]);var s=100;return this.config.cylinderLOD&&(s=s/this.config.cylinderLOD.length>>0),e.Utils.runBatch(0,s,n,function(e,t){r.meshes[e.key]=r.createMesh(e,i)},"prepare cylinder").then(function(){console.timeEnd("prepare bonds as cylinder")})},t.prototype.createMesh=function(e,t){if(this.config.cylinderLOD){for(var i=this.config.cylinderLOD[0],r=this.createCylinder(e,t,0,i.segments,i.effects,i.color),n=1,o=this.config.cylinderLOD.length;n<o;n++){var s=this.config.cylinderLOD[n];if(s.segments){var a=this.createCylinder(e,t,n,s.segments,s.effects,s.color);r.addLODLevel(s.depth,a)}else r.addLODLevel(s.depth,null)}return r}return this.createCylinder(e,t,0,this.config.cylinderSegments,!0,null)},t.prototype.createCylinder=function(e,t,i,r,n,o){var s=BABYLON.Mesh.CreateCylinder("bondtemplate"+e.key,e.d,t,t,r,2,this.ctx.scene,!1),a=new BABYLON.StandardMaterial("materialFor"+e.key+i,this.ctx.scene);o||e.kindA.color;return a.diffuseColor=new BABYLON.Color3(.3,.3,.3),this.ctx.cylinderMaterial(s,a,n),s.material=a,s.isPickable=!1,s.setEnabled(!1),s},t.prototype.alignCylinderToBinding=function(e,t,i,r){var n=new BABYLON.Vector3(e.x,e.y,e.z),o=new BABYLON.Vector3(t.x,t.y,t.z),s=o.subtract(n);s.normalize();var a=new BABYLON.Vector3(0,1,0);if(this.vectorEqualsCloseEnough(s,a.negate())){console.log("must invert...");a=new BABYLON.Vector3(1,0,0);(l=BABYLON.Vector3.Cross(a,s)).normalize();var h=BABYLON.Vector3.Dot(s,a);h=Math.acos(h)+Math.PI/2,r.setPivotMatrix(BABYLON.Matrix.Translation(0,-i/2,0)),r.position=o;var c=BABYLON.Quaternion.RotationAxis(l,h);c.w=-c.w,r.rotationQuaternion=c,console.log(r.rotationQuaternion)}else{var l;(l=BABYLON.Vector3.Cross(a,s)).normalize();h=BABYLON.Vector3.Dot(s,a);h=Math.acos(h),r.setPivotMatrix(BABYLON.Matrix.Translation(0,-i/2,0)),r.position=o,r.rotationQuaternion=BABYLON.Quaternion.RotationAxis(l,h)}},t.prototype.vectorEqualsCloseEnough=function(e,t,i){if(void 0===i&&(i=2e-5),"object"!=typeof t)throw"v2 is supposed to be an object";if("object"!=typeof e)throw"v1 is supposed to be an object";return!(e.x<t.x-i||e.x>t.x+i)&&(!(e.y<t.y-i||e.y>t.y+i)&&!(e.z<t.z-i||e.z>t.z+i))},t}();t.BondsCylinder=i}(e.Renderer||(e.Renderer={}))}(Molvwr||(Molvwr={})),function(e){!function(t){var i=function(){function t(e,t,i){this.meshes={},this.ctx=t,this.config=i,this.viewer=e}return t.prototype.render=function(t){var i=this,r=(this.config,[]);return console.log("rendering bonds as lines"),t.bonds.forEach(function(e,t){var n=BABYLON.Mesh.CreateLines("bond-"+t,[new BABYLON.Vector3(e.atomA.x,e.atomA.y,e.atomA.z),new BABYLON.Vector3(e.atomB.x,e.atomB.y,e.atomB.z)],i.ctx.scene,!1);n.color=new BABYLON.Color3(.5,.5,.5),r.push(n)}),e.Utils.Promise.resolve()},t}();t.BondsLines=i}(e.Renderer||(e.Renderer={}))}(Molvwr||(Molvwr={})),function(e){!function(t){var i=function(){function t(e,t,i){this.meshes={},this.ctx=t,this.config=i,this.viewer=e}return t.prototype.render=function(t){var i=this;return this.prepareMeshes(t).then(function(){return console.time("sphere rendering"),e.Utils.runBatch(0,t.batchSize,t.atoms,i.renderAtom.bind(i),"sphere rendering").then(function(){console.timeEnd("sphere rendering")})})},t.prototype.prepareMeshes=function(t){var i=this;console.time("prepare spheres");var r=[];for(var n in t.kinds)r.push(t.kinds[n]);return e.Utils.runBatch(0,100,r,function(e,t){i.meshes[e.kind.symbol]=i.createMesh(e.kind)},"prepare spheres").then(function(){console.timeEnd("prepare spheres")})},t.prototype.createMesh=function(e){if(this.config.sphereLOD){for(var t=this.config.sphereLOD[0],i=this.createSphere(e,t.segments,t.effects,t.color),r=1,n=this.config.sphereLOD.length;r<n;r++){var o=this.config.sphereLOD[r];if(o.segments){var s=this.createSphere(e,o.segments,o.effects,o.color);i.addLODLevel(o.depth,s)}else i.addLODLevel(o.depth,null)}return i}return this.createSphere(e,this.config.sphereSegments,!0,null)},t.prototype.createSphere=function(e,t,i,r){var n=BABYLON.Mesh.CreateSphere("spheretemplate",t,e.radius*this.config.atomScaleFactor,this.ctx.scene,!1);n.setEnabled(!1),n.isPickable=!1;var o=new BABYLON.StandardMaterial("materialFor"+e.symbol,this.ctx.scene),s=r||e.color;return o.diffuseColor=new BABYLON.Color3(s[0],s[1],s[2]),this.ctx.sphereMaterial(n,o,i),n.material=o,n},t.prototype.renderAtom=function(e,t){this.config;var i=this.meshes[e.kind.symbol];i||console.warn("no mesh for "+e.kind.symbol);var r=i.createInstance("sphere"+t);return r.pickable=!1,r.position.x=e.x,r.position.y=e.y,r.position.z=e.z,r},t}();t.Sphere=i}(e.Renderer||(e.Renderer={}))}(Molvwr||(Molvwr={})),function(e){!function(t){var i=function(){function t(e,t,i){this.meshes={},this.ctx=t,this.config=i,this.viewer=e}return t.prototype.render=function(t){var i=this,r=(this.config,e.Elements.MIN_ATOM_RADIUS*this.config.cylinderScale*this.config.atomScaleFactor);t.bonds.length;return this.prepareBonds(t,r).then(function(){return console.time("sticks rendering"),e.Utils.runBatch(0,t.batchSize,t.bonds,function(e,t){var r=e.atomA.kind.symbol+"#"+e.atomB.kind.symbol,n=i.meshes[r].createInstance("bond"+t);i.alignCylinderToBinding(e.atomA,e.atomB,e.d,n)}).then(function(){console.timeEnd("sticks rendering")})})},t.prototype.prepareBonds=function(t,i){var r=this;console.time("prepare bonds as sticks");var n=[];for(var o in t.bondkinds)n.push(t.bondkinds[o]);var s=50;return this.config.cylinderLOD&&(s=s/this.config.cylinderLOD.length>>0),e.Utils.runBatch(0,s,n,function(e,t){r.meshes[e.key]=r.createMesh(e,i)},"prepare sticks").then(function(){console.timeEnd("prepare bonds as sticks")})},t.prototype.createMesh=function(e,t){var i=this.createStickMergemesh;if(this.config.cylinderLOD){for(var r=this.config.cylinderLOD[0],n=i.apply(this,[e,t,0,r.segments,r.texture,r.effects,r.color]),o=1,s=this.config.cylinderLOD.length;o<s;o++){var a=this.config.cylinderLOD[o];if(a.segments){var h=i.apply(this,[e,t,o,a.segments,a.texture,a.effects,a.color]);n.addLODLevel(a.depth,h)}else n.addLODLevel(a.depth,null)}return n}return i.apply(this,[e,t,0,this.config.cylinderSegments,!0,!0,null])},t.prototype.createStickMergemesh=function(e,t,i,r,n,o,s){var a=t/2,h=e.d-a/2.5,c=h/2,l=BABYLON.Mesh.CreateCylinder("bondtemplate"+e.key+"-"+i,h,t,t,r,2,this.ctx.scene,!1),u=(l.getIndices(),BABYLON.Mesh.CreateSphere("sphereA"+e.key+"-"+i,r,t,this.ctx.scene,!1));u.position.y=-c;var d=BABYLON.Mesh.CreateSphere("sphereB"+e.key+"-"+i,r,t,this.ctx.scene,!1);d.position.y=c;var f=BABYLON.Mesh.MergeMeshes([u,l,d],!0),p=new BABYLON.StandardMaterial("materialFor"+e.key+e.kindA.symbol+"-"+i,this.ctx.scene),m=s||e.kindA.color;p.diffuseColor=new BABYLON.Color3(m[0],m[1],m[2]),this.ctx.cylinderMaterial(null,p,o);var g=new BABYLON.StandardMaterial("materialFor"+e.key+e.kindB.symbol+"-"+i,this.ctx.scene),v=s||e.kindB.color;g.diffuseColor=new BABYLON.Color3(v[0],v[1],v[2]),this.ctx.cylinderMaterial(null,g,o);var _=new BABYLON.MultiMaterial("materialFor"+e.key+"-"+i,this.ctx.scene);_.subMaterials.push(p),_.subMaterials.push(g);var y=f.getTotalVertices(),x=f.getIndices();f.subMeshes=[];var b=(x.length/2>>0)-3*r;return f.subMeshes.push(new BABYLON.SubMesh(0,0,y,0,b,f)),f.subMeshes.push(new BABYLON.SubMesh(1,0,y,b,x.length-b,f)),f.material=_,f.isPickable=!1,f.setEnabled(!1),f},t.prototype.alignCylinderToBinding=function(e,t,i,r){var n=new BABYLON.Vector3(e.x,e.y,e.z),o=new BABYLON.Vector3(t.x,t.y,t.z),s=o.subtract(n);s.normalize();var a=new BABYLON.Vector3(0,1,0);if(this.vectorEqualsCloseEnough(s,a.negate())){a=new BABYLON.Vector3(1,0,0);(l=BABYLON.Vector3.Cross(a,s)).normalize();var h=BABYLON.Vector3.Dot(s,a);h=Math.acos(h)+Math.PI/2,r.setPivotMatrix(BABYLON.Matrix.Translation(0,-i/2,0)),r.position=o;var c=BABYLON.Quaternion.RotationAxis(l,h);c.w=-c.w,r.rotationQuaternion=c,console.log(r.rotationQuaternion)}else{var l;(l=BABYLON.Vector3.Cross(a,s)).normalize();h=BABYLON.Vector3.Dot(s,a);h=Math.acos(h),r.setPivotMatrix(BABYLON.Matrix.Translation(0,-i/2,0)),r.position=o,r.rotationQuaternion=BABYLON.Quaternion.RotationAxis(l,h)}},t.prototype.vectorEqualsCloseEnough=function(e,t,i){if(void 0===i&&(i=2e-5),"object"!=typeof t)throw"v2 is supposed to be an object";if("object"!=typeof e)throw"v1 is supposed to be an object";return!(e.x<t.x-i||e.x>t.x+i)&&(!(e.y<t.y-i||e.y>t.y+i)&&!(e.z<t.z-i||e.z>t.z+i))},t}();t.Sticks=i}(e.Renderer||(e.Renderer={}))}(Molvwr||(Molvwr={})),function(e){!function(t){var i=function(){function t(t){this.options=t,t||(console.log("default viewmode config"),this.options=e.ViewModes.Standard.defaultConfig()),this.options.sphere||(this.options.sphere={}),this.options.cylinder||(this.options.cylinder={})}return t.defaultConfig=function(){var e={texture:!1,emisivefresnel:new BABYLON.FresnelParameters,cylinder:{},sphere:{}};return e.emisivefresnel.bias=.3,e.emisivefresnel.power=1,e.emisivefresnel.leftColor=BABYLON.Color3.Black(),e.emisivefresnel.rightColor=BABYLON.Color3.White(),e},t.prototype.getColor=function(e,t){return e&&e.length>=3?new BABYLON.Color3(e[0],e[1],e[2]):new BABYLON.Color3(t[0],t[1],t[2])},t.prototype.createScene=function(e){e.scene.clearColor=this.getColor(this.options.clearColor,[.9,.9,.95]),e.scene.fogMode=BABYLON.Scene.FOGMODE_EXP2,e.scene.fogColor=this.getColor(this.options.fogColor,[.9,.9,.85]),e.scene.fogDensity=this.options.fogDensity||.01;var t=new BABYLON.ArcRotateCamera("Camera",1,.8,28,new BABYLON.Vector3(0,0,0),e.scene);t.wheelPrecision=this.options.wheelPrecision||10,t.pinchPrecision=this.options.pinchPrecision||7,t.panningSensibility=this.options.panningSensibility||70,t.setTarget(BABYLON.Vector3.Zero()),t.attachControl(e.canvas,!1),e.camera=t;var i=new BABYLON.HemisphericLight("light1",new BABYLON.Vector3(0,1,0),e.scene);i.intensity=.7,i.groundColor=this.getColor(this.options.groundColor,[.4,.4,.4]),i.specular=this.getColor(this.options.specular,[.5,.5,.5])},t.prototype.applyTexture=function(e,t,i){i.diffuseTexture&&(t.diffuseTexture=new BABYLON.Texture(i.diffuseTexture,e.scene),t.diffuseTexture.uScale=i.textureScale||1,t.diffuseTexture.vScale=i.textureScale||1),i.specularTexture&&(t.specularTexture=new BABYLON.Texture(i.specularTexture,e.scene),t.specularTexture.uScale=i.textureScale||1,t.specularTexture.vScale=i.textureScale||1),i.bumpTexture&&(t.bumpTexture=new BABYLON.Texture(i.bumpTexture,e.scene),t.bumpTexture.uScale=i.textureScale||1,t.bumpTexture.vScale=i.textureScale||1)},t.prototype.sphereMaterial=function(e,t,i,r){i.ambientColor=new BABYLON.Color3(0,0,1),i.specularColor=new BABYLON.Color3(.1,.1,.1),i.emissiveColor=new BABYLON.Color3(.2,.2,.2),r&&(this.options.emisivefresnel&&(i.emissiveFresnelParameters=this.options.emisivefresnel),this.options.sphere&&this.applyTexture(e,i,this.options.sphere))},t.prototype.cylinderMaterial=function(e,t,i,r){i.ambientColor=new BABYLON.Color3(0,0,1),i.specularColor=new BABYLON.Color3(.2,.2,.2),i.emissiveColor=new BABYLON.Color3(.2,.2,.2),r&&(this.options.emisivefresnel&&(i.emissiveFresnelParameters=this.options.emisivefresnel),this.options.cylinder&&this.applyTexture(e,i,this.options.cylinder))},t}();t.Standard=i}(e.ViewModes||(e.ViewModes={}))}(Molvwr||(Molvwr={})),function(e){!function(e){var t=function(){function e(){}return e.prototype.createScene=function(e){e.scene.clearColor=new BABYLON.Color3(.9,.9,.95),e.scene.fogMode=BABYLON.Scene.FOGMODE_EXP2,e.scene.fogColor=new BABYLON.Color3(.9,.9,.85),e.scene.fogDensity=.01;var t=new BABYLON.ArcRotateCamera("Camera",1,.8,28,new BABYLON.Vector3(0,0,0),e.scene);t.wheelPrecision=10,t.pinchPrecision=7,t.panningSensibility=70,t.setTarget(BABYLON.Vector3.Zero()),t.attachControl(e.canvas,!1),e.camera=t;var i=new BABYLON.HemisphericLight("light1",new BABYLON.Vector3(0,1,0),e.scene);i.intensity=.7,i.groundColor=new BABYLON.Color3(.4,.4,.4),i.specular=new BABYLON.Color3(.5,.5,.5)},e.prototype.sphereMaterial=function(e,t,i,r){},e.prototype.cylinderMaterial=function(e,t,i,r){},e.prototype.useAmbientOcclusion=function(e){new BABYLON.SSAORenderingPipeline("ssaopipeline",e.scene,.75);e.scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline("ssaopipeline",e.camera)},e.prototype.useHDR=function(e){var t=new BABYLON.HDRRenderingPipeline("hdr",e.scene,1,null,[e.camera]);t.brightThreshold=1.2,t.gaussCoeff=.3,t.gaussMean=1,t.gaussStandDev=.8,t.exposure=1,t.minimumLuminance=.5,t.maximumLuminance=1e10,t.luminanceDecreaseRate=.5,t.luminanceIncreaserate=.5,e.scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline("hdr",[e.camera])},e.prototype.useLensEffect=function(e){new BABYLON.LensRenderingPipeline("lens",{edge_blur:.2,chromatic_aberration:.2,distortion:.2,dof_focus_depth:100/e.camera.maxZ,dof_aperture:1,grain_amount:.2,dof_pentagon:!0,dof_gain:1,dof_threshold:1},e.scene,1,[e.camera])},e}();e.Experiments=t}(e.ViewModes||(e.ViewModes={}))}(Molvwr||(Molvwr={}));var BABYLON,__extends=this&&this.__extends||function(e,t){function i(){this.constructor=e}for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);i.prototype=t.prototype,e.prototype=new i};!function(e){var t=function(){function t(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this.r=e,this.g=t,this.b=i}return t.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},t.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,this},t.prototype.toColor4=function(e){return void 0===e&&(e=1),new i(this.r,this.g,this.b,e)},t.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},t.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},t.prototype.multiply=function(e){return new t(this.r*e.r,this.g*e.g,this.b*e.b)},t.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,this},t.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b},t.prototype.equalsFloats=function(e,t,i){return this.r===e&&this.g===t&&this.b===i},t.prototype.scale=function(e){return new t(this.r*e,this.g*e,this.b*e)},t.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,this},t.prototype.add=function(e){return new t(this.r+e.r,this.g+e.g,this.b+e.b)},t.prototype.addToRef=function(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,this},t.prototype.subtract=function(e){return new t(this.r-e.r,this.g-e.g,this.b-e.b)},t.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,this},t.prototype.clone=function(){return new t(this.r,this.g,this.b)},t.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},t.prototype.copyFromFloats=function(e,t,i){return this.r=e,this.g=t,this.b=i,this},t.prototype.toHexString=function(){var t=255*this.r|0,i=255*this.g|0,r=255*this.b|0;return"#"+e.Tools.ToHex(t)+e.Tools.ToHex(i)+e.Tools.ToHex(r)},t.FromHexString=function(i){if("#"!==i.substring(0,1)||7!==i.length)return e.Tools.Warn("Color3.FromHexString must be called with a string like #FFFFFF"),new t(0,0,0);var r=parseInt(i.substring(1,3),16),n=parseInt(i.substring(3,5),16),o=parseInt(i.substring(5,7),16);return t.FromInts(r,n,o)},t.FromArray=function(e,i){return void 0===i&&(i=0),new t(e[i],e[i+1],e[i+2])},t.FromInts=function(e,i,r){return new t(e/255,i/255,r/255)},t.Lerp=function(e,i,r){return new t(e.r+(i.r-e.r)*r,e.g+(i.g-e.g)*r,e.b+(i.b-e.b)*r)},t.Red=function(){return new t(1,0,0)},t.Green=function(){return new t(0,1,0)},t.Blue=function(){return new t(0,0,1)},t.Black=function(){return new t(0,0,0)},t.White=function(){return new t(1,1,1)},t.Purple=function(){return new t(.5,0,.5)},t.Magenta=function(){return new t(1,0,1)},t.Yellow=function(){return new t(1,1,0)},t.Gray=function(){return new t(.5,.5,.5)},t}();e.Color3=t;var i=function(){function t(e,t,i,r){this.r=e,this.g=t,this.b=i,this.a=r}return t.prototype.addInPlace=function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this},t.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},t.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e[t+3]=this.a,this},t.prototype.add=function(e){return new t(this.r+e.r,this.g+e.g,this.b+e.b,this.a+e.a)},t.prototype.subtract=function(e){return new t(this.r-e.r,this.g-e.g,this.b-e.b,this.a-e.a)},t.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t.a=this.a-e.a,this},t.prototype.scale=function(e){return new t(this.r*e,this.g*e,this.b*e,this.a*e)},t.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t.a=this.a*e,this},t.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"},t.prototype.clone=function(){return new t(this.r,this.g,this.b,this.a)},t.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this},t.prototype.toHexString=function(){var t=255*this.r|0,i=255*this.g|0,r=255*this.b|0,n=255*this.a|0;return"#"+e.Tools.ToHex(t)+e.Tools.ToHex(i)+e.Tools.ToHex(r)+e.Tools.ToHex(n)},t.FromHexString=function(i){if("#"!==i.substring(0,1)||9!==i.length)return e.Tools.Warn("Color4.FromHexString must be called with a string like #FFFFFFFF"),new t(0,0,0,0);var r=parseInt(i.substring(1,3),16),n=parseInt(i.substring(3,5),16),o=parseInt(i.substring(5,7),16),s=parseInt(i.substring(7,9),16);return t.FromInts(r,n,o,s)},t.Lerp=function(e,i,r){var n=new t(0,0,0,0);return t.LerpToRef(e,i,r,n),n},t.LerpToRef=function(e,t,i,r){r.r=e.r+(t.r-e.r)*i,r.g=e.g+(t.g-e.g)*i,r.b=e.b+(t.b-e.b)*i,r.a=e.a+(t.a-e.a)*i},t.FromArray=function(e,i){return void 0===i&&(i=0),new t(e[i],e[i+1],e[i+2],e[i+3])},t.FromInts=function(e,i,r,n){return new t(e/255,i/255,r/255,n/255)},t}();e.Color4=i;var r=function(){function t(e,t){this.x=e,this.y=t}return t.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+"}"},t.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,this},t.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},t.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this},t.prototype.copyFromFloats=function(e,t){return this.x=e,this.y=t,this},t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y)},t.prototype.addVector3=function(e){return new t(this.x+e.x,this.y+e.y)},t.prototype.subtract=function(e){return new t(this.x-e.x,this.y-e.y)},t.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this},t.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this},t.prototype.multiply=function(e){return new t(this.x*e.x,this.y*e.y)},t.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,this},t.prototype.multiplyByFloats=function(e,i){return new t(this.x*e,this.y*i)},t.prototype.divide=function(e){return new t(this.x/e.x,this.y/e.y)},t.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,this},t.prototype.negate=function(){return new t(-this.x,-this.y)},t.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this},t.prototype.scale=function(e){return new t(this.x*e,this.y*e)},t.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y},t.prototype.equalsWithEpsilon=function(t,i){return void 0===i&&(i=e.Engine.Epsilon),t&&e.Tools.WithinEpsilon(this.x,t.x,i)&&e.Tools.WithinEpsilon(this.y,t.y,i)},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},t.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},t.prototype.normalize=function(){var e=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this},t.prototype.clone=function(){return new t(this.x,this.y)},t.Zero=function(){return new t(0,0)},t.FromArray=function(e,i){return void 0===i&&(i=0),new t(e[i],e[i+1])},t.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1]},t.CatmullRom=function(e,i,r,n,o){var s=o*o,a=o*s;return new t(.5*(2*i.x+(-e.x+r.x)*o+(2*e.x-5*i.x+4*r.x-n.x)*s+(-e.x+3*i.x-3*r.x+n.x)*a),.5*(2*i.y+(-e.y+r.y)*o+(2*e.y-5*i.y+4*r.y-n.y)*s+(-e.y+3*i.y-3*r.y+n.y)*a))},t.Clamp=function(e,i,r){var n=e.x;n=(n=n>r.x?r.x:n)<i.x?i.x:n;var o=e.y;return new t(n,o=(o=o>r.y?r.y:o)<i.y?i.y:o)},t.Hermite=function(e,i,r,n,o){var s=o*o,a=o*s,h=2*a-3*s+1,c=-2*a+3*s,l=a-2*s+o,u=a-s;return new t(e.x*h+r.x*c+i.x*l+n.x*u,e.y*h+r.y*c+i.y*l+n.y*u)},t.Lerp=function(e,i,r){return new t(e.x+(i.x-e.x)*r,e.y+(i.y-e.y)*r)},t.Dot=function(e,t){return e.x*t.x+e.y*t.y},t.Normalize=function(e){var t=e.clone();return t.normalize(),t},t.Minimize=function(e,i){return new t(e.x<i.x?e.x:i.x,e.y<i.y?e.y:i.y)},t.Maximize=function(e,i){return new t(e.x>i.x?e.x:i.x,e.y>i.y?e.y:i.y)},t.Transform=function(e,i){return new t(e.x*i.m[0]+e.y*i.m[4],e.x*i.m[1]+e.y*i.m[5])},t.Distance=function(e,i){return Math.sqrt(t.DistanceSquared(e,i))},t.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y;return i*i+r*r},t}();e.Vector2=r;var n=function(){function t(e,t,i){this.x=e,this.y=t,this.z=i}return t.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"}"},t.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},t.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,this},t.prototype.toQuaternion=function(){var e=new s(0,0,0,1),t=Math.cos(.5*(this.x+this.z)),i=Math.sin(.5*(this.x+this.z)),r=Math.cos(.5*(this.z-this.x)),n=Math.sin(.5*(this.z-this.x)),o=Math.cos(.5*this.y),a=Math.sin(.5*this.y);return e.x=r*a,e.y=-n*a,e.z=i*o,e.w=t*o,e},t.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y,this.z+e.z)},t.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t.z=this.z+e.z,this},t.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},t.prototype.subtract=function(e){return new t(this.x-e.x,this.y-e.y,this.z-e.z)},t.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t.z=this.z-e.z,this},t.prototype.subtractFromFloats=function(e,i,r){return new t(this.x-e,this.y-i,this.z-r)},t.prototype.subtractFromFloatsToRef=function(e,t,i,r){return r.x=this.x-e,r.y=this.y-t,r.z=this.z-i,this},t.prototype.negate=function(){return new t(-this.x,-this.y,-this.z)},t.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this},t.prototype.scale=function(e){return new t(this.x*e,this.y*e,this.z*e)},t.prototype.scaleToRef=function(e,t){t.x=this.x*e,t.y=this.y*e,t.z=this.z*e},t.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z},t.prototype.equalsWithEpsilon=function(t,i){return void 0===i&&(i=e.Engine.Epsilon),t&&e.Tools.WithinEpsilon(this.x,t.x,i)&&e.Tools.WithinEpsilon(this.y,t.y,i)&&e.Tools.WithinEpsilon(this.z,t.z,i)},t.prototype.equalsToFloats=function(e,t,i){return this.x===e&&this.y===t&&this.z===i},t.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this},t.prototype.multiply=function(e){return new t(this.x*e.x,this.y*e.y,this.z*e.z)},t.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,t.z=this.z*e.z,this},t.prototype.multiplyByFloats=function(e,i,r){return new t(this.x*e,this.y*i,this.z*r)},t.prototype.divide=function(e){return new t(this.x/e.x,this.y/e.y,this.z/e.z)},t.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,t.z=this.z/e.z,this},t.prototype.MinimizeInPlace=function(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),this},t.prototype.MaximizeInPlace=function(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),this},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},t.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},t.prototype.normalize=function(){var e=this.length();if(0===e||1===e)return this;var t=1/e;return this.x*=t,this.y*=t,this.z*=t,this},t.prototype.clone=function(){return new t(this.x,this.y,this.z)},t.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},t.prototype.copyFromFloats=function(e,t,i){return this.x=e,this.y=t,this.z=i,this},t.GetClipFactor=function(e,i,r,n){var o=t.Dot(e,r)-n;return o/(o-(t.Dot(i,r)-n))},t.FromArray=function(e,i){return i||(i=0),new t(e[i],e[i+1],e[i+2])},t.FromFloatArray=function(e,i){return i||(i=0),new t(e[i],e[i+1],e[i+2])},t.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2]},t.FromFloatArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2]},t.FromFloatsToRef=function(e,t,i,r){r.x=e,r.y=t,r.z=i},t.Zero=function(){return new t(0,0,0)},t.Up=function(){return new t(0,1,0)},t.TransformCoordinates=function(e,i){var r=t.Zero();return t.TransformCoordinatesToRef(e,i,r),r},t.TransformCoordinatesToRef=function(e,t,i){var r=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8]+t.m[12],n=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9]+t.m[13],o=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10]+t.m[14],s=e.x*t.m[3]+e.y*t.m[7]+e.z*t.m[11]+t.m[15];i.x=r/s,i.y=n/s,i.z=o/s},t.TransformCoordinatesFromFloatsToRef=function(e,t,i,r,n){var o=e*r.m[0]+t*r.m[4]+i*r.m[8]+r.m[12],s=e*r.m[1]+t*r.m[5]+i*r.m[9]+r.m[13],a=e*r.m[2]+t*r.m[6]+i*r.m[10]+r.m[14],h=e*r.m[3]+t*r.m[7]+i*r.m[11]+r.m[15];n.x=o/h,n.y=s/h,n.z=a/h},t.TransformCoordinatesToRefSIMD=function(e,t,i){var r=SIMD.float32x4.loadXYZ(e._data,0),n=SIMD.float32x4.load(t.m,0),o=SIMD.float32x4.load(t.m,4),s=SIMD.float32x4.load(t.m,8),a=SIMD.float32x4.load(t.m,12),h=SIMD.float32x4.add(SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(r,0,0,0,0),n),SIMD.float32x4.mul(SIMD.float32x4.swizzle(r,1,1,1,1),o)),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(r,2,2,2,2),s),a));h=SIMD.float32x4.div(h,SIMD.float32x4.swizzle(h,3,3,3,3)),SIMD.float32x4.storeXYZ(i._data,0,h)},t.TransformCoordinatesFromFloatsToRefSIMD=function(e,t,i,r,n){var o=SIMD.float32x4.splat(e),s=SIMD.float32x4.splat(t),a=SIMD.float32x4.splat(i),h=SIMD.float32x4.load(r.m,0),c=SIMD.float32x4.load(r.m,4),l=SIMD.float32x4.load(r.m,8),u=SIMD.float32x4.load(r.m,12),d=SIMD.float32x4.add(SIMD.float32x4.add(SIMD.float32x4.mul(o,h),SIMD.float32x4.mul(s,c)),SIMD.float32x4.add(SIMD.float32x4.mul(a,l),u));d=SIMD.float32x4.div(d,SIMD.float32x4.swizzle(d,3,3,3,3)),SIMD.float32x4.storeXYZ(n._data,0,d)},t.TransformNormal=function(e,i){var r=t.Zero();return t.TransformNormalToRef(e,i,r),r},t.TransformNormalToRef=function(e,t,i){i.x=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8],i.y=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9],i.z=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10]},t.TransformNormalFromFloatsToRef=function(e,t,i,r,n){n.x=e*r.m[0]+t*r.m[4]+i*r.m[8],n.y=e*r.m[1]+t*r.m[5]+i*r.m[9],n.z=e*r.m[2]+t*r.m[6]+i*r.m[10]},t.CatmullRom=function(e,i,r,n,o){var s=o*o,a=o*s;return new t(.5*(2*i.x+(-e.x+r.x)*o+(2*e.x-5*i.x+4*r.x-n.x)*s+(-e.x+3*i.x-3*r.x+n.x)*a),.5*(2*i.y+(-e.y+r.y)*o+(2*e.y-5*i.y+4*r.y-n.y)*s+(-e.y+3*i.y-3*r.y+n.y)*a),.5*(2*i.z+(-e.z+r.z)*o+(2*e.z-5*i.z+4*r.z-n.z)*s+(-e.z+3*i.z-3*r.z+n.z)*a))},t.Clamp=function(e,i,r){var n=e.x;n=(n=n>r.x?r.x:n)<i.x?i.x:n;var o=e.y;o=(o=o>r.y?r.y:o)<i.y?i.y:o;var s=e.z;return new t(n,o,s=(s=s>r.z?r.z:s)<i.z?i.z:s)},t.Hermite=function(e,i,r,n,o){var s=o*o,a=o*s,h=2*a-3*s+1,c=-2*a+3*s,l=a-2*s+o,u=a-s;return new t(e.x*h+r.x*c+i.x*l+n.x*u,e.y*h+r.y*c+i.y*l+n.y*u,e.z*h+r.z*c+i.z*l+n.z*u)},t.Lerp=function(e,i,r){return new t(e.x+(i.x-e.x)*r,e.y+(i.y-e.y)*r,e.z+(i.z-e.z)*r)},t.Dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z},t.Cross=function(e,i){var r=t.Zero();return t.CrossToRef(e,i,r),r},t.CrossToRef=function(e,t,i){i.x=e.y*t.z-e.z*t.y,i.y=e.z*t.x-e.x*t.z,i.z=e.x*t.y-e.y*t.x},t.Normalize=function(e){var i=t.Zero();return t.NormalizeToRef(e,i),i},t.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},t.Project=function(e,i,r,n){var o=n.width,s=n.height,h=n.x,c=n.y,l=a.FromValues(o/2,0,0,0,0,-s/2,0,0,0,0,1,0,h+o/2,s/2+c,0,1),u=i.multiply(r).multiply(l);return t.TransformCoordinates(e,u)},t.UnprojectFromTransform=function(i,r,n,o,s){var a=o.multiply(s);a.invert(),i.x=i.x/r*2-1,i.y=-(i.y/n*2-1);var h=t.TransformCoordinates(i,a),c=i.x*a.m[3]+i.y*a.m[7]+i.z*a.m[11]+a.m[15];return e.Tools.WithinEpsilon(c,1)&&(h=h.scale(1/c)),h},t.Unproject=function(i,r,n,o,s,a){var h=o.multiply(s).multiply(a);h.invert();var c=new t(i.x/r*2-1,-(i.y/n*2-1),i.z),l=t.TransformCoordinates(c,h),u=c.x*h.m[3]+c.y*h.m[7]+c.z*h.m[11]+h.m[15];return e.Tools.WithinEpsilon(u,1)&&(l=l.scale(1/u)),l},t.Minimize=function(e,t){var i=e.clone();return i.MinimizeInPlace(t),i},t.Maximize=function(e,t){var i=e.clone();return i.MaximizeInPlace(t),i},t.Distance=function(e,i){return Math.sqrt(t.DistanceSquared(e,i))},t.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y,n=e.z-t.z;return i*i+r*r+n*n},t.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},t.RotationFromAxis=function(e,i,r){var n=t.Zero();return t.RotationFromAxisToRef(e,i,r,n),n},t.RotationFromAxisToRef=function(i,r,n,o){var s,a,h,c,l,u=t.Normalize(i),f=t.Normalize(n),p=d.X,m=d.Y,g=0,v=0,_=0,y=0,x=0,b=0,M=0,E=-1,T=0,w=0;e.Tools.WithinEpsilon(f.z,0,e.Engine.Epsilon)?b=1:e.Tools.WithinEpsilon(f.x,0,e.Engine.Epsilon)?y=1:(y=-(M=f.z/f.x)*Math.sqrt(1/(1+M*M)),b=Math.sqrt(1/(1+M*M))),(a=new t(y,x,b)).normalize(),(h=t.Cross(f,a)).normalize(),(s=t.Cross(u,a)).normalize(),t.Dot(f,s)<0&&(E=1),w=t.Dot(u,a),w=Math.min(1,Math.max(-1,w)),_=Math.acos(w)*E,t.Dot(a,p)<0&&(_=Math.PI+_,a=a.scaleInPlace(-1),h=h.scaleInPlace(-1),T++),y=0,x=0,b=0,E=-1,e.Tools.WithinEpsilon(f.z,0,e.Engine.Epsilon)?y=1:(y=-(M=a.z/a.x)*Math.sqrt(1/(1+M*M)),b=Math.sqrt(1/(1+M*M))),(c=new t(y,x,b)).normalize(),(l=t.Cross(c,a)).normalize(),(s=t.Cross(f,c)).normalize(),t.Dot(a,s)<0&&(E=1),w=t.Dot(f,c),w=Math.min(1,Math.max(-1,w)),v=Math.acos(w)*E,t.Dot(l,m)<0&&(v=Math.PI+v,l=l.scaleInPlace(-1),c=c.scaleInPlace(-1),T++),E=-1,(s=t.Cross(p,a)).normalize(),t.Dot(s,m)<0&&(E=1),w=t.Dot(a,p),w=Math.min(1,Math.max(-1,w)),g=-Math.acos(w)*E,0>w&&2>T&&(g=Math.PI+g),o.x=v,o.y=g,o.z=_},t}();e.Vector3=n;var o=function(){function t(e,t,i,r){this.x=e,this.y=t,this.z=i,this.w=r}return t.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"W:"+this.w+"}"},t.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},t.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,this},t.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)},t.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t.z=this.z+e.z,t.w=this.w+e.w,this},t.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this},t.prototype.subtract=function(e){return new t(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)},t.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t.z=this.z-e.z,t.w=this.w-e.w,this},t.prototype.subtractFromFloats=function(e,i,r,n){return new t(this.x-e,this.y-i,this.z-r,this.w-n)},t.prototype.subtractFromFloatsToRef=function(e,t,i,r,n){return n.x=this.x-e,n.y=this.y-t,n.z=this.z-i,n.w=this.w-r,this},t.prototype.negate=function(){return new t(-this.x,-this.y,-this.z,-this.w)},t.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},t.prototype.scale=function(e){return new t(this.x*e,this.y*e,this.z*e,this.w*e)},t.prototype.scaleToRef=function(e,t){t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,t.w=this.w*e},t.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},t.prototype.equalsWithEpsilon=function(t,i){return void 0===i&&(i=e.Engine.Epsilon),t&&e.Tools.WithinEpsilon(this.x,t.x,i)&&e.Tools.WithinEpsilon(this.y,t.y,i)&&e.Tools.WithinEpsilon(this.z,t.z,i)&&e.Tools.WithinEpsilon(this.w,t.w,i)},t.prototype.equalsToFloats=function(e,t,i,r){return this.x===e&&this.y===t&&this.z===i&&this.w===r},t.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this},t.prototype.multiply=function(e){return new t(this.x*e.x,this.y*e.y,this.z*e.z,this.w*e.w)},t.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,t.z=this.z*e.z,t.w=this.w*e.w,this},t.prototype.multiplyByFloats=function(e,i,r,n){return new t(this.x*e,this.y*i,this.z*r,this.w*n)},t.prototype.divide=function(e){return new t(this.x/e.x,this.y/e.y,this.z/e.z,this.w/e.w)},t.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,t.z=this.z/e.z,t.w=this.w/e.w,this},t.prototype.MinimizeInPlace=function(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),e.w<this.w&&(this.w=e.w),this},t.prototype.MaximizeInPlace=function(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),e.w>this.w&&(this.w=e.w),this},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},t.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},t.prototype.normalize=function(){var e=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},t.prototype.clone=function(){return new t(this.x,this.y,this.z,this.w)},t.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},t.prototype.copyFromFloats=function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},t.FromArray=function(e,i){return i||(i=0),new t(e[i],e[i+1],e[i+2],e[i+3])},t.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3]},t.FromFloatArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3]},t.FromFloatsToRef=function(e,t,i,r,n){n.x=e,n.y=t,n.z=i,n.w=r},t.Zero=function(){return new t(0,0,0,0)},t.Normalize=function(e){var i=t.Zero();return t.NormalizeToRef(e,i),i},t.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},t.Minimize=function(e,t){var i=e.clone();return i.MinimizeInPlace(t),i},t.Maximize=function(e,t){var i=e.clone();return i.MaximizeInPlace(t),i},t.Distance=function(e,i){return Math.sqrt(t.DistanceSquared(e,i))},t.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y,n=e.z-t.z,o=e.w-t.w;return i*i+r*r+n*n+o*o},t.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},t}();e.Vector4=o;var s=function(){function e(e,t,i,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),this.x=e,this.y=t,this.z=i,this.w=r}return e.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},e.prototype.asArray=function(){return[this.x,this.y,this.z,this.w]},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},e.prototype.clone=function(){return new e(this.x,this.y,this.z,this.w)},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},e.prototype.copyFromFloats=function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y,this.z+t.z,this.w+t.w)},e.prototype.subtract=function(t){return new e(this.x-t.x,this.y-t.y,this.z-t.z,this.w-t.w)},e.prototype.scale=function(t){return new e(this.x*t,this.y*t,this.z*t,this.w*t)},e.prototype.multiply=function(t){var i=new e(0,0,0,1);return this.multiplyToRef(t,i),i},e.prototype.multiplyToRef=function(e,t){var i=this.x*e.w+this.y*e.z-this.z*e.y+this.w*e.x,r=-this.x*e.z+this.y*e.w+this.z*e.x+this.w*e.y,n=this.x*e.y-this.y*e.x+this.z*e.w+this.w*e.z,o=-this.x*e.x-this.y*e.y-this.z*e.z+this.w*e.w;return t.copyFromFloats(i,r,n,o),this},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.prototype.normalize=function(){var e=1/this.length();return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},e.prototype.toEulerAngles=function(){var e=n.Zero();return this.toEulerAnglesToRef(e),e},e.prototype.toEulerAnglesToRef=function(e){var t=this.x,i=this.y,r=this.z,n=this.w,o=t*i,s=t*r,a=n*i,h=n*r,c=n*t,l=i*r,u=i*i,d=t*t+u;return 0!==d&&1!==d?(e.x=Math.atan2(s+a,c-l),e.y=Math.acos(1-2*d),e.z=Math.atan2(s-a,c+l)):0===d?(e.x=0,e.y=0,e.z=Math.atan2(o-h,.5-u-r*r)):(e.x=Math.atan2(o-h,.5-u-r*r),e.y=Math.PI,e.z=0),this},e.prototype.toRotationMatrix=function(e){var t=this.x*this.x,i=this.y*this.y,r=this.z*this.z,n=this.x*this.y,o=this.z*this.w,s=this.z*this.x,a=this.y*this.w,h=this.y*this.z,c=this.x*this.w;return e.m[0]=1-2*(i+r),e.m[1]=2*(n+o),e.m[2]=2*(s-a),e.m[3]=0,e.m[4]=2*(n-o),e.m[5]=1-2*(r+t),e.m[6]=2*(h+c),e.m[7]=0,e.m[8]=2*(s+a),e.m[9]=2*(h-c),e.m[10]=1-2*(i+t),e.m[11]=0,e.m[12]=0,e.m[13]=0,e.m[14]=0,e.m[15]=1,this},e.prototype.fromRotationMatrix=function(t){return e.FromRotationMatrixToRef(t,this),this},e.FromRotationMatrix=function(t){var i=new e;return e.FromRotationMatrixToRef(t,i),i},e.FromRotationMatrixToRef=function(e,t){var i,r=e.m,n=r[0],o=r[4],s=r[8],a=r[1],h=r[5],c=r[9],l=r[2],u=r[6],d=r[10],f=n+h+d;f>0?(i=.5/Math.sqrt(f+1),t.w=.25/i,t.x=(u-c)*i,t.y=(s-l)*i,t.z=(a-o)*i):n>h&&n>d?(i=2*Math.sqrt(1+n-h-d),t.w=(u-c)/i,t.x=.25*i,t.y=(o+a)/i,t.z=(s+l)/i):h>d?(i=2*Math.sqrt(1+h-n-d),t.w=(s-l)/i,t.x=(o+a)/i,t.y=.25*i,t.z=(c+u)/i):(i=2*Math.sqrt(1+d-n-h),t.w=(a-o)/i,t.x=(s+l)/i,t.y=(c+u)/i,t.z=.25*i)},e.Inverse=function(t){return new e(-t.x,-t.y,-t.z,t.w)},e.Identity=function(){return new e(0,0,0,1)},e.RotationAxis=function(t,i){var r=new e,n=Math.sin(i/2);return t.normalize(),r.w=Math.cos(i/2),r.x=t.x*n,r.y=t.y*n,r.z=t.z*n,r},e.FromArray=function(t,i){return i||(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.RotationYawPitchRoll=function(t,i,r){var n=new e;return e.RotationYawPitchRollToRef(t,i,r,n),n},e.RotationYawPitchRollToRef=function(e,t,i,r){var n=.5*i,o=.5*t,s=.5*e,a=Math.sin(n),h=Math.cos(n),c=Math.sin(o),l=Math.cos(o),u=Math.sin(s),d=Math.cos(s);r.x=d*c*h+u*l*a,r.y=u*l*h-d*c*a,r.z=d*l*a-u*c*h,r.w=d*l*h+u*c*a},e.RotationAlphaBetaGamma=function(t,i,r){var n=new e;return e.RotationAlphaBetaGammaToRef(t,i,r,n),n},e.RotationAlphaBetaGammaToRef=function(e,t,i,r){var n=.5*(i+e),o=.5*(i-e),s=.5*t;r.x=Math.cos(o)*Math.sin(s),r.y=Math.sin(o)*Math.sin(s),r.z=Math.sin(n)*Math.cos(s),r.w=Math.cos(n)*Math.cos(s)},e.Slerp=function(t,i,r){var n,o,s=r,a=t.x*i.x+t.y*i.y+t.z*i.z+t.w*i.w,h=!1;if(0>a&&(h=!0,a=-a),a>.999999)o=1-s,n=h?-s:s;else{var c=Math.acos(a),l=1/Math.sin(c);o=Math.sin((1-s)*c)*l,n=h?-Math.sin(s*c)*l:Math.sin(s*c)*l}return new e(o*t.x+n*i.x,o*t.y+n*i.y,o*t.z+n*i.z,o*t.w+n*i.w)},e}();e.Quaternion=s;var a=function(){function t(){this.m=new Float32Array(16)}return t.prototype.isIdentity=function(){return 1===this.m[0]&&1===this.m[5]&&1===this.m[10]&&1===this.m[15]&&(0===this.m[1]&&0===this.m[2]&&0===this.m[3]&&0===this.m[4]&&0===this.m[6]&&0===this.m[7]&&0===this.m[8]&&0===this.m[9]&&0===this.m[11]&&0===this.m[12]&&0===this.m[13]&&0===this.m[14])},t.prototype.determinant=function(){var e=this.m[10]*this.m[15]-this.m[11]*this.m[14],t=this.m[9]*this.m[15]-this.m[11]*this.m[13],i=this.m[9]*this.m[14]-this.m[10]*this.m[13],r=this.m[8]*this.m[15]-this.m[11]*this.m[12],n=this.m[8]*this.m[14]-this.m[10]*this.m[12],o=this.m[8]*this.m[13]-this.m[9]*this.m[12];return this.m[0]*(this.m[5]*e-this.m[6]*t+this.m[7]*i)-this.m[1]*(this.m[4]*e-this.m[6]*r+this.m[7]*n)+this.m[2]*(this.m[4]*t-this.m[5]*r+this.m[7]*o)-this.m[3]*(this.m[4]*i-this.m[5]*n+this.m[6]*o)},t.prototype.toArray=function(){return this.m},t.prototype.asArray=function(){return this.toArray()},t.prototype.invert=function(){return this.invertToRef(this),this},t.prototype.reset=function(){for(var e=0;16>e;e++)this.m[e]=0;return this},t.prototype.add=function(e){var i=new t;return this.addToRef(e,i),i},t.prototype.addToRef=function(e,t){for(var i=0;16>i;i++)t.m[i]=this.m[i]+e.m[i];return this},t.prototype.addToSelf=function(e){for(var t=0;16>t;t++)this.m[t]+=e.m[t];return this},t.prototype.invertToRef=function(e){var t=this.m[0],i=this.m[1],r=this.m[2],n=this.m[3],o=this.m[4],s=this.m[5],a=this.m[6],h=this.m[7],c=this.m[8],l=this.m[9],u=this.m[10],d=this.m[11],f=this.m[12],p=this.m[13],m=this.m[14],g=this.m[15],v=u*g-d*m,_=l*g-d*p,y=l*m-u*p,x=c*g-d*f,b=c*m-u*f,M=c*p-l*f,E=s*v-a*_+h*y,T=-(o*v-a*x+h*b),w=o*_-s*x+h*M,S=-(o*y-s*b+a*M),A=1/(t*E+i*T+r*w+n*S),P=a*g-h*m,C=s*g-h*p,D=s*m-a*p,R=o*g-h*f,I=o*m-a*f,L=o*p-s*f,O=a*d-h*u,B=s*d-h*l,F=s*u-a*l,N=o*d-h*c,V=o*u-a*c,U=o*l-s*c;return e.m[0]=E*A,e.m[4]=T*A,e.m[8]=w*A,e.m[12]=S*A,e.m[1]=-(i*v-r*_+n*y)*A,e.m[5]=(t*v-r*x+n*b)*A,e.m[9]=-(t*_-i*x+n*M)*A,e.m[13]=(t*y-i*b+r*M)*A,e.m[2]=(i*P-r*C+n*D)*A,e.m[6]=-(t*P-r*R+n*I)*A,e.m[10]=(t*C-i*R+n*L)*A,e.m[14]=-(t*D-i*I+r*L)*A,e.m[3]=-(i*O-r*B+n*F)*A,e.m[7]=(t*O-r*N+n*V)*A,e.m[11]=-(t*B-i*N+n*U)*A,e.m[15]=(t*F-i*V+r*U)*A,this},t.prototype.invertToRefSIMD=function(e){var t,i,r,n,o,s,a,h,c,l,u=this.m,d=e.m,f=SIMD.float32x4.load(u,0),p=SIMD.float32x4.load(u,4),m=SIMD.float32x4.load(u,8),g=SIMD.float32x4.load(u,12);return o=SIMD.float32x4.shuffle(f,p,0,1,4,5),i=SIMD.float32x4.shuffle(m,g,0,1,4,5),t=SIMD.float32x4.shuffle(o,i,0,2,4,6),i=SIMD.float32x4.shuffle(i,o,1,3,5,7),o=SIMD.float32x4.shuffle(f,p,2,3,6,7),n=SIMD.float32x4.shuffle(m,g,2,3,6,7),r=SIMD.float32x4.shuffle(o,n,0,2,4,6),n=SIMD.float32x4.shuffle(n,o,1,3,5,7),o=SIMD.float32x4.mul(r,n),o=SIMD.float32x4.swizzle(o,1,0,3,2),s=SIMD.float32x4.mul(i,o),a=SIMD.float32x4.mul(t,o),o=SIMD.float32x4.swizzle(o,2,3,0,1),s=SIMD.float32x4.sub(SIMD.float32x4.mul(i,o),s),a=SIMD.float32x4.sub(SIMD.float32x4.mul(t,o),a),a=SIMD.float32x4.swizzle(a,2,3,0,1),o=SIMD.float32x4.mul(i,r),o=SIMD.float32x4.swizzle(o,1,0,3,2),s=SIMD.float32x4.add(SIMD.float32x4.mul(n,o),s),c=SIMD.float32x4.mul(t,o),o=SIMD.float32x4.swizzle(o,2,3,0,1),s=SIMD.float32x4.sub(s,SIMD.float32x4.mul(n,o)),c=SIMD.float32x4.sub(SIMD.float32x4.mul(t,o),c),c=SIMD.float32x4.swizzle(c,2,3,0,1),o=SIMD.float32x4.mul(SIMD.float32x4.swizzle(i,2,3,0,1),n),o=SIMD.float32x4.swizzle(o,1,0,3,2),r=SIMD.float32x4.swizzle(r,2,3,0,1),s=SIMD.float32x4.add(SIMD.float32x4.mul(r,o),s),h=SIMD.float32x4.mul(t,o),o=SIMD.float32x4.swizzle(o,2,3,0,1),s=SIMD.float32x4.sub(s,SIMD.float32x4.mul(r,o)),h=SIMD.float32x4.sub(SIMD.float32x4.mul(t,o),h),h=SIMD.float32x4.swizzle(h,2,3,0,1),o=SIMD.float32x4.mul(t,i),o=SIMD.float32x4.swizzle(o,1,0,3,2),h=SIMD.float32x4.add(SIMD.float32x4.mul(n,o),h),c=SIMD.float32x4.sub(SIMD.float32x4.mul(r,o),c),o=SIMD.float32x4.swizzle(o,2,3,0,1),h=SIMD.float32x4.sub(SIMD.float32x4.mul(n,o),h),c=SIMD.float32x4.sub(c,SIMD.float32x4.mul(r,o)),o=SIMD.float32x4.mul(t,n),o=SIMD.float32x4.swizzle(o,1,0,3,2),a=SIMD.float32x4.sub(a,SIMD.float32x4.mul(r,o)),h=SIMD.float32x4.add(SIMD.float32x4.mul(i,o),h),o=SIMD.float32x4.swizzle(o,2,3,0,1),a=SIMD.float32x4.add(SIMD.float32x4.mul(r,o),a),h=SIMD.float32x4.sub(h,SIMD.float32x4.mul(i,o)),o=SIMD.float32x4.mul(t,r),o=SIMD.float32x4.swizzle(o,1,0,3,2),a=SIMD.float32x4.add(SIMD.float32x4.mul(n,o),a),c=SIMD.float32x4.sub(c,SIMD.float32x4.mul(i,o)),o=SIMD.float32x4.swizzle(o,2,3,0,1),a=SIMD.float32x4.sub(a,SIMD.float32x4.mul(n,o)),c=SIMD.float32x4.add(SIMD.float32x4.mul(i,o),c),l=SIMD.float32x4.mul(t,s),l=SIMD.float32x4.add(SIMD.float32x4.swizzle(l,2,3,0,1),l),l=SIMD.float32x4.add(SIMD.float32x4.swizzle(l,1,0,3,2),l),o=SIMD.float32x4.reciprocalApproximation(l),l=SIMD.float32x4.sub(SIMD.float32x4.add(o,o),SIMD.float32x4.mul(l,SIMD.float32x4.mul(o,o))),l=SIMD.float32x4.swizzle(l,0,0,0,0),s=SIMD.float32x4.mul(l,s),a=SIMD.float32x4.mul(l,a),h=SIMD.float32x4.mul(l,h),c=SIMD.float32x4.mul(l,c),SIMD.float32x4.store(d,0,s),SIMD.float32x4.store(d,4,a),SIMD.float32x4.store(d,8,h),SIMD.float32x4.store(d,12,c),this},t.prototype.setTranslation=function(e){return this.m[12]=e.x,this.m[13]=e.y,this.m[14]=e.z,this},t.prototype.multiply=function(e){var i=new t;return this.multiplyToRef(e,i),i},t.prototype.copyFrom=function(e){for(var t=0;16>t;t++)this.m[t]=e.m[t];return this},t.prototype.copyToArray=function(e,t){void 0===t&&(t=0);for(var i=0;16>i;i++)e[t+i]=this.m[i];return this},t.prototype.multiplyToRef=function(e,t){return this.multiplyToArray(e,t.m,0),this},t.prototype.multiplyToArray=function(e,t,i){var r=this.m[0],n=this.m[1],o=this.m[2],s=this.m[3],a=this.m[4],h=this.m[5],c=this.m[6],l=this.m[7],u=this.m[8],d=this.m[9],f=this.m[10],p=this.m[11],m=this.m[12],g=this.m[13],v=this.m[14],_=this.m[15],y=e.m[0],x=e.m[1],b=e.m[2],M=e.m[3],E=e.m[4],T=e.m[5],w=e.m[6],S=e.m[7],A=e.m[8],P=e.m[9],C=e.m[10],D=e.m[11],R=e.m[12],I=e.m[13],L=e.m[14],O=e.m[15];return t[i]=r*y+n*E+o*A+s*R,t[i+1]=r*x+n*T+o*P+s*I,t[i+2]=r*b+n*w+o*C+s*L,t[i+3]=r*M+n*S+o*D+s*O,t[i+4]=a*y+h*E+c*A+l*R,t[i+5]=a*x+h*T+c*P+l*I,t[i+6]=a*b+h*w+c*C+l*L,t[i+7]=a*M+h*S+c*D+l*O,t[i+8]=u*y+d*E+f*A+p*R,t[i+9]=u*x+d*T+f*P+p*I,t[i+10]=u*b+d*w+f*C+p*L,t[i+11]=u*M+d*S+f*D+p*O,t[i+12]=m*y+g*E+v*A+_*R,t[i+13]=m*x+g*T+v*P+_*I,t[i+14]=m*b+g*w+v*C+_*L,t[i+15]=m*M+g*S+v*D+_*O,this},t.prototype.multiplyToArraySIMD=function(e,t,i){void 0===i&&(i=0);var r=this.m,n=e.m,o=SIMD.float32x4.load(n,0),s=SIMD.float32x4.load(n,4),a=SIMD.float32x4.load(n,8),h=SIMD.float32x4.load(n,12),c=SIMD.float32x4.load(r,0);SIMD.float32x4.store(t,i+0,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(c,0,0,0,0),o),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(c,1,1,1,1),s),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(c,2,2,2,2),a),SIMD.float32x4.mul(SIMD.float32x4.swizzle(c,3,3,3,3),h)))));var l=SIMD.float32x4.load(r,4);SIMD.float32x4.store(t,i+4,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(l,0,0,0,0),o),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(l,1,1,1,1),s),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(l,2,2,2,2),a),SIMD.float32x4.mul(SIMD.float32x4.swizzle(l,3,3,3,3),h)))));var u=SIMD.float32x4.load(r,8);SIMD.float32x4.store(t,i+8,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(u,0,0,0,0),o),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(u,1,1,1,1),s),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(u,2,2,2,2),a),SIMD.float32x4.mul(SIMD.float32x4.swizzle(u,3,3,3,3),h)))));var d=SIMD.float32x4.load(r,12);SIMD.float32x4.store(t,i+12,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(d,0,0,0,0),o),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(d,1,1,1,1),s),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(d,2,2,2,2),a),SIMD.float32x4.mul(SIMD.float32x4.swizzle(d,3,3,3,3),h)))))},t.prototype.equals=function(e){return e&&this.m[0]===e.m[0]&&this.m[1]===e.m[1]&&this.m[2]===e.m[2]&&this.m[3]===e.m[3]&&this.m[4]===e.m[4]&&this.m[5]===e.m[5]&&this.m[6]===e.m[6]&&this.m[7]===e.m[7]&&this.m[8]===e.m[8]&&this.m[9]===e.m[9]&&this.m[10]===e.m[10]&&this.m[11]===e.m[11]&&this.m[12]===e.m[12]&&this.m[13]===e.m[13]&&this.m[14]===e.m[14]&&this.m[15]===e.m[15]},t.prototype.clone=function(){return t.FromValues(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5],this.m[6],this.m[7],this.m[8],this.m[9],this.m[10],this.m[11],this.m[12],this.m[13],this.m[14],this.m[15])},t.prototype.decompose=function(i,r,n){n.x=this.m[12],n.y=this.m[13],n.z=this.m[14];var o=e.Tools.Sign(this.m[0]*this.m[1]*this.m[2]*this.m[3])<0?-1:1,a=e.Tools.Sign(this.m[4]*this.m[5]*this.m[6]*this.m[7])<0?-1:1,h=e.Tools.Sign(this.m[8]*this.m[9]*this.m[10]*this.m[11])<0?-1:1;if(i.x=o*Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]+this.m[2]*this.m[2]),i.y=a*Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]+this.m[6]*this.m[6]),i.z=h*Math.sqrt(this.m[8]*this.m[8]+this.m[9]*this.m[9]+this.m[10]*this.m[10]),0===i.x||0===i.y||0===i.z)return r.x=0,r.y=0,r.z=0,r.w=1,!1;var c=t.FromValues(this.m[0]/i.x,this.m[1]/i.x,this.m[2]/i.x,0,this.m[4]/i.y,this.m[5]/i.y,this.m[6]/i.y,0,this.m[8]/i.z,this.m[9]/i.z,this.m[10]/i.z,0,0,0,0,1);return s.FromRotationMatrixToRef(c,r),!0},t.FromArray=function(e,i){var r=new t;return i||(i=0),t.FromArrayToRef(e,i,r),r},t.FromArrayToRef=function(e,t,i){for(var r=0;16>r;r++)i.m[r]=e[r+t]},t.FromFloat32ArrayToRefScaled=function(e,t,i,r){for(var n=0;16>n;n++)r.m[n]=e[n+t]*i},t.FromValuesToRef=function(e,t,i,r,n,o,s,a,h,c,l,u,d,f,p,m,g){g.m[0]=e,g.m[1]=t,g.m[2]=i,g.m[3]=r,g.m[4]=n,g.m[5]=o,g.m[6]=s,g.m[7]=a,g.m[8]=h,g.m[9]=c,g.m[10]=l,g.m[11]=u,g.m[12]=d,g.m[13]=f,g.m[14]=p,g.m[15]=m},t.FromValues=function(e,i,r,n,o,s,a,h,c,l,u,d,f,p,m,g){var v=new t;return v.m[0]=e,v.m[1]=i,v.m[2]=r,v.m[3]=n,v.m[4]=o,v.m[5]=s,v.m[6]=a,v.m[7]=h,v.m[8]=c,v.m[9]=l,v.m[10]=u,v.m[11]=d,v.m[12]=f,v.m[13]=p,v.m[14]=m,v.m[15]=g,v},t.Compose=function(e,i,r){var n=t.FromValues(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1),o=t.Identity();return i.toRotationMatrix(o),(n=n.multiply(o)).setTranslation(r),n},t.Identity=function(){return t.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},t.IdentityToRef=function(e){t.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,e)},t.Zero=function(){return t.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},t.RotationX=function(e){var i=new t;return t.RotationXToRef(e,i),i},t.Invert=function(e){var i=new t;return e.invertToRef(i),i},t.RotationXToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.m[0]=1,t.m[15]=1,t.m[5]=r,t.m[10]=r,t.m[9]=-i,t.m[6]=i,t.m[1]=0,t.m[2]=0,t.m[3]=0,t.m[4]=0,t.m[7]=0,t.m[8]=0,t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0},t.RotationY=function(e){var i=new t;return t.RotationYToRef(e,i),i},t.RotationYToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.m[5]=1,t.m[15]=1,t.m[0]=r,t.m[2]=-i,t.m[8]=i,t.m[10]=r,t.m[1]=0,t.m[3]=0,t.m[4]=0,t.m[6]=0,t.m[7]=0,t.m[9]=0,t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0},t.RotationZ=function(e){var i=new t;return t.RotationZToRef(e,i),i},t.RotationZToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.m[10]=1,t.m[15]=1,t.m[0]=r,t.m[1]=i,t.m[4]=-i,t.m[5]=r,t.m[2]=0,t.m[3]=0,t.m[6]=0,t.m[7]=0,t.m[8]=0,t.m[9]=0,t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0},t.RotationAxis=function(e,i){var r=t.Zero();return t.RotationAxisToRef(e,i,r),r},t.RotationAxisToRef=function(e,t,i){var r=Math.sin(-t),n=Math.cos(-t),o=1-n;e.normalize(),i.m[0]=e.x*e.x*o+n,i.m[1]=e.x*e.y*o-e.z*r,i.m[2]=e.x*e.z*o+e.y*r,i.m[3]=0,i.m[4]=e.y*e.x*o+e.z*r,i.m[5]=e.y*e.y*o+n,i.m[6]=e.y*e.z*o-e.x*r,i.m[7]=0,i.m[8]=e.z*e.x*o-e.y*r,i.m[9]=e.z*e.y*o+e.x*r,i.m[10]=e.z*e.z*o+n,i.m[11]=0,i.m[15]=1},t.RotationYawPitchRoll=function(e,i,r){var n=new t;return t.RotationYawPitchRollToRef(e,i,r,n),n},t.RotationYawPitchRollToRef=function(e,t,i,r){s.RotationYawPitchRollToRef(e,t,i,this._tempQuaternion),this._tempQuaternion.toRotationMatrix(r)},t.Scaling=function(e,i,r){var n=t.Zero();return t.ScalingToRef(e,i,r,n),n},t.ScalingToRef=function(e,t,i,r){r.m[0]=e,r.m[1]=0,r.m[2]=0,r.m[3]=0,r.m[4]=0,r.m[5]=t,r.m[6]=0,r.m[7]=0,r.m[8]=0,r.m[9]=0,r.m[10]=i,r.m[11]=0,r.m[12]=0,r.m[13]=0,r.m[14]=0,r.m[15]=1},t.Translation=function(e,i,r){var n=t.Identity();return t.TranslationToRef(e,i,r,n),n},t.TranslationToRef=function(e,i,r,n){t.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,i,r,1,n)},t.LookAtLH=function(e,i,r){var n=t.Zero();return t.LookAtLHToRef(e,i,r,n),n},t.LookAtLHToRef=function(e,i,r,o){i.subtractToRef(e,this._zAxis),this._zAxis.normalize(),n.CrossToRef(r,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),n.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var s=-n.Dot(this._xAxis,e),a=-n.Dot(this._yAxis,e),h=-n.Dot(this._zAxis,e);return t.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,s,a,h,1,o)},t.LookAtLHToRefSIMD=function(e,t,i,r){var n=r.m,o=SIMD.float32x4(t.x,t.y,t.z,0),s=SIMD.float32x4(e.x,e.y,e.z,0),a=SIMD.float32x4(i.x,i.y,i.z,0),h=SIMD.float32x4.sub(o,s),c=SIMD.float32x4.mul(h,h);c=SIMD.float32x4.add(c,SIMD.float32x4.add(SIMD.float32x4.swizzle(c,1,2,0,3),SIMD.float32x4.swizzle(c,2,0,1,3))),h=SIMD.float32x4.mul(h,SIMD.float32x4.reciprocalSqrtApproximation(c)),c=SIMD.float32x4.mul(a,a),c=SIMD.float32x4.add(c,SIMD.float32x4.add(SIMD.float32x4.swizzle(c,1,2,0,3),SIMD.float32x4.swizzle(c,2,0,1,3))),a=SIMD.float32x4.mul(a,SIMD.float32x4.reciprocalSqrtApproximation(c));var l=SIMD.float32x4.sub(SIMD.float32x4.mul(SIMD.float32x4.swizzle(h,1,2,0,3),SIMD.float32x4.swizzle(a,2,0,1,3)),SIMD.float32x4.mul(SIMD.float32x4.swizzle(h,2,0,1,3),SIMD.float32x4.swizzle(a,1,2,0,3)));c=SIMD.float32x4.mul(l,l),c=SIMD.float32x4.add(c,SIMD.float32x4.add(SIMD.float32x4.swizzle(c,1,2,0,3),SIMD.float32x4.swizzle(c,2,0,1,3))),l=SIMD.float32x4.mul(l,SIMD.float32x4.reciprocalSqrtApproximation(c));var u=SIMD.float32x4.sub(SIMD.float32x4.mul(SIMD.float32x4.swizzle(l,1,2,0,3),SIMD.float32x4.swizzle(h,2,0,1,3)),SIMD.float32x4.mul(SIMD.float32x4.swizzle(l,2,0,1,3),SIMD.float32x4.swizzle(h,1,2,0,3)));c=SIMD.float32x4.mul(l,l),c=SIMD.float32x4.add(c,SIMD.float32x4.add(SIMD.float32x4.swizzle(c,1,2,0,3),SIMD.float32x4.swizzle(c,2,0,1,3))),l=SIMD.float32x4.mul(l,SIMD.float32x4.reciprocalSqrtApproximation(c));var d=SIMD.float32x4.splat(0);l=SIMD.float32x4.neg(l);var f=SIMD.float32x4.shuffle(l,u,0,1,4,5),p=SIMD.float32x4.shuffle(h,d,0,1,4,5),m=SIMD.float32x4.shuffle(f,p,0,2,4,6),g=SIMD.float32x4.shuffle(f,p,1,3,5,7);f=SIMD.float32x4.shuffle(l,u,2,3,6,7),p=SIMD.float32x4.shuffle(h,d,2,3,6,7);var v=SIMD.float32x4.shuffle(f,p,0,2,4,6),_=SIMD.float32x4(0,0,0,1),y=SIMD.float32x4(1,0,0,0),x=SIMD.float32x4(0,1,0,0),b=SIMD.float32x4(0,0,1,0),M=SIMD.float32x4.neg(s);M=SIMD.float32x4.withW(M,1),SIMD.float32x4.store(n,0,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(y,0,0,0,0),m),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(y,1,1,1,1),g),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(y,2,2,2,2),v),SIMD.float32x4.mul(SIMD.float32x4.swizzle(y,3,3,3,3),_))))),SIMD.float32x4.store(n,4,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(x,0,0,0,0),m),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(x,1,1,1,1),g),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(x,2,2,2,2),v),SIMD.float32x4.mul(SIMD.float32x4.swizzle(x,3,3,3,3),_))))),SIMD.float32x4.store(n,8,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(b,0,0,0,0),m),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(b,1,1,1,1),g),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(b,2,2,2,2),v),SIMD.float32x4.mul(SIMD.float32x4.swizzle(b,3,3,3,3),_))))),SIMD.float32x4.store(n,12,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(M,0,0,0,0),m),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(M,1,1,1,1),g),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(M,2,2,2,2),v),SIMD.float32x4.mul(SIMD.float32x4.swizzle(M,3,3,3,3),_)))))},t.OrthoLH=function(e,i,r,n){var o=t.Zero();return t.OrthoLHToRef(e,i,r,n,o),o},t.OrthoLHToRef=function(e,i,r,n,o){var s=2/e,a=2/i,h=1/(n-r),c=r/(r-n);t.FromValuesToRef(s,0,0,0,0,a,0,0,0,0,h,0,0,0,c,1,o)},t.OrthoOffCenterLH=function(e,i,r,n,o,s){var a=t.Zero();return t.OrthoOffCenterLHToRef(e,i,r,n,o,s,a),a},t.OrthoOffCenterLHToRef=function(e,t,i,r,n,o,s){s.m[0]=2/(t-e),s.m[1]=s.m[2]=s.m[3]=0,s.m[5]=2/(r-i),s.m[4]=s.m[6]=s.m[7]=0,s.m[10]=-1/(n-o),s.m[8]=s.m[9]=s.m[11]=0,s.m[12]=(e+t)/(e-t),s.m[13]=(r+i)/(i-r),s.m[14]=n/(n-o),s.m[15]=1},t.PerspectiveLH=function(e,i,r,n){var o=t.Zero();return o.m[0]=2*r/e,o.m[1]=o.m[2]=o.m[3]=0,o.m[5]=2*r/i,o.m[4]=o.m[6]=o.m[7]=0,o.m[10]=-n/(r-n),o.m[8]=o.m[9]=0,o.m[11]=1,o.m[12]=o.m[13]=o.m[15]=0,o.m[14]=r*n/(r-n),o},t.PerspectiveFovLH=function(e,i,r,n){var o=t.Zero();return t.PerspectiveFovLHToRef(e,i,r,n,o),o},t.PerspectiveFovLHToRef=function(t,i,r,n,o,s){void 0===s&&(s=e.Camera.FOVMODE_VERTICAL_FIXED);var a=1/Math.tan(.5*t),h=s===e.Camera.FOVMODE_VERTICAL_FIXED;o.m[0]=h?a/i:a,o.m[1]=o.m[2]=o.m[3]=0,o.m[5]=h?a:a*i,o.m[4]=o.m[6]=o.m[7]=0,o.m[8]=o.m[9]=0,o.m[10]=-n/(r-n),o.m[11]=1,o.m[12]=o.m[13]=o.m[15]=0,o.m[14]=r*n/(r-n)},t.GetFinalMatrix=function(e,i,r,n,o,s){var a=e.width,h=e.height,c=e.x,l=e.y,u=t.FromValues(a/2,0,0,0,0,-h/2,0,0,0,0,s-o,0,c+a/2,h/2+l,o,1);return i.multiply(r).multiply(n).multiply(u)},t.GetAsMatrix2x2=function(e){return new Float32Array([e.m[0],e.m[1],e.m[4],e.m[5]])},t.GetAsMatrix3x3=function(e){return new Float32Array([e.m[0],e.m[1],e.m[2],e.m[4],e.m[5],e.m[6],e.m[8],e.m[9],e.m[10]])},t.Transpose=function(e){var i=new t;return i.m[0]=e.m[0],i.m[1]=e.m[4],i.m[2]=e.m[8],i.m[3]=e.m[12],i.m[4]=e.m[1],i.m[5]=e.m[5],i.m[6]=e.m[9],i.m[7]=e.m[13],i.m[8]=e.m[2],i.m[9]=e.m[6],i.m[10]=e.m[10],i.m[11]=e.m[14],i.m[12]=e.m[3],i.m[13]=e.m[7],i.m[14]=e.m[11],i.m[15]=e.m[15],i},t.Reflection=function(e){var i=new t;return t.ReflectionToRef(e,i),i},t.ReflectionToRef=function(e,t){e.normalize();var i=e.normal.x,r=e.normal.y,n=e.normal.z,o=-2*i,s=-2*r,a=-2*n;t.m[0]=o*i+1,t.m[1]=s*i,t.m[2]=a*i,t.m[3]=0,t.m[4]=o*r,t.m[5]=s*r+1,t.m[6]=a*r,t.m[7]=0,t.m[8]=o*n,t.m[9]=s*n,t.m[10]=a*n+1,t.m[11]=0,t.m[12]=o*e.d,t.m[13]=s*e.d,t.m[14]=a*e.d,t.m[15]=1},t._tempQuaternion=new s,t._xAxis=n.Zero(),t._yAxis=n.Zero(),t._zAxis=n.Zero(),t}();e.Matrix=a;var h=function(){function e(e,t,i,r){this.normal=new n(e,t,i),this.d=r}return e.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},e.prototype.clone=function(){return new e(this.normal.x,this.normal.y,this.normal.z,this.d)},e.prototype.normalize=function(){var e=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z),t=0;return 0!==e&&(t=1/e),this.normal.x*=t,this.normal.y*=t,this.normal.z*=t,this.d*=t,this},e.prototype.transform=function(t){var i=a.Transpose(t),r=this.normal.x,n=this.normal.y,o=this.normal.z,s=this.d;return new e(r*i.m[0]+n*i.m[1]+o*i.m[2]+s*i.m[3],r*i.m[4]+n*i.m[5]+o*i.m[6]+s*i.m[7],r*i.m[8]+n*i.m[9]+o*i.m[10]+s*i.m[11],r*i.m[12]+n*i.m[13]+o*i.m[14]+s*i.m[15])},e.prototype.dotCoordinate=function(e){return this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z+this.d},e.prototype.copyFromPoints=function(e,t,i){var r,n=t.x-e.x,o=t.y-e.y,s=t.z-e.z,a=i.x-e.x,h=i.y-e.y,c=i.z-e.z,l=o*c-s*h,u=s*a-n*c,d=n*h-o*a,f=Math.sqrt(l*l+u*u+d*d);return r=0!==f?1/f:0,this.normal.x=l*r,this.normal.y=u*r,this.normal.z=d*r,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this},e.prototype.isFrontFacingTo=function(e,t){return t>=n.Dot(this.normal,e)},e.prototype.signedDistanceTo=function(e){return n.Dot(e,this.normal)+this.d},e.FromArray=function(t){return new e(t[0],t[1],t[2],t[3])},e.FromPoints=function(t,i,r){var n=new e(0,0,0,0);return n.copyFromPoints(t,i,r),n},e.FromPositionAndNormal=function(t,i){var r=new e(0,0,0,0);return i.normalize(),r.normal=i,r.d=-(i.x*t.x+i.y*t.y+i.z*t.z),r},e.SignedDistanceToPlaneFromPositionAndNormal=function(e,t,i){var r=-(t.x*e.x+t.y*e.y+t.z*e.z);return n.Dot(i,t)+r},e}();e.Plane=h;var c=function(){function e(e,t,i,r){this.x=e,this.y=t,this.width=i,this.height=r}return e.prototype.toGlobal=function(t){var i=t.getRenderWidth(),r=t.getRenderHeight();return new e(this.x*i,this.y*r,this.width*i,this.height*r)},e}();e.Viewport=c;var l=function(){function e(){}return e.GetPlanes=function(t){for(var i=[],r=0;6>r;r++)i.push(new h(0,0,0,0));return e.GetPlanesToRef(t,i),i},e.GetPlanesToRef=function(e,t){t[0].normal.x=e.m[3]+e.m[2],t[0].normal.y=e.m[7]+e.m[6],t[0].normal.z=e.m[11]+e.m[10],t[0].d=e.m[15]+e.m[14],t[0].normalize(),t[1].normal.x=e.m[3]-e.m[2],t[1].normal.y=e.m[7]-e.m[6],t[1].normal.z=e.m[11]-e.m[10],t[1].d=e.m[15]-e.m[14],t[1].normalize(),t[2].normal.x=e.m[3]+e.m[0],t[2].normal.y=e.m[7]+e.m[4],t[2].normal.z=e.m[11]+e.m[8],t[2].d=e.m[15]+e.m[12],t[2].normalize(),t[3].normal.x=e.m[3]-e.m[0],t[3].normal.y=e.m[7]-e.m[4],t[3].normal.z=e.m[11]-e.m[8],t[3].d=e.m[15]-e.m[12],t[3].normalize(),t[4].normal.x=e.m[3]-e.m[1],t[4].normal.y=e.m[7]-e.m[5],t[4].normal.z=e.m[11]-e.m[9],t[4].d=e.m[15]-e.m[13],t[4].normalize(),t[5].normal.x=e.m[3]+e.m[1],t[5].normal.y=e.m[7]+e.m[5],t[5].normal.z=e.m[11]+e.m[9],t[5].d=e.m[15]+e.m[13],t[5].normalize()},e}();e.Frustum=l;var u=function(){function t(e,t,i){void 0===i&&(i=Number.MAX_VALUE),this.origin=e,this.direction=t,this.length=i}return t.prototype.intersectsBoxMinMax=function(e,t){var i,r,n,o,s=0,a=Number.MAX_VALUE;if(Math.abs(this.direction.x)<1e-7){if(this.origin.x<e.x||this.origin.x>t.x)return!1}else if(i=1/this.direction.x,r=(e.x-this.origin.x)*i,(n=(t.x-this.origin.x)*i)===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),(s=Math.max(r,s))>(a=Math.min(n,a)))return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.y<e.y||this.origin.y>t.y)return!1}else if(i=1/this.direction.y,r=(e.y-this.origin.y)*i,(n=(t.y-this.origin.y)*i)===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),(s=Math.max(r,s))>(a=Math.min(n,a)))return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.z<e.z||this.origin.z>t.z)return!1}else if(i=1/this.direction.z,r=(e.z-this.origin.z)*i,(n=(t.z-this.origin.z)*i)===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),(s=Math.max(r,s))>(a=Math.min(n,a)))return!1;return!0},t.prototype.intersectsBox=function(e){return this.intersectsBoxMinMax(e.minimum,e.maximum)},t.prototype.intersectsSphere=function(e){var t=e.center.x-this.origin.x,i=e.center.y-this.origin.y,r=e.center.z-this.origin.z,n=t*t+i*i+r*r,o=e.radius*e.radius;if(o>=n)return!0;var s=t*this.direction.x+i*this.direction.y+r*this.direction.z;return!(0>s)&&o>=n-s*s},t.prototype.intersectsTriangle=function(t,i,r){this._edge1||(this._edge1=n.Zero(),this._edge2=n.Zero(),this._pvec=n.Zero(),this._tvec=n.Zero(),this._qvec=n.Zero()),i.subtractToRef(t,this._edge1),r.subtractToRef(t,this._edge2),n.CrossToRef(this.direction,this._edge2,this._pvec);var o=n.Dot(this._edge1,this._pvec);if(0===o)return null;var s=1/o;this.origin.subtractToRef(t,this._tvec);var a=n.Dot(this._tvec,this._pvec)*s;if(0>a||a>1)return null;n.CrossToRef(this._tvec,this._edge1,this._qvec);var h=n.Dot(this.direction,this._qvec)*s;if(0>h||a+h>1)return null;var c=n.Dot(this._edge2,this._qvec)*s;return c>this.length?null:new e.IntersectionInfo(a,h,c)},t.CreateNew=function(e,i,r,o,s,a,h){var c=n.Unproject(new n(e,i,0),r,o,s,a,h),l=n.Unproject(new n(e,i,1),r,o,s,a,h).subtract(c);return l.normalize(),new t(c,l)},t.CreateNewFromTo=function(e,i,r){void 0===r&&(r=a.Identity());var n=i.subtract(e),o=Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z);return n.normalize(),t.Transform(new t(e,n,o),r)},t.Transform=function(e,i){return new t(n.TransformCoordinates(e.origin,i),n.TransformNormal(e.direction,i),e.length)},t}();e.Ray=u,function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD"}(e.Space||(e.Space={}));var d=(e.Space,function(){function e(){}return e.X=new n(1,0,0),e.Y=new n(0,1,0),e.Z=new n(0,0,1),e}());e.Axis=d;var f=function(){function e(){}return e.interpolate=function(e,t,i,r,n){for(var o=1-3*r+3*t,s=3*r-6*t,a=3*t,h=e,c=0;5>c;c++){var l=h*h;h-=(o*(l*h)+s*l+a*h-e)*(1/(3*o*l+2*s*h+a)),h=Math.min(1,Math.max(0,h))}return 3*Math.pow(1-h,2)*h*i+3*(1-h)*Math.pow(h,2)*n+Math.pow(h,3)},e}();e.BezierCurve=f,function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"}(e.Orientation||(e.Orientation={}));var p=e.Orientation,m=function(){function e(e){var t=this;this.degrees=function(){return 180*t._radians/Math.PI},this.radians=function(){return t._radians},this._radians=e,this._radians<0&&(this._radians+=2*Math.PI)}return e.BetweenTwoPoints=function(t,i){var r=i.subtract(t);return new e(Math.atan2(r.y,r.x))},e.FromRadians=function(t){return new e(t)},e.FromDegrees=function(t){return new e(t*Math.PI/180)},e}();e.Angle=m;var g=function(){return function(e,t,i){this.startPoint=e,this.midPoint=t,this.endPoint=i;var n=Math.pow(t.x,2)+Math.pow(t.y,2),o=(Math.pow(e.x,2)+Math.pow(e.y,2)-n)/2,s=(n-Math.pow(i.x,2)-Math.pow(i.y,2))/2,a=(e.x-t.x)*(t.y-i.y)-(t.x-i.x)*(e.y-t.y);this.centerPoint=new r((o*(t.y-i.y)-s*(e.y-t.y))/a,((e.x-t.x)*s-(t.x-i.x)*o)/a),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=m.BetweenTwoPoints(this.centerPoint,this.startPoint);var h=this.startAngle.degrees(),c=m.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),l=m.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();c-h>180&&(c-=360),-180>c-h&&(c+=360),l-c>180&&(l-=360),-180>l-c&&(l+=360),this.orientation=0>c-h?p.CW:p.CCW,this.angle=m.FromDegrees(this.orientation===p.CW?h-l:l-h)}}();e.Arc2=g;var v=function(){function e(e){this.path=e,this._onchange=new Array,this.value=0,this.animations=new Array}return e.prototype.getPoint=function(){var e=this.path.getPointAtLengthPosition(this.value);return new n(e.x,0,e.y)},e.prototype.moveAhead=function(e){return void 0===e&&(e=.002),this.move(e),this},e.prototype.moveBack=function(e){return void 0===e&&(e=.002),this.move(-e),this},e.prototype.move=function(e){if(Math.abs(e)>1)throw"step size should be less than 1.";return this.value+=e,this.ensureLimits(),this.raiseOnChange(),this},e.prototype.ensureLimits=function(){for(;this.value>1;)this.value-=1;for(;this.value<0;)this.value+=1;return this},e.prototype.markAsDirty=function(e){return this.ensureLimits(),this.raiseOnChange(),this},e.prototype.raiseOnChange=function(){var e=this;return this._onchange.forEach(function(t){return t(e)}),this},e.prototype.onchange=function(e){return this._onchange.push(e),this},e}();e.PathCursor=v;var _=function(){function t(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new r(e,t))}return t.prototype.addLineTo=function(t,i){if(closed)return e.Tools.Error("cannot add lines to closed paths"),this;var n=new r(t,i),o=this._points[this._points.length-1];return this._points.push(n),this._length+=n.subtract(o).length(),this},t.prototype.addArcTo=function(t,i,n,o,s){if(void 0===s&&(s=36),closed)return e.Tools.Error("cannot add arcs to closed paths"),this;var a=this._points[this._points.length-1],h=new r(t,i),c=new r(n,o),l=new g(a,h,c),u=l.angle.radians()/s;l.orientation===p.CW&&(u*=-1);for(var d=l.startAngle.radians()+u,f=0;s>f;f++){var m=Math.cos(d)*l.radius+l.centerPoint.x,v=Math.sin(d)*l.radius+l.centerPoint.y;this.addLineTo(m,v),d+=u}return this},t.prototype.close=function(){return this.closed=!0,this},t.prototype.length=function(){var e=this._length;if(!this.closed){var t=this._points[this._points.length-1];e+=this._points[0].subtract(t).length()}return e},t.prototype.getPoints=function(){return this._points},t.prototype.getPointAtLengthPosition=function(t){if(0>t||t>1)return e.Tools.Error("normalized length position should be between 0 and 1."),r.Zero();for(var i=t*this.length(),n=0,o=0;o<this._points.length;o++){var s=(o+1)%this._points.length,a=this._points[o],h=this._points[s].subtract(a),c=h.length()+n;if(i>=n&&c>=i){var l=h.normalize(),u=i-n;return new r(a.x+l.x*u,a.y+l.y*u)}n=c}return e.Tools.Error("internal error"),r.Zero()},t.StartingAt=function(e,i){return new t(e,i)},t}();e.Path2=_;var y=function(){function t(e,t,i){this.path=e,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array;for(var r=0;r<e.length;r++)this._curve[r]=e[r].clone();this._raw=i||!1,this._compute(t)}return t.prototype.getCurve=function(){return this._curve},t.prototype.getTangents=function(){return this._tangents},t.prototype.getNormals=function(){return this._normals},t.prototype.getBinormals=function(){return this._binormals},t.prototype.getDistances=function(){return this._distances},t.prototype.update=function(e,t){for(var i=0;i<e.length;i++)this._curve[i].x=e[i].x,this._curve[i].y=e[i].y,this._curve[i].z=e[i].z;return this._compute(t),this},t.prototype._compute=function(e){var t=this._curve.length;this._tangents[0]=this._getFirstNonNullVector(0),this._raw||this._tangents[0].normalize(),this._tangents[t-1]=this._curve[t-1].subtract(this._curve[t-2]),this._raw||this._tangents[t-1].normalize();var i=this._tangents[0],r=this._normalVector(this._curve[0],i,e);this._normals[0]=r,this._raw||this._normals[0].normalize(),this._binormals[0]=n.Cross(i,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;for(var o,s,a,h,c=1;t>c;c++)o=this._getLastNonNullVector(c),t-1>c&&(s=this._getFirstNonNullVector(c),this._tangents[c]=o.add(s),this._tangents[c].normalize()),this._distances[c]=this._distances[c-1]+o.length(),a=this._tangents[c],h=this._binormals[c-1],this._normals[c]=n.Cross(h,a),this._raw||this._normals[c].normalize(),this._binormals[c]=n.Cross(a,this._normals[c]),this._raw||this._binormals[c].normalize()},t.prototype._getFirstNonNullVector=function(e){for(var t=1,i=this._curve[e+t].subtract(this._curve[e]);0===i.length()&&e+t+1<this._curve.length;)t++,i=this._curve[e+t].subtract(this._curve[e]);return i},t.prototype._getLastNonNullVector=function(e){for(var t=1,i=this._curve[e].subtract(this._curve[e-t]);0===i.length()&&e>t+1;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i},t.prototype._normalVector=function(t,i,r){var o,s;null==r?(e.Tools.WithinEpsilon(i.y,1,e.Engine.Epsilon)?e.Tools.WithinEpsilon(i.x,1,e.Engine.Epsilon)?e.Tools.WithinEpsilon(i.z,1,e.Engine.Epsilon)||(s=new n(0,0,1)):s=new n(1,0,0):s=new n(0,-1,0),o=n.Cross(i,s)):(o=n.Cross(i,r),n.CrossToRef(o,i,o));return o.normalize(),o},t}();e.Path3D=y;var x=function(){function e(e){this._length=0,this._points=e,this._length=this._computeLength(e)}return e.CreateQuadraticBezier=function(t,i,r,o){o=o>2?o:3;for(var s=new Array,a=function(e,t,i,r){return(1-e)*(1-e)*t+2*e*(1-e)*i+e*e*r},h=0;o>=h;h++)s.push(new n(a(h/o,t.x,i.x,r.x),a(h/o,t.y,i.y,r.y),a(h/o,t.z,i.z,r.z)));return new e(s)},e.CreateCubicBezier=function(t,i,r,o,s){s=s>3?s:4;for(var a=new Array,h=function(e,t,i,r,n){return(1-e)*(1-e)*(1-e)*t+3*e*(1-e)*(1-e)*i+3*e*e*(1-e)*r+e*e*e*n},c=0;s>=c;c++)a.push(new n(h(c/s,t.x,i.x,r.x,o.x),h(c/s,t.y,i.y,r.y,o.y),h(c/s,t.z,i.z,r.z,o.z)));return new e(a)},e.CreateHermiteSpline=function(t,i,r,o,s){for(var a=new Array,h=1/s,c=0;s>=c;c++)a.push(n.Hermite(t,i,r,o,c*h));return new e(a)},e.prototype.getPoints=function(){return this._points},e.prototype.length=function(){return this._length},e.prototype.continue=function(t){for(var i=this._points[this._points.length-1],r=this._points.slice(),n=t.getPoints(),o=1;o<n.length;o++)r.push(n[o].subtract(n[0]).add(i));return new e(r)},e.prototype._computeLength=function(e){for(var t=0,i=1;i<e.length;i++)t+=e[i].subtract(e[i-1]).length();return t},e}();e.Curve3=x;var b=function(){function e(e,t){void 0===e&&(e=n.Zero()),void 0===t&&(t=n.Up()),this.position=e,this.normal=t}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone())},e}();e.PositionNormalVertex=b;var M=function(){function e(e,t,i){void 0===e&&(e=n.Zero()),void 0===t&&(t=n.Up()),void 0===i&&(i=r.Zero()),this.position=e,this.normal=t,this.uv=i}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone(),this.uv.clone())},e}();e.PositionNormalTextureVertex=M;var E=a.prototype.multiplyToArray,T=a.prototype.invertToRef,w=a.LookAtLHToRef,S=n.TransformCoordinatesToRef,A=n.TransformCoordinatesFromFloatsToRef,P=function(){function e(){}return Object.defineProperty(e,"IsEnabled",{get:function(){return e._isEnabled},enumerable:!0,configurable:!0}),e.DisableSIMD=function(){a.prototype.multiplyToArray=E,a.prototype.invertToRef=T,a.LookAtLHToRef=w,n.TransformCoordinatesToRef=S,n.TransformCoordinatesFromFloatsToRef=A,e._isEnabled=!1},e.EnableSIMD=function(){void 0!==window.SIMD&&(a.prototype.multiplyToArray=a.prototype.multiplyToArraySIMD,a.prototype.invertToRef=a.prototype.invertToRefSIMD,a.LookAtLHToRef=a.LookAtLHToRefSIMD,n.TransformCoordinatesToRef=n.TransformCoordinatesToRefSIMD,n.TransformCoordinatesFromFloatsToRef=n.TransformCoordinatesFromFloatsToRefSIMD,Object.defineProperty(n.prototype,"x",{get:function(){return this._data[0]},set:function(e){this._data||(this._data=new Float32Array(3)),this._data[0]=e}}),Object.defineProperty(n.prototype,"y",{get:function(){return this._data[1]},set:function(e){this._data[1]=e}}),Object.defineProperty(n.prototype,"z",{get:function(){return this._data[2]},set:function(e){this._data[2]=e}}),e._isEnabled=!0)},e._isEnabled=!1,e}();e.SIMDHelper=P}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(e,i){this.idbFactory=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,this.callbackManifestChecked=i,this.currentSceneUrl=t.ReturnFullUrlLocation(e),this.db=null,this.enableSceneOffline=!1,this.enableTexturesOffline=!1,this.manifestVersionFound=0,this.mustUpdateRessources=!1,this.hasReachedQuota=!1,t.IDBStorageEnabled?this.checkManifestFile():this.callbackManifestChecked(!0)}return t.prototype.checkManifestFile=function(){function t(){r.enableSceneOffline=!1,r.enableTexturesOffline=!1,r.callbackManifestChecked(!1)}var i=this,r=this,n=this.currentSceneUrl+".manifest",o=new XMLHttpRequest,s=n+(null==n.match(/\?/)?"?":"&")+(new Date).getTime();o.open("GET",s,!0),o.addEventListener("load",function(){if(200===o.status||e.Tools.ValidateXHRData(o,1))try{var r=JSON.parse(o.response);i.enableSceneOffline=r.enableSceneOffline,i.enableTexturesOffline=r.enableTexturesOffline,r.version&&!isNaN(parseInt(r.version))&&(i.manifestVersionFound=r.version),i.callbackManifestChecked&&i.callbackManifestChecked(!0)}catch(e){t()}else t()},!1),o.addEventListener("error",function(e){t()},!1);try{o.send()}catch(t){e.Tools.Error("Error on XHR send request."),r.callbackManifestChecked(!1)}},t.prototype.openAsync=function(t,i){function r(){o.isSupported=!1,i&&i()}var n=this,o=this;if(this.idbFactory&&(this.enableSceneOffline||this.enableTexturesOffline))if(this.db)t&&t();else{this.hasReachedQuota=!1,this.isSupported=!0;var s=this.idbFactory.open("babylonjs",1);s.onerror=function(e){r()},s.onblocked=function(t){e.Tools.Error("IDB request blocked. Please reload the page."),r()},s.onsuccess=function(e){n.db=s.result,t()},s.onupgradeneeded=function(t){n.db=t.target.result;try{n.db.createObjectStore("scenes",{keyPath:"sceneUrl"}),n.db.createObjectStore("versions",{keyPath:"sceneUrl"}),n.db.createObjectStore("textures",{keyPath:"textureUrl"})}catch(t){e.Tools.Error("Error while creating object stores. Exception: "+t.message),r()}}}else this.isSupported=!1,i&&i()},t.prototype.loadImageFromDB=function(e,i){var r=this,n=t.ReturnFullUrlLocation(e),o=function(){r.hasReachedQuota||null===r.db?i.src=e:r._saveImageIntoDBAsync(n,i)};this.mustUpdateRessources?o():this._loadImageFromDBAsync(n,i,o)},t.prototype._loadImageFromDBAsync=function(t,i,r){if(this.isSupported&&null!==this.db){var n,o=this.db.transaction(["textures"]);o.onabort=function(e){i.src=t},o.oncomplete=function(o){var s;if(n){var a=window.URL||window.webkitURL;s=a.createObjectURL(n.data,{oneTimeOnly:!0}),i.onerror=function(){e.Tools.Error("Error loading image from blob URL: "+s+" switching back to web url: "+t),i.src=t},i.src=s}else r()};var s=o.objectStore("textures").get(t);s.onsuccess=function(e){n=e.target.result},s.onerror=function(r){e.Tools.Error("Error loading texture "+t+" from DB."),i.src=t}}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i.src=t},t.prototype._saveImageIntoDBAsync=function(i,r){var n=this;if(this.isSupported){var o=function(){var e;if(s){var t=window.URL||window.webkitURL;try{e=t.createObjectURL(s,{oneTimeOnly:!0})}catch(i){e=t.createObjectURL(s)}}r.src=e};if(t.IsUASupportingBlobStorage){var s,a=new XMLHttpRequest;a.open("GET",i,!0),a.responseType="blob",a.addEventListener("load",function(){if(200===a.status){s=a.response;var e=n.db.transaction(["textures"],"readwrite");e.onabort=function(e){try{e.srcElement.error&&"QuotaExceededError"===e.srcElement.error.name&&(this.hasReachedQuota=!0)}catch(e){}o()},e.oncomplete=function(e){o()};var h={textureUrl:i,data:s};try{var c=e.objectStore("textures").put(h);c.onsuccess=function(e){},c.onerror=function(e){o()}}catch(e){25===e.code&&(t.IsUASupportingBlobStorage=!1),r.src=i}}else r.src=i},!1),a.addEventListener("error",function(t){e.Tools.Error("Error in XHR request in BABYLON.Database."),r.src=i},!1),a.send()}else r.src=i}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),r.src=i},t.prototype._checkVersionFromDB=function(e,t){var i=this;this._loadVersionFromDBAsync(e,t,function(r){i._saveVersionIntoDBAsync(e,t)})},t.prototype._loadVersionFromDBAsync=function(t,i,r){var n,o=this;if(this.isSupported)try{var s=this.db.transaction(["versions"]);s.oncomplete=function(e){n?o.manifestVersionFound>n.data?(o.mustUpdateRessources=!0,r()):i(n.data):(o.mustUpdateRessources=!0,r())},s.onabort=function(e){i(-1)};var a=s.objectStore("versions").get(t);a.onsuccess=function(e){n=e.target.result},a.onerror=function(r){e.Tools.Error("Error loading version for scene "+t+" from DB."),i(-1)}}catch(t){e.Tools.Error("Error while accessing 'versions' object store (READ OP). Exception: "+t.message),i(-1)}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i(-1)},t.prototype._saveVersionIntoDBAsync=function(t,i){var r=this;if(this.isSupported&&!this.hasReachedQuota)try{var n=this.db.transaction(["versions"],"readwrite");n.onabort=function(e){try{e.srcElement.error&&"QuotaExceededError"===e.srcElement.error.name&&(r.hasReachedQuota=!0)}catch(e){}i(-1)},n.oncomplete=function(e){i(r.manifestVersionFound)};var o={sceneUrl:t,data:this.manifestVersionFound},s=n.objectStore("versions").put(o);s.onsuccess=function(e){},s.onerror=function(t){e.Tools.Error("Error in DB add version request in BABYLON.Database.")}}catch(t){e.Tools.Error("Error while accessing 'versions' object store (WRITE OP). Exception: "+t.message),i(-1)}else i(-1)},t.prototype.loadFileFromDB=function(e,i,r,n,o){var s=this,a=t.ReturnFullUrlLocation(e),h=function(e){s._saveFileIntoDBAsync(a,i,r)};this._checkVersionFromDB(a,function(e){-1!==e?s.mustUpdateRessources?s._saveFileIntoDBAsync(a,i,r,o):s._loadFileFromDBAsync(a,i,h,o):n()})},t.prototype._loadFileFromDBAsync=function(t,i,r,n){if(this.isSupported){var o;o=-1!==t.indexOf(".babylon")?"scenes":"textures";var s,a=this.db.transaction([o]);a.oncomplete=function(e){s?i(s.data):r()},a.onabort=function(e){r()};var h=a.objectStore(o).get(t);h.onsuccess=function(e){s=e.target.result},h.onerror=function(i){e.Tools.Error("Error loading file "+t+" from DB."),r()}}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i()},t.prototype._saveFileIntoDBAsync=function(t,i,r,n){var o=this;if(this.isSupported){var s;s=-1!==t.indexOf(".babylon")?"scenes":"textures";var a,h=new XMLHttpRequest;h.open("GET",t,!0),n&&(h.responseType="arraybuffer"),h.onprogress=r,h.addEventListener("load",function(){if(200===h.status||e.Tools.ValidateXHRData(h,n?6:1))if(a=n?h.response:h.responseText,o.hasReachedQuota)i(a);else{var r,c=o.db.transaction([s],"readwrite");c.onabort=function(e){try{e.srcElement.error&&"QuotaExceededError"===e.srcElement.error.name&&(this.hasReachedQuota=!0)}catch(e){}i(a)},c.oncomplete=function(e){i(a)},r="scenes"===s?{sceneUrl:t,data:a,version:o.manifestVersionFound}:{textureUrl:t,data:a};try{var l=c.objectStore(s).put(r);l.onsuccess=function(e){},l.onerror=function(t){e.Tools.Error("Error in DB add file request in BABYLON.Database.")}}catch(e){i(a)}}else i()},!1),h.addEventListener("error",function(t){e.Tools.Error("error on XHR request."),i()},!1),h.send()}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i()},t.IsUASupportingBlobStorage=!0,t.IDBStorageEnabled=!0,t.parseURL=function(e){document.createElement("a").href=e;var t=e.substring(0,e.lastIndexOf("#")),i=e.substring(t.lastIndexOf("/")+1,e.length);return e.substring(0,e.indexOf(i,0))},t.ReturnFullUrlLocation=function(e){return-1===e.indexOf("http:/")?t.parseURL(window.location.href)+e:e},t}();e.Database=t}(BABYLON||(BABYLON={})),function(e){!function(t){var i=function(){function t(){}return t.GetTGAHeader=function(e){var t=0;return{id_length:e[t++],colormap_type:e[t++],image_type:e[t++],colormap_index:e[t++]|e[t++]<<8,colormap_length:e[t++]|e[t++]<<8,colormap_size:e[t++],origin:[e[t++]|e[t++]<<8,e[t++]|e[t++]<<8],width:e[t++]|e[t++]<<8,height:e[t++]|e[t++]<<8,pixel_size:e[t++],flags:e[t++]}},t.UploadContent=function(i,r){if(r.length<19)e.Tools.Error("Unable to load TGA file - Not enough data to contain header");else{var n=18,o=t.GetTGAHeader(r);if(o.id_length+n>r.length)e.Tools.Error("Unable to load TGA file - Not enough data");else{n+=o.id_length;var s=!1,a=!1,h=!1;switch(o.image_type){case t._TYPE_RLE_INDEXED:s=!0;case t._TYPE_INDEXED:a=!0;break;case t._TYPE_RLE_RGB:s=!0;case t._TYPE_RGB:!0;break;case t._TYPE_RLE_GREY:s=!0;case t._TYPE_GREY:h=!0}var c,l,u,d,f,p,m,g,v=(o.flags,o.pixel_size>>3),_=o.width*o.height*v;if(a&&(l=r.subarray(n,n+=o.colormap_length*(o.colormap_size>>3))),s){c=new Uint8Array(_);for(var y,x,b,M=0,E=new Uint8Array(v);_>n&&_>M;)if(x=1+(127&(y=r[n++])),128&y){for(b=0;v>b;++b)E[b]=r[n++];for(b=0;x>b;++b)c.set(E,M+b*v);M+=v*x}else{for(x*=v,b=0;x>b;++b)c[M+b]=r[n++];M+=x}}else c=r.subarray(n,n+=a?o.width*o.height:_);switch((o.flags&t._ORIGIN_MASK)>>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:u=0,f=1,g=o.width,d=0,p=1,m=o.height;break;case t._ORIGIN_BL:u=0,f=1,g=o.width,d=o.height-1,p=-1,m=-1;break;case t._ORIGIN_UR:u=o.width-1,f=-1,g=-1,d=0,p=1,m=o.height;break;case t._ORIGIN_BR:u=o.width-1,f=-1,g=-1,d=o.height-1,p=-1,m=-1}var T=t["_getImageData"+(h?"Grey":"")+o.pixel_size+"bits"](o,l,c,d,p,m,u,f,g);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,o.width,o.height,0,i.RGBA,i.UNSIGNED_BYTE,T)}}},t._getImageData8bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,d=i,f=t,p=e.width,m=e.height,g=0,v=new Uint8Array(p*m*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,g++)c=d[g],v[4*(l+p*u)+3]=255,v[4*(l+p*u)+2]=f[3*c+0],v[4*(l+p*u)+1]=f[3*c+1],v[4*(l+p*u)+0]=f[3*c+2];return v},t._getImageData16bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,d=i,f=e.width,p=e.height,m=0,g=new Uint8Array(f*p*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,m+=2)c=d[m+0]+(d[m+1]<<8),g[4*(l+f*u)+0]=(31744&c)>>7,g[4*(l+f*u)+1]=(992&c)>>2,g[4*(l+f*u)+2]=(31&c)>>3,g[4*(l+f*u)+3]=32768&c?0:255;return g},t._getImageData24bits=function(e,t,i,r,n,o,s,a,h){var c,l,u=i,d=e.width,f=e.height,p=0,m=new Uint8Array(d*f*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=3)m[4*(c+d*l)+3]=255,m[4*(c+d*l)+2]=u[p+0],m[4*(c+d*l)+1]=u[p+1],m[4*(c+d*l)+0]=u[p+2];return m},t._getImageData32bits=function(e,t,i,r,n,o,s,a,h){var c,l,u=i,d=e.width,f=e.height,p=0,m=new Uint8Array(d*f*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=4)m[4*(c+d*l)+2]=u[p+0],m[4*(c+d*l)+1]=u[p+1],m[4*(c+d*l)+0]=u[p+2],m[4*(c+d*l)+3]=u[p+3];return m},t._getImageDataGrey8bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,d=i,f=e.width,p=e.height,m=0,g=new Uint8Array(f*p*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,m++)c=d[m],g[4*(l+f*u)+0]=c,g[4*(l+f*u)+1]=c,g[4*(l+f*u)+2]=c,g[4*(l+f*u)+3]=255;return g},t._getImageDataGrey16bits=function(e,t,i,r,n,o,s,a,h){var c,l,u=i,d=e.width,f=e.height,p=0,m=new Uint8Array(d*f*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=2)m[4*(c+d*l)+0]=u[p+0],m[4*(c+d*l)+1]=u[p+0],m[4*(c+d*l)+2]=u[p+0],m[4*(c+d*l)+3]=u[p+1];return m},t._TYPE_NO_DATA=0,t._TYPE_INDEXED=1,t._TYPE_RGB=2,t._TYPE_GREY=3,t._TYPE_RLE_INDEXED=9,t._TYPE_RLE_RGB=10,t._TYPE_RLE_GREY=11,t._ORIGIN_MASK=48,t._ORIGIN_SHIFT=4,t._ORIGIN_BL=0,t._ORIGIN_BR=1,t._ORIGIN_UL=2,t._ORIGIN_UR=3,t}();t.TGATools=i}(e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={})),function(e){!function(t){function i(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var r=131072,n=131072,o=i("DXT1"),s=i("DXT3"),a=i("DXT5"),h=function(){function t(){}return t.GetDDSInfo=function(e){var t=new Int32Array(e,0,31),i=1;return t[2]&r&&(i=Math.max(1,t[7])),{width:t[4],height:t[3],mipmapCount:i,isFourCC:4==(4&t[20]),isRGB:64==(64&t[20]),isLuminance:(t[20]&n)===n,isCube:512==(512&t[28])}},t.GetRGBAArrayBuffer=function(e,t,i,r,n){for(var o=new Uint8Array(r),s=new Uint8Array(n),a=0,h=t-1;h>=0;h--)for(var c=0;e>c;c++){var l=i+4*(c+h*e);o[a+2]=s[l],o[a+1]=s[l+1],o[a]=s[l+2],o[a+3]=s[l+3],a+=4}return o},t.GetRGBArrayBuffer=function(e,t,i,r,n){for(var o=new Uint8Array(r),s=new Uint8Array(n),a=0,h=t-1;h>=0;h--)for(var c=0;e>c;c++){var l=i+3*(c+h*e);o[a+2]=s[l],o[a+1]=s[l+1],o[a]=s[l+2],a+=3}return o},t.GetLuminanceArrayBuffer=function(e,t,i,r,n){for(var o=new Uint8Array(r),s=new Uint8Array(n),a=0,h=t-1;h>=0;h--)for(var c=0;e>c;c++){var l=i+(c+h*e);o[a]=s[l],a++}return o},t.UploadDDSLevels=function(i,n,h,c,l,u){var d,f,p,m,g,v,_,y,x,b,M=new Int32Array(h,0,31);if(542327876==M[0])if(c.isFourCC||c.isRGB||c.isLuminance){if(c.isFourCC)switch(d=M[21]){case o:f=8,p=n.COMPRESSED_RGBA_S3TC_DXT1_EXT;break;case s:f=16,p=n.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case a:f=16,p=n.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return void console.error("Unsupported FourCC code:",function(e){return String.fromCharCode(255&e,e>>8&255,e>>16&255,e>>24&255)}(d))}x=1,M[2]&r&&!1!==l&&(x=Math.max(1,M[7]));for(var E=M[22],T=0;u>T;T++){var w=1===u?i.TEXTURE_2D:i.TEXTURE_CUBE_MAP_POSITIVE_X+T;for(m=M[4],g=M[3],_=M[1]+4,b=0;x>b;++b){if(c.isRGB)24===E?(v=m*g*3,y=t.GetRGBArrayBuffer(m,g,_,v,h),i.texImage2D(w,b,i.RGB,m,g,0,i.RGB,i.UNSIGNED_BYTE,y)):(v=m*g*4,y=t.GetRGBAArrayBuffer(m,g,_,v,h),i.texImage2D(w,b,i.RGBA,m,g,0,i.RGBA,i.UNSIGNED_BYTE,y));else if(c.isLuminance){var S=i.getParameter(i.UNPACK_ALIGNMENT),A=m;v=Math.floor((m+S-1)/S)*S*(g-1)+A,y=t.GetLuminanceArrayBuffer(m,g,_,v,h),i.texImage2D(w,b,i.LUMINANCE,m,g,0,i.LUMINANCE,i.UNSIGNED_BYTE,y)}else v=Math.max(4,m)/4*Math.max(4,g)/4*f,y=new Uint8Array(h,_,v),i.compressedTexImage2D(w,b,p,m,g,0,y);_+=v,m*=.5,g*=.5,m=Math.max(1,m),g=Math.max(1,g)}}}else e.Tools.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");else e.Tools.Error("Invalid magic number in DDS header")},t}();t.DDSTools=h}(e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={})),function(e){var t=function(){function e(t){this.length=0,this._duplicateId=0,this.data=new Array(t),this._id=e._GlobalId++}return e.prototype.push=function(e){this.data[this.length++]=e,this.length>this.data.length&&(this.data.length*=2),e.__smartArrayFlags||(e.__smartArrayFlags={}),e.__smartArrayFlags[this._id]=this._duplicateId},e.prototype.pushNoDuplicate=function(e){e.__smartArrayFlags&&e.__smartArrayFlags[this._id]===this._duplicateId||this.push(e)},e.prototype.sort=function(e){this.data.sort(e)},e.prototype.reset=function(){this.length=0,this._duplicateId++},e.prototype.concat=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t<e.length;t++)this.data[this.length++]=(e.data||e)[t]}},e.prototype.concatWithNoDuplicate=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t<e.length;t++){var i=(e.data||e)[t];this.pushNoDuplicate(i)}}},e.prototype.indexOf=function(e){var t=this.data.indexOf(e);return t>=this.length?-1:t},e._GlobalId=0,e}();e.SmartArray=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function e(e){void 0===e&&(e=10),this.count=0,this._initialCapacity=e,this.items={},this._keys=new Array(this._initialCapacity)}return e.prototype.add=function(e,t){return null!=this.items[e]?-1:(this.items[e]=t,this._keys[this.count++]=e,this.count>this._keys.length&&(this._keys.length*=2),this.count)},e.prototype.remove=function(e){return null==this.items[e]?-1:this.removeItemOfIndex(this.indexOf(e))},e.prototype.removeItemOfIndex=function(e){if(!(e<this.count&&e>-1))return-1;for(delete this.items[this._keys[e]];e<this.count;)this._keys[e]=this._keys[e+1],e++;return--this.count},e.prototype.indexOf=function(e){for(var t=0;t!==this.count;t++)if(this._keys[t]===e)return t;return-1},e.prototype.item=function(e){return this.items[e]},e.prototype.getAllKeys=function(){if(this.count>0){for(var e=new Array(this.count),t=0;t<this.count;t++)e[t]=this._keys[t];return e}},e.prototype.getKeyByIndex=function(e){return e<this.count&&e>-1?this._keys[e]:void 0},e.prototype.getItemByIndex=function(e){return e<this.count&&e>-1?this.items[this._keys[e]]:void 0},e.prototype.empty=function(){this.count>0&&(this.count=0,this.items={},this._keys=new Array(this._initialCapacity))},e.prototype.forEach=function(e){var t;for(t in this.items)this.items.hasOwnProperty(t)&&e(this.items[t])},e}();e.SmartCollection=t}(BABYLON||(BABYLON={})),function(e){var t,i=function(t,i){return t?t instanceof e.Mesh?null:t instanceof e.SubMesh?t.clone(i):t.clone?t.clone():null:null},r=function(){function r(){}return r.ToHex=function(e){var t=e.toString(16);return 15>=e?("0"+t).toUpperCase():t.toUpperCase()},r.SetImmediate=function(e){window.setImmediate?window.setImmediate(e):setTimeout(e,1)},r.IsExponentOfTwo=function(e){var t=1;do{t*=2}while(e>t);return t===e},r.GetExponentOfTwo=function(e,t){var i=1;do{i*=2}while(e>i);return i>t&&(i=t),i},r.GetFilename=function(e){var t=e.lastIndexOf("/");return 0>t?e:e.substring(t+1)},r.GetDOMTextContent=function(e){for(var t="",i=e.firstChild;i;)3===i.nodeType&&(t+=i.textContent),i=i.nextSibling;return t},r.ToDegrees=function(e){return 180*e/Math.PI},r.ToRadians=function(e){return e*Math.PI/180},r.ExtractMinAndMaxIndexed=function(t,i,r,n){for(var o=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),a=r;r+n>a;a++){var h=new e.Vector3(t[3*i[a]],t[3*i[a]+1],t[3*i[a]+2]);o=e.Vector3.Minimize(h,o),s=e.Vector3.Maximize(h,s)}return{minimum:o,maximum:s}},r.ExtractMinAndMax=function(t,i,r){for(var n=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),o=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),s=i;i+r>s;s++){var a=new e.Vector3(t[3*s],t[3*s+1],t[3*s+2]);n=e.Vector3.Minimize(a,n),o=e.Vector3.Maximize(a,o)}return{minimum:n,maximum:o}},r.MakeArray=function(e,t){return!0===t||void 0!==e&&null!=e?Array.isArray(e)?e:[e]:void 0},r.GetPointerPrefix=function(){var e="pointer";return navigator.pointerEnabled||(e="mouse"),e},r.QueueNewFrame=function(e){window.requestAnimationFrame?window.requestAnimationFrame(e):window.msRequestAnimationFrame?window.msRequestAnimationFrame(e):window.webkitRequestAnimationFrame?window.webkitRequestAnimationFrame(e):window.mozRequestAnimationFrame?window.mozRequestAnimationFrame(e):window.oRequestAnimationFrame?window.oRequestAnimationFrame(e):window.setTimeout(e,16)},r.RequestFullscreen=function(e){e.requestFullscreen?e.requestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.mozRequestFullScreen&&e.mozRequestFullScreen()},r.ExitFullscreen=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msCancelFullScreen&&document.msCancelFullScreen()},r.CleanUrl=function(e){return e.replace(/#/gm,"%23")},r.LoadImage=function(t,i,n,o){t=r.CleanUrl(t);var s=new Image;"data:"!==t.substr(0,5)&&(s.crossOrigin="anonymous"),s.onload=function(){i(s)},s.onerror=function(e){r.Error("Error while trying to load texture: "+t),s.src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z",i(s)};var a=function(){s.src=t};if(o&&o.enableTexturesOffline&&e.Database.IsUASupportingBlobStorage)o.openAsync(function(){o.loadImageFromDB(t,s)},a);else if(-1===t.indexOf("file:"))a();else try{var h,c=t.substring(5);try{h=URL.createObjectURL(e.FilesInput.FilesTextures[c],{oneTimeOnly:!0})}catch(t){h=URL.createObjectURL(e.FilesInput.FilesTextures[c])}s.src=h}catch(e){s.src=null}return s},r.LoadFile=function(t,i,n,o,s,a){t=r.CleanUrl(t);var h=function(){var e=new XMLHttpRequest,o=r.BaseUrl+t;e.open("GET",o,!0),s&&(e.responseType="arraybuffer"),e.onprogress=n,e.onreadystatechange=function(){if(4===e.readyState)if(200===e.status||r.ValidateXHRData(e,s?6:1))i(s?e.response:e.responseText);else{if(!a)throw new Error("Error status: "+e.status+" - Unable to load "+o);a()}},e.send(null)};if(-1!==t.indexOf("file:")){var c=t.substring(5);r.ReadFile(e.FilesInput.FilesToLoad[c],i,n,!0)}else o&&o.enableSceneOffline?o.openAsync(function(){o.loadFileFromDB(t,i,n,h,s)},h):h()},r.ReadFileAsDataURL=function(e,t,i){var r=new FileReader;r.onload=function(e){t(e.target.result)},r.onprogress=i,r.readAsDataURL(e)},r.ReadFile=function(e,t,i,n){var o=new FileReader;o.onerror=function(i){r.Log("Error while reading file: "+e.name),t(JSON.stringify({autoClear:!0,clearColor:[1,0,0],ambientColor:[0,0,0],gravity:[0,-9.807,0],meshes:[],cameras:[],lights:[]}))},o.onload=function(e){t(e.target.result)},o.onprogress=i,n?o.readAsArrayBuffer(e):o.readAsText(e)},r.FileAsURL=function(e){var t=new Blob([e]);return(window.URL||window.webkitURL).createObjectURL(t)},r.Clamp=function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=1),Math.min(i,Math.max(t,e))},r.Sign=function(e){return 0===(e=+e)||isNaN(e)?e:e>0?1:-1},r.Format=function(e,t){return void 0===t&&(t=2),e.toFixed(t)},r.CheckExtends=function(e,t,i){e.x<t.x&&(t.x=e.x),e.y<t.y&&(t.y=e.y),e.z<t.z&&(t.z=e.z),e.x>i.x&&(i.x=e.x),e.y>i.y&&(i.y=e.y),e.z>i.z&&(i.z=e.z)},r.WithinEpsilon=function(e,t,i){void 0===i&&(i=1.401298e-45);var r=e-t;return r>=-i&&i>=r},r.DeepCopy=function(e,t,r,n){for(var o in e)if(("_"!==o[0]||n&&-1!==n.indexOf(o))&&(!r||-1===r.indexOf(o))){var s=e[o],a=typeof s;if("function"!==a)if("object"===a)if(s instanceof Array){if(t[o]=[],s.length>0)if("object"==typeof s[0])for(var h=0;h<s.length;h++){var c=i(s[h],t);-1===t[o].indexOf(c)&&t[o].push(c)}else t[o]=s.slice(0)}else t[o]=i(s,t);else t[o]=s}},r.IsEmpty=function(e){for(var t in e)return!1;return!0},r.RegisterTopRootEvents=function(e){for(var t=0;t<e.length;t++){var i=e[t];window.addEventListener(i.name,i.handler,!1);try{window.parent&&window.parent.addEventListener(i.name,i.handler,!1)}catch(e){}}},r.UnregisterTopRootEvents=function(e){for(var t=0;t<e.length;t++){var i=e[t];window.removeEventListener(i.name,i.handler);try{window.parent&&window.parent.removeEventListener(i.name,i.handler)}catch(e){}}},r.DumpFramebuffer=function(e,i,r,n){for(var o=4*e,s=i/2,a=r.readPixels(0,0,e,i),h=0;s>h;h++)for(var c=0;o>c;c++){var l=c+h*o,u=c+(i-h-1)*o,d=a[l];a[l]=a[u],a[u]=d}t||(t=document.createElement("canvas")),t.width=e,t.height=i;var f=t.getContext("2d"),p=f.createImageData(e,i);p.data.set(a),f.putImageData(p,0,0);var m=t.toDataURL();if(n)n(m);else if("download"in document.createElement("a")){var g=window.document.createElement("a");g.href=m;var v=new Date,_=v.getFullYear()+"-"+v.getMonth()+"-"+v.getDate()+"_"+v.getHours()+"-"+("0"+v.getMinutes()).slice(-2);g.setAttribute("download","screenshot_"+_+".png"),window.document.body.appendChild(g),g.addEventListener("click",function(){g.parentElement.removeChild(g)}),g.click()}else{var y=window.open(""),x=y.document.createElement("img");x.src=m,y.document.body.appendChild(x)}},r.CreateScreenshot=function(t,i,n,o){var s,a;if(n.precision)s=Math.round(t.getRenderWidth()*n.precision),a=Math.round(s/t.getAspectRatio(i)),n={width:s,height:a};else if(n.width&&n.height)s=n.width,a=n.height;else if(n.width&&!n.height)s=n.width,a=Math.round(s/t.getAspectRatio(i)),n={width:s,height:a};else if(n.height&&!n.width)a=n.height,n={width:s=Math.round(a*t.getAspectRatio(i)),height:a};else{if(isNaN(n))return void r.Error("Invalid 'size' parameter !");a=n,s=n}var h=i.getScene(),c=null;h.activeCamera!==i&&(c=h.activeCamera,h.activeCamera=i);var l=new e.RenderTargetTexture("screenShot",n,h,!1,!1);l.renderList=h.meshes,l.onAfterRender=function(){r.DumpFramebuffer(s,a,t,o)},h.incrementRenderId(),l.render(!0),l.dispose(),c&&(h.activeCamera=c)},r.ValidateXHRData=function(t,i){void 0===i&&(i=7);try{if(1&i){if(t.responseText&&t.responseText.length>0)return!0;if(1===i)return!1}if(2&i){var r=e.Internals.TGATools.GetTGAHeader(t.response);if(r.width&&r.height&&r.width>0&&r.height>0)return!0;if(2===i)return!1}if(4&i){var n=new Uint8Array(t.response,0,3);return 68===n[0]&&68===n[1]&&83===n[2]}}catch(e){}return!1},Object.defineProperty(r,"NoneLogLevel",{get:function(){return r._NoneLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(r,"MessageLogLevel",{get:function(){return r._MessageLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(r,"WarningLogLevel",{get:function(){return r._WarningLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ErrorLogLevel",{get:function(){return r._ErrorLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(r,"AllLogLevel",{get:function(){return r._MessageLogLevel|r._WarningLogLevel|r._ErrorLogLevel},enumerable:!0,configurable:!0}),r._AddLogEntry=function(e){r._LogCache=e+r._LogCache,r.OnNewCacheEntry&&r.OnNewCacheEntry(e)},r._FormatMessage=function(e){var t=function(e){return 10>e?"0"+e:""+e},i=new Date;return"["+t(i.getHours())+":"+t(i.getMinutes())+":"+t(i.getSeconds())+"]: "+e},r._LogDisabled=function(e){},r._LogEnabled=function(e){var t=r._FormatMessage(e);console.log("BJS - "+t);var i="<div style='color:white'>"+t+"</div><br>";r._AddLogEntry(i)},r._WarnDisabled=function(e){},r._WarnEnabled=function(e){var t=r._FormatMessage(e);console.warn("BJS - "+t);var i="<div style='color:orange'>"+t+"</div><br>";r._AddLogEntry(i)},r._ErrorDisabled=function(e){},r._ErrorEnabled=function(e){r.errorsCount++;var t=r._FormatMessage(e);console.error("BJS - "+t);var i="<div style='color:red'>"+t+"</div><br>";r._AddLogEntry(i)},Object.defineProperty(r,"LogCache",{get:function(){return r._LogCache},enumerable:!0,configurable:!0}),r.ClearLogCache=function(){r._LogCache="",r.errorsCount=0},Object.defineProperty(r,"LogLevels",{set:function(e){r.Log=(e&r.MessageLogLevel)===r.MessageLogLevel?r._LogEnabled:r._LogDisabled,r.Warn=(e&r.WarningLogLevel)===r.WarningLogLevel?r._WarnEnabled:r._WarnDisabled,r.Error=(e&r.ErrorLogLevel)===r.ErrorLogLevel?r._ErrorEnabled:r._ErrorDisabled},enumerable:!0,configurable:!0}),Object.defineProperty(r,"PerformanceNoneLogLevel",{get:function(){return r._PerformanceNoneLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(r,"PerformanceUserMarkLogLevel",{get:function(){return r._PerformanceUserMarkLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(r,"PerformanceConsoleLogLevel",{get:function(){return r._PerformanceConsoleLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(r,"PerformanceLogLevel",{set:function(e){return(e&r.PerformanceUserMarkLogLevel)===r.PerformanceUserMarkLogLevel?(r.StartPerformanceCounter=r._StartUserMark,void(r.EndPerformanceCounter=r._EndUserMark)):(e&r.PerformanceConsoleLogLevel)===r.PerformanceConsoleLogLevel?(r.StartPerformanceCounter=r._StartPerformanceConsole,void(r.EndPerformanceCounter=r._EndPerformanceConsole)):(r.StartPerformanceCounter=r._StartPerformanceCounterDisabled,void(r.EndPerformanceCounter=r._EndPerformanceCounterDisabled))},enumerable:!0,configurable:!0}),r._StartPerformanceCounterDisabled=function(e,t){},r._EndPerformanceCounterDisabled=function(e,t){},r._StartUserMark=function(e,t){void 0===t&&(t=!0),t&&r._performance.mark&&r._performance.mark(e+"-Begin")},r._EndUserMark=function(e,t){void 0===t&&(t=!0),t&&r._performance.mark&&(r._performance.mark(e+"-End"),r._performance.measure(e,e+"-Begin",e+"-End"))},r._StartPerformanceConsole=function(e,t){void 0===t&&(t=!0),t&&(r._StartUserMark(e,t),console.time&&console.time(e))},r._EndPerformanceConsole=function(e,t){void 0===t&&(t=!0),t&&(r._EndUserMark(e,t),console.time&&console.timeEnd(e))},Object.defineProperty(r,"Now",{get:function(){return window.performance&&window.performance.now?window.performance.now():(new Date).getTime()},enumerable:!0,configurable:!0}),r.GetFps=function(){return r.Warn("Tools.GetFps() is deprecated. Please use engine.getFps() instead"),0},r.BaseUrl="",r._NoneLogLevel=0,r._MessageLogLevel=1,r._WarningLogLevel=2,r._ErrorLogLevel=4,r._LogCache="",r.errorsCount=0,r.Log=r._LogEnabled,r.Warn=r._WarnEnabled,r.Error=r._ErrorEnabled,r._PerformanceNoneLogLevel=0,r._PerformanceUserMarkLogLevel=1,r._PerformanceConsoleLogLevel=2,r._performance=window.performance,r.StartPerformanceCounter=r._StartPerformanceCounterDisabled,r.EndPerformanceCounter=r._EndPerformanceCounterDisabled,r}();e.Tools=r;var n=function(){function e(e,t,i,r){void 0===r&&(r=0),this.iterations=e,this._fn=t,this._successCallback=i,this.index=r-1,this._done=!1}return e.prototype.executeNext=function(){this._done||(this.index+1<this.iterations?(++this.index,this._fn(this)):this.breakLoop())},e.prototype.breakLoop=function(){this._done=!0,this._successCallback()},e.Run=function(t,i,r,n){void 0===n&&(n=0);var o=new e(t,i,r,n);return o.executeNext(),o},e.SyncAsyncForLoop=function(t,i,r,n,o,s){void 0===s&&(s=0),e.Run(Math.ceil(t/i),function(e){o&&o()?e.breakLoop():setTimeout(function(){for(var n=0;i>n;++n){var s=e.index*i+n;if(s>=t)break;if(r(s),o&&o()){e.breakLoop();break}}e.executeNext()},s)},n)},e}();e.AsyncLoop=n}(BABYLON||(BABYLON={})),function(e){var t=function(){function e(){this._isDepthTestDirty=!1,this._isDepthMaskDirty=!1,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isDepthFuncDirty||this._isDepthTestDirty||this._isDepthMaskDirty||this._isCullFaceDirty||this._isCullDirty||this._isZOffsetDirty},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"zOffset",{get:function(){return this._zOffset},set:function(e){this._zOffset!==e&&(this._zOffset=e,this._isZOffsetDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cullFace",{get:function(){return this._cullFace},set:function(e){this._cullFace!==e&&(this._cullFace=e,this._isCullFaceDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cull",{get:function(){return this._cull},set:function(e){this._cull!==e&&(this._cull=e,this._isCullDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthFunc",{get:function(){return this._depthFunc},set:function(e){this._depthFunc!==e&&(this._depthFunc=e,this._isDepthFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthMask",{get:function(){return this._depthMask},set:function(e){this._depthMask!==e&&(this._depthMask=e,this._isDepthMaskDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthTest",{get:function(){return this._depthTest},set:function(e){this._depthTest!==e&&(this._depthTest=e,this._isDepthTestDirty=!0)},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this._depthMask=!0,this._depthTest=!0,this._depthFunc=null,this._cull=null,this._cullFace=null,this._zOffset=0,this._isDepthTestDirty=!0,this._isDepthMaskDirty=!0,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1},e.prototype.apply=function(e){this.isDirty&&(this._isCullDirty&&(this.cull?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this._isCullDirty=!1),this._isCullFaceDirty&&(e.cullFace(this.cullFace),this._isCullFaceDirty=!1),this._isDepthMaskDirty&&(e.depthMask(this.depthMask),this._isDepthMaskDirty=!1),this._isDepthTestDirty&&(this.depthTest?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this._isDepthTestDirty=!1),this._isDepthFuncDirty&&(e.depthFunc(this.depthFunc),this._isDepthFuncDirty=!1),this._isZOffsetDirty&&(this.zOffset?(e.enable(e.POLYGON_OFFSET_FILL),e.polygonOffset(this.zOffset,0)):e.disable(e.POLYGON_OFFSET_FILL),this._isZOffsetDirty=!1))},e}();e._DepthCullingState=t;var i=function(){function e(){this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._alphaBlend=!1,this._blendFunctionParameters=new Array(4)}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alphaBlend",{get:function(){return this._alphaBlend},set:function(e){this._alphaBlend!==e&&(this._alphaBlend=e,this._isAlphaBlendDirty=!0)},enumerable:!0,configurable:!0}),e.prototype.setAlphaBlendFunctionParameters=function(e,t,i,r){(this._blendFunctionParameters[0]!==e||this._blendFunctionParameters[1]!==t||this._blendFunctionParameters[2]!==i||this._blendFunctionParameters[3]!==r)&&(this._blendFunctionParameters[0]=e,this._blendFunctionParameters[1]=t,this._blendFunctionParameters[2]=i,this._blendFunctionParameters[3]=r,this._isBlendFunctionParametersDirty=!0)},e.prototype.reset=function(){this._alphaBlend=!1,this._blendFunctionParameters[0]=null,this._blendFunctionParameters[1]=null,this._blendFunctionParameters[2]=null,this._blendFunctionParameters[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1},e.prototype.apply=function(e){this.isDirty&&(this._isAlphaBlendDirty&&(this._alphaBlend?e.enable(e.BLEND):e.disable(e.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(e.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1))},e}();e._AlphaState=i;var r=function(e,t,i,r){var n=e.createShader("vertex"===i?e.VERTEX_SHADER:e.FRAGMENT_SHADER);if(e.shaderSource(n,(r?r+"\n":"")+t),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS))throw new Error(e.getShaderInfoLog(n));return n},n=function(e,t){var i=e.UNSIGNED_BYTE;return t===l.TEXTURETYPE_FLOAT&&(i=e.FLOAT),i},o=function(t,i,r){var n=r.NEAREST,o=r.NEAREST;return t===e.Texture.BILINEAR_SAMPLINGMODE?(n=r.LINEAR,o=i?r.LINEAR_MIPMAP_NEAREST:r.LINEAR):t===e.Texture.TRILINEAR_SAMPLINGMODE?(n=r.LINEAR,o=i?r.LINEAR_MIPMAP_LINEAR:r.LINEAR):t===e.Texture.NEAREST_SAMPLINGMODE&&(n=r.NEAREST,o=i?r.NEAREST_MIPMAP_LINEAR:r.NEAREST),{min:o,mag:n}},s=function(t,i,r,n,s,a,h,c,l,u){void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE);var d=r.getEngine(),f=e.Tools.GetExponentOfTwo(n,d.getCaps().maxTextureSize),p=e.Tools.GetExponentOfTwo(s,d.getCaps().maxTextureSize);i.bindTexture(i.TEXTURE_2D,t),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,void 0===a?1:a?1:0),t._baseWidth=n,t._baseHeight=s,t._width=f,t._height=p,t.isReady=!0,l(f,p);var m=o(u,!h,i);i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,m.mag),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,m.min),h||c||i.generateMipmap(i.TEXTURE_2D),i.bindTexture(i.TEXTURE_2D,null),d._activeTexturesCache=[],r._removePendingData(t)},a=function(t,i,r,n,o){var s=e.Tools.LoadImage(t,function(){r[i]=s,r._internalCount++,n._removePendingData(s),6===r._internalCount&&o(r)},function(){n._removePendingData(s)},n.database);n._addPendingData(s)},h=function(e,t,i,r){var n=[];n._internalCount=0;for(var o=0;6>o;o++)a(e+r[o],o,n,t,i)},c=function(){return function(){}}();e.EngineCapabilities=c;var l=function(){function a(r,n,o,s){var h=this;void 0===s&&(s=!0),this.isFullscreen=!1,this.isPointerLock=!1,this.cullBackFaces=!0,this.renderEvenInBackground=!0,this.enableOfflineSupport=!0,this.scenes=new Array,this._windowIsBackground=!1,this._drawCalls=0,this._renderingQueueLaunched=!1,this._activeRenderLoops=[],this.fpsRange=60,this.previousFramesDuration=[],this.fps=60,this.deltaTime=0,this._depthCullingState=new t,this._alphaState=new i,this._alphaMode=a.ALPHA_DISABLE,this._loadedTexturesCache=new Array,this._activeTexturesCache=new Array,this._compiledEffects={},this._uintIndicesCurrentlySet=!1,this._renderingCanvas=r,(o=o||{}).antialias=n,void 0===o.preserveDrawingBuffer&&(o.preserveDrawingBuffer=!1);try{this._gl=r.getContext("webgl",o)||r.getContext("experimental-webgl",o)}catch(e){throw new Error("WebGL not supported")}if(!this._gl)throw new Error("WebGL not supported");this._onBlur=function(){h._windowIsBackground=!0},this._onFocus=function(){h._windowIsBackground=!1},window.addEventListener("blur",this._onBlur),window.addEventListener("focus",this._onFocus),this._hardwareScalingLevel=s?1/(window.devicePixelRatio||1):1,this.resize(),this._caps=new c,this._caps.maxTexturesImageUnits=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._caps.maxCubemapTextureSize=this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),this._caps.maxRenderTextureSize=this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),this._glVersion=this._gl.getParameter(this._gl.VERSION);var l=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=l&&(this._glRenderer=this._gl.getParameter(l.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(l.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor="Unknown vendor"),this._glRenderer||(this._glRenderer="Unknown renderer"),this._caps.standardDerivatives=null!==this._gl.getExtension("OES_standard_derivatives"),this._caps.s3tc=this._gl.getExtension("WEBGL_compressed_texture_s3tc"),this._caps.textureFloat=null!==this._gl.getExtension("OES_texture_float"),this._caps.textureAnisotropicFilterExtension=this._gl.getExtension("EXT_texture_filter_anisotropic")||this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),this._caps.maxAnisotropy=this._caps.textureAnisotropicFilterExtension?this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,this._caps.instancedArrays=this._gl.getExtension("ANGLE_instanced_arrays"),this._caps.uintIndices=null!==this._gl.getExtension("OES_element_index_uint"),this._caps.highPrecisionShaderSupported=!0,this._gl.getShaderPrecisionFormat){var u=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);this._caps.highPrecisionShaderSupported=0!=u.precision}this.setDepthBuffer(!0),this.setDepthFunctionToLessOrEqual(),this.setDepthWrite(!0),this._onFullscreenChange=function(){void 0!==document.fullscreen?h.isFullscreen=document.fullscreen:void 0!==document.mozFullScreen?h.isFullscreen=document.mozFullScreen:void 0!==document.webkitIsFullScreen?h.isFullscreen=document.webkitIsFullScreen:void 0!==document.msIsFullScreen&&(h.isFullscreen=document.msIsFullScreen),h.isFullscreen&&h._pointerLockRequested&&(r.requestPointerLock=r.requestPointerLock||r.msRequestPointerLock||r.mozRequestPointerLock||r.webkitRequestPointerLock,r.requestPointerLock&&r.requestPointerLock())},document.addEventListener("fullscreenchange",this._onFullscreenChange,!1),document.addEventListener("mozfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("msfullscreenchange",this._onFullscreenChange,!1),this._onPointerLockChange=function(){h.isPointerLock=document.mozPointerLockElement===r||document.webkitPointerLockElement===r||document.msPointerLockElement===r||document.pointerLockElement===r},document.addEventListener("pointerlockchange",this._onPointerLockChange,!1),document.addEventListener("mspointerlockchange",this._onPointerLockChange,!1),document.addEventListener("mozpointerlockchange",this._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",this._onPointerLockChange,!1),a.audioEngine||(a.audioEngine=new e.AudioEngine),this._loadingScreen=new e.DefaultLoadingScreen(this._renderingCanvas),e.Tools.Log("Babylon.js engine (v"+a.Version+") launched")}return Object.defineProperty(a,"ALPHA_DISABLE",{get:function(){return a._ALPHA_DISABLE},enumerable:!0,configurable:!0}),Object.defineProperty(a,"ALPHA_ONEONE",{get:function(){return a._ALPHA_ONEONE},enumerable:!0,configurable:!0}),Object.defineProperty(a,"ALPHA_ADD",{get:function(){return a._ALPHA_ADD},enumerable:!0,configurable:!0}),Object.defineProperty(a,"ALPHA_COMBINE",{get:function(){return a._ALPHA_COMBINE},enumerable:!0,configurable:!0}),Object.defineProperty(a,"ALPHA_SUBTRACT",{get:function(){return a._ALPHA_SUBTRACT},enumerable:!0,configurable:!0}),Object.defineProperty(a,"ALPHA_MULTIPLY",{get:function(){return a._ALPHA_MULTIPLY},enumerable:!0,configurable:!0}),Object.defineProperty(a,"ALPHA_MAXIMIZED",{get:function(){return a._ALPHA_MAXIMIZED},enumerable:!0,configurable:!0}),Object.defineProperty(a,"DELAYLOADSTATE_NONE",{get:function(){return a._DELAYLOADSTATE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(a,"DELAYLOADSTATE_LOADED",{get:function(){return a._DELAYLOADSTATE_LOADED},enumerable:!0,configurable:!0}),Object.defineProperty(a,"DELAYLOADSTATE_LOADING",{get:function(){return a._DELAYLOADSTATE_LOADING},enumerable:!0,configurable:!0}),Object.defineProperty(a,"DELAYLOADSTATE_NOTLOADED",{get:function(){return a._DELAYLOADSTATE_NOTLOADED},enumerable:!0,configurable:!0}),Object.defineProperty(a,"TEXTUREFORMAT_ALPHA",{get:function(){return a._TEXTUREFORMAT_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(a,"TEXTUREFORMAT_LUMINANCE",{get:function(){return a._TEXTUREFORMAT_LUMINANCE},enumerable:!0,configurable:!0}),Object.defineProperty(a,"TEXTUREFORMAT_LUMINANCE_ALPHA",{get:function(){return a._TEXTUREFORMAT_LUMINANCE_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(a,"TEXTUREFORMAT_RGB",{get:function(){return a._TEXTUREFORMAT_RGB},enumerable:!0,configurable:!0}),Object.defineProperty(a,"TEXTUREFORMAT_RGBA",{get:function(){return a._TEXTUREFORMAT_RGBA},enumerable:!0,configurable:!0}),Object.defineProperty(a,"TEXTURETYPE_UNSIGNED_INT",{get:function(){return a._TEXTURETYPE_UNSIGNED_INT},enumerable:!0,configurable:!0}),Object.defineProperty(a,"TEXTURETYPE_FLOAT",{get:function(){return a._TEXTURETYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(a,"Version",{get:function(){return"2.3.0-alpha"},enumerable:!0,configurable:!0}),a.prototype._prepareWorkingCanvas=function(){this._workingCanvas||(this._workingCanvas=document.createElement("canvas"),this._workingContext=this._workingCanvas.getContext("2d"))},a.prototype.getGlInfo=function(){return{vendor:this._glVendor,renderer:this._glRenderer,version:this._glVersion}},a.prototype.getAspectRatio=function(e){var t=e.viewport;return this.getRenderWidth()*t.width/(this.getRenderHeight()*t.height)},a.prototype.getRenderWidth=function(){return this._currentRenderTarget?this._currentRenderTarget._width:this._renderingCanvas.width},a.prototype.getRenderHeight=function(){return this._currentRenderTarget?this._currentRenderTarget._height:this._renderingCanvas.height},a.prototype.getRenderingCanvas=function(){return this._renderingCanvas},a.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas.getBoundingClientRect()},a.prototype.setHardwareScalingLevel=function(e){this._hardwareScalingLevel=e,this.resize()},a.prototype.getHardwareScalingLevel=function(){return this._hardwareScalingLevel},a.prototype.getLoadedTexturesCache=function(){return this._loadedTexturesCache},a.prototype.getCaps=function(){return this._caps},Object.defineProperty(a.prototype,"drawCalls",{get:function(){return this._drawCalls},enumerable:!0,configurable:!0}),a.prototype.resetDrawCalls=function(){this._drawCalls=0},a.prototype.setDepthFunctionToGreater=function(){this._depthCullingState.depthFunc=this._gl.GREATER},a.prototype.setDepthFunctionToGreaterOrEqual=function(){this._depthCullingState.depthFunc=this._gl.GEQUAL},a.prototype.setDepthFunctionToLess=function(){this._depthCullingState.depthFunc=this._gl.LESS},a.prototype.setDepthFunctionToLessOrEqual=function(){this._depthCullingState.depthFunc=this._gl.LEQUAL},a.prototype.stopRenderLoop=function(e){if(e){var t=this._activeRenderLoops.indexOf(e);t>=0&&this._activeRenderLoops.splice(t,1)}else this._activeRenderLoops=[]},a.prototype._renderLoop=function(){var t=this,i=!0;if(!this.renderEvenInBackground&&this._windowIsBackground&&(i=!1),i){this.beginFrame();for(var r=0;r<this._activeRenderLoops.length;r++){(0,this._activeRenderLoops[r])()}this.endFrame()}this._activeRenderLoops.length>0?e.Tools.QueueNewFrame(function(){t._renderLoop()}):this._renderingQueueLaunched=!1},a.prototype.runRenderLoop=function(t){var i=this;-1===this._activeRenderLoops.indexOf(t)&&(this._activeRenderLoops.push(t),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,e.Tools.QueueNewFrame(function(){i._renderLoop()})))},a.prototype.switchFullscreen=function(t){this.isFullscreen?e.Tools.ExitFullscreen():(this._pointerLockRequested=t,e.Tools.RequestFullscreen(this._renderingCanvas))},a.prototype.clear=function(e,t,i){this.applyStates(),this._gl.clearColor(e.r,e.g,e.b,void 0!==e.a?e.a:1),this._depthCullingState.depthMask&&this._gl.clearDepth(1);var r=0;t&&(r|=this._gl.COLOR_BUFFER_BIT),i&&this._depthCullingState.depthMask&&(r|=this._gl.DEPTH_BUFFER_BIT),this._gl.clear(r)},a.prototype.setViewport=function(e,t,i){var r=t||(navigator.isCocoonJS?window.innerWidth:this._renderingCanvas.width),n=i||(navigator.isCocoonJS?window.innerHeight:this._renderingCanvas.height),o=e.x||0,s=e.y||0;this._cachedViewport=e,this._gl.viewport(o*r,s*n,r*e.width,n*e.height)},a.prototype.setDirectViewport=function(e,t,i,r){this._cachedViewport=null,this._gl.viewport(e,t,i,r)},a.prototype.beginFrame=function(){this._measureFps()},a.prototype.endFrame=function(){},a.prototype.resize=function(){var e=navigator.isCocoonJS?window.innerWidth:this._renderingCanvas.clientWidth,t=navigator.isCocoonJS?window.innerHeight:this._renderingCanvas.clientHeight;this.setSize(e/this._hardwareScalingLevel,t/this._hardwareScalingLevel)},a.prototype.setSize=function(e,t){this._renderingCanvas.width=e,this._renderingCanvas.height=t;for(var i=0;i<this.scenes.length;i++)for(var r=this.scenes[i],n=0;n<r.cameras.length;n++){r.cameras[n]._currentRenderId=0}},a.prototype.bindFramebuffer=function(e,t){this._currentRenderTarget=e;var i=this._gl;i.bindFramebuffer(i.FRAMEBUFFER,e._framebuffer),e.isCube?i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+t,e,0):i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0),this._gl.viewport(0,0,e._width,e._height),this.wipeCaches()},a.prototype.unBindFramebuffer=function(e,t){if(void 0===t&&(t=!1),this._currentRenderTarget=null,e.generateMipMaps&&!t){var i=this._gl;i.bindTexture(i.TEXTURE_2D,e),i.generateMipmap(i.TEXTURE_2D),i.bindTexture(i.TEXTURE_2D,null)}this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,null)},a.prototype.generateMipMapsForCubemap=function(e){if(e.generateMipMaps){var t=this._gl;t.bindTexture(t.TEXTURE_CUBE_MAP,e),t.generateMipmap(t.TEXTURE_CUBE_MAP),t.bindTexture(t.TEXTURE_CUBE_MAP,null)}},a.prototype.flushFramebuffer=function(){this._gl.flush()},a.prototype.restoreDefaultFramebuffer=function(){this._currentRenderTarget=null,this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,null),this.setViewport(this._cachedViewport),this.wipeCaches()},a.prototype._resetVertexBufferBinding=function(){this._gl.bindBuffer(this._gl.ARRAY_BUFFER,null),this._cachedVertexBuffers=null},a.prototype.createVertexBuffer=function(e){var t=this._gl.createBuffer();return this._gl.bindBuffer(this._gl.ARRAY_BUFFER,t),this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(e),this._gl.STATIC_DRAW),this._resetVertexBufferBinding(),t.references=1,t},a.prototype.createDynamicVertexBuffer=function(e){var t=this._gl.createBuffer();return this._gl.bindBuffer(this._gl.ARRAY_BUFFER,t),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),this._resetVertexBufferBinding(),t.references=1,t},a.prototype.updateDynamicVertexBuffer=function(e,t,i){this._gl.bindBuffer(this._gl.ARRAY_BUFFER,e),void 0===i&&(i=0),t instanceof Float32Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,t):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,new Float32Array(t)),this._resetVertexBufferBinding()},a.prototype._resetIndexBufferBinding=function(){this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,null),this._cachedIndexBuffer=null},a.prototype.createIndexBuffer=function(e){var t=this._gl.createBuffer();this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,t);var i,r=!1;if(this._caps.uintIndices){for(var n=0;n<e.length;n++)if(e[n]>65535){r=!0;break}i=r?new Uint32Array(e):new Uint16Array(e)}else i=new Uint16Array(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,i,this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),t.references=1,t.is32Bits=r,t},a.prototype.bindBuffers=function(e,t,i,r,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n,this._gl.bindBuffer(this._gl.ARRAY_BUFFER,e);for(var o=0,s=0;s<i.length;s++){var a=n.getAttributeLocation(s);a>=0&&this._gl.vertexAttribPointer(a,i[s],this._gl.FLOAT,!1,r,o),o+=4*i[s]}}this._cachedIndexBuffer!==t&&(this._cachedIndexBuffer=t,this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,t),this._uintIndicesCurrentlySet=t.is32Bits)},a.prototype.bindMultiBuffers=function(e,t,i){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==i){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i;for(var r=i.getAttributesNames(),n=0;n<r.length;n++){var o=i.getAttributeLocation(n);if(o>=0){var s=e[r[n]];if(!s)continue;var a=s.getStrideSize();this._gl.bindBuffer(this._gl.ARRAY_BUFFER,s.getBuffer()),this._gl.vertexAttribPointer(o,a,this._gl.FLOAT,!1,4*a,0)}}}null!=t&&this._cachedIndexBuffer!==t&&(this._cachedIndexBuffer=t,this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,t),this._uintIndicesCurrentlySet=t.is32Bits)},a.prototype._releaseBuffer=function(e){return e.references--,0===e.references&&(this._gl.deleteBuffer(e),!0)},a.prototype.createInstancesBuffer=function(e){var t=this._gl.createBuffer();return t.capacity=e,this._gl.bindBuffer(this._gl.ARRAY_BUFFER,t),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),t},a.prototype.deleteInstancesBuffer=function(e){this._gl.deleteBuffer(e)},a.prototype.updateAndBindInstancesBuffer=function(e,t,i){this._gl.bindBuffer(this._gl.ARRAY_BUFFER,e),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t);for(var r=0;4>r;r++){var n=i[r];this._gl.enableVertexAttribArray(n),this._gl.vertexAttribPointer(n,4,this._gl.FLOAT,!1,64,16*r),this._caps.instancedArrays.vertexAttribDivisorANGLE(n,1)}},a.prototype.unBindInstancesBuffer=function(e,t){this._gl.bindBuffer(this._gl.ARRAY_BUFFER,e);for(var i=0;4>i;i++){var r=t[i];this._gl.disableVertexAttribArray(r),this._caps.instancedArrays.vertexAttribDivisorANGLE(r,0)}},a.prototype.applyStates=function(){this._depthCullingState.apply(this._gl),this._alphaState.apply(this._gl)},a.prototype.draw=function(e,t,i,r){this.applyStates(),this._drawCalls++;var n=this._uintIndicesCurrentlySet?this._gl.UNSIGNED_INT:this._gl.UNSIGNED_SHORT,o=this._uintIndicesCurrentlySet?4:2;return r?void this._caps.instancedArrays.drawElementsInstancedANGLE(e?this._gl.TRIANGLES:this._gl.LINES,i,n,t*o,r):void this._gl.drawElements(e?this._gl.TRIANGLES:this._gl.LINES,i,n,t*o)},a.prototype.drawPointClouds=function(e,t,i){return this.applyStates(),this._drawCalls++,i?void this._caps.instancedArrays.drawArraysInstancedANGLE(this._gl.POINTS,e,t,i):void this._gl.drawArrays(this._gl.POINTS,e,t)},a.prototype._releaseEffect=function(e){this._compiledEffects[e._key]&&(delete this._compiledEffects[e._key],e.getProgram()&&this._gl.deleteProgram(e.getProgram()))},a.prototype.createEffect=function(t,i,r,n,o,s,a,h){var c=(t.vertexElement||t.vertex||t)+"+"+(t.fragmentElement||t.fragment||t)+"@"+o;if(this._compiledEffects[c])return this._compiledEffects[c];var l=new e.Effect(t,i,r,n,this,o,s,a,h);return l._key=c,this._compiledEffects[c]=l,l},a.prototype.createEffectForParticles=function(e,t,i,r,n,o,s){return void 0===t&&(t=[]),void 0===i&&(i=[]),void 0===r&&(r=""),this.createEffect({vertex:"particles",fragmentElement:e},["position","color","options"],["view","projection"].concat(t),["diffuseSampler"].concat(i),r,n,o,s)},a.prototype.createShaderProgram=function(e,t,i){var n=r(this._gl,e,"vertex",i),o=r(this._gl,t,"fragment",i),s=this._gl.createProgram();if(this._gl.attachShader(s,n),this._gl.attachShader(s,o),this._gl.linkProgram(s),!this._gl.getProgramParameter(s,this._gl.LINK_STATUS)){var a=this._gl.getProgramInfoLog(s);if(a)throw new Error(a)}return this._gl.deleteShader(n),this._gl.deleteShader(o),s},a.prototype.getUniforms=function(e,t){for(var i=[],r=0;r<t.length;r++)i.push(this._gl.getUniformLocation(e,t[r]));return i},a.prototype.getAttributes=function(e,t){for(var i=[],r=0;r<t.length;r++)try{i.push(this._gl.getAttribLocation(e,t[r]))}catch(e){i.push(-1)}return i},a.prototype.enableEffect=function(e){if(e&&e.getAttributesCount()&&this._currentEffect!==e){for(var t in this._vertexAttribArrays=this._vertexAttribArrays||[],this._gl.useProgram(e.getProgram()),this._vertexAttribArrays)t>this._gl.VERTEX_ATTRIB_ARRAY_ENABLED||!this._vertexAttribArrays[t]||(this._vertexAttribArrays[t]=!1,this._gl.disableVertexAttribArray(t));for(var i=e.getAttributesCount(),r=0;i>r;r++){var n=e.getAttributeLocation(r);n>=0&&(this._vertexAttribArrays[n]=!0,this._gl.enableVertexAttribArray(n))}this._currentEffect=e,e.onBind&&e.onBind(e)}else e&&e.onBind&&e.onBind(e)},a.prototype.setArray=function(e,t){e&&this._gl.uniform1fv(e,t)},a.prototype.setArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2fv(e,t)},a.prototype.setArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3fv(e,t)},a.prototype.setArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4fv(e,t)},a.prototype.setMatrices=function(e,t){e&&this._gl.uniformMatrix4fv(e,!1,t)},a.prototype.setMatrix=function(e,t){e&&this._gl.uniformMatrix4fv(e,!1,t.toArray())},a.prototype.setMatrix3x3=function(e,t){e&&this._gl.uniformMatrix3fv(e,!1,t)},a.prototype.setMatrix2x2=function(e,t){e&&this._gl.uniformMatrix2fv(e,!1,t)},a.prototype.setFloat=function(e,t){e&&this._gl.uniform1f(e,t)},a.prototype.setFloat2=function(e,t,i){e&&this._gl.uniform2f(e,t,i)},a.prototype.setFloat3=function(e,t,i,r){e&&this._gl.uniform3f(e,t,i,r)},a.prototype.setBool=function(e,t){e&&this._gl.uniform1i(e,t)},a.prototype.setFloat4=function(e,t,i,r,n){e&&this._gl.uniform4f(e,t,i,r,n)},a.prototype.setColor3=function(e,t){e&&this._gl.uniform3f(e,t.r,t.g,t.b)},a.prototype.setColor4=function(e,t,i){e&&this._gl.uniform4f(e,t.r,t.g,t.b,i)},a.prototype.setState=function(e,t,i,r){void 0===t&&(t=0),void 0===r&&(r=!1);var n=r?this._gl.FRONT:this._gl.BACK,o=r?this._gl.BACK:this._gl.FRONT,s=this.cullBackFaces?n:o;(this._depthCullingState.cull!==e||i||this._depthCullingState.cullFace!==s)&&(e?(this._depthCullingState.cullFace=s,this._depthCullingState.cull=!0):this._depthCullingState.cull=!1),this._depthCullingState.zOffset=t},a.prototype.setDepthBuffer=function(e){this._depthCullingState.depthTest=e},a.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask},a.prototype.setDepthWrite=function(e){this._depthCullingState.depthMask=e},a.prototype.setColorWrite=function(e){this._gl.colorMask(e,e,e,e)},a.prototype.setAlphaMode=function(e){if(this._alphaMode!==e){switch(e){case a.ALPHA_DISABLE:this.setDepthWrite(!0),this._alphaState.alphaBlend=!1;break;case a.ALPHA_COMBINE:this.setDepthWrite(!1),this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case a.ALPHA_ONEONE:this.setDepthWrite(!1),this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case a.ALPHA_ADD:this.setDepthWrite(!1),this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case a.ALPHA_SUBTRACT:this.setDepthWrite(!1),this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case a.ALPHA_MULTIPLY:this.setDepthWrite(!1),this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR,this._gl.ZERO,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case a.ALPHA_MAXIMIZED:this.setDepthWrite(!1),this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0}this._alphaMode=e}},a.prototype.getAlphaMode=function(){return this._alphaMode},a.prototype.setAlphaTesting=function(e){this._alphaTest=e},a.prototype.getAlphaTesting=function(){return this._alphaTest},a.prototype.wipeCaches=function(){this._activeTexturesCache=[],this._currentEffect=null,this._depthCullingState.reset(),this._alphaState.reset(),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null},a.prototype.setSamplingMode=function(t,i){var r=this._gl;r.bindTexture(r.TEXTURE_2D,t);var n=r.NEAREST,o=r.NEAREST;i===e.Texture.BILINEAR_SAMPLINGMODE?(n=r.LINEAR,o=r.LINEAR):i===e.Texture.TRILINEAR_SAMPLINGMODE&&(n=r.LINEAR,o=r.LINEAR_MIPMAP_LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,n),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,o),r.bindTexture(r.TEXTURE_2D,null),t.samplingMode=i},a.prototype.createTexture=function(t,i,r,n,o,a,h,c){var l=this;void 0===o&&(o=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=null),void 0===h&&(h=null),void 0===c&&(c=null);var u,d=this._gl.createTexture(),f=!1;if("data:"===t.substr(0,5)&&(f=!0),f){var p=t;t=p,u=(f=p.split(":"))[1].substr(f[1].length-4,4).toLowerCase()}else u=t.substr(t.length-4,4).toLowerCase();var m=this.getCaps().s3tc&&".dds"===u,g=".tga"===u;n._addPendingData(d),d.url=t,d.noMipmap=i,d.references=1,d.samplingMode=o,this._loadedTexturesCache.push(d);var v,_=function(){n._removePendingData(d),h&&h()};if(g)v=function(t){var h=new Uint8Array(t),c=e.Internals.TGATools.GetTGAHeader(h);s(d,l._gl,n,c.width,c.height,r,i,!1,function(){e.Internals.TGATools.UploadContent(l._gl,h),a&&a()},o)},f instanceof Array?v(c):e.Tools.LoadFile(t,function(e){v(e)},_,n.database,!0);else if(m)v=function(t){var h=e.Internals.DDSTools.GetDDSInfo(t),c=(h.isRGB||h.isLuminance||h.mipmapCount>1)&&!i&&h.width>>h.mipmapCount-1==1;s(d,l._gl,n,h.width,h.height,r,!c,h.isFourCC,function(){e.Internals.DDSTools.UploadDDSLevels(l._gl,l.getCaps().s3tc,t,h,c,1),a&&a()},o)},f instanceof Array?v(c):e.Tools.LoadFile(t,function(e){v(e)},_,n.database,!0);else{var y=function(t){s(d,l._gl,n,t.width,t.height,r,i,!1,function(i,r){var n=t.width===i&&t.height===r;n||(l._prepareWorkingCanvas(),l._workingCanvas.width=i,l._workingCanvas.height=r,o===e.Texture.NEAREST_SAMPLINGMODE&&(l._workingContext.imageSmoothingEnabled=!1,l._workingContext.mozImageSmoothingEnabled=!1,l._workingContext.oImageSmoothingEnabled=!1,l._workingContext.webkitImageSmoothingEnabled=!1,l._workingContext.msImageSmoothingEnabled=!1),l._workingContext.drawImage(t,0,0,t.width,t.height,0,0,i,r),o===e.Texture.NEAREST_SAMPLINGMODE&&(l._workingContext.imageSmoothingEnabled=!0,l._workingContext.mozImageSmoothingEnabled=!0,l._workingContext.oImageSmoothingEnabled=!0,l._workingContext.webkitImageSmoothingEnabled=!0,l._workingContext.msImageSmoothingEnabled=!0)),l._gl.texImage2D(l._gl.TEXTURE_2D,0,l._gl.RGBA,l._gl.RGBA,l._gl.UNSIGNED_BYTE,n?t:l._workingCanvas),a&&a()},o)};f instanceof Array?e.Tools.LoadImage(c,y,_,n.database):e.Tools.LoadImage(t,y,_,n.database)}return d},a.prototype.updateRawTexture=function(e,t,i,r,n){void 0===n&&(n=null);var o=this._gl.RGBA;switch(i){case a.TEXTUREFORMAT_ALPHA:o=this._gl.ALPHA;break;case a.TEXTUREFORMAT_LUMINANCE:o=this._gl.LUMINANCE;break;case a.TEXTUREFORMAT_LUMINANCE_ALPHA:o=this._gl.LUMINANCE_ALPHA;break;case a.TEXTUREFORMAT_RGB:o=this._gl.RGB;break;case a.TEXTUREFORMAT_RGBA:o=this._gl.RGBA}this._gl.bindTexture(this._gl.TEXTURE_2D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,void 0===r?1:r?1:0),n?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[n],e._width,e._height,0,t):this._gl.texImage2D(this._gl.TEXTURE_2D,0,o,e._width,e._height,0,o,this._gl.UNSIGNED_BYTE,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._activeTexturesCache=[],e.isReady=!0},a.prototype.createRawTexture=function(e,t,i,r,n,s,a,h){void 0===h&&(h=null);var c=this._gl.createTexture();c._baseWidth=t,c._baseHeight=i,c._width=t,c._height=i,c.references=1,this.updateRawTexture(c,e,r,s,h),this._gl.bindTexture(this._gl.TEXTURE_2D,c);var l=o(a,n,this._gl);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,l.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,l.min),this._gl.bindTexture(this._gl.TEXTURE_2D,null),c.samplingMode=a,this._loadedTexturesCache.push(c),c},a.prototype.createDynamicTexture=function(t,i,r,n,o){void 0===o&&(o=!0);var s=this._gl.createTexture();return s._baseWidth=t,s._baseHeight=i,o&&(t=e.Tools.GetExponentOfTwo(t,this._caps.maxTextureSize),i=e.Tools.GetExponentOfTwo(i,this._caps.maxTextureSize)),this._activeTexturesCache=[],s._width=t,s._height=i,s.isReady=!1,s.generateMipMaps=r,s.references=1,s.samplingMode=n,this.updateTextureSamplingMode(n,s),this._loadedTexturesCache.push(s),s},a.prototype.updateTextureSamplingMode=function(e,t){var i=o(e,t.generateMipMaps,this._gl);this._gl.bindTexture(this._gl.TEXTURE_2D,t),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,i.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,i.min),this._gl.bindTexture(this._gl.TEXTURE_2D,null)},a.prototype.updateDynamicTexture=function(e,t,i){this._gl.bindTexture(this._gl.TEXTURE_2D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,i?1:0),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._activeTexturesCache=[],e.isReady=!0},a.prototype.updateVideoTexture=function(e,t,i){if(!e._isDisabled){this._gl.bindTexture(this._gl.TEXTURE_2D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,i?0:1);try{void 0===this._videoTextureSupported&&(this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t),this._videoTextureSupported=0===this._gl.getError()),this._videoTextureSupported?this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t):(e._workingCanvas||(e._workingCanvas=document.createElement("canvas"),e._workingContext=e._workingCanvas.getContext("2d"),e._workingCanvas.width=e._width,e._workingCanvas.height=e._height),e._workingContext.drawImage(t,0,0,t.videoWidth,t.videoHeight,0,0,e._width,e._height),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,e._workingCanvas)),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._activeTexturesCache=[],e.isReady=!0}catch(t){e._isDisabled=!0}}},a.prototype.createRenderTargetTexture=function(t,i){var r=!1,s=!0,h=a.TEXTURETYPE_UNSIGNED_INT,c=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(r=void 0===i.generateMipMaps?i:i.generateMipMaps,s=void 0===i.generateDepthBuffer||i.generateDepthBuffer,h=void 0===i.type?h:i.type,void 0!==i.samplingMode&&(c=i.samplingMode),h===a.TEXTURETYPE_FLOAT&&(c=e.Texture.NEAREST_SAMPLINGMODE));var l=this._gl,u=l.createTexture();l.bindTexture(l.TEXTURE_2D,u);var d,f=t.width||t,p=t.height||t,m=o(c,r,l);h!==a.TEXTURETYPE_FLOAT||this._caps.textureFloat||(h=a.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,m.mag),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,m.min),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,f,p,0,l.RGBA,n(l,h),null),s&&(d=l.createRenderbuffer(),l.bindRenderbuffer(l.RENDERBUFFER,d),l.renderbufferStorage(l.RENDERBUFFER,l.DEPTH_COMPONENT16,f,p));var g=l.createFramebuffer();return l.bindFramebuffer(l.FRAMEBUFFER,g),s&&l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_ATTACHMENT,l.RENDERBUFFER,d),r&&this._gl.generateMipmap(this._gl.TEXTURE_2D),l.bindTexture(l.TEXTURE_2D,null),l.bindRenderbuffer(l.RENDERBUFFER,null),l.bindFramebuffer(l.FRAMEBUFFER,null),u._framebuffer=g,s&&(u._depthBuffer=d),u._width=f,u._height=p,u.isReady=!0,u.generateMipMaps=r,u.references=1,u.samplingMode=c,this._activeTexturesCache=[],this._loadedTexturesCache.push(u),u},a.prototype.createRenderTargetCubeTexture=function(t,i){var r=this._gl,n=r.createTexture(),s=!0,a=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(s=void 0===i.generateMipMaps?i:i.generateMipMaps,void 0!==i.samplingMode&&(a=i.samplingMode)),n.isCube=!0,n.references=1,n.generateMipMaps=s,n.references=1,n.samplingMode=a;var h=o(a,s,r);r.bindTexture(r.TEXTURE_CUBE_MAP,n);for(var c=0;6>c;c++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,r.RGBA,t,t,0,r.RGBA,r.UNSIGNED_BYTE,null);r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,h.mag),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,h.min),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);var l=r.createRenderbuffer();r.bindRenderbuffer(r.RENDERBUFFER,l),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT16,t,t);var u=r.createFramebuffer();return r.bindFramebuffer(r.FRAMEBUFFER,u),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,l),r.bindTexture(r.TEXTURE_CUBE_MAP,null),r.bindRenderbuffer(r.RENDERBUFFER,null),r.bindFramebuffer(r.FRAMEBUFFER,null),n._framebuffer=u,n._depthBuffer=l,this._activeTexturesCache=[],n._width=t,n._height=t,n.isReady=!0,n},a.prototype.createCubeTexture=function(t,i,r,n){var o=this,s=this._gl,a=s.createTexture();a.isCube=!0,a.url=t,a.references=1;var c=t.substr(t.length-4,4).toLowerCase();return this.getCaps().s3tc&&".dds"===c?e.Tools.LoadFile(t,function(t){var i=e.Internals.DDSTools.GetDDSInfo(t),r=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&!n;s.bindTexture(s.TEXTURE_CUBE_MAP,a),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,1),e.Internals.DDSTools.UploadDDSLevels(o._gl,o.getCaps().s3tc,t,i,r,6),n||i.isFourCC||1!==i.mipmapCount||s.generateMipmap(s.TEXTURE_CUBE_MAP),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,r?s.LINEAR_MIPMAP_LINEAR:s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.bindTexture(s.TEXTURE_CUBE_MAP,null),o._activeTexturesCache=[],a._width=i.width,a._height=i.height,a.isReady=!0},null,null,!0):h(t,i,function(t){var i=e.Tools.GetExponentOfTwo(t[0].width,o._caps.maxCubemapTextureSize),r=i;o._prepareWorkingCanvas(),o._workingCanvas.width=i,o._workingCanvas.height=r;var h=[s.TEXTURE_CUBE_MAP_POSITIVE_X,s.TEXTURE_CUBE_MAP_POSITIVE_Y,s.TEXTURE_CUBE_MAP_POSITIVE_Z,s.TEXTURE_CUBE_MAP_NEGATIVE_X,s.TEXTURE_CUBE_MAP_NEGATIVE_Y,s.TEXTURE_CUBE_MAP_NEGATIVE_Z];s.bindTexture(s.TEXTURE_CUBE_MAP,a),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,0);for(var c=0;c<h.length;c++)o._workingContext.drawImage(t[c],0,0,t[c].width,t[c].height,0,0,i,r),s.texImage2D(h[c],0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,o._workingCanvas);n||s.generateMipmap(s.TEXTURE_CUBE_MAP),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,n?s.LINEAR:s.LINEAR_MIPMAP_LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.bindTexture(s.TEXTURE_CUBE_MAP,null),o._activeTexturesCache=[],a._width=i,a._height=r,a.isReady=!0},r),a},a.prototype._releaseTexture=function(e){var t=this._gl;e._framebuffer&&t.deleteFramebuffer(e._framebuffer),e._depthBuffer&&t.deleteRenderbuffer(e._depthBuffer),t.deleteTexture(e);for(var i=0;i<this._caps.maxTexturesImageUnits;i++)this._gl.activeTexture(this._gl["TEXTURE"+i]),this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._gl.bindTexture(this._gl.TEXTURE_CUBE_MAP,null),this._activeTexturesCache[i]=null;var r=this._loadedTexturesCache.indexOf(e);-1!==r&&this._loadedTexturesCache.splice(r,1)},a.prototype.bindSamplers=function(e){this._gl.useProgram(e.getProgram());for(var t=e.getSamplers(),i=0;i<t.length;i++){var r=e.getUniform(t[i]);this._gl.uniform1i(r,i)}this._currentEffect=null},a.prototype._bindTexture=function(e,t){this._gl.activeTexture(this._gl["TEXTURE"+e]),this._gl.bindTexture(this._gl.TEXTURE_2D,t),this._activeTexturesCache[e]=null},a.prototype.setTextureFromPostProcess=function(e,t){this._bindTexture(e,t._textures.data[t._currentRenderTextureInd])},a.prototype.setTexture=function(t,i){if(!(0>t)){if(!i||!i.isReady())return void(null!=this._activeTexturesCache[t]&&(this._gl.activeTexture(this._gl["TEXTURE"+t]),this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._gl.bindTexture(this._gl.TEXTURE_CUBE_MAP,null),this._activeTexturesCache[t]=null));if(i instanceof e.VideoTexture)i.update()&&(this._activeTexturesCache[t]=null);else if(i.delayLoadState===a.DELAYLOADSTATE_NOTLOADED)return void i.delayLoad();if(this._activeTexturesCache[t]!==i){this._activeTexturesCache[t]=i;var r=i.getInternalTexture();if(this._gl.activeTexture(this._gl["TEXTURE"+t]),r.isCube){if(this._gl.bindTexture(this._gl.TEXTURE_CUBE_MAP,r),r._cachedCoordinatesMode!==i.coordinatesMode){r._cachedCoordinatesMode=i.coordinatesMode;var n=i.coordinatesMode!==e.Texture.CUBIC_MODE&&i.coordinatesMode!==e.Texture.SKYBOX_MODE?this._gl.REPEAT:this._gl.CLAMP_TO_EDGE;this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_S,n),this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_T,n)}this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP,i)}else{if(this._gl.bindTexture(this._gl.TEXTURE_2D,r),r._cachedWrapU!==i.wrapU)switch(r._cachedWrapU=i.wrapU,i.wrapU){case e.Texture.WRAP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.REPEAT);break;case e.Texture.CLAMP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE);break;case e.Texture.MIRROR_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.MIRRORED_REPEAT)}if(r._cachedWrapV!==i.wrapV)switch(r._cachedWrapV=i.wrapV,i.wrapV){case e.Texture.WRAP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.REPEAT);break;case e.Texture.CLAMP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);break;case e.Texture.MIRROR_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.MIRRORED_REPEAT)}this._setAnisotropicLevel(this._gl.TEXTURE_2D,i)}}}},a.prototype._setAnisotropicLevel=function(t,i){var r=this._caps.textureAnisotropicFilterExtension,n=i.anisotropicFilteringLevel;i.getInternalTexture().samplingMode===e.Texture.NEAREST_SAMPLINGMODE&&(n=1),r&&i._cachedAnisotropicFilteringLevel!==n&&(this._gl.texParameterf(t,r.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(n,this._caps.maxAnisotropy)),i._cachedAnisotropicFilteringLevel=n)},a.prototype.readPixels=function(e,t,i,r){var n=new Uint8Array(r*i*4);return this._gl.readPixels(e,t,i,r,this._gl.RGBA,this._gl.UNSIGNED_BYTE,n),n},a.prototype.releaseInternalTexture=function(e){if(e&&(e.references--,0===e.references)){var t=this.getLoadedTexturesCache(),i=t.indexOf(e);i>-1&&t.splice(i,1),this._releaseTexture(e)}},a.prototype.dispose=function(){for(this.hideLoadingUI(),this.stopRenderLoop();this.scenes.length;)this.scenes[0].dispose();for(var e in a.audioEngine.dispose(),this._compiledEffects)this._gl.deleteProgram(this._compiledEffects[e]._program);for(var t in this._vertexAttribArrays)t>this._gl.VERTEX_ATTRIB_ARRAY_ENABLED||!this._vertexAttribArrays[t]||this._gl.disableVertexAttribArray(t);this._gl=null,window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),document.removeEventListener("fullscreenchange",this._onFullscreenChange),document.removeEventListener("mozfullscreenchange",this._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",this._onFullscreenChange),document.removeEventListener("msfullscreenchange",this._onFullscreenChange),document.removeEventListener("pointerlockchange",this._onPointerLockChange),document.removeEventListener("mspointerlockchange",this._onPointerLockChange),document.removeEventListener("mozpointerlockchange",this._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",this._onPointerLockChange)},a.prototype.displayLoadingUI=function(){this._loadingScreen.displayLoadingUI()},a.prototype.hideLoadingUI=function(){this._loadingScreen.hideLoadingUI()},Object.defineProperty(a.prototype,"loadingScreen",{get:function(){return this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"loadingUIText",{set:function(e){this._loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"loadingUIBackgroundColor",{set:function(e){this._loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),a.prototype.getFps=function(){return this.fps},a.prototype.getDeltaTime=function(){return this.deltaTime},a.prototype._measureFps=function(){this.previousFramesDuration.push(e.Tools.Now);var t=this.previousFramesDuration.length;if(t>=2&&(this.deltaTime=this.previousFramesDuration[t-1]-this.previousFramesDuration[t-2]),t>=this.fpsRange){t>this.fpsRange&&(this.previousFramesDuration.splice(0,1),t=this.previousFramesDuration.length);for(var i=0,r=0;t-1>r;r++)i+=this.previousFramesDuration[r+1]-this.previousFramesDuration[r];this.fps=1e3/(i/(t-1))}},a.isSupported=function(){try{if(navigator.isCocoonJS)return!0;var e=document.createElement("canvas");return null!=(e.getContext("webgl")||e.getContext("experimental-webgl"))&&!!window.WebGLRenderingContext}catch(e){return!1}},a._ALPHA_DISABLE=0,a._ALPHA_ADD=1,a._ALPHA_COMBINE=2,a._ALPHA_SUBTRACT=3,a._ALPHA_MULTIPLY=4,a._ALPHA_MAXIMIZED=5,a._ALPHA_ONEONE=6,a._DELAYLOADSTATE_NONE=0,a._DELAYLOADSTATE_LOADED=1,a._DELAYLOADSTATE_LOADING=2,a._DELAYLOADSTATE_NOTLOADED=4,a._TEXTUREFORMAT_ALPHA=0,a._TEXTUREFORMAT_LUMINANCE=1,a._TEXTUREFORMAT_LUMINANCE_ALPHA=2,a._TEXTUREFORMAT_RGB=4,a._TEXTUREFORMAT_RGBA=5,a._TEXTURETYPE_UNSIGNED_INT=0,a._TEXTURETYPE_FLOAT=1,a.Epsilon=.001,a.CollisionsEpsilon=.001,a.CodeRepository="src/",a.ShadersRepository="src/Shaders/",a}();e.Engine=l}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(e,t){this.state="",this.animations=new Array,this._childrenFlag=-1,this._isEnabled=!0,this._isReady=!0,this._currentRenderId=-1,this._parentRenderId=-1,this.name=e,this.id=e,this._scene=t,this._initCache()}return t.prototype.getScene=function(){return this._scene},t.prototype.getEngine=function(){return this._scene.getEngine()},t.prototype.getWorldMatrix=function(){return e.Matrix.Identity()},t.prototype._initCache=function(){this._cache={},this._cache.parent=void 0},t.prototype.updateCache=function(e){(e||!this.isSynchronized())&&(this._cache.parent=this.parent,this._updateCache())},t.prototype._updateCache=function(e){},t.prototype._isSynchronized=function(){return!0},t.prototype._markSyncedWithParent=function(){this._parentRenderId=this.parent._currentRenderId},t.prototype.isSynchronizedWithParent=function(){return!this.parent||this._parentRenderId===this.parent._currentRenderId&&this.parent.isSynchronized()},t.prototype.isSynchronized=function(e){var t=this.hasNewParent();return t=(t=t||!this.isSynchronizedWithParent())||!this._isSynchronized(),e&&this.updateCache(!0),!t},t.prototype.hasNewParent=function(e){return this._cache.parent!==this.parent&&(e&&(this._cache.parent=this.parent),!0)},t.prototype.isReady=function(){return this._isReady},t.prototype.isEnabled=function(){return!!this._isEnabled&&(!this.parent||this.parent.isEnabled())},t.prototype.setEnabled=function(e){this._isEnabled=e},t.prototype.isDescendantOf=function(e){return!!this.parent&&(this.parent===e||this.parent.isDescendantOf(e))},t.prototype._getDescendants=function(e,t){for(var i=0;i<e.length;i++){var r=e[i];r.isDescendantOf(this)&&t.push(r)}},t.prototype.getDescendants=function(){var e=[];return this._getDescendants(this._scene.meshes,e),this._getDescendants(this._scene.lights,e),this._getDescendants(this._scene.cameras,e),e},t.prototype._setReady=function(e){if(e!=this._isReady){if(!e)return void(this._isReady=!1);this._isReady=!0,this.onReady&&this.onReady(this)}},t}();e.Node=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(e,t,i,r,n,o,s,a){this._engine=e,this._canvas=i,this._currentScene=t,this._sceneLoadedCallback=r,this._progressCallback=n,this._additionnalRenderLoopLogicCallback=o,this._textureLoadingCallback=s,this._startingProcessingFilesCallback=a}return t.prototype.monitorElementForDragNDrop=function(e){var t=this;e&&(this._elementToMonitor=e,this._elementToMonitor.addEventListener("dragenter",function(e){t.drag(e)},!1),this._elementToMonitor.addEventListener("dragover",function(e){t.drag(e)},!1),this._elementToMonitor.addEventListener("drop",function(e){t.drop(e)},!1))},t.prototype.renderFunction=function(){if(this._additionnalRenderLoopLogicCallback&&this._additionnalRenderLoopLogicCallback(),this._currentScene){if(this._textureLoadingCallback){var e=this._currentScene.getWaitingItemsCount();e>0&&this._textureLoadingCallback(e)}this._currentScene.render()}},t.prototype.drag=function(e){e.stopPropagation(),e.preventDefault()},t.prototype.drop=function(e){e.stopPropagation(),e.preventDefault(),this.loadFiles(e)},t.prototype.loadFiles=function(e){if(this._startingProcessingFilesCallback&&this._startingProcessingFilesCallback(),e&&e.dataTransfer&&e.dataTransfer.files&&(this._filesToLoad=e.dataTransfer.files),e&&e.target&&e.target.files&&(this._filesToLoad=e.target.files),this._filesToLoad&&this._filesToLoad.length>0){for(var i=0;i<this._filesToLoad.length;i++)switch(this._filesToLoad[i].type){case"image/jpeg":case"image/png":case"image/bmp":t.FilesTextures[this._filesToLoad[i].name]=this._filesToLoad[i];break;case"image/targa":case"image/vnd.ms-dds":case"audio/wav":case"audio/x-wav":case"audio/mp3":case"audio/mpeg":case"audio/mpeg3":case"audio/x-mpeg-3":case"audio/ogg":t.FilesToLoad[this._filesToLoad[i].name]=this._filesToLoad[i];break;default:-1===this._filesToLoad[i].name.indexOf(".babylon")&&-1===this._filesToLoad[i].name.indexOf(".stl")&&-1===this._filesToLoad[i].name.indexOf(".obj")&&-1===this._filesToLoad[i].name.indexOf(".mtl")||-1!==this._filesToLoad[i].name.indexOf(".manifest")||-1!==this._filesToLoad[i].name.indexOf(".incremental")||-1!==this._filesToLoad[i].name.indexOf(".babylonmeshdata")||-1!==this._filesToLoad[i].name.indexOf(".babylongeometrydata")||-1!==this._filesToLoad[i].name.indexOf(".babylonbinarymeshdata")||-1!==this._filesToLoad[i].name.indexOf(".binary.babylon")||(this._sceneFileToLoad=this._filesToLoad[i])}this.reload()}},t.prototype.reload=function(){var t=this,i=this;this._sceneFileToLoad?(this._currentScene&&(e.Tools.errorsCount>0&&(e.Tools.ClearLogCache(),e.Tools.Log("Babylon.js engine (v"+e.Engine.Version+") launched")),this._engine.stopRenderLoop(),this._currentScene.dispose()),e.SceneLoader.Load("file:",this._sceneFileToLoad,this._engine,function(e){i._currentScene=e,i._currentScene.executeWhenReady(function(){i._currentScene.activeCamera&&0!==i._currentScene.lights.length||i._currentScene.createDefaultCameraOrLight(),i._currentScene.activeCamera.attachControl(i._canvas),i._sceneLoadedCallback&&i._sceneLoadedCallback(t._sceneFileToLoad,i._currentScene),i._engine.runRenderLoop(function(){i.renderFunction()})})},function(e){t._progressCallback&&t._progressCallback(e)})):e.Tools.Error("Please provide a valid .babylon file.")},t.FilesTextures=new Array,t.FilesToLoad=new Array,t}();e.FilesInput=t}(BABYLON||(BABYLON={})),function(e){var t=function(){return function(e,t,i){this.bu=e,this.bv=t,this.distance=i,this.faceId=0,this.subMeshId=0}}();e.IntersectionInfo=t;var i=function(){function t(){this.hit=!1,this.distance=0,this.pickedPoint=null,this.pickedMesh=null,this.bu=0,this.bv=0,this.faceId=-1,this.subMeshId=0,this.pickedSprite=null}return t.prototype.getNormal=function(t,i){if(void 0===t&&(t=!1),void 0===i&&(i=!0),!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e.VertexBuffer.NormalKind))return null;var r,n=this.pickedMesh.getIndices();if(i){var o=this.pickedMesh.getVerticesData(e.VertexBuffer.NormalKind),s=e.Vector3.FromArray(o,3*n[3*this.faceId]),a=e.Vector3.FromArray(o,3*n[3*this.faceId+1]),h=e.Vector3.FromArray(o,3*n[3*this.faceId+2]);s=s.scale(this.bu),a=a.scale(this.bv),h=h.scale(1-this.bu-this.bv),r=new e.Vector3(s.x+a.x+h.x,s.y+a.y+h.y,s.z+a.z+h.z)}else{var c=this.pickedMesh.getVerticesData(e.VertexBuffer.PositionKind),l=e.Vector3.FromArray(c,3*n[3*this.faceId]),u=e.Vector3.FromArray(c,3*n[3*this.faceId+1]),d=e.Vector3.FromArray(c,3*n[3*this.faceId+2]),f=l.subtract(u),p=d.subtract(u);r=e.Vector3.Cross(f,p)}return t&&(r=e.Vector3.TransformNormal(r,this.pickedMesh.getWorldMatrix())),e.Vector3.Normalize(r)},t.prototype.getTextureCoordinates=function(){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e.VertexBuffer.UVKind))return null;var t=this.pickedMesh.getIndices(),i=this.pickedMesh.getVerticesData(e.VertexBuffer.UVKind),r=e.Vector2.FromArray(i,2*t[3*this.faceId]),n=e.Vector2.FromArray(i,2*t[3*this.faceId+1]),o=e.Vector2.FromArray(i,2*t[3*this.faceId+2]);return r=r.scale(1-this.bu-this.bv),n=n.scale(this.bu),o=o.scale(this.bv),new e.Vector2(r.x+n.x+o.x,r.y+n.y+o.y)},t}();e.PickingInfo=i}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t,i){this.minimum=t,this.maximum=i,this._tempRadiusVector=e.Vector3.Zero();var r=e.Vector3.Distance(t,i);this.center=e.Vector3.Lerp(t,i,.5),this.radius=.5*r,this.centerWorld=e.Vector3.Zero(),this._update(e.Matrix.Identity())}return t.prototype._update=function(t){e.Vector3.TransformCoordinatesToRef(this.center,t,this.centerWorld),e.Vector3.TransformNormalFromFloatsToRef(1,1,1,t,this._tempRadiusVector),this.radiusWorld=Math.max(Math.abs(this._tempRadiusVector.x),Math.abs(this._tempRadiusVector.y),Math.abs(this._tempRadiusVector.z))*this.radius},t.prototype.isInFrustum=function(e){for(var t=0;6>t;t++)if(e[t].dotCoordinate(this.centerWorld)<=-this.radiusWorld)return!1;return!0},t.prototype.intersectsPoint=function(t){var i=this.centerWorld.x-t.x,r=this.centerWorld.y-t.y,n=this.centerWorld.z-t.z,o=Math.sqrt(i*i+r*r+n*n);return!(Math.abs(this.radiusWorld-o)<e.Engine.Epsilon)},t.Intersects=function(e,t){var i=e.centerWorld.x-t.centerWorld.x,r=e.centerWorld.y-t.centerWorld.y,n=e.centerWorld.z-t.centerWorld.z,o=Math.sqrt(i*i+r*r+n*n);return!(e.radiusWorld+t.radiusWorld<o)},t}();e.BoundingSphere=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t,i){this.minimum=t,this.maximum=i,this.vectors=new Array,this.vectorsWorld=new Array,this.vectors.push(this.minimum.clone()),this.vectors.push(this.maximum.clone()),this.vectors.push(this.minimum.clone()),this.vectors[2].x=this.maximum.x,this.vectors.push(this.minimum.clone()),this.vectors[3].y=this.maximum.y,this.vectors.push(this.minimum.clone()),this.vectors[4].z=this.maximum.z,this.vectors.push(this.maximum.clone()),this.vectors[5].z=this.minimum.z,this.vectors.push(this.maximum.clone()),this.vectors[6].x=this.minimum.x,this.vectors.push(this.maximum.clone()),this.vectors[7].y=this.minimum.y,this.center=this.maximum.add(this.minimum).scale(.5),this.extendSize=this.maximum.subtract(this.minimum).scale(.5),this.directions=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()];for(var r=0;r<this.vectors.length;r++)this.vectorsWorld[r]=e.Vector3.Zero();this.minimumWorld=e.Vector3.Zero(),this.maximumWorld=e.Vector3.Zero(),this._update(e.Matrix.Identity())}return t.prototype.getWorldMatrix=function(){return this._worldMatrix},t.prototype._update=function(t){e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,this.minimumWorld),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,this.maximumWorld);for(var i=0;i<this.vectors.length;i++){var r=this.vectorsWorld[i];e.Vector3.TransformCoordinatesToRef(this.vectors[i],t,r),r.x<this.minimumWorld.x&&(this.minimumWorld.x=r.x),r.y<this.minimumWorld.y&&(this.minimumWorld.y=r.y),r.z<this.minimumWorld.z&&(this.minimumWorld.z=r.z),r.x>this.maximumWorld.x&&(this.maximumWorld.x=r.x),r.y>this.maximumWorld.y&&(this.maximumWorld.y=r.y),r.z>this.maximumWorld.z&&(this.maximumWorld.z=r.z)}this.maximumWorld.addToRef(this.minimumWorld,this.center),this.center.scaleInPlace(.5),e.Vector3.FromFloatArrayToRef(t.m,0,this.directions[0]),e.Vector3.FromFloatArrayToRef(t.m,4,this.directions[1]),e.Vector3.FromFloatArrayToRef(t.m,8,this.directions[2]),this._worldMatrix=t},t.prototype.isInFrustum=function(e){return t.IsInFrustum(this.vectorsWorld,e)},t.prototype.isCompletelyInFrustum=function(e){return t.IsCompletelyInFrustum(this.vectorsWorld,e)},t.prototype.intersectsPoint=function(t){var i=-e.Engine.Epsilon;return!(this.maximumWorld.x-t.x<i||i>t.x-this.minimumWorld.x)&&(!(this.maximumWorld.y-t.y<i||i>t.y-this.minimumWorld.y)&&!(this.maximumWorld.z-t.z<i||i>t.z-this.minimumWorld.z))},t.prototype.intersectsSphere=function(e){return t.IntersectsSphere(this.minimumWorld,this.maximumWorld,e.centerWorld,e.radiusWorld)},t.prototype.intersectsMinMax=function(e,t){return!(this.maximumWorld.x<e.x||this.minimumWorld.x>t.x)&&(!(this.maximumWorld.y<e.y||this.minimumWorld.y>t.y)&&!(this.maximumWorld.z<e.z||this.minimumWorld.z>t.z))},t.Intersects=function(e,t){return!(e.maximumWorld.x<t.minimumWorld.x||e.minimumWorld.x>t.maximumWorld.x)&&(!(e.maximumWorld.y<t.minimumWorld.y||e.minimumWorld.y>t.maximumWorld.y)&&!(e.maximumWorld.z<t.minimumWorld.z||e.minimumWorld.z>t.maximumWorld.z))},t.IntersectsSphere=function(t,i,r,n){var o=e.Vector3.Clamp(r,t,i);return n*n>=e.Vector3.DistanceSquared(r,o)},t.IsCompletelyInFrustum=function(e,t){for(var i=0;6>i;i++)for(var r=0;8>r;r++)if(t[i].dotCoordinate(e[r])<0)return!1;return!0},t.IsInFrustum=function(e,t){for(var i=0;6>i;i++){for(var r=8,n=0;8>n&&t[i].dotCoordinate(e[n])<0;n++)--r;if(0===r)return!1}return!0},t}();e.BoundingBox=t}(BABYLON||(BABYLON={})),function(e){var t=function(t,i){var r=e.Vector3.Dot(i.center,t),n=Math.abs(e.Vector3.Dot(i.directions[0],t))*i.extendSize.x+Math.abs(e.Vector3.Dot(i.directions[1],t))*i.extendSize.y+Math.abs(e.Vector3.Dot(i.directions[2],t))*i.extendSize.z;return{min:r-n,max:r+n}},i=function(e,i,r){var n=t(e,i),o=t(e,r);return function(e,t,i,r){return!(e>r||i>t)}(n.min,n.max,o.min,o.max)},r=function(){function t(t,i){this.minimum=t,this.maximum=i,this.boundingBox=new e.BoundingBox(t,i),this.boundingSphere=new e.BoundingSphere(t,i)}return t.prototype._update=function(e){this.boundingBox._update(e),this.boundingSphere._update(e)},t.prototype.isInFrustum=function(e){return!!this.boundingSphere.isInFrustum(e)&&this.boundingBox.isInFrustum(e)},t.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},t.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},t.prototype.intersectsPoint=function(e){return!!(this.boundingSphere.centerWorld&&this.boundingSphere.intersectsPoint(e)&&this.boundingBox.intersectsPoint(e))},t.prototype.intersects=function(t,r){if(!this.boundingSphere.centerWorld||!t.boundingSphere.centerWorld)return!1;if(!e.BoundingSphere.Intersects(this.boundingSphere,t.boundingSphere))return!1;if(!e.BoundingBox.Intersects(this.boundingBox,t.boundingBox))return!1;if(!r)return!0;var n=this.boundingBox,o=t.boundingBox;return!!(i(n.directions[0],n,o)&&i(n.directions[1],n,o)&&i(n.directions[2],n,o)&&i(o.directions[0],n,o)&&i(o.directions[1],n,o)&&i(o.directions[2],n,o)&&i(e.Vector3.Cross(n.directions[0],o.directions[0]),n,o)&&i(e.Vector3.Cross(n.directions[0],o.directions[1]),n,o)&&i(e.Vector3.Cross(n.directions[0],o.directions[2]),n,o)&&i(e.Vector3.Cross(n.directions[1],o.directions[0]),n,o)&&i(e.Vector3.Cross(n.directions[1],o.directions[1]),n,o)&&i(e.Vector3.Cross(n.directions[1],o.directions[2]),n,o)&&i(e.Vector3.Cross(n.directions[2],o.directions[0]),n,o)&&i(e.Vector3.Cross(n.directions[2],o.directions[1]),n,o)&&i(e.Vector3.Cross(n.directions[2],o.directions[2]),n,o))},t}();e.BoundingInfo=r}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(r,n){var o=this;t.call(this,r,n),this.definedFacingForward=!0,this.position=new e.Vector3(0,0,0),this.rotation=new e.Vector3(0,0,0),this.scaling=new e.Vector3(1,1,1),this.billboardMode=i.BILLBOARDMODE_NONE,this.visibility=1,this.alphaIndex=Number.MAX_VALUE,this.infiniteDistance=!1,this.isVisible=!0,this.isPickable=!0,this.showBoundingBox=!1,this.showSubMeshesBoundingBox=!1,this.onDispose=null,this.isBlocker=!1,this.renderingGroupId=0,this.receiveShadows=!1,this.renderOutline=!1,this.outlineColor=e.Color3.Red(),this.outlineWidth=.02,this.renderOverlay=!1,this.overlayColor=e.Color3.Red(),this.overlayAlpha=.5,this.hasVertexAlpha=!1,this.useVertexColors=!0,this.applyFog=!0,this.computeBonesUsingShaders=!0,this.scalingDeterminant=1,this.useOctreeForRenderingSelection=!0,this.useOctreeForPicking=!0,this.useOctreeForCollisions=!0,this.layerMask=268435455,this.alwaysSelectAsActiveMesh=!1,this._physicImpostor=e.PhysicsEngine.NoImpostor,this._checkCollisions=!1,this.ellipsoid=new e.Vector3(.5,1,.5),this.ellipsoidOffset=new e.Vector3(0,0,0),this._collider=new e.Collider,this._oldPositionForCollisions=new e.Vector3(0,0,0),this._diffPositionForCollisions=new e.Vector3(0,0,0),this._newPositionForCollisions=new e.Vector3(0,0,0),this.edgesWidth=1,this.edgesColor=new e.Color4(1,0,0,1),this._localScaling=e.Matrix.Zero(),this._localRotation=e.Matrix.Zero(),this._localTranslation=e.Matrix.Zero(),this._localBillboard=e.Matrix.Zero(),this._localPivotScaling=e.Matrix.Zero(),this._localPivotScalingRotation=e.Matrix.Zero(),this._localWorld=e.Matrix.Zero(),this._worldMatrix=e.Matrix.Zero(),this._rotateYByPI=e.Matrix.RotationY(Math.PI),this._absolutePosition=e.Vector3.Zero(),this._collisionsTransformMatrix=e.Matrix.Zero(),this._collisionsScalingMatrix=e.Matrix.Zero(),this._isDirty=!1,this._pivotMatrix=e.Matrix.Identity(),this._isDisposed=!1,this._renderId=0,this._intersectionsInProgress=new Array,this._onAfterWorldMatrixUpdate=new Array,this._isWorldMatrixFrozen=!1,this._onCollisionPositionChange=function(t,i,r){void 0===r&&(r=null),o.getScene().workerCollisions&&i.multiplyInPlace(o._collider.radius),i.subtractToRef(o._oldPositionForCollisions,o._diffPositionForCollisions),o._diffPositionForCollisions.length()>e.Engine.CollisionsEpsilon&&o.position.addInPlace(o._diffPositionForCollisions),o.onCollide&&r&&o.onCollide(r)},n.addMesh(this)}return __extends(i,t),Object.defineProperty(i,"BILLBOARDMODE_NONE",{get:function(){return i._BILLBOARDMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_X",{get:function(){return i._BILLBOARDMODE_X},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_Y",{get:function(){return i._BILLBOARDMODE_Y},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_Z",{get:function(){return i._BILLBOARDMODE_Z},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_ALL",{get:function(){return i._BILLBOARDMODE_ALL},enumerable:!0,configurable:!0}),i.prototype.disableEdgesRendering=function(){void 0!==this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=void 0)},i.prototype.enableEdgesRendering=function(t,i){void 0===t&&(t=.95),void 0===i&&(i=!1),this.disableEdgesRendering(),this._edgesRenderer=new e.EdgesRenderer(this,t,i)},Object.defineProperty(i.prototype,"isBlocked",{get:function(){return!1},enumerable:!0,configurable:!0}),i.prototype.getLOD=function(e){return this},i.prototype.getTotalVertices=function(){return 0},i.prototype.getIndices=function(){return null},i.prototype.getVerticesData=function(e){return null},i.prototype.isVerticesDataPresent=function(e){return!1},i.prototype.getBoundingInfo=function(){return this._masterMesh?this._masterMesh.getBoundingInfo():(this._boundingInfo||this._updateBoundingInfo(),this._boundingInfo)},Object.defineProperty(i.prototype,"useBones",{get:function(){return this.skeleton&&this.getScene().skeletonsEnabled&&this.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind)&&this.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind)},enumerable:!0,configurable:!0}),i.prototype._preActivate=function(){},i.prototype._activate=function(e){this._renderId=e},i.prototype.getWorldMatrix=function(){return this._masterMesh?this._masterMesh.getWorldMatrix():(this._currentRenderId!==this.getScene().getRenderId()&&this.computeWorldMatrix(),this._worldMatrix)},Object.defineProperty(i.prototype,"worldMatrixFromCache",{get:function(){return this._worldMatrix},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"absolutePosition",{get:function(){return this._absolutePosition},enumerable:!0,configurable:!0}),i.prototype.freezeWorldMatrix=function(){this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this._isWorldMatrixFrozen=!0},i.prototype.unfreezeWorldMatrix=function(){this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0)},Object.defineProperty(i.prototype,"isWorldMatrixFrozen",{get:function(){return this._isWorldMatrixFrozen},enumerable:!0,configurable:!0}),i.prototype.rotate=function(t,i,r){var n;if(t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation=e.Vector3.Zero()),r&&r!==e.Space.LOCAL){if(this.parent){var o=this.parent.getWorldMatrix().clone();o.invert(),t=e.Vector3.TransformNormal(t,o)}n=e.Quaternion.RotationAxis(t,i),this.rotationQuaternion=n.multiply(this.rotationQuaternion)}else n=e.Quaternion.RotationAxis(t,i),this.rotationQuaternion=this.rotationQuaternion.multiply(n)},i.prototype.translate=function(t,i,r){var n=t.scale(i);if(r&&r!==e.Space.LOCAL)this.setAbsolutePosition(this.getAbsolutePosition().add(n));else{var o=this.getPositionExpressedInLocalSpace().add(n);this.setPositionWithLocalVector(o)}},i.prototype.getAbsolutePosition=function(){return this.computeWorldMatrix(),this._absolutePosition},i.prototype.setAbsolutePosition=function(t){if(t){var i,r,n;if(void 0===t.x){if(arguments.length<3)return;i=arguments[0],r=arguments[1],n=arguments[2]}else i=t.x,r=t.y,n=t.z;if(this.parent){var o=this.parent.getWorldMatrix().clone();o.invert();var s=new e.Vector3(i,r,n);this.position=e.Vector3.TransformCoordinates(s,o)}else this.position.x=i,this.position.y=r,this.position.z=n}},i.prototype.movePOV=function(e,t,i){this.position.addInPlace(this.calcMovePOV(e,t,i))},i.prototype.calcMovePOV=function(t,i,r){var n=new e.Matrix;(this.rotationQuaternion?this.rotationQuaternion:e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(n);var o=e.Vector3.Zero(),s=this.definedFacingForward?-1:1;return e.Vector3.TransformCoordinatesFromFloatsToRef(t*s,i,r*s,n,o),o},i.prototype.rotatePOV=function(e,t,i){this.rotation.addInPlace(this.calcRotatePOV(e,t,i))},i.prototype.calcRotatePOV=function(t,i,r){var n=this.definedFacingForward?1:-1;return new e.Vector3(t*n,i,r*n)},i.prototype.setPivotMatrix=function(e){this._pivotMatrix=e,this._cache.pivotMatrixUpdated=!0},i.prototype.getPivotMatrix=function(){return this._pivotMatrix},i.prototype._isSynchronized=function(){if(this._isDirty)return!1;if(this.billboardMode!==i.BILLBOARDMODE_NONE)return!1;if(this._cache.pivotMatrixUpdated)return!1;if(this.infiniteDistance)return!1;if(!this._cache.position.equals(this.position))return!1;if(this.rotationQuaternion){if(!this._cache.rotationQuaternion.equals(this.rotationQuaternion))return!1}else if(!this._cache.rotation.equals(this.rotation))return!1;return!!this._cache.scaling.equals(this.scaling)},i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.localMatrixUpdated=!1,this._cache.position=e.Vector3.Zero(),this._cache.scaling=e.Vector3.Zero(),this._cache.rotation=e.Vector3.Zero(),this._cache.rotationQuaternion=new e.Quaternion(0,0,0,0)},i.prototype.markAsDirty=function(e){"rotation"===e&&(this.rotationQuaternion=null),this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0},i.prototype._updateBoundingInfo=function(){this._boundingInfo=this._boundingInfo||new e.BoundingInfo(this.absolutePosition,this.absolutePosition),this._boundingInfo._update(this.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)},i.prototype._updateSubMeshesBoundingInfo=function(e){if(this.subMeshes)for(var t=0;t<this.subMeshes.length;t++){this.subMeshes[t].updateBoundingInfo(e)}},i.prototype.computeWorldMatrix=function(t){if(this._isWorldMatrixFrozen)return this._worldMatrix;if(!t&&(this._currentRenderId===this.getScene().getRenderId()||this.isSynchronized(!0)))return this._worldMatrix;if(this._cache.position.copyFrom(this.position),this._cache.scaling.copyFrom(this.scaling),this._cache.pivotMatrixUpdated=!1,this._currentRenderId=this.getScene().getRenderId(),this._isDirty=!1,e.Matrix.ScalingToRef(this.scaling.x*this.scalingDeterminant,this.scaling.y*this.scalingDeterminant,this.scaling.z*this.scalingDeterminant,this._localScaling),this.rotationQuaternion?(this.rotationQuaternion.toRotationMatrix(this._localRotation),this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)):(e.Matrix.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._localRotation),this._cache.rotation.copyFrom(this.rotation)),this.infiniteDistance&&!this.parent){var r=this.getScene().activeCamera;if(r){var n=r.getWorldMatrix(),o=new e.Vector3(n.m[12],n.m[13],n.m[14]);e.Matrix.TranslationToRef(this.position.x+o.x,this.position.y+o.y,this.position.z+o.z,this._localTranslation)}}else e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,this._localTranslation);if(this._pivotMatrix.multiplyToRef(this._localScaling,this._localPivotScaling),this._localPivotScaling.multiplyToRef(this._localRotation,this._localPivotScalingRotation),this.billboardMode!==i.BILLBOARDMODE_NONE&&this.getScene().activeCamera){var s=this.position.clone(),a=this.getScene().activeCamera.globalPosition.clone();this.parent&&this.parent.position&&(s.addInPlace(this.parent.position),e.Matrix.TranslationToRef(s.x,s.y,s.z,this._localTranslation)),(this.billboardMode&i.BILLBOARDMODE_ALL)!==i.BILLBOARDMODE_ALL&&(this.billboardMode&i.BILLBOARDMODE_X&&(a.x=s.x+e.Engine.Epsilon),this.billboardMode&i.BILLBOARDMODE_Y&&(a.y=s.y+.001),this.billboardMode&i.BILLBOARDMODE_Z&&(a.z=s.z+.001)),e.Matrix.LookAtLHToRef(s,a,e.Vector3.Up(),this._localBillboard),this._localBillboard.m[12]=this._localBillboard.m[13]=this._localBillboard.m[14]=0,this._localBillboard.invert(),this._localPivotScalingRotation.multiplyToRef(this._localBillboard,this._localWorld),this._rotateYByPI.multiplyToRef(this._localWorld,this._localPivotScalingRotation)}this._localPivotScalingRotation.multiplyToRef(this._localTranslation,this._localWorld),this.parent&&this.parent.getWorldMatrix&&this.billboardMode===i.BILLBOARDMODE_NONE?(this._markSyncedWithParent(),this._meshToBoneReferal?(this._localMeshReferalTransform||(this._localMeshReferalTransform=e.Matrix.Zero()),this._localWorld.multiplyToRef(this.parent.getWorldMatrix(),this._localMeshReferalTransform),this._localMeshReferalTransform.multiplyToRef(this._meshToBoneReferal.getWorldMatrix(),this._worldMatrix)):this._localWorld.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix)):this._worldMatrix.copyFrom(this._localWorld),this._updateBoundingInfo(),this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]);for(var h=0;h<this._onAfterWorldMatrixUpdate.length;h++)this._onAfterWorldMatrixUpdate[h](this);return this._worldMatrix},i.prototype.registerAfterWorldMatrixUpdate=function(e){this._onAfterWorldMatrixUpdate.push(e)},i.prototype.unregisterAfterWorldMatrixUpdate=function(e){var t=this._onAfterWorldMatrixUpdate.indexOf(e);t>-1&&this._onAfterWorldMatrixUpdate.splice(t,1)},i.prototype.setPositionWithLocalVector=function(t){this.computeWorldMatrix(),this.position=e.Vector3.TransformNormal(t,this._localWorld)},i.prototype.getPositionExpressedInLocalSpace=function(){this.computeWorldMatrix();var t=this._localWorld.clone();return t.invert(),e.Vector3.TransformNormal(this.position,t)},i.prototype.locallyTranslate=function(t){this.computeWorldMatrix(!0),this.position=e.Vector3.TransformCoordinates(t,this._localWorld)},i.prototype.lookAt=function(t,i,r,n){i=i||0,r=r||0,n=n||0;var o=t.subtract(this.position),s=-Math.atan2(o.z,o.x)-Math.PI/2,a=Math.sqrt(o.x*o.x+o.z*o.z),h=Math.atan2(o.y,a);this.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(s+i,h+r,n)},i.prototype.attachToBone=function(e,t){this._meshToBoneReferal=t,this.parent=e,e.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1)},i.prototype.detachFromBone=function(){this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._meshToBoneReferal=null,this.parent=null},i.prototype.isInFrustum=function(e){return this._boundingInfo.isInFrustum(e)},i.prototype.isCompletelyInFrustum=function(t){t||(t=this.getScene().activeCamera);var i=t.getViewMatrix().multiply(t.getProjectionMatrix());return!!this._boundingInfo.isCompletelyInFrustum(e.Frustum.GetPlanes(i))},i.prototype.intersectsMesh=function(e,t){return!(!this._boundingInfo||!e._boundingInfo)&&this._boundingInfo.intersects(e._boundingInfo,t)},i.prototype.intersectsPoint=function(e){return!!this._boundingInfo&&this._boundingInfo.intersectsPoint(e)},i.prototype.setPhysicsState=function(t,i){var r=this.getScene().getPhysicsEngine();return r?((t=t||e.PhysicsEngine.NoImpostor).impostor&&(i=t,t=t.impostor),t===e.PhysicsEngine.NoImpostor?(r._unregisterMesh(this),null):(i?(i.mass||0===i.mass||(i.mass=0),i.friction||0===i.friction||(i.friction=.2),i.restitution||0===i.restitution||(i.restitution=.2)):i={mass:0,friction:.2,restitution:.2},this._physicImpostor=t,this._physicsMass=i.mass,this._physicsFriction=i.friction,this._physicRestitution=i.restitution,r._registerMesh(this,t,i))):null},i.prototype.getPhysicsImpostor=function(){return this._physicImpostor?this._physicImpostor:e.PhysicsEngine.NoImpostor},i.prototype.getPhysicsMass=function(){return this._physicsMass?this._physicsMass:0},i.prototype.getPhysicsFriction=function(){return this._physicsFriction?this._physicsFriction:0},i.prototype.getPhysicsRestitution=function(){return this._physicRestitution?this._physicRestitution:0},i.prototype.getPositionInCameraSpace=function(t){return t||(t=this.getScene().activeCamera),e.Vector3.TransformCoordinates(this.absolutePosition,t.getViewMatrix())},i.prototype.getDistanceToCamera=function(e){return e||(e=this.getScene().activeCamera),this.absolutePosition.subtract(e.position).length()},i.prototype.applyImpulse=function(e,t){this._physicImpostor&&this.getScene().getPhysicsEngine()._applyImpulse(this,e,t)},i.prototype.setPhysicsLinkWith=function(e,t,i,r){this._physicImpostor&&this.getScene().getPhysicsEngine()._createLink(this,e,t,i,r)},i.prototype.updatePhysicsBodyPosition=function(){this._physicImpostor&&this.getScene().getPhysicsEngine()._updateBodyPosition(this)},Object.defineProperty(i.prototype,"checkCollisions",{get:function(){return this._checkCollisions},set:function(e){this._checkCollisions=e,this.getScene().workerCollisions&&this.getScene().collisionCoordinator.onMeshUpdated(this)},enumerable:!0,configurable:!0}),i.prototype.moveWithCollisions=function(e){this.getAbsolutePosition().subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPositionForCollisions),this._oldPositionForCollisions.addInPlace(this.ellipsoidOffset),this._collider.radius=this.ellipsoid,this.getScene().collisionCoordinator.getNewPosition(this._oldPositionForCollisions,e,this._collider,3,this,this._onCollisionPositionChange,this.uniqueId)},i.prototype.createOrUpdateSubmeshesOctree=function(t,i){void 0===t&&(t=64),void 0===i&&(i=2),this._submeshesOctree||(this._submeshesOctree=new e.Octree(e.Octree.CreationFuncForSubMeshes,t,i)),this.computeWorldMatrix(!0);var r=this.getBoundingInfo().boundingBox;return this._submeshesOctree.update(r.minimumWorld,r.maximumWorld,this.subMeshes),this._submeshesOctree},i.prototype._collideForSubMesh=function(t,i,r){if(this._generatePointsArray(),!t._lastColliderWorldVertices||!t._lastColliderTransformMatrix.equals(i)){t._lastColliderTransformMatrix=i.clone(),t._lastColliderWorldVertices=[],t._trianglePlanes=[];for(var n=t.verticesStart,o=t.verticesStart+t.verticesCount,s=n;o>s;s++)t._lastColliderWorldVertices.push(e.Vector3.TransformCoordinates(this._positions[s],i))}r._collide(t._trianglePlanes,t._lastColliderWorldVertices,this.getIndices(),t.indexStart,t.indexStart+t.indexCount,t.verticesStart,!!t.getMaterial()),r.collisionFound&&(r.collidedMesh=this)},i.prototype._processCollisionsForSubMeshes=function(e,t){var i,r;if(this._submeshesOctree&&this.useOctreeForCollisions){var n=e.velocityWorldLength+Math.max(e.radius.x,e.radius.y,e.radius.z),o=this._submeshesOctree.intersects(e.basePointWorld,n);r=o.length,i=o.data}else r=(i=this.subMeshes).length;for(var s=0;r>s;s++){var a=i[s];r>1&&!a._checkCollision(e)||this._collideForSubMesh(a,t,e)}},i.prototype._checkCollision=function(t){this._boundingInfo._checkCollision(t)&&(e.Matrix.ScalingToRef(1/t.radius.x,1/t.radius.y,1/t.radius.z,this._collisionsScalingMatrix),this.worldMatrixFromCache.multiplyToRef(this._collisionsScalingMatrix,this._collisionsTransformMatrix),this._processCollisionsForSubMeshes(t,this._collisionsTransformMatrix))},i.prototype._generatePointsArray=function(){return!1},i.prototype.intersects=function(t,i){var r=new e.PickingInfo;if(!(this.subMeshes&&this._boundingInfo&&t.intersectsSphere(this._boundingInfo.boundingSphere)&&t.intersectsBox(this._boundingInfo.boundingBox)))return r;if(!this._generatePointsArray())return r;var n,o,s=null;if(this._submeshesOctree&&this.useOctreeForPicking){var a=e.Ray.Transform(t,this.getWorldMatrix()),h=this._submeshesOctree.intersectsRay(a);o=h.length,n=h.data}else o=(n=this.subMeshes).length;for(var c=0;o>c;c++){var l=n[c];if(!(o>1)||l.canIntersects(t)){var u=l.intersects(t,this._positions,this.getIndices(),i);if(u&&(i||!s||u.distance<s.distance)&&((s=u).subMeshId=c,i))break}}if(s){var d=this.getWorldMatrix(),f=e.Vector3.TransformCoordinates(t.origin,d),p=t.direction.clone();p=p.scale(s.distance);var m=e.Vector3.TransformNormal(p,d),g=f.add(m);return r.hit=!0,r.distance=e.Vector3.Distance(f,g),r.pickedPoint=g,r.pickedMesh=this,r.bu=s.bu,r.bv=s.bv,r.faceId=s.faceId,r.subMeshId=s.subMeshId,r}return r},i.prototype.clone=function(e,t,i){return null},i.prototype.releaseSubMeshes=function(){if(this.subMeshes)for(;this.subMeshes.length;)this.subMeshes[0].dispose();else this.subMeshes=new Array},i.prototype.dispose=function(t){var i;for(this.getPhysicsImpostor()!==e.PhysicsEngine.NoImpostor&&this.setPhysicsState(e.PhysicsEngine.NoImpostor),i=0;i<this._intersectionsInProgress.length;i++){var r=this._intersectionsInProgress[i],n=r._intersectionsInProgress.indexOf(this);r._intersectionsInProgress.splice(n,1)}if(this._intersectionsInProgress=[],this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),this.releaseSubMeshes(),this.getScene().removeMesh(this),t)for(i=0;i<this.getScene().meshes.length;i++){var o=this.getScene().meshes[i];o.parent===this&&(o.parent=null,o.computeWorldMatrix(!0))}else{for(i=0;i<this.getScene().particleSystems.length;i++)this.getScene().particleSystems[i].emitter===this&&(this.getScene().particleSystems[i].dispose(),i--);var s=this.getScene().meshes.slice(0);for(i=0;i<s.length;i++)s[i].parent===this&&s[i].dispose()}this._onAfterWorldMatrixUpdate=[],this._isDisposed=!0,this.onDispose&&this.onDispose()},i._BILLBOARDMODE_NONE=0,i._BILLBOARDMODE_X=1,i._BILLBOARDMODE_Y=2,i._BILLBOARDMODE_Z=4,i._BILLBOARDMODE_ALL=7,i}(e.Node);e.AbstractMesh=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r){t.call(this,i,r),this.diffuse=new e.Color3(1,1,1),this.specular=new e.Color3(1,1,1),this.intensity=1,this.range=Number.MAX_VALUE,this.includeOnlyWithLayerMask=0,this.includedOnlyMeshes=new Array,this.excludedMeshes=new Array,this.excludeWithLayerMask=0,this._excludedMeshesIds=new Array,this._includedOnlyMeshesIds=new Array,r.addLight(this)}return __extends(i,t),i.prototype.getShadowGenerator=function(){return this._shadowGenerator},i.prototype.getAbsolutePosition=function(){return e.Vector3.Zero()},i.prototype.transferToEffect=function(e,t,i){},i.prototype._getWorldMatrix=function(){return e.Matrix.Identity()},i.prototype.canAffectMesh=function(e){return!e||!(this.includedOnlyMeshes.length>0&&-1===this.includedOnlyMeshes.indexOf(e))&&(!(this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e))&&((0===this.includeOnlyWithLayerMask||0!=(this.includeOnlyWithLayerMask&e.layerMask))&&!(0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask)))},i.prototype.getWorldMatrix=function(){this._currentRenderId=this.getScene().getRenderId();var t=this._getWorldMatrix();return this.parent&&this.parent.getWorldMatrix?(this._parentedWorldMatrix||(this._parentedWorldMatrix=e.Matrix.Identity()),t.multiplyToRef(this.parent.getWorldMatrix(),this._parentedWorldMatrix),this._markSyncedWithParent(),this._parentedWorldMatrix):t},i.prototype.dispose=function(){this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().removeLight(this)},i}(e.Node);e.Light=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(e,i,r){t.call(this,e,r),this.position=i}return __extends(i,t),i.prototype.getAbsolutePosition=function(){return this._transformedPosition?this._transformedPosition:this.position},i.prototype.transferToEffect=function(t,i){return this.parent&&this.parent.getWorldMatrix?(this._transformedPosition||(this._transformedPosition=e.Vector3.Zero()),e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this._transformedPosition),void t.setFloat4(i,this._transformedPosition.x,this._transformedPosition.y,this._transformedPosition.z,0)):void t.setFloat4(i,this.position.x,this.position.y,this.position.z,0)},i.prototype.getShadowGenerator=function(){return null},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this._worldMatrix},i}(e.Light);e.PointLight=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(e,i,r,n,o,s){t.call(this,e,s),this.position=i,this.direction=r,this.angle=n,this.exponent=o}return __extends(i,t),i.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},i.prototype.setShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;e.Matrix.PerspectiveFovLHToRef(this.angle,1,n.minZ,n.maxZ,t)},i.prototype.supportsVSM=function(){return!0},i.prototype.needRefreshPerFrame=function(){return!1},i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(this.position)),this.direction},i.prototype.computeTransformedPosition=function(){return!(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition||(this.transformedPosition=e.Vector3.Zero()),e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),!0)},i.prototype.transferToEffect=function(t,i,r){var n;this.parent&&this.parent.getWorldMatrix?(this._transformedDirection||(this._transformedDirection=e.Vector3.Zero()),this.computeTransformedPosition(),e.Vector3.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this._transformedDirection),t.setFloat4(i,this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent),n=e.Vector3.Normalize(this._transformedDirection)):(t.setFloat4(i,this.position.x,this.position.y,this.position.z,this.exponent),n=e.Vector3.Normalize(this.direction)),t.setFloat4(r,n.x,n.y,n.z,Math.cos(.5*this.angle))},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this._worldMatrix},i}(e.Light);e.SpotLight=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n){t.call(this,i,n),this.direction=r,this.groundColor=new e.Color3(0,0,0)}return __extends(i,t),i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(e.Vector3.Zero())),this.direction},i.prototype.getShadowGenerator=function(){return null},i.prototype.transferToEffect=function(t,i,r){var n=e.Vector3.Normalize(this.direction);t.setFloat4(i,n.x,n.y,n.z,0),t.setColor3(r,this.groundColor.scale(this.intensity))},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this._worldMatrix},i}(e.Light);e.HemisphericLight=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(e,i,r){t.call(this,e,r),this.direction=i,this.shadowOrthoScale=.5,this.position=i.scale(-1)}return __extends(i,t),i.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(this.position)),this.direction},i.prototype.setShadowProjectionMatrix=function(t,i,r){for(var n=Number.MAX_VALUE,o=Number.MIN_VALUE,s=Number.MIN_VALUE,a=Number.MAX_VALUE,h=e.Vector3.Zero(),c=this.getScene().activeCamera,l=0;l<r.length;l++){var u=r[l];if(u){var d=u.getBoundingInfo();if(d)for(var f=d.boundingBox,p=0;p<f.vectorsWorld.length;p++)e.Vector3.TransformCoordinatesToRef(f.vectorsWorld[p],i,h),h.x<n&&(n=h.x),h.y<a&&(a=h.y),h.x>o&&(o=h.x),h.y>s&&(s=h.y)}}var m=o-n,g=s-a;e.Matrix.OrthoOffCenterLHToRef(n-m*this.shadowOrthoScale,o+m*this.shadowOrthoScale,a-g*this.shadowOrthoScale,s+g*this.shadowOrthoScale,-c.maxZ,c.maxZ,t)},i.prototype.supportsVSM=function(){return!0},i.prototype.needRefreshPerFrame=function(){return!0},i.prototype.computeTransformedPosition=function(){return!(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition||(this.transformedPosition=e.Vector3.Zero()),e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),!0)},i.prototype.transferToEffect=function(t,i){return this.parent&&this.parent.getWorldMatrix?(this._transformedDirection||(this._transformedDirection=e.Vector3.Zero()),e.Vector3.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this._transformedDirection),void t.setFloat4(i,this._transformedDirection.x,this._transformedDirection.y,this._transformedDirection.z,1)):void t.setFloat4(i,this.direction.x,this.direction.y,this.direction.z,1)},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this._worldMatrix},i}(e.Light);e.DirectionalLight=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(i,r){var n=this;this._filter=t.FILTER_NONE,this.blurScale=2,this._blurBoxOffset=0,this._bias=5e-5,this._lightDirection=e.Vector3.Zero(),this._darkness=0,this._transparencyShadow=!1,this._viewMatrix=e.Matrix.Zero(),this._projectionMatrix=e.Matrix.Zero(),this._transformMatrix=e.Matrix.Zero(),this._worldViewProjection=e.Matrix.Zero(),this._light=r,this._scene=r.getScene(),this._mapSize=i,r._shadowGenerator=this,this._shadowMap=new e.RenderTargetTexture(r.name+"_shadowMap",i,this._scene,!1),this._shadowMap.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(e.Texture.NEAREST_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.onAfterUnbind=function(){n.useBlurVarianceShadowMap&&(n._shadowMap2||(n._shadowMap2=new e.RenderTargetTexture(r.name+"_shadowMap",i,n._scene,!1),n._shadowMap2.wrapU=e.Texture.CLAMP_ADDRESSMODE,n._shadowMap2.wrapV=e.Texture.CLAMP_ADDRESSMODE,n._shadowMap2.updateSamplingMode(e.Texture.TRILINEAR_SAMPLINGMODE),n._downSamplePostprocess=new e.PassPostProcess("downScale",1/n.blurScale,null,e.Texture.BILINEAR_SAMPLINGMODE,n._scene.getEngine()),n._downSamplePostprocess.onApply=function(e){e.setTexture("textureSampler",n._shadowMap)},n.blurBoxOffset=1),n._scene.postProcessManager.directRender([n._downSamplePostprocess,n._boxBlurPostprocess],n._shadowMap2.getInternalTexture()))};var o=function(t){var i=t.getRenderingMesh(),r=n._scene.getEngine();r.setState(t.getMaterial().backFaceCulling);var o=i._getInstancesRenderList(t._id);if(!o.mustReturn){var s=null!==r.getCaps().instancedArrays&&null!==o.visibleInstances[t._id];if(n.isReady(t,s)){r.enableEffect(n._effect),i._bind(t,n._effect,e.Material.TriangleFillMode);var a=t.getMaterial();if(n._effect.setMatrix("viewProjection",n.getTransformMatrix()),a&&a.needAlphaTesting()){var h=a.getAlphaTestTexture();n._effect.setTexture("diffuseSampler",h),n._effect.setMatrix("diffuseMatrix",h.getTextureMatrix())}i.useBones&&i.computeBonesUsingShaders&&n._effect.setMatrices("mBones",i.skeleton.getTransformMatrices()),i._processRendering(t,n._effect,e.Material.TriangleFillMode,o,s,function(e,t){return n._effect.setMatrix("world",t)})}else n._shadowMap.resetRefreshCounter()}};this._shadowMap.customRenderFunction=function(e,t,i){var r;for(r=0;r<e.length;r++)o(e.data[r]);for(r=0;r<t.length;r++)o(t.data[r]);if(n._transparencyShadow)for(r=0;r<i.length;r++)o(i.data[r])},this._shadowMap.onClear=function(t){n.useBlurVarianceShadowMap||n.useVarianceShadowMap?t.clear(new e.Color4(0,0,0,0),!0,!0):t.clear(new e.Color4(1,1,1,1),!0,!0)}}return Object.defineProperty(t,"FILTER_NONE",{get:function(){return t._FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_VARIANCESHADOWMAP",{get:function(){return t._FILTER_VARIANCESHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_POISSONSAMPLING",{get:function(){return t._FILTER_POISSONSAMPLING},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_BLURVARIANCESHADOWMAP",{get:function(){return t._FILTER_BLURVARIANCESHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bias",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(t){var i=this;this._blurBoxOffset!==t&&(this._blurBoxOffset=t,this._boxBlurPostprocess&&this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=new e.PostProcess("DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1/this.blurScale,null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define OFFSET "+t),this._boxBlurPostprocess.onApply=function(e){e.setFloat2("screenSize",i._mapSize/i.blurScale,i._mapSize/i.blurScale)})},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},set:function(t){this._filter!==t&&(this._filter=t,this.useVarianceShadowMap||this.useBlurVarianceShadowMap?(this._shadowMap.anisotropicFilteringLevel=16,this._shadowMap.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE)):(this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(e.Texture.NEAREST_SAMPLINGMODE)))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useVarianceShadowMap",{get:function(){return this.filter===t.FILTER_VARIANCESHADOWMAP&&this._light.supportsVSM()},set:function(e){this.filter=e?t.FILTER_VARIANCESHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"usePoissonSampling",{get:function(){return this.filter===t.FILTER_POISSONSAMPLING||!this._light.supportsVSM()&&(this.filter===t.FILTER_VARIANCESHADOWMAP||this.filter===t.FILTER_BLURVARIANCESHADOWMAP)},set:function(e){this.filter=e?t.FILTER_POISSONSAMPLING:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurVarianceShadowMap",{get:function(){return this.filter===t.FILTER_BLURVARIANCESHADOWMAP&&this._light.supportsVSM()},set:function(e){this.filter=e?t.FILTER_BLURVARIANCESHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),t.prototype.isReady=function(t,i){var r=[];(this.useVarianceShadowMap||this.useBlurVarianceShadowMap)&&r.push("#define VSM");var n=[e.VertexBuffer.PositionKind],o=t.getMesh(),s=t.getMaterial();s&&s.needAlphaTesting()&&(r.push("#define ALPHATEST"),o.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.push(e.VertexBuffer.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(n.push(e.VertexBuffer.UV2Kind),r.push("#define UV2"))),o.useBones&&o.computeBonesUsingShaders&&(n.push(e.VertexBuffer.MatricesIndicesKind),n.push(e.VertexBuffer.MatricesWeightsKind),r.push("#define BONES"),r.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))),i&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var a=r.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("shadowMap",n,["world","mBones","viewProjection","diffuseMatrix"],["diffuseSampler"],a)),this._effect.isReady()},t.prototype.getShadowMap=function(){return this._shadowMap},t.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},t.prototype.getLight=function(){return this._light},t.prototype.getTransformMatrix=function(){var t=this._scene;if(this._currentRenderID===t.getRenderId())return this._transformMatrix;this._currentRenderID=t.getRenderId();var i=this._light.position;return e.Vector3.NormalizeToRef(this._light.direction,this._lightDirection),1==Math.abs(e.Vector3.Dot(this._lightDirection,e.Vector3.Up()))&&(this._lightDirection.z=1e-13),this._light.computeTransformedPosition()&&(i=this._light.transformedPosition),!this._light.needRefreshPerFrame()&&this._cachedPosition&&this._cachedDirection&&i.equals(this._cachedPosition)&&this._lightDirection.equals(this._cachedDirection)||(this._cachedPosition=i.clone(),this._cachedDirection=this._lightDirection.clone(),e.Matrix.LookAtLHToRef(i,this._light.position.add(this._lightDirection),e.Vector3.Up(),this._viewMatrix),this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,this.getShadowMap().renderList),this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)),this._transformMatrix},t.prototype.getDarkness=function(){return this._darkness},t.prototype.setDarkness=function(e){this._darkness=e>=1?1:0>=e?0:e},t.prototype.setTransparencyShadow=function(e){this._transparencyShadow=e},t.prototype._packHalf=function(t){var i=255*t,r=i-Math.floor(i);return new e.Vector2(t-r/255,r)},t.prototype.dispose=function(){this._shadowMap.dispose(),this._shadowMap2&&this._shadowMap2.dispose(),this._downSamplePostprocess&&this._downSamplePostprocess.dispose(),this._boxBlurPostprocess&&this._boxBlurPostprocess.dispose()},t._FILTER_NONE=0,t._FILTER_VARIANCESHADOWMAP=1,t._FILTER_POISSONSAMPLING=2,t._FILTER_BLURVARIANCESHADOWMAP=3,t}();e.ShadowGenerator=t}(BABYLON||(BABYLON={})),function(e){var t=function(e,t,i,r){var n=t*t-4*e*i,o={root:0,found:!1};if(0>n)return o;var s=Math.sqrt(n),a=(-t-s)/(2*e),h=(-t+s)/(2*e);if(a>h){var c=h;h=a,a=c}return a>0&&r>a?(o.root=a,o.found=!0,o):h>0&&r>h?(o.root=h,o.found=!0,o):o},i=function(){function i(){this.radius=new e.Vector3(1,1,1),this.retry=0,this.basePointWorld=e.Vector3.Zero(),this.velocityWorld=e.Vector3.Zero(),this.normalizedVelocity=e.Vector3.Zero(),this._collisionPoint=e.Vector3.Zero(),this._planeIntersectionPoint=e.Vector3.Zero(),this._tempVector=e.Vector3.Zero(),this._tempVector2=e.Vector3.Zero(),this._tempVector3=e.Vector3.Zero(),this._tempVector4=e.Vector3.Zero(),this._edge=e.Vector3.Zero(),this._baseToVertex=e.Vector3.Zero(),this._destinationPoint=e.Vector3.Zero(),this._slidePlaneNormal=e.Vector3.Zero(),this._displacementVector=e.Vector3.Zero()}return i.prototype._initialize=function(t,i,r){this.velocity=i,e.Vector3.NormalizeToRef(i,this.normalizedVelocity),this.basePoint=t,t.multiplyToRef(this.radius,this.basePointWorld),i.multiplyToRef(this.radius,this.velocityWorld),this.velocityWorldLength=this.velocityWorld.length(),this.epsilon=r,this.collisionFound=!1},i.prototype._checkPointInTriangle=function(t,i,r,n,o){i.subtractToRef(t,this._tempVector),r.subtractToRef(t,this._tempVector2),e.Vector3.CrossToRef(this._tempVector,this._tempVector2,this._tempVector4);var s=e.Vector3.Dot(this._tempVector4,o);return!(0>s)&&(n.subtractToRef(t,this._tempVector3),e.Vector3.CrossToRef(this._tempVector2,this._tempVector3,this._tempVector4),!(0>(s=e.Vector3.Dot(this._tempVector4,o)))&&(e.Vector3.CrossToRef(this._tempVector3,this._tempVector,this._tempVector4),(s=e.Vector3.Dot(this._tempVector4,o))>=0))},i.prototype._canDoCollision=function(t,i,r,n){var o=e.Vector3.Distance(this.basePointWorld,t),s=Math.max(this.radius.x,this.radius.y,this.radius.z);return!(o>this.velocityWorldLength+s+i)&&!!function(e,t,i,r){return!(e.x>i.x+r||i.x-r>t.x||e.y>i.y+r||i.y-r>t.y||e.z>i.z+r||i.z-r>t.z)}(r,n,this.basePointWorld,this.velocityWorldLength+s)},i.prototype._testTriangle=function(i,r,n,o,s,a){var h,c=!1;r||(r=[]),r[i]||(r[i]=new e.Plane(0,0,0,0),r[i].copyFromPoints(n,o,s));var l=r[i];if(a||l.isFrontFacingTo(this.normalizedVelocity,0)){var u=l.signedDistanceTo(this.basePoint),d=e.Vector3.Dot(l.normal,this.velocity);if(0==d){if(Math.abs(u)>=1)return;c=!0,h=0}else{var f=(1-u)/d;if((h=(-1-u)/d)>f){var p=f;f=h,h=p}if(h>1||0>f)return;0>h&&(h=0),h>1&&(h=1)}this._collisionPoint.copyFromFloats(0,0,0);var m=!1,g=1;if(c||(this.basePoint.subtractToRef(l.normal,this._planeIntersectionPoint),this.velocity.scaleToRef(h,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,o,s,l.normal)&&(m=!0,g=h,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!m){var v=this.velocity.lengthSquared(),_=v;this.basePoint.subtractToRef(n,this._tempVector);var y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=t(_,y,x,g);b.found&&(g=b.root,m=!0,this._collisionPoint.copyFrom(n)),this.basePoint.subtractToRef(o,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,(b=t(_,y,x,g)).found&&(g=b.root,m=!0,this._collisionPoint.copyFrom(o)),this.basePoint.subtractToRef(s,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,(b=t(_,y,x,g)).found&&(g=b.root,m=!0,this._collisionPoint.copyFrom(s)),o.subtractToRef(n,this._edge),n.subtractToRef(this.basePoint,this._baseToVertex);var M=this._edge.lengthSquared(),E=e.Vector3.Dot(this._edge,this.velocity),T=e.Vector3.Dot(this._edge,this._baseToVertex);if(_=M*-v+E*E,y=2*M*e.Vector3.Dot(this.velocity,this._baseToVertex)-2*E*T,x=M*(1-this._baseToVertex.lengthSquared())+T*T,(b=t(_,y,x,g)).found){var w=(E*b.root-T)/M;w>=0&&1>=w&&(g=b.root,m=!0,this._edge.scaleInPlace(w),n.addToRef(this._edge,this._collisionPoint))}s.subtractToRef(o,this._edge),o.subtractToRef(this.basePoint,this._baseToVertex),M=this._edge.lengthSquared(),E=e.Vector3.Dot(this._edge,this.velocity),T=e.Vector3.Dot(this._edge,this._baseToVertex),_=M*-v+E*E,y=2*M*e.Vector3.Dot(this.velocity,this._baseToVertex)-2*E*T,x=M*(1-this._baseToVertex.lengthSquared())+T*T,(b=t(_,y,x,g)).found&&((w=(E*b.root-T)/M)>=0&&1>=w&&(g=b.root,m=!0,this._edge.scaleInPlace(w),o.addToRef(this._edge,this._collisionPoint))),n.subtractToRef(s,this._edge),s.subtractToRef(this.basePoint,this._baseToVertex),M=this._edge.lengthSquared(),E=e.Vector3.Dot(this._edge,this.velocity),T=e.Vector3.Dot(this._edge,this._baseToVertex),_=M*-v+E*E,y=2*M*e.Vector3.Dot(this.velocity,this._baseToVertex)-2*E*T,x=M*(1-this._baseToVertex.lengthSquared())+T*T,(b=t(_,y,x,g)).found&&((w=(E*b.root-T)/M)>=0&&1>=w&&(g=b.root,m=!0,this._edge.scaleInPlace(w),s.addToRef(this._edge,this._collisionPoint)))}if(m){var S=g*this.velocity.length();(!this.collisionFound||S<this.nearestDistance)&&(this.intersectionPoint?this.intersectionPoint.copyFrom(this._collisionPoint):this.intersectionPoint=this._collisionPoint.clone(),this.nearestDistance=S,this.collisionFound=!0)}}},i.prototype._collide=function(e,t,i,r,n,o,s){for(var a=r;n>a;a+=3){var h=t[i[a]-o],c=t[i[a+1]-o],l=t[i[a+2]-o];this._testTriangle(a,e,l,c,h,s)}},i.prototype._getResponse=function(t,i){t.addToRef(i,this._destinationPoint),i.scaleInPlace(this.nearestDistance/i.length()),this.basePoint.addToRef(i,t),t.subtractToRef(this.intersectionPoint,this._slidePlaneNormal),this._slidePlaneNormal.normalize(),this._slidePlaneNormal.scaleToRef(this.epsilon,this._displacementVector),t.addInPlace(this._displacementVector),this.intersectionPoint.addInPlace(this._displacementVector),this._slidePlaneNormal.scaleInPlace(e.Plane.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint,this._slidePlaneNormal,this._destinationPoint)),this._destinationPoint.subtractInPlace(this._slidePlaneNormal),this._destinationPoint.subtractToRef(this.intersectionPoint,i)},i}();e.Collider=i}(BABYLON||(BABYLON={})),function(e){e.CollisionWorker="",function(e){e[e.INIT=0]="INIT",e[e.UPDATE=1]="UPDATE",e[e.COLLIDE=2]="COLLIDE"}(e.WorkerTaskType||(e.WorkerTaskType={}));var t=e.WorkerTaskType;!function(e){e[e.SUCCESS=0]="SUCCESS",e[e.UNKNOWN_ERROR=1]="UNKNOWN_ERROR"}(e.WorkerReplyType||(e.WorkerReplyType={}));var i=e.WorkerReplyType,r=function(){function r(){var n=this;this._scaledPosition=e.Vector3.Zero(),this._scaledVelocity=e.Vector3.Zero(),this.onMeshUpdated=function(e){n._addUpdateMeshesList[e.uniqueId]=r.SerializeMesh(e)},this.onGeometryUpdated=function(e){n._addUpdateGeometriesList[e.id]=r.SerializeGeometry(e)},this._afterRender=function(){if(n._init&&!(0==n._toRemoveGeometryArray.length&&0==n._toRemoveMeshesArray.length&&0==Object.keys(n._addUpdateGeometriesList).length&&0==Object.keys(n._addUpdateMeshesList).length||n._runningUpdated>4)){++n._runningUpdated;var e={updatedMeshes:n._addUpdateMeshesList,updatedGeometries:n._addUpdateGeometriesList,removedGeometries:n._toRemoveGeometryArray,removedMeshes:n._toRemoveMeshesArray},i={payload:e,taskType:t.UPDATE},r=[];for(var o in e.updatedGeometries)e.updatedGeometries.hasOwnProperty(o)&&(r.push(i.payload.updatedGeometries[o].indices.buffer),r.push(i.payload.updatedGeometries[o].normals.buffer),r.push(i.payload.updatedGeometries[o].positions.buffer));n._worker.postMessage(i,r),n._addUpdateMeshesList={},n._addUpdateGeometriesList={},n._toRemoveGeometryArray=[],n._toRemoveMeshesArray=[]}},this._onMessageFromWorker=function(r){var o=r.data;if(o.error==i.SUCCESS)switch(o.taskType){case t.INIT:n._init=!0,n._scene.meshes.forEach(function(e){n.onMeshAdded(e)}),n._scene.getGeometries().forEach(function(e){n.onGeometryAdded(e)});break;case t.UPDATE:n._runningUpdated--;break;case t.COLLIDE:n._runningCollisionTask=!1;var s=o.payload;if(!n._collisionsCallbackArray[s.collisionId])return;n._collisionsCallbackArray[s.collisionId](s.collisionId,e.Vector3.FromArray(s.newPosition),n._scene.getMeshByUniqueID(s.collidedMeshUniqueId)),n._collisionsCallbackArray[s.collisionId]=void 0}else e.Tools.Warn("error returned from worker!")},this._collisionsCallbackArray=[],this._init=!1,this._runningUpdated=0,this._runningCollisionTask=!1,this._addUpdateMeshesList={},this._addUpdateGeometriesList={},this._toRemoveGeometryArray=[],this._toRemoveMeshesArray=[]}return r.prototype.getNewPosition=function(e,i,r,n,o,s,a){if(this._init&&!this._collisionsCallbackArray[a]&&!this._collisionsCallbackArray[a+1e5]){e.divideToRef(r.radius,this._scaledPosition),i.divideToRef(r.radius,this._scaledVelocity),this._collisionsCallbackArray[a]=s;var h={payload:{collider:{position:this._scaledPosition.asArray(),velocity:this._scaledVelocity.asArray(),radius:r.radius.asArray()},collisionId:a,excludedMeshUniqueId:o?o.uniqueId:null,maximumRetry:n},taskType:t.COLLIDE};this._worker.postMessage(h)}},r.prototype.init=function(i){this._scene=i,this._scene.registerAfterRender(this._afterRender);var r=e.WorkerIncluded?e.Engine.CodeRepository+"Collisions/babylon.collisionWorker.js":URL.createObjectURL(new Blob([e.CollisionWorker],{type:"application/javascript"}));this._worker=new Worker(r),this._worker.onmessage=this._onMessageFromWorker;var n={payload:{},taskType:t.INIT};this._worker.postMessage(n)},r.prototype.destroy=function(){this._scene.unregisterAfterRender(this._afterRender),this._worker.terminate()},r.prototype.onMeshAdded=function(e){e.registerAfterWorldMatrixUpdate(this.onMeshUpdated),this.onMeshUpdated(e)},r.prototype.onMeshRemoved=function(e){this._toRemoveMeshesArray.push(e.uniqueId)},r.prototype.onGeometryAdded=function(e){e.onGeometryUpdated=this.onGeometryUpdated,this.onGeometryUpdated(e)},r.prototype.onGeometryDeleted=function(e){this._toRemoveGeometryArray.push(e.id)},r.SerializeMesh=function(t){var i=[];t.subMeshes&&(i=t.subMeshes.map(function(e,t){return{position:t,verticesStart:e.verticesStart,verticesCount:e.verticesCount,indexStart:e.indexStart,indexCount:e.indexCount,hasMaterial:!!e.getMaterial(),sphereCenter:e.getBoundingInfo().boundingSphere.centerWorld.asArray(),sphereRadius:e.getBoundingInfo().boundingSphere.radiusWorld,boxMinimum:e.getBoundingInfo().boundingBox.minimumWorld.asArray(),boxMaximum:e.getBoundingInfo().boundingBox.maximumWorld.asArray()}}));var r=null;return t instanceof e.Mesh?r=t.geometry?t.geometry.id:null:t instanceof e.InstancedMesh&&(r=t.sourceMesh&&t.sourceMesh.geometry?t.sourceMesh.geometry.id:null),{uniqueId:t.uniqueId,id:t.id,name:t.name,geometryId:r,sphereCenter:t.getBoundingInfo().boundingSphere.centerWorld.asArray(),sphereRadius:t.getBoundingInfo().boundingSphere.radiusWorld,boxMinimum:t.getBoundingInfo().boundingBox.minimumWorld.asArray(),boxMaximum:t.getBoundingInfo().boundingBox.maximumWorld.asArray(),worldMatrixFromCache:t.worldMatrixFromCache.asArray(),subMeshes:i,checkCollisions:t.checkCollisions}},r.SerializeGeometry=function(t){return{id:t.id,positions:new Float32Array(t.getVerticesData(e.VertexBuffer.PositionKind)||[]),normals:new Float32Array(t.getVerticesData(e.VertexBuffer.NormalKind)||[]),indices:new Int32Array(t.getIndices()||[])}},r}();e.CollisionCoordinatorWorker=r;var n=function(){function t(){this._scaledPosition=e.Vector3.Zero(),this._scaledVelocity=e.Vector3.Zero(),this._finalPosition=e.Vector3.Zero()}return t.prototype.getNewPosition=function(e,t,i,r,n,o,s){e.divideToRef(i.radius,this._scaledPosition),t.divideToRef(i.radius,this._scaledVelocity),i.collidedMesh=null,i.retry=0,i.initialVelocity=this._scaledVelocity,i.initialPosition=this._scaledPosition,this._collideWithWorld(this._scaledPosition,this._scaledVelocity,i,r,this._finalPosition,n),this._finalPosition.multiplyInPlace(i.radius),o(s,this._finalPosition,i.collidedMesh)},t.prototype.init=function(e){this._scene=e},t.prototype.destroy=function(){},t.prototype.onMeshAdded=function(e){},t.prototype.onMeshUpdated=function(e){},t.prototype.onMeshRemoved=function(e){},t.prototype.onGeometryAdded=function(e){},t.prototype.onGeometryUpdated=function(e){},t.prototype.onGeometryDeleted=function(e){},t.prototype._collideWithWorld=function(t,i,r,n,o,s){void 0===s&&(s=null);var a=10*e.Engine.CollisionsEpsilon;if(!(r.retry>=n)){r._initialize(t,i,a);for(var h=0;h<this._scene.meshes.length;h++){var c=this._scene.meshes[h];c.isEnabled()&&c.checkCollisions&&c.subMeshes&&c!==s&&c._checkCollision(r)}return r.collisionFound?((0!==i.x||0!==i.y||0!==i.z)&&r._getResponse(t,i),i.length()<=a?void o.copyFrom(t):(r.retry++,void this._collideWithWorld(t,i,r,n,o,s))):void t.addToRef(i,o)}o.copyFrom(t)},t}();e.CollisionCoordinatorLegacy=n}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(){this.compensateDistortion=!0}return Object.defineProperty(t.prototype,"aspectRatio",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"aspectRatioFov",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftHMatrix",{get:function(){var t=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return e.Matrix.Translation(t,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightHMatrix",{get:function(){var t=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return e.Matrix.Translation(-t,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftPreViewMatrix",{get:function(){return e.Matrix.Translation(.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightPreViewMatrix",{get:function(){return e.Matrix.Translation(-.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),t.GetDefault=function(){var e=new t;return e.hResolution=1280,e.vResolution=800,e.hScreenSize=.149759993,e.vScreenSize=.0935999975,e.vScreenCenter=.0467999987,e.eyeToScreenDistance=.0410000011,e.lensSeparationDistance=.063500002,e.interpupillaryDistance=.064000003,e.distortionK=[1,.219999999,.239999995,0],e.chromaAbCorrection=[.995999992,-.00400000019,1.01400006,0],e.postProcessScaleFactor=1.714605507808412,e.lensCenterOffset=.151976421,e},t}();e.VRCameraMetrics=t;var i=function(i){function r(t,n,o){i.call(this,t,o),this.position=n,this.upVector=e.Vector3.Up(),this.orthoLeft=null,this.orthoRight=null,this.orthoBottom=null,this.orthoTop=null,this.fov=.8,this.minZ=1,this.maxZ=1e4,this.inertia=.9,this.mode=r.PERSPECTIVE_CAMERA,this.isIntermediate=!1,this.viewport=new e.Viewport(0,0,1,1),this.layerMask=268435455,this.fovMode=r.FOVMODE_VERTICAL_FIXED,this.cameraRigMode=r.RIG_MODE_NONE,this._rigCameras=new Array,this._computedViewMatrix=e.Matrix.Identity(),this._projectionMatrix=new e.Matrix,this._postProcesses=new Array,this._postProcessesTakenIndices=[],this._activeMeshes=new e.SmartArray(256),this._globalPosition=e.Vector3.Zero(),o.addCamera(this),o.activeCamera||(o.activeCamera=this)}return __extends(r,i),Object.defineProperty(r,"PERSPECTIVE_CAMERA",{get:function(){return r._PERSPECTIVE_CAMERA},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ORTHOGRAPHIC_CAMERA",{get:function(){return r._ORTHOGRAPHIC_CAMERA},enumerable:!0,configurable:!0}),Object.defineProperty(r,"FOVMODE_VERTICAL_FIXED",{get:function(){return r._FOVMODE_VERTICAL_FIXED},enumerable:!0,configurable:!0}),Object.defineProperty(r,"FOVMODE_HORIZONTAL_FIXED",{get:function(){return r._FOVMODE_HORIZONTAL_FIXED},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RIG_MODE_NONE",{get:function(){return r._RIG_MODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RIG_MODE_STEREOSCOPIC_ANAGLYPH",{get:function(){return r._RIG_MODE_STEREOSCOPIC_ANAGLYPH},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL",{get:function(){return r._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED",{get:function(){return r._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RIG_MODE_STEREOSCOPIC_OVERUNDER",{get:function(){return r._RIG_MODE_STEREOSCOPIC_OVERUNDER},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RIG_MODE_VR",{get:function(){return r._RIG_MODE_VR},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"globalPosition",{get:function(){return this._globalPosition},enumerable:!0,configurable:!0}),r.prototype.getActiveMeshes=function(){return this._activeMeshes},r.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},r.prototype._initCache=function(){i.prototype._initCache.call(this),this._cache.position=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.upVector=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.mode=void 0,this._cache.minZ=void 0,this._cache.maxZ=void 0,this._cache.fov=void 0,this._cache.aspectRatio=void 0,this._cache.orthoLeft=void 0,this._cache.orthoRight=void 0,this._cache.orthoBottom=void 0,this._cache.orthoTop=void 0,this._cache.renderWidth=void 0,this._cache.renderHeight=void 0},r.prototype._updateCache=function(e){e||i.prototype._updateCache.call(this);var t=this.getEngine();this._cache.position.copyFrom(this.position),this._cache.upVector.copyFrom(this.upVector),this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._cache.fov=this.fov,this._cache.aspectRatio=t.getAspectRatio(this),this._cache.orthoLeft=this.orthoLeft,this._cache.orthoRight=this.orthoRight,this._cache.orthoBottom=this.orthoBottom,this._cache.orthoTop=this.orthoTop,this._cache.renderWidth=t.getRenderWidth(),this._cache.renderHeight=t.getRenderHeight()},r.prototype._updateFromScene=function(){this.updateCache(),this._update()},r.prototype._isSynchronized=function(){return this._isSynchronizedViewMatrix()&&this._isSynchronizedProjectionMatrix()},r.prototype._isSynchronizedViewMatrix=function(){return!!i.prototype._isSynchronized.call(this)&&(this._cache.position.equals(this.position)&&this._cache.upVector.equals(this.upVector)&&this.isSynchronizedWithParent())},r.prototype._isSynchronizedProjectionMatrix=function(){var e=this._cache.mode===this.mode&&this._cache.minZ===this.minZ&&this._cache.maxZ===this.maxZ;if(!e)return!1;var t=this.getEngine();return this.mode===r.PERSPECTIVE_CAMERA?this._cache.fov===this.fov&&this._cache.aspectRatio===t.getAspectRatio(this):this._cache.orthoLeft===this.orthoLeft&&this._cache.orthoRight===this.orthoRight&&this._cache.orthoBottom===this.orthoBottom&&this._cache.orthoTop===this.orthoTop&&this._cache.renderWidth===t.getRenderWidth()&&this._cache.renderHeight===t.getRenderHeight()},r.prototype.attachControl=function(e){},r.prototype.detachControl=function(e){},r.prototype._update=function(){this.cameraRigMode!==r.RIG_MODE_NONE&&this._updateRigCameras(),this._checkInputs()},r.prototype._checkInputs=function(){},r.prototype.attachPostProcess=function(t,i){if(void 0===i&&(i=null),!t.isReusable()&&this._postProcesses.indexOf(t)>-1)return e.Tools.Error("You're trying to reuse a post process not defined as reusable."),0;if(null==i||0>i)return this._postProcesses.push(t),this._postProcessesTakenIndices.push(this._postProcesses.length-1),this._postProcesses.length-1;var r,n=0;if(this._postProcesses[i]){for(r=this._postProcesses.length-1;r>=i+1;--r)this._postProcesses[r+1]=this._postProcesses[r];n=1}for(r=0;r<this._postProcessesTakenIndices.length;++r)if(!(this._postProcessesTakenIndices[r]<i)){for(var o=this._postProcessesTakenIndices.length-1;o>=r;--o)this._postProcessesTakenIndices[o+1]=this._postProcessesTakenIndices[o]+n;this._postProcessesTakenIndices[r]=i;break}n||-1!==this._postProcessesTakenIndices.indexOf(i)||this._postProcessesTakenIndices.push(i);var s=i+n;return this._postProcesses[s]=t,s},r.prototype.detachPostProcess=function(e,t){void 0===t&&(t=null);var i,r,n=[];if(t)for(t=t instanceof Array?t:[t],i=0;i<t.length;i++){this._postProcesses[t[i]]===e?(delete this._postProcesses[t[i]],r=this._postProcessesTakenIndices.indexOf(t[i]),this._postProcessesTakenIndices.splice(r,1)):n.push(i)}else{var o=this._postProcesses.length;for(i=0;o>i;i++)this._postProcesses[i]===e&&(delete this._postProcesses[i],r=this._postProcessesTakenIndices.indexOf(i),this._postProcessesTakenIndices.splice(r,1))}return n},r.prototype.getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this.getViewMatrix().invertToRef(this._worldMatrix),this._worldMatrix},r.prototype._getViewMatrix=function(){return e.Matrix.Identity()},r.prototype.getViewMatrix=function(t){return this._computedViewMatrix=this._computeViewMatrix(t),!t&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this.parent&&this.parent.getWorldMatrix?(this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this._computedViewMatrix.invertToRef(this._worldMatrix),this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._computedViewMatrix),this._globalPosition.copyFromFloats(this._computedViewMatrix.m[12],this._computedViewMatrix.m[13],this._computedViewMatrix.m[14]),this._computedViewMatrix.invert(),this._markSyncedWithParent()):this._globalPosition.copyFrom(this.position),this._currentRenderId=this.getScene().getRenderId(),this._computedViewMatrix)},r.prototype._computeViewMatrix=function(e){return!e&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._computedViewMatrix)},r.prototype.getProjectionMatrix=function(t){if(!t&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;var i=this.getEngine();if(this.mode===r.PERSPECTIVE_CAMERA)return this.minZ<=0&&(this.minZ=.1),e.Matrix.PerspectiveFovLHToRef(this.fov,i.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode),this._projectionMatrix;var n=i.getRenderWidth()/2,o=i.getRenderHeight()/2;return e.Matrix.OrthoOffCenterLHToRef(this.orthoLeft||-n,this.orthoRight||n,this.orthoBottom||-o,this.orthoTop||o,this.minZ,this.maxZ,this._projectionMatrix),this._projectionMatrix},r.prototype.dispose=function(){for(this.getScene().removeCamera(this);this._rigCameras.length>0;)this._rigCameras.pop().dispose();for(var e=0;e<this._postProcessesTakenIndices.length;++e)this._postProcesses[this._postProcessesTakenIndices[e]].dispose(this)},r.prototype.setCameraRigMode=function(i,n){for(;this._rigCameras.length>0;)this._rigCameras.pop().dispose();switch(this.cameraRigMode=i,this._cameraRigParams={},this.cameraRigMode){case r.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case r.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case r.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case r.RIG_MODE_STEREOSCOPIC_OVERUNDER:this._cameraRigParams.interaxialDistance=n.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=e.Tools.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this._rigCameras.push(this.createRigCamera(this.name+"_L",0)),this._rigCameras.push(this.createRigCamera(this.name+"_R",1))}var o=new Array;switch(this.cameraRigMode){case r.RIG_MODE_STEREOSCOPIC_ANAGLYPH:o.push(new e.PassPostProcess(this.name+"_passthru",1,this._rigCameras[0])),this._rigCameras[0].isIntermediate=!0,o.push(new e.AnaglyphPostProcess(this.name+"_anaglyph",1,this._rigCameras[1])),o[1].onApply=function(e){e.setTextureFromPostProcess("leftSampler",o[0])};break;case r.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case r.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case r.RIG_MODE_STEREOSCOPIC_OVERUNDER:var s=this.cameraRigMode===r.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||this.cameraRigMode===r.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED,a=this.cameraRigMode===r.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?1:0,h=1-a;o.push(new e.PassPostProcess(this.name+"_passthru",1,this._rigCameras[a])),this._rigCameras[a].isIntermediate=!0,o.push(new e.StereoscopicInterlacePostProcess(this.name+"_stereoInterlace",this._rigCameras[h],o[0],s));break;case r.RIG_MODE_VR:this._rigCameras.push(this.createRigCamera(this.name+"_L",0)),this._rigCameras.push(this.createRigCamera(this.name+"_R",1));var c=n.vrCameraMetrics||t.GetDefault();this._rigCameras[0]._cameraRigParams.vrMetrics=c,this._rigCameras[0].viewport=new e.Viewport(0,0,.5,1),this._rigCameras[0]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[0]._cameraRigParams.vrHMatrix=c.leftHMatrix,this._rigCameras[0]._cameraRigParams.vrPreViewMatrix=c.leftPreViewMatrix,this._rigCameras[0].getProjectionMatrix=this._rigCameras[0]._getVRProjectionMatrix,c.compensateDistortion&&o.push(new e.VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Left",this._rigCameras[0],!1,c)),this._rigCameras[1]._cameraRigParams.vrMetrics=this._rigCameras[0]._cameraRigParams.vrMetrics,this._rigCameras[1].viewport=new e.Viewport(.5,0,.5,1),this._rigCameras[1]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[1]._cameraRigParams.vrHMatrix=c.rightHMatrix,this._rigCameras[1]._cameraRigParams.vrPreViewMatrix=c.rightPreViewMatrix,this._rigCameras[1].getProjectionMatrix=this._rigCameras[1]._getVRProjectionMatrix,c.compensateDistortion&&o.push(new e.VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Right",this._rigCameras[1],!0,c))}this._update()},r.prototype._getVRProjectionMatrix=function(){return e.Matrix.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.maxZ,this._cameraRigParams.vrWorkMatrix),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix},r.prototype.setCameraRigParameter=function(t,i){this._cameraRigParams[t]=i,"interaxialDistance"===t&&(this._cameraRigParams.stereoHalfAngle=e.Tools.ToRadians(i/.0637))},r.prototype.createRigCamera=function(e,t){return null},r.prototype._updateRigCameras=function(){for(var e=0;e<this._rigCameras.length;e++)this._rigCameras[e].minZ=this.minZ,this._rigCameras[e].maxZ=this.maxZ,this._rigCameras[e].fov=this.fov;this.cameraRigMode===r.RIG_MODE_STEREOSCOPIC_ANAGLYPH&&(this._rigCameras[0].viewport=this._rigCameras[1].viewport=this.viewport)},r._PERSPECTIVE_CAMERA=0,r._ORTHOGRAPHIC_CAMERA=1,r._FOVMODE_VERTICAL_FIXED=0,r._FOVMODE_HORIZONTAL_FIXED=1,r._RIG_MODE_NONE=0,r._RIG_MODE_STEREOSCOPIC_ANAGLYPH=10,r._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11,r._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12,r._RIG_MODE_STEREOSCOPIC_OVERUNDER=13,r._RIG_MODE_VR=20,r}(e.Node);e.Camera=i}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n){t.call(this,i,r,n),this.cameraDirection=new e.Vector3(0,0,0),this.cameraRotation=new e.Vector2(0,0),this.rotation=new e.Vector3(0,0,0),this.speed=2,this.noRotationConstraint=!1,this.lockedTarget=null,this._currentTarget=e.Vector3.Zero(),this._viewMatrix=e.Matrix.Zero(),this._camMatrix=e.Matrix.Zero(),this._cameraTransformMatrix=e.Matrix.Zero(),this._cameraRotationMatrix=e.Matrix.Zero(),this._referencePoint=new e.Vector3(0,0,1),this._transformedReferencePoint=e.Vector3.Zero(),this._lookAtTemp=e.Matrix.Zero(),this._tempMatrix=e.Matrix.Zero()}return __extends(i,t),i.prototype.getFrontPosition=function(e){var t=this.getTarget().subtract(this.position);return t.normalize(),t.scaleInPlace(e),this.globalPosition.add(t)},i.prototype._getLockedTargetPosition=function(){return this.lockedTarget?this.lockedTarget.position||this.lockedTarget:null},i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.lockedTarget=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},i.prototype._updateCache=function(e){e||t.prototype._updateCache.call(this);var i=this._getLockedTargetPosition();i?this._cache.lockedTarget?this._cache.lockedTarget.copyFrom(i):this._cache.lockedTarget=i.clone():this._cache.lockedTarget=null,this._cache.rotation.copyFrom(this.rotation)},i.prototype._isSynchronizedViewMatrix=function(){if(!t.prototype._isSynchronizedViewMatrix.call(this))return!1;var e=this._getLockedTargetPosition();return(this._cache.lockedTarget?this._cache.lockedTarget.equals(e):!e)&&this._cache.rotation.equals(this.rotation)},i.prototype._computeLocalCameraSpeed=function(){var e=this.getEngine();return this.speed*(e.getDeltaTime()/(10*e.getFps()))},i.prototype.setTarget=function(t){this.upVector.normalize(),e.Matrix.LookAtLHToRef(this.position,t,this.upVector,this._camMatrix),this._camMatrix.invert(),this.rotation.x=Math.atan(this._camMatrix.m[6]/this._camMatrix.m[10]);var i=t.subtract(this.position);this.rotation.y=i.x>=0?-Math.atan(i.z/i.x)+Math.PI/2:-Math.atan(i.z/i.x)-Math.PI/2,this.rotation.z=-Math.acos(e.Vector3.Dot(new e.Vector3(0,1,0),this.upVector)),isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0)},i.prototype.getTarget=function(){return this._currentTarget},i.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){this.position.addInPlace(this.cameraDirection)},i.prototype._checkInputs=function(){var i=this._decideIfNeedsToMove(),r=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(i&&this._updatePosition(),r&&(this.rotation.x+=this.cameraRotation.x,this.rotation.y+=this.cameraRotation.y,!this.noRotationConstraint)){var n=Math.PI/2*.95;this.rotation.x>n&&(this.rotation.x=n),this.rotation.x<-n&&(this.rotation.x=-n)}i&&(Math.abs(this.cameraDirection.x)<e.Engine.Epsilon&&(this.cameraDirection.x=0),Math.abs(this.cameraDirection.y)<e.Engine.Epsilon&&(this.cameraDirection.y=0),Math.abs(this.cameraDirection.z)<e.Engine.Epsilon&&(this.cameraDirection.z=0),this.cameraDirection.scaleInPlace(this.inertia)),r&&(Math.abs(this.cameraRotation.x)<e.Engine.Epsilon&&(this.cameraRotation.x=0),Math.abs(this.cameraRotation.y)<e.Engine.Epsilon&&(this.cameraRotation.y=0),this.cameraRotation.scaleInPlace(this.inertia)),t.prototype._checkInputs.call(this)},i.prototype._getViewMatrix=function(){return this.lockedTarget?this._currentTarget.copyFrom(this._getLockedTargetPosition()):(0!==this.upVector.x||1!==this.upVector.y||0!==this.upVector.z?(e.Matrix.LookAtLHToRef(e.Vector3.Zero(),this._referencePoint,this.upVector,this._lookAtTemp),e.Matrix.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix),this._lookAtTemp.multiplyToRef(this._cameraRotationMatrix,this._tempMatrix),this._lookAtTemp.invert(),this._tempMatrix.multiplyToRef(this._lookAtTemp,this._cameraRotationMatrix)):e.Matrix.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix),e.Vector3.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget)),e.Matrix.LookAtLHToRef(this.position,this._currentTarget,this.upVector,this._viewMatrix),this._viewMatrix},i.prototype._getVRViewMatrix=function(){return e.Matrix.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix),e.Vector3.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),e.Vector3.TransformNormalToRef(this.upVector,this._cameraRotationMatrix,this._cameraRigParams.vrActualUp),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),e.Matrix.LookAtLHToRef(this.position,this._currentTarget,this._cameraRigParams.vrActualUp,this._cameraRigParams.vrWorkMatrix),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._viewMatrix),this._viewMatrix},i.prototype.createRigCamera=function(t,r){if(this.cameraRigMode!==e.Camera.RIG_MODE_NONE){var n=new i(t,this.position.clone(),this.getScene());return this.cameraRigMode===e.Camera.RIG_MODE_VR&&(n._cameraRigParams={},n._cameraRigParams.vrActualUp=new e.Vector3(0,0,0),n._getViewMatrix=n._getVRViewMatrix),n}return null},i.prototype._updateRigCameras=function(){switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:var i=this._rigCameras[0],r=this._rigCameras[1];this.cameraRigMode===e.Camera.RIG_MODE_VR?(i.rotation.x=r.rotation.x=this.rotation.x,i.rotation.y=r.rotation.y=this.rotation.y,i.rotation.z=r.rotation.z=this.rotation.z,i.position.copyFrom(this.position),r.position.copyFrom(this.position)):(this._getRigCamPosition(-this._cameraRigParams.stereoHalfAngle,i.position),this._getRigCamPosition(this._cameraRigParams.stereoHalfAngle,r.position),i.setTarget(this.getTarget()),r.setTarget(this.getTarget()))}t.prototype._updateRigCameras.call(this)},i.prototype._getRigCamPosition=function(t,i){this._rigCamTransformMatrix||(this._rigCamTransformMatrix=new e.Matrix);var r=this.getTarget();e.Matrix.Translation(-r.x,-r.y,-r.z).multiplyToRef(e.Matrix.RotationY(t),this._rigCamTransformMatrix),this._rigCamTransformMatrix=this._rigCamTransformMatrix.multiply(e.Matrix.Translation(r.x,r.y,r.z)),e.Vector3.TransformCoordinatesToRef(this.position,this._rigCamTransformMatrix,i)},i}(e.Camera);e.TargetCamera=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n){var o=this;t.call(this,i,r,n),this.ellipsoid=new e.Vector3(.5,1,.5),this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this.checkCollisions=!1,this.applyGravity=!1,this.angularSensibility=2e3,this._keys=[],this._collider=new e.Collider,this._needMoveForGravity=!1,this._oldPosition=e.Vector3.Zero(),this._diffPosition=e.Vector3.Zero(),this._newPosition=e.Vector3.Zero(),this._onCollisionPositionChange=function(t,i,r){void 0===r&&(r=null),o.getScene().workerCollisions&&i.multiplyInPlace(o._collider.radius);!function(t){o._newPosition.copyFrom(t),o._newPosition.subtractToRef(o._oldPosition,o._diffPosition),o.position.clone(),o._diffPosition.length()>e.Engine.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&r&&o.onCollide(r))}(i)}}return __extends(i,t),i.prototype.attachControl=function(t,i){var r,n=this,o=this.getEngine();this._attachedElement||(this._attachedElement=t,void 0===this._onMouseDown&&(this._onMouseDown=function(e){r={x:e.clientX,y:e.clientY},i||e.preventDefault()},this._onMouseUp=function(e){r=null,i||e.preventDefault()},this._onMouseOut=function(e){r=null,n._keys=[],i||e.preventDefault()},this._onMouseMove=function(e){var t,s;(r||o.isPointerLock)&&(o.isPointerLock?(t=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0,s=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0):(t=e.clientX-r.x,s=e.clientY-r.y),n.cameraRotation.y+=t/n.angularSensibility,n.cameraRotation.x+=s/n.angularSensibility,r={x:e.clientX,y:e.clientY},i||e.preventDefault())},this._onKeyDown=function(e){-1===n.keysUp.indexOf(e.keyCode)&&-1===n.keysDown.indexOf(e.keyCode)&&-1===n.keysLeft.indexOf(e.keyCode)&&-1===n.keysRight.indexOf(e.keyCode)||(-1===n._keys.indexOf(e.keyCode)&&n._keys.push(e.keyCode),i||e.preventDefault())},this._onKeyUp=function(e){if(-1!==n.keysUp.indexOf(e.keyCode)||-1!==n.keysDown.indexOf(e.keyCode)||-1!==n.keysLeft.indexOf(e.keyCode)||-1!==n.keysRight.indexOf(e.keyCode)){var t=n._keys.indexOf(e.keyCode);t>=0&&n._keys.splice(t,1),i||e.preventDefault()}},this._onLostFocus=function(){n._keys=[]},this._reset=function(){n._keys=[],r=null,n.cameraDirection=new e.Vector3(0,0,0),n.cameraRotation=new e.Vector2(0,0)}),t.addEventListener("mousedown",this._onMouseDown,!1),t.addEventListener("mouseup",this._onMouseUp,!1),t.addEventListener("mouseout",this._onMouseOut,!1),t.addEventListener("mousemove",this._onMouseMove,!1),e.Tools.RegisterTopRootEvents([{name:"keydown",handler:this._onKeyDown},{name:"keyup",handler:this._onKeyUp},{name:"blur",handler:this._onLostFocus}]))},i.prototype.detachControl=function(t){this._attachedElement==t&&(t.removeEventListener("mousedown",this._onMouseDown),t.removeEventListener("mouseup",this._onMouseUp),t.removeEventListener("mouseout",this._onMouseOut),t.removeEventListener("mousemove",this._onMouseMove),e.Tools.UnregisterTopRootEvents([{name:"keydown",handler:this._onKeyDown},{name:"keyup",handler:this._onKeyUp},{name:"blur",handler:this._onLostFocus}]),this._attachedElement=null,this._reset&&this._reset())},i.prototype._collideWithWorld=function(t){(this.parent?e.Vector3.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position).subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._collider.radius=this.ellipsoid;var i=t;this.applyGravity&&(i=t.add(this.getScene().gravity)),this.getScene().collisionCoordinator.getNewPosition(this._oldPosition,i,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},i.prototype._checkInputs=function(){this._localDirection||(this._localDirection=e.Vector3.Zero(),this._transformedDirection=e.Vector3.Zero());for(var i=0;i<this._keys.length;i++){var r=this._keys[i],n=this._computeLocalCameraSpeed();-1!==this.keysLeft.indexOf(r)?this._localDirection.copyFromFloats(-n,0,0):-1!==this.keysUp.indexOf(r)?this._localDirection.copyFromFloats(0,0,n):-1!==this.keysRight.indexOf(r)?this._localDirection.copyFromFloats(n,0,0):-1!==this.keysDown.indexOf(r)&&this._localDirection.copyFromFloats(0,0,-n),this.getViewMatrix().invertToRef(this._cameraTransformMatrix),e.Vector3.TransformNormalToRef(this._localDirection,this._cameraTransformMatrix,this._transformedDirection),this.cameraDirection.addInPlace(this._transformedDirection)}t.prototype._checkInputs.call(this)},i.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):this.position.addInPlace(this.cameraDirection)},i}(e.TargetCamera);e.FreeCamera=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(e,i,r){t.call(this,e,i,r),this.radius=12,this.rotationOffset=0,this.heightOffset=4,this.cameraAcceleration=.05,this.maxCameraSpeed=20}return __extends(i,t),i.prototype.getRadians=function(e){return e*Math.PI/180},i.prototype.follow=function(t){if(t){var i;if(t.rotationQuaternion){var r=new e.Matrix;t.rotationQuaternion.toRotationMatrix(r),i=Math.atan2(r.m[8],r.m[10])}else i=t.rotation.y;var n=this.getRadians(this.rotationOffset)+i,o=t.position.x+Math.sin(n)*this.radius,s=t.position.z+Math.cos(n)*this.radius,a=o-this.position.x,h=t.position.y+this.heightOffset-this.position.y,c=s-this.position.z,l=a*this.cameraAcceleration*2,u=h*this.cameraAcceleration,d=c*this.cameraAcceleration*2;(l>this.maxCameraSpeed||l<-this.maxCameraSpeed)&&(l=1>l?-this.maxCameraSpeed:this.maxCameraSpeed),(u>this.maxCameraSpeed||u<-this.maxCameraSpeed)&&(u=1>u?-this.maxCameraSpeed:this.maxCameraSpeed),(d>this.maxCameraSpeed||d<-this.maxCameraSpeed)&&(d=1>d?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new e.Vector3(this.position.x+l,this.position.y+u,this.position.z+d),this.setTarget(t.position)}},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.follow(this.target)},i}(e.TargetCamera);e.FollowCamera=t;var i=function(t){function i(i,r,n,o,s,a){t.call(this,i,e.Vector3.Zero(),a),this.alpha=r,this.beta=n,this.radius=o,this.target=s,this._cartesianCoordinates=e.Vector3.Zero(),this.follow()}return __extends(i,t),i.prototype.follow=function(){this._cartesianCoordinates.x=this.radius*Math.cos(this.alpha)*Math.cos(this.beta),this._cartesianCoordinates.y=this.radius*Math.sin(this.beta),this._cartesianCoordinates.z=this.radius*Math.sin(this.alpha)*Math.cos(this.beta),this.position=this.target.position.add(this._cartesianCoordinates),this.setTarget(this.target.position)},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.follow()},i}(e.TargetCamera);e.ArcFollowCamera=i}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(e,i,r){t.call(this,e,i,r),this._offsetX=null,this._offsetY=null,this._pointerCount=0,this._pointerPressed=[],this.angularSensibility=2e5,this.moveSensibility=500}return __extends(i,t),i.prototype.attachControl=function(t,i){var r,n=this;this._attachedCanvas||(this._attachedCanvas=t,void 0===this._onPointerDown&&(this._onPointerDown=function(e){i||e.preventDefault(),n._pointerPressed.push(e.pointerId),1===n._pointerPressed.length&&(r={x:e.clientX,y:e.clientY})},this._onPointerUp=function(e){i||e.preventDefault();var t=n._pointerPressed.indexOf(e.pointerId);-1!==t&&(n._pointerPressed.splice(t,1),0==t&&(r=null,n._offsetX=null,n._offsetY=null))},this._onPointerMove=function(e){(i||e.preventDefault(),r)&&(0==n._pointerPressed.indexOf(e.pointerId)&&(n._offsetX=e.clientX-r.x,n._offsetY=-(e.clientY-r.y)))},this._onLostFocus=function(){n._offsetX=null,n._offsetY=null}),t.addEventListener("pointerdown",this._onPointerDown),t.addEventListener("pointerup",this._onPointerUp),t.addEventListener("pointerout",this._onPointerUp),t.addEventListener("pointermove",this._onPointerMove),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]))},i.prototype.detachControl=function(t){this._attachedCanvas==t&&(t.removeEventListener("pointerdown",this._onPointerDown),t.removeEventListener("pointerup",this._onPointerUp),t.removeEventListener("pointerout",this._onPointerUp),t.removeEventListener("pointermove",this._onPointerMove),e.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),this._attachedCanvas=null)},i.prototype._checkInputs=function(){if(this._offsetX)if(this.cameraRotation.y+=this._offsetX/this.angularSensibility,this._pointerPressed.length>1)this.cameraRotation.x+=-this._offsetY/this.angularSensibility;else{var i=this._computeLocalCameraSpeed(),r=new e.Vector3(0,0,i*this._offsetY/this.moveSensibility);e.Matrix.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,0,this._cameraRotationMatrix),this.cameraDirection.addInPlace(e.Vector3.TransformCoordinates(r,this._cameraRotationMatrix))}t.prototype._checkInputs.call(this)},i}(e.FreeCamera);e.TouchCamera=t}(BABYLON||(BABYLON={})),function(e){var t=e.Tools.GetPointerPrefix(),i=function(i){function r(t,r,n,o,s,a){var h=this;i.call(this,t,e.Vector3.Zero(),a),this.alpha=r,this.beta=n,this.radius=o,this.target=s,this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.lowerAlphaLimit=null,this.upperAlphaLimit=null,this.lowerBetaLimit=.01,this.upperBetaLimit=Math.PI,this.lowerRadiusLimit=null,this.upperRadiusLimit=null,this.angularSensibilityX=1e3,this.angularSensibilityY=1e3,this.wheelPrecision=3,this.pinchPrecision=2,this.panningSensibility=50,this.inertialPanningX=0,this.inertialPanningY=0,this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this.zoomOnFactor=1,this.targetScreenOffset=e.Vector2.Zero(),this.pinchInwards=!0,this.allowUpsideDown=!0,this._keys=[],this._viewMatrix=new e.Matrix,this._isRightClick=!1,this._isCtrlPushed=!1,this.checkCollisions=!1,this.collisionRadius=new e.Vector3(.5,.5,.5),this._collider=new e.Collider,this._previousPosition=e.Vector3.Zero(),this._collisionVelocity=e.Vector3.Zero(),this._newPosition=e.Vector3.Zero(),this._onCollisionPositionChange=function(t,i,r){void 0===r&&(r=null),h.getScene().workerCollisions&&h.checkCollisions&&i.multiplyInPlace(h._collider.radius),r?(h.setPosition(h.position),h.onCollide&&h.onCollide(r)):h._previousPosition.copyFrom(h.position);var n=Math.cos(h.alpha),o=Math.sin(h.alpha),s=Math.cos(h.beta),a=Math.sin(h.beta),c=h._getTargetPosition();c.addToRef(new e.Vector3(h.radius*n*a,h.radius*s,h.radius*o*a),h._newPosition),h.position.copyFrom(h._newPosition);var l=h.upVector;h.allowUpsideDown&&h.beta<0&&(l=(l=l.clone()).negate());e.Matrix.LookAtLHToRef(h.position,c,l,h._viewMatrix),h._viewMatrix.m[12]+=h.targetScreenOffset.x,h._viewMatrix.m[13]+=h.targetScreenOffset.y,h._collisionTriggered=!1},this.target||(this.target=e.Vector3.Zero()),this.getViewMatrix()}return __extends(r,i),Object.defineProperty(r.prototype,"angularSensibility",{get:function(){return e.Tools.Warn("Warning: angularSensibility is deprecated, use angularSensibilityX and angularSensibilityY instead."),Math.max(this.angularSensibilityX,this.angularSensibilityY)},set:function(t){e.Tools.Warn("Warning: angularSensibility is deprecated, use angularSensibilityX and angularSensibilityY instead."),this.angularSensibilityX=t,this.angularSensibilityY=t},enumerable:!0,configurable:!0}),r.prototype._getTargetPosition=function(){return this.target.position||this.target},r.prototype._initCache=function(){i.prototype._initCache.call(this),this._cache.target=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.alpha=void 0,this._cache.beta=void 0,this._cache.radius=void 0,this._cache.targetScreenOffset=void 0},r.prototype._updateCache=function(e){e||i.prototype._updateCache.call(this),this._cache.target.copyFrom(this._getTargetPosition()),this._cache.alpha=this.alpha,this._cache.beta=this.beta,this._cache.radius=this.radius,this._cache.targetScreenOffset=this.targetScreenOffset.clone()},r.prototype._isSynchronizedViewMatrix=function(){return!!i.prototype._isSynchronizedViewMatrix.call(this)&&(this._cache.target.equals(this._getTargetPosition())&&this._cache.alpha===this.alpha&&this._cache.beta===this.beta&&this._cache.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset))},r.prototype.attachControl=function(i,r,n){var o=this;void 0===n&&(n=!0);var s,a=0,h=new e.SmartCollection;if(!this._attachedElement){this._attachedElement=i;var c=this.getEngine();void 0===this._onPointerDown&&(this._onPointerDown=function(e){o._isRightClick=2===e.button,h.add(e.pointerId,{x:e.clientX,y:e.clientY,type:e.pointerType}),s=h.item(e.pointerId),r||e.preventDefault()},this._onPointerUp=function(e){s=null,a=0,h.empty(),r||e.preventDefault()},this._onContextMenu=function(e){e.preventDefault()},this._onPointerMove=function(e){switch(r||e.preventDefault(),h.count){case 1:if(o._isCtrlPushed&&n||!n&&o._isRightClick)o.inertialPanningX+=-(e.clientX-s.x)/o.panningSensibility,o.inertialPanningY+=(e.clientY-s.y)/o.panningSensibility;else{var t=e.clientX-s.x,i=e.clientY-s.y;o.inertialAlphaOffset-=t/o.angularSensibilityX,o.inertialBetaOffset-=i/o.angularSensibilityY}s.x=e.clientX,s.y=e.clientY;break;case 2:h.item(e.pointerId).x=e.clientX,h.item(e.pointerId).y=e.clientY;var c=o.pinchInwards?1:-1,l=h.getItemByIndex(0).x-h.getItemByIndex(1).x,u=h.getItemByIndex(0).y-h.getItemByIndex(1).y,d=l*l+u*u;if(0===a)return void(a=d);d!==a&&(o.inertialRadiusOffset+=(d-a)/(o.pinchPrecision*o.wheelPrecision*((o.angularSensibilityX+o.angularSensibilityY)/2)*c),a=d);break;default:h.item(e.pointerId)&&(h.item(e.pointerId).x=e.clientX,h.item(e.pointerId).y=e.clientY)}},this._onMouseMove=function(e){if(c.isPointerLock){var t=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0,i=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;o.inertialAlphaOffset-=t/o.angularSensibilityX,o.inertialBetaOffset-=i/o.angularSensibilityY,r||e.preventDefault()}},this._wheel=function(e){var t=0;e.wheelDelta?t=e.wheelDelta/(40*o.wheelPrecision):e.detail&&(t=-e.detail/o.wheelPrecision),t&&(o.inertialRadiusOffset+=t),e.preventDefault&&(r||e.preventDefault())},this._onKeyDown=function(e){(o._isCtrlPushed=e.ctrlKey,-1!==o.keysUp.indexOf(e.keyCode)||-1!==o.keysDown.indexOf(e.keyCode)||-1!==o.keysLeft.indexOf(e.keyCode)||-1!==o.keysRight.indexOf(e.keyCode))&&(-1===o._keys.indexOf(e.keyCode)&&o._keys.push(e.keyCode),e.preventDefault&&(r||e.preventDefault()))},this._onKeyUp=function(e){if(o._isCtrlPushed=e.ctrlKey,-1!==o.keysUp.indexOf(e.keyCode)||-1!==o.keysDown.indexOf(e.keyCode)||-1!==o.keysLeft.indexOf(e.keyCode)||-1!==o.keysRight.indexOf(e.keyCode)){var t=o._keys.indexOf(e.keyCode);t>=0&&o._keys.splice(t,1),e.preventDefault&&(r||e.preventDefault())}},this._onLostFocus=function(){o._keys=[],h.empty(),a=0,s=null},this._onGestureStart=function(e){void 0!==window.MSGesture&&(o._MSGestureHandler||(o._MSGestureHandler=new MSGesture,o._MSGestureHandler.target=i),o._MSGestureHandler.addPointer(e.pointerId))},this._onGesture=function(e){o.radius*=e.scale,e.preventDefault&&(r||(e.stopPropagation(),e.preventDefault()))},this._reset=function(){o._keys=[],o.inertialAlphaOffset=0,o.inertialBetaOffset=0,o.inertialRadiusOffset=0,h.empty(),a=0,s=null}),n||i.addEventListener("contextmenu",this._onContextMenu,!1),i.addEventListener(t+"down",this._onPointerDown,!1),i.addEventListener(t+"up",this._onPointerUp,!1),i.addEventListener(t+"out",this._onPointerUp,!1),i.addEventListener(t+"move",this._onPointerMove,!1),i.addEventListener("mousemove",this._onMouseMove,!1),i.addEventListener("MSPointerDown",this._onGestureStart,!1),i.addEventListener("MSGestureChange",this._onGesture,!1),i.addEventListener("mousewheel",this._wheel,!1),i.addEventListener("DOMMouseScroll",this._wheel,!1),e.Tools.RegisterTopRootEvents([{name:"keydown",handler:this._onKeyDown},{name:"keyup",handler:this._onKeyUp},{name:"blur",handler:this._onLostFocus}])}},r.prototype.detachControl=function(i){this._attachedElement===i&&(i.removeEventListener("contextmenu",this._onContextMenu),i.removeEventListener(t+"down",this._onPointerDown),i.removeEventListener(t+"up",this._onPointerUp),i.removeEventListener(t+"out",this._onPointerUp),i.removeEventListener(t+"move",this._onPointerMove),i.removeEventListener("mousemove",this._onMouseMove),i.removeEventListener("MSPointerDown",this._onGestureStart),i.removeEventListener("MSGestureChange",this._onGesture),i.removeEventListener("mousewheel",this._wheel),i.removeEventListener("DOMMouseScroll",this._wheel),e.Tools.UnregisterTopRootEvents([{name:"keydown",handler:this._onKeyDown},{name:"keyup",handler:this._onKeyUp},{name:"blur",handler:this._onLostFocus}]),this._MSGestureHandler=null,this._attachedElement=null,this._reset&&this._reset())},r.prototype._checkInputs=function(){if(!this._collisionTriggered){for(var t=0;t<this._keys.length;t++){var r=this._keys[t];-1!==this.keysLeft.indexOf(r)?this.inertialAlphaOffset-=.01:-1!==this.keysUp.indexOf(r)?this.inertialBetaOffset-=.01:-1!==this.keysRight.indexOf(r)?this.inertialAlphaOffset+=.01:-1!==this.keysDown.indexOf(r)&&(this.inertialBetaOffset+=.01)}(0!==this.inertialAlphaOffset||0!==this.inertialBetaOffset||0!=this.inertialRadiusOffset)&&(this.alpha+=this.beta<=0?-this.inertialAlphaOffset:this.inertialAlphaOffset,this.beta+=this.inertialBetaOffset,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)<e.Engine.Epsilon&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<e.Engine.Epsilon&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)<e.Engine.Epsilon&&(this.inertialRadiusOffset=0)),(0!==this.inertialPanningX||0!==this.inertialPanningY)&&(this._localDirection||(this._localDirection=e.Vector3.Zero(),this._transformedDirection=e.Vector3.Zero()),this.inertialPanningX*=this.inertia,this.inertialPanningY*=this.inertia,Math.abs(this.inertialPanningX)<e.Engine.Epsilon&&(this.inertialPanningX=0),Math.abs(this.inertialPanningY)<e.Engine.Epsilon&&(this.inertialPanningY=0),this._localDirection.copyFromFloats(this.inertialPanningX,this.inertialPanningY,0),this._viewMatrix.invertToRef(this._cameraTransformMatrix),e.Vector3.TransformNormalToRef(this._localDirection,this._cameraTransformMatrix,this._transformedDirection),this.target.addInPlace(this._transformedDirection)),this._checkLimits(),i.prototype._checkInputs.call(this)}},r.prototype._checkLimits=function(){null===this.lowerBetaLimit||void 0===this.lowerBetaLimit?this.allowUpsideDown&&this.beta>Math.PI&&(this.beta=this.beta-2*Math.PI):this.beta<this.lowerBetaLimit&&(this.beta=this.lowerBetaLimit),null===this.upperBetaLimit||void 0===this.upperBetaLimit?this.allowUpsideDown&&this.beta<-Math.PI&&(this.beta=this.beta+2*Math.PI):this.beta>this.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit&&this.alpha<this.lowerAlphaLimit&&(this.alpha=this.lowerAlphaLimit),this.upperAlphaLimit&&this.alpha>this.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radius<this.lowerRadiusLimit&&(this.radius=this.lowerRadiusLimit),this.upperRadiusLimit&&this.radius>this.upperRadiusLimit&&(this.radius=this.upperRadiusLimit)},r.prototype.setPosition=function(e){var t=e.subtract(this._getTargetPosition());this.radius=t.length(),this.alpha=Math.acos(t.x/Math.sqrt(Math.pow(t.x,2)+Math.pow(t.z,2))),t.z<0&&(this.alpha=2*Math.PI-this.alpha),this.beta=Math.acos(t.y/this.radius),this._checkLimits()},r.prototype.setTarget=function(e){this.target=e},r.prototype._getViewMatrix=function(){var t=Math.cos(this.alpha),i=Math.sin(this.alpha),r=Math.cos(this.beta),n=Math.sin(this.beta),o=this._getTargetPosition();if(o.addToRef(new e.Vector3(this.radius*t*n,this.radius*r,this.radius*i*n),this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions)this._collider.radius=this.collisionRadius,this._newPosition.subtractToRef(this.position,this._collisionVelocity),this._collisionTriggered=!0,this.getScene().collisionCoordinator.getNewPosition(this.position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId);else{this.position.copyFrom(this._newPosition);var s=this.upVector;if(this.allowUpsideDown&&this.beta<0)s=(s=s.clone()).negate();e.Matrix.LookAtLHToRef(this.position,o,s,this._viewMatrix),this._viewMatrix.m[12]+=this.targetScreenOffset.x,this._viewMatrix.m[13]+=this.targetScreenOffset.y}return this._viewMatrix},r.prototype.zoomOn=function(t,i){void 0===i&&(i=!1),t=t||this.getScene().meshes;var r=e.Mesh.MinMax(t),n=e.Vector3.Distance(r.min,r.max);this.radius=n*this.zoomOnFactor,this.focusOn({min:r.min,max:r.max,distance:n},i)},r.prototype.focusOn=function(t,i){var r,n;void 0===i&&(i=!1),void 0===t.min?(r=t||this.getScene().meshes,r=e.Mesh.MinMax(r),n=e.Vector3.Distance(r.min,r.max)):(r=t,n=t.distance),this.target=e.Mesh.Center(r),i||(this.maxZ=2*n)},r.prototype.createRigCamera=function(t,i){switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:var n=this._cameraRigParams.stereoHalfAngle*(0===i?1:-1);return new r(t,this.alpha+n,this.beta,this.radius,this.target,this.getScene())}},r.prototype._updateRigCameras=function(){switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:var t=this._rigCameras[0],r=this._rigCameras[1];t.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,t.beta=r.beta=this.beta,t.radius=r.radius=this.radius}i.prototype._updateRigCameras.call(this)},r}(e.TargetCamera);e.ArcRotateCamera=i}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(e,i,r){var n=this;t.call(this,e,i,r),this._offsetX=null,this._offsetY=null,this._orientationGamma=0,this._orientationBeta=0,this._initialOrientationGamma=0,this._initialOrientationBeta=0,this.angularSensibility=1e4,this.moveSensibility=50,window.addEventListener("resize",function(){n._initialOrientationGamma=null},!1)}return __extends(i,t),i.prototype.attachControl=function(e,t){var i=this;this._attachedCanvas||(this._attachedCanvas=e,this._orientationChanged||(this._orientationChanged=function(e){i._initialOrientationGamma||(i._initialOrientationGamma=e.gamma,i._initialOrientationBeta=e.beta),i._orientationGamma=e.gamma,i._orientationBeta=e.beta,i._offsetY=i._initialOrientationBeta-i._orientationBeta,i._offsetX=i._initialOrientationGamma-i._orientationGamma}),window.addEventListener("deviceorientation",this._orientationChanged))},i.prototype.detachControl=function(e){this._attachedCanvas==e&&(window.removeEventListener("deviceorientation",this._orientationChanged),this._attachedCanvas=null,this._orientationGamma=0,this._orientationBeta=0,this._initialOrientationGamma=0,this._initialOrientationBeta=0)},i.prototype._checkInputs=function(){if(this._offsetX){this.cameraRotation.y-=this._offsetX/this.angularSensibility;var i=this._computeLocalCameraSpeed(),r=new e.Vector3(0,0,i*this._offsetY/this.moveSensibility);e.Matrix.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,0,this._cameraRotationMatrix),this.cameraDirection.addInPlace(e.Vector3.TransformCoordinates(r,this._cameraRotationMatrix)),t.prototype._checkInputs.call(this)}},i}(e.FreeCamera);e.DeviceOrientationCamera=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function e(e){var t=this;this.babylonGamepads=[],this.oneGamepadConnected=!1,this.isMonitoring=!1,this.gamepadEventSupported="GamepadEvent"in window,this.gamepadSupportAvailable=navigator.getGamepads||!!navigator.webkitGetGamepads||!!navigator.msGetGamepads||!!navigator.webkitGamepads,this.buttonADataURL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAA9aSURBVHja7FtpbBzneX7m3otcihSpm9Z9UJalxPKhVLZlp6ktNzEaxE0CtAnQAgnSoPWPBi3syuiPwordFi5Qt2haFygCoylSV4Vby6os1I3kOLYrS65kXXQoypJJSaFEUTyXy925+rzfzC6HFFlL1kpAIe7i5czO7H7zPs97ft8MtTAMcSu/dNzirxkCZgiYIWCGgBkCZgi4hV/mDR5fSxAt+0ZiX0ucDxMSTJLK+f83BFSA6TFgK75OclshouKBFbA+xaV4k7Z+fD6sNRlmjYFXQMu4NiUVS/oHe5/ecnHo3MYxd7QthN9UcsdW6FqEPwgDOFbqpAajL2VlTrTULzj4Ow8+s4+nipSxWMoxIUkyrl/pGswFtIR7WzHgDCX77K7vfHNkbOA+AryjYZadb27OIJdzCNZBKmXw4kbk35qPsTEfJbeEkZESentHMdBfGtY142gu1bDvqV/925f4tQJlNCaj4hXX7RHXS0AFuJEAXvfHr/zmk67vPjir0V68aFEe8xtuQ6O1FHlrEXLmHBiaDUtzYBlpNYjrF+GFZfhhCcPeBQy53ehzT+H8QBe6uwfRf7l8xjKsvX/y5X98jl8fThDhJ4i46QQkrS5I6v7oX7/++77vPtLUlFnZtnIRlubvxRxnHbJmE79sxD/SqG0oZk8MFarRqufUkQAFrxcXSkfx0eB+nOggKX2jHYZhvf79r/z4L2IiipO84aYRkASfefnAX695p3P3c9mM/UufuaMVdzRvxVx7A0xaWdOMqVULJ6Z3TZv6KmHo0ztK6CkfxpHe3Th0pAuF0fLbn1u+9cmv3vW77bE3fGoSPi0BVfAvvPEHm9rPv//iooWz5m9Z/wCWZx+Go9UrN48QTD9IGMZ1cJIzTPisRQclPMrhME4W9mDfB2+i+2z/+TXz7/z2E7/85+9OIuGGE6BV3H77zm/d33nx6Ktr18zFg2t+DQude2n1tLJ8tcJ90vDhpG5Am7qTkJAQErywiLOld7G3/d9xvL0Hy1vWPbbtS3//00Q4hDeaAFXintrx1fu7+jp2r13bgofX/gaazbVkJQdLT9P6VqRFDSu2hIgXlBUBLgtCr3cce47/CMePX0Rr08qtzz7+8k8TpfKGtcKq1jPZre7oObyjdWkGd628l7AXwvMCeL7HjO6qrS8S1E5kTE9tfbiur665ccU9EB1EF9Ep0WXesEZIJb9j5/b/XUtzNrt29Rw0og2lchmBVqLo8LSAHlCixbTpddGm8Y7pjkttCCUP+JQy3FiatNuxdvUx9F4ayopO/OL9sQeEN4oA/eHn577oWPbGVes11PsrUBxjDafze1Te1VzouqnK2TgmLQljQqmrnAsT+iaPVb5b2co7EC+QhBgUeM1R1AcrsGp9Jy6+4W8U3fZ8r+e3EnOI2uaAX3l+zgNB4O9rW5/B8tY5WGo9BtOrJ4uMfUl+uj0B8HTmPXj8Pex86xVEnTDBBSE2r78fX9i09RPyZfT2A5ceIMSPwDOH8JH7Kk5+fAHtR0Zh6MZ9e7534Wc3wgO0sXLhD9OpFOa0egjGMhguD8BgTJooMfPbV1h/umz25ondcFP90IzY2iTgrfY9uH31aqSc9CeSEHkBEyITv28M8XMGc2/z0HGCpWCs8BS/9sWrDYOrJuCBZ+vu5sUfXbicia5kYGzUw4DWTwJKbApSjHuTBBjT2H68zg0MD4KlEwabZi0Y7wd85u/3O9/B6sVrPlEXeiF9nMmRxPt6Qf4y/HyIbh3HwkdF1zefGt5fUwK8wP2WAGwh02MFE/5ogYr3Qg/STL0W3d8aB1ppa+Pw0uI2Tz6/134Mg+UoIGZlZ2HMLaJYHkPICr6//RBamvPj/UA4dYKsegGrXqAXMaqNsDT6SreOY5Gu/FptCeBFN+caAphGiKFiGaOjA3AJHoGt6r7GgNbjqjo5yQkBUVHQ8PaJExjiaZ2yue12nO27gCNdHSptvf/xGdw11I2UZSmvCIJgQiJMhoEfeqpNDvUSRvUB5hMX9fUecg0aBi+Hm2uaAz633bmbm1VN8+h07LfKJdkOkQB2fL4BTlsj8No4YLG2putMSjwjp3QNvZdH8YsiExV501isFjU30lpF7D8dVfCA8sFHp7BuWYtaIwiCsCrCSDVhh9IX8k0CoHsoMQ84FrfFAE3zQAK0VaLzO9tK79XKAxSj+aYALt3XLfNipZD1v492YexrE/sP0zBgUIQIoYaflAXbz16CzyY6YKqYl8uheTarRioD7xAxCQHUpv18L1Yud+Iloujtk4zQo9WZcKURqjbHclzKvj0Gvcw8UA6oY2WqonSuGQGb5I+TJgEFEsB4daXzc0eopabcX13W0BXwgAnRZL4Q62s8ppnR/pFz/QjF+tRvxeIsY/cizGwRt83P4czACL8HdA1JUivCNGVogvdkNkgaGDNe4CvXFyJ8n+B5XGLJ1FmJXJ53AzjZKgGbatkKL5c/liNWIPO8uM/4VO2uKCQZjLmBqQAGJ4EmI8NMabDTOuyUobYXmPlCEpiqA1IkYdWSBpjpEDl6wsrF9aAjqHNOPXDyXAGprAknY5B0btOGGk/GlfE1taqofCNuuYNIJ+omOiZ1rpUHtEYWjkpWoP5EWV2sb5isA7aIQTHHxaIniNADui8PIs0Eb6SY/Z0UQc+j+mXYuoM7Vy/Age7zkBUyCZGLhRLSOYcWpfXFA1wPhqup8JNKq5UkKeoqSHxPLSoqnUQtw5ioc60IyE/VkOji8mYE2nZELNgCXLaOkGDFJBg4OzCMDEcxCfAzS1pQX5fHSNDLClLGwmwzls6vQ09hGFJYegdZ1hha2bqIBNelB5Qjog02TzpFNVEquYpMuTSYr/lcQPKPJHoRQ8W1GYO3lDgpO9pPWTEZEQGnuodg5Hyk66Lyd8fKOQQ6gqyWict7GeuWz8HQyWEFw+bB7ksF3Nk2V1nfpZTLQqSLslzXlDmHpsQ1osVoy/Solwf/GpdErpaAQUqjWxL2GWcWaSfAMIis7RBwiuCdtD1OgmNHBJCg7r4uZBnbdjaaq+3YewB+USYicY8juYPnMtloqdCjG3f39eO+3JKIAFadSiiZigBdgdcqItMxsmZbIbvUIKlzzQjoEgLGRjU2KTp8AjRCkzEnAG0mtQh8Ku0oAqok8JzP+Lw0MkB3jpKjKpapaL5WKZxafDdBqoC6O8LtyMAQhoZdzG7MwLU8FUYKPINcl+qimismRj26v2I71I3jDxfdpM41I6CTsmG4X0djKyc8RYu9t0Vl2QJbBJ5xFPiICJIg1hdhR3fs5HnWeldleZXABLA98b7Y5HtjkgwNEtbTN4iFC5oI3I1CTsAbsfVjAizJB3Qbx9HphRp6eqr3TDprSYA0FI/3ntOxbpUNM2OjpEcE6HYEWkhIKw+ICeBxi+T09F1WZU+iJq2n8fRDf4Ymu3XSrcOIgg8H9uOFn31fNUVC0oddZ7B5YxtDwlTgo66SEici2fokwCJjju0hw7J54WypQsB7tSRAza+H+nld30Y+m2b7SS+Qn9PKFl1egRciHIfWpxC8x+7tdA97+3zUcNyWX4Ci/THOoD2x/hmlQTox+3gDjWYeg/4gmF853xjBpUsjaGnJR24fu36FNzX5pmfY7EPStlSLIgb6gwk616QRYk8tS88/l/2PT/loyqbQkEmhPpNGNp1CmvtieQHvONGtL4sdy9Hjp5kkpTWmSzM7L529hErHs0cCpt2qW00BymDV3JXSU8HkAXKIjtNnedxS48m4Mr5cR9YlMrx+XTqNRmbP2ZkMOjvHKir/PNa5pouiitFjH44iZ6YwO5tFAy+eo6SdpOUJyhBQTJR+HT9HYLJaFve0PqQmTQLaVOCdmIRIWE+wrmWTzG8iAugF7qgWjSWkGbYa32EjJQTkGFv5dBZNJKCeHdb77UPXZP1rWhKLZ4Rqjv2Fz86lLMNlpusCY9BnqTNUIyTgrVhhs7rVq2KoW2TSxWlXLOCqWX4svmpzZdEjWvgQcdVWPnu+i4ClUS+HyLIFnsVf/9eBduw8eKYy2D1XMxO8Jg+IB9wl+3s/uAC3qKMpXY88m/ecnUHaSis3Na8Ab1UtaCh3j1y+sm8m9o0J+9Fv9MR4Zhw6DufTWasOebsOs+xZKHJOtvtQtertulrwV+0BtH5yWvyW7CxubsCTX9+KUQZ4ga7qmdGUFmrya8QWHwcxlReMF8Mw4QETrR8oy7tq2ivH5Tvya8n8aXZMGc4An/nRDpy52FfR8b5KCJCImt8YkYF/KDtnegfwz3sPodGajQajCTk9z/4mQ6iphMWv9AA9IeMWdyYdn+gBkVc5amwHWV6lHvVaI2YZzfinN95Ngv/htcT/p31CRNbdV8l8e++xD5HPNeHxhx5Bgf18kTN5T1kvjBfEjGjBJCai4gnjHqAnlvqS8e9NeujEjEul/NokDbai4V/2voafHD1S0evdWLeb8ojMNyly5fS//ffbcD0L33j4K4RX4rtMh/UUGLXmr6BWXN9MEFAhYfzmZ6hcXI+TpISRH8061Ui68gTWGUJP4aU9P8ZrB39S+Xkx1ummPSMkbebnJcxU1jm4D5eGhvB7j32HJcpUJHhxLIfxTZpxwGa8eKrHC51a9Tmp+N5P1RsQ01cJAwEflHw8/+pfYn/HgaQ+n7/a1vd6k+BUS2XvVD401TXhu488gQ0r71QUuLJsrWT8mSYtfkBMm0BAmFhNrgDX4oRqqeaJMw4c6TyIv/qPP0Xf8KUJ6sXuP1XluuEEyGsD5TXKgsqBNQvW4RtbnkDb4ttJQlGt/IQqLMJE7tWqOSBZCSrL6dFSqq3AnzhzDC/tewHt5w4nr3suvgN0+P8o3TeegFe3vYDHtj+xhLt/Q3kkeW5d693YuuHXsWHZPcixW4tCwo+trVU9QEs8G6HFqW5kdBiHTu3H64dfxpGuK8r665Tv7tz2D6e/tP23cT0E1OA5QR2iiIbs1i9u/9qTPPC12CtwlIofjZVvW/BZ3LVsC5bPW4u5DQuxaPay2NpRIuy61IkLA+dw8hdHceDUPpw49z9TXUysvWPXtl3bQ4yQtMJ1a18DAsbvRO/atvM5DXXPPbp9yzP8+GXBXTkngKYBdTWvE5RXdm87+HQEfLh2T57UIAdM95Js9+04LKSDbLzG31+Omxpx9xfxKR6AukkhMP0aKuUHsag5VEzE3fGSddsUVu6KFzIE+H/iJry0mX+bu8VfMwTMEDBDwAwBMwTMEHALv/5XgAEASpR5N6rB30UAAAAASUVORK5CYII=",this._callbackGamepadConnected=e,this.gamepadSupportAvailable?(this.gamepadEventSupported?(window.addEventListener("gamepadconnected",function(e){t._onGamepadConnected(e)},!1),window.addEventListener("gamepaddisconnected",function(e){t._onGamepadDisconnected(e)},!1)):this._startMonitoringGamepads(),this.oneGamepadConnected||this._insertGamepadDOMInstructions()):this._insertGamepadDOMNotSupported()}return e.prototype._insertGamepadDOMInstructions=function(){e.gamepadDOMInfo=document.createElement("div");var t=document.createElement("img");t.src=this.buttonADataURL;var i=document.createElement("span");i.innerHTML="<strong>to activate gamepad</strong>",e.gamepadDOMInfo.appendChild(t),e.gamepadDOMInfo.appendChild(i),e.gamepadDOMInfo.style.position="absolute",e.gamepadDOMInfo.style.width="100%",e.gamepadDOMInfo.style.height="48px",e.gamepadDOMInfo.style.bottom="0px",e.gamepadDOMInfo.style.backgroundColor="rgba(1, 1, 1, 0.15)",e.gamepadDOMInfo.style.textAlign="center",e.gamepadDOMInfo.style.zIndex="10",t.style.position="relative",t.style.bottom="8px",i.style.position="relative",i.style.fontSize="32px",i.style.bottom="32px",i.style.color="green",document.body.appendChild(e.gamepadDOMInfo)},e.prototype._insertGamepadDOMNotSupported=function(){e.gamepadDOMInfo=document.createElement("div");var t=document.createElement("span");t.innerHTML="<strong>gamepad not supported</strong>",e.gamepadDOMInfo.appendChild(t),e.gamepadDOMInfo.style.position="absolute",e.gamepadDOMInfo.style.width="100%",e.gamepadDOMInfo.style.height="40px",e.gamepadDOMInfo.style.bottom="0px",e.gamepadDOMInfo.style.backgroundColor="rgba(1, 1, 1, 0.15)",e.gamepadDOMInfo.style.textAlign="center",e.gamepadDOMInfo.style.zIndex="10",t.style.position="relative",t.style.fontSize="32px",t.style.color="red",document.body.appendChild(e.gamepadDOMInfo)},e.prototype.dispose=function(){e.gamepadDOMInfo&&document.body.removeChild(e.gamepadDOMInfo)},e.prototype._onGamepadConnected=function(e){var t=this._addNewGamepad(e.gamepad);this._callbackGamepadConnected&&this._callbackGamepadConnected(t),this._startMonitoringGamepads()},e.prototype._addNewGamepad=function(t){var i;return this.oneGamepadConnected||(this.oneGamepadConnected=!0,e.gamepadDOMInfo&&(document.body.removeChild(e.gamepadDOMInfo),e.gamepadDOMInfo=null)),i=-1!==t.id.search("Xbox 360")||-1!==t.id.search("xinput")?new a(t.id,t.index,t):new n(t.id,t.index,t),this.babylonGamepads.push(i),i},e.prototype._onGamepadDisconnected=function(e){for(var t in this.babylonGamepads)if(this.babylonGamepads[t].index==e.gamepad.index){this.babylonGamepads.splice(t,1);break}0==this.babylonGamepads.length&&this._stopMonitoringGamepads()},e.prototype._startMonitoringGamepads=function(){this.isMonitoring||(this.isMonitoring=!0,this._checkGamepadsStatus())},e.prototype._stopMonitoringGamepads=function(){this.isMonitoring=!1},e.prototype._checkGamepadsStatus=function(){var e=this;for(var t in this._updateGamepadObjects(),this.babylonGamepads)this.babylonGamepads[t].update();this.isMonitoring&&(window.requestAnimationFrame?window.requestAnimationFrame(function(){e._checkGamepadsStatus()}):window.mozRequestAnimationFrame?window.mozRequestAnimationFrame(function(){e._checkGamepadsStatus()}):window.webkitRequestAnimationFrame&&window.webkitRequestAnimationFrame(function(){e._checkGamepadsStatus()}))},e.prototype._updateGamepadObjects=function(){for(var e=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads():[],t=0;t<e.length;t++)if(e[t])if(e[t].index in this.babylonGamepads)this.babylonGamepads[t].browserGamepad=e[t];else{var i=this._addNewGamepad(e[t]);this._callbackGamepadConnected&&this._callbackGamepadConnected(i)}},e}();e.Gamepads=t;var i=function(){return function(e,t){this.x=e,this.y=t}}();e.StickValues=i;var r=function(){function e(e,t,i){this.id=e,this.index=t,this.browserGamepad=i,this.browserGamepad.axes.length>=2&&(this._leftStick={x:this.browserGamepad.axes[0],y:this.browserGamepad.axes[1]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[2],y:this.browserGamepad.axes[3]})}return e.prototype.onleftstickchanged=function(e){this._onleftstickchanged=e},e.prototype.onrightstickchanged=function(e){this._onrightstickchanged=e},Object.defineProperty(e.prototype,"leftStick",{get:function(){return this._leftStick},set:function(e){!this._onleftstickchanged||this._leftStick.x===e.x&&this._leftStick.y===e.y||this._onleftstickchanged(e),this._leftStick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightStick",{get:function(){return this._rightStick},set:function(e){!this._onrightstickchanged||this._rightStick.x===e.x&&this._rightStick.y===e.y||this._onrightstickchanged(e),this._rightStick=e},enumerable:!0,configurable:!0}),e.prototype.update=function(){this._leftStick&&(this.leftStick={x:this.browserGamepad.axes[0],y:this.browserGamepad.axes[1]}),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[2],y:this.browserGamepad.axes[3]})},e}();e.Gamepad=r;var n=function(e){function t(t,i,r){e.call(this,t,i,r),this.id=t,this.index=i,this.gamepad=r,this._buttons=new Array(r.buttons.length)}return __extends(t,e),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype._setButtonValue=function(e,t,i){return e!==t&&(this._onbuttondown&&1===e&&this._onbuttondown(i),this._onbuttonup&&0===e&&this._onbuttonup(i)),e},t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;t<this._buttons.length;t++)this._buttons[t]=this._setButtonValue(this.gamepad.buttons[t].value,this._buttons[t],t)},t}(r);e.GenericPad=n,function(e){e[e.A=0]="A",e[e.B=1]="B",e[e.X=2]="X",e[e.Y=3]="Y",e[e.Start=4]="Start",e[e.Back=5]="Back",e[e.LB=6]="LB",e[e.RB=7]="RB",e[e.LeftStick=8]="LeftStick",e[e.RightStick=9]="RightStick"}(e.Xbox360Button||(e.Xbox360Button={}));var o=e.Xbox360Button;!function(e){e[e.Up=0]="Up",e[e.Down=1]="Down",e[e.Left=2]="Left",e[e.Right=3]="Right"}(e.Xbox360Dpad||(e.Xbox360Dpad={}));var s=e.Xbox360Dpad,a=function(e){function t(){e.apply(this,arguments),this._leftTrigger=0,this._rightTrigger=0,this._buttonA=0,this._buttonB=0,this._buttonX=0,this._buttonY=0,this._buttonBack=0,this._buttonStart=0,this._buttonLB=0,this._buttonRB=0,this._buttonLeftStick=0,this._buttonRightStick=0,this._dPadUp=0,this._dPadDown=0,this._dPadLeft=0,this._dPadRight=0}return __extends(t,e),t.prototype.onlefttriggerchanged=function(e){this._onlefttriggerchanged=e},t.prototype.onrighttriggerchanged=function(e){this._onrighttriggerchanged=e},Object.defineProperty(t.prototype,"leftTrigger",{get:function(){return this._leftTrigger},set:function(e){this._onlefttriggerchanged&&this._leftTrigger!==e&&this._onlefttriggerchanged(e),this._leftTrigger=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightTrigger",{get:function(){return this._rightTrigger},set:function(e){this._onrighttriggerchanged&&this._rightTrigger!==e&&this._onrighttriggerchanged(e),this._rightTrigger=e},enumerable:!0,configurable:!0}),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype.ondpaddown=function(e){this._ondpaddown=e},t.prototype.ondpadup=function(e){this._ondpadup=e},t.prototype._setButtonValue=function(e,t,i){return e!==t&&(this._onbuttondown&&1===e&&this._onbuttondown(i),this._onbuttonup&&0===e&&this._onbuttonup(i)),e},t.prototype._setDPadValue=function(e,t,i){return e!==t&&(this._ondpaddown&&1===e&&this._ondpaddown(i),this._ondpadup&&0===e&&this._ondpadup(i)),e},Object.defineProperty(t.prototype,"buttonA",{get:function(){return this._buttonA},set:function(e){this._buttonA=this._setButtonValue(e,this._buttonA,o.A)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonB",{get:function(){return this._buttonB},set:function(e){this._buttonB=this._setButtonValue(e,this._buttonB,o.B)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonX",{get:function(){return this._buttonX},set:function(e){this._buttonX=this._setButtonValue(e,this._buttonX,o.X)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonY",{get:function(){return this._buttonY},set:function(e){this._buttonY=this._setButtonValue(e,this._buttonY,o.Y)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonStart",{get:function(){return this._buttonStart},set:function(e){this._buttonStart=this._setButtonValue(e,this._buttonStart,o.Start)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonBack",{get:function(){return this._buttonBack},set:function(e){this._buttonBack=this._setButtonValue(e,this._buttonBack,o.Back)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonLB",{get:function(){return this._buttonLB},set:function(e){this._buttonLB=this._setButtonValue(e,this._buttonLB,o.LB)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonRB",{get:function(){return this._buttonRB},set:function(e){this._buttonRB=this._setButtonValue(e,this._buttonRB,o.RB)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,o.LeftStick)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,o.RightStick)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,s.Up)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,s.Down)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,s.Left)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,s.Right)},enumerable:!0,configurable:!0}),t.prototype.update=function(){e.prototype.update.call(this),this.buttonA=this.browserGamepad.buttons[0].value,this.buttonB=this.browserGamepad.buttons[1].value,this.buttonX=this.browserGamepad.buttons[2].value,this.buttonY=this.browserGamepad.buttons[3].value,this.buttonLB=this.browserGamepad.buttons[4].value,this.buttonRB=this.browserGamepad.buttons[5].value,this.leftTrigger=this.browserGamepad.buttons[6].value,this.rightTrigger=this.browserGamepad.buttons[7].value,this.buttonBack=this.browserGamepad.buttons[8].value,this.buttonStart=this.browserGamepad.buttons[9].value,this.buttonLeftStick=this.browserGamepad.buttons[10].value,this.buttonRightStick=this.browserGamepad.buttons[11].value,this.dPadUp=this.browserGamepad.buttons[12].value,this.dPadDown=this.browserGamepad.buttons[13].value,this.dPadLeft=this.browserGamepad.buttons[14].value,this.dPadRight=this.browserGamepad.buttons[15].value},t}(r);e.Xbox360Pad=a}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n){var o=this;t.call(this,i,r,n),this.angularSensibility=200,this.moveSensibility=75,this._gamepads=new e.Gamepads(function(e){o._onNewGameConnected(e)})}return __extends(i,t),i.prototype._onNewGameConnected=function(e){0===e.index&&(this._gamepad=e)},i.prototype._checkInputs=function(){if(this._gamepad){var i=this._gamepad.leftStick,r=i.x/this.moveSensibility,n=i.y/this.moveSensibility;i.x=Math.abs(r)>.005?0+r:0,i.y=Math.abs(n)>.005?0+n:0;var o=this._gamepad.rightStick,s=o.x/this.angularSensibility,a=o.y/this.angularSensibility;o.x=Math.abs(s)>.001?0+s:0,o.y=Math.abs(a)>.001?0+a:0;var h=e.Matrix.RotationYawPitchRoll(this.rotation.y,this.rotation.x,0),c=50*this._computeLocalCameraSpeed(),l=e.Vector3.TransformCoordinates(new e.Vector3(i.x*c,0,-i.y*c),h);this.cameraDirection=this.cameraDirection.add(l),this.cameraRotation=this.cameraRotation.add(new e.Vector2(o.y,o.x))}t.prototype._checkInputs.call(this)},i.prototype.dispose=function(){this._gamepads.dispose(),t.prototype.dispose.call(this)},i}(e.FreeCamera);e.GamepadCamera=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(e){this._renderingGroups=new Array,this._scene=e}return t.prototype._renderParticles=function(t,i){if(0!==this._scene._activeParticleSystems.length){for(var r=this._scene.activeCamera,n=e.Tools.Now,o=0;o<this._scene._activeParticleSystems.length;o++){var s=this._scene._activeParticleSystems.data[o];s.renderingGroupId===t&&0!=(r.layerMask&s.layerMask)&&(this._clearDepthBuffer(),s.emitter.position&&i&&-1===i.indexOf(s.emitter)||(this._scene._activeParticles+=s.render()))}this._scene._particlesDuration+=e.Tools.Now-n}},t.prototype._renderSprites=function(t){if(this._scene.spritesEnabled&&0!==this._scene.spriteManagers.length){for(var i=this._scene.activeCamera,r=e.Tools.Now,n=0;n<this._scene.spriteManagers.length;n++){var o=this._scene.spriteManagers[n];o.renderingGroupId===t&&0!=(i.layerMask&o.layerMask)&&(this._clearDepthBuffer(),o.render())}this._scene._spritesDuration+=e.Tools.Now-r}},t.prototype._clearDepthBuffer=function(){this._depthBufferAlreadyCleaned||(this._scene.getEngine().clear(0,!1,!0),this._depthBufferAlreadyCleaned=!0)},t.prototype.render=function(e,i,r,n){for(var o=0;o<t.MAX_RENDERINGGROUPS;o++){this._depthBufferAlreadyCleaned=!1;var s=this._renderingGroups[o],a=!1;s&&(this._clearDepthBuffer(),s.render(e)||(this._renderingGroups.splice(o,1),a=!0)),n&&this._renderSprites(o),r&&this._renderParticles(o,i),a&&o--}},t.prototype.reset=function(){this._renderingGroups.forEach(function(e,t,i){e&&e.prepare()})},t.prototype.dispatch=function(t){var i=t.getMesh().renderingGroupId||0;this._renderingGroups[i]||(this._renderingGroups[i]=new e.RenderingGroup(i,this._scene)),this._renderingGroups[i].dispatch(t)},t.MAX_RENDERINGGROUPS=4,t}();e.RenderingManager=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t,i){this.index=t,this._opaqueSubMeshes=new e.SmartArray(256),this._transparentSubMeshes=new e.SmartArray(256),this._alphaTestSubMeshes=new e.SmartArray(256),this._scene=i}return t.prototype.render=function(t){if(t)return t(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes),!0;if(0===this._opaqueSubMeshes.length&&0===this._alphaTestSubMeshes.length&&0===this._transparentSubMeshes.length)return!1;var i,r,n=this._scene.getEngine();for(i=0;i<this._opaqueSubMeshes.length;i++)(r=this._opaqueSubMeshes.data[i]).render(!1);for(n.setAlphaTesting(!0),i=0;i<this._alphaTestSubMeshes.length;i++)(r=this._alphaTestSubMeshes.data[i]).render(!1);if(n.setAlphaTesting(!1),this._transparentSubMeshes.length){for(i=0;i<this._transparentSubMeshes.length;i++)(r=this._transparentSubMeshes.data[i])._alphaIndex=r.getMesh().alphaIndex,r._distanceToCamera=r.getBoundingInfo().boundingSphere.centerWorld.subtract(this._scene.activeCamera.globalPosition).length();var o=this._transparentSubMeshes.data.slice(0,this._transparentSubMeshes.length);for(o.sort(function(e,t){return e._alphaIndex>t._alphaIndex?1:e._alphaIndex<t._alphaIndex?-1:e._distanceToCamera<t._distanceToCamera?1:e._distanceToCamera>t._distanceToCamera?-1:0}),i=0;i<o.length;i++)(r=o[i]).render(!0);n.setAlphaMode(e.Engine.ALPHA_DISABLE)}return!0},t.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset()},t.prototype.dispatch=function(e){var t=e.getMaterial(),i=e.getMesh();t.needAlphaBlending()||i.visibility<1||i.hasVertexAlpha?this._transparentSubMeshes.push(e):t.needAlphaTesting()?this._alphaTestSubMeshes.push(e):this._opaqueSubMeshes.push(e)},t}();e.RenderingGroup=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(i){this.autoClear=!0,this.clearColor=new e.Color3(.2,.2,.3),this.ambientColor=new e.Color3(0,0,0),this.forceWireframe=!1,this.forcePointsCloud=!1,this.forceShowBoundingBoxes=!1,this.animationsEnabled=!0,this.constantlyUpdateMeshUnderPointer=!1,this.cameraToUseForPointers=null,this.fogEnabled=!0,this.fogMode=t.FOGMODE_NONE,this.fogColor=new e.Color3(.2,.2,.3),this.fogDensity=.1,this.fogStart=0,this.fogEnd=1e3,this.shadowsEnabled=!0,this.lightsEnabled=!0,this.lights=new Array,this.cameras=new Array,this.activeCameras=new Array,this.meshes=new Array,this._geometries=new Array,this.materials=new Array,this.multiMaterials=new Array,this.defaultMaterial=new e.StandardMaterial("default material",this),this.texturesEnabled=!0,this.textures=new Array,this.particlesEnabled=!0,this.particleSystems=new Array,this.spritesEnabled=!0,this.spriteManagers=new Array,this.layers=new Array,this.skeletonsEnabled=!0,this.skeletons=new Array,this.lensFlaresEnabled=!0,this.lensFlareSystems=new Array,this.collisionsEnabled=!0,this.gravity=new e.Vector3(0,-9.807,0),this.postProcessesEnabled=!0,this.renderTargetsEnabled=!0,this.dumpNextRenderTargets=!1,this.customRenderTargets=new Array,this.importedMeshesFiles=new Array,this.probesEnabled=!0,this.reflectionProbes=new Array,this._actionManagers=new Array,this._meshesForIntersections=new e.SmartArray(256),this.proceduralTexturesEnabled=!0,this._proceduralTextures=new Array,this.soundTracks=new Array,this._audioEnabled=!0,this._headphone=!1,this._totalVertices=0,this._activeIndices=0,this._activeParticles=0,this._lastFrameDuration=0,this._evaluateActiveMeshesDuration=0,this._renderTargetsDuration=0,this._particlesDuration=0,this._renderDuration=0,this._spritesDuration=0,this._animationRatio=0,this._renderId=0,this._executeWhenReadyTimeoutId=-1,this._toBeDisposed=new e.SmartArray(256),this._onReadyCallbacks=new Array,this._pendingData=[],this._onBeforeRenderCallbacks=new Array,this._onAfterRenderCallbacks=new Array,this._activeMeshes=new e.SmartArray(256),this._processedMaterials=new e.SmartArray(256),this._renderTargets=new e.SmartArray(256),this._activeParticleSystems=new e.SmartArray(256),this._activeSkeletons=new e.SmartArray(32),this._softwareSkinnedMeshes=new e.SmartArray(32),this._activeBones=0,this._activeAnimatables=new Array,this._transformMatrix=e.Matrix.Zero(),this._edgesRenderers=new e.SmartArray(16),this._uniqueIdCounter=0,this._engine=i,i.scenes.push(this),this._renderingManager=new e.RenderingManager(this),this.postProcessManager=new e.PostProcessManager(this),this.postProcessRenderPipelineManager=new e.PostProcessRenderPipelineManager,this._boundingBoxRenderer=new e.BoundingBoxRenderer(this),this._outlineRenderer=new e.OutlineRenderer(this),this.attachControl(),this._debugLayer=new e.DebugLayer(this),this.mainSoundTrack=new e.SoundTrack(this,{mainTrack:!0}),this.simplificationQueue=new e.SimplificationQueue,this.workerCollisions=!1}return Object.defineProperty(t,"FOGMODE_NONE",{get:function(){return t._FOGMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FOGMODE_EXP",{get:function(){return t._FOGMODE_EXP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FOGMODE_EXP2",{get:function(){return t._FOGMODE_EXP2},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FOGMODE_LINEAR",{get:function(){return t._FOGMODE_LINEAR},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"debugLayer",{get:function(){return this._debugLayer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"workerCollisions",{get:function(){return this._workerCollisions},set:function(t){t=t&&!!Worker,this._workerCollisions=t,this.collisionCoordinator&&this.collisionCoordinator.destroy(),this.collisionCoordinator=t?new e.CollisionCoordinatorWorker:new e.CollisionCoordinatorLegacy,this.collisionCoordinator.init(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"SelectionOctree",{get:function(){return this._selectionOctree},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"meshUnderPointer",{get:function(){return this._meshUnderPointer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pointerX",{get:function(){return this._pointerX},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pointerY",{get:function(){return this._pointerY},enumerable:!0,configurable:!0}),t.prototype.getCachedMaterial=function(){return this._cachedMaterial},t.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer},t.prototype.getOutlineRenderer=function(){return this._outlineRenderer},t.prototype.getEngine=function(){return this._engine},t.prototype.getTotalVertices=function(){return this._totalVertices},t.prototype.getActiveIndices=function(){return this._activeIndices},t.prototype.getActiveParticles=function(){return this._activeParticles},t.prototype.getActiveBones=function(){return this._activeBones},t.prototype.getLastFrameDuration=function(){return this._lastFrameDuration},t.prototype.getEvaluateActiveMeshesDuration=function(){return this._evaluateActiveMeshesDuration},t.prototype.getActiveMeshes=function(){return this._activeMeshes},t.prototype.getRenderTargetsDuration=function(){return this._renderTargetsDuration},t.prototype.getRenderDuration=function(){return this._renderDuration},t.prototype.getParticlesDuration=function(){return this._particlesDuration},t.prototype.getSpritesDuration=function(){return this._spritesDuration},t.prototype.getAnimationRatio=function(){return this._animationRatio},t.prototype.getRenderId=function(){return this._renderId},t.prototype.incrementRenderId=function(){this._renderId++},t.prototype._updatePointerPosition=function(e){var t=this._engine.getRenderingCanvasClientRect();this._pointerX=e.clientX-t.left,this._pointerY=e.clientY-t.top,this.cameraToUseForPointers&&(this._pointerX=this._pointerX-this.cameraToUseForPointers.viewport.x*this._engine.getRenderWidth(),this._pointerY=this._pointerY-this.cameraToUseForPointers.viewport.y*this._engine.getRenderHeight())},t.prototype.attachControl=function(){var t=this,i=function(e){return e.isPickable&&e.actionManager&&e.actionManager.hasPickTriggers};this._onPointerMove=function(e){var r=t._engine.getRenderingCanvas();t._updatePointerPosition(e);var n=t.pick(t._pointerX,t._pointerY,function(e){return e.isPickable&&e.isVisible&&e.isReady()&&(t.constantlyUpdateMeshUnderPointer||null!==e.actionManager&&void 0!==e.actionManager)},!1,t.cameraToUseForPointers);if(n.hit&&n.pickedMesh)t._meshUnderPointer=n.pickedMesh,t.setPointerOverMesh(n.pickedMesh),r.style.cursor=t._meshUnderPointer.actionManager&&t._meshUnderPointer.actionManager.hasPointerTriggers?"pointer":"";else{if((n=t.pickSprite(t._pointerX,t._pointerY,i,!1,t.cameraToUseForPointers)).hit&&n.pickedSprite)return void(r.style.cursor="pointer");t.setPointerOverMesh(null),r.style.cursor="",t._meshUnderPointer=null}},this._onPointerDown=function(r){t._updatePointerPosition(r);var n=null;t.onPointerDown||(n=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.actionManager&&e.actionManager.hasPickTriggers});var o=t.pick(t._pointerX,t._pointerY,n,!1,t.cameraToUseForPointers);if(o.hit&&o.pickedMesh&&o.pickedMesh.actionManager){switch(r.button){case 0:o.pickedMesh.actionManager.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNew(o.pickedMesh,r));break;case 1:o.pickedMesh.actionManager.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNew(o.pickedMesh,r));break;case 2:o.pickedMesh.actionManager.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNew(o.pickedMesh,r))}o.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickTrigger,e.ActionEvent.CreateNew(o.pickedMesh,r))}if(t.onPointerDown&&t.onPointerDown(r,o),t.spriteManagers.length>0&&((o=t.pickSprite(t._pointerX,t._pointerY,i,!1,t.cameraToUseForPointers)).hit&&o.pickedSprite&&o.pickedSprite.actionManager)){switch(r.button){case 0:o.pickedSprite.actionManager.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNewFromSprite(o.pickedSprite,t,r));break;case 1:o.pickedSprite.actionManager.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNewFromSprite(o.pickedSprite,t,r));break;case 2:o.pickedSprite.actionManager.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNewFromSprite(o.pickedSprite,t,r))}o.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickTrigger,e.ActionEvent.CreateNewFromSprite(o.pickedSprite,t,r))}},this._onPointerUp=function(r){var n=null;t._updatePointerPosition(r),t.onPointerUp||(n=function(t){return t.isPickable&&t.isVisible&&t.isReady()&&t.actionManager&&t.actionManager.hasSpecificTrigger(e.ActionManager.OnPickUpTrigger)});var o=t.pick(t._pointerX,t._pointerY,n,!1,t.cameraToUseForPointers);o.hit&&o.pickedMesh&&o.pickedMesh.actionManager&&o.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNew(o.pickedMesh,r)),t.onPointerUp&&t.onPointerUp(r,o),t.spriteManagers.length>0&&((o=t.pickSprite(t._pointerX,t._pointerY,i,!1,t.cameraToUseForPointers)).hit&&o.pickedSprite&&o.pickedSprite.actionManager&&o.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNewFromSprite(o.pickedSprite,t,r)))},this._onKeyDown=function(i){t.actionManager&&t.actionManager.processTrigger(e.ActionManager.OnKeyDownTrigger,e.ActionEvent.CreateNewFromScene(t,i))},this._onKeyUp=function(i){t.actionManager&&t.actionManager.processTrigger(e.ActionManager.OnKeyUpTrigger,e.ActionEvent.CreateNewFromScene(t,i))};var r=e.Tools.GetPointerPrefix();this._engine.getRenderingCanvas().addEventListener(r+"move",this._onPointerMove,!1),this._engine.getRenderingCanvas().addEventListener(r+"down",this._onPointerDown,!1),this._engine.getRenderingCanvas().addEventListener(r+"up",this._onPointerUp,!1),this._engine.getRenderingCanvas().addEventListener("mousewheel",this._onPointerMove,!1),this._engine.getRenderingCanvas().addEventListener("DOMMouseScroll",this._onPointerMove,!1),e.Tools.RegisterTopRootEvents([{name:"keydown",handler:this._onKeyDown},{name:"keyup",handler:this._onKeyUp}])},t.prototype.detachControl=function(){var t=e.Tools.GetPointerPrefix();this._engine.getRenderingCanvas().removeEventListener(t+"move",this._onPointerMove),this._engine.getRenderingCanvas().removeEventListener(t+"down",this._onPointerDown),this._engine.getRenderingCanvas().removeEventListener(t+"up",this._onPointerUp),this._engine.getRenderingCanvas().removeEventListener("mousewheel",this._onPointerMove),this._engine.getRenderingCanvas().removeEventListener("DOMMouseScroll",this._onPointerMove),e.Tools.UnregisterTopRootEvents([{name:"keydown",handler:this._onKeyDown},{name:"keyup",handler:this._onKeyUp}])},t.prototype.isReady=function(){if(this._pendingData.length>0)return!1;var t;for(t=0;t<this._geometries.length;t++){if(this._geometries[t].delayLoadState===e.Engine.DELAYLOADSTATE_LOADING)return!1}for(t=0;t<this.meshes.length;t++){var i=this.meshes[t];if(!i.isReady())return!1;var r=i.material;if(r&&!r.isReady(i))return!1}return!0},t.prototype.resetCachedMaterial=function(){this._cachedMaterial=null},t.prototype.registerBeforeRender=function(e){this._onBeforeRenderCallbacks.push(e)},t.prototype.unregisterBeforeRender=function(e){var t=this._onBeforeRenderCallbacks.indexOf(e);t>-1&&this._onBeforeRenderCallbacks.splice(t,1)},t.prototype.registerAfterRender=function(e){this._onAfterRenderCallbacks.push(e)},t.prototype.unregisterAfterRender=function(e){var t=this._onAfterRenderCallbacks.indexOf(e);t>-1&&this._onAfterRenderCallbacks.splice(t,1)},t.prototype._addPendingData=function(e){this._pendingData.push(e)},t.prototype._removePendingData=function(e){var t=this._pendingData.indexOf(e);-1!==t&&this._pendingData.splice(t,1)},t.prototype.getWaitingItemsCount=function(){return this._pendingData.length},t.prototype.executeWhenReady=function(e){var t=this;this._onReadyCallbacks.push(e),-1===this._executeWhenReadyTimeoutId&&(this._executeWhenReadyTimeoutId=setTimeout(function(){t._checkIsReady()},150))},t.prototype._checkIsReady=function(){var e=this;return this.isReady()?(this._onReadyCallbacks.forEach(function(e){e()}),this._onReadyCallbacks=[],void(this._executeWhenReadyTimeoutId=-1)):void(this._executeWhenReadyTimeoutId=setTimeout(function(){e._checkIsReady()},150))},t.prototype.beginAnimation=function(t,i,r,n,o,s,a){if(void 0===o&&(o=1),this.stopAnimation(t),a||(a=new e.Animatable(this,t,i,r,n,o,s)),t.animations&&a.appendAnimations(t,t.animations),t.getAnimatables)for(var h=t.getAnimatables(),c=0;c<h.length;c++)this.beginAnimation(h[c],i,r,n,o,s,a);return a},t.prototype.beginDirectAnimation=function(t,i,r,n,o,s,a){return void 0===s&&(s=1),new e.Animatable(this,t,r,n,o,s,a,i)},t.prototype.getAnimatableByTarget=function(e){for(var t=0;t<this._activeAnimatables.length;t++)if(this._activeAnimatables[t].target===e)return this._activeAnimatables[t];return null},t.prototype.stopAnimation=function(e){var t=this.getAnimatableByTarget(e);t&&t.stop()},t.prototype._animate=function(){if(this.animationsEnabled){this._animationStartDate||(this._animationStartDate=e.Tools.Now);for(var t=e.Tools.Now-this._animationStartDate,i=0;i<this._activeAnimatables.length;i++)this._activeAnimatables[i]._animate(t)}},t.prototype.getViewMatrix=function(){return this._viewMatrix},t.prototype.getProjectionMatrix=function(){return this._projectionMatrix},t.prototype.getTransformMatrix=function(){return this._transformMatrix},t.prototype.setTransformMatrix=function(e,t){this._viewMatrix=e,this._projectionMatrix=t,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)},t.prototype.addMesh=function(e){e.uniqueId=this._uniqueIdCounter++;var t=this.meshes.push(e);this.collisionCoordinator.onMeshAdded(e),this.onNewMeshAdded&&this.onNewMeshAdded(e,t,this)},t.prototype.removeMesh=function(e){var t=this.meshes.indexOf(e);return-1!==t&&this.meshes.splice(t,1),this.collisionCoordinator.onMeshRemoved(e),this.onMeshRemoved&&this.onMeshRemoved(e),t},t.prototype.removeLight=function(e){var t=this.lights.indexOf(e);return-1!==t&&this.lights.splice(t,1),this.onLightRemoved&&this.onLightRemoved(e),t},t.prototype.removeCamera=function(e){var t=this.cameras.indexOf(e);-1!==t&&this.cameras.splice(t,1);var i=this.activeCameras.indexOf(e);return-1!==i&&this.activeCameras.splice(i,1),this.activeCamera===e&&(this.activeCamera=this.cameras.length>0?this.cameras[0]:null),this.onCameraRemoved&&this.onCameraRemoved(e),t},t.prototype.addLight=function(e){e.uniqueId=this._uniqueIdCounter++;var t=this.lights.push(e);this.onNewLightAdded&&this.onNewLightAdded(e,t,this)},t.prototype.addCamera=function(e){e.uniqueId=this._uniqueIdCounter++;var t=this.cameras.push(e);this.onNewCameraAdded&&this.onNewCameraAdded(e,t,this)},t.prototype.setActiveCameraByID=function(e){var t=this.getCameraByID(e);return t?(this.activeCamera=t,t):null},t.prototype.setActiveCameraByName=function(e){var t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null},t.prototype.getMaterialByID=function(e){for(var t=0;t<this.materials.length;t++)if(this.materials[t].id===e)return this.materials[t];return null},t.prototype.getMaterialByName=function(e){for(var t=0;t<this.materials.length;t++)if(this.materials[t].name===e)return this.materials[t];return null},t.prototype.getLensFlareSystemByName=function(e){for(var t=0;t<this.lensFlareSystems.length;t++)if(this.lensFlareSystems[t].name===e)return this.lensFlareSystems[t];return null},t.prototype.getCameraByID=function(e){for(var t=0;t<this.cameras.length;t++)if(this.cameras[t].id===e)return this.cameras[t];return null},t.prototype.getCameraByUniqueID=function(e){for(var t=0;t<this.cameras.length;t++)if(this.cameras[t].uniqueId===e)return this.cameras[t];return null},t.prototype.getCameraByName=function(e){for(var t=0;t<this.cameras.length;t++)if(this.cameras[t].name===e)return this.cameras[t];return null},t.prototype.getLightByName=function(e){for(var t=0;t<this.lights.length;t++)if(this.lights[t].name===e)return this.lights[t];return null},t.prototype.getLightByID=function(e){for(var t=0;t<this.lights.length;t++)if(this.lights[t].id===e)return this.lights[t];return null},t.prototype.getLightByUniqueID=function(e){for(var t=0;t<this.lights.length;t++)if(this.lights[t].uniqueId===e)return this.lights[t];return null},t.prototype.getGeometryByID=function(e){for(var t=0;t<this._geometries.length;t++)if(this._geometries[t].id===e)return this._geometries[t];return null},t.prototype.pushGeometry=function(e,t){return!(!t&&this.getGeometryByID(e.id))&&(this._geometries.push(e),this.collisionCoordinator.onGeometryAdded(e),this.onGeometryAdded&&this.onGeometryAdded(e),!0)},t.prototype.removeGeometry=function(e){var t=this._geometries.indexOf(e);return t>-1&&(this._geometries.splice(t,1),this.collisionCoordinator.onGeometryDeleted(e),this.onGeometryRemoved&&this.onGeometryRemoved(e),!0)},t.prototype.getGeometries=function(){return this._geometries},t.prototype.getMeshByID=function(e){for(var t=0;t<this.meshes.length;t++)if(this.meshes[t].id===e)return this.meshes[t];return null},t.prototype.getMeshByUniqueID=function(e){for(var t=0;t<this.meshes.length;t++)if(this.meshes[t].uniqueId===e)return this.meshes[t];return null},t.prototype.getLastMeshByID=function(e){for(var t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null},t.prototype.getLastEntryByID=function(e){var t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null},t.prototype.getNodeByID=function(e){var t=this.getMeshByID(e);if(t)return t;var i=this.getLightByID(e);return i||this.getCameraByID(e)},t.prototype.getNodeByName=function(e){var t=this.getMeshByName(e);if(t)return t;var i=this.getLightByName(e);return i||this.getCameraByName(e)},t.prototype.getMeshByName=function(e){for(var t=0;t<this.meshes.length;t++)if(this.meshes[t].name===e)return this.meshes[t];return null},t.prototype.getSoundByName=function(e){var t;for(t=0;t<this.mainSoundTrack.soundCollection.length;t++)if(this.mainSoundTrack.soundCollection[t].name===e)return this.mainSoundTrack.soundCollection[t];for(var i=0;i<this.soundTracks.length;i++)for(t=0;t<this.soundTracks[i].soundCollection.length;t++)if(this.soundTracks[i].soundCollection[t].name===e)return this.soundTracks[i].soundCollection[t];return null},t.prototype.getLastSkeletonByID=function(e){for(var t=this.skeletons.length-1;t>=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},t.prototype.getSkeletonById=function(e){for(var t=0;t<this.skeletons.length;t++)if(this.skeletons[t].id===e)return this.skeletons[t];return null},t.prototype.getSkeletonByName=function(e){for(var t=0;t<this.skeletons.length;t++)if(this.skeletons[t].name===e)return this.skeletons[t];return null},t.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},t.prototype._evaluateSubMesh=function(e,t){if(t.alwaysSelectAsActiveMesh||1===t.subMeshes.length||e.isInFrustum(this._frustumPlanes)){var i=e.getMaterial();t.showSubMeshesBoundingBox&&this._boundingBoxRenderer.renderList.push(e.getBoundingInfo().boundingBox),i&&(i.getRenderTargetTextures&&-1===this._processedMaterials.indexOf(i)&&(this._processedMaterials.push(i),this._renderTargets.concat(i.getRenderTargetTextures())),this._activeIndices+=e.indexCount,this._renderingManager.dispatch(e))}},t.prototype._evaluateActiveMeshes=function(){var t,i;if(this.activeCamera._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset(),this._boundingBoxRenderer.reset(),this._edgesRenderers.reset(),this._frustumPlanes?e.Frustum.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=e.Frustum.GetPlanes(this._transformMatrix),this._selectionOctree){var r=this._selectionOctree.select(this._frustumPlanes);t=r.data,i=r.length}else i=this.meshes.length,t=this.meshes;for(var n=0;i>n;n++){var o=t[n];if(!o.isBlocked&&(this._totalVertices+=o.getTotalVertices(),o.isReady()&&o.isEnabled())){o.computeWorldMatrix(),o.actionManager&&o.actionManager.hasSpecificTriggers([e.ActionManager.OnIntersectionEnterTrigger,e.ActionManager.OnIntersectionExitTrigger])&&this._meshesForIntersections.pushNoDuplicate(o);var s=o.getLOD(this.activeCamera);s&&(o._preActivate(),(o.alwaysSelectAsActiveMesh||o.isVisible&&o.visibility>0&&0!=(o.layerMask&this.activeCamera.layerMask)&&o.isInFrustum(this._frustumPlanes))&&(this._activeMeshes.push(o),this.activeCamera._activeMeshes.push(o),o._activate(this._renderId),this._activeMesh(s)))}}var a=e.Tools.Now;if(this.particlesEnabled){e.Tools.StartPerformanceCounter("Particles",this.particleSystems.length>0);for(var h=0;h<this.particleSystems.length;h++){var c=this.particleSystems[h];c.isStarted()&&(!c.emitter.position||c.emitter&&c.emitter.isEnabled())&&(this._activeParticleSystems.push(c),c.animate())}e.Tools.EndPerformanceCounter("Particles",this.particleSystems.length>0)}this._particlesDuration+=e.Tools.Now-a},t.prototype._activeMesh=function(e){if(e.skeleton&&this.skeletonsEnabled&&(this._activeSkeletons.pushNoDuplicate(e.skeleton),e.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(e)),(e.showBoundingBox||this.forceShowBoundingBoxes)&&this._boundingBoxRenderer.renderList.push(e.getBoundingInfo().boundingBox),e._edgesRenderer&&this._edgesRenderers.push(e._edgesRenderer),e&&e.subMeshes){var t,i;if(e._submeshesOctree&&e.useOctreeForRenderingSelection){var r=e._submeshesOctree.select(this._frustumPlanes);t=r.length,i=r.data}else t=(i=e.subMeshes).length;for(var n=0;t>n;n++){var o=i[n];this._evaluateSubMesh(o,e)}}},t.prototype.updateTransformMatrix=function(e){this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(e))},t.prototype._renderForCamera=function(t){var i=this._engine;if(this.activeCamera=t,!this.activeCamera)throw new Error("Active camera not set");e.Tools.StartPerformanceCounter("Rendering camera "+this.activeCamera.name),i.setViewport(this.activeCamera.viewport),this.resetCachedMaterial(),this._renderId++,this.updateTransformMatrix(),this.beforeCameraRender&&this.beforeCameraRender(this.activeCamera);var r=e.Tools.Now;e.Tools.StartPerformanceCounter("Active meshes evaluation"),this._evaluateActiveMeshes(),this._evaluateActiveMeshesDuration+=e.Tools.Now-r,e.Tools.EndPerformanceCounter("Active meshes evaluation");for(var n=0;n<this._activeSkeletons.length;n++){this._activeSkeletons.data[n].prepare()}for(var o=0;o<this._softwareSkinnedMeshes.length;o++){var s=this._softwareSkinnedMeshes.data[o];s.applySkeleton(s.skeleton)}var a=e.Tools.Now;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var h=0;h<this._renderTargets.length;h++){var c=this._renderTargets.data[h];if(c._shouldRender()){this._renderId++;var l=c.activeCamera&&c.activeCamera!==this.activeCamera;c.render(l,this.dumpNextRenderTargets)}}e.Tools.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._renderId++}this._renderTargets.length>0&&i.restoreDefaultFramebuffer(),this._renderTargetsDuration+=e.Tools.Now-a,this.postProcessManager._prepareFrame();var u,d,f=e.Tools.Now;if(this.layers.length){for(i.setDepthBuffer(!1),u=0;u<this.layers.length;u++)(d=this.layers[u]).isBackground&&d.render();i.setDepthBuffer(!0)}e.Tools.StartPerformanceCounter("Main render"),this._renderingManager.render(null,null,!0,!0),e.Tools.EndPerformanceCounter("Main render"),this._boundingBoxRenderer.render();for(var p=0;p<this._edgesRenderers.length;p++)this._edgesRenderers.data[p].render();if(this.lensFlaresEnabled){e.Tools.StartPerformanceCounter("Lens flares",this.lensFlareSystems.length>0);for(var m=0;m<this.lensFlareSystems.length;m++){var g=this.lensFlareSystems[m];0!=(t.layerMask&g.layerMask)&&g.render()}e.Tools.EndPerformanceCounter("Lens flares",this.lensFlareSystems.length>0)}if(this.layers.length){for(i.setDepthBuffer(!1),u=0;u<this.layers.length;u++)(d=this.layers[u]).isBackground||d.render();i.setDepthBuffer(!0)}this._renderDuration+=e.Tools.Now-f,this.postProcessManager._finalizeFrame(t.isIntermediate),this.activeCamera._updateFromScene(),this._renderTargets.reset(),this.afterCameraRender&&this.afterCameraRender(this.activeCamera),e.Tools.EndPerformanceCounter("Rendering camera "+this.activeCamera.name)},t.prototype._processSubCameras=function(t){if(t.cameraRigMode!==e.Camera.RIG_MODE_NONE){for(var i=0;i<t._rigCameras.length;i++)this._renderForCamera(t._rigCameras[i]);this.activeCamera=t,this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix()),this.activeCamera._updateFromScene()}else this._renderForCamera(t)},t.prototype._checkIntersections=function(){for(var t=0;t<this._meshesForIntersections.length;t++)for(var i=this._meshesForIntersections.data[t],r=0;r<i.actionManager.actions.length;r++){var n=i.actionManager.actions[r];if(n.trigger===e.ActionManager.OnIntersectionEnterTrigger||n.trigger===e.ActionManager.OnIntersectionExitTrigger){var o=n.getTriggerParameter(),s=o instanceof e.AbstractMesh?o:o.mesh,a=s.intersectsMesh(i,o.usePreciseIntersection),h=i._intersectionsInProgress.indexOf(s);a&&-1===h?n.trigger===e.ActionManager.OnIntersectionEnterTrigger?(n._executeCurrent(e.ActionEvent.CreateNew(i,null,s)),i._intersectionsInProgress.push(s)):n.trigger===e.ActionManager.OnIntersectionExitTrigger&&i._intersectionsInProgress.push(s):!a&&h>-1&&(n.trigger===e.ActionManager.OnIntersectionExitTrigger&&n._executeCurrent(e.ActionEvent.CreateNew(i,null,s)),i.actionManager.hasSpecificTrigger(e.ActionManager.OnIntersectionExitTrigger)&&n.trigger!==e.ActionManager.OnIntersectionExitTrigger||i._intersectionsInProgress.splice(h,1))}}},t.prototype.render=function(){var i=e.Tools.Now;this._particlesDuration=0,this._spritesDuration=0,this._activeParticles=0,this._renderDuration=0,this._renderTargetsDuration=0,this._evaluateActiveMeshesDuration=0,this._totalVertices=0,this._activeIndices=0,this._activeBones=0,this.getEngine().resetDrawCalls(),this._meshesForIntersections.reset(),this.resetCachedMaterial(),e.Tools.StartPerformanceCounter("Scene rendering"),this.actionManager&&this.actionManager.processTrigger(e.ActionManager.OnEveryFrameTrigger,null),this.simplificationQueue.running||this.simplificationQueue.executeNext();var r,n=Math.max(t.MinDeltaTime,Math.min(this._engine.getDeltaTime(),t.MaxDeltaTime));for(this._animationRatio=.06*n,this._animate(),this._physicsEngine&&(e.Tools.StartPerformanceCounter("Physics"),this._physicsEngine._runOneStep(n/1e3),e.Tools.EndPerformanceCounter("Physics")),this.beforeRender&&this.beforeRender(),r=0;r<this._onBeforeRenderCallbacks.length;r++)this._onBeforeRenderCallbacks[r]();var o=e.Tools.Now,s=this.getEngine(),a=this.activeCamera;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0);for(var h=0;h<this.customRenderTargets.length;h++){var c=this.customRenderTargets[h];if(c._shouldRender()){if(this._renderId++,this.activeCamera=c.activeCamera||this.activeCamera,!this.activeCamera)throw new Error("Active camera not set");s.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),c.render(a!==this.activeCamera,this.dumpNextRenderTargets)}}e.Tools.EndPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._renderId++}if(this.customRenderTargets.length>0&&s.restoreDefaultFramebuffer(),this._renderTargetsDuration+=e.Tools.Now-o,this.activeCamera=a,this.proceduralTexturesEnabled){e.Tools.StartPerformanceCounter("Procedural textures",this._proceduralTextures.length>0);for(var l=0;l<this._proceduralTextures.length;l++){var u=this._proceduralTextures[l];u._shouldRender()&&u.render()}e.Tools.EndPerformanceCounter("Procedural textures",this._proceduralTextures.length>0)}if(this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,!0),this.shadowsEnabled)for(var d=0;d<this.lights.length;d++){var f=this.lights[d],p=f.getShadowGenerator();f.isEnabled()&&p&&-1!==p.getShadowMap().getScene().textures.indexOf(p.getShadowMap())&&this._renderTargets.push(p.getShadowMap())}if(this._depthRenderer&&this._renderTargets.push(this._depthRenderer.getDepthMap()),this.postProcessRenderPipelineManager.update(),this.activeCameras.length>0)for(var m=this._renderId,g=0;g<this.activeCameras.length;g++)this._renderId=m,this._processSubCameras(this.activeCameras[g]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}for(this._checkIntersections(),this._updateAudioParameters(),this.afterRender&&this.afterRender(),r=0;r<this._onAfterRenderCallbacks.length;r++)this._onAfterRenderCallbacks[r]();for(var v=0;v<this._toBeDisposed.length;v++)this._toBeDisposed.data[v].dispose(),this._toBeDisposed[v]=null;this._toBeDisposed.reset(),this.dumpNextRenderTargets&&(this.dumpNextRenderTargets=!1),e.Tools.EndPerformanceCounter("Scene rendering"),this._lastFrameDuration=e.Tools.Now-i},t.prototype._updateAudioParameters=function(){if(this.audioEnabled&&(0!==this.mainSoundTrack.soundCollection.length||0!==this.soundTracks.length)){var t,i=e.Engine.audioEngine;if((t=this.activeCameras.length>0?this.activeCameras[0]:this.activeCamera)&&i.canUseWebAudio){i.audioContext.listener.setPosition(t.position.x,t.position.y,t.position.z);var r,n=e.Matrix.Invert(t.getViewMatrix()),o=e.Vector3.TransformNormal(new e.Vector3(0,0,-1),n);for(o.normalize(),i.audioContext.listener.setOrientation(o.x,o.y,o.z,0,1,0),r=0;r<this.mainSoundTrack.soundCollection.length;r++){var s=this.mainSoundTrack.soundCollection[r];s.useCustomAttenuation&&s.updateDistanceFromListener()}for(r=0;r<this.soundTracks.length;r++)for(var a=0;a<this.soundTracks[r].soundCollection.length;a++)(s=this.soundTracks[r].soundCollection[a]).useCustomAttenuation&&s.updateDistanceFromListener()}}},Object.defineProperty(t.prototype,"audioEnabled",{get:function(){return this._audioEnabled},set:function(e){this._audioEnabled=e,this._audioEnabled?this._enableAudio():this._disableAudio()},enumerable:!0,configurable:!0}),t.prototype._disableAudio=function(){var e;for(e=0;e<this.mainSoundTrack.soundCollection.length;e++)this.mainSoundTrack.soundCollection[e].pause();for(e=0;e<this.soundTracks.length;e++)for(var t=0;t<this.soundTracks[e].soundCollection.length;t++)this.soundTracks[e].soundCollection[t].pause()},t.prototype._enableAudio=function(){var e;for(e=0;e<this.mainSoundTrack.soundCollection.length;e++)this.mainSoundTrack.soundCollection[e].isPaused&&this.mainSoundTrack.soundCollection[e].play();for(e=0;e<this.soundTracks.length;e++)for(var t=0;t<this.soundTracks[e].soundCollection.length;t++)this.soundTracks[e].soundCollection[t].isPaused&&this.soundTracks[e].soundCollection[t].play()},Object.defineProperty(t.prototype,"headphone",{get:function(){return this._headphone},set:function(e){this._headphone=e,this._headphone?this._switchAudioModeForHeadphones():this._switchAudioModeForNormalSpeakers()},enumerable:!0,configurable:!0}),t.prototype._switchAudioModeForHeadphones=function(){this.mainSoundTrack.switchPanningModelToHRTF();for(var e=0;e<this.soundTracks.length;e++)this.soundTracks[e].switchPanningModelToHRTF()},t.prototype._switchAudioModeForNormalSpeakers=function(){this.mainSoundTrack.switchPanningModelToEqualPower();for(var e=0;e<this.soundTracks.length;e++)this.soundTracks[e].switchPanningModelToEqualPower()},t.prototype.enableDepthRenderer=function(){return this._depthRenderer?this._depthRenderer:(this._depthRenderer=new e.DepthRenderer(this),this._depthRenderer)},t.prototype.disableDepthRenderer=function(){this._depthRenderer&&(this._depthRenderer.dispose(),this._depthRenderer=null)},t.prototype.dispose=function(){this.beforeRender=null,this.afterRender=null,this.skeletons=[],this._boundingBoxRenderer.dispose(),this._depthRenderer&&this._depthRenderer.dispose(),this.debugLayer.hide(),this.onDispose&&this.onDispose(),this._onBeforeRenderCallbacks=[],this._onAfterRenderCallbacks=[],this.detachControl(),this.disposeSounds();var e,t=this._engine.getRenderingCanvas();for(e=0;e<this.cameras.length;e++)this.cameras[e].detachControl(t);for(;this.lights.length;)this.lights[0].dispose();for(;this.meshes.length;)this.meshes[0].dispose(!0);for(;this.cameras.length;)this.cameras[0].dispose();for(;this.materials.length;)this.materials[0].dispose();for(;this.particleSystems.length;)this.particleSystems[0].dispose();for(;this.spriteManagers.length;)this.spriteManagers[0].dispose();for(;this.layers.length;)this.layers[0].dispose();for(;this.textures.length;)this.textures[0].dispose();this.postProcessManager.dispose(),this._physicsEngine&&this.disablePhysicsEngine(),(e=this._engine.scenes.indexOf(this))>-1&&this._engine.scenes.splice(e,1),this._engine.wipeCaches()},t.prototype.disposeSounds=function(){this.mainSoundTrack.dispose();for(var e=0;e<this.soundTracks.length;e++)this.soundTracks[e].dispose()},t.prototype.getWorldExtends=function(){for(var t=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),i=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),r=0;r<this.meshes.length;r++){var n=this.meshes[r];n.computeWorldMatrix(!0);var o=n.getBoundingInfo().boundingBox.minimumWorld,s=n.getBoundingInfo().boundingBox.maximumWorld;e.Tools.CheckExtends(o,t,i),e.Tools.CheckExtends(s,t,i)}return{min:t,max:i}},t.prototype.createOrUpdateSelectionOctree=function(t,i){void 0===t&&(t=64),void 0===i&&(i=2),this._selectionOctree||(this._selectionOctree=new e.Octree(e.Octree.CreationFuncForMeshes,t,i));var r=this.getWorldExtends();return this._selectionOctree.update(r.min,r.max,this.meshes),this._selectionOctree},t.prototype.createPickingRay=function(t,i,r,n,o){void 0===o&&(o=!1);var s=this._engine;if(!n){if(!this.activeCamera)throw new Error("Active camera not set");n=this.activeCamera}var a=n.viewport.toGlobal(s);return t=t/this._engine.getHardwareScalingLevel()-a.x,i=i/this._engine.getHardwareScalingLevel()-(this._engine.getRenderHeight()-a.y-a.height),e.Ray.CreateNew(t,i,a.width,a.height,r||e.Matrix.Identity(),o?e.Matrix.Identity():n.getViewMatrix(),n.getProjectionMatrix())},t.prototype.createPickingRayInCameraSpace=function(t,i,r){var n=this._engine;if(!r){if(!this.activeCamera)throw new Error("Active camera not set");r=this.activeCamera}var o=r.viewport.toGlobal(n),s=e.Matrix.Identity();return t=t/this._engine.getHardwareScalingLevel()-o.x,i=i/this._engine.getHardwareScalingLevel()-(this._engine.getRenderHeight()-o.y-o.height),e.Ray.CreateNew(t,i,o.width,o.height,s,s,r.getProjectionMatrix())},t.prototype._internalPick=function(t,i,r){for(var n=null,o=0;o<this.meshes.length;o++){var s=this.meshes[o];if(i){if(!i(s))continue}else if(!s.isEnabled()||!s.isVisible||!s.isPickable)continue;var a=t(s.getWorldMatrix()),h=s.intersects(a,r);if(h&&h.hit&&(r||null==n||!(h.distance>=n.distance))&&(n=h,r))break}return n||new e.PickingInfo},t.prototype._internalPickSprites=function(t,i,r,n){var o=null;if(n=n||this.activeCamera,this.spriteManagers.length>0)for(var s=0;s<this.spriteManagers.length;s++){var a=this.spriteManagers[s];if(a.isPickable){var h=a.intersects(t,n,i,r);if(h&&h.hit&&(r||null==o||!(h.distance>=o.distance))&&(o=h,r))break}}return o||new e.PickingInfo},t.prototype.pick=function(e,t,i,r,n){var o=this;return this._internalPick(function(i){return o.createPickingRay(e,t,i,n)},i,r)},t.prototype.pickSprite=function(e,t,i,r,n){return this._internalPickSprites(this.createPickingRayInCameraSpace(e,t,n),i,r,n)},t.prototype.pickWithRay=function(t,i,r){var n=this;return this._internalPick(function(i){return n._pickWithRayInverseMatrix||(n._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(n._pickWithRayInverseMatrix),e.Ray.Transform(t,n._pickWithRayInverseMatrix)},i,r)},t.prototype.setPointerOverMesh=function(t){this._pointerOverMesh!==t&&(this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,e.ActionEvent.CreateNew(this._pointerOverMesh)),this._pointerOverMesh=t,this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,e.ActionEvent.CreateNew(this._pointerOverMesh)))},t.prototype.getPointerOverMesh=function(){return this._pointerOverMesh},t.prototype.getPhysicsEngine=function(){return this._physicsEngine},t.prototype.enablePhysics=function(t,i){return!!this._physicsEngine||(this._physicsEngine=new e.PhysicsEngine(i),this._physicsEngine.isSupported()?(this._physicsEngine._initialize(t),!0):(this._physicsEngine=null,!1))},t.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=void 0)},t.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},t.prototype.setGravity=function(e){this._physicsEngine&&this._physicsEngine._setGravity(e)},t.prototype.createCompoundImpostor=function(e,t){if(e.parts&&(t=e,e=e.parts),!this._physicsEngine)return null;for(var i=0;i<e.length;i++){var r=e[i].mesh;r._physicImpostor=e[i].impostor,r._physicsMass=t.mass/e.length,r._physicsFriction=t.friction,r._physicRestitution=t.restitution}return this._physicsEngine._registerMeshesAsCompound(e,t)},t.prototype.deleteCompoundImpostor=function(t){for(var i=0;i<t.parts.length;i++){var r=t.parts[i].mesh;r._physicImpostor=e.PhysicsEngine.NoImpostor,this._physicsEngine._unregisterMesh(r)}},t.prototype.createDefaultCameraOrLight=function(){if(0===this.lights.length&&new e.HemisphericLight("default light",e.Vector3.Up(),this),!this.activeCamera){var t=new e.FreeCamera("default camera",e.Vector3.Zero(),this),i=this.getWorldExtends(),r=i.min.add(i.max.subtract(i.min).scale(.5));t.position=new e.Vector3(r.x,r.y,i.min.z-(i.max.z-i.min.z)),t.setTarget(r),this.activeCamera=t}},t.prototype._getByTags=function(t,i,r){if(void 0===i)return t;var n=[];for(var o in r=r||function(e){},t){var s=t[o];e.Tags.MatchesQuery(s,i)&&(n.push(s),r(s))}return n},t.prototype.getMeshesByTags=function(e,t){return this._getByTags(this.meshes,e,t)},t.prototype.getCamerasByTags=function(e,t){return this._getByTags(this.cameras,e,t)},t.prototype.getLightsByTags=function(e,t){return this._getByTags(this.lights,e,t)},t.prototype.getMaterialByTags=function(e,t){return this._getByTags(this.materials,e,t).concat(this._getByTags(this.multiMaterials,e,t))},t._FOGMODE_NONE=0,t._FOGMODE_EXP=1,t._FOGMODE_EXP2=2,t._FOGMODE_LINEAR=3,t.MinDeltaTime=1,t.MaxDeltaTime=1e3,t}();e.Scene=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(i,r,n,o,s,a){if(this._engine=i instanceof e.Mesh?i.getScene().getEngine():i,this._updatable=o,this._data=r,s||this.create(),this._kind=n,a)this._strideSize=a;else switch(n){case t.PositionKind:case t.NormalKind:this._strideSize=3;break;case t.UVKind:case t.UV2Kind:case t.UV3Kind:case t.UV4Kind:case t.UV5Kind:case t.UV6Kind:this._strideSize=2;break;case t.ColorKind:case t.MatricesIndicesKind:this._strideSize=4;break;case t.MatricesWeightsKind:this._strideSize=4}}return t.prototype.isUpdatable=function(){return this._updatable},t.prototype.getData=function(){return this._data},t.prototype.getBuffer=function(){return this._buffer},t.prototype.getStrideSize=function(){return this._strideSize},t.prototype.create=function(e){(e||!this._buffer)&&(e=e||this._data,this._buffer||(this._buffer=this._updatable?this._engine.createDynamicVertexBuffer(4*e.length):this._engine.createVertexBuffer(e)),this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e),this._data=e))},t.prototype.update=function(e){this.create(e)},t.prototype.updateDirectly=function(e,t){this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e,t),this._data=null)},t.prototype.dispose=function(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)},Object.defineProperty(t,"PositionKind",{get:function(){return t._PositionKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"NormalKind",{get:function(){return t._NormalKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UVKind",{get:function(){return t._UVKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV2Kind",{get:function(){return t._UV2Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV3Kind",{get:function(){return t._UV3Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV4Kind",{get:function(){return t._UV4Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV5Kind",{get:function(){return t._UV5Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV6Kind",{get:function(){return t._UV6Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ColorKind",{get:function(){return t._ColorKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MatricesIndicesKind",{get:function(){return t._MatricesIndicesKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MatricesWeightsKind",{get:function(){return t._MatricesWeightsKind},enumerable:!0,configurable:!0}),t._PositionKind="position",t._NormalKind="normal",t._UVKind="uv",t._UV2Kind="uv2",t._UV3Kind="uv3",t._UV4Kind="uv4",t._UV5Kind="uv5",t._UV6Kind="uv6",t._ColorKind="color",t._MatricesIndicesKind="matricesIndices",t._MatricesWeightsKind="matricesWeights",t}();e.VertexBuffer=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(e,i){t.call(this,e,i.getScene()),i.instances.push(this),this._sourceMesh=i,this.position.copyFrom(i.position),this.rotation.copyFrom(i.rotation),this.scaling.copyFrom(i.scaling),i.rotationQuaternion&&(this.rotationQuaternion=i.rotationQuaternion.clone()),this.infiniteDistance=i.infiniteDistance,this.setPivotMatrix(i.getPivotMatrix()),this.refreshBoundingInfo(),this._syncSubMeshes()}return __extends(i,t),Object.defineProperty(i.prototype,"receiveShadows",{get:function(){return this._sourceMesh.receiveShadows},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"material",{get:function(){return this._sourceMesh.material},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"visibility",{get:function(){return this._sourceMesh.visibility},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"skeleton",{get:function(){return this._sourceMesh.skeleton},enumerable:!0,configurable:!0}),i.prototype.getTotalVertices=function(){return this._sourceMesh.getTotalVertices()},Object.defineProperty(i.prototype,"sourceMesh",{get:function(){return this._sourceMesh},enumerable:!0,configurable:!0}),i.prototype.getVerticesData=function(e){return this._sourceMesh.getVerticesData(e)},i.prototype.isVerticesDataPresent=function(e){return this._sourceMesh.isVerticesDataPresent(e)},i.prototype.getIndices=function(){return this._sourceMesh.getIndices()},Object.defineProperty(i.prototype,"_positions",{get:function(){return this._sourceMesh._positions},enumerable:!0,configurable:!0}),i.prototype.refreshBoundingInfo=function(){var t=this._sourceMesh.getVerticesData(e.VertexBuffer.PositionKind);if(t){var i=e.Tools.ExtractMinAndMax(t,0,this._sourceMesh.getTotalVertices());this._boundingInfo=new e.BoundingInfo(i.minimum,i.maximum)}this._updateBoundingInfo()},i.prototype._preActivate=function(){this._currentLOD&&this._currentLOD._preActivate()},i.prototype._activate=function(e){this._currentLOD&&this._currentLOD._registerInstanceForRenderId(this,e)},i.prototype.getLOD=function(e){return this._currentLOD=this.sourceMesh.getLOD(this.getScene().activeCamera,this.getBoundingInfo().boundingSphere),this._currentLOD===this.sourceMesh?this:this._currentLOD},i.prototype._syncSubMeshes=function(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(var e=0;e<this._sourceMesh.subMeshes.length;e++)this._sourceMesh.subMeshes[e].clone(this,this._sourceMesh)},i.prototype._generatePointsArray=function(){return this._sourceMesh._generatePointsArray()},i.prototype.clone=function(t,i,r){var n=this._sourceMesh.createInstance(t);if(e.Tools.DeepCopy(this,n,["name"],[]),this.refreshBoundingInfo(),i&&(n.parent=i),!r)for(var o=0;o<this.getScene().meshes.length;o++){var s=this.getScene().meshes[o];s.parent===this&&s.clone(s.name,n)}return n.computeWorldMatrix(!0),n},i.prototype.dispose=function(e){var i=this._sourceMesh.instances.indexOf(this);this._sourceMesh.instances.splice(i,1),t.prototype.dispose.call(this,e)},i}(e.AbstractMesh);e.InstancedMesh=t}(BABYLON||(BABYLON={})),function(e){var t=function(){return function(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=new Array}}();e._InstancesBatch=t;var i=function(i){function r(n,o,s,a,h){if(void 0===s&&(s=null),i.call(this,n,o),this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this.instances=new Array,this._LODLevels=new Array,this._onBeforeRenderCallbacks=new Array,this._onAfterRenderCallbacks=new Array,this._visibleInstances={},this._renderIdForInstances=new Array,this._batchCache=new t,this._instancesBufferSize=2048,this._sideOrientation=r._DEFAULTSIDE,this._areNormalsFrozen=!1,a){var c;if(a._geometry&&a._geometry.applyToMesh(this),e.Tools.DeepCopy(a,this,["name","material","skeleton","instances"],[]),this.id=n+"."+a.id,this.material=a.material,!h)for(c=0;c<o.meshes.length;c++){var l=o.meshes[c];l.parent===a&&l.clone(n+"."+l.name,this,h)}for(c=0;c<o.particleSystems.length;c++){var u=o.particleSystems[c];u.emitter===a&&u.clone(u.name,this)}this.computeWorldMatrix(!0)}null!==s&&(this.parent=s)}return __extends(r,i),Object.defineProperty(r,"FRONTSIDE",{get:function(){return r._FRONTSIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BACKSIDE",{get:function(){return r._BACKSIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"DOUBLESIDE",{get:function(){return r._DOUBLESIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"DEFAULTSIDE",{get:function(){return r._DEFAULTSIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"NO_CAP",{get:function(){return r._NO_CAP},enumerable:!0,configurable:!0}),Object.defineProperty(r,"CAP_START",{get:function(){return r._CAP_START},enumerable:!0,configurable:!0}),Object.defineProperty(r,"CAP_END",{get:function(){return r._CAP_END},enumerable:!0,configurable:!0}),Object.defineProperty(r,"CAP_ALL",{get:function(){return r._CAP_ALL},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"hasLODLevels",{get:function(){return this._LODLevels.length>0},enumerable:!0,configurable:!0}),r.prototype._sortLODLevels=function(){this._LODLevels.sort(function(e,t){return e.distance<t.distance?1:e.distance>t.distance?-1:0})},r.prototype.addLODLevel=function(t,i){if(i&&i._masterMesh)return e.Tools.Warn("You cannot use a mesh as LOD level twice"),this;var r=new e.Internals.MeshLODLevel(t,i);return this._LODLevels.push(r),i&&(i._masterMesh=this),this._sortLODLevels(),this},r.prototype.getLODLevelAtDistance=function(e){for(var t=0;t<this._LODLevels.length;t++){var i=this._LODLevels[t];if(i.distance===e)return i.mesh}return null},r.prototype.removeLODLevel=function(e){for(var t=0;t<this._LODLevels.length;t++)this._LODLevels[t].mesh===e&&(this._LODLevels.splice(t,1),e&&(e._masterMesh=null));return this._sortLODLevels(),this},r.prototype.getLOD=function(e,t){if(!this._LODLevels||0===this._LODLevels.length)return this;var i=(t||this.getBoundingInfo().boundingSphere).centerWorld.subtract(e.position).length();if(this._LODLevels[this._LODLevels.length-1].distance>i)return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var r=0;r<this._LODLevels.length;r++){var n=this._LODLevels[r];if(n.distance<i)return n.mesh&&(n.mesh._preActivate(),n.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)),this.onLODLevelSelection&&this.onLODLevelSelection(i,this,n.mesh),n.mesh}return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this),this},Object.defineProperty(r.prototype,"geometry",{get:function(){return this._geometry},enumerable:!0,configurable:!0}),r.prototype.getTotalVertices=function(){return this._geometry?this._geometry.getTotalVertices():0},r.prototype.getVerticesData=function(e,t){return this._geometry?this._geometry.getVerticesData(e,t):null},r.prototype.getVertexBuffer=function(e){return this._geometry?this._geometry.getVertexBuffer(e):void 0},r.prototype.isVerticesDataPresent=function(e){return this._geometry?this._geometry.isVerticesDataPresent(e):!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)},r.prototype.getVerticesDataKinds=function(){if(!this._geometry){var e=[];if(this._delayInfo)for(var t in this._delayInfo)e.push(t);return e}return this._geometry.getVerticesDataKinds()},r.prototype.getTotalIndices=function(){return this._geometry?this._geometry.getTotalIndices():0},r.prototype.getIndices=function(e){return this._geometry?this._geometry.getIndices(e):[]},Object.defineProperty(r.prototype,"isBlocked",{get:function(){return null!==this._masterMesh&&void 0!==this._masterMesh},enumerable:!0,configurable:!0}),r.prototype.isReady=function(){return this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING&&i.prototype.isReady.call(this)},r.prototype.isDisposed=function(){return this._isDisposed},Object.defineProperty(r.prototype,"sideOrientation",{get:function(){return this._sideOrientation},set:function(e){this._sideOrientation=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"areNormalsFrozen",{get:function(){return this._areNormalsFrozen},enumerable:!0,configurable:!0}),r.prototype.freezeNormals=function(){this._areNormalsFrozen=!0},r.prototype.unfreezeNormals=function(){this._areNormalsFrozen=!1},r.prototype._preActivate=function(){var e=this.getScene().getRenderId();this._preActivateId!==e&&(this._preActivateId=e,this._visibleInstances=null)},r.prototype._registerInstanceForRenderId=function(e,t){this._visibleInstances||(this._visibleInstances={},this._visibleInstances.defaultRenderId=t,this._visibleInstances.selfDefaultRenderId=this._renderId),this._visibleInstances[t]||(this._visibleInstances[t]=new Array),this._visibleInstances[t].push(e)},r.prototype.refreshBoundingInfo=function(){var t=this.getVerticesData(e.VertexBuffer.PositionKind);if(t){var i=e.Tools.ExtractMinAndMax(t,0,this.getTotalVertices());this._boundingInfo=new e.BoundingInfo(i.minimum,i.maximum)}if(this.subMeshes)for(var r=0;r<this.subMeshes.length;r++)this.subMeshes[r].refreshBoundingInfo();this._updateBoundingInfo()},r.prototype._createGlobalSubMesh=function(){var t=this.getTotalVertices();return t&&this.getIndices()?(this.releaseSubMeshes(),new e.SubMesh(0,0,t,0,this.getTotalIndices(),this)):null},r.prototype.subdivide=function(t){if(!(1>t)){for(var i=this.getTotalIndices(),r=i/t|0,n=0;r%3!=0;)r++;this.releaseSubMeshes();for(var o=0;t>o&&!(n>=i);o++)e.SubMesh.CreateFromIndices(0,n,Math.min(r,i-n),this),n+=r;this.synchronizeInstances()}},r.prototype.setVerticesData=function(t,i,r,n){if(t instanceof Array){var o=i;i=t,t=o,e.Tools.Warn("Deprecated usage of setVerticesData detected (since v1.12). Current signature is setVerticesData(kind, data, updatable).")}if(this._geometry)this._geometry.setVerticesData(t,i,r,n);else{var s=new e.VertexData;s.set(i,t);var a=this.getScene();new e.Geometry(e.Geometry.RandomId(),a,s,r,this)}},r.prototype.updateVerticesData=function(e,t,i,r){this._geometry&&(r?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i))},r.prototype.updateVerticesDataDirectly=function(e,t,i,r){this._geometry&&(r?(this.makeGeometryUnique(),this.updateVerticesDataDirectly(e,t,i,!1)):this._geometry.updateVerticesDataDirectly(e,t,i))},r.prototype.updateMeshPositions=function(t,i){void 0===i&&(i=!0);var r=this.getVerticesData(e.VertexBuffer.PositionKind);if(t(r),this.updateVerticesData(e.VertexBuffer.PositionKind,r,!1,!1),i){var n=this.getIndices(),o=this.getVerticesData(e.VertexBuffer.NormalKind);e.VertexData.ComputeNormals(r,n,o),this.updateVerticesData(e.VertexBuffer.NormalKind,o,!1,!1)}},r.prototype.makeGeometryUnique=function(){this._geometry&&this._geometry.copy(e.Geometry.RandomId()).applyToMesh(this)},r.prototype.setIndices=function(t,i){if(this._geometry)this._geometry.setIndices(t,i);else{var r=new e.VertexData;r.indices=t;var n=this.getScene();new e.Geometry(e.Geometry.RandomId(),n,r,!1,this)}},r.prototype._bind=function(t,i,r){var n,o=this.getScene().getEngine();switch(r){case e.Material.PointFillMode:n=null;break;case e.Material.WireFrameFillMode:n=t.getLinesIndexBuffer(this.getIndices(),o);break;default:case e.Material.TriangleFillMode:n=this._geometry.getIndexBuffer()}o.bindMultiBuffers(this._geometry.getVertexBuffers(),n,i)},r.prototype._draw=function(t,i,r){if(this._geometry&&this._geometry.getVertexBuffers()&&this._geometry.getIndexBuffer()){var n=this.getScene().getEngine();switch(i){case e.Material.PointFillMode:n.drawPointClouds(t.verticesStart,t.verticesCount,r);break;case e.Material.WireFrameFillMode:n.draw(!1,0,t.linesIndexCount,r);break;default:n.draw(!0,t.indexStart,t.indexCount,r)}}},r.prototype.registerBeforeRender=function(e){this._onBeforeRenderCallbacks.push(e)},r.prototype.unregisterBeforeRender=function(e){var t=this._onBeforeRenderCallbacks.indexOf(e);t>-1&&this._onBeforeRenderCallbacks.splice(t,1)},r.prototype.registerAfterRender=function(e){this._onAfterRenderCallbacks.push(e)},r.prototype.unregisterAfterRender=function(e){var t=this._onAfterRenderCallbacks.indexOf(e);t>-1&&this._onAfterRenderCallbacks.splice(t,1)},r.prototype._getInstancesRenderList=function(e){var t=this.getScene();if(this._batchCache.mustReturn=!1,this._batchCache.renderSelf[e]=this.isEnabled()&&this.isVisible,this._batchCache.visibleInstances[e]=null,this._visibleInstances){var i=t.getRenderId();this._batchCache.visibleInstances[e]=this._visibleInstances[i];var r=this._renderId;if(!this._batchCache.visibleInstances[e]&&this._visibleInstances.defaultRenderId&&(this._batchCache.visibleInstances[e]=this._visibleInstances[this._visibleInstances.defaultRenderId],i=Math.max(this._visibleInstances.defaultRenderId,i),r=Math.max(this._visibleInstances.selfDefaultRenderId,i)),this._batchCache.visibleInstances[e]&&this._batchCache.visibleInstances[e].length){if(this._renderIdForInstances[e]===i)return this._batchCache.mustReturn=!0,this._batchCache;i!==r&&(this._batchCache.renderSelf[e]=!1)}this._renderIdForInstances[e]=i}return this._batchCache},r.prototype._renderWithInstances=function(e,t,i,r,n){for(var o=i.visibleInstances[e._id],s=16*(o.length+1)*4;this._instancesBufferSize<s;)this._instancesBufferSize*=2;(!this._worldMatricesInstancesBuffer||this._worldMatricesInstancesBuffer.capacity<this._instancesBufferSize)&&(this._worldMatricesInstancesBuffer&&n.deleteInstancesBuffer(this._worldMatricesInstancesBuffer),this._worldMatricesInstancesBuffer=n.createInstancesBuffer(this._instancesBufferSize),this._worldMatricesInstancesArray=new Float32Array(this._instancesBufferSize/4));var a=0,h=0,c=this.getWorldMatrix();if(i.renderSelf[e._id]&&(c.copyToArray(this._worldMatricesInstancesArray,a),a+=16,h++),o)for(var l=0;l<o.length;l++){o[l].getWorldMatrix().copyToArray(this._worldMatricesInstancesArray,a),a+=16,h++}var u=[r.getAttributeLocationByName("world0"),r.getAttributeLocationByName("world1"),r.getAttributeLocationByName("world2"),r.getAttributeLocationByName("world3")];n.updateAndBindInstancesBuffer(this._worldMatricesInstancesBuffer,this._worldMatricesInstancesArray,u),this._draw(e,t,h),n.unBindInstancesBuffer(this._worldMatricesInstancesBuffer,u)},r.prototype._processRendering=function(e,t,i,r,n,o){var s=this.getScene().getEngine();if(n)this._renderWithInstances(e,i,r,t,s);else if(r.renderSelf[e._id]&&(o&&o(!1,this.getWorldMatrix()),this._draw(e,i)),r.visibleInstances[e._id])for(var a=0;a<r.visibleInstances[e._id].length;a++){var h=r.visibleInstances[e._id][a].getWorldMatrix();o&&o(!0,h),this._draw(e,i)}},r.prototype.render=function(t,i){var r=this.getScene(),n=this._getInstancesRenderList(t._id);if(!n.mustReturn&&this._geometry&&this._geometry.getVertexBuffers()&&this._geometry.getIndexBuffer()){var o;for(o=0;o<this._onBeforeRenderCallbacks.length;o++)this._onBeforeRenderCallbacks[o](this);var s=r.getEngine(),a=null!==s.getCaps().instancedArrays&&null!==n.visibleInstances[t._id]&&void 0!==n.visibleInstances[t._id],h=t.getMaterial();if(h&&h.isReady(this,a)){var c=s.getDepthWrite();this.renderOutline&&(s.setDepthWrite(!1),r.getOutlineRenderer().render(t,n),s.setDepthWrite(c)),h._preBind();var l=h.getEffect(),u=r.forcePointsCloud?e.Material.PointFillMode:r.forceWireframe?e.Material.WireFrameFillMode:h.fillMode;this._bind(t,l,u);var d=this.getWorldMatrix();if(h.bind(d,this),i&&s.setAlphaMode(h.alphaMode),this._processRendering(t,l,u,n,a,function(e,t){e&&h.bindOnlyWorldMatrix(t)}),h.unbind(),this.renderOutline&&c&&(s.setDepthWrite(!0),s.setColorWrite(!1),r.getOutlineRenderer().render(t,n),s.setColorWrite(!0)),this.renderOverlay){var f=s.getAlphaMode();s.setAlphaMode(e.Engine.ALPHA_COMBINE),r.getOutlineRenderer().render(t,n,!0),s.setAlphaMode(f)}for(o=0;o<this._onAfterRenderCallbacks.length;o++)this._onAfterRenderCallbacks[o](this)}}},r.prototype.getEmittedParticleSystems=function(){for(var e=new Array,t=0;t<this.getScene().particleSystems.length;t++){var i=this.getScene().particleSystems[t];i.emitter===this&&e.push(i)}return e},r.prototype.getHierarchyEmittedParticleSystems=function(){var e=new Array,t=this.getDescendants();t.push(this);for(var i=0;i<this.getScene().particleSystems.length;i++){var r=this.getScene().particleSystems[i];-1!==t.indexOf(r.emitter)&&e.push(r)}return e},r.prototype.getChildren=function(){for(var e=[],t=0;t<this.getScene().meshes.length;t++){var i=this.getScene().meshes[t];i.parent===this&&e.push(i)}return e},r.prototype._checkDelayState=function(){var t=this,i=this,r=this.getScene();if(this._geometry)this._geometry.load(r);else if(i.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED){i.delayLoadState=e.Engine.DELAYLOADSTATE_LOADING,r._addPendingData(i);var n=-1!==this.delayLoadingFile.indexOf(".babylonbinarymeshdata");e.Tools.LoadFile(this.delayLoadingFile,function(i){i instanceof ArrayBuffer?t._delayLoadingFunction(i,t):t._delayLoadingFunction(JSON.parse(i),t),t.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,r._removePendingData(t)},function(){},r.database,n)}},r.prototype.isInFrustum=function(t){return this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING&&(!!i.prototype.isInFrustum.call(this,t)&&(this._checkDelayState(),!0))},r.prototype.setMaterialByID=function(e){var t,i=this.getScene().materials;for(t=0;t<i.length;t++)if(i[t].id===e)return void(this.material=i[t]);var r=this.getScene().multiMaterials;for(t=0;t<r.length;t++)if(r[t].id===e)return void(this.material=r[t])},r.prototype.getAnimatables=function(){var e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},r.prototype.bakeTransformIntoVertices=function(t){if(this.isVerticesDataPresent(e.VertexBuffer.PositionKind)){this._resetPointsArrayCache();var i,r=this.getVerticesData(e.VertexBuffer.PositionKind),n=[];for(i=0;i<r.length;i+=3)e.Vector3.TransformCoordinates(e.Vector3.FromArray(r,i),t).toArray(n,i);if(this.setVerticesData(e.VertexBuffer.PositionKind,n,this.getVertexBuffer(e.VertexBuffer.PositionKind).isUpdatable()),this.isVerticesDataPresent(e.VertexBuffer.NormalKind)){for(r=this.getVerticesData(e.VertexBuffer.NormalKind),n=[],i=0;i<r.length;i+=3)e.Vector3.TransformNormal(e.Vector3.FromArray(r,i),t).normalize().toArray(n,i);this.setVerticesData(e.VertexBuffer.NormalKind,n,this.getVertexBuffer(e.VertexBuffer.NormalKind).isUpdatable()),t.m[0]*t.m[5]*t.m[10]<0&&this.flipFaces()}}},r.prototype.bakeCurrentTransformIntoVertices=function(){this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)),this.scaling.copyFromFloats(1,1,1),this.position.copyFromFloats(0,0,0),this.rotation.copyFromFloats(0,0,0),this.rotationQuaternion&&(this.rotationQuaternion=e.Quaternion.Identity()),this._worldMatrix=e.Matrix.Identity()},r.prototype._resetPointsArrayCache=function(){this._positions=null},r.prototype._generatePointsArray=function(){if(this._positions)return!0;this._positions=[];var t=this.getVerticesData(e.VertexBuffer.PositionKind);if(!t)return!1;for(var i=0;i<t.length;i+=3)this._positions.push(e.Vector3.FromArray(t,i));return!0},r.prototype.clone=function(e,t,i){return new r(e,this.getScene(),t,this,i)},r.prototype.dispose=function(e){for(this._geometry&&this._geometry.releaseForMesh(this,!0),this._worldMatricesInstancesBuffer&&(this.getEngine().deleteInstancesBuffer(this._worldMatricesInstancesBuffer),this._worldMatricesInstancesBuffer=null);this.instances.length;)this.instances[0].dispose();i.prototype.dispose.call(this,e)},r.prototype.applyDisplacementMap=function(t,i,r,n){var o=this,s=this.getScene();e.Tools.LoadImage(t,function(e){var t=document.createElement("canvas"),s=t.getContext("2d"),a=e.width,h=e.height;t.width=a,t.height=h,s.drawImage(e,0,0);var c=s.getImageData(0,0,a,h).data;o.applyDisplacementMapFromBuffer(c,a,h,i,r),n&&n(o)},function(){},s.database)},r.prototype.applyDisplacementMapFromBuffer=function(t,i,r,n,o){if(this.isVerticesDataPresent(e.VertexBuffer.PositionKind)&&this.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&this.isVerticesDataPresent(e.VertexBuffer.UVKind)){for(var s=this.getVerticesData(e.VertexBuffer.PositionKind),a=this.getVerticesData(e.VertexBuffer.NormalKind),h=this.getVerticesData(e.VertexBuffer.UVKind),c=e.Vector3.Zero(),l=e.Vector3.Zero(),u=e.Vector2.Zero(),d=0;d<s.length;d+=3){e.Vector3.FromArrayToRef(s,d,c),e.Vector3.FromArrayToRef(a,d,l),e.Vector2.FromArrayToRef(h,d/3*2,u);var f=4*((Math.abs(u.x)*i%i|0)+(Math.abs(u.y)*r%r|0)*i),p=.3*(t[f]/255)+.59*(t[f+1]/255)+.11*(t[f+2]/255);l.normalize(),l.scaleInPlace(n+(o-n)*p),(c=c.add(l)).toArray(s,d)}e.VertexData.ComputeNormals(s,this.getIndices(),a),this.updateVerticesData(e.VertexBuffer.PositionKind,s),this.updateVerticesData(e.VertexBuffer.NormalKind,a)}else e.Tools.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing")},r.prototype.convertToFlatShadedMesh=function(){var t,i,r=this.getVerticesDataKinds(),n=[],o=[],s=[],a=!1;for(t=0;t<r.length;t++){i=r[t];var h=this.getVertexBuffer(i);i!==e.VertexBuffer.NormalKind?(n[i]=h,o[i]=n[i].getData(),s[i]=[]):(a=h.isUpdatable(),r.splice(t,1),t--)}var c,l=this.subMeshes.slice(0),u=this.getIndices(),d=this.getTotalIndices();for(c=0;d>c;c++){var f=u[c];for(t=0;t<r.length;t++)for(var p=n[i=r[t]].getStrideSize(),m=0;p>m;m++)s[i].push(o[i][f*p+m])}var g=[],v=s[e.VertexBuffer.PositionKind];for(c=0;d>c;c+=3){u[c]=c,u[c+1]=c+1,u[c+2]=c+2;for(var _=e.Vector3.FromArray(v,3*c),y=e.Vector3.FromArray(v,3*(c+1)),x=e.Vector3.FromArray(v,3*(c+2)),b=_.subtract(y),M=x.subtract(y),E=e.Vector3.Normalize(e.Vector3.Cross(b,M)),T=0;3>T;T++)g.push(E.x),g.push(E.y),g.push(E.z)}for(this.setIndices(u),this.setVerticesData(e.VertexBuffer.NormalKind,g,a),t=0;t<r.length;t++)i=r[t],this.setVerticesData(i,s[i],n[i].isUpdatable());this.releaseSubMeshes();for(var w=0;w<l.length;w++){var S=l[w];new e.SubMesh(S.materialIndex,S.indexStart,S.indexCount,S.indexStart,S.indexCount,this)}this.synchronizeInstances()},r.prototype.flipFaces=function(t){void 0===t&&(t=!1);var i,r,n=e.VertexData.ExtractFromMesh(this);if(t&&this.isVerticesDataPresent(e.VertexBuffer.NormalKind))for(i=0;i<n.normals.length;i++)n.normals[i]*=-1;for(i=0;i<n.indices.length;i+=3)r=n.indices[i+1],n.indices[i+1]=n.indices[i+2],n.indices[i+2]=r;n.applyToMesh(this)},r.prototype.createInstance=function(t){return new e.InstancedMesh(t,this)},r.prototype.synchronizeInstances=function(){for(var e=0;e<this.instances.length;e++){this.instances[e]._syncSubMeshes()}},r.prototype.simplify=function(t,i,r,n){void 0===i&&(i=!0),void 0===r&&(r=e.SimplificationType.QUADRATIC),this.getScene().simplificationQueue.addTask({settings:t,parallelProcessing:i,mesh:this,simplificationType:r,successCallback:n})},r.prototype.optimizeIndices=function(t){for(var i=this,r=this.getIndices(),n=this.getVerticesData(e.VertexBuffer.PositionKind),o=[],s=0;s<n.length;s+=3)o.push(e.Vector3.FromArray(n,s));var a=[];e.AsyncLoop.SyncAsyncForLoop(o.length,40,function(e){for(var t=o.length-1-e,i=o[t],r=0;t>r;++r){var n=o[r];if(i.equals(n)){a[t]=r;break}}},function(){for(var e=0;e<r.length;++e)r[e]=a[r[e]]||r[e];var n=i.subMeshes.slice(0);i.setIndices(r),i.subMeshes=n,t&&t(i)})},r.CreateRibbon=function(t,i,n,o,s,a,h,c,l){var u,d;if(void 0===c&&(c=r.DEFAULTSIDE),void 0===l&&(l=null),Array.isArray(i)?(u=i,d=n,l||(i={pathArray:u,closeArray:d,closePath:o,offset:s,updatable:h,sideOrientation:c})):(a=n,u=i.pathArray,d=i.closeArray,o=i.closePath,s=i.offset,c=i.sideOrientation,l=i.instance,h=i.updatable),l){var f=l.getVerticesData(e.VertexBuffer.PositionKind);if(function(e){for(var t=u[0].length,i=0,n=l.sideOrientation===r.DOUBLESIDE?2:1,o=1;n>=o;o++)for(var s=0;s<u.length;s++){var a=u[s],h=a.length;t=h>t?t:h;for(var c=0;t>c;)e[i]=a[c].x,e[i+1]=a[c].y,e[i+2]=a[c].z,c++,i+=3;l._closePath&&(e[i]=a[0].x,e[i+1]=a[0].y,e[i+2]=a[0].z,i+=3)}}(f),l.updateVerticesData(e.VertexBuffer.PositionKind,f,!1,!1),!l.areNormalsFrozen){var p=l.getIndices(),m=l.getVerticesData(e.VertexBuffer.NormalKind);if(e.VertexData.ComputeNormals(f,p,m),l._closePath)for(var g=0,v=0,_=0;_<u.length;_++)g=3*l._idx[_],v=_+1<u.length?3*(l._idx[_+1]-1):m.length-3,m[g]=.5*(m[g]+m[v]),m[g+1]=.5*(m[g+1]+m[v+1]),m[g+2]=.5*(m[g+2]+m[v+2]),m[v]=m[g],m[v+1]=m[g+1],m[v+2]=m[g+2];l.updateVerticesData(e.VertexBuffer.NormalKind,m,!1,!1)}return l}var y=new r(t,a);y.sideOrientation=c;var x=e.VertexData.CreateRibbon(i);return o&&(y._idx=x._idx),y._closePath=o,y._closeArray=d,x.applyToMesh(y,h),y},r.CreateDisc=function(t,i,n,o,s,a){(void 0===a&&(a=r.DEFAULTSIDE),n instanceof e.Scene)?o=n:i={radius:i,tessellation:n,sideOrientation:a};var h=new r(t,o);return e.VertexData.CreateDisc(i).applyToMesh(h,s||i.updatable),h},r.CreateBox=function(t,i,n,o,s){(void 0===s&&(s=r.DEFAULTSIDE),o=o||i.updatable,"number"==typeof i)&&(i={size:i,sideOrientation:s});var a=new r(t,n);return e.VertexData.CreateBox(i).applyToMesh(a,o),a},r.CreateSphere=function(t,i,n,o,s,a){(void 0===a&&(a=r.DEFAULTSIDE),n instanceof e.Scene)?(o=n,s=i.updatable):i={segments:i,diameterX:n,diameterY:n,diameterZ:n,sideOrientation:a};var h=new r(t,o);return e.VertexData.CreateSphere(i).applyToMesh(h,s),h},r.CreateCylinder=function(t,i,n,o,s,a,h,c,l){(void 0===l&&(l=r.DEFAULTSIDE),n instanceof e.Scene)?(h=n,c=i.updatable):(void 0!==h&&h instanceof e.Scene||(void 0!==h&&(l=c||r.DEFAULTSIDE,c=h),h=a,a=1),i={height:i,diameterTop:n,diameterBottom:o,tessellation:s,subdivisions:a,sideOrientation:l});var u=new r(t,h);return e.VertexData.CreateCylinder(i).applyToMesh(u,c),u},r.CreateTorus=function(t,i,n,o,s,a,h){n instanceof e.Scene?(s=n,a=i.updatable):i={diameter:i,thickness:n,tessellation:o,sideOrientation:h};var c=new r(t,s);return e.VertexData.CreateTorus(i).applyToMesh(c,a),c},r.CreateTorusKnot=function(t,i,n,o,s,a,h,c,l,u){n instanceof e.Scene?(c=n,l=i.updatable):i={radius:i,tube:n,radialSegments:o,tubularSegments:s,p:a,q:h,sideOrientation:u};var d=new r(t,c);return e.VertexData.CreateTorusKnot(i).applyToMesh(d,l),d},r.CreateLines=function(t,i,r,n,o){var s;if(Array.isArray(i)?(s=i,o||(i={points:s})):(o=i.instance,s=i.points),o){return o.updateMeshPositions(function(e){for(var t=0,i=0;i<s.length;i++)e[t]=s[i].x,e[t+1]=s[i].y,e[t+2]=s[i].z,t+=3},!1),o}var a=new e.LinesMesh(t,r);return e.VertexData.CreateLines(i).applyToMesh(a,n||i.updatable),a},r.CreateDashedLines=function(t,i,r,n,o,s,a,h){var c,l;if(Array.isArray(i)?(c=i,l=r,h||(i={points:c,dashSize:l,gapSize:n,dashNb:o})):(s=r,c=i.points,h=i.instance,n=i.gapSize,o=i.dashNb,l=i.dashSize),h){return h.updateMeshPositions(function(t){var i,r,n=e.Vector3.Zero(),o=t.length/6,s=0,a=0,l=0,u=0,d=0,f=0;for(d=0;d<c.length-1;d++)c[d+1].subtractToRef(c[d],n),s+=n.length();for(i=s/o,r=h.dashSize*i/(h.dashSize+h.gapSize),d=0;d<c.length-1;d++)for(c[d+1].subtractToRef(c[d],n),a=Math.floor(n.length()/i),n.normalize(),f=0;a>f&&u<t.length;)l=i*f,t[u]=c[d].x+l*n.x,t[u+1]=c[d].y+l*n.y,t[u+2]=c[d].z+l*n.z,t[u+3]=c[d].x+(l+r)*n.x,t[u+4]=c[d].y+(l+r)*n.y,t[u+5]=c[d].z+(l+r)*n.z,u+=6,f++;for(;u<t.length;)t[u]=c[d].x,t[u+1]=c[d].y,t[u+2]=c[d].z,u+=3},!1),h}var u=new e.LinesMesh(t,s);return e.VertexData.CreateDashedLines(i).applyToMesh(u,a||i.updatable),u.dashSize=l,u.gapSize=n,u},r.ExtrudeShape=function(e,t,i,n,o,s,a,h,c,l){var u,d;return void 0===c&&(c=r.DEFAULTSIDE),void 0===l&&(l=null),Array.isArray(t)?(d=t,u=i,n=n||1,o=o||0,s=0===s?0:s||r.NO_CAP):(a=i,u=t.path,d=t.shape,n=t.scale||1,o=t.rotation||0,s=0===t.cap?0:t.cap||r.NO_CAP,h=t.updatable,c=0===t.sideOrientation?0:t.sideOrientation||r.DEFAULTSIDE,l=t.instance),r._ExtrudeShapeGeneric(e,d,u,n,o,null,null,!1,!1,s,!1,a,h,c,l)},r.ExtrudeShapeCustom=function(e,t,i,n,o,s,a,h,c,l,u,d){var f,p;return void 0===u&&(u=r.DEFAULTSIDE),void 0===d&&(d=null),Array.isArray(t)?(p=t,f=i,s=s||!1,a=a||!1,h=0===h?0:h||r.NO_CAP):(c=i,f=t.path,p=t.shape,n=t.scaleFunction||function(e,t){return 1},o=t.rotationFunction||function(e,t){return 0},s=t.ribbonCloseArray||!1,a=t.ribbonClosePath||!1,h=0===t.cap?0:t.cap||r.NO_CAP,l=t.updatable,u=0===t.sideOrientation?0:t.sideOrientation||r.DEFAULTSIDE,d=t.instance),r._ExtrudeShapeGeneric(e,p,f,null,null,n,o,s,a,h,!0,c,l,u,d)},r._ExtrudeShapeGeneric=function(t,i,n,o,s,a,h,c,l,u,d,f,p,m,g){var v,_,y=function(t,i,n,o,s,a,h,c,l,u){for(var d=n.getTangents(),f=n.getNormals(),p=n.getBinormals(),m=n.getDistances(),g=0,v=u?c:function(e,t){return a},_=u?h:function(e,t){return s},y=l===r.NO_CAP||l===r.CAP_END?0:2,x=e.Matrix.Zero(),b=0;b<i.length;b++){for(var M=new Array,E=v(b,m[b]),T=_(b,m[b]),w=0;w<t.length;w++){e.Matrix.RotationAxisToRef(d[b],g,x);var S=d[b].scale(t[w].z).add(f[b].scale(t[w].x)).add(p[b].scale(t[w].y)),A=e.Vector3.TransformCoordinates(S,x).scaleInPlace(T).add(i[b]);M.push(A)}o[y]=M,g+=E,y++}var P=function(t){var i,r=Array(),n=e.Vector3.Zero();for(i=0;i<t.length;i++)n.addInPlace(t[i]);for(n.scaleInPlace(1/t.length),i=0;i<t.length;i++)r.push(n);return r};switch(l){case r.NO_CAP:break;case r.CAP_START:o[0]=P(o[2]),o[1]=o[2].slice(0);break;case r.CAP_END:o[y]=o[y-1],o[y+1]=P(o[y-1]);break;case r.CAP_ALL:o[0]=P(o[2]),o[1]=o[2].slice(0),o[y]=o[y-1],o[y+1]=P(o[y-1])}return o};if(g)return v=g.path3D.update(n),_=y(i,n,g.path3D,g.pathArray,o,s,a,h,g.cap,d),r.CreateRibbon(null,_,null,null,null,null,null,null,g);_=y(i,n,v=new e.Path3D(n),new Array,o,s,a,h,u=0>u||u>3?0:u,d);var x=r.CreateRibbon(t,_,c,l,0,f,p,m);return x.pathArray=_,x.path3D=v,x.cap=u,x},r.CreateLathe=function(t,i,n,o,s,a,h){void 0===h&&(h=r.DEFAULTSIDE);var c,l,u=i.arc<=0?1:i.arc||1,d=void 0===i.closed||i.closed;Array.isArray(i)?(c=i,l=n||1,o=o||64):(s=n,c=i.shape,l=i.radius||1,o=i.tessellation||64,a=i.updatable,h=0===i.sideOrientation?0:i.sideOrientation||r.DEFAULTSIDE);for(var f=2*Math.PI,p=new Array,m=0;0===c[m].x;)m++;var g=c[m];for(m=0;m<c.length;m++)p.push(c[m].subtract(g));var v,_=f/o*u,y=new Array;for(m=0;o>=m;m++)v=new e.Vector3(Math.cos(m*_)*l,0,Math.sin(m*_)*l),y.push(v);d&&y.push(y[0]);return r.ExtrudeShapeCustom(t,p,y,function(){return 1},function(){return 0},d,!1,r.NO_CAP,s,a,h)},r.CreatePlane=function(t,i,n,o,s){if(void 0===s&&(s=r.DEFAULTSIDE),"number"==typeof i){i={size:i,width:i,height:i,sideOrientation:s}}var a=new r(t,n);return e.VertexData.CreatePlane(i).applyToMesh(a,o||i.updatable),a},r.CreateGround=function(t,i,r,n,o,s){r instanceof e.Scene?(o=r,s=i.updatable):i={width:i,height:r,subdivisions:n};var a=new e.GroundMesh(t,o);return a._setReady(!1),a._subdivisions=i.subdivisions||1,e.VertexData.CreateGround(i).applyToMesh(a,s||i.updatable),a._setReady(!0),a},r.CreateTiledGround=function(t,i,n,o,s,a,h,c,l){var u,d;"number"==typeof i?(u=i||-1,d=n||-1,o=o||1,s=s||1,a=a||{w:6,h:6},h=h||{w:2,h:2}):(c=n,u=i.xmin||-1,d=i.zmin||-1,o=i.xmax||1,s=i.zmax||1,a=i.subdivisions||{w:6,h:6},h=i.precision||{w:2,h:2});var f=new r(t,c);return e.VertexData.CreateTiledGround({xmin:u,zmin:d,xmax:o,zmax:s,subdivisions:a,precision:h}).applyToMesh(f,l),f},r.CreateGroundFromHeightMap=function(t,i,r,n,o,s,a,h,c,l){var u,d;"number"==typeof r?(u=r,d=n):(u=r.width||10,d=r.height||10,o=r.subdivisions||1,s=r.minHeight,a=r.maxHeight||10,c=r.updatable,l=r.onReady,h=n);var f=new e.GroundMesh(t,h);f._subdivisions=o,f._setReady(!1);return e.Tools.LoadImage(i,function(t){var i=document.createElement("canvas"),r=i.getContext("2d"),n=t.width,h=t.height;i.width=n,i.height=h,r.drawImage(t,0,0);var p=r.getImageData(0,0,n,h).data;e.VertexData.CreateGroundFromHeightMap({width:u,height:d,subdivisions:o,minHeight:s,maxHeight:a,buffer:p,bufferWidth:n,bufferHeight:h}).applyToMesh(f,c),f._setReady(!0),l&&l(f)},function(){},h.database),f},r.CreateTube=function(t,i,n,o,s,a,h,c,l,u){void 0===l&&(l=r.DEFAULTSIDE),void 0===u&&(u=null);var d,f,p=i.arc<=0?1:i.arc||1;Array.isArray(i)?(d=i,f=n):(h=n,d=i.path,f=i.radius||1,o=i.tessellation||64,s=i.radiusFunction,a=i.cap||r.NO_CAP,c=i.updatable,l=i.sideOrientation||r.DEFAULTSIDE,u=i.instance);var m,g,v=function(t,i,n,o,s,a,h,c){for(var l,u,d,f,p=i.getTangents(),m=i.getNormals(),g=i.getDistances(),v=2*Math.PI/s*c,_=a||function(e,t){return o},y=e.Matrix.Zero(),x=h===r._NO_CAP||h===r.CAP_END?0:2,b=0;b<t.length;b++){u=_(b,g[b]),l=Array(),d=m[b];for(var M=0;s>M;M++)e.Matrix.RotationAxisToRef(p[b],v*M,y),f=e.Vector3.TransformCoordinates(d,y).scaleInPlace(u).add(t[b]),l.push(f);n[x]=l,x++}var E=function(e,i){for(var r=Array(),n=0;e>n;n++)r.push(t[i]);return r};switch(h){case r.NO_CAP:break;case r.CAP_START:n[0]=E(s,0),n[1]=n[2].slice(0);break;case r.CAP_END:n[x]=n[x-1].slice(0),n[x+1]=E(s,t.length-1);break;case r.CAP_ALL:n[0]=E(s,0),n[1]=n[2].slice(0),n[x]=n[x-1].slice(0),n[x+1]=E(s,t.length-1)}return n};if(u)return p=p||u.arc,g=v(d,m=u.path3D.update(d),u.pathArray,f,u.tessellation,s,u.cap,p),(u=r.CreateRibbon(null,{pathArray:g,instance:u})).path3D=m,u.pathArray=g,u.arc=p,u;g=v(d,m=new e.Path3D(d),new Array,f,o,s,a=0>a||a>3?0:a,p);var _=r.CreateRibbon(t,{pathArray:g,closePath:!0,closeArray:!1,updatable:c,sideOrientation:l},h);return _.pathArray=g,_.path3D=m,_.tessellation=o,_.cap=a,_.arc=p,_},r.CreatePolyhedron=function(t,i,n){var o=new r(t,n);return e.VertexData.CreatePolyhedron(i).applyToMesh(o,i.updatable),o},r.CreateDecal=function(t,i,n,o,s,a){void 0===a&&(a=0);var h,c=i.getIndices(),l=i.getVerticesData(e.VertexBuffer.PositionKind),u=i.getVerticesData(e.VertexBuffer.NormalKind);if(n instanceof e.Vector3?h=n:(h=n.position||e.Vector3.Zero(),o=n.normal||e.Vector3.Up(),s=n.size||new e.Vector3(1,1,1),a=n.angle),!o){var d=new e.Vector3(0,0,1),f=i.getScene().activeCamera,p=e.Vector3.TransformCoordinates(d,f.getWorldMatrix());o=f.globalPosition.subtract(p)}var m=-Math.atan2(o.z,o.x)-Math.PI/2,g=Math.sqrt(o.x*o.x+o.z*o.z),v=Math.atan2(o.y,g),_=e.Matrix.RotationYawPitchRoll(m,v,a).multiply(e.Matrix.Translation(h.x,h.y,h.z)),y=e.Matrix.Invert(_),x=i.getWorldMatrix().multiply(y),b=new e.VertexData;b.indices=[],b.positions=[],b.normals=[],b.uvs=[];for(var M=0,E=function(t){var i=c[t],r=new e.PositionNormalVertex;return r.position=new e.Vector3(l[3*i],l[3*i+1],l[3*i+2]),r.position=e.Vector3.TransformCoordinates(r.position,x),r.normal=new e.Vector3(u[3*i],u[3*i+1],u[3*i+2]),r},T=function(t,i){if(0===t.length)return t;for(var r=.5*Math.abs(e.Vector3.Dot(s,i)),n=function(t,n){var o=e.Vector3.GetClipFactor(t.position,n.position,i,r);return new e.PositionNormalVertex(e.Vector3.Lerp(t.position,n.position,o),e.Vector3.Lerp(t.normal,n.normal,o))},o=new Array,a=0;a<t.length;a+=3){var h,c,l,u,d,f,p;switch(((h=e.Vector3.Dot(t[a].position,i)-r>0)?1:0)+((c=e.Vector3.Dot(t[a+1].position,i)-r>0)?1:0)+((l=e.Vector3.Dot(t[a+2].position,i)-r>0)?1:0)){case 0:o.push(t[a]),o.push(t[a+1]),o.push(t[a+2]);break;case 1:if(h&&(u=t[a+1],d=t[a+2],f=n(t[a],u),p=n(t[a],d)),c){u=t[a],d=t[a+2],f=n(t[a+1],u),p=n(t[a+1],d),o.push(f),o.push(d.clone()),o.push(u.clone()),o.push(d.clone()),o.push(f.clone()),o.push(p);break}l&&(u=t[a],d=t[a+1],f=n(t[a+2],u),p=n(t[a+2],d)),o.push(u.clone()),o.push(d.clone()),o.push(f),o.push(p),o.push(f.clone()),o.push(d.clone());break;case 2:h||(d=n(u=t[a].clone(),t[a+1]),f=n(u,t[a+2]),o.push(u),o.push(d),o.push(f)),c||(d=n(u=t[a+1].clone(),t[a+2]),f=n(u,t[a]),o.push(u),o.push(d),o.push(f)),l||(d=n(u=t[a+2].clone(),t[a]),f=n(u,t[a+1]),o.push(u),o.push(d),o.push(f))}}return o},w=0;w<c.length;w+=3){var S=new Array;if(S.push(E(w)),S.push(E(w+1)),S.push(E(w+2)),0!==(S=T(S=T(S=T(S=T(S=T(S=T(S,new e.Vector3(1,0,0)),new e.Vector3(-1,0,0)),new e.Vector3(0,1,0)),new e.Vector3(0,-1,0)),new e.Vector3(0,0,1)),new e.Vector3(0,0,-1))).length)for(var A=0;A<S.length;A++){var P=S[A];b.indices.push(M),P.position.toArray(b.positions,3*M),P.normal.toArray(b.normals,3*M),b.uvs.push(.5+P.position.x/s.x),b.uvs.push(.5+P.position.y/s.y),M++}}var C=new r(t,i.getScene());return b.applyToMesh(C),C.position=h.clone(),C.rotation=new e.Vector3(v,m,a),C},r.prototype.applySkeleton=function(t){if(!this.isVerticesDataPresent(e.VertexBuffer.PositionKind))return this;if(!this.isVerticesDataPresent(e.VertexBuffer.NormalKind))return this;if(!this.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind))return this;if(!this.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind))return this;var i;this._sourcePositions||(i=this.getVerticesData(e.VertexBuffer.PositionKind),this._sourcePositions=new Float32Array(i),this.getVertexBuffer(e.VertexBuffer.PositionKind).isUpdatable()||this.setVerticesData(e.VertexBuffer.PositionKind,i,!0)),this._sourceNormals||(i=this.getVerticesData(e.VertexBuffer.NormalKind),this._sourceNormals=new Float32Array(i),this.getVertexBuffer(e.VertexBuffer.NormalKind).isUpdatable()||this.setVerticesData(e.VertexBuffer.NormalKind,i,!0));for(var r=this.getVerticesData(e.VertexBuffer.PositionKind),n=this.getVerticesData(e.VertexBuffer.NormalKind),o=this.getVerticesData(e.VertexBuffer.MatricesIndicesKind),s=this.getVerticesData(e.VertexBuffer.MatricesWeightsKind),a=t.getTransformMatrices(),h=e.Vector3.Zero(),c=new e.Matrix,l=new e.Matrix,u=0;u<r.length;u+=3){var d=u/3*4,f=s[d],p=s[d+1],m=s[d+2],g=s[d+3];f>0&&(e.Matrix.FromFloat32ArrayToRefScaled(a,16*o[d],f,l),c.addToSelf(l)),p>0&&(e.Matrix.FromFloat32ArrayToRefScaled(a,16*o[d+1],p,l),c.addToSelf(l)),m>0&&(e.Matrix.FromFloat32ArrayToRefScaled(a,16*o[d+2],m,l),c.addToSelf(l)),g>0&&(e.Matrix.FromFloat32ArrayToRefScaled(a,16*o[d+3],g,l),c.addToSelf(l)),e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[u],this._sourcePositions[u+1],this._sourcePositions[u+2],c,h),h.toArray(r,u),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[u],this._sourceNormals[u+1],this._sourceNormals[u+2],c,h),h.toArray(n,u),c.reset()}return this.updateVerticesData(e.VertexBuffer.PositionKind,r),this.updateVerticesData(e.VertexBuffer.NormalKind,n),this},r.MinMax=function(e){var t=null,i=null;for(var r in e){var n=e[r].getBoundingInfo().boundingBox;t?(t.MinimizeInPlace(n.minimumWorld),i.MaximizeInPlace(n.maximumWorld)):(t=n.minimumWorld,i=n.maximumWorld)}return{min:t,max:i}},r.Center=function(t){var i=void 0!==t.min?t:r.MinMax(t);return e.Vector3.Center(i.min,i.max)},r.MergeMeshes=function(t,i,n,o){var s,a,h,c;if(void 0===i&&(i=!0),!n){var l=0;for(s=0;s<t.length;s++)if(t[s]&&(l+=t[s].getTotalVertices())>65536)return e.Tools.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}for(s=0;s<t.length;s++)t[s]&&(t[s].computeWorldMatrix(!0),(h=e.VertexData.ExtractFromMesh(t[s],!0)).transform(t[s].getWorldMatrix()),a?a.merge(h):(a=h,c=t[s]));if(o||(o=new r(c.name+"_merged",c.getScene())),a.applyToMesh(o),o.material=c.material,o.checkCollisions=c.checkCollisions,i)for(s=0;s<t.length;s++)t[s]&&t[s].dispose();return o},r._FRONTSIDE=0,r._BACKSIDE=1,r._DOUBLESIDE=2,r._DEFAULTSIDE=0,r._NO_CAP=0,r._CAP_START=1,r._CAP_END=2,r._CAP_ALL=3,r}(e.AbstractMesh);e.Mesh=i}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(e,t,i,r,n,o,s,a){void 0===a&&(a=!0),this.materialIndex=e,this.verticesStart=t,this.verticesCount=i,this.indexStart=r,this.indexCount=n,this._renderId=0,this._mesh=o,this._renderingMesh=s||o,o.subMeshes.push(this),this._trianglePlanes=[],this._id=o.subMeshes.length-1,a&&(this.refreshBoundingInfo(),o.computeWorldMatrix(!0))}return t.prototype.getBoundingInfo=function(){return this._boundingInfo},t.prototype.getMesh=function(){return this._mesh},t.prototype.getRenderingMesh=function(){return this._renderingMesh},t.prototype.getMaterial=function(){var t=this._renderingMesh.material;return t&&t instanceof e.MultiMaterial?t.getSubMaterial(this.materialIndex):t||this._mesh.getScene().defaultMaterial},t.prototype.refreshBoundingInfo=function(){var t=this._renderingMesh.getVerticesData(e.VertexBuffer.PositionKind);if(t){var i,r=this._renderingMesh.getIndices();i=0===this.indexStart&&this.indexCount===r.length?e.Tools.ExtractMinAndMax(t,this.verticesStart,this.verticesCount):e.Tools.ExtractMinAndMaxIndexed(t,r,this.indexStart,this.indexCount),this._boundingInfo=new e.BoundingInfo(i.minimum,i.maximum)}else this._boundingInfo=this._mesh._boundingInfo},t.prototype._checkCollision=function(e){return this._boundingInfo._checkCollision(e)},t.prototype.updateBoundingInfo=function(e){this._boundingInfo||this.refreshBoundingInfo(),this._boundingInfo._update(e)},t.prototype.isInFrustum=function(e){return this._boundingInfo.isInFrustum(e)},t.prototype.render=function(e){this._renderingMesh.render(this,e)},t.prototype.getLinesIndexBuffer=function(e,t){if(!this._linesIndexBuffer){for(var i=[],r=this.indexStart;r<this.indexStart+this.indexCount;r+=3)i.push(e[r],e[r+1],e[r+1],e[r+2],e[r+2],e[r]);this._linesIndexBuffer=t.createIndexBuffer(i),this.linesIndexCount=i.length}return this._linesIndexBuffer},t.prototype.canIntersects=function(e){return e.intersectsBox(this._boundingInfo.boundingBox)},t.prototype.intersects=function(e,t,i,r){for(var n=null,o=this.indexStart;o<this.indexStart+this.indexCount;o+=3){var s=t[i[o]],a=t[i[o+1]],h=t[i[o+2]],c=e.intersectsTriangle(s,a,h);if(c){if(c.distance<0)continue;if((r||!n||c.distance<n.distance)&&((n=c).faceId=o/3,r))break}}return n},t.prototype.clone=function(i,r){var n=new t(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,i,r,!1);return n._boundingInfo=new e.BoundingInfo(this._boundingInfo.minimum,this._boundingInfo.maximum),n},t.prototype.dispose=function(){this._linesIndexBuffer&&(this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer),this._linesIndexBuffer=null);var e=this._mesh.subMeshes.indexOf(this);this._mesh.subMeshes.splice(e,1)},t.CreateFromIndices=function(e,i,r,n,o){for(var s=Number.MAX_VALUE,a=-Number.MAX_VALUE,h=(o=o||n).getIndices(),c=i;i+r>c;c++){var l=h[c];s>l&&(s=l),l>a&&(a=l)}return new t(e,s,a-s+1,i,r,n,o)},t}();e.SubMesh=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t){this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this.hasAlpha=!1,this.getAlphaFromRGB=!1,this.level=1,this.isCube=!1,this.isRenderTarget=!1,this.animations=new Array,this.coordinatesIndex=0,this.coordinatesMode=e.Texture.EXPLICIT_MODE,this.wrapU=e.Texture.WRAP_ADDRESSMODE,this.wrapV=e.Texture.WRAP_ADDRESSMODE,this.anisotropicFilteringLevel=4,this._scene=t,this._scene.textures.push(this)}return t.prototype.getScene=function(){return this._scene},t.prototype.getTextureMatrix=function(){return null},t.prototype.getReflectionTextureMatrix=function(){return null},t.prototype.getInternalTexture=function(){return this._texture},t.prototype.isReady=function(){return this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED||!!this._texture&&this._texture.isReady},t.prototype.getSize=function(){return this._texture._width?{width:this._texture._width,height:this._texture._height}:this._texture._size?{width:this._texture._size,height:this._texture._size}:{width:0,height:0}},t.prototype.getBaseSize=function(){return this.isReady()?this._texture._size?{width:this._texture._size,height:this._texture._size}:{width:this._texture._baseWidth,height:this._texture._baseHeight}:{width:0,height:0}},t.prototype.scale=function(e){},Object.defineProperty(t.prototype,"canRescale",{get:function(){return!1},enumerable:!0,configurable:!0}),t.prototype._removeFromCache=function(e,t){for(var i=this._scene.getEngine().getLoadedTexturesCache(),r=0;r<i.length;r++){var n=i[r];if(n.url===e&&n.noMipmap===t)return void i.splice(r,1)}},t.prototype._getFromCache=function(e,t,i){for(var r=this._scene.getEngine().getLoadedTexturesCache(),n=0;n<r.length;n++){var o=r[n];if(o.url===e&&o.noMipmap===t&&(!i||i===o.samplingMode))return o.references++,o}return null},t.prototype.delayLoad=function(){},t.prototype.clone=function(){return null},t.prototype.releaseInternalTexture=function(){this._texture&&(this._scene.getEngine().releaseInternalTexture(this._texture),delete this._texture)},t.prototype.dispose=function(){var e=this._scene.textures.indexOf(this);e>=0&&this._scene.textures.splice(e,1),void 0!==this._texture&&this.onDispose&&this.onDispose()},t}();e.BaseTexture=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(r,n,o,s,a,h,c,l,u){void 0===a&&(a=i.TRILINEAR_SAMPLINGMODE),void 0===h&&(h=null),void 0===c&&(c=null),void 0===l&&(l=null),void 0===u&&(u=!1),t.call(this,n),this.uOffset=0,this.vOffset=0,this.uScale=1,this.vScale=1,this.uAng=0,this.vAng=0,this.wAng=0,this.name=r,this.url=r,this._noMipmap=o,this._invertY=s,this._samplingMode=a,this._buffer=l,this._deleteBuffer=u,r&&(this._texture=this._getFromCache(r,o,a),this._texture?e.Tools.SetImmediate(function(){h&&h()}):n.useDelayedTextureLoading?this.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:(this._texture=n.getEngine().createTexture(r,o,s,n,this._samplingMode,h,c,this._buffer),u&&delete this._buffer))}return __extends(i,t),i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap,this._samplingMode),this._texture||(this._texture=this.getScene().getEngine().createTexture(this.url,this._noMipmap,this._invertY,this.getScene(),this._samplingMode,null,null,this._buffer),this._deleteBuffer&&delete this._buffer))},i.prototype.updateSamplingMode=function(e){this._texture&&this.getScene().getEngine().updateTextureSamplingMode(e,this._texture)},i.prototype._prepareRowForTextureGeneration=function(t,i,r,n){t*=this.uScale,i*=this.vScale,t-=.5*this.uScale,i-=.5*this.vScale,r-=.5,e.Vector3.TransformCoordinatesFromFloatsToRef(t,i,r,this._rowGenerationMatrix,n),n.x+=.5*this.uScale+this.uOffset,n.y+=.5*this.vScale+this.vOffset,n.z+=.5},i.prototype.getTextureMatrix=function(){return this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale===this._cachedUScale&&this.vScale===this._cachedVScale&&this.uAng===this._cachedUAng&&this.vAng===this._cachedVAng&&this.wAng===this._cachedWAng?this._cachedTextureMatrix:(this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale,this._cachedVScale=this.vScale,this._cachedUAng=this.uAng,this._cachedVAng=this.vAng,this._cachedWAng=this.wAng,this._cachedTextureMatrix||(this._cachedTextureMatrix=e.Matrix.Zero(),this._rowGenerationMatrix=new e.Matrix,this._t0=e.Vector3.Zero(),this._t1=e.Vector3.Zero(),this._t2=e.Vector3.Zero()),e.Matrix.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this._prepareRowForTextureGeneration(0,0,0,this._t0),this._prepareRowForTextureGeneration(1,0,0,this._t1),this._prepareRowForTextureGeneration(0,1,0,this._t2),this._t1.subtractInPlace(this._t0),this._t2.subtractInPlace(this._t0),e.Matrix.IdentityToRef(this._cachedTextureMatrix),this._cachedTextureMatrix.m[0]=this._t1.x,this._cachedTextureMatrix.m[1]=this._t1.y,this._cachedTextureMatrix.m[2]=this._t1.z,this._cachedTextureMatrix.m[4]=this._t2.x,this._cachedTextureMatrix.m[5]=this._t2.y,this._cachedTextureMatrix.m[6]=this._t2.z,this._cachedTextureMatrix.m[8]=this._t0.x,this._cachedTextureMatrix.m[9]=this._t0.y,this._cachedTextureMatrix.m[10]=this._t0.z,this._cachedTextureMatrix)},i.prototype.getReflectionTextureMatrix=function(){if(this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale===this._cachedUScale&&this.vScale===this._cachedVScale&&this.coordinatesMode===this._cachedCoordinatesMode)return this._cachedTextureMatrix;switch(this._cachedTextureMatrix||(this._cachedTextureMatrix=e.Matrix.Zero(),this._projectionModeMatrix=e.Matrix.Zero()),this._cachedCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case i.SPHERICAL_MODE:e.Matrix.IdentityToRef(this._cachedTextureMatrix),this._cachedTextureMatrix[0]=-.5*this.uScale,this._cachedTextureMatrix[5]=-.5*this.vScale,this._cachedTextureMatrix[12]=.5+this.uOffset,this._cachedTextureMatrix[13]=.5+this.vOffset;break;case i.PLANAR_MODE:e.Matrix.IdentityToRef(this._cachedTextureMatrix),this._cachedTextureMatrix[0]=this.uScale,this._cachedTextureMatrix[5]=this.vScale,this._cachedTextureMatrix[12]=this.uOffset,this._cachedTextureMatrix[13]=this.vOffset;break;case i.PROJECTION_MODE:e.Matrix.IdentityToRef(this._projectionModeMatrix),this._projectionModeMatrix.m[0]=.5,this._projectionModeMatrix.m[5]=-.5,this._projectionModeMatrix.m[10]=0,this._projectionModeMatrix.m[12]=.5,this._projectionModeMatrix.m[13]=.5,this._projectionModeMatrix.m[14]=1,this._projectionModeMatrix.m[15]=1,this.getScene().getProjectionMatrix().multiplyToRef(this._projectionModeMatrix,this._cachedTextureMatrix);break;default:e.Matrix.IdentityToRef(this._cachedTextureMatrix)}return this._cachedTextureMatrix},i.prototype.clone=function(){var e=new i(this._texture.url,this.getScene(),this._noMipmap,this._invertY,this._samplingMode);return e.hasAlpha=this.hasAlpha,e.level=this.level,e.wrapU=this.wrapU,e.wrapV=this.wrapV,e.coordinatesIndex=this.coordinatesIndex,e.coordinatesMode=this.coordinatesMode,e.uOffset=this.uOffset,e.vOffset=this.vOffset,e.uScale=this.uScale,e.vScale=this.vScale,e.uAng=this.uAng,e.vAng=this.vAng,e.wAng=this.wAng,e},i.CreateFromBase64String=function(e,t,r,n,o,s,a,h){return void 0===s&&(s=i.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=null),void 0===h&&(h=null),new i("data:"+t,r,n,o,s,a,h,e)},i.NEAREST_SAMPLINGMODE=1,i.BILINEAR_SAMPLINGMODE=2,i.TRILINEAR_SAMPLINGMODE=3,i.EXPLICIT_MODE=0,i.SPHERICAL_MODE=1,i.PLANAR_MODE=2,i.CUBIC_MODE=3,i.PROJECTION_MODE=4,i.SKYBOX_MODE=5,i.INVCUBIC_MODE=6,i.CLAMP_ADDRESSMODE=0,i.WRAP_ADDRESSMODE=1,i.MIRROR_ADDRESSMODE=2,i}(e.BaseTexture);e.Texture=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o){t.call(this,r),this.coordinatesMode=e.Texture.CUBIC_MODE,this.name=i,this.url=i,this._noMipmap=o,this.hasAlpha=!1,i&&(this._texture=this._getFromCache(i,o),n||(n=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),this._extensions=n,this._texture||(r.useDelayedTextureLoading?this.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:this._texture=r.getEngine().createCubeTexture(i,r,n,o)),this.isCube=!0,this._textureMatrix=e.Matrix.Identity())}return __extends(i,t),i.prototype.clone=function(){var e=new i(this.url,this.getScene(),this._extensions,this._noMipmap);return e.level=this.level,e.wrapU=this.wrapU,e.wrapV=this.wrapV,e.coordinatesIndex=this.coordinatesIndex,e.coordinatesMode=this.coordinatesMode,e},i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||(this._texture=this.getScene().getEngine().createCubeTexture(this.url,this.getScene(),this._extensions)))},i.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},i}(e.BaseTexture);e.CubeTexture=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o,s,a,h){void 0===s&&(s=!0),void 0===a&&(a=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=!1),t.call(this,null,n,!o),this.isCube=h,this.renderList=new Array,this.renderParticles=!0,this.renderSprites=!1,this.coordinatesMode=e.Texture.PROJECTION_MODE,this._currentRefreshId=-1,this._refreshRate=1,this.name=i,this.isRenderTarget=!0,this._size=r,this._generateMipMaps=o,this._doNotChangeAspectRatio=s,h?(this._texture=n.getEngine().createRenderTargetCubeTexture(r,{generateMipMaps:o}),this.coordinatesMode=e.Texture.INVCUBIC_MODE,this._textureMatrix=e.Matrix.Identity()):this._texture=n.getEngine().createRenderTargetTexture(r,{generateMipMaps:o,type:a}),this._renderingManager=new e.RenderingManager(n)}return __extends(i,t),Object.defineProperty(i,"REFRESHRATE_RENDERONCE",{get:function(){return i._REFRESHRATE_RENDERONCE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"REFRESHRATE_RENDERONEVERYFRAME",{get:function(){return i._REFRESHRATE_RENDERONEVERYFRAME},enumerable:!0,configurable:!0}),Object.defineProperty(i,"REFRESHRATE_RENDERONEVERYTWOFRAME",{get:function(){return i._REFRESHRATE_RENDERONEVERYTWOFRAME},enumerable:!0,configurable:!0}),i.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},Object.defineProperty(i.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),i.prototype._shouldRender=function(){return-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},i.prototype.isReady=function(){return!!this.getScene().renderTargetsEnabled&&t.prototype.isReady.call(this)},i.prototype.getRenderSize=function(){return this._size},Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this._size*e;this.resize(t,this._generateMipMaps)},i.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:t.prototype.getReflectionTextureMatrix.call(this)},i.prototype.resize=function(e,t){this.releaseInternalTexture(),this._texture=this.isCube?this.getScene().getEngine().createRenderTargetCubeTexture(e):this.getScene().getEngine().createRenderTargetTexture(e,t)},i.prototype.render=function(e,t){var i=this.getScene();if(this._waitingRenderList){this.renderList=[];for(var r=0;r<this._waitingRenderList.length;r++){var n=this._waitingRenderList[r];this.renderList.push(i.getMeshByID(n))}delete this._waitingRenderList}if(!this.renderList||0!==this.renderList.length){this._renderingManager.reset();for(var o=this.renderList?this.renderList:i.getActiveMeshes().data,s=0;s<o.length;s++){var a=o[s];if(a){if(!a.isReady()){this.resetRefreshCounter();continue}if(a.isEnabled()&&a.isVisible&&a.subMeshes&&0!=(a.layerMask&i.activeCamera.layerMask)){a._activate(i.getRenderId());for(var h=0;h<a.subMeshes.length;h++){var c=a.subMeshes[h];i._activeIndices+=c.indexCount,this._renderingManager.dispatch(c)}}}}if(this.isCube)for(var l=0;6>l;l++)this.renderToTarget(l,o,e,t);else this.renderToTarget(0,o,e,t);this.onAfterUnbind&&this.onAfterUnbind(),i.resetCachedMaterial()}},i.prototype.renderToTarget=function(t,i,r,n){var o=this.getScene(),s=o.getEngine();r&&o.postProcessManager._prepareFrame(this._texture)||(this.isCube?s.bindFramebuffer(this._texture,t):s.bindFramebuffer(this._texture)),this.onBeforeRender&&this.onBeforeRender(t),this.onClear?this.onClear(s):s.clear(o.clearColor,!0,!0),this._doNotChangeAspectRatio||o.updateTransformMatrix(!0),this._renderingManager.render(this.customRenderFunction,i,this.renderParticles,this.renderSprites),r&&o.postProcessManager._finalizeFrame(!1,this._texture,t),this._doNotChangeAspectRatio||o.updateTransformMatrix(!0),this.onAfterRender&&this.onAfterRender(t),n&&e.Tools.DumpFramebuffer(this._size,this._size,s),this.isCube&&5!==t||(this.isCube&&5===t&&s.generateMipMapsForCubemap(this._texture),s.unBindFramebuffer(this._texture,!0))},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t.renderList=this.renderList.slice(0),t},i._REFRESHRATE_RENDERONCE=0,i._REFRESHRATE_RENDERONEVERYFRAME=1,i._REFRESHRATE_RENDERONEVERYTWOFRAME=2,i}(e.Texture);e.RenderTargetTexture=t}(BABYLON||(BABYLON={})),function(e){var t=function(e){function t(t,i,r,n,o,s){void 0===s&&(s=!0),e.call(this,null,n,!s),this.isEnabled=!0,this._currentRefreshId=-1,this._refreshRate=1,this._vertexDeclaration=[2],this._vertexStrideSize=8,this._uniforms=new Array,this._samplers=new Array,this._textures=new Array,this._floats=new Array,this._floatsArrays={},this._colors3=new Array,this._colors4=new Array,this._vectors2=new Array,this._vectors3=new Array,this._matrices=new Array,this._fallbackTextureUsed=!1,n._proceduralTextures.push(this),this.name=t,this.isRenderTarget=!0,this._size=i,this._generateMipMaps=s,this.setFragment(r),this._fallbackTexture=o,this._texture=n.getEngine().createRenderTargetTexture(i,s);var a=[];a.push(1,1),a.push(-1,1),a.push(-1,-1),a.push(1,-1),this._vertexBuffer=n.getEngine().createVertexBuffer(a);var h=[];h.push(0),h.push(1),h.push(2),h.push(0),h.push(2),h.push(3),this._indexBuffer=n.getEngine().createIndexBuffer(h)}return __extends(t,e),t.prototype.reset=function(){void 0!==this._effect&&this.getScene().getEngine()._releaseEffect(this._effect)},t.prototype.isReady=function(){var e,t=this,i=this.getScene().getEngine();return!!this._fragment&&(!!this._fallbackTextureUsed||(e=void 0!==this._fragment.fragmentElement?{vertex:"procedural",fragmentElement:this._fragment.fragmentElement}:{vertex:"procedural",fragment:this._fragment},this._effect=i.createEffect(e,["position"],this._uniforms,this._samplers,"",null,null,function(){t.releaseInternalTexture(),t._fallbackTexture&&(t._texture=t._fallbackTexture._texture,t._texture.references++),t._fallbackTextureUsed=!0}),this._effect.isReady()))},t.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},t.prototype.setFragment=function(e){this._fragment=e},Object.defineProperty(t.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),t.prototype._shouldRender=function(){return!!(this.isEnabled&&this.isReady()&&this._texture)&&(!this._fallbackTextureUsed&&(-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)))},t.prototype.getRenderSize=function(){return this._size},t.prototype.resize=function(e,t){this._fallbackTextureUsed||(this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createRenderTargetTexture(e,t))},t.prototype._checkUniform=function(e){-1===this._uniforms.indexOf(e)&&this._uniforms.push(e)},t.prototype.setTexture=function(e,t){return-1===this._samplers.indexOf(e)&&this._samplers.push(e),this._textures[e]=t,this},t.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},t.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},t.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},t.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},t.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},t.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},t.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},t.prototype.render=function(e){var t=this.getScene(),i=t.getEngine();for(var r in i.bindFramebuffer(this._texture),i.clear(t.clearColor,!0,!0),i.enableEffect(this._effect),i.setState(!1),this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);i.bindBuffers(this._vertexBuffer,this._indexBuffer,this._vertexDeclaration,this._vertexStrideSize,this._effect),i.draw(!0,0,6),i.unBindFramebuffer(this._texture)},t.prototype.clone=function(){var e=this.getSize(),i=new t(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.coordinatesMode=this.coordinatesMode,i},t.prototype.dispose=function(){var t=this.getScene()._proceduralTextures.indexOf(this);t>=0&&this.getScene()._proceduralTextures.splice(t,1),e.prototype.dispose.call(this)},t}(e.Texture);e.ProceduralTexture=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o){var s=this;t.call(this,i,r,n,o,!0),this.mirrorPlane=new e.Plane(0,1,0,1),this._transformMatrix=e.Matrix.Zero(),this._mirrorMatrix=e.Matrix.Zero(),this.onBeforeRender=function(){e.Matrix.ReflectionToRef(s.mirrorPlane,s._mirrorMatrix),s._savedViewMatrix=n.getViewMatrix(),s._mirrorMatrix.multiplyToRef(s._savedViewMatrix,s._transformMatrix),n.setTransformMatrix(s._transformMatrix,n.getProjectionMatrix()),n.clipPlane=s.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.position,s._mirrorMatrix)},this.onAfterRender=function(){n.setTransformMatrix(s._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane}}return __extends(i,t),i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.mirrorPlane=this.mirrorPlane.clone(),t.renderList=this.renderList.slice(0),t},i}(e.RenderTargetTexture);e.MirrorTexture=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o,s){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE),t.call(this,null,n,!o),this.name=i,this.wrapU=e.Texture.CLAMP_ADDRESSMODE,this.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._generateMipMaps=o,r.getContext?(this._canvas=r,this._texture=n.getEngine().createDynamicTexture(r.width,r.height,o,s)):(this._canvas=document.createElement("canvas"),this._texture=r.width?n.getEngine().createDynamicTexture(r.width,r.height,o,s):n.getEngine().createDynamicTexture(r,r,o,s));var a=this.getSize();this._canvas.width=a.width,this._canvas.height=a.height,this._context=this._canvas.getContext("2d")}return __extends(i,t),Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._canvas.width=t.width,this._canvas.height=t.height,this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createDynamicTexture(t.width,t.height,this._generateMipMaps,this._samplingMode)},i.prototype.getContext=function(){return this._context},i.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},i.prototype.update=function(e){this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e)},i.prototype.drawText=function(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var h=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,h.width,h.height)),this._context.font=r,null===t){var c=this._context.measureText(e);t=(h.width-c.width)/2}this._context.fillStyle=n,this._context.fillText(e,t,i),a&&this.update(s)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t},i}(e.Texture);e.DynamicTexture=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o,s,a){var h=this;void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE),t.call(this,null,n,!o,s),this._autoLaunch=!0,this.name=i,this.video=document.createElement("video"),this.video.autoplay=!1,this.video.loop=!0,this.video.addEventListener("canplaythrough",function(){e.Tools.IsExponentOfTwo(h.video.videoWidth)&&e.Tools.IsExponentOfTwo(h.video.videoHeight)?(h.wrapU=e.Texture.WRAP_ADDRESSMODE,h.wrapV=e.Texture.WRAP_ADDRESSMODE):(h.wrapU=e.Texture.CLAMP_ADDRESSMODE,h.wrapV=e.Texture.CLAMP_ADDRESSMODE,o=!1),h._texture=n.getEngine().createDynamicTexture(h.video.videoWidth,h.video.videoHeight,o,a,!1),h._texture.isReady=!0}),r.forEach(function(e){var t=document.createElement("source");t.src=e,h.video.appendChild(t)}),this._lastUpdate=e.Tools.Now}return __extends(i,t),i.prototype.update=function(){this._autoLaunch&&(this._autoLaunch=!1,this.video.play());var t=e.Tools.Now;return!(t-this._lastUpdate<15||this.video.readyState!==this.video.HAVE_ENOUGH_DATA)&&(this._lastUpdate=t,this.getScene().getEngine().updateVideoTexture(this._texture,this.video,this._invertY),!0)},i}(e.Texture);e.VideoTexture=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(e,i,r,n,o,s){t.call(this,e,r,null,n,o,s),this._animate=!0,this._time=0,this._texturePath=i,this.loadJson(i),this.refreshRate=1}return __extends(i,t),i.prototype.loadJson=function(t){function i(){e.Tools.Log("No config file found in "+t+" trying to use ShadersStore or DOM element");try{n.setFragment(n._texturePath)}catch(t){e.Tools.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture")}}var r=this,n=this,o=t+"/config.json",s=new XMLHttpRequest;s.open("GET",o,!0),s.addEventListener("load",function(){if(200===s.status||e.Tools.ValidateXHRData(s,1))try{r._config=JSON.parse(s.response),r.updateShaderUniforms(),r.updateTextures(),r.setFragment(r._texturePath+"/custom"),r._animate=r._config.animate,r.refreshRate=r._config.refreshrate}catch(e){i()}else i()},!1),s.addEventListener("error",function(){i()},!1);try{s.send()}catch(t){e.Tools.Error("CustomProceduralTexture: Error on XHR send request.")}},i.prototype.isReady=function(){if(!t.prototype.isReady.call(this))return!1;for(var e in this._textures){if(!this._textures[e].isReady())return!1}return!0},i.prototype.render=function(e){this._animate&&(this._time+=.03*this.getScene().getAnimationRatio(),this.updateShaderUniforms()),t.prototype.render.call(this,e)},i.prototype.updateTextures=function(){for(var t=0;t<this._config.sampler2Ds.length;t++)this.setTexture(this._config.sampler2Ds[t].sample2Dname,new e.Texture(this._texturePath+"/"+this._config.sampler2Ds[t].textureRelativeUrl,this.getScene()))},i.prototype.updateShaderUniforms=function(){if(this._config)for(var t=0;t<this._config.uniforms.length;t++){var i=this._config.uniforms[t];switch(i.type){case"float":this.setFloat(i.name,i.value);break;case"color3":this.setColor3(i.name,new e.Color3(i.r,i.g,i.b));break;case"color4":this.setColor4(i.name,new e.Color4(i.r,i.g,i.b,i.a));break;case"vector2":this.setVector2(i.name,new e.Vector2(i.x,i.y));break;case"vector3":this.setVector3(i.name,new e.Vector3(i.x,i.y,i.z))}}this.setFloat("time",this._time)},Object.defineProperty(i.prototype,"animate",{get:function(){return this._animate},set:function(e){this._animate=e},enumerable:!0,configurable:!0}),i}(e.ProceduralTexture);e.CustomProceduralTexture=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o,s){t.call(this,i,r,"wood",n,o,s),this._ampScale=100,this._woodColor=new e.Color3(.32,.17,.09),this.updateShaderUniforms(),this.refreshRate=0}return __extends(i,t),i.prototype.updateShaderUniforms=function(){this.setFloat("ampScale",this._ampScale),this.setColor3("woodColor",this._woodColor)},Object.defineProperty(i.prototype,"ampScale",{get:function(){return this._ampScale},set:function(e){this._ampScale=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"woodColor",{get:function(){return this._woodColor},set:function(e){this._woodColor=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),i}(e.ProceduralTexture);e.WoodProceduralTexture=t;var i=function(t){function i(r,n,o,s,a){t.call(this,r,n,"fire",o,s,a),this._time=0,this._speed=new e.Vector2(.5,.3),this._autoGenerateTime=!0,this._alphaThreshold=.5,this._fireColors=i.RedFireColors,this.updateShaderUniforms(),this.refreshRate=1}return __extends(i,t),i.prototype.updateShaderUniforms=function(){this.setFloat("time",this._time),this.setVector2("speed",this._speed),this.setColor3("c1",this._fireColors[0]),this.setColor3("c2",this._fireColors[1]),this.setColor3("c3",this._fireColors[2]),this.setColor3("c4",this._fireColors[3]),this.setColor3("c5",this._fireColors[4]),this.setColor3("c6",this._fireColors[5]),this.setFloat("alphaThreshold",this._alphaThreshold)},i.prototype.render=function(e){this._autoGenerateTime&&(this._time+=.03*this.getScene().getAnimationRatio(),this.updateShaderUniforms()),t.prototype.render.call(this,e)},Object.defineProperty(i,"PurpleFireColors",{get:function(){return[new e.Color3(.5,0,1),new e.Color3(.9,0,1),new e.Color3(.2,0,1),new e.Color3(1,.9,1),new e.Color3(.1,.1,1),new e.Color3(.9,.9,1)]},enumerable:!0,configurable:!0}),Object.defineProperty(i,"GreenFireColors",{get:function(){return[new e.Color3(.5,1,0),new e.Color3(.5,1,0),new e.Color3(.3,.4,0),new e.Color3(.5,1,0),new e.Color3(.2,0,0),new e.Color3(.5,1,0)]},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RedFireColors",{get:function(){return[new e.Color3(.5,0,.1),new e.Color3(.9,0,0),new e.Color3(.2,0,0),new e.Color3(1,.9,0),new e.Color3(.1,.1,.1),new e.Color3(.9,.9,.9)]},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BlueFireColors",{get:function(){return[new e.Color3(.1,0,.5),new e.Color3(0,0,.5),new e.Color3(.1,0,.2),new e.Color3(0,0,1),new e.Color3(.1,.2,.3),new e.Color3(0,.2,.9)]},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fireColors",{get:function(){return this._fireColors},set:function(e){this._fireColors=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"time",{get:function(){return this._time},set:function(e){this._time=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"speed",{get:function(){return this._speed},set:function(e){this._speed=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"alphaThreshold",{get:function(){return this._alphaThreshold},set:function(e){this._alphaThreshold=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),i}(e.ProceduralTexture);e.FireProceduralTexture=i;var r=function(t){function i(i,r,n,o,s){t.call(this,i,r,"cloud",n,o,s),this._skyColor=new e.Color4(.15,.68,1,1),this._cloudColor=new e.Color4(1,1,1,1),this.updateShaderUniforms(),this.refreshRate=0}return __extends(i,t),i.prototype.updateShaderUniforms=function(){this.setColor4("skyColor",this._skyColor),this.setColor4("cloudColor",this._cloudColor)},Object.defineProperty(i.prototype,"skyColor",{get:function(){return this._skyColor},set:function(e){this._skyColor=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cloudColor",{get:function(){return this._cloudColor},set:function(e){this._cloudColor=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),i}(e.ProceduralTexture);e.CloudProceduralTexture=r;var n=function(t){function i(i,r,n,o,s){t.call(this,i,r,"grass",n,o,s),this._herb1=new e.Color3(.29,.38,.02),this._herb2=new e.Color3(.36,.49,.09),this._herb3=new e.Color3(.51,.6,.28),this._groundColor=new e.Color3(1,1,1),this._grassColors=[new e.Color3(.29,.38,.02),new e.Color3(.36,.49,.09),new e.Color3(.51,.6,.28)],this.updateShaderUniforms(),this.refreshRate=0}return __extends(i,t),i.prototype.updateShaderUniforms=function(){this.setColor3("herb1Color",this._grassColors[0]),this.setColor3("herb2Color",this._grassColors[1]),this.setColor3("herb3Color",this._grassColors[2]),this.setColor3("groundColor",this._groundColor)},Object.defineProperty(i.prototype,"grassColors",{get:function(){return this._grassColors},set:function(e){this._grassColors=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"groundColor",{get:function(){return this._groundColor},set:function(e){this.groundColor=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),i}(e.ProceduralTexture);e.GrassProceduralTexture=n;var o=function(t){function i(i,r,n,o,s){t.call(this,i,r,"road",n,o,s),this._roadColor=new e.Color3(.53,.53,.53),this.updateShaderUniforms(),this.refreshRate=0}return __extends(i,t),i.prototype.updateShaderUniforms=function(){this.setColor3("roadColor",this._roadColor)},Object.defineProperty(i.prototype,"roadColor",{get:function(){return this._roadColor},set:function(e){this._roadColor=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),i}(e.ProceduralTexture);e.RoadProceduralTexture=o;var s=function(t){function i(i,r,n,o,s){t.call(this,i,r,"brick",n,o,s),this._numberOfBricksHeight=15,this._numberOfBricksWidth=5,this._jointColor=new e.Color3(.72,.72,.72),this._brickColor=new e.Color3(.77,.47,.4),this.updateShaderUniforms(),this.refreshRate=0}return __extends(i,t),i.prototype.updateShaderUniforms=function(){this.setFloat("numberOfBricksHeight",this._numberOfBricksHeight),this.setFloat("numberOfBricksWidth",this._numberOfBricksWidth),this.setColor3("brickColor",this._brickColor),this.setColor3("jointColor",this._jointColor)},Object.defineProperty(i.prototype,"numberOfBricksHeight",{get:function(){return this._numberOfBricksHeight},set:function(e){this._numberOfBricksHeight=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"numberOfBricksWidth",{get:function(){return this._numberOfBricksWidth},set:function(e){this._numberOfBricksWidth=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"jointColor",{get:function(){return this._jointColor},set:function(e){this._jointColor=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"brickColor",{get:function(){return this._brickColor},set:function(e){this._brickColor=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),i}(e.ProceduralTexture);e.BrickProceduralTexture=s;var a=function(t){function i(i,r,n,o,s){t.call(this,i,r,"marble",n,o,s),this._numberOfTilesHeight=3,this._numberOfTilesWidth=3,this._amplitude=9,this._marbleColor=new e.Color3(.77,.47,.4),this._jointColor=new e.Color3(.72,.72,.72),this.updateShaderUniforms(),this.refreshRate=0}return __extends(i,t),i.prototype.updateShaderUniforms=function(){this.setFloat("numberOfTilesHeight",this._numberOfTilesHeight),this.setFloat("numberOfTilesWidth",this._numberOfTilesWidth),this.setFloat("amplitude",this._amplitude),this.setColor3("marbleColor",this._marbleColor),this.setColor3("jointColor",this._jointColor)},Object.defineProperty(i.prototype,"numberOfTilesHeight",{get:function(){return this._numberOfTilesHeight},set:function(e){this._numberOfTilesHeight=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"numberOfTilesWidth",{get:function(){return this._numberOfTilesWidth},set:function(e){this._numberOfTilesWidth=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"jointColor",{get:function(){return this._jointColor},set:function(e){this._jointColor=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"marbleColor",{get:function(){return this._marbleColor},set:function(e){this._marbleColor=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),i}(e.ProceduralTexture);e.MarbleProceduralTexture=a}(BABYLON||(BABYLON={})),function(e){var t=function(){function e(){this._defines={},this._currentRank=32,this._maxRank=-1}return e.prototype.addFallback=function(e,t){this._defines[e]||(e<this._currentRank&&(this._currentRank=e),e>this._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},Object.defineProperty(e.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e){for(var t=this._defines[this._currentRank],i=0;i<t.length;i++)e=e.replace("#define "+t[i],"");return this._currentRank++,e},e}();e.EffectFallbacks=t;var i=function(){function t(e,t,i,r,n,o,s,a,h){var c,l,u=this;this._isReady=!1,this._compilationError="",this._valueCache=[],this._engine=n,this.name=e,this.defines=o,this._uniformsNames=i.concat(r),this._samplers=r,this._attributesNames=t,this.onError=h,this.onCompiled=a,e.vertexElement?(c=document.getElementById(e.vertexElement))||(c=e.vertexElement):c=e.vertex||e,e.fragmentElement?(l=document.getElementById(e.fragmentElement))||(l=e.fragmentElement):l=e.fragment||e,this._loadVertexShader(c,function(e){u._loadFragmentShader(l,function(i){u._prepareEffect(e,i,t,o,s)})})}return t.prototype.isReady=function(){return this._isReady},t.prototype.getProgram=function(){return this._program},t.prototype.getAttributesNames=function(){return this._attributesNames},t.prototype.getAttributeLocation=function(e){return this._attributes[e]},t.prototype.getAttributeLocationByName=function(e){var t=this._attributesNames.indexOf(e);return this._attributes[t]},t.prototype.getAttributesCount=function(){return this._attributes.length},t.prototype.getUniformIndex=function(e){return this._uniformsNames.indexOf(e)},t.prototype.getUniform=function(e){return this._uniforms[this._uniformsNames.indexOf(e)]},t.prototype.getSamplers=function(){return this._samplers},t.prototype.getCompilationError=function(){return this._compilationError},t.prototype._loadVertexShader=function(i,r){var n;i instanceof HTMLElement?r(e.Tools.GetDOMTextContent(i)):t.ShadersStore[i+"VertexShader"]?r(t.ShadersStore[i+"VertexShader"]):(n="."===i[0]||"/"===i[0]?i:e.Engine.ShadersRepository+i,e.Tools.LoadFile(n+".vertex.fx",r))},t.prototype._loadFragmentShader=function(i,r){var n;i instanceof HTMLElement?r(e.Tools.GetDOMTextContent(i)):t.ShadersStore[i+"PixelShader"]?r(t.ShadersStore[i+"PixelShader"]):t.ShadersStore[i+"FragmentShader"]?r(t.ShadersStore[i+"FragmentShader"]):(n="."===i[0]||"/"===i[0]?i:e.Engine.ShadersRepository+i,e.Tools.LoadFile(n+".fragment.fx",r))},t.prototype._prepareEffect=function(t,i,r,n,o){try{var s=this._engine;s.getCaps().highPrecisionShaderSupported||(t=t.replace("precision highp float","precision mediump float"),i=i.replace("precision highp float","precision mediump float")),this._program=s.createShaderProgram(t,i,n),this._uniforms=s.getUniforms(this._program,this._uniformsNames),this._attributes=s.getAttributes(this._program,r);for(var a=0;a<this._samplers.length;a++){null==this.getUniform(this._samplers[a])&&(this._samplers.splice(a,1),a--)}s.bindSamplers(this),this._isReady=!0,this.onCompiled&&this.onCompiled(this)}catch(s){if(-1!==s.message.indexOf("highp"))return t=t.replace("precision highp float","precision mediump float"),i=i.replace("precision highp float","precision mediump float"),void this._prepareEffect(t,i,r,n,o);o&&o.isMoreFallbacks?(n=o.reduce(n),this._prepareEffect(t,i,r,n,o)):(e.Tools.Error("Unable to compile effect: "),this.name.vertexElement?(e.Tools.Error("Vertex shader:"+this.name.vertexElement),e.Tools.Error("Fragment shader:"+this.name.fragmentElement)):this.name.vertex?(e.Tools.Error("Vertex shader:"+this.name.vertex),e.Tools.Error("Fragment shader:"+this.name.fragment)):(e.Tools.Error("Vertex shader:"+this.name),e.Tools.Error("Fragment shader:"+this.name)),e.Tools.Error("Defines: "+n),e.Tools.Error("Error: "+s.message),this._compilationError=s.message,this.onError&&this.onError(this,this._compilationError))}},t.prototype._bindTexture=function(e,t){this._engine._bindTexture(this._samplers.indexOf(e),t)},t.prototype.setTexture=function(e,t){this._engine.setTexture(this._samplers.indexOf(e),t)},t.prototype.setTextureFromPostProcess=function(e,t){this._engine.setTextureFromPostProcess(this._samplers.indexOf(e),t)},t.prototype._cacheFloat2=function(e,t,i){return this._valueCache[e]?(this._valueCache[e][0]=t,void(this._valueCache[e][1]=i)):void(this._valueCache[e]=[t,i])},t.prototype._cacheFloat3=function(e,t,i,r){return this._valueCache[e]?(this._valueCache[e][0]=t,this._valueCache[e][1]=i,void(this._valueCache[e][2]=r)):void(this._valueCache[e]=[t,i,r])},t.prototype._cacheFloat4=function(e,t,i,r,n){return this._valueCache[e]?(this._valueCache[e][0]=t,this._valueCache[e][1]=i,this._valueCache[e][2]=r,void(this._valueCache[e][3]=n)):void(this._valueCache[e]=[t,i,r,n])},t.prototype.setArray=function(e,t){return this._engine.setArray(this.getUniform(e),t),this},t.prototype.setArray2=function(e,t){return this._engine.setArray2(this.getUniform(e),t),this},t.prototype.setArray3=function(e,t){return this._engine.setArray3(this.getUniform(e),t),this},t.prototype.setArray4=function(e,t){return this._engine.setArray4(this.getUniform(e),t),this},t.prototype.setMatrices=function(e,t){return this._engine.setMatrices(this.getUniform(e),t),this},t.prototype.setMatrix=function(e,t){return this._engine.setMatrix(this.getUniform(e),t),this},t.prototype.setMatrix3x3=function(e,t){return this._engine.setMatrix3x3(this.getUniform(e),t),this},t.prototype.setMatrix2x2=function(e,t){return this._engine.setMatrix2x2(this.getUniform(e),t),this},t.prototype.setFloat=function(e,t){return this._valueCache[e]&&this._valueCache[e]===t?this:(this._valueCache[e]=t,this._engine.setFloat(this.getUniform(e),t),this)},t.prototype.setBool=function(e,t){return this._valueCache[e]&&this._valueCache[e]===t?this:(this._valueCache[e]=t,this._engine.setBool(this.getUniform(e),t?1:0),this)},t.prototype.setVector2=function(e,t){return this._valueCache[e]&&this._valueCache[e][0]===t.x&&this._valueCache[e][1]===t.y?this:(this._cacheFloat2(e,t.x,t.y),this._engine.setFloat2(this.getUniform(e),t.x,t.y),this)},t.prototype.setFloat2=function(e,t,i){return this._valueCache[e]&&this._valueCache[e][0]===t&&this._valueCache[e][1]===i?this:(this._cacheFloat2(e,t,i),this._engine.setFloat2(this.getUniform(e),t,i),this)},t.prototype.setVector3=function(e,t){return this._valueCache[e]&&this._valueCache[e][0]===t.x&&this._valueCache[e][1]===t.y&&this._valueCache[e][2]===t.z?this:(this._cacheFloat3(e,t.x,t.y,t.z),this._engine.setFloat3(this.getUniform(e),t.x,t.y,t.z),this)},t.prototype.setFloat3=function(e,t,i,r){return this._valueCache[e]&&this._valueCache[e][0]===t&&this._valueCache[e][1]===i&&this._valueCache[e][2]===r?this:(this._cacheFloat3(e,t,i,r),this._engine.setFloat3(this.getUniform(e),t,i,r),this)},t.prototype.setVector4=function(e,t){return this._valueCache[e]&&this._valueCache[e][0]===t.x&&this._valueCache[e][1]===t.y&&this._valueCache[e][2]===t.z&&this._valueCache[e][3]===t.w?this:(this._cacheFloat4(e,t.x,t.y,t.z,t.w),this._engine.setFloat4(this.getUniform(e),t.x,t.y,t.z,t.w),this)},t.prototype.setFloat4=function(e,t,i,r,n){return this._valueCache[e]&&this._valueCache[e][0]===t&&this._valueCache[e][1]===i&&this._valueCache[e][2]===r&&this._valueCache[e][3]===n?this:(this._cacheFloat4(e,t,i,r,n),this._engine.setFloat4(this.getUniform(e),t,i,r,n),this)},t.prototype.setColor3=function(e,t){return this._valueCache[e]&&this._valueCache[e][0]===t.r&&this._valueCache[e][1]===t.g&&this._valueCache[e][2]===t.b?this:(this._cacheFloat3(e,t.r,t.g,t.b),this._engine.setColor3(this.getUniform(e),t),this)},t.prototype.setColor4=function(e,t,i){return this._valueCache[e]&&this._valueCache[e][0]===t.r&&this._valueCache[e][1]===t.g&&this._valueCache[e][2]===t.b&&this._valueCache[e][3]===i?this:(this._cacheFloat4(e,t.r,t.g,t.b,i),this._engine.setColor4(this.getUniform(e),t,i),this)},t.ShadersStore={},t}();e.Effect=i}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(i,r,n){this.name=i,this.checkReadyOnEveryCall=!0,this.checkReadyOnlyOnce=!1,this.state="",this.alpha=1,this.backFaceCulling=!0,this.sideOrientation=t.CounterClockWiseSideOrientation,this.alphaMode=e.Engine.ALPHA_COMBINE,this.disableDepthWrite=!1,this.fogEnabled=!0,this._wasPreviouslyReady=!1,this._fillMode=t.TriangleFillMode,this.pointSize=1,this.zOffset=0,this.id=i,this._scene=r,n||r.materials.push(this)}return Object.defineProperty(t,"TriangleFillMode",{get:function(){return t._TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WireFrameFillMode",{get:function(){return t._WireFrameFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointFillMode",{get:function(){return t._PointFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ClockWiseSideOrientation",{get:function(){return t._ClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"CounterClockWiseSideOrientation",{get:function(){return t._CounterClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wireframe",{get:function(){return this._fillMode===t.WireFrameFillMode},set:function(e){this._fillMode=e?t.WireFrameFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pointsCloud",{get:function(){return this._fillMode===t.PointFillMode},set:function(e){this._fillMode=e?t.PointFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fillMode",{get:function(){return this._fillMode},set:function(e){this._fillMode=e},enumerable:!0,configurable:!0}),t.prototype.isReady=function(e,t){return!0},t.prototype.getEffect=function(){return this._effect},t.prototype.getScene=function(){return this._scene},t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.trackCreation=function(e,t){},t.prototype._preBind=function(){var e=this._scene.getEngine();e.enableEffect(this._effect),e.setState(this.backFaceCulling,this.zOffset,!1,this.sideOrientation===t.ClockWiseSideOrientation)},t.prototype.bind=function(e,t){if(this._scene._cachedMaterial=this,this.onBind&&this.onBind(this,t),this.disableDepthWrite){var i=this._scene.getEngine();this._cachedDepthWriteState=i.getDepthWrite(),i.setDepthWrite(!1)}},t.prototype.bindOnlyWorldMatrix=function(e){},t.prototype.unbind=function(){this.disableDepthWrite&&this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState)},t.prototype.clone=function(e){return null},t.prototype.getBindedMeshes=function(){for(var e=new Array,t=0;t<this._scene.meshes.length;t++){var i=this._scene.meshes[t];i.material===this&&e.push(i)}return e},t.prototype.dispose=function(e){var t=this._scene.materials.indexOf(this);for(t>=0&&this._scene.materials.splice(t,1),e&&this._effect&&(this._scene.getEngine()._releaseEffect(this._effect),this._effect=null),t=0;t<this._scene.meshes.length;t++){var i=this._scene.meshes[t];i.material===this&&(i.material=null)}this.onDispose&&this.onDispose()},t.prototype.copyTo=function(e){e.checkReadyOnlyOnce=this.checkReadyOnlyOnce,e.checkReadyOnEveryCall=this.checkReadyOnEveryCall,e.alpha=this.alpha,e.fillMode=this.fillMode,e.backFaceCulling=this.backFaceCulling,e.wireframe=this.wireframe,e.fogEnabled=this.fogEnabled,e.wireframe=this.wireframe,e.zOffset=this.zOffset,e.alphaMode=this.alphaMode,e.sideOrientation=this.sideOrientation,e.disableDepthWrite=this.disableDepthWrite,e.pointSize=this.pointSize,e.pointsCloud=this.pointsCloud},t._TriangleFillMode=0,t._WireFrameFillMode=1,t._PointFillMode=2,t._ClockWiseSideOrientation=0,t._CounterClockWiseSideOrientation=1,t}();e.Material=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(){this.isEnabled=!0,this.leftColor=e.Color3.White(),this.rightColor=e.Color3.Black(),this.bias=0,this.power=1}return t.prototype.clone=function(){var i=new t;return e.Tools.DeepCopy(this,i),new t},t}();e.FresnelParameters=t;var i=function(){function e(){this.DIFFUSE=!1,this.AMBIENT=!1,this.OPACITY=!1,this.OPACITYRGB=!1,this.REFLECTION=!1,this.EMISSIVE=!1,this.SPECULAR=!1,this.BUMP=!1,this.SPECULAROVERALPHA=!1,this.CLIPPLANE=!1,this.ALPHATEST=!1,this.ALPHAFROMDIFFUSE=!1,this.POINTSIZE=!1,this.FOG=!1,this.LIGHT0=!1,this.LIGHT1=!1,this.LIGHT2=!1,this.LIGHT3=!1,this.SPOTLIGHT0=!1,this.SPOTLIGHT1=!1,this.SPOTLIGHT2=!1,this.SPOTLIGHT3=!1,this.HEMILIGHT0=!1,this.HEMILIGHT1=!1,this.HEMILIGHT2=!1,this.HEMILIGHT3=!1,this.POINTDIRLIGHT0=!1,this.POINTDIRLIGHT1=!1,this.POINTDIRLIGHT2=!1,this.POINTDIRLIGHT3=!1,this.SPECULARTERM=!1,this.SHADOW0=!1,this.SHADOW1=!1,this.SHADOW2=!1,this.SHADOW3=!1,this.SHADOWS=!1,this.SHADOWVSM0=!1,this.SHADOWVSM1=!1,this.SHADOWVSM2=!1,this.SHADOWVSM3=!1,this.SHADOWPCF0=!1,this.SHADOWPCF1=!1,this.SHADOWPCF2=!1,this.SHADOWPCF3=!1,this.DIFFUSEFRESNEL=!1,this.OPACITYFRESNEL=!1,this.REFLECTIONFRESNEL=!1,this.EMISSIVEFRESNEL=!1,this.FRESNEL=!1,this.NORMAL=!1,this.UV1=!1,this.UV2=!1,this.VERTEXCOLOR=!1,this.VERTEXALPHA=!1,this.BONES=!1,this.BONES4=!1,this.BonesPerMesh=0,this.INSTANCES=!1,this.GLOSSINESS=!1,this.ROUGHNESS=!1,this.EMISSIVEASILLUMINATION=!1,this.REFLECTIONFRESNELFROMSPECULAR=!1,this.LIGHTMAP=!1,this.REFLECTIONMAP_3D=!1,this.REFLECTIONMAP_SPHERICAL=!1,this.REFLECTIONMAP_PLANAR=!1,this.REFLECTIONMAP_CUBIC=!1,this.REFLECTIONMAP_PROJECTION=!1,this.REFLECTIONMAP_SKYBOX=!1,this.REFLECTIONMAP_EXPLICIT=!1,this.INVERTCUBICMAP=!1,this._keys=Object.keys(this)}return e.prototype.isEqual=function(e){for(var t=0;t<this._keys.length;t++){var i=this._keys[t];if(this[i]!==e[i])return!1}return!0},e.prototype.cloneTo=function(e){for(var t=0;t<this._keys.length;t++){var i=this._keys[t];e[i]=this[i]}},e.prototype.reset=function(){for(var e=0;e<this._keys.length;e++){var t=this._keys[e];this[t]="BonesPerMesh"===t&&0}},e.prototype.toString=function(){for(var e="",t=0;t<this._keys.length;t++){var i=this._keys[t];"BonesPerMesh"===i&&this[i]>0?e+="#define BonesPerMesh "+this[i]+"\n":this[i]&&(e+="#define "+i+"\n")}return e},e}(),r=function(t){function r(r,n){var o=this;t.call(this,r,n),this.ambientColor=new e.Color3(0,0,0),this.diffuseColor=new e.Color3(1,1,1),this.specularColor=new e.Color3(1,1,1),this.specularPower=64,this.emissiveColor=new e.Color3(0,0,0),this.useAlphaFromDiffuseTexture=!1,this.useEmissiveAsIllumination=!1,this.useReflectionFresnelFromSpecular=!1,this.useSpecularOverAlpha=!0,this.disableLighting=!1,this.roughness=0,this.lightmapThreshold=0,this.useGlossinessFromSpecularMapAlpha=!1,this._renderTargets=new e.SmartArray(16),this._worldViewProjectionMatrix=e.Matrix.Zero(),this._globalAmbientColor=new e.Color3(0,0,0),this._scaledDiffuse=new e.Color3,this._scaledSpecular=new e.Color3,this._defines=new i,this._cachedDefines=new i,this._cachedDefines.BonesPerMesh=-1,this.getRenderTargetTextures=function(){return o._renderTargets.reset(),o.reflectionTexture&&o.reflectionTexture.isRenderTarget&&o._renderTargets.push(o.reflectionTexture),o._renderTargets}}return __extends(r,t),r.prototype.needAlphaBlending=function(){return this.alpha<1||null!=this.opacityTexture||this._shouldUseAlphaFromDiffuseTexture()||this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled},r.prototype.needAlphaTesting=function(){return null!=this.diffuseTexture&&this.diffuseTexture.hasAlpha},r.prototype._shouldUseAlphaFromDiffuseTexture=function(){return null!=this.diffuseTexture&&this.diffuseTexture.hasAlpha&&this.useAlphaFromDiffuseTexture},r.prototype.getAlphaTestTexture=function(){return this.diffuseTexture},r.prototype.isReady=function(t,i){if(this.checkReadyOnlyOnce&&this._wasPreviouslyReady)return!0;var n=this.getScene();if(!this.checkReadyOnEveryCall&&this._renderId===n.getRenderId())return!0;var o=n.getEngine(),s=!1,a=!1;if(this._defines.reset(),n.texturesEnabled){if(this.diffuseTexture&&r.DiffuseTextureEnabled){if(!this.diffuseTexture.isReady())return!1;a=!0,this._defines.DIFFUSE=!0}if(this.ambientTexture&&r.AmbientTextureEnabled){if(!this.ambientTexture.isReady())return!1;a=!0,this._defines.AMBIENT=!0}if(this.opacityTexture&&r.OpacityTextureEnabled){if(!this.opacityTexture.isReady())return!1;a=!0,this._defines.OPACITY=!0,this.opacityTexture.getAlphaFromRGB&&(this._defines.OPACITYRGB=!0)}if(this.reflectionTexture&&r.ReflectionTextureEnabled){if(!this.reflectionTexture.isReady())return!1;switch(s=!0,this._defines.REFLECTION=!0,this.roughness>0&&(this._defines.ROUGHNESS=!0),this.reflectionTexture.coordinatesMode===e.Texture.INVCUBIC_MODE&&(this._defines.INVERTCUBICMAP=!0),this._defines.REFLECTIONMAP_3D=this.reflectionTexture.isCube,this.reflectionTexture.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:this._defines.REFLECTIONMAP_CUBIC=!0;break;case e.Texture.EXPLICIT_MODE:this._defines.REFLECTIONMAP_EXPLICIT=!0;break;case e.Texture.PLANAR_MODE:this._defines.REFLECTIONMAP_PLANAR=!0;break;case e.Texture.PROJECTION_MODE:this._defines.REFLECTIONMAP_PROJECTION=!0;break;case e.Texture.SKYBOX_MODE:this._defines.REFLECTIONMAP_SKYBOX=!0;break;case e.Texture.SPHERICAL_MODE:this._defines.REFLECTIONMAP_SPHERICAL=!0}}if(this.emissiveTexture&&r.EmissiveTextureEnabled){if(!this.emissiveTexture.isReady())return!1;a=!0,this._defines.EMISSIVE=!0}if(this.lightmapTexture&&r.LightmapEnabled){if(!this.lightmapTexture.isReady())return!1;a=!0,this._defines.LIGHTMAP=!0}if(this.specularTexture&&r.SpecularTextureEnabled){if(!this.specularTexture.isReady())return!1;a=!0,this._defines.SPECULAR=!0,this._defines.GLOSSINESS=this.useGlossinessFromSpecularMapAlpha}}if(n.getEngine().getCaps().standardDerivatives&&this.bumpTexture&&r.BumpTextureEnabled){if(!this.bumpTexture.isReady())return!1;a=!0,this._defines.BUMP=!0}n.clipPlane&&(this._defines.CLIPPLANE=!0),o.getAlphaTesting()&&(this._defines.ALPHATEST=!0),this._shouldUseAlphaFromDiffuseTexture()&&(this._defines.ALPHAFROMDIFFUSE=!0),this.useEmissiveAsIllumination&&(this._defines.EMISSIVEASILLUMINATION=!0),this.useReflectionFresnelFromSpecular&&(this._defines.REFLECTIONFRESNELFROMSPECULAR=!0),(this.pointsCloud||n.forcePointsCloud)&&(this._defines.POINTSIZE=!0),n.fogEnabled&&t&&t.applyFog&&n.fogMode!==e.Scene.FOGMODE_NONE&&this.fogEnabled&&(this._defines.FOG=!0);var h=0;if(n.lightsEnabled&&!this.disableLighting)for(var c=0;c<n.lights.length;c++){var l=n.lights[c];if(l.isEnabled()){if(l._excludedMeshesIds.length>0){for(var u=0;u<l._excludedMeshesIds.length;u++){var d=n.getMeshByID(l._excludedMeshesIds[u]);d&&l.excludedMeshes.push(d)}l._excludedMeshesIds=[]}if(l._includedOnlyMeshesIds.length>0){for(var f=0;f<l._includedOnlyMeshesIds.length;f++){var p=n.getMeshByID(l._includedOnlyMeshesIds[f]);p&&l.includedOnlyMeshes.push(p)}l._includedOnlyMeshesIds=[]}if(l.canAffectMesh(t)){var m;if(s=!0,this._defines["LIGHT"+h]=!0,m=l instanceof e.SpotLight?"SPOTLIGHT"+h:l instanceof e.HemisphericLight?"HEMILIGHT"+h:"POINTDIRLIGHT"+h,this._defines[m]=!0,l.specular.equalsFloats(0,0,0)||(this._defines.SPECULARTERM=!0),n.shadowsEnabled){var g=l.getShadowGenerator();t&&t.receiveShadows&&g&&(this._defines["SHADOW"+h]=!0,this._defines.SHADOWS=!0,(g.useVarianceShadowMap||g.useBlurVarianceShadowMap)&&(this._defines["SHADOWVSM"+h]=!0),g.usePoissonSampling&&(this._defines["SHADOWPCF"+h]=!0))}if(4===++h)break}}}if(r.FresnelEnabled&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled||this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled||this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled||this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled)&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(this._defines.DIFFUSEFRESNEL=!0),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&(this._defines.OPACITYFRESNEL=!0),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(this._defines.REFLECTIONFRESNEL=!0),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._defines.EMISSIVEFRESNEL=!0),s=!0,this._defines.FRESNEL=!0),this._defines.SPECULARTERM&&this.useSpecularOverAlpha&&(this._defines.SPECULAROVERALPHA=!0),t&&(s&&t.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&(this._defines.NORMAL=!0),a&&(t.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(this._defines.UV1=!0),t.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(this._defines.UV2=!0)),t.useVertexColors&&t.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(this._defines.VERTEXCOLOR=!0,t.hasVertexAlpha&&(this._defines.VERTEXALPHA=!0)),t.useBones&&t.computeBonesUsingShaders&&(this._defines.BONES=!0,this._defines.BonesPerMesh=t.skeleton.bones.length+1,this._defines.BONES4=!0),i&&(this._defines.INSTANCES=!0)),!this._defines.isEqual(this._cachedDefines)){this._defines.cloneTo(this._cachedDefines),n.resetCachedMaterial();var v=new e.EffectFallbacks;for(this._defines.REFLECTION&&v.addFallback(0,"REFLECTION"),this._defines.SPECULAR&&v.addFallback(0,"SPECULAR"),this._defines.BUMP&&v.addFallback(0,"BUMP"),this._defines.SPECULAROVERALPHA&&v.addFallback(0,"SPECULAROVERALPHA"),this._defines.FOG&&v.addFallback(1,"FOG"),h=0;4>h;h++)this._defines["LIGHT"+h]&&(h>0&&v.addFallback(h,"LIGHT"+h),this._defines["SHADOW"+h]&&v.addFallback(0,"SHADOW"+h),this._defines["SHADOWPCF"+h]&&v.addFallback(0,"SHADOWPCF"+h),this._defines["SHADOWVSM"+h]&&v.addFallback(0,"SHADOWVSM"+h));this._defines.SPECULARTERM&&v.addFallback(0,"SPECULARTERM"),this._defines.DIFFUSEFRESNEL&&v.addFallback(1,"DIFFUSEFRESNEL"),this._defines.OPACITYFRESNEL&&v.addFallback(2,"OPACITYFRESNEL"),this._defines.REFLECTIONFRESNEL&&v.addFallback(3,"REFLECTIONFRESNEL"),this._defines.EMISSIVEFRESNEL&&v.addFallback(4,"EMISSIVEFRESNEL"),this._defines.FRESNEL&&v.addFallback(4,"FRESNEL"),this._defines.BONES4&&v.addFallback(0,"BONES4");var _=[e.VertexBuffer.PositionKind];this._defines.NORMAL&&_.push(e.VertexBuffer.NormalKind),this._defines.UV1&&_.push(e.VertexBuffer.UVKind),this._defines.UV2&&_.push(e.VertexBuffer.UV2Kind),this._defines.VERTEXCOLOR&&_.push(e.VertexBuffer.ColorKind),this._defines.BONES&&(_.push(e.VertexBuffer.MatricesIndicesKind),_.push(e.VertexBuffer.MatricesWeightsKind)),this._defines.INSTANCES&&(_.push("world0"),_.push("world1"),_.push("world2"),_.push("world3"));var y="default";n.getEngine().getCaps().standardDerivatives||(y="legacydefault");var x=this._defines.toString();this._effect=n.getEngine().createEffect(y,_,["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","vLightData0","vLightDiffuse0","vLightSpecular0","vLightDirection0","vLightGround0","lightMatrix0","vLightData1","vLightDiffuse1","vLightSpecular1","vLightDirection1","vLightGround1","lightMatrix1","vLightData2","vLightDiffuse2","vLightSpecular2","vLightDirection2","vLightGround2","lightMatrix2","vLightData3","vLightDiffuse3","vLightSpecular3","vLightDirection3","vLightGround3","lightMatrix3","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","mBones","vClipPlane","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","lightmapMatrix","shadowsInfo0","shadowsInfo1","shadowsInfo2","shadowsInfo3","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor"],["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","shadowSampler0","shadowSampler1","shadowSampler2","shadowSampler3"],x,v,this.onCompiled,this.onError)}return!!this._effect.isReady()&&(this._renderId=n.getRenderId(),this._wasPreviouslyReady=!0,!0)},r.prototype.unbind=function(){this.reflectionTexture&&this.reflectionTexture.isRenderTarget&&this._effect.setTexture("reflection2DSampler",null),t.prototype.unbind.call(this)},r.prototype.bindOnlyWorldMatrix=function(e){this._effect.setMatrix("world",e)},r.prototype.bind=function(i,n){var o=this.getScene();if(this.bindOnlyWorldMatrix(i),this._effect.setMatrix("viewProjection",o.getTransformMatrix()),n&&n.useBones&&n.computeBonesUsingShaders&&this._effect.setMatrices("mBones",n.skeleton.getTransformMatrices()),o.getCachedMaterial()!==this){if(r.FresnelEnabled&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(this._effect.setColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),this._effect.setColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&this._effect.setColor4("opacityParts",new e.Color3(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(this._effect.setColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),this._effect.setColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._effect.setColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),this._effect.setColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),this.diffuseTexture&&r.DiffuseTextureEnabled&&(this._effect.setTexture("diffuseSampler",this.diffuseTexture),this._effect.setFloat2("vDiffuseInfos",this.diffuseTexture.coordinatesIndex,this.diffuseTexture.level),this._effect.setMatrix("diffuseMatrix",this.diffuseTexture.getTextureMatrix())),this.ambientTexture&&r.AmbientTextureEnabled&&(this._effect.setTexture("ambientSampler",this.ambientTexture),this._effect.setFloat2("vAmbientInfos",this.ambientTexture.coordinatesIndex,this.ambientTexture.level),this._effect.setMatrix("ambientMatrix",this.ambientTexture.getTextureMatrix())),this.opacityTexture&&r.OpacityTextureEnabled&&(this._effect.setTexture("opacitySampler",this.opacityTexture),this._effect.setFloat2("vOpacityInfos",this.opacityTexture.coordinatesIndex,this.opacityTexture.level),this._effect.setMatrix("opacityMatrix",this.opacityTexture.getTextureMatrix())),this.reflectionTexture&&r.ReflectionTextureEnabled&&(this.reflectionTexture.isCube?this._effect.setTexture("reflectionCubeSampler",this.reflectionTexture):this._effect.setTexture("reflection2DSampler",this.reflectionTexture),this._effect.setMatrix("reflectionMatrix",this.reflectionTexture.getReflectionTextureMatrix()),this._effect.setFloat2("vReflectionInfos",this.reflectionTexture.level,this.roughness)),this.emissiveTexture&&r.EmissiveTextureEnabled&&(this._effect.setTexture("emissiveSampler",this.emissiveTexture),this._effect.setFloat2("vEmissiveInfos",this.emissiveTexture.coordinatesIndex,this.emissiveTexture.level),this._effect.setMatrix("emissiveMatrix",this.emissiveTexture.getTextureMatrix())),this.lightmapTexture&&r.LightmapEnabled&&(this._effect.setTexture("lightmapSampler",this.lightmapTexture),this._effect.setFloat3("vLightmapInfos",this.lightmapTexture.coordinatesIndex,this.lightmapTexture.level,this.lightmapThreshold),this._effect.setMatrix("lightmapMatrix",this.lightmapTexture.getTextureMatrix())),this.specularTexture&&r.SpecularTextureEnabled&&(this._effect.setTexture("specularSampler",this.specularTexture),this._effect.setFloat2("vSpecularInfos",this.specularTexture.coordinatesIndex,this.specularTexture.level),this._effect.setMatrix("specularMatrix",this.specularTexture.getTextureMatrix())),this.bumpTexture&&o.getEngine().getCaps().standardDerivatives&&r.BumpTextureEnabled&&(this._effect.setTexture("bumpSampler",this.bumpTexture),this._effect.setFloat2("vBumpInfos",this.bumpTexture.coordinatesIndex,1/this.bumpTexture.level),this._effect.setMatrix("bumpMatrix",this.bumpTexture.getTextureMatrix())),o.clipPlane){var s=o.clipPlane;this._effect.setFloat4("vClipPlane",s.normal.x,s.normal.y,s.normal.z,s.d)}this.pointsCloud&&this._effect.setFloat("pointSize",this.pointSize),o.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),this._scaledSpecular.r=this.specularColor.r*e.Tools.Clamp(1-this.emissiveColor.r),this._scaledSpecular.g=this.specularColor.g*e.Tools.Clamp(1-this.emissiveColor.g),this._scaledSpecular.b=this.specularColor.b*e.Tools.Clamp(1-this.emissiveColor.b),this._effect.setVector3("vEyePosition",o._mirroredCameraPosition?o._mirroredCameraPosition:o.activeCamera.position),this._effect.setColor3("vAmbientColor",this._globalAmbientColor),this._defines.SPECULARTERM&&this._effect.setColor4("vSpecularColor",this._scaledSpecular,this.specularPower),this._effect.setColor3("vEmissiveColor",this.emissiveColor)}if(this._scaledDiffuse.r=this.diffuseColor.r*e.Tools.Clamp(1-this.emissiveColor.r),this._scaledDiffuse.g=this.diffuseColor.g*e.Tools.Clamp(1-this.emissiveColor.g),this._scaledDiffuse.b=this.diffuseColor.b*e.Tools.Clamp(1-this.emissiveColor.b),this._effect.setColor4("vDiffuseColor",this._scaledDiffuse,this.alpha*n.visibility),o.lightsEnabled&&!this.disableLighting)for(var a=0,h=0;h<o.lights.length;h++){var c=o.lights[h];if(c.isEnabled()&&c.canAffectMesh(n)){if(c instanceof e.PointLight?c.transferToEffect(this._effect,"vLightData"+a):c instanceof e.DirectionalLight?c.transferToEffect(this._effect,"vLightData"+a):c instanceof e.SpotLight?c.transferToEffect(this._effect,"vLightData"+a,"vLightDirection"+a):c instanceof e.HemisphericLight&&c.transferToEffect(this._effect,"vLightData"+a,"vLightGround"+a),c.diffuse.scaleToRef(c.intensity,this._scaledDiffuse),this._effect.setColor4("vLightDiffuse"+a,this._scaledDiffuse,c.range),this._defines.SPECULARTERM&&(c.specular.scaleToRef(c.intensity,this._scaledSpecular),this._effect.setColor3("vLightSpecular"+a,this._scaledSpecular)),o.shadowsEnabled){var l=c.getShadowGenerator();n.receiveShadows&&l&&(this._effect.setMatrix("lightMatrix"+a,l.getTransformMatrix()),this._effect.setTexture("shadowSampler"+a,l.getShadowMapForRendering()),this._effect.setFloat3("shadowsInfo"+a,l.getDarkness(),l.getShadowMap().getSize().width,l.bias))}if(4===++a)break}}(o.fogEnabled&&n.applyFog&&o.fogMode!==e.Scene.FOGMODE_NONE||this.reflectionTexture)&&this._effect.setMatrix("view",o.getViewMatrix()),o.fogEnabled&&n.applyFog&&o.fogMode!==e.Scene.FOGMODE_NONE&&(this._effect.setFloat4("vFogInfos",o.fogMode,o.fogStart,o.fogEnd,o.fogDensity),this._effect.setColor3("vFogColor",o.fogColor)),t.prototype.bind.call(this,i,n)},r.prototype.getAnimatables=function(){var e=[];return this.diffuseTexture&&this.diffuseTexture.animations&&this.diffuseTexture.animations.length>0&&e.push(this.diffuseTexture),this.ambientTexture&&this.ambientTexture.animations&&this.ambientTexture.animations.length>0&&e.push(this.ambientTexture),this.opacityTexture&&this.opacityTexture.animations&&this.opacityTexture.animations.length>0&&e.push(this.opacityTexture),this.reflectionTexture&&this.reflectionTexture.animations&&this.reflectionTexture.animations.length>0&&e.push(this.reflectionTexture),this.emissiveTexture&&this.emissiveTexture.animations&&this.emissiveTexture.animations.length>0&&e.push(this.emissiveTexture),this.specularTexture&&this.specularTexture.animations&&this.specularTexture.animations.length>0&&e.push(this.specularTexture),this.bumpTexture&&this.bumpTexture.animations&&this.bumpTexture.animations.length>0&&e.push(this.bumpTexture),e},r.prototype.dispose=function(e){this.diffuseTexture&&this.diffuseTexture.dispose(),this.ambientTexture&&this.ambientTexture.dispose(),this.opacityTexture&&this.opacityTexture.dispose(),this.reflectionTexture&&this.reflectionTexture.dispose(),this.emissiveTexture&&this.emissiveTexture.dispose(),this.specularTexture&&this.specularTexture.dispose(),this.bumpTexture&&this.bumpTexture.dispose(),t.prototype.dispose.call(this,e)},r.prototype.clone=function(e){var t=new r(e,this.getScene());return this.copyTo(t),this.diffuseTexture&&this.diffuseTexture.clone&&(t.diffuseTexture=this.diffuseTexture.clone()),this.ambientTexture&&this.ambientTexture.clone&&(t.ambientTexture=this.ambientTexture.clone()),this.opacityTexture&&this.opacityTexture.clone&&(t.opacityTexture=this.opacityTexture.clone()),this.reflectionTexture&&this.reflectionTexture.clone&&(t.reflectionTexture=this.reflectionTexture.clone()),this.emissiveTexture&&this.emissiveTexture.clone&&(t.emissiveTexture=this.emissiveTexture.clone()),this.specularTexture&&this.specularTexture.clone&&(t.specularTexture=this.specularTexture.clone()),this.bumpTexture&&this.bumpTexture.clone&&(t.bumpTexture=this.bumpTexture.clone()),this.lightmapTexture&&this.lightmapTexture.clone&&(t.bumpTexture=this.bumpTexture.clone(),t.lightmapTexture=this.lightmapTexture.clone(),t.lightmapThreshold=this.lightmapThreshold),t.ambientColor=this.ambientColor.clone(),t.diffuseColor=this.diffuseColor.clone(),t.specularColor=this.specularColor.clone(),t.specularPower=this.specularPower,t.emissiveColor=this.emissiveColor.clone(),t.useAlphaFromDiffuseTexture=this.useAlphaFromDiffuseTexture,t.useEmissiveAsIllumination=this.useEmissiveAsIllumination,t.useGlossinessFromSpecularMapAlpha=this.useGlossinessFromSpecularMapAlpha,t.useReflectionFresnelFromSpecular=this.useReflectionFresnelFromSpecular,t.useSpecularOverAlpha=this.useSpecularOverAlpha,t.roughness=this.roughness,this.diffuseFresnelParameters&&this.diffuseFresnelParameters.clone&&(t.diffuseFresnelParameters=this.diffuseFresnelParameters.clone()),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.clone&&(t.emissiveFresnelParameters=this.emissiveFresnelParameters.clone()),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.clone&&(t.reflectionFresnelParameters=this.reflectionFresnelParameters.clone()),this.opacityFresnelParameters&&this.opacityFresnelParameters.clone&&(t.opacityFresnelParameters=this.opacityFresnelParameters.clone()),t},r.DiffuseTextureEnabled=!0,r.AmbientTextureEnabled=!0,r.OpacityTextureEnabled=!0,r.ReflectionTextureEnabled=!0,r.EmissiveTextureEnabled=!0,r.SpecularTextureEnabled=!0,r.BumpTextureEnabled=!0,r.FresnelEnabled=!0,r.LightmapEnabled=!0,r}(e.Material);e.StandardMaterial=r}(BABYLON||(BABYLON={})),function(e){var t=function(e){function t(t,i){e.call(this,t,i,!0),this.subMaterials=new Array,i.multiMaterials.push(this)}return __extends(t,e),t.prototype.getSubMaterial=function(e){return 0>e||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},t.prototype.isReady=function(e){for(var t=0;t<this.subMaterials.length;t++){if(this.subMaterials[t]&&!this.subMaterials[t].isReady(e))return!1}return!0},t.prototype.clone=function(e){for(var i=new t(e,this.getScene()),r=0;r<this.subMaterials.length;r++){var n=this.subMaterials[r];i.subMaterials.push(n)}return i},t}(e.Material);e.MultiMaterial=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(){}return Object.defineProperty(t,"ForceFullSceneLoadingForIncremental",{get:function(){return t._ForceFullSceneLoadingForIncremental},set:function(e){t._ForceFullSceneLoadingForIncremental=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ShowLoadingScreen",{get:function(){return t._ShowLoadingScreen},set:function(e){t._ShowLoadingScreen=e},enumerable:!0,configurable:!0}),t._getPluginForFilename=function(e){var t=e.lastIndexOf("."),i=e.indexOf("?");-1===i&&(i=e.length);for(var r=e.substring(t,i).toLowerCase(),n=0;n<this._registeredPlugins.length;n++){var o=this._registeredPlugins[n];if(-1!==o.extensions.indexOf(r))return o}return this._registeredPlugins[this._registeredPlugins.length-1]},t.RegisterPlugin=function(e){e.extensions=e.extensions.toLowerCase(),t._registeredPlugins.push(e)},t.ImportMesh=function(i,r,n,o,s,a,h){if(n.substr&&"/"===n.substr(0,1))e.Tools.Error("Wrong sceneFilename parameter");else{var c={};o._addPendingData(c);var l=function(l){o.database=u;var d=t._getPluginForFilename(n),f=function(e){var t=[],a=[],l=[];try{if(!d.importMesh(i,o,e,r,t,a,l))return h&&h(o,"Unable to import meshes from "+r+n),void o._removePendingData(c)}catch(e){return h&&h(o,"Unable to import meshes from "+r+n+" (Exception: "+e+")"),void o._removePendingData(c)}s&&(o.importedMeshesFiles.push(r+n),s(t,a,l),o._removePendingData(c))};return n.substr&&"data:"===n.substr(0,5)?void f(n.substr(5)):void e.Tools.LoadFile(r+n,function(e){f(e)},a,u)};if(o.getEngine().enableOfflineSupport)var u=new e.Database(r+n,l);else l()}},t.Load=function(i,r,n,o,s,a){t.Append(i,r,new e.Scene(n),o,s,a)},t.Append=function(i,r,n,o,s,a){if(!r.substr||"/"!==r.substr(0,1)){var h,c=this._getPluginForFilename(r.name||r),l={};n._addPendingData(l),t.ShowLoadingScreen&&n.getEngine().displayLoadingUI();var u=function(e){return n.database=h,c.load(n,e,i)?(o&&o(n),n._removePendingData(l),void(t.ShowLoadingScreen&&n.executeWhenReady(function(){n.getEngine().hideLoadingUI()}))):(a&&a(n),n._removePendingData(l),void n.getEngine().hideLoadingUI())},d=function(t){e.Tools.LoadFile(i+r,u,s,h)};return r.substr&&"data:"===r.substr(0,5)?void u(r.substr(5)):void(-1===i.indexOf("file:")?n.getEngine().enableOfflineSupport?h=new e.Database(i+r,d):d():e.Tools.ReadFile(r,u,s))}e.Tools.Error("Wrong sceneFilename parameter")},t._ForceFullSceneLoadingForIncremental=!1,t._ShowLoadingScreen=!0,t._registeredPlugins=new Array,t}();e.SceneLoader=t}(BABYLON||(BABYLON={})),function(e){var t,i,r,n,o,s,a,h,c,l,u,d,f,p,m,g,v,_,y,x,b,M,E,T,w,S,A,P;e.Internals||(e.Internals={}),t=function(e,t){if(e.length===3*t){for(var i=[],r=0;r<e.length;r+=3){var n=r/3*4;i[n]=e[r],i[n+1]=e[r+1],i[n+2]=e[r+2],i[n+3]=1}return i}return e},i=function(t,i,r){if(i.isCube)return function(t,i,r){var n=null;return!i.name&&!i.extensions||i.isRenderTarget||((n=new e.CubeTexture(t+i.name,r,i.extensions)).name=i.name,n.hasAlpha=i.hasAlpha,n.level=i.level,n.coordinatesMode=i.coordinatesMode),n}(t,i,r);if(!i.name&&!i.isRenderTarget)return null;var n;if(i.mirrorPlane?((n=new e.MirrorTexture(i.name,i.renderTargetSize,r))._waitingRenderList=i.renderList,n.mirrorPlane=e.Plane.FromArray(i.mirrorPlane)):i.isRenderTarget?(n=new e.RenderTargetTexture(i.name,i.renderTargetSize,r))._waitingRenderList=i.renderList:n=i.base64String?e.Texture.CreateFromBase64String(i.base64String,i.name,r):new e.Texture(t+i.name,r),n.name=i.name,n.hasAlpha=i.hasAlpha,n.getAlphaFromRGB=i.getAlphaFromRGB,n.level=i.level,n.coordinatesIndex=i.coordinatesIndex,n.coordinatesMode=i.coordinatesMode,n.uOffset=i.uOffset,n.vOffset=i.vOffset,n.uScale=i.uScale,n.vScale=i.vScale,n.uAng=i.uAng,n.vAng=i.vAng,n.wAng=i.wAng,n.wrapU=i.wrapU,n.wrapV=i.wrapV,i.animations)for(var o=0;o<i.animations.length;o++){var s=i.animations[o];n.animations.push(u(s))}return n},r=function(t,i){for(var r=new e.Skeleton(t.name,t.id,i),n=0;n<t.bones.length;n++){var o=t.bones[n],s=null;o.parentBoneIndex>-1&&(s=r.bones[o.parentBoneIndex]);var a=new e.Bone(o.name,r,s,e.Matrix.FromArray(o.matrix));o.animation&&a.animations.push(u(o.animation))}return r},n=function(t){var i=new e.FresnelParameters;return i.isEnabled=t.isEnabled,i.leftColor=e.Color3.FromArray(t.leftColor),i.rightColor=e.Color3.FromArray(t.rightColor),i.bias=t.bias,i.power=t.power||1,i},o=function(t,r,o){var s;return(s=new e.StandardMaterial(t.name,r)).ambientColor=e.Color3.FromArray(t.ambient),s.diffuseColor=e.Color3.FromArray(t.diffuse),s.specularColor=e.Color3.FromArray(t.specular),s.specularPower=t.specularPower,s.emissiveColor=e.Color3.FromArray(t.emissive),s.useReflectionFresnelFromSpecular=t.useReflectionFresnelFromSpecular,s.useEmissiveAsIllumination=t.useEmissiveAsIllumination,s.alpha=t.alpha,s.id=t.id,t.disableDepthWrite&&(s.disableDepthWrite=t.disableDepthWrite),e.Tags.AddTagsTo(s,t.tags),s.backFaceCulling=t.backFaceCulling,s.wireframe=t.wireframe,t.diffuseTexture&&(s.diffuseTexture=i(o,t.diffuseTexture,r)),t.diffuseFresnelParameters&&(s.diffuseFresnelParameters=n(t.diffuseFresnelParameters)),t.ambientTexture&&(s.ambientTexture=i(o,t.ambientTexture,r)),t.opacityTexture&&(s.opacityTexture=i(o,t.opacityTexture,r)),t.opacityFresnelParameters&&(s.opacityFresnelParameters=n(t.opacityFresnelParameters)),t.reflectionTexture&&(s.reflectionTexture=i(o,t.reflectionTexture,r)),t.reflectionFresnelParameters&&(s.reflectionFresnelParameters=n(t.reflectionFresnelParameters)),t.emissiveTexture&&(s.emissiveTexture=i(o,t.emissiveTexture,r)),t.lightmapTexture&&(s.lightmapTexture=i(o,t.lightmapTexture,r),s.lightmapThreshold=t.lightmapThreshold),t.emissiveFresnelParameters&&(s.emissiveFresnelParameters=n(t.emissiveFresnelParameters)),t.specularTexture&&(s.specularTexture=i(o,t.specularTexture,r)),t.bumpTexture&&(s.bumpTexture=i(o,t.bumpTexture,r)),t.checkReadyOnlyOnce&&(s.checkReadyOnlyOnce=t.checkReadyOnlyOnce),s},s=function(e,t,i,r){for(var n=0;n<t.materials.length;n++){var s=t.materials[n];if(s.id===e)return o(s,i,r)}return null},a=function(t,i){var r=new e.MultiMaterial(t.name,i);r.id=t.id,e.Tags.AddTagsTo(r,t.tags);for(var n=0;n<t.materials.length;n++){var o=t.materials[n];r.subMaterials.push(o?i.getMaterialByID(o):null)}return r},h=function(t,i,r){var n=i.getLastEntryByID(t.emitterId),o=new e.LensFlareSystem("lensFlareSystem#"+t.emitterId,n,i);o.borderLimit=t.borderLimit;for(var s=0;s<t.flares.length;s++){var a=t.flares[s];new e.LensFlare(a.size,a.position,e.Color3.FromArray(a.color),r+a.textureName,o)}return o},c=function(t,i,r){var n=i.getLastMeshByID(t.emitterId),o=new e.ParticleSystem("particles#"+n.name,t.capacity,i);return t.textureName&&(o.particleTexture=new e.Texture(r+t.textureName,i),o.particleTexture.name=t.textureName),o.minAngularSpeed=t.minAngularSpeed,o.maxAngularSpeed=t.maxAngularSpeed,o.minSize=t.minSize,o.maxSize=t.maxSize,o.minLifeTime=t.minLifeTime,o.maxLifeTime=t.maxLifeTime,o.emitter=n,o.emitRate=t.emitRate,o.minEmitBox=e.Vector3.FromArray(t.minEmitBox),o.maxEmitBox=e.Vector3.FromArray(t.maxEmitBox),o.gravity=e.Vector3.FromArray(t.gravity),o.direction1=e.Vector3.FromArray(t.direction1),o.direction2=e.Vector3.FromArray(t.direction2),o.color1=e.Color4.FromArray(t.color1),o.color2=e.Color4.FromArray(t.color2),o.colorDead=e.Color4.FromArray(t.colorDead),o.updateSpeed=t.updateSpeed,o.targetStopDuration=t.targetStopFrame,o.textureMask=e.Color4.FromArray(t.textureMask),o.blendMode=t.blendMode,o.start(),o},l=function(t,i){for(var r=i.getLightByID(t.lightId),n=new e.ShadowGenerator(t.mapSize,r),o=0;o<t.renderList.length;o++){var s=i.getMeshByID(t.renderList[o]);n.getShadowMap().renderList.push(s)}return t.usePoissonSampling?n.usePoissonSampling=!0:t.useVarianceShadowMap?n.useVarianceShadowMap=!0:t.useBlurVarianceShadowMap&&(n.useBlurVarianceShadowMap=!0,t.blurScale&&(n.blurScale=t.blurScale),t.blurBoxOffset&&(n.blurBoxOffset=t.blurBoxOffset)),void 0!==t.bias&&(n.bias=t.bias),n},u=function(t){for(var i=new e.Animation(t.name,t.property,t.framePerSecond,t.dataType,t.loopBehavior),r=t.dataType,n=[],o=0;o<t.keys.length;o++){var s,a=t.keys[o];switch(r){case e.Animation.ANIMATIONTYPE_FLOAT:s=a.values[0];break;case e.Animation.ANIMATIONTYPE_QUATERNION:s=e.Quaternion.FromArray(a.values);break;case e.Animation.ANIMATIONTYPE_MATRIX:s=e.Matrix.FromArray(a.values);break;case e.Animation.ANIMATIONTYPE_VECTOR3:default:s=e.Vector3.FromArray(a.values)}n.push({frame:a.frame,value:s})}return i.setKeys(n),i},d=function(t,i){var r;switch(t.type){case 0:r=new e.PointLight(t.name,e.Vector3.FromArray(t.position),i);break;case 1:(r=new e.DirectionalLight(t.name,e.Vector3.FromArray(t.direction),i)).position=e.Vector3.FromArray(t.position);break;case 2:r=new e.SpotLight(t.name,e.Vector3.FromArray(t.position),e.Vector3.FromArray(t.direction),t.angle,t.exponent,i);break;case 3:(r=new e.HemisphericLight(t.name,e.Vector3.FromArray(t.direction),i)).groundColor=e.Color3.FromArray(t.groundColor)}if(r.id=t.id,e.Tags.AddTagsTo(r,t.tags),void 0!==t.intensity&&(r.intensity=t.intensity),t.range&&(r.range=t.range),r.diffuse=e.Color3.FromArray(t.diffuse),r.specular=e.Color3.FromArray(t.specular),t.excludedMeshesIds&&(r._excludedMeshesIds=t.excludedMeshesIds),t.parentId&&(r._waitingParentId=t.parentId),t.includedOnlyMeshesIds&&(r._includedOnlyMeshesIds=t.includedOnlyMeshesIds),t.animations)for(var n=0;n<t.animations.length;n++){var o=t.animations[n];r.animations.push(u(o))}t.autoAnimate&&i.beginAnimation(r,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,1)},f=function(t,i){var r,n=e.Vector3.FromArray(t.position),o=t.lockedTargetId?i.getLastMeshByID(t.lockedTargetId):null;if("AnaglyphArcRotateCamera"===t.type||"ArcRotateCamera"===t.type){var s=t.alpha,a=t.beta,h=t.radius;if("AnaglyphArcRotateCamera"===t.type){var c=t.interaxial_distance;r=new e.AnaglyphArcRotateCamera(t.name,s,a,h,o,c,i)}else r=new e.ArcRotateCamera(t.name,s,a,h,o,i)}else"AnaglyphFreeCamera"===t.type?(c=t.interaxial_distance,r=new e.AnaglyphFreeCamera(t.name,n,c,i)):"DeviceOrientationCamera"===t.type?r=new e.DeviceOrientationCamera(t.name,n,i):"FollowCamera"===t.type?((r=new e.FollowCamera(t.name,n,i)).heightOffset=t.heightOffset,r.radius=t.radius,r.rotationOffset=t.rotationOffset,o&&(r.target=o)):r="GamepadCamera"===t.type?new e.GamepadCamera(t.name,n,i):"TouchCamera"===t.type?new e.TouchCamera(t.name,n,i):"VirtualJoysticksCamera"===t.type?new e.VirtualJoysticksCamera(t.name,n,i):"WebVRFreeCamera"===t.type?new e.WebVRFreeCamera(t.name,n,i):"VRDeviceOrientationFreeCamera"===t.type?new e.VRDeviceOrientationFreeCamera(t.name,n,i):new e.FreeCamera(t.name,n,i);if(t.cameraRigMode){var l=t.interaxial_distance?{interaxialDistance:t.interaxial_distance}:{};r.setCameraRigMode(t.cameraRigMode,l)}if(o&&r instanceof e.FreeCamera&&(r.lockedTarget=o),r.id=t.id,e.Tags.AddTagsTo(r,t.tags),t.parentId&&(r._waitingParentId=t.parentId),t.target?r.setTarget?r.setTarget(e.Vector3.FromArray(t.target)):r.target=e.Vector3.FromArray(t.target):r.rotation=e.Vector3.FromArray(t.rotation),r.fov=t.fov,r.minZ=t.minZ,r.maxZ=t.maxZ,r.speed=t.speed,r.inertia=t.inertia,r.checkCollisions=t.checkCollisions,r.applyGravity=t.applyGravity,t.ellipsoid&&(r.ellipsoid=e.Vector3.FromArray(t.ellipsoid)),t.animations)for(var d=0;d<t.animations.length;d++){var f=t.animations[d];r.animations.push(u(f))}return t.autoAnimate&&i.beginAnimation(r,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,1),r.layerMask=t.layerMask&&!isNaN(t.layerMask)?Math.abs(parseInt(t.layerMask)):268435455,r},p=function(e,t){var i=e.id;return t.getGeometryByID(i)},m=function(t,i){if(p(t,i))return null;var r=new e.Geometry.Primitives.Box(t.id,i,t.size,t.canBeRegenerated,null);return e.Tags.AddTagsTo(r,t.tags),i.pushGeometry(r,!0),r},g=function(t,i){if(p(t,i))return null;var r=new e.Geometry.Primitives.Sphere(t.id,i,t.segments,t.diameter,t.canBeRegenerated,null);return e.Tags.AddTagsTo(r,t.tags),i.pushGeometry(r,!0),r},v=function(t,i){if(p(t,i))return null;var r=new e.Geometry.Primitives.Cylinder(t.id,i,t.height,t.diameterTop,t.diameterBottom,t.tessellation,t.subdivisions,t.canBeRegenerated,null);return e.Tags.AddTagsTo(r,t.tags),i.pushGeometry(r,!0),r},_=function(t,i){if(p(t,i))return null;var r=new e.Geometry.Primitives.Torus(t.id,i,t.diameter,t.thickness,t.tessellation,t.canBeRegenerated,null);return e.Tags.AddTagsTo(r,t.tags),i.pushGeometry(r,!0),r},y=function(t,i){if(p(t,i))return null;var r=new e.Geometry.Primitives.Ground(t.id,i,t.width,t.height,t.subdivisions,t.canBeRegenerated,null);return e.Tags.AddTagsTo(r,t.tags),i.pushGeometry(r,!0),r},x=function(t,i){if(p(t,i))return null;var r=new e.Geometry.Primitives.Plane(t.id,i,t.size,t.canBeRegenerated,null);return e.Tags.AddTagsTo(r,t.tags),i.pushGeometry(r,!0),r},b=function(t,i){if(p(t,i))return null;var r=new e.Geometry.Primitives.TorusKnot(t.id,i,t.radius,t.tube,t.radialSegments,t.tubularSegments,t.p,t.q,t.canBeRegenerated,null);return e.Tags.AddTagsTo(r,t.tags),i.pushGeometry(r,!0),r},M=function(t,i,r){if(p(t,i))return null;var n=new e.Geometry(t.id,i);return e.Tags.AddTagsTo(n,t.tags),t.delayLoadingFile?(n.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,n.delayLoadingFile=r+t.delayLoadingFile,n._boundingInfo=new e.BoundingInfo(e.Vector3.FromArray(t.boundingBoxMinimum),e.Vector3.FromArray(t.boundingBoxMaximum)),n._delayInfo=[],t.hasUVs&&n._delayInfo.push(e.VertexBuffer.UVKind),t.hasUVs2&&n._delayInfo.push(e.VertexBuffer.UV2Kind),t.hasUVs3&&n._delayInfo.push(e.VertexBuffer.UV3Kind),t.hasUVs4&&n._delayInfo.push(e.VertexBuffer.UV4Kind),t.hasUVs5&&n._delayInfo.push(e.VertexBuffer.UV5Kind),t.hasUVs6&&n._delayInfo.push(e.VertexBuffer.UV6Kind),t.hasColors&&n._delayInfo.push(e.VertexBuffer.ColorKind),t.hasMatricesIndices&&n._delayInfo.push(e.VertexBuffer.MatricesIndicesKind),t.hasMatricesWeights&&n._delayInfo.push(e.VertexBuffer.MatricesWeightsKind),n._delayLoadingFunction=A):A(t,n),i.pushGeometry(n,!0),n},E=function(t,i,r){var n=new e.Mesh(t.name,i);if(n.id=t.id,e.Tags.AddTagsTo(n,t.tags),n.position=e.Vector3.FromArray(t.position),t.rotationQuaternion?n.rotationQuaternion=e.Quaternion.FromArray(t.rotationQuaternion):t.rotation&&(n.rotation=e.Vector3.FromArray(t.rotation)),n.scaling=e.Vector3.FromArray(t.scaling),t.localMatrix?n.setPivotMatrix(e.Matrix.FromArray(t.localMatrix)):t.pivotMatrix&&n.setPivotMatrix(e.Matrix.FromArray(t.pivotMatrix)),n.setEnabled(t.isEnabled),n.isVisible=t.isVisible,n.infiniteDistance=t.infiniteDistance,n.showBoundingBox=t.showBoundingBox,n.showSubMeshesBoundingBox=t.showSubMeshesBoundingBox,void 0!==t.applyFog&&(n.applyFog=t.applyFog),void 0!==t.pickable&&(n.isPickable=t.pickable),void 0!==t.alphaIndex&&(n.alphaIndex=t.alphaIndex),n.receiveShadows=t.receiveShadows,n.billboardMode=t.billboardMode,void 0!==t.visibility&&(n.visibility=t.visibility),n.checkCollisions=t.checkCollisions,n._shouldGenerateFlatShading=t.useFlatShading,t.freezeWorldMatrix&&(n._waitingFreezeWorldMatrix=t.freezeWorldMatrix),t.parentId&&(n._waitingParentId=t.parentId),void 0!==t.actions&&(n._waitingActions=t.actions),n.hasVertexAlpha=t.hasVertexAlpha,t.delayLoadingFile?(n.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,n.delayLoadingFile=r+t.delayLoadingFile,n._boundingInfo=new e.BoundingInfo(e.Vector3.FromArray(t.boundingBoxMinimum),e.Vector3.FromArray(t.boundingBoxMaximum)),t._binaryInfo&&(n._binaryInfo=t._binaryInfo),n._delayInfo=[],t.hasUVs&&n._delayInfo.push(e.VertexBuffer.UVKind),t.hasUVs2&&n._delayInfo.push(e.VertexBuffer.UV2Kind),t.hasUVs3&&n._delayInfo.push(e.VertexBuffer.UV3Kind),t.hasUVs4&&n._delayInfo.push(e.VertexBuffer.UV4Kind),t.hasUVs5&&n._delayInfo.push(e.VertexBuffer.UV5Kind),t.hasUVs6&&n._delayInfo.push(e.VertexBuffer.UV6Kind),t.hasColors&&n._delayInfo.push(e.VertexBuffer.ColorKind),t.hasMatricesIndices&&n._delayInfo.push(e.VertexBuffer.MatricesIndicesKind),t.hasMatricesWeights&&n._delayInfo.push(e.VertexBuffer.MatricesWeightsKind),n._delayLoadingFunction=P,e.SceneLoader.ForceFullSceneLoadingForIncremental&&n._checkDelayState()):P(t,n),t.materialId?n.setMaterialByID(t.materialId):n.material=null,t.skeletonId>-1&&(n.skeleton=i.getLastSkeletonByID(t.skeletonId)),t.physicsImpostor&&(i.isPhysicsEnabled()||i.enablePhysics(),n.setPhysicsState({impostor:t.physicsImpostor,mass:t.physicsMass,friction:t.physicsFriction,restitution:t.physicsRestitution})),t.animations)for(var o=0;o<t.animations.length;o++){var s=t.animations[o];n.animations.push(u(s))}if(t.autoAnimate&&i.beginAnimation(n,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,1),n.layerMask=t.layerMask&&!isNaN(t.layerMask)?Math.abs(parseInt(t.layerMask)):268435455,t.instances)for(var a=0;a<t.instances.length;a++){var h=t.instances[a],c=n.createInstance(h.name);if(e.Tags.AddTagsTo(c,h.tags),c.position=e.Vector3.FromArray(h.position),h.rotationQuaternion?c.rotationQuaternion=e.Quaternion.FromArray(h.rotationQuaternion):h.rotation&&(c.rotation=e.Vector3.FromArray(h.rotation)),c.scaling=e.Vector3.FromArray(h.scaling),c.checkCollisions=n.checkCollisions,t.animations)for(o=0;o<t.animations.length;o++)s=t.animations[o],c.animations.push(u(s))}return n},T=function(t,i,r){var n=new e.ActionManager(r);null===i?r.actionManager=n:i.actionManager=n;for(var o=function(t,i,r,n){if(null===n){var o=parseFloat(i);return"true"===i||"false"===i?"true"===i:isNaN(o)?i:o}for(var s=n.split("."),a=i.split(","),h=0;h<s.length;h++)r=r[s[h]];if("boolean"==typeof r)return"true"===a[0];if("string"==typeof r)return a[0];var c=new Array;for(h=0;h<a.length;h++)c.push(parseFloat(a[h]));return r instanceof e.Vector3?e.Vector3.FromArray(c):r instanceof e.Vector4?e.Vector4.FromArray(c):r instanceof e.Color3?e.Color3.FromArray(c):r instanceof e.Color4?e.Color4.FromArray(c):parseFloat(a[0])},s=function(t,i,a,h,c){if(void 0===c&&(c=null),!t.detached){var l=new Array,u=null,d=null,f=t.combine&&t.combine.length>0;if(l.push(2===t.type?n:i),f){for(var p=new Array,m=0;m<t.combine.length;m++)s(t.combine[m],e.ActionManager.NothingTrigger,a,h,p);l.push(p)}else for(var g=0;g<t.properties.length;g++){var v=t.properties[g].value,_=t.properties[g].name,y=t.properties[g].targetType;"target"===_?v=u=null!==y&&"SceneProperties"===y?r:r.getNodeByName(v):"parent"===_?v=r.getNodeByName(v):"sound"===_?v=r.getSoundByName(v):"propertyPath"!==_?v=2===t.type&&"operator"===_?e.ValueCondition[v]:o(0,v,u,"value"===_?d:null):d=v,l.push(v)}if(l.push(null===c?a:null),"InterpolateValueAction"===t.name){var x=l[l.length-2];l[l.length-1]=x,l[l.length-2]=a}var b=function(t,i){var r=Object.create(e[t].prototype);return r.constructor.apply(r,i),r}(t.name,l);if(b instanceof e.Condition&&null!==a){var M=new e.DoNothingAction(i,a);h?h.then(M):n.registerAction(M),h=M}null===c?b instanceof e.Condition?(a=b,b=h):(a=null,h?h.then(b):n.registerAction(b)):c.push(b);for(g=0;g<t.children.length;g++)s(t.children[g],i,a,b,null)}},a=0;a<t.children.length;a++){var h,c=t.children[a];if(c.properties.length>0){var l=c.properties[0].value,u=null===c.properties[0].targetType?l:r.getMeshByName(l);h={trigger:e.ActionManager[c.name],parameter:u}}else h=e.ActionManager[c.name];for(var d=0;d<c.children.length;d++)c.detached||s(c.children[d],h,null,null)}},w=function(t,i,r){var n=t.name,o=r+n,s={autoplay:t.autoplay,loop:t.loop,volume:t.volume,spatialSound:t.spatialSound,maxDistance:t.maxDistance,rolloffFactor:t.rolloffFactor,refDistance:t.refDistance,distanceModel:t.distanceModel,playbackRate:t.playbackRate},a=new e.Sound(n,o,i,function(){i._removePendingData(a)},s);if(i._addPendingData(a),t.position){var h=e.Vector3.FromArray(t.position);a.setPosition(h)}if(t.isDirectional&&(a.setDirectionalCone(t.coneInnerAngle||360,t.coneOuterAngle||360,t.coneOuterGain||0),t.localDirectionToMesh)){var c=e.Vector3.FromArray(t.localDirectionToMesh);a.setLocalDirectionToMesh(c)}if(t.connectedMeshId){var l=i.getMeshByID(t.connectedMeshId);l&&a.attachToMesh(l)}},S=function(e,t,i){for(var r in t=t instanceof Array?t:[t])if(e.name===t[r])return i.push(e.id),!0;return!(!e.parentId||-1===i.indexOf(e.parentId))&&(i.push(e.id),!0)},A=function(i,r){var n=new e.VertexData,o=i.positions;o&&n.set(o,e.VertexBuffer.PositionKind);var s=i.normals;s&&n.set(s,e.VertexBuffer.NormalKind);var a=i.uvs;a&&n.set(a,e.VertexBuffer.UVKind);var h=i.uv2s;h&&n.set(h,e.VertexBuffer.UV2Kind);var c=i.uv3s;c&&n.set(c,e.VertexBuffer.UV3Kind);var l=i.uv4s;l&&n.set(l,e.VertexBuffer.UV4Kind);var u=i.uv5s;u&&n.set(u,e.VertexBuffer.UV5Kind);var d=i.uv6s;d&&n.set(d,e.VertexBuffer.UV6Kind);var f=i.colors;f&&n.set(t(f,o.length/3),e.VertexBuffer.ColorKind);var p=i.matricesIndices;p&&n.set(p,e.VertexBuffer.MatricesIndicesKind);var m=i.matricesWeights;m&&n.set(m,e.VertexBuffer.MatricesWeightsKind);var g=i.indices;g&&(n.indices=g),r.setAllVerticesData(n,i.updatable)},P=function(i,r){var n=r.getScene(),o=i.geometryId;if(o){var s=n.getGeometryByID(o);s&&s.applyToMesh(r)}else if(i instanceof ArrayBuffer){var a=r._binaryInfo;if(a.positionsAttrDesc&&a.positionsAttrDesc.count>0){var h=new Float32Array(i,a.positionsAttrDesc.offset,a.positionsAttrDesc.count);r.setVerticesData(e.VertexBuffer.PositionKind,h,!1)}if(a.normalsAttrDesc&&a.normalsAttrDesc.count>0){var c=new Float32Array(i,a.normalsAttrDesc.offset,a.normalsAttrDesc.count);r.setVerticesData(e.VertexBuffer.NormalKind,c,!1)}if(a.uvsAttrDesc&&a.uvsAttrDesc.count>0){var l=new Float32Array(i,a.uvsAttrDesc.offset,a.uvsAttrDesc.count);r.setVerticesData(e.VertexBuffer.UVKind,l,!1)}if(a.uvs2AttrDesc&&a.uvs2AttrDesc.count>0){var u=new Float32Array(i,a.uvs2AttrDesc.offset,a.uvs2AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV2Kind,u,!1)}if(a.uvs3AttrDesc&&a.uvs3AttrDesc.count>0){var d=new Float32Array(i,a.uvs3AttrDesc.offset,a.uvs3AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV3Kind,d,!1)}if(a.uvs4AttrDesc&&a.uvs4AttrDesc.count>0){var f=new Float32Array(i,a.uvs4AttrDesc.offset,a.uvs4AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV4Kind,f,!1)}if(a.uvs5AttrDesc&&a.uvs5AttrDesc.count>0){var p=new Float32Array(i,a.uvs5AttrDesc.offset,a.uvs5AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV5Kind,p,!1)}if(a.uvs6AttrDesc&&a.uvs6AttrDesc.count>0){var m=new Float32Array(i,a.uvs6AttrDesc.offset,a.uvs6AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV6Kind,m,!1)}if(a.colorsAttrDesc&&a.colorsAttrDesc.count>0){var g=new Float32Array(i,a.colorsAttrDesc.offset,a.colorsAttrDesc.count);r.setVerticesData(e.VertexBuffer.ColorKind,g,!1,a.colorsAttrDesc.stride)}if(a.matricesIndicesAttrDesc&&a.matricesIndicesAttrDesc.count>0){var v=new Int32Array(i,a.matricesIndicesAttrDesc.offset,a.matricesIndicesAttrDesc.count);r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,v,!1)}if(a.matricesWeightsAttrDesc&&a.matricesWeightsAttrDesc.count>0){var _=new Float32Array(i,a.matricesWeightsAttrDesc.offset,a.matricesWeightsAttrDesc.count);r.setVerticesData(e.VertexBuffer.MatricesWeightsKind,_,!1)}if(a.indicesAttrDesc&&a.indicesAttrDesc.count>0){var y=new Int32Array(i,a.indicesAttrDesc.offset,a.indicesAttrDesc.count);r.setIndices(y)}if(a.subMeshesAttrDesc&&a.subMeshesAttrDesc.count>0){var x=new Int32Array(i,a.subMeshesAttrDesc.offset,5*a.subMeshesAttrDesc.count);r.subMeshes=[];for(var b=0;b<a.subMeshesAttrDesc.count;b++){var M=x[5*b+0],E=x[5*b+1],T=x[5*b+2],w=x[5*b+3],S=x[5*b+4];new e.SubMesh(M,E,T,w,S,r)}}}else if(i.positions&&i.normals&&i.indices){if(r.setVerticesData(e.VertexBuffer.PositionKind,i.positions,!1),r.setVerticesData(e.VertexBuffer.NormalKind,i.normals,!1),i.uvs&&r.setVerticesData(e.VertexBuffer.UVKind,i.uvs,!1),i.uvs2&&r.setVerticesData(e.VertexBuffer.UV2Kind,i.uvs2,!1),i.uvs3&&r.setVerticesData(e.VertexBuffer.UV3Kind,i.uvs3,!1),i.uvs4&&r.setVerticesData(e.VertexBuffer.UV4Kind,i.uvs4,!1),i.uvs5&&r.setVerticesData(e.VertexBuffer.UV5Kind,i.uvs5,!1),i.uvs6&&r.setVerticesData(e.VertexBuffer.UV6Kind,i.uvs6,!1),i.colors&&r.setVerticesData(e.VertexBuffer.ColorKind,t(i.colors,i.positions.length/3),!1),i.matricesIndices)if(i.matricesIndices._isExpanded)delete i.matricesIndices._isExpanded,r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,i.matricesIndices,!1);else{var A=[];for(b=0;b<i.matricesIndices.length;b++){var P=i.matricesIndices[b];A.push(255&P),A.push((65280&P)>>8),A.push((16711680&P)>>16),A.push(P>>24)}r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,A,!1)}i.matricesWeights&&r.setVerticesData(e.VertexBuffer.MatricesWeightsKind,i.matricesWeights,!1),r.setIndices(i.indices)}if(i.subMeshes){r.subMeshes=[];for(var C=0;C<i.subMeshes.length;C++){var D=i.subMeshes[C];new e.SubMesh(D.materialIndex,D.verticesStart,D.verticesCount,D.indexStart,D.indexCount,r)}}r._shouldGenerateFlatShading&&(r.convertToFlatShadedMesh(),delete r._shouldGenerateFlatShading),r.computeWorldMatrix(!0),n._selectionOctree&&n._selectionOctree.addMesh(r)},e.SceneLoader.RegisterPlugin({extensions:".babylon",importMesh:function(t,i,n,o,h,l,u){for(var d=JSON.parse(n),f=[],p=[],T=[],w=0;w<d.meshes.length;w++){var A=d.meshes[w];if(!t||S(A,t,T)){if(t instanceof Array&&delete t[t.indexOf(A.name)],A.geometryId&&d.geometries){var P=!1;["boxes","spheres","cylinders","toruses","grounds","planes","torusKnots","vertexData"].forEach(function(e){!P&&d.geometries[e]&&d.geometries[e]instanceof Array&&d.geometries[e].forEach(function(t){if(t.id==A.geometryId){switch(e){case"boxes":m(t,i);break;case"spheres":g(t,i);break;case"cylinders":v(t,i);break;case"toruses":_(t,i);break;case"grounds":y(t,i);break;case"planes":x(t,i);break;case"torusKnots":b(t,i);break;case"vertexData":M(t,i,o)}P=!0}})}),P||e.Tools.Warn("Geometry not found for mesh "+A.id)}if(A.materialId){var C=-1!==p.indexOf(A.materialId);if(!C&&d.multiMaterials)for(var D=0;D<d.multiMaterials.length;D++){var R=d.multiMaterials[D];if(R.id==A.materialId){for(var I=0;I<R.materials.length;I++){var L=R.materials[I];p.push(L),s(L,d,i,o)}p.push(R.id),a(R,i),C=!0;break}}C||(p.push(A.materialId),s(A.materialId,d,i,o)||e.Tools.Warn("Material not found for mesh "+A.id))}if(A.skeletonId>-1&&i.skeletons&&!(f.indexOf(A.skeletonId)>-1))for(var O=0;O<d.skeletons.length;O++){var B=d.skeletons[O];B.id===A.skeletonId&&(u.push(r(B,i)),f.push(B.id))}var F=E(A,i,o);h.push(F)}}for(w=0;w<i.meshes.length;w++)(N=i.meshes[w])._waitingParentId&&(N.parent=i.getLastEntryByID(N._waitingParentId),N._waitingParentId=void 0);for(w=0;w<i.meshes.length;w++){var N;(N=i.meshes[w])._waitingFreezeWorldMatrix&&(N.freezeWorldMatrix(),N._waitingFreezeWorldMatrix=void 0)}if(d.particleSystems)for(w=0;w<d.particleSystems.length;w++){var V=d.particleSystems[w];-1!==T.indexOf(V.emitterId)&&l.push(c(V,i,o))}return!0},load:function(t,i,n){var s=JSON.parse(i);t.useDelayedTextureLoading=s.useDelayedTextureLoading&&!e.SceneLoader.ForceFullSceneLoadingForIncremental,t.autoClear=s.autoClear,t.clearColor=e.Color3.FromArray(s.clearColor),t.ambientColor=e.Color3.FromArray(s.ambientColor),t.gravity=e.Vector3.FromArray(s.gravity),s.fogMode&&0!==s.fogMode&&(t.fogMode=s.fogMode,t.fogColor=e.Color3.FromArray(s.fogColor),t.fogStart=s.fogStart,t.fogEnd=s.fogEnd,t.fogDensity=s.fogDensity);for(var u=0;u<s.lights.length;u++){var p=s.lights[u];d(p,t)}if(s.materials)for(u=0;u<s.materials.length;u++){var S=s.materials[u];o(S,t,n)}if(s.multiMaterials)for(u=0;u<s.multiMaterials.length;u++){var A=s.multiMaterials[u];a(A,t)}if(s.skeletons)for(u=0;u<s.skeletons.length;u++){var P=s.skeletons[u];r(P,t)}var C=s.geometries;if(C){var D=C.boxes;if(D)for(u=0;u<D.length;u++){var R=D[u];m(R,t)}var I=C.spheres;if(I)for(u=0;u<I.length;u++){var L=I[u];g(L,t)}var O=C.cylinders;if(O)for(u=0;u<O.length;u++){var B=O[u];v(B,t)}var F=C.toruses;if(F)for(u=0;u<F.length;u++){var N=F[u];_(N,t)}var V=C.grounds;if(V)for(u=0;u<V.length;u++){var U=V[u];y(U,t)}var z=C.planes;if(z)for(u=0;u<z.length;u++){var k=z[u];x(k,t)}var G=C.torusKnots;if(G)for(u=0;u<G.length;u++){var W=G[u];b(W,t)}var H=C.vertexData;if(H)for(u=0;u<H.length;u++){var j=H[u];M(j,t,n)}}for(u=0;u<s.meshes.length;u++){var Y=s.meshes[u];E(Y,t,n)}for(u=0;u<s.cameras.length;u++){var X=s.cameras[u];f(X,t)}for(s.activeCameraID&&t.setActiveCameraByID(s.activeCameraID),u=0;u<t.cameras.length;u++){var K=t.cameras[u];K._waitingParentId&&(K.parent=t.getLastEntryByID(K._waitingParentId),K._waitingParentId=void 0)}for(u=0;u<t.lights.length;u++){var q=t.lights[u];q._waitingParentId&&(q.parent=t.getLastEntryByID(q._waitingParentId),q._waitingParentId=void 0)}if(s.sounds)for(u=0;u<s.sounds.length;u++){var Z=s.sounds[u];e.Engine.audioEngine.canUseWebAudio?w(Z,t,n):new e.Sound(Z.name,null,t)}for(u=0;u<t.meshes.length;u++){var Q=t.meshes[u];Q._waitingParentId&&(Q.parent=t.getLastEntryByID(Q._waitingParentId),Q._waitingParentId=void 0),Q._waitingActions&&(T(Q._waitingActions,Q,t),Q._waitingActions=void 0)}for(u=0;u<t.meshes.length;u++){var J=t.meshes[u];J._waitingFreezeWorldMatrix&&(J.freezeWorldMatrix(),J._waitingFreezeWorldMatrix=void 0)}if(s.particleSystems)for(u=0;u<s.particleSystems.length;u++){var $=s.particleSystems[u];c($,t,n)}if(s.lensFlareSystems)for(u=0;u<s.lensFlareSystems.length;u++){var ee=s.lensFlareSystems[u];h(ee,t,n)}if(s.shadowGenerators)for(u=0;u<s.shadowGenerators.length;u++){var te=s.shadowGenerators[u];l(te,t)}return s.actions&&T(s.actions,null,t),!0}})}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t,i,r,n,o,s,a){void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE),this.name=t,this.cellSize=n,this.sprites=new Array,this.renderingGroupId=0,this.layerMask=268435455,this.fogEnabled=!0,this.isPickable=!1,this._vertexDeclaration=[4,4,4,4],this._vertexStrideSize=64,this._capacity=r,this._spriteTexture=new e.Texture(i,o,!0,!1,a),this._spriteTexture.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._spriteTexture.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._epsilon=void 0===s?.01:s,this._scene=o,this._scene.spriteManagers.push(this),this._vertexBuffer=o.getEngine().createDynamicVertexBuffer(r*this._vertexStrideSize*4);for(var h=[],c=0,l=0;r>l;l++)h.push(c),h.push(c+1),h.push(c+2),h.push(c),h.push(c+2),h.push(c+3),c+=4;this._indexBuffer=o.getEngine().createIndexBuffer(h),this._vertices=new Float32Array(r*this._vertexStrideSize),this._effectBase=this._scene.getEngine().createEffect("sprites",["position","options","cellInfo","color"],["view","projection","textureInfos","alphaTest"],["diffuseSampler"],""),this._effectFog=this._scene.getEngine().createEffect("sprites",["position","options","cellInfo","color"],["view","projection","textureInfos","alphaTest","vFogInfos","vFogColor"],["diffuseSampler"],"#define FOG")}return t.prototype._appendSpriteVertex=function(e,t,i,r,n){var o=16*e;0===i?i=this._epsilon:1===i&&(i=1-this._epsilon),0===r?r=this._epsilon:1===r&&(r=1-this._epsilon),this._vertices[o]=t.position.x,this._vertices[o+1]=t.position.y,this._vertices[o+2]=t.position.z,this._vertices[o+3]=t.angle,this._vertices[o+4]=t.width,this._vertices[o+5]=t.height,this._vertices[o+6]=i,this._vertices[o+7]=r,this._vertices[o+8]=t.invertU?1:0,this._vertices[o+9]=t.invertV?1:0;var s=t.cellIndex/n>>0;this._vertices[o+10]=t.cellIndex-s*n,this._vertices[o+11]=s,this._vertices[o+12]=t.color.r,this._vertices[o+13]=t.color.g,this._vertices[o+14]=t.color.b,this._vertices[o+15]=t.color.a},t.prototype.intersects=function(t,i,r,n){for(var o,s=Math.min(this._capacity,this.sprites.length),a=e.Vector3.Zero(),h=e.Vector3.Zero(),c=Number.MAX_VALUE,l=e.Vector3.Zero(),u=i.getViewMatrix(),d=0;s>d;d++){var f=this.sprites[d];if(f){if(r){if(!r(f))continue}else if(!f.isPickable)continue;if(e.Vector3.TransformCoordinatesToRef(f.position,u,l),a.copyFromFloats(l.x-f.width/2,l.y-f.height/2,l.z),h.copyFromFloats(l.x+f.width/2,l.y+f.height/2,l.z),t.intersectsBoxMinMax(a,h)){var p=e.Vector3.Distance(l,t.origin);if(c>p&&(c=p,o=f,n))break}}}if(o){var m=new e.PickingInfo;return m.hit=!0,m.pickedSprite=o,m.distance=c,m}return null},t.prototype.render=function(){if(this._effectBase.isReady()&&this._effectFog.isReady()&&this._spriteTexture&&this._spriteTexture.isReady()){for(var t=this._scene.getEngine(),i=this._spriteTexture.getBaseSize(),r=t.getDeltaTime(),n=Math.min(this._capacity,this.sprites.length),o=i.width/this.cellSize,s=0,a=0;n>a;a++){var h=this.sprites[a];h&&(h._animate(r),this._appendSpriteVertex(s++,h,0,0,o),this._appendSpriteVertex(s++,h,1,0,o),this._appendSpriteVertex(s++,h,1,1,o),this._appendSpriteVertex(s++,h,0,1,o))}t.updateDynamicVertexBuffer(this._vertexBuffer,this._vertices);var c=this._effectBase;this._scene.fogEnabled&&this._scene.fogMode!==e.Scene.FOGMODE_NONE&&this.fogEnabled&&(c=this._effectFog),t.enableEffect(c);var l=this._scene.getViewMatrix();c.setTexture("diffuseSampler",this._spriteTexture),c.setMatrix("view",l),c.setMatrix("projection",this._scene.getProjectionMatrix()),c.setFloat2("textureInfos",this.cellSize/i.width,this.cellSize/i.height),this._scene.fogEnabled&&this._scene.fogMode!==e.Scene.FOGMODE_NONE&&this.fogEnabled&&(c.setFloat4("vFogInfos",this._scene.fogMode,this._scene.fogStart,this._scene.fogEnd,this._scene.fogDensity),c.setColor3("vFogColor",this._scene.fogColor)),t.bindBuffers(this._vertexBuffer,this._indexBuffer,this._vertexDeclaration,this._vertexStrideSize,c),t.setDepthFunctionToLessOrEqual(),c.setBool("alphaTest",!0),t.setColorWrite(!1),t.draw(!0,0,6*n),t.setColorWrite(!0),c.setBool("alphaTest",!1),t.setAlphaMode(e.Engine.ALPHA_COMBINE),t.draw(!0,0,6*n),t.setAlphaMode(e.Engine.ALPHA_DISABLE)}},t.prototype.dispose=function(){this._vertexBuffer&&(this._scene.getEngine()._releaseBuffer(this._vertexBuffer),this._vertexBuffer=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this._spriteTexture&&(this._spriteTexture.dispose(),this._spriteTexture=null);var e=this._scene.spriteManagers.indexOf(this);this._scene.spriteManagers.splice(e,1),this.onDispose&&this.onDispose()},t}();e.SpriteManager=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t,i){this.name=t,this.color=new e.Color4(1,1,1,1),this.width=1,this.height=1,this.angle=0,this.cellIndex=0,this.invertU=0,this.invertV=0,this.animations=new Array,this.isPickable=!1,this._animationStarted=!1,this._loopAnimation=!1,this._fromIndex=0,this._toIndex=0,this._delay=0,this._direction=1,this._frameCount=0,this._time=0,this._manager=i,this._manager.sprites.push(this),this.position=e.Vector3.Zero()}return Object.defineProperty(t.prototype,"size",{get:function(){return this.width},set:function(e){this.width=e,this.height=e},enumerable:!0,configurable:!0}),t.prototype.playAnimation=function(e,t,i,r){this._fromIndex=e,this._toIndex=t,this._loopAnimation=i,this._delay=r,this._animationStarted=!0,this._direction=t>e?1:-1,this.cellIndex=e,this._time=0},t.prototype.stopAnimation=function(){this._animationStarted=!1},t.prototype._animate=function(e){this._animationStarted&&(this._time+=e,this._time>this._delay&&(this._time=this._time%this._delay,this.cellIndex+=this._direction,this.cellIndex==this._toIndex&&(this._loopAnimation?this.cellIndex=this._fromIndex:(this._animationStarted=!1,this.disposeWhenFinishedAnimating&&this.dispose()))))},t.prototype.dispose=function(){for(var e=0;e<this._manager.sprites.length;e++)this._manager.sprites[e]==this&&this._manager.sprites.splice(e,1)},t}();e.Sprite=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t,i,r,n,o){this.name=t,this._vertexDeclaration=[2],this._vertexStrideSize=8,this.texture=i?new e.Texture(i,r,!0):null,this.isBackground=void 0===n||n,this.color=void 0===o?new e.Color4(1,1,1,1):o,this._scene=r,this._scene.layers.push(this);var s=[];s.push(1,1),s.push(-1,1),s.push(-1,-1),s.push(1,-1),this._vertexBuffer=r.getEngine().createVertexBuffer(s);var a=[];a.push(0),a.push(1),a.push(2),a.push(0),a.push(2),a.push(3),this._indexBuffer=r.getEngine().createIndexBuffer(a),this._effect=this._scene.getEngine().createEffect("layer",["position"],["textureMatrix","color"],["textureSampler"],"")}return t.prototype.render=function(){if(this._effect.isReady()&&this.texture&&this.texture.isReady()){var t=this._scene.getEngine();t.enableEffect(this._effect),t.setState(!1),this._effect.setTexture("textureSampler",this.texture),this._effect.setMatrix("textureMatrix",this.texture.getTextureMatrix()),this._effect.setFloat4("color",this.color.r,this.color.g,this.color.b,this.color.a),t.bindBuffers(this._vertexBuffer,this._indexBuffer,this._vertexDeclaration,this._vertexStrideSize,this._effect),t.setAlphaMode(e.Engine.ALPHA_COMBINE),t.draw(!0,0,6),t.setAlphaMode(e.Engine.ALPHA_DISABLE)}},t.prototype.dispose=function(){this._vertexBuffer&&(this._scene.getEngine()._releaseBuffer(this._vertexBuffer),this._vertexBuffer=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.texture&&(this.texture.dispose(),this.texture=null);var e=this._scene.layers.indexOf(this);this._scene.layers.splice(e,1),this.onDispose&&this.onDispose()},t}();e.Layer=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(){this.position=e.Vector3.Zero(),this.direction=e.Vector3.Zero(),this.color=new e.Color4(0,0,0,0),this.colorStep=new e.Color4(0,0,0,0),this.lifeTime=1,this.age=0,this.size=0,this.angle=0,this.angularSpeed=0}return t.prototype.copyTo=function(e){e.position.copyFrom(this.position),e.direction.copyFrom(this.direction),e.color.copyFrom(this.color),e.colorStep.copyFrom(this.colorStep),e.lifeTime=this.lifeTime,e.age=this.age,e.size=this.size,e.angle=this.angle,e.angularSpeed=this.angularSpeed},t}();e.Particle=t}(BABYLON||(BABYLON={})),function(e){var t=function(e,t){return e===t?e:Math.random()*(t-e)+e},i=function(){function i(r,n,o,s){var a=this;this.name=r,this.renderingGroupId=0,this.emitter=null,this.emitRate=10,this.manualEmitCount=-1,this.updateSpeed=.01,this.targetStopDuration=0,this.disposeOnStop=!1,this.minEmitPower=1,this.maxEmitPower=1,this.minLifeTime=1,this.maxLifeTime=1,this.minSize=1,this.maxSize=1,this.minAngularSpeed=0,this.maxAngularSpeed=0,this.layerMask=268435455,this.blendMode=i.BLENDMODE_ONEONE,this.forceDepthWrite=!1,this.gravity=e.Vector3.Zero(),this.direction1=new e.Vector3(0,1,0),this.direction2=new e.Vector3(0,1,0),this.minEmitBox=new e.Vector3(-.5,-.5,-.5),this.maxEmitBox=new e.Vector3(.5,.5,.5),this.color1=new e.Color4(1,1,1,1),this.color2=new e.Color4(1,1,1,1),this.colorDead=new e.Color4(0,0,0,1),this.textureMask=new e.Color4(1,1,1,1),this.particles=new Array,this._vertexDeclaration=[3,4,4],this._vertexStrideSize=44,this._stockParticles=new Array,this._newPartsExcess=0,this._scaledColorStep=new e.Color4(0,0,0,0),this._colorDiff=new e.Color4(0,0,0,0),this._scaledDirection=e.Vector3.Zero(),this._scaledGravity=e.Vector3.Zero(),this._currentRenderId=-1,this._started=!1,this._stopped=!1,this._actualFrame=0,this.id=r,this._capacity=n,this._scene=o,this._customEffect=s,o.particleSystems.push(this),this._vertexBuffer=o.getEngine().createDynamicVertexBuffer(n*this._vertexStrideSize*4);for(var h=[],c=0,l=0;n>l;l++)h.push(c),h.push(c+1),h.push(c+2),h.push(c),h.push(c+2),h.push(c+3),c+=4;this._indexBuffer=o.getEngine().createIndexBuffer(h),this._vertices=new Float32Array(n*this._vertexStrideSize),this.startDirectionFunction=function(i,r,n){var o=t(a.direction1.x,a.direction2.x),s=t(a.direction1.y,a.direction2.y),h=t(a.direction1.z,a.direction2.z);e.Vector3.TransformNormalFromFloatsToRef(o*i,s*i,h*i,r,n)},this.startPositionFunction=function(i,r){var n=t(a.minEmitBox.x,a.maxEmitBox.x),o=t(a.minEmitBox.y,a.maxEmitBox.y),s=t(a.minEmitBox.z,a.maxEmitBox.z);e.Vector3.TransformCoordinatesFromFloatsToRef(n,o,s,i,r)},this.updateFunction=function(e){for(var t=0;t<e.length;t++){var i=e[t];i.age+=a._scaledUpdateSpeed,i.age>=i.lifeTime?(a.recycleParticle(i),t--):(i.colorStep.scaleToRef(a._scaledUpdateSpeed,a._scaledColorStep),i.color.addInPlace(a._scaledColorStep),i.color.a<0&&(i.color.a=0),i.angle+=i.angularSpeed*a._scaledUpdateSpeed,i.direction.scaleToRef(a._scaledUpdateSpeed,a._scaledDirection),i.position.addInPlace(a._scaledDirection),a.gravity.scaleToRef(a._scaledUpdateSpeed,a._scaledGravity),i.direction.addInPlace(a._scaledGravity))}}}return i.prototype.recycleParticle=function(e){var t=this.particles.pop();t!==e&&(t.copyTo(e),this._stockParticles.push(t))},i.prototype.getCapacity=function(){return this._capacity},i.prototype.isAlive=function(){return this._alive},i.prototype.isStarted=function(){return this._started},i.prototype.start=function(){this._started=!0,this._stopped=!1,this._actualFrame=0},i.prototype.stop=function(){this._stopped=!0},i.prototype._appendParticleVertex=function(e,t,i,r){var n=11*e;this._vertices[n]=t.position.x,this._vertices[n+1]=t.position.y,this._vertices[n+2]=t.position.z,this._vertices[n+3]=t.color.r,this._vertices[n+4]=t.color.g,this._vertices[n+5]=t.color.b,this._vertices[n+6]=t.color.a,this._vertices[n+7]=t.angle,this._vertices[n+8]=t.size,this._vertices[n+9]=i,this._vertices[n+10]=r},i.prototype._update=function(i){var r;this._alive=this.particles.length>0,this.updateFunction(this.particles),r=this.emitter.position?this.emitter.getWorldMatrix():e.Matrix.Translation(this.emitter.x,this.emitter.y,this.emitter.z);for(var n=0;i>n&&this.particles.length!==this._capacity;n++){if(0!==this._stockParticles.length){var o=this._stockParticles.pop();o.age=0}else o=new e.Particle;this.particles.push(o);var s=t(this.minEmitPower,this.maxEmitPower);this.startDirectionFunction(s,r,o.direction),o.lifeTime=t(this.minLifeTime,this.maxLifeTime),o.size=t(this.minSize,this.maxSize),o.angularSpeed=t(this.minAngularSpeed,this.maxAngularSpeed),this.startPositionFunction(r,o.position);var a=t(0,1);e.Color4.LerpToRef(this.color1,this.color2,a,o.color),this.colorDead.subtractToRef(o.color,this._colorDiff),this._colorDiff.scaleToRef(1/o.lifeTime,o.colorStep)}},i.prototype._getEffect=function(){if(this._customEffect)return this._customEffect;var e=[];this._scene.clipPlane&&e.push("#define CLIPPLANE");var t=e.join("\n");return this._cachedDefines!==t&&(this._cachedDefines=t,this._effect=this._scene.getEngine().createEffect("particles",["position","color","options"],["invView","view","projection","vClipPlane","textureMask"],["diffuseSampler"],t)),this._effect},i.prototype.animate=function(){if(this._started){var e=this._getEffect();if(this.emitter&&e.isReady()&&this.particleTexture&&this.particleTexture.isReady()&&this._currentRenderId!==this._scene.getRenderId()){var t;this._currentRenderId=this._scene.getRenderId(),this._scaledUpdateSpeed=this.updateSpeed*this._scene.getAnimationRatio(),this.manualEmitCount>-1?(t=this.manualEmitCount,this.manualEmitCount=0):t=this.emitRate;var i=t*this._scaledUpdateSpeed>>0;this._newPartsExcess+=t*this._scaledUpdateSpeed-i,this._newPartsExcess>1&&(i+=this._newPartsExcess>>0,this._newPartsExcess-=this._newPartsExcess>>0),this._alive=!1,this._stopped?i=0:(this._actualFrame+=this._scaledUpdateSpeed,this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()),this._update(i),this._stopped&&(this._alive||(this._started=!1,this.disposeOnStop&&this._scene._toBeDisposed.push(this)));for(var r=0,n=0;n<this.particles.length;n++){var o=this.particles[n];this._appendParticleVertex(r++,o,0,0),this._appendParticleVertex(r++,o,1,0),this._appendParticleVertex(r++,o,1,1),this._appendParticleVertex(r++,o,0,1)}this._scene.getEngine().updateDynamicVertexBuffer(this._vertexBuffer,this._vertices)}}},i.prototype.render=function(){var t=this._getEffect();if(!(this.emitter&&t.isReady()&&this.particleTexture&&this.particleTexture.isReady()&&this.particles.length))return 0;var r=this._scene.getEngine();r.enableEffect(t),r.setState(!1);var n=this._scene.getViewMatrix();if(t.setTexture("diffuseSampler",this.particleTexture),t.setMatrix("view",n),t.setMatrix("projection",this._scene.getProjectionMatrix()),t.setFloat4("textureMask",this.textureMask.r,this.textureMask.g,this.textureMask.b,this.textureMask.a),this._scene.clipPlane){var o=this._scene.clipPlane,s=n.clone();s.invert(),t.setMatrix("invView",s),t.setFloat4("vClipPlane",o.normal.x,o.normal.y,o.normal.z,o.d)}return r.bindBuffers(this._vertexBuffer,this._indexBuffer,this._vertexDeclaration,this._vertexStrideSize,t),r.setAlphaMode(this.blendMode===i.BLENDMODE_ONEONE?e.Engine.ALPHA_ONEONE:e.Engine.ALPHA_COMBINE),this.forceDepthWrite&&r.setDepthWrite(!0),r.draw(!0,0,6*this.particles.length),r.setAlphaMode(e.Engine.ALPHA_DISABLE),this.particles.length},i.prototype.dispose=function(){this._vertexBuffer&&(this._scene.getEngine()._releaseBuffer(this._vertexBuffer),this._vertexBuffer=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.particleTexture&&(this.particleTexture.dispose(),this.particleTexture=null);var e=this._scene.particleSystems.indexOf(this);this._scene.particleSystems.splice(e,1),this.onDispose&&this.onDispose()},i.prototype.clone=function(t,r){var n=new i(t,this._capacity,this._scene);return e.Tools.DeepCopy(this,n,["particles"],["_vertexDeclaration","_vertexStrideSize"]),void 0===r&&(r=this.emitter),n.emitter=r,this.particleTexture&&(n.particleTexture=new e.Texture(this.particleTexture.url,this._scene)),n.start(),n},i.BLENDMODE_ONEONE=0,i.BLENDMODE_STANDARD=1,i}();e.ParticleSystem=i}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(e,i,r,n,o){this.name=e,this.targetProperty=i,this.framePerSecond=r,this.dataType=n,this.loopMode=o,this._offsetsCache={},this._highLimitsCache={},this._stopped=!1,this.allowMatricesInterpolation=!1,this.targetPropertyPath=i.split("."),this.dataType=n,this.loopMode=void 0===o?t.ANIMATIONLOOPMODE_CYCLE:o}return t.CreateAndStartAnimation=function(i,r,n,o,s,a,h,c,l,u){var d=void 0;if(!isNaN(parseFloat(a))&&isFinite(a)?d=t.ANIMATIONTYPE_FLOAT:a instanceof e.Quaternion?d=t.ANIMATIONTYPE_QUATERNION:a instanceof e.Vector3?d=t.ANIMATIONTYPE_VECTOR3:a instanceof e.Vector2?d=t.ANIMATIONTYPE_VECTOR2:a instanceof e.Color3&&(d=t.ANIMATIONTYPE_COLOR3),null==d)return null;var f=new t(i,n,o,d,c),p=[];return p.push({frame:0,value:a}),p.push({frame:s,value:h}),f.setKeys(p),void 0!==l&&f.setEasingFunction(l),r.animations.push(f),r.getScene().beginAnimation(r,0,s,1===f.loopMode,1,u)},t.prototype.reset=function(){this._offsetsCache={},this._highLimitsCache={},this.currentFrame=0},t.prototype.isStopped=function(){return this._stopped},t.prototype.getKeys=function(){return this._keys},t.prototype.getEasingFunction=function(){return this._easingFunction},t.prototype.setEasingFunction=function(e){this._easingFunction=e},t.prototype.floatInterpolateFunction=function(e,t,i){return e+(t-e)*i},t.prototype.quaternionInterpolateFunction=function(t,i,r){return e.Quaternion.Slerp(t,i,r)},t.prototype.vector3InterpolateFunction=function(t,i,r){return e.Vector3.Lerp(t,i,r)},t.prototype.vector2InterpolateFunction=function(t,i,r){return e.Vector2.Lerp(t,i,r)},t.prototype.color3InterpolateFunction=function(t,i,r){return e.Color3.Lerp(t,i,r)},t.prototype.matrixInterpolateFunction=function(t,i,r){var n=new e.Vector3(0,0,0),o=new e.Quaternion,s=new e.Vector3(0,0,0);t.decompose(n,o,s);var a=new e.Vector3(0,0,0),h=new e.Quaternion,c=new e.Vector3(0,0,0);i.decompose(a,h,c);var l=this.vector3InterpolateFunction(n,a,r),u=this.quaternionInterpolateFunction(o,h,r),d=this.vector3InterpolateFunction(s,c,r);return e.Matrix.Compose(l,u,d)},t.prototype.clone=function(){var e=new t(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);return this._keys&&e.setKeys(this._keys),e},t.prototype.setKeys=function(e){this._keys=e.slice(0),this._offsetsCache={},this._highLimitsCache={}},t.prototype._getKeyValue=function(e){return"function"==typeof e?e():e},t.prototype._interpolate=function(e,i,r,n,o){if(r===t.ANIMATIONLOOPMODE_CONSTANT&&i>0)return o.clone?o.clone():o;this.currentFrame=e;var s=Math.max(0,Math.min(this._keys.length-1,Math.floor(this._keys.length*(e-this._keys[0].frame)/(this._keys[this._keys.length-1].frame-this._keys[0].frame))-1));if(this._keys[s].frame>=e)for(;s-1>=0&&this._keys[s].frame>=e;)s--;for(var a=s;a<this._keys.length;a++)if(this._keys[a+1].frame>=e){var h=this._getKeyValue(this._keys[a].value),c=this._getKeyValue(this._keys[a+1].value),l=(e-this._keys[a].frame)/(this._keys[a+1].frame-this._keys[a].frame);switch(null!=this._easingFunction&&(l=this._easingFunction.ease(l)),this.dataType){case t.ANIMATIONTYPE_FLOAT:switch(r){case t.ANIMATIONLOOPMODE_CYCLE:case t.ANIMATIONLOOPMODE_CONSTANT:return this.floatInterpolateFunction(h,c,l);case t.ANIMATIONLOOPMODE_RELATIVE:return n*i+this.floatInterpolateFunction(h,c,l)}break;case t.ANIMATIONTYPE_QUATERNION:var u=null;switch(r){case t.ANIMATIONLOOPMODE_CYCLE:case t.ANIMATIONLOOPMODE_CONSTANT:u=this.quaternionInterpolateFunction(h,c,l);break;case t.ANIMATIONLOOPMODE_RELATIVE:u=this.quaternionInterpolateFunction(h,c,l).add(n.scale(i))}return u;case t.ANIMATIONTYPE_VECTOR3:switch(r){case t.ANIMATIONLOOPMODE_CYCLE:case t.ANIMATIONLOOPMODE_CONSTANT:return this.vector3InterpolateFunction(h,c,l);case t.ANIMATIONLOOPMODE_RELATIVE:return this.vector3InterpolateFunction(h,c,l).add(n.scale(i))}case t.ANIMATIONTYPE_VECTOR2:switch(r){case t.ANIMATIONLOOPMODE_CYCLE:case t.ANIMATIONLOOPMODE_CONSTANT:return this.vector2InterpolateFunction(h,c,l);case t.ANIMATIONLOOPMODE_RELATIVE:return this.vector2InterpolateFunction(h,c,l).add(n.scale(i))}case t.ANIMATIONTYPE_COLOR3:switch(r){case t.ANIMATIONLOOPMODE_CYCLE:case t.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(h,c,l);case t.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(h,c,l).add(n.scale(i))}case t.ANIMATIONTYPE_MATRIX:switch(r){case t.ANIMATIONLOOPMODE_CYCLE:case t.ANIMATIONLOOPMODE_CONSTANT:if(this.allowMatricesInterpolation)return this.matrixInterpolateFunction(h,c,l);case t.ANIMATIONLOOPMODE_RELATIVE:return h}}break}return this._getKeyValue(this._keys[this._keys.length-1].value)},t.prototype.animate=function(i,r,n,o,s){if(!this.targetPropertyPath||this.targetPropertyPath.length<1)return this._stopped=!0,!1;var a=!0;if(0!==this._keys[0].frame){var h={frame:0,value:this._keys[0].value};this._keys.splice(0,0,h)}(r<this._keys[0].frame||r>this._keys[this._keys.length-1].frame)&&(r=this._keys[0].frame),(n<this._keys[0].frame||n>this._keys[this._keys.length-1].frame)&&(n=this._keys[this._keys.length-1].frame);var c,l=n-r,u=i*this.framePerSecond*s/1e3,d=0;if(u>l&&!o)a=!1,d=this._getKeyValue(this._keys[this._keys.length-1].value);else if(this.loopMode!==t.ANIMATIONLOOPMODE_CYCLE){var f=n.toString()+r.toString();if(!this._offsetsCache[f]){var p=this._interpolate(r,0,t.ANIMATIONLOOPMODE_CYCLE),m=this._interpolate(n,0,t.ANIMATIONLOOPMODE_CYCLE);switch(this.dataType){case t.ANIMATIONTYPE_FLOAT:this._offsetsCache[f]=m-p;break;case t.ANIMATIONTYPE_QUATERNION:this._offsetsCache[f]=m.subtract(p);break;case t.ANIMATIONTYPE_VECTOR3:this._offsetsCache[f]=m.subtract(p);case t.ANIMATIONTYPE_VECTOR2:this._offsetsCache[f]=m.subtract(p);case t.ANIMATIONTYPE_COLOR3:this._offsetsCache[f]=m.subtract(p)}this._highLimitsCache[f]=m}d=this._highLimitsCache[f],c=this._offsetsCache[f]}if(void 0===c)switch(this.dataType){case t.ANIMATIONTYPE_FLOAT:c=0;break;case t.ANIMATIONTYPE_QUATERNION:c=new e.Quaternion(0,0,0,0);break;case t.ANIMATIONTYPE_VECTOR3:c=e.Vector3.Zero();break;case t.ANIMATIONTYPE_VECTOR2:c=e.Vector2.Zero();break;case t.ANIMATIONTYPE_COLOR3:c=e.Color3.Black()}var g=u/l>>0,v=a?r+u%l:n,_=this._interpolate(v,g,this.loopMode,c,d);if(this.targetPropertyPath.length>1){for(var y=this._target[this.targetPropertyPath[0]],x=1;x<this.targetPropertyPath.length-1;x++)y=y[this.targetPropertyPath[x]];y[this.targetPropertyPath[this.targetPropertyPath.length-1]]=_}else this._target[this.targetPropertyPath[0]]=_;return this._target.markAsDirty&&this._target.markAsDirty(this.targetProperty),a||(this._stopped=!0),a},Object.defineProperty(t,"ANIMATIONTYPE_FLOAT",{get:function(){return t._ANIMATIONTYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ANIMATIONTYPE_VECTOR3",{get:function(){return t._ANIMATIONTYPE_VECTOR3},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ANIMATIONTYPE_VECTOR2",{get:function(){return t._ANIMATIONTYPE_VECTOR2},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ANIMATIONTYPE_QUATERNION",{get:function(){return t._ANIMATIONTYPE_QUATERNION},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ANIMATIONTYPE_MATRIX",{get:function(){return t._ANIMATIONTYPE_MATRIX},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ANIMATIONTYPE_COLOR3",{get:function(){return t._ANIMATIONTYPE_COLOR3},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ANIMATIONLOOPMODE_RELATIVE",{get:function(){return t._ANIMATIONLOOPMODE_RELATIVE},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ANIMATIONLOOPMODE_CYCLE",{get:function(){return t._ANIMATIONLOOPMODE_CYCLE},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ANIMATIONLOOPMODE_CONSTANT",{get:function(){return t._ANIMATIONLOOPMODE_CONSTANT},enumerable:!0,configurable:!0}),t._ANIMATIONTYPE_FLOAT=0,t._ANIMATIONTYPE_VECTOR3=1,t._ANIMATIONTYPE_QUATERNION=2,t._ANIMATIONTYPE_MATRIX=3,t._ANIMATIONTYPE_COLOR3=4,t._ANIMATIONTYPE_VECTOR2=5,t._ANIMATIONLOOPMODE_RELATIVE=0,t._ANIMATIONLOOPMODE_CYCLE=1,t._ANIMATIONLOOPMODE_CONSTANT=2,t}();e.Animation=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function e(e,t,i,r,n,o,s,a){void 0===i&&(i=0),void 0===r&&(r=100),void 0===n&&(n=!1),void 0===o&&(o=1),this.target=t,this.fromFrame=i,this.toFrame=r,this.loopAnimation=n,this.speedRatio=o,this.onAnimationEnd=s,this._animations=new Array,this._paused=!1,this.animationStarted=!1,a&&this.appendAnimations(t,a),this._scene=e,e._activeAnimatables.push(this)}return e.prototype.appendAnimations=function(e,t){for(var i=0;i<t.length;i++){var r=t[i];r._target=e,this._animations.push(r)}},e.prototype.getAnimationByTargetProperty=function(e){for(var t=this._animations,i=0;i<t.length;i++)if(t[i].targetProperty===e)return t[i];return null},e.prototype.reset=function(){for(var e=this._animations,t=0;t<e.length;t++)e[t].reset();this._localDelayOffset=null,this._pausedDelay=null},e.prototype.pause=function(){this._paused||(this._paused=!0)},e.prototype.restart=function(){this._paused=!1},e.prototype.stop=function(){var e=this._scene._activeAnimatables.indexOf(this);e>-1&&this._scene._activeAnimatables.splice(e,1),this.onAnimationEnd&&this.onAnimationEnd()},e.prototype._animate=function(e){if(this._paused)return this._pausedDelay||(this._pausedDelay=e),!0;this._localDelayOffset?this._pausedDelay&&(this._localDelayOffset+=e-this._pausedDelay,this._pausedDelay=null):this._localDelayOffset=e;for(var t=!1,i=this._animations,r=0;r<i.length;r++){var n=i[r].animate(e-this._localDelayOffset,this.fromFrame,this.toFrame,this.loopAnimation,this.speedRatio);t=t||n}return t||(r=this._scene._activeAnimatables.indexOf(this),this._scene._activeAnimatables.splice(r,1)),!t&&this.onAnimationEnd&&this.onAnimationEnd(),t},e}();e.Animatable=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function e(){this._easingMode=e.EASINGMODE_EASEIN}return Object.defineProperty(e,"EASINGMODE_EASEIN",{get:function(){return e._EASINGMODE_EASEIN},enumerable:!0,configurable:!0}),Object.defineProperty(e,"EASINGMODE_EASEOUT",{get:function(){return e._EASINGMODE_EASEOUT},enumerable:!0,configurable:!0}),Object.defineProperty(e,"EASINGMODE_EASEINOUT",{get:function(){return e._EASINGMODE_EASEINOUT},enumerable:!0,configurable:!0}),e.prototype.setEasingMode=function(e){var t=Math.min(Math.max(e,0),2);this._easingMode=t},e.prototype.getEasingMode=function(){return this._easingMode},e.prototype.easeInCore=function(e){throw new Error("You must implement this method")},e.prototype.ease=function(t){switch(this._easingMode){case e.EASINGMODE_EASEIN:return this.easeInCore(t);case e.EASINGMODE_EASEOUT:return 1-this.easeInCore(1-t)}return t>=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e._EASINGMODE_EASEIN=0,e._EASINGMODE_EASEOUT=1,e._EASINGMODE_EASEINOUT=2,e}();e.EasingFunction=t;var i=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t}(t);e.CircleEase=i;var r=function(e){function t(t){void 0===t&&(t=1),e.call(this),this.amplitude=t}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)},t}(t);e.BackEase=r;var n=function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=2),e.call(this),this.bounces=t,this.bounciness=i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;1>=i&&(i=1.001);var r=Math.pow(i,t),n=1-i,o=(1-r)/n+.5*r,s=e*o,a=Math.log(-s*(1-i)+1)/Math.log(i),h=Math.floor(a),c=h+1,l=(1-Math.pow(i,h))/(n*o),u=.5*(l+(1-Math.pow(i,c))/(n*o)),d=e-u,f=u-l;return-Math.pow(1/i,t-h)/(f*f)*(d-f)*(d+f)},t}(t);e.BounceEase=n;var o=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e},t}(t);e.CubicEase=o;var s=function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=3),e.call(this),this.oscillations=t,this.springiness=i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),i=Math.max(0,this.springiness);return(0==i?e:(Math.exp(i*e)-1)/(Math.exp(i)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)},t}(t);e.ElasticEase=s;var a=function(e){function t(t){void 0===t&&(t=2),e.call(this),this.exponent=t}return __extends(t,e),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t}(t);e.ExponentialEase=a;var h=function(e){function t(t){void 0===t&&(t=2),e.call(this),this.power=t}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t}(t);e.PowerEase=h;var c=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e},t}(t);e.QuadraticEase=c;var l=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t}(t);e.QuarticEase=l;var u=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t}(t);e.QuinticEase=u;var d=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t}(t);e.SineEase=d;var f=function(t){function i(e,i,r,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=1),t.call(this),this.x1=e,this.y1=i,this.x2=r,this.y2=n}return __extends(i,t),i.prototype.easeInCore=function(t){return e.BezierCurve.interpolate(t,this.x1,this.y1,this.x2,this.y2)},i}(t);e.BezierCurveEase=f}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t,i,r){void 0===r&&(r=2),this.maxDepth=r,this.dynamicContent=new Array,this._maxBlockCapacity=i||64,this._selectionContent=new e.SmartArray(1024),this._creationFunc=t}return t.prototype.update=function(e,i,r){t._CreateBlocks(e,i,r,this._maxBlockCapacity,0,this.maxDepth,this,this._creationFunc)},t.prototype.addMesh=function(e){for(var t=0;t<this.blocks.length;t++){this.blocks[t].addEntry(e)}},t.prototype.select=function(e,t){this._selectionContent.reset();for(var i=0;i<this.blocks.length;i++){this.blocks[i].select(e,this._selectionContent,t)}return t?this._selectionContent.concat(this.dynamicContent):this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},t.prototype.intersects=function(e,t,i){this._selectionContent.reset();for(var r=0;r<this.blocks.length;r++){this.blocks[r].intersects(e,t,this._selectionContent,i)}return i?this._selectionContent.concat(this.dynamicContent):this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},t.prototype.intersectsRay=function(e){this._selectionContent.reset();for(var t=0;t<this.blocks.length;t++){this.blocks[t].intersectsRay(e,this._selectionContent)}return this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},t._CreateBlocks=function(t,i,r,n,o,s,a,h){a.blocks=new Array;for(var c=new e.Vector3((i.x-t.x)/2,(i.y-t.y)/2,(i.z-t.z)/2),l=0;2>l;l++)for(var u=0;2>u;u++)for(var d=0;2>d;d++){var f=t.add(c.multiplyByFloats(l,u,d)),p=t.add(c.multiplyByFloats(l+1,u+1,d+1)),m=new e.OctreeBlock(f,p,n,o+1,s,h);m.addEntries(r),a.blocks.push(m)}},t.CreationFuncForMeshes=function(e,t){!e.isBlocked&&e.getBoundingInfo().boundingBox.intersectsMinMax(t.minPoint,t.maxPoint)&&t.entries.push(e)},t.CreationFuncForSubMeshes=function(e,t){e.getBoundingInfo().boundingBox.intersectsMinMax(t.minPoint,t.maxPoint)&&t.entries.push(e)},t}();e.Octree=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(e,t,i,r,n,o){this.entries=new Array,this._boundingVectors=new Array,this._capacity=i,this._depth=r,this._maxDepth=n,this._creationFunc=o,this._minPoint=e,this._maxPoint=t,this._boundingVectors.push(e.clone()),this._boundingVectors.push(t.clone()),this._boundingVectors.push(e.clone()),this._boundingVectors[2].x=t.x,this._boundingVectors.push(e.clone()),this._boundingVectors[3].y=t.y,this._boundingVectors.push(e.clone()),this._boundingVectors[4].z=t.z,this._boundingVectors.push(t.clone()),this._boundingVectors[5].z=e.z,this._boundingVectors.push(t.clone()),this._boundingVectors[6].x=e.x,this._boundingVectors.push(t.clone()),this._boundingVectors[7].y=e.y}return Object.defineProperty(t.prototype,"capacity",{get:function(){return this._capacity},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minPoint",{get:function(){return this._minPoint},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxPoint",{get:function(){return this._maxPoint},enumerable:!0,configurable:!0}),t.prototype.addEntry=function(e){if(this.blocks)for(var t=0;t<this.blocks.length;t++){this.blocks[t].addEntry(e)}else this._creationFunc(e,this),this.entries.length>this.capacity&&this._depth<this._maxDepth&&this.createInnerBlocks()},t.prototype.addEntries=function(e){for(var t=0;t<e.length;t++){var i=e[t];this.addEntry(i)}},t.prototype.select=function(t,i,r){if(e.BoundingBox.IsInFrustum(this._boundingVectors,t)){if(this.blocks){for(var n=0;n<this.blocks.length;n++){this.blocks[n].select(t,i,r)}return}r?i.concat(this.entries):i.concatWithNoDuplicate(this.entries)}},t.prototype.intersects=function(t,i,r,n){if(e.BoundingBox.IntersectsSphere(this._minPoint,this._maxPoint,t,i)){if(this.blocks){for(var o=0;o<this.blocks.length;o++){this.blocks[o].intersects(t,i,r,n)}return}n?r.concat(this.entries):r.concatWithNoDuplicate(this.entries)}},t.prototype.intersectsRay=function(e,t){if(e.intersectsBoxMinMax(this._minPoint,this._maxPoint)){if(this.blocks){for(var i=0;i<this.blocks.length;i++){this.blocks[i].intersectsRay(e,t)}return}t.concatWithNoDuplicate(this.entries)}},t.prototype.createInnerBlocks=function(){e.Octree._CreateBlocks(this._minPoint,this._maxPoint,this.entries,this._capacity,this._depth,this._maxDepth,this,this._creationFunc)},t}();e.OctreeBlock=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o){t.call(this,i,r.getScene()),this.name=i,this.children=new Array,this.animations=new Array,this._worldTransform=new e.Matrix,this._absoluteTransform=new e.Matrix,this._invertedAbsoluteTransform=new e.Matrix,this._skeleton=r,this._matrix=o,this._baseMatrix=o,r.bones.push(this),n?(this._parent=n,n.children.push(this)):this._parent=null,this._updateDifferenceMatrix()}return __extends(i,t),i.prototype.getParent=function(){return this._parent},i.prototype.getLocalMatrix=function(){return this._matrix},i.prototype.getBaseMatrix=function(){return this._baseMatrix},i.prototype.getWorldMatrix=function(){return this._worldTransform},i.prototype.getInvertedAbsoluteTransform=function(){return this._invertedAbsoluteTransform},i.prototype.getAbsoluteMatrix=function(){for(var e=this._matrix.clone(),t=this._parent;t;)e=e.multiply(t.getLocalMatrix()),t=t.getParent();return e},i.prototype.updateMatrix=function(e){this._matrix=e,this._skeleton._markAsDirty(),this._updateDifferenceMatrix()},i.prototype._updateDifferenceMatrix=function(){this._parent?this._matrix.multiplyToRef(this._parent._absoluteTransform,this._absoluteTransform):this._absoluteTransform.copyFrom(this._matrix),this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);for(var e=0;e<this.children.length;e++)this.children[e]._updateDifferenceMatrix()},i.prototype.markAsDirty=function(){this._currentRenderId++,this._skeleton._markAsDirty()},i}(e.Node);e.Bone=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t,i,r){this.name=t,this.id=i,this.bones=new Array,this._isDirty=!0,this._identity=e.Matrix.Identity(),this.bones=[],this._scene=r,r.skeletons.push(this),this.prepare(),this._isDirty=!0}return t.prototype.getTransformMatrices=function(){return this._transformMatrices},t.prototype.getScene=function(){return this._scene},t.prototype._markAsDirty=function(){this._isDirty=!0},t.prototype.prepare=function(){if(this._isDirty){this._transformMatrices&&this._transformMatrices.length===16*(this.bones.length+1)||(this._transformMatrices=new Float32Array(16*(this.bones.length+1)));for(var e=0;e<this.bones.length;e++){var t=this.bones[e],i=t.getParent();i?t.getLocalMatrix().multiplyToRef(i.getWorldMatrix(),t.getWorldMatrix()):t.getWorldMatrix().copyFrom(t.getLocalMatrix()),t.getInvertedAbsoluteTransform().multiplyToArray(t.getWorldMatrix(),this._transformMatrices,16*e)}this._identity.copyToArray(this._transformMatrices,16*this.bones.length),this._isDirty=!1,this._scene._activeBones+=this.bones.length}},t.prototype.getAnimatables=function(){if(!this._animatables||this._animatables.length!==this.bones.length){this._animatables=[];for(var e=0;e<this.bones.length;e++)this._animatables.push(this.bones[e])}return this._animatables},t.prototype.clone=function(i,r){for(var n=new t(i,r||i,this._scene),o=0;o<this.bones.length;o++){var s=this.bones[o],a=null;if(s.getParent()){var h=this.bones.indexOf(s.getParent());a=n.bones[h]}var c=new e.Bone(s.name,n,a,s.getBaseMatrix());e.Tools.DeepCopy(s.animations,c.animations)}return n},t}();e.Skeleton=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t,i,r,n,o,s,a,h,c,l,u){void 0===a&&(a=e.Texture.NEAREST_SAMPLINGMODE),void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT),this.name=t,this.width=-1,this.height=-1,this._reusable=!1,this._textures=new e.SmartArray(2),this._currentRenderTextureInd=0,null!=s?(this._camera=s,this._scene=s.getScene(),s.attachPostProcess(this),this._engine=this._scene.getEngine()):this._engine=h,this._renderRatio=o,this.renderTargetSamplingMode=a||e.Texture.NEAREST_SAMPLINGMODE,this._reusable=c||!1,this._textureType=u,(n=n||[]).push("textureSampler"),this._effect=this._engine.createEffect({vertex:"postprocess",fragment:i},["position"],r||[],n,void 0!==l?l:"")}return t.prototype.isReusable=function(){return this._reusable},t.prototype.activate=function(t,i){var r=(t=t||this._camera).getScene(),n=t.getEngine().getCaps().maxTextureSize,o=(i?i._width:this._engine.getRenderingCanvas().width)*this._renderRatio|0,s=(i?i._height:this._engine.getRenderingCanvas().height)*this._renderRatio|0;if(o=this._renderRatio.width||e.Tools.GetExponentOfTwo(o,n),s=this._renderRatio.height||e.Tools.GetExponentOfTwo(s,n),this.width!==o||this.height!==s){if(this._textures.length>0){for(var a=0;a<this._textures.length;a++)this._engine._releaseTexture(this._textures.data[a]);this._textures.reset()}this.width=o,this.height=s,this._textures.push(this._engine.createRenderTargetTexture({width:this.width,height:this.height},{generateMipMaps:!1,generateDepthBuffer:t._postProcesses.indexOf(this)===t._postProcessesTakenIndices[0],samplingMode:this.renderTargetSamplingMode,type:this._textureType})),this._reusable&&this._textures.push(this._engine.createRenderTargetTexture({width:this.width,height:this.height},{generateMipMaps:!1,generateDepthBuffer:t._postProcesses.indexOf(this)===t._postProcessesTakenIndices[0],samplingMode:this.renderTargetSamplingMode,type:this._textureType})),this.onSizeChanged&&this.onSizeChanged()}this._engine.bindFramebuffer(this._textures.data[this._currentRenderTextureInd]),this.onActivate&&this.onActivate(t),this.clearColor?this._engine.clear(this.clearColor,!0,!0):this._engine.clear(r.clearColor,r.autoClear||r.forceWireframe,!0),this._reusable&&(this._currentRenderTextureInd=(this._currentRenderTextureInd+1)%2)},t.prototype.apply=function(){return this._effect.isReady()?(this._engine.enableEffect(this._effect),this._engine.setState(!1),this._engine.setAlphaMode(e.Engine.ALPHA_DISABLE),this._engine.setDepthBuffer(!1),this._engine.setDepthWrite(!1),this._effect._bindTexture("textureSampler",this._textures.data[this._currentRenderTextureInd]),this.onApply&&this.onApply(this._effect),this._effect):null},t.prototype.dispose=function(e){if(e=e||this._camera,this._textures.length>0){for(var t=0;t<this._textures.length;t++)this._engine._releaseTexture(this._textures.data[t]);this._textures.reset()}e&&(e.detachPostProcess(this),e._postProcesses.indexOf(this)===e._postProcessesTakenIndices[0]&&e._postProcessesTakenIndices.length>0&&(this._camera._postProcesses[e._postProcessesTakenIndices[0]].width=-1))},t}();e.PostProcess=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function e(e){this._vertexDeclaration=[2],this._vertexStrideSize=8,this._scene=e}return e.prototype._prepareBuffers=function(){if(!this._vertexBuffer){var e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffer=this._scene.getEngine().createVertexBuffer(e);var t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(t)}},e.prototype._prepareFrame=function(e){var t=this._scene.activeCamera._postProcesses;return!(0===this._scene.activeCamera._postProcessesTakenIndices.length||!this._scene.postProcessesEnabled)&&(t[this._scene.activeCamera._postProcessesTakenIndices[0]].activate(this._scene.activeCamera,e),!0)},e.prototype.directRender=function(e,t){for(var i=this._scene.getEngine(),r=0;r<e.length;r++){r<e.length-1?e[r+1].activate(this._scene.activeCamera,t):t?i.bindFramebuffer(t):i.restoreDefaultFramebuffer();var n=e[r],o=n.apply();o&&(n.onBeforeRender&&n.onBeforeRender(o),this._prepareBuffers(),i.bindBuffers(this._vertexBuffer,this._indexBuffer,this._vertexDeclaration,this._vertexStrideSize,o),i.draw(!0,0,6),n.onAfterRender&&n.onAfterRender(o))}i.setDepthBuffer(!0),i.setDepthWrite(!0)},e.prototype._finalizeFrame=function(e,t,i,r){r=r||this._scene.activeCamera._postProcesses;var n=this._scene.activeCamera._postProcessesTakenIndices;if(0!==n.length&&this._scene.postProcessesEnabled){for(var o=this._scene.getEngine(),s=0;s<n.length&&(s<n.length-1?r[n[s+1]].activate(this._scene.activeCamera):t?o.bindFramebuffer(t,i):o.restoreDefaultFramebuffer(),!e);s++){var a=r[n[s]],h=a.apply();h&&(a.onBeforeRender&&a.onBeforeRender(h),this._prepareBuffers(),o.bindBuffers(this._vertexBuffer,this._indexBuffer,this._vertexDeclaration,this._vertexStrideSize,h),o.draw(!0,0,6),a.onAfterRender&&a.onAfterRender(h))}o.setDepthBuffer(!0),o.setDepthWrite(!0)}},e.prototype.dispose=function(){this._vertexBuffer&&(this._scene.getEngine()._releaseBuffer(this._vertexBuffer),this._vertexBuffer=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null)},e}();e.PostProcessManager=t}(BABYLON||(BABYLON={})),function(e){var t=function(e){function t(t,i,r,n,o,s){e.call(this,t,"pass",null,null,i,r,n,o,s)}return __extends(t,e),t}(e.PostProcess);e.PassPostProcess=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o,s,a,h,c){var l=this;void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),t.call(this,i,"blur",["screenSize","direction","blurWidth"],null,o,s,a,h,c),this.direction=r,this.blurWidth=n,this.onApply=function(e){e.setFloat2("screenSize",l.width,l.height),e.setVector2("direction",l.direction),e.setFloat("blurWidth",l.blurWidth)}}return __extends(i,t),i}(e.PostProcess);e.BlurPostProcess=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o,s,a,h,c,l,u){var d=this;t.call(this,i,"refraction",["baseColor","depth","colorLevel"],["refractionSampler"],a,h,c,l,u),this.color=n,this.depth=o,this.colorLevel=s,this.onActivate=function(t){d._refRexture=d._refRexture||new e.Texture(r,t.getScene())},this.onApply=function(e){e.setColor3("baseColor",d.color),e.setFloat("depth",d.depth),e.setFloat("colorLevel",d.colorLevel),e.setTexture("refractionSampler",d._refRexture)}}return __extends(i,t),i.prototype.dispose=function(e){this._refRexture&&this._refRexture.dispose(),t.prototype.dispose.call(this,e)},i}(e.PostProcess);e.RefractionPostProcess=t}(BABYLON||(BABYLON={})),function(e){var t=function(e){function t(t,i,r,n,o,s){e.call(this,t,"blackAndWhite",null,null,i,r,n,o,s)}return __extends(t,e),t}(e.PostProcess);e.BlackAndWhitePostProcess=t}(BABYLON||(BABYLON={})),function(e){var t=function(e){function t(t,i,r,n,o,s,a){var h=this;e.call(this,t,"convolution",["kernel","screenSize"],null,r,n,o,s,a),this.kernel=i,this.onApply=function(e){e.setFloat2("screenSize",h.width,h.height),e.setArray("kernel",h.kernel)}}return __extends(t,e),t.EdgeDetect0Kernel=[1,0,-1,0,0,0,-1,0,1],t.EdgeDetect1Kernel=[0,1,0,1,-4,1,0,1,0],t.EdgeDetect2Kernel=[-1,-1,-1,-1,8,-1,-1,-1,-1],t.SharpenKernel=[0,-1,0,-1,5,-1,0,-1,0],t.EmbossKernel=[-2,-1,0,-1,1,1,0,1,2],t.GaussianKernel=[0,1,0,1,1,1,0,1,0],t}(e.PostProcess);e.ConvolutionPostProcess=t}(BABYLON||(BABYLON={})),function(e){var t=function(e){function t(t,i,r,n,o,s,a){var h=this;e.call(this,t,"filter",["kernelMatrix"],null,r,n,o,s,a),this.kernelMatrix=i,this.onApply=function(e){e.setMatrix("kernelMatrix",h.kernelMatrix)}}return __extends(t,e),t}(e.PostProcess);e.FilterPostProcess=t}(BABYLON||(BABYLON={})),function(e){var t=function(e){function t(t,i,r,n,o,s){var a=this;e.call(this,t,"fxaa",["texelSize"],null,i,r,n,o,s),this.onSizeChanged=function(){a.texelWidth=1/a.width,a.texelHeight=1/a.height},this.onApply=function(e){e.setFloat2("texelSize",a.texelWidth,a.texelHeight)}}return __extends(t,e),t}(e.PostProcess);e.FxaaPostProcess=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o,s){var a=this;t.call(this,i,"stereoscopicInterlace",["stepSize"],["camASampler"],1,r,s,r.getScene().getEngine(),!1,o?"#define IS_STEREOSCOPIC_HORIZ 1":void 0),this._stepSize=new e.Vector2(1/this.width,1/this.height),this.onSizeChanged=function(){a._stepSize=new e.Vector2(1/a.width,1/a.height)},this.onApply=function(e){e.setTextureFromPostProcess("camASampler",n),e.setFloat2("stepSize",a._stepSize.x,a._stepSize.y)}}return __extends(i,t),i}(e.PostProcess);e.StereoscopicInterlacePostProcess=t}(BABYLON||(BABYLON={})),function(e){var t=function(){return function(t,i,r,n,o){this.size=t,this.position=i,this.dispose=function(){this.texture&&this.texture.dispose();var e=this._system.lensFlares.indexOf(this);this._system.lensFlares.splice(e,1)},this.color=r||new e.Color3(1,1,1),this.texture=n?new e.Texture(n,o.getScene(),!0):null,this._system=o,o.lensFlares.push(this)}}();e.LensFlare=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(e,t,i){this.name=e,this.lensFlares=new Array,this.borderLimit=300,this.layerMask=268435455,this._vertexDeclaration=[2],this._vertexStrideSize=8,this._isEnabled=!0,this._scene=i,this._emitter=t,i.lensFlareSystems.push(this),this.meshesSelectionPredicate=function(e){return e.material&&e.isVisible&&e.isEnabled()&&e.isBlocker&&0!=(e.layerMask&i.activeCamera.layerMask)};var r=[];r.push(1,1),r.push(-1,1),r.push(-1,-1),r.push(1,-1),this._vertexBuffer=i.getEngine().createVertexBuffer(r);var n=[];n.push(0),n.push(1),n.push(2),n.push(0),n.push(2),n.push(3),this._indexBuffer=i.getEngine().createIndexBuffer(n),this._effect=this._scene.getEngine().createEffect("lensFlare",["position"],["color","viewportMatrix"],["textureSampler"],"")}return Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e},enumerable:!0,configurable:!0}),t.prototype.getScene=function(){return this._scene},t.prototype.getEmitter=function(){return this._emitter},t.prototype.setEmitter=function(e){this._emitter=e},t.prototype.getEmitterPosition=function(){return this._emitter.getAbsolutePosition?this._emitter.getAbsolutePosition():this._emitter.position},t.prototype.computeEffectivePosition=function(t){var i=this.getEmitterPosition();return i=e.Vector3.Project(i,e.Matrix.Identity(),this._scene.getTransformMatrix(),t),this._positionX=i.x,this._positionY=i.y,(i=e.Vector3.TransformCoordinates(this.getEmitterPosition(),this._scene.getViewMatrix())).z>0&&this._positionX>t.x&&this._positionX<t.x+t.width&&this._positionY>t.y&&this._positionY<t.y+t.height},t.prototype._isVisible=function(){if(!this._isEnabled)return!1;var t=this.getEmitterPosition().subtract(this._scene.activeCamera.position),i=t.length();t.normalize();var r=new e.Ray(this._scene.activeCamera.position,t),n=this._scene.pickWithRay(r,this.meshesSelectionPredicate,!0);return!n.hit||n.distance>i},t.prototype.render=function(){if(!this._effect.isReady())return!1;var t,i,r=this._scene.getEngine(),n=this._scene.activeCamera.viewport.toGlobal(r);if(!this.computeEffectivePosition(n))return!1;if(!this._isVisible())return!1;var o=(t=this._positionX<this.borderLimit+n.x?this.borderLimit+n.x-this._positionX:this._positionX>n.x+n.width-this.borderLimit?this._positionX-n.x-n.width+this.borderLimit:0)>(i=this._positionY<this.borderLimit+n.y?this.borderLimit+n.y-this._positionY:this._positionY>n.y+n.height-this.borderLimit?this._positionY-n.y-n.height+this.borderLimit:0)?t:i;o>this.borderLimit&&(o=this.borderLimit);var s=1-o/this.borderLimit;if(0>s)return!1;s>1&&(s=1);var a=n.x+n.width/2,h=n.y+n.height/2,c=a-this._positionX,l=h-this._positionY;r.enableEffect(this._effect),r.setState(!1),r.setDepthBuffer(!1),r.setAlphaMode(e.Engine.ALPHA_ONEONE),r.bindBuffers(this._vertexBuffer,this._indexBuffer,this._vertexDeclaration,this._vertexStrideSize,this._effect);for(var u=0;u<this.lensFlares.length;u++){var d=this.lensFlares[u],f=a-c*d.position,p=h-l*d.position,m=d.size,g=d.size*r.getAspectRatio(this._scene.activeCamera),v=f/n.width*2-1,_=1-p/n.height*2,y=e.Matrix.FromValues(m/2,0,0,0,0,g/2,0,0,0,0,1,0,v,_,0,1);this._effect.setMatrix("viewportMatrix",y),this._effect.setTexture("textureSampler",d.texture),this._effect.setFloat4("color",d.color.r*s,d.color.g*s,d.color.b*s,1),r.draw(!0,0,6)}return r.setDepthBuffer(!0),r.setAlphaMode(e.Engine.ALPHA_DISABLE),!0},t.prototype.dispose=function(){for(this._vertexBuffer&&(this._scene.getEngine()._releaseBuffer(this._vertexBuffer),this._vertexBuffer=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null);this.lensFlares.length;)this.lensFlares[0].dispose();var e=this._scene.lensFlareSystems.indexOf(this);this._scene.lensFlareSystems.splice(e,1)},t}();e.LensFlareSystem=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(){this._registeredMeshes=[],this._physicsMaterials=[],this.updateBodyPosition=function(e){for(var t=0;t<this._registeredMeshes.length;t++){var i=this._registeredMeshes[t];if(i.mesh===e||i.mesh===e.parent){var r=i.body,n=e.getBoundingInfo().boundingBox.center;return r.position.set(n.x,n.z,n.y),r.quaternion.x=e.rotationQuaternion.x,r.quaternion.z=e.rotationQuaternion.y,r.quaternion.y=e.rotationQuaternion.z,void(r.quaternion.w=-e.rotationQuaternion.w)}}}}return t.prototype.initialize=function(e){void 0===e&&(e=10),this._world=new CANNON.World,this._world.broadphase=new CANNON.NaiveBroadphase,this._world.solver.iterations=e},t.prototype._checkWithEpsilon=function(t){return t<e.PhysicsEngine.Epsilon?e.PhysicsEngine.Epsilon:t},t.prototype.runOneStep=function(t){this._world.step(t);for(var i=0;i<this._registeredMeshes.length;i++){var r=this._registeredMeshes[i];if(!r.isChild){var n=r.body.position.x,o=r.body.position.y,s=r.body.position.z,a=r.delta;a?(r.mesh.position.x=n+a.x,r.mesh.position.y=s+a.y,r.mesh.position.z=o+a.z):(r.mesh.position.x=n,r.mesh.position.y=s,r.mesh.position.z=o),r.mesh.rotationQuaternion||(r.mesh.rotationQuaternion=new e.Quaternion(0,0,0,1)),r.mesh.rotationQuaternion.x=r.body.quaternion.x,r.mesh.rotationQuaternion.y=r.body.quaternion.z,r.mesh.rotationQuaternion.z=r.body.quaternion.y,r.mesh.rotationQuaternion.w=-r.body.quaternion.w}}},t.prototype.setGravity=function(e){this._world.gravity.set(e.x,e.z,e.y)},t.prototype.registerMesh=function(t,i,r){switch(this.unregisterMesh(t),t.computeWorldMatrix(!0),i){case e.PhysicsEngine.SphereImpostor:var n=t.getBoundingInfo().boundingBox,o=n.maximumWorld.x-n.minimumWorld.x,s=n.maximumWorld.y-n.minimumWorld.y,a=n.maximumWorld.z-n.minimumWorld.z;return this._createSphere(Math.max(this._checkWithEpsilon(o),this._checkWithEpsilon(s),this._checkWithEpsilon(a))/2,t,r);case e.PhysicsEngine.BoxImpostor:var h=(n=t.getBoundingInfo().boundingBox).minimumWorld,c=n.maximumWorld.subtract(h).scale(.5);return this._createBox(this._checkWithEpsilon(c.x),this._checkWithEpsilon(c.y),this._checkWithEpsilon(c.z),t,r);case e.PhysicsEngine.PlaneImpostor:return this._createPlane(t,r);case e.PhysicsEngine.MeshImpostor:var l=t.getVerticesData(e.VertexBuffer.PositionKind),u=t.getIndices();return this._createConvexPolyhedron(l,u,t,r)}return null},t.prototype._createSphere=function(e,t,i){var r=new CANNON.Sphere(e);return i?this._createRigidBodyFromShape(r,t,i.mass,i.friction,i.restitution):r},t.prototype._createBox=function(e,t,i,r,n){var o=new CANNON.Box(new CANNON.Vec3(e,i,t));return n?this._createRigidBodyFromShape(o,r,n.mass,n.friction,n.restitution):o},t.prototype._createPlane=function(e,t){var i=new CANNON.Plane;return t?this._createRigidBodyFromShape(i,e,t.mass,t.friction,t.restitution):i},t.prototype._createConvexPolyhedron=function(t,i,r,n){var o=[],s=[];r.computeWorldMatrix(!0);for(var a=0;a<t.length;a+=3){var h=e.Vector3.Zero();e.Vector3.TransformNormalFromFloatsToRef(t[a],t[a+1],t[a+2],r.getWorldMatrix(),h),o.push(new CANNON.Vec3(h.x,h.z,h.y))}for(var c=0;c<i.length;c+=3)s.push([i[c],i[c+2],i[c+1]]);var l=new CANNON.ConvexPolyhedron(o,s);return n?this._createRigidBodyFromShape(l,r,n.mass,n.friction,n.restitution):l},t.prototype._addMaterial=function(e,t){var i,r;for(i=0;i<this._physicsMaterials.length;i++)if((r=this._physicsMaterials[i]).friction===e&&r.restitution===t)return r;var n=new CANNON.Material;for(n.friction=e,n.restitution=t,this._physicsMaterials.push(n),i=0;i<this._physicsMaterials.length;i++){r=this._physicsMaterials[i];var o=new CANNON.ContactMaterial(r,n,r.friction*n.friction,r.restitution*n.restitution);o.contactEquationStiffness=1e10,o.contactEquationRegularizationTime=10,this._world.addContactMaterial(o)}return n},t.prototype._createRigidBodyFromShape=function(t,i,r,n,o){var s=null;i.rotationQuaternion&&(s=i.rotationQuaternion.clone(),i.rotationQuaternion=new e.Quaternion(0,0,0,1));var a=i.getBoundingInfo().boundingBox,h=i.position.subtract(a.center),c=this._addMaterial(n,o),l=new CANNON.RigidBody(r,t,c);return s&&(l.quaternion.x=s.x,l.quaternion.z=s.y,l.quaternion.y=s.z,l.quaternion.w=-s.w),l.position.set(a.center.x,a.center.z,a.center.y),this._world.add(l),this._registeredMeshes.push({mesh:i,body:l,material:c,delta:h}),l},t.prototype.registerMeshesAsCompound=function(e,t){for(var i=new CANNON.Compound,r=0;r<e.length;r++){var n=e[r].mesh,o=this.registerMesh(n,e[r].impostor);0==r?i.addChild(o,new CANNON.Vec3(0,0,0)):i.addChild(o,new CANNON.Vec3(n.position.x,n.position.z,n.position.y))}var s=e[0].mesh,a=this._createRigidBodyFromShape(i,s,t.mass,t.friction,t.restitution);return a.parts=e,a},t.prototype._unbindBody=function(e){for(var t=0;t<this._registeredMeshes.length;t++){var i=this._registeredMeshes[t];i.body===e&&(i.body=null,i.delta=0)}},t.prototype.unregisterMesh=function(e){for(var t=0;t<this._registeredMeshes.length;t++){var i=this._registeredMeshes[t];if(i.mesh===e)return i.body&&(this._world.remove(i.body),this._unbindBody(i.body)),void this._registeredMeshes.splice(t,1)}},t.prototype.applyImpulse=function(e,t,i){for(var r=new CANNON.Vec3(i.x,i.z,i.y),n=new CANNON.Vec3(t.x,t.z,t.y),o=0;o<this._registeredMeshes.length;o++){var s=this._registeredMeshes[o];if(s.mesh===e)return void s.body.applyImpulse(n,r)}},t.prototype.createLink=function(e,t,i,r){for(var n=null,o=null,s=0;s<this._registeredMeshes.length;s++){var a=this._registeredMeshes[s];a.mesh===e?n=a.body:a.mesh===t&&(o=a.body)}if(!n||!o)return!1;var h=new CANNON.PointToPointConstraint(n,new CANNON.Vec3(i.x,i.z,i.y),o,new CANNON.Vec3(r.x,r.z,r.y));return this._world.addConstraint(h),!0},t.prototype.dispose=function(){for(;this._registeredMeshes.length;)this.unregisterMesh(this._registeredMeshes[0].mesh)},t.prototype.isSupported=function(){return void 0!==window.CANNON},t}();e.CannonJSPlugin=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(){this._registeredMeshes=[],this.updateBodyPosition=function(e){for(var t=0;t<this._registeredMeshes.length;t++){var i=this._registeredMeshes[t];if(i.mesh===e||i.mesh===e.parent){var r=i.body.body;e.computeWorldMatrix(!0);var n=e.getBoundingInfo().boundingBox.center;return r.setPosition(new OIMO.Vec3(n.x,n.y,n.z)),r.setRotation(new OIMO.Vec3(e.rotation.x,e.rotation.y,e.rotation.z)),void(r.sleeping=!1)}if(i.mesh.parent===e){e.computeWorldMatrix(!0),i.mesh.computeWorldMatrix(!0);var o=i.mesh.getAbsolutePosition(),s=e.rotation;return(r=i.body.body).setPosition(new OIMO.Vec3(o.x,o.y,o.z)),r.setRotation(new OIMO.Vec3(s.x,s.y,s.z)),void(r.sleeping=!1)}}}}return t.prototype._checkWithEpsilon=function(t){return t<e.PhysicsEngine.Epsilon?e.PhysicsEngine.Epsilon:t},t.prototype.initialize=function(e){this._world=new OIMO.World,this._world.clear()},t.prototype.setGravity=function(e){this._world.gravity=e},t.prototype.registerMesh=function(t,i,r){var n=null;this.unregisterMesh(t),t.computeWorldMatrix(!0);var o=null;t.rotationQuaternion&&(o=t.rotationQuaternion.clone(),t.rotationQuaternion=new e.Quaternion(0,0,0,1),t.computeWorldMatrix(!0));var s=t.getBoundingInfo().boundingBox,a=t.position.subtract(s.center);if(o){var h=new e.Matrix;o.toRotationMatrix(h),a=e.Vector3.TransformCoordinates(a,h)}switch(i){case e.PhysicsEngine.SphereImpostor:var c=s.maximumWorld.x-s.minimumWorld.x,l=s.maximumWorld.y-s.minimumWorld.y,u=s.maximumWorld.z-s.minimumWorld.z,d=Math.max(this._checkWithEpsilon(c),this._checkWithEpsilon(l),this._checkWithEpsilon(u))/2;n=new OIMO.Body({type:"sphere",size:[d],pos:[s.center.x,s.center.y,s.center.z],rot:[t.rotation.x/OIMO.TO_RAD,t.rotation.y/OIMO.TO_RAD,t.rotation.z/OIMO.TO_RAD],move:0!=r.mass,config:[r.mass,r.friction,r.restitution],world:this._world});break;case e.PhysicsEngine.PlaneImpostor:case e.PhysicsEngine.CylinderImpostor:case e.PhysicsEngine.BoxImpostor:var f=s.minimumWorld,p=s.maximumWorld.subtract(f),m=this._checkWithEpsilon(p.x),g=this._checkWithEpsilon(p.y),v=this._checkWithEpsilon(p.z);n=new OIMO.Body({type:"box",size:[m,g,v],pos:[s.center.x,s.center.y,s.center.z],rot:[t.rotation.x/OIMO.TO_RAD,t.rotation.y/OIMO.TO_RAD,t.rotation.z/OIMO.TO_RAD],move:0!=r.mass,config:[r.mass,r.friction,r.restitution],world:this._world})}return o&&(n.body.orientation=new OIMO.Quat(o.w,o.x,o.y,o.z),n.body.syncShapes()),this._registeredMeshes.push({mesh:t,body:n,delta:a}),n},t.prototype.registerMeshesAsCompound=function(e,t){for(var i=[],r=[],n=[],o=[],s=e[0].mesh,a=0;a<e.length;a++){var h=e[a],c=this._createBodyAsCompound(h,t,s);i.push(c.type),r.push.apply(r,c.size),n.push.apply(n,c.pos),o.push.apply(o,c.rot)}var l=new OIMO.Body({type:i,size:r,pos:n,rot:o,move:0!=t.mass,config:[t.mass,t.friction,t.restitution],world:this._world});return this._registeredMeshes.push({mesh:s,body:l}),l},t.prototype._createBodyAsCompound=function(t,i,r){var n=null,o=t.mesh;switch(o.computeWorldMatrix(),t.impostor){case e.PhysicsEngine.SphereImpostor:var s=o.getBoundingInfo().boundingBox,a=s.maximumWorld.x-s.minimumWorld.x,h=s.maximumWorld.y-s.minimumWorld.y,c=s.maximumWorld.z-s.minimumWorld.z;n={type:"sphere",size:[Math.max(this._checkWithEpsilon(a),this._checkWithEpsilon(h),this._checkWithEpsilon(c))/2,-1,-1],pos:[o.position.x,o.position.y,o.position.z],rot:[o.rotation.x/OIMO.TO_RAD,o.rotation.y/OIMO.TO_RAD,o.rotation.z/OIMO.TO_RAD]};break;case e.PhysicsEngine.PlaneImpostor:case e.PhysicsEngine.BoxImpostor:var l=(s=o.getBoundingInfo().boundingBox).minimumWorld,u=s.maximumWorld.subtract(l),d=this._checkWithEpsilon(u.x),f=this._checkWithEpsilon(u.y),p=this._checkWithEpsilon(u.z),m=o.position;n={type:"box",size:[d,f,p],pos:[m.x,m.y,m.z],rot:[o.rotation.x/OIMO.TO_RAD,o.rotation.y/OIMO.TO_RAD,o.rotation.z/OIMO.TO_RAD]}}return n},t.prototype.unregisterMesh=function(e){for(var t=0;t<this._registeredMeshes.length;t++){var i=this._registeredMeshes[t];if(i.mesh===e||i.mesh===e.parent)return i.body&&(this._world.removeRigidBody(i.body.body),this._unbindBody(i.body)),void this._registeredMeshes.splice(t,1)}},t.prototype._unbindBody=function(e){for(var t=0;t<this._registeredMeshes.length;t++){var i=this._registeredMeshes[t];i.body===e&&(i.body=null)}},t.prototype.applyImpulse=function(e,t,i){for(var r=0;r<this._registeredMeshes.length;r++){var n=this._registeredMeshes[r];if(n.mesh===e||n.mesh===e.parent){var o=n.body.body.massInfo.mass;return void n.body.body.applyImpulse(i.scale(OIMO.INV_SCALE),t.scale(OIMO.INV_SCALE*o))}}},t.prototype.createLink=function(e,t,i,r,n){for(var o=null,s=null,a=0;a<this._registeredMeshes.length;a++){var h=this._registeredMeshes[a];h.mesh===e?o=h.body.body:h.mesh===t&&(s=h.body.body)}return!(!o||!s)&&(n||(n={}),new OIMO.Link({type:n.type,body1:o,body2:s,min:n.min,max:n.max,axe1:n.axe1,axe2:n.axe2,pos1:[i.x,i.y,i.z],pos2:[r.x,r.y,r.z],collision:n.collision,spring:n.spring,world:this._world}),!0)},t.prototype.dispose=function(){for(this._world.clear();this._registeredMeshes.length;)this.unregisterMesh(this._registeredMeshes[0].mesh)},t.prototype.isSupported=function(){return void 0!==OIMO},t.prototype._getLastShape=function(e){for(var t=e.shapes;t.next;)t=t.next;return t},t.prototype.runOneStep=function(t){this._world.step();for(var i,r=this._registeredMeshes.length;r--;){var n=this._registeredMeshes[r].body.body,o=this._registeredMeshes[r].mesh,s=this._registeredMeshes[r].delta;if(!n.sleeping)if(n.shapes.next){var a=this._getLastShape(n);o.position.x=a.position.x*OIMO.WORLD_SCALE,o.position.y=a.position.y*OIMO.WORLD_SCALE,o.position.z=a.position.z*OIMO.WORLD_SCALE;var h=e.Matrix.FromArray(n.getMatrix());o.rotationQuaternion||(o.rotationQuaternion=new e.Quaternion(0,0,0,1)),o.rotationQuaternion.fromRotationMatrix(h),o.computeWorldMatrix()}else{i=n.getMatrix();var c=(h=e.Matrix.FromArray(i)).m[12],l=h.m[13],u=h.m[14];s?(o.position.x=c+s.x,o.position.y=l+s.y,o.position.z=u+s.z):(o.position.x=c,o.position.y=l,o.position.z=u),o.rotationQuaternion||(o.rotationQuaternion=new e.Quaternion(0,0,0,1)),e.Quaternion.FromRotationMatrixToRef(h,o.rotationQuaternion),o.computeWorldMatrix()}}},t}();e.OimoJSPlugin=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t){this._currentPlugin=t||new e.OimoJSPlugin}return t.prototype._initialize=function(e){this._currentPlugin.initialize(),this._setGravity(e)},t.prototype._runOneStep=function(e){e>.1?e=.1:0>=e&&(e=1/60),this._currentPlugin.runOneStep(e)},t.prototype._setGravity=function(t){this.gravity=t||new e.Vector3(0,-9.807,0),this._currentPlugin.setGravity(this.gravity)},t.prototype._registerMesh=function(e,t,i){return this._currentPlugin.registerMesh(e,t,i)},t.prototype._registerMeshesAsCompound=function(e,t){return this._currentPlugin.registerMeshesAsCompound(e,t)},t.prototype._unregisterMesh=function(e){this._currentPlugin.unregisterMesh(e)},t.prototype._applyImpulse=function(e,t,i){this._currentPlugin.applyImpulse(e,t,i)},t.prototype._createLink=function(e,t,i,r,n){return this._currentPlugin.createLink(e,t,i,r,n)},t.prototype._updateBodyPosition=function(e){this._currentPlugin.updateBodyPosition(e)},t.prototype.dispose=function(){this._currentPlugin.dispose()},t.prototype.isSupported=function(){return this._currentPlugin.isSupported()},t.NoImpostor=0,t.SphereImpostor=1,t.BoxImpostor=2,t.PlaneImpostor=3,t.MeshImpostor=4,t.CapsuleImpostor=5,t.ConeImpostor=6,t.CylinderImpostor=7,t.ConvexHullImpostor=8,t.Epsilon=.001,t}();e.PhysicsEngine=t}(BABYLON||(BABYLON={})),function(e){var t,i=function(t){var i={};if(i.name=t.name,i.id=t.id,i.tags=e.Tags.GetTags(t),t instanceof e.PointLight)i.type=0,i.position=t.position.asArray();else if(t instanceof e.DirectionalLight){i.type=1;var r=t;i.position=r.position.asArray(),i.direction=r.direction.asArray()}else if(t instanceof e.SpotLight){i.type=2;var n=t;i.position=n.position.asArray(),i.direction=n.position.asArray(),i.angle=n.angle,i.exponent=n.exponent}else if(t instanceof e.HemisphericLight){i.type=3;var o=t;i.direction=o.direction.asArray(),i.groundColor=o.groundColor.asArray()}return t.intensity&&(i.intensity=t.intensity),i.range=t.range,i.diffuse=t.diffuse.asArray(),i.specular=t.specular.asArray(),i},r=function(e){var t={};return t.isEnabled=e.isEnabled,t.leftColor=e.leftColor,t.rightColor=e.rightColor,t.bias=e.bias,t.power=e.power,t},n=function(e,i){if(e.animations){i.animations=[];for(var r=0;r<e.animations.length;r++){var n=e.animations[r];i.animations.push(t(n))}}},o=function(t){var i={};if(i.name=t.name,i.tags=e.Tags.GetTags(t),i.id=t.id,i.position=t.position.asArray(),t.parent&&(i.parentId=t.parent.id),i.fov=t.fov,i.minZ=t.minZ,i.maxZ=t.maxZ,i.inertia=t.inertia,t instanceof e.FreeCamera?i.type="FreeCamera":t instanceof e.ArcRotateCamera?i.type="ArcRotateCamera":t instanceof e.AnaglyphArcRotateCamera?i.type="AnaglyphArcRotateCamera":t instanceof e.GamepadCamera?i.type="GamepadCamera":t instanceof e.AnaglyphFreeCamera?i.type="AnaglyphFreeCamera":t instanceof e.DeviceOrientationCamera?i.type="DeviceOrientationCamera":t instanceof e.FollowCamera?i.type="FollowCamera":t instanceof e.TouchCamera?i.type="TouchCamera":t instanceof e.VirtualJoysticksCamera?i.type="VirtualJoysticksCamera":t instanceof e.WebVRFreeCamera?i.type="WebVRFreeCamera":t instanceof e.VRDeviceOrientationFreeCamera&&(i.type="VRDeviceOrientationFreeCamera"),t instanceof e.ArcRotateCamera||t instanceof e.AnaglyphArcRotateCamera){var r=t;i.alpha=r.alpha,i.beta=r.beta,i.radius=r.radius,r.target&&r.target.id&&(i.lockedTargetId=r.target.id)}else if(t instanceof e.FollowCamera){var o=t;i.radius=o.radius,i.heightOffset=o.heightOffset,i.rotationOffset=o.rotationOffset}else(t instanceof e.AnaglyphFreeCamera||t instanceof e.AnaglyphArcRotateCamera)&&void 0!==t._interaxialDistance&&(i.interaxial_distance=e.Tools.ToDegrees(t._interaxialDistance));return void 0!==t.speed&&(i.speed=t.speed),t.target&&t.target instanceof e.Vector3&&(i.target=t.target.asArray()),t.rotation&&t.rotation instanceof e.Vector3&&(i.rotation=t.rotation.asArray()),t.lockedTarget&&t.lockedTarget.id&&(i.lockedTargetId=t.lockedTarget.id),i.checkCollisions=t.checkCollisions||!1,i.applyGravity=t.applyGravity||!1,t.ellipsoid&&(i.ellipsoid=t.ellipsoid.asArray()),n(t,i),i.layerMask=t.layerMask,i};t=function(t){var i={};i.name=t.name,i.property=t.targetProperty,i.framePerSecond=t.framePerSecond,i.dataType=t.dataType,i.loopBehavior=t.loopMode;var r=t.dataType;i.keys=[];for(var n=t.getKeys(),o=0;o<n.length;o++){var s=n[o],a={};switch(a.frame=s.frame,r){case e.Animation.ANIMATIONTYPE_FLOAT:a.values=[s.value];break;case e.Animation.ANIMATIONTYPE_QUATERNION:case e.Animation.ANIMATIONTYPE_MATRIX:case e.Animation.ANIMATIONTYPE_VECTOR3:a.values=s.value.asArray()}i.keys.push(a)}return i};var s,a=function(t){var i={};i.name=t.name,i.id=t.id,i.tags=e.Tags.GetTags(t),i.materials=[];for(var r=0;r<t.subMaterials.length;r++){var n=t.subMaterials[r];i.materials.push(n?n.id:null)}return i},h=function(t){var i={};return i.name=t.name,i.ambient=t.ambientColor.asArray(),i.diffuse=t.diffuseColor.asArray(),i.specular=t.specularColor.asArray(),i.specularPower=t.specularPower,i.emissive=t.emissiveColor.asArray(),i.useReflectionFresnelFromSpecular=i.useReflectionFresnelFromSpecular,i.useEmissiveAsIllumination=i.useEmissiveAsIllumination,i.alpha=t.alpha,i.id=t.id,i.tags=e.Tags.GetTags(t),i.backFaceCulling=t.backFaceCulling,t.diffuseTexture&&(i.diffuseTexture=s(t.diffuseTexture)),t.diffuseFresnelParameters&&(i.diffuseFresnelParameters=r(t.diffuseFresnelParameters)),t.ambientTexture&&(i.ambientTexture=s(t.ambientTexture)),t.opacityTexture&&(i.opacityTexture=s(t.opacityTexture)),t.opacityFresnelParameters&&(i.opacityFresnelParameters=r(t.opacityFresnelParameters)),t.reflectionTexture&&(i.reflectionTexture=s(t.reflectionTexture)),t.reflectionFresnelParameters&&(i.reflectionFresnelParameters=r(t.reflectionFresnelParameters)),t.emissiveTexture&&(i.emissiveTexture=s(t.emissiveTexture)),t.lightmapTexture&&(i.lightmapTexture=s(t.lightmapTexture),i.lightmapThreshold=t.lightmapThreshold),t.emissiveFresnelParameters&&(i.emissiveFresnelParameters=r(t.emissiveFresnelParameters)),t.specularTexture&&(i.specularTexture=s(t.specularTexture)),t.bumpTexture&&(i.bumpTexture=s(t.bumpTexture)),i};s=function(t){var i,r={};if(!t.name)return null;if(t instanceof e.CubeTexture)return r.name=t.name,r.hasAlpha=t.hasAlpha,r.isCube=!0,r.level=t.level,r.coordinatesMode=t.coordinatesMode,r;if(t instanceof e.MirrorTexture){var o=t;for(r.renderTargetSize=o.getRenderSize(),r.renderList=[],i=0;i<o.renderList.length;i++)r.renderList.push(o.renderList[i].id);r.mirrorPlane=o.mirrorPlane.asArray()}else if(t instanceof e.RenderTargetTexture){var s=t;for(r.renderTargetSize=s.getRenderSize(),r.renderList=[],i=0;i<s.renderList.length;i++)r.renderList.push(s.renderList[i].id)}var a=t;return r.name=t.name,r.hasAlpha=t.hasAlpha,r.level=t.level,r.coordinatesIndex=t.coordinatesIndex,r.coordinatesMode=t.coordinatesMode,r.uOffset=a.uOffset,r.vOffset=a.vOffset,r.uScale=a.uScale,r.vScale=a.vScale,r.uAng=a.uAng,r.vAng=a.vAng,r.wAng=a.wAng,r.wrapU=t.wrapU,r.wrapV=t.wrapV,n(t,r),r};var c,l,u,d,f,p,m,g,v=function(e){var i={};i.name=e.name,i.id=e.id,i.bones=[];for(var r=0;r<e.bones.length;r++){var n=e.bones[r],o={parentBoneIndex:n.getParent()?e.bones.indexOf(n.getParent()):-1,name:n.name,matrix:n.getLocalMatrix().toArray()};i.bones.push(o),n.animations&&n.animations.length>0&&(o.animation=t(n.animations[0]))}return i},_=function(e){var t={};return t.emitterId=e.emitter.id,t.capacity=e.getCapacity(),e.particleTexture&&(t.textureName=e.particleTexture.name),t.minAngularSpeed=e.minAngularSpeed,t.maxAngularSpeed=e.maxAngularSpeed,t.minSize=e.minSize,t.maxSize=e.maxSize,t.minLifeTime=e.minLifeTime,t.maxLifeTime=e.maxLifeTime,t.emitRate=e.emitRate,t.minEmitBox=e.minEmitBox.asArray(),t.maxEmitBox=e.maxEmitBox.asArray(),t.gravity=e.gravity.asArray(),t.direction1=e.direction1.asArray(),t.direction2=e.direction2.asArray(),t.color1=e.color1.asArray(),t.color2=e.color2.asArray(),t.colorDead=e.colorDead.asArray(),t.updateSpeed=e.updateSpeed,t.targetStopDuration=e.targetStopDuration,t.textureMask=e.textureMask.asArray(),t.blendMode=e.blendMode,t},y=function(t){var i={};i.emitterId=t.getEmitter().id,i.borderLimit=t.borderLimit,i.flares=[];for(var r=0;r<t.lensFlares.length;r++){var n=t.lensFlares[r];i.flares.push({size:n.size,position:n.position,color:n.color.asArray(),textureName:e.Tools.GetFilename(n.texture.name)})}return i},x=function(e){var t={},i=e.getShadowGenerator();t.lightId=e.id,t.mapSize=i.getShadowMap().getRenderSize(),t.useVarianceShadowMap=i.useVarianceShadowMap,t.usePoissonSampling=i.usePoissonSampling,t.renderList=[];for(var r=0;r<i.getShadowMap().renderList.length;r++){var n=i.getShadowMap().renderList[r];t.renderList.push(n.id)}return t},b=[],M=function(t,i){if(!b[t.id]){if(t instanceof e.Geometry.Primitives.Box)i.boxes.push(g(t));else if(t instanceof e.Geometry.Primitives.Sphere)i.spheres.push(m(t));else if(t instanceof e.Geometry.Primitives.Cylinder)i.cylinders.push(p(t));else if(t instanceof e.Geometry.Primitives.Torus)i.toruses.push(f(t));else if(t instanceof e.Geometry.Primitives.Ground)i.grounds.push(d(t));else if(t instanceof e.Geometry.Primitives.Plane)i.planes.push(u(t));else if(t instanceof e.Geometry.Primitives.TorusKnot)i.torusKnots.push(l(t));else{if(t instanceof e.Geometry.Primitives._Primitive)throw new Error("Unknown primitive type");i.vertexData.push(c(t))}b[t.id]=!0}},E=function(t){var i={};return i.id=t.id,e.Tags.HasTags(t)&&(i.tags=e.Tags.GetTags(t)),i};c=function(t){var i=E(t);return t.isVerticesDataPresent(e.VertexBuffer.PositionKind)&&(i.positions=t.getVerticesData(e.VertexBuffer.PositionKind)),t.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&(i.normals=t.getVerticesData(e.VertexBuffer.NormalKind)),t.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(i.uvs=t.getVerticesData(e.VertexBuffer.UVKind)),t.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(i.uvs2=t.getVerticesData(e.VertexBuffer.UV2Kind)),t.isVerticesDataPresent(e.VertexBuffer.UV3Kind)&&(i.uvs3=t.getVerticesData(e.VertexBuffer.UV3Kind)),t.isVerticesDataPresent(e.VertexBuffer.UV4Kind)&&(i.uvs4=t.getVerticesData(e.VertexBuffer.UV4Kind)),t.isVerticesDataPresent(e.VertexBuffer.UV5Kind)&&(i.uvs5=t.getVerticesData(e.VertexBuffer.UV5Kind)),t.isVerticesDataPresent(e.VertexBuffer.UV6Kind)&&(i.uvs6=t.getVerticesData(e.VertexBuffer.UV6Kind)),t.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(i.colors=t.getVerticesData(e.VertexBuffer.ColorKind)),t.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind)&&(i.matricesIndices=t.getVerticesData(e.VertexBuffer.MatricesIndicesKind),i.matricesIndices._isExpanded=!0),t.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind)&&(i.matricesWeights=t.getVerticesData(e.VertexBuffer.MatricesWeightsKind)),i.indices=t.getIndices(),i};var T=function(e){var t=E(e);return t.canBeRegenerated=e.canBeRegenerated(),t};g=function(e){var t=T(e);return t.size=e.size,t},m=function(e){var t=T(e);return t.segments=e.segments,t.diameter=e.diameter,t},p=function(e){var t=T(e);return t.height=e.height,t.diameterTop=e.diameterTop,t.diameterBottom=e.diameterBottom,t.tessellation=e.tessellation,t},f=function(e){var t=T(e);return t.diameter=e.diameter,t.thickness=e.thickness,t.tessellation=e.tessellation,t},d=function(e){var t=T(e);return t.width=e.width,t.height=e.height,t.subdivisions=e.subdivisions,t},u=function(e){var t=T(e);return t.size=e.size,t},l=function(e){var t=T(e);return t.radius=e.radius,t.tube=e.tube,t.radialSegments=e.radialSegments,t.tubularSegments=e.tubularSegments,t.p=e.p,t.q=e.q,t};var w=function(t,i){var r={};r.name=t.name,r.id=t.id,e.Tags.HasTags(t)&&(r.tags=e.Tags.GetTags(t)),r.position=t.position.asArray(),t.rotationQuaternion?r.rotationQuaternion=t.rotationQuaternion.asArray():t.rotation&&(r.rotation=t.rotation.asArray()),r.scaling=t.scaling.asArray(),r.localMatrix=t.getPivotMatrix().asArray(),r.isEnabled=t.isEnabled(),r.isVisible=t.isVisible,r.infiniteDistance=t.infiniteDistance,r.pickable=t.isPickable,r.receiveShadows=t.receiveShadows,r.billboardMode=t.billboardMode,r.visibility=t.visibility,r.checkCollisions=t.checkCollisions,t.parent&&(r.parentId=t.parent.id);var o=t._geometry;if(o){var s=o.id;r.geometryId=s,t.getScene().getGeometryByID(s)||M(o,i.geometries),r.subMeshes=[];for(var a=0;a<t.subMeshes.length;a++){var h=t.subMeshes[a];r.subMeshes.push({materialIndex:h.materialIndex,verticesStart:h.verticesStart,verticesCount:h.verticesCount,indexStart:h.indexStart,indexCount:h.indexCount})}}if(t.material?r.materialId=t.material.id:t.material=null,t.skeleton&&(r.skeletonId=t.skeleton.id),t.getPhysicsImpostor()!==e.PhysicsEngine.NoImpostor)switch(r.physicsMass=t.getPhysicsMass(),r.physicsFriction=t.getPhysicsFriction(),r.physicsRestitution=t.getPhysicsRestitution(),t.getPhysicsImpostor()){case e.PhysicsEngine.BoxImpostor:r.physicsImpostor=1;break;case e.PhysicsEngine.SphereImpostor:r.physicsImpostor=2}r.instances=[];for(var c=0;c<t.instances.length;c++){var l=t.instances[c],u={name:l.name,position:l.position.asArray(),rotation:l.rotation.asArray(),rotationQuaternion:l.rotationQuaternion.asArray(),scaling:l.scaling.asArray()};r.instances.push(u),n(l,u)}return n(t,r),r.layerMask=t.layerMask,r},S=function(t,i){if(t.delayLoadState===e.Engine.DELAYLOADSTATE_LOADED||t.delayLoadState===e.Engine.DELAYLOADSTATE_NONE){t.material&&(t.material instanceof e.StandardMaterial?(i.materials=i.materials||[],i.materials.some(function(e){return e.id===t.material.id})||i.materials.push(h(t.material))):t.material instanceof e.MultiMaterial&&(i.multiMaterials=i.multiMaterials||[],i.multiMaterials.some(function(e){return e.id===t.material.id})||i.multiMaterials.push(a(t.material))));var r=t._geometry;r&&(i.geometries||(i.geometries={},i.geometries.boxes=[],i.geometries.spheres=[],i.geometries.cylinders=[],i.geometries.toruses=[],i.geometries.grounds=[],i.geometries.planes=[],i.geometries.torusKnots=[],i.geometries.vertexData=[]),M(r,i.geometries)),t.skeleton&&(i.skeletons=i.skeletons||[],i.skeletons.push(v(t.skeleton))),i.meshes=i.meshes||[],i.meshes.push(w(t,i))}},A=function(){function t(){}return t.Serialize=function(t){var r,n,s,c={};for(c.useDelayedTextureLoading=t.useDelayedTextureLoading,c.autoClear=t.autoClear,c.clearColor=t.clearColor.asArray(),c.ambientColor=t.ambientColor.asArray(),c.gravity=t.gravity.asArray(),t.fogMode&&0!==t.fogMode&&(c.fogMode=t.fogMode,c.fogColor=t.fogColor.asArray(),c.fogStart=t.fogStart,c.fogEnd=t.fogEnd,c.fogDensity=t.fogDensity),c.lights=[],r=0;r<t.lights.length;r++)n=t.lights[r],c.lights.push(i(n));for(c.cameras=[],r=0;r<t.cameras.length;r++){var l=t.cameras[r];c.cameras.push(o(l))}for(t.activeCamera&&(c.activeCameraID=t.activeCamera.id),c.materials=[],c.multiMaterials=[],r=0;r<t.materials.length;r++)s=t.materials[r],c.materials.push(h(s));for(c.multiMaterials=[],r=0;r<t.multiMaterials.length;r++){var u=t.multiMaterials[r];c.multiMaterials.push(a(u))}for(r=0;r<t.materials.length;r++)(s=t.materials[r])instanceof e.StandardMaterial?c.materials.push(h(s)):s instanceof e.MultiMaterial&&c.multiMaterials.push(a(s));for(c.skeletons=[],r=0;r<t.skeletons.length;r++)c.skeletons.push(v(t.skeletons[r]));c.geometries={},c.geometries.boxes=[],c.geometries.spheres=[],c.geometries.cylinders=[],c.geometries.toruses=[],c.geometries.grounds=[],c.geometries.planes=[],c.geometries.torusKnots=[],c.geometries.vertexData=[],b=[];var d=t.getGeometries();for(r=0;r<d.length;r++){var f=d[r];f.isReady()&&M(f,c.geometries)}for(c.meshes=[],r=0;r<t.meshes.length;r++){var p=t.meshes[r];if(p instanceof e.Mesh){var m=p;(m.delayLoadState===e.Engine.DELAYLOADSTATE_LOADED||m.delayLoadState===e.Engine.DELAYLOADSTATE_NONE)&&c.meshes.push(w(m,c))}}for(c.particleSystems=[],r=0;r<t.particleSystems.length;r++)c.particleSystems.push(_(t.particleSystems[r]));for(c.lensFlareSystems=[],r=0;r<t.lensFlareSystems.length;r++)c.lensFlareSystems.push(y(t.lensFlareSystems[r]));for(c.shadowGenerators=[],r=0;r<t.lights.length;r++)(n=t.lights[r]).getShadowGenerator()&&c.shadowGenerators.push(x(n));return c},t.SerializeMesh=function(t,i,r){void 0===i&&(i=!1),void 0===r&&(r=!1);var n={};if(t=t instanceof Array?t:[t],i||r)for(var o=0;o<t.length;++o)r&&t[o].getDescendants().forEach(function(i){i instanceof e.Mesh&&t.indexOf(i)<0&&t.push(i)}),i&&t[o].parent&&t.indexOf(t[o].parent)<0&&t.push(t[o].parent);return t.forEach(function(e){S(e,n)}),n},t}();e.SceneSerializer=A}(BABYLON||(BABYLON={})),function(e){var t=0,i=function(){function t(e,t,i){this.pos=e,this.normal=t,this.uv=i}return t.prototype.clone=function(){return new t(this.pos.clone(),this.normal.clone(),this.uv.clone())},t.prototype.flip=function(){this.normal=this.normal.scale(-1)},t.prototype.interpolate=function(i,r){return new t(e.Vector3.Lerp(this.pos,i.pos,r),e.Vector3.Lerp(this.normal,i.normal,r),e.Vector2.Lerp(this.uv,i.uv,r))},t}(),r=function(){function t(e,t){this.normal=e,this.w=t}return t.FromPoints=function(i,r,n){var o=n.subtract(i),s=r.subtract(i);if(0===o.lengthSquared()||0===s.lengthSquared())return null;var a=e.Vector3.Normalize(e.Vector3.Cross(o,s));return new t(a,e.Vector3.Dot(a,i))},t.prototype.clone=function(){return new t(this.normal.clone(),this.w)},t.prototype.flip=function(){this.normal.scaleInPlace(-1),this.w=-this.w},t.prototype.splitPolygon=function(i,r,o,s,a){for(var h=0,c=[],l=0;l<i.vertices.length;l++){var u=e.Vector3.Dot(this.normal,i.vertices[l].pos)-this.w,d=u<-t.EPSILON?2:u>t.EPSILON?1:0;h|=d,c.push(d)}switch(h){case 0:(e.Vector3.Dot(this.normal,i.plane.normal)>0?r:o).push(i);break;case 1:s.push(i);break;case 2:a.push(i);break;case 3:var f=[],p=[];for(l=0;l<i.vertices.length;l++){var m=(l+1)%i.vertices.length,g=c[l],v=c[m],_=i.vertices[l],y=i.vertices[m];if(2!=g&&f.push(_),1!=g&&p.push(2!=g?_.clone():_),3==(g|v)){u=(this.w-e.Vector3.Dot(this.normal,_.pos))/e.Vector3.Dot(this.normal,y.pos.subtract(_.pos));var x=_.interpolate(y,u);f.push(x),p.push(x.clone())}}if(f.length>=3){var b=new n(f,i.shared);b.plane&&s.push(b)}p.length>=3&&((b=new n(p,i.shared)).plane&&a.push(b))}},t.EPSILON=1e-5,t}(),n=function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=r.FromPoints(e[0].pos,e[1].pos,e[2].pos)}return e.prototype.clone=function(){return new e(this.vertices.map(function(e){return e.clone()}),this.shared)},e.prototype.flip=function(){this.vertices.reverse().map(function(e){e.flip()}),this.plane.flip()},e}(),o=function(){function e(e){this.plane=null,this.front=null,this.back=null,this.polygons=[],e&&this.build(e)}return e.prototype.clone=function(){var t=new e;return t.plane=this.plane&&this.plane.clone(),t.front=this.front&&this.front.clone(),t.back=this.back&&this.back.clone(),t.polygons=this.polygons.map(function(e){return e.clone()}),t},e.prototype.invert=function(){for(var e=0;e<this.polygons.length;e++)this.polygons[e].flip();this.plane&&this.plane.flip(),this.front&&this.front.invert(),this.back&&this.back.invert();var t=this.front;this.front=this.back,this.back=t},e.prototype.clipPolygons=function(e){if(!this.plane)return e.slice();for(var t=[],i=[],r=0;r<e.length;r++)this.plane.splitPolygon(e[r],t,i,t,i);return this.front&&(t=this.front.clipPolygons(t)),i=this.back?this.back.clipPolygons(i):[],t.concat(i)},e.prototype.clipTo=function(e){this.polygons=e.clipPolygons(this.polygons),this.front&&this.front.clipTo(e),this.back&&this.back.clipTo(e)},e.prototype.allPolygons=function(){var e=this.polygons.slice();return this.front&&(e=e.concat(this.front.allPolygons())),this.back&&(e=e.concat(this.back.allPolygons())),e},e.prototype.build=function(t){if(t.length){this.plane||(this.plane=t[0].plane.clone());for(var i=[],r=[],n=0;n<t.length;n++)this.plane.splitPolygon(t[n],this.polygons,this.polygons,i,r);i.length&&(this.front||(this.front=new e),this.front.build(i)),r.length&&(this.back||(this.back=new e),this.back.build(r))}},e}(),s=function(){function r(){this.polygons=new Array}return r.FromMesh=function(o){var s,a,h,c,l,u,d,f,p,m,g,v=new Array;if(!(o instanceof e.Mesh))throw"BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh";o.computeWorldMatrix(!0),d=o.getWorldMatrix(),f=o.position.clone(),p=o.rotation.clone(),o.rotationQuaternion&&(m=o.rotationQuaternion.clone()),g=o.scaling.clone();for(var _=o.getIndices(),y=o.getVerticesData(e.VertexBuffer.PositionKind),x=o.getVerticesData(e.VertexBuffer.NormalKind),b=o.getVerticesData(e.VertexBuffer.UVKind),M=o.subMeshes,E=0,T=M.length;T>E;E++)for(var w=M[E].indexStart,S=M[E].indexCount+M[E].indexStart;S>w;w+=3){u=[];for(var A=0;3>A;A++){var P=new e.Vector3(x[3*_[w+A]],x[3*_[w+A]+1],x[3*_[w+A]+2]);h=new e.Vector2(b[2*_[w+A]],b[2*_[w+A]+1]);var C=new e.Vector3(y[3*_[w+A]],y[3*_[w+A]+1],y[3*_[w+A]+2]);c=e.Vector3.TransformCoordinates(C,d),a=e.Vector3.TransformNormal(P,d),s=new i(c,a,h),u.push(s)}(l=new n(u,{subMeshId:E,meshId:t,materialIndex:M[E].materialIndex})).plane&&v.push(l)}var D=r.FromPolygons(v);return D.matrix=d,D.position=f,D.rotation=p,D.scaling=g,D.rotationQuaternion=m,t++,D},r.FromPolygons=function(e){var t=new r;return t.polygons=e,t},r.prototype.clone=function(){var e=new r;return e.polygons=this.polygons.map(function(e){return e.clone()}),e.copyTransformAttributes(this),e},r.prototype.toPolygons=function(){return this.polygons},r.prototype.union=function(e){var t=new o(this.clone().polygons),i=new o(e.clone().polygons);return t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),r.FromPolygons(t.allPolygons()).copyTransformAttributes(this)},r.prototype.unionInPlace=function(e){var t=new o(this.polygons),i=new o(e.polygons);t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),this.polygons=t.allPolygons()},r.prototype.subtract=function(e){var t=new o(this.clone().polygons),i=new o(e.clone().polygons);return t.invert(),t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),t.invert(),r.FromPolygons(t.allPolygons()).copyTransformAttributes(this)},r.prototype.subtractInPlace=function(e){var t=new o(this.polygons),i=new o(e.polygons);t.invert(),t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),t.invert(),this.polygons=t.allPolygons()},r.prototype.intersect=function(e){var t=new o(this.clone().polygons),i=new o(e.clone().polygons);return t.invert(),i.clipTo(t),i.invert(),t.clipTo(i),i.clipTo(t),t.build(i.allPolygons()),t.invert(),r.FromPolygons(t.allPolygons()).copyTransformAttributes(this)},r.prototype.intersectInPlace=function(e){var t=new o(this.polygons),i=new o(e.polygons);t.invert(),i.clipTo(t),i.invert(),t.clipTo(i),i.clipTo(t),t.build(i.allPolygons()),t.invert(),this.polygons=t.allPolygons()},r.prototype.inverse=function(){var e=this.clone();return e.inverseInPlace(),e},r.prototype.inverseInPlace=function(){this.polygons.map(function(e){e.flip()})},r.prototype.copyTransformAttributes=function(e){return this.matrix=e.matrix,this.position=e.position,this.rotation=e.rotation,this.scaling=e.scaling,this.rotationQuaternion=e.rotationQuaternion,this},r.prototype.buildMeshGeometry=function(t,i,r){var n=this.matrix.clone();n.invert();var o,s,a,h=new e.Mesh(t,i),c=[],l=[],u=[],d=[],f=e.Vector3.Zero(),p=e.Vector3.Zero(),m=e.Vector2.Zero(),g=this.polygons,v=[0,0,0],_={},y=0,x={};r&&g.sort(function(e,t){return e.shared.meshId===t.shared.meshId?e.shared.subMeshId-t.shared.subMeshId:e.shared.meshId-t.shared.meshId});for(var b=0,M=g.length;M>b;b++){x[(o=g[b]).shared.meshId]||(x[o.shared.meshId]={}),x[o.shared.meshId][o.shared.subMeshId]||(x[o.shared.meshId][o.shared.subMeshId]={indexStart:1/0,indexEnd:-1/0,materialIndex:o.shared.materialIndex}),a=x[o.shared.meshId][o.shared.subMeshId];for(var E=2,T=o.vertices.length;T>E;E++){v[0]=0,v[1]=E-1,v[2]=E;for(var w=0;3>w;w++){f.copyFrom(o.vertices[v[w]].pos),p.copyFrom(o.vertices[v[w]].normal),m.copyFrom(o.vertices[v[w]].uv);var S=e.Vector3.TransformCoordinates(f,n),A=e.Vector3.TransformNormal(p,n);(void 0===(s=_[S.x+","+S.y+","+S.z])||u[3*s]!==A.x||u[3*s+1]!==A.y||u[3*s+2]!==A.z||d[2*s]!==m.x||d[2*s+1]!==m.y)&&(c.push(S.x,S.y,S.z),d.push(m.x,m.y),u.push(p.x,p.y,p.z),s=_[S.x+","+S.y+","+S.z]=c.length/3-1),l.push(s),a.indexStart=Math.min(y,a.indexStart),a.indexEnd=Math.max(y,a.indexEnd),y++}}}if(h.setVerticesData(e.VertexBuffer.PositionKind,c),h.setVerticesData(e.VertexBuffer.NormalKind,u),h.setVerticesData(e.VertexBuffer.UVKind,d),h.setIndices(l),r){var P,C=0;for(var D in h.subMeshes.length=0,x){for(var R in P=-1,x[D])a=x[D][R],e.SubMesh.CreateFromIndices(a.materialIndex+C,a.indexStart,a.indexEnd-a.indexStart+1,h),P=Math.max(a.materialIndex,P);C+=++P}}return h},r.prototype.toMesh=function(e,t,i,r){var n=this.buildMeshGeometry(e,i,r);return n.material=t,n.position.copyFrom(this.position),n.rotation.copyFrom(this.rotation),this.rotationQuaternion&&(n.rotationQuaternion=this.rotationQuaternion.clone()),n.scaling.copyFrom(this.scaling),n.computeWorldMatrix(!0),n},r}();e.CSG=s}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o){var s=this;t.call(this,i,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,o.postProcessScaleFactor,r,e.Texture.BILINEAR_SAMPLINGMODE,null,null),this._isRightEye=n,this._distortionFactors=o.distortionK,this._postProcessScaleFactor=o.postProcessScaleFactor,this._lensCenterOffset=o.lensCenterOffset,this.onSizeChanged=function(){s.aspectRatio=.5*s.width/s.height,s._scaleIn=new e.Vector2(2,2/s.aspectRatio),s._scaleFactor=new e.Vector2(1/s._postProcessScaleFactor*.5,1/s._postProcessScaleFactor*.5*s.aspectRatio),s._lensCenter=new e.Vector2(s._isRightEye?.5-.5*s._lensCenterOffset:.5+.5*s._lensCenterOffset,.5)},this.onApply=function(e){e.setFloat2("LensCenter",s._lensCenter.x,s._lensCenter.y),e.setFloat2("Scale",s._scaleFactor.x,s._scaleFactor.y),e.setFloat2("ScaleIn",s._scaleIn.x,s._scaleIn.y),e.setFloat4("HmdWarpParam",s._distortionFactors[0],s._distortionFactors[1],s._distortionFactors[2],s._distortionFactors[3])}}return __extends(i,t),i}(e.PostProcess);e.VRDistortionCorrectionPostProcess=t}(BABYLON||(BABYLON={})),function(e){!function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(e.JoystickAxis||(e.JoystickAxis={}));var t=e.JoystickAxis,i=function(){function i(r){var n=this;this._leftJoystick=!!r,this._joystickIndex=i._globalJoystickIndex,i._globalJoystickIndex++,this._axisTargetedByLeftAndRight=t.X,this._axisTargetedByUpAndDown=t.Y,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new e.SmartCollection,this.deltaPosition=e.Vector3.Zero(),this._joystickSensibility=25,this._inversedSensibility=1/(this._joystickSensibility/1e3),this._rotationSpeed=25,this._inverseRotationSpeed=1/(this._rotationSpeed/1e3),this._rotateOnAxisRelativeToMesh=!1,this._onResize=function(e){i.vjCanvasWidth=window.innerWidth,i.vjCanvasHeight=window.innerHeight,i.vjCanvas.width=i.vjCanvasWidth,i.vjCanvas.height=i.vjCanvasHeight,i.halfWidth=i.vjCanvasWidth/2,i.halfHeight=i.vjCanvasHeight/2},i.vjCanvas||(window.addEventListener("resize",this._onResize,!1),i.vjCanvas=document.createElement("canvas"),i.vjCanvasWidth=window.innerWidth,i.vjCanvasHeight=window.innerHeight,i.vjCanvas.width=window.innerWidth,i.vjCanvas.height=window.innerHeight,i.vjCanvas.style.width="100%",i.vjCanvas.style.height="100%",i.vjCanvas.style.position="absolute",i.vjCanvas.style.backgroundColor="transparent",i.vjCanvas.style.top="0px",i.vjCanvas.style.left="0px",i.vjCanvas.style.zIndex="5",i.vjCanvas.style.msTouchAction="none",i.vjCanvas.setAttribute("touch-action","none"),i.vjCanvasContext=i.vjCanvas.getContext("2d"),i.vjCanvasContext.strokeStyle="#ffffff",i.vjCanvasContext.lineWidth=2,document.body.appendChild(i.vjCanvas)),i.halfWidth=i.vjCanvas.width/2,i.halfHeight=i.vjCanvas.height/2,this.pressed=!1,this._joystickColor="cyan",this._joystickPointerID=-1,this._joystickPointerPos=new e.Vector2(0,0),this._joystickPreviousPointerPos=new e.Vector2(0,0),this._joystickPointerStartPos=new e.Vector2(0,0),this._deltaJoystickVector=new e.Vector2(0,0),this._onPointerDownHandlerRef=function(e){n._onPointerDown(e)},this._onPointerMoveHandlerRef=function(e){n._onPointerMove(e)},this._onPointerOutHandlerRef=function(e){n._onPointerUp(e)},this._onPointerUpHandlerRef=function(e){n._onPointerUp(e)},i.vjCanvas.addEventListener("pointerdown",this._onPointerDownHandlerRef,!1),i.vjCanvas.addEventListener("pointermove",this._onPointerMoveHandlerRef,!1),i.vjCanvas.addEventListener("pointerup",this._onPointerUpHandlerRef,!1),i.vjCanvas.addEventListener("pointerout",this._onPointerUpHandlerRef,!1),i.vjCanvas.addEventListener("contextmenu",function(e){e.preventDefault()},!1),requestAnimationFrame(function(){n._drawVirtualJoystick()})}return i.prototype.setJoystickSensibility=function(e){this._joystickSensibility=e,this._inversedSensibility=1/(this._joystickSensibility/1e3)},i.prototype._onPointerDown=function(e){e.preventDefault(),(!0===this._leftJoystick?e.clientX<i.halfWidth:e.clientX>i.halfWidth)&&this._joystickPointerID<0?(this._joystickPointerID=e.pointerId,this._joystickPointerStartPos.x=e.clientX,this._joystickPointerStartPos.y=e.clientY,this._joystickPointerPos=this._joystickPointerStartPos.clone(),this._joystickPreviousPointerPos=this._joystickPointerStartPos.clone(),this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this.pressed=!0,this._touches.add(e.pointerId.toString(),e)):i._globalJoystickIndex<2&&this._action&&(this._action(),this._touches.add(e.pointerId.toString(),{x:e.clientX,y:e.clientY,prevX:e.clientX,prevY:e.clientY}))},i.prototype._onPointerMove=function(e){if(this._joystickPointerID==e.pointerId){this._joystickPointerPos.x=e.clientX,this._joystickPointerPos.y=e.clientY,this._deltaJoystickVector=this._joystickPointerPos.clone(),this._deltaJoystickVector=this._deltaJoystickVector.subtract(this._joystickPointerStartPos);var i=(this.reverseLeftRight?-1:1)*this._deltaJoystickVector.x/this._inversedSensibility;switch(this._axisTargetedByLeftAndRight){case t.X:this.deltaPosition.x=Math.min(1,Math.max(-1,i));break;case t.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,i));break;case t.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,i))}var r=(this.reverseUpDown?1:-1)*this._deltaJoystickVector.y/this._inversedSensibility;switch(this._axisTargetedByUpAndDown){case t.X:this.deltaPosition.x=Math.min(1,Math.max(-1,r));break;case t.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,r));break;case t.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,r))}}else this._touches.item(e.pointerId.toString())&&(this._touches.item(e.pointerId.toString()).x=e.clientX,this._touches.item(e.pointerId.toString()).y=e.clientY)},i.prototype._onPointerUp=function(e){if(this._joystickPointerID==e.pointerId)i.vjCanvasContext.clearRect(this._joystickPointerStartPos.x-63,this._joystickPointerStartPos.y-63,126,126),i.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x-41,this._joystickPreviousPointerPos.y-41,82,82),this._joystickPointerID=-1,this.pressed=!1;else{var t=this._touches.item(e.pointerId.toString());t&&i.vjCanvasContext.clearRect(t.prevX-43,t.prevY-43,86,86)}this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this._touches.remove(e.pointerId.toString())},i.prototype.setJoystickColor=function(e){this._joystickColor=e},i.prototype.setActionOnTouch=function(e){this._action=e},i.prototype.setAxisForLeftRight=function(e){switch(e){case t.X:case t.Y:case t.Z:this._axisTargetedByLeftAndRight=e;break;default:this._axisTargetedByLeftAndRight=t.X}},i.prototype.setAxisForUpDown=function(e){switch(e){case t.X:case t.Y:case t.Z:this._axisTargetedByUpAndDown=e;break;default:this._axisTargetedByUpAndDown=t.Y}},i.prototype._clearCanvas=function(){this._leftJoystick?i.vjCanvasContext.clearRect(0,0,i.vjCanvasWidth/2,i.vjCanvasHeight):i.vjCanvasContext.clearRect(i.vjCanvasWidth/2,0,i.vjCanvasWidth,i.vjCanvasHeight)},i.prototype._drawVirtualJoystick=function(){var e=this;this.pressed&&this._touches.forEach(function(t){t.pointerId===e._joystickPointerID?(i.vjCanvasContext.clearRect(e._joystickPointerStartPos.x-63,e._joystickPointerStartPos.y-63,126,126),i.vjCanvasContext.clearRect(e._joystickPreviousPointerPos.x-41,e._joystickPreviousPointerPos.y-41,82,82),i.vjCanvasContext.beginPath(),i.vjCanvasContext.lineWidth=6,i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.arc(e._joystickPointerStartPos.x,e._joystickPointerStartPos.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.lineWidth=2,i.vjCanvasContext.arc(e._joystickPointerStartPos.x,e._joystickPointerStartPos.y,60,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.arc(e._joystickPointerPos.x,e._joystickPointerPos.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),e._joystickPreviousPointerPos=e._joystickPointerPos.clone()):(i.vjCanvasContext.clearRect(t.prevX-43,t.prevY-43,86,86),i.vjCanvasContext.beginPath(),i.vjCanvasContext.fillStyle="white",i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle="red",i.vjCanvasContext.lineWidth=6,i.vjCanvasContext.arc(t.x,t.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),t.prevX=t.x,t.prevY=t.y)}),requestAnimationFrame(function(){e._drawVirtualJoystick()})},i.prototype.releaseCanvas=function(){i.vjCanvas&&(i.vjCanvas.removeEventListener("pointerdown",this._onPointerDownHandlerRef),i.vjCanvas.removeEventListener("pointermove",this._onPointerMoveHandlerRef),i.vjCanvas.removeEventListener("pointerup",this._onPointerUpHandlerRef),i.vjCanvas.removeEventListener("pointerout",this._onPointerUpHandlerRef),window.removeEventListener("resize",this._onResize),document.body.removeChild(i.vjCanvas),i.vjCanvas=null)},i._globalJoystickIndex=0,i}();e.VirtualJoystick=i}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n){t.call(this,i,r,n),this._leftjoystick=new e.VirtualJoystick(!0),this._leftjoystick.setAxisForUpDown(e.JoystickAxis.Z),this._leftjoystick.setAxisForLeftRight(e.JoystickAxis.X),this._leftjoystick.setJoystickSensibility(.15),this._rightjoystick=new e.VirtualJoystick(!1),this._rightjoystick.setAxisForUpDown(e.JoystickAxis.X),this._rightjoystick.setAxisForLeftRight(e.JoystickAxis.Y),this._rightjoystick.reverseUpDown=!0,this._rightjoystick.setJoystickSensibility(.05),this._rightjoystick.setJoystickColor("yellow")}return __extends(i,t),i.prototype.getLeftJoystick=function(){return this._leftjoystick},i.prototype.getRightJoystick=function(){return this._rightjoystick},i.prototype._checkInputs=function(){var i=50*this._computeLocalCameraSpeed(),r=e.Matrix.RotationYawPitchRoll(this.rotation.y,this.rotation.x,0),n=e.Vector3.TransformCoordinates(new e.Vector3(this._leftjoystick.deltaPosition.x*i,this._leftjoystick.deltaPosition.y*i,this._leftjoystick.deltaPosition.z*i),r);this.cameraDirection=this.cameraDirection.add(n),this.cameraRotation=this.cameraRotation.addVector3(this._rightjoystick.deltaPosition),this._leftjoystick.pressed||(this._leftjoystick.deltaPosition=this._leftjoystick.deltaPosition.scale(.9)),this._rightjoystick.pressed||(this._rightjoystick.deltaPosition=this._rightjoystick.deltaPosition.scale(.9)),t.prototype._checkInputs.call(this)},i.prototype.dispose=function(){this._leftjoystick.releaseCanvas(),t.prototype.dispose.call(this)},i}(e.FreeCamera);e.VirtualJoysticksCamera=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o){t.call(this,i,r),this._textures=new Array,this._floats=new Array,this._floatsArrays={},this._colors3=new Array,this._colors4=new Array,this._vectors2=new Array,this._vectors3=new Array,this._vectors4=new Array,this._matrices=new Array,this._matrices3x3=new Array,this._matrices2x2=new Array,this._cachedWorldViewMatrix=new e.Matrix,this._shaderPath=n,o.needAlphaBlending=o.needAlphaBlending||!1,o.needAlphaTesting=o.needAlphaTesting||!1,o.attributes=o.attributes||["position","normal","uv"],o.uniforms=o.uniforms||["worldViewProjection"],o.samplers=o.samplers||[],o.defines=o.defines||[],this._options=o}return __extends(i,t),i.prototype.needAlphaBlending=function(){return this._options.needAlphaBlending},i.prototype.needAlphaTesting=function(){return this._options.needAlphaTesting},i.prototype._checkUniform=function(e){-1===this._options.uniforms.indexOf(e)&&this._options.uniforms.push(e)},i.prototype.setTexture=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._textures[e]=t,this},i.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},i.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},i.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},i.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},i.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},i.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},i.prototype.setVector4=function(e,t){return this._checkUniform(e),this._vectors4[e]=t,this},i.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},i.prototype.setMatrix3x3=function(e,t){return this._checkUniform(e),this._matrices3x3[e]=t,this},i.prototype.setMatrix2x2=function(e,t){return this._checkUniform(e),this._matrices2x2[e]=t,this},i.prototype.isReady=function(t,i){var r=this.getScene(),n=r.getEngine();if(!this.checkReadyOnEveryCall&&this._renderId===r.getRenderId())return!0;var o=[],s=new e.EffectFallbacks;i&&o.push("#define INSTANCES");for(var a=0;a<this._options.defines.length;a++)o.push(this._options.defines[a]);t&&t.useBones&&t.computeBonesUsingShaders&&(o.push("#define BONES"),o.push("#define BonesPerMesh "+(t.skeleton.bones.length+1)),o.push("#define BONES4"),s.addFallback(0,"BONES4")),n.getAlphaTesting()&&o.push("#define ALPHATEST");var h=this._effect,c=o.join("\n");return this._effect=n.createEffect(this._shaderPath,this._options.attributes,this._options.uniforms,this._options.samplers,c,s,this.onCompiled,this.onError),!!this._effect.isReady()&&(h!==this._effect&&r.resetCachedMaterial(),this._renderId=r.getRenderId(),!0)},i.prototype.bindOnlyWorldMatrix=function(e){var t=this.getScene();-1!==this._options.uniforms.indexOf("world")&&this._effect.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(t.getViewMatrix(),this._cachedWorldViewMatrix),this._effect.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&this._effect.setMatrix("worldViewProjection",e.multiply(t.getTransformMatrix()))},i.prototype.bind=function(e,i){if(this.bindOnlyWorldMatrix(e),this.getScene().getCachedMaterial()!==this){for(var r in-1!==this._options.uniforms.indexOf("view")&&this._effect.setMatrix("view",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf("projection")&&this._effect.setMatrix("projection",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf("viewProjection")&&this._effect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),i&&i.useBones&&i.computeBonesUsingShaders&&this._effect.setMatrices("mBones",i.skeleton.getTransformMatrices()),this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._vectors4)this._effect.setVector4(r,this._vectors4[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);for(r in this._matrices3x3)this._effect.setMatrix3x3(r,this._matrices3x3[r]);for(r in this._matrices2x2)this._effect.setMatrix2x2(r,this._matrices2x2[r])}t.prototype.bind.call(this,e,i)},i.prototype.clone=function(e){return new i(e,this.getScene(),this._shaderPath,this._options)},i.prototype.dispose=function(e){for(var i in this._textures)this._textures[i].dispose();this._textures=[],t.prototype.dispose.call(this,e)},i}(e.Material);e.ShaderMaterial=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(){}return t.prototype.set=function(t,i){switch(i){case e.VertexBuffer.PositionKind:this.positions=t;break;case e.VertexBuffer.NormalKind:this.normals=t;break;case e.VertexBuffer.UVKind:this.uvs=t;break;case e.VertexBuffer.UV2Kind:this.uvs2=t;break;case e.VertexBuffer.UV3Kind:this.uvs3=t;break;case e.VertexBuffer.UV4Kind:this.uvs4=t;break;case e.VertexBuffer.UV5Kind:this.uvs5=t;break;case e.VertexBuffer.UV6Kind:this.uvs6=t;break;case e.VertexBuffer.ColorKind:this.colors=t;break;case e.VertexBuffer.MatricesIndicesKind:this.matricesIndices=t;break;case e.VertexBuffer.MatricesWeightsKind:this.matricesWeights=t}},t.prototype.applyToMesh=function(e,t){this._applyTo(e,t)},t.prototype.applyToGeometry=function(e,t){this._applyTo(e,t)},t.prototype.updateMesh=function(e,t,i){this._update(e)},t.prototype.updateGeometry=function(e,t,i){this._update(e)},t.prototype._applyTo=function(t,i){this.positions&&t.setVerticesData(e.VertexBuffer.PositionKind,this.positions,i),this.normals&&t.setVerticesData(e.VertexBuffer.NormalKind,this.normals,i),this.uvs&&t.setVerticesData(e.VertexBuffer.UVKind,this.uvs,i),this.uvs2&&t.setVerticesData(e.VertexBuffer.UV2Kind,this.uvs2,i),this.uvs3&&t.setVerticesData(e.VertexBuffer.UV3Kind,this.uvs3,i),this.uvs4&&t.setVerticesData(e.VertexBuffer.UV4Kind,this.uvs4,i),this.uvs5&&t.setVerticesData(e.VertexBuffer.UV5Kind,this.uvs5,i),this.uvs6&&t.setVerticesData(e.VertexBuffer.UV6Kind,this.uvs6,i),this.colors&&t.setVerticesData(e.VertexBuffer.ColorKind,this.colors,i),this.matricesIndices&&t.setVerticesData(e.VertexBuffer.MatricesIndicesKind,this.matricesIndices,i),this.matricesWeights&&t.setVerticesData(e.VertexBuffer.MatricesWeightsKind,this.matricesWeights,i),this.indices&&t.setIndices(this.indices)},t.prototype._update=function(t,i,r){this.positions&&t.updateVerticesData(e.VertexBuffer.PositionKind,this.positions,i,r),this.normals&&t.updateVerticesData(e.VertexBuffer.NormalKind,this.normals,i,r),this.uvs&&t.updateVerticesData(e.VertexBuffer.UVKind,this.uvs,i,r),this.uvs2&&t.updateVerticesData(e.VertexBuffer.UV2Kind,this.uvs2,i,r),this.uvs3&&t.updateVerticesData(e.VertexBuffer.UV3Kind,this.uvs3,i,r),this.uvs4&&t.updateVerticesData(e.VertexBuffer.UV4Kind,this.uvs4,i,r),this.uvs5&&t.updateVerticesData(e.VertexBuffer.UV5Kind,this.uvs5,i,r),this.uvs6&&t.updateVerticesData(e.VertexBuffer.UV6Kind,this.uvs6,i,r),this.colors&&t.updateVerticesData(e.VertexBuffer.ColorKind,this.colors,i,r),this.matricesIndices&&t.updateVerticesData(e.VertexBuffer.MatricesIndicesKind,this.matricesIndices,i,r),this.matricesWeights&&t.updateVerticesData(e.VertexBuffer.MatricesWeightsKind,this.matricesWeights,i,r),this.indices&&t.setIndices(this.indices)},t.prototype.transform=function(t){var i,r=e.Vector3.Zero();if(this.positions){var n=e.Vector3.Zero();for(i=0;i<this.positions.length;i+=3)e.Vector3.FromArrayToRef(this.positions,i,n),e.Vector3.TransformCoordinatesToRef(n,t,r),this.positions[i]=r.x,this.positions[i+1]=r.y,this.positions[i+2]=r.z}if(this.normals){var o=e.Vector3.Zero();for(i=0;i<this.normals.length;i+=3)e.Vector3.FromArrayToRef(this.normals,i,o),e.Vector3.TransformNormalToRef(o,t,r),this.normals[i]=r.x,this.normals[i+1]=r.y,this.normals[i+2]=r.z}},t.prototype.merge=function(e){var t;if(e.indices){this.indices||(this.indices=[]);var i=this.positions?this.positions.length/3:0;for(t=0;t<e.indices.length;t++)this.indices.push(e.indices[t]+i)}if(e.positions)for(this.positions||(this.positions=[]),t=0;t<e.positions.length;t++)this.positions.push(e.positions[t]);if(e.normals)for(this.normals||(this.normals=[]),t=0;t<e.normals.length;t++)this.normals.push(e.normals[t]);if(e.uvs)for(this.uvs||(this.uvs=[]),t=0;t<e.uvs.length;t++)this.uvs.push(e.uvs[t]);if(e.uvs2)for(this.uvs2||(this.uvs2=[]),t=0;t<e.uvs2.length;t++)this.uvs2.push(e.uvs2[t]);if(e.uvs3)for(this.uvs3||(this.uvs3=[]),t=0;t<e.uvs3.length;t++)this.uvs3.push(e.uvs3[t]);if(e.uvs4)for(this.uvs4||(this.uvs4=[]),t=0;t<e.uvs4.length;t++)this.uvs4.push(e.uvs4[t]);if(e.uvs5)for(this.uvs5||(this.uvs5=[]),t=0;t<e.uvs5.length;t++)this.uvs5.push(e.uvs5[t]);if(e.uvs6)for(this.uvs6||(this.uvs6=[]),t=0;t<e.uvs6.length;t++)this.uvs6.push(e.uvs6[t]);if(e.matricesIndices)for(this.matricesIndices||(this.matricesIndices=[]),t=0;t<e.matricesIndices.length;t++)this.matricesIndices.push(e.matricesIndices[t]);if(e.matricesWeights)for(this.matricesWeights||(this.matricesWeights=[]),t=0;t<e.matricesWeights.length;t++)this.matricesWeights.push(e.matricesWeights[t]);if(e.colors)for(this.colors||(this.colors=[]),t=0;t<e.colors.length;t++)this.colors.push(e.colors[t])},t.ExtractFromMesh=function(e,i){return t._ExtractFrom(e,i)},t.ExtractFromGeometry=function(e,i){return t._ExtractFrom(e,i)},t._ExtractFrom=function(i,r){var n=new t;return i.isVerticesDataPresent(e.VertexBuffer.PositionKind)&&(n.positions=i.getVerticesData(e.VertexBuffer.PositionKind,r)),i.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&(n.normals=i.getVerticesData(e.VertexBuffer.NormalKind,r)),i.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.uvs=i.getVerticesData(e.VertexBuffer.UVKind,r)),i.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(n.uvs2=i.getVerticesData(e.VertexBuffer.UV2Kind,r)),i.isVerticesDataPresent(e.VertexBuffer.UV3Kind)&&(n.uvs3=i.getVerticesData(e.VertexBuffer.UV3Kind,r)),i.isVerticesDataPresent(e.VertexBuffer.UV4Kind)&&(n.uvs4=i.getVerticesData(e.VertexBuffer.UV4Kind,r)),i.isVerticesDataPresent(e.VertexBuffer.UV5Kind)&&(n.uvs5=i.getVerticesData(e.VertexBuffer.UV5Kind,r)),i.isVerticesDataPresent(e.VertexBuffer.UV6Kind)&&(n.uvs6=i.getVerticesData(e.VertexBuffer.UV6Kind,r)),i.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(n.colors=i.getVerticesData(e.VertexBuffer.ColorKind,r)),i.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind)&&(n.matricesIndices=i.getVerticesData(e.VertexBuffer.MatricesIndicesKind,r)),i.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind)&&(n.matricesWeights=i.getVerticesData(e.VertexBuffer.MatricesWeightsKind,r)),n.indices=i.getIndices(r),n},t.CreateRibbon=function(i){var r=i.pathArray,n=i.closeArray||!1,o=i.closePath||!1,s=Math.floor(r[0].length/2),a=i.offset||s;a=a>s?s:Math.floor(a);var h,c,l,u,d=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,f=[],p=[],m=[],g=[],v=[],_=[],y=[],x=[],b=[],M=[];if(r.length<2){var E=[],T=[];for(l=0;l<r[0].length-a;l++)E.push(r[0][l]),T.push(r[0][l+a]);r=[E,T]}var w,S,A,P,C,D,R,I,L,O=0,B=o?1:0;for(h=r[0].length,c=0;c<r.length;c++){for(y[c]=0,v[c]=[0],h=(S=(w=r[c]).length)>h?h:S,u=0;S>u;)f.push(w[u].x,w[u].y,w[u].z),u>0&&(A=w[u].subtract(w[u-1]).length()+y[c],v[c].push(A),y[c]=A),u++;o&&(u--,f.push(w[0].x,w[0].y,w[0].z),A=w[u].subtract(w[0]).length()+y[c],v[c].push(A),y[c]=A),b[c]=S+B,M[c]=O,O+=S+B}for(l=0;h+B>l;l++){for(x[l]=0,_[l]=[0],c=0;c<r.length-1;c++)P=r[c],C=r[c+1],l===h?(D=P[0],R=C[0]):(D=P[l],R=C[l]),A=R.subtract(D).length()+x[l],_[l].push(A),x[l]=A;n&&(P=r[c],C=r[0],l===h&&(R=C[0]),A=R.subtract(D).length()+x[l],x[l]=A)}for(c=0;c<r.length;c++)for(l=0;h+B>l;l++)I=v[c][l]/y[c],L=_[l][c]/x[l],g.push(I,L);for(var F=0,N=b[c=0]-1,V=b[c+1]-1,U=V>N?N:V,z=M[1]-M[0],k=n?b.length:b.length-1;U>=F&&k>c;)p.push(F,F+z,F+1),p.push(F+z+1,F+1,F+z),(F+=1)===U&&(++c===b.length-1?(z=M[0]-M[c],N=b[c]-1,V=b[0]-1):(z=M[c+1]-M[c],N=b[c]-1,V=b[c+1]-1),F=M[c],U=V>N?N+F:V+F);if(t.ComputeNormals(f,p,m),o){var G=0,W=0;for(c=0;c<r.length;c++)G=3*M[c],W=c+1<r.length?3*(M[c+1]-1):m.length-3,m[G]=.5*(m[G]+m[W]),m[G+1]=.5*(m[G+1]+m[W+1]),m[G+2]=.5*(m[G+2]+m[W+2]),m[W]=m[G],m[W+1]=m[G+1],m[W+2]=m[G+2]}t._ComputeSides(d,f,p,m,g);var H=new t;return H.indices=p,H.positions=f,H.normals=m,H.uvs=g,o&&(H._idx=M),H},t.CreateBox=function(i){for(var r=[new e.Vector3(0,0,1),new e.Vector3(0,0,-1),new e.Vector3(1,0,0),new e.Vector3(-1,0,0),new e.Vector3(0,1,0),new e.Vector3(0,-1,0)],n=[],o=[],s=[],a=[],h=i.width||i.size||1,c=i.height||i.size||1,l=i.depth||i.size||1,u=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,d=i.faceUV||new Array(6),f=i.faceColors,p=[],m=0;6>m;m++)void 0===d[m]&&(d[m]=new e.Vector4(0,0,1,1)),f&&void 0===f[m]&&(f[m]=new e.Color4(1,1,1,1));for(var g=new e.Vector3(h/2,c/2,l/2),v=0;v<r.length;v++){var _=r[v],y=new e.Vector3(_.y,_.z,_.x),x=e.Vector3.Cross(_,y),b=o.length/3;n.push(b),n.push(b+1),n.push(b+2),n.push(b),n.push(b+2),n.push(b+3);var M=_.subtract(y).subtract(x).multiply(g);o.push(M.x,M.y,M.z),s.push(_.x,_.y,_.z),a.push(d[v].z,d[v].w),f&&p.push(f[v].r,f[v].g,f[v].b,f[v].a),M=_.subtract(y).add(x).multiply(g),o.push(M.x,M.y,M.z),s.push(_.x,_.y,_.z),a.push(d[v].x,d[v].w),f&&p.push(f[v].r,f[v].g,f[v].b,f[v].a),M=_.add(y).add(x).multiply(g),o.push(M.x,M.y,M.z),s.push(_.x,_.y,_.z),a.push(d[v].x,d[v].y),f&&p.push(f[v].r,f[v].g,f[v].b,f[v].a),M=_.add(y).subtract(x).multiply(g),o.push(M.x,M.y,M.z),s.push(_.x,_.y,_.z),a.push(d[v].z,d[v].y),f&&p.push(f[v].r,f[v].g,f[v].b,f[v].a)}t._ComputeSides(u,o,n,s,a);var E=new t;if(E.indices=n,E.positions=o,E.normals=s,E.uvs=a,f){var T=u===e.Mesh.DOUBLESIDE?p.concat(p):p;E.colors=T}return E},t.CreateSphere=function(i){for(var r=i.segments||32,n=i.diameterX||i.diameter||1,o=i.diameterY||i.diameter||1,s=i.diameterZ||i.diameter||1,a=i.arc<=0?1:i.arc||1,h=i.slice<=0?1:i.slice||1,c=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,l=new e.Vector3(n/2,o/2,s/2),u=2+r,d=2*u,f=[],p=[],m=[],g=[],v=0;u>=v;v++){for(var _=v/u,y=_*Math.PI*h,x=0;d>=x;x++){var b=x/d,M=b*Math.PI*2*a,E=e.Matrix.RotationZ(-y),T=e.Matrix.RotationY(M),w=e.Vector3.TransformCoordinates(e.Vector3.Up(),E),S=e.Vector3.TransformCoordinates(w,T).multiply(l),A=e.Vector3.Normalize(S);p.push(S.x,S.y,S.z),m.push(A.x,A.y,A.z),g.push(b,_)}if(v>0)for(var P=p.length/3,C=P-2*(d+1);P>C+d+2;C++)f.push(C),f.push(C+1),f.push(C+d+1),f.push(C+d+1),f.push(C+1),f.push(C+d+2)}t._ComputeSides(c,p,f,m,g);var D=new t;return D.indices=f,D.positions=p,D.normals=m,D.uvs=g,D},t.CreateCylinder=function(i){for(var r=i.height||2,n=0===i.diameterTop?0:i.diameterTop||i.diameter||1,o=i.diameterBottom||i.diameter||1,s=i.tessellation||24,a=i.subdivisions||1,h=i.arc<=0?1:i.arc||1,c=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,l=i.faceUV||new Array(3),u=i.faceColors,d=0;3>d;d++)u&&void 0===u[d]&&(u[d]=new e.Color4(1,1,1,1)),l&&void 0===l[d]&&(l[d]=new e.Vector4(0,0,1,1));var f,p,m,g,v,_=[],y=[],x=[],b=[],M=[],E=2*Math.PI*h/s,T=(o-n)/2/r,w=e.Vector3.Zero(),S=e.Vector3.Zero();for(g=0;a>=g;g++)for(m=((p=g/a)*(n-o)+o)/2,v=0;s>=v;v++)f=v*E,w.x=Math.cos(-f)*m,w.y=-r/2+p*r,w.z=Math.sin(-f)*m,0===n&&g===a?(S.x=x[x.length-3*(s+1)],S.y=x[x.length-3*(s+1)+1],S.z=x[x.length-3*(s+1)+2]):(S.x=w.x,S.z=w.z,S.y=Math.sqrt(S.x*S.x+S.z*S.z)*T,S.normalize()),y.push(w.x,w.y,w.z),x.push(S.x,S.y,S.z),b.push(l[1].x+(l[1].z-l[1].x)*v/s,l[1].y+(l[1].w-l[1].y)*p),u&&M.push(u[1].r,u[1].g,u[1].b,u[1].a);for(g=0;a>g;g++)for(v=0;s>v;v++){var A=g*(s+1)+v,P=(g+1)*(s+1)+v,C=g*(s+1)+(v+1),D=(g+1)*(s+1)+(v+1);_.push(A,P,C),_.push(D,C,P)}var R=function(t){var i=t?n/2:o/2;if(0!==i){var a,c,d,f,p=t?l[2]:l[0];u&&(f=t?u[2]:u[0]);var m=y.length/3,g=t?r/2:-r/2,v=new e.Vector3(0,g,0);y.push(v.x,v.y,v.z),x.push(0,t?1:-1,0),b.push(p.x+.5*(p.z-p.x),p.y+.5*(p.w-p.y)),u&&M.push(f.r,f.g,f.b,f.a);var E=new e.Vector2(.5,.5);for(d=0;s>=d;d++){a=2*Math.PI*d*h/s;var T=Math.cos(-a),w=Math.sin(-a);c=new e.Vector3(T*i,g,w*i);var S=new e.Vector2(T*E.x+.5,w*E.y+.5);y.push(c.x,c.y,c.z),x.push(0,t?1:-1,0),b.push(p.x+(p.z-p.x)*S.x,p.y+(p.w-p.y)*S.y),u&&M.push(f.r,f.g,f.b,f.a)}for(d=0;s>d;d++)t?(_.push(m),_.push(m+(d+2)),_.push(m+(d+1))):(_.push(m),_.push(m+(d+1)),_.push(m+(d+2)))}};R(!1),R(!0),t._ComputeSides(c,y,_,x,b);var I=new t;return I.indices=_,I.positions=y,I.normals=x,I.uvs=b,u&&(I.colors=M),I},t.CreateTorus=function(i){for(var r=[],n=[],o=[],s=[],a=i.diameter||1,h=i.thickness||.5,c=i.tessellation||16,l=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,u=c+1,d=0;c>=d;d++)for(var f=d/c,p=d*Math.PI*2/c-Math.PI/2,m=e.Matrix.Translation(a/2,0,0).multiply(e.Matrix.RotationY(p)),g=0;c>=g;g++){var v=1-g/c,_=g*Math.PI*2/c+Math.PI,y=Math.cos(_),x=Math.sin(_),b=new e.Vector3(y,x,0),M=b.scale(h/2),E=new e.Vector2(f,v);M=e.Vector3.TransformCoordinates(M,m),b=e.Vector3.TransformNormal(b,m),n.push(M.x,M.y,M.z),o.push(b.x,b.y,b.z),s.push(E.x,E.y);var T=(d+1)%u,w=(g+1)%u;r.push(d*u+g),r.push(d*u+w),r.push(T*u+g),r.push(d*u+w),r.push(T*u+w),r.push(T*u+g)}t._ComputeSides(l,n,r,o,s);var S=new t;return S.indices=r,S.positions=n,S.normals=o,S.uvs=s,S},t.CreateLines=function(e){for(var i=[],r=[],n=e.points,o=0;o<n.length;o++)r.push(n[o].x,n[o].y,n[o].z),o>0&&(i.push(o-1),i.push(o));var s=new t;return s.indices=i,s.positions=r,s},t.CreateDashedLines=function(i){var r,n,o=i.dashSize||3,s=i.gapSize||1,a=i.dashNb||200,h=i.points,c=new Array,l=new Array,u=e.Vector3.Zero(),d=0,f=0,p=0,m=0,g=0;for(g=0;g<h.length-1;g++)h[g+1].subtractToRef(h[g],u),d+=u.length();for(n=o*(r=d/a)/(o+s),g=0;g<h.length-1;g++){h[g+1].subtractToRef(h[g],u),f=Math.floor(u.length()/r),u.normalize();for(var v=0;f>v;v++)p=r*v,c.push(h[g].x+p*u.x,h[g].y+p*u.y,h[g].z+p*u.z),c.push(h[g].x+(p+n)*u.x,h[g].y+(p+n)*u.y,h[g].z+(p+n)*u.z),l.push(m,m+1),m+=2}var _=new t;return _.positions=c,_.indices=l,_},t.CreateGround=function(i){var r,n,o=[],s=[],a=[],h=[],c=i.width||1,l=i.height||1,u=i.subdivisions||1;for(r=0;u>=r;r++)for(n=0;u>=n;n++){var d=new e.Vector3(n*c/u-c/2,0,(u-r)*l/u-l/2),f=new e.Vector3(0,1,0);s.push(d.x,d.y,d.z),a.push(f.x,f.y,f.z),h.push(n/u,1-r/u)}for(r=0;u>r;r++)for(n=0;u>n;n++)o.push(n+1+(r+1)*(u+1)),o.push(n+1+r*(u+1)),o.push(n+r*(u+1)),o.push(n+(r+1)*(u+1)),o.push(n+1+(r+1)*(u+1)),o.push(n+r*(u+1));var p=new t;return p.indices=o,p.positions=s,p.normals=a,p.uvs=h,p},t.CreateTiledGround=function(i){function r(t,i,r,s){var a=m.length/3,h=f.w+1;for(n=0;n<f.h;n++)for(o=0;o<f.w;o++){var c=[a+o+n*h,a+(o+1)+n*h,a+(o+1)+(n+1)*h,a+o+(n+1)*h];p.push(c[1]),p.push(c[2]),p.push(c[3]),p.push(c[0]),p.push(c[1]),p.push(c[3])}var l=e.Vector3.Zero(),u=new e.Vector3(0,1,0);for(n=0;n<=f.h;n++)for(l.z=n*(s-i)/f.h+i,o=0;o<=f.w;o++)l.x=o*(r-t)/f.w+t,l.y=0,m.push(l.x,l.y,l.z),g.push(u.x,u.y,u.z),v.push(o/f.w,n/f.h)}var n,o,s,a,h=i.xmin,c=i.zmin,l=i.xmax,u=i.zmax,d=i.subdivisions||{w:1,h:1},f=i.precision||{w:1,h:1},p=[],m=[],g=[],v=[];d.h=d.w<1?1:d.h,d.w=d.w<1?1:d.w,f.w=f.w<1?1:f.w,f.h=f.h<1?1:f.h;var _=(l-h)/d.w,y=(u-c)/d.h;for(s=0;s<d.h;s++)for(a=0;a<d.w;a++)r(h+a*_,c+s*y,h+(a+1)*_,c+(s+1)*y);var x=new t;return x.indices=p,x.positions=m,x.normals=g,x.uvs=v,x},t.CreateGroundFromHeightMap=function(i){var r,n,o=[],s=[],a=[],h=[];for(r=0;r<=i.subdivisions;r++)for(n=0;n<=i.subdivisions;n++){var c=new e.Vector3(n*i.width/i.subdivisions-i.width/2,0,(i.subdivisions-r)*i.height/i.subdivisions-i.height/2),l=4*(((c.x+i.width/2)/i.width*(i.bufferWidth-1)|0)+((1-(c.z+i.height/2)/i.height)*(i.bufferHeight-1)|0)*i.bufferWidth),u=.3*(i.buffer[l]/255)+.59*(i.buffer[l+1]/255)+.11*(i.buffer[l+2]/255);c.y=i.minHeight+(i.maxHeight-i.minHeight)*u,s.push(c.x,c.y,c.z),a.push(0,0,0),h.push(n/i.subdivisions,1-r/i.subdivisions)}for(r=0;r<i.subdivisions;r++)for(n=0;n<i.subdivisions;n++)o.push(n+1+(r+1)*(i.subdivisions+1)),o.push(n+1+r*(i.subdivisions+1)),o.push(n+r*(i.subdivisions+1)),o.push(n+(r+1)*(i.subdivisions+1)),o.push(n+1+(r+1)*(i.subdivisions+1)),o.push(n+r*(i.subdivisions+1));t.ComputeNormals(s,o,a);var d=new t;return d.indices=o,d.positions=s,d.normals=a,d.uvs=h,d},t.CreatePlane=function(i){var r=[],n=[],o=[],s=[],a=i.width||i.size||1,h=i.height||i.size||1,c=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,l=a/2,u=h/2;n.push(-l,-u,0),o.push(0,0,-1),s.push(0,0),n.push(l,-u,0),o.push(0,0,-1),s.push(1,0),n.push(l,u,0),o.push(0,0,-1),s.push(1,1),n.push(-l,u,0),o.push(0,0,-1),s.push(0,1),r.push(0),r.push(1),r.push(2),r.push(0),r.push(2),r.push(3),t._ComputeSides(c,n,r,o,s);var d=new t;return d.indices=r,d.positions=n,d.normals=o,d.uvs=s,d},t.CreateDisc=function(i){var r=[],n=[],o=[],s=[],a=i.radius||.5,h=i.tessellation||64,c=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE;r.push(0,0,0),s.push(.5,.5);for(var l=2*Math.PI/h,u=0;u<2*Math.PI;u+=l){var d=Math.cos(u),f=Math.sin(u),p=(d+1)/2,m=(1-f)/2;r.push(a*d,a*f,0),s.push(p,m)}r.push(r[3],r[4],r[5]),s.push(s[2],s[3]);for(var g=r.length/3,v=1;g-1>v;v++)n.push(v+1,0,v);t.ComputeNormals(r,n,o),t._ComputeSides(c,r,n,o,s);var _=new t;return _.indices=n,_.positions=r,_.normals=o,_.uvs=s,_},t.CreatePolyhedron=function(i){var r=[];r[0]={vertex:[[0,0,1.732051],[1.632993,0,-.5773503],[-.8164966,1.414214,-.5773503],[-.8164966,-1.414214,-.5773503]],face:[[0,1,2],[0,2,3],[0,3,1],[1,3,2]]},r[1]={vertex:[[0,0,1.414214],[1.414214,0,0],[0,1.414214,0],[-1.414214,0,0],[0,-1.414214,0],[0,0,-1.414214]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,1],[1,4,5],[1,5,2],[2,5,3],[3,5,4]]},r[2]={vertex:[[0,0,1.070466],[.7136442,0,.7978784],[-.3568221,.618034,.7978784],[-.3568221,-.618034,.7978784],[.7978784,.618034,.3568221],[.7978784,-.618034,.3568221],[-.9341724,.381966,.3568221],[.1362939,1,.3568221],[.1362939,-1,.3568221],[-.9341724,-.381966,.3568221],[.9341724,.381966,-.3568221],[.9341724,-.381966,-.3568221],[-.7978784,.618034,-.3568221],[-.1362939,1,-.3568221],[-.1362939,-1,-.3568221],[-.7978784,-.618034,-.3568221],[.3568221,.618034,-.7978784],[.3568221,-.618034,-.7978784],[-.7136442,0,-.7978784],[0,0,-1.070466]],face:[[0,1,4,7,2],[0,2,6,9,3],[0,3,8,5,1],[1,5,11,10,4],[2,7,13,12,6],[3,9,15,14,8],[4,10,16,13,7],[5,8,14,17,11],[6,12,18,15,9],[10,11,17,19,16],[12,13,16,19,18],[14,15,18,19,17]]},r[3]={vertex:[[0,0,1.175571],[1.051462,0,.5257311],[.3249197,1,.5257311],[-.8506508,.618034,.5257311],[-.8506508,-.618034,.5257311],[.3249197,-1,.5257311],[.8506508,.618034,-.5257311],[.8506508,-.618034,-.5257311],[-.3249197,1,-.5257311],[-1.051462,0,-.5257311],[-.3249197,-1,-.5257311],[0,0,-1.175571]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,5],[0,5,1],[1,5,7],[1,7,6],[1,6,2],[2,6,8],[2,8,3],[3,8,9],[3,9,4],[4,9,10],[4,10,5],[5,10,7],[6,7,11],[6,11,8],[7,10,11],[8,11,9],[9,11,10]]},r[4]={vertex:[[0,0,1.070722],[.7148135,0,.7971752],[-.104682,.7071068,.7971752],[-.6841528,.2071068,.7971752],[-.104682,-.7071068,.7971752],[.6101315,.7071068,.5236279],[1.04156,.2071068,.1367736],[.6101315,-.7071068,.5236279],[-.3574067,1,.1367736],[-.7888348,-.5,.5236279],[-.9368776,.5,.1367736],[-.3574067,-1,.1367736],[.3574067,1,-.1367736],[.9368776,-.5,-.1367736],[.7888348,.5,-.5236279],[.3574067,-1,-.1367736],[-.6101315,.7071068,-.5236279],[-1.04156,-.2071068,-.1367736],[-.6101315,-.7071068,-.5236279],[.104682,.7071068,-.7971752],[.6841528,-.2071068,-.7971752],[.104682,-.7071068,-.7971752],[-.7148135,0,-.7971752],[0,0,-1.070722]],face:[[0,2,3],[1,6,5],[4,9,11],[7,15,13],[8,16,10],[12,14,19],[17,22,18],[20,21,23],[0,1,5,2],[0,3,9,4],[0,4,7,1],[1,7,13,6],[2,5,12,8],[2,8,10,3],[3,10,17,9],[4,11,15,7],[5,6,14,12],[6,13,20,14],[8,12,19,16],[9,17,18,11],[10,16,22,17],[11,18,21,15],[13,15,21,20],[14,20,23,19],[16,19,23,22],[18,22,23,21]]},r[5]={vertex:[[0,0,1.322876],[1.309307,0,.1889822],[-.9819805,.8660254,.1889822],[.1636634,-1.299038,.1889822],[.3273268,.8660254,-.9449112],[-.8183171,-.4330127,-.9449112]],face:[[0,3,1],[2,4,5],[0,1,4,2],[0,2,5,3],[1,3,5,4]]},r[6]={vertex:[[0,0,1.159953],[1.013464,0,.5642542],[-.3501431,.9510565,.5642542],[-.7715208,-.6571639,.5642542],[.6633206,.9510565,-.03144481],[.8682979,-.6571639,-.3996071],[-1.121664,.2938926,-.03144481],[-.2348831,-1.063314,-.3996071],[.5181548,.2938926,-.9953061],[-.5850262,-.112257,-.9953061]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,9,7],[5,7,9,8],[0,3,7,5,1],[2,4,8,9,6]]},r[7]={vertex:[[0,0,1.118034],[.8944272,0,.6708204],[-.2236068,.8660254,.6708204],[-.7826238,-.4330127,.6708204],[.6708204,.8660254,.2236068],[1.006231,-.4330127,-.2236068],[-1.006231,.4330127,.2236068],[-.6708204,-.8660254,-.2236068],[.7826238,.4330127,-.6708204],[.2236068,-.8660254,-.6708204],[-.8944272,0,-.6708204],[0,0,-1.118034]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,10,7],[5,9,11,8],[7,10,11,9],[0,3,7,9,5,1],[2,4,8,11,10,6]]},r[8]={vertex:[[-.729665,.670121,.319155],[-.655235,-.29213,-.754096],[-.093922,-.607123,.537818],[.702196,.595691,.485187],[.776626,-.36656,-.588064]],face:[[1,4,2],[0,1,2],[3,0,2],[4,3,2],[4,1,0,3]]},r[9]={vertex:[[-.868849,-.100041,.61257],[-.329458,.976099,.28078],[-.26629,-.013796,-.477654],[-.13392,-1.034115,.229829],[.738834,.707117,-.307018],[.859683,-.535264,-.338508]],face:[[3,0,2],[5,3,2],[4,5,2],[1,4,2],[0,1,2],[0,3,5,4,1]]},r[10]={vertex:[[-.610389,.243975,.531213],[-.187812,-.48795,-.664016],[-.187812,.9759,-.664016],[.187812,-.9759,.664016],[.798201,.243975,.132803]],face:[[1,3,0],[3,4,0],[3,1,4],[0,2,1],[0,4,2],[2,4,1]]},r[11]={vertex:[[-1.028778,.392027,-.048786],[-.640503,-.646161,.621837],[-.125162,-.395663,-.540059],[.004683,.888447,-.651988],[.125161,.395663,.540059],[.632925,-.791376,.433102],[1.031672,.157063,-.354165]],face:[[3,2,0],[2,1,0],[2,5,1],[0,4,3],[0,1,4],[4,1,5],[2,3,6],[3,4,6],[5,2,6],[4,5,6]]},r[12]={vertex:[[-.669867,.334933,-.529576],[-.669867,.334933,.529577],[-.4043,1.212901,0],[-.334933,-.669867,-.529576],[-.334933,-.669867,.529577],[.334933,.669867,-.529576],[.334933,.669867,.529577],[.4043,-1.212901,0],[.669867,-.334933,-.529576],[.669867,-.334933,.529577]],face:[[8,9,7],[6,5,2],[3,8,7],[5,0,2],[4,3,7],[0,1,2],[9,4,7],[1,6,2],[9,8,5,6],[8,3,0,5],[3,4,1,0],[4,9,6,1]]},r[13]={vertex:[[-.931836,.219976,-.264632],[-.636706,.318353,.692816],[-.613483,-.735083,-.264632],[-.326545,.979634,0],[-.318353,-.636706,.692816],[-.159176,.477529,-.856368],[.159176,-.477529,-.856368],[.318353,.636706,.692816],[.326545,-.979634,0],[.613482,.735082,-.264632],[.636706,-.318353,.692816],[.931835,-.219977,-.264632]],face:[[11,10,8],[7,9,3],[6,11,8],[9,5,3],[2,6,8],[5,0,3],[4,2,8],[0,1,3],[10,4,8],[1,7,3],[10,11,9,7],[11,6,5,9],[6,2,0,5],[2,4,1,0],[4,10,7,1]]},r[14]={vertex:[[-.93465,.300459,-.271185],[-.838689,-.260219,-.516017],[-.711319,.717591,.128359],[-.710334,-.156922,.080946],[-.599799,.556003,-.725148],[-.503838,-.004675,-.969981],[-.487004,.26021,.48049],[-.460089,-.750282,-.512622],[-.376468,.973135,-.325605],[-.331735,-.646985,.084342],[-.254001,.831847,.530001],[-.125239,-.494738,-.966586],[.029622,.027949,.730817],[.056536,-.982543,-.262295],[.08085,1.087391,.076037],[.125583,-.532729,.485984],[.262625,.599586,.780328],[.391387,-.726999,-.716259],[.513854,-.868287,.139347],[.597475,.85513,.326364],[.641224,.109523,.783723],[.737185,-.451155,.538891],[.848705,-.612742,-.314616],[.976075,.365067,.32976],[1.072036,-.19561,.084927]],face:[[15,18,21],[12,20,16],[6,10,2],[3,0,1],[9,7,13],[2,8,4,0],[0,4,5,1],[1,5,11,7],[7,11,17,13],[13,17,22,18],[18,22,24,21],[21,24,23,20],[20,23,19,16],[16,19,14,10],[10,14,8,2],[15,9,13,18],[12,15,21,20],[6,12,16,10],[3,6,2,0],[9,3,1,7],[9,15,12,6,3],[22,17,11,5,4,8,14,19,23,24]]};var n,o,s,a,h,c,l=i.type<0||i.type>=r.length?0:i.type||0,u=i.size,d=i.sizeX||u||1,f=i.sizeY||u||1,p=i.sizeZ||u||1,m=i.custom||r[l],g=m.face.length,v=i.faceUV||new Array(g),_=i.faceColors,y=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,x=[],b=[],M=[],E=[],T=[],w=0,S=0,A=[],P=0,C=0;for(C=0;g>C;C++)_&&void 0===_[C]&&(_[C]=new e.Color4(1,1,1,1)),v&&void 0===v[C]&&(v[C]=new e.Vector4(0,0,1,1));for(C=0;g>C;C++){var D=m.face[C].length;for(s=2*Math.PI/D,a=.5*Math.tan(s/2),h=.5,P=0;D>P;P++)x.push(m.vertex[m.face[C][P]][0]*d,m.vertex[m.face[C][P]][1]*f,m.vertex[m.face[C][P]][2]*p),A.push(w),w++,n=v[C].x+(v[C].z-v[C].x)*(.5+a),o=v[C].y+(v[C].w-v[C].y)*(h-.5),E.push(n,o),c=a*Math.cos(s)-h*Math.sin(s),h=a*Math.sin(s)+h*Math.cos(s),a=c,_&&T.push(_[C].r,_[C].g,_[C].b,_[C].a);for(P=0;D-2>P;P++)b.push(A[0+S],A[P+2+S],A[P+1+S]);S+=D}t.ComputeNormals(x,b,M),t._ComputeSides(y,x,b,M,E);var R=new t;return R.positions=x,R.indices=b,R.normals=M,R.uvs=E,_&&(R.colors=T),R},t.CreateTorusKnot=function(i){var r,n,o=[],s=[],a=[],h=[],c=i.radius||2,l=i.tube||.5,u=i.radialSegments||32,d=i.tubularSegments||32,f=i.p||2,p=i.q||3,m=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,g=function(t){var i=Math.cos(t),r=Math.sin(t),n=p/f*t,o=Math.cos(n),s=c*(2+o)*.5*i,a=c*(2+o)*r*.5,h=c*Math.sin(n)*.5;return new e.Vector3(s,a,h)};for(r=0;u>=r;r++){var v=r%u/u*2*f*Math.PI,_=g(v),y=g(v+.01),x=y.subtract(_),b=y.add(_),M=e.Vector3.Cross(x,b);for(b=e.Vector3.Cross(M,x),M.normalize(),b.normalize(),n=0;d>n;n++){var E=n%d/d*2*Math.PI,T=-l*Math.cos(E),w=l*Math.sin(E);s.push(_.x+T*b.x+w*M.x),s.push(_.y+T*b.y+w*M.y),s.push(_.z+T*b.z+w*M.z),h.push(r/u),h.push(n/d)}}for(r=0;u>r;r++)for(n=0;d>n;n++){var S=(n+1)%d,A=r*d+n,P=(r+1)*d+n,C=(r+1)*d+S,D=r*d+S;o.push(D),o.push(P),o.push(A),o.push(D),o.push(C),o.push(P)}t.ComputeNormals(s,o,a),t._ComputeSides(m,s,o,a,h);var R=new t;return R.indices=o,R.positions=s,R.normals=a,R.uvs=h,R},t.ComputeNormals=function(t,i,r){var n=0,o=e.Vector3.Zero(),s=e.Vector3.Zero(),a=e.Vector3.Zero(),h=e.Vector3.Zero();for(n=0;n<t.length;n++)r[n]=0;var c=i.length/3;for(n=0;c>n;n++){var l=i[3*n],u=i[3*n+1],d=i[3*n+2];o.x=t[3*l]-t[3*u],o.y=t[3*l+1]-t[3*u+1],o.z=t[3*l+2]-t[3*u+2],s.x=t[3*d]-t[3*u],s.y=t[3*d+1]-t[3*u+1],s.z=t[3*d+2]-t[3*u+2],e.Vector3.CrossToRef(o,s,a),a.normalize(),r[3*l]+=a.x,r[3*l+1]+=a.y,r[3*l+2]+=a.z,r[3*u]+=a.x,r[3*u+1]+=a.y,r[3*u+2]+=a.z,r[3*d]+=a.x,r[3*d+1]+=a.y,r[3*d+2]+=a.z}for(n=0;n<r.length/3;n++)e.Vector3.FromFloatsToRef(r[3*n],r[3*n+1],r[3*n+2],h),h.normalize(),r[3*n]=h.x,r[3*n+1]=h.y,r[3*n+2]=h.z},t._ComputeSides=function(t,i,r,n,o){var s,a,h=r.length,c=n.length;switch(t=t||e.Mesh.DEFAULTSIDE){case e.Mesh.FRONTSIDE:break;case e.Mesh.BACKSIDE:var l;for(s=0;h>s;s+=3)l=r[s],r[s]=r[s+2],r[s+2]=l;for(a=0;c>a;a++)n[a]=-n[a];break;case e.Mesh.DOUBLESIDE:for(var u=i.length,d=u/3,f=0;u>f;f++)i[u+f]=i[f];for(s=0;h>s;s+=3)r[s+h]=r[s+2]+d,r[s+1+h]=r[s+1]+d,r[s+2+h]=r[s]+d;for(a=0;c>a;a++)n[c+a]=-n[a];for(var p=o.length,m=0;p>m;m++)o[m+p]=o[m]}},t}();e.VertexData=t}(BABYLON||(BABYLON={})),function(e){var t=function(e){function t(t,i,r,n,o,s){e.call(this,t,"anaglyph",null,["leftSampler"],i,r,n,o,s)}return __extends(t,e),t}(e.PostProcess);e.AnaglyphPostProcess=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(){}return t.EnableFor=function(e){e._tags=e._tags||{},e.hasTags=function(){return t.HasTags(e)},e.addTags=function(i){return t.AddTagsTo(e,i)},e.removeTags=function(i){return t.RemoveTagsFrom(e,i)},e.matchesTagsQuery=function(i){return t.MatchesQuery(e,i)}},t.DisableFor=function(e){delete e._tags,delete e.hasTags,delete e.addTags,delete e.removeTags,delete e.matchesTagsQuery},t.HasTags=function(t){return!!t._tags&&!e.Tools.IsEmpty(t._tags)},t.GetTags=function(e){return e._tags?e._tags:null},t.AddTagsTo=function(e,i){if(i){var r=i.split(" ");for(var n in r)t._AddTagTo(e,r[n])}},t._AddTagTo=function(e,i){""!==(i=i.trim())&&"true"!==i&&"false"!==i&&(i.match(/[\s]/)||i.match(/^([!]|([|]|[&]){2})/)||(t.EnableFor(e),e._tags[i]=!0))},t.RemoveTagsFrom=function(e,i){if(t.HasTags(e)){var r=i.split(" ");for(var n in r)t._RemoveTagFrom(e,r[n])}},t._RemoveTagFrom=function(e,t){delete e._tags[t]},t.MatchesQuery=function(i,r){return void 0===r||(""===r?t.HasTags(i):e.Internals.AndOrNotEvaluator.Eval(r,function(e){return t.HasTags(i)&&i._tags[e]}))},t}();e.Tags=t}(BABYLON||(BABYLON={})),function(e){!function(e){var t=function(){function e(){}return e.Eval=function(t,i){return"true"===(t=t.match(/\([^\(\)]*\)/g)?t.replace(/\([^\(\)]*\)/g,function(t){return t=t.slice(1,t.length-1),e._HandleParenthesisContent(t,i)}):e._HandleParenthesisContent(t,i))||"false"!==t&&e.Eval(t,i)},e._HandleParenthesisContent=function(t,i){i=i||function(e){return"true"===e};var r,n=t.split("||");for(var o in n){var s=e._SimplifyNegation(n[o].trim()),a=s.split("&&");if(a.length>1)for(var h=0;h<a.length;++h){var c=e._SimplifyNegation(a[h].trim());if(!(r="true"!==c&&"false"!==c?"!"===c[0]?!i(c.substring(1)):i(c):"true"===c)){s="false";break}}if(r||"true"===s){r=!0;break}r="true"!==s&&"false"!==s?"!"===s[0]?!i(s.substring(1)):i(s):"true"===s}return r?"true":"false"},e._SimplifyNegation=function(e){return"!true"===(e=(e=e.replace(/^[\s!]+/,function(e){return(e=e.replace(/[\s]/g,function(){return""})).length%2?"!":""})).trim())?e="false":"!false"===e&&(e="true"),e},e}();e.AndOrNotEvaluator=t}(e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t,i,r,n,o,s){this._enabled=!0,this._refCount=0,this._name=i,this._renderTexture=new e.RenderTargetTexture(i,r,t),this.setRenderList(n),this._renderTexture.onBeforeRender=o,this._renderTexture.onAfterRender=s,this._scene=t,this._renderList=n}return t.prototype._incRefCount=function(){return 0===this._refCount&&this._scene.customRenderTargets.push(this._renderTexture),++this._refCount},t.prototype._decRefCount=function(){return this._refCount--,this._refCount<=0&&this._scene.customRenderTargets.splice(this._scene.customRenderTargets.indexOf(this._renderTexture),1),this._refCount},t.prototype._update=function(){this.setRenderList(this._renderList)},t.prototype.setRenderList=function(e){this._renderTexture.renderList=e},t.prototype.getRenderTexture=function(){return this._renderTexture},t}();e.PostProcessRenderPass=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(e,t,i,r){this._engine=e,this._name=t,this._singleInstance=r||!0,this._getPostProcess=i,this._cameras=[],this._indicesForCamera=[],this._postProcesses={},this._renderPasses={},this._renderEffectAsPasses={}}return t.prototype._update=function(){for(var e in this._renderPasses)this._renderPasses[e]._update()},t.prototype.addPass=function(e){this._renderPasses[e._name]=e,this._linkParameters()},t.prototype.removePass=function(e){delete this._renderPasses[e._name],this._linkParameters()},t.prototype.addRenderEffectAsPass=function(e){this._renderEffectAsPasses[e._name]=e,this._linkParameters()},t.prototype.getPass=function(e){for(var t in this._renderPasses)if(t===e)return this._renderPasses[e]},t.prototype.emptyPasses=function(){this._renderPasses={},this._linkParameters()},t.prototype._attachCameras=function(t){for(var i,r=e.Tools.MakeArray(t||this._cameras),n=0;n<r.length;n++){var o=r[n],s=o.name;i=this._singleInstance?0:s,this._postProcesses[i]=this._postProcesses[i]||this._getPostProcess();var a=o.attachPostProcess(this._postProcesses[i]);for(var h in this._indicesForCamera[s]||(this._indicesForCamera[s]=[]),this._indicesForCamera[s].push(a),-1===this._cameras.indexOf(o)&&(this._cameras[s]=o),this._renderPasses)this._renderPasses[h]._incRefCount()}this._linkParameters()},t.prototype._detachCameras=function(t){for(var i=e.Tools.MakeArray(t||this._cameras),r=0;r<i.length;r++){var n=i[r],o=n.name;n.detachPostProcess(this._postProcesses[this._singleInstance?0:o],this._indicesForCamera[o]);var s=this._cameras.indexOf(o);for(var a in this._indicesForCamera.splice(s,1),this._cameras.splice(s,1),this._renderPasses)this._renderPasses[a]._decRefCount()}},t.prototype._enable=function(t){for(var i=e.Tools.MakeArray(t||this._cameras),r=0;r<i.length;r++){for(var n=i[r],o=n.name,s=0;s<this._indicesForCamera[o].length;s++)void 0===n._postProcesses[this._indicesForCamera[o][s]]&&t[r].attachPostProcess(this._postProcesses[this._singleInstance?0:o],this._indicesForCamera[o][s]);for(var a in this._renderPasses)this._renderPasses[a]._incRefCount()}},t.prototype._disable=function(t){for(var i=e.Tools.MakeArray(t||this._cameras),r=0;r<i.length;r++){var n=i[r],o=n.Name;for(var s in n.detachPostProcess(this._postProcesses[this._singleInstance?0:o],this._indicesForCamera[o]),this._renderPasses)this._renderPasses[s]._decRefCount()}},t.prototype.getPostProcess=function(e){return this._singleInstance?this._postProcesses[0]:this._postProcesses[e.name]},t.prototype._linkParameters=function(){var e=this;for(var t in this._postProcesses)this.applyParameters&&this.applyParameters(this._postProcesses[t]),this._postProcesses[t].onBeforeRender=function(t){e._linkTextures(t)}},t.prototype._linkTextures=function(e){for(var t in this._renderPasses)e.setTexture(t,this._renderPasses[t].getRenderTexture());for(var i in this._renderEffectAsPasses)e.setTextureFromPostProcess(i+"Sampler",this._renderEffectAsPasses[i].getPostProcess())},t}();e.PostProcessRenderEffect=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(e,t){this._engine=e,this._name=t,this._renderEffects={},this._renderEffectsForIsolatedPass={},this._cameras=[]}return t.prototype.addEffect=function(e){this._renderEffects[e._name]=e},t.prototype._enableEffect=function(t,i){var r=this._renderEffects[t];r&&r._enable(e.Tools.MakeArray(i||this._cameras))},t.prototype._disableEffect=function(t,i){var r=this._renderEffects[t];r&&r._disable(e.Tools.MakeArray(i||this._cameras))},t.prototype._attachCameras=function(t,i){for(var r=e.Tools.MakeArray(t||this._cameras),n=[],o=0;o<r.length;o++){var s=r[o],a=s.name;-1===this._cameras.indexOf(s)?this._cameras[a]=s:i&&n.push(o)}for(o=0;o<n.length;o++)t.splice(n[o],1);for(var h in this._renderEffects)this._renderEffects[h]._attachCameras(r)},t.prototype._detachCameras=function(t){var i=e.Tools.MakeArray(t||this._cameras);for(var r in this._renderEffects)this._renderEffects[r]._detachCameras(i);for(var n=0;n<i.length;n++)this._cameras.splice(this._cameras.indexOf(i[n]),1)},t.prototype._enableDisplayOnlyPass=function(i,r){var n=this,o=e.Tools.MakeArray(r||this._cameras),s=null;for(var a in this._renderEffects)if(null!=(s=this._renderEffects[a].getPass(i)))break;if(null!==s){for(var a in this._renderEffects)this._renderEffects[a]._disable(o);s._name=t.PASS_SAMPLER_NAME;for(var h=0;h<o.length;h++){var c=o[h],l=c.name;this._renderEffectsForIsolatedPass[l]=this._renderEffectsForIsolatedPass[l]||new e.PostProcessRenderEffect(this._engine,t.PASS_EFFECT_NAME,function(){return new e.DisplayPassPostProcess(t.PASS_EFFECT_NAME,1,null,null,n._engine,!0)}),this._renderEffectsForIsolatedPass[l].emptyPasses(),this._renderEffectsForIsolatedPass[l].addPass(s),this._renderEffectsForIsolatedPass[l]._attachCameras(c)}}},t.prototype._disableDisplayOnlyPass=function(i){for(var r=this,n=e.Tools.MakeArray(i||this._cameras),o=0;o<n.length;o++){var s=n[o],a=s.name;this._renderEffectsForIsolatedPass[a]=this._renderEffectsForIsolatedPass[a]||new e.PostProcessRenderEffect(this._engine,t.PASS_EFFECT_NAME,function(){return new e.DisplayPassPostProcess(t.PASS_EFFECT_NAME,1,null,null,r._engine,!0)}),this._renderEffectsForIsolatedPass[a]._disable(s)}for(var h in this._renderEffects)this._renderEffects[h]._enable(n)},t.prototype._update=function(){for(var e in this._renderEffects)this._renderEffects[e]._update();for(var t=0;t<this._cameras.length;t++){var i=this._cameras[t].name;this._renderEffectsForIsolatedPass[i]&&this._renderEffectsForIsolatedPass[i]._update()}},t.PASS_EFFECT_NAME="passEffect",t.PASS_SAMPLER_NAME="passSampler",t}();e.PostProcessRenderPipeline=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function e(){this._renderPipelines={}}return e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._attachCameras(t,i)},e.prototype.detachCamerasFromRenderPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._detachCameras(t)},e.prototype.enableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._enableEffect(t,i)},e.prototype.disableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._disableEffect(t,i)},e.prototype.enableDisplayOnlyPassInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._enableDisplayOnlyPass(t,i)},e.prototype.disableDisplayOnlyPassInPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._disableDisplayOnlyPass(t)},e.prototype.update=function(){for(var e in this._renderPipelines)this._renderPipelines[e]._update()},e}();e.PostProcessRenderPipelineManager=t}(BABYLON||(BABYLON={})),function(e){var t=function(e){function t(t,i,r,n,o,s){e.call(this,t,"displayPass",["passSampler"],["passSampler"],i,r,n,o,s)}return __extends(t,e),t}(e.PostProcess);e.DisplayPassPostProcess=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t){this.frontColor=new e.Color3(1,1,1),this.backColor=new e.Color3(.1,.1,.1),this.showBackLines=!0,this.renderList=new e.SmartArray(32),this._scene=t}return t.prototype._prepareRessources=function(){if(!this._colorShader){this._colorShader=new e.ShaderMaterial("colorShader",this._scene,"color",{attributes:["position"],uniforms:["worldViewProjection","color"]});var t=this._scene.getEngine(),i=e.VertexData.CreateBox(1);this._vb=new e.VertexBuffer(t,i.positions,e.VertexBuffer.PositionKind,!1),this._ib=t.createIndexBuffer([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,7,1,6,2,5,3,4])}},t.prototype.reset=function(){this.renderList.reset()},t.prototype.render=function(){if(0!==this.renderList.length&&(this._prepareRessources(),this._colorShader.isReady())){var t=this._scene.getEngine();t.setDepthWrite(!1),this._colorShader._preBind();for(var i=0;i<this.renderList.length;i++){var r=this.renderList.data[i],n=r.minimum,o=r.maximum.subtract(n),s=n.add(o.scale(.5)),a=e.Matrix.Scaling(o.x,o.y,o.z).multiply(e.Matrix.Translation(s.x,s.y,s.z)).multiply(r.getWorldMatrix());t.bindBuffers(this._vb.getBuffer(),this._ib,[3],12,this._colorShader.getEffect()),this.showBackLines&&(t.setDepthFunctionToGreaterOrEqual(),this._scene.resetCachedMaterial(),this._colorShader.setColor4("color",this.backColor.toColor4()),this._colorShader.bind(a),t.draw(!1,0,24)),t.setDepthFunctionToLess(),this._scene.resetCachedMaterial(),this._colorShader.setColor4("color",this.frontColor.toColor4()),this._colorShader.bind(a),t.draw(!1,0,24)}this._colorShader.unbind(),t.setDepthFunctionToLessOrEqual(),t.setDepthWrite(!0)}},t.prototype.dispose=function(){this._colorShader&&(this._colorShader.dispose(),this._vb.dispose(),this._scene.getEngine()._releaseBuffer(this._ib))},t}();e.BoundingBoxRenderer=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function e(e){this._actionManager=e}return e.prototype.isValid=function(){return!0},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e}();e.Condition=t;var i=function(e){function t(i,r,n,o,s){void 0===s&&(s=t.IsEqual),e.call(this,i),this.propertyPath=n,this.value=o,this.operator=s,this._target=this._getEffectiveTarget(r,this.propertyPath),this._property=this._getProperty(this.propertyPath)}return __extends(t,e),Object.defineProperty(t,"IsEqual",{get:function(){return t._IsEqual},enumerable:!0,configurable:!0}),Object.defineProperty(t,"IsDifferent",{get:function(){return t._IsDifferent},enumerable:!0,configurable:!0}),Object.defineProperty(t,"IsGreater",{get:function(){return t._IsGreater},enumerable:!0,configurable:!0}),Object.defineProperty(t,"IsLesser",{get:function(){return t._IsLesser},enumerable:!0,configurable:!0}),t.prototype.isValid=function(){switch(this.operator){case t.IsGreater:return this._target[this._property]>this.value;case t.IsLesser:return this._target[this._property]<this.value;case t.IsEqual:case t.IsDifferent:var e;return e=this.value.equals?this.value.equals(this._target[this._property]):this.value===this._target[this._property],this.operator===t.IsEqual?e:!e}return!1},t._IsEqual=0,t._IsDifferent=1,t._IsGreater=2,t._IsLesser=3,t}(t);e.ValueCondition=i;var r=function(e){function t(t,i){e.call(this,t),this.predicate=i}return __extends(t,e),t.prototype.isValid=function(){return this.predicate()},t}(t);e.PredicateCondition=r;var n=function(e){function t(t,i,r){e.call(this,t),this.value=r,this._target=i}return __extends(t,e),t.prototype.isValid=function(){return this._target.state===this.value},t}(t);e.StateCondition=n}(BABYLON||(BABYLON={})),function(e){var t=function(){function e(e,t){this.triggerOptions=e,e.parameter?(this.trigger=e.trigger,this._triggerParameter=e.parameter):this.trigger=e,this._nextActiveAction=this,this._condition=t}return e.prototype._prepare=function(){},e.prototype.getTriggerParameter=function(){return this._triggerParameter},e.prototype._executeCurrent=function(e){if(this._nextActiveAction._condition){var t=this._nextActiveAction._condition,i=this._actionManager.getScene().getRenderId();if(t._evaluationId===i){if(!t._currentResult)return}else{if(t._evaluationId=i,!t.isValid())return void(t._currentResult=!1);t._currentResult=!0}}this._nextActiveAction.execute(e),this._nextActiveAction._child?(this._nextActiveAction._child._actionManager||(this._nextActiveAction._child._actionManager=this._actionManager),this._nextActiveAction=this._nextActiveAction._child):this._nextActiveAction=this},e.prototype.execute=function(e){},e.prototype.then=function(e){return this._child=e,e._actionManager=this._actionManager,e._prepare(),e},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e}();e.Action=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function e(e,t,i,r,n,o){this.source=e,this.pointerX=t,this.pointerY=i,this.meshUnderPointer=r,this.sourceEvent=n,this.additionalData=o}return e.CreateNew=function(t,i,r){var n=t.getScene();return new e(t,n.pointerX,n.pointerY,n.meshUnderPointer,i,r)},e.CreateNewFromSprite=function(t,i,r,n){return new e(t,i.pointerX,i.pointerY,i.meshUnderPointer,r,n)},e.CreateNewFromScene=function(t,i){return new e(null,t.pointerX,t.pointerY,t.meshUnderPointer,i)},e}();e.ActionEvent=t;var i=function(){function t(e){this.actions=new Array,this._scene=e,e._actionManagers.push(this)}return Object.defineProperty(t,"NothingTrigger",{get:function(){return t._NothingTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPickTrigger",{get:function(){return t._OnPickTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnLeftPickTrigger",{get:function(){return t._OnLeftPickTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnRightPickTrigger",{get:function(){return t._OnRightPickTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnCenterPickTrigger",{get:function(){return t._OnCenterPickTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPointerOverTrigger",{get:function(){return t._OnPointerOverTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPointerOutTrigger",{get:function(){return t._OnPointerOutTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnEveryFrameTrigger",{get:function(){return t._OnEveryFrameTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnIntersectionEnterTrigger",{get:function(){return t._OnIntersectionEnterTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnIntersectionExitTrigger",{get:function(){return t._OnIntersectionExitTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnKeyDownTrigger",{get:function(){return t._OnKeyDownTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnKeyUpTrigger",{get:function(){return t._OnKeyUpTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPickUpTrigger",{get:function(){return t._OnPickUpTrigger},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){var e=this._scene._actionManagers.indexOf(this);e>-1&&this._scene._actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t<this.actions.length;t++){var i=this.actions[t];if(e.indexOf(i.trigger)>-1)return!0}return!1},t.prototype.hasSpecificTrigger=function(e){for(var t=0;t<this.actions.length;t++){if(this.actions[t].trigger===e)return!0}return!1},Object.defineProperty(t.prototype,"hasPointerTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var i=this.actions[e];if(i.trigger>=t._OnPickTrigger&&i.trigger<=t._OnPointerOutTrigger)return!0;if(i.trigger===t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var i=this.actions[e];if(i.trigger>=t._OnPickTrigger&&i.trigger<=t._OnCenterPickTrigger)return!0;if(i.trigger===t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),t.prototype.registerAction=function(i){return i.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(e.Tools.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(i),i._actionManager=this,i._prepare(),i)},t.prototype.processTrigger=function(e,i){for(var r=0;r<this.actions.length;r++){var n=this.actions[r];if(n.trigger===e){if(e===t.OnKeyUpTrigger||e===t.OnKeyDownTrigger){var o=n.getTriggerParameter();if(o){var s=i.sourceEvent.charCode?i.sourceEvent.charCode:i.sourceEvent.keyCode;if(String.fromCharCode(s).toLowerCase()!==o.toLowerCase())continue}}n._executeCurrent(i)}}},t.prototype._getEffectiveTarget=function(e,t){for(var i=t.split("."),r=0;r<i.length-1;r++)e=e[i[r]];return e},t.prototype._getProperty=function(e){var t=e.split(".");return t[t.length-1]},t._NothingTrigger=0,t._OnPickTrigger=1,t._OnLeftPickTrigger=2,t._OnRightPickTrigger=3,t._OnCenterPickTrigger=4,t._OnPointerOverTrigger=5,t._OnPointerOutTrigger=6,t._OnEveryFrameTrigger=7,t._OnIntersectionEnterTrigger=8,t._OnIntersectionExitTrigger=9,t._OnKeyDownTrigger=10,t._OnKeyUpTrigger=11,t._OnPickUpTrigger=12,t}();e.ActionManager=i}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(e,i,r,n,o,s,a,h){void 0===o&&(o=1e3),t.call(this,e,s),this.propertyPath=r,this.value=n,this.duration=o,this.stopOtherAnimations=a,this.onInterpolationDone=h,this._target=i}return __extends(i,t),i.prototype._prepare=function(){this._target=this._getEffectiveTarget(this._target,this.propertyPath),this._property=this._getProperty(this.propertyPath)},i.prototype.execute=function(){var t,i=this._actionManager.getScene(),r=[{frame:0,value:this._target[this._property]},{frame:100,value:this.value}];if("number"==typeof this.value)t=e.Animation.ANIMATIONTYPE_FLOAT;else if(this.value instanceof e.Color3)t=e.Animation.ANIMATIONTYPE_COLOR3;else if(this.value instanceof e.Vector3)t=e.Animation.ANIMATIONTYPE_VECTOR3;else if(this.value instanceof e.Matrix)t=e.Animation.ANIMATIONTYPE_MATRIX;else{if(!(this.value instanceof e.Quaternion))return void e.Tools.Warn("InterpolateValueAction: Unsupported type ("+typeof this.value+")");t=e.Animation.ANIMATIONTYPE_QUATERNION}var n=new e.Animation("InterpolateValueAction",this._property,1e3/this.duration*100,t,e.Animation.ANIMATIONLOOPMODE_CONSTANT);n.setKeys(r),this.stopOtherAnimations&&i.stopAnimation(this._target),i.beginDirectAnimation(this._target,[n],0,100,!1,1,this.onInterpolationDone)},i}(e.Action);e.InterpolateValueAction=t}(BABYLON||(BABYLON={})),function(e){var t=function(e){function t(t,i,r,n){e.call(this,t,n),this.propertyPath=r,this._target=i}return __extends(t,e),t.prototype._prepare=function(){this._target=this._getEffectiveTarget(this._target,this.propertyPath),this._property=this._getProperty(this.propertyPath)},t.prototype.execute=function(){this._target[this._property]=!this._target[this._property]},t}(e.Action);e.SwitchBooleanAction=t;var i=function(e){function t(t,i,r,n){e.call(this,t,n),this.value=r,this._target=i}return __extends(t,e),t.prototype.execute=function(){this._target.state=this.value},t}(e.Action);e.SetStateAction=i;var r=function(e){function t(t,i,r,n,o){e.call(this,t,o),this.propertyPath=r,this.value=n,this._target=i}return __extends(t,e),t.prototype._prepare=function(){this._target=this._getEffectiveTarget(this._target,this.propertyPath),this._property=this._getProperty(this.propertyPath)},t.prototype.execute=function(){this._target[this._property]=this.value},t}(e.Action);e.SetValueAction=r;var n=function(t){function i(e,i,r,n,o){t.call(this,e,o),this.propertyPath=r,this.value=n,this._target=i}return __extends(i,t),i.prototype._prepare=function(){this._target=this._getEffectiveTarget(this._target,this.propertyPath),this._property=this._getProperty(this.propertyPath),"number"!=typeof this._target[this._property]&&e.Tools.Warn("Warning: IncrementValueAction can only be used with number values")},i.prototype.execute=function(){this._target[this._property]+=this.value},i}(e.Action);e.IncrementValueAction=n;var o=function(e){function t(t,i,r,n,o,s){e.call(this,t,s),this.from=r,this.to=n,this.loop=o,this._target=i}return __extends(t,e),t.prototype._prepare=function(){},t.prototype.execute=function(){this._actionManager.getScene().beginAnimation(this._target,this.from,this.to,this.loop)},t}(e.Action);e.PlayAnimationAction=o;var s=function(e){function t(t,i,r){e.call(this,t,r),this._target=i}return __extends(t,e),t.prototype._prepare=function(){},t.prototype.execute=function(){this._actionManager.getScene().stopAnimation(this._target)},t}(e.Action);e.StopAnimationAction=s;var a=function(t){function i(i,r){void 0===i&&(i=e.ActionManager.NothingTrigger),t.call(this,i,r)}return __extends(i,t),i.prototype.execute=function(){},i}(e.Action);e.DoNothingAction=a;var h=function(e){function t(t,i,r){e.call(this,t,r),this.children=i}return __extends(t,e),t.prototype._prepare=function(){for(var e=0;e<this.children.length;e++)this.children[e]._actionManager=this._actionManager,this.children[e]._prepare()},t.prototype.execute=function(e){for(var t=0;t<this.children.length;t++)this.children[t].execute(e)},t}(e.Action);e.CombineAction=h;var c=function(e){function t(t,i,r){e.call(this,t,r),this.func=i}return __extends(t,e),t.prototype.execute=function(e){this.func(e)},t}(e.Action);e.ExecuteCodeAction=c;var l=function(t){function i(e,i,r,n){t.call(this,e,n),this._target=i,this._parent=r}return __extends(i,t),i.prototype._prepare=function(){},i.prototype.execute=function(){if(this._target.parent!==this._parent){var t=this._parent.getWorldMatrix().clone();t.invert(),this._target.position=e.Vector3.TransformCoordinates(this._target.position,t),this._target.parent=this._parent}},i}(e.Action);e.SetParentAction=l;var u=function(e){function t(t,i,r){e.call(this,t,r),this._sound=i}return __extends(t,e),t.prototype._prepare=function(){},t.prototype.execute=function(){void 0!==this._sound&&this._sound.play()},t}(e.Action);e.PlaySoundAction=u;var d=function(e){function t(t,i,r){e.call(this,t,r),this._sound=i}return __extends(t,e),t.prototype._prepare=function(){},t.prototype.execute=function(){void 0!==this._sound&&this._sound.stop()},t}(e.Action);e.StopSoundAction=d}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t,i,r,n,o){this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this._totalVertices=0,this._indices=[],this._isDisposed=!1,this.id=t,this._engine=i.getEngine(),this._meshes=[],this._scene=i,r?this.setAllVerticesData(r,n):(this._totalVertices=0,this._indices=[]),o&&(this.applyToMesh(o),o.computeWorldMatrix(!0))}return t.prototype.getScene=function(){return this._scene},t.prototype.getEngine=function(){return this._engine},t.prototype.isReady=function(){return this.delayLoadState===e.Engine.DELAYLOADSTATE_LOADED||this.delayLoadState===e.Engine.DELAYLOADSTATE_NONE},t.prototype.setAllVerticesData=function(e,t){e.applyToGeometry(this,t),this.notifyUpdate()},t.prototype.setVerticesData=function(t,i,r,n){if(this._vertexBuffers=this._vertexBuffers||{},this._vertexBuffers[t]&&this._vertexBuffers[t].dispose(),this._vertexBuffers[t]=new e.VertexBuffer(this._engine,i,t,r,0===this._meshes.length,n),t===e.VertexBuffer.PositionKind){n=this._vertexBuffers[t].getStrideSize(),this._totalVertices=i.length/n;for(var o=e.Tools.ExtractMinAndMax(i,0,this._totalVertices),s=this._meshes,a=s.length,h=0;a>h;h++){var c=s[h];c._resetPointsArrayCache(),c._boundingInfo=new e.BoundingInfo(o.minimum,o.maximum),c._createGlobalSubMesh(),c.computeWorldMatrix(!0)}}this.notifyUpdate(t)},t.prototype.updateVerticesDataDirectly=function(e,t,i){var r=this.getVertexBuffer(e);r&&(r.updateDirectly(t,i),this.notifyUpdate(e))},t.prototype.updateVerticesData=function(t,i,r){var n=this.getVertexBuffer(t);if(n){if(n.update(i),t===e.VertexBuffer.PositionKind){var o,s=n.getStrideSize();this._totalVertices=i.length/s,r&&(o=e.Tools.ExtractMinAndMax(i,0,this._totalVertices));for(var a=this._meshes,h=a.length,c=0;h>c;c++){var l=a[c];if(l._resetPointsArrayCache(),r){l._boundingInfo=new e.BoundingInfo(o.minimum,o.maximum);for(var u=0;u<l.subMeshes.length;u++){l.subMeshes[u].refreshBoundingInfo()}}}}this.notifyUpdate(t)}},t.prototype.getTotalVertices=function(){return this.isReady()?this._totalVertices:0},t.prototype.getVerticesData=function(e,t){var i=this.getVertexBuffer(e);if(!i)return null;var r=i.getData();if(t&&1!==this._meshes.length){for(var n=r.length,o=[],s=0;n>s;s++)o.push(r[s]);return o}return r},t.prototype.getVertexBuffer=function(e){return this.isReady()?this._vertexBuffers[e]:null},t.prototype.getVertexBuffers=function(){return this.isReady()?this._vertexBuffers:null},t.prototype.isVerticesDataPresent=function(e){return this._vertexBuffers?void 0!==this._vertexBuffers[e]:!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)},t.prototype.getVerticesDataKinds=function(){var e=[];if(!this._vertexBuffers&&this._delayInfo)for(var t in this._delayInfo)e.push(t);else for(t in this._vertexBuffers)e.push(t);return e},t.prototype.setIndices=function(e,t){this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indices=e,0!==this._meshes.length&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),void 0!==t&&(this._totalVertices=t);for(var i=this._meshes,r=i.length,n=0;r>n;n++)i[n]._createGlobalSubMesh();this.notifyUpdate()},t.prototype.getTotalIndices=function(){return this.isReady()?this._indices.length:0},t.prototype.getIndices=function(e){if(!this.isReady())return null;var t=this._indices;if(e&&1!==this._meshes.length){for(var i=t.length,r=[],n=0;i>n;n++)r.push(t[n]);return r}return t},t.prototype.getIndexBuffer=function(){return this.isReady()?this._indexBuffer:null},t.prototype.releaseForMesh=function(e,t){var i=this._meshes,r=i.indexOf(e);if(-1!==r){for(var n in this._vertexBuffers)this._vertexBuffers[n].dispose();this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),i.splice(r,1),e._geometry=null,0===i.length&&t&&this.dispose()}},t.prototype.applyToMesh=function(e){if(e._geometry!==this){var t=e._geometry;t&&t.releaseForMesh(e);var i=this._meshes;e._geometry=this,this._scene.pushGeometry(this),i.push(e),this.isReady()?this._applyToMesh(e):e._boundingInfo=this._boundingInfo}},t.prototype._applyToMesh=function(t){var i=this._meshes.length;for(var r in this._vertexBuffers)if(1===i&&this._vertexBuffers[r].create(),this._vertexBuffers[r]._buffer.references=i,r===e.VertexBuffer.PositionKind){t._resetPointsArrayCache();var n=e.Tools.ExtractMinAndMax(this._vertexBuffers[r].getData(),0,this._totalVertices);t._boundingInfo=new e.BoundingInfo(n.minimum,n.maximum),t._createGlobalSubMesh(),t._updateBoundingInfo()}1===i&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=i)},t.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e)},t.prototype.load=function(t,i){var r=this;if(this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING){if(this.isReady())return void(i&&i());this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADING,t._addPendingData(this),e.Tools.LoadFile(this.delayLoadingFile,function(n){r._delayLoadingFunction(JSON.parse(n),r),r.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,r._delayInfo=[],t._removePendingData(r);for(var o=r._meshes,s=o.length,a=0;s>a;a++)r._applyToMesh(o[a]);i&&i()},function(){},t.database)}},t.prototype.isDisposed=function(){return this._isDisposed},t.prototype.dispose=function(){var t,i=this._meshes,r=i.length;for(t=0;r>t;t++)this.releaseForMesh(i[t]);for(var n in this._meshes=[],this._vertexBuffers)this._vertexBuffers[n].dispose();this._vertexBuffers=[],this._totalVertices=0,this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null,this._indices=[],this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this.delayLoadingFile=null,this._delayLoadingFunction=null,this._delayInfo=[],this._boundingInfo=null,this._scene.removeGeometry(this),this._isDisposed=!0},t.prototype.copy=function(i){var r=new e.VertexData;r.indices=[];for(var n=this.getIndices(),o=0;o<n.length;o++)r.indices.push(n[o]);var s,a=!1,h=!1;for(s in this._vertexBuffers)r.set(this.getVerticesData(s).slice(0),s),h||(h=!(a=this.getVertexBuffer(s).isUpdatable()));var c=new t(i,this._scene,r,a,null);for(s in c.delayLoadState=this.delayLoadState,c.delayLoadingFile=this.delayLoadingFile,c._delayLoadingFunction=this._delayLoadingFunction,this._delayInfo)c._delayInfo=c._delayInfo||[],c._delayInfo.push(s);var l=e.Tools.ExtractMinAndMax(this.getVerticesData(e.VertexBuffer.PositionKind),0,this.getTotalVertices());return c._boundingInfo=new e.BoundingInfo(l.minimum,l.maximum),c},t.ExtractFromMesh=function(e,t){var i=e._geometry;return i?i.copy(t):null},t.RandomId=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},t}();e.Geometry=t,function(t){!function(i){var r=function(e){function t(t,i,r,n,o){this._beingRegenerated=!0,this._canBeRegenerated=n,e.call(this,t,i,r,!1,o),this._beingRegenerated=!1}return __extends(t,e),t.prototype.canBeRegenerated=function(){return this._canBeRegenerated},t.prototype.regenerate=function(){this._canBeRegenerated&&(this._beingRegenerated=!0,this.setAllVerticesData(this._regenerateVertexData(),!1),this._beingRegenerated=!1)},t.prototype.asNewGeometry=function(t){return e.prototype.copy.call(this,t)},t.prototype.setAllVerticesData=function(t,i){this._beingRegenerated&&e.prototype.setAllVerticesData.call(this,t,!1)},t.prototype.setVerticesData=function(t,i,r){this._beingRegenerated&&e.prototype.setVerticesData.call(this,t,i,!1)},t.prototype._regenerateVertexData=function(){throw new Error("Abstract method")},t.prototype.copy=function(e){throw new Error("Must be overriden in sub-classes.")},t}(t);i._Primitive=r;var n=function(t){function i(i,r,n,o,s,a,h,c,l){void 0===l&&(l=e.Mesh.DEFAULTSIDE),this.pathArray=n,this.closeArray=o,this.closePath=s,this.offset=a,this.side=l,t.call(this,i,r,this._regenerateVertexData(),h,c)}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateRibbon({pathArray:this.pathArray,closeArray:this.closeArray,closePath:this.closePath,offset:this.offset,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.pathArray,this.closeArray,this.closePath,this.offset,this.canBeRegenerated(),null,this.side)},i}(r);i.Ribbon=n;var o=function(t){function i(i,r,n,o,s,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE),this.size=n,this.side=a,t.call(this,i,r,this._regenerateVertexData(),o,s)}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateBox({size:this.size,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},i}(r);i.Box=o;var s=function(t){function i(i,r,n,o,s,a,h){void 0===h&&(h=e.Mesh.DEFAULTSIDE),this.segments=n,this.diameter=o,this.side=h,t.call(this,i,r,this._regenerateVertexData(),s,a)}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateSphere({segments:this.segments,diameter:this.diameter,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.segments,this.diameter,this.canBeRegenerated(),null,this.side)},i}(r);i.Sphere=s;var a=function(t){function i(i,r,n,o,s,a,h){void 0===h&&(h=e.Mesh.DEFAULTSIDE),this.radius=n,this.tessellation=o,this.side=h,t.call(this,i,r,this._regenerateVertexData(),s,a)}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateDisc({radius:this.radius,tessellation:this.tessellation,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.radius,this.tessellation,this.canBeRegenerated(),null,this.side)},i}(r);i.Disc=a;var h=function(t){function i(i,r,n,o,s,a,h,c,l,u){void 0===h&&(h=1),void 0===u&&(u=e.Mesh.DEFAULTSIDE),this.height=n,this.diameterTop=o,this.diameterBottom=s,this.tessellation=a,this.subdivisions=h,this.side=u,t.call(this,i,r,this._regenerateVertexData(),c,l)}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateCylinder({height:this.height,diameterTop:this.diameterTop,diameterBottom:this.diameterBottom,tessellation:this.tessellation,subdivisions:this.subdivisions,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.height,this.diameterTop,this.diameterBottom,this.tessellation,this.subdivisions,this.canBeRegenerated(),null,this.side)},i}(r);i.Cylinder=h;var c=function(t){function i(i,r,n,o,s,a,h,c){void 0===c&&(c=e.Mesh.DEFAULTSIDE),this.diameter=n,this.thickness=o,this.tessellation=s,this.side=c,t.call(this,i,r,this._regenerateVertexData(),a,h)}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorus({diameter:this.diameter,thickness:this.thickness,tessellation:this.tessellation,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.diameter,this.thickness,this.tessellation,this.canBeRegenerated(),null,this.side)},i}(r);i.Torus=c;var l=function(t){function i(e,i,r,n,o,s,a){this.width=r,this.height=n,this.subdivisions=o,t.call(this,e,i,this._regenerateVertexData(),s,a)}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateGround({width:this.width,height:this.height,subdivisions:this.subdivisions})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.width,this.height,this.subdivisions,this.canBeRegenerated(),null)},i}(r);i.Ground=l;var u=function(t){function i(e,i,r,n,o,s,a,h,c,l){this.xmin=r,this.zmin=n,this.xmax=o,this.zmax=s,this.subdivisions=a,this.precision=h,t.call(this,e,i,this._regenerateVertexData(),c,l)}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTiledGround({xmin:this.xmin,zmin:this.zmin,xmax:this.xmax,zmax:this.zmax,subdivisions:this.subdivisions,precision:this.precision})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.xmin,this.zmin,this.xmax,this.zmax,this.subdivisions,this.precision,this.canBeRegenerated(),null)},i}(r);i.TiledGround=u;var d=function(t){function i(i,r,n,o,s,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE),this.size=n,this.side=a,t.call(this,i,r,this._regenerateVertexData(),o,s)}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreatePlane({size:this.size,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},i}(r);i.Plane=d;var f=function(t){function i(i,r,n,o,s,a,h,c,l,u,d){void 0===d&&(d=e.Mesh.DEFAULTSIDE),this.radius=n,this.tube=o,this.radialSegments=s,this.tubularSegments=a,this.p=h,this.q=c,this.side=d,t.call(this,i,r,this._regenerateVertexData(),l,u)}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorusKnot({radius:this.radius,tube:this.tube,radialSegments:this.radialSegments,tubularSegments:this.tubularSegments,p:this.p,q:this.q,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.radius,this.tube,this.radialSegments,this.tubularSegments,this.p,this.q,this.canBeRegenerated(),null,this.side)},i}(r);i.TorusKnot=f}(t.Primitives||(t.Primitives={}))}(t=e.Geometry||(e.Geometry={}))}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r){t.call(this,i,r),this.generateOctree=!1,this._worldInverse=new e.Matrix}return __extends(i,t),Object.defineProperty(i.prototype,"subdivisions",{get:function(){return this._subdivisions},enumerable:!0,configurable:!0}),i.prototype.optimize=function(e,t){void 0===t&&(t=32),this._subdivisions=e,this.subdivide(this._subdivisions),this.createOrUpdateSubmeshesOctree(t)},i.prototype.getHeightAtCoordinates=function(t,i){var r=new e.Ray(new e.Vector3(t,this.getBoundingInfo().boundingBox.maximumWorld.y+1,i),new e.Vector3(0,-1,0));this.getWorldMatrix().invertToRef(this._worldInverse),r=e.Ray.Transform(r,this._worldInverse);var n=this.intersects(r);return n.hit?n.pickedPoint.y:0},i}(e.Mesh);e.GroundMesh=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o,s){void 0===n&&(n=null),t.call(this,i,r,n,o,s),this.color=new e.Color3(1,1,1),this.alpha=1,this._colorShader=new e.ShaderMaterial("colorShader",r,"color",{attributes:["position"],uniforms:["worldViewProjection","color"],needAlphaBlending:!0})}return __extends(i,t),Object.defineProperty(i.prototype,"material",{get:function(){return this._colorShader},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isPickable",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"checkCollisions",{get:function(){return!1},enumerable:!0,configurable:!0}),i.prototype._bind=function(t,i,r){var n=this.getScene().getEngine(),o=this._geometry.getIndexBuffer();n.bindBuffers(this._geometry.getVertexBuffer(e.VertexBuffer.PositionKind).getBuffer(),o,[3],12,this._colorShader.getEffect()),this._colorShader.setColor4("color",this.color.toColor4(this.alpha))},i.prototype._draw=function(e,t,i){this._geometry&&this._geometry.getVertexBuffers()&&this._geometry.getIndexBuffer()&&this.getScene().getEngine().draw(!1,e.indexStart,e.indexCount)},i.prototype.intersects=function(e,t){return null},i.prototype.dispose=function(e){this._colorShader.dispose(),t.prototype.dispose.call(this,e)},i.prototype.clone=function(e,t,r){return new i(e,this.getScene(),t,this,r)},i}(e.Mesh);e.LinesMesh=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(e){this._scene=e}return t.prototype.render=function(t,i,r){var n=this;void 0===r&&(r=!1);var o=this._scene,s=this._scene.getEngine(),a=null!==s.getCaps().instancedArrays&&null!==i.visibleInstances[t._id]&&void 0!==i.visibleInstances[t._id];if(this.isReady(t,a)){var h=t.getRenderingMesh(),c=t.getMaterial();if(s.enableEffect(this._effect),this._effect.setFloat("offset",r?0:h.outlineWidth),this._effect.setColor4("color",r?h.overlayColor:h.outlineColor,r?h.overlayAlpha:1),this._effect.setMatrix("viewProjection",o.getTransformMatrix()),h.useBones&&h.computeBonesUsingShaders&&this._effect.setMatrices("mBones",h.skeleton.getTransformMatrices()),h._bind(t,this._effect,e.Material.TriangleFillMode),c&&c.needAlphaTesting()){var l=c.getAlphaTestTexture();this._effect.setTexture("diffuseSampler",l),this._effect.setMatrix("diffuseMatrix",l.getTextureMatrix())}h._processRendering(t,this._effect,e.Material.TriangleFillMode,i,a,function(e,t){n._effect.setMatrix("world",t)})}},t.prototype.isReady=function(t,i){var r=[],n=[e.VertexBuffer.PositionKind,e.VertexBuffer.NormalKind],o=t.getMesh(),s=t.getMaterial();s&&s.needAlphaTesting()&&(r.push("#define ALPHATEST"),o.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.push(e.VertexBuffer.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(n.push(e.VertexBuffer.UV2Kind),r.push("#define UV2"))),o.useBones&&o.computeBonesUsingShaders&&(n.push(e.VertexBuffer.MatricesIndicesKind),n.push(e.VertexBuffer.MatricesWeightsKind),r.push("#define BONES"),r.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))),i&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var a=r.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("outline",n,["world","mBones","viewProjection","diffuseMatrix","offset","color"],["diffuseSampler"],a)),this._effect.isReady()},t}();e.OutlineRenderer=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(e,t,i,r){this.name=e,this.meshesNames=t,this.rootUrl=i,this.sceneFilename=r,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;e.SceneLoader.ImportMesh(this.meshesNames,this.rootUrl,this.sceneFilename,t,function(e,t,r){n.loadedMeshes=e,n.loadedParticleSystems=t,n.loadedSkeletons=r,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},null,function(){n.onError&&n.onError(n),r()})},t}();e.MeshAssetTask=t;var i=function(){function t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;e.Tools.LoadFile(this.url,function(e){n.text=e,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},null,t.database,!1,function(){n.onError&&n.onError(n),r()})},t}();e.TextFileAssetTask=i;var r=function(){function t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;e.Tools.LoadFile(this.url,function(e){n.data=e,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},null,t.database,!0,function(){n.onError&&n.onError(n),r()})},t}();e.BinaryFileAssetTask=r;var n=function(){function e(e,t){this.name=e,this.url=t,this.isCompleted=!1}return e.prototype.run=function(e,t,i){var r=this,n=new Image;n.onload=function(){r.image=n,r.isCompleted=!0,r.onSuccess&&r.onSuccess(r),t()},n.onerror=function(){r.onError&&r.onError(r),i()},n.src=this.url},e}();e.ImageAssetTask=n;var o=function(){function t(t,i,r,n,o){void 0===o&&(o=e.Texture.TRILINEAR_SAMPLINGMODE),this.name=t,this.url=i,this.noMipmap=r,this.invertY=n,this.samplingMode=o,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;this.texture=new e.Texture(this.url,t,this.noMipmap,this.invertY,this.samplingMode,function(){n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},r)},t}();e.TextureAssetTask=o;var s=function(){function s(e){this._tasks=new Array,this._waitingTasksCount=0,this.useDefaultLoadingScreen=!0,this._scene=e}return s.prototype.addMeshTask=function(e,i,r,n){var o=new t(e,i,r,n);return this._tasks.push(o),o},s.prototype.addTextFileTask=function(e,t){var r=new i(e,t);return this._tasks.push(r),r},s.prototype.addBinaryFileTask=function(e,t){var i=new r(e,t);return this._tasks.push(i),i},s.prototype.addImageTask=function(e,t){var i=new n(e,t);return this._tasks.push(i),i},s.prototype.addTextureTask=function(t,i,r,n,s){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE);var a=new o(t,i,r,n,s);return this._tasks.push(a),a},s.prototype._decreaseWaitingTasksCount=function(){this._waitingTasksCount--,0===this._waitingTasksCount&&(this.onFinish&&this.onFinish(this._tasks),this._scene.getEngine().hideLoadingUI())},s.prototype._runTask=function(e){var t=this;e.run(this._scene,function(){t.onTaskSuccess&&t.onTaskSuccess(e),t._decreaseWaitingTasksCount()},function(){t.onTaskError&&t.onTaskError(e),t._decreaseWaitingTasksCount()})},s.prototype.reset=function(){return this._tasks=new Array,this},s.prototype.load=function(){if(this._waitingTasksCount=this._tasks.length,0===this._waitingTasksCount)return this.onFinish&&this.onFinish(this._tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(var e=0;e<this._tasks.length;e++){var t=this._tasks[e];this._runTask(t)}return this},s}();e.AssetsManager=s}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o){void 0===o&&(o=!0),t.call(this,i,r,n),this._alpha=0,this._beta=0,this._gamma=0;var s=e.VRCameraMetrics.GetDefault();s.compensateDistortion=o,this.setCameraRigMode(e.Camera.RIG_MODE_VR,{vrCameraMetrics:s}),this._deviceOrientationHandler=this._onOrientationEvent.bind(this)}return __extends(i,t),i.prototype._onOrientationEvent=function(e){this._alpha=0|+e.alpha,this._beta=0|+e.beta,this._gamma=0|+e.gamma,this._gamma=this._gamma<0?90+this._gamma:270-this._gamma,this.rotation.x=this._gamma/180*Math.PI,this.rotation.y=-this._alpha/180*Math.PI,this.rotation.z=this._beta/180*Math.PI},i.prototype.attachControl=function(e,i){t.prototype.attachControl.call(this,e,i),window.addEventListener("deviceorientation",this._deviceOrientationHandler)},i.prototype.detachControl=function(e){t.prototype.detachControl.call(this,e),window.removeEventListener("deviceorientation",this._deviceOrientationHandler)},i}(e.FreeCamera);e.VRDeviceOrientationFreeCamera=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o){void 0===o&&(o=!0),t.call(this,i,r,n),this._hmdDevice=null,this._sensorDevice=null,this._cacheState=null,this._cacheQuaternion=new e.Quaternion,this._cacheRotation=e.Vector3.Zero(),this._vrEnabled=!1;var s=e.VRCameraMetrics.GetDefault();s.compensateDistortion=o,this.setCameraRigMode(e.Camera.RIG_MODE_VR,{vrCameraMetrics:s}),this._getWebVRDevices=this._getWebVRDevices.bind(this)}return __extends(i,t),i.prototype._getWebVRDevices=function(e){var t=e.length,i=0;for(this._sensorDevice=null,this._hmdDevice=null;t>i&&null===this._hmdDevice;)e[i]instanceof HMDVRDevice&&(this._hmdDevice=e[i]),i++;for(i=0;t>i&&null===this._sensorDevice;)e[i]instanceof PositionSensorVRDevice&&(!this._hmdDevice||e[i].hardwareUnitId===this._hmdDevice.hardwareUnitId)&&(this._sensorDevice=e[i]),i++;this._vrEnabled=!(!this._sensorDevice||!this._hmdDevice)},i.prototype._checkInputs=function(){this._vrEnabled&&(this._cacheState=this._sensorDevice.getState(),this._cacheQuaternion.copyFromFloats(this._cacheState.orientation.x,this._cacheState.orientation.y,this._cacheState.orientation.z,this._cacheState.orientation.w),this._cacheQuaternion.toEulerAnglesToRef(this._cacheRotation),this.rotation.x=-this._cacheRotation.z,this.rotation.y=-this._cacheRotation.y,this.rotation.z=this._cacheRotation.x),t.prototype._checkInputs.call(this)},i.prototype.attachControl=function(e,i){t.prototype.attachControl.call(this,e,i),navigator.getVRDevices?navigator.getVRDevices().then(this._getWebVRDevices):navigator.mozGetVRDevices&&navigator.mozGetVRDevices(this._getWebVRDevices)},i.prototype.detachControl=function(e){t.prototype.detachControl.call(this,e),this._vrEnabled=!1},i}(e.FreeCamera);e.WebVRFreeCamera=t}(BABYLON||(BABYLON={})),function(e){var t=function(){return function(e){void 0===e&&(e=0),this.priority=e,this.apply=function(e){return!0}}}();e.SceneOptimization=t;var i=function(e){function t(t,i){var r=this;void 0===t&&(t=0),void 0===i&&(i=1024),e.call(this,t),this.priority=t,this.maximumSize=i,this.apply=function(e){for(var t=!0,i=0;i<e.textures.length;i++){var n=e.textures[i];if(n.canRescale){var o=n.getSize();Math.max(o.width,o.height)>r.maximumSize&&(n.scale(.5),t=!1)}}return t}}return __extends(t,e),t}(t);e.TextureOptimization=i;var r=function(e){function t(t,i){var r=this;void 0===t&&(t=0),void 0===i&&(i=2),e.call(this,t),this.priority=t,this.maximumScale=i,this._currentScale=1,this.apply=function(e){return r._currentScale++,e.getEngine().setHardwareScalingLevel(r._currentScale),r._currentScale>=r.maximumScale}}return __extends(t,e),t}(t);e.HardwareScalingOptimization=r;var n=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.shadowsEnabled=!1,!0}}return __extends(t,e),t}(t);e.ShadowsOptimization=n;var o=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.postProcessesEnabled=!1,!0}}return __extends(t,e),t}(t);e.PostProcessesOptimization=o;var s=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.lensFlaresEnabled=!1,!0}}return __extends(t,e),t}(t);e.LensFlaresOptimization=s;var a=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.particlesEnabled=!1,!0}}return __extends(t,e),t}(t);e.ParticlesOptimization=a;var h=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.renderTargetsEnabled=!1,!0}}return __extends(t,e),t}(t);e.RenderTargetsOptimization=h;var c=function(t){function i(){var r=this;t.apply(this,arguments),this._canBeMerged=function(t){if(!(t instanceof e.Mesh))return!1;var i=t;return!(!i.isVisible||!i.isEnabled())&&(!(i.instances.length>0)&&(!i.skeleton&&!i.hasLODLevels))},this.apply=function(t,n){for(var o=t.meshes.slice(0),s=o.length,a=0;s>a;a++){var h=new Array,c=o[a];if(r._canBeMerged(c)){h.push(c);for(var l=a+1;s>l;l++){var u=o[l];r._canBeMerged(u)&&u.material===c.material&&u.checkCollisions===c.checkCollisions&&(h.push(u),s--,o.splice(l,1),l--)}h.length<2||e.Mesh.MergeMeshes(h)}}return null!=n?n&&t.createOrUpdateSelectionOctree():i.UpdateSelectionTree&&t.createOrUpdateSelectionOctree(),!0}}return __extends(i,t),Object.defineProperty(i,"UpdateSelectionTree",{get:function(){return i._UpdateSelectionTree},set:function(e){i._UpdateSelectionTree=e},enumerable:!0,configurable:!0}),i._UpdateSelectionTree=!1,i}(t);e.MergeMeshesOptimization=c;var l=function(){function e(e,t){void 0===e&&(e=60),void 0===t&&(t=2e3),this.targetFrameRate=e,this.trackerDuration=t,this.optimizations=new Array}return e.LowDegradationAllowed=function(t){var r=new e(t),h=0;return r.optimizations.push(new c(h)),r.optimizations.push(new n(h)),r.optimizations.push(new s(h)),h++,r.optimizations.push(new o(h)),r.optimizations.push(new a(h)),h++,r.optimizations.push(new i(h,1024)),r},e.ModerateDegradationAllowed=function(t){var l=new e(t),u=0;return l.optimizations.push(new c(u)),l.optimizations.push(new n(u)),l.optimizations.push(new s(u)),u++,l.optimizations.push(new o(u)),l.optimizations.push(new a(u)),u++,l.optimizations.push(new i(u,512)),u++,l.optimizations.push(new h(u)),u++,l.optimizations.push(new r(u,2)),l},e.HighDegradationAllowed=function(t){var l=new e(t),u=0;return l.optimizations.push(new c(u)),l.optimizations.push(new n(u)),l.optimizations.push(new s(u)),u++,l.optimizations.push(new o(u)),l.optimizations.push(new a(u)),u++,l.optimizations.push(new i(u,256)),u++,l.optimizations.push(new h(u)),u++,l.optimizations.push(new r(u,4)),l},e}();e.SceneOptimizerOptions=l;var u=function(){function e(){}return e._CheckCurrentState=function(t,i,r,n,o){if(!(t.getEngine().getFps()>=i.targetFrameRate)){for(var s=!0,a=!0,h=0;h<i.optimizations.length;h++){var c=i.optimizations[h];c.priority===r&&(a=!1,s=s&&c.apply(t))}return a?void(o&&o()):(s&&r++,void t.executeWhenReady(function(){setTimeout(function(){e._CheckCurrentState(t,i,r,n,o)},i.trackerDuration)}))}n&&n()},e.OptimizeAsync=function(t,i,r,n){i||(i=l.ModerateDegradationAllowed()),t.executeWhenReady(function(){setTimeout(function(){e._CheckCurrentState(t,i,0,r,n)},i.trackerDuration)})},e}();e.SceneOptimizer=u}(BABYLON||(BABYLON={})),function(e){!function(e){var t=function(){return function(e,t){this.distance=e,this.mesh=t}}();e.MeshLODLevel=t}(e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(){this._audioContext=null,this._audioContextInitialized=!1,this.canUseWebAudio=!1,this.WarnedWebAudioUnsupported=!1,(void 0!==window.AudioContext||void 0!==window.webkitAudioContext)&&(window.AudioContext=window.AudioContext||window.webkitAudioContext,this.canUseWebAudio=!0)}return Object.defineProperty(t.prototype,"audioContext",{get:function(){return this._audioContextInitialized||this._initializeAudioContext(),this._audioContext},enumerable:!0,configurable:!0}),t.prototype._initializeAudioContext=function(){try{this.canUseWebAudio&&(this._audioContext=new AudioContext,this.masterGain=this._audioContext.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this._audioContext.destination),this._audioContextInitialized=!0)}catch(t){this.canUseWebAudio=!1,e.Tools.Error("Web Audio: "+t.message)}},t.prototype.dispose=function(){this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser&&(this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser.dispose(),this.masterGain.disconnect(),this.masterGain.connect(this._audioContext.destination),this._connectedAnalyser=null),this.masterGain.gain.value=1),this.WarnedWebAudioUnsupported=!1},t.prototype.getGlobalVolume=function(){return this.canUseWebAudio&&this._audioContextInitialized?this.masterGain.gain.value:-1},t.prototype.setGlobalVolume=function(e){this.canUseWebAudio&&this._audioContextInitialized&&(this.masterGain.gain.value=e)},t.prototype.connectToAnalyser=function(e){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser=e,this.masterGain.disconnect(),this._connectedAnalyser.connectAudioNodes(this.masterGain,this._audioContext.destination))},t}();e.AudioEngine=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t,i,r,n,o){var s=this;this.autoplay=!1,this.loop=!1,this.useCustomAttenuation=!1,this.spatialSound=!1,this.refDistance=1,this.rolloffFactor=1,this.maxDistance=100,this.distanceModel="linear",this._panningModel="equalpower",this._playbackRate=1,this._startTime=0,this._startOffset=0,this._position=e.Vector3.Zero(),this._localDirection=new e.Vector3(1,0,0),this._volume=1,this._isLoaded=!1,this._isReadyToPlay=!1,this.isPlaying=!1,this.isPaused=!1,this._isDirectional=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._coneOuterGain=0,this._isOutputConnected=!1,this.name=t,this._scene=r,this._readyToPlayCallback=n,this._customAttenuationFunction=function(e,t,i,r,n){return i>t?e*(1-t/i):0},o&&(this.autoplay=o.autoplay||!1,this.loop=o.loop||!1,void 0!==o.volume&&(this._volume=o.volume),this.spatialSound=o.spatialSound||!1,this.maxDistance=o.maxDistance||100,this.useCustomAttenuation=o.useCustomAttenuation||!1,this.rolloffFactor=o.rolloffFactor||1,this.refDistance=o.refDistance||1,this.distanceModel=o.distanceModel||"linear",this._playbackRate=o.playbackRate||1),e.Engine.audioEngine.canUseWebAudio?(this._soundGain=e.Engine.audioEngine.audioContext.createGain(),this._soundGain.gain.value=this._volume,this._inputAudioNode=this._soundGain,this._ouputAudioNode=this._soundGain,this.spatialSound&&this._createSpatialParameters(),this._scene.mainSoundTrack.AddSound(this),i&&("string"==typeof i?e.Tools.LoadFile(i,function(e){s._soundLoaded(e)},null,null,!0):i instanceof ArrayBuffer?this._soundLoaded(i):e.Tools.Error("Parameter must be a URL to the sound or an ArrayBuffer of the sound."))):(this._scene.mainSoundTrack.AddSound(this),e.Engine.audioEngine.WarnedWebAudioUnsupported||(e.Tools.Error("Web Audio is not supported by your browser."),e.Engine.audioEngine.WarnedWebAudioUnsupported=!0),this._readyToPlayCallback&&window.setTimeout(function(){s._readyToPlayCallback()},1e3))}return t.prototype.dispose=function(){e.Engine.audioEngine.canUseWebAudio&&this._isReadyToPlay&&(this.isPlaying&&this.stop(),this._isReadyToPlay=!1,-1===this.soundTrackId?this._scene.mainSoundTrack.RemoveSound(this):this._scene.soundTracks[this.soundTrackId].RemoveSound(this),this._soundGain&&(this._soundGain.disconnect(),this._soundGain=null),this._soundPanner&&(this._soundPanner.disconnect(),this._soundPanner=null),this._soundSource&&(this._soundSource.disconnect(),this._soundSource=null),this._audioBuffer=null,this._connectedMesh&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._connectedMesh=null))},t.prototype._soundLoaded=function(t){var i=this;this._isLoaded=!0,e.Engine.audioEngine.audioContext.decodeAudioData(t,function(e){i._audioBuffer=e,i._isReadyToPlay=!0,i.autoplay&&i.play(),i._readyToPlayCallback&&i._readyToPlayCallback()},function(){e.Tools.Error("Error while decoding audio data for: "+i.name)})},t.prototype.setAudioBuffer=function(t){e.Engine.audioEngine.canUseWebAudio&&(this._audioBuffer=t,this._isReadyToPlay=!0)},t.prototype.updateOptions=function(e){e&&(this.loop=e.loop||this.loop,this.maxDistance=e.maxDistance||this.maxDistance,this.useCustomAttenuation=e.useCustomAttenuation||this.useCustomAttenuation,this.rolloffFactor=e.rolloffFactor||this.rolloffFactor,this.refDistance=e.refDistance||this.refDistance,this.distanceModel=e.distanceModel||this.distanceModel,this._playbackRate=e.playbackRate||this._playbackRate,this._updateSpatialParameters(),this.isPlaying&&(this._soundSource.playbackRate.value=this._playbackRate))},t.prototype._createSpatialParameters=function(){e.Engine.audioEngine.canUseWebAudio&&(this._scene.headphone&&(this._panningModel="HRTF"),this._soundPanner=e.Engine.audioEngine.audioContext.createPanner(),this._updateSpatialParameters(),this._soundPanner.connect(this._ouputAudioNode),this._inputAudioNode=this._soundPanner)},t.prototype._updateSpatialParameters=function(){this.spatialSound&&(this.useCustomAttenuation?(this._soundPanner.distanceModel="linear",this._soundPanner.maxDistance=Number.MAX_VALUE,this._soundPanner.refDistance=1,this._soundPanner.rolloffFactor=1,this._soundPanner.panningModel=this._panningModel):(this._soundPanner.distanceModel=this.distanceModel,this._soundPanner.maxDistance=this.maxDistance,this._soundPanner.refDistance=this.refDistance,this._soundPanner.rolloffFactor=this.rolloffFactor,this._soundPanner.panningModel=this._panningModel))},t.prototype.switchPanningModelToHRTF=function(){this._panningModel="HRTF",this._switchPanningModel()},t.prototype.switchPanningModelToEqualPower=function(){this._panningModel="equalpower",this._switchPanningModel()},t.prototype._switchPanningModel=function(){e.Engine.audioEngine.canUseWebAudio&&this.spatialSound&&(this._soundPanner.panningModel=this._panningModel)},t.prototype.connectToSoundTrackAudioNode=function(t){e.Engine.audioEngine.canUseWebAudio&&(this._isOutputConnected&&this._ouputAudioNode.disconnect(),this._ouputAudioNode.connect(t),this._isOutputConnected=!0)},t.prototype.setDirectionalCone=function(t,i,r){return t>i?void e.Tools.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle."):(this._coneInnerAngle=t,this._coneOuterAngle=i,this._coneOuterGain=r,this._isDirectional=!0,void(this.isPlaying&&this.loop&&(this.stop(),this.play())))},t.prototype.setPosition=function(t){this._position=t,e.Engine.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner.setPosition(this._position.x,this._position.y,this._position.z)},t.prototype.setLocalDirectionToMesh=function(t){this._localDirection=t,e.Engine.audioEngine.canUseWebAudio&&this._connectedMesh&&this.isPlaying&&this._updateDirection()},t.prototype._updateDirection=function(){var t=this._connectedMesh.getWorldMatrix(),i=e.Vector3.TransformNormal(this._localDirection,t);i.normalize(),this._soundPanner.setOrientation(i.x,i.y,i.z)},t.prototype.updateDistanceFromListener=function(){if(e.Engine.audioEngine.canUseWebAudio&&this._connectedMesh&&this.useCustomAttenuation){var t=this._connectedMesh.getDistanceToCamera(this._scene.activeCamera);this._soundGain.gain.value=this._customAttenuationFunction(this._volume,t,this.maxDistance,this.refDistance,this.rolloffFactor)}},t.prototype.setAttenuationFunction=function(e){this._customAttenuationFunction=e},t.prototype.play=function(t){var i=this;if(this._isReadyToPlay&&this._scene.audioEnabled)try{var r=t?e.Engine.audioEngine.audioContext.currentTime+t:e.Engine.audioEngine.audioContext.currentTime;this._soundSource||this.spatialSound&&(this._soundPanner.setPosition(this._position.x,this._position.y,this._position.z),this._isDirectional&&(this._soundPanner.coneInnerAngle=this._coneInnerAngle,this._soundPanner.coneOuterAngle=this._coneOuterAngle,this._soundPanner.coneOuterGain=this._coneOuterGain,this._connectedMesh?this._updateDirection():this._soundPanner.setOrientation(this._localDirection.x,this._localDirection.y,this._localDirection.z))),this._soundSource=e.Engine.audioEngine.audioContext.createBufferSource(),this._soundSource.buffer=this._audioBuffer,this._soundSource.connect(this._inputAudioNode),this._soundSource.loop=this.loop,this._soundSource.playbackRate.value=this._playbackRate,this._startTime=r,this._soundSource.onended=function(){i._onended()},this._soundSource.start(this._startTime,this.isPaused?this._startOffset%this._soundSource.buffer.duration:0),this.isPlaying=!0,this.isPaused=!1}catch(t){e.Tools.Error("Error while trying to play audio: "+this.name+", "+t.message)}},t.prototype._onended=function(){this.isPlaying=!1,this.onended&&this.onended()},t.prototype.stop=function(t){if(this.isPlaying){var i=t?e.Engine.audioEngine.audioContext.currentTime+t:e.Engine.audioEngine.audioContext.currentTime;this._soundSource.stop(i),this.isPlaying=!1}},t.prototype.pause=function(){this.isPlaying&&(this.stop(0),this._startOffset+=e.Engine.audioEngine.audioContext.currentTime-this._startTime,this.isPaused=!0)},t.prototype.setVolume=function(t,i){e.Engine.audioEngine.canUseWebAudio&&(i?(this._soundGain.gain.linearRampToValueAtTime(this._volume,e.Engine.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(t,i)):this._soundGain.gain.value=t),this._volume=t},t.prototype.setPlaybackRate=function(e){this._playbackRate=e,this.isPlaying&&(this._soundSource.playbackRate.value=this._playbackRate)},t.prototype.getVolume=function(){return this._volume},t.prototype.attachToMesh=function(e){var t=this;this._connectedMesh=e,this.spatialSound||(this.spatialSound=!0,this._createSpatialParameters(),this.isPlaying&&this.loop&&(this.stop(),this.play())),this._onRegisterAfterWorldMatrixUpdate(this._connectedMesh),this._registerFunc=function(e){return t._onRegisterAfterWorldMatrixUpdate(e)},e.registerAfterWorldMatrixUpdate(this._registerFunc)},t.prototype._onRegisterAfterWorldMatrixUpdate=function(t){this.setPosition(t.getBoundingInfo().boundingSphere.centerWorld),e.Engine.audioEngine.canUseWebAudio&&this._isDirectional&&this.isPlaying&&this._updateDirection()},t}();e.Sound=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t,i){this.id=-1,this._isMainTrack=!1,this._scene=t,this._audioEngine=e.Engine.audioEngine,this.soundCollection=new Array,this._audioEngine.canUseWebAudio&&(this._outputAudioNode=this._audioEngine.audioContext.createGain(),this._outputAudioNode.connect(this._audioEngine.masterGain),i&&(i.volume&&(this._outputAudioNode.gain.value=i.volume),i.mainTrack&&(this._isMainTrack=i.mainTrack))),this._isMainTrack||(this._scene.soundTracks.push(this),this.id=this._scene.soundTracks.length-1)}return t.prototype.dispose=function(){if(this._audioEngine.canUseWebAudio){for(this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas();this.soundCollection.length;)this.soundCollection[0].dispose();this._outputAudioNode&&this._outputAudioNode.disconnect(),this._outputAudioNode=null}},t.prototype.AddSound=function(t){e.Engine.audioEngine.canUseWebAudio&&t.connectToSoundTrackAudioNode(this._outputAudioNode),t.soundTrackId&&(-1===t.soundTrackId?this._scene.mainSoundTrack.RemoveSound(t):this._scene.soundTracks[t.soundTrackId].RemoveSound(t)),this.soundCollection.push(t),t.soundTrackId=this.id},t.prototype.RemoveSound=function(e){var t=this.soundCollection.indexOf(e);-1!==t&&this.soundCollection.splice(t,1)},t.prototype.setVolume=function(e){this._audioEngine.canUseWebAudio&&(this._outputAudioNode.gain.value=e)},t.prototype.switchPanningModelToHRTF=function(){if(e.Engine.audioEngine.canUseWebAudio)for(var t=0;t<this.soundCollection.length;t++)this.soundCollection[t].switchPanningModelToHRTF()},t.prototype.switchPanningModelToEqualPower=function(){if(e.Engine.audioEngine.canUseWebAudio)for(var t=0;t<this.soundCollection.length;t++)this.soundCollection[t].switchPanningModelToEqualPower()},t.prototype.connectToAnalyser=function(e){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser=e,this._audioEngine.canUseWebAudio&&(this._outputAudioNode.disconnect(),this._connectedAnalyser.connectAudioNodes(this._outputAudioNode,this._audioEngine.masterGain))},t}();e.SoundTrack=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t){var i=this;this._transformationMatrix=e.Matrix.Identity(),this._enabled=!1,this._labelsEnabled=!1,this._displayStatistics=!0,this._displayTree=!1,this._displayLogs=!1,this._identityMatrix=e.Matrix.Identity(),this.axisRatio=.02,this.accentColor="orange",this._scene=t,this._syncPositions=function(){var e=i._scene.getEngine(),t=e.getRenderingCanvasClientRect();i._showUI&&(i._statsDiv.style.left=t.width-410+"px",i._statsDiv.style.top=t.height-290+"px",i._statsDiv.style.width="400px",i._statsDiv.style.height="auto",i._statsSubsetDiv.style.maxHeight="240px",i._optionsDiv.style.left="0px",i._optionsDiv.style.top="10px",i._optionsDiv.style.width="200px",i._optionsDiv.style.height="auto",i._optionsSubsetDiv.style.maxHeight=t.height-225+"px",i._logDiv.style.left="0px",i._logDiv.style.top=t.height-170+"px",i._logDiv.style.width="600px",i._logDiv.style.height="160px",i._treeDiv.style.left=t.width-310+"px",i._treeDiv.style.top="10px",i._treeDiv.style.width="300px",i._treeDiv.style.height="auto",i._treeSubsetDiv.style.maxHeight=t.height-340+"px"),i._globalDiv.style.left=t.left+"px",i._globalDiv.style.top=t.top+"px",i._drawingCanvas.style.left="0px",i._drawingCanvas.style.top="0px",i._drawingCanvas.style.width=e.getRenderWidth()+"px",i._drawingCanvas.style.height=e.getRenderHeight()+"px";var r=window.devicePixelRatio||1,n=i._drawingContext,o=n.webkitBackingStorePixelRatio||n.mozBackingStorePixelRatio||n.msBackingStorePixelRatio||n.oBackingStorePixelRatio||n.backingStorePixelRatio||1;i._ratio=r/o,i._drawingCanvas.width=e.getRenderWidth()*i._ratio,i._drawingCanvas.height=e.getRenderHeight()*i._ratio},this._onCanvasClick=function(e){i._clickPosition={x:e.clientX*i._ratio,y:e.clientY*i._ratio}},this._syncUI=function(){i._showUI&&(i._displayStatistics?(i._displayStats(),i._statsDiv.style.display=""):i._statsDiv.style.display="none",i._logDiv.style.display=i._displayLogs?"":"none",i._displayTree?(i._treeDiv.style.display="",i._needToRefreshMeshesTree&&(i._needToRefreshMeshesTree=!1,i._refreshMeshesTreeContent())):i._treeDiv.style.display="none")},this._syncData=function(){if(i._labelsEnabled||!i._showUI){i._camera.getViewMatrix().multiplyToRef(i._camera.getProjectionMatrix(),i._transformationMatrix),i._drawingContext.clearRect(0,0,i._drawingCanvas.width,i._drawingCanvas.height);for(var t=i._scene.getEngine(),r=i._camera.viewport.toGlobal(t),n=i._camera.getActiveMeshes(),o=0;o<n.length;o++){var s=n.data[o],a=s.getBoundingInfo().boundingSphere.center,h=e.Vector3.Project(a,s.getWorldMatrix(),i._transformationMatrix,r);(s.renderOverlay||i.shouldDisplayAxis&&i.shouldDisplayAxis(s))&&i._renderAxis(h,s,r),(!i.shouldDisplayLabel||i.shouldDisplayLabel(s))&&i._renderLabel(s.name,h,12,function(){s.renderOverlay=!s.renderOverlay},function(){return s.renderOverlay?"red":"black"})}var c=i._scene.cameras;for(o=0;o<c.length;o++){var l=c[o];l!==i._camera&&(h=e.Vector3.Project(e.Vector3.Zero(),l.getWorldMatrix(),i._transformationMatrix,r),(!i.shouldDisplayLabel||i.shouldDisplayLabel(l))&&i._renderLabel(l.name,h,12,function(){i._camera.detachControl(t.getRenderingCanvas()),i._camera=l,i._camera.attachControl(t.getRenderingCanvas())},function(){return"purple"}))}var u=i._scene.lights;for(o=0;o<u.length;o++){var d=u[o];d.position&&(h=e.Vector3.Project(d.getAbsolutePosition(),i._identityMatrix,i._transformationMatrix,r),(!i.shouldDisplayLabel||i.shouldDisplayLabel(d))&&i._renderLabel(d.name,h,-20,function(){d.setEnabled(!d.isEnabled())},function(){return d.isEnabled()?"orange":"gray"}))}}i._clickPosition=void 0}}return t.prototype._refreshMeshesTreeContent=function(){for(;this._treeSubsetDiv.hasChildNodes();)this._treeSubsetDiv.removeChild(this._treeSubsetDiv.lastChild);var e=this._scene.meshes.slice(0,this._scene.meshes.length);e.sort(function(e,t){return e.name===t.name?0:e.name>t.name?1:-1});for(var t=0;t<e.length;t++){var i=e[t];i.isEnabled()&&this._generateAdvancedCheckBox(this._treeSubsetDiv,i.name,i.getTotalVertices()+" verts",i.isVisible,function(e,t){t.isVisible=e.checked},i)}},t.prototype._renderSingleAxis=function(e,t,i,r,n){this._drawingContext.beginPath(),this._drawingContext.moveTo(e.x,e.y),this._drawingContext.lineTo(t.x,t.y),this._drawingContext.strokeStyle=n,this._drawingContext.lineWidth=4,this._drawingContext.stroke(),this._drawingContext.font="normal 14px Segoe UI",this._drawingContext.fillStyle=n,this._drawingContext.fillText(r,i.x,i.y)},t.prototype._renderAxis=function(t,i,r){var n=i.getBoundingInfo().boundingSphere.center,o=i.getWorldMatrix(),s=e.Vector3.UnprojectFromTransform(t.add(new e.Vector3(this._drawingCanvas.width*this.axisRatio,0,0)),r.width,r.height,o,this._transformationMatrix).subtract(n).length(),a=e.Vector3.Project(n.add(new e.Vector3(s,0,0)),o,this._transformationMatrix,r),h=e.Vector3.Project(n.add(new e.Vector3(1.5*s,0,0)),o,this._transformationMatrix,r);this._renderSingleAxis(t,a,h,"x","#FF0000");var c=e.Vector3.Project(n.add(new e.Vector3(0,s,0)),o,this._transformationMatrix,r),l=e.Vector3.Project(n.add(new e.Vector3(0,1.5*s,0)),o,this._transformationMatrix,r);this._renderSingleAxis(t,c,l,"y","#00FF00");var u=e.Vector3.Project(n.add(new e.Vector3(0,0,s)),o,this._transformationMatrix,r),d=e.Vector3.Project(n.add(new e.Vector3(0,0,1.5*s)),o,this._transformationMatrix,r);this._renderSingleAxis(t,u,d,"z","#0000FF")},t.prototype._renderLabel=function(e,t,i,r,n){if(t.z>0&&t.z<1){this._drawingContext.font="normal 12px Segoe UI";var o=this._drawingContext.measureText(e),s=t.x-o.width/2,a=t.y,h=this._drawingCanvas.getBoundingClientRect();this._showUI&&this._isClickInsideRect(h.left*this._ratio+s-5,h.top*this._ratio+a-i-12,o.width+10,17)&&r(),this._drawingContext.beginPath(),this._drawingContext.rect(s-5,a-i-12,o.width+10,17),this._drawingContext.fillStyle=n(),this._drawingContext.globalAlpha=.5,this._drawingContext.fill(),this._drawingContext.globalAlpha=1,this._drawingContext.strokeStyle="#FFFFFF",this._drawingContext.lineWidth=1,this._drawingContext.stroke(),this._drawingContext.fillStyle="#FFFFFF",this._drawingContext.fillText(e,s,a-i),this._drawingContext.beginPath(),this._drawingContext.arc(t.x,a,5,0,2*Math.PI,!1),this._drawingContext.fill()}},t.prototype._isClickInsideRect=function(e,t,i,r){return!!this._clickPosition&&(!(this._clickPosition.x<e||this._clickPosition.x>e+i)&&!(this._clickPosition.y<t||this._clickPosition.y>t+r))},t.prototype.isVisible=function(){return this._enabled},t.prototype.hide=function(){if(this._enabled){this._enabled=!1;var t=this._scene.getEngine();this._scene.unregisterBeforeRender(this._syncData),this._scene.unregisterAfterRender(this._syncUI),document.body.removeChild(this._globalDiv),window.removeEventListener("resize",this._syncPositions),this._scene.forceShowBoundingBoxes=!1,this._scene.forceWireframe=!1,e.StandardMaterial.DiffuseTextureEnabled=!0,e.StandardMaterial.AmbientTextureEnabled=!0,e.StandardMaterial.SpecularTextureEnabled=!0,e.StandardMaterial.EmissiveTextureEnabled=!0,e.StandardMaterial.BumpTextureEnabled=!0,e.StandardMaterial.OpacityTextureEnabled=!0,e.StandardMaterial.ReflectionTextureEnabled=!0,e.StandardMaterial.LightmapEnabled=!0,this._scene.shadowsEnabled=!0,this._scene.particlesEnabled=!0,this._scene.postProcessesEnabled=!0,this._scene.collisionsEnabled=!0,this._scene.lightsEnabled=!0,this._scene.texturesEnabled=!0,this._scene.lensFlaresEnabled=!0,this._scene.proceduralTexturesEnabled=!0,this._scene.renderTargetsEnabled=!0,this._scene.probesEnabled=!0,t.getRenderingCanvas().removeEventListener("click",this._onCanvasClick)}},t.prototype.show=function(e,t){if(void 0===e&&(e=!0),void 0===t&&(t=null),!this._enabled){this._enabled=!0,this._camera=t||this._scene.activeCamera,this._showUI=e;var i=this._scene.getEngine();this._globalDiv=document.createElement("div"),document.body.appendChild(this._globalDiv),this._generateDOMelements(),window.addEventListener("resize",this._syncPositions),i.getRenderingCanvas().addEventListener("click",this._onCanvasClick),this._syncPositions(),this._scene.registerBeforeRender(this._syncData),this._scene.registerAfterRender(this._syncUI)}},t.prototype._clearLabels=function(){this._drawingContext.clearRect(0,0,this._drawingCanvas.width,this._drawingCanvas.height);for(var e=0;e<this._scene.meshes.length;e++){this._scene.meshes[e].renderOverlay=!1}},t.prototype._generateheader=function(e,t){var i=document.createElement("div");i.innerHTML=t+"&nbsp;",i.style.textAlign="right",i.style.width="100%",i.style.color="white",i.style.backgroundColor="Black",i.style.padding="5px 5px 4px 0px",i.style.marginLeft="-5px",i.style.fontWeight="bold",e.appendChild(i)},t.prototype._generateTexBox=function(e,t,i){var r=document.createElement("label");r.innerHTML=t,r.style.color=i,e.appendChild(r),e.appendChild(document.createElement("br"))},t.prototype._generateAdvancedCheckBox=function(e,t,i,r,n,o){void 0===o&&(o=null);var s=document.createElement("label"),a=document.createElement("input");a.type="checkbox",a.checked=r,a.addEventListener("change",function(e){n(e.target,o)}),s.appendChild(a);var h=document.createElement("span"),c=document.createElement("span"),l=document.createElement("span");l.style.cssFloat="right",c.innerHTML=t,l.innerHTML=i,l.style.fontSize="12px",l.style.maxWidth="200px",h.appendChild(c),h.appendChild(l),s.appendChild(h),e.appendChild(s),e.appendChild(document.createElement("br"))},t.prototype._generateCheckBox=function(e,t,i,r,n){void 0===n&&(n=null);var o=document.createElement("label"),s=document.createElement("input");s.type="checkbox",s.checked=i,s.addEventListener("change",function(e){r(e.target,n)}),o.appendChild(s),o.appendChild(document.createTextNode(t)),e.appendChild(o),e.appendChild(document.createElement("br"))},t.prototype._generateButton=function(e,t,i,r){void 0===r&&(r=null);var n=document.createElement("button");n.innerHTML=t,n.style.height="24px",n.style.color="#444444",n.style.border="1px solid white",n.className="debugLayerButton",n.addEventListener("click",function(e){i(e.target,r)}),e.appendChild(n),e.appendChild(document.createElement("br"))},t.prototype._generateRadio=function(e,t,i,r,n,o){void 0===o&&(o=null);var s=document.createElement("label"),a=document.createElement("input");a.type="radio",a.name=i,a.checked=r,a.addEventListener("change",function(e){n(e.target,o)}),s.appendChild(a),s.appendChild(document.createTextNode(t)),e.appendChild(s),e.appendChild(document.createElement("br"))},t.prototype._generateDOMelements=function(){var t=this;if(this._globalDiv.id="DebugLayer",this._globalDiv.style.position="absolute",this._globalDiv.style.fontFamily="Segoe UI, Arial",this._globalDiv.style.fontSize="14px",this._globalDiv.style.color="white",this._drawingCanvas=document.createElement("canvas"),this._drawingCanvas.id="DebugLayerDrawingCanvas",this._drawingCanvas.style.position="absolute",this._drawingCanvas.style.pointerEvents="none",this._drawingContext=this._drawingCanvas.getContext("2d"),this._globalDiv.appendChild(this._drawingCanvas),this._showUI){var i="rgba(128, 128, 128, 0.4)",r="rgb(180, 180, 180) solid 1px";this._statsDiv=document.createElement("div"),this._statsDiv.id="DebugLayerStats",this._statsDiv.style.border=r,this._statsDiv.style.position="absolute",this._statsDiv.style.background=i,this._statsDiv.style.padding="0px 0px 0px 5px",this._generateheader(this._statsDiv,"STATISTICS"),this._statsSubsetDiv=document.createElement("div"),this._statsSubsetDiv.style.paddingTop="5px",this._statsSubsetDiv.style.paddingBottom="5px",this._statsSubsetDiv.style.overflowY="auto",this._statsDiv.appendChild(this._statsSubsetDiv),this._treeDiv=document.createElement("div"),this._treeDiv.id="DebugLayerTree",this._treeDiv.style.border=r,this._treeDiv.style.position="absolute",this._treeDiv.style.background=i,this._treeDiv.style.padding="0px 0px 0px 5px",this._treeDiv.style.display="none",this._generateheader(this._treeDiv,"MESHES TREE"),this._treeSubsetDiv=document.createElement("div"),this._treeSubsetDiv.style.paddingTop="5px",this._treeSubsetDiv.style.paddingRight="5px",this._treeSubsetDiv.style.overflowY="auto",this._treeSubsetDiv.style.maxHeight="300px",this._treeDiv.appendChild(this._treeSubsetDiv),this._needToRefreshMeshesTree=!0,this._logDiv=document.createElement("div"),this._logDiv.style.border=r,this._logDiv.id="DebugLayerLogs",this._logDiv.style.position="absolute",this._logDiv.style.background=i,this._logDiv.style.padding="0px 0px 0px 5px",this._logDiv.style.display="none",this._generateheader(this._logDiv,"LOGS"),this._logSubsetDiv=document.createElement("div"),this._logSubsetDiv.style.height="127px",this._logSubsetDiv.style.paddingTop="5px",this._logSubsetDiv.style.overflowY="auto",this._logSubsetDiv.style.fontSize="12px",this._logSubsetDiv.style.fontFamily="consolas",this._logSubsetDiv.innerHTML=e.Tools.LogCache,this._logDiv.appendChild(this._logSubsetDiv),e.Tools.OnNewCacheEntry=function(e){t._logSubsetDiv.innerHTML=e+t._logSubsetDiv.innerHTML},this._optionsDiv=document.createElement("div"),this._optionsDiv.id="DebugLayerOptions",this._optionsDiv.style.border=r,this._optionsDiv.style.position="absolute",this._optionsDiv.style.background=i,this._optionsDiv.style.padding="0px 0px 0px 5px",this._optionsDiv.style.overflowY="auto",this._generateheader(this._optionsDiv,"OPTIONS"),this._optionsSubsetDiv=document.createElement("div"),this._optionsSubsetDiv.style.paddingTop="5px",this._optionsSubsetDiv.style.paddingBottom="5px",this._optionsSubsetDiv.style.overflowY="auto",this._optionsSubsetDiv.style.maxHeight="200px",this._optionsDiv.appendChild(this._optionsSubsetDiv),this._generateTexBox(this._optionsSubsetDiv,"<b>Windows:</b>",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Statistics",this._displayStatistics,function(e){t._displayStatistics=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Logs",this._displayLogs,function(e){t._displayLogs=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Meshes tree",this._displayTree,function(e){t._displayTree=e.checked,t._needToRefreshMeshesTree=!0}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"<b>General:</b>",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Bounding boxes",this._scene.forceShowBoundingBoxes,function(e){t._scene.forceShowBoundingBoxes=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Clickable labels",this._labelsEnabled,function(e){t._labelsEnabled=e.checked,t._labelsEnabled||t._clearLabels()}),this._generateCheckBox(this._optionsSubsetDiv,"Generate user marks (F12)",e.Tools.PerformanceLogLevel===e.Tools.PerformanceUserMarkLogLevel,function(t){e.Tools.PerformanceLogLevel=t.checked?e.Tools.PerformanceUserMarkLogLevel:e.Tools.PerformanceNoneLogLevel}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"<b>Rendering mode:</b>",this.accentColor),this._generateRadio(this._optionsSubsetDiv,"Solid","renderMode",!this._scene.forceWireframe&&!this._scene.forcePointsCloud,function(e){e.checked&&(t._scene.forceWireframe=!1,t._scene.forcePointsCloud=!1)}),this._generateRadio(this._optionsSubsetDiv,"Wireframe","renderMode",this._scene.forceWireframe,function(e){e.checked&&(t._scene.forceWireframe=!0,t._scene.forcePointsCloud=!1)}),this._generateRadio(this._optionsSubsetDiv,"Point","renderMode",this._scene.forcePointsCloud,function(e){e.checked&&(t._scene.forceWireframe=!1,t._scene.forcePointsCloud=!0)}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"<b>Texture channels:</b>",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Diffuse",e.StandardMaterial.DiffuseTextureEnabled,function(t){e.StandardMaterial.DiffuseTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Ambient",e.StandardMaterial.AmbientTextureEnabled,function(t){e.StandardMaterial.AmbientTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Specular",e.StandardMaterial.SpecularTextureEnabled,function(t){e.StandardMaterial.SpecularTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Emissive",e.StandardMaterial.EmissiveTextureEnabled,function(t){e.StandardMaterial.EmissiveTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Bump",e.StandardMaterial.BumpTextureEnabled,function(t){e.StandardMaterial.BumpTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Opacity",e.StandardMaterial.OpacityTextureEnabled,function(t){e.StandardMaterial.OpacityTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Reflection",e.StandardMaterial.ReflectionTextureEnabled,function(t){e.StandardMaterial.ReflectionTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Fresnel",e.StandardMaterial.FresnelEnabled,function(t){e.StandardMaterial.FresnelEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Lightmap",e.StandardMaterial.LightmapEnabled,function(t){e.StandardMaterial.LightmapEnabled=t.checked}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"<b>Options:</b>",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Animations",this._scene.animationsEnabled,function(e){t._scene.animationsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Collisions",this._scene.collisionsEnabled,function(e){t._scene.collisionsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Fog",this._scene.fogEnabled,function(e){t._scene.fogEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Lens flares",this._scene.lensFlaresEnabled,function(e){t._scene.lensFlaresEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Lights",this._scene.lightsEnabled,function(e){t._scene.lightsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Particles",this._scene.particlesEnabled,function(e){t._scene.particlesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Post-processes",this._scene.postProcessesEnabled,function(e){t._scene.postProcessesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Probes",this._scene.probesEnabled,function(e){t._scene.probesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Procedural textures",this._scene.proceduralTexturesEnabled,function(e){t._scene.proceduralTexturesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Render targets",this._scene.renderTargetsEnabled,function(e){t._scene.renderTargetsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Shadows",this._scene.shadowsEnabled,function(e){t._scene.shadowsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Skeletons",this._scene.skeletonsEnabled,function(e){t._scene.skeletonsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Sprites",this._scene.spritesEnabled,function(e){t._scene.spritesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Textures",this._scene.texturesEnabled,function(e){t._scene.texturesEnabled=e.checked}),e.Engine.audioEngine.canUseWebAudio&&(this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"<b>Audio:</b>",this.accentColor),this._generateRadio(this._optionsSubsetDiv,"Headphones","panningModel",this._scene.headphone,function(e){e.checked&&(t._scene.headphone=!0)}),this._generateRadio(this._optionsSubsetDiv,"Normal Speakers","panningModel",!this._scene.headphone,function(e){e.checked&&(t._scene.headphone=!1)}),this._generateCheckBox(this._optionsSubsetDiv,"Disable audio",!this._scene.audioEnabled,function(e){t._scene.audioEnabled=!e.checked})),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"<b>Tools:</b>",this.accentColor),this._generateButton(this._optionsSubsetDiv,"Dump rendertargets",function(e){t._scene.dumpNextRenderTargets=!0}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._globalDiv.appendChild(this._statsDiv),this._globalDiv.appendChild(this._logDiv),this._globalDiv.appendChild(this._optionsDiv),this._globalDiv.appendChild(this._treeDiv)}},t.prototype._displayStats=function(){var t=this._scene,i=t.getEngine(),r=i.getGlInfo();this._statsSubsetDiv.innerHTML="Babylon.js v"+e.Engine.Version+" - <b>"+e.Tools.Format(i.getFps(),0)+" fps</b><br><br><div style='column-count: 2;-moz-column-count:2;-webkit-column-count:2'><b>Count</b><br>Total meshes: "+t.meshes.length+"<br>Total vertices: "+t.getTotalVertices()+"<br>Total materials: "+t.materials.length+"<br>Total textures: "+t.textures.length+"<br>Active meshes: "+t.getActiveMeshes().length+"<br>Active indices: "+t.getActiveIndices()+"<br>Active bones: "+t.getActiveBones()+"<br>Active particles: "+t.getActiveParticles()+"<br><b>Draw calls: "+i.drawCalls+"</b><br><br><b>Duration</b><br>Meshes selection:</i> "+e.Tools.Format(t.getEvaluateActiveMeshesDuration())+" ms<br>Render Targets: "+e.Tools.Format(t.getRenderTargetsDuration())+" ms<br>Particles: "+e.Tools.Format(t.getParticlesDuration())+" ms<br>Sprites: "+e.Tools.Format(t.getSpritesDuration())+" ms<br><br>Render: <b>"+e.Tools.Format(t.getRenderDuration())+" ms</b><br>Frame: "+e.Tools.Format(t.getLastFrameDuration())+" ms<br>Potential FPS: "+e.Tools.Format(1e3/t.getLastFrameDuration(),0)+"<br><br></div><div style='column-count: 2;-moz-column-count:2;-webkit-column-count:2'><b>Extensions</b><br>Std derivatives: "+(i.getCaps().standardDerivatives?"Yes":"No")+"<br>Compressed textures: "+(i.getCaps().s3tc?"Yes":"No")+"<br>Hardware instances: "+(i.getCaps().instancedArrays?"Yes":"No")+"<br>Texture float: "+(i.getCaps().textureFloat?"Yes":"No")+"<br>32bits indices: "+(i.getCaps().uintIndices?"Yes":"No")+"<br><b>Caps.</b><br>Max textures units: "+i.getCaps().maxTexturesImageUnits+"<br>Max textures size: "+i.getCaps().maxTextureSize+"<br>Max anisotropy: "+i.getCaps().maxAnisotropy+"<br><br><br></div><br><b>Info</b><br>"+r.version+"<br>"+r.renderer+"<br>",this.customStatsFunction&&(this._statsSubsetDiv.innerHTML+=this._statsSubsetDiv.innerHTML)},t}();e.DebugLayer=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o,s,a,h,c){void 0===a&&(a=!0),void 0===h&&(h=!1),void 0===c&&(c=e.Texture.TRILINEAR_SAMPLINGMODE),t.call(this,null,s,!a,h),this.format=o,this._texture=s.getEngine().createRawTexture(i,r,n,o,a,h,c),this.wrapU=e.Texture.CLAMP_ADDRESSMODE,this.wrapV=e.Texture.CLAMP_ADDRESSMODE}return __extends(i,t),i.prototype.update=function(e){this.getScene().getEngine().updateRawTexture(this._texture,e,this.format,this._invertY)},i.CreateLuminanceTexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_LUMINANCE,o,s,a,h)},i.CreateLuminanceAlphaTexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_LUMINANCE_ALPHA,o,s,a,h)},i.CreateAlphaTexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_ALPHA,o,s,a,h)},i.CreateRGBTexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_RGB,o,s,a,h)},i.CreateRGBATexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_RGBA,o,s,a,h)},i}(e.Texture);e.RawTexture=t}(BABYLON||(BABYLON={})),function(e){var t=function(e){function t(t,i){e.call(this,t.x,t.y),this.index=i}return __extends(t,e),t}(e.Vector2),i=function(){function i(){this.elements=new Array}return i.prototype.add=function(e){var i=this,r=new Array;return e.forEach(function(e){if(0===r.length||!e.equalsWithEpsilon(r[0])){var n=new t(e,i.elements.length);r.push(n),i.elements.push(n)}}),r},i.prototype.computeBounds=function(){var t=new e.Vector2(this.elements[0].x,this.elements[0].y),i=new e.Vector2(this.elements[0].x,this.elements[0].y);return this.elements.forEach(function(e){e.x<t.x?t.x=e.x:e.x>i.x&&(i.x=e.x),e.y<t.y?t.y=e.y:e.y>i.y&&(i.y=e.y)}),{min:t,max:i,width:i.x-t.x,height:i.y-t.y}},i}(),r=function(){function t(){}return t.Rectangle=function(t,i,r,n){return[new e.Vector2(t,i),new e.Vector2(r,i),new e.Vector2(r,n),new e.Vector2(t,n)]},t.Circle=function(t,i,r,n){void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=32);for(var o=new Array,s=0,a=2*Math.PI/n,h=0;n>h;h++)o.push(new e.Vector2(i+Math.cos(s)*t,r+Math.sin(s)*t)),s-=a;return o},t.Parse=function(t){var i,r=t.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function(e){return!isNaN(e)}),n=[];for(i=0;i<(2147483646&r.length);i+=2)n.push(new e.Vector2(r[i],r[i+1]));return n},t.StartingAt=function(t,i){return e.Path2.StartingAt(t,i)},t}();e.Polygon=r;var n=function(){function t(t,r,n){if(this._points=new i,this._outlinepoints=new i,this._holes=[],!("poly2tri"in window))throw"PolygonMeshBuilder cannot be used because poly2tri is not referenced";var o;this._name=t,this._scene=n,o=r instanceof e.Path2?r.getPoints():r,this._swctx=new poly2tri.SweepContext(this._points.add(o)),this._outlinepoints.add(o)}return t.prototype.addHole=function(e){this._swctx.addHole(this._points.add(e));var t=new i;return t.add(e),this._holes.push(t),this},t.prototype.build=function(t,i){var r=this;void 0===t&&(t=!1);var n=new e.Mesh(this._name,this._scene),o=[],s=[],a=[],h=this._points.computeBounds();this._points.elements.forEach(function(e){o.push(0,1,0),s.push(e.x,0,e.y),a.push((e.x-h.min.x)/h.width,(e.y-h.min.y)/h.height)});var c=[];if(this._swctx.triangulate(),this._swctx.getTriangles().forEach(function(e){e.getPoints().forEach(function(e){c.push(e.index)})}),i>0){var l=s.length/3;this._points.elements.forEach(function(e){o.push(0,-1,0),s.push(e.x,-i,e.y),a.push(1-(e.x-h.min.x)/h.width,1-(e.y-h.min.y)/h.height)});var u,d,f=0;this._swctx.getTriangles().forEach(function(e){e.getPoints().forEach(function(e){switch(f){case 0:u=e;break;case 1:d=e;break;case 2:c.push(e.index+l),c.push(d.index+l),c.push(u.index+l),f=-1}f++})}),this.addSide(s,o,a,c,h,this._outlinepoints,i,!1),this._holes.forEach(function(e){r.addSide(s,o,a,c,h,e,i,!0)})}return n.setVerticesData(e.VertexBuffer.PositionKind,s,t),n.setVerticesData(e.VertexBuffer.NormalKind,o,t),n.setVerticesData(e.VertexBuffer.UVKind,a,t),n.setIndices(c),n},t.prototype.addSide=function(t,i,r,n,o,s,a,h){for(var c=t.length/3,l=0,u=0;u<s.elements.length;u++){var d,f=s.elements[u];d=u+1>s.elements.length-1?s.elements[0]:s.elements[u+1],t.push(f.x,0,f.y),t.push(f.x,-a,f.y),t.push(d.x,0,d.y),t.push(d.x,-a,d.y);var p=new e.Vector3(f.x,0,f.y),m=new e.Vector3(d.x,0,d.y).subtract(p),g=new e.Vector3(0,1,0),v=e.Vector3.Cross(m,g);v=v.normalize(),r.push(l/o.width,0),r.push(l/o.width,1),l+=m.length(),r.push(l/o.width,0),r.push(l/o.width,1),h?(i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),n.push(c),n.push(c+2),n.push(c+1),n.push(c+1),n.push(c+2),n.push(c+3)):(i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),n.push(c),n.push(c+1),n.push(c+2),n.push(c+1),n.push(c+3),n.push(c+2)),c+=4}},t}();e.PolygonMeshBuilder=n}(BABYLON||(BABYLON={})),function(e){var t=function(){return function(e,t,i){this.quality=e,this.distance=t,this.optimizeMesh=i}}();e.SimplificationSettings=t;var i=function(){function t(){this.running=!1,this._simplificationArray=[]}return t.prototype.addTask=function(e){this._simplificationArray.push(e)},t.prototype.executeNext=function(){var e=this._simplificationArray.pop();e?(this.running=!0,this.runSimplification(e)):this.running=!1},t.prototype.runSimplification=function(t){var i=this;if(t.parallelProcessing)t.settings.forEach(function(e){i.getSimplifier(t).simplify(e,function(r){t.mesh.addLODLevel(e.distance,r),r.isVisible=!0,e.quality===t.settings[t.settings.length-1].quality&&t.successCallback&&t.successCallback(),i.executeNext()})});else{var r=this.getSimplifier(t);e.AsyncLoop.Run(t.settings.length,function(e){!function(e,i){r.simplify(e,function(r){t.mesh.addLODLevel(e.distance,r),r.isVisible=!0,i()})}(t.settings[e.index],function(){e.executeNext()})},function(){t.successCallback&&t.successCallback(),i.executeNext()})}},t.prototype.getSimplifier=function(e){switch(e.simplificationType){case r.QUADRATIC:default:return new h(e.mesh)}},t}();e.SimplificationQueue=i,function(e){e[e.QUADRATIC=0]="QUADRATIC"}(e.SimplificationType||(e.SimplificationType={}));var r=e.SimplificationType,n=function(){return function(e){this.vertices=e,this.error=new Array(4),this.deleted=!1,this.isDirty=!1,this.deletePending=!1,this.borderFactor=0}}();e.DecimationTriangle=n;var o=function(){function e(e,t){this.position=e,this.id=t,this.isBorder=!0,this.q=new s,this.triangleCount=0,this.triangleStart=0,this.originalOffsets=[]}return e.prototype.updatePosition=function(e){this.position.copyFrom(e)},e}();e.DecimationVertex=o;var s=function(){function e(e){this.data=new Array(10);for(var t=0;10>t;++t)this.data[t]=e&&e[t]?e[t]:0}return e.prototype.det=function(e,t,i,r,n,o,s,a,h){return this.data[e]*this.data[n]*this.data[h]+this.data[i]*this.data[r]*this.data[a]+this.data[t]*this.data[o]*this.data[s]-this.data[i]*this.data[n]*this.data[s]-this.data[e]*this.data[o]*this.data[a]-this.data[t]*this.data[r]*this.data[h]},e.prototype.addInPlace=function(e){for(var t=0;10>t;++t)this.data[t]+=e.data[t]},e.prototype.addArrayInPlace=function(e){for(var t=0;10>t;++t)this.data[t]+=e[t]},e.prototype.add=function(t){for(var i=new e,r=0;10>r;++r)i.data[r]=this.data[r]+t.data[r];return i},e.FromData=function(t,i,r,n){return new e(e.DataFromNumbers(t,i,r,n))},e.DataFromNumbers=function(e,t,i,r){return[e*e,e*t,e*i,e*r,t*t,t*i,t*r,i*i,i*r,r*r]},e}();e.QuadraticMatrix=s;var a=function(){return function(e,t){this.vertexId=e,this.triangleId=t}}();e.Reference=a;var h=function(){function t(t){this._mesh=t,this.initialized=!1,this.syncIterations=5e3,this.aggressiveness=7,this.decimationIterations=100,this.boundingBoxEpsilon=e.Engine.Epsilon}return t.prototype.simplify=function(t,i){var r=this;this.initDecimatedMesh(),e.AsyncLoop.Run(this._mesh.subMeshes.length,function(e){r.initWithMesh(e.index,function(){r.runDecimation(t,e.index,function(){e.executeNext()})},t.optimizeMesh)},function(){setTimeout(function(){i(r._reconstructedMesh)},0)})},t.prototype.isTriangleOnBoundingBox=function(e){var t=this,i=0;return e.vertices.forEach(function(e){var r=0,n=e.position,o=t._mesh.getBoundingInfo().boundingBox;(o.maximum.x-n.x<t.boundingBoxEpsilon||n.x-o.minimum.x>t.boundingBoxEpsilon)&&++r,(o.maximum.y==n.y||n.y==o.minimum.y)&&++r,(o.maximum.z==n.z||n.z==o.minimum.z)&&++r,r>1&&++i}),i>1&&console.log(e,i),i>1},t.prototype.runDecimation=function(t,i,r){var n=this,o=~~(this.triangles.length*t.quality),s=0,a=this.triangles.length,h=function(t,i){setTimeout(function(){t%5==0&&n.updateMesh(0===t);for(var r=0;r<n.triangles.length;++r)n.triangles[r].isDirty=!1;var h=1e-9*Math.pow(t+3,n.aggressiveness);e.AsyncLoop.SyncAsyncForLoop(n.triangles.length,n.syncIterations,function(t){var i=~~((n.triangles.length/2+t)%n.triangles.length),r=n.triangles[i];if(r&&!(r.error[3]>h||r.deleted||r.isDirty))for(var o=0;3>o;++o)if(r.error[o]<h){var a=[],c=[],l=r.vertices[o],u=r.vertices[(o+1)%3];if(l.isBorder!==u.isBorder)continue;var d=e.Vector3.Zero(),f=e.Vector3.Zero(),p=e.Vector2.Zero(),m=new e.Color4(0,0,0,1);n.calculateError(l,u,d,f,p,m);var g=[];if(n.isFlipped(l,u,d,a,r.borderFactor,g))continue;if(n.isFlipped(u,l,d,c,r.borderFactor,g))continue;if(a.indexOf(!0)<0||c.indexOf(!0)<0)continue;var v=[];if(g.forEach(function(e){-1===v.indexOf(e)&&(e.deletePending=!0,v.push(e))}),v.length%2!=0)continue;l.q=u.q.add(l.q),l.updatePosition(d);var _=n.references.length;s=n.updateTriangles(l,l,a,s),s=n.updateTriangles(l,u,c,s);var y=n.references.length-_;if(y<=l.triangleCount){if(y)for(var x=0;y>x;x++)n.references[l.triangleStart+x]=n.references[_+x]}else l.triangleStart=_;l.triangleCount=y;break}},i,function(){return o>=a-s})},0)};e.AsyncLoop.Run(this.decimationIterations,function(e){o>=a-s?e.breakLoop():h(e.index,function(){e.executeNext()})},function(){setTimeout(function(){n.reconstructMesh(i),r()},0)})},t.prototype.initWithMesh=function(t,i,r){var s=this;this.vertices=[],this.triangles=[];var a=this._mesh.getVerticesData(e.VertexBuffer.PositionKind),h=this._mesh.getIndices(),c=this._mesh.subMeshes[t],l=function(e){if(r)for(var t=0;t<s.vertices.length;++t)if(s.vertices[t].position.equals(e))return s.vertices[t];return null},u=[],d=c.verticesCount;e.AsyncLoop.SyncAsyncForLoop(d,this.syncIterations/4>>0,function(t){var i=t+c.verticesStart,r=e.Vector3.FromArray(a,3*i),n=l(r)||new o(r,s.vertices.length);n.originalOffsets.push(i),n.id==s.vertices.length&&s.vertices.push(n),u.push(n.id)},function(){e.AsyncLoop.SyncAsyncForLoop(c.indexCount/3,s.syncIterations,function(e){var t=3*(c.indexStart/3+e),i=h[t+0],r=h[t+1],o=h[t+2],a=s.vertices[u[i-c.verticesStart]],l=s.vertices[u[r-c.verticesStart]],d=s.vertices[u[o-c.verticesStart]],f=new n([a,l,d]);f.originalOffset=t,s.triangles.push(f)},function(){s.init(i)})})},t.prototype.init=function(t){var i=this;e.AsyncLoop.SyncAsyncForLoop(this.triangles.length,this.syncIterations,function(t){var r=i.triangles[t];r.normal=e.Vector3.Cross(r.vertices[1].position.subtract(r.vertices[0].position),r.vertices[2].position.subtract(r.vertices[0].position)).normalize();for(var n=0;3>n;n++)r.vertices[n].q.addArrayInPlace(s.DataFromNumbers(r.normal.x,r.normal.y,r.normal.z,-e.Vector3.Dot(r.normal,r.vertices[0].position)))},function(){e.AsyncLoop.SyncAsyncForLoop(i.triangles.length,i.syncIterations,function(e){for(var t=i.triangles[e],r=0;3>r;++r)t.error[r]=i.calculateError(t.vertices[r],t.vertices[(r+1)%3]);t.error[3]=Math.min(t.error[0],t.error[1],t.error[2])},function(){i.initialized=!0,t()})})},t.prototype.reconstructMesh=function(t){var i,r,n=[];for(i=0;i<this.vertices.length;++i)this.vertices[i].triangleCount=0;for(i=0;i<this.triangles.length;++i)if(!this.triangles[i].deleted){for(y=this.triangles[i],r=0;3>r;++r)y.vertices[r].triangleCount=1;n.push(y)}var o=this._reconstructedMesh.getVerticesData(e.VertexBuffer.PositionKind)||[],s=this._reconstructedMesh.getVerticesData(e.VertexBuffer.NormalKind)||[],a=this._reconstructedMesh.getVerticesData(e.VertexBuffer.UVKind)||[],h=this._reconstructedMesh.getVerticesData(e.VertexBuffer.ColorKind)||[],c=this._mesh.getVerticesData(e.VertexBuffer.NormalKind),l=this._mesh.getVerticesData(e.VertexBuffer.UVKind),u=this._mesh.getVerticesData(e.VertexBuffer.ColorKind),d=0;for(i=0;i<this.vertices.length;++i){var f=this.vertices[i];f.id=d,f.triangleCount&&f.originalOffsets.forEach(function(e){o.push(f.position.x),o.push(f.position.y),o.push(f.position.z),s.push(c[3*e]),s.push(c[3*e+1]),s.push(c[3*e+2]),l&&l.length?(a.push(l[2*e]),a.push(l[2*e+1])):u&&u.length&&(h.push(u[4*e]),h.push(u[4*e+1]),h.push(u[4*e+2]),h.push(u[4*e+3])),++d})}var p=this._reconstructedMesh.getTotalIndices(),m=this._reconstructedMesh.getTotalVertices(),g=this._reconstructedMesh.subMeshes;this._reconstructedMesh.subMeshes=[];var v=this._reconstructedMesh.getIndices(),_=this._mesh.getIndices();for(i=0;i<n.length;++i){var y=n[i];[0,1,2].forEach(function(e){var t=_[y.originalOffset+e],i=y.vertices[e].originalOffsets.indexOf(t);0>i&&(i=0),v.push(y.vertices[e].id+i+m)})}this._reconstructedMesh.setIndices(v),this._reconstructedMesh.setVerticesData(e.VertexBuffer.PositionKind,o),this._reconstructedMesh.setVerticesData(e.VertexBuffer.NormalKind,s),a.length>0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.UVKind,a),h.length>0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.ColorKind,h);var x=this._mesh.subMeshes[t];t>0&&(this._reconstructedMesh.subMeshes=[],g.forEach(function(t){new e.SubMesh(t.materialIndex,t.verticesStart,t.verticesCount,t.indexStart,t.indexCount,t.getMesh())}),new e.SubMesh(x.materialIndex,m,d,p,3*n.length,this._reconstructedMesh))},t.prototype.initDecimatedMesh=function(){this._reconstructedMesh=new e.Mesh(this._mesh.name+"Decimated",this._mesh.getScene()),this._reconstructedMesh.material=this._mesh.material,this._reconstructedMesh.parent=this._mesh.parent,this._reconstructedMesh.isVisible=!1},t.prototype.isFlipped=function(t,i,r,n,o,s){for(var a=0;a<t.triangleCount;++a){var h=this.triangles[this.references[t.triangleStart+a].triangleId];if(!h.deleted){var c=this.references[t.triangleStart+a].vertexId,l=h.vertices[(c+1)%3],u=h.vertices[(c+2)%3];if(l!==i&&u!==i){var d=l.position.subtract(r);d=d.normalize();var f=u.position.subtract(r);if(f=f.normalize(),Math.abs(e.Vector3.Dot(d,f))>.999)return!0;var p=e.Vector3.Cross(d,f).normalize();if(n[a]=!1,e.Vector3.Dot(p,h.normal)<.2)return!0}else n[a]=!0,s.push(h)}}return!1},t.prototype.updateTriangles=function(e,t,i,r){for(var n=r,o=0;o<t.triangleCount;++o){var s=this.references[t.triangleStart+o],a=this.triangles[s.triangleId];a.deleted||(i[o]&&a.deletePending?(a.deleted=!0,n++):(a.vertices[s.vertexId]=e,a.isDirty=!0,a.error[0]=this.calculateError(a.vertices[0],a.vertices[1])+a.borderFactor/2,a.error[1]=this.calculateError(a.vertices[1],a.vertices[2])+a.borderFactor/2,a.error[2]=this.calculateError(a.vertices[2],a.vertices[0])+a.borderFactor/2,a.error[3]=Math.min(a.error[0],a.error[1],a.error[2]),this.references.push(s)))}return n},t.prototype.identifyBorder=function(){for(var e=0;e<this.vertices.length;++e){var t,i=[],r=[],n=this.vertices[e];for(t=0;t<n.triangleCount;++t)for(var o=this.triangles[this.references[n.triangleStart+t].triangleId],s=0;3>s;s++){for(var a=0,h=o.vertices[s];a<i.length&&r[a]!==h.id;)++a;a===i.length?(i.push(1),r.push(h.id)):i[a]++}for(t=0;t<i.length;++t)this.vertices[r[t]].isBorder=1===i[t]}},t.prototype.updateMesh=function(e){var t,i,r,n;if(void 0===e&&(e=!1),!e){var o=[];for(t=0;t<this.triangles.length;++t)this.triangles[t].deleted||o.push(this.triangles[t]);this.triangles=o}for(t=0;t<this.vertices.length;++t)this.vertices[t].triangleCount=0,this.vertices[t].triangleStart=0;for(t=0;t<this.triangles.length;++t)for(i=this.triangles[t],r=0;3>r;++r)(n=i.vertices[r]).triangleCount++;var s=0;for(t=0;t<this.vertices.length;++t)this.vertices[t].triangleStart=s,s+=this.vertices[t].triangleCount,this.vertices[t].triangleCount=0;var h=new Array(3*this.triangles.length);for(t=0;t<this.triangles.length;++t)for(i=this.triangles[t],r=0;3>r;++r)h[(n=i.vertices[r]).triangleStart+n.triangleCount]=new a(r,t),n.triangleCount++;this.references=h,e&&this.identifyBorder()},t.prototype.vertexError=function(e,t){var i=t.x,r=t.y,n=t.z;return e.data[0]*i*i+2*e.data[1]*i*r+2*e.data[2]*i*n+2*e.data[3]*i+e.data[4]*r*r+2*e.data[5]*r*n+2*e.data[6]*r+e.data[7]*n*n+2*e.data[8]*n+e.data[9]},t.prototype.calculateError=function(t,i,r,n,o,s){var a=t.q.add(i.q),h=t.isBorder&&i.isBorder,c=0,l=a.det(0,1,2,1,4,5,2,5,7);if(0===l||h){var u=t.position.add(i.position).divide(new e.Vector3(2,2,2)),d=this.vertexError(a,t.position),f=this.vertexError(a,i.position),p=this.vertexError(a,u);(c=Math.min(d,f,p))===d?r&&r.copyFrom(t.position):c===f?r&&r.copyFrom(i.position):r&&r.copyFrom(u)}else r||(r=e.Vector3.Zero()),r.x=-1/l*a.det(1,2,3,4,5,6,5,7,8),r.y=1/l*a.det(0,2,3,1,5,6,2,7,8),r.z=-1/l*a.det(0,1,3,1,4,6,2,5,8),c=this.vertexError(a,r);return c},t}();e.QuadraticErrorSimplification=h}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t){this.SMOOTHING=.75,this.FFT_SIZE=512,this.BARGRAPHAMPLITUDE=256,this.DEBUGCANVASPOS={x:20,y:20},this.DEBUGCANVASSIZE={width:320,height:200},this._scene=t,this._audioEngine=e.Engine.audioEngine,this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser=this._audioEngine.audioContext.createAnalyser(),this._webAudioAnalyser.minDecibels=-140,this._webAudioAnalyser.maxDecibels=0,this._byteFreqs=new Uint8Array(this._webAudioAnalyser.frequencyBinCount),this._byteTime=new Uint8Array(this._webAudioAnalyser.frequencyBinCount),this._floatFreqs=new Float32Array(this._webAudioAnalyser.frequencyBinCount))}return t.prototype.getFrequencyBinCount=function(){return this._audioEngine.canUseWebAudio?this._webAudioAnalyser.frequencyBinCount:0},t.prototype.getByteFrequencyData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs)),this._byteFreqs},t.prototype.getByteTimeDomainData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getByteTimeDomainData(this._byteTime)),this._byteTime},t.prototype.getFloatFrequencyData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs)),this._floatFreqs},t.prototype.drawDebugCanvas=function(){var e=this;if(this._audioEngine.canUseWebAudio&&(this._debugCanvas||(this._debugCanvas=document.createElement("canvas"),this._debugCanvas.width=this.DEBUGCANVASSIZE.width,this._debugCanvas.height=this.DEBUGCANVASSIZE.height,this._debugCanvas.style.position="absolute",this._debugCanvas.style.top=this.DEBUGCANVASPOS.y+"px",this._debugCanvas.style.left=this.DEBUGCANVASPOS.x+"px",this._debugCanvasContext=this._debugCanvas.getContext("2d"),document.body.appendChild(this._debugCanvas),this._registerFunc=function(){e.drawDebugCanvas()},this._scene.registerBeforeRender(this._registerFunc)),this._registerFunc)){var t=this.getByteFrequencyData();this._debugCanvasContext.fillStyle="rgb(0, 0, 0)",this._debugCanvasContext.fillRect(0,0,this.DEBUGCANVASSIZE.width,this.DEBUGCANVASSIZE.height);for(var i=0;i<this.getFrequencyBinCount();i++){var r=t[i]/this.BARGRAPHAMPLITUDE,n=this.DEBUGCANVASSIZE.height*r,o=this.DEBUGCANVASSIZE.height-n-1,s=this.DEBUGCANVASSIZE.width/this.getFrequencyBinCount(),a=i/this.getFrequencyBinCount()*360;this._debugCanvasContext.fillStyle="hsl("+a+", 100%, 50%)",this._debugCanvasContext.fillRect(i*s,o,s,n)}}},t.prototype.stopDebugCanvas=function(){this._debugCanvas&&(this._scene.unregisterBeforeRender(this._registerFunc),this._registerFunc=null,document.body.removeChild(this._debugCanvas),this._debugCanvas=null,this._debugCanvasContext=null)},t.prototype.connectAudioNodes=function(e,t){this._audioEngine.canUseWebAudio&&(e.connect(this._webAudioAnalyser),this._webAudioAnalyser.connect(t))},t.prototype.dispose=function(){this._audioEngine.canUseWebAudio&&this._webAudioAnalyser.disconnect()},t}();e.Analyser=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t,i){var r=this;void 0===i&&(i=e.Engine.TEXTURETYPE_FLOAT),this._viewMatrix=e.Matrix.Zero(),this._projectionMatrix=e.Matrix.Zero(),this._transformMatrix=e.Matrix.Zero(),this._worldViewProjection=e.Matrix.Zero(),this._scene=t;var n=t.getEngine();this._depthMap=new e.RenderTargetTexture("depthMap",{width:n.getRenderWidth(),height:n.getRenderHeight()},this._scene,!1,!0,i),this._depthMap.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._depthMap.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._depthMap.refreshRate=1,this._depthMap.renderParticles=!1,this._depthMap.renderList=null,this._depthMap.onClear=function(t){t.clear(new e.Color4(1,1,1,1),!0,!0)};var o=function(t){var i=t.getRenderingMesh(),n=r._scene,o=n.getEngine();o.setState(t.getMaterial().backFaceCulling);var s=i._getInstancesRenderList(t._id);if(!s.mustReturn){var a=null!==o.getCaps().instancedArrays&&null!==s.visibleInstances[t._id];if(r.isReady(t,a)){o.enableEffect(r._effect),i._bind(t,r._effect,e.Material.TriangleFillMode);var h=t.getMaterial();if(r._effect.setMatrix("viewProjection",n.getTransformMatrix()),r._effect.setFloat("far",n.activeCamera.maxZ),h&&h.needAlphaTesting()){var c=h.getAlphaTestTexture();r._effect.setTexture("diffuseSampler",c),r._effect.setMatrix("diffuseMatrix",c.getTextureMatrix())}i.useBones&&i.computeBonesUsingShaders&&r._effect.setMatrices("mBones",i.skeleton.getTransformMatrices()),i._processRendering(t,r._effect,e.Material.TriangleFillMode,s,a,function(e,t){return r._effect.setMatrix("world",t)})}}};this._depthMap.customRenderFunction=function(e,t){var i;for(i=0;i<e.length;i++)o(e.data[i]);for(i=0;i<t.length;i++)o(t.data[i])}}return t.prototype.isReady=function(t,i){var r=[],n=[e.VertexBuffer.PositionKind],o=t.getMesh(),s=(o.getScene(),t.getMaterial());s&&s.needAlphaTesting()&&(r.push("#define ALPHATEST"),o.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.push(e.VertexBuffer.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(n.push(e.VertexBuffer.UV2Kind),r.push("#define UV2"))),o.useBones&&o.computeBonesUsingShaders&&(n.push(e.VertexBuffer.MatricesIndicesKind),n.push(e.VertexBuffer.MatricesWeightsKind),r.push("#define BONES"),r.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))),i&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var a=r.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("depth",n,["world","mBones","viewProjection","diffuseMatrix","far"],["diffuseSampler"],a)),this._effect.isReady()},t.prototype.getDepthMap=function(){return this._depthMap},t.prototype.dispose=function(){this._depthMap.dispose()},t}();e.DepthRenderer=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o){var s=this;t.call(this,r.getEngine(),i),this.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",this.SSAORenderEffect="SSAORenderEffect",this.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",this.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",this.SSAOCombineRenderEffect="SSAOCombineRenderEffect",this.totalStrength=1,this.radius=2e-4,this.area=.0075,this.fallOff=2e-4,this._firstUpdate=!0,this._scene=r,this._createRandomTexture(),this._depthTexture=r.enableDepthRenderer().getDepthMap();var a=n.ssaoRatio||n,h=n.combineRatio||n;this._originalColorPostProcess=new e.PassPostProcess("SSAOOriginalSceneColor",h,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1),this._createSSAOPostProcess(a),this._blurHPostProcess=new e.BlurPostProcess("SSAOBlurH",new e.Vector2(2,0),2,a,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1),this._blurVPostProcess=new e.BlurPostProcess("SSAOBlurV",new e.Vector2(0,2),2,a,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1),this._createSSAOCombinePostProcess(h),this.addEffect(new e.PostProcessRenderEffect(r.getEngine(),this.SSAOOriginalSceneColorEffect,function(){return s._originalColorPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(r.getEngine(),this.SSAORenderEffect,function(){return s._ssaoPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(r.getEngine(),this.SSAOBlurHRenderEffect,function(){return s._blurHPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(r.getEngine(),this.SSAOBlurVRenderEffect,function(){return s._blurVPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(r.getEngine(),this.SSAOCombineRenderEffect,function(){return s._ssaoCombinePostProcess},!0)),r.postProcessRenderPipelineManager.addPipeline(this),o&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,o)}return __extends(i,t),i.prototype.getBlurHPostProcess=function(){return this._blurHPostProcess},i.prototype.getBlurVPostProcess=function(){return this._blurVPostProcess},i.prototype.dispose=function(e){void 0===e&&(e=!1),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),this._originalColorPostProcess=void 0,this._ssaoPostProcess=void 0,this._blurHPostProcess=void 0,this._blurVPostProcess=void 0,this._ssaoCombinePostProcess=void 0,this._randomTexture.dispose(),e&&this._scene.disableDepthRenderer()},i.prototype._createSSAOPostProcess=function(t){var i=this,r=[.5381,.1856,-.4319,.1379,.2486,.443,.3371,.5679,-.0057,-.6999,-.0451,-.0019,.0689,-.1598,-.8547,.056,.0069,-.1843,-.0146,.1402,.0762,.01,-.1924,-.0344,-.3577,-.5301,-.4358,-.3169,.1063,.0158,.0103,-.5869,.0046,-.0897,-.494,.3287,.7119,-.0154,-.0918,-.0533,.0596,-.5411,.0352,-.0631,.546,-.4776,.2847,-.0271];this._ssaoPostProcess=new e.PostProcess("ssao","ssao",["sampleSphere","samplesFactor","randTextureTiles","totalStrength","radius","area","fallOff"],["randomSampler"],t,null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._ssaoPostProcess.onApply=function(e){i._firstUpdate&&(e.setArray3("sampleSphere",r),e.setFloat("samplesFactor",1/16),e.setFloat("randTextureTiles",4/t),i._firstUpdate=!1),e.setFloat("totalStrength",i.totalStrength),e.setFloat("radius",i.radius),e.setFloat("area",i.area),e.setFloat("fallOff",i.fallOff),e.setTexture("textureSampler",i._depthTexture),e.setTexture("randomSampler",i._randomTexture)}},i.prototype._createSSAOCombinePostProcess=function(t){var i=this;this._ssaoCombinePostProcess=new e.PostProcess("ssaoCombine","ssaoCombine",[],["originalColor"],t,null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._ssaoCombinePostProcess.onApply=function(e){e.setTextureFromPostProcess("originalColor",i._originalColorPostProcess)}},i.prototype._createRandomTexture=function(){this._randomTexture=new e.DynamicTexture("SSAORandomTexture",512,this._scene,!1,e.Texture.BILINEAR_SAMPLINGMODE),this._randomTexture.wrapU=e.Texture.WRAP_ADDRESSMODE,this._randomTexture.wrapV=e.Texture.WRAP_ADDRESSMODE;for(var t=this._randomTexture.getContext(),i=function(e,t){return Math.random()*(t-e)+e},r=0;512>r;r++)for(var n=0;512>n;n++){var o=e.Vector3.Zero();o.x=Math.floor(255*i(0,1)),o.y=Math.floor(255*i(0,1)),o.z=Math.floor(255*i(0,1)),t.fillStyle="rgb("+o.x+", "+o.y+", "+o.z+")",t.fillRect(r,n,1,1)}this._randomTexture.update(!1)},i}(e.PostProcessRenderPipeline);e.SSAORenderingPipeline=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(r,n,o,s,a,h,c,l,u){var d=this;void 0===a&&(a=100),void 0===h&&(h=e.Texture.BILINEAR_SAMPLINGMODE),t.call(this,r,"volumetricLightScattering",["decay","exposure","weight","meshPositionOnScreen","density"],["lightScatteringSampler"],n.postProcessRatio||n,o,h,c,l,"#define NUM_SAMPLES "+a),this._screenCoordinates=e.Vector2.Zero(),this.useCustomMeshPosition=!1,this.invert=!0,this.useDiffuseColor=!1,this.excludedMeshes=new Array,this.exposure=.3,this.decay=.96815,this.weight=.58767,this.density=.926,u=null===o?u:o.getScene(),this._viewPort=new e.Viewport(0,0,1,1).toGlobal(u.getEngine()),this.mesh=null!==s?s:i.CreateDefaultMesh("VolumetricLightScatteringMesh",u),this._createPass(u,n.passRatio||n),this.onApply=function(e){d._updateMeshScreenCoordinates(u),e.setTexture("lightScatteringSampler",d._volumetricLightScatteringRTT),e.setFloat("exposure",d.exposure),e.setFloat("decay",d.decay),e.setFloat("weight",d.weight),e.setFloat("density",d.density),e.setVector2("meshPositionOnScreen",d._screenCoordinates)}}return __extends(i,t),i.prototype.isReady=function(t,i){var r=t.getMesh(),n=[],o=[e.VertexBuffer.PositionKind],s=t.getMaterial(),a=!1;r===this.mesh&&(this.useDiffuseColor?n.push("#define DIFFUSE_COLOR_RENDER"):s&&n.push(void 0!==s.diffuseTexture?"#define BASIC_RENDER":"#define DIFFUSE_COLOR_RENDER"),n.push("#define NEED_UV"),a=!0),s&&(s.needAlphaTesting()&&n.push("#define ALPHATEST"),void 0!==s.opacityTexture&&(n.push("#define OPACITY"),s.opacityTexture.getAlphaFromRGB&&n.push("#define OPACITYRGB"),a||n.push("#define NEED_UV")),r.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(o.push(e.VertexBuffer.UVKind),n.push("#define UV1")),r.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(o.push(e.VertexBuffer.UV2Kind),n.push("#define UV2"))),r.useBones&&r.computeBonesUsingShaders&&(o.push(e.VertexBuffer.MatricesIndicesKind),o.push(e.VertexBuffer.MatricesWeightsKind),n.push("#define BONES"),n.push("#define BonesPerMesh "+(r.skeleton.bones.length+1))),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var h=n.join("\n");return this._cachedDefines!==h&&(this._cachedDefines=h,this._volumetricLightScatteringPass=r.getScene().getEngine().createEffect({vertexElement:"depth",fragmentElement:"volumetricLightScatteringPass"},o,["world","mBones","viewProjection","diffuseMatrix","opacityLevel","color"],["diffuseSampler","opacitySampler"],h)),this._volumetricLightScatteringPass.isReady()},i.prototype.setCustomMeshPosition=function(e){this._customMeshPosition=e},i.prototype.getCustomMeshPosition=function(){return this._customMeshPosition},i.prototype.dispose=function(e){var i=e.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);-1!==i&&e.getScene().customRenderTargets.splice(i,1),this._volumetricLightScatteringRTT.dispose(),t.prototype.dispose.call(this,e)},i.prototype.getPass=function(){return this._volumetricLightScatteringRTT},i.prototype._meshExcluded=function(e){return this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e)},i.prototype._createPass=function(t,i){var r=this,n=t.getEngine();this._volumetricLightScatteringRTT=new e.RenderTargetTexture("volumetricLightScatteringMap",{width:n.getRenderWidth()*i,height:n.getRenderHeight()*i},t,!1,!0,e.Engine.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.renderList=null,this._volumetricLightScatteringRTT.renderParticles=!1,t.customRenderTargets.push(this._volumetricLightScatteringRTT);var o,s=function(t){var i=t.getRenderingMesh();if(!r._meshExcluded(i)){var n=i.getScene(),o=n.getEngine();o.setState(t.getMaterial().backFaceCulling);var s=i._getInstancesRenderList(t._id);if(!s.mustReturn){var a=null!==o.getCaps().instancedArrays&&null!==s.visibleInstances[t._id];if(r.isReady(t,a)){o.enableEffect(r._volumetricLightScatteringPass),i._bind(t,r._volumetricLightScatteringPass,e.Material.TriangleFillMode);var h=t.getMaterial();if(r._volumetricLightScatteringPass.setMatrix("viewProjection",n.getTransformMatrix()),h&&(i===r.mesh||h.needAlphaTesting()||void 0!==h.opacityTexture)){var c=h.getAlphaTestTexture();!r.useDiffuseColor&&void 0!==c||i!==r.mesh||r._volumetricLightScatteringPass.setColor3("color",h.diffuseColor),(h.needAlphaTesting()||i===r.mesh&&c&&!r.useDiffuseColor)&&(r._volumetricLightScatteringPass.setTexture("diffuseSampler",c),c&&r._volumetricLightScatteringPass.setMatrix("diffuseMatrix",c.getTextureMatrix())),void 0!==h.opacityTexture&&(r._volumetricLightScatteringPass.setTexture("opacitySampler",h.opacityTexture),r._volumetricLightScatteringPass.setFloat("opacityLevel",h.opacityTexture.level))}i.useBones&&i.computeBonesUsingShaders&&r._volumetricLightScatteringPass.setMatrices("mBones",i.skeleton.getTransformMatrices()),i._processRendering(t,r._volumetricLightScatteringPass,e.Material.TriangleFillMode,s,a,function(e,t){return r._volumetricLightScatteringPass.setMatrix("world",t)})}}}},a=new e.Color4(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRender=function(){o=t.clearColor,t.clearColor=a},this._volumetricLightScatteringRTT.onAfterRender=function(){t.clearColor=o},this._volumetricLightScatteringRTT.customRenderFunction=function(i,r,n){var o,a=t.getEngine();for(o=0;o<i.length;o++)s(i.data[o]);for(a.setAlphaTesting(!0),o=0;o<r.length;o++)s(r.data[o]);if(a.setAlphaTesting(!1),n.length){for(o=0;o<n.length;o++){var h=n.data[o];h._alphaIndex=h.getMesh().alphaIndex,h._distanceToCamera=h.getBoundingInfo().boundingSphere.centerWorld.subtract(t.activeCamera.position).length()}var c=n.data.slice(0,n.length);for(c.sort(function(e,t){return e._alphaIndex>t._alphaIndex?1:e._alphaIndex<t._alphaIndex?-1:e._distanceToCamera<t._distanceToCamera?1:e._distanceToCamera>t._distanceToCamera?-1:0}),a.setAlphaMode(e.Engine.ALPHA_COMBINE),o=0;o<c.length;o++)s(c[o]);a.setAlphaMode(e.Engine.ALPHA_DISABLE)}}},i.prototype._updateMeshScreenCoordinates=function(t){var i=t.getTransformMatrix(),r=e.Vector3.Project(this.useCustomMeshPosition?this._customMeshPosition:this.mesh.position,e.Matrix.Identity(),i,this._viewPort);this._screenCoordinates.x=r.x/this._viewPort.width,this._screenCoordinates.y=r.y/this._viewPort.height,this.invert&&(this._screenCoordinates.y=1-this._screenCoordinates.y)},i.CreateDefaultMesh=function(t,i){var r=e.Mesh.CreatePlane(t,1,i);return r.billboardMode=e.AbstractMesh.BILLBOARDMODE_ALL,r.material=new e.StandardMaterial(t+"Material",i),r},i}(e.PostProcess);e.VolumetricLightScatteringPostProcess=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o,s){var a=this;void 0===o&&(o=1),t.call(this,n.getEngine(),i),this.LensChromaticAberrationEffect="LensChromaticAberrationEffect",this.HighlightsEnhancingEffect="HighlightsEnhancingEffect",this.LensDepthOfFieldEffect="LensDepthOfFieldEffect",this._scene=n,this._depthTexture=n.enableDepthRenderer().getDepthMap(),r.grain_texture?this._grainTexture=r.grain_texture:this._createGrainTexture(),this._edgeBlur=r.edge_blur?r.edge_blur:0,this._grainAmount=r.grain_amount?r.grain_amount:0,this._chromaticAberration=r.chromatic_aberration?r.chromatic_aberration:0,this._distortion=r.distortion?r.distortion:0,this._highlightsGain=void 0!==r.dof_gain?r.dof_gain:-1,this._highlightsThreshold=r.dof_threshold?r.dof_threshold:1,this._dofDistance=void 0!==r.dof_focus_distance?r.dof_focus_distance:-1,this._dofAperture=r.dof_aperture?r.dof_aperture:1,this._dofDarken=r.dof_darken?r.dof_darken:0,this._dofPentagon=void 0===r.dof_pentagon||r.dof_pentagon,this._blurNoise=void 0===r.blur_noise||r.blur_noise,this._createChromaticAberrationPostProcess(o),this._createHighlightsPostProcess(o),this._createDepthOfFieldPostProcess(o/4),this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),this.LensChromaticAberrationEffect,function(){return a._chromaticAberrationPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),this.HighlightsEnhancingEffect,function(){return a._highlightsPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),this.LensDepthOfFieldEffect,function(){return a._depthOfFieldPostProcess},!0)),-1==this._highlightsGain&&this._disableEffect(this.HighlightsEnhancingEffect,null),n.postProcessRenderPipelineManager.addPipeline(this),s&&n.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,s)}return __extends(i,t),i.prototype.setEdgeBlur=function(e){this._edgeBlur=e},i.prototype.disableEdgeBlur=function(){this._edgeBlur=0},i.prototype.setGrainAmount=function(e){this._grainAmount=e},i.prototype.disableGrain=function(){this._grainAmount=0},i.prototype.setChromaticAberration=function(e){this._chromaticAberration=e},i.prototype.disableChromaticAberration=function(){this._chromaticAberration=0},i.prototype.setEdgeDistortion=function(e){this._distortion=e},i.prototype.disableEdgeDistortion=function(){this._distortion=0},i.prototype.setFocusDistance=function(e){this._dofDistance=e},i.prototype.disableDepthOfField=function(){this._dofDistance=-1},i.prototype.setAperture=function(e){this._dofAperture=e},i.prototype.setDarkenOutOfFocus=function(e){this._dofDarken=e},i.prototype.enablePentagonBokeh=function(){this._dofPentagon=!0},i.prototype.disablePentagonBokeh=function(){this._dofPentagon=!1},i.prototype.enableNoiseBlur=function(){this._blurNoise=!0},i.prototype.disableNoiseBlur=function(){this._blurNoise=!1},i.prototype.setHighlightsGain=function(e){this._highlightsGain=e},i.prototype.setHighlightsThreshold=function(e){-1==this._highlightsGain&&(this._highlightsGain=1),this._highlightsThreshold=e},i.prototype.disableHighlights=function(){this._highlightsGain=-1},i.prototype.dispose=function(e){void 0===e&&(e=!1),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),this._chromaticAberrationPostProcess=void 0,this._highlightsPostProcess=void 0,this._depthOfFieldPostProcess=void 0,this._grainTexture.dispose(),e&&this._scene.disableDepthRenderer()},i.prototype._createChromaticAberrationPostProcess=function(t){var i=this;this._chromaticAberrationPostProcess=new e.PostProcess("LensChromaticAberration","chromaticAberration",["chromatic_aberration","screen_width","screen_height"],[],t,null,e.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._chromaticAberrationPostProcess.onApply=function(e){e.setFloat("chromatic_aberration",i._chromaticAberration),e.setFloat("screen_width",i._scene.getEngine().getRenderingCanvas().width),e.setFloat("screen_height",i._scene.getEngine().getRenderingCanvas().height)}},i.prototype._createHighlightsPostProcess=function(t){var i=this;this._highlightsPostProcess=new e.PostProcess("LensHighlights","lensHighlights",["pentagon","gain","threshold","screen_width","screen_height"],[],t,null,e.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._highlightsPostProcess.onApply=function(e){e.setFloat("gain",i._highlightsGain),e.setFloat("threshold",i._highlightsThreshold),e.setBool("pentagon",i._dofPentagon),e.setTextureFromPostProcess("textureSampler",i._chromaticAberrationPostProcess),e.setFloat("screen_width",i._scene.getEngine().getRenderingCanvas().width),e.setFloat("screen_height",i._scene.getEngine().getRenderingCanvas().height)}},i.prototype._createDepthOfFieldPostProcess=function(t){var i=this;this._depthOfFieldPostProcess=new e.PostProcess("LensDepthOfField","depthOfField",["grain_amount","blur_noise","screen_width","screen_height","distortion","dof_enabled","screen_distance","aperture","darken","edge_blur","highlights","near","far"],["depthSampler","grainSampler","highlightsSampler"],t,null,e.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._depthOfFieldPostProcess.onApply=function(e){e.setTexture("depthSampler",i._depthTexture),e.setTexture("grainSampler",i._grainTexture),e.setTextureFromPostProcess("textureSampler",i._highlightsPostProcess),e.setTextureFromPostProcess("highlightsSampler",i._depthOfFieldPostProcess),e.setFloat("grain_amount",i._grainAmount),e.setBool("blur_noise",i._blurNoise),e.setFloat("screen_width",i._scene.getEngine().getRenderingCanvas().width),e.setFloat("screen_height",i._scene.getEngine().getRenderingCanvas().height),e.setFloat("distortion",i._distortion),e.setBool("dof_enabled",-1!=i._dofDistance),e.setFloat("screen_distance",1/(.1-1/i._dofDistance)),e.setFloat("aperture",i._dofAperture),e.setFloat("darken",i._dofDarken),e.setFloat("edge_blur",i._edgeBlur),e.setBool("highlights",-1!=i._highlightsGain),e.setFloat("near",i._scene.activeCamera.minZ),e.setFloat("far",i._scene.activeCamera.maxZ)}},i.prototype._createGrainTexture=function(){this._grainTexture=new e.DynamicTexture("LensNoiseTexture",512,this._scene,!1,e.Texture.BILINEAR_SAMPLINGMODE),this._grainTexture.wrapU=e.Texture.WRAP_ADDRESSMODE,this._grainTexture.wrapV=e.Texture.WRAP_ADDRESSMODE;for(var t,i=this._grainTexture.getContext(),r=function(e,t){return Math.random()*(t-e)+e},n=0;512>n;n++)for(var o=0;512>o;o++)t=Math.floor(255*r(.42,.58)),i.fillStyle="rgb("+t+", "+t+", "+t+")",i.fillRect(n,o,1,1);this._grainTexture.update(!1)},i}(e.PostProcessRenderPipeline);e.LensRenderingPipeline=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o,s,a,h){var c=this;t.call(this,i,"colorCorrection",null,["colorTable"],n,o,s,a,h),this._colorTableTexture=new e.Texture(r,o.getScene(),!0,!1,e.Texture.TRILINEAR_SAMPLINGMODE),this._colorTableTexture.anisotropicFilteringLevel=1,this._colorTableTexture.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._colorTableTexture.wrapV=e.Texture.CLAMP_ADDRESSMODE,this.onApply=function(e){e.setTexture("colorTable",c._colorTableTexture)}}return __extends(i,t),i}(e.PostProcess);e.ColorCorrectionPostProcess=t}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(i,r,n,o){t.call(this,i,r,o),this.setCameraRigMode(e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:n})}return __extends(i,t),i}(e.FreeCamera);e.AnaglyphFreeCamera=t;var i=function(t){function i(i,r,n,o,s,a,h){t.call(this,i,r,n,o,s,h),this.setCameraRigMode(e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:a})}return __extends(i,t),i}(e.ArcRotateCamera);e.AnaglyphArcRotateCamera=i;var r=function(t){function i(i,r,n,o){t.call(this,i,r,o),this.setCameraRigMode(e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:n})}return __extends(i,t),i}(e.GamepadCamera);e.AnaglyphGamepadCamera=r;var n=function(t){function i(i,r,n,o,s){t.call(this,i,r,s),this.setCameraRigMode(o?e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:n})}return __extends(i,t),i}(e.FreeCamera);e.StereoscopicFreeCamera=n;var o=function(t){function i(i,r,n,o,s,a,h,c){t.call(this,i,r,n,o,s,c),this.setCameraRigMode(h?e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:a})}return __extends(i,t),i}(e.ArcRotateCamera);e.StereoscopicArcRotateCamera=o;var s=function(t){function i(i,r,n,o,s){t.call(this,i,r,s),this.setCameraRigMode(o?e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:n})}return __extends(i,t),i}(e.GamepadCamera);e.StereoscopicGamepadCamera=s}(BABYLON||(BABYLON={})),function(e){var t=function(t){function i(r,n,o,s,a){var h=this;void 0===s&&(s=null),t.call(this,n.getEngine(),r),this.gaussCoeff=.3,this.gaussMean=1,this.gaussStandDev=.8,this.exposure=1,this.minimumLuminance=1,this.maximumLuminance=1e20,this.luminanceIncreaserate=.5,this.luminanceDecreaseRate=.5,this.brightThreshold=.8,this._needUpdate=!0,this._scene=n,this._createBrightPassPostProcess(n,o),this._createDownSampleX4PostProcess(n,o),this._createGaussianBlurPostProcess(n,o),this._createTextureAdderPostProcess(n,o),this._createLuminanceGeneratorPostProcess(n),this._createHDRPostProcess(n,o),this._originalPostProcess=null===s?new e.PassPostProcess("hdr",o,null,e.Texture.BILINEAR_SAMPLINGMODE,n.getEngine(),!1):s,this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDRPassPostProcess",function(){return h._originalPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDRBrightPass",function(){return h._brightPassPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDRDownSampleX4",function(){return h._downSampleX4PostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDRGaussianBlurH",function(){return h._guassianBlurHPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDRGaussianBlurV",function(){return h._guassianBlurVPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDRTextureAdder",function(){return h._textureAdderPostProcess},!0));for(var c=function(t){h.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDRDownSampler"+t,function(){return h._downSamplePostProcesses[t]},!0))},l=i.LUM_STEPS-1;l>=0;l--)c(l);this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDR",function(){return h._hdrPostProcess},!0)),n.postProcessRenderPipelineManager.addPipeline(this),null!==a&&n.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(r,a),this.update()}return __extends(i,t),i.prototype.update=function(){this._needUpdate=!0},i.prototype.getCurrentLuminance=function(){return this._hdrCurrentLuminance},i.prototype.getOutputLuminance=function(){return this._hdrOutputLuminance},i.prototype.dispose=function(){this._originalPostProcess=void 0,this._brightPassPostProcess=void 0,this._downSampleX4PostProcess=void 0,this._guassianBlurHPostProcess=void 0,this._guassianBlurVPostProcess=void 0,this._textureAdderPostProcess=void 0;for(var e=i.LUM_STEPS-1;e>=0;e--)this._downSamplePostProcesses[e]=void 0;this._hdrPostProcess=void 0,this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras)},i.prototype._createHDRPostProcess=function(t,i){var r=this,n=0;this._hdrOutputLuminance=-1,this._hdrCurrentLuminance=1,this._hdrPostProcess=new e.PostProcess("hdr","hdr",["exposure","avgLuminance"],["otherSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define HDR"),this._hdrPostProcess.onApply=function(i){if(r._hdrOutputLuminance<0)r._hdrOutputLuminance=r._hdrCurrentLuminance;else{var o=(n-(n+t.getEngine().getDeltaTime()))/1e3;r._hdrCurrentLuminance<r._hdrOutputLuminance+r.luminanceDecreaseRate*o?r._hdrOutputLuminance+=r.luminanceDecreaseRate*o:r._hdrCurrentLuminance>r._hdrOutputLuminance-r.luminanceIncreaserate*o?r._hdrOutputLuminance-=r.luminanceIncreaserate*o:r._hdrOutputLuminance=r._hdrCurrentLuminance}r._hdrOutputLuminance=e.Tools.Clamp(r._hdrOutputLuminance,r.minimumLuminance,r.maximumLuminance),n+=t.getEngine().getDeltaTime(),i.setTextureFromPostProcess("textureSampler",r._textureAdderPostProcess),i.setTextureFromPostProcess("otherSampler",r._originalPostProcess),i.setFloat("exposure",r.exposure),i.setFloat("avgLuminance",r._hdrOutputLuminance),r._needUpdate=!1}},i.prototype._createTextureAdderPostProcess=function(t,i){var r=this;this._textureAdderPostProcess=new e.PostProcess("hdr","hdr",[],["otherSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define TEXTURE_ADDER"),this._textureAdderPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",r._originalPostProcess)}},i.prototype._createDownSampleX4PostProcess=function(t,i){var r=this,n=new Array(32);this._downSampleX4PostProcess=new e.PostProcess("hdr","hdr",["dsOffsets"],[],i/4,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define DOWN_SAMPLE_X4"),this._downSampleX4PostProcess.onApply=function(e){if(r._needUpdate)for(var t=0,i=-2;2>i;i++)for(var o=-2;2>o;o++)n[t]=(i+.5)*(1/r._downSampleX4PostProcess.width),n[t+1]=(o+.5)*(1/r._downSampleX4PostProcess.height),t+=2;e.setArray2("dsOffsets",n)}},i.prototype._createBrightPassPostProcess=function(t,i){var r=this,n=new Array(8);this._brightPassPostProcess=new e.PostProcess("hdr","hdr",["dsOffsets","brightThreshold"],[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define BRIGHT_PASS"),this._brightPassPostProcess.onApply=function(e){if(r._needUpdate){var t=1/r._brightPassPostProcess.width,i=1/r._brightPassPostProcess.height;n[0]=-.5*t,n[1]=.5*i,n[2]=.5*t,n[3]=.5*i,n[4]=-.5*t,n[5]=-.5*i,n[6]=.5*t,n[7]=-.5*i}e.setArray2("dsOffsets",n),e.setFloat("brightThreshold",r.brightThreshold)}},i.prototype._createLuminanceGeneratorPostProcess=function(t){var r,n=this,o=i.LUM_STEPS,s=new Array(8),a=new Array(18);this._downSamplePostProcesses=new Array(o);var h=function(e,t){var i=1/e,r=1/t;s[0]=-.5*i,s[1]=.5*r,s[2]=.5*i,s[3]=.5*r,s[4]=-.5*i,s[5]=-.5*r,s[6]=.5*i,s[7]=-.5*r},c=function(e){var t=e;return function(e){h(n._downSamplePostProcesses[t].width,n._downSamplePostProcesses[t].height),function(e,t){for(var i=0,r=-1;2>r;r++)for(var n=-1;2>n;n++)a[i]=r/e,a[i+1]=n/t,i+=2}(n._downSamplePostProcesses[t].width,n._downSamplePostProcesses[t].height),r=.5/n._downSamplePostProcesses[t].width,e.setTextureFromPostProcess("textureSampler",n._downSamplePostProcesses[t+1]),e.setFloat("halfDestPixelSize",r),e.setArray2("dsOffsets",a)}},l=function(i){var r=t.getEngine().readPixels(0,0,1,1),o=new e.Vector4(1/16581375,1/65025,1/255,1);n._hdrCurrentLuminance=(r[0]*o.x+r[1]*o.y+r[2]*o.z+r[3]*o.w)/100},u={width:Math.pow(3,o-1),height:Math.pow(3,o-1)};this._downSamplePostProcesses[o-1]=new e.PostProcess("hdr","hdr",["lumOffsets"],[],u,null,e.Texture.NEAREST_SAMPLINGMODE,t.getEngine(),!1,"#define LUMINANCE_GENERATOR",e.Engine.TEXTURETYPE_FLOAT),this._downSamplePostProcesses[o-1].onApply=function(e){n._needUpdate&&h(n._textureAdderPostProcess.width,n._textureAdderPostProcess.height),e.setTextureFromPostProcess("textureSampler",n._textureAdderPostProcess),e.setArray2("lumOffsets",s)};for(var d=o-2;d>=0;d--){var f=Math.pow(3,d);u={width:f,height:f};var p="#define DOWN_SAMPLE\n";0===d&&(p+="#define FINAL_DOWN_SAMPLE\n"),this._downSamplePostProcesses[d]=new e.PostProcess("hdr","hdr",["dsOffsets","halfDestPixelSize"],[],u,null,e.Texture.NEAREST_SAMPLINGMODE,t.getEngine(),!1,p,e.Engine.TEXTURETYPE_FLOAT),this._downSamplePostProcesses[d].onApply=c(d),0===d&&(this._downSamplePostProcesses[d].onAfterRender=l)}},i.prototype._createGaussianBlurPostProcess=function(t,i){var r=this,n=new Array(9),o=new Array(9),s=new Array(9),a=["blurOffsets","blurWeights"],h=function(e){for(var r={width:t.getEngine().getRenderWidth()*(i/4),height:t.getEngine().getRenderHeight()*(i/4)},s=0;9>s;s++){var a=1/(!0===e?r.height:r.width)*(s-4);e?o[s]=a:n[s]=a}},c=function(e){return function(t){r._needUpdate&&(function(){for(var e=0,t=0;9>t;t++)e=(t-4)/4,s[t]=r.gaussCoeff*(1/Math.sqrt(2*Math.PI*r.gaussStandDev))*Math.exp(-(e-r.gaussMean)*(e-r.gaussMean)/(2*r.gaussStandDev*r.gaussStandDev))}(),h(e)),t.setArray("blurOffsets",e?o:n),t.setArray("blurWeights",s)}};this._guassianBlurHPostProcess=new e.PostProcess("hdr","hdr",a,[],i/4,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define GAUSSIAN_BLUR_H"),this._guassianBlurHPostProcess.onApply=c(!1),this._guassianBlurVPostProcess=new e.PostProcess("hdr","hdr",a,[],i/4,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define GAUSSIAN_BLUR_V"),this._guassianBlurVPostProcess.onApply=c(!0)},i.LUM_STEPS=6,i}(e.PostProcessRenderPipeline);e.HDRRenderingPipeline=t}(BABYLON||(BABYLON={})),function(e){var t=function(){return function(){this.edges=new Array,this.edgesConnectedCount=0}}(),i=function(){function i(e,t,i){void 0===t&&(t=.95),void 0===i&&(i=!1),this._linesPositions=new Array,this._linesNormals=new Array,this._linesIndices=new Array,this._buffers=new Array,this._checkVerticesInsteadOfIndices=!1,this._source=e,this._checkVerticesInsteadOfIndices=i,this._epsilon=t,this._prepareRessources(),this._generateEdgesLines()}return i.prototype._prepareRessources=function(){this._lineShader||(this._lineShader=new e.ShaderMaterial("lineShader",this._source.getScene(),"line",{attributes:["position","normal"],uniforms:["worldViewProjection","color","width","aspectRatio"]}),this._lineShader.disableDepthWrite=!0,this._lineShader.backFaceCulling=!1)},i.prototype.dispose=function(){this._vb0.dispose(),this._vb1.dispose(),this._source.getScene().getEngine()._releaseBuffer(this._ib),this._lineShader.dispose()},i.prototype._processEdgeForAdjacencies=function(e,t,i,r,n){return e===i&&t===r||e===r&&t===i?0:e===r&&t===n||e===n&&t===r?1:e===n&&t===i||e===i&&t===n?2:-1},i.prototype._processEdgeForAdjacenciesWithVertices=function(e,t,i,r,n){return e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(r)||e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(i)?0:e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(n)||e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(r)?1:e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(i)||e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(n)?2:-1},i.prototype._checkEdge=function(t,i,r,n,o){var s;void 0===i?s=!0:s=e.Vector3.Dot(r[t],r[i])<this._epsilon;if(s){var a=this._linesPositions.length/3;n.subtract(o).normalize(),this._linesPositions.push(n.x),this._linesPositions.push(n.y),this._linesPositions.push(n.z),this._linesPositions.push(n.x),this._linesPositions.push(n.y),this._linesPositions.push(n.z),this._linesPositions.push(o.x),this._linesPositions.push(o.y),this._linesPositions.push(o.z),this._linesPositions.push(o.x),this._linesPositions.push(o.y),this._linesPositions.push(o.z),this._linesNormals.push(o.x),this._linesNormals.push(o.y),this._linesNormals.push(o.z),this._linesNormals.push(-1),this._linesNormals.push(o.x),this._linesNormals.push(o.y),this._linesNormals.push(o.z),this._linesNormals.push(1),this._linesNormals.push(n.x),this._linesNormals.push(n.y),this._linesNormals.push(n.z),this._linesNormals.push(-1),this._linesNormals.push(n.x),this._linesNormals.push(n.y),this._linesNormals.push(n.z),this._linesNormals.push(1),this._linesIndices.push(a),this._linesIndices.push(a+1),this._linesIndices.push(a+2),this._linesIndices.push(a),this._linesIndices.push(a+2),this._linesIndices.push(a+3)}},i.prototype._generateEdgesLines=function(){var i,r,n=this._source.getVerticesData(e.VertexBuffer.PositionKind),o=this._source.getIndices(),s=new Array,a=new Array;for(i=0;i<o.length;i+=3){r=new t;var h=o[i],c=o[i+1],l=o[i+2];r.p0=new e.Vector3(n[3*h],n[3*h+1],n[3*h+2]),r.p1=new e.Vector3(n[3*c],n[3*c+1],n[3*c+2]),r.p2=new e.Vector3(n[3*l],n[3*l+1],n[3*l+2]);var u=e.Vector3.Cross(r.p1.subtract(r.p0),r.p2.subtract(r.p1));u.normalize(),a.push(u),s.push(r)}for(i=0;i<s.length;i++){r=s[i];for(var d=i+1;d<s.length;d++){var f=s[d];if(3===r.edgesConnectedCount)break;if(3!==f.edgesConnectedCount)for(var p=o[3*d],m=o[3*d+1],g=o[3*d+2],v=0;3>v;v++){var _;if(void 0===r.edges[v]){switch(v){case 0:_=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(r.p0,r.p1,f.p0,f.p1,f.p2):this._processEdgeForAdjacencies(o[3*i],o[3*i+1],p,m,g);break;case 1:_=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(r.p1,r.p2,f.p0,f.p1,f.p2):this._processEdgeForAdjacencies(o[3*i+1],o[3*i+2],p,m,g);break;case 2:_=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(r.p2,r.p0,f.p0,f.p1,f.p2):this._processEdgeForAdjacencies(o[3*i+2],o[3*i],p,m,g)}if(-1!==_&&(r.edges[v]=d,f.edges[_]=i,r.edgesConnectedCount++,f.edgesConnectedCount++,3===r.edgesConnectedCount))break}}}}for(i=0;i<s.length;i++){var y=s[i];this._checkEdge(i,y.edges[0],a,y.p0,y.p1),this._checkEdge(i,y.edges[1],a,y.p1,y.p2),this._checkEdge(i,y.edges[2],a,y.p2,y.p0)}var x=this._source.getScene().getEngine();this._vb0=new e.VertexBuffer(x,this._linesPositions,e.VertexBuffer.PositionKind,!1),this._vb1=new e.VertexBuffer(x,this._linesNormals,e.VertexBuffer.NormalKind,!1,!1,4),this._buffers[e.VertexBuffer.PositionKind]=this._vb0,this._buffers[e.VertexBuffer.NormalKind]=this._vb1,this._ib=x.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length},i.prototype.render=function(){if(this._lineShader.isReady()){var e=this._source.getScene(),t=e.getEngine();this._lineShader._preBind(),t.bindMultiBuffers(this._buffers,this._ib,this._lineShader.getEffect()),e.resetCachedMaterial(),this._lineShader.setColor4("color",this._source.edgesColor),this._lineShader.setFloat("width",this._source.edgesWidth/50),this._lineShader.setFloat("aspectRatio",t.getAspectRatio(e.activeCamera)),this._lineShader.bind(this._source.getWorldMatrix()),t.draw(!0,0,this._indicesCount),this._lineShader.unbind(),t.setDepthWrite(!0)}},i}();e.EdgesRenderer=i}(BABYLON||(BABYLON={})),function(e){!function(e){e[e.Hable=0]="Hable",e[e.Reinhard=1]="Reinhard",e[e.HejiDawson=2]="HejiDawson",e[e.Photographic=3]="Photographic"}(e.TonemappingOperator||(e.TonemappingOperator={}));var t=e.TonemappingOperator,i=function(i){function r(r,n,o,s,a,h,c){var l=this;void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===c&&(c=e.Engine.TEXTURETYPE_UNSIGNED_INT),this._operator=n,this._exposureAdjustment=o;var u="#define ";n===t.Hable?u+="HABLE_TONEMAPPING":n===t.Reinhard?u+="REINHARD_TONEMAPPING":n===t.HejiDawson?u+="OPTIMIZED_HEJIDAWSON_TONEMAPPING":n===t.Photographic&&(u+="PHOTOGRAPHIC_TONEMAPPING"),i.call(this,r,"tonemap",["_ExposureAdjustment"],null,1,s,a,h,!0,u,c),this.onApply=function(e){e.setFloat("_ExposureAdjustment",l._exposureAdjustment)}}return __extends(r,i),r}(e.PostProcess);e.TonemapPostProcess=i}(BABYLON||(BABYLON={})),function(e){var t=function(){function e(e,t,i){var r=this;void 0===t&&(t=""),void 0===i&&(i="black"),this._renderingCanvas=e,this._loadingText=t,this._loadingDivBackgroundColor=i,this._resizeLoadingUI=function(){var e=r._renderingCanvas.getBoundingClientRect();r._loadingDiv.style.position="absolute",r._loadingDiv.style.left=e.left+"px",r._loadingDiv.style.top=e.top+"px",r._loadingDiv.style.width=e.width+"px",r._loadingDiv.style.height=e.height+"px"}}return e.prototype.displayLoadingUI=function(){var e=this;this._loadingDiv=document.createElement("div"),this._loadingDiv.style.opacity="0",this._loadingDiv.style.transition="opacity 1.5s ease",this._loadingTextDiv=document.createElement("div"),this._loadingTextDiv.style.position="absolute",this._loadingTextDiv.style.left="0",this._loadingTextDiv.style.top="50%",this._loadingTextDiv.style.marginTop="80px",this._loadingTextDiv.style.width="100%",this._loadingTextDiv.style.height="20px",this._loadingTextDiv.style.fontFamily="Arial",this._loadingTextDiv.style.fontSize="14px",this._loadingTextDiv.style.color="white",this._loadingTextDiv.style.textAlign="center",this._loadingTextDiv.innerHTML="Loading",this._loadingDiv.appendChild(this._loadingTextDiv),this._loadingTextDiv.innerHTML=this._loadingText;var t=new Image;t.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuM4zml1AAAARbSURBVHhe7Z09aFNRFMc716kuLrq4FdyLq4Wi4CAoRQcR0UJBUBdRiuLSIYMo6CA4FF2sgw6CFAdFUOpSQYcWO4hD26UQCfXrIQrx/JJzw1OSWq3NPeL/B4Fy+0jg/HO+7j3vpUcI8b/Q39+/49ihfWdPHT94Yf/e3Se3bd263f8lus218TPn6vV6Ya8Wi/MzNRNmj18iusX9W1evmP1/EKNEIVG6CMbG6E3bt+fT++pHha8NoHdT72bLE8NDg7tGU64gLLndV4Wc4m8j/pS+vr4tGB/DT16v3Fyr8dvBe/jbit8BL0AES9LX1iPAz+BR/hFiLVCynj95dPzNy6fv3IZ/k4L3948Sq7FzYGBg4vLFGxitabuOFCbWNKGrMnbiUuo18KaV6tIHv6YtvL9/nOgE31jCktmrY7k6+/zhE4yP4Vf7hiNqh/BWWEl8mzDol4p22Lf7cIdvdUMEvv0Y2S9fE5S1hLzpqTsPkiep//gFGPnR3Yl7GL5p/xYFBrTwM+iXio3GqpwDGL5p/xYNIX7XG8Q6IJRgdIzf1KBBgafII7oMidhyQtVFaMA2Bt7il4huQRhaXphbcR2g4RXqBzKAGHiCCwGFVUAj/m/RTRDj29cvn10I0PZ3LghH5f4CL1EFlQmqqXK3jDDKFxmhQ3Yt6oQseUZGKmMnTpsOqc8o1F9kBOMjQlOLeqEeIyOc6JV6jYLJD/+XyIFvnzdgl9aXRQ5I2qZDK1SpospMqaoqON/wZZGDciLnMMiXRS7IF4hhqMTNTdk7CFu+LHLhR7BQqBvPDJUUQqCGvCMATHUgBmhWNgApmdOda9YpM+VwRYfuyyIXDK8hBlilNerLIheMZCKGwlUAyru6GlwOgPUbRxADdJ9FAChxXY864viyyEXqPxhc0M2TAfAbatSdRyHtXymhByEdRnE3ky+JnHAIhSA0h74kckETmHoQbSgGwJrCIRMEPSRIBCRIMAhZaYhaggQhJXUJEoRU9mofKwh+F22dLRRfEjlJM7w6KQwCoQpBOKTyJZETjmwRxKqtGV8SOSkNOGjKPQppBEgDDkFgpxdBVGkFgaYQQXRIFQSObk0P5ZFIpAZRHXsQ0r0hCluBWKkuvVbYCkQaCdL5ehBScudJP4yY+rLISdps1NBDEJKXMMmoSfggWC4ZQRR17oFYXph7hSiquIKQ+hJGTX1J5MYSPD/GVdNzsgLBwZVCVyAQAkF0ohiI/c1fS6tNXq9UfEnkhudmIQolsS+J3Hh/UtNDzQLhj42VKJFInqLwFYiUU5ToA+HdfI0JevUpQUAIn+vSz2lHIuUV/dJOIHhOY/IWVWGBIHQtzs88s9zyWBuTgcBLzGOmeNnfF/QslSDgMeQW85i3DOQxuipxAkCyZ8SIm4Omp+7MMlCB59j6sKZcMoM4iIEoeI2J9AKxrFobZx0v4vYInuHFS4J1GQRCAGaLEYQXfyMML5XSQgghhBBCCCH+cXp6vgNhKpSKX/XdOAAAAABJRU5ErkJggg==",t.style.position="absolute",t.style.left="50%",t.style.top="50%",t.style.marginLeft="-50px",t.style.marginTop="-50px",t.style.transition="transform 1.0s ease",t.style.webkitTransition="-webkit-transform 1.0s ease";var i=360,r=function(){i+=360,t.style.transform="rotateZ("+i+"deg)",t.style.webkitTransform="rotateZ("+i+"deg)"};t.addEventListener("transitionend",r),t.addEventListener("webkitTransitionEnd",r),this._loadingDiv.appendChild(t);var n=new Image;n.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuM4zml1AAAAYJSURBVHhe7Zy/qx1FFMff/2Av2Nvbi4WFiiAEY/OQ2IgQsbCJQoqkCAgpFLXyoZURLfwBIiIpgqZJoYQYlWelNsIrNOxDJcrzfHe+G97dnTl75u7euzv7zgcWHrlnZmfOmXPmzI/NjuM4juM4juM4juM4juM4juM4juM4juM45fPic08/uHf5/CvffH7lnT8PfrtxdHS0n3p+/fHGl5+89/prr5599iEWd8bg0rkXHoFyqehKnlxQpjYSDHTm9JMPsGrHylOPPXofvICKXMcIGtXdf/76AYbm6xyNW9e/eAtKC7rbKLXnvHHx5Sf4auc4Ek7OQkFU1Dap/vv37k/wSjblZANFiFIGzw98hhizwqBgs04mCBdQRNCHidoAEtY+lLIvtSdoGFeyql2ZH57HBH4sE7O+o/r9l+8/ZXUni68+2jsHBQQ9qNRGeP/tSxdSYQX/roUcpL4/f3vtM9TD+jTq92n1LQ7jxF1hhGPtwWL3gGccy8JuS1r8sVWBGXNVdSKMYjBGPUJjCzooiGuSpnwlnnOGP2dhHRSLNgpHp2oMKIriK8TmG4Qh/rwW8D6pps9b9im+LDDipXOqMVJrAngBfg9i98gevWKA+/nnCod3Dr5GfaHaDgidVym6HKRjGIkpqthcAVKGxNqBImbEo66kjCih8AOpNmkUmbMuUrR8kEqiU6FvHZLGAPJ71JCYSyhiBqmwFE2GoD6jLGIfDHtG6EzoU4dK21PCqIRMEF0FGRjFzGDtIkXVAdATvsqfT9CJ0JcOFdYiFIsiMlqYy1YOFpQo2OddqBtyEaq9y+efoVh5oPHoROjLKn0j3JIE5Ka8UqZRtGrMnneX6yVofOhDh94MSbznTcpqmDOt1vyQzOgaJAF4F3JBfIXesrNEGWWmjIX7UBZ6jRJbBMLg/DmJiKUGVHleIpnVNTa+jakzkAviJqLhi4MC9XQGBrZeKJZESSrKy7ik0VGFWhQBRDTHIACKQ5l9nAjy75gya4a2w+Jhs0FJdc0xX/GwUbAqFBkZi7QpJ2w16WUbjFyK9MJF3KaoEM74KhVtLrQOrsmRxkbdHEqmSC/c+EuGnIFkjW7Ih2Kr4CCMIvNG2hrrgLpCjiFloooYCjyYrzCRyvhyBthkIPuQtsZGdnbMTezyDiU71KTC5zr7aVsHbsz2tllrEkS5UHwU1tq1HbtPW4UbeB0O7xx8R5EsMJql+BheUmHjkNVmIRP7LutoM3+D4O4tG7vCkNO9ESZ4lL3J6rKRMPx4qKbD/A0icf8CG7tC7kTahnMTwleuYSrsS7GatRAvfZh1tTm5BmmQCdZ8a0Sefe28xUrRBkmFLKy8KTIKUDRX0Y1xagPgwbaIdeFnQULmKak3xvwNMkVGgok/N5XNoehJvejRlCDl9escI28dJU0tZ++nBTJE9mEF647x5Ehbo4s5hDOKFIU0PdofeA5F5k1q63zIWmQqNI/P3ZubjFTqKxQ3jyjHAOX0RdlgVO9hzRFpczRcjZ3Gbxxpc7Qj6+5pTYF2OFXawNI+yDGf1k2NcvOlzBQeDQ/t7zD7DsEDpJ2xATXaNtDWUS4IzP4DS2ljajAVu57SUkYw245ptxZxA5JiZaJ0DswudGn3kYUy54426EjoT4dZfYbccxC2nI92cDkZHQr96jD4AGkMDKeSy/COBsRe6VTSKFN6irLeaCh3IteQjt1E5+oudsG/b/2DfZ5AqsYo8vMDK9LB1HzSsLWvlGThdxXvC6+NsqyPPWP0pMINtbdsajfVeC6f/GZ+cdAofQoB1d+Hf9waY98I7+RXWab3Lt4zYkjHtTnlOLXHYMsCh1zWeQYehu1zfNPOOiys/d91LAKEBSgh6MJMbSA82AaHofDgAIwbgvVvlLNS11nModMm4UZergLHZBZrodmBuA3lBB1thdorSjkOmATMDwg/UBQVtglqQyx6fbEJ+H3IWIapjYAjAfeIgeCMHldueJvFaqDaAHhwf8qNsEEQ1iQbOoUUGIbCLRc8+Bvfp4jyd2FEijuO4ziO4ziO4ziO4ziO4ziO4ziO4ziOUzw7O/8D0P7rcZ/GEboAAAAASUVORK5CYII=",n.style.position="absolute",n.style.left="50%",n.style.top="50%",n.style.marginLeft="-50px",n.style.marginTop="-50px",this._loadingDiv.appendChild(n),this._resizeLoadingUI(),window.addEventListener("resize",this._resizeLoadingUI),this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor,document.body.appendChild(this._loadingDiv),setTimeout(function(){e._loadingDiv.style.opacity="1",t.style.transform="rotateZ(360deg)",t.style.webkitTransform="rotateZ(360deg)"},0)},e.prototype.hideLoadingUI=function(){var e=this;if(this._loadingDiv){this._loadingDiv.style.opacity="0",this._loadingDiv.addEventListener("transitionend",function(){e._loadingDiv&&(document.body.removeChild(e._loadingDiv),window.removeEventListener("resize",e._resizeLoadingUI),e._loadingDiv=null)})}},Object.defineProperty(e.prototype,"loadingUIText",{set:function(e){this._loadingText=e,this._loadingTextDiv&&(this._loadingTextDiv.innerHTML=this._loadingText)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loadingUIBackgroundColor",{get:function(){return this._loadingDivBackgroundColor},set:function(e){this._loadingDivBackgroundColor=e,this._loadingDiv&&(this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor)},enumerable:!0,configurable:!0}),e}();e.DefaultLoadingScreen=t}(BABYLON||(BABYLON={})),function(e){var t=function(){function e(){this.ALBEDO=!1,this.CLIPPLANE=!1,this.ALPHATEST=!1,this.FOG=!1,this.NORMAL=!1,this.UV1=!1,this.UV2=!1,this.VERTEXCOLOR=!1,this.VERTEXALPHA=!1,this.BONES=!1,this.BONES4=!1,this.BonesPerMesh=0,this.INSTANCES=!1,this.POINTSIZE=!1,this._keys=Object.keys(this)}return e.prototype.isEqual=function(e){for(var t=0;t<this._keys.length;t++){var i=this._keys[t];if(this[i]!==e[i])return!1}return!0},e.prototype.cloneTo=function(e){for(var t=0;t<this._keys.length;t++){var i=this._keys[t];e[i]=this[i]}},e.prototype.reset=function(){for(var e=0;e<this._keys.length;e++){var t=this._keys[e];this[t]="BonesPerMesh"===t&&0}},e.prototype.toString=function(){for(var e="",t=0;t<this._keys.length;t++){var i=this._keys[t];"BonesPerMesh"===i&&this[i]>0?e+="#define BonesPerMesh "+this[i]+"\n":this[i]&&(e+="#define "+i+"\n")}return e},e}(),i=function(i){function r(r,n){i.call(this,r,n),this.albedoColor=new e.Color3(1,1,1),this._worldViewProjectionMatrix=e.Matrix.Zero(),this._globalAmbientColor=new e.Color3(0,0,0),this._scaledDiffuse=new e.Color3,this._scaledSpecular=new e.Color3,this._defines=new t,this._cachedDefines=new t,this._cachedDefines.BonesPerMesh=-1}return __extends(r,i),r.prototype.needAlphaBlending=function(){return this.alpha<1},r.prototype.needAlphaTesting=function(){return!1},r.prototype.getAlphaTestTexture=function(){return null},r.prototype.isReady=function(t,i){if(this.checkReadyOnlyOnce&&this._wasPreviouslyReady)return!0;var r=this.getScene();if(!this.checkReadyOnEveryCall&&this._renderId===r.getRenderId())return!0;var n=r.getEngine();if(this._defines.reset(),r.texturesEnabled,r.clipPlane&&(this._defines.CLIPPLANE=!0),n.getAlphaTesting()&&(this._defines.ALPHATEST=!0),(this.pointsCloud||r.forcePointsCloud)&&(this._defines.POINTSIZE=!0),r.fogEnabled&&t&&t.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&this.fogEnabled&&(this._defines.FOG=!0),t&&(t.useVertexColors&&t.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(this._defines.VERTEXCOLOR=!0,t.hasVertexAlpha&&(this._defines.VERTEXALPHA=!0)),t.useBones&&t.computeBonesUsingShaders&&(this._defines.BONES=!0,this._defines.BonesPerMesh=t.skeleton.bones.length+1,this._defines.BONES4=!0),i&&(this._defines.INSTANCES=!0)),!this._defines.isEqual(this._cachedDefines)){this._defines.cloneTo(this._cachedDefines),r.resetCachedMaterial();var o=new e.EffectFallbacks;this._defines.FOG&&o.addFallback(1,"FOG"),this._defines.BONES4&&o.addFallback(0,"BONES4");var s=[e.VertexBuffer.PositionKind];this._defines.NORMAL&&s.push(e.VertexBuffer.NormalKind),this._defines.UV1&&s.push(e.VertexBuffer.UVKind),this._defines.UV2&&s.push(e.VertexBuffer.UV2Kind),this._defines.VERTEXCOLOR&&s.push(e.VertexBuffer.ColorKind),this._defines.BONES&&(s.push(e.VertexBuffer.MatricesIndicesKind),s.push(e.VertexBuffer.MatricesWeightsKind)),this._defines.INSTANCES&&(s.push("world0"),s.push("world1"),s.push("world2"),s.push("world3"));var a=this._defines.toString();this._effect=r.getEngine().createEffect("pbr",s,["world","view","viewProjection","vEyePosition","vAlbedoColor","vFogInfos","vFogColor","pointSize","mBones","vClipPlane"],[],a,o,this.onCompiled,this.onError)}return!!this._effect.isReady()&&(this._renderId=r.getRenderId(),this._wasPreviouslyReady=!0,!0)},r.prototype.bindOnlyWorldMatrix=function(e){this._effect.setMatrix("world",e)},r.prototype.bind=function(t,r){var n=this.getScene();if(this.bindOnlyWorldMatrix(t),this._effect.setMatrix("viewProjection",n.getTransformMatrix()),r&&r.useBones&&r.computeBonesUsingShaders&&this._effect.setMatrices("mBones",r.skeleton.getTransformMatrices()),n.getCachedMaterial()!==this){if(n.clipPlane){var o=n.clipPlane;this._effect.setFloat4("vClipPlane",o.normal.x,o.normal.y,o.normal.z,o.d)}this._effect.setVector3("vEyePosition",n.activeCamera.position)}this.pointsCloud&&this._effect.setFloat("pointSize",this.pointSize),this._effect.setColor4("vAlbedoColor",this.albedoColor,this.alpha*r.visibility),n.fogEnabled&&r.applyFog&&n.fogMode!==e.Scene.FOGMODE_NONE&&this._effect.setMatrix("view",n.getViewMatrix()),n.fogEnabled&&r.applyFog&&n.fogMode!==e.Scene.FOGMODE_NONE&&(this._effect.setFloat4("vFogInfos",n.fogMode,n.fogStart,n.fogEnd,n.fogDensity),this._effect.setColor3("vFogColor",n.fogColor)),i.prototype.bind.call(this,t,r)},r.prototype.getAnimatables=function(){return[]},r.prototype.dispose=function(e){i.prototype.dispose.call(this,e)},r.prototype.clone=function(e){var t=new r(e,this.getScene());return this.copyTo(t),t.albedoColor=this.albedoColor.clone(),t},r}(e.Material);e.PBRMaterial=i}(BABYLON||(BABYLON={})),function(e){var t=function(){function t(t,i,r,n){var o=this;void 0===n&&(n=!0),this.name=t,this._viewMatrix=e.Matrix.Identity(),this._target=e.Vector3.Zero(),this._add=e.Vector3.Zero(),this.position=e.Vector3.Zero(),this._scene=r,this._scene.reflectionProbes.push(this),this._renderTargetTexture=new e.RenderTargetTexture(t,i,r,n,!0,e.Engine.TEXTURETYPE_UNSIGNED_INT,!0),this._renderTargetTexture.onBeforeRender=function(t){switch(t){case 0:o._add.copyFromFloats(1,0,0);break;case 1:o._add.copyFromFloats(-1,0,0);break;case 2:o._add.copyFromFloats(0,-1,0);break;case 3:o._add.copyFromFloats(0,1,0);break;case 4:o._add.copyFromFloats(0,0,1);break;case 5:o._add.copyFromFloats(0,0,-1)}o._attachedMesh&&o.position.copyFrom(o._attachedMesh.getAbsolutePosition()),o.position.addToRef(o._add,o._target),e.Matrix.LookAtLHToRef(o.position,o._target,e.Vector3.Up(),o._viewMatrix),r.setTransformMatrix(o._viewMatrix,o._projectionMatrix)},this._renderTargetTexture.onAfterUnbind=function(){r.updateTransformMatrix(!0)},this._projectionMatrix=e.Matrix.PerspectiveFovLH(Math.PI/2,1,r.activeCamera.minZ,r.activeCamera.maxZ)}return Object.defineProperty(t.prototype,"refreshRate",{get:function(){return this._renderTargetTexture.refreshRate},set:function(e){this._renderTargetTexture.refreshRate=e},enumerable:!0,configurable:!0}),t.prototype.getScene=function(){return this._scene},Object.defineProperty(t.prototype,"cubeTexture",{get:function(){return this._renderTargetTexture},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderList",{get:function(){return this._renderTargetTexture.renderList},enumerable:!0,configurable:!0}),t.prototype.attachToMesh=function(e){this._attachedMesh=e},t.prototype.dispose=function(){var e=this._scene.reflectionProbes.indexOf(this);-1!==e&&this._scene.reflectionProbes.splice(e,1)},t}();e.ReflectionProbe=t}(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore={anaglyphPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Samplers\r\nvarying vec2 vUV;\r\nuniform sampler2D textureSampler;\r\nuniform sampler2D leftSampler;\r\n\r\nvoid main(void)\r\n{\r\n    vec4 leftFrag = texture2D(leftSampler, vUV);\r\n    leftFrag = vec4(1.0, leftFrag.g, leftFrag.b, 1.0);\r\n\r\n\tvec4 rightFrag = texture2D(textureSampler, vUV);\r\n    rightFrag = vec4(rightFrag.r, 1.0, 1.0, 1.0);\r\n\r\n    gl_FragColor = vec4(rightFrag.rgb * leftFrag.rgb, 1.0);\r\n}",blackAndWhitePixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Samplers\r\nvarying vec2 vUV;\r\nuniform sampler2D textureSampler;\r\n\r\nvoid main(void) \r\n{\r\n\tfloat luminance = dot(texture2D(textureSampler, vUV).rgb, vec3(0.3, 0.59, 0.11));\r\n\tgl_FragColor = vec4(luminance, luminance, luminance, 1.0);\r\n}",blurPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Samplers\r\nvarying vec2 vUV;\r\nuniform sampler2D textureSampler;\r\n\r\n// Parameters\r\nuniform vec2 screenSize;\r\nuniform vec2 direction;\r\nuniform float blurWidth;\r\n\r\nvoid main(void)\r\n{\r\n\tfloat weights[7];\r\n\tweights[0] = 0.05;\r\n\tweights[1] = 0.1;\r\n\tweights[2] = 0.2;\r\n\tweights[3] = 0.3;\r\n\tweights[4] = 0.2;\r\n\tweights[5] = 0.1;\r\n\tweights[6] = 0.05;\r\n\r\n\tvec2 texelSize = vec2(1.0 / screenSize.x, 1.0 / screenSize.y);\r\n\tvec2 texelStep = texelSize * direction * blurWidth;\r\n\tvec2 start = vUV - 3.0 * texelStep;\r\n\r\n\tvec4 baseColor = vec4(0., 0., 0., 0.);\r\n\tvec2 texelOffset = vec2(0., 0.);\r\n\r\n\tfor (int i = 0; i < 7; i++)\r\n\t{\r\n\t\tbaseColor += texture2D(textureSampler, start + texelOffset) * weights[i];\r\n\t\ttexelOffset += texelStep;\r\n\t}\r\n\r\n\tgl_FragColor = baseColor;\r\n}",brickPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\nvarying vec2 vPosition;\r\nvarying vec2 vUV;\r\n\r\nuniform float numberOfBricksHeight;\r\nuniform float numberOfBricksWidth;\r\nuniform vec3 brickColor;\r\nuniform vec3 jointColor;\r\n\r\nfloat rand(vec2 n) {\r\n\treturn fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);\r\n}\r\n\r\nfloat noise(vec2 n) {\r\n\tconst vec2 d = vec2(0.0, 1.0);\r\n\tvec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));\r\n\treturn mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);\r\n}\r\n\r\nfloat fbm(vec2 n) {\r\n\tfloat total = 0.0, amplitude = 1.0;\r\n\tfor (int i = 0; i < 4; i++) {\r\n\t\ttotal += noise(n) * amplitude;\r\n\t\tn += n;\r\n\t\tamplitude *= 0.5;\r\n\t}\r\n\treturn total;\r\n}\r\n\r\nfloat round(float number){\r\n\treturn sign(number)*floor(abs(number) + 0.5);\r\n}\r\n\r\nvoid main(void)\r\n{\r\n\tfloat brickW = 1.0 / numberOfBricksWidth;\r\n\tfloat brickH = 1.0 / numberOfBricksHeight;\r\n\tfloat jointWPercentage = 0.01;\r\n\tfloat jointHPercentage = 0.05;\r\n\tvec3 color = brickColor;\r\n\tfloat yi = vUV.y / brickH;\r\n\tfloat nyi = round(yi);\r\n\tfloat xi = vUV.x / brickW;\r\n\r\n\tif (mod(floor(yi), 2.0) == 0.0){\r\n\t\txi = xi - 0.5;\r\n\t}\r\n\r\n\tfloat nxi = round(xi);\r\n\tvec2 brickvUV = vec2((xi - floor(xi)) / brickH, (yi - floor(yi)) /  brickW);\r\n\r\n\tif (yi < nyi + jointHPercentage && yi > nyi - jointHPercentage){\r\n\t\tcolor = mix(jointColor, vec3(0.37, 0.25, 0.25), (yi - nyi) / jointHPercentage + 0.2);\r\n\t}\r\n\telse if (xi < nxi + jointWPercentage && xi > nxi - jointWPercentage){\r\n\t\tcolor = mix(jointColor, vec3(0.44, 0.44, 0.44), (xi - nxi) / jointWPercentage + 0.2);\r\n\t}\r\n\telse {\r\n\t\tfloat brickColorSwitch = mod(floor(yi) + floor(xi), 3.0);\r\n\r\n\t\tif (brickColorSwitch == 0.0)\r\n\t\t\tcolor = mix(color, vec3(0.33, 0.33, 0.33), 0.3);\r\n\t\telse if (brickColorSwitch == 2.0)\r\n\t\t\tcolor = mix(color, vec3(0.11, 0.11, 0.11), 0.3);\r\n\t}\r\n\r\n\tgl_FragColor = vec4(color, 1.0);\r\n}",chromaticAberrationPixelShader:"// BABYLON.JS Chromatic Aberration GLSL Shader\r\n// Author: Olivier Guyot\r\n// Separates very slightly R, G and B colors on the edges of the screen\r\n// Inspired by Francois Tarlier & Martins Upitis\r\n\r\n#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// samplers\r\nuniform sampler2D textureSampler;\t// original color\r\n\r\n// uniforms\r\nuniform float chromatic_aberration;\r\nuniform float screen_width;\r\nuniform float screen_height;\r\n\r\n// varyings\r\nvarying vec2 vUV;\r\n\r\nvoid main(void)\r\n{\r\n\tvec2 centered_screen_pos = vec2(vUV.x - 0.5, vUV.y - 0.5);\r\n\tfloat radius2 = centered_screen_pos.x*centered_screen_pos.x\r\n\t\t+ centered_screen_pos.y*centered_screen_pos.y;\r\n\tfloat radius = sqrt(radius2);\r\n\r\n\tvec4 original = texture2D(textureSampler, vUV);\r\n\r\n\tif (chromatic_aberration > 0.0) {\r\n\t\t//index of refraction of each color channel, causing chromatic dispersion\r\n\t\tvec3 ref_indices = vec3(-0.3, 0.0, 0.3);\r\n\t\tfloat ref_shiftX = chromatic_aberration * radius * 17.0 / screen_width;\r\n\t\tfloat ref_shiftY = chromatic_aberration * radius * 17.0 / screen_height;\r\n\r\n\t\t// shifts for red, green & blue\r\n\t\tvec2 ref_coords_r = vec2(vUV.x + ref_indices.r*ref_shiftX, vUV.y + ref_indices.r*ref_shiftY*0.5);\r\n\t\tvec2 ref_coords_g = vec2(vUV.x + ref_indices.g*ref_shiftX, vUV.y + ref_indices.g*ref_shiftY*0.5);\r\n\t\tvec2 ref_coords_b = vec2(vUV.x + ref_indices.b*ref_shiftX, vUV.y + ref_indices.b*ref_shiftY*0.5);\r\n\r\n\t\toriginal.r = texture2D(textureSampler, ref_coords_r).r;\r\n\t\toriginal.g = texture2D(textureSampler, ref_coords_g).g;\r\n\t\toriginal.b = texture2D(textureSampler, ref_coords_b).b;\r\n\t}\r\n\r\n\tgl_FragColor = original;\r\n}",cloudPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\nvarying vec2 vUV;\r\n\r\nuniform vec4 skyColor;\r\nuniform vec4 cloudColor;\r\n\r\nfloat rand(vec2 n) {\r\n\treturn fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);\r\n}\r\n\r\nfloat noise(vec2 n) {\r\n\tconst vec2 d = vec2(0.0, 1.0);\r\n\tvec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));\r\n\treturn mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);\r\n}\r\n\r\nfloat fbm(vec2 n) {\r\n\tfloat total = 0.0, amplitude = 1.0;\r\n\tfor (int i = 0; i < 4; i++) {\r\n\t\ttotal += noise(n) * amplitude;\r\n\t\tn += n;\r\n\t\tamplitude *= 0.5;\r\n\t}\r\n\treturn total;\r\n}\r\n\r\nvoid main() {\r\n\r\n\tvec2 p = vUV * 12.0;\r\n\tvec4 c = mix(skyColor, cloudColor, fbm(p));\r\n\tgl_FragColor = c;\r\n\r\n}\r\n\r\n",colorPixelShader:"precision highp float;\r\n\r\nuniform vec4 color;\r\n\r\nvoid main(void) {\r\n\tgl_FragColor = color;\r\n}",colorVertexShader:"precision highp float;\r\n\r\n// Attributes\r\nattribute vec3 position;\r\n\r\n// Uniforms\r\nuniform mat4 worldViewProjection;\r\n\r\nvoid main(void) {\r\n\tgl_Position = worldViewProjection * vec4(position, 1.0);\r\n}",colorCorrectionPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// samplers\r\nuniform sampler2D textureSampler;\t// screen render\r\nuniform sampler2D colorTable;\t\t// color table with modified colors\r\n\r\n// varyings\r\nvarying vec2 vUV;\r\n\r\n// constants\r\nconst float SLICE_COUNT = 16.0;\t\t// how many slices in the color cube; 1 slice = 1 pixel\r\n// it means the image is 256x16 pixels\r\n\r\nvec4 sampleAs3DTexture(sampler2D texture, vec3 uv, float width) {\r\n\tfloat sliceSize = 1.0 / width;              // space of 1 slice\r\n\tfloat slicePixelSize = sliceSize / width;          // space of 1 pixel\r\n\tfloat sliceInnerSize = slicePixelSize * (width - 1.0);  // space of width pixels\r\n\tfloat zSlice0 = min(floor(uv.z * width), width - 1.0);\r\n\tfloat zSlice1 = min(zSlice0 + 1.0, width - 1.0);\r\n\tfloat xOffset = slicePixelSize * 0.5 + uv.x * sliceInnerSize;\r\n\tfloat s0 = xOffset + (zSlice0 * sliceSize);\r\n\tfloat s1 = xOffset + (zSlice1 * sliceSize);\r\n\tvec4 slice0Color = texture2D(texture, vec2(s0, uv.y));\r\n\tvec4 slice1Color = texture2D(texture, vec2(s1, uv.y));\r\n\tfloat zOffset = mod(uv.z * width, 1.0);\r\n\tvec4 result = mix(slice0Color, slice1Color, zOffset);\r\n\treturn result;\r\n}\r\n\r\nvoid main(void)\r\n{\r\n\tvec4 screen_color = texture2D(textureSampler, vUV);\r\n\tgl_FragColor = sampleAs3DTexture(colorTable, screen_color.rgb, SLICE_COUNT);\r\n\r\n}",convolutionPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Samplers\r\nvarying vec2 vUV;\r\nuniform sampler2D textureSampler;\r\n\r\nuniform vec2 screenSize;\r\nuniform float kernel[9];\r\n\r\nvoid main(void)\r\n{\r\n\tvec2 onePixel = vec2(1.0, 1.0) / screenSize;\r\n\tvec4 colorSum =\r\n\t\ttexture2D(textureSampler, vUV + onePixel * vec2(-1, -1)) * kernel[0] +\r\n\t\ttexture2D(textureSampler, vUV + onePixel * vec2(0, -1)) * kernel[1] +\r\n\t\ttexture2D(textureSampler, vUV + onePixel * vec2(1, -1)) * kernel[2] +\r\n\t\ttexture2D(textureSampler, vUV + onePixel * vec2(-1, 0)) * kernel[3] +\r\n\t\ttexture2D(textureSampler, vUV + onePixel * vec2(0, 0)) * kernel[4] +\r\n\t\ttexture2D(textureSampler, vUV + onePixel * vec2(1, 0)) * kernel[5] +\r\n\t\ttexture2D(textureSampler, vUV + onePixel * vec2(-1, 1)) * kernel[6] +\r\n\t\ttexture2D(textureSampler, vUV + onePixel * vec2(0, 1)) * kernel[7] +\r\n\t\ttexture2D(textureSampler, vUV + onePixel * vec2(1, 1)) * kernel[8];\r\n\r\n\tfloat kernelWeight =\r\n\t\tkernel[0] +\r\n\t\tkernel[1] +\r\n\t\tkernel[2] +\r\n\t\tkernel[3] +\r\n\t\tkernel[4] +\r\n\t\tkernel[5] +\r\n\t\tkernel[6] +\r\n\t\tkernel[7] +\r\n\t\tkernel[8];\r\n\r\n\tif (kernelWeight <= 0.0) {\r\n\t\tkernelWeight = 1.0;\r\n\t}\r\n\r\n\tgl_FragColor = vec4((colorSum / kernelWeight).rgb, 1);\r\n}",defaultPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Constants\r\nuniform vec3 vEyePosition;\r\nuniform vec3 vAmbientColor;\r\nuniform vec4 vDiffuseColor;\r\n#ifdef SPECULARTERM\r\nuniform vec4 vSpecularColor;\r\n#endif\r\nuniform vec3 vEmissiveColor;\r\n\r\n// Input\r\nvarying vec3 vPositionW;\r\n\r\n#ifdef NORMAL\r\nvarying vec3 vNormalW;\r\n#endif\r\n\r\n#ifdef VERTEXCOLOR\r\nvarying vec4 vColor;\r\n#endif\r\n\r\n// Lights\r\n#ifdef LIGHT0\r\nuniform vec4 vLightData0;\r\nuniform vec4 vLightDiffuse0;\r\n#ifdef SPECULARTERM\r\nuniform vec3 vLightSpecular0;\r\n#endif\r\n#ifdef SHADOW0\r\nvarying vec4 vPositionFromLight0;\r\nuniform sampler2D shadowSampler0;\r\nuniform vec3 shadowsInfo0;\r\n#endif\r\n#ifdef SPOTLIGHT0\r\nuniform vec4 vLightDirection0;\r\n#endif\r\n#ifdef HEMILIGHT0\r\nuniform vec3 vLightGround0;\r\n#endif\r\n#endif\r\n\r\n#ifdef LIGHT1\r\nuniform vec4 vLightData1;\r\nuniform vec4 vLightDiffuse1;\r\n#ifdef SPECULARTERM\r\nuniform vec3 vLightSpecular1;\r\n#endif\r\n#ifdef SHADOW1\r\nvarying vec4 vPositionFromLight1;\r\nuniform sampler2D shadowSampler1;\r\nuniform vec3 shadowsInfo1;\r\n#endif\r\n#ifdef SPOTLIGHT1\r\nuniform vec4 vLightDirection1;\r\n#endif\r\n#ifdef HEMILIGHT1\r\nuniform vec3 vLightGround1;\r\n#endif\r\n#endif\r\n\r\n#ifdef LIGHT2\r\nuniform vec4 vLightData2;\r\nuniform vec4 vLightDiffuse2;\r\n#ifdef SPECULARTERM\r\nuniform vec3 vLightSpecular2;\r\n#endif\r\n#ifdef SHADOW2\r\nvarying vec4 vPositionFromLight2;\r\nuniform sampler2D shadowSampler2;\r\nuniform vec3 shadowsInfo2;\r\n#endif\r\n#ifdef SPOTLIGHT2\r\nuniform vec4 vLightDirection2;\r\n#endif\r\n#ifdef HEMILIGHT2\r\nuniform vec3 vLightGround2;\r\n#endif\r\n#endif\r\n\r\n#ifdef LIGHT3\r\nuniform vec4 vLightData3;\r\nuniform vec4 vLightDiffuse3;\r\n#ifdef SPECULARTERM\r\nuniform vec3 vLightSpecular3;\r\n#endif\r\n#ifdef SHADOW3\r\nvarying vec4 vPositionFromLight3;\r\nuniform sampler2D shadowSampler3;\r\nuniform vec3 shadowsInfo3;\r\n#endif\r\n#ifdef SPOTLIGHT3\r\nuniform vec4 vLightDirection3;\r\n#endif\r\n#ifdef HEMILIGHT3\r\nuniform vec3 vLightGround3;\r\n#endif\r\n#endif\r\n\r\n// Samplers\r\n#ifdef DIFFUSE\r\nvarying vec2 vDiffuseUV;\r\nuniform sampler2D diffuseSampler;\r\nuniform vec2 vDiffuseInfos;\r\n#endif\r\n\r\n#ifdef AMBIENT\r\nvarying vec2 vAmbientUV;\r\nuniform sampler2D ambientSampler;\r\nuniform vec2 vAmbientInfos;\r\n#endif\r\n\r\n#ifdef OPACITY\t\r\nvarying vec2 vOpacityUV;\r\nuniform sampler2D opacitySampler;\r\nuniform vec2 vOpacityInfos;\r\n#endif\r\n\r\n#ifdef EMISSIVE\r\nvarying vec2 vEmissiveUV;\r\nuniform vec2 vEmissiveInfos;\r\nuniform sampler2D emissiveSampler;\r\n#endif\r\n\r\n#ifdef LIGHTMAP\r\nvarying vec2 vLightmapUV;\r\nuniform vec3 vLightmapInfos;\r\nuniform sampler2D lightmapSampler;\r\n#endif\r\n\r\n#if defined(SPECULAR) && defined(SPECULARTERM)\r\nvarying vec2 vSpecularUV;\r\nuniform vec2 vSpecularInfos;\r\nuniform sampler2D specularSampler;\r\n#endif\r\n\r\n// Fresnel\r\n#ifdef FRESNEL\r\nfloat computeFresnelTerm(vec3 viewDirection, vec3 worldNormal, float bias, float power)\r\n{\r\n\tfloat fresnelTerm = pow(bias + abs(dot(viewDirection, worldNormal)), power);\r\n\treturn clamp(fresnelTerm, 0., 1.);\r\n}\r\n#endif\r\n\r\n#ifdef DIFFUSEFRESNEL\r\nuniform vec4 diffuseLeftColor;\r\nuniform vec4 diffuseRightColor;\r\n#endif\r\n\r\n#ifdef OPACITYFRESNEL\r\nuniform vec4 opacityParts;\r\n#endif\r\n\r\n#ifdef REFLECTIONFRESNEL\r\nuniform vec4 reflectionLeftColor;\r\nuniform vec4 reflectionRightColor;\r\n#endif\r\n\r\n#ifdef EMISSIVEFRESNEL\r\nuniform vec4 emissiveLeftColor;\r\nuniform vec4 emissiveRightColor;\r\n#endif\r\n\r\n#ifdef REFLECTION\r\nvarying vec3 vReflectionUVW;\r\n#ifdef REFLECTIONMAP_3D\r\nuniform samplerCube reflectionCubeSampler;\r\n#else\r\nuniform sampler2D reflection2DSampler;\r\n#endif\r\nuniform vec2 vReflectionInfos;\r\n#endif\r\n\r\n// Shadows\r\n#ifdef SHADOWS\r\n\r\nfloat unpack(vec4 color)\r\n{\r\n\tconst vec4 bit_shift = vec4(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0);\r\n\treturn dot(color, bit_shift);\r\n}\r\n\r\nfloat unpackHalf(vec2 color)\r\n{\r\n\treturn color.x + (color.y / 255.0);\r\n}\r\n\r\nfloat computeShadow(vec4 vPositionFromLight, sampler2D shadowSampler, float darkness, float bias)\r\n{\r\n\tvec3 depth = vPositionFromLight.xyz / vPositionFromLight.w;\r\n\tdepth = 0.5 * depth + vec3(0.5);\r\n\tvec2 uv = depth.xy;\r\n\r\n\tif (uv.x < 0. || uv.x > 1.0 || uv.y < 0. || uv.y > 1.0)\r\n\t{\r\n\t\treturn 1.0;\r\n\t}\r\n\r\n\tfloat shadow = unpack(texture2D(shadowSampler, uv)) + bias;\r\n\r\n\tif (depth.z > shadow)\r\n\t{\r\n\t\treturn darkness;\r\n\t}\r\n\treturn 1.;\r\n}\r\n\r\nfloat computeShadowWithPCF(vec4 vPositionFromLight, sampler2D shadowSampler, float mapSize, float bias, float darkness)\r\n{\r\n\tvec3 depth = vPositionFromLight.xyz / vPositionFromLight.w;\r\n\tdepth = 0.5 * depth + vec3(0.5);\r\n\tvec2 uv = depth.xy;\r\n\r\n\tif (uv.x < 0. || uv.x > 1.0 || uv.y < 0. || uv.y > 1.0)\r\n\t{\r\n\t\treturn 1.0;\r\n\t}\r\n\r\n\tfloat visibility = 1.;\r\n\r\n\tvec2 poissonDisk[4];\r\n\tpoissonDisk[0] = vec2(-0.94201624, -0.39906216);\r\n\tpoissonDisk[1] = vec2(0.94558609, -0.76890725);\r\n\tpoissonDisk[2] = vec2(-0.094184101, -0.92938870);\r\n\tpoissonDisk[3] = vec2(0.34495938, 0.29387760);\r\n\r\n\t// Poisson Sampling\r\n\tfloat biasedDepth = depth.z - bias;\r\n\r\n\tif (unpack(texture2D(shadowSampler, uv + poissonDisk[0] / mapSize)) < biasedDepth) visibility -= 0.25;\r\n\tif (unpack(texture2D(shadowSampler, uv + poissonDisk[1] / mapSize)) < biasedDepth) visibility -= 0.25;\r\n\tif (unpack(texture2D(shadowSampler, uv + poissonDisk[2] / mapSize)) < biasedDepth) visibility -= 0.25;\r\n\tif (unpack(texture2D(shadowSampler, uv + poissonDisk[3] / mapSize)) < biasedDepth) visibility -= 0.25;\r\n\r\n\treturn  min(1.0, visibility + darkness);\r\n}\r\n\r\n// Thanks to http://devmaster.net/\r\nfloat linstep(float low, float high, float v) {\r\n\treturn clamp((v - low) / (high - low), 0.0, 1.0);\r\n}\r\n\r\nfloat ChebychevInequality(vec2 moments, float compare, float bias)\r\n{\r\n\tfloat p = smoothstep(compare - bias, compare, moments.x);\r\n\tfloat variance = max(moments.y - moments.x * moments.x, 0.02);\r\n\tfloat d = compare - moments.x;\r\n\tfloat p_max = linstep(0.2, 1.0, variance / (variance + d * d));\r\n\r\n\treturn clamp(max(p, p_max), 0.0, 1.0);\r\n}\r\n\r\nfloat computeShadowWithVSM(vec4 vPositionFromLight, sampler2D shadowSampler, float bias, float darkness)\r\n{\r\n\tvec3 depth = vPositionFromLight.xyz / vPositionFromLight.w;\r\n\tdepth = 0.5 * depth + vec3(0.5);\r\n\tvec2 uv = depth.xy;\r\n\r\n\tif (uv.x < 0. || uv.x > 1.0 || uv.y < 0. || uv.y > 1.0 || depth.z >= 1.0)\r\n\t{\r\n\t\treturn 1.0;\r\n\t}\r\n\r\n\tvec4 texel = texture2D(shadowSampler, uv);\r\n\r\n\tvec2 moments = vec2(unpackHalf(texel.xy), unpackHalf(texel.zw));\r\n\treturn min(1.0, 1.0 - ChebychevInequality(moments, depth.z, bias) + darkness);\r\n}\r\n#endif\r\n\r\n// Bump\r\n#ifdef BUMP\r\n#extension GL_OES_standard_derivatives : enable\r\nvarying vec2 vBumpUV;\r\nuniform vec2 vBumpInfos;\r\nuniform sampler2D bumpSampler;\r\n\r\n// Thanks to http://www.thetenthplanet.de/archives/1180\r\nmat3 cotangent_frame(vec3 normal, vec3 p, vec2 uv)\r\n{\r\n\t// get edge vectors of the pixel triangle\r\n\tvec3 dp1 = dFdx(p);\r\n\tvec3 dp2 = dFdy(p);\r\n\tvec2 duv1 = dFdx(uv);\r\n\tvec2 duv2 = dFdy(uv);\r\n\r\n\t// solve the linear system\r\n\tvec3 dp2perp = cross(dp2, normal);\r\n\tvec3 dp1perp = cross(normal, dp1);\r\n\tvec3 tangent = dp2perp * duv1.x + dp1perp * duv2.x;\r\n\tvec3 binormal = dp2perp * duv1.y + dp1perp * duv2.y;\r\n\r\n\t// construct a scale-invariant frame \r\n\tfloat invmax = inversesqrt(max(dot(tangent, tangent), dot(binormal, binormal)));\r\n\treturn mat3(tangent * invmax, binormal * invmax, normal);\r\n}\r\n\r\nvec3 perturbNormal(vec3 viewDir)\r\n{\r\n\tvec3 map = texture2D(bumpSampler, vBumpUV).xyz;\r\n\tmap = map * 255. / 127. - 128. / 127.;\r\n\tmat3 TBN = cotangent_frame(vNormalW * vBumpInfos.y, -viewDir, vBumpUV);\r\n\treturn normalize(TBN * map);\r\n}\r\n#endif\r\n\r\n#ifdef CLIPPLANE\r\nvarying float fClipDistance;\r\n#endif\r\n\r\n// Fog\r\n#ifdef FOG\r\n\r\n#define FOGMODE_NONE    0.\r\n#define FOGMODE_EXP    1.\r\n#define FOGMODE_EXP2    2.\r\n#define FOGMODE_LINEAR  3.\r\n#define E 2.71828\r\n\r\nuniform vec4 vFogInfos;\r\nuniform vec3 vFogColor;\r\nvarying float fFogDistance;\r\n\r\nfloat CalcFogFactor()\r\n{\r\n\tfloat fogCoeff = 1.0;\r\n\tfloat fogStart = vFogInfos.y;\r\n\tfloat fogEnd = vFogInfos.z;\r\n\tfloat fogDensity = vFogInfos.w;\r\n\r\n\tif (FOGMODE_LINEAR == vFogInfos.x)\r\n\t{\r\n\t\tfogCoeff = (fogEnd - fFogDistance) / (fogEnd - fogStart);\r\n\t}\r\n\telse if (FOGMODE_EXP == vFogInfos.x)\r\n\t{\r\n\t\tfogCoeff = 1.0 / pow(E, fFogDistance * fogDensity);\r\n\t}\r\n\telse if (FOGMODE_EXP2 == vFogInfos.x)\r\n\t{\r\n\t\tfogCoeff = 1.0 / pow(E, fFogDistance * fFogDistance * fogDensity * fogDensity);\r\n\t}\r\n\r\n\treturn clamp(fogCoeff, 0.0, 1.0);\r\n}\r\n#endif\r\n\r\n// Light Computing\r\nstruct lightingInfo\r\n{\r\n\tvec3 diffuse;\r\n#ifdef SPECULARTERM\r\n\tvec3 specular;\r\n#endif\r\n};\r\n\r\nlightingInfo computeLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec3 diffuseColor, vec3 specularColor, float range, float glossiness) {\r\n\tlightingInfo result;\r\n\r\n\tvec3 lightVectorW;\r\n\tfloat attenuation = 1.0;\r\n\tif (lightData.w == 0.)\r\n\t{\r\n\t\tvec3 direction = lightData.xyz - vPositionW;\r\n\r\n\t\tattenuation = max(0., 1.0 - length(direction) / range);\r\n\t\tlightVectorW = normalize(direction);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tlightVectorW = normalize(-lightData.xyz);\r\n\t}\r\n\r\n\t// diffuse\r\n\tfloat ndl = max(0., dot(vNormal, lightVectorW));\r\n\tresult.diffuse = ndl * diffuseColor * attenuation;\r\n\r\n#ifdef SPECULARTERM\r\n\t// Specular\r\n\tvec3 angleW = normalize(viewDirectionW + lightVectorW);\r\n\tfloat specComp = max(0., dot(vNormal, angleW));\r\n\tspecComp = pow(specComp, max(1., glossiness));\r\n\r\n\tresult.specular = specComp * specularColor * attenuation;\r\n#endif\r\n\treturn result;\r\n}\r\n\r\nlightingInfo computeSpotLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec4 lightDirection, vec3 diffuseColor, vec3 specularColor, float range, float glossiness) {\r\n\tlightingInfo result;\r\n\r\n\tvec3 direction = lightData.xyz - vPositionW;\r\n\tvec3 lightVectorW = normalize(direction);\r\n\tfloat attenuation = max(0., 1.0 - length(direction) / range);\r\n\r\n\t// diffuse\r\n\tfloat cosAngle = max(0., dot(-lightDirection.xyz, lightVectorW));\r\n\tfloat spotAtten = 0.0;\r\n\r\n\tif (cosAngle >= lightDirection.w)\r\n\t{\r\n\t\tcosAngle = max(0., pow(cosAngle, lightData.w));\r\n\t\tspotAtten = clamp((cosAngle - lightDirection.w) / (1. - cosAngle), 0.0, 1.0);\r\n\r\n\t\t// Diffuse\r\n\t\tfloat ndl = max(0., dot(vNormal, -lightDirection.xyz));\r\n\t\tresult.diffuse = ndl * spotAtten * diffuseColor * attenuation;\r\n\r\n#ifdef SPECULARTERM\r\n\t\t// Specular\r\n\t\tvec3 angleW = normalize(viewDirectionW - lightDirection.xyz);\r\n\t\tfloat specComp = max(0., dot(vNormal, angleW));\r\n\t\tspecComp = pow(specComp, max(1., glossiness));\r\n\r\n\t\tresult.specular = specComp * specularColor * spotAtten * attenuation;\r\n#endif\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\tresult.diffuse = vec3(0.);\r\n#ifdef SPECULARTERM\r\n\tresult.specular = vec3(0.);\r\n#endif\r\n\r\n\treturn result;\r\n}\r\n\r\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec3 diffuseColor, vec3 specularColor, vec3 groundColor, float glossiness) {\r\n\tlightingInfo result;\r\n\r\n\t// Diffuse\r\n\tfloat ndl = dot(vNormal, lightData.xyz) * 0.5 + 0.5;\r\n\tresult.diffuse = mix(groundColor, diffuseColor, ndl);\r\n\r\n#ifdef SPECULARTERM\r\n\t// Specular\r\n\tvec3 angleW = normalize(viewDirectionW + lightData.xyz);\r\n\tfloat specComp = max(0., dot(vNormal, angleW));\r\n\tspecComp = pow(specComp, max(1., glossiness));\r\n\r\n\tresult.specular = specComp * specularColor;\r\n#endif\r\n\r\n\treturn result;\r\n}\r\n\r\nvoid main(void) {\r\n\t// Clip plane\r\n#ifdef CLIPPLANE\r\n\tif (fClipDistance > 0.0)\r\n\t\tdiscard;\r\n#endif\r\n\r\n\tvec3 viewDirectionW = normalize(vEyePosition - vPositionW);\r\n\r\n\t// Base color\r\n\tvec4 baseColor = vec4(1., 1., 1., 1.);\r\n\tvec3 diffuseColor = vDiffuseColor.rgb;\r\n\r\n\t// Alpha\r\n\tfloat alpha = vDiffuseColor.a;\r\n\r\n#ifdef DIFFUSE\r\n\tbaseColor = texture2D(diffuseSampler, vDiffuseUV);\r\n\r\n#ifdef ALPHATEST\r\n\tif (baseColor.a < 0.4)\r\n\t\tdiscard;\r\n#endif\r\n\r\n#ifdef ALPHAFROMDIFFUSE\r\n\talpha *= baseColor.a;\r\n#endif\r\n\r\n\tbaseColor.rgb *= vDiffuseInfos.y;\r\n#endif\r\n\r\n#ifdef VERTEXCOLOR\r\n\tbaseColor.rgb *= vColor.rgb;\r\n#endif\r\n\r\n\t// Bump\r\n#ifdef NORMAL\r\n\tvec3 normalW = normalize(vNormalW);\r\n#else\r\n\tvec3 normalW = vec3(1.0, 1.0, 1.0);\r\n#endif\r\n\r\n\r\n#ifdef BUMP\r\n\tnormalW = perturbNormal(viewDirectionW);\r\n#endif\r\n\r\n\t// Ambient color\r\n\tvec3 baseAmbientColor = vec3(1., 1., 1.);\r\n\r\n#ifdef AMBIENT\r\n\tbaseAmbientColor = texture2D(ambientSampler, vAmbientUV).rgb * vAmbientInfos.y;\r\n#endif\r\n\r\n\r\n\t// Specular map\r\n#ifdef SPECULARTERM\r\n\tfloat glossiness = vSpecularColor.a;\r\n\tvec3 specularColor = vSpecularColor.rgb;\r\n\r\n\t#ifdef SPECULAR\r\n\t\tvec4 specularMapColor = texture2D(specularSampler, vSpecularUV);\r\n\t\tspecularColor = specularMapColor.rgb;\r\n\t\t#ifdef GLOSSINESS\r\n\t\t\tglossiness = glossiness * specularMapColor.a;\r\n\t\t#endif\r\n\t#endif\r\n#else\r\n\tfloat glossiness = 0.;\r\n#endif\r\n\r\n\t// Lighting\r\n\tvec3 diffuseBase = vec3(0., 0., 0.);\r\n#ifdef SPECULARTERM\r\n\tvec3 specularBase = vec3(0., 0., 0.);\r\n#endif\r\n\tfloat shadow = 1.;\r\n\r\n#ifdef LIGHT0\r\n#ifndef SPECULARTERM\r\n\tvec3 vLightSpecular0 = vec3(0.0);\r\n#endif\r\n#ifdef SPOTLIGHT0\r\n\tlightingInfo info = computeSpotLighting(viewDirectionW, normalW, vLightData0, vLightDirection0, vLightDiffuse0.rgb, vLightSpecular0, vLightDiffuse0.a, glossiness);\r\n#endif\r\n#ifdef HEMILIGHT0\r\n\tlightingInfo info = computeHemisphericLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0.rgb, vLightSpecular0, vLightGround0, glossiness);\r\n#endif\r\n#ifdef POINTDIRLIGHT0\r\n\tlightingInfo info = computeLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0.rgb, vLightSpecular0, vLightDiffuse0.a, glossiness);\r\n#endif\r\n#ifdef SHADOW0\r\n#ifdef SHADOWVSM0\r\n\tshadow = computeShadowWithVSM(vPositionFromLight0, shadowSampler0, shadowsInfo0.z, shadowsInfo0.x);\r\n#else\r\n\t#ifdef SHADOWPCF0\r\n\t\tshadow = computeShadowWithPCF(vPositionFromLight0, shadowSampler0, shadowsInfo0.y, shadowsInfo0.z, shadowsInfo0.x);\r\n\t#else\r\n\t\tshadow = computeShadow(vPositionFromLight0, shadowSampler0, shadowsInfo0.x, shadowsInfo0.z);\r\n\t#endif\r\n#endif\r\n#else\r\n\tshadow = 1.;\r\n#endif\r\n\tdiffuseBase += info.diffuse * shadow;\r\n#ifdef SPECULARTERM\r\n\tspecularBase += info.specular * shadow;\r\n#endif\r\n#endif\r\n\r\n#ifdef LIGHT1\r\n#ifndef SPECULARTERM\r\n\tvec3 vLightSpecular1 = vec3(0.0);\r\n#endif\r\n#ifdef SPOTLIGHT1\r\n\tinfo = computeSpotLighting(viewDirectionW, normalW, vLightData1, vLightDirection1, vLightDiffuse1.rgb, vLightSpecular1, vLightDiffuse1.a, glossiness);\r\n#endif\r\n#ifdef HEMILIGHT1\r\n\tinfo = computeHemisphericLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1.rgb, vLightSpecular1, vLightGround1, glossiness);\r\n#endif\r\n#ifdef POINTDIRLIGHT1\r\n\tinfo = computeLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1.rgb, vLightSpecular1, vLightDiffuse1.a, glossiness);\r\n#endif\r\n#ifdef SHADOW1\r\n#ifdef SHADOWVSM1\r\n\tshadow = computeShadowWithVSM(vPositionFromLight1, shadowSampler1, shadowsInfo1.z, shadowsInfo1.x);\r\n#else\r\n\t#ifdef SHADOWPCF1\r\n\t\tshadow = computeShadowWithPCF(vPositionFromLight1, shadowSampler1, shadowsInfo1.y, shadowsInfo1.z, shadowsInfo1.x);\r\n\t#else\r\n\t\tshadow = computeShadow(vPositionFromLight1, shadowSampler1, shadowsInfo1.x, shadowsInfo1.z);\r\n\t#endif\r\n#endif\r\n#else\r\n\tshadow = 1.;\r\n#endif\r\n\tdiffuseBase += info.diffuse * shadow;\r\n#ifdef SPECULARTERM\r\n\tspecularBase += info.specular * shadow;\r\n#endif\r\n#endif\r\n\r\n#ifdef LIGHT2\r\n#ifndef SPECULARTERM\r\n\tvec3 vLightSpecular2 = vec3(0.0);\r\n#endif\r\n#ifdef SPOTLIGHT2\r\n\tinfo = computeSpotLighting(viewDirectionW, normalW, vLightData2, vLightDirection2, vLightDiffuse2.rgb, vLightSpecular2, vLightDiffuse2.a, glossiness);\r\n#endif\r\n#ifdef HEMILIGHT2\r\n\tinfo = computeHemisphericLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2.rgb, vLightSpecular2, vLightGround2, glossiness);\r\n#endif\r\n#ifdef POINTDIRLIGHT2\r\n\tinfo = computeLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2.rgb, vLightSpecular2, vLightDiffuse2.a, glossiness);\r\n#endif\r\n#ifdef SHADOW2\r\n#ifdef SHADOWVSM2\r\n\tshadow = computeShadowWithVSM(vPositionFromLight2, shadowSampler2, shadowsInfo2.z, shadowsInfo2.x);\r\n#else\r\n\t#ifdef SHADOWPCF2\r\n\t\tshadow = computeShadowWithPCF(vPositionFromLight2, shadowSampler2, shadowsInfo2.y, shadowsInfo2.z, shadowsInfo2.x);\r\n\t#else\r\n\t\tshadow = computeShadow(vPositionFromLight2, shadowSampler2, shadowsInfo2.x, shadowsInfo2.z);\r\n\t#endif\t\r\n#endif\t\r\n#else\r\n\tshadow = 1.;\r\n#endif\r\n\tdiffuseBase += info.diffuse * shadow;\r\n#ifdef SPECULARTERM\r\n\tspecularBase += info.specular * shadow;\r\n#endif\r\n#endif\r\n\r\n#ifdef LIGHT3\r\n#ifndef SPECULARTERM\r\n\tvec3 vLightSpecular3 = vec3(0.0);\r\n#endif\r\n#ifdef SPOTLIGHT3\r\n\tinfo = computeSpotLighting(viewDirectionW, normalW, vLightData3, vLightDirection3, vLightDiffuse3.rgb, vLightSpecular3, vLightDiffuse3.a, glossiness);\r\n#endif\r\n#ifdef HEMILIGHT3\r\n\tinfo = computeHemisphericLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3.rgb, vLightSpecular3, vLightGround3, glossiness);\r\n#endif\r\n#ifdef POINTDIRLIGHT3\r\n\tinfo = computeLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3.rgb, vLightSpecular3, vLightDiffuse3.a, glossiness);\r\n#endif\r\n#ifdef SHADOW3\r\n#ifdef SHADOWVSM3\r\n\tshadow = computeShadowWithVSM(vPositionFromLight3, shadowSampler3, shadowsInfo3.z, shadowsInfo3.x);\r\n#else\r\n\t#ifdef SHADOWPCF3\r\n\t\tshadow = computeShadowWithPCF(vPositionFromLight3, shadowSampler3, shadowsInfo3.y, shadowsInfo3.z, shadowsInfo3.x);\r\n\t#else\r\n\t\tshadow = computeShadow(vPositionFromLight3, shadowSampler3, shadowsInfo3.x, shadowsInfo3.z);\r\n\t#endif\t\r\n#endif\t\r\n#else\r\n\tshadow = 1.;\r\n#endif\r\n\tdiffuseBase += info.diffuse * shadow;\r\n#ifdef SPECULARTERM\r\n\tspecularBase += info.specular * shadow;\r\n#endif\r\n#endif\r\n\r\n\t// Reflection\r\n\tvec3 reflectionColor = vec3(0., 0., 0.);\r\n\r\n#ifdef REFLECTION\r\n\t#ifdef REFLECTIONMAP_3D\r\n\t\t\tfloat bias = 0.;\r\n\r\n\t\t#ifdef ROUGHNESS\r\n\t\t\t\tbias = vReflectionInfos.y;\r\n\t\t#endif\r\n\r\n\t\t#ifdef SPECULARTERM\r\n\t\t\t#ifdef SPECULAR\r\n\t\t\t\t#ifdef GLOSSINESS\r\n\t\t\t\t\t\tbias *= (1.0 - specularMapColor.a);\r\n\t\t\t\t#endif\r\n\t\t\t#endif\r\n\t\t#endif\r\n\r\n\t\treflectionColor = textureCube(reflectionCubeSampler, vReflectionUVW, bias).rgb * vReflectionInfos.x * shadow;\r\n\t#else\r\n\t\tvec2 coords = vReflectionUVW.xy;\r\n\r\n\t\t#ifdef REFLECTIONMAP_PROJECTION\r\n\t\t\tcoords /= vReflectionUVW.z;\r\n\t\t#endif\r\n\r\n\t\tcoords.y = 1.0 - coords.y;\r\n\r\n\t\treflectionColor = texture2D(reflection2DSampler, coords).rgb * vReflectionInfos.x * shadow;\r\n#endif\t\r\n\r\n#ifdef REFLECTIONFRESNEL\r\n\tfloat reflectionFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, reflectionRightColor.a, reflectionLeftColor.a);\r\n\r\n#ifdef REFLECTIONFRESNELFROMSPECULAR\r\n#ifdef SPECULARTERM\r\n\treflectionColor *= specularColor.rgb * (1.0 - reflectionFresnelTerm) + reflectionFresnelTerm * reflectionRightColor.rgb;\r\n#else\r\n\treflectionColor *= reflectionLeftColor.rgb * (1.0 - reflectionFresnelTerm) + reflectionFresnelTerm * reflectionRightColor.rgb;\r\n#endif\r\n#else\r\n\treflectionColor *= reflectionLeftColor.rgb * (1.0 - reflectionFresnelTerm) + reflectionFresnelTerm * reflectionRightColor.rgb;\r\n#endif\r\n#endif\r\n#endif\r\n\r\n\r\n#ifdef OPACITY\r\n\tvec4 opacityMap = texture2D(opacitySampler, vOpacityUV);\r\n\r\n#ifdef OPACITYRGB\r\n\topacityMap.rgb = opacityMap.rgb * vec3(0.3, 0.59, 0.11);\r\n\talpha *= (opacityMap.x + opacityMap.y + opacityMap.z)* vOpacityInfos.y;\r\n#else\r\n\talpha *= opacityMap.a * vOpacityInfos.y;\r\n#endif\r\n\r\n#endif\r\n\r\n#ifdef VERTEXALPHA\r\n\talpha *= vColor.a;\r\n#endif\r\n\r\n#ifdef OPACITYFRESNEL\r\n\tfloat opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w);\r\n\r\n\talpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y;\r\n#endif\r\n\r\n\t// Emissive\r\n\tvec3 emissiveColor = vEmissiveColor;\r\n#ifdef EMISSIVE\r\n    emissiveColor += texture2D(emissiveSampler, vEmissiveUV).rgb * vEmissiveInfos.y;\r\n#endif\r\n\r\n#ifdef EMISSIVEFRESNEL\r\n\tfloat emissiveFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, emissiveRightColor.a, emissiveLeftColor.a);\r\n\r\n\temissiveColor *= emissiveLeftColor.rgb * (1.0 - emissiveFresnelTerm) + emissiveFresnelTerm * emissiveRightColor.rgb;\r\n#endif\r\n\r\n\t// Fresnel\r\n#ifdef DIFFUSEFRESNEL\r\n\tfloat diffuseFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, diffuseRightColor.a, diffuseLeftColor.a);\r\n\r\n\tdiffuseBase *= diffuseLeftColor.rgb * (1.0 - diffuseFresnelTerm) + diffuseFresnelTerm * diffuseRightColor.rgb;\r\n#endif\r\n\r\n\t// Composition\r\n#ifdef EMISSIVEASILLUMINATION\r\n\tvec3 finalDiffuse = clamp(diffuseBase * diffuseColor + vAmbientColor, 0.0, 1.0) * baseColor.rgb;\r\n#else\r\n    vec3 finalDiffuse = clamp(diffuseBase * diffuseColor + emissiveColor + vAmbientColor, 0.0, 1.0) * baseColor.rgb;\r\n#endif\r\n\r\n#ifdef SPECULARTERM\r\n\tvec3 finalSpecular = specularBase * specularColor;\r\n#else\r\n\tvec3 finalSpecular = vec3(0.0);\r\n#endif\r\n\r\n#ifdef SPECULAROVERALPHA\r\n\talpha = clamp(alpha + dot(finalSpecular, vec3(0.3, 0.59, 0.11)), 0., 1.);\r\n#endif\r\n\r\n// Composition\r\n#ifdef EMISSIVEASILLUMINATION\r\n    vec4 color = vec4(clamp(finalDiffuse * baseAmbientColor + finalSpecular + reflectionColor + emissiveColor, 0.0, 1.0), alpha);\r\n#else\r\n    vec4 color = vec4(finalDiffuse * baseAmbientColor + finalSpecular + reflectionColor, alpha);\r\n#endif\r\n\r\n#ifdef LIGHTMAP\r\n\tvec3 lightmapColor = texture2D(lightmapSampler, vLightmapUV).rgb * vLightmapInfos.y;\r\n\tfloat lightmapIllum = clamp(dot(lightmapColor, vec3(0.3, 0.59, 0.11)), 0., 1.);\r\n\r\n\tif (lightmapIllum > vLightmapInfos.z)\r\n\t{\r\n\t\tcolor.rgb += lightmapColor;\r\n\t}\r\n\telse\r\n\t{\r\n\t\tcolor.rgb *= lightmapColor;\r\n\t}\r\n#endif\r\n\r\n#ifdef FOG\r\n\tfloat fog = CalcFogFactor();\r\n\tcolor.rgb = fog * color.rgb + (1.0 - fog) * vFogColor;\r\n#endif\r\n\r\n\tgl_FragColor = color;\r\n}",defaultVertexShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Attributes\r\nattribute vec3 position;\r\n#ifdef NORMAL\r\nattribute vec3 normal;\r\n#endif\r\n#ifdef UV1\r\nattribute vec2 uv;\r\n#endif\r\n#ifdef UV2\r\nattribute vec2 uv2;\r\n#endif\r\n#ifdef VERTEXCOLOR\r\nattribute vec4 color;\r\n#endif\r\n#ifdef BONES\r\nattribute vec4 matricesIndices;\r\nattribute vec4 matricesWeights;\r\n#endif\r\n\r\n// Uniforms\r\n\r\n#ifdef INSTANCES\r\nattribute vec4 world0;\r\nattribute vec4 world1;\r\nattribute vec4 world2;\r\nattribute vec4 world3;\r\n#else\r\nuniform mat4 world;\r\n#endif\r\n\r\nuniform mat4 view;\r\nuniform mat4 viewProjection;\r\n\r\n#ifdef DIFFUSE\r\nvarying vec2 vDiffuseUV;\r\nuniform mat4 diffuseMatrix;\r\nuniform vec2 vDiffuseInfos;\r\n#endif\r\n\r\n#ifdef AMBIENT\r\nvarying vec2 vAmbientUV;\r\nuniform mat4 ambientMatrix;\r\nuniform vec2 vAmbientInfos;\r\n#endif\r\n\r\n#ifdef OPACITY\r\nvarying vec2 vOpacityUV;\r\nuniform mat4 opacityMatrix;\r\nuniform vec2 vOpacityInfos;\r\n#endif\r\n\r\n#ifdef EMISSIVE\r\nvarying vec2 vEmissiveUV;\r\nuniform vec2 vEmissiveInfos;\r\nuniform mat4 emissiveMatrix;\r\n#endif\r\n\r\n#ifdef LIGHTMAP\r\nvarying vec2 vLightmapUV;\r\nuniform vec3 vLightmapInfos;\r\nuniform mat4 lightmapMatrix;\r\n#endif\r\n\r\n#if defined(SPECULAR) && defined(SPECULARTERM)\r\nvarying vec2 vSpecularUV;\r\nuniform vec2 vSpecularInfos;\r\nuniform mat4 specularMatrix;\r\n#endif\r\n\r\n#ifdef BUMP\r\nvarying vec2 vBumpUV;\r\nuniform vec2 vBumpInfos;\r\nuniform mat4 bumpMatrix;\r\n#endif\r\n\r\n#ifdef BONES\r\nuniform mat4 mBones[BonesPerMesh];\r\n#endif\r\n\r\n#ifdef POINTSIZE\r\nuniform float pointSize;\r\n#endif\r\n\r\n// Output\r\nvarying vec3 vPositionW;\r\n#ifdef NORMAL\r\nvarying vec3 vNormalW;\r\n#endif\r\n\r\n#ifdef VERTEXCOLOR\r\nvarying vec4 vColor;\r\n#endif\r\n\r\n#ifdef CLIPPLANE\r\nuniform vec4 vClipPlane;\r\nvarying float fClipDistance;\r\n#endif\r\n\r\n#ifdef FOG\r\nvarying float fFogDistance;\r\n#endif\r\n\r\n#ifdef SHADOWS\r\n#ifdef LIGHT0\r\nuniform mat4 lightMatrix0;\r\nvarying vec4 vPositionFromLight0;\r\n#endif\r\n#ifdef LIGHT1\r\nuniform mat4 lightMatrix1;\r\nvarying vec4 vPositionFromLight1;\r\n#endif\r\n#ifdef LIGHT2\r\nuniform mat4 lightMatrix2;\r\nvarying vec4 vPositionFromLight2;\r\n#endif\r\n#ifdef LIGHT3\r\nuniform mat4 lightMatrix3;\r\nvarying vec4 vPositionFromLight3;\r\n#endif\r\n#endif\r\n\r\n#ifdef REFLECTION\r\nuniform vec3 vEyePosition;\r\nvarying vec3 vReflectionUVW;\r\nuniform mat4 reflectionMatrix;\r\n\r\nvec3 computeReflectionCoords(vec4 worldPos, vec3 worldNormal)\r\n{\r\n#ifdef REFLECTIONMAP_SPHERICAL\r\n\tvec3 coords = vec3(view * vec4(worldNormal, 0.0));\r\n\r\n\treturn vec3(reflectionMatrix * vec4(coords, 1.0));\r\n#endif\r\n\r\n#ifdef REFLECTIONMAP_PLANAR\r\n\tvec3 viewDir = worldPos.xyz - vEyePosition;\r\n\tvec3 coords = normalize(reflect(viewDir, worldNormal));\r\n\r\n\treturn vec3(reflectionMatrix * vec4(coords, 1));\r\n#endif\r\n\r\n#ifdef REFLECTIONMAP_CUBIC\r\n\tvec3 viewDir = worldPos.xyz - vEyePosition;\r\n\tvec3 coords = reflect(viewDir, worldNormal);\r\n#ifdef INVERTCUBICMAP\r\n\tcoords.y = 1.0 - coords.y;\r\n#endif\r\n\treturn vec3(reflectionMatrix * vec4(coords, 0));\r\n#endif\r\n\r\n#ifdef REFLECTIONMAP_PROJECTION\r\n\treturn vec3(reflectionMatrix * (view * worldPos));\r\n#endif\r\n\r\n#ifdef REFLECTIONMAP_SKYBOX\r\n\treturn position;\r\n#endif\r\n\r\n#ifdef REFLECTIONMAP_EXPLICIT\r\n\treturn vec3(0, 0, 0);\r\n#endif\r\n}\r\n#endif\r\n\r\nvoid main(void) {\r\n\tmat4 finalWorld;\r\n\r\n#ifdef INSTANCES\r\n\tfinalWorld = mat4(world0, world1, world2, world3);\r\n#else\r\n\tfinalWorld = world;\r\n#endif\r\n\r\n#ifdef BONES\r\n\tmat4 m0 = mBones[int(matricesIndices.x)] * matricesWeights.x;\r\n\tmat4 m1 = mBones[int(matricesIndices.y)] * matricesWeights.y;\r\n\tmat4 m2 = mBones[int(matricesIndices.z)] * matricesWeights.z;\r\n\r\n#ifdef BONES4\r\n\tmat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;\r\n\tfinalWorld = finalWorld * (m0 + m1 + m2 + m3);\r\n#else\r\n\tfinalWorld = finalWorld * (m0 + m1 + m2);\r\n#endif \r\n\r\n#endif\r\n\tgl_Position = viewProjection * finalWorld * vec4(position, 1.0);\r\n\r\n\tvec4 worldPos = finalWorld * vec4(position, 1.0);\r\n\tvPositionW = vec3(worldPos);\r\n\r\n#ifdef NORMAL\r\n\tvNormalW = normalize(vec3(finalWorld * vec4(normal, 0.0)));\r\n#endif\r\n\r\n\t// Texture coordinates\r\n#ifndef UV1\r\n\tvec2 uv = vec2(0., 0.);\r\n#endif\r\n#ifndef UV2\r\n\tvec2 uv2 = vec2(0., 0.);\r\n#endif\r\n\r\n#ifdef DIFFUSE\r\n\tif (vDiffuseInfos.x == 0.)\r\n\t{\r\n\t\tvDiffuseUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));\r\n\t}\r\n\telse\r\n\t{\r\n\t\tvDiffuseUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));\r\n\t}\r\n#endif\r\n\r\n#ifdef AMBIENT\r\n\tif (vAmbientInfos.x == 0.)\r\n\t{\r\n\t\tvAmbientUV = vec2(ambientMatrix * vec4(uv, 1.0, 0.0));\r\n\t}\r\n\telse\r\n\t{\r\n\t\tvAmbientUV = vec2(ambientMatrix * vec4(uv2, 1.0, 0.0));\r\n\t}\r\n#endif\r\n\r\n#ifdef OPACITY\r\n\tif (vOpacityInfos.x == 0.)\r\n\t{\r\n\t\tvOpacityUV = vec2(opacityMatrix * vec4(uv, 1.0, 0.0));\r\n\t}\r\n\telse\r\n\t{\r\n\t\tvOpacityUV = vec2(opacityMatrix * vec4(uv2, 1.0, 0.0));\r\n\t}\r\n#endif\r\n\r\n#ifdef REFLECTION\r\n\tvReflectionUVW = computeReflectionCoords(vec4(vPositionW, 1.0), vNormalW);\r\n#endif\r\n\r\n#ifdef EMISSIVE\r\n\tif (vEmissiveInfos.x == 0.)\r\n\t{\r\n\t\tvEmissiveUV = vec2(emissiveMatrix * vec4(uv, 1.0, 0.0));\r\n\t}\r\n\telse\r\n\t{\r\n\t\tvEmissiveUV = vec2(emissiveMatrix * vec4(uv2, 1.0, 0.0));\r\n\t}\r\n#endif\r\n\r\n#ifdef LIGHTMAP\r\n\tif (vLightmapInfos.x == 0.)\r\n\t{\r\n\t\tvLightmapUV = vec2(lightmapMatrix * vec4(uv, 1.0, 0.0));\r\n\t}\r\n\telse\r\n\t{\r\n\t\tvLightmapUV = vec2(lightmapMatrix * vec4(uv2, 1.0, 0.0));\r\n\t}\r\n#endif\r\n\r\n#if defined(SPECULAR) && defined(SPECULARTERM)\r\n\tif (vSpecularInfos.x == 0.)\r\n\t{\r\n\t\tvSpecularUV = vec2(specularMatrix * vec4(uv, 1.0, 0.0));\r\n\t}\r\n\telse\r\n\t{\r\n\t\tvSpecularUV = vec2(specularMatrix * vec4(uv2, 1.0, 0.0));\r\n\t}\r\n#endif\r\n\r\n#ifdef BUMP\r\n\tif (vBumpInfos.x == 0.)\r\n\t{\r\n\t\tvBumpUV = vec2(bumpMatrix * vec4(uv, 1.0, 0.0));\r\n\t}\r\n\telse\r\n\t{\r\n\t\tvBumpUV = vec2(bumpMatrix * vec4(uv2, 1.0, 0.0));\r\n\t}\r\n#endif\r\n\r\n\t// Clip plane\r\n#ifdef CLIPPLANE\r\n\tfClipDistance = dot(worldPos, vClipPlane);\r\n#endif\r\n\r\n\t// Fog\r\n#ifdef FOG\r\n\tfFogDistance = (view * worldPos).z;\r\n#endif\r\n\r\n\t// Shadows\r\n#ifdef SHADOWS\r\n#ifdef LIGHT0\r\n\tvPositionFromLight0 = lightMatrix0 * worldPos;\r\n#endif\r\n#ifdef LIGHT1\r\n\tvPositionFromLight1 = lightMatrix1 * worldPos;\r\n#endif\r\n#ifdef LIGHT2\r\n\tvPositionFromLight2 = lightMatrix2 * worldPos;\r\n#endif\r\n#ifdef LIGHT3\r\n\tvPositionFromLight3 = lightMatrix3 * worldPos;\r\n#endif\r\n#endif\r\n\r\n\t// Vertex color\r\n#ifdef VERTEXCOLOR\r\n\tvColor = color;\r\n#endif\r\n\r\n\t// Point size\r\n#ifdef POINTSIZE\r\n\tgl_PointSize = pointSize;\r\n#endif\r\n}",depthPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n#ifdef ALPHATEST\r\nvarying vec2 vUV;\r\nuniform sampler2D diffuseSampler;\r\n#endif\r\n\r\nuniform float far;\r\n\r\nvoid main(void)\r\n{\r\n#ifdef ALPHATEST\r\n\tif (texture2D(diffuseSampler, vUV).a < 0.4)\r\n\t\tdiscard;\r\n#endif\r\n\r\n\tfloat depth = (gl_FragCoord.z / gl_FragCoord.w) / far;\r\n\tgl_FragColor = vec4(depth, depth * depth, 0.0, 1.0);\r\n}",depthVertexShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Attribute\r\nattribute vec3 position;\r\n#ifdef BONES\r\nattribute vec4 matricesIndices;\r\nattribute vec4 matricesWeights;\r\n#endif\r\n\r\n// Uniform\r\n#ifdef INSTANCES\r\nattribute vec4 world0;\r\nattribute vec4 world1;\r\nattribute vec4 world2;\r\nattribute vec4 world3;\r\n#else\r\nuniform mat4 world;\r\n#endif\r\n\r\nuniform mat4 viewProjection;\r\n#ifdef BONES\r\nuniform mat4 mBones[BonesPerMesh];\r\n#endif\r\n\r\n#if defined(ALPHATEST) || defined(NEED_UV)\r\nvarying vec2 vUV;\r\nuniform mat4 diffuseMatrix;\r\n#ifdef UV1\r\nattribute vec2 uv;\r\n#endif\r\n#ifdef UV2\r\nattribute vec2 uv2;\r\n#endif\r\n#endif\r\n\r\nvoid main(void)\r\n{\r\n#ifdef INSTANCES\r\n\tmat4 finalWorld = mat4(world0, world1, world2, world3);\r\n#else\r\n\tmat4 finalWorld = world;\r\n#endif\r\n\r\n#ifdef BONES\r\n\tmat4 m0 = mBones[int(matricesIndices.x)] * matricesWeights.x;\r\n\tmat4 m1 = mBones[int(matricesIndices.y)] * matricesWeights.y;\r\n\tmat4 m2 = mBones[int(matricesIndices.z)] * matricesWeights.z;\r\n\tmat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;\r\n\tfinalWorld = finalWorld * (m0 + m1 + m2 + m3);\r\n\tgl_Position = viewProjection * finalWorld * vec4(position, 1.0);\r\n#else\r\n\tgl_Position = viewProjection * finalWorld * vec4(position, 1.0);\r\n#endif\r\n\r\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\r\n#ifdef UV1\r\n\tvUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));\r\n#endif\r\n#ifdef UV2\r\n\tvUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));\r\n#endif\r\n#endif\r\n}",depthBoxBlurPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Samplers\r\nvarying vec2 vUV;\r\nuniform sampler2D textureSampler;\r\n\r\n// Parameters\r\nuniform vec2 screenSize;\r\n\r\nvoid main(void)\r\n{\r\n\tvec4 colorDepth = vec4(0.0);\r\n\r\n\tfor (int x = -OFFSET; x <= OFFSET; x++)\r\n\t\tfor (int y = -OFFSET; y <= OFFSET; y++)\r\n\t\t\tcolorDepth += texture2D(textureSampler, vUV + vec2(x, y) / screenSize);\r\n\r\n\tgl_FragColor = (colorDepth / float((OFFSET * 2 + 1) * (OFFSET * 2 + 1)));\r\n}",depthOfFieldPixelShader:'// BABYLON.JS Depth-of-field GLSL Shader\r\n// Author: Olivier Guyot\r\n// Does depth-of-field blur, edge blur\r\n// Inspired by Francois Tarlier & Martins Upitis\r\n\r\n#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n\r\n// samplers\r\nuniform sampler2D textureSampler;\r\nuniform sampler2D highlightsSampler;\r\nuniform sampler2D depthSampler;\r\nuniform sampler2D grainSampler;\r\n\r\n// uniforms\r\nuniform float grain_amount;\r\nuniform bool blur_noise;\r\nuniform float screen_width;\r\nuniform float screen_height;\r\nuniform float distortion;\r\nuniform bool dof_enabled;\r\n//uniform float focus_distance;\t\t// not needed; already used to compute screen distance\r\nuniform float screen_distance;\t\t// precomputed screen distance from lens center; based on focal length & desired focus distance\r\nuniform float aperture;\r\nuniform float darken;\r\nuniform float edge_blur;\r\nuniform bool highlights;\r\n\r\n// preconputed uniforms (not effect parameters)\r\nuniform float near;\r\nuniform float far;\r\n\r\n// varyings\r\nvarying vec2 vUV;\r\n\r\n// constants\r\n#define PI \t\t3.14159265\r\n#define TWOPI \t6.28318530\r\n#define inverse_focal_length 0.1\t// a property of the lens used\r\n\r\n// common calculations\r\nvec2 centered_screen_pos;\r\nvec2 distorted_coords;\r\nfloat radius2;\r\nfloat radius;\r\n\r\n\r\n// on-the-fly constant noise\r\nvec2 rand(vec2 co)\r\n{\r\n\tfloat noise1 = (fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453));\r\n\tfloat noise2 = (fract(sin(dot(co, vec2(12.9898, 78.233)*2.0)) * 43758.5453));\r\n\treturn clamp(vec2(noise1, noise2), 0.0, 1.0);\r\n}\r\n\r\n// applies edge distortion on texture coords\r\nvec2 getDistortedCoords(vec2 coords) {\r\n\r\n\tif (distortion == 0.0) { return coords; }\r\n\r\n\tvec2 direction = 1.0 * normalize(centered_screen_pos);\r\n\tvec2 dist_coords = vec2(0.5, 0.5);\r\n\tdist_coords.x = 0.5 + direction.x * radius2 * 1.0;\r\n\tdist_coords.y = 0.5 + direction.y * radius2 * 1.0;\r\n\tfloat dist_amount = clamp(distortion*0.23, 0.0, 1.0);\r\n\r\n\tdist_coords = mix(coords, dist_coords, dist_amount);\r\n\r\n\treturn dist_coords;\r\n}\r\n\r\n// sample screen with an offset (randomize offset angle for better smothness), returns partial sample weight\r\nfloat sampleScreen(inout vec4 color, const in vec2 offset, const in float weight) {\r\n\r\n\t// compute coords with offset (a random angle is added)\r\n\tvec2 coords = distorted_coords;\r\n\tfloat angle = rand(coords * 100.0).x * TWOPI;\r\n\tcoords += vec2(offset.x * cos(angle) - offset.y * sin(angle), offset.x * sin(angle) + offset.y * cos(angle));\r\n\r\n\tcolor += texture2D(textureSampler, coords)*weight;\r\n\r\n\treturn weight;\r\n}\r\n\r\n// returns blur level according to blur size required\r\nfloat getBlurLevel(float size) {\r\n\treturn min(3.0, ceil(size / 1.0));\r\n}\r\n\r\n// returns original screen color after blur\r\nvec4 getBlurColor(float size) {\r\n\r\n\tvec4 col = texture2D(textureSampler, distorted_coords);\r\n\tif (size == 0.0) { return col; }\r\n\r\n\t// there are max. 30 samples; the number of samples chosen is dependant on the blur size\r\n\t// there can be 10, 20 or 30 samples chosen; levels of blur are then 1, 2 or 3\r\n\tfloat blur_level = getBlurLevel(size);\r\n\r\n\tfloat w = (size / screen_width);\r\n\tfloat h = (size / screen_height);\r\n\tfloat total_weight = 1.0;\r\n\tvec2 sample_coords;\r\n\r\n\ttotal_weight += sampleScreen(col, vec2(-0.50*w, 0.24*h), 0.93);\r\n\ttotal_weight += sampleScreen(col, vec2(0.30*w, -0.75*h), 0.90);\r\n\ttotal_weight += sampleScreen(col, vec2(0.36*w, 0.96*h), 0.87);\r\n\ttotal_weight += sampleScreen(col, vec2(-1.08*w, -0.55*h), 0.85);\r\n\ttotal_weight += sampleScreen(col, vec2(1.33*w, -0.37*h), 0.83);\r\n\ttotal_weight += sampleScreen(col, vec2(-0.82*w, 1.31*h), 0.80);\r\n\ttotal_weight += sampleScreen(col, vec2(-0.31*w, -1.67*h), 0.78);\r\n\ttotal_weight += sampleScreen(col, vec2(1.47*w, 1.11*h), 0.76);\r\n\ttotal_weight += sampleScreen(col, vec2(-1.97*w, 0.19*h), 0.74);\r\n\ttotal_weight += sampleScreen(col, vec2(1.42*w, -1.57*h), 0.72);\r\n\r\n\tif (blur_level > 1.0) {\r\n\t\ttotal_weight += sampleScreen(col, vec2(0.01*w, 2.25*h), 0.70);\r\n\t\ttotal_weight += sampleScreen(col, vec2(-1.62*w, -1.74*h), 0.67);\r\n\t\ttotal_weight += sampleScreen(col, vec2(2.49*w, 0.20*h), 0.65);\r\n\t\ttotal_weight += sampleScreen(col, vec2(-2.07*w, 1.61*h), 0.63);\r\n\t\ttotal_weight += sampleScreen(col, vec2(0.46*w, -2.70*h), 0.61);\r\n\t\ttotal_weight += sampleScreen(col, vec2(1.55*w, 2.40*h), 0.59);\r\n\t\ttotal_weight += sampleScreen(col, vec2(-2.88*w, -0.75*h), 0.56);\r\n\t\ttotal_weight += sampleScreen(col, vec2(2.73*w, -1.44*h), 0.54);\r\n\t\ttotal_weight += sampleScreen(col, vec2(-1.08*w, 3.02*h), 0.52);\r\n\t\ttotal_weight += sampleScreen(col, vec2(-1.28*w, -3.05*h), 0.49);\r\n\t}\r\n\r\n\tif (blur_level > 2.0) {\r\n\t\ttotal_weight += sampleScreen(col, vec2(3.11*w, 1.43*h), 0.46);\r\n\t\ttotal_weight += sampleScreen(col, vec2(-3.36*w, 1.08*h), 0.44);\r\n\t\ttotal_weight += sampleScreen(col, vec2(1.80*w, -3.16*h), 0.41);\r\n\t\ttotal_weight += sampleScreen(col, vec2(0.83*w, 3.65*h), 0.38);\r\n\t\ttotal_weight += sampleScreen(col, vec2(-3.16*w, -2.19*h), 0.34);\r\n\t\ttotal_weight += sampleScreen(col, vec2(3.92*w, -0.53*h), 0.31);\r\n\t\ttotal_weight += sampleScreen(col, vec2(-2.59*w, 3.12*h), 0.26);\r\n\t\ttotal_weight += sampleScreen(col, vec2(-0.20*w, -4.15*h), 0.22);\r\n\t\ttotal_weight += sampleScreen(col, vec2(3.02*w, 3.00*h), 0.15);\r\n\t}\r\n\r\n\tcol /= total_weight;\t\t// scales color according to weights\r\n\r\n\t\t\t\t\t\t\t\t// darken if out of focus\r\n\tif (darken > 0.0) {\r\n\t\tcol.rgb *= clamp(0.3, 1.0, 1.05 - size*0.5*darken);\r\n\t}\r\n\r\n\t// blur levels debug\r\n\t// if(blur_level == 1.0) { col.b *= 0.5; }\r\n\t// if(blur_level == 2.0) { col.r *= 0.5; }\r\n\t// if(blur_level == 3.0) { col.g *= 0.5; }\r\n\r\n\treturn col;\r\n}\r\n\r\nvoid main(void)\r\n{\r\n\r\n\t// Common calc: position relative to screen center, screen radius, distorted coords, position in texel space\r\n\tcentered_screen_pos = vec2(vUV.x - 0.5, vUV.y - 0.5);\r\n\tradius2 = centered_screen_pos.x*centered_screen_pos.x + centered_screen_pos.y*centered_screen_pos.y;\r\n\tradius = sqrt(radius2);\r\n\tdistorted_coords = getDistortedCoords(vUV);\t\t// we distort the screen coordinates (lens "magnifying" effect)\r\n\tvec2 texels_coords = vec2(vUV.x * screen_width, vUV.y * screen_height);\t// varies from 0 to SCREEN_WIDTH or _HEIGHT\r\n\r\n\tfloat depth = texture2D(depthSampler, distorted_coords).r;\t// depth value from DepthRenderer: 0 to 1\r\n\tfloat distance = near + (far - near)*depth;\t\t// actual distance from the lens\r\n\tvec4 color = texture2D(textureSampler, vUV);\t// original raster\r\n\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t// compute the circle of confusion size (CoC), i.e. blur radius depending on depth\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t// screen_distance is precomputed in code\r\n\tfloat coc = abs(aperture * (screen_distance * (inverse_focal_length - 1.0 / distance) - 1.0));\r\n\r\n\t// disable blur\r\n\tif (dof_enabled == false || coc < 0.07) { coc = 0.0; }\r\n\r\n\t// blur from edge blur effect\r\n\tfloat edge_blur_amount = 0.0;\r\n\tif (edge_blur > 0.0) {\r\n\t\tedge_blur_amount = clamp((radius*2.0 - 1.0 + 0.15*edge_blur) * 1.5, 0.0, 1.0) * 1.3;\r\n\t}\r\n\r\n\t// total blur amount\r\n\tfloat blur_amount = max(edge_blur_amount, coc);\r\n\r\n\t// apply blur if necessary\r\n\tif (blur_amount == 0.0) {\r\n\t\tgl_FragColor = texture2D(textureSampler, distorted_coords);\r\n\t}\r\n\telse {\r\n\r\n\t\t// add blurred color\r\n\t\tgl_FragColor = getBlurColor(blur_amount * 1.7);\r\n\r\n\t\t// if we have computed highlights: enhance highlights\r\n\t\tif (highlights) {\r\n\t\t\tgl_FragColor.rgb += clamp(coc, 0.0, 1.0)*texture2D(highlightsSampler, distorted_coords).rgb;\r\n\t\t}\r\n\r\n\t\tif (blur_noise) {\r\n\t\t\t// we put a slight amount of noise in the blurred color\r\n\t\t\tvec2 noise = rand(distorted_coords) * 0.01 * blur_amount;\r\n\t\t\tvec2 blurred_coord = vec2(distorted_coords.x + noise.x, distorted_coords.y + noise.y);\r\n\t\t\tgl_FragColor = 0.04 * texture2D(textureSampler, blurred_coord) + 0.96 * gl_FragColor;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t// apply grain\r\n\tif (grain_amount > 0.0) {\r\n\t\tvec4 grain_color = texture2D(grainSampler, texels_coords*0.003);\r\n\t\tgl_FragColor.rgb += (-0.5 + grain_color.rgb) * 0.30 * grain_amount;\r\n\t}\r\n\r\n}\r\n',displayPassPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Samplers\r\nvarying vec2 vUV;\r\nuniform sampler2D textureSampler;\r\nuniform sampler2D passSampler;\r\n\r\nvoid main(void)\r\n{\r\n    gl_FragColor = texture2D(passSampler, vUV);\r\n}",filterPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Samplers\r\nvarying vec2 vUV;\r\nuniform sampler2D textureSampler;\r\n\r\nuniform mat4 kernelMatrix;\r\n\r\nvoid main(void)\r\n{\r\n\tvec3 baseColor = texture2D(textureSampler, vUV).rgb;\r\n\tvec3 updatedColor = (kernelMatrix * vec4(baseColor, 1.0)).rgb;\r\n\r\n\tgl_FragColor = vec4(updatedColor, 1.0);\r\n}",firePixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\nuniform float time;\r\nuniform vec3 c1;\r\nuniform vec3 c2;\r\nuniform vec3 c3;\r\nuniform vec3 c4;\r\nuniform vec3 c5;\r\nuniform vec3 c6;\r\nuniform vec2 speed;\r\nuniform float shift;\r\nuniform float alphaThreshold;\r\n\r\nvarying vec2 vUV;\r\n\r\nfloat rand(vec2 n) {\r\n\treturn fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);\r\n}\r\n\r\nfloat noise(vec2 n) {\r\n\tconst vec2 d = vec2(0.0, 1.0);\r\n\tvec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));\r\n\treturn mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);\r\n}\r\n\r\nfloat fbm(vec2 n) {\r\n\tfloat total = 0.0, amplitude = 1.0;\r\n\tfor (int i = 0; i < 4; i++) {\r\n\t\ttotal += noise(n) * amplitude;\r\n\t\tn += n;\r\n\t\tamplitude *= 0.5;\r\n\t}\r\n\treturn total;\r\n}\r\n\r\nvoid main() {\r\n\tvec2 p = vUV * 8.0;\r\n\tfloat q = fbm(p - time * 0.1);\r\n\tvec2 r = vec2(fbm(p + q + time * speed.x - p.x - p.y), fbm(p + q - time * speed.y));\r\n\tvec3 c = mix(c1, c2, fbm(p + r)) + mix(c3, c4, r.x) - mix(c5, c6, r.y);\r\n\tvec3 color = c * cos(shift * vUV.y);\r\n\tfloat luminance = dot(color.rgb, vec3(0.3, 0.59, 0.11));\r\n\r\n\tgl_FragColor = vec4(color, luminance * alphaThreshold + (1.0 - alphaThreshold));\r\n}",fxaaPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n#define FXAA_REDUCE_MIN  (1.0/128.0)\r\n#define FXAA_REDUCE_MUL  (1.0/8.0)\r\n#define FXAA_SPAN_MAX    8.0\r\n\r\nvarying vec2 vUV;\r\nuniform sampler2D textureSampler;\r\nuniform vec2 texelSize;\r\n\r\nvoid main(){\r\n\tvec2 localTexelSize = texelSize;\r\n\tvec4 rgbNW = texture2D(textureSampler, (vUV + vec2(-1.0, -1.0) * localTexelSize));\r\n\tvec4 rgbNE = texture2D(textureSampler, (vUV + vec2(1.0, -1.0) * localTexelSize));\r\n\tvec4 rgbSW = texture2D(textureSampler, (vUV + vec2(-1.0, 1.0) * localTexelSize));\r\n\tvec4 rgbSE = texture2D(textureSampler, (vUV + vec2(1.0, 1.0) * localTexelSize));\r\n\tvec4 rgbM = texture2D(textureSampler, vUV);\r\n\tvec4 luma = vec4(0.299, 0.587, 0.114, 1.0);\r\n\tfloat lumaNW = dot(rgbNW, luma);\r\n\tfloat lumaNE = dot(rgbNE, luma);\r\n\tfloat lumaSW = dot(rgbSW, luma);\r\n\tfloat lumaSE = dot(rgbSE, luma);\r\n\tfloat lumaM = dot(rgbM, luma);\r\n\tfloat lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\r\n\tfloat lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\r\n\r\n\tvec2 dir = vec2(-((lumaNW + lumaNE) - (lumaSW + lumaSE)), ((lumaNW + lumaSW) - (lumaNE + lumaSE)));\r\n\r\n\tfloat dirReduce = max(\r\n\t\t(lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL),\r\n\t\tFXAA_REDUCE_MIN);\r\n\r\n\tfloat rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\r\n\tdir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),\r\n\t\tmax(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\r\n\t\tdir * rcpDirMin)) * localTexelSize;\r\n\r\n\tvec4 rgbA = 0.5 * (\r\n\t\ttexture2D(textureSampler, vUV + dir * (1.0 / 3.0 - 0.5)) +\r\n\t\ttexture2D(textureSampler, vUV + dir * (2.0 / 3.0 - 0.5)));\r\n\r\n\tvec4 rgbB = rgbA * 0.5 + 0.25 * (\r\n\t\ttexture2D(textureSampler, vUV + dir *  -0.5) +\r\n\t\ttexture2D(textureSampler, vUV + dir * 0.5));\r\n\tfloat lumaB = dot(rgbB, luma);\r\n\tif ((lumaB < lumaMin) || (lumaB > lumaMax)) {\r\n\t\tgl_FragColor = rgbA;\r\n\t}\r\n\telse {\r\n\t\tgl_FragColor = rgbB;\r\n\t}\r\n}",grassPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\nvarying vec2 vPosition;\r\nvarying vec2 vUV;\r\n\r\nuniform vec3 herb1Color;\r\nuniform vec3 herb2Color;\r\nuniform vec3 herb3Color;\r\nuniform vec3 groundColor;\r\n\r\nfloat rand(vec2 n) {\r\n\treturn fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);\r\n}\r\n\r\nfloat noise(vec2 n) {\r\n\tconst vec2 d = vec2(0.0, 1.0);\r\n\tvec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));\r\n\treturn mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);\r\n}\r\n\r\nfloat fbm(vec2 n) {\r\n\tfloat total = 0.0, amplitude = 1.0;\r\n\tfor (int i = 0; i < 4; i++) {\r\n\t\ttotal += noise(n) * amplitude;\r\n\t\tn += n;\r\n\t\tamplitude *= 0.5;\r\n\t}\r\n\treturn total;\r\n}\r\n\r\nvoid main(void) {\r\n\tvec3 color = mix(groundColor, herb1Color, rand(gl_FragCoord.xy * 4.0));\r\n\tcolor = mix(color, herb2Color, rand(gl_FragCoord.xy * 8.0));\r\n\tcolor = mix(color, herb3Color, rand(gl_FragCoord.xy));\r\n\tcolor = mix(color, herb1Color, fbm(gl_FragCoord.xy * 16.0));\r\n\tgl_FragColor = vec4(color, 1.0);\r\n}",hdrPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\nuniform sampler2D textureSampler;\r\nvarying vec2 vUV;\r\n\r\n#if defined(GAUSSIAN_BLUR_H) || defined(GAUSSIAN_BLUR_V)\r\nuniform float blurOffsets[9];\r\nuniform float blurWeights[9];\r\n\r\nvoid main(void) {\r\n\tvec4 color = vec4(0.0, 0.0, 0.0, 0.0);\r\n\r\n\tfor (int i = 0; i < 9; i++) {\r\n\t\t#ifdef GAUSSIAN_BLUR_H\r\n\t\tcolor += (texture2D(textureSampler, vUV + vec2(blurOffsets[i], 0.0)) * blurWeights[i]);\r\n\t\t#else\r\n\t\tcolor += (texture2D(textureSampler, vUV + vec2(0.0, blurOffsets[i])) * blurWeights[i]);\r\n\t\t#endif\r\n\t}\r\n\r\n\tcolor.a = 1.0;\r\n\tgl_FragColor = color;\r\n}\r\n#endif\r\n\r\n#if defined(TEXTURE_ADDER)\r\nuniform sampler2D otherSampler;\r\n\r\nvoid main() {\r\n\tvec4 sum = texture2D(textureSampler, vUV) + texture2D(otherSampler, vUV);\r\n\tsum.a = clamp(sum.a, 0.0, 1.0);\r\n\r\n\tgl_FragColor = sum;\r\n}\r\n#endif\r\n\r\n#if defined(LUMINANCE_GENERATOR)\r\nuniform vec2 lumOffsets[4];\r\n\r\nvoid main() {\r\n\tfloat average = 0.0;\r\n\tvec4 color = vec4(0.0, 0.0, 0.0, 0.0);\r\n\tfloat maximum = -1e20;\r\n\r\n\tfor (int i = 0; i < 4; i++) {\r\n\t\tcolor = texture2D(textureSampler, vUV + lumOffsets[i]);\r\n\r\n\t\tfloat GreyValue = length(color.rgb);\r\n\r\n\t\tmaximum = max(maximum, GreyValue);\r\n\t\taverage += (0.25 * log(1e-5 + GreyValue));\r\n\t}\r\n\r\n\taverage = exp(average);\r\n\r\n\tgl_FragColor = vec4(average, maximum, 0.0, 1.0);\r\n\r\n}\r\n#endif\r\n\r\n#if defined(DOWN_SAMPLE)\r\nuniform vec2 dsOffsets[9];\r\nuniform float halfDestPixelSize;\r\n\r\n#ifdef FINAL_DOWN_SAMPLE\r\nvec4 pack(float value) {\r\n\tconst vec4 bit_shift = vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0);\r\n\tconst vec4 bit_mask = vec4(0.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);\r\n\r\n\tvec4 res = fract(value * bit_shift);\r\n\tres -= res.xxyz * bit_mask;\r\n\r\n\treturn res;\r\n}\r\n#endif\r\n\r\nvoid main() {\r\n\tvec4 color = vec4(0.0, 0.0, 0.0, 0.0);\r\n\tfloat average = 0.0;\r\n\r\n\tfor (int i = 0; i < 9; i++) {\r\n\t\tcolor = texture2D(textureSampler, vUV + vec2(halfDestPixelSize, halfDestPixelSize) + dsOffsets[i]);\r\n\t\taverage += color.r;\r\n\t}\r\n\r\n\taverage /= 9.0;\r\n\r\n\t#ifndef FINAL_DOWN_SAMPLE\r\n\tgl_FragColor = vec4(average, average, 0.0, 1.0);\r\n\t#else\r\n\tgl_FragColor = pack(average);\r\n\t#endif\r\n}\r\n#endif\r\n\r\n#if defined(BRIGHT_PASS)\r\nuniform vec2 dsOffsets[4];\r\nuniform float brightThreshold;\r\n\r\nvoid main() {\r\n\tvec4 average = vec4(0.0, 0.0, 0.0, 0.0);\r\n\r\n\taverage = texture2D(textureSampler, vUV + vec2(dsOffsets[0].x, dsOffsets[0].y));\r\n\taverage += texture2D(textureSampler, vUV + vec2(dsOffsets[1].x, dsOffsets[1].y));\r\n\taverage += texture2D(textureSampler, vUV + vec2(dsOffsets[2].x, dsOffsets[2].y));\r\n\taverage += texture2D(textureSampler, vUV + vec2(dsOffsets[3].x, dsOffsets[3].y));\r\n\r\n\taverage *= 0.25;\r\n\r\n\tfloat luminance = length(average.rgb);\r\n\r\n\tif (luminance < brightThreshold) {\r\n\t\taverage = vec4(0.0, 0.0, 0.0, 1.0);\r\n\t}\r\n\r\n\tgl_FragColor = average;\r\n}\r\n#endif\r\n\r\n#if defined(DOWN_SAMPLE_X4)\r\nuniform vec2 dsOffsets[16];\r\n\r\nvoid main() {\r\n\tvec4 average = vec4(0.0, 0.0, 0.0, 0.0);\r\n\r\n\taverage = texture2D(textureSampler, vUV + dsOffsets[0]);\r\n\taverage += texture2D(textureSampler, vUV + dsOffsets[1]);\r\n\taverage += texture2D(textureSampler, vUV + dsOffsets[2]);\r\n\taverage += texture2D(textureSampler, vUV + dsOffsets[3]);\r\n\taverage += texture2D(textureSampler, vUV + dsOffsets[4]);\r\n\taverage += texture2D(textureSampler, vUV + dsOffsets[5]);\r\n\taverage += texture2D(textureSampler, vUV + dsOffsets[6]);\r\n\taverage += texture2D(textureSampler, vUV + dsOffsets[7]);\r\n\taverage += texture2D(textureSampler, vUV + dsOffsets[8]);\r\n\taverage += texture2D(textureSampler, vUV + dsOffsets[9]);\r\n\taverage += texture2D(textureSampler, vUV + dsOffsets[10]);\r\n\taverage += texture2D(textureSampler, vUV + dsOffsets[11]);\r\n\taverage += texture2D(textureSampler, vUV + dsOffsets[12]);\r\n\taverage += texture2D(textureSampler, vUV + dsOffsets[13]);\r\n\taverage += texture2D(textureSampler, vUV + dsOffsets[14]);\r\n\taverage += texture2D(textureSampler, vUV + dsOffsets[15]);\r\n\r\n\taverage /= 16.0;\r\n\r\n\tgl_FragColor = average;\r\n}\r\n#endif\r\n\r\n#if defined(HDR)\r\nuniform sampler2D otherSampler;\r\n\r\nuniform float exposure;\r\nuniform float avgLuminance;\r\n\r\nvoid main() {\r\n\tvec4 color = texture2D(textureSampler, vUV) + texture2D(otherSampler, vUV);\r\n\tvec4 adjustedColor = color / avgLuminance * exposure;\r\n\r\n\tcolor = adjustedColor;\r\n\tcolor.a = 1.0;\r\n\r\n\tgl_FragColor = color;\r\n}\r\n#endif\r\n",layerPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Samplers\r\nvarying vec2 vUV;\r\nuniform sampler2D textureSampler;\r\n\r\n// Color\r\nuniform vec4 color;\r\n\r\nvoid main(void) {\r\n\tvec4 baseColor = texture2D(textureSampler, vUV);\r\n\r\n\tgl_FragColor = baseColor * color;\r\n}",layerVertexShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Attributes\r\nattribute vec2 position;\r\n\r\n// Uniforms\r\nuniform mat4 textureMatrix;\r\n\r\n// Output\r\nvarying vec2 vUV;\r\n\r\nconst vec2 madd = vec2(0.5, 0.5);\r\n\r\nvoid main(void) {\t\r\n\r\n\tvUV = vec2(textureMatrix * vec4(position * madd + madd, 1.0, 0.0));\r\n\tgl_Position = vec4(position, 0.0, 1.0);\r\n}",legacydefaultPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n#define MAP_PROJECTION\t4.\r\n\r\n// Constants\r\nuniform vec3 vEyePosition;\r\nuniform vec3 vAmbientColor;\r\nuniform vec4 vDiffuseColor;\r\n#ifdef SPECULARTERM\r\nuniform vec4 vSpecularColor;\r\n#endif\r\nuniform vec3 vEmissiveColor;\r\n\r\n// Input\r\nvarying vec3 vPositionW;\r\nvarying vec3 vNormalW;\r\n\r\n#ifdef VERTEXCOLOR\r\nvarying vec4 vColor;\r\n#endif\r\n\r\n// Lights\r\n#ifdef LIGHT0\r\nuniform vec4 vLightData0;\r\nuniform vec4 vLightDiffuse0;\r\n#ifdef SPECULARTERM\r\nuniform vec3 vLightSpecular0;\r\n#endif\r\n#ifdef SHADOW0\r\nvarying vec4 vPositionFromLight0;\r\nuniform sampler2D shadowSampler0;\r\n#endif\r\n#ifdef SPOTLIGHT0\r\nuniform vec4 vLightDirection0;\r\n#endif\r\n#ifdef HEMILIGHT0\r\nuniform vec3 vLightGround0;\r\n#endif\r\n#endif\r\n\r\n#ifdef LIGHT1\r\nuniform vec4 vLightData1;\r\nuniform vec4 vLightDiffuse1;\r\n#ifdef SPECULARTERM\r\nuniform vec3 vLightSpecular1;\r\n#endif\r\n#ifdef SHADOW1\r\nvarying vec4 vPositionFromLight1;\r\nuniform sampler2D shadowSampler1;\r\n#endif\r\n#ifdef SPOTLIGHT1\r\nuniform vec4 vLightDirection1;\r\n#endif\r\n#ifdef HEMILIGHT1\r\nuniform vec3 vLightGround1;\r\n#endif\r\n#endif\r\n\r\n#ifdef LIGHT2\r\nuniform vec4 vLightData2;\r\nuniform vec4 vLightDiffuse2;\r\n#ifdef SPECULARTERM\r\nuniform vec3 vLightSpecular2;\r\n#endif\r\n#ifdef SHADOW2\r\nvarying vec4 vPositionFromLight2;\r\nuniform sampler2D shadowSampler2;\r\n#endif\r\n#ifdef SPOTLIGHT2\r\nuniform vec4 vLightDirection2;\r\n#endif\r\n#ifdef HEMILIGHT2\r\nuniform vec3 vLightGround2;\r\n#endif\r\n#endif\r\n\r\n#ifdef LIGHT3\r\nuniform vec4 vLightData3;\r\nuniform vec4 vLightDiffuse3;\r\n#ifdef SPECULARTERM\r\nuniform vec3 vLightSpecular3;\r\n#endif\r\n#ifdef SHADOW3\r\nvarying vec4 vPositionFromLight3;\r\nuniform sampler2D shadowSampler3;\r\n#endif\r\n#ifdef SPOTLIGHT3\r\nuniform vec4 vLightDirection3;\r\n#endif\r\n#ifdef HEMILIGHT3\r\nuniform vec3 vLightGround3;\r\n#endif\r\n#endif\r\n\r\n// Samplers\r\n#ifdef DIFFUSE\r\nvarying vec2 vDiffuseUV;\r\nuniform sampler2D diffuseSampler;\r\nuniform vec2 vDiffuseInfos;\r\n#endif\r\n\r\n#ifdef AMBIENT\r\nvarying vec2 vAmbientUV;\r\nuniform sampler2D ambientSampler;\r\nuniform vec2 vAmbientInfos;\r\n#endif\r\n\r\n#ifdef OPACITY\t\r\nvarying vec2 vOpacityUV;\r\nuniform sampler2D opacitySampler;\r\nuniform vec2 vOpacityInfos;\r\n#endif\r\n\r\n#ifdef REFLECTION\r\nvarying vec3 vReflectionUVW;\r\n#ifdef REFLECTIONMAP_3D\r\nuniform samplerCube reflectionCubeSampler;\r\n#else\r\nuniform sampler2D reflection2DSampler;\r\n#endif\r\nuniform vec2 vReflectionInfos;\r\n#endif\r\n\r\n#ifdef EMISSIVE\r\nvarying vec2 vEmissiveUV;\r\nuniform vec2 vEmissiveInfos;\r\nuniform sampler2D emissiveSampler;\r\n#endif\r\n\r\n#if defined(SPECULAR) && defined(SPECULARTERM)\r\nvarying vec2 vSpecularUV;\r\nuniform vec2 vSpecularInfos;\r\nuniform sampler2D specularSampler;\r\n#endif\r\n\r\n// Fresnel\r\n#ifdef FRESNEL\r\nfloat computeFresnelTerm(vec3 viewDirection, vec3 worldNormal, float bias, float power)\r\n{\r\n\tfloat fresnelTerm = pow(bias + abs(dot(viewDirection, worldNormal)), power);\r\n\treturn clamp(fresnelTerm, 0., 1.);\r\n}\r\n#endif\r\n\r\n#ifdef DIFFUSEFRESNEL\r\nuniform vec4 diffuseLeftColor;\r\nuniform vec4 diffuseRightColor;\r\n#endif\r\n\r\n#ifdef OPACITYFRESNEL\r\nuniform vec4 opacityParts;\r\n#endif\r\n\r\n#ifdef REFLECTIONFRESNEL\r\nuniform vec4 reflectionLeftColor;\r\nuniform vec4 reflectionRightColor;\r\n#endif\r\n\r\n#ifdef EMISSIVEFRESNEL\r\nuniform vec4 emissiveLeftColor;\r\nuniform vec4 emissiveRightColor;\r\n#endif\r\n\r\n// Shadows\r\n#ifdef SHADOWS\r\n\r\nfloat unpack(vec4 color)\r\n{\r\n\tconst vec4 bitShift = vec4(1. / (255. * 255. * 255.), 1. / (255. * 255.), 1. / 255., 1.);\r\n\treturn dot(color, bitShift);\r\n}\r\n\r\nfloat unpackHalf(vec2 color)\r\n{\r\n\treturn color.x + (color.y / 255.0);\r\n}\r\n\r\nfloat computeShadow(vec4 vPositionFromLight, sampler2D shadowSampler)\r\n{\r\n\tvec3 depth = vPositionFromLight.xyz / vPositionFromLight.w;\r\n\tvec2 uv = 0.5 * depth.xy + vec2(0.5, 0.5);\r\n\r\n\tif (uv.x < 0. || uv.x > 1.0 || uv.y < 0. || uv.y > 1.0)\r\n\t{\r\n\t\treturn 1.0;\r\n\t}\r\n\r\n\tfloat shadow = unpack(texture2D(shadowSampler, uv));\r\n\r\n\tif (depth.z > shadow)\r\n\t{\r\n\t\treturn 0.;\r\n\t}\r\n\treturn 1.;\r\n}\r\n\r\n// Thanks to http://devmaster.net/\r\nfloat ChebychevInequality(vec2 moments, float t)\r\n{\r\n\tif (t <= moments.x)\r\n\t{\r\n\t\treturn 1.0;\r\n\t}\r\n\r\n\tfloat variance = moments.y - (moments.x * moments.x);\r\n\tvariance = max(variance, 0.);\r\n\r\n\tfloat d = t - moments.x;\r\n\treturn variance / (variance + d * d);\r\n}\r\n\r\nfloat computeShadowWithVSM(vec4 vPositionFromLight, sampler2D shadowSampler)\r\n{\r\n\tvec3 depth = vPositionFromLight.xyz / vPositionFromLight.w;\r\n\tvec2 uv = 0.5 * depth.xy + vec2(0.5, 0.5);\r\n\r\n\tif (uv.x < 0. || uv.x > 1.0 || uv.y < 0. || uv.y > 1.0)\r\n\t{\r\n\t\treturn 1.0;\r\n\t}\r\n\r\n\tvec4 texel = texture2D(shadowSampler, uv);\r\n\r\n\tvec2 moments = vec2(unpackHalf(texel.xy), unpackHalf(texel.zw));\r\n\treturn clamp(1.3 - ChebychevInequality(moments, depth.z), 0., 1.0);\r\n}\r\n#endif\r\n\r\n#ifdef CLIPPLANE\r\nvarying float fClipDistance;\r\n#endif\r\n\r\n// Fog\r\n#ifdef FOG\r\n\r\n#define FOGMODE_NONE    0.\r\n#define FOGMODE_EXP    1.\r\n#define FOGMODE_EXP2    2.\r\n#define FOGMODE_LINEAR  3.\r\n#define E 2.71828\r\n\r\nuniform vec4 vFogInfos;\r\nuniform vec3 vFogColor;\r\nvarying float fFogDistance;\r\n\r\nfloat CalcFogFactor()\r\n{\r\n\tfloat fogCoeff = 1.0;\r\n\tfloat fogStart = vFogInfos.y;\r\n\tfloat fogEnd = vFogInfos.z;\r\n\tfloat fogDensity = vFogInfos.w;\r\n\r\n\tif (FOGMODE_LINEAR == vFogInfos.x)\r\n\t{\r\n\t\tfogCoeff = (fogEnd - fFogDistance) / (fogEnd - fogStart);\r\n\t}\r\n\telse if (FOGMODE_EXP == vFogInfos.x)\r\n\t{\r\n\t\tfogCoeff = 1.0 / pow(E, fFogDistance * fogDensity);\r\n\t}\r\n\telse if (FOGMODE_EXP2 == vFogInfos.x)\r\n\t{\r\n\t\tfogCoeff = 1.0 / pow(E, fFogDistance * fFogDistance * fogDensity * fogDensity);\r\n\t}\r\n\r\n\treturn clamp(fogCoeff, 0.0, 1.0);\r\n}\r\n#endif\r\n\r\n// Light Computing\r\nmat3 computeLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec4 diffuseColor, vec3 specularColor) {\r\n\tmat3 result;\r\n\r\n\tvec3 lightVectorW;\r\n\tif (lightData.w == 0.)\r\n\t{\r\n\t\tlightVectorW = normalize(lightData.xyz - vPositionW);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tlightVectorW = normalize(-lightData.xyz);\r\n\t}\r\n\r\n\t// diffuse\r\n\tfloat ndl = max(0., dot(vNormal, lightVectorW));\r\n\r\n\tresult[0] = ndl * diffuseColor.rgb;\r\n\r\n#ifdef SPECULARTERM\r\n\t// Specular\r\n\tvec3 angleW = normalize(viewDirectionW + lightVectorW);\r\n\tfloat specComp = max(0., dot(vNormal, angleW));\r\n\tspecComp = max(0., pow(specComp, max(1.0, vSpecularColor.a)));\r\n\tresult[1] = specComp * specularColor;\r\n#else\r\n\tresult[1] = vec3(0.);\r\n#endif\r\n\r\n\tresult[2] = vec3(0.);\r\n\r\n\treturn result;\r\n}\r\n\r\nmat3 computeSpotLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec4 lightDirection, vec4 diffuseColor, vec3 specularColor) {\r\n\tmat3 result;\r\n\r\n\tvec3 lightVectorW = normalize(lightData.xyz - vPositionW);\r\n\r\n\t// diffuse\r\n\tfloat cosAngle = max(0., dot(-lightDirection.xyz, lightVectorW));\r\n\tfloat spotAtten = 0.0;\r\n\r\n\tif (cosAngle >= lightDirection.w)\r\n\t{\r\n\t\tcosAngle = max(0., pow(cosAngle, lightData.w));\r\n\t\tspotAtten = max(0., (cosAngle - lightDirection.w) / (1. - cosAngle));\r\n\r\n\t\t// Diffuse\r\n\t\tfloat ndl = max(0., dot(vNormal, -lightDirection.xyz));\r\n\t\tresult[0] = ndl * spotAtten * diffuseColor.rgb;\r\n\r\n#ifdef SPECULARTERM\r\n\t\t// Specular\r\n\t\tvec3 angleW = normalize(viewDirectionW - lightDirection.xyz);\r\n\t\tfloat specComp = max(0., dot(vNormal, angleW));\r\n\t\tspecComp = pow(specComp, vSpecularColor.a);\r\n\t\tresult[1] = specComp * specularColor * spotAtten;\r\n#else\r\n\t\tresult[1] = vec3(0.);\r\n#endif\r\n\t\tresult[2] = vec3(0.);\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\tresult[0] = vec3(0.);\r\n\tresult[1] = vec3(0.);\r\n\tresult[2] = vec3(0.);\r\n\r\n\treturn result;\r\n}\r\n\r\nmat3 computeHemisphericLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec4 diffuseColor, vec3 specularColor, vec3 groundColor) {\r\n\tmat3 result;\r\n\r\n\t// Diffuse\r\n\tfloat ndl = dot(vNormal, lightData.xyz) * 0.5 + 0.5;\r\n\tresult[0] = mix(groundColor, diffuseColor.rgb, ndl);\r\n\r\n#ifdef SPECULARTERM\r\n\t// Specular\r\n\tvec3 angleW = normalize(viewDirectionW + lightData.xyz);\r\n\tfloat specComp = max(0., dot(vNormal, angleW));\r\n\tspecComp = pow(specComp, vSpecularColor.a);\r\n\tresult[1] = specComp * specularColor;\r\n#else\r\n\tresult[1] = vec3(0.);\r\n#endif\r\n\r\n\tresult[2] = vec3(0.);\r\n\r\n\treturn result;\r\n}\r\n\r\nvoid main(void) {\r\n\t// Clip plane\r\n#ifdef CLIPPLANE\r\n\tif (fClipDistance > 0.0)\r\n\t\tdiscard;\r\n#endif\r\n\r\n\tvec3 viewDirectionW = normalize(vEyePosition - vPositionW);\r\n\r\n\t// Base color\r\n\tvec4 baseColor = vec4(1., 1., 1., 1.);\r\n\tvec3 diffuseColor = vDiffuseColor.rgb;\r\n\r\n#ifdef DIFFUSE\r\n\tbaseColor = texture2D(diffuseSampler, vDiffuseUV);\r\n\r\n#ifdef ALPHATEST\r\n\tif (baseColor.a < 0.4)\r\n\t\tdiscard;\r\n#endif\r\n\r\n\tbaseColor.rgb *= vDiffuseInfos.y;\r\n#endif\r\n\r\n#ifdef VERTEXCOLOR\r\n\tbaseColor.rgb *= vColor.rgb;\r\n#endif\r\n\r\n\t// Bump\r\n\tvec3 normalW = normalize(vNormalW);\r\n\r\n\t// Ambient color\r\n\tvec3 baseAmbientColor = vec3(1., 1., 1.);\r\n\r\n#ifdef AMBIENT\r\n\tbaseAmbientColor = texture2D(ambientSampler, vAmbientUV).rgb * vAmbientInfos.y;\r\n#endif\r\n\r\n\t// Lighting\r\n\tvec3 diffuseBase = vec3(0., 0., 0.);\r\n#ifdef SPECULARTERM\r\n\tvec3 specularBase = vec3(0., 0., 0.);\r\n#endif\r\n\tfloat shadow = 1.;\r\n\r\n#ifdef LIGHT0\r\n#ifndef SPECULARTERM\r\n\tvec3 vLightSpecular0 = vec3(0.0);\r\n#endif\r\n#ifdef SPOTLIGHT0\r\n\tmat3 info = computeSpotLighting(viewDirectionW, normalW, vLightData0, vLightDirection0, vLightDiffuse0, vLightSpecular0);\r\n#endif\r\n#ifdef HEMILIGHT0\r\n\tmat3 info = computeHemisphericLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0, vLightSpecular0, vLightGround0);\r\n#endif\r\n#ifdef POINTDIRLIGHT0\r\n\tmat3 info = computeLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0, vLightSpecular0);\r\n#endif\r\n#ifdef SHADOW0\r\n#ifdef SHADOWVSM0\r\n\tshadow = computeShadowWithVSM(vPositionFromLight0, shadowSampler0);\r\n#else\r\n\tshadow = computeShadow(vPositionFromLight0, shadowSampler0);\r\n#endif\r\n#else\r\n\tshadow = 1.;\r\n#endif\r\n\tdiffuseBase += info[0] * shadow;\r\n#ifdef SPECULARTERM\r\n\tspecularBase += info[1] * shadow;\r\n#endif\r\n#endif\r\n\r\n#ifdef LIGHT1\r\n#ifndef SPECULARTERM\r\n\tvec3 vLightSpecular1 = vec3(0.0);\r\n#endif\r\n#ifdef SPOTLIGHT1\r\n\tinfo = computeSpotLighting(viewDirectionW, normalW, vLightData1, vLightDirection1, vLightDiffuse1, vLightSpecular1);\r\n#endif\r\n#ifdef HEMILIGHT1\r\n\tinfo = computeHemisphericLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1, vLightSpecular1, vLightGround1);\r\n#endif\r\n#ifdef POINTDIRLIGHT1\r\n\tinfo = computeLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1, vLightSpecular1);\r\n#endif\r\n#ifdef SHADOW1\r\n#ifdef SHADOWVSM1\r\n\tshadow = computeShadowWithVSM(vPositionFromLight1, shadowSampler1);\r\n#else\r\n\tshadow = computeShadow(vPositionFromLight1, shadowSampler1);\r\n#endif\r\n#else\r\n\tshadow = 1.;\r\n#endif\r\n\tdiffuseBase += info[0] * shadow;\r\n#ifdef SPECULARTERM\r\n\tspecularBase += info[1] * shadow;\r\n#endif\r\n#endif\r\n\r\n#ifdef LIGHT2\r\n#ifndef SPECULARTERM\r\n\tvec3 vLightSpecular2 = vec3(0.0);\r\n#endif\r\n#ifdef SPOTLIGHT2\r\n\tinfo = computeSpotLighting(viewDirectionW, normalW, vLightData2, vLightDirection2, vLightDiffuse2, vLightSpecular2);\r\n#endif\r\n#ifdef HEMILIGHT2\r\n\tinfo = computeHemisphericLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2, vLightSpecular2, vLightGround2);\r\n#endif\r\n#ifdef POINTDIRLIGHT2\r\n\tinfo = computeLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2, vLightSpecular2);\r\n#endif\r\n#ifdef SHADOW2\r\n#ifdef SHADOWVSM2\r\n\tshadow = computeShadowWithVSM(vPositionFromLight2, shadowSampler2);\r\n#else\r\n\tshadow = computeShadow(vPositionFromLight2, shadowSampler2);\r\n#endif\t\r\n#else\r\n\tshadow = 1.;\r\n#endif\r\n\tdiffuseBase += info[0] * shadow;\r\n#ifdef SPECULARTERM\r\n\tspecularBase += info[1] * shadow;\r\n#endif\r\n#endif\r\n\r\n#ifdef LIGHT3\r\n#ifndef SPECULARTERM\r\n\tvec3 vLightSpecular3 = vec3(0.0);\r\n#endif\r\n#ifdef SPOTLIGHT3\r\n\tinfo = computeSpotLighting(viewDirectionW, normalW, vLightData3, vLightDirection3, vLightDiffuse3, vLightSpecular3);\r\n#endif\r\n#ifdef HEMILIGHT3\r\n\tinfo = computeHemisphericLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3, vLightSpecular3, vLightGround3);\r\n#endif\r\n#ifdef POINTDIRLIGHT3\r\n\tinfo = computeLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3, vLightSpecular3);\r\n#endif\r\n#ifdef SHADOW3\r\n#ifdef SHADOWVSM3\r\n\tshadow = computeShadowWithVSM(vPositionFromLight3, shadowSampler3);\r\n#else\r\n\tshadow = computeShadow(vPositionFromLight3, shadowSampler3);\r\n#endif\t\r\n#else\r\n\tshadow = 1.;\r\n#endif\r\n\tdiffuseBase += info[0] * shadow;\r\n#ifdef SPECULARTERM\r\n\tspecularBase += info[1] * shadow;\r\n#endif\r\n#endif\r\n\r\n\t// Reflection\r\n\tvec3 reflectionColor = vec3(0., 0., 0.);\r\n\r\n#ifdef REFLECTION\r\n#ifdef REFLECTIONMAP_3D\r\n\t\treflectionColor = textureCube(reflectionCubeSampler, vReflectionUVW).rgb * vReflectionInfos.x;\r\n#else\r\n\t\tvec2 coords = vReflectionUVW.xy;\r\n\r\n#ifdef REFLECTIONMAP_PROJECTION\r\n\t\tcoords /= vReflectionUVW.z;\r\n#endif\r\n\r\n\t\tcoords.y = 1.0 - coords.y;\r\n\r\n\t\treflectionColor = texture2D(reflection2DSampler, coords).rgb * vReflectionInfos.x;\r\n#endif\r\n\r\n#ifdef REFLECTIONFRESNEL\r\n\tfloat reflectionFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, reflectionRightColor.a, reflectionLeftColor.a);\r\n\r\n\treflectionColor *= reflectionLeftColor.rgb * (1.0 - reflectionFresnelTerm) + reflectionFresnelTerm * reflectionRightColor.rgb;\r\n#endif\r\n#endif\r\n\r\n\t// Alpha\r\n\tfloat alpha = vDiffuseColor.a;\r\n\r\n#ifdef OPACITY\r\n\tvec4 opacityMap = texture2D(opacitySampler, vOpacityUV);\r\n#ifdef OPACITYRGB\r\n\topacityMap.rgb = opacityMap.rgb * vec3(0.3, 0.59, 0.11);\r\n\talpha *= (opacityMap.x + opacityMap.y + opacityMap.z)* vOpacityInfos.y;\r\n#else\r\n\talpha *= opacityMap.a * vOpacityInfos.y;\r\n#endif\r\n#endif\r\n\r\n#ifdef VERTEXALPHA\r\n\talpha *= vColor.a;\r\n#endif\r\n\r\n#ifdef OPACITYFRESNEL\r\n\tfloat opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w);\r\n\r\n\talpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y;\r\n#endif\r\n\r\n\t// Emissive\r\n\tvec3 emissiveColor = vEmissiveColor;\r\n#ifdef EMISSIVE\r\n\temissiveColor += texture2D(emissiveSampler, vEmissiveUV).rgb * vEmissiveInfos.y;\r\n#endif\r\n\r\n#ifdef EMISSIVEFRESNEL\r\n\tfloat emissiveFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, emissiveRightColor.a, emissiveLeftColor.a);\r\n\r\n\temissiveColor *= emissiveLeftColor.rgb * (1.0 - emissiveFresnelTerm) + emissiveFresnelTerm * emissiveRightColor.rgb;\r\n#endif\r\n\r\n\t// Specular map\r\n#ifdef SPECULARTERM\r\n\tvec3 specularColor = vSpecularColor.rgb;\r\n#ifdef SPECULAR\r\n\tspecularColor = texture2D(specularSampler, vSpecularUV).rgb * vSpecularInfos.y;\r\n#endif\r\n#endif\r\n\r\n\t// Fresnel\r\n#ifdef DIFFUSEFRESNEL\r\n\tfloat diffuseFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, diffuseRightColor.a, diffuseLeftColor.a);\r\n\r\n\tdiffuseBase *= diffuseLeftColor.rgb * (1.0 - diffuseFresnelTerm) + diffuseFresnelTerm * diffuseRightColor.rgb;\r\n#endif\r\n\r\n\t// Composition\r\n\tvec3 finalDiffuse = clamp(diffuseBase * diffuseColor + emissiveColor + vAmbientColor, 0.0, 1.0) * baseColor.rgb;\r\n#ifdef SPECULARTERM\r\n\tvec3 finalSpecular = specularBase * specularColor;\r\n#else\r\n\tvec3 finalSpecular = vec3(0.0);\r\n#endif\r\n\r\n\tvec4 color = vec4(finalDiffuse * baseAmbientColor + finalSpecular + reflectionColor, alpha);\r\n\r\n#ifdef FOG\r\n\tfloat fog = CalcFogFactor();\r\n\tcolor.rgb = fog * color.rgb + (1.0 - fog) * vFogColor;\r\n#endif\r\n\r\n\tgl_FragColor = color;\r\n}",legacydefaultVertexShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Attributes\r\nattribute vec3 position;\r\nattribute vec3 normal;\r\n#ifdef UV1\r\nattribute vec2 uv;\r\n#endif\r\n#ifdef UV2\r\nattribute vec2 uv2;\r\n#endif\r\n#ifdef VERTEXCOLOR\r\nattribute vec4 color;\r\n#endif\r\n#ifdef BONES\r\nattribute vec4 matricesIndices;\r\nattribute vec4 matricesWeights;\r\n#endif\r\n\r\n// Uniforms\r\nuniform mat4 world;\r\nuniform mat4 view;\r\nuniform mat4 viewProjection;\r\n\r\n#ifdef DIFFUSE\r\nvarying vec2 vDiffuseUV;\r\nuniform mat4 diffuseMatrix;\r\nuniform vec2 vDiffuseInfos;\r\n#endif\r\n\r\n#ifdef AMBIENT\r\nvarying vec2 vAmbientUV;\r\nuniform mat4 ambientMatrix;\r\nuniform vec2 vAmbientInfos;\r\n#endif\r\n\r\n#ifdef OPACITY\r\nvarying vec2 vOpacityUV;\r\nuniform mat4 opacityMatrix;\r\nuniform vec2 vOpacityInfos;\r\n#endif\r\n\r\n#ifdef EMISSIVE\r\nvarying vec2 vEmissiveUV;\r\nuniform vec2 vEmissiveInfos;\r\nuniform mat4 emissiveMatrix;\r\n#endif\r\n\r\n#if defined(SPECULAR) && defined(SPECULARTERM)\r\nvarying vec2 vSpecularUV;\r\nuniform vec2 vSpecularInfos;\r\nuniform mat4 specularMatrix;\r\n#endif\r\n\r\n#ifdef BUMP\r\nvarying vec2 vBumpUV;\r\nuniform vec2 vBumpInfos;\r\nuniform mat4 bumpMatrix;\r\n#endif\r\n\r\n#ifdef BONES\r\nuniform mat4 mBones[BonesPerMesh];\r\n#endif\r\n\r\n// Output\r\nvarying vec3 vPositionW;\r\nvarying vec3 vNormalW;\r\n\r\n#ifdef VERTEXCOLOR\r\nvarying vec4 vColor;\r\n#endif\r\n\r\n#ifdef CLIPPLANE\r\nuniform vec4 vClipPlane;\r\nvarying float fClipDistance;\r\n#endif\r\n\r\n#ifdef FOG\r\nvarying float fFogDistance;\r\n#endif\r\n\r\n#ifdef SHADOWS\r\n#ifdef LIGHT0\r\nuniform mat4 lightMatrix0;\r\nvarying vec4 vPositionFromLight0;\r\n#endif\r\n#ifdef LIGHT1\r\nuniform mat4 lightMatrix1;\r\nvarying vec4 vPositionFromLight1;\r\n#endif\r\n#ifdef LIGHT2\r\nuniform mat4 lightMatrix2;\r\nvarying vec4 vPositionFromLight2;\r\n#endif\r\n#ifdef LIGHT3\r\nuniform mat4 lightMatrix3;\r\nvarying vec4 vPositionFromLight3;\r\n#endif\r\n#endif\r\n\r\n#ifdef REFLECTION\r\nuniform vec3 vEyePosition;\r\nvarying vec3 vReflectionUVW;\r\nuniform mat4 reflectionMatrix;\r\n\r\nvec3 computeReflectionCoords(vec4 worldPos, vec3 worldNormal)\r\n{\r\n#ifdef REFLECTIONMAP_SPHERICAL\r\n\tvec3 coords = vec3(view * vec4(worldNormal, 0.0));\r\n\r\n\treturn vec3(reflectionMatrix * vec4(coords, 1.0));\r\n#endif\r\n\r\n#ifdef REFLECTIONMAP_PLANAR\r\n\tvec3 viewDir = worldPos.xyz - vEyePosition;\r\n\tvec3 coords = normalize(reflect(viewDir, worldNormal));\r\n\r\n\treturn vec3(reflectionMatrix * vec4(coords, 1));\r\n#endif\r\n\r\n#ifdef REFLECTIONMAP_CUBIC\r\n\tvec3 viewDir = worldPos.xyz - vEyePosition;\r\n\tvec3 coords = reflect(viewDir, worldNormal);\r\n#ifdef INVERTCUBICMAP\r\n\tcoords.y = 1.0 - coords.y;\r\n#endif\r\n\treturn vec3(reflectionMatrix * vec4(coords, 0));\r\n#endif\r\n\r\n#ifdef REFLECTIONMAP_PROJECTION\r\n\treturn vec3(reflectionMatrix * (view * worldPos));\r\n#endif\r\n\r\n#ifdef REFLECTIONMAP_SKYBOX\r\n\treturn position;\r\n#endif\r\n\r\n#ifdef REFLECTIONMAP_EXPLICIT\r\n\treturn vec3(0, 0, 0);\r\n#endif\r\n}\r\n#endif\r\n\r\nvoid main(void) {\r\n\tmat4 finalWorld;\r\n\r\n#ifdef BONES\r\n\tmat4 m0 = mBones[int(matricesIndices.x)] * matricesWeights.x;\r\n\tmat4 m1 = mBones[int(matricesIndices.y)] * matricesWeights.y;\r\n\tmat4 m2 = mBones[int(matricesIndices.z)] * matricesWeights.z;\r\n\r\n#ifdef BONES4\r\n\tmat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;\r\n\tfinalWorld = world * (m0 + m1 + m2 + m3);\r\n#else\r\n\tfinalWorld = world * (m0 + m1 + m2);\r\n#endif \r\n\r\n#else\r\n\tfinalWorld = world;\r\n#endif\r\n\r\n\tgl_Position = viewProjection * finalWorld * vec4(position, 1.0);\r\n\r\n\tvec4 worldPos = finalWorld * vec4(position, 1.0);\r\n\tvPositionW = vec3(worldPos);\r\n\tvNormalW = normalize(vec3(finalWorld * vec4(normal, 0.0)));\r\n\r\n\t// Texture coordinates\r\n#ifndef UV1\r\n\tvec2 uv = vec2(0., 0.);\r\n#endif\r\n#ifndef UV2\r\n\tvec2 uv2 = vec2(0., 0.);\r\n#endif\r\n\r\n#ifdef DIFFUSE\r\n\tif (vDiffuseInfos.x == 0.)\r\n\t{\r\n\t\tvDiffuseUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));\r\n\t}\r\n\telse\r\n\t{\r\n\t\tvDiffuseUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));\r\n\t}\r\n#endif\r\n\r\n#ifdef AMBIENT\r\n\tif (vAmbientInfos.x == 0.)\r\n\t{\r\n\t\tvAmbientUV = vec2(ambientMatrix * vec4(uv, 1.0, 0.0));\r\n\t}\r\n\telse\r\n\t{\r\n\t\tvAmbientUV = vec2(ambientMatrix * vec4(uv2, 1.0, 0.0));\r\n\t}\r\n#endif\r\n\r\n#ifdef OPACITY\r\n\tif (vOpacityInfos.x == 0.)\r\n\t{\r\n\t\tvOpacityUV = vec2(opacityMatrix * vec4(uv, 1.0, 0.0));\r\n\t}\r\n\telse\r\n\t{\r\n\t\tvOpacityUV = vec2(opacityMatrix * vec4(uv2, 1.0, 0.0));\r\n\t}\r\n#endif\r\n\t\r\n#ifdef REFLECTION\r\n\tvReflectionUVW = computeReflectionCoords(vec4(vPositionW, 1.0), vNormalW);\r\n#endif\r\n\r\n#ifdef EMISSIVE\r\n\tif (vEmissiveInfos.x == 0.)\r\n\t{\r\n\t\tvEmissiveUV = vec2(emissiveMatrix * vec4(uv, 1.0, 0.0));\r\n\t}\r\n\telse\r\n\t{\r\n\t\tvEmissiveUV = vec2(emissiveMatrix * vec4(uv2, 1.0, 0.0));\r\n\t}\r\n#endif\r\n\r\n#if defined(SPECULAR) && defined(SPECULARTERM)\r\n\tif (vSpecularInfos.x == 0.)\r\n\t{\r\n\t\tvSpecularUV = vec2(specularMatrix * vec4(uv, 1.0, 0.0));\r\n\t}\r\n\telse\r\n\t{\r\n\t\tvSpecularUV = vec2(specularMatrix * vec4(uv2, 1.0, 0.0));\r\n\t}\r\n#endif\r\n\r\n#ifdef BUMP\r\n\tif (vBumpInfos.x == 0.)\r\n\t{\r\n\t\tvBumpUV = vec2(bumpMatrix * vec4(uv, 1.0, 0.0));\r\n\t}\r\n\telse\r\n\t{\r\n\t\tvBumpUV = vec2(bumpMatrix * vec4(uv2, 1.0, 0.0));\r\n\t}\r\n#endif\r\n\r\n\t// Clip plane\r\n#ifdef CLIPPLANE\r\n\tfClipDistance = dot(worldPos, vClipPlane);\r\n#endif\r\n\r\n\t// Fog\r\n#ifdef FOG\r\n\tfFogDistance = (view * worldPos).z;\r\n#endif\r\n\r\n\t// Shadows\r\n#ifdef SHADOWS\r\n#ifdef LIGHT0\r\n\tvPositionFromLight0 = lightMatrix0 * worldPos;\r\n#endif\r\n#ifdef LIGHT1\r\n\tvPositionFromLight1 = lightMatrix1 * worldPos;\r\n#endif\r\n#ifdef LIGHT2\r\n\tvPositionFromLight2 = lightMatrix2 * worldPos;\r\n#endif\r\n#ifdef LIGHT3\r\n\tvPositionFromLight3 = lightMatrix3 * worldPos;\r\n#endif\r\n#endif\r\n\r\n\t// Vertex color\r\n#ifdef VERTEXCOLOR\r\n\tvColor = color;\r\n#endif\r\n}",lensFlarePixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Samplers\r\nvarying vec2 vUV;\r\nuniform sampler2D textureSampler;\r\n\r\n// Color\r\nuniform vec4 color;\r\n\r\nvoid main(void) {\r\n\tvec4 baseColor = texture2D(textureSampler, vUV);\r\n\r\n\tgl_FragColor = baseColor * color;\r\n}",lensFlareVertexShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Attributes\r\nattribute vec2 position;\r\n\r\n// Uniforms\r\nuniform mat4 viewportMatrix;\r\n\r\n// Output\r\nvarying vec2 vUV;\r\n\r\nconst vec2 madd = vec2(0.5, 0.5);\r\n\r\nvoid main(void) {\t\r\n\r\n\tvUV = position * madd + madd;\r\n\tgl_Position = viewportMatrix * vec4(position, 0.0, 1.0);\r\n}",lensHighlightsPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// samplers\r\nuniform sampler2D textureSampler;\t// original color\r\n\r\n// uniforms\r\nuniform float gain;\r\nuniform float threshold;\r\nuniform bool pentagon;\r\nuniform float screen_width;\r\nuniform float screen_height;\r\n\r\n// varyings\r\nvarying vec2 vUV;\r\n\r\n// apply luminance filter\r\nvec4 highlightColor(vec4 color) {\r\n\tvec4 highlight = color;\r\n\tfloat luminance = dot(highlight.rgb, vec3(0.2125, 0.7154, 0.0721));\r\n\tfloat lum_threshold;\r\n\tif (threshold > 1.0) { lum_threshold = 0.94 + 0.01 * threshold; }\r\n\telse { lum_threshold = 0.5 + 0.44 * threshold; }\r\n\r\n\tluminance = clamp((luminance - lum_threshold) * (1.0 / (1.0 - lum_threshold)), 0.0, 1.0);\r\n\r\n\thighlight *= luminance * gain;\r\n\thighlight.a = 1.0;\r\n\r\n\treturn highlight;\r\n}\r\n\r\nvoid main(void)\r\n{\r\n\tvec4 original = texture2D(textureSampler, vUV);\r\n\r\n\t// quick exit if no highlight computing\r\n\tif (gain == -1.0) {\r\n\t\tgl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\r\n\t\treturn;\r\n\t}\r\n\r\n\tfloat w = 2.0 / screen_width;\r\n\tfloat h = 2.0 / screen_height;\r\n\r\n\tfloat weight = 1.0;\r\n\r\n\t// compute blurred color\r\n\tvec4 blurred = vec4(0.0, 0.0, 0.0, 0.0);\r\n\r\n\tif (pentagon) {\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-0.84*w, 0.43*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(0.48*w, -1.29*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(0.61*w, 1.51*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-1.55*w, -0.74*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(1.71*w, -0.52*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-0.94*w, 1.59*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-0.40*w, -1.87*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(1.62*w, 1.16*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-2.09*w, 0.25*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(1.46*w, -1.71*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(0.08*w, 2.42*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-1.85*w, -1.89*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(2.89*w, 0.16*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-2.29*w, 1.88*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(0.40*w, -2.81*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(1.54*w, 2.26*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-2.60*w, -0.61*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(2.31*w, -1.30*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-0.83*w, 2.53*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-1.12*w, -2.48*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(2.60*w, 1.11*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-2.82*w, 0.99*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(1.50*w, -2.81*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(0.85*w, 3.33*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-2.94*w, -1.92*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(3.27*w, -0.53*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-1.95*w, 2.48*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-0.23*w, -3.04*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(2.17*w, 2.05*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-2.97*w, -0.04*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(2.25*w, -2.00*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-0.31*w, 3.08*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-1.94*w, -2.59*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(3.37*w, 0.64*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-3.13*w, 1.93*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(1.03*w, -3.65*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(1.60*w, 3.17*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-3.14*w, -1.19*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(3.00*w, -1.19*h)));\r\n\t}\r\n\telse {\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-0.85*w, 0.36*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(0.52*w, -1.14*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(0.46*w, 1.42*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-1.46*w, -0.83*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(1.79*w, -0.42*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-1.11*w, 1.62*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-0.29*w, -2.07*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(1.69*w, 1.39*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-2.28*w, 0.12*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(1.65*w, -1.69*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-0.08*w, 2.44*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-1.63*w, -1.90*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(2.55*w, 0.31*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-2.13*w, 1.52*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(0.56*w, -2.61*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(1.38*w, 2.34*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-2.64*w, -0.81*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(2.53*w, -1.21*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-1.06*w, 2.63*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-1.00*w, -2.69*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(2.59*w, 1.32*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-2.82*w, 0.78*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(1.57*w, -2.50*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(0.54*w, 2.93*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-2.39*w, -1.81*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(3.01*w, -0.28*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-2.04*w, 2.25*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-0.02*w, -3.05*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(2.09*w, 2.25*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-3.07*w, -0.25*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(2.44*w, -1.90*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-0.52*w, 3.05*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-1.68*w, -2.61*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(3.01*w, 0.79*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-2.76*w, 1.46*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(1.05*w, -2.94*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(1.21*w, 2.88*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(-2.84*w, -1.30*h)));\r\n\t\tblurred += highlightColor(texture2D(textureSampler, vUV + vec2(2.98*w, -0.96*h)));\r\n\t}\r\n\r\n\tblurred /= 39.0;\r\n\r\n\tgl_FragColor = blurred;\r\n\r\n\t//if(vUV.x > 0.5) { gl_FragColor.rgb *= 0.0; }\r\n}",linePixelShader:"precision highp float;\r\n\r\nuniform vec4 color;\r\n\r\nvoid main(void) {\r\n\tgl_FragColor = color;\r\n}",lineVertexShader:"precision highp float;\r\n\r\n// Attributes\r\nattribute vec3 position;\r\nattribute vec4 normal;\r\n\r\n// Uniforms\r\nuniform mat4 worldViewProjection;\r\n\r\nuniform float width;\r\nuniform float aspectRatio;\r\n\r\nvoid main(void) {\r\n\tvec4 viewPosition = worldViewProjection * vec4(position, 1.0);\r\n\tvec4 viewPositionNext = worldViewProjection * vec4(normal.xyz, 1.0);\r\n\r\n\tvec2 currentScreen = viewPosition.xy / viewPosition.w;\r\n\tvec2 nextScreen = viewPositionNext.xy / viewPositionNext.w;\r\n\r\n\tcurrentScreen.x *= aspectRatio;\r\n\tnextScreen.x *= aspectRatio;\r\n\r\n\tvec2 dir = normalize(nextScreen - currentScreen);\r\n\tvec2 normalDir = vec2(-dir.y, dir.x);\r\n\r\n\tnormalDir *= width / 2.0;\r\n\tnormalDir.x /= aspectRatio;\r\n\r\n\tvec4 offset = vec4(normalDir * normal.w, 0.0, 0.0);\r\n\tgl_Position = viewPosition + offset;\r\n}",marblePixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\nvarying vec2 vPosition;\r\nvarying vec2 vUV;\r\n\r\nuniform float numberOfTilesHeight;\r\nuniform float numberOfTilesWidth;\r\nuniform float amplitude;\r\nuniform vec3 brickColor;\r\nuniform vec3 jointColor;\r\n\r\nconst vec3 tileSize = vec3(1.1, 1.0, 1.1);\r\nconst vec3 tilePct = vec3(0.98, 1.0, 0.98);\r\n\r\nfloat rand(vec2 n) {\r\n\treturn fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);\r\n}\r\n\r\nfloat noise(vec2 n) {\r\n\tconst vec2 d = vec2(0.0, 1.0);\r\n\tvec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));\r\n\treturn mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);\r\n}\r\n\r\nfloat turbulence(vec2 P)\r\n{\r\n\tfloat val = 0.0;\r\n\tfloat freq = 1.0;\r\n\tfor (int i = 0; i < 4; i++)\r\n\t{\r\n\t\tval += abs(noise(P*freq) / freq);\r\n\t\tfreq *= 2.07;\r\n\t}\r\n\treturn val;\r\n}\r\n\r\nfloat round(float number){\r\n\treturn sign(number)*floor(abs(number) + 0.5);\r\n}\r\n\r\nvec3 marble_color(float x)\r\n{\r\n\tvec3 col;\r\n\tx = 0.5*(x + 1.);\r\n\tx = sqrt(x);            \r\n\tx = sqrt(x);\r\n\tx = sqrt(x);\r\n\tcol = vec3(.2 + .75*x);  \r\n\tcol.b *= 0.95;          \r\n\treturn col;\r\n}\r\n\r\nvoid main()\r\n{\r\n\tfloat brickW = 1.0 / numberOfTilesWidth;\r\n\tfloat brickH = 1.0 / numberOfTilesHeight;\r\n\tfloat jointWPercentage = 0.01;\r\n\tfloat jointHPercentage = 0.01;\r\n\tvec3 color = brickColor;\r\n\tfloat yi = vUV.y / brickH;\r\n\tfloat nyi = round(yi);\r\n\tfloat xi = vUV.x / brickW;\r\n\r\n\tif (mod(floor(yi), 2.0) == 0.0){\r\n\t\txi = xi - 0.5;\r\n\t}\r\n\r\n\tfloat nxi = round(xi);\r\n\tvec2 brickvUV = vec2((xi - floor(xi)) / brickH, (yi - floor(yi)) / brickW);\r\n\r\n\tif (yi < nyi + jointHPercentage && yi > nyi - jointHPercentage){\r\n\t\tcolor = mix(jointColor, vec3(0.37, 0.25, 0.25), (yi - nyi) / jointHPercentage + 0.2);\r\n\t}\r\n\telse if (xi < nxi + jointWPercentage && xi > nxi - jointWPercentage){\r\n\t\tcolor = mix(jointColor, vec3(0.44, 0.44, 0.44), (xi - nxi) / jointWPercentage + 0.2);\r\n\t}\r\n\telse {\r\n\t\tfloat t = 6.28 * brickvUV.x / (tileSize.x + noise(vec2(vUV)*6.0));\r\n\t\tt += amplitude * turbulence(brickvUV.xy);\r\n\t\tt = sin(t);\r\n\t\tcolor = marble_color(t);\r\n\t}\r\n\r\n\tgl_FragColor = vec4(color, 0.0);\r\n}",outlinePixelShader:"precision highp float;\r\n\r\nuniform vec4 color;\r\n\r\n#ifdef ALPHATEST\r\nvarying vec2 vUV;\r\nuniform sampler2D diffuseSampler;\r\n#endif\r\n\r\nvoid main(void) {\r\n#ifdef ALPHATEST\r\n\tif (texture2D(diffuseSampler, vUV).a < 0.4)\r\n\t\tdiscard;\r\n#endif\r\n\r\n\tgl_FragColor = color;\r\n}",outlineVertexShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Attribute\r\nattribute vec3 position;\r\nattribute vec3 normal;\r\n\r\n#ifdef BONES\r\nattribute vec4 matricesIndices;\r\nattribute vec4 matricesWeights;\r\n#endif\r\n\r\n// Uniform\r\nuniform float offset;\r\n\r\n#ifdef INSTANCES\r\nattribute vec4 world0;\r\nattribute vec4 world1;\r\nattribute vec4 world2;\r\nattribute vec4 world3;\r\n#else\r\nuniform mat4 world;\r\n#endif\r\n\r\nuniform mat4 viewProjection;\r\n#ifdef BONES\r\nuniform mat4 mBones[BonesPerMesh];\r\n#endif\r\n\r\n#ifdef ALPHATEST\r\nvarying vec2 vUV;\r\nuniform mat4 diffuseMatrix;\r\n#ifdef UV1\r\nattribute vec2 uv;\r\n#endif\r\n#ifdef UV2\r\nattribute vec2 uv2;\r\n#endif\r\n#endif\r\n\r\nvoid main(void)\r\n{\r\n#ifdef INSTANCES\r\n\tmat4 finalWorld = mat4(world0, world1, world2, world3);\r\n#else\r\n\tmat4 finalWorld = world;\r\n#endif\r\n\r\n\tvec3 offsetPosition = position + normal * offset;\r\n\r\n#ifdef BONES\r\n\tmat4 m0 = mBones[int(matricesIndices.x)] * matricesWeights.x;\r\n\tmat4 m1 = mBones[int(matricesIndices.y)] * matricesWeights.y;\r\n\tmat4 m2 = mBones[int(matricesIndices.z)] * matricesWeights.z;\r\n\tmat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;\r\n\tfinalWorld = finalWorld * (m0 + m1 + m2 + m3);\r\n\tgl_Position = viewProjection * finalWorld * vec4(offsetPosition, 1.0);\r\n#else\r\n\tgl_Position = viewProjection * finalWorld * vec4(offsetPosition, 1.0);\r\n#endif\r\n\r\n#ifdef ALPHATEST\r\n#ifdef UV1\r\n\tvUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));\r\n#endif\r\n#ifdef UV2\r\n\tvUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));\r\n#endif\r\n#endif\r\n}",particlesPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Samplers\r\nvarying vec2 vUV;\r\nvarying vec4 vColor;\r\nuniform vec4 textureMask;\r\nuniform sampler2D diffuseSampler;\r\n\r\n#ifdef CLIPPLANE\r\nvarying float fClipDistance;\r\n#endif\r\n\r\nvoid main(void) {\r\n#ifdef CLIPPLANE\r\n\tif (fClipDistance > 0.0)\r\n\t\tdiscard;\r\n#endif\r\n\tvec4 baseColor = texture2D(diffuseSampler, vUV);\r\n\r\n\tgl_FragColor = (baseColor * textureMask + (vec4(1., 1., 1., 1.) - textureMask)) * vColor;\r\n}",particlesVertexShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Attributes\r\nattribute vec3 position;\r\nattribute vec4 color;\r\nattribute vec4 options;\r\n\r\n// Uniforms\r\nuniform mat4 view;\r\nuniform mat4 projection;\r\n\r\n// Output\r\nvarying vec2 vUV;\r\nvarying vec4 vColor;\r\n\r\n#ifdef CLIPPLANE\r\nuniform vec4 vClipPlane;\r\nuniform mat4 invView;\r\nvarying float fClipDistance;\r\n#endif\r\n\r\nvoid main(void) {\t\r\n\tvec3 viewPos = (view * vec4(position, 1.0)).xyz; \r\n\tvec3 cornerPos;\r\n\tfloat size = options.y;\r\n\tfloat angle = options.x;\r\n\tvec2 offset = options.zw;\r\n\r\n\tcornerPos = vec3(offset.x - 0.5, offset.y  - 0.5, 0.) * size;\r\n\r\n\t// Rotate\r\n\tvec3 rotatedCorner;\r\n\trotatedCorner.x = cornerPos.x * cos(angle) - cornerPos.y * sin(angle);\r\n\trotatedCorner.y = cornerPos.x * sin(angle) + cornerPos.y * cos(angle);\r\n\trotatedCorner.z = 0.;\r\n\r\n\t// Position\r\n\tviewPos += rotatedCorner;\r\n\tgl_Position = projection * vec4(viewPos, 1.0);  \r\n\t\r\n\tvColor = color;\r\n\tvUV = offset;\r\n\r\n\t// Clip plane\r\n#ifdef CLIPPLANE\r\n\tvec4 worldPos = invView * vec4(viewPos, 1.0);\r\n\tfClipDistance = dot(worldPos, vClipPlane);\r\n#endif\r\n}",passPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Samplers\r\nvarying vec2 vUV;\r\nuniform sampler2D textureSampler;\r\n\r\nvoid main(void) \r\n{\r\n\tgl_FragColor = texture2D(textureSampler, vUV);\r\n}",pbrPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Constants\r\nuniform vec3 vEyePosition;\r\nuniform vec4 vAlbedoColor;\r\n\r\n// Input\r\nvarying vec3 vPositionW;\r\n\r\n#ifdef NORMAL\r\nvarying vec3 vNormalW;\r\n#endif\r\n\r\n#ifdef VERTEXCOLOR\r\nvarying vec4 vColor;\r\n#endif\r\n\r\n#ifdef CLIPPLANE\r\nvarying float fClipDistance;\r\n#endif\r\n\r\n// Fog\r\n#ifdef FOG\r\n\r\n#define FOGMODE_NONE    0.\r\n#define FOGMODE_EXP    1.\r\n#define FOGMODE_EXP2    2.\r\n#define FOGMODE_LINEAR  3.\r\n#define E 2.71828\r\n\r\nuniform vec4 vFogInfos;\r\nuniform vec3 vFogColor;\r\nvarying float fFogDistance;\r\n\r\nfloat CalcFogFactor()\r\n{\r\n\tfloat fogCoeff = 1.0;\r\n\tfloat fogStart = vFogInfos.y;\r\n\tfloat fogEnd = vFogInfos.z;\r\n\tfloat fogDensity = vFogInfos.w;\r\n\r\n\tif (FOGMODE_LINEAR == vFogInfos.x)\r\n\t{\r\n\t\tfogCoeff = (fogEnd - fFogDistance) / (fogEnd - fogStart);\r\n\t}\r\n\telse if (FOGMODE_EXP == vFogInfos.x)\r\n\t{\r\n\t\tfogCoeff = 1.0 / pow(E, fFogDistance * fogDensity);\r\n\t}\r\n\telse if (FOGMODE_EXP2 == vFogInfos.x)\r\n\t{\r\n\t\tfogCoeff = 1.0 / pow(E, fFogDistance * fFogDistance * fogDensity * fogDensity);\r\n\t}\r\n\r\n\treturn clamp(fogCoeff, 0.0, 1.0);\r\n}\r\n#endif\r\n\r\nvoid main(void) {\r\n\t// Clip plane\r\n#ifdef CLIPPLANE\r\n\tif (fClipDistance > 0.0)\r\n\t\tdiscard;\r\n#endif\r\n\r\n\tvec3 viewDirectionW = normalize(vEyePosition - vPositionW);\r\n\r\n\t// Base color\r\n\tvec3 baseColor = vAlbedoColor.rgb;\r\n\r\n\t// Alpha\r\n\tfloat alpha = vAlbedoColor.a;\r\n\r\n#ifdef VERTEXCOLOR\r\n\tbaseColor *= vColor.rgb;\r\n#endif\r\n\r\n#ifdef VERTEXALPHA\r\n\talpha *= vColor.a;\r\n#endif\r\n\r\n\t// Composition\r\n    vec4 color = vec4(clamp(baseColor, 0.0, 1.0), alpha);\r\n\r\n#ifdef FOG\r\n\tfloat fog = CalcFogFactor();\r\n\tcolor.rgb = fog * color.rgb + (1.0 - fog) * vFogColor;\r\n#endif\r\n\r\n\tgl_FragColor = color;\r\n}",pbrVertexShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Attributes\r\nattribute vec3 position;\r\n#ifdef NORMAL\r\nattribute vec3 normal;\r\n#endif\r\n#ifdef UV1\r\nattribute vec2 uv;\r\n#endif\r\n#ifdef UV2\r\nattribute vec2 uv2;\r\n#endif\r\n#ifdef VERTEXCOLOR\r\nattribute vec4 color;\r\n#endif\r\n#ifdef BONES\r\nattribute vec4 matricesIndices;\r\nattribute vec4 matricesWeights;\r\n#endif\r\n\r\n// Uniforms\r\n#ifdef INSTANCES\r\nattribute vec4 world0;\r\nattribute vec4 world1;\r\nattribute vec4 world2;\r\nattribute vec4 world3;\r\n#else\r\nuniform mat4 world;\r\n#endif\r\n\r\nuniform mat4 view;\r\nuniform mat4 viewProjection;\r\n\r\n#ifdef BONES\r\nuniform mat4 mBones[BonesPerMesh];\r\n#endif\r\n\r\n#ifdef POINTSIZE\r\nuniform float pointSize;\r\n#endif\r\n\r\n// Output\r\nvarying vec3 vPositionW;\r\n#ifdef NORMAL\r\nvarying vec3 vNormalW;\r\n#endif\r\n\r\n#ifdef VERTEXCOLOR\r\nvarying vec4 vColor;\r\n#endif\r\n\r\n#ifdef CLIPPLANE\r\nuniform vec4 vClipPlane;\r\nvarying float fClipDistance;\r\n#endif\r\n\r\n#ifdef FOG\r\nvarying float fFogDistance;\r\n#endif\r\n\r\nvoid main(void) {\r\n\tmat4 finalWorld;\r\n\r\n#ifdef INSTANCES\r\n\tfinalWorld = mat4(world0, world1, world2, world3);\r\n#else\r\n\tfinalWorld = world;\r\n#endif\r\n\r\n#ifdef BONES\r\n\tmat4 m0 = mBones[int(matricesIndices.x)] * matricesWeights.x;\r\n\tmat4 m1 = mBones[int(matricesIndices.y)] * matricesWeights.y;\r\n\tmat4 m2 = mBones[int(matricesIndices.z)] * matricesWeights.z;\r\n\r\n#ifdef BONES4\r\n\tmat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;\r\n\tfinalWorld = finalWorld * (m0 + m1 + m2 + m3);\r\n#else\r\n\tfinalWorld = finalWorld * (m0 + m1 + m2);\r\n#endif \r\n\r\n#endif\r\n\tgl_Position = viewProjection * finalWorld * vec4(position, 1.0);\r\n\r\n\tvec4 worldPos = finalWorld * vec4(position, 1.0);\r\n\tvPositionW = vec3(worldPos);\r\n\r\n#ifdef NORMAL\r\n\tvNormalW = normalize(vec3(finalWorld * vec4(normal, 0.0)));\r\n#endif\r\n\r\n\t// Texture coordinates\r\n#ifndef UV1\r\n\tvec2 uv = vec2(0., 0.);\r\n#endif\r\n#ifndef UV2\r\n\tvec2 uv2 = vec2(0., 0.);\r\n#endif\r\n\r\n\t// Clip plane\r\n#ifdef CLIPPLANE\r\n\tfClipDistance = dot(worldPos, vClipPlane);\r\n#endif\r\n\r\n\t// Fog\r\n#ifdef FOG\r\n\tfFogDistance = (view * worldPos).z;\r\n#endif\r\n\r\n\t// Vertex color\r\n#ifdef VERTEXCOLOR\r\n\tvColor = color;\r\n#endif\r\n\r\n\t// Point size\r\n#ifdef POINTSIZE\r\n\tgl_PointSize = pointSize;\r\n#endif\r\n}",postprocessVertexShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Attributes\r\nattribute vec2 position;\r\n\r\n// Output\r\nvarying vec2 vUV;\r\n\r\nconst vec2 madd = vec2(0.5, 0.5);\r\n\r\nvoid main(void) {\t\r\n\r\n\tvUV = position * madd + madd;\r\n\tgl_Position = vec4(position, 0.0, 1.0);\r\n}",proceduralVertexShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Attributes\r\nattribute vec2 position;\r\n\r\n// Output\r\nvarying vec2 vPosition;\r\nvarying vec2 vUV;\r\n\r\nconst vec2 madd = vec2(0.5, 0.5);\r\n\r\nvoid main(void) {\t\r\n\tvPosition = position;\r\n\tvUV = position * madd + madd;\r\n\tgl_Position = vec4(position, 0.0, 1.0);\r\n}",refractionPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Samplers\r\nvarying vec2 vUV;\r\nuniform sampler2D textureSampler;\r\nuniform sampler2D refractionSampler;\r\n\r\n// Parameters\r\nuniform vec3 baseColor;\r\nuniform float depth;\r\nuniform float colorLevel;\r\n\r\nvoid main() {\r\n\tfloat ref = 1.0 - texture2D(refractionSampler, vUV).r;\r\n\r\n\tvec2 uv = vUV - vec2(0.5);\r\n\tvec2 offset = uv * depth * ref;\r\n\tvec3 sourceColor = texture2D(textureSampler, vUV - offset).rgb;\r\n\r\n\tgl_FragColor = vec4(sourceColor + sourceColor * ref * colorLevel, 1.0);\r\n}",roadPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\nvarying vec2 vUV;                    \r\nuniform vec3 roadColor;\r\n\r\nfloat rand(vec2 n) {\r\n\treturn fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);\r\n}\r\n\r\nfloat noise(vec2 n) {\r\n\tconst vec2 d = vec2(0.0, 1.0);\r\n\tvec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));\r\n\treturn mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);\r\n}\r\n\r\nfloat fbm(vec2 n) {\r\n\tfloat total = 0.0, amplitude = 1.0;\r\n\tfor (int i = 0; i < 4; i++) {\r\n\t\ttotal += noise(n) * amplitude;\r\n\t\tn += n;\r\n\t\tamplitude *= 0.5;\r\n\t}\r\n\treturn total;\r\n}\r\n\r\nvoid main(void) {\r\n\tfloat ratioy = mod(gl_FragCoord.y * 100.0 , fbm(vUV * 2.0));\r\n\tvec3 color = roadColor * ratioy;\r\n\tgl_FragColor = vec4(color, 1.0);\r\n}",shadowMapPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\nvec4 pack(float depth)\r\n{\r\n\tconst vec4 bit_shift = vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0);\r\n\tconst vec4 bit_mask = vec4(0.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);\r\n\r\n\tvec4 res = fract(depth * bit_shift);\r\n\tres -= res.xxyz * bit_mask;\r\n\r\n\treturn res;\r\n}\r\n\r\n// Thanks to http://devmaster.net/\r\nvec2 packHalf(float depth) \r\n{ \r\n\tconst vec2 bitOffset = vec2(1.0 / 255., 0.);\r\n\tvec2 color = vec2(depth, fract(depth * 255.));\r\n\r\n\treturn color - (color.yy * bitOffset);\r\n}\r\n\r\nvarying vec4 vPosition;\r\n\r\n#ifdef ALPHATEST\r\nvarying vec2 vUV;\r\nuniform sampler2D diffuseSampler;\r\n#endif\r\n\r\nvoid main(void)\r\n{\r\n#ifdef ALPHATEST\r\n\tif (texture2D(diffuseSampler, vUV).a < 0.4)\r\n\t\tdiscard;\r\n#endif\r\n\tfloat depth = vPosition.z / vPosition.w;\r\n\tdepth = depth * 0.5 + 0.5;\r\n\r\n#ifdef VSM\r\n\tfloat moment1 = depth;\r\n\tfloat moment2 = moment1 * moment1;\r\n\r\n\tgl_FragColor = vec4(packHalf(moment1), packHalf(moment2));\r\n#else\r\n\tgl_FragColor = pack(depth);\r\n#endif\r\n}",shadowMapVertexShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Attribute\r\nattribute vec3 position;\r\n#ifdef BONES\r\nattribute vec4 matricesIndices;\r\nattribute vec4 matricesWeights;\r\n#endif\r\n\r\n// Uniform\r\n#ifdef INSTANCES\r\nattribute vec4 world0;\r\nattribute vec4 world1;\r\nattribute vec4 world2;\r\nattribute vec4 world3;\r\n#else\r\nuniform mat4 world;\r\n#endif\r\n\r\nuniform mat4 viewProjection;\r\n#ifdef BONES\r\nuniform mat4 mBones[BonesPerMesh];\r\n#endif\r\n\r\nvarying vec4 vPosition;\r\n\r\n#ifdef ALPHATEST\r\nvarying vec2 vUV;\r\nuniform mat4 diffuseMatrix;\r\n#ifdef UV1\r\nattribute vec2 uv;\r\n#endif\r\n#ifdef UV2\r\nattribute vec2 uv2;\r\n#endif\r\n#endif\r\n\r\nvoid main(void)\r\n{\r\n#ifdef INSTANCES\r\n\tmat4 finalWorld = mat4(world0, world1, world2, world3);\r\n#else\r\n\tmat4 finalWorld = world;\r\n#endif\r\n\r\n#ifdef BONES\r\n\tmat4 m0 = mBones[int(matricesIndices.x)] * matricesWeights.x;\r\n\tmat4 m1 = mBones[int(matricesIndices.y)] * matricesWeights.y;\r\n\tmat4 m2 = mBones[int(matricesIndices.z)] * matricesWeights.z;\r\n\tmat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;\r\n\tfinalWorld = finalWorld * (m0 + m1 + m2 + m3);\r\n#endif\r\n\r\n\tvPosition = viewProjection * finalWorld * vec4(position, 1.0);\r\n\tgl_Position = vPosition;\r\n\r\n#ifdef ALPHATEST\r\n#ifdef UV1\r\n\tvUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));\r\n#endif\r\n#ifdef UV2\r\n\tvUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));\r\n#endif\r\n#endif\r\n}",spritesPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\nuniform bool alphaTest;\r\n\r\nvarying vec4 vColor;\r\n\r\n// Samplers\r\nvarying vec2 vUV;\r\nuniform sampler2D diffuseSampler;\r\n\r\n// Fog\r\n#ifdef FOG\r\n\r\n#define FOGMODE_NONE    0.\r\n#define FOGMODE_EXP    1.\r\n#define FOGMODE_EXP2    2.\r\n#define FOGMODE_LINEAR  3.\r\n#define E 2.71828\r\n\r\nuniform vec4 vFogInfos;\r\nuniform vec3 vFogColor;\r\nvarying float fFogDistance;\r\n\r\nfloat CalcFogFactor()\r\n{\r\n\tfloat fogCoeff = 1.0;\r\n\tfloat fogStart = vFogInfos.y;\r\n\tfloat fogEnd = vFogInfos.z;\r\n\tfloat fogDensity = vFogInfos.w;\r\n\r\n\tif (FOGMODE_LINEAR == vFogInfos.x)\r\n\t{\r\n\t\tfogCoeff = (fogEnd - fFogDistance) / (fogEnd - fogStart);\r\n\t}\r\n\telse if (FOGMODE_EXP == vFogInfos.x)\r\n\t{\r\n\t\tfogCoeff = 1.0 / pow(E, fFogDistance * fogDensity);\r\n\t}\r\n\telse if (FOGMODE_EXP2 == vFogInfos.x)\r\n\t{\r\n\t\tfogCoeff = 1.0 / pow(E, fFogDistance * fFogDistance * fogDensity * fogDensity);\r\n\t}\r\n\r\n\treturn min(1., max(0., fogCoeff));\r\n}\r\n#endif\r\n\r\n\r\nvoid main(void) {\r\n\tvec4 baseColor = texture2D(diffuseSampler, vUV);\r\n\r\n\tif (alphaTest) \r\n\t{\r\n\t\tif (baseColor.a < 0.95)\r\n\t\t\tdiscard;\r\n\t}\r\n\r\n\tbaseColor *= vColor;\r\n\r\n#ifdef FOG\r\n\tfloat fog = CalcFogFactor();\r\n\tbaseColor.rgb = fog * baseColor.rgb + (1.0 - fog) * vFogColor;\r\n#endif\r\n\r\n\tgl_FragColor = baseColor;\r\n}",spritesVertexShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Attributes\r\nattribute vec4 position;\r\nattribute vec4 options;\r\nattribute vec4 cellInfo;\r\nattribute vec4 color;\r\n\r\n// Uniforms\r\nuniform vec2 textureInfos;\r\nuniform mat4 view;\r\nuniform mat4 projection;\r\n\r\n// Output\r\nvarying vec2 vUV;\r\nvarying vec4 vColor;\r\n\r\n#ifdef FOG\r\nvarying float fFogDistance;\r\n#endif\r\n\r\nvoid main(void) {\t\r\n\tvec3 viewPos = (view * vec4(position.xyz, 1.0)).xyz; \r\n\tvec2 cornerPos;\r\n\t\r\n\tfloat angle = position.w;\r\n\tvec2 size = vec2(options.x, options.y);\r\n\tvec2 offset = options.zw;\r\n\tvec2 uvScale = textureInfos.xy;\r\n\r\n\tcornerPos = vec2(offset.x - 0.5, offset.y  - 0.5) * size;\r\n\r\n\t// Rotate\r\n\tvec3 rotatedCorner;\r\n\trotatedCorner.x = cornerPos.x * cos(angle) - cornerPos.y * sin(angle);\r\n\trotatedCorner.y = cornerPos.x * sin(angle) + cornerPos.y * cos(angle);\r\n\trotatedCorner.z = 0.;\r\n\r\n\t// Position\r\n\tviewPos += rotatedCorner;\r\n\tgl_Position = projection * vec4(viewPos, 1.0);  \r\n\r\n\t// Color\r\n\tvColor = color;\r\n\t\r\n\t// Texture\r\n\tvec2 uvOffset = vec2(abs(offset.x - cellInfo.x), 1.0 - abs(offset.y - cellInfo.y));\r\n\r\n\tvUV = (uvOffset + cellInfo.zw) * uvScale;\r\n\r\n\t// Fog\r\n#ifdef FOG\r\n\tfFogDistance = viewPos.z;\r\n#endif\r\n}",ssaoPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n#define SAMPLES 16\r\n\r\nuniform sampler2D textureSampler;\r\nuniform sampler2D randomSampler;\r\n\r\nuniform float randTextureTiles;\r\nuniform float samplesFactor;\r\nuniform vec3 sampleSphere[16];\r\n\r\nuniform float totalStrength;\r\nuniform float radius;\r\nuniform float area;\r\nuniform float fallOff;\r\n\r\nvarying vec2 vUV;\r\n\r\nconst vec2 offset1 = vec2(0.0, 0.001);\r\nconst vec2 offset2 = vec2(0.001, 0.0);\r\n\r\nvec3 normalFromDepth(const float depth, const vec2 coords) {\r\n\tfloat depth1 = texture2D(textureSampler, coords + offset1).r;\r\n\tfloat depth2 = texture2D(textureSampler, coords + offset2).r;\r\n\r\n    vec3 p1 = vec3(offset1, depth1 - depth);\r\n    vec3 p2 = vec3(offset2, depth2 - depth);\r\n\r\n    vec3 normal = cross(p1, p2);\r\n    normal.z = -normal.z;\r\n\r\n    return normalize(normal);\r\n}\r\n\r\nvoid main(void)\r\n{\r\n\tconst float base = 0.2;\r\n\r\n\tvec3 random = texture2D(randomSampler, vUV * randTextureTiles).rgb;\r\n\tfloat depth = texture2D(textureSampler, vUV).r;\r\n\tvec3 position = vec3(vUV, depth);\r\n\tvec3 normal = normalFromDepth(depth, vUV);\r\n\tfloat radiusDepth = radius / depth;\r\n\tfloat occlusion = 0.0;\r\n\r\n\tvec3 ray;\r\n\tvec3 hemiRay;\r\n\tfloat occlusionDepth;\r\n\tfloat difference;\r\n\r\n\tfor (int i = 0; i < SAMPLES; i++)\r\n\t{\r\n\t\tray = radiusDepth * reflect(sampleSphere[i], random);\r\n\t\themiRay = position + sign(dot(ray, normal)) * ray;\r\n\r\n\t\tocclusionDepth = texture2D(textureSampler, clamp(hemiRay.xy, 0.0, 1.0)).r;\r\n\t\tdifference = depth - occlusionDepth;\r\n\r\n\t\tocclusion += step(fallOff, difference) * (1.0 - smoothstep(fallOff, area, difference));\r\n\t}\r\n\r\n\tfloat ao = 1.0 - totalStrength * occlusion * samplesFactor;\r\n\r\n\tfloat result = clamp(ao + base, 0.0, 1.0);\r\n\tgl_FragColor.r = result;\r\n\tgl_FragColor.g = result;\r\n\tgl_FragColor.b = result;\r\n\tgl_FragColor.a = 1.0;\r\n}\r\n",ssaoCombinePixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\nuniform sampler2D textureSampler;\r\nuniform sampler2D originalColor;\r\n\r\nvarying vec2 vUV;\r\n\r\nvoid main(void) {\r\n\tgl_FragColor = texture2D(originalColor, vUV) * texture2D(textureSampler, vUV);\r\n}\r\n",stereoscopicInterlacePixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\nconst vec3 TWO = vec3(2.0, 2.0, 2.0);\r\n\r\nvarying vec2 vUV;\r\nuniform sampler2D camASampler;\r\nuniform sampler2D textureSampler;\r\nuniform vec2 stepSize;\r\n\r\nvoid main(void)\r\n{\r\n    bool useCamB;\r\n    vec2 texCoord1;\r\n    vec2 texCoord2;\r\n    \r\n    vec3 frag1;\r\n    vec3 frag2;\r\n    \r\n#ifdef IS_STEREOSCOPIC_HORIZ\r\n\t    useCamB = vUV.x > 0.5;\r\n\t    texCoord1 = vec2(useCamB ? (vUV.x - 0.5) * 2.0 : vUV.x * 2.0, vUV.y);\r\n\t    texCoord2 = vec2(texCoord1.x + stepSize.x, vUV.y);\r\n#else\r\n\t    useCamB = vUV.y > 0.5;\r\n\t    texCoord1 = vec2(vUV.x, useCamB ? (vUV.y - 0.5) * 2.0 : vUV.y * 2.0);\r\n\t    texCoord2 = vec2(vUV.x, texCoord1.y + stepSize.y);\r\n#endif\r\n    \r\n    // cannot assign a sampler to a variable, so must duplicate texture accesses\r\n    if (useCamB){\r\n        frag1 = texture2D(textureSampler, texCoord1).rgb;\r\n        frag2 = texture2D(textureSampler, texCoord2).rgb;\r\n    }else{\r\n        frag1 = texture2D(camASampler  , texCoord1).rgb;\r\n        frag2 = texture2D(camASampler  , texCoord2).rgb;\r\n    }\r\n    \r\n    gl_FragColor = vec4((frag1 + frag2) / TWO, 1.0);\r\n}",tonemapPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Samplers\r\nvarying vec2 vUV;\r\nuniform sampler2D textureSampler;\r\n\r\n// Constants\r\nuniform float _ExposureAdjustment;\r\n\r\n#if defined(HABLE_TONEMAPPING)\r\n    const float A = 0.15;\r\n    const float B = 0.50;\r\n    const float C = 0.10;\r\n    const float D = 0.20;\r\n    const float E = 0.02;\r\n    const float F = 0.30;\r\n    const float W = 11.2;\r\n#endif\r\n\r\nfloat Luminance(vec3 c)\r\n{\r\n    return dot(c, vec3(0.22, 0.707, 0.071));\r\n}\r\n\r\nvoid main(void) \r\n{\r\n    vec3 colour = texture2D(textureSampler, vUV).rgb;\r\n\r\n#if defined(REINHARD_TONEMAPPING)\r\n\r\n    float lum = Luminance(colour.rgb); \r\n    float lumTm = lum * _ExposureAdjustment;\r\n    float scale = lumTm / (1.0 + lumTm);  \r\n\r\n    colour *= scale / lum;\r\n\r\n#elif defined(HABLE_TONEMAPPING)\r\n\r\n    colour *= _ExposureAdjustment;\r\n\r\n    const float ExposureBias = 2.0;\r\n    vec3 x = ExposureBias * colour;\r\n\r\n    vec3 curr = ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F;\r\n    \r\n    x = vec3(W, W, W);\r\n    vec3 whiteScale = 1.0 / (((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F);\r\n    colour = curr * whiteScale;\r\n\r\n#elif defined(OPTIMIZED_HEJIDAWSON_TONEMAPPING)\r\n\r\n    colour *= _ExposureAdjustment;\r\n    \r\n    vec3 X = max(vec3(0.0, 0.0, 0.0), colour - 0.004);\r\n    vec3 retColor = (X * (6.2 * X + 0.5)) / (X * (6.2 * X + 1.7) + 0.06);\r\n\r\n    colour = retColor * retColor;\r\n\r\n#elif defined(PHOTOGRAPHIC_TONEMAPPING)\r\n\r\n    colour =  vec3(1.0, 1.0, 1.0) - exp2(-_ExposureAdjustment * colour);\r\n\r\n#endif\r\n\r\n\tgl_FragColor = vec4(colour.rgb, 1.0);\r\n}",volumetricLightScatteringPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\nuniform sampler2D textureSampler;\r\nuniform sampler2D lightScatteringSampler;\r\n\r\nuniform float decay;\r\nuniform float exposure;\r\nuniform float weight;\r\nuniform float density;\r\nuniform vec2 meshPositionOnScreen;\r\n\r\nvarying vec2 vUV;\r\n\r\nvoid main(void) {\r\n    vec2 tc = vUV;\r\n\tvec2 deltaTexCoord = (tc - meshPositionOnScreen.xy);\r\n    deltaTexCoord *= 1.0 / float(NUM_SAMPLES) * density;\r\n\r\n    float illuminationDecay = 1.0;\r\n\r\n\tvec4 color = texture2D(lightScatteringSampler, tc) * 0.4;\r\n\r\n    for(int i=0; i < NUM_SAMPLES; i++) {\r\n        tc -= deltaTexCoord;\r\n\t\tvec4 sample = texture2D(lightScatteringSampler, tc) * 0.4;\r\n        sample *= illuminationDecay * weight;\r\n        color += sample;\r\n        illuminationDecay *= decay;\r\n    }\r\n\r\n    vec4 realColor = texture2D(textureSampler, vUV);\r\n    gl_FragColor = ((vec4((vec3(color.r, color.g, color.b) * exposure), 1)) + (realColor * (1.5 - 0.4)));\r\n}\r\n",volumetricLightScatteringPassPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n#if defined(ALPHATEST) || defined(NEED_UV)\r\nvarying vec2 vUV;\r\n#endif\r\n\r\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\r\nuniform sampler2D diffuseSampler;\r\n#endif\r\n\r\n#if defined(DIFFUSE_COLOR_RENDER)\r\nuniform vec3 color;\r\n#endif\r\n\r\n#if defined(OPACITY)\r\nuniform sampler2D opacitySampler;\r\nuniform float opacityLevel;\r\n#endif\r\n\r\nvoid main(void)\r\n{\r\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\r\n\tvec4 diffuseColor = texture2D(diffuseSampler, vUV);\r\n#endif\r\n\r\n#ifdef ALPHATEST\r\n\tif (diffuseColor.a < 0.4)\r\n\t\tdiscard;\r\n#endif\r\n\r\n#ifdef OPACITY\r\n\tvec4 opacityColor = texture2D(opacitySampler, vUV);\r\n\tfloat alpha = 1.0;\r\n\r\n\t#ifdef OPACITYRGB\r\n\topacityColor.rgb = opacityColor.rgb * vec3(0.3, 0.59, 0.11);\r\n\talpha *= (opacityColor.x + opacityColor.y + opacityColor.z) * opacityLevel;\r\n\t#else\r\n\talpha *= opacityColor.a * opacityLevel;\r\n\t#endif\r\n\r\n\t#if defined(BASIC_RENDER)\r\n\tgl_FragColor = vec4(diffuseColor.rgb, alpha);\r\n\t#elif defined(DIFFUSE_COLOR_RENDER)\r\n\tgl_FragColor = vec4(color.rgb, alpha);\r\n\t#else\r\n\tgl_FragColor = vec4(0.0, 0.0, 0.0, alpha);\r\n\t#endif\r\n\r\n\tgl_FragColor.a = alpha;\r\n#else\r\n\r\n\t#if defined(BASIC_RENDER)\r\n\tgl_FragColor = diffuseColor;\r\n\t#elif defined(DIFFUSE_COLOR_RENDER)\r\n\tgl_FragColor = vec4(color.rgb, 1.0);\r\n\t#else\r\n\tgl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\r\n\t#endif\r\n#endif\r\n\r\n}\r\n",vrDistortionCorrectionPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\n// Samplers\r\nvarying vec2 vUV;\r\nuniform sampler2D textureSampler;\r\nuniform vec2 LensCenter;\r\nuniform vec2 Scale;\r\nuniform vec2 ScaleIn;\r\nuniform vec4 HmdWarpParam;\r\n\r\nvec2 HmdWarp(vec2 in01) {\r\n\r\n\tvec2 theta = (in01 - LensCenter) * ScaleIn; // Scales to [-1, 1]\r\n\tfloat rSq = theta.x * theta.x + theta.y * theta.y;\r\n\tvec2 rvector = theta * (HmdWarpParam.x + HmdWarpParam.y * rSq + HmdWarpParam.z * rSq * rSq + HmdWarpParam.w * rSq * rSq * rSq);\r\n\treturn LensCenter + Scale * rvector;\r\n}\r\n\r\nvoid main(void)\r\n{\r\n\tvec2 tc = HmdWarp(vUV);\r\n\tif (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0)\r\n\t\tgl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\r\n\telse{\r\n\t\tgl_FragColor = vec4(texture2D(textureSampler, tc).rgb, 1.0);\r\n\t}\r\n}",woodPixelShader:"#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\n\r\nvarying vec2 vPosition;\r\nvarying vec2 vUV;\r\n\r\nuniform float ampScale;\r\nuniform vec3 woodColor;\r\n\r\nfloat rand(vec2 n) {\r\n\treturn fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);\r\n}\r\n\r\nfloat noise(vec2 n) {\r\n\tconst vec2 d = vec2(0.0, 1.0);\r\n\tvec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));\r\n\treturn mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);\r\n}\r\n\r\nfloat fbm(vec2 n) {\r\n\tfloat total = 0.0, amplitude = 1.0;\r\n\tfor (int i = 0; i < 4; i++) {\r\n\t\ttotal += noise(n) * amplitude;\r\n\t\tn += n;\r\n\t\tamplitude *= 0.5;\r\n\t}\r\n\treturn total;\r\n}\r\n\r\nvoid main(void) {\r\n\tfloat ratioy = mod(vUV.x * ampScale, 2.0 + fbm(vUV * 0.8));\r\n\tvec3 wood = woodColor * ratioy;\r\n\tgl_FragColor = vec4(wood, 1.0);\r\n}"},BABYLON.CollisionWorker='var BABYLON;!function(t){var e=function(t,e,o,i){return t.x>o.x+i?!1:o.x-i>e.x?!1:t.y>o.y+i?!1:o.y-i>e.y?!1:t.z>o.z+i?!1:o.z-i>e.z?!1:!0},o=function(t,e,o,i){var s=e*e-4*t*o,r={root:0,found:!1};if(0>s)return r;var n=Math.sqrt(s),c=(-e-n)/(2*t),h=(-e+n)/(2*t);if(c>h){var a=h;h=c,c=a}return c>0&&i>c?(r.root=c,r.found=!0,r):h>0&&i>h?(r.root=h,r.found=!0,r):r},i=function(){function i(){this.radius=new t.Vector3(1,1,1),this.retry=0,this.basePointWorld=t.Vector3.Zero(),this.velocityWorld=t.Vector3.Zero(),this.normalizedVelocity=t.Vector3.Zero(),this._collisionPoint=t.Vector3.Zero(),this._planeIntersectionPoint=t.Vector3.Zero(),this._tempVector=t.Vector3.Zero(),this._tempVector2=t.Vector3.Zero(),this._tempVector3=t.Vector3.Zero(),this._tempVector4=t.Vector3.Zero(),this._edge=t.Vector3.Zero(),this._baseToVertex=t.Vector3.Zero(),this._destinationPoint=t.Vector3.Zero(),this._slidePlaneNormal=t.Vector3.Zero(),this._displacementVector=t.Vector3.Zero()}return i.prototype._initialize=function(e,o,i){this.velocity=o,t.Vector3.NormalizeToRef(o,this.normalizedVelocity),this.basePoint=e,e.multiplyToRef(this.radius,this.basePointWorld),o.multiplyToRef(this.radius,this.velocityWorld),this.velocityWorldLength=this.velocityWorld.length(),this.epsilon=i,this.collisionFound=!1},i.prototype._checkPointInTriangle=function(e,o,i,s,r){o.subtractToRef(e,this._tempVector),i.subtractToRef(e,this._tempVector2),t.Vector3.CrossToRef(this._tempVector,this._tempVector2,this._tempVector4);var n=t.Vector3.Dot(this._tempVector4,r);return 0>n?!1:(s.subtractToRef(e,this._tempVector3),t.Vector3.CrossToRef(this._tempVector2,this._tempVector3,this._tempVector4),n=t.Vector3.Dot(this._tempVector4,r),0>n?!1:(t.Vector3.CrossToRef(this._tempVector3,this._tempVector,this._tempVector4),n=t.Vector3.Dot(this._tempVector4,r),n>=0))},i.prototype._canDoCollision=function(o,i,s,r){var n=t.Vector3.Distance(this.basePointWorld,o),c=Math.max(this.radius.x,this.radius.y,this.radius.z);return n>this.velocityWorldLength+c+i?!1:e(s,r,this.basePointWorld,this.velocityWorldLength+c)?!0:!1},i.prototype._testTriangle=function(e,i,s,r,n,c){var h,a=!1;i||(i=[]),i[e]||(i[e]=new t.Plane(0,0,0,0),i[e].copyFromPoints(s,r,n));var l=i[e];if(c||l.isFrontFacingTo(this.normalizedVelocity,0)){var _=l.signedDistanceTo(this.basePoint),d=t.Vector3.Dot(l.normal,this.velocity);if(0==d){if(Math.abs(_)>=1)return;a=!0,h=0}else{h=(-1-_)/d;var V=(1-_)/d;if(h>V){var u=V;V=h,h=u}if(h>1||0>V)return;0>h&&(h=0),h>1&&(h=1)}this._collisionPoint.copyFromFloats(0,0,0);var P=!1,p=1;if(a||(this.basePoint.subtractToRef(l.normal,this._planeIntersectionPoint),this.velocity.scaleToRef(h,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,s,r,n,l.normal)&&(P=!0,p=h,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!P){var m=this.velocity.lengthSquared(),f=m;this.basePoint.subtractToRef(s,this._tempVector);var T=2*t.Vector3.Dot(this.velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,y=o(f,T,b,p);y.found&&(p=y.root,P=!0,this._collisionPoint.copyFrom(s)),this.basePoint.subtractToRef(r,this._tempVector),T=2*t.Vector3.Dot(this.velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,y=o(f,T,b,p),y.found&&(p=y.root,P=!0,this._collisionPoint.copyFrom(r)),this.basePoint.subtractToRef(n,this._tempVector),T=2*t.Vector3.Dot(this.velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,y=o(f,T,b,p),y.found&&(p=y.root,P=!0,this._collisionPoint.copyFrom(n)),r.subtractToRef(s,this._edge),s.subtractToRef(this.basePoint,this._baseToVertex);var g=this._edge.lengthSquared(),v=t.Vector3.Dot(this._edge,this.velocity),R=t.Vector3.Dot(this._edge,this._baseToVertex);if(f=g*-m+v*v,T=2*g*t.Vector3.Dot(this.velocity,this._baseToVertex)-2*v*R,b=g*(1-this._baseToVertex.lengthSquared())+R*R,y=o(f,T,b,p),y.found){var D=(v*y.root-R)/g;D>=0&&1>=D&&(p=y.root,P=!0,this._edge.scaleInPlace(D),s.addToRef(this._edge,this._collisionPoint))}n.subtractToRef(r,this._edge),r.subtractToRef(this.basePoint,this._baseToVertex),g=this._edge.lengthSquared(),v=t.Vector3.Dot(this._edge,this.velocity),R=t.Vector3.Dot(this._edge,this._baseToVertex),f=g*-m+v*v,T=2*g*t.Vector3.Dot(this.velocity,this._baseToVertex)-2*v*R,b=g*(1-this._baseToVertex.lengthSquared())+R*R,y=o(f,T,b,p),y.found&&(D=(v*y.root-R)/g,D>=0&&1>=D&&(p=y.root,P=!0,this._edge.scaleInPlace(D),r.addToRef(this._edge,this._collisionPoint))),s.subtractToRef(n,this._edge),n.subtractToRef(this.basePoint,this._baseToVertex),g=this._edge.lengthSquared(),v=t.Vector3.Dot(this._edge,this.velocity),R=t.Vector3.Dot(this._edge,this._baseToVertex),f=g*-m+v*v,T=2*g*t.Vector3.Dot(this.velocity,this._baseToVertex)-2*v*R,b=g*(1-this._baseToVertex.lengthSquared())+R*R,y=o(f,T,b,p),y.found&&(D=(v*y.root-R)/g,D>=0&&1>=D&&(p=y.root,P=!0,this._edge.scaleInPlace(D),n.addToRef(this._edge,this._collisionPoint)))}if(P){var x=p*this.velocity.length();(!this.collisionFound||x<this.nearestDistance)&&(this.intersectionPoint?this.intersectionPoint.copyFrom(this._collisionPoint):this.intersectionPoint=this._collisionPoint.clone(),this.nearestDistance=x,this.collisionFound=!0)}}},i.prototype._collide=function(t,e,o,i,s,r,n){for(var c=i;s>c;c+=3){var h=e[o[c]-r],a=e[o[c+1]-r],l=e[o[c+2]-r];this._testTriangle(c,t,l,a,h,n)}},i.prototype._getResponse=function(e,o){e.addToRef(o,this._destinationPoint),o.scaleInPlace(this.nearestDistance/o.length()),this.basePoint.addToRef(o,e),e.subtractToRef(this.intersectionPoint,this._slidePlaneNormal),this._slidePlaneNormal.normalize(),this._slidePlaneNormal.scaleToRef(this.epsilon,this._displacementVector),e.addInPlace(this._displacementVector),this.intersectionPoint.addInPlace(this._displacementVector),this._slidePlaneNormal.scaleInPlace(t.Plane.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint,this._slidePlaneNormal,this._destinationPoint)),this._destinationPoint.subtractInPlace(this._slidePlaneNormal),this._destinationPoint.subtractToRef(this.intersectionPoint,o)},i}();t.Collider=i}(BABYLON||(BABYLON={}));var BABYLON;!function(o){o.WorkerIncluded=!0;var e=function(){function o(){this._meshes={},this._geometries={}}return o.prototype.getMeshes=function(){return this._meshes},o.prototype.getGeometries=function(){return this._geometries},o.prototype.getMesh=function(o){return this._meshes[o]},o.prototype.addMesh=function(o){this._meshes[o.uniqueId]=o},o.prototype.removeMesh=function(o){delete this._meshes[o]},o.prototype.getGeometry=function(o){return this._geometries[o]},o.prototype.addGeometry=function(o){this._geometries[o.id]=o},o.prototype.removeGeometry=function(o){delete this._geometries[o]},o}();o.CollisionCache=e;var i=function(){function e(e,i,r){this.collider=e,this._collisionCache=i,this.finalPosition=r,this.collisionsScalingMatrix=o.Matrix.Zero(),this.collisionTranformationMatrix=o.Matrix.Zero()}return e.prototype.collideWithWorld=function(o,e,i,r){var t=.01;if(this.collider.retry>=i)return void this.finalPosition.copyFrom(o);this.collider._initialize(o,e,t);for(var s,l=this._collisionCache.getMeshes(),n=Object.keys(l),a=n.length,c=0;a>c;++c)if(s=n[c],parseInt(s)!=r){var d=l[s];d.checkCollisions&&this.checkCollision(d)}return this.collider.collisionFound?((0!==e.x||0!==e.y||0!==e.z)&&this.collider._getResponse(o,e),e.length()<=t?void this.finalPosition.copyFrom(o):(this.collider.retry++,void this.collideWithWorld(o,e,i,r))):void o.addToRef(e,this.finalPosition)},e.prototype.checkCollision=function(e){if(this.collider._canDoCollision(o.Vector3.FromArray(e.sphereCenter),e.sphereRadius,o.Vector3.FromArray(e.boxMinimum),o.Vector3.FromArray(e.boxMaximum))){o.Matrix.ScalingToRef(1/this.collider.radius.x,1/this.collider.radius.y,1/this.collider.radius.z,this.collisionsScalingMatrix);var i=o.Matrix.FromArray(e.worldMatrixFromCache);i.multiplyToRef(this.collisionsScalingMatrix,this.collisionTranformationMatrix),this.processCollisionsForSubMeshes(this.collisionTranformationMatrix,e)}},e.prototype.processCollisionsForSubMeshes=function(o,e){var i=e.subMeshes,r=i.length;if(!e.geometryId)return void console.log("no mesh geometry id");var t=this._collisionCache.getGeometry(e.geometryId);if(!t)return void console.log("couldn\'t find geometry",e.geometryId);for(var s=0;r>s;s++){var l=i[s];r>1&&!this.checkSubmeshCollision(l)||(this.collideForSubMesh(l,o,t),this.collider.collisionFound&&(this.collider.collidedMesh=e.uniqueId))}},e.prototype.collideForSubMesh=function(e,i,r){if(!r.positionsArray){r.positionsArray=[];for(var t=0,s=r.positions.length;s>t;t+=3){var l=o.Vector3.FromArray([r.positions[t],r.positions[t+1],r.positions[t+2]]);r.positionsArray.push(l)}}if(!e._lastColliderWorldVertices||!e._lastColliderTransformMatrix.equals(i)){e._lastColliderTransformMatrix=i.clone(),e._lastColliderWorldVertices=[],e._trianglePlanes=[];for(var n=e.verticesStart,a=e.verticesStart+e.verticesCount,t=n;a>t;t++)e._lastColliderWorldVertices.push(o.Vector3.TransformCoordinates(r.positionsArray[t],i))}this.collider._collide(e._trianglePlanes,e._lastColliderWorldVertices,r.indices,e.indexStart,e.indexStart+e.indexCount,e.verticesStart,e.hasMaterial)},e.prototype.checkSubmeshCollision=function(e){return this.collider._canDoCollision(o.Vector3.FromArray(e.sphereCenter),e.sphereRadius,o.Vector3.FromArray(e.boxMinimum),o.Vector3.FromArray(e.boxMaximum))},e}();o.CollideWorker=i;var r=function(){function r(){}return r.prototype.onInit=function(i){this._collisionCache=new e;var r={error:o.WorkerReplyType.SUCCESS,taskType:o.WorkerTaskType.INIT};postMessage(r,void 0)},r.prototype.onUpdate=function(e){var i=this,r={error:o.WorkerReplyType.SUCCESS,taskType:o.WorkerTaskType.UPDATE};try{for(var t in e.updatedGeometries)e.updatedGeometries.hasOwnProperty(t)&&this._collisionCache.addGeometry(e.updatedGeometries[t]);for(var s in e.updatedMeshes)e.updatedMeshes.hasOwnProperty(s)&&this._collisionCache.addMesh(e.updatedMeshes[s]);e.removedGeometries.forEach(function(o){i._collisionCache.removeGeometry(o)}),e.removedMeshes.forEach(function(o){i._collisionCache.removeMesh(o)})}catch(l){r.error=o.WorkerReplyType.UNKNOWN_ERROR}postMessage(r,void 0)},r.prototype.onCollision=function(e){var r=o.Vector3.Zero(),t=new o.Collider;t.radius=o.Vector3.FromArray(e.collider.radius);var s=new i(t,this._collisionCache,r);s.collideWithWorld(o.Vector3.FromArray(e.collider.position),o.Vector3.FromArray(e.collider.velocity),e.maximumRetry,e.excludedMeshUniqueId);var l={collidedMeshUniqueId:t.collidedMesh,collisionId:e.collisionId,newPosition:r.asArray()},n={error:o.WorkerReplyType.SUCCESS,taskType:o.WorkerTaskType.COLLIDE,payload:l};postMessage(n,void 0)},r}();o.CollisionDetectorTransferable=r;try{if(self&&self instanceof WorkerGlobalScope){window={},o.Collider||(importScripts("./babylon.collisionCoordinator.js"),importScripts("./babylon.collider.js"),importScripts("../Math/babylon.math.js"));var t=new r,s=function(e){var i=e.data;switch(i.taskType){case o.WorkerTaskType.INIT:t.onInit(i.payload);break;case o.WorkerTaskType.COLLIDE:t.onCollision(i.payload);break;case o.WorkerTaskType.UPDATE:t.onUpdate(i.payload)}};self.onmessage=s}}catch(l){console.log("single worker init")}}(BABYLON||(BABYLON={}));var BABYLON;!function(e){e.CollisionWorker="",function(e){e[e.INIT=0]="INIT",e[e.UPDATE=1]="UPDATE",e[e.COLLIDE=2]="COLLIDE"}(e.WorkerTaskType||(e.WorkerTaskType={}));var o=e.WorkerTaskType;!function(e){e[e.SUCCESS=0]="SUCCESS",e[e.UNKNOWN_ERROR=1]="UNKNOWN_ERROR"}(e.WorkerReplyType||(e.WorkerReplyType={}));var i=e.WorkerReplyType,t=function(){function t(){var r=this;this._scaledPosition=e.Vector3.Zero(),this._scaledVelocity=e.Vector3.Zero(),this.onMeshUpdated=function(e){r._addUpdateMeshesList[e.uniqueId]=t.SerializeMesh(e)},this.onGeometryUpdated=function(e){r._addUpdateGeometriesList[e.id]=t.SerializeGeometry(e)},this._afterRender=function(){if(r._init&&!(0==r._toRemoveGeometryArray.length&&0==r._toRemoveMeshesArray.length&&0==Object.keys(r._addUpdateGeometriesList).length&&0==Object.keys(r._addUpdateMeshesList).length||r._runningUpdated>4)){++r._runningUpdated;var e={updatedMeshes:r._addUpdateMeshesList,updatedGeometries:r._addUpdateGeometriesList,removedGeometries:r._toRemoveGeometryArray,removedMeshes:r._toRemoveMeshesArray},i={payload:e,taskType:o.UPDATE},t=[];for(var s in e.updatedGeometries)e.updatedGeometries.hasOwnProperty(s)&&(t.push(i.payload.updatedGeometries[s].indices.buffer),t.push(i.payload.updatedGeometries[s].normals.buffer),t.push(i.payload.updatedGeometries[s].positions.buffer));r._worker.postMessage(i,t),r._addUpdateMeshesList={},r._addUpdateGeometriesList={},r._toRemoveGeometryArray=[],r._toRemoveMeshesArray=[]}},this._onMessageFromWorker=function(t){var s=t.data;if(s.error!=i.SUCCESS)return void e.Tools.Warn("error returned from worker!");switch(s.taskType){case o.INIT:r._init=!0,r._scene.meshes.forEach(function(e){r.onMeshAdded(e)}),r._scene.getGeometries().forEach(function(e){r.onGeometryAdded(e)});break;case o.UPDATE:r._runningUpdated--;break;case o.COLLIDE:r._runningCollisionTask=!1;var n=s.payload;if(!r._collisionsCallbackArray[n.collisionId])return;r._collisionsCallbackArray[n.collisionId](n.collisionId,e.Vector3.FromArray(n.newPosition),r._scene.getMeshByUniqueID(n.collidedMeshUniqueId)),r._collisionsCallbackArray[n.collisionId]=void 0}},this._collisionsCallbackArray=[],this._init=!1,this._runningUpdated=0,this._runningCollisionTask=!1,this._addUpdateMeshesList={},this._addUpdateGeometriesList={},this._toRemoveGeometryArray=[],this._toRemoveMeshesArray=[]}return t.prototype.getNewPosition=function(e,i,t,r,s,n,a){if(this._init&&!this._collisionsCallbackArray[a]&&!this._collisionsCallbackArray[a+1e5]){e.divideToRef(t.radius,this._scaledPosition),i.divideToRef(t.radius,this._scaledVelocity),this._collisionsCallbackArray[a]=n;var d={collider:{position:this._scaledPosition.asArray(),velocity:this._scaledVelocity.asArray(),radius:t.radius.asArray()},collisionId:a,excludedMeshUniqueId:s?s.uniqueId:null,maximumRetry:r},l={payload:d,taskType:o.COLLIDE};this._worker.postMessage(l)}},t.prototype.init=function(i){this._scene=i,this._scene.registerAfterRender(this._afterRender);var t=e.WorkerIncluded?e.Engine.CodeRepository+"Collisions/babylon.collisionWorker.js":URL.createObjectURL(new Blob([e.CollisionWorker],{type:"application/javascript"}));this._worker=new Worker(t),this._worker.onmessage=this._onMessageFromWorker;var r={payload:{},taskType:o.INIT};this._worker.postMessage(r)},t.prototype.destroy=function(){this._scene.unregisterAfterRender(this._afterRender),this._worker.terminate()},t.prototype.onMeshAdded=function(e){e.registerAfterWorldMatrixUpdate(this.onMeshUpdated),this.onMeshUpdated(e)},t.prototype.onMeshRemoved=function(e){this._toRemoveMeshesArray.push(e.uniqueId)},t.prototype.onGeometryAdded=function(e){e.onGeometryUpdated=this.onGeometryUpdated,this.onGeometryUpdated(e)},t.prototype.onGeometryDeleted=function(e){this._toRemoveGeometryArray.push(e.id)},t.SerializeMesh=function(o){var i=[];o.subMeshes&&(i=o.subMeshes.map(function(e,o){return{position:o,verticesStart:e.verticesStart,verticesCount:e.verticesCount,indexStart:e.indexStart,indexCount:e.indexCount,hasMaterial:!!e.getMaterial(),sphereCenter:e.getBoundingInfo().boundingSphere.centerWorld.asArray(),sphereRadius:e.getBoundingInfo().boundingSphere.radiusWorld,boxMinimum:e.getBoundingInfo().boundingBox.minimumWorld.asArray(),boxMaximum:e.getBoundingInfo().boundingBox.maximumWorld.asArray()}}));var t=null;return o instanceof e.Mesh?t=o.geometry?o.geometry.id:null:o instanceof e.InstancedMesh&&(t=o.sourceMesh&&o.sourceMesh.geometry?o.sourceMesh.geometry.id:null),{uniqueId:o.uniqueId,id:o.id,name:o.name,geometryId:t,sphereCenter:o.getBoundingInfo().boundingSphere.centerWorld.asArray(),sphereRadius:o.getBoundingInfo().boundingSphere.radiusWorld,boxMinimum:o.getBoundingInfo().boundingBox.minimumWorld.asArray(),boxMaximum:o.getBoundingInfo().boundingBox.maximumWorld.asArray(),worldMatrixFromCache:o.worldMatrixFromCache.asArray(),subMeshes:i,checkCollisions:o.checkCollisions}},t.SerializeGeometry=function(o){return{id:o.id,positions:new Float32Array(o.getVerticesData(e.VertexBuffer.PositionKind)||[]),normals:new Float32Array(o.getVerticesData(e.VertexBuffer.NormalKind)||[]),indices:new Int32Array(o.getIndices()||[])}},t}();e.CollisionCoordinatorWorker=t;var r=function(){function o(){this._scaledPosition=e.Vector3.Zero(),this._scaledVelocity=e.Vector3.Zero(),this._finalPosition=e.Vector3.Zero()}return o.prototype.getNewPosition=function(e,o,i,t,r,s,n){e.divideToRef(i.radius,this._scaledPosition),o.divideToRef(i.radius,this._scaledVelocity),i.collidedMesh=null,i.retry=0,i.initialVelocity=this._scaledVelocity,i.initialPosition=this._scaledPosition,this._collideWithWorld(this._scaledPosition,this._scaledVelocity,i,t,this._finalPosition,r),this._finalPosition.multiplyInPlace(i.radius),s(n,this._finalPosition,i.collidedMesh)},o.prototype.init=function(e){this._scene=e},o.prototype.destroy=function(){},o.prototype.onMeshAdded=function(e){},o.prototype.onMeshUpdated=function(e){},o.prototype.onMeshRemoved=function(e){},o.prototype.onGeometryAdded=function(e){},o.prototype.onGeometryUpdated=function(e){},o.prototype.onGeometryDeleted=function(e){},o.prototype._collideWithWorld=function(o,i,t,r,s,n){void 0===n&&(n=null);var a=10*e.Engine.CollisionsEpsilon;if(t.retry>=r)return void s.copyFrom(o);t._initialize(o,i,a);for(var d=0;d<this._scene.meshes.length;d++){var l=this._scene.meshes[d];l.isEnabled()&&l.checkCollisions&&l.subMeshes&&l!==n&&l._checkCollision(t)}return t.collisionFound?((0!==i.x||0!==i.y||0!==i.z)&&t._getResponse(o,i),i.length()<=a?void s.copyFrom(o):(t.retry++,void this._collideWithWorld(o,i,t,r,s,n))):void o.addToRef(i,s)},o}();e.CollisionCoordinatorLegacy=r}(BABYLON||(BABYLON={}));var BABYLON;!function(t){var i=function(){function i(t,i,o){void 0===t&&(t=0),void 0===i&&(i=0),void 0===o&&(o=0),this.r=t,this.g=i,this.b=o}return i.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},i.prototype.toArray=function(t,i){return void 0===i&&(i=0),t[i]=this.r,t[i+1]=this.g,t[i+2]=this.b,this},i.prototype.toColor4=function(t){return void 0===t&&(t=1),new o(this.r,this.g,this.b,t)},i.prototype.asArray=function(){var t=[];return this.toArray(t,0),t},i.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},i.prototype.multiply=function(t){return new i(this.r*t.r,this.g*t.g,this.b*t.b)},i.prototype.multiplyToRef=function(t,i){return i.r=this.r*t.r,i.g=this.g*t.g,i.b=this.b*t.b,this},i.prototype.equals=function(t){return t&&this.r===t.r&&this.g===t.g&&this.b===t.b},i.prototype.equalsFloats=function(t,i,o){return this.r===t&&this.g===i&&this.b===o},i.prototype.scale=function(t){return new i(this.r*t,this.g*t,this.b*t)},i.prototype.scaleToRef=function(t,i){return i.r=this.r*t,i.g=this.g*t,i.b=this.b*t,this},i.prototype.add=function(t){return new i(this.r+t.r,this.g+t.g,this.b+t.b)},i.prototype.addToRef=function(t,i){return i.r=this.r+t.r,i.g=this.g+t.g,i.b=this.b+t.b,this},i.prototype.subtract=function(t){return new i(this.r-t.r,this.g-t.g,this.b-t.b)},i.prototype.subtractToRef=function(t,i){return i.r=this.r-t.r,i.g=this.g-t.g,i.b=this.b-t.b,this},i.prototype.clone=function(){return new i(this.r,this.g,this.b)},i.prototype.copyFrom=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},i.prototype.copyFromFloats=function(t,i,o){return this.r=t,this.g=i,this.b=o,this},i.prototype.toHexString=function(){var i=255*this.r|0,o=255*this.g|0,n=255*this.b|0;return"#"+t.Tools.ToHex(i)+t.Tools.ToHex(o)+t.Tools.ToHex(n)},i.FromHexString=function(o){if("#"!==o.substring(0,1)||7!==o.length)return t.Tools.Warn("Color3.FromHexString must be called with a string like #FFFFFF"),new i(0,0,0);var n=parseInt(o.substring(1,3),16),r=parseInt(o.substring(3,5),16),s=parseInt(o.substring(5,7),16);return i.FromInts(n,r,s)},i.FromArray=function(t,o){return void 0===o&&(o=0),new i(t[o],t[o+1],t[o+2])},i.FromInts=function(t,o,n){return new i(t/255,o/255,n/255)},i.Lerp=function(t,o,n){var r=t.r+(o.r-t.r)*n,s=t.g+(o.g-t.g)*n,e=t.b+(o.b-t.b)*n;return new i(r,s,e)},i.Red=function(){return new i(1,0,0)},i.Green=function(){return new i(0,1,0)},i.Blue=function(){return new i(0,0,1)},i.Black=function(){return new i(0,0,0)},i.White=function(){return new i(1,1,1)},i.Purple=function(){return new i(.5,0,.5)},i.Magenta=function(){return new i(1,0,1)},i.Yellow=function(){return new i(1,1,0)},i.Gray=function(){return new i(.5,.5,.5)},i}();t.Color3=i;var o=function(){function i(t,i,o,n){this.r=t,this.g=i,this.b=o,this.a=n}return i.prototype.addInPlace=function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this.a+=t.a,this},i.prototype.asArray=function(){var t=[];return this.toArray(t,0),t},i.prototype.toArray=function(t,i){return void 0===i&&(i=0),t[i]=this.r,t[i+1]=this.g,t[i+2]=this.b,t[i+3]=this.a,this},i.prototype.add=function(t){return new i(this.r+t.r,this.g+t.g,this.b+t.b,this.a+t.a)},i.prototype.subtract=function(t){return new i(this.r-t.r,this.g-t.g,this.b-t.b,this.a-t.a)},i.prototype.subtractToRef=function(t,i){return i.r=this.r-t.r,i.g=this.g-t.g,i.b=this.b-t.b,i.a=this.a-t.a,this},i.prototype.scale=function(t){return new i(this.r*t,this.g*t,this.b*t,this.a*t)},i.prototype.scaleToRef=function(t,i){return i.r=this.r*t,i.g=this.g*t,i.b=this.b*t,i.a=this.a*t,this},i.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"},i.prototype.clone=function(){return new i(this.r,this.g,this.b,this.a)},i.prototype.copyFrom=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this},i.prototype.toHexString=function(){var i=255*this.r|0,o=255*this.g|0,n=255*this.b|0,r=255*this.a|0;return"#"+t.Tools.ToHex(i)+t.Tools.ToHex(o)+t.Tools.ToHex(n)+t.Tools.ToHex(r)},i.FromHexString=function(o){if("#"!==o.substring(0,1)||9!==o.length)return t.Tools.Warn("Color4.FromHexString must be called with a string like #FFFFFFFF"),new i(0,0,0,0);var n=parseInt(o.substring(1,3),16),r=parseInt(o.substring(3,5),16),s=parseInt(o.substring(5,7),16),e=parseInt(o.substring(7,9),16);return i.FromInts(n,r,s,e)},i.Lerp=function(t,o,n){var r=new i(0,0,0,0);return i.LerpToRef(t,o,n,r),r},i.LerpToRef=function(t,i,o,n){n.r=t.r+(i.r-t.r)*o,n.g=t.g+(i.g-t.g)*o,n.b=t.b+(i.b-t.b)*o,n.a=t.a+(i.a-t.a)*o},i.FromArray=function(t,o){return void 0===o&&(o=0),new i(t[o],t[o+1],t[o+2],t[o+3])},i.FromInts=function(t,o,n,r){return new i(t/255,o/255,n/255,r/255)},i}();t.Color4=o;var n=function(){function i(t,i){this.x=t,this.y=i}return i.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+"}"},i.prototype.toArray=function(t,i){return void 0===i&&(i=0),t[i]=this.x,t[i+1]=this.y,this},i.prototype.asArray=function(){var t=[];return this.toArray(t,0),t},i.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this},i.prototype.copyFromFloats=function(t,i){return this.x=t,this.y=i,this},i.prototype.add=function(t){return new i(this.x+t.x,this.y+t.y)},i.prototype.addVector3=function(t){return new i(this.x+t.x,this.y+t.y)},i.prototype.subtract=function(t){return new i(this.x-t.x,this.y-t.y)},i.prototype.subtractInPlace=function(t){return this.x-=t.x,this.y-=t.y,this},i.prototype.multiplyInPlace=function(t){return this.x*=t.x,this.y*=t.y,this},i.prototype.multiply=function(t){return new i(this.x*t.x,this.y*t.y)},i.prototype.multiplyToRef=function(t,i){return i.x=this.x*t.x,i.y=this.y*t.y,this},i.prototype.multiplyByFloats=function(t,o){return new i(this.x*t,this.y*o)},i.prototype.divide=function(t){return new i(this.x/t.x,this.y/t.y)},i.prototype.divideToRef=function(t,i){return i.x=this.x/t.x,i.y=this.y/t.y,this},i.prototype.negate=function(){return new i(-this.x,-this.y)},i.prototype.scaleInPlace=function(t){return this.x*=t,this.y*=t,this},i.prototype.scale=function(t){return new i(this.x*t,this.y*t)},i.prototype.equals=function(t){return t&&this.x===t.x&&this.y===t.y},i.prototype.equalsWithEpsilon=function(i,o){return void 0===o&&(o=t.Engine.Epsilon),i&&t.Tools.WithinEpsilon(this.x,i.x,o)&&t.Tools.WithinEpsilon(this.y,i.y,o)},i.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},i.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},i.prototype.normalize=function(){var t=this.length();if(0===t)return this;var i=1/t;return this.x*=i,this.y*=i,this},i.prototype.clone=function(){return new i(this.x,this.y)},i.Zero=function(){return new i(0,0)},i.FromArray=function(t,o){return void 0===o&&(o=0),new i(t[o],t[o+1])},i.FromArrayToRef=function(t,i,o){o.x=t[i],o.y=t[i+1]},i.CatmullRom=function(t,o,n,r,s){var e=s*s,a=s*e,h=.5*(2*o.x+(-t.x+n.x)*s+(2*t.x-5*o.x+4*n.x-r.x)*e+(-t.x+3*o.x-3*n.x+r.x)*a),u=.5*(2*o.y+(-t.y+n.y)*s+(2*t.y-5*o.y+4*n.y-r.y)*e+(-t.y+3*o.y-3*n.y+r.y)*a);return new i(h,u)},i.Clamp=function(t,o,n){var r=t.x;r=r>n.x?n.x:r,r=r<o.x?o.x:r;var s=t.y;return s=s>n.y?n.y:s,s=s<o.y?o.y:s,new i(r,s)},i.Hermite=function(t,o,n,r,s){var e=s*s,a=s*e,h=2*a-3*e+1,u=-2*a+3*e,l=a-2*e+s,m=a-e,f=t.x*h+n.x*u+o.x*l+r.x*m,x=t.y*h+n.y*u+o.y*l+r.y*m;return new i(f,x)},i.Lerp=function(t,o,n){var r=t.x+(o.x-t.x)*n,s=t.y+(o.y-t.y)*n;return new i(r,s)},i.Dot=function(t,i){return t.x*i.x+t.y*i.y},i.Normalize=function(t){var i=t.clone();return i.normalize(),i},i.Minimize=function(t,o){var n=t.x<o.x?t.x:o.x,r=t.y<o.y?t.y:o.y;return new i(n,r)},i.Maximize=function(t,o){var n=t.x>o.x?t.x:o.x,r=t.y>o.y?t.y:o.y;return new i(n,r)},i.Transform=function(t,o){var n=t.x*o.m[0]+t.y*o.m[4],r=t.x*o.m[1]+t.y*o.m[5];return new i(n,r)},i.Distance=function(t,o){return Math.sqrt(i.DistanceSquared(t,o))},i.DistanceSquared=function(t,i){var o=t.x-i.x,n=t.y-i.y;return o*o+n*n},i}();t.Vector2=n;var r=function(){function i(t,i,o){this.x=t,this.y=i,this.z=o}return i.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"}"},i.prototype.asArray=function(){var t=[];return this.toArray(t,0),t},i.prototype.toArray=function(t,i){return void 0===i&&(i=0),t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,this},i.prototype.toQuaternion=function(){var t=new e(0,0,0,1),i=Math.cos(.5*(this.x+this.z)),o=Math.sin(.5*(this.x+this.z)),n=Math.cos(.5*(this.z-this.x)),r=Math.sin(.5*(this.z-this.x)),s=Math.cos(.5*this.y),a=Math.sin(.5*this.y);return t.x=n*a,t.y=-r*a,t.z=o*s,t.w=i*s,t},i.prototype.addInPlace=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},i.prototype.add=function(t){return new i(this.x+t.x,this.y+t.y,this.z+t.z)},i.prototype.addToRef=function(t,i){return i.x=this.x+t.x,i.y=this.y+t.y,i.z=this.z+t.z,this},i.prototype.subtractInPlace=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},i.prototype.subtract=function(t){return new i(this.x-t.x,this.y-t.y,this.z-t.z)},i.prototype.subtractToRef=function(t,i){return i.x=this.x-t.x,i.y=this.y-t.y,i.z=this.z-t.z,this},i.prototype.subtractFromFloats=function(t,o,n){return new i(this.x-t,this.y-o,this.z-n)},i.prototype.subtractFromFloatsToRef=function(t,i,o,n){return n.x=this.x-t,n.y=this.y-i,n.z=this.z-o,this},i.prototype.negate=function(){return new i(-this.x,-this.y,-this.z)},i.prototype.scaleInPlace=function(t){return this.x*=t,this.y*=t,this.z*=t,this},i.prototype.scale=function(t){return new i(this.x*t,this.y*t,this.z*t)},i.prototype.scaleToRef=function(t,i){i.x=this.x*t,i.y=this.y*t,i.z=this.z*t},i.prototype.equals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.z===t.z},i.prototype.equalsWithEpsilon=function(i,o){return void 0===o&&(o=t.Engine.Epsilon),i&&t.Tools.WithinEpsilon(this.x,i.x,o)&&t.Tools.WithinEpsilon(this.y,i.y,o)&&t.Tools.WithinEpsilon(this.z,i.z,o)},i.prototype.equalsToFloats=function(t,i,o){return this.x===t&&this.y===i&&this.z===o},i.prototype.multiplyInPlace=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this},i.prototype.multiply=function(t){return new i(this.x*t.x,this.y*t.y,this.z*t.z)},i.prototype.multiplyToRef=function(t,i){return i.x=this.x*t.x,i.y=this.y*t.y,i.z=this.z*t.z,this},i.prototype.multiplyByFloats=function(t,o,n){return new i(this.x*t,this.y*o,this.z*n)},i.prototype.divide=function(t){return new i(this.x/t.x,this.y/t.y,this.z/t.z)},i.prototype.divideToRef=function(t,i){return i.x=this.x/t.x,i.y=this.y/t.y,i.z=this.z/t.z,this},i.prototype.MinimizeInPlace=function(t){return t.x<this.x&&(this.x=t.x),t.y<this.y&&(this.y=t.y),t.z<this.z&&(this.z=t.z),this},i.prototype.MaximizeInPlace=function(t){return t.x>this.x&&(this.x=t.x),t.y>this.y&&(this.y=t.y),t.z>this.z&&(this.z=t.z),this},i.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},i.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},i.prototype.normalize=function(){var t=this.length();if(0===t||1===t)return this;var i=1/t;return this.x*=i,this.y*=i,this.z*=i,this},i.prototype.clone=function(){return new i(this.x,this.y,this.z)},i.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},i.prototype.copyFromFloats=function(t,i,o){return this.x=t,this.y=i,this.z=o,this},i.GetClipFactor=function(t,o,n,r){var s=i.Dot(t,n)-r,e=i.Dot(o,n)-r,a=s/(s-e);return a},i.FromArray=function(t,o){return o||(o=0),new i(t[o],t[o+1],t[o+2])},i.FromFloatArray=function(t,o){return o||(o=0),new i(t[o],t[o+1],t[o+2])},i.FromArrayToRef=function(t,i,o){o.x=t[i],o.y=t[i+1],o.z=t[i+2]},i.FromFloatArrayToRef=function(t,i,o){o.x=t[i],o.y=t[i+1],o.z=t[i+2]},i.FromFloatsToRef=function(t,i,o,n){n.x=t,n.y=i,n.z=o},i.Zero=function(){return new i(0,0,0)},i.Up=function(){return new i(0,1,0)},i.TransformCoordinates=function(t,o){var n=i.Zero();return i.TransformCoordinatesToRef(t,o,n),n},i.TransformCoordinatesToRef=function(t,i,o){var n=t.x*i.m[0]+t.y*i.m[4]+t.z*i.m[8]+i.m[12],r=t.x*i.m[1]+t.y*i.m[5]+t.z*i.m[9]+i.m[13],s=t.x*i.m[2]+t.y*i.m[6]+t.z*i.m[10]+i.m[14],e=t.x*i.m[3]+t.y*i.m[7]+t.z*i.m[11]+i.m[15];o.x=n/e,o.y=r/e,o.z=s/e},i.TransformCoordinatesFromFloatsToRef=function(t,i,o,n,r){var s=t*n.m[0]+i*n.m[4]+o*n.m[8]+n.m[12],e=t*n.m[1]+i*n.m[5]+o*n.m[9]+n.m[13],a=t*n.m[2]+i*n.m[6]+o*n.m[10]+n.m[14],h=t*n.m[3]+i*n.m[7]+o*n.m[11]+n.m[15];r.x=s/h,r.y=e/h,r.z=a/h},i.TransformCoordinatesToRefSIMD=function(t,i,o){var n=SIMD.float32x4.loadXYZ(t._data,0),r=SIMD.float32x4.load(i.m,0),s=SIMD.float32x4.load(i.m,4),e=SIMD.float32x4.load(i.m,8),a=SIMD.float32x4.load(i.m,12),h=SIMD.float32x4.add(SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(n,0,0,0,0),r),SIMD.float32x4.mul(SIMD.float32x4.swizzle(n,1,1,1,1),s)),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(n,2,2,2,2),e),a));h=SIMD.float32x4.div(h,SIMD.float32x4.swizzle(h,3,3,3,3)),SIMD.float32x4.storeXYZ(o._data,0,h)},i.TransformCoordinatesFromFloatsToRefSIMD=function(t,i,o,n,r){var s=SIMD.float32x4.splat(t),e=SIMD.float32x4.splat(i),a=SIMD.float32x4.splat(o),h=SIMD.float32x4.load(n.m,0),u=SIMD.float32x4.load(n.m,4),l=SIMD.float32x4.load(n.m,8),m=SIMD.float32x4.load(n.m,12),f=SIMD.float32x4.add(SIMD.float32x4.add(SIMD.float32x4.mul(s,h),SIMD.float32x4.mul(e,u)),SIMD.float32x4.add(SIMD.float32x4.mul(a,l),m));f=SIMD.float32x4.div(f,SIMD.float32x4.swizzle(f,3,3,3,3)),SIMD.float32x4.storeXYZ(r._data,0,f)},i.TransformNormal=function(t,o){var n=i.Zero();return i.TransformNormalToRef(t,o,n),n},i.TransformNormalToRef=function(t,i,o){o.x=t.x*i.m[0]+t.y*i.m[4]+t.z*i.m[8],o.y=t.x*i.m[1]+t.y*i.m[5]+t.z*i.m[9],o.z=t.x*i.m[2]+t.y*i.m[6]+t.z*i.m[10]},i.TransformNormalFromFloatsToRef=function(t,i,o,n,r){r.x=t*n.m[0]+i*n.m[4]+o*n.m[8],r.y=t*n.m[1]+i*n.m[5]+o*n.m[9],r.z=t*n.m[2]+i*n.m[6]+o*n.m[10]},i.CatmullRom=function(t,o,n,r,s){var e=s*s,a=s*e,h=.5*(2*o.x+(-t.x+n.x)*s+(2*t.x-5*o.x+4*n.x-r.x)*e+(-t.x+3*o.x-3*n.x+r.x)*a),u=.5*(2*o.y+(-t.y+n.y)*s+(2*t.y-5*o.y+4*n.y-r.y)*e+(-t.y+3*o.y-3*n.y+r.y)*a),l=.5*(2*o.z+(-t.z+n.z)*s+(2*t.z-5*o.z+4*n.z-r.z)*e+(-t.z+3*o.z-3*n.z+r.z)*a);return new i(h,u,l)},i.Clamp=function(t,o,n){var r=t.x;r=r>n.x?n.x:r,r=r<o.x?o.x:r;var s=t.y;s=s>n.y?n.y:s,s=s<o.y?o.y:s;var e=t.z;return e=e>n.z?n.z:e,e=e<o.z?o.z:e,new i(r,s,e)},i.Hermite=function(t,o,n,r,s){var e=s*s,a=s*e,h=2*a-3*e+1,u=-2*a+3*e,l=a-2*e+s,m=a-e,f=t.x*h+n.x*u+o.x*l+r.x*m,x=t.y*h+n.y*u+o.y*l+r.y*m,y=t.z*h+n.z*u+o.z*l+r.z*m;return new i(f,x,y)},i.Lerp=function(t,o,n){var r=t.x+(o.x-t.x)*n,s=t.y+(o.y-t.y)*n,e=t.z+(o.z-t.z)*n;return new i(r,s,e)},i.Dot=function(t,i){return t.x*i.x+t.y*i.y+t.z*i.z},i.Cross=function(t,o){var n=i.Zero();return i.CrossToRef(t,o,n),n},i.CrossToRef=function(t,i,o){o.x=t.y*i.z-t.z*i.y,o.y=t.z*i.x-t.x*i.z,o.z=t.x*i.y-t.y*i.x},i.Normalize=function(t){var o=i.Zero();return i.NormalizeToRef(t,o),o},i.NormalizeToRef=function(t,i){i.copyFrom(t),i.normalize()},i.Project=function(t,o,n,r){var s=r.width,e=r.height,h=r.x,u=r.y,l=a.FromValues(s/2,0,0,0,0,-e/2,0,0,0,0,1,0,h+s/2,e/2+u,0,1),m=o.multiply(n).multiply(l);return i.TransformCoordinates(t,m)},i.UnprojectFromTransform=function(o,n,r,s,e){var a=s.multiply(e);a.invert(),o.x=o.x/n*2-1,o.y=-(o.y/r*2-1);var h=i.TransformCoordinates(o,a),u=o.x*a.m[3]+o.y*a.m[7]+o.z*a.m[11]+a.m[15];return t.Tools.WithinEpsilon(u,1)&&(h=h.scale(1/u)),h},i.Unproject=function(o,n,r,s,e,a){var h=s.multiply(e).multiply(a);h.invert();var u=new i(o.x/n*2-1,-(o.y/r*2-1),o.z),l=i.TransformCoordinates(u,h),m=u.x*h.m[3]+u.y*h.m[7]+u.z*h.m[11]+h.m[15];return t.Tools.WithinEpsilon(m,1)&&(l=l.scale(1/m)),l},i.Minimize=function(t,i){var o=t.clone();return o.MinimizeInPlace(i),o},i.Maximize=function(t,i){var o=t.clone();return o.MaximizeInPlace(i),o},i.Distance=function(t,o){return Math.sqrt(i.DistanceSquared(t,o))},i.DistanceSquared=function(t,i){var o=t.x-i.x,n=t.y-i.y,r=t.z-i.z;return o*o+n*n+r*r},i.Center=function(t,i){var o=t.add(i);return o.scaleInPlace(.5),o},i.RotationFromAxis=function(t,o,n){var r=i.Zero();return i.RotationFromAxisToRef(t,o,n,r),r},i.RotationFromAxisToRef=function(o,n,r,s){var e,a,h,u=i.Normalize(o),l=i.Normalize(r),m=f.X,x=f.Y,y=0,c=0,p=0,z=0,M=0,w=0,d=0,I=-1,D=0,S=0;t.Tools.WithinEpsilon(l.z,0,t.Engine.Epsilon)?w=1:t.Tools.WithinEpsilon(l.x,0,t.Engine.Epsilon)?z=1:(d=l.z/l.x,z=-d*Math.sqrt(1/(1+d*d)),w=Math.sqrt(1/(1+d*d))),a=new i(z,M,w),a.normalize(),h=i.Cross(l,a),h.normalize(),e=i.Cross(u,a),e.normalize(),i.Dot(l,e)<0&&(I=1),S=i.Dot(u,a),S=Math.min(1,Math.max(-1,S)),p=Math.acos(S)*I,i.Dot(a,m)<0&&(p=Math.PI+p,a=a.scaleInPlace(-1),h=h.scaleInPlace(-1),D++);var v,g;z=0,M=0,w=0,I=-1,t.Tools.WithinEpsilon(l.z,0,t.Engine.Epsilon)?z=1:(d=a.z/a.x,z=-d*Math.sqrt(1/(1+d*d)),w=Math.sqrt(1/(1+d*d))),v=new i(z,M,w),v.normalize(),g=i.Cross(v,a),g.normalize(),e=i.Cross(l,v),e.normalize(),i.Dot(a,e)<0&&(I=1),S=i.Dot(l,v),S=Math.min(1,Math.max(-1,S)),c=Math.acos(S)*I,i.Dot(g,x)<0&&(c=Math.PI+c,g=g.scaleInPlace(-1),v=v.scaleInPlace(-1),D++),I=-1,e=i.Cross(m,a),e.normalize(),i.Dot(e,x)<0&&(I=1),S=i.Dot(a,m),S=Math.min(1,Math.max(-1,S)),y=-Math.acos(S)*I,0>S&&2>D&&(y=Math.PI+y),s.x=c,s.y=y,s.z=p},i}();t.Vector3=r;var s=function(){function i(t,i,o,n){this.x=t,this.y=i,this.z=o,this.w=n}return i.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"W:"+this.w+"}"},i.prototype.asArray=function(){var t=[];return this.toArray(t,0),t},i.prototype.toArray=function(t,i){return void 0===i&&(i=0),t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,t[i+3]=this.w,this},i.prototype.addInPlace=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},i.prototype.add=function(t){return new i(this.x+t.x,this.y+t.y,this.z+t.z,this.w+t.w)},i.prototype.addToRef=function(t,i){return i.x=this.x+t.x,i.y=this.y+t.y,i.z=this.z+t.z,i.w=this.w+t.w,this},i.prototype.subtractInPlace=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this},i.prototype.subtract=function(t){return new i(this.x-t.x,this.y-t.y,this.z-t.z,this.w-t.w)},i.prototype.subtractToRef=function(t,i){return i.x=this.x-t.x,i.y=this.y-t.y,i.z=this.z-t.z,i.w=this.w-t.w,this},i.prototype.subtractFromFloats=function(t,o,n,r){return new i(this.x-t,this.y-o,this.z-n,this.w-r)},i.prototype.subtractFromFloatsToRef=function(t,i,o,n,r){return r.x=this.x-t,r.y=this.y-i,r.z=this.z-o,r.w=this.w-n,this},i.prototype.negate=function(){return new i(-this.x,-this.y,-this.z,-this.w)},i.prototype.scaleInPlace=function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},i.prototype.scale=function(t){return new i(this.x*t,this.y*t,this.z*t,this.w*t)},i.prototype.scaleToRef=function(t,i){i.x=this.x*t,i.y=this.y*t,i.z=this.z*t,i.w=this.w*t},i.prototype.equals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},i.prototype.equalsWithEpsilon=function(i,o){return void 0===o&&(o=t.Engine.Epsilon),i&&t.Tools.WithinEpsilon(this.x,i.x,o)&&t.Tools.WithinEpsilon(this.y,i.y,o)&&t.Tools.WithinEpsilon(this.z,i.z,o)&&t.Tools.WithinEpsilon(this.w,i.w,o)},i.prototype.equalsToFloats=function(t,i,o,n){return this.x===t&&this.y===i&&this.z===o&&this.w===n},i.prototype.multiplyInPlace=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this},i.prototype.multiply=function(t){return new i(this.x*t.x,this.y*t.y,this.z*t.z,this.w*t.w)},i.prototype.multiplyToRef=function(t,i){return i.x=this.x*t.x,i.y=this.y*t.y,i.z=this.z*t.z,i.w=this.w*t.w,this},i.prototype.multiplyByFloats=function(t,o,n,r){return new i(this.x*t,this.y*o,this.z*n,this.w*r)},i.prototype.divide=function(t){return new i(this.x/t.x,this.y/t.y,this.z/t.z,this.w/t.w)},i.prototype.divideToRef=function(t,i){return i.x=this.x/t.x,i.y=this.y/t.y,i.z=this.z/t.z,i.w=this.w/t.w,this},i.prototype.MinimizeInPlace=function(t){return t.x<this.x&&(this.x=t.x),t.y<this.y&&(this.y=t.y),t.z<this.z&&(this.z=t.z),t.w<this.w&&(this.w=t.w),this},i.prototype.MaximizeInPlace=function(t){return t.x>this.x&&(this.x=t.x),t.y>this.y&&(this.y=t.y),t.z>this.z&&(this.z=t.z),t.w>this.w&&(this.w=t.w),this},i.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},i.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},i.prototype.normalize=function(){var t=this.length();if(0===t)return this;var i=1/t;return this.x*=i,this.y*=i,this.z*=i,this.w*=i,this},i.prototype.clone=function(){return new i(this.x,this.y,this.z,this.w)},i.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},i.prototype.copyFromFloats=function(t,i,o,n){return this.x=t,this.y=i,this.z=o,this.w=n,this},i.FromArray=function(t,o){return o||(o=0),new i(t[o],t[o+1],t[o+2],t[o+3])},i.FromArrayToRef=function(t,i,o){o.x=t[i],o.y=t[i+1],o.z=t[i+2],o.w=t[i+3]},i.FromFloatArrayToRef=function(t,i,o){o.x=t[i],o.y=t[i+1],o.z=t[i+2],o.w=t[i+3]},i.FromFloatsToRef=function(t,i,o,n,r){r.x=t,r.y=i,r.z=o,r.w=n},i.Zero=function(){return new i(0,0,0,0)},i.Normalize=function(t){var o=i.Zero();return i.NormalizeToRef(t,o),o},i.NormalizeToRef=function(t,i){i.copyFrom(t),i.normalize()},i.Minimize=function(t,i){var o=t.clone();return o.MinimizeInPlace(i),o},i.Maximize=function(t,i){var o=t.clone();return o.MaximizeInPlace(i),o},i.Distance=function(t,o){return Math.sqrt(i.DistanceSquared(t,o))},i.DistanceSquared=function(t,i){var o=t.x-i.x,n=t.y-i.y,r=t.z-i.z,s=t.w-i.w;return o*o+n*n+r*r+s*s},i.Center=function(t,i){var o=t.add(i);return o.scaleInPlace(.5),o},i}();t.Vector4=s;var e=function(){function t(t,i,o,n){void 0===t&&(t=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===n&&(n=1),this.x=t,this.y=i,this.z=o,this.w=n}return t.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},t.prototype.asArray=function(){return[this.x,this.y,this.z,this.w]},t.prototype.equals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},t.prototype.clone=function(){return new t(this.x,this.y,this.z,this.w)},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},t.prototype.copyFromFloats=function(t,i,o,n){return this.x=t,this.y=i,this.z=o,this.w=n,this},t.prototype.add=function(i){return new t(this.x+i.x,this.y+i.y,this.z+i.z,this.w+i.w)},t.prototype.subtract=function(i){return new t(this.x-i.x,this.y-i.y,this.z-i.z,this.w-i.w)},t.prototype.scale=function(i){return new t(this.x*i,this.y*i,this.z*i,this.w*i)},t.prototype.multiply=function(i){var o=new t(0,0,0,1);return this.multiplyToRef(i,o),o},t.prototype.multiplyToRef=function(t,i){var o=this.x*t.w+this.y*t.z-this.z*t.y+this.w*t.x,n=-this.x*t.z+this.y*t.w+this.z*t.x+this.w*t.y,r=this.x*t.y-this.y*t.x+this.z*t.w+this.w*t.z,s=-this.x*t.x-this.y*t.y-this.z*t.z+this.w*t.w;return i.copyFromFloats(o,n,r,s),this},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},t.prototype.normalize=function(){var t=1/this.length();return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},t.prototype.toEulerAngles=function(){var t=r.Zero();return this.toEulerAnglesToRef(t),t},t.prototype.toEulerAnglesToRef=function(t){var i=this.x,o=this.y,n=this.z,r=this.w,s=i*o,e=i*n,a=r*o,h=r*n,u=r*i,l=o*n,m=i*i,f=o*o,x=m+f;return 0!==x&&1!==x?(t.x=Math.atan2(e+a,u-l),t.y=Math.acos(1-2*x),t.z=Math.atan2(e-a,u+l)):0===x?(t.x=0,t.y=0,t.z=Math.atan2(s-h,.5-f-n*n)):(t.x=Math.atan2(s-h,.5-f-n*n),t.y=Math.PI,t.z=0),this},t.prototype.toRotationMatrix=function(t){var i=this.x*this.x,o=this.y*this.y,n=this.z*this.z,r=this.x*this.y,s=this.z*this.w,e=this.z*this.x,a=this.y*this.w,h=this.y*this.z,u=this.x*this.w;return t.m[0]=1-2*(o+n),t.m[1]=2*(r+s),t.m[2]=2*(e-a),t.m[3]=0,t.m[4]=2*(r-s),t.m[5]=1-2*(n+i),t.m[6]=2*(h+u),t.m[7]=0,t.m[8]=2*(e+a),t.m[9]=2*(h-u),t.m[10]=1-2*(o+i),t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t.m[15]=1,this},t.prototype.fromRotationMatrix=function(i){return t.FromRotationMatrixToRef(i,this),this},t.FromRotationMatrix=function(i){var o=new t;return t.FromRotationMatrixToRef(i,o),o},t.FromRotationMatrixToRef=function(t,i){var o,n=t.m,r=n[0],s=n[4],e=n[8],a=n[1],h=n[5],u=n[9],l=n[2],m=n[6],f=n[10],x=r+h+f;x>0?(o=.5/Math.sqrt(x+1),i.w=.25/o,i.x=(m-u)*o,i.y=(e-l)*o,i.z=(a-s)*o):r>h&&r>f?(o=2*Math.sqrt(1+r-h-f),i.w=(m-u)/o,i.x=.25*o,i.y=(s+a)/o,i.z=(e+l)/o):h>f?(o=2*Math.sqrt(1+h-r-f),i.w=(e-l)/o,i.x=(s+a)/o,i.y=.25*o,i.z=(u+m)/o):(o=2*Math.sqrt(1+f-r-h),i.w=(a-s)/o,i.x=(e+l)/o,i.y=(u+m)/o,i.z=.25*o)},t.Inverse=function(i){return new t(-i.x,-i.y,-i.z,i.w)},t.Identity=function(){return new t(0,0,0,1)},t.RotationAxis=function(i,o){var n=new t,r=Math.sin(o/2);return i.normalize(),n.w=Math.cos(o/2),n.x=i.x*r,n.y=i.y*r,n.z=i.z*r,n},t.FromArray=function(i,o){return o||(o=0),new t(i[o],i[o+1],i[o+2],i[o+3])},t.RotationYawPitchRoll=function(i,o,n){var r=new t;return t.RotationYawPitchRollToRef(i,o,n,r),r},t.RotationYawPitchRollToRef=function(t,i,o,n){var r=.5*o,s=.5*i,e=.5*t,a=Math.sin(r),h=Math.cos(r),u=Math.sin(s),l=Math.cos(s),m=Math.sin(e),f=Math.cos(e);n.x=f*u*h+m*l*a,n.y=m*l*h-f*u*a,n.z=f*l*a-m*u*h,n.w=f*l*h+m*u*a},t.RotationAlphaBetaGamma=function(i,o,n){var r=new t;return t.RotationAlphaBetaGammaToRef(i,o,n,r),r},t.RotationAlphaBetaGammaToRef=function(t,i,o,n){var r=.5*(o+t),s=.5*(o-t),e=.5*i;n.x=Math.cos(s)*Math.sin(e),n.y=Math.sin(s)*Math.sin(e),n.z=Math.sin(r)*Math.cos(e),n.w=Math.cos(r)*Math.cos(e)},t.Slerp=function(i,o,n){var r,s,e=n,a=i.x*o.x+i.y*o.y+i.z*o.z+i.w*o.w,h=!1;if(0>a&&(h=!0,a=-a),a>.999999)s=1-e,r=h?-e:e;else{var u=Math.acos(a),l=1/Math.sin(u);s=Math.sin((1-e)*u)*l,r=h?-Math.sin(e*u)*l:Math.sin(e*u)*l}return new t(s*i.x+r*o.x,s*i.y+r*o.y,s*i.z+r*o.z,s*i.w+r*o.w)},t}();t.Quaternion=e;var a=function(){function i(){this.m=new Float32Array(16)}return i.prototype.isIdentity=function(){return 1!==this.m[0]||1!==this.m[5]||1!==this.m[10]||1!==this.m[15]?!1:0!==this.m[1]||0!==this.m[2]||0!==this.m[3]||0!==this.m[4]||0!==this.m[6]||0!==this.m[7]||0!==this.m[8]||0!==this.m[9]||0!==this.m[11]||0!==this.m[12]||0!==this.m[13]||0!==this.m[14]?!1:!0},i.prototype.determinant=function(){var t=this.m[10]*this.m[15]-this.m[11]*this.m[14],i=this.m[9]*this.m[15]-this.m[11]*this.m[13],o=this.m[9]*this.m[14]-this.m[10]*this.m[13],n=this.m[8]*this.m[15]-this.m[11]*this.m[12],r=this.m[8]*this.m[14]-this.m[10]*this.m[12],s=this.m[8]*this.m[13]-this.m[9]*this.m[12];return this.m[0]*(this.m[5]*t-this.m[6]*i+this.m[7]*o)-this.m[1]*(this.m[4]*t-this.m[6]*n+this.m[7]*r)+this.m[2]*(this.m[4]*i-this.m[5]*n+this.m[7]*s)-this.m[3]*(this.m[4]*o-this.m[5]*r+this.m[6]*s)},i.prototype.toArray=function(){return this.m},i.prototype.asArray=function(){return this.toArray()},i.prototype.invert=function(){return this.invertToRef(this),this},i.prototype.reset=function(){for(var t=0;16>t;t++)this.m[t]=0;return this},i.prototype.add=function(t){var o=new i;return this.addToRef(t,o),o},i.prototype.addToRef=function(t,i){for(var o=0;16>o;o++)i.m[o]=this.m[o]+t.m[o];return this},i.prototype.addToSelf=function(t){for(var i=0;16>i;i++)this.m[i]+=t.m[i];return this},i.prototype.invertToRef=function(t){var i=this.m[0],o=this.m[1],n=this.m[2],r=this.m[3],s=this.m[4],e=this.m[5],a=this.m[6],h=this.m[7],u=this.m[8],l=this.m[9],m=this.m[10],f=this.m[11],x=this.m[12],y=this.m[13],c=this.m[14],p=this.m[15],z=m*p-f*c,M=l*p-f*y,w=l*c-m*y,d=u*p-f*x,I=u*c-m*x,D=u*y-l*x,S=e*z-a*M+h*w,v=-(s*z-a*d+h*I),g=s*M-e*d+h*D,T=-(s*w-e*I+a*D),R=1/(i*S+o*v+n*g+r*T),_=a*p-h*c,b=e*p-h*y,F=e*c-a*y,A=s*p-h*x,P=s*c-a*x,C=s*y-e*x,E=a*f-h*m,L=e*f-h*l,q=e*m-a*l,Z=s*f-h*u,H=s*m-a*u,W=s*l-e*u;return t.m[0]=S*R,t.m[4]=v*R,t.m[8]=g*R,t.m[12]=T*R,t.m[1]=-(o*z-n*M+r*w)*R,t.m[5]=(i*z-n*d+r*I)*R,t.m[9]=-(i*M-o*d+r*D)*R,t.m[13]=(i*w-o*I+n*D)*R,t.m[2]=(o*_-n*b+r*F)*R,t.m[6]=-(i*_-n*A+r*P)*R,t.m[10]=(i*b-o*A+r*C)*R,t.m[14]=-(i*F-o*P+n*C)*R,t.m[3]=-(o*E-n*L+r*q)*R,t.m[7]=(i*E-n*Z+r*H)*R,t.m[11]=-(i*L-o*Z+r*W)*R,t.m[15]=(i*q-o*H+n*W)*R,this},i.prototype.invertToRefSIMD=function(t){var i,o,n,r,s,e,a,h,u,l,m=this.m,f=t.m,x=SIMD.float32x4.load(m,0),y=SIMD.float32x4.load(m,4),c=SIMD.float32x4.load(m,8),p=SIMD.float32x4.load(m,12);return s=SIMD.float32x4.shuffle(x,y,0,1,4,5),o=SIMD.float32x4.shuffle(c,p,0,1,4,5),i=SIMD.float32x4.shuffle(s,o,0,2,4,6),o=SIMD.float32x4.shuffle(o,s,1,3,5,7),s=SIMD.float32x4.shuffle(x,y,2,3,6,7),r=SIMD.float32x4.shuffle(c,p,2,3,6,7),n=SIMD.float32x4.shuffle(s,r,0,2,4,6),r=SIMD.float32x4.shuffle(r,s,1,3,5,7),s=SIMD.float32x4.mul(n,r),s=SIMD.float32x4.swizzle(s,1,0,3,2),e=SIMD.float32x4.mul(o,s),a=SIMD.float32x4.mul(i,s),s=SIMD.float32x4.swizzle(s,2,3,0,1),e=SIMD.float32x4.sub(SIMD.float32x4.mul(o,s),e),a=SIMD.float32x4.sub(SIMD.float32x4.mul(i,s),a),a=SIMD.float32x4.swizzle(a,2,3,0,1),s=SIMD.float32x4.mul(o,n),s=SIMD.float32x4.swizzle(s,1,0,3,2),e=SIMD.float32x4.add(SIMD.float32x4.mul(r,s),e),u=SIMD.float32x4.mul(i,s),s=SIMD.float32x4.swizzle(s,2,3,0,1),e=SIMD.float32x4.sub(e,SIMD.float32x4.mul(r,s)),u=SIMD.float32x4.sub(SIMD.float32x4.mul(i,s),u),u=SIMD.float32x4.swizzle(u,2,3,0,1),s=SIMD.float32x4.mul(SIMD.float32x4.swizzle(o,2,3,0,1),r),s=SIMD.float32x4.swizzle(s,1,0,3,2),n=SIMD.float32x4.swizzle(n,2,3,0,1),e=SIMD.float32x4.add(SIMD.float32x4.mul(n,s),e),h=SIMD.float32x4.mul(i,s),s=SIMD.float32x4.swizzle(s,2,3,0,1),e=SIMD.float32x4.sub(e,SIMD.float32x4.mul(n,s)),h=SIMD.float32x4.sub(SIMD.float32x4.mul(i,s),h),h=SIMD.float32x4.swizzle(h,2,3,0,1),s=SIMD.float32x4.mul(i,o),s=SIMD.float32x4.swizzle(s,1,0,3,2),h=SIMD.float32x4.add(SIMD.float32x4.mul(r,s),h),u=SIMD.float32x4.sub(SIMD.float32x4.mul(n,s),u),s=SIMD.float32x4.swizzle(s,2,3,0,1),h=SIMD.float32x4.sub(SIMD.float32x4.mul(r,s),h),u=SIMD.float32x4.sub(u,SIMD.float32x4.mul(n,s)),s=SIMD.float32x4.mul(i,r),s=SIMD.float32x4.swizzle(s,1,0,3,2),a=SIMD.float32x4.sub(a,SIMD.float32x4.mul(n,s)),h=SIMD.float32x4.add(SIMD.float32x4.mul(o,s),h),s=SIMD.float32x4.swizzle(s,2,3,0,1),a=SIMD.float32x4.add(SIMD.float32x4.mul(n,s),a),h=SIMD.float32x4.sub(h,SIMD.float32x4.mul(o,s)),s=SIMD.float32x4.mul(i,n),s=SIMD.float32x4.swizzle(s,1,0,3,2),a=SIMD.float32x4.add(SIMD.float32x4.mul(r,s),a),u=SIMD.float32x4.sub(u,SIMD.float32x4.mul(o,s)),s=SIMD.float32x4.swizzle(s,2,3,0,1),a=SIMD.float32x4.sub(a,SIMD.float32x4.mul(r,s)),u=SIMD.float32x4.add(SIMD.float32x4.mul(o,s),u),l=SIMD.float32x4.mul(i,e),l=SIMD.float32x4.add(SIMD.float32x4.swizzle(l,2,3,0,1),l),l=SIMD.float32x4.add(SIMD.float32x4.swizzle(l,1,0,3,2),l),s=SIMD.float32x4.reciprocalApproximation(l),l=SIMD.float32x4.sub(SIMD.float32x4.add(s,s),SIMD.float32x4.mul(l,SIMD.float32x4.mul(s,s))),l=SIMD.float32x4.swizzle(l,0,0,0,0),e=SIMD.float32x4.mul(l,e),a=SIMD.float32x4.mul(l,a),h=SIMD.float32x4.mul(l,h),u=SIMD.float32x4.mul(l,u),SIMD.float32x4.store(f,0,e),SIMD.float32x4.store(f,4,a),SIMD.float32x4.store(f,8,h),SIMD.float32x4.store(f,12,u),this},i.prototype.setTranslation=function(t){return this.m[12]=t.x,this.m[13]=t.y,this.m[14]=t.z,this},i.prototype.multiply=function(t){var o=new i;return this.multiplyToRef(t,o),o},i.prototype.copyFrom=function(t){for(var i=0;16>i;i++)this.m[i]=t.m[i];return this},i.prototype.copyToArray=function(t,i){void 0===i&&(i=0);for(var o=0;16>o;o++)t[i+o]=this.m[o];return this},i.prototype.multiplyToRef=function(t,i){return this.multiplyToArray(t,i.m,0),this},i.prototype.multiplyToArray=function(t,i,o){var n=this.m[0],r=this.m[1],s=this.m[2],e=this.m[3],a=this.m[4],h=this.m[5],u=this.m[6],l=this.m[7],m=this.m[8],f=this.m[9],x=this.m[10],y=this.m[11],c=this.m[12],p=this.m[13],z=this.m[14],M=this.m[15],w=t.m[0],d=t.m[1],I=t.m[2],D=t.m[3],S=t.m[4],v=t.m[5],g=t.m[6],T=t.m[7],R=t.m[8],_=t.m[9],b=t.m[10],F=t.m[11],A=t.m[12],P=t.m[13],C=t.m[14],E=t.m[15];return i[o]=n*w+r*S+s*R+e*A,i[o+1]=n*d+r*v+s*_+e*P,i[o+2]=n*I+r*g+s*b+e*C,i[o+3]=n*D+r*T+s*F+e*E,i[o+4]=a*w+h*S+u*R+l*A,i[o+5]=a*d+h*v+u*_+l*P,i[o+6]=a*I+h*g+u*b+l*C,i[o+7]=a*D+h*T+u*F+l*E,i[o+8]=m*w+f*S+x*R+y*A,i[o+9]=m*d+f*v+x*_+y*P,i[o+10]=m*I+f*g+x*b+y*C,i[o+11]=m*D+f*T+x*F+y*E,i[o+12]=c*w+p*S+z*R+M*A,i[o+13]=c*d+p*v+z*_+M*P,i[o+14]=c*I+p*g+z*b+M*C,i[o+15]=c*D+p*T+z*F+M*E,this},i.prototype.multiplyToArraySIMD=function(t,i,o){void 0===o&&(o=0);var n=this.m,r=t.m,s=SIMD.float32x4.load(r,0),e=SIMD.float32x4.load(r,4),a=SIMD.float32x4.load(r,8),h=SIMD.float32x4.load(r,12),u=SIMD.float32x4.load(n,0);SIMD.float32x4.store(i,o+0,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(u,0,0,0,0),s),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(u,1,1,1,1),e),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(u,2,2,2,2),a),SIMD.float32x4.mul(SIMD.float32x4.swizzle(u,3,3,3,3),h)))));\n\nvar l=SIMD.float32x4.load(n,4);SIMD.float32x4.store(i,o+4,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(l,0,0,0,0),s),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(l,1,1,1,1),e),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(l,2,2,2,2),a),SIMD.float32x4.mul(SIMD.float32x4.swizzle(l,3,3,3,3),h)))));var m=SIMD.float32x4.load(n,8);SIMD.float32x4.store(i,o+8,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(m,0,0,0,0),s),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(m,1,1,1,1),e),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(m,2,2,2,2),a),SIMD.float32x4.mul(SIMD.float32x4.swizzle(m,3,3,3,3),h)))));var f=SIMD.float32x4.load(n,12);SIMD.float32x4.store(i,o+12,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(f,0,0,0,0),s),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(f,1,1,1,1),e),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(f,2,2,2,2),a),SIMD.float32x4.mul(SIMD.float32x4.swizzle(f,3,3,3,3),h)))))},i.prototype.equals=function(t){return t&&this.m[0]===t.m[0]&&this.m[1]===t.m[1]&&this.m[2]===t.m[2]&&this.m[3]===t.m[3]&&this.m[4]===t.m[4]&&this.m[5]===t.m[5]&&this.m[6]===t.m[6]&&this.m[7]===t.m[7]&&this.m[8]===t.m[8]&&this.m[9]===t.m[9]&&this.m[10]===t.m[10]&&this.m[11]===t.m[11]&&this.m[12]===t.m[12]&&this.m[13]===t.m[13]&&this.m[14]===t.m[14]&&this.m[15]===t.m[15]},i.prototype.clone=function(){return i.FromValues(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5],this.m[6],this.m[7],this.m[8],this.m[9],this.m[10],this.m[11],this.m[12],this.m[13],this.m[14],this.m[15])},i.prototype.decompose=function(o,n,r){r.x=this.m[12],r.y=this.m[13],r.z=this.m[14];var s=t.Tools.Sign(this.m[0]*this.m[1]*this.m[2]*this.m[3])<0?-1:1,a=t.Tools.Sign(this.m[4]*this.m[5]*this.m[6]*this.m[7])<0?-1:1,h=t.Tools.Sign(this.m[8]*this.m[9]*this.m[10]*this.m[11])<0?-1:1;if(o.x=s*Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]+this.m[2]*this.m[2]),o.y=a*Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]+this.m[6]*this.m[6]),o.z=h*Math.sqrt(this.m[8]*this.m[8]+this.m[9]*this.m[9]+this.m[10]*this.m[10]),0===o.x||0===o.y||0===o.z)return n.x=0,n.y=0,n.z=0,n.w=1,!1;var u=i.FromValues(this.m[0]/o.x,this.m[1]/o.x,this.m[2]/o.x,0,this.m[4]/o.y,this.m[5]/o.y,this.m[6]/o.y,0,this.m[8]/o.z,this.m[9]/o.z,this.m[10]/o.z,0,0,0,0,1);return e.FromRotationMatrixToRef(u,n),!0},i.FromArray=function(t,o){var n=new i;return o||(o=0),i.FromArrayToRef(t,o,n),n},i.FromArrayToRef=function(t,i,o){for(var n=0;16>n;n++)o.m[n]=t[n+i]},i.FromFloat32ArrayToRefScaled=function(t,i,o,n){for(var r=0;16>r;r++)n.m[r]=t[r+i]*o},i.FromValuesToRef=function(t,i,o,n,r,s,e,a,h,u,l,m,f,x,y,c,p){p.m[0]=t,p.m[1]=i,p.m[2]=o,p.m[3]=n,p.m[4]=r,p.m[5]=s,p.m[6]=e,p.m[7]=a,p.m[8]=h,p.m[9]=u,p.m[10]=l,p.m[11]=m,p.m[12]=f,p.m[13]=x,p.m[14]=y,p.m[15]=c},i.FromValues=function(t,o,n,r,s,e,a,h,u,l,m,f,x,y,c,p){var z=new i;return z.m[0]=t,z.m[1]=o,z.m[2]=n,z.m[3]=r,z.m[4]=s,z.m[5]=e,z.m[6]=a,z.m[7]=h,z.m[8]=u,z.m[9]=l,z.m[10]=m,z.m[11]=f,z.m[12]=x,z.m[13]=y,z.m[14]=c,z.m[15]=p,z},i.Compose=function(t,o,n){var r=i.FromValues(t.x,0,0,0,0,t.y,0,0,0,0,t.z,0,0,0,0,1),s=i.Identity();return o.toRotationMatrix(s),r=r.multiply(s),r.setTranslation(n),r},i.Identity=function(){return i.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},i.IdentityToRef=function(t){i.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,t)},i.Zero=function(){return i.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},i.RotationX=function(t){var o=new i;return i.RotationXToRef(t,o),o},i.Invert=function(t){var o=new i;return t.invertToRef(o),o},i.RotationXToRef=function(t,i){var o=Math.sin(t),n=Math.cos(t);i.m[0]=1,i.m[15]=1,i.m[5]=n,i.m[10]=n,i.m[9]=-o,i.m[6]=o,i.m[1]=0,i.m[2]=0,i.m[3]=0,i.m[4]=0,i.m[7]=0,i.m[8]=0,i.m[11]=0,i.m[12]=0,i.m[13]=0,i.m[14]=0},i.RotationY=function(t){var o=new i;return i.RotationYToRef(t,o),o},i.RotationYToRef=function(t,i){var o=Math.sin(t),n=Math.cos(t);i.m[5]=1,i.m[15]=1,i.m[0]=n,i.m[2]=-o,i.m[8]=o,i.m[10]=n,i.m[1]=0,i.m[3]=0,i.m[4]=0,i.m[6]=0,i.m[7]=0,i.m[9]=0,i.m[11]=0,i.m[12]=0,i.m[13]=0,i.m[14]=0},i.RotationZ=function(t){var o=new i;return i.RotationZToRef(t,o),o},i.RotationZToRef=function(t,i){var o=Math.sin(t),n=Math.cos(t);i.m[10]=1,i.m[15]=1,i.m[0]=n,i.m[1]=o,i.m[4]=-o,i.m[5]=n,i.m[2]=0,i.m[3]=0,i.m[6]=0,i.m[7]=0,i.m[8]=0,i.m[9]=0,i.m[11]=0,i.m[12]=0,i.m[13]=0,i.m[14]=0},i.RotationAxis=function(t,o){var n=i.Zero();return i.RotationAxisToRef(t,o,n),n},i.RotationAxisToRef=function(t,i,o){var n=Math.sin(-i),r=Math.cos(-i),s=1-r;t.normalize(),o.m[0]=t.x*t.x*s+r,o.m[1]=t.x*t.y*s-t.z*n,o.m[2]=t.x*t.z*s+t.y*n,o.m[3]=0,o.m[4]=t.y*t.x*s+t.z*n,o.m[5]=t.y*t.y*s+r,o.m[6]=t.y*t.z*s-t.x*n,o.m[7]=0,o.m[8]=t.z*t.x*s-t.y*n,o.m[9]=t.z*t.y*s+t.x*n,o.m[10]=t.z*t.z*s+r,o.m[11]=0,o.m[15]=1},i.RotationYawPitchRoll=function(t,o,n){var r=new i;return i.RotationYawPitchRollToRef(t,o,n,r),r},i.RotationYawPitchRollToRef=function(t,i,o,n){e.RotationYawPitchRollToRef(t,i,o,this._tempQuaternion),this._tempQuaternion.toRotationMatrix(n)},i.Scaling=function(t,o,n){var r=i.Zero();return i.ScalingToRef(t,o,n,r),r},i.ScalingToRef=function(t,i,o,n){n.m[0]=t,n.m[1]=0,n.m[2]=0,n.m[3]=0,n.m[4]=0,n.m[5]=i,n.m[6]=0,n.m[7]=0,n.m[8]=0,n.m[9]=0,n.m[10]=o,n.m[11]=0,n.m[12]=0,n.m[13]=0,n.m[14]=0,n.m[15]=1},i.Translation=function(t,o,n){var r=i.Identity();return i.TranslationToRef(t,o,n,r),r},i.TranslationToRef=function(t,o,n,r){i.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t,o,n,1,r)},i.LookAtLH=function(t,o,n){var r=i.Zero();return i.LookAtLHToRef(t,o,n,r),r},i.LookAtLHToRef=function(t,o,n,s){o.subtractToRef(t,this._zAxis),this._zAxis.normalize(),r.CrossToRef(n,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),r.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var e=-r.Dot(this._xAxis,t),a=-r.Dot(this._yAxis,t),h=-r.Dot(this._zAxis,t);return i.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,e,a,h,1,s)},i.LookAtLHToRefSIMD=function(t,i,o,n){var r=n.m,s=SIMD.float32x4(i.x,i.y,i.z,0),e=SIMD.float32x4(t.x,t.y,t.z,0),a=SIMD.float32x4(o.x,o.y,o.z,0),h=SIMD.float32x4.sub(s,e),u=SIMD.float32x4.mul(h,h);u=SIMD.float32x4.add(u,SIMD.float32x4.add(SIMD.float32x4.swizzle(u,1,2,0,3),SIMD.float32x4.swizzle(u,2,0,1,3))),h=SIMD.float32x4.mul(h,SIMD.float32x4.reciprocalSqrtApproximation(u)),u=SIMD.float32x4.mul(a,a),u=SIMD.float32x4.add(u,SIMD.float32x4.add(SIMD.float32x4.swizzle(u,1,2,0,3),SIMD.float32x4.swizzle(u,2,0,1,3))),a=SIMD.float32x4.mul(a,SIMD.float32x4.reciprocalSqrtApproximation(u));var l=SIMD.float32x4.sub(SIMD.float32x4.mul(SIMD.float32x4.swizzle(h,1,2,0,3),SIMD.float32x4.swizzle(a,2,0,1,3)),SIMD.float32x4.mul(SIMD.float32x4.swizzle(h,2,0,1,3),SIMD.float32x4.swizzle(a,1,2,0,3)));u=SIMD.float32x4.mul(l,l),u=SIMD.float32x4.add(u,SIMD.float32x4.add(SIMD.float32x4.swizzle(u,1,2,0,3),SIMD.float32x4.swizzle(u,2,0,1,3))),l=SIMD.float32x4.mul(l,SIMD.float32x4.reciprocalSqrtApproximation(u));var m=SIMD.float32x4.sub(SIMD.float32x4.mul(SIMD.float32x4.swizzle(l,1,2,0,3),SIMD.float32x4.swizzle(h,2,0,1,3)),SIMD.float32x4.mul(SIMD.float32x4.swizzle(l,2,0,1,3),SIMD.float32x4.swizzle(h,1,2,0,3)));u=SIMD.float32x4.mul(l,l),u=SIMD.float32x4.add(u,SIMD.float32x4.add(SIMD.float32x4.swizzle(u,1,2,0,3),SIMD.float32x4.swizzle(u,2,0,1,3))),l=SIMD.float32x4.mul(l,SIMD.float32x4.reciprocalSqrtApproximation(u));var f=SIMD.float32x4.splat(0);l=SIMD.float32x4.neg(l);var x=SIMD.float32x4.shuffle(l,m,0,1,4,5),y=SIMD.float32x4.shuffle(h,f,0,1,4,5),c=SIMD.float32x4.shuffle(x,y,0,2,4,6),p=SIMD.float32x4.shuffle(x,y,1,3,5,7);x=SIMD.float32x4.shuffle(l,m,2,3,6,7),y=SIMD.float32x4.shuffle(h,f,2,3,6,7);var z=SIMD.float32x4.shuffle(x,y,0,2,4,6),M=SIMD.float32x4(0,0,0,1),w=SIMD.float32x4(1,0,0,0),d=SIMD.float32x4(0,1,0,0),I=SIMD.float32x4(0,0,1,0),D=SIMD.float32x4.neg(e);D=SIMD.float32x4.withW(D,1),SIMD.float32x4.store(r,0,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(w,0,0,0,0),c),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(w,1,1,1,1),p),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(w,2,2,2,2),z),SIMD.float32x4.mul(SIMD.float32x4.swizzle(w,3,3,3,3),M))))),SIMD.float32x4.store(r,4,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(d,0,0,0,0),c),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(d,1,1,1,1),p),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(d,2,2,2,2),z),SIMD.float32x4.mul(SIMD.float32x4.swizzle(d,3,3,3,3),M))))),SIMD.float32x4.store(r,8,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(I,0,0,0,0),c),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(I,1,1,1,1),p),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(I,2,2,2,2),z),SIMD.float32x4.mul(SIMD.float32x4.swizzle(I,3,3,3,3),M))))),SIMD.float32x4.store(r,12,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(D,0,0,0,0),c),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(D,1,1,1,1),p),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(D,2,2,2,2),z),SIMD.float32x4.mul(SIMD.float32x4.swizzle(D,3,3,3,3),M)))))},i.OrthoLH=function(t,o,n,r){var s=i.Zero();return i.OrthoLHToRef(t,o,n,r,s),s},i.OrthoLHToRef=function(t,o,n,r,s){var e=2/t,a=2/o,h=1/(r-n),u=n/(n-r);i.FromValuesToRef(e,0,0,0,0,a,0,0,0,0,h,0,0,0,u,1,s)},i.OrthoOffCenterLH=function(t,o,n,r,s,e){var a=i.Zero();return i.OrthoOffCenterLHToRef(t,o,n,r,s,e,a),a},i.OrthoOffCenterLHToRef=function(t,i,o,n,r,s,e){e.m[0]=2/(i-t),e.m[1]=e.m[2]=e.m[3]=0,e.m[5]=2/(n-o),e.m[4]=e.m[6]=e.m[7]=0,e.m[10]=-1/(r-s),e.m[8]=e.m[9]=e.m[11]=0,e.m[12]=(t+i)/(t-i),e.m[13]=(n+o)/(o-n),e.m[14]=r/(r-s),e.m[15]=1},i.PerspectiveLH=function(t,o,n,r){var s=i.Zero();return s.m[0]=2*n/t,s.m[1]=s.m[2]=s.m[3]=0,s.m[5]=2*n/o,s.m[4]=s.m[6]=s.m[7]=0,s.m[10]=-r/(n-r),s.m[8]=s.m[9]=0,s.m[11]=1,s.m[12]=s.m[13]=s.m[15]=0,s.m[14]=n*r/(n-r),s},i.PerspectiveFovLH=function(t,o,n,r){var s=i.Zero();return i.PerspectiveFovLHToRef(t,o,n,r,s),s},i.PerspectiveFovLHToRef=function(i,o,n,r,s,e){void 0===e&&(e=t.Camera.FOVMODE_VERTICAL_FIXED);var a=1/Math.tan(.5*i),h=e===t.Camera.FOVMODE_VERTICAL_FIXED;s.m[0]=h?a/o:a,s.m[1]=s.m[2]=s.m[3]=0,s.m[5]=h?a:a*o,s.m[4]=s.m[6]=s.m[7]=0,s.m[8]=s.m[9]=0,s.m[10]=-r/(n-r),s.m[11]=1,s.m[12]=s.m[13]=s.m[15]=0,s.m[14]=n*r/(n-r)},i.GetFinalMatrix=function(t,o,n,r,s,e){var a=t.width,h=t.height,u=t.x,l=t.y,m=i.FromValues(a/2,0,0,0,0,-h/2,0,0,0,0,e-s,0,u+a/2,h/2+l,s,1);return o.multiply(n).multiply(r).multiply(m)},i.GetAsMatrix2x2=function(t){return new Float32Array([t.m[0],t.m[1],t.m[4],t.m[5]])},i.GetAsMatrix3x3=function(t){return new Float32Array([t.m[0],t.m[1],t.m[2],t.m[4],t.m[5],t.m[6],t.m[8],t.m[9],t.m[10]])},i.Transpose=function(t){var o=new i;return o.m[0]=t.m[0],o.m[1]=t.m[4],o.m[2]=t.m[8],o.m[3]=t.m[12],o.m[4]=t.m[1],o.m[5]=t.m[5],o.m[6]=t.m[9],o.m[7]=t.m[13],o.m[8]=t.m[2],o.m[9]=t.m[6],o.m[10]=t.m[10],o.m[11]=t.m[14],o.m[12]=t.m[3],o.m[13]=t.m[7],o.m[14]=t.m[11],o.m[15]=t.m[15],o},i.Reflection=function(t){var o=new i;return i.ReflectionToRef(t,o),o},i.ReflectionToRef=function(t,i){t.normalize();var o=t.normal.x,n=t.normal.y,r=t.normal.z,s=-2*o,e=-2*n,a=-2*r;i.m[0]=s*o+1,i.m[1]=e*o,i.m[2]=a*o,i.m[3]=0,i.m[4]=s*n,i.m[5]=e*n+1,i.m[6]=a*n,i.m[7]=0,i.m[8]=s*r,i.m[9]=e*r,i.m[10]=a*r+1,i.m[11]=0,i.m[12]=s*t.d,i.m[13]=e*t.d,i.m[14]=a*t.d,i.m[15]=1},i._tempQuaternion=new e,i._xAxis=r.Zero(),i._yAxis=r.Zero(),i._zAxis=r.Zero(),i}();t.Matrix=a;var h=function(){function t(t,i,o,n){this.normal=new r(t,i,o),this.d=n}return t.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},t.prototype.clone=function(){return new t(this.normal.x,this.normal.y,this.normal.z,this.d)},t.prototype.normalize=function(){var t=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z),i=0;return 0!==t&&(i=1/t),this.normal.x*=i,this.normal.y*=i,this.normal.z*=i,this.d*=i,this},t.prototype.transform=function(i){var o=a.Transpose(i),n=this.normal.x,r=this.normal.y,s=this.normal.z,e=this.d,h=n*o.m[0]+r*o.m[1]+s*o.m[2]+e*o.m[3],u=n*o.m[4]+r*o.m[5]+s*o.m[6]+e*o.m[7],l=n*o.m[8]+r*o.m[9]+s*o.m[10]+e*o.m[11],m=n*o.m[12]+r*o.m[13]+s*o.m[14]+e*o.m[15];return new t(h,u,l,m)},t.prototype.dotCoordinate=function(t){return this.normal.x*t.x+this.normal.y*t.y+this.normal.z*t.z+this.d},t.prototype.copyFromPoints=function(t,i,o){var n,r=i.x-t.x,s=i.y-t.y,e=i.z-t.z,a=o.x-t.x,h=o.y-t.y,u=o.z-t.z,l=s*u-e*h,m=e*a-r*u,f=r*h-s*a,x=Math.sqrt(l*l+m*m+f*f);return n=0!==x?1/x:0,this.normal.x=l*n,this.normal.y=m*n,this.normal.z=f*n,this.d=-(this.normal.x*t.x+this.normal.y*t.y+this.normal.z*t.z),this},t.prototype.isFrontFacingTo=function(t,i){var o=r.Dot(this.normal,t);return i>=o},t.prototype.signedDistanceTo=function(t){return r.Dot(t,this.normal)+this.d},t.FromArray=function(i){return new t(i[0],i[1],i[2],i[3])},t.FromPoints=function(i,o,n){var r=new t(0,0,0,0);return r.copyFromPoints(i,o,n),r},t.FromPositionAndNormal=function(i,o){var n=new t(0,0,0,0);return o.normalize(),n.normal=o,n.d=-(o.x*i.x+o.y*i.y+o.z*i.z),n},t.SignedDistanceToPlaneFromPositionAndNormal=function(t,i,o){var n=-(i.x*t.x+i.y*t.y+i.z*t.z);return r.Dot(o,i)+n},t}();t.Plane=h;var u=function(){function t(t,i,o,n){this.x=t,this.y=i,this.width=o,this.height=n}return t.prototype.toGlobal=function(i){var o=i.getRenderWidth(),n=i.getRenderHeight();return new t(this.x*o,this.y*n,this.width*o,this.height*n)},t}();t.Viewport=u;var l=function(){function t(){}return t.GetPlanes=function(i){for(var o=[],n=0;6>n;n++)o.push(new h(0,0,0,0));return t.GetPlanesToRef(i,o),o},t.GetPlanesToRef=function(t,i){i[0].normal.x=t.m[3]+t.m[2],i[0].normal.y=t.m[7]+t.m[6],i[0].normal.z=t.m[11]+t.m[10],i[0].d=t.m[15]+t.m[14],i[0].normalize(),i[1].normal.x=t.m[3]-t.m[2],i[1].normal.y=t.m[7]-t.m[6],i[1].normal.z=t.m[11]-t.m[10],i[1].d=t.m[15]-t.m[14],i[1].normalize(),i[2].normal.x=t.m[3]+t.m[0],i[2].normal.y=t.m[7]+t.m[4],i[2].normal.z=t.m[11]+t.m[8],i[2].d=t.m[15]+t.m[12],i[2].normalize(),i[3].normal.x=t.m[3]-t.m[0],i[3].normal.y=t.m[7]-t.m[4],i[3].normal.z=t.m[11]-t.m[8],i[3].d=t.m[15]-t.m[12],i[3].normalize(),i[4].normal.x=t.m[3]-t.m[1],i[4].normal.y=t.m[7]-t.m[5],i[4].normal.z=t.m[11]-t.m[9],i[4].d=t.m[15]-t.m[13],i[4].normalize(),i[5].normal.x=t.m[3]+t.m[1],i[5].normal.y=t.m[7]+t.m[5],i[5].normal.z=t.m[11]+t.m[9],i[5].d=t.m[15]+t.m[13],i[5].normalize()},t}();t.Frustum=l;var m=function(){function i(t,i,o){void 0===o&&(o=Number.MAX_VALUE),this.origin=t,this.direction=i,this.length=o}return i.prototype.intersectsBoxMinMax=function(t,i){var o,n,r,s,e=0,a=Number.MAX_VALUE;if(Math.abs(this.direction.x)<1e-7){if(this.origin.x<t.x||this.origin.x>i.x)return!1}else if(o=1/this.direction.x,n=(t.x-this.origin.x)*o,r=(i.x-this.origin.x)*o,r===-(1/0)&&(r=1/0),n>r&&(s=n,n=r,r=s),e=Math.max(n,e),a=Math.min(r,a),e>a)return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.y<t.y||this.origin.y>i.y)return!1}else if(o=1/this.direction.y,n=(t.y-this.origin.y)*o,r=(i.y-this.origin.y)*o,r===-(1/0)&&(r=1/0),n>r&&(s=n,n=r,r=s),e=Math.max(n,e),a=Math.min(r,a),e>a)return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.z<t.z||this.origin.z>i.z)return!1}else if(o=1/this.direction.z,n=(t.z-this.origin.z)*o,r=(i.z-this.origin.z)*o,r===-(1/0)&&(r=1/0),n>r&&(s=n,n=r,r=s),e=Math.max(n,e),a=Math.min(r,a),e>a)return!1;return!0},i.prototype.intersectsBox=function(t){return this.intersectsBoxMinMax(t.minimum,t.maximum)},i.prototype.intersectsSphere=function(t){var i=t.center.x-this.origin.x,o=t.center.y-this.origin.y,n=t.center.z-this.origin.z,r=i*i+o*o+n*n,s=t.radius*t.radius;if(s>=r)return!0;var e=i*this.direction.x+o*this.direction.y+n*this.direction.z;if(0>e)return!1;var a=r-e*e;return s>=a},i.prototype.intersectsTriangle=function(i,o,n){this._edge1||(this._edge1=r.Zero(),this._edge2=r.Zero(),this._pvec=r.Zero(),this._tvec=r.Zero(),this._qvec=r.Zero()),o.subtractToRef(i,this._edge1),n.subtractToRef(i,this._edge2),r.CrossToRef(this.direction,this._edge2,this._pvec);var s=r.Dot(this._edge1,this._pvec);if(0===s)return null;var e=1/s;this.origin.subtractToRef(i,this._tvec);var a=r.Dot(this._tvec,this._pvec)*e;if(0>a||a>1)return null;r.CrossToRef(this._tvec,this._edge1,this._qvec);var h=r.Dot(this.direction,this._qvec)*e;if(0>h||a+h>1)return null;var u=r.Dot(this._edge2,this._qvec)*e;return u>this.length?null:new t.IntersectionInfo(a,h,u)},i.CreateNew=function(t,o,n,s,e,a,h){var u=r.Unproject(new r(t,o,0),n,s,e,a,h),l=r.Unproject(new r(t,o,1),n,s,e,a,h),m=l.subtract(u);return m.normalize(),new i(u,m)},i.CreateNewFromTo=function(t,o,n){void 0===n&&(n=a.Identity());var r=o.subtract(t),s=Math.sqrt(r.x*r.x+r.y*r.y+r.z*r.z);return r.normalize(),i.Transform(new i(t,r,s),n)},i.Transform=function(t,o){var n=r.TransformCoordinates(t.origin,o),s=r.TransformNormal(t.direction,o);return new i(n,s,t.length)},i}();t.Ray=m,function(t){t[t.LOCAL=0]="LOCAL",t[t.WORLD=1]="WORLD"}(t.Space||(t.Space={}));var f=(t.Space,function(){function t(){}return t.X=new r(1,0,0),t.Y=new r(0,1,0),t.Z=new r(0,0,1),t}());t.Axis=f;var x=function(){function t(){}return t.interpolate=function(t,i,o,n,r){for(var s=1-3*n+3*i,e=3*n-6*i,a=3*i,h=t,u=0;5>u;u++){var l=h*h,m=l*h,f=s*m+e*l+a*h,x=1/(3*s*l+2*e*h+a);h-=(f-t)*x,h=Math.min(1,Math.max(0,h))}return 3*Math.pow(1-h,2)*h*o+3*(1-h)*Math.pow(h,2)*r+Math.pow(h,3)},t}();t.BezierCurve=x,function(t){t[t.CW=0]="CW",t[t.CCW=1]="CCW"}(t.Orientation||(t.Orientation={}));var y=t.Orientation,c=function(){function t(t){var i=this;this.degrees=function(){return 180*i._radians/Math.PI},this.radians=function(){return i._radians},this._radians=t,this._radians<0&&(this._radians+=2*Math.PI)}return t.BetweenTwoPoints=function(i,o){var n=o.subtract(i),r=Math.atan2(n.y,n.x);return new t(r)},t.FromRadians=function(i){return new t(i)},t.FromDegrees=function(i){return new t(i*Math.PI/180)},t}();t.Angle=c;var p=function(){function t(t,i,o){this.startPoint=t,this.midPoint=i,this.endPoint=o;var r=Math.pow(i.x,2)+Math.pow(i.y,2),s=(Math.pow(t.x,2)+Math.pow(t.y,2)-r)/2,e=(r-Math.pow(o.x,2)-Math.pow(o.y,2))/2,a=(t.x-i.x)*(i.y-o.y)-(i.x-o.x)*(t.y-i.y);this.centerPoint=new n((s*(i.y-o.y)-e*(t.y-i.y))/a,((t.x-i.x)*e-(i.x-o.x)*s)/a),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=c.BetweenTwoPoints(this.centerPoint,this.startPoint);var h=this.startAngle.degrees(),u=c.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),l=c.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();u-h>180&&(u-=360),-180>u-h&&(u+=360),l-u>180&&(l-=360),-180>l-u&&(l+=360),this.orientation=0>u-h?y.CW:y.CCW,this.angle=c.FromDegrees(this.orientation===y.CW?h-l:l-h)}return t}();t.Arc2=p;var z=function(){function t(t){this.path=t,this._onchange=new Array,this.value=0,this.animations=new Array}return t.prototype.getPoint=function(){var t=this.path.getPointAtLengthPosition(this.value);return new r(t.x,0,t.y)},t.prototype.moveAhead=function(t){return void 0===t&&(t=.002),this.move(t),this},t.prototype.moveBack=function(t){return void 0===t&&(t=.002),this.move(-t),this},t.prototype.move=function(t){if(Math.abs(t)>1)throw"step size should be less than 1.";return this.value+=t,this.ensureLimits(),this.raiseOnChange(),this},t.prototype.ensureLimits=function(){for(;this.value>1;)this.value-=1;for(;this.value<0;)this.value+=1;return this},t.prototype.markAsDirty=function(t){return this.ensureLimits(),this.raiseOnChange(),this},t.prototype.raiseOnChange=function(){var t=this;return this._onchange.forEach(function(i){return i(t)}),this},t.prototype.onchange=function(t){return this._onchange.push(t),this},t}();t.PathCursor=z;var M=function(){function i(t,i){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new n(t,i))}return i.prototype.addLineTo=function(i,o){if(closed)return t.Tools.Error("cannot add lines to closed paths"),this;var r=new n(i,o),s=this._points[this._points.length-1];return this._points.push(r),this._length+=r.subtract(s).length(),this},i.prototype.addArcTo=function(i,o,r,s,e){if(void 0===e&&(e=36),closed)return t.Tools.Error("cannot add arcs to closed paths"),this;var a=this._points[this._points.length-1],h=new n(i,o),u=new n(r,s),l=new p(a,h,u),m=l.angle.radians()/e;l.orientation===y.CW&&(m*=-1);for(var f=l.startAngle.radians()+m,x=0;e>x;x++){var c=Math.cos(f)*l.radius+l.centerPoint.x,z=Math.sin(f)*l.radius+l.centerPoint.y;this.addLineTo(c,z),f+=m}return this},i.prototype.close=function(){return this.closed=!0,this},i.prototype.length=function(){var t=this._length;if(!this.closed){var i=this._points[this._points.length-1],o=this._points[0];t+=o.subtract(i).length()}return t},i.prototype.getPoints=function(){return this._points},i.prototype.getPointAtLengthPosition=function(i){if(0>i||i>1)return t.Tools.Error("normalized length position should be between 0 and 1."),n.Zero();for(var o=i*this.length(),r=0,s=0;s<this._points.length;s++){var e=(s+1)%this._points.length,a=this._points[s],h=this._points[e],u=h.subtract(a),l=u.length()+r;if(o>=r&&l>=o){var m=u.normalize(),f=o-r;return new n(a.x+m.x*f,a.y+m.y*f)}r=l}return t.Tools.Error("internal error"),n.Zero()},i.StartingAt=function(t,o){return new i(t,o)},i}();t.Path2=M;var w=function(){function i(t,i,o){this.path=t,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array;for(var n=0;n<t.length;n++)this._curve[n]=t[n].clone();this._raw=o||!1,this._compute(i)}return i.prototype.getCurve=function(){return this._curve},i.prototype.getTangents=function(){return this._tangents},i.prototype.getNormals=function(){return this._normals},i.prototype.getBinormals=function(){return this._binormals},i.prototype.getDistances=function(){return this._distances},i.prototype.update=function(t,i){for(var o=0;o<t.length;o++)this._curve[o].x=t[o].x,this._curve[o].y=t[o].y,this._curve[o].z=t[o].z;return this._compute(i),this},i.prototype._compute=function(t){var i=this._curve.length;this._tangents[0]=this._getFirstNonNullVector(0),this._raw||this._tangents[0].normalize(),this._tangents[i-1]=this._curve[i-1].subtract(this._curve[i-2]),this._raw||this._tangents[i-1].normalize();var o=this._tangents[0],n=this._normalVector(this._curve[0],o,t);this._normals[0]=n,this._raw||this._normals[0].normalize(),this._binormals[0]=r.Cross(o,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;for(var s,e,a,h,u=1;i>u;u++)s=this._getLastNonNullVector(u),i-1>u&&(e=this._getFirstNonNullVector(u),this._tangents[u]=s.add(e),this._tangents[u].normalize()),this._distances[u]=this._distances[u-1]+s.length(),a=this._tangents[u],h=this._binormals[u-1],this._normals[u]=r.Cross(h,a),this._raw||this._normals[u].normalize(),this._binormals[u]=r.Cross(a,this._normals[u]),this._raw||this._binormals[u].normalize()},i.prototype._getFirstNonNullVector=function(t){for(var i=1,o=this._curve[t+i].subtract(this._curve[t]);0===o.length()&&t+i+1<this._curve.length;)i++,o=this._curve[t+i].subtract(this._curve[t]);return o},i.prototype._getLastNonNullVector=function(t){for(var i=1,o=this._curve[t].subtract(this._curve[t-i]);0===o.length()&&t>i+1;)i++,o=this._curve[t].subtract(this._curve[t-i]);return o},i.prototype._normalVector=function(i,o,n){var s;if(void 0===n||null===n){var e;t.Tools.WithinEpsilon(o.y,1,t.Engine.Epsilon)?t.Tools.WithinEpsilon(o.x,1,t.Engine.Epsilon)?t.Tools.WithinEpsilon(o.z,1,t.Engine.Epsilon)||(e=new r(0,0,1)):e=new r(1,0,0):e=new r(0,-1,0),s=r.Cross(o,e)}else s=r.Cross(o,n),r.CrossToRef(s,o,s);return s.normalize(),s},i}();t.Path3D=w;var d=function(){function t(t){this._length=0,this._points=t,this._length=this._computeLength(t)}return t.CreateQuadraticBezier=function(i,o,n,s){s=s>2?s:3;for(var e=new Array,a=function(t,i,o,n){var r=(1-t)*(1-t)*i+2*t*(1-t)*o+t*t*n;return r},h=0;s>=h;h++)e.push(new r(a(h/s,i.x,o.x,n.x),a(h/s,i.y,o.y,n.y),a(h/s,i.z,o.z,n.z)));return new t(e)},t.CreateCubicBezier=function(i,o,n,s,e){e=e>3?e:4;for(var a=new Array,h=function(t,i,o,n,r){var s=(1-t)*(1-t)*(1-t)*i+3*t*(1-t)*(1-t)*o+3*t*t*(1-t)*n+t*t*t*r;return s},u=0;e>=u;u++)a.push(new r(h(u/e,i.x,o.x,n.x,s.x),h(u/e,i.y,o.y,n.y,s.y),h(u/e,i.z,o.z,n.z,s.z)));return new t(a)},t.CreateHermiteSpline=function(i,o,n,s,e){for(var a=new Array,h=1/e,u=0;e>=u;u++)a.push(r.Hermite(i,o,n,s,u*h));return new t(a)},t.prototype.getPoints=function(){return this._points},t.prototype.length=function(){return this._length},t.prototype["continue"]=function(i){for(var o=this._points[this._points.length-1],n=this._points.slice(),r=i.getPoints(),s=1;s<r.length;s++)n.push(r[s].subtract(r[0]).add(o));var e=new t(n);return e},t.prototype._computeLength=function(t){for(var i=0,o=1;o<t.length;o++)i+=t[o].subtract(t[o-1]).length();return i},t}();t.Curve3=d;var I=function(){function t(t,i){void 0===t&&(t=r.Zero()),void 0===i&&(i=r.Up()),this.position=t,this.normal=i}return t.prototype.clone=function(){return new t(this.position.clone(),this.normal.clone())},t}();t.PositionNormalVertex=I;var D=function(){function t(t,i,o){void 0===t&&(t=r.Zero()),void 0===i&&(i=r.Up()),void 0===o&&(o=n.Zero()),this.position=t,this.normal=i,this.uv=o}return t.prototype.clone=function(){return new t(this.position.clone(),this.normal.clone(),this.uv.clone())},t}();t.PositionNormalTextureVertex=D;var S=a.prototype.multiplyToArray,v=a.prototype.invertToRef,g=a.LookAtLHToRef,T=r.TransformCoordinatesToRef,R=r.TransformCoordinatesFromFloatsToRef,_=function(){function t(){}return Object.defineProperty(t,"IsEnabled",{get:function(){return t._isEnabled},enumerable:!0,configurable:!0}),t.DisableSIMD=function(){a.prototype.multiplyToArray=S,a.prototype.invertToRef=v,a.LookAtLHToRef=g,r.TransformCoordinatesToRef=T,r.TransformCoordinatesFromFloatsToRef=R,t._isEnabled=!1},t.EnableSIMD=function(){void 0!==window.SIMD&&(a.prototype.multiplyToArray=a.prototype.multiplyToArraySIMD,a.prototype.invertToRef=a.prototype.invertToRefSIMD,a.LookAtLHToRef=a.LookAtLHToRefSIMD,r.TransformCoordinatesToRef=r.TransformCoordinatesToRefSIMD,r.TransformCoordinatesFromFloatsToRef=r.TransformCoordinatesFromFloatsToRefSIMD,Object.defineProperty(r.prototype,"x",{get:function(){return this._data[0]},set:function(t){this._data||(this._data=new Float32Array(3)),this._data[0]=t}}),Object.defineProperty(r.prototype,"y",{get:function(){return this._data[1]},set:function(t){this._data[1]=t}}),Object.defineProperty(r.prototype,"z",{get:function(){return this._data[2]},set:function(t){this._data[2]=t}}),t._isEnabled=!0)},t._isEnabled=!1,t}();t.SIMDHelper=_}(BABYLON||(BABYLON={}));',("undefined"!=typeof window&&window.module||"undefined"!=typeof module)&&void 0!==module.exports&&(module.exports=BABYLON);var HANDJS=HANDJS||{};!function(){function e(){M=!0,clearTimeout(E),E=setTimeout(function(){M=!1},700)}function t(e,t){for(;e;){if(e.contains(t))return e;e=e.parentNode}return null}function i(e,i,r){for(var n=t(e,i),o=e,s=[];o&&o!==n;)p(o,"pointerenter")&&s.push(o),o=o.parentNode;for(;s.length>0;)r(s.pop())}function r(e,i,r){for(var n=t(e,i),o=e;o&&o!==n;)p(o,"pointerleave")&&r(o),o=o.parentNode}function n(e,t){["pointerdown","pointermove","pointerup","pointerover","pointerout"].forEach(function(i){window.addEventListener(e(i),function(e){!M&&m(e.target,i)&&t(e,i,!0)})}),void 0===window["on"+e("pointerenter").toLowerCase()]&&window.addEventListener(e("pointerover"),function(e){if(!M){var r=m(e.target,"pointerenter");r&&r!==window&&(r.contains(e.relatedTarget)||i(r,e.relatedTarget,function(i){t(e,"pointerenter",!1,i,e.relatedTarget)}))}}),void 0===window["on"+e("pointerleave").toLowerCase()]&&window.addEventListener(e("pointerout"),function(e){if(!M){var i=m(e.target,"pointerleave");i&&i!==window&&(i.contains(e.relatedTarget)||r(i,e.relatedTarget,function(i){t(e,"pointerleave",!1,i,e.relatedTarget)}))}})}if(!window.PointerEvent){Array.prototype.indexOf||(Array.prototype.indexOf=function(e){var t=Object(this),i=t.length>>>0;if(0===i)return-1;var r=0;if(arguments.length>0&&((r=Number(arguments[1]))!=r?r=0:0!==r&&1/0!==r&&r!==-1/0&&(r=(r>0||-1)*Math.floor(Math.abs(r)))),r>=i)return-1;for(var n=r>=0?r:Math.max(i-Math.abs(r),0);i>n;n++)if(n in t&&t[n]===e)return n;return-1}),Array.prototype.forEach||(Array.prototype.forEach=function(e,t){if(!(this&&e instanceof Function))throw new TypeError;for(var i=0;i<this.length;i++)e.call(t,this[i],i,this)}),String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/,"")});var o=["pointerdown","pointerup","pointermove","pointerover","pointerout","pointercancel","pointerenter","pointerleave"],s=["PointerDown","PointerUp","PointerMove","PointerOver","PointerOut","PointerCancel","PointerEnter","PointerLeave"],a="touch",h="mouse",c={},l=function(e){for(;e&&!e.handjs_forcePreventDefault;)e=e.parentNode;return!!e||window.handjs_forcePreventDefault},u=function(e,t,i,r,n){var o;if(document.createEvent?(o=document.createEvent("MouseEvents")).initMouseEvent(t,i,!0,window,1,e.screenX,e.screenY,e.clientX,e.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,n||e.relatedTarget):((o=document.createEventObject()).screenX=e.screenX,o.screenY=e.screenY,o.clientX=e.clientX,o.clientY=e.clientY,o.ctrlKey=e.ctrlKey,o.altKey=e.altKey,o.shiftKey=e.shiftKey,o.metaKey=e.metaKey,o.button=e.button,o.relatedTarget=n||e.relatedTarget),void 0===o.offsetX&&(void 0!==e.offsetX?(Object&&void 0!==Object.defineProperty&&(Object.defineProperty(o,"offsetX",{writable:!0}),Object.defineProperty(o,"offsetY",{writable:!0})),o.offsetX=e.offsetX,o.offsetY=e.offsetY):Object&&void 0!==Object.defineProperty?(Object.defineProperty(o,"offsetX",{get:function(){return this.currentTarget&&this.currentTarget.offsetLeft?e.clientX-this.currentTarget.offsetLeft:e.clientX}}),Object.defineProperty(o,"offsetY",{get:function(){return this.currentTarget&&this.currentTarget.offsetTop?e.clientY-this.currentTarget.offsetTop:e.clientY}})):void 0!==e.layerX&&(o.offsetX=e.layerX-e.currentTarget.offsetLeft,o.offsetY=e.layerY-e.currentTarget.offsetTop)),o.isPrimary=void 0===e.isPrimary||e.isPrimary,e.pressure)o.pressure=e.pressure;else{var s=0;void 0!==e.which?s=e.which:void 0!==e.button&&(s=e.button),o.pressure=0===s?0:.5}if(o.rotation=e.rotation?e.rotation:0,o.hwTimestamp=e.hwTimestamp?e.hwTimestamp:0,o.tiltX=e.tiltX?e.tiltX:0,o.tiltY=e.tiltY?e.tiltY:0,o.height=e.height?e.height:0,o.width=e.width?e.width:0,o.preventDefault=function(){void 0!==e.preventDefault&&e.preventDefault()},void 0!==o.stopPropagation){var c=o.stopPropagation;o.stopPropagation=function(){void 0!==e.stopPropagation&&e.stopPropagation(),c.call(this)}}switch(o.pointerId=e.pointerId,o.pointerType=e.pointerType,o.pointerType){case 2:o.pointerType=a;break;case 3:o.pointerType="pen";break;case 4:o.pointerType=h}r?r.dispatchEvent(o):e.target?e.target.dispatchEvent(o):e.srcElement.fireEvent("on"+v(t),o)},d=function(e,t,i,r,n){e.pointerId=1,e.pointerType=h,u(e,t,i,r,n)},f=function(e,t,i,r,n,o){var s=t.identifier+2;t.pointerId=s,t.pointerType=a,t.currentTarget=i,void 0!==r.preventDefault&&(t.preventDefault=function(){r.preventDefault()}),u(t,e,n,i,o)},p=function(e,t){return e.__handjsGlobalRegisteredEvents&&e.__handjsGlobalRegisteredEvents[t]},m=function(e,t){for(;e&&!p(e,t);)e=e.parentNode;return e||(p(window,t)?window:void 0)},g=function(e,t,i,r,n,o){m(i,e)&&f(e,t,i,r,n,o)},v=function(e){return e.toLowerCase().replace("pointer","mouse")},_=function(e,t){var i=o.indexOf(t);return e+s[i]},y=function(e,t,i){if(e.__handjsGlobalRegisteredEvents||(e.__handjsGlobalRegisteredEvents=[]),i){if(void 0!==e.__handjsGlobalRegisteredEvents[t])return void e.__handjsGlobalRegisteredEvents[t]++;e.__handjsGlobalRegisteredEvents[t]=1}else void 0!==e.__handjsGlobalRegisteredEvents[t]&&(e.__handjsGlobalRegisteredEvents[t]--,e.__handjsGlobalRegisteredEvents[t]<0&&(e.__handjsGlobalRegisteredEvents[t]=0));var r,n;switch(window.MSPointerEvent?(r=function(e){return _("MS",e)},n=u):(r=v,n=d),t){case"pointerenter":case"pointerleave":var o=r(t);void 0!==e["on"+o.toLowerCase()]&&function(e,t,i,r){if(void 0===e.__handjsRegisteredEvents&&(e.__handjsRegisteredEvents=[]),r){if(void 0!==e.__handjsRegisteredEvents[t])return void e.__handjsRegisteredEvents[t]++;e.__handjsRegisteredEvents[t]=1,e.addEventListener(t,i,!1)}else{if(-1!==e.__handjsRegisteredEvents.indexOf(t)&&(e.__handjsRegisteredEvents[t]--,0!==e.__handjsRegisteredEvents[t]))return;e.removeEventListener(t,i),e.__handjsRegisteredEvents[t]=0}}(e,o,function(e){n(e,t)},i)}},x=function(e){var t=e.prototype?e.prototype.addEventListener:e.addEventListener,i=function(e,i,r){-1!==o.indexOf(e)&&y(this,e,!0),void 0===t?this.attachEvent("on"+v(e),i):t.call(this,e,i,r)};e.prototype?e.prototype.addEventListener=i:e.addEventListener=i},b=function(e){var t=e.prototype?e.prototype.removeEventListener:e.removeEventListener,i=function(e,i,r){-1!==o.indexOf(e)&&y(this,e,!1),void 0===t?this.detachEvent(v(e),i):t.call(this,e,i,r)};e.prototype?e.prototype.removeEventListener=i:e.removeEventListener=i};x(window),x(window.HTMLElement||window.Element),x(document),x(HTMLBodyElement),x(HTMLDivElement),x(HTMLImageElement),x(HTMLUListElement),x(HTMLAnchorElement),x(HTMLLIElement),x(HTMLTableElement),window.HTMLSpanElement&&x(HTMLSpanElement),window.HTMLCanvasElement&&x(HTMLCanvasElement),window.SVGElement&&x(SVGElement),b(window),b(window.HTMLElement||window.Element),b(document),b(HTMLBodyElement),b(HTMLDivElement),b(HTMLImageElement),b(HTMLUListElement),b(HTMLAnchorElement),b(HTMLLIElement),b(HTMLTableElement),window.HTMLSpanElement&&b(HTMLSpanElement),window.HTMLCanvasElement&&b(HTMLCanvasElement),window.SVGElement&&b(SVGElement);var M=!1,E=-1;window.MSPointerEvent?n(function(e){return _("MS",e)},u):(n(v,d),void 0!==window.ontouchstart&&(window.addEventListener("touchstart",function(t){for(var r=0;r<t.changedTouches.length;++r){var n=t.changedTouches[r];c[n.identifier]=n.target,g("pointerover",n,n.target,t,!0),i(n.target,null,function(e){f("pointerenter",n,e,t,!1)}),g("pointerdown",n,n.target,t,!0)}e()}),window.addEventListener("touchend",function(t){for(var i=0;i<t.changedTouches.length;++i){var n=t.changedTouches[i],o=c[n.identifier];g("pointerup",n,o,t,!0),g("pointerout",n,o,t,!0),r(o,null,function(e){f("pointerleave",n,e,t,!1)})}e()}),window.addEventListener("touchmove",function(t){for(var n=0;n<t.changedTouches.length;++n){var o=t.changedTouches[n],s=document.elementFromPoint(o.clientX,o.clientY),a=c[o.identifier];a&&!0===l(a)&&t.preventDefault(),g("pointermove",o,a,t,!0),a!==s&&(a&&(g("pointerout",o,a,t,!0,s),a.contains(s)||r(a,s,function(e){f("pointerleave",o,e,t,!1,s)})),s&&(g("pointerover",o,s,t,!0,a),s.contains(a)||i(s,a,function(e){f("pointerenter",o,e,t,!1,a)})),c[o.identifier]=s)}e()}),window.addEventListener("touchcancel",function(e){for(var t=0;t<e.changedTouches.length;++t){var i=e.changedTouches[t];g("pointercancel",i,c[i.identifier],e,!0)}}))),void 0===navigator.pointerEnabled&&(navigator.pointerEnabled=!0,navigator.msPointerEnabled&&(navigator.maxTouchPoints=navigator.msMaxTouchPoints))}}(),window.PointerEvent||document.styleSheets&&document.addEventListener&&document.addEventListener("DOMContentLoaded",function(){if(void 0===document.body.style.touchAction){var e=new RegExp(".+?{.*?}","m"),t=new RegExp(".+?{","m"),i=function(i){var r=e.exec(i);if(r){var n=r[0];i=i.replace(n,"").trim();var o=t.exec(n)[0].replace("{","").trim();if(-1!==n.replace(/\s/g,"").indexOf("touch-action:none"))for(var s=document.querySelectorAll(o),a=0;a<s.length;a++){var h=s[a];void 0!==h.style.msTouchAction?h.style.msTouchAction="none":h.handjs_forcePreventDefault=!0}return i}},r=function(e){if(window.setImmediate)e&&setImmediate(r,i(e));else for(;e;)e=i(e)};try{for(var n=0;n<document.styleSheets.length;n++){var o=document.styleSheets[n];if(void 0!==o.href){var s=new XMLHttpRequest;s.open("get",o.href),s.send();var a=s.responseText.replace(/(\n|\r)/g,"");r(a)}}}catch(e){}var h=document.getElementsByTagName("style");for(n=0;n<h.length;n++){var c=h[n].innerHTML.replace(/(\n|\r)/g,"").trim();r(c)}}},!1);var ScrollReveal=function(){"use strict";var e={delay:0,distance:"0",duration:600,easing:"cubic-bezier(0.5, 0, 0, 1)",interval:0,opacity:0,origin:"bottom",rotate:{x:0,y:0,z:0},scale:1,cleanup:!0,container:document.documentElement,desktop:!0,mobile:!0,reset:!1,useDelay:"always",viewFactor:0,viewOffset:{top:0,right:0,bottom:0,left:0},afterReset:function(){},afterReveal:function(){},beforeReset:function(){},beforeReveal:function(){}},t={clean:function(){},destroy:function(){},reveal:function(){},sync:function(){},get noop(){return!0}};function i(e){return"object"==typeof window.Node?e instanceof window.Node:null!==e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName}function r(e,t){if(void 0===t&&(t=document),e instanceof Array)return e.filter(i);if(i(e))return[e];if(r=e,n=Object.prototype.toString.call(r),"object"==typeof window.NodeList?r instanceof window.NodeList:null!==r&&"object"==typeof r&&"number"==typeof r.length&&/^\[object (HTMLCollection|NodeList|Object)\]$/.test(n)&&(0===r.length||i(r[0])))return Array.prototype.slice.call(e);var r,n;if("string"==typeof e)try{var o=t.querySelectorAll(e);return Array.prototype.slice.call(o)}catch(e){return[]}return[]}function n(e){return null!==e&&e instanceof Object&&(e.constructor===Object||"[object Object]"===Object.prototype.toString.call(e))}function o(e,t){if(n(e))return Object.keys(e).forEach(function(i){return t(e[i],i,e)});if(e instanceof Array)return e.forEach(function(i,r){return t(i,r,e)});throw new TypeError("Expected either an array or object literal.")}function s(e){for(var t=[],i=arguments.length-1;0<i--;)t[i]=arguments[i+1];if(this.constructor.debug&&console){var r="%cScrollReveal: "+e;t.forEach(function(e){return r+="\n — "+e}),console.log(r,"color: #ea654b;")}}function a(){var e=this,t={active:[],stale:[]},i={active:[],stale:[]},n={active:[],stale:[]};try{o(r("[data-sr-id]"),function(e){var i=parseInt(e.getAttribute("data-sr-id"));t.active.push(i)})}catch(e){throw e}o(this.store.elements,function(e){-1===t.active.indexOf(e.id)&&t.stale.push(e.id)}),o(t.stale,function(t){return delete e.store.elements[t]}),o(this.store.elements,function(e){-1===n.active.indexOf(e.containerId)&&n.active.push(e.containerId),e.hasOwnProperty("sequence")&&-1===i.active.indexOf(e.sequence.id)&&i.active.push(e.sequence.id)}),o(this.store.containers,function(e){-1===n.active.indexOf(e.id)&&n.stale.push(e.id)}),o(n.stale,function(t){var i=e.store.containers[t].node;i.removeEventListener("scroll",e.delegate),i.removeEventListener("resize",e.delegate),delete e.store.containers[t]}),o(this.store.sequences,function(e){-1===i.active.indexOf(e.id)&&i.stale.push(e.id)}),o(i.stale,function(t){return delete e.store.sequences[t]})}function h(e){var t,i=this;try{o(r(e),function(e){var r=e.getAttribute("data-sr-id");if(null!==r){t=!0;var n=i.store.elements[r];n.callbackTimer&&window.clearTimeout(n.callbackTimer.clock),e.setAttribute("style",n.styles.inline.generated),e.removeAttribute("data-sr-id"),delete i.store.elements[r]}})}catch(e){return s.call(this,"Clean failed.",e.message)}if(t)try{a.call(this)}catch(e){return s.call(this,"Clean failed.",e.message)}}function c(e){if(e.constructor!==Array)throw new TypeError("Expected array.");if(16===e.length)return e;if(6===e.length){var t=l();return t[0]=e[0],t[1]=e[1],t[4]=e[2],t[5]=e[3],t[12]=e[4],t[13]=e[5],t}throw new RangeError("Expected array with either 6 or 16 values.")}function l(){for(var e=[],t=0;t<16;t++)t%5==0?e.push(1):e.push(0);return e}function u(e,t){for(var i=c(e),r=c(t),n=[],o=0;o<4;o++)for(var s=[i[o],i[o+4],i[o+8],i[o+12]],a=0;a<4;a++){var h=4*a,l=[r[h],r[h+1],r[h+2],r[h+3]],u=s[0]*l[0]+s[1]*l[1]+s[2]*l[2]+s[3]*l[3];n[o+h]=u}return n}function d(e,t){var i=l();return i[0]=e,i[5]="number"==typeof t?t:e,i}var f=function(){var e={},t=document.documentElement.style;function i(i,r){if(void 0===r&&(r=t),i&&"string"==typeof i){if(e[i])return e[i];if("string"==typeof r[i])return e[i]=i;if("string"==typeof r["-webkit-"+i])return e[i]="-webkit-"+i;throw new RangeError('Unable to find "'+i+'" style property.')}throw new TypeError("Expected a string.")}return i.clearCache=function(){return e={}},i}();function p(e,t){void 0===t&&(t={});var i=t.pristine||this.pristine,r="always"===e.config.useDelay||"onload"===e.config.useDelay&&i||"once"===e.config.useDelay&&!e.seen,n=e.visible&&!e.revealed,o=!e.visible&&e.revealed&&e.config.reset;return t.reveal||n?function(e,t){var i=[e.styles.inline.generated,e.styles.opacity.computed,e.styles.transform.generated.final];t?i.push(e.styles.transition.generated.delayed):i.push(e.styles.transition.generated.instant),e.revealed=e.seen=!0,e.node.setAttribute("style",i.filter(function(e){return""!==e}).join(" ")),m.call(this,e,t)}.call(this,e,r):t.reset||o?function(e){var t=[e.styles.inline.generated,e.styles.opacity.generated,e.styles.transform.generated.initial,e.styles.transition.generated.instant];e.revealed=!1,e.node.setAttribute("style",t.filter(function(e){return""!==e}).join(" ")),m.call(this,e)}.call(this,e):void 0}function m(e,t){var i=this,r=t?e.config.duration+e.config.delay:e.config.duration,n=e.revealed?e.config.beforeReveal:e.config.beforeReset,o=e.revealed?e.config.afterReveal:e.config.afterReset,s=0;e.callbackTimer&&(s=Date.now()-e.callbackTimer.start,window.clearTimeout(e.callbackTimer.clock)),n(e.node),e.callbackTimer={start:Date.now(),clock:window.setTimeout(function(){o(e.node),e.callbackTimer=null,e.revealed&&!e.config.reset&&e.config.cleanup&&h.call(i,e.node)},r-s)}}var g,v=(g=0,function(){return g++});function _(e,t){if(void 0===t&&(t=this.pristine),!e.visible&&e.revealed&&e.config.reset)return p.call(this,e,{reset:!0});var i=this.store.sequences[e.sequence.id],r=e.sequence.index;if(i){var n=new y(i,"visible",this.store),o=new y(i,"revealed",this.store);if(i.models={visible:n,revealed:o},!o.body.length){var s=i.members[n.body[0]],a=this.store.elements[s];if(a)return x.call(this,i,n.body[0],-1,t),x.call(this,i,n.body[0],1,t),p.call(this,a,{reveal:!0,pristine:t})}if(!i.blocked.head&&r===[].concat(o.head).pop()&&r>=[].concat(n.body).shift())return x.call(this,i,r,-1,t),p.call(this,e,{reveal:!0,pristine:t});if(!i.blocked.foot&&r===[].concat(o.foot).shift()&&r<=[].concat(n.body).pop())return x.call(this,i,r,1,t),p.call(this,e,{reveal:!0,pristine:t})}}function y(e,t,i){var r=this;this.head=[],this.body=[],this.foot=[],o(e.members,function(e,n){var o=i.elements[e];o&&o[t]&&r.body.push(n)}),this.body.length&&o(e.members,function(e,n){var o=i.elements[e];o&&!o[t]&&(n<r.body[0]?r.head.push(n):r.foot.push(n))})}function x(e,t,i,r){var n=this,o=["head",null,"foot"][1+i],s=e.members[t+i],a=this.store.elements[s];e.blocked[o]=!0,setTimeout(function(){e.blocked[o]=!1,a&&_.call(n,a,r)},e.interval)}function b(){var e=this;a.call(this),o(this.store.elements,function(e){var t=[e.styles.inline.generated];e.visible?(t.push(e.styles.opacity.computed),t.push(e.styles.transform.generated.final)):(t.push(e.styles.opacity.generated),t.push(e.styles.transform.generated.initial)),e.node.setAttribute("style",t.filter(function(e){return""!==e}).join(" "))}),o(this.store.containers,function(t){var i=t.node===document.documentElement?window:t.node;i.addEventListener("scroll",e.delegate),i.addEventListener("resize",e.delegate)}),this.delegate(),this.initTimeout=null}function M(e){return void 0===e&&(e=navigator.userAgent),/Android|iPhone|iPad|iPod/i.test(e)}function E(e){for(var t=[],i=arguments.length-1;0<i--;)t[i]=arguments[i+1];if(n(e))return o(t,function(t){o(t,function(t,i){n(t)?(e[i]&&n(e[i])||(e[i]={}),E(e[i],t)):e[i]=t})}),e;throw new TypeError("Target must be an object literal.")}function T(t,i,n){var a=this;void 0===i&&(i={}),void 0===n&&(n=!1);var p,m=[],g=i.interval||e.interval;try{g&&(p=new function(e){var t=Math.abs(e);if(isNaN(t))throw new RangeError("Invalid sequence interval.");this.id=v(),this.interval=Math.max(t,16),this.members=[],this.models={},this.blocked={head:!1,foot:!1}}(g));var _=r(t);if(!_.length)throw new Error("Invalid reveal target.");o(_.reduce(function(e,t){var n={},s=t.getAttribute("data-sr-id");s?(E(n,a.store.elements[s]),n.node.setAttribute("style",n.styles.inline.computed)):(n.id=v(),n.node=t,n.seen=!1,n.revealed=!1,n.visible=!1);var g=E({},n.config||a.defaults,i);if(!g.mobile&&M()||!g.desktop&&!M())return s&&h.call(a,n),e;var _,y=r(g.container)[0];if(!y)throw new Error("Invalid container.");return y.contains(t)&&(null===(_=function(e){for(var t=[],i=arguments.length-1;0<i--;)t[i]=arguments[i+1];var r=null;return o(t,function(t){o(t,function(t){null===r&&t.node===e&&(r=t.id)})}),r}(y,m,a.store.containers))&&(_=v(),m.push({id:_,node:y})),n.config=g,n.containerId=_,n.styles=function(e){var t=window.getComputedStyle(e.node),i=t.position,r=e.config,n={},o=(e.node.getAttribute("style")||"").match(/[\w-]+\s*:\s*[^;]+\s*/gi)||[];n.computed=o?o.map(function(e){return e.trim()}).join("; ")+";":"",n.generated=o.some(function(e){return e.match(/visibility\s?:\s?visible/i)})?n.computed:o.concat(["visibility: visible"]).map(function(e){return e.trim()}).join("; ")+";";var s,a,h,p,m,g,v,_,y,x,b,M,E,T=parseFloat(t.opacity),w=isNaN(parseFloat(r.opacity))?parseFloat(t.opacity):parseFloat(r.opacity),S={computed:T!==w?"opacity: "+T+";":"",generated:T!==w?"opacity: "+w+";":""},A=[];if(parseFloat(r.distance)){var P="top"===r.origin||"bottom"===r.origin?"Y":"X",C=r.distance;"top"!==r.origin&&"left"!==r.origin||(C=/^-/.test(C)?C.substr(1):"-"+C);var D=C.match(/(^-?\d+\.?\d?)|(em$|px$|%$)/g),R=D[0];switch(D[1]){case"em":C=parseInt(t.fontSize)*R;break;case"px":C=R;break;case"%":C="Y"===P?e.node.getBoundingClientRect().height*R/100:e.node.getBoundingClientRect().width*R/100;break;default:throw new RangeError("Unrecognized or missing distance unit.")}"Y"===P?A.push((h=C,(p=l())[13]=h,p)):A.push((s=C,(a=l())[12]=s,a))}r.rotate.x&&A.push((m=r.rotate.x,g=Math.PI/180*m,(v=l())[5]=v[10]=Math.cos(g),v[6]=v[9]=Math.sin(g),v[9]*=-1,v)),r.rotate.y&&A.push((_=r.rotate.y,y=Math.PI/180*_,(x=l())[0]=x[10]=Math.cos(y),x[2]=x[8]=Math.sin(y),x[2]*=-1,x)),r.rotate.z&&A.push((b=r.rotate.z,M=Math.PI/180*b,(E=l())[0]=E[5]=Math.cos(M),E[1]=E[4]=Math.sin(M),E[4]*=-1,E)),1!==r.scale&&(0===r.scale?A.push(d(2e-4)):A.push(d(r.scale)));var I={};if(A.length){I.property=f("transform"),I.computed={raw:t[I.property],matrix:function(e){if("string"==typeof e){var t=e.match(/matrix(3d)?\(([^)]+)\)/);if(t)return c(t[2].split(", ").map(parseFloat))}return l()}(t[I.property])},A.unshift(I.computed.matrix);var L=A.reduce(u);I.generated={initial:I.property+": matrix3d("+L.join(", ")+");",final:I.property+": matrix3d("+I.computed.matrix.join(", ")+");"}}else I.generated={initial:"",final:""};var O={};if(S.generated||I.generated.initial){O.property=f("transition"),O.computed=t[O.property],O.fragments=[];var B=r.delay,F=r.duration,N=r.easing;S.generated&&O.fragments.push({delayed:"opacity "+F/1e3+"s "+N+" "+B/1e3+"s",instant:"opacity "+F/1e3+"s "+N+" 0s"}),I.generated.initial&&O.fragments.push({delayed:I.property+" "+F/1e3+"s "+N+" "+B/1e3+"s",instant:I.property+" "+F/1e3+"s "+N+" 0s"}),O.computed&&!O.computed.match(/all 0s/)&&O.fragments.unshift({delayed:O.computed,instant:O.computed});var V=O.fragments.reduce(function(e,t,i){return e.delayed+=0===i?t.delayed:", "+t.delayed,e.instant+=0===i?t.instant:", "+t.instant,e},{delayed:"",instant:""});O.generated={delayed:O.property+": "+V.delayed+";",instant:O.property+": "+V.instant+";"}}else O.generated={delayed:"",instant:""};return{inline:n,opacity:S,position:i,transform:I,transition:O}}(n),p&&(n.sequence={id:p.id,index:p.members.length},p.members.push(n.id)),e.push(n)),e},[]),function(e){(a.store.elements[e.id]=e).node.setAttribute("data-sr-id",e.id)})}catch(t){return s.call(this,"Reveal failed.",t.message)}o(m,function(e){a.store.containers[e.id]={id:e.id,node:e.node}}),p&&(this.store.sequences[p.id]=p),!0!==n&&(this.store.history.push({target:t,options:i}),this.initTimeout&&window.clearTimeout(this.initTimeout),this.initTimeout=window.setTimeout(b.bind(this),0))}var w,S=Math.sign||function(e){return(0<e)-(e<0)||+e},A=(w=Date.now(),function(e){var t=Date.now();16<t-w?e(w=t):setTimeout(function(){return A(e)},0)}),P=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||A;function C(e,t){for(var i=t?e.node.clientHeight:e.node.offsetHeight,r=t?e.node.clientWidth:e.node.offsetWidth,n=0,o=0,s=e.node;isNaN(s.offsetTop)||(n+=s.offsetTop),isNaN(s.offsetLeft)||(o+=s.offsetLeft),s=s.offsetParent;);return{bounds:{top:n,right:o+r,bottom:n+i,left:o},height:i,width:r}}var D,R,I,L,O,B,F,N,V="4.0.0";function U(i){var n;if(void 0===i&&(i={}),void 0===this||Object.getPrototypeOf(this)!==U.prototype)return new U(i);if(!U.isSupported())return s.call(this,"Instantiation failed.","This browser is not supported."),t;try{n=E({},B||e,i)}catch(i){return s.call(this,"Instantiation failed.","Invalid configuration.",i.message),t}try{if(!r(n.container)[0])throw new Error("Invalid container.");if(!n.mobile&&M()||!n.desktop&&!M())throw new Error("This device is disabled.")}catch(i){return s.call(this,"Instantiation failed.",i.message),t}return B=n,document.documentElement.classList.add("sr"),document.body?document.body.style.height="100%":document.addEventListener("DOMContentLoaded",function(){document.body.style.height="100%"}),this.store={containers:{},elements:{},history:[],sequences:{}},this.pristine=!0,D=D||function(e,t){var i=this;void 0===e&&(e={type:"init"}),void 0===t&&(t=this.store.elements),P(function(){var r="init"===e.type||"resize"===e.type;o(i.store.containers,function(e){r&&(e.geometry=C.call(i,e,!0));var t=function(e){var t,i;return e.node===document.documentElement?(t=window.pageYOffset,i=window.pageXOffset):(t=e.node.scrollTop,i=e.node.scrollLeft),{top:t,left:i}}.call(i,e);e.scroll&&(e.direction={x:S(t.left-e.scroll.left),y:S(t.top-e.scroll.top)}),e.scroll=t}),o(t,function(e){r&&(e.geometry=C.call(i,e)),e.visible=function(e){void 0===e&&(e={});var t=this.store.containers[e.containerId];if(t){var i=Math.max(0,Math.min(1,e.config.viewFactor)),r=e.config.viewOffset,n=e.geometry.bounds.top+e.geometry.height*i,o=e.geometry.bounds.right-e.geometry.width*i,s=e.geometry.bounds.bottom-e.geometry.height*i,a=e.geometry.bounds.left+e.geometry.width*i,h=t.geometry.bounds.top+t.scroll.top+r.top,c=t.geometry.bounds.right+t.scroll.left-r.right,l=t.geometry.bounds.bottom+t.scroll.top-r.bottom,u=t.geometry.bounds.left+t.scroll.left+r.left;return n<l&&u<o&&h<s&&a<c||"fixed"===e.styles.position}}.call(i,e)}),o(t,function(e){e.sequence?_.call(i,e):p.call(i,e)}),i.pristine=!1})}.bind(this),R=R||function(){var e=this;o(this.store.elements,function(e){e.node.setAttribute("style",e.styles.inline.generated),e.node.removeAttribute("data-sr-id")}),o(this.store.containers,function(t){var i=t.node===document.documentElement?window:t.node;i.removeEventListener("scroll",e.delegate),i.removeEventListener("resize",e.delegate)}),this.store={containers:{},elements:{},history:[],sequences:{}}}.bind(this),I=I||T.bind(this),L=L||h.bind(this),O=O||function(){var e=this;o(this.store.history,function(t){T.call(e,t.target,t.options,!0)}),b.call(this)}.bind(this),Object.defineProperty(this,"delegate",{get:function(){return D}}),Object.defineProperty(this,"destroy",{get:function(){return R}}),Object.defineProperty(this,"reveal",{get:function(){return I}}),Object.defineProperty(this,"clean",{get:function(){return L}}),Object.defineProperty(this,"sync",{get:function(){return O}}),Object.defineProperty(this,"defaults",{get:function(){return B}}),Object.defineProperty(this,"version",{get:function(){return V}}),Object.defineProperty(this,"noop",{get:function(){return!1}}),N||(N=this)}return U.isSupported=function(){return("transform"in(t=document.documentElement.style)||"WebkitTransform"in t)&&("transition"in(e=document.documentElement.style)||"WebkitTransition"in e);var e,t},Object.defineProperty(U,"debug",{get:function(){return F||!1},set:function(e){return F="boolean"==typeof e?e:F}}),U(),U}();function addScrollListener(e){for(var t=0;t<e.length;t++)e[t].addEventListener("click",function(e){e.preventDefault();var t=this.getAttribute("data-link"),i=document.getElementById(t);animate(document.scrollingElement||document.documentElement,"scrollTop","",0,i.offsetTop,300,!0)},!1)}function animate(e,t,i,r,n,o,s){if(e){var a=(new Date).getTime(),h=setInterval(function(){var c=Math.min(1,((new Date).getTime()-a)/o);s?e[t]=r+c*(n-r)+i:e.style[t]=r+c*(n-r)+i,1===c&&clearInterval(h)},25);s?e[t]=r+i:e.style[t]=r+i}}!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.THREE={})}(this,function(e){function t(){}function i(e,t){this.x=e||0,this.y=t||0}function r(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0<arguments.length&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function n(e,t,i,r){this._x=e||0,this._y=t||0,this._z=i||0,this._w=void 0!==r?r:1}function o(e,t,i){this.x=e||0,this.y=t||0,this.z=i||0}function s(){this.elements=[1,0,0,0,1,0,0,0,1],0<arguments.length&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function a(e,t,r,n,o,h,c,l,u,d){Object.defineProperty(this,"id",{value:Pn++}),this.uuid=An.generateUUID(),this.name="",this.image=void 0!==e?e:a.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==t?t:a.DEFAULT_MAPPING,this.wrapS=void 0!==r?r:1001,this.wrapT=void 0!==n?n:1001,this.magFilter=void 0!==o?o:1006,this.minFilter=void 0!==h?h:1008,this.anisotropy=void 0!==u?u:1,this.format=void 0!==c?c:1023,this.type=void 0!==l?l:1009,this.offset=new i(0,0),this.repeat=new i(1,1),this.center=new i(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new s,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==d?d:3e3,this.version=0,this.onUpdate=null}function h(e,t,i,r){this.x=e||0,this.y=t||0,this.z=i||0,this.w=void 0!==r?r:1}function c(e,t,i){this.width=e,this.height=t,this.scissor=new h(0,0,e,t),this.scissorTest=!1,this.viewport=new h(0,0,e,t),void 0===(i=i||{}).minFilter&&(i.minFilter=1006),this.texture=new a(void 0,void 0,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0===i.stencilBuffer||i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null}function l(e,t,i){c.call(this,e,t,i),this.activeMipMapLevel=this.activeCubeFace=0}function u(e,t,i,r,n,o,s,h,c,l,u,d){a.call(this,null,o,s,h,c,l,r,n,u,d),this.image={data:e,width:t,height:i},this.magFilter=void 0!==c?c:1003,this.minFilter=void 0!==l?l:1003,this.flipY=this.generateMipmaps=!1,this.unpackAlignment=1}function d(e,t){this.min=void 0!==e?e:new o(1/0,1/0,1/0),this.max=void 0!==t?t:new o(-1/0,-1/0,-1/0)}function f(e,t){this.center=void 0!==e?e:new o,this.radius=void 0!==t?t:0}function p(e,t){this.normal=void 0!==e?e:new o(1,0,0),this.constant=void 0!==t?t:0}function m(e,t,i,r,n,o){this.planes=[void 0!==e?e:new p,void 0!==t?t:new p,void 0!==i?i:new p,void 0!==r?r:new p,void 0!==n?n:new p,void 0!==o?o:new p]}function g(e,t,i){return void 0===t&&void 0===i?this.set(e):this.setRGB(e,t,i)}function v(e){var t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(i){i.isInterleavedBufferAttribute&&(i=i.data);var r=t.get(i);r&&(e.deleteBuffer(r.buffer),t.delete(i))},update:function(i,r){i.isInterleavedBufferAttribute&&(i=i.data);var n=t.get(i);if(void 0===n)t.set(i,function(t,i){var r=t.array,n=t.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW,o=e.createBuffer();return e.bindBuffer(i,o),e.bufferData(i,r,n),t.onUploadCallback(),i=e.FLOAT,r instanceof Float32Array?i=e.FLOAT:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?i=e.UNSIGNED_SHORT:r instanceof Int16Array?i=e.SHORT:r instanceof Uint32Array?i=e.UNSIGNED_INT:r instanceof Int32Array?i=e.INT:r instanceof Int8Array?i=e.BYTE:r instanceof Uint8Array&&(i=e.UNSIGNED_BYTE),{buffer:o,type:i,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version}}(i,r));else if(n.version<i.version){var o=i,s=o.array,a=o.updateRange;e.bindBuffer(r,n.buffer),!1===o.dynamic?e.bufferData(r,s,e.STATIC_DRAW):-1===a.count?e.bufferSubData(r,0,s):0===a.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(e.bufferSubData(r,a.offset*s.BYTES_PER_ELEMENT,s.subarray(a.offset,a.offset+a.count)),a.count=-1),n.version=i.version}}}}function _(e,t,i,r){this._x=e||0,this._y=t||0,this._z=i||0,this._order=r||_.DefaultOrder}function y(){this.mask=1}function x(){Object.defineProperty(this,"id",{value:On++}),this.uuid=An.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=x.DefaultUp.clone();var e=new o,t=new _,i=new n,a=new o(1,1,1);t.onChange(function(){i.setFromEuler(t,!1)}),i.onChange(function(){t.setFromQuaternion(i,void 0,!1)}),Object.defineProperties(this,{position:{enumerable:!0,value:e},rotation:{enumerable:!0,value:t},quaternion:{enumerable:!0,value:i},scale:{enumerable:!0,value:a},modelViewMatrix:{value:new r},normalMatrix:{value:new s}}),this.matrix=new r,this.matrixWorld=new r,this.matrixAutoUpdate=x.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new y,this.visible=!0,this.receiveShadow=this.castShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}function b(){x.call(this),this.type="Camera",this.matrixWorldInverse=new r,this.projectionMatrix=new r}function M(e,t,i,r,n,o){b.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=void 0!==n?n:.1,this.far=void 0!==o?o:2e3,this.updateProjectionMatrix()}function E(e,t,i,r,n,s){this.a=e,this.b=t,this.c=i,this.normal=r&&r.isVector3?r:new o,this.vertexNormals=Array.isArray(r)?r:[],this.color=n&&n.isColor?n:new g,this.vertexColors=Array.isArray(n)?n:[],this.materialIndex=void 0!==s?s:0}function T(){Object.defineProperty(this,"id",{value:Bn+=2}),this.uuid=An.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingSphere=this.boundingBox=null,this.groupsNeedUpdate=this.lineDistancesNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.uvsNeedUpdate=this.verticesNeedUpdate=this.elementsNeedUpdate=!1}function w(e,t,i){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===i,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}function S(e,t,i){w.call(this,new Int8Array(e),t,i)}function A(e,t,i){w.call(this,new Uint8Array(e),t,i)}function P(e,t,i){w.call(this,new Uint8ClampedArray(e),t,i)}function C(e,t,i){w.call(this,new Int16Array(e),t,i)}function D(e,t,i){w.call(this,new Uint16Array(e),t,i)}function R(e,t,i){w.call(this,new Int32Array(e),t,i)}function I(e,t,i){w.call(this,new Uint32Array(e),t,i)}function L(e,t,i){w.call(this,new Float32Array(e),t,i)}function O(e,t,i){w.call(this,new Float64Array(e),t,i)}function B(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingSphere=this.boundingBox=null,this.groupsNeedUpdate=this.uvsNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.verticesNeedUpdate=!1}function F(e){if(0===e.length)return-1/0;for(var t=e[0],i=1,r=e.length;i<r;++i)e[i]>t&&(t=e[i]);return t}function N(){Object.defineProperty(this,"id",{value:Fn+=2}),this.uuid=An.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingSphere=this.boundingBox=null,this.drawRange={start:0,count:1/0}}function V(e,t,i,r,n,o){T.call(this),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:n,depthSegments:o},this.fromBufferGeometry(new U(e,t,i,r,n,o)),this.mergeVertices()}function U(e,t,i,r,n,s){function a(e,t,i,r,n,s,a,m,g,v,_){var y=s/g,x=a/v,b=s/2,M=a/2,E=m/2;a=g+1;var T,w,S=v+1,A=s=0,P=new o;for(w=0;w<S;w++){var C=w*x-M;for(T=0;T<a;T++)P[e]=(T*y-b)*r,P[t]=C*n,P[i]=E,l.push(P.x,P.y,P.z),P[e]=0,P[t]=0,P[i]=0<m?1:-1,u.push(P.x,P.y,P.z),d.push(T/g),d.push(1-w/v),s+=1}for(w=0;w<v;w++)for(T=0;T<g;T++)e=f+T+a*(w+1),t=f+(T+1)+a*(w+1),i=f+(T+1)+a*w,c.push(f+T+a*w,e,i),c.push(e,t,i),A+=6;h.addGroup(p,A,_),p+=A,f+=s}N.call(this),this.type="BoxBufferGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:n,depthSegments:s};var h=this;e=e||1,t=t||1,i=i||1,r=Math.floor(r)||1,n=Math.floor(n)||1,s=Math.floor(s)||1;var c=[],l=[],u=[],d=[],f=0,p=0;a("z","y","x",-1,-1,i,t,e,s,n,0),a("z","y","x",1,-1,i,t,-e,s,n,1),a("x","z","y",1,1,e,i,t,r,s,2),a("x","z","y",1,-1,e,i,-t,r,s,3),a("x","y","z",1,-1,e,t,i,r,n,4),a("x","y","z",-1,-1,e,t,-i,r,n,5),this.setIndex(c),this.addAttribute("position",new L(l,3)),this.addAttribute("normal",new L(u,3)),this.addAttribute("uv",new L(d,2))}function z(e,t,i,r){T.call(this),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r},this.fromBufferGeometry(new k(e,t,i,r)),this.mergeVertices()}function k(e,t,i,r){N.call(this),this.type="PlaneBufferGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};var n=(e=e||1)/2,o=(t=t||1)/2,s=(i=Math.floor(i)||1)+1,a=(r=Math.floor(r)||1)+1,h=e/i,c=t/r,l=[],u=[],d=[],f=[];for(e=0;e<a;e++){var p=e*c-o;for(t=0;t<s;t++)u.push(t*h-n,-p,0),d.push(0,0,1),f.push(t/i),f.push(1-e/r)}for(e=0;e<r;e++)for(t=0;t<i;t++)n=t+s*(e+1),o=t+1+s*(e+1),a=t+1+s*e,l.push(t+s*e,n,a),l.push(n,o,a);this.setIndex(l),this.addAttribute("position",new L(u,3)),this.addAttribute("normal",new L(d,3)),this.addAttribute("uv",new L(f,2))}function G(){Object.defineProperty(this,"id",{value:Nn++}),this.uuid=An.generateUUID(),this.name="",this.type="Material",this.lights=this.fog=!0,this.blending=1,this.side=0,this.flatShading=!1,this.vertexColors=0,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendEquationAlpha=this.blendDstAlpha=this.blendSrcAlpha=null,this.depthFunc=3,this.depthWrite=this.depthTest=!0,this.clippingPlanes=null,this.clipShadows=this.clipIntersection=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetUnits=this.polygonOffsetFactor=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this.userData={},this.needsUpdate=!0}function W(e){G.call(this),this.type="MeshBasicMaterial",this.color=new g(16777215),this.lightMap=this.map=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.envMap=this.alphaMap=this.specularMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinejoin=this.wireframeLinecap="round",this.lights=this.morphTargets=this.skinning=!1,this.setValues(e)}function H(e){G.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.morphNormals=this.morphTargets=this.skinning=this.clipping=this.lights=this.fog=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,void 0!==e&&(void 0!==e.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}function j(e,t){this.origin=void 0!==e?e:new o,this.direction=void 0!==t?t:new o}function Y(e,t){this.start=void 0!==e?e:new o,this.end=void 0!==t?t:new o}function X(e,t,i){this.a=void 0!==e?e:new o,this.b=void 0!==t?t:new o,this.c=void 0!==i?i:new o}function K(e,t){x.call(this),this.type="Mesh",this.geometry=void 0!==e?e:new N,this.material=void 0!==t?t:new W({color:16777215*Math.random()}),this.drawMode=0,this.updateMorphTargets()}function q(e,t,i,r){function n(e,i){t.buffers.color.setClear(e.r,e.g,e.b,i,r)}var o,s,a,h=new g(0),c=0;return{getClearColor:function(){return h},setClearColor:function(e,t){h.set(e),n(h,c=void 0!==t?t:1)},getClearAlpha:function(){return c},setClearAlpha:function(e){n(h,c=e)},render:function(t,r,l,u){null===(r=r.background)?n(h,c):r&&r.isColor&&(n(r,1),u=!0),(e.autoClear||u)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),r&&r.isCubeTexture?(void 0===a&&((a=new K(new U(1,1,1),new H({uniforms:Ln.cube.uniforms,vertexShader:Ln.cube.vertexShader,fragmentShader:Ln.cube.fragmentShader,side:1,depthTest:!0,depthWrite:!1,fog:!1}))).geometry.removeAttribute("normal"),a.geometry.removeAttribute("uv"),a.onBeforeRender=function(e,t,i){this.matrixWorld.copyPosition(i.matrixWorld)},i.update(a.geometry)),a.material.uniforms.tCube.value=r,t.push(a,a.geometry,a.material,0,null)):r&&r.isTexture&&(void 0===o&&(o=new M(-1,1,1,-1,0,1),s=new K(new k(2,2),new W({depthTest:!1,depthWrite:!1,fog:!1})),i.update(s.geometry)),s.material.map=r,e.renderBufferDirect(o,null,s.geometry,s.material,s,null))}}}function Z(){function e(){l.value!==r&&(l.value=r,l.needsUpdate=0<n),i.numPlanes=n,i.numIntersection=0}function t(e,t,r,n){var o=null!==e?e.length:0,s=null;if(0!==o){if(s=l.value,!0!==n||null===s)for(n=r+4*o,t=t.matrixWorldInverse,c.getNormalMatrix(t),(null===s||s.length<n)&&(s=new Float32Array(n)),n=0;n!==o;++n,r+=4)h.copy(e[n]).applyMatrix4(t,c),h.normal.toArray(s,r),s[r+3]=h.constant;l.value=s,l.needsUpdate=!0}return i.numPlanes=o,s}var i=this,r=null,n=0,o=!1,a=!1,h=new p,c=new s,l={value:null,needsUpdate:!1};this.uniform=l,this.numIntersection=this.numPlanes=0,this.init=function(e,i,s){var a=0!==e.length||i||0!==n||o;return o=i,r=t(e,s,0),n=e.length,a},this.beginShadows=function(){a=!0,t(null)},this.endShadows=function(){a=!1,e()},this.setState=function(i,s,h,c,u,d){if(!o||null===i||0===i.length||a&&!h)a?t(null):e();else{var f=4*(h=a?0:n),p=u.clippingState||null;for(l.value=p,p=t(i,c,f,d),i=0;i!==f;++i)p[i]=r[i];u.clippingState=p,this.numIntersection=s?this.numPlanes:0,this.numPlanes+=h}}}function Q(e,t,i){function r(e){e=e.target;var s=n[e.id];for(var a in null!==s.index&&t.remove(s.index),s.attributes)t.remove(s.attributes[a]);e.removeEventListener("dispose",r),delete n[e.id],(a=o[e.id])&&(t.remove(a),delete o[e.id]),(a=o[s.id])&&(t.remove(a),delete o[s.id]),i.memory.geometries--}var n={},o={};return{get:function(e,t){var o=n[t.id];return o||(t.addEventListener("dispose",r),t.isBufferGeometry?o=t:t.isGeometry&&(void 0===t._bufferGeometry&&(t._bufferGeometry=(new N).setFromObject(e)),o=t._bufferGeometry),n[t.id]=o,i.memory.geometries++,o)},update:function(i){var r=i.index,n=i.attributes;for(var o in null!==r&&t.update(r,e.ELEMENT_ARRAY_BUFFER),n)t.update(n[o],e.ARRAY_BUFFER);for(o in i=i.morphAttributes){n=0;for(var s=(r=i[o]).length;n<s;n++)t.update(r[n],e.ARRAY_BUFFER)}},getWireframeAttribute:function(i){var r=o[i.id];if(r)return r;r=[];var n=i.index,s=i.attributes;if(null!==n){s=0;for(var a=(n=n.array).length;s<a;s+=3){var h=n[s+0],c=n[s+1],l=n[s+2];r.push(h,c,c,l,l,h)}}else for(n=s.position.array,s=0,a=n.length/3-1;s<a;s+=3)h=s+0,c=s+1,l=s+2,r.push(h,c,c,l,l,h);return r=new(65535<F(r)?I:D)(r,1),t.update(r,e.ELEMENT_ARRAY_BUFFER),o[i.id]=r}}}function J(e,t){return Math.abs(t[1])-Math.abs(e[1])}function $(e,t,i,r,n,o,s,h,c,l){e=void 0!==e?e:[],a.call(this,e,void 0!==t?t:301,i,r,n,o,s,h,c,l),this.flipY=!1}function ee(e,t,i){var r=e[0];if(0>=r||0<r)return e;var n=t*i,o=zn[n];if(void 0===o&&(o=new Float32Array(n),zn[n]=o),0!==t)for(r.toArray(o,0),r=1,n=0;r!==t;++r)n+=i,e[r].toArray(o,n);return o}function te(e,t){var i=kn[t];void 0===i&&(i=new Int32Array(t),kn[t]=i);for(var r=0;r!==t;++r)i[r]=e.allocTextureUnit();return i}function ie(e,t){e.uniform1f(this.addr,t)}function re(e,t){e.uniform1i(this.addr,t)}function ne(e,t){void 0===t.x?e.uniform2fv(this.addr,t):e.uniform2f(this.addr,t.x,t.y)}function oe(e,t){void 0!==t.x?e.uniform3f(this.addr,t.x,t.y,t.z):void 0!==t.r?e.uniform3f(this.addr,t.r,t.g,t.b):e.uniform3fv(this.addr,t)}function se(e,t){void 0===t.x?e.uniform4fv(this.addr,t):e.uniform4f(this.addr,t.x,t.y,t.z,t.w)}function ae(e,t){e.uniformMatrix2fv(this.addr,!1,t.elements||t)}function he(e,t){void 0===t.elements?e.uniformMatrix3fv(this.addr,!1,t):(Wn.set(t.elements),e.uniformMatrix3fv(this.addr,!1,Wn))}function ce(e,t){void 0===t.elements?e.uniformMatrix4fv(this.addr,!1,t):(Gn.set(t.elements),e.uniformMatrix4fv(this.addr,!1,Gn))}function le(e,t,i){var r=i.allocTextureUnit();e.uniform1i(this.addr,r),i.setTexture2D(t||Vn,r)}function ue(e,t,i){var r=i.allocTextureUnit();e.uniform1i(this.addr,r),i.setTextureCube(t||Un,r)}function de(e,t){e.uniform2iv(this.addr,t)}function fe(e,t){e.uniform3iv(this.addr,t)}function pe(e,t){e.uniform4iv(this.addr,t)}function me(e,t){e.uniform1fv(this.addr,t)}function ge(e,t){e.uniform1iv(this.addr,t)}function ve(e,t){e.uniform2fv(this.addr,ee(t,this.size,2))}function _e(e,t){e.uniform3fv(this.addr,ee(t,this.size,3))}function ye(e,t){e.uniform4fv(this.addr,ee(t,this.size,4))}function xe(e,t){e.uniformMatrix2fv(this.addr,!1,ee(t,this.size,4))}function be(e,t){e.uniformMatrix3fv(this.addr,!1,ee(t,this.size,9))}function Me(e,t){e.uniformMatrix4fv(this.addr,!1,ee(t,this.size,16))}function Ee(e,t,i){var r=t.length,n=te(i,r);for(e.uniform1iv(this.addr,n),e=0;e!==r;++e)i.setTexture2D(t[e]||Vn,n[e])}function Te(e,t,i){var r=t.length,n=te(i,r);for(e.uniform1iv(this.addr,n),e=0;e!==r;++e)i.setTextureCube(t[e]||Un,n[e])}function we(e,t,i){this.id=e,this.addr=i,this.setValue=function(e){switch(e){case 5126:return ie;case 35664:return ne;case 35665:return oe;case 35666:return se;case 35674:return ae;case 35675:return he;case 35676:return ce;case 35678:case 36198:return le;case 35680:return ue;case 5124:case 35670:return re;case 35667:case 35671:return de;case 35668:case 35672:return fe;case 35669:case 35673:return pe}}(t.type)}function Se(e,t,i){this.id=e,this.addr=i,this.size=t.size,this.setValue=function(e){switch(e){case 5126:return me;case 35664:return ve;case 35665:return _e;case 35666:return ye;case 35674:return xe;case 35675:return be;case 35676:return Me;case 35678:return Ee;case 35680:return Te;case 5124:case 35670:return ge;case 35667:case 35671:return de;case 35668:case 35672:return fe;case 35669:case 35673:return pe}}(t.type)}function Ae(e){this.id=e,this.seq=[],this.map={}}function Pe(e,t,i){this.seq=[],this.map={},this.renderer=i,i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(var r=0;r<i;++r){var n=e.getActiveUniform(t,r),o=e.getUniformLocation(t,n.name),s=this,a=n.name,h=a.length;for(Hn.lastIndex=0;;){var c=Hn.exec(a),l=Hn.lastIndex,u=c[1],d=c[3];if("]"===c[2]&&(u|=0),void 0===d||"["===d&&l+2===h){a=s,n=void 0===d?new we(u,n,o):new Se(u,n,o),a.seq.push(n),a.map[n.id]=n;break}void 0===(d=s.map[u])&&(d=new Ae(u),u=s,s=d,u.seq.push(s),u.map[s.id]=s),s=d}}}function Ce(e,t,i){var r=e.createShader(t);return e.shaderSource(r,i),e.compileShader(r),!1===e.getShaderParameter(r,e.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile."),""!==e.getShaderInfoLog(r)&&console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",t===e.VERTEX_SHADER?"vertex":"fragment",e.getShaderInfoLog(r),function(e){e=e.split("\n");for(var t=0;t<e.length;t++)e[t]=t+1+": "+e[t];return e.join("\n")}(i)),r}function De(e){switch(e){case 3e3:return["Linear","( value )"];case 3001:return["sRGB","( value )"];case 3002:return["RGBE","( value )"];case 3004:return["RGBM","( value, 7.0 )"];case 3005:return["RGBM","( value, 16.0 )"];case 3006:return["RGBD","( value, 256.0 )"];case 3007:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw Error("unsupported encoding: "+e)}}function Re(e,t){return"vec4 "+e+"( vec4 value ) { return "+(t=De(t))[0]+"ToLinear"+t[1]+"; }"}function Ie(e){return""!==e}function Le(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights)}function Oe(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}function Be(e){return e.replace(/^[ \t]*#include +<([\w\d.]+)>/gm,function(e,t){if(void 0===(e=Cn[t]))throw Error("Can not resolve #include <"+t+">");return Be(e)})}function Fe(e){return e.replace(/#pragma unroll_loop[\s]+?for \( int i = (\d+); i < (\d+); i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(e,t,i,r){for(e="",t=parseInt(t);t<parseInt(i);t++)e+=r.replace(/\[ i \]/g,"[ "+t+" ]");return e})}function Ne(e,t,i,r,n,o){var s=e.context,a=r.defines,h=n.vertexShader,c=n.fragmentShader,l="SHADOWMAP_TYPE_BASIC";1===o.shadowMapType?l="SHADOWMAP_TYPE_PCF":2===o.shadowMapType&&(l="SHADOWMAP_TYPE_PCF_SOFT");var u="ENVMAP_TYPE_CUBE",d="ENVMAP_MODE_REFLECTION",f="ENVMAP_BLENDING_MULTIPLY";if(o.envMap){switch(r.envMap.mapping){case 301:case 302:u="ENVMAP_TYPE_CUBE";break;case 306:case 307:u="ENVMAP_TYPE_CUBE_UV";break;case 303:case 304:u="ENVMAP_TYPE_EQUIREC";break;case 305:u="ENVMAP_TYPE_SPHERE"}switch(r.envMap.mapping){case 302:case 304:d="ENVMAP_MODE_REFRACTION"}switch(r.combine){case 0:f="ENVMAP_BLENDING_MULTIPLY";break;case 1:f="ENVMAP_BLENDING_MIX";break;case 2:f="ENVMAP_BLENDING_ADD"}}var p,m,g=0<e.gammaFactor?e.gammaFactor:1,v=function(e,t,i){return[(e=e||{}).derivatives||t.envMapCubeUV||t.bumpMap||t.normalMap||t.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(e.fragDepth||t.logarithmicDepthBuffer)&&i.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",e.drawBuffers&&i.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(e.shaderTextureLOD||t.envMap)&&i.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Ie).join("\n")}(r.extensions,o,t),_=function(e){var t,i=[];for(t in e){var r=e[t];!1!==r&&i.push("#define "+t+" "+r)}return i.join("\n")}(a),y=s.createProgram();return r.isRawShaderMaterial?(0<(a=[_].filter(Ie).join("\n")).length&&(a+="\n"),0<(t=[v,_].filter(Ie).join("\n")).length&&(t+="\n")):(a=["precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+n.name,_,o.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+o.maxBones,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+d:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.displacementMap&&o.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.flatShading?"#define FLAT_SHADED":"",o.skinning?"#define USE_SKINNING":"",o.useVertexTexture?"#define BONE_TEXTURE":"",o.morphTargets?"#define USE_MORPHTARGETS":"",o.morphNormals&&!1===o.flatShading?"#define USE_MORPHNORMALS":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"",o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+l:"",o.sizeAttenuation?"#define USE_SIZEATTENUATION":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&t.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Ie).join("\n"),t=[v,"precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+n.name,_,o.alphaTest?"#define ALPHATEST "+o.alphaTest:"","#define GAMMA_FACTOR "+g,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+u:"",o.envMap?"#define "+d:"",o.envMap?"#define "+f:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.gradientMap?"#define USE_GRADIENTMAP":"",o.flatShading?"#define FLAT_SHADED":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"",o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+l:"",o.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",o.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&t.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",o.envMap&&t.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",0!==o.toneMapping?"#define TONE_MAPPING":"",0!==o.toneMapping?Cn.tonemapping_pars_fragment:"",0!==o.toneMapping?function(e,t){switch(t){case 1:t="Linear";break;case 2:t="Reinhard";break;case 3:t="Uncharted2";break;case 4:t="OptimizedCineon";break;default:throw Error("unsupported toneMapping: "+t)}return"vec3 "+e+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}("toneMapping",o.toneMapping):"",o.dithering?"#define DITHERING":"",o.outputEncoding||o.mapEncoding||o.envMapEncoding||o.emissiveMapEncoding?Cn.encodings_pars_fragment:"",o.mapEncoding?Re("mapTexelToLinear",o.mapEncoding):"",o.envMapEncoding?Re("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?Re("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?function(e,t){return"vec4 "+e+"( vec4 value ) { return LinearTo"+(t=De(t))[0]+t[1]+"; }"}("linearToOutputTexel",o.outputEncoding):"",o.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(Ie).join("\n")),h=Oe(h=Le(h=Be(h),o),o),c=Oe(c=Le(c=Be(c),o),o),h=Fe(h),c=t+(c=Fe(c)),h=Ce(s,s.VERTEX_SHADER,a+h),c=Ce(s,s.FRAGMENT_SHADER,c),s.attachShader(y,h),s.attachShader(y,c),void 0!==r.index0AttributeName?s.bindAttribLocation(y,0,r.index0AttributeName):!0===o.morphTargets&&s.bindAttribLocation(y,0,"position"),s.linkProgram(y),o=s.getProgramInfoLog(y).trim(),l=s.getShaderInfoLog(h).trim(),u=s.getShaderInfoLog(c).trim(),f=d=!0,!1===s.getProgramParameter(y,s.LINK_STATUS)?(d=!1,console.error("THREE.WebGLProgram: shader error: ",s.getError(),"gl.VALIDATE_STATUS",s.getProgramParameter(y,s.VALIDATE_STATUS),"gl.getProgramInfoLog",o,l,u)):""!==o?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",o):""!==l&&""!==u||(f=!1),f&&(this.diagnostics={runnable:d,material:r,programLog:o,vertexShader:{log:l,prefix:a},fragmentShader:{log:u,prefix:t}}),s.deleteShader(h),s.deleteShader(c),this.getUniforms=function(){return void 0===p&&(p=new Pe(s,y,e)),p},this.getAttributes=function(){if(void 0===m){for(var e={},t=s.getProgramParameter(y,s.ACTIVE_ATTRIBUTES),i=0;i<t;i++){var r=s.getActiveAttrib(y,i).name;e[r]=s.getAttribLocation(y,r)}m=e}return m},this.destroy=function(){s.deleteProgram(y),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms()."),this.getUniforms()}},attributes:{get:function(){return console.warn("THREE.WebGLProgram: .attributes is now .getAttributes()."),this.getAttributes()}}}),this.name=n.name,this.id=jn++,this.code=i,this.usedTimes=1,this.program=y,this.vertexShader=h,this.fragmentShader=c,this}function Ve(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.program&&t.program&&e.program!==t.program?e.program.id-t.program.id:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function Ue(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function ze(){var e={};return{get:function(t,i){return t=t.id+","+i.id,void 0===(i=e[t])&&(i=new function(){var e=[],t=0,i=[],r=[];return{opaque:i,transparent:r,init:function(){t=0,i.length=0,r.length=0},push:function(n,o,s,a,h){var c=e[t];void 0===c?(c={id:n.id,object:n,geometry:o,material:s,program:s.program,renderOrder:n.renderOrder,z:a,group:h},e[t]=c):(c.id=n.id,c.object=n,c.geometry=o,c.material=s,c.program=s.program,c.renderOrder=n.renderOrder,c.z=a,c.group=h),(!0===s.transparent?r:i).push(c),t++},sort:function(){1<i.length&&i.sort(Ve),1<r.length&&r.sort(Ue)}}},e[t]=i),i},dispose:function(){e={}}}}function ke(){var e=new function(){var e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];switch(t.type){case"DirectionalLight":var r={direction:new o,color:new g,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new i};break;case"SpotLight":r={position:new o,direction:new o,color:new g,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new i};break;case"PointLight":r={position:new o,color:new g,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new i,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":r={direction:new o,skyColor:new g,groundColor:new g};break;case"RectAreaLight":r={color:new g,position:new o,halfWidth:new o,halfHeight:new o}}return e[t.id]=r}}},t={id:Yn++,hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},n=new o,s=new r,a=new r;return{setup:function(i,r,o){var h=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0;o=o.matrixWorldInverse;for(var g=0,v=i.length;g<v;g++){var _=i[g],y=_.color,x=_.intensity,b=_.distance,M=_.shadow&&_.shadow.map?_.shadow.map.texture:null;if(_.isAmbientLight)h+=y.r*x,c+=y.g*x,l+=y.b*x;else if(_.isDirectionalLight){var E=e.get(_);E.color.copy(_.color).multiplyScalar(_.intensity),E.direction.setFromMatrixPosition(_.matrixWorld),n.setFromMatrixPosition(_.target.matrixWorld),E.direction.sub(n),E.direction.transformDirection(o),(E.shadow=_.castShadow)&&(y=_.shadow,E.shadowBias=y.bias,E.shadowRadius=y.radius,E.shadowMapSize=y.mapSize),t.directionalShadowMap[u]=M,t.directionalShadowMatrix[u]=_.shadow.matrix,t.directional[u]=E,u++}else _.isSpotLight?((E=e.get(_)).position.setFromMatrixPosition(_.matrixWorld),E.position.applyMatrix4(o),E.color.copy(y).multiplyScalar(x),E.distance=b,E.direction.setFromMatrixPosition(_.matrixWorld),n.setFromMatrixPosition(_.target.matrixWorld),E.direction.sub(n),E.direction.transformDirection(o),E.coneCos=Math.cos(_.angle),E.penumbraCos=Math.cos(_.angle*(1-_.penumbra)),E.decay=0===_.distance?0:_.decay,(E.shadow=_.castShadow)&&(y=_.shadow,E.shadowBias=y.bias,E.shadowRadius=y.radius,E.shadowMapSize=y.mapSize),t.spotShadowMap[f]=M,t.spotShadowMatrix[f]=_.shadow.matrix,t.spot[f]=E,f++):_.isRectAreaLight?((E=e.get(_)).color.copy(y).multiplyScalar(x),E.position.setFromMatrixPosition(_.matrixWorld),E.position.applyMatrix4(o),a.identity(),s.copy(_.matrixWorld),s.premultiply(o),a.extractRotation(s),E.halfWidth.set(.5*_.width,0,0),E.halfHeight.set(0,.5*_.height,0),E.halfWidth.applyMatrix4(a),E.halfHeight.applyMatrix4(a),t.rectArea[p]=E,p++):_.isPointLight?((E=e.get(_)).position.setFromMatrixPosition(_.matrixWorld),E.position.applyMatrix4(o),E.color.copy(_.color).multiplyScalar(_.intensity),E.distance=_.distance,E.decay=0===_.distance?0:_.decay,(E.shadow=_.castShadow)&&(y=_.shadow,E.shadowBias=y.bias,E.shadowRadius=y.radius,E.shadowMapSize=y.mapSize,E.shadowCameraNear=y.camera.near,E.shadowCameraFar=y.camera.far),t.pointShadowMap[d]=M,t.pointShadowMatrix[d]=_.shadow.matrix,t.point[d]=E,d++):_.isHemisphereLight&&((E=e.get(_)).direction.setFromMatrixPosition(_.matrixWorld),E.direction.transformDirection(o),E.direction.normalize(),E.skyColor.copy(_.color).multiplyScalar(x),E.groundColor.copy(_.groundColor).multiplyScalar(x),t.hemi[m]=E,m++)}t.ambient[0]=h,t.ambient[1]=c,t.ambient[2]=l,t.directional.length=u,t.spot.length=f,t.rectArea.length=p,t.point.length=d,t.hemi.length=m,t.hash=t.id+","+u+","+d+","+f+","+p+","+m+","+r.length},state:t}}function Ge(){var e={};return{get:function(t,i){return t=t.id+","+i.id,void 0===(i=e[t])&&(i=new function(){var e=new ke,t=[],i=[],r=[];return{init:function(){t.length=0,i.length=0,r.length=0},state:{lightsArray:t,shadowsArray:i,spritesArray:r,lights:e},setupLights:function(r){e.setup(t,i,r)},pushLight:function(e){t.push(e)},pushShadow:function(e){i.push(e)},pushSprite:function(e){r.push(e)}}},e[t]=i),i},dispose:function(){e={}}}}function We(e){G.call(this),this.type="MeshDepthMaterial",this.depthPacking=3200,this.morphTargets=this.skinning=!1,this.displacementMap=this.alphaMap=this.map=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.lights=this.fog=!1,this.setValues(e)}function He(e){G.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new o,this.nearDistance=1,this.farDistance=1e3,this.morphTargets=this.skinning=!1,this.displacementMap=this.alphaMap=this.map=null,this.displacementScale=1,this.displacementBias=0,this.lights=this.fog=!1,this.setValues(e)}function je(e,t,n){function s(t,i,r,n,o,s){var a=t.geometry,h=v,c=t.customDepthMaterial;return r&&(h=_,c=t.customDistanceMaterial),c?h=c:(c=!1,i.morphTargets&&(a&&a.isBufferGeometry?c=a.morphAttributes&&a.morphAttributes.position&&0<a.morphAttributes.position.length:a&&a.isGeometry&&(c=a.morphTargets&&0<a.morphTargets.length)),t.isSkinnedMesh&&!1===i.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",t),a=0,c&&(a|=1),(t=t.isSkinnedMesh&&i.skinning)&&(a|=2),h=h[a]),e.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length&&(a=h.uuid,c=i.uuid,void 0===(t=y[a])&&(t={},y[a]=t),void 0===(a=t[c])&&(a=h.clone(),t[c]=a),h=a),h.visible=i.visible,h.wireframe=i.wireframe,h.side=null!=i.shadowSide?i.shadowSide:x[i.side],h.clipShadows=i.clipShadows,h.clippingPlanes=i.clippingPlanes,h.clipIntersection=i.clipIntersection,h.wireframeLinewidth=i.wireframeLinewidth,h.linewidth=i.linewidth,r&&h.isMeshDistanceMaterial&&(h.referencePosition.copy(n),h.nearDistance=o,h.farDistance=s),h}function a(i,r,n,o){if(!1!==i.visible){if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&i.castShadow&&(!i.frustumCulled||l.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,i.matrixWorld);var h=t.update(i),c=i.material;if(Array.isArray(c))for(var u=h.groups,d=0,f=u.length;d<f;d++){var p=u[d],m=c[p.materialIndex];m&&m.visible&&(m=s(i,m,o,g,n.near,n.far),e.renderBufferDirect(n,null,h,m,i,p))}else c.visible&&(m=s(i,c,o,g,n.near,n.far),e.renderBufferDirect(n,null,h,m,i,null))}for(h=0,c=(i=i.children).length;h<c;h++)a(i[h],r,n,o)}}var l=new m,u=new r,d=new i,f=new i(n,n),p=new o,g=new o,v=Array(4),_=Array(4),y={},x={0:1,1:0,2:2},b=[new o(1,0,0),new o(-1,0,0),new o(0,0,1),new o(0,0,-1),new o(0,1,0),new o(0,-1,0)],M=[new o(0,1,0),new o(0,1,0),new o(0,1,0),new o(0,1,0),new o(0,0,1),new o(0,0,-1)],E=[new h,new h,new h,new h,new h,new h];for(n=0;4!==n;++n){var T=0!=(1&n),w=0!=(2&n),S=new We({depthPacking:3201,morphTargets:T,skinning:w});v[n]=S,T=new He({morphTargets:T,skinning:w}),_[n]=T}var A=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1,this.render=function(t,i,r){if(!1!==A.enabled&&(!1!==A.autoUpdate||!1!==A.needsUpdate)&&0!==t.length){var n=e.state;n.disable(e.context.BLEND),n.buffers.color.setClear(1,1,1,1),n.buffers.depth.setTest(!0),n.setScissorTest(!1);for(var o,s=0,h=t.length;s<h;s++){var m=t[s];o=m.shadow;var v=m&&m.isPointLight;if(void 0===o)console.warn("THREE.WebGLShadowMap:",m,"has no shadow.");else{var _=o.camera;if(d.copy(o.mapSize),d.min(f),v){var y=d.x,x=d.y;E[0].set(2*y,x,y,x),E[1].set(0,x,y,x),E[2].set(3*y,x,y,x),E[3].set(y,x,y,x),E[4].set(3*y,0,y,x),E[5].set(y,0,y,x),d.x*=4,d.y*=2}for(null===o.map&&(o.map=new c(d.x,d.y,{minFilter:1003,magFilter:1003,format:1023}),o.map.texture.name=m.name+".shadowMap",_.updateProjectionMatrix()),o.isSpotLightShadow&&o.update(m),y=o.map,x=o.matrix,g.setFromMatrixPosition(m.matrixWorld),_.position.copy(g),v?(o=6,x.makeTranslation(-g.x,-g.y,-g.z)):(o=1,p.setFromMatrixPosition(m.target.matrixWorld),_.lookAt(p),_.updateMatrixWorld(),x.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),x.multiply(_.projectionMatrix),x.multiply(_.matrixWorldInverse)),e.setRenderTarget(y),e.clear(),m=0;m<o;m++)v&&(p.copy(_.position),p.add(b[m]),_.up.copy(M[m]),_.lookAt(p),_.updateMatrixWorld(),n.viewport(E[m])),u.multiplyMatrices(_.projectionMatrix,_.matrixWorldInverse),l.setFromMatrix(u),a(i,r,_,v)}}A.needsUpdate=!1}}}function Ye(e,t,i,r,n,o,s,h,c){a.call(this,e,t,i,r,n,o,s,h,c),this.needsUpdate=!0}function Xe(e,t,i,r,s){var a,h,c,l,u,d,f,p,m,g,v,_,y,x,b,M,E,T;function w(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:t.id-e.id}var S,A,P,C,D=new o,R=new n,I=new o;this.render=function(n,o,L){if(0!==n.length){if(void 0===P){var O=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),B=new Uint16Array([0,1,2,0,2,3]);S=t.createBuffer(),A=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,S),t.bufferData(t.ARRAY_BUFFER,O,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,A),t.bufferData(t.ELEMENT_ARRAY_BUFFER,B,t.STATIC_DRAW),O=t.createProgram(),B=t.createShader(t.VERTEX_SHADER);var F=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(B,["precision "+s.precision+" float;","#define SHADER_NAME SpriteMaterial\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 center;\nuniform vec2 scale;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvarying float fogDepth;\nvoid main() {\n\tvUV = uvOffset + uv * uvScale;\n\tvec2 alignedPosition = ( position - center ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tvec4 mvPosition;\n\tmvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\tfogDepth = - mvPosition.z;\n}"].join("\n")),t.shaderSource(F,["precision "+s.precision+" float;","#define SHADER_NAME SpriteMaterial\nuniform vec3 color;\nuniform sampler2D map;\nuniform float opacity;\nuniform int fogType;\nuniform vec3 fogColor;\nuniform float fogDensity;\nuniform float fogNear;\nuniform float fogFar;\nuniform float alphaTest;\nvarying vec2 vUV;\nvarying float fogDepth;\nvoid main() {\n\tvec4 texture = texture2D( map, vUV );\n\tgl_FragColor = vec4( color * texture.xyz, texture.a * opacity );\n\tif ( gl_FragColor.a < alphaTest ) discard;\n\tif ( fogType > 0 ) {\n\t\tfloat fogFactor = 0.0;\n\t\tif ( fogType == 1 ) {\n\t\t\tfogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t\t} else {\n\t\t\tconst float LOG2 = 1.442695;\n\t\t\tfogFactor = exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 );\n\t\t\tfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n\t\t}\n\t\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n\t}\n}"].join("\n")),t.compileShader(B),t.compileShader(F),t.attachShader(O,B),t.attachShader(O,F),t.linkProgram(O),P=O,E=t.getAttribLocation(P,"position"),T=t.getAttribLocation(P,"uv"),a=t.getUniformLocation(P,"uvOffset"),h=t.getUniformLocation(P,"uvScale"),c=t.getUniformLocation(P,"rotation"),l=t.getUniformLocation(P,"center"),u=t.getUniformLocation(P,"scale"),d=t.getUniformLocation(P,"color"),f=t.getUniformLocation(P,"map"),p=t.getUniformLocation(P,"opacity"),m=t.getUniformLocation(P,"modelViewMatrix"),g=t.getUniformLocation(P,"projectionMatrix"),v=t.getUniformLocation(P,"fogType"),_=t.getUniformLocation(P,"fogDensity"),y=t.getUniformLocation(P,"fogNear"),x=t.getUniformLocation(P,"fogFar"),b=t.getUniformLocation(P,"fogColor"),t.getUniformLocation(P,"fogDepth"),M=t.getUniformLocation(P,"alphaTest"),(O=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")).width=8,O.height=8,(B=O.getContext("2d")).fillStyle="white",B.fillRect(0,0,8,8),C=new Ye(O)}i.useProgram(P),i.initAttributes(),i.enableAttribute(E),i.enableAttribute(T),i.disableUnusedAttributes(),i.disable(t.CULL_FACE),i.enable(t.BLEND),t.bindBuffer(t.ARRAY_BUFFER,S),t.vertexAttribPointer(E,2,t.FLOAT,!1,16,0),t.vertexAttribPointer(T,2,t.FLOAT,!1,16,8),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,A),t.uniformMatrix4fv(g,!1,L.projectionMatrix.elements),i.activeTexture(t.TEXTURE0),t.uniform1i(f,0),B=O=0,(F=o.fog)?(t.uniform3f(b,F.color.r,F.color.g,F.color.b),F.isFog?(t.uniform1f(y,F.near),t.uniform1f(x,F.far),t.uniform1i(v,1),B=O=1):F.isFogExp2&&(t.uniform1f(_,F.density),t.uniform1i(v,2),B=O=2)):(t.uniform1i(v,0),B=O=0),F=0;for(var N=n.length;F<N;F++){var V=n[F];V.modelViewMatrix.multiplyMatrices(L.matrixWorldInverse,V.matrixWorld),V.z=-V.modelViewMatrix.elements[14]}n.sort(w);var U=[],z=[];for(F=0,N=n.length;F<N;F++){var k=(V=n[F]).material;if(!1!==k.visible){V.onBeforeRender(e,o,L,void 0,k,void 0),t.uniform1f(M,k.alphaTest),t.uniformMatrix4fv(m,!1,V.modelViewMatrix.elements),V.matrixWorld.decompose(D,R,I),U[0]=I.x,U[1]=I.y,z[0]=V.center.x-.5,z[1]=V.center.y-.5;var G=0;o.fog&&k.fog&&(G=B),O!==G&&(t.uniform1i(v,G),O=G),null!==k.map?(t.uniform2f(a,k.map.offset.x,k.map.offset.y),t.uniform2f(h,k.map.repeat.x,k.map.repeat.y)):(t.uniform2f(a,0,0),t.uniform2f(h,1,1)),t.uniform1f(p,k.opacity),t.uniform3f(d,k.color.r,k.color.g,k.color.b),t.uniform1f(c,k.rotation),t.uniform2fv(l,z),t.uniform2fv(u,U),i.setBlending(k.blending,k.blendEquation,k.blendSrc,k.blendDst,k.blendEquationAlpha,k.blendSrcAlpha,k.blendDstAlpha,k.premultipliedAlpha),i.buffers.depth.setTest(k.depthTest),i.buffers.depth.setMask(k.depthWrite),i.buffers.color.setMask(k.colorWrite),r.setTexture2D(k.map||C,0),t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0),V.onAfterRender(e,o,L,void 0,k,void 0)}}i.enable(t.CULL_FACE),i.reset()}}}function Ke(e,t){return{convert:function(i){if(1e3===i)return e.REPEAT;if(1001===i)return e.CLAMP_TO_EDGE;if(1002===i)return e.MIRRORED_REPEAT;if(1003===i)return e.NEAREST;if(1004===i)return e.NEAREST_MIPMAP_NEAREST;if(1005===i)return e.NEAREST_MIPMAP_LINEAR;if(1006===i)return e.LINEAR;if(1007===i)return e.LINEAR_MIPMAP_NEAREST;if(1008===i)return e.LINEAR_MIPMAP_LINEAR;if(1009===i)return e.UNSIGNED_BYTE;if(1017===i)return e.UNSIGNED_SHORT_4_4_4_4;if(1018===i)return e.UNSIGNED_SHORT_5_5_5_1;if(1019===i)return e.UNSIGNED_SHORT_5_6_5;if(1010===i)return e.BYTE;if(1011===i)return e.SHORT;if(1012===i)return e.UNSIGNED_SHORT;if(1013===i)return e.INT;if(1014===i)return e.UNSIGNED_INT;if(1015===i)return e.FLOAT;if(1016===i){var r=t.get("OES_texture_half_float");if(null!==r)return r.HALF_FLOAT_OES}if(1021===i)return e.ALPHA;if(1022===i)return e.RGB;if(1023===i)return e.RGBA;if(1024===i)return e.LUMINANCE;if(1025===i)return e.LUMINANCE_ALPHA;if(1026===i)return e.DEPTH_COMPONENT;if(1027===i)return e.DEPTH_STENCIL;if(100===i)return e.FUNC_ADD;if(101===i)return e.FUNC_SUBTRACT;if(102===i)return e.FUNC_REVERSE_SUBTRACT;if(200===i)return e.ZERO;if(201===i)return e.ONE;if(202===i)return e.SRC_COLOR;if(203===i)return e.ONE_MINUS_SRC_COLOR;if(204===i)return e.SRC_ALPHA;if(205===i)return e.ONE_MINUS_SRC_ALPHA;if(206===i)return e.DST_ALPHA;if(207===i)return e.ONE_MINUS_DST_ALPHA;if(208===i)return e.DST_COLOR;if(209===i)return e.ONE_MINUS_DST_COLOR;if(210===i)return e.SRC_ALPHA_SATURATE;if((33776===i||33777===i||33778===i||33779===i)&&null!==(r=t.get("WEBGL_compressed_texture_s3tc"))){if(33776===i)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===i)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===i)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===i)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((35840===i||35841===i||35842===i||35843===i)&&null!==(r=t.get("WEBGL_compressed_texture_pvrtc"))){if(35840===i)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===i)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===i)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===i)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===i&&null!==(r=t.get("WEBGL_compressed_texture_etc1")))return r.COMPRESSED_RGB_ETC1_WEBGL;if((37808===i||37809===i||37810===i||37811===i||37812===i||37813===i||37814===i||37815===i||37816===i||37817===i||37818===i||37819===i||37820===i||37821===i)&&null!==(r=t.get("WEBGL_compressed_texture_astc")))return i;if((103===i||104===i)&&null!==(r=t.get("EXT_blend_minmax"))){if(103===i)return r.MIN_EXT;if(104===i)return r.MAX_EXT}return 1020===i&&null!==(r=t.get("WEBGL_depth_texture"))?r.UNSIGNED_INT_24_8_WEBGL:0}}}function qe(e,t,i,r){b.call(this),this.type="PerspectiveCamera",this.fov=void 0!==e?e:50,this.zoom=1,this.near=void 0!==i?i:.1,this.far=void 0!==r?r:2e3,this.focus=10,this.aspect=void 0!==t?t:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}function Ze(e){qe.call(this),this.cameras=e||[]}function Qe(e){function t(){if(null!==s&&!0===s.isPresenting){var t=s.getEyeParameters("left"),r=t.renderWidth;t=t.renderHeight,_=e.getPixelRatio(),v=e.getSize(),e.setDrawingBufferSize(2*r,t,1)}else i.enabled&&e.setDrawingBufferSize(v.width,v.height,_)}var i=this,s=null,a=null,c=null,l=new r,u=new r;"undefined"!=typeof window&&"VRFrameData"in window&&(a=new window.VRFrameData,window.addEventListener("vrdisplaypresentchange",t,!1));var d=new r,f=new n,p=new o,m=new qe;m.bounds=new h(0,0,.5,1),m.layers.enable(1);var g=new qe;g.bounds=new h(.5,0,.5,1),g.layers.enable(2);var v,_,y=new Ze([m,g]);y.layers.enable(1),y.layers.enable(2),this.enabled=!1,this.userHeight=1.6,this.getDevice=function(){return s},this.setDevice=function(e){void 0!==e&&(s=e)},this.setPoseTarget=function(e){void 0!==e&&(c=e)},this.getCamera=function(e){if(null===s)return e;s.depthNear=e.near,s.depthFar=e.far,s.getFrameData(a);var t=s.stageParameters;t?l.fromArray(t.sittingToStandingTransform):l.makeTranslation(0,i.userHeight,0),t=a.pose;var r=null!==c?c:e;return r.matrix.copy(l),r.matrix.decompose(r.position,r.quaternion,r.scale),null!==t.orientation&&(f.fromArray(t.orientation),r.quaternion.multiply(f)),null!==t.position&&(f.setFromRotationMatrix(l),p.fromArray(t.position),p.applyQuaternion(f),r.position.add(p)),r.updateMatrixWorld(),!1===s.isPresenting?e:(m.near=e.near,g.near=e.near,m.far=e.far,g.far=e.far,y.matrixWorld.copy(e.matrixWorld),y.matrixWorldInverse.copy(e.matrixWorldInverse),m.matrixWorldInverse.fromArray(a.leftViewMatrix),g.matrixWorldInverse.fromArray(a.rightViewMatrix),u.getInverse(l),m.matrixWorldInverse.multiply(u),g.matrixWorldInverse.multiply(u),null!==(e=r.parent)&&(d.getInverse(e.matrixWorld),m.matrixWorldInverse.multiply(d),g.matrixWorldInverse.multiply(d)),m.matrixWorld.getInverse(m.matrixWorldInverse),g.matrixWorld.getInverse(g.matrixWorldInverse),m.projectionMatrix.fromArray(a.leftProjectionMatrix),g.projectionMatrix.fromArray(a.rightProjectionMatrix),y.projectionMatrix.copy(m.projectionMatrix),(e=s.getLayers()).length&&(null!==(e=e[0]).leftBounds&&4===e.leftBounds.length&&m.bounds.fromArray(e.leftBounds),null!==e.rightBounds&&4===e.rightBounds.length&&g.bounds.fromArray(e.rightBounds)),y)},this.getStandingMatrix=function(){return l},this.submitFrame=function(){null!==s&&!0===s.isPresenting&&s.submitFrame()},this.dispose=function(){"undefined"!=typeof window&&window.removeEventListener("vrdisplaypresentchange",t)}}function Je(e){function t(){(R=new function(e){var t={};return{get:function(i){if(void 0!==t[i])return t[i];switch(i){case"WEBGL_depth_texture":var r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=e.getExtension(i)}return null===r&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),t[i]=r}}}(Ee)).get("WEBGL_depth_texture"),R.get("OES_texture_float"),R.get("OES_texture_float_linear"),R.get("OES_texture_half_float"),R.get("OES_texture_half_float_linear"),R.get("OES_standard_derivatives"),R.get("OES_element_index_uint"),R.get("ANGLE_instanced_arrays"),K=new Ke(Ee,R),I=new function(e,t,i){function r(t){if("highp"===t){if(0<e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision&&0<e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision)return"highp";t="mediump"}return"mediump"===t&&0<e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision&&0<e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision?"mediump":"lowp"}var n,o=void 0!==i.precision?i.precision:"highp",s=r(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s),i=!0===i.logarithmicDepthBuffer,s=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);var a=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_TEXTURE_SIZE),c=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),l=e.getParameter(e.MAX_VERTEX_ATTRIBS),u=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),d=e.getParameter(e.MAX_VARYING_VECTORS),f=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),p=0<a,m=!!t.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==n)return n;var i=t.get("EXT_texture_filter_anisotropic");return n=null!==i?e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:r,precision:o,logarithmicDepthBuffer:i,maxTextures:s,maxVertexTextures:a,maxTextureSize:h,maxCubemapSize:c,maxAttributes:l,maxVertexUniforms:u,maxVaryings:d,maxFragmentUniforms:f,vertexTextures:p,floatFragmentTextures:m,floatVertexTextures:p&&m}}(Ee,R,e),(L=new function(e,t,i){function r(t,i,r){var n=new Uint8Array(4),o=e.createTexture();for(e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST),t=0;t<r;t++)e.texImage2D(i+t,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,n);return o}function n(t){!0!==y[t]&&(e.enable(t),y[t]=!0)}function o(t){!1!==y[t]&&(e.disable(t),y[t]=!1)}function s(t,r,s,a,h,c,l,u){if(0!==t?n(e.BLEND):o(e.BLEND),5!==t){if(t!==M||u!==C)switch(t){case 2:u?(e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE,e.ONE,e.ONE)):(e.blendEquation(e.FUNC_ADD),e.blendFunc(e.SRC_ALPHA,e.ONE));break;case 3:u?(e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ZERO,e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ONE_MINUS_SRC_ALPHA)):(e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR));break;case 4:u?(e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ZERO,e.SRC_COLOR,e.ZERO,e.SRC_ALPHA)):(e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ZERO,e.SRC_COLOR));break;default:u?(e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)):(e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA))}P=A=S=w=T=E=null}else h=h||r,c=c||s,l=l||a,r===E&&h===S||(e.blendEquationSeparate(i.convert(r),i.convert(h)),E=r,S=h),s===T&&a===w&&c===A&&l===P||(e.blendFuncSeparate(i.convert(s),i.convert(a),i.convert(c),i.convert(l)),T=s,w=a,A=c,P=l);M=t,C=u}function a(t){D!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),D=t)}function c(t){0!==t?(n(e.CULL_FACE),t!==R&&(1===t?e.cullFace(e.BACK):2===t?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):o(e.CULL_FACE),R=t}function l(t,i,r){t?(n(e.POLYGON_OFFSET_FILL),(L!==i||O!==r)&&(e.polygonOffset(i,r),L=i,O=r)):o(e.POLYGON_OFFSET_FILL)}function u(t){void 0===t&&(t=e.TEXTURE0+B-1),N!==t&&(e.activeTexture(t),N=t)}var d=new function(){var t=!1,i=new h,r=null,n=new h(0,0,0,0);return{setMask:function(i){r===i||t||(e.colorMask(i,i,i,i),r=i)},setLocked:function(e){t=e},setClear:function(t,r,o,s,a){!0===a&&(t*=s,r*=s,o*=s),i.set(t,r,o,s),!1===n.equals(i)&&(e.clearColor(t,r,o,s),n.copy(i))},reset:function(){t=!1,r=null,n.set(-1,0,0,0)}}},f=new function(){var t=!1,i=null,r=null,s=null;return{setTest:function(t){t?n(e.DEPTH_TEST):o(e.DEPTH_TEST)},setMask:function(r){i===r||t||(e.depthMask(r),i=r)},setFunc:function(t){if(r!==t){if(t)switch(t){case 0:e.depthFunc(e.NEVER);break;case 1:e.depthFunc(e.ALWAYS);break;case 2:e.depthFunc(e.LESS);break;case 3:e.depthFunc(e.LEQUAL);break;case 4:e.depthFunc(e.EQUAL);break;case 5:e.depthFunc(e.GEQUAL);break;case 6:e.depthFunc(e.GREATER);break;case 7:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}else e.depthFunc(e.LEQUAL);r=t}},setLocked:function(e){t=e},setClear:function(t){s!==t&&(e.clearDepth(t),s=t)},reset:function(){t=!1,s=r=i=null}}},p=new function(){var t=!1,i=null,r=null,s=null,a=null,h=null,c=null,l=null,u=null;return{setTest:function(t){t?n(e.STENCIL_TEST):o(e.STENCIL_TEST)},setMask:function(r){i===r||t||(e.stencilMask(r),i=r)},setFunc:function(t,i,n){r===t&&s===i&&a===n||(e.stencilFunc(t,i,n),r=t,s=i,a=n)},setOp:function(t,i,r){h===t&&c===i&&l===r||(e.stencilOp(t,i,r),h=t,c=i,l=r)},setLocked:function(e){t=e},setClear:function(t){u!==t&&(e.clearStencil(t),u=t)},reset:function(){t=!1,u=l=c=h=a=s=r=i=null}}},m=e.getParameter(e.MAX_VERTEX_ATTRIBS),g=new Uint8Array(m),v=new Uint8Array(m),_=new Uint8Array(m),y={},x=null,b=null,M=null,E=null,T=null,w=null,S=null,A=null,P=null,C=!1,D=null,R=null,I=null,L=null,O=null,B=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),F=!1;m=0,-1!==(m=e.getParameter(e.VERSION)).indexOf("WebGL")?(m=parseFloat(/^WebGL ([0-9])/.exec(m)[1]),F=1<=m):-1!==m.indexOf("OpenGL ES")&&(m=parseFloat(/^OpenGL ES ([0-9])/.exec(m)[1]),F=2<=m);var N=null,V={},U=new h,z=new h,k={};return k[e.TEXTURE_2D]=r(e.TEXTURE_2D,e.TEXTURE_2D,1),k[e.TEXTURE_CUBE_MAP]=r(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),d.setClear(0,0,0,1),f.setClear(1),p.setClear(0),n(e.DEPTH_TEST),f.setFunc(3),a(!1),c(1),n(e.CULL_FACE),n(e.BLEND),s(1),{buffers:{color:d,depth:f,stencil:p},initAttributes:function(){for(var e=0,t=g.length;e<t;e++)g[e]=0},enableAttribute:function(i){g[i]=1,0===v[i]&&(e.enableVertexAttribArray(i),v[i]=1),0!==_[i]&&(t.get("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(i,0),_[i]=0)},enableAttributeAndDivisor:function(i,r){g[i]=1,0===v[i]&&(e.enableVertexAttribArray(i),v[i]=1),_[i]!==r&&(t.get("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(i,r),_[i]=r)},disableUnusedAttributes:function(){for(var t=0,i=v.length;t!==i;++t)v[t]!==g[t]&&(e.disableVertexAttribArray(t),v[t]=0)},enable:n,disable:o,getCompressedTextureFormats:function(){if(null===x&&(x=[],t.get("WEBGL_compressed_texture_pvrtc")||t.get("WEBGL_compressed_texture_s3tc")||t.get("WEBGL_compressed_texture_etc1")||t.get("WEBGL_compressed_texture_astc")))for(var i=e.getParameter(e.COMPRESSED_TEXTURE_FORMATS),r=0;r<i.length;r++)x.push(i[r]);return x},useProgram:function(t){return b!==t&&(e.useProgram(t),b=t,!0)},setBlending:s,setMaterial:function(t,i){2===t.side?o(e.CULL_FACE):n(e.CULL_FACE);var r=1===t.side;i&&(r=!r),a(r),!0===t.transparent?s(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha):s(0),f.setFunc(t.depthFunc),f.setTest(t.depthTest),f.setMask(t.depthWrite),d.setMask(t.colorWrite),l(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits)},setFlipSided:a,setCullFace:c,setLineWidth:function(t){t!==I&&(F&&e.lineWidth(t),I=t)},setPolygonOffset:l,setScissorTest:function(t){t?n(e.SCISSOR_TEST):o(e.SCISSOR_TEST)},activeTexture:u,bindTexture:function(t,i){null===N&&u();var r=V[N];void 0===r&&(r={type:void 0,texture:void 0},V[N]=r),r.type===t&&r.texture===i||(e.bindTexture(t,i||k[t]),r.type=t,r.texture=i)},compressedTexImage2D:function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function(t){!1===U.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),U.copy(t))},viewport:function(t){!1===z.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),z.copy(t))},reset:function(){for(var t=0;t<v.length;t++)1===v[t]&&(e.disableVertexAttribArray(t),v[t]=0);y={},N=x=null,V={},R=D=M=b=null,d.reset(),f.reset(),p.reset()}}}(Ee,R,K)).scissor(he.copy(me).multiplyScalar(fe)),L.viewport(ae.copy(pe).multiplyScalar(fe)),O=new function(e){var t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(i,r,n){switch(n=n||1,t.calls++,r){case e.TRIANGLES:t.triangles+=i/3*n;break;case e.TRIANGLE_STRIP:case e.TRIANGLE_FAN:t.triangles+=n*(i-2);break;case e.LINES:t.lines+=i/2*n;break;case e.LINE_STRIP:t.lines+=n*(i-1);break;case e.LINE_LOOP:t.lines+=n*i;break;case e.POINTS:t.points+=n*i;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",r)}}}}(Ee),B=new function(){var e=new WeakMap;return{get:function(t){var i=e.get(t);return void 0===i&&(i={},e.set(t,i)),i},remove:function(t){e.delete(t)},update:function(t,i,r){e.get(t)[i]=r},dispose:function(){e=new WeakMap}}},F=new function(e,t,i,r,n,o,s){function a(e,t){if(e.width>t||e.height>t){if("data"in e)return void console.warn("THREE.WebGLRenderer: image in DataTexture is too big ("+e.width+"x"+e.height+").");t/=Math.max(e.width,e.height);var i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return i.width=Math.floor(e.width*t),i.height=Math.floor(e.height*t),i.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,i.width,i.height),console.warn("THREE.WebGLRenderer: image is too big ("+e.width+"x"+e.height+"). Resized to "+i.width+"x"+i.height,e),i}return e}function h(e){return An.isPowerOfTwo(e.width)&&An.isPowerOfTwo(e.height)}function c(e,t){return e.generateMipmaps&&t&&1003!==e.minFilter&&1006!==e.minFilter}function l(t,i,n,o){e.generateMipmap(t),r.get(i).__maxMipLevel=Math.log(Math.max(n,o))*Math.LOG2E}function u(t){return 1003===t||1004===t||1005===t?e.NEAREST:e.LINEAR}function d(t){(t=t.target).removeEventListener("dispose",d);e:{var i=r.get(t);if(t.image&&i.__image__webglTextureCube)e.deleteTexture(i.__image__webglTextureCube);else{if(void 0===i.__webglInit)break e;e.deleteTexture(i.__webglTexture)}r.remove(t)}t.isVideoTexture&&delete x[t.id],s.memory.textures--}function f(t){(t=t.target).removeEventListener("dispose",f);var i=r.get(t),n=r.get(t.texture);if(t){if(void 0!==n.__webglTexture&&e.deleteTexture(n.__webglTexture),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLRenderTargetCube)for(n=0;6>n;n++)e.deleteFramebuffer(i.__webglFramebuffer[n]),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer[n]);else e.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer);r.remove(t.texture),r.remove(t)}s.memory.textures--}function p(t,u){var f=r.get(t);if(t.isVideoTexture){var p=t.id,g=s.render.frame;x[p]!==g&&(x[p]=g,t.update())}if(0<t.version&&f.__version!==t.version)if(void 0===(p=t.image))console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",t);else{if(!1!==p.complete){void 0===f.__webglInit&&(f.__webglInit=!0,t.addEventListener("dispose",d),f.__webglTexture=e.createTexture(),s.memory.textures++),i.activeTexture(e.TEXTURE0+u),i.bindTexture(e.TEXTURE_2D,f.__webglTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,t.unpackAlignment),u=a(t.image,n.maxTextureSize),(1001!==t.wrapS||1001!==t.wrapT||1003!==t.minFilter&&1006!==t.minFilter)&&!1===h(u)&&(u instanceof HTMLImageElement||u instanceof HTMLCanvasElement||u instanceof ImageBitmap)&&(void 0===_&&(_=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),_.width=An.floorPowerOfTwo(u.width),_.height=An.floorPowerOfTwo(u.height),_.getContext("2d").drawImage(u,0,0,_.width,_.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+u.width+"x"+u.height+"). Resized to "+_.width+"x"+_.height,u),u=_),p=h(u),g=o.convert(t.format);var v=o.convert(t.type);m(e.TEXTURE_2D,t,p);var b=t.mipmaps;if(t.isDepthTexture){var M=e.DEPTH_COMPONENT;if(1015===t.type){if(!y)throw Error("Float Depth Texture only supported in WebGL2.0");M=e.DEPTH_COMPONENT32F}else y&&(M=e.DEPTH_COMPONENT16);1026===t.format&&M===e.DEPTH_COMPONENT&&1012!==t.type&&1014!==t.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),t.type=1012,v=o.convert(t.type)),1027===t.format&&(M=e.DEPTH_STENCIL,1020!==t.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),t.type=1020,v=o.convert(t.type))),i.texImage2D(e.TEXTURE_2D,0,M,u.width,u.height,0,g,v,null)}else if(t.isDataTexture)if(0<b.length&&p){for(var E=0,T=b.length;E<T;E++)M=b[E],i.texImage2D(e.TEXTURE_2D,E,g,M.width,M.height,0,g,v,M.data);t.generateMipmaps=!1,f.__maxMipLevel=b.length-1}else i.texImage2D(e.TEXTURE_2D,0,g,u.width,u.height,0,g,v,u.data),f.__maxMipLevel=0;else if(t.isCompressedTexture){for(E=0,T=b.length;E<T;E++)M=b[E],1023!==t.format&&1022!==t.format?-1<i.getCompressedTextureFormats().indexOf(g)?i.compressedTexImage2D(e.TEXTURE_2D,E,g,M.width,M.height,0,M.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.texImage2D(e.TEXTURE_2D,E,g,M.width,M.height,0,g,v,M.data);f.__maxMipLevel=b.length-1}else if(0<b.length&&p){for(E=0,T=b.length;E<T;E++)M=b[E],i.texImage2D(e.TEXTURE_2D,E,g,g,v,M);t.generateMipmaps=!1,f.__maxMipLevel=b.length-1}else i.texImage2D(e.TEXTURE_2D,0,g,g,v,u),f.__maxMipLevel=0;return c(t,p)&&l(e.TEXTURE_2D,t,u.width,u.height),f.__version=t.version,void(t.onUpdate&&t.onUpdate(t))}console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",t)}i.activeTexture(e.TEXTURE0+u),i.bindTexture(e.TEXTURE_2D,f.__webglTexture)}function m(i,s,a){a?(e.texParameteri(i,e.TEXTURE_WRAP_S,o.convert(s.wrapS)),e.texParameteri(i,e.TEXTURE_WRAP_T,o.convert(s.wrapT)),e.texParameteri(i,e.TEXTURE_MAG_FILTER,o.convert(s.magFilter)),e.texParameteri(i,e.TEXTURE_MIN_FILTER,o.convert(s.minFilter))):(e.texParameteri(i,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(i,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),1001===s.wrapS&&1001===s.wrapT||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",s),e.texParameteri(i,e.TEXTURE_MAG_FILTER,u(s.magFilter)),e.texParameteri(i,e.TEXTURE_MIN_FILTER,u(s.minFilter)),1003!==s.minFilter&&1006!==s.minFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",s)),!(a=t.get("EXT_texture_filter_anisotropic"))||1015===s.type&&null===t.get("OES_texture_float_linear")||1016===s.type&&null===t.get("OES_texture_half_float_linear")||!(1<s.anisotropy||r.get(s).__currentAnisotropy)||(e.texParameterf(i,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,n.getMaxAnisotropy())),r.get(s).__currentAnisotropy=s.anisotropy)}function g(t,n,s,a){var h=o.convert(n.texture.format),c=o.convert(n.texture.type);i.texImage2D(a,0,h,n.width,n.height,0,h,c,null),e.bindFramebuffer(e.FRAMEBUFFER,t),e.framebufferTexture2D(e.FRAMEBUFFER,s,a,r.get(n.texture).__webglTexture,0),e.bindFramebuffer(e.FRAMEBUFFER,null)}function v(t,i){e.bindRenderbuffer(e.RENDERBUFFER,t),i.depthBuffer&&!i.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,i.width,i.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)):i.depthBuffer&&i.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,i.width,i.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)):e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,i.width,i.height),e.bindRenderbuffer(e.RENDERBUFFER,null)}var _,y="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext,x={};this.setTexture2D=p,this.setTextureCube=function(t,u){var f=r.get(t);if(6===t.image.length)if(0<t.version&&f.__version!==t.version){f.__image__webglTextureCube||(t.addEventListener("dispose",d),f.__image__webglTextureCube=e.createTexture(),s.memory.textures++),i.activeTexture(e.TEXTURE0+u),i.bindTexture(e.TEXTURE_CUBE_MAP,f.__image__webglTextureCube),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t.flipY),u=t&&t.isCompressedTexture;for(var p=t.image[0]&&t.image[0].isDataTexture,g=[],v=0;6>v;v++)g[v]=u||p?p?t.image[v].image:t.image[v]:a(t.image[v],n.maxCubemapSize);var _=g[0],y=h(_),x=o.convert(t.format),b=o.convert(t.type);for(m(e.TEXTURE_CUBE_MAP,t,y),v=0;6>v;v++)if(u)for(var M,E=g[v].mipmaps,T=0,w=E.length;T<w;T++)M=E[T],1023!==t.format&&1022!==t.format?-1<i.getCompressedTextureFormats().indexOf(x)?i.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+v,T,x,M.width,M.height,0,M.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+v,T,x,M.width,M.height,0,x,b,M.data);else p?i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,x,g[v].width,g[v].height,0,x,b,g[v].data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,x,x,b,g[v]);f.__maxMipLevel=u?E.length-1:0,c(t,y)&&l(e.TEXTURE_CUBE_MAP,t,_.width,_.height),f.__version=t.version,t.onUpdate&&t.onUpdate(t)}else i.activeTexture(e.TEXTURE0+u),i.bindTexture(e.TEXTURE_CUBE_MAP,f.__image__webglTextureCube)},this.setTextureCubeDynamic=function(t,n){i.activeTexture(e.TEXTURE0+n),i.bindTexture(e.TEXTURE_CUBE_MAP,r.get(t).__webglTexture)},this.setupRenderTarget=function(t){var n=r.get(t),o=r.get(t.texture);t.addEventListener("dispose",f),o.__webglTexture=e.createTexture(),s.memory.textures++;var a=!0===t.isWebGLRenderTargetCube,u=h(t);if(a){n.__webglFramebuffer=[];for(var d=0;6>d;d++)n.__webglFramebuffer[d]=e.createFramebuffer()}else n.__webglFramebuffer=e.createFramebuffer();if(a){for(i.bindTexture(e.TEXTURE_CUBE_MAP,o.__webglTexture),m(e.TEXTURE_CUBE_MAP,t.texture,u),d=0;6>d;d++)g(n.__webglFramebuffer[d],t,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+d);c(t.texture,u)&&l(e.TEXTURE_CUBE_MAP,t.texture,t.width,t.height),i.bindTexture(e.TEXTURE_CUBE_MAP,null)}else i.bindTexture(e.TEXTURE_2D,o.__webglTexture),m(e.TEXTURE_2D,t.texture,u),g(n.__webglFramebuffer,t,e.COLOR_ATTACHMENT0,e.TEXTURE_2D),c(t.texture,u)&&l(e.TEXTURE_2D,t.texture,t.width,t.height),i.bindTexture(e.TEXTURE_2D,null);if(t.depthBuffer){if(n=r.get(t),o=!0===t.isWebGLRenderTargetCube,t.depthTexture){if(o)throw Error("target.depthTexture not supported in Cube render targets");if(t&&t.isWebGLRenderTargetCube)throw Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer),!t.depthTexture||!t.depthTexture.isDepthTexture)throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");if(r.get(t.depthTexture).__webglTexture&&t.depthTexture.image.width===t.width&&t.depthTexture.image.height===t.height||(t.depthTexture.image.width=t.width,t.depthTexture.image.height=t.height,t.depthTexture.needsUpdate=!0),p(t.depthTexture,0),n=r.get(t.depthTexture).__webglTexture,1026===t.depthTexture.format)e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,n,0);else{if(1027!==t.depthTexture.format)throw Error("Unknown depthTexture format");e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,n,0)}}else if(o)for(n.__webglDepthbuffer=[],o=0;6>o;o++)e.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer[o]),n.__webglDepthbuffer[o]=e.createRenderbuffer(),v(n.__webglDepthbuffer[o],t);else e.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer),n.__webglDepthbuffer=e.createRenderbuffer(),v(n.__webglDepthbuffer,t);e.bindFramebuffer(e.FRAMEBUFFER,null)}},this.updateRenderTargetMipmap=function(t){var n=t.texture,o=h(t);if(c(n,o)){o=t.isWebGLRenderTargetCube?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D;var s=r.get(n).__webglTexture;i.bindTexture(o,s),l(o,n,t.width,t.height),i.bindTexture(o,null)}}}(Ee,R,L,B,I,K,O),N=new v(Ee),V=new Q(Ee,N,O),U=new function(e,t){var i={};return{update:function(r){var n=t.render.frame,o=r.geometry,s=e.get(r,o);return i[s.id]!==n&&(o.isGeometry&&s.updateFromObject(r),e.update(s),i[s.id]=n),s},dispose:function(){i={}}}}(V,O),H=new function(e){var t={},i=new Float32Array(8);return{update:function(r,n,o,s){var a=r.morphTargetInfluences,h=a.length;if(void 0===(r=t[n.id])){r=[];for(var c=0;c<h;c++)r[c]=[c,0];t[n.id]=r}var l=o.morphTargets&&n.morphAttributes.position;for(o=o.morphNormals&&n.morphAttributes.normal,c=0;c<h;c++){var u=r[c];0!==u[1]&&(l&&n.removeAttribute("morphTarget"+c),o&&n.removeAttribute("morphNormal"+c))}for(c=0;c<h;c++)(u=r[c])[0]=c,u[1]=a[c];for(r.sort(J),c=0;8>c;c++)(u=r[c])&&(a=u[0],h=u[1])?(l&&n.addAttribute("morphTarget"+c,l[a]),o&&n.addAttribute("morphNormal"+c,o[a]),i[c]=h):i[c]=0;s.getUniforms().setValue(e,"morphTargetInfluences",i)}}}(Ee),z=new function(e,t,i){function r(e,t){if(e)e.isTexture?i=e.encoding:e.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),i=e.texture.encoding);else var i=3e3;return 3e3===i&&t&&(i=3007),i}var n=[],o={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow"},s="precision supportsVertexTextures map mapEncoding envMap envMapMode envMapEncoding lightMap aoMap emissiveMap emissiveMapEncoding bumpMap normalMap displacementMap specularMap roughnessMap metalnessMap gradientMap alphaMap combine vertexColors fog useFog fogExp flatShading sizeAttenuation logarithmicDepthBuffer skinning maxBones useVertexTexture morphTargets morphNormals maxMorphTargets maxMorphNormals premultipliedAlpha numDirLights numPointLights numSpotLights numHemiLights numRectAreaLights shadowMapEnabled shadowMapType toneMapping physicallyCorrectLights alphaTest doubleSided flipSided numClippingPlanes numClipIntersection depthPacking dithering".split(" ");this.getParameters=function(t,n,s,a,h,c,l){var u=o[t.type];if(l.isSkinnedMesh){var d=l.skeleton.bones;if(i.floatVertexTextures)d=1024;else{var f=Math.min(Math.floor((i.maxVertexUniforms-20)/4),d.length);f<d.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+d.length+" bones. This GPU supports "+f+"."),d=0):d=f}}else d=0;f=i.precision,null!==t.precision&&(f=i.getMaxPrecision(t.precision))!==t.precision&&console.warn("THREE.WebGLProgram.getParameters:",t.precision,"not supported, using",f,"instead.");var p=e.getRenderTarget();return{shaderID:u,precision:f,supportsVertexTextures:i.vertexTextures,outputEncoding:r(p?p.texture:null,e.gammaOutput),map:!!t.map,mapEncoding:r(t.map,e.gammaInput),envMap:!!t.envMap,envMapMode:t.envMap&&t.envMap.mapping,envMapEncoding:r(t.envMap,e.gammaInput),envMapCubeUV:!!t.envMap&&(306===t.envMap.mapping||307===t.envMap.mapping),lightMap:!!t.lightMap,aoMap:!!t.aoMap,emissiveMap:!!t.emissiveMap,emissiveMapEncoding:r(t.emissiveMap,e.gammaInput),bumpMap:!!t.bumpMap,normalMap:!!t.normalMap,displacementMap:!!t.displacementMap,roughnessMap:!!t.roughnessMap,metalnessMap:!!t.metalnessMap,specularMap:!!t.specularMap,alphaMap:!!t.alphaMap,gradientMap:!!t.gradientMap,combine:t.combine,vertexColors:t.vertexColors,fog:!!a,useFog:t.fog,fogExp:a&&a.isFogExp2,flatShading:t.flatShading,sizeAttenuation:t.sizeAttenuation,logarithmicDepthBuffer:i.logarithmicDepthBuffer,skinning:t.skinning&&0<d,maxBones:d,useVertexTexture:i.floatVertexTextures,morphTargets:t.morphTargets,morphNormals:t.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:n.directional.length,numPointLights:n.point.length,numSpotLights:n.spot.length,numRectAreaLights:n.rectArea.length,numHemiLights:n.hemi.length,numClippingPlanes:h,numClipIntersection:c,dithering:t.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.receiveShadow&&0<s.length,shadowMapType:e.shadowMap.type,toneMapping:e.toneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:t.premultipliedAlpha,alphaTest:t.alphaTest,doubleSided:2===t.side,flipSided:1===t.side,depthPacking:void 0!==t.depthPacking&&t.depthPacking}},this.getProgramCode=function(t,i){var r=[];if(i.shaderID?r.push(i.shaderID):(r.push(t.fragmentShader),r.push(t.vertexShader)),void 0!==t.defines)for(var n in t.defines)r.push(n),r.push(t.defines[n]);for(n=0;n<s.length;n++)r.push(i[s[n]]);return r.push(t.onBeforeCompile.toString()),r.push(e.gammaOutput),r.join()},this.acquireProgram=function(i,r,o,s){for(var a,h=0,c=n.length;h<c;h++){var l=n[h];if(l.code===s){++(a=l).usedTimes;break}}return void 0===a&&(a=new Ne(e,t,s,i,r,o),n.push(a)),a},this.releaseProgram=function(e){if(0==--e.usedTimes){var t=n.indexOf(e);n[t]=n[n.length-1],n.pop(),e.destroy()}},this.programs=n}($,R,I),k=new ze,G=new Ge,W=new q($,L,V,S),j=new function(e,t,i){var r;this.setMode=function(e){r=e},this.render=function(t,n){e.drawArrays(r,t,n),i.update(n,r)},this.renderInstances=function(e,n,o){var s=t.get("ANGLE_instanced_arrays");if(null===s)console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");else{var a=e.attributes.position;a.isInterleavedBufferAttribute?(o=a.data.count,s.drawArraysInstancedANGLE(r,0,o,e.maxInstancedCount)):s.drawArraysInstancedANGLE(r,n,o,e.maxInstancedCount),i.update(o,r,e.maxInstancedCount)}}}(Ee,R,O),Y=new function(e,t,i){var r,n,o;this.setMode=function(e){r=e},this.setIndex=function(e){n=e.type,o=e.bytesPerElement},this.render=function(t,s){e.drawElements(r,s,n,t*o),i.update(s,r)},this.renderInstances=function(e,s,a){var h=t.get("ANGLE_instanced_arrays");null===h?console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."):(h.drawElementsInstancedANGLE(r,a,n,s*o,e.maxInstancedCount),i.update(a,r,e.maxInstancedCount))}}(Ee,R,O),X=new Xe($,Ee,L,F,I),O.programs=z.programs,$.context=Ee,$.capabilities=I,$.extensions=R,$.properties=B,$.renderLists=k,$.state=L,$.info=O}function i(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),ee=!0}function n(){console.log("THREE.WebGLRenderer: Context Restored."),ee=!1,t()}function s(e){(e=e.target).removeEventListener("dispose",s),a(e),B.remove(e)}function a(e){var t=B.get(e).program;e.program=void 0,void 0!==t&&z.releaseProgram(t)}function c(){var e=Te.getDevice();e&&e.isPresenting?e.requestAnimationFrame(l):window.requestAnimationFrame(l)}function l(e){!1!==Se&&(Ae(e),c())}function d(e,t,i,r){for(var n=0,o=e.length;n<o;n++){var s=e[n],a=s.object,h=s.geometry,c=void 0===r?s.material:r;if(s=s.group,i.isArrayCamera){se=i;for(var l=i.cameras,u=0,d=l.length;u<d;u++){var p=l[u];if(a.layers.test(p.layers)){var m=p.bounds;L.viewport(ae.set(m.x*ue,m.y*de,m.z*ue,m.w*de).multiplyScalar(fe)),f(a,t,p,h,c,s)}}}else se=null,f(a,t,i,h,c,s)}}function f(e,t,i,r,n,o){if(e.onBeforeRender($,t,i,r,n,o),D=G.get(t,se||i),e.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),e.isImmediateRenderObject){var s=e.isMesh&&0>e.matrixWorld.determinant();L.setMaterial(n,s),s=g(i,t.fog,n,e),ne="",function(e,t,i){e.render(function(e){$.renderBufferImmediate(e,t,i)})}(e,s,n)}else $.renderBufferDirect(i,t.fog,r,n,e,o);e.onAfterRender($,t,i,r,n,o),D=G.get(t,se||i)}function p(e,t,i){var r=B.get(e),n=D.state.lights;i=z.getParameters(e,n.state,D.state.shadowsArray,t,_e.numPlanes,_e.numIntersection,i);var o=z.getProgramCode(e,i),h=r.program,c=!0;if(void 0===h)e.addEventListener("dispose",s);else if(h.code!==o)a(e);else{if(r.lightsHash!==n.state.hash)B.update(e,"lightsHash",n.state.hash);else if(void 0!==i.shaderID)return;c=!1}if(c&&(i.shaderID?(h=Ln[i.shaderID],r.shader={name:e.type,uniforms:Dn.clone(h.uniforms),vertexShader:h.vertexShader,fragmentShader:h.fragmentShader}):r.shader={name:e.type,uniforms:e.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader},e.onBeforeCompile(r.shader,$),h=z.acquireProgram(e,r.shader,i,o),r.program=h,e.program=h),i=h.getAttributes(),e.morphTargets)for(o=e.numSupportedMorphTargets=0;o<$.maxMorphTargets;o++)0<=i["morphTarget"+o]&&e.numSupportedMorphTargets++;if(e.morphNormals)for(o=e.numSupportedMorphNormals=0;o<$.maxMorphNormals;o++)0<=i["morphNormal"+o]&&e.numSupportedMorphNormals++;i=r.shader.uniforms,(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(r.numClippingPlanes=_e.numPlanes,r.numIntersection=_e.numIntersection,i.clippingPlanes=_e.uniform),r.fog=t,r.lightsHash=n.state.hash,e.lights&&(i.ambientLightColor.value=n.state.ambient,i.directionalLights.value=n.state.directional,i.spotLights.value=n.state.spot,i.rectAreaLights.value=n.state.rectArea,i.pointLights.value=n.state.point,i.hemisphereLights.value=n.state.hemi,i.directionalShadowMap.value=n.state.directionalShadowMap,i.directionalShadowMatrix.value=n.state.directionalShadowMatrix,i.spotShadowMap.value=n.state.spotShadowMap,i.spotShadowMatrix.value=n.state.spotShadowMatrix,i.pointShadowMap.value=n.state.pointShadowMap,i.pointShadowMatrix.value=n.state.pointShadowMatrix),e=r.program.getUniforms(),e=Pe.seqWithValue(e.seq,i),r.uniformsList=e}function g(e,t,i,r){le=0;var n=B.get(i),o=D.state.lights;ye&&(xe||e!==oe)&&_e.setState(i.clippingPlanes,i.clipIntersection,i.clipShadows,e,n,e===oe&&i.id===re),!1===i.needsUpdate&&(void 0===n.program?i.needsUpdate=!0:i.fog&&n.fog!==t?i.needsUpdate=!0:i.lights&&n.lightsHash!==o.state.hash?i.needsUpdate=!0:void 0===n.numClippingPlanes||n.numClippingPlanes===_e.numPlanes&&n.numIntersection===_e.numIntersection||(i.needsUpdate=!0)),i.needsUpdate&&(p(i,t,r),i.needsUpdate=!1);var s=!1,a=!1,h=!1,c=(o=n.program).getUniforms(),l=n.shader.uniforms;if(L.useProgram(o.program)&&(h=a=s=!0),i.id!==re&&(re=i.id,a=!0),(s||e!==oe)&&(c.setValue(Ee,"projectionMatrix",e.projectionMatrix),I.logarithmicDepthBuffer&&c.setValue(Ee,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),oe!==(se||e)&&(oe=se||e,h=a=!0),(i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.envMap)&&(void 0!==(s=c.map.cameraPosition)&&s.setValue(Ee,Me.setFromMatrixPosition(e.matrixWorld))),(i.isMeshPhongMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.skinning)&&c.setValue(Ee,"viewMatrix",e.matrixWorldInverse)),i.skinning&&(c.setOptional(Ee,r,"bindMatrix"),c.setOptional(Ee,r,"bindMatrixInverse"),e=r.skeleton))if(s=e.bones,I.floatVertexTextures){if(void 0===e.boneTexture){s=Math.sqrt(4*s.length),s=An.ceilPowerOfTwo(s),s=Math.max(s,4);var d=new Float32Array(s*s*4);d.set(e.boneMatrices);var f=new u(d,s,s,1023,1015);f.needsUpdate=!0,e.boneMatrices=d,e.boneTexture=f,e.boneTextureSize=s}c.setValue(Ee,"boneTexture",e.boneTexture),c.setValue(Ee,"boneTextureSize",e.boneTextureSize)}else c.setOptional(Ee,e,"boneMatrices");return a&&(c.setValue(Ee,"toneMappingExposure",$.toneMappingExposure),c.setValue(Ee,"toneMappingWhitePoint",$.toneMappingWhitePoint),i.lights&&(a=h,l.ambientLightColor.needsUpdate=a,l.directionalLights.needsUpdate=a,l.pointLights.needsUpdate=a,l.spotLights.needsUpdate=a,l.rectAreaLights.needsUpdate=a,l.hemisphereLights.needsUpdate=a),t&&i.fog&&(l.fogColor.value=t.color,t.isFog?(l.fogNear.value=t.near,l.fogFar.value=t.far):t.isFogExp2&&(l.fogDensity.value=t.density)),i.isMeshBasicMaterial?_(l,i):i.isMeshLambertMaterial?(_(l,i),i.emissiveMap&&(l.emissiveMap.value=i.emissiveMap)):i.isMeshPhongMaterial?(_(l,i),i.isMeshToonMaterial?(y(l,i),i.gradientMap&&(l.gradientMap.value=i.gradientMap)):y(l,i)):i.isMeshStandardMaterial?(_(l,i),i.isMeshPhysicalMaterial&&(l.clearCoat.value=i.clearCoat,l.clearCoatRoughness.value=i.clearCoatRoughness),l.roughness.value=i.roughness,l.metalness.value=i.metalness,i.roughnessMap&&(l.roughnessMap.value=i.roughnessMap),i.metalnessMap&&(l.metalnessMap.value=i.metalnessMap),i.emissiveMap&&(l.emissiveMap.value=i.emissiveMap),i.bumpMap&&(l.bumpMap.value=i.bumpMap,l.bumpScale.value=i.bumpScale),i.normalMap&&(l.normalMap.value=i.normalMap,l.normalScale.value.copy(i.normalScale)),i.displacementMap&&(l.displacementMap.value=i.displacementMap,l.displacementScale.value=i.displacementScale,l.displacementBias.value=i.displacementBias),i.envMap&&(l.envMapIntensity.value=i.envMapIntensity)):i.isMeshDepthMaterial?(_(l,i),i.displacementMap&&(l.displacementMap.value=i.displacementMap,l.displacementScale.value=i.displacementScale,l.displacementBias.value=i.displacementBias)):i.isMeshDistanceMaterial?(_(l,i),i.displacementMap&&(l.displacementMap.value=i.displacementMap,l.displacementScale.value=i.displacementScale,l.displacementBias.value=i.displacementBias),l.referencePosition.value.copy(i.referencePosition),l.nearDistance.value=i.nearDistance,l.farDistance.value=i.farDistance):i.isMeshNormalMaterial?(_(l,i),i.bumpMap&&(l.bumpMap.value=i.bumpMap,l.bumpScale.value=i.bumpScale),i.normalMap&&(l.normalMap.value=i.normalMap,l.normalScale.value.copy(i.normalScale)),i.displacementMap&&(l.displacementMap.value=i.displacementMap,l.displacementScale.value=i.displacementScale,l.displacementBias.value=i.displacementBias)):i.isLineBasicMaterial?(l.diffuse.value=i.color,l.opacity.value=i.opacity,i.isLineDashedMaterial&&(l.dashSize.value=i.dashSize,l.totalSize.value=i.dashSize+i.gapSize,l.scale.value=i.scale)):i.isPointsMaterial?(l.diffuse.value=i.color,l.opacity.value=i.opacity,l.size.value=i.size*fe,l.scale.value=.5*de,l.map.value=i.map,null!==i.map&&(!0===i.map.matrixAutoUpdate&&i.map.updateMatrix(),l.uvTransform.value.copy(i.map.matrix))):i.isShadowMaterial&&(l.color.value=i.color,l.opacity.value=i.opacity),void 0!==l.ltc_1&&(l.ltc_1.value=In.LTC_1),void 0!==l.ltc_2&&(l.ltc_2.value=In.LTC_2),Pe.upload(Ee,n.uniformsList,l,$)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Pe.upload(Ee,n.uniformsList,l,$),i.uniformsNeedUpdate=!1),c.setValue(Ee,"modelViewMatrix",r.modelViewMatrix),c.setValue(Ee,"normalMatrix",r.normalMatrix),c.setValue(Ee,"modelMatrix",r.matrixWorld),o}function _(e,t){if(e.opacity.value=t.opacity,t.color&&(e.diffuse.value=t.color),t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity),t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.specularMap&&(e.specularMap.value=t.specularMap),t.envMap&&(e.envMap.value=t.envMap,e.flipEnvMap.value=t.envMap&&t.envMap.isCubeTexture?-1:1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio,e.maxMipLevel.value=B.get(t.envMap).__maxMipLevel),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity),t.map)var i=t.map;else t.specularMap?i=t.specularMap:t.displacementMap?i=t.displacementMap:t.normalMap?i=t.normalMap:t.bumpMap?i=t.bumpMap:t.roughnessMap?i=t.roughnessMap:t.metalnessMap?i=t.metalnessMap:t.alphaMap?i=t.alphaMap:t.emissiveMap&&(i=t.emissiveMap);void 0!==i&&(i.isWebGLRenderTarget&&(i=i.texture),!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix))}function y(e,t){e.specular.value=t.specular,e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale)),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}console.log("THREE.WebGLRenderer","92");var x=void 0!==(e=e||{}).canvas?e.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),b=void 0!==e.context?e.context:null,M=void 0!==e.alpha&&e.alpha,E=void 0===e.depth||e.depth,T=void 0===e.stencil||e.stencil,w=void 0!==e.antialias&&e.antialias,S=void 0===e.premultipliedAlpha||e.premultipliedAlpha,A=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,P=void 0!==e.powerPreference?e.powerPreference:"default",C=null,D=null;this.domElement=x,this.context=null,this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.physicallyCorrectLights=this.gammaOutput=this.gammaInput=!1,this.toneMappingWhitePoint=this.toneMappingExposure=this.toneMapping=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var R,I,L,O,B,F,N,V,U,z,k,G,W,H,j,Y,X,K,$=this,ee=!1,te=null,ie=null,re=-1,ne="",oe=null,se=null,ae=new h,he=new h,ce=null,le=0,ue=x.width,de=x.height,fe=1,pe=new h(0,0,ue,de),me=new h(0,0,ue,de),ge=!1,ve=new m,_e=new Z,ye=!1,xe=!1,be=new r,Me=new o;try{M={alpha:M,depth:E,stencil:T,antialias:w,premultipliedAlpha:S,preserveDrawingBuffer:A,powerPreference:P},x.addEventListener("webglcontextlost",i,!1),x.addEventListener("webglcontextrestored",n,!1);var Ee=b||x.getContext("webgl",M)||x.getContext("experimental-webgl",M);if(null===Ee){if(null!==x.getContext("webgl"))throw Error("Error creating WebGL context with your selected attributes.");throw Error("Error creating WebGL context.")}void 0===Ee.getShaderPrecisionFormat&&(Ee.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){console.error("THREE.WebGLRenderer: "+e.message)}t();var Te=new Qe($);this.vr=Te;var we=new je($,U,I.maxTextureSize);this.shadowMap=we,this.getContext=function(){return Ee},this.getContextAttributes=function(){return Ee.getContextAttributes()},this.forceContextLoss=function(){var e=R.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){var e=R.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return fe},this.setPixelRatio=function(e){void 0!==e&&(fe=e,this.setSize(ue,de,!1))},this.getSize=function(){return{width:ue,height:de}},this.setSize=function(e,t,i){var r=Te.getDevice();r&&r.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(ue=e,de=t,x.width=e*fe,x.height=t*fe,!1!==i&&(x.style.width=e+"px",x.style.height=t+"px"),this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(){return{width:ue*fe,height:de*fe}},this.setDrawingBufferSize=function(e,t,i){ue=e,de=t,fe=i,x.width=e*i,x.height=t*i,this.setViewport(0,0,e,t)},this.getCurrentViewport=function(){return ae},this.setViewport=function(e,t,i,r){pe.set(e,de-t-r,i,r),L.viewport(ae.copy(pe).multiplyScalar(fe))},this.setScissor=function(e,t,i,r){me.set(e,de-t-r,i,r),L.scissor(he.copy(me).multiplyScalar(fe))},this.setScissorTest=function(e){L.setScissorTest(ge=e)},this.getClearColor=function(){return W.getClearColor()},this.setClearColor=function(){W.setClearColor.apply(W,arguments)},this.getClearAlpha=function(){return W.getClearAlpha()},this.setClearAlpha=function(){W.setClearAlpha.apply(W,arguments)},this.clear=function(e,t,i){var r=0;(void 0===e||e)&&(r|=Ee.COLOR_BUFFER_BIT),(void 0===t||t)&&(r|=Ee.DEPTH_BUFFER_BIT),(void 0===i||i)&&(r|=Ee.STENCIL_BUFFER_BIT),Ee.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.clearTarget=function(e,t,i,r){this.setRenderTarget(e),this.clear(t,i,r)},this.dispose=function(){x.removeEventListener("webglcontextlost",i,!1),x.removeEventListener("webglcontextrestored",n,!1),k.dispose(),G.dispose(),B.dispose(),U.dispose(),Te.dispose(),Se=!1},this.renderBufferImmediate=function(e,t,i){L.initAttributes();var r=B.get(e);if(e.hasPositions&&!r.position&&(r.position=Ee.createBuffer()),e.hasNormals&&!r.normal&&(r.normal=Ee.createBuffer()),e.hasUvs&&!r.uv&&(r.uv=Ee.createBuffer()),e.hasColors&&!r.color&&(r.color=Ee.createBuffer()),t=t.getAttributes(),e.hasPositions&&(Ee.bindBuffer(Ee.ARRAY_BUFFER,r.position),Ee.bufferData(Ee.ARRAY_BUFFER,e.positionArray,Ee.DYNAMIC_DRAW),L.enableAttribute(t.position),Ee.vertexAttribPointer(t.position,3,Ee.FLOAT,!1,0,0)),e.hasNormals){if(Ee.bindBuffer(Ee.ARRAY_BUFFER,r.normal),!i.isMeshPhongMaterial&&!i.isMeshStandardMaterial&&!i.isMeshNormalMaterial&&!0===i.flatShading)for(var n=0,o=3*e.count;n<o;n+=9){var s=e.normalArray,a=(s[n+0]+s[n+3]+s[n+6])/3,h=(s[n+1]+s[n+4]+s[n+7])/3,c=(s[n+2]+s[n+5]+s[n+8])/3;s[n+0]=a,s[n+1]=h,s[n+2]=c,s[n+3]=a,s[n+4]=h,s[n+5]=c,s[n+6]=a,s[n+7]=h,s[n+8]=c}Ee.bufferData(Ee.ARRAY_BUFFER,e.normalArray,Ee.DYNAMIC_DRAW),L.enableAttribute(t.normal),Ee.vertexAttribPointer(t.normal,3,Ee.FLOAT,!1,0,0)}e.hasUvs&&i.map&&(Ee.bindBuffer(Ee.ARRAY_BUFFER,r.uv),Ee.bufferData(Ee.ARRAY_BUFFER,e.uvArray,Ee.DYNAMIC_DRAW),L.enableAttribute(t.uv),Ee.vertexAttribPointer(t.uv,2,Ee.FLOAT,!1,0,0)),e.hasColors&&0!==i.vertexColors&&(Ee.bindBuffer(Ee.ARRAY_BUFFER,r.color),Ee.bufferData(Ee.ARRAY_BUFFER,e.colorArray,Ee.DYNAMIC_DRAW),L.enableAttribute(t.color),Ee.vertexAttribPointer(t.color,3,Ee.FLOAT,!1,0,0)),L.disableUnusedAttributes(),Ee.drawArrays(Ee.TRIANGLES,0,e.count),e.count=0},this.renderBufferDirect=function(e,t,i,r,n,o){var s=n.isMesh&&0>n.matrixWorld.determinant();L.setMaterial(r,s);var a=g(e,t,r,n),h=!1;(e=i.id+"_"+a.id+"_"+(!0===r.wireframe))!==ne&&(ne=e,h=!0),n.morphTargetInfluences&&(H.update(n,i,r,a),h=!0),s=i.index;var c=i.attributes.position;if(t=1,!0===r.wireframe&&(s=V.getWireframeAttribute(i),t=2),e=j,null!==s){var l=N.get(s);(e=Y).setIndex(l)}if(h){if(i&&i.isInstancedBufferGeometry&&null===R.get("ANGLE_instanced_arrays"))console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");else{L.initAttributes(),h=i.attributes,a=a.getAttributes();var u=r.defaultAttributeValues;for(M in a){var d=a[M];if(0<=d){var f=h[M];if(void 0!==f){var p=f.normalized,m=f.itemSize,v=N.get(f);if(void 0!==v){var _=v.buffer,y=v.type;if(v=v.bytesPerElement,f.isInterleavedBufferAttribute){var x=f.data,b=x.stride;f=f.offset,x&&x.isInstancedInterleavedBuffer?(L.enableAttributeAndDivisor(d,x.meshPerAttribute),void 0===i.maxInstancedCount&&(i.maxInstancedCount=x.meshPerAttribute*x.count)):L.enableAttribute(d),Ee.bindBuffer(Ee.ARRAY_BUFFER,_),Ee.vertexAttribPointer(d,m,y,p,b*v,f*v)}else f.isInstancedBufferAttribute?(L.enableAttributeAndDivisor(d,f.meshPerAttribute),void 0===i.maxInstancedCount&&(i.maxInstancedCount=f.meshPerAttribute*f.count)):L.enableAttribute(d),Ee.bindBuffer(Ee.ARRAY_BUFFER,_),Ee.vertexAttribPointer(d,m,y,p,0,0)}}else if(void 0!==u&&void 0!==(p=u[M]))switch(p.length){case 2:Ee.vertexAttrib2fv(d,p);break;case 3:Ee.vertexAttrib3fv(d,p);break;case 4:Ee.vertexAttrib4fv(d,p);break;default:Ee.vertexAttrib1fv(d,p)}}}L.disableUnusedAttributes()}null!==s&&Ee.bindBuffer(Ee.ELEMENT_ARRAY_BUFFER,l.buffer)}l=1/0,null!==s?l=s.count:void 0!==c&&(l=c.count),s=i.drawRange.start*t,c=null!==o?o.start*t:0;var M=Math.max(s,c);if(0!==(o=Math.max(0,Math.min(l,s+i.drawRange.count*t,c+(null!==o?o.count*t:1/0))-1-M+1))){if(n.isMesh)if(!0===r.wireframe)L.setLineWidth(r.wireframeLinewidth*(null===te?fe:1)),e.setMode(Ee.LINES);else switch(n.drawMode){case 0:e.setMode(Ee.TRIANGLES);break;case 1:e.setMode(Ee.TRIANGLE_STRIP);break;case 2:e.setMode(Ee.TRIANGLE_FAN)}else n.isLine?(void 0===(r=r.linewidth)&&(r=1),L.setLineWidth(r*(null===te?fe:1)),n.isLineSegments?e.setMode(Ee.LINES):n.isLineLoop?e.setMode(Ee.LINE_LOOP):e.setMode(Ee.LINE_STRIP)):n.isPoints&&e.setMode(Ee.POINTS);i&&i.isInstancedBufferGeometry?0<i.maxInstancedCount&&e.renderInstances(i,M,o):e.render(M,o)}},this.compile=function(e,t){(D=G.get(e,t)).init(),e.traverse(function(e){e.isLight&&(D.pushLight(e),e.castShadow&&D.pushShadow(e))}),D.setupLights(t),e.traverse(function(t){if(t.material)if(Array.isArray(t.material))for(var i=0;i<t.material.length;i++)p(t.material[i],e.fog,t);else p(t.material,e.fog,t)})};var Se=!1,Ae=null;this.animate=function(e){null!==(Ae=e)?Se||(c(),Se=!0):Se=!1},this.render=function(e,t,i,r){if(t&&t.isCamera){if(!ee){ne="",re=-1,oe=null,!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),Te.enabled&&(t=Te.getCamera(t)),(D=G.get(e,t)).init(),e.onBeforeRender($,e,t,i),be.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),ve.setFromMatrix(be),xe=this.localClippingEnabled,ye=_e.init(this.clippingPlanes,xe,t),(C=k.get(e,t)).init(),function e(t,i,r){if(!1!==t.visible){if(t.layers.test(i.layers))if(t.isLight)D.pushLight(t),t.castShadow&&D.pushShadow(t);else if(t.isSprite)t.frustumCulled&&!ve.intersectsSprite(t)||D.pushSprite(t);else if(t.isImmediateRenderObject)r&&Me.setFromMatrixPosition(t.matrixWorld).applyMatrix4(be),C.push(t,null,t.material,Me.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.update(),!t.frustumCulled||ve.intersectsObject(t))){r&&Me.setFromMatrixPosition(t.matrixWorld).applyMatrix4(be);var n=U.update(t),o=t.material;if(Array.isArray(o))for(var s=n.groups,a=0,h=s.length;a<h;a++){var c=s[a],l=o[c.materialIndex];l&&l.visible&&C.push(t,n,l,Me.z,c)}else o.visible&&C.push(t,n,o,Me.z,null)}for(a=0,h=(t=t.children).length;a<h;a++)e(t[a],i,r)}}(e,t,$.sortObjects),!0===$.sortObjects&&C.sort(),ye&&_e.beginShadows(),we.render(D.state.shadowsArray,e,t),D.setupLights(t),ye&&_e.endShadows(),this.info.autoReset&&this.info.reset(),void 0===i&&(i=null),this.setRenderTarget(i),W.render(C,e,t,r),r=C.opaque;var n=C.transparent;if(e.overrideMaterial){var o=e.overrideMaterial;r.length&&d(r,e,t,o),n.length&&d(n,e,t,o)}else r.length&&d(r,e,t),n.length&&d(n,e,t);X.render(D.state.spritesArray,e,t),i&&F.updateRenderTargetMipmap(i),L.buffers.depth.setTest(!0),L.buffers.depth.setMask(!0),L.buffers.color.setMask(!0),L.setPolygonOffset(!1),e.onAfterRender($,e,t),Te.enabled&&Te.submitFrame(),D=C=null}}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.allocTextureUnit=function(){var e=le;return e>=I.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+e+" texture units while this GPU supports only "+I.maxTextures),le+=1,e},this.setTexture2D=function(){var e=!1;return function(t,i){t&&t.isWebGLRenderTarget&&(e||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),e=!0),t=t.texture),F.setTexture2D(t,i)}}(),this.setTexture=function(){var e=!1;return function(t,i){e||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),e=!0),F.setTexture2D(t,i)}}(),this.setTextureCube=function(){var e=!1;return function(t,i){t&&t.isWebGLRenderTargetCube&&(e||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),e=!0),t=t.texture),t&&t.isCubeTexture||Array.isArray(t.image)&&6===t.image.length?F.setTextureCube(t,i):F.setTextureCubeDynamic(t,i)}}(),this.getRenderTarget=function(){return te},this.setRenderTarget=function(e){(te=e)&&void 0===B.get(e).__webglFramebuffer&&F.setupRenderTarget(e);var t=null,i=!1;e?(t=B.get(e).__webglFramebuffer,e.isWebGLRenderTargetCube&&(t=t[e.activeCubeFace],i=!0),ae.copy(e.viewport),he.copy(e.scissor),ce=e.scissorTest):(ae.copy(pe).multiplyScalar(fe),he.copy(me).multiplyScalar(fe),ce=ge),ie!==t&&(Ee.bindFramebuffer(Ee.FRAMEBUFFER,t),ie=t),L.viewport(ae),L.scissor(he),L.setScissorTest(ce),i&&(i=B.get(e.texture),Ee.framebufferTexture2D(Ee.FRAMEBUFFER,Ee.COLOR_ATTACHMENT0,Ee.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,i.__webglTexture,e.activeMipMapLevel))},this.readRenderTargetPixels=function(e,t,i,r,n,o){if(e&&e.isWebGLRenderTarget){var s=B.get(e).__webglFramebuffer;if(s){var a=!1;s!==ie&&(Ee.bindFramebuffer(Ee.FRAMEBUFFER,s),a=!0);try{var h=e.texture,c=h.format,l=h.type;1023!==c&&K.convert(c)!==Ee.getParameter(Ee.IMPLEMENTATION_COLOR_READ_FORMAT)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):1009===l||K.convert(l)===Ee.getParameter(Ee.IMPLEMENTATION_COLOR_READ_TYPE)||1015===l&&(R.get("OES_texture_float")||R.get("WEBGL_color_buffer_float"))||1016===l&&R.get("EXT_color_buffer_half_float")?Ee.checkFramebufferStatus(Ee.FRAMEBUFFER)===Ee.FRAMEBUFFER_COMPLETE?0<=t&&t<=e.width-r&&0<=i&&i<=e.height-n&&Ee.readPixels(t,i,r,n,K.convert(c),K.convert(l),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.")}finally{a&&Ee.bindFramebuffer(Ee.FRAMEBUFFER,ie)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(e,t,i){var r=t.image.width,n=t.image.height,o=K.convert(t.format);this.setTexture2D(t,0),Ee.copyTexImage2D(Ee.TEXTURE_2D,i||0,o,e.x,e.y,r,n,0)},this.copyTextureToTexture=function(e,t,i,r){var n=t.image.width,o=t.image.height,s=K.convert(i.format),a=K.convert(i.type);t=t.isDataTexture?t.image.data:t.image,this.setTexture2D(i,0),Ee.texSubImage2D(Ee.TEXTURE_2D,r||0,e.x,e.y,n,o,s,a,t)}}function $e(e,t){this.name="",this.color=new g(e),this.density=void 0!==t?t:25e-5}function et(e,t,i){this.name="",this.color=new g(e),this.near=void 0!==t?t:1,this.far=void 0!==i?i:1e3}function tt(){x.call(this),this.type="Scene",this.overrideMaterial=this.fog=this.background=null,this.autoUpdate=!0}function it(e){G.call(this),this.type="SpriteMaterial",this.color=new g(16777215),this.map=null,this.rotation=0,this.lights=this.fog=!1,this.setValues(e)}function rt(e){x.call(this),this.type="Sprite",this.material=void 0!==e?e:new it,this.center=new i(.5,.5)}function nt(){x.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function ot(e,t){if(e=e||[],this.bones=e.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===t)this.calculateInverses();else if(this.bones.length===t.length)this.boneInverses=t.slice(0);else for(console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[],e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new r)}function st(){x.call(this),this.type="Bone"}function at(e,t){K.call(this,e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new r,this.bindMatrixInverse=new r,e=new ot(e=this.initBones()),this.bind(e,this.matrixWorld),this.normalizeSkinWeights()}function ht(e){G.call(this),this.type="LineBasicMaterial",this.color=new g(16777215),this.linewidth=1,this.linejoin=this.linecap="round",this.lights=!1,this.setValues(e)}function ct(e,t,i){if(1===i)return console.warn("THREE.Line: parameter THREE.LinePieces no longer supported. Created THREE.LineSegments instead."),new lt(e,t);x.call(this),this.type="Line",this.geometry=void 0!==e?e:new N,this.material=void 0!==t?t:new ht({color:16777215*Math.random()})}function lt(e,t){ct.call(this,e,t),this.type="LineSegments"}function ut(e,t){ct.call(this,e,t),this.type="LineLoop"}function dt(e){G.call(this),this.type="PointsMaterial",this.color=new g(16777215),this.map=null,this.size=1,this.sizeAttenuation=!0,this.lights=!1,this.setValues(e)}function ft(e,t){x.call(this),this.type="Points",this.geometry=void 0!==e?e:new N,this.material=void 0!==t?t:new dt({color:16777215*Math.random()})}function pt(){x.call(this),this.type="Group"}function mt(e,t,i,r,n,o,s,h,c){a.call(this,e,t,i,r,n,o,s,h,c),this.generateMipmaps=!1}function gt(e,t,i,r,n,o,s,h,c,l,u,d){a.call(this,null,o,s,h,c,l,r,n,u,d),this.image={width:t,height:i},this.mipmaps=e,this.generateMipmaps=this.flipY=!1}function vt(e,t,i,r,n,o,s,h,c,l){if(1026!==(l=void 0!==l?l:1026)&&1027!==l)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&1026===l&&(i=1012),void 0===i&&1027===l&&(i=1020),a.call(this,null,r,n,o,s,h,l,i,c),this.image={width:e,height:t},this.magFilter=void 0!==s?s:1003,this.minFilter=void 0!==h?h:1003,this.generateMipmaps=this.flipY=!1}function _t(e){N.call(this),this.type="WireframeGeometry";var t,i,r,n=[],s=[0,0],a={},h=["a","b","c"];if(e&&e.isGeometry){var c=e.faces,l=0;for(i=c.length;l<i;l++){var u=c[l];for(t=0;3>t;t++){var d=u[h[t]],f=u[h[(t+1)%3]];s[0]=Math.min(d,f),s[1]=Math.max(d,f),void 0===a[d=s[0]+","+s[1]]&&(a[d]={index1:s[0],index2:s[1]})}}for(d in a)l=a[d],h=e.vertices[l.index1],n.push(h.x,h.y,h.z),h=e.vertices[l.index2],n.push(h.x,h.y,h.z)}else if(e&&e.isBufferGeometry)if(h=new o,null!==e.index){c=e.attributes.position,u=e.index;var p=e.groups;for(0===p.length&&(p=[{start:0,count:u.count,materialIndex:0}]),e=0,r=p.length;e<r;++e)for(t=(l=p[e]).start,i=l.count,l=t,i=t+i;l<i;l+=3)for(t=0;3>t;t++)d=u.getX(l+t),f=u.getX(l+(t+1)%3),s[0]=Math.min(d,f),s[1]=Math.max(d,f),void 0===a[d=s[0]+","+s[1]]&&(a[d]={index1:s[0],index2:s[1]});for(d in a)l=a[d],h.fromBufferAttribute(c,l.index1),n.push(h.x,h.y,h.z),h.fromBufferAttribute(c,l.index2),n.push(h.x,h.y,h.z)}else for(l=0,i=(c=e.attributes.position).count/3;l<i;l++)for(t=0;3>t;t++)a=3*l+t,h.fromBufferAttribute(c,a),n.push(h.x,h.y,h.z),a=3*l+(t+1)%3,h.fromBufferAttribute(c,a),n.push(h.x,h.y,h.z);this.addAttribute("position",new L(n,3))}function yt(e,t,i){T.call(this),this.type="ParametricGeometry",this.parameters={func:e,slices:t,stacks:i},this.fromBufferGeometry(new xt(e,t,i)),this.mergeVertices()}function xt(e,t,i){N.call(this),this.type="ParametricBufferGeometry",this.parameters={func:e,slices:t,stacks:i};var r,n,s=[],a=[],h=[],c=[],l=new o,u=new o,d=new o,f=new o,p=new o,m=t+1;for(r=0;r<=i;r++){var g=r/i;for(n=0;n<=t;n++){var v=n/t;e(v,g,u),a.push(u.x,u.y,u.z),0<=v-1e-5?(e(v-1e-5,g,d),f.subVectors(u,d)):(e(v+1e-5,g,d),f.subVectors(d,u)),0<=g-1e-5?(e(v,g-1e-5,d),p.subVectors(u,d)):(e(v,g+1e-5,d),p.subVectors(d,u)),l.crossVectors(f,p).normalize(),h.push(l.x,l.y,l.z),c.push(v,g)}}for(r=0;r<i;r++)for(n=0;n<t;n++)e=r*m+n+1,l=(r+1)*m+n+1,u=(r+1)*m+n,s.push(r*m+n,e,u),s.push(e,l,u);this.setIndex(s),this.addAttribute("position",new L(a,3)),this.addAttribute("normal",new L(h,3)),this.addAttribute("uv",new L(c,2))}function bt(e,t,i,r){T.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r},this.fromBufferGeometry(new Mt(e,t,i,r)),this.mergeVertices()}function Mt(e,t,r,n){function s(e){c.push(e.x,e.y,e.z)}function a(t,i){t*=3,i.x=e[t+0],i.y=e[t+1],i.z=e[t+2]}function h(e,t,i,r){0>r&&1===e.x&&(l[t]=e.x-1),0===i.x&&0===i.z&&(l[t]=r/2/Math.PI+.5)}N.call(this),this.type="PolyhedronBufferGeometry",this.parameters={vertices:e,indices:t,radius:r,detail:n},r=r||1;var c=[],l=[];!function(e){for(var i=new o,r=new o,n=new o,h=0;h<t.length;h+=3){a(t[h+0],i),a(t[h+1],r),a(t[h+2],n);var c,l,u=i,d=r,f=n,p=Math.pow(2,e),m=[];for(l=0;l<=p;l++){m[l]=[];var g=u.clone().lerp(f,l/p),v=d.clone().lerp(f,l/p),_=p-l;for(c=0;c<=_;c++)m[l][c]=0===c&&l===p?g:g.clone().lerp(v,c/_)}for(l=0;l<p;l++)for(c=0;c<2*(p-l)-1;c++)u=Math.floor(c/2),0==c%2?(s(m[l][u+1]),s(m[l+1][u]),s(m[l][u])):(s(m[l][u+1]),s(m[l+1][u+1]),s(m[l+1][u]))}}(n=n||0),function(e){for(var t=new o,i=0;i<c.length;i+=3)t.x=c[i+0],t.y=c[i+1],t.z=c[i+2],t.normalize().multiplyScalar(e),c[i+0]=t.x,c[i+1]=t.y,c[i+2]=t.z}(r),function(){for(var e=new o,t=0;t<c.length;t+=3)e.x=c[t+0],e.y=c[t+1],e.z=c[t+2],l.push(Math.atan2(e.z,-e.x)/2/Math.PI+.5,1-(Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))/Math.PI+.5));e=new o,t=new o;for(var r=new o,n=new o,s=new i,a=new i,u=new i,d=0,f=0;d<c.length;d+=9,f+=6){e.set(c[d+0],c[d+1],c[d+2]),t.set(c[d+3],c[d+4],c[d+5]),r.set(c[d+6],c[d+7],c[d+8]),s.set(l[f+0],l[f+1]),a.set(l[f+2],l[f+3]),u.set(l[f+4],l[f+5]),n.copy(e).add(t).add(r).divideScalar(3);var p=Math.atan2(n.z,-n.x);h(s,f+0,e,p),h(a,f+2,t,p),h(u,f+4,r,p)}for(e=0;e<l.length;e+=6)t=l[e+0],r=l[e+2],n=l[e+4],s=Math.min(t,r,n),.9<Math.max(t,r,n)&&.1>s&&(.2>t&&(l[e+0]+=1),.2>r&&(l[e+2]+=1),.2>n&&(l[e+4]+=1))}(),this.addAttribute("position",new L(c,3)),this.addAttribute("normal",new L(c.slice(),3)),this.addAttribute("uv",new L(l,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}function Et(e,t){T.call(this),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Tt(e,t)),this.mergeVertices()}function Tt(e,t){Mt.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],e,t),this.type="TetrahedronBufferGeometry",this.parameters={radius:e,detail:t}}function wt(e,t){T.call(this),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new St(e,t)),this.mergeVertices()}function St(e,t){Mt.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],e,t),this.type="OctahedronBufferGeometry",this.parameters={radius:e,detail:t}}function At(e,t){T.call(this),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Pt(e,t)),this.mergeVertices()}function Pt(e,t){var i=(1+Math.sqrt(5))/2;Mt.call(this,[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,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],e,t),this.type="IcosahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Ct(e,t){T.call(this),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Dt(e,t)),this.mergeVertices()}function Dt(e,t){var i=(1+Math.sqrt(5))/2,r=1/i;Mt.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Rt(e,t,i,r,n,o){T.call(this),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:n},void 0!==o&&console.warn("THREE.TubeGeometry: taper has been removed."),e=new It(e,t,i,r,n),this.tangents=e.tangents,this.normals=e.normals,this.binormals=e.binormals,this.fromBufferGeometry(e),this.mergeVertices()}function It(e,t,r,n,s){function a(i){p=e.getPointAt(i/t,p);var o=h.normals[i];for(i=h.binormals[i],l=0;l<=n;l++){var s=l/n*Math.PI*2,a=Math.sin(s);s=-Math.cos(s),d.x=s*o.x+a*i.x,d.y=s*o.y+a*i.y,d.z=s*o.z+a*i.z,d.normalize(),g.push(d.x,d.y,d.z),u.x=p.x+r*d.x,u.y=p.y+r*d.y,u.z=p.z+r*d.z,m.push(u.x,u.y,u.z)}}N.call(this),this.type="TubeBufferGeometry",this.parameters={path:e,tubularSegments:t,radius:r,radialSegments:n,closed:s},t=t||64,r=r||1,n=n||8,s=s||!1;var h=e.computeFrenetFrames(t,s);this.tangents=h.tangents,this.normals=h.normals,this.binormals=h.binormals;var c,l,u=new o,d=new o,f=new i,p=new o,m=[],g=[],v=[],_=[];for(c=0;c<t;c++)a(c);for(a(!1===s?t:0),c=0;c<=t;c++)for(l=0;l<=n;l++)f.x=c/t,f.y=l/n,v.push(f.x,f.y);!function(){for(l=1;l<=t;l++)for(c=1;c<=n;c++){var e=(n+1)*l+(c-1),i=(n+1)*l+c,r=(n+1)*(l-1)+c;_.push((n+1)*(l-1)+(c-1),e,r),_.push(e,i,r)}}(),this.setIndex(_),this.addAttribute("position",new L(m,3)),this.addAttribute("normal",new L(g,3)),this.addAttribute("uv",new L(v,2))}function Lt(e,t,i,r,n,o,s){T.call(this),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:n,q:o},void 0!==s&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead."),this.fromBufferGeometry(new Ot(e,t,i,r,n,o)),this.mergeVertices()}function Ot(e,t,i,r,n,s){function a(e,t,i,r,n){var o=Math.sin(e);t=i/t*e,i=Math.cos(t),n.x=r*(2+i)*.5*Math.cos(e),n.y=r*(2+i)*o*.5,n.z=r*Math.sin(t)*.5}N.call(this),this.type="TorusKnotBufferGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:n,q:s},e=e||1,t=t||.4,i=Math.floor(i)||64,r=Math.floor(r)||8,n=n||2,s=s||3;var h,c=[],l=[],u=[],d=[],f=new o,p=new o,m=new o,g=new o,v=new o,_=new o,y=new o;for(h=0;h<=i;++h){var x=h/i*n*Math.PI*2;for(a(x,n,s,e,m),a(x+.01,n,s,e,g),_.subVectors(g,m),y.addVectors(g,m),v.crossVectors(_,y),y.crossVectors(v,_),v.normalize(),y.normalize(),x=0;x<=r;++x){var b=x/r*Math.PI*2,M=-t*Math.cos(b);b=t*Math.sin(b),f.x=m.x+(M*y.x+b*v.x),f.y=m.y+(M*y.y+b*v.y),f.z=m.z+(M*y.z+b*v.z),l.push(f.x,f.y,f.z),p.subVectors(f,m).normalize(),u.push(p.x,p.y,p.z),d.push(h/i),d.push(x/r)}}for(x=1;x<=i;x++)for(h=1;h<=r;h++)e=(r+1)*x+(h-1),t=(r+1)*x+h,n=(r+1)*(x-1)+h,c.push((r+1)*(x-1)+(h-1),e,n),c.push(e,t,n);this.setIndex(c),this.addAttribute("position",new L(l,3)),this.addAttribute("normal",new L(u,3)),this.addAttribute("uv",new L(d,2))}function Bt(e,t,i,r,n){T.call(this),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:n},this.fromBufferGeometry(new Ft(e,t,i,r,n)),this.mergeVertices()}function Ft(e,t,i,r,n){N.call(this),this.type="TorusBufferGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:n},e=e||1,t=t||.4,i=Math.floor(i)||8,r=Math.floor(r)||6,n=n||2*Math.PI;var s,a,h=[],c=[],l=[],u=[],d=new o,f=new o,p=new o;for(s=0;s<=i;s++)for(a=0;a<=r;a++){var m=a/r*n,g=s/i*Math.PI*2;f.x=(e+t*Math.cos(g))*Math.cos(m),f.y=(e+t*Math.cos(g))*Math.sin(m),f.z=t*Math.sin(g),c.push(f.x,f.y,f.z),d.x=e*Math.cos(m),d.y=e*Math.sin(m),p.subVectors(f,d).normalize(),l.push(p.x,p.y,p.z),u.push(a/r),u.push(s/i)}for(s=1;s<=i;s++)for(a=1;a<=r;a++)e=(r+1)*(s-1)+a-1,t=(r+1)*(s-1)+a,n=(r+1)*s+a,h.push((r+1)*s+a-1,e,n),h.push(e,t,n);this.setIndex(h),this.addAttribute("position",new L(c,3)),this.addAttribute("normal",new L(l,3)),this.addAttribute("uv",new L(u,2))}function Nt(e,t,i,r,n){for(var o,s=0,a=t,h=i-r;a<i;a+=r)s+=(e[h]-e[a])*(e[a+1]+e[h+1]),h=a;if(n===0<s)for(n=t;n<i;n+=r)o=qt(n,e[n],e[n+1],o);else for(n=i-r;n>=t;n-=r)o=qt(n,e[n],e[n+1],o);return o&&jt(o,o.next)&&(Zt(o),o=o.next),o}function Vt(e,t){if(!e)return e;t||(t=e);do{var i=!1;if(e.steiner||!jt(e,e.next)&&0!==Ht(e.prev,e,e.next))e=e.next;else{if(Zt(e),(e=t=e.prev)===e.next)break;i=!0}}while(i||e!==t);return t}function Ut(e,t){return e.x-t.x}function zt(e,t){var i=t,r=e.x,n=e.y,o=-1/0;do{if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){var s=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=r&&s>o){if(o=s,s===r){if(n===i.y)return i;if(n===i.next.y)return i.next}var a=i.x<i.next.x?i:i.next}}i=i.next}while(i!==t);if(!a)return null;if(r===o)return a.prev;t=a,s=a.x;var h=a.y,c=1/0;for(i=a.next;i!==t;){if(r>=i.x&&i.x>=s&&r!==i.x&&Wt(n<h?r:o,n,s,h,n<h?o:r,n,i.x,i.y)){var l=Math.abs(n-i.y)/(r-i.x);(l<c||l===c&&i.x>a.x)&&Xt(i,e)&&(a=i,c=l)}i=i.next}return a}function kt(e,t,i,r,n){return 1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*n)|e<<8))|e<<4))|e<<2))|e<<1)|(1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*n)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Gt(e){var t=e,i=e;do{t.x<i.x&&(i=t),t=t.next}while(t!==e);return i}function Wt(e,t,i,r,n,o,s,a){return 0<=(n-s)*(t-a)-(e-s)*(o-a)&&0<=(e-s)*(r-a)-(i-s)*(t-a)&&0<=(i-s)*(o-a)-(n-s)*(r-a)}function Ht(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function jt(e,t){return e.x===t.x&&e.y===t.y}function Yt(e,t,i,r){return!!(jt(e,t)&&jt(i,r)||jt(e,r)&&jt(i,t))||0<Ht(e,t,i)!=0<Ht(e,t,r)&&0<Ht(i,r,e)!=0<Ht(i,r,t)}function Xt(e,t){return 0>Ht(e.prev,e,e.next)?0<=Ht(e,t,e.next)&&0<=Ht(e,e.prev,t):0>Ht(e,t,e.prev)||0>Ht(e,e.next,t)}function Kt(e,t){var i=new Qt(e.i,e.x,e.y),r=new Qt(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function qt(e,t,i,r){return e=new Qt(e,t,i),r?(e.next=r.next,e.prev=r,r.next.prev=e,r.next=e):(e.prev=e,e.next=e),e}function Zt(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Qt(e,t,i){this.i=e,this.x=t,this.y=i,this.nextZ=this.prevZ=this.z=this.next=this.prev=null,this.steiner=!1}function Jt(e){var t=e.length;2<t&&e[t-1].equals(e[0])&&e.pop()}function $t(e,t){for(var i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}function ei(e,t){T.call(this),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},this.fromBufferGeometry(new ti(e,t)),this.mergeVertices()}function ti(e,t){function r(e){function r(e,t,i){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(i).add(e)}function h(e,t,r){var n=e.x-t.x,o=e.y-t.y,s=r.x-e.x,a=r.y-e.y,h=n*n+o*o;if(Math.abs(n*a-o*s)>Number.EPSILON){var c=Math.sqrt(h),l=Math.sqrt(s*s+a*a);if(h=t.x-o/c,t=t.y+n/c,2>=(o=(s=h+n*(a=((r.x-a/l-h)*a-(r.y+s/l-t)*s)/(n*a-o*s))-e.x)*s+(n=t+o*a-e.y)*n))return new i(s,n);o=Math.sqrt(o/2)}else e=!1,n>Number.EPSILON?s>Number.EPSILON&&(e=!0):n<-Number.EPSILON?s<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(a)&&(e=!0),e?(s=-o,o=Math.sqrt(h)):(s=n,n=o,o=Math.sqrt(h/2));return new i(s/o,n/o)}function c(e,t){for(z=e.length;0<=--z;){var i=z,r=z-1;0>r&&(r=e.length-1);var o,a=v+2*M;for(o=0;o<a;o++){var h=V*o,c=V*(o+1),l=t+r+h,u=t+r+c;c=t+i+c,d(t+i+h),d(l),d(c),d(l),d(u),d(c),h=s.length/3,f((h=T.generateSideWallUV(n,s,h-6,h-3,h-2,h-1))[0]),f(h[1]),f(h[3]),f(h[1]),f(h[2]),f(h[3])}}}function l(e,t,i){m.push(e),m.push(t),m.push(i)}function u(e,t,i){d(e),d(t),d(i),e=s.length/3,f((e=T.generateTopUV(n,s,e-3,e-2,e-1))[0]),f(e[1]),f(e[2])}function d(e){s.push(m[3*e]),s.push(m[3*e+1]),s.push(m[3*e+2])}function f(e){a.push(e.x),a.push(e.y)}var p,m=[],g=void 0!==t.curveSegments?t.curveSegments:12,v=void 0!==t.steps?t.steps:1,_=void 0!==t.amount?t.amount:100,y=void 0===t.bevelEnabled||t.bevelEnabled,x=void 0!==t.bevelThickness?t.bevelThickness:6,b=void 0!==t.bevelSize?t.bevelSize:x-2,M=void 0!==t.bevelSegments?t.bevelSegments:3,E=t.extrudePath,T=void 0!==t.UVGenerator?t.UVGenerator:qn,w=!1;if(E){var S=E.getSpacedPoints(v);w=!0,y=!1;var A=E.computeFrenetFrames(v,!1),P=new o,C=new o,D=new o}y||(b=x=M=0),e=(g=e.extractPoints(g)).shape;var R=g.holes;if(!Kn.isClockWise(e)){e=e.reverse();var I=0;for(p=R.length;I<p;I++){var L=R[I];Kn.isClockWise(L)&&(R[I]=L.reverse())}}var O=Kn.triangulateShape(e,R),B=e;for(I=0,p=R.length;I<p;I++)L=R[I],e=e.concat(L);var F,N,V=e.length,U=O.length;g=[];var z=0,k=B.length,G=k-1;for(F=z+1;z<k;z++,G++,F++)G===k&&(G=0),F===k&&(F=0),g[z]=h(B[z],B[G],B[F]);E=[];var W=g.concat();for(I=0,p=R.length;I<p;I++){L=R[I];var H=[];for(z=0,G=(k=L.length)-1,F=z+1;z<k;z++,G++,F++)G===k&&(G=0),F===k&&(F=0),H[z]=h(L[z],L[G],L[F]);E.push(H),W=W.concat(H)}for(G=0;G<M;G++){k=G/M;var j=x*Math.cos(k*Math.PI/2);for(F=b*Math.sin(k*Math.PI/2),z=0,k=B.length;z<k;z++){var Y=r(B[z],g[z],F);l(Y.x,Y.y,-j)}for(I=0,p=R.length;I<p;I++)for(L=R[I],H=E[I],z=0,k=L.length;z<k;z++)l((Y=r(L[z],H[z],F)).x,Y.y,-j)}for(F=b,z=0;z<V;z++)Y=y?r(e[z],W[z],F):e[z],w?(C.copy(A.normals[0]).multiplyScalar(Y.x),P.copy(A.binormals[0]).multiplyScalar(Y.y),D.copy(S[0]).add(C).add(P),l(D.x,D.y,D.z)):l(Y.x,Y.y,0);for(k=1;k<=v;k++)for(z=0;z<V;z++)Y=y?r(e[z],W[z],F):e[z],w?(C.copy(A.normals[k]).multiplyScalar(Y.x),P.copy(A.binormals[k]).multiplyScalar(Y.y),D.copy(S[k]).add(C).add(P),l(D.x,D.y,D.z)):l(Y.x,Y.y,_/v*k);for(G=M-1;0<=G;G--){for(k=G/M,j=x*Math.cos(k*Math.PI/2),F=b*Math.sin(k*Math.PI/2),z=0,k=B.length;z<k;z++)l((Y=r(B[z],g[z],F)).x,Y.y,_+j);for(I=0,p=R.length;I<p;I++)for(L=R[I],H=E[I],z=0,k=L.length;z<k;z++)Y=r(L[z],H[z],F),w?l(Y.x,Y.y+S[v-1].y,S[v-1].x+j):l(Y.x,Y.y,_+j)}!function(){var e=s.length/3;if(y){var t=0*V;for(z=0;z<U;z++)u((N=O[z])[2]+t,N[1]+t,N[0]+t);for(t=V*(v+2*M),z=0;z<U;z++)u((N=O[z])[0]+t,N[1]+t,N[2]+t)}else{for(z=0;z<U;z++)u((N=O[z])[2],N[1],N[0]);for(z=0;z<U;z++)u((N=O[z])[0]+V*v,N[1]+V*v,N[2]+V*v)}n.addGroup(e,s.length/3-e,0)}(),function(){var e=s.length/3,t=0;for(c(B,t),t+=B.length,I=0,p=R.length;I<p;I++)c(L=R[I],t),t+=L.length;n.addGroup(e,s.length/3-e,1)}()}N.call(this),this.type="ExtrudeBufferGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];for(var n=this,s=[],a=[],h=0,c=e.length;h<c;h++)r(e[h]);this.addAttribute("position",new L(s,3)),this.addAttribute("uv",new L(a,2)),this.computeVertexNormals()}function ii(e,t){T.call(this),this.type="TextGeometry",this.parameters={text:e,parameters:t},this.fromBufferGeometry(new ri(e,t)),this.mergeVertices()}function ri(e,t){var i=(t=t||{}).font;if(!i||!i.isFont)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new T;e=i.generateShapes(e,t.size,t.curveSegments),t.amount=void 0!==t.height?t.height:50,void 0===t.bevelThickness&&(t.bevelThickness=10),void 0===t.bevelSize&&(t.bevelSize=8),void 0===t.bevelEnabled&&(t.bevelEnabled=!1),ti.call(this,e,t),this.type="TextBufferGeometry"}function ni(e,t,i,r,n,o,s){T.call(this),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:n,thetaStart:o,thetaLength:s},this.fromBufferGeometry(new oi(e,t,i,r,n,o,s)),this.mergeVertices()}function oi(e,t,i,r,n,s,a){N.call(this),this.type="SphereBufferGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:n,thetaStart:s,thetaLength:a},e=e||1,t=Math.max(3,Math.floor(t)||8),i=Math.max(2,Math.floor(i)||6),r=void 0!==r?r:0,n=void 0!==n?n:2*Math.PI;var h,c,l=(s=void 0!==s?s:0)+(a=void 0!==a?a:Math.PI),u=0,d=[],f=new o,p=new o,m=[],g=[],v=[],_=[];for(c=0;c<=i;c++){var y=[],x=c/i;for(h=0;h<=t;h++){var b=h/t;f.x=-e*Math.cos(r+b*n)*Math.sin(s+x*a),f.y=e*Math.cos(s+x*a),f.z=e*Math.sin(r+b*n)*Math.sin(s+x*a),g.push(f.x,f.y,f.z),p.set(f.x,f.y,f.z).normalize(),v.push(p.x,p.y,p.z),_.push(b,1-x),y.push(u++)}d.push(y)}for(c=0;c<i;c++)for(h=0;h<t;h++)e=d[c][h+1],r=d[c][h],n=d[c+1][h],a=d[c+1][h+1],(0!==c||0<s)&&m.push(e,r,a),(c!==i-1||l<Math.PI)&&m.push(r,n,a);this.setIndex(m),this.addAttribute("position",new L(g,3)),this.addAttribute("normal",new L(v,3)),this.addAttribute("uv",new L(_,2))}function si(e,t,i,r,n,o){T.call(this),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:n,thetaLength:o},this.fromBufferGeometry(new ai(e,t,i,r,n,o)),this.mergeVertices()}function ai(e,t,r,n,s,a){N.call(this),this.type="RingBufferGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:r,phiSegments:n,thetaStart:s,thetaLength:a},e=e||.5,t=t||1,s=void 0!==s?s:0,a=void 0!==a?a:2*Math.PI,r=void 0!==r?Math.max(3,r):8;var h,c,l=[],u=[],d=[],f=[],p=e,m=(t-e)/(n=void 0!==n?Math.max(1,n):1),g=new o,v=new i;for(h=0;h<=n;h++){for(c=0;c<=r;c++)e=s+c/r*a,g.x=p*Math.cos(e),g.y=p*Math.sin(e),u.push(g.x,g.y,g.z),d.push(0,0,1),v.x=(g.x/t+1)/2,v.y=(g.y/t+1)/2,f.push(v.x,v.y);p+=m}for(h=0;h<n;h++)for(t=h*(r+1),c=0;c<r;c++)s=(e=c+t)+r+1,a=e+r+2,p=e+1,l.push(e,s,p),l.push(s,a,p);this.setIndex(l),this.addAttribute("position",new L(u,3)),this.addAttribute("normal",new L(d,3)),this.addAttribute("uv",new L(f,2))}function hi(e,t,i,r){T.call(this),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},this.fromBufferGeometry(new ci(e,t,i,r)),this.mergeVertices()}function ci(e,t,r,n){N.call(this),this.type="LatheBufferGeometry",this.parameters={points:e,segments:t,phiStart:r,phiLength:n},t=Math.floor(t)||12,r=r||0,n=n||2*Math.PI,n=An.clamp(n,0,2*Math.PI);var s,a=[],h=[],c=[],l=1/t,u=new o,d=new i;for(s=0;s<=t;s++){var f=r+s*l*n,p=Math.sin(f),m=Math.cos(f);for(f=0;f<=e.length-1;f++)u.x=e[f].x*p,u.y=e[f].y,u.z=e[f].x*m,h.push(u.x,u.y,u.z),d.x=s/t,d.y=f/(e.length-1),c.push(d.x,d.y)}for(s=0;s<t;s++)for(f=0;f<e.length-1;f++)l=(r=f+s*e.length)+e.length,u=r+e.length+1,d=r+1,a.push(r,l,d),a.push(l,u,d);if(this.setIndex(a),this.addAttribute("position",new L(h,3)),this.addAttribute("uv",new L(c,2)),this.computeVertexNormals(),n===2*Math.PI)for(n=this.attributes.normal.array,a=new o,h=new o,c=new o,r=t*e.length*3,f=s=0;s<e.length;s++,f+=3)a.x=n[f+0],a.y=n[f+1],a.z=n[f+2],h.x=n[r+f+0],h.y=n[r+f+1],h.z=n[r+f+2],c.addVectors(a,h).normalize(),n[f+0]=n[r+f+0]=c.x,n[f+1]=n[r+f+1]=c.y,n[f+2]=n[r+f+2]=c.z}function li(e,t){T.call(this),this.type="ShapeGeometry","object"==typeof t&&(console.warn("THREE.ShapeGeometry: Options parameter has been removed."),t=t.curveSegments),this.parameters={shapes:e,curveSegments:t},this.fromBufferGeometry(new ui(e,t)),this.mergeVertices()}function ui(e,t){function i(e){var i,a=n.length/3,c=(e=e.extractPoints(t)).shape,l=e.holes;if(!1===Kn.isClockWise(c))for(c=c.reverse(),e=0,i=l.length;e<i;e++){var u=l[e];!0===Kn.isClockWise(u)&&(l[e]=u.reverse())}var d=Kn.triangulateShape(c,l);for(e=0,i=l.length;e<i;e++)u=l[e],c=c.concat(u);for(e=0,i=c.length;e<i;e++)u=c[e],n.push(u.x,u.y,0),o.push(0,0,1),s.push(u.x,u.y);for(e=0,i=d.length;e<i;e++)c=d[e],r.push(c[0]+a,c[1]+a,c[2]+a),h+=3}N.call(this),this.type="ShapeBufferGeometry",this.parameters={shapes:e,curveSegments:t},t=t||12;var r=[],n=[],o=[],s=[],a=0,h=0;if(!1===Array.isArray(e))i(e);else for(var c=0;c<e.length;c++)i(e[c]),this.addGroup(a,h,c),a+=h,h=0;this.setIndex(r),this.addAttribute("position",new L(n,3)),this.addAttribute("normal",new L(o,3)),this.addAttribute("uv",new L(s,2))}function di(e,t){if(t.shapes=[],Array.isArray(e))for(var i=0,r=e.length;i<r;i++)t.shapes.push(e[i].uuid);else t.shapes.push(e.uuid);return t}function fi(e,t){N.call(this),this.type="EdgesGeometry",this.parameters={thresholdAngle:t};var i=[];t=Math.cos(An.DEG2RAD*(void 0!==t?t:1));var r=[0,0],n={},o=["a","b","c"];if(e.isBufferGeometry){var s=new T;s.fromBufferGeometry(e)}else s=e.clone();s.mergeVertices(),s.computeFaceNormals(),e=s.vertices;for(var a=0,h=(s=s.faces).length;a<h;a++)for(var c=s[a],l=0;3>l;l++){var u=c[o[l]],d=c[o[(l+1)%3]];r[0]=Math.min(u,d),r[1]=Math.max(u,d),void 0===n[u=r[0]+","+r[1]]?n[u]={index1:r[0],index2:r[1],face1:a,face2:void 0}:n[u].face2=a}for(u in n)(void 0===(r=n[u]).face2||s[r.face1].normal.dot(s[r.face2].normal)<=t)&&(o=e[r.index1],i.push(o.x,o.y,o.z),o=e[r.index2],i.push(o.x,o.y,o.z));this.addAttribute("position",new L(i,3))}function pi(e,t,i,r,n,o,s,a){T.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:n,openEnded:o,thetaStart:s,thetaLength:a},this.fromBufferGeometry(new mi(e,t,i,r,n,o,s,a)),this.mergeVertices()}function mi(e,t,r,n,s,a,h,c){function l(r){var s,a=new i,l=new o,v=0,x=!0===r?e:t,b=!0===r?1:-1,M=g;for(s=1;s<=n;s++)f.push(0,_*b,0),p.push(0,b,0),m.push(.5,.5),g++;var E=g;for(s=0;s<=n;s++){var T=s/n*c+h,w=Math.cos(T);T=Math.sin(T),l.x=x*T,l.y=_*b,l.z=x*w,f.push(l.x,l.y,l.z),p.push(0,b,0),a.x=.5*w+.5,a.y=.5*T*b+.5,m.push(a.x,a.y),g++}for(s=0;s<n;s++)a=M+s,l=E+s,!0===r?d.push(l,l+1,a):d.push(l+1,l,a),v+=3;u.addGroup(y,v,!0===r?1:2),y+=v}N.call(this),this.type="CylinderBufferGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:r,radialSegments:n,heightSegments:s,openEnded:a,thetaStart:h,thetaLength:c};var u=this;e=void 0!==e?e:1,t=void 0!==t?t:1,r=r||1,n=Math.floor(n)||8,s=Math.floor(s)||1,a=void 0!==a&&a,h=void 0!==h?h:0,c=void 0!==c?c:2*Math.PI;var d=[],f=[],p=[],m=[],g=0,v=[],_=r/2,y=0;!function(){var i,a,l=new o,x=new o,b=0,M=(t-e)/r;for(a=0;a<=s;a++){var E=[],T=a/s,w=T*(t-e)+e;for(i=0;i<=n;i++){var S=i/n,A=S*c+h,P=Math.sin(A);A=Math.cos(A),x.x=w*P,x.y=-T*r+_,x.z=w*A,f.push(x.x,x.y,x.z),l.set(P,M,A).normalize(),p.push(l.x,l.y,l.z),m.push(S,1-T),E.push(g++)}v.push(E)}for(i=0;i<n;i++)for(a=0;a<s;a++)l=v[a+1][i],x=v[a+1][i+1],M=v[a][i+1],d.push(v[a][i],l,M),d.push(l,x,M),b+=6;u.addGroup(y,b,0),y+=b}(),!1===a&&(0<e&&l(!0),0<t&&l(!1)),this.setIndex(d),this.addAttribute("position",new L(f,3)),this.addAttribute("normal",new L(p,3)),this.addAttribute("uv",new L(m,2))}function gi(e,t,i,r,n,o,s){pi.call(this,0,e,t,i,r,n,o,s),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:o,thetaLength:s}}function vi(e,t,i,r,n,o,s){mi.call(this,0,e,t,i,r,n,o,s),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:o,thetaLength:s}}function _i(e,t,i,r){T.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},this.fromBufferGeometry(new yi(e,t,i,r)),this.mergeVertices()}function yi(e,t,r,n){N.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:r,thetaLength:n},e=e||1,t=void 0!==t?Math.max(3,t):8,r=void 0!==r?r:0,n=void 0!==n?n:2*Math.PI;var s,a=[],h=[],c=[],l=[],u=new o,d=new i;h.push(0,0,0),c.push(0,0,1),l.push(.5,.5);var f=0;for(s=3;f<=t;f++,s+=3){var p=r+f/t*n;u.x=e*Math.cos(p),u.y=e*Math.sin(p),h.push(u.x,u.y,u.z),c.push(0,0,1),d.x=(h[s]/e+1)/2,d.y=(h[s+1]/e+1)/2,l.push(d.x,d.y)}for(s=1;s<=t;s++)a.push(s,s+1,0);this.setIndex(a),this.addAttribute("position",new L(h,3)),this.addAttribute("normal",new L(c,3)),this.addAttribute("uv",new L(l,2))}function xi(e){G.call(this),this.type="ShadowMaterial",this.color=new g(0),this.transparent=!0,this.setValues(e)}function bi(e){H.call(this,e),this.type="RawShaderMaterial"}function Mi(e){G.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new g(16777215),this.metalness=this.roughness=.5,this.lightMap=this.map=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new g(0),this.emissiveIntensity=1,this.bumpMap=this.emissiveMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new i(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.envMap=this.alphaMap=this.metalnessMap=this.roughnessMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinejoin=this.wireframeLinecap="round",this.morphNormals=this.morphTargets=this.skinning=!1,this.setValues(e)}function Ei(e){Mi.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoatRoughness=this.clearCoat=0,this.setValues(e)}function Ti(e){G.call(this),this.type="MeshPhongMaterial",this.color=new g(16777215),this.specular=new g(1118481),this.shininess=30,this.lightMap=this.map=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new g(0),this.emissiveIntensity=1,this.bumpMap=this.emissiveMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new i(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.envMap=this.alphaMap=this.specularMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinejoin=this.wireframeLinecap="round",this.morphNormals=this.morphTargets=this.skinning=!1,this.setValues(e)}function wi(e){Ti.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(e)}function Si(e){G.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new i(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.morphNormals=this.morphTargets=this.skinning=this.lights=this.fog=!1,this.setValues(e)}function Ai(e){G.call(this),this.type="MeshLambertMaterial",this.color=new g(16777215),this.lightMap=this.map=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new g(0),this.emissiveIntensity=1,this.envMap=this.alphaMap=this.specularMap=this.emissiveMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinejoin=this.wireframeLinecap="round",this.morphNormals=this.morphTargets=this.skinning=!1,this.setValues(e)}function Pi(e){ht.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}function Ci(e,t,i){var r=this,n=!1,o=0,s=0,a=void 0;this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(e){s++,!1===n&&void 0!==r.onStart&&r.onStart(e,o,s),n=!0},this.itemEnd=function(e){o++,void 0!==r.onProgress&&r.onProgress(e,o,s),o===s&&(n=!1,void 0!==r.onLoad)&&r.onLoad()},this.itemError=function(e){void 0!==r.onError&&r.onError(e)},this.resolveURL=function(e){return a?a(e):e},this.setURLModifier=function(e){return a=e,this}}function Di(e){this.manager=void 0!==e?e:$n}function Ri(e){this.manager=void 0!==e?e:$n,this._parser=null}function Ii(e){this.manager=void 0!==e?e:$n,this._parser=null}function Li(e){this.manager=void 0!==e?e:$n}function Oi(e){this.manager=void 0!==e?e:$n}function Bi(e){this.manager=void 0!==e?e:$n}function Fi(){this.type="Curve",this.arcLengthDivisions=200}function Ni(e,t,i,r,n,o,s,a){Fi.call(this),this.type="EllipseCurve",this.aX=e||0,this.aY=t||0,this.xRadius=i||1,this.yRadius=r||1,this.aStartAngle=n||0,this.aEndAngle=o||2*Math.PI,this.aClockwise=s||!1,this.aRotation=a||0}function Vi(e,t,i,r,n,o){Ni.call(this,e,t,i,i,r,n,o),this.type="ArcCurve"}function Ui(){var e=0,t=0,i=0,r=0;return{initCatmullRom:function(n,o,s,a,h){e=o,t=n=h*(s-n),i=-3*o+3*s-2*n-(a=h*(a-o)),r=2*o-2*s+n+a},initNonuniformCatmullRom:function(n,o,s,a,h,c,l){e=o,t=n=((o-n)/h-(s-n)/(h+c)+(s-o)/c)*c,i=-3*o+3*s-2*n-(a=((s-o)/c-(a-o)/(c+l)+(a-s)/l)*c),r=2*o-2*s+n+a},calc:function(n){var o=n*n;return e+t*n+i*o+r*o*n}}}function zi(e,t,i,r){Fi.call(this),this.type="CatmullRomCurve3",this.points=e||[],this.closed=t||!1,this.curveType=i||"centripetal",this.tension=r||.5}function ki(e,t,i,r,n){var o=e*e;return(2*i-2*r+(t=.5*(r-t))+(n=.5*(n-i)))*e*o+(-3*i+3*r-2*t-n)*o+t*e+i}function Gi(e,t,i,r){var n=1-e;return n*n*t+2*(1-e)*e*i+e*e*r}function Wi(e,t,i,r,n){var o=1-e,s=1-e;return o*o*o*t+3*s*s*e*i+3*(1-e)*e*e*r+e*e*e*n}function Hi(e,t,r,n){Fi.call(this),this.type="CubicBezierCurve",this.v0=e||new i,this.v1=t||new i,this.v2=r||new i,this.v3=n||new i}function ji(e,t,i,r){Fi.call(this),this.type="CubicBezierCurve3",this.v0=e||new o,this.v1=t||new o,this.v2=i||new o,this.v3=r||new o}function Yi(e,t){Fi.call(this),this.type="LineCurve",this.v1=e||new i,this.v2=t||new i}function Xi(e,t){Fi.call(this),this.type="LineCurve3",this.v1=e||new o,this.v2=t||new o}function Ki(e,t,r){Fi.call(this),this.type="QuadraticBezierCurve",this.v0=e||new i,this.v1=t||new i,this.v2=r||new i}function qi(e,t,i){Fi.call(this),this.type="QuadraticBezierCurve3",this.v0=e||new o,this.v1=t||new o,this.v2=i||new o}function Zi(e){Fi.call(this),this.type="SplineCurve",this.points=e||[]}function Qi(){Fi.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}function Ji(e){Qi.call(this),this.type="Path",this.currentPoint=new i,e&&this.setFromPoints(e)}function $i(e){Ji.call(this,e),this.uuid=An.generateUUID(),this.type="Shape",this.holes=[]}function er(e,t){x.call(this),this.type="Light",this.color=new g(e),this.intensity=void 0!==t?t:1,this.receiveShadow=void 0}function tr(e,t,i){er.call(this,e,i),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(x.DefaultUp),this.updateMatrix(),this.groundColor=new g(t)}function ir(e){this.camera=e,this.bias=0,this.radius=1,this.mapSize=new i(512,512),this.map=null,this.matrix=new r}function rr(){ir.call(this,new qe(50,1,.5,500))}function nr(e,t,i,r,n,o){er.call(this,e,t),this.type="SpotLight",this.position.copy(x.DefaultUp),this.updateMatrix(),this.target=new x,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(e){this.intensity=e/Math.PI}}),this.distance=void 0!==i?i:0,this.angle=void 0!==r?r:Math.PI/3,this.penumbra=void 0!==n?n:0,this.decay=void 0!==o?o:1,this.shadow=new rr}function or(e,t,i,r){er.call(this,e,t),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(e){this.intensity=e/(4*Math.PI)}}),this.distance=void 0!==i?i:0,this.decay=void 0!==r?r:1,this.shadow=new ir(new qe(90,1,.5,500))}function sr(){ir.call(this,new M(-5,5,5,-5,.5,500))}function ar(e,t){er.call(this,e,t),this.type="DirectionalLight",this.position.copy(x.DefaultUp),this.updateMatrix(),this.target=new x,this.shadow=new sr}function hr(e,t){er.call(this,e,t),this.type="AmbientLight",this.castShadow=void 0}function cr(e,t,i,r){er.call(this,e,t),this.type="RectAreaLight",this.width=void 0!==i?i:10,this.height=void 0!==r?r:10}function lr(e,t,i,r){xr.call(this,e,t,i,r)}function ur(e,t,i){xr.call(this,e,t,i)}function dr(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i}function fr(e,t,i,r){dr.call(this,e,t,i,r)}function pr(e,t,i,r){xr.call(this,e,t,i,r)}function mr(e,t,i,r){xr.call(this,e,t,i,r)}function gr(e,t,i,r){xr.call(this,e,t,i,r)}function vr(e,t,i,r){dr.call(this,e,t,i,r),this._offsetNext=this._weightNext=this._offsetPrev=this._weightPrev=-0}function _r(e,t,i,r){dr.call(this,e,t,i,r)}function yr(e,t,i,r){dr.call(this,e,t,i,r)}function xr(e,t,i,r){if(void 0===e)throw Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=so.convertArray(t,this.TimeBufferType),this.values=so.convertArray(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation),this.validate(),this.optimize()}function br(e,t,i,r){xr.call(this,e,t,i,r)}function Mr(e,t,i){this.name=e,this.tracks=i,this.duration=void 0!==t?t:-1,this.uuid=An.generateUUID(),0>this.duration&&this.resetDuration(),this.optimize()}function Er(e){this.manager=void 0!==e?e:$n,this.textures={}}function Tr(e){this.manager=void 0!==e?e:$n}function wr(){}function Sr(e){"boolean"==typeof e&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),e=void 0),this.manager=void 0!==e?e:$n,this.withCredentials=!1}function Ar(e){this.manager=void 0!==e?e:$n,this.texturePath=""}function Pr(e){"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.manager=void 0!==e?e:$n,this.options=void 0}function Cr(){this.type="ShapePath",this.color=new g,this.subPaths=[],this.currentPath=null}function Dr(e){this.type="Font",this.data=e}function Rr(e){this.manager=void 0!==e?e:$n}function Ir(e){this.manager=void 0!==e?e:$n}function Lr(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new qe,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new qe,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1}function Or(e,t,i){x.call(this),this.type="CubeCamera";var r=new qe(90,1,e,t);r.up.set(0,-1,0),r.lookAt(new o(1,0,0)),this.add(r);var n=new qe(90,1,e,t);n.up.set(0,-1,0),n.lookAt(new o(-1,0,0)),this.add(n);var s=new qe(90,1,e,t);s.up.set(0,0,1),s.lookAt(new o(0,1,0)),this.add(s);var a=new qe(90,1,e,t);a.up.set(0,0,-1),a.lookAt(new o(0,-1,0)),this.add(a);var h=new qe(90,1,e,t);h.up.set(0,-1,0),h.lookAt(new o(0,0,1)),this.add(h);var c=new qe(90,1,e,t);c.up.set(0,-1,0),c.lookAt(new o(0,0,-1)),this.add(c),this.renderTarget=new l(i,i,{format:1022,magFilter:1006,minFilter:1006}),this.renderTarget.texture.name="CubeCamera",this.update=function(e,t){null===this.parent&&this.updateMatrixWorld();var i=this.renderTarget,o=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,i.activeCubeFace=0,e.render(t,r,i),i.activeCubeFace=1,e.render(t,n,i),i.activeCubeFace=2,e.render(t,s,i),i.activeCubeFace=3,e.render(t,a,i),i.activeCubeFace=4,e.render(t,h,i),i.texture.generateMipmaps=o,i.activeCubeFace=5,e.render(t,c,i),e.setRenderTarget(null)},this.clear=function(e,t,i,r){for(var n=this.renderTarget,o=0;6>o;o++)n.activeCubeFace=o,e.setRenderTarget(n),e.clear(t,i,r);e.setRenderTarget(null)}}function Br(){x.call(this),this.type="AudioListener",this.context=go.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null}function Fr(e){x.call(this),this.type="Audio",this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.loop=!1,this.offset=this.startTime=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filters=[]}function Nr(e){Fr.call(this,e),this.panner=this.context.createPanner(),this.panner.connect(this.gain)}function Vr(e,t){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=void 0!==t?t:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}function Ur(e,t,i){switch(this.binding=e,this.valueSize=i,e=Float64Array,t){case"quaternion":t=this._slerp;break;case"string":case"bool":e=Array,t=this._select;break;default:t=this._lerp}this.buffer=new e(4*i),this._mixBufferRegion=t,this.referenceCount=this.useCount=this.cumulativeWeight=0}function zr(e,t,i){i=i||kr.parseTrackName(t),this._targetGroup=e,this._bindings=e.subscribe_(t,i)}function kr(e,t,i){this.path=t,this.parsedPath=i||kr.parseTrackName(t),this.node=kr.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e}function Gr(){this.uuid=An.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var e={};this._indicesByUUID=e;for(var t=0,i=arguments.length;t!==i;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var r=this;this.stats={objects:{get total(){return r._objects.length},get inUse(){return this.total-r.nCachedObjects_}},get bindingsPerObject(){return r._bindings.length}}}function Wr(e,t,i){this._mixer=e,this._clip=t,this._localRoot=i||null,t=(e=t.tracks).length,i=Array(t);for(var r={endingStart:2400,endingEnd:2400},n=0;n!==t;++n){var o=e[n].createInterpolant(null);i[n]=o,o.settings=r}this._interpolantSettings=r,this._interpolants=i,this._propertyBindings=Array(t),this._weightInterpolant=this._timeScaleInterpolant=this._byClipCacheIndex=this._cacheIndex=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this._effectiveWeight=this.weight=this._effectiveTimeScale=this.timeScale=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtEnd=this.zeroSlopeAtStart=!0}function Hr(e){this._root=e,this._initMemoryManager(),this.time=this._accuIndex=0,this.timeScale=1}function jr(e,t){"string"==typeof e&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=t),this.value=e}function Yr(){N.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function Xr(e,t,i,r){this.data=e,this.itemSize=t,this.offset=i,this.normalized=!0===r}function Kr(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}function qr(e,t,i){Kr.call(this,e,t),this.meshPerAttribute=i||1}function Zr(e,t,i){w.call(this,e,t),this.meshPerAttribute=i||1}function Qr(e,t,i,r){this.ray=new j(e,t),this.near=i||0,this.far=r||1/0,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function Jr(e,t){return e.distance-t.distance}function $r(e,t,i,r){if(!1!==e.visible&&(e.raycast(t,i),!0===r)){r=0;for(var n=(e=e.children).length;r<n;r++)$r(e[r],t,i,!0)}}function en(e){this.autoStart=void 0===e||e,this.elapsedTime=this.oldTime=this.startTime=0,this.running=!1}function tn(e,t,i){return this.radius=void 0!==e?e:1,this.phi=void 0!==t?t:0,this.theta=void 0!==i?i:0,this}function rn(e,t,i){return this.radius=void 0!==e?e:1,this.theta=void 0!==t?t:0,this.y=void 0!==i?i:0,this}function nn(e,t){this.min=void 0!==e?e:new i(1/0,1/0),this.max=void 0!==t?t:new i(-1/0,-1/0)}function on(e){x.call(this),this.material=e,this.render=function(){}}function sn(e,t,i,r){this.object=e,this.size=void 0!==t?t:1,e=void 0!==i?i:16711680,r=void 0!==r?r:1,t=0,(i=this.object.geometry)&&i.isGeometry?t=3*i.faces.length:i&&i.isBufferGeometry&&(t=i.attributes.normal.count),i=new N,t=new L(6*t,3),i.addAttribute("position",t),lt.call(this,i,new ht({color:e,linewidth:r})),this.matrixAutoUpdate=!1,this.update()}function an(e,t){x.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,e=new N,t=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(var i=0,r=1;32>i;i++,r++){var n=i/32*Math.PI*2,o=r/32*Math.PI*2;t.push(Math.cos(n),Math.sin(n),1,Math.cos(o),Math.sin(o),1)}e.addAttribute("position",new L(t,3)),t=new ht({fog:!1}),this.cone=new lt(e,t),this.add(this.cone),this.update()}function hn(e){for(var t=function e(t){var i=[];t&&t.isBone&&i.push(t);for(var r=0;r<t.children.length;r++)i.push.apply(i,e(t.children[r]));return i}(e),i=new N,r=[],n=[],o=new g(0,0,1),s=new g(0,1,0),a=0;a<t.length;a++){var h=t[a];h.parent&&h.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),n.push(o.r,o.g,o.b),n.push(s.r,s.g,s.b))}i.addAttribute("position",new L(r,3)),i.addAttribute("color",new L(n,3)),r=new ht({vertexColors:2,depthTest:!1,depthWrite:!1,transparent:!0}),lt.call(this,i,r),this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}function cn(e,t,i){this.light=e,this.light.updateMatrixWorld(),this.color=i,e=new oi(t,4,2),t=new W({wireframe:!0,fog:!1}),K.call(this,e,t),this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}function ln(e,t){x.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,e=new ht({fog:!1}),(t=new N).addAttribute("position",new w(new Float32Array(15),3)),this.line=new ct(t,e),this.add(this.line),this.update()}function un(e,t,i){x.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,(e=new St(t)).rotateY(.5*Math.PI),this.material=new W({wireframe:!0,fog:!1}),void 0===this.color&&(this.material.vertexColors=2),t=e.getAttribute("position"),t=new Float32Array(3*t.count),e.addAttribute("color",new w(t,3)),this.add(new K(e,this.material)),this.update()}function dn(e,t,i,r){e=e||10,t=t||10,i=new g(void 0!==i?i:4473924),r=new g(void 0!==r?r:8947848);var n=t/2,o=e/t,s=e/2;e=[];for(var a=[],h=0,c=0,l=-s;h<=t;h++,l+=o){e.push(-s,0,l,s,0,l),e.push(l,0,-s,l,0,s);var u=h===n?i:r;u.toArray(a,c),c+=3,u.toArray(a,c),c+=3,u.toArray(a,c),c+=3,u.toArray(a,c),c+=3}(t=new N).addAttribute("position",new L(e,3)),t.addAttribute("color",new L(a,3)),i=new ht({vertexColors:2}),lt.call(this,t,i)}function fn(e,t,i,r,n,o){e=e||10,t=t||16,i=i||8,r=r||64,n=new g(void 0!==n?n:4473924),o=new g(void 0!==o?o:8947848);var s,a=[],h=[];for(s=0;s<=t;s++){var c=s/t*2*Math.PI,l=Math.sin(c)*e;c=Math.cos(c)*e,a.push(0,0,0),a.push(l,0,c);var u=1&s?n:o;h.push(u.r,u.g,u.b),h.push(u.r,u.g,u.b)}for(s=0;s<=i;s++){u=1&s?n:o;var d=e-e/i*s;for(t=0;t<r;t++)c=t/r*2*Math.PI,l=Math.sin(c)*d,c=Math.cos(c)*d,a.push(l,0,c),h.push(u.r,u.g,u.b),c=(t+1)/r*2*Math.PI,l=Math.sin(c)*d,c=Math.cos(c)*d,a.push(l,0,c),h.push(u.r,u.g,u.b)}(e=new N).addAttribute("position",new L(a,3)),e.addAttribute("color",new L(h,3)),a=new ht({vertexColors:2}),lt.call(this,e,a)}function pn(e,t,i,r){this.object=e,this.size=void 0!==t?t:1,e=void 0!==i?i:16776960,r=void 0!==r?r:1,t=0,(i=this.object.geometry)&&i.isGeometry?t=i.faces.length:console.warn("THREE.FaceNormalsHelper: only THREE.Geometry is supported. Use THREE.VertexNormalsHelper, instead."),i=new N,t=new L(6*t,3),i.addAttribute("position",t),lt.call(this,i,new ht({color:e,linewidth:r})),this.matrixAutoUpdate=!1,this.update()}function mn(e,t,i){x.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,void 0===t&&(t=1),(e=new N).addAttribute("position",new L([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3)),t=new ht({fog:!1}),this.lightPlane=new ct(e,t),this.add(this.lightPlane),(e=new N).addAttribute("position",new L([0,0,0,0,0,1],3)),this.targetLine=new ct(e,t),this.add(this.targetLine),this.update()}function gn(e){function t(e,t,r){i(e,r),i(t,r)}function i(e,t){o.push(0,0,0),s.push(t.r,t.g,t.b),void 0===a[e]&&(a[e]=[]),a[e].push(o.length/3-1)}var r=new N,n=new ht({color:16777215,vertexColors:1}),o=[],s=[],a={},h=new g(16755200),c=new g(16711680),l=new g(43775),u=new g(16777215),d=new g(3355443);t("n1","n2",h),t("n2","n4",h),t("n4","n3",h),t("n3","n1",h),t("f1","f2",h),t("f2","f4",h),t("f4","f3",h),t("f3","f1",h),t("n1","f1",h),t("n2","f2",h),t("n3","f3",h),t("n4","f4",h),t("p","n1",c),t("p","n2",c),t("p","n3",c),t("p","n4",c),t("u1","u2",l),t("u2","u3",l),t("u3","u1",l),t("c","t",u),t("p","c",d),t("cn1","cn2",d),t("cn3","cn4",d),t("cf1","cf2",d),t("cf3","cf4",d),r.addAttribute("position",new L(o,3)),r.addAttribute("color",new L(s,3)),lt.call(this,r,n),this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}function vn(e,t){this.object=e,void 0===t&&(t=16776960),e=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]);var i=new Float32Array(24),r=new N;r.setIndex(new w(e,1)),r.addAttribute("position",new w(i,3)),lt.call(this,r,new ht({color:t})),this.matrixAutoUpdate=!1,this.update()}function _n(e,t){this.type="Box3Helper",this.box=e,e=void 0!==t?t:16776960,t=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]);var i=new N;i.setIndex(new w(t,1)),i.addAttribute("position",new L([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),lt.call(this,i,new ht({color:e})),this.geometry.computeBoundingSphere()}function yn(e,t,i){this.type="PlaneHelper",this.plane=e,this.size=void 0===t?1:t,e=void 0!==i?i:16776960,(t=new N).addAttribute("position",new L([1,-1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,0,0,1,0,0,0],3)),t.computeBoundingSphere(),ct.call(this,t,new ht({color:e})),(t=new N).addAttribute("position",new L([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3)),t.computeBoundingSphere(),this.add(new K(t,new W({color:e,opacity:.2,transparent:!0,depthWrite:!1})))}function xn(e,t,i,r,n,o){x.call(this),void 0===r&&(r=16776960),void 0===i&&(i=1),void 0===n&&(n=.2*i),void 0===o&&(o=.2*n),void 0===po&&((po=new N).addAttribute("position",new L([0,0,0,0,1,0],3)),(mo=new mi(0,.5,1,5,1)).translate(0,-.5,0)),this.position.copy(t),this.line=new ct(po,new ht({color:r})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new K(mo,new W({color:r})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,n,o)}function bn(e){var t=[0,0,0,e=e||1,0,0,0,0,0,0,e,0,0,0,0,0,0,e];(e=new N).addAttribute("position",new L(t,3)),e.addAttribute("color",new L([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),t=new ht({vertexColors:2}),lt.call(this,e,t)}function Mn(e){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),zi.call(this,e),this.type="catmullrom",this.closed=!0}function En(e){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),zi.call(this,e),this.type="catmullrom"}function Tn(e){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),zi.call(this,e),this.type="catmullrom"}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}),void 0===Math.sign&&(Math.sign=function(e){return 0>e?-1:0<e?1:+e}),!1=="name"in Function.prototype&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),i=1;i<arguments.length;i++){var r=arguments[i];if(null!=r)for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}),Object.assign(t.prototype,{addEventListener:function(e,t){void 0===this._listeners&&(this._listeners={});var i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)},hasEventListener:function(e,t){if(void 0===this._listeners)return!1;var i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)},removeEventListener:function(e,t){void 0!==this._listeners&&(void 0!==(e=this._listeners[e])&&(-1!==(t=e.indexOf(t))&&e.splice(t,1)))},dispatchEvent:function(e){if(void 0!==this._listeners){var t=this._listeners[e.type];if(void 0!==t){e.target=this;for(var i=0,r=(t=t.slice(0)).length;i<r;i++)t[i].call(this,e)}}}});var wn,Sn,An={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){for(var e=[],t=0;256>t;t++)e[t]=(16>t?"0":"")+t.toString(16);return function(){var t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,r=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]+"-"+e[255&i]+e[i>>8&255]+"-"+e[i>>16&15|64]+e[i>>24&255]+"-"+e[63&r|128]+e[r>>8&255]+"-"+e[r>>16&255]+e[r>>24&255]+e[255&n]+e[n>>8&255]+e[n>>16&255]+e[n>>24&255]).toUpperCase()}}(),clamp:function(e,t,i){return Math.max(t,Math.min(i,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,i,r,n){return r+(e-t)*(n-r)/(i-t)},lerp:function(e,t,i){return(1-i)*e+i*t},smoothstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*(3-2*e)},smootherstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*An.DEG2RAD},radToDeg:function(e){return e*An.RAD2DEG},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}};Object.defineProperties(i.prototype,{width:{get:function(){return this.x},set:function(e){this.x=e}},height:{get:function(){return this.y},set:function(e){this.y=e}}}),Object.assign(i.prototype,{isVector2:!0,set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.y=this.x=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},applyMatrix3:function(e){var t=this.x,i=this.y;return e=e.elements,this.x=e[0]*t+e[3]*i+e[6],this.y=e[1]*t+e[4]*i+e[7],this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:(wn=new i,Sn=new i,function(e,t){return wn.set(e,e),Sn.set(t,t),this.clamp(wn,Sn)}),clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},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=0>this.x?Math.ceil(this.x):Math.floor(this.x),this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.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)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var e=Math.atan2(this.y,this.x);return 0>e&&(e+=2*Math.PI),e},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x;return t*t+(e=this.y-e.y)*e},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromBufferAttribute:function(e,t,i){return void 0!==i&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this},rotateAround:function(e,t){var i=Math.cos(t);t=Math.sin(t);var r=this.x-e.x,n=this.y-e.y;return this.x=r*i-n*t+e.x,this.y=r*t+n*i+e.y,this}}),Object.assign(r.prototype,{isMatrix4:!0,set:function(e,t,i,r,n,o,s,a,h,c,l,u,d,f,p,m){var g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=r,g[1]=n,g[5]=o,g[9]=s,g[13]=a,g[2]=h,g[6]=c,g[10]=l,g[14]=u,g[3]=d,g[7]=f,g[11]=p,g[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 r).fromArray(this.elements)},copy:function(e){var t=this.elements;return e=e.elements,t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],this},copyPosition:function(e){var t=this.elements;return e=e.elements,t[12]=e[12],t[13]=e[13],t[14]=e[14],this},extractBasis:function(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this},extractRotation:function(){var e=new o;return function(t){var i=this.elements,r=t.elements,n=1/e.setFromMatrixColumn(t,0).length(),o=1/e.setFromMatrixColumn(t,1).length();return t=1/e.setFromMatrixColumn(t,2).length(),i[0]=r[0]*n,i[1]=r[1]*n,i[2]=r[2]*n,i[4]=r[4]*o,i[5]=r[5]*o,i[6]=r[6]*o,i[8]=r[8]*t,i[9]=r[9]*t,i[10]=r[10]*t,this}}(),makeRotationFromEuler:function(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t=this.elements,i=e.x,r=e.y,n=e.z,o=Math.cos(i);i=Math.sin(i);var s=Math.cos(r);r=Math.sin(r);var a=Math.cos(n);if(n=Math.sin(n),"XYZ"===e.order){e=o*a;var h=o*n,c=i*a,l=i*n;t[0]=s*a,t[4]=-s*n,t[8]=r,t[1]=h+c*r,t[5]=e-l*r,t[9]=-i*s,t[2]=l-e*r,t[6]=c+h*r,t[10]=o*s}else"YXZ"===e.order?(e=s*a,h=s*n,c=r*a,l=r*n,t[0]=e+l*i,t[4]=c*i-h,t[8]=o*r,t[1]=o*n,t[5]=o*a,t[9]=-i,t[2]=h*i-c,t[6]=l+e*i,t[10]=o*s):"ZXY"===e.order?(e=s*a,h=s*n,c=r*a,l=r*n,t[0]=e-l*i,t[4]=-o*n,t[8]=c+h*i,t[1]=h+c*i,t[5]=o*a,t[9]=l-e*i,t[2]=-o*r,t[6]=i,t[10]=o*s):"ZYX"===e.order?(e=o*a,h=o*n,c=i*a,l=i*n,t[0]=s*a,t[4]=c*r-h,t[8]=e*r+l,t[1]=s*n,t[5]=l*r+e,t[9]=h*r-c,t[2]=-r,t[6]=i*s,t[10]=o*s):"YZX"===e.order?(e=o*s,h=o*r,c=i*s,l=i*r,t[0]=s*a,t[4]=l-e*n,t[8]=c*n+h,t[1]=n,t[5]=o*a,t[9]=-i*a,t[2]=-r*a,t[6]=h*n+c,t[10]=e-l*n):"XZY"===e.order&&(e=o*s,h=o*r,c=i*s,l=i*r,t[0]=s*a,t[4]=-n,t[8]=r*a,t[1]=e*n+l,t[5]=o*a,t[9]=h*n-c,t[2]=c*n-h,t[6]=i*a,t[10]=l*n+e);return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(e){var t=this.elements,i=e._x,r=e._y,n=e._z,o=e._w,s=i+i,a=r+r,h=n+n;e=i*s;var c=i*a;i*=h;var l=r*a;return r*=h,n*=h,s*=o,a*=o,o*=h,t[0]=1-(l+n),t[4]=c-o,t[8]=i+a,t[1]=c+o,t[5]=1-(e+n),t[9]=r-s,t[2]=i-a,t[6]=r+s,t[10]=1-(e+l),t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},lookAt:function(){var e=new o,t=new o,i=new o;return function(r,n,o){var s=this.elements;return i.subVectors(r,n),0===i.lengthSq()&&(i.z=1),i.normalize(),e.crossVectors(o,i),0===e.lengthSq()&&(1===Math.abs(o.z)?i.x+=1e-4:i.z+=1e-4,i.normalize(),e.crossVectors(o,i)),e.normalize(),t.crossVectors(i,e),s[0]=e.x,s[4]=t.x,s[8]=i.x,s[1]=e.y,s[5]=t.y,s[9]=i.y,s[2]=e.z,s[6]=t.z,s[10]=i.z,this}}(),multiply:function(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var i=e.elements,r=t.elements;t=this.elements,e=i[0];var n=i[4],o=i[8],s=i[12],a=i[1],h=i[5],c=i[9],l=i[13],u=i[2],d=i[6],f=i[10],p=i[14],m=i[3],g=i[7],v=i[11];i=i[15];var _=r[0],y=r[4],x=r[8],b=r[12],M=r[1],E=r[5],T=r[9],w=r[13],S=r[2],A=r[6],P=r[10],C=r[14],D=r[3],R=r[7],I=r[11];return r=r[15],t[0]=e*_+n*M+o*S+s*D,t[4]=e*y+n*E+o*A+s*R,t[8]=e*x+n*T+o*P+s*I,t[12]=e*b+n*w+o*C+s*r,t[1]=a*_+h*M+c*S+l*D,t[5]=a*y+h*E+c*A+l*R,t[9]=a*x+h*T+c*P+l*I,t[13]=a*b+h*w+c*C+l*r,t[2]=u*_+d*M+f*S+p*D,t[6]=u*y+d*E+f*A+p*R,t[10]=u*x+d*T+f*P+p*I,t[14]=u*b+d*w+f*C+p*r,t[3]=m*_+g*M+v*S+i*D,t[7]=m*y+g*E+v*A+i*R,t[11]=m*x+g*T+v*P+i*I,t[15]=m*b+g*w+v*C+i*r,this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},applyToBufferAttribute:function(){var e=new o;return function(t){for(var i=0,r=t.count;i<r;i++)e.x=t.getX(i),e.y=t.getY(i),e.z=t.getZ(i),e.applyMatrix4(this),t.setXYZ(i,e.x,e.y,e.z);return t}}(),determinant:function(){var e=this.elements,t=e[0],i=e[4],r=e[8],n=e[12],o=e[1],s=e[5],a=e[9],h=e[13],c=e[2],l=e[6],u=e[10],d=e[14];return e[3]*(+n*a*l-r*h*l-n*s*u+i*h*u+r*s*d-i*a*d)+e[7]*(+t*a*d-t*h*u+n*o*u-r*o*d+r*h*c-n*a*c)+e[11]*(+t*h*l-t*s*d-n*o*l+i*o*d+n*s*c-i*h*c)+e[15]*(-r*s*c-t*a*l+t*s*u+r*o*l-i*o*u+i*a*c)},transpose:function(){var e=this.elements,t=e[1];return 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},setPosition:function(e){var t=this.elements;return t[12]=e.x,t[13]=e.y,t[14]=e.z,this},getInverse:function(e,t){var i=this.elements,r=e.elements;e=r[0];var n=r[1],o=r[2],s=r[3],a=r[4],h=r[5],c=r[6],l=r[7],u=r[8],d=r[9],f=r[10],p=r[11],m=r[12],g=r[13],v=r[14],_=d*v*l-g*f*l+g*c*p-h*v*p-d*c*(r=r[15])+h*f*r,y=m*f*l-u*v*l-m*c*p+a*v*p+u*c*r-a*f*r,x=u*g*l-m*d*l+m*h*p-a*g*p-u*h*r+a*d*r,b=m*d*c-u*g*c-m*h*f+a*g*f+u*h*v-a*d*v,M=e*_+n*y+o*x+s*b;if(0===M){if(!0===t)throw Error("THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0");return console.warn("THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0"),this.identity()}return t=1/M,i[0]=_*t,i[1]=(g*f*s-d*v*s-g*o*p+n*v*p+d*o*r-n*f*r)*t,i[2]=(h*v*s-g*c*s+g*o*l-n*v*l-h*o*r+n*c*r)*t,i[3]=(d*c*s-h*f*s-d*o*l+n*f*l+h*o*p-n*c*p)*t,i[4]=y*t,i[5]=(u*v*s-m*f*s+m*o*p-e*v*p-u*o*r+e*f*r)*t,i[6]=(m*c*s-a*v*s-m*o*l+e*v*l+a*o*r-e*c*r)*t,i[7]=(a*f*s-u*c*s+u*o*l-e*f*l-a*o*p+e*c*p)*t,i[8]=x*t,i[9]=(m*d*s-u*g*s-m*n*p+e*g*p+u*n*r-e*d*r)*t,i[10]=(a*g*s-m*h*s+m*n*l-e*g*l-a*n*r+e*h*r)*t,i[11]=(u*h*s-a*d*s-u*n*l+e*d*l+a*n*p-e*h*p)*t,i[12]=b*t,i[13]=(u*g*o-m*d*o+m*n*f-e*g*f-u*n*v+e*d*v)*t,i[14]=(m*h*o-a*g*o-m*n*c+e*g*c+a*n*v-e*h*v)*t,i[15]=(a*d*o-u*h*o+u*n*c-e*d*c-a*n*f+e*h*f)*t,this},scale:function(e){var t=this.elements,i=e.x,r=e.y;return e=e.z,t[0]*=i,t[4]*=r,t[8]*=e,t[1]*=i,t[5]*=r,t[9]*=e,t[2]*=i,t[6]*=r,t[10]*=e,t[3]*=i,t[7]*=r,t[11]*=e,this},getMaxScaleOnAxis:function(){var e=this.elements;return Math.sqrt(Math.max(e[0]*e[0]+e[1]*e[1]+e[2]*e[2],e[4]*e[4]+e[5]*e[5]+e[6]*e[6],e[8]*e[8]+e[9]*e[9]+e[10]*e[10]))},makeTranslation:function(e,t,i){return this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this},makeRotationX:function(e){var t=Math.cos(e);return e=Math.sin(e),this.set(1,0,0,0,0,t,-e,0,0,e,t,0,0,0,0,1),this},makeRotationY:function(e){var t=Math.cos(e);return e=Math.sin(e),this.set(t,0,e,0,0,1,0,0,-e,0,t,0,0,0,0,1),this},makeRotationZ:function(e){var t=Math.cos(e);return e=Math.sin(e),this.set(t,-e,0,0,e,t,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(e,t){var i=Math.cos(t);t=Math.sin(t);var r=1-i,n=e.x,o=e.y;e=e.z;var s=r*n,a=r*o;return this.set(s*n+i,s*o-t*e,s*e+t*o,0,s*o+t*e,a*o+i,a*e-t*n,0,s*e-t*o,a*e+t*n,r*e*e+i,0,0,0,0,1),this},makeScale:function(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this},makeShear:function(e,t,i){return this.set(1,t,i,0,e,1,i,0,e,t,1,0,0,0,0,1),this},compose:function(e,t,i){return this.makeRotationFromQuaternion(t),this.scale(i),this.setPosition(e),this},decompose:function(){var e=new o,t=new r;return function(i,r,n){var o=this.elements,s=e.set(o[0],o[1],o[2]).length(),a=e.set(o[4],o[5],o[6]).length(),h=e.set(o[8],o[9],o[10]).length();0>this.determinant()&&(s=-s),i.x=o[12],i.y=o[13],i.z=o[14],t.copy(this),i=1/s,o=1/a;var c=1/h;return t.elements[0]*=i,t.elements[1]*=i,t.elements[2]*=i,t.elements[4]*=o,t.elements[5]*=o,t.elements[6]*=o,t.elements[8]*=c,t.elements[9]*=c,t.elements[10]*=c,r.setFromRotationMatrix(t),n.x=s,n.y=a,n.z=h,this}}(),makePerspective:function(e,t,i,r,n,o){void 0===o&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var s=this.elements;return s[0]=2*n/(t-e),s[4]=0,s[8]=(t+e)/(t-e),s[12]=0,s[1]=0,s[5]=2*n/(i-r),s[9]=(i+r)/(i-r),s[13]=0,s[2]=0,s[6]=0,s[10]=-(o+n)/(o-n),s[14]=-2*o*n/(o-n),s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this},makeOrthographic:function(e,t,i,r,n,o){var s=this.elements,a=1/(t-e),h=1/(i-r),c=1/(o-n);return s[0]=2*a,s[4]=0,s[8]=0,s[12]=-(t+e)*a,s[1]=0,s[5]=2*h,s[9]=0,s[13]=-(i+r)*h,s[2]=0,s[6]=0,s[10]=-2*c,s[14]=-(o+n)*c,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this},equals:function(e){var t=this.elements;e=e.elements;for(var i=0;16>i;i++)if(t[i]!==e[i])return!1;return!0},fromArray:function(e,t){void 0===t&&(t=0);for(var i=0;16>i;i++)this.elements[i]=e[i+t];return this},toArray:function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);var i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}),Object.assign(n,{slerp:function(e,t,i,r){return i.copy(e).slerp(t,r)},slerpFlat:function(e,t,i,r,n,o,s){var a=i[r+0],h=i[r+1],c=i[r+2];i=i[r+3],r=n[o+0];var l=n[o+1],u=n[o+2];if(i!==(n=n[o+3])||a!==r||h!==l||c!==u){o=1-s;var d=a*r+h*l+c*u+i*n,f=0<=d?1:-1,p=1-d*d;p>Number.EPSILON&&(p=Math.sqrt(p),d=Math.atan2(p,d*f),o=Math.sin(o*d)/p,s=Math.sin(s*d)/p),a=a*o+r*(f*=s),h=h*o+l*f,c=c*o+u*f,i=i*o+n*f,o===1-s&&(a*=s=1/Math.sqrt(a*a+h*h+c*c+i*i),h*=s,c*=s,i*=s)}e[t]=a,e[t+1]=h,e[t+2]=c,e[t+3]=i}}),Object.defineProperties(n.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this.onChangeCallback()}}}),Object.assign(n.prototype,{set:function(e,t,i,r){return this._x=e,this._y=t,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(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this.onChangeCallback(),this},setFromEuler:function(e,t){if(!e||!e.isEuler)throw Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var i=e._x,r=e._y,n=e._z;e=e.order;var o=Math.cos,s=Math.sin,a=o(i/2),h=o(r/2);return o=o(n/2),i=s(i/2),r=s(r/2),n=s(n/2),"XYZ"===e?(this._x=i*h*o+a*r*n,this._y=a*r*o-i*h*n,this._z=a*h*n+i*r*o,this._w=a*h*o-i*r*n):"YXZ"===e?(this._x=i*h*o+a*r*n,this._y=a*r*o-i*h*n,this._z=a*h*n-i*r*o,this._w=a*h*o+i*r*n):"ZXY"===e?(this._x=i*h*o-a*r*n,this._y=a*r*o+i*h*n,this._z=a*h*n+i*r*o,this._w=a*h*o-i*r*n):"ZYX"===e?(this._x=i*h*o-a*r*n,this._y=a*r*o+i*h*n,this._z=a*h*n-i*r*o,this._w=a*h*o+i*r*n):"YZX"===e?(this._x=i*h*o+a*r*n,this._y=a*r*o+i*h*n,this._z=a*h*n-i*r*o,this._w=a*h*o-i*r*n):"XZY"===e&&(this._x=i*h*o-a*r*n,this._y=a*r*o-i*h*n,this._z=a*h*n+i*r*o,this._w=a*h*o+i*r*n),!1!==t&&this.onChangeCallback(),this},setFromAxisAngle:function(e,t){t/=2;var i=Math.sin(t);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(t),this.onChangeCallback(),this},setFromRotationMatrix:function(e){var t=e.elements,i=t[0];e=t[4];var r=t[8],n=t[1],o=t[5],s=t[9],a=t[2],h=t[6],c=i+o+(t=t[10]);return 0<c?(i=.5/Math.sqrt(c+1),this._w=.25/i,this._x=(h-s)*i,this._y=(r-a)*i,this._z=(n-e)*i):i>o&&i>t?(i=2*Math.sqrt(1+i-o-t),this._w=(h-s)/i,this._x=.25*i,this._y=(e+n)/i,this._z=(r+a)/i):o>t?(i=2*Math.sqrt(1+o-i-t),this._w=(r-a)/i,this._x=(e+n)/i,this._y=.25*i,this._z=(s+h)/i):(i=2*Math.sqrt(1+t-i-o),this._w=(n-e)/i,this._x=(r+a)/i,this._y=(s+h)/i,this._z=.25*i),this.onChangeCallback(),this},setFromUnitVectors:function(){var e,t=new o;return function(i,r){return void 0===t&&(t=new o),1e-6>(e=i.dot(r)+1)?(e=0,Math.abs(i.x)>Math.abs(i.z)?t.set(-i.y,i.x,0):t.set(0,-i.z,i.y)):t.crossVectors(i,r),this._x=t.x,this._y=t.y,this._z=t.z,this._w=e,this.normalize()}}(),inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return 0===e?(this._z=this._y=this._x=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this.onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var i=e._x,r=e._y,n=e._z;e=e._w;var o=t._x,s=t._y,a=t._z;return t=t._w,this._x=i*t+e*o+r*a-n*s,this._y=r*t+e*s+n*o-i*a,this._z=n*t+e*a+i*s-r*o,this._w=e*t-i*o-r*s-n*a,this.onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var i=this._x,r=this._y,n=this._z,o=this._w,s=o*e._w+i*e._x+r*e._y+n*e._z;if(0>s?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,s=-s):this.copy(e),1<=s)return this._w=o,this._x=i,this._y=r,this._z=n,this;if(e=Math.sqrt(1-s*s),.001>Math.abs(e))return this._w=.5*(o+this._w),this._x=.5*(i+this._x),this._y=.5*(r+this._y),this._z=.5*(n+this._z),this;var a=Math.atan2(e,s);return s=Math.sin((1-t)*a)/e,t=Math.sin(t*a)/e,this._w=o*s+this._w*t,this._x=i*s+this._x*t,this._y=r*s+this._y*t,this._z=n*s+this._z*t,this.onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}}),Object.assign(o.prototype,{isVector3:!0,set:function(e,t,i){return this.x=e,this.y=t,this.z=i,this},setScalar:function(e){return this.z=this.y=this.x=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:function(){var e=new n;return function(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(e.setFromEuler(t))}}(),applyAxisAngle:function(){var e=new n;return function(t,i){return this.applyQuaternion(e.setFromAxisAngle(t,i))}}(),applyMatrix3:function(e){var t=this.x,i=this.y,r=this.z;return e=e.elements,this.x=e[0]*t+e[3]*i+e[6]*r,this.y=e[1]*t+e[4]*i+e[7]*r,this.z=e[2]*t+e[5]*i+e[8]*r,this},applyMatrix4:function(e){var t=this.x,i=this.y,r=this.z,n=1/((e=e.elements)[3]*t+e[7]*i+e[11]*r+e[15]);return this.x=(e[0]*t+e[4]*i+e[8]*r+e[12])*n,this.y=(e[1]*t+e[5]*i+e[9]*r+e[13])*n,this.z=(e[2]*t+e[6]*i+e[10]*r+e[14])*n,this},applyQuaternion:function(e){var t=this.x,i=this.y,r=this.z,n=e.x,o=e.y,s=e.z,a=(e=e.w)*t+o*r-s*i,h=e*i+s*t-n*r,c=e*r+n*i-o*t;return t=-n*t-o*i-s*r,this.x=a*e+t*-n+h*-s-c*-o,this.y=h*e+t*-o+c*-n-a*-s,this.z=c*e+t*-s+a*-o-h*-n,this},project:function(){var e=new r;return function(t){return e.multiplyMatrices(t.projectionMatrix,e.getInverse(t.matrixWorld)),this.applyMatrix4(e)}}(),unproject:function(){var e=new r;return function(t){return e.multiplyMatrices(t.matrixWorld,e.getInverse(t.projectionMatrix)),this.applyMatrix4(e)}}(),transformDirection:function(e){var t=this.x,i=this.y,r=this.z;return e=e.elements,this.x=e[0]*t+e[4]*i+e[8]*r,this.y=e[1]*t+e[5]*i+e[9]*r,this.z=e[2]*t+e[6]*i+e[10]*r,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(){var e=new o,t=new o;return function(i,r){return e.set(i,i,i),t.set(r,r,r),this.clamp(e,t)}}(),clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},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=0>this.x?Math.ceil(this.x):Math.floor(this.x),this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y),this.z=0>this.z?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(e){return this.x*e.x+this.y*e.y+this.z*e.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)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e)},cross:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)},crossVectors:function(e,t){var i=e.x,r=e.y;e=e.z;var n=t.x,o=t.y;return t=t.z,this.x=r*t-e*o,this.y=e*n-i*t,this.z=i*o-r*n,this},projectOnVector:function(e){var t=e.dot(this)/e.lengthSq();return this.copy(e).multiplyScalar(t)},projectOnPlane:function(){var e=new o;return function(t){return e.copy(this).projectOnVector(t),this.sub(e)}}(),reflect:function(){var e=new o;return function(t){return this.sub(e.copy(t).multiplyScalar(2*this.dot(t)))}}(),angleTo:function(e){return e=this.dot(e)/Math.sqrt(this.lengthSq()*e.lengthSq()),Math.acos(An.clamp(e,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y;return t*t+i*i+(e=this.z-e.z)*e},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){var t=Math.sin(e.phi)*e.radius;return this.x=t*Math.sin(e.theta),this.y=Math.cos(e.phi)*e.radius,this.z=t*Math.cos(e.theta),this},setFromCylindrical:function(e){return this.x=e.radius*Math.sin(e.theta),this.y=e.y,this.z=e.radius*Math.cos(e.theta),this},setFromMatrixPosition:function(e){return e=e.elements,this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length();return e=this.setFromMatrixColumn(e,2).length(),this.x=t,this.y=i,this.z=e,this},setFromMatrixColumn:function(e,t){return this.fromArray(e.elements,4*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromBufferAttribute:function(e,t,i){return void 0!==i&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}}),Object.assign(s.prototype,{isMatrix3:!0,set:function(e,t,i,r,n,o,s,a,h){var c=this.elements;return c[0]=e,c[1]=r,c[2]=s,c[3]=t,c[4]=n,c[5]=a,c[6]=i,c[7]=o,c[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(e){var t=this.elements;return e=e.elements,t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],this},setFromMatrix4:function(e){return e=e.elements,this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},applyToBufferAttribute:function(){var e=new o;return function(t){for(var i=0,r=t.count;i<r;i++)e.x=t.getX(i),e.y=t.getY(i),e.z=t.getZ(i),e.applyMatrix3(this),t.setXYZ(i,e.x,e.y,e.z);return t}}(),multiply:function(e){return this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var i=e.elements,r=t.elements;t=this.elements,e=i[0];var n=i[3],o=i[6],s=i[1],a=i[4],h=i[7],c=i[2],l=i[5];i=i[8];var u=r[0],d=r[3],f=r[6],p=r[1],m=r[4],g=r[7],v=r[2],_=r[5];return r=r[8],t[0]=e*u+n*p+o*v,t[3]=e*d+n*m+o*_,t[6]=e*f+n*g+o*r,t[1]=s*u+a*p+h*v,t[4]=s*d+a*m+h*_,t[7]=s*f+a*g+h*r,t[2]=c*u+l*p+i*v,t[5]=c*d+l*m+i*_,t[8]=c*f+l*g+i*r,this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this},determinant:function(){var e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],o=e[4],s=e[5],a=e[6],h=e[7];return t*o*(e=e[8])-t*s*h-i*n*e+i*s*a+r*n*h-r*o*a},getInverse:function(e,t){e&&e.isMatrix4&&console.error("THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument.");var i=e.elements;e=this.elements;var r=i[0],n=i[1],o=i[2],s=i[3],a=i[4],h=i[5],c=i[6],l=i[7],u=(i=i[8])*a-h*l,d=h*c-i*s,f=l*s-a*c,p=r*u+n*d+o*f;if(0===p){if(!0===t)throw Error("THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0");return console.warn("THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0"),this.identity()}return t=1/p,e[0]=u*t,e[1]=(o*l-i*n)*t,e[2]=(h*n-o*a)*t,e[3]=d*t,e[4]=(i*r-o*c)*t,e[5]=(o*s-h*r)*t,e[6]=f*t,e[7]=(n*c-l*r)*t,e[8]=(a*r-n*s)*t,this},transpose:function(){var e=this.elements,t=e[1];return 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},getNormalMatrix:function(e){return this.setFromMatrix4(e).getInverse(this).transpose()},transposeIntoArray:function(e){var t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this},setUvTransform:function(e,t,i,r,n,o,s){var a=Math.cos(n);n=Math.sin(n),this.set(i*a,i*n,-i*(a*o+n*s)+o+e,-r*n,r*a,-r*(-n*o+a*s)+s+t,0,0,1)},scale:function(e,t){var i=this.elements;return i[0]*=e,i[3]*=e,i[6]*=e,i[1]*=t,i[4]*=t,i[7]*=t,this},rotate:function(e){var t=Math.cos(e);e=Math.sin(e);var i=this.elements,r=i[0],n=i[3],o=i[6],s=i[1],a=i[4],h=i[7];return i[0]=t*r+e*s,i[3]=t*n+e*a,i[6]=t*o+e*h,i[1]=-e*r+t*s,i[4]=-e*n+t*a,i[7]=-e*o+t*h,this},translate:function(e,t){var i=this.elements;return i[0]+=e*i[2],i[3]+=e*i[5],i[6]+=e*i[8],i[1]+=t*i[2],i[4]+=t*i[5],i[7]+=t*i[8],this},equals:function(e){var t=this.elements;e=e.elements;for(var i=0;9>i;i++)if(t[i]!==e[i])return!1;return!0},fromArray:function(e,t){void 0===t&&(t=0);for(var i=0;9>i;i++)this.elements[i]=e[i+t];return this},toArray:function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);var i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}});var Pn=0;a.DEFAULT_IMAGE=void 0,a.DEFAULT_MAPPING=300,a.prototype=Object.assign(Object.create(t.prototype),{constructor:a,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this},toJSON:function(e){var t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];var i={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var r=this.image;if(void 0===r.uuid&&(r.uuid=An.generateUUID()),!t&&void 0===e.images[r.uuid]){var n=e.images,o=r.uuid,s=r.uuid;if(r instanceof HTMLCanvasElement)var a=r;else{(a=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")).width=r.width,a.height=r.height;var h=a.getContext("2d");r instanceof ImageData?h.putImageData(r,0,0):h.drawImage(r,0,0,r.width,r.height)}a=2048<a.width||2048<a.height?a.toDataURL("image/jpeg",.6):a.toDataURL("image/png"),n[o]={uuid:s,url:a}}i.image=r.uuid}return t||(e.textures[this.uuid]=i),i},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(e){if(300===this.mapping){if(e.applyMatrix3(this.matrix),0>e.x||1<e.x)switch(this.wrapS){case 1e3:e.x-=Math.floor(e.x);break;case 1001:e.x=0>e.x?0:1;break;case 1002:e.x=1===Math.abs(Math.floor(e.x)%2)?Math.ceil(e.x)-e.x:e.x-Math.floor(e.x)}if(0>e.y||1<e.y)switch(this.wrapT){case 1e3:e.y-=Math.floor(e.y);break;case 1001:e.y=0>e.y?0:1;break;case 1002:e.y=1===Math.abs(Math.floor(e.y)%2)?Math.ceil(e.y)-e.y:e.y-Math.floor(e.y)}this.flipY&&(e.y=1-e.y)}}}),Object.defineProperty(a.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(h.prototype,{isVector4:!0,set:function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},setScalar:function(e){return this.w=this.z=this.y=this.x=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var t=this.x,i=this.y,r=this.z,n=this.w;return e=e.elements,this.x=e[0]*t+e[4]*i+e[8]*r+e[12]*n,this.y=e[1]*t+e[5]*i+e[9]*r+e[13]*n,this.z=e[2]*t+e[6]*i+e[10]*r+e[14]*n,this.w=e[3]*t+e[7]*i+e[11]*r+e[15]*n,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return 1e-4>t?(this.x=1,this.z=this.y=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t=(e=e.elements)[0],i=e[4],r=e[8],n=e[1],o=e[5],s=e[9],a=e[2],h=e[6],c=e[10];return.01>Math.abs(i-n)&&.01>Math.abs(r-a)&&.01>Math.abs(s-h)?.1>Math.abs(i+n)&&.1>Math.abs(r+a)&&.1>Math.abs(s+h)&&.1>Math.abs(t+o+c-3)?(this.set(1,0,0,0),this):(e=Math.PI,c=(c+1)/2,i=(i+n)/4,r=(r+a)/4,s=(s+h)/4,(t=(t+1)/2)>(o=(o+1)/2)&&t>c?.01>t?(h=0,i=a=.707106781):(a=i/(h=Math.sqrt(t)),i=r/h):o>c?.01>o?(h=.707106781,a=0,i=.707106781):(h=i/(a=Math.sqrt(o)),i=s/a):.01>c?(a=h=.707106781,i=0):(h=r/(i=Math.sqrt(c)),a=s/i),this.set(h,a,i,e),this):(e=Math.sqrt((h-s)*(h-s)+(r-a)*(r-a)+(n-i)*(n-i)),.001>Math.abs(e)&&(e=1),this.x=(h-s)/e,this.y=(r-a)/e,this.z=(n-i)/e,this.w=Math.acos((t+o+c-1)/2),this)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this},clampScalar:function(){var e,t;return function(i,r){return void 0===e&&(e=new h,t=new h),e.set(i,i,i,i),t.set(r,r,r,r),this.clamp(e,t)}}(),clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},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=0>this.x?Math.ceil(this.x):Math.floor(this.x),this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y),this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z),this.w=0>this.w?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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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)},manhattanLength: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()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e},fromBufferAttribute:function(e,t,i){return void 0!==i&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}}),c.prototype=Object.assign(Object.create(t.prototype),{constructor:c,isWebGLRenderTarget:!0,setSize:function(e,t){this.width===e&&this.height===t||(this.width=e,this.height=t,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),l.prototype=Object.create(c.prototype),l.prototype.constructor=l,l.prototype.isWebGLRenderTargetCube=!0,u.prototype=Object.create(a.prototype),u.prototype.constructor=u,u.prototype.isDataTexture=!0,Object.assign(d.prototype,{isBox3:!0,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){for(var t=1/0,i=1/0,r=1/0,n=-1/0,o=-1/0,s=-1/0,a=0,h=e.length;a<h;a+=3){var c=e[a],l=e[a+1],u=e[a+2];c<t&&(t=c),l<i&&(i=l),u<r&&(r=u),c>n&&(n=c),l>o&&(o=l),u>s&&(s=u)}return this.min.set(t,i,r),this.max.set(n,o,s),this},setFromBufferAttribute:function(e){for(var t=1/0,i=1/0,r=1/0,n=-1/0,o=-1/0,s=-1/0,a=0,h=e.count;a<h;a++){var c=e.getX(a),l=e.getY(a),u=e.getZ(a);c<t&&(t=c),l<i&&(i=l),u<r&&(r=u),c>n&&(n=c),l>o&&(o=l),u>s&&(s=u)}return this.min.set(t,i,r),this.max.set(n,o,s),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this},setFromCenterAndSize:function(){var e=new o;return function(t,i){return i=e.copy(i).multiplyScalar(.5),this.min.copy(t).sub(i),this.max.copy(t).add(i),this}}(),setFromObject:function(e){return this.makeEmpty(),this.expandByObject(e)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},getCenter:function(e){return void 0===e&&(console.warn("THREE.Box3: .getCenter() target is now required"),e=new o),this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(e){return void 0===e&&(console.warn("THREE.Box3: .getSize() target is now required"),e=new o),this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)},expandByPoint:function(e){return this.min.min(e),this.max.max(e),this},expandByVector:function(e){return this.min.sub(e),this.max.add(e),this},expandByScalar:function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},expandByObject:function(){function e(e){var o=e.geometry;if(void 0!==o)if(o.isGeometry)for(o=o.vertices,i=0,r=o.length;i<r;i++)n.copy(o[i]),n.applyMatrix4(e.matrixWorld),t.expandByPoint(n);else if(o.isBufferGeometry&&void 0!==(o=o.attributes.position))for(i=0,r=o.count;i<r;i++)n.fromBufferAttribute(o,i).applyMatrix4(e.matrixWorld),t.expandByPoint(n)}var t,i,r,n=new o;return function(i){return t=this,i.updateMatrixWorld(!0),i.traverse(e),this}}(),containsPoint:function(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z},getParameter:function(e,t){return void 0===t&&(console.warn("THREE.Box3: .getParameter() target is now required"),t=new o),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)},intersectsSphere:function(){var e=new o;return function(t){return this.clampPoint(t.center,e),e.distanceToSquared(t.center)<=t.radius*t.radius}}(),intersectsPlane:function(e){if(0<e.normal.x)var t=e.normal.x*this.min.x,i=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,i=e.normal.x*this.min.x;return 0<e.normal.y?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),0<e.normal.z?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=e.constant&&i>=e.constant},intersectsTriangle:function(){function e(e){var n,o=0;for(n=e.length-3;o<=n;o+=3){h.fromArray(e,o);var s=l.x*Math.abs(h.x)+l.y*Math.abs(h.y)+l.z*Math.abs(h.z),a=t.dot(h),c=i.dot(h),u=r.dot(h);if(Math.max(-Math.max(a,c,u),Math.min(a,c,u))>s)return!1}return!0}var t=new o,i=new o,r=new o,n=new o,s=new o,a=new o,h=new o,c=new o,l=new o,u=new o;return function(o){return!this.isEmpty()&&(this.getCenter(c),l.subVectors(this.max,c),t.subVectors(o.a,c),i.subVectors(o.b,c),r.subVectors(o.c,c),n.subVectors(i,t),s.subVectors(r,i),a.subVectors(t,r),!!e(o=[0,-n.z,n.y,0,-s.z,s.y,0,-a.z,a.y,n.z,0,-n.x,s.z,0,-s.x,a.z,0,-a.x,-n.y,n.x,0,-s.y,s.x,0,-a.y,a.x,0])&&(!!e(o=[1,0,0,0,1,0,0,0,1])&&(u.crossVectors(n,s),e(o=[u.x,u.y,u.z]))))}}(),clampPoint:function(e,t){return void 0===t&&(console.warn("THREE.Box3: .clampPoint() target is now required"),t=new o),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new o;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),getBoundingSphere:function(){var e=new o;return function(t){return void 0===t&&(console.warn("THREE.Box3: .getBoundingSphere() target is now required"),t=new f),this.getCenter(t.center),t.radius=.5*this.getSize(e).length(),t}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(){var e=[new o,new o,new o,new o,new o,new o,new o,new o];return function(t){return this.isEmpty()?this:(e[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),e[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),e[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),e[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),e[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),e[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),e[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),e[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(e),this)}}(),translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}),Object.assign(f.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(){var e=new d;return function(t,i){var r=this.center;void 0!==i?r.copy(i):e.setFromPoints(t).getCenter(r);for(var n=i=0,o=t.length;n<o;n++)i=Math.max(i,r.distanceToSquared(t[n]));return this.radius=Math.sqrt(i),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.center.copy(e.center),this.radius=e.radius,this},empty:function(){return 0>=this.radius},containsPoint:function(e){return e.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(e){return e.distanceTo(this.center)-this.radius},intersectsSphere:function(e){var t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t},intersectsBox:function(e){return e.intersectsSphere(this)},intersectsPlane:function(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius},clampPoint:function(e,t){var i=this.center.distanceToSquared(e);return void 0===t&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),t=new o),t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t},getBoundingBox:function(e){return void 0===e&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),e=new d),e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}}),Object.assign(p.prototype,{set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(){var e=new o,t=new o;return function(i,r,n){return r=e.subVectors(n,r).cross(t.subVectors(i,r)).normalize(),this.setFromNormalAndCoplanarPoint(r,i),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return void 0===t&&(console.warn("THREE.Plane: .projectPoint() target is now required"),t=new o),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(){var e=new o;return function(t,i){void 0===i&&(console.warn("THREE.Plane: .intersectLine() target is now required"),i=new o);var r=t.delta(e),n=this.normal.dot(r);if(0===n){if(0===this.distanceToPoint(t.start))return i.copy(t.start)}else if(!(0>(n=-(t.start.dot(this.normal)+this.constant)/n)||1<n))return i.copy(r).multiplyScalar(n).add(t.start)}}(),intersectsLine:function(e){var t=this.distanceToPoint(e.start);return e=this.distanceToPoint(e.end),0>t&&0<e||0>e&&0<t},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return void 0===e&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),e=new o),e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new o,t=new s;return function(i,r){return r=r||t.getNormalMatrix(i),i=this.coplanarPoint(e).applyMatrix4(i),r=this.normal.applyMatrix3(r).normalize(),this.constant=-i.dot(r),this}}(),translate:function(e){return this.constant-=e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}}),Object.assign(m.prototype,{set:function(e,t,i,r,n,o){var s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(i),s[3].copy(r),s[4].copy(n),s[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,i=0;6>i;i++)t[i].copy(e.planes[i]);return this},setFromMatrix:function(e){var t=this.planes,i=e.elements;e=i[0];var r=i[1],n=i[2],o=i[3],s=i[4],a=i[5],h=i[6],c=i[7],l=i[8],u=i[9],d=i[10],f=i[11],p=i[12],m=i[13],g=i[14];return i=i[15],t[0].setComponents(o-e,c-s,f-l,i-p).normalize(),t[1].setComponents(o+e,c+s,f+l,i+p).normalize(),t[2].setComponents(o+r,c+a,f+u,i+m).normalize(),t[3].setComponents(o-r,c-a,f-u,i-m).normalize(),t[4].setComponents(o-n,c-h,f-d,i-g).normalize(),t[5].setComponents(o+n,c+h,f+d,i+g).normalize(),this},intersectsObject:function(){var e=new f;return function(t){var i=t.geometry;return null===i.boundingSphere&&i.computeBoundingSphere(),e.copy(i.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSprite:function(){var e=new f;return function(t){return e.center.set(0,0,0),e.radius=.7071067811865476,e.applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSphere:function(e){var t=this.planes,i=e.center;e=-e.radius;for(var r=0;6>r;r++)if(t[r].distanceToPoint(i)<e)return!1;return!0},intersectsBox:function(){var e=new o,t=new o;return function(i){for(var r=this.planes,n=0;6>n;n++){var o=r[n];e.x=0<o.normal.x?i.min.x:i.max.x,t.x=0<o.normal.x?i.max.x:i.min.x,e.y=0<o.normal.y?i.min.y:i.max.y,t.y=0<o.normal.y?i.max.y:i.min.y,e.z=0<o.normal.z?i.min.z:i.max.z,t.z=0<o.normal.z?i.max.z:i.min.z;var s=o.distanceToPoint(e);if(o=o.distanceToPoint(t),0>s&&0>o)return!1}return!0}}(),containsPoint:function(e){for(var t=this.planes,i=0;6>i;i++)if(0>t[i].distanceToPoint(e))return!1;return!0}});var Cn={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif\n",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"\nvec3 transformed = vec3( position );\n",beginnormal_vertex:"\nvec3 objectNormal = vec3( normal );\n",bsdfs:"float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE  = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS  = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\n",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1  (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale =  bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:"  gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M      = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM            = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D      = max( maxRange / maxRGB, 1.0 );\n\tD            = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value )  {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n  varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n",gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",lights_pars_begin:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight  ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n",lights_pars_maps:"#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3(    0, 1,    0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material )  GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material )  GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif\n",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifndef STANDARD\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif\n",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\tgl_Position.z *= gl_Position.w;\n\t#endif\n#endif\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif\n",normal_fragment_maps:"#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\t\tscale *= float( gl_FrontFacing ) * 2.0 - 1.0;\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256.,  256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"#if defined( DITHERING )\n  gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",dithering_pars_fragment:"#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif\n",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix  = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tonemapping_pars_fragment:"#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\n",uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n}\n",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_ENVMAP\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}\n",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_pars_maps>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_pars_maps>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_pars_maps>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <lights_pars_begin>\n#include <lights_pars_maps>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <fog_fragment>\n}\n",shadow_vert:"#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n"},Dn={merge:function(e){for(var t={},i=0;i<e.length;i++){var r,n=this.clone(e[i]);for(r in n)t[r]=n[r]}return t},clone:function(e){var t,i={};for(t in e)for(var r in i[t]={},e[t]){var n=e[t][r];n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture)?i[t][r]=n.clone():Array.isArray(n)?i[t][r]=n.slice():i[t][r]=n}return i}},Rn={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,rebeccapurple:6697881,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};Object.assign(g.prototype,{isColor:!0,r:1,g:1,b:1,set:function(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this},setScalar:function(e){return this.b=this.g=this.r=e,this},setHex:function(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,i){return this.r=e,this.g=t,this.b=i,this},setHSL:function(){function e(e,t,i){return 0>i&&(i+=1),1<i&&--i,i<1/6?e+6*(t-e)*i:.5>i?t:i<2/3?e+6*(t-e)*(2/3-i):e}return function(t,i,r){return t=An.euclideanModulo(t,1),i=An.clamp(i,0,1),r=An.clamp(r,0,1),0===i?this.r=this.g=this.b=r:(r=2*r-(i=.5>=r?r*(1+i):r+i-r*i),this.r=e(r,i,t+1/3),this.g=e(r,i,t),this.b=e(r,i,t-1/3)),this}}(),setStyle:function(e){function t(t){void 0!==t&&1>parseFloat(t)&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}var i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var r=i[2];switch(i[1]){case"rgb":case"rgba":if(i=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(i[1],10))/255,this.g=Math.min(255,parseInt(i[2],10))/255,this.b=Math.min(255,parseInt(i[3],10))/255,t(i[5]),this;if(i=/^(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(i[1],10))/100,this.g=Math.min(100,parseInt(i[2],10))/100,this.b=Math.min(100,parseInt(i[3],10))/100,t(i[5]),this;break;case"hsl":case"hsla":if(i=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(r)){r=parseFloat(i[1])/360;var n=parseInt(i[2],10)/100,o=parseInt(i[3],10)/100;return t(i[5]),this.setHSL(r,n,o)}}}else if(i=/^#([A-Fa-f0-9]+)$/.exec(e)){if(3===(r=(i=i[1]).length))return this.r=parseInt(i.charAt(0)+i.charAt(0),16)/255,this.g=parseInt(i.charAt(1)+i.charAt(1),16)/255,this.b=parseInt(i.charAt(2)+i.charAt(2),16)/255,this;if(6===r)return this.r=parseInt(i.charAt(0)+i.charAt(1),16)/255,this.g=parseInt(i.charAt(2)+i.charAt(3),16)/255,this.b=parseInt(i.charAt(4)+i.charAt(5),16)/255,this}return e&&0<e.length&&(void 0!==(i=Rn[e])?this.setHex(i):console.warn("THREE.Color: Unknown color "+e)),this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){return void 0===t&&(t=2),t=0<t?1/t:1,this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},convertGammaToLinear:function(){var e=this.r,t=this.g,i=this.b;return this.r=e*e,this.g=t*t,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(e){void 0===e&&(console.warn("THREE.Color: .getHSL() target is now required"),e={h:0,s:0,l:0});var t,i=this.r,r=this.g,n=this.b,o=Math.max(i,r,n),s=Math.min(i,r,n),a=(s+o)/2;if(s===o)s=t=0;else{var h=o-s;switch(s=.5>=a?h/(o+s):h/(2-o-s),o){case i:t=(r-n)/h+(r<n?6:0);break;case r:t=(n-i)/h+2;break;case n:t=(i-r)/h+4}t/=6}return e.h=t,e.s=s,e.l=a,e},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(){var e={};return function(t,i,r){return this.getHSL(e),e.h+=t,e.s+=i,e.l+=r,this.setHSL(e.h,e.s,e.l),this}}(),add:function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this},addColors:function(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this},addScalar:function(e){return this.r+=e,this.g+=e,this.b+=e,this},sub:function(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this},multiply:function(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this},multiplyScalar:function(e){return this.r*=e,this.g*=e,this.b*=e,this},lerp:function(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this},equals:function(e){return e.r===this.r&&e.g===this.g&&e.b===this.b},fromArray:function(e,t){return void 0===t&&(t=0),this.r=e[t],this.g=e[t+1],this.b=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e},toJSON:function(){return this.getHex()}});var In={common:{diffuse:{value:new g(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new s},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new i(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new g(16777215)}},lights:{ambientLightColor:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new g(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},uvTransform:{value:new s}}},Ln={basic:{uniforms:Dn.merge([In.common,In.specularmap,In.envmap,In.aomap,In.lightmap,In.fog]),vertexShader:Cn.meshbasic_vert,fragmentShader:Cn.meshbasic_frag},lambert:{uniforms:Dn.merge([In.common,In.specularmap,In.envmap,In.aomap,In.lightmap,In.emissivemap,In.fog,In.lights,{emissive:{value:new g(0)}}]),vertexShader:Cn.meshlambert_vert,fragmentShader:Cn.meshlambert_frag},phong:{uniforms:Dn.merge([In.common,In.specularmap,In.envmap,In.aomap,In.lightmap,In.emissivemap,In.bumpmap,In.normalmap,In.displacementmap,In.gradientmap,In.fog,In.lights,{emissive:{value:new g(0)},specular:{value:new g(1118481)},shininess:{value:30}}]),vertexShader:Cn.meshphong_vert,fragmentShader:Cn.meshphong_frag},standard:{uniforms:Dn.merge([In.common,In.envmap,In.aomap,In.lightmap,In.emissivemap,In.bumpmap,In.normalmap,In.displacementmap,In.roughnessmap,In.metalnessmap,In.fog,In.lights,{emissive:{value:new g(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Cn.meshphysical_vert,fragmentShader:Cn.meshphysical_frag},points:{uniforms:Dn.merge([In.points,In.fog]),vertexShader:Cn.points_vert,fragmentShader:Cn.points_frag},dashed:{uniforms:Dn.merge([In.common,In.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Cn.linedashed_vert,fragmentShader:Cn.linedashed_frag},depth:{uniforms:Dn.merge([In.common,In.displacementmap]),vertexShader:Cn.depth_vert,fragmentShader:Cn.depth_frag},normal:{uniforms:Dn.merge([In.common,In.bumpmap,In.normalmap,In.displacementmap,{opacity:{value:1}}]),vertexShader:Cn.normal_vert,fragmentShader:Cn.normal_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Cn.cube_vert,fragmentShader:Cn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Cn.equirect_vert,fragmentShader:Cn.equirect_frag},distanceRGBA:{uniforms:Dn.merge([In.common,In.displacementmap,{referencePosition:{value:new o},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Cn.distanceRGBA_vert,fragmentShader:Cn.distanceRGBA_frag},shadow:{uniforms:Dn.merge([In.lights,In.fog,{color:{value:new g(0)},opacity:{value:1}}]),vertexShader:Cn.shadow_vert,fragmentShader:Cn.shadow_frag}};Ln.physical={uniforms:Dn.merge([Ln.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:Cn.meshphysical_vert,fragmentShader:Cn.meshphysical_frag},_.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" "),_.DefaultOrder="XYZ",Object.defineProperties(_.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},order:{get:function(){return this._order},set:function(e){this._order=e,this.onChangeCallback()}}}),Object.assign(_.prototype,{isEuler:!0,set:function(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._order=r||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this.onChangeCallback(),this},setFromRotationMatrix:function(e,t,i){var r=An.clamp,n=e.elements;e=n[0];var o=n[4],s=n[8],a=n[1],h=n[5],c=n[9],l=n[2],u=n[6];return n=n[10],"XYZ"===(t=t||this._order)?(this._y=Math.asin(r(s,-1,1)),.99999>Math.abs(s)?(this._x=Math.atan2(-c,n),this._z=Math.atan2(-o,e)):(this._x=Math.atan2(u,h),this._z=0)):"YXZ"===t?(this._x=Math.asin(-r(c,-1,1)),.99999>Math.abs(c)?(this._y=Math.atan2(s,n),this._z=Math.atan2(a,h)):(this._y=Math.atan2(-l,e),this._z=0)):"ZXY"===t?(this._x=Math.asin(r(u,-1,1)),.99999>Math.abs(u)?(this._y=Math.atan2(-l,n),this._z=Math.atan2(-o,h)):(this._y=0,this._z=Math.atan2(a,e))):"ZYX"===t?(this._y=Math.asin(-r(l,-1,1)),.99999>Math.abs(l)?(this._x=Math.atan2(u,n),this._z=Math.atan2(a,e)):(this._x=0,this._z=Math.atan2(-o,h))):"YZX"===t?(this._z=Math.asin(r(a,-1,1)),.99999>Math.abs(a)?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-l,e)):(this._x=0,this._y=Math.atan2(s,n))):"XZY"===t?(this._z=Math.asin(-r(o,-1,1)),.99999>Math.abs(o)?(this._x=Math.atan2(u,h),this._y=Math.atan2(s,e)):(this._x=Math.atan2(-c,n),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+t),this._order=t,!1!==i&&this.onChangeCallback(),this},setFromQuaternion:function(){var e=new r;return function(t,i,r){return e.makeRotationFromQuaternion(t),this.setFromRotationMatrix(e,i,r)}}(),setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:function(){var e=new n;return function(t){return e.setFromEuler(this),this.setFromQuaternion(e,t)}}(),equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order},fromArray:function(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e},toVector3:function(e){return e?e.set(this._x,this._y,this._z):new o(this._x,this._y,this._z)},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}}),Object.assign(y.prototype,{set:function(e){this.mask=1<<e|0},enable:function(e){this.mask=this.mask|1<<e|0},toggle:function(e){this.mask^=1<<e|0},disable:function(e){this.mask&=~(1<<e|0)},test:function(e){return 0!=(this.mask&e.mask)}});var On=0;x.DefaultUp=new o(0,1,0),x.DefaultMatrixAutoUpdate=!0,x.prototype=Object.assign(Object.create(t.prototype),{constructor:x,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix:function(e){this.matrix.multiplyMatrices(e,this.matrix),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(e){return this.quaternion.premultiply(e),this},setRotationFromAxisAngle:function(e,t){this.quaternion.setFromAxisAngle(e,t)},setRotationFromEuler:function(e){this.quaternion.setFromEuler(e,!0)},setRotationFromMatrix:function(e){this.quaternion.setFromRotationMatrix(e)},setRotationFromQuaternion:function(e){this.quaternion.copy(e)},rotateOnAxis:function(){var e=new n;return function(t,i){return e.setFromAxisAngle(t,i),this.quaternion.multiply(e),this}}(),rotateOnWorldAxis:function(){var e=new n;return function(t,i){return e.setFromAxisAngle(t,i),this.quaternion.premultiply(e),this}}(),rotateX:function(){var e=new o(1,0,0);return function(t){return this.rotateOnAxis(e,t)}}(),rotateY:function(){var e=new o(0,1,0);return function(t){return this.rotateOnAxis(e,t)}}(),rotateZ:function(){var e=new o(0,0,1);return function(t){return this.rotateOnAxis(e,t)}}(),translateOnAxis:function(){var e=new o;return function(t,i){return e.copy(t).applyQuaternion(this.quaternion),this.position.add(e.multiplyScalar(i)),this}}(),translateX:function(){var e=new o(1,0,0);return function(t){return this.translateOnAxis(e,t)}}(),translateY:function(){var e=new o(0,1,0);return function(t){return this.translateOnAxis(e,t)}}(),translateZ:function(){var e=new o(0,0,1);return function(t){return this.translateOnAxis(e,t)}}(),localToWorld:function(e){return e.applyMatrix4(this.matrixWorld)},worldToLocal:function(){var e=new r;return function(t){return t.applyMatrix4(e.getInverse(this.matrixWorld))}}(),lookAt:function(){var e=new r,t=new o;return function(i,r,n){i.isVector3?t.copy(i):t.set(i,r,n),this.isCamera?e.lookAt(this.position,t,this.up):e.lookAt(t,this.position,this.up),this.quaternion.setFromRotationMatrix(e)}}(),add:function(e){if(1<arguments.length){for(var t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),e.parent=this,e.dispatchEvent({type:"added"}),this.children.push(e)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)},remove:function(e){if(1<arguments.length){for(var t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}return-1!==(t=this.children.indexOf(e))&&(e.parent=null,e.dispatchEvent({type:"removed"}),this.children.splice(t,1)),this},getObjectById:function(e){return this.getObjectByProperty("id",e)},getObjectByName:function(e){return this.getObjectByProperty("name",e)},getObjectByProperty:function(e,t){if(this[e]===t)return this;for(var i=0,r=this.children.length;i<r;i++){var n=this.children[i].getObjectByProperty(e,t);if(void 0!==n)return n}},getWorldPosition:function(e){return void 0===e&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),e=new o),this.updateMatrixWorld(!0),e.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(){var e=new o,t=new o;return function(i){return void 0===i&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),i=new n),this.updateMatrixWorld(!0),this.matrixWorld.decompose(e,i,t),i}}(),getWorldScale:function(){var e=new o,t=new n;return function(i){return void 0===i&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),i=new o),this.updateMatrixWorld(!0),this.matrixWorld.decompose(e,t,i),i}}(),getWorldDirection:function(){var e=new n;return function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),t=new o),this.getWorldQuaternion(e),t.set(0,0,1).applyQuaternion(e)}}(),raycast:function(){},traverse:function(e){e(this);for(var t=this.children,i=0,r=t.length;i<r;i++)t[i].traverse(e)},traverseVisible:function(e){if(!1!==this.visible){e(this);for(var t=this.children,i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}},traverseAncestors:function(e){var t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(var t=this.children,i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)},toJSON:function(e){function t(t,i){return void 0===t[i.uuid]&&(t[i.uuid]=i.toJSON(e)),i.uuid}function i(e){var t,i=[];for(t in e){var r=e[t];delete r.metadata,i.push(r)}return i}var r=void 0===e||"string"==typeof e,n={};r&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});var o={};if(o.uuid=this.uuid,o.type=this.type,""!==this.name&&(o.name=this.name),!0===this.castShadow&&(o.castShadow=!0),!0===this.receiveShadow&&(o.receiveShadow=!0),!1===this.visible&&(o.visible=!1),!1===this.frustumCulled&&(o.frustumCulled=!1),0!==this.renderOrder&&(o.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(o.userData=this.userData),o.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(o.matrixAutoUpdate=!1),void 0!==this.geometry){o.geometry=t(e.geometries,this.geometry);var s=this.geometry.parameters;if(void 0!==s&&void 0!==s.shapes)if(s=s.shapes,Array.isArray(s))for(var a=0,h=s.length;a<h;a++)t(e.shapes,s[a]);else t(e.shapes,s)}if(void 0!==this.material)if(Array.isArray(this.material)){for(s=[],a=0,h=this.material.length;a<h;a++)s.push(t(e.materials,this.material[a]));o.material=s}else o.material=t(e.materials,this.material);if(0<this.children.length)for(o.children=[],a=0;a<this.children.length;a++)o.children.push(this.children[a].toJSON(e).object);if(r){r=i(e.geometries),a=i(e.materials),h=i(e.textures);var c=i(e.images);s=i(e.shapes),0<r.length&&(n.geometries=r),0<a.length&&(n.materials=a),0<h.length&&(n.textures=h),0<c.length&&(n.images=c),0<s.length&&(n.shapes=s)}return n.object=o,n},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){if(void 0===t&&(t=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(t=0;t<e.children.length;t++)this.add(e.children[t].clone());return this}}),b.prototype=Object.assign(Object.create(x.prototype),{constructor:b,isCamera:!0,copy:function(e,t){return x.prototype.copy.call(this,e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this},getWorldDirection:function(){var e=new n;return function(t){return void 0===t&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),t=new o),this.getWorldQuaternion(e),t.set(0,0,-1).applyQuaternion(e)}}(),updateMatrixWorld:function(e){x.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),M.prototype=Object.assign(Object.create(b.prototype),{constructor:M,isOrthographicCamera:!0,copy:function(e,t){return b.prototype.copy.call(this,e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this},setViewOffset:function(e,t,i,r,n,o){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=n,this.view.height=o,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,n=i-e;if(i+=e,e=r+t,t=r-t,null!==this.view&&this.view.enabled){i=this.zoom/(this.view.width/this.view.fullWidth),t=this.zoom/(this.view.height/this.view.fullHeight);var o=(this.right-this.left)/this.view.width;r=(this.top-this.bottom)/this.view.height,i=(n+=this.view.offsetX/i*o)+this.view.width/i*o,t=(e-=this.view.offsetY/t*r)-this.view.height/t*r}this.projectionMatrix.makeOrthographic(n,i,e,t,this.near,this.far)},toJSON:function(e){return(e=x.prototype.toJSON.call(this,e)).object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}),Object.assign(E.prototype,{clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(var t=0,i=e.vertexNormals.length;t<i;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(t=0,i=e.vertexColors.length;t<i;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}});var Bn=0;T.prototype=Object.assign(Object.create(t.prototype),{constructor:T,isGeometry:!0,applyMatrix:function(e){for(var t=(new s).getNormalMatrix(e),i=0,r=this.vertices.length;i<r;i++)this.vertices[i].applyMatrix4(e);for(i=0,r=this.faces.length;i<r;i++){(e=this.faces[i]).normal.applyMatrix3(t).normalize();for(var n=0,o=e.vertexNormals.length;n<o;n++)e.vertexNormals[n].applyMatrix3(t).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.normalsNeedUpdate=this.verticesNeedUpdate=!0,this},rotateX:function(){var e=new r;return function(t){return e.makeRotationX(t),this.applyMatrix(e),this}}(),rotateY:function(){var e=new r;return function(t){return e.makeRotationY(t),this.applyMatrix(e),this}}(),rotateZ:function(){var e=new r;return function(t){return e.makeRotationZ(t),this.applyMatrix(e),this}}(),translate:function(){var e=new r;return function(t,i,r){return e.makeTranslation(t,i,r),this.applyMatrix(e),this}}(),scale:function(){var e=new r;return function(t,i,r){return e.makeScale(t,i,r),this.applyMatrix(e),this}}(),lookAt:function(){var e=new x;return function(t){e.lookAt(t),e.updateMatrix(),this.applyMatrix(e.matrix)}}(),fromBufferGeometry:function(e){function t(e,t,i,n){n=new E(e,t,i,void 0!==h?[d[e].clone(),d[t].clone(),d[i].clone()]:[],void 0!==c?[r.colors[e].clone(),r.colors[t].clone(),r.colors[i].clone()]:[],n),r.faces.push(n),void 0!==l&&r.faceVertexUvs[0].push([f[e].clone(),f[t].clone(),f[i].clone()]),void 0!==u&&r.faceVertexUvs[1].push([p[e].clone(),p[t].clone(),p[i].clone()])}var r=this,n=null!==e.index?e.index.array:void 0,s=e.attributes,a=s.position.array,h=void 0!==s.normal?s.normal.array:void 0,c=void 0!==s.color?s.color.array:void 0,l=void 0!==s.uv?s.uv.array:void 0,u=void 0!==s.uv2?s.uv2.array:void 0;void 0!==u&&(this.faceVertexUvs[1]=[]);for(var d=[],f=[],p=[],m=s=0;s<a.length;s+=3,m+=2)r.vertices.push(new o(a[s],a[s+1],a[s+2])),void 0!==h&&d.push(new o(h[s],h[s+1],h[s+2])),void 0!==c&&r.colors.push(new g(c[s],c[s+1],c[s+2])),void 0!==l&&f.push(new i(l[m],l[m+1])),void 0!==u&&p.push(new i(u[m],u[m+1]));var v=e.groups;if(0<v.length)for(s=0;s<v.length;s++){var _=(a=v[s]).start;for(m=_,_+=a.count;m<_;m+=3)void 0!==n?t(n[m],n[m+1],n[m+2],a.materialIndex):t(m,m+1,m+2,a.materialIndex)}else if(void 0!==n)for(s=0;s<n.length;s+=3)t(n[s],n[s+1],n[s+2]);else for(s=0;s<a.length/3;s+=3)t(s,s+1,s+2);return this.computeFaceNormals(),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this},center:function(){var e=new o;return function(){return this.computeBoundingBox(),this.boundingBox.getCenter(e).negate(),this.translate(e.x,e.y,e.z),this}}(),normalize:function(){this.computeBoundingSphere();var e=this.boundingSphere.center,t=this.boundingSphere.radius;t=0===t?1:1/t;var i=new r;return i.set(t,0,0,-t*e.x,0,t,0,-t*e.y,0,0,t,-t*e.z,0,0,0,1),this.applyMatrix(i),this},computeFaceNormals:function(){for(var e=new o,t=new o,i=0,r=this.faces.length;i<r;i++){var n=this.faces[i],s=this.vertices[n.a],a=this.vertices[n.b];e.subVectors(this.vertices[n.c],a),t.subVectors(s,a),e.cross(t),e.normalize(),n.normal.copy(e)}},computeVertexNormals:function(e){var t;void 0===e&&(e=!0);var i=Array(this.vertices.length),r=0;for(t=this.vertices.length;r<t;r++)i[r]=new o;if(e){var n=new o,s=new o;for(e=0,r=this.faces.length;e<r;e++){t=this.faces[e];var a=this.vertices[t.a],h=this.vertices[t.b],c=this.vertices[t.c];n.subVectors(c,h),s.subVectors(a,h),n.cross(s),i[t.a].add(n),i[t.b].add(n),i[t.c].add(n)}}else for(this.computeFaceNormals(),e=0,r=this.faces.length;e<r;e++)i[(t=this.faces[e]).a].add(t.normal),i[t.b].add(t.normal),i[t.c].add(t.normal);for(r=0,t=this.vertices.length;r<t;r++)i[r].normalize();for(e=0,r=this.faces.length;e<r;e++)3===(a=(t=this.faces[e]).vertexNormals).length?(a[0].copy(i[t.a]),a[1].copy(i[t.b]),a[2].copy(i[t.c])):(a[0]=i[t.a].clone(),a[1]=i[t.b].clone(),a[2]=i[t.c].clone());0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e;this.computeFaceNormals();var t=0;for(e=this.faces.length;t<e;t++){var i=this.faces[t],r=i.vertexNormals;3===r.length?(r[0].copy(i.normal),r[1].copy(i.normal),r[2].copy(i.normal)):(r[0]=i.normal.clone(),r[1]=i.normal.clone(),r[2]=i.normal.clone())}0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,i=0;for(t=this.faces.length;i<t;i++){var r=this.faces[i];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);var n=0;for(e=r.vertexNormals.length;n<e;n++)r.__originalVertexNormals[n]?r.__originalVertexNormals[n].copy(r.vertexNormals[n]):r.__originalVertexNormals[n]=r.vertexNormals[n].clone()}var s=new T;for(s.faces=this.faces,n=0,e=this.morphTargets.length;n<e;n++){if(!this.morphNormals[n]){this.morphNormals[n]={},this.morphNormals[n].faceNormals=[],this.morphNormals[n].vertexNormals=[],r=this.morphNormals[n].faceNormals;var a=this.morphNormals[n].vertexNormals;for(i=0,t=this.faces.length;i<t;i++){var h=new o,c={a:new o,b:new o,c:new o};r.push(h),a.push(c)}}for(a=this.morphNormals[n],s.vertices=this.morphTargets[n].vertices,s.computeFaceNormals(),s.computeVertexNormals(),i=0,t=this.faces.length;i<t;i++)r=this.faces[i],h=a.faceNormals[i],c=a.vertexNormals[i],h.copy(r.normal),c.a.copy(r.vertexNormals[0]),c.b.copy(r.vertexNormals[1]),c.c.copy(r.vertexNormals[2])}for(i=0,t=this.faces.length;i<t;i++)(r=this.faces[i]).normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new d),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new f),this.boundingSphere.setFromPoints(this.vertices)},merge:function(e,t,i){if(e&&e.isGeometry){var r,n=this.vertices.length,o=this.vertices,a=e.vertices,h=this.faces,c=e.faces,l=this.faceVertexUvs[0],u=e.faceVertexUvs[0],d=this.colors,f=e.colors;void 0===i&&(i=0),void 0!==t&&(r=(new s).getNormalMatrix(t)),e=0;for(var p=a.length;e<p;e++){var m=a[e].clone();void 0!==t&&m.applyMatrix4(t),o.push(m)}for(e=0,p=f.length;e<p;e++)d.push(f[e].clone());for(e=0,p=c.length;e<p;e++){var g=(a=c[e]).vertexNormals;for(f=a.vertexColors,(d=new E(a.a+n,a.b+n,a.c+n)).normal.copy(a.normal),void 0!==r&&d.normal.applyMatrix3(r).normalize(),t=0,o=g.length;t<o;t++)m=g[t].clone(),void 0!==r&&m.applyMatrix3(r).normalize(),d.vertexNormals.push(m);for(d.color.copy(a.color),t=0,o=f.length;t<o;t++)m=f[t],d.vertexColors.push(m.clone());d.materialIndex=a.materialIndex+i,h.push(d)}for(e=0,p=u.length;e<p;e++)if(r=[],void 0!==(i=u[e])){for(t=0,o=i.length;t<o;t++)r.push(i[t].clone());l.push(r)}}else console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e)},mergeMesh:function(e){e&&e.isMesh?(e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)):console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e)},mergeVertices:function(){var e,t={},i=[],r=[],n=Math.pow(10,4),o=0;for(e=this.vertices.length;o<e;o++){var s=this.vertices[o];void 0===t[s=Math.round(s.x*n)+"_"+Math.round(s.y*n)+"_"+Math.round(s.z*n)]?(t[s]=o,i.push(this.vertices[o]),r[o]=i.length-1):r[o]=r[t[s]]}for(t=[],o=0,e=this.faces.length;o<e;o++)for((n=this.faces[o]).a=r[n.a],n.b=r[n.b],n.c=r[n.c],n=[n.a,n.b,n.c],s=0;3>s;s++)if(n[s]===n[(s+1)%3]){t.push(o);break}for(o=t.length-1;0<=o;o--)for(n=t[o],this.faces.splice(n,1),r=0,e=this.faceVertexUvs.length;r<e;r++)this.faceVertexUvs[r].splice(n,1);return o=this.vertices.length-i.length,this.vertices=i,o},setFromPoints:function(e){this.vertices=[];for(var t=0,i=e.length;t<i;t++){var r=e[t];this.vertices.push(new o(r.x,r.y,r.z||0))}return this},sortFacesByMaterialIndex:function(){for(var e=this.faces,t=e.length,i=0;i<t;i++)e[i]._id=i;e.sort(function(e,t){return e.materialIndex-t.materialIndex});var r,n,o=this.faceVertexUvs[0],s=this.faceVertexUvs[1];for(o&&o.length===t&&(r=[]),s&&s.length===t&&(n=[]),i=0;i<t;i++){var a=e[i]._id;r&&r.push(o[a]),n&&n.push(s[a])}r&&(this.faceVertexUvs[0]=r),n&&(this.faceVertexUvs[1]=n)},toJSON:function(){function e(e,t,i){return i?e|1<<t:e&~(1<<t)}function t(e){var t=e.x.toString()+e.y.toString()+e.z.toString();return void 0!==c[t]?c[t]:(c[t]=h.length/3,h.push(e.x,e.y,e.z),c[t])}function i(e){var t=e.r.toString()+e.g.toString()+e.b.toString();return void 0!==u[t]?u[t]:(u[t]=l.length,l.push(e.getHex()),u[t])}function r(e){var t=e.x.toString()+e.y.toString();return void 0!==f[t]?f[t]:(f[t]=d.length/2,d.push(e.x,e.y),f[t])}var n={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),void 0!==this.parameters){var o,s=this.parameters;for(o in s)void 0!==s[o]&&(n[o]=s[o]);return n}for(s=[],o=0;o<this.vertices.length;o++){var a=this.vertices[o];s.push(a.x,a.y,a.z)}a=[];var h=[],c={},l=[],u={},d=[],f={};for(o=0;o<this.faces.length;o++){var p=this.faces[o],m=void 0!==this.faceVertexUvs[0][o],g=0<p.normal.length(),v=0<p.vertexNormals.length,_=1!==p.color.r||1!==p.color.g||1!==p.color.b,y=0<p.vertexColors.length,x=0;x=e(x=e(x=e(x=e(x=e(x=e(x=e(x=e(x,0,0),1,!0),2,!1),3,m),4,g),5,v),6,_),7,y),a.push(x),a.push(p.a,p.b,p.c),a.push(p.materialIndex),m&&(m=this.faceVertexUvs[0][o],a.push(r(m[0]),r(m[1]),r(m[2]))),g&&a.push(t(p.normal)),v&&(g=p.vertexNormals,a.push(t(g[0]),t(g[1]),t(g[2]))),_&&a.push(i(p.color)),y&&(p=p.vertexColors,a.push(i(p[0]),i(p[1]),i(p[2])))}return n.data={},n.data.vertices=s,n.data.normals=h,0<l.length&&(n.data.colors=l),0<d.length&&(n.data.uvs=[d]),n.data.faces=a,n},clone:function(){return(new T).copy(this)},copy:function(e){var t,i,r;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingSphere=this.boundingBox=null,this.name=e.name;var n=e.vertices,o=0;for(t=n.length;o<t;o++)this.vertices.push(n[o].clone());for(o=0,t=(n=e.colors).length;o<t;o++)this.colors.push(n[o].clone());for(o=0,t=(n=e.faces).length;o<t;o++)this.faces.push(n[o].clone());for(o=0,t=e.faceVertexUvs.length;o<t;o++){var s=e.faceVertexUvs[o];for(void 0===this.faceVertexUvs[o]&&(this.faceVertexUvs[o]=[]),n=0,i=s.length;n<i;n++){var a=s[n],h=[],c=0;for(r=a.length;c<r;c++)h.push(a[c].clone());this.faceVertexUvs[o].push(h)}}for(o=0,t=(c=e.morphTargets).length;o<t;o++){if((r={}).name=c[o].name,void 0!==c[o].vertices)for(r.vertices=[],n=0,i=c[o].vertices.length;n<i;n++)r.vertices.push(c[o].vertices[n].clone());if(void 0!==c[o].normals)for(r.normals=[],n=0,i=c[o].normals.length;n<i;n++)r.normals.push(c[o].normals[n].clone());this.morphTargets.push(r)}for(o=0,t=(c=e.morphNormals).length;o<t;o++){if(r={},void 0!==c[o].vertexNormals)for(r.vertexNormals=[],n=0,i=c[o].vertexNormals.length;n<i;n++)s=c[o].vertexNormals[n],(a={}).a=s.a.clone(),a.b=s.b.clone(),a.c=s.c.clone(),r.vertexNormals.push(a);if(void 0!==c[o].faceNormals)for(r.faceNormals=[],n=0,i=c[o].faceNormals.length;n<i;n++)r.faceNormals.push(c[o].faceNormals[n].clone());this.morphNormals.push(r)}for(o=0,t=(n=e.skinWeights).length;o<t;o++)this.skinWeights.push(n[o].clone());for(o=0,t=(n=e.skinIndices).length;o<t;o++)this.skinIndices.push(n[o].clone());for(o=0,t=(n=e.lineDistances).length;o<t;o++)this.lineDistances.push(n[o]);return null!==(o=e.boundingBox)&&(this.boundingBox=o.clone()),null!==(o=e.boundingSphere)&&(this.boundingSphere=o.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(w.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(w.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setArray:function(e){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");return this.count=void 0!==e?e.length/this.itemSize:0,this.array=e,this},setDynamic:function(e){return this.dynamic=e,this},copy:function(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.dynamic=e.dynamic,this},copyAt:function(e,t,i){e*=this.itemSize,i*=t.itemSize;for(var r=0,n=this.itemSize;r<n;r++)this.array[e+r]=t.array[i+r];return this},copyArray:function(e){return this.array.set(e),this},copyColorsArray:function(e){for(var t=this.array,i=0,r=0,n=e.length;r<n;r++){var o=e[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),o=new g),t[i++]=o.r,t[i++]=o.g,t[i++]=o.b}return this},copyVector2sArray:function(e){for(var t=this.array,r=0,n=0,o=e.length;n<o;n++){var s=e[n];void 0===s&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),s=new i),t[r++]=s.x,t[r++]=s.y}return this},copyVector3sArray:function(e){for(var t=this.array,i=0,r=0,n=e.length;r<n;r++){var s=e[r];void 0===s&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),s=new o),t[i++]=s.x,t[i++]=s.y,t[i++]=s.z}return this},copyVector4sArray:function(e){for(var t=this.array,i=0,r=0,n=e.length;r<n;r++){var o=e[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),o=new h),t[i++]=o.x,t[i++]=o.y,t[i++]=o.z,t[i++]=o.w}return this},set:function(e,t){return void 0===t&&(t=0),this.array.set(e,t),this},getX:function(e){return this.array[e*this.itemSize]},setX:function(e,t){return this.array[e*this.itemSize]=t,this},getY:function(e){return this.array[e*this.itemSize+1]},setY:function(e,t){return this.array[e*this.itemSize+1]=t,this},getZ:function(e){return this.array[e*this.itemSize+2]},setZ:function(e,t){return this.array[e*this.itemSize+2]=t,this},getW:function(e){return this.array[e*this.itemSize+3]},setW:function(e,t){return this.array[e*this.itemSize+3]=t,this},setXY:function(e,t,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this},setXYZ:function(e,t,i,r){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this},setXYZW:function(e,t,i,r,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=n,this},onUpload:function(e){return this.onUploadCallback=e,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)}}),S.prototype=Object.create(w.prototype),S.prototype.constructor=S,A.prototype=Object.create(w.prototype),A.prototype.constructor=A,P.prototype=Object.create(w.prototype),P.prototype.constructor=P,C.prototype=Object.create(w.prototype),C.prototype.constructor=C,D.prototype=Object.create(w.prototype),D.prototype.constructor=D,R.prototype=Object.create(w.prototype),R.prototype.constructor=R,I.prototype=Object.create(w.prototype),I.prototype.constructor=I,L.prototype=Object.create(w.prototype),L.prototype.constructor=L,O.prototype=Object.create(w.prototype),O.prototype.constructor=O,Object.assign(B.prototype,{computeGroups:function(e){var t=[],i=void 0;e=e.faces;for(var r=0;r<e.length;r++){var n=e[r];if(n.materialIndex!==i){i=n.materialIndex,void 0!==o&&(o.count=3*r-o.start,t.push(o));var o={start:3*r,materialIndex:i}}}void 0!==o&&(o.count=3*r-o.start,t.push(o)),this.groups=t},fromGeometry:function(e){var t=e.faces,r=e.vertices,n=e.faceVertexUvs,o=n[0]&&0<n[0].length,s=n[1]&&0<n[1].length,a=e.morphTargets,h=a.length;if(0<h){for(var c=[],l=0;l<h;l++)c[l]=[];this.morphTargets.position=c}var u=e.morphNormals,d=u.length;if(0<d){var f=[];for(l=0;l<d;l++)f[l]=[];this.morphTargets.normal=f}var p=e.skinIndices,m=e.skinWeights,g=p.length===r.length,v=m.length===r.length;for(l=0;l<t.length;l++){var _=t[l];this.vertices.push(r[_.a],r[_.b],r[_.c]);var y=_.vertexNormals;for(3===y.length?this.normals.push(y[0],y[1],y[2]):(y=_.normal,this.normals.push(y,y,y)),3===(y=_.vertexColors).length?this.colors.push(y[0],y[1],y[2]):(y=_.color,this.colors.push(y,y,y)),!0===o&&(void 0!==(y=n[0][l])?this.uvs.push(y[0],y[1],y[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",l),this.uvs.push(new i,new i,new i))),!0===s&&(void 0!==(y=n[1][l])?this.uvs2.push(y[0],y[1],y[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",l),this.uvs2.push(new i,new i,new i))),y=0;y<h;y++){var x=a[y].vertices;c[y].push(x[_.a],x[_.b],x[_.c])}for(y=0;y<d;y++)x=u[y].vertexNormals[l],f[y].push(x.a,x.b,x.c);g&&this.skinIndices.push(p[_.a],p[_.b],p[_.c]),v&&this.skinWeights.push(m[_.a],m[_.b],m[_.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}});var Fn=1;N.prototype=Object.assign(Object.create(t.prototype),{constructor:N,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(e){Array.isArray(e)?this.index=new(65535<F(e)?I:D)(e,1):this.index=e},addAttribute:function(e,t,i){if(t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute){if("index"!==e)return this.attributes[e]=t,this;console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t)}else console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.addAttribute(e,new w(t,i))},getAttribute:function(e){return this.attributes[e]},removeAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,t,i){this.groups.push({start:e,count:t,materialIndex:void 0!==i?i:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix:function(e){var t=this.attributes.position;return void 0!==t&&(e.applyToBufferAttribute(t),t.needsUpdate=!0),void 0!==(t=this.attributes.normal)&&((new s).getNormalMatrix(e).applyToBufferAttribute(t),t.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var e=new r;return function(t){return e.makeRotationX(t),this.applyMatrix(e),this}}(),rotateY:function(){var e=new r;return function(t){return e.makeRotationY(t),this.applyMatrix(e),this}}(),rotateZ:function(){var e=new r;return function(t){return e.makeRotationZ(t),this.applyMatrix(e),this}}(),translate:function(){var e=new r;return function(t,i,r){return e.makeTranslation(t,i,r),this.applyMatrix(e),this}}(),scale:function(){var e=new r;return function(t,i,r){return e.makeScale(t,i,r),this.applyMatrix(e),this}}(),lookAt:function(){var e=new x;return function(t){e.lookAt(t),e.updateMatrix(),this.applyMatrix(e.matrix)}}(),center:function(){var e=new o;return function(){return this.computeBoundingBox(),this.boundingBox.getCenter(e).negate(),this.translate(e.x,e.y,e.z),this}}(),setFromObject:function(e){var t=e.geometry;if(e.isPoints||e.isLine){e=new L(3*t.vertices.length,3);var i=new L(3*t.colors.length,3);this.addAttribute("position",e.copyVector3sArray(t.vertices)),this.addAttribute("color",i.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length&&(e=new L(t.lineDistances.length,1),this.addAttribute("lineDistance",e.copyArray(t.lineDistances))),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone())}else e.isMesh&&t&&t.isGeometry&&this.fromGeometry(t);return this},setFromPoints:function(e){for(var t=[],i=0,r=e.length;i<r;i++){var n=e[i];t.push(n.x,n.y,n.z||0)}return this.addAttribute("position",new L(t,3)),this},updateFromObject:function(e){var t=e.geometry;if(e.isMesh){var i=t.__directGeometry;if(!0===t.elementsNeedUpdate&&(i=void 0,t.elementsNeedUpdate=!1),void 0===i)return this.fromGeometry(t);i.verticesNeedUpdate=t.verticesNeedUpdate,i.normalsNeedUpdate=t.normalsNeedUpdate,i.colorsNeedUpdate=t.colorsNeedUpdate,i.uvsNeedUpdate=t.uvsNeedUpdate,i.groupsNeedUpdate=t.groupsNeedUpdate,t.verticesNeedUpdate=!1,t.normalsNeedUpdate=!1,t.colorsNeedUpdate=!1,t.uvsNeedUpdate=!1,t.groupsNeedUpdate=!1,t=i}return!0===t.verticesNeedUpdate&&(void 0!==(i=this.attributes.position)&&(i.copyVector3sArray(t.vertices),i.needsUpdate=!0),t.verticesNeedUpdate=!1),!0===t.normalsNeedUpdate&&(void 0!==(i=this.attributes.normal)&&(i.copyVector3sArray(t.normals),i.needsUpdate=!0),t.normalsNeedUpdate=!1),!0===t.colorsNeedUpdate&&(void 0!==(i=this.attributes.color)&&(i.copyColorsArray(t.colors),i.needsUpdate=!0),t.colorsNeedUpdate=!1),t.uvsNeedUpdate&&(void 0!==(i=this.attributes.uv)&&(i.copyVector2sArray(t.uvs),i.needsUpdate=!0),t.uvsNeedUpdate=!1),t.lineDistancesNeedUpdate&&(void 0!==(i=this.attributes.lineDistance)&&(i.copyArray(t.lineDistances),i.needsUpdate=!0),t.lineDistancesNeedUpdate=!1),t.groupsNeedUpdate&&(t.computeGroups(e.geometry),this.groups=t.groups,t.groupsNeedUpdate=!1),this},fromGeometry:function(e){return e.__directGeometry=(new B).fromGeometry(e),this.fromDirectGeometry(e.__directGeometry)},fromDirectGeometry:function(e){var t=new Float32Array(3*e.vertices.length);for(var i in this.addAttribute("position",new w(t,3).copyVector3sArray(e.vertices)),0<e.normals.length&&(t=new Float32Array(3*e.normals.length),this.addAttribute("normal",new w(t,3).copyVector3sArray(e.normals))),0<e.colors.length&&(t=new Float32Array(3*e.colors.length),this.addAttribute("color",new w(t,3).copyColorsArray(e.colors))),0<e.uvs.length&&(t=new Float32Array(2*e.uvs.length),this.addAttribute("uv",new w(t,2).copyVector2sArray(e.uvs))),0<e.uvs2.length&&(t=new Float32Array(2*e.uvs2.length),this.addAttribute("uv2",new w(t,2).copyVector2sArray(e.uvs2))),this.groups=e.groups,e.morphTargets){t=[];for(var r=e.morphTargets[i],n=0,o=r.length;n<o;n++){var s=r[n],a=new L(3*s.length,3);t.push(a.copyVector3sArray(s))}this.morphAttributes[i]=t}return 0<e.skinIndices.length&&(i=new L(4*e.skinIndices.length,4),this.addAttribute("skinIndex",i.copyVector4sArray(e.skinIndices))),0<e.skinWeights.length&&(i=new L(4*e.skinWeights.length,4),this.addAttribute("skinWeight",i.copyVector4sArray(e.skinWeights))),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new d);var e=this.attributes.position;void 0!==e?this.boundingBox.setFromBufferAttribute(e):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var e=new d,t=new o;return function(){null===this.boundingSphere&&(this.boundingSphere=new f);var i=this.attributes.position;if(i){var r=this.boundingSphere.center;e.setFromBufferAttribute(i),e.getCenter(r);for(var n=0,o=0,s=i.count;o<s;o++)t.x=i.getX(o),t.y=i.getY(o),t.z=i.getZ(o),n=Math.max(n,r.distanceToSquared(t));this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}}(),computeFaceNormals:function(){},computeVertexNormals:function(){var e=this.index,t=this.attributes,i=this.groups;if(t.position){var r=t.position.array;if(void 0===t.normal)this.addAttribute("normal",new w(new Float32Array(r.length),3));else for(var n=t.normal.array,s=0,a=n.length;s<a;s++)n[s]=0;n=t.normal.array;var h=new o,c=new o,l=new o,u=new o,d=new o;if(e){e=e.array,0===i.length&&this.addGroup(0,e.length);for(var f=0,p=i.length;f<p;++f){a=(s=i[f]).start;var m=s.count;for(s=a,a+=m;s<a;s+=3){m=3*e[s+0];var g=3*e[s+1],v=3*e[s+2];h.fromArray(r,m),c.fromArray(r,g),l.fromArray(r,v),u.subVectors(l,c),d.subVectors(h,c),u.cross(d),n[m]+=u.x,n[m+1]+=u.y,n[m+2]+=u.z,n[g]+=u.x,n[g+1]+=u.y,n[g+2]+=u.z,n[v]+=u.x,n[v+1]+=u.y,n[v+2]+=u.z}}}else for(s=0,a=r.length;s<a;s+=9)h.fromArray(r,s),c.fromArray(r,s+3),l.fromArray(r,s+6),u.subVectors(l,c),d.subVectors(h,c),u.cross(d),n[s]=u.x,n[s+1]=u.y,n[s+2]=u.z,n[s+3]=u.x,n[s+4]=u.y,n[s+5]=u.z,n[s+6]=u.x,n[s+7]=u.y,n[s+8]=u.z;this.normalizeNormals(),t.normal.needsUpdate=!0}},merge:function(e,t){if(e&&e.isBufferGeometry){void 0===t&&(t=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));var i,r=this.attributes;for(i in r)if(void 0!==e.attributes[i]){var n=r[i].array,o=e.attributes[i],s=o.array,a=0;for(o=o.itemSize*t;a<s.length;a++,o++)n[o]=s[a]}return this}console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e)},normalizeNormals:function(){var e=new o;return function(){for(var t=this.attributes.normal,i=0,r=t.count;i<r;i++)e.x=t.getX(i),e.y=t.getY(i),e.z=t.getZ(i),e.normalize(),t.setXYZ(i,e.x,e.y,e.z)}}(),toNonIndexed:function(){if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var e,t=new N,i=this.index.array,r=this.attributes;for(e in r){var n=r[e],o=n.array,s=n.itemSize,a=new o.constructor(i.length*s),h=0;n=0;for(var c=i.length;n<c;n++)for(var l=i[n]*s,u=0;u<s;u++)a[h++]=o[l++];t.addAttribute(e,new w(a,s))}for(n=0,c=(i=this.groups).length;n<c;n++)r=i[n],t.addGroup(r.start,r.count,r.materialIndex);return t},toJSON:function(){var e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),void 0!==this.parameters){var t=this.parameters;for(n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};var i=this.index;for(n in null!==i&&(t=Array.prototype.slice.call(i.array),e.data.index={type:i.array.constructor.name,array:t}),i=this.attributes){var r=i[n];t=Array.prototype.slice.call(r.array),e.data.attributes[n]={itemSize:r.itemSize,type:r.array.constructor.name,array:t,normalized:r.normalized}}var n=this.groups;return 0<n.length&&(e.data.groups=JSON.parse(JSON.stringify(n))),null!==(n=this.boundingSphere)&&(e.data.boundingSphere={center:n.center.toArray(),radius:n.radius}),e},clone:function(){return(new N).copy(this)},copy:function(e){var t;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingSphere=this.boundingBox=null,this.name=e.name;var i=e.index;for(s in null!==i&&this.setIndex(i.clone()),i=e.attributes)this.addAttribute(s,i[s].clone());var r=e.morphAttributes;for(s in r){var n=[],o=r[s];for(i=0,t=o.length;i<t;i++)n.push(o[i].clone());this.morphAttributes[s]=n}var s=e.groups;for(i=0,t=s.length;i<t;i++)r=s[i],this.addGroup(r.start,r.count,r.materialIndex);return null!==(s=e.boundingBox)&&(this.boundingBox=s.clone()),null!==(s=e.boundingSphere)&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),V.prototype=Object.create(T.prototype),V.prototype.constructor=V,U.prototype=Object.create(N.prototype),U.prototype.constructor=U,z.prototype=Object.create(T.prototype),z.prototype.constructor=z,k.prototype=Object.create(N.prototype),k.prototype.constructor=k;var Nn=0;G.prototype=Object.assign(Object.create(t.prototype),{constructor:G,isMaterial:!0,onBeforeCompile:function(){},setValues:function(e){if(void 0!==e)for(var t in e){var i=e[t];if(void 0===i)console.warn("THREE.Material: '"+t+"' parameter is undefined.");else if("shading"===t)console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===i;else{var r=this[t];void 0===r?console.warn("THREE."+this.type+": '"+t+"' is not a property of this material."):r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]="overdraw"===t?Number(i):i}}},toJSON:function(e){function t(e){var t,i=[];for(t in e){var r=e[t];delete r.metadata,i.push(r)}return i}var i=void 0===e||"string"==typeof e;i&&(e={textures:{},images:{}});var r={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};return r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),void 0!==this.roughness&&(r.roughness=this.roughness),void 0!==this.metalness&&(r.metalness=this.metalness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),1!==this.emissiveIntensity&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),void 0!==this.shininess&&(r.shininess=this.shininess),void 0!==this.clearCoat&&(r.clearCoat=this.clearCoat),void 0!==this.clearCoatRoughness&&(r.clearCoatRoughness=this.clearCoatRoughness),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,r.reflectivity=this.reflectivity),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.size&&(r.size=this.size),void 0!==this.sizeAttenuation&&(r.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(r.blending=this.blending),!0===this.flatShading&&(r.flatShading=this.flatShading),0!==this.side&&(r.side=this.side),0!==this.vertexColors&&(r.vertexColors=this.vertexColors),1>this.opacity&&(r.opacity=this.opacity),!0===this.transparent&&(r.transparent=this.transparent),r.depthFunc=this.depthFunc,r.depthTest=this.depthTest,r.depthWrite=this.depthWrite,0!==this.rotation&&(r.rotation=this.rotation),1!==this.linewidth&&(r.linewidth=this.linewidth),void 0!==this.dashSize&&(r.dashSize=this.dashSize),void 0!==this.gapSize&&(r.gapSize=this.gapSize),void 0!==this.scale&&(r.scale=this.scale),!0===this.dithering&&(r.dithering=!0),0<this.alphaTest&&(r.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(r.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(r.wireframe=this.wireframe),1<this.wireframeLinewidth&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(r.morphTargets=!0),!0===this.skinning&&(r.skinning=!0),!1===this.visible&&(r.visible=!1),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),i&&(i=t(e.textures),e=t(e.images),0<i.length&&(r.textures=i),0<e.length&&(r.images=e)),r},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.lights=e.lights,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.overdraw=e.overdraw,this.visible=e.visible,this.userData=JSON.parse(JSON.stringify(e.userData)),this.clipShadows=e.clipShadows,this.clipIntersection=e.clipIntersection;var t=e.clippingPlanes,i=null;if(null!==t){var r=t.length;i=Array(r);for(var n=0;n!==r;++n)i[n]=t[n].clone()}return this.clippingPlanes=i,this.shadowSide=e.shadowSide,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),W.prototype=Object.create(G.prototype),W.prototype.constructor=W,W.prototype.isMeshBasicMaterial=!0,W.prototype.copy=function(e){return G.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this},H.prototype=Object.create(G.prototype),H.prototype.constructor=H,H.prototype.isShaderMaterial=!0,H.prototype.copy=function(e){return G.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Dn.clone(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.extensions=e.extensions,this},H.prototype.toJSON=function(e){return(e=G.prototype.toJSON.call(this,e)).uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},Object.assign(j.prototype,{set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){return void 0===t&&(console.warn("THREE.Ray: .at() target is now required"),t=new o),t.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:function(){var e=new o;return function(t){return this.origin.copy(this.at(t,e)),this}}(),closestPointToPoint:function(e,t){return void 0===t&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),t=new o),t.subVectors(e,this.origin),0>(e=t.dot(this.direction))?t.copy(this.origin):t.copy(this.direction).multiplyScalar(e).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(){var e=new o;return function(t){var i=e.subVectors(t,this.origin).dot(this.direction);return 0>i?this.origin.distanceToSquared(t):(e.copy(this.direction).multiplyScalar(i).add(this.origin),e.distanceToSquared(t))}}(),distanceSqToSegment:function(){var e=new o,t=new o,i=new o;return function(r,n,o,s){e.copy(r).add(n).multiplyScalar(.5),t.copy(n).sub(r).normalize(),i.copy(this.origin).sub(e);var a=.5*r.distanceTo(n),h=-this.direction.dot(t),c=i.dot(this.direction),l=-i.dot(t),u=i.lengthSq(),d=Math.abs(1-h*h);if(0<d){n=h*c-l;var f=a*d;0<=(r=h*l-c)?n>=-f?n<=f?h=(r*=a=1/d)*(r+h*(n*=a)+2*c)+n*(h*r+n+2*l)+u:(n=a,h=-(r=Math.max(0,-(h*n+c)))*r+n*(n+2*l)+u):(n=-a,h=-(r=Math.max(0,-(h*n+c)))*r+n*(n+2*l)+u):n<=-f?h=-(r=Math.max(0,-(-h*a+c)))*r+(n=0<r?-a:Math.min(Math.max(-a,-l),a))*(n+2*l)+u:n<=f?(r=0,h=(n=Math.min(Math.max(-a,-l),a))*(n+2*l)+u):h=-(r=Math.max(0,-(h*a+c)))*r+(n=0<r?a:Math.min(Math.max(-a,-l),a))*(n+2*l)+u}else n=0<h?-a:a,h=-(r=Math.max(0,-(h*n+c)))*r+n*(n+2*l)+u;return o&&o.copy(this.direction).multiplyScalar(r).add(this.origin),s&&s.copy(t).multiplyScalar(n).add(e),h}}(),intersectSphere:function(){var e=new o;return function(t,i){e.subVectors(t.center,this.origin);var r=e.dot(this.direction),n=e.dot(e)-r*r;return n>(t=t.radius*t.radius)?null:(n=r-(t=Math.sqrt(t-n)),r+=t,0>n&&0>r?null:0>n?this.at(r,i):this.at(n,i))}}(),intersectsSphere:function(e){return this.distanceToPoint(e.center)<=e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);return 0===t?0===e.distanceToPoint(this.origin)?0:null:0<=(e=-(this.origin.dot(e.normal)+e.constant)/t)?e:null},intersectPlane:function(e,t){return null===(e=this.distanceToPlane(e))?null:this.at(e,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);return 0===t||0>e.normal.dot(this.direction)*t},intersectBox:function(e,t){var i=1/this.direction.x,r=1/this.direction.y,n=1/this.direction.z,o=this.origin;if(0<=i){var s=(e.min.x-o.x)*i;i*=e.max.x-o.x}else s=(e.max.x-o.x)*i,i*=e.min.x-o.x;if(0<=r){var a=(e.min.y-o.y)*r;r*=e.max.y-o.y}else a=(e.max.y-o.y)*r,r*=e.min.y-o.y;return s>r||a>i?null:((a>s||s!=s)&&(s=a),(r<i||i!=i)&&(i=r),0<=n?(a=(e.min.z-o.z)*n,e=(e.max.z-o.z)*n):(a=(e.max.z-o.z)*n,e=(e.min.z-o.z)*n),s>e||a>i?null:((a>s||s!=s)&&(s=a),(e<i||i!=i)&&(i=e),0>i?null:this.at(0<=s?s:i,t)))},intersectsBox:function(){var e=new o;return function(t){return null!==this.intersectBox(t,e)}}(),intersectTriangle:function(){var e=new o,t=new o,i=new o,r=new o;return function(n,o,s,a,h){if(t.subVectors(o,n),i.subVectors(s,n),r.crossVectors(t,i),0<(o=this.direction.dot(r))){if(a)return null;a=1}else{if(!(0>o))return null;a=-1,o=-o}return e.subVectors(this.origin,n),0>(n=a*this.direction.dot(i.crossVectors(e,i)))?null:0>(s=a*this.direction.dot(t.cross(e)))||n+s>o?null:0>(n=-a*e.dot(r))?null:this.at(n/o,h)}}(),applyMatrix4:function(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}}),Object.assign(Y.prototype,{set:function(e,t){return this.start.copy(e),this.end.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},getCenter:function(e){return void 0===e&&(console.warn("THREE.Line3: .getCenter() target is now required"),e=new o),e.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){return void 0===e&&(console.warn("THREE.Line3: .delta() target is now required"),e=new o),e.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){return void 0===t&&(console.warn("THREE.Line3: .at() target is now required"),t=new o),this.delta(t).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(){var e=new o,t=new o;return function(i,r){return e.subVectors(i,this.start),t.subVectors(this.end,this.start),i=t.dot(t),i=t.dot(e)/i,r&&(i=An.clamp(i,0,1)),i}}(),closestPointToPoint:function(e,t,i){return e=this.closestPointToPointParameter(e,t),void 0===i&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),i=new o),this.delta(i).multiplyScalar(e).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}}),Object.assign(X,{getNormal:function(){var e=new o;return function(t,i,r,n){return void 0===n&&(console.warn("THREE.Triangle: .getNormal() target is now required"),n=new o),n.subVectors(r,i),e.subVectors(t,i),n.cross(e),0<(t=n.lengthSq())?n.multiplyScalar(1/Math.sqrt(t)):n.set(0,0,0)}}(),getBarycoord:function(){var e=new o,t=new o,i=new o;return function(r,n,s,a,h){e.subVectors(a,n),t.subVectors(s,n),i.subVectors(r,n),r=e.dot(e),n=e.dot(t),s=e.dot(i);var c=t.dot(t);a=t.dot(i);var l=r*c-n*n;return void 0===h&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),h=new o),0===l?h.set(-2,-1,-1):(c=(c*s-n*a)*(l=1/l),r=(r*a-n*s)*l,h.set(1-c-r,r,c))}}(),containsPoint:function(){var e=new o;return function(t,i,r,n){return X.getBarycoord(t,i,r,n,e),0<=e.x&&0<=e.y&&1>=e.x+e.y}}()}),Object.assign(X.prototype,{set:function(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this},setFromPointsAndIndices:function(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},getArea:function(){var e=new o,t=new o;return function(){return e.subVectors(this.c,this.b),t.subVectors(this.a,this.b),.5*e.cross(t).length()}}(),getMidpoint:function(e){return void 0===e&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),e=new o),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(e){return X.getNormal(this.a,this.b,this.c,e)},getPlane:function(e){return void 0===e&&(console.warn("THREE.Triangle: .getPlane() target is now required"),e=new o),e.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(e,t){return X.getBarycoord(e,this.a,this.b,this.c,t)},containsPoint:function(e){return X.containsPoint(e,this.a,this.b,this.c)},intersectsBox:function(e){return e.intersectsTriangle(this)},closestPointToPoint:function(){var e=new p,t=[new Y,new Y,new Y],i=new o,r=new o;return function(n,s){void 0===s&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),s=new o);var a=1/0;if(e.setFromCoplanarPoints(this.a,this.b,this.c),e.projectPoint(n,i),!0===this.containsPoint(i))s.copy(i);else for(t[0].set(this.a,this.b),t[1].set(this.b,this.c),t[2].set(this.c,this.a),n=0;n<t.length;n++){t[n].closestPointToPoint(i,!0,r);var h=i.distanceToSquared(r);h<a&&(a=h,s.copy(r))}return s}}(),equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}),K.prototype=Object.assign(Object.create(x.prototype),{constructor:K,isMesh:!0,setDrawMode:function(e){this.drawMode=e},copy:function(e){return x.prototype.copy.call(this,e),this.drawMode=e.drawMode,void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this},updateMorphTargets:function(){var e=this.geometry;if(e.isBufferGeometry){e=e.morphAttributes;var t=Object.keys(e);if(0<t.length){var i=e[t[0]];if(void 0!==i)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=i.length;e<t;e++){var r=i[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[r]=e}}}else if(void 0!==(i=e.morphTargets)&&0<i.length)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=i.length;e<t;e++)r=i[e].name||String(e),this.morphTargetInfluences.push(0),this.morphTargetDictionary[r]=e},raycast:function(){function e(e,t,i,r,n,o,s){return X.getBarycoord(e,t,i,r,y),n.multiplyScalar(y.x),o.multiplyScalar(y.y),s.multiplyScalar(y.z),n.add(o).add(s),n.clone()}function t(e,t,i,r,n,o,s,a){return null===(1===t.side?r.intersectTriangle(s,o,n,!0,a):r.intersectTriangle(n,o,s,2!==t.side,a))?null:(b.copy(a),b.applyMatrix4(e.matrixWorld),(t=i.ray.origin.distanceTo(b))<i.near||t>i.far?null:{distance:t,point:b.clone(),object:e})}function n(i,r,n,o,s,a,h,d){return c.fromBufferAttribute(o,a),l.fromBufferAttribute(o,h),u.fromBufferAttribute(o,d),(i=t(i,i.material,r,n,c,l,u,x))&&(s&&(g.fromBufferAttribute(s,a),v.fromBufferAttribute(s,h),_.fromBufferAttribute(s,d),i.uv=e(x,c,l,u,g,v,_)),s=new E(a,h,d),X.getNormal(c,l,u,s.normal),i.face=s,i.faceIndex=a),i}var s=new r,a=new j,h=new f,c=new o,l=new o,u=new o,d=new o,p=new o,m=new o,g=new i,v=new i,_=new i,y=new o,x=new o,b=new o;return function(i,r){var o,f=this.geometry,y=this.material,b=this.matrixWorld;if(void 0!==y&&(null===f.boundingSphere&&f.computeBoundingSphere(),h.copy(f.boundingSphere),h.applyMatrix4(b),!1!==i.ray.intersectsSphere(h)&&(s.getInverse(b),a.copy(i.ray).applyMatrix4(s),null===f.boundingBox||!1!==a.intersectsBox(f.boundingBox))))if(f.isBufferGeometry){y=f.index;var M,E=f.attributes.position;if(f=f.attributes.uv,null!==y)for(b=0,M=y.count;b<M;b+=3){var T=y.getX(b),w=y.getX(b+1),S=y.getX(b+2);(o=n(this,i,a,E,f,T,w,S))&&(o.faceIndex=Math.floor(b/3),r.push(o))}else if(void 0!==E)for(b=0,M=E.count;b<M;b+=3)(o=n(this,i,a,E,f,T=b,w=b+1,S=b+2))&&r.push(o)}else if(f.isGeometry){b=Array.isArray(y),M=f.vertices,T=f.faces,0<(w=f.faceVertexUvs[0]).length&&(E=w);for(var A=0,P=T.length;A<P;A++){var C=T[A];if(void 0!==(o=b?y[C.materialIndex]:y)){w=M[C.a],S=M[C.b];var D=M[C.c];if(!0===o.morphTargets){var R=f.morphTargets,I=this.morphTargetInfluences;c.set(0,0,0),l.set(0,0,0),u.set(0,0,0);for(var L=0,O=R.length;L<O;L++){var B=I[L];if(0!==B){var F=R[L].vertices;c.addScaledVector(d.subVectors(F[C.a],w),B),l.addScaledVector(p.subVectors(F[C.b],S),B),u.addScaledVector(m.subVectors(F[C.c],D),B)}}c.add(w),l.add(S),u.add(D),w=c,S=l,D=u}(o=t(this,o,i,a,w,S,D,x))&&(E&&E[A]&&(R=E[A],g.copy(R[0]),v.copy(R[1]),_.copy(R[2]),o.uv=e(x,w,S,D,g,v,_)),o.face=C,o.faceIndex=A,r.push(o))}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),$.prototype=Object.create(a.prototype),$.prototype.constructor=$,$.prototype.isCubeTexture=!0,Object.defineProperty($.prototype,"images",{get:function(){return this.image},set:function(e){this.image=e}});var Vn=new a,Un=new $,zn=[],kn=[],Gn=new Float32Array(16),Wn=new Float32Array(9);Ae.prototype.setValue=function(e,t){for(var i=this.seq,r=0,n=i.length;r!==n;++r){var o=i[r];o.setValue(e,t[o.id])}};var Hn=/([\w\d_]+)(\])?(\[|\.)?/g;Pe.prototype.setValue=function(e,t,i){void 0!==(t=this.map[t])&&t.setValue(e,i,this.renderer)},Pe.prototype.setOptional=function(e,t,i){void 0!==(t=t[i])&&this.setValue(e,i,t)},Pe.upload=function(e,t,i,r){for(var n=0,o=t.length;n!==o;++n){var s=t[n],a=i[s.id];!1!==a.needsUpdate&&s.setValue(e,a.value,r)}},Pe.seqWithValue=function(e,t){for(var i=[],r=0,n=e.length;r!==n;++r){var o=e[r];o.id in t&&i.push(o)}return i};var jn=0,Yn=0;We.prototype=Object.create(G.prototype),We.prototype.constructor=We,We.prototype.isMeshDepthMaterial=!0,We.prototype.copy=function(e){return G.prototype.copy.call(this,e),this.depthPacking=e.depthPacking,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this},He.prototype=Object.create(G.prototype),He.prototype.constructor=He,He.prototype.isMeshDistanceMaterial=!0,He.prototype.copy=function(e){return G.prototype.copy.call(this,e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this},Ye.prototype=Object.create(a.prototype),Ye.prototype.constructor=Ye,qe.prototype=Object.assign(Object.create(b.prototype),{constructor:qe,isPerspectiveCamera:!0,copy:function(e,t){return b.prototype.copy.call(this,e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this},setFocalLength:function(e){e=.5*this.getFilmHeight()/e,this.fov=2*An.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){var e=Math.tan(.5*An.DEG2RAD*this.fov);return.5*this.getFilmHeight()/e},getEffectiveFOV:function(){return 2*An.RAD2DEG*Math.atan(Math.tan(.5*An.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(e,t,i,r,n,o){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=n,this.view.height=o,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var e=this.near,t=e*Math.tan(.5*An.DEG2RAD*this.fov)/this.zoom,i=2*t,r=this.aspect*i,n=-.5*r,o=this.view;if(null!==this.view&&this.view.enabled){var s=o.fullWidth,a=o.fullHeight;n+=o.offsetX*r/s,t-=o.offsetY*i/a,r*=o.width/s,i*=o.height/a}0!==(o=this.filmOffset)&&(n+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+r,t,t-i,e,this.far)},toJSON:function(e){return(e=x.prototype.toJSON.call(this,e)).object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}),Ze.prototype=Object.assign(Object.create(qe.prototype),{constructor:Ze,isArrayCamera:!0}),$e.prototype.isFogExp2=!0,$e.prototype.clone=function(){return new $e(this.color.getHex(),this.density)},$e.prototype.toJSON=function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}},et.prototype.isFog=!0,et.prototype.clone=function(){return new et(this.color.getHex(),this.near,this.far)},et.prototype.toJSON=function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}},tt.prototype=Object.assign(Object.create(x.prototype),{constructor:tt,copy:function(e,t){return x.prototype.copy.call(this,e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this},toJSON:function(e){var t=x.prototype.toJSON.call(this,e);return null!==this.background&&(t.object.background=this.background.toJSON(e)),null!==this.fog&&(t.object.fog=this.fog.toJSON()),t}}),it.prototype=Object.create(G.prototype),it.prototype.constructor=it,it.prototype.isSpriteMaterial=!0,it.prototype.copy=function(e){return G.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.rotation=e.rotation,this},rt.prototype=Object.assign(Object.create(x.prototype),{constructor:rt,isSprite:!0,raycast:function(){var e=new o,t=new o,i=new o;return function(r,n){t.setFromMatrixPosition(this.matrixWorld),r.ray.closestPointToPoint(t,e),i.setFromMatrixScale(this.matrixWorld);var o=i.x*i.y/4;t.distanceToSquared(e)>o||((o=r.ray.origin.distanceTo(e))<r.near||o>r.far||n.push({distance:o,point:e.clone(),face:null,object:this}))}}(),clone:function(){return new this.constructor(this.material).copy(this)},copy:function(e){return x.prototype.copy.call(this,e),void 0!==e.center&&this.center.copy(e.center),this}}),nt.prototype=Object.assign(Object.create(x.prototype),{constructor:nt,copy:function(e){x.prototype.copy.call(this,e,!1);for(var t=0,i=(e=e.levels).length;t<i;t++){var r=e[t];this.addLevel(r.object.clone(),r.distance)}return this},addLevel:function(e,t){void 0===t&&(t=0),t=Math.abs(t);for(var i=this.levels,r=0;r<i.length&&!(t<i[r].distance);r++);i.splice(r,0,{distance:t,object:e}),this.add(e)},getObjectForDistance:function(e){for(var t=this.levels,i=1,r=t.length;i<r&&!(e<t[i].distance);i++);return t[i-1].object},raycast:function(){var e=new o;return function(t,i){e.setFromMatrixPosition(this.matrixWorld);var r=t.ray.origin.distanceTo(e);this.getObjectForDistance(r).raycast(t,i)}}(),update:function(){var e=new o,t=new o;return function(i){var r=this.levels;if(1<r.length){e.setFromMatrixPosition(i.matrixWorld),t.setFromMatrixPosition(this.matrixWorld),i=e.distanceTo(t),r[0].object.visible=!0;for(var n=1,o=r.length;n<o&&i>=r[n].distance;n++)r[n-1].object.visible=!1,r[n].object.visible=!0;for(;n<o;n++)r[n].object.visible=!1}}}(),toJSON:function(e){(e=x.prototype.toJSON.call(this,e)).object.levels=[];for(var t=this.levels,i=0,r=t.length;i<r;i++){var n=t[i];e.object.levels.push({object:n.object.uuid,distance:n.distance})}return e}}),Object.assign(ot.prototype,{calculateInverses:function(){this.boneInverses=[];for(var e=0,t=this.bones.length;e<t;e++){var i=new r;this.bones[e]&&i.getInverse(this.bones[e].matrixWorld),this.boneInverses.push(i)}},pose:function(){var e,t,i=0;for(t=this.bones.length;i<t;i++)(e=this.bones[i])&&e.matrixWorld.getInverse(this.boneInverses[i]);for(i=0,t=this.bones.length;i<t;i++)(e=this.bones[i])&&(e.parent&&e.parent.isBone?(e.matrix.getInverse(e.parent.matrixWorld),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))},update:function(){var e=new r,t=new r;return function(){for(var i=this.bones,r=this.boneInverses,n=this.boneMatrices,o=this.boneTexture,s=0,a=i.length;s<a;s++)e.multiplyMatrices(i[s]?i[s].matrixWorld:t,r[s]),e.toArray(n,16*s);void 0!==o&&(o.needsUpdate=!0)}}(),clone:function(){return new ot(this.bones,this.boneInverses)},getBoneByName:function(e){for(var t=0,i=this.bones.length;t<i;t++){var r=this.bones[t];if(r.name===e)return r}}}),st.prototype=Object.assign(Object.create(x.prototype),{constructor:st,isBone:!0}),at.prototype=Object.assign(Object.create(K.prototype),{constructor:at,isSkinnedMesh:!0,initBones:function(){var e,t=[];if(this.geometry&&void 0!==this.geometry.bones){var i=0;for(e=this.geometry.bones.length;i<e;i++){var r=this.geometry.bones[i],n=new st;t.push(n),n.name=r.name,n.position.fromArray(r.pos),n.quaternion.fromArray(r.rotq),void 0!==r.scl&&n.scale.fromArray(r.scl)}for(i=0,e=this.geometry.bones.length;i<e;i++)-1!==(r=this.geometry.bones[i]).parent&&null!==r.parent&&void 0!==t[r.parent]?t[r.parent].add(t[i]):this.add(t[i])}return this.updateMatrixWorld(!0),t},bind:function(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.getInverse(t)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){var e;if(this.geometry&&this.geometry.isGeometry)for(e=0;e<this.geometry.skinWeights.length;e++){var t=this.geometry.skinWeights[e],i=1/t.manhattanLength();1/0!==i?t.multiplyScalar(i):t.set(1,0,0,0)}else if(this.geometry&&this.geometry.isBufferGeometry){t=new h;var r=this.geometry.attributes.skinWeight;for(e=0;e<r.count;e++)t.x=r.getX(e),t.y=r.getY(e),t.z=r.getZ(e),t.w=r.getW(e),1/0!==(i=1/t.manhattanLength())?t.multiplyScalar(i):t.set(1,0,0,0),r.setXYZW(e,t.x,t.y,t.z,t.w)}},updateMatrixWorld:function(e){K.prototype.updateMatrixWorld.call(this,e),"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),ht.prototype=Object.create(G.prototype),ht.prototype.constructor=ht,ht.prototype.isLineBasicMaterial=!0,ht.prototype.copy=function(e){return G.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this},ct.prototype=Object.assign(Object.create(x.prototype),{constructor:ct,isLine:!0,computeLineDistances:function(){var e=new o,t=new o;return function(){var i=this.geometry;if(i.isBufferGeometry)if(null===i.index){for(var r=i.attributes.position,n=[0],o=1,s=r.count;o<s;o++)e.fromBufferAttribute(r,o-1),t.fromBufferAttribute(r,o),n[o]=n[o-1],n[o]+=e.distanceTo(t);i.addAttribute("lineDistance",new L(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(i.isGeometry)for(r=i.vertices,(n=i.lineDistances)[0]=0,o=1,s=r.length;o<s;o++)n[o]=n[o-1],n[o]+=r[o-1].distanceTo(r[o]);return this}}(),raycast:function(){var e=new r,t=new j,i=new f;return function(r,n){var s=r.linePrecision;s*=s;var a=this.geometry,h=this.matrixWorld;if(null===a.boundingSphere&&a.computeBoundingSphere(),i.copy(a.boundingSphere),i.applyMatrix4(h),!1!==r.ray.intersectsSphere(i)){e.getInverse(h),t.copy(r.ray).applyMatrix4(e);var c=new o,l=new o;h=new o;var u=new o,d=this&&this.isLineSegments?2:1;if(a.isBufferGeometry){var f=a.index,p=a.attributes.position.array;if(null!==f){a=0;for(var m=(f=f.array).length-1;a<m;a+=d){var g=f[a+1];c.fromArray(p,3*f[a]),l.fromArray(p,3*g),(g=t.distanceSqToSegment(c,l,u,h))>s||(u.applyMatrix4(this.matrixWorld),(g=r.ray.origin.distanceTo(u))<r.near||g>r.far||n.push({distance:g,point:h.clone().applyMatrix4(this.matrixWorld),index:a,face:null,faceIndex:null,object:this}))}}else for(a=0,m=p.length/3-1;a<m;a+=d)c.fromArray(p,3*a),l.fromArray(p,3*a+3),(g=t.distanceSqToSegment(c,l,u,h))>s||(u.applyMatrix4(this.matrixWorld),(g=r.ray.origin.distanceTo(u))<r.near||g>r.far||n.push({distance:g,point:h.clone().applyMatrix4(this.matrixWorld),index:a,face:null,faceIndex:null,object:this}))}else if(a.isGeometry)for(l=(c=a.vertices).length,a=0;a<l-1;a+=d)(g=t.distanceSqToSegment(c[a],c[a+1],u,h))>s||(u.applyMatrix4(this.matrixWorld),(g=r.ray.origin.distanceTo(u))<r.near||g>r.far||n.push({distance:g,point:h.clone().applyMatrix4(this.matrixWorld),index:a,face:null,faceIndex:null,object:this}))}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),lt.prototype=Object.assign(Object.create(ct.prototype),{constructor:lt,isLineSegments:!0,computeLineDistances:function(){var e=new o,t=new o;return function(){var i=this.geometry;if(i.isBufferGeometry)if(null===i.index){for(var r=i.attributes.position,n=[],o=0,s=r.count;o<s;o+=2)e.fromBufferAttribute(r,o),t.fromBufferAttribute(r,o+1),n[o]=0===o?0:n[o-1],n[o+1]=n[o]+e.distanceTo(t);i.addAttribute("lineDistance",new L(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(i.isGeometry)for(r=i.vertices,n=i.lineDistances,o=0,s=r.length;o<s;o+=2)e.copy(r[o]),t.copy(r[o+1]),n[o]=0===o?0:n[o-1],n[o+1]=n[o]+e.distanceTo(t);return this}}()}),ut.prototype=Object.assign(Object.create(ct.prototype),{constructor:ut,isLineLoop:!0}),dt.prototype=Object.create(G.prototype),dt.prototype.constructor=dt,dt.prototype.isPointsMaterial=!0,dt.prototype.copy=function(e){return G.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this},ft.prototype=Object.assign(Object.create(x.prototype),{constructor:ft,isPoints:!0,raycast:function(){var e=new r,t=new j,i=new f;return function(r,n){function s(e,i){var o=t.distanceSqToPoint(e);o<u&&(t.closestPointToPoint(e,d),d.applyMatrix4(c),(e=r.ray.origin.distanceTo(d))<r.near||e>r.far||n.push({distance:e,distanceToRay:Math.sqrt(o),point:d.clone(),index:i,face:null,object:a}))}var a=this,h=this.geometry,c=this.matrixWorld,l=r.params.Points.threshold;if(null===h.boundingSphere&&h.computeBoundingSphere(),i.copy(h.boundingSphere),i.applyMatrix4(c),i.radius+=l,!1!==r.ray.intersectsSphere(i)){e.getInverse(c),t.copy(r.ray).applyMatrix4(e);var u=(l/=(this.scale.x+this.scale.y+this.scale.z)/3)*l;l=new o;var d=new o;if(h.isBufferGeometry){var f=h.index;if(h=h.attributes.position.array,null!==f){var p=f.array;f=0;for(var m=p.length;f<m;f++){var g=p[f];l.fromArray(h,3*g),s(l,g)}}else for(f=0,p=h.length/3;f<p;f++)l.fromArray(h,3*f),s(l,f)}else for(f=0,p=(l=h.vertices).length;f<p;f++)s(l[f],f)}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),pt.prototype=Object.assign(Object.create(x.prototype),{constructor:pt,isGroup:!0}),mt.prototype=Object.assign(Object.create(a.prototype),{constructor:mt,isVideoTexture:!0,update:function(){var e=this.image;e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),gt.prototype=Object.create(a.prototype),gt.prototype.constructor=gt,gt.prototype.isCompressedTexture=!0,vt.prototype=Object.create(a.prototype),vt.prototype.constructor=vt,vt.prototype.isDepthTexture=!0,_t.prototype=Object.create(N.prototype),_t.prototype.constructor=_t,yt.prototype=Object.create(T.prototype),yt.prototype.constructor=yt,xt.prototype=Object.create(N.prototype),xt.prototype.constructor=xt,bt.prototype=Object.create(T.prototype),bt.prototype.constructor=bt,Mt.prototype=Object.create(N.prototype),Mt.prototype.constructor=Mt,Et.prototype=Object.create(T.prototype),Et.prototype.constructor=Et,Tt.prototype=Object.create(Mt.prototype),Tt.prototype.constructor=Tt,wt.prototype=Object.create(T.prototype),wt.prototype.constructor=wt,St.prototype=Object.create(Mt.prototype),St.prototype.constructor=St,At.prototype=Object.create(T.prototype),At.prototype.constructor=At,Pt.prototype=Object.create(Mt.prototype),Pt.prototype.constructor=Pt,Ct.prototype=Object.create(T.prototype),Ct.prototype.constructor=Ct,Dt.prototype=Object.create(Mt.prototype),Dt.prototype.constructor=Dt,Rt.prototype=Object.create(T.prototype),Rt.prototype.constructor=Rt,It.prototype=Object.create(N.prototype),It.prototype.constructor=It,Lt.prototype=Object.create(T.prototype),Lt.prototype.constructor=Lt,Ot.prototype=Object.create(N.prototype),Ot.prototype.constructor=Ot,Bt.prototype=Object.create(T.prototype),Bt.prototype.constructor=Bt,Ft.prototype=Object.create(N.prototype),Ft.prototype.constructor=Ft;var Xn=function(e,t,i){i=i||2;var r,n=t&&t.length,o=n?t[0]*i:e.length,s=Nt(e,0,o,i,!0),a=[];if(!s)return a;if(n){var h,c=i;n=[];var l=0;for(h=t.length;l<h;l++){var u=t[l]*c;(u=Nt(e,u,l<h-1?t[l+1]*c:e.length,c,!1))===u.next&&(u.steiner=!0),n.push(Gt(u))}for(n.sort(Ut),l=0;l<n.length;l++)(c=zt(t=n[l],c=s))&&Vt(t=Kt(c,t),t.next),s=Vt(s,s.next)}if(e.length>80*i){var d=r=e[0],f=n=e[1];for(c=i;c<o;c+=i)(l=e[c])<d&&(d=l),(t=e[c+1])<f&&(f=t),l>r&&(r=l),t>n&&(n=t);r=0!==(r=Math.max(r-d,n-f))?1/r:0}return function e(t,i,r,n,o,s,a){if(t){if(!a&&s){var h=t,c=h;do{null===c.z&&(c.z=kt(c.x,c.y,n,o,s)),c.prevZ=c.prev,c=c.nextZ=c.next}while(c!==h);c.prevZ.nextZ=null,c.prevZ=null,h=c;var l,u,d,f,p=1;do{c=h;var m=h=null;for(u=0;c;){u++;var g=c;for(l=d=0;l<p&&(d++,g=g.nextZ);l++);for(f=p;0<d||0<f&&g;)0!==d&&(0===f||!g||c.z<=g.z)?(l=c,c=c.nextZ,d--):(l=g,g=g.nextZ,f--),m?m.nextZ=l:h=l,l.prevZ=m,m=l;c=g}m.nextZ=null,p*=2}while(1<u)}for(h=t;t.prev!==t.next;){if(c=t.prev,g=t.next,s)e:{f=n;var v=o,_=s;if(0<=Ht(u=(m=t).prev,d=m,p=m.next))m=!1;else{var y=u.x>d.x?u.x>p.x?u.x:p.x:d.x>p.x?d.x:p.x,x=u.y>d.y?u.y>p.y?u.y:p.y:d.y>p.y?d.y:p.y;for(l=kt(u.x<d.x?u.x<p.x?u.x:p.x:d.x<p.x?d.x:p.x,u.y<d.y?u.y<p.y?u.y:p.y:d.y<p.y?d.y:p.y,f,v,_),f=kt(y,x,f,v,_),v=m.nextZ;v&&v.z<=f;){if(v!==m.prev&&v!==m.next&&Wt(u.x,u.y,d.x,d.y,p.x,p.y,v.x,v.y)&&0<=Ht(v.prev,v,v.next)){m=!1;break e}v=v.nextZ}for(v=m.prevZ;v&&v.z>=l;){if(v!==m.prev&&v!==m.next&&Wt(u.x,u.y,d.x,d.y,p.x,p.y,v.x,v.y)&&0<=Ht(v.prev,v,v.next)){m=!1;break e}v=v.prevZ}m=!0}}else e:if(m=t,u=m.prev,d=m,p=m.next,0<=Ht(u,d,p))m=!1;else{for(l=m.next.next;l!==m.prev;){if(Wt(u.x,u.y,d.x,d.y,p.x,p.y,l.x,l.y)&&0<=Ht(l.prev,l,l.next)){m=!1;break e}l=l.next}m=!0}if(m)i.push(c.i/r),i.push(t.i/r),i.push(g.i/r),Zt(t),h=t=g.next;else if((t=g)===h){if(a){if(1===a){a=i,h=r,c=t;do{!jt(g=c.prev,m=c.next.next)&&Yt(g,c,c.next,m)&&Xt(g,m)&&Xt(m,g)&&(a.push(g.i/h),a.push(c.i/h),a.push(m.i/h),Zt(c),Zt(c.next),c=t=m),c=c.next}while(c!==t);e(t=c,i,r,n,o,s,2)}else if(2===a)e:{a=t;do{for(h=a.next.next;h!==a.prev;){if(c=a.i!==h.i){if(g=h,m=(c=a).next.i!==g.i&&c.prev.i!==g.i){t:{m=c;do{if(m.i!==c.i&&m.next.i!==c.i&&m.i!==g.i&&m.next.i!==g.i&&Yt(m,m.next,c,g)){m=!0;break t}m=m.next}while(m!==c);m=!1}m=!m}if(m=m&&Xt(c,g)&&Xt(g,c)){m=c,u=!1,d=(c.x+g.x)/2,g=(c.y+g.y)/2;do{m.y>g!=m.next.y>g&&m.next.y!==m.y&&d<(m.next.x-m.x)*(g-m.y)/(m.next.y-m.y)+m.x&&(u=!u),m=m.next}while(m!==c);m=u}c=m}if(c){t=Kt(a,h),a=Vt(a,a.next),t=Vt(t,t.next),e(a,i,r,n,o,s),e(t,i,r,n,o,s);break e}h=h.next}a=a.next}while(a!==t)}}else e(Vt(t),i,r,n,o,s,1);break}}}}(s,a,i,d,f,r),a},Kn={area:function(e){for(var t=e.length,i=0,r=t-1,n=0;n<t;r=n++)i+=e[r].x*e[n].y-e[n].x*e[r].y;return.5*i},isClockWise:function(e){return 0>Kn.area(e)},triangulateShape:function(e,t){var i=[],r=[],n=[];Jt(e),$t(i,e);var o=e.length;for(t.forEach(Jt),e=0;e<t.length;e++)r.push(o),o+=t[e].length,$t(i,t[e]);for(t=Xn(i,r),e=0;e<t.length;e+=3)n.push(t.slice(e,e+3));return n}};ei.prototype=Object.create(T.prototype),ei.prototype.constructor=ei,ti.prototype=Object.create(N.prototype),ti.prototype.constructor=ti;var qn={generateTopUV:function(e,t,r,n,o){e=t[3*n],n=t[3*n+1];var s=t[3*o];return o=t[3*o+1],[new i(t[3*r],t[3*r+1]),new i(e,n),new i(s,o)]},generateSideWallUV:function(e,t,r,n,o,s){e=t[3*r];var a=t[3*r+1];r=t[3*r+2];var h=t[3*n],c=t[3*n+1];n=t[3*n+2];var l=t[3*o],u=t[3*o+1];o=t[3*o+2];var d=t[3*s],f=t[3*s+1];return t=t[3*s+2],.01>Math.abs(a-c)?[new i(e,1-r),new i(h,1-n),new i(l,1-o),new i(d,1-t)]:[new i(a,1-r),new i(c,1-n),new i(u,1-o),new i(f,1-t)]}};ii.prototype=Object.create(T.prototype),ii.prototype.constructor=ii,ri.prototype=Object.create(ti.prototype),ri.prototype.constructor=ri,ni.prototype=Object.create(T.prototype),ni.prototype.constructor=ni,oi.prototype=Object.create(N.prototype),oi.prototype.constructor=oi,si.prototype=Object.create(T.prototype),si.prototype.constructor=si,ai.prototype=Object.create(N.prototype),ai.prototype.constructor=ai,hi.prototype=Object.create(T.prototype),hi.prototype.constructor=hi,ci.prototype=Object.create(N.prototype),ci.prototype.constructor=ci,li.prototype=Object.create(T.prototype),li.prototype.constructor=li,li.prototype.toJSON=function(){var e=T.prototype.toJSON.call(this);return di(this.parameters.shapes,e)},ui.prototype=Object.create(N.prototype),ui.prototype.constructor=ui,ui.prototype.toJSON=function(){var e=N.prototype.toJSON.call(this);return di(this.parameters.shapes,e)},fi.prototype=Object.create(N.prototype),fi.prototype.constructor=fi,pi.prototype=Object.create(T.prototype),pi.prototype.constructor=pi,mi.prototype=Object.create(N.prototype),mi.prototype.constructor=mi,gi.prototype=Object.create(pi.prototype),gi.prototype.constructor=gi,vi.prototype=Object.create(mi.prototype),vi.prototype.constructor=vi,_i.prototype=Object.create(T.prototype),_i.prototype.constructor=_i,yi.prototype=Object.create(N.prototype),yi.prototype.constructor=yi;var Zn=Object.freeze({WireframeGeometry:_t,ParametricGeometry:yt,ParametricBufferGeometry:xt,TetrahedronGeometry:Et,TetrahedronBufferGeometry:Tt,OctahedronGeometry:wt,OctahedronBufferGeometry:St,IcosahedronGeometry:At,IcosahedronBufferGeometry:Pt,DodecahedronGeometry:Ct,DodecahedronBufferGeometry:Dt,PolyhedronGeometry:bt,PolyhedronBufferGeometry:Mt,TubeGeometry:Rt,TubeBufferGeometry:It,TorusKnotGeometry:Lt,TorusKnotBufferGeometry:Ot,TorusGeometry:Bt,TorusBufferGeometry:Ft,TextGeometry:ii,TextBufferGeometry:ri,SphereGeometry:ni,SphereBufferGeometry:oi,RingGeometry:si,RingBufferGeometry:ai,PlaneGeometry:z,PlaneBufferGeometry:k,LatheGeometry:hi,LatheBufferGeometry:ci,ShapeGeometry:li,ShapeBufferGeometry:ui,ExtrudeGeometry:ei,ExtrudeBufferGeometry:ti,EdgesGeometry:fi,ConeGeometry:gi,ConeBufferGeometry:vi,CylinderGeometry:pi,CylinderBufferGeometry:mi,CircleGeometry:_i,CircleBufferGeometry:yi,BoxGeometry:V,BoxBufferGeometry:U});xi.prototype=Object.create(G.prototype),xi.prototype.constructor=xi,xi.prototype.isShadowMaterial=!0,xi.prototype.copy=function(e){return G.prototype.copy.call(this,e),this.color.copy(e.color),this},bi.prototype=Object.create(H.prototype),bi.prototype.constructor=bi,bi.prototype.isRawShaderMaterial=!0,Mi.prototype=Object.create(G.prototype),Mi.prototype.constructor=Mi,Mi.prototype.isMeshStandardMaterial=!0,Mi.prototype.copy=function(e){return G.prototype.copy.call(this,e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},Ei.prototype=Object.create(Mi.prototype),Ei.prototype.constructor=Ei,Ei.prototype.isMeshPhysicalMaterial=!0,Ei.prototype.copy=function(e){return Mi.prototype.copy.call(this,e),this.defines={PHYSICAL:""},this.reflectivity=e.reflectivity,this.clearCoat=e.clearCoat,this.clearCoatRoughness=e.clearCoatRoughness,this},Ti.prototype=Object.create(G.prototype),Ti.prototype.constructor=Ti,Ti.prototype.isMeshPhongMaterial=!0,Ti.prototype.copy=function(e){return G.prototype.copy.call(this,e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},wi.prototype=Object.create(Ti.prototype),wi.prototype.constructor=wi,wi.prototype.isMeshToonMaterial=!0,wi.prototype.copy=function(e){return Ti.prototype.copy.call(this,e),this.gradientMap=e.gradientMap,this},Si.prototype=Object.create(G.prototype),Si.prototype.constructor=Si,Si.prototype.isMeshNormalMaterial=!0,Si.prototype.copy=function(e){return G.prototype.copy.call(this,e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},Ai.prototype=Object.create(G.prototype),Ai.prototype.constructor=Ai,Ai.prototype.isMeshLambertMaterial=!0,Ai.prototype.copy=function(e){return G.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},Pi.prototype=Object.create(ht.prototype),Pi.prototype.constructor=Pi,Pi.prototype.isLineDashedMaterial=!0,Pi.prototype.copy=function(e){return ht.prototype.copy.call(this,e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this};var Qn=Object.freeze({ShadowMaterial:xi,SpriteMaterial:it,RawShaderMaterial:bi,ShaderMaterial:H,PointsMaterial:dt,MeshPhysicalMaterial:Ei,MeshStandardMaterial:Mi,MeshPhongMaterial:Ti,MeshToonMaterial:wi,MeshNormalMaterial:Si,MeshLambertMaterial:Ai,MeshDepthMaterial:We,MeshDistanceMaterial:He,MeshBasicMaterial:W,LineDashedMaterial:Pi,LineBasicMaterial:ht,Material:G}),Jn={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},$n=new Ci,eo={};Object.assign(Di.prototype,{load:function(e,t,i,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);var n=this,o=Jn.get(e);if(void 0!==o)return n.manager.itemStart(e),setTimeout(function(){t&&t(o),n.manager.itemEnd(e)},0),o;if(void 0===eo[e]){var s=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(s){i=s[1];var a=!!s[2];s=s[3],s=window.decodeURIComponent(s),a&&(s=window.atob(s));try{var h=(this.responseType||"").toLowerCase();switch(h){case"arraybuffer":case"blob":var c=new Uint8Array(s.length);for(a=0;a<s.length;a++)c[a]=s.charCodeAt(a);var l="blob"===h?new Blob([c.buffer],{type:i}):c.buffer;break;case"document":l=(new DOMParser).parseFromString(s,i);break;case"json":l=JSON.parse(s);break;default:l=s}window.setTimeout(function(){t&&t(l),n.manager.itemEnd(e)},0)}catch(t){window.setTimeout(function(){r&&r(t),n.manager.itemEnd(e),n.manager.itemError(e)},0)}}else{eo[e]=[],eo[e].push({onLoad:t,onProgress:i,onError:r});var u=new XMLHttpRequest;for(a in u.open("GET",e,!0),u.addEventListener("load",function(t){var i=this.response;Jn.add(e,i);var r=eo[e];if(delete eo[e],200===this.status){for(var o=0,s=r.length;o<s;o++){var a=r[o];a.onLoad&&a.onLoad(i)}n.manager.itemEnd(e)}else if(0===this.status){for(console.warn("THREE.FileLoader: HTTP Status 0 received."),o=0,s=r.length;o<s;o++)(a=r[o]).onLoad&&a.onLoad(i);n.manager.itemEnd(e)}else{for(o=0,s=r.length;o<s;o++)(a=r[o]).onError&&a.onError(t);n.manager.itemEnd(e),n.manager.itemError(e)}},!1),u.addEventListener("progress",function(t){for(var i=eo[e],r=0,n=i.length;r<n;r++){var o=i[r];o.onProgress&&o.onProgress(t)}},!1),u.addEventListener("error",function(t){var i=eo[e];delete eo[e];for(var r=0,o=i.length;r<o;r++){var s=i[r];s.onError&&s.onError(t)}n.manager.itemEnd(e),n.manager.itemError(e)},!1),void 0!==this.responseType&&(u.responseType=this.responseType),void 0!==this.withCredentials&&(u.withCredentials=this.withCredentials),u.overrideMimeType&&u.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain"),this.requestHeader)u.setRequestHeader(a,this.requestHeader[a]);u.send(null)}return n.manager.itemStart(e),u}eo[e].push({onLoad:t,onProgress:i,onError:r})},setPath:function(e){return this.path=e,this},setResponseType:function(e){return this.responseType=e,this},setWithCredentials:function(e){return this.withCredentials=e,this},setMimeType:function(e){return this.mimeType=e,this},setRequestHeader:function(e){return this.requestHeader=e,this}}),Object.assign(Ri.prototype,{load:function(e,t,i,r){function n(n){h.load(e[n],function(e){e=o._parser(e,!0),s[n]={width:e.width,height:e.height,format:e.format,mipmaps:e.mipmaps},6===(c+=1)&&(1===e.mipmapCount&&(a.minFilter=1006),a.format=e.format,a.needsUpdate=!0,t&&t(a))},i,r)}var o=this,s=[],a=new gt;a.image=s;var h=new Di(this.manager);if(h.setPath(this.path),h.setResponseType("arraybuffer"),Array.isArray(e))for(var c=0,l=0,u=e.length;l<u;++l)n(l);else h.load(e,function(e){if((e=o._parser(e,!0)).isCubemap)for(var i=e.mipmaps.length/e.mipmapCount,r=0;r<i;r++){s[r]={mipmaps:[]};for(var n=0;n<e.mipmapCount;n++)s[r].mipmaps.push(e.mipmaps[r*e.mipmapCount+n]),s[r].format=e.format,s[r].width=e.width,s[r].height=e.height}else a.image.width=e.width,a.image.height=e.height,a.mipmaps=e.mipmaps;1===e.mipmapCount&&(a.minFilter=1006),a.format=e.format,a.needsUpdate=!0,t&&t(a)},i,r);return a},setPath:function(e){return this.path=e,this}}),Object.assign(Ii.prototype,{load:function(e,t,i,r){var n=this,o=new u,s=new Di(this.manager);return s.setResponseType("arraybuffer"),s.load(e,function(e){(e=n._parser(e))&&(void 0!==e.image?o.image=e.image:void 0!==e.data&&(o.image.width=e.width,o.image.height=e.height,o.image.data=e.data),o.wrapS=void 0!==e.wrapS?e.wrapS:1001,o.wrapT=void 0!==e.wrapT?e.wrapT:1001,o.magFilter=void 0!==e.magFilter?e.magFilter:1006,o.minFilter=void 0!==e.minFilter?e.minFilter:1008,o.anisotropy=void 0!==e.anisotropy?e.anisotropy:1,void 0!==e.format&&(o.format=e.format),void 0!==e.type&&(o.type=e.type),void 0!==e.mipmaps&&(o.mipmaps=e.mipmaps),1===e.mipmapCount&&(o.minFilter=1006),o.needsUpdate=!0,t&&t(o,e))},i,r),o}}),Object.assign(Li.prototype,{crossOrigin:"Anonymous",load:function(e,t,i,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);var n=this,o=Jn.get(e);return void 0!==o?(n.manager.itemStart(e),setTimeout(function(){t&&t(o),n.manager.itemEnd(e)},0),o):((i=document.createElementNS("http://www.w3.org/1999/xhtml","img")).addEventListener("load",function(){Jn.add(e,this),t&&t(this),n.manager.itemEnd(e)},!1),i.addEventListener("error",function(t){r&&r(t),n.manager.itemEnd(e),n.manager.itemError(e)},!1),"data:"!==e.substr(0,5)&&void 0!==this.crossOrigin&&(i.crossOrigin=this.crossOrigin),n.manager.itemStart(e),i.src=e,i)},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}}),Object.assign(Oi.prototype,{crossOrigin:"Anonymous",load:function(e,t,i,r){function n(i){s.load(e[i],function(e){o.images[i]=e,6===++a&&(o.needsUpdate=!0,t&&t(o))},void 0,r)}var o=new $,s=new Li(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);var a=0;for(i=0;i<e.length;++i)n(i);return o},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}}),Object.assign(Bi.prototype,{crossOrigin:"Anonymous",load:function(e,t,i,r){var n=new a,o=new Li(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(i){n.image=i,i=0<e.search(/\.(jpg|jpeg)$/)||0===e.search(/^data:image\/jpeg/),n.format=i?1022:1023,n.needsUpdate=!0,void 0!==t&&t(n)},i,r),n},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}}),Object.assign(Fi.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(e,t){return e=this.getUtoTmapping(e),this.getPoint(e,t)},getPoints:function(e){void 0===e&&(e=5);for(var t=[],i=0;i<=e;i++)t.push(this.getPoint(i/e));return t},getSpacedPoints:function(e){void 0===e&&(e=5);for(var t=[],i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t},getLength:function(){var e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(void 0===e&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,i=[],r=this.getPoint(0),n=0;for(i.push(0),t=1;t<=e;t++){var o=this.getPoint(t/e);n+=o.distanceTo(r),i.push(n),r=o}return this.cacheArcLengths=i},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){var i=this.getLengths(),r=i.length;t=t||e*i[r-1];for(var n,o=0,s=r-1;o<=s;)if(0>(n=i[e=Math.floor(o+(s-o)/2)]-t))o=e+1;else{if(!(0<n)){s=e;break}s=e-1}return i[e=s]===t?e/(r-1):(e+(t-(o=i[e]))/(i[e+1]-o))/(r-1)},getTangent:function(e){var t=e-1e-4;return 0>t&&(t=0),1<(e+=1e-4)&&(e=1),t=this.getPoint(t),this.getPoint(e).clone().sub(t).normalize()},getTangentAt:function(e){return e=this.getUtoTmapping(e),this.getTangent(e)},computeFrenetFrames:function(e,t){var i,n=new o,s=[],a=[],h=[],c=new o,l=new r;for(i=0;i<=e;i++){var u=i/e;s[i]=this.getTangentAt(u),s[i].normalize()}a[0]=new o,h[0]=new o,i=Number.MAX_VALUE,u=Math.abs(s[0].x);var d=Math.abs(s[0].y),f=Math.abs(s[0].z);for(u<=i&&(i=u,n.set(1,0,0)),d<=i&&(i=d,n.set(0,1,0)),f<=i&&n.set(0,0,1),c.crossVectors(s[0],n).normalize(),a[0].crossVectors(s[0],c),h[0].crossVectors(s[0],a[0]),i=1;i<=e;i++)a[i]=a[i-1].clone(),h[i]=h[i-1].clone(),c.crossVectors(s[i-1],s[i]),c.length()>Number.EPSILON&&(c.normalize(),n=Math.acos(An.clamp(s[i-1].dot(s[i]),-1,1)),a[i].applyMatrix4(l.makeRotationAxis(c,n))),h[i].crossVectors(s[i],a[i]);if(!0===t)for(n=Math.acos(An.clamp(a[0].dot(a[e]),-1,1)),n/=e,0<s[0].dot(c.crossVectors(a[0],a[e]))&&(n=-n),i=1;i<=e;i++)a[i].applyMatrix4(l.makeRotationAxis(s[i],n*i)),h[i].crossVectors(s[i],a[i]);return{tangents:s,normals:a,binormals:h}},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){var e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}),Ni.prototype=Object.create(Fi.prototype),Ni.prototype.constructor=Ni,Ni.prototype.isEllipseCurve=!0,Ni.prototype.getPoint=function(e,t){t=t||new i;for(var r=2*Math.PI,n=this.aEndAngle-this.aStartAngle,o=Math.abs(n)<Number.EPSILON;0>n;)n+=r;for(;n>r;)n-=r;n<Number.EPSILON&&(n=o?0:r),!0!==this.aClockwise||o||(n=n===r?-r:n-r),r=this.aStartAngle+e*n,e=this.aX+this.xRadius*Math.cos(r);var s=this.aY+this.yRadius*Math.sin(r);return 0!==this.aRotation&&(r=Math.cos(this.aRotation),n=Math.sin(this.aRotation),e=(o=e-this.aX)*r-(s-=this.aY)*n+this.aX,s=o*n+s*r+this.aY),t.set(e,s)},Ni.prototype.copy=function(e){return Fi.prototype.copy.call(this,e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this},Ni.prototype.toJSON=function(){var e=Fi.prototype.toJSON.call(this);return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e},Ni.prototype.fromJSON=function(e){return Fi.prototype.fromJSON.call(this,e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this},Vi.prototype=Object.create(Ni.prototype),Vi.prototype.constructor=Vi,Vi.prototype.isArcCurve=!0;var to=new o,io=new Ui,ro=new Ui,no=new Ui;zi.prototype=Object.create(Fi.prototype),zi.prototype.constructor=zi,zi.prototype.isCatmullRomCurve3=!0,zi.prototype.getPoint=function(e,t){t=t||new o;var i=this.points,r=i.length;e*=r-(this.closed?0:1);var n=Math.floor(e);if(e-=n,this.closed?n+=0<n?0:(Math.floor(Math.abs(n)/r)+1)*r:0===e&&n===r-1&&(n=r-2,e=1),this.closed||0<n)var s=i[(n-1)%r];else to.subVectors(i[0],i[1]).add(i[0]),s=to;var a=i[n%r],h=i[(n+1)%r];if(this.closed||n+2<r?i=i[(n+2)%r]:(to.subVectors(i[r-1],i[r-2]).add(i[r-1]),i=to),"centripetal"===this.curveType||"chordal"===this.curveType){var c="chordal"===this.curveType?.5:.25;r=Math.pow(s.distanceToSquared(a),c),1e-4>(n=Math.pow(a.distanceToSquared(h),c))&&(n=1),1e-4>r&&(r=n),1e-4>(c=Math.pow(h.distanceToSquared(i),c))&&(c=n),io.initNonuniformCatmullRom(s.x,a.x,h.x,i.x,r,n,c),ro.initNonuniformCatmullRom(s.y,a.y,h.y,i.y,r,n,c),no.initNonuniformCatmullRom(s.z,a.z,h.z,i.z,r,n,c)}else"catmullrom"===this.curveType&&(io.initCatmullRom(s.x,a.x,h.x,i.x,this.tension),ro.initCatmullRom(s.y,a.y,h.y,i.y,this.tension),no.initCatmullRom(s.z,a.z,h.z,i.z,this.tension));return t.set(io.calc(e),ro.calc(e),no.calc(e)),t},zi.prototype.copy=function(e){Fi.prototype.copy.call(this,e),this.points=[];for(var t=0,i=e.points.length;t<i;t++)this.points.push(e.points[t].clone());return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this},zi.prototype.toJSON=function(){var e=Fi.prototype.toJSON.call(this);e.points=[];for(var t=0,i=this.points.length;t<i;t++)e.points.push(this.points[t].toArray());return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e},zi.prototype.fromJSON=function(e){Fi.prototype.fromJSON.call(this,e),this.points=[];for(var t=0,i=e.points.length;t<i;t++){var r=e.points[t];this.points.push((new o).fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this},Hi.prototype=Object.create(Fi.prototype),Hi.prototype.constructor=Hi,Hi.prototype.isCubicBezierCurve=!0,Hi.prototype.getPoint=function(e,t){t=t||new i;var r=this.v0,n=this.v1,o=this.v2,s=this.v3;return t.set(Wi(e,r.x,n.x,o.x,s.x),Wi(e,r.y,n.y,o.y,s.y)),t},Hi.prototype.copy=function(e){return Fi.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this},Hi.prototype.toJSON=function(){var e=Fi.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e},Hi.prototype.fromJSON=function(e){return Fi.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this},ji.prototype=Object.create(Fi.prototype),ji.prototype.constructor=ji,ji.prototype.isCubicBezierCurve3=!0,ji.prototype.getPoint=function(e,t){t=t||new o;var i=this.v0,r=this.v1,n=this.v2,s=this.v3;return t.set(Wi(e,i.x,r.x,n.x,s.x),Wi(e,i.y,r.y,n.y,s.y),Wi(e,i.z,r.z,n.z,s.z)),t},ji.prototype.copy=function(e){return Fi.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this},ji.prototype.toJSON=function(){var e=Fi.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e},ji.prototype.fromJSON=function(e){return Fi.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this},Yi.prototype=Object.create(Fi.prototype),Yi.prototype.constructor=Yi,Yi.prototype.isLineCurve=!0,Yi.prototype.getPoint=function(e,t){return t=t||new i,1===e?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t},Yi.prototype.getPointAt=function(e,t){return this.getPoint(e,t)},Yi.prototype.getTangent=function(){return this.v2.clone().sub(this.v1).normalize()},Yi.prototype.copy=function(e){return Fi.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},Yi.prototype.toJSON=function(){var e=Fi.prototype.toJSON.call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},Yi.prototype.fromJSON=function(e){return Fi.prototype.fromJSON.call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},Xi.prototype=Object.create(Fi.prototype),Xi.prototype.constructor=Xi,Xi.prototype.isLineCurve3=!0,Xi.prototype.getPoint=function(e,t){return t=t||new o,1===e?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t},Xi.prototype.getPointAt=function(e,t){return this.getPoint(e,t)},Xi.prototype.copy=function(e){return Fi.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},Xi.prototype.toJSON=function(){var e=Fi.prototype.toJSON.call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},Xi.prototype.fromJSON=function(e){return Fi.prototype.fromJSON.call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},Ki.prototype=Object.create(Fi.prototype),Ki.prototype.constructor=Ki,Ki.prototype.isQuadraticBezierCurve=!0,Ki.prototype.getPoint=function(e,t){t=t||new i;var r=this.v0,n=this.v1,o=this.v2;return t.set(Gi(e,r.x,n.x,o.x),Gi(e,r.y,n.y,o.y)),t},Ki.prototype.copy=function(e){return Fi.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this},Ki.prototype.toJSON=function(){var e=Fi.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},Ki.prototype.fromJSON=function(e){return Fi.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},qi.prototype=Object.create(Fi.prototype),qi.prototype.constructor=qi,qi.prototype.isQuadraticBezierCurve3=!0,qi.prototype.getPoint=function(e,t){t=t||new o;var i=this.v0,r=this.v1,n=this.v2;return t.set(Gi(e,i.x,r.x,n.x),Gi(e,i.y,r.y,n.y),Gi(e,i.z,r.z,n.z)),t},qi.prototype.copy=function(e){return Fi.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this},qi.prototype.toJSON=function(){var e=Fi.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},qi.prototype.fromJSON=function(e){return Fi.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},Zi.prototype=Object.create(Fi.prototype),Zi.prototype.constructor=Zi,Zi.prototype.isSplineCurve=!0,Zi.prototype.getPoint=function(e,t){t=t||new i;var r=this.points,n=(r.length-1)*e;n-=e=Math.floor(n);var o=r[0===e?e:e-1],s=r[e],a=r[e>r.length-2?r.length-1:e+1];return r=r[e>r.length-3?r.length-1:e+2],t.set(ki(n,o.x,s.x,a.x,r.x),ki(n,o.y,s.y,a.y,r.y)),t},Zi.prototype.copy=function(e){Fi.prototype.copy.call(this,e),this.points=[];for(var t=0,i=e.points.length;t<i;t++)this.points.push(e.points[t].clone());return this},Zi.prototype.toJSON=function(){var e=Fi.prototype.toJSON.call(this);e.points=[];for(var t=0,i=this.points.length;t<i;t++)e.points.push(this.points[t].toArray());return e},Zi.prototype.fromJSON=function(e){Fi.prototype.fromJSON.call(this,e),this.points=[];for(var t=0,r=e.points.length;t<r;t++){var n=e.points[t];this.points.push((new i).fromArray(n))}return this};var oo=Object.freeze({ArcCurve:Vi,CatmullRomCurve3:zi,CubicBezierCurve:Hi,CubicBezierCurve3:ji,EllipseCurve:Ni,LineCurve:Yi,LineCurve3:Xi,QuadraticBezierCurve:Ki,QuadraticBezierCurve3:qi,SplineCurve:Zi});Qi.prototype=Object.assign(Object.create(Fi.prototype),{constructor:Qi,add:function(e){this.curves.push(e)},closePath:function(){var e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new Yi(t,e))},getPoint:function(e){var t=e*this.getLength(),i=this.getCurveLengths();for(e=0;e<i.length;){if(i[e]>=t)return t=i[e]-t,i=(e=this.curves[e]).getLength(),e.getPointAt(0===i?0:1-t/i);e++}return null},getLength:function(){var e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],t=0,i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e},getSpacedPoints:function(e){void 0===e&&(e=40);for(var t=[],i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t},getPoints:function(e){e=e||12;for(var t,i=[],r=0,n=this.curves;r<n.length;r++){var o=n[r];o=o.getPoints(o&&o.isEllipseCurve?2*e:o&&o.isLineCurve?1:o&&o.isSplineCurve?e*o.points.length:e);for(var s=0;s<o.length;s++){var a=o[s];t&&t.equals(a)||(i.push(a),t=a)}}return this.autoClose&&1<i.length&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},copy:function(e){Fi.prototype.copy.call(this,e),this.curves=[];for(var t=0,i=e.curves.length;t<i;t++)this.curves.push(e.curves[t].clone());return this.autoClose=e.autoClose,this},toJSON:function(){var e=Fi.prototype.toJSON.call(this);e.autoClose=this.autoClose,e.curves=[];for(var t=0,i=this.curves.length;t<i;t++)e.curves.push(this.curves[t].toJSON());return e},fromJSON:function(e){Fi.prototype.fromJSON.call(this,e),this.autoClose=e.autoClose,this.curves=[];for(var t=0,i=e.curves.length;t<i;t++){var r=e.curves[t];this.curves.push((new oo[r.type]).fromJSON(r))}return this}}),Ji.prototype=Object.assign(Object.create(Qi.prototype),{constructor:Ji,setFromPoints:function(e){this.moveTo(e[0].x,e[0].y);for(var t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y)},moveTo:function(e,t){this.currentPoint.set(e,t)},lineTo:function(e,t){var r=new Yi(this.currentPoint.clone(),new i(e,t));this.curves.push(r),this.currentPoint.set(e,t)},quadraticCurveTo:function(e,t,r,n){e=new Ki(this.currentPoint.clone(),new i(e,t),new i(r,n)),this.curves.push(e),this.currentPoint.set(r,n)},bezierCurveTo:function(e,t,r,n,o,s){e=new Hi(this.currentPoint.clone(),new i(e,t),new i(r,n),new i(o,s)),this.curves.push(e),this.currentPoint.set(o,s)},splineThru:function(e){var t=[this.currentPoint.clone()].concat(e);t=new Zi(t),this.curves.push(t),this.currentPoint.copy(e[e.length-1])},arc:function(e,t,i,r,n,o){this.absarc(e+this.currentPoint.x,t+this.currentPoint.y,i,r,n,o)},absarc:function(e,t,i,r,n,o){this.absellipse(e,t,i,i,r,n,o)},ellipse:function(e,t,i,r,n,o,s,a){this.absellipse(e+this.currentPoint.x,t+this.currentPoint.y,i,r,n,o,s,a)},absellipse:function(e,t,i,r,n,o,s,a){e=new Ni(e,t,i,r,n,o,s,a),0<this.curves.length&&((t=e.getPoint(0)).equals(this.currentPoint)||this.lineTo(t.x,t.y)),this.curves.push(e),e=e.getPoint(1),this.currentPoint.copy(e)},copy:function(e){return Qi.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){var e=Qi.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return Qi.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}}),$i.prototype=Object.assign(Object.create(Ji.prototype),{constructor:$i,getPointsHoles:function(e){for(var t=[],i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t},extractPoints:function(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}},copy:function(e){Ji.prototype.copy.call(this,e),this.holes=[];for(var t=0,i=e.holes.length;t<i;t++)this.holes.push(e.holes[t].clone());return this},toJSON:function(){var e=Ji.prototype.toJSON.call(this);e.uuid=this.uuid,e.holes=[];for(var t=0,i=this.holes.length;t<i;t++)e.holes.push(this.holes[t].toJSON());return e},fromJSON:function(e){Ji.prototype.fromJSON.call(this,e),this.uuid=e.uuid,this.holes=[];for(var t=0,i=e.holes.length;t<i;t++){var r=e.holes[t];this.holes.push((new Ji).fromJSON(r))}return this}}),er.prototype=Object.assign(Object.create(x.prototype),{constructor:er,isLight:!0,copy:function(e){return x.prototype.copy.call(this,e),this.color.copy(e.color),this.intensity=e.intensity,this},toJSON:function(e){return(e=x.prototype.toJSON.call(this,e)).object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),tr.prototype=Object.assign(Object.create(er.prototype),{constructor:tr,isHemisphereLight:!0,copy:function(e){return er.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}),Object.assign(ir.prototype,{copy:function(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var e={};return 0!==this.bias&&(e.bias=this.bias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}),rr.prototype=Object.assign(Object.create(ir.prototype),{constructor:rr,isSpotLightShadow:!0,update:function(e){var t=this.camera,i=2*An.RAD2DEG*e.angle,r=this.mapSize.width/this.mapSize.height;e=e.distance||t.far,i===t.fov&&r===t.aspect&&e===t.far||(t.fov=i,t.aspect=r,t.far=e,t.updateProjectionMatrix())}}),nr.prototype=Object.assign(Object.create(er.prototype),{constructor:nr,isSpotLight:!0,copy:function(e){return er.prototype.copy.call(this,e),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),or.prototype=Object.assign(Object.create(er.prototype),{constructor:or,isPointLight:!0,copy:function(e){return er.prototype.copy.call(this,e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}),sr.prototype=Object.assign(Object.create(ir.prototype),{constructor:sr}),ar.prototype=Object.assign(Object.create(er.prototype),{constructor:ar,isDirectionalLight:!0,copy:function(e){return er.prototype.copy.call(this,e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),hr.prototype=Object.assign(Object.create(er.prototype),{constructor:hr,isAmbientLight:!0}),cr.prototype=Object.assign(Object.create(er.prototype),{constructor:cr,isRectAreaLight:!0,copy:function(e){return er.prototype.copy.call(this,e),this.width=e.width,this.height=e.height,this},toJSON:function(e){return(e=er.prototype.toJSON.call(this,e)).object.width=this.width,e.object.height=this.height,e}}),lr.prototype=Object.assign(Object.create(xr.prototype),{constructor:lr,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),ur.prototype=Object.assign(Object.create(xr.prototype),{constructor:ur,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Object.assign(dr.prototype,{evaluate:function(e){var t=this.parameterPositions,i=this._cachedIndex,r=t[i],n=t[i-1];e:{t:{i:{r:if(!(e<r)){for(var o=i+2;;){if(void 0===r){if(e<n)break r;return this._cachedIndex=i=t.length,this.afterEnd_(i-1,e,n)}if(i===o)break;if(n=r,e<(r=t[++i]))break t}r=t.length;break i}if(e>=n)break e;for(e<(o=t[1])&&(i=2,n=o),o=i-2;;){if(void 0===n)return this._cachedIndex=0,this.beforeStart_(0,e,r);if(i===o)break;if(r=n,e>=(n=t[--i-1]))break t}r=i,i=0}for(;i<r;)e<t[n=i+r>>>1]?r=n:i=n+1;if(r=t[i],void 0===(n=t[i-1]))return this._cachedIndex=0,this.beforeStart_(0,e,r);if(void 0===r)return this._cachedIndex=i=t.length,this.afterEnd_(i-1,n,e)}this._cachedIndex=i,this.intervalChanged_(i,n,r)}return this.interpolate_(i,n,e,r)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(e){var t=this.resultBuffer,i=this.sampleValues,r=this.valueSize;e*=r;for(var n=0;n!==r;++n)t[n]=i[e+n];return t},interpolate_:function(){throw Error("call to abstract method")},intervalChanged_:function(){}}),Object.assign(dr.prototype,{beforeStart_:dr.prototype.copySampleValue_,afterEnd_:dr.prototype.copySampleValue_}),fr.prototype=Object.assign(Object.create(dr.prototype),{constructor:fr,interpolate_:function(e,t,i,r){var o=this.resultBuffer,s=this.sampleValues,a=this.valueSize;for(t=(i-t)/(r-t),i=(e*=a)+a;e!==i;e+=4)n.slerpFlat(o,0,s,e-a,s,e,t);return o}}),pr.prototype=Object.assign(Object.create(xr.prototype),{constructor:pr,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(e){return new fr(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0}),mr.prototype=Object.assign(Object.create(xr.prototype),{constructor:mr,ValueTypeName:"color"}),gr.prototype=Object.assign(Object.create(xr.prototype),{constructor:gr,ValueTypeName:"number"}),vr.prototype=Object.assign(Object.create(dr.prototype),{constructor:vr,DefaultSettings_:{endingStart:2400,endingEnd:2400},intervalChanged_:function(e,t,i){var r=this.parameterPositions,n=e-2,o=e+1,s=r[n],a=r[o];if(void 0===s)switch(this.getSettings_().endingStart){case 2401:n=e,s=2*t-i;break;case 2402:s=t+r[n=r.length-2]-r[n+1];break;default:n=e,s=i}if(void 0===a)switch(this.getSettings_().endingEnd){case 2401:o=e,a=2*i-t;break;case 2402:o=1,a=i+r[1]-r[0];break;default:o=e-1,a=t}e=.5*(i-t),r=this.valueSize,this._weightPrev=e/(t-s),this._weightNext=e/(a-i),this._offsetPrev=n*r,this._offsetNext=o*r},interpolate_:function(e,t,i,r){var n=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=(e*=s)-s,h=this._offsetPrev,c=this._offsetNext,l=this._weightPrev,u=this._weightNext,d=(i-t)/(r-t);for(t=-l*(r=(i=d*d)*d)+2*l*i-l*d,l=(1+l)*r+(-1.5-2*l)*i+(-.5+l)*d+1,d=(-1-u)*r+(1.5+u)*i+.5*d,u=u*r-u*i,i=0;i!==s;++i)n[i]=t*o[h+i]+l*o[a+i]+d*o[e+i]+u*o[c+i];return n}}),_r.prototype=Object.assign(Object.create(dr.prototype),{constructor:_r,interpolate_:function(e,t,i,r){var n=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=(e*=s)-s;for(i=1-(t=(i-t)/(r-t)),r=0;r!==s;++r)n[r]=o[a+r]*i+o[e+r]*t;return n}}),yr.prototype=Object.assign(Object.create(dr.prototype),{constructor:yr,interpolate_:function(e){return this.copySampleValue_(e-1)}});var so={arraySlice:function(e,t,i){return so.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==i?i:e.length)):e.slice(t,i)},convertArray:function(e,t,i){return!e||!i&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){for(var t=e.length,i=Array(t),r=0;r!==t;++r)i[r]=r;return i.sort(function(t,i){return e[t]-e[i]}),i},sortedArray:function(e,t,i){for(var r=e.length,n=new e.constructor(r),o=0,s=0;s!==r;++o)for(var a=i[o]*t,h=0;h!==t;++h)n[s++]=e[a+h];return n},flattenJSON:function(e,t,i,r){for(var n=1,o=e[0];void 0!==o&&void 0===o[r];)o=e[n++];if(void 0!==o){var s=o[r];if(void 0!==s)if(Array.isArray(s))do{void 0!==(s=o[r])&&(t.push(o.time),i.push.apply(i,s)),o=e[n++]}while(void 0!==o);else if(void 0!==s.toArray)do{void 0!==(s=o[r])&&(t.push(o.time),s.toArray(i,i.length)),o=e[n++]}while(void 0!==o);else do{void 0!==(s=o[r])&&(t.push(o.time),i.push(s)),o=e[n++]}while(void 0!==o)}}};Object.assign(xr,{parse:function(e){if(void 0===e.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");var t=xr._getTrackTypeForValueTypeName(e.type);if(void 0===e.times){var i=[],r=[];so.flattenJSON(e.keys,i,r,"value"),e.times=i,e.values=r}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)},toJSON:function(e){var t=e.constructor;if(void 0!==t.toJSON)t=t.toJSON(e);else{t={name:e.name,times:so.convertArray(e.times,Array),values:so.convertArray(e.values,Array)};var i=e.getInterpolation();i!==e.DefaultInterpolation&&(t.interpolation=i)}return t.type=e.ValueTypeName,t},_getTrackTypeForValueTypeName:function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return gr;case"vector":case"vector2":case"vector3":case"vector4":return br;case"color":return mr;case"quaternion":return pr;case"bool":case"boolean":return ur;case"string":return lr}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}}),Object.assign(xr.prototype,{constructor:xr,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:2301,InterpolantFactoryMethodDiscrete:function(e){return new yr(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodLinear:function(e){return new _r(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:function(e){return new vr(this.times,this.values,this.getValueSize(),e)},setInterpolation:function(e){switch(e){case 2300:var t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){if(t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name,void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw Error(t);this.setInterpolation(this.DefaultInterpolation)}console.warn("THREE.KeyframeTrack:",t)}else this.createInterpolant=t},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302}},getValueSize:function(){return this.values.length/this.times.length},shift:function(e){if(0!==e)for(var t=this.times,i=0,r=t.length;i!==r;++i)t[i]+=e;return this},scale:function(e){if(1!==e)for(var t=this.times,i=0,r=t.length;i!==r;++i)t[i]*=e;return this},trim:function(e,t){for(var i=this.times,r=i.length,n=0,o=r-1;n!==r&&i[n]<e;)++n;for(;-1!==o&&i[o]>t;)--o;return++o,0===n&&o===r||(n>=o&&(n=(o=Math.max(o,1))-1),e=this.getValueSize(),this.times=so.arraySlice(i,n,o),this.values=so.arraySlice(this.values,n*e,o*e)),this},validate:function(){var e=!0,t=this.getValueSize();0!=t-Math.floor(t)&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);var i=this.times;t=this.values;var r=i.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);for(var n=null,o=0;o!==r;o++){var s=i[o];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,s),e=!1;break}if(null!==n&&n>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,s,n),e=!1;break}n=s}if(void 0!==t&&so.isTypedArray(t))for(o=0,i=t.length;o!==i;++o)if(r=t[o],isNaN(r)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,r),e=!1;break}return e},optimize:function(){for(var e=this.times,t=this.values,i=this.getValueSize(),r=2302===this.getInterpolation(),n=1,o=e.length-1,s=1;s<o;++s){var a=!1,h=e[s];if(h!==e[s+1]&&(1!==s||h!==h[0]))if(r)a=!0;else{var c=s*i,l=c-i,u=c+i;for(h=0;h!==i;++h){var d=t[c+h];if(d!==t[l+h]||d!==t[u+h]){a=!0;break}}}if(a){if(s!==n)for(e[n]=e[s],a=s*i,c=n*i,h=0;h!==i;++h)t[c+h]=t[a+h];++n}}if(0<o){for(e[n]=e[o],a=o*i,c=n*i,h=0;h!==i;++h)t[c+h]=t[a+h];++n}return n!==e.length&&(this.times=so.arraySlice(e,0,n),this.values=so.arraySlice(t,0,n*i)),this}}),br.prototype=Object.assign(Object.create(xr.prototype),{constructor:br,ValueTypeName:"vector"}),Object.assign(Mr,{parse:function(e){for(var t=[],i=e.tracks,r=1/(e.fps||1),n=0,o=i.length;n!==o;++n)t.push(xr.parse(i[n]).scale(r));return new Mr(e.name,e.duration,t)},toJSON:function(e){var t=[],i=e.tracks;e={name:e.name,duration:e.duration,tracks:t};for(var r=0,n=i.length;r!==n;++r)t.push(xr.toJSON(i[r]));return e},CreateFromMorphTargetSequence:function(e,t,i,r){for(var n=t.length,o=[],s=0;s<n;s++){var a=[],h=[];a.push((s+n-1)%n,s,(s+1)%n),h.push(0,1,0);var c=so.getKeyframeOrder(a);a=so.sortedArray(a,1,c),h=so.sortedArray(h,1,c),r||0!==a[0]||(a.push(n),h.push(h[0])),o.push(new gr(".morphTargetInfluences["+t[s].name+"]",a,h).scale(1/i))}return new Mr(e,-1,o)},findByName:function(e,t){var i=e;for(Array.isArray(e)||(i=e.geometry&&e.geometry.animations||e.animations),e=0;e<i.length;e++)if(i[e].name===t)return i[e];return null},CreateClipsFromMorphTargetSequences:function(e,t,i){for(var r={},n=/^([\w-]*?)([\d]+)$/,o=0,s=e.length;o<s;o++){var a=e[o],h=a.name.match(n);if(h&&1<h.length){var c=h[1];(h=r[c])||(r[c]=h=[]),h.push(a)}}for(c in e=[],r)e.push(Mr.CreateFromMorphTargetSequence(c,r[c],t,i));return e},parseAnimation:function(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;var i=function(e,t,i,r,n){if(0!==i.length){var o=[],s=[];so.flattenJSON(i,o,s,r),0!==o.length&&n.push(new e(t,o,s))}},r=[],n=e.name||"default",o=e.length||-1,s=e.fps||30;e=e.hierarchy||[];for(var a=0;a<e.length;a++){var h=e[a].keys;if(h&&0!==h.length)if(h[0].morphTargets){o={};for(var c=0;c<h.length;c++)if(h[c].morphTargets)for(var l=0;l<h[c].morphTargets.length;l++)o[h[c].morphTargets[l]]=-1;for(var u in o){var d=[],f=[];for(l=0;l!==h[c].morphTargets.length;++l){var p=h[c];d.push(p.time),f.push(p.morphTarget===u?1:0)}r.push(new gr(".morphTargetInfluence["+u+"]",d,f))}o=o.length*(s||1)}else i(br,(c=".bones["+t[a].name+"]")+".position",h,"pos",r),i(pr,c+".quaternion",h,"rot",r),i(br,c+".scale",h,"scl",r)}return 0===r.length?null:new Mr(n,o,r)}}),Object.assign(Mr.prototype,{resetDuration:function(){for(var e=0,t=0,i=this.tracks.length;t!==i;++t){var r=this.tracks[t];e=Math.max(e,r.times[r.times.length-1])}this.duration=e},trim:function(){for(var e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this},optimize:function(){for(var e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}}),Object.assign(Er.prototype,{load:function(e,t,i,r){var n=this;new Di(n.manager).load(e,function(e){t(n.parse(JSON.parse(e)))},i,r)},setTextures:function(e){this.textures=e},parse:function(e){function t(e){return void 0===r[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),r[e]}var r=this.textures,n=new Qn[e.type];if(void 0!==e.uuid&&(n.uuid=e.uuid),void 0!==e.name&&(n.name=e.name),void 0!==e.color&&n.color.setHex(e.color),void 0!==e.roughness&&(n.roughness=e.roughness),void 0!==e.metalness&&(n.metalness=e.metalness),void 0!==e.emissive&&n.emissive.setHex(e.emissive),void 0!==e.specular&&n.specular.setHex(e.specular),void 0!==e.shininess&&(n.shininess=e.shininess),void 0!==e.clearCoat&&(n.clearCoat=e.clearCoat),void 0!==e.clearCoatRoughness&&(n.clearCoatRoughness=e.clearCoatRoughness),void 0!==e.uniforms&&(n.uniforms=e.uniforms),void 0!==e.vertexShader&&(n.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(n.fragmentShader=e.fragmentShader),void 0!==e.vertexColors&&(n.vertexColors=e.vertexColors),void 0!==e.fog&&(n.fog=e.fog),void 0!==e.flatShading&&(n.flatShading=e.flatShading),void 0!==e.blending&&(n.blending=e.blending),void 0!==e.side&&(n.side=e.side),void 0!==e.opacity&&(n.opacity=e.opacity),void 0!==e.transparent&&(n.transparent=e.transparent),void 0!==e.alphaTest&&(n.alphaTest=e.alphaTest),void 0!==e.depthTest&&(n.depthTest=e.depthTest),void 0!==e.depthWrite&&(n.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(n.colorWrite=e.colorWrite),void 0!==e.wireframe&&(n.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(n.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(n.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(n.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(n.rotation=e.rotation),1!==e.linewidth&&(n.linewidth=e.linewidth),void 0!==e.dashSize&&(n.dashSize=e.dashSize),void 0!==e.gapSize&&(n.gapSize=e.gapSize),void 0!==e.scale&&(n.scale=e.scale),void 0!==e.polygonOffset&&(n.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(n.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(n.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.skinning&&(n.skinning=e.skinning),void 0!==e.morphTargets&&(n.morphTargets=e.morphTargets),void 0!==e.dithering&&(n.dithering=e.dithering),void 0!==e.visible&&(n.visible=e.visible),void 0!==e.userData&&(n.userData=e.userData),void 0!==e.shading&&(n.flatShading=1===e.shading),void 0!==e.size&&(n.size=e.size),void 0!==e.sizeAttenuation&&(n.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(n.map=t(e.map)),void 0!==e.alphaMap&&(n.alphaMap=t(e.alphaMap),n.transparent=!0),void 0!==e.bumpMap&&(n.bumpMap=t(e.bumpMap)),void 0!==e.bumpScale&&(n.bumpScale=e.bumpScale),void 0!==e.normalMap&&(n.normalMap=t(e.normalMap)),void 0!==e.normalScale){var o=e.normalScale;!1===Array.isArray(o)&&(o=[o,o]),n.normalScale=(new i).fromArray(o)}return void 0!==e.displacementMap&&(n.displacementMap=t(e.displacementMap)),void 0!==e.displacementScale&&(n.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(n.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(n.roughnessMap=t(e.roughnessMap)),void 0!==e.metalnessMap&&(n.metalnessMap=t(e.metalnessMap)),void 0!==e.emissiveMap&&(n.emissiveMap=t(e.emissiveMap)),void 0!==e.emissiveIntensity&&(n.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(n.specularMap=t(e.specularMap)),void 0!==e.envMap&&(n.envMap=t(e.envMap)),void 0!==e.reflectivity&&(n.reflectivity=e.reflectivity),void 0!==e.lightMap&&(n.lightMap=t(e.lightMap)),void 0!==e.lightMapIntensity&&(n.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(n.aoMap=t(e.aoMap)),void 0!==e.aoMapIntensity&&(n.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(n.gradientMap=t(e.gradientMap)),n}}),Object.assign(Tr.prototype,{load:function(e,t,i,r){var n=this;new Di(n.manager).load(e,function(e){t(n.parse(JSON.parse(e)))},i,r)},parse:function(e){var t=new N,i=e.data.index;void 0!==i&&(i=new ao[i.type](i.array),t.setIndex(new w(i,1)));var r=e.data.attributes;for(s in r){var n=r[s];i=new ao[n.type](n.array),t.addAttribute(s,new w(i,n.itemSize,n.normalized))}var s=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==s)for(i=0,r=s.length;i!==r;++i)n=s[i],t.addGroup(n.start,n.count,n.materialIndex);return void 0!==(e=e.data.boundingSphere)&&(s=new o,void 0!==e.center&&s.fromArray(e.center),t.boundingSphere=new f(s,e.radius)),t}});var ao={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!=typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};wr.Handlers={handlers:[],add:function(e,t){this.handlers.push(e,t)},get:function(e){for(var t=this.handlers,i=0,r=t.length;i<r;i+=2){var n=t[i+1];if(t[i].test(e))return n}return null}},Object.assign(wr.prototype,{crossOrigin:void 0,onLoadStart:function(){},onLoadProgress:function(){},onLoadComplete:function(){},initMaterials:function(e,t,i){for(var r=[],n=0;n<e.length;++n)r[n]=this.createMaterial(e[n],t,i);return r},createMaterial:function(){var e={NoBlending:0,NormalBlending:1,AdditiveBlending:2,SubtractiveBlending:3,MultiplyBlending:4,CustomBlending:5},t=new g,i=new Bi,r=new Er;return function(n,o,s){function a(e,t,r,n,a){e=o+e;var h=wr.Handlers.get(e);return null!==h?e=h.load(e):(i.setCrossOrigin(s),e=i.load(e)),void 0!==t&&(e.repeat.fromArray(t),1!==t[0]&&(e.wrapS=1e3),1!==t[1]&&(e.wrapT=1e3)),void 0!==r&&e.offset.fromArray(r),void 0!==n&&("repeat"===n[0]&&(e.wrapS=1e3),"mirror"===n[0]&&(e.wrapS=1002),"repeat"===n[1]&&(e.wrapT=1e3),"mirror"===n[1]&&(e.wrapT=1002)),void 0!==a&&(e.anisotropy=a),t=An.generateUUID(),c[t]=e,t}var h,c={},l={uuid:An.generateUUID(),type:"MeshLambertMaterial"};for(h in n){var u=n[h];switch(h){case"DbgColor":case"DbgIndex":case"opticalDensity":case"illumination":break;case"DbgName":l.name=u;break;case"blending":l.blending=e[u];break;case"colorAmbient":case"mapAmbient":console.warn("THREE.Loader.createMaterial:",h,"is no longer supported.");break;case"colorDiffuse":l.color=t.fromArray(u).getHex();break;case"colorSpecular":l.specular=t.fromArray(u).getHex();break;case"colorEmissive":l.emissive=t.fromArray(u).getHex();break;case"specularCoef":l.shininess=u;break;case"shading":"basic"===u.toLowerCase()&&(l.type="MeshBasicMaterial"),"phong"===u.toLowerCase()&&(l.type="MeshPhongMaterial"),"standard"===u.toLowerCase()&&(l.type="MeshStandardMaterial");break;case"mapDiffuse":l.map=a(u,n.mapDiffuseRepeat,n.mapDiffuseOffset,n.mapDiffuseWrap,n.mapDiffuseAnisotropy);break;case"mapDiffuseRepeat":case"mapDiffuseOffset":case"mapDiffuseWrap":case"mapDiffuseAnisotropy":break;case"mapEmissive":l.emissiveMap=a(u,n.mapEmissiveRepeat,n.mapEmissiveOffset,n.mapEmissiveWrap,n.mapEmissiveAnisotropy);break;case"mapEmissiveRepeat":case"mapEmissiveOffset":case"mapEmissiveWrap":case"mapEmissiveAnisotropy":break;case"mapLight":l.lightMap=a(u,n.mapLightRepeat,n.mapLightOffset,n.mapLightWrap,n.mapLightAnisotropy);break;case"mapLightRepeat":case"mapLightOffset":case"mapLightWrap":case"mapLightAnisotropy":break;case"mapAO":l.aoMap=a(u,n.mapAORepeat,n.mapAOOffset,n.mapAOWrap,n.mapAOAnisotropy);break;case"mapAORepeat":case"mapAOOffset":case"mapAOWrap":case"mapAOAnisotropy":break;case"mapBump":l.bumpMap=a(u,n.mapBumpRepeat,n.mapBumpOffset,n.mapBumpWrap,n.mapBumpAnisotropy);break;case"mapBumpScale":l.bumpScale=u;break;case"mapBumpRepeat":case"mapBumpOffset":case"mapBumpWrap":case"mapBumpAnisotropy":break;case"mapNormal":l.normalMap=a(u,n.mapNormalRepeat,n.mapNormalOffset,n.mapNormalWrap,n.mapNormalAnisotropy);break;case"mapNormalFactor":l.normalScale=u;break;case"mapNormalRepeat":case"mapNormalOffset":case"mapNormalWrap":case"mapNormalAnisotropy":break;case"mapSpecular":l.specularMap=a(u,n.mapSpecularRepeat,n.mapSpecularOffset,n.mapSpecularWrap,n.mapSpecularAnisotropy);break;case"mapSpecularRepeat":case"mapSpecularOffset":case"mapSpecularWrap":case"mapSpecularAnisotropy":break;case"mapMetalness":l.metalnessMap=a(u,n.mapMetalnessRepeat,n.mapMetalnessOffset,n.mapMetalnessWrap,n.mapMetalnessAnisotropy);break;case"mapMetalnessRepeat":case"mapMetalnessOffset":case"mapMetalnessWrap":case"mapMetalnessAnisotropy":break;case"mapRoughness":l.roughnessMap=a(u,n.mapRoughnessRepeat,n.mapRoughnessOffset,n.mapRoughnessWrap,n.mapRoughnessAnisotropy);break;case"mapRoughnessRepeat":case"mapRoughnessOffset":case"mapRoughnessWrap":case"mapRoughnessAnisotropy":break;case"mapAlpha":l.alphaMap=a(u,n.mapAlphaRepeat,n.mapAlphaOffset,n.mapAlphaWrap,n.mapAlphaAnisotropy);break;case"mapAlphaRepeat":case"mapAlphaOffset":case"mapAlphaWrap":case"mapAlphaAnisotropy":break;case"flipSided":l.side=1;break;case"doubleSided":l.side=2;break;case"transparency":console.warn("THREE.Loader.createMaterial: transparency has been renamed to opacity"),l.opacity=u;break;case"depthTest":case"depthWrite":case"colorWrite":case"opacity":case"reflectivity":case"transparent":case"visible":case"wireframe":l[h]=u;break;case"vertexColors":!0===u&&(l.vertexColors=2),"face"===u&&(l.vertexColors=1);break;default:console.error("THREE.Loader.createMaterial: Unsupported",h,u)}}return"MeshBasicMaterial"===l.type&&delete l.emissive,"MeshPhongMaterial"!==l.type&&delete l.specular,1>l.opacity&&(l.transparent=!0),r.setTextures(c),r.parse(l)}}()});var ho={decodeText:function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var t="",i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);return decodeURIComponent(escape(t))},extractUrlBase:function(e){var t=e.lastIndexOf("/");return-1===t?"./":e.substr(0,t+1)}};Object.assign(Sr.prototype,{load:function(e,t,i,r){var n=this,o=this.texturePath&&"string"==typeof this.texturePath?this.texturePath:ho.extractUrlBase(e),s=new Di(this.manager);s.setWithCredentials(this.withCredentials),s.load(e,function(i){var r=(i=JSON.parse(i)).metadata;void 0===r||(void 0===(r=r.type)||"object"!==r.toLowerCase())?(i=n.parse(i,o),t(i.geometry,i.materials)):console.error("THREE.JSONLoader: "+e+" should be loaded with THREE.ObjectLoader instead.")},i,r)},setTexturePath:function(e){this.texturePath=e},parse:function(e,t){void 0!==e.data&&(e=e.data),e.scale=void 0!==e.scale?1/e.scale:1;var r,n,s,a=new T,c=e,l=c.faces,u=c.vertices,d=c.normals,f=c.colors,p=c.scale,m=0;if(void 0!==c.uvs){for(r=0;r<c.uvs.length;r++)c.uvs[r].length&&m++;for(r=0;r<m;r++)a.faceVertexUvs[r]=[]}var v=0;for(s=u.length;v<s;)(r=new o).x=u[v++]*p,r.y=u[v++]*p,r.z=u[v++]*p,a.vertices.push(r);for(v=0,s=l.length;v<s;){var _=1&(u=l[v++]),y=2&u;r=8&u;var x=16&u,b=32&u;if(p=64&u,u&=128,_){(_=new E).a=l[v],_.b=l[v+1],_.c=l[v+3];var M=new E;if(M.a=l[v+1],M.b=l[v+2],M.c=l[v+3],v+=4,y&&(y=l[v++],_.materialIndex=y,M.materialIndex=y),y=a.faces.length,r)for(r=0;r<m;r++){var w=c.uvs[r];for(a.faceVertexUvs[r][y]=[],a.faceVertexUvs[r][y+1]=[],n=0;4>n;n++){var S=l[v++],A=w[2*S];A=new i(A,S=w[2*S+1]),2!==n&&a.faceVertexUvs[r][y].push(A),0!==n&&a.faceVertexUvs[r][y+1].push(A)}}if(x&&(x=3*l[v++],_.normal.set(d[x++],d[x++],d[x]),M.normal.copy(_.normal)),b)for(r=0;4>r;r++)x=3*l[v++],b=new o(d[x++],d[x++],d[x]),2!==r&&_.vertexNormals.push(b),0!==r&&M.vertexNormals.push(b);if(p&&(p=f[p=l[v++]],_.color.setHex(p),M.color.setHex(p)),u)for(r=0;4>r;r++)p=f[p=l[v++]],2!==r&&_.vertexColors.push(new g(p)),0!==r&&M.vertexColors.push(new g(p));a.faces.push(_),a.faces.push(M)}else{if((_=new E).a=l[v++],_.b=l[v++],_.c=l[v++],y&&(y=l[v++],_.materialIndex=y),y=a.faces.length,r)for(r=0;r<m;r++)for(w=c.uvs[r],a.faceVertexUvs[r][y]=[],n=0;3>n;n++)A=new i(A=w[2*(S=l[v++])],S=w[2*S+1]),a.faceVertexUvs[r][y].push(A);if(x&&(x=3*l[v++],_.normal.set(d[x++],d[x++],d[x])),b)for(r=0;3>r;r++)x=3*l[v++],b=new o(d[x++],d[x++],d[x]),_.vertexNormals.push(b);if(p&&(p=l[v++],_.color.setHex(f[p])),u)for(r=0;3>r;r++)p=l[v++],_.vertexColors.push(new g(f[p]));a.faces.push(_)}}if(v=void 0!==(c=e).influencesPerVertex?c.influencesPerVertex:2,c.skinWeights)for(s=0,l=c.skinWeights.length;s<l;s+=v)a.skinWeights.push(new h(c.skinWeights[s],1<v?c.skinWeights[s+1]:0,2<v?c.skinWeights[s+2]:0,3<v?c.skinWeights[s+3]:0));if(c.skinIndices)for(s=0,l=c.skinIndices.length;s<l;s+=v)a.skinIndices.push(new h(c.skinIndices[s],1<v?c.skinIndices[s+1]:0,2<v?c.skinIndices[s+2]:0,3<v?c.skinIndices[s+3]:0));if(a.bones=c.bones,a.bones&&0<a.bones.length&&(a.skinWeights.length!==a.skinIndices.length||a.skinIndices.length!==a.vertices.length)&&console.warn("When skinning, number of vertices ("+a.vertices.length+"), skinIndices ("+a.skinIndices.length+"), and skinWeights ("+a.skinWeights.length+") should match."),l=(s=e).scale,void 0!==s.morphTargets)for(c=0,v=s.morphTargets.length;c<v;c++)for(a.morphTargets[c]={},a.morphTargets[c].name=s.morphTargets[c].name,a.morphTargets[c].vertices=[],d=a.morphTargets[c].vertices,m=0,u=(f=s.morphTargets[c].vertices).length;m<u;m+=3)(p=new o).x=f[m]*l,p.y=f[m+1]*l,p.z=f[m+2]*l,d.push(p);if(void 0!==s.morphColors&&0<s.morphColors.length)for(console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.'),l=a.faces,s=s.morphColors[0].colors,c=0,v=l.length;c<v;c++)l[c].color.fromArray(s,3*c);for(c=[],v=[],void 0!==(s=e).animation&&v.push(s.animation),void 0!==s.animations&&(s.animations.length?v=v.concat(s.animations):v.push(s.animations)),s=0;s<v.length;s++)(l=Mr.parseAnimation(v[s],a.bones))&&c.push(l);return a.morphTargets&&(v=Mr.CreateClipsFromMorphTargetSequences(a.morphTargets,10),c=c.concat(v)),0<c.length&&(a.animations=c),a.computeFaceNormals(),a.computeBoundingSphere(),void 0===e.materials||0===e.materials.length?{geometry:a}:{geometry:a,materials:e=wr.prototype.initMaterials(e.materials,t,this.crossOrigin)}}}),Object.assign(Ar.prototype,{load:function(e,t,i,r){""===this.texturePath&&(this.texturePath=e.substring(0,e.lastIndexOf("/")+1));var n=this;new Di(n.manager).load(e,function(i){var o=null;try{o=JSON.parse(i)}catch(t){return void 0!==r&&r(t),void console.error("THREE:ObjectLoader: Can't parse "+e+".",t.message)}void 0===(i=o.metadata)||void 0===i.type||"geometry"===i.type.toLowerCase()?console.error("THREE.ObjectLoader: Can't load "+e+". Use THREE.JSONLoader instead."):n.parse(o,t)},i,r)},setTexturePath:function(e){this.texturePath=e},setCrossOrigin:function(e){this.crossOrigin=e},parse:function(e,t){var i=this.parseShape(e.shapes);i=this.parseGeometries(e.geometries,i);var r=this.parseImages(e.images,function(){void 0!==t&&t(n)});r=this.parseTextures(e.textures,r),r=this.parseMaterials(e.materials,r);var n=this.parseObject(e.object,i,r);return e.animations&&(n.animations=this.parseAnimations(e.animations)),void 0!==e.images&&0!==e.images.length||void 0===t||t(n),n},parseShape:function(e){var t={};if(void 0!==e)for(var i=0,r=e.length;i<r;i++){var n=(new $i).fromJSON(e[i]);t[n.uuid]=n}return t},parseGeometries:function(e,t){var i={};if(void 0!==e)for(var r=new Sr,n=new Tr,o=0,s=e.length;o<s;o++){var a=e[o];switch(a.type){case"PlaneGeometry":case"PlaneBufferGeometry":var h=new Zn[a.type](a.width,a.height,a.widthSegments,a.heightSegments);break;case"BoxGeometry":case"BoxBufferGeometry":case"CubeGeometry":h=new Zn[a.type](a.width,a.height,a.depth,a.widthSegments,a.heightSegments,a.depthSegments);break;case"CircleGeometry":case"CircleBufferGeometry":h=new Zn[a.type](a.radius,a.segments,a.thetaStart,a.thetaLength);break;case"CylinderGeometry":case"CylinderBufferGeometry":h=new Zn[a.type](a.radiusTop,a.radiusBottom,a.height,a.radialSegments,a.heightSegments,a.openEnded,a.thetaStart,a.thetaLength);break;case"ConeGeometry":case"ConeBufferGeometry":h=new Zn[a.type](a.radius,a.height,a.radialSegments,a.heightSegments,a.openEnded,a.thetaStart,a.thetaLength);break;case"SphereGeometry":case"SphereBufferGeometry":h=new Zn[a.type](a.radius,a.widthSegments,a.heightSegments,a.phiStart,a.phiLength,a.thetaStart,a.thetaLength);break;case"DodecahedronGeometry":case"DodecahedronBufferGeometry":case"IcosahedronGeometry":case"IcosahedronBufferGeometry":case"OctahedronGeometry":case"OctahedronBufferGeometry":case"TetrahedronGeometry":case"TetrahedronBufferGeometry":h=new Zn[a.type](a.radius,a.detail);break;case"RingGeometry":case"RingBufferGeometry":h=new Zn[a.type](a.innerRadius,a.outerRadius,a.thetaSegments,a.phiSegments,a.thetaStart,a.thetaLength);break;case"TorusGeometry":case"TorusBufferGeometry":h=new Zn[a.type](a.radius,a.tube,a.radialSegments,a.tubularSegments,a.arc);break;case"TorusKnotGeometry":case"TorusKnotBufferGeometry":h=new Zn[a.type](a.radius,a.tube,a.tubularSegments,a.radialSegments,a.p,a.q);break;case"LatheGeometry":case"LatheBufferGeometry":h=new Zn[a.type](a.points,a.segments,a.phiStart,a.phiLength);break;case"PolyhedronGeometry":case"PolyhedronBufferGeometry":h=new Zn[a.type](a.vertices,a.indices,a.radius,a.details);break;case"ShapeGeometry":case"ShapeBufferGeometry":h=[];for(var c=0,l=a.shapes.length;c<l;c++)h.push(t[a.shapes[c]]);h=new Zn[a.type](h,a.curveSegments);break;case"BufferGeometry":h=n.parse(a);break;case"Geometry":h=r.parse(a,this.texturePath).geometry;break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+a.type+'"');continue}h.uuid=a.uuid,void 0!==a.name&&(h.name=a.name),i[a.uuid]=h}return i},parseMaterials:function(e,t){var i={};if(void 0!==e){var r=new Er;r.setTextures(t),t=0;for(var n=e.length;t<n;t++){var o=e[t];if("MultiMaterial"===o.type){for(var s=[],a=0;a<o.materials.length;a++)s.push(r.parse(o.materials[a]));i[o.uuid]=s}else i[o.uuid]=r.parse(o)}}return i},parseAnimations:function(e){for(var t=[],i=0;i<e.length;i++){var r=Mr.parse(e[i]);t.push(r)}return t},parseImages:function(e,t){function i(e){return r.manager.itemStart(e),o.load(e,function(){r.manager.itemEnd(e)},void 0,function(){r.manager.itemEnd(e),r.manager.itemError(e)})}var r=this,n={};if(void 0!==e&&0<e.length){var o=new Li(t=new Ci(t));o.setCrossOrigin(this.crossOrigin),t=0;for(var s=e.length;t<s;t++){var a=e[t],h=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a.url)?a.url:r.texturePath+a.url;n[a.uuid]=i(h)}}return n},parseTextures:function(e,t){function i(e,t){return"number"==typeof e?e:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}var r={};if(void 0!==e)for(var n=0,o=e.length;n<o;n++){var s=e[n];void 0===s.image&&console.warn('THREE.ObjectLoader: No "image" specified for',s.uuid),void 0===t[s.image]&&console.warn("THREE.ObjectLoader: Undefined image",s.image);var h=new a(t[s.image]);h.needsUpdate=!0,h.uuid=s.uuid,void 0!==s.name&&(h.name=s.name),void 0!==s.mapping&&(h.mapping=i(s.mapping,co)),void 0!==s.offset&&h.offset.fromArray(s.offset),void 0!==s.repeat&&h.repeat.fromArray(s.repeat),void 0!==s.center&&h.center.fromArray(s.center),void 0!==s.rotation&&(h.rotation=s.rotation),void 0!==s.wrap&&(h.wrapS=i(s.wrap[0],lo),h.wrapT=i(s.wrap[1],lo)),void 0!==s.format&&(h.format=s.format),void 0!==s.minFilter&&(h.minFilter=i(s.minFilter,uo)),void 0!==s.magFilter&&(h.magFilter=i(s.magFilter,uo)),void 0!==s.anisotropy&&(h.anisotropy=s.anisotropy),void 0!==s.flipY&&(h.flipY=s.flipY),r[s.uuid]=h}return r},parseObject:function(e,t,i){function r(e){return void 0===t[e]&&console.warn("THREE.ObjectLoader: Undefined geometry",e),t[e]}function n(e){if(void 0!==e){if(Array.isArray(e)){for(var t=[],r=0,n=e.length;r<n;r++){var o=e[r];void 0===i[o]&&console.warn("THREE.ObjectLoader: Undefined material",o),t.push(i[o])}return t}return void 0===i[e]&&console.warn("THREE.ObjectLoader: Undefined material",e),i[e]}}switch(e.type){case"Scene":var o=new tt;void 0!==e.background&&Number.isInteger(e.background)&&(o.background=new g(e.background)),void 0!==e.fog&&("Fog"===e.fog.type?o.fog=new et(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(o.fog=new $e(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":o=new qe(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(o.focus=e.focus),void 0!==e.zoom&&(o.zoom=e.zoom),void 0!==e.filmGauge&&(o.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(o.filmOffset=e.filmOffset),void 0!==e.view&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new M(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(o.zoom=e.zoom),void 0!==e.view&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new hr(e.color,e.intensity);break;case"DirectionalLight":o=new ar(e.color,e.intensity);break;case"PointLight":o=new or(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new cr(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new nr(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new tr(e.color,e.groundColor,e.intensity);break;case"SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.");case"Mesh":o=r(e.geometry);var s=n(e.material);o=o.bones&&0<o.bones.length?new at(o,s):new K(o,s);break;case"LOD":o=new nt;break;case"Line":o=new ct(r(e.geometry),n(e.material),e.mode);break;case"LineLoop":o=new ut(r(e.geometry),n(e.material));break;case"LineSegments":o=new lt(r(e.geometry),n(e.material));break;case"PointCloud":case"Points":o=new ft(r(e.geometry),n(e.material));break;case"Sprite":o=new rt(n(e.material));break;case"Group":o=new pt;break;default:o=new x}if(o.uuid=e.uuid,void 0!==e.name&&(o.name=e.name),void 0!==e.matrix?(o.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(void 0!==e.position&&o.position.fromArray(e.position),void 0!==e.rotation&&o.rotation.fromArray(e.rotation),void 0!==e.quaternion&&o.quaternion.fromArray(e.quaternion),void 0!==e.scale&&o.scale.fromArray(e.scale)),void 0!==e.castShadow&&(o.castShadow=e.castShadow),void 0!==e.receiveShadow&&(o.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(o.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(o.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&o.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(o.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(o.visible=e.visible),void 0!==e.frustumCulled&&(o.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(o.renderOrder=e.renderOrder),void 0!==e.userData&&(o.userData=e.userData),void 0!==e.children){s=e.children;for(var a=0;a<s.length;a++)o.add(this.parseObject(s[a],t,i))}if("LOD"===e.type)for(e=e.levels,s=0;s<e.length;s++){a=e[s];var h=o.getObjectByProperty("uuid",a.object);void 0!==h&&o.addLevel(h,a.distance)}return o}});var co={UVMapping:300,CubeReflectionMapping:301,CubeRefractionMapping:302,EquirectangularReflectionMapping:303,EquirectangularRefractionMapping:304,SphericalReflectionMapping:305,CubeUVReflectionMapping:306,CubeUVRefractionMapping:307},lo={RepeatWrapping:1e3,ClampToEdgeWrapping:1001,MirroredRepeatWrapping:1002},uo={NearestFilter:1003,NearestMipMapNearestFilter:1004,NearestMipMapLinearFilter:1005,LinearFilter:1006,LinearMipMapNearestFilter:1007,LinearMipMapLinearFilter:1008};Pr.prototype={constructor:Pr,setOptions:function(e){return this.options=e,this},load:function(e,t,i,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e);var n=this,o=Jn.get(e);if(void 0!==o)return n.manager.itemStart(e),setTimeout(function(){t&&t(o),n.manager.itemEnd(e)},0),o;fetch(e).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,n.options)}).then(function(i){Jn.add(e,i),t&&t(i),n.manager.itemEnd(e)}).catch(function(t){r&&r(t),n.manager.itemEnd(e),n.manager.itemError(e)})},setCrossOrigin:function(){return this},setPath:function(e){return this.path=e,this}},Object.assign(Cr.prototype,{moveTo:function(e,t){this.currentPath=new Ji,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t)},lineTo:function(e,t){this.currentPath.lineTo(e,t)},quadraticCurveTo:function(e,t,i,r){this.currentPath.quadraticCurveTo(e,t,i,r)},bezierCurveTo:function(e,t,i,r,n,o){this.currentPath.bezierCurveTo(e,t,i,r,n,o)},splineThru:function(e){this.currentPath.splineThru(e)},toShapes:function(e,t){function i(e){for(var t=[],i=0,r=e.length;i<r;i++){var n=e[i],o=new $i;o.curves=n.curves,t.push(o)}return t}function r(e,t){for(var i=t.length,r=!1,n=i-1,o=0;o<i;n=o++){var s=t[n],a=t[o],h=a.x-s.x,c=a.y-s.y;if(Math.abs(c)>Number.EPSILON){if(0>c&&(s=t[o],h=-h,a=t[n],c=-c),!(e.y<s.y||e.y>a.y))if(e.y===s.y){if(e.x===s.x)return!0}else{if(0===(n=c*(e.x-s.x)-h*(e.y-s.y)))return!0;0>n||(r=!r)}}else if(e.y===s.y&&(a.x<=e.x&&e.x<=s.x||s.x<=e.x&&e.x<=a.x))return!0}return r}var n=Kn.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===t)return i(o);if(t=[],1===o.length){var s=o[0],a=new $i;return a.curves=s.curves,t.push(a),t}var h=!n(o[0].getPoints());h=e?!h:h,a=[];var c=[],l=[],u=0;c[u]=void 0,l[u]=[];for(var d=0,f=o.length;d<f;d++){var p=(s=o[d]).getPoints(),m=n(p);(m=e?!m:m)?(!h&&c[u]&&u++,c[u]={s:new $i,p:p},c[u].s.curves=s.curves,h&&u++,l[u]=[]):l[u].push({h:s,p:p[0]})}if(!c[0])return i(o);if(1<c.length){for(d=!1,e=[],n=0,o=c.length;n<o;n++)a[n]=[];for(n=0,o=c.length;n<o;n++)for(s=l[n],m=0;m<s.length;m++){for(h=s[m],u=!0,p=0;p<c.length;p++)r(h.p,c[p].p)&&(n!==p&&e.push({froms:n,tos:p,hole:m}),u?(u=!1,a[p].push(h)):d=!0);u&&a[n].push(h)}0<e.length&&(d||(l=a))}for(d=0,n=c.length;d<n;d++)for(a=c[d].s,t.push(a),o=0,s=(e=l[d]).length;o<s;o++)a.holes.push(e[o].h);return t}}),Object.assign(Dr.prototype,{isFont:!0,generateShapes:function(e,t,i){void 0===t&&(t=100),i=[];var r=t;t=this.data;var n=String(e).split("");r/=t.resolution;var o=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*r;e=[];for(var s=0,a=0,h=0;h<n.length;h++){var c=n[h];if("\n"===c)s=0,a-=o;else{var l=r,u=s,d=a;if(c=t.glyphs[c]||t.glyphs["?"]){var f=new Cr;if(c.o)for(var p=c._cachedOutline||(c._cachedOutline=c.o.split(" ")),m=0,g=p.length;m<g;)switch(p[m++]){case"m":var v=p[m++]*l+u,_=p[m++]*l+d;f.moveTo(v,_);break;case"l":v=p[m++]*l+u,_=p[m++]*l+d,f.lineTo(v,_);break;case"q":var y=p[m++]*l+u,x=p[m++]*l+d,b=p[m++]*l+u,M=p[m++]*l+d;f.quadraticCurveTo(b,M,y,x);break;case"b":y=p[m++]*l+u,x=p[m++]*l+d,b=p[m++]*l+u,M=p[m++]*l+d,v=p[m++]*l+u,_=p[m++]*l+d,f.bezierCurveTo(b,M,v,_,y,x)}l={offsetX:c.ha*l,path:f}}else l=void 0;s+=l.offsetX,e.push(l.path)}}for(t=0,n=e.length;t<n;t++)Array.prototype.push.apply(i,e[t].toShapes());return i}}),Object.assign(Rr.prototype,{load:function(e,t,i,r){var n=this,o=new Di(this.manager);o.setPath(this.path),o.load(e,function(e){try{var i=JSON.parse(e)}catch(t){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),i=JSON.parse(e.substring(65,e.length-2))}e=n.parse(i),t&&t(e)},i,r)},parse:function(e){return new Dr(e)},setPath:function(e){return this.path=e,this}});var fo,po,mo,go={getContext:function(){return void 0===fo&&(fo=new(window.AudioContext||window.webkitAudioContext)),fo},setContext:function(e){fo=e}};Object.assign(Ir.prototype,{load:function(e,t,i,r){var n=new Di(this.manager);n.setResponseType("arraybuffer"),n.load(e,function(e){go.getContext().decodeAudioData(e,function(e){t(e)})},i,r)}}),Object.assign(Lr.prototype,{update:function(){var e,t,i,n,o,s,a,h,c=new r,l=new r;return function(r){if(e!==this||t!==r.focus||i!==r.fov||n!==r.aspect*this.aspect||o!==r.near||s!==r.far||a!==r.zoom||h!==this.eyeSep){e=this,t=r.focus,i=r.fov,n=r.aspect*this.aspect,o=r.near,s=r.far,a=r.zoom;var u=r.projectionMatrix.clone(),d=(h=this.eyeSep/2)*o/t,f=o*Math.tan(An.DEG2RAD*i*.5)/a;l.elements[12]=-h,c.elements[12]=h;var p=-f*n+d,m=f*n+d;u.elements[0]=2*o/(m-p),u.elements[8]=(m+p)/(m-p),this.cameraL.projectionMatrix.copy(u),p=-f*n-d,m=f*n-d,u.elements[0]=2*o/(m-p),u.elements[8]=(m+p)/(m-p),this.cameraR.projectionMatrix.copy(u)}this.cameraL.matrixWorld.copy(r.matrixWorld).multiply(l),this.cameraR.matrixWorld.copy(r.matrixWorld).multiply(c)}}()}),Or.prototype=Object.create(x.prototype),Or.prototype.constructor=Or,Br.prototype=Object.assign(Object.create(x.prototype),{constructor:Br,getInput:function(){return this.gain},removeFilter:function(){null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null)},getFilter:function(){return this.filter},setFilter:function(e){null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination)},getMasterVolume:function(){return this.gain.gain.value},setMasterVolume:function(e){this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01)},updateMatrixWorld:function(){var e=new o,t=new n,i=new o,r=new o;return function(n){x.prototype.updateMatrixWorld.call(this,n),n=this.context.listener;var o=this.up;this.matrixWorld.decompose(e,t,i),r.set(0,0,-1).applyQuaternion(t),n.positionX?(n.positionX.setValueAtTime(e.x,this.context.currentTime),n.positionY.setValueAtTime(e.y,this.context.currentTime),n.positionZ.setValueAtTime(e.z,this.context.currentTime),n.forwardX.setValueAtTime(r.x,this.context.currentTime),n.forwardY.setValueAtTime(r.y,this.context.currentTime),n.forwardZ.setValueAtTime(r.z,this.context.currentTime),n.upX.setValueAtTime(o.x,this.context.currentTime),n.upY.setValueAtTime(o.y,this.context.currentTime),n.upZ.setValueAtTime(o.z,this.context.currentTime)):(n.setPosition(e.x,e.y,e.z),n.setOrientation(r.x,r.y,r.z,o.x,o.y,o.z))}}()}),Fr.prototype=Object.assign(Object.create(x.prototype),{constructor:Fr,getOutput:function(){return this.gain},setNodeSource:function(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this},setBuffer:function(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this},play:function(){if(!0===this.isPlaying)console.warn("THREE.Audio: Audio is already playing.");else{if(!1!==this.hasPlaybackControl){var e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.onended=this.onEnded.bind(this),e.playbackRate.setValueAtTime(this.playbackRate,this.startTime),this.startTime=this.context.currentTime,e.start(this.startTime,this.offset),this.isPlaying=!0,this.source=e,this.connect()}console.warn("THREE.Audio: this Audio has no playback control.")}},pause:function(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this.source.stop(),this.offset+=(this.context.currentTime-this.startTime)*this.playbackRate,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")},stop:function(){if(!1!==this.hasPlaybackControl)return this.source.stop(),this.offset=0,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")},connect:function(){if(0<this.filters.length){this.source.connect(this.filters[0]);for(var e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this},disconnect:function(){if(0<this.filters.length){this.source.disconnect(this.filters[0]);for(var e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this},getFilters:function(){return this.filters},setFilters:function(e){return e||(e=[]),!0===this.isPlaying?(this.disconnect(),this.filters=e,this.connect()):this.filters=e,this},getFilter:function(){return this.getFilters()[0]},setFilter:function(e){return this.setFilters(e?[e]:[])},setPlaybackRate:function(e){if(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setValueAtTime(this.playbackRate,this.context.currentTime),this;console.warn("THREE.Audio: this Audio has no playback control.")},getPlaybackRate:function(){return this.playbackRate},onEnded:function(){this.isPlaying=!1},getLoop:function(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop},setLoop:function(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")},getVolume:function(){return this.gain.gain.value},setVolume:function(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}),Nr.prototype=Object.assign(Object.create(Fr.prototype),{constructor:Nr,getOutput:function(){return this.panner},getRefDistance:function(){return this.panner.refDistance},setRefDistance:function(e){this.panner.refDistance=e},getRolloffFactor:function(){return this.panner.rolloffFactor},setRolloffFactor:function(e){this.panner.rolloffFactor=e},getDistanceModel:function(){return this.panner.distanceModel},setDistanceModel:function(e){this.panner.distanceModel=e},getMaxDistance:function(){return this.panner.maxDistance},setMaxDistance:function(e){this.panner.maxDistance=e},updateMatrixWorld:function(){var e=new o;return function(t){x.prototype.updateMatrixWorld.call(this,t),e.setFromMatrixPosition(this.matrixWorld),this.panner.setPosition(e.x,e.y,e.z)}}()}),Object.assign(Vr.prototype,{getFrequencyData:function(){return this.analyser.getByteFrequencyData(this.data),this.data},getAverageFrequency:function(){for(var e=0,t=this.getFrequencyData(),i=0;i<t.length;i++)e+=t[i];return e/t.length}}),Object.assign(Ur.prototype,{accumulate:function(e,t){var i=this.buffer,r=this.valueSize;e=e*r+r;var n=this.cumulativeWeight;if(0===n){for(n=0;n!==r;++n)i[e+n]=i[n];n=t}else n+=t,this._mixBufferRegion(i,e,0,t/n,r);this.cumulativeWeight=n},apply:function(e){var t=this.valueSize,i=this.buffer;e=e*t+t;var r=this.cumulativeWeight,n=this.binding;this.cumulativeWeight=0,1>r&&this._mixBufferRegion(i,e,3*t,1-r,t),r=t;for(var o=t+t;r!==o;++r)if(i[r]!==i[r+t]){n.setValue(i,e);break}},saveOriginalState:function(){var e=this.buffer,t=this.valueSize,i=3*t;this.binding.getValue(e,i);for(var r=t;r!==i;++r)e[r]=e[i+r%t];this.cumulativeWeight=0},restoreOriginalState:function(){this.binding.setValue(this.buffer,3*this.valueSize)},_select:function(e,t,i,r,n){if(.5<=r)for(r=0;r!==n;++r)e[t+r]=e[i+r]},_slerp:function(e,t,i,r){n.slerpFlat(e,t,e,t,e,i,r)},_lerp:function(e,t,i,r,n){for(var o=1-r,s=0;s!==n;++s){var a=t+s;e[a]=e[a]*o+e[i+s]*r}}}),Object.assign(zr.prototype,{getValue:function(e,t){this.bind();var i=this._bindings[this._targetGroup.nCachedObjects_];void 0!==i&&i.getValue(e,t)},setValue:function(e,t){for(var i=this._bindings,r=this._targetGroup.nCachedObjects_,n=i.length;r!==n;++r)i[r].setValue(e,t)},bind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()},unbind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}),Object.assign(kr,{Composite:zr,create:function(e,t,i){return e&&e.isAnimationObjectGroup?new kr.Composite(e,t,i):new kr(e,t,i)},sanitizeNodeName:function(){var e=/[\[\]\.:\/]/g;return function(t){return t.replace(/\s/g,"_").replace(e,"")}}(),parseTrackName:function(){var e="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",t=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]");e=/(WCOD+)?/.source.replace("WCOD",e);var i=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),r=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),n=new RegExp("^"+t+e+i+r+"$"),o=["material","materials","bones"];return function(e){var t=n.exec(e);if(!t)throw Error("PropertyBinding: Cannot parse trackName: "+e);var i=(t={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]}).nodeName&&t.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){var r=t.nodeName.substring(i+1);-1!==o.indexOf(r)&&(t.nodeName=t.nodeName.substring(0,i),t.objectName=r)}if(null===t.propertyName||0===t.propertyName.length)throw Error("PropertyBinding: can not parse propertyName from trackName: "+e);return t}}(),findNode:function(e,t){if(!t||""===t||"root"===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){var i=e.skeleton.getBoneByName(t);if(void 0!==i)return i}if(e.children){var r=function(e){for(var i=0;i<e.length;i++){var n=e[i];if(n.name===t||n.uuid===t||(n=r(n.children)))return n}return null};if(e=r(e.children))return e}return null}}),Object.assign(kr.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(e,t){e[t]=this.node[this.propertyName]},function(e,t){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)e[t++]=i[r]},function(e,t){e[t]=this.resolvedProperty[this.propertyIndex]},function(e,t){this.resolvedProperty.toArray(e,t)}],SetterByBindingTypeAndVersioning:[[function(e,t){this.targetObject[this.propertyName]=e[t]},function(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0},function(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)i[r]=e[t++]},function(e,t){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0},function(e,t){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){this.resolvedProperty[this.propertyIndex]=e[t]},function(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0},function(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){this.resolvedProperty.fromArray(e,t)},function(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0},function(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(e,t){this.bind(),this.getValue(e,t)},setValue:function(e,t){this.bind(),this.setValue(e,t)},bind:function(){var e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,n=t.propertyIndex;if(e||(this.node=e=kr.findNode(this.rootNode,t.nodeName)||this.rootNode),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,e){if(i){var o=t.objectIndex;switch(i){case"materials":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);for(e=e.skeleton.bones,i=0;i<e.length;i++)if(e[i].name===o){o=i;break}break;default:if(void 0===e[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[i]}if(void 0!==o){if(void 0===e[o])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[o]}}if(void 0===(o=e[r]))console.error("THREE.PropertyBinding: Trying to update property for track: "+t.nodeName+"."+r+" but it wasn't found.",e);else{if(t=this.Versioning.None,void 0!==e.needsUpdate?(t=this.Versioning.NeedsUpdate,this.targetObject=e):void 0!==e.matrixWorldNeedsUpdate&&(t=this.Versioning.MatrixWorldNeedsUpdate,this.targetObject=e),i=this.BindingType.Direct,void 0!==n){if("morphTargetInfluences"===r){if(!e.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(e.geometry.isBufferGeometry){if(!e.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);for(i=0;i<this.node.geometry.morphAttributes.position.length;i++)if(e.geometry.morphAttributes.position[i].name===n){n=i;break}}else{if(!e.geometry.morphTargets)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphTargets.",this);for(i=0;i<this.node.geometry.morphTargets.length;i++)if(e.geometry.morphTargets[i].name===n){n=i;break}}}i=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=n}else void 0!==o.fromArray&&void 0!==o.toArray?(i=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(i=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[i],this.setValue=this.SetterByBindingTypeAndVersioning[i][t]}}else console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.")},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}),Object.assign(kr.prototype,{_getValue_unbound:kr.prototype.getValue,_setValue_unbound:kr.prototype.setValue}),Object.assign(Gr.prototype,{isAnimationObjectGroup:!0,add:function(){for(var e=this._objects,t=e.length,i=this.nCachedObjects_,r=this._indicesByUUID,n=this._paths,o=this._parsedPaths,s=this._bindings,a=s.length,h=void 0,c=0,l=arguments.length;c!==l;++c){var u=arguments[c],d=u.uuid,f=r[d];if(void 0===f){f=t++,r[d]=f,e.push(u),d=0;for(var p=a;d!==p;++d)s[d].push(new kr(u,n[d],o[d]))}else if(f<i){h=e[f];var m=--i;for(r[(p=e[m]).uuid]=f,e[f]=p,r[d]=m,e[m]=u,d=0,p=a;d!==p;++d){var g=s[d],v=g[f];g[f]=g[m],void 0===v&&(v=new kr(u,n[d],o[d])),g[m]=v}}else e[f]!==h&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=i},remove:function(){for(var e=this._objects,t=this.nCachedObjects_,i=this._indicesByUUID,r=this._bindings,n=r.length,o=0,s=arguments.length;o!==s;++o){var a=arguments[o],h=a.uuid,c=i[h];if(void 0!==c&&c>=t){var l=t++,u=e[l];for(i[u.uuid]=c,e[c]=u,i[h]=l,e[l]=a,a=0,h=n;a!==h;++a){var d=(u=r[a])[c];u[c]=u[l],u[l]=d}}}this.nCachedObjects_=t},uncache:function(){for(var e=this._objects,t=e.length,i=this.nCachedObjects_,r=this._indicesByUUID,n=this._bindings,o=n.length,s=0,a=arguments.length;s!==a;++s){var h=arguments[s].uuid,c=r[h];if(void 0!==c)if(delete r[h],c<i){var l=e[h=--i],u=--t,d=e[u];for(r[l.uuid]=c,e[c]=l,r[d.uuid]=h,e[h]=d,e.pop(),l=0,d=o;l!==d;++l){var f=n[l],p=f[u];f[c]=f[h],f[h]=p,f.pop()}}else for(r[(d=e[u=--t]).uuid]=c,e[c]=d,e.pop(),l=0,d=o;l!==d;++l)(f=n[l])[c]=f[u],f.pop()}this.nCachedObjects_=i},subscribe_:function(e,t){var i=this._bindingsIndicesByPath,r=i[e],n=this._bindings;if(void 0!==r)return n[r];var o=this._paths,s=this._parsedPaths,a=this._objects,h=this.nCachedObjects_,c=Array(a.length);for(r=n.length,i[e]=r,o.push(e),s.push(t),n.push(c),i=h,r=a.length;i!==r;++i)c[i]=new kr(a[i],e,t);return c},unsubscribe_:function(e){var t=this._bindingsIndicesByPath,i=t[e];if(void 0!==i){var r=this._paths,n=this._parsedPaths,o=this._bindings,s=o.length-1,a=o[s];t[e[s]]=i,o[i]=a,o.pop(),n[i]=n[s],n.pop(),r[i]=r[s],r.pop()}}}),Object.assign(Wr.prototype,{play:function(){return this._mixer._activateAction(this),this},stop:function(){return this._mixer._deactivateAction(this),this.reset()},reset:function(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()},isRunning:function(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)},isScheduled:function(){return this._mixer._isActiveAction(this)},startAt:function(e){return this._startTime=e,this},setLoop:function(e,t){return this.loop=e,this.repetitions=t,this},setEffectiveWeight:function(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(e){return this._scheduleFading(e,0,1)},fadeOut:function(e){return this._scheduleFading(e,1,0)},crossFadeFrom:function(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){i=this._clip.duration;var r=e._clip.duration,n=i/r;e.warp(1,r/i,t),this.warp(n,1,t)}return this},crossFadeTo:function(e,t,i){return e.crossFadeFrom(this,t,i)},stopFading:function(){var e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this},setEffectiveTimeScale:function(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()},getEffectiveTimeScale:function(){return this._effectiveTimeScale},setDuration:function(e){return this.timeScale=this._clip.duration/e,this.stopWarping()},syncWith:function(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()},halt:function(e){return this.warp(this._effectiveTimeScale,0,e)},warp:function(e,t,i){var r=this._mixer,n=r.time,o=this._timeScaleInterpolant,s=this.timeScale;return null===o&&(this._timeScaleInterpolant=o=r._lendControlInterpolant()),r=o.parameterPositions,o=o.sampleValues,r[0]=n,r[1]=n+i,o[0]=e/s,o[1]=t/s,this},stopWarping:function(){var e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this},getMixer:function(){return this._mixer},getClip:function(){return this._clip},getRoot:function(){return this._localRoot||this._mixer._root},_update:function(e,t,i,r){if(this.enabled){var n=this._startTime;if(null!==n){if(0>(t=(e-n)*i)||0===i)return;this._startTime=null,t*=i}if(t*=this._updateTimeScale(e),i=this._updateTime(t),0<(e=this._updateWeight(e))){t=this._interpolants,n=this._propertyBindings;for(var o=0,s=t.length;o!==s;++o)t[o].evaluate(i),n[o].accumulate(r,e)}}else this._updateWeight(e)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var i=this._weightInterpolant;if(null!==i){var r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=t},_updateTimeScale:function(e){var t=0;if(!this.paused){t=this.timeScale;var i=this._timeScaleInterpolant;if(null!==i)t*=i.evaluate(e)[0],e>i.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}return this._effectiveTimeScale=t},_updateTime:function(e){var t=this.time+e;if(0===e)return t;var i=this._clip.duration,r=this.loop,n=this._loopCount;if(2200===r)e:{if(-1===n&&(this._loopCount=0,this._setEndings(!0,!0,!1)),t>=i)t=i;else{if(!(0>t))break e;t=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:0>e?-1:1})}else{if(r=2202===r,-1===n&&(0<=e?(n=0,this._setEndings(!0,0===this.repetitions,r)):this._setEndings(0===this.repetitions,!0,r)),t>=i||0>t){var o=Math.floor(t/i);t-=i*o,n+=Math.abs(o);var s=this.repetitions-n;0>=s?(this.clampWhenFinished?this.paused=!0:this.enabled=!1,t=0<e?i:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:0<e?1:-1})):(1===s?(e=0>e,this._setEndings(e,!e,r)):this._setEndings(!1,!1,r),this._loopCount=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o}))}if(r&&1==(1&n))return this.time=t,i-t}return this.time=t},_setEndings:function(e,t,i){var r=this._interpolantSettings;i?(r.endingStart=2401,r.endingEnd=2401):(r.endingStart=e?this.zeroSlopeAtStart?2401:2400:2402,r.endingEnd=t?this.zeroSlopeAtEnd?2401:2400:2402)},_scheduleFading:function(e,t,i){var r=this._mixer,n=r.time,o=this._weightInterpolant;return null===o&&(this._weightInterpolant=o=r._lendControlInterpolant()),r=o.parameterPositions,o=o.sampleValues,r[0]=n,o[0]=t,r[1]=n+e,o[1]=i,this}}),Hr.prototype=Object.assign(Object.create(t.prototype),{constructor:Hr,_bindAction:function(e,t){var i=e._localRoot||this._root,r=e._clip.tracks,n=r.length,o=e._propertyBindings;e=e._interpolants;var s=i.uuid,a=this._bindingsByRootAndName,h=a[s];for(void 0===h&&(h={},a[s]=h),a=0;a!==n;++a){var c=r[a],l=c.name,u=h[l];if(void 0===u){if(void 0!==(u=o[a])){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,s,l));continue}++(u=new Ur(kr.create(i,l,t&&t._propertyBindings[a].binding.parsedPath),c.ValueTypeName,c.getValueSize())).referenceCount,this._addInactiveBinding(u,s,l)}o[a]=u,e[a].resultBuffer=u.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){var t=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,t)}for(i=0,r=(t=e._propertyBindings).length;i!==r;++i){var n=t[i];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,i=0,r=t.length;i!==r;++i){var n=t[i];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){return null!==(e=e._cacheIndex)&&e<this._nActiveActions},_addInactiveAction:function(e,t,i){var r=this._actions,n=this._actionsByClip,o=n[t];void 0===o?(o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,n[t]=o):(t=o.knownActions,e._byClipCacheIndex=t.length,t.push(e)),e._cacheIndex=r.length,r.push(e),o.actionByRoot[i]=e},_removeInactiveAction:function(e){var t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null,t=e._clip.uuid;var n=(r=(i=this._actionsByClip)[t]).knownActions,o=n[n.length-1],s=e._byClipCacheIndex;o._byClipCacheIndex=s,n[s]=o,n.pop(),e._byClipCacheIndex=null,delete r.actionByRoot[(e._localRoot||this._root).uuid],0===n.length&&delete i[t],this._removeInactiveBindingsForAction(e)},_removeInactiveBindingsForAction:function(e){for(var t=0,i=(e=e._propertyBindings).length;t!==i;++t){var r=e[t];0==--r.referenceCount&&this._removeInactiveBinding(r)}},_lendAction:function(e){var t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n},_takeBackAction:function(e){var t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n},_addInactiveBinding:function(e,t,i){var r=this._bindingsByRootAndName,n=r[t],o=this._bindings;void 0===n&&(n={},r[t]=n),n[i]=e,e._cacheIndex=o.length,o.push(e)},_removeInactiveBinding:function(e){var t=this._bindings,i=e.binding,r=i.rootNode.uuid;i=i.path;var n=this._bindingsByRootAndName,o=n[r],s=t[t.length-1];e=e._cacheIndex,s._cacheIndex=e,t[e]=s,t.pop(),delete o[i];e:{for(var a in o)break e;delete n[r]}},_lendBinding:function(e){var t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n},_takeBackBinding:function(e){var t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,n=t[r];e._cacheIndex=r,t[r]=e,n._cacheIndex=i,t[i]=n},_lendControlInterpolant:function(){var e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return void 0===i&&((i=new _r(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer)).__cacheIndex=t,e[t]=i),i},_takeBackControlInterpolant:function(e){var t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,n=t[r];e.__cacheIndex=r,t[r]=e,n.__cacheIndex=i,t[i]=n},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(e,t){var i=t||this._root,r=i.uuid;e=null!==(i="string"==typeof e?Mr.findByName(i,e):e)?i.uuid:e;var n=this._actionsByClip[e],o=null;if(void 0!==n){if(void 0!==(o=n.actionByRoot[r]))return o;o=n.knownActions[0],null===i&&(i=o._clip)}return null===i?null:(t=new Wr(this,i,t),this._bindAction(t,o),this._addInactiveAction(t,e,r),t)},existingAction:function(e,t){var i=t||this._root;return t=i.uuid,i="string"==typeof e?Mr.findByName(i,e):e,void 0!==(e=this._actionsByClip[i?i.uuid:e])&&e.actionByRoot[t]||null},stopAllAction:function(){for(var e=this._actions,t=this._nActiveActions,i=this._bindings,r=this._nActiveBindings,n=this._nActiveBindings=this._nActiveActions=0;n!==t;++n)e[n].reset();for(n=0;n!==r;++n)i[n].useCount=0;return this},update:function(e){e*=this.timeScale;for(var t=this._actions,i=this._nActiveActions,r=this.time+=e,n=Math.sign(e),o=this._accuIndex^=1,s=0;s!==i;++s)t[s]._update(r,e,n,o);for(e=this._bindings,t=this._nActiveBindings,s=0;s!==t;++s)e[s].apply(o);return this},getRoot:function(){return this._root},uncacheClip:function(e){var t=this._actions;e=e.uuid;var i=this._actionsByClip,r=i[e];if(void 0!==r){for(var n=0,o=(r=r.knownActions).length;n!==o;++n){var s=r[n];this._deactivateAction(s);var a=s._cacheIndex,h=t[t.length-1];s._cacheIndex=null,s._byClipCacheIndex=null,h._cacheIndex=a,t[a]=h,t.pop(),this._removeInactiveBindingsForAction(s)}delete i[e]}},uncacheRoot:function(e){e=e.uuid;var t=this._actionsByClip;for(r in t){var i=t[r].actionByRoot[e];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}var r=this._bindingsByRootAndName[e];if(void 0!==r)for(var n in r)(e=r[n]).restoreOriginalState(),this._removeInactiveBinding(e)},uncacheAction:function(e,t){null!==(e=this.existingAction(e,t))&&(this._deactivateAction(e),this._removeInactiveAction(e))}}),jr.prototype.clone=function(){return new jr(void 0===this.value.clone?this.value:this.value.clone())},Yr.prototype=Object.assign(Object.create(N.prototype),{constructor:Yr,isInstancedBufferGeometry:!0,copy:function(e){return N.prototype.copy.call(this,e),this.maxInstancedCount=e.maxInstancedCount,this},clone:function(){return(new this.constructor).copy(this)}}),Object.defineProperties(Xr.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}}),Object.assign(Xr.prototype,{isInterleavedBufferAttribute:!0,setX:function(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this},setY:function(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this},setZ:function(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this},setW:function(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this},getX:function(e){return this.data.array[e*this.data.stride+this.offset]},getY:function(e){return this.data.array[e*this.data.stride+this.offset+1]},getZ:function(e){return this.data.array[e*this.data.stride+this.offset+2]},getW:function(e){return this.data.array[e*this.data.stride+this.offset+3]},setXY:function(e,t,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this},setXYZ:function(e,t,i,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this},setXYZW:function(e,t,i,r,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=n,this}}),Object.defineProperty(Kr.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(Kr.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setArray:function(e){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");return this.count=void 0!==e?e.length/this.stride:0,this.array=e,this},setDynamic:function(e){return this.dynamic=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.dynamic=e.dynamic,this},copyAt:function(e,t,i){e*=this.stride,i*=t.stride;for(var r=0,n=this.stride;r<n;r++)this.array[e+r]=t.array[i+r];return this},set:function(e,t){return void 0===t&&(t=0),this.array.set(e,t),this},clone:function(){return(new this.constructor).copy(this)},onUpload:function(e){return this.onUploadCallback=e,this}}),qr.prototype=Object.assign(Object.create(Kr.prototype),{constructor:qr,isInstancedInterleavedBuffer:!0,copy:function(e){return Kr.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this}}),Zr.prototype=Object.assign(Object.create(w.prototype),{constructor:Zr,isInstancedBufferAttribute:!0,copy:function(e){return w.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this}}),Object.assign(Qr.prototype,{linePrecision:1,set:function(e,t){this.ray.set(e,t)},setFromCamera:function(e,t){t&&t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize()):t&&t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld)):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(e,t,i){return $r(e,this,i=i||[],t),i.sort(Jr),i},intersectObjects:function(e,t,i){if(i=i||[],!1===Array.isArray(e))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),i;for(var r=0,n=e.length;r<n;r++)$r(e[r],this,i,t);return i.sort(Jr),i}}),Object.assign(en.prototype,{start:function(){this.oldTime=this.startTime=("undefined"==typeof performance?Date:performance).now(),this.elapsedTime=0,this.running=!0},stop:function(){this.getElapsedTime(),this.autoStart=this.running=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var t=("undefined"==typeof performance?Date:performance).now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}),Object.assign(tn.prototype,{set:function(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this},makeSafe:function(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this},setFromVector3:function(e){return this.radius=e.length(),0===this.radius?this.phi=this.theta=0:(this.theta=Math.atan2(e.x,e.z),this.phi=Math.acos(An.clamp(e.y/this.radius,-1,1))),this}}),Object.assign(rn.prototype,{set:function(e,t,i){return this.radius=e,this.theta=t,this.y=i,this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this},setFromVector3:function(e){return this.radius=Math.sqrt(e.x*e.x+e.z*e.z),this.theta=Math.atan2(e.x,e.z),this.y=e.y,this}}),Object.assign(nn.prototype,{set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this},setFromCenterAndSize:function(){var e=new i;return function(t,i){return i=e.copy(i).multiplyScalar(.5),this.min.copy(t).sub(i),this.max.copy(t).add(i),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},getCenter:function(e){return void 0===e&&(console.warn("THREE.Box2: .getCenter() target is now required"),e=new i),this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(e){return void 0===e&&(console.warn("THREE.Box2: .getSize() target is now required"),e=new i),this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)},expandByPoint:function(e){return this.min.min(e),this.max.max(e),this},expandByVector:function(e){return this.min.sub(e),this.max.add(e),this},expandByScalar:function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},containsPoint:function(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y},getParameter:function(e,t){return void 0===t&&(console.warn("THREE.Box2: .getParameter() target is now required"),t=new i),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)},clampPoint:function(e,t){return void 0===t&&(console.warn("THREE.Box2: .clampPoint() target is now required"),t=new i),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new i;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}),on.prototype=Object.create(x.prototype),on.prototype.constructor=on,on.prototype.isImmediateRenderObject=!0,sn.prototype=Object.create(lt.prototype),sn.prototype.constructor=sn,sn.prototype.update=function(){var e=new o,t=new o,i=new s;return function(){var r=["a","b","c"];this.object.updateMatrixWorld(!0),i.getNormalMatrix(this.object.matrixWorld);var n=this.object.matrixWorld,o=this.geometry.attributes.position,s=this.object.geometry;if(s&&s.isGeometry)for(var a=s.vertices,h=s.faces,c=s=0,l=h.length;c<l;c++)for(var u=h[c],d=0,f=u.vertexNormals.length;d<f;d++){var p=u.vertexNormals[d];e.copy(a[u[r[d]]]).applyMatrix4(n),t.copy(p).applyMatrix3(i).normalize().multiplyScalar(this.size).add(e),o.setXYZ(s,e.x,e.y,e.z),s+=1,o.setXYZ(s,t.x,t.y,t.z),s+=1}else if(s&&s.isBufferGeometry)for(r=s.attributes.position,a=s.attributes.normal,d=s=0,f=r.count;d<f;d++)e.set(r.getX(d),r.getY(d),r.getZ(d)).applyMatrix4(n),t.set(a.getX(d),a.getY(d),a.getZ(d)),t.applyMatrix3(i).normalize().multiplyScalar(this.size).add(e),o.setXYZ(s,e.x,e.y,e.z),s+=1,o.setXYZ(s,t.x,t.y,t.z),s+=1;o.needsUpdate=!0}}(),an.prototype=Object.create(x.prototype),an.prototype.constructor=an,an.prototype.dispose=function(){this.cone.geometry.dispose(),this.cone.material.dispose()},an.prototype.update=function(){var e=new o,t=new o;return function(){this.light.updateMatrixWorld();var i=this.light.distance?this.light.distance:1e3,r=i*Math.tan(this.light.angle);this.cone.scale.set(r,r,i),e.setFromMatrixPosition(this.light.matrixWorld),t.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(t.sub(e)),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}(),hn.prototype=Object.create(lt.prototype),hn.prototype.constructor=hn,hn.prototype.updateMatrixWorld=function(){var e=new o,t=new r,i=new r;return function(r){var n=this.bones,o=this.geometry,s=o.getAttribute("position");i.getInverse(this.root.matrixWorld);for(var a=0,h=0;a<n.length;a++){var c=n[a];c.parent&&c.parent.isBone&&(t.multiplyMatrices(i,c.matrixWorld),e.setFromMatrixPosition(t),s.setXYZ(h,e.x,e.y,e.z),t.multiplyMatrices(i,c.parent.matrixWorld),e.setFromMatrixPosition(t),s.setXYZ(h+1,e.x,e.y,e.z),h+=2)}o.getAttribute("position").needsUpdate=!0,x.prototype.updateMatrixWorld.call(this,r)}}(),cn.prototype=Object.create(K.prototype),cn.prototype.constructor=cn,cn.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose()},cn.prototype.update=function(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)},ln.prototype=Object.create(x.prototype),ln.prototype.constructor=ln,ln.prototype.dispose=function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()},ln.prototype.update=function(){var e=.5*this.light.width,t=.5*this.light.height,i=this.line.geometry.attributes.position,r=i.array;r[0]=e,r[1]=-t,r[2]=0,r[3]=e,r[4]=t,r[5]=0,r[6]=-e,r[7]=t,r[8]=0,r[9]=-e,r[10]=-t,r[11]=0,r[12]=e,r[13]=-t,r[14]=0,i.needsUpdate=!0,void 0!==this.color?this.line.material.color.set(this.color):this.line.material.color.copy(this.light.color)},un.prototype=Object.create(x.prototype),un.prototype.constructor=un,un.prototype.dispose=function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()},un.prototype.update=function(){var e=new o,t=new g,i=new g;return function(){var r=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{var n=r.geometry.getAttribute("color");t.copy(this.light.color),i.copy(this.light.groundColor);for(var o=0,s=n.count;o<s;o++){var a=o<s/2?t:i;n.setXYZ(o,a.r,a.g,a.b)}n.needsUpdate=!0}r.lookAt(e.setFromMatrixPosition(this.light.matrixWorld).negate())}}(),dn.prototype=Object.create(lt.prototype),dn.prototype.constructor=dn,fn.prototype=Object.create(lt.prototype),fn.prototype.constructor=fn,pn.prototype=Object.create(lt.prototype),pn.prototype.constructor=pn,pn.prototype.update=function(){var e=new o,t=new o,i=new s;return function(){this.object.updateMatrixWorld(!0),i.getNormalMatrix(this.object.matrixWorld);for(var r=this.object.matrixWorld,n=this.geometry.attributes.position,o=this.object.geometry,s=o.vertices,a=0,h=0,c=(o=o.faces).length;h<c;h++){var l=o[h],u=l.normal;e.copy(s[l.a]).add(s[l.b]).add(s[l.c]).divideScalar(3).applyMatrix4(r),t.copy(u).applyMatrix3(i).normalize().multiplyScalar(this.size).add(e),n.setXYZ(a,e.x,e.y,e.z),a+=1,n.setXYZ(a,t.x,t.y,t.z),a+=1}n.needsUpdate=!0}}(),mn.prototype=Object.create(x.prototype),mn.prototype.constructor=mn,mn.prototype.dispose=function(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()},mn.prototype.update=function(){var e=new o,t=new o,i=new o;return function(){e.setFromMatrixPosition(this.light.matrixWorld),t.setFromMatrixPosition(this.light.target.matrixWorld),i.subVectors(t,e),this.lightPlane.lookAt(i),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(i),this.targetLine.scale.z=i.length()}}(),gn.prototype=Object.create(lt.prototype),gn.prototype.constructor=gn,gn.prototype.update=function(){function e(e,o,s,a){if(r.set(o,s,a).unproject(n),void 0!==(e=i[e]))for(o=t.getAttribute("position"),s=0,a=e.length;s<a;s++)o.setXYZ(e[s],r.x,r.y,r.z)}var t,i,r=new o,n=new b;return function(){t=this.geometry,i=this.pointMap,n.projectionMatrix.copy(this.camera.projectionMatrix),e("c",0,0,-1),e("t",0,0,1),e("n1",-1,-1,-1),e("n2",1,-1,-1),e("n3",-1,1,-1),e("n4",1,1,-1),e("f1",-1,-1,1),e("f2",1,-1,1),e("f3",-1,1,1),e("f4",1,1,1),e("u1",.7,1.1,-1),e("u2",-.7,1.1,-1),e("u3",0,2,-1),e("cf1",-1,0,1),e("cf2",1,0,1),e("cf3",0,-1,1),e("cf4",0,1,1),e("cn1",-1,0,-1),e("cn2",1,0,-1),e("cn3",0,-1,-1),e("cn4",0,1,-1),t.getAttribute("position").needsUpdate=!0}}(),vn.prototype=Object.create(lt.prototype),vn.prototype.constructor=vn,vn.prototype.update=function(){var e=new d;return function(t){if(void 0!==t&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&e.setFromObject(this.object),!e.isEmpty()){t=e.min;var i=e.max,r=this.geometry.attributes.position,n=r.array;n[0]=i.x,n[1]=i.y,n[2]=i.z,n[3]=t.x,n[4]=i.y,n[5]=i.z,n[6]=t.x,n[7]=t.y,n[8]=i.z,n[9]=i.x,n[10]=t.y,n[11]=i.z,n[12]=i.x,n[13]=i.y,n[14]=t.z,n[15]=t.x,n[16]=i.y,n[17]=t.z,n[18]=t.x,n[19]=t.y,n[20]=t.z,n[21]=i.x,n[22]=t.y,n[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}}}(),vn.prototype.setFromObject=function(e){return this.object=e,this.update(),this},_n.prototype=Object.create(lt.prototype),_n.prototype.constructor=_n,_n.prototype.updateMatrixWorld=function(e){var t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),x.prototype.updateMatrixWorld.call(this,e))},yn.prototype=Object.create(ct.prototype),yn.prototype.constructor=yn,yn.prototype.updateMatrixWorld=function(e){var t=-this.plane.constant;1e-8>Math.abs(t)&&(t=1e-8),this.scale.set(.5*this.size,.5*this.size,t),this.lookAt(this.plane.normal),x.prototype.updateMatrixWorld.call(this,e)},xn.prototype=Object.create(x.prototype),xn.prototype.constructor=xn,xn.prototype.setDirection=function(){var e,t=new o;return function(i){.99999<i.y?this.quaternion.set(0,0,0,1):-.99999>i.y?this.quaternion.set(1,0,0,0):(t.set(i.z,0,-i.x).normalize(),e=Math.acos(i.y),this.quaternion.setFromAxisAngle(t,e))}}(),xn.prototype.setLength=function(e,t,i){void 0===t&&(t=.2*e),void 0===i&&(i=.2*t),this.line.scale.set(1,Math.max(0,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()},xn.prototype.setColor=function(e){this.line.material.color.copy(e),this.cone.material.color.copy(e)},bn.prototype=Object.create(lt.prototype),bn.prototype.constructor=bn,Fi.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(Fi.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},Object.assign(Qi.prototype,{createPointsGeometry:function(e){return console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead."),e=this.getPoints(e),this.createGeometry(e)},createSpacedPointsGeometry:function(e){return console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead."),e=this.getSpacedPoints(e),this.createGeometry(e)},createGeometry:function(e){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var t=new T,i=0,r=e.length;i<r;i++){var n=e[i];t.vertices.push(new o(n.x,n.y,n.z||0))}return t}}),Object.assign(Ji.prototype,{fromPoints:function(e){console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)}}),Mn.prototype=Object.create(zi.prototype),En.prototype=Object.create(zi.prototype),Tn.prototype=Object.create(zi.prototype),Object.assign(Tn.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}}),dn.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},hn.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Object.assign(wr.prototype,{extractUrlBase:function(e){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),ho.extractUrlBase(e)}}),Object.assign(nn.prototype,{center:function(e){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(e)},empty:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(e){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},size:function(e){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(e)}}),Object.assign(d.prototype,{center:function(e){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(e)},empty:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(e){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},isIntersectionSphere:function(e){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},size:function(e){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(e)}}),Y.prototype.center=function(e){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(e)},Object.assign(An,{random16:function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},nearestPowerOfTwo:function(e){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),An.floorPowerOfTwo(e)},nextPowerOfTwo:function(e){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),An.ceilPowerOfTwo(e)}}),Object.assign(s.prototype,{flattenToArrayOffset:function(e,t){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},multiplyVector3:function(e){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},multiplyVector3Array:function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBuffer:function(e){return console.warn("THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead."),this.applyToBufferAttribute(e)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}}),Object.assign(r.prototype,{extractPosition:function(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)},flattenToArrayOffset:function(e,t){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},getPosition:function(){var e;return function(){return void 0===e&&(e=new o),console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),e.setFromMatrixColumn(this,3)}}(),setRotationFromQuaternion:function(e){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(e)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(e){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},multiplyVector4:function(e){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},multiplyVector3Array:function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(e){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),e.transformDirection(this)},crossVector:function(e){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBuffer:function(e){return console.warn("THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead."),this.applyToBufferAttribute(e)},applyToVector3Array:function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(e,t,i,r,n,o){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(e,t,r,i,n,o)}}),p.prototype.isIntersectionLine=function(e){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(e)},n.prototype.multiplyVector3=function(e){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},Object.assign(j.prototype,{isIntersectionBox:function(e){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},isIntersectionPlane:function(e){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(e)},isIntersectionSphere:function(e){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)}}),Object.assign(X.prototype,{area:function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},barycoordFromPoint:function(e,t){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(e,t)},midpoint:function(e){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(e)},normal:function(e){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(e)},plane:function(e){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(e)}}),Object.assign(X,{barycoordFromPoint:function(e,t,i,r,n){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),X.getBarycoord(e,t,i,r,n)},normal:function(e,t,i,r){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),X.getNormal(e,t,i,r)}}),Object.assign($i.prototype,{extractAllPoints:function(e){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(e)},extrude:function(e){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new ei(this,e)},makeGeometry:function(e){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new li(this,e)}}),Object.assign(i.prototype,{fromAttribute:function(e,t,i){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},distanceToManhattan:function(e){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},lengthManhattan:function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(o.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(e){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)},getScaleFromMatrix:function(e){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)},getColumnFromMatrix:function(e,t){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(t,e)},applyProjection:function(e){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(e)},fromAttribute:function(e,t,i){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},distanceToManhattan:function(e){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},lengthManhattan:function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(h.prototype,{fromAttribute:function(e,t,i){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},lengthManhattan:function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(T.prototype,{computeTangents:function(){console.error("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}}),Object.assign(x.prototype,{getChildByName:function(e){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(e)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(e,t){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(t,e)},getWorldRotation:function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")}}),Object.defineProperties(x.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(e){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=e}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Object.defineProperties(nt.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}}),Object.defineProperty(ot.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}}),Object.defineProperty(Fi.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(e){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=e}}),qe.prototype.setLens=function(e,t){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==t&&(this.filmGauge=t),this.setFocalLength(e)},Object.defineProperties(er.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(e){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=e}},shadowCameraLeft:{set:function(e){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=e}},shadowCameraRight:{set:function(e){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=e}},shadowCameraTop:{set:function(e){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=e}},shadowCameraBottom:{set:function(e){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=e}},shadowCameraNear:{set:function(e){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=e}},shadowCameraFar:{set:function(e){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=e}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(e){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=e}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(e){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=e}},shadowMapHeight:{set:function(e){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=e}}}),Object.defineProperties(w.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},copyIndicesArray:function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")}}),Object.assign(N.prototype,{addIndex:function(e){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(e)},addDrawCall:function(e,t,i){void 0!==i&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(e,t)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")}}),Object.defineProperties(N.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.assign(ti.prototype,{getArrays:function(){console.error("THREE.ExtrudeBufferGeometry: .getArrays() has been removed.")},addShapeList:function(){console.error("THREE.ExtrudeBufferGeometry: .addShapeList() has been removed.")},addShape:function(){console.error("THREE.ExtrudeBufferGeometry: .addShape() has been removed.")}}),Object.defineProperties(jr.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this}}}),Object.defineProperties(G.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new g}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===e}}}),Object.defineProperties(Ti.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}}),Object.defineProperties(H.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(e){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=e}}}),Object.assign(Je.prototype,{getCurrentRenderTarget:function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},getMaxAnisotropy:function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},getPrecision:function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},resetGLState:function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},supportsFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(e){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(e)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},setFaceCulling:function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")}}),Object.defineProperties(Je.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=e}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=e}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(je.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(c.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=e}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=e}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=e}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=e}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(e){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=e}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(e){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=e}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(e){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=e}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(e){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=e}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(e){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=e}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(e){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=e}}}),Object.defineProperties(Qe.prototype,{standing:{set:function(){console.warn("THREE.WebVRManager: .standing has been removed.")}}}),Fr.prototype.load=function(e){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");var t=this;return(new Ir).load(e,function(e){t.setBuffer(e)}),this},Vr.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},Or.prototype.updateCubeMap=function(e,t){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(e,t)},e.WebGLRenderTargetCube=l,e.WebGLRenderTarget=c,e.WebGLRenderer=Je,e.ShaderLib=Ln,e.UniformsLib=In,e.UniformsUtils=Dn,e.ShaderChunk=Cn,e.FogExp2=$e,e.Fog=et,e.Scene=tt,e.Sprite=rt,e.LOD=nt,e.SkinnedMesh=at,e.Skeleton=ot,e.Bone=st,e.Mesh=K,e.LineSegments=lt,e.LineLoop=ut,e.Line=ct,e.Points=ft,e.Group=pt,e.VideoTexture=mt,e.DataTexture=u,e.CompressedTexture=gt,e.CubeTexture=$,e.CanvasTexture=Ye,e.DepthTexture=vt,e.Texture=a,e.CompressedTextureLoader=Ri,e.DataTextureLoader=Ii,e.CubeTextureLoader=Oi,e.TextureLoader=Bi,e.ObjectLoader=Ar,e.MaterialLoader=Er,e.BufferGeometryLoader=Tr,e.DefaultLoadingManager=$n,e.LoadingManager=Ci,e.JSONLoader=Sr,e.ImageLoader=Li,e.ImageBitmapLoader=Pr,e.FontLoader=Rr,e.FileLoader=Di,e.Loader=wr,e.LoaderUtils=ho,e.Cache=Jn,e.AudioLoader=Ir,e.SpotLightShadow=rr,e.SpotLight=nr,e.PointLight=or,e.RectAreaLight=cr,e.HemisphereLight=tr,e.DirectionalLightShadow=sr,e.DirectionalLight=ar,e.AmbientLight=hr,e.LightShadow=ir,e.Light=er,e.StereoCamera=Lr,e.PerspectiveCamera=qe,e.OrthographicCamera=M,e.CubeCamera=Or,e.ArrayCamera=Ze,e.Camera=b,e.AudioListener=Br,e.PositionalAudio=Nr,e.AudioContext=go,e.AudioAnalyser=Vr,e.Audio=Fr,e.VectorKeyframeTrack=br,e.StringKeyframeTrack=lr,e.QuaternionKeyframeTrack=pr,e.NumberKeyframeTrack=gr,e.ColorKeyframeTrack=mr,e.BooleanKeyframeTrack=ur,e.PropertyMixer=Ur,e.PropertyBinding=kr,e.KeyframeTrack=xr,e.AnimationUtils=so,e.AnimationObjectGroup=Gr,e.AnimationMixer=Hr,e.AnimationClip=Mr,e.Uniform=jr,e.InstancedBufferGeometry=Yr,e.BufferGeometry=N,e.Geometry=T,e.InterleavedBufferAttribute=Xr,e.InstancedInterleavedBuffer=qr,e.InterleavedBuffer=Kr,e.InstancedBufferAttribute=Zr,e.Face3=E,e.Object3D=x,e.Raycaster=Qr,e.Layers=y,e.EventDispatcher=t,e.Clock=en,e.QuaternionLinearInterpolant=fr,e.LinearInterpolant=_r,e.DiscreteInterpolant=yr,e.CubicInterpolant=vr,e.Interpolant=dr,e.Triangle=X,e.Math=An,e.Spherical=tn,e.Cylindrical=rn,e.Plane=p,e.Frustum=m,e.Sphere=f,e.Ray=j,e.Matrix4=r,e.Matrix3=s,e.Box3=d,e.Box2=nn,e.Line3=Y,e.Euler=_,e.Vector4=h,e.Vector3=o,e.Vector2=i,e.Quaternion=n,e.Color=g,e.ImmediateRenderObject=on,e.VertexNormalsHelper=sn,e.SpotLightHelper=an,e.SkeletonHelper=hn,e.PointLightHelper=cn,e.RectAreaLightHelper=ln,e.HemisphereLightHelper=un,e.GridHelper=dn,e.PolarGridHelper=fn,e.FaceNormalsHelper=pn,e.DirectionalLightHelper=mn,e.CameraHelper=gn,e.BoxHelper=vn,e.Box3Helper=_n,e.PlaneHelper=yn,e.ArrowHelper=xn,e.AxesHelper=bn,e.Shape=$i,e.Path=Ji,e.ShapePath=Cr,e.Font=Dr,e.CurvePath=Qi,e.Curve=Fi,e.ShapeUtils=Kn,e.WebGLUtils=Ke,e.WireframeGeometry=_t,e.ParametricGeometry=yt,e.ParametricBufferGeometry=xt,e.TetrahedronGeometry=Et,e.TetrahedronBufferGeometry=Tt,e.OctahedronGeometry=wt,e.OctahedronBufferGeometry=St,e.IcosahedronGeometry=At,e.IcosahedronBufferGeometry=Pt,e.DodecahedronGeometry=Ct,e.DodecahedronBufferGeometry=Dt,e.PolyhedronGeometry=bt,e.PolyhedronBufferGeometry=Mt,e.TubeGeometry=Rt,e.TubeBufferGeometry=It,e.TorusKnotGeometry=Lt,e.TorusKnotBufferGeometry=Ot,e.TorusGeometry=Bt,e.TorusBufferGeometry=Ft,e.TextGeometry=ii,e.TextBufferGeometry=ri,e.SphereGeometry=ni,e.SphereBufferGeometry=oi,e.RingGeometry=si,e.RingBufferGeometry=ai,e.PlaneGeometry=z,e.PlaneBufferGeometry=k,e.LatheGeometry=hi,e.LatheBufferGeometry=ci,e.ShapeGeometry=li,e.ShapeBufferGeometry=ui,e.ExtrudeGeometry=ei,e.ExtrudeBufferGeometry=ti,e.EdgesGeometry=fi,e.ConeGeometry=gi,e.ConeBufferGeometry=vi,e.CylinderGeometry=pi,e.CylinderBufferGeometry=mi,e.CircleGeometry=_i,e.CircleBufferGeometry=yi,e.BoxGeometry=V,e.BoxBufferGeometry=U,e.ShadowMaterial=xi,e.SpriteMaterial=it,e.RawShaderMaterial=bi,e.ShaderMaterial=H,e.PointsMaterial=dt,e.MeshPhysicalMaterial=Ei,e.MeshStandardMaterial=Mi,e.MeshPhongMaterial=Ti,e.MeshToonMaterial=wi,e.MeshNormalMaterial=Si,e.MeshLambertMaterial=Ai,e.MeshDepthMaterial=We,e.MeshDistanceMaterial=He,e.MeshBasicMaterial=W,e.LineDashedMaterial=Pi,e.LineBasicMaterial=ht,e.Material=G,e.Float64BufferAttribute=O,e.Float32BufferAttribute=L,e.Uint32BufferAttribute=I,e.Int32BufferAttribute=R,e.Uint16BufferAttribute=D,e.Int16BufferAttribute=C,e.Uint8ClampedBufferAttribute=P,e.Uint8BufferAttribute=A,e.Int8BufferAttribute=S,e.BufferAttribute=w,e.ArcCurve=Vi,e.CatmullRomCurve3=zi,e.CubicBezierCurve=Hi,e.CubicBezierCurve3=ji,e.EllipseCurve=Ni,e.LineCurve=Yi,e.LineCurve3=Xi,e.QuadraticBezierCurve=Ki,e.QuadraticBezierCurve3=qi,e.SplineCurve=Zi,e.REVISION="92",e.MOUSE={LEFT:0,MIDDLE:1,RIGHT:2},e.CullFaceNone=0,e.CullFaceBack=1,e.CullFaceFront=2,e.CullFaceFrontBack=3,e.FrontFaceDirectionCW=0,e.FrontFaceDirectionCCW=1,e.BasicShadowMap=0,e.PCFShadowMap=1,e.PCFSoftShadowMap=2,e.FrontSide=0,e.BackSide=1,e.DoubleSide=2,e.FlatShading=1,e.SmoothShading=2,e.NoColors=0,e.FaceColors=1,e.VertexColors=2,e.NoBlending=0,e.NormalBlending=1,e.AdditiveBlending=2,e.SubtractiveBlending=3,e.MultiplyBlending=4,e.CustomBlending=5,e.AddEquation=100,e.SubtractEquation=101,e.ReverseSubtractEquation=102,e.MinEquation=103,e.MaxEquation=104,e.ZeroFactor=200,e.OneFactor=201,e.SrcColorFactor=202,e.OneMinusSrcColorFactor=203,e.SrcAlphaFactor=204,e.OneMinusSrcAlphaFactor=205,e.DstAlphaFactor=206,e.OneMinusDstAlphaFactor=207,e.DstColorFactor=208,e.OneMinusDstColorFactor=209,e.SrcAlphaSaturateFactor=210,e.NeverDepth=0,e.AlwaysDepth=1,e.LessDepth=2,e.LessEqualDepth=3,e.EqualDepth=4,e.GreaterEqualDepth=5,e.GreaterDepth=6,e.NotEqualDepth=7,e.MultiplyOperation=0,e.MixOperation=1,e.AddOperation=2,e.NoToneMapping=0,e.LinearToneMapping=1,e.ReinhardToneMapping=2,e.Uncharted2ToneMapping=3,e.CineonToneMapping=4,e.UVMapping=300,e.CubeReflectionMapping=301,e.CubeRefractionMapping=302,e.EquirectangularReflectionMapping=303,e.EquirectangularRefractionMapping=304,e.SphericalReflectionMapping=305,e.CubeUVReflectionMapping=306,e.CubeUVRefractionMapping=307,e.RepeatWrapping=1e3,e.ClampToEdgeWrapping=1001,e.MirroredRepeatWrapping=1002,e.NearestFilter=1003,e.NearestMipMapNearestFilter=1004,e.NearestMipMapLinearFilter=1005,e.LinearFilter=1006,e.LinearMipMapNearestFilter=1007,e.LinearMipMapLinearFilter=1008,e.UnsignedByteType=1009,e.ByteType=1010,e.ShortType=1011,e.UnsignedShortType=1012,e.IntType=1013,e.UnsignedIntType=1014,e.FloatType=1015,e.HalfFloatType=1016,e.UnsignedShort4444Type=1017,e.UnsignedShort5551Type=1018,e.UnsignedShort565Type=1019,e.UnsignedInt248Type=1020,e.AlphaFormat=1021,e.RGBFormat=1022,e.RGBAFormat=1023,e.LuminanceFormat=1024,e.LuminanceAlphaFormat=1025,e.RGBEFormat=1023,e.DepthFormat=1026,e.DepthStencilFormat=1027,e.RGB_S3TC_DXT1_Format=33776,e.RGBA_S3TC_DXT1_Format=33777,e.RGBA_S3TC_DXT3_Format=33778,e.RGBA_S3TC_DXT5_Format=33779,e.RGB_PVRTC_4BPPV1_Format=35840,e.RGB_PVRTC_2BPPV1_Format=35841,e.RGBA_PVRTC_4BPPV1_Format=35842,e.RGBA_PVRTC_2BPPV1_Format=35843,e.RGB_ETC1_Format=36196,e.RGBA_ASTC_4x4_Format=37808,e.RGBA_ASTC_5x4_Format=37809,e.RGBA_ASTC_5x5_Format=37810,e.RGBA_ASTC_6x5_Format=37811,e.RGBA_ASTC_6x6_Format=37812,e.RGBA_ASTC_8x5_Format=37813,e.RGBA_ASTC_8x6_Format=37814,e.RGBA_ASTC_8x8_Format=37815,e.RGBA_ASTC_10x5_Format=37816,e.RGBA_ASTC_10x6_Format=37817,e.RGBA_ASTC_10x8_Format=37818,e.RGBA_ASTC_10x10_Format=37819,e.RGBA_ASTC_12x10_Format=37820,e.RGBA_ASTC_12x12_Format=37821,e.LoopOnce=2200,e.LoopRepeat=2201,e.LoopPingPong=2202,e.InterpolateDiscrete=2300,e.InterpolateLinear=2301,e.InterpolateSmooth=2302,e.ZeroCurvatureEnding=2400,e.ZeroSlopeEnding=2401,e.WrapAroundEnding=2402,e.TrianglesDrawMode=0,e.TriangleStripDrawMode=1,e.TriangleFanDrawMode=2,e.LinearEncoding=3e3,e.sRGBEncoding=3001,e.GammaEncoding=3007,e.RGBEEncoding=3002,e.LogLuvEncoding=3003,e.RGBM7Encoding=3004,e.RGBM16Encoding=3005,e.RGBDEncoding=3006,e.BasicDepthPacking=3200,e.RGBADepthPacking=3201,e.CubeGeometry=V,e.Face4=function(e,t,i,r,n,o,s){return console.warn("THREE.Face4 has been removed. A THREE.Face3 will be created instead."),new E(e,t,i,n,o,s)},e.LineStrip=0,e.LinePieces=1,e.MeshFaceMaterial=function(e){return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."),e},e.MultiMaterial=function(e){return void 0===e&&(e=[]),console.warn("THREE.MultiMaterial has been removed. Use an Array instead."),e.isMultiMaterial=!0,e.materials=e,e.clone=function(){return e.slice()},e},e.PointCloud=function(e,t){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new ft(e,t)},e.Particle=function(e){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new rt(e)},e.ParticleSystem=function(e,t){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new ft(e,t)},e.PointCloudMaterial=function(e){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new dt(e)},e.ParticleBasicMaterial=function(e){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new dt(e)},e.ParticleSystemMaterial=function(e){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new dt(e)},e.Vertex=function(e,t,i){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new o(e,t,i)},e.DynamicBufferAttribute=function(e,t){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead."),new w(e,t).setDynamic(!0)},e.Int8Attribute=function(e,t){return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."),new S(e,t)},e.Uint8Attribute=function(e,t){return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."),new A(e,t)},e.Uint8ClampedAttribute=function(e,t){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."),new P(e,t)},e.Int16Attribute=function(e,t){return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."),new C(e,t)},e.Uint16Attribute=function(e,t){return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."),new D(e,t)},e.Int32Attribute=function(e,t){return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."),new R(e,t)},e.Uint32Attribute=function(e,t){return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."),new I(e,t)},e.Float32Attribute=function(e,t){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new L(e,t)},e.Float64Attribute=function(e,t){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new O(e,t)},e.ClosedSplineCurve3=Mn,e.SplineCurve3=En,e.Spline=Tn,e.AxisHelper=function(e){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new bn(e)},e.BoundingBoxHelper=function(e,t){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new vn(e,t)},e.EdgesHelper=function(e,t){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new lt(new fi(e.geometry),new ht({color:void 0!==t?t:16777215}))},e.WireframeHelper=function(e,t){return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."),new lt(new _t(e.geometry),new ht({color:void 0!==t?t:16777215}))},e.XHRLoader=function(e){return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."),new Di(e)},e.BinaryTextureLoader=function(e){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new Ii(e)},e.GeometryUtils={merge:function(e,t,i){if(console.warn("THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead."),t.isMesh){t.matrixAutoUpdate&&t.updateMatrix();var r=t.matrix;t=t.geometry}e.merge(t,r,i)},center:function(e){return console.warn("THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead."),e.center()}},e.ImageUtils={crossOrigin:void 0,loadTexture:function(e,t,i,r){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var n=new Bi;return n.setCrossOrigin(this.crossOrigin),e=n.load(e,i,void 0,r),t&&(e.mapping=t),e},loadTextureCube:function(e,t,i,r){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");var n=new Oi;return n.setCrossOrigin(this.crossOrigin),e=n.load(e,i,void 0,r),t&&(e.mapping=t),e},loadCompressedTexture:function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},loadCompressedTextureCube:function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")}},e.Projector=function(){console.error("THREE.Projector has been moved to /examples/js/renderers/Projector.js."),this.projectVector=function(e,t){console.warn("THREE.Projector: .projectVector() is now vector.project()."),e.project(t)},this.unprojectVector=function(e,t){console.warn("THREE.Projector: .unprojectVector() is now vector.unproject()."),e.unproject(t)},this.pickingRay=function(){console.error("THREE.Projector: .pickingRay() is now raycaster.setFromCamera().")}},e.CanvasRenderer=function(){console.error("THREE.CanvasRenderer has been moved to /examples/js/renderers/CanvasRenderer.js"),this.domElement=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),this.clear=function(){},this.render=function(){},this.setClearColor=function(){},this.setSize=function(){}},e.SceneUtils={createMultiMaterialObject:function(){console.error("THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js")},detach:function(){console.error("THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js")},attach:function(){console.error("THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js")}},e.LensFlare=function(){console.error("THREE.LensFlare has been moved to /examples/js/objects/Lensflare.js")},Object.defineProperty(e,"__esModule",{value:!0})}),function(e){var t={};function i(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=e,i.c=t,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(r,n,function(t){return e[t]}.bind(null,n));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=15)}({0:function(e,t,i){"use strict";function r(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e}function n(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||window.innerWidth<600}i.d(t,"c",function(){return r}),i.d(t,"d",function(){return n}),i.d(t,"h",function(){return o}),i.d(t,"g",function(){return s}),i.d(t,"f",function(){return a}),i.d(t,"e",function(){return h}),i.d(t,"a",function(){return c}),i.d(t,"b",function(){return l}),Number.prototype.clamp=function(e,t){return Math.min(Math.max(this,e),t)};const o=e=>e[Math.floor(Math.random()*e.length)];function s(e,t){return null==e&&(e=0),null==t&&(t=1),e+Math.random()*(t-e)}function a(e,t){return null==e&&(e=0),null==t&&(t=1),Math.floor(e+Math.random()*(t-e+1))}var h=e=>document.querySelector(e);const c=e=>"number"==typeof e?"#"+("00000"+e.toString(16)).slice(-6):e,l=(e,t=1)=>{const i=c(e),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i),n=r?{r:parseInt(r[1],16),g:parseInt(r[2],16),b:parseInt(r[3],16)}:null;return"rgba("+n.r+","+n.g+","+n.b+","+t+")"}},1:function(e,t,i){"use strict";i.d(t,"a",function(){return n});var r=i(0);window&&!window.VANTA&&(window.VANTA={version:"0.3.1"});const n=window.VANTA||{};n.register||(n.register=((e,t)=>{n[e]=(e=>new t(e))}));var o=function(){return Array.prototype.unshift.call(arguments,"[VANTA]"),console.error.apply(this,arguments)};n.VantaBase=class{constructor(e={}){var t,i,s,a;if(n.current=this,this.onMouseMoveWrapper=this.onMouseMoveWrapper.bind(this),this.resize=this.resize.bind(this),this.animationLoop=this.animationLoop.bind(this),this.restart=this.restart.bind(this),this.options=Object(r.c)({},this.defaultOptions),e instanceof HTMLElement||"string"==typeof e?Object(r.c)(this.options,{el:e}):Object(r.c)(this.options,e),this.el=this.options.el,null==this.el)o('Instance needs "el" param!');else if(!(this.options.el instanceof HTMLElement||(a=this.el,this.el=Object(r.e)(a),this.el)))return void o("Cannot find element",a);for(s=0;s<this.el.children.length;s++)t=this.el.children[s],"static"===getComputedStyle(t).position&&(t.style.position="relative"),"auto"===getComputedStyle(t).zIndex&&(t.style.zIndex=1);"static"===getComputedStyle(this.el).position&&(this.el.style.position="relative"),"object"==typeof THREE&&this.initThree(),this.setSize(),this.uniforms={u_time:{type:"f",value:1},u_resolution:{type:"v2",value:new THREE.Vector2(1,1)},u_mouse:{type:"v2",value:new THREE.Vector2(0,0)}};try{this.init()}catch(e){return i=e,o("Init error"),o(i),this.el.removeChild(this.renderer.domElement),void(this.options.backgroundColor&&(console.log("[VANTA] Falling back to backgroundColor"),this.el.style.background=this.color2Hex(this.options.backgroundColor)))}window.addEventListener("resize",this.resize),this.resize(),this.animationLoop(),this.el.addEventListener("mousemove",this.onMouseMoveWrapper,!1),window.addEventListener("scroll",this.onMouseMoveWrapper)}applyCanvasStyles(e,t={}){Object(r.c)(e.style,{position:"absolute",zIndex:0,top:0,left:0,background:""}),Object(r.c)(e.style,t),e.classList.add("vanta-canvas")}initThree(){this.renderer=new THREE.WebGLRenderer({alpha:!0,antialias:!0}),this.el.appendChild(this.renderer.domElement),this.applyCanvasStyles(this.renderer.domElement),isNaN(this.options.backgroundAlpha)&&(this.options.backgroundAlpha=1),this.scene=new THREE.Scene}onMouseMoveWrapper(e){var t,i,r;t=this.renderer.domElement.getBoundingClientRect(),i=this.mouseX=e.clientX-t.left,r=this.mouseY=e.clientY-t.top,i>=0&&r>=0&&!this.options.mouseEase&&this.triggerMouseMove(i,r)}triggerMouseMove(e,t){this.uniforms&&(this.uniforms.u_mouse.value.x=e/this.scale,this.uniforms.u_mouse.value.y=t/this.scale);const i=e/this.width,r=t/this.height;"function"==typeof this.onMouseMove&&this.onMouseMove(i,r)}setSize(){this.scale||(this.scale=1),Object(r.d)()&&this.options.scaleMobile?this.scale=this.options.scaleMobile:this.options.scale&&(this.scale=this.options.scale),this.width=this.el.offsetWidth||window.innerWidth,this.height=this.el.offsetHeight||window.innerHeight}resize(){var e,t;this.setSize(),null!=(e=this.camera)&&(e.aspect=this.width/this.height),null!=(t=this.camera)&&"function"==typeof t.updateProjectionMatrix&&t.updateProjectionMatrix(),this.renderer&&(this.renderer.setSize(this.width,this.height),this.renderer.setPixelRatio(window.devicePixelRatio/this.scale)),"function"==typeof this.onResize&&this.onResize()}animationLoop(){var e,t,i,r,n,o,s,a;return this.t||(this.t=0),this.t+=1,this.t2||(this.t2=0),this.t2+=null!=(o=this.options.speed)?o:1,this.uniforms&&(this.uniforms.u_time.value=.016667*this.t2),e=this.el.offsetHeight,t=this.el.getBoundingClientRect(),a=null!=(s=window.pageYOffset)?s:(document.documentElement||document.body.parentNode||document.body).scrollTop,r=(n=t.top+a)-window.innerHeight,i=n+e,this.options.mouseEase&&(this.mouseEaseX=this.mouseEaseX||this.mouseX||0,this.mouseEaseY=this.mouseEaseY||this.mouseY||0,Math.abs(this.mouseEaseX-this.mouseX)+Math.abs(this.mouseEaseY-this.mouseY)>.1&&(this.mouseEaseX=this.mouseEaseX+.05*(this.mouseX-this.mouseEaseX),this.mouseEaseY=this.mouseEaseY+.05*(this.mouseY-this.mouseEaseY),this.triggerMouseMove(this.mouseEaseX,this.mouseEaseY))),r<=a&&a<=i&&("function"==typeof this.onUpdate&&this.onUpdate(),this.scene&&this.camera&&(this.renderer.render(this.scene,this.camera),"transparent"==this.options.backgroundColor?this.renderer.setClearColor(this.options.backgroundColor,0):this.renderer.setClearColor(this.options.backgroundColor,this.options.backgroundAlpha)),this.fps&&this.fps.update&&this.fps.update()),this.req=window.requestAnimationFrame(this.animationLoop)}restart(){if(this.scene)for(;this.scene.children.length;)this.scene.remove(this.scene.children[0]);"function"==typeof this.onRestart&&this.onRestart(),this.init()}init(){"function"==typeof this.onInit&&this.onInit()}destroy(){"function"==typeof this.onDestroy&&this.onDestroy(),this.el.removeEventListener("mousemove",this.onMouseMoveWrapper),window.removeEventListener("scroll",this.onMouseMoveWrapper),window.removeEventListener("resize",this.resize),window.cancelAnimationFrame(this.req),this.renderer&&(this.el.removeChild(this.renderer.domElement),this.renderer=null,this.scene=null)}},t.b=n.VantaBase},15:function(e,t,i){"use strict";i.r(t);var r=i(2);class n extends r.b{}r.a.register("CELLS",n),n.prototype.defaultOptions={color1:35980,color2:15918901,backgroundColor:14155663,amplitudeFactor:1,ringFactor:1,rotationFactor:1,size:1.5,speed:1,scaleMobile:3},n.prototype.fragmentShader="uniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\n\nuniform float blurFactor;\nuniform vec3 color1;\nuniform vec3 color2;\nuniform vec3 backgroundColor;\nuniform float size;\nuniform float amplitudeFactor;\nuniform float ringFactor;\nuniform float rotationFactor;\n\nfloat length2(vec2 p) { return dot(p, p); }\n\nfloat noise(vec2 p){\n    return fract(sin(fract(sin(p.x) * (43.13311)) + p.y) * 31.0011);\n}\n\nfloat worley(vec2 p) {\n    float d = 1e30;\n    for (int xo = -1; xo <= 1; ++xo) {\n        for (int yo = -1; yo <= 1; ++yo) {\n            vec2 tp = floor(p) + vec2(xo, yo);\n            d = min(d, length2(p - tp - vec2(noise(tp))));\n        }\n    }\n    vec2 uv = gl_FragCoord.xy / u_resolution.xy;\n    float timeOffset =  0.15 * sin(u_time * 2.0 + 10.0*(uv.x - uv.y));\n    return 3.0*exp(-4.0*abs(2.0*d - 1.0 + timeOffset));\n}\n\nfloat fworley(vec2 p) {\n    return sqrt(sqrt(sqrt(\n    1.1 * // light\n    worley(p*5. + .3 + u_time*.0525) *\n    sqrt(worley(p * 50. / size + 0.3 + u_time * -0.15)) *\n    sqrt(sqrt(worley(p * -10. + 9.3))))));\n}\n\nvoid main() {\n    vec2 uv = gl_FragCoord.xy / u_resolution.xy;\n    float t = fworley(uv * u_resolution.xy / 1500.0);\n    t *= exp(-length2(abs(0.7*uv - 1.0)));\n\n    float tExp = pow(t, 0.5 - t);\n    vec3 c1 = color1 * (1.0 - t);\n    vec3 c2 = color2 * tExp;\n\n    gl_FragColor = vec4(pow(t, 1.0 - t) * (c1 + c2), 1.0);\n}\n"},2:function(e,t,i){"use strict";i.d(t,"b",function(){return o});var r=i(1),n=i(0);i.d(t,"a",function(){return r.a}),"object"==typeof THREE&&(THREE.Color.prototype.toVector=function(){return new THREE.Vector3(this.r,this.g,this.b)});class o extends r.b{constructor(e){super(e),this.mode="shader",this.updateUniforms=this.updateUniforms.bind(this)}initBasicShader(e=this.fragmentShader,t=this.vertexShader){var i,r,n;return t||(t="uniform float u_time;\nuniform vec2 u_resolution;\nvoid main() {\n  gl_Position = vec4( position, 1.0 );\n}"),this.updateUniforms(),"function"==typeof this.valuesChanger&&this.valuesChanger(),i=new THREE.ShaderMaterial({uniforms:this.uniforms,vertexShader:t,fragmentShader:e}),(n=this.options.texturePath)&&(this.uniforms.u_tex={type:"t",value:(new THREE.TextureLoader).load(n)}),r=new THREE.Mesh(new THREE.PlaneGeometry(2,2),i),this.scene.add(r),this.camera=new THREE.Camera,this.camera.position.z=1}updateUniforms(){var e,t,i,r;for(e in t={},i=this.options)r=i[e],-1!==e.toLowerCase().indexOf("color")?t[e]={type:"v3",value:new THREE.Color(r).toVector()}:"number"==typeof r&&(t[e]={type:"f",value:r});return Object(n.c)(this.uniforms,t)}init(){super.init(),this.fragmentShader&&this.initBasicShader()}resize(){super.resize(),this.uniforms.u_resolution.value.x=this.width/this.scale,this.uniforms.u_resolution.value.y=this.height/this.scale}}}}),function(){const e=document.documentElement;if(e.classList.remove("no-js"),e.classList.add("js"),document.body.classList.contains("has-animations")){(window.sr=ScrollReveal()).reveal(".is-revealing",{duration:1e3,distance:"40px",easing:"cubic-bezier(0.5, -0.01, 0, 1.005)",origin:"bottom",interval:150})}addScrollListener(document.querySelectorAll(".scroll-link",0)),null!==document.getElementById("cells-bg")&&VANTA.CELLS({el:"#cells-bg",color1:39064,color2:16773939})}(),window.onscroll=function(){if(null!==document.getElementById("mouse")){var e=document.getElementById("mouse"),t=window.innerHeight,i=void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;t/=2,e.style.opacity=(t-i)/t}};const imageContainer=document.querySelector(".image-container"),showAllButton=document.querySelector(".show-all-members"),allTeamMembers=document.querySelectorAll(".team-member");function addPosition(e,t){e.style.left=t[0]+"%",e.style.top=t[1]+"%",e.style.width=t[2]-t[0]+"%",e.style.height=t[3]-t[1]+"%"}function getPosition(e){var t=e.target.getBoundingClientRect(),i=e.target.width,r=e.target.height,n=(e.clientX-t.left)/i*100,o=(e.clientY-t.top)/r*100;console.log(n,o)}function addTag(e,t,i){const r=document.createElement("div");document.createElement("div");r.addEventListener("click",i),r.classList.add("image-tag"),addPosition(r,e),imageContainer.appendChild(r)}function filterImages(e){allTeamMembers.forEach(t=>{t.id===e?(t.classList.remove("hidden"),t.scrollIntoView({left:0,block:"start",behavior:"smooth"})):t.classList.add("hidden")}),showAllButton.classList.remove("hidden")}function resetFilter(e){e.preventDefault(),allTeamMembers.forEach(e=>{e.classList.remove("hidden")}),showAllButton.classList.add("hidden")}null!==document.getElementById("team")&&(showAllButton.addEventListener("click",resetFilter),addTag([45,57,53,71],"Paul",()=>{filterImages("paul")}),addTag([15,38,21,49],"Vincent",()=>{filterImages("vincent")}));
 +
</script>
 +
 +
  
 
<!------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
 
<!------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------->

Revision as of 06:49, 9 May 2019