UNPKG

claygl

Version:
2 lines 422 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.clay={})}(this,function(t){"use strict";function e(){}function r(t,e){return t[e]}function n(t,e,r){t[e]=r}function i(t,e,r){return(e-t)*r+t}function a(t,e,r,n,a){var o=t.length;if(1==a)for(var s=0;s<o;s++)n[s]=i(t[s],e[s],r);else for(var u=t[0].length,s=0;s<o;s++)for(var l=0;l<u;l++)n[s][l]=i(t[s][l],e[s][l],r)}function o(t){return void 0!==t&&("string"!=typeof t&&"number"==typeof t.length)}function s(t){if(o(t)){var e=t.length;if(o(t[0])){for(var r=[],n=0;n<e;n++)r.push(ge.call(t[n]));return r}return ge.call(t)}return t}function u(t,e,r,n,i,a,o,s,u){var h=t.length;if(1==u)for(var c=0;c<h;c++)s[c]=l(t[c],e[c],r[c],n[c],i,a,o);else for(var f=t[0].length,c=0;c<h;c++)for(var d=0;d<f;d++)s[c][d]=l(t[c][d],e[c][d],r[c][d],n[c][d],i,a,o)}function l(t,e,r,n,i,a,o){var s=.5*(r-t),u=.5*(n-e);return(2*(e-r)+s+u)*o+(-3*(e-r)-2*s-u)*a+s*i+e}function h(t,e,r){var n=t.length,i=e.length;if(n!==i){if(n>i)t.length=i;else for(var a=n;a<i;a++)t.push(1===r?e[a]:ge.call(e[a]))}for(var o=t[0]&&t[0].length,a=0;a<t.length;a++)if(1===r)isNaN(t[a])&&(t[a]=e[a]);else for(var s=0;s<o;s++)isNaN(t[a][s])&&(t[a][s]=e[a][s])}function c(t,e,r){if(t===e)return!0;var n=t.length;if(n!==e.length)return!1;if(1===r){for(var i=0;i<n;i++)if(t[i]!==e[i])return!1}else for(var a=t[0].length,i=0;i<n;i++)for(var o=0;o<a;o++)if(t[i][o]!==e[i][o])return!1;return!0}function f(t,e,r,n,s,f,d){var p=t._getter,m=t._setter,_="spline"===e,g=n.length;if(g){var v=n[0].value,y=o(v),T=y&&o(v[0])?2:1;n.sort(function(t,e){return t.time-e.time});for(var x=[],E=[],A=[],b=n[0].value,S=!0,M=0;M<g;M++){x.push(n[M].time/d);var w=n[M].value;y&&c(w,b,T)||!y&&w===b||(S=!1),b=w,E.push(w),A.push(n[M].easing)}if(!S){for(var C=E[g-1],M=0;M<g-1;M++)y?h(E[M],C,T):isNaN(E[M])&&!isNaN(C)&&(E[M]=C);y&&h(p(t._target,s),C,T);var R,M,L,N,P,I,O,D=0,B=0,U=function(t,e){if(e<B){for(R=Math.min(D+1,g-1),M=R;M>=0&&!(x[M]<=e);M--);M=Math.min(M,g-2)}else{for(M=D;M<g&&!(x[M]>e);M++);M=Math.min(M-1,g-2)}D=M,B=e;var r=x[M+1]-x[M];0!==r&&(L=(e-x[M])/r,L=Math.max(Math.min(1,L),0),L=A[M+1](L),_?(P=E[M],N=E[0===M?M:M-1],I=E[M>g-2?g-1:M+1],O=E[M>g-3?g-1:M+2],f?m(t,s,f(p(t,s),N,P,I,O,L)):y?u(N,P,I,O,L,L*L,L*L*L,p(t,s),T):m(t,s,l(N,P,I,O,L,L*L,L*L*L))):f?m(t,s,f(p(t,s),E[M],E[M+1],L)):y?a(E[M],E[M+1],L,p(t,s),T):m(t,s,i(E[M],E[M+1],L)))},F=new _e({target:t._target,life:d,loop:t._loop,delay:t._delay,onframe:U,onfinish:r});return e&&"spline"!==e&&F.setEasing(e),F}}}function d(t,e,i,a,o){this._tracks={},this._target=t,this._loop=e||!1,this._getter=i||r,this._setter=a||n,this._interpolater=o||null,this._delay=0,this._doneList=[],this._onframeList=[],this._clipList=[],this._maxTime=0,this._lastKFTime=0}function p(t){return t}function m(t){var e,r,n,i,a,o,s=Number.POSITIVE_INFINITY,u=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY;for(e=t.length;e--;)t[e][0]<s&&(s=t[e][0]),t[e][0]>l&&(l=t[e][0]),t[e][1]<u&&(u=t[e][1]),t[e][1]>h&&(h=t[e][1]);return r=l-s,n=h-u,i=Math.max(r,n),a=s+.5*r,o=u+.5*n,[[a-20*i,o-i],[a,o+20*i],[a+20*i,o-i]]}function _(t,e,r,n){var i,a,o,s,u,l,h,c,f,d,p=t[e][0],m=t[e][1],_=t[r][0],g=t[r][1],v=t[n][0],y=t[n][1],T=Math.abs(m-g),x=Math.abs(g-y);if(T<Te&&x<Te)throw new Error("Eek! Coincident points!");return T<Te?(s=-(v-_)/(y-g),l=(_+v)/2,c=(g+y)/2,i=(_+p)/2,a=s*(i-l)+c):x<Te?(o=-(_-p)/(g-m),u=(p+_)/2,h=(m+g)/2,i=(v+_)/2,a=o*(i-u)+h):(o=-(_-p)/(g-m),s=-(v-_)/(y-g),u=(p+_)/2,l=(_+v)/2,h=(m+g)/2,c=(g+y)/2,i=(o*u-s*l+c-h)/(o-s),a=T>x?o*(i-u)+h:s*(i-l)+c),f=_-i,d=g-a,{i:e,j:r,k:n,x:i,y:a,r:f*f+d*d}}function g(t){var e,r,n,i,a,o;for(r=t.length;r;)for(i=t[--r],n=t[--r],e=r;e;)if(o=t[--e],a=t[--e],n===a&&i===o||n===o&&i===a){t.splice(r,2),t.splice(e,2);break}}function v(t,e,r,n,i,a){var o=e[i],s=e[i+1],u=e[i+2];return t[0]=o+n*(r[a]-o),t[1]=s+n*(r[a+1]-s),t[2]=u+n*(r[a+2]-u),t}function y(t,e,r,n,i,a){var o,s,u,l,h,c=e[0+i],f=e[1+i],d=e[2+i],p=e[3+i],m=r[0+a],_=r[1+a],g=r[2+a],v=r[3+a];return s=c*m+f*_+d*g+p*v,s<0&&(s=-s,m=-m,_=-_,g=-g,v=-v),1-s>1e-6?(o=Math.acos(s),u=Math.sin(o),l=Math.sin((1-n)*o)/u,h=Math.sin(n*o)/u):(l=1-n,h=n),t[0]=l*c+h*m,t[1]=l*f+h*_,t[2]=l*d+h*g,t[3]=l*p+h*v,t}function T(t,e,r){"object"==typeof e&&(r=e,e=null);var n,i=this;if(!(t instanceof Function)){n=[];for(var a in t)t.hasOwnProperty(a)&&n.push(a)}var o=function(e){if(i.apply(this,arguments),t instanceof Function?x(this,t.call(this,e)):E(this,t,n),this.constructor===o)for(var r=o.__initializers__,a=0;a<r.length;a++)r[a].apply(this,arguments)};o.__super__=i,i.__initializers__?o.__initializers__=i.__initializers__.slice():o.__initializers__=[],e&&o.__initializers__.push(e);var s=function(){};return s.prototype=i.prototype,o.prototype=new s,o.prototype.constructor=o,x(o.prototype,r),o.extend=i.extend,o.derive=i.extend,o}function x(t,e){if(e)for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])}function E(t,e,r){for(var n=0;n<r.length;n++){var i=r[n];t[i]=e[i]}}function A(t,e){this.action=t,this.context=e}function b(t){var e=new XMLHttpRequest;e.open("get",t.url),e.responseType=t.responseType||"text",t.onprogress&&(e.onprogress=function(e){if(e.lengthComputable){var r=e.loaded/e.total;t.onprogress(r,e.loaded,e.total)}else t.onprogress(null)}),e.onload=function(r){e.status>=400?t.onerror&&t.onerror():t.onload&&t.onload(e.response)},t.onerror&&(e.onerror=t.onerror),e.send(null)}function S(t){function e(e){if(t.getExtension){var n=t.getExtension(e);n||(n=t.getExtension("MOZ_"+e)),n||(n=t.getExtension("WEBKIT_"+e)),r[e]=n}}for(var r={},n={},i=0;i<je.length;i++){e(je[i])}for(var i=0;i<qe.length;i++){var a=qe[i];n[a]=t.getParameter(t[a])}this.getExtension=function(t){return t in r||e(t),r[t]},this.getParameter=function(t){return n[t]}}function M(t){return t=Math.round(t),t<0?0:t>255?255:t}function w(t){return t=Math.round(t),t<0?0:t>360?360:t}function C(t){return t<0?0:t>1?1:t}function R(t){return M(t.length&&"%"===t.charAt(t.length-1)?parseFloat(t)/100*255:parseInt(t,10))}function L(t){return C(t.length&&"%"===t.charAt(t.length-1)?parseFloat(t)/100:parseFloat(t))}function N(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}function P(t,e,r){return t+(e-t)*r}function I(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t}function O(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function D(t,e){tr&&O(tr,e),tr=$e.put(t,tr||e.slice())}function B(t,e){var r=(parseFloat(t[0])%360+360)%360/360,n=L(t[1]),i=L(t[2]),a=i<=.5?i*(n+1):i+n-i*n,o=2*i-a;return e=e||[],I(e,M(255*N(o,a,r+1/3)),M(255*N(o,a,r)),M(255*N(o,a,r-1/3)),1),4===t.length&&(e[3]=t[3]),e}function U(t){if(t){var e,r,n=t[0]/255,i=t[1]/255,a=t[2]/255,o=Math.min(n,i,a),s=Math.max(n,i,a),u=s-o,l=(s+o)/2;if(0===u)e=0,r=0;else{r=l<.5?u/(s+o):u/(2-s-o);var h=((s-n)/6+u/2)/u,c=((s-i)/6+u/2)/u,f=((s-a)/6+u/2)/u;n===s?e=f-c:i===s?e=1/3+h-f:a===s&&(e=2/3+c-h),e<0&&(e+=1),e>1&&(e-=1)}var d=[360*e,r,l];return null!=t[3]&&d.push(t[3]),d}}function F(t){var e=Object.keys(t);e.sort();for(var r=[],n=0;n<e.length;n++){var i=e[n],a=t[i];null===a?r.push(i):r.push(i+" "+a.toString())}return r.join("\n")}function k(t,e,r){r.sort();for(var n=[],i=0;i<r.length;i++){var a=r[i];n.push(a)}var o=F(t)+"\n"+F(e)+"\n"+n.join("\n");if(rr[o])return rr[o];var s=Fe.genGUID();return rr[o]=s,s}function H(t){for(var e=t.split("\n"),r=0,n=e.length;r<n;r++)e[r]=r+1+": "+e[r];return e.join("\n")}function G(t,e,r){if(!t.getShaderParameter(e,t.COMPILE_STATUS))return[t.getShaderInfoLog(e),H(r)].join("\n")}function V(t,e,r){function n(t,r,n,a){var o="";isNaN(r)&&(r=r in e?e[r]:i[r]),isNaN(n)&&(n=n in e?e[n]:i[n]);for(var s=parseInt(r);s<parseInt(n);s++)o+="{"+a.replace(/float\s*\(\s*_idx_\s*\)/g,s.toFixed(1)).replace(/_idx_/g,s)+"}";return o}var i={};for(var a in r)i[a+"_COUNT"]=r[a];return t.replace(sr,n)}function W(t,e,r){var n=[];if(e)for(var i in e){var a=e[i];a>0&&n.push("#define "+i.toUpperCase()+"_COUNT "+a)}if(r)for(var o=0;o<r.length;o++){var s=r[o];n.push("#define "+s.toUpperCase()+"_ENABLED")}for(var s in t){var u=t[s];null===u?n.push("#define "+s):n.push("#define "+s+" "+u.toString())}return n.join("\n")}function z(t){for(var e=[],r=0;r<t.length;r++)e.push("#extension GL_"+t[r]+" : enable");return e.join("\n")}function X(t){return["precision",t,"float"].join(" ")+";\n"+["precision",t,"int"].join(" ")+";\n"+["precision",t,"sampler2D"].join(" ")+";\n"}function j(t){this._renderer=t,this._cache={}}function q(t){for(var e=[],r=0;r<t;r++)e[r]=0;return e}function Y(t,e){var r="vertex:"+t+"fragment:"+e;if(gr[r])return gr[r];var n=Fe.genGUID();return gr[r]=n,vr[n]={vertex:t,fragment:e},n}function K(t){return t.replace(/[ \t]*\/\/.*\n/g,"").replace(/[ \t]*\/\*[\s\S]*?\*\//g,"")}function Z(){console.error("Wrong uniform/attributes syntax")}function J(t,e){function r(t){t||Z();var e=t.match(/\[(.*?)\]/);s=t.replace(/\[(.*?)\]/,""),l[s]={},e&&(l[s].isArray=!0,l[s].arraySize=e[1])}for(var n=/[,=\(\):]/,i=e.replace(/:\s*\[\s*(.*)\s*\]/g,"="+t+"($1)").replace(/\s+/g,"").split(/(?=[,=\(\):])/g),a=[],o=0;o<i.length;o++)i[o].match(n)?a.push(i[o].charAt(0),i[o].slice(1)):a.push(i[o]);i=a;var s,u=0,l={},h=null;r(i[0]);for(var o=1;o<i.length;o++){var c=i[o];if(c)if("="!==c)if(":"!==c)if(","!==c)if(")"!==c)if("("!==c)if(c.indexOf("vec")>=0){if(1!==u&&4!==u){Z();break}u=2,h=[]}else if(1!==u)if(4!==u)r(c),u=0;else{var f=c;dr.indexOf(f)>=0||pr.indexOf(f)>=0||mr.indexOf(f)>=0?l[s].semantic=f:"ignore"===f||"unconfigurable"===f?l[s].ignore=!0:l[s].value="bool"===t?"true"===f:parseFloat(f)}else l[s].value="bool"===t?"true"===c:parseFloat(c),h=null;else{if(2!==u){Z();break}if(!(h instanceof Array)){Z();break}h.push(+i[++o])}else l[s].value=new Ve.Float32Array(h),h=null,u=5;else if(2===u){if(!(h instanceof Array)){Z();break}h.push(+i[++o])}else u=5;else u=4;else{if(0!==u&&3!==u){Z();break}u=1}}return l}function Q(t,e){"object"==typeof t&&(e=t.fragment,t=t.vertex),t=K(t),e=K(e),this._shaderID=Y(t,e),this._vertexCode=Q.parseImport(t),this._fragmentCode=Q.parseImport(e),this.attributeSemantics={},this.matrixSemantics={},this.uniformSemantics={},this.matrixSemanticKeys=[],this.uniformTemplates={},this.attributes={},this.textures={},this.vertexDefines={},this.fragmentDefines={},this._parseAttributes(),this._parseUniforms(),this._parseDefines()}function $(t){return t.material}function tt(t,e,r){return e.uniforms[r].value}function et(t,e,r,n){return r!==n}function rt(t){return!0}function nt(){}function it(t,e,r){this.availableAttributes=t,this.availableAttributeSymbols=e,this.indicesBuffer=r,this.vao=null}function at(t){var e,r;this.bind=function(t){e||(e=Ve.createCanvas(),e.width=e.height=1,e.getContext("2d"));var n=t.gl,i=!r;i&&(r=n.createTexture()),n.bindTexture(n.TEXTURE_2D,r),i&&n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e)},this.unbind=function(t){t.gl.bindTexture(t.gl.TEXTURE_2D,null)},this.isRenderable=function(){return!0}}function ot(t,e,r){return t<e?e:t>r?r:t}function st(t){var e=[],r=Object.keys(t);r.sort();for(var n=0;n<r.length;n++){var i=r[n];e.push(i+" "+t[i])}var a=e.join("\n");if(on[a])return on[a];var o=Fe.genGUID();return on[a]=o,o}function ut(){this.opaque=[],this.transparent=[],this._opaqueCount=0,this._transparentCount=0}function lt(t,e){if(e.castShadow&&!t.castShadow)return!0}function ht(t){return{byte:Ve.Int8Array,ubyte:Ve.Uint8Array,short:Ve.Int16Array,ushort:Ve.Uint16Array}[t]||Ve.Float32Array}function ct(t){return"attr_"+t}function ft(t,e,r,n){switch(this.name=t,this.type=e,this.size=r,this.semantic=n||"",this.value=null,r){case 1:this.get=function(t){return this.value[t]},this.set=function(t,e){this.value[t]=e},this.copy=function(t,e){this.value[t]=this.value[t]};break;case 2:this.get=function(t,e){var r=this.value;return e[0]=r[2*t],e[1]=r[2*t+1],e},this.set=function(t,e){var r=this.value;r[2*t]=e[0],r[2*t+1]=e[1]},this.copy=function(t,e){var r=this.value;e*=2,t*=2,r[t]=r[e],r[t+1]=r[e+1]};break;case 3:this.get=function(t,e){var r=3*t,n=this.value;return e[0]=n[r],e[1]=n[r+1],e[2]=n[r+2],e},this.set=function(t,e){var r=3*t,n=this.value;n[r]=e[0],n[r+1]=e[1],n[r+2]=e[2]},this.copy=function(t,e){var r=this.value;e*=3,t*=3,r[t]=r[e],r[t+1]=r[e+1],r[t+2]=r[e+2]};break;case 4:this.get=function(t,e){var r=this.value,n=4*t;return e[0]=r[n],e[1]=r[n+1],e[2]=r[n+2],e[3]=r[n+3],e},this.set=function(t,e){var r=this.value,n=4*t;r[n]=e[0],r[n+1]=e[1],r[n+2]=e[2],r[n+3]=e[3]},this.copy=function(t,e){var r=this.value;e*=4,t*=4,r[t]=r[e],r[t+1]=r[e+1],r[t+2]=r[e+2],r[t+3]=r[e+3]}}}function dt(t,e,r,n,i){this.name=t,this.type=e,this.buffer=r,this.size=n,this.semantic=i,this.symbol="",this.needsRemove=!1}function pt(t){this.buffer=t,this.count=0}function mt(t,e,r){_n.identity();var n=new mn({widthSegments:e,heightSegments:r});switch(t){case"px":Ur.translate(_n,_n,Cr.POSITIVE_X),Ur.rotateY(_n,_n,Math.PI/2);break;case"nx":Ur.translate(_n,_n,Cr.NEGATIVE_X),Ur.rotateY(_n,_n,-Math.PI/2);break;case"py":Ur.translate(_n,_n,Cr.POSITIVE_Y),Ur.rotateX(_n,_n,-Math.PI/2);break;case"ny":Ur.translate(_n,_n,Cr.NEGATIVE_Y),Ur.rotateX(_n,_n,Math.PI/2);break;case"pz":Ur.translate(_n,_n,Cr.POSITIVE_Z);break;case"nz":Ur.translate(_n,_n,Cr.NEGATIVE_Z),Ur.rotateY(_n,_n,Math.PI)}return n.applyTransform(_n),n}function _t(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))}function gt(t,e){var r=_t(t.width),n=_t(t.height);return e=e||document.createElement("canvas"),e.width=r,e.height=n,e.getContext("2d").drawImage(t.image,0,0,r,n),e}function vt(t){return t.width>0&&t.height>0}function yt(){this._pool={}}function Tt(t,e,r){kn[t]={vertex:e,fragment:r}}function xt(t,e,r,n){var i=t.accessors[r],a=e.bufferViews[i.bufferView],o=i.byteOffset||0,s=Kn[i.componentType]||Ve.Float32Array,u=Zn[i.type];null==u&&n&&(u=1);var l=new s(a,o,u*i.count),h=i.extensions&&i.extensions.WEB3D_quantized_attributes;if(h){for(var c,f,d=new Ve.Float32Array(u*i.count),p=h.decodeMatrix,c=new Array(u),f=new Array(u),m=0;m<u;m++)c[m]=p[u*(u+1)+m],f[m]=p[m*(u+1)+m];for(var _=0;_<i.count;_++)for(var m=0;m<u;m++)d[_*u+m]=l[_*u+m]*f[m]+c[m];l=d}return l}function Et(t,e){for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=new Uint8Array(130),i=0;i<r.length;i++)n[r.charCodeAt(i)]=i;var a=t.length-e;"="===t.charAt(a-1)&&a--,"="===t.charAt(a-1)&&a--;for(var o=new Uint8Array(a/4*3),i=0,s=e;i<o.length;){var u=n[t.charCodeAt(s++)],l=n[t.charCodeAt(s++)],h=n[t.charCodeAt(s++)],c=n[t.charCodeAt(s++)];o[i++]=u<<2|l>>4,o[i++]=(15&l)<<4|h>>2,o[i++]=(3&h)<<6|c}return o.buffer}function At(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}function bt(t,e,r,n){if(t[3]>0){var i=Math.pow(2,t[3]-128-8+n);e[r+0]=t[0]*i,e[r+1]=t[1]*i,e[r+2]=t[2]*i}else e[r+0]=0,e[r+1]=0,e[r+2]=0;return e[r+3]=1,e}function St(t,e,r){for(var n="",i=e;i<r;i++)n+=vi(t[i]);return n}function Mt(t,e){e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]}function wt(t,e,r,n){for(var i=0,a=0,o=n;o>0;)if(t[a][0]=e[r++],t[a][1]=e[r++],t[a][2]=e[r++],t[a][3]=e[r++],1===t[a][0]&&1===t[a][1]&&1===t[a][2]){for(var s=t[a][3]<<i>>>0;s>0;s--)Mt(t[a-1],t[a]),a++,o--;i+=8}else a++,o--,i=0;return r}function Ct(t,e,r,n){if(n<yi|n>Ti)return wt(t,e,r,n);var i=e[r++];if(2!=i)return wt(t,e,r-1,n);if(t[0][1]=e[r++],t[0][2]=e[r++],i=e[r++],(t[0][2]<<8>>>0|i)>>>0!==n)return null;for(var i=0;i<4;i++)for(var a=0;a<n;){var o=e[r++];if(o>128){o=(127&o)>>>0;for(var s=e[r++];o--;)t[a++][i]=s}else for(;o--;)t[a++][i]=e[r++]}return r}function Rt(t){Fe.defaultsWithPropList(t,Ci,Ri),Lt(t);for(var e="",r=0;r<Ri.length;r++){e+=t[Ri[r]].toString()}return e}function Lt(t){var e=Nt(t.width,t.height);t.format===Ye.DEPTH_COMPONENT&&(t.useMipmap=!1),e&&t.useMipmap||(t.minFilter==Ye.NEAREST_MIPMAP_NEAREST||t.minFilter==Ye.NEAREST_MIPMAP_LINEAR?t.minFilter=Ye.NEAREST:t.minFilter!=Ye.LINEAR_MIPMAP_LINEAR&&t.minFilter!=Ye.LINEAR_MIPMAP_NEAREST||(t.minFilter=Ye.LINEAR)),e||(t.wrapS=Ye.CLAMP_TO_EDGE,t.wrapT=Ye.CLAMP_TO_EDGE)}function Nt(t,e){return 0==(t&t-1)&&0==(e&e-1)}function Pt(t,e,r){if("alphaMap"===r)return t.material.get("diffuseMap");if("alphaCutoff"===r){if(t.material.isDefined("fragment","ALPHA_TEST")&&t.material.get("diffuseMap")){return t.material.get("alphaCutoff")||0}return 0}return"uvRepeat"===r?t.material.get("uvRepeat"):"uvOffset"===r?t.material.get("uvOffset"):e.get(r)}function It(t,e){var r=t.material,n=e.material;return r.get("diffuseMap")!==n.get("diffuseMap")||(r.get("alphaCutoff")||0)!==(n.get("alphaCutoff")||0)}function Ot(t,e){var r=t[0],n=t[1],i=t[2];return 0===e?1:1===e?r:2===e?n:3===e?i:4===e?r*i:5===e?n*i:6===e?r*n:7===e?3*i*i-1:r*r-n*n}function Dt(t,e,r,n){for(var i=new Ve.Float32Array(27),a=Ce.create(),o=Ce.create(),s=Ce.create(),u=0;u<9;u++){for(var l=Ce.create(),h=0;h<Oi.length;h++){for(var c=e[Oi[h]],f=Ce.create(),d=0,p=0,m=Di[Oi[h]],_=0;_<n;_++)for(var g=0;g<r;g++){a[0]=g/(r-1)*2-1,a[1]=_/(n-1)*2-1,a[2]=-1,Ce.normalize(a,a),s[0]=a[m[0]]*m[3],s[1]=a[m[1]]*m[4],s[2]=a[m[2]]*m[5],o[0]=c[p++]/255,o[1]=c[p++]/255,o[2]=c[p++]/255;var v=c[p++]/255*8.12;o[0]*=v,o[1]*=v,o[2]*=v,Ce.scaleAndAdd(f,f,o,Ot(s,u)*-a[2]),d+=-a[2]}Ce.scaleAndAdd(l,l,f,1/d)}i[3*u]=l[0]/6,i[3*u+1]=l[1]/6,i[3*u+2]=l[2]/6}return i}function Bt(t,e){if(e=e||{},e.graphic=e.graphic||{},null==e.autoRender&&(e.autoRender=!0),"string"==typeof t&&(t=document.querySelector(t)),!t)throw new Error("Invalid dom");var r=!t.nodeName||"CANVAS"===t.nodeName.toUpperCase(),n={};r&&(n.canvas=t),e.devicePixelRatio&&(n.devicePixelRatio=e.devicePixelRatio);var i=new Mr(n),a=e.width||t.clientWidth,o=e.height||t.clientHeight,s=new sn,u=new ze,l=e.graphic.shadow&&new Ni,h=e.event&&new Pi({scene:s,renderer:i});!r&&t.appendChild(i.canvas),i.resize(a,o);var c=0,f=0;u.start();var d={};for(var p in e.methods)d[p]=e.methods[p].bind(e,this);Object.defineProperties(this,{container:{get:function(){return t}},renderer:{get:function(){return i}},scene:{get:function(){return s}},timeline:{get:function(){return u}},frameTime:{get:function(){return c}},elapsedTime:{get:function(){return f}},width:{get:function(){return i.getWidth()}},height:{get:function(){return i.getHeight()}},methods:{get:function(){return d}},_shadowPass:{get:function(){return l}},_appNS:{get:function(){return e}}}),this.resize=function(r,n){a=r||e.width||t.clientWidth,o=n||t.height||t.clientHeight,i.resize(a,o)},this.dispose=function(){this._disposed=!0,e.dispose&&e.dispose(this),u.stop(),i.disposeScene(s),l&&l.dispose(i),t.innerHTML="",Ui.forEach(function(e){this[kt(e)]&&Ve.removeEventListener(t,kt(e))},this)},h&&this._initMouseEvents(h),this._geoCache=new Ze(20),this._texCache=new Ze(20),this._texturesList={},this._geometriesList={};var m=Promise.resolve(e.init&&e.init(this));h&&(h.camera=s.getMainCamera()),e.loop||console.warn("Miss loop method.");var _=this;m.then(function(){u.on("frame",function(t){c=t,f+=t;var r=s.getMainCamera();r&&(r.aspect=i.getViewportAspect()),h&&(h.camera=r),e.loop&&e.loop(_),e.autoRender&&_.render(),_.collectResources()},this)}),s.on("beforerender",function(t,r,n,i){this._inRender&&(this._updateGraphicOptions(e.graphic,i.opaque,!1),this._updateGraphicOptions(e.graphic,i.transparent,!1))},this)}function Ut(t){return"undefined"!=typeof Image&&t instanceof Image||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement}function Ft(t){return"string"==typeof t?t:t.__key__||(t.__key__=Fe.genGUID())}function kt(t){return"_"+t+"Handler"}function Ht(t,e,r,n,i){var a=Fe.clone(e);return a.type=t,a.offsetX=r,a.offsetY=n,null!==i&&(a.wheelDelta=i),a}function Gt(t,e){for(;t&&!e.cancelBubble;)t.trigger(e.type,e),t=t.getParent()}function Vt(t){for(var e=0;e<t.length;e++)t[e].__used=0}function Wt(t,e){for(var r=0;r<e.length;r++)e[r].__used||e[r].dispose(t)}function zt(t,e){t.__used=t.__used||0,1===++t.__used&&e.push(t)}function Xt(t,e,r){var n,i;t.traverse(function(t){if(t.isRenderable()){var a=t.geometry,o=t.material;if(o!==n)for(var s=o.getTextureUniforms(),u=0;u<s.length;u++){var l=s[u],h=o.uniforms[l].value,c=o.uniforms[l].type;if(h)if("t"===c)zt(h,e);else if("tv"===c)for(var f=0;f<h.length;f++)h[f]&&zt(h[f],e)}a!==i&&zt(a,r),n=o,i=a}});for(var a=0;a<t.lights.length;a++)t.lights[a].cubemap&&zt(t.lights[a].cubemap,e)}function jt(){this._fullfilled=!1,this._rejected=!1}function qt(t,e){var r=new jt;return Ve.request.get({url:t,responseType:e,onload:function(t){r.resolve(t)},onerror:function(t){r.reject(t)}}),r}function Yt(t){t.import(qi),t.import(Yi),t.import(Ki),t.import(Zi),t.import(Ji),t.import(Qi),t.import($i),t.import(ta),t.import(ea),t.import(ra),t.import(na),t.import(ia),t.import(aa)}function Kt(t,e){var r=new Wi;e=e||{};var n={textures:{},parameters:{}},i=function(i,a){for(var o=0;o<t.nodes.length;o++){var s=t.nodes[o],u=Zt(s,n,e);u&&r.addNode(u)}};for(var a in t.parameters){var o=t.parameters[a];n.parameters[a]=$t(o)}return te(t,n,e,function(t){n.textures=t,i()}),r}function Zt(t,e,r){var n,i,a,o=t.type||"filter";if("filter"===o){var s=t.shader.trim(),u=oa.exec(s);if(u?n=Q.source(u[1].trim()):"#"===s.charAt(0)&&(n=e.shaders[s.substr(1)]),n||(n=s),!n)return}if(t.inputs){i={};for(var l in t.inputs)"string"==typeof t.inputs[l]?i[l]=t.inputs[l]:i[l]={node:t.inputs[l].node,pin:t.inputs[l].pin}}if(t.outputs){a={};for(var l in t.outputs){var h=t.outputs[l];a[l]={},null!=h.attachment&&(a[l].attachment=h.attachment),null!=h.keepLastFrame&&(a[l].keepLastFrame=h.keepLastFrame),null!=h.outputLastFrame&&(a[l].outputLastFrame=h.outputLastFrame),h.parameters&&(a[l].parameters=$t(h.parameters))}}var c;if(c="scene"===o?new zi({name:t.name,scene:r.scene,camera:r.camera,outputs:a}):"texture"===o?new Xi({name:t.name,outputs:a}):new ji({name:t.name,shader:n,inputs:i,outputs:a})){if(t.parameters)for(var l in t.parameters){var f=t.parameters[l];"string"==typeof f?(f=f.trim(),"#"===f.charAt(0)?f=e.textures[f.substr(1)]:c.on("beforerender",ee(l,ne(f)))):"function"==typeof f&&c.on("beforerender",f),c.setParameter(l,f)}if(t.defines&&c.pass)for(var l in t.defines){var f=t.defines[l];c.pass.material.define("fragment",l,f)}}return c}function Jt(t,e){return t}function Qt(t,e){return e}function $t(t){var e={};if(!t)return e;["type","minFilter","magFilter","wrapS","wrapT","flipY","useMipmap"].forEach(function(r){var n=t[r];null!=n&&("string"==typeof n&&(n=Tn[n]),e[r]=n)});var r=t.scale||1;return["width","height"].forEach(function(n){if(null!=t[n]){var i=t[n];"string"==typeof i?(i=i.trim(),e[n]=re(n,ne(i),r)):e[n]=i}}),e.width||(e.width=Jt),e.height||(e.height=Qt),null!=t.useMipmap&&(e.useMipmap=t.useMipmap),e}function te(t,e,r,n){if(!t.textures)return void n({});var i={},a=0,o=!1,s=r.textureRootPath;Fe.each(t.textures,function(t,e){var r,u=t.path,l=$t(t.parameters);if(Array.isArray(u)&&6===u.length)s&&(u=u.map(function(t){return Fe.relative2absolute(t,s)})),r=new Mn(l);else{if("string"!=typeof u)return;s&&(u=Fe.relative2absolute(u,s)),r=new An(l)}r.load(u),a++,r.once("success",function(){i[e]=r,0===--a&&(n(i),o=!0)})}),0!==a||o||n(i)}function ee(t,e){return function(r){var n=r.getDevicePixelRatio(),i=r.getWidth(),a=r.getHeight(),o=e(i,a,n);this.setParameter(t,o)}}function re(t,e,r){return r=r||1,function(t){var n=t.getDevicePixelRatio(),i=t.getWidth()*r,a=t.getHeight()*r;return e(i,a,n)}}function ne(t){var e=/^expr\((.*)\)$/.exec(t);if(e)try{var r=new Function("width","height","dpr","return "+e[1]);return r(1,1),r}catch(t){throw new Error("Invalid expression.")}}function ie(t){var e=document.createElement("canvas");e.width=e.height=1;var r=e.getContext("2d");return r.fillStyle=t||"#000",r.fillRect(0,0,1,1),e}function ae(t,e,r){return function(e,n,i){var a=e.material;if("doubleSided"===i)return a.isDefined("fragment","DOUBLE_SIDED");if("uvRepeat"===i||"uvOffset"===i||"alpha"===i)return a.get(i);if("normalMap"===i)return a.get(i)||t;if("diffuseMap"===i)return a.get(i)||r;if("alphaCutoff"===i){if(a.isDefined("fragment","ALPHA_TEST")){return a.get("alphaCutoff")||0}return 0}var o=a.isDefined("fragment","USE_ROUGHNESS"),s=o?a.get("roughnessMap"):a.get("glossinessMap");switch(i){case"glossiness":return o?1-a.get("roughness"):a.get("glossiness");case"roughGlossMap":return s;case"useRoughGlossMap":return!!s;case"useRoughness":return o;case"roughGlossChannel":return o?a.getDefine("fragment","ROUGHNESS_CHANNEL"):a.getDefine("fragment","GLOSSINESS_CHANNEL")}}}function oe(t,e){return function(r,n,i){var a=r.material;switch(i){case"color":case"uvRepeat":case"uvOffset":case"alpha":return a.get(i);case"metalness":return a.get("metalness")||0;case"diffuseMap":return a.get(i)||t;case"metalnessMap":return a.get(i)||e;case"useMetalnessMap":return!!a.get("metalnessMap");case"linear":return a.isDefined("SRGB_DECODE");case"alphaCutoff":if(a.isDefined("fragment","ALPHA_TEST")){return a.get("alphaCutoff")||0}return 0}}}function se(t){var e=t>>16,r=t-(e<<8)>>8;return[e,r,t-(e<<16)-(r<<8)]}function ue(t,e,r){return(t<<16)+(e<<8)+r}function le(t){var e=t[1][0]-t[0][0],r=t[1][1]-t[0][1];return Math.sqrt(e*e+r*r)}function he(t){return[(t[0][0]+t[1][0])/2,(t[0][1]+t[1][1])/2]}function ce(t){return Array.isArray(t)||(t=[t,t]),t}function fe(t,e){return{name:t.name,type:t.type,size:t.size,semantic:t.semantic,value:de(t.value,e)}}function de(t,e){return e?t:new t.constructor(t)}function pe(t,e,r){return t*(1-r)+e*r}var me={linear:function(t){return t},quadraticIn:function(t){return t*t},quadraticOut:function(t){return t*(2-t)},quadraticInOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},cubicIn:function(t){return t*t*t},cubicOut:function(t){return--t*t*t+1},cubicInOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},quarticIn:function(t){return t*t*t*t},quarticOut:function(t){return 1- --t*t*t*t},quarticInOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},quinticIn:function(t){return t*t*t*t*t},quinticOut:function(t){return--t*t*t*t*t+1},quinticInOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},sinusoidalIn:function(t){return 1-Math.cos(t*Math.PI/2)},sinusoidalOut:function(t){return Math.sin(t*Math.PI/2)},sinusoidalInOut:function(t){return.5*(1-Math.cos(Math.PI*t))},exponentialIn:function(t){return 0===t?0:Math.pow(1024,t-1)},exponentialOut:function(t){return 1===t?1:1-Math.pow(2,-10*t)},exponentialInOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))},circularIn:function(t){return 1-Math.sqrt(1-t*t)},circularOut:function(t){return Math.sqrt(1- --t*t)},circularInOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},elasticIn:function(t){var e,r=.1;return 0===t?0:1===t?1:(!r||r<1?(r=1,e=.1):e=.4*Math.asin(1/r)/(2*Math.PI),-r*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4))},elasticOut:function(t){var e,r=.1;return 0===t?0:1===t?1:(!r||r<1?(r=1,e=.1):e=.4*Math.asin(1/r)/(2*Math.PI),r*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/.4)+1)},elasticInOut:function(t){var e,r=.1;return 0===t?0:1===t?1:(!r||r<1?(r=1,e=.1):e=.4*Math.asin(1/r)/(2*Math.PI),(t*=2)<1?r*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4)*-.5:r*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4)*.5+1)},backIn:function(t){var e=1.70158;return t*t*((e+1)*t-e)},backOut:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},backInOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)},bounceIn:function(t){return 1-me.bounceOut(1-t)},bounceOut:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},bounceInOut:function(t){return t<.5?.5*me.bounceIn(2*t):.5*me.bounceOut(2*t-1)+.5}},_e=function(t){t=t||{},this.name=t.name||"",this.target=t.target,this.life=t.life||1e3,this.delay=t.delay||0,this.gap=t.gap||0,this.playbackRate=t.playbackRate||1,this._initialized=!1,this._elapsedTime=0,this._loop=null!=t.loop&&t.loop,this.setLoop(this._loop),null!=t.easing&&this.setEasing(t.easing),this.onframe=t.onframe||e,this.onfinish=t.onfinish||e,this.onrestart=t.onrestart||e,this._paused=!1};_e.prototype={gap:0,life:0,delay:0,setLoop:function(t){this._loop=t,t&&(this._loopRemained="number"==typeof t?t:1/0)},setEasing:function(t){"string"==typeof t&&(t=me[t]),this.easing=t},step:function(t,e,r){if(this._initialized||(this._startTime=t+this.delay,this._initialized=!0),null!=this._currentTime&&(e=t-this._currentTime),this._currentTime=t,this._paused)return"paused";if(!(t<this._startTime)){this._elapse(t,e);var n=Math.min(this._elapsedTime/this.life,1);if(!(n<0)){var i;return i=this.easing?this.easing(n):n,r||this.fire("frame",i),1===n?this._loop&&this._loopRemained>0?(this._restartInLoop(t),this._loopRemained--,"restart"):(this._needsRemove=!0,"finish"):null}}},setTime:function(t){return this.step(t+this._startTime)},restart:function(t){var e=0;t&&(this._elapse(t),e=this._elapsedTime%this.life),t=t||Date.now(),this._startTime=t-e+this.delay,this._elapsedTime=0,this._needsRemove=!1,this._paused=!1},getElapsedTime:function(){return this._elapsedTime},_restartInLoop:function(t){this._startTime=t+this.gap,this._elapsedTime=0},_elapse:function(t,e){this._elapsedTime+=e*this.playbackRate},fire:function(t,e){var r="on"+t;this[r]&&this[r](this.target,e)},clone:function(){var t=new this.constructor;return t.name=this.name,t._loop=this._loop,t._loopRemained=this._loopRemained,t.life=this.life,t.gap=this.gap,t.delay=this.delay,t},pause:function(){this._paused=!0},resume:function(){this._paused=!1}},_e.prototype.constructor=_e;var ge=Array.prototype.slice;d.prototype={constructor:d,when:function(t,e,r){this._maxTime=Math.max(t,this._maxTime),r=("function"==typeof r?r:me[r])||p;for(var n in e)this._tracks[n]||(this._tracks[n]=[],0!==t&&this._tracks[n].push({time:0,value:s(this._getter(this._target,n)),easing:r})),this._tracks[n].push({time:parseInt(t),value:e[n],easing:r});return this},then:function(t,e,r){return this.when(t+this._lastKFTime,e,r),this._lastKFTime+=t,this},during:function(t){return this._onframeList.push(t),this},_doneCallback:function(){this._tracks={},this._clipList.length=0;for(var t=this._doneList,e=t.length,r=0;r<e;r++)t[r].call(this)},start:function(t){var e,r=this,n=0,i=function(){0===--n&&r._doneCallback()};for(var a in this._tracks){var o=f(this,t,i,this._tracks[a],a,r._interpolater,r._maxTime);o&&(this._clipList.push(o),n++,this.animation&&this.animation.addClip(o),e=o)}if(e){var s=e.onframe;e.onframe=function(t,e){s(t,e);for(var n=0;n<r._onframeList.length;n++)r._onframeList[n](t,e)}}return n||this._doneCallback(),this},stop:function(){for(var t=0;t<this._clipList.length;t++){var e=this._clipList[t];this.animation.removeClip(e)}this._clipList=[]},delay:function(t){return this._delay=t,this},done:function(t){return t&&this._doneList.push(t),this},getClips:function(){return this._clipList}};var ve=function(t,e){return t.position<e.position},ye=function(t){t=t||{},_e.call(this,t),this.output=t.output||null,this.inputs=t.inputs||[],this.position=0,this._cacheKey=0,this._cachePosition=-1/0,this.inputs.sort(ve)};ye.prototype=new _e,ye.prototype.constructor=ye,ye.prototype.addInput=function(t,e,r){var n={position:t,clip:e,offset:r||0};if(this.life=Math.max(e.life,this.life),!this.inputs.length)return this.inputs.push(n),n;var i=this.inputs.length;if(this.inputs[0].position>t)this.inputs.unshift(n);else if(this.inputs[i-1].position<=t)this.inputs.push(n);else{var a=this._findKey(t);this.inputs.splice(a,n)}return n},ye.prototype.step=function(t,e,r){var n=_e.prototype.step.call(this,t);return"finish"!==n&&this.setTime(this.getElapsedTime()),r||"paused"===n||this.fire("frame"),n},ye.prototype.setTime=function(t){var e=this.position,r=this.inputs,n=r.length,i=r[0].position,a=r[n-1].position;if(e<=i||e>=a){var o=e<=i?r[0]:r[n-1],s=o.clip,u=o.offset;s.setTime((t+u)%s.life),s.output instanceof _e?this.output.copy(s.output):this.output.copy(s)}else{var l=this._findKey(e),h=r[l],c=r[l+1],f=h.clip,d=c.clip;f.setTime((t+h.offset)%f.life),d.setTime((t+c.offset)%d.life) ;var p=(this.position-h.position)/(c.position-h.position),m=f.output instanceof _e?f.output:f,_=d.output instanceof _e?d.output:d;this.output.blend1D(m,_,p)}},ye.prototype.clone=function(t){var e=_e.prototype.clone.call(this);e.output=this.output.clone();for(var r=0;r<this.inputs.length;r++){var n=t?this.inputs[r].clip.clone(!0):this.inputs[r].clip;e.addInput(this.inputs[r].position,n,this.inputs[r].offset)}return e},ye.prototype._findKey=function(t){var e=-1,r=this.inputs,n=r.length;if(this._cachePosition<t)for(var i=this._cacheKey;i<n-1;i++)t>=r[i].position&&t<r[i+1].position&&(e=i);else for(var a=Math.min(n-2,this._cacheKey),i=a;i>=0;i--)t>=r[i].position&&t<r[i+1].position&&(e=i);return e>=0&&(this._cacheKey=e,this._cachePosition=t),e};var Te=1/1048576,xe={triangulate:function(t,e){var r,n,i,a,o,s,u,l,h,c,f,d,p=t.length;if(p<3)return[];if(t=t.slice(0),e)for(r=p;r--;)t[r]=t[r][e];for(i=new Array(p),r=p;r--;)i[r]=r;for(i.sort(function(e,r){var n=t[r][0]-t[e][0];return 0!==n?n:e-r}),a=m(t),t.push(a[0],a[1],a[2]),o=[_(t,p+0,p+1,p+2)],s=[],u=[],r=i.length;r--;u.length=0){for(d=i[r],n=o.length;n--;)l=t[d][0]-o[n].x,l>0&&l*l>o[n].r?(s.push(o[n]),o.splice(n,1)):(h=t[d][1]-o[n].y,l*l+h*h-o[n].r>Te||(u.push(o[n].i,o[n].j,o[n].j,o[n].k,o[n].k,o[n].i),o.splice(n,1)));for(g(u),n=u.length;n;)f=u[--n],c=u[--n],o.push(_(t,c,f,d))}for(r=o.length;r--;)s.push(o[r]);for(o.length=0,r=s.length;r--;)s[r].i<p&&s[r].j<p&&s[r].k<p&&o.push(s[r].i,s[r].j,s[r].k);return o},contains:function(t,e){if(e[0]<t[0][0]&&e[0]<t[1][0]&&e[0]<t[2][0]||e[0]>t[0][0]&&e[0]>t[1][0]&&e[0]>t[2][0]||e[1]<t[0][1]&&e[1]<t[1][1]&&e[1]<t[2][1]||e[1]>t[0][1]&&e[1]>t[1][1]&&e[1]>t[2][1])return null;var r=t[1][0]-t[0][0],n=t[2][0]-t[0][0],i=t[1][1]-t[0][1],a=t[2][1]-t[0][1],o=r*a-n*i;if(0===o)return null;var s=(a*(e[0]-t[0][0])-n*(e[1]-t[0][1]))/o,u=(r*(e[1]-t[0][1])-i*(e[0]-t[0][0]))/o;return s<0||u<0||s+u>1?null:[s,u]}},Ee=Array,Ae=Math.random,be={};be.create=function(){var t=new Ee(2);return t[0]=0,t[1]=0,t},be.clone=function(t){var e=new Ee(2);return e[0]=t[0],e[1]=t[1],e},be.fromValues=function(t,e){var r=new Ee(2);return r[0]=t,r[1]=e,r},be.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},be.set=function(t,e,r){return t[0]=e,t[1]=r,t},be.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t},be.subtract=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t},be.sub=be.subtract,be.multiply=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t},be.mul=be.multiply,be.divide=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t},be.div=be.divide,be.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t},be.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t},be.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},be.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t},be.distance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1];return Math.sqrt(r*r+n*n)},be.dist=be.distance,be.squaredDistance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1];return r*r+n*n},be.sqrDist=be.squaredDistance,be.length=function(t){var e=t[0],r=t[1];return Math.sqrt(e*e+r*r)},be.len=be.length,be.squaredLength=function(t){var e=t[0],r=t[1];return e*e+r*r},be.sqrLen=be.squaredLength,be.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},be.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},be.normalize=function(t,e){var r=e[0],n=e[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i),t},be.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},be.cross=function(t,e,r){var n=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=n,t},be.lerp=function(t,e,r,n){var i=e[0],a=e[1];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t},be.random=function(t,e){e=e||1;var r=2*GLMAT_RANDOM()*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t},be.transformMat2=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i,t[1]=r[1]*n+r[3]*i,t},be.transformMat2d=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i+r[4],t[1]=r[1]*n+r[3]*i+r[5],t},be.transformMat3=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[3]*i+r[6],t[1]=r[1]*n+r[4]*i+r[7],t},be.transformMat4=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t},be.forEach=function(){var t=be.create();return function(e,r,n,i,a,o){var s,u;for(r||(r=2),n||(n=0),u=i?Math.min(i*r+n,e.length):e.length,s=n;s<u;s+=r)t[0]=e[s],t[1]=e[s+1],a(t,t,o),e[s]=t[0],e[s+1]=t[1];return e}}();var Se=function(t,e){t=t||0,e=e||0,this.array=be.fromValues(t,e),this._dirty=!0};if(Se.prototype={constructor:Se,add:function(t){return be.add(this.array,this.array,t.array),this._dirty=!0,this},set:function(t,e){return this.array[0]=t,this.array[1]=e,this._dirty=!0,this},setArray:function(t){return this.array[0]=t[0],this.array[1]=t[1],this._dirty=!0,this},clone:function(){return new Se(this.x,this.y)},copy:function(t){return be.copy(this.array,t.array),this._dirty=!0,this},cross:function(t,e){return be.cross(t.array,this.array,e.array),t._dirty=!0,this},dist:function(t){return be.dist(this.array,t.array)},distance:function(t){return be.distance(this.array,t.array)},div:function(t){return be.div(this.array,this.array,t.array),this._dirty=!0,this},divide:function(t){return be.divide(this.array,this.array,t.array),this._dirty=!0,this},dot:function(t){return be.dot(this.array,t.array)},len:function(){return be.len(this.array)},length:function(){return be.length(this.array)},lerp:function(t,e,r){return be.lerp(this.array,t.array,e.array,r),this._dirty=!0,this},min:function(t){return be.min(this.array,this.array,t.array),this._dirty=!0,this},max:function(t){return be.max(this.array,this.array,t.array),this._dirty=!0,this},mul:function(t){return be.mul(this.array,this.array,t.array),this._dirty=!0,this},multiply:function(t){return be.multiply(this.array,this.array,t.array),this._dirty=!0,this},negate:function(){return be.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return be.normalize(this.array,this.array),this._dirty=!0,this},random:function(t){return be.random(this.array,t),this._dirty=!0,this},scale:function(t){return be.scale(this.array,this.array,t),this._dirty=!0,this},scaleAndAdd:function(t,e){return be.scaleAndAdd(this.array,this.array,t.array,e),this._dirty=!0,this},sqrDist:function(t){return be.sqrDist(this.array,t.array)},squaredDistance:function(t){return be.squaredDistance(this.array,t.array)},sqrLen:function(){return be.sqrLen(this.array)},squaredLength:function(){return be.squaredLength(this.array)},sub:function(t){return be.sub(this.array,this.array,t.array),this._dirty=!0,this},subtract:function(t){return be.subtract(this.array,this.array,t.array),this._dirty=!0,this},transformMat2:function(t){return be.transformMat2(this.array,this.array,t.array),this._dirty=!0,this},transformMat2d:function(t){return be.transformMat2d(this.array,this.array,t.array),this._dirty=!0,this},transformMat3:function(t){return be.transformMat3(this.array,this.array,t.array),this._dirty=!0,this},transformMat4:function(t){return be.transformMat4(this.array,this.array,t.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},Object.defineProperty){var Me=Se.prototype;Object.defineProperty(Me,"x",{get:function(){return this.array[0]},set:function(t){this.array[0]=t,this._dirty=!0}}),Object.defineProperty(Me,"y",{get:function(){return this.array[1]},set:function(t){this.array[1]=t,this._dirty=!0}})}Se.add=function(t,e,r){return be.add(t.array,e.array,r.array),t._dirty=!0,t},Se.set=function(t,e,r){return be.set(t.array,e,r),t._dirty=!0,t},Se.copy=function(t,e){return be.copy(t.array,e.array),t._dirty=!0,t},Se.cross=function(t,e,r){return be.cross(t.array,e.array,r.array),t._dirty=!0,t},Se.dist=function(t,e){return be.distance(t.array,e.array)},Se.distance=Se.dist,Se.div=function(t,e,r){return be.divide(t.array,e.array,r.array),t._dirty=!0,t},Se.divide=Se.div,Se.dot=function(t,e){return be.dot(t.array,e.array)},Se.len=function(t){return be.length(t.array)},Se.lerp=function(t,e,r,n){return be.lerp(t.array,e.array,r.array,n),t._dirty=!0,t},Se.min=function(t,e,r){return be.min(t.array,e.array,r.array),t._dirty=!0,t},Se.max=function(t,e,r){return be.max(t.array,e.array,r.array),t._dirty=!0,t},Se.mul=function(t,e,r){return be.multiply(t.array,e.array,r.array),t._dirty=!0,t},Se.multiply=Se.mul,Se.negate=function(t,e){return be.negate(t.array,e.array),t._dirty=!0,t},Se.normalize=function(t,e){return be.normalize(t.array,e.array),t._dirty=!0,t},Se.random=function(t,e){return be.random(t.array,e),t._dirty=!0,t},Se.scale=function(t,e,r){return be.scale(t.array,e.array,r),t._dirty=!0,t},Se.scaleAndAdd=function(t,e,r,n){return be.scaleAndAdd(t.array,e.array,r.array,n),t._dirty=!0,t},Se.sqrDist=function(t,e){return be.sqrDist(t.array,e.array)},Se.squaredDistance=Se.sqrDist,Se.sqrLen=function(t){return be.sqrLen(t.array)},Se.squaredLength=Se.sqrLen,Se.sub=function(t,e,r){return be.subtract(t.array,e.array,r.array),t._dirty=!0,t},Se.subtract=Se.sub,Se.transformMat2=function(t,e,r){return be.transformMat2(t.array,e.array,r.array),t._dirty=!0,t},Se.transformMat2d=function(t,e,r){return be.transformMat2d(t.array,e.array,r.array),t._dirty=!0,t},Se.transformMat3=function(t,e,r){return be.transformMat3(t.array,e.array,r.array),t._dirty=!0,t},Se.transformMat4=function(t,e,r){return be.transformMat4(t.array,e.array,r.array),t._dirty=!0,t};var we=function(t){t=t||{},_e.call(this,t),this.output=t.output||null,this.inputs=t.inputs||[],this.position=new Se,this._cacheTriangle=null,this._triangles=[],this._updateTriangles()};we.prototype=new _e,we.prototype.constructor=we,we.prototype.addInput=function(t,e,r){var n={position:t,clip:e,offset:r||0};return this.inputs.push(n),this.life=Math.max(e.life,this.life),this._updateTriangles(),n},we.prototype._updateTriangles=function(){var t=this.inputs.map(function(t){return t.position});this._triangles=xe.triangulate(t,"array")},we.prototype.step=function(t,e,r){var n=_e.prototype.step.call(this,t);return"finish"!==n&&this.setTime(this.getElapsedTime()),r||"paused"===n||this.fire("frame"),n},we.prototype.setTime=function(t){var e=this._findTriangle(this.position);if(e){var r=e[1],n=e[2],i=e[0],a=this.inputs[i.indices[0]],o=this.inputs[i.indices[1]],s=this.inputs[i.indices[2]],u=a.clip,l=o.clip,h=s.clip;u.setTime((t+a.offset)%u.life),l.setTime((t+o.offset)%l.life),h.setTime((t+s.offset)%h.life);var c=u.output instanceof _e?u.output:u,f=l.output instanceof _e?l.output:l,d=h.output instanceof _e?h.output:h;this.output.blend2D(c,f,d,r,n)}},we.prototype.clone=function(t){var e=_e.prototype.clone.call(this);e.output=this.output.clone();for(var r=0;r<this.inputs.length;r++){var n=t?this.inputs[r].clip.clone(!0):this.inputs[r].clip;e.addInput(this.inputs[r].position,n,this.inputs[r].offset)}return e},we.prototype._findTriangle=function(t){if(this._cacheTriangle){var e=xe.contains(this._cacheTriangle.vertices,t.array);if(e)return[this._cacheTriangle,e[0],e[1]]}for(var r=0;r<this._triangles.length;r++){var n=this._triangles[r],e=xe.contains(n.vertices,this.position.array);if(e)return this._cacheTriangle=n,[n,e[0],e[1]]}};var Ce={};Ce.create=function(){var t=new Ee(3);return t[0]=0,t[1]=0,t[2]=0,t},Ce.clone=function(t){var e=new Ee(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},Ce.fromValues=function(t,e,r){var n=new Ee(3);return n[0]=t,n[1]=e,n[2]=r,n},Ce.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},Ce.set=function(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t},Ce.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t},Ce.subtract=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t},Ce.sub=Ce.subtract,Ce.multiply=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t},Ce.mul=Ce.multiply,Ce.divide=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t},Ce.div=Ce.divide,Ce.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t},Ce.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t},Ce.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},Ce.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t},Ce.distance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(r*r+n*n+i*i)},Ce.dist=Ce.distance,Ce.squaredDistance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i},Ce.sqrDist=Ce.squaredDistance,Ce.length=function(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)},Ce.len=Ce.length,Ce.squaredLength=function(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n},Ce.sqrLen=Ce.squaredLength,Ce.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t},Ce.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t},Ce.normalize=function(t,e){var r=e[0],n=e[1],i=e[2],a=r*r+n*n+i*i;return a>0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a),t},Ce.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},Ce.cross=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],u=r[2];return t[0]=i*u-a*s,t[1]=a*o-n*u,t[2]=n*s-i*o,t},Ce.lerp=function(t,e,r,n){var i=e[0],a=e[1],o=e[2];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=o+n*(r[2]-o),t},Ce.random=function(t,e){e=e||1;var r=2*Ae()*Math.PI,n=2*Ae()-1,i=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*i,t[1]=Math.sin(r)*i,t[2]=n*e,t},Ce.transformMat4=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[3]*n+r[7]*i+r[11]*a+r[15];return o=o||1,t[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/o,t[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/o,t[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/o,t},Ce.transformMat3=function(t,e,r){var n=e[0],i=e[1],a=e[2];return t[0]=n*r[0]+i*r[3]+a*r[6],t[1]=n*r[1]+i*r[4]+a*r[7],t[2]=n*r[2]+i*r[5]+a*r[8],t},Ce.transformQuat=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],u=r[2],l=r[3],h=l*n+s*a-u*i,c=l*i+u*n-o*a,f=l*a+o*i-s*n,d=-o*n-s*i-u*a;return t[0]=h*l+d*-o+c*-u-f*-s,t[1]=c*l+d*-s+f*-o-h*-u,t[2]=f*l+d*-u+h*-s-c*-o,t},Ce.rotateX=function(t,e,r,n){var i=[],a=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],a[0]=i[0],a[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),a[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},Ce.rotateY=function(t,e,r,n){var i=[],a=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],a[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),a[1]=i[1],a[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},Ce.rotateZ=function(t,e,r,n){var i=[],a=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],a[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),a[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),a[2]=i[2],t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},Ce.forEach=function(){var t=Ce.create();return function(e,r,n,i,a,o){var s,u;for(r||(r=3),n||(n=0),u=i?Math.min(i*r+n,e.length):e.length,s=n;s<u;s+=r)t[0]=e[s],t[1]=e[s+1],t[2]=e[s+2],a(t,t,o),e[s]=t[0],e[s+1]=t[1],e[s+2]=t[2];return e}}(),Ce.angle=function(t,e){var r=Ce.fromValues(t[0],t[1],t[2]),n=Ce.fromValues(e[0],e[1],e[2]);Ce.normalize(r,r),Ce.normalize(n,n);var i=Ce.dot(r,n);return i>1?0:Math.acos(i)};var Re={};Re.create=function(){var t=new Ee(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t},Re.clone=function(t){var e=new Ee(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},Re.fromValues=function(t,e,r,n){var i=new Ee(4);return i[0]=t,i[1]=e,i[2]=r,i[3]=n,i},Re.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},Re.set=function(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t},Re.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t},Re.subtract=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t},Re.sub=Re.subtract,Re.multiply=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t},Re.mul=Re.multiply,Re.divide=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t},Re.div=Re.divide,Re.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t},Re.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t},Re.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t},Re.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t},Re.distance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return Math.sqrt(r*r+n*n+i*i+a*a)},Re.dist=Re.distance,Re.squaredDistance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return r*r+n*n+i*i+a*a},Re.sqrDist=Re.squaredDistance,Re.length=function(t){var e=t[0],r=t[1],n=t[2],i=t[3];return Math.sqrt(e*e+r*r+n*n+i*i)},Re.len=Re.length,Re.squaredLength=function(t){var e=t[0],r=t[1],n=t[2],i=t[3];return e*e+r*r+n*n+i*i},Re.sqrLen=Re.squaredLength,Re.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t},Re.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t},Re.normalize=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r*r+n*n+i*i+a*a;return o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t[3]=e[3]*o),t},Re.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},Re.lerp=function(t,e,r,n){var i=e[0],a=e[1],o=e[2],s=e[3];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=o+n*(r[2]-o),t[3]=s+n*(r[3]-s),t},Re.random=function(t,e){return e=e||1,t[0]=Ae(),t[1]=Ae(),t[2]=Ae(),t[3]=Ae(),Re.normalize(t,t),Re.scale(t,t,e),t},Re.transformMat4=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t},Re.transformQuat=function(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],u=r[2],l=r[3],h=l*n+s*a-u*i,c=l*i+u*n-o*a,f=l*a+o*i-s*n,d=-o*n-s*i-u*a;return t[0]=h*l+d*-o+c*-u-f*-s,t[1]=c*l+d*-s+f*-o-h*-u,t[2]=f*l+d*-u+h*-s-c*-o,t},Re.forEach=function(){var t=R