;(function (root, factory) { if (typeof define === 'function' && define.amd) { define([], factory); } else if (typeof module === 'object' && module.exports) { try { var JSDOM = require("jsdom").JSDOM; var DOM = new JSDOM(); var window = DOM.window; var navigator = window.navigator; module.exports = factory(window, navigator); } catch (error) { module.exports = factory(); } } else { root.pc = factory(root, root.navigator); } }(this, function (_window, _navigator) { window = _window || window; navigator = _navigator || navigator; /* PlayCanvas Engine v1.14.0 revision b9681f3 http://playcanvas.com Copyright 2011-2018 PlayCanvas Ltd. All rights reserved. */ var _typeLookup=function(){for(var f={},b="Array Object Function Date RegExp Float32Array".split(" "),a=0;athis.length)b=this.length;return this.substring(b-f.length,b)===f});String.prototype.includes||(String.prototype.includes=function(f,b){"number"!==typeof b&&(b=0);return b+f.length>this.length?!1:-1!==this.indexOf(f,b)});String.prototype.startsWith||(String.prototype.startsWith=function(f,b){return this.substr(!b||0>b?0:+b,f.length)===f});Object.assign(pc,function(){var f=function(b,a,c,d){var e=b&&b.length;3===e||4===e?(this.r=b[0],this.g=b[1],this.b=b[2],this.a=void 0!==b[3]?b[3]:1):(this.r=b||0,this.g=a||0,this.b=c||0,this.a=void 0!==d?d:1)};Object.assign(f.prototype,{clone:function(){return new pc.Color(this.r,this.g,this.b,this.a)},copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.a=b.a;return this},set:function(b,a,c,d){this.r=b;this.g=a;this.b=c;this.a=void 0===d?1:d;return this},lerp:function(b,a,c){this.r=b.r+c*(a.r- b.r);this.g=b.g+c*(a.g-b.g);this.b=b.b+c*(a.b-b.b);this.a=b.a+c*(a.a-b.a);return this},fromString:function(b){var a=parseInt(b.replace("#","0x"),16);7c||c>=b)return null;var e=a.charCodeAt(c);return 1=e&&(b=a.charCodeAt(c+1),56320<=b&&57343>=b)?{code:1024*(e-55296)+b-56320+65536,"long":!0}:{code:e,"long":!1}}function b(a,c,b){return a?(a=f(a))?(a=a.code,a>=c&&a<=b):!1:!1}return{ASCII_LOWERCASE:"abcdefghijklmnopqrstuvwxyz",ASCII_UPPERCASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",ASCII_LETTERS:"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",format:function(a){var c,b, e=pc.makeArray(arguments);e.shift();for(c=0;c>10)+55296,b%1024+56320]:[c],a.push(String.fromCharCode.apply(null,c));return a.join("")}}}();pc.debug=function(){var f=null,b=null,a=null,c=null;return{display:function(d){f||(f=document.createElement("table"),b=document.createElement("tr"),a=document.createElement("td"),c=document.createElement("td"),f.style.cssText="position:absolute;font-family:sans-serif;font-size:12px;color:#cccccc",f.style.top="0px",f.style.left="0px",f.style.border="thin solid #cccccc",document.body.appendChild(f));f.innerHTML="";for(var e in d){var g=b.cloneNode(),l=a.cloneNode(),k=c.cloneNode();l.textContent=e;k.textContent= d[e];g.appendChild(l);g.appendChild(k);f.appendChild(g)}}}}();pc.events={attach:function(f){var b=pc.events;f.on=b.on;f.off=b.off;f.fire=b.fire;f.once=b.once;f.hasEvent=b.hasEvent;f._callbackActive={};return f},on:function(f,b,a){if(!f||"string"!==typeof f||!b)return this;this._callbacks||(this._callbacks={});this._callbacks[f]||(this._callbacks[f]=[]);this._callbackActive||(this._callbackActive={});this._callbackActive[f]&&this._callbackActive[f]===this._callbacks[f]&&(this._callbackActive[f]=this._callbackActive[f].slice());this._callbacks[f].push({callback:b, scope:a||this});return this},off:function(f,b,a){if(!this._callbacks)return this;if(this._callbackActive)if(f)this._callbackActive[f]&&this._callbackActive[f]===this._callbacks[f]&&(this._callbackActive[f]=this._callbackActive[f].slice());else for(var c in this._callbackActive)this._callbacks[c]&&this._callbacks[c]===this._callbackActive[c]&&(this._callbackActive[c]=this._callbackActive[c].slice());if(f)if(b){f=this._callbacks[f];if(!f)return this;for(c=f.length;c--;)f[c].callback===b&&(a&&f[c].scope!== a||f.splice(c,1))}else this._callbacks[f]&&delete this._callbacks[f];else this._callbacks=null;return this},fire:function(f,b,a,c,d,e,g,l,k){if(!f||!this._callbacks||!this._callbacks[f])return this;var p;this._callbackActive||(this._callbackActive={});this._callbackActive[f]?(this._callbackActive[f]===this._callbacks[f]&&(this._callbackActive[f]=this._callbackActive[f].slice()),p=this._callbacks[f].slice()):this._callbackActive[f]=this._callbacks[f];for(var h=0;(p||this._callbackActive[f])&&h<(p|| this._callbackActive[f]).length;h++){var n=(p||this._callbackActive[f])[h];n.callback.call(n.scope,b,a,c,d,e,g,l,k);n.callback.once&&(n=this._callbacks[f].indexOf(n),-1!==n&&(this._callbackActive[f]===this._callbacks[f]&&(this._callbackActive[f]=this._callbackActive[f].slice()),this._callbacks[f].splice(n,1)))}p||(this._callbackActive[f]=null);return this},once:function(f,b,a){b.once=!0;this.on(f,b,a);return this},hasEvent:function(f){return this._callbacks&&this._callbacks[f]&&0!==this._callbacks[f].length|| !1}};Object.assign(pc,function(){var f=function(a){this._index={};this._key=a||null};Object.assign(f.prototype,{addItem:function(a){for(var c=a.tags._list,b=0;bthis._pool.length)for(var a=this._pool.length;a=this._pool.length&&this._resize(2*this._pool.length);return this._pool[this._count++]},freeAll:function(){this._count=0}});return{AllocatePool:f}}());Object.assign(pc,function(){var f={desktop:!1,mobile:!1,ios:!1,android:!1,windows:!1,cocoonjs:!1,xbox:!1,gamepads:!1,touch:!1,workers:!1},b=navigator.userAgent;/(windows|mac os|linux|cros)/i.test(b)&&(f.desktop=!0);/xbox/i.test(b)&&(f.xbox=!0);/(windows phone|iemobile|wpdesktop)/i.test(b)?(f.desktop=!1,f.mobile=!0,f.windows=!0):/android/i.test(b)?(f.desktop=!1,f.mobile=!0,f.android=!0):/ip([ao]d|hone)/i.test(b)&&(f.desktop=!1,f.mobile=!0,f.ios=!0);navigator.isCocoonJS&&(f.cocoonjs=!0);f.touch="ontouchstart"in window||"maxTouchPoints"in navigator&&0a&&(this._index[b]= c-1)}return!0}return!1},list:function(){return this._list},clear:function(){this._list.length=0;for(var b in this._index)delete this._index[b]}});return{IndexedList:f}}());pc.math={DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,clamp:function(f,b,a){return f>=a?a:f<=b?b:f},intToBytes24:function(f){return[f>>16&255,f>>8&255,f&255]},intToBytes32:function(f){return[f>>24&255,f>>16&255,f>>8&255,f&255]},bytesToInt24:function(f,b,a){f.length&&(a=f[2],b=f[1],f=f[0]);return f<<16|b<<8|a},bytesToInt32:function(f,b,a,c){f.length&&(c=f[3],a=f[2],b=f[1],f=f[0]);return(f<<24|b<<16|a<<8|c)>>>32},lerp:function(f,b,a){return f+(b-f)*pc.math.clamp(a,0,1)},lerpAngle:function(f,b,a){180< b-f&&(b-=360);-180>b-f&&(b+=360);return pc.math.lerp(f,b,pc.math.clamp(a,0,1))},powerOfTwo:function(f){return 0!==f&&!(f&f-1)},nextPowerOfTwo:function(f){f--;f|=f>>1;f|=f>>2;f|=f>>4;f|=f>>8;f|=f>>16;f++;return f},random:function(f,b){return Math.random()*(b-f)+f},smoothstep:function(f,b,a){if(a<=f)return 0;if(a>=b)return 1;a=(a-f)/(b-f);return a*a*(3-2*a)},smootherstep:function(f,b,a){if(a<=f)return 0;if(a>=b)return 1;a=(a-f)/(b-f);return a*a*a*(a*(6*a-15)+10)}};Object.assign(pc,function(){var f=function(b,a){b&&2===b.length?(this.x=b[0],this.y=b[1]):(this.x=b||0,this.y=a||0)};Object.assign(f.prototype,{add:function(b){this.x+=b.x;this.y+=b.y;return this},add2:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;return this},clone:function(){return(new f).copy(this)},copy:function(b){this.x=b.x;this.y=b.y;return this},dot:function(b){return this.x*b.x+this.y*b.y},equals:function(b){return this.x===b.x&&this.y===b.y},length:function(){return Math.sqrt(this.x*this.x+ this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},lerp:function(b,a,c){this.x=b.x+c*(a.x-b.x);this.y=b.y+c*(a.y-b.y);return this},mul:function(b){this.x*=b.x;this.y*=b.y;return this},mul2:function(b,a){this.x=b.x*a.x;this.y=b.y*a.y;return this},normalize:function(){var b=this.x*this.x+this.y*this.y;0a;a++)b+=this.data[a],b+=9!==a?", ":"";return b+"]"},transpose:function(){var b=this.data, a;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this}});Object.defineProperty(f,"IDENTITY",{get:function(){var b=new f;return function(){return b}}()});Object.defineProperty(f,"ZERO",{get:function(){var b=(new f).set([0,0,0,0,0,0,0,0,0]);return function(){return b}}()});return{Mat3:f}}());Object.assign(pc,function(){var f=function(){var b=new Float32Array(16);b[0]=b[5]=b[10]=b[15]=1;this.data=b};Object.assign(f.prototype,{add2:function(b,a){var c=b.data,d=a.data,e=this.data;e[0]=c[0]+d[0];e[1]=c[1]+d[1];e[2]=c[2]+d[2];e[3]=c[3]+d[3];e[4]=c[4]+d[4];e[5]=c[5]+d[5];e[6]=c[6]+d[6];e[7]=c[7]+d[7];e[8]=c[8]+d[8];e[9]=c[9]+d[9];e[10]=c[10]+d[10];e[11]=c[11]+d[11];e[12]=c[12]+d[12];e[13]=c[13]+d[13];e[14]=c[14]+d[14];e[15]=c[15]+d[15];return this},add:function(b){return this.add2(this,b)}, clone:function(){return(new pc.Mat4).copy(this)},copy:function(b){b=b.data;var a=this.data;a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3];a[4]=b[4];a[5]=b[5];a[6]=b[6];a[7]=b[7];a[8]=b[8];a[9]=b[9];a[10]=b[10];a[11]=b[11];a[12]=b[12];a[13]=b[13];a[14]=b[14];a[15]=b[15];return this},equals:function(b){var a=this.data;b=b.data;return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]&&a[4]===b[4]&&a[5]===b[5]&&a[6]===b[6]&&a[7]===b[7]&&a[8]===b[8]&&a[9]===b[9]&&a[10]===b[10]&&a[11]===b[11]&&a[12]===b[12]&& a[13]===b[13]&&a[14]===b[14]&&a[15]===b[15]},isIdentity:function(){var b=this.data;return 1===b[0]&&0===b[1]&&0===b[2]&&0===b[3]&&0===b[4]&&1===b[5]&&0===b[6]&&0===b[7]&&0===b[8]&&0===b[9]&&1===b[10]&&0===b[11]&&0===b[12]&&0===b[13]&&0===b[14]&&1===b[15]},mul2:function(b,a){var c,d,e,g,l,k,f,h,n,q,m,r,t,v,y,u,w,x,D,z;u=b.data;var C=a.data,A=this.data;c=u[0];d=u[1];e=u[2];g=u[3];l=u[4];k=u[5];f=u[6];h=u[7];n=u[8];q=u[9];m=u[10];r=u[11];t=u[12];v=u[13];y=u[14];u=u[15];w=C[0];x=C[1];D=C[2];z=C[3];A[0]= c*w+l*x+n*D+t*z;A[1]=d*w+k*x+q*D+v*z;A[2]=e*w+f*x+m*D+y*z;A[3]=g*w+h*x+r*D+u*z;w=C[4];x=C[5];D=C[6];z=C[7];A[4]=c*w+l*x+n*D+t*z;A[5]=d*w+k*x+q*D+v*z;A[6]=e*w+f*x+m*D+y*z;A[7]=g*w+h*x+r*D+u*z;w=C[8];x=C[9];D=C[10];z=C[11];A[8]=c*w+l*x+n*D+t*z;A[9]=d*w+k*x+q*D+v*z;A[10]=e*w+f*x+m*D+y*z;A[11]=g*w+h*x+r*D+u*z;w=C[12];x=C[13];D=C[14];z=C[15];A[12]=c*w+l*x+n*D+t*z;A[13]=d*w+k*x+q*D+v*z;A[14]=e*w+f*x+m*D+y*z;A[15]=g*w+h*x+r*D+u*z;return this},mul:function(b){return this.mul2(this,b)},transformPoint:function(b, a){var c,d,e,g;g=this.data;c=b.x;d=b.y;e=b.z;a=void 0===a?new pc.Vec3:a;a.x=c*g[0]+d*g[4]+e*g[8]+g[12];a.y=c*g[1]+d*g[5]+e*g[9]+g[13];a.z=c*g[2]+d*g[6]+e*g[10]+g[14];return a},transformVector:function(b,a){var c,d,e,g;g=this.data;c=b.x;d=b.y;e=b.z;a=void 0===a?new pc.Vec3:a;a.x=c*g[0]+d*g[4]+e*g[8];a.y=c*g[1]+d*g[5]+e*g[9];a.z=c*g[2]+d*g[6]+e*g[10];return a},transformVec4:function(b,a){var c,d,e,g,l;l=this.data;c=b.x;d=b.y;e=b.z;g=b.w;a=void 0===a?new pc.Vec4:a;a.x=c*l[0]+d*l[4]+e*l[8]+g*l[12];a.y= c*l[1]+d*l[5]+e*l[9]+g*l[13];a.z=c*l[2]+d*l[6]+e*l[10]+g*l[14];a.w=c*l[3]+d*l[7]+e*l[11]+g*l[15];return a},setLookAt:function(){var b,a,c;b=new pc.Vec3;a=new pc.Vec3;c=new pc.Vec3;return function(d,e,g){c.sub2(d,e).normalize();a.copy(g).normalize();b.cross(a,c).normalize();a.cross(c,b);e=this.data;e[0]=b.x;e[1]=b.y;e[2]=b.z;e[3]=0;e[4]=a.x;e[5]=a.y;e[6]=a.z;e[7]=0;e[8]=c.x;e[9]=c.y;e[10]=c.z;e[11]=0;e[12]=d.x;e[13]=d.y;e[14]=d.z;e[15]=1;return this}}(),setFrustum:function(b,a,c,d,e,g){var l,k,f,h, n;l=2*e;k=a-b;f=d-c;h=g-e;n=this.data;n[0]=l/k;n[1]=0;n[2]=0;n[3]=0;n[4]=0;n[5]=l/f;n[6]=0;n[7]=0;n[8]=(a+b)/k;n[9]=(d+c)/f;n[10]=(-g-e)/h;n[11]=-1;n[12]=0;n[13]=0;n[14]=-l*g/h;n[15]=0;return this},setPerspective:function(b,a,c,d,e){e?(b=c*Math.tan(b*Math.PI/360),e=b/a):(e=c*Math.tan(b*Math.PI/360),b=e*a);return this.setFrustum(-b,b,-e,e,c,d)},setOrtho:function(b,a,c,d,e,g){var l=this.data;l[0]=2/(a-b);l[1]=0;l[2]=0;l[3]=0;l[4]=0;l[5]=2/(d-c);l[6]=0;l[7]=0;l[8]=0;l[9]=0;l[10]=-2/(g-e);l[11]=0;l[12]= -(a+b)/(a-b);l[13]=-(d+c)/(d-c);l[14]=-(g+e)/(g-e);l[15]=1;return this},setFromAxisAngle:function(b,a){var c,d,e,g,l,k,f,h,n;a*=pc.math.DEG_TO_RAD;c=b.x;d=b.y;e=b.z;g=Math.cos(a);l=Math.sin(a);k=1-g;f=k*c;h=k*d;n=this.data;n[0]=f*c+g;n[1]=f*d+l*e;n[2]=f*e-l*d;n[3]=0;n[4]=f*d-l*e;n[5]=h*d+g;n[6]=h*e+l*c;n[7]=0;n[8]=f*e+l*d;n[9]=h*e-c*l;n[10]=k*e*e+g;n[11]=0;n[12]=0;n[13]=0;n[14]=0;n[15]=1;return this},setTranslate:function(b,a,c){var d=this.data;d[0]=1;d[1]=0;d[2]=0;d[3]=0;d[4]=0;d[5]=1;d[6]=0;d[7]= 0;d[8]=0;d[9]=0;d[10]=1;d[11]=0;d[12]=b;d[13]=a;d[14]=c;d[15]=1;return this},setScale:function(b,a,c){var d=this.data;d[0]=b;d[1]=0;d[2]=0;d[3]=0;d[4]=0;d[5]=a;d[6]=0;d[7]=0;d[8]=0;d[9]=0;d[10]=c;d[11]=0;d[12]=0;d[13]=0;d[14]=0;d[15]=1;return this},invert:function(){var b,a,c,d,e,g,l,k,f,h,n,q,m,r,t,v,y,u,w,x,D,z,C,A,B,J,F,H,E,G;G=this.data;b=G[0];a=G[1];c=G[2];d=G[3];e=G[4];g=G[5];l=G[6];k=G[7];f=G[8];h=G[9];n=G[10];q=G[11];m=G[12];r=G[13];t=G[14];v=G[15];y=b*g-a*e;u=b*l-c*e;w=b*k-d*e;x=a*l-c*g; D=a*k-d*g;z=c*k-d*l;C=f*r-h*m;A=f*t-n*m;B=f*v-q*m;J=h*t-n*r;F=h*v-q*r;H=n*v-q*t;E=y*H-u*F+w*J+x*B-D*A+z*C;0===E?this.setIdentity():(E=1/E,G[0]=(g*H-l*F+k*J)*E,G[1]=(-a*H+c*F-d*J)*E,G[2]=(r*z-t*D+v*x)*E,G[3]=(-h*z+n*D-q*x)*E,G[4]=(-e*H+l*B-k*A)*E,G[5]=(b*H-c*B+d*A)*E,G[6]=(-m*z+t*w-v*u)*E,G[7]=(f*z-n*w+q*u)*E,G[8]=(e*F-g*B+k*C)*E,G[9]=(-b*F+a*B-d*C)*E,G[10]=(m*D-r*w+v*y)*E,G[11]=(-f*D+h*w-q*y)*E,G[12]=(-e*J+g*A-l*C)*E,G[13]=(b*J-a*A+c*C)*E,G[14]=(-m*x+r*u-t*y)*E,G[15]=(f*x-h*u+n*y)*E);return this}, set:function(b){var a=this.data;a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3];a[4]=b[4];a[5]=b[5];a[6]=b[6];a[7]=b[7];a[8]=b[8];a[9]=b[9];a[10]=b[10];a[11]=b[11];a[12]=b[12];a[13]=b[13];a[14]=b[14];a[15]=b[15];return this},setIdentity:function(){var b=this.data;b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=0;b[5]=1;b[6]=0;b[7]=0;b[8]=0;b[9]=0;b[10]=1;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},setTRS:function(b,a,c){var d,e,g,l,k,f,h,n,q,m,r,t,v;d=b.x;e=b.y;b=b.z;g=a.x;l=a.y;k=a.z;f=a.w;a=c.x;h=c.y;c=c.z;n= g+g;q=l+l;m=k+k;r=g*n;t=g*q;g*=m;v=l*q;l*=m;k*=m;n*=f;q*=f;f*=m;m=this.data;m[0]=(1-(v+k))*a;m[1]=(t+f)*a;m[2]=(g-q)*a;m[3]=0;m[4]=(t-f)*h;m[5]=(1-(r+k))*h;m[6]=(l+n)*h;m[7]=0;m[8]=(g+q)*c;m[9]=(l-n)*c;m[10]=(1-(r+v))*c;m[11]=0;m[12]=d;m[13]=e;m[14]=b;m[15]=1;return this},transpose:function(){var b,a=this.data;b=a[1];a[1]=a[4];a[4]=b;b=a[2];a[2]=a[8];a[8]=b;b=a[3];a[3]=a[12];a[12]=b;b=a[6];a[6]=a[9];a[9]=b;b=a[7];a[7]=a[13];a[13]=b;b=a[11];a[11]=a[14];a[14]=b;return this},invertTo3x3:function(b){var a, c,d,e;a=this.data;b=b.data;var g=a[0],l=a[1],k=a[2],f=a[4],h=a[5],n=a[6],q=a[8],m=a[9],r=a[10];a=r*h-n*m;c=-r*f+n*q;d=m*f-h*q;e=g*a+l*c+k*d;if(0===e)return this;e=1/e;b[0]=e*a;b[1]=e*(-r*l+k*m);b[2]=e*(n*l-k*h);b[3]=e*c;b[4]=e*(r*g-k*q);b[5]=e*(-n*g+k*f);b[6]=e*d;b[7]=e*(-m*g+l*q);b[8]=e*(h*g-l*f);return this},getTranslation:function(b){b=void 0===b?new pc.Vec3:b;return b.set(this.data[12],this.data[13],this.data[14])},getX:function(b){b=void 0===b?new pc.Vec3:b;return b.set(this.data[0],this.data[1], this.data[2])},getY:function(b){b=void 0===b?new pc.Vec3:b;return b.set(this.data[4],this.data[5],this.data[6])},getZ:function(b){b=void 0===b?new pc.Vec3:b;return b.set(this.data[8],this.data[9],this.data[10])},getScale:function(){var b,a,c;b=new pc.Vec3;a=new pc.Vec3;c=new pc.Vec3;return function(d){d=void 0===d?new pc.Vec3:d;this.getX(b);this.getY(a);this.getZ(c);d.set(b.length(),a.length(),c.length());return d}}(),setFromEulerAngles:function(b,a,c){var d,e,g,l;b*=pc.math.DEG_TO_RAD;a*=pc.math.DEG_TO_RAD; c*=pc.math.DEG_TO_RAD;d=Math.sin(-b);b=Math.cos(-b);e=Math.sin(-a);a=Math.cos(-a);g=Math.sin(-c);c=Math.cos(-c);l=this.data;l[0]=a*c;l[1]=-a*g;l[2]=e;l[3]=0;l[4]=b*g+c*d*e;l[5]=b*c-d*e*g;l[6]=-a*d;l[7]=0;l[8]=d*g-b*c*e;l[9]=c*d+b*e*g;l[10]=b*a;l[11]=0;l[12]=0;l[13]=0;l[14]=0;l[15]=1;return this},getEulerAngles:function(){var b=new pc.Vec3;return function(a){var c,d,e,g,l,k;a=void 0===a?new pc.Vec3:a;this.getScale(b);e=b.x;c=b.y;g=b.z;l=this.data;d=Math.asin(-l[2]/e);k=.5*Math.PI;d-k?(c=Math.atan2(l[6]/ c,l[10]/g),e=Math.atan2(l[1]/e,l[0]/e)):(e=0,c=-Math.atan2(l[4]/c,l[5]/c)):(e=0,c=Math.atan2(l[4]/c,l[5]/c));return a.set(c,d,e).scale(pc.math.RAD_TO_DEG)}}(),toString:function(){var b,a;a="[";for(b=0;16>b;b+=1)a+=this.data[b],a+=15!==b?", ":"";return a+"]"}});Object.defineProperty(f,"IDENTITY",{get:function(){var b=new f;return function(){return b}}()});Object.defineProperty(f,"ZERO",{get:function(){var b=(new f).set([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);return function(){return b}}()});return{Mat4:f}}());Object.assign(pc,function(){var f=function(b,a,c,d){b&&4===b.length?(this.x=b[0],this.y=b[1],this.z=b[2],this.w=b[3]):(this.x=void 0===b?0:b,this.y=void 0===a?0:a,this.z=void 0===c?0:c,this.w=void 0===d?1:d)};Object.assign(f.prototype,{clone:function(){return new pc.Quat(this.x,this.y,this.z,this.w)},conjugate:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},equals:function(b){return this.x===b.x&&this.y===b.y&&this.z=== b.z&&this.w===b.w},getAxisAngle:function(b){var a=2*Math.acos(this.w),c=Math.sin(a/2);if(0!==c){if(b.x=this.x/c,b.y=this.y/c,b.z=this.z/c,0>b.x||0>b.y||0>b.z)b.x*=-1,b.y*=-1,b.z*=-1,a*=-1}else b.x=1,b.y=0,b.z=0;return a*pc.math.RAD_TO_DEG},getEulerAngles:function(b){var a,c,d,e,g,l;b=void 0===b?new pc.Vec3:b;d=this.x;e=this.y;g=this.z;l=this.w;c=2*(l*e-d*g);-.99999>=c?(a=2*Math.atan2(d,l),c=-Math.PI/2,d=0):.99999<=c?(a=2*Math.atan2(d,l),c=Math.PI/2,d=0):(a=Math.atan2(2*(l*d+e*g),1-2*(d*d+e*e)),c= Math.asin(c),d=Math.atan2(2*(l*g+d*e),1-2*(e*e+g*g)));return b.set(a,c,d).scale(pc.math.RAD_TO_DEG)},invert:function(){return this.conjugate().normalize()},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},mul:function(b){var a,c,d,e,g,l,k;a=this.x;c=this.y;d=this.z;e=this.w;g=b.x;l=b.y;k=b.z;b=b.w;this.x=e*g+a*b+c*k-d*l;this.y=e*l+c*b+d*g-a*k;this.z=e*k+d*b+a*l-c*g;this.w= e*b-a*g-c*l-d*k;return this},mul2:function(b,a){var c,d,e,g,l,k,f,h;c=b.x;d=b.y;e=b.z;g=b.w;l=a.x;k=a.y;f=a.z;h=a.w;this.x=g*l+c*h+d*f-e*k;this.y=g*k+d*h+e*l-c*f;this.z=g*f+e*h+c*k-d*l;this.w=g*h-c*l-d*k-e*f;return this},normalize:function(){var b=this.length();0===b?(this.x=this.y=this.z=0,this.w=1):(b=1/b,this.x*=b,this.y*=b,this.z*=b,this.w*=b);return this},set:function(b,a,c,d){this.x=b;this.y=a;this.z=c;this.w=d;return this},setFromAxisAngle:function(b,a){var c,d;a*=.5*pc.math.DEG_TO_RAD;c=Math.sin(a); d=Math.cos(a);this.x=c*b.x;this.y=c*b.y;this.z=c*b.z;this.w=d;return this},setFromEulerAngles:function(b,a,c){var d,e,g;d=.5*pc.math.DEG_TO_RAD;b*=d;a*=d;c*=d;d=Math.sin(b);b=Math.cos(b);e=Math.sin(a);a=Math.cos(a);g=Math.sin(c);c=Math.cos(c);this.x=d*a*c-b*e*g;this.y=b*e*c+d*a*g;this.z=b*a*g-d*e*c;this.w=b*a*c+d*e*g;return this},setFromMat4:function(b){var a,c,d,e,g,l,k,f,h,n,q;b=b.data;a=b[0];c=b[1];d=b[2];e=b[4];g=b[5];l=b[6];k=b[8];f=b[9];b=b[10];h=1/Math.sqrt(a*a+c*c+d*d);n=1/Math.sqrt(e*e+g* g+l*l);q=1/Math.sqrt(k*k+f*f+b*b);a*=h;c*=h;d*=h;e*=n;g*=n;l*=n;k*=q;f*=q;b*=q;h=a+g+b;0<=h?(a=Math.sqrt(h+1),this.w=.5*a,a=.5/a,this.x=(l-f)*a,this.y=(k-d)*a,this.z=(c-e)*a):a>g?a>b?(a=Math.sqrt(a-(g+b)+1),this.x=.5*a,a=.5/a,this.w=(l-f)*a,this.y=(c+e)*a,this.z=(d+k)*a):(a=Math.sqrt(b-(a+g)+1),this.z=.5*a,a=.5/a,this.w=(c-e)*a,this.x=(k+d)*a,this.y=(f+l)*a):g>b?(a=Math.sqrt(g-(b+a)+1),this.y=.5*a,a=.5/a,this.w=(k-d)*a,this.z=(l+f)*a,this.x=(e+c)*a):(a=Math.sqrt(b-(a+g)+1),this.z=.5*a,a=.5/a,this.w= (c-e)*a,this.x=(k+d)*a,this.y=(f+l)*a);return this},slerp:function(b,a,c){var d,e,g,l,k,f;d=b.x;e=b.y;g=b.z;b=b.w;l=a.x;k=a.y;f=a.z;a=a.w;var h=b*a+d*l+e*k+g*f;0>h&&(a=-a,l=-l,k=-k,f=-f,h=-h);if(1<=Math.abs(h))return this.w=b,this.x=d,this.y=e,this.z=g,this;var n=Math.acos(h),q=Math.sqrt(1-h*h);if(.001>Math.abs(q))return this.w=.5*b+.5*a,this.x=.5*d+.5*l,this.y=.5*e+.5*k,this.z=.5*g+.5*f,this;h=Math.sin((1-c)*n)/q;c=Math.sin(c*n)/q;this.w=b*h+a*c;this.x=d*h+l*c;this.y=e*h+k*c;this.z=g*h+f*c;return this}, transformVector:function(b,a){void 0===a&&(a=new pc.Vec3);var c=b.x,d=b.y,e=b.z,g=this.x,l=this.y,k=this.z,f=this.w,h=f*c+l*e-k*d,n=f*d+k*c-g*e,q=f*e+g*d-l*c,c=-g*c-l*d-k*e;a.x=h*f+c*-g+n*-k-q*-l;a.y=n*f+c*-l+q*-g-h*-k;a.z=q*f+c*-k+h*-l-n*-g;return a},toString:function(){return"["+this.x+", "+this.y+", "+this.z+", "+this.w+"]"}});Object.defineProperty(f,"IDENTITY",{get:function(){var b=new f;return function(){return b}}()});Object.defineProperty(f,"ZERO",{get:function(){var b=new f(0,0,0,0);return function(){return b}}()}); return{Quat:f}}());Object.assign(pc,function(){var f=function(b){this.keys=[];this.type=1;this.tension=.5;if(b)for(var a=0;ab);e++);c=[b,a];this.keys.splice(e,0,c);return c},get:function(b){return this.keys[b]},sort:function(){this.keys.sort(function(b,a){return b[0]-a[0]})},value:function(b){var a,c,d=this.keys;if(!d.length)return 0;if(b d[d.length-1][0])return d[d.length-1][1];var e=0,g=d.length?d[0][1]:0,l=1,k=0;a=0;for(c=d.length;aa+1&&(e=d[a+1][0]-d[a][0]);d.length>a+2&&(h=d[a+2][0]-d[a+1][0],f=d[a+2][1]);c=g+(c-g)*e/l;f=k+(f-k)*e/h;return 2===this.type? this._interpolateCatmullRom(c,g,k,f,b):this._interpolateCardinal(c,g,k,f,b,this.tension)}return pc.math.lerp(g,k,b)},_interpolateHermite:function(b,a,c,d,e){var g=e*e,l=e*e*e;return b*(2*l-3*g+1)+a*(-2*l+3*g)+c*(l-2*g+e)+d*(l-g)},_interpolateCardinal:function(b,a,c,d,e,g){return this._interpolateHermite(a,c,g*(c-b),g*(d-a),e)},_interpolateCatmullRom:function(b,a,c,d,e){return this._interpolateCardinal(b,a,c,d,e,.5)},closest:function(b){for(var a=this.keys,c=a.length,d=2,e=null,g=0;g=l)d=l,e=a[g];else break}return e},clone:function(){var b=new pc.Curve;b.keys=pc.extend(b.keys,this.keys);b.type=this.type;return b},quantize:function(b){b=Math.max(b,2);for(var a=new Float32Array(b),c=1/(b-1),d=0;db&&(b=v);ud&&(d=y);we&&(e=r);c.x=.5*(t+b);c.y=.5*(f+d);c.z=.5*(m+e);g.x=.5*(b-t);g.y=.5*(d-f);g.z=.5*(e-m)},copy:function(a){this.center.copy(a.center);this.halfExtents.copy(a.halfExtents);this.type=a.type},clone:function(){return new pc.BoundingBox(this.center.clone(),this.halfExtents.clone())},intersects:function(a){var c=this.getMax(),b=this.getMin(),d=a.getMax();a=a.getMin();return b.x<=d.x&&c.x>=a.x&&b.y<=d.y&&c.y>=a.y&&b.z<=d.z&&c.z>=a.z},_intersectsRay:function(d, e){var g=f.copy(this.getMin()).sub(d.origin),l=b.copy(this.getMax()).sub(d.origin),h=d.direction;0===h.x?(g.x=0>g.x?-Number.MAX_VALUE:Number.MAX_VALUE,l.x=0>l.x?-Number.MAX_VALUE:Number.MAX_VALUE):(g.x/=h.x,l.x/=h.x);0===h.y?(g.y=0>g.y?-Number.MAX_VALUE:Number.MAX_VALUE,l.y=0>l.y?-Number.MAX_VALUE:Number.MAX_VALUE):(g.y/=h.y,l.y/=h.y);0===h.z?(g.z=0>g.z?-Number.MAX_VALUE:Number.MAX_VALUE,l.z=0>l.z?-Number.MAX_VALUE:Number.MAX_VALUE):(g.z/=h.z,l.z/=h.z);h=a.set(Math.min(g.x,l.x),Math.min(g.y,l.y), Math.min(g.z,l.z));g=c.set(Math.max(g.x,l.x),Math.max(g.y,l.y),Math.max(g.z,l.z));l=Math.max(Math.max(h.x,h.y),h.z);(g=Math.min(Math.min(g.x,g.y),g.z)>=l&&0<=l)&&e.copy(d.direction).scale(l).add(d.origin);return g},_fastIntersectsRay:function(e){var g=e.direction;f.sub2(e.origin,this.center);c.set(Math.abs(f.x),Math.abs(f.y),Math.abs(f.z));a.mul2(f,g);if(c.x>this.halfExtents.x&&0<=a.x||c.y>this.halfExtents.y&&0<=a.y||c.z>this.halfExtents.z&&0<=a.z)return!1;d.set(Math.abs(g.x),Math.abs(g.y),Math.abs(g.z)); b.cross(g,f);b.set(Math.abs(b.x),Math.abs(b.y),Math.abs(b.z));return b.x>this.halfExtents.y*d.z+this.halfExtents.z*d.y||b.y>this.halfExtents.x*d.z+this.halfExtents.z*d.x||b.z>this.halfExtents.x*d.y+this.halfExtents.y*d.x?!1:!0},intersectsRay:function(a,c){return c?this._intersectsRay(a,c):this._fastIntersectsRay(a)},setMinMax:function(a,c){this.center.add2(c,a).scale(.5);this.halfExtents.sub2(c,a).scale(.5)},getMin:function(){return this._min.copy(this.center).sub(this.halfExtents)},getMax:function(){return this._max.copy(this.center).add(this.halfExtents)}, containsPoint:function(a){var c=this.getMin(),b=this.getMax();return a.xb.x||a.yb.y||a.zb.z?!1:!0},setFromTransformedAabb:function(a,c){var b=this.center,d=this.halfExtents,e=a.center,g=a.halfExtents;c=c.data;var l=c[0],f=c[4],r=c[8],t=c[1],v=c[5],y=c[9],u=c[2],w=c[6],x=c[10],D=Math.abs(l),z=Math.abs(f),C=Math.abs(r),A=Math.abs(t),B=Math.abs(v),J=Math.abs(y),F=Math.abs(u),H=Math.abs(w),E=Math.abs(x);b.set(c[12]+l*e.x+f*e.y+r*e.z,c[13]+t*e.x+v*e.y+y*e.z,c[14]+u*e.x+w* e.y+x*e.z);d.set(D*g.x+z*g.y+C*g.z,A*g.x+B*g.y+J*g.z,F*g.x+H*g.y+E*g.z)},compute:function(a){for(var c=f.set(a[0],a[1],a[2]),d=b.set(a[0],a[1],a[2]),e=a.length/3,g=1;gd.x&&(d.x=n);q>d.y&&(d.y=q);m>d.z&&(d.z=m)}this.setMinMax(c,d)},intersectsBoundingSphere:function(a){return this._distanceToBoundingSphereSq(a)<=a.radius*a.radius?!0:!1},_distanceToBoundingSphereSq:function(a){for(var c=this.getMin(),b=this.getMax(), d=0,e=["x","y","z"],g=0;3>g;++g){var f=0,m=a.center[e[g]],r=c[e[g]],t=b[e[g]];mt&&(r=m-t,f+=r*r);d+=f}return d}});return{BoundingBox:e}}());Object.assign(pc,function(){function f(a,c){this.center=a||new pc.Vec3(0,0,0);this.radius=void 0===c?.5:c}var b=new pc.Vec3,a=new pc.Vec3,c=new pc.Vec3,d=new pc.Vec3;Object.assign(f.prototype,{containsPoint:function(a){a=b.sub2(a,this.center).lengthSq();var c=this.radius;return ae)return!1;g=Math.abs(-g-Math.sqrt(e));d&&d.copy(c.direction).scale(g).add(c.origin);return!0},intersectsBoundingSphere:function(a){b.sub2(a.center,this.center);a=a.radius+this.radius;return b.lengthSq()<=a*a?!0:!1}});return{BoundingSphere:f}}());Object.assign(pc,function(){var f=new pc.Mat4,b=function(a,c){a=a||(new pc.Mat4).setPerspective(90,16/9,.1,1E3);c=c||new pc.Mat4;this.planes=[];for(var b=0;6>b;b++)this.planes[b]=[];this.update(a,c)};Object.assign(b.prototype,{update:function(a,c){f.mul2(a,c);var b=f.data;this.planes[0][0]=b[3]-b[0];this.planes[0][1]=b[7]-b[4];this.planes[0][2]=b[11]-b[8];this.planes[0][3]=b[15]-b[12];var e=Math.sqrt(this.planes[0][0]*this.planes[0][0]+this.planes[0][1]*this.planes[0][1]+this.planes[0][2]*this.planes[0][2]); this.planes[0][0]/=e;this.planes[0][1]/=e;this.planes[0][2]/=e;this.planes[0][3]/=e;this.planes[1][0]=b[3]+b[0];this.planes[1][1]=b[7]+b[4];this.planes[1][2]=b[11]+b[8];this.planes[1][3]=b[15]+b[12];e=Math.sqrt(this.planes[1][0]*this.planes[1][0]+this.planes[1][1]*this.planes[1][1]+this.planes[1][2]*this.planes[1][2]);this.planes[1][0]/=e;this.planes[1][1]/=e;this.planes[1][2]/=e;this.planes[1][3]/=e;this.planes[2][0]=b[3]+b[1];this.planes[2][1]=b[7]+b[5];this.planes[2][2]=b[11]+b[9];this.planes[2][3]= b[15]+b[13];e=Math.sqrt(this.planes[2][0]*this.planes[2][0]+this.planes[2][1]*this.planes[2][1]+this.planes[2][2]*this.planes[2][2]);this.planes[2][0]/=e;this.planes[2][1]/=e;this.planes[2][2]/=e;this.planes[2][3]/=e;this.planes[3][0]=b[3]-b[1];this.planes[3][1]=b[7]-b[5];this.planes[3][2]=b[11]-b[9];this.planes[3][3]=b[15]-b[13];e=Math.sqrt(this.planes[3][0]*this.planes[3][0]+this.planes[3][1]*this.planes[3][1]+this.planes[3][2]*this.planes[3][2]);this.planes[3][0]/=e;this.planes[3][1]/=e;this.planes[3][2]/= e;this.planes[3][3]/=e;this.planes[4][0]=b[3]-b[2];this.planes[4][1]=b[7]-b[6];this.planes[4][2]=b[11]-b[10];this.planes[4][3]=b[15]-b[14];e=Math.sqrt(this.planes[4][0]*this.planes[4][0]+this.planes[4][1]*this.planes[4][1]+this.planes[4][2]*this.planes[4][2]);this.planes[4][0]/=e;this.planes[4][1]/=e;this.planes[4][2]/=e;this.planes[4][3]/=e;this.planes[5][0]=b[3]+b[2];this.planes[5][1]=b[7]+b[6];this.planes[5][2]=b[11]+b[10];this.planes[5][3]=b[15]+b[14];e=Math.sqrt(this.planes[5][0]*this.planes[5][0]+ this.planes[5][1]*this.planes[5][1]+this.planes[5][2]*this.planes[5][2]);this.planes[5][0]/=e;this.planes[5][1]/=e;this.planes[5][2]/=e;this.planes[5][3]/=e},containsPoint:function(a){for(var b=0;6>b;b++)if(0>=this.planes[b][0]*a.x+this.planes[b][1]*a.y+this.planes[b][2]*a.z+this.planes[b][3])return!1;return!0},containsSphere:function(a){var b=0,d,e,g=a.radius;e=a.center;a=e.x;var l=e.y,k=e.z,f=this.planes;for(e=0;6>e;e++){d=f[e];d=d[0]*a+d[1]*l+d[2]*k+d[3];if(d<=-g)return 0;d>g&&b++}return 6===b? 2:1}});return{Frustum:b}}());Object.assign(pc,function(){var f=new pc.Vec3,b=function(a,b){this.normal=b||new pc.Vec3(0,0,1);this.point=a||new pc.Vec3(0,0,0)};Object.assign(b.prototype,{intersectsLine:function(a,b,d){var c=-this.normal.dot(this.point),g=this.normal.dot(a)+c,c=this.normal.dot(b)+c,g=g/(g-c);(c=0<=g&&1>=g)&&d&&d.lerp(a,b,g);return c},intersectsRay:function(a,b){var c=f.sub2(this.point,a.origin),c=this.normal.dot(c)/this.normal.dot(a.direction),e=0<=c;e&&b&&b.copy(a.direction).scale(c).add(a.origin);return e}}); return{Plane:b}}());Object.assign(pc,function(){return{Ray:function(f,b){this.origin=f||new pc.Vec3(0,0,0);this.direction=b||new pc.Vec3(0,0,-1)}}}());Object.assign(pc,function(){var f=new pc.Ray,b=new pc.Vec3,a=new pc.BoundingSphere,c=new pc.Mat4,d=function(a,b){this.halfExtents=b||new pc.Vec3(.5,.5,.5);a=a||c.setIdentity();this._modelTransform=a.clone().invert();this._worldTransform=a.clone();this._aabb=new pc.BoundingBox(new pc.Vec3,this.halfExtents)};Object.assign(d.prototype,{intersectsRay:function(a,b){this._modelTransform.transformPoint(a.origin,f.origin);this._modelTransform.transformVector(a.direction,f.direction);if(b){var d=this._aabb._intersectsRay(f, b);c.copy(this._modelTransform).invert().transformPoint(b,b);return d}return this._aabb._fastIntersectsRay(f)},containsPoint:function(a){this._modelTransform.transformPoint(a,b);return this._aabb.containsPoint(b)},intersectsBoundingSphere:function(b){this._modelTransform.transformPoint(b.center,a.center);a.radius=b.radius;return this._aabb.intersectsBoundingSphere(a)?!0:!1}});Object.defineProperty(d.prototype,"worldTransform",{get:function(){return this._worldTransform},set:function(a){this._worldTransform.copy(a); this._modelTransform.copy(a).invert()}});return{OrientedBox:d}}());(function(){var f={ADDRESS_REPEAT:0,ADDRESS_CLAMP_TO_EDGE:1,ADDRESS_MIRRORED_REPEAT:2,BLENDMODE_ZERO:0,BLENDMODE_ONE:1,BLENDMODE_SRC_COLOR:2,BLENDMODE_ONE_MINUS_SRC_COLOR:3,BLENDMODE_DST_COLOR:4,BLENDMODE_ONE_MINUS_DST_COLOR:5,BLENDMODE_SRC_ALPHA:6,BLENDMODE_SRC_ALPHA_SATURATE:7,BLENDMODE_ONE_MINUS_SRC_ALPHA:8,BLENDMODE_DST_ALPHA:9,BLENDMODE_ONE_MINUS_DST_ALPHA:10,BLENDEQUATION_ADD:0,BLENDEQUATION_SUBTRACT:1,BLENDEQUATION_REVERSE_SUBTRACT:2,BLENDEQUATION_MIN:3,BLENDEQUATION_MAX:4,BUFFER_STATIC:0, BUFFER_DYNAMIC:1,BUFFER_STREAM:2,BUFFER_GPUDYNAMIC:3,CLEARFLAG_COLOR:1,CLEARFLAG_DEPTH:2,CLEARFLAG_STENCIL:4,CUBEFACE_POSX:0,CUBEFACE_NEGX:1,CUBEFACE_POSY:2,CUBEFACE_NEGY:3,CUBEFACE_POSZ:4,CUBEFACE_NEGZ:5,CULLFACE_NONE:0,CULLFACE_BACK:1,CULLFACE_FRONT:2,CULLFACE_FRONTANDBACK:3,TYPE_INT8:0,TYPE_UINT8:1,TYPE_INT16:2,TYPE_UINT16:3,TYPE_INT32:4,TYPE_UINT32:5,TYPE_FLOAT32:6,FILTER_NEAREST:0,FILTER_LINEAR:1,FILTER_NEAREST_MIPMAP_NEAREST:2,FILTER_NEAREST_MIPMAP_LINEAR:3,FILTER_LINEAR_MIPMAP_NEAREST:4,FILTER_LINEAR_MIPMAP_LINEAR:5, FUNC_NEVER:0,FUNC_LESS:1,FUNC_EQUAL:2,FUNC_LESSEQUAL:3,FUNC_GREATER:4,FUNC_NOTEQUAL:5,FUNC_GREATEREQUAL:6,FUNC_ALWAYS:7,INDEXFORMAT_UINT8:0,INDEXFORMAT_UINT16:1,INDEXFORMAT_UINT32:2,PIXELFORMAT_A8:0,PIXELFORMAT_L8:1,PIXELFORMAT_L8_A8:2,PIXELFORMAT_R5_G6_B5:3,PIXELFORMAT_R5_G5_B5_A1:4,PIXELFORMAT_R4_G4_B4_A4:5,PIXELFORMAT_R8_G8_B8:6,PIXELFORMAT_R8_G8_B8_A8:7,PIXELFORMAT_DXT1:8,PIXELFORMAT_DXT3:9,PIXELFORMAT_DXT5:10,PIXELFORMAT_RGB16F:11,PIXELFORMAT_RGBA16F:12,PIXELFORMAT_RGB32F:13,PIXELFORMAT_RGBA32F:14, PIXELFORMAT_R32F:15,PIXELFORMAT_DEPTH:16,PIXELFORMAT_DEPTHSTENCIL:17,PIXELFORMAT_111110F:18,PIXELFORMAT_SRGB:19,PIXELFORMAT_SRGBA:20,PIXELFORMAT_ETC1:21,PIXELFORMAT_ETC2_RGB:22,PIXELFORMAT_ETC2_RGBA:23,PIXELFORMAT_PVRTC_2BPP_RGB_1:24,PIXELFORMAT_PVRTC_2BPP_RGBA_1:25,PIXELFORMAT_PVRTC_4BPP_RGB_1:26,PIXELFORMAT_PVRTC_4BPP_RGBA_1:27,PRIMITIVE_POINTS:0,PRIMITIVE_LINES:1,PRIMITIVE_LINELOOP:2,PRIMITIVE_LINESTRIP:3,PRIMITIVE_TRIANGLES:4,PRIMITIVE_TRISTRIP:5,PRIMITIVE_TRIFAN:6,SEMANTIC_POSITION:"POSITION", SEMANTIC_NORMAL:"NORMAL",SEMANTIC_TANGENT:"TANGENT",SEMANTIC_BLENDWEIGHT:"BLENDWEIGHT",SEMANTIC_BLENDINDICES:"BLENDINDICES",SEMANTIC_COLOR:"COLOR",SEMANTIC_TEXCOORD0:"TEXCOORD0",SEMANTIC_TEXCOORD1:"TEXCOORD1",SEMANTIC_TEXCOORD2:"TEXCOORD2",SEMANTIC_TEXCOORD3:"TEXCOORD3",SEMANTIC_TEXCOORD4:"TEXCOORD4",SEMANTIC_TEXCOORD5:"TEXCOORD5",SEMANTIC_TEXCOORD6:"TEXCOORD6",SEMANTIC_TEXCOORD7:"TEXCOORD7",SEMANTIC_ATTR0:"ATTR0",SEMANTIC_ATTR1:"ATTR1",SEMANTIC_ATTR2:"ATTR2",SEMANTIC_ATTR3:"ATTR3",SEMANTIC_ATTR4:"ATTR4", SEMANTIC_ATTR5:"ATTR5",SEMANTIC_ATTR6:"ATTR6",SEMANTIC_ATTR7:"ATTR7",SEMANTIC_ATTR8:"ATTR8",SEMANTIC_ATTR9:"ATTR9",SEMANTIC_ATTR10:"ATTR10",SEMANTIC_ATTR11:"ATTR11",SEMANTIC_ATTR12:"ATTR12",SEMANTIC_ATTR13:"ATTR13",SEMANTIC_ATTR14:"ATTR14",SEMANTIC_ATTR15:"ATTR15",SHADERTAG_MATERIAL:1,STENCILOP_KEEP:0,STENCILOP_ZERO:1,STENCILOP_REPLACE:2,STENCILOP_INCREMENT:3,STENCILOP_INCREMENTWRAP:4,STENCILOP_DECREMENT:5,STENCILOP_DECREMENTWRAP:6,STENCILOP_INVERT:7,TEXTURELOCK_READ:1,TEXTURELOCK_WRITE:2,TEXHINT_NONE:0, TEXHINT_SHADOWMAP:1,TEXHINT_ASSET:2,TEXHINT_LIGHTMAP:3,UNIFORMTYPE_BOOL:0,UNIFORMTYPE_INT:1,UNIFORMTYPE_FLOAT:2,UNIFORMTYPE_VEC2:3,UNIFORMTYPE_VEC3:4,UNIFORMTYPE_VEC4:5,UNIFORMTYPE_IVEC2:6,UNIFORMTYPE_IVEC3:7,UNIFORMTYPE_IVEC4:8,UNIFORMTYPE_BVEC2:9,UNIFORMTYPE_BVEC3:10,UNIFORMTYPE_BVEC4:11,UNIFORMTYPE_MAT2:12,UNIFORMTYPE_MAT3:13,UNIFORMTYPE_MAT4:14,UNIFORMTYPE_TEXTURE2D:15,UNIFORMTYPE_TEXTURECUBE:16,UNIFORMTYPE_FLOATARRAY:17,UNIFORMTYPE_TEXTURE2D_SHADOW:18,UNIFORMTYPE_TEXTURECUBE_SHADOW:19,UNIFORMTYPE_TEXTURE3D:20}; Object.assign(pc,f);pc.gfx={};Object.assign(pc.gfx,f)})();Object.assign(pc,function(){var f=function(b){this.name=b;this.value=null;this.versionObject=new pc.VersionedObject};Object.assign(f.prototype,{setValue:function(b){this.value=b;this.versionObject.increment()},getValue:function(b){return this.value}});return{ScopeId:f}}());Object.assign(pc,function(){var f=function(b){this.name=b;this.variables={};this.namespaces={}};Object.assign(f.prototype,{resolve:function(b){this.variables.hasOwnProperty(b)||(this.variables[b]=new pc.ScopeId(b));return this.variables[b]},getSubSpace:function(b){this.namespaces.hasOwnProperty(b)||(this.namespaces[b]=new pc.ScopeSpace(b));return this.namespaces[b]}});return{ScopeSpace:f}}());Object.assign(pc,function(){var f=function(){this.revision=this.globalId=0};Object.assign(f.prototype,{equals:function(b){return this.globalId===b.globalId&&this.revision===b.revision},notequals:function(b){return this.globalId!==b.globalId||this.revision!==b.revision},copy:function(b){this.globalId=b.globalId;this.revision=b.revision},reset:function(){this.revision=this.globalId=0}});return{Version:f}}());Object.assign(pc,function(){var f=0,b=function(){f++;this.version=new pc.Version;this.version.globalId=f};Object.assign(b.prototype,{increment:function(){this.version.revision++}});return{VersionedObject:b}}());Object.assign(pc,function(){function f(e,l){this.index=0;switch(l.dataType){case pc.TYPE_INT8:this.array=new Int8Array(e,l.offset);break;case pc.TYPE_UINT8:this.array=new Uint8Array(e,l.offset);break;case pc.TYPE_INT16:this.array=new Int16Array(e,l.offset);break;case pc.TYPE_UINT16:this.array=new Uint16Array(e,l.offset);break;case pc.TYPE_INT32:this.array=new Int32Array(e,l.offset);break;case pc.TYPE_UINT32:this.array=new Uint32Array(e,l.offset);break;case pc.TYPE_FLOAT32:this.array=new Float32Array(e, l.offset)}switch(l.numComponents){case 1:this.set=b;break;case 2:this.set=a;break;case 3:this.set=c;break;case 4:this.set=d}}function b(a){this.array[this.index]=a}function a(a,b){this.array[this.index]=a;this.array[this.index+1]=b}function c(a,b,c){this.array[this.index]=a;this.array[this.index+1]=b;this.array[this.index+2]=c}function d(a,b,c,d){this.array[this.index]=a;this.array[this.index+1]=b;this.array[this.index+2]=c;this.array[this.index+3]=d}function e(a){this.vertexBuffer=a;this.buffer= this.vertexBuffer.lock();this.accessors=[];this.element={};a=this.vertexBuffer.getFormat();for(var b=0;b=pc.PIXELFORMAT_ETC1;this._invalid=!1;this._lockedLevel= -1;this._levels||(this._levels=this._cubemap?[[null,null,null,null,null,null]]:[null]);this.dirtyAll();this._gpuSize=0};Object.defineProperty(f.prototype,"minFilter",{get:function(){return this._minFilter},set:function(a){this._minFilter!==a&&(this._minFilter=a,this._parameterFlags|=1)}});Object.defineProperty(f.prototype,"magFilter",{get:function(){return this._magFilter},set:function(a){this._magFilter!==a&&(this._magFilter=a,this._parameterFlags|=2)}});Object.defineProperty(f.prototype,"addressU", {get:function(){return this._addressU},set:function(a){this._addressU!==a&&(this._addressU=a,this._parameterFlags|=4)}});Object.defineProperty(f.prototype,"addressV",{get:function(){return this._addressV},set:function(a){this._addressV!==a&&(this._addressV=a,this._parameterFlags|=8)}});Object.defineProperty(f.prototype,"addressW",{get:function(){return this._addressW},set:function(a){this.device.webgl2&&this._volume&&a!==this._addressW&&(this._addressW=a,this._parameterFlags|=16)}});Object.defineProperty(f.prototype, "compareOnRead",{get:function(){return this._compareOnRead},set:function(a){this._compareOnRead!==a&&(this._compareOnRead=a,this._parameterFlags|=32)}});Object.defineProperty(f.prototype,"compareFunc",{get:function(){return this._compareFunc},set:function(a){this._compareFunc!==a&&(this._compareFunc=a,this._parameterFlags|=64)}});Object.defineProperty(f.prototype,"anisotropy",{get:function(){return this._anisotropy},set:function(a){this._anisotropy!==a&&(this._anisotropy=a,this._parameterFlags|=128)}}); Object.defineProperty(f.prototype,"autoMipmap",{get:function(){return this._mipmaps},set:function(a){this._mipmaps=a}});Object.defineProperty(f.prototype,"mipmaps",{get:function(){return this._mipmaps},set:function(a){this._mipmaps!==a&&(this._mipmaps=a,this._minFilterDirty=!0,a&&(this._needsMipmapsUpload=!0))}});Object.defineProperty(f.prototype,"width",{get:function(){return this._width}});Object.defineProperty(f.prototype,"height",{get:function(){return this._height}});Object.defineProperty(f.prototype, "depth",{get:function(){return this._depth}});Object.defineProperty(f.prototype,"format",{get:function(){return this._format}});Object.defineProperty(f.prototype,"cubemap",{get:function(){return this._cubemap}});var b=null;Object.defineProperty(f.prototype,"gpuSize",{get:function(){b||(b=[],b[pc.PIXELFORMAT_A8]=1,b[pc.PIXELFORMAT_L8]=1,b[pc.PIXELFORMAT_L8_A8]=1,b[pc.PIXELFORMAT_R5_G6_B5]=2,b[pc.PIXELFORMAT_R5_G5_B5_A1]=2,b[pc.PIXELFORMAT_R4_G4_B4_A4]=2,b[pc.PIXELFORMAT_R8_G8_B8]=4,b[pc.PIXELFORMAT_R8_G8_B8_A8]= 4,b[pc.PIXELFORMAT_RGB16F]=8,b[pc.PIXELFORMAT_RGBA16F]=8,b[pc.PIXELFORMAT_RGB32F]=16,b[pc.PIXELFORMAT_RGBA32F]=16,b[pc.PIXELFORMAT_R32F]=4,b[pc.PIXELFORMAT_DEPTH]=4,b[pc.PIXELFORMAT_DEPTHSTENCIL]=4,b[pc.PIXELFORMAT_111110F]=4,b[pc.PIXELFORMAT_SRGB]=4,b[pc.PIXELFORMAT_SRGBA]=4);var a=1;!this._pot||!this._mipmaps&&this._minFilter!==pc.FILTER_NEAREST_MIPMAP_NEAREST&&this._minFilter!==pc.FILTER_NEAREST_MIPMAP_LINEAR&&this._minFilter!==pc.FILTER_LINEAR_MIPMAP_NEAREST&&this._minFilter!==pc.FILTER_LINEAR_MIPMAP_LINEAR|| this._compressed&&1===this._levels.length||(a=Math.round(Math.log2(Math.max(this._width,this._height))+1));for(var c=this._width,d=this._height,e=this._depth,g=0,l=0;lb;b++){if(!a[b]||a[b].width!==e||a[b].height!==g||!(a[b]instanceof HTMLImageElement||a[b]instanceof HTMLCanvasElement||a[b]instanceof HTMLVideoElement)){d=!0;break}}else d=!0;if(!d)for(b=0;6>b;b++)this._levels[0][b]!==a[b]&&(this._levelsUpdated[0][b]=!0)}else a instanceof HTMLImageElement||a instanceof HTMLCanvasElement||a instanceof HTMLVideoElement|| (d=!0),d||(a!==this._levels[0]&&(this._levelsUpdated[0]=!0),e=a.width,g=a.height);if(d)if(this._height=this._width=4,this._pot=!0,this._cubemap)for(b=0;6>b;b++)this._levels[0][b]=null,this._levelsUpdated[0][b]=!0;else this._levels[0]=null,this._levelsUpdated[0]=!0;else this._width=e,this._height=g,this._pot=pc.math.powerOfTwo(this._width)&&pc.math.powerOfTwo(this._height),this._levels[0]=a;this._invalid===d&&d||(this._invalid=d,this.upload())},getSource:function(){return this._levels[0]},unlock:function(){this.upload(); this._lockedLevel=-1},upload:function(){this._needsUpload=!0;this._needsMipmapsUpload=this._mipmaps},getDds:function(){this.format!==pc.PIXELFORMAT_R8_G8_B8_A8&&console.error("This format is not implemented yet");for(var a=128,b=0,d,e;this._levels[b];){if(this.cubemap)for(e=0;6>e;e++){if(!this._levels[b][e]){console.error("No level data for mip "+b+", face "+e);return}d=this._levels[b][e].length;if(!d){console.error("No byte array for mip "+b+", face "+e);return}a+=d}else{d=this._levels[b].length; if(!d){console.error("No byte array for mip "+b);return}a+=d}a+=this._levels[b].length;b++}a=new ArrayBuffer(a);e=new Uint32Array(a,0,32);b=528391;1b;b++)e[8+b]=0;e[19]=32;e[20]=65;e[21]=0;e[22]=32;e[23]=16711680;e[24]= 65280;e[25]=255;e[26]=4278190080;e[27]=d;e[28]=g;e[29]=0;e[30]=0;e[31]=0;var g=128,l,k;if(this.cubemap)for(e=0;6>e;e++)for(b=0;bpc.SHADER_FORWARDHDR&&b<=pc.SHADER_PICK?this._defaultStdMatOptionMin:this._defaultStdMatOption};f.prototype.precompile=function(b){if(b)for(var a=Array(b.length),c=0;cb||d>b){var l=b/Math.max(c,d),k=Math.floor(c*l),l=Math.floor(d*l);console.warn("Image dimensions larger than max supported texture size of "+b+". Resizing from "+c+", "+d+" to "+k+", "+l+".");var f=document.createElement("canvas"); f.width=k;f.height=l;f.getContext("2d").drawImage(a,0,0,c,d,0,0,k,l);return f}return a},a=function(a,b){var c;this.canvas=a;this.indexBuffer=this.shader=null;this.vertexBuffers=[];this.vbOffsets=[];this._enableAutoInstancing=!1;this.autoInstancingMaxObjects=16384;this.attributesInvalidated=!0;this.boundElementBuffer=this.boundBuffer=null;this.instancedAttribs={};this.enabledAttributes={};this.activeFramebuffer=this.transformFeedbackBuffer=null;this.textureUnit=0;this.textureUnits=[];this._maxPixelRatio= 1;this.feedback=this.renderTarget=null;this._height=this._width=0;this.updateClientRect();this.vertexShaderCache={};this.fragmentShaderCache={};this.shaders=[];this.buffers=[];this.textures=[];this.targets=[];this.contextLost=!1;this._contextLostHandler=function(a){a.preventDefault();this.contextLost=!0;this.fire("devicelost")}.bind(this);this._contextRestoredHandler=function(){this.initializeContext();this.contextLost=!1;this.fire("devicerestored")}.bind(this);a.addEventListener("webglcontextlost", this._contextLostHandler,!1);a.addEventListener("webglcontextrestored",this._contextRestoredHandler,!1);var d=b&&void 0!==b.preferWebGl2?b.preferWebGl2:!0,l=d?["webgl2","experimental-webgl2","webgl","experimental-webgl"]:["webgl","experimental-webgl"],k=null;b=b||{};b.stencil=!0;for(c=0;cc;break}}if(!k)throw Error("WebGL not supported");this.gl=k;this.initializeExtensions();this.initializeCapabilities();this.initializeRenderState(); for(c=0;cthis.maxTextures;this.boneLimit=Math.floor((this.vertexUniformsCount- 16-8-1-16)/4);this.boneLimit=Math.min(this.boneLimit,128);"Mali-450 MP"===this.unmaskedRenderer&&(this.boneLimit=34);"Apple A8 GPU"===this.unmaskedRenderer&&(this.forceCpuParticles=!0);this._shaderSwitchesPerFrame=this._drawCallsPerFrame=0;this._primsPerFrame=[];for(c=pc.PRIMITIVE_POINTS;c<=pc.PRIMITIVE_TRIFAN;c++)this._primsPerFrame[c]=0;this._renderTargetCreationTime=0;this._vram={tex:0,vb:0,ib:0};this._shaderStats={vsCompiled:0,fsCompiled:0,linked:0,materialShaders:0,compileTime:0};this.constantTexSource= this.scope.resolve("source");this.textureFloatRenderable=this.extTextureFloat?this.webgl2?!!this.extColorBufferFloat:f(k,k.FLOAT):!1;this.textureHalfFloatRenderable=this.extTextureHalfFloat?this.webgl2?!!this.extColorBufferFloat:f(k,this.extTextureHalfFloat.HALF_FLOAT_OES):!1;this._textureFloatHighPrecision=void 0;this.initializeGrabPassTexture()};Object.assign(a.prototype,{getPrecision:function(){var a=this.gl,b="highp";if(a.getShaderPrecisionFormat){var e=a.getShaderPrecisionFormat(a.VERTEX_SHADER, a.HIGH_FLOAT),g=a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.MEDIUM_FLOAT),l=a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.HIGH_FLOAT),a=a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.MEDIUM_FLOAT),g=0k;k++)a._levelsUpdated[0][k]&&(l=g[k],l instanceof HTMLImageElement&&(l.width>this.maxCubeMapSize||l.height>this.maxCubeMapSize)&&(l=b(l,this.maxCubeMapSize),0===e&&(a.width=l.width,a.height=l.height)),this.setUnpackFlipY(!1),this.setUnpackPremultiplyAlpha(a._premultiplyAlpha),c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+k,e,a._glInternalFormat,a._glFormat,a._glPixelType,l));else for(l=1/Math.pow(2,e),k=0;6>k;k++)if(a._levelsUpdated[0][k]){var f=g[k];a._compressed?c.compressedTexImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+k,e,a._glInternalFormat,Math.max(a._width* l,1),Math.max(a._height*l,1),0,f):(this.setUnpackFlipY(!1),this.setUnpackPremultiplyAlpha(a._premultiplyAlpha),c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+k,e,a._glInternalFormat,Math.max(a._width*l,1),Math.max(a._height*l,1),0,a._glFormat,a._glPixelType,f))}}else a._volume?(l=1/Math.pow(2,e),a._compressed?c.compressedTexImage3D(c.TEXTURE_3D,e,a._glInternalFormat,Math.max(a._width*l,1),Math.max(a._height*l,1),Math.max(a._depth*l,1),0,g):(this.setUnpackFlipY(!1),this.setUnpackPremultiplyAlpha(a._premultiplyAlpha), c.texImage3D(c.TEXTURE_3D,e,a._glInternalFormat,Math.max(a._width*l,1),Math.max(a._height*l,1),Math.max(a._depth*l,1),0,a._glFormat,a._glPixelType,g))):(g instanceof HTMLCanvasElement||g instanceof HTMLImageElement||g instanceof HTMLVideoElement?(g instanceof HTMLImageElement&&(g.width>this.maxTextureSize||g.height>this.maxTextureSize)&&(g=b(g,this.maxTextureSize),0===e&&(a.width=g.width,a.height=g.height)),this.setUnpackFlipY(a._flipY),this.setUnpackPremultiplyAlpha(a._premultiplyAlpha),c.texImage2D(c.TEXTURE_2D, e,a._glInternalFormat,a._glFormat,a._glPixelType,g)):(l=1/Math.pow(2,e),a._compressed?c.compressedTexImage2D(c.TEXTURE_2D,e,a._glInternalFormat,Math.max(a._width*l,1),Math.max(a._height*l,1),0,g):(this.setUnpackFlipY(!1),this.setUnpackPremultiplyAlpha(a._premultiplyAlpha),c.texImage2D(c.TEXTURE_2D,e,a._glInternalFormat,Math.max(a._width*l,1),Math.max(a._height*l,1),0,a._glFormat,a._glPixelType,g))),a._mipmapsUploaded=0===e?!1:!0)}e++}if(a._needsUpload)if(a._cubemap)for(e=0;6>e;e++)a._levelsUpdated[0][e]= !1;else a._levelsUpdated[0]=!1;!a._compressed&&a._mipmaps&&a._needsMipmapsUpload&&a._pot&&1===a._levels.length&&(c.generateMipmap(a._glTarget),a._mipmapsUploaded=!0);a._gpuSize&&(this._vram.tex-=a._gpuSize);a._gpuSize=a.gpuSize;this._vram.tex+=a._gpuSize}},activeTexture:function(a){this.textureUnit!==a&&(this.gl.activeTexture(this.gl.TEXTURE0+a),this.textureUnit=a)},bindTexture:function(a){var b=a._glTarget;a=a._glTexture;var c=this.textureUnit,g=this.targetToSlot[b];this.textureUnits[c][g]!==a&& (this.gl.bindTexture(b,a),this.textureUnits[c][g]=a)},bindTextureOnUnit:function(a,b){var c=a._glTarget,d=a._glTexture,l=this.targetToSlot[c];this.textureUnits[b][l]!==d&&(this.activeTexture(b),this.gl.bindTexture(c,d),this.textureUnits[b][l]=d)},setTextureParameters:function(a){var b=this.gl,c=a._parameterFlags,g=a._glTarget;if(c&1){var l=a._minFilter;if(!a._pot||!a._mipmaps||a._compressed&&1===a._levels.length)if(l===pc.FILTER_NEAREST_MIPMAP_NEAREST||l===pc.FILTER_NEAREST_MIPMAP_LINEAR)l=pc.FILTER_NEAREST; else if(l===pc.FILTER_LINEAR_MIPMAP_NEAREST||l===pc.FILTER_LINEAR_MIPMAP_LINEAR)l=pc.FILTER_LINEAR;b.texParameteri(g,b.TEXTURE_MIN_FILTER,this.glFilter[l])}c&2&&b.texParameteri(g,b.TEXTURE_MAG_FILTER,this.glFilter[a._magFilter]);c&4&&(this.webgl2?b.texParameteri(g,b.TEXTURE_WRAP_S,this.glAddress[a._addressU]):b.texParameteri(g,b.TEXTURE_WRAP_S,this.glAddress[a._pot?a._addressU:pc.ADDRESS_CLAMP_TO_EDGE]));c&8&&(this.webgl2?b.texParameteri(g,b.TEXTURE_WRAP_T,this.glAddress[a._addressV]):b.texParameteri(g, b.TEXTURE_WRAP_T,this.glAddress[a._pot?a._addressV:pc.ADDRESS_CLAMP_TO_EDGE]));c&16&&this.webgl2&&b.texParameteri(g,b.TEXTURE_WRAP_R,this.glAddress[a._addressW]);c&32&&this.webgl2&&b.texParameteri(g,b.TEXTURE_COMPARE_MODE,a._compareOnRead?b.COMPARE_REF_TO_TEXTURE:b.NONE);c&64&&this.webgl2&&b.texParameteri(g,b.TEXTURE_COMPARE_FUNC,this.glComparison[a._compareFunc]);c&128&&(c=this.extTextureFilterAnisotropic)&&b.texParameterf(g,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.max(1,Math.min(Math.round(a._anisotropy), this.maxAnisotropy)))},setTexture:function(a,b){a._glTexture||this.initializeTexture(a);if(0x;x++)u=new pc.RenderTarget(b,D,{face:x,depth:!1}),m.x=x,m.y=0,n.setValue(d),q.setValue(m.data),pc.drawQuadWithShader(b,u,h),f(b,u,x);d=D}if(128x;x++)u=new pc.RenderTarget(b,D,{face:x,depth:!1}),m.x=x,m.y=C,m.z=r,m.w=p?3:0,n.setValue(d),q.setValue(m.data),pc.drawQuadWithShader(b,u,h),w===z-1&&l&&f(b,u,x);d=D}}a.sourceCubemap=d;D=null;if(!p&&a.filteredFixedRgbm)for(D=new pc.Texture(b,{cubemap:!0,rgbm:!0,format:pc.PIXELFORMAT_R8_G8_B8_A8, width:r,height:r,mipmaps:!1}),D.name="prefiltered-cube",x=0;6>x;x++)u=new pc.RenderTarget(b,D,{face:x,depth:!1}),m.x=x,m.w=2,n.setValue(d),q.setValue(m.data),pc.drawQuadWithShader(b,u,h),f(b,u,x);r=0===e?1:2048;u=0===e?0:-1;t[u]=[];for(w=0;5>w;w++)for(h=u;hh?p:!0,format:2>h?k:pc.PIXELFORMAT_R8_G8_B8_A8,fixCubemapSeams:1===h||3===h,width:y[w],height:y[w],mipmaps:!1}),t[h][w].name="prefiltered-cube");for(h=u;hw;w++)for(x=0;6>x;x++)u=new pc.RenderTarget(b,t[h][w],{face:x,depth:!1}),m.x=x,m.y=0>h?r:v[w],m.z=y[w],m.w=p?3:h,n.setValue(0===w?d:0===e?t[0][w-1]:t[-1][w-1]),q.setValue(m.data),pc.drawQuadWithShader(b,u,g),l&&f(b,u,x);a.filtered=t[0];if(l&&a.singleFilteredFixed){d=[d,a.filteredFixed[0],a.filteredFixed[1],a.filteredFixed[2],a.filteredFixed[3],a.filteredFixed[4],a.filteredFixed[5]];p=new pc.Texture(b,{cubemap:!0,rgbm:p,fixCubemapSeams:!0,format:k,width:128, height:128,addressU:pc.ADDRESS_CLAMP_TO_EDGE,addressV:pc.ADDRESS_CLAMP_TO_EDGE});p.name="prefiltered-cube";for(w=0;6>w;w++)p._levels[w]=d[w]._levels[0];p.upload();p._prefilteredMips=!0;a.singleFilteredFixed=p}if(l&&a.singleFilteredFixedRgbm&&a.filteredFixedRgbm){d=[D,a.filteredFixedRgbm[0],a.filteredFixedRgbm[1],a.filteredFixedRgbm[2],a.filteredFixedRgbm[3],a.filteredFixedRgbm[4],a.filteredFixedRgbm[5]];p=new pc.Texture(b,{cubemap:!0,rgbm:!0,fixCubemapSeams:!0,format:pc.PIXELFORMAT_R8_G8_B8_A8,width:128, height:128,addressU:pc.ADDRESS_CLAMP_TO_EDGE,addressV:pc.ADDRESS_CLAMP_TO_EDGE});p.name="prefiltered-cube";for(w=0;6>w;w++)p._levels[w]=d[w]._levels[0];p.upload();p._prefilteredMips=!0;a.singleFilteredFixedRgbm=p}}},shFromCubemap:function(a,c){var d,e=a.width,g,l;if(a.format!=pc.PIXELFORMAT_R8_G8_B8_A8)console.error("ERROR: SH: cubemap must be RGBA8");else{if(a._levels[0]){if(!a._levels[0][0].length)if(a._levels[0][0]instanceof HTMLImageElement){g=pc.Application.getApplication().graphicsDevice;l= g.gl;d=pc.shaderChunks;var k=d.createShaderFromCode(g,d.fullscreenQuadVS,d.fullscreenQuadPS,"fsQuadSimple"),f=g.scope.resolve("source");for(d=0;6>d;d++){var h=a._levels[0][d],n=new pc.Texture(g,{cubemap:!1,rgbm:!1,format:a.format,width:e,height:e,mipmaps:!1});n.name="prefiltered-cube";n._levels[0]=h;n.upload();h=new pc.Texture(g,{cubemap:!1,rgbm:!1,format:a.format,width:e,height:e,mipmaps:!1});h.name="prefiltered-cube";h=new pc.RenderTarget(g,h,{depth:!1});f.setValue(n);pc.drawQuadWithShader(g,h, k);var q=new Uint8Array(e*e*4);l.bindFramebuffer(l.FRAMEBUFFER,h._glFrameBuffer);l.readPixels(0,0,n.width,n.height,l.RGBA,l.UNSIGNED_BYTE,q);a._levels[0][d]=q}}else{console.error("ERROR: SH: cubemap must be composed of arrays or images");return}k=[];for(l=0;ld;d++)for(l=0;lm;m++)t=a._levels[0][d][4*n+m]/255,a.rgbm?(t*= 8*r,t*=t):t=Math.pow(t,2.2),f[0+m]+=t*w,f[3+m]+=t*x*v,f[6+m]+=t*x*y,f[9+m]+=t*x*u,f[12+m]+=t*D*v*u,f[15+m]+=t*D*u*y,f[18+m]+=t*D*y*v,f[21+m]+=t*z*(3*u*u-1),f[24+m]+=t*C*(v*v-y*y),h+=q}for(m=0;mm;m++){c=pc.paraboloidFromCubemap(f, b[m],m,a);k.setValue(c);c=d;var r=m;c.x=.5*pc.math.clamp(r-2,0,1);var r=r-6*c.x,t=1-c.x;c.y=Math.min(.5*r,.75)*t+c.x;c.z=(1-.5*pc.math.clamp(r,0,1))*t;c.w=.5*c.z;c=1/c.z;e.x=c*q;e.y=2*e.x;e.x+=1;e.y+=1;p.setValue(e.data);d.x*=g;d.y*=g;d.z*=g;d.w*=g;pc.drawQuadWithShader(f,n,l,d)}return h}}}());pc.shaderChunks.TBNPS="void getTBN() {\n dTBN = mat3(normalize(dTangentW), normalize(dBinormalW), normalize(dVertexNormalW));\n}\n";pc.shaderChunks.TBNderivativePS="// http://www.thetenthplanet.de/archives/1180\nvoid getTBN() {\n vec2 uv = $UV;\n // get edge vectors of the pixel triangle\n vec3 dp1 = dFdx( vPositionW );\n vec3 dp2 = dFdy( vPositionW );\n vec2 duv1 = dFdx( uv );\n vec2 duv2 = dFdy( uv );\n // solve the linear system\n vec3 dp2perp = cross( dp2, dVertexNormalW );\n vec3 dp1perp = cross( dVertexNormalW, dp1 );\n vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;\n vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;\n // construct a scale-invariant frame\n float invmax = 1.0 / sqrt( max( dot(T,T), dot(B,B) ) );\n dTBN = mat3( T * invmax, B * invmax, dVertexNormalW );\n}\n"; pc.shaderChunks.TBNfastPS="void getTBN() {\n dTBN = mat3(dTangentW, dBinormalW, dVertexNormalW);\n}\n";pc.shaderChunks.alphaTestPS="uniform float alpha_ref;\nvoid alphaTest(float a) {\n if (a < alpha_ref) discard;\n}\n";pc.shaderChunks.ambientConstantPS="\nvoid addAmbient() {\n dDiffuseLight += light_globalAmbient;\n}\n";pc.shaderChunks.ambientPrefilteredCubePS="#ifndef PMREM4\n#define PMREM4\nuniform samplerCube texture_prefilteredCubeMap4;\n#endif\nvoid addAmbient() {\n vec3 fixedReflDir = fixSeamsStatic(dNormalW, 1.0 - 1.0 / 4.0);\n fixedReflDir.x *= -1.0;\n dDiffuseLight += processEnvironment($DECODE(textureCube(texture_prefilteredCubeMap4, fixedReflDir)).rgb);\n}\n"; pc.shaderChunks.ambientPrefilteredCubeLodPS="#ifndef PMREM4\n#define PMREM4\n#extension GL_EXT_shader_texture_lod : enable\nuniform samplerCube texture_prefilteredCubeMap128;\n#endif\nvoid addAmbient() {\n vec3 fixedReflDir = fixSeamsStatic(dNormalW, 1.0 - 1.0 / 4.0);\n fixedReflDir.x *= -1.0;\n dDiffuseLight += processEnvironment($DECODE( textureCubeLodEXT(texture_prefilteredCubeMap128, fixedReflDir, 5.0) ).rgb);\n}\n";pc.shaderChunks.ambientSHPS="uniform vec3 ambientSH[9];\nvoid addAmbient() {\n vec3 n = dNormalW;\n vec3 color =\n ambientSH[0] +\n ambientSH[1] * n.x +\n ambientSH[2] * n.y +\n ambientSH[3] * n.z +\n ambientSH[4] * n.x * n.z +\n ambientSH[5] * n.z * n.y +\n ambientSH[6] * n.y * n.x +\n ambientSH[7] * (3.0 * n.z * n.z - 1.0) +\n ambientSH[8] * (n.x * n.x - n.y * n.y);\n dDiffuseLight += processEnvironment(max(color, vec3(0.0)));\n}\n"; pc.shaderChunks.aoPS="#ifdef MAPTEXTURE\nuniform sampler2D texture_aoMap;\n#endif\nvoid applyAO() {\n dAo = 1.0;\n #ifdef MAPTEXTURE\n dAo *= texture2D(texture_aoMap, $UV).$CH;\n #endif\n #ifdef MAPVERTEX\n dAo *= saturate(vVertexColor.$VC);\n #endif\n dDiffuseLight *= dAo;\n}\n";pc.shaderChunks.aoSpecOccPS="uniform float material_occludeSpecularIntensity;\nvoid occludeSpecular() {\n // approximated specular occlusion from AO\n float specPow = exp2(dGlossiness * 11.0);\n // http://research.tri-ace.com/Data/cedec2011_RealtimePBR_Implementation_e.pptx\n float specOcc = saturate(pow(dot(dNormalW, dViewDirW) + dAo, 0.01*specPow) - 1.0 + dAo);\n specOcc = mix(1.0, specOcc, material_occludeSpecularIntensity);\n dSpecularLight *= specOcc;\n dReflection *= specOcc;\n}\n"; pc.shaderChunks.aoSpecOccConstPS="void occludeSpecular() {\n // approximated specular occlusion from AO\n float specPow = exp2(dGlossiness * 11.0);\n // http://research.tri-ace.com/Data/cedec2011_RealtimePBR_Implementation_e.pptx\n float specOcc = saturate(pow(dot(dNormalW, dViewDirW) + dAo, 0.01*specPow) - 1.0 + dAo);\n dSpecularLight *= specOcc;\n dReflection *= specOcc;\n}\n";pc.shaderChunks.aoSpecOccConstSimplePS="void occludeSpecular() {\n float specOcc = dAo;\n dSpecularLight *= specOcc;\n dReflection *= specOcc;\n}\n"; pc.shaderChunks.aoSpecOccSimplePS="uniform float material_occludeSpecularIntensity;\nvoid occludeSpecular() {\n float specOcc = mix(1.0, dAo, material_occludeSpecularIntensity);\n dSpecularLight *= specOcc;\n dReflection *= specOcc;\n}\n";pc.shaderChunks.bakeDirLmEndPS="\n vec4 dirLm = texture2D(texture_dirLightMap, vUv1);\n if (bakeDir > 0.5) {\n if (dAtten > 0.00001) {\n dirLm.xyz = dirLm.xyz * 2.0 - vec3(1.0);\n dAtten = saturate(dAtten);\n gl_FragColor.rgb = normalize(dLightDirNormW.xyz*dAtten + dirLm.xyz*dirLm.w) * 0.5 + vec3(0.5);\n gl_FragColor.a = dirLm.w + dAtten;\n gl_FragColor.a = max(gl_FragColor.a, 1.0 / 255.0);\n } else {\n gl_FragColor = dirLm;\n }\n } else {\n gl_FragColor.rgb = dirLm.xyz;\n gl_FragColor.a = max(dirLm.w, dAtten > 0.00001? (1.0/255.0) : 0.0);\n }\n"; pc.shaderChunks.bakeLmEndPS="\ngl_FragColor.rgb = dDiffuseLight;\ngl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(0.5));\ngl_FragColor.rgb /= 8.0;\ngl_FragColor.a = clamp( max( max( gl_FragColor.r, gl_FragColor.g ), max( gl_FragColor.b, 1.0 / 255.0 ) ), 0.0,1.0 );\ngl_FragColor.a = ceil(gl_FragColor.a * 255.0) / 255.0;\ngl_FragColor.rgb /= gl_FragColor.a;\n";pc.shaderChunks.basePS="\nuniform vec3 view_position;\nuniform vec3 light_globalAmbient;\nfloat square(float x) {\n return x*x;\n}\nfloat saturate(float x) {\n return clamp(x, 0.0, 1.0);\n}\nvec3 saturate(vec3 x) {\n return clamp(x, vec3(0.0), vec3(1.0));\n}\n"; pc.shaderChunks.baseVS="\nattribute vec3 vertex_position;\nattribute vec3 vertex_normal;\nattribute vec4 vertex_tangent;\nattribute vec2 vertex_texCoord0;\nattribute vec2 vertex_texCoord1;\nattribute vec4 vertex_color;\nuniform mat4 matrix_viewProjection;\nuniform mat4 matrix_model;\nuniform mat3 matrix_normal;\nvec3 dPositionW;\nmat4 dModelMatrix;\nmat3 dNormalMatrix;\nvec3 dLightPosW;\nvec3 dLightDirNormW;\nvec3 dNormalW;\n";pc.shaderChunks.baseNineSlicedPS="#define NINESLICED\nvarying vec2 vMask;\nvarying vec2 vTiledUv;\nuniform mediump vec4 innerOffset;\nuniform mediump vec2 outerScale;\nuniform mediump vec4 atlasRect;\nvec2 nineSlicedUv;\n"; pc.shaderChunks.baseNineSlicedVS="#define NINESLICED\nvarying vec2 vMask;\nvarying vec2 vTiledUv;\nuniform mediump vec4 innerOffset;\nuniform mediump vec2 outerScale;\nuniform mediump vec4 atlasRect;\n";pc.shaderChunks.baseNineSlicedTiledPS="#define NINESLICED\n#define NINESLICETILED\nvarying vec2 vMask;\nvarying vec2 vTiledUv;\nuniform mediump vec4 innerOffset;\nuniform mediump vec2 outerScale;\nuniform mediump vec4 atlasRect;\nvec2 nineSlicedUv;\n";pc.shaderChunks.biasConstPS="#define SHADOWBIAS\nfloat getShadowBias(float resolution, float maxBias) {\n return maxBias;\n}\n"; pc.shaderChunks.blurVSMPS="\nvarying vec2 vUv0;\nuniform sampler2D source;\nuniform vec2 pixelOffset;\n#ifdef GAUSS\nuniform float weight[SAMPLES];\n#endif\n#ifdef PACKED\nfloat decodeFloatRG(vec2 rg) {\n return rg.y*(1.0/255.0) + rg.x;\n}\nvec2 encodeFloatRG( float v ) {\n vec2 enc = vec2(1.0, 255.0) * v;\n enc = fract(enc);\n enc -= enc.yy * vec2(1.0/255.0, 1.0/255.0);\n return enc;\n}\n#endif\nvoid main(void) {\n vec3 moments = vec3(0.0);\n vec2 uv = vUv0 - pixelOffset * (float(SAMPLES) * 0.5);\n for(int i=0; ib.length){for(var a=b,c=a.charAt(a.length-1),d=pc._matTex2D[f]-a.length,e=0;e=pc.SHADER_SHADOW&&17>=b.pass;this.options=b;var h="",n="",q="",m=pc.shaderChunks,r,t={vertex_position:pc.SEMANTIC_POSITION};if(b.chunks){var v={};for(c in m)m.hasOwnProperty(c)&&(b.chunks[c]?(r=b.chunks[c],0<=r.indexOf("vertex_normal")&&(t.vertex_normal=pc.SEMANTIC_NORMAL),0<=r.indexOf("vertex_tangent")&&(t.vertex_tangent=pc.SEMANTIC_TANGENT),0<=r.indexOf("vertex_texCoord0")&&(t.vertex_texCoord0=pc.SEMANTIC_TEXCOORD0),0<=r.indexOf("vertex_texCoord1")&&(t.vertex_texCoord1=pc.SEMANTIC_TEXCOORD1), 0<=r.indexOf("vertex_color")&&(t.vertex_color=pc.SEMANTIC_COLOR),0<=r.indexOf("vertex_boneWeights")&&(t.vertex_boneWeights=pc.SEMANTIC_BLENDWEIGHT),0<=r.indexOf("vertex_boneIndices")&&(t.vertex_boneIndices=pc.SEMANTIC_BLENDINDICES),v[c]=r):v[c]=m[c]);for(c in b.chunks)(m=this._oldChunkToNew[c])&&(v[m.n]=m.f(b.chunks[c],m.n,c));m=v}h=this._vsAddBaseCode(h,f,m,b);v=-1;if(!b.noShadow&&!b.twoSidedLighting){for(a=0;a=f.fragmentUniformsCount&&(h+=m.viewNormalVS,n+=" vNormalV = getViewNormal();\n"),(b.heightMap||b.normalMap)&&b.hasTangents&&(t.vertex_tangent=pc.SEMANTIC_TANGENT,h+=m.tangentBinormalVS,n+=" vTangentW = getTangent();\n vBinormalW = getBinormal();\n"), 0<=v&&(r=b.lights[v]._type,n=r===pc.LIGHTTYPE_DIRECTIONAL?n+(" dLightDirNormW = light"+v+"_directionVS;\n"):n+(" getLightDirPoint(light"+v+"_positionVS);\n"),n+=this._nonPointShadowMapProjection(f,b.lights[v],"(light"+v+"_shadowMatrixVS, light"+v+"_shadowParamsVS);\n")));r=[];var y=[],u,w,x;for(c in pc._matTex2D)a=c+"Map",b[c+"VertexColor"]&&(u=c+"VertexColorChannel",b[u]=this._correctChannel(c,b[u])),b[a]&&(u=a+"Channel",w=a+"Transform",x=a+"Uv",b[x]=Math.min(b[x],1),b[u]=this._correctChannel(c, b[u]),x=b[x],r[x]=!0,y[x]=y[x]||b[a]&&!b[w]);b.forceUv1&&(r[1]=!0);for(a=0;2>a;a++)r[a]&&(t["vertex_texCoord"+a]=pc["SEMANTIC_TEXCOORD"+a],h+=m["uv"+a+"VS"],n+=" vec2 uv"+a+" = getUv"+a+"();\n"),y[a]&&(n+=" vUv"+a+" = uv"+a+";\n");r=[h,q,n,[]];for(c in pc._matTex2D)a=c+"Map",b[a]&&(w=a+"Transform",b[w]&&(x=a+"Uv",this._setMapTransform(r,c,b[w],b[x])));h=r[0];q=r[1];n=r[2];b.vertexColors&&(t.vertex_color=pc.SEMANTIC_COLOR,n+=" vVertexColor = vertex_color;\n");b.skin?(t.vertex_boneWeights=pc.SEMANTIC_BLENDWEIGHT, t.vertex_boneIndices=pc.SEMANTIC_BLENDINDICES,h+=pc.programlib.skinCode(f,m),h+="#define SKIN\n"):b.useInstancing&&(h+="#define INSTANCING\n");b.screenSpace&&(h+="#define SCREENSPACE\n");b.pixelSnap&&(h+="#define PIXELSNAP\n");h=this._vsAddTransformCode(h,f,m,b);k&&(h+=m.normalVS);h=h+"\n"+m.startVS;c=h=h+n+"}";r=q;q=""+this._addVaryingIfNeeded(h,"vec4","vMainShadowUv");q+=this._addVaryingIfNeeded(h,"vec4","vVertexColor");q+=this._addVaryingIfNeeded(h,"vec3","vPositionW");q+=this._addVaryingIfNeeded(h, "vec3","vNormalV");q+=this._addVaryingIfNeeded(h,"vec3","vNormalW");q+=this._addVaryingIfNeeded(h,"vec3","vTangentW");q+=this._addVaryingIfNeeded(h,"vec3","vBinormalW");q+=this._addVaryingIfNeeded(h,"vec2","vUv0");q+=this._addVaryingIfNeeded(h,"vec2","vUv1");q+=r;c=q+c;h="";f.webgl2?(h=pc.programlib.versionCode(f),m.extensionVS&&(h+=m.extensionVS+"\n"),c=h+m.gles3VS+c):(m.extensionVS&&(h=m.extensionVS+"\n"),c=h+c);b.forceFragmentPrecision&&"highp"!=b.forceFragmentPrecision&&"mediump"!==b.forceFragmentPrecision&& "lowp"!==b.forceFragmentPrecision&&(b.forceFragmentPrecision=null);b.forceFragmentPrecision&&("highp"===b.forceFragmentPrecision&&"highp"!==f.maxPrecision&&(b.forceFragmentPrecision="mediump"),"mediump"===b.forceFragmentPrecision&&"lowp"===f.maxPrecision&&(b.forceFragmentPrecision="lowp"));h="";f.webgl2&&(h+=pc.programlib.versionCode(f));f.extStandardDerivatives&&!f.webgl2&&(h+="#extension GL_OES_standard_derivatives : enable\n\n");m.extensionPS&&(h+=m.extensionPS+"\n");f.webgl2&&(h+=m.gles3PS);h+= b.forceFragmentPrecision?"precision "+b.forceFragmentPrecision+" float;\n\n":pc.programlib.precisionCode(f);if(b.pass===pc.SHADER_PICK)return h=h+"uniform vec4 uColor;"+q,b.alphaTest&&(h=h+"float dAlpha;\n"+this._addMap("opacity","opacityPS",b,m),h+=m.alphaTestPS),h+=pc.programlib.begin(),b.alphaTest&&(h+=" getOpacity();\n alphaTest(dAlpha);\n"),h=h+" gl_FragColor = uColor;\n"+pc.programlib.end(),{attributes:t,vshader:c,fshader:h};if(b.pass===pc.SHADER_DEPTH)return h=h+"varying float vDepth;\n"+ q+m.packDepthPS,b.alphaTest&&(h+="float dAlpha;\n",h+=this._addMap("opacity","opacityPS",b,m),h+=m.alphaTestPS),h+=pc.programlib.begin(),b.alphaTest&&(h+=" getOpacity();\n",h+=" alphaTest(dAlpha);\n"),h+=" gl_FragColor = packFloat(vDepth);\n",h+=pc.programlib.end(),{attributes:t,vshader:c,fshader:h};if(p){e=b.pass-pc.SHADER_SHADOW;r=Math.floor(e/5);e-=5*r;f.extStandardDerivatives&&!f.webgl2&&(h+="uniform vec2 polygonOffset;\n");e===pc.SHADOW_VSM32?h=f.textureFloatHighPrecision?h+"#define VSM_EXPONENT 15.0\n\n": h+"#define VSM_EXPONENT 5.54\n\n":e===pc.SHADOW_VSM16&&(h+="#define VSM_EXPONENT 5.54\n\n");r!==pc.LIGHTTYPE_DIRECTIONAL&&(h+="uniform vec3 view_position;\n",h+="uniform float light_radius;\n");h+=q;b.alphaTest&&(h+="float dAlpha;\n",h+=this._addMap("opacity","opacityPS",b,m),h+=m.alphaTestPS);e!==pc.SHADOW_PCF3||f.webgl2&&r!==pc.LIGHTTYPE_POINT?e===pc.SHADOW_VSM8&&(h+="vec2 encodeFloatRG( float v ) {\n",h+=" vec2 enc = vec2(1.0, 255.0) * v;\n",h+=" enc = fract(enc);\n",h+=" enc -= enc.yy * vec2(1.0/255.0, 1.0/255.0);\n", h+=" return enc;\n",h+="}\n\n"):h+=m.packDepthPS;h+=pc.programlib.begin();b.alphaTest&&(h+=" getOpacity();\n",h+=" alphaTest(dAlpha);\n");var D=e===pc.SHADOW_VSM8||e===pc.SHADOW_VSM16||e===pc.SHADOW_VSM32,h=r===pc.LIGHTTYPE_POINT||D&&r!==pc.LIGHTTYPE_DIRECTIONAL?h+" float depth = min(distance(view_position, vPositionW) / light_radius, 0.99999);\n":h+" float depth = gl_FragCoord.z;\n";e!==pc.SHADOW_PCF3||f.webgl2&&r!==pc.LIGHTTYPE_POINT?h=e===pc.SHADOW_PCF3||e===pc.SHADOW_PCF5?h+" gl_FragColor = vec4(1.0);\n": e===pc.SHADOW_VSM8?h+" gl_FragColor = vec4(encodeFloatRG(depth), encodeFloatRG(depth*depth));\n":h+m.storeEVSMPS:(f.extStandardDerivatives&&!f.webgl2&&(h+=" float minValue = 2.3374370500153186e-10; //(1.0 / 255.0) / (256.0 * 256.0 * 256.0);\n",h+=" depth += polygonOffset.x * max(abs(dFdx(depth)), abs(dFdy(depth))) + minValue * polygonOffset.y;\n"),h+=" gl_FragColor = packFloat(depth);\n");h+=pc.programlib.end();return{attributes:t,vshader:c,fshader:h}}if(b.customFragmentShader)return h+=b.customFragmentShader, {attributes:t,vshader:c,fshader:h,tag:pc.SHADERTAG_MATERIAL};q=h=this._fsAddBaseCode(h+q,f,m,b);h="";y=0;w=[];u=x=!1;for(a=0;a 0.00001) {\n",r!==pc.LIGHTTYPE_SPOT||g&&!n._cookieFalloff||(h+=" dAtten *= getSpotEffect(light"+a+"_direction, light"+a+"_innerConeAngle, light"+a+"_outerConeAngle);\n",x=!0)),h+=" dAtten *= getLightDiffuse();\n", n.castShadows&&!b.noShadow&&(n._shadowType===pc.SHADOW_VSM8?(k="VSM8",D="0.0"):n._shadowType===pc.SHADOW_VSM16?(k="VSM16",D="5.54"):n._shadowType===pc.SHADOW_VSM32?(k="VSM32",D=f.textureFloatHighPrecision?"15.0":"5.54"):k=n._shadowType===pc.SHADOW_PCF5?"PCF5x5":"PCF3x3",null!==k&&(r===pc.LIGHTTYPE_POINT?(d="(light"+a+"_shadowMap, light"+a+"_shadowParams);\n",n._normalOffsetBias&&(h+=" normalOffsetPointShadow(light"+a+"_shadowParams);\n"),h+=" dAtten *= getShadowPoint"+k+d):(v===a?k+="VS": (d="(light"+a+"_shadowMatrix, light"+a+"_shadowParams);\n",h+=this._nonPointShadowMapProjection(f,b.lights[a],d)),r===pc.LIGHTTYPE_SPOT&&(k="Spot"+k),h+=" dAtten *= getShadow"+k+"(light"+a+"_shadowMap, light"+a+"_shadowParams"+(n._isVsm?", "+D:"")+");\n"))),h+=" dDiffuseLight += dAtten * light"+a+"_color"+(g?" * dAtten3":"")+";\n",b.useSpecular&&(h+=" dAtten *= getLightSpecular();\n",h+=" dSpecularLight += dAtten * light"+a+"_color"+(g?" * dAtten3":"")+";\n"),r!==pc.LIGHTTYPE_DIRECTIONAL&& (h+=" }\n"),h+="\n";(e||b.sphereMap||b.dpAtlas)&&b.refraction&&(h+=" addRefraction();\n")}h+="\n";p&&(b.occludeDirect&&(h+=" applyAO();\n"),b.occludeSpecular&&(h+=" occludeSpecular();\n"));h+=m.endPS;h=b.blendType===pc.BLEND_NORMAL||b.blendType===pc.BLEND_ADDITIVEALPHA||b.alphaToCoverage?h+m.outputAlphaPS:b.blendType===pc.BLEND_PREMULTIPLIED?h+m.outputAlphaPremulPS:h+m.outputAlphaOpaquePS;b.msdf&&(h+=" gl_FragColor = applyMsdf(gl_FragColor);\n");h+="\n";h+=pc.programlib.end();l&&(h=m.lightDirPointPS+ h);y&&(h=m.falloffLinearPS+h);w&&(h=m.falloffInvSquaredPS+h);x&&(h=m.spotPS+h);u&&(h=m.cookiePS+h);m="";h.includes("dReflection")&&(m+="vec4 dReflection;\n");h.includes("dTBN")&&(m+="mat3 dTBN;\n");h.includes("dAlbedo")&&(m+="vec3 dAlbedo;\n");h.includes("dEmission")&&(m+="vec3 dEmission;\n");h.includes("dNormalW")&&(m+="vec3 dNormalW;\n");h.includes("dVertexNormalW")&&(m+="vec3 dVertexNormalW;\n");h.includes("dTangentW")&&(m+="vec3 dTangentW;\n");h.includes("dBinormalW")&&(m+="vec3 dBinormalW;\n"); h.includes("dViewDirW")&&(m+="vec3 dViewDirW;\n");h.includes("dReflDirW")&&(m+="vec3 dReflDirW;\n");h.includes("dDiffuseLight")&&(m+="vec3 dDiffuseLight;\n");h.includes("dSpecularLight")&&(m+="vec3 dSpecularLight;\n");h.includes("dLightDirNormW")&&(m+="vec3 dLightDirNormW;\n");h.includes("dLightDirW")&&(m+="vec3 dLightDirW;\n");h.includes("dLightPosW")&&(m+="vec3 dLightPosW;\n");h.includes("dShadowCoord")&&(m+="vec3 dShadowCoord;\n");h.includes("dNormalMap")&&(m+="vec3 dNormalMap;\n");h.includes("dSpecularity")&& (m+="vec3 dSpecularity;\n");h.includes("dUvOffset")&&(m+="vec2 dUvOffset;\n");h.includes("dGlossiness")&&(m+="float dGlossiness;\n");h.includes("dAlpha")&&(m+="float dAlpha;\n");h.includes("dAtten")&&(m+="float dAtten;\n");h.includes("dAtten3")&&(m+="vec3 dAtten3;\n");h.includes("dAo")&&(m+="float dAo;\n");h.includes("dMsdf")&&(m+="vec4 dMsdf;\n");h=q+m+h;return{attributes:t,vshader:c,fshader:h,tag:pc.SHADERTAG_MATERIAL}}};pc.programlib.skybox={generateKey:function(f){return"skybox"+f.rgbm+" "+f.hdr+" "+f.fixSeams+""+f.toneMapping+""+f.gamma+""+f.useIntensity+""+f.mip},createShaderDefinition:function(f,b){var a=pc.shaderChunks;return{attributes:{aPosition:pc.SEMANTIC_POSITION},vshader:a.skyboxVS,fshader:pc.programlib.precisionCode(f)+(b.mip?a.fixCubemapSeamsStretchPS:a.fixCubemapSeamsNonePS)+(b.useIntensity?a.envMultiplyPS:a.envConstPS)+pc.programlib.gammaCode(b.gamma)+pc.programlib.tonemapCode(b.toneMapping)+a.rgbmPS+ a.skyboxHDRPS.replace(/\$textureCubeSAMPLE/g,b.rgbm?"textureCubeRGBM":b.hdr?"textureCube":"textureCubeSRGB").replace(/\$FIXCONST/g,1-1/[128,64,16,8,4,2][b.mip]+"")}}};Object.assign(pc,function(){var f={type:pc.PRIMITIVE_TRISTRIP,base:0,count:4,indexed:!1},b=function(a){this.device=a;this.depthMap=this.shader=null;this.vertexBuffer=pc.createFullscreenQuad(a);this.needsDepthBuffer=!1};Object.assign(b.prototype,{render:function(a,b,d){}});return{PostEffect:b,createFullscreenQuad:function(a){var b=new pc.VertexFormat(a,[{semantic:pc.SEMANTIC_POSITION,components:2,type:pc.TYPE_FLOAT32}]);a=new pc.VertexBuffer(a,b,4);b=new pc.VertexIterator(a);b.element[pc.SEMANTIC_POSITION].set(-1, -1);b.next();b.element[pc.SEMANTIC_POSITION].set(1,-1);b.next();b.element[pc.SEMANTIC_POSITION].set(-1,1);b.next();b.element[pc.SEMANTIC_POSITION].set(1,1);b.end();return a},drawFullscreenQuad:function(a,b,d,e,g){var c=a.getRenderTarget();a.setRenderTarget(b);a.updateBegin();var k=null!==b?b.width:a.width,p=null!==b?b.height:a.height,h=0,n=0;g&&(h=g.x*k,n=g.y*p,k*=g.z,p*=g.w);g=a.vx;b=a.vy;var q=a.vw,m=a.vh;a.setViewport(h,n,k,p);var r=a.sx,t=a.sy,v=a.sw,y=a.sh;a.setScissor(h,n,k,p);var k=a.getBlending(), p=a.getDepthTest(),h=a.getDepthWrite(),n=a.getCullMode(),u=a.writeRed,w=a.writeGreen,x=a.writeBlue,D=a.writeAlpha;a.setBlending(!1);a.setDepthTest(!1);a.setDepthWrite(!1);a.setCullMode(pc.CULLFACE_NONE);a.setColorWrite(!0,!0,!0,!0);a.setVertexBuffer(d,0);a.setShader(e);a.draw(f);a.setBlending(k);a.setDepthTest(p);a.setDepthWrite(h);a.setCullMode(n);a.setColorWrite(u,w,x,D);a.updateEnd();a.setRenderTarget(c);a.updateBegin();a.setViewport(g,b,q,m);a.setScissor(r,t,v,y)}}}());(function(){var f={BLEND_SUBTRACTIVE:0,BLEND_ADDITIVE:1,BLEND_NORMAL:2,BLEND_NONE:3,BLEND_PREMULTIPLIED:4,BLEND_MULTIPLICATIVE:5,BLEND_ADDITIVEALPHA:6,BLEND_MULTIPLICATIVE2X:7,BLEND_SCREEN:8,BLEND_MIN:9,BLEND_MAX:10,FOG_NONE:"none",FOG_LINEAR:"linear",FOG_EXP:"exp",FOG_EXP2:"exp2",FRESNEL_NONE:0,FRESNEL_SCHLICK:2,LAYER_HUD:0,LAYER_GIZMO:1,LAYER_FX:2,LAYER_WORLD:15,LAYERID_WORLD:0,LAYERID_DEPTH:1,LAYERID_SKYBOX:2,LAYERID_IMMEDIATE:3,LAYERID_UI:4,LIGHTTYPE_DIRECTIONAL:0,LIGHTTYPE_POINT:1,LIGHTTYPE_SPOT:2, LIGHTFALLOFF_LINEAR:0,LIGHTFALLOFF_INVERSESQUARED:1,SHADOW_PCF3:0,SHADOW_DEPTH:0,SHADOW_VSM8:1,SHADOW_VSM16:2,SHADOW_VSM32:3,SHADOW_PCF5:4,BLUR_BOX:0,BLUR_GAUSSIAN:1,PARTICLESORT_NONE:0,PARTICLESORT_DISTANCE:1,PARTICLESORT_NEWER_FIRST:2,PARTICLESORT_OLDER_FIRST:3,PARTICLEMODE_GPU:0,PARTICLEMODE_CPU:1,EMITTERSHAPE_BOX:0,EMITTERSHAPE_SPHERE:1,PROJECTION_PERSPECTIVE:0,PROJECTION_ORTHOGRAPHIC:1,RENDERSTYLE_SOLID:0,RENDERSTYLE_WIREFRAME:1,RENDERSTYLE_POINTS:2,CUBEPROJ_NONE:0,CUBEPROJ_BOX:1,SPECULAR_PHONG:0, SPECULAR_BLINN:1,GAMMA_NONE:0,GAMMA_SRGB:1,GAMMA_SRGBFAST:2,GAMMA_SRGBHDR:3,TONEMAP_LINEAR:0,TONEMAP_FILMIC:1,TONEMAP_HEJL:2,TONEMAP_ACES:3,TONEMAP_ACES2:4,SPECOCC_NONE:0,SPECOCC_AO:1,SPECOCC_GLOSSDEPENDENT:2,SHADERDEF_NOSHADOW:1,SHADERDEF_SKIN:2,SHADERDEF_UV0:4,SHADERDEF_UV1:8,SHADERDEF_VCOLOR:16,SHADERDEF_INSTANCING:32,SHADERDEF_LM:64,SHADERDEF_DIRLM:128,SHADERDEF_SCREENSPACE:256,SHADERDEF_TANGENTS:512,LINEBATCH_WORLD:0,LINEBATCH_OVERLAY:1,LINEBATCH_GIZMO:2,SHADOWUPDATE_NONE:0,SHADOWUPDATE_THISFRAME:1, SHADOWUPDATE_REALTIME:2,SORTKEY_FORWARD:0,SORTKEY_DEPTH:1,MASK_DYNAMIC:1,MASK_BAKED:2,MASK_LIGHTMAP:4,SHADER_FORWARD:0,SHADER_FORWARDHDR:1,SHADER_DEPTH:2,SHADER_SHADOW:3,SHADER_PICK:18,BAKE_COLOR:0,BAKE_COLORDIR:1,VIEW_CENTER:0,VIEW_LEFT:1,VIEW_RIGHT:2,SORTMODE_NONE:0,SORTMODE_MANUAL:1,SORTMODE_MATERIALMESH:2,SORTMODE_BACK2FRONT:3,SORTMODE_FRONT2BACK:4,SORTMODE_CUSTOM:5,COMPUPDATED_INSTANCES:1,COMPUPDATED_LIGHTS:2,COMPUPDATED_CAMERAS:4,COMPUPDATED_BLEND:8,ASPECT_AUTO:0,ASPECT_MANUAL:1,ORIENTATION_HORIZONTAL:0, ORIENTATION_VERTICAL:1};Object.assign(pc,f);pc.scene={};Object.assign(pc.scene,f)})(); Object.assign(pc,function(){var f=function(){this.root=null;this._gravity=new pc.Vec3(0,-9.8,0);this._layers=null;this._fog=pc.FOG_NONE;this.fogColor=new pc.Color(0,0,0);this.fogStart=1;this.fogEnd=1E3;this.fogDensity=0;this.ambientLight=new pc.Color(0,0,0);this._gammaCorrection=pc.GAMMA_NONE;this._toneMapping=0;this.exposure=1;this._skyboxPrefiltered=[null,null,null,null,null,null];this.skyboxModel=this._skyboxCubeMap=null;this._skyboxIntensity=1;this._skyboxMip=0;this.lightmapSizeMultiplier=1;this.lightmapMaxResolution= 2048;this.lightmapMode=pc.BAKE_COLORDIR;this._stats={meshInstances:0,lights:0,dynamicLights:0,bakedLights:0,lastStaticPrepareFullTime:0,lastStaticPrepareSearchTime:0,lastStaticPrepareWriteTime:0,lastStaticPrepareTriAabbTime:0,lastStaticPrepareCombineTime:0,updateShadersTime:0};this.updateSkybox=this.updateShaders=!0;this._shaderVersion=0;this._statsUpdated=!1;this._models=[];this.defaultMaterial=new pc.StandardMaterial;this.defaultMaterial.name="Default Material";this.defaultMaterial.shadingModel= pc.SPECULAR_BLINN;pc.events.attach(this)};f.prototype.destroy=function(){this.root=null;this.defaultMaterial.destroy();this.defaultMaterial=null;this.off()};Object.defineProperty(f.prototype,"fog",{get:function(){return this._fog},set:function(b){b!==this._fog&&(this._fog=b,this.updateShaders=!0)}});Object.defineProperty(f.prototype,"gammaCorrection",{get:function(){return this._gammaCorrection},set:function(b){b!==this._gammaCorrection&&(this._gammaCorrection=b,this.updateShaders=!0)}});Object.defineProperty(f.prototype, "toneMapping",{get:function(){return this._toneMapping},set:function(b){b!==this._toneMapping&&(this._toneMapping=b,this.updateShaders=!0)}});Object.defineProperty(f.prototype,"skybox",{get:function(){return this._skyboxCubeMap},set:function(b){this._skyboxCubeMap=b;this._resetSkyboxModel();this.updateShaders=!0}});Object.defineProperty(f.prototype,"skyboxIntensity",{get:function(){return this._skyboxIntensity},set:function(b){this._skyboxIntensity=b;this._resetSkyboxModel();this.updateShaders=!0}}); Object.defineProperty(f.prototype,"skyboxMip",{get:function(){return this._skyboxMip},set:function(b){this._skyboxMip=b;this._resetSkyboxModel();this.updateShaders=!0}});Object.defineProperty(f.prototype,"skyboxPrefiltered128",{get:function(){return this._skyboxPrefiltered[0]},set:function(b){this._skyboxPrefiltered[0]!==b&&(this._skyboxPrefiltered[0]=b,this.updateShaders=!0)}});Object.defineProperty(f.prototype,"skyboxPrefiltered64",{get:function(){return this._skyboxPrefiltered[1]},set:function(b){this._skyboxPrefiltered[1]!== b&&(this._skyboxPrefiltered[1]=b,this.updateShaders=!0)}});Object.defineProperty(f.prototype,"skyboxPrefiltered32",{get:function(){return this._skyboxPrefiltered[2]},set:function(b){this._skyboxPrefiltered[2]!==b&&(this._skyboxPrefiltered[2]=b,this.updateShaders=!0)}});Object.defineProperty(f.prototype,"skyboxPrefiltered16",{get:function(){return this._skyboxPrefiltered[3]},set:function(b){this._skyboxPrefiltered[3]!==b&&(this._skyboxPrefiltered[3]=b,this.updateShaders=!0)}});Object.defineProperty(f.prototype, "skyboxPrefiltered8",{get:function(){return this._skyboxPrefiltered[4]},set:function(b){this._skyboxPrefiltered[4]!==b&&(this._skyboxPrefiltered[4]=b,this.updateShaders=!0)}});Object.defineProperty(f.prototype,"skyboxPrefiltered4",{get:function(){return this._skyboxPrefiltered[5]},set:function(b){this._skyboxPrefiltered[5]!==b&&(this._skyboxPrefiltered[5]=b,this.updateShaders=!0)}});Object.defineProperty(f.prototype,"drawCalls",{get:function(){var b=this.layers._meshInstances;b.length||(this.layers._update(), b=this.layers._meshInstances);return b},set:function(b){}});Object.defineProperty(f.prototype,"layers",{get:function(){return this._layers},set:function(b){var a=this._layers;this._layers=b;this.fire("set:layers",a,b)}});f.prototype.applySettings=function(b){this._gravity.set(b.physics.gravity[0],b.physics.gravity[1],b.physics.gravity[2]);this.ambientLight.set(b.render.global_ambient[0],b.render.global_ambient[1],b.render.global_ambient[2]);this._fog=b.render.fog;this.fogColor.set(b.render.fog_color[0], b.render.fog_color[1],b.render.fog_color[2]);this.fogStart=b.render.fog_start;this.fogEnd=b.render.fog_end;this.fogDensity=b.render.fog_density;this._gammaCorrection=b.render.gamma_correction;this._toneMapping=b.render.tonemapping;this.lightmapSizeMultiplier=b.render.lightmapSizeMultiplier;this.lightmapMaxResolution=b.render.lightmapMaxResolution;this.lightmapMode=b.render.lightmapMode;this.exposure=b.render.exposure;this._skyboxIntensity=void 0===b.render.skyboxIntensity?1:b.render.skyboxIntensity; this._skyboxMip=void 0===b.render.skyboxMip?0:b.render.skyboxMip;this._resetSkyboxModel();this.updateShaders=!0};f.prototype._updateSkybox=function(b){if(this._skyboxCubeMap&&!this.skyboxModel){var a=new pc.Material,c=this;a.updateShader=function(a,d,e,g,l){this.shader=b.getProgramLibrary().getProgram("skybox",{rgbm:c._skyboxCubeMap.rgbm,hdr:c._skyboxCubeMap.rgbm||c._skyboxCubeMap.format===pc.PIXELFORMAT_RGBA32F,useIntensity:1!==c.skyboxIntensity,mip:c._skyboxCubeMap.fixCubemapSeams?c.skyboxMip:0, fixSeams:c._skyboxCubeMap.fixCubemapSeams,gamma:l===pc.SHADER_FORWARDHDR?c.gammaCorrection?pc.GAMMA_SRGBHDR:pc.GAMMA_NONE:c.gammaCorrection,toneMapping:l===pc.SHADER_FORWARDHDR?pc.TONEMAP_LINEAR:c.toneMapping})};a.updateShader();var d;if(this._skyboxCubeMap.fixCubemapSeams&&c._skyboxMip){var e=this["skyboxPrefiltered"+[null,"64","16","8","4"][c._skyboxMip]];e&&(d=e)}else d=this._skyboxCubeMap;a.setParameter("texture_cubeMap",d);a.cull=pc.CULLFACE_NONE;if(e=this.layers.getLayerById(pc.LAYERID_SKYBOX)){var g= new pc.GraphNode,l=pc.createBox(b),a=new pc.MeshInstance(g,l,a);a.cull=!1;a._noDepthDrawGl1=!0;l=new pc.Model;l.graph=g;l.meshInstances=[a];this.skyboxModel=l;e.addMeshInstances(l.meshInstances);e.enabled=!0;this.skyLayer=e;this.fire("set:skybox",d)}}};f.prototype._resetSkyboxModel=function(){this.skyboxModel&&(this.skyLayer.removeMeshInstances(this.skyboxModel.meshInstances),this.skyLayer.enabled=!1);this.skyboxModel=null;this.updateSkybox=!0};f.prototype.setSkybox=function(b){var a;b||(b=[null, null,null,null,null,null,null]);var c=!1;this._skyboxCubeMap!==b[0]&&(c=!0);if(!c)for(a=0;6>a&&!c;a++)this._skyboxPrefiltered[a]!==b[a+1]&&(c=!0);if(c){for(a=0;6>a;a++)this._skyboxPrefiltered[a]=b[a+1];this.skybox=b[0]}};f.prototype.destroy=function(){this.skybox=null};f.prototype.addModel=function(b){if(!this.containsModel(b)){var a=this.layers.getLayerById(pc.LAYERID_WORLD);a&&(a.addMeshInstances(b.meshInstances),this._models.push(b))}};f.prototype.addShadowCaster=function(b){var a=this.layers.getLayerById(pc.LAYERID_WORLD); a&&a.addShadowCasters(b.meshInstances)};f.prototype.removeModel=function(b){var a=this._models.indexOf(b);if(-1!==a){var c=this.layers.getLayerById(pc.LAYERID_WORLD);c&&(c.removeMeshInstances(b.meshInstances),this._models.splice(a,1))}};f.prototype.removeShadowCasters=function(b){var a=this.layers.getLayerById(pc.LAYERID_WORLD);a&&a.removeShadowCasters(b.meshInstances)};f.prototype.containsModel=function(b){return 0<=this._models.indexOf(b)};f.prototype.getModels=function(b){return this._models}; return{Scene:f}}());Object.assign(pc,function(){function f(a,b){if(b!==pc.SHADOW_PCF3||a.webgl2){if(b===pc.SHADOW_VSM32)return a.extTextureFloatLinear?pc.FILTER_LINEAR:pc.FILTER_NEAREST;if(b===pc.SHADOW_VSM16)return a.extTextureHalfFloatLinear?pc.FILTER_LINEAR:pc.FILTER_NEAREST}else return pc.FILTER_NEAREST;return pc.FILTER_LINEAR}function b(a,b,c,d){var e=d===pc.SHADOW_VSM32?pc.PIXELFORMAT_RGBA32F:d===pc.SHADOW_VSM16?pc.PIXELFORMAT_RGBA16F:d===pc.SHADOW_PCF5||d===pc.SHADOW_PCF3&&a.webgl2?pc.PIXELFORMAT_DEPTH:pc.PIXELFORMAT_R8_G8_B8_A8, g=f(a,d);b=new pc.Texture(a,{format:e,width:b,height:c,mipmaps:!1,minFilter:g,magFilter:g,addressU:pc.ADDRESS_CLAMP_TO_EDGE,addressV:pc.ADDRESS_CLAMP_TO_EDGE});b.name="shadowmap";return d===pc.SHADOW_PCF5||d===pc.SHADOW_PCF3&&a.webgl2?(b.compareOnRead=!0,b.compareFunc=pc.FUNC_LESS,new pc.RenderTarget({depthBuffer:b})):new pc.RenderTarget({colorBuffer:b,depth:!0})}function a(a,b){var c=new pc.Texture(a,{format:pc.PIXELFORMAT_R8_G8_B8_A8,width:b,height:b,cubemap:!0,mipmaps:!1,minFilter:pc.FILTER_NEAREST, magFilter:pc.FILTER_NEAREST,addressU:pc.ADDRESS_CLAMP_TO_EDGE,addressV:pc.ADDRESS_CLAMP_TO_EDGE});c.name="shadowcube";for(var d=[],e,g=0;6>g;g++)e=new pc.RenderTarget({colorBuffer:c,face:g,depth:!0}),d.push(e);return d}function c(a){25pc.SHADOW_PCF3&&(e._shadowType=pc.SHADOW_PCF3),e._cacheShadowMap?(g=O[e._shadowResolution],g||(g=a(c,e._shadowResolution),O[e._shadowResolution]=g)):g=a(c,e._shadowResolution),e._shadowCamera.renderTarget=g[0],e._shadowCubeMap=g):(g=e._cacheShadowMap?d(c,e._shadowResolution,e._shadowType):b(c,e._shadowResolution,e._shadowResolution,e._shadowType),e._shadowCamera.renderTarget=g);e._isCachedShadowMap=e._cacheShadowMap}function g(a){a=this.device= a;this._instancingTime=this._morphTime=this._skinTime=this._sortTime=this._cullTime=this._forwardTime=this._depthMapTime=this._shadowMapTime=this._shadowMapUpdates=this._materialSwitches=this._camerasRendered=this._skinDrawCalls=this._forwardDrawCalls=this._shadowDrawCalls=0;this.library=a.getProgramLibrary();a=a.scope;this.projId=a.resolve("matrix_projection");this.viewId=a.resolve("matrix_view");this.viewId3=a.resolve("matrix_view3");this.viewInvId=a.resolve("matrix_viewInverse");this.viewProjId= a.resolve("matrix_viewProjection");this.viewPos=new Float32Array(3);this.viewPosId=a.resolve("view_position");this.nearClipId=a.resolve("camera_near");this.farClipId=a.resolve("camera_far");this.cameraParamsId=a.resolve("camera_params");this.shadowMapLightRadiusId=a.resolve("light_radius");this.fogColorId=a.resolve("fog_color");this.fogStartId=a.resolve("fog_start");this.fogEndId=a.resolve("fog_end");this.fogDensityId=a.resolve("fog_density");this.modelMatrixId=a.resolve("matrix_model");this.normalMatrixId= a.resolve("matrix_normal");this.poseMatrixId=a.resolve("matrix_pose[0]");this.boneTextureId=a.resolve("texture_poseMap");this.boneTextureSizeId=a.resolve("texture_poseMapSize");this.alphaTestId=a.resolve("alpha_ref");this.opacityMapId=a.resolve("texture_opacityMap");this.ambientId=a.resolve("light_globalAmbient");this.exposureId=a.resolve("exposure");this.skyboxIntensityId=a.resolve("skyboxIntensity");this.lightColorId=[];this.lightDir=[];this.lightDirId=[];this.lightShadowMapId=[];this.lightShadowMatrixId= [];this.lightShadowParamsId=[];this.lightShadowMatrixVsId=[];this.lightShadowParamsVsId=[];this.lightDirVs=[];this.lightDirVsId=[];this.lightRadiusId=[];this.lightPos=[];this.lightPosId=[];this.lightInAngleId=[];this.lightOutAngleId=[];this.lightPosVsId=[];this.lightCookieId=[];this.lightCookieIntId=[];this.lightCookieMatrixId=[];this.lightCookieOffsetId=[];this.depthMapId=a.resolve("uDepthMap");this.screenSizeId=a.resolve("uScreenSize");this._screenSize=new Float32Array(4);this.sourceId=a.resolve("source"); this.pixelOffsetId=a.resolve("pixelOffset");this.weightId=a.resolve("weight[0]");var b=pc.shaderChunks;this.blurVsmShaderCode=[b.blurVSMPS,"#define GAUSS\n"+b.blurVSMPS];this.blurPackedVsmShaderCode=["#define PACKED\n"+this.blurVsmShaderCode[0],"#define PACKED\n"+this.blurVsmShaderCode[1]];this.blurVsmShader=[{},{}];this.blurPackedVsmShader=[{},{}];this.blurVsmWeights={};this.polygonOffsetId=a.resolve("polygonOffset");this.polygonOffset=new Float32Array(2);this.fogColor=new Float32Array(3);this.ambientColor= new Float32Array(3)}function l(a,b){a.data[0]=b.data[0];a.data[1]=b.data[1];a.data[2]=b.data[2];a.data[3]=b.data[4];a.data[4]=b.data[5];a.data[5]=b.data[6];a.data[6]=b.data[8];a.data[7]=b.data[9];a.data[8]=b.data[10]}for(var k=(new pc.Mat4).mul2((new pc.Mat4).setTranslate(.5,.5,.5),(new pc.Mat4).setScale(.5,.5,.5)),p={r:1,g:2,b:3,a:4},h=[(new pc.Quat).setFromEulerAngles(0,90,180),(new pc.Quat).setFromEulerAngles(0,-90,180),(new pc.Quat).setFromEulerAngles(90,0,0),(new pc.Quat).setFromEulerAngles(-90, 0,0),(new pc.Quat).setFromEulerAngles(0,180,180),(new pc.Quat).setFromEulerAngles(0,0,180)],n=[{},{},{},{},{}],q=new Float32Array(2),m={x:1,y:1,z:0,w:0},r=new pc.Mat4,t=new pc.Mat4,v=new pc.Mat4,y=new pc.Mat4,u=new pc.Mat4,w=new pc.Mat3,x=new pc.Mat4,D,z=new pc.Mat4,C=new pc.Mat4,A=new pc.Mat4,B=new pc.Mat4,J=new pc.Vec3,F=new pc.Vec3,H,E,G=new pc.Mat4,I=new pc.Mat4,Q=new pc.Mat4,V=new pc.Mat4,W=new pc.Vec3,U={center:null,radius:0},Z,T=new pc.BoundingBox,L=[0,0],R,P,K,da,O={},S,aa,N=[],ba=0;8>ba;ba++)N.push(new pc.Vec3); var M=[new pc.Vec3,new pc.Vec3,new pc.Vec3,new pc.Vec3,new pc.Vec3,new pc.Vec3,new pc.Vec3,new pc.Vec3];Object.assign(g.prototype,{sortCompare:function(a,b){if(a.layer===b.layer){if(a.drawOrder&&b.drawOrder)return a.drawOrder-b.drawOrder;if(a.zdist&&b.zdist)return b.zdist-a.zdist;if(a.zdist2&&b.zdist2)return a.zdist2-b.zdist2}return b._key[pc.SORTKEY_FORWARD]-a._key[pc.SORTKEY_FORWARD]},sortCompareMesh:function(a,b){if(a.layer===b.layer){if(a.drawOrder&&b.drawOrder)return a.drawOrder-b.drawOrder; if(a.zdist&&b.zdist)return b.zdist-a.zdist}S=a._key[pc.SORTKEY_FORWARD];aa=b._key[pc.SORTKEY_FORWARD];return S===aa&&a.mesh&&b.mesh?b.mesh.id-a.mesh.id:aa-S},depthSortCompare:function(a,b){S=a._key[pc.SORTKEY_DEPTH];aa=b._key[pc.SORTKEY_DEPTH];return S===aa&&a.mesh&&b.mesh?b.mesh.id-a.mesh.id:aa-S},lightCompare:function(a,b){return a.key-b.key},_isVisible:function(a,b){if(!b.visible)return!1;if(b.isVisibleFunc)return b.isVisibleFunc(a);Z=b.aabb.center;b._aabb._radiusVer!==b._aabbVer&&(b._aabb._radius= b._aabb.halfExtents.length(),b._aabb._radiusVer=b._aabbVer);U.radius=b._aabb._radius;U.center=Z;return a.frustum.containsSphere(U)},getShadowCamera:function(a,b){var c=b._shadowCamera,d;if(null===c){c=b._shadowType;d=pc.CLEARFLAG_DEPTH;var g=c===pc.SHADOW_PCF5||c===pc.SHADOW_PCF3&&a.webgl2;b._type===pc.LIGHTTYPE_POINT&&(g=!1);g||(d|=pc.CLEARFLAG_COLOR);g=new pc.Camera;c>=pc.SHADOW_VSM8&&c<=pc.SHADOW_VSM32?(g.clearColor[0]=0,g.clearColor[1]=0,g.clearColor[2]=0,g.clearColor[3]=0):(g.clearColor[0]=1, g.clearColor[1]=1,g.clearColor[2]=1,g.clearColor[3]=1);g.clearDepth=1;g.clearFlags=d;g.clearStencil=null;g._node=new pc.GraphNode;c=b._shadowCamera=g;e(a,b)}else d=c.renderTarget,d.width===b._shadowResolution&&d.height===b._shadowResolution||e(a,b);return c},updateCameraFrustum:function(a){if(a.vrDisplay&&a.vrDisplay.presenting){D=a.vrDisplay.combinedProj;var b=a._node.getParent();b?u.copy(b.getWorldTransform()).mul(a.vrDisplay.combinedViewInv).invert():u.copy(a.vrDisplay.combinedView);y.copy(u).invert(); this.viewInvId.setValue(y.data)}else{D=a.getProjectionMatrix();a.overrideCalculateProjection&&a.calculateProjection(D,pc.VIEW_CENTER);if(a.overrideCalculateTransform)a.calculateTransform(y,pc.VIEW_CENTER);else{var b=a._node.getPosition(),c=a._node.getRotation();y.setTRS(b,c,pc.Vec3.ONE);this.viewInvId.setValue(y.data)}u.copy(y).invert()}a.frustum.update(D,u)},setCamera:function(a,b,c,d){var e=a.vrDisplay;if(e&&e.presenting){H=e.leftProj;E=e.rightProj;D=e.combinedProj;a.overrideCalculateProjection&& (a.calculateProjection(H,pc.VIEW_LEFT),a.calculateProjection(E,pc.VIEW_RIGHT),a.calculateProjection(D,pc.VIEW_CENTER));if(a.overrideCalculateTransform)a.calculateTransform(z,pc.VIEW_LEFT),a.calculateTransform(C,pc.VIEW_RIGHT),a.calculateTransform(y,pc.VIEW_CENTER),A.copy(z).invert(),B.copy(C).invert(),u.copy(y).invert();else{var g=a._node.getParent();if(g){var k=g.getWorldTransform();z.mul2(k,e.leftViewInv);C.mul2(k,e.rightViewInv);A.copy(z).invert();B.copy(C).invert();u.copy(g.getWorldTransform()).mul(e.combinedViewInv).invert()}else z.copy(e.leftViewInv), C.copy(e.rightViewInv),A.copy(e.leftView),B.copy(e.rightView),u.copy(e.combinedView)}l(G,A);l(I,B);Q.mul2(H,A);V.mul2(E,B);J.x=z.data[12];J.y=z.data[13];J.z=z.data[14];F.x=C.data[12];F.y=C.data[13];F.z=C.data[14]}else D=a.getProjectionMatrix(),a.overrideCalculateProjection&&a.calculateProjection(D,pc.VIEW_CENTER),this.projId.setValue(D.data),a.overrideCalculateTransform?a.calculateTransform(y,pc.VIEW_CENTER):(e=a._node.getPosition(),g=a._node.getRotation(),y.setTRS(e,g,pc.Vec3.ONE)),this.viewInvId.setValue(y.data), u.copy(y).invert(),this.viewId.setValue(u.data),l(w,u),this.viewId3.setValue(w.data),x.mul2(D,u),this.viewProjId.setValue(x.data),e=a._node.getPosition(),this.viewPos[0]=e.x,this.viewPos[1]=e.y,this.viewPos[2]=e.z,this.viewPosId.setValue(this.viewPos);a.frustum.update(D,u);this.nearClipId.setValue(a._nearClip);this.farClipId.setValue(a._farClip);this.cameraParamsId.setValue(a._shaderParams);e=this.device;e.setRenderTarget(b);e.updateBegin();k=a.getRect();g=b?b.width:e.width;b=b?b.height:e.height; var f=Math.floor(k.x*g),h=Math.floor(k.y*b),p=Math.floor(k.width*g),k=Math.floor(k.height*b);e.setViewport(f,h,p,k);e.setScissor(f,h,p,k);c&&e.clear(a._clearOptions);k=a._scissorRect;f=Math.floor(k.x*g);h=Math.floor(k.y*b);p=Math.floor(k.width*g);k=Math.floor(k.height*b);e.setScissor(f,h,p,k);d&&e.setScissor(1,1,g-2,b-2)},dispatchGlobalLights:function(a){var b;this.mainLight=-1;this.ambientColor[0]=a.ambientLight.r;this.ambientColor[1]=a.ambientLight.g;this.ambientColor[2]=a.ambientLight.b;if(a.gammaCorrection)for(b= 0;3>b;b++)this.ambientColor[b]=Math.pow(this.ambientColor[b],2.2);this.ambientId.setValue(this.ambientColor);this.exposureId.setValue(a.exposure);a.skyboxModel&&this.skyboxIntensityId.setValue(a.skyboxIntensity)},_resolveLight:function(a,b){var c="light"+b;this.lightColorId[b]=a.resolve(c+"_color");this.lightDir[b]=new Float32Array(3);this.lightDirId[b]=a.resolve(c+"_direction");this.lightShadowMapId[b]=a.resolve(c+"_shadowMap");this.lightShadowMatrixId[b]=a.resolve(c+"_shadowMatrix");this.lightShadowParamsId[b]= a.resolve(c+"_shadowParams");this.lightShadowMatrixVsId[b]=a.resolve(c+"_shadowMatrixVS");this.lightShadowParamsVsId[b]=a.resolve(c+"_shadowParamsVS");this.lightDirVs[b]=new Float32Array(3);this.lightDirVsId[b]=a.resolve(c+"_directionVS");this.lightRadiusId[b]=a.resolve(c+"_radius");this.lightPos[b]=new Float32Array(3);this.lightPosId[b]=a.resolve(c+"_position");this.lightInAngleId[b]=a.resolve(c+"_innerConeAngle");this.lightOutAngleId[b]=a.resolve(c+"_outerConeAngle");this.lightPosVsId[b]=a.resolve(c+ "_positionVS");this.lightCookieId[b]=a.resolve(c+"_cookie");this.lightCookieIntId[b]=a.resolve(c+"_cookieIntensity");this.lightCookieMatrixId[b]=a.resolve(c+"_cookieMatrix");this.lightCookieOffsetId[b]=a.resolve(c+"_cookieOffset")},dispatchDirectLights:function(a,b,c){var d=a.length,e,g,l,k=0;this.mainLight=-1;var f=this.device.scope;for(e=0;ethis.mainLight&&(this.lightShadowMatrixVsId[k].setValue(g._shadowMatrix.data),this.lightShadowParamsVsId[k].setValue(h),g._direction.normalize(),this.lightDirVs[k][0]=g._direction.x,this.lightDirVs[k][1]=g._direction.y, this.lightDirVs[k][2]=g._direction.z,this.lightDirVsId[k].setValue(this.lightDirVs[k]),this.mainLight=e)}k++}return k},dispatchPointLight:function(a,b,c,d){var e=c._node.getWorldTransform();this.lightColorId[d]||this._resolveLight(b,d);this.lightRadiusId[d].setValue(c.attenuationEnd);this.lightColorId[d].setValue(a.gammaCorrection?c._linearFinalColor:c._finalColor);e.getTranslation(c._position);this.lightPos[d][0]=c._position.x;this.lightPos[d][1]=c._position.y;this.lightPos[d][2]=c._position.z;this.lightPosId[d].setValue(this.lightPos[d]); c.castShadows&&(this.lightShadowMapId[d].setValue(c._shadowCamera.renderTarget.colorBuffer),a=c._rendererParams,4!==a.length&&(a.length=4),a[0]=c._shadowResolution,a[1]=c._normalOffsetBias,a[2]=c.shadowBias,a[3]=1/c.attenuationEnd,this.lightShadowParamsId[d].setValue(a));c._cookie&&(this.lightCookieId[d].setValue(c._cookie),this.lightShadowMatrixId[d].setValue(e.data),this.lightCookieIntId[d].setValue(c.cookieIntensity))},dispatchSpotLight:function(a,b,c,d){var e=c._node.getWorldTransform();this.lightColorId[d]|| this._resolveLight(b,d);this.lightInAngleId[d].setValue(c._innerConeAngleCos);this.lightOutAngleId[d].setValue(c._outerConeAngleCos);this.lightRadiusId[d].setValue(c.attenuationEnd);this.lightColorId[d].setValue(a.gammaCorrection?c._linearFinalColor:c._finalColor);e.getTranslation(c._position);this.lightPos[d][0]=c._position.x;this.lightPos[d][1]=c._position.y;this.lightPos[d][2]=c._position.z;this.lightPosId[d].setValue(this.lightPos[d]);e.getY(c._direction).scale(-1);c._direction.normalize();this.lightDir[d][0]= c._direction.x;this.lightDir[d][1]=c._direction.y;this.lightDir[d][2]=c._direction.z;this.lightDirId[d].setValue(this.lightDir[d]);c.castShadows&&(c._isVsm?a=-2E-4:(a=20*c.shadowBias,!this.device.webgl2&&this.device.extStandardDerivatives&&(a*=-100)),b=c._isVsm?c.vsmBias/(c.attenuationEnd/7):c._normalOffsetBias,this.lightShadowMapId[d].setValue(c._isPcf&&this.device.webgl2?c._shadowCamera.renderTarget.depthBuffer:c._shadowCamera.renderTarget.colorBuffer),this.lightShadowMatrixId[d].setValue(c._shadowMatrix.data), e=c._rendererParams,4!==e.length&&(e.length=4),e[0]=c._shadowResolution,e[1]=b,e[2]=a,e[3]=1/c.attenuationEnd,this.lightShadowParamsId[d].setValue(e));c._cookie&&(this.lightCookieId[d].setValue(c._cookie),c.castShadows||(a=this.getShadowCamera(this.device,c),b=a._node,b.setPosition(c._node.getPosition()),b.setRotation(c._node.getRotation()),b.rotateLocal(-90,0,0),a.projection=pc.PROJECTION_PERSPECTIVE,a.aspectRatio=1,a.fov=2*c._outerConeAngle,r.setTRS(b.getPosition(),b.getRotation(),pc.Vec3.ONE).invert(), t.mul2(a.getProjectionMatrix(),r),c._shadowMatrix.mul2(k,t)),this.lightShadowMatrixId[d].setValue(c._shadowMatrix.data),this.lightCookieIntId[d].setValue(c.cookieIntensity),c._cookieTransform&&(c._cookieTransformUniform[0]=c._cookieTransform.x,c._cookieTransformUniform[1]=c._cookieTransform.y,c._cookieTransformUniform[2]=c._cookieTransform.z,c._cookieTransformUniform[3]=c._cookieTransform.w,this.lightCookieMatrixId[d].setValue(c._cookieTransformUniform),c._cookieOffsetUniform[0]=c._cookieOffset.x, c._cookieOffsetUniform[1]=c._cookieOffset.y,this.lightCookieOffsetId[d].setValue(c._cookieOffsetUniform)))},dispatchLocalLights:function(a,b,c,d,e){var g,l=a[pc.LIGHTTYPE_POINT];a=a[pc.LIGHTTYPE_SPOT];var k=l.length,f=a.length,h=d,p=this.device.scope;for(d=0;df._visibleLength[b])continue;y=f._visibleCameraSettings[b];w.setPosition(y.x,y.y,y.z); u.orthoHeight=y.orthoHeight;u.farClip=y.farClip;y=b}else v===pc.LIGHTTYPE_SPOT?(F=w.getPosition(),this.viewPos[0]=F.x,this.viewPos[1]=F.y,this.viewPos[2]=F.z,this.viewPosId.setValue(this.viewPos),this.shadowMapLightRadiusId.setValue(f.attenuationEnd)):v===pc.LIGHTTYPE_POINT&&(F=w.getPosition(),this.viewPos[0]=F.x,this.viewPos[1]=F.y,this.viewPos[2]=F.z,this.viewPosId.setValue(this.viewPos),this.shadowMapLightRadiusId.setValue(f.attenuationEnd),E=6);v!==pc.LIGHTTYPE_POINT&&(r.setTRS(w.getPosition(), w.getRotation(),pc.Vec3.ONE).invert(),t.mul2(u.getProjectionMatrix(),r),f._shadowMatrix.mul2(k,t));e.webgl2?v===pc.LIGHTTYPE_POINT?e.setDepthBias(!1):(e.setDepthBias(!0),e.setDepthBiasValues(-1E3*f.shadowBias,-1E3*f.shadowBias)):e.extStandardDerivatives&&(v===pc.LIGHTTYPE_POINT?(this.polygonOffset[0]=0,this.polygonOffset[1]=0):(this.polygonOffset[0]=-1E3*f.shadowBias,this.polygonOffset[1]=-1E3*f.shadowBias),this.polygonOffsetId.setValue(this.polygonOffset));f.shadowUpdateMode===pc.SHADOWUPDATE_THISFRAME&& (f.shadowUpdateMode=pc.SHADOWUPDATE_NONE);this._shadowMapUpdates+=E;e.setBlending(!1);e.setDepthWrite(!0);e.setDepthTest(!0);f._isPcf&&e.webgl2&&v!==pc.LIGHTTYPE_POINT?e.setColorWrite(!1,!1,!1,!1):e.setColorWrite(!0,!0,!0,!0);for(y?E=y+1:y=0;yg;g++)d=q[3*e+g+w],d=d*v+u,l=m[d],y=m[d+1],d=m[d+2],lH&&(H=l),y>F&&(F=y),d>G&&(G=d);d=6*e;P[d]=x;P[d+1]=E;P[d+2]=J;P[d+3]=H;P[d+4]=F;P[d+5]=G}for(l=0;l=y.x&&P[d+1]<=x.y&&P[d+4]>=y.y&&P[d+2]<=x.z&&P[d+5]>=y.z&&(B[e]|=g,t=!0);if(t){t={};for(e=0;eH&&(H=l),y>F&&(F=y),d>G&&(G=d);C.set(x,E,J);z.set(H,F,G);e=new pc.BoundingBox;e.setMinMax(C,z); r=new pc.Mesh;r.vertexBuffer=K;r.indexBuffer[0]=q;r.primitive[0].type=pc.PRIMITIVE_TRIANGLES;r.primitive[0].base=0;r.primitive[0].count=g.length;r.primitive[0].indexed=!0;r.aabb=e;q=new pc.MeshInstance(h.node,r,h.material);q.isStatic=h.isStatic;q.visible=h.visible;q.layer=h.layer;q.castShadow=h.castShadow;q._receiveShadow=h._receiveShadow;q.cull=h.cull;q.pick=h.pick;q.mask=h.mask;q.parameters=h.parameters;q._shaderDefs=h._shaderDefs;q._staticSource=h;q._staticLightList=h._staticLightList?h._staticLightList: [];for(e=0;eq._staticLightList.indexOf(r)&&q._staticLightList.push(r));q._staticLightList.sort(this.lightCompare);n.push(q)}}else n.push(h)}}else n.push(h);a.length=n.length;for(c=0;ce;e++)v.transformPoint(N[e],N[e]);n=m=c=1E6;q=t=h=-1E6;for(e=0;8>e;e++)p=N[e],p.xq&&(q=p.x),p.yt&&(t=p.y),p.zh&&(h=p.z);e=f/a._shadowResolution;n=Math.floor((n-.5*(f-(q-n)))/e)*e;m=Math.floor((m-.5*(f-(t-m)))/e)*e;n=.5*(n+f+n);m=.5*(m+f+m);l.translateLocal(n,m,1E5);g.projection=pc.PROJECTION_ORTHOGRAPHIC; g.nearClip=0;g.farClip=2E5;g.aspectRatio=1;g.orthoHeight=.5*f;this.updateCameraFrustum(g);t=!0;(h=a._visibleList[d])||(h=a._visibleList[d]=[]);e=f=a._visibleLength[d]=0;for(q=b.length;eh;++h)r.transformPoint(M[h],M[h]),f=M[h].z,fb&&(b=f);h=b;e>c&&(c=e);l.setPosition(k.getPosition());l.translateLocal(n,m,h+.01);g.farClip=h-c;(k=a._visibleCameraSettings[d])||(k=a._visibleCameraSettings[d]={});a=l.getPosition();k.x=a.x;k.y=a.y;k.z=a.z;k.orthoHeight=g.orthoHeight;k.farClip=g.farClip},gpuUpdate:function(a){this.updateGpuSkinMatrices(a); this.updateMorphing(a)},clearView:function(a,b,c){a=a.camera;var d=this.device;d.setRenderTarget(b);d.updateBegin();d.setColorWrite(!0,!0,!0,!0);d.setDepthWrite(!0);var e=a.getRect(),g=b?b.width:d.width,l=b?b.height:d.height;b=Math.floor(e.x*g);var k=Math.floor(e.y*l),g=Math.floor(e.width*g),e=Math.floor(e.height*l);d.setViewport(b,k,g,e);d.setScissor(b,k,g,e);d.clear(c?c:a._clearOptions)},setSceneConstants:function(){var a,b=this.device,c=this.scene;this.dispatchGlobalLights(c);if(c.fog!==pc.FOG_NONE){this.fogColor[0]= c.fogColor.r;this.fogColor[1]=c.fogColor.g;this.fogColor[2]=c.fogColor.b;if(c.gammaCorrection)for(a=0;3>a;a++)this.fogColor[a]=Math.pow(this.fogColor[a],2.2);this.fogColorId.setValue(this.fogColor);c.fog===pc.FOG_LINEAR?(this.fogStartId.setValue(c.fogStart),this.fogEndId.setValue(c.fogEnd)):this.fogDensityId.setValue(c.fogDensity)}this._screenSize[0]=b.width;this._screenSize[1]=b.height;this._screenSize[2]=1/b.width;this._screenSize[3]=1/b.height;this.screenSizeId.setValue(this._screenSize)},renderComposition:function(a){var b= this.device,c,d=a._renderedRt,e=a._renderedByCam,g=a._renderedLayer,l,k,f,h,p,n,m,q;this.beginLayers(a);a._update()&pc.COMPUPDATED_LIGHTS&&(this.scene.updateLitShaders=!0);this.beginFrame(a);this.setSceneConstants();var t=0,r,v;for(l=0;l=pc.SHADOW_VSM8&&a<=pc.SHADOW_VSM32;this._isPcf=a===pc.SHADOW_PCF5||a===pc.SHADOW_PCF3;this._shadowType=a;this._destroyShadowMap();this.updateKey()}}});Object.defineProperty(d.prototype,"castShadows",{get:function(){return this._castShadows&&this._mask!==pc.MASK_LIGHTMAP&&0!==this._mask},set:function(a){this._castShadows!==a&&(this._castShadows=a,this.updateKey())}});Object.defineProperty(d.prototype, "shadowResolution",{get:function(){return this._shadowResolution},set:function(a){if(this._shadowResolution!==a){var b=pc.Application.getApplication().graphicsDevice;this._shadowResolution=a=this._type===pc.LIGHTTYPE_POINT?Math.min(a,b.maxCubeMapSize):Math.min(a,b.maxTextureSize)}}});Object.defineProperty(d.prototype,"vsmBlurSize",{get:function(){return this._vsmBlurSize},set:function(a){this._vsmBlurSize!==a&&(0===a%2&&a++,this._vsmBlurSize=a)}});Object.defineProperty(d.prototype,"normalOffsetBias", {get:function(){return this._normalOffsetBias},set:function(a){this._normalOffsetBias!==a&&((!this._normalOffsetBias&&a||this._normalOffsetBias&&!a)&&this.updateKey(),this._normalOffsetBias=a)}});Object.defineProperty(d.prototype,"falloffMode",{get:function(){return this._falloffMode},set:function(a){this._falloffMode!==a&&(this._falloffMode=a,this.updateKey())}});Object.defineProperty(d.prototype,"innerConeAngle",{get:function(){return this._innerConeAngle},set:function(a){this._innerConeAngle!== a&&(this._innerConeAngle=a,this._innerConeAngleCos=Math.cos(a*Math.PI/180))}});Object.defineProperty(d.prototype,"outerConeAngle",{get:function(){return this._outerConeAngle},set:function(a){this._outerConeAngle!==a&&(this._outerConeAngle=a,this._outerConeAngleCos=Math.cos(a*Math.PI/180))}});Object.defineProperty(d.prototype,"intensity",{get:function(){return this._intensity},set:function(a){this._intensity!==a&&(this._intensity=a,this._updateFinalColor())}});Object.defineProperty(d.prototype,"cookie", {get:function(){return this._cookie},set:function(a){this._cookie!==a&&(this._cookie=a,this.updateKey())}});Object.defineProperty(d.prototype,"cookieFalloff",{get:function(){return this._cookieFalloff},set:function(a){this._cookieFalloff!==a&&(this._cookieFalloff=a,this.updateKey())}});Object.defineProperty(d.prototype,"cookieChannel",{get:function(){return this._cookieChannel},set:function(a){if(this._cookieChannel!==a){if(3>a.length)for(var b=a.charAt(a.length-1),c=3-a.length,d=0;dthis.shader._refCount&&this.shader.destroy());var a,b;for(b in this.variants)this.variants.hasOwnProperty(b)&&(a=this.variants[b],a!==this.shader&&(a._refCount--,1>a._refCount&&a.destroy()));this.variants= {};this.shader=null;var d;for(b=0;bg;g++)d[g]=e?Math.pow(b.data[g],2.2):b.data[g],k&&(d[g]*=a[m]);return{name:"material_"+c,value:d}};k&&(a[m]=1,Object.defineProperty(f.prototype,n,{get:function(){return this[m]},set:function(a){var b=this[m];(0===b||1===b)^(0===a||1===a)&&(this.dirtyShader=!0);this.dirtyColor=!0;this[m]=a}}),b.push(n),e[n]= function(a,b,d){b=d?a[p]:new Float32Array(3);d=!1;a.useGammaTonemap&&(d=(a._scene||pc.Application.getApplication().scene).gammaCorrection);for(var e=0;3>e;e++)b[e]=d?Math.pow(a[h].data[e],2.2):a[h].data[e],b[e]*=a[m];return{name:"material_"+c,value:b}})},p=function(a,c,d,g){var l="_"+c;a[l]=d;Object.defineProperty(f.prototype,c,{get:function(){return this[l]},set:function(a){var b=this[l];b!==a&&(this[l]=a,0===b||1===b||0===a||1===a)&&(this.dirtyShader=!0)}});b.push(c);e[c]=void 0!==g?g:function(a, b,d){return{name:"material_"+c,value:b}}},h=function(a,c,d){var g="_"+c;a[g]=null;Object.defineProperty(f.prototype,c,{get:function(){return this[g]},set:function(a){!!this[g]^!!a&&(this.dirtyShader=!0);this[g]=a}});b.push(c);e[c]=d},n=function(a,b,c){Object.defineProperty(f.prototype,c,{get:function(){return this[b]},set:function(a){this[b]=a}})},q=function(a){Object.defineProperty(f.prototype,"chunks",{get:function(){this.dirtyShader=!0;return this._chunks},set:function(a){this.dirtyShader=!0;this._chunks= a}});b.push("chunks")},m=function(a,c,d){var e="_"+c;a[e]=d;Object.defineProperty(f.prototype,c,{get:function(){return this[e]},set:function(a){this[e]!==a&&(this.dirtyShader=!0);this[e]=a}});b.push(c)},r=function(){};r.prototype.copy=function(a){for(var b in a)a.hasOwnProperty(b)&&"copy"!==b&&(this[b]=a[b])};Object.assign(f.prototype,{reset:function(){var e;for(e=0;ethis.metalness)&&this._setParameter("material_metalness",this.metalness):this.specularMap&&!this.specularTint||this._setParameter("material_specular", this.specularUniform);a=this.getUniform("shininess",this.shininess,!0);this._setParameter(a.name,a.value);this.emissiveMap&&!this.emissiveTint||this._setParameter("material_emissive",this.emissiveUniform);this.emissiveMap&&this._setParameter("material_emissiveIntensity",this.emissiveIntensity);0a;a++)this.emissiveUniform[a]*=this.emissiveIntensity;this.dirtyColor=!1}},updateShader:function(a,b,c,d,e,g){!this._colorProcessed&&this._scene&&(this._colorProcessed=!0,this._processColor());var l=a.useTexCubeLod,f=!a.extTextureLod,k,h,p,n,m,q;this.useSkybox&&(k=b._skyboxPrefiltered[0],h=b._skyboxPrefiltered[1],p=b._skyboxPrefiltered[2],n=b._skyboxPrefiltered[3],m=b._skyboxPrefiltered[4],q=b._skyboxPrefiltered[5]);k=this.prefilteredCubeMap128|| k;h=this.prefilteredCubeMap64||h;p=this.prefilteredCubeMap32||p;n=this.prefilteredCubeMap16||n;m=this.prefilteredCubeMap8||m;q=this.prefilteredCubeMap4||q;if(k){var r=k&&h&&p&&n&&m&&q;f&&r?(k.dpAtlas||(k.dpAtlas=pc.generateDpAtlas(a,[k,h,p,n,m,q]),k.sh=pc.shFromCubemap(n)),this.dpAtlas=k.dpAtlas,this.ambientSH=k.sh,this._setParameter("ambientSH[0]",this.ambientSH),this._setParameter("texture_sphereMap",this.dpAtlas)):l?6>k._levels.length?r?this._setParameter("texture_prefilteredCubeMap128",k):console.log("Can't use prefiltered cubemap: "+ r+", "+l+", "+k._levels):this._setParameter("texture_prefilteredCubeMap128",k):r?(this._setParameter("texture_prefilteredCubeMap128",k),this._setParameter("texture_prefilteredCubeMap64",h),this._setParameter("texture_prefilteredCubeMap32",p),this._setParameter("texture_prefilteredCubeMap16",n),this._setParameter("texture_prefilteredCubeMap8",m),this._setParameter("texture_prefilteredCubeMap4",q)):console.log("Can't use prefiltered cubemap: "+r+", "+l+", "+k._levels)}f=pc.programlib.standard;f=(l= e>pc.SHADER_FORWARDHDR&&e<=pc.SHADER_PICK)?f.optionsContextMin:f.optionsContext;l?this.shaderOptBuilder.updateMinRef(f,a,b,this,c,d,e,g,k):this.shaderOptBuilder.updateRef(f,a,b,this,c,d,e,g,k);this.onUpdateShader&&(f=this.onUpdateShader(f));this.shader=a.getProgramLibrary().getProgram("standard",f);c||(this.clearVariants(),this.variants[0]=this.shader);this.dirtyShader=!1}});(function(c){c.dirtyShader=!0;c.dirtyColor=!0;c._scene=null;c._colorProcessed=!1;k(c,"ambient",new pc.Color(.7,.7,.7));k(c, "diffuse",new pc.Color(1,1,1));k(c,"specular",new pc.Color(0,0,0));k(c,"emissive",new pc.Color(0,0,0),!0);p(c,"shininess",25,function(a,b){return{name:"material_shininess",value:a.shadingModel===pc.SPECULAR_PHONG?Math.pow(2,.11*b):.01*b}});p(c,"heightMapFactor",1,function(a,b){return{name:"material_heightMapFactor",value:.025*b}});p(c,"opacity",1);p(c,"alphaTest",0);p(c,"bumpiness",1);p(c,"reflectivity",1);p(c,"occludeSpecularIntensity",1);p(c,"refraction",0);p(c,"refractionIndex",1/1.5);p(c,"metalness", 1);p(c,"aoUvSet",0,null);h(c,"ambientSH",function(a,b,c){return{name:"ambientSH[0]",value:b}});h(c,"cubeMapProjectionBox",function(a,b,c){var d=c?a.cubeMapMinUniform:new Float32Array(3);a=c?a.cubeMapMaxUniform:new Float32Array(3);d[0]=b.center.x-b.halfExtents.x;d[1]=b.center.y-b.halfExtents.y;d[2]=b.center.z-b.halfExtents.z;a[0]=b.center.x+b.halfExtents.x;a[1]=b.center.y+b.halfExtents.y;a[2]=b.center.z+b.halfExtents.z;return[{name:"envBoxMin",value:d},{name:"envBoxMax",value:a}]});q(c);m(c,"ambientTint", !1);m(c,"diffuseTint",!1);m(c,"specularTint",!1);m(c,"emissiveTint",!1);m(c,"fastTbn",!1);m(c,"specularAntialias",!1);m(c,"useMetalness",!1);m(c,"occludeDirect",!1);m(c,"normalizeNormalMap",!0);m(c,"conserveEnergy",!0);m(c,"occludeSpecular",pc.SPECOCC_AO);m(c,"shadingModel",pc.SPECULAR_BLINN);m(c,"fresnelModel",pc.FRESNEL_NONE);m(c,"cubeMapProjection",pc.CUBEPROJ_NONE);m(c,"customFragmentShader",null);m(c,"forceFragmentPrecision",null);m(c,"useFog",!0);m(c,"useLighting",!0);m(c,"useGammaTonemap", !0);m(c,"useSkybox",!0);m(c,"forceUv1",!1);m(c,"pixelSnap",!1);m(c,"twoSidedLighting",!1);m(c,"nineSlicedMode",pc.SPRITE_RENDERMODE_SLICED);g(c,"diffuse",0,3);g(c,"specular",0,3);g(c,"emissive",0,3);g(c,"normal",0,-1);g(c,"metalness",0,1);g(c,"gloss",0,1);g(c,"opacity",0,1,"a");g(c,"height",0,1);g(c,"ao",0,1);g(c,"light",1,3);g(c,"msdf",0,3);h(c,"cubeMap");h(c,"sphereMap");h(c,"dpAtlas");h(c,"prefilteredCubeMap128");h(c,"prefilteredCubeMap64");h(c,"prefilteredCubeMap32");h(c,"prefilteredCubeMap16"); h(c,"prefilteredCubeMap8");h(c,"prefilteredCubeMap4");n(c,"diffuseTint","diffuseMapTint");n(c,"specularTint","specularMapTint");n(c,"emissiveTint","emissiveMapTint");n(c,"aoVertexColor","aoMapVertexColor");n(c,"diffuseVertexColor","diffuseMapVertexColor");n(c,"specularVertexColor","specularMapVertexColor");n(c,"emissiveVertexColor","emissiveMapVertexColor");n(c,"metalnessVertexColor","metalnessMapVertexColor");n(c,"glossVertexColor","glossMapVertexColor");n(c,"opacityVertexColor","opacityMapVertexColor"); n(c,"lightVertexColor","lightMapVertexColor");for(var d=0;da.metalness?1:0;b.glossTint=1;b.emissiveTint=g;b.alphaToCoverage=a.alphaToCoverage;b.needsNormalFloat=a.normalizeNormalMap;b.sphereMap=!!a.sphereMap;b.cubeMap=!!a.cubeMap;b.dpAtlas=!!a.dpAtlas;b.ambientSH=!!a.ambientSH;b.useSpecular=e;b.emissiveFormat=a.emissiveMap?a.emissiveMap.rgbm?1:a.emissiveMap.format===pc.PIXELFORMAT_RGBA32F?2:0:null;b.lightMapFormat= a.lightMap?a.lightMap.rgbm?1:a.lightMap.format===pc.PIXELFORMAT_RGBA32F?2:0:null;b.specularAntialias=a.specularAntialias;b.conserveEnergy=a.conserveEnergy;b.occludeSpecular=a.occludeSpecular;b.occludeSpecularFloat=1!==a.occludeSpecularIntensity;b.occludeDirect=a.occludeDirect;b.shadingModel=a.shadingModel;b.fresnelModel=a.fresnelModel;b.packedNormal=a.normalMap?a.normalMap.format===pc.PIXELFORMAT_DXT5:!1;b.fastTbn=a.fastTbn;b.cubeMapProjection=a.cubeMapProjection;b.customFragmentShader=a.customFragmentShader; b.refraction=!!a.refraction;b.useMetalness=a.useMetalness;b.msdf=!!a.msdfMap;b.twoSidedLighting=a.twoSidedLighting;b.pixelSnap=a.pixelSnap;b.nineSlicedMode=a.nineSlicedMode||0;b.aoMapUv=a.aoUvSet};f.prototype._updateEnvOptions=function(b,a,c,d){var e=(d?d.rgbm:!1)||(a.cubeMap?a.cubeMap.rgbm:!1)||(a.dpAtlas?a.dpAtlas.rgbm:!1),g=(d?d.rgbm||d.format===pc.PIXELFORMAT_RGBA32F:!1)||(a.cubeMap?a.cubeMap.rgbm||a.cubeMap.format===pc.PIXELFORMAT_RGBA32F:!1)||(a.dpAtlas?a.dpAtlas.rgbm||a.dpAtlas.format===pc.PIXELFORMAT_RGBA32F: !1),l=(!d||a.cubeMap||a.sphereMap||a.dpAtlas?!1:d.rgbm)||(a.cubeMap?a.cubeMap.rgbm:!1)||(a.sphereMap?a.sphereMap.rgbm:!1)||(a.dpAtlas?a.dpAtlas.rgbm:!1),f=(!d||a.cubeMap||a.sphereMap||a.dpAtlas?!1:d.rgbm||d.format===pc.PIXELFORMAT_RGBA32F)||(a.cubeMap?a.cubeMap.rgbm||a.cubeMap.format===pc.PIXELFORMAT_RGBA32F:!1)||(a.sphereMap?a.sphereMap.rgbm||a.sphereMap.format===pc.PIXELFORMAT_RGBA32F:!1)||(a.dpAtlas?a.dpAtlas.rgbm||a.dpAtlas.format===pc.PIXELFORMAT_RGBA32F:!1),p;a.useSkybox&&c._skyboxPrefiltered&& (p=c._skyboxPrefiltered[0]);b.fog=a.useFog?c.fog:"none";b.gamma=a.useGammaTonemap?c.gammaCorrection:pc.GAMMA_NONE;b.toneMap=a.useGammaTonemap?c.toneMapping:-1;b.rgbmAmbient=e;b.hdrAmbient=g;b.rgbmReflection=l;b.hdrReflection=f;b.useRgbm=l||e||(a.emissiveMap?a.emissiveMap.rgbm:!1)||(a.lightMap?a.lightMap.rgbm:!1);b.fixSeams=d?d.fixCubemapSeams:a.cubeMap?a.cubeMap.fixCubemapSeams:!1;b.prefilteredCubemap=!!d;b.skyboxIntensity=d&&p&&d===p&&1!==c.skyboxIntensity};f.prototype._updateLightOptions=function(b, a,c,d,e){b.lightMap=!1;b.lightMapChannel="";b.lightMapUv=0;b.lightMapTransform=0;b.lightMapWithoutAmbient=!1;b.dirLightMap=!1;c&&(b.noShadow=0!==(c&pc.SHADERDEF_NOSHADOW),0!==(c&pc.SHADERDEF_LM)&&(b.lightMapFormat=1,b.lightMap=!0,b.lightMapChannel="rgb",b.lightMapUv=1,b.lightMapTransform=0,b.lightMapWithoutAmbient=!a.lightMap,b.useRgbm=!0,0!==(c&pc.SHADERDEF_DIRLM)&&(b.dirLightMap=!0)));a.useLighting?(a=[],c=c?c>>16:1,d&&(this._collectLights(pc.LIGHTTYPE_DIRECTIONAL,d[pc.LIGHTTYPE_DIRECTIONAL],a, c),this._collectLights(pc.LIGHTTYPE_POINT,d[pc.LIGHTTYPE_POINT],a,c,e),this._collectLights(pc.LIGHTTYPE_SPOT,d[pc.LIGHTTYPE_SPOT],a,c,e)),b.lights=a):b.lights=[];0===b.lights.length&&(b.noShadow=!0)};f.prototype._updateTexOptions=function(b,a,c,d,e,g,l){var f=c+"Map",p=c+"VertexColor",h=c+"VertexColorChannel",n=f+"Channel",q=f+"Transform",m=f+"Uv";"light"!==c&&(b[f]=!1,b[n]="",b[q]=0,b[m]=0);b[p]=!1;b[h]="";var r="opacity"===c;if(r&&a.blendType===pc.BLEND_NONE&&0===a.alphaTest&&!a.alphaToCoverage)return b; if(!l||r)"height"!==c&&a[p]&&g&&(b[p]=a[p],b[h]=a[h],b.vertexColors=!0),a[f]&&(c=!0,0!==a[m]||d||(c=!1),1!==a[m]||e||(c=!1),c&&(b[f]=!!a[f],b[q]=this._getMapTransformID(a[q],a[m]),b[n]=a[n],b[m]=a[m]))};f.prototype._collectLights=function(b,a,c,d,e){var g,l;for(l=0;le;e++)0A&&(C.x=A),C.y>B&&(C.y=B),C.z>J&&(C.z=J),z.xm?H[3*F]+=m:E[3*F]+=m,0>z?H[3*F+1]+=z:E[3*F+1]+=z,0>C?H[3*F+2]+=C:E[3*F+2]+=C;for(f=0;fG;G++)0A&&(C.x=A),C.y>B&&(C.y=B),C.z>J&&(C.z=J),A=E[3*F],B=E[3*F+1],J=E[3*F+2],z.x>16},set:function(a){this._shaderDefs=this._shaderDefs&65535|a<<16;this._shader[pc.SHADER_FORWARD]=null;this._shader[pc.SHADER_FORWARDHDR]=null}});Object.assign(d.prototype,{syncAabb:function(){},updateKey:function(){var a=this.material;this._key[pc.SORTKEY_FORWARD]=f(this.layer,a.alphaToCoverage||a.alphaTest?pc.BLEND_NORMAL:a.blendType,!1,a.id)},setParameter:pc.Material.prototype.setParameter,setParameters:pc.Material.prototype.setParameters,deleteParameter:pc.Material.prototype.deleteParameter, getParameter:pc.Material.prototype.getParameter,getParameters:pc.Material.prototype.getParameters,clearParameters:pc.Material.prototype.clearParameters});var e=function(a,b,c){this._key=[];this._key[pc.SORTKEY_FORWARD]=f(a,b,!0,0);this.command=c};Object.defineProperty(e.prototype,"key",{get:function(){return this._key[pc.SORTKEY_FORWARD]},set:function(a){this._key[pc.SORTKEY_FORWARD]=a}});var g=function(a,b,c){this.buffer=new Float32Array(a*(c||16));this.count=a;this.offset=0;this.usage=b?pc.BUFFER_DYNAMIC: pc.BUFFER_STATIC;this._buffer=null};Object.assign(g.prototype,{update:function(){this._buffer&&this._buffer.setData(this.buffer)}});return{Command:e,Mesh:c,MeshInstance:d,InstancingData:g,_getDrawcallSortKey:f}}());Object.assign(pc,function(){var f=new pc.Mat4,b=function(a){this.skin=a;this._dirty=!0;this.bones=[];var b=a.inverseBindPose.length;a=a.device;if(a.supportsBoneTextures){var d;d=256d;d++)0!==c.blendWeight.data[4*b+d]&&(a.boneIndices[d]=this.getBoneRemap(c.blendIndices.data[4*a.index+d]));c=this.vertices.length;this.indices.push(c);this.vertices.push(a); this.indexMap[b]=c}},addPrimitive:function(a,b,c,f){var d,e,g=[],l=0,q=a.length;for(d=0;dr;r++)if(0f)return!1;for(d=0;dg){var y=q.splice(l,1)[0],u=[];for(k=0;kk&&(f.x=k),f.y>h&&(f.y=h),f.z>p&&(f.z=p),b.xc._refCount){c.vertexBuffer&&(c.vertexBuffer.destroy(),c.vertexBuffer=null);for(e=0;ec;c++){d=h[a+q[c][0]];e=h[a+q[c][1]];var t=d>e?e<<16|d:d<<16|e;void 0===m[t]&&(m[t]=0,r.push(d,e))}p.unlock();a=new pc.IndexBuffer(p.device,pc.INDEXFORMAT_UINT16,r.length);c=new Uint16Array(a.lock());c.set(r);a.unlock();g.primitive[pc.RENDERSTYLE_WIREFRAME]= {type:pc.PRIMITIVE_LINES,base:0,count:r.length,indexed:!0};g.indexBuffer[pc.RENDERSTYLE_WIREFRAME]=a}}});return{Model:f}}());Object.assign(pc,function(){function f(a){return a-Math.floor(a)}function b(a){var b=f(a);a=f(255*a);return[b-a/255,a-a/255]}function a(a,b){return a-b*Math.floor(a/b)}function c(a,b){U[a]=void 0!==Z[a]&&null!==Z[a]?Z[a]:b}function d(a,b){for(var c=a.length/3,d=Array(4*c),e=0;eg;g++)for(e=0;16>e;e++)f=e+ 1-8.5,l=g+1-8.5,l=Math.max(Math.min(1-Math.max(Math.min(Math.sqrt(f*f+l*l)/16,1),0)-.5,1),0),f=16*g+e,d[4*f]=1,d[4*f+1]=1,d[4*f+2]=1,d[4*f+3]=l;T.DEFAULT_PARAM_TEXTURE=p(a,16,16,d,pc.PIXELFORMAT_R8_G8_B8_A8,1,!0);T.DEFAULT_PARAM_TEXTURE.minFilter=pc.FILTER_LINEAR;T.DEFAULT_PARAM_TEXTURE.magFilter=pc.FILTER_LINEAR}U=this;Z=b;c("numParticles",1);this.numParticles>a.maxTextureSize&&(console.warn("WARNING: can't create more than "+a.maxTextureSize+" particles on this device."),this.numParticles=a.maxTextureSize); c("rate",1);c("rate2",this.rate);c("lifetime",50);c("emitterExtents",new pc.Vec3(0,0,0));c("emitterRadius",0);c("emitterShape",pc.EMITTERSHAPE_BOX);c("initialVelocity",1);c("wrap",!1);c("localSpace",!1);c("wrapBounds",null);c("colorMap",T.DEFAULT_PARAM_TEXTURE);c("normalMap",null);c("loop",!0);c("preWarm",!1);c("sort",pc.PARTICLESORT_NONE);c("mode",pc.PARTICLEMODE_GPU);c("scene",null);c("lighting",!1);c("halfLambert",!1);c("intensity",1);c("stretch",0);c("alignToMotion",!1);c("depthSoftening",0); c("mesh",null);c("depthWrite",!1);c("noFog",!1);c("blendType",pc.BLEND_NORMAL);c("node",null);c("startAngle",0);c("startAngle2",this.startAngle);c("animTilesX",1);c("animTilesY",1);c("animNumFrames",1);c("animSpeed",1);c("animLoop",!0);this.frameRandomUniform=new Float32Array(3);this.emitterPosUniform=new Float32Array(3);this.wrapBoundsUniform=new Float32Array(3);this.emitterScaleUniform=new Float32Array([1,1,1]);c("colorGraph",m);c("colorGraph2",this.colorGraph);c("scaleGraph",n);c("scaleGraph2", this.scaleGraph);c("alphaGraph",n);c("alphaGraph2",this.alphaGraph);c("localVelocityGraph",q);c("localVelocityGraph2",this.localVelocityGraph);c("velocityGraph",q);c("velocityGraph2",this.velocityGraph);c("rotationSpeedGraph",h);c("rotationSpeedGraph2",this.rotationSpeedGraph);this.constantParticleTexIN=a.scope.resolve("particleTexIN");this.constantParticleTexOUT=a.scope.resolve("particleTexOUT");this.constantEmitterPos=a.scope.resolve("emitterPos");this.constantEmitterScale=a.scope.resolve("emitterScale"); this.constantSpawnBounds=a.scope.resolve("spawnBounds");this.constantSpawnBoundsSphere=a.scope.resolve("spawnBoundsSphere");this.constantInitialVelocity=a.scope.resolve("initialVelocity");this.constantFrameRandom=a.scope.resolve("frameRandom");this.constantDelta=a.scope.resolve("delta");this.constantRate=a.scope.resolve("rate");this.constantRateDiv=a.scope.resolve("rateDiv");this.constantLifetime=a.scope.resolve("lifetime");this.constantLightCube=a.scope.resolve("lightCube[0]");this.constantGraphSampleSize= a.scope.resolve("graphSampleSize");this.constantGraphNumSamples=a.scope.resolve("graphNumSamples");this.constantInternalTex0=a.scope.resolve("internalTex0");this.constantInternalTex1=a.scope.resolve("internalTex1");this.constantInternalTex2=a.scope.resolve("internalTex2");this.constantEmitterMatrix=a.scope.resolve("emitterMatrix");this.constantNumParticles=a.scope.resolve("numParticles");this.constantNumParticlesPot=a.scope.resolve("numParticlesPot");this.constantLocalVelocityDivMult=a.scope.resolve("localVelocityDivMult"); this.constantVelocityDivMult=a.scope.resolve("velocityDivMult");this.constantRotSpeedDivMult=a.scope.resolve("rotSpeedDivMult");this.constantSeed=a.scope.resolve("seed");this.constantStartAngle=a.scope.resolve("startAngle");this.constantStartAngle2=a.scope.resolve("startAngle2");this.constantOutBoundsMul=a.scope.resolve("outBoundsMul");this.constantOutBoundsAdd=a.scope.resolve("outBoundsAdd");this.constantInBoundsSize=a.scope.resolve("inBoundsSize");this.constantInBoundsCenter=a.scope.resolve("inBoundsCenter"); this.constantMaxVel=a.scope.resolve("maxVel");this.lightCube=new Float32Array(18);this.lightCubeDir=Array(6);this.lightCubeDir[0]=new pc.Vec3(-1,0,0);this.lightCubeDir[1]=new pc.Vec3(1,0,0);this.lightCubeDir[2]=new pc.Vec3(0,-1,0);this.lightCubeDir[3]=new pc.Vec3(0,1,0);this.lightCubeDir[4]=new pc.Vec3(0,0,-1);this.lightCubeDir[5]=new pc.Vec3(0,0,1);this.animParams=new Float32Array(4);this.camera=this.particleDistance=this.vbOld=this.vbToSort=this.internalTex3=this.internalTex2=this.internalTex1= this.internalTex0=null;this.swapTex=!1;this.useMesh=!0;this.useCpu=!1;this.pack8=!0;this.localBounds=new pc.BoundingBox;this.worldBoundsNoTrail=new pc.BoundingBox;this.worldBoundsTrail=[new pc.BoundingBox,new pc.BoundingBox];this.worldBounds=new pc.BoundingBox;this.inBoundsCenterUniform=new Float32Array(3);this.worldBoundsSize=new pc.Vec3;this.inBoundsSizeUniform=new Float32Array(3);this.prevWorldBoundsSize=new pc.Vec3;this.prevWorldBoundsCenter=new pc.Vec3;this.worldBoundsMul=new pc.Vec3;this.worldBoundsMulUniform= new Float32Array(3);this.worldBoundsAdd=new pc.Vec3;this.worldBoundsAddUniform=new Float32Array(3);this.timeToSwitchBounds=0;this.shaderParticleUpdateOnStop=this.shaderParticleUpdateNoRespawn=this.shaderParticleUpdateRespawn=null;this.numParticleIndices=this.numParticleVerts=0;this.meshInstance=this.material=null;this.seed=0;this.fixedTimeStep=1/60;this.maxSubSteps=10;this.simTimeTotal=this.simTime=0;this.beenReset=!1;this._layer=null;this.rebuild()};Object.assign(T.prototype,{onChangeCamera:function(){this.regenShader(); this.resetMaterial()},calculateBoundsMad:function(){this.worldBoundsMul.x=1/this.worldBoundsSize.x;this.worldBoundsMul.y=1/this.worldBoundsSize.y;this.worldBoundsMul.z=1/this.worldBoundsSize.z;this.worldBoundsAdd.copy(this.worldBounds.center).mul(this.worldBoundsMul).scale(-1);this.worldBoundsAdd.x+=.5;this.worldBoundsAdd.y+=.5;this.worldBoundsAdd.z+=.5},calculateWorldBounds:function(){if(this.node){this.prevWorldBoundsSize.copy(this.worldBoundsSize);this.prevWorldBoundsCenter.copy(this.worldBounds.center); this.worldBoundsNoTrail.setFromTransformedAabb(this.localBounds,this.node.getWorldTransform());this.worldBoundsTrail[0].add(this.worldBoundsNoTrail);var a=this.simTimeTotal;if(a>this.timeToSwitchBounds){var b=this.worldBoundsTrail[0];this.worldBoundsTrail[0]=this.worldBoundsTrail[1];this.worldBoundsTrail[1]=b;this.worldBoundsTrail[0].copy(this.worldBoundsNoTrail);this.timeToSwitchBounds=a+this.lifetime}this.worldBounds.copy(this.worldBoundsTrail[0]);this.worldBounds.add(this.worldBoundsTrail[1]); this.worldBoundsSize.copy(this.worldBounds.halfExtents).scale(2);this.meshInstance.mesh.aabb=this.worldBounds;this.meshInstance._aabbVer=1-this.meshInstance._aabbVer;this.pack8&&this.calculateBoundsMad()}},calculateLocalBounds:function(){var a=Number.MAX_VALUE,b=Number.MAX_VALUE,c=Number.MAX_VALUE,d=-Number.MAX_VALUE,e=-Number.MAX_VALUE,g=-Number.MAX_VALUE,f=0,l=this.lifetime/this.precision,k=[this.qVelocity,this.qVelocity2,this.qLocalVelocity,this.qLocalVelocity2],h=[0,0,0,0],p=[0,0,0,0],m=[0,0, 0,0],n,q,r,t,v,u;for(n=0;nq;q++)t=k[q][3*r]*l+h[q],v=k[q][3*r+1]*l+p[q],u=k[q][3*r+2]*l+m[q],a>t&&(a=t),b>v&&(b=v),c>u&&(c=u),dt&&(a=t);b>v&&(b=v);c>u&&(c=u); V.x=a-f;V.y=b-f;V.z=c-f;W.x=d+f;W.y=e+f;W.z=g+f;this.localBounds.setMinMax(V,W)},rebuild:function(){var a,b=this.graphicsDevice;null===this.colorMap&&(this.colorMap=T.DEFAULT_PARAM_TEXTURE);this.spawnBounds=this.emitterShape===pc.EMITTERSHAPE_BOX?this.emitterExtents:this.emitterRadius;this.useCpu=this.useCpu||this.sort>pc.PARTICLESORT_NONE||1>=b.maxVertexTextures||64>b.fragmentUniformsCount||b.forceCpuParticles||!b.extTextureFloat;this._destroyResources();this.pack8=(this.pack8||!b.textureFloatRenderable)&& !this.useCpu;r=this.useCpu||this.pack8?4:2;this.useMesh=!1;this.mesh&&(65535k;k++)A.data[k]=f.data[k];H=this.meshInstance.node.localScale;F=Math.max(Math.max(H.x,H.y),H.z)}k=null=== this.meshInstance.node||this.localSpace?pc.Vec3.ZERO:this.meshInstance.node.getPosition();var p=this.camera?this.camera._node.getPosition():pc.Vec3.ZERO,m,n,q,r,I,V,W,U=this.precision-1;for(f=0;fX&&(this.particleTex[4*L+3+8*this.numParticlesPot]=-1):(X>=R&&(X-=Math.max(R,(this.numParticles-1)*T),this.particleTex[4*L+3+8*this.numParticlesPot]=this.loop?1:-1),0>X&&this.loop&&(this.particleTex[4*L+3+8*this.numParticlesPot]= 1));0>this.particleTex[4*L+3+8*this.numParticlesPot]&&(ka=!1);this.particleTex[4*L+3+4*this.numParticlesPot]=X;for(q=0;qpc.PARTICLESORT_NONE&&this.camera){k=this.particleDistance;for(f=0;fthis.endTime){if(this.onFinished)this.onFinished();this.meshInstance.visible=!1}},_destroyResources:function(){this.particleTexIN&& (this.particleTexIN.destroy(),this.particleTexIN=null);this.particleTexOUT&&(this.particleTexOUT.destroy(),this.particleTexOUT=null);this.particleTexStart&&this.particleTexStart.destroy&&(this.particleTexStart.destroy(),this.particleTexStart=null);this.rtParticleTexIN&&(this.rtParticleTexIN.destroy(),this.rtParticleTexIN=null);this.rtParticleTexOUT&&(this.rtParticleTexOUT.destroy(),this.rtParticleTexOUT=null);this.internalTex0&&(this.internalTex0.destroy(),this.internalTex0=null);this.internalTex1&& (this.internalTex1.destroy(),this.internalTex1=null);this.internalTex2&&(this.internalTex2.destroy(),this.internalTex2=null);this.internalTex3&&(this.internalTex3.destroy(),this.internalTex3=null);this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBuffer=void 0);this.indexBuffer&&(this.indexBuffer.destroy(),this.indexBuffer=void 0);this.material&&(this.material.destroy(),this.material=null)},destroy:function(){this.camera=null;this._destroyResources()}});return{ParticleEmitter:T}}());Object.assign(pc,function(){var f=!1,b=function(a,b,d){a instanceof pc.GraphicsDevice&&(a=pc.Application.getApplication(),f||(f=!0));this.app=a;var c=this.device=a.graphicsDevice;this.library=c.getProgramLibrary();this.pickColor=new Float32Array(4);this.pickColor[3]=1;this.scene=null;this.drawCalls=[];this.layerComp=this.layer=null;this.clearOptions={color:[1,1,1,1],depth:1,flags:pc.CLEARFLAG_COLOR|pc.CLEARFLAG_DEPTH};var g=this;this._clearDepthOptions={depth:1,flags:pc.CLEARFLAG_DEPTH};this.clearDepthCommand= new pc.Command(0,0,function(){c.clear(g._clearDepthOptions)});this.resize(b,d);this._ignoreOpacityFor=null};b.prototype.getSelection=function(a,b,d,e){var c=this.device;"object"===typeof a?(e=a,a=e.x,b=e.y,d=e.width,e=e.height):b=this.layer.renderTarget.height-(b+(e||1));d=d||1;e=e||1;var f=c.renderTarget;c.setRenderTarget(this.layer.renderTarget);c.updateBegin();var k=new Uint8Array(4*d*e);c.readPixels(a,b,d,e,k);c.updateEnd();c.setRenderTarget(f);a=[];b=this.layer.instances.visibleOpaque[0].list; for(var p,h,c=0;c>16&255)/255;f.pickColor[1]=(b>>8&255)/255;f.pickColor[2]= (b&255)/255;h.setValue(f.pickColor);c.setBlending(!1)}});this.layerComp=new pc.LayerComposition;this.layerComp.pushOpaque(this.layer);this.meshInstances=this.layer.opaqueMeshInstances;this._instancesVersion=-1}var n,q,m;if(!k){this.layer.clearMeshInstances();d=b.layers.layerList;var r=b.layers.subLayerEnabled,t=b.layers.subLayerList;for(b=0;bn)))for(g.overrideClear&&g._clearDepthBuffer&&!g._pickerCleared&&(this.meshInstances.push(this.clearDepthCommand),g._pickerCleared=!0),n=(n=t[b])?g.instances.transparentMeshInstances:g.instances.opaqueMeshInstances,q=n.length,g=0;ga.dot(u)?-1:1;return I}; pc.createMesh=function(f,b,a){var c=a&&void 0!==a.normals?a.normals:null,d=a&&void 0!==a.tangents?a.tangents:null,e=a&&void 0!==a.colors?a.colors:null,g=a&&void 0!==a.uvs?a.uvs:null,l=a&&void 0!==a.uvs1?a.uvs1:null,k=a&&void 0!==a.indices?a.indices:null,p=a&&void 0!==a.blendIndices?a.blendIndices:null,h=a&&void 0!==a.blendWeights?a.blendWeights:null;a=[{semantic:pc.SEMANTIC_POSITION,components:3,type:pc.TYPE_FLOAT32}];null!==c&&a.push({semantic:pc.SEMANTIC_NORMAL,components:3,type:pc.TYPE_FLOAT32}); null!==d&&a.push({semantic:pc.SEMANTIC_TANGENT,components:4,type:pc.TYPE_FLOAT32});null!==e&&a.push({semantic:pc.SEMANTIC_COLOR,components:4,type:pc.TYPE_UINT8,normalize:!0});null!==g&&a.push({semantic:pc.SEMANTIC_TEXCOORD0,components:2,type:pc.TYPE_FLOAT32});null!==l&&a.push({semantic:pc.SEMANTIC_TEXCOORD1,components:2,type:pc.TYPE_FLOAT32});null!==p&&a.push({semantic:pc.SEMANTIC_BLENDINDICES,components:2,type:pc.TYPE_UINT8});null!==h&&a.push({semantic:pc.SEMANTIC_BLENDWEIGHT,components:2,type:pc.TYPE_FLOAT32}); var n=new pc.VertexFormat(f,a);a=b.length/3;for(var n=new pc.VertexBuffer(f,n,a),q=new pc.VertexIterator(n),m=0;me.indexOf(d)&&e.push(d),!b&&d.castShadow&&0>f.indexOf(d)&&f.push(d),!this.passThrough&&0<=c&&g._shaderVersion!==c&&(g.updateShader!==pc.Material.prototype.updateShader&&(g.clearVariants(),g.shader=null),g._shaderVersion=c);this.passThrough||(this._dirty=!0)};p.prototype.removeMeshInstances=function(a,b){var c,d,e,g,f,l,k,h=this.opaqueMeshInstances, p=this.transparentMeshInstances,n=this.shadowCasters;for(c=0;cg&&(g=d),f++;else if(0<=g)break}0<=g&&h.splice(g,f);g=-1;f=0;l=p.length;for(d=0;dg&&(g=d),f++;else if(0<=g)break}0<=g&&p.splice(g,f);b||(d=n.indexOf(e),0<=d&&n.splice(d,1))}this._dirty=!0};p.prototype.clearMeshInstances=function(a){if(0!==this.opaqueMeshInstances.length|| 0!==this.transparentMeshInstances.length||!a&&0!==this.shadowCasters.length)this.opaqueMeshInstances.length=0,this.transparentMeshInstances.length=0,a||(this.shadowCasters.length=0),this.passThrough||(this._dirty=!0)};p.prototype.addLight=function(a){0<=this._lightComponents.indexOf(a)||(this._lightComponents.push(a),this._lights.push(a.light),this._dirtyLights=!0,this._generateLightHash())};p.prototype.removeLight=function(a){var b=this._lightComponents.indexOf(a);0>b||(this._lightComponents.splice(b, 1),b=this._lights.indexOf(a.light),this._lights.splice(b,1),this._dirtyLights=!0,this._generateLightHash())};p.prototype.clearLights=function(){this._lightComponents.length=0;this._lights.length=0;this._dirtyLights=!0};p.prototype.addShadowCasters=function(a){for(var b,c=this.shadowCasters,d=0;dc.indexOf(b)&&c.push(b);this._dirtyLights=!0};p.prototype.removeShadowCasters=function(a){for(var b,c=this.shadowCasters,d=0;da||(this.cameras.splice(a,1),this._generateCameraHash(),this.instances.clearVisibleLists(a))};p.prototype.clearCameras=function(){this._cameraHash=this.cameras.length=0;this._dirtyCameras=!0};p.prototype._sortCameras= function(){this._generateCameraHash()};p.prototype._calculateSortDistances=function(a,b,c,d){var e,g,f,l,k;for(e=0;ethis._meshInstances.indexOf(c)&&(this._meshInstances.push(c),c.material&&c.material._dirtyBlend&&(this._dirtyBlend=!0,c.material._dirtyBlend=!1));f=d.transparentMeshInstances;for(a=0;athis._meshInstances.indexOf(c)&&(this._meshInstances.push(c), c.material&&c.material._dirtyBlend&&(this._dirtyBlend=!0,c.material._dirtyBlend=!1))}for(b=0;bc&&(this._lights.push(k),c=this._lights.length- 1),(k=this._lightShadowCasters[c])||(this._lightShadowCasters[c]=[]);if(this._dirtyLights)for(this._sortLights(this),this._dirtyLights=!1,b=0;bthis._meshInstances.indexOf(k[c])?(k[c]=k[k.length-1],--k.length):c++;for(c=0;ck.indexOf(p[c])&&k.push(p[c])}if(g& pc.COMPUPDATED_LIGHTS||this._dirtyCameras)for(this._globalLightCameras.length=0,f=this._sortedLights[pc.LIGHTTYPE_DIRECTIONAL],a=0;ad._sortedLights[pc.LIGHTTYPE_DIRECTIONAL].indexOf(k)))for(c=0;cc&&this.cameras.push(f);this._renderList.length=0;for(b=c=this._renderListCamera.length=0;bc||f.push(c);this._globalLightCameraIds.push(f)}return g}; f.prototype._isLayerAdded=function(b){return 0<=this.layerList.indexOf(b)?!0:!1};f.prototype._isSublayerAdded=function(b,a){for(var c=0;cthis.layerList.indexOf(b)&&this.fire("remove",b);break}};f.prototype.pushTransparent=function(b){this._isSublayerAdded(b,!0)||(this.layerList.push(b),this._transparentOrder[b.id]=this.subLayerList.push(!0)-1,this.subLayerEnabled.push(!0),this._dirtyCameras=this._dirtyLights=this._dirty=!0,this.fire("add",b))};f.prototype.insertTransparent=function(b,a){this._isSublayerAdded(b, !0)||(this.layerList.splice(a,0,b),this.subLayerList.splice(a,0,!0),this._updateTransparentOrder(a,this.subLayerList.length-1),this.subLayerEnabled.splice(a,0,!0),this._dirtyCameras=this._dirtyLights=this._dirty=!0,this.fire("add",b))};f.prototype.removeTransparent=function(b){for(var a=0,c=this.layerList.length;athis.layerList.indexOf(b)&&this.fire("remove",b);break}};f.prototype._getSublayerIndex=function(b,a){var c=this.layerList.indexOf(b);return 0>c||this.subLayerList[c]!==a&&(c=this.layerList.indexOf(b,c+1),0>c||this.subLayerList[c]!==a)?-1:c};f.prototype.getOpaqueIndex=function(b){return this._getSublayerIndex(b,!1)};f.prototype.getTransparentIndex=function(b){return this._getSublayerIndex(b,!0)};f.prototype.getLayerById=function(b){for(var a=0;a=b;b++)for(k=0===b||3===b?0:1,e=0;3>=e;e++)g=-a.x+2*a.x*(1>=b?0:3)/3,f=-(-a.y+2*a.y*(1>=e?0:3)/3),p=0===e||3===e?0:1,h.push(-g,0,f),n.push(0,1,0),q.push(k,p),3>b&&3>e&&(m.push(r+3+1,r+1,r),m.push(r+3+1,r+3+2,r+1)),r++;return pc.createMesh(this._device,h,{normals:n,uvs:q,indices:m})};a.prototype._onSetFrames=function(a){this._updatingProperties?this._meshesDirty=!0:this._createMeshes()};a.prototype._onFrameChanged=function(a,b){var c=this._frameKeys.indexOf(a); 0>c||(b?this.renderMode===pc.SPRITE_RENDERMODE_SIMPLE&&(this._meshes[c]=this._createSimpleMesh(b)):this._meshes[c]=null,this.fire("set:meshes"))};a.prototype._onFrameRemoved=function(a){a=this._frameKeys.indexOf(a);0>a||(this._meshes[a]=null,this.fire("set:meshes"))};a.prototype.startUpdate=function(){this._updatingProperties=!0;this._meshesDirty=!1};a.prototype.endUpdate=function(){this._updatingProperties=!1;this._meshesDirty&&this._atlas&&this._frameKeys&&this._createMeshes();this._meshesDirty= !1};a.prototype.destroy=function(){var a,b;a=0;for(b=this._meshes.length;ae?b(a,c,g,e):a[g]b)for(this._time=this.looping?0:b,b=0;bthis._time)for(this._time=this.looping?b:0,b=0;b=this._time){p=(this._time-f.time)/(k.time-f.time);g._pos.lerp(f.position,k.position,p);g._quat.slerp(f.rotation,k.rotation,p);g._scale.lerp(f.scale,k.scale,p);g._written=!0;this._currKeyIndices[e]=n;p=!0;break}if(1=== d.length||!p&&0===this._time&&this.looping)g._pos.copy(d[0].position),g._quat.copy(d[0].rotation),g._scale.copy(d[0].scale),g._written=!0}}}};b.prototype.blend=function(a,b,d){for(var c=this._interpolatedKeys.length,g=0;gb))if(0===this._state){this.stop();var a=this._suspendInstanceEvents;this._suspendInstanceEvents=!0;this._startOffset=b;this.play();this._suspendInstanceEvents=a}else this._currentTime=this._startOffset=b}})):pc.SoundManager.hasAudio()?(f=function(b,a,c){pc.events.attach(this);c=c||{};this._volume= void 0!==c.volume?pc.math.clamp(Number(c.volume)||0,0,1):1;this._pitch=void 0!==c.pitch?Math.max(.01,Number(c.pitch)||0):1;this._loop=!(void 0===c.loop||!c.loop);this._sound=a;this._state=2;this._suspendInstanceEvents=this._suspendEndEvent=this._suspended=!1;this._playWhenLoaded=!0;this._startTime=Math.max(0,Number(c.startTime)||0);this._duration=Math.max(0,Number(c.duration)||0);this._startOffset=null;this._isReady=!1;this._manager=b;this._loadedMetadataHandler=this._onLoadedMetadata.bind(this); this._timeUpdateHandler=this._onTimeUpdate.bind(this);this._endedHandler=this._onEnded.bind(this);this._onPlayCallback=c.onPlay;this._onPauseCallback=c.onPause;this._onResumeCallback=c.onResume;this._onStopCallback=c.onStop;this._onEndCallback=c.onEnd;this.source=null;this._createSource()},Object.assign(f.prototype,{play:function(){2!==this._state&&this.stop();if(!this.source&&!this._createSource())return!1;this.volume=this._volume;this.pitch=this._pitch;this.loop=this._loop;this.source.play();this._state= 0;this._playWhenLoaded=!1;this._manager.on("volumechange",this._onManagerVolumeChange,this);this._manager.on("suspend",this._onManagerSuspend,this);this._manager.on("resume",this._onManagerResume,this);this._manager.on("destroy",this._onManagerDestroy,this);this._manager.suspended&&this._onManagerSuspend();this._suspendInstanceEvents||this._onPlay();return!0},pause:function(){if(!this.source||0!==this._state)return!1;this._suspendEndEvent=!0;this.source.pause();this._playWhenLoaded=!1;this._state= 1;this._startOffset=null;this._suspendInstanceEvents||this._onPause();return!0},resume:function(){if(!this.source||1!==this._state)return!1;this._state=0;this._playWhenLoaded=!1;this.source.paused&&(this.source.play(),this._suspendInstanceEvents||this._onResume());return!0},stop:function(){if(!this.source||2===this._state)return!1;this._manager.off("volumechange",this._onManagerVolumeChange,this);this._manager.off("suspend",this._onManagerSuspend,this);this._manager.off("resume",this._onManagerResume, this);this._manager.off("destroy",this._onManagerDestroy,this);this._suspendEndEvent=!0;this.source.pause();this._playWhenLoaded=!1;this._state=2;this._startOffset=null;this._suspendInstanceEvents||this._onStop();return!0},setExternalNodes:function(){},clearExternalNodes:function(){},getExternalNodes:function(){return[null,null]},_onLoadedMetadata:function(){this.source.removeEventListener("loadedmetadata",this._loadedMetadataHandler);this._isReady=!0;var b=this._startOffset%this.duration||0,b=(this._startTime+ b)%this._sound.duration||0;this._startOffset=null;this.source.currentTime=b},_createSource:function(){this._sound&&this._sound.audio&&(this._isReady=!1,this.source=this._sound.audio.cloneNode(!0),this.source.addEventListener("loadedmetadata",this._loadedMetadataHandler),this.source.addEventListener("timeupdate",this._timeUpdateHandler),this.source.onended=this._endedHandler);return this.source},_onTimeUpdate:function(){this._duration&&this.source.currentTime>((this._startTime+this._duration)%this.source.duration|| 0)&&(this.loop?this.source.currentTime=this._startTime%this.source.duration||0:(this.source.removeEventListener("timeupdate",this._timeUpdateHandler),this.source.pause(),this._onEnded()))},_onManagerDestroy:function(){this.source&&this.source.pause()}}),Object.defineProperty(f.prototype,"volume",{get:function(){return this._volume},set:function(b){this._volume=b=pc.math.clamp(b,0,1);this.source&&(this.source.volume=b*this._manager.volume)}}),Object.defineProperty(f.prototype,"pitch",{get:function(){return this._pitch}, set:function(b){this._pitch=Math.max(Number(b)||0,.01);this.source&&(this.source.playbackRate=this._pitch)}}),Object.defineProperty(f.prototype,"loop",{get:function(){return this._loop},set:function(b){this._loop=!!b;this.source&&(this.source.loop=this._loop)}}),Object.defineProperty(f.prototype,"sound",{get:function(){return this._sound},set:function(b){this.stop();this._sound=b}}),Object.defineProperty(f.prototype,"currentTime",{get:function(){return null!==this._startOffset?this._startOffset:2!== this._state&&this.source?this.source.currentTime-this._startTime:0},set:function(b){0>b||(this._startOffset=b,this.source&&this._isReady&&(this.source.currentTime=(this._startTime+(b%this.duration||0))%this._sound.duration||0,this._startOffset=null))}})):f=function(){};Object.assign(f.prototype,{_onPlay:function(){this.fire("play");this._onPlayCallback&&this._onPlayCallback(this)},_onPause:function(){this.fire("pause");this._onPauseCallback&&this._onPauseCallback(this)},_onResume:function(){this.fire("resume"); this._onResumeCallback&&this._onResumeCallback(this)},_onStop:function(){this.fire("stop");this._onStopCallback&&this._onStopCallback(this)},_onEnded:function(){this._suspendEndEvent?this._suspendEndEvent=!1:(this.fire("end"),this._onEndCallback&&this._onEndCallback(this),this.stop())},_onManagerVolumeChange:function(){this.volume=this._volume},_onManagerSuspend:function(){0!==this._state||this._suspended||(this._suspended=!0,this.pause())},_onManagerResume:function(){this._suspended&&(this._suspended= !1,this.resume())}});Object.defineProperty(f.prototype,"startTime",{get:function(){return this._startTime},set:function(b){this._startTime=Math.max(0,Number(b)||0);b=0===this._state;this.stop();b&&this.play()}});Object.defineProperty(f.prototype,"duration",{get:function(){return this._sound?this._duration?this._duration%this._sound.duration||0:this._sound.duration:0},set:function(b){this._duration=Math.max(0,Number(b)||0);b=0===this._state;this.stop();b&&this.play()}});Object.defineProperty(f.prototype, "isPlaying",{get:function(){return 0===this._state}});Object.defineProperty(f.prototype,"isPaused",{get:function(){return 1===this._state}});Object.defineProperty(f.prototype,"isStopped",{get:function(){return 2===this._state}});Object.defineProperty(f.prototype,"isSuspended",{get:function(){return this._suspended}});return{SoundInstance:f}}());Object.assign(pc,function(){var f;if(pc.SoundManager.hasAudioContext())f=function(a,b,d){pc.SoundInstance.call(this,a,b,d);d=d||{};this._position=new pc.Vec3;d.position&&(this.position=d.position);this._velocity=new pc.Vec3;d.velocity&&(this.velocity=d.velocity);this.maxDistance=void 0!==d.maxDistance?Number(d.maxDistance):1E4;this.refDistance=void 0!==d.refDistance?Number(d.refDistance):1;this.rollOffFactor=void 0!==d.rollOffFactor?Number(d.rollOffFactor):1;this.distanceModel=void 0!==d.distanceModel? d.distanceModel:pc.DISTANCE_LINEAR},f.prototype=Object.create(pc.SoundInstance.prototype),f.prototype.constructor=f,Object.assign(f.prototype,{_initializeNodes:function(){this.gain=this._manager.context.createGain();this.panner=this._manager.context.createPanner();this.panner.connect(this.gain);this._inputNode=this.panner;this._connectorNode=this.gain;this._connectorNode.connect(this._manager.context.destination)}}),Object.defineProperty(f.prototype,"position",{get:function(){return this._position}, set:function(a){this._position.copy(a);this.panner.setPosition(a.x,a.y,a.z)}}),Object.defineProperty(f.prototype,"velocity",{get:function(){return this._velocity},set:function(a){this._velocity.copy(a);this.panner.setVelocity(a.x,a.y,a.z)}}),Object.defineProperty(f.prototype,"maxDistance",{get:function(){return this.panner.maxDistance},set:function(a){this.panner.maxDistance=a}}),Object.defineProperty(f.prototype,"refDistance",{get:function(){return this.panner.refDistance},set:function(a){this.panner.refDistance= a}}),Object.defineProperty(f.prototype,"rollOffFactor",{get:function(){return this.panner.rolloffFactor},set:function(a){this.panner.rolloffFactor=a}}),Object.defineProperty(f.prototype,"distanceModel",{get:function(){return this.panner.distanceModel},set:function(a){this.panner.distanceModel=a}});else if(pc.SoundManager.hasAudio()){var b=new pc.Vec3;f=function(a,b,d){pc.SoundInstance.call(this,a,b,d);d=d||{};this._position=new pc.Vec3;d.position&&(this.position=d.position);this._velocity=new pc.Vec3; d.velocity&&(this.velocity=d.velocity);this._maxDistance=void 0!==d.maxDistance?Number(d.maxDistance):1E4;this._refDistance=void 0!==d.refDistance?Number(d.refDistance):1;this._rollOffFactor=void 0!==d.rollOffFactor?Number(d.rollOffFactor):1;this._distanceModel=void 0!==d.distanceModel?d.distanceModel:pc.DISTANCE_LINEAR};f.prototype=Object.create(pc.SoundInstance.prototype);f.prototype.constructor=f;Object.defineProperty(f.prototype,"position",{get:function(){return this._position},set:function(a){this._position.copy(a); if(this.source){var c=this._manager.listener.getPosition();a=this.refDistance;var d=this.maxDistance,e=this.rollOffFactor,g=this.distanceModel;b=b.sub2(c,this._position);c=b.length();if(cd)a=0;else{var f=0;g===pc.DISTANCE_LINEAR?f=1-e*(c-a)/(d-a):g===pc.DISTANCE_INVERSE?f=a/(a+e*(c-a)):g===pc.DISTANCE_EXPONENTIAL&&(f=Math.pow(c/a,-e));a=pc.math.clamp(f,0,1)}this.source.volume=this.volume*a*this._manager.volume}}});Object.defineProperty(f.prototype,"velocity",{get:function(){return this._velocity}, set:function(a){this._velocity.copy(a)}});Object.defineProperty(f.prototype,"maxDistance",{get:function(){return this._maxDistance},set:function(a){this._maxDistance=a}});Object.defineProperty(f.prototype,"refDistance",{get:function(){return this._refDistance},set:function(a){this._refDistance=a}});Object.defineProperty(f.prototype,"rollOffFactor",{get:function(){return this._rollOffFactor},set:function(a){this._rollOffFactor=a}});Object.defineProperty(f.prototype,"distanceModel",{get:function(){return this._distanceModel}, set:function(a){this._distanceModel=a}})}else f=function(){};return{SoundInstance3d:f}}());Object.assign(pc,function(){var f;pc.AudioManager.hasAudioContext()?(f=function(b,a,c){c=c||{};this.volume=void 0===c.volume?1:c.volume;this.loop=void 0===c.loop?!1:c.loop;this.pitch=void 0===c.pitch?1:c.pitch;this.sound=a;this.suspended=this.paused=!1;this.startOffset=this.startTime=0;this.manager=b;this.source=null;this.gain=b.context.createGain()},Object.assign(f.prototype,{play:function(){if(this.source)throw Error("Call stop() before calling play()");this._createSource();if(this.source&&(this.startTime= this.manager.context.currentTime,this.source.start(0,this.startOffset%this.source.buffer.duration),this.setVolume(this.volume),this.setLoop(this.loop),this.setPitch(this.pitch),this.manager.on("volumechange",this.onManagerVolumeChange,this),this.manager.on("suspend",this.onManagerSuspend,this),this.manager.on("resume",this.onManagerResume,this),this.manager.suspended))this.onManagerSuspend()},pause:function(){this.source&&(this.paused=!0,this.startOffset+=this.manager.context.currentTime-this.startTime, this.source.stop(0),this.source=null)},unpause:function(){this.source||!this.paused?console.warn("Call pause() before unpausing."):(this._createSource(),this.source&&(this.startTime=this.manager.context.currentTime,this.source.start(0,this.startOffset%this.source.buffer.duration),this.setVolume(this.volume),this.setLoop(this.loop),this.setPitch(this.pitch),this.paused=!1))},stop:function(){this.source&&(this.source.stop(0),this.source=null);this.manager.off("volumechange",this.onManagerVolumeChange, this);this.manager.off("suspend",this.onManagerSuspend,this);this.manager.off("resume",this.onManagerResume,this)},setLoop:function(b){this.loop=b;this.source&&(this.source.loop=b)},setVolume:function(b){this.volume=b=pc.math.clamp(b,0,1);this.gain&&(this.gain.gain.value=b*this.manager.volume)},setPitch:function(b){this.pitch=b;this.source&&(this.source.playbackRate.value=b)},isPlaying:function(){return!this.paused&&this.source.playbackState===this.source.PLAYING_STATE},getDuration:function(){return this.source? this.source.buffer.duration:0},_createSource:function(){var b=this.manager.context;this.sound.buffer&&(this.source=b.createBufferSource(),this.source.buffer=this.sound.buffer,this.source.connect(this.gain),this.gain.connect(b.destination),this.loop||(this.source.onended=this.pause.bind(this)))}})):pc.AudioManager.hasAudio()?(f=function(b,a,c){this.volume=c.volume||1;this.loop=c.loop||!1;this.sound=a;this.pitch=void 0!==c.pitch?c.pitch:1;this.suspended=this.paused=!1;this.manager=b;a.audio&&(this.source= a.audio.cloneNode(!1),this.source.pause())},Object.assign(f.prototype,{play:function(){this.source&&(this.paused=!1,this.setVolume(this.volume),this.setLoop(this.loop),this.setPitch(this.pitch),this.source.play());this.manager.on("volumechange",this.onManagerVolumeChange,this);this.manager.on("suspend",this.onManagerSuspend,this);this.manager.on("resume",this.onManagerResume,this);if(this.manager.suspended)this.onManagerSuspend()},pause:function(){this.source&&(this.paused=!0,this.source.pause())}, unpause:function(){this.source&&(this.paused=!1,this.source.play())},stop:function(){this.source&&this.source.pause();this.manager.off("volumechange",this.onManagerVolumeChange,this);this.manager.off("suspend",this.onManagerSuspend,this);this.manager.off("resume",this.onManagerResume,this)},setVolume:function(b){this.volume=b=pc.math.clamp(b,0,1);this.source&&(this.source.volume=b*this.manager.volume)},setLoop:function(b){this.loop=b;this.source&&(this.source.loop=b)},setPitch:function(b){this.pitch= b;this.source&&(this.source.playbackRate=b)},getDuration:function(){return this.source&&!isNaN(this.source.duration)?this.source.duration:0},isPlaying:function(){return!this.source.paused}})):f=function(){};Object.assign(f.prototype,{getVolume:function(){return this.volume},getLoop:function(){return this.loop},getPitch:function(){return this.pitch},onManagerVolumeChange:function(){this.setVolume(this.getVolume())},onManagerSuspend:function(){this.isPlaying()&&!this.suspended&&(this.suspended=!0,this.pause())}, onManagerResume:function(){this.suspended&&(this.suspended=!1,this.unpause())}});return{Channel:f}}());Object.assign(pc,function(){var f;if(pc.AudioManager.hasAudioContext())f=function(a,b,d){pc.Channel.call(this,a,b,d);this.position=new pc.Vec3;this.velocity=new pc.Vec3;this.panner=a.context.createPanner()},f.prototype=Object.create(pc.Channel.prototype),f.prototype.constructor=f,Object.assign(f.prototype,{getPosition:function(){return this.position},setPosition:function(a){this.position.copy(a);this.panner.setPosition(a.x,a.y,a.z)},getVelocity:function(){return this.velocity},setVelocity:function(a){this.velocity.copy(a); this.panner.setVelocity(a.x,a.y,a.z)},getMaxDistance:function(){return this.panner.maxDistance},setMaxDistance:function(a){this.panner.maxDistance=a},getMinDistance:function(){return this.panner.refDistance},setMinDistance:function(a){this.panner.refDistance=a},getRollOffFactor:function(){return this.panner.rolloffFactor},setRollOffFactor:function(a){this.panner.rolloffFactor=a},getDistanceModel:function(){return this.pannel.distanceModel},setDistanceModel:function(a){this.panner.distanceModel=a}, _createSource:function(){var a=this.manager.context;this.source=a.createBufferSource();this.source.buffer=this.sound.buffer;this.source.connect(this.panner);this.panner.connect(this.gain);this.gain.connect(a.destination);this.loop||(this.source.onended=this.pause.bind(this))}});else if(pc.AudioManager.hasAudio()){var b=new pc.Vec3;f=function(a,b){pc.Channel.call(this,a,b);this.position=new pc.Vec3;this.velocity=new pc.Vec3;this.maxDistance=1E4;this.rollOffFactor=this.minDistance=1;this.distanceModel= pc.DISTANCE_INVERSE};f.prototype=Object.create(pc.Channel.prototype);f.prototype.constructor=f;Object.assign(f.prototype,{getPosition:function(){return this.position},setPosition:function(a){this.position.copy(a);if(this.source){var c=this.manager.listener.getPosition();a=this.minDistance;var d=this.maxDistance,e=this.rollOffFactor,g=this.distanceModel;b=b.sub2(c,this.position);c=b.length();if(cd)a=0;else{var f=0;g===pc.DISTANCE_LINEAR?f=1-e*(c-a)/(d-a):g===pc.DISTANCE_INVERSE?f= a/(a+e*(c-a)):g===pc.DISTANCE_EXPONENTIAL&&(f=Math.pow(c/a,-e));a=pc.math.clamp(f,0,1)}d=this.getVolume();this.source.volume=d*a}},getVelocity:function(){return this.velocity},setVelocity:function(a){this.velocity.copy(a)},getMaxDistance:function(){return this.maxDistance},setMaxDistance:function(a){this.maxDistance=a},getMinDistance:function(){return this.minDistance},setMinDistance:function(a){this.minDistance=a},getRollOffFactor:function(){return this.rollOffFactor},setRollOffFactor:function(a){this.rollOffFactor= a},getDistanceModel:function(){return this.distanceModel},setDistanceModel:function(a){this.distanceModel=a}})}else f=function(){};return{Channel3d:f}}());(function(){var f={ACTION_MOUSE:"mouse",ACTION_KEYBOARD:"keyboard",ACTION_GAMEPAD:"gamepad",AXIS_MOUSE_X:"mousex",AXIS_MOUSE_Y:"mousey",AXIS_PAD_L_X:"padlx",AXIS_PAD_L_Y:"padly",AXIS_PAD_R_X:"padrx",AXIS_PAD_R_Y:"padry",AXIS_KEY:"key",EVENT_KEYDOWN:"keydown",EVENT_KEYUP:"keyup",EVENT_MOUSEDOWN:"mousedown",EVENT_MOUSEMOVE:"mousemove",EVENT_MOUSEUP:"mouseup",EVENT_MOUSEWHEEL:"mousewheel",EVENT_TOUCHSTART:"touchstart",EVENT_TOUCHEND:"touchend",EVENT_TOUCHMOVE:"touchmove",EVENT_TOUCHCANCEL:"touchcancel", KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ENTER:13,KEY_SHIFT:16,KEY_CONTROL:17,KEY_ALT:18,KEY_PAUSE:19,KEY_CAPS_LOCK:20,KEY_ESCAPE:27,KEY_SPACE:32,KEY_PAGE_UP:33,KEY_PAGE_DOWN:34,KEY_END:35,KEY_HOME:36,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_PRINT_SCREEN:44,KEY_INSERT:45,KEY_DELETE:46,KEY_0:48,KEY_1:49,KEY_2:50,KEY_3:51,KEY_4:52,KEY_5:53,KEY_6:54,KEY_7:55,KEY_8:56,KEY_9:57,KEY_SEMICOLON:59,KEY_EQUAL:61,KEY_A:65,KEY_B:66,KEY_C:67,KEY_D:68,KEY_E:69,KEY_F:70,KEY_G:71,KEY_H:72,KEY_I:73,KEY_J:74, KEY_K:75,KEY_L:76,KEY_M:77,KEY_N:78,KEY_O:79,KEY_P:80,KEY_Q:81,KEY_R:82,KEY_S:83,KEY_T:84,KEY_U:85,KEY_V:86,KEY_W:87,KEY_X:88,KEY_Y:89,KEY_Z:90,KEY_WINDOWS:91,KEY_CONTEXT_MENU:93,KEY_NUMPAD_0:96,KEY_NUMPAD_1:97,KEY_NUMPAD_2:98,KEY_NUMPAD_3:99,KEY_NUMPAD_4:100,KEY_NUMPAD_5:101,KEY_NUMPAD_6:102,KEY_NUMPAD_7:103,KEY_NUMPAD_8:104,KEY_NUMPAD_9:105,KEY_MULTIPLY:106,KEY_ADD:107,KEY_SEPARATOR:108,KEY_SUBTRACT:109,KEY_DECIMAL:110,KEY_DIVIDE:111,KEY_F1:112,KEY_F2:113,KEY_F3:114,KEY_F4:115,KEY_F5:116,KEY_F6:117, KEY_F7:118,KEY_F8:119,KEY_F9:120,KEY_F10:121,KEY_F11:122,KEY_F12:123,KEY_COMMA:188,KEY_PERIOD:190,KEY_SLASH:191,KEY_OPEN_BRACKET:219,KEY_BACK_SLASH:220,KEY_CLOSE_BRACKET:221,KEY_META:224,MOUSEBUTTON_NONE:-1,MOUSEBUTTON_LEFT:0,MOUSEBUTTON_MIDDLE:1,MOUSEBUTTON_RIGHT:2,PAD_1:0,PAD_2:1,PAD_3:2,PAD_4:3,PAD_FACE_1:0,PAD_FACE_2:1,PAD_FACE_3:2,PAD_FACE_4:3,PAD_L_SHOULDER_1:4,PAD_R_SHOULDER_1:5,PAD_L_SHOULDER_2:6,PAD_R_SHOULDER_2:7,PAD_SELECT:8,PAD_START:9,PAD_L_STICK_BUTTON:10,PAD_R_STICK_BUTTON:11,PAD_UP:12, PAD_DOWN:13,PAD_LEFT:14,PAD_RIGHT:15,PAD_VENDOR:16,PAD_L_STICK_X:0,PAD_L_STICK_Y:1,PAD_R_STICK_X:2,PAD_R_STICK_Y:3};Object.assign(pc,f);pc.input={};Object.assign(pc.input,f)})();Object.assign(pc,function(){var f=function(a,b){var c={x:0,y:0};if(b){if(b instanceof f)throw Error("Expected MouseEvent");c=a._getTargetCoords(b)}else b={};if(c)this.x=c.x,this.y=c.y;else if(pc.Mouse.isPointerLocked())this.y=this.x=0;else return;this.wheel=b.detail?-1*b.detail:b.wheelDelta?b.wheelDelta/120:0;pc.Mouse.isPointerLocked()?(this.dx=b.movementX||b.webkitMovementX||b.mozMovementX||0,this.dy=b.movementY||b.webkitMovementY||b.mozMovementY||0):(this.dx=this.x-a._lastX,this.dy=this.y-a._lastY); this.button="mousedown"===b.type||"mouseup"===b.type?b.button:pc.MOUSEBUTTON_NONE;this.buttons=a._buttons.slice(0);this.element=b.target;this.ctrlKey=b.ctrlKey||!1;this.altKey=b.altKey||!1;this.shiftKey=b.shiftKey||!1;this.metaKey=b.metaKey||!1;this.event=b},b=function(a){this._lastY=this._lastX=0;this._buttons=[!1,!1,!1];this._lastbuttons=[!1,!1,!1];this._upHandler=this._handleUp.bind(this);this._downHandler=this._handleDown.bind(this);this._moveHandler=this._handleMove.bind(this);this._wheelHandler= this._handleWheel.bind(this);this._contextMenuHandler=function(a){a.preventDefault()};this._target=null;this._attached=!1;this.attach(a);pc.events.attach(this)};b.isPointerLocked=function(){return!!(document.pointerLockElement||document.mozPointerLockElement||document.webkitPointerLockElement)};Object.assign(b.prototype,{attach:function(a){this._target=a;this._attached||(this._attached=!0,window.addEventListener("mouseup",this._upHandler,!1),window.addEventListener("mousedown",this._downHandler,!1), window.addEventListener("mousemove",this._moveHandler,!1),window.addEventListener("mousewheel",this._wheelHandler,!1),window.addEventListener("DOMMouseScroll",this._wheelHandler,!1))},detach:function(){this._attached&&(this._attached=!1,this._target=null,window.removeEventListener("mouseup",this._upHandler),window.removeEventListener("mousedown",this._downHandler),window.removeEventListener("mousemove",this._moveHandler),window.removeEventListener("mousewheel",this._wheelHandler),window.removeEventListener("DOMMouseScroll", this._wheelHandler))},disableContextMenu:function(){this._target&&this._target.addEventListener("contextmenu",this._contextMenuHandler)},enableContextMenu:function(){this._target&&this._target.removeEventListener("contextmenu",this._contextMenuHandler)},enablePointerLock:function(a,b){if(document.body.requestPointerLock){var c=function(){a();document.removeEventListener("pointerlockchange",c)},e=function(){b();document.removeEventListener("pointerlockerror",e)};a&&document.addEventListener("pointerlockchange", c,!1);b&&document.addEventListener("pointerlockerror",e,!1);document.body.requestPointerLock()}else b&&b()},disablePointerLock:function(a){if(document.exitPointerLock){var b=function(){a();document.removeEventListener("pointerlockchange",b)};a&&document.addEventListener("pointerlockchange",b,!1);document.exitPointerLock()}},update:function(){this._lastbuttons[0]=this._buttons[0];this._lastbuttons[1]=this._buttons[1];this._lastbuttons[2]=this._buttons[2]},isPressed:function(a){return this._buttons[a]}, wasPressed:function(a){return this._buttons[a]&&!this._lastbuttons[a]},wasReleased:function(a){return!this._buttons[a]&&this._lastbuttons[a]},_handleUp:function(a){this._buttons[a.button]=!1;a=new f(this,a);a.event&&this.fire(pc.EVENT_MOUSEUP,a)},_handleDown:function(a){this._buttons[a.button]=!0;a=new f(this,a);a.event&&this.fire(pc.EVENT_MOUSEDOWN,a)},_handleMove:function(a){a=new f(this,a);a.event&&(this.fire(pc.EVENT_MOUSEMOVE,a),this._lastX=a.x,this._lastY=a.y)},_handleWheel:function(a){a=new f(this, a);a.event&&this.fire(pc.EVENT_MOUSEWHEEL,a)},_getTargetCoords:function(a){var b=this._target.getBoundingClientRect(),d=Math.floor(b.left),b=Math.floor(b.top);return a.clientX=d+this._target.clientWidth||a.clientY=b+this._target.clientHeight?null:{x:a.clientX-d,y:a.clientY-b}}});return{Mouse:b,MouseEvent:f}}());Object.assign(pc,function(){function f(a){c.key=a.keyCode;c.element=a.target;c.event=a;return c}function b(a){return"string"===typeof a?a.toUpperCase().charCodeAt(0):a}var a=function(a,b){b?(this.key=b.keyCode,this.element=b.target,this.event=b):this.event=this.element=this.key=null},c=new a,d={9:"Tab",13:"Enter",16:"Shift",17:"Control",18:"Alt",27:"Escape",37:"Left",38:"Up",39:"Right",40:"Down",46:"Delete",91:"Win"},e=function(a,b){b=b||{};this._element=null;this._keyDownHandler=this._handleKeyDown.bind(this); this._keyUpHandler=this._handleKeyUp.bind(this);this._keyPressHandler=this._handleKeyPress.bind(this);pc.events.attach(this);this._keymap={};this._lastmap={};a&&this.attach(a);this.preventDefault=b.preventDefault||!1;this.stopPropagation=b.stopPropagation||!1};e.prototype.attach=function(a){this._element&&this.detach();this._element=a;this._element.addEventListener("keydown",this._keyDownHandler,!1);this._element.addEventListener("keypress",this._keyPressHandler,!1);this._element.addEventListener("keyup", this._keyUpHandler,!1)};e.prototype.detach=function(){this._element.removeEventListener("keydown",this._keyDownHandler);this._element.removeEventListener("keypress",this._keyPressHandler);this._element.removeEventListener("keyup",this._keyUpHandler);this._element=null};e.prototype.toKeyIdentifier=function(a){a=b(a);var c,e;if(c=d[a.toString()])return c;c=a.toString(16).toUpperCase();e=c.length;for(a=0;a<4-e;a++)c="0"+c;return"U+"+c};e.prototype._handleKeyDown=function(a){var b=a.keyCode||a.charCode; void 0!==b&&(b=this.toKeyIdentifier(b),this._keymap[b]=!0,this.fire("keydown",f(a)),this.preventDefault&&a.preventDefault(),this.stopPropagation&&a.stopPropagation())};e.prototype._handleKeyUp=function(a){var b=a.keyCode||a.charCode;void 0!==b&&(b=this.toKeyIdentifier(b),delete this._keymap[b],this.fire("keyup",f(a)),this.preventDefault&&a.preventDefault(),this.stopPropagation&&a.stopPropagation())};e.prototype._handleKeyPress=function(a){this.fire("keypress",f(a));this.preventDefault&&a.preventDefault(); this.stopPropagation&&a.stopPropagation()};e.prototype.update=function(){for(var a in this._lastmap)delete this._lastmap[a];for(a in this._keymap)this._keymap.hasOwnProperty(a)&&(this._lastmap[a]=this._keymap[a])};e.prototype.isPressed=function(a){a=b(a);a=this.toKeyIdentifier(a);return!!this._keymap[a]};e.prototype.wasPressed=function(a){a=b(a);a=this.toKeyIdentifier(a);return!!this._keymap[a]&&!this._lastmap[a]};e.prototype.wasReleased=function(a){a=b(a);a=this.toKeyIdentifier(a);return!this._keymap[a]&& !!this._lastmap[a]};return{Keyboard:e,KeyboardEvent:a}}());Object.assign(pc,function(){var f=function(){this.gamepadsSupported=!!navigator.getGamepads||!!navigator.webkitGetGamepads;this.current=[];this.previous=[];this.deadZone=.25},b={DEFAULT:{buttons:"PAD_FACE_1 PAD_FACE_2 PAD_FACE_3 PAD_FACE_4 PAD_L_SHOULDER_1 PAD_R_SHOULDER_1 PAD_L_SHOULDER_2 PAD_R_SHOULDER_2 PAD_SELECT PAD_START PAD_L_STICK_BUTTON PAD_R_STICK_BUTTON PAD_UP PAD_DOWN PAD_LEFT PAD_RIGHT PAD_VENDOR".split(" "),axes:["PAD_L_STICK_X","PAD_L_STICK_Y","PAD_R_STICK_X","PAD_R_STICK_Y"]},PS3:{buttons:"PAD_FACE_1 PAD_FACE_2 PAD_FACE_4 PAD_FACE_3 PAD_L_SHOULDER_1 PAD_R_SHOULDER_1 PAD_L_SHOULDER_2 PAD_R_SHOULDER_2 PAD_SELECT PAD_START PAD_L_STICK_BUTTON PAD_R_STICK_BUTTON PAD_UP PAD_DOWN PAD_LEFT PAD_RIGHT PAD_VENDOR".split(" "), axes:["PAD_L_STICK_X","PAD_L_STICK_Y","PAD_R_STICK_X","PAD_R_STICK_Y"]}},a={"Product: 0268":"PS3"};Object.assign(f.prototype,{update:function(){var a,b,e,g,f;a=0;for(e=this.current.length;aMath.abs(a)&&(a=e)}else this._axesValues[b]&&Math.abs(this._axesValues[b][c])>Math.abs(a)&&(a=this._axesValues[b][c])}return a};f.prototype._enableMouse=function(){this._mouse=new pc.Mouse;if(!this._element)throw Error("Controller must be attached to an Element");this._mouse.attach(this._element)}; f.prototype._enableKeyboard=function(){this._keyboard=new pc.Keyboard;if(!this._element)throw Error("Controller must be attached to an Element");this._keyboard.attach(this._element)};return{Controller:f}}());Object.assign(pc,function(){var f,b,a=new pc.Vec3,c=new pc.Vec3,d=new pc.Vec3,e=new pc.Vec3,g=new pc.Vec3,l=new pc.Vec3,k=new pc.Vec3,p=new pc.Vec3,h=new pc.Vec3,n=new pc.Vec2,q=new pc.Vec3,m=new pc.Vec3,r=new pc.Vec3,t=new pc.Vec3,v=new pc.Vec3,y=new pc.Vec3,u=new pc.Vec3,w=new pc.Vec3,x=new pc.Vec4,D=function(a,b,c){d.sub2(b,a);e.sub2(c[0],a);g.sub2(c[1],a);l.sub2(c[2],a);p.cross(l,d);if(0<=e.dot(p)){if(0>-g.dot(p)||0>h.cross(d,g).dot(e))return!1}else if(k.sub2(c[3],a),0>k.dot(p)||0>h.cross(d,e).dot(k))return!1; return 1E-8>d.sub2(c[0],c[2]).lengthSq()||1E-8>d.sub2(c[1],c[3]).lengthSq()?!1:!0},z=function(a,b,c){this.event=a;this.element=b;this.camera=c;this._stopPropagation=!1};Object.assign(z.prototype,{stopPropagation:function(){this._stopPropagation=!0;this.event.stopImmediatePropagation();this.event.stopPropagation()}});var C=function(a,b,c,d,e,g,f){z.call(this,a,b,c);this.x=d;this.y=e;this.ctrlKey=a.ctrlKey||!1;this.altKey=a.altKey||!1;this.shiftKey=a.shiftKey||!1;this.metaKey=a.metaKey||!1;this.button= a.button;pc.Mouse.isPointerLocked()?(this.dx=a.movementX||a.webkitMovementX||a.mozMovementX||0,this.dy=a.movementY||a.webkitMovementY||a.mozMovementY||0):(this.dx=d-g,this.dy=e-f);this.wheel=a.detail?-1*a.detail:a.wheelDelta?a.wheelDelta/120:0};C.prototype=Object.create(z.prototype);C.prototype.constructor=C;var A=function(a,b,c,d,e,g){z.call(this,a,b,c);this.touches=a.touches;this.changedTouches=a.changedTouches;this.x=d;this.y=e};A.prototype=Object.create(z.prototype);A.prototype.constructor=A; var B=function(a,b){this._app=null;this._attached=!1;this._target=null;this._enabled=!0;this._lastY=this._lastX=0;this._upHandler=this._handleUp.bind(this);this._downHandler=this._handleDown.bind(this);this._moveHandler=this._handleMove.bind(this);this._wheelHandler=this._handleWheel.bind(this);this._touchstartHandler=this._handleTouchStart.bind(this);this._touchcancelHandler=this._touchendHandler=this._handleTouchEnd.bind(this);this._touchmoveHandler=this._handleTouchMove.bind(this);this._sortHandler= this._sortElements.bind(this);this._elements=[];this._pressedElement=this._hoveredElement=null;this._touchedElements={};this._touchesForWhichTouchLeaveHasFired={};this._useMouse=!b||!1!==b.useMouse;this._useTouch=!b||!1!==b.useTouch;pc.platform.touch&&(this._clickedEntities={});this.attach(a,b)};Object.assign(B.prototype,{attach:function(a){this._attached&&(this._attached=!1,this.detach());this._target=a;this._attached=!0;this._useMouse&&(window.addEventListener("mouseup",this._upHandler,{passive:!0}), window.addEventListener("mousedown",this._downHandler,{passive:!0}),window.addEventListener("mousemove",this._moveHandler,{passive:!0}),window.addEventListener("mousewheel",this._wheelHandler,{passive:!0}),window.addEventListener("DOMMouseScroll",this._wheelHandler,{passive:!0}));this._useTouch&&pc.platform.touch&&(this._target.addEventListener("touchstart",this._touchstartHandler,{passive:!0}),this._target.addEventListener("touchend",this._touchendHandler,!1),this._target.addEventListener("touchmove", this._touchmoveHandler,!1),this._target.addEventListener("touchcancel",this._touchcancelHandler,!1))},detach:function(){this._attached&&(this._attached=!1,this._useMouse&&(window.removeEventListener("mouseup",this._upHandler,!1),window.removeEventListener("mousedown",this._downHandler,!1),window.removeEventListener("mousemove",this._moveHandler,!1),window.removeEventListener("mousewheel",this._wheelHandler,!1),window.removeEventListener("DOMMouseScroll",this._wheelHandler,!1)),this._useTouch&&(this._target.removeEventListener("touchstart", this._touchstartHandler,!1),this._target.removeEventListener("touchend",this._touchendHandler,!1),this._target.removeEventListener("touchmove",this._touchmoveHandler,!1),this._target.removeEventListener("touchcancel",this._touchcancelHandler,!1)),this._target=null)},addElement:function(a){-1===this._elements.indexOf(a)&&this._elements.push(a)},removeElement:function(a){a=this._elements.indexOf(a);-1!==a&&this._elements.splice(a,1)},_handleUp:function(a){this._enabled&&!pc.Mouse.isPointerLocked()&& (this._calcMouseCoords(a),null!==f&&this._onElementMouseEvent(a))},_handleDown:function(a){this._enabled&&!pc.Mouse.isPointerLocked()&&(this._calcMouseCoords(a),null!==f&&this._onElementMouseEvent(a))},_handleMove:function(a){this._enabled&&(this._calcMouseCoords(a),null!==f&&(this._onElementMouseEvent(a),this._lastX=f,this._lastY=b))},_handleWheel:function(a){this._enabled&&(this._calcMouseCoords(a),null!==f&&this._onElementMouseEvent(a))},_determineTouchedElements:function(a){var b={},c=this.app.systems.camera.cameras, d,e,g;for(d=c.length-1;0<=d;d--){var f=c[d],l=0;e=0;for(g=a.changedTouches.length;e=d+this._target.clientWidth||a.clientY=c+this._target.clientHeight?b=f=null:(f=a.clientX-d,b=a.clientY-c)},_calcTouchCoords:function(a){for(var b=0,c=0,d=a.target;!(d instanceof HTMLElement);)d=d.parentNode;do b+=d.offsetLeft-d.scrollLeft,c+=d.offsetTop-d.scrollTop,d=d.offsetParent;while(d);return{x:a.pageX-b,y:a.pageY-c}},_sortElements:function(a,b){var c=this.app.scene.layers.sortTransparentLayers(a.layers,b.layers);return 0!== c?c:a.screen&&!b.screen?-1:!a.screen&&b.screen?1:a.screen||b.screen?a.screen.screen.screenSpace&&!b.screen.screen.screenSpace?-1:b.screen.screen.screenSpace&&!a.screen.screen.screenSpace?1:b.drawOrder-a.drawOrder:0},_getTargetElement:function(a,b,c){var d=null;this._elements.sort(this._sortHandler);for(var e=0,g=this._elements.length;e=p&&b<=p+k&&d<=g&&d>=m&&(b=f*(b-p)/k,d=l-l*(d-m)/h,f=this._calculateScaleToScreen(e),e=this._buildHitCorners(e,e.screenCorners,f.x,f.y),a.set(b,d,1),c.set(b,d,-1),D(a, c,e))?!0:!1},_checkElement3d:function(b,d,e,g){if(e.maskedBy&&!this._checkElement3d(b,d,e.maskedBy.element,g))return!1;var f=this._target.clientWidth,l=this._target.clientHeight,k=g.rect.z*f,h=g.rect.w*l,p=g.rect.x*f,m=(1-g.rect.y)*l,n=m-h,q=d;return b>=p&&b<=p+k&&d<=m&&q>=n&&(b=f*(b-p)/k,q=l*(q-n)/h,l=e.entity.getWorldTransform().getScale(),e=this._buildHitCorners(e,e.worldCorners,l.x,l.y),g.screenToWorld(b,q,g.nearClip,a),g.screenToWorld(b,q,g.farClip,c),D(a,c,e))?!0:!1}});Object.defineProperty(B.prototype, "enabled",{get:function(){return this._enabled},set:function(a){this._enabled=a}});Object.defineProperty(B.prototype,"app",{get:function(){return this._app||pc.app},set:function(a){this._app=a}});return{ElementInput:B,ElementInputEvent:z,ElementMouseEvent:C,ElementTouchEvent:A}}());Object.assign(pc,function(){var f=function(b){pc.events.attach(this);var a=this;this.isSupported=f.isSupported;this.usesPolyfill=f.usesPolyfill;window.InitializeWebVRPolyfill&&window.InitializeWebVRPolyfill();this._index={};this.displays=[];this.display=null;this._app=b;this._onDisplayConnect=this._onDisplayConnect.bind(this);this._onDisplayDisconnect=this._onDisplayDisconnect.bind(this);a._attach();this._getDisplays(function(b,d){if(b)a.fire("error",b);else{for(var c=0;c=c.length){for(a=0;a=a?0:1});b(["fr"],function(a){return 0<=a&&2>a?0:1});b("de en it el es tr".split(" "),function(a){return 1===a?0:1});b(["ru","uk"],function(a){if(Number.isInteger(a)){var b= a%10;a%=100;if(1===b&&11!==a)return 0;if(2<=b&&4>=b&&(12>a||14=b||11<=a&&14>=a)return 2}return 3});b(["ar"],function(a){if(0===a)return 0;if(1===a)return 1;if(2===a)return 2;if(Number.isInteger(a)){a%=100;if(3<=a&&10>=a)return 3;if(11<=a&&99>=a)return 4}return 5});b=function(a){pc.events.attach(this);this.locale="en-US";this._translations={};this._availableLangs={};this._app=a;this._assets=[];this._parser=new pc.I18nParser};b.prototype.getText=function(b,c){var d=b, e;c||(c=this._locale,e=this._lang);var g=this._translations[c];g||(e||(e=a(c)),c=this._findFallbackLocale(e),g=this._translations[c]);g&&((d=g[b])?Array.isArray(d)&&(d=d[0]||""):d=b);return d};b.prototype.getPluralText=function(b,d,l){var e=b,g,h;l?(h=a(l),g=f[h]||c):(l=this._locale,h=this._lang,g=this._pluralFn);l=this._translations[l];l||(l=this._findFallbackLocale(h),g=f[h]||c,l=this._translations[l]);l&&l[b]&&(d=g(d),e=l[b][d]||b);return e};b.prototype.addData=function(b){var c;try{c=this._parser.parse(b)}catch(n){console.error(n); return}b=0;for(var d=c.length;bv)))for(v=(y=l[w])?t.instances.visibleTransparent[v]:t.instances.visibleOpaque[v],y=v.length,v=v.list,t=0;td._timeToCountFrames?(d.fps=d._fpsAccum,d._fpsAccum=0,d._timeToCountFrames=a+1E3):d._fpsAccum++;d.cameras=this.renderer._camerasRendered;d.materials=this.renderer._materialSwitches; d.shaders=this.graphicsDevice._shaderSwitchesPerFrame;d.shadowMapUpdates=this.renderer._shadowMapUpdates;d.shadowMapTime=this.renderer._shadowMapTime;d.depthMapTime=this.renderer._depthMapTime;d.forwardTime=this.renderer._forwardTime;a=this.graphicsDevice._primsPerFrame;d.triangles=a[pc.PRIMITIVE_TRIANGLES]/3+Math.max(a[pc.PRIMITIVE_TRISTRIP]-2,0)+Math.max(a[pc.PRIMITIVE_TRIFAN]-2,0);d.cullTime=this.renderer._cullTime;d.sortTime=this.renderer._sortTime;d.skinTime=this.renderer._skinTime;d.morphTime= this.renderer._morphTime;d.instancingTime=this.renderer._instancingTime;for(b=d.otherPrimitives=0;bc/d?(a=c,b=a/e):(b=d,a=b*e)}else this._fillMode===pc.FILLMODE_FILL_WINDOW&&(a=c,b=d);this.graphicsDevice.canvas.style.width=a+"px";this.graphicsDevice.canvas.style.height=b+"px";this._resolutionMode===pc.RESOLUTION_AUTO&&this.setCanvasResolution(pc.RESOLUTION_AUTO)}return{width:a,height:b}}},onLibrariesLoaded:function(){this._librariesLoaded= !0;this.systems.rigidbody.onLibraryLoaded();this.systems.collision.onLibraryLoaded()},applySceneSettings:function(a){var b;this.systems.rigidbody&&"undefined"!==typeof Ammo&&(b=a.physics.gravity,this.systems.rigidbody.setGravity(b[0],b[1],b[2]));this.scene.applySettings(a);if(a.render.hasOwnProperty("skybox"))if(a.render.skybox)if(b=this.assets.get(a.render.skybox))this.setSkybox(b);else this.assets.once("add:"+a.render.skybox,this.setSkybox,this);else this.setSkybox(null)},setSkybox:function(a){a? this._skyboxLast===a.id?0!==this.scene.skyboxMip||a.loadFaces?this._onSkyboxChange(a):this._skyboxLoad(a):(this._skyboxLast&&(this.assets.off("add:"+this._skyboxLast,this.setSkybox,this),this.assets.off("load:"+this._skyboxLast,this._onSkyboxChange,this),this.assets.off("remove:"+this._skyboxLast,this._skyboxRemove,this)),this._skyboxLast=a.id,this.assets.on("load:"+a.id,this._onSkyboxChange,this),this.assets.once("remove:"+a.id,this._skyboxRemove,this),a.resource&&this.scene.setSkybox(a.resources), this._skyboxLoad(a)):this._skyboxLast&&this._skyboxRemove({id:this._skyboxLast})},_onVrChange:function(a){a?this.vr||(this.vr=new pc.VrManager(this)):this.vr&&(this.vr.destroy(),this.vr=null)},_onSkyboxChange:function(a){this.scene.setSkybox(a.resources)},_skyboxLoad:function(a){0===this.scene.skyboxMip&&(a.loadFaces=!0);this.assets.load(a);this._onSkyboxChange(a)},_skyboxRemove:function(a){this._skyboxLast&&(this.assets.off("add:"+a.id,this.setSkybox,this),this.assets.off("load:"+a.id,this._onSkyboxChange, this),this.assets.off("remove:"+a.id,this._skyboxRemove,this),this.scene.setSkybox(null),this._skyboxLast=null)},_firstBake:function(){this.lightmapper.bake(null,this.scene.lightmapMode)},_firstBatch:function(){this.scene._needsStaticPrepare&&(this.renderer.prepareStaticMeshes(this.graphicsDevice,this.scene),this.scene._needsStaticPrepare=!1);this.batcher.generate()},destroy:function(){var a,b,c=this.graphicsDevice.canvas.id;this.off("librariesloaded");document.removeEventListener("visibilitychange", this._visibilityChangeHandler,!1);document.removeEventListener("mozvisibilitychange",this._visibilityChangeHandler,!1);document.removeEventListener("msvisibilitychange",this._visibilityChangeHandler,!1);document.removeEventListener("webkitvisibilitychange",this._visibilityChangeHandler,!1);this.onVisibilityChange=this._visibilityChangeHandler=null;this.root.destroy();this.root=null;this.mouse&&(this.mouse.off(),this.mouse.detach(),this.mouse=null);this.keyboard&&(this.keyboard.off(),this.keyboard.detach(), this.keyboard=null);this.touch&&(this.touch.off(),this.touch.detach(),this.touch=null);this.elementInput&&(this.elementInput.detach(),this.elementInput=null);this.controller&&(this.controller=null);var l=this.systems.list;a=0;for(b=l.length;ag.blendTimeRemaining&&(g.blendTimeRemaining=0),e.blend(g.fromSkel,g.toSkel,1-g.blendTimeRemaining/g.blendTime)):(e.addTime(a*g.speed),e._time!==e._animation.duration||g.loop||(g.playing=!1)),g.blending&&0===g.blendTimeRemaining&&(g.blending=!1,e.animation=g.toSkel._animation),e.updateGraph()))}}});return{AnimationComponentSystem:b}}());Object.assign(pc,function(){return{AnimationComponentData:function(){this.assets=[];this.speed=1;this.enabled=this.activate=this.loop=!0;this.animations={};this.toSkel=this.fromSkel=this.currAnim=this.prevAnim=this.model=this.skeleton=null;this.blending=!1;this.blendTimeRemaining=this.blendTime=0;this.playing=!1}}}());Object.assign(pc,function(){var f=function(b,a){pc.Component.call(this,b,a);this._type="asset";this._model=this._asset=null;this._mapping={};this._receiveShadows=this._castShadows=!0;this._materialAsset=null;this._material=b.defaultMaterial;this._castShadowsLightmap=!0;this._lightmapped=!1;this._lightmapSizeMultiplier=1;this._isStatic=!1;this._layers=[pc.LAYERID_WORLD];this._batchGroupId=-1;this._area=null;this._assetOld=0;this._materialEvents=null;this._clonedModel=this._dirtyMaterialAsset=this._dirtyModelAsset= !1};f.prototype=Object.create(pc.Component.prototype);f.prototype.constructor=f;Object.assign(f.prototype,{setVisible:function(b){console.warn("WARNING: setVisible: Function is deprecated. Set enabled property instead.");this.enabled=b},addModelToLayers:function(){for(var b,a=this.system.app.scene.layers,c=0;cthis.layers.indexOf(b.id)||b.addMeshInstances(this.meshInstances)},onLayerRemoved:function(b){0>this.layers.indexOf(b.id)|| b.removeMeshInstances(this.meshInstances)},_setMaterialEvent:function(b,a,c,d){a=a+":"+c;this.system.app.assets.on(a,d,this);this._materialEvents||(this._materialEvents=[]);this._materialEvents[b]||(this._materialEvents[b]={});this._materialEvents[b][a]={id:c,handler:d}},_unsetMaterialEvents:function(){var b=this.system.app.assets,a=this._materialEvents;if(a){for(var c=0,d=a.length;cb&&0<=this._batchGroupId&&this.enabled&&this.entity.enabled&&this.addModelToLayers();this._batchGroupId=b}}});Object.defineProperty(f.prototype,"materialAsset",{get:function(){return this._materialAsset},set:function(b){var a=b;b instanceof pc.Asset&&(a=b.id);b=this.system.app.assets;if(a!==this._materialAsset){if(this._materialAsset){b.off("add:"+ this._materialAsset,this._onMaterialAdded,this);var c=b.get(this._materialAsset);c&&this._unbindMaterialAsset(c)}(this._materialAsset=a)?(a=b.get(this._materialAsset))?this._bindMaterialAsset(a):(this.material=this.system.defaultMaterial,b.on("add:"+this._materialAsset,this._onMaterialAdded,this)):this.material=this.system.defaultMaterial}}});Object.defineProperty(f.prototype,"material",{get:function(){return this._material},set:function(b){if(this._material!==b){this._material=b;var a=this._model; if(a&&"asset"!==this._type)for(var a=a.meshInstances,c=0,d=a.length;cthis.layers.indexOf(b.id)||b.addCamera(this)},onLayerRemoved:function(b){0>this.layers.indexOf(b.id)||b.removeCamera(this)},updateClearFlags:function(){var b=0;this.clearColorBuffer&&(b|=pc.CLEARFLAG_COLOR);this.clearDepthBuffer&&(b|=pc.CLEARFLAG_DEPTH); this.clearStencilBuffer&&(b|=pc.CLEARFLAG_STENCIL);this.data.camera.clearFlags=b},onSetRenderTarget:function(b,a,c){this.data.camera.renderTarget=c},onSetRect:function(b,a,c){this.data.camera.setRect(c.x,c.y,c.z,c.w)},onSetScissorRect:function(b,a,c){this.data.camera.setScissorRect(c.x,c.y,c.z,c.w)},onEnable:function(){this.system.addCamera(this);this.system.app.scene.on("set:layers",this.onLayersChanged,this);this.system.app.scene.layers&&(this.system.app.scene.layers.on("add",this.onLayerAdded, this),this.system.app.scene.layers.on("remove",this.onLayerRemoved,this));this.enabled&&this.entity.enabled&&this.addCameraToLayers();this.postEffects.enable()},onDisable:function(){this.postEffects.disable();this.removeCameraFromLayers();this.system.app.scene.off("set:layers",this.onLayersChanged,this);this.system.app.scene.layers&&(this.system.app.scene.layers.off("add",this.onLayerAdded,this),this.system.app.scene.layers.off("remove",this.onLayerRemoved,this));this.system.removeCamera(this)},onRemove:function(){this.off()}, calculateAspectRatio:function(b){b=b?b:this.system.app.graphicsDevice;var a=this.rect;return b.width*a.z/(b.height*a.w)},frameBegin:function(b){this.aspectRatioMode===pc.ASPECT_AUTO&&(this.aspectRatio=this.calculateAspectRatio(b));this.data.isRendering=!0},frameEnd:function(){this.data.isRendering=!1},enterVr:function(b,a){b instanceof Function&&!a&&(a=b,b=null);if(this.system.app.vr)if(b||(b=this.system.app.vr.display),b){var c=this;b.capabilities.canPresent?b.requestPresent(function(d){d||(c.vrDisplay= b,c.vrDisplay.once("beforepresentchange",function(a){a.presenting||(c.vrDisplay=null)}));a(d)}):(c.vrDisplay=b,a())}else a("No pc.VrDisplay to present");else a("VrManager not created. Enable VR in project settings.")},exitVr:function(b){if(this.vrDisplay)if(this.vrDisplay.capabilities.canPresent){var a=this.vrDisplay;this.vrDisplay=null;a.exitPresent(b)}else this.vrDisplay=null,b();else b("Not presenting VR")}});return{CameraComponent:f}}());Object.assign(pc,function(){var f="enabled clearColorBuffer clearColor clearDepthBuffer clearStencilBuffer frustumCulling projection fov orthoHeight nearClip farClip priority rect scissorRect camera aspectRatio aspectRatioMode horizontalFov model renderTarget calculateTransform calculateProjection cullFaces flipFaces layers".split(" "),b=function(a){pc.ComponentSystem.call(this,a);this.id="camera";this.description="Renders the scene from the location of the Entity.";this.ComponentType=pc.CameraComponent; this.DataType=pc.CameraComponentData;this.schema=f;this.cameras=[];this.on("beforeremove",this.onBeforeRemove,this);this.on("remove",this.onRemove,this);pc.ComponentSystem.bind("update",this.onUpdate,this)};b.prototype=Object.create(pc.ComponentSystem.prototype);b.prototype.constructor=b;pc.Component._buildAccessors(pc.CameraComponent.prototype,f);Object.assign(b.prototype,{initializeComponentData:function(a,b,d){d="postEffects enabled model camera aspectRatio aspectRatioMode horizontalFov renderTarget clearColor fov orthoHeight nearClip farClip projection priority clearColorBuffer clearDepthBuffer clearStencilBuffer frustumCulling rect scissorRect calculateTransform calculateProjection cullFaces flipFaces layers".split(" "); for(var c={},g=0,f=d.length;gthis._postEffectCombined)n.setup&&n.setup(q,n,d,null,this.renderTarget);else{var g;g=this._postEffectCombinedSrc?this._postEffectCombinedSrc:n.srcRenderTarget?n.srcRenderTarget:b[this._backbufferRtId];1F;F++)b[F]=new pc.RenderTarget({depth:!0,stencil:q.supportsStencil,samples:H,autoResolve:!1}),b[F].name="backbuffer"+F;f.on("prerender",function(){var a=f.scene.layers.layerList,c,d,e=0,h=0;p=k=l=!1;var n=pc.PIXELFORMAT_R8_G8_B8_A8;if(f.scene.layers._dirty){var E=0,H,G;for(c=0;c=e;d--)a[d].renderTarget||(a[d].renderTarget=b[h]);a[c]._backbufferRtId= h;e=c;l=!0;1===h&&(k=!0);a[c].postEffect.hdr&&(n=q.webgl2&&q.textureFloatRenderable?pc.PIXELFORMAT_111110F:q.extTextureHalfFloatLinear&&q.textureHalfFloatRenderable?pc.PIXELFORMAT_RGBA16F:pc.PIXELFORMAT_R8_G8_B8_A8);a[c].postEffect.shader&&!a[c].renderTarget&&(h=1-h)}else a[c].isPostEffect||a[c].renderTarget||!l||(a[c].renderTarget=b[h]);a[c].isPostEffect&&!a[c].renderTarget&&(p=!0)}if(l)if(!b[0].colorBuffer)B(0,q,n);else if(b[0].width!==q.width||b[0].height!==q.height||b[0]._colorBuffer._format!== n)b[0].colorBuffer.destroy(),b[0].destroy(),B(0,q,n);if(k)if(!b[1].colorBuffer)B(1,q,n);else if(b[1].width!==q.width||b[1].height!==q.height||b[1]._colorBuffer._format!==n)b[1].colorBuffer.destroy(),b[1].destroy(),B(1,q,n)},this);f.on("postrender",function(){var a=f.graphicsDevice;if(l&&!p){for(var c=f.scene.layers.layerList,d,e=c.length-1;0<=e&&(d=c[e].renderTarget,d!==b[0]&&d!==b[1]);e--);d&&(1this.layers.indexOf(a.id)||this.enabled&&this.entity.enabled&&a.addLight(this)},onLayerRemoved:function(a){0>this.layers.indexOf(a.id)||a.removeLight(this)},refreshProperties:function(){for(var a,c=0;ca.ind&&(l=a.ind);this._insertScriptInstance(e, l,g);this._scriptsIndex[d.__name]={instance:e,onSwap:function(){c.swap(d.__name)}};this[d.__name]=e;a.preloading||e.__initializeAttributes();this.fire("create",d.__name,e);this.fire("create:"+d.__name,e);this.system.app.scripts.on("swap:"+d.__name,this._scriptsIndex[d.__name].onSwap);a.preloading||(e.enabled&&!e._initialized&&(e._initialized=!0,e.initialize&&this._scriptMethod(e,f.scriptMethods.initialize)),e.enabled&&!e._postInitialized&&(e._postInitialized=!0,e.postInitialize&&this._scriptMethod(e, f.scriptMethods.postInitialize)));return e}console.warn("script '"+e+"' is already added to entity '"+this.entity.name+"'")}else this._scriptsIndex[e]={awaiting:!0,ind:this._scripts.length},console.warn("script '"+e+"' is not found, awaiting it to be added to registry");return null},destroy:function(b){var a=b;"string"===typeof b&&(b=this.system.app.scripts.get(b))&&(a=b.__name);b=this._scriptsIndex[a];delete this._scriptsIndex[a];if(!b)return!1;if(b.instance&&!b.instance._destroyed)if(b.instance.enabled= !1,b.instance._destroyed=!0,this._isLoopingThroughScripts)this._destroyedScripts.push(b.instance);else{var c=this._removeScriptInstance(b.instance);0<=c&&this._resetExecutionOrder(c,this._scripts.length)}this.system.app.scripts.off("swap:"+a,b.onSwap);delete this[a];this.fire("destroy",a,b.instance||null);this.fire("destroy:"+a,b.instance||null);b.instance&&b.instance.fire("destroy");return!0},swap:function(b){"string"===typeof b&&(b=this.system.app.scripts.get(b));var a=this._scriptsIndex[b.__name]; if(!a||!a.instance)return!1;var a=a.instance,c=this._scripts.indexOf(a),d=new b({app:this.system.app,entity:this.entity,enabled:a.enabled,attributes:a.__attributes});if(!d.swap)return!1;d.__initializeAttributes();this._scripts[c]=d;this._scriptsIndex[b.__name].instance=d;this[b.__name]=d;d.__executionOrder=c;a.update&&this._updateList.remove(a);a.postUpdate&&this._postUpdateList.remove(a);d.update&&this._updateList.insert(d);d.postUpdate&&this._postUpdateList.insert(d);this._scriptMethod(d,f.scriptMethods.swap, a);this.fire("swap",b.__name,d);this.fire("swap:"+b.__name,d);return!0},resolveDuplicatedEntityReferenceProperties:function(b,a){var c=this.entity.script,d;for(d in b._scriptsIndex){var e=this.system.app.scripts.get(d);if(e){var g=b._scriptsIndex[d];if(g&&g.instance){var f=c[d].__attributesRaw,k=c[d].__attributes;if(f||k){var g=g.instance.__attributes,p;for(p in g)if(g[p]){var h=e.attributes.get(p);if(h&&"entity"===h.type)if(h.array){var n=g[p];if(h=n.length){for(var n=n.slice(),q=0;q=c||0>a)return!1;var d=b;"string"!==typeof d&&(d=b.__name);var e=this._scriptsIndex[d];if(!e||!e.instance)return!1;var g=this._scripts.indexOf(e.instance);if(-1===g||g===a)return!1;this._scripts.splice(a,0,this._scripts.splice(g, 1)[0]);this._resetExecutionOrder(0,c);this._updateList.sort();this._postUpdateList.sort();this.fire("move",d,e.instance,a,g);this.fire("move:"+d,e.instance,a,g);return!0}});Object.defineProperty(f.prototype,"enabled",{get:function(){return this._enabled},set:function(b){var a=this._enabled;this._enabled=b;this.fire("set","enabled",a,b)}});Object.defineProperty(f.prototype,"scripts",{get:function(){return this._scripts},set:function(b){this._scriptsData=b;for(var a in b)if(b.hasOwnProperty(a)){var c= this._scriptsIndex[a];if(c){if("boolean"===typeof b[a].enabled&&(c.enabled=!!b[a].enabled),"object"===typeof b[a].attributes)for(var d in b[a].attributes)if(!pc.createScript.reservedAttributes[d]){if(!c.__attributes.hasOwnProperty(d)){var e=this.system.app.scripts.get(a);e&&e.attributes.add(d,{})}c[d]=b[a].attributes[d]}}else console.log(this.order)}}});return{ScriptComponent:f}}());Object.assign(pc,function(){var f=0,b=function(a){pc.ComponentSystem.call(this,a);this.id="script";this.app=a;this.ComponentType=pc.ScriptComponent;this.DataType=pc.ScriptComponentData;this._components=new pc.SortedLoopArray({sortBy:"_executionOrder"});this._enabledComponents=new pc.SortedLoopArray({sortBy:"_executionOrder"});this.preloading=!0;this.on("beforeremove",this._onBeforeRemove,this);pc.ComponentSystem.bind("initialize",this._onInitialize,this);pc.ComponentSystem.bind("postInitialize",this._onPostInitialize, this);pc.ComponentSystem.bind("update",this._onUpdate,this);pc.ComponentSystem.bind("postUpdate",this._onPostUpdate,this)};b.prototype=Object.create(pc.ComponentSystem.prototype);b.prototype.constructor=b;Object.assign(b.prototype,{initializeComponentData:function(a,b){a._executionOrder=f++;this._components.append(a);f>Number.MAX_SAFE_INTEGER&&this._resetExecutionOrder();a.enabled=b.hasOwnProperty("enabled")?!!b.enabled:!0;a.enabled&&a.entity.enabled&&this._enabledComponents.append(a);if(b.hasOwnProperty("order")&& b.hasOwnProperty("scripts")){a._scriptsData=b.scripts;for(var c=0;ca.indexOf(c[d])&&(c[d]instanceof pc.Asset?b.push(c[d].id):b.push(c[d]));!this.system._inTools&&b.length&&this.loadAudioSourceAssets(b)},onAssetChanged:function(b, a,c,d){"resource"===a&&this.data.sources&&(this.data.sources[b.name]=c,this.data.currentSource===b.name&&this.channel&&(this.channel.paused?(this.play(b.name),this.pause()):this.play(b.name)))},onAssetRemoved:function(b){b.off("remove",this.onAssetRemoved,this);this.data.sources[b.name]&&(delete this.data.sources[b.name],this.data.currentSource===b.name&&(this.stop(),this.data.currentSource=null))},onSetLoop:function(b,a,c){a!=c&&this.channel&&this.channel.setLoop(c)},onSetVolume:function(b,a,c){a!= c&&this.channel&&this.channel.setVolume(c)},onSetPitch:function(b,a,c){a!=c&&this.channel&&this.channel.setPitch(c)},onSetMaxDistance:function(b,a,c){a!=c&&this.channel instanceof pc.Channel3d&&this.channel.setMaxDistance(c)},onSetMinDistance:function(b,a,c){a!=c&&this.channel instanceof pc.Channel3d&&this.channel.setMinDistance(c)},onSetRollOffFactor:function(b,a,c){a!=c&&this.channel instanceof pc.Channel3d&&this.channel.setRollOffFactor(c)},onSetDistanceModel:function(b,a,c){a!==c&&this.channel instanceof pc.Channel3d&&this.channel.setDistanceModel(c)},onSet3d:function(b,a,c){a!==c&&this.system.initialized&&this.currentSource&&(a=b=!1,this.channel&&(b=this.channel.paused,a=this.channel.suspended),this.play(this.currentSource),this.channel&&(this.channel.paused=b,this.channel.suspended=a))},onEnable:function(){var b=this.data.assets;if(b)for(var a=this.system.app.assets,c=0,d=b.length;carguments.length?(arguments[0]&&this.entity.setPosition(arguments[0]),arguments[1]&&(arguments[1]instanceof pc.Quat?this.entity.setRotation(arguments[1]):this.entity.setEulerAngles(arguments[1]))):(6===arguments.length&&this.entity.setEulerAngles(arguments[3],arguments[4],arguments[5]),this.entity.setPosition(arguments[0],arguments[1],arguments[2]));this.syncEntityToBody()},_updateKinematic:function(a){this._displacement.copy(this._linearVelocity).scale(a);this.entity.translate(this._displacement); this._displacement.copy(this._angularVelocity).scale(a);this.entity.rotate(this._displacement.x,this._displacement.y,this._displacement.z);if(this.body.getMotionState()){a=this.entity.getPosition();var b=this.entity.getRotation();f.getOrigin().setValue(a.x,a.y,a.z);c.setValue(b.x,b.y,b.z,b.w);f.setRotation(c);this.body.getMotionState().setWorldTransform(f)}},onEnable:function(){this.body||this.createBody();this.enableSimulation()},onDisable:function(){this.disableSimulation()},onSetMass:function(a, b,c){if(a=this.data.body){(b=this.enabled&&this.entity.enabled)&&this.disableSimulation();var d=new Ammo.btVector3(0,0,0);a.getCollisionShape().calculateLocalInertia(c,d);a.setMassProps(c,d);a.updateInertiaTensor();b&&this.enableSimulation()}},onSetLinearDamping:function(a,b,c){(a=this.data.body)&&a.setDamping(c,this.data.angularDamping)},onSetAngularDamping:function(a,b,c){(a=this.data.body)&&a.setDamping(this.data.linearDamping,c)},onSetLinearFactor:function(a,c,d){if(a=this.data.body)b.setValue(d.x, d.y,d.z),a.setLinearFactor(b)},onSetAngularFactor:function(a,c,d){if(a=this.data.body)b.setValue(d.x,d.y,d.z),a.setAngularFactor(b)},onSetFriction:function(a,b,c){(a=this.data.body)&&a.setFriction(c)},onSetRestitution:function(a,b,c){(a=this.data.body)&&a.setRestitution(c)},onSetType:function(a,b,c){c!==b&&(this.disableSimulation(),c===pc.BODYTYPE_DYNAMIC?(this.data.group=pc.BODYGROUP_DYNAMIC,this.data.mask=pc.BODYMASK_ALL):c===pc.BODYTYPE_KINEMATIC?(this.data.group=pc.BODYGROUP_KINEMATIC,this.data.mask= pc.BODYMASK_ALL):(this.data.group=pc.BODYGROUP_STATIC,this.data.mask=pc.BODYMASK_NOT_STATIC),this.createBody())},onSetGroupOrMask:function(a,b,c){c!==b&&this.enabled&&this.entity.enabled&&(this.disableSimulation(),this.enableSimulation())},onSetBody:function(a,b,c){this.body&&this.data.simulationEnabled&&this.body.activate()}});return{RigidBodyComponent:e}}());Object.assign(pc,function(){var f,b,a={},c={},d=!1,e=function(a,b,c){this.entity=a;this.point=b;this.normal=c},g=function(a,b,c){0===arguments.length?(this.b=this.a=null,this.localPointA=new pc.Vec3,this.localPointB=new pc.Vec3,this.pointA=new pc.Vec3,this.pointB=new pc.Vec3,this.normal=new pc.Vec3):(this.a=a,this.b=b,this.localPointA=c.localPoint,this.localPointB=c.localPointOther,this.pointA=c.point,this.pointB=c.pointOther,this.normal=c.normal)},l=function(a,b,c,d,e){0===arguments.length?(this.localPoint= new pc.Vec3,this.localPointOther=new pc.Vec3,this.point=new pc.Vec3,this.pointOther=new pc.Vec3,this.normal=new pc.Vec3):(this.localPoint=a,this.localPointOther=b,this.point=c,this.pointOther=d,this.normal=e)},k=function(a,b){this.other=a;this.contacts=b},p="enabled type mass linearDamping angularDamping linearFactor angularFactor friction restitution group mask body".split(" "),h=function(a){pc.ComponentSystem.call(this,a);this.id="rigidbody";this.description="Adds the entity to the scene's physical simulation."; this._stats=a.stats.frame;this.ComponentType=pc.RigidBodyComponent;this.DataType=pc.RigidBodyComponentData;this.contactPointPool=new pc.AllocatePool(l,1);this.contactResultPool=new pc.AllocatePool(k,1);this.singleContactResultPool=new pc.AllocatePool(g,1);this.schema=p;this.maxSubSteps=10;this.fixedTimeStep=1/60;this.on("remove",this.onRemove,this)};h.prototype=Object.create(pc.ComponentSystem.prototype);h.prototype.constructor=h;pc.Component._buildAccessors(pc.RigidBodyComponent.prototype,p);Object.assign(h.prototype, {onLibraryLoaded:function(){if("undefined"!==typeof Ammo){var a=new Ammo.btDefaultCollisionConfiguration,c=new Ammo.btCollisionDispatcher(a),d=new Ammo.btDbvtBroadphase,e=new Ammo.btSequentialImpulseConstraintSolver;this.dynamicsWorld=new Ammo.btDiscreteDynamicsWorld(c,d,e,a);this._ammoGravity=new Ammo.btVector3(0,-9.82,0);this.dynamicsWorld.setGravity(this._ammoGravity);f=new Ammo.btVector3;b=new Ammo.btVector3;pc.ComponentSystem.bind("update",this.onUpdate,this)}else pc.ComponentSystem.unbind("update", this.onUpdate,this)},initializeComponentData:function(a,b,c){c="enabled mass linearDamping angularDamping linearFactor angularFactor friction restitution type group mask".split(" ");for(var d={},e=0,g=c.length;ea[g].others.indexOf(d)&&(a[g].others.push(d),e=!0);c[g]=c[g]||{others:[],entity:b};c[g].others.push(d);return e},_createContactPointFromAmmo:function(a){var b=this.contactPointPool.allocate();b.localPoint.set(a.get_m_localPointA().x(),a.get_m_localPointA().y(),a.get_m_localPointA().z());b.localPointOther.set(a.get_m_localPointB().x(),a.get_m_localPointB().y(),a.get_m_localPointB().z());b.point.set(a.getPositionWorldOnA().x(),a.getPositionWorldOnA().y(),a.getPositionWorldOnA().z()); b.pointOther.set(a.getPositionWorldOnB().x(),a.getPositionWorldOnB().y(),a.getPositionWorldOnB().z());b.normal.set(a.get_m_normalWorldOnB().x(),a.get_m_normalWorldOnB().y(),a.get_m_normalWorldOnB().z());return b},_createReverseContactPointFromAmmo:function(a){var b=this.contactPointPool.allocate();b.localPointOther.set(a.get_m_localPointA().x(),a.get_m_localPointA().y(),a.get_m_localPointA().z());b.localPoint.set(a.get_m_localPointB().x(),a.get_m_localPointB().y(),a.get_m_localPointB().z());b.pointOther.set(a.getPositionWorldOnA().x(), a.getPositionWorldOnA().y(),a.getPositionWorldOnA().z());b.point.set(a.getPositionWorldOnB().x(),a.getPositionWorldOnB().y(),a.getPositionWorldOnB().z());b.normal.set(a.get_m_normalWorldOnB().x(),a.get_m_normalWorldOnB().y(),a.get_m_normalWorldOnB().z());return b},_createSingleContactResult:function(a,b,c){var d=this.singleContactResultPool.allocate();d.a=a;d.b=b;d.localPointA=c.localPoint;d.localPointB=c.localPointOther;d.pointA=c.point;d.pointB=c.pointOther;d.normal=c.normal;return d},_createContactResult:function(a, b){var c=this.contactResultPool.allocate();c.other=a;c.contacts=b;return c},_cleanOldCollisions:function(){for(var b in a)if(a.hasOwnProperty(b)){for(var d=a[b].entity,e=d.collision,g=a[b].others,f=g.length;f--;){var k=g[f];if(!c[b]||0>c[b].others.indexOf(k))g.splice(f,1),e&&k.collision&&(d.rigidbody&&k.rigidbody?e.fire("collisionend",k):d.trigger&&e.fire("triggerleave",k))}0===g.length&&delete a[b]}},onUpdate:function(a){this.dynamicsWorld.stepSimulation(a,this.maxSubSteps,this.fixedTimeStep);var b= this.store,d;for(d in b)if(b.hasOwnProperty(d)){var e=b[d].entity,g=b[d].data;g.body&&g.body.isActive()&&g.enabled&&e.enabled&&(g.type===pc.BODYTYPE_DYNAMIC?e.rigidbody.syncBodyToEntity():g.type===pc.BODYTYPE_KINEMATIC&&e.rigidbody._updateKinematic(a))}a=this.dynamicsWorld.getDispatcher();var b=a.getNumManifolds(),f;c={};for(d=0;dthis.layers.indexOf(a.id)||a.addMeshInstances(this.data.model.meshInstances))},onLayerRemoved:function(a){this.data.model&&(0>this.layers.indexOf(a.id)||a.removeMeshInstances(this.data.model.meshInstances))}, _bindColorMapAsset:function(a){a.once("remove",this._onColorMapRemoved,this);a.resource?this.colorMap=a.resource:(a.once("load",this._onColorMapLoad,this),this.enabled&&this.entity.enabled&&this.system.app.assets.load(a))},_unbindColorMapAsset:function(a){a.off("remove",this._onColorMapRemoved,this);a.off("load",this._onColorMapLoad,this)},_onColorMapLoad:function(a){this.colorMap=a.resource},_onColorMapRemoved:function(a){this.colorMapAsset=null},onSetColorMapAsset:function(a,b,c){var d=this;a=this.system.app.assets; b&&(b=a.get(b))&&this._unbindColorMapAsset(b);if(c)if(c instanceof pc.Asset&&(c=this.data.colorMapAsset=c.id),b=a.get(c))d._bindColorMapAsset(b);else a.once("add:"+c,function(a){d._bindColorMapAsset(a)});else this.colorMap=null},_bindNormalMapAsset:function(a){a.once("remove",this._onNormalMapRemoved,this);a.resource?this.normalMap=a.resource:(a.once("load",this._onNormalMapLoad,this),this.enabled&&this.entity.enabled&&this.system.app.assets.load(a))},_unbindNormalMapAsset:function(a){a.off("remove", this._onNormalMapRemoved,this);a.off("load",this._onNormalMapLoad,this)},_onNormalMapLoad:function(a){this.normalMap=a.resource},_onNormalMapRemoved:function(a){this.normalMapAsset=null},onSetNormalMapAsset:function(a,b,c){var d=this;a=this.system.app.assets;b&&(b=a.get(b))&&this._unbindNormalMapAsset(b);if(c)if(c instanceof pc.Asset&&(c=this.data.normalMapAsset=c.id),b=a.get(c))d._bindNormalMapAsset(b);else a.once("add:"+c,function(a){d._bindNormalMapAsset(a)});else this.normalMap=null},_bindMeshAsset:function(a){a.on("remove", this._onMeshAssetRemoved,this);a.on("load",this._onMeshAssetLoad,this)},_unbindMeshAsset:function(a){a.off("remove",this._onMeshAssetRemoved,this);a.off("load",this._onMeshAssetLoad,this)},_onMeshAssetLoad:function(a){this._onMeshChanged(a.resource)},onSetMeshAsset:function(a,b,c){a=this.system.app.assets;b&&(b=a.get(b))&&this._unbindMeshAsset(b);if(c){if(c instanceof pc.Asset&&(c=this.data.meshAsset=c.id),b=a.get(c))this._bindMeshAsset(b),b.resource?this._onMeshChanged(b.resource):a.load(b)}else this._onMeshChanged(null)}, onSetMesh:function(a,b,c){!c||c instanceof pc.Asset||"number"===typeof c?this.meshAsset=c:this._onMeshChanged(c)},_onMeshChanged:function(a){!a||a instanceof pc.Mesh||(a=a.meshInstances[0]?a.meshInstances[0].mesh:null);this.data.mesh=a;this.emitter&&(this.emitter.mesh=a,this.emitter.resetMaterial(),this.rebuild())},onMeshAssetRemoved:function(a){a.off("remove",this.onMeshAssetRemoved,this);this.mesh=null},onSetLoop:function(a,b,c){this.emitter&&(this.emitter[a]=c,this.emitter.resetTime())},onSetBlendType:function(a, b,c){this.emitter&&(this.emitter[a]=c,this.emitter.material.blendType=c,this.emitter.resetMaterial(),this.rebuild())},_requestDepth:function(){this._requestedDepth||(d||(d=this.system.app.scene.layers.getLayerById(pc.LAYERID_DEPTH)),d&&(d.incrementCounter(),this._requestedDepth=!0))},_releaseDepth:function(){this._requestedDepth&&d&&(d.decrementCounter(),this._requestedDepth=!1)},onSetDepthSoftening:function(a,b,c){b!==c&&(c?this.enabled&&this.entity.enabled&&this._requestDepth():this.enabled&&this.entity.enabled&& this._releaseDepth(),this.emitter&&(this.emitter[a]=c),this.emitter&&(this.reset(),this.emitter.resetMaterial(),this.rebuild()))},onSetSimpleProperty:function(a,b,c){this.emitter&&(this.emitter[a]=c,this.emitter.resetMaterial())},onSetComplexProperty:function(a,b,c){this.emitter&&(this.emitter[a]=c,this.reset(),this.emitter.resetMaterial(),this.rebuild())},onSetGraphProperty:function(a,b,c){this.emitter&&(this.emitter[a]=c,this.emitter.rebuildGraphs(),this.emitter.resetMaterial())},onEnable:function(){for(var a= this.data,b=0,d=c.length;be;e++)n[3*e]=this.app.scene.ambientLight.r,n[3*e+1]=this.app.scene.ambientLight.g,n[3*e+2]=this.app.scene.ambientLight.b;var m=l._sortedLights[pc.LIGHTTYPE_DIRECTIONAL];for(f=0;fl;l++){var r=Math.max(h.lightCubeDir[l].dot(m[f]._direction),0)*m[f]._intensity;n[3*l]+=m[f]._color.r*r;n[3*l+1]+=m[f]._color.g*r;n[3*l+2]+=m[f]._color.b* r}}h.constantLightCube.setValue(n)}if(!d.paused){h.simTime+=a;d=0;h.simTime>h.fixedTimeStep&&(d=Math.floor(h.simTime/h.fixedTimeStep),h.simTime-=d*h.fixedTimeStep);if(d){d=Math.min(d,h.maxSubSteps);for(e=0;ethis.fps?-1:1),c=this.duration;b=a>c||0>a;this._setTime(a);a=this._sprite?Math.floor(this._sprite.frameKeys.length*this._time/c):0;a!==this._frame&&this._setFrame(a);b&&(this.loop?(this.fire("loop"),this._component.fire("loop", this)):(this._paused=this._playing=!1,this.fire("end"),this._component.fire("end",this)))}},_setTime:function(b){this._time=b;b=this.duration;0>this._time?this._time=this.loop?this._time%b+b:0:this._time>b&&(this._time=this.loop?this._time%b:b)},_setFrame:function(b){this._frame=this._sprite?pc.math.clamp(b,0,this._sprite.frameKeys.length-1):b;this._component.currentClip===this&&this._component._showFrame(this._frame)},_destroy:function(){this._sprite&&(this.sprite=null);this._spriteAsset&&(this.spriteAsset= null)},play:function(){this._playing||(this._playing=!0,this._paused=!1,this.frame=0,this.fire("play"),this._component.fire("play",this))},pause:function(){this._playing&&!this._paused&&(this._paused=!0,this.fire("pause"),this._component.fire("pause",this))},resume:function(){this._paused&&(this._paused=!1,this.fire("resume"),this._component.fire("resume",this))},stop:function(){this._playing&&(this._paused=this._playing=!1,this.frame=this._time=0,this.fire("stop"),this._component.fire("stop",this))}}); Object.defineProperty(f.prototype,"spriteAsset",{get:function(){return this._spriteAsset},set:function(b){var a=this._component.system.app.assets,c=b;b instanceof pc.Asset&&(c=b.id);this._spriteAsset!==c&&(this._spriteAsset&&(b=a.get(this._spriteAsset))&&this._unbindSpriteAsset(b),(this._spriteAsset=c)?(c=a.get(this._spriteAsset))?this._bindSpriteAsset(c):(this.sprite=null,a.on("add:"+this._spriteAsset,this._onSpriteAssetAdded,this)):this.sprite=null)}});Object.defineProperty(f.prototype,"sprite", {get:function(){return this._sprite},set:function(b){this._sprite&&(this._sprite.off("set:meshes",this._onSpriteMeshesChange,this),this._sprite.off("set:pixelsPerUnit",this._onSpritePpuChanged,this),this._sprite.off("set:atlas",this._onSpriteMeshesChange,this),this._sprite.atlas&&this._sprite.atlas.off("set:texture",this._onSpriteMeshesChange,this));if(this._sprite=b)if(this._sprite.on("set:meshes",this._onSpriteMeshesChange,this),this._sprite.on("set:pixelsPerUnit",this._onSpritePpuChanged,this), this._sprite.on("set:atlas",this._onSpriteMeshesChange,this),this._sprite.atlas)this._sprite.atlas.on("set:texture",this._onSpriteMeshesChange,this);if(this._component.currentClip===this){var a;if(b&&b.atlas){if(b.atlas.texture){if(a=this._component._meshInstance)a.setParameter("texture_emissiveMap",b.atlas.texture),a.setParameter("texture_opacityMap",b.atlas.texture);this._component.enabled&&this._component.entity.enabled&&this._component._showModel()}this.time&&this.fps?this.time=this.time:this.frame= this.frame}else{if(a=this._component._meshInstance)a.deleteParameter("texture_emissiveMap"),a.deleteParameter("texture_opacityMap");this._component._hideModel()}}}});Object.defineProperty(f.prototype,"frame",{get:function(){return this._frame},set:function(b){this._setFrame(b);this._setTime(this._frame/(this.fps||Number.MIN_VALUE))}});Object.defineProperty(f.prototype,"isPlaying",{get:function(){return this._playing}});Object.defineProperty(f.prototype,"isPaused",{get:function(){return this._paused}}); Object.defineProperty(f.prototype,"duration",{get:function(){return this._sprite?this._sprite.frameKeys.length/Math.abs(this.fps||Number.MIN_VALUE):0}});Object.defineProperty(f.prototype,"time",{get:function(){return this._time},set:function(b){this._setTime(b);this.frame=this._sprite?Math.min(this._sprite.frameKeys.length-1,Math.floor(this._time*Math.abs(this.fps))):0}});return{SpriteAnimationClip:f}}());Object.assign(pc,function(){pc.SPRITETYPE_SIMPLE="simple";pc.SPRITETYPE_ANIMATED="animated";var f=function(b,a){pc.Component.call(this,b,a);this._type=pc.SPRITETYPE_SIMPLE;this._material=b.defaultMaterial;this._color=new pc.Color(1,1,1,1);this._colorUniform=new Float32Array(3);this._speed=1;this._flipY=this._flipX=!1;this._height=this._width=1;this._drawOrder=0;this._layers=[pc.LAYERID_WORLD];this._outerScale=new pc.Vec2(1,1);this._outerScaleUniform=new Float32Array(2);this._innerOffset=new pc.Vec4; this._innerOffsetUniform=new Float32Array(4);this._atlasRect=new pc.Vec4;this._atlasRectUniform=new Float32Array(4);this._batchGroupId=-1;this._batchGroup=null;this._node=new pc.GraphNode;this._model=new pc.Model;this._model.graph=this._node;this._meshInstance=null;a.addChild(this._model.graph);this._model._entity=a;this._updateAabbFunc=this._updateAabb.bind(this);this._addedModel=!1;this._autoPlayClip=null;this._clips={};this._currentClip=this._defaultClip=new pc.SpriteAnimationClip(this,{name:this.entity.name, fps:0,loop:!1,spriteAsset:null})};f.prototype=Object.create(pc.Component.prototype);f.prototype.constructor=f;Object.assign(f.prototype,{onEnable:function(){var b=this.system.app.scene;b.on("set:layers",this._onLayersChanged,this);b.layers&&(b.layers.on("add",this._onLayerAdded,this),b.layers.on("remove",this._onLayerRemoved,this));this._showModel();this._autoPlayClip&&this._tryAutoPlay()},onDisable:function(){var b=this.system.app,a=b.scene;a.off("set:layers",this._onLayersChanged,this);a.layers&& (a.layers.off("add",this._onLayerAdded,this),a.layers.off("remove",this._onLayerRemoved,this));this.stop();this._hideModel();0<=this._batchGroupId&&b.batcher.markGroupDirty(this.batchGroupId)},onDestroy:function(){this._currentClip=null;this._defaultClip&&(this._defaultClip._destroy(),this._defaultClip=null);for(var b in this._clips)this._clips[b]._destroy();this._clips=null;this._hideModel();this._model=null;this._node&&(this._node.parent&&this._node.parent.removeChild(this._node),this._node=null); this._meshInstance&&(this._meshInstance.material=null,this._meshInstance=this._meshInstance.mesh=null)},_showModel:function(){if(!this._addedModel&&this._meshInstance){var b,a,c=[this._meshInstance];b=0;for(a=this._layers.length;bthis.layers.indexOf(b.id)||this._addedModel&&this.enabled&&this.entity.enabled&&this._meshInstance&&b.addMeshInstances([this._meshInstance])},_onLayerRemoved:function(b){this._meshInstance&&(0>this.layers.indexOf(b.id)||b.removeMeshInstances([this._meshInstance]))},addClip:function(b){var a=new pc.SpriteAnimationClip(this,{name:b.name,fps:b.fps,loop:b.loop, spriteAsset:b.spriteAsset});this._clips[b.name]=a;a.name&&a.name===this._autoPlayClip&&this._tryAutoPlay();return a},removeClip:function(b){delete this._clips[b]},clip:function(b){return this._clips[b]},play:function(b){var a=this._clips[b],c=this._currentClip;c&&c!==a&&(c._playing=!1);(this._currentClip=a)?(this._currentClip=a,this._currentClip.play()):logWARNING("Trying to play sprite animation "+b+" which does not exist.");return a},pause:function(){this._currentClip!==this._defaultClip&&this._currentClip.isPlaying&& this._currentClip.pause()},resume:function(){this._currentClip!==this._defaultClip&&this._currentClip.isPaused&&this._currentClip.resume()},stop:function(){this._currentClip!==this._defaultClip&&this._currentClip.stop()}});Object.defineProperty(f.prototype,"type",{get:function(){return this._type},set:function(b){this._type!==b&&(this._type=b,this._type===pc.SPRITETYPE_SIMPLE?(this.stop(),this._currentClip=this._defaultClip,this.enabled&&this.entity.enabled&&(this._currentClip.frame=this.frame,this._currentClip.sprite? this._showModel():this._hideModel())):this._type===pc.SPRITETYPE_ANIMATED&&(this.stop(),this._autoPlayClip&&this._tryAutoPlay(),this._currentClip&&this._currentClip.isPlaying&&this.enabled&&this.entity.enabled?this._showModel():this._hideModel()))}});Object.defineProperty(f.prototype,"frame",{get:function(){return this._currentClip.frame},set:function(b){this._currentClip.frame=b}});Object.defineProperty(f.prototype,"spriteAsset",{get:function(){return this._defaultClip._spriteAsset},set:function(b){this._defaultClip.spriteAsset= b}});Object.defineProperty(f.prototype,"sprite",{get:function(){return this._currentClip.sprite},set:function(b){this._currentClip.sprite=b}});Object.defineProperty(f.prototype,"material",{get:function(){return this._material},set:function(b){this._material=b;this._meshInstance&&(this._meshInstance.material=b)}});Object.defineProperty(f.prototype,"color",{get:function(){return this._color},set:function(b){this._color.r=b.r;this._color.g=b.g;this._color.b=b.b;this._meshInstance&&(this._colorUniform[0]= this._color.r,this._colorUniform[1]=this._color.g,this._colorUniform[2]=this._color.b,this._meshInstance.setParameter("material_emissive",this._colorUniform))}});Object.defineProperty(f.prototype,"opacity",{get:function(){return this._color.a},set:function(b){this._color.a=b;this._meshInstance&&this._meshInstance.setParameter("material_opacity",b)}});Object.defineProperty(f.prototype,"clips",{get:function(){return this._clips},set:function(b){var a,c;if(b){for(a in this._clips){var d=!1;for(c in b)if(b[c].name=== a){d=!0;this._clips[a].fps=b[c].fps;this._clips[a].loop=b[c].loop;b[c].hasOwnProperty("sprite")?this._clips[a].sprite=b[c].sprite:b[c].hasOwnProperty("spriteAsset")&&(this._clips[a].spriteAsset=b[c].spriteAsset);break}d||this.removeClip(a)}for(c in b)this._clips[b[c].name]||this.addClip(b[c]);this._autoPlayClip&&this._tryAutoPlay();this._currentClip&&this._currentClip.sprite||this._hideModel()}else for(a in this._clips)this.removeClip(a)}});Object.defineProperty(f.prototype,"currentClip",{get:function(){return this._currentClip}}); Object.defineProperty(f.prototype,"speed",{get:function(){return this._speed},set:function(b){this._speed=b}});Object.defineProperty(f.prototype,"flipX",{get:function(){return this._flipX},set:function(b){this._flipX!==b&&(this._flipX=b,this._updateTransform())}});Object.defineProperty(f.prototype,"flipY",{get:function(){return this._flipY},set:function(b){this._flipY!==b&&(this._flipY=b,this._updateTransform())}});Object.defineProperty(f.prototype,"width",{get:function(){return this._width},set:function(b){b!== this._width&&(this._width=b,this._outerScale.x=this._width,!this.sprite||this.sprite.renderMode!==pc.SPRITE_RENDERMODE_TILED&&this.sprite.renderMode!==pc.SPRITE_RENDERMODE_SLICED||this._updateTransform())}});Object.defineProperty(f.prototype,"height",{get:function(){return this._height},set:function(b){b!==this._height&&(this._height=b,this._outerScale.y=this.height,!this.sprite||this.sprite.renderMode!==pc.SPRITE_RENDERMODE_TILED&&this.sprite.renderMode!==pc.SPRITE_RENDERMODE_SLICED||this._updateTransform())}}); Object.defineProperty(f.prototype,"batchGroupId",{get:function(){return this._batchGroupId},set:function(b){if(this._batchGroupId!==b){var a=this._batchGroupId;this._batchGroupId=b;0<=a&&this.system.app.batcher.markGroupDirty(a);0<=this._batchGroupId?this.system.app.batcher.markGroupDirty(this._batchGroupId):0<=a&&this._currentClip&&this._currentClip.sprite&&this.enabled&&this.entity.enabled&&this._showModel()}}});Object.defineProperty(f.prototype,"autoPlayClip",{get:function(){return this._autoPlayClip}, set:function(b){this._autoPlayClip=b instanceof pc.SpriteAnimationClip?b.name:b;this._tryAutoPlay()}});Object.defineProperty(f.prototype,"drawOrder",{get:function(){return this._drawOrder},set:function(b){this._drawOrder=b;this._meshInstance&&(this._meshInstance.drawOrder=b)}});Object.defineProperty(f.prototype,"layers",{get:function(){return this._layers},set:function(b){this._addedModel&&this._hideModel();this._layers=b;this._meshInstance&&this.enabled&&this.entity.enabled&&this._showModel()}}); Object.defineProperty(f.prototype,"aabb",{get:function(){return this._meshInstance?this._meshInstance.aabb:null}});return{SpriteComponent:f}}());Object.assign(pc,function(){var f=["enabled"],b=function(a){pc.ComponentSystem.call(this,a);this.id="sprite";this.app=a;this.ComponentType=pc.SpriteComponent;this.DataType=pc.SpriteComponentData;this.schema=f;this._defaultTexture=new pc.Texture(a.graphicsDevice,{width:1,height:1,format:pc.PIXELFORMAT_R8_G8_B8_A8});a=this._defaultTexture.lock();var b=new Uint8Array(4);b[0]=255;b[1]=255;b[2]=255;b[3]=255;a.set(b);this._defaultTexture.name="sprite";this._defaultTexture.unlock();this.defaultMaterial= new pc.StandardMaterial;this.defaultMaterial.diffuse=new pc.Color(0,0,0,1);this.defaultMaterial.emissive=new pc.Color(.5,.5,.5,1);this.defaultMaterial.emissiveMap=this._defaultTexture;this.defaultMaterial.emissiveMapTint=!0;this.defaultMaterial.opacityMap=this._defaultTexture;this.defaultMaterial.opacityMapChannel="a";this.defaultMaterial.opacityTint=!0;this.defaultMaterial.opacity=0;this.defaultMaterial.useLighting=!1;this.defaultMaterial.useGammaTonemap=!1;this.defaultMaterial.useFog=!1;this.defaultMaterial.useSkybox= !1;this.defaultMaterial.blendType=pc.BLEND_PREMULTIPLIED;this.defaultMaterial.depthWrite=!1;this.defaultMaterial.pixelSnap=!1;this.defaultMaterial.cull=pc.CULLFACE_NONE;this.defaultMaterial.update();this.default9SlicedMaterialSlicedMode=this.defaultMaterial.clone();this.default9SlicedMaterialSlicedMode.nineSlicedMode=pc.SPRITE_RENDERMODE_SLICED;this.default9SlicedMaterialSlicedMode.update();this.default9SlicedMaterialTiledMode=this.defaultMaterial.clone();this.default9SlicedMaterialTiledMode.nineSlicedMode= pc.SPRITE_RENDERMODE_TILED;this.default9SlicedMaterialTiledMode.update();pc.ComponentSystem.bind("update",this.onUpdate,this);this.on("beforeremove",this.onBeforeRemove,this)};b.prototype=Object.create(pc.ComponentSystem.prototype);b.prototype.constructor=b;pc.Component._buildAccessors(pc.SpriteComponent.prototype,f);Object.assign(b.prototype,{destroy:function(){this._defaultTexture.destroy();this._defaultTexture=null},initializeComponentData:function(a,b,d){void 0!==b.enabled&&(a.enabled=b.enabled); a.type=b.type;b.layers&&"array"===pc.type(b.layers)&&(a.layers=b.layers.slice(0));void 0!==b.drawOrder&&(a.drawOrder=b.drawOrder);void 0!==b.color&&(b.color instanceof pc.Color?a.color.set(b.color.r,b.color.g,b.color.b,void 0!==b.opacity?b.opacity:1):a.color.set(b.color[0],b.color[1],b.color[2],void 0!==b.opacity?b.opacity:1),a.color=a.color);void 0!==b.opacity&&(a.opacity=b.opacity);void 0!==b.flipX&&(a.flipX=b.flipX);void 0!==b.flipY&&(a.flipY=b.flipY);void 0!==b.width&&(a.width=b.width);void 0!== b.height&&(a.height=b.height);void 0!==b.spriteAsset&&(a.spriteAsset=b.spriteAsset);b.sprite&&(a.sprite=b.sprite);void 0!==b.frame&&(a.frame=b.frame);if(b.clips)for(var c in b.clips)a.addClip(b.clips[c]);void 0!==b.speed&&(a.speed=b.speed);b.autoPlayClip&&(a.autoPlayClip=b.autoPlayClip);a.batchGroupId=void 0===b.batchGroupId||null===b.batchGroupId?-1:b.batchGroupId;pc.ComponentSystem.prototype.initializeComponentData.call(this,a,b,d)},cloneComponent:function(a,b){var c=a.sprite;return this.addComponent(b, {enabled:c.enabled,type:c.type,spriteAsset:c.spriteAsset,sprite:c.sprite,frame:c.frame,color:c.color.clone(),opacity:c.opacity,flipX:c.flipX,flipY:c.flipY,speed:c.speed,clips:c.clips,autoPlayClip:c.autoPlayClip,batchGroupId:c.batchGroupId,drawOrder:c.drawOrder,layers:c.layers.slice(0)})},onUpdate:function(a){var b=this.store,d;for(d in b)if(b.hasOwnProperty(d)){var e=b[d];e.data.enabled&&e.entity.enabled&&(e=e.entity.sprite,e._currentClip&&e._currentClip._update(a))}},onBeforeRemove:function(a,b){b.onDestroy()}}); return{SpriteComponentSystem:b}}());Object.assign(pc,function(){return{SpriteComponentData:function(){this.enabled=!0}}}());Object.assign(pc,function(){pc.SCALEMODE_NONE="none";pc.SCALEMODE_BLEND="blend";var f=function(a,b){pc.Component.call(this,a,b);this._resolution=new pc.Vec2(640,320);this._referenceResolution=new pc.Vec2(640,320);this._scaleMode=pc.SCALEMODE_NONE;this.scale=1;this._scaleBlend=.5;this._priority=0;this.cull=this._screenSpace=!1;this._screenMatrix=new pc.Mat4;a.app.graphicsDevice.on("resizecanvas",this._onResize,this)};f.prototype=Object.create(pc.Component.prototype);f.prototype.constructor=f;var b= new pc.Mat4;Object.assign(f.prototype,{syncDrawOrder:function(){this.system.queueDrawOrderSync(this.entity.getGuid(),this._processDrawOrderSync,this)},_recurseDrawOrderSync:function(a,b){if(!(a instanceof pc.Entity))return b;a.element&&(a.element.drawOrder=b++);for(var c=a.getChildren(),e=0;ethis.system._prerender.indexOf(a)&& this.system._prerender.push(a)}a=b}},_onPrerender:function(){for(var a=0;athis.layers.indexOf(a.id)||(this._image?a.addMeshInstances(this._image._model.meshInstances):this._text&&a.addMeshInstances(this._text._model.meshInstances))},onLayerRemoved:function(a){0> this.layers.indexOf(a.id)||(this._image?a.removeMeshInstances(this._image._model.meshInstances):this._text&&a.removeMeshInstances(this._text._model.meshInstances))},onEnable:function(){if(this._image)this._image.onEnable();if(this._text)this._text.onEnable();if(this._group)this._group.onEnable();this.useInput&&this.system.app.elementInput&&this.system.app.elementInput.addElement(this);this.system.app.scene.on("set:layers",this.onLayersChanged,this);this.system.app.scene.layers&&(this.system.app.scene.layers.on("add", this.onLayerAdded,this),this.system.app.scene.layers.on("remove",this.onLayerRemoved,this));this.fire("enableelement")},onDisable:function(){this.system.app.scene.off("set:layers",this.onLayersChanged,this);this.system.app.scene.layers&&(this.system.app.scene.layers.off("add",this.onLayerAdded,this),this.system.app.scene.layers.off("remove",this.onLayerRemoved,this));if(this._image)this._image.onDisable();if(this._text)this._text.onDisable();if(this._group)this._group.onDisable();this.system.app.elementInput&& this.useInput&&this.system.app.elementInput.removeElement(this);0<=this._batchGroupId&&this.system.app.batcher.markGroupDirty(this.batchGroupId);this.fire("disableelement")},onRemove:function(){this.entity.off("insert",this._onInsert,this);this._unpatch();this._image&&this._image.destroy();this._text&&this._text.destroy();this.system.app.elementInput&&this.useInput&&this.system.app.elementInput.removeElement(this);this.screen&&this.screen.screen&&(this._unbindScreen(this.screen.screen),this.screen.screen.syncDrawOrder()); this.off()},_calculateSize:function(a,b){if(this.entity._parent||this.screen){this._calculateLocalAnchors();var c=this._absRight-this._absLeft,d=this._absTop-this._absBottom;a?this._setWidth(c):this._setCalculatedWidth(c,!1);b?this._setHeight(d):this._setCalculatedHeight(d,!1);c=this.entity.getLocalPosition();c.x=this._margin.x+this._calculatedWidth*this._pivot.x;c.y=this._margin.y+this._calculatedHeight*this._pivot.y;this.entity.setLocalPosition(c);this._sizeDirty=!1}},_setWidth:function(a){this._width= a;this._setCalculatedWidth(a,!1);this.fire("set:width",this._width)},_setHeight:function(a){this._height=a;this._setCalculatedHeight(a,!1);this.fire("set:height",this._height)},_setCalculatedWidth:function(a,b){var c=1E-4c||g>a||lc;c++)this._screenTransform.transformPoint(this._screenCorners[c],this._screenCorners[c]),b&&this._screenCorners[c].scale(this.screen.screen.scale),a&&this._screenCorners[c].add(a);this._cornersDirty=!1;this._worldCornersDirty=this._canvasCornersDirty=!0;return this._screenCorners}}); Object.defineProperty(g.prototype,"canvasCorners",{get:function(){if(!this._canvasCornersDirty||!this.screen||!this.screen.screen.screenSpace)return this._canvasCorners;for(var a=this.system.app.graphicsDevice,b=this.screenCorners,c=a.canvas.clientWidth/a.width,d=a.canvas.clientHeight/a.height,e=0;4>e;e++)this._canvasCorners[e].set(b[e].x*c,(a.height-b[e].y)*d);this._canvasCornersDirty=!1;return this._canvasCorners}});Object.defineProperty(g.prototype,"worldCorners",{get:function(){if(!this._worldCornersDirty)return this._worldCorners; if(this.screen){var b=this.screenCorners;if(!this.screen.screen.screenSpace){a.copy(this.screen.screen._screenMatrix);a.data[13]=-a.data[13];a.mul2(this.screen.getWorldTransform(),a);for(var g=0;4>g;g++)a.transformPoint(b[g],this._worldCorners[g])}}else b=this.entity.getLocalPosition(),a.setTranslate(-b.x,-b.y,-b.z),c.setTRS(pc.Vec3.ZERO,this.entity.getLocalRotation(),this.entity.getLocalScale()),d.setTranslate(b.x,b.y,b.z),e.copy(this.entity.parent.getWorldTransform()),e.mul(d).mul(c).mul(a),f.set(b.x- this.pivot.x*this.calculatedWidth,b.y-this.pivot.y*this.calculatedHeight,b.z),e.transformPoint(f,this._worldCorners[0]),f.set(b.x+(1-this.pivot.x)*this.calculatedWidth,b.y-this.pivot.y*this.calculatedHeight,b.z),e.transformPoint(f,this._worldCorners[1]),f.set(b.x+(1-this.pivot.x)*this.calculatedWidth,b.y+(1-this.pivot.y)*this.calculatedHeight,b.z),e.transformPoint(f,this._worldCorners[2]),f.set(b.x-this.pivot.x*this.calculatedWidth,b.y+(1-this.pivot.y)*this.calculatedHeight,b.z),e.transformPoint(f, this._worldCorners[3]);this._worldCornersDirty=!1;return this._worldCorners}});Object.defineProperty(g.prototype,"textWidth",{get:function(){return this._text?this._text.width:0}});Object.defineProperty(g.prototype,"textHeight",{get:function(){return this._text?this._text.height:0}});Object.defineProperty(g.prototype,"useInput",{get:function(){return this._useInput},set:function(a){this._useInput!==a&&(this._useInput=a,this.system.app.elementInput&&(a?this.enabled&&this.entity.enabled&&this.system.app.elementInput.addElement(this): this.system.app.elementInput.removeElement(this)),this.fire("set:useInput",a))}});Object.defineProperty(g.prototype,"batchGroupId",{get:function(){return this._batchGroupId},set:function(a){this._batchGroupId!==a&&(0<=this._batchGroupId&&this.system.app.batcher.markGroupDirty(this._batchGroupId),0<=a&&this.system.app.batcher.markGroupDirty(a),0>a&&0<=this._batchGroupId&&this.enabled&&this.entity.enabled&&(this._image._model?this.addModelToLayers(this._image._model):this._text._model&&this.addModelToLayers(this._text._model)), this._batchGroupId=a)}});Object.defineProperty(g.prototype,"maskedBy",{get:function(){return this._maskedBy}});var l=function(a){Object.defineProperty(g.prototype,a,{get:function(){return this._text?this._text[a]:this._image?this._image[a]:null},set:function(b){this._text?this._text[a]=b:this._image&&(this._image[a]=b)}})};l("fontSize");l("color");l("font");l("fontAsset");l("spacing");l("lineHeight");l("wrapLines");l("lines");l("alignment");l("autoWidth");l("autoHeight");l("rtlReorder");l("unicodeConverter"); l("text");l("key");l("texture");l("textureAsset");l("material");l("materialAsset");l("sprite");l("spriteAsset");l("spriteFrame");l("pixelsPerUnit");l("opacity");l("rect");l("mask");l("outlineColor");l("outlineThickness");l("shadowColor");l("shadowOffset");return{ElementComponent:g}}());Object.assign(pc,function(){var f=["enabled"],b=function(a){pc.ComponentSystem.call(this,a);this.id="element";this.app=a;this.ComponentType=pc.ElementComponent;this.DataType=pc.ElementComponentData;this.schema=f;this._rtlReorder=this._unicodeConverter=null;this._defaultTexture=new pc.Texture(a.graphicsDevice,{width:1,height:1,format:pc.PIXELFORMAT_R8_G8_B8_A8});this._defaultTexture.name="element-system";a=this._defaultTexture.lock();var b=new Uint8Array(4);b[0]=255;b[1]=255;b[2]=255;b[3]=255;a.set(b); this._defaultTexture.unlock();this.defaultScreenSpaceBitmapTextMaterial=this.defaultScreenSpaceTextMaterial=this.defaultBitmapTextMaterial=this.defaultTextMaterial=this.defaultScreenSpaceImageMaskMaterial=this.defaultScreenSpaceImageMask9TiledMaterial=this.defaultScreenSpaceImageMask9SlicedMaterial=this.defaultScreenSpaceImage9TiledMaterial=this.defaultScreenSpaceImage9SlicedMaterial=this.defaultScreenSpaceImageMaterial=this.defaultImage9TiledMaskMaterial=this.defaultImage9SlicedMaskMaterial=this.defaultImageMaskMaterial= this.defaultImage9TiledMaterial=this.defaultImage9SlicedMaterial=this.defaultImageMaterial=null;this.defaultImageMaterials=[];this.on("beforeremove",this.onRemoveComponent,this)};b.prototype=Object.create(pc.ComponentSystem.prototype);b.prototype.constructor=b;pc.Component._buildAccessors(pc.ElementComponent.prototype,f);Object.assign(b.prototype,{destroy:function(){this._defaultTexture.destroy()},initializeComponentData:function(a,b,d){a._beingInitialized=!0;void 0!==b.anchor&&(b.anchor instanceof pc.Vec4?a.anchor.copy(b.anchor):a.anchor.set(b.anchor[0],b.anchor[1],b.anchor[2],b.anchor[3]));void 0!==b.pivot&&(b.pivot instanceof pc.Vec2?a.pivot.copy(b.pivot):a.pivot.set(b.pivot[0],b.pivot[1]));var c=.001a;a+=3)this._normals[a]=0,this._normals[a+1]=0,this._normals[a+ 2]=1;this._uvs[0]=this._rect.x;this._uvs[1]=this._rect.y;this._uvs[2]=this._rect.x+this._rect.z;this._uvs[3]=this._rect.y;this._uvs[4]=this._rect.x+this._rect.z;this._uvs[5]=this._rect.y+this._rect.w;this._uvs[6]=this._rect.x;this._uvs[7]=this._rect.y+this._rect.w;this._indices[0]=0;this._indices[1]=1;this._indices[2]=3;this._indices[3]=2;this._indices[4]=3;this._indices[5]=1;a=pc.createMesh(this._system.app.graphicsDevice,this._positions,{uvs:this._uvs,normals:this._normals,indices:this._indices}); this._updateMesh(a);return a},_updateMesh:function(a){var b;b=this._element;var d=b.calculatedWidth,e=b.calculatedHeight,f=b._isScreenSpace();this._updateMaterial(f);this._renderable&&this._renderable.forceUpdateAabb();if(!this.sprite||this.sprite.renderMode!==pc.SPRITE_RENDERMODE_SLICED&&this.sprite.renderMode!==pc.SPRITE_RENDERMODE_TILED){this._positions[0]=0;this._positions[1]=0;this._positions[2]=0;this._positions[3]=d;this._positions[4]=0;this._positions[5]=0;this._positions[6]=d;this._positions[7]= e;this._positions[8]=0;this._positions[9]=0;this._positions[10]=e;this._positions[11]=0;var f=b.pivot.x,l=b.pivot.y;for(b=0;bb;b++)d.element[pc.SEMANTIC_POSITION].set(this._positions[3*b+0],this._positions[3*b+1],this._positions[3*b+2]),d.element[pc.SEMANTIC_NORMAL].set(this._normals[3*b+0],this._normals[3*b+1],this._normals[3*b+2]),d.element[pc.SEMANTIC_TEXCOORD0].set(this._uvs[2*b+0],this._uvs[2*b+1]),d.next();d.end();a.aabb.compute(this._positions); this._renderable&&(this._renderable.node.setLocalScale(1,1,1),this._renderable.node.setLocalPosition(0,0,0),this._renderable.setAabbFunc(null))}else a=this._sprite.atlas.frames[this._sprite.frameKeys[this._spriteFrame]],f=2/a.rect.z,l=2/a.rect.w,this._innerOffset.set(a.border.x*f,a.border.y*l,a.border.z*f,a.border.w*l),f=this.sprite.atlas.texture,this._atlasRect.set(a.rect.x/f.width,a.rect.y/f.height,a.rect.z/f.width,a.rect.w/f.height),l=null!==this._pixelsPerUnit?this._pixelsPerUnit:this.sprite.pixelsPerUnit, f=a.rect.z/l,a=a.rect.w/l,this._outerScale.set(Math.max(d,this._innerOffset.x*f),Math.max(e,this._innerOffset.y*a)),l=a,this._outerScale.x/=f,this._outerScale.y/=a,f*=pc.math.clamp(d/(this._innerOffset.x*f),1E-4,1),l*=pc.math.clamp(e/(this._innerOffset.y*a),1E-4,1),this._renderable&&(this._innerOffsetUniform[0]=this._innerOffset.x,this._innerOffsetUniform[1]=this._innerOffset.y,this._innerOffsetUniform[2]=this._innerOffset.z,this._innerOffsetUniform[3]=this._innerOffset.w,this._renderable.setParameter("innerOffset", this._innerOffsetUniform),this._atlasRectUniform[0]=this._atlasRect.x,this._atlasRectUniform[1]=this._atlasRect.y,this._atlasRectUniform[2]=this._atlasRect.z,this._atlasRectUniform[3]=this._atlasRect.w,this._renderable.setParameter("atlasRect",this._atlasRectUniform),this._outerScaleUniform[0]=this._outerScale.x,this._outerScaleUniform[1]=this._outerScale.y,this._renderable.setParameter("outerScale",this._outerScaleUniform),this._renderable.setAabbFunc(this._updateAabbFunc),this._renderable.node.setLocalScale(f, l,1),this._renderable.node.setLocalPosition((.5-b.pivot.x)*d,(.5-b.pivot.y)*e,0));this._meshDirty=!1},_updateSprite:function(){var a=!1,b=null;this._sprite&&this._sprite.atlas&&(b=this._sprite.meshes[this.spriteFrame],a=this._sprite.renderMode===pc.SPRITE_RENDERMODE_SLICED||this._sprite.renderMode===pc.SPRITE_RENDERMODE_TILED);if(this.mesh=a?b:this._defaultMesh)this._element._beingInitialized?this._meshDirty=!0:this._updateMesh(this.mesh)},_updateAabb:function(a){a.center.set(0,0,0);a.halfExtents.set(.5* this._outerScale.x,.5*this._outerScale.y,.001);a.setFromTransformedAabb(a,this._renderable.node.getWorldTransform());return a},_toggleMask:function(){this._element._dirtifyMask();var a=this._element._isScreenSpace();this._updateMaterial(a);this._renderable.setMask(!!this._mask)},_onMaterialLoad:function(a){this.material=a.resource},_onMaterialAdded:function(a){this._system.app.assets.off("add:"+a.id,this._onMaterialAdded,this);this._materialAsset===a.id&&this._bindMaterialAsset(a)},_bindMaterialAsset:function(a){this._entity.enabled&& (a.on("load",this._onMaterialLoad,this),a.on("change",this._onMaterialChange,this),a.on("remove",this._onMaterialRemove,this),a.resource?this._onMaterialLoad(a):this._system.app.assets.load(a))},_unbindMaterialAsset:function(a){a.off("load",this._onMaterialLoad,this);a.off("change",this._onMaterialChange,this);a.off("remove",this._onMaterialRemove,this)},_onMaterialChange:function(){},_onMaterialRemove:function(){},_onTextureAdded:function(a){this._system.app.assets.off("add:"+a.id,this._onTextureAdded, this);this._textureAsset===a.id&&this._bindTextureAsset(a)},_bindTextureAsset:function(a){this._entity.enabled&&(a.on("load",this._onTextureLoad,this),a.on("change",this._onTextureChange,this),a.on("remove",this._onTextureRemove,this),a.resource?this._onTextureLoad(a):this._system.app.assets.load(a))},_unbindTextureAsset:function(a){a.off("load",this._onTextureLoad,this);a.off("change",this._onTextureChange,this);a.off("remove",this._onTextureRemove,this)},_onTextureLoad:function(a){this.texture= a.resource},_onTextureChange:function(a){},_onTextureRemove:function(a){},_onSpriteAssetAdded:function(a){this._system.app.assets.off("add:"+a.id,this._onSpriteAssetAdded,this);this._spriteAsset===a.id&&this._bindSpriteAsset(a)},_bindSpriteAsset:function(a){this._entity.enabled&&(a.on("load",this._onSpriteAssetLoad,this),a.on("change",this._onSpriteAssetChange,this),a.on("remove",this._onSpriteAssetRemove,this),a.resource?this._onSpriteAssetLoad(a):this._system.app.assets.load(a))},_unbindSpriteAsset:function(a){a.off("load", this._onSpriteAssetLoad,this);a.off("change",this._onSpriteAssetChange,this);a.off("remove",this._onSpriteAssetRemove,this);a.data.textureAtlasAsset&&this._system.app.assets.off("load:"+a.data.textureAtlasAsset,this._onTextureAtlasLoad,this)},_onSpriteAssetLoad:function(a){if(a&&a.resource)if(a.resource.atlas)this.sprite=a.resource;else{if(a=a.data.textureAtlasAsset){var b=this._system.app.assets;b.off("load:"+a,this._onTextureAtlasLoad,this);b.once("load:"+a,this._onTextureAtlasLoad,this)}}else this.sprite= null},_onSpriteAssetChange:function(a){this._onSpriteAssetLoad(a)},_onSpriteAssetRemove:function(a){},_bindSprite:function(a){a.on("set:meshes",this._onSpriteMeshesChange,this);a.on("set:pixelsPerUnit",this._onSpritePpuChange,this);a.on("set:atlas",this._onAtlasTextureChange,this);if(a.atlas)a.atlas.on("set:texture",this._onAtlasTextureChange,this)},_unbindSprite:function(a){a.off("set:meshes",this._onSpriteMeshesChange,this);a.off("set:pixelsPerUnit",this._onSpritePpuChange,this);a.off("set:atlas", this._onAtlasTextureChange,this);a.atlas&&a.atlas.off("set:texture",this._onAtlasTextureChange,this)},_onSpriteMeshesChange:function(){this._sprite&&(this._spriteFrame=pc.math.clamp(this._spriteFrame,0,this._sprite.frameKeys.length-1));this._updateSprite()},_onSpritePpuChange:function(){this.sprite.renderMode!==pc.SPRITE_RENDERMODE_SIMPLE&&null===this._pixelsPerUnit&&this._updateSprite()},_onAtlasTextureChange:function(){this.sprite&&this.sprite.atlas&&this.sprite.atlas.texture?(this._renderable.setParameter("texture_emissiveMap", this._sprite.atlas.texture),this._renderable.setParameter("texture_opacityMap",this._sprite.atlas.texture)):(this._renderable.deleteParameter("texture_emissiveMap"),this._renderable.deleteParameter("texture_opacityMap"))},_onTextureAtlasLoad:function(a){a=this._spriteAsset;a instanceof pc.Asset?this._onSpriteAssetLoad(a):this._onSpriteAssetLoad(this._system.app.assets.get(a))},onEnable:function(){var a;this._materialAsset&&(a=this._system.app.assets.get(this._materialAsset))&&a.resource!==this._material&& this._bindMaterialAsset(a);this._textureAsset&&(a=this._system.app.assets.get(this._textureAsset))&&a.resource!==this._texture&&this._bindTextureAsset(a);this._spriteAsset&&(a=this._system.app.assets.get(this._spriteAsset))&&a.resource!==this._sprite&&this._bindSpriteAsset(a);this._element.addModelToLayers(this._renderable.model)},onDisable:function(){this._element.removeModelFromLayers(this._renderable.model)},_setStencil:function(a){this._renderable.meshInstance.stencilFront=a;this._renderable.meshInstance.stencilBack= a;a=0;this._element.maskedBy&&(a=this._element.maskedBy.element._image._maskRef);this._renderable.unmaskMeshInstance&&(a=new pc.StencilParameters({ref:a+1,func:pc.FUNC_EQUAL,zpass:pc.STENCILOP_DECREMENT}),this._renderable.unmaskMeshInstance.stencilFront=a,this._renderable.unmaskMeshInstance.stencilBack=a)}});Object.defineProperty(b.prototype,"color",{get:function(){return this._color},set:function(a){var b=a.r,d=a.g;a=a.b;if(this._color.r!==b||this._color.g!==d||this._color.b!==a)this._color.r=b, this._color.g=d,this._color.b=a,this._colorUniform[0]=b,this._colorUniform[1]=d,this._colorUniform[2]=a,this._renderable.setParameter("material_emissive",this._colorUniform),this._element&&this._element.fire("set:color",this._color)}});Object.defineProperty(b.prototype,"opacity",{get:function(){return this._color.a},set:function(a){a!==this._color.a&&(this._color.a=a,this._renderable.setParameter("material_opacity",a),this._element&&this._element.fire("set:opacity",a))}});Object.defineProperty(b.prototype, "rect",{get:function(){return this._rect},set:function(a){var b,d,e;a instanceof pc.Vec4?(b=a.x,d=a.y,e=a.z,a=a.w):(b=a[0],d=a[1],e=a[2],a=a[3]);if(b!==this._rect.x||d!==this._rect.y||e!==this._rect.z||a!==this._rect.w)this._rect.set(b,d,e,a),this._renderable.mesh&&(this._element._beingInitialized?this._meshDirty=!0:this._updateMesh(this._renderable.mesh))}});Object.defineProperty(b.prototype,"material",{get:function(){return this._material},set:function(a){this._material!==a&&(a||(a=this._element._isScreenSpace(), a=this.mask?a?this._system.defaultScreenSpaceImageMaskMaterial:this._system.defaultImageMaskMaterial:a?this._system.defaultScreenSpaceImageMaterial:this._system.defaultImageMaterial),this._material=a)&&(this._renderable.setMaterial(a),this._hasUserMaterial()?(this._renderable.deleteParameter("material_opacity"),this._renderable.deleteParameter("material_emissive")):(this._colorUniform[0]=this._color.r,this._colorUniform[1]=this._color.g,this._colorUniform[2]=this._color.b,this._renderable.setParameter("material_emissive", this._colorUniform),this._renderable.setParameter("material_opacity",this._color.a)))}});Object.defineProperty(b.prototype,"materialAsset",{get:function(){return this._materialAsset},set:function(a){var b=this._system.app.assets,d=a;a instanceof pc.Asset&&(d=a.id);this._materialAsset!==d&&(this._materialAsset&&(b.off("add:"+this._materialAsset,this._onMaterialAdded,this),a=b.get(this._materialAsset))&&(a.off("load",this._onMaterialLoad,this),a.off("change",this._onMaterialChange,this),a.off("remove", this._onMaterialRemove,this)),(this._materialAsset=d)?(d=b.get(this._materialAsset))?this._bindMaterialAsset(d):(this.material=null,b.on("add:"+this._materialAsset,this._onMaterialAdded,this)):this.material=null)}});Object.defineProperty(b.prototype,"texture",{get:function(){return this._texture},set:function(a){if(this._texture!==a){if(this._textureAsset){var b=this._system.app.assets.get(this._textureAsset);b&&b.resource!==a&&(this.textureAsset=null)}(this._texture=a)?(this._spriteAsset&&(this.spriteAsset= null),this._renderable.setParameter("texture_emissiveMap",this._texture),this._renderable.setParameter("texture_opacityMap",this._texture),this._colorUniform[0]=this._color.r,this._colorUniform[1]=this._color.g,this._colorUniform[2]=this._color.b,this._renderable.setParameter("material_emissive",this._colorUniform),this._renderable.setParameter("material_opacity",this._color.a)):(this._renderable.deleteParameter("texture_emissiveMap"),this._renderable.deleteParameter("texture_opacityMap"))}}});Object.defineProperty(b.prototype, "textureAsset",{get:function(){return this._textureAsset},set:function(a){var b=this._system.app.assets,d=a;a instanceof pc.Asset&&(d=a.id);this._textureAsset!==d&&(this._textureAsset&&(b.off("add:"+this._textureAsset,this._onTextureAdded,this),a=b.get(this._textureAsset))&&(a.off("load",this._onTextureLoad,this),a.off("change",this._onTextureChange,this),a.off("remove",this._onTextureRemove,this)),(this._textureAsset=d)?(d=b.get(this._textureAsset))?this._bindTextureAsset(d):(this.texture=null,b.on("add:"+ this._textureAsset,this._onTextureAdded,this)):this.texture=null)}});Object.defineProperty(b.prototype,"spriteAsset",{get:function(){return this._spriteAsset},set:function(a){var b=this._system.app.assets,d=a;a instanceof pc.Asset&&(d=a.id);this._spriteAsset!==d&&(this._spriteAsset&&(b.off("add:"+this._spriteAsset,this._onSpriteAssetAdded,this),(a=b.get(this._spriteAsset))&&this._unbindSpriteAsset(a)),(this._spriteAsset=d)?(a=b.get(this._spriteAsset))?this._bindSpriteAsset(a):(this.sprite=null,b.on("add:"+ this._spriteAsset,this._onSpriteAssetAdded,this)):this.sprite=null,this._element&&this._element.fire("set:spriteAsset",d))}});Object.defineProperty(b.prototype,"sprite",{get:function(){return this._sprite},set:function(a){if(this._sprite!==a){this._sprite&&this._unbindSprite(this._sprite);if(this._spriteAsset){var b=this._system.app.assets.get(this._spriteAsset);b&&b.resource!==a&&(this.spriteAsset=null)}if(this._sprite=a)this._bindSprite(this._sprite),this._textureAsset&&(this.textureAsset=null); this._sprite&&this._sprite.atlas&&this._sprite.atlas.texture?(this._renderable.setParameter("texture_emissiveMap",this._sprite.atlas.texture),this._renderable.setParameter("texture_opacityMap",this._sprite.atlas.texture)):(this._renderable.deleteParameter("texture_emissiveMap"),this._renderable.deleteParameter("texture_opacityMap"));this._sprite&&(this._spriteFrame=pc.math.clamp(this._spriteFrame,0,this._sprite.frameKeys.length-1));this._updateSprite()}}});Object.defineProperty(b.prototype,"spriteFrame", {get:function(){return this._spriteFrame},set:function(a){var b=this._spriteFrame;this._spriteFrame=this._sprite?pc.math.clamp(a,0,this._sprite.frameKeys.length-1):a;this._spriteFrame!==b&&(this._updateSprite(),this._element&&this._element.fire("set:spriteFrame",a))}});Object.defineProperty(b.prototype,"mesh",{get:function(){return this._renderable.mesh},set:function(a){this._renderable.setMesh(a);this._defaultMesh===a?this._renderable.setAabbFunc(null):this._renderable.setAabbFunc(this._updateAabbFunc)}}); Object.defineProperty(b.prototype,"mask",{get:function(){return this._mask},set:function(a){this._mask!==a&&(this._mask=a,this._toggleMask())}});Object.defineProperty(b.prototype,"pixelsPerUnit",{get:function(){return this._pixelsPerUnit},set:function(a){this._pixelsPerUnit!==a&&(this._pixelsPerUnit=a,!this._sprite||this._sprite.renderMode!==pc.SPRITE_RENDERMODE_SLICED&&this._sprite.renderMode!==pc.SPRITE_RENDERMODE_TILED||this._updateSprite())}});Object.defineProperty(b.prototype,"aabb",{get:function(){return this._renderable.meshInstance? this._renderable.meshInstance.aabb:null}});return{ImageElement:b}}());Object.assign(pc,function(){var f=function(){this.quad=this.count=0;this.lines={};this.positions=[];this.normals=[];this.uvs=[];this.indices=[];this.meshInstance=null},b=function(a){this._element=a;this._system=a.system;this._entity=a.entity;this._text="";this._font=this._fontAsset=this._i18nKey=null;this._color=new pc.Color(1,1,1,1);this._colorUniform=new Float32Array(3);this._spacing=1;this._lineHeight=this._fontSize=32;this._wrapLines=!1;this._drawOrder=0;this._alignment=new pc.Vec2(.5,.5);this._autoHeight= this._autoWidth=!0;this.height=this.width=0;this._node=new pc.GraphNode;this._model=new pc.Model;this._model.graph=this._node;this._entity.addChild(this._node);this._meshInfo=[];this._material=null;this._aabbDirty=!0;this._aabb=new pc.BoundingBox;this._noResize=!1;this._maskedMaterialSrc=this._currentMaterialType=null;this._unicodeConverter=this._rtlReorder=!1;this._outlineColor=new pc.Color(0,0,0,1);this._outlineColorUniform=new Float32Array(4);this._outlineThicknessScale=.2;this._outlineThickness= 0;this._shadowColor=new pc.Color(0,0,0,1);this._shadowColorUniform=new Float32Array(4);this._shadowOffsetScale=.005;this._shadowOffset=new pc.Vec2(0,0);this._shadowOffsetUniform=new Float32Array(2);this._onScreenChange(this._element.screen);a.on("resize",this._onParentResize,this);this._element.on("set:screen",this._onScreenChange,this);a.on("screen:set:screenspace",this._onScreenSpaceChange,this);a.on("set:draworder",this._onDrawOrderChange,this);a.on("set:pivot",this._onPivotChange,this);this._system.app.i18n.on("set:locale", this._resetLocalizedText,this);this._system.app.i18n.on("data:add",this._onLocalizationData,this);this._system.app.i18n.on("data:remove",this._onLocalizationData,this)},a=/^[\r\n]$/,c=/^[ \t]$/,d=/^[ \t\-]$/;Object.assign(b.prototype,{destroy:function(){this._setMaterial(null);this._model&&(this._element.removeModelFromLayers(this._model),this._model.destroy(),this._model=null);this.font=this.fontAsset=null;this._element.off("resize",this._onParentResize,this);this._element.off("set:screen",this._onScreenChange, this);this._element.off("screen:set:screenspace",this._onScreenSpaceChange,this);this._element.off("set:draworder",this._onDrawOrderChange,this);this._element.off("set:pivot",this._onPivotChange,this)},_onParentResize:function(a,b){this._noResize||this._font&&this._updateText(this._text)},_onScreenChange:function(a){a?this._updateMaterial(a.screen.screenSpace):this._updateMaterial(!1)},_onScreenSpaceChange:function(a){this._updateMaterial(a)},_onDrawOrderChange:function(a){this._drawOrder=a;if(this._model){var b, c;b=0;for(c=this._model.meshInstances.length;b=x&&0=this._meshInfo.length)z.lines[m-1]-=B,z.quad-=B;else for(C=t;C=D?(B.element[pc.SEMANTIC_POSITION].set(0,0,0),B.element[pc.SEMANTIC_TEXCOORD0].set(0,0)):(B.element[pc.SEMANTIC_POSITION].set(this._meshInfo[A].positions[3*C+0],this._meshInfo[A].positions[3*C+1],this._meshInfo[A].positions[3*C+2]),B.element[pc.SEMANTIC_TEXCOORD0].set(this._meshInfo[A].uvs[2*C+0],this._meshInfo[A].uvs[2*C+1])),B.next();B.end();this._meshInfo[A].meshInstance.mesh.aabb.compute(this._meshInfo[A].positions);this._meshInfo[A].meshInstance._aabbVer=-1}this._aabbDirty= !0},_onFontAdded:function(a){this._system.app.assets.off("add:"+a.id,this._onFontAdded,this);a.id===this._fontAsset&&this._bindFont(a)},_bindFont:function(a){this._entity.enabled&&(a.on("load",this._onFontLoad,this),a.on("change",this._onFontChange,this),a.on("remove",this._onFontRemove,this),a.resource?this._onFontLoad(a):this._system.app.assets.load(a))},_unbindFont:function(a){a.off("load",this._onFontLoad,this);a.off("change",this._onFontChange,this);a.off("remove",this._onFontRemove,this)},_onFontRender:function(){this.font= this._font},_onFontLoad:function(a){this.font!==a.resource&&(this.font=a.resource)},_onFontChange:function(a,b,c,d){if("data"===b)for(this._font.data=c,a=this._font.data.info.maps.length,b=0;bthis._font.textures.length&&(this._meshInfo.length=this._font.textures.length);this._updateText()}}});Object.defineProperty(b.prototype,"alignment",{get:function(){return this._alignment},set:function(a){a instanceof pc.Vec2?this._alignment.set(a.x,a.y):this._alignment.set(a[0],a[1]);this._font&&this._updateText()}});Object.defineProperty(b.prototype,"autoWidth",{get:function(){return this._autoWidth},set:function(a){(this._autoWidth=a)&&1E-4>Math.abs(this._element.anchor.x- this._element.anchor.z)&&(this._element.width=this.width)}});Object.defineProperty(b.prototype,"autoHeight",{get:function(){return this._autoHeight},set:function(a){(this._autoHeight=a)&&1E-4>Math.abs(this._element.anchor.y-this._element.anchor.w)&&(this._element.height=this.height)}});Object.defineProperty(b.prototype,"rtlReorder",{get:function(){return this._rtlReorder},set:function(a){this._rtlReorder!==a&&(this._rtlReorder=a,this._font&&this._updateText())}});Object.defineProperty(b.prototype, "unicodeConverter",{get:function(){return this._unicodeConverter},set:function(a){this._unicodeConverter!==a&&(this._unicodeConverter=a,this.text=this._text)}});Object.defineProperty(b.prototype,"aabb",{get:function(){if(this._aabbDirty){for(var a=!1,b=0;bthis.dragThreshold||Math.abs(b)>this.dragThreshold)&&this._disableContentInput()}},_onSetContentOrViewportSize:function(){this._syncAll()},_onSetHorizontalScrollbarValue:function(a){!this._scrollbarUpdateFlags[pc.ORIENTATION_HORIZONTAL]&&this.enabled&&this.entity.enabled&&this._onSetScroll(a,null)},_onSetVerticalScrollbarValue:function(a){!this._scrollbarUpdateFlags[pc.ORIENTATION_VERTICAL]&& this.enabled&&this.entity.enabled&&this._onSetScroll(null,a)},_onSetHorizontalScrollingEnabled:function(){this._syncScrollbarEnabledState(pc.ORIENTATION_HORIZONTAL)},_onSetVerticalScrollingEnabled:function(){this._syncScrollbarEnabledState(pc.ORIENTATION_VERTICAL)},_onHorizontalScrollbarGain:function(){this._syncScrollbarEnabledState(pc.ORIENTATION_HORIZONTAL);this._syncScrollbarPosition(pc.ORIENTATION_HORIZONTAL)},_onVerticalScrollbarGain:function(){this._syncScrollbarEnabledState(pc.ORIENTATION_VERTICAL); this._syncScrollbarPosition(pc.ORIENTATION_VERTICAL)},_onSetScroll:function(a,b,d){!1!==d&&this._velocity.set(0,0,0);a=0|this._updateAxis(a,"x",pc.ORIENTATION_HORIZONTAL);(a|=this._updateAxis(b,"y",pc.ORIENTATION_VERTICAL))&&this.fire("set:scroll",this._scroll)},_updateAxis:function(a,b,d){var c=null!==a&&1E-5this._getViewportSize(a)},_contentPositionToScrollValue:function(a){var b=this._getMaxOffset(pc.ORIENTATION_HORIZONTAL),d=this._getMaxOffset(pc.ORIENTATION_VERTICAL); f.x=0===b?0:a.x/b;f.y=0===d?0:a.y/-d;return f},_getMaxOffset:function(a,b){b=void 0===b?this._getContentSize(a):b;var c=this._getViewportSize(a);return bMath.abs(e))return 1;c=Math.min(c/e,1);e=this._toOvershoot(this._scroll[a],b);return 0===e?c:c/(1+Math.abs(e))},_getViewportSize:function(a){return this._getSize(a, this._viewportReference)},_getContentSize:function(a){return this._getSize(a,this._contentReference)},_getSize:function(a,b){return b.entity&&b.entity.element?b.entity.element[this._getCalculatedDimension(a)]:0},_getScrollingEnabled:function(a){if(a===pc.ORIENTATION_HORIZONTAL)return this.horizontal;if(a===pc.ORIENTATION_VERTICAL)return this.vertical;console.warn("Unrecognized orientation: "+a)},_getScrollbarVisibility:function(a){if(a===pc.ORIENTATION_HORIZONTAL)return this.horizontalScrollbarVisibility; if(a===pc.ORIENTATION_VERTICAL)return this.verticalScrollbarVisibility;console.warn("Unrecognized orientation: "+a)},_getSign:function(a){return a===pc.ORIENTATION_HORIZONTAL?1:-1},_getAxis:function(a){return a===pc.ORIENTATION_HORIZONTAL?"x":"y"},_getCalculatedDimension:function(a){return a===pc.ORIENTATION_HORIZONTAL?"calculatedWidth":"calculatedHeight"},_destroyDragHelper:function(){this._contentDragHelper&&this._contentDragHelper.destroy()},onUpdate:function(){this._contentReference.entity&&(this._updateVelocity(), this._syncScrollbarEnabledState(pc.ORIENTATION_HORIZONTAL),this._syncScrollbarEnabledState(pc.ORIENTATION_VERTICAL))},_updateVelocity:function(){if(!this._isDragging()&&(this.scrollMode===pc.SCROLL_MODE_BOUNCE&&(this._hasOvershoot("x",pc.ORIENTATION_HORIZONTAL)&&this._setVelocityFromOvershoot(this.scroll.x,"x",pc.ORIENTATION_HORIZONTAL),this._hasOvershoot("y",pc.ORIENTATION_VERTICAL)&&this._setVelocityFromOvershoot(this.scroll.y,"y",pc.ORIENTATION_VERTICAL)),this._velocity.x*=1-this.friction,this._velocity.y*= 1-this.friction,1E-4a?a:a>c?a-c:0},_setVelocityFromOvershoot:function(a,b,d){a=this._toOvershoot(a, d)*this._getMaxOffset(d)*this._getSign(d);0d&&(a.x=-1*Math.log10(1-d));b=this._getMaxScrollValue(pc.ORIENTATION_VERTICAL);d=this._toOvershoot(a.y,pc.ORIENTATION_VERTICAL);0d&&(a.y=-1*Math.log10(1-d));return a},_isDragging:function(){return this._contentDragHelper&&this._contentDragHelper.isDragging},_setScrollbarComponentsEnabled:function(a){this._scrollbarReferences[pc.ORIENTATION_HORIZONTAL].hasComponent("scrollbar")&& (this._scrollbarReferences[pc.ORIENTATION_HORIZONTAL].entity.scrollbar.enabled=a);this._scrollbarReferences[pc.ORIENTATION_VERTICAL].hasComponent("scrollbar")&&(this._scrollbarReferences[pc.ORIENTATION_VERTICAL].entity.scrollbar.enabled=a)},_setContentDraggingEnabled:function(a){this._contentDragHelper&&(this._contentDragHelper.enabled=a)},_enableContentInput:function(){for(;this._disabledContentInputEntities.length;){var a=this._disabledContentInputEntities.pop();a.element&&(a.element.useInput=!0)}this._disabledContentInput= !1},_disableContentInput:function(){var a=this,b=function(c){c.element&&c.element.useInput&&(a._disabledContentInputEntities.push(c),c.element.useInput=!1);c=c.children;var d,e;d=0;for(e=c.length;d=c?e.APPLY_SHRINKING:e.NONE;case pc.FITTING_BOTH:return b=c?e.APPLY_SHRINKING:e.NONE;default:throw Error("Unrecognized fitting mode: "+a);}}function k(a,b){return y(a,b.size)+(a.length- 1)*C.spacing[b.axis]}function q(a,b,c){var d=w(a,c.maxSize),e=u(a,c.fittingProportion),f=z(e,d);b=g[c.axis]-b;for(var l=0;lMath.abs(c)&&1E-5>Math.abs(a)?b:b*c/a}function t(a){for(var b=[],c=0;cg[A.axis]&&0!==d[d.length-1].length&&(n=v,d.push([]));d[d.length-1].push(c[r]);p&&n>g[A.axis]&&r!==c.length-1&&(n=0,d.push([]))}c=d}else c=[c];d=C.orientation===pc.ORIENTATION_HORIZONTAL&&C.reverseX||C.orientation===pc.ORIENTATION_VERTICAL&&C.reverseY;h=C.orientation===pc.ORIENTATION_HORIZONTAL&&C.reverseY||C.orientation===pc.ORIENTATION_VERTICAL&&C.reverseX;if(d)for(n= 0;np.largestSize[B.size]&&(p.largestElement=p[h],p.largestSize=u)}v.push(p.largestElement);r.push(p.largestSize)}h= k(r,B);n=l(C[B.fitting],h,g[B.axis]);n===e.APPLY_STRETCHING?q(r,h,B):n===e.APPLY_SHRINKING&&m(r,h,B);for(n=0;nthis._data.version)if(this._data.info.maps=[{width:this._data.info.width, height:this._data.info.height}],this._data.chars)for(var a in this._data.chars)this._data.chars[a].map=0}});return{FONT_MSDF:pc.FONT_MSDF,Font:f}}());Object.assign(pc,function(){var f=function(b,a){this.type="bitmap";this.app=b;this.intensity=0;a=a||{};this.fontWeight=a.fontWeight||"normal";this.glyphSize=this.fontSize=parseInt(a.fontSize,10);this.fontName=a.fontName||"Arial";this.color=a.color||new pc.Color(1,1,1);var c=4096c&&(v=t,y+=r,y>d&&(this.textures[b-1].upload(),b++,y=r,b>p?(a=document.createElement("canvas"),a.height=d,a.width=c,f=this._getAndClearContext(a,l),u=new pc.Texture(this.app.graphicsDevice,{format:pc.PIXELFORMAT_R8_G8_B8_A8, autoMipmap:!0}),u.name="font-atlas",u.setSource(a),u.minFilter=pc.FILTER_LINEAR_MIPMAP_LINEAR,u.magFilter=pc.FILTER_LINEAR,u.addressU=pc.ADDRESS_CLAMP_TO_EDGE,u.addressV=pc.ADDRESS_CLAMP_TO_EDGE,this.textures.push(u)):(a=this.textures[b-1].getSource(),f=this._getAndClearContext(a,l))))}this.textures[b-1].upload();if(bb&&(c=d-1);return a};f.prototype._doSort=function(b,a){var c=this._sortBy;return b[c]-a[c]};f.prototype.insert=function(b){var a=this._binarySearch(b);this.items.splice(a,0,b); this.length++;this.loopIndex>=a&&this.loopIndex++};f.prototype.append=function(b){this.items.push(b);this.length++};f.prototype.remove=function(b){b=this.items.indexOf(b);0>b||(this.items.splice(b,1),this.length--,this.loopIndex>=b&&this.loopIndex--)};f.prototype.sort=function(){var b=0<=this.loopIndex?this.items[this.loopIndex]:null;this.items.sort(this._sortHandler);null!==b&&(this.loopIndex=this.items.indexOf(b))};return{SortedLoopArray:f}}());Object.assign(pc,function(){var f=function(b){this._handlers={};this._requests={};this._cache={};this._app=b};Object.assign(f.prototype,{addHandler:function(b,a){this._handlers[b]=a;a._loader=this},removeHandler:function(b){delete this._handlers[b]},getHandler:function(b){return this._handlers[b]},load:function(b,a,c,d){var e=this._handlers[a];if(e){var f=b+a;if(void 0!==this._cache[f])c(null,this._cache[f]);else if(this._requests[f])this._requests[f].push(c);else{this._requests[f]=[c];var l=function(a, b){if(a){console.error(a);if(this._requests[f])for(var c=0,g=this._requests[f].length;c=e)throw Error("Invalid PAX header data format.");var k=parseInt(d.decode(new Uint8Array(a,b+g,h-g)),10);h=d.decode(new Uint8Array(a,b+h+1,k-(h- g)-2)).split("=");if(2!==h.length)throw Error("Invalid PAX header data format.");0===h[1].length&&(h[1]=null);l.push({name:h[0],value:h[1]});g+=k}return new c(l)};c.prototype.applyHeader=function(a){for(var b=0;bd;d++)e=new pc.Texture(this._device, {cubemap:!0,fixCubemapSeams:!0,mipmaps:!0,format:b._dds.format,rgbm:b._dds.rgbm,width:Math.pow(2,7-d),height:Math.pow(2,7-d)}),e.name="cubemap-mip",e._levels[0]=b._dds._levels[d],e.upload(),b.resources.push(e);d=!0}e=b.resource;e.name!==b.name&&(e.name=b.name);var f=!!b.data.rgbm;b.data.hasOwnProperty("rgbm")&&e.rgbm!==f&&(e.rgbm=f);e.fixCubemapSeams=!!b._dds;b.data.hasOwnProperty("minFilter")&&e.minFilter!==b.data.minFilter&&(e.minFilter=b.data.minFilter);b.data.hasOwnProperty("magFilter")&&e.magFilter!== b.data.magFilter&&(e.magFilter=b.data.magFilter);b.data.hasOwnProperty("anisotropy")&&e.anisotropy!==b.data.anisotropy&&(e.anisotropy=b.data.anisotropy);e.addressU!==pc.ADDRESS_CLAMP_TO_EDGE&&(e.addressU=pc.ADDRESS_CLAMP_TO_EDGE);e.addressV!==pc.ADDRESS_CLAMP_TO_EDGE&&(e.addressV=pc.ADDRESS_CLAMP_TO_EDGE);this._patchTextureFaces(b,a);d&&(a.fire("load",b),a.fire("load:"+b.id,b),b.fire("load",b))},_patchTexture:function(){this.registry._loader._handlers.cubemap._patchTextureFaces(this,this.registry)}, _patchTextureFaces:function(b,a){if(b.loadFaces||!b.file){var c=b.resource,d=[],e=0,f=!1,l=this;b._levelsEvents||(b._levelsEvents=[null,null,null,null,null,null]);b.data.textures.forEach(function(g,p){var h=function(g){e++;d[p]=g&&g.resource.getSource()||null;var h=b._levelsEvents[p];if(h!==g){h&&h.off("load",l._patchTexture,b);if(g)g.on("load",l._patchTexture,b);b._levelsEvents[p]=g||null}d[p]!==c._levels[0][p]&&(f=!0);6===e&&f&&(c.setSource(d),a.fire("load",b),a.fire("load:"+b.id,b),b.fire("load", b))},k=function(b){b.ready(h);a.load(b)},q=a.get(g);q?(q.ready(h),a.load(q)):g?(a.once("load:"+g,h),a.once("add:"+g,k)):h(null)})}}});return{CubemapHandler:f}}());Object.assign(pc,function(){var f=function(){};Object.assign(f.prototype,{load:function(b,a){"string"===typeof b&&(b={load:b,original:b});var c={};b.load.startsWith("blob:")&&(c.responseType=pc.Http.ResponseType.JSON);pc.http.get(b.load,c,function(c,e){c?a(pc.string.format("Error loading JSON resource: {0} [{1}]",b.original,c)):a(null,e)})},open:function(b,a){return a},patch:function(b,a){}});return{JsonHandler:f}}());Object.assign(pc,function(){var f={aoMap:"white",diffuseMap:"gray",specularMap:"gray",metalnessMap:"black",glossMap:"gray",emissiveMap:"gray",normalMap:"normal",heightMap:"gray",opacityMap:"gray",sphereMap:"gray",lightMap:"white"},b=function(a){this._assets=a.assets;this._device=a.graphicsDevice;this._placeholderTextures=null;this._parser=new pc.JsonStandardMaterialParser};Object.assign(b.prototype,{load:function(a,b){"string"===typeof a&&(a={load:a,original:a});pc.http.get(a.load,function(c,e){c? b&&b(pc.string.format("Error loading material: {0} [{1}]",a.original,c)):b&&(e._engine=!0,b(null,e))})},open:function(a,b){var c=this._parser.parse(b);b._engine&&(c._data=b,delete b._engine);return c},_createPlaceholders:function(){this._placeholderTextures={};var a={white:[255,255,255,255],gray:[128,128,128,255],black:[0,0,0,255],normal:[128,128,255,255]},b;for(b in a)if(a.hasOwnProperty(b)){this._placeholderTextures[b]=new pc.Texture(this._device,{width:2,height:2,format:pc.PIXELFORMAT_R8_G8_B8_A8}); this._placeholderTextures[b].name="placeholder";for(var d=this._placeholderTextures[b].lock(),e=0;4>e;e++)for(var f=0;4>f;f++)d[4*e+f]=a[b][f];this._placeholderTextures[b].unlock()}},patch:function(a,b){a.resource._data&&(a._data=a.resource._data,delete a.resource._data);a.data.name=a.name;a.resource.name=a.name;this._bindAndAssignAssets(a,b);a.off("unload",this._onAssetUnload,this);a.on("unload",this._onAssetUnload,this)},_onAssetUnload:function(a){delete a.data.parameters;delete a.data.chunks;delete a.data.name}, _assignTexture:function(a,b,d){b.data[a]=d;b.resource[a]=d},_assignPlaceholderTexture:function(a,b){this._placeholderTextures||this._createPlaceholders();b.resource[a]=this._placeholderTextures[f[a]]},_onTextureLoad:function(a,b,d){this._assignTexture(a,b,d.resource);b.resource.update()},_onTextureAdd:function(a,b,d){this._assets.load(d)},_onTextureRemove:function(a,b,d){var c=b.resource;c[a]===d.resource&&(this._assignTexture(a,b,null),c.update())},_assignCubemap:function(a,b,d){b.data[a]=d[0];7=== d.length&&(b.data.prefilteredCubeMap128=d[1],b.data.prefilteredCubeMap64=d[2],b.data.prefilteredCubeMap32=d[3],b.data.prefilteredCubeMap16=d[4],b.data.prefilteredCubeMap8=d[5],b.data.prefilteredCubeMap4=d[6])},_onCubemapLoad:function(a,b,d){this._assignCubemap(a,b,d.resources);this._parser.initialize(b.resource,b.data)},_onCubemapAdd:function(a,b,d){b.data.shadingModel===pc.SPECULAR_PHONG&&(b.loadFaces=!0);this._assets.load(d)},_onCubemapRemove:function(a,b,d){var c=b.resource;c[a]===d.resource&& (this._assignCubemap(a,b,[null,null,null,null,null,null,null]),c.update())},_bindAndAssignAssets:function(a,b){var c=this._parser.migrate(a.data),e=a.resource,f="path"===c.mappingFormat,l=pc.StandardMaterial.TEXTURE_PARAMETERS,k;f&&(k=pc.path.getDirectory(a.getFileUrl()));var p,h,n;for(p=0;pa.version&&(2>a.version&&(a.info.maps=a.info.maps||[{width:a.info.width,height:a.info.height}]),a.chars=Object.keys(a.chars||{}).reduce(function(b,d){var c=a.chars[d],f=void 0!==c.letter?c.letter:pc.string.fromCodePoint(d);2>a.version&&(c.map=c.map||0);b[f]=c;return b},{}),a.version=3);return a}var b=function(a){this._loader=a};Object.assign(b.prototype,{load:function(a,b,d){"string"===typeof a&&(a={load:a,original:a});var c=this;".json"===pc.path.getExtension(a.original)? pc.http.get(a.load,function(d,e){var g=f(e);d?b(pc.string.format("Error loading font resource: {0} [{1}]",a.original,d)):c._loadTextures(a.original.replace(".json",".png"),g,function(a,c){if(a)return b(a);b(null,{data:g,textures:c})})}):(d&&d.data&&(d.data=f(d.data)),this._loadTextures(a.original,d&&d.data,b))},_loadTextures:function(a,b,d){var c=b.info.maps.length,f=0,l=null,k=Array(c),p=this._loader;b=function(b){var e=function(a,e){if(!l){if(a)return l=a,d(a);e.upload();k[b]=e;f++;f===c&&d(null, k)}};0===b?p.load(a,"texture",e):p.load(a.replace(".png",b+".png"),"texture",e)};for(var h=0;h=b.version)return null;var b=this._parseNodes(a),c=this._parseSkins(a,b),f=this._parseMorphs(a,b),l=this._parseVertexBuffers(a),k=this._parseIndexBuffers(a,l),k=this._parseMeshes(a,c.skins,f.morphs,l,k.buffer,k.data);this._initMorphs(a,f.morphs,l,k);a=this._parseMeshInstances(a,b,k,c.skins,c.instances,f.morphs,f.instances);l=new pc.Model;l.graph=b[0];l.meshInstances=a;l.skinInstances=c.instances;l.morphInstances=f.instances;l.getGraph().syncHierarchy();return l}, _parseNodes:function(a){a=a.model;var b=[],c;for(c=0;cr* J+u*F+w*H?-1:1;return h},_initMorphs:function(a,b,e,f){a=a.model;var c,d,g,h,n,q,m,r,t,v,y,u,w,x,D,z=[],C=[];for(e=0;ef&&(f=a)}});Object.defineProperty(d.prototype,"file",{get:function(){return this._file}, set:function(a){var b;if(!!a!==!!this._file||a&&this._file&&a.hash!==this._file)if(a){this._file||(this._file={});this._file.url=a.url;this._file.filename=a.filename;this._file.hash=a.hash;this._file.size=a.size;this._file.variants=this.variants;if(a.hasOwnProperty("variants")&&(this.variants.clear(),a.variants))for(b in a.variants)a.variants[b]&&(this.variants[b]=a.variants[b]);this.fire("change",this,"file",this._file,this._file);this.reload()}else this._file=null,this.variants.clear();else if(a&& this._file&&a.hasOwnProperty("variants")&&(this.variants.clear(),a.variants))for(b in a.variants)a.variants[b]&&(this.variants[b]=a.variants[b])}});Object.defineProperty(d.prototype,"data",{get:function(){return this._data},set:function(a){var b=this._data;this._data=a;a!==b&&(this.fire("change",this,"data",a,b),this.loaded&&this.registry._loader.patch(this,this.registry))}});Object.defineProperty(d.prototype,"resource",{get:function(){return this._resources[0]},set:function(a){var b=this._resources[0]; this._resources[0]=a;this.fire("change",this,"resource",a,b)}});Object.defineProperty(d.prototype,"resources",{get:function(){return this._resources},set:function(a){var b=this._resources;this._resources=a;this.fire("change",this,"resources",a,b)}});Object.defineProperty(d.prototype,"preload",{get:function(){return this._preload},set:function(a){a=!!a;this._preload!==a&&(this._preload=a)&&!this.loaded&&!this.loading&&this.registry&&this.registry.load(this)}});return{Asset:d,ASSET_ANIMATION:"animation", ASSET_AUDIO:"audio",ASSET_IMAGE:"image",ASSET_JSON:"json",ASSET_MODEL:"model",ASSET_MATERIAL:"material",ASSET_TEXT:"text",ASSET_TEXTURE:"texture",ASSET_CUBEMAP:"cubemap",ASSET_SHADER:"shader",ASSET_CSS:"css",ASSET_HTML:"html",ASSET_SCRIPT:"script",ABSOLUTE_URL:b}}());Object.assign(pc,function(){var f=[],b=function(a){this.asset=a},a=function(a){var c="_"+a;f.push(c);Object.defineProperty(b.prototype,a,{get:function(){return this[c]||null},set:function(a){if(!!this[c]!==!!a||this[c]&&a&&this[c].hash!==a.hash)this[c]=a?{url:a.url,filename:a.filename,size:a.size,hash:a.hash,opt:a.opt||0}:null,this.asset.file&&(this.asset.fire("change",this.asset,"file",this.asset._file,this.asset._file),this.asset.reload())}})};a("dxt");a("pvr");a("etc1");a("etc2");b.prototype.clear= function(){for(var a=0;athis.layers.indexOf(a)&& this.layers.push(a)};d.prototype.getLayerIdx=function(a){return this.layerToBatch[a.id]};d.prototype.addLayerIdx=function(a,b){this.layerToBatch[b.id]=a};var e=function(){this.numLinesAllocated=128;this.mesh=this.vbRam=this.vb=null;this.linesUsed=0;this.layer=this.meshInstance=this.material=null};Object.assign(e.prototype,{init:function(a,c,d,e){this.mesh||(this.mesh=new pc.Mesh,this.mesh.primitive[0].type=pc.PRIMITIVE_LINES,this.mesh.primitive[0].base=0,this.mesh.primitive[0].indexed=!1,this.material= new pc.BasicMaterial,this.material.vertexColors=!0,this.material.blend=!0,this.material.blendType=pc.BLEND_NORMAL,this.material.update());for(this.layer=d;this.linesUsed+e>this.numLinesAllocated;)this.vb&&(this.vb.destroy(),this.vb=null),this.numLinesAllocated*=2;this.vertexFormat=c;this.vb||(this.vb=new pc.VertexBuffer(a,c,2*this.numLinesAllocated,pc.BUFFER_DYNAMIC),this.mesh.vertexBuffer=this.vb,this.vbRam=new DataView(this.vb.lock()),this.meshInstance||(b.worldTransform=pc.Mat4.IDENTITY,b._dirtyWorld= b._dirtyNormal=!1,this.meshInstance=new pc.MeshInstance(b,this.mesh,this.material),this.meshInstance.cull=!1))},addLines:function(a,b){for(var c=!!b.length,d=2*this.linesUsed*this.vertexFormat.size,e,f=0;fd;d++)a.transformPoint(e[d],f[d]);this.renderLines([f[0],f[1],f[1],f[2],f[2],f[3],f[3],f[0],f[4],f[5],f[5],f[6],f[6],f[7],f[7],f[4],f[0],f[4],f[1],f[5],f[2],f[6],f[3],f[7]],b,c)},_addLines:function(a,b,c){void 0===c.layer&&(c.layer=this.scene.layers.getLayerById(pc.LAYERID_IMMEDIATE));void 0===c.depthTest&&(c.depthTest=!0);this._initImmediate();var d=c.layer; this._immediateData.addLayer(d);var f=this._immediateData.getLayerIdx(d);void 0===f?(f=new e,f.init(this.graphicsDevice,this._immediateData.lineVertexFormat,d,a.length/2),f.material.depthTest=c.depthTest,c.mask&&(f.meshInstance.mask=c.mask),f=this._immediateData.lineBatches.push(f)-1,this._immediateData.addLayerIdx(f,d)):(this._immediateData.lineBatches[f].init(this.graphicsDevice,this._immediateData.lineVertexFormat,d,a.length/2),this._immediateData.lineBatches[f].material.depthTest=c.depthTest, c.mask&&(this._immediateData.lineBatches[f].meshInstance.mask=c.mask));this._immediateData.lineBatches[f].addLines(a,b)},_initImmediate:function(){this._immediateData||(this._immediateData=new d(this.graphicsDevice),this.on("prerender",this._preRenderImmediate,this),this.on("postrender",this._postRenderImmediate,this))},_preRenderImmediate:function(){for(var a=0;am;m++)W.setValue(da),pc.drawQuadWithShader(t,S,J),W.setValue(ga),pc.drawQuadWithShader(t,fa,J);for(m=0;mthis._dirtyGroups.indexOf(a)&& this._dirtyGroups.push(a)};a.prototype.getGroupByName=function(a){var b=this._batchGroups,c;for(c in b)if(b.hasOwnProperty(c)&&b[c].name===a)return b[c];return null};a.prototype.getBatches=function(a){for(var b=[],c=this._batchList.length,f=0;ff.indexOf(d[c]._staticSource)||b[a.model.batchGroupId].push(d[c]));for(c=0;ca.indexOf(this._batchList[b].batchGroupId)?c.push(this._batchList[b]):this.destroy(this._batchList[b]);this._batchList= c;this._collectAndRemoveModels(this.rootNode,f,a);if(a===this._dirtyGroups)this._dirtyGroups.length=0;else{c=[];for(b=0;ba.indexOf(this._dirtyGroups[b])&&c.push(this._dirtyGroups[b]);this._dirtyGroups=c}}else{for(b=0;be||y.halfExtents.y>e||y.halfExtents.z>e){D.push(x[a]);continue}n= x[a].parameters;m=!1;for(q in h)if(h.hasOwnProperty(q)&&!f(h[q],n[q])){m=!0;break}if(!m)for(q in n)if(n.hasOwnProperty(q)&&!f(n[q],h[q])){m=!0;break}if(m){D.push(x[a]);continue}n=x[a]._staticLightList;if(r&&!n||!r&&n){D.push(x[a]);continue}if(r&&n){m=!1;for(z=0;zn.indexOf(r[z])){m=!0;break}for(z=0;zr.indexOf(n[z])){m=!0;break}if(m){D.push(x[a]);continue}}}v.add(x[a].aabb);p+=x[a].mesh.vertexBuffer.getNumVertices();u[w].push(x[a]);if(b&&u[w].length===c){D=a=== x.length?[]:x.slice(a+1);break}}w++;x=D}return u};a.prototype.create=function(a,d,f){this._init||(this.transformVS="#define BONE_LIMIT "+this.device.getBoneLimit()+"\n#define DYNAMICBATCH\n"+pc.shaderChunks.transformVS,this.skinTexVS=pc.shaderChunks.skinBatchTexVS,this.skinConstVS=pc.shaderChunks.skinBatchConstVS,this.vertexFormats={},this._init=!0);var c,e;f=new pc.Batch(a,d,f);this._batchList.push(f);var k=null,p,h,n,q,m,r,t,v,y,u=0,w=0;for(c=0;c