/** @preserve Made with Koru 2.0.5 application [ https://boxshot.com/koru/ ] Copyright (c) 2005-2022 Appsforlife Ltd */
Koru={version:"2.0.5",Vec3:function(t,e,r){this.x=t||0,this.y=e||0,this.z=r||0}},Koru.Vec3.prototype={constructor:Koru.Vec3,copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},setFromArray:function(t){return this.x=t[0],this.y=t[1],this.z=t[2],this},toArray:function(){return[this.x,this.y,this.z]},setXYZ:function(t,e,r){return this.x=t,this.y=e,this.z=r,this},setScalar:function(t){return this.x=this.y=this.z=t,this},set:function(){var t;return 2<=arguments.length?(this.x=arguments[0],this.y=arguments[1],this.z=arguments[2]):(t=arguments[0]).constructor===Koru.Vec3?this.copy(t):Array.isArray(t)||t.constructor===Float32Array?this.setFromArray(t):this.setScalar(t||0),this},clone:function(){return new Koru.Vec3(this.x,this.y,this.z)},add:function(t){return t.constructor===Koru.Vec3?(this.x+=t.x,this.y+=t.y,this.z+=t.z):Array.isArray(t)||t.constructor===Float32Array?(this.x+=t[0],this.y+=t[1],this.z+=t[2]):(this.x+=t,this.y+=t,this.z+=t),this},sub:function(t){return t.constructor===Koru.Vec3?(this.x-=t.x,this.y-=t.y,this.z-=t.z):(this.x-=t,this.y-=t,this.z-=t),this},mul:function(t){return t.constructor===Koru.Vec3?(this.x*=t.x,this.y*=t.y,this.z*=t.z):(this.x*=t,this.y*=t,this.z*=t),this},div:function(t){return t.constructor===Koru.Vec3?(this.x/=t.x,this.y/=t.y,this.z/=t.z):(t=1/t,this.x*=t,this.y*=t,this.z*=t),this},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},cross:function(t){var e=this.x,r=this.y,n=this.z;return this.x=r*t.z-n*t.y,this.y=n*t.x-e*t.z,this.z=e*t.y-r*t.x,this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},normalize:function(){var t=this.length();return 0!==t&&this.div(t),this},transform:function(t){var e=this.x,r=this.y,n=this.z,t=t.m;return this.x=e*t[0]+r*t[4]+n*t[8]+t[12],this.y=e*t[1]+r*t[5]+n*t[9]+t[13],this.z=e*t[2]+r*t[6]+n*t[10]+t[14],this},transformNormal:function(t){var e=this.x,r=this.y,n=this.z,t=t.m;return this.x=e*t[0]+r*t[4]+n*t[8],this.y=e*t[1]+r*t[5]+n*t[9],this.z=e*t[2]+r*t[6]+n*t[10],this},equals:function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z}},Koru.Quaternion=function(t,e,r,n){this.x=t||0,this.y=e||0,this.z=r||0,this.w=void 0!==n?n:1},Koru.Quaternion.prototype={constructor:Koru.Quaternion,copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},setFromArray:function(t){return this.x=t[0],this.y=t[1],this.z=t[2],this.w=t[3],this},toArray:function(){return[this.x,this.y,this.z,this.w]},setFromMatrix:function(t){var e,r,n=[0,0,0,1],i=t.m,o=i[0]+i[5]+i[10];return 0<o?(r=Math.sqrt(o+1),n[3]=.5*r,r=.5/r,n[0]=(i[6]-i[9])*r,n[1]=(i[8]-i[2])*r,n[2]=(i[1]-i[4])*r):(e=0,i[5]>i[4*e+e]&&(e=1),o=(t=(e=i[10]>i[4*e+e]?2:e)<2?e+1:0)<2?t+1:0,r=Math.sqrt(i[4*e+e]-(i[4*t+t]+i[4*o+o])+1),n[e]=.5*r,0!==r&&(r=.5/r),n[t]=(i[4*e+t]+i[4*t+e])*r,n[o]=(i[4*e+o]+i[4*o+e])*r,n[3]=(i[4*t+o]-i[4*o+t])*r),this.setFromArray(n),this},clone:function(){return new Koru.Quaternion(this.x,this.y,this.z,this.w)},slerp:function(t,e){var r,n,i=this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w,o=i<0?-1:1;return e=1e-5<1-(i*=o)?(r=Math.acos(i),i=1/Math.sin(r),n=Math.sin((1-e)*r)*i,Math.sin(e*r)*i):(n=1-e,e),e*=o,this.x=this.x*n+t.x*e,this.y=this.y*n+t.y*e,this.z=this.z*n+t.z*e,this.w=this.w*n+t.w*e,this},equals:function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w}},Koru.Mat4=function(t){var e=this.m=new Float32Array(16);void 0!==t?e.set(t.constructor===Koru.Mat4?t.m:t):e[0]=e[5]=e[10]=e[15]=1},Koru.Mat4.prototype={constructor:Koru.Mat4,copy:function(t){return this.m.set(t.m),this},set:function(t){return this.m.set(t.constructor===Koru.Mat4?t.m:t),this},setIdentity:function(){var t=this.m;return t[1]=t[2]=t[3]=t[4]=t[6]=t[7]=t[8]=t[9]=t[11]=t[12]=t[13]=t[14]=0,t[0]=t[5]=t[10]=t[15]=1,this},setFromArray:function(t){return this.m.set(t),this},toArray:function(){return this.m.slice()},mulMatrices:function(t,e){t=t!==this?t.m:new Float32Array(t.m),e=e!==this?e.m:new Float32Array(e.m);var r=this.m;return r[0]=t[0]*e[0]+t[1]*e[4]+t[2]*e[8]+t[3]*e[12],r[1]=t[0]*e[1]+t[1]*e[5]+t[2]*e[9]+t[3]*e[13],r[2]=t[0]*e[2]+t[1]*e[6]+t[2]*e[10]+t[3]*e[14],r[3]=t[0]*e[3]+t[1]*e[7]+t[2]*e[11]+t[3]*e[15],r[4]=t[4]*e[0]+t[5]*e[4]+t[6]*e[8]+t[7]*e[12],r[5]=t[4]*e[1]+t[5]*e[5]+t[6]*e[9]+t[7]*e[13],r[6]=t[4]*e[2]+t[5]*e[6]+t[6]*e[10]+t[7]*e[14],r[7]=t[4]*e[3]+t[5]*e[7]+t[6]*e[11]+t[7]*e[15],r[8]=t[8]*e[0]+t[9]*e[4]+t[10]*e[8]+t[11]*e[12],r[9]=t[8]*e[1]+t[9]*e[5]+t[10]*e[9]+t[11]*e[13],r[10]=t[8]*e[2]+t[9]*e[6]+t[10]*e[10]+t[11]*e[14],r[11]=t[8]*e[3]+t[9]*e[7]+t[10]*e[11]+t[11]*e[15],r[12]=t[12]*e[0]+t[13]*e[4]+t[14]*e[8]+t[15]*e[12],r[13]=t[12]*e[1]+t[13]*e[5]+t[14]*e[9]+t[15]*e[13],r[14]=t[12]*e[2]+t[13]*e[6]+t[14]*e[10]+t[15]*e[14],r[15]=t[12]*e[3]+t[13]*e[7]+t[14]*e[11]+t[15]*e[15],this},mul:function(t){return this.mulMatrices(this,t)},invert:function(t){void 0===t?t=new Float32Array(this.m):t.constructor===Koru.Mat4&&(t=t.m);var e=t[0]*t[5]-t[1]*t[4],r=t[0]*t[6]-t[2]*t[4],n=t[0]*t[7]-t[3]*t[4],i=t[1]*t[6]-t[2]*t[5],o=t[1]*t[7]-t[3]*t[5],a=t[2]*t[7]-t[3]*t[6],s=t[8]*t[13]-t[9]*t[12],u=t[8]*t[14]-t[10]*t[12],c=t[8]*t[15]-t[11]*t[12],l=t[9]*t[14]-t[10]*t[13],h=t[9]*t[15]-t[11]*t[13],f=t[10]*t[15]-t[11]*t[14];if(0==(d=e*f-r*h+n*l+i*c-o*u+a*s))return this.setIdentity(),this;var d=1/d,m=this.m;return m[0]=(t[5]*f-t[6]*h+t[7]*l)*d,m[1]=(t[2]*h-t[1]*f-t[3]*l)*d,m[2]=(t[13]*a-t[14]*o+t[15]*i)*d,m[3]=(t[10]*o-t[9]*a-t[11]*i)*d,m[4]=(t[6]*c-t[4]*f-t[7]*u)*d,m[5]=(t[0]*f-t[2]*c+t[3]*u)*d,m[6]=(t[14]*n-t[12]*a-t[15]*r)*d,m[7]=(t[8]*a-t[10]*n+t[11]*r)*d,m[8]=(t[4]*h-t[5]*c+t[7]*s)*d,m[9]=(t[1]*c-t[0]*h-t[3]*s)*d,m[10]=(t[12]*o-t[13]*n+t[15]*e)*d,m[11]=(t[9]*n-t[8]*o-t[11]*e)*d,m[12]=(t[5]*u-t[4]*l-t[6]*s)*d,m[13]=(t[0]*l-t[1]*u+t[2]*s)*d,m[14]=(t[13]*r-t[12]*i-t[14]*e)*d,m[15]=(t[8]*i-t[9]*r+t[10]*e)*d,this},setPosition:function(t){return this.m[12]=t.x,this.m[13]=t.y,this.m[14]=t.z,this},setRotation:function(t){function e(t){return t*Math.PI/180}var r=e(t.x),n=e(t.y),i=e(t.z),o=Math.sin(r),a=Math.cos(r),s=Math.sin(n),t=Math.cos(n),r=Math.sin(-i),n=Math.cos(i),i=this.m;return i[0]=t*n,i[1]=-t*r,i[2]=s,i[4]=a*r+n*o*s,i[5]=a*n-o*s*r,i[6]=-t*o,i[8]=o*r-a*n*s,i[9]=n*o+a*s*r,i[10]=a*t,this},setFromQuaternion:function(t){var e=this.m;return e[0]=1-2*t.y*t.y-2*t.z*t.z,e[1]=2*t.x*t.y+2*t.w*t.z,e[2]=2*t.x*t.z-2*t.w*t.y,e[4]=2*t.x*t.y-2*t.w*t.z,e[5]=1-2*t.x*t.x-2*t.z*t.z,e[6]=2*t.y*t.z+2*t.w*t.x,e[8]=2*t.x*t.z+2*t.w*t.y,e[9]=2*t.y*t.z-2*t.w*t.x,e[10]=1-2*t.x*t.x-2*t.y*t.y,e[3]=e[7]=e[11]=e[12]=e[13]=e[14]=0,e[15]=1,this},setRotationAxis:function(t,e,r){var n=Math.sin(e),i=Math.cos(e),o=t.clone().normalize(),a=o.x*o.x,s=o.y*o.y,u=o.z*o.z,c=o.x*o.y,l=o.y*o.z,h=o.z*o.x,f=o.x*n,e=o.y*n,t=o.z*n,o=1-i,n=this.m;return n[0]=o*a+i,n[1]=o*c+t,n[2]=o*h-e,n[3]=0,n[4]=o*c-t,n[5]=o*s+i,n[6]=o*l+f,n[7]=0,n[8]=o*h+e,n[9]=o*l-f,n[10]=o*u+i,void(n[11]=0)===r?n[11]=n[12]=n[13]=0:(n[11]=r.x-(r.x*n[0]+r.y*n[4]+r.z*n[8]),n[12]=r.y-(r.x*n[1]+r.y*n[5]+r.z*n[9]),n[13]=r.z-(r.x*n[2]+r.y*n[6]+r.z*n[10])),n[14]=1,this},setTransformation:function(t,e,r){this.setRotation(e),this.setPosition(t);t=this.m;return void 0!==r&&(t[0]*=r.x,t[1]*=r.x,t[2]*=r.x,t[4]*=r.y,t[5]*=r.y,t[6]*=r.y,t[8]*=r.z,t[9]*=r.z,t[10]*=r.z),t[3]=t[7]=t[11]=0,t[15]=1,this},setFrustum:function(t,e,r,n,i,o){var a=1/(e-t),s=1/(n-r),u=1/(i-o),c=this.m;return c[0]=2*i*a,c[1]=0,c[2]=0,c[3]=0,c[4]=0,c[5]=2*i*s,c[6]=0,c[7]=0,c[8]=(e+t)*a,c[9]=(n+r)*s,c[10]=(o+i)*u,c[11]=-1,c[12]=0,c[13]=0,c[14]=o*i*2*u,c[15]=0,this},clone:function(){return new Koru.Mat4(this)}},Koru.Color=function(){this.set.apply(this,arguments)},Koru.Color.prototype={constructor:Koru.Color,copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this},clone:function(){return new Koru.Color(this)},set:function(){var t;return 3<=arguments.length?this.setRGBA(arguments[0],arguments[1],arguments[2],arguments[3]):void 0!==(t=arguments[0])?t.constructor===Koru.Color?this.copy(t):Array.isArray(t)||t.constructor===Float32Array?this.setFromArray(t):"number"==typeof t&&this.setHex(t):this.a=this.b=this.g=this.r=1,this},setRGBA:function(t,e,r,n){return this.r=t,this.g=e,this.b=r,this.a=void 0!==n?n:1,this},setHex:function(t){t=Math.floor(t);return this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this.a=(t>>24&255)/255,this},setScalar:function(t){return this.b=this.g=this.r=t,this.a=1,this},setFromArray:function(t){return this.r=t[0],this.g=t[1],this.b=t[2],this.a=void 0!==t[3]?t[3]:1,this},toArray:function(){return[this.r,this.g,this.b,this.a]},lerp:function(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this.a+=(t.a-this.a)*e,this}},Koru.Box3=function(t,e){this.min=t,this.max=e},Koru.Box3.prototype={constructor:Koru.Box3,copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},clone:function(){return new Koru.Box3(this.min.clone(),this.max.clone())},center:function(){return this.min.clone().add(this.max).mul(.5)},size:function(){return this.max.clone().sub(this.min)},intersect:function(t){var e,r,n,i=t.origin,o=t._invDir,a=0<=o.x?(e=(this.min.x-i.x)*o.x,(this.max.x-i.x)*o.x):(e=(this.max.x-i.x)*o.x,(this.min.x-i.x)*o.x),s=0<=o.y?(r=(this.min.y-i.y)*o.y,(this.max.y-i.y)*o.y):(r=(this.max.y-i.y)*o.y,(this.min.y-i.y)*o.y);return!(s<e||a<r)&&((e<r||e!=e)&&(e=r),(s<a||a!=a)&&(a=s),!((o=0<=o.z?(n=(this.min.z-i.z)*o.z,(this.max.z-i.z)*o.z):(n=(this.max.z-i.z)*o.z,(this.min.z-i.z)*o.z))<e||a<n)&&((e<n||e!=e)&&(e=n),!((a=o<a||a!=a?o:a)<0||e>t.tfar)&&(t.tfar=Math.max(e,0),!0)))},occluded:function(t){var e,r,n,i=t.origin,o=t._invDir,a=0<=o.x?(e=(this.min.x-i.x)*o.x,(this.max.x-i.x)*o.x):(e=(this.max.x-i.x)*o.x,(this.min.x-i.x)*o.x),s=0<=o.y?(r=(this.min.y-i.y)*o.y,(this.max.y-i.y)*o.y):(r=(this.max.y-i.y)*o.y,(this.min.y-i.y)*o.y);return!(s<e||a<r)&&((e<r||e!=e)&&(e=r),(s<a||a!=a)&&(a=s),!((o=0<=o.z?(n=(this.min.z-i.z)*o.z,(this.max.z-i.z)*o.z):(n=(this.max.z-i.z)*o.z,(this.min.z-i.z)*o.z))<e||a<n)&&((e<n||e!=e)&&(e=n),0<=(a=o<a||a!=a?o:a)&&e<=t.tfar))}},Koru.Ray=function(t,e,r){this.origin=t.clone(),this.direction=e.clone(),this.tfar=r,this._invDir=new Koru.Vec3(1,1,1).div(this.direction)},Koru.Ray.prototype={constructor:Koru.Ray,getPoint:function(t){return this.direction.clone().mul(t).add(this.origin)},hitPoint:function(){return this.getPoint(this.tfar)}},Koru.Viewport=function(){this.version=Koru.version,this.supportHighDPI=true,this.interactive=!0,this.showProgressBar=!0,this.createSnapshotButtons=!0;var h,d,m,v,p,y,g,T,a,w,x,c,b,l,s,u,E,M,A,F,P,R,O,C,z,_,N,k,L,S,n,D,I,H,B=this,U=Koru.Vec3,V=Koru.Mat4,i=Koru.Quaternion,Y=null;function K(t){return t*Math.PI/180}function o(t){return 180*t/Math.PI}function W(t){return 0==(t&t-1)}function j(t,e,r){return t+(e-t)*r}function Z(t,e,r){return Math.max(e,Math.min(t,r))}function G(t){return new U(t[0],t[1],t[2])}function q(t,e){return[t[0]*e[0]+t[1]*e[4]+t[2]*e[8]+e[12],t[0]*e[1]+t[1]*e[5]+t[2]*e[9]+e[13],t[0]*e[2]+t[1]*e[6]+t[2]*e[10]+e[14],t[0]*e[3]+t[1]*e[7]+t[2]*e[11]+e[15]]}function r(t,e){t.x=0,t.y=o(Math.atan2(e.z,Math.sqrt(e.x*e.x+e.y*e.y))),t.z=o(Math.atan2(e.y,e.x))}function X(t,e,r,n,i){return 0<e*(0<e?t[3]:t[0])+r*(0<r?t[4]:t[1])+n*(0<n?t[5]:t[2])+i}function Q(t,e){return X(t,e[3]+e[0],e[7]+e[4],e[11]+e[8],e[15]+e[12])&&X(t,e[3]-e[0],e[7]-e[4],e[11]-e[8],e[15]-e[12])&&X(t,e[3]-e[1],e[7]-e[5],e[11]-e[9],e[15]-e[13])&&X(t,e[3]+e[1],e[7]+e[5],e[11]+e[9],e[15]+e[13])&&X(t,e[3]+e[2],e[7]+e[6],e[11]+e[10],e[15]+e[14])&&X(t,e[3]-e[2],e[7]-e[6],e[11]-e[10],e[15]-e[14])}function J(t){return document.createElement(t)}function $(t){for(var e="",r=0,n=t.byteLength;r<n;r++)e+=String.fromCharCode(t[r]);return e}function tt(t){return new Uint16Array(t.buffer,0,t.length/Uint16Array.BYTES_PER_ELEMENT)}function et(t){return new Float32Array(t.buffer,0,t.length/Float32Array.BYTES_PER_ELEMENT)}function rt(t){t=function(t){for(var e=new Uint8Array(t.length),r=0,n=t.length;r<n;r++)e[r]=t.charCodeAt(r);return e}(t);return new Zlib.Inflate(t).decompress()}function nt(t){var e=I.charCodeAt(t)+(I.charCodeAt(t+1)<<8)+(I.charCodeAt(t+2)<<16)+(I.charCodeAt(t+3)<<24);return rt(I.substr(t+4,e))}function it(t){for(var e="",r=0;r<t.length;r++){var n=t.charCodeAt(r).toString(16);e+="%0".substr(0,3-n.length)+n.toUpperCase()}return decodeURIComponent(e)}function ot(t){var e,r={};for(e in t)r[it(e)]=it(t[e]);return r}function at(t,e){this.amount=this.time=0,this.duration=t,this.exp=e}function t(t){if(this.time+=t,this.time<this.duration){t=this.time/this.duration;return this.amount=t<.5?.5*Math.pow(2*t,this.exp):1-.5*Math.pow(2*(1-t),this.exp),!0}return!(this.amount=1)}function st(t,e,r,n){at.call(this,r,n),t.anim&&(le.delete(t.anim),t.anim.finish()),(t.anim=this).shadow=t,this.prevState={m:null!=t.m?t.m.slice():void 0,texture:t.texture},this.nextState=e}function ut(t,e,r,n,i){at.call(this,n,i);i=t[e];i.anim&&(le.delete(i.anim),i.anim.finish()),(i.anim=this).owner=t,this.property=e,this.nextValue=r}function ct(t,e,r,n){at.call(this,r,n),t.animM&&(le.delete(t.animM),t.animM.finish()),(t.animM=this).geom=t,this.material=e}function lt(t,e,r,n){at.call(this,r,n),t.anim&&(le.delete(t.anim),t.anim.finish()),this.camera=t,this.prevState=JSON.parse(JSON.stringify(t)),this.nextState=e,t.anim=this;n=new V;void 0===this.prevState.q&&(n.setRotation(t.rotation),this.prevState.q=(new i).setFromMatrix(n)),n.setRotation(e.rotation),this.nextState.q=(new i).setFromMatrix(n),t.q=(new i).copy(this.prevState.q)}function ht(t,e,r,n){at.call(this,r,n),t.animT&&(le.delete(t.animT),t.animT.finish()),(t.animT=this).node=t,this.prevState={p:t.p.clone(),r:t.r.clone(),s:t.s.clone()},this.nextState=e}function ft(t,e,r,n,i){at.call(this,n,i),t.animV&&(le.delete(t.animV),t.animV.finish()),(t.animV=this).node=t,this.prevO=t.o,this.nextO=r,this.nextF=e.f,1&this.nextF&&!(1&t.f)&&(t.f|=1,Qr("visibilitychange",{koru:B,node:t.no}))}window.requestAnimFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)},st.prototype={constructor:st,update:t,apply:function(){var t,e,r,n,i=this.shadow,o=this.prevState,a=this.nextState,s=this.amount;if(p(k,i.fb),Y.viewport(0,0,a.texture.w,a.texture.h),d(N),t=o.texture.texture,e=a.texture.texture,r=s,n=xt,Y.useProgram(n.program),v(L,Mt),g(n.aP,3,Y.FLOAT,!1,12,0),T(n.aP),l(n.uBlend,r),b(n.uT1,0),w(E),x(M,t),fe(M),b(n.uT2,1),w(Y.TEXTURE1),x(M,e),fe(M),Y.drawArrays(Y.TRIANGLE_FAN,0,4),p(k,null),i.bt=i.fb.texture,null==o.m)i.m=a.m;else if(null!=a.m)for(var u=0;u<4;u++)i.m[u]=j(o.m[u],a.m[u],s)},finish:function(){var t=this.shadow,e=this.amount<.5?this.prevState:this.nextState;t.texture=e.texture,t.bt=void 0,t.m=null!=e.m?e.m.slice():void 0,delete t.anim}},ut.prototype={constructor:ut,update:t,apply:function(){},finish:function(){delete this.owner[this.property].anim,.5<=this.amount&&(this.owner[this.property]=this.nextValue)}},ct.prototype={constructor:ct,update:t,apply:function(){},finish:function(){var t=this.geom;.5<=this.amount&&(t.material=this.material),delete t.animM}},lt.prototype={constructor:lt,update:t,apply:function(){var t=this.camera,e=this.prevState,r=this.nextState,n=this.amount;t.target.copy(e.target).lerp(r.target,n),t.dist=j(e.dist,r.dist,n),t.q.copy(e.q).slerp(r.q,n),t.fov=j(e.fov,r.fov,n),t.idleTime=0},finish:function(){var t,e=this.camera;1===this.amount&&(t=this.nextState,e.target.copy(t.target),e.rotation.copy(t.rotation),e.dist=t.dist,e.fov=t.fov,e.flags=t.flags,e.sensitivity=t.sensitivity,e.minDistance="minDistance"in t?t.minDistance:0,e.maxDistance="maxDistance"in t?t.maxDistance:1e6,e.minYaw="minYaw"in t?t.minYaw:0,e.maxYaw="maxYaw"in t?t.maxYaw:360,e.minPitch="minPitch"in t?t.minPitch:-90,e.maxPitch="maxPitch"in t?t.maxPitch:90,e.idleAnimation=16&t.flags?t.idleAnimation:null,e.idleTime=0,delete e.q),delete e.anim}},ht.prototype={constructor:ht,update:t,apply:function(){var t=this.node,e=this.prevState,r=this.nextState,n=this.amount;t.p.copy(e.p).lerp(r.p,n),t.r.copy(e.r).lerp(r.r,n),t.s.copy(e.s).lerp(r.s,n),t.tm.setTransformation(t.p,t.r,t.s)},finish:function(){var t,e=this.node;1===this.amount&&(t=this.nextState,e.p.copy(t.p),e.r.copy(t.r),e.s.copy(t.s),e.tm.setTransformation(e.p,e.r,e.s)),delete e.animT}},ft.prototype={constructor:ft,update:t,apply:function(){this.node.o=j(this.prevO,this.nextO,this.amount)},finish:function(){var t=this.node;1===this.amount&&(t.o=this.nextO,1&t.f&&!(1&this.nextF)&&(t.f&=-2,Qr("visibilitychange",{koru:B,node:t.no}))),delete t.animV}};var dt,mt,vt,pt,yt,gt,Tt,wt,xt,bt,Et,Mt,At,Ft,Pt=[],Rt=0,Ot=new U,Ct=new Float32Array([0,0,1,0]),zt=!1,_t=[0,0],Nt=new V,kt=new V,Lt=new V,St=new V,Dt=new V,It=new V,Ht=new V,Bt=new V,Ut=new V,Vt=new V,Yt=new V([0,1,0,0,0,0,1,0,1,0,0,0,0,0,0,1]),Kt=[],Wt=[],jt=[],Zt=[],Gt=[],qt=[Zt,jt,Gt],Xt=[],Qt=null,Jt=null,$t=null,te=null,ee=null,re=null,ne=null,ie=null,oe=2048,ae=!1,se=!1,ue=!1,ce=!0,le=new Set,he=[];function fe(t){c(t,P,O),c(t,R,O)}function de(t){c(t,P,C),c(t,R,C)}function me(t){c(t,A,Y.CLAMP_TO_EDGE),c(t,F,Y.CLAMP_TO_EDGE)}function ve(t,e,r,n,i){try{var o=Y.createFramebuffer();o.w=t,o.h=e,o.texture=Y.createTexture(),x(M,o.texture),me(M),(i?de:fe)(M),Y.texImage2D(M,0,Y.RGBA,t,e,0,Y.RGBA,r,null),p(k,o),Y.framebufferTexture2D(k,Y.COLOR_ATTACHMENT0,M,o.texture,0),n&&(o.depthBuffer=Y.createRenderbuffer(Y.RENDERBUFFER),Y.bindRenderbuffer(Y.RENDERBUFFER,o.depthBuffer),Y.renderbufferStorage(Y.RENDERBUFFER,Y.DEPTH_STENCIL,t,e),Y.bindRenderbuffer(Y.RENDERBUFFER,null),Y.framebufferRenderbuffer(k,Y.DEPTH_STENCIL_ATTACHMENT,Y.RENDERBUFFER,o.depthBuffer));var a=Y.checkFramebufferStatus(k);return p(k,null),a!==Y.FRAMEBUFFER_COMPLETE?(console.error("Unable to create frame buffer "+t+"x"+e+", status: "+a),pe(o),null):o}catch(t){return p(k,null),console.error(t),null}}function pe(t){t&&(Y.deleteFramebuffer(t),t.texture&&Y.deleteTexture(t.texture),t.depthBuffer&&Y.deleteRenderbuffer(t.depthBuffer))}function ye(t,e,r){var n=ie&&re?ee.HALF_FLOAT_OES:ne&&te?Y.FLOAT:Y.UNSIGNED_BYTE,i=1.4<window.devicePixelRatio/Math.min(window.screen.availWidth/document.documentElement.clientWidth,window.screen.availHeight/document.documentElement.clientHeight),o=r?(window.devicePixelRatio||1)*(i?1:2):1,r=t*o,o=e*o;Xt[0]=ve(r,o,n,!0),null===Xt[0]&&(se=!0,n=Y.UNSIGNED_BYTE,Xt[0]=ve(r,o,Y.UNSIGNED_BYTE,!0)),Xt[1]=ve(r,o,Y.UNSIGNED_BYTE,!1,!i),pt=ve(r,o,n,!1);for(var a=2;a<10;a++)Xt[a]=ve(t,e,2===a?n:Y.UNSIGNED_BYTE,!1),a%2&&(t=t/2|0,e=e/2|0)}function ge(t){_t=[t.viewport.clientWidth,t.viewport.clientHeight];var e=t.canvas,r=t.supportHighDPI&&window.devicePixelRatio||1,n=_t[0]*r|0,r=_t[1]*r|0;if(e.width!==n||e.height!==r){for(var i in console.log("resize: "+_t[0]+"x"+_t[1]),Wr(),Y.viewportWidth=e.width=n,Y.viewportHeight=e.height=r,pe(pt),Xt)pe(Xt[i]);ye(_t[0],_t[1],t.supportHighDPI)}}function Te(t){var e,r=D.textures;for(e in r)if(t===r[e].id)return r[e];return null}function we(t,e){if(e!==Y.RGB)return et(t);for(var r=new Float32Array(t.length/4*3),n=new DataView(t.buffer),i=0,o=0,a=r.length;i<a;i+=3,o+=4){var s=n.getUint8(o+3);0<s?(f=Math.pow(2,s-136),r[i+0]=n.getUint8(o+0)*f,r[i+1]=n.getUint8(o+1)*f,r[i+2]=n.getUint8(o+2)*f):(r[i+0]=0,r[i+1]=0,r[i+2]=0)}return r}function xe(t){x(t.tt,t.texture)}function be(t){var e=t.f,r=t.t,n=r;if(t.texture=Y.createTexture(),t.data.hasOwnProperty(length)&&6===t.data.length){t.tt=Y.TEXTURE_CUBE_MAP,xe(t),de(t.tt),me(t.tt);for(var i=0;i<6;i++){var o=nt(t.data[i]);n===Y.FLOAT&&(ae?o=we(o,e):(ue=!0,e=Y.RGBA,r=Y.UNSIGNED_BYTE)),Y.texImage2D(Y.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,e,t.w,t.h,0,e,r,o)}}else{t.tt=M,xe(t);var a,o=nt(t.data);n===Y.FLOAT&&(o=we(o,e),$t||(o=function(t){for(var e=new Uint8Array(t.length),r=0;r<t.length;r++)e[r]=255*Z(t[r],0,1);return e}(o),r=Y.UNSIGNED_BYTE)),xe(t),Y.texImage2D(t.tt,0,e,t.w,t.h,0,e,r,o),0===Y.getError()&&(W(t.w)&&W(t.h)?(Y.generateMipmap(t.tt),c(t.tt,A,Y.REPEAT),c(t.tt,F,Y.REPEAT),c(t.tt,R,C),c(t.tt,P,Y.LINEAR_MIPMAP_LINEAR)):(de(t.tt),me(t.tt))),null!=t.idata&&((a=new Image).t=t,a.onload=function(){for(;a.width>oe||a.height>oe;){var t=document.createElement("canvas");t.width=a.width>oe?a.width/2:a.width,t.height=a.height>oe?a.height/2:a.height,t.getContext("2d").drawImage(a,0,0,t.width,t.height),a=t}var e=this.t;e.w=a.width,e.h=a.height,xe(e),Y.texImage2D(e.tt,0,e.f,e.f,e.t,a),Y.generateMipmap(e.tt),Wr()},a.onerror=function(){console.error("Unable to load image",this.t)},o=H?H.substr(t.idata[0],t.idata[1]):btoa(I.substr(t.idata[0],t.idata[1])),a.src="data:image/"+("/"===o[0]?"jpeg":"png")+";base64,"+o)}}function Ee(t){void 0!==t&&(t.color=new Float32Array(t.color),t.hasOwnProperty("texture")&&(t.texture=Te(t.texture)),t.hasOwnProperty("diffuseTexture")&&(t.diffuseTexture=Te(t.diffuseTexture)))}function Me(t){var e,r;void 0!==t&&(t.color=new Float32Array(t.color),t.texture&&(t.texture=Te(t.texture),(e=t.data)&&(r=je(e.vertices),e.vertices=r.vertices,e.vb=r.vb,r=Ze(e.indices),e.indices=r.indices,e.ib=r.ib,e.icount=r.indices.length)),r=_e(t.defs,!ae&&t.texture&&t.texture.t===Y.FLOAT),t.shader=ze(r+D.shaders[0],r+D.shaders[1],["aP"],["uColor","uT","uIVPM","uTT","uColor2","uMVPM","uEO"]))}function Ae(){for(var t in D.shaders)D.shaders[t]=$(nt(D.shaders[t]));var e=D.camera;e.target=G(e.target),e.rotation=G(e.rotation),e.idleTime=0;var r=D.environment,e=D.background;Ee(r),Me(e),D.hasOwnProperty("noiseTexture")&&(D.noiseTexture=Te(D.noiseTexture),xe(D.noiseTexture),fe(M)),yt=ze(D.shaders[4],"#define BLUR\n#define THRESHOLD\n"+D.shaders[5],["aP"],["uBlend","uT","uThreshold"]),gt=ze(D.shaders[4],"#define BLUR\n"+D.shaders[5],["aP"],["uOffset","uT"]),Tt=ze(D.shaders[4],"#define GLOW\n"+D.shaders[5],["aP"],["uT1","uT2","uT3","uT4","uLevel"]),wt=ze(D.shaders[4],"#define CLIP\n"+D.shaders[5],["aP"],["uT","uColor"]),xt=ze(D.shaders[4],"#define MIX\n"+D.shaders[5],["aP"],["uBlend","uT1","uT2"]),bt=ze(D.shaders[4],D.shaders[5],["aP"],["uT"]),Et=ze("#define AREA\n"+D.shaders[4],"#define AREA\n"+D.shaders[5],["aP"],["uM","uTM","uT"]),ue=!ae&&r.texture&&r.texture.t===Y.FLOAT,Mt=Y.createBuffer(),v(L,Mt),y(L,new Float32Array([-1,1,1,1,1,1,1,-1,1,-1,-1,1]),Y.STATIC_DRAW),se&&delete D.glow,null!=D.floor&&(D.floor.material=dt[D.floor.material],(n={}).vb=Mt,n.ib=Y.createBuffer(),n.icount=6,v(S,n.ib),y(S,new Uint16Array([0,1,2,0,2,3]),Y.STATIC_DRAW),D.floor.data=[n]);var n=D.shadow;null!=n&&((i=n.texture=Te(n.texture))?null!=D.snapshots&&(n.fb=ve(i.w,i.h,Y.UNSIGNED_BYTE,!1)):delete D.shadow);var i,n=D.lightmap;n&&((i=n.texture=Te(n.texture))?null!=D.snapshots&&(n.fb=ve(i.w,i.h,Y.UNSIGNED_BYTE,!1)):delete D.lightmap)}function Fe(){var t=D.snapshots;if(null!=t)for(var e in t){var r=t[e];null!=r.shadow&&(r.shadow.texture=Te(r.shadow.texture)),null!=r.lightmap&&(r.lightmap.texture=Te(r.lightmap.texture));var n=r.nodes;if(null!=n)for(var i in n){i=n[i];i.p=G(i.p),i.r=G(i.r),i.s=G(i.s)}e=r.camera;e&&(e.target=G(e.target),e.rotation=G(e.rotation)),Ee(r.environment),Me(r.background)}}var Pe=["aP","aN","aT","aB","aTC0","aTC1","aTC3"],Re=["uMVPM","uMM","uNM","uCP","uFN","uISS","uClP","uEnC","uEnT","uDEnT","uEnT2","uDEnT2","uCF","uMT","uMTM","uEC","uET","uETM","uDC","uDT","uDTM","uRC","uRT","uRTM","uTC","uTT","uTTM","uRoL","uRoT","uRoTM","uBL","uNmT","uNmTM","uAL","uAA","uAT","uATM","uAAT","uAATM","uThT","uThTM","uFRT","uFRM","uFST","uFSM","uRfT","uNoT","uEta","uRfrT","uRfrM","uLMT","uHC"],Oe={};function Ce(t,e){e=Y.createShader(e);return Y.shaderSource(e,t),Y.compileShader(e),Y.getShaderParameter(e,Y.COMPILE_STATUS)?e:(console.error(Y.getShaderInfoLog(e)),null)}function ze(t,e,r,n){var i,o={};for(i in o.program=function(t,e){if(t=Ce(t,Y.VERTEX_SHADER),e=Ce("precision mediump float;\n"+e,Y.FRAGMENT_SHADER),t&&e){var r=Y.createProgram();return Y.attachShader(r,t),Y.attachShader(r,e),Y.linkProgram(r),Y.getProgramParameter(r,Y.LINK_STATUS)?r:(console.error("Could not initialise shaders"),null)}}(t,e),r){var a=Y.getAttribLocation(o.program,r[i]);-1!==a&&(o[r[i]]=a)}for(i in n){var s=Y.getUniformLocation(o.program,n[i]);null!==s&&(o[n[i]]=s)}return o}function _e(t,e){for(var r="",n=0,i=t;0<i;n++,i=Math.floor(i/2))1&i&&(r+="#define D"+n+"\n");return(void 0!==e?e:ue)&&(r+="#define D22\n"),r}function Ne(t,e,r){var n=t.texture,i=t.tt,o=e[0],a=e[1],s=r,u=r===O?O:C;this.setFromImage=function(t){return n=Y.createTexture(),t=t,x(i=M,n),Y.texImage2D(i,0,Y.RGBA,Y.RGBA,Y.UNSIGNED_BYTE,t),W(t.width)&&W(t.height)?Y.generateMipmap(i):(o=a=Y.CLAMP_TO_EDGE,s=u=C),this},this.set=function(t){return(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement)&&this.setFromImage(t),this},this.bind=function(){x(i,n),c(i,A,o),c(i,F,a),c(i,P,s),c(i,R,u)}}function ke(e,r){r.shader=function(t){if(Oe.hasOwnProperty(t))return Oe[t];var e=ze((e=_e(t))+D.shaders[2],e+D.shaders[3],Pe,Re);return Oe[t]=e}(r.defs),r.tcount=0;var t,n=[],i=r.shader;"uMVPM"in i&&n.push(function(){Y.uniformMatrix4fv(i.uMVPM,!1,Vt.m)}),"uMM"in i&&n.push(function(){Y.uniformMatrix4fv(i.uMM,!1,Dt.m)}),"uNM"in i&&n.push(function(){It.copy(Dt).invert(),Y.uniformMatrix4fv(i.uNM,!1,It.m)}),"uCP"in i&&n.push(function(){s(i.uCP,new Float32Array([Ot.x,Ot.y,Ot.z]))}),"uEnC"in i&&n.push(function(){s(i.uEnC,D.environment.color)}),"uEC"in i&&(t=e.o*e.ec[3],e.ea=new Float32Array([e.ec[0]*t,e.ec[1]*t,e.ec[2]*t]),n.push(function(){s(i.uEC,mt<1?new Float32Array([e.ea[0]*mt,e.ea[1]*mt,e.ea[2]*mt]):e.ea)})),"uDC"in i&&(t=e.o*e.dc[3],e.da=new Float32Array([e.dc[0]*t,e.dc[1]*t,e.dc[2]*t,t]),n.push(function(){u(i.uDC,mt<1?new Float32Array([e.da[0]*mt,e.da[1]*mt,e.da[2]*mt,e.da[3]*mt]):e.da)})),"uRC"in i&&(t=e.o*e.rc[3],e.ra=new Float32Array([e.rc[0]*t,e.rc[1]*t,e.rc[2]*t,t]),n.push(function(){u(i.uRC,mt<1?new Float32Array([e.ra[0]*mt,e.ra[1]*mt,e.ra[2]*mt,e.ra[3]*mt]):e.ra)})),"uTC"in i&&(e.tc=new Float32Array(e.tc),n.push(function(){u(i.uTC,e.tc)})),"uBL"in i&&n.push(function(){l(i.uBL,e.bl)}),"uRoL"in i&&n.push(function(){l(i.uRoL,e.ro)}),"uAL"in i&&n.push(function(){l(i.uAL,e.a)}),"uAA"in i&&n.push(function(){l(i.uAA,e.aa)}),"uFN"in i&&n.push(function(){l(i.uFN,Rt)}),"uISS"in i&&n.push(function(){Y.uniform2f(i.uISS,1/Y.viewportWidth,1/Y.viewportHeight)}),"uClP"in i&&n.push(function(){u(i.uClP,Ct)}),"uMTM"in i&&n.push(function(){s(i.uMTM,e.mTM)}),"uNmTM"in i&&n.push(function(){s(i.uNmTM,e.nmTM)}),"uETM"in i&&n.push(function(){s(i.uETM,e.ecTM)}),"uDTM"in i&&n.push(function(){s(i.uDTM,e.dcTM)}),"uRTM"in i&&n.push(function(){s(i.uRTM,e.rcTM)}),"uTTM"in i&&n.push(function(){s(i.uTTM,e.tcTM)}),"uThTM"in i&&n.push(function(){s(i.uThTM,e.thTM)}),"uRoTM"in i&&n.push(function(){s(i.uRoTM,e.roTM)}),"uATM"in i&&n.push(function(){s(i.uATM,e.aTM)}),"uAATM"in i&&n.push(function(){s(i.uAATM,e.aaTM)}),"uFRM"in i&&n.push(function(){var t=kt.clone();t[12]=t[13]=t[14]=0,t.mulMatrices(t,Lt);t=t.m,t=new Float32Array([t[0],t[4],-t[8],0,t[1],t[5],-t[9],0,t[3],t[7],-t[11],0]);t[0]=.5*(t[0]+t[8]),t[1]=.5*(t[1]+t[9]),t[2]=.5*(t[2]+t[10]),t[4]=.5*(t[4]+t[8]),t[5]=.5*(t[5]+t[9]),t[6]=.5*(t[6]+t[10]),u(i.uFRM,t)}),"uRfrM"in i&&n.push(function(){var t=kt.clone();t[12]=t[13]=t[14]=0,t.mulMatrices(t,Lt);t=t.m,t=new Float32Array([t[0],t[4],t[8],0,t[1],t[5],t[9],0,t[3],t[7],t[11],0]);t[0]=.5*(t[0]+t[8]),t[1]=.5*(t[1]+t[9]),t[2]=.5*(t[2]+t[10]),t[4]=.5*(t[4]+t[8]),t[5]=.5*(t[5]+t[9]),t[6]=.5*(t[6]+t[10]),u(i.uRfrM,t)}),"uFSM"in i&&n.push(function(){var t=D.shadow.m||[0,0,0,0];Y.uniform4f(i.uFSM,t[0],t[1],t[2]-Ot.x*t[0],t[3]-Ot.y*t[1])}),"uEta"in i&&n.push(function(){Y.uniform2f(i.uEta,e.eta[0],e.eta[1])}),"uFRT"in i&&n.push(function(){var t=r.tcount++;b(i.uFRT,t),w(E+t),x(M,Xt[2].texture),de(M)}),"uRfrT"in i&&n.push(function(){var t=r.tcount++;b(i.uRfrT,t),w(E+t),x(M,pt.texture),de(M)}),"uFST"in i&&n.push(function(){var t=r.tcount++;b(i.uFST,t),w(E+t),x(M,D.shadow.bt||D.shadow.texture.texture),de(M),me(M)}),"uEnT"in i&&n.push(function(){var t=r.tcount++;b(i.uEnT,t),w(E+t),xe(D.environment.texture)}),"uEnT2"in i&&n.push(function(){var t=r.tcount++;b(i.uEnT2,t),w(E+t),xe(D.environment.anim.nextValue.texture)}),"uCF"in i&&n.push(function(){l(i.uCF,D.environment.anim.amount)}),"uDEnT"in i&&n.push(function(){var t=r.tcount++;b(i.uDEnT,t),w(E+t),xe(D.environment.diffuseTexture)}),"uDEnT2"in i&&n.push(function(){var t=r.tcount++;b(i.uDEnT2,t),w(E+t),xe(D.environment.anim.nextValue.diffuseTexture)}),"uLMT"in i&&n.push(function(){var t=r.tcount++;b(i.uLMT,t),w(E+t),x(M,D.lightmap.bt||D.lightmap.texture.texture),de(M),me(M)}),"uMT"in i&&n.push(function(){var t=r.tcount++;b(i.uMT,t),w(E+t),e.mm.bind()}),"uET"in i&&n.push(function(){var t=r.tcount++;b(i.uET,t),w(E+t),e.em.bind()}),"uDT"in i&&n.push(function(){var t=r.tcount++;b(i.uDT,t),w(E+t),e.dm.bind()}),"uRT"in i&&n.push(function(){var t=r.tcount++;b(i.uRT,t),w(E+t),e.sm.bind()}),"uTT"in i&&n.push(function(){var t=r.tcount++;b(i.uTT,t),w(E+t),xe(e.tcT),c(e.tcT.tt,A,e.tcWM[0]),c(e.tcT.tt,F,e.tcWM[1]),c(e.tcT.tt,P,e.tcF+O),c(e.tcT.tt,R,e.tcF+O)}),"uRfT"in i&&n.push(function(){var t=r.tcount++;b(i.uRfT,t),w(E+t),xe(e.frT)}),"uThT"in i&&n.push(function(){var t=r.tcount++;b(i.uThT,t),w(E+t),xe(e.thT),c(e.thT.tt,A,e.thWM[0]),c(e.thT.tt,F,e.thWM[1])}),"uNmT"in i&&n.push(function(){var t=r.tcount++;b(i.uNmT,t),w(E+t),xe(e.nmT),c(e.nmT.tt,A,e.nmWM[0]),c(e.nmT.tt,F,e.nmWM[1])}),"uNoT"in i&&n.push(function(){var t=r.tcount++;b(i.uNoT,t),w(E+t),xe(D.noiseTexture)}),"uRoT"in i&&n.push(function(){var t=r.tcount++;b(i.uRoT,t),w(E+t),xe(e.roT),c(e.roT.tt,A,e.roWM[0]),c(e.roT.tt,F,e.roWM[1])}),"uAT"in i&&n.push(function(){var t=r.tcount++;b(i.uAT,t),w(E+t),xe(e.aT),c(e.aT.tt,A,e.aWM[0]),c(e.aT.tt,F,e.aWM[1])}),"uAAT"in i&&n.push(function(){var t=r.tcount++;b(i.uAAT,t),w(E+t),xe(e.aaT),c(e.aaT.tt,A,e.aaWM[0]),c(e.aaT.tt,F,e.aaWM[1]),c(e.aaT.tt,P,e.aaF+O),c(e.aaT.tt,R,e.aaF+O)}),"uHC"in i&&n.push(function(){u(i.uHC,vt)}),r.binds=n}var Le=["m","ec","dc","rc","tc","nm","th","ro","a","aa"],Se=1<<25,De=1<<23,Ie=Math.pow(2,38);function He(t){var e=t.data,r=0,t=0;void 0!==D.lightmap&&void 0!==e[0].tc3b&&(t|=1,r+=Se),void 0!==vt&&(t|=2,r+=De),D.environment.anim&&(t|=4,r+=Ie);var n=this[t];void 0===n&&(ke(this,n={defs:this.defs+r}),this[t]=n);var i=n.shader;if(i.program){for(var o in Y.useProgram(i.program),n.tcount=0,n.binds)n.binds[o]();for(var o in e)!function(t,e){v(L,e.vb),g(t.aP,3,Y.FLOAT,!1,12,0),T(t.aP),void 0!==t.aN&&(e.nb?(v(L,e.nb),g(t.aN,3,Y.FLOAT,!1,12,0),T(t.aN)):a(t.aN)),void 0!==t.aT&&(e.tbb?(v(L,e.tbb),g(t.aT,3,Y.FLOAT,!1,24,0),T(t.aT),void 0!==t.aB&&(g(t.aB,3,Y.FLOAT,!1,24,12),T(t.aB))):(a(t.aT),void 0!==t.aB&&a(t.aB)));for(var r=0;r<4;r++){var n,i=t["aTC"+r];void 0!==i&&((n=e["tc"+r+"b"])?(v(L,n),g(i,2,Y.FLOAT,!1,8,0),T(i)):a(i))}v(S,e.ib),Y.drawElements(Y.TRIANGLES,e.icount,Y.UNSIGNED_SHORT,0)}(i,e[o]);for(;0<n.tcount--;)w(E+n.tcount),x(M,null)}}function Be(t){for(var e in Le){e=Le[e]+"T";e in t&&(t[e]=Te(t[e]),t[e+="M"]=new Float32Array(t[e]))}"frT"in t&&(t.frT=Te(t.frT),xe(t.frT),de(M),me(M)),t.o=t.o||1,t.mm="mT"in t?new Ne(t.mT,t.mWM,n[t.mF]):null,t.em="ecT"in t?new Ne(t.ecT,t.ecWM,n[t.ecF]):null,t.dm="dcT"in t?new Ne(t.dcT,t.dcWM,n[t.dcF]):null,t.sm="rcT"in t?new Ne(t.rcT,t.rcWM,n[t.rcF]):null,t[0]={defs:t.defs},ke(t,t[0]),t.draw=He}function Ue(t){if(!t.hasOwnProperty("vertices")||!t.hasOwnProperty("normals")||!t.hasOwnProperty("indices"))return null;for(var e=t.indices,r=t.vertices,n=t.normals,i=t["tc"+t.tbi]||t.tc0||null,o=new Float32Array(r.length<<1),a=0;a<e.length;a+=3)!function(r,t,e,n,i,o){var a,s;s=e?(u=n<<1,h=o<<1,a=e[s=i<<1]-e[u],c=e[1+s]-e[1+u],l=e[h]-e[u],e[1+h]-e[1+u]):(l=c=0,a=1),0===(h=a*s-c*l)&&(l=c=0,h=s=a=1),i*=3,o*=3;var e=new U(t[n*=3],t[n+1],t[n+2]),u=new U(t[i],t[i+1],t[i+2]),t=new U(t[o],t[o+1],t[o+2]);u.sub(e),t.sub(e);var c=u.clone().mul(s).sub(t.clone().mul(c)),l=t.clone().mul(a).sub(u.clone().mul(l)),h=1/h;c.mul(h),l.mul(h),n<<=1,i<<=1,o<<=1,[c.x,c.y,c.z,l.x,l.y,l.z].forEach(function(t,e){r[n+e]+=t,r[i+e]+=t,r[o+e]+=t})}(o,r,i,e[a+0],e[a+1],e[a+2]);for(var a=0,s=r.length;a<s;a+=3){var u=a<<1,c=new U(n[a],n[a+1],n[a+2]),l=new U(o[u],o[1+u],o[2+u]),h=new U(o[3+u],o[4+u],o[5+u]);l.sub(c.clone().mul(l.dot(c))).normalize(),h.sub(c.clone().mul(h.dot(c))).normalize(),o[u]=l.x,o[1+u]=l.y,o[2+u]=l.z,o[3+u]=h.x,o[4+u]=h.y,o[5+u]=h.z}return o}var Ve={},Ye={},Ke={},We={};function je(t){if(Ve.hasOwnProperty(t))return Ve[t];var e=nt(t),r=e=et(e),n=Y.createBuffer();v(L,n),y(L,e,Y.STATIC_DRAW);n={vertices:r,vb:n};return Ve[t]=n}function Ze(t){if(We.hasOwnProperty(t))return We[t];var e=nt(t),r=e=tt(e),n=Y.createBuffer();v(S,n),y(S,e,Y.STATIC_DRAW);n={indices:r,ib:n};return We[t]=n}function Ge(t){t.hasOwnProperty("vertices")&&(r=je(t.vertices),t.vertices=r.vertices,t.vb=r.vb),t.hasOwnProperty("normals")&&(r=function(t){if(Ye.hasOwnProperty(t))return Ye[t];for(var e=tt(e=nt(t)),r=new Float32Array(e.length/2*3),n=Math.PI/32768,i=0,o=0;i<e.length;){var a=e[i++]*n,s=e[i++]*n,u=Math.sin(a),c=Math.cos(a),a=Math.sin(s),s=Math.cos(s);r[o++]=c*s,r[o++]=u*s,r[o++]=a}var l=Y.createBuffer();return v(L,l),y(L,r,Y.STATIC_DRAW),l={normals:r,nb:l},Ye[t]=l}(t.normals),t.normals=r.normals,t.nb=r.nb);for(var e=0;e<4;e++){var r,n="tc"+e;t.hasOwnProperty(n)&&(r=function(t){var e=t<0;if(e&&(t=-t),Ke.hasOwnProperty(t))return Ke[t];var r=nt(t);if(e)for(var n=new Float32Array(r.buffer,0,4),i=new Uint16Array(r.buffer,16,(r.length-16)/Uint16Array.BYTES_PER_ELEMENT),r=new Float32Array(i.length),o=n[0],a=n[1],s=(n[2]-o)/65535,u=(n[3]-a)/65535,c=0;c<r.length;)r[c]=i[c]*s+o,r[++c]=i[c]*u+a,c++;else r=et(r);return n=Y.createBuffer(),v(L,n),y(L,r,Y.STATIC_DRAW),n={tc:r,ab:n},Ke[t]=n}(t[n]),t[n]=r.tc,t[n+"b"]=r.ab)}t.hasOwnProperty("indices")&&(r=Ze(t.indices),t.indices=r.indices,t.icount=r.indices.length,t.ib=r.ib);var i=Ue(t);i&&(t.tbb=Y.createBuffer(),v(L,t.tbb),y(L,i,Y.STATIC_DRAW))}function qe(a){this.userData={},Object.defineProperty(this,"target",{get:function(){return a.target},set:function(t){a.target.set(t),Wr()}}),Object.defineProperty(this,"position",{get:function(){var t,e,r,n,i,o=new U;return t=o,e=a.rotation,r=K(e.y),n=K(e.z),i=Math.cos(r),e=Math.sin(r),r=Math.cos(n),n=Math.sin(n),t.x=r*i,t.y=n*i,t.z=e,o.mul(a.dist).add(a.target)},set:function(t){t=(new U).set(t).sub(this.target);a.dist=t.length(),r(a.rotation,t),Wr()}}),Object.defineProperty(this,"rotation",{get:function(){return a.rotation},set:function(t){a.rotation.set(t),Wr()}}),Object.defineProperty(this,"distance",{get:function(){return a.dist},set:function(t){a.dist=t,Wr()}}),Object.defineProperty(this,"matrixWorld",{value:Nt,writable:!1}),Object.defineProperty(this,"matrixView",{value:kt,writable:!1}),Object.defineProperty(this,"matrixProj",{value:St,writable:!1}),Object.defineProperty(this,"matrixViewProj",{value:Bt,writable:!1}),this.lookAt=function(t){var e=this.position;a.target.set(t),e.sub(a.target),a.dist=e.length(),r(a.rotation,e),Wr()},this.getRay=function(t,e){var r=this.position,t=q([t,e,1],Bt.clone().invert().m),e=G(t).div(t[3]).sub(r),t=e.length();return new Koru.Ray(r,e.div(t),t)},this.getPixelRay=function(t,e){return this.getRay(t/_t[0]*2-1,e/_t[1]*-2+1)}}function Xe(t){if(this.visible){var e=!1,r=this.meshes;if(0<r.length){var n,i,o=this.matrixWorld.clone().invert(),a=new Koru.Ray(t.origin.clone().transform(o),t.direction.clone().transformNormal(o),t.tfar);for(i in r){var s=r[i];void 0!==s.boundingBox&&s.boundingBox.occluded(a)&&s.intersect(a)&&(n=s)}n&&(e=!0,t.tfar=a.tfar,t.triangle=a.triangle,t.triangle.gNormal.normalize(),t.mesh=n,t.node=this)}for(i in this.children)e|=this.children[i].intersect(t);return e}}function Qe(t,e){if(!t.hasOwnProperty("vertices")||!t.hasOwnProperty("indices"))return!1;for(var r=!1,n=t.indices,i=t.vertices,o=new U,a=new U,s=new U,u=0;u<n.length;u+=3){var c=3*n[u+0],l=3*n[u+1],h=3*n[u+2];o.setXYZ(i[c],i[1+c],i[2+c]),a.setXYZ(i[l],i[1+l],i[2+l]),s.setXYZ(i[h],i[1+h],i[2+h]),r|=function(t,e,r,n,i){var o,a=e.clone().sub(t),s=r.clone().sub(t),u=s.clone().cross(a),c=n.direction.dot(u);if(0<c)o=1;else{if(!(c<0))return!1;if(i)return!1;o=-1,c=-c}i=n.origin.clone().sub(t),a=-o*a.cross(i).dot(n.direction);if(a<0)return!1;s=o*s.cross(i).dot(n.direction);if(s<0||c<a+s)return!1;i=-o*i.dot(u);if(i<0||i>n.tfar*c)return!1;return c=1/c,n.tfar=i*c,n.triangle={u:a*c,v:s*c,vertices:[t,e,r],gNormal:u},!0}(o,a,s,e,!1)}return r}function Je(e){this.name=e.name,this.userData={};var r=new Koru.Color(e.dc||4294967295),n=new Koru.Color(e.rc||4294967295),i=new Koru.Color(e.ec||16777215),o=this;Object.defineProperty(this,"mask",{get:function(){return e.mm},set:function(t){e.mm?(e.mm.set(t),Wr()):console.log("The material layer doesn't have mask")}}),Object.defineProperty(this,"opacity",{get:function(){return e.o},set:function(t){e.o=t,o.update()}}),Object.defineProperty(this,"diffuseEnabled",{value:!!(2&e.defs),writable:!1}),Object.defineProperty(this,"diffuseColor",{get:function(){return r},set:function(t){r.set(t),o.update()}}),Object.defineProperty(this,"diffuseMap",{get:function(){return e.dm},set:function(t){e.dm?(e.dm.set(t),Wr()):console.log("The material layer doesn't have diffuseMap")}}),Object.defineProperty(this,"specularEnabled",{value:!!(4&e.defs),writable:!1}),Object.defineProperty(this,"specularColor",{get:function(){return n},set:function(t){n.set(t),o.update()}}),Object.defineProperty(this,"specularMap",{get:function(){return e.sm},set:function(t){e.sm?(e.sm.set(image),Wr()):console.log("The material layer doesn't have specularMap")}}),Object.defineProperty(this,"emissiveEnabled",{value:!!(8&e.defs),writable:!1}),Object.defineProperty(this,"emissiveColor",{get:function(){return i},set:function(t){i.set(t),o.update()}}),Object.defineProperty(this,"emissiveMap",{get:function(){return e.em},set:function(t){e.em?(e.em.set(image),Wr()):console.log("The material layer doesn't have emissiveMap")}}),this.update=function(){var t=e.o*r.a;return e.da=new Float32Array([r.r*t,r.g*t,r.b*t,t]),t=e.o*n.a,e.ra=new Float32Array([n.r*t,n.g*t,n.b*t,t]),t=e.o*i.a,e.ea=new Float32Array([i.r*t,i.g*t,i.b*t]),Wr(),this}}function $e(e,t){(e.mo=this).name=t,this.userData={};var r,n=[];for(r in e.layers)n.push(new Je(e.layers[r]));Object.defineProperty(this,"layers",{value:n,writable:!1}),Object.defineProperty(this,"transparent",{get:function(){return!!(2&e.flags)},set:function(t){e.flags=-3&e.flags|(t?2:0),Wr()}}),Object.defineProperty(this,"doubleSided",{get:function(){return!!(1&e.flags)},set:function(t){e.flags=-2&e.flags|(t?1:0),Wr()}}),this.update=function(){for(var t in n)n[t].update();return Wr(),this}}function tr(i){var t=void 0!==i.bb?new Koru.Box3(new U(i.bb[0],i.bb[1],i.bb[2]),new U(i.bb[3],i.bb[4],i.bb[5])):void 0;Object.defineProperty(this,"boundingBox",{value:t,writable:!1}),Object.defineProperty(this,"material",{value:i.material.mo,writable:!1});var e=new Koru.Color(0,0,0,0);Object.defineProperty(this,"highlightColor",{get:function(){return e},set:function(t){e.set(t);t=e.a;i.hc=0<t?new Float32Array([e.r*t,e.g*t,e.b*t,1-t]):void 0,Wr()}}),this.userData={},this.intersect=function(t){for(var e=i.data,r=!1,n=0;n<e.length;n++)r|=Qe(e[n],t);return r}}function er(r,t){for(;void 0===r.name;)r=r.children[0];(r.no=this).name=it(r.name),this.metadata=ot(r.metadata),this.userData={};var e=void 0!==r.bb?new Koru.Box3(new U(r.bb[0],r.bb[1],r.bb[2]),new U(r.bb[3],r.bb[4],r.bb[5])):void 0;Object.defineProperty(this,"boundingBox",{value:e,writable:!1}),Object.defineProperty(this,"parent",{value:t,writable:!1});var n=[];if(void 0!==r.children)for(var i in r.children)n.push(new er(r.children[i],this));Object.defineProperty(this,"children",{value:n,writable:!1});var o=[];if(void 0!==r.geometries)for(var i in r.geometries)o.push(new tr(r.geometries[i]));Object.defineProperty(this,"meshes",{value:o,writable:!1}),Object.defineProperty(this,"visible",{get:function(){return 1==(1&r.f)},set:function(t){t=t?1|r.f:-2&r.f;r.f!==t&&(r.f=t,Qr("visibilitychange",{koru:B,node:this}),Wr())}});var a=new Koru.Color(0,0,0,0);Object.defineProperty(this,"highlightColor",{get:function(){return a},set:function(t){for(var e in a.set(t),o)o[e].highlightColor=a}}),Object.defineProperty(this,"position",{get:function(){return r.p},set:function(t){r.p.set(t),this.updateMatrix()}}),Object.defineProperty(this,"rotation",{get:function(){return r.r},set:function(t){r.r.set(t),this.updateMatrix()}}),Object.defineProperty(this,"scale",{get:function(){return r.s},set:function(t){r.s.set(t),this.updateMatrix()}}),Object.defineProperty(this,"matrix",{value:r.tm,writable:!1}),Object.defineProperty(this,"matrixWorld",{value:r.mm,writable:!1}),this.getTransformation=function(){return{position:r.p.clone(),rotation:r.r.clone(),scale:r.s.clone()}},this.setTransformation=function(t){var e=t.position;void 0!==e&&r.p.set(e);e=t.rotation;void 0!==e&&r.r.set(e);t=t.scale;void 0!==t&&r.s.set(t),this.updateMatrix()},this.updateMatrix=function(){r.tm.setTransformation(r.p,r.r,r.s),Wr()},this.getNodesByName=function(t){var e=[];return function t(e,r,n){for(var i in e.name===n&&r.push(e),e.children)t(e.children[i],r,n)}(this,e,t),e},this.traverse=function(t){for(var e=t(this),r=this.children,n=0,i=r.length;!e&&n<i;n++)e=r[n].traverse(t);return e},this.traverseVisible=function(t){for(var e=t(this),r=this.children,n=0,i=r.length;!e&&n<i;n++){var o=r[n];!0===o.visible&&(e=o.traverseVisible(t))}return e},this.traverseAncestors=function(t){var e,r=this.parent;return e=null!==r?(e=t(r))||r.traverseAncestors(t):e},this.intersect=Xe}function rr(t,e){this.name=it(t.name),this.metadata=ot(t.metadata),this.userData={},Object.defineProperty(this,"visible",{value:1&t.flags,writable:!1}),Object.defineProperty(this,"crossfadeDuration",{value:t.crossfadeDuration,writable:!1}),Object.defineProperty(this,"duration",{value:t.duration,writable:!1}),this.apply=function(){gr(e)}}function nr(t,e){if(e&=1&t.f,t.o=e,t.p=G(t.p),t.r=G(t.r),t.s=G(t.s),t.tm=new V,t.tm.setTransformation(t.p,t.r,t.s),t.mm=new V,t.mvpm=new V,t.z|=0,void 0!==t.geometries)for(var r in t.geometries)!function(t){t.material=dt.hasOwnProperty(t.material)?dt[t.material]:null;var e,r=t.data;for(e in r.constructor!==Array&&(t.data=r=[r]),r)r[e].tbi=t.material.flags>>4&1,Pt.push([Ge,r[e]])}(t.geometries[r]);if(void 0!==t.children)for(var r in t.children)nr(t.children[r],e);var n=t.a;if(void 0!==n){var i=J("a");for(r in n)i[r]=n[r];B.viewport.appendChild(i)}}function ir(t,e){try{for(var r in e)e[r].draw(t)}catch(t){console.error(t)}}function or(t){var e,r,n,i=t.material;vt=t.hc,void 0!==t.animM?(e=t.animM.material,r=t.animM.amount,n=mt,2&i.flags?(1&i.flags&&(Y.cullFace(Y.FRONT),mt=n*(1-r),ir(t,i.layers),mt=n*r,ir(t,e.layers),Y.cullFace(Y.BACK)),mt=n*(1-r),ir(t,i.layers),mt=n*r,ir(t,e.layers)):1&i.flags?(d(Y.CULL_FACE),ir(t,i.layers),mt=n*r,ir(t,e.layers),h(Y.CULL_FACE)):(ir(t,i.layers),mt=n*r,ir(t,e.layers)),mt=n):2&i.flags?(1&i.flags&&(Y.cullFace(Y.FRONT),ir(t,i.layers),Y.cullFace(Y.BACK)),ir(t,i.layers)):1&i.flags?(d(Y.CULL_FACE),ir(t,i.layers),h(Y.CULL_FACE)):ir(t,i.layers)}function ar(t){return Math.round((.5*t+.5)*_t[0])/_t[0]*2-1}function sr(t){return Math.round((.5*t+.5)*_t[1])/_t[1]*2-1}function ur(t){var e=Vt.m;return.5*((t[0]+t[3])*e[3]-(t[3]-t[0])*Math.abs(e[3])+(t[1]+t[4])*e[7]-(t[4]-t[1])*Math.abs(e[7])+(t[2]+t[5])*e[11]-(t[5]-t[2])*Math.abs(e[11]))+e[15]}function cr(t){Kt.length=0,Wt.length=0,jt.length=0,Zt.length=0,Gt.length=0,function t(e,r){if(!(1&e.f))return;var n=(new V).mulMatrices(e.tm,r);{var i,o,a,s,u,c,l,h;void 0!==e.geometries&&(4&e.f?zt||(e.mm.set(e.tm.m),e.mvpm.set(e.tm.m),lr(e),(64&e.f?Gt:Zt).push(e)):16&e.f?zt||(s=[n.m[12],n.m[13],n.m[14]],0<(c=q(s,Bt.m))[3]&&(void 0!==e.vd?e.vo=c[3]<e.vd?Z(8-8*c[3]/e.vd,0,1):0:e.vo=1,0<e.vo&&void 0!==e.va&&(u=Math.acos((n.m[0]*kt.m[2]+n.m[1]*kt.m[6]+n.m[2]*kt.m[10])/Math.sqrt(n.m[0]*n.m[0]+n.m[1]*n.m[1]+n.m[2]*n.m[2])),e.vo*=Z(3-3*u/e.va,0,1)),0<e.vo&&(i=1/c[3],o=c[3],l=c[0]*i,h=c[1]*i,a=32&e.f?1:c[2]*i,r=l,s=h,u=1/_t[0],c=1/_t[1],l=e.ss[0],h=e.ss[1],32&e.f?(l*=u,h*=c,r+=e.so[0]*u,s+=e.so[1]*c):(l*=Lt.m[0]*i,h*=Lt.m[5]*i,r+=e.so[0]*i,s+=e.so[1]*i),r-=l*e.sa[0],s-=h*e.sa[1],32&e.f&&(r=ar(r-l)+l,s=sr(s-h)+h),(h=e.mvpm.m)[1]=h[2]=h[3]=h[4]=h[6]=h[7]=h[8]=h[9]=h[10]=h[11]=0,h[0]=u,h[5]=c,h[12]=r,h[13]=s,h[14]=a,h[15]=1,e.cd=o,(32&e.f?jt:Wt).push(e)))):(e.mm.set(n),e.mvpm.mulMatrices(n,Ht),Q(e.bb,e.mvpm.m)&&Kt.push(e)))}if(void 0!==e.children)for(var f in e.children)t(e.children[f],n)}(D.root,(new V).setIdentity());var e=D.background,r=e.anim;fr(e,r&&1===r.nextValue.mode?1-r.amount:1),r&&fr(r.nextValue,r.amount),h(N),Y.blendFunc(Y.ONE,Y.ONE_MINUS_SRC_ALPHA),hr(Gt),t&&function(){var t=D.camera.farZ;Dt.setIdentity();var e=Dt.m;e[0]=e[5]=t,e[10]=0,e[12]=Ot.x,e[13]=Ot.y,Vt.mulMatrices(Dt,Ht),mt=1,vt=void 0,e=D.floor.material,d(Y.DEPTH_TEST),h(N),d(Y.CULL_FACE),ir(D.floor,e.layers),h(Y.CULL_FACE),h(Y.DEPTH_TEST)}(),function(t){for(var e in h(Y.DEPTH_TEST),Kt){t=Kt[e];if(Dt.set(t.mm),Vt.set(t.mvpm),t.o<1)t.cd=ur(t.bb),Wt.push(t);else for(var e in mt=1,m(!!(2&t.f)^zt?_:z),t.geometries){var r=t.geometries[e];2&r.material.flags?Wt[Wt.length-1]!==t&&(t.cd=ur(t.bb),Wt.push(t)):or(r)}}}(),function(){function t(t,e){return t.z===e.z?e.cd-t.cd:t.z-e.z}Wt.sort(t),jt.sort(t);var e,r=!0,n=[];for(e in Wt){var i=Wt[e];if(mt=i.o*(i.vo||1),Dt.set(i.mm),Vt.set(i.mvpm),m(!!(2&i.f)^zt?_:z),function(t){for(var e in t)if(8&t[e].material.flags)return!0;return!1}(i.geometries)&&Xt[0]){if(p(k,pt),d(N),r)dr(Xt[0].texture),r=!1;else{var o=0;for(u in n){var a=n[u],s=function(t){var e=[2,2,-2,-2],r=t.bb;if(r)for(var n=t.node.mvpm.m,i=0;i<8;i++){var o=r[1&i?3:0],a=r[i>>1&1?4:1],s=r[i>>2?5:2],u=o*n[3]+a*n[7]+s*n[11]+n[15];u<-1||(l=(o*n[0]+a*n[4]+s*n[8]+n[12])/u,h=(o*n[1]+a*n[5]+s*n[9]+n[13])/u,e[0]=Math.min(e[0],l),e[1]=Math.min(e[1],h),e[2]=Math.max(e[2],l),e[3]=Math.max(e[3],h))}else for(var c=t.data.vertices,i=0;i<12;i+=3){var l=c[i],h=c[i+1];e[0]=Math.min(e[0],l),e[1]=Math.min(e[1],h),e[2]=Math.max(e[2],l),e[3]=Math.max(e[3],h)}return e}(a);if(s[0]=Math.max(s[0],-1),s[1]=Math.max(s[1],-1),s[2]=Math.min(s[2],1),s[3]=Math.min(s[3],1),a.r=s,!(s[0]>=s[2]||s[1]>=s[3])&&3<(o+=(s[2]-s[0])*(s[3]-s[1])))break}if(3<o)dr(Xt[0].texture);else for(var u in n)(s=n[u].r)[0]>=s[2]||s[1]>=s[3]||function(t,e,r,n){var i=Et;Y.useProgram(i.program),v(L,Mt),g(i.aP,3,Y.FLOAT,!1,12,0),T(i.aP),Y.uniform4f(i.uM,.5*(e[2]-e[0]),.5*(e[3]-e[1]),.5*(e[2]+e[0]),.5*(e[3]+e[1])),Y.uniform4f(i.uTM,.25*(r[2]-r[0]),.25*(r[3]-r[1]),.25*(r[2]+r[0])+.5,.25*(r[3]+r[1])+.5),b(i.uT,0),w(E),x(M,t),(n?de:fe)(M),Y.drawArrays(Y.TRIANGLE_FAN,0,4)}(Xt[0].texture,s,s);n.length=0}h(N),p(k,Xt[0])}for(l in i.geometries){var c=i.geometries[l];(i.o<1||2&c.material.flags)&&(or(c),r||(c.node=i,n.push(c)))}}for(e in d(Y.DEPTH_TEST),m(z),jt){var l,i=jt[e];for(l in mt=i.o*(i.vo||1),Vt.set(i.mvpm),i.geometries)or(i.geometries[l])}}(),hr(Zt),d(N)}function lr(t){var e=t.mvpm.m,r=1,n=1,i=t.w,o=t.h;8&t.f&&(r=Math.min(i*_t[1]/o,_t[0]),n=Math.min(o*_t[0]/i,_t[1]),i=o=1),e[0]*=r/_t[0],e[1]*=r/_t[1],e[4]*=n/_t[0],e[5]*=n/_t[1];r=Math.abs(e[0])*i+Math.abs(e[4])*o,n=Math.abs(e[1])*i+Math.abs(e[5])*o;e[12]=ar(e[12]-Z(t.p.x,-1,1)*r-r)+r,e[13]=sr(e[13]-Z(t.p.y,-1,1)*n-n)+n,void 0===t.ss&&(t.ss=new Float32Array([i,o]))}function hr(t){for(var e in t.sort(function(t,e){return t.z-e.z}),d(Y.DEPTH_TEST),t){var r,n=t[e];for(r in mt=n.o,Dt.set(n.mm),Vt.set(n.mvpm),n.geometries)or(n.geometries[r])}}function fr(t,e){var r,n,i,o,a=t.shader;1!==t.mode&&a.program&&Mt&&(Y.useProgram(a.program),u(a.uColor,t.color),a.uColor2&&s(a.uColor2,t.color2),a.uT&&(b(a.uT,0),w(E),xe(t.texture),t.texture.tt===M&&t.textureWM&&(c(M,A,t.textureWM[0]),c(M,F,t.textureWM[1]),c(M,P,t.textureF+O),c(M,R,t.textureF+O))),a.uIVPM&&(Ut.copy(Ht).invert(),Y.uniformMatrix4fv(a.uIVPM,!1,Ut.m)),a.uTT&&(r=D.camera.aspect,i=_t[0],o=_t[1]*r,n=ce?[i/o,1]:[1,o/i],(i=t.texture.ow||t.texture.w)<(o=(t.texture.oh||t.texture.h)*r)?n[1]*=i/o:n[0]*=o/i,u(a.uTT,new Float32Array([.5*n[0],-.5*n[1],.5,.5]))),e<1?(h(N),Y.blendFunc(Y.CONSTANT_ALPHA,Y.ONE_MINUS_CONSTANT_ALPHA),Y.blendColor(1,1,1,e)):d(N),d(Y.DEPTH_TEST),(e=t.data)?(a.uMVPM&&(Dt.setIdentity(),Dt.m[0]=Dt.m[5]=Dt.m[10]=.5*D.camera.farZ,Vt.mulMatrices(Dt,Ht),Y.uniformMatrix4fv(a.uMVPM,!1,Vt.m)),a.uEO&&l(a.uEO,t.scale),m(zt?_:z),v(L,e.vb),g(a.aP,3,Y.FLOAT,!1,12,0),T(a.aP),v(S,e.ib),Y.drawElements(Y.TRIANGLES,e.icount,Y.UNSIGNED_SHORT,0)):(d(Y.CULL_FACE),v(L,Mt),g(a.aP,3,Y.FLOAT,!1,12,0),T(a.aP),Y.drawArrays(Y.TRIANGLE_FAN,0,4),h(Y.CULL_FACE)))}function dr(t){var e=bt;Y.useProgram(e.program),v(L,Mt),g(e.aP,3,Y.FLOAT,!1,12,0),T(e.aP),b(e.uT,0),w(E),x(M,t),Y.drawArrays(Y.TRIANGLE_FAN,0,4)}function mr(t,e){var r=wt;Y.useProgram(r.program),v(L,Mt),g(r.aP,3,Y.FLOAT,!1,12,0),T(r.aP),u(r.uColor,e),b(r.uT,0),w(E),x(M,t),Y.drawArrays(Y.TRIANGLE_FAN,0,4)}function vr(t,e,r,n){var i;v(L,Mt),0<n?(i=yt,Y.useProgram(i.program),g(i.aP,3,Y.FLOAT,!1,12,0),T(i.aP),Y.uniform4f(i.uOffset,e,0,0,r),l(i.uThreshold,n)):(i=gt,Y.useProgram(i.program),g(i.aP,3,Y.FLOAT,!1,12,0),T(i.aP),Y.uniform4f(i.uOffset,e,0,0,r)),b(i.uT,0),w(E),x(M,t),de(M),Y.drawArrays(Y.TRIANGLE_FAN,0,4)}function pr(){Lt.set(St);var t=[.375,.625,.125,.875];Lt.m[8]+=(2*t[3&Rt]-1)/Y.viewportWidth,Lt.m[9]+=(2*t[Rt>>2&3]-1)/Y.viewportHeight,Ht.mulMatrices(kt,Lt),Y.viewport(0,0,Y.viewportWidth,Y.viewportHeight),m(z),h(Y.DEPTH_TEST),h(N),Y.blendFunc(Y.ONE,Y.ONE_MINUS_SRC_ALPHA);t=null!=D.floor&&0<Ot.z;if(Xt[0]&&(t&&4&D.floor.material.flags&&Xt[2]&&function(){p(k,Xt[0]),Y.clear(Y.COLOR_BUFFER_BIT|Y.DEPTH_BUFFER_BIT);var t=Ht.clone(),e=Bt.clone(),r=Ot.clone(),n=Nt.clone();n.m[2]*=-1,n.m[6]*=-1,n.m[10]*=-1,n.m[14]*=-1,Ot.z*=-1,n.invert(),Ht.mulMatrices(n,Lt),Bt.mulMatrices(n,St),zt=!0,cr(),Ot.set(r),Ht.set(t),Bt.set(e),zt=!1,p(k,Xt[2]),Y.viewport(0,0,Xt[2].w,Xt[2].h),dr(Xt[0].texture)}(),p(k,Xt[0]),Y.viewport(0,0,Xt[0].w,Xt[0].h),Y.clear(Y.COLOR_BUFFER_BIT|Y.DEPTH_BUFFER_BIT)),cr(t),Xt[0]){if(d(Y.DEPTH_TEST),p(k,Xt[1]),Y.viewport(0,0,Xt[1].w,Xt[1].h),h(N),Y.blendFunc(Y.CONSTANT_ALPHA,Y.ONE_MINUS_CONSTANT_ALPHA),Y.blendColor(1,1,1,1/(Rt+1)),mr(Xt[0].texture,new Float32Array([1,1,1,1])),0===Rt&&null!=D.glow)for(var e=[1/Y.viewportWidth,1/Y.viewportHeight],r=0,n=2,i=0;r<5;r++)p(k,Xt[n]),Y.viewport(0,0,Xt[n].w,Xt[n].h),vr(Xt[i].texture,e[0],e[1],0===r?D.glow.threshold:0),i=n++,e[0]*=1.4142,e[1]*=1.4142,p(k,Xt[n]),Y.viewport(0,0,Xt[n].w,Xt[n].h),vr(Xt[i].texture,e[0],e[1],0),i=0===r?n--:n++,e[0]*=1.4142,e[1]*=1.4142;p(k,null),Y.viewport(0,0,Y.viewportWidth,Y.viewportHeight),d(N),null!=D.glow?(t=j(1,D.glow.threshold,Math.min(D.glow.level,1)),mr(Xt[1].texture,new Float32Array([t,t,t,1])),h(N),Y.blendFuncSeparate(Y.ONE,Y.ONE,Y.ZERO,Y.ONE),function(t,e){var r=Tt;Y.useProgram(r.program),v(L,Mt),g(r.aP,3,Y.FLOAT,!1,12,0),T(r.aP);for(var n=0;n<4;n++)b(r["uT"+(n+1)],n),w(E+n),x(M,t[n]),de(M);l(r.uLevel,e),Y.drawArrays(Y.TRIANGLE_FAN,0,4),w(E)}([Xt[3].texture,Xt[5].texture,Xt[7].texture,Xt[9].texture],D.glow.level),d(N)):dr(Xt[1].texture)}}function yr(t,e,r){var n,i,o,a;if(e.nodes.hasOwnProperty(t.id)?(n=e.nodes[t.id],4&e.flags&&(!t.animT&&t.p.equals(n.p)&&t.r.equals(n.r)&&t.s.equals(n.s)||le.add(new ht(t,n,e.crossfadeDuration,e.crossfadeExp))),8&e.flags&&(r&=1&n.f,(t.animV||(1&t.f)!=(1&n.f)||0<t.o&&!r||t.o<1&&r)&&le.add(new ft(t,n,r,e.crossfadeDuration,e.crossfadeExp)))):(0<t.o&&!r||t.o<1&&r)&&le.add(new ft(t,t,r,e.crossfadeDuration,e.crossfadeExp)),16&e.flags&&void 0!==t.geometries)for(var s in t.geometries)i=t.geometries[s],a=void 0,(o=e).geometries.hasOwnProperty(i.id)&&(a=o.geometries[i.id].m,dt.hasOwnProperty(a)&&(a=dt[a],!i.animM&&i.material===a||le.add(new ct(i,a,o.crossfadeDuration,o.crossfadeExp))));if(void 0!==t.children)for(var s in t.children)yr(t.children[s],e,r)}function gr(t){var e;Jt=null,"number"==typeof t&&0<=t&&t<D.snapshots.length&&(null!==Qt&&Qr("snapshotfinish",{koru:B,snapshot:Qt}),Qt=D.snapshots[t]||null,Jt=Qt.next,At=Qt.crossfadeDuration||0,Ft=At+(Qt.duration||0),e=Qt.crossfadeExp||1,Qr("snapshotstart",{koru:B,index:t,snapshot:Qt}),null!=Qt.camera&&le.add(new lt(D.camera,Qt.camera,At,e)),null!=Qt.environment&&le.add(new ut(D,"environment",Qt.environment,At,e)),null!=Qt.background&&le.add(new ut(D,"background",Qt.background,At,e)),yr(D.root,Qt,1),null!=D.shadow&&null!=Qt.shadow&&le.add(new st(D.shadow,Qt.shadow,At,e)),null!=D.lightmap&&null!=Qt.lightmap&&le.add(new st(D.lightmap,Qt.lightmap,At,e)),Wr())}var Tr=0,wr=0,xr=0,br=0;function Er(t){Qr("update",{koru:B,deltaTime:t,idleTime:wr,userIdleTime:xr,cameraIdleTime:D.camera.idleTime}),0<le.size&&Wr(),function(e){for(var t in le.forEach(function(t){t.update(e)?t.apply():(t.finish(),he.push(t))}),he)le.delete(he[t]);he.length=0}(t),null!=At&&(At-=t)<=0&&(At=void 0,Qr("snapshotready",{koru:B,snapshot:Qt})),null!=Ft&&(Ft-=t)<=0&&(Ft=void 0,null!=Jt?gr(Jt):null!==Qt&&(Qr("snapshotfinish",{koru:B,snapshot:Qt}),Qt=null))}var Mr=[0,0],Ar=[0,0],Fr=[0,0],Pr=[0,0,1],Rr=null,Or={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN_ZOOM:4,CLICK:5},Cr=Or.NONE;function zr(t){var e,r=t.target.getBoundingClientRect(),n=(t.clientX-r.left)/r.width*2-1,i=(r.bottom-t.clientY)/r.height*2-1;for(e in qt)for(var o=qt[e],a=o.length-1;0<=a;a--){var s=o[a],u=s.mvpm.m,c=u[0]*s.ss[0],l=u[5]*s.ss[1];if((null!=s.snapshot||s.url)&&n>=u[12]-c&&n<=u[12]+c&&i>=u[13]-l&&i<=u[13]+l)return s}return null}function _r(t){var e=zr(t);t.target.style.cursor=null!==e?"pointer":"default"}function Nr(t){var e;B.interactive&&(Rr=zr(t),e=D.camera.flags,0===t.button&&null!==Rr?Cr=Or.CLICK:0===t.button&&1&e?(Cr=Or.ROTATE,Mr=[t.clientX,t.clientY]):1===t.button&&2&e?(Cr=Or.ZOOM,Fr=[t.clientX,t.clientY]):2===t.button&&4&e&&(Cr=Or.PAN,Ar=[t.clientX,t.clientY]),Cr!==Or.NONE&&(t.preventDefault(),window.addEventListener("mousemove",kr,!1),window.addEventListener("mouseup",Lr,!1)))}function kr(t){switch(t.preventDefault(),Cr){case Or.ROTATE:Ur(t.clientX-Mr[0],t.clientY-Mr[1]),Mr=[t.clientX,t.clientY];break;case Or.ZOOM:Yr(.1*(Fr[1]-t.clientY)),Fr=[t.clientX,t.clientY];break;case Or.PAN:Vr(t.clientX-Ar[0],t.clientY-Ar[1]),Ar=[t.clientX,t.clientY];break;default:return}}function e(t){null!==t&&(null!=t.snapshot?gr(t.snapshot):t.url&&window.open(t.url,t.lt))}function Lr(t){t.preventDefault(),Cr===Or.CLICK&&e(Rr),Cr=Or.NONE,window.removeEventListener("mousemove",kr,!1),window.removeEventListener("mouseup",Lr,!1)}function Sr(t){if("scale"in t)return t.scale;var e=t.touches[1].clientX-t.touches[0].clientX,t=t.touches[1].clientY-t.touches[0].clientY;return Math.sqrt(e*e+t*t)}function Dr(t){var e,r;B.interactive&&(r=D.camera.flags,e=t.touches[0],null!==(Rr=1===t.touches.length?zr(e):null)?Cr=Or.CLICK:1===t.touches.length&&1&r?(Cr=Or.TOUCH_ROTATE,Pr=[e.clientX,e.clientY,t.scale]):2===t.touches.length&&6&r?(r=t.touches[1],Cr=Or.TOUCH_PAN_ZOOM,Pr=[.5*(e.clientX+r.clientX),.5*(e.clientY+r.clientY),Sr(t)]):Cr=Or.NONE,Cr!==Or.NONE&&(t.preventDefault(),window.addEventListener("touchmove",Ir,!1),window.addEventListener("touchend",Hr,!1)))}function Ir(t){var e,r;t.preventDefault(),1===t.touches.length?(r=[t.touches[0].clientX,t.touches[0].clientY,t.scale],Cr===Or.TOUCH_ROTATE?Ur(r[0]-Pr[0],r[1]-Pr[1]):Cr=Or.TOUCH_ROTATE,Pr=r):2===t.touches.length&&(e=Sr(t),r=[.5*(t.touches[0].clientX+t.touches[1].clientX),.5*(t.touches[0].clientY+t.touches[1].clientY),e],Cr===Or.TOUCH_PAN_ZOOM?(2&(t=D.camera).flags&&(Wr(),t.dist=Z(t.dist*Pr[2]/e,t.nearZ,.5*t.farZ)),Vr(r[0]-Pr[0],r[1]-Pr[1])):Cr=Or.TOUCH_PAN_ZOOM,Pr=r)}function Hr(t){t.preventDefault(),Cr===Or.CLICK&&e(Rr),Cr=Or.NONE,0===t.touches.length&&(window.removeEventListener("touchmove",Ir,!1),window.removeEventListener("touchend",Hr,!1))}function Br(t,e){return t-Math.floor(t/e)*e}function Ur(t,e){var r,n=D.camera;1&n.flags&&(Wr(),r=.5*(null!=n.sensitivity?n.sensitivity:1),(t=Br(n.rotation.z-t*r,360))<0&&(t+=360),n.minYaw<n.maxYaw?(t<n.minYaw||t>n.maxYaw)&&(t=Br(n.minYaw+360-t,360)<.5*(360-n.maxYaw+n.minYaw)?n.minYaw:n.maxYaw):t>n.maxYaw&&t<n.minYaw&&(t=t>.5*(n.minYaw+n.maxYaw)?n.minYaw:n.maxYaw),n.rotation.z=t,n.rotation.y=Z(n.rotation.y+e*r,n.minPitch,n.maxPitch),n.rotation.y=Z(n.rotation.y,-89.99,89.99),n.idleTime=xr=wr=0)}function Vr(t,e){var r,n,i=D.camera;4&i.flags&&(Wr(),n=Nt.m,r=new U(n[0],n[1],n[2]),n=new U(n[4],n[5],n[6]),r.mul(t*i.dist*-2/(Lt.m[0]*_t[0])),n.mul(e*i.dist*2/(Lt.m[5]*_t[1])),i.target.add(r).add(n),i.idleTime=xr=wr=0)}function Yr(t){var e,r=D.camera;2&r.flags&&(Wr(),e=Math.pow(1.03,Math.abs(t)),e=t<0?r.dist/e:r.dist*e,Math.abs(e-r.dist)<Math.abs(.5*t)&&(e=r.dist+.5*t),r.dist=Z(e,r.minDistance,Math.min(r.maxDistance,.5*r.farZ)),r.idleTime=xr=wr=0)}function Kr(t){B.interactive&&2&D.camera.flags&&(t.preventDefault(),Yr((D.invertWheel?t.deltaY:-t.deltaY)*[.01,.5,1][t.deltaMode]))}function Wr(t){Rt=0,br=Math.min(t||1,16)}function jr(){requestAnimFrame(jr);var t=(new Date).getTime(),e=0!==Tr?.001*(t-Tr):0;Tr=t,(Cr!==Or.NONE||0<le.size)&&(wr=0);try{Er(e)}catch(t){console.error(t)}if(!function(t){var e,r=D.camera,n=r.idleAnimation;switch(n&&(r.idleTime>n.delay?(e=(e=r.idleTime-n.delay)<1?e*e*.5:e-.5,r.rotation.z=n.startAngle+e*n.speed,Wr(3)):n.startAngle=r.rotation.z),r.idleTime+=t,r.q?(null!=D.floor&&(r.target.z=Math.max(r.target.z,2*r.nearZ)),Nt.setFromQuaternion(r.q)):(null!=D.floor&&D.floor.obstacle&&(r.target.z=Math.max(r.target.z,2*r.nearZ),r.rotation.y<0&&0<r.dist&&(r.rotation.y=Math.max(r.rotation.y,o(Math.asin(Math.max((2*r.nearZ-r.target.z)/r.dist,-1)))))),Nt.setIdentity(),Nt.setRotation(r.rotation)),Ot.set(Nt.m).mul(r.dist).add(r.target),Nt.setPosition(Ot),Nt.mulMatrices(Yt,Nt),kt.invert(Nt),D.viewportMode){case 0:ce=_t[0]>_t[1]*r.aspect;break;case 1:ce=_t[0]<_t[1]*r.aspect;break;case 2:ce=!0;break;case 3:ce=!1}var i,t=r.nearZ*Math.tan(.5*K(r.fov));ce?i=t*_t[0]/_t[1]:t=(i=t*r.aspect)*_t[1]/_t[0],St.setFrustum(-i,i,-t,t,r.nearZ,r.farZ),Bt.mulMatrices(kt,St),Ct[3]=0<=Ot.z?0:r.nearZ}(e),wr+=e,xr+=e,Rt<(Xt[0]?16:1)){do{try{pr()}catch(t){console.error(t)}}while(++Rt<br);br=1}}function Zr(t,e){var r,n;(D=JSON.parse(t)).version===B.version?(function(){for(var t in D.textures)Pt.push([be,D.textures[t]])}(),dt=D.materialsDict,Pt.push([Ae]),Pt.push([Fe]),function(){for(var t in dt){var e,r=dt[t];for(e in r.flags=0|r.flags,r.layers)Pt.push([Be,r.layers[e]])}}(),nr(D.root,1),(t=B.canvas).addEventListener("touchstart",Dr,!1),t.addEventListener("mousedown",Nr,!1),t.addEventListener("wheel",Kr,!1),t.parentElement.addEventListener("contextmenu",function(t){B.interactive&&t.preventDefault()},!1),t.addEventListener("mousemove",_r,!1),Pt.push([function(){var e={};D.materials.forEach(function(t){e[t]=new $e(dt[t],t)}),Object.defineProperty(B,"materials",{value:e,writable:!1}),Object.defineProperty(B,"root",{value:new er(D.root,null),writable:!1}),Object.defineProperty(B,"camera",{value:new qe(D.camera),writable:!1});var r=[];"snapshots"in D&&(D.snapshots.forEach(function(t,e){r.push(new rr(t,e))}),"startSnapshot"in D&&(Jt=D.startSnapshot,Ft=D.snapshotDelay)),Object.defineProperty(B,"snapshots",{value:r,writable:!1})}]),r=setInterval(function(){if(n<Pt.length){var t=Pt[n];try{t[0](t[1])}catch(t){console.error(t)}}else clearInterval(r),jr();$r(j(e,1,n/Pt.length)),n++},1),n=0):qr(2,D.version)}function Gr(t,e){var r=t.getElementsByClassName(e);if(0<r.length){for(var n=0;n<r.length;n++)r[n].style.display="block";return 1}}function qr(t,e){var r,n=B.viewport;switch(t){case 0:if(Gr(n,"koru-error koru-error-no-webgl"))return;r='<div class="koru-error koru-error-no-webgl"><div class="koru-error-container"><div class="koru-error-container-text"><div class="koru-error-container-h1">Unable to initialize WebGL</div><div class="koru-error-container-h2">Looks like your browser does not support it.</div><div class="koru-error-container-h3"><a href="http://boxshot.com/koru/">Koru</a> needs WebGL to display graphics, so please consider upgrading your browser or graphics driver to support WebGL.</div></div></div></div>';break;case 1:if(Gr(n,"koru-error koru-error-file-loading"))return;r='<div class="koru-error koru-error-file-loading"><div class="koru-error-container"><div class="koru-error-container-text"><div class="koru-error-container-h1">Unable to load data</div><div class="koru-error-container-h2"></div><div class="koru-error-container-h3">',null===n.getAttribute("data-scene")?r+="Please make sure you didn't modify the exported file":r+="Please make sure you properly uploaded all the exported files to server",r+="</div></div></div></div>";break;case 2:if(Gr(n,"koru-error koru-error-version"))return;r='<div class="koru-error koru-error-version"><div class="koru-error-container"><div class="koru-error-container-text"><div class="koru-error-container-h1">Version mismatch, please use koru.js version '+e+'</div><div class="koru-error-container-h2"></div><div class="koru-error-container-h3"></div></div></div></div>'}t=J("div");t.innerHTML=r,n.insertBefore(t,n.firstChild)}this.invalidate=Wr,this.draw=function(t){Wr(t),jr()};var Xr={};function Qr(t,e){t.startsWith("snapshot")&&console.log("dispatchEvent",t,e);var r=Xr[t];if(null!=r)for(var n in r)try{r[n](e)}catch(t){console.error(t)}}function Jr(){var t=J("ul");t.className="koru-ul";var e,r="koru-fadeIn",n=function(t){if(null!=document.styleSheets){var e,r=document.styleSheets;for(e in r)try{var n,i=r[e].rules||r[e].cssRules;for(n in i)if(i[n].name===t)return!0}catch(t){return!1}}return!1}(r),i=[];for(e in B.snapshots){var o,a,s=B.snapshots[e];s.visible&&((o=J("li")).className="koru-li",(a=J("button")).className="koru-button",n&&(a.style.opacity=0,a.style.animation=r+" 2s ease "+(.1*e+1)+"s",a.style.animationFillMode="forwards"),a.snapshot=s,a.onclick=function(t){this.snapshot.apply()},a.innerHTML=a.title=s.name,o.appendChild(a),t.appendChild(o),i.push(a))}B.viewport.insertBefore(t,B.canvas)}function $r(t){var e,r=B.showProgressBar?B.viewport.getElementsByClassName("koru-progressIndicator")[0]:void 0;r&&(r.style.width=100*t+"%"),0===t&&(Qr("loadstart",{koru:B}),r&&((e=r.parentElement).style.transition="opacity 0.5s ease",e.style.opacity=1)),Qr("progress",{koru:B,progress:t}),1===t&&(Qr("loadend",{koru:B}),r&&((e=r.parentElement).style.transition="opacity 0.5s ease",e.style.opacity=0,setTimeout(function(){e.parentElement.removeChild(e)},500)),B.canvas.style.transition="opacity 2s ease",B.canvas.style.opacity=1,B.createSnapshotButtons&&Jr())}this.addEventListener=function(t,e){var r=Xr[t.toLowerCase()];if(void 0===r)Xr[t]=r=[];else if(0<=r.indexOf(e))return;r.push(e)},this.removeEventListener=function(t,e){t=Xr[t.toLowerCase()];null==t||0<=(e=t.indexOf(e))&&t.splice(e,1)},this.init=function(t,e){if((this.viewport=t).koru=this,null!=window.koruInit&&koruInit(this),function(t){var e,r=t.viewport;t.showProgressBar&&((n=J("div")).className="koru-progressBar",n.style.opacity=0,(e=J("div")).className="koru-progressIndicator",n.appendChild(e),r.appendChild(n));var n=J("canvas");n.className="koru-canvas",n.style.opacity=0,n.style.imageRendering="pixelated",r.appendChild(n),t.canvas=n,(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)&&((n=J("div")).innerHTML='<svg xmlns="http://www.w3.org/2000/svg" class="koru-fullscreen koru-fullscreen-on"><g class="koru-fullscreen-on-group"><path class="inside" d="M17.5,29.5v-5h7v-7h5v12Zm-15,0v-12h5v7h7v5Zm22-15v-7h-7v-5h12v12Zm-22,0V2.5h12v5h-7v7Z"/><path class="border" d="M29,3V14H25V7H18V3H29M14,3V7H7v7H3V3H14M7,18v7h7v4H3V18H7m22,0V29H18V25h7V18h4M30,2H17V8h7v7h6V2ZM15,2H2V15H8V8h7V2ZM8,17H2V30H15V24H8V17Zm22,0H24v7H17v6H30V17Z"/></g><g class="koru-fullscreen-off-group"><path class="inside" d="M17.5,29.5v-12h12v5h-7v7Zm-8,0v-7h-7v-5h12v12Zm-7-15v-5h7v-7h5v12Zm15,0V2.5h5v7h7v5Z"/><path class="border" d="M22,3v7h7v4H18V3h4M14,3V14H3V10h7V3h4M29,18v4H22v7H18V18H29M14,18V29H10V22H3V18H14M23,2H17V15H30V9H23V2ZM15,2H9V9H2v6H15V2ZM30,17H17V30h6V23h7V17ZM15,17H2v6H9v7h6V17Z"/></g></svg>',n.onclick=function(){t.toggleFullscreenMode(this.firstChild)},r.appendChild(n))}(this),function(e){_t=[e.viewport.clientWidth,e.viewport.clientHeight];var t=e.canvas,r=e.supportHighDPI&&window.devicePixelRatio||1;console.log("initGL: "+_t[0]+"x"+_t[1]),t.width=_t[0]*r|0,t.height=_t[1]*r|0,t.style.width="100%",t.style.height="100%";try{Y=t.getContext("webgl")||t.getContext("experimental-webgl")}catch(t){return void console.error(t)}return Y&&(h=Y.enable.bind(Y),d=Y.disable.bind(Y),m=Y.frontFace.bind(Y),v=Y.bindBuffer.bind(Y),p=Y.bindFramebuffer.bind(Y),y=Y.bufferData.bind(Y),g=Y.vertexAttribPointer.bind(Y),T=Y.enableVertexAttribArray.bind(Y),a=Y.disableVertexAttribArray.bind(Y),w=Y.activeTexture.bind(Y),x=Y.bindTexture.bind(Y),c=Y.texParameteri.bind(Y),b=Y.uniform1i.bind(Y),l=Y.uniform1f.bind(Y),s=Y.uniform3fv.bind(Y),u=Y.uniform4fv.bind(Y),E=Y.TEXTURE0,M=Y.TEXTURE_2D,A=Y.TEXTURE_WRAP_S,F=Y.TEXTURE_WRAP_T,P=Y.TEXTURE_MIN_FILTER,R=Y.TEXTURE_MAG_FILTER,O=Y.NEAREST,C=Y.LINEAR,z=Y.CW,_=Y.CCW,N=Y.BLEND,k=Y.FRAMEBUFFER,L=Y.ARRAY_BUFFER,S=Y.ELEMENT_ARRAY_BUFFER,n=[O,C,Y.LINEAR_MIPMAP_LINEAR],Y.viewportWidth=t.width,Y.viewportHeight=t.height,console.log("User-Agent:",navigator.userAgent),console.log("GL Extensions:",Y.getSupportedExtensions()),$t=Y.getExtension("OES_texture_float"),te=Y.getExtension("OES_texture_float_linear"),ee=Y.getExtension("OES_texture_half_float"),re=Y.getExtension("OES_texture_half_float_linear"),ne=Y.getExtension("WEBGL_color_buffer_float"),ie=Y.getExtension("EXT_color_buffer_half_float"),oe=Y.getParameter(Y.MAX_TEXTURE_SIZE),ae=!!$t&&!!te,ye(_t[0],_t[1],e.supportHighDPI),window.addEventListener("resize",function(t){ge(e)}),Y.clearColor(0,0,0,0),h(Y.DEPTH_TEST),h(Y.CULL_FACE),Y.depthFunc(Y.LEQUAL),Y.blendFunc(Y.ONE,Y.ONE_MINUS_SRC_ALPHA),1)}(this)){if(e.constructor===Array){var r=$(rt(e[0]));return I=e[1],H=e[2],void Zr(r,0)}console.log(e),this.fileName=e;r=new XMLHttpRequest;r.onload=function(t){var e,r=new Uint32Array(this.response,0,2);r[0]+r[1]+8===this.response.byteLength?(e=$(new Zlib.Inflate(new Uint8Array(this.response,8,r[0])).decompress()),I=$(new Uint8Array(this.response,8+r[0],r[1])),Zr(e,.5)):qr(1)},r.onerror=function(t){qr(1)},$r(0),r.onprogress=function(t){$r(.5*t.loaded/t.total)},r.open("GET",e),r.responseType="arraybuffer",r.send()}else qr(0)},this.toggleFullscreenMode=function(r){var n,t,i;function o(t,e,r){for(var n="",i=t.getAttribute("class").split(" "),o=0;o<i.length;o++)i[o]!==e&&(n+=i[o]+" ");""!==r&&(n+=r),t.setAttribute("class",n)}(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)&&(t=(n=this).viewport,document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement?document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen():(t.requestFullscreen?(t.requestFullscreen(),i="fullscreenchange"):t.webkitRequestFullscreen?(t.webkitRequestFullscreen(),i="webkitfullscreenchange"):t.mozRequestFullScreen?(t.mozRequestFullScreen(),i="mozfullscreenchange"):t.msRequestFullscreen&&(t.msRequestFullscreen(),i="MSFullscreenChange"),document.addEventListener(i,function t(e){ge(n),setTimeout(function(){ge(n)},100),document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||(document.removeEventListener(i,t,!1),o(r,"koru-fullscreen-off","koru-fullscreen-on"))},!1),o(r,"koru-fullscreen-on","koru-fullscreen-off")))}},function(){"use strict";var t=Koru.Vec3.prototype;t.multiply=t.mul,t.divide=t.div;t=Koru.Mat4.prototype;t.multiply=t.mul,t.multiplyMatrices=t.mulMatrices,window.addEventListener("load",function(t){for(var e=document.body.getElementsByClassName("koru-viewport"),r=0;r<e.length;r++){var n=e[r],i=n.getAttribute("data-scene");null===i?koruCreate(n):(new Koru.Viewport).init(n,i)}});t=document.createElement("style");document.head.appendChild(t);var e=t.sheet,r=0;function n(t){if(null!=document.styleSheets){var e,r=document.styleSheets;for(e in r)try{var n,i=r[e].rules||r[e].cssRules;for(n in i)if(i[n].selectorText===t)return 1}catch(t){if("SecurityError"!==t.name)throw t}}}function i(t){try{e.insertRule(t,r),r++}catch(t){console.error(t)}}n(".koru-viewport")||i(".koru-viewport {background:radial-gradient(#ccc,#222);width:100%;height:100%;margin:auto;position:relative;touch-action:none;}"),n(".koru-canvas")||i(".koru-canvas {position:absolute;left:0;top:0;}"),n(".koru-button")||(i(".koru-button {min-width:100px;max-width:250px;width:100%;height:24px;background:rgba(0,0,0,.3);color:#fff;text-shadow:1px 1px 4px #000;border:2px solid rgba(255,255,255,.7);border-radius:12px;font-size:12px;z-index:2;position:relative;margin:2px;padding:0 8px 0 8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer;}"),i(".koru-button:hover {background:rgba(0,0,0,.5);border-color:#fff;}"),i(".koru-button:focus {outline:0 !important;}"),i("@keyframes koru-fadeIn {0% {opacity:0;} 100% {opacity:1;}}")),n(".koru-ul")||i(".koru-ul {left:8px;top:8px;margin:0;padding:0;list-style:none;position:absolute;z-index:2;}"),n(".koru-error")||(i(".koru-error {width:100%;height:100%;position:absolute;z-index:1;}"),i(".koru-error-container {display:table;color:#FFF;font-family:Verdana, Helvetica, Arial, Serif;background-color:#3777bc;height:100%;width:100%;}"),i(".koru-error-container .koru-error-container-text {display:table-cell;vertical-align:middle;text-align:center;}"),i(".koru-error-container a {color:#fff;}"),i(".koru-error-container .koru-error-container-text .koru-error-container-h1 {font-size:32pt;font-weight:bold;}"),i(".koru-error-container .koru-error-container-text .koru-error-container-h2 {font-size:20pt;}"),i(".koru-error-container .koru-error-container-text .koru-error-container-h3 {margin-top:50px;font-size:14pt;}")),n(".koru-progressBar")||i(".koru-progressBar {position:absolute;width:100%;height:6px;background-color:rgba(0, 0, 0, 0.3);}"),n(".koru-progressIndicator")||i(".koru-progressIndicator {position:absolute;width:0%;height:100%;background:linear-gradient(to right, #222, #3777bc);}"),n(".koru-fullscreen")||(i(".koru-fullscreen {width:32px;height:32px;position:absolute;right:10px;top:10px;cursor:pointer;}"),i(".koru-fullscreen .inside {fill:#ddd;}"),i(".koru-fullscreen .border {fill:#666;}"),i(".koru-fullscreen:hover .inside {fill:#fff;}"),i(".koru-fullscreen:active {transform:scale(0.95, 0.95);}"),i(".koru-fullscreen-on .koru-fullscreen-on-group, .koru-fullscreen-off .koru-fullscreen-off-group {display:inline-block;}"),i(".koru-fullscreen-on .koru-fullscreen-off-group, .koru-fullscreen-off .koru-fullscreen-on-group {display:none;}"))}.call(this);
/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */(function() {'use strict';var m=this;function q(c,d){var a=c.split("."),b=m;!(a[0]in b)&&b.execScript&&b.execScript("var "+a[0]);for(var e;a.length&&(e=a.shift());)!a.length&&void 0!==d?b[e]=d:b=b[e]?b[e]:b[e]={}};var s="undefined"!==typeof Uint8Array&&"undefined"!==typeof Uint16Array&&"undefined"!==typeof Uint32Array&&"undefined"!==typeof DataView;function t(c){var d=c.length,a=0,b=Number.POSITIVE_INFINITY,e,f,g,h,k,l,p,n,r,K;for(n=0;n<d;++n)c[n]>a&&(a=c[n]),c[n]<b&&(b=c[n]);e=1<<a;f=new (s?Uint32Array:Array)(e);g=1;h=0;for(k=2;g<=a;){for(n=0;n<d;++n)if(c[n]===g){l=0;p=h;for(r=0;r<g;++r)l=l<<1|p&1,p>>=1;K=g<<16|n;for(r=l;r<e;r+=k)f[r]=K;++h}++g;h<<=1;k<<=1}return[f,a,b]};function u(c,d){this.g=[];this.h=32768;this.d=this.f=this.a=this.l=0;this.input=s?new Uint8Array(c):c;this.m=!1;this.i=v;this.s=!1;if(d||!(d={}))d.index&&(this.a=d.index),d.bufferSize&&(this.h=d.bufferSize),d.bufferType&&(this.i=d.bufferType),d.resize&&(this.s=d.resize);switch(this.i){case w:this.b=32768;this.c=new (s?Uint8Array:Array)(32768+this.h+258);break;case v:this.b=0;this.c=new (s?Uint8Array:Array)(this.h);this.e=this.A;this.n=this.w;this.j=this.z;break;default:throw Error("invalid inflate mode");
}}var w=0,v=1,x={u:w,t:v};
u.prototype.k=function(){for(;!this.m;){var c=y(this,3);c&1&&(this.m=!0);c>>>=1;switch(c){case 0:var d=this.input,a=this.a,b=this.c,e=this.b,f=d.length,g=void 0,h=void 0,k=b.length,l=void 0;this.d=this.f=0;if(a+1>=f)throw Error("invalid uncompressed block header: LEN");g=d[a++]|d[a++]<<8;if(a+1>=f)throw Error("invalid uncompressed block header: NLEN");h=d[a++]|d[a++]<<8;if(g===~h)throw Error("invalid uncompressed block header: length verify");if(a+g>d.length)throw Error("input buffer is broken");switch(this.i){case w:for(;e+
g>b.length;){l=k-e;g-=l;if(s)b.set(d.subarray(a,a+l),e),e+=l,a+=l;else for(;l--;)b[e++]=d[a++];this.b=e;b=this.e();e=this.b}break;case v:for(;e+g>b.length;)b=this.e({p:2});break;default:throw Error("invalid inflate mode");}if(s)b.set(d.subarray(a,a+g),e),e+=g,a+=g;else for(;g--;)b[e++]=d[a++];this.a=a;this.b=e;this.c=b;break;case 1:this.j(z,A);break;case 2:B(this);break;default:throw Error("unknown BTYPE: "+c);}}return this.n()};
var C=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],D=s?new Uint16Array(C):C,E=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],F=s?new Uint16Array(E):E,G=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],H=s?new Uint8Array(G):G,I=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],J=s?new Uint16Array(I):I,L=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,
13],M=s?new Uint8Array(L):L,N=new (s?Uint8Array:Array)(288),O,P;O=0;for(P=N.length;O<P;++O)N[O]=143>=O?8:255>=O?9:279>=O?7:8;var z=t(N),Q=new (s?Uint8Array:Array)(30),R,S;R=0;for(S=Q.length;R<S;++R)Q[R]=5;var A=t(Q);function y(c,d){for(var a=c.f,b=c.d,e=c.input,f=c.a,g=e.length,h;b<d;){if(f>=g)throw Error("input buffer is broken");a|=e[f++]<<b;b+=8}h=a&(1<<d)-1;c.f=a>>>d;c.d=b-d;c.a=f;return h}
function T(c,d){for(var a=c.f,b=c.d,e=c.input,f=c.a,g=e.length,h=d[0],k=d[1],l,p;b<k&&!(f>=g);)a|=e[f++]<<b,b+=8;l=h[a&(1<<k)-1];p=l>>>16;c.f=a>>p;c.d=b-p;c.a=f;return l&65535}
function B(c){function d(a,c,b){var d,e=this.q,f,g;for(g=0;g<a;)switch(d=T(this,c),d){case 16:for(f=3+y(this,2);f--;)b[g++]=e;break;case 17:for(f=3+y(this,3);f--;)b[g++]=0;e=0;break;case 18:for(f=11+y(this,7);f--;)b[g++]=0;e=0;break;default:e=b[g++]=d}this.q=e;return b}var a=y(c,5)+257,b=y(c,5)+1,e=y(c,4)+4,f=new (s?Uint8Array:Array)(D.length),g,h,k,l;for(l=0;l<e;++l)f[D[l]]=y(c,3);if(!s){l=e;for(e=f.length;l<e;++l)f[D[l]]=0}g=t(f);h=new (s?Uint8Array:Array)(a);k=new (s?Uint8Array:Array)(b);c.q=0;
c.j(t(d.call(c,a,g,h)),t(d.call(c,b,g,k)))}u.prototype.j=function(c,d){var a=this.c,b=this.b;this.o=c;for(var e=a.length-258,f,g,h,k;256!==(f=T(this,c));)if(256>f)b>=e&&(this.b=b,a=this.e(),b=this.b),a[b++]=f;else{g=f-257;k=F[g];0<H[g]&&(k+=y(this,H[g]));f=T(this,d);h=J[f];0<M[f]&&(h+=y(this,M[f]));b>=e&&(this.b=b,a=this.e(),b=this.b);for(;k--;)a[b]=a[b++-h]}for(;8<=this.d;)this.d-=8,this.a--;this.b=b};
u.prototype.z=function(c,d){var a=this.c,b=this.b;this.o=c;for(var e=a.length,f,g,h,k;256!==(f=T(this,c));)if(256>f)b>=e&&(a=this.e(),e=a.length),a[b++]=f;else{g=f-257;k=F[g];0<H[g]&&(k+=y(this,H[g]));f=T(this,d);h=J[f];0<M[f]&&(h+=y(this,M[f]));b+k>e&&(a=this.e(),e=a.length);for(;k--;)a[b]=a[b++-h]}for(;8<=this.d;)this.d-=8,this.a--;this.b=b};
u.prototype.e=function(){var c=new (s?Uint8Array:Array)(this.b-32768),d=this.b-32768,a,b,e=this.c;if(s)c.set(e.subarray(32768,c.length));else{a=0;for(b=c.length;a<b;++a)c[a]=e[a+32768]}this.g.push(c);this.l+=c.length;if(s)e.set(e.subarray(d,d+32768));else for(a=0;32768>a;++a)e[a]=e[d+a];this.b=32768;return e};
u.prototype.A=function(c){var d,a=this.input.length/this.a+1|0,b,e,f,g=this.input,h=this.c;c&&("number"===typeof c.p&&(a=c.p),"number"===typeof c.v&&(a+=c.v));2>a?(b=(g.length-this.a)/this.o[2],f=258*(b/2)|0,e=f<h.length?h.length+f:h.length<<1):e=h.length*a;s?(d=new Uint8Array(e),d.set(h)):d=h;return this.c=d};
u.prototype.n=function(){var c=0,d=this.c,a=this.g,b,e=new (s?Uint8Array:Array)(this.l+(this.b-32768)),f,g,h,k;if(0===a.length)return s?this.c.subarray(32768,this.b):this.c.slice(32768,this.b);f=0;for(g=a.length;f<g;++f){b=a[f];h=0;for(k=b.length;h<k;++h)e[c++]=b[h]}f=32768;for(g=this.b;f<g;++f)e[c++]=d[f];this.g=[];return this.buffer=e};
u.prototype.w=function(){var c,d=this.b;s?this.s?(c=new Uint8Array(d),c.set(this.c.subarray(0,d))):c=this.c.subarray(0,d):(this.c.length>d&&(this.c.length=d),c=this.c);return this.buffer=c};function U(c,d){var a,b;this.input=c;this.a=0;if(d||!(d={}))d.index&&(this.a=d.index),d.verify&&(this.B=d.verify);a=c[this.a++];b=c[this.a++];switch(a&15){case V:this.method=V;break;default:throw Error("unsupported compression method");}if(0!==((a<<8)+b)%31)throw Error("invalid fcheck flag:"+((a<<8)+b)%31);if(b&32)throw Error("fdict flag is not supported");this.r=new u(c,{index:this.a,bufferSize:d.bufferSize,bufferType:d.bufferType,resize:d.resize})}
U.prototype.k=function(){var c=this.input,d,a;d=this.r.k();this.a=this.r.a;if(this.B){a=(c[this.a++]<<24|c[this.a++]<<16|c[this.a++]<<8|c[this.a++])>>>0;var b=d;if("string"===typeof b){var e=b.split(""),f,g;f=0;for(g=e.length;f<g;f++)e[f]=(e[f].charCodeAt(0)&255)>>>0;b=e}for(var h=1,k=0,l=b.length,p,n=0;0<l;){p=1024<l?1024:l;l-=p;do h+=b[n++],k+=h;while(--p);h%=65521;k%=65521}if(a!==(k<<16|h)>>>0)throw Error("invalid adler-32 checksum");}return d};var V=8;q("Zlib.Inflate",U);q("Zlib.Inflate.prototype.decompress",U.prototype.k);var W={ADAPTIVE:x.t,BLOCK:x.u},X,Y,Z,$;if(Object.keys)X=Object.keys(W);else for(Y in X=[],Z=0,W)X[Z++]=Y;Z=0;for($=X.length;Z<$;++Z)Y=X[Z],q("Zlib.Inflate.BufferType."+Y,W[Y]);}).call(this);
